authhero 0.2.3 → 0.2.4
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.
- package/dist/authhero.cjs +1 -1
- package/dist/authhero.d.ts +2684 -0
- package/dist/authhero.iife.js +1 -1
- package/dist/authhero.mjs +694 -655
- package/package.json +8 -4
- package/CHANGELOG.md +0 -34
- package/src/hooks/index.ts +0 -29
- package/src/hooks/link-users.ts +0 -31
- package/src/hooks/webhooks.ts +0 -77
- package/src/index.ts +0 -41
- package/src/management-app.ts +0 -55
- package/src/middlewares/register-component.ts +0 -36
- package/src/routes/management-api/tenants.ts +0 -224
- package/src/routes/oauth2/index.ts +0 -1
- package/src/routes/oauth2/well-known.ts +0 -178
- package/src/types/Bindings.ts +0 -12
- package/src/types/Query.ts +0 -42
- package/src/types/Variables.ts +0 -3
- package/src/types/index.ts +0 -3
- package/src/utils/parse-sort.ts +0 -18
- package/src/utils/users.ts +0 -130
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -11
- package/tsconfig.node.json +0 -4
- package/vite.config.ts +0 -41
package/dist/authhero.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ds=Object.defineProperty;var or=n=>{throw TypeError(n)};var us=(n,e,t)=>e in n?ds(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var g=(n,e,t)=>us(n,typeof e!="symbol"?e+"":e,t),cr=(n,e,t)=>e.has(n)||or("Cannot "+t);var m=(n,e,t)=>(cr(n,e,"read from private field"),t?t.call(n):e.get(n)),K=(n,e,t)=>e.has(n)?or("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),A=(n,e,t,r)=>(cr(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function bt(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function C(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function ls(n){return"_def"in n}function gt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function ps(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var i,o,d,u,l,p;const R=typeof s=="string"?a:s,D=R??{},{param:N}=D,j=bt(D,["param"]),V=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),H=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),j),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||N?{param:Object.assign(Object.assign({},(p=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||p===void 0?void 0:p.param),N)}:void 0),ee=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(V).length>0?{_internal:V}:void 0),Object.keys(H).length>0?{metadata:H}:void 0)}));if(C(this,"ZodObject")){const te=this.extend;ee.extend=function(...Re){var ae,ne,X,ge,ie,Ue;const qe=te.apply(this,Re);return qe._def.openapi={_internal:{extendedFrom:!((ne=(ae=this._def.openapi)===null||ae===void 0?void 0:ae._internal)===null||ne===void 0)&&ne.refId?{refId:(ge=(X=this._def.openapi)===null||X===void 0?void 0:X._internal)===null||ge===void 0?void 0:ge.refId,schema:this}:(ie=this._def.openapi)===null||ie===void 0?void 0:ie._internal.extendedFrom},metadata:(Ue=qe._def.openapi)===null||Ue===void 0?void 0:Ue.metadata},qe}}return ee},gt(n,"optional"),gt(n,"nullable"),gt(n,"default"),gt(n,"transform"),gt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var u,l;d._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}function yn(n,e){if(n==null||e===null||e===void 0)return n===e;if(n===e||n.valueOf()===e.valueOf())return!0;if(Array.isArray(n)&&(!Array.isArray(e)||n.length!==e.length)||!(n instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(n);return Object.keys(e).every(r=>t.indexOf(r)!==-1)&&t.every(r=>yn(n[r],e[r]))}class hs{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),r=this.buckets.get(t);if(!r){this.buckets.set(t,[e]);return}r.some(a=>yn(a,e))||r.push(e)}contains(e){const t=this.hashCodeOf(e),r=this.buckets.get(t);return r?r.some(s=>yn(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,r=0;for(const a of this.buckets.values())e+=1,t+=a.length,a.length>1&&(r+=1);const s=e/t;return{totalBuckets:e,collisions:r,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let r=0;r<e.length;r++)t^=this.hashCodeOf(e[r])*r;return t}if(typeof e=="string"){for(let r=0;r<e.length;r++)t^=e.charCodeAt(r)*r;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[r,s]of Object.entries(e))t^=this.hashCodeOf(r)+this.hashCodeOf(s??"");return t}}function jt(n){return n==null}function Zt(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{t[r]=e(s)}),t}function fs(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{e.some(a=>a===r)||(t[r]=s)}),t}function st(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{e(s,r)||(t[r]=s)}),t}function dr(n){return n.filter(e=>!jt(e))}const Hn=yn;function ms(n){const e=new hs;return n.forEach(t=>e.put(t)),[...e.values()]}function wr(n){return typeof n=="string"}class gs{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const r=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:r}),r}registerParameter(e,t){var r,s,a;const i=this.schemaWithRefId(e,t),o=(r=i._def.openapi)===null||r===void 0?void 0:r.metadata,d=i.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(a=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&a!==void 0?a:e})}));return this._definitions.push({type:"parameter",schema:d}),d}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,r){return this._definitions.push({type:"component",componentType:e,name:t,component:r}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class Mn{constructor(e){this.message=e}}class _t extends Mn{constructor(e,t){super(e),this.data=t}}class vn extends Mn{constructor(e){super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``),this.data=e}}function yt(n,e){try{return n()}catch(t){throw t instanceof vn?new vn(Object.assign(Object.assign({},t.data),e)):t}}class _s extends Mn{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class L{static getMetadata(e){var t;const r=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:r._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:r.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:a},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),r=e._def.openapi?e._def.openapi:t._def.openapi;return r==null?void 0:r._internal}static getParamMetadata(e){var t,r;const s=this.unwrapChained(e),a=e._def.openapi?e._def.openapi:s._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:a==null?void 0:a._internal,metadata:Object.assign(Object.assign({},a==null?void 0:a.metadata),{param:Object.assign({description:i},(r=a==null?void 0:a.metadata)===null||r===void 0?void 0:r.param)})}}static buildSchemaMetadata(e){return st(fs(e,["param"]),jt)}static buildParameterMetadata(e){return st(e,jt)}static applySchemaMetadata(e,t){return st(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),jt)}static getRefId(e){var t;return(t=this.getInternalMetadata(e))===null||t===void 0?void 0:t.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){const t=this.unwrapUntil(e,"ZodDefault");return t==null?void 0:t._def.defaultValue()}static unwrapUntil(e,t){return t&&C(e,t)?e:C(e,"ZodOptional")||C(e,"ZodNullable")||C(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):C(e,"ZodDefault")||C(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):C(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):C(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return C(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class ys{transform(e,t,r){var s,a;const i=e._def.type;return Object.assign(Object.assign({},t("array")),{items:r(i),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(a=e._def.maxLength)===null||a===void 0?void 0:a.value})}}class vs{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class bs{transform(e,t,r,s,a){const i=[...e.options.values()],o=i.map(s);return t?{oneOf:r(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(i,e.discriminator,a)}}mapDiscriminator(e,t,r){if(e.some(a=>L.getRefId(a)===void 0))return;const s={};return e.forEach(a=>{var i;const o=L.getRefId(a),d=(i=a.shape)===null||i===void 0?void 0:i[t];if(C(d,"ZodEnum")||C(d,"ZodNativeEnum")){Object.values(d.enum).filter(wr).forEach(p=>{s[p]=r(o)});return}const u=d==null?void 0:d._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=r(o)}),{propertyName:t,mapping:s}}}class ks{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class ws{transform(e,t,r,s){const i={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:r([i],t)}:i}flattenIntersectionTypes(e){if(!C(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),r=this.flattenIntersectionTypes(e._def.right);return[...t,...r]}}class xs{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function Os(n){const t=Object.keys(n).filter(a=>typeof n[n[a]]!="number").map(a=>n[a]),r=t.filter(a=>typeof a=="number").length,s=r===0?"string":r===t.length?"numeric":"mixed";return{values:t,type:s}}class Ts{transform(e,t){const{type:r,values:s}=Os(e._def.values);if(r==="mixed")throw new Mn("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(r==="numeric"?"integer":"string")),{enum:s})}}class js{transform(e,t,r){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),r(e._def.checks))}}class Zs{transform(e,t,r,s){var a;const i=(a=L.getInternalMetadata(e))===null||a===void 0?void 0:a.extendedFrom,o=this.requiredKeysOf(e),d=Zt(e._def.shape(),s);if(!i)return Object.assign(Object.assign(Object.assign(Object.assign({},r("object")),{properties:d,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=i.schema;s(u);const l=this.requiredKeysOf(u),p=Zt(u==null?void 0:u._def.shape(),s),R=Object.fromEntries(Object.entries(d).filter(([j,V])=>!Hn(p[j],V))),D=o.filter(j=>!l.includes(j)),N=Object.assign(Object.assign(Object.assign(Object.assign({},r("object")),{default:t,properties:R}),D.length>0?{required:D}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${i.refId}`},N]}}generateAdditionalProperties(e,t){const r=e._def.unknownKeys,s=e._def.catchall;return C(s,"ZodNever")?r==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,r])=>!L.isOptionalSchema(r)).map(([t,r])=>t)}}class Rs{transform(e,t,r){const s=e._def.valueType,a=e._def.keyType,i=r(s);if(C(a,"ZodEnum")||C(a,"ZodNativeEnum")){const d=Object.values(a.enum).filter(wr).reduce((u,l)=>Object.assign(Object.assign({},u),{[l]:i}),{});return Object.assign(Object.assign({},t("object")),{properties:d})}return Object.assign(Object.assign({},t("object")),{additionalProperties:i})}}class Es{transform(e,t){var r,s,a;const i=this.getZodStringCheck(e,"regex"),o=(r=this.getZodStringCheck(e,"length"))===null||r===void 0?void 0:r.value,d=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(a=e.maxLength)!==null&&a!==void 0?a:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??d,maxLength:o??u,format:this.mapStringFormat(e),pattern:i==null?void 0:i.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(r=>r.kind===t)}}class Ss{constructor(e){this.versionSpecifics=e}transform(e,t,r){const{items:s}=e._def,a=s.map(r);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(a))}}class Cs{transform(e,t,r){const a=this.flattenUnionTypes(e).map(i=>{const o=this.unwrapNullable(i);return r(o)});return{anyOf:t(a)}}flattenUnionTypes(e){return C(e,"ZodUnion")?e._def.options.flatMap(r=>this.flattenUnionTypes(r)):[e]}unwrapNullable(e){return C(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Is{constructor(e){this.versionSpecifics=e,this.objectTransformer=new Zs,this.stringTransformer=new Es,this.numberTransformer=new js,this.bigIntTransformer=new vs,this.literalTransformer=new xs,this.enumTransformer=new ks,this.nativeEnumTransformer=new Ts,this.arrayTransformer=new ys,this.unionTransformer=new Cs,this.discriminatedUnionTransformer=new bs,this.intersectionTransformer=new ws,this.recordTransformer=new Rs,this.tupleTransformer=new Ss(e)}transform(e,t,r,s,a){if(C(e,"ZodNull"))return this.versionSpecifics.nullType;if(C(e,"ZodUnknown")||C(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(C(e,"ZodObject"))return this.objectTransformer.transform(e,a,o=>this.versionSpecifics.mapNullableType(o,t),r);const i=this.transformSchemaWithoutDefault(e,t,r,s);return Object.assign(Object.assign({},i),{default:a})}transformSchemaWithoutDefault(e,t,r,s){if(C(e,"ZodUnknown")||C(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(C(e,"ZodString"))return this.stringTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodNumber"))return this.numberTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),i=>this.versionSpecifics.getNumberChecks(i));if(C(e,"ZodBigInt"))return this.bigIntTransformer.transform(i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(C(e,"ZodLiteral"))return this.literalTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodEnum"))return this.enumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodArray"))return this.arrayTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(C(e,"ZodTuple"))return this.tupleTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(C(e,"ZodUnion"))return this.unionTransformer.transform(e,i=>this.versionSpecifics.mapNullableOfArray(i,t),r);if(C(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),r,s);if(C(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),r);if(C(e,"ZodRecord"))return this.recordTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(C(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const a=L.getRefId(e);throw new _s({currentSchema:e._def,schemaName:a})}}class xr{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Is(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const r={};return this.rawComponents.forEach(({componentType:s,name:a,component:i})=>{var o;(o=r[s])!==null&&o!==void 0||(r[s]={}),r[s][a]=i}),Object.assign(Object.assign({},r),{schemas:Object.assign(Object.assign({},(e=r.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=r.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,r)=>{if(!("type"in t))return"type"in r?-1:0;if(!("type"in r))return 1;const s=e.findIndex(i=>i===t.type),a=e.findIndex(i=>i===r.type);return s-a})}generateSingle(e){if(!("type"in e)){this.generateSchemaWithRef(e);return}switch(e.type){case"parameter":this.generateParameterDefinition(e.schema);return;case"schema":this.generateSchemaWithRef(e.schema);return;case"route":this.generateSingleRoute(e.route);return;case"component":this.rawComponents.push(e);return}}generateParameterDefinition(e){const t=L.getRefId(e),r=this.generateParameter(e);return t&&(this.paramRefs[t]=r),r}getParameterRef(e,t){var r,s,a,i,o;const d=(r=e==null?void 0:e.metadata)===null||r===void 0?void 0:r.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(a=e._internal)===null||a===void 0?void 0:a.refId]:void 0;if(!(!(!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId)||!u)){if(d&&u.in!==d.in||t!=null&&t.in&&u.in!==t.in)throw new _t(`Conflicting location for parameter ${u.name}`,{key:"in",values:dr([u.in,t==null?void 0:t.in,d==null?void 0:d.in])});if(d&&u.name!==d.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new _t("Conflicting names for parameter",{key:"name",values:dr([u.name,t==null?void 0:t.name,d==null?void 0:d.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var r;const s=L.getMetadata(e),a=(r=s==null?void 0:s.metadata)===null||r===void 0?void 0:r.param,i=this.getParameterRef(s,{in:t});if(i)return[i];if(C(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,l])=>{var p,R;const D=L.getMetadata(l),N=this.getParameterRef(D,{in:t,name:u});if(N)return N;const j=(p=D==null?void 0:D.metadata)===null||p===void 0?void 0:p.param;if(j!=null&&j.name&&j.name!==u)throw new _t("Conflicting names for parameter",{key:"name",values:[u,j.name]});if(j!=null&&j.in&&j.in!==t)throw new _t(`Conflicting location for parameter ${(R=j.name)!==null&&R!==void 0?R:u}`,{key:"in",values:[t,j.in]});return this.generateParameter(l.openapi({param:{name:u,in:t}}))})}if(a!=null&&a.in&&a.in!==t)throw new _t(`Conflicting location for parameter ${a.name}`,{key:"in",values:[t,a.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const r=L.getParamMetadata(e),s=(t=r==null?void 0:r.metadata)===null||t===void 0?void 0:t.param,a=!L.isOptionalSchema(e)&&!e.isNullable(),i=this.generateSchemaWithRef(e);return Object.assign({schema:i,required:a},s?L.buildParameterMetadata(s):{})}generateParameter(e){var t;const r=L.getMetadata(e),s=(t=r==null?void 0:r.metadata)===null||t===void 0?void 0:t.param,a=s==null?void 0:s.name,i=s==null?void 0:s.in;if(!a)throw new vn({missingField:"name"});if(!i)throw new vn({missingField:"in",paramName:a});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:i,name:a})}generateSchemaWithMetadata(e){var t;const r=L.unwrapChained(e),s=L.getMetadata(e),a=L.getDefaultValue(e),i=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(r,e.isNullable(),a);return s!=null&&s.metadata?L.applySchemaMetadata(i,s.metadata):st(i,jt)}constructReferencedOpenAPISchema(e){var t;const r=L.getMetadata(e),s=L.unwrapChained(e),a=L.getDefaultValue(e),i=e.isNullable();return!((t=r==null?void 0:r.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(r.metadata.type,i):this.toOpenAPISchema(s,i,a)}generateSimpleSchema(e){var t;const r=L.getMetadata(e),s=L.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const a=this.schemaRefs[s],i={$ref:this.generateSchemaRef(s)},o=st(L.buildSchemaMetadata((t=r==null?void 0:r.metadata)!==null&&t!==void 0?t:{}),(l,p)=>l===void 0||Hn(l,a[p]));if(o.type)return{allOf:[i,o]};const d=st(this.constructReferencedOpenAPISchema(e),(l,p)=>l===void 0||Hn(l,a[p])),u=L.applySchemaMetadata(d,o);return Object.keys(u).length>0?{allOf:[i,u]}:i}generateSchemaWithRef(e){const t=L.getRefId(e),r=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=r,{$ref:this.generateSchemaRef(t)}):r}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,r=bt(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},r),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,r=this.cleanParameter(e.query),s=this.cleanParameter(e.params),a=this.cleanParameter(e.cookies),i=yt(()=>r?this.generateInlineParameters(r,"query"):[],{location:"query"}),o=yt(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),d=yt(()=>a?this.generateInlineParameters(a,"cookie"):[],{location:"cookie"}),u=yt(()=>{if(Array.isArray(t))return t.flatMap(p=>this.generateInlineParameters(p,"header"));const l=this.cleanParameter(t);return l?this.generateInlineParameters(l,"header"):[]},{location:"header"});return[...o,...i,...u,...d]}cleanParameter(e){if(e)return C(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:r,request:s,responses:a}=e,i=bt(e,["method","path","request","responses"]),o=Zt(a,p=>this.getResponse(p)),d=yt(()=>this.getParameters(s),{route:`${t} ${r}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},i),d.length>0?{parameters:[...i.parameters||[],...d]}:{}),u?{requestBody:u}:{}),{responses:o})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){var{content:t,headers:r}=e,s=bt(e,["content","headers"]);const a=t?{content:this.getBodyContent(t)}:{};if(!r)return Object.assign(Object.assign({},s),a);const i=C(r,"ZodObject")?this.getResponseHeaders(r):r;return Object.assign(Object.assign(Object.assign({},s),{headers:i}),a)}getResponseHeaders(e){const t=e._def.shape();return Zt(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return Zt(e,t=>{if(!t||!ls(t.schema))return t;const{schema:r}=t,s=bt(t,["schema"]),a=this.generateSchemaWithRef(r);return Object.assign({schema:a},s)})}toOpenAPISchema(e,t,r){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),r)}}class Ps{get nullType(){return{nullable:!0}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return Object.assign(Object.assign({},e?{type:e}:void 0),t?this.nullType:void 0)}mapTupleItems(e){const t=ms(e);return{items:t.length===1?t[0]:{anyOf:t},minItems:e.length,maxItems:e.length}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{minimum:Number(t.value),exclusiveMinimum:!0};case"max":return t.inclusive?{maximum:Number(t.value)}:{maximum:Number(t.value),exclusiveMaximum:!0};default:return{}}}))}}class Ns{constructor(e){const t=new Ps;this.generator=new xr(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class As{get nullType(){return{type:"null"}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return e?t?{type:Array.isArray(e)?[...e,"null"]:[e,"null"]}:{type:e}:{}}mapTupleItems(e){return{prefixItems:e}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{exclusiveMinimum:Number(t.value)};case"max":return t.inclusive?{maximum:Number(t.value)}:{exclusiveMaximum:Number(t.value)};default:return{}}}))}}function $s(n){return"type"in n&&n.type==="webhook"}class Ms{constructor(e){this.definitions=e,this.webhookRefs={};const t=new As;this.generator=new xr(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter($s).forEach(r=>this.generateSingleWebhook(r.webhook)),Object.assign(Object.assign(Object.assign({},e),t),{webhooks:this.webhookRefs})}generateComponents(){return this.generator.generateComponents()}generateSingleWebhook(e){const t=this.generator.generatePath(e);return this.webhookRefs[e.path]=Object.assign(Object.assign({},this.webhookRefs[e.path]),t),t}}var Or=n=>{const e=n.split("/");return e[0]===""&&e.shift(),e},Ds=n=>{const{groups:e,path:t}=Ls(n),r=Or(t);return Vs(r,e)},Ls=n=>{const e=[];return n=n.replace(/\{[^}]+\}/g,(t,r)=>{const s=`@${r}`;return e.push([s,t]),s}),{groups:e,path:n}},Vs=(n,e)=>{for(let t=e.length-1;t>=0;t--){const[r]=e[t];for(let s=n.length-1;s>=0;s--)if(n[s].includes(r)){n[s]=n[s].replace(r,e[t][1]);break}}return n},hn={},ur=n=>{if(n==="*")return"*";const e=n.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(hn[n]||(e[2]?hn[n]=[n,e[1],new RegExp("^"+e[2]+"$")]:hn[n]=[n,e[1],!0]),hn[n]):null},Us=n=>{try{return decodeURI(n)}catch{return n.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURI(e)}catch{return e}})}},Tr=n=>{const e=n.url,t=e.indexOf("/",8);let r=t;for(;r<e.length;r++){const s=e.charCodeAt(r);if(s===37){const a=e.indexOf("?",r),i=e.slice(t,a===-1?void 0:a);return Us(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}else if(s===63)break}return e.slice(t,r)},qs=n=>{const e=Tr(n);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},Be=(...n)=>{let e="",t=!1;for(let r of n)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),r[0]!=="/"&&(r=`/${r}`),r==="/"&&t?e=`${e}/`:r!=="/"&&(e=`${e}${r}`),r==="/"&&e===""&&(e="/");return e},jr=n=>{if(!n.match(/\:.+\?$/))return null;const e=n.split("/"),t=[];let r="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))r+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&r===""?t.push("/"):t.push(r);const a=s.replace("?","");r+="/"+a,t.push(r)}else r+="/"+s}),t.filter((s,a,i)=>i.indexOf(s)===a)},Un=n=>/[%+]/.test(n)?(n.indexOf("+")!==-1&&(n=n.replace(/\+/g," ")),/%/.test(n)?bn(n):n):n,Zr=(n,e,t)=>{let r;if(!t&&e&&!/[%+]/.test(e)){let i=n.indexOf(`?${e}`,8);for(i===-1&&(i=n.indexOf(`&${e}`,8));i!==-1;){const o=n.charCodeAt(i+e.length+1);if(o===61){const d=i+e.length+2,u=n.indexOf("&",d);return Un(n.slice(d,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";i=n.indexOf(`&${e}`,i+1)}if(r=/[%+]/.test(n),!r)return}const s={};r??(r=/[%+]/.test(n));let a=n.indexOf("?",8);for(;a!==-1;){const i=n.indexOf("&",a+1);let o=n.indexOf("=",a);o>i&&i!==-1&&(o=-1);let d=n.slice(a+1,o===-1?i===-1?void 0:i:o);if(r&&(d=Un(d)),a=i,d==="")continue;let u;o===-1?u="":(u=n.slice(o+1,i===-1?void 0:i),r&&(u=Un(u))),t?(s[d]&&Array.isArray(s[d])||(s[d]=[]),s[d].push(u)):s[d]??(s[d]=u)}return e?s[e]:s},Bs=Zr,Ws=(n,e)=>Zr(n,e,!0),bn=decodeURIComponent,Hs=/^[\w!#$%&'*.^`|~+-]+$/,Fs=/^[ !#-:<-[\]-~]*$/,Ks=(n,e)=>n.trim().split(";").reduce((r,s)=>{s=s.trim();const a=s.indexOf("=");if(a===-1)return r;const i=s.substring(0,a).trim();if(!Hs.test(i))return r;let o=s.substring(a+1).trim();return o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Fs.test(o)&&(r[i]=bn(o)),r},{}),Gs=(n,e,t)=>{const r=n.req.raw.headers.get("Cookie");return r?Ks(r):{}},fn=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});g(this,"res");g(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},zs=(n,e)=>new Response(n,{headers:{"Content-Type":e}}).formData(),Ys=(n,e)=>async(t,r)=>{let s={};const a=t.req.header("Content-Type");switch(n){case"json":if(!a||!/^application\/([a-z-\.]+\+)?json/.test(a)){const o=`Invalid HTTP header: Content-Type=${a}`;throw new fn(400,{message:o})}try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new fn(400,{message:o})}break;case"form":{if(!a)break;if(t.req.bodyCache.formData){s=await t.req.bodyCache.formData;break}try{const o=await t.req.arrayBuffer(),d=await zs(o,a),u={};d.forEach((l,p)=>{p.endsWith("[]")?u[p]===void 0?u[p]=[l]:Array.isArray(u[p])&&u[p].push(l):u[p]=l}),s=u,t.req.bodyCache.formData=d}catch(o){let d="Malformed FormData request.";throw d+=o instanceof Error?` ${o.message}`:` ${String(o)}`,new fn(400,{message:d})}break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,d])=>d.length===1?[o,d[0]]:[o,d]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=Gs(t);break}const i=await e(s,t);if(i instanceof Response)return i;t.req.addValidatedData(n,i),await r()};const Qe=(n,e,t)=>Ys(n,async(r,s)=>{const a=await e.safeParseAsync(r);if(t){const i=await t({data:r,...a},s);if(i){if(i instanceof Response)return i;if("response"in i)return i.response}}return a.success?a.data:s.json(a,400)});var Js=async(n,e=Object.create(null))=>{const{all:t=!1,dot:r=!1}=e,a=(n instanceof Rr?n.raw.headers:n.headers).get("Content-Type");return a!==null&&a.startsWith("multipart/form-data")||a!==null&&a.startsWith("application/x-www-form-urlencoded")?Qs(n,{all:t,dot:r}):{}};async function Qs(n,e){const t=await n.formData();return t?Xs(t,e):{}}function Xs(n,e){const t=Object.create(null);return n.forEach((r,s)=>{e.all||s.endsWith("[]")?ea(t,s,r):t[s]=r}),e.dot&&Object.entries(t).forEach(([r,s])=>{r.includes(".")&&(ta(t,r,s),delete t[r])}),t}var ea=(n,e,t)=>{n[e]!==void 0?Array.isArray(n[e])?n[e].push(t):n[e]=[n[e],t]:n[e]=t},ta=(n,e,t)=>{let r=n;const s=e.split(".");s.forEach((a,i)=>{i===s.length-1?r[a]=t:((!r[a]||typeof r[a]!="object"||Array.isArray(r[a])||r[a]instanceof File)&&(r[a]=Object.create(null)),r=r[a])})},ot,oe,vr,Rr=(vr=class{constructor(n,e="/",t=[[]]){g(this,"raw");K(this,ot);K(this,oe);g(this,"routeIndex",0);g(this,"path");g(this,"bodyCache",{});g(this,"cachedBody",n=>{const{bodyCache:e,raw:t}=this,r=e[n];if(r)return r;const s=Object.keys(e)[0];return s?e[s].then(a=>(s==="json"&&(a=JSON.stringify(a)),new Response(a)[n]())):e[n]=t[n]()});this.raw=n,this.path=e,A(this,oe,t),A(this,ot,{})}param(n){return n?this.getDecodedParam(n):this.getAllDecodedParams()}getDecodedParam(n){const e=m(this,oe)[0][this.routeIndex][1][n],t=this.getParamValue(e);return t?/\%/.test(t)?bn(t):t:void 0}getAllDecodedParams(){const n={},e=Object.keys(m(this,oe)[0][this.routeIndex][1]);for(const t of e){const r=this.getParamValue(m(this,oe)[0][this.routeIndex][1][t]);r&&typeof r=="string"&&(n[t]=/\%/.test(r)?bn(r):r)}return n}getParamValue(n){return m(this,oe)[1]?m(this,oe)[1][n]:n}query(n){return Bs(this.url,n)}queries(n){return Ws(this.url,n)}header(n){if(n)return this.raw.headers.get(n.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,r)=>{e[r]=t}),e}async parseBody(n){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await Js(this,n))}json(){return this.cachedBody("json")}text(){return this.cachedBody("text")}arrayBuffer(){return this.cachedBody("arrayBuffer")}blob(){return this.cachedBody("blob")}formData(){return this.cachedBody("formData")}addValidatedData(n,e){m(this,ot)[n]=e}valid(n){return m(this,ot)[n]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return m(this,oe)[0].map(([[,n]])=>n)}get routePath(){return m(this,oe)[0].map(([[,n]])=>n)[this.routeIndex].path}},ot=new WeakMap,oe=new WeakMap,vr),na={Stringify:1,BeforeStream:2,Stream:3},Er=async(n,e,t,r,s)=>{const a=n.callbacks;return a!=null&&a.length?(s?s[0]+=n:s=[n],Promise.all(a.map(o=>o({phase:e,buffer:s,context:r}))).then(o=>Promise.all(o.filter(Boolean).map(d=>Er(d,e,!1,r,s))).then(()=>s[0]))):Promise.resolve(n)},ra="text/plain; charset=UTF-8",qn=(n,e={})=>(Object.entries(e).forEach(([t,r])=>n.set(t,r)),n),an,on,Ie,He,Oe,U,W,ce,Te,cn,ct,dt,dn,un,br,mn=(br=class{constructor(n,e){K(this,an);K(this,on);g(this,"env",{});K(this,Ie);g(this,"finalized",!1);g(this,"error");K(this,He,200);K(this,Oe);K(this,U);K(this,W);K(this,ce);K(this,Te,!0);K(this,cn);K(this,ct);K(this,dt);K(this,dn);K(this,un);g(this,"render",(...n)=>(m(this,ct)??A(this,ct,e=>this.html(e)),m(this,ct).call(this,...n)));g(this,"setLayout",n=>A(this,cn,n));g(this,"getLayout",()=>m(this,cn));g(this,"setRenderer",n=>{A(this,ct,n)});g(this,"header",(n,e,t)=>{if(e===void 0){m(this,U)?m(this,U).delete(n):m(this,W)&&delete m(this,W)[n.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(n);return}t!=null&&t.append?(m(this,U)||(A(this,Te,!1),A(this,U,new Headers(m(this,W))),A(this,W,{})),m(this,U).append(n,e)):m(this,U)?m(this,U).set(n,e):(m(this,W)??A(this,W,{}),m(this,W)[n.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(n,e):this.res.headers.set(n,e))});g(this,"status",n=>{A(this,Te,!1),A(this,He,n)});g(this,"set",(n,e)=>{m(this,Ie)??A(this,Ie,{}),m(this,Ie)[n]=e});g(this,"get",n=>m(this,Ie)?m(this,Ie)[n]:void 0);g(this,"newResponse",(n,e,t)=>{if(m(this,Te)&&!t&&!e&&m(this,He)===200)return new Response(n,{headers:m(this,W)});if(e&&typeof e!="number"){const s=new Headers(e.headers);m(this,U)&&m(this,U).forEach((i,o)=>{o==="set-cookie"?s.append(o,i):s.set(o,i)});const a=qn(s,m(this,W));return new Response(n,{headers:a,status:e.status??m(this,He)})}const r=typeof e=="number"?e:m(this,He);m(this,W)??A(this,W,{}),m(this,U)??A(this,U,new Headers),qn(m(this,U),m(this,W)),m(this,ce)&&(m(this,ce).headers.forEach((s,a)=>{var i,o;a==="set-cookie"?(i=m(this,U))==null||i.append(a,s):(o=m(this,U))==null||o.set(a,s)}),qn(m(this,U),m(this,W))),t??(t={});for(const[s,a]of Object.entries(t))if(typeof a=="string")m(this,U).set(s,a);else{m(this,U).delete(s);for(const i of a)m(this,U).append(s,i)}return new Response(n,{status:r,headers:m(this,U)})});g(this,"body",(n,e,t)=>typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e));g(this,"text",(n,e,t)=>{if(!m(this,W)){if(m(this,Te)&&!t&&!e)return new Response(n);A(this,W,{})}return m(this,W)["content-type"]=ra,typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)});g(this,"json",(n,e,t)=>{const r=JSON.stringify(n);return m(this,W)??A(this,W,{}),m(this,W)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)});g(this,"html",(n,e,t)=>(m(this,W)??A(this,W,{}),m(this,W)["content-type"]="text/html; charset=UTF-8",typeof n=="object"&&(n instanceof Promise||(n=n.toString()),n instanceof Promise)?n.then(r=>Er(r,na.Stringify,!1,{})).then(r=>typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)):typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)));g(this,"redirect",(n,e)=>(m(this,U)??A(this,U,new Headers),m(this,U).set("Location",n),this.newResponse(null,e??302)));g(this,"notFound",()=>(m(this,dt)??A(this,dt,()=>new Response),m(this,dt).call(this,this)));A(this,an,n),e&&(A(this,Oe,e.executionCtx),this.env=e.env,A(this,dt,e.notFoundHandler),A(this,un,e.path),A(this,dn,e.matchResult))}get req(){return m(this,on)??A(this,on,new Rr(m(this,an),m(this,un),m(this,dn))),m(this,on)}get event(){if(m(this,Oe)&&"respondWith"in m(this,Oe))return m(this,Oe);throw Error("This context has no FetchEvent")}get executionCtx(){if(m(this,Oe))return m(this,Oe);throw Error("This context has no ExecutionContext")}get res(){return A(this,Te,!1),m(this,ce)||A(this,ce,new Response("404 Not Found",{status:404}))}set res(n){if(A(this,Te,!1),m(this,ce)&&n){m(this,ce).headers.delete("content-type");for(const[e,t]of m(this,ce).headers.entries())if(e==="set-cookie"){const r=m(this,ce).headers.getSetCookie();n.headers.delete("set-cookie");for(const s of r)n.headers.append("set-cookie",s)}else n.headers.set(e,t)}A(this,ce,n),this.finalized=!0}get var(){return{...m(this,Ie)}}},an=new WeakMap,on=new WeakMap,Ie=new WeakMap,He=new WeakMap,Oe=new WeakMap,U=new WeakMap,W=new WeakMap,ce=new WeakMap,Te=new WeakMap,cn=new WeakMap,ct=new WeakMap,dt=new WeakMap,dn=new WeakMap,un=new WeakMap,br),lr=(n,e,t)=>(r,s)=>{let a=-1;return i(0);async function i(o){if(o<=a)throw new Error("next() called multiple times");a=o;let d,u=!1,l;if(n[o]?(l=n[o][0][0],r instanceof mn&&(r.req.routeIndex=o)):l=o===n.length&&s||void 0,!l)r instanceof mn&&r.finalized===!1&&t&&(d=await t(r));else try{d=await l(r,()=>i(o+1))}catch(p){if(p instanceof Error&&r instanceof mn&&e)r.error=p,d=await e(p,r),u=!0;else throw p}return d&&(r.finalized===!1||u)&&(r.res=d),r}},F="ALL",sa="all",aa=["get","post","put","delete","options","patch"],Sr="Can not add a route since the matcher is already built.",Cr=class extends Error{},ia=Symbol("composedHandler"),oa=n=>n.text("404 Not Found",404),pr=(n,e)=>"getResponse"in n?n.getResponse():(console.error(n),e.text("Internal Server Error",500)),de,kr,Ir=(kr=class{constructor(e={}){g(this,"get");g(this,"post");g(this,"put");g(this,"delete");g(this,"options");g(this,"patch");g(this,"all");g(this,"on");g(this,"use");g(this,"router");g(this,"getPath");g(this,"_basePath","/");K(this,de,"/");g(this,"routes",[]);g(this,"notFoundHandler",oa);g(this,"errorHandler",pr);g(this,"onError",e=>(this.errorHandler=e,this));g(this,"notFound",e=>(this.notFoundHandler=e,this));g(this,"fetch",(e,...t)=>this.dispatch(e,t[1],t[0],e.method));g(this,"request",(e,t,r,s)=>{if(e instanceof Request)return t!==void 0&&(e=new Request(e,t)),this.fetch(e,r,s);e=e.toString();const a=/^https?:\/\//.test(e)?e:`http://localhost${Be("/",e)}`,i=new Request(a,t);return this.fetch(i,r,s)});g(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(this.dispatch(e.request,e,void 0,e.request.method))})});[...aa,sa].forEach(s=>{this[s]=(a,...i)=>(typeof a=="string"?A(this,de,a):this.addRoute(s,m(this,de),a),i.forEach(o=>{typeof o!="string"&&this.addRoute(s,m(this,de),o)}),this)}),this.on=(s,a,...i)=>{for(const o of[a].flat()){A(this,de,o);for(const d of[s].flat())i.map(u=>{this.addRoute(d.toUpperCase(),m(this,de),u)})}return this},this.use=(s,...a)=>(typeof s=="string"?A(this,de,s):(A(this,de,"*"),a.unshift(s)),a.forEach(i=>{this.addRoute(F,m(this,de),i)}),this);const r=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=r?e.getPath??Tr:qs}clone(){const e=new Ir({router:this.router,getPath:this.getPath});return e.routes=this.routes,e}route(e,t){const r=this.basePath(e);return t.routes.map(s=>{let a;t.errorHandler===pr?a=s.handler:(a=async(i,o)=>(await lr([],t.errorHandler)(i,()=>s.handler(i,o))).res,a[ia]=s.handler),r.addRoute(s.method,s.path,a)}),this}basePath(e){const t=this.clone();return t._basePath=Be(this._basePath,e),t}mount(e,t,r){let s,a;r&&(typeof r=="function"?a=r:(a=r.optionHandler,s=r.replaceRequest));const i=a?d=>{const u=a(d);return Array.isArray(u)?u:[u]}:d=>{let u;try{u=d.executionCtx}catch{}return[d.env,u]};s||(s=(()=>{const d=Be(this._basePath,e),u=d==="/"?0:d.length;return l=>{const p=new URL(l.url);return p.pathname=p.pathname.slice(u)||"/",new Request(p,l)}})());const o=async(d,u)=>{const l=await t(s(d.req.raw),...i(d));if(l)return l;await u()};return this.addRoute(F,Be(e,"*"),o),this}addRoute(e,t,r){e=e.toUpperCase(),t=Be(this._basePath,t);const s={path:t,method:e,handler:r};this.router.add(e,t,[r,s]),this.routes.push(s)}matchRoute(e,t){return this.router.match(e,t)}handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}dispatch(e,t,r,s){if(s==="HEAD")return(async()=>new Response(null,await this.dispatch(e,t,r,"GET")))();const a=this.getPath(e,{env:r}),i=this.matchRoute(s,a),o=new mn(e,{path:a,matchResult:i,env:r,executionCtx:t,notFoundHandler:this.notFoundHandler});if(i[0].length===1){let u;try{u=i[0][0][0][0](o,async()=>{o.res=await this.notFoundHandler(o)})}catch(l){return this.handleError(l,o)}return u instanceof Promise?u.then(l=>l||(o.finalized?o.res:this.notFoundHandler(o))).catch(l=>this.handleError(l,o)):u??this.notFoundHandler(o)}const d=lr(i[0],this.errorHandler,this.notFoundHandler);return(async()=>{try{const u=await d(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.handleError(u,o)}})()}},de=new WeakMap,kr),kn="[^/]+",Rt=".*",Et="(?:|/.*)",kt=Symbol(),ca=new Set(".\\+*[^]$()");function da(n,e){return n.length===1?e.length===1?n<e?-1:1:-1:e.length===1||n===Rt||n===Et?1:e===Rt||e===Et?-1:n===kn?1:e===kn?-1:n.length===e.length?n<e?-1:1:e.length-n.length}var Fn=class{constructor(){g(this,"index");g(this,"varIndex");g(this,"children",Object.create(null))}insert(e,t,r,s,a){if(e.length===0){if(this.index!==void 0)throw kt;if(a)return;this.index=t;return}const[i,...o]=e,d=i==="*"?o.length===0?["","",Rt]:["","",kn]:i==="/*"?["","",Et]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(d){const l=d[1];let p=d[2]||kn;if(l&&d[2]&&(p=p.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(p)))throw kt;if(u=this.children[p],!u){if(Object.keys(this.children).some(R=>R!==Rt&&R!==Et))throw kt;if(a)return;u=this.children[p]=new Fn,l!==""&&(u.varIndex=s.varIndex++)}!a&&l!==""&&r.push([l,u.varIndex])}else if(u=this.children[i],!u){if(Object.keys(this.children).some(l=>l.length>1&&l!==Rt&&l!==Et))throw kt;if(a)return;u=this.children[i]=new Fn}u.insert(o,t,r,s,a)}buildRegExpStr(){const t=Object.keys(this.children).sort(da).map(r=>{const s=this.children[r];return(typeof s.varIndex=="number"?`(${r})@${s.varIndex}`:ca.has(r)?`\\${r}`:r)+s.buildRegExpStr()});return typeof this.index=="number"&&t.unshift(`#${this.index}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},ua=class{constructor(){g(this,"context",{varIndex:0});g(this,"root",new Fn)}insert(n,e,t){const r=[],s=[];for(let i=0;;){let o=!1;if(n=n.replace(/\{[^}]+\}/g,d=>{const u=`@\\${i}`;return s[i]=[u,d],i++,o=!0,u}),!o)break}const a=n.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=s.length-1;i>=0;i--){const[o]=s[i];for(let d=a.length-1;d>=0;d--)if(a[d].indexOf(o)!==-1){a[d]=a[d].replace(o,s[i][1]);break}}return this.root.insert(a,e,r,this.context,t),r}buildRegExp(){let n=this.root.buildRegExpStr();if(n==="")return[/^$/,[],[]];let e=0;const t=[],r=[];return n=n.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,a,i)=>typeof a<"u"?(t[++e]=Number(a),"$()"):(typeof i<"u"&&(r[Number(i)]=++e),"")),[new RegExp(`^${n}`),t,r]}},Pr=[],la=[/^$/,[],Object.create(null)],gn=Object.create(null);function Nr(n){return gn[n]??(gn[n]=new RegExp(n==="*"?"":`^${n.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function pa(){gn=Object.create(null)}function ha(n){var u;const e=new ua,t=[];if(n.length===0)return la;const r=n.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,p],[R,D])=>l?1:R?-1:p.length-D.length),s=Object.create(null);for(let l=0,p=-1,R=r.length;l<R;l++){const[D,N,j]=r[l];D?s[N]=[j.map(([H])=>[H,Object.create(null)]),Pr]:p++;let V;try{V=e.insert(N,p,D)}catch(H){throw H===kt?new Cr(N):H}D||(t[p]=j.map(([H,ee])=>{const te=Object.create(null);for(ee-=1;ee>=0;ee--){const[Re,ae]=V[ee];te[Re]=ae}return[H,te]}))}const[a,i,o]=e.buildRegExp();for(let l=0,p=t.length;l<p;l++)for(let R=0,D=t[l].length;R<D;R++){const N=(u=t[l][R])==null?void 0:u[1];if(!N)continue;const j=Object.keys(N);for(let V=0,H=j.length;V<H;V++)N[j[V]]=o[N[j[V]]]}const d=[];for(const l in i)d[l]=t[i[l]];return[a,d,s]}function Xe(n,e){if(n){for(const t of Object.keys(n).sort((r,s)=>s.length-r.length))if(Nr(t).test(e))return[...n[t]]}}var fa=class{constructor(){g(this,"name","RegExpRouter");g(this,"middleware");g(this,"routes");this.middleware={[F]:Object.create(null)},this.routes={[F]:Object.create(null)}}add(n,e,t){var o;const{middleware:r,routes:s}=this;if(!r||!s)throw new Error(Sr);r[n]||[r,s].forEach(d=>{d[n]=Object.create(null),Object.keys(d[F]).forEach(u=>{d[n][u]=[...d[F][u]]})}),e==="/*"&&(e="*");const a=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const d=Nr(e);n===F?Object.keys(r).forEach(u=>{var l;(l=r[u])[e]||(l[e]=Xe(r[u],e)||Xe(r[F],e)||[])}):(o=r[n])[e]||(o[e]=Xe(r[n],e)||Xe(r[F],e)||[]),Object.keys(r).forEach(u=>{(n===F||n===u)&&Object.keys(r[u]).forEach(l=>{d.test(l)&&r[u][l].push([t,a])})}),Object.keys(s).forEach(u=>{(n===F||n===u)&&Object.keys(s[u]).forEach(l=>d.test(l)&&s[u][l].push([t,a]))});return}const i=jr(e)||[e];for(let d=0,u=i.length;d<u;d++){const l=i[d];Object.keys(s).forEach(p=>{var R;(n===F||n===p)&&((R=s[p])[l]||(R[l]=[...Xe(r[p],l)||Xe(r[F],l)||[]]),s[p][l].push([t,a-u+d+1]))})}}match(n,e){pa();const t=this.buildAllMatchers();return this.match=(r,s)=>{const a=t[r]||t[F],i=a[2][s];if(i)return i;const o=s.match(a[0]);if(!o)return[[],Pr];const d=o.indexOf("",1);return[a[1][d],o]},this.match(n,e)}buildAllMatchers(){const n=Object.create(null);return[...Object.keys(this.routes),...Object.keys(this.middleware)].forEach(e=>{n[e]||(n[e]=this.buildMatcher(e))}),this.middleware=this.routes=void 0,n}buildMatcher(n){const e=[];let t=n===F;return[this.middleware,this.routes].forEach(r=>{const s=r[n]?Object.keys(r[n]).map(a=>[a,r[n][a]]):[];s.length!==0?(t||(t=!0),e.push(...s)):n!==F&&e.push(...Object.keys(r[F]).map(a=>[a,r[F][a]]))}),t?ha(e):null}},ma=class{constructor(n){g(this,"name","SmartRouter");g(this,"routers",[]);g(this,"routes",[]);Object.assign(this,n)}add(n,e,t){if(!this.routes)throw new Error(Sr);this.routes.push([n,e,t])}match(n,e){if(!this.routes)throw new Error("Fatal error");const{routers:t,routes:r}=this,s=t.length;let a=0,i;for(;a<s;a++){const o=t[a];try{r.forEach(d=>{o.add(...d)}),i=o.match(n,e)}catch(d){if(d instanceof Cr)continue;throw d}this.match=o.match.bind(o),this.routers=[o],this.routes=void 0;break}if(a===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.routes||this.routers.length!==1)throw new Error("No active router has been determined yet.");return this.routers[0]}},Ar=class{constructor(n,e,t){g(this,"methods");g(this,"children");g(this,"patterns");g(this,"order",0);g(this,"name");g(this,"params",Object.create(null));if(this.children=t||Object.create(null),this.methods=[],this.name="",n&&e){const r=Object.create(null);r[n]={handler:e,possibleKeys:[],score:0,name:this.name},this.methods=[r]}this.patterns=[]}insert(n,e,t){this.name=`${n} ${e}`,this.order=++this.order;let r=this;const s=Ds(e),a=[];for(let d=0,u=s.length;d<u;d++){const l=s[d];if(Object.keys(r.children).includes(l)){r=r.children[l];const R=ur(l);R&&a.push(R[1]);continue}r.children[l]=new Ar;const p=ur(l);p&&(r.patterns.push(p),a.push(p[1])),r=r.children[l]}r.methods.length||(r.methods=[]);const i=Object.create(null),o={handler:t,possibleKeys:a.filter((d,u,l)=>l.indexOf(d)===u),name:this.name,score:this.order};return i[n]=o,r.methods.push(i),r}gHSets(n,e,t,r){const s=[];for(let a=0,i=n.methods.length;a<i;a++){const o=n.methods[a],d=o[e]||o[F],u=Object.create(null);d!==void 0&&(d.params=Object.create(null),d.possibleKeys.forEach(l=>{const p=u[d.name];d.params[l]=r[l]&&!p?r[l]:t[l]??r[l],u[d.name]=!0}),s.push(d))}return s}search(n,e){const t=[];this.params=Object.create(null);let s=[this];const a=Or(e);for(let o=0,d=a.length;o<d;o++){const u=a[o],l=o===d-1,p=[];for(let R=0,D=s.length;R<D;R++){const N=s[R],j=N.children[u];j&&(j.params=N.params,l===!0?(j.children["*"]&&t.push(...this.gHSets(j.children["*"],n,N.params,Object.create(null))),t.push(...this.gHSets(j,n,N.params,Object.create(null)))):p.push(j));for(let V=0,H=N.patterns.length;V<H;V++){const ee=N.patterns[V],te={...N.params};if(ee==="*"){const ie=N.children["*"];ie&&(t.push(...this.gHSets(ie,n,N.params,Object.create(null))),p.push(ie));continue}if(u==="")continue;const[Re,ae,ne]=ee,X=N.children[Re],ge=a.slice(o).join("/");if(ne instanceof RegExp&&ne.test(ge)){te[ae]=ge,t.push(...this.gHSets(X,n,N.params,te));continue}(ne===!0||ne instanceof RegExp&&ne.test(u))&&typeof Re=="string"&&(te[ae]=u,l===!0?(t.push(...this.gHSets(X,n,te,N.params)),X.children["*"]&&t.push(...this.gHSets(X.children["*"],n,te,N.params))):(X.params=te,p.push(X)))}}s=p}return[t.sort((o,d)=>o.score-d.score).map(({handler:o,params:d})=>[o,d])]}},ga=class{constructor(){g(this,"name","TrieRouter");g(this,"node");this.node=new Ar}add(n,e,t){const r=jr(e);if(r){for(const s of r)this.node.insert(n,s,t);return}this.node.insert(n,e,t)}match(n,e){return this.node.search(n,e)}},_a=class extends Ir{constructor(n={}){super(n),this.router=n.router??new ma({routers:[new fa,new ga]})}},$;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})($||($={}));var Kn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Kn||(Kn={}));const v=$.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Se=n=>{switch(typeof n){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(n)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(n)?v.array:n===null?v.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?v.promise:typeof Map<"u"&&n instanceof Map?v.map:typeof Set<"u"&&n instanceof Set?v.set:typeof Date<"u"&&n instanceof Date?v.date:v.object;default:return v.unknown}},h=$.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"]),ya=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class re extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof re))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}re.create=n=>new re(n);const ut=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===v.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,$.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${$.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${$.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${$.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:$.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,$.assertNever(n)}return{message:t}};let $r=ut;function va(n){$r=n}function wn(){return $r}const xn=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},ba=[];function _(n,e){const t=wn(),r=xn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ut?void 0:ut].filter(s=>!!s)});n.common.issues.push(r)}class z{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return T;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return z.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return T;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const T=Object.freeze({status:"aborted"}),rt=n=>({status:"dirty",value:n}),J=n=>({status:"valid",value:n}),Gn=n=>n.status==="aborted",zn=n=>n.status==="dirty",St=n=>n.status==="valid",Ct=n=>typeof Promise<"u"&&n instanceof Promise;function On(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Mr(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var k;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(k||(k={}));var wt,xt;class ve{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const hr=(n,e)=>{if(St(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new re(n.common.issues);return this._error=t,this._error}}};function E(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var d,u;const{message:l}=n;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(d=l??r)!==null&&d!==void 0?d:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class I{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Se(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new z,ctx:{common:e.parent.common,data:e.data,parsedType:Se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ct(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Se(e)},a=this._parseSync({data:e,path:s.path,parent:s});return hr(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Se(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Ct(s)?s:Promise.resolve(s));return hr(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new fe({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _e.create(this,this._def)}nullable(){return $e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pe.create(this,this._def)}promise(){return pt.create(this,this._def)}or(e){return At.create([this,e],this._def)}and(e){return $t.create(this,e,this._def)}transform(e){return new fe({...E(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ut({...E(this._def),innerType:this,defaultValue:t,typeName:x.ZodDefault})}brand(){return new rr({typeName:x.ZodBranded,type:this,...E(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new qt({...E(this._def),innerType:this,catchValue:t,typeName:x.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ln.create(this,e)}readonly(){return Bt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ka=/^c[^\s-]{8,}$/i,wa=/^[0-9a-z]+$/,xa=/^[0-9A-HJKMNP-TV-Z]{26}$/,Oa=/^[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,Ta=/^[a-z0-9_-]{21}$/i,ja=/^[-+]?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)?)??$/,Za=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ra="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Bn;const Ea=/^(?:(?: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])$/,Sa=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ca=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dr="((\\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])))",Ia=new RegExp(`^${Dr}$`);function Lr(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Pa(n){return new RegExp(`^${Lr(n)}$`)}function Vr(n){let e=`${Dr}T${Lr(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Na(n,e){return!!((e==="v4"||!e)&&Ea.test(n)||(e==="v6"||!e)&&Sa.test(n))}class ue extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_type,expected:v.string,received:a.parsedType}),T}const r=new z;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?_(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&_(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Za.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"email",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Bn||(Bn=new RegExp(Ra,"u")),Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"emoji",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Oa.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"uuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Ta.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"nanoid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")ka.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"cuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")wa.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"cuid2",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")xa.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"ulid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),_(s,{validation:"url",code:h.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"regex",code:h.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Vr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Ia.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Pa(a).test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?ja.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"duration",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Na(e.data,a.version)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"ip",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Ca.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"base64",code:h.invalid_string,message:a.message}),r.dirty()):$.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...k.errToObj(r)})}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...k.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...k.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...k.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new ue({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ue({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ue({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ue.create=n=>{var e;return new ue({checks:[],typeName:x.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...E(n)})};function Aa(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Pe extends I{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)!==v.number){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_type,expected:v.number,received:a.parsedType}),T}let r;const s=new z;for(const a of this._def.checks)a.kind==="int"?$.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Aa(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:h.not_finite,message:a.message}),s.dirty()):$.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,s){return new Pe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(s)}]})}_addCheck(e){return new Pe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&$.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Pe.create=n=>new Pe({checks:[],typeName:x.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...E(n)});class Ne extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==v.bigint){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_type,expected:v.bigint,received:a.parsedType}),T}let r;const s=new z;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):$.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,s){return new Ne({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(s)}]})}_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:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ne.create=n=>{var e;return new Ne({checks:[],typeName:x.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...E(n)})};class It extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.boolean,received:r.parsedType}),T}return J(e.data)}}It.create=n=>new It({typeName:x.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...E(n)});class Ge extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_type,expected:v.date,received:a.parsedType}),T}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_date}),T}const r=new z;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):$.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ge({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ge.create=n=>new Ge({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:x.ZodDate,...E(n)});class Tn extends I{_parse(e){if(this._getType(e)!==v.symbol){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.symbol,received:r.parsedType}),T}return J(e.data)}}Tn.create=n=>new Tn({typeName:x.ZodSymbol,...E(n)});class Pt extends I{_parse(e){if(this._getType(e)!==v.undefined){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.undefined,received:r.parsedType}),T}return J(e.data)}}Pt.create=n=>new Pt({typeName:x.ZodUndefined,...E(n)});class Nt extends I{_parse(e){if(this._getType(e)!==v.null){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.null,received:r.parsedType}),T}return J(e.data)}}Nt.create=n=>new Nt({typeName:x.ZodNull,...E(n)});class lt extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}}lt.create=n=>new lt({typeName:x.ZodAny,...E(n)});class Fe extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}}Fe.create=n=>new Fe({typeName:x.ZodUnknown,...E(n)});class je extends I{_parse(e){const t=this._getOrReturnCtx(e);return _(t,{code:h.invalid_type,expected:v.never,received:t.parsedType}),T}}je.create=n=>new je({typeName:x.ZodNever,...E(n)});class jn extends I{_parse(e){if(this._getType(e)!==v.undefined){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.void,received:r.parsedType}),T}return J(e.data)}}jn.create=n=>new jn({typeName:x.ZodVoid,...E(n)});class pe extends I{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return _(t,{code:h.invalid_type,expected:v.array,received:t.parsedType}),T;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(_(t,{code:i?h.too_big:h.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(_(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(_(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ve(t,i,t.path,o)))).then(i=>z.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ve(t,i,t.path,o)));return z.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new pe({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new pe({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new pe({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}pe.create=(n,e)=>new pe({type:n,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...E(e)});function tt(n){if(n instanceof q){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=_e.create(tt(r))}return new q({...n._def,shape:()=>e})}else return n instanceof pe?new pe({...n._def,type:tt(n.element)}):n instanceof _e?_e.create(tt(n.unwrap())):n instanceof $e?$e.create(tt(n.unwrap())):n instanceof be?be.create(n.items.map(e=>tt(e))):n}class q extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=$.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==v.object){const u=this._getOrReturnCtx(e);return _(u,{code:h.invalid_type,expected:v.object,received:u.parsedType}),T}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof je&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const d=[];for(const u of i){const l=a[u],p=s.data[u];d.push({key:{status:"valid",value:u},value:l._parse(new ve(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof je){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)d.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(_(s,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of o){const p=s.data[l];d.push({key:{status:"valid",value:l},value:u._parse(new ve(s,p,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of d){const p=await l.key,R=await l.value;u.push({key:p,value:R,alwaysSet:l.alwaysSet})}return u}).then(u=>z.mergeObjectSync(r,u)):z.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new q({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=k.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new q({...this._def,unknownKeys:"strip"})}passthrough(){return new q({...this._def,unknownKeys:"passthrough"})}extend(e){return new q({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new q({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new q({...this._def,catchall:e})}pick(e){const t={};return $.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new q({...this._def,shape:()=>t})}omit(e){const t={};return $.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new q({...this._def,shape:()=>t})}deepPartial(){return tt(this)}partial(e){const t={};return $.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new q({...this._def,shape:()=>t})}required(e){const t={};return $.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof _e;)a=a._def.innerType;t[r]=a}}),new q({...this._def,shape:()=>t})}keyof(){return Ur($.objectKeys(this.shape))}}q.create=(n,e)=>new q({shape:()=>n,unknownKeys:"strip",catchall:je.create(),typeName:x.ZodObject,...E(e)});q.strictCreate=(n,e)=>new q({shape:()=>n,unknownKeys:"strict",catchall:je.create(),typeName:x.ZodObject,...E(e)});q.lazycreate=(n,e)=>new q({shape:n,unknownKeys:"strip",catchall:je.create(),typeName:x.ZodObject,...E(e)});class At extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new re(o.ctx.common.issues));return _(t,{code:h.invalid_union,unionErrors:i}),T}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new re(d));return _(t,{code:h.invalid_union,unionErrors:o}),T}}get options(){return this._def.options}}At.create=(n,e)=>new At({options:n,typeName:x.ZodUnion,...E(e)});const xe=n=>n instanceof Dt?xe(n.schema):n instanceof fe?xe(n.innerType()):n instanceof Lt?[n.value]:n instanceof Ae?n.options:n instanceof Vt?$.objectValues(n.enum):n instanceof Ut?xe(n._def.innerType):n instanceof Pt?[void 0]:n instanceof Nt?[null]:n instanceof _e?[void 0,...xe(n.unwrap())]:n instanceof $e?[null,...xe(n.unwrap())]:n instanceof rr||n instanceof Bt?xe(n.unwrap()):n instanceof qt?xe(n._def.innerType):[];class Dn extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return _(t,{code:h.invalid_type,expected:v.object,received:t.parsedType}),T;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(_(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),T)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=xe(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Dn({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...E(r)})}}function Yn(n,e){const t=Se(n),r=Se(e);if(n===e)return{valid:!0,data:n};if(t===v.object&&r===v.object){const s=$.objectKeys(e),a=$.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i={...n,...e};for(const o of a){const d=Yn(n[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===v.array&&r===v.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],d=Yn(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===v.date&&r===v.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class $t extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(Gn(a)||Gn(i))return T;const o=Yn(a.value,i.value);return o.valid?((zn(a)||zn(i))&&t.dirty(),{status:t.value,value:o.data}):(_(r,{code:h.invalid_intersection_types}),T)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}$t.create=(n,e,t)=>new $t({left:n,right:e,typeName:x.ZodIntersection,...E(t)});class be extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.array)return _(r,{code:h.invalid_type,expected:v.array,received:r.parsedType}),T;if(r.data.length<this._def.items.length)return _(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;!this._def.rest&&r.data.length>this._def.items.length&&(_(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new ve(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>z.mergeArray(t,i)):z.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new be({...this._def,rest:e})}}be.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new be({items:n,typeName:x.ZodTuple,rest:null,...E(e)})};class Mt extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return _(r,{code:h.invalid_type,expected:v.object,received:r.parsedType}),T;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ve(r,o,r.path,o)),value:i._parse(new ve(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?z.mergeObjectAsync(t,s):z.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof I?new Mt({keyType:e,valueType:t,typeName:x.ZodRecord,...E(r)}):new Mt({keyType:ue.create(),valueType:e,typeName:x.ZodRecord,...E(t)})}}class Zn extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.map)return _(r,{code:h.invalid_type,expected:v.map,received:r.parsedType}),T;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],u)=>({key:s._parse(new ve(r,o,r.path,[u,"key"])),value:a._parse(new ve(r,d,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return T;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return T;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}Zn.create=(n,e,t)=>new Zn({valueType:e,keyType:n,typeName:x.ZodMap,...E(t)});class ze extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.set)return _(r,{code:h.invalid_type,expected:v.set,received:r.parsedType}),T;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(_(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(_(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const l of d){if(l.status==="aborted")return T;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((d,u)=>a._parse(new ve(r,d,r.path,u)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new ze({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new ze({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ze.create=(n,e)=>new ze({valueType:n,minSize:null,maxSize:null,typeName:x.ZodSet,...E(e)});class at extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return _(t,{code:h.invalid_type,expected:v.function,received:t.parsedType}),T;function r(o,d){return xn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,wn(),ut].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:d}})}function s(o,d){return xn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,wn(),ut].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof pt){const o=this;return J(async function(...d){const u=new re([]),l=await o._def.args.parseAsync(d,a).catch(D=>{throw u.addIssue(r(d,D)),u}),p=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(p,a).catch(D=>{throw u.addIssue(s(p,D)),u})})}else{const o=this;return J(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new re([r(d,u.error)]);const l=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(l,a);if(!p.success)throw new re([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new at({...this._def,args:be.create(e).rest(Fe.create())})}returns(e){return new at({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new at({args:e||be.create([]).rest(Fe.create()),returns:t||Fe.create(),typeName:x.ZodFunction,...E(r)})}}class Dt extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Dt.create=(n,e)=>new Dt({getter:n,typeName:x.ZodLazy,...E(e)});class Lt extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}Lt.create=(n,e)=>new Lt({value:n,typeName:x.ZodLiteral,...E(e)});function Ur(n,e){return new Ae({values:n,typeName:x.ZodEnum,...E(e)})}class Ae extends I{constructor(){super(...arguments),wt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{expected:$.joinValues(r),received:t.parsedType,code:h.invalid_type}),T}if(On(this,wt)||Mr(this,wt,new Set(this._def.values)),!On(this,wt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{received:t.data,code:h.invalid_enum_value,options:r}),T}return J(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ae.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ae.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}wt=new WeakMap;Ae.create=Ur;class Vt extends I{constructor(){super(...arguments),xt.set(this,void 0)}_parse(e){const t=$.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==v.string&&r.parsedType!==v.number){const s=$.objectValues(t);return _(r,{expected:$.joinValues(s),received:r.parsedType,code:h.invalid_type}),T}if(On(this,xt)||Mr(this,xt,new Set($.getValidEnumValues(this._def.values))),!On(this,xt).has(e.data)){const s=$.objectValues(t);return _(r,{received:r.data,code:h.invalid_enum_value,options:s}),T}return J(e.data)}get enum(){return this._def.values}}xt=new WeakMap;Vt.create=(n,e)=>new Vt({values:n,typeName:x.ZodNativeEnum,...E(e)});class pt extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return _(t,{code:h.invalid_type,expected:v.promise,received:t.parsedType}),T;const r=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return J(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}pt.create=(n,e)=>new pt({type:n,typeName:x.ZodPromise,...E(e)});class fe extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{_(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return T;const d=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return d.status==="aborted"?T:d.status==="dirty"||t.value==="dirty"?rt(d.value):d});{if(t.value==="aborted")return T;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?T:o.status==="dirty"||t.value==="dirty"?rt(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?T:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?T:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!St(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>St(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);$.assertNever(s)}}fe.create=(n,e,t)=>new fe({schema:n,typeName:x.ZodEffects,effect:e,...E(t)});fe.createWithPreprocess=(n,e,t)=>new fe({schema:e,effect:{type:"preprocess",transform:n},typeName:x.ZodEffects,...E(t)});class _e extends I{_parse(e){return this._getType(e)===v.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_e.create=(n,e)=>new _e({innerType:n,typeName:x.ZodOptional,...E(e)});class $e extends I{_parse(e){return this._getType(e)===v.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$e.create=(n,e)=>new $e({innerType:n,typeName:x.ZodNullable,...E(e)});class Ut extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===v.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ut.create=(n,e)=>new Ut({innerType:n,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...E(e)});class qt extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ct(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}qt.create=(n,e)=>new qt({innerType:n,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...E(e)});class Rn extends I{_parse(e){if(this._getType(e)!==v.nan){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.nan,received:r.parsedType}),T}return{status:"valid",value:e.data}}}Rn.create=n=>new Rn({typeName:x.ZodNaN,...E(n)});const $a=Symbol("zod_brand");class rr extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ln extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?T:a.status==="dirty"?(t.dirty(),rt(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?T:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ln({in:e,out:t,typeName:x.ZodPipeline})}}class Bt extends I{_parse(e){const t=this._def.innerType._parse(e),r=s=>(St(s)&&(s.value=Object.freeze(s.value)),s);return Ct(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}Bt.create=(n,e)=>new Bt({innerType:n,typeName:x.ZodReadonly,...E(e)});function qr(n,e={},t){return n?lt.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:d})}}):lt.create()}const Ma={object:q.lazycreate};var x;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(x||(x={}));const Da=(n,e={message:`Input not instance of ${n.name}`})=>qr(t=>t instanceof n,e),Br=ue.create,Wr=Pe.create,La=Rn.create,Va=Ne.create,Hr=It.create,Ua=Ge.create,qa=Tn.create,Ba=Pt.create,Wa=Nt.create,Ha=lt.create,Fa=Fe.create,Ka=je.create,Ga=jn.create,za=pe.create,Ya=q.create,Ja=q.strictCreate,Qa=At.create,Xa=Dn.create,ei=$t.create,ti=be.create,ni=Mt.create,ri=Zn.create,si=ze.create,ai=at.create,ii=Dt.create,oi=Lt.create,ci=Ae.create,di=Vt.create,ui=pt.create,fr=fe.create,li=_e.create,pi=$e.create,hi=fe.createWithPreprocess,fi=ln.create,mi=()=>Br().optional(),gi=()=>Wr().optional(),_i=()=>Hr().optional(),yi={string:n=>ue.create({...n,coerce:!0}),number:n=>Pe.create({...n,coerce:!0}),boolean:n=>It.create({...n,coerce:!0}),bigint:n=>Ne.create({...n,coerce:!0}),date:n=>Ge.create({...n,coerce:!0})},vi=T;var G=Object.freeze({__proto__:null,defaultErrorMap:ut,setErrorMap:va,getErrorMap:wn,makeIssue:xn,EMPTY_PATH:ba,addIssueToContext:_,ParseStatus:z,INVALID:T,DIRTY:rt,OK:J,isAborted:Gn,isDirty:zn,isValid:St,isAsync:Ct,get util(){return $},get objectUtil(){return Kn},ZodParsedType:v,getParsedType:Se,ZodType:I,datetimeRegex:Vr,ZodString:ue,ZodNumber:Pe,ZodBigInt:Ne,ZodBoolean:It,ZodDate:Ge,ZodSymbol:Tn,ZodUndefined:Pt,ZodNull:Nt,ZodAny:lt,ZodUnknown:Fe,ZodNever:je,ZodVoid:jn,ZodArray:pe,ZodObject:q,ZodUnion:At,ZodDiscriminatedUnion:Dn,ZodIntersection:$t,ZodTuple:be,ZodRecord:Mt,ZodMap:Zn,ZodSet:ze,ZodFunction:at,ZodLazy:Dt,ZodLiteral:Lt,ZodEnum:Ae,ZodNativeEnum:Vt,ZodPromise:pt,ZodEffects:fe,ZodTransformer:fe,ZodOptional:_e,ZodNullable:$e,ZodDefault:Ut,ZodCatch:qt,ZodNaN:Rn,BRAND:$a,ZodBranded:rr,ZodPipeline:ln,ZodReadonly:Bt,custom:qr,Schema:I,ZodSchema:I,late:Ma,get ZodFirstPartyTypeKind(){return x},coerce:yi,any:Ha,array:za,bigint:Va,boolean:Hr,date:Ua,discriminatedUnion:Xa,effect:fr,enum:ci,function:ai,instanceof:Da,intersection:ei,lazy:ii,literal:oi,map:ri,nan:La,nativeEnum:di,never:Ka,null:Wa,nullable:pi,number:Wr,object:Ya,oboolean:_i,onumber:gi,optional:li,ostring:mi,pipeline:fi,preprocess:hi,promise:ui,record:ni,set:si,strictObject:Ja,string:Br,symbol:qa,transformer:fr,tuple:ti,undefined:Ba,union:Qa,unknown:Fa,void:Ga,NEVER:vi,ZodIssueCode:h,quotelessJson:ya,ZodError:re}),Wt=class Jn extends _a{constructor(t){super(t);g(this,"openAPIRegistry");g(this,"defaultHook");g(this,"openapi",({middleware:t,...r},s,a=this.defaultHook)=>{var u,l,p,R,D,N;this.openAPIRegistry.registerPath(r);const i=[];if((u=r.request)!=null&&u.query){const j=Qe("query",r.request.query,a);i.push(j)}if((l=r.request)!=null&&l.params){const j=Qe("param",r.request.params,a);i.push(j)}if((p=r.request)!=null&&p.headers){const j=Qe("header",r.request.headers,a);i.push(j)}if((R=r.request)!=null&&R.cookies){const j=Qe("cookie",r.request.cookies,a);i.push(j)}const o=(N=(D=r.request)==null?void 0:D.body)==null?void 0:N.content;if(o)for(const j of Object.keys(o)){if(!o[j])continue;const V=o[j].schema;if(V instanceof I){if(j.startsWith("application/json")){const H=Qe("json",V,a);i.push(H)}if(j.startsWith("multipart/form-data")||j.startsWith("application/x-www-form-urlencoded")){const H=Qe("form",V,a);i.push(H)}}}const d=t?Array.isArray(t)?t:[t]:[];return this.on([r.method],r.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...d,...i,s),this});g(this,"getOpenAPIDocument",t=>new Ns(this.openAPIRegistry.definitions).generateDocument(t));g(this,"getOpenAPI31Document",t=>new Ms(this.openAPIRegistry.definitions).generateDocument(t));g(this,"doc",(t,r)=>this.get(t,s=>{const a=typeof r=="function"?r(s):r;try{const i=this.getOpenAPIDocument(a);return s.json(i)}catch(i){return s.json(i,500)}}));g(this,"doc31",(t,r)=>this.get(t,s=>{const a=typeof r=="function"?r(s):r;try{const i=this.getOpenAPI31Document(a);return s.json(i)}catch(i){return s.json(i,500)}}));this.openAPIRegistry=new gs,this.defaultHook=t==null?void 0:t.defaultHook}route(t,r){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,r),r instanceof Jn?(r.openAPIRegistry.definitions.forEach(a=>{switch(a.type){case"component":return this.openAPIRegistry.registerComponent(a.componentType,a.name,a.component);case"route":return this.openAPIRegistry.registerPath({...a.route,path:Be(s,a.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...a.webhook,path:Be(s,a.webhook.path)});case"schema":return this.openAPIRegistry.register(a.schema._def.openapi._internal.refId,a.schema);case"parameter":return this.openAPIRegistry.registerParameter(a.schema._def.openapi._internal.refId,a.schema);default:{const i=a;throw new Error(`Unknown registry type: ${i}`)}}}),this):this}basePath(t){return new Jn({...super.basePath(t),defaultHook:this.defaultHook})}},We=n=>{const e={...n,getRoutingPath(){return n.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};ps(G);function bi(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function ki(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function vt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function wi(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var i,o,d,u,l,p;const R=typeof s=="string"?a:s,D=R??{},{param:N}=D,j=bi(D,["param"]),V=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),H=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),j),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||N?{param:Object.assign(Object.assign({},(p=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||p===void 0?void 0:p.param),N)}:void 0),ee=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(V).length>0?{_internal:V}:void 0),Object.keys(H).length>0?{metadata:H}:void 0)}));if(ki(this,"ZodObject")){const te=this.extend;ee.extend=function(...Re){var ae,ne,X,ge,ie,Ue;const qe=te.apply(this,Re);return qe._def.openapi={_internal:{extendedFrom:!((ne=(ae=this._def.openapi)===null||ae===void 0?void 0:ae._internal)===null||ne===void 0)&&ne.refId?{refId:(ge=(X=this._def.openapi)===null||X===void 0?void 0:X._internal)===null||ge===void 0?void 0:ge.refId,schema:this}:(ie=this._def.openapi)===null||ie===void 0?void 0:ie._internal.extendedFrom},metadata:(Ue=qe._def.openapi)===null||Ue===void 0?void 0:Ue.metadata},qe}}return ee},vt(n,"optional"),vt(n,"nullable"),vt(n,"default"),vt(n,"transform"),vt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var u,l;d._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var M;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(M||(M={}));var Qn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Qn||(Qn={}));const b=M.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ce=n=>{switch(typeof n){case"undefined":return b.undefined;case"string":return b.string;case"number":return isNaN(n)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(n)?b.array:n===null?b.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?b.promise:typeof Map<"u"&&n instanceof Map?b.map:typeof Set<"u"&&n instanceof Set?b.set:typeof Date<"u"&&n instanceof Date?b.date:b.object;default:return b.unknown}},f=M.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"]),xi=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class se extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof se))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,M.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}se.create=n=>new se(n);const ht=(n,e)=>{let t;switch(n.code){case f.invalid_type:n.received===b.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,M.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${M.joinValues(n.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${M.joinValues(n.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${M.joinValues(n.options)}, received '${n.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:M.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case f.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case f.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,M.assertNever(n)}return{message:t}};let Fr=ht;function Oi(n){Fr=n}function En(){return Fr}const Sn=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},Ti=[];function y(n,e){const t=En(),r=Sn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ht?void 0:ht].filter(s=>!!s)});n.common.issues.push(r)}class Y{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return Z;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return Y.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return Z;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const Z=Object.freeze({status:"aborted"}),Cn=n=>({status:"dirty",value:n}),Q=n=>({status:"valid",value:n}),Xn=n=>n.status==="aborted",er=n=>n.status==="dirty",Ht=n=>n.status==="valid",Ft=n=>typeof Promise<"u"&&n instanceof Promise;function In(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Kr(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var w;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Ot,Tt;class ke{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const mr=(n,e)=>{if(Ht(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new se(n.common.issues);return this._error=t,this._error}}};function S(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>{var o,d;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??i.defaultError}:typeof i.data>"u"?{message:(o=u??r)!==null&&o!==void 0?o:i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:(d=u??t)!==null&&d!==void 0?d:i.defaultError}},description:s}}class P{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ce(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Y,ctx:{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ft(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},a=this._parseSync({data:e,path:s.path,parent:s});return mr(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Ft(s)?s:Promise.resolve(s));return mr(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:f.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new me({schema:this,typeName:O.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ye.create(this,this._def)}nullable(){return Ve.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return he.create(this,this._def)}promise(){return mt.create(this,this._def)}or(e){return Yt.create([this,e],this._def)}and(e){return Jt.create(this,e,this._def)}transform(e){return new me({...S(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new nn({...S(this._def),innerType:this,defaultValue:t,typeName:O.ZodDefault})}brand(){return new sr({typeName:O.ZodBranded,type:this,...S(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new rn({...S(this._def),innerType:this,catchValue:t,typeName:O.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pn.create(this,e)}readonly(){return sn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ji=/^c[^\s-]{8,}$/i,Zi=/^[0-9a-z]+$/,Ri=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ei=/^[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,Si=/^[a-z0-9_-]{21}$/i,Ci=/^[-+]?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)?)??$/,Ii=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wn;const Ni=/^(?:(?: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])$/,Ai=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,$i=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gr="((\\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])))",Mi=new RegExp(`^${Gr}$`);function zr(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Di(n){return new RegExp(`^${zr(n)}$`)}function Yr(n){let e=`${Gr}T${zr(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Li(n,e){return!!((e==="v4"||!e)&&Ni.test(n)||(e==="v6"||!e)&&Ai.test(n))}class le extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_type,expected:b.string,received:s.parsedType}),Z}const t=new Y;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:f.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:f.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(r=this._getOrReturnCtx(e,r),a?y(r,{code:f.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&y(r,{code:f.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Ii.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"email",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Wn||(Wn=new RegExp(Pi,"u")),Wn.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"emoji",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Ei.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"uuid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")Si.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"nanoid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")ji.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"cuid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")Zi.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"cuid2",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Ri.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"ulid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),y(r,{validation:"url",code:f.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"regex",code:f.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?Yr(s).test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Mi.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Di(s).test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?Ci.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"duration",code:f.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Li(e.data,s.version)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"ip",code:f.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?$i.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"base64",code:f.invalid_string,message:s.message}),t.dirty()):M.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:f.invalid_string,...w.errToObj(r)})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...w.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...w.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}le.create=n=>{var e;return new le({checks:[],typeName:O.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};function Vi(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Me extends P{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)!==b.number){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_type,expected:b.number,received:s.parsedType}),Z}let t;const r=new Y;for(const s of this._def.checks)s.kind==="int"?M.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),y(t,{code:f.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?Vi(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),y(t,{code:f.not_finite,message:s.message}),r.dirty()):M.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new Me({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new Me({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&M.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Me.create=n=>new Me({checks:[],typeName:O.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class De extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==b.bigint){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_type,expected:b.bigint,received:s.parsedType}),Z}let t;const r=new Y;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):M.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new De({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}De.create=n=>{var e;return new De({checks:[],typeName:O.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};class Kt extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.boolean,received:t.parsedType}),Z}return Q(e.data)}}Kt.create=n=>new Kt({typeName:O.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Ye extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_type,expected:b.date,received:s.parsedType}),Z}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_date}),Z}const t=new Y;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:f.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:f.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):M.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ye({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ye.create=n=>new Ye({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:O.ZodDate,...S(n)});class Pn extends P{_parse(e){if(this._getType(e)!==b.symbol){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.symbol,received:t.parsedType}),Z}return Q(e.data)}}Pn.create=n=>new Pn({typeName:O.ZodSymbol,...S(n)});class Gt extends P{_parse(e){if(this._getType(e)!==b.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.undefined,received:t.parsedType}),Z}return Q(e.data)}}Gt.create=n=>new Gt({typeName:O.ZodUndefined,...S(n)});class zt extends P{_parse(e){if(this._getType(e)!==b.null){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.null,received:t.parsedType}),Z}return Q(e.data)}}zt.create=n=>new zt({typeName:O.ZodNull,...S(n)});class ft extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return Q(e.data)}}ft.create=n=>new ft({typeName:O.ZodAny,...S(n)});class Ke extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Q(e.data)}}Ke.create=n=>new Ke({typeName:O.ZodUnknown,...S(n)});class Ze extends P{_parse(e){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.never,received:t.parsedType}),Z}}Ze.create=n=>new Ze({typeName:O.ZodNever,...S(n)});class Nn extends P{_parse(e){if(this._getType(e)!==b.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.void,received:t.parsedType}),Z}return Q(e.data)}}Nn.create=n=>new Nn({typeName:O.ZodVoid,...S(n)});class he extends P{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==b.array)return y(t,{code:f.invalid_type,expected:b.array,received:t.parsedType}),Z;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(y(t,{code:i?f.too_big:f.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(y(t,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(y(t,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ke(t,i,t.path,o)))).then(i=>Y.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ke(t,i,t.path,o)));return Y.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new he({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new he({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new he({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}he.create=(n,e)=>new he({type:n,minLength:null,maxLength:null,exactLength:null,typeName:O.ZodArray,...S(e)});function nt(n){if(n instanceof B){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=ye.create(nt(r))}return new B({...n._def,shape:()=>e})}else return n instanceof he?new he({...n._def,type:nt(n.element)}):n instanceof ye?ye.create(nt(n.unwrap())):n instanceof Ve?Ve.create(nt(n.unwrap())):n instanceof we?we.create(n.items.map(e=>nt(e))):n}class B extends P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=M.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==b.object){const d=this._getOrReturnCtx(e);return y(d,{code:f.invalid_type,expected:b.object,received:d.parsedType}),Z}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ze&&this._def.unknownKeys==="strip"))for(const d in r.data)a.includes(d)||i.push(d);const o=[];for(const d of a){const u=s[d],l=r.data[d];o.push({key:{status:"valid",value:d},value:u._parse(new ke(r,l,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof Ze){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of i)o.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")i.length>0&&(y(r,{code:f.unrecognized_keys,keys:i}),t.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of i){const l=r.data[u];o.push({key:{status:"valid",value:u},value:d._parse(new ke(r,l,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of o){const l=await u.key,p=await u.value;d.push({key:l,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>Y.mergeObjectSync(t,d)):Y.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new B({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=w.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new B({...this._def,unknownKeys:"strip"})}passthrough(){return new B({...this._def,unknownKeys:"passthrough"})}extend(e){return new B({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new B({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:O.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new B({...this._def,catchall:e})}pick(e){const t={};return M.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new B({...this._def,shape:()=>t})}omit(e){const t={};return M.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new B({...this._def,shape:()=>t})}deepPartial(){return nt(this)}partial(e){const t={};return M.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new B({...this._def,shape:()=>t})}required(e){const t={};return M.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof ye;)s=s._def.innerType;t[r]=s}}),new B({...this._def,shape:()=>t})}keyof(){return Jr(M.objectKeys(this.shape))}}B.create=(n,e)=>new B({shape:()=>n,unknownKeys:"strip",catchall:Ze.create(),typeName:O.ZodObject,...S(e)});B.strictCreate=(n,e)=>new B({shape:()=>n,unknownKeys:"strict",catchall:Ze.create(),typeName:O.ZodObject,...S(e)});B.lazycreate=(n,e)=>new B({shape:n,unknownKeys:"strip",catchall:Ze.create(),typeName:O.ZodObject,...S(e)});class Yt extends P{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new se(o.ctx.common.issues));return y(t,{code:f.invalid_union,unionErrors:i}),Z}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new se(d));return y(t,{code:f.invalid_union,unionErrors:o}),Z}}get options(){return this._def.options}}Yt.create=(n,e)=>new Yt({options:n,typeName:O.ZodUnion,...S(e)});const Ee=n=>n instanceof Xt?Ee(n.schema):n instanceof me?Ee(n.innerType()):n instanceof en?[n.value]:n instanceof Le?n.options:n instanceof tn?M.objectValues(n.enum):n instanceof nn?Ee(n._def.innerType):n instanceof Gt?[void 0]:n instanceof zt?[null]:n instanceof ye?[void 0,...Ee(n.unwrap())]:n instanceof Ve?[null,...Ee(n.unwrap())]:n instanceof sr||n instanceof sn?Ee(n.unwrap()):n instanceof rn?Ee(n._def.innerType):[];class Ln extends P{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.object)return y(t,{code:f.invalid_type,expected:b.object,received:t.parsedType}),Z;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(y(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=Ee(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Ln({typeName:O.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...S(r)})}}function tr(n,e){const t=Ce(n),r=Ce(e);if(n===e)return{valid:!0,data:n};if(t===b.object&&r===b.object){const s=M.objectKeys(e),a=M.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i={...n,...e};for(const o of a){const d=tr(n[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===b.array&&r===b.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],d=tr(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===b.date&&r===b.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Jt extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(Xn(a)||Xn(i))return Z;const o=tr(a.value,i.value);return o.valid?((er(a)||er(i))&&t.dirty(),{status:t.value,value:o.data}):(y(r,{code:f.invalid_intersection_types}),Z)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Jt.create=(n,e,t)=>new Jt({left:n,right:e,typeName:O.ZodIntersection,...S(t)});class we extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.array)return y(r,{code:f.invalid_type,expected:b.array,received:r.parsedType}),Z;if(r.data.length<this._def.items.length)return y(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Z;!this._def.rest&&r.data.length>this._def.items.length&&(y(r,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new ke(r,a,r.path,i)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>Y.mergeArray(t,a)):Y.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new we({...this._def,rest:e})}}we.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new we({items:n,typeName:O.ZodTuple,rest:null,...S(e)})};class Qt extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.object)return y(r,{code:f.invalid_type,expected:b.object,received:r.parsedType}),Z;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ke(r,o,r.path,o)),value:i._parse(new ke(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?Y.mergeObjectAsync(t,s):Y.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof P?new Qt({keyType:e,valueType:t,typeName:O.ZodRecord,...S(r)}):new Qt({keyType:le.create(),valueType:e,typeName:O.ZodRecord,...S(t)})}}class An extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.map)return y(r,{code:f.invalid_type,expected:b.map,received:r.parsedType}),Z;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],u)=>({key:s._parse(new ke(r,o,r.path,[u,"key"])),value:a._parse(new ke(r,d,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return Z;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return Z;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}An.create=(n,e,t)=>new An({valueType:e,keyType:n,typeName:O.ZodMap,...S(t)});class Je extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.set)return y(r,{code:f.invalid_type,expected:b.set,received:r.parsedType}),Z;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(y(r,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(y(r,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const l of d){if(l.status==="aborted")return Z;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((d,u)=>a._parse(new ke(r,d,r.path,u)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new Je({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Je({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Je.create=(n,e)=>new Je({valueType:n,minSize:null,maxSize:null,typeName:O.ZodSet,...S(e)});class it extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.function)return y(t,{code:f.invalid_type,expected:b.function,received:t.parsedType}),Z;function r(o,d){return Sn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,En(),ht].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:d}})}function s(o,d){return Sn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,En(),ht].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof mt){const o=this;return Q(async function(...d){const u=new se([]),l=await o._def.args.parseAsync(d,a).catch(R=>{throw u.addIssue(r(d,R)),u}),p=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(p,a).catch(R=>{throw u.addIssue(s(p,R)),u})})}else{const o=this;return Q(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new se([r(d,u.error)]);const l=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(l,a);if(!p.success)throw new se([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new it({...this._def,args:we.create(e).rest(Ke.create())})}returns(e){return new it({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new it({args:e||we.create([]).rest(Ke.create()),returns:t||Ke.create(),typeName:O.ZodFunction,...S(r)})}}class Xt extends P{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Xt.create=(n,e)=>new Xt({getter:n,typeName:O.ZodLazy,...S(e)});class en extends P{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return y(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:e.data}}get value(){return this._def.value}}en.create=(n,e)=>new en({value:n,typeName:O.ZodLiteral,...S(e)});function Jr(n,e){return new Le({values:n,typeName:O.ZodEnum,...S(e)})}class Le extends P{constructor(){super(...arguments),Ot.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return y(t,{expected:M.joinValues(r),received:t.parsedType,code:f.invalid_type}),Z}if(In(this,Ot)||Kr(this,Ot,new Set(this._def.values)),!In(this,Ot).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return y(t,{received:t.data,code:f.invalid_enum_value,options:r}),Z}return Q(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Le.create(e,{...this._def,...t})}exclude(e,t=this._def){return Le.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Ot=new WeakMap;Le.create=Jr;class tn extends P{constructor(){super(...arguments),Tt.set(this,void 0)}_parse(e){const t=M.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==b.string&&r.parsedType!==b.number){const s=M.objectValues(t);return y(r,{expected:M.joinValues(s),received:r.parsedType,code:f.invalid_type}),Z}if(In(this,Tt)||Kr(this,Tt,new Set(M.getValidEnumValues(this._def.values))),!In(this,Tt).has(e.data)){const s=M.objectValues(t);return y(r,{received:r.data,code:f.invalid_enum_value,options:s}),Z}return Q(e.data)}get enum(){return this._def.values}}Tt=new WeakMap;tn.create=(n,e)=>new tn({values:n,typeName:O.ZodNativeEnum,...S(e)});class mt extends P{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.promise&&t.common.async===!1)return y(t,{code:f.invalid_type,expected:b.promise,received:t.parsedType}),Z;const r=t.parsedType===b.promise?t.data:Promise.resolve(t.data);return Q(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}mt.create=(n,e)=>new mt({type:n,typeName:O.ZodPromise,...S(e)});class me extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===O.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{y(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return Z;const d=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return d.status==="aborted"?Z:d.status==="dirty"||t.value==="dirty"?Cn(d.value):d});{if(t.value==="aborted")return Z;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?Z:o.status==="dirty"||t.value==="dirty"?Cn(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Z:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?Z:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ht(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Ht(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);M.assertNever(s)}}me.create=(n,e,t)=>new me({schema:n,typeName:O.ZodEffects,effect:e,...S(t)});me.createWithPreprocess=(n,e,t)=>new me({schema:e,effect:{type:"preprocess",transform:n},typeName:O.ZodEffects,...S(t)});class ye extends P{_parse(e){return this._getType(e)===b.undefined?Q(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ye.create=(n,e)=>new ye({innerType:n,typeName:O.ZodOptional,...S(e)});class Ve extends P{_parse(e){return this._getType(e)===b.null?Q(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ve.create=(n,e)=>new Ve({innerType:n,typeName:O.ZodNullable,...S(e)});class nn extends P{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===b.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}nn.create=(n,e)=>new nn({innerType:n,typeName:O.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class rn extends P{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ft(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new se(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new se(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}rn.create=(n,e)=>new rn({innerType:n,typeName:O.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class $n extends P{_parse(e){if(this._getType(e)!==b.nan){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.nan,received:t.parsedType}),Z}return{status:"valid",value:e.data}}}$n.create=n=>new $n({typeName:O.ZodNaN,...S(n)});const Ui=Symbol("zod_brand");class sr extends P{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class pn extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Z:s.status==="dirty"?(t.dirty(),Cn(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Z:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new pn({in:e,out:t,typeName:O.ZodPipeline})}}class sn extends P{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Ht(s)&&(s.value=Object.freeze(s.value)),s);return Ft(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}sn.create=(n,e)=>new sn({innerType:n,typeName:O.ZodReadonly,...S(e)});function Qr(n,e={},t){return n?ft.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:d})}}):ft.create()}const qi={object:B.lazycreate};var O;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(O||(O={}));const Bi=(n,e={message:`Input not instance of ${n.name}`})=>Qr(t=>t instanceof n,e),Xr=le.create,es=Me.create,Wi=$n.create,Hi=De.create,ts=Kt.create,Fi=Ye.create,Ki=Pn.create,Gi=Gt.create,zi=zt.create,Yi=ft.create,Ji=Ke.create,Qi=Ze.create,Xi=Nn.create,eo=he.create,to=B.create,no=B.strictCreate,ro=Yt.create,so=Ln.create,ao=Jt.create,io=we.create,oo=Qt.create,co=An.create,uo=Je.create,lo=it.create,po=Xt.create,ho=en.create,fo=Le.create,mo=tn.create,go=mt.create,gr=me.create,_o=ye.create,yo=Ve.create,vo=me.createWithPreprocess,bo=pn.create,ko=()=>Xr().optional(),wo=()=>es().optional(),xo=()=>ts().optional(),Oo={string:n=>le.create({...n,coerce:!0}),number:n=>Me.create({...n,coerce:!0}),boolean:n=>Kt.create({...n,coerce:!0}),bigint:n=>De.create({...n,coerce:!0}),date:n=>Ye.create({...n,coerce:!0})},To=Z;var c=Object.freeze({__proto__:null,defaultErrorMap:ht,setErrorMap:Oi,getErrorMap:En,makeIssue:Sn,EMPTY_PATH:Ti,addIssueToContext:y,ParseStatus:Y,INVALID:Z,DIRTY:Cn,OK:Q,isAborted:Xn,isDirty:er,isValid:Ht,isAsync:Ft,get util(){return M},get objectUtil(){return Qn},ZodParsedType:b,getParsedType:Ce,ZodType:P,datetimeRegex:Yr,ZodString:le,ZodNumber:Me,ZodBigInt:De,ZodBoolean:Kt,ZodDate:Ye,ZodSymbol:Pn,ZodUndefined:Gt,ZodNull:zt,ZodAny:ft,ZodUnknown:Ke,ZodNever:Ze,ZodVoid:Nn,ZodArray:he,ZodObject:B,ZodUnion:Yt,ZodDiscriminatedUnion:Ln,ZodIntersection:Jt,ZodTuple:we,ZodRecord:Qt,ZodMap:An,ZodSet:Je,ZodFunction:it,ZodLazy:Xt,ZodLiteral:en,ZodEnum:Le,ZodNativeEnum:tn,ZodPromise:mt,ZodEffects:me,ZodTransformer:me,ZodOptional:ye,ZodNullable:Ve,ZodDefault:nn,ZodCatch:rn,ZodNaN:$n,BRAND:Ui,ZodBranded:sr,ZodPipeline:pn,ZodReadonly:sn,custom:Qr,Schema:P,ZodSchema:P,late:qi,get ZodFirstPartyTypeKind(){return O},coerce:Oo,any:Yi,array:eo,bigint:Hi,boolean:ts,date:Fi,discriminatedUnion:so,effect:gr,enum:fo,function:lo,instanceof:Bi,intersection:ao,lazy:po,literal:ho,map:co,nan:Wi,nativeEnum:mo,never:Qi,null:zi,nullable:yo,number:es,object:to,oboolean:xo,onumber:wo,optional:_o,ostring:ko,pipeline:bo,preprocess:vo,promise:go,record:oo,set:uo,strictObject:no,string:Xr,symbol:Ki,transformer:gr,tuple:io,undefined:Gi,union:ro,unknown:Ji,void:Xi,NEVER:To,ZodIssueCode:f,quotelessJson:xi,ZodError:se});wi(c);const jo=c.object({start:c.number(),limit:c.number(),length:c.number()}),ar=c.object({created_at:c.string(),updated_at:c.string()}),Zo=c.object({email:c.string().optional(),email_verified:c.boolean().optional(),name:c.string().optional(),username:c.string().optional(),given_name:c.string().optional(),phone_number:c.string().optional(),phone_verified:c.boolean().optional(),family_name:c.string().optional()}).catchall(c.any()),Ro=c.object({connection:c.string(),user_id:c.string(),provider:c.string(),isSocial:c.boolean(),access_token:c.string().optional(),access_token_secret:c.string().optional(),refresh_token:c.string().optional(),profileData:Zo.optional()}),ns=c.object({email:c.string().optional(),username:c.string().optional(),given_name:c.string().optional(),family_name:c.string().optional(),nickname:c.string().optional(),name:c.string().optional(),picture:c.string().optional(),locale:c.string().optional(),linked_to:c.string().optional(),profileData:c.string().optional(),user_id:c.string().optional()}),Eo=ns.extend({email_verified:c.boolean().default(!1),verify_email:c.boolean().optional(),last_ip:c.string().optional(),last_login:c.string().optional(),user_id:c.string().optional(),provider:c.string().default("email"),connection:c.string().default("email")});Eo.extend(ar.shape).extend({user_id:c.string(),email:c.string(),is_social:c.boolean(),login_count:c.number(),identities:c.array(Ro).optional()});ns.extend({email:c.string(),login_count:c.number(),multifactor:c.array(c.string()).optional(),last_ip:c.string().optional(),last_login:c.string().optional(),user_id:c.string()}).catchall(c.any());const So=c.object({id:c.string(),name:c.string(),allowed_web_origins:c.string().transform(n=>n===null?"":n).default(""),allowed_callback_urls:c.string().transform(n=>n===null?"":n).default(""),allowed_logout_urls:c.string().transform(n=>n===null?"":n).default(""),email_validation:c.enum(["enabled","disabled","enforced"]).default("enforced"),client_secret:c.string().default(""),disable_sign_ups:c.boolean().default(!1)});c.object({created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)}).extend(So.shape);var rs=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(rs||{}),ss=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n))(ss||{}),as=(n=>(n.S265="S256",n.plain="plain",n))(as||{});const Vn=c.object({client_id:c.string(),vendor_id:c.string().optional(),response_type:c.nativeEnum(rs).optional(),response_mode:c.nativeEnum(ss).optional(),redirect_uri:c.string().optional(),audience:c.string().optional(),state:c.string().optional(),nonce:c.string().optional(),scope:c.string().optional(),code_challenge_method:c.nativeEnum(as).optional(),code_challenge:c.string().optional(),username:c.string().optional()});c.object({colors:c.object({primary:c.string(),page_background:c.object({type:c.string().optional(),start:c.string().optional(),end:c.string().optional(),angle_deg:c.number().optional()}).optional()}).optional(),logo_url:c.string().optional(),favicon_url:c.string().optional(),font:c.object({url:c.string()}).optional()});const Co=c.object({id:c.string().optional(),name:c.string(),client_id:c.string().optional(),client_secret:c.string().optional(),authorization_endpoint:c.string().optional(),response_type:c.custom().optional(),response_mode:c.custom().optional(),private_key:c.string().optional(),kid:c.string().optional(),team_id:c.string().optional(),token_endpoint:c.string().optional(),token_exchange_basic_auth:c.boolean().optional(),userinfo_endpoint:c.string().optional(),scope:c.string().optional()}),is=c.object({id:c.string(),created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)}).extend(Co.shape),Io=c.object({domain:c.string(),dkim_private_key:c.string().optional(),dkim_public_key:c.string().optional(),email_api_key:c.string().optional(),email_service:c.union([c.literal("mailgun"),c.literal("mailchannels")]).optional()}),os=c.object({id:c.string(),name:c.string(),domains:c.array(Io),allowed_callback_urls:c.array(c.string()),allowed_logout_urls:c.array(c.string()),allowed_web_origins:c.array(c.string()),email_validation:c.union([c.literal("enabled"),c.literal("disabled"),c.literal("enforced")]),tenant_id:c.string(),client_secret:c.string(),disable_sign_ups:c.boolean(),tenant:c.object({name:c.string(),audience:c.string().optional(),logo:c.string().optional(),primary_color:c.string().optional(),secondary_color:c.string().optional(),sender_email:c.string(),sender_name:c.string(),support_url:c.string().optional(),language:c.string().length(2).optional()})});os.extend({connections:c.array(is)});os.extend({connections:c.array(is.partial())});const Po=c.enum(["password_reset","email_verification","otp","oauth2","oauth2_state","ticket"]);c.object({code_id:c.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:c.string().openapi({description:"The id of the login session that the code is connected to"}),code_type:Po,created_at:c.string(),expires_at:c.string(),used_at:c.string().optional()});const No=c.object({domain:c.string(),dkim_private_key:c.string().optional(),dkim_public_key:c.string().optional(),email_api_key:c.string().optional(),email_service:c.enum(["mailgun","mailchannels"])});ar.extend({...No.shape,id:c.string()});const Ao=c.object({trigger_id:c.enum(["post-user-registration","post-user-login"]),enabled:c.boolean().default(!1),url:c.string(),hook_id:c.string().optional()});Ao.extend({...ar.shape,hook_id:c.string()});const $o=c.object({alg:c.string(),e:c.string(),kid:c.string(),kty:c.string(),n:c.string(),use:c.string().optional()}),Mo=c.object({keys:c.array($o)}),_r=c.object({issuer:c.string(),authorization_endpoint:c.string(),token_endpoint:c.string(),device_authorization_endpoint:c.string(),userinfo_endpoint:c.string(),mfa_challenge_endpoint:c.string(),jwks_uri:c.string(),registration_endpoint:c.string(),revocation_endpoint:c.string(),scopes_supported:c.array(c.string()),response_types_supported:c.array(c.string()),code_challenge_methods_supported:c.array(c.string()),response_modes_supported:c.array(c.string()),subject_types_supported:c.array(c.string()),id_token_signing_alg_values_supported:c.array(c.string()),token_endpoint_auth_methods_supported:c.array(c.string()),claims_supported:c.array(c.string()),request_uri_parameter_supported:c.boolean(),request_parameter_supported:c.boolean(),token_endpoint_auth_signing_alg_values_supported:c.array(c.string())}),Do=c.object({login_id:c.string().openapi({description:"This is is used as the state in the universal login"}),auth0Client:c.string().optional(),authParams:Vn,expires_at:c.string(),deleted_at:c.string(),ip:c.string().optional()}).openapi({description:"This represents a login sesion"});c.object({...Do.shape,created_at:c.string(),updated_at:c.string()});const Lo=c.enum(["sapi","ssa","fsa","ss","ssa","fs","s","f","fp","slo","scoa","fcoa","seccft","cls","seacft","serft"]),Vo=c.object({name:c.string(),version:c.string(),env:c.object({node:c.string().optional()}).optional()});c.object({type:Lo,date:c.string(),description:c.string().optional(),log_id:c.string().optional(),_id:c.string().optional(),ip:c.string(),user_agent:c.string(),details:c.any().optional(),isMobile:c.boolean(),user_id:c.string().optional(),user_name:c.string().optional(),connection:c.string().optional(),connection_id:c.string().optional(),client_id:c.string().optional(),client_name:c.string().optional(),audience:c.string().optional(),scope:c.array(c.string()).optional(),strategy:c.string().optional(),strategy_type:c.string().optional(),hostname:c.string().optional(),auth0_client:Vo.optional()});const Uo=c.object({user_id:c.string(),password:c.string(),algorithm:c.enum(["bcrypt","argon2id"]).default("argon2id")});c.object({...Uo.shape,created_at:c.string(),updated_at:c.string()});const qo=c.object({session_id:c.string(),client_id:c.string(),expires_at:c.string(),used_at:c.string(),deleted_at:c.string().optional(),user_id:c.string()});c.object({created_at:c.string(),...qo.shape});c.object({private_key:c.string(),public_key:c.string(),kid:c.string(),created_at:c.string(),revoked_at:c.string().optional()});c.object({kid:c.string().openapi({description:"The key id of the signing key"}),cert:c.string().openapi({description:"The public certificate of the signing key"}),fingerprint:c.string().openapi({description:"The cert fingerprint"}),thumbprint:c.string().openapi({description:"The cert thumbprint"}),pkcs7:c.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:c.boolean().optional().openapi({description:"True if the key is the current key"}),next:c.boolean().optional().openapi({description:"True if the key is the next key"}),previous:c.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:c.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:c.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:c.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:c.string().optional().openapi({description:"The date and time when the key was revoked"})});const nr=c.object({name:c.string(),audience:c.string(),sender_email:c.string().email(),sender_name:c.string(),support_url:c.string().url().optional(),logo:c.string().url().optional(),primary_color:c.string().optional(),secondary_color:c.string().optional(),language:c.string().optional()}),_n=nr.extend({created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)});c.object({logoUrl:c.string(),loginBackgroundImage:c.string().nullish(),style:c.object({primaryColor:c.string(),buttonTextColor:c.string(),primaryHoverColor:c.string()}),supportEmail:c.string().nullable(),supportUrl:c.string().nullable(),name:c.string(),showGreyishBackground:c.boolean().optional(),termsAndConditionsUrl:c.string().nullable(),companyName:c.string().optional(),checkoutHideSocial:c.boolean().optional(),siteUrl:c.string().nullable(),manageSubscriptionsUrl:c.string().optional()});var cs=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(cs||{});const ir=c.nativeEnum(cs);c.object({grant_type:ir.refine(n=>n==="authorization_code"),code:c.string(),client_secret:c.string(),client_id:c.string()});c.object({grant_type:ir.refine(n=>n==="authorization_code"),code:c.string(),code_verifier:c.string(),client_id:c.string().optional(),redirect_uri:c.string()});c.object({grant_type:ir.refine(n=>n==="client_credentials"),scope:c.string().optional(),client_secret:c.string(),client_id:c.string(),audience:c.string().optional()});c.object({access_token:c.string(),id_token:c.string().optional(),scope:c.string().optional(),state:c.string().optional(),refresh_token:c.string().optional(),token_type:c.string(),expires_in:c.number()});c.object({code:c.string(),state:c.string().optional()});const Bo=c.object({button_border_radius:c.number(),button_border_weight:c.number(),buttons_style:c.enum(["pill"]),input_border_radius:c.number(),input_border_weight:c.number(),inputs_style:c.enum(["pill"]),show_widget_shadow:c.boolean(),widget_border_weight:c.number(),widget_corner_radius:c.number()}),Wo=c.object({base_focus_color:c.string(),base_hover_color:c.string(),body_text:c.string(),captcha_widget_theme:c.enum(["auto"]),error:c.string(),header:c.string(),icons:c.string(),input_background:c.string(),input_border:c.string(),input_filled_text:c.string(),input_labels_placeholders:c.string(),links_focused_components:c.string(),primary_button:c.string(),primary_button_label:c.string(),secondary_button_border:c.string(),secondary_button_label:c.string(),success:c.string(),widget_background:c.string(),widget_border:c.string()}),et=c.object({bold:c.boolean(),size:c.number()}),Ho=c.object({body_text:et,buttons_text:et,font_url:c.string(),input_labels:et,links:et,links_style:c.enum(["normal"]),reference_text_size:c.number(),subtitle:et,title:et}),Fo=c.object({background_color:c.string(),background_image_url:c.string(),page_layout:c.enum(["center"])}),Ko=c.object({header_text_alignment:c.enum(["center"]),logo_height:c.number(),logo_position:c.enum(["center"]),logo_url:c.string(),social_buttons_layout:c.enum(["bottom"])}),Go=c.object({borders:Bo,colors:Wo,displayName:c.string(),fonts:Ho,page_background:Fo,widget:Ko});Go.extend({themeId:c.string()});const zo=c.object({id:c.string(),expires_at:c.string(),auth0Client:c.string().optional(),authParams:Vn});c.object({...zo.shape,created_at:c.string(),updated_at:c.string()});const Yo=c.object({id:c.string(),email:c.string(),code:c.string(),ip:c.string().optional(),send:c.enum(["code","link"]),authParams:Vn,expires_at:c.string(),used_at:c.string().optional(),user_id:c.string().optional()});c.object({created_at:c.string(),...Yo.shape});const Jo=c.object({authParams:Vn,code:c.string(),user_id:c.string(),created_at:c.string(),expires_at:c.string(),used_at:c.string().optional()});c.object({...Jo.shape,created_at:c.string()});const Qo=new Wt().openapi(We({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Mo}},description:"List of tenants"}}}),async n=>{const{env:e}=n,t=[{alg:"RS256",e:"AQAB",kid:"hZ42TWGWLdmyKfwGVA6c2",kty:"RSA",n:"nUd-mktFZQNfVwmXufxcVcvJo6Lkb-jDuymtfQunmEhWCctOccWx9e7LX7_9uN15ZnRS7XJInPMRs9KLYdZ0GCnE2HM_QbrEoHpdkCRgyTE-KzmoaEv_AOVGE_Kg0-0ct3r9Z7aJLDVAsxXl1C9y8Gr7ZYkq0c4DyZr9VT8nQiwZQERbfxXdXw-5RLj21S_Lm-LL-AjKvry_TDBLpfUFJV18SVsM07lY_V45TwykNewRdaGLspFIeGdG5j5eByV8ifzBqvzOSptSCsmOTtW-ceWUk0FPD7g_KKzjjbzenoB0TC8mBb_4vWZlHnuGIAs2YoTFglp9uNu7t_OVl3Svo6ZE6alzUnaNfZNeAi78KPHYQ4tDWPjpYNfGynsiD0nojkDSPCIak56jWNYjj614cPEBiv9MVQRiSbBxpiGhMoHlW_QCCPMcXygLAaRs_tUksqoH4QB80krifG2yHPgGDPjXK1_0cYzV80iOcQIeoceqhkSSc6YxzzgDrQcsV2k3bizRQSL83GWkpdHhTZn-Q_JzsW_bDY_f9fjigYbRnoDSgS7038VFIPc92StE41MdgvIQMomcyEE4lYK1uv1Mo6cnXbCZhm8tvddo7VKNorOB4nsiv8DGrWPlzQBca9VN4C1oE2mH-3WLFR7XEkBHWVouOdTWM2S3K9F10YtahkM"}];return n.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})}).openapi(We({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:_r}},description:"List of tenants"}}}),async n=>{const{env:e}=n,{ISSUER:t}=e,r=_r.parse({issuer:t,authorization_endpoint:`${t}authorize`,token_endpoint:`${t}oauth/token`,device_authorization_endpoint:`${t}oauth/device/code`,userinfo_endpoint:`${t}userinfo`,mfa_challenge_endpoint:`${t}mfa/challenge`,jwks_uri:`${t}.well-known/jwks.json`,registration_endpoint:`${t}oidc/register`,revocation_endpoint:`${t}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return n.json(r,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})});async function Xo({userAdapter:n,tenant_id:e,email:t}){var o;const{users:r}=await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),s=r.filter(d=>!(d.provider==="auth2"&&!d.email_verified));if(s.length===0)return;const a=s.filter(d=>!d.linked_to);if(a.length>0)return a.length>1&&console.error("More than one primary user found for same email"),a[0];const i=await n.get(e,(o=s[0])==null?void 0:o.linked_to);if(!i)throw new Error("Primary account not found");return i}function ec(n){return async(e,t)=>{if(!t.email||!t.email_verified)return n.users.create(e,t);const r=await Xo({userAdapter:n.users,tenant_id:e,email:t.email});return r?(await n.users.create(e,{...t,linked_to:r.user_id}),r):n.users.create(e,t)}}async function tc(n,e,t){for await(const r of e)(await fetch(r.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok}function nc(n,e){return async(t,r)=>{const{hooks:s}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await tc(n,s,{tenant_id:t,user:r,trigger_id:"post-user-registration"}),r}}function rc(n,e){return async(t,r)=>{let s=await ec(e)(t,r);return await nc(n,e)(t,s),s}}function sc(n,e){return{...e,users:{...e.users,create:rc(n,e)}}}const ac=G.object({page:G.string().min(0).optional().default("0").transform(n=>parseInt(n,10)).openapi({description:"The page number where 0 is the first page"}),per_page:G.string().min(1).optional().default("10").transform(n=>parseInt(n,10)).openapi({description:"The number of items per page"}),include_totals:G.string().optional().default("false").transform(n=>n==="true").openapi({description:"If the total number of items should be included in the response"}),sort:G.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:G.string().optional().openapi({description:"A lucene query string used to filter the results"})});function ic(n){if(!n)return;const[e="",t]=n.split(":");return{sort_by:e,sort_order:t==="1"?"asc":"desc"}}const oc=jo.extend({tenants:G.array(_n)}),cc=new Wt().openapi(We({tags:["tenants"],method:"get",path:"/",request:{query:ac},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:G.union([G.array(_n),oc])}},description:"List of tenants"}}}),async n=>{const{page:e,per_page:t,include_totals:r,sort:s,q:a}=n.req.valid("query"),i=await n.env.data.tenants.list({page:e,per_page:t,include_totals:r,sort:ic(s),q:a});return r?n.json(i):n.json(i.tenants)}).openapi(We({tags:["tenants"],method:"get",path:"/{id}",request:{params:G.object({id:G.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:_n}},description:"A tenant"}}}),async n=>{const{id:e}=n.req.valid("param"),t=await n.env.data.tenants.get(e);if(!t)throw new fn(404);return console.log("tenant",t),n.json(t)}).openapi(We({tags:["tenants"],method:"delete",path:"/{id}",request:{params:G.object({id:G.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{id:e}=n.req.valid("param");return await n.env.data.tenants.remove(e),n.text("OK")}).openapi(We({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:G.object(nr.shape).partial()}}},params:G.object({id:G.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{id:e}=n.req.valid("param"),t=n.req.valid("json");return await n.env.data.tenants.update(e,t),n.text("OK")}).openapi(We({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:G.object(nr.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:_n}},description:"An tenant"}}}),async n=>{const e=n.req.valid("json"),t=await n.env.data.tenants.create(e);return n.json(t,{status:201})});let yr=!1;function dc(n){n.use(async(e,t)=>(yr||(n.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),yr=!0),await t()))}function uc(n){const e=new Wt;e.use(async(r,s)=>(r.env.data=sc(r,n.dataAdapter),s()));const t=e.route("/api/v2/tenants",cc);return dc(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function lc(n){const e=new Wt;e.get("/",s=>s.text("Hello, authhero!"));const t=uc(n);e.route("/api/v2",t);const r=new Wt().route("/.well-known",Qo);return r.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",r),e}exports.init=lc;
|
|
1
|
+
"use strict";var us=Object.defineProperty;var or=n=>{throw TypeError(n)};var ls=(n,e,t)=>e in n?us(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var g=(n,e,t)=>ls(n,typeof e!="symbol"?e+"":e,t),cr=(n,e,t)=>e.has(n)||or("Cannot "+t);var m=(n,e,t)=>(cr(n,e,"read from private field"),t?t.call(n):e.get(n)),K=(n,e,t)=>e.has(n)?or("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),A=(n,e,t,r)=>(cr(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function bt(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function C(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function ps(n){return"_def"in n}function gt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function hs(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var i,o,d,u,l,p;const R=typeof s=="string"?a:s,D=R??{},{param:P}=D,j=bt(D,["param"]),U=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),H=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),j),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||P?{param:Object.assign(Object.assign({},(p=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||p===void 0?void 0:p.param),P)}:void 0),ee=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(U).length>0?{_internal:U}:void 0),Object.keys(H).length>0?{metadata:H}:void 0)}));if(C(this,"ZodObject")){const te=this.extend;ee.extend=function(...Re){var ae,ne,X,ge,ie,Ve;const qe=te.apply(this,Re);return qe._def.openapi={_internal:{extendedFrom:!((ne=(ae=this._def.openapi)===null||ae===void 0?void 0:ae._internal)===null||ne===void 0)&&ne.refId?{refId:(ge=(X=this._def.openapi)===null||X===void 0?void 0:X._internal)===null||ge===void 0?void 0:ge.refId,schema:this}:(ie=this._def.openapi)===null||ie===void 0?void 0:ie._internal.extendedFrom},metadata:(Ve=qe._def.openapi)===null||Ve===void 0?void 0:Ve.metadata},qe}}return ee},gt(n,"optional"),gt(n,"nullable"),gt(n,"default"),gt(n,"transform"),gt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var u,l;d._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}function yn(n,e){if(n==null||e===null||e===void 0)return n===e;if(n===e||n.valueOf()===e.valueOf())return!0;if(Array.isArray(n)&&(!Array.isArray(e)||n.length!==e.length)||!(n instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(n);return Object.keys(e).every(r=>t.indexOf(r)!==-1)&&t.every(r=>yn(n[r],e[r]))}class fs{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),r=this.buckets.get(t);if(!r){this.buckets.set(t,[e]);return}r.some(a=>yn(a,e))||r.push(e)}contains(e){const t=this.hashCodeOf(e),r=this.buckets.get(t);return r?r.some(s=>yn(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,r=0;for(const a of this.buckets.values())e+=1,t+=a.length,a.length>1&&(r+=1);const s=e/t;return{totalBuckets:e,collisions:r,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let r=0;r<e.length;r++)t^=this.hashCodeOf(e[r])*r;return t}if(typeof e=="string"){for(let r=0;r<e.length;r++)t^=e.charCodeAt(r)*r;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[r,s]of Object.entries(e))t^=this.hashCodeOf(r)+this.hashCodeOf(s??"");return t}}function jt(n){return n==null}function Et(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{t[r]=e(s)}),t}function ms(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{e.some(a=>a===r)||(t[r]=s)}),t}function st(n,e){const t={};return Object.entries(n).forEach(([r,s])=>{e(s,r)||(t[r]=s)}),t}function dr(n){return n.filter(e=>!jt(e))}const Hn=yn;function gs(n){const e=new fs;return n.forEach(t=>e.put(t)),[...e.values()]}function wr(n){return typeof n=="string"}class _s{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const r=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:r}),r}registerParameter(e,t){var r,s,a;const i=this.schemaWithRefId(e,t),o=(r=i._def.openapi)===null||r===void 0?void 0:r.metadata,d=i.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(a=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&a!==void 0?a:e})}));return this._definitions.push({type:"parameter",schema:d}),d}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,r){return this._definitions.push({type:"component",componentType:e,name:t,component:r}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class $n{constructor(e){this.message=e}}class _t extends $n{constructor(e,t){super(e),this.data=t}}class vn extends $n{constructor(e){super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``),this.data=e}}function yt(n,e){try{return n()}catch(t){throw t instanceof vn?new vn(Object.assign(Object.assign({},t.data),e)):t}}class ys extends $n{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class L{static getMetadata(e){var t;const r=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:r._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:r.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:a},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),r=e._def.openapi?e._def.openapi:t._def.openapi;return r==null?void 0:r._internal}static getParamMetadata(e){var t,r;const s=this.unwrapChained(e),a=e._def.openapi?e._def.openapi:s._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:a==null?void 0:a._internal,metadata:Object.assign(Object.assign({},a==null?void 0:a.metadata),{param:Object.assign({description:i},(r=a==null?void 0:a.metadata)===null||r===void 0?void 0:r.param)})}}static buildSchemaMetadata(e){return st(ms(e,["param"]),jt)}static buildParameterMetadata(e){return st(e,jt)}static applySchemaMetadata(e,t){return st(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),jt)}static getRefId(e){var t;return(t=this.getInternalMetadata(e))===null||t===void 0?void 0:t.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){const t=this.unwrapUntil(e,"ZodDefault");return t==null?void 0:t._def.defaultValue()}static unwrapUntil(e,t){return t&&C(e,t)?e:C(e,"ZodOptional")||C(e,"ZodNullable")||C(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):C(e,"ZodDefault")||C(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):C(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):C(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return C(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class vs{transform(e,t,r){var s,a;const i=e._def.type;return Object.assign(Object.assign({},t("array")),{items:r(i),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(a=e._def.maxLength)===null||a===void 0?void 0:a.value})}}class bs{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class ks{transform(e,t,r,s,a){const i=[...e.options.values()],o=i.map(s);return t?{oneOf:r(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(i,e.discriminator,a)}}mapDiscriminator(e,t,r){if(e.some(a=>L.getRefId(a)===void 0))return;const s={};return e.forEach(a=>{var i;const o=L.getRefId(a),d=(i=a.shape)===null||i===void 0?void 0:i[t];if(C(d,"ZodEnum")||C(d,"ZodNativeEnum")){Object.values(d.enum).filter(wr).forEach(p=>{s[p]=r(o)});return}const u=d==null?void 0:d._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=r(o)}),{propertyName:t,mapping:s}}}class ws{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class xs{transform(e,t,r,s){const i={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:r([i],t)}:i}flattenIntersectionTypes(e){if(!C(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),r=this.flattenIntersectionTypes(e._def.right);return[...t,...r]}}class Os{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function Ts(n){const t=Object.keys(n).filter(a=>typeof n[n[a]]!="number").map(a=>n[a]),r=t.filter(a=>typeof a=="number").length,s=r===0?"string":r===t.length?"numeric":"mixed";return{values:t,type:s}}class js{transform(e,t){const{type:r,values:s}=Ts(e._def.values);if(r==="mixed")throw new $n("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(r==="numeric"?"integer":"string")),{enum:s})}}class Es{transform(e,t,r){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),r(e._def.checks))}}class Rs{transform(e,t,r,s){var a;const i=(a=L.getInternalMetadata(e))===null||a===void 0?void 0:a.extendedFrom,o=this.requiredKeysOf(e),d=Et(e._def.shape(),s);if(!i)return Object.assign(Object.assign(Object.assign(Object.assign({},r("object")),{properties:d,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=i.schema;s(u);const l=this.requiredKeysOf(u),p=Et(u==null?void 0:u._def.shape(),s),R=Object.fromEntries(Object.entries(d).filter(([j,U])=>!Hn(p[j],U))),D=o.filter(j=>!l.includes(j)),P=Object.assign(Object.assign(Object.assign(Object.assign({},r("object")),{default:t,properties:R}),D.length>0?{required:D}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${i.refId}`},P]}}generateAdditionalProperties(e,t){const r=e._def.unknownKeys,s=e._def.catchall;return C(s,"ZodNever")?r==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,r])=>!L.isOptionalSchema(r)).map(([t,r])=>t)}}class Ss{transform(e,t,r){const s=e._def.valueType,a=e._def.keyType,i=r(s);if(C(a,"ZodEnum")||C(a,"ZodNativeEnum")){const d=Object.values(a.enum).filter(wr).reduce((u,l)=>Object.assign(Object.assign({},u),{[l]:i}),{});return Object.assign(Object.assign({},t("object")),{properties:d})}return Object.assign(Object.assign({},t("object")),{additionalProperties:i})}}class Zs{transform(e,t){var r,s,a;const i=this.getZodStringCheck(e,"regex"),o=(r=this.getZodStringCheck(e,"length"))===null||r===void 0?void 0:r.value,d=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(a=e.maxLength)!==null&&a!==void 0?a:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??d,maxLength:o??u,format:this.mapStringFormat(e),pattern:i==null?void 0:i.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(r=>r.kind===t)}}class Cs{constructor(e){this.versionSpecifics=e}transform(e,t,r){const{items:s}=e._def,a=s.map(r);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(a))}}class Is{transform(e,t,r){const a=this.flattenUnionTypes(e).map(i=>{const o=this.unwrapNullable(i);return r(o)});return{anyOf:t(a)}}flattenUnionTypes(e){return C(e,"ZodUnion")?e._def.options.flatMap(r=>this.flattenUnionTypes(r)):[e]}unwrapNullable(e){return C(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Ns{constructor(e){this.versionSpecifics=e,this.objectTransformer=new Rs,this.stringTransformer=new Zs,this.numberTransformer=new Es,this.bigIntTransformer=new bs,this.literalTransformer=new Os,this.enumTransformer=new ws,this.nativeEnumTransformer=new js,this.arrayTransformer=new vs,this.unionTransformer=new Is,this.discriminatedUnionTransformer=new ks,this.intersectionTransformer=new xs,this.recordTransformer=new Ss,this.tupleTransformer=new Cs(e)}transform(e,t,r,s,a){if(C(e,"ZodNull"))return this.versionSpecifics.nullType;if(C(e,"ZodUnknown")||C(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(C(e,"ZodObject"))return this.objectTransformer.transform(e,a,o=>this.versionSpecifics.mapNullableType(o,t),r);const i=this.transformSchemaWithoutDefault(e,t,r,s);return Object.assign(Object.assign({},i),{default:a})}transformSchemaWithoutDefault(e,t,r,s){if(C(e,"ZodUnknown")||C(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(C(e,"ZodString"))return this.stringTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodNumber"))return this.numberTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),i=>this.versionSpecifics.getNumberChecks(i));if(C(e,"ZodBigInt"))return this.bigIntTransformer.transform(i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(C(e,"ZodLiteral"))return this.literalTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodEnum"))return this.enumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(C(e,"ZodArray"))return this.arrayTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(C(e,"ZodTuple"))return this.tupleTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(C(e,"ZodUnion"))return this.unionTransformer.transform(e,i=>this.versionSpecifics.mapNullableOfArray(i,t),r);if(C(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),r,s);if(C(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),r);if(C(e,"ZodRecord"))return this.recordTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),r);if(C(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const a=L.getRefId(e);throw new ys({currentSchema:e._def,schemaName:a})}}class xr{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Ns(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const r={};return this.rawComponents.forEach(({componentType:s,name:a,component:i})=>{var o;(o=r[s])!==null&&o!==void 0||(r[s]={}),r[s][a]=i}),Object.assign(Object.assign({},r),{schemas:Object.assign(Object.assign({},(e=r.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=r.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,r)=>{if(!("type"in t))return"type"in r?-1:0;if(!("type"in r))return 1;const s=e.findIndex(i=>i===t.type),a=e.findIndex(i=>i===r.type);return s-a})}generateSingle(e){if(!("type"in e)){this.generateSchemaWithRef(e);return}switch(e.type){case"parameter":this.generateParameterDefinition(e.schema);return;case"schema":this.generateSchemaWithRef(e.schema);return;case"route":this.generateSingleRoute(e.route);return;case"component":this.rawComponents.push(e);return}}generateParameterDefinition(e){const t=L.getRefId(e),r=this.generateParameter(e);return t&&(this.paramRefs[t]=r),r}getParameterRef(e,t){var r,s,a,i,o;const d=(r=e==null?void 0:e.metadata)===null||r===void 0?void 0:r.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(a=e._internal)===null||a===void 0?void 0:a.refId]:void 0;if(!(!(!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId)||!u)){if(d&&u.in!==d.in||t!=null&&t.in&&u.in!==t.in)throw new _t(`Conflicting location for parameter ${u.name}`,{key:"in",values:dr([u.in,t==null?void 0:t.in,d==null?void 0:d.in])});if(d&&u.name!==d.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new _t("Conflicting names for parameter",{key:"name",values:dr([u.name,t==null?void 0:t.name,d==null?void 0:d.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var r;const s=L.getMetadata(e),a=(r=s==null?void 0:s.metadata)===null||r===void 0?void 0:r.param,i=this.getParameterRef(s,{in:t});if(i)return[i];if(C(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,l])=>{var p,R;const D=L.getMetadata(l),P=this.getParameterRef(D,{in:t,name:u});if(P)return P;const j=(p=D==null?void 0:D.metadata)===null||p===void 0?void 0:p.param;if(j!=null&&j.name&&j.name!==u)throw new _t("Conflicting names for parameter",{key:"name",values:[u,j.name]});if(j!=null&&j.in&&j.in!==t)throw new _t(`Conflicting location for parameter ${(R=j.name)!==null&&R!==void 0?R:u}`,{key:"in",values:[t,j.in]});return this.generateParameter(l.openapi({param:{name:u,in:t}}))})}if(a!=null&&a.in&&a.in!==t)throw new _t(`Conflicting location for parameter ${a.name}`,{key:"in",values:[t,a.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const r=L.getParamMetadata(e),s=(t=r==null?void 0:r.metadata)===null||t===void 0?void 0:t.param,a=!L.isOptionalSchema(e)&&!e.isNullable(),i=this.generateSchemaWithRef(e);return Object.assign({schema:i,required:a},s?L.buildParameterMetadata(s):{})}generateParameter(e){var t;const r=L.getMetadata(e),s=(t=r==null?void 0:r.metadata)===null||t===void 0?void 0:t.param,a=s==null?void 0:s.name,i=s==null?void 0:s.in;if(!a)throw new vn({missingField:"name"});if(!i)throw new vn({missingField:"in",paramName:a});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:i,name:a})}generateSchemaWithMetadata(e){var t;const r=L.unwrapChained(e),s=L.getMetadata(e),a=L.getDefaultValue(e),i=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(r,e.isNullable(),a);return s!=null&&s.metadata?L.applySchemaMetadata(i,s.metadata):st(i,jt)}constructReferencedOpenAPISchema(e){var t;const r=L.getMetadata(e),s=L.unwrapChained(e),a=L.getDefaultValue(e),i=e.isNullable();return!((t=r==null?void 0:r.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(r.metadata.type,i):this.toOpenAPISchema(s,i,a)}generateSimpleSchema(e){var t;const r=L.getMetadata(e),s=L.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const a=this.schemaRefs[s],i={$ref:this.generateSchemaRef(s)},o=st(L.buildSchemaMetadata((t=r==null?void 0:r.metadata)!==null&&t!==void 0?t:{}),(l,p)=>l===void 0||Hn(l,a[p]));if(o.type)return{allOf:[i,o]};const d=st(this.constructReferencedOpenAPISchema(e),(l,p)=>l===void 0||Hn(l,a[p])),u=L.applySchemaMetadata(d,o);return Object.keys(u).length>0?{allOf:[i,u]}:i}generateSchemaWithRef(e){const t=L.getRefId(e),r=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=r,{$ref:this.generateSchemaRef(t)}):r}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,r=bt(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},r),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,r=this.cleanParameter(e.query),s=this.cleanParameter(e.params),a=this.cleanParameter(e.cookies),i=yt(()=>r?this.generateInlineParameters(r,"query"):[],{location:"query"}),o=yt(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),d=yt(()=>a?this.generateInlineParameters(a,"cookie"):[],{location:"cookie"}),u=yt(()=>{if(Array.isArray(t))return t.flatMap(p=>this.generateInlineParameters(p,"header"));const l=this.cleanParameter(t);return l?this.generateInlineParameters(l,"header"):[]},{location:"header"});return[...o,...i,...u,...d]}cleanParameter(e){if(e)return C(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:r,request:s,responses:a}=e,i=bt(e,["method","path","request","responses"]),o=Et(a,p=>this.getResponse(p)),d=yt(()=>this.getParameters(s),{route:`${t} ${r}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},i),d.length>0?{parameters:[...i.parameters||[],...d]}:{}),u?{requestBody:u}:{}),{responses:o})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){var{content:t,headers:r}=e,s=bt(e,["content","headers"]);const a=t?{content:this.getBodyContent(t)}:{};if(!r)return Object.assign(Object.assign({},s),a);const i=C(r,"ZodObject")?this.getResponseHeaders(r):r;return Object.assign(Object.assign(Object.assign({},s),{headers:i}),a)}getResponseHeaders(e){const t=e._def.shape();return Et(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return Et(e,t=>{if(!t||!ps(t.schema))return t;const{schema:r}=t,s=bt(t,["schema"]),a=this.generateSchemaWithRef(r);return Object.assign({schema:a},s)})}toOpenAPISchema(e,t,r){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),r)}}class Ps{get nullType(){return{nullable:!0}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return Object.assign(Object.assign({},e?{type:e}:void 0),t?this.nullType:void 0)}mapTupleItems(e){const t=gs(e);return{items:t.length===1?t[0]:{anyOf:t},minItems:e.length,maxItems:e.length}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{minimum:Number(t.value),exclusiveMinimum:!0};case"max":return t.inclusive?{maximum:Number(t.value)}:{maximum:Number(t.value),exclusiveMaximum:!0};default:return{}}}))}}class As{constructor(e){const t=new Ps;this.generator=new xr(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class Ms{get nullType(){return{type:"null"}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return e?t?{type:Array.isArray(e)?[...e,"null"]:[e,"null"]}:{type:e}:{}}mapTupleItems(e){return{prefixItems:e}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{exclusiveMinimum:Number(t.value)};case"max":return t.inclusive?{maximum:Number(t.value)}:{exclusiveMaximum:Number(t.value)};default:return{}}}))}}function $s(n){return"type"in n&&n.type==="webhook"}class Ds{constructor(e){this.definitions=e,this.webhookRefs={};const t=new Ms;this.generator=new xr(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter($s).forEach(r=>this.generateSingleWebhook(r.webhook)),Object.assign(Object.assign(Object.assign({},e),t),{webhooks:this.webhookRefs})}generateComponents(){return this.generator.generateComponents()}generateSingleWebhook(e){const t=this.generator.generatePath(e);return this.webhookRefs[e.path]=Object.assign(Object.assign({},this.webhookRefs[e.path]),t),t}}var Or=n=>{const e=n.split("/");return e[0]===""&&e.shift(),e},Ls=n=>{const{groups:e,path:t}=Us(n),r=Or(t);return Vs(r,e)},Us=n=>{const e=[];return n=n.replace(/\{[^}]+\}/g,(t,r)=>{const s=`@${r}`;return e.push([s,t]),s}),{groups:e,path:n}},Vs=(n,e)=>{for(let t=e.length-1;t>=0;t--){const[r]=e[t];for(let s=n.length-1;s>=0;s--)if(n[s].includes(r)){n[s]=n[s].replace(r,e[t][1]);break}}return n},hn={},ur=n=>{if(n==="*")return"*";const e=n.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(hn[n]||(e[2]?hn[n]=[n,e[1],new RegExp("^"+e[2]+"$")]:hn[n]=[n,e[1],!0]),hn[n]):null},qs=n=>{try{return decodeURI(n)}catch{return n.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURI(e)}catch{return e}})}},Tr=n=>{const e=n.url,t=e.indexOf("/",8);let r=t;for(;r<e.length;r++){const s=e.charCodeAt(r);if(s===37){const a=e.indexOf("?",r),i=e.slice(t,a===-1?void 0:a);return qs(i.includes("%25")?i.replace(/%25/g,"%2525"):i)}else if(s===63)break}return e.slice(t,r)},Bs=n=>{const e=Tr(n);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},Be=(...n)=>{let e="",t=!1;for(let r of n)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),r[0]!=="/"&&(r=`/${r}`),r==="/"&&t?e=`${e}/`:r!=="/"&&(e=`${e}${r}`),r==="/"&&e===""&&(e="/");return e},jr=n=>{if(!n.match(/\:.+\?$/))return null;const e=n.split("/"),t=[];let r="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))r+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&r===""?t.push("/"):t.push(r);const a=s.replace("?","");r+="/"+a,t.push(r)}else r+="/"+s}),t.filter((s,a,i)=>i.indexOf(s)===a)},Vn=n=>/[%+]/.test(n)?(n.indexOf("+")!==-1&&(n=n.replace(/\+/g," ")),/%/.test(n)?bn(n):n):n,Er=(n,e,t)=>{let r;if(!t&&e&&!/[%+]/.test(e)){let i=n.indexOf(`?${e}`,8);for(i===-1&&(i=n.indexOf(`&${e}`,8));i!==-1;){const o=n.charCodeAt(i+e.length+1);if(o===61){const d=i+e.length+2,u=n.indexOf("&",d);return Vn(n.slice(d,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";i=n.indexOf(`&${e}`,i+1)}if(r=/[%+]/.test(n),!r)return}const s={};r??(r=/[%+]/.test(n));let a=n.indexOf("?",8);for(;a!==-1;){const i=n.indexOf("&",a+1);let o=n.indexOf("=",a);o>i&&i!==-1&&(o=-1);let d=n.slice(a+1,o===-1?i===-1?void 0:i:o);if(r&&(d=Vn(d)),a=i,d==="")continue;let u;o===-1?u="":(u=n.slice(o+1,i===-1?void 0:i),r&&(u=Vn(u))),t?(s[d]&&Array.isArray(s[d])||(s[d]=[]),s[d].push(u)):s[d]??(s[d]=u)}return e?s[e]:s},Ws=Er,Hs=(n,e)=>Er(n,e,!0),bn=decodeURIComponent,Fs=/^[\w!#$%&'*.^`|~+-]+$/,Ks=/^[ !#-:<-[\]-~]*$/,Gs=(n,e)=>n.trim().split(";").reduce((r,s)=>{s=s.trim();const a=s.indexOf("=");if(a===-1)return r;const i=s.substring(0,a).trim();if(!Fs.test(i))return r;let o=s.substring(a+1).trim();return o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Ks.test(o)&&(r[i]=bn(o)),r},{}),zs=(n,e,t)=>{const r=n.req.raw.headers.get("Cookie");return r?Gs(r):{}},fn=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});g(this,"res");g(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},Ys=(n,e)=>new Response(n,{headers:{"Content-Type":e}}).formData(),Js=(n,e)=>async(t,r)=>{let s={};const a=t.req.header("Content-Type");switch(n){case"json":if(!a||!/^application\/([a-z-\.]+\+)?json/.test(a)){const o=`Invalid HTTP header: Content-Type=${a}`;throw new fn(400,{message:o})}try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new fn(400,{message:o})}break;case"form":{if(!a)break;if(t.req.bodyCache.formData){s=await t.req.bodyCache.formData;break}try{const o=await t.req.arrayBuffer(),d=await Ys(o,a),u={};d.forEach((l,p)=>{p.endsWith("[]")?u[p]===void 0?u[p]=[l]:Array.isArray(u[p])&&u[p].push(l):u[p]=l}),s=u,t.req.bodyCache.formData=d}catch(o){let d="Malformed FormData request.";throw d+=o instanceof Error?` ${o.message}`:` ${String(o)}`,new fn(400,{message:d})}break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,d])=>d.length===1?[o,d[0]]:[o,d]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=zs(t);break}const i=await e(s,t);if(i instanceof Response)return i;t.req.addValidatedData(n,i),await r()};const Qe=(n,e,t)=>Js(n,async(r,s)=>{const a=await e.safeParseAsync(r);if(t){const i=await t({data:r,...a},s);if(i){if(i instanceof Response)return i;if("response"in i)return i.response}}return a.success?a.data:s.json(a,400)});var Qs=async(n,e=Object.create(null))=>{const{all:t=!1,dot:r=!1}=e,a=(n instanceof Rr?n.raw.headers:n.headers).get("Content-Type");return a!==null&&a.startsWith("multipart/form-data")||a!==null&&a.startsWith("application/x-www-form-urlencoded")?Xs(n,{all:t,dot:r}):{}};async function Xs(n,e){const t=await n.formData();return t?ea(t,e):{}}function ea(n,e){const t=Object.create(null);return n.forEach((r,s)=>{e.all||s.endsWith("[]")?ta(t,s,r):t[s]=r}),e.dot&&Object.entries(t).forEach(([r,s])=>{r.includes(".")&&(na(t,r,s),delete t[r])}),t}var ta=(n,e,t)=>{n[e]!==void 0?Array.isArray(n[e])?n[e].push(t):n[e]=[n[e],t]:n[e]=t},na=(n,e,t)=>{let r=n;const s=e.split(".");s.forEach((a,i)=>{i===s.length-1?r[a]=t:((!r[a]||typeof r[a]!="object"||Array.isArray(r[a])||r[a]instanceof File)&&(r[a]=Object.create(null)),r=r[a])})},ot,oe,vr,Rr=(vr=class{constructor(n,e="/",t=[[]]){g(this,"raw");K(this,ot);K(this,oe);g(this,"routeIndex",0);g(this,"path");g(this,"bodyCache",{});g(this,"cachedBody",n=>{const{bodyCache:e,raw:t}=this,r=e[n];if(r)return r;const s=Object.keys(e)[0];return s?e[s].then(a=>(s==="json"&&(a=JSON.stringify(a)),new Response(a)[n]())):e[n]=t[n]()});this.raw=n,this.path=e,A(this,oe,t),A(this,ot,{})}param(n){return n?this.getDecodedParam(n):this.getAllDecodedParams()}getDecodedParam(n){const e=m(this,oe)[0][this.routeIndex][1][n],t=this.getParamValue(e);return t?/\%/.test(t)?bn(t):t:void 0}getAllDecodedParams(){const n={},e=Object.keys(m(this,oe)[0][this.routeIndex][1]);for(const t of e){const r=this.getParamValue(m(this,oe)[0][this.routeIndex][1][t]);r&&typeof r=="string"&&(n[t]=/\%/.test(r)?bn(r):r)}return n}getParamValue(n){return m(this,oe)[1]?m(this,oe)[1][n]:n}query(n){return Ws(this.url,n)}queries(n){return Hs(this.url,n)}header(n){if(n)return this.raw.headers.get(n.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,r)=>{e[r]=t}),e}async parseBody(n){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await Qs(this,n))}json(){return this.cachedBody("json")}text(){return this.cachedBody("text")}arrayBuffer(){return this.cachedBody("arrayBuffer")}blob(){return this.cachedBody("blob")}formData(){return this.cachedBody("formData")}addValidatedData(n,e){m(this,ot)[n]=e}valid(n){return m(this,ot)[n]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return m(this,oe)[0].map(([[,n]])=>n)}get routePath(){return m(this,oe)[0].map(([[,n]])=>n)[this.routeIndex].path}},ot=new WeakMap,oe=new WeakMap,vr),ra={Stringify:1,BeforeStream:2,Stream:3},Sr=async(n,e,t,r,s)=>{const a=n.callbacks;return a!=null&&a.length?(s?s[0]+=n:s=[n],Promise.all(a.map(o=>o({phase:e,buffer:s,context:r}))).then(o=>Promise.all(o.filter(Boolean).map(d=>Sr(d,e,!1,r,s))).then(()=>s[0]))):Promise.resolve(n)},sa="text/plain; charset=UTF-8",qn=(n,e={})=>(Object.entries(e).forEach(([t,r])=>n.set(t,r)),n),an,on,Ie,He,Oe,V,W,ce,Te,cn,ct,dt,dn,un,br,mn=(br=class{constructor(n,e){K(this,an);K(this,on);g(this,"env",{});K(this,Ie);g(this,"finalized",!1);g(this,"error");K(this,He,200);K(this,Oe);K(this,V);K(this,W);K(this,ce);K(this,Te,!0);K(this,cn);K(this,ct);K(this,dt);K(this,dn);K(this,un);g(this,"render",(...n)=>(m(this,ct)??A(this,ct,e=>this.html(e)),m(this,ct).call(this,...n)));g(this,"setLayout",n=>A(this,cn,n));g(this,"getLayout",()=>m(this,cn));g(this,"setRenderer",n=>{A(this,ct,n)});g(this,"header",(n,e,t)=>{if(e===void 0){m(this,V)?m(this,V).delete(n):m(this,W)&&delete m(this,W)[n.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(n);return}t!=null&&t.append?(m(this,V)||(A(this,Te,!1),A(this,V,new Headers(m(this,W))),A(this,W,{})),m(this,V).append(n,e)):m(this,V)?m(this,V).set(n,e):(m(this,W)??A(this,W,{}),m(this,W)[n.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(n,e):this.res.headers.set(n,e))});g(this,"status",n=>{A(this,Te,!1),A(this,He,n)});g(this,"set",(n,e)=>{m(this,Ie)??A(this,Ie,{}),m(this,Ie)[n]=e});g(this,"get",n=>m(this,Ie)?m(this,Ie)[n]:void 0);g(this,"newResponse",(n,e,t)=>{if(m(this,Te)&&!t&&!e&&m(this,He)===200)return new Response(n,{headers:m(this,W)});if(e&&typeof e!="number"){const s=new Headers(e.headers);m(this,V)&&m(this,V).forEach((i,o)=>{o==="set-cookie"?s.append(o,i):s.set(o,i)});const a=qn(s,m(this,W));return new Response(n,{headers:a,status:e.status??m(this,He)})}const r=typeof e=="number"?e:m(this,He);m(this,W)??A(this,W,{}),m(this,V)??A(this,V,new Headers),qn(m(this,V),m(this,W)),m(this,ce)&&(m(this,ce).headers.forEach((s,a)=>{var i,o;a==="set-cookie"?(i=m(this,V))==null||i.append(a,s):(o=m(this,V))==null||o.set(a,s)}),qn(m(this,V),m(this,W))),t??(t={});for(const[s,a]of Object.entries(t))if(typeof a=="string")m(this,V).set(s,a);else{m(this,V).delete(s);for(const i of a)m(this,V).append(s,i)}return new Response(n,{status:r,headers:m(this,V)})});g(this,"body",(n,e,t)=>typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e));g(this,"text",(n,e,t)=>{if(!m(this,W)){if(m(this,Te)&&!t&&!e)return new Response(n);A(this,W,{})}return m(this,W)["content-type"]=sa,typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)});g(this,"json",(n,e,t)=>{const r=JSON.stringify(n);return m(this,W)??A(this,W,{}),m(this,W)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)});g(this,"html",(n,e,t)=>(m(this,W)??A(this,W,{}),m(this,W)["content-type"]="text/html; charset=UTF-8",typeof n=="object"&&(n instanceof Promise||(n=n.toString()),n instanceof Promise)?n.then(r=>Sr(r,ra.Stringify,!1,{})).then(r=>typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)):typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)));g(this,"redirect",(n,e)=>(m(this,V)??A(this,V,new Headers),m(this,V).set("Location",n),this.newResponse(null,e??302)));g(this,"notFound",()=>(m(this,dt)??A(this,dt,()=>new Response),m(this,dt).call(this,this)));A(this,an,n),e&&(A(this,Oe,e.executionCtx),this.env=e.env,A(this,dt,e.notFoundHandler),A(this,un,e.path),A(this,dn,e.matchResult))}get req(){return m(this,on)??A(this,on,new Rr(m(this,an),m(this,un),m(this,dn))),m(this,on)}get event(){if(m(this,Oe)&&"respondWith"in m(this,Oe))return m(this,Oe);throw Error("This context has no FetchEvent")}get executionCtx(){if(m(this,Oe))return m(this,Oe);throw Error("This context has no ExecutionContext")}get res(){return A(this,Te,!1),m(this,ce)||A(this,ce,new Response("404 Not Found",{status:404}))}set res(n){if(A(this,Te,!1),m(this,ce)&&n){m(this,ce).headers.delete("content-type");for(const[e,t]of m(this,ce).headers.entries())if(e==="set-cookie"){const r=m(this,ce).headers.getSetCookie();n.headers.delete("set-cookie");for(const s of r)n.headers.append("set-cookie",s)}else n.headers.set(e,t)}A(this,ce,n),this.finalized=!0}get var(){return{...m(this,Ie)}}},an=new WeakMap,on=new WeakMap,Ie=new WeakMap,He=new WeakMap,Oe=new WeakMap,V=new WeakMap,W=new WeakMap,ce=new WeakMap,Te=new WeakMap,cn=new WeakMap,ct=new WeakMap,dt=new WeakMap,dn=new WeakMap,un=new WeakMap,br),lr=(n,e,t)=>(r,s)=>{let a=-1;return i(0);async function i(o){if(o<=a)throw new Error("next() called multiple times");a=o;let d,u=!1,l;if(n[o]?(l=n[o][0][0],r instanceof mn&&(r.req.routeIndex=o)):l=o===n.length&&s||void 0,!l)r instanceof mn&&r.finalized===!1&&t&&(d=await t(r));else try{d=await l(r,()=>i(o+1))}catch(p){if(p instanceof Error&&r instanceof mn&&e)r.error=p,d=await e(p,r),u=!0;else throw p}return d&&(r.finalized===!1||u)&&(r.res=d),r}},F="ALL",aa="all",ia=["get","post","put","delete","options","patch"],Zr="Can not add a route since the matcher is already built.",Cr=class extends Error{},oa=Symbol("composedHandler"),ca=n=>n.text("404 Not Found",404),pr=(n,e)=>"getResponse"in n?n.getResponse():(console.error(n),e.text("Internal Server Error",500)),de,kr,Ir=(kr=class{constructor(e={}){g(this,"get");g(this,"post");g(this,"put");g(this,"delete");g(this,"options");g(this,"patch");g(this,"all");g(this,"on");g(this,"use");g(this,"router");g(this,"getPath");g(this,"_basePath","/");K(this,de,"/");g(this,"routes",[]);g(this,"notFoundHandler",ca);g(this,"errorHandler",pr);g(this,"onError",e=>(this.errorHandler=e,this));g(this,"notFound",e=>(this.notFoundHandler=e,this));g(this,"fetch",(e,...t)=>this.dispatch(e,t[1],t[0],e.method));g(this,"request",(e,t,r,s)=>{if(e instanceof Request)return t!==void 0&&(e=new Request(e,t)),this.fetch(e,r,s);e=e.toString();const a=/^https?:\/\//.test(e)?e:`http://localhost${Be("/",e)}`,i=new Request(a,t);return this.fetch(i,r,s)});g(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(this.dispatch(e.request,e,void 0,e.request.method))})});[...ia,aa].forEach(s=>{this[s]=(a,...i)=>(typeof a=="string"?A(this,de,a):this.addRoute(s,m(this,de),a),i.forEach(o=>{typeof o!="string"&&this.addRoute(s,m(this,de),o)}),this)}),this.on=(s,a,...i)=>{for(const o of[a].flat()){A(this,de,o);for(const d of[s].flat())i.map(u=>{this.addRoute(d.toUpperCase(),m(this,de),u)})}return this},this.use=(s,...a)=>(typeof s=="string"?A(this,de,s):(A(this,de,"*"),a.unshift(s)),a.forEach(i=>{this.addRoute(F,m(this,de),i)}),this);const r=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=r?e.getPath??Tr:Bs}clone(){const e=new Ir({router:this.router,getPath:this.getPath});return e.routes=this.routes,e}route(e,t){const r=this.basePath(e);return t.routes.map(s=>{let a;t.errorHandler===pr?a=s.handler:(a=async(i,o)=>(await lr([],t.errorHandler)(i,()=>s.handler(i,o))).res,a[oa]=s.handler),r.addRoute(s.method,s.path,a)}),this}basePath(e){const t=this.clone();return t._basePath=Be(this._basePath,e),t}mount(e,t,r){let s,a;r&&(typeof r=="function"?a=r:(a=r.optionHandler,s=r.replaceRequest));const i=a?d=>{const u=a(d);return Array.isArray(u)?u:[u]}:d=>{let u;try{u=d.executionCtx}catch{}return[d.env,u]};s||(s=(()=>{const d=Be(this._basePath,e),u=d==="/"?0:d.length;return l=>{const p=new URL(l.url);return p.pathname=p.pathname.slice(u)||"/",new Request(p,l)}})());const o=async(d,u)=>{const l=await t(s(d.req.raw),...i(d));if(l)return l;await u()};return this.addRoute(F,Be(e,"*"),o),this}addRoute(e,t,r){e=e.toUpperCase(),t=Be(this._basePath,t);const s={path:t,method:e,handler:r};this.router.add(e,t,[r,s]),this.routes.push(s)}matchRoute(e,t){return this.router.match(e,t)}handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}dispatch(e,t,r,s){if(s==="HEAD")return(async()=>new Response(null,await this.dispatch(e,t,r,"GET")))();const a=this.getPath(e,{env:r}),i=this.matchRoute(s,a),o=new mn(e,{path:a,matchResult:i,env:r,executionCtx:t,notFoundHandler:this.notFoundHandler});if(i[0].length===1){let u;try{u=i[0][0][0][0](o,async()=>{o.res=await this.notFoundHandler(o)})}catch(l){return this.handleError(l,o)}return u instanceof Promise?u.then(l=>l||(o.finalized?o.res:this.notFoundHandler(o))).catch(l=>this.handleError(l,o)):u??this.notFoundHandler(o)}const d=lr(i[0],this.errorHandler,this.notFoundHandler);return(async()=>{try{const u=await d(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.handleError(u,o)}})()}},de=new WeakMap,kr),kn="[^/]+",Rt=".*",St="(?:|/.*)",kt=Symbol(),da=new Set(".\\+*[^]$()");function ua(n,e){return n.length===1?e.length===1?n<e?-1:1:-1:e.length===1||n===Rt||n===St?1:e===Rt||e===St?-1:n===kn?1:e===kn?-1:n.length===e.length?n<e?-1:1:e.length-n.length}var Fn=class{constructor(){g(this,"index");g(this,"varIndex");g(this,"children",Object.create(null))}insert(e,t,r,s,a){if(e.length===0){if(this.index!==void 0)throw kt;if(a)return;this.index=t;return}const[i,...o]=e,d=i==="*"?o.length===0?["","",Rt]:["","",kn]:i==="/*"?["","",St]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(d){const l=d[1];let p=d[2]||kn;if(l&&d[2]&&(p=p.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(p)))throw kt;if(u=this.children[p],!u){if(Object.keys(this.children).some(R=>R!==Rt&&R!==St))throw kt;if(a)return;u=this.children[p]=new Fn,l!==""&&(u.varIndex=s.varIndex++)}!a&&l!==""&&r.push([l,u.varIndex])}else if(u=this.children[i],!u){if(Object.keys(this.children).some(l=>l.length>1&&l!==Rt&&l!==St))throw kt;if(a)return;u=this.children[i]=new Fn}u.insert(o,t,r,s,a)}buildRegExpStr(){const t=Object.keys(this.children).sort(ua).map(r=>{const s=this.children[r];return(typeof s.varIndex=="number"?`(${r})@${s.varIndex}`:da.has(r)?`\\${r}`:r)+s.buildRegExpStr()});return typeof this.index=="number"&&t.unshift(`#${this.index}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},la=class{constructor(){g(this,"context",{varIndex:0});g(this,"root",new Fn)}insert(n,e,t){const r=[],s=[];for(let i=0;;){let o=!1;if(n=n.replace(/\{[^}]+\}/g,d=>{const u=`@\\${i}`;return s[i]=[u,d],i++,o=!0,u}),!o)break}const a=n.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let i=s.length-1;i>=0;i--){const[o]=s[i];for(let d=a.length-1;d>=0;d--)if(a[d].indexOf(o)!==-1){a[d]=a[d].replace(o,s[i][1]);break}}return this.root.insert(a,e,r,this.context,t),r}buildRegExp(){let n=this.root.buildRegExpStr();if(n==="")return[/^$/,[],[]];let e=0;const t=[],r=[];return n=n.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,a,i)=>typeof a<"u"?(t[++e]=Number(a),"$()"):(typeof i<"u"&&(r[Number(i)]=++e),"")),[new RegExp(`^${n}`),t,r]}},Nr=[],pa=[/^$/,[],Object.create(null)],gn=Object.create(null);function Pr(n){return gn[n]??(gn[n]=new RegExp(n==="*"?"":`^${n.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function ha(){gn=Object.create(null)}function fa(n){var u;const e=new la,t=[];if(n.length===0)return pa;const r=n.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,p],[R,D])=>l?1:R?-1:p.length-D.length),s=Object.create(null);for(let l=0,p=-1,R=r.length;l<R;l++){const[D,P,j]=r[l];D?s[P]=[j.map(([H])=>[H,Object.create(null)]),Nr]:p++;let U;try{U=e.insert(P,p,D)}catch(H){throw H===kt?new Cr(P):H}D||(t[p]=j.map(([H,ee])=>{const te=Object.create(null);for(ee-=1;ee>=0;ee--){const[Re,ae]=U[ee];te[Re]=ae}return[H,te]}))}const[a,i,o]=e.buildRegExp();for(let l=0,p=t.length;l<p;l++)for(let R=0,D=t[l].length;R<D;R++){const P=(u=t[l][R])==null?void 0:u[1];if(!P)continue;const j=Object.keys(P);for(let U=0,H=j.length;U<H;U++)P[j[U]]=o[P[j[U]]]}const d=[];for(const l in i)d[l]=t[i[l]];return[a,d,s]}function Xe(n,e){if(n){for(const t of Object.keys(n).sort((r,s)=>s.length-r.length))if(Pr(t).test(e))return[...n[t]]}}var ma=class{constructor(){g(this,"name","RegExpRouter");g(this,"middleware");g(this,"routes");this.middleware={[F]:Object.create(null)},this.routes={[F]:Object.create(null)}}add(n,e,t){var o;const{middleware:r,routes:s}=this;if(!r||!s)throw new Error(Zr);r[n]||[r,s].forEach(d=>{d[n]=Object.create(null),Object.keys(d[F]).forEach(u=>{d[n][u]=[...d[F][u]]})}),e==="/*"&&(e="*");const a=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const d=Pr(e);n===F?Object.keys(r).forEach(u=>{var l;(l=r[u])[e]||(l[e]=Xe(r[u],e)||Xe(r[F],e)||[])}):(o=r[n])[e]||(o[e]=Xe(r[n],e)||Xe(r[F],e)||[]),Object.keys(r).forEach(u=>{(n===F||n===u)&&Object.keys(r[u]).forEach(l=>{d.test(l)&&r[u][l].push([t,a])})}),Object.keys(s).forEach(u=>{(n===F||n===u)&&Object.keys(s[u]).forEach(l=>d.test(l)&&s[u][l].push([t,a]))});return}const i=jr(e)||[e];for(let d=0,u=i.length;d<u;d++){const l=i[d];Object.keys(s).forEach(p=>{var R;(n===F||n===p)&&((R=s[p])[l]||(R[l]=[...Xe(r[p],l)||Xe(r[F],l)||[]]),s[p][l].push([t,a-u+d+1]))})}}match(n,e){ha();const t=this.buildAllMatchers();return this.match=(r,s)=>{const a=t[r]||t[F],i=a[2][s];if(i)return i;const o=s.match(a[0]);if(!o)return[[],Nr];const d=o.indexOf("",1);return[a[1][d],o]},this.match(n,e)}buildAllMatchers(){const n=Object.create(null);return[...Object.keys(this.routes),...Object.keys(this.middleware)].forEach(e=>{n[e]||(n[e]=this.buildMatcher(e))}),this.middleware=this.routes=void 0,n}buildMatcher(n){const e=[];let t=n===F;return[this.middleware,this.routes].forEach(r=>{const s=r[n]?Object.keys(r[n]).map(a=>[a,r[n][a]]):[];s.length!==0?(t||(t=!0),e.push(...s)):n!==F&&e.push(...Object.keys(r[F]).map(a=>[a,r[F][a]]))}),t?fa(e):null}},ga=class{constructor(n){g(this,"name","SmartRouter");g(this,"routers",[]);g(this,"routes",[]);Object.assign(this,n)}add(n,e,t){if(!this.routes)throw new Error(Zr);this.routes.push([n,e,t])}match(n,e){if(!this.routes)throw new Error("Fatal error");const{routers:t,routes:r}=this,s=t.length;let a=0,i;for(;a<s;a++){const o=t[a];try{r.forEach(d=>{o.add(...d)}),i=o.match(n,e)}catch(d){if(d instanceof Cr)continue;throw d}this.match=o.match.bind(o),this.routers=[o],this.routes=void 0;break}if(a===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,i}get activeRouter(){if(this.routes||this.routers.length!==1)throw new Error("No active router has been determined yet.");return this.routers[0]}},Ar=class{constructor(n,e,t){g(this,"methods");g(this,"children");g(this,"patterns");g(this,"order",0);g(this,"name");g(this,"params",Object.create(null));if(this.children=t||Object.create(null),this.methods=[],this.name="",n&&e){const r=Object.create(null);r[n]={handler:e,possibleKeys:[],score:0,name:this.name},this.methods=[r]}this.patterns=[]}insert(n,e,t){this.name=`${n} ${e}`,this.order=++this.order;let r=this;const s=Ls(e),a=[];for(let d=0,u=s.length;d<u;d++){const l=s[d];if(Object.keys(r.children).includes(l)){r=r.children[l];const R=ur(l);R&&a.push(R[1]);continue}r.children[l]=new Ar;const p=ur(l);p&&(r.patterns.push(p),a.push(p[1])),r=r.children[l]}r.methods.length||(r.methods=[]);const i=Object.create(null),o={handler:t,possibleKeys:a.filter((d,u,l)=>l.indexOf(d)===u),name:this.name,score:this.order};return i[n]=o,r.methods.push(i),r}gHSets(n,e,t,r){const s=[];for(let a=0,i=n.methods.length;a<i;a++){const o=n.methods[a],d=o[e]||o[F],u=Object.create(null);d!==void 0&&(d.params=Object.create(null),d.possibleKeys.forEach(l=>{const p=u[d.name];d.params[l]=r[l]&&!p?r[l]:t[l]??r[l],u[d.name]=!0}),s.push(d))}return s}search(n,e){const t=[];this.params=Object.create(null);let s=[this];const a=Or(e);for(let o=0,d=a.length;o<d;o++){const u=a[o],l=o===d-1,p=[];for(let R=0,D=s.length;R<D;R++){const P=s[R],j=P.children[u];j&&(j.params=P.params,l===!0?(j.children["*"]&&t.push(...this.gHSets(j.children["*"],n,P.params,Object.create(null))),t.push(...this.gHSets(j,n,P.params,Object.create(null)))):p.push(j));for(let U=0,H=P.patterns.length;U<H;U++){const ee=P.patterns[U],te={...P.params};if(ee==="*"){const ie=P.children["*"];ie&&(t.push(...this.gHSets(ie,n,P.params,Object.create(null))),p.push(ie));continue}if(u==="")continue;const[Re,ae,ne]=ee,X=P.children[Re],ge=a.slice(o).join("/");if(ne instanceof RegExp&&ne.test(ge)){te[ae]=ge,t.push(...this.gHSets(X,n,P.params,te));continue}(ne===!0||ne instanceof RegExp&&ne.test(u))&&typeof Re=="string"&&(te[ae]=u,l===!0?(t.push(...this.gHSets(X,n,te,P.params)),X.children["*"]&&t.push(...this.gHSets(X.children["*"],n,te,P.params))):(X.params=te,p.push(X)))}}s=p}return[t.sort((o,d)=>o.score-d.score).map(({handler:o,params:d})=>[o,d])]}},_a=class{constructor(){g(this,"name","TrieRouter");g(this,"node");this.node=new Ar}add(n,e,t){const r=jr(e);if(r){for(const s of r)this.node.insert(n,s,t);return}this.node.insert(n,e,t)}match(n,e){return this.node.search(n,e)}},ya=class extends Ir{constructor(n={}){super(n),this.router=n.router??new ga({routers:[new ma,new _a]})}},M;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(M||(M={}));var Kn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Kn||(Kn={}));const v=M.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ze=n=>{switch(typeof n){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(n)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(n)?v.array:n===null?v.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?v.promise:typeof Map<"u"&&n instanceof Map?v.map:typeof Set<"u"&&n instanceof Set?v.set:typeof Date<"u"&&n instanceof Date?v.date:v.object;default:return v.unknown}},h=M.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"]),va=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class re extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof re))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,M.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}re.create=n=>new re(n);const ut=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===v.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,M.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${M.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${M.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${M.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:M.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,M.assertNever(n)}return{message:t}};let Mr=ut;function ba(n){Mr=n}function wn(){return Mr}const xn=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},ka=[];function _(n,e){const t=wn(),r=xn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ut?void 0:ut].filter(s=>!!s)});n.common.issues.push(r)}class z{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return T;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return z.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return T;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const T=Object.freeze({status:"aborted"}),rt=n=>({status:"dirty",value:n}),J=n=>({status:"valid",value:n}),Gn=n=>n.status==="aborted",zn=n=>n.status==="dirty",Zt=n=>n.status==="valid",Ct=n=>typeof Promise<"u"&&n instanceof Promise;function On(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function $r(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var k;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(k||(k={}));var wt,xt;class ve{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const hr=(n,e)=>{if(Zt(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new re(n.common.issues);return this._error=t,this._error}}};function S(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var d,u;const{message:l}=n;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(d=l??r)!==null&&d!==void 0?d:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class I{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ze(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new z,ctx:{common:e.parent.common,data:e.data,parsedType:Ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ct(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ze(e)},a=this._parseSync({data:e,path:s.path,parent:s});return hr(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ze(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Ct(s)?s:Promise.resolve(s));return hr(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new fe({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _e.create(this,this._def)}nullable(){return Me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pe.create(this,this._def)}promise(){return pt.create(this,this._def)}or(e){return At.create([this,e],this._def)}and(e){return Mt.create(this,e,this._def)}transform(e){return new fe({...S(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Vt({...S(this._def),innerType:this,defaultValue:t,typeName:x.ZodDefault})}brand(){return new rr({typeName:x.ZodBranded,type:this,...S(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new qt({...S(this._def),innerType:this,catchValue:t,typeName:x.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ln.create(this,e)}readonly(){return Bt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const wa=/^c[^\s-]{8,}$/i,xa=/^[0-9a-z]+$/,Oa=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ta=/^[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,ja=/^[a-z0-9_-]{21}$/i,Ea=/^[-+]?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)?)??$/,Ra=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Sa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Bn;const Za=/^(?:(?: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])$/,Ca=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ia=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dr="((\\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])))",Na=new RegExp(`^${Dr}$`);function Lr(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Pa(n){return new RegExp(`^${Lr(n)}$`)}function Ur(n){let e=`${Dr}T${Lr(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Aa(n,e){return!!((e==="v4"||!e)&&Za.test(n)||(e==="v6"||!e)&&Ca.test(n))}class ue extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_type,expected:v.string,received:a.parsedType}),T}const r=new z;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?_(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&_(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Ra.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"email",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Bn||(Bn=new RegExp(Sa,"u")),Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"emoji",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Ta.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"uuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")ja.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"nanoid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")wa.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"cuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")xa.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"cuid2",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Oa.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"ulid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),_(s,{validation:"url",code:h.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"regex",code:h.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Ur(a).test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Na.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Pa(a).test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{code:h.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?Ea.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"duration",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Aa(e.data,a.version)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"ip",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Ia.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"base64",code:h.invalid_string,message:a.message}),r.dirty()):M.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...k.errToObj(r)})}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...k.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...k.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...k.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new ue({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ue({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ue({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ue.create=n=>{var e;return new ue({checks:[],typeName:x.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};function Ma(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Ne extends I{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)!==v.number){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_type,expected:v.number,received:a.parsedType}),T}let r;const s=new z;for(const a of this._def.checks)a.kind==="int"?M.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Ma(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:h.not_finite,message:a.message}),s.dirty()):M.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,s){return new Ne({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(s)}]})}_addCheck(e){return new Ne({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&M.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ne.create=n=>new Ne({checks:[],typeName:x.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Pe extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==v.bigint){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_type,expected:v.bigint,received:a.parsedType}),T}let r;const s=new z;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),_(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):M.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,r,s){return new Pe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:k.toString(s)}]})}_addCheck(e){return new Pe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Pe.create=n=>{var e;return new Pe({checks:[],typeName:x.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};class It extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.boolean,received:r.parsedType}),T}return J(e.data)}}It.create=n=>new It({typeName:x.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Ge extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_type,expected:v.date,received:a.parsedType}),T}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return _(a,{code:h.invalid_date}),T}const r=new z;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):M.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ge({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ge.create=n=>new Ge({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:x.ZodDate,...S(n)});class Tn extends I{_parse(e){if(this._getType(e)!==v.symbol){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.symbol,received:r.parsedType}),T}return J(e.data)}}Tn.create=n=>new Tn({typeName:x.ZodSymbol,...S(n)});class Nt extends I{_parse(e){if(this._getType(e)!==v.undefined){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.undefined,received:r.parsedType}),T}return J(e.data)}}Nt.create=n=>new Nt({typeName:x.ZodUndefined,...S(n)});class Pt extends I{_parse(e){if(this._getType(e)!==v.null){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.null,received:r.parsedType}),T}return J(e.data)}}Pt.create=n=>new Pt({typeName:x.ZodNull,...S(n)});class lt extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}}lt.create=n=>new lt({typeName:x.ZodAny,...S(n)});class Fe extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}}Fe.create=n=>new Fe({typeName:x.ZodUnknown,...S(n)});class je extends I{_parse(e){const t=this._getOrReturnCtx(e);return _(t,{code:h.invalid_type,expected:v.never,received:t.parsedType}),T}}je.create=n=>new je({typeName:x.ZodNever,...S(n)});class jn extends I{_parse(e){if(this._getType(e)!==v.undefined){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.void,received:r.parsedType}),T}return J(e.data)}}jn.create=n=>new jn({typeName:x.ZodVoid,...S(n)});class pe extends I{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return _(t,{code:h.invalid_type,expected:v.array,received:t.parsedType}),T;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(_(t,{code:i?h.too_big:h.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(_(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(_(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ve(t,i,t.path,o)))).then(i=>z.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ve(t,i,t.path,o)));return z.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new pe({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new pe({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new pe({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}pe.create=(n,e)=>new pe({type:n,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...S(e)});function tt(n){if(n instanceof q){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=_e.create(tt(r))}return new q({...n._def,shape:()=>e})}else return n instanceof pe?new pe({...n._def,type:tt(n.element)}):n instanceof _e?_e.create(tt(n.unwrap())):n instanceof Me?Me.create(tt(n.unwrap())):n instanceof be?be.create(n.items.map(e=>tt(e))):n}class q extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=M.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==v.object){const u=this._getOrReturnCtx(e);return _(u,{code:h.invalid_type,expected:v.object,received:u.parsedType}),T}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof je&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const d=[];for(const u of i){const l=a[u],p=s.data[u];d.push({key:{status:"valid",value:u},value:l._parse(new ve(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof je){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)d.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(_(s,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of o){const p=s.data[l];d.push({key:{status:"valid",value:l},value:u._parse(new ve(s,p,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of d){const p=await l.key,R=await l.value;u.push({key:p,value:R,alwaysSet:l.alwaysSet})}return u}).then(u=>z.mergeObjectSync(r,u)):z.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new q({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=k.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new q({...this._def,unknownKeys:"strip"})}passthrough(){return new q({...this._def,unknownKeys:"passthrough"})}extend(e){return new q({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new q({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new q({...this._def,catchall:e})}pick(e){const t={};return M.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new q({...this._def,shape:()=>t})}omit(e){const t={};return M.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new q({...this._def,shape:()=>t})}deepPartial(){return tt(this)}partial(e){const t={};return M.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new q({...this._def,shape:()=>t})}required(e){const t={};return M.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof _e;)a=a._def.innerType;t[r]=a}}),new q({...this._def,shape:()=>t})}keyof(){return Vr(M.objectKeys(this.shape))}}q.create=(n,e)=>new q({shape:()=>n,unknownKeys:"strip",catchall:je.create(),typeName:x.ZodObject,...S(e)});q.strictCreate=(n,e)=>new q({shape:()=>n,unknownKeys:"strict",catchall:je.create(),typeName:x.ZodObject,...S(e)});q.lazycreate=(n,e)=>new q({shape:n,unknownKeys:"strip",catchall:je.create(),typeName:x.ZodObject,...S(e)});class At extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new re(o.ctx.common.issues));return _(t,{code:h.invalid_union,unionErrors:i}),T}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new re(d));return _(t,{code:h.invalid_union,unionErrors:o}),T}}get options(){return this._def.options}}At.create=(n,e)=>new At({options:n,typeName:x.ZodUnion,...S(e)});const xe=n=>n instanceof Dt?xe(n.schema):n instanceof fe?xe(n.innerType()):n instanceof Lt?[n.value]:n instanceof Ae?n.options:n instanceof Ut?M.objectValues(n.enum):n instanceof Vt?xe(n._def.innerType):n instanceof Nt?[void 0]:n instanceof Pt?[null]:n instanceof _e?[void 0,...xe(n.unwrap())]:n instanceof Me?[null,...xe(n.unwrap())]:n instanceof rr||n instanceof Bt?xe(n.unwrap()):n instanceof qt?xe(n._def.innerType):[];class Dn extends I{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return _(t,{code:h.invalid_type,expected:v.object,received:t.parsedType}),T;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(_(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),T)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=xe(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Dn({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...S(r)})}}function Yn(n,e){const t=Ze(n),r=Ze(e);if(n===e)return{valid:!0,data:n};if(t===v.object&&r===v.object){const s=M.objectKeys(e),a=M.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i={...n,...e};for(const o of a){const d=Yn(n[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===v.array&&r===v.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],d=Yn(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===v.date&&r===v.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Mt extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(Gn(a)||Gn(i))return T;const o=Yn(a.value,i.value);return o.valid?((zn(a)||zn(i))&&t.dirty(),{status:t.value,value:o.data}):(_(r,{code:h.invalid_intersection_types}),T)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Mt.create=(n,e,t)=>new Mt({left:n,right:e,typeName:x.ZodIntersection,...S(t)});class be extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.array)return _(r,{code:h.invalid_type,expected:v.array,received:r.parsedType}),T;if(r.data.length<this._def.items.length)return _(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;!this._def.rest&&r.data.length>this._def.items.length&&(_(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new ve(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>z.mergeArray(t,i)):z.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new be({...this._def,rest:e})}}be.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new be({items:n,typeName:x.ZodTuple,rest:null,...S(e)})};class $t extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return _(r,{code:h.invalid_type,expected:v.object,received:r.parsedType}),T;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ve(r,o,r.path,o)),value:i._parse(new ve(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?z.mergeObjectAsync(t,s):z.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof I?new $t({keyType:e,valueType:t,typeName:x.ZodRecord,...S(r)}):new $t({keyType:ue.create(),valueType:e,typeName:x.ZodRecord,...S(t)})}}class En extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.map)return _(r,{code:h.invalid_type,expected:v.map,received:r.parsedType}),T;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],u)=>({key:s._parse(new ve(r,o,r.path,[u,"key"])),value:a._parse(new ve(r,d,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return T;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return T;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}En.create=(n,e,t)=>new En({valueType:e,keyType:n,typeName:x.ZodMap,...S(t)});class ze extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==v.set)return _(r,{code:h.invalid_type,expected:v.set,received:r.parsedType}),T;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(_(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(_(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const l of d){if(l.status==="aborted")return T;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((d,u)=>a._parse(new ve(r,d,r.path,u)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new ze({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new ze({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ze.create=(n,e)=>new ze({valueType:n,minSize:null,maxSize:null,typeName:x.ZodSet,...S(e)});class at extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return _(t,{code:h.invalid_type,expected:v.function,received:t.parsedType}),T;function r(o,d){return xn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,wn(),ut].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:d}})}function s(o,d){return xn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,wn(),ut].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof pt){const o=this;return J(async function(...d){const u=new re([]),l=await o._def.args.parseAsync(d,a).catch(D=>{throw u.addIssue(r(d,D)),u}),p=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(p,a).catch(D=>{throw u.addIssue(s(p,D)),u})})}else{const o=this;return J(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new re([r(d,u.error)]);const l=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(l,a);if(!p.success)throw new re([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new at({...this._def,args:be.create(e).rest(Fe.create())})}returns(e){return new at({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new at({args:e||be.create([]).rest(Fe.create()),returns:t||Fe.create(),typeName:x.ZodFunction,...S(r)})}}class Dt extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Dt.create=(n,e)=>new Dt({getter:n,typeName:x.ZodLazy,...S(e)});class Lt extends I{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}Lt.create=(n,e)=>new Lt({value:n,typeName:x.ZodLiteral,...S(e)});function Vr(n,e){return new Ae({values:n,typeName:x.ZodEnum,...S(e)})}class Ae extends I{constructor(){super(...arguments),wt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{expected:M.joinValues(r),received:t.parsedType,code:h.invalid_type}),T}if(On(this,wt)||$r(this,wt,new Set(this._def.values)),!On(this,wt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return _(t,{received:t.data,code:h.invalid_enum_value,options:r}),T}return J(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ae.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ae.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}wt=new WeakMap;Ae.create=Vr;class Ut extends I{constructor(){super(...arguments),xt.set(this,void 0)}_parse(e){const t=M.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==v.string&&r.parsedType!==v.number){const s=M.objectValues(t);return _(r,{expected:M.joinValues(s),received:r.parsedType,code:h.invalid_type}),T}if(On(this,xt)||$r(this,xt,new Set(M.getValidEnumValues(this._def.values))),!On(this,xt).has(e.data)){const s=M.objectValues(t);return _(r,{received:r.data,code:h.invalid_enum_value,options:s}),T}return J(e.data)}get enum(){return this._def.values}}xt=new WeakMap;Ut.create=(n,e)=>new Ut({values:n,typeName:x.ZodNativeEnum,...S(e)});class pt extends I{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return _(t,{code:h.invalid_type,expected:v.promise,received:t.parsedType}),T;const r=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return J(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}pt.create=(n,e)=>new pt({type:n,typeName:x.ZodPromise,...S(e)});class fe extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{_(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return T;const d=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return d.status==="aborted"?T:d.status==="dirty"||t.value==="dirty"?rt(d.value):d});{if(t.value==="aborted")return T;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?T:o.status==="dirty"||t.value==="dirty"?rt(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?T:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?T:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Zt(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Zt(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);M.assertNever(s)}}fe.create=(n,e,t)=>new fe({schema:n,typeName:x.ZodEffects,effect:e,...S(t)});fe.createWithPreprocess=(n,e,t)=>new fe({schema:e,effect:{type:"preprocess",transform:n},typeName:x.ZodEffects,...S(t)});class _e extends I{_parse(e){return this._getType(e)===v.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_e.create=(n,e)=>new _e({innerType:n,typeName:x.ZodOptional,...S(e)});class Me extends I{_parse(e){return this._getType(e)===v.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Me.create=(n,e)=>new Me({innerType:n,typeName:x.ZodNullable,...S(e)});class Vt extends I{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===v.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Vt.create=(n,e)=>new Vt({innerType:n,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class qt extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ct(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}qt.create=(n,e)=>new qt({innerType:n,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class Rn extends I{_parse(e){if(this._getType(e)!==v.nan){const r=this._getOrReturnCtx(e);return _(r,{code:h.invalid_type,expected:v.nan,received:r.parsedType}),T}return{status:"valid",value:e.data}}}Rn.create=n=>new Rn({typeName:x.ZodNaN,...S(n)});const $a=Symbol("zod_brand");class rr extends I{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ln extends I{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?T:a.status==="dirty"?(t.dirty(),rt(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?T:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ln({in:e,out:t,typeName:x.ZodPipeline})}}class Bt extends I{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Zt(s)&&(s.value=Object.freeze(s.value)),s);return Ct(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}Bt.create=(n,e)=>new Bt({innerType:n,typeName:x.ZodReadonly,...S(e)});function qr(n,e={},t){return n?lt.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:d})}}):lt.create()}const Da={object:q.lazycreate};var x;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(x||(x={}));const La=(n,e={message:`Input not instance of ${n.name}`})=>qr(t=>t instanceof n,e),Br=ue.create,Wr=Ne.create,Ua=Rn.create,Va=Pe.create,Hr=It.create,qa=Ge.create,Ba=Tn.create,Wa=Nt.create,Ha=Pt.create,Fa=lt.create,Ka=Fe.create,Ga=je.create,za=jn.create,Ya=pe.create,Ja=q.create,Qa=q.strictCreate,Xa=At.create,ei=Dn.create,ti=Mt.create,ni=be.create,ri=$t.create,si=En.create,ai=ze.create,ii=at.create,oi=Dt.create,ci=Lt.create,di=Ae.create,ui=Ut.create,li=pt.create,fr=fe.create,pi=_e.create,hi=Me.create,fi=fe.createWithPreprocess,mi=ln.create,gi=()=>Br().optional(),_i=()=>Wr().optional(),yi=()=>Hr().optional(),vi={string:n=>ue.create({...n,coerce:!0}),number:n=>Ne.create({...n,coerce:!0}),boolean:n=>It.create({...n,coerce:!0}),bigint:n=>Pe.create({...n,coerce:!0}),date:n=>Ge.create({...n,coerce:!0})},bi=T;var G=Object.freeze({__proto__:null,defaultErrorMap:ut,setErrorMap:ba,getErrorMap:wn,makeIssue:xn,EMPTY_PATH:ka,addIssueToContext:_,ParseStatus:z,INVALID:T,DIRTY:rt,OK:J,isAborted:Gn,isDirty:zn,isValid:Zt,isAsync:Ct,get util(){return M},get objectUtil(){return Kn},ZodParsedType:v,getParsedType:Ze,ZodType:I,datetimeRegex:Ur,ZodString:ue,ZodNumber:Ne,ZodBigInt:Pe,ZodBoolean:It,ZodDate:Ge,ZodSymbol:Tn,ZodUndefined:Nt,ZodNull:Pt,ZodAny:lt,ZodUnknown:Fe,ZodNever:je,ZodVoid:jn,ZodArray:pe,ZodObject:q,ZodUnion:At,ZodDiscriminatedUnion:Dn,ZodIntersection:Mt,ZodTuple:be,ZodRecord:$t,ZodMap:En,ZodSet:ze,ZodFunction:at,ZodLazy:Dt,ZodLiteral:Lt,ZodEnum:Ae,ZodNativeEnum:Ut,ZodPromise:pt,ZodEffects:fe,ZodTransformer:fe,ZodOptional:_e,ZodNullable:Me,ZodDefault:Vt,ZodCatch:qt,ZodNaN:Rn,BRAND:$a,ZodBranded:rr,ZodPipeline:ln,ZodReadonly:Bt,custom:qr,Schema:I,ZodSchema:I,late:Da,get ZodFirstPartyTypeKind(){return x},coerce:vi,any:Fa,array:Ya,bigint:Va,boolean:Hr,date:qa,discriminatedUnion:ei,effect:fr,enum:di,function:ii,instanceof:La,intersection:ti,lazy:oi,literal:ci,map:si,nan:Ua,nativeEnum:ui,never:Ga,null:Ha,nullable:hi,number:Wr,object:Ja,oboolean:yi,onumber:_i,optional:pi,ostring:gi,pipeline:mi,preprocess:fi,promise:li,record:ri,set:ai,strictObject:Qa,string:Br,symbol:Ba,transformer:fr,tuple:ni,undefined:Wa,union:Xa,unknown:Ka,void:za,NEVER:bi,ZodIssueCode:h,quotelessJson:va,ZodError:re}),Wt=class Jn extends ya{constructor(t){super(t);g(this,"openAPIRegistry");g(this,"defaultHook");g(this,"openapi",({middleware:t,...r},s,a=this.defaultHook)=>{var u,l,p,R,D,P;this.openAPIRegistry.registerPath(r);const i=[];if((u=r.request)!=null&&u.query){const j=Qe("query",r.request.query,a);i.push(j)}if((l=r.request)!=null&&l.params){const j=Qe("param",r.request.params,a);i.push(j)}if((p=r.request)!=null&&p.headers){const j=Qe("header",r.request.headers,a);i.push(j)}if((R=r.request)!=null&&R.cookies){const j=Qe("cookie",r.request.cookies,a);i.push(j)}const o=(P=(D=r.request)==null?void 0:D.body)==null?void 0:P.content;if(o)for(const j of Object.keys(o)){if(!o[j])continue;const U=o[j].schema;if(U instanceof I){if(j.startsWith("application/json")){const H=Qe("json",U,a);i.push(H)}if(j.startsWith("multipart/form-data")||j.startsWith("application/x-www-form-urlencoded")){const H=Qe("form",U,a);i.push(H)}}}const d=t?Array.isArray(t)?t:[t]:[];return this.on([r.method],r.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...d,...i,s),this});g(this,"getOpenAPIDocument",t=>new As(this.openAPIRegistry.definitions).generateDocument(t));g(this,"getOpenAPI31Document",t=>new Ds(this.openAPIRegistry.definitions).generateDocument(t));g(this,"doc",(t,r)=>this.get(t,s=>{const a=typeof r=="function"?r(s):r;try{const i=this.getOpenAPIDocument(a);return s.json(i)}catch(i){return s.json(i,500)}}));g(this,"doc31",(t,r)=>this.get(t,s=>{const a=typeof r=="function"?r(s):r;try{const i=this.getOpenAPI31Document(a);return s.json(i)}catch(i){return s.json(i,500)}}));this.openAPIRegistry=new _s,this.defaultHook=t==null?void 0:t.defaultHook}route(t,r){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,r),r instanceof Jn?(r.openAPIRegistry.definitions.forEach(a=>{switch(a.type){case"component":return this.openAPIRegistry.registerComponent(a.componentType,a.name,a.component);case"route":return this.openAPIRegistry.registerPath({...a.route,path:Be(s,a.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...a.webhook,path:Be(s,a.webhook.path)});case"schema":return this.openAPIRegistry.register(a.schema._def.openapi._internal.refId,a.schema);case"parameter":return this.openAPIRegistry.registerParameter(a.schema._def.openapi._internal.refId,a.schema);default:{const i=a;throw new Error(`Unknown registry type: ${i}`)}}}),this):this}basePath(t){return new Jn({...super.basePath(t),defaultHook:this.defaultHook})}},We=n=>{const e={...n,getRoutingPath(){return n.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};hs(G);function ki(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function wi(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function vt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function xi(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var i,o,d,u,l,p;const R=typeof s=="string"?a:s,D=R??{},{param:P}=D,j=ki(D,["param"]),U=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),H=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),j),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||P?{param:Object.assign(Object.assign({},(p=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||p===void 0?void 0:p.param),P)}:void 0),ee=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(U).length>0?{_internal:U}:void 0),Object.keys(H).length>0?{metadata:H}:void 0)}));if(wi(this,"ZodObject")){const te=this.extend;ee.extend=function(...Re){var ae,ne,X,ge,ie,Ve;const qe=te.apply(this,Re);return qe._def.openapi={_internal:{extendedFrom:!((ne=(ae=this._def.openapi)===null||ae===void 0?void 0:ae._internal)===null||ne===void 0)&&ne.refId?{refId:(ge=(X=this._def.openapi)===null||X===void 0?void 0:X._internal)===null||ge===void 0?void 0:ge.refId,schema:this}:(ie=this._def.openapi)===null||ie===void 0?void 0:ie._internal.extendedFrom},metadata:(Ve=qe._def.openapi)===null||Ve===void 0?void 0:Ve.metadata},qe}}return ee},vt(n,"optional"),vt(n,"nullable"),vt(n,"default"),vt(n,"transform"),vt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,d])=>{var u,l;d._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var $;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return n.objectValues(i)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},n.find=(s,a)=>{for(const i of s)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})($||($={}));var Qn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Qn||(Qn={}));const b=$.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ce=n=>{switch(typeof n){case"undefined":return b.undefined;case"string":return b.string;case"number":return isNaN(n)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(n)?b.array:n===null?b.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?b.promise:typeof Map<"u"&&n instanceof Map?b.map:typeof Set<"u"&&n instanceof Set?b.set:typeof Date<"u"&&n instanceof Date?b.date:b.object;default:return b.unknown}},f=$.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"]),Oi=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class se extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof se))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}se.create=n=>new se(n);const ht=(n,e)=>{let t;switch(n.code){case f.invalid_type:n.received===b.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,$.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${$.joinValues(n.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${$.joinValues(n.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${$.joinValues(n.options)}, received '${n.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:$.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case f.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case f.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,$.assertNever(n)}return{message:t}};let Fr=ht;function Ti(n){Fr=n}function Sn(){return Fr}const Zn=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},ji=[];function y(n,e){const t=Sn(),r=Zn({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ht?void 0:ht].filter(s=>!!s)});n.common.issues.push(r)}class Y{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return E;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return Y.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return E;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const E=Object.freeze({status:"aborted"}),Cn=n=>({status:"dirty",value:n}),Q=n=>({status:"valid",value:n}),Xn=n=>n.status==="aborted",er=n=>n.status==="dirty",Ht=n=>n.status==="valid",Ft=n=>typeof Promise<"u"&&n instanceof Promise;function In(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Kr(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var w;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Ot,Tt;class ke{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const mr=(n,e)=>{if(Ht(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new se(n.common.issues);return this._error=t,this._error}}};function Z(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>{var o,d;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??i.defaultError}:typeof i.data>"u"?{message:(o=u??r)!==null&&o!==void 0?o:i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:(d=u??t)!==null&&d!==void 0?d:i.defaultError}},description:s}}class N{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ce(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Y,ctx:{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ft(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},a=this._parseSync({data:e,path:s.path,parent:s});return mr(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Ft(s)?s:Promise.resolve(s));return mr(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:f.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new me({schema:this,typeName:O.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ye.create(this,this._def)}nullable(){return Ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return he.create(this,this._def)}promise(){return mt.create(this,this._def)}or(e){return Yt.create([this,e],this._def)}and(e){return Jt.create(this,e,this._def)}transform(e){return new me({...Z(this._def),schema:this,typeName:O.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new nn({...Z(this._def),innerType:this,defaultValue:t,typeName:O.ZodDefault})}brand(){return new sr({typeName:O.ZodBranded,type:this,...Z(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new rn({...Z(this._def),innerType:this,catchValue:t,typeName:O.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pn.create(this,e)}readonly(){return sn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ei=/^c[^\s-]{8,}$/i,Ri=/^[0-9a-z]+$/,Si=/^[0-9A-HJKMNP-TV-Z]{26}$/,Zi=/^[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,Ci=/^[a-z0-9_-]{21}$/i,Ii=/^[-+]?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)?)??$/,Ni=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wn;const Ai=/^(?:(?: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])$/,Mi=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,$i=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gr="((\\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])))",Di=new RegExp(`^${Gr}$`);function zr(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Li(n){return new RegExp(`^${zr(n)}$`)}function Yr(n){let e=`${Gr}T${zr(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ui(n,e){return!!((e==="v4"||!e)&&Ai.test(n)||(e==="v6"||!e)&&Mi.test(n))}class le extends N{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_type,expected:b.string,received:s.parsedType}),E}const t=new Y;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:f.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:f.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(r=this._getOrReturnCtx(e,r),a?y(r,{code:f.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&y(r,{code:f.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Ni.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"email",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Wn||(Wn=new RegExp(Pi,"u")),Wn.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"emoji",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Zi.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"uuid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")Ci.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"nanoid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")Ei.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"cuid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")Ri.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"cuid2",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Si.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"ulid",code:f.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),y(r,{validation:"url",code:f.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"regex",code:f.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?Yr(s).test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Di.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Li(s).test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{code:f.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?Ii.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"duration",code:f.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Ui(e.data,s.version)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"ip",code:f.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?$i.test(e.data)||(r=this._getOrReturnCtx(e,r),y(r,{validation:"base64",code:f.invalid_string,message:s.message}),t.dirty()):$.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:f.invalid_string,...w.errToObj(r)})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...w.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...w.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new le({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}le.create=n=>{var e;return new le({checks:[],typeName:O.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...Z(n)})};function Vi(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class $e extends N{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)!==b.number){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_type,expected:b.number,received:s.parsedType}),E}let t;const r=new Y;for(const s of this._def.checks)s.kind==="int"?$.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),y(t,{code:f.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?Vi(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),y(t,{code:f.not_finite,message:s.message}),r.dirty()):$.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new $e({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new $e({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&$.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}$e.create=n=>new $e({checks:[],typeName:O.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Z(n)});class De extends N{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==b.bigint){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_type,expected:b.bigint,received:s.parsedType}),E}let t;const r=new Y;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),y(t,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):$.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new De({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}De.create=n=>{var e;return new De({checks:[],typeName:O.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...Z(n)})};class Kt extends N{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.boolean,received:t.parsedType}),E}return Q(e.data)}}Kt.create=n=>new Kt({typeName:O.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Z(n)});class Ye extends N{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_type,expected:b.date,received:s.parsedType}),E}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return y(s,{code:f.invalid_date}),E}const t=new Y;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:f.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),y(r,{code:f.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):$.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ye({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ye.create=n=>new Ye({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:O.ZodDate,...Z(n)});class Nn extends N{_parse(e){if(this._getType(e)!==b.symbol){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.symbol,received:t.parsedType}),E}return Q(e.data)}}Nn.create=n=>new Nn({typeName:O.ZodSymbol,...Z(n)});class Gt extends N{_parse(e){if(this._getType(e)!==b.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.undefined,received:t.parsedType}),E}return Q(e.data)}}Gt.create=n=>new Gt({typeName:O.ZodUndefined,...Z(n)});class zt extends N{_parse(e){if(this._getType(e)!==b.null){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.null,received:t.parsedType}),E}return Q(e.data)}}zt.create=n=>new zt({typeName:O.ZodNull,...Z(n)});class ft extends N{constructor(){super(...arguments),this._any=!0}_parse(e){return Q(e.data)}}ft.create=n=>new ft({typeName:O.ZodAny,...Z(n)});class Ke extends N{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Q(e.data)}}Ke.create=n=>new Ke({typeName:O.ZodUnknown,...Z(n)});class Ee extends N{_parse(e){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.never,received:t.parsedType}),E}}Ee.create=n=>new Ee({typeName:O.ZodNever,...Z(n)});class Pn extends N{_parse(e){if(this._getType(e)!==b.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.void,received:t.parsedType}),E}return Q(e.data)}}Pn.create=n=>new Pn({typeName:O.ZodVoid,...Z(n)});class he extends N{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==b.array)return y(t,{code:f.invalid_type,expected:b.array,received:t.parsedType}),E;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(y(t,{code:i?f.too_big:f.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(y(t,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(y(t,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new ke(t,i,t.path,o)))).then(i=>Y.mergeArray(r,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new ke(t,i,t.path,o)));return Y.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new he({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new he({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new he({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}he.create=(n,e)=>new he({type:n,minLength:null,maxLength:null,exactLength:null,typeName:O.ZodArray,...Z(e)});function nt(n){if(n instanceof B){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=ye.create(nt(r))}return new B({...n._def,shape:()=>e})}else return n instanceof he?new he({...n._def,type:nt(n.element)}):n instanceof ye?ye.create(nt(n.unwrap())):n instanceof Ue?Ue.create(nt(n.unwrap())):n instanceof we?we.create(n.items.map(e=>nt(e))):n}class B extends N{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=$.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==b.object){const d=this._getOrReturnCtx(e);return y(d,{code:f.invalid_type,expected:b.object,received:d.parsedType}),E}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ee&&this._def.unknownKeys==="strip"))for(const d in r.data)a.includes(d)||i.push(d);const o=[];for(const d of a){const u=s[d],l=r.data[d];o.push({key:{status:"valid",value:d},value:u._parse(new ke(r,l,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof Ee){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of i)o.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")i.length>0&&(y(r,{code:f.unrecognized_keys,keys:i}),t.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of i){const l=r.data[u];o.push({key:{status:"valid",value:u},value:d._parse(new ke(r,l,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of o){const l=await u.key,p=await u.value;d.push({key:l,value:p,alwaysSet:u.alwaysSet})}return d}).then(d=>Y.mergeObjectSync(t,d)):Y.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new B({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,i,o;const d=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=w.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new B({...this._def,unknownKeys:"strip"})}passthrough(){return new B({...this._def,unknownKeys:"passthrough"})}extend(e){return new B({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new B({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:O.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new B({...this._def,catchall:e})}pick(e){const t={};return $.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new B({...this._def,shape:()=>t})}omit(e){const t={};return $.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new B({...this._def,shape:()=>t})}deepPartial(){return nt(this)}partial(e){const t={};return $.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new B({...this._def,shape:()=>t})}required(e){const t={};return $.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof ye;)s=s._def.innerType;t[r]=s}}),new B({...this._def,shape:()=>t})}keyof(){return Jr($.objectKeys(this.shape))}}B.create=(n,e)=>new B({shape:()=>n,unknownKeys:"strip",catchall:Ee.create(),typeName:O.ZodObject,...Z(e)});B.strictCreate=(n,e)=>new B({shape:()=>n,unknownKeys:"strict",catchall:Ee.create(),typeName:O.ZodObject,...Z(e)});B.lazycreate=(n,e)=>new B({shape:n,unknownKeys:"strip",catchall:Ee.create(),typeName:O.ZodObject,...Z(e)});class Yt extends N{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new se(o.ctx.common.issues));return y(t,{code:f.invalid_union,unionErrors:i}),E}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new se(d));return y(t,{code:f.invalid_union,unionErrors:o}),E}}get options(){return this._def.options}}Yt.create=(n,e)=>new Yt({options:n,typeName:O.ZodUnion,...Z(e)});const Se=n=>n instanceof Xt?Se(n.schema):n instanceof me?Se(n.innerType()):n instanceof en?[n.value]:n instanceof Le?n.options:n instanceof tn?$.objectValues(n.enum):n instanceof nn?Se(n._def.innerType):n instanceof Gt?[void 0]:n instanceof zt?[null]:n instanceof ye?[void 0,...Se(n.unwrap())]:n instanceof Ue?[null,...Se(n.unwrap())]:n instanceof sr||n instanceof sn?Se(n.unwrap()):n instanceof rn?Se(n._def.innerType):[];class Ln extends N{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.object)return y(t,{code:f.invalid_type,expected:b.object,received:t.parsedType}),E;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(y(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const i=Se(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Ln({typeName:O.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...Z(r)})}}function tr(n,e){const t=Ce(n),r=Ce(e);if(n===e)return{valid:!0,data:n};if(t===b.object&&r===b.object){const s=$.objectKeys(e),a=$.objectKeys(n).filter(o=>s.indexOf(o)!==-1),i={...n,...e};for(const o of a){const d=tr(n[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===b.array&&r===b.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const i=n[a],o=e[a],d=tr(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===b.date&&r===b.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Jt extends N{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,i)=>{if(Xn(a)||Xn(i))return E;const o=tr(a.value,i.value);return o.valid?((er(a)||er(i))&&t.dirty(),{status:t.value,value:o.data}):(y(r,{code:f.invalid_intersection_types}),E)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Jt.create=(n,e,t)=>new Jt({left:n,right:e,typeName:O.ZodIntersection,...Z(t)});class we extends N{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.array)return y(r,{code:f.invalid_type,expected:b.array,received:r.parsedType}),E;if(r.data.length<this._def.items.length)return y(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&r.data.length>this._def.items.length&&(y(r,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new ke(r,a,r.path,i)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>Y.mergeArray(t,a)):Y.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new we({...this._def,rest:e})}}we.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new we({items:n,typeName:O.ZodTuple,rest:null,...Z(e)})};class Qt extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.object)return y(r,{code:f.invalid_type,expected:b.object,received:r.parsedType}),E;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)s.push({key:a._parse(new ke(r,o,r.path,o)),value:i._parse(new ke(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?Y.mergeObjectAsync(t,s):Y.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof N?new Qt({keyType:e,valueType:t,typeName:O.ZodRecord,...Z(r)}):new Qt({keyType:le.create(),valueType:e,typeName:O.ZodRecord,...Z(t)})}}class An extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.map)return y(r,{code:f.invalid_type,expected:b.map,received:r.parsedType}),E;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],u)=>({key:s._parse(new ke(r,o,r.path,[u,"key"])),value:a._parse(new ke(r,d,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return E;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return E;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}An.create=(n,e,t)=>new An({valueType:e,keyType:n,typeName:O.ZodMap,...Z(t)});class Je extends N{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.set)return y(r,{code:f.invalid_type,expected:b.set,received:r.parsedType}),E;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(y(r,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(y(r,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const l of d){if(l.status==="aborted")return E;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((d,u)=>a._parse(new ke(r,d,r.path,u)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new Je({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Je({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Je.create=(n,e)=>new Je({valueType:n,minSize:null,maxSize:null,typeName:O.ZodSet,...Z(e)});class it extends N{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.function)return y(t,{code:f.invalid_type,expected:b.function,received:t.parsedType}),E;function r(o,d){return Zn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sn(),ht].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:d}})}function s(o,d){return Zn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sn(),ht].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof mt){const o=this;return Q(async function(...d){const u=new se([]),l=await o._def.args.parseAsync(d,a).catch(R=>{throw u.addIssue(r(d,R)),u}),p=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(p,a).catch(R=>{throw u.addIssue(s(p,R)),u})})}else{const o=this;return Q(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new se([r(d,u.error)]);const l=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(l,a);if(!p.success)throw new se([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new it({...this._def,args:we.create(e).rest(Ke.create())})}returns(e){return new it({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new it({args:e||we.create([]).rest(Ke.create()),returns:t||Ke.create(),typeName:O.ZodFunction,...Z(r)})}}class Xt extends N{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Xt.create=(n,e)=>new Xt({getter:n,typeName:O.ZodLazy,...Z(e)});class en extends N{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return y(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:e.data}}get value(){return this._def.value}}en.create=(n,e)=>new en({value:n,typeName:O.ZodLiteral,...Z(e)});function Jr(n,e){return new Le({values:n,typeName:O.ZodEnum,...Z(e)})}class Le extends N{constructor(){super(...arguments),Ot.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return y(t,{expected:$.joinValues(r),received:t.parsedType,code:f.invalid_type}),E}if(In(this,Ot)||Kr(this,Ot,new Set(this._def.values)),!In(this,Ot).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return y(t,{received:t.data,code:f.invalid_enum_value,options:r}),E}return Q(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Le.create(e,{...this._def,...t})}exclude(e,t=this._def){return Le.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Ot=new WeakMap;Le.create=Jr;class tn extends N{constructor(){super(...arguments),Tt.set(this,void 0)}_parse(e){const t=$.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==b.string&&r.parsedType!==b.number){const s=$.objectValues(t);return y(r,{expected:$.joinValues(s),received:r.parsedType,code:f.invalid_type}),E}if(In(this,Tt)||Kr(this,Tt,new Set($.getValidEnumValues(this._def.values))),!In(this,Tt).has(e.data)){const s=$.objectValues(t);return y(r,{received:r.data,code:f.invalid_enum_value,options:s}),E}return Q(e.data)}get enum(){return this._def.values}}Tt=new WeakMap;tn.create=(n,e)=>new tn({values:n,typeName:O.ZodNativeEnum,...Z(e)});class mt extends N{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==b.promise&&t.common.async===!1)return y(t,{code:f.invalid_type,expected:b.promise,received:t.parsedType}),E;const r=t.parsedType===b.promise?t.data:Promise.resolve(t.data);return Q(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}mt.create=(n,e)=>new mt({type:n,typeName:O.ZodPromise,...Z(e)});class me extends N{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===O.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{y(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return E;const d=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return d.status==="aborted"?E:d.status==="dirty"||t.value==="dirty"?Cn(d.value):d});{if(t.value==="aborted")return E;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?E:o.status==="dirty"||t.value==="dirty"?Cn(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?E:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?E:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ht(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Ht(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);$.assertNever(s)}}me.create=(n,e,t)=>new me({schema:n,typeName:O.ZodEffects,effect:e,...Z(t)});me.createWithPreprocess=(n,e,t)=>new me({schema:e,effect:{type:"preprocess",transform:n},typeName:O.ZodEffects,...Z(t)});class ye extends N{_parse(e){return this._getType(e)===b.undefined?Q(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ye.create=(n,e)=>new ye({innerType:n,typeName:O.ZodOptional,...Z(e)});class Ue extends N{_parse(e){return this._getType(e)===b.null?Q(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ue.create=(n,e)=>new Ue({innerType:n,typeName:O.ZodNullable,...Z(e)});class nn extends N{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===b.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}nn.create=(n,e)=>new nn({innerType:n,typeName:O.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Z(e)});class rn extends N{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ft(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new se(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new se(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}rn.create=(n,e)=>new rn({innerType:n,typeName:O.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Z(e)});class Mn extends N{_parse(e){if(this._getType(e)!==b.nan){const t=this._getOrReturnCtx(e);return y(t,{code:f.invalid_type,expected:b.nan,received:t.parsedType}),E}return{status:"valid",value:e.data}}}Mn.create=n=>new Mn({typeName:O.ZodNaN,...Z(n)});const qi=Symbol("zod_brand");class sr extends N{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class pn extends N{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?E:s.status==="dirty"?(t.dirty(),Cn(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?E:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new pn({in:e,out:t,typeName:O.ZodPipeline})}}class sn extends N{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Ht(s)&&(s.value=Object.freeze(s.value)),s);return Ft(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}sn.create=(n,e)=>new sn({innerType:n,typeName:O.ZodReadonly,...Z(e)});function Qr(n,e={},t){return n?ft.create().superRefine((r,s)=>{var a,i;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:d})}}):ft.create()}const Bi={object:B.lazycreate};var O;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(O||(O={}));const Wi=(n,e={message:`Input not instance of ${n.name}`})=>Qr(t=>t instanceof n,e),Xr=le.create,es=$e.create,Hi=Mn.create,Fi=De.create,ts=Kt.create,Ki=Ye.create,Gi=Nn.create,zi=Gt.create,Yi=zt.create,Ji=ft.create,Qi=Ke.create,Xi=Ee.create,eo=Pn.create,to=he.create,no=B.create,ro=B.strictCreate,so=Yt.create,ao=Ln.create,io=Jt.create,oo=we.create,co=Qt.create,uo=An.create,lo=Je.create,po=it.create,ho=Xt.create,fo=en.create,mo=Le.create,go=tn.create,_o=mt.create,gr=me.create,yo=ye.create,vo=Ue.create,bo=me.createWithPreprocess,ko=pn.create,wo=()=>Xr().optional(),xo=()=>es().optional(),Oo=()=>ts().optional(),To={string:n=>le.create({...n,coerce:!0}),number:n=>$e.create({...n,coerce:!0}),boolean:n=>Kt.create({...n,coerce:!0}),bigint:n=>De.create({...n,coerce:!0}),date:n=>Ye.create({...n,coerce:!0})},jo=E;var c=Object.freeze({__proto__:null,defaultErrorMap:ht,setErrorMap:Ti,getErrorMap:Sn,makeIssue:Zn,EMPTY_PATH:ji,addIssueToContext:y,ParseStatus:Y,INVALID:E,DIRTY:Cn,OK:Q,isAborted:Xn,isDirty:er,isValid:Ht,isAsync:Ft,get util(){return $},get objectUtil(){return Qn},ZodParsedType:b,getParsedType:Ce,ZodType:N,datetimeRegex:Yr,ZodString:le,ZodNumber:$e,ZodBigInt:De,ZodBoolean:Kt,ZodDate:Ye,ZodSymbol:Nn,ZodUndefined:Gt,ZodNull:zt,ZodAny:ft,ZodUnknown:Ke,ZodNever:Ee,ZodVoid:Pn,ZodArray:he,ZodObject:B,ZodUnion:Yt,ZodDiscriminatedUnion:Ln,ZodIntersection:Jt,ZodTuple:we,ZodRecord:Qt,ZodMap:An,ZodSet:Je,ZodFunction:it,ZodLazy:Xt,ZodLiteral:en,ZodEnum:Le,ZodNativeEnum:tn,ZodPromise:mt,ZodEffects:me,ZodTransformer:me,ZodOptional:ye,ZodNullable:Ue,ZodDefault:nn,ZodCatch:rn,ZodNaN:Mn,BRAND:qi,ZodBranded:sr,ZodPipeline:pn,ZodReadonly:sn,custom:Qr,Schema:N,ZodSchema:N,late:Bi,get ZodFirstPartyTypeKind(){return O},coerce:To,any:Ji,array:to,bigint:Fi,boolean:ts,date:Ki,discriminatedUnion:ao,effect:gr,enum:mo,function:po,instanceof:Wi,intersection:io,lazy:ho,literal:fo,map:uo,nan:Hi,nativeEnum:go,never:Xi,null:Yi,nullable:vo,number:es,object:no,oboolean:Oo,onumber:xo,optional:yo,ostring:wo,pipeline:ko,preprocess:bo,promise:_o,record:co,set:lo,strictObject:ro,string:Xr,symbol:Gi,transformer:gr,tuple:oo,undefined:zi,union:so,unknown:Qi,void:eo,NEVER:jo,ZodIssueCode:f,quotelessJson:Oi,ZodError:se});xi(c);const Eo=c.object({start:c.number(),limit:c.number(),length:c.number()}),ar=c.object({created_at:c.string(),updated_at:c.string()}),Ro=c.object({email:c.string().optional(),email_verified:c.boolean().optional(),name:c.string().optional(),username:c.string().optional(),given_name:c.string().optional(),phone_number:c.string().optional(),phone_verified:c.boolean().optional(),family_name:c.string().optional()}).catchall(c.any()),So=c.object({connection:c.string(),user_id:c.string(),provider:c.string(),isSocial:c.boolean(),access_token:c.string().optional(),access_token_secret:c.string().optional(),refresh_token:c.string().optional(),profileData:Ro.optional()}),ns=c.object({email:c.string().optional(),username:c.string().optional(),given_name:c.string().optional(),family_name:c.string().optional(),nickname:c.string().optional(),name:c.string().optional(),picture:c.string().optional(),locale:c.string().optional(),linked_to:c.string().optional(),profileData:c.string().optional(),user_id:c.string().optional()}),Zo=ns.extend({email_verified:c.boolean().default(!1),verify_email:c.boolean().optional(),last_ip:c.string().optional(),last_login:c.string().optional(),user_id:c.string().optional(),provider:c.string().default("email"),connection:c.string().default("email")});Zo.extend(ar.shape).extend({user_id:c.string(),email:c.string(),is_social:c.boolean(),login_count:c.number(),identities:c.array(So).optional()});ns.extend({email:c.string(),login_count:c.number(),multifactor:c.array(c.string()).optional(),last_ip:c.string().optional(),last_login:c.string().optional(),user_id:c.string()}).catchall(c.any());const Co=c.object({id:c.string(),name:c.string(),allowed_web_origins:c.string().transform(n=>n===null?"":n).default(""),allowed_callback_urls:c.string().transform(n=>n===null?"":n).default(""),allowed_logout_urls:c.string().transform(n=>n===null?"":n).default(""),email_validation:c.enum(["enabled","disabled","enforced"]).default("enforced"),client_secret:c.string().default(""),disable_sign_ups:c.boolean().default(!1)});c.object({created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)}).extend(Co.shape);var rs=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(rs||{}),ss=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n))(ss||{}),as=(n=>(n.S265="S256",n.plain="plain",n))(as||{});const Un=c.object({client_id:c.string(),vendor_id:c.string().optional(),response_type:c.nativeEnum(rs).optional(),response_mode:c.nativeEnum(ss).optional(),redirect_uri:c.string().optional(),audience:c.string().optional(),state:c.string().optional(),nonce:c.string().optional(),scope:c.string().optional(),code_challenge_method:c.nativeEnum(as).optional(),code_challenge:c.string().optional(),username:c.string().optional()});c.object({colors:c.object({primary:c.string(),page_background:c.object({type:c.string().optional(),start:c.string().optional(),end:c.string().optional(),angle_deg:c.number().optional()}).optional()}).optional(),logo_url:c.string().optional(),favicon_url:c.string().optional(),font:c.object({url:c.string()}).optional()});const Io=c.object({id:c.string().optional(),name:c.string(),client_id:c.string().optional(),client_secret:c.string().optional(),authorization_endpoint:c.string().optional(),response_type:c.custom().optional(),response_mode:c.custom().optional(),private_key:c.string().optional(),kid:c.string().optional(),team_id:c.string().optional(),token_endpoint:c.string().optional(),token_exchange_basic_auth:c.boolean().optional(),userinfo_endpoint:c.string().optional(),scope:c.string().optional()}),is=c.object({id:c.string(),created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)}).extend(Io.shape),No=c.object({domain:c.string(),dkim_private_key:c.string().optional(),dkim_public_key:c.string().optional(),email_api_key:c.string().optional(),email_service:c.union([c.literal("mailgun"),c.literal("mailchannels")]).optional()}),os=c.object({id:c.string(),name:c.string(),domains:c.array(No),allowed_callback_urls:c.array(c.string()),allowed_logout_urls:c.array(c.string()),allowed_web_origins:c.array(c.string()),email_validation:c.union([c.literal("enabled"),c.literal("disabled"),c.literal("enforced")]),tenant_id:c.string(),client_secret:c.string(),disable_sign_ups:c.boolean(),tenant:c.object({name:c.string(),audience:c.string().optional(),logo:c.string().optional(),primary_color:c.string().optional(),secondary_color:c.string().optional(),sender_email:c.string(),sender_name:c.string(),support_url:c.string().optional(),language:c.string().length(2).optional()})});os.extend({connections:c.array(is)});os.extend({connections:c.array(is.partial())});const Po=c.enum(["password_reset","email_verification","otp","oauth2","oauth2_state","ticket"]),Ao=c.object({code_id:c.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:c.string().openapi({description:"The id of the login session that the code is connected to"}),code_type:Po,expires_at:c.string(),used_at:c.string().optional()});c.object({...Ao.shape,created_at:c.string()});const Mo=c.object({domain:c.string(),dkim_private_key:c.string().optional(),dkim_public_key:c.string().optional(),email_api_key:c.string().optional(),email_service:c.enum(["mailgun","mailchannels"])});ar.extend({...Mo.shape,id:c.string()});const $o=c.object({trigger_id:c.enum(["post-user-registration","post-user-login"]),enabled:c.boolean().default(!1),url:c.string(),hook_id:c.string().optional()});$o.extend({...ar.shape,hook_id:c.string()});const Do=c.object({alg:c.string(),e:c.string(),kid:c.string(),kty:c.string(),n:c.string(),use:c.string().optional()}),Lo=c.object({keys:c.array(Do)}),_r=c.object({issuer:c.string(),authorization_endpoint:c.string(),token_endpoint:c.string(),device_authorization_endpoint:c.string(),userinfo_endpoint:c.string(),mfa_challenge_endpoint:c.string(),jwks_uri:c.string(),registration_endpoint:c.string(),revocation_endpoint:c.string(),scopes_supported:c.array(c.string()),response_types_supported:c.array(c.string()),code_challenge_methods_supported:c.array(c.string()),response_modes_supported:c.array(c.string()),subject_types_supported:c.array(c.string()),id_token_signing_alg_values_supported:c.array(c.string()),token_endpoint_auth_methods_supported:c.array(c.string()),claims_supported:c.array(c.string()),request_uri_parameter_supported:c.boolean(),request_parameter_supported:c.boolean(),token_endpoint_auth_signing_alg_values_supported:c.array(c.string())}),Uo=c.object({auth0Client:c.string().optional(),authParams:Un,expires_at:c.string(),deleted_at:c.string().optional(),ip:c.string().optional()}).openapi({description:"This represents a login sesion"});c.object({...Uo.shape,login_id:c.string().openapi({description:"This is is used as the state in the universal login"}),created_at:c.string(),updated_at:c.string()});var cs=(n=>(n.SUCCESS_API_OPERATION="sapi",n.SUCCESS_SILENT_AUTH="ssa",n.FAILED_SILENT_AUTH="fsa",n.SUCCESS_SIGNUP="ss",n.FAILED_SIGNUP="fs",n.SUCCESS_LOGIN="s",n.FAILED_LOGIN="f",n.FAILED_LOGIN_INCORRECT_PASSWORD="fp",n.SUCCESS_LOGOUT="slo",n.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",n.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",n.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",n.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",n.CODE_LINK_SENT="cls",n.NOT_IMPLEMENTED_1="seccft",n))(cs||{});const Vo=c.enum(["sapi","ssa","fsa","ss","ssa","fs","s","f","fp","slo","scoa","fcoa","seccft","cls","seacft","serft"]),qo=c.object({name:c.string(),version:c.string(),env:c.object({node:c.string().optional()}).optional()});c.object({type:Vo,date:c.string(),description:c.string().optional(),log_id:c.string().optional(),_id:c.string().optional(),ip:c.string(),user_agent:c.string(),details:c.any().optional(),isMobile:c.boolean(),user_id:c.string().optional(),user_name:c.string().optional(),connection:c.string().optional(),connection_id:c.string().optional(),client_id:c.string().optional(),client_name:c.string().optional(),audience:c.string().optional(),scope:c.array(c.string()).optional(),strategy:c.string().optional(),strategy_type:c.string().optional(),hostname:c.string().optional(),auth0_client:qo.optional()});const Bo=c.object({user_id:c.string(),password:c.string(),algorithm:c.enum(["bcrypt","argon2id"]).default("argon2id")});c.object({...Bo.shape,created_at:c.string(),updated_at:c.string()});const Wo=c.object({session_id:c.string(),client_id:c.string(),expires_at:c.string(),used_at:c.string(),deleted_at:c.string().optional(),user_id:c.string()});c.object({created_at:c.string(),...Wo.shape});c.object({private_key:c.string(),public_key:c.string(),kid:c.string(),created_at:c.string(),revoked_at:c.string().optional()});c.object({kid:c.string().openapi({description:"The key id of the signing key"}),cert:c.string().openapi({description:"The public certificate of the signing key"}),fingerprint:c.string().openapi({description:"The cert fingerprint"}),thumbprint:c.string().openapi({description:"The cert thumbprint"}),pkcs7:c.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:c.boolean().optional().openapi({description:"True if the key is the current key"}),next:c.boolean().optional().openapi({description:"True if the key is the next key"}),previous:c.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:c.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:c.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:c.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:c.string().optional().openapi({description:"The date and time when the key was revoked"})});const nr=c.object({name:c.string(),audience:c.string(),sender_email:c.string().email(),sender_name:c.string(),support_url:c.string().url().optional(),logo:c.string().url().optional(),primary_color:c.string().optional(),secondary_color:c.string().optional(),language:c.string().optional()}),_n=nr.extend({created_at:c.string().transform(n=>n===null?"":n),updated_at:c.string().transform(n=>n===null?"":n)});c.object({logoUrl:c.string(),loginBackgroundImage:c.string().nullish(),style:c.object({primaryColor:c.string(),buttonTextColor:c.string(),primaryHoverColor:c.string()}),supportEmail:c.string().nullable(),supportUrl:c.string().nullable(),name:c.string(),showGreyishBackground:c.boolean().optional(),termsAndConditionsUrl:c.string().nullable(),companyName:c.string().optional(),checkoutHideSocial:c.boolean().optional(),siteUrl:c.string().nullable(),manageSubscriptionsUrl:c.string().optional()});var ds=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(ds||{});const ir=c.nativeEnum(ds);c.object({grant_type:ir.refine(n=>n==="authorization_code"),code:c.string(),client_secret:c.string(),client_id:c.string()});c.object({grant_type:ir.refine(n=>n==="authorization_code"),code:c.string(),code_verifier:c.string(),client_id:c.string().optional(),redirect_uri:c.string()});c.object({grant_type:ir.refine(n=>n==="client_credentials"),scope:c.string().optional(),client_secret:c.string(),client_id:c.string(),audience:c.string().optional()});c.object({access_token:c.string(),id_token:c.string().optional(),scope:c.string().optional(),state:c.string().optional(),refresh_token:c.string().optional(),token_type:c.string(),expires_in:c.number()});c.object({code:c.string(),state:c.string().optional()});const Ho=c.object({button_border_radius:c.number(),button_border_weight:c.number(),buttons_style:c.enum(["pill"]),input_border_radius:c.number(),input_border_weight:c.number(),inputs_style:c.enum(["pill"]),show_widget_shadow:c.boolean(),widget_border_weight:c.number(),widget_corner_radius:c.number()}),Fo=c.object({base_focus_color:c.string(),base_hover_color:c.string(),body_text:c.string(),captcha_widget_theme:c.enum(["auto"]),error:c.string(),header:c.string(),icons:c.string(),input_background:c.string(),input_border:c.string(),input_filled_text:c.string(),input_labels_placeholders:c.string(),links_focused_components:c.string(),primary_button:c.string(),primary_button_label:c.string(),secondary_button_border:c.string(),secondary_button_label:c.string(),success:c.string(),widget_background:c.string(),widget_border:c.string()}),et=c.object({bold:c.boolean(),size:c.number()}),Ko=c.object({body_text:et,buttons_text:et,font_url:c.string(),input_labels:et,links:et,links_style:c.enum(["normal"]),reference_text_size:c.number(),subtitle:et,title:et}),Go=c.object({background_color:c.string(),background_image_url:c.string(),page_layout:c.enum(["center"])}),zo=c.object({header_text_alignment:c.enum(["center"]),logo_height:c.number(),logo_position:c.enum(["center"]),logo_url:c.string(),social_buttons_layout:c.enum(["bottom"])}),Yo=c.object({borders:Ho,colors:Fo,displayName:c.string(),fonts:Ko,page_background:Go,widget:zo});Yo.extend({themeId:c.string()});const Jo=c.object({id:c.string(),expires_at:c.string(),auth0Client:c.string().optional(),authParams:Un});c.object({...Jo.shape,created_at:c.string(),updated_at:c.string()});const Qo=c.object({id:c.string(),email:c.string(),code:c.string(),ip:c.string().optional(),send:c.enum(["code","link"]),authParams:Un,expires_at:c.string(),used_at:c.string().optional(),user_id:c.string().optional()});c.object({created_at:c.string(),...Qo.shape});const Xo=c.object({authParams:Un,code:c.string(),user_id:c.string(),created_at:c.string(),expires_at:c.string(),used_at:c.string().optional()});c.object({...Xo.shape,created_at:c.string()});const ec=new Wt().openapi(We({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Lo}},description:"List of tenants"}}}),async n=>{const{env:e}=n,t=[{alg:"RS256",e:"AQAB",kid:"hZ42TWGWLdmyKfwGVA6c2",kty:"RSA",n:"nUd-mktFZQNfVwmXufxcVcvJo6Lkb-jDuymtfQunmEhWCctOccWx9e7LX7_9uN15ZnRS7XJInPMRs9KLYdZ0GCnE2HM_QbrEoHpdkCRgyTE-KzmoaEv_AOVGE_Kg0-0ct3r9Z7aJLDVAsxXl1C9y8Gr7ZYkq0c4DyZr9VT8nQiwZQERbfxXdXw-5RLj21S_Lm-LL-AjKvry_TDBLpfUFJV18SVsM07lY_V45TwykNewRdaGLspFIeGdG5j5eByV8ifzBqvzOSptSCsmOTtW-ceWUk0FPD7g_KKzjjbzenoB0TC8mBb_4vWZlHnuGIAs2YoTFglp9uNu7t_OVl3Svo6ZE6alzUnaNfZNeAi78KPHYQ4tDWPjpYNfGynsiD0nojkDSPCIak56jWNYjj614cPEBiv9MVQRiSbBxpiGhMoHlW_QCCPMcXygLAaRs_tUksqoH4QB80krifG2yHPgGDPjXK1_0cYzV80iOcQIeoceqhkSSc6YxzzgDrQcsV2k3bizRQSL83GWkpdHhTZn-Q_JzsW_bDY_f9fjigYbRnoDSgS7038VFIPc92StE41MdgvIQMomcyEE4lYK1uv1Mo6cnXbCZhm8tvddo7VKNorOB4nsiv8DGrWPlzQBca9VN4C1oE2mH-3WLFR7XEkBHWVouOdTWM2S3K9F10YtahkM"}];return n.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})}).openapi(We({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:_r}},description:"List of tenants"}}}),async n=>{const{env:e}=n,{ISSUER:t}=e,r=_r.parse({issuer:t,authorization_endpoint:`${t}authorize`,token_endpoint:`${t}oauth/token`,device_authorization_endpoint:`${t}oauth/device/code`,userinfo_endpoint:`${t}userinfo`,mfa_challenge_endpoint:`${t}mfa/challenge`,jwks_uri:`${t}.well-known/jwks.json`,registration_endpoint:`${t}oidc/register`,revocation_endpoint:`${t}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return n.json(r,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS*2}, stale-if-error=86400`}})});async function tc({userAdapter:n,tenant_id:e,email:t}){var o;const{users:r}=await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),s=r.filter(d=>!(d.provider==="auth2"&&!d.email_verified));if(s.length===0)return;const a=s.filter(d=>!d.linked_to);if(a.length>0)return a.length>1&&console.error("More than one primary user found for same email"),a[0];const i=await n.get(e,(o=s[0])==null?void 0:o.linked_to);if(!i)throw new Error("Primary account not found");return i}function nc(n){return async(e,t)=>{if(!t.email||!t.email_verified)return n.users.create(e,t);const r=await tc({userAdapter:n.users,tenant_id:e,email:t.email});return r?(await n.users.create(e,{...t,linked_to:r.user_id}),r):n.users.create(e,t)}}function rc(n,e){return{type:e.type,description:e.description||"",ip:n.req.header("x-real-ip")||"",user_agent:n.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:n.req.method,path:n.req.path,qs:n.req.queries(),body:e.body||n.var.body||""}},isMobile:!1,client_id:n.var.client_id,client_name:"",user_id:e.userId||n.var.user_id||"",hostname:n.req.header("host")||"",user_name:n.var.username||"",connection_id:"",connection:n.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}async function sc(n,e,t){for await(const r of e)if(!(await fetch(r.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const a=rc(n,{type:cs.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(n.var.tenant_id,a)}}function ac(n,e){return async(t,r)=>{const{hooks:s}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await sc(n,s,{tenant_id:t,user:r,trigger_id:"post-user-registration"}),r}}function ic(n,e){return async(t,r)=>{let s=await nc(e)(t,r);return await ac(n,e)(t,s),s}}function oc(n,e){return{...e,users:{...e.users,create:ic(n,e)}}}const cc=G.object({page:G.string().min(0).optional().default("0").transform(n=>parseInt(n,10)).openapi({description:"The page number where 0 is the first page"}),per_page:G.string().min(1).optional().default("10").transform(n=>parseInt(n,10)).openapi({description:"The number of items per page"}),include_totals:G.string().optional().default("false").transform(n=>n==="true").openapi({description:"If the total number of items should be included in the response"}),sort:G.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:G.string().optional().openapi({description:"A lucene query string used to filter the results"})});function dc(n){if(!n)return;const[e="",t]=n.split(":");return{sort_by:e,sort_order:t==="1"?"asc":"desc"}}const uc=Eo.extend({tenants:G.array(_n)}),lc=new Wt().openapi(We({tags:["tenants"],method:"get",path:"/",request:{query:cc},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:G.union([G.array(_n),uc])}},description:"List of tenants"}}}),async n=>{const{page:e,per_page:t,include_totals:r,sort:s,q:a}=n.req.valid("query"),i=await n.env.data.tenants.list({page:e,per_page:t,include_totals:r,sort:dc(s),q:a});return r?n.json(i):n.json(i.tenants)}).openapi(We({tags:["tenants"],method:"get",path:"/{id}",request:{params:G.object({id:G.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:_n}},description:"A tenant"}}}),async n=>{const{id:e}=n.req.valid("param"),t=await n.env.data.tenants.get(e);if(!t)throw new fn(404);return console.log("tenant",t),n.json(t)}).openapi(We({tags:["tenants"],method:"delete",path:"/{id}",request:{params:G.object({id:G.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{id:e}=n.req.valid("param");return await n.env.data.tenants.remove(e),n.text("OK")}).openapi(We({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:G.object(nr.shape).partial()}}},params:G.object({id:G.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{id:e}=n.req.valid("param"),t=n.req.valid("json");return await n.env.data.tenants.update(e,t),n.text("OK")}).openapi(We({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:G.object(nr.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:_n}},description:"An tenant"}}}),async n=>{const e=n.req.valid("json"),t=await n.env.data.tenants.create(e);return n.json(t,{status:201})});let yr=!1;function pc(n){n.use(async(e,t)=>(yr||(n.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),yr=!0),await t()))}function hc(n){const e=new Wt;e.use(async(r,s)=>(r.env.data=oc(r,n.dataAdapter),s()));const t=e.route("/api/v2/tenants",lc);return pc(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function fc(n){const e=new Wt;e.get("/",s=>s.text("Hello, authhero!"));const t=hc(n);e.route("/api/v2",t);const r=new Wt().route("/.well-known",ec);return r.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",r),e}exports.init=fc;
|