authhero 0.19.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/authhero.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";var nv=Object.defineProperty;var mh=r=>{throw TypeError(r)};var iv=(r,e,t)=>e in r?nv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ne=(r,e,t)=>iv(r,typeof e!="symbol"?e+"":e,t),Yu=(r,e,t)=>e.has(r)||mh("Cannot "+t);var w=(r,e,t)=>(Yu(r,e,"read from private field"),t?t.call(r):e.get(r)),Oe=(r,e,t)=>e.has(r)?mh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Yu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Te=(r,e,t)=>(Yu(r,e,"access private method"),t);var yh=(r,e,t,n)=>({set _(i){ue(r,e,i,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function As(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function Se(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function sv(r){return"_def"in r}function xs(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function av(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=As(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(Se(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xs(r,"optional"),xs(r,"nullable"),xs(r,"default"),xs(r,"transform"),xs(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}function Do(r,e){if(r==null||e===null||e===void 0)return r===e;if(r===e||r.valueOf()===e.valueOf())return!0;if(Array.isArray(r)&&(!Array.isArray(e)||r.length!==e.length)||!(r instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(r);return Object.keys(e).every(n=>t.indexOf(n)!==-1)&&t.every(n=>Do(r[n],e[n]))}class ov{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(s=>Do(s,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(i=>Do(i,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const s of this.buckets.values())e+=1,t+=s.length,s.length>1&&(n+=1);const i=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:i}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if(typeof e=="string"){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[n,i]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(i??"");return t}}function Rs(r){return r==null}function Ps(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{t[n]=e(i)}),t}function cv(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e.some(s=>s===n)||(t[n]=i)}),t}function ji(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e(i,n)||(t[n]=i)}),t}function gh(r){return r.filter(e=>!Rs(e))}const ml=Do;function uv(r){const e=new ov;return r.forEach(t=>e.put(t)),[...e.values()]}function _m(r){return typeof r=="string"}class lv{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(i=>i.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,i,s;const a=this.schemaWithRefId(e,t),o=(n=a._def.openapi)===null||n===void 0?void 0:n.metadata,c=a.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(s=(i=o==null?void 0:o.param)===null||i===void 0?void 0:i.name)!==null&&s!==void 0?s:e})}));return this._definitions.push({type:"parameter",schema:c}),c}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:"component",componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class eu{constructor(e){this.message=e}}class _s extends eu{constructor(e,t){super(e),this.data=t}}class Zo extends eu{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 ws(r,e){try{return r()}catch(t){throw t instanceof Zo?new Zo(Object.assign(Object.assign({},t.data),e)):t}}class dv extends eu{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class We{static getMetadata(e){var t;const n=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:n._def.openapi,s=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign({description:s},i==null?void 0:i.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return n==null?void 0:n._internal}static getParamMetadata(e){var t,n;const i=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:i._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:i.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign(Object.assign({},s==null?void 0:s.metadata),{param:Object.assign({description:a},(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return ji(cv(e,["param"]),Rs)}static buildParameterMetadata(e){return ji(e,Rs)}static applySchemaMetadata(e,t){return ji(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Rs)}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&&Se(e,t)?e:Se(e,"ZodOptional")||Se(e,"ZodNullable")||Se(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):Se(e,"ZodDefault")||Se(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):Se(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):Se(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return Se(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class fv{transform(e,t,n){var i,s;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(i=e._def.minLength)===null||i===void 0?void 0:i.value,maxItems:(s=e._def.maxLength)===null||s===void 0?void 0:s.value})}}class hv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class pv{transform(e,t,n,i,s){const a=[...e.options.values()],o=a.map(i);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,s)}}mapDiscriminator(e,t,n){if(e.some(s=>We.getRefId(s)===void 0))return;const i={};return e.forEach(s=>{var a;const o=We.getRefId(s),c=(a=s.shape)===null||a===void 0?void 0:a[t];if(Se(c,"ZodEnum")||Se(c,"ZodNativeEnum")){Object.values(c.enum).filter(_m).forEach(m=>{i[m]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);i[u]=n(o)}),{propertyName:t,mapping:i}}}class mv{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class yv{transform(e,t,n,i){const a={allOf:this.flattenIntersectionTypes(e).map(i)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!Se(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class gv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function vv(r){const t=Object.keys(r).filter(s=>typeof r[r[s]]!="number").map(s=>r[s]),n=t.filter(s=>typeof s=="number").length,i=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:i}}class bv{transform(e,t){const{type:n,values:i}=vv(e._def.values);if(n==="mixed")throw new eu("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:i})}}class xv{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class _v{transform(e,t,n,i){var s;const a=(s=We.getInternalMetadata(e))===null||s===void 0?void 0:s.extendedFrom,o=this.requiredKeysOf(e),c=Ps(e._def.shape(),i);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,i));const u=a.schema;i(u);const f=this.requiredKeysOf(u),m=Ps(u==null?void 0:u._def.shape(),i),B=Object.fromEntries(Object.entries(c).filter(([g,A])=>!ml(m[g],A))),C=o.filter(g=>!f.includes(g)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:B}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,i));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,i=e._def.catchall;return Se(i,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(i)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!We.isOptionalSchema(n)).map(([t,n])=>t)}}class wv{transform(e,t,n){const i=e._def.valueType,s=e._def.keyType,a=n(i);if(Se(s,"ZodEnum")||Se(s,"ZodNativeEnum")){const c=Object.values(s.enum).filter(_m).reduce((u,f)=>Object.assign(Object.assign({},u),{[f]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class kv{transform(e,t){var n,i,s;const a=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(i=e.minLength)!==null&&i!==void 0?i:void 0,u=Number.isFinite(e.maxLength)&&(s=e.maxLength)!==null&&s!==void 0?s:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:a==null?void 0:a.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(n=>n.kind===t)}}class Sv{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:i}=e._def,s=i.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(s))}}class Av{transform(e,t,n){const s=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(s)}}flattenUnionTypes(e){return Se(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return Se(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Ov{constructor(e){this.versionSpecifics=e,this.objectTransformer=new _v,this.stringTransformer=new kv,this.numberTransformer=new xv,this.bigIntTransformer=new hv,this.literalTransformer=new gv,this.enumTransformer=new mv,this.nativeEnumTransformer=new bv,this.arrayTransformer=new fv,this.unionTransformer=new Av,this.discriminatedUnionTransformer=new pv,this.intersectionTransformer=new yv,this.recordTransformer=new wv,this.tupleTransformer=new Sv(e)}transform(e,t,n,i,s){if(Se(e,"ZodNull"))return this.versionSpecifics.nullType;if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodObject"))return this.objectTransformer.transform(e,s,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,i);return Object.assign(Object.assign({},a),{default:s})}transformSchemaWithoutDefault(e,t,n,i){if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(Se(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(Se(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,i);if(Se(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const s=We.getRefId(e);throw new dv({currentSchema:e._def,schemaName:s})}}class wm{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Ov(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 n={};return this.rawComponents.forEach(({componentType:i,name:s,component:a})=>{var o;(o=n[i])!==null&&o!==void 0||(n[i]={}),n[i][s]=a}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},(e=n.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=n.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const i=e.findIndex(a=>a===t.type),s=e.findIndex(a=>a===n.type);return i-s})}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=We.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,i,s,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId?this.paramRefs[(s=e._internal)===null||s===void 0?void 0:s.refId]:void 0;if(!(!(!((a=e==null?void 0:e._internal)===null||a===void 0)&&a.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new _s(`Conflicting location for parameter ${u.name}`,{key:"in",values:gh([u.in,t==null?void 0:t.in,c==null?void 0:c.in])});if(c&&u.name!==c.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new _s("Conflicting names for parameter",{key:"name",values:gh([u.name,t==null?void 0:t.name,c==null?void 0:c.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var n;const i=We.getMetadata(e),s=(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(i,{in:t});if(a)return[a];if(Se(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,B;const C=We.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const g=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(g!=null&&g.name&&g.name!==u)throw new _s("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new _s(`Conflicting location for parameter ${(B=g.name)!==null&&B!==void 0?B:u}`,{key:"in",values:[t,g.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(s!=null&&s.in&&s.in!==t)throw new _s(`Conflicting location for parameter ${s.name}`,{key:"in",values:[t,s.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=We.getParamMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=!We.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:s},i?We.buildParameterMetadata(i):{})}generateParameter(e){var t;const n=We.getMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=i==null?void 0:i.name,a=i==null?void 0:i.in;if(!s)throw new Zo({missingField:"name"});if(!a)throw new Zo({missingField:"in",paramName:s});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:s})}generateSchemaWithMetadata(e){var t;const n=We.unwrapChained(e),i=We.getMetadata(e),s=We.getDefaultValue(e),a=!((t=i==null?void 0:i.metadata)===null||t===void 0)&&t.type?{type:i==null?void 0:i.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),s);return i!=null&&i.metadata?We.applySchemaMetadata(a,i.metadata):ji(a,Rs)}constructReferencedOpenAPISchema(e){var t;const n=We.getMetadata(e),i=We.unwrapChained(e),s=We.getDefaultValue(e),a=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,a):this.toOpenAPISchema(i,a,s)}generateSimpleSchema(e){var t;const n=We.getMetadata(e),i=We.getRefId(e);if(!i||!this.schemaRefs[i])return this.generateSchemaWithMetadata(e);const s=this.schemaRefs[i],a={$ref:this.generateSchemaRef(i)},o=ji(We.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||ml(f,s[m]));if(o.type)return{allOf:[a,o]};const c=ji(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||ml(f,s[m])),u=We.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=We.getRefId(e),n=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=As(e,["content"]),i=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:i})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),i=this.cleanParameter(e.params),s=this.cleanParameter(e.cookies),a=ws(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=ws(()=>i?this.generateInlineParameters(i,"path"):[],{location:"path"}),c=ws(()=>s?this.generateInlineParameters(s,"cookie"):[],{location:"cookie"}),u=ws(()=>{if(Array.isArray(t))return t.flatMap(m=>this.generateInlineParameters(m,"header"));const f=this.cleanParameter(t);return f?this.generateInlineParameters(f,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return Se(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:i,responses:s}=e,a=As(e,["method","path","request","responses"]),o=Ps(s,m=>this.getResponse(m)),c=ws(()=>this.getParameters(i),{route:`${t} ${n}`}),u=this.getRequestBody(i==null?void 0:i.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},a),c.length>0?{parameters:[...a.parameters||[],...c]}:{}),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:n}=e,i=As(e,["content","headers"]);const s=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},i),s);const a=Se(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},i),{headers:a}),s)}getResponseHeaders(e){const t=e._def.shape();return Ps(t,i=>this.generateSimpleParameter(i))}getBodyContent(e){return Ps(e,t=>{if(!t||!sv(t.schema))return t;const{schema:n}=t,i=As(t,["schema"]),s=this.generateSchemaWithRef(n);return Object.assign({schema:s},i)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,i=>this.generateSchemaWithRef(i),i=>this.generateSchemaRef(i),n)}}class Ev{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=uv(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 Iv{constructor(e){const t=new Ev;this.generator=new wm(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class Cv{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 jv(r){return"type"in r&&r.type==="webhook"}class Tv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new Cv;this.generator=new wm(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(jv).forEach(n=>this.generateSingleWebhook(n.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 km=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Nv=r=>{const{groups:e,path:t}=Bv(r),n=km(t);return Rv(n,e)},Bv=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const i=`@${n}`;return e.push([i,t]),i}),{groups:e,path:r}},Rv=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let i=r.length-1;i>=0;i--)if(r[i].includes(n)){r[i]=r[i].replace(n,e[t][1]);break}}return r},bo={},vh=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(bo[r]||(e[2]?bo[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:bo[r]=[r,e[1],!0]),bo[r]):null},Sm=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},Pv=r=>Sm(r,decodeURI),Am=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const i=e.charCodeAt(n);if(i===37){const s=e.indexOf("?",n),a=e.slice(t,s===-1?void 0:s);return Pv(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(i===63)break}return e.slice(t,n)},$v=r=>{const e=Am(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},nn=(...r)=>{let e="",t=!1;for(let n of r)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),n[0]!=="/"&&(n=`/${n}`),n==="/"&&t?e=`${e}/`:n!=="/"&&(e=`${e}${n}`),n==="/"&&e===""&&(e="/");return e},Om=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(i=>{if(i!==""&&!/\:/.test(i))n+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){t.length===0&&n===""?t.push("/"):t.push(n);const s=i.replace("?","");n+="/"+s,t.push(n)}else n+="/"+i}),t.filter((i,s,a)=>a.indexOf(i)===s)},Xu=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?sf(r):r):r,Em=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let a=r.indexOf(`?${e}`,8);for(a===-1&&(a=r.indexOf(`&${e}`,8));a!==-1;){const o=r.charCodeAt(a+e.length+1);if(o===61){const c=a+e.length+2,u=r.indexOf("&",c);return Xu(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";a=r.indexOf(`&${e}`,a+1)}if(n=/[%+]/.test(r),!n)return}const i={};n??(n=/[%+]/.test(r));let s=r.indexOf("?",8);for(;s!==-1;){const a=r.indexOf("&",s+1);let o=r.indexOf("=",s);o>a&&a!==-1&&(o=-1);let c=r.slice(s+1,o===-1?a===-1?void 0:a:o);if(n&&(c=Xu(c)),s=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=Xu(u))),t?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(u)):i[c]??(i[c]=u)}return e?i[e]:i},Dv=Em,Zv=(r,e)=>Em(r,e,!0),sf=decodeURIComponent,Mv=/^[\w!#$%&'*.^`|~+-]+$/,Uv=/^[ !#-:<-[\]-~]*$/,Vv=(r,e)=>{const t=r.trim().split(";"),n={};for(let i of t){i=i.trim();const s=i.indexOf("=");if(s===-1)continue;const a=i.substring(0,s).trim();if(!Mv.test(a))continue;let o=i.substring(s+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Uv.test(o)&&(n[a]=sf(o))}return n},Lv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Vv(n):{}},ye=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});ne(this,"res");ne(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})}},qv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),Hv=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Fv=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Kv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Wv=(r,e)=>async(t,n)=>{let i={};const s=t.req.header("Content-Type");switch(r){case"json":if(!s||!Hv.test(s))break;try{i=await t.req.json()}catch{const o="Malformed JSON in request body";throw new ye(400,{message:o})}break;case"form":{if(!s||!(Fv.test(s)||Kv.test(s)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await qv(u,s),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new ye(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),i=c;break}case"query":i=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":i=t.req.param();break;case"header":i=t.req.header();break;case"cookie":i=Lv(t);break}const a=await e(i,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xi=(r,e,t)=>Wv(r,async(n,i)=>{const s=await e.safeParseAsync(n);if(t){const a=await t({data:n,...s,target:r},i);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return s.success?s.data:i.json(s,400)});var zv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,s=(r instanceof Im?r.raw.headers:r.headers).get("Content-Type");return s!=null&&s.startsWith("multipart/form-data")||s!=null&&s.startsWith("application/x-www-form-urlencoded")?Gv(r,{all:t,dot:n}):{}};async function Gv(r,e){const t=await r.formData();return t?Jv(t,e):{}}function Jv(r,e){const t=Object.create(null);return r.forEach((n,i)=>{e.all||i.endsWith("[]")?Yv(t,i,n):t[i]=n}),e.dot&&Object.entries(t).forEach(([n,i])=>{n.includes(".")&&(Xv(t,n,i),delete t[n])}),t}var Yv=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},Xv=(r,e,t)=>{let n=r;const i=e.split(".");i.forEach((s,a)=>{a===i.length-1?n[s]=t:((!n[s]||typeof n[s]!="object"||Array.isArray(n[s])||n[s]instanceof File)&&(n[s]=Object.create(null)),n=n[s])})},bh=r=>Sm(r,sf),$i,tr,Xr,Cm,jm,yl,cn,fm,Im=(fm=class{constructor(r,e="/",t=[[]]){Oe(this,Xr);ne(this,"raw");Oe(this,$i);Oe(this,tr);ne(this,"routeIndex",0);ne(this,"path");ne(this,"bodyCache",{});Oe(this,cn,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const i=Object.keys(e)[0];return i?e[i].then(s=>(i==="json"&&(s=JSON.stringify(s)),new Response(s)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,ue(this,tr,t),ue(this,$i,{})}param(r){return r?Te(this,Xr,Cm).call(this,r):Te(this,Xr,jm).call(this)}query(r){return Dv(this.url,r)}queries(r){return Zv(this.url,r)}header(r){if(r)return this.raw.headers.get(r.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,n)=>{e[n]=t}),e}async parseBody(r){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await zv(this,r))}json(){return w(this,cn).call(this,"json")}text(){return w(this,cn).call(this,"text")}arrayBuffer(){return w(this,cn).call(this,"arrayBuffer")}blob(){return w(this,cn).call(this,"blob")}formData(){return w(this,cn).call(this,"formData")}addValidatedData(r,e){w(this,$i)[r]=e}valid(r){return w(this,$i)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return w(this,tr)[0].map(([[,r]])=>r)}get routePath(){return w(this,tr)[0].map(([[,r]])=>r)[this.routeIndex].path}},$i=new WeakMap,tr=new WeakMap,Xr=new WeakSet,Cm=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=Te(this,Xr,yl).call(this,e);return t?/\%/.test(t)?bh(t):t:void 0},jm=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=Te(this,Xr,yl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?bh(n):n)}return r},yl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,fm),Qv={Stringify:1,BeforeStream:2,Stream:3},Tm=async(r,e,t,n,i)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const s=r.callbacks;return s!=null&&s.length?(i?i[0]+=r:i=[r],Promise.all(s.map(o=>o({phase:e,buffer:i,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Tm(c,e,!1,n,i))).then(()=>i[0]))):Promise.resolve(r)},eb="text/plain; charset=UTF-8",Qu=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Dr,Ka,Di,Zi,Wa,za,Ot,Vt,hm,Nm=(hm=class{constructor(r,e){Oe(this,Ot);Oe(this,Ha);Oe(this,Fa);ne(this,"env",{});Oe(this,Pr);ne(this,"finalized",!1);ne(this,"error");Oe(this,qn,200);Oe(this,$r);Oe(this,Ge);Oe(this,Qe);Oe(this,br);Oe(this,Dr,!0);Oe(this,Ka);Oe(this,Di);Oe(this,Zi);Oe(this,Wa);Oe(this,za);ne(this,"render",(...r)=>(w(this,Di)??ue(this,Di,e=>this.html(e)),w(this,Di).call(this,...r)));ne(this,"setLayout",r=>ue(this,Ka,r));ne(this,"getLayout",()=>w(this,Ka));ne(this,"setRenderer",r=>{ue(this,Di,r)});ne(this,"header",(r,e,t)=>{if(e===void 0){w(this,Ge)?w(this,Ge).delete(r):w(this,Qe)&&delete w(this,Qe)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(w(this,Ge)||(ue(this,Dr,!1),ue(this,Ge,new Headers(w(this,Qe))),ue(this,Qe,{})),w(this,Ge).append(r,e)):w(this,Ge)?w(this,Ge).set(r,e):(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});ne(this,"status",r=>{ue(this,Dr,!1),ue(this,qn,r)});ne(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});ne(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);ne(this,"newResponse",(...r)=>Te(this,Ot,Vt).call(this,...r));ne(this,"body",(r,e,t)=>typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e));ne(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Dr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=eb,typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)});ne(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)});ne(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Tm(r,Qv.Stringify,!1,{}).then(n=>typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)):typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)));ne(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));ne(this,"notFound",()=>(w(this,Zi)??ue(this,Zi,()=>new Response),w(this,Zi).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Zi,e.notFoundHandler),ue(this,za,e.path),ue(this,Wa,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Im(w(this,Ha),w(this,za),w(this,Wa))),w(this,Fa)}get event(){if(w(this,$r)&&"respondWith"in w(this,$r))return w(this,$r);throw Error("This context has no FetchEvent")}get executionCtx(){if(w(this,$r))return w(this,$r);throw Error("This context has no ExecutionContext")}get res(){return ue(this,Dr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Dr,!1),w(this,br)&&r)try{for(const[e,t]of w(this,br).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=w(this,br).headers.getSetCookie();r.headers.delete("set-cookie");for(const i of n)r.headers.append("set-cookie",i)}else r.headers.set(e,t)}catch(e){if(e instanceof TypeError&&e.message.includes("immutable")){this.res=new Response(r.body,{headers:r.headers,status:r.status});return}else throw e}ue(this,br,r),this.finalized=!0}get var(){return w(this,Pr)?Object.fromEntries(w(this,Pr)):{}}},Ha=new WeakMap,Fa=new WeakMap,Pr=new WeakMap,qn=new WeakMap,$r=new WeakMap,Ge=new WeakMap,Qe=new WeakMap,br=new WeakMap,Dr=new WeakMap,Ka=new WeakMap,Di=new WeakMap,Zi=new WeakMap,Wa=new WeakMap,za=new WeakMap,Ot=new WeakSet,Vt=function(r,e,t){if(w(this,Dr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const i=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?i.append(o,a):i.set(o,a)});const s=Qu(i,w(this,Qe));return new Response(r,{headers:s,status:e.status??w(this,qn)})}const n=typeof e=="number"?e:w(this,qn);w(this,Qe)??ue(this,Qe,{}),w(this,Ge)??ue(this,Ge,new Headers),Qu(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((i,s)=>{var a,o;s==="set-cookie"?(a=w(this,Ge))==null||a.append(s,i):(o=w(this,Ge))==null||o.set(s,i)}),Qu(w(this,Ge),w(this,Qe))),t??(t={});for(const[i,s]of Object.entries(t))if(typeof s=="string")w(this,Ge).set(i,s);else{w(this,Ge).delete(i);for(const a of s)w(this,Ge).append(i,a)}return new Response(r,{status:n,headers:w(this,Ge)})},hm),xh=(r,e,t)=>(n,i)=>{let s=-1;const a=n instanceof Nm;return o(0);async function o(c){if(c<=s)throw new Error("next() called multiple times");s=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&i||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(B){if(B instanceof Error&&a&&e)n.error=B,u=await e(B,n),f=!0;else throw B}return u&&(n.finalized===!1||f)&&(n.res=u),n}},it="ALL",tb="all",rb=["get","post","put","delete","options","patch"],Bm="Can not add a route since the matcher is already built.",Rm=class extends Error{},nb=Symbol("composedHandler"),ib=r=>r.text("404 Not Found",404),_h=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,st,$m,Zr,Pn,Ao,Oo,pm,Pm=(pm=class{constructor(e={}){Oe(this,st);ne(this,"get");ne(this,"post");ne(this,"put");ne(this,"delete");ne(this,"options");ne(this,"patch");ne(this,"all");ne(this,"on");ne(this,"use");ne(this,"router");ne(this,"getPath");ne(this,"_basePath","/");Oe(this,rr,"/");ne(this,"routes",[]);Oe(this,Zr,ib);ne(this,"errorHandler",_h);ne(this,"onError",e=>(this.errorHandler=e,this));ne(this,"notFound",e=>(ue(this,Zr,e),this));ne(this,"fetch",(e,...t)=>Te(this,st,Oo).call(this,e,t[1],t[0],e.method));ne(this,"request",(e,t,n,i)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,i):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${nn("/",e)}`,t),n,i)));ne(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Te(this,st,Oo).call(this,e.request,e,void 0,e.request.method))})});[...rb,tb].forEach(i=>{this[i]=(s,...a)=>(typeof s=="string"?ue(this,rr,s):Te(this,st,Pn).call(this,i,w(this,rr),s),a.forEach(o=>{Te(this,st,Pn).call(this,i,w(this,rr),o)}),this)}),this.on=(i,s,...a)=>{for(const o of[s].flat()){ue(this,rr,o);for(const c of[i].flat())a.map(u=>{Te(this,st,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(i,...s)=>(typeof i=="string"?ue(this,rr,i):(ue(this,rr,"*"),s.unshift(i)),s.forEach(a=>{Te(this,st,Pn).call(this,it,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Am:$v}route(e,t){const n=this.basePath(e);return t.routes.map(i=>{var a;let s;t.errorHandler===_h?s=i.handler:(s=async(o,c)=>(await xh([],t.errorHandler)(o,()=>i.handler(o,c))).res,s[nb]=i.handler),Te(a=n,st,Pn).call(a,i.method,i.path,s)}),this}basePath(e){const t=Te(this,st,$m).call(this);return t._basePath=nn(this._basePath,e),t}mount(e,t,n){let i,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,i=n.replaceRequest));const a=s?c=>{const u=s(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};i||(i=(()=>{const c=nn(this._basePath,e),u=c==="/"?0:c.length;return f=>{const m=new URL(f.url);return m.pathname=m.pathname.slice(u)||"/",new Request(m,f)}})());const o=async(c,u)=>{const f=await t(i(c.req.raw),...a(c));if(f)return f;await u()};return Te(this,st,Pn).call(this,it,nn(e,"*"),o),this}},rr=new WeakMap,st=new WeakSet,$m=function(){const e=new Pm({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Zr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const i={path:t,method:e,handler:n};this.router.add(e,t,[n,i]),this.routes.push(i)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,i){if(i==="HEAD")return(async()=>new Response(null,await Te(this,st,Oo).call(this,e,t,n,"GET")))();const s=this.getPath(e,{env:n}),a=this.router.match(i,s),o=new Nm(e,{path:s,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Zr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Zr).call(this,o)})}catch(f){return Te(this,st,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Zr).call(this,o))).catch(f=>Te(this,st,Ao).call(this,f,o)):u??w(this,Zr).call(this,o)}const c=xh(a[0],this.errorHandler,w(this,Zr));return(async()=>{try{const u=await c(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 Te(this,st,Ao).call(this,u,o)}})()},pm),Mo="[^/]+",$s=".*",Ds="(?:|/.*)",Os=Symbol(),sb=new Set(".\\+*[^]$()");function ab(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$s||r===Ds?1:e===$s||e===Ds?-1:r===Mo?1:e===Mo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,mm,gl=(mm=class{constructor(){Oe(this,Hn);Oe(this,Fn);Oe(this,nr,Object.create(null))}insert(e,t,n,i,s){if(e.length===0){if(w(this,Hn)!==void 0)throw Os;if(s)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$s]:["","",Mo]:a==="/*"?["","",Ds]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Mo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Os;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(B=>B!==$s&&B!==Ds))throw Os;if(s)return;u=w(this,nr)[m]=new gl,f!==""&&ue(u,Fn,i.varIndex++)}!s&&f!==""&&n.push([f,w(u,Fn)])}else if(u=w(this,nr)[a],!u){if(Object.keys(w(this,nr)).some(f=>f.length>1&&f!==$s&&f!==Ds))throw Os;if(s)return;u=w(this,nr)[a]=new gl}u.insert(o,t,n,i,s)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(ab).map(n=>{const i=w(this,nr)[n];return(typeof w(i,Fn)=="number"?`(${n})@${w(i,Fn)}`:sb.has(n)?`\\${n}`:n)+i.buildRegExpStr()});return typeof w(this,Hn)=="number"&&t.unshift(`#${w(this,Hn)}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},Hn=new WeakMap,Fn=new WeakMap,nr=new WeakMap,mm),Qc,Ga,ym,ob=(ym=class{constructor(){Oe(this,Qc,{varIndex:0});Oe(this,Ga,new gl)}insert(r,e,t){const n=[],i=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return i[a]=[u,c],a++,o=!0,u}),!o)break}const s=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=i.length-1;a>=0;a--){const[o]=i[a];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(o)!==-1){s[c]=s[c].replace(o,i[a][1]);break}}return w(this,Ga).insert(s,e,n,w(this,Qc),t),n}buildRegExp(){let r=w(this,Ga).buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,s,a)=>s!==void 0?(t[++e]=Number(s),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},Qc=new WeakMap,Ga=new WeakMap,ym),Dm=[],cb=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Zm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function ub(){Eo=Object.create(null)}function lb(r){var u;const e=new ob,t=[];if(r.length===0)return cb;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[B,C])=>f?1:B?-1:m.length-C.length),i=Object.create(null);for(let f=0,m=-1,B=n.length;f<B;f++){const[C,p,g]=n[f];C?i[p]=[g.map(([O])=>[O,Object.create(null)]),Dm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Os?new Rm(p):O}C||(t[m]=g.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[xe,Le]=A[P];N[xe]=Le}return[O,N]}))}const[s,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let B=0,C=t[f].length;B<C;B++){const p=(u=t[f][B])==null?void 0:u[1];if(!p)continue;const g=Object.keys(p);for(let A=0,O=g.length;A<O;A++)p[g[A]]=o[p[g[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[s,c,i]}function _i(r,e){if(r){for(const t of Object.keys(r).sort((n,i)=>i.length-n.length))if(Zm(t).test(e))return[...r[t]]}}var un,ln,os,Mm,Um,gm,db=(gm=class{constructor(){Oe(this,os);ne(this,"name","RegExpRouter");Oe(this,un);Oe(this,ln);ue(this,un,{[it]:Object.create(null)}),ue(this,ln,{[it]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),i=w(this,ln);if(!n||!i)throw new Error(Bm);n[r]||[n,i].forEach(c=>{c[r]=Object.create(null),Object.keys(c[it]).forEach(u=>{c[r][u]=[...c[it][u]]})}),e==="/*"&&(e="*");const s=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Zm(e);r===it?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_i(n[u],e)||_i(n[it],e)||[])}):(o=n[r])[e]||(o[e]=_i(n[r],e)||_i(n[it],e)||[]),Object.keys(n).forEach(u=>{(r===it||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,s])})}),Object.keys(i).forEach(u=>{(r===it||r===u)&&Object.keys(i[u]).forEach(f=>c.test(f)&&i[u][f].push([t,s]))});return}const a=Om(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(i).forEach(m=>{var B;(r===it||r===m)&&((B=i[m])[f]||(B[f]=[..._i(n[m],f)||_i(n[it],f)||[]]),i[m][f].push([t,s-u+c+1]))})}}match(r,e){ub();const t=Te(this,os,Mm).call(this);return this.match=(n,i)=>{const s=t[n]||t[it],a=s[2][i];if(a)return a;const o=i.match(s[0]);if(!o)return[[],Dm];const c=o.indexOf("",1);return[s[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,os=new WeakSet,Mm=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=Te(this,os,Um).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},Um=function(r){const e=[];let t=r===it;return[w(this,un),w(this,ln)].forEach(n=>{const i=n[r]?Object.keys(n[r]).map(s=>[s,n[r][s]]):[];i.length!==0?(t||(t=!0),e.push(...i)):r!==it&&e.push(...Object.keys(n[it]).map(s=>[s,n[it][s]]))}),t?lb(e):null},gm),dn,Mr,vm,fb=(vm=class{constructor(r){ne(this,"name","SmartRouter");Oe(this,dn,[]);Oe(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(Bm);w(this,Mr).push([r,e,t])}match(r,e){if(!w(this,Mr))throw new Error("Fatal error");const t=w(this,dn),n=w(this,Mr),i=t.length;let s=0,a;for(;s<i;s++){const o=t[s];try{for(let c=0,u=n.length;c<u;c++)o.add(...n[c]);a=o.match(r,e)}catch(c){if(c instanceof Rm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(s===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(w(this,Mr)||w(this,dn).length!==1)throw new Error("No active router has been determined yet.");return w(this,dn)[0]}},dn=new WeakMap,Mr=new WeakMap,vm),fn,bt,Kn,Mi,Et,Ur,$n,bm,Vm=(bm=class{constructor(r,e,t){Oe(this,Ur);Oe(this,fn);Oe(this,bt);Oe(this,Kn);Oe(this,Mi,0);Oe(this,Et,Object.create(null));if(ue(this,bt,t||Object.create(null)),ue(this,fn,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},ue(this,fn,[n])}ue(this,Kn,[])}insert(r,e,t){ue(this,Mi,++yh(this,Mi)._);let n=this;const i=Nv(e),s=[];for(let c=0,u=i.length;c<u;c++){const f=i[c];if(Object.keys(w(n,bt)).includes(f)){n=w(n,bt)[f];const B=vh(f);B&&s.push(B[1]);continue}w(n,bt)[f]=new Vm;const m=vh(f);m&&(w(n,Kn).push(m),s.push(m[1])),n=w(n,bt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:s.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Mi)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Et,Object.create(null));let i=[this];const s=km(e);for(let o=0,c=s.length;o<c;o++){const u=s[o],f=o===c-1,m=[];for(let B=0,C=i.length;B<C;B++){const p=i[B],g=w(p,bt)[u];g&&(ue(g,Et,w(p,Et)),f?(w(g,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(g,bt)["*"],r,w(p,Et),Object.create(null))),t.push(...Te(this,Ur,$n).call(this,g,r,w(p,Et),Object.create(null)))):m.push(g));for(let A=0,O=w(p,Kn).length;A<O;A++){const P=w(p,Kn)[A],N={...w(p,Et)};if(P==="*"){const mt=w(p,bt)["*"];mt&&(t.push(...Te(this,Ur,$n).call(this,mt,r,w(p,Et),Object.create(null))),m.push(mt));continue}if(u==="")continue;const[xe,Le,qe]=P,Ze=w(p,bt)[xe],tt=s.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...Te(this,Ur,$n).call(this,Ze,r,w(p,Et),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...Te(this,Ur,$n).call(this,Ze,r,N,w(p,Et))),w(Ze,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(Ze,bt)["*"],r,N,w(p,Et)))):(ue(Ze,Et,N),m.push(Ze)))}}i=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,bt=new WeakMap,Kn=new WeakMap,Mi=new WeakMap,Et=new WeakMap,Ur=new WeakSet,$n=function(r,e,t,n){const i=[];for(let s=0,a=w(r,fn).length;s<a;s++){const o=w(r,fn)[s],c=o[e]||o[it],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const B=c.possibleKeys[f],C=u[c.score];c.params[B]=n[B]&&!C?n[B]:t[B]??n[B],u[c.score]=!0}i.push(c)}}return i},bm),Wn,xm,hb=(xm=class{constructor(){ne(this,"name","TrieRouter");Oe(this,Wn);ue(this,Wn,new Vm)}add(r,e,t){const n=Om(e);if(n){for(let i=0,s=n.length;i<s;i++)w(this,Wn).insert(r,n[i],t);return}w(this,Wn).insert(r,e,t)}match(r,e){return w(this,Wn).search(r,e)}},Wn=new WeakMap,xm),pb=class extends Pm{constructor(r={}){super(r),this.router=r.router??new fb({routers:[new db,new hb]})}},Re;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Re||(Re={}));var vl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(vl||(vl={}));const z=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),sn=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},D=Re.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"]),mb=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class Lm extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Lm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Ui=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Re.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Re.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case D.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,Re.assertNever(r)}return{message:t}};let qm=Ui;function yb(r){qm=r}function Uo(){return qm}const Vo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},gb=[];function H(r,e){const t=Uo(),n=Vo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ui?void 0:Ui].filter(i=>!!i)});r.common.issues.push(n)}let jt=class Hm{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return Hm.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Oi=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),bl=r=>r.status==="aborted",xl=r=>r.status==="dirty",Ls=r=>r.status==="valid",qs=r=>typeof Promise<"u"&&r instanceof Promise;function Lo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Fm(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Es,Is;let Sr=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 wh=(r,e)=>{if(Ls(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new or(r.common.issues);return this._error=t,this._error}}};function _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:i}}let Ae=class{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 sn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new jt,ctx:{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qs(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return wh(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(qs(i)?i:Promise.resolve(i));return wh(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:D.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new dr({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qn.create(this,this._def)}promise(){return qi.create(this,this._def)}or(e){return Js.create([this,e],this._def)}and(e){return Ys.create(this,e,this._def)}transform(e){return new dr({..._e(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({..._e(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new af({typeName:de.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({..._e(this._def),innerType:this,catchValue:t,typeName:de.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return of.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const vb=/^c[^\s-]{8,}$/i,bb=/^[0-9a-z]+$/,xb=/^[0-9A-HJKMNP-TV-Z]{26}$/,_b=/^[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,wb=/^[a-z0-9_-]{21}$/i,kb=/^[-+]?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)?)??$/,Sb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ab="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let el;const Ob=/^(?:(?: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])$/,Eb=/^(([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})))$/,Ib=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Km="((\\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])))",Cb=new RegExp(`^${Km}$`);function Wm(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function jb(r){return new RegExp(`^${Wm(r)}$`)}function zm(r){let e=`${Km}T${Wm(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Tb(r,e){return!!((e==="v4"||!e)&&Ob.test(r)||(e==="v6"||!e)&&Eb.test(r))}let Vi=class Cs extends Ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.string,received:s.parsedType}),pe}const n=new jt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Sb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"email",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")el||(el=new RegExp(Ab,"u")),el.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"emoji",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")_b.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"uuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")wb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"nanoid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")vb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")bb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid2",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")xb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ulid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),H(i,{validation:"url",code:D.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"regex",code:D.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.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)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?zm(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?Cb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?jb(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?kb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"duration",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Tb(e.data,s.version)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ip",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Ib.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"base64",code:D.invalid_string,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:D.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Cs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ae.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ae.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,...ae.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ae.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ae.errToObj(t)})}nonempty(e){return this.min(1,ae.errToObj(e))}trim(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Cs({...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}};Vi.create=r=>{var e;return new Vi({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function Nb(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}let Hs=class _l extends Ae{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)!==z.number){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.number,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Nb(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_finite,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new _l({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new _l({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ae.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ae.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"&&Re.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Hs.create=r=>new Hs({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Fs=class wl extends Ae{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)!==z.bigint){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.bigint,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new wl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new wl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.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}};Fs.create=r=>{var e;return new Fs({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};let Ks=class extends Ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return _t(e.data)}};Ks.create=r=>new Ks({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Ws=class Gm extends Ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.date,received:s.parsedType}),pe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_date}),pe}const n=new jt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Re.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Gm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.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}};Ws.create=r=>new Ws({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,..._e(r)});let qo=class extends Ae{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return _t(e.data)}};qo.create=r=>new qo({typeName:de.ZodSymbol,..._e(r)});let zs=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return _t(e.data)}};zs.create=r=>new zs({typeName:de.ZodUndefined,..._e(r)});let Gs=class extends Ae{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.null,received:n.parsedType}),pe}return _t(e.data)}};Gs.create=r=>new Gs({typeName:de.ZodNull,..._e(r)});let Li=class extends Ae{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}};Li.create=r=>new Li({typeName:de.ZodAny,..._e(r)});let zn=class extends Ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,..._e(r)});let Hr=class extends Ae{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,..._e(r)});let Ho=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.void,received:n.parsedType}),pe}return _t(e.data)}};Ho.create=r=>new Ho({typeName:de.ZodVoid,..._e(r)});let Qn=class Io extends Ae{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==z.array)return H(t,{code:D.invalid_type,expected:z.array,received:t.parsedType}),pe;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(H(t,{code:a?D.too_big:D.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(H(t,{code:D.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(H(t,{code:D.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>jt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Sr(t,a,t.path,o)));return jt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Io({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new Io({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new Io({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Qn.create=(r,e)=>new Qn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,..._e(e)});function ki(r){if(r instanceof Kt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ki(n))}return new Kt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ki(r.element)}):r instanceof xr?xr.create(ki(r.unwrap())):r instanceof vn?vn.create(ki(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ki(e))):r}let Kt=class Xt extends Ae{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=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:D.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],m=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(i,m,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Hr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(H(i,{code:D.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(i,m,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,B=await f.value;u.push({key:m,value:B,alwaysSet:f.alwaysSet})}return u}).then(u=>jt.mergeObjectSync(n,u)):jt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:de.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return Re.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return ki(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof xr;)s=s._def.innerType;t[n]=s}}),new Xt({...this._def,shape:()=>t})}keyof(){return ty(Re.objectKeys(this.shape))}};Kt.create=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.strictCreate=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.lazycreate=(r,e)=>new Kt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});let Js=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new or(o.ctx.common.issues));return H(t,{code:D.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new or(c));return H(t,{code:D.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Js.create=(r,e)=>new Js({options:r,typeName:de.ZodUnion,..._e(e)});const Br=r=>r instanceof Xs?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qs?[r.value]:r instanceof Ja?r.options:r instanceof ea?Re.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zs?[void 0]:r instanceof Gs?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof af||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Jm=class Ym extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:D.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=Br(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new Ym({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,..._e(n)})}};function kl(r,e){const t=sn(r),n=sn(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&n===z.object){const i=Re.objectKeys(e),s=Re.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=kl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===z.array&&n===z.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=kl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Ys=class extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(bl(s)||bl(a))return pe;const o=kl(s.value,a.value);return o.valid?((xl(s)||xl(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:D.invalid_intersection_types}),pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ys.create=(r,e,t)=>new Ys({left:r,right:e,typeName:de.ZodIntersection,..._e(t)});let gn=class Xm extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:D.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>jt.mergeArray(t,a)):jt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Xm({...this._def,rest:e})}};gn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gn({items:r,typeName:de.ZodTuple,rest:null,..._e(e)})};let Qm=class Sl extends Ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return H(n,{code:D.invalid_type,expected:z.object,received:n.parsedType}),pe;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Sr(n,o,n.path,o)),value:a._parse(new Sr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?jt.mergeObjectAsync(t,i):jt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ae?new Sl({keyType:e,valueType:t,typeName:de.ZodRecord,..._e(n)}):new Sl({keyType:Vi.create(),valueType:e,typeName:de.ZodRecord,..._e(t)})}},Fo=class extends Ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return H(n,{code:D.invalid_type,expected:z.map,received:n.parsedType}),pe;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Sr(n,o,n.path,[u,"key"])),value:s._parse(new Sr(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};Fo.create=(r,e,t)=>new Fo({valueType:e,keyType:r,typeName:de.ZodMap,..._e(t)});let Ko=class Al extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:D.invalid_type,expected:z.set,received:n.parsedType}),pe;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(H(n,{code:D.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(H(n,{code:D.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Al({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Al({...this._def,maxSize:{value:e,message:ae.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ko.create=(r,e)=>new Ko({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,..._e(e)});let ey=class Co extends Ae{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:D.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Vo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Uo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function i(o,c){return Vo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Uo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qi){const o=this;return _t(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,s).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(C=>{throw u.addIssue(i(m,C)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new or([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Co({...this._def,args:gn.create(e).rest(zn.create())})}returns(e){return new Co({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Co({args:e||gn.create([]).rest(zn.create()),returns:t||zn.create(),typeName:de.ZodFunction,..._e(n)})}},Xs=class extends Ae{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})}};Xs.create=(r,e)=>new Xs({getter:r,typeName:de.ZodLazy,..._e(e)});let Qs=class extends Ae{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qs.create=(r,e)=>new Qs({value:r,typeName:de.ZodLiteral,..._e(e)});function ty(r,e){return new Ja({values:r,typeName:de.ZodEnum,..._e(e)})}let Ja=class Ol extends Ae{constructor(){super(...arguments),Es.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Re.joinValues(n),received:t.parsedType,code:D.invalid_type}),pe}if(Lo(this,Es)||Fm(this,Es,new Set(this._def.values)),!Lo(this,Es).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:D.invalid_enum_value,options:n}),pe}return _t(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 Ol.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ol.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Es=new WeakMap;Ja.create=ty;let ea=class extends Ae{constructor(){super(...arguments),Is.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){const i=Re.objectValues(t);return H(n,{expected:Re.joinValues(i),received:n.parsedType,code:D.invalid_type}),pe}if(Lo(this,Is)||Fm(this,Is,new Set(Re.getValidEnumValues(this._def.values))),!Lo(this,Is).has(e.data)){const i=Re.objectValues(t);return H(n,{received:n.data,code:D.invalid_enum_value,options:i}),pe}return _t(e.data)}get enum(){return this._def.values}};Is=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,..._e(e)});let qi=class extends Ae{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return H(t,{code:D.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return _t(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qi.create=(r,e)=>new qi({type:r,typeName:de.ZodPromise,..._e(e)});let dr=class extends Ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return pe;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?pe:c.status==="dirty"||t.value==="dirty"?Oi(c.value):c});{if(t.value==="aborted")return pe;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?pe:o.status==="dirty"||t.value==="dirty"?Oi(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ls(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Ls(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Re.assertNever(i)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,..._e(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,..._e(t)});let xr=class extends Ae{_parse(e){return this._getType(e)===z.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,..._e(e)});let vn=class extends Ae{_parse(e){return this._getType(e)===z.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,..._e(e)});let ta=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ta.create=(r,e)=>new ta({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});let ra=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qs(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ra.create=(r,e)=>new ra({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});let Wo=class extends Ae{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};Wo.create=r=>new Wo({typeName:de.ZodNaN,..._e(r)});const Bb=Symbol("zod_brand");let af=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},of=class ry extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),Oi(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new ry({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Ae{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Ls(i)&&(i.value=Object.freeze(i.value)),i);return qs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,..._e(e)});function ny(r,e={},t){return r?Li.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Li.create()}const Rb={object:Kt.lazycreate};var de;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(de||(de={}));const Pb=(r,e={message:`Input not instance of ${r.name}`})=>ny(t=>t instanceof r,e),iy=Vi.create,sy=Hs.create,$b=Wo.create,Db=Fs.create,ay=Ks.create,Zb=Ws.create,Mb=qo.create,Ub=zs.create,Vb=Gs.create,Lb=Li.create,qb=zn.create,Hb=Hr.create,Fb=Ho.create,Kb=Qn.create,Wb=Kt.create,zb=Kt.strictCreate,Gb=Js.create,Jb=Jm.create,Yb=Ys.create,Xb=gn.create,Qb=Qm.create,ex=Fo.create,tx=Ko.create,rx=ey.create,nx=Xs.create,ix=Qs.create,sx=Ja.create,ax=ea.create,ox=qi.create,kh=dr.create,cx=xr.create,ux=vn.create,lx=dr.createWithPreprocess,dx=of.create,fx=()=>iy().optional(),hx=()=>sy().optional(),px=()=>ay().optional(),mx={string:r=>Vi.create({...r,coerce:!0}),number:r=>Hs.create({...r,coerce:!0}),boolean:r=>Ks.create({...r,coerce:!0}),bigint:r=>Fs.create({...r,coerce:!0}),date:r=>Ws.create({...r,coerce:!0})},yx=pe;var y=Object.freeze({__proto__:null,defaultErrorMap:Ui,setErrorMap:yb,getErrorMap:Uo,makeIssue:Vo,EMPTY_PATH:gb,addIssueToContext:H,ParseStatus:jt,INVALID:pe,DIRTY:Oi,OK:_t,isAborted:bl,isDirty:xl,isValid:Ls,isAsync:qs,get util(){return Re},get objectUtil(){return vl},ZodParsedType:z,getParsedType:sn,ZodType:Ae,datetimeRegex:zm,ZodString:Vi,ZodNumber:Hs,ZodBigInt:Fs,ZodBoolean:Ks,ZodDate:Ws,ZodSymbol:qo,ZodUndefined:zs,ZodNull:Gs,ZodAny:Li,ZodUnknown:zn,ZodNever:Hr,ZodVoid:Ho,ZodArray:Qn,ZodObject:Kt,ZodUnion:Js,ZodDiscriminatedUnion:Jm,ZodIntersection:Ys,ZodTuple:gn,ZodRecord:Qm,ZodMap:Fo,ZodSet:Ko,ZodFunction:ey,ZodLazy:Xs,ZodLiteral:Qs,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qi,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:Wo,BRAND:Bb,ZodBranded:af,ZodPipeline:of,ZodReadonly:na,custom:ny,Schema:Ae,ZodSchema:Ae,late:Rb,get ZodFirstPartyTypeKind(){return de},coerce:mx,any:Lb,array:Kb,bigint:Db,boolean:ay,date:Zb,discriminatedUnion:Jb,effect:kh,enum:sx,function:rx,instanceof:Pb,intersection:Yb,lazy:nx,literal:ix,map:ex,nan:$b,nativeEnum:ax,never:Hb,null:Vb,nullable:ux,number:sy,object:Wb,oboolean:px,onumber:hx,optional:cx,ostring:fx,pipeline:dx,preprocess:lx,promise:ox,record:Qb,set:tx,strictObject:zb,string:iy,symbol:Mb,transformer:kh,tuple:Xb,undefined:Ub,union:Gb,unknown:qb,void:Fb,NEVER:yx,ZodIssueCode:D,quotelessJson:mb,ZodError:or}),dt=class El extends pb{constructor(t){super(t);ne(this,"openAPIRegistry");ne(this,"defaultHook");ne(this,"openapi",({middleware:t,...n},i,s=this.defaultHook)=>{var u,f,m,B,C,p,g,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xi("query",n.request.query,s);a.push(N)}if((f=n.request)!=null&&f.params){const N=xi("param",n.request.params,s);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xi("header",n.request.headers,s);a.push(N)}if((B=n.request)!=null&&B.cookies){const N=xi("cookie",n.request.cookies,s);a.push(N)}const o=(p=(C=n.request)==null?void 0:C.body)==null?void 0:p.content;if(o)for(const N of Object.keys(o)){if(!o[N])continue;const xe=o[N].schema;if(xe instanceof Ae){if(Ah(N)){const Le=xi("json",xe,s);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Ah(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(Oh(N)){const Le=xi("form",xe,s);if((P=(O=n.request)==null?void 0:O.body)!=null&&P.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Oh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("form",{}),await tt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,i),this});ne(this,"getOpenAPIDocument",t=>{const i=new Iv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Sh(i,this._basePath):i});ne(this,"getOpenAPI31Document",t=>{const i=new Tv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Sh(i,this._basePath):i});ne(this,"doc",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPIDocument(s);return i.json(a)}catch(a){return i.json(a,500)}}));ne(this,"doc31",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPI31Document(s);return i.json(a)}catch(a){return i.json(a,500)}}));this.openAPIRegistry=new lv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const i=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof El?(n.openAPIRegistry.definitions.forEach(s=>{switch(s.type){case"component":return this.openAPIRegistry.registerComponent(s.componentType,s.name,s.component);case"route":return this.openAPIRegistry.registerPath({...s.route,path:nn(i,s.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...s.webhook,path:nn(i,s.webhook.path)});case"schema":return this.openAPIRegistry.register(s.schema._def.openapi._internal.refId,s.schema);case"parameter":return this.openAPIRegistry.registerParameter(s.schema._def.openapi._internal.refId,s.schema);default:{const a=s;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new El({...super.basePath(t),defaultHook:this.defaultHook})}},ve=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};av(y);function Sh(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function Ah(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function Oh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function gx(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function vx(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ks(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function bx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=gx(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(vx(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ks(r,"optional"),ks(r,"nullable"),ks(r,"default"),ks(r,"transform"),ks(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var Pe;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Pe||(Pe={}));var Il;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Il||(Il={}));const G=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),an=r=>{switch(typeof r){case"undefined":return G.undefined;case"string":return G.string;case"number":return isNaN(r)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(r)?G.array:r===null?G.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?G.promise:typeof Map<"u"&&r instanceof Map?G.map:typeof Set<"u"&&r instanceof Set?G.set:typeof Date<"u"&&r instanceof Date?G.date:G.object;default:return G.unknown}},Z=Pe.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"]),xx=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Dt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const Hi=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Pe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(r)}return{message:t}};let oy=Hi;function _x(r){oy=r}function zo(){return oy}const Go=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},wx=[];function F(r,e){const t=zo(),n=Go({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hi?void 0:Hi].filter(i=>!!i)});r.common.issues.push(n)}class gt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return ge;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return ge;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const ge=Object.freeze({status:"aborted"}),Jo=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Cl=r=>r.status==="aborted",jl=r=>r.status==="dirty",ia=r=>r.status==="valid",sa=r=>typeof Promise<"u"&&r instanceof Promise;function Yo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function cy(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var js,Ts;class Ar{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 Eh=(r,e)=>{if(ia(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Dt(r.common.issues);return this._error=t,this._error}}};function we(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{var o,c;const{message:u}=r;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:i}}class Ee{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 an(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gt,ctx:{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(sa(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Eh(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(sa(i)?i:Promise.resolve(i));return Eh(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:Z.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new fr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cr.create(this,this._def)}promise(){return Ki.create(this,this._def)}or(e){return ua.create([this,e],this._def)}and(e){return la.create(this,e,this._def)}transform(e){return new fr({...we(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({...we(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new cf({typeName:fe.ZodBranded,type:this,...we(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({...we(this._def),innerType:this,catchValue:t,typeName:fe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ya.create(this,e)}readonly(){return ga.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const kx=/^c[^\s-]{8,}$/i,Sx=/^[0-9a-z]+$/,Ax=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ox=/^[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,Ex=/^[a-z0-9_-]{21}$/i,Ix=/^[-+]?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)?)??$/,Cx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,jx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tl;const Tx=/^(?:(?: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])$/,Nx=/^(([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})))$/,Bx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,uy="((\\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])))",Rx=new RegExp(`^${uy}$`);function ly(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Px(r){return new RegExp(`^${ly(r)}$`)}function dy(r){let e=`${uy}T${ly(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function $x(r,e){return!!((e==="v4"||!e)&&Tx.test(r)||(e==="v6"||!e)&&Nx.test(r))}class ir extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.string,received:i.parsedType}),ge}const t=new gt;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="length"){const s=e.data.length>i.value,a=e.data.length<i.value;(s||a)&&(n=this._getOrReturnCtx(e,n),s?F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if(i.kind==="email")Cx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="emoji")tl||(tl=new RegExp(jx,"u")),tl.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="uuid")Ox.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="nanoid")Ex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid")kx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid2")Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="ulid")Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:Z.invalid_string,message:i.message}),t.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:Z.invalid_string,message:i.message}),t.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty()):i.kind==="datetime"?dy(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"datetime",message:i.message}),t.dirty()):i.kind==="date"?Rx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"date",message:i.message}),t.dirty()):i.kind==="time"?Px(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"time",message:i.message}),t.dirty()):i.kind==="duration"?Ix.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="ip"?$x(e.data,i.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="base64"?Bx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:Z.invalid_string,message:i.message}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Z.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new ir({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...oe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...oe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...oe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...oe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...oe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...oe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...oe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...oe.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...oe.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,...oe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...oe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...oe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...oe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...oe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...oe.errToObj(t)})}nonempty(e){return this.min(1,oe.errToObj(e))}trim(){return new ir({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ir({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ir({...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}}ir.create=r=>{var e;return new ir({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};function Dx(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class bn extends Ee{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)!==G.number){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.number,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Dx(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_finite,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new bn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:oe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:oe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:oe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:oe.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"&&Pe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}bn.create=r=>new bn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class xn extends Ee{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)!==G.bigint){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.bigint,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new xn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.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}}xn.create=r=>{var e;return new xn({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};class aa extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.boolean,received:t.parsedType}),ge}return wt(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class ei extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.date,received:i.parsedType}),ge}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_date}),ge}const t=new gt;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:oe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:oe.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}}ei.create=r=>new ei({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...we(r)});class Xo extends Ee{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.symbol,received:t.parsedType}),ge}return wt(e.data)}}Xo.create=r=>new Xo({typeName:fe.ZodSymbol,...we(r)});class oa extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.undefined,received:t.parsedType}),ge}return wt(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,...we(r)});class ca extends Ee{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.null,received:t.parsedType}),ge}return wt(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,...we(r)});class Fi extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Fi.create=r=>new Fi({typeName:fe.ZodAny,...we(r)});class Gn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,...we(r)});class Fr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.never,received:t.parsedType}),ge}}Fr.create=r=>new Fr({typeName:fe.ZodNever,...we(r)});class Qo extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.void,received:t.parsedType}),ge}return wt(e.data)}}Qo.create=r=>new Qo({typeName:fe.ZodVoid,...we(r)});class cr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==G.array)return F(t,{code:Z.invalid_type,expected:G.array,received:t.parsedType}),ge;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(F(t,{code:a?Z.too_big:Z.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(F(t,{code:Z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(F(t,{code:Z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Ar(t,a,t.path,o)));return gt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new cr({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new cr({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new cr({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}cr.create=(r,e)=>new cr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...we(e)});function Si(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Si(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Si(r.element)}):r instanceof _r?_r.create(Si(r.unwrap())):r instanceof wn?wn.create(Si(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Si(e))):r}class Je extends Ee{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=Pe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const c=this._getOrReturnCtx(e);return F(c,{code:Z.invalid_type,expected:G.object,received:c.parsedType}),ge}const{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)s.includes(c)||a.push(c);const o=[];for(const c of s){const u=i[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ar(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Fr){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")a.length>0&&(F(n,{code:Z.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ar(n,f,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const f=await u.key,m=await u.value;c.push({key:f,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>gt.mergeObjectSync(t,c)):gt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return Pe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return Si(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof _r;)i=i._def.innerType;t[n]=i}}),new Je({...this._def,shape:()=>t})}keyof(){return fy(Pe.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});class ua extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Dt(o.ctx.common.issues));return F(t,{code:Z.invalid_union,unionErrors:a}),ge}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new Dt(c));return F(t,{code:Z.invalid_union,unionErrors:o}),ge}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,...we(e)});const rn=r=>r instanceof fa?rn(r.schema):r instanceof fr?rn(r.innerType()):r instanceof ha?[r.value]:r instanceof _n?r.options:r instanceof pa?Pe.objectValues(r.enum):r instanceof ma?rn(r._def.innerType):r instanceof oa?[void 0]:r instanceof ca?[null]:r instanceof _r?[void 0,...rn(r.unwrap())]:r instanceof wn?[null,...rn(r.unwrap())]:r instanceof cf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class tu extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:Z.invalid_type,expected:G.object,received:t.parsedType}),ge;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ge)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=rn(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new tu({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...we(n)})}}function Tl(r,e){const t=an(r),n=an(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const i=Pe.objectKeys(e),s=Pe.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Tl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Tl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(Cl(s)||Cl(a))return ge;const o=Tl(s.value,a.value);return o.valid?((jl(s)||jl(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:Z.invalid_intersection_types}),ge)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,...we(t)});class Or extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:Z.invalid_type,expected:G.array,received:n.parsedType}),ge;if(n.data.length<this._def.items.length)return F(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ge;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((s,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>gt.mergeArray(t,s)):gt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Or({...this._def,rest:e})}}Or.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Or({items:r,typeName:fe.ZodTuple,rest:null,...we(e)})};class da extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return F(n,{code:Z.invalid_type,expected:G.object,received:n.parsedType}),ge;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?gt.mergeObjectAsync(t,i):gt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,...we(n)}):new da({keyType:ir.create(),valueType:e,typeName:fe.ZodRecord,...we(t)})}}class ec extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return F(n,{code:Z.invalid_type,expected:G.map,received:n.parsedType}),ge;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Ar(n,o,n.path,[u,"key"])),value:s._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}ec.create=(r,e,t)=>new ec({valueType:e,keyType:r,typeName:fe.ZodMap,...we(t)});class ti extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:Z.invalid_type,expected:G.set,received:n.parsedType}),ge;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(F(n,{code:Z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(F(n,{code:Z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ge;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ti({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ti({...this._def,maxSize:{value:e,message:oe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ti.create=(r,e)=>new ti({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...we(e)});class Ti extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:Z.invalid_type,expected:G.function,received:t.parsedType}),ge;function n(o,c){return Go({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,zo(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function i(o,c){return Go({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,zo(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ki){const o=this;return wt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,s).catch(B=>{throw u.addIssue(n(c,B)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(B=>{throw u.addIssue(i(m,B)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new Dt([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ti({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ti({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ti({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,...we(n)})}}class fa extends Ee{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})}}fa.create=(r,e)=>new fa({getter:r,typeName:fe.ZodLazy,...we(e)});class ha extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),ge}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,...we(e)});function fy(r,e){return new _n({values:r,typeName:fe.ZodEnum,...we(e)})}class _n extends Ee{constructor(){super(...arguments),js.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Pe.joinValues(n),received:t.parsedType,code:Z.invalid_type}),ge}if(Yo(this,js)||cy(this,js,new Set(this._def.values)),!Yo(this,js).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:Z.invalid_enum_value,options:n}),ge}return wt(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 _n.create(e,{...this._def,...t})}exclude(e,t=this._def){return _n.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}js=new WeakMap;_n.create=fy;class pa extends Ee{constructor(){super(...arguments),Ts.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const i=Pe.objectValues(t);return F(n,{expected:Pe.joinValues(i),received:n.parsedType,code:Z.invalid_type}),ge}if(Yo(this,Ts)||cy(this,Ts,new Set(Pe.getValidEnumValues(this._def.values))),!Yo(this,Ts).has(e.data)){const i=Pe.objectValues(t);return F(n,{received:n.data,code:Z.invalid_enum_value,options:i}),ge}return wt(e.data)}get enum(){return this._def.values}}Ts=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,...we(e)});class Ki extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return F(t,{code:Z.invalid_type,expected:G.promise,received:t.parsedType}),ge;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return wt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ki.create=(r,e)=>new Ki({type:r,typeName:fe.ZodPromise,...we(e)});class fr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ge;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ge:c.status==="dirty"||t.value==="dirty"?Jo(c.value):c});{if(t.value==="aborted")return ge;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ge:o.status==="dirty"||t.value==="dirty"?Jo(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ge:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ge:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ia(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ia(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(i)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,...we(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...we(t)});class _r extends Ee{_parse(e){return this._getType(e)===G.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:fe.ZodOptional,...we(e)});class wn extends Ee{_parse(e){return this._getType(e)===G.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wn.create=(r,e)=>new wn({innerType:r,typeName:fe.ZodNullable,...we(e)});class ma extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ma.create=(r,e)=>new ma({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...we(e)});class ya extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return sa(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ya.create=(r,e)=>new ya({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...we(e)});class tc extends Ee{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.nan,received:t.parsedType}),ge}return{status:"valid",value:e.data}}}tc.create=r=>new tc({typeName:fe.ZodNaN,...we(r)});const Zx=Symbol("zod_brand");class cf extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ya extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),Jo(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=i=>(ia(i)&&(i.value=Object.freeze(i.value)),i);return sa(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,...we(e)});function hy(r,e={},t){return r?Fi.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Fi.create()}const Mx={object:Je.lazycreate};var fe;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(fe||(fe={}));const Ux=(r,e={message:`Input not instance of ${r.name}`})=>hy(t=>t instanceof r,e),py=ir.create,my=bn.create,Vx=tc.create,Lx=xn.create,yy=aa.create,qx=ei.create,Hx=Xo.create,Fx=oa.create,Kx=ca.create,Wx=Fi.create,zx=Gn.create,Gx=Fr.create,Jx=Qo.create,Yx=cr.create,Xx=Je.create,Qx=Je.strictCreate,e_=ua.create,t_=tu.create,r_=la.create,n_=Or.create,i_=da.create,s_=ec.create,a_=ti.create,o_=Ti.create,c_=fa.create,u_=ha.create,l_=_n.create,d_=pa.create,f_=Ki.create,Ih=fr.create,h_=_r.create,p_=wn.create,m_=fr.createWithPreprocess,y_=Ya.create,g_=()=>py().optional(),v_=()=>my().optional(),b_=()=>yy().optional(),x_={string:r=>ir.create({...r,coerce:!0}),number:r=>bn.create({...r,coerce:!0}),boolean:r=>aa.create({...r,coerce:!0}),bigint:r=>xn.create({...r,coerce:!0}),date:r=>ei.create({...r,coerce:!0})},__=ge;var d=Object.freeze({__proto__:null,defaultErrorMap:Hi,setErrorMap:_x,getErrorMap:zo,makeIssue:Go,EMPTY_PATH:wx,addIssueToContext:F,ParseStatus:gt,INVALID:ge,DIRTY:Jo,OK:wt,isAborted:Cl,isDirty:jl,isValid:ia,isAsync:sa,get util(){return Pe},get objectUtil(){return Il},ZodParsedType:G,getParsedType:an,ZodType:Ee,datetimeRegex:dy,ZodString:ir,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:ei,ZodSymbol:Xo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fi,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:Qo,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:tu,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:ec,ZodSet:ti,ZodFunction:Ti,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ki,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:tc,BRAND:Zx,ZodBranded:cf,ZodPipeline:Ya,ZodReadonly:ga,custom:hy,Schema:Ee,ZodSchema:Ee,late:Mx,get ZodFirstPartyTypeKind(){return fe},coerce:x_,any:Wx,array:Yx,bigint:Lx,boolean:yy,date:qx,discriminatedUnion:t_,effect:Ih,enum:l_,function:o_,instanceof:Ux,intersection:r_,lazy:c_,literal:u_,map:s_,nan:Vx,nativeEnum:d_,never:Gx,null:Kx,nullable:p_,number:my,object:Xx,oboolean:b_,onumber:v_,optional:h_,ostring:g_,pipeline:y_,preprocess:m_,promise:f_,record:i_,set:a_,strictObject:Qx,string:py,symbol:Hx,transformer:Ih,tuple:n_,undefined:Fx,union:e_,unknown:zx,void:Jx,NEVER:__,ZodIssueCode:Z,quotelessJson:xx,ZodError:Dt});bx(d);const jn=d.object({start:d.number(),limit:d.number(),length:d.number()}),uf=d.object({created_at:d.string(),updated_at:d.string()}),gy=d.object({email:d.string().optional(),email_verified:d.boolean().optional(),name:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),phone_number:d.string().optional(),phone_verified:d.boolean().optional(),family_name:d.string().optional()}).catchall(d.any()),vy=d.object({connection:d.string(),user_id:d.string(),provider:d.string(),isSocial:d.boolean(),access_token:d.string().optional(),access_token_secret:d.string().optional(),refresh_token:d.string().optional(),profileData:gy.optional()}),ru=d.object({email:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),family_name:d.string().optional(),nickname:d.string().optional(),name:d.string().optional(),picture:d.string().optional(),locale:d.string().optional(),linked_to:d.string().optional(),profileData:d.string().optional(),user_id:d.string().optional(),app_metadata:d.any().default({}).optional(),user_metadata:d.any().default({}).optional()}),rc=ru.extend({email_verified:d.boolean().default(!1),verify_email:d.boolean().optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string().optional(),provider:d.string().default("email"),connection:d.string().default("email")}),lf=d.object({...rc.shape,...uf.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(vy).optional()}),vr=lf,w_=ru.extend({email:d.string(),login_count:d.number(),multifactor:d.array(d.string()).optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string()}).catchall(d.any()),k_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let S_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=k_[t[r]&63];return e};const by=d.object({audience:d.string().optional(),recipient:d.string().optional(),createUpnClaim:d.boolean().optional(),mapUnknownClaimsAsIs:d.boolean().optional(),passthroughClaimsWithNoMapping:d.boolean().optional(),mapIdentities:d.boolean().optional(),signatureAlgorithm:d.string().optional(),digestAlgorithm:d.string().optional(),issuer:d.string().optional(),destination:d.string().optional(),lifetimeInSeconds:d.number().optional(),signResponse:d.boolean().optional(),nameIdentifierFormat:d.string().optional(),nameIdentifierProbes:d.array(d.string()).optional(),authnContextClassRef:d.string().optional(),mappings:d.record(d.string()).optional()}),nc=d.object({id:d.string(),name:d.string(),callbacks:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:d.array(d.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:d.object({samlp:by.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:d.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:d.string().default(()=>S_()).optional(),disable_sign_ups:d.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Mn=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...nc.shape});var df=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(df||{}),ff=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(ff||{}),hf=(r=>(r.S256="S256",r.Plain="plain",r))(hf||{});const xy=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(df).optional(),response_mode:d.nativeEnum(ff).optional(),redirect_uri:d.string().optional(),audience:d.string().optional(),state:d.string().optional(),nonce:d.string().optional(),scope:d.string().optional(),prompt:d.string().optional(),code_challenge_method:d.nativeEnum(hf).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),Nl=d.object({colors:d.object({primary:d.string(),page_background:d.object({type:d.string().optional(),start:d.string().optional(),end:d.string().optional(),angle_deg:d.number().optional()}).optional()}).optional(),logo_url:d.string().optional(),favicon_url:d.string().optional(),font:d.object({url:d.string()}).optional()}),ic=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:d.object({kid:d.string().optional(),team_id:d.string().optional(),realms:d.string().optional(),client_id:d.string().optional(),client_secret:d.string().optional(),app_secret:d.string().optional(),scope:d.string().optional(),authorization_endpoint:d.string().default("").optional(),token_endpoint:d.string().default("").optional(),userinfo_endpoint:d.string().default("").optional(),jwks_uri:d.string().default("").optional(),discovery_url:d.string().default("").optional(),issuer:d.string().default("").optional()}).default({}).optional(),enabled_clients:d.array(d.string()).default([]).optional(),response_type:d.custom().optional(),response_mode:d.custom().optional()}),Un=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(ic.shape),sc=d.object({name:d.string(),audience:d.string(),sender_email:d.string().email(),sender_name:d.string(),support_url:d.string().url().optional(),logo:d.string().url().optional(),primary_color:d.string().optional(),secondary_color:d.string().optional(),language:d.string().optional()}),Ni=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...sc.shape}),A_=d.object({logoUrl:d.string(),loginBackgroundImage:d.string().nullish(),style:d.object({primaryColor:d.string(),buttonTextColor:d.string(),primaryHoverColor:d.string()}),supportEmail:d.string().nullable(),supportUrl:d.string().nullable(),name:d.string(),showGreyishBackground:d.boolean().optional(),termsAndConditionsUrl:d.string().nullable(),companyName:d.string().optional(),checkoutHideSocial:d.boolean().optional(),siteUrl:d.string().nullable(),manageSubscriptionsUrl:d.string().optional()}),O_=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.union([d.literal("mailgun"),d.literal("mailchannels")]).optional()});d.object({...Mn.shape,domains:d.array(O_),tenant:Ni,connections:d.array(Un)});const _y=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),wy=d.object({code_id:d.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:d.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:d.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:_y,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()}),E_=d.object({...wy.shape,created_at:d.string()}),ky=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.enum(["mailgun","mailchannels"])}),I_=uf.extend({...ky.shape,id:d.string()}),ac=d.object({trigger_id:d.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:d.boolean().default(!1),url:d.string(),hook_id:d.string().optional(),synchronous:d.boolean().default(!1),priority:d.number().optional()}),Ei=ac.extend({...uf.shape,hook_id:d.string()}),pf=d.object({alg:d.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:d.string(),kid:d.string(),kty:d.enum(["RSA","EC","oct"]),n:d.string(),x5t:d.string().optional(),x5c:d.array(d.string()).optional(),use:d.enum(["sig","enc"]).optional()}),Sy=d.object({keys:d.array(pf)}),Bl=d.object({issuer:d.string(),authorization_endpoint:d.string(),token_endpoint:d.string(),device_authorization_endpoint:d.string(),userinfo_endpoint:d.string(),mfa_challenge_endpoint:d.string(),jwks_uri:d.string(),registration_endpoint:d.string(),revocation_endpoint:d.string(),scopes_supported:d.array(d.string()),response_types_supported:d.array(d.string()),code_challenge_methods_supported:d.array(d.string()),response_modes_supported:d.array(d.string()),subject_types_supported:d.array(d.string()),id_token_signing_alg_values_supported:d.array(d.string()),token_endpoint_auth_methods_supported:d.array(d.string()),claims_supported:d.array(d.string()),request_uri_parameter_supported:d.boolean(),request_parameter_supported:d.boolean(),token_endpoint_auth_signing_alg_values_supported:d.array(d.string())}),Ay=d.object({auth0Client:d.string().optional(),authParams:xy,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional(),useragent:d.string().optional()}).openapi({description:"This represents a login sesion"}),C_=d.object({...Ay.shape,login_id:d.string().openapi({description:"This is is used as the state in the universal login"}),created_at:d.string(),updated_at:d.string()});var nu=(r=>(r.FAILED_SILENT_AUTH="fsa",r.FAILED_SIGNUP="fs",r.FAILED_LOGIN="f",r.FAILED_LOGIN_INCORRECT_PASSWORD="fp",r.FAILED_CHANGE_PASSWORD="fcp",r.FAILED_BY_CONNECTOR="fc",r.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",r.FAILED_HOOK="fh",r.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",r.SUCCESS_API_OPERATION="sapi",r.SUCCESS_CHANGE_PASSWORD="scp",r.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",r.SUCCESS_CHANGE_USERNAME="scu",r.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",r.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",r.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",r.SUCCESS_LOGIN="s",r.SUCCESS_LOGOUT="slo",r.SUCCESS_SIGNUP="ss",r.SUCCESS_SILENT_AUTH="ssa",r.SUCCESS_VERIFICATION_EMAIL="sv",r.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",r.CODE_LINK_SENT="cls",r))(nu||{});const j_=d.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),Oy=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),oc=d.object({type:j_,date:d.string(),description:d.string().optional(),log_id:d.string().optional(),_id:d.string().optional(),ip:d.string(),user_agent:d.string(),details:d.any().optional(),isMobile:d.boolean(),user_id:d.string().optional(),user_name:d.string().optional(),connection:d.string().optional(),connection_id:d.string().optional(),client_id:d.string().optional(),client_name:d.string().optional(),audience:d.string().optional(),scope:d.array(d.string()).optional(),strategy:d.string().optional(),strategy_type:d.string().optional(),hostname:d.string().optional(),auth0_client:Oy.optional()}),Ey=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")}),T_=d.object({...Ey.shape,created_at:d.string(),updated_at:d.string()}),Iy=d.object({session_id:d.string(),client_id:d.string(),expires_at:d.string(),used_at:d.string(),deleted_at:d.string().optional(),user_id:d.string()}),mf=d.object({created_at:d.string(),...Iy.shape}),Rl=d.object({kid:d.string().openapi({description:"The key id of the signing key"}),cert:d.string().openapi({description:"The public certificate of the signing key"}),fingerprint:d.string().openapi({description:"The cert fingerprint"}),thumbprint:d.string().openapi({description:"The cert thumbprint"}),pkcs7:d.string().optional().openapi({description:"The private key in pkcs7 format"}),current:d.boolean().optional().openapi({description:"True if the key is the current key"}),next:d.boolean().optional().openapi({description:"True if the key is the next key"}),previous:d.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:d.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:d.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:d.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:d.string().optional().openapi({description:"The date and time when the key was revoked"})});var cc=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(cc||{});d.object({access_token:d.string(),id_token:d.string().optional(),scope:d.string().optional(),state:d.string().optional(),refresh_token:d.string().optional(),token_type:d.string(),expires_in:d.number()});d.object({code:d.string(),state:d.string().optional()});const Cy=d.object({button_border_radius:d.number(),button_border_weight:d.number(),buttons_style:d.enum(["pill"]),input_border_radius:d.number(),input_border_weight:d.number(),inputs_style:d.enum(["pill"]),show_widget_shadow:d.boolean(),widget_border_weight:d.number(),widget_corner_radius:d.number()}),jy=d.object({base_focus_color:d.string(),base_hover_color:d.string(),body_text:d.string(),captcha_widget_theme:d.enum(["auto"]),error:d.string(),header:d.string(),icons:d.string(),input_background:d.string(),input_border:d.string(),input_filled_text:d.string(),input_labels_placeholders:d.string(),links_focused_components:d.string(),primary_button:d.string(),primary_button_label:d.string(),secondary_button_border:d.string(),secondary_button_label:d.string(),success:d.string(),widget_background:d.string(),widget_border:d.string()}),Dn=d.object({bold:d.boolean(),size:d.number()}),Ty=d.object({body_text:Dn,buttons_text:Dn,font_url:d.string(),input_labels:Dn,links:Dn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Dn,title:Dn}),Ny=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),By=d.object({header_text_alignment:d.enum(["center"]),logo_height:d.number(),logo_position:d.enum(["center"]),logo_url:d.string(),social_buttons_layout:d.enum(["bottom"])}),Ry=d.object({borders:Cy,colors:jy,displayName:d.string(),fonts:Ty,page_background:Ny,widget:By}),N_=Ry.extend({themeId:d.string()}),jo=d.object({universal_login_experience:d.enum(["new","classic"]).default("new"),identifier_first:d.boolean().default(!0),password_first:d.boolean().default(!1),webauthn_platform_first_factor:d.boolean()}),To=d.object({name:d.string(),enabled:d.boolean().optional().default(!0),default_from_address:d.string().optional(),credentials:d.union([d.object({accessKeyId:d.string(),secretAccessKey:d.string(),region:d.string()}),d.object({smtp_host:d.array(d.string()),smtp_port:d.number(),smtp_user:d.string(),smtp_pass:d.string()}),d.object({api_key:d.string(),domain:d.string().optional()}),d.object({connectionString:d.string()}),d.object({tenantId:d.string(),clientId:d.string(),clientSecret:d.string()})]),settings:d.object({}).optional()});function B_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}const R_=new dt().openapi(ve({tags:["branding"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Nl}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.branding.get(e);return t?r.json(t):r.json({})}).openapi(ve({tags:["branding"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(Nl.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});var uc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function P_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function $_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}function D_(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Py={exports:{}};const Z_={},M_=Object.freeze(Object.defineProperty({__proto__:null,default:Z_},Symbol.toStringTag,{value:"Module"})),U_=$_(M_);(function(r){/**
1
+ "use strict";var iv=Object.defineProperty;var yh=r=>{throw TypeError(r)};var sv=(r,e,t)=>e in r?iv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ne=(r,e,t)=>sv(r,typeof e!="symbol"?e+"":e,t),Xu=(r,e,t)=>e.has(r)||yh("Cannot "+t);var w=(r,e,t)=>(Xu(r,e,"read from private field"),t?t.call(r):e.get(r)),Oe=(r,e,t)=>e.has(r)?yh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Xu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Te=(r,e,t)=>(Xu(r,e,"access private method"),t);var gh=(r,e,t,n)=>({set _(i){ue(r,e,i,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function As(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function Se(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function av(r){return"_def"in r}function xs(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function ov(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=As(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(Se(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xs(r,"optional"),xs(r,"nullable"),xs(r,"default"),xs(r,"transform"),xs(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}function Zo(r,e){if(r==null||e===null||e===void 0)return r===e;if(r===e||r.valueOf()===e.valueOf())return!0;if(Array.isArray(r)&&(!Array.isArray(e)||r.length!==e.length)||!(r instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(r);return Object.keys(e).every(n=>t.indexOf(n)!==-1)&&t.every(n=>Zo(r[n],e[n]))}class cv{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(s=>Zo(s,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(i=>Zo(i,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const s of this.buckets.values())e+=1,t+=s.length,s.length>1&&(n+=1);const i=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:i}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if(typeof e=="string"){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[n,i]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(i??"");return t}}function Rs(r){return r==null}function Ps(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{t[n]=e(i)}),t}function uv(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e.some(s=>s===n)||(t[n]=i)}),t}function ji(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e(i,n)||(t[n]=i)}),t}function vh(r){return r.filter(e=>!Rs(e))}const yl=Zo;function lv(r){const e=new cv;return r.forEach(t=>e.put(t)),[...e.values()]}function wm(r){return typeof r=="string"}class dv{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(i=>i.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,i,s;const a=this.schemaWithRefId(e,t),o=(n=a._def.openapi)===null||n===void 0?void 0:n.metadata,c=a.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(s=(i=o==null?void 0:o.param)===null||i===void 0?void 0:i.name)!==null&&s!==void 0?s:e})}));return this._definitions.push({type:"parameter",schema:c}),c}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:"component",componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class tu{constructor(e){this.message=e}}class _s extends tu{constructor(e,t){super(e),this.data=t}}class Mo extends tu{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 ws(r,e){try{return r()}catch(t){throw t instanceof Mo?new Mo(Object.assign(Object.assign({},t.data),e)):t}}class fv extends tu{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class We{static getMetadata(e){var t;const n=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:n._def.openapi,s=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign({description:s},i==null?void 0:i.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return n==null?void 0:n._internal}static getParamMetadata(e){var t,n;const i=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:i._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:i.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign(Object.assign({},s==null?void 0:s.metadata),{param:Object.assign({description:a},(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return ji(uv(e,["param"]),Rs)}static buildParameterMetadata(e){return ji(e,Rs)}static applySchemaMetadata(e,t){return ji(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Rs)}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&&Se(e,t)?e:Se(e,"ZodOptional")||Se(e,"ZodNullable")||Se(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):Se(e,"ZodDefault")||Se(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):Se(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):Se(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return Se(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class hv{transform(e,t,n){var i,s;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(i=e._def.minLength)===null||i===void 0?void 0:i.value,maxItems:(s=e._def.maxLength)===null||s===void 0?void 0:s.value})}}class pv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class mv{transform(e,t,n,i,s){const a=[...e.options.values()],o=a.map(i);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,s)}}mapDiscriminator(e,t,n){if(e.some(s=>We.getRefId(s)===void 0))return;const i={};return e.forEach(s=>{var a;const o=We.getRefId(s),c=(a=s.shape)===null||a===void 0?void 0:a[t];if(Se(c,"ZodEnum")||Se(c,"ZodNativeEnum")){Object.values(c.enum).filter(wm).forEach(m=>{i[m]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);i[u]=n(o)}),{propertyName:t,mapping:i}}}class yv{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class gv{transform(e,t,n,i){const a={allOf:this.flattenIntersectionTypes(e).map(i)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!Se(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class vv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function bv(r){const t=Object.keys(r).filter(s=>typeof r[r[s]]!="number").map(s=>r[s]),n=t.filter(s=>typeof s=="number").length,i=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:i}}class xv{transform(e,t){const{type:n,values:i}=bv(e._def.values);if(n==="mixed")throw new tu("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:i})}}class _v{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class wv{transform(e,t,n,i){var s;const a=(s=We.getInternalMetadata(e))===null||s===void 0?void 0:s.extendedFrom,o=this.requiredKeysOf(e),c=Ps(e._def.shape(),i);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,i));const u=a.schema;i(u);const f=this.requiredKeysOf(u),m=Ps(u==null?void 0:u._def.shape(),i),B=Object.fromEntries(Object.entries(c).filter(([g,A])=>!yl(m[g],A))),C=o.filter(g=>!f.includes(g)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:B}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,i));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,i=e._def.catchall;return Se(i,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(i)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!We.isOptionalSchema(n)).map(([t,n])=>t)}}class kv{transform(e,t,n){const i=e._def.valueType,s=e._def.keyType,a=n(i);if(Se(s,"ZodEnum")||Se(s,"ZodNativeEnum")){const c=Object.values(s.enum).filter(wm).reduce((u,f)=>Object.assign(Object.assign({},u),{[f]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class Sv{transform(e,t){var n,i,s;const a=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(i=e.minLength)!==null&&i!==void 0?i:void 0,u=Number.isFinite(e.maxLength)&&(s=e.maxLength)!==null&&s!==void 0?s:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:a==null?void 0:a.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(n=>n.kind===t)}}class Av{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:i}=e._def,s=i.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(s))}}class Ov{transform(e,t,n){const s=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(s)}}flattenUnionTypes(e){return Se(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return Se(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Ev{constructor(e){this.versionSpecifics=e,this.objectTransformer=new wv,this.stringTransformer=new Sv,this.numberTransformer=new _v,this.bigIntTransformer=new pv,this.literalTransformer=new vv,this.enumTransformer=new yv,this.nativeEnumTransformer=new xv,this.arrayTransformer=new hv,this.unionTransformer=new Ov,this.discriminatedUnionTransformer=new mv,this.intersectionTransformer=new gv,this.recordTransformer=new kv,this.tupleTransformer=new Av(e)}transform(e,t,n,i,s){if(Se(e,"ZodNull"))return this.versionSpecifics.nullType;if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodObject"))return this.objectTransformer.transform(e,s,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,i);return Object.assign(Object.assign({},a),{default:s})}transformSchemaWithoutDefault(e,t,n,i){if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(Se(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(Se(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,i);if(Se(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const s=We.getRefId(e);throw new fv({currentSchema:e._def,schemaName:s})}}class km{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Ev(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 n={};return this.rawComponents.forEach(({componentType:i,name:s,component:a})=>{var o;(o=n[i])!==null&&o!==void 0||(n[i]={}),n[i][s]=a}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},(e=n.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=n.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const i=e.findIndex(a=>a===t.type),s=e.findIndex(a=>a===n.type);return i-s})}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=We.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,i,s,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId?this.paramRefs[(s=e._internal)===null||s===void 0?void 0:s.refId]:void 0;if(!(!(!((a=e==null?void 0:e._internal)===null||a===void 0)&&a.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new _s(`Conflicting location for parameter ${u.name}`,{key:"in",values:vh([u.in,t==null?void 0:t.in,c==null?void 0:c.in])});if(c&&u.name!==c.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new _s("Conflicting names for parameter",{key:"name",values:vh([u.name,t==null?void 0:t.name,c==null?void 0:c.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var n;const i=We.getMetadata(e),s=(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(i,{in:t});if(a)return[a];if(Se(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,B;const C=We.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const g=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(g!=null&&g.name&&g.name!==u)throw new _s("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new _s(`Conflicting location for parameter ${(B=g.name)!==null&&B!==void 0?B:u}`,{key:"in",values:[t,g.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(s!=null&&s.in&&s.in!==t)throw new _s(`Conflicting location for parameter ${s.name}`,{key:"in",values:[t,s.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=We.getParamMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=!We.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:s},i?We.buildParameterMetadata(i):{})}generateParameter(e){var t;const n=We.getMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=i==null?void 0:i.name,a=i==null?void 0:i.in;if(!s)throw new Mo({missingField:"name"});if(!a)throw new Mo({missingField:"in",paramName:s});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:s})}generateSchemaWithMetadata(e){var t;const n=We.unwrapChained(e),i=We.getMetadata(e),s=We.getDefaultValue(e),a=!((t=i==null?void 0:i.metadata)===null||t===void 0)&&t.type?{type:i==null?void 0:i.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),s);return i!=null&&i.metadata?We.applySchemaMetadata(a,i.metadata):ji(a,Rs)}constructReferencedOpenAPISchema(e){var t;const n=We.getMetadata(e),i=We.unwrapChained(e),s=We.getDefaultValue(e),a=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,a):this.toOpenAPISchema(i,a,s)}generateSimpleSchema(e){var t;const n=We.getMetadata(e),i=We.getRefId(e);if(!i||!this.schemaRefs[i])return this.generateSchemaWithMetadata(e);const s=this.schemaRefs[i],a={$ref:this.generateSchemaRef(i)},o=ji(We.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||yl(f,s[m]));if(o.type)return{allOf:[a,o]};const c=ji(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||yl(f,s[m])),u=We.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=We.getRefId(e),n=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=As(e,["content"]),i=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:i})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),i=this.cleanParameter(e.params),s=this.cleanParameter(e.cookies),a=ws(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=ws(()=>i?this.generateInlineParameters(i,"path"):[],{location:"path"}),c=ws(()=>s?this.generateInlineParameters(s,"cookie"):[],{location:"cookie"}),u=ws(()=>{if(Array.isArray(t))return t.flatMap(m=>this.generateInlineParameters(m,"header"));const f=this.cleanParameter(t);return f?this.generateInlineParameters(f,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return Se(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:i,responses:s}=e,a=As(e,["method","path","request","responses"]),o=Ps(s,m=>this.getResponse(m)),c=ws(()=>this.getParameters(i),{route:`${t} ${n}`}),u=this.getRequestBody(i==null?void 0:i.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},a),c.length>0?{parameters:[...a.parameters||[],...c]}:{}),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:n}=e,i=As(e,["content","headers"]);const s=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},i),s);const a=Se(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},i),{headers:a}),s)}getResponseHeaders(e){const t=e._def.shape();return Ps(t,i=>this.generateSimpleParameter(i))}getBodyContent(e){return Ps(e,t=>{if(!t||!av(t.schema))return t;const{schema:n}=t,i=As(t,["schema"]),s=this.generateSchemaWithRef(n);return Object.assign({schema:s},i)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,i=>this.generateSchemaWithRef(i),i=>this.generateSchemaRef(i),n)}}class Iv{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=lv(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 Cv{constructor(e){const t=new Iv;this.generator=new km(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class jv{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 Tv(r){return"type"in r&&r.type==="webhook"}class Nv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new jv;this.generator=new km(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(Tv).forEach(n=>this.generateSingleWebhook(n.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 Sm=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Bv=r=>{const{groups:e,path:t}=Rv(r),n=Sm(t);return Pv(n,e)},Rv=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const i=`@${n}`;return e.push([i,t]),i}),{groups:e,path:r}},Pv=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let i=r.length-1;i>=0;i--)if(r[i].includes(n)){r[i]=r[i].replace(n,e[t][1]);break}}return r},bo={},bh=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(bo[r]||(e[2]?bo[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:bo[r]=[r,e[1],!0]),bo[r]):null},Am=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},$v=r=>Am(r,decodeURI),Om=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const i=e.charCodeAt(n);if(i===37){const s=e.indexOf("?",n),a=e.slice(t,s===-1?void 0:s);return $v(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(i===63)break}return e.slice(t,n)},Dv=r=>{const e=Om(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},nn=(...r)=>{let e="",t=!1;for(let n of r)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),n[0]!=="/"&&(n=`/${n}`),n==="/"&&t?e=`${e}/`:n!=="/"&&(e=`${e}${n}`),n==="/"&&e===""&&(e="/");return e},Em=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(i=>{if(i!==""&&!/\:/.test(i))n+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){t.length===0&&n===""?t.push("/"):t.push(n);const s=i.replace("?","");n+="/"+s,t.push(n)}else n+="/"+i}),t.filter((i,s,a)=>a.indexOf(i)===s)},Qu=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?af(r):r):r,Im=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let a=r.indexOf(`?${e}`,8);for(a===-1&&(a=r.indexOf(`&${e}`,8));a!==-1;){const o=r.charCodeAt(a+e.length+1);if(o===61){const c=a+e.length+2,u=r.indexOf("&",c);return Qu(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";a=r.indexOf(`&${e}`,a+1)}if(n=/[%+]/.test(r),!n)return}const i={};n??(n=/[%+]/.test(r));let s=r.indexOf("?",8);for(;s!==-1;){const a=r.indexOf("&",s+1);let o=r.indexOf("=",s);o>a&&a!==-1&&(o=-1);let c=r.slice(s+1,o===-1?a===-1?void 0:a:o);if(n&&(c=Qu(c)),s=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=Qu(u))),t?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(u)):i[c]??(i[c]=u)}return e?i[e]:i},Zv=Im,Mv=(r,e)=>Im(r,e,!0),af=decodeURIComponent,Uv=/^[\w!#$%&'*.^`|~+-]+$/,Vv=/^[ !#-:<-[\]-~]*$/,Lv=(r,e)=>{const t=r.trim().split(";"),n={};for(let i of t){i=i.trim();const s=i.indexOf("=");if(s===-1)continue;const a=i.substring(0,s).trim();if(!Uv.test(a))continue;let o=i.substring(s+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Vv.test(o)&&(n[a]=af(o))}return n},qv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Lv(n):{}},ye=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});ne(this,"res");ne(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})}},Hv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),Fv=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Kv=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Wv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,zv=(r,e)=>async(t,n)=>{let i={};const s=t.req.header("Content-Type");switch(r){case"json":if(!s||!Fv.test(s))break;try{i=await t.req.json()}catch{const o="Malformed JSON in request body";throw new ye(400,{message:o})}break;case"form":{if(!s||!(Kv.test(s)||Wv.test(s)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await Hv(u,s),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new ye(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),i=c;break}case"query":i=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":i=t.req.param();break;case"header":i=t.req.header();break;case"cookie":i=qv(t);break}const a=await e(i,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xi=(r,e,t)=>zv(r,async(n,i)=>{const s=await e.safeParseAsync(n);if(t){const a=await t({data:n,...s,target:r},i);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return s.success?s.data:i.json(s,400)});var Gv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,s=(r instanceof Cm?r.raw.headers:r.headers).get("Content-Type");return s!=null&&s.startsWith("multipart/form-data")||s!=null&&s.startsWith("application/x-www-form-urlencoded")?Jv(r,{all:t,dot:n}):{}};async function Jv(r,e){const t=await r.formData();return t?Yv(t,e):{}}function Yv(r,e){const t=Object.create(null);return r.forEach((n,i)=>{e.all||i.endsWith("[]")?Xv(t,i,n):t[i]=n}),e.dot&&Object.entries(t).forEach(([n,i])=>{n.includes(".")&&(Qv(t,n,i),delete t[n])}),t}var Xv=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},Qv=(r,e,t)=>{let n=r;const i=e.split(".");i.forEach((s,a)=>{a===i.length-1?n[s]=t:((!n[s]||typeof n[s]!="object"||Array.isArray(n[s])||n[s]instanceof File)&&(n[s]=Object.create(null)),n=n[s])})},xh=r=>Am(r,af),$i,tr,Xr,jm,Tm,gl,cn,hm,Cm=(hm=class{constructor(r,e="/",t=[[]]){Oe(this,Xr);ne(this,"raw");Oe(this,$i);Oe(this,tr);ne(this,"routeIndex",0);ne(this,"path");ne(this,"bodyCache",{});Oe(this,cn,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const i=Object.keys(e)[0];return i?e[i].then(s=>(i==="json"&&(s=JSON.stringify(s)),new Response(s)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,ue(this,tr,t),ue(this,$i,{})}param(r){return r?Te(this,Xr,jm).call(this,r):Te(this,Xr,Tm).call(this)}query(r){return Zv(this.url,r)}queries(r){return Mv(this.url,r)}header(r){if(r)return this.raw.headers.get(r.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,n)=>{e[n]=t}),e}async parseBody(r){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await Gv(this,r))}json(){return w(this,cn).call(this,"json")}text(){return w(this,cn).call(this,"text")}arrayBuffer(){return w(this,cn).call(this,"arrayBuffer")}blob(){return w(this,cn).call(this,"blob")}formData(){return w(this,cn).call(this,"formData")}addValidatedData(r,e){w(this,$i)[r]=e}valid(r){return w(this,$i)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return w(this,tr)[0].map(([[,r]])=>r)}get routePath(){return w(this,tr)[0].map(([[,r]])=>r)[this.routeIndex].path}},$i=new WeakMap,tr=new WeakMap,Xr=new WeakSet,jm=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=Te(this,Xr,gl).call(this,e);return t?/\%/.test(t)?xh(t):t:void 0},Tm=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=Te(this,Xr,gl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?xh(n):n)}return r},gl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,hm),eb={Stringify:1,BeforeStream:2,Stream:3},Nm=async(r,e,t,n,i)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const s=r.callbacks;return s!=null&&s.length?(i?i[0]+=r:i=[r],Promise.all(s.map(o=>o({phase:e,buffer:i,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Nm(c,e,!1,n,i))).then(()=>i[0]))):Promise.resolve(r)},tb="text/plain; charset=UTF-8",el=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Dr,Ka,Di,Zi,Wa,za,Ot,Vt,pm,Bm=(pm=class{constructor(r,e){Oe(this,Ot);Oe(this,Ha);Oe(this,Fa);ne(this,"env",{});Oe(this,Pr);ne(this,"finalized",!1);ne(this,"error");Oe(this,qn,200);Oe(this,$r);Oe(this,Ge);Oe(this,Qe);Oe(this,br);Oe(this,Dr,!0);Oe(this,Ka);Oe(this,Di);Oe(this,Zi);Oe(this,Wa);Oe(this,za);ne(this,"render",(...r)=>(w(this,Di)??ue(this,Di,e=>this.html(e)),w(this,Di).call(this,...r)));ne(this,"setLayout",r=>ue(this,Ka,r));ne(this,"getLayout",()=>w(this,Ka));ne(this,"setRenderer",r=>{ue(this,Di,r)});ne(this,"header",(r,e,t)=>{if(e===void 0){w(this,Ge)?w(this,Ge).delete(r):w(this,Qe)&&delete w(this,Qe)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(w(this,Ge)||(ue(this,Dr,!1),ue(this,Ge,new Headers(w(this,Qe))),ue(this,Qe,{})),w(this,Ge).append(r,e)):w(this,Ge)?w(this,Ge).set(r,e):(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});ne(this,"status",r=>{ue(this,Dr,!1),ue(this,qn,r)});ne(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});ne(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);ne(this,"newResponse",(...r)=>Te(this,Ot,Vt).call(this,...r));ne(this,"body",(r,e,t)=>typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e));ne(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Dr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=tb,typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)});ne(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)});ne(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Nm(r,eb.Stringify,!1,{}).then(n=>typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)):typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)));ne(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));ne(this,"notFound",()=>(w(this,Zi)??ue(this,Zi,()=>new Response),w(this,Zi).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Zi,e.notFoundHandler),ue(this,za,e.path),ue(this,Wa,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Cm(w(this,Ha),w(this,za),w(this,Wa))),w(this,Fa)}get event(){if(w(this,$r)&&"respondWith"in w(this,$r))return w(this,$r);throw Error("This context has no FetchEvent")}get executionCtx(){if(w(this,$r))return w(this,$r);throw Error("This context has no ExecutionContext")}get res(){return ue(this,Dr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Dr,!1),w(this,br)&&r)try{for(const[e,t]of w(this,br).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=w(this,br).headers.getSetCookie();r.headers.delete("set-cookie");for(const i of n)r.headers.append("set-cookie",i)}else r.headers.set(e,t)}catch(e){if(e instanceof TypeError&&e.message.includes("immutable")){this.res=new Response(r.body,{headers:r.headers,status:r.status});return}else throw e}ue(this,br,r),this.finalized=!0}get var(){return w(this,Pr)?Object.fromEntries(w(this,Pr)):{}}},Ha=new WeakMap,Fa=new WeakMap,Pr=new WeakMap,qn=new WeakMap,$r=new WeakMap,Ge=new WeakMap,Qe=new WeakMap,br=new WeakMap,Dr=new WeakMap,Ka=new WeakMap,Di=new WeakMap,Zi=new WeakMap,Wa=new WeakMap,za=new WeakMap,Ot=new WeakSet,Vt=function(r,e,t){if(w(this,Dr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const i=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?i.append(o,a):i.set(o,a)});const s=el(i,w(this,Qe));return new Response(r,{headers:s,status:e.status??w(this,qn)})}const n=typeof e=="number"?e:w(this,qn);w(this,Qe)??ue(this,Qe,{}),w(this,Ge)??ue(this,Ge,new Headers),el(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((i,s)=>{var a,o;s==="set-cookie"?(a=w(this,Ge))==null||a.append(s,i):(o=w(this,Ge))==null||o.set(s,i)}),el(w(this,Ge),w(this,Qe))),t??(t={});for(const[i,s]of Object.entries(t))if(typeof s=="string")w(this,Ge).set(i,s);else{w(this,Ge).delete(i);for(const a of s)w(this,Ge).append(i,a)}return new Response(r,{status:n,headers:w(this,Ge)})},pm),_h=(r,e,t)=>(n,i)=>{let s=-1;const a=n instanceof Bm;return o(0);async function o(c){if(c<=s)throw new Error("next() called multiple times");s=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&i||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(B){if(B instanceof Error&&a&&e)n.error=B,u=await e(B,n),f=!0;else throw B}return u&&(n.finalized===!1||f)&&(n.res=u),n}},it="ALL",rb="all",nb=["get","post","put","delete","options","patch"],Rm="Can not add a route since the matcher is already built.",Pm=class extends Error{},ib=Symbol("composedHandler"),sb=r=>r.text("404 Not Found",404),wh=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,st,Dm,Zr,Pn,Ao,Oo,mm,$m=(mm=class{constructor(e={}){Oe(this,st);ne(this,"get");ne(this,"post");ne(this,"put");ne(this,"delete");ne(this,"options");ne(this,"patch");ne(this,"all");ne(this,"on");ne(this,"use");ne(this,"router");ne(this,"getPath");ne(this,"_basePath","/");Oe(this,rr,"/");ne(this,"routes",[]);Oe(this,Zr,sb);ne(this,"errorHandler",wh);ne(this,"onError",e=>(this.errorHandler=e,this));ne(this,"notFound",e=>(ue(this,Zr,e),this));ne(this,"fetch",(e,...t)=>Te(this,st,Oo).call(this,e,t[1],t[0],e.method));ne(this,"request",(e,t,n,i)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,i):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${nn("/",e)}`,t),n,i)));ne(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Te(this,st,Oo).call(this,e.request,e,void 0,e.request.method))})});[...nb,rb].forEach(i=>{this[i]=(s,...a)=>(typeof s=="string"?ue(this,rr,s):Te(this,st,Pn).call(this,i,w(this,rr),s),a.forEach(o=>{Te(this,st,Pn).call(this,i,w(this,rr),o)}),this)}),this.on=(i,s,...a)=>{for(const o of[s].flat()){ue(this,rr,o);for(const c of[i].flat())a.map(u=>{Te(this,st,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(i,...s)=>(typeof i=="string"?ue(this,rr,i):(ue(this,rr,"*"),s.unshift(i)),s.forEach(a=>{Te(this,st,Pn).call(this,it,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Om:Dv}route(e,t){const n=this.basePath(e);return t.routes.map(i=>{var a;let s;t.errorHandler===wh?s=i.handler:(s=async(o,c)=>(await _h([],t.errorHandler)(o,()=>i.handler(o,c))).res,s[ib]=i.handler),Te(a=n,st,Pn).call(a,i.method,i.path,s)}),this}basePath(e){const t=Te(this,st,Dm).call(this);return t._basePath=nn(this._basePath,e),t}mount(e,t,n){let i,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,i=n.replaceRequest));const a=s?c=>{const u=s(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};i||(i=(()=>{const c=nn(this._basePath,e),u=c==="/"?0:c.length;return f=>{const m=new URL(f.url);return m.pathname=m.pathname.slice(u)||"/",new Request(m,f)}})());const o=async(c,u)=>{const f=await t(i(c.req.raw),...a(c));if(f)return f;await u()};return Te(this,st,Pn).call(this,it,nn(e,"*"),o),this}},rr=new WeakMap,st=new WeakSet,Dm=function(){const e=new $m({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Zr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const i={path:t,method:e,handler:n};this.router.add(e,t,[n,i]),this.routes.push(i)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,i){if(i==="HEAD")return(async()=>new Response(null,await Te(this,st,Oo).call(this,e,t,n,"GET")))();const s=this.getPath(e,{env:n}),a=this.router.match(i,s),o=new Bm(e,{path:s,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Zr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Zr).call(this,o)})}catch(f){return Te(this,st,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Zr).call(this,o))).catch(f=>Te(this,st,Ao).call(this,f,o)):u??w(this,Zr).call(this,o)}const c=_h(a[0],this.errorHandler,w(this,Zr));return(async()=>{try{const u=await c(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 Te(this,st,Ao).call(this,u,o)}})()},mm),Uo="[^/]+",$s=".*",Ds="(?:|/.*)",Os=Symbol(),ab=new Set(".\\+*[^]$()");function ob(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$s||r===Ds?1:e===$s||e===Ds?-1:r===Uo?1:e===Uo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,ym,vl=(ym=class{constructor(){Oe(this,Hn);Oe(this,Fn);Oe(this,nr,Object.create(null))}insert(e,t,n,i,s){if(e.length===0){if(w(this,Hn)!==void 0)throw Os;if(s)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$s]:["","",Uo]:a==="/*"?["","",Ds]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Uo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Os;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(B=>B!==$s&&B!==Ds))throw Os;if(s)return;u=w(this,nr)[m]=new vl,f!==""&&ue(u,Fn,i.varIndex++)}!s&&f!==""&&n.push([f,w(u,Fn)])}else if(u=w(this,nr)[a],!u){if(Object.keys(w(this,nr)).some(f=>f.length>1&&f!==$s&&f!==Ds))throw Os;if(s)return;u=w(this,nr)[a]=new vl}u.insert(o,t,n,i,s)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(ob).map(n=>{const i=w(this,nr)[n];return(typeof w(i,Fn)=="number"?`(${n})@${w(i,Fn)}`:ab.has(n)?`\\${n}`:n)+i.buildRegExpStr()});return typeof w(this,Hn)=="number"&&t.unshift(`#${w(this,Hn)}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},Hn=new WeakMap,Fn=new WeakMap,nr=new WeakMap,ym),eu,Ga,gm,cb=(gm=class{constructor(){Oe(this,eu,{varIndex:0});Oe(this,Ga,new vl)}insert(r,e,t){const n=[],i=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return i[a]=[u,c],a++,o=!0,u}),!o)break}const s=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=i.length-1;a>=0;a--){const[o]=i[a];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(o)!==-1){s[c]=s[c].replace(o,i[a][1]);break}}return w(this,Ga).insert(s,e,n,w(this,eu),t),n}buildRegExp(){let r=w(this,Ga).buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,s,a)=>s!==void 0?(t[++e]=Number(s),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},eu=new WeakMap,Ga=new WeakMap,gm),Zm=[],ub=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Mm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function lb(){Eo=Object.create(null)}function db(r){var u;const e=new cb,t=[];if(r.length===0)return ub;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[B,C])=>f?1:B?-1:m.length-C.length),i=Object.create(null);for(let f=0,m=-1,B=n.length;f<B;f++){const[C,p,g]=n[f];C?i[p]=[g.map(([O])=>[O,Object.create(null)]),Zm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Os?new Pm(p):O}C||(t[m]=g.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[xe,Le]=A[P];N[xe]=Le}return[O,N]}))}const[s,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let B=0,C=t[f].length;B<C;B++){const p=(u=t[f][B])==null?void 0:u[1];if(!p)continue;const g=Object.keys(p);for(let A=0,O=g.length;A<O;A++)p[g[A]]=o[p[g[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[s,c,i]}function _i(r,e){if(r){for(const t of Object.keys(r).sort((n,i)=>i.length-n.length))if(Mm(t).test(e))return[...r[t]]}}var un,ln,os,Um,Vm,vm,fb=(vm=class{constructor(){Oe(this,os);ne(this,"name","RegExpRouter");Oe(this,un);Oe(this,ln);ue(this,un,{[it]:Object.create(null)}),ue(this,ln,{[it]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),i=w(this,ln);if(!n||!i)throw new Error(Rm);n[r]||[n,i].forEach(c=>{c[r]=Object.create(null),Object.keys(c[it]).forEach(u=>{c[r][u]=[...c[it][u]]})}),e==="/*"&&(e="*");const s=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Mm(e);r===it?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_i(n[u],e)||_i(n[it],e)||[])}):(o=n[r])[e]||(o[e]=_i(n[r],e)||_i(n[it],e)||[]),Object.keys(n).forEach(u=>{(r===it||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,s])})}),Object.keys(i).forEach(u=>{(r===it||r===u)&&Object.keys(i[u]).forEach(f=>c.test(f)&&i[u][f].push([t,s]))});return}const a=Em(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(i).forEach(m=>{var B;(r===it||r===m)&&((B=i[m])[f]||(B[f]=[..._i(n[m],f)||_i(n[it],f)||[]]),i[m][f].push([t,s-u+c+1]))})}}match(r,e){lb();const t=Te(this,os,Um).call(this);return this.match=(n,i)=>{const s=t[n]||t[it],a=s[2][i];if(a)return a;const o=i.match(s[0]);if(!o)return[[],Zm];const c=o.indexOf("",1);return[s[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,os=new WeakSet,Um=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=Te(this,os,Vm).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},Vm=function(r){const e=[];let t=r===it;return[w(this,un),w(this,ln)].forEach(n=>{const i=n[r]?Object.keys(n[r]).map(s=>[s,n[r][s]]):[];i.length!==0?(t||(t=!0),e.push(...i)):r!==it&&e.push(...Object.keys(n[it]).map(s=>[s,n[it][s]]))}),t?db(e):null},vm),dn,Mr,bm,hb=(bm=class{constructor(r){ne(this,"name","SmartRouter");Oe(this,dn,[]);Oe(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(Rm);w(this,Mr).push([r,e,t])}match(r,e){if(!w(this,Mr))throw new Error("Fatal error");const t=w(this,dn),n=w(this,Mr),i=t.length;let s=0,a;for(;s<i;s++){const o=t[s];try{for(let c=0,u=n.length;c<u;c++)o.add(...n[c]);a=o.match(r,e)}catch(c){if(c instanceof Pm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(s===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(w(this,Mr)||w(this,dn).length!==1)throw new Error("No active router has been determined yet.");return w(this,dn)[0]}},dn=new WeakMap,Mr=new WeakMap,bm),fn,bt,Kn,Mi,Et,Ur,$n,xm,Lm=(xm=class{constructor(r,e,t){Oe(this,Ur);Oe(this,fn);Oe(this,bt);Oe(this,Kn);Oe(this,Mi,0);Oe(this,Et,Object.create(null));if(ue(this,bt,t||Object.create(null)),ue(this,fn,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},ue(this,fn,[n])}ue(this,Kn,[])}insert(r,e,t){ue(this,Mi,++gh(this,Mi)._);let n=this;const i=Bv(e),s=[];for(let c=0,u=i.length;c<u;c++){const f=i[c];if(Object.keys(w(n,bt)).includes(f)){n=w(n,bt)[f];const B=bh(f);B&&s.push(B[1]);continue}w(n,bt)[f]=new Lm;const m=bh(f);m&&(w(n,Kn).push(m),s.push(m[1])),n=w(n,bt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:s.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Mi)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Et,Object.create(null));let i=[this];const s=Sm(e);for(let o=0,c=s.length;o<c;o++){const u=s[o],f=o===c-1,m=[];for(let B=0,C=i.length;B<C;B++){const p=i[B],g=w(p,bt)[u];g&&(ue(g,Et,w(p,Et)),f?(w(g,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(g,bt)["*"],r,w(p,Et),Object.create(null))),t.push(...Te(this,Ur,$n).call(this,g,r,w(p,Et),Object.create(null)))):m.push(g));for(let A=0,O=w(p,Kn).length;A<O;A++){const P=w(p,Kn)[A],N={...w(p,Et)};if(P==="*"){const mt=w(p,bt)["*"];mt&&(t.push(...Te(this,Ur,$n).call(this,mt,r,w(p,Et),Object.create(null))),m.push(mt));continue}if(u==="")continue;const[xe,Le,qe]=P,Ze=w(p,bt)[xe],tt=s.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...Te(this,Ur,$n).call(this,Ze,r,w(p,Et),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...Te(this,Ur,$n).call(this,Ze,r,N,w(p,Et))),w(Ze,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(Ze,bt)["*"],r,N,w(p,Et)))):(ue(Ze,Et,N),m.push(Ze)))}}i=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,bt=new WeakMap,Kn=new WeakMap,Mi=new WeakMap,Et=new WeakMap,Ur=new WeakSet,$n=function(r,e,t,n){const i=[];for(let s=0,a=w(r,fn).length;s<a;s++){const o=w(r,fn)[s],c=o[e]||o[it],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const B=c.possibleKeys[f],C=u[c.score];c.params[B]=n[B]&&!C?n[B]:t[B]??n[B],u[c.score]=!0}i.push(c)}}return i},xm),Wn,_m,pb=(_m=class{constructor(){ne(this,"name","TrieRouter");Oe(this,Wn);ue(this,Wn,new Lm)}add(r,e,t){const n=Em(e);if(n){for(let i=0,s=n.length;i<s;i++)w(this,Wn).insert(r,n[i],t);return}w(this,Wn).insert(r,e,t)}match(r,e){return w(this,Wn).search(r,e)}},Wn=new WeakMap,_m),mb=class extends $m{constructor(r={}){super(r),this.router=r.router??new hb({routers:[new fb,new pb]})}},Re;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Re||(Re={}));var bl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(bl||(bl={}));const z=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),sn=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},D=Re.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"]),yb=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class qm extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof qm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Ui=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Re.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Re.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case D.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,Re.assertNever(r)}return{message:t}};let Hm=Ui;function gb(r){Hm=r}function Vo(){return Hm}const Lo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},vb=[];function H(r,e){const t=Vo(),n=Lo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ui?void 0:Ui].filter(i=>!!i)});r.common.issues.push(n)}let jt=class Fm{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return Fm.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Oi=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),xl=r=>r.status==="aborted",_l=r=>r.status==="dirty",Ls=r=>r.status==="valid",qs=r=>typeof Promise<"u"&&r instanceof Promise;function qo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Km(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Es,Is;let Sr=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 kh=(r,e)=>{if(Ls(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new or(r.common.issues);return this._error=t,this._error}}};function _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:i}}let Ae=class{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 sn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new jt,ctx:{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qs(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return kh(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(qs(i)?i:Promise.resolve(i));return kh(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:D.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new dr({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qn.create(this,this._def)}promise(){return qi.create(this,this._def)}or(e){return Js.create([this,e],this._def)}and(e){return Ys.create(this,e,this._def)}transform(e){return new dr({..._e(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({..._e(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new of({typeName:de.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({..._e(this._def),innerType:this,catchValue:t,typeName:de.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return cf.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const bb=/^c[^\s-]{8,}$/i,xb=/^[0-9a-z]+$/,_b=/^[0-9A-HJKMNP-TV-Z]{26}$/,wb=/^[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,kb=/^[a-z0-9_-]{21}$/i,Sb=/^[-+]?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)?)??$/,Ab=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ob="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tl;const Eb=/^(?:(?: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])$/,Ib=/^(([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})))$/,Cb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wm="((\\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])))",jb=new RegExp(`^${Wm}$`);function zm(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Tb(r){return new RegExp(`^${zm(r)}$`)}function Gm(r){let e=`${Wm}T${zm(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Nb(r,e){return!!((e==="v4"||!e)&&Eb.test(r)||(e==="v6"||!e)&&Ib.test(r))}let Vi=class Cs extends Ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.string,received:s.parsedType}),pe}const n=new jt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Ab.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"email",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")tl||(tl=new RegExp(Ob,"u")),tl.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"emoji",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")wb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"uuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")kb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"nanoid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")bb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")xb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid2",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")_b.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ulid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),H(i,{validation:"url",code:D.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"regex",code:D.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.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)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Gm(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?jb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Tb(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Sb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"duration",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Nb(e.data,s.version)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ip",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Cb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"base64",code:D.invalid_string,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:D.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Cs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ae.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ae.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,...ae.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ae.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ae.errToObj(t)})}nonempty(e){return this.min(1,ae.errToObj(e))}trim(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Cs({...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}};Vi.create=r=>{var e;return new Vi({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function Bb(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}let Hs=class wl extends Ae{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)!==z.number){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.number,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Bb(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_finite,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new wl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new wl({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ae.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ae.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"&&Re.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Hs.create=r=>new Hs({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Fs=class kl extends Ae{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)!==z.bigint){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.bigint,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new kl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new kl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.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}};Fs.create=r=>{var e;return new Fs({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};let Ks=class extends Ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return _t(e.data)}};Ks.create=r=>new Ks({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Ws=class Jm extends Ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.date,received:s.parsedType}),pe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_date}),pe}const n=new jt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Re.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Jm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.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}};Ws.create=r=>new Ws({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,..._e(r)});let Ho=class extends Ae{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return _t(e.data)}};Ho.create=r=>new Ho({typeName:de.ZodSymbol,..._e(r)});let zs=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return _t(e.data)}};zs.create=r=>new zs({typeName:de.ZodUndefined,..._e(r)});let Gs=class extends Ae{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.null,received:n.parsedType}),pe}return _t(e.data)}};Gs.create=r=>new Gs({typeName:de.ZodNull,..._e(r)});let Li=class extends Ae{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}};Li.create=r=>new Li({typeName:de.ZodAny,..._e(r)});let zn=class extends Ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,..._e(r)});let Hr=class extends Ae{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,..._e(r)});let Fo=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.void,received:n.parsedType}),pe}return _t(e.data)}};Fo.create=r=>new Fo({typeName:de.ZodVoid,..._e(r)});let Qn=class Io extends Ae{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==z.array)return H(t,{code:D.invalid_type,expected:z.array,received:t.parsedType}),pe;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(H(t,{code:a?D.too_big:D.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(H(t,{code:D.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(H(t,{code:D.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>jt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Sr(t,a,t.path,o)));return jt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Io({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new Io({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new Io({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Qn.create=(r,e)=>new Qn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,..._e(e)});function ki(r){if(r instanceof Kt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ki(n))}return new Kt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ki(r.element)}):r instanceof xr?xr.create(ki(r.unwrap())):r instanceof vn?vn.create(ki(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ki(e))):r}let Kt=class Xt extends Ae{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=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:D.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],m=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(i,m,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Hr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(H(i,{code:D.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(i,m,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,B=await f.value;u.push({key:m,value:B,alwaysSet:f.alwaysSet})}return u}).then(u=>jt.mergeObjectSync(n,u)):jt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:de.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return Re.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return ki(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof xr;)s=s._def.innerType;t[n]=s}}),new Xt({...this._def,shape:()=>t})}keyof(){return ry(Re.objectKeys(this.shape))}};Kt.create=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.strictCreate=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.lazycreate=(r,e)=>new Kt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});let Js=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new or(o.ctx.common.issues));return H(t,{code:D.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new or(c));return H(t,{code:D.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Js.create=(r,e)=>new Js({options:r,typeName:de.ZodUnion,..._e(e)});const Br=r=>r instanceof Xs?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qs?[r.value]:r instanceof Ja?r.options:r instanceof ea?Re.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zs?[void 0]:r instanceof Gs?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof of||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Ym=class Xm extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:D.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=Br(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new Xm({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,..._e(n)})}};function Sl(r,e){const t=sn(r),n=sn(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&n===z.object){const i=Re.objectKeys(e),s=Re.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Sl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===z.array&&n===z.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Sl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Ys=class extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(xl(s)||xl(a))return pe;const o=Sl(s.value,a.value);return o.valid?((_l(s)||_l(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:D.invalid_intersection_types}),pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ys.create=(r,e,t)=>new Ys({left:r,right:e,typeName:de.ZodIntersection,..._e(t)});let gn=class Qm extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:D.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>jt.mergeArray(t,a)):jt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qm({...this._def,rest:e})}};gn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gn({items:r,typeName:de.ZodTuple,rest:null,..._e(e)})};let ey=class Al extends Ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return H(n,{code:D.invalid_type,expected:z.object,received:n.parsedType}),pe;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Sr(n,o,n.path,o)),value:a._parse(new Sr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?jt.mergeObjectAsync(t,i):jt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ae?new Al({keyType:e,valueType:t,typeName:de.ZodRecord,..._e(n)}):new Al({keyType:Vi.create(),valueType:e,typeName:de.ZodRecord,..._e(t)})}},Ko=class extends Ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return H(n,{code:D.invalid_type,expected:z.map,received:n.parsedType}),pe;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Sr(n,o,n.path,[u,"key"])),value:s._parse(new Sr(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};Ko.create=(r,e,t)=>new Ko({valueType:e,keyType:r,typeName:de.ZodMap,..._e(t)});let Wo=class Ol extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:D.invalid_type,expected:z.set,received:n.parsedType}),pe;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(H(n,{code:D.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(H(n,{code:D.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Ol({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Ol({...this._def,maxSize:{value:e,message:ae.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Wo.create=(r,e)=>new Wo({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,..._e(e)});let ty=class Co extends Ae{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:D.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function i(o,c){return Lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qi){const o=this;return _t(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,s).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(C=>{throw u.addIssue(i(m,C)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new or([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Co({...this._def,args:gn.create(e).rest(zn.create())})}returns(e){return new Co({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Co({args:e||gn.create([]).rest(zn.create()),returns:t||zn.create(),typeName:de.ZodFunction,..._e(n)})}},Xs=class extends Ae{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})}};Xs.create=(r,e)=>new Xs({getter:r,typeName:de.ZodLazy,..._e(e)});let Qs=class extends Ae{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qs.create=(r,e)=>new Qs({value:r,typeName:de.ZodLiteral,..._e(e)});function ry(r,e){return new Ja({values:r,typeName:de.ZodEnum,..._e(e)})}let Ja=class El extends Ae{constructor(){super(...arguments),Es.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Re.joinValues(n),received:t.parsedType,code:D.invalid_type}),pe}if(qo(this,Es)||Km(this,Es,new Set(this._def.values)),!qo(this,Es).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:D.invalid_enum_value,options:n}),pe}return _t(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 El.create(e,{...this._def,...t})}exclude(e,t=this._def){return El.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Es=new WeakMap;Ja.create=ry;let ea=class extends Ae{constructor(){super(...arguments),Is.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){const i=Re.objectValues(t);return H(n,{expected:Re.joinValues(i),received:n.parsedType,code:D.invalid_type}),pe}if(qo(this,Is)||Km(this,Is,new Set(Re.getValidEnumValues(this._def.values))),!qo(this,Is).has(e.data)){const i=Re.objectValues(t);return H(n,{received:n.data,code:D.invalid_enum_value,options:i}),pe}return _t(e.data)}get enum(){return this._def.values}};Is=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,..._e(e)});let qi=class extends Ae{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return H(t,{code:D.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return _t(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qi.create=(r,e)=>new qi({type:r,typeName:de.ZodPromise,..._e(e)});let dr=class extends Ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return pe;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?pe:c.status==="dirty"||t.value==="dirty"?Oi(c.value):c});{if(t.value==="aborted")return pe;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?pe:o.status==="dirty"||t.value==="dirty"?Oi(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ls(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Ls(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Re.assertNever(i)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,..._e(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,..._e(t)});let xr=class extends Ae{_parse(e){return this._getType(e)===z.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,..._e(e)});let vn=class extends Ae{_parse(e){return this._getType(e)===z.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,..._e(e)});let ta=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ta.create=(r,e)=>new ta({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});let ra=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qs(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ra.create=(r,e)=>new ra({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});let zo=class extends Ae{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};zo.create=r=>new zo({typeName:de.ZodNaN,..._e(r)});const Rb=Symbol("zod_brand");let of=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},cf=class ny extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),Oi(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new ny({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Ae{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Ls(i)&&(i.value=Object.freeze(i.value)),i);return qs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,..._e(e)});function iy(r,e={},t){return r?Li.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Li.create()}const Pb={object:Kt.lazycreate};var de;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(de||(de={}));const $b=(r,e={message:`Input not instance of ${r.name}`})=>iy(t=>t instanceof r,e),sy=Vi.create,ay=Hs.create,Db=zo.create,Zb=Fs.create,oy=Ks.create,Mb=Ws.create,Ub=Ho.create,Vb=zs.create,Lb=Gs.create,qb=Li.create,Hb=zn.create,Fb=Hr.create,Kb=Fo.create,Wb=Qn.create,zb=Kt.create,Gb=Kt.strictCreate,Jb=Js.create,Yb=Ym.create,Xb=Ys.create,Qb=gn.create,ex=ey.create,tx=Ko.create,rx=Wo.create,nx=ty.create,ix=Xs.create,sx=Qs.create,ax=Ja.create,ox=ea.create,cx=qi.create,Sh=dr.create,ux=xr.create,lx=vn.create,dx=dr.createWithPreprocess,fx=cf.create,hx=()=>sy().optional(),px=()=>ay().optional(),mx=()=>oy().optional(),yx={string:r=>Vi.create({...r,coerce:!0}),number:r=>Hs.create({...r,coerce:!0}),boolean:r=>Ks.create({...r,coerce:!0}),bigint:r=>Fs.create({...r,coerce:!0}),date:r=>Ws.create({...r,coerce:!0})},gx=pe;var y=Object.freeze({__proto__:null,defaultErrorMap:Ui,setErrorMap:gb,getErrorMap:Vo,makeIssue:Lo,EMPTY_PATH:vb,addIssueToContext:H,ParseStatus:jt,INVALID:pe,DIRTY:Oi,OK:_t,isAborted:xl,isDirty:_l,isValid:Ls,isAsync:qs,get util(){return Re},get objectUtil(){return bl},ZodParsedType:z,getParsedType:sn,ZodType:Ae,datetimeRegex:Gm,ZodString:Vi,ZodNumber:Hs,ZodBigInt:Fs,ZodBoolean:Ks,ZodDate:Ws,ZodSymbol:Ho,ZodUndefined:zs,ZodNull:Gs,ZodAny:Li,ZodUnknown:zn,ZodNever:Hr,ZodVoid:Fo,ZodArray:Qn,ZodObject:Kt,ZodUnion:Js,ZodDiscriminatedUnion:Ym,ZodIntersection:Ys,ZodTuple:gn,ZodRecord:ey,ZodMap:Ko,ZodSet:Wo,ZodFunction:ty,ZodLazy:Xs,ZodLiteral:Qs,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qi,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:zo,BRAND:Rb,ZodBranded:of,ZodPipeline:cf,ZodReadonly:na,custom:iy,Schema:Ae,ZodSchema:Ae,late:Pb,get ZodFirstPartyTypeKind(){return de},coerce:yx,any:qb,array:Wb,bigint:Zb,boolean:oy,date:Mb,discriminatedUnion:Yb,effect:Sh,enum:ax,function:nx,instanceof:$b,intersection:Xb,lazy:ix,literal:sx,map:tx,nan:Db,nativeEnum:ox,never:Fb,null:Lb,nullable:lx,number:ay,object:zb,oboolean:mx,onumber:px,optional:ux,ostring:hx,pipeline:fx,preprocess:dx,promise:cx,record:ex,set:rx,strictObject:Gb,string:sy,symbol:Ub,transformer:Sh,tuple:Qb,undefined:Vb,union:Jb,unknown:Hb,void:Kb,NEVER:gx,ZodIssueCode:D,quotelessJson:yb,ZodError:or}),dt=class Il extends mb{constructor(t){super(t);ne(this,"openAPIRegistry");ne(this,"defaultHook");ne(this,"openapi",({middleware:t,...n},i,s=this.defaultHook)=>{var u,f,m,B,C,p,g,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xi("query",n.request.query,s);a.push(N)}if((f=n.request)!=null&&f.params){const N=xi("param",n.request.params,s);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xi("header",n.request.headers,s);a.push(N)}if((B=n.request)!=null&&B.cookies){const N=xi("cookie",n.request.cookies,s);a.push(N)}const o=(p=(C=n.request)==null?void 0:C.body)==null?void 0:p.content;if(o)for(const N of Object.keys(o)){if(!o[N])continue;const xe=o[N].schema;if(xe instanceof Ae){if(Oh(N)){const Le=xi("json",xe,s);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Oh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(Eh(N)){const Le=xi("form",xe,s);if((P=(O=n.request)==null?void 0:O.body)!=null&&P.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Eh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("form",{}),await tt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,i),this});ne(this,"getOpenAPIDocument",t=>{const i=new Cv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Ah(i,this._basePath):i});ne(this,"getOpenAPI31Document",t=>{const i=new Nv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Ah(i,this._basePath):i});ne(this,"doc",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPIDocument(s);return i.json(a)}catch(a){return i.json(a,500)}}));ne(this,"doc31",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPI31Document(s);return i.json(a)}catch(a){return i.json(a,500)}}));this.openAPIRegistry=new dv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const i=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Il?(n.openAPIRegistry.definitions.forEach(s=>{switch(s.type){case"component":return this.openAPIRegistry.registerComponent(s.componentType,s.name,s.component);case"route":return this.openAPIRegistry.registerPath({...s.route,path:nn(i,s.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...s.webhook,path:nn(i,s.webhook.path)});case"schema":return this.openAPIRegistry.register(s.schema._def.openapi._internal.refId,s.schema);case"parameter":return this.openAPIRegistry.registerParameter(s.schema._def.openapi._internal.refId,s.schema);default:{const a=s;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new Il({...super.basePath(t),defaultHook:this.defaultHook})}},ve=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};ov(y);function Ah(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function Oh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function Eh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function vx(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function bx(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ks(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function xx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=vx(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(bx(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ks(r,"optional"),ks(r,"nullable"),ks(r,"default"),ks(r,"transform"),ks(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var Pe;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Pe||(Pe={}));var Cl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Cl||(Cl={}));const G=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),an=r=>{switch(typeof r){case"undefined":return G.undefined;case"string":return G.string;case"number":return isNaN(r)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(r)?G.array:r===null?G.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?G.promise:typeof Map<"u"&&r instanceof Map?G.map:typeof Set<"u"&&r instanceof Set?G.set:typeof Date<"u"&&r instanceof Date?G.date:G.object;default:return G.unknown}},Z=Pe.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"]),_x=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Dt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const Hi=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Pe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(r)}return{message:t}};let cy=Hi;function wx(r){cy=r}function Go(){return cy}const Jo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},kx=[];function F(r,e){const t=Go(),n=Jo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hi?void 0:Hi].filter(i=>!!i)});r.common.issues.push(n)}class gt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return ge;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return ge;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const ge=Object.freeze({status:"aborted"}),Yo=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),jl=r=>r.status==="aborted",Tl=r=>r.status==="dirty",ia=r=>r.status==="valid",sa=r=>typeof Promise<"u"&&r instanceof Promise;function Xo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function uy(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var js,Ts;class Ar{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 Ih=(r,e)=>{if(ia(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Dt(r.common.issues);return this._error=t,this._error}}};function we(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{var o,c;const{message:u}=r;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:i}}class Ee{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 an(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gt,ctx:{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(sa(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Ih(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(sa(i)?i:Promise.resolve(i));return Ih(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:Z.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new fr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cr.create(this,this._def)}promise(){return Ki.create(this,this._def)}or(e){return ua.create([this,e],this._def)}and(e){return la.create(this,e,this._def)}transform(e){return new fr({...we(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({...we(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new uf({typeName:fe.ZodBranded,type:this,...we(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({...we(this._def),innerType:this,catchValue:t,typeName:fe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ya.create(this,e)}readonly(){return ga.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Sx=/^c[^\s-]{8,}$/i,Ax=/^[0-9a-z]+$/,Ox=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ex=/^[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,Ix=/^[a-z0-9_-]{21}$/i,Cx=/^[-+]?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)?)??$/,jx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let rl;const Nx=/^(?:(?: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])$/,Bx=/^(([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})))$/,Rx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ly="((\\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])))",Px=new RegExp(`^${ly}$`);function dy(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function $x(r){return new RegExp(`^${dy(r)}$`)}function fy(r){let e=`${ly}T${dy(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Dx(r,e){return!!((e==="v4"||!e)&&Nx.test(r)||(e==="v6"||!e)&&Bx.test(r))}class ir extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.string,received:i.parsedType}),ge}const t=new gt;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="length"){const s=e.data.length>i.value,a=e.data.length<i.value;(s||a)&&(n=this._getOrReturnCtx(e,n),s?F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if(i.kind==="email")jx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="emoji")rl||(rl=new RegExp(Tx,"u")),rl.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="uuid")Ex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="nanoid")Ix.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid")Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid2")Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="ulid")Ox.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:Z.invalid_string,message:i.message}),t.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:Z.invalid_string,message:i.message}),t.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty()):i.kind==="datetime"?fy(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"datetime",message:i.message}),t.dirty()):i.kind==="date"?Px.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"date",message:i.message}),t.dirty()):i.kind==="time"?$x(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"time",message:i.message}),t.dirty()):i.kind==="duration"?Cx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="ip"?Dx(e.data,i.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="base64"?Rx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:Z.invalid_string,message:i.message}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Z.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new ir({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...oe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...oe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...oe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...oe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...oe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...oe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...oe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...oe.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...oe.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,...oe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...oe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...oe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...oe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...oe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...oe.errToObj(t)})}nonempty(e){return this.min(1,oe.errToObj(e))}trim(){return new ir({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ir({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ir({...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}}ir.create=r=>{var e;return new ir({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};function Zx(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class bn extends Ee{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)!==G.number){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.number,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Zx(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_finite,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new bn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:oe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:oe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:oe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:oe.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"&&Pe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}bn.create=r=>new bn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class xn extends Ee{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)!==G.bigint){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.bigint,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new xn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.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}}xn.create=r=>{var e;return new xn({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};class aa extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.boolean,received:t.parsedType}),ge}return wt(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class ei extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.date,received:i.parsedType}),ge}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_date}),ge}const t=new gt;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:oe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:oe.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}}ei.create=r=>new ei({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...we(r)});class Qo extends Ee{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.symbol,received:t.parsedType}),ge}return wt(e.data)}}Qo.create=r=>new Qo({typeName:fe.ZodSymbol,...we(r)});class oa extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.undefined,received:t.parsedType}),ge}return wt(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,...we(r)});class ca extends Ee{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.null,received:t.parsedType}),ge}return wt(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,...we(r)});class Fi extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Fi.create=r=>new Fi({typeName:fe.ZodAny,...we(r)});class Gn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,...we(r)});class Fr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.never,received:t.parsedType}),ge}}Fr.create=r=>new Fr({typeName:fe.ZodNever,...we(r)});class ec extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.void,received:t.parsedType}),ge}return wt(e.data)}}ec.create=r=>new ec({typeName:fe.ZodVoid,...we(r)});class cr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==G.array)return F(t,{code:Z.invalid_type,expected:G.array,received:t.parsedType}),ge;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(F(t,{code:a?Z.too_big:Z.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(F(t,{code:Z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(F(t,{code:Z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Ar(t,a,t.path,o)));return gt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new cr({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new cr({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new cr({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}cr.create=(r,e)=>new cr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...we(e)});function Si(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Si(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Si(r.element)}):r instanceof _r?_r.create(Si(r.unwrap())):r instanceof wn?wn.create(Si(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Si(e))):r}class Je extends Ee{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=Pe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const c=this._getOrReturnCtx(e);return F(c,{code:Z.invalid_type,expected:G.object,received:c.parsedType}),ge}const{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)s.includes(c)||a.push(c);const o=[];for(const c of s){const u=i[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ar(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Fr){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")a.length>0&&(F(n,{code:Z.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ar(n,f,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const f=await u.key,m=await u.value;c.push({key:f,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>gt.mergeObjectSync(t,c)):gt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return Pe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return Si(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof _r;)i=i._def.innerType;t[n]=i}}),new Je({...this._def,shape:()=>t})}keyof(){return hy(Pe.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});class ua extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Dt(o.ctx.common.issues));return F(t,{code:Z.invalid_union,unionErrors:a}),ge}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new Dt(c));return F(t,{code:Z.invalid_union,unionErrors:o}),ge}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,...we(e)});const rn=r=>r instanceof fa?rn(r.schema):r instanceof fr?rn(r.innerType()):r instanceof ha?[r.value]:r instanceof _n?r.options:r instanceof pa?Pe.objectValues(r.enum):r instanceof ma?rn(r._def.innerType):r instanceof oa?[void 0]:r instanceof ca?[null]:r instanceof _r?[void 0,...rn(r.unwrap())]:r instanceof wn?[null,...rn(r.unwrap())]:r instanceof uf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class ru extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:Z.invalid_type,expected:G.object,received:t.parsedType}),ge;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ge)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=rn(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new ru({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...we(n)})}}function Nl(r,e){const t=an(r),n=an(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const i=Pe.objectKeys(e),s=Pe.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Nl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Nl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(jl(s)||jl(a))return ge;const o=Nl(s.value,a.value);return o.valid?((Tl(s)||Tl(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:Z.invalid_intersection_types}),ge)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,...we(t)});class Or extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:Z.invalid_type,expected:G.array,received:n.parsedType}),ge;if(n.data.length<this._def.items.length)return F(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ge;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((s,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>gt.mergeArray(t,s)):gt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Or({...this._def,rest:e})}}Or.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Or({items:r,typeName:fe.ZodTuple,rest:null,...we(e)})};class da extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return F(n,{code:Z.invalid_type,expected:G.object,received:n.parsedType}),ge;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?gt.mergeObjectAsync(t,i):gt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,...we(n)}):new da({keyType:ir.create(),valueType:e,typeName:fe.ZodRecord,...we(t)})}}class tc extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return F(n,{code:Z.invalid_type,expected:G.map,received:n.parsedType}),ge;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Ar(n,o,n.path,[u,"key"])),value:s._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}tc.create=(r,e,t)=>new tc({valueType:e,keyType:r,typeName:fe.ZodMap,...we(t)});class ti extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:Z.invalid_type,expected:G.set,received:n.parsedType}),ge;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(F(n,{code:Z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(F(n,{code:Z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ge;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ti({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ti({...this._def,maxSize:{value:e,message:oe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ti.create=(r,e)=>new ti({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...we(e)});class Ti extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:Z.invalid_type,expected:G.function,received:t.parsedType}),ge;function n(o,c){return Jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Go(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function i(o,c){return Jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Go(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ki){const o=this;return wt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,s).catch(B=>{throw u.addIssue(n(c,B)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(B=>{throw u.addIssue(i(m,B)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new Dt([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ti({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ti({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ti({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,...we(n)})}}class fa extends Ee{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})}}fa.create=(r,e)=>new fa({getter:r,typeName:fe.ZodLazy,...we(e)});class ha extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),ge}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,...we(e)});function hy(r,e){return new _n({values:r,typeName:fe.ZodEnum,...we(e)})}class _n extends Ee{constructor(){super(...arguments),js.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Pe.joinValues(n),received:t.parsedType,code:Z.invalid_type}),ge}if(Xo(this,js)||uy(this,js,new Set(this._def.values)),!Xo(this,js).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:Z.invalid_enum_value,options:n}),ge}return wt(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 _n.create(e,{...this._def,...t})}exclude(e,t=this._def){return _n.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}js=new WeakMap;_n.create=hy;class pa extends Ee{constructor(){super(...arguments),Ts.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const i=Pe.objectValues(t);return F(n,{expected:Pe.joinValues(i),received:n.parsedType,code:Z.invalid_type}),ge}if(Xo(this,Ts)||uy(this,Ts,new Set(Pe.getValidEnumValues(this._def.values))),!Xo(this,Ts).has(e.data)){const i=Pe.objectValues(t);return F(n,{received:n.data,code:Z.invalid_enum_value,options:i}),ge}return wt(e.data)}get enum(){return this._def.values}}Ts=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,...we(e)});class Ki extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return F(t,{code:Z.invalid_type,expected:G.promise,received:t.parsedType}),ge;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return wt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ki.create=(r,e)=>new Ki({type:r,typeName:fe.ZodPromise,...we(e)});class fr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ge;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ge:c.status==="dirty"||t.value==="dirty"?Yo(c.value):c});{if(t.value==="aborted")return ge;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ge:o.status==="dirty"||t.value==="dirty"?Yo(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ge:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ge:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ia(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ia(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(i)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,...we(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...we(t)});class _r extends Ee{_parse(e){return this._getType(e)===G.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:fe.ZodOptional,...we(e)});class wn extends Ee{_parse(e){return this._getType(e)===G.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wn.create=(r,e)=>new wn({innerType:r,typeName:fe.ZodNullable,...we(e)});class ma extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ma.create=(r,e)=>new ma({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...we(e)});class ya extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return sa(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ya.create=(r,e)=>new ya({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...we(e)});class rc extends Ee{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.nan,received:t.parsedType}),ge}return{status:"valid",value:e.data}}}rc.create=r=>new rc({typeName:fe.ZodNaN,...we(r)});const Mx=Symbol("zod_brand");class uf extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ya extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),Yo(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=i=>(ia(i)&&(i.value=Object.freeze(i.value)),i);return sa(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,...we(e)});function py(r,e={},t){return r?Fi.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Fi.create()}const Ux={object:Je.lazycreate};var fe;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(fe||(fe={}));const Vx=(r,e={message:`Input not instance of ${r.name}`})=>py(t=>t instanceof r,e),my=ir.create,yy=bn.create,Lx=rc.create,qx=xn.create,gy=aa.create,Hx=ei.create,Fx=Qo.create,Kx=oa.create,Wx=ca.create,zx=Fi.create,Gx=Gn.create,Jx=Fr.create,Yx=ec.create,Xx=cr.create,Qx=Je.create,e_=Je.strictCreate,t_=ua.create,r_=ru.create,n_=la.create,i_=Or.create,s_=da.create,a_=tc.create,o_=ti.create,c_=Ti.create,u_=fa.create,l_=ha.create,d_=_n.create,f_=pa.create,h_=Ki.create,Ch=fr.create,p_=_r.create,m_=wn.create,y_=fr.createWithPreprocess,g_=Ya.create,v_=()=>my().optional(),b_=()=>yy().optional(),x_=()=>gy().optional(),__={string:r=>ir.create({...r,coerce:!0}),number:r=>bn.create({...r,coerce:!0}),boolean:r=>aa.create({...r,coerce:!0}),bigint:r=>xn.create({...r,coerce:!0}),date:r=>ei.create({...r,coerce:!0})},w_=ge;var d=Object.freeze({__proto__:null,defaultErrorMap:Hi,setErrorMap:wx,getErrorMap:Go,makeIssue:Jo,EMPTY_PATH:kx,addIssueToContext:F,ParseStatus:gt,INVALID:ge,DIRTY:Yo,OK:wt,isAborted:jl,isDirty:Tl,isValid:ia,isAsync:sa,get util(){return Pe},get objectUtil(){return Cl},ZodParsedType:G,getParsedType:an,ZodType:Ee,datetimeRegex:fy,ZodString:ir,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:ei,ZodSymbol:Qo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fi,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:ec,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:ru,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:tc,ZodSet:ti,ZodFunction:Ti,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ki,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:rc,BRAND:Mx,ZodBranded:uf,ZodPipeline:Ya,ZodReadonly:ga,custom:py,Schema:Ee,ZodSchema:Ee,late:Ux,get ZodFirstPartyTypeKind(){return fe},coerce:__,any:zx,array:Xx,bigint:qx,boolean:gy,date:Hx,discriminatedUnion:r_,effect:Ch,enum:d_,function:c_,instanceof:Vx,intersection:n_,lazy:u_,literal:l_,map:a_,nan:Lx,nativeEnum:f_,never:Jx,null:Wx,nullable:m_,number:yy,object:Qx,oboolean:x_,onumber:b_,optional:p_,ostring:v_,pipeline:g_,preprocess:y_,promise:h_,record:s_,set:o_,strictObject:e_,string:my,symbol:Fx,transformer:Ch,tuple:i_,undefined:Kx,union:t_,unknown:Gx,void:Yx,NEVER:w_,ZodIssueCode:Z,quotelessJson:_x,ZodError:Dt});xx(d);const jn=d.object({start:d.number(),limit:d.number(),length:d.number()}),lf=d.object({created_at:d.string(),updated_at:d.string()}),vy=d.object({email:d.string().optional(),email_verified:d.boolean().optional(),name:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),phone_number:d.string().optional(),phone_verified:d.boolean().optional(),family_name:d.string().optional()}).catchall(d.any()),by=d.object({connection:d.string(),user_id:d.string(),provider:d.string(),isSocial:d.boolean(),access_token:d.string().optional(),access_token_secret:d.string().optional(),refresh_token:d.string().optional(),profileData:vy.optional()}),nu=d.object({email:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),family_name:d.string().optional(),nickname:d.string().optional(),name:d.string().optional(),picture:d.string().optional(),locale:d.string().optional(),linked_to:d.string().optional(),profileData:d.string().optional(),user_id:d.string().optional(),app_metadata:d.any().default({}).optional(),user_metadata:d.any().default({}).optional()}),nc=nu.extend({email_verified:d.boolean().default(!1),verify_email:d.boolean().optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string().optional(),provider:d.string().default("email"),connection:d.string().default("email")}),df=d.object({...nc.shape,...lf.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(by).optional()}),vr=df,k_=nu.extend({email:d.string(),login_count:d.number(),multifactor:d.array(d.string()).optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string()}).catchall(d.any()),S_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let A_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=S_[t[r]&63];return e};const xy=d.object({audience:d.string().optional(),recipient:d.string().optional(),createUpnClaim:d.boolean().optional(),mapUnknownClaimsAsIs:d.boolean().optional(),passthroughClaimsWithNoMapping:d.boolean().optional(),mapIdentities:d.boolean().optional(),signatureAlgorithm:d.string().optional(),digestAlgorithm:d.string().optional(),issuer:d.string().optional(),destination:d.string().optional(),lifetimeInSeconds:d.number().optional(),signResponse:d.boolean().optional(),nameIdentifierFormat:d.string().optional(),nameIdentifierProbes:d.array(d.string()).optional(),authnContextClassRef:d.string().optional(),mappings:d.record(d.string()).optional()}),ic=d.object({id:d.string(),name:d.string(),callbacks:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:d.array(d.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:d.object({samlp:xy.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:d.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:d.string().default(()=>A_()).optional(),disable_sign_ups:d.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Mn=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...ic.shape});var ff=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(ff||{}),hf=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(hf||{}),pf=(r=>(r.S256="S256",r.Plain="plain",r))(pf||{});const _y=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(ff).optional(),response_mode:d.nativeEnum(hf).optional(),redirect_uri:d.string().optional(),audience:d.string().optional(),state:d.string().optional(),nonce:d.string().optional(),scope:d.string().optional(),prompt:d.string().optional(),code_challenge_method:d.nativeEnum(pf).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),Bl=d.object({colors:d.object({primary:d.string(),page_background:d.object({type:d.string().optional(),start:d.string().optional(),end:d.string().optional(),angle_deg:d.number().optional()}).optional()}).optional(),logo_url:d.string().optional(),favicon_url:d.string().optional(),font:d.object({url:d.string()}).optional()}),sc=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:d.object({kid:d.string().optional(),team_id:d.string().optional(),realms:d.string().optional(),client_id:d.string().optional(),client_secret:d.string().optional(),app_secret:d.string().optional(),scope:d.string().optional(),authorization_endpoint:d.string().default("").optional(),token_endpoint:d.string().default("").optional(),userinfo_endpoint:d.string().default("").optional(),jwks_uri:d.string().default("").optional(),discovery_url:d.string().default("").optional(),issuer:d.string().default("").optional()}).default({}).optional(),enabled_clients:d.array(d.string()).default([]).optional(),response_type:d.custom().optional(),response_mode:d.custom().optional()}),Un=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(sc.shape),ac=d.object({name:d.string(),audience:d.string(),sender_email:d.string().email(),sender_name:d.string(),support_url:d.string().url().optional(),logo:d.string().url().optional(),primary_color:d.string().optional(),secondary_color:d.string().optional(),language:d.string().optional()}),Ni=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...ac.shape}),O_=d.object({logoUrl:d.string(),loginBackgroundImage:d.string().nullish(),style:d.object({primaryColor:d.string(),buttonTextColor:d.string(),primaryHoverColor:d.string()}),supportEmail:d.string().nullable(),supportUrl:d.string().nullable(),name:d.string(),showGreyishBackground:d.boolean().optional(),termsAndConditionsUrl:d.string().nullable(),companyName:d.string().optional(),checkoutHideSocial:d.boolean().optional(),siteUrl:d.string().nullable(),manageSubscriptionsUrl:d.string().optional()}),E_=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.union([d.literal("mailgun"),d.literal("mailchannels")]).optional()});d.object({...Mn.shape,domains:d.array(E_),tenant:Ni,connections:d.array(Un)});const wy=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ky=d.object({code_id:d.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:d.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:d.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:wy,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()}),I_=d.object({...ky.shape,created_at:d.string()}),Sy=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.enum(["mailgun","mailchannels"])}),C_=lf.extend({...Sy.shape,id:d.string()}),oc=d.object({trigger_id:d.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:d.boolean().default(!1),url:d.string(),hook_id:d.string().optional(),synchronous:d.boolean().default(!1),priority:d.number().optional()}),Ei=oc.extend({...lf.shape,hook_id:d.string()}),mf=d.object({alg:d.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:d.string(),kid:d.string(),kty:d.enum(["RSA","EC","oct"]),n:d.string(),x5t:d.string().optional(),x5c:d.array(d.string()).optional(),use:d.enum(["sig","enc"]).optional()}),Ay=d.object({keys:d.array(mf)}),Rl=d.object({issuer:d.string(),authorization_endpoint:d.string(),token_endpoint:d.string(),device_authorization_endpoint:d.string(),userinfo_endpoint:d.string(),mfa_challenge_endpoint:d.string(),jwks_uri:d.string(),registration_endpoint:d.string(),revocation_endpoint:d.string(),scopes_supported:d.array(d.string()),response_types_supported:d.array(d.string()),code_challenge_methods_supported:d.array(d.string()),response_modes_supported:d.array(d.string()),subject_types_supported:d.array(d.string()),id_token_signing_alg_values_supported:d.array(d.string()),token_endpoint_auth_methods_supported:d.array(d.string()),claims_supported:d.array(d.string()),request_uri_parameter_supported:d.boolean(),request_parameter_supported:d.boolean(),token_endpoint_auth_signing_alg_values_supported:d.array(d.string())}),Oy=d.object({auth0Client:d.string().optional(),authParams:_y,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional(),useragent:d.string().optional()}).openapi({description:"This represents a login sesion"}),j_=d.object({...Oy.shape,login_id:d.string().openapi({description:"This is is used as the state in the universal login"}),created_at:d.string(),updated_at:d.string()});var iu=(r=>(r.FAILED_SILENT_AUTH="fsa",r.FAILED_SIGNUP="fs",r.FAILED_LOGIN="f",r.FAILED_LOGIN_INCORRECT_PASSWORD="fp",r.FAILED_CHANGE_PASSWORD="fcp",r.FAILED_BY_CONNECTOR="fc",r.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",r.FAILED_HOOK="fh",r.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",r.SUCCESS_API_OPERATION="sapi",r.SUCCESS_CHANGE_PASSWORD="scp",r.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",r.SUCCESS_CHANGE_USERNAME="scu",r.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",r.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",r.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",r.SUCCESS_LOGIN="s",r.SUCCESS_LOGOUT="slo",r.SUCCESS_SIGNUP="ss",r.SUCCESS_SILENT_AUTH="ssa",r.SUCCESS_VERIFICATION_EMAIL="sv",r.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",r.CODE_LINK_SENT="cls",r))(iu||{});const T_=d.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),Ey=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),cc=d.object({type:T_,date:d.string(),description:d.string().optional(),log_id:d.string().optional(),_id:d.string().optional(),ip:d.string(),user_agent:d.string(),details:d.any().optional(),isMobile:d.boolean(),user_id:d.string().optional(),user_name:d.string().optional(),connection:d.string().optional(),connection_id:d.string().optional(),client_id:d.string().optional(),client_name:d.string().optional(),audience:d.string().optional(),scope:d.array(d.string()).optional(),strategy:d.string().optional(),strategy_type:d.string().optional(),hostname:d.string().optional(),auth0_client:Ey.optional()}),Iy=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")}),N_=d.object({...Iy.shape,created_at:d.string(),updated_at:d.string()}),Cy=d.object({session_id:d.string(),client_id:d.string(),expires_at:d.string(),used_at:d.string(),deleted_at:d.string().optional(),user_id:d.string()}),yf=d.object({created_at:d.string(),...Cy.shape}),Pl=d.object({kid:d.string().openapi({description:"The key id of the signing key"}),cert:d.string().openapi({description:"The public certificate of the signing key"}),fingerprint:d.string().openapi({description:"The cert fingerprint"}),thumbprint:d.string().openapi({description:"The cert thumbprint"}),pkcs7:d.string().optional().openapi({description:"The private key in pkcs7 format"}),current:d.boolean().optional().openapi({description:"True if the key is the current key"}),next:d.boolean().optional().openapi({description:"True if the key is the next key"}),previous:d.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:d.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:d.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:d.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:d.string().optional().openapi({description:"The date and time when the key was revoked"})});var uc=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(uc||{});d.object({access_token:d.string(),id_token:d.string().optional(),scope:d.string().optional(),state:d.string().optional(),refresh_token:d.string().optional(),token_type:d.string(),expires_in:d.number()});d.object({code:d.string(),state:d.string().optional()});const jy=d.object({button_border_radius:d.number(),button_border_weight:d.number(),buttons_style:d.enum(["pill"]),input_border_radius:d.number(),input_border_weight:d.number(),inputs_style:d.enum(["pill"]),show_widget_shadow:d.boolean(),widget_border_weight:d.number(),widget_corner_radius:d.number()}),Ty=d.object({base_focus_color:d.string(),base_hover_color:d.string(),body_text:d.string(),captcha_widget_theme:d.enum(["auto"]),error:d.string(),header:d.string(),icons:d.string(),input_background:d.string(),input_border:d.string(),input_filled_text:d.string(),input_labels_placeholders:d.string(),links_focused_components:d.string(),primary_button:d.string(),primary_button_label:d.string(),secondary_button_border:d.string(),secondary_button_label:d.string(),success:d.string(),widget_background:d.string(),widget_border:d.string()}),Dn=d.object({bold:d.boolean(),size:d.number()}),Ny=d.object({body_text:Dn,buttons_text:Dn,font_url:d.string(),input_labels:Dn,links:Dn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Dn,title:Dn}),By=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Ry=d.object({header_text_alignment:d.enum(["center"]),logo_height:d.number(),logo_position:d.enum(["center"]),logo_url:d.string(),social_buttons_layout:d.enum(["bottom"])}),Py=d.object({borders:jy,colors:Ty,displayName:d.string(),fonts:Ny,page_background:By,widget:Ry}),B_=Py.extend({themeId:d.string()}),jo=d.object({universal_login_experience:d.enum(["new","classic"]).default("new"),identifier_first:d.boolean().default(!0),password_first:d.boolean().default(!1),webauthn_platform_first_factor:d.boolean()}),To=d.object({name:d.string(),enabled:d.boolean().optional().default(!0),default_from_address:d.string().optional(),credentials:d.union([d.object({accessKeyId:d.string(),secretAccessKey:d.string(),region:d.string()}),d.object({smtp_host:d.array(d.string()),smtp_port:d.number(),smtp_user:d.string(),smtp_pass:d.string()}),d.object({api_key:d.string(),domain:d.string().optional()}),d.object({connectionString:d.string()}),d.object({tenantId:d.string(),clientId:d.string(),clientSecret:d.string()})]),settings:d.object({}).optional()});function R_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}const P_=new dt().openapi(ve({tags:["branding"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Bl}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.branding.get(e);return t?r.json(t):r.json({})}).openapi(ve({tags:["branding"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(Bl.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});var lc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function D_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}function Z_(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var $y={exports:{}};const M_={},U_=Object.freeze(Object.defineProperty({__proto__:null,default:M_},Symbol.toStringTag,{value:"Module"})),V_=D_(U_);(function(r){/**
2
2
  * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
3
3
  * Released under the Apache License, Version 2.0
4
4
  * see: https://github.com/dcodeIO/bcrypt.js for details
5
- */(function(e,t){typeof D_=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(uc,function(){var e={},t=null;function n(I){if(r&&r.exports)try{return U_.randomBytes(I)}catch{}try{var E;return(self.crypto||self.msCrypto).getRandomValues(E=new Uint32Array(I)),Array.prototype.slice.call(E)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t(I)}var i=!1;try{n(1),i=!0}catch{}t=null,e.setRandomFallback=function(I){t=I},e.genSaltSync=function(I,E){if(I=I||g,typeof I!="number")throw Error("Illegal arguments: "+typeof I+", "+typeof E);I<4?I=4:I>31&&(I=31);var k=[];return k.push("$2a$"),I<10&&k.push("0"),k.push(I.toString()),k.push("$"),k.push(m(n(p),p)),k.join("")},e.genSalt=function(I,E,k){if(typeof E=="function"&&(k=E,E=void 0),typeof I=="function"&&(k=I,I=void 0),typeof I>"u")I=g;else if(typeof I!="number")throw Error("illegal arguments: "+typeof I);function x(b){a(function(){try{b(null,e.genSaltSync(I))}catch(j){b(j)}})}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);x(k)}else return new Promise(function(b,j){x(function(U,Ce){if(U){j(U);return}b(Ce)})})},e.hashSync=function(I,E){if(typeof E>"u"&&(E=g),typeof E=="number"&&(E=e.genSaltSync(E)),typeof I!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof I+", "+typeof E);return Rt(I,E)},e.hash=function(I,E,k,x){function b(j){typeof I=="string"&&typeof E=="number"?e.genSalt(E,function(U,Ce){Rt(I,Ce,j,x)}):typeof I=="string"&&typeof E=="string"?Rt(I,E,j,x):a(j.bind(this,Error("Illegal arguments: "+typeof I+", "+typeof E)))}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(j,U){b(function(Ce,se){if(Ce){U(Ce);return}j(se)})})};function s(I,E){for(var k=0,x=0,b=0,j=I.length;b<j;++b)I.charCodeAt(b)===E.charCodeAt(b)?++k:++x;return k<0?!1:x===0}e.compareSync=function(I,E){if(typeof I!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof I+", "+typeof E);return E.length!==60?!1:s(e.hashSync(I,E.substr(0,E.length-31)),E)},e.compare=function(I,E,k,x){function b(j){if(typeof I!="string"||typeof E!="string"){a(j.bind(this,Error("Illegal arguments: "+typeof I+", "+typeof E)));return}if(E.length!==60){a(j.bind(this,null,!1));return}e.hash(I,E.substr(0,29),function(U,Ce){U?j(U):j(null,s(Ce,E))},x)}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(j,U){b(function(Ce,se){if(Ce){U(Ce);return}j(se)})})},e.getRounds=function(I){if(typeof I!="string")throw Error("Illegal arguments: "+typeof I);return parseInt(I.split("$")[2],10)},e.getSalt=function(I){if(typeof I!="string")throw Error("Illegal arguments: "+typeof I);if(I.length!==60)throw Error("Illegal hash length: "+I.length+" != 60");return I.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function o(I){var E=[],k=0;return C.encodeUTF16toUTF8(function(){return k>=I.length?null:I.charCodeAt(k++)},function(x){E.push(x)}),E}var c="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],f=String.fromCharCode;function m(I,E){var k=0,x=[],b,j;if(E<=0||E>I.length)throw Error("Illegal len: "+E);for(;k<E;){if(b=I[k++]&255,x.push(c[b>>2&63]),b=(b&3)<<4,k>=E){x.push(c[b&63]);break}if(j=I[k++]&255,b|=j>>4&15,x.push(c[b&63]),b=(j&15)<<2,k>=E){x.push(c[b&63]);break}j=I[k++]&255,b|=j>>6&3,x.push(c[b&63]),x.push(c[j&63])}return x.join("")}function B(I,E){var k=0,x=I.length,b=0,j=[],U,Ce,se,Ne,Ue,Q;if(E<=0)throw Error("Illegal len: "+E);for(;k<x-1&&b<E&&(Q=I.charCodeAt(k++),U=Q<u.length?u[Q]:-1,Q=I.charCodeAt(k++),Ce=Q<u.length?u[Q]:-1,!(U==-1||Ce==-1||(Ue=U<<2>>>0,Ue|=(Ce&48)>>4,j.push(f(Ue)),++b>=E||k>=x)||(Q=I.charCodeAt(k++),se=Q<u.length?u[Q]:-1,se==-1)||(Ue=(Ce&15)<<4>>>0,Ue|=(se&60)>>2,j.push(f(Ue)),++b>=E||k>=x)));)Q=I.charCodeAt(k++),Ne=Q<u.length?u[Q]:-1,Ue=(se&3)<<6>>>0,Ue|=Ne,j.push(f(Ue)),++b;var ot=[];for(k=0;k<b;k++)ot.push(j[k].charCodeAt(0));return ot}var C=function(){var I={};return I.MAX_CODEPOINT=1114111,I.encodeUTF8=function(E,k){var x=null;for(typeof E=="number"&&(x=E,E=function(){return null});x!==null||(x=E())!==null;)x<128?k(x&127):x<2048?(k(x>>6&31|192),k(x&63|128)):x<65536?(k(x>>12&15|224),k(x>>6&63|128),k(x&63|128)):(k(x>>18&7|240),k(x>>12&63|128),k(x>>6&63|128),k(x&63|128)),x=null},I.decodeUTF8=function(E,k){for(var x,b,j,U,Ce=function(se){se=se.slice(0,se.indexOf(null));var Ne=Error(se.toString());throw Ne.name="TruncatedError",Ne.bytes=se,Ne};(x=E())!==null;)if(!(x&128))k(x);else if((x&224)===192)(b=E())===null&&Ce([x,b]),k((x&31)<<6|b&63);else if((x&240)===224)((b=E())===null||(j=E())===null)&&Ce([x,b,j]),k((x&15)<<12|(b&63)<<6|j&63);else if((x&248)===240)((b=E())===null||(j=E())===null||(U=E())===null)&&Ce([x,b,j,U]),k((x&7)<<18|(b&63)<<12|(j&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+x)},I.UTF16toUTF8=function(E,k){for(var x,b=null;(x=b!==null?b:E())!==null;){if(x>=55296&&x<=57343&&(b=E())!==null&&b>=56320&&b<=57343){k((x-55296)*1024+b-56320+65536),b=null;continue}k(x)}b!==null&&k(b)},I.UTF8toUTF16=function(E,k){var x=null;for(typeof E=="number"&&(x=E,E=function(){return null});x!==null||(x=E())!==null;)x<=65535?k(x):(x-=65536,k((x>>10)+55296),k(x%1024+56320)),x=null},I.encodeUTF16toUTF8=function(E,k){I.UTF16toUTF8(E,function(x){I.encodeUTF8(x,k)})},I.decodeUTF8toUTF16=function(E,k){I.decodeUTF8(E,function(x){I.UTF8toUTF16(x,k)})},I.calculateCodePoint=function(E){return E<128?1:E<2048?2:E<65536?3:4},I.calculateUTF8=function(E){for(var k,x=0;(k=E())!==null;)x+=I.calculateCodePoint(k);return x},I.calculateUTF16asUTF8=function(E){var k=0,x=0;return I.UTF16toUTF8(E,function(b){++k,x+=I.calculateCodePoint(b)}),[k,x]},I}();Date.now=Date.now||function(){return+new Date};var p=16,g=10,A=16,O=100,P=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],N=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],xe=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Le(I,E,k,x){var b,j=I[E],U=I[E+1];return j^=k[0],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[1],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[2],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[3],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[4],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[5],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[6],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[7],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[8],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[9],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[10],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[11],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[12],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[13],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[14],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[15],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[16],I[E]=U^k[A+1],I[E+1]=j,I}function qe(I,E){for(var k=0,x=0;k<4;++k)x=x<<8|I[E]&255,E=(E+1)%I.length;return{key:x,offp:E}}function Ze(I,E,k){for(var x=0,b=[0,0],j=E.length,U=k.length,Ce,se=0;se<j;se++)Ce=qe(I,x),x=Ce.offp,E[se]=E[se]^Ce.key;for(se=0;se<j;se+=2)b=Le(b,0,E,k),E[se]=b[0],E[se+1]=b[1];for(se=0;se<U;se+=2)b=Le(b,0,E,k),k[se]=b[0],k[se+1]=b[1]}function tt(I,E,k,x){for(var b=0,j=[0,0],U=k.length,Ce=x.length,se,Ne=0;Ne<U;Ne++)se=qe(E,b),b=se.offp,k[Ne]=k[Ne]^se.key;for(b=0,Ne=0;Ne<U;Ne+=2)se=qe(I,b),b=se.offp,j[0]^=se.key,se=qe(I,b),b=se.offp,j[1]^=se.key,j=Le(j,0,k,x),k[Ne]=j[0],k[Ne+1]=j[1];for(Ne=0;Ne<Ce;Ne+=2)se=qe(I,b),b=se.offp,j[0]^=se.key,se=qe(I,b),b=se.offp,j[1]^=se.key,j=Le(j,0,k,x),x[Ne]=j[0],x[Ne+1]=j[1]}function mt(I,E,k,x,b){var j=xe.slice(),U=j.length,Ce;if(k<4||k>31)if(Ce=Error("Illegal number of rounds (4-31): "+k),x){a(x.bind(this,Ce));return}else throw Ce;if(E.length!==p)if(Ce=Error("Illegal salt length: "+E.length+" != "+p),x){a(x.bind(this,Ce));return}else throw Ce;k=1<<k>>>0;var se,Ne,Ue=0,Q;Int32Array?(se=new Int32Array(P),Ne=new Int32Array(N)):(se=P.slice(),Ne=N.slice()),tt(E,I,se,Ne);function ot(){if(b&&b(Ue/k),Ue<k)for(var He=Date.now();Ue<k&&(Ue=Ue+1,Ze(I,se,Ne),Ze(E,se,Ne),!(Date.now()-He>O)););else{for(Ue=0;Ue<64;Ue++)for(Q=0;Q<U>>1;Q++)Le(j,Q<<1,se,Ne);var rt=[];for(Ue=0;Ue<U;Ue++)rt.push((j[Ue]>>24&255)>>>0),rt.push((j[Ue]>>16&255)>>>0),rt.push((j[Ue]>>8&255)>>>0),rt.push((j[Ue]&255)>>>0);if(x){x(null,rt);return}else return rt}x&&a(ot)}if(typeof x<"u")ot();else for(var Rn;;)if(typeof(Rn=ot())<"u")return Rn||[]}function Rt(I,E,k,x){var b;if(typeof I!="string"||typeof E!="string")if(b=Error("Invalid string / salt: Not a string"),k){a(k.bind(this,b));return}else throw b;var j,U;if(E.charAt(0)!=="$"||E.charAt(1)!=="2")if(b=Error("Invalid salt version: "+E.substring(0,2)),k){a(k.bind(this,b));return}else throw b;if(E.charAt(2)==="$")j="\0",U=3;else{if(j=E.charAt(2),j!=="a"&&j!=="b"&&j!=="y"||E.charAt(3)!=="$")if(b=Error("Invalid salt revision: "+E.substring(2,4)),k){a(k.bind(this,b));return}else throw b;U=4}if(E.charAt(U+2)>"$")if(b=Error("Missing salt rounds"),k){a(k.bind(this,b));return}else throw b;var Ce=parseInt(E.substring(U,U+1),10)*10,se=parseInt(E.substring(U+1,U+2),10),Ne=Ce+se,Ue=E.substring(U+3,U+25);I+=j>="a"?"\0":"";var Q=o(I),ot=B(Ue,p);function Rn(He){var rt=[];return rt.push("$2"),j>="a"&&rt.push(j),rt.push("$"),Ne<10&&rt.push("0"),rt.push(Ne.toString()),rt.push("$"),rt.push(m(ot,ot.length)),rt.push(m(He,xe.length*4-1)),rt.join("")}if(typeof k>"u")return Rn(mt(Q,ot,Ne));mt(Q,ot,Ne,function(He,rt){He?k(He,null):k(null,Rn(rt))},x)}return e.encodeBase64=m,e.decodeBase64=B,e})})(Py);var V_=Py.exports;const L_=P_(V_),q_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let H_=r=>crypto.getRandomValues(new Uint8Array(r)),F_=(r,e,t)=>{let n=(2<<Math.log2(r.length-1))-1,i=-~(1.6*n*e/r.length);return(s=e)=>{let a="";for(;;){let o=t(i),c=i;for(;c--;)if(a+=r[o[c]&n]||"",a.length===s)return a}}},K_=(r,e=21)=>F_(r,e,H_),lc=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=q_[t[r]&63];return e};const W_=24;function z_(){return K_("0123456789abcdef",W_)()}function Ch(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}async function $y(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function G_({userAdapter:r,tenant_id:e,email:t}){var o;const{users:n}=await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),i=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(i.length===0)return;const s=i.filter(c=>!c.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const a=await r.get(e,(o=i[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}const ri=y.object({page:y.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:y.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:y.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:y.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:y.string().optional().openapi({description:"A lucene query string used to filter the results"})});function cs(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}function Dy(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}var J_={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},Y_=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(J_))if(X_(s))return i}return typeof(r==null?void 0:r.EdgeRuntime)=="string"?"edge-light":(r==null?void 0:r.fastly)!==void 0?"fastly":((n=(t=r==null?void 0:r.process)==null?void 0:t.release)==null?void 0:n.name)==="node"?"node":"other"},X_=r=>navigator.userAgent.startsWith(r);function Q_(r,e){Y_()==="workerd"&&r.executionCtx.waitUntil(e)}const jh=jn.extend({users:y.array(vr)}),ew=jn.extend({sessions:y.array(mf)}),tw=new dt().openapi(ve({tags:["users"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(vr),jh])}},description:"List of users"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const f=s.split("=")[1],B=(await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,q:`email:${f}`})).users.filter(g=>g.linked_to),[C]=B;if(!C)return r.json([]);const p=await r.env.data.users.get(a,C.linked_to);if(!p)throw new ye(500,{message:"Primary account not found"});return r.json([vr.parse(p)])}const o=["-_exists_:linked_to"];s&&o.push(s);const c=await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,sort:cs(i),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(jh.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(y.array(vr).parse(u))}).openapi(ve({tags:["users"],method:"get",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:vr}},description:"List of users"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{"tenant-id":t}=r.req.valid("header"),n=await r.env.data.users.get(t,e);if(!n)throw new ye(404);if(n.linked_to)throw new ye(404,{message:"User is linked to another user"});return r.json(n)}).openapi(ve({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{"tenant-id":t}=r.req.valid("header");if(!await r.env.data.users.remove(t,e))throw new ye(404);return r.text("OK")}).openapi(ve({tags:["users"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object({...rc.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:vr}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");r.set("body",t);const{email:n}=t;if(!n)throw new ye(400,{message:"Email is required"});const i=n.toLowerCase(),s=`${t.provider}|${t.user_id||z_()}`;try{const a=await r.env.data.users.create(e,{email:i,user_id:s,name:t.name||i,provider:t.provider,connection:t.connection,email_verified:t.email_verified||!1,last_ip:"",login_count:0,is_social:!1,last_login:new Date().toISOString(),created_at:new Date().toISOString(),updated_at:new Date().toISOString()});r.set("user_id",a.user_id);const o=Dy(r,{type:nu.SUCCESS_API_OPERATION,description:"User created"});Q_(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:Ch(a.user_id),isSocial:a.is_social}]};return r.json(vr.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new ye(409,{message:"User already exists"}):a}}).openapi(ve({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object({...rc.shape,verify_email:y.boolean(),password:y.string()}).partial()}}},params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{var u;const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),{user_id:n}=r.req.valid("param"),{verify_email:i,password:s,...a}=t,o=await r.env.data.users.get(e,n);if(!o)throw new ye(404);if(a.email&&a.email!==o.email){const f=await $y(r.env.data.users,e,a.email);if(f.length&&f.some(m=>m.user_id!==n))throw new ye(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new ye(404,{message:"User is linked to another user"});if(await r.env.data.users.update(e,n,a),s){const f=(u=o.identities)==null?void 0:u.find(m=>m.connection==="Username-Password-Authentication");if(!f)throw new ye(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${f.provider}|${f.user_id}`,password:L_.hashSync(s,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new ye(500);return r.json(c)}).openapi(ve({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.union([y.object({link_with:y.string()}),y.object({user_id:y.string(),provider:y.string(),connection:y.string().optional()})])}}},params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:y.array(y.object({connection:y.string(),provider:y.string(),user_id:y.string(),isSocial:y.boolean()}))}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),{user_id:n}=r.req.valid("param"),i="link_with"in t?t.link_with:t.user_id,s=await r.env.data.users.get(e,n);if(!s)throw new ye(400,{message:"Linking an inexistent identity is not allowed."});await r.env.data.users.update(e,i,{linked_to:n});const a=await r.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${n}`}),o=[s,...a.users].map(c=>({connection:c.connection,provider:c.provider,user_id:Ch(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(ve({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string(),provider:y.string(),linked_user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:y.array(vr)}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{user_id:t,provider:n,linked_user_id:i}=r.req.valid("param");await r.env.data.users.unlink(e,t,n,i);const s=await r.env.data.users.get(e,t);if(!s)throw new ye(404);return r.json([vr.parse(s)])}).openapi(ve({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:ri,headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(mf),ew])}},description:"List of sessions"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{include_totals:t}=r.req.valid("query"),{"tenant-id":n}=r.req.valid("header"),i=await r.env.data.sessions.list(n,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return t?r.json(i):r.json(i.sessions)});/*! *****************************************************************************
5
+ */(function(e,t){typeof Z_=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(lc,function(){var e={},t=null;function n(I){if(r&&r.exports)try{return V_.randomBytes(I)}catch{}try{var E;return(self.crypto||self.msCrypto).getRandomValues(E=new Uint32Array(I)),Array.prototype.slice.call(E)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t(I)}var i=!1;try{n(1),i=!0}catch{}t=null,e.setRandomFallback=function(I){t=I},e.genSaltSync=function(I,E){if(I=I||g,typeof I!="number")throw Error("Illegal arguments: "+typeof I+", "+typeof E);I<4?I=4:I>31&&(I=31);var k=[];return k.push("$2a$"),I<10&&k.push("0"),k.push(I.toString()),k.push("$"),k.push(m(n(p),p)),k.join("")},e.genSalt=function(I,E,k){if(typeof E=="function"&&(k=E,E=void 0),typeof I=="function"&&(k=I,I=void 0),typeof I>"u")I=g;else if(typeof I!="number")throw Error("illegal arguments: "+typeof I);function x(b){a(function(){try{b(null,e.genSaltSync(I))}catch(j){b(j)}})}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);x(k)}else return new Promise(function(b,j){x(function(U,Ce){if(U){j(U);return}b(Ce)})})},e.hashSync=function(I,E){if(typeof E>"u"&&(E=g),typeof E=="number"&&(E=e.genSaltSync(E)),typeof I!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof I+", "+typeof E);return Rt(I,E)},e.hash=function(I,E,k,x){function b(j){typeof I=="string"&&typeof E=="number"?e.genSalt(E,function(U,Ce){Rt(I,Ce,j,x)}):typeof I=="string"&&typeof E=="string"?Rt(I,E,j,x):a(j.bind(this,Error("Illegal arguments: "+typeof I+", "+typeof E)))}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(j,U){b(function(Ce,se){if(Ce){U(Ce);return}j(se)})})};function s(I,E){for(var k=0,x=0,b=0,j=I.length;b<j;++b)I.charCodeAt(b)===E.charCodeAt(b)?++k:++x;return k<0?!1:x===0}e.compareSync=function(I,E){if(typeof I!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof I+", "+typeof E);return E.length!==60?!1:s(e.hashSync(I,E.substr(0,E.length-31)),E)},e.compare=function(I,E,k,x){function b(j){if(typeof I!="string"||typeof E!="string"){a(j.bind(this,Error("Illegal arguments: "+typeof I+", "+typeof E)));return}if(E.length!==60){a(j.bind(this,null,!1));return}e.hash(I,E.substr(0,29),function(U,Ce){U?j(U):j(null,s(Ce,E))},x)}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(j,U){b(function(Ce,se){if(Ce){U(Ce);return}j(se)})})},e.getRounds=function(I){if(typeof I!="string")throw Error("Illegal arguments: "+typeof I);return parseInt(I.split("$")[2],10)},e.getSalt=function(I){if(typeof I!="string")throw Error("Illegal arguments: "+typeof I);if(I.length!==60)throw Error("Illegal hash length: "+I.length+" != 60");return I.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function o(I){var E=[],k=0;return C.encodeUTF16toUTF8(function(){return k>=I.length?null:I.charCodeAt(k++)},function(x){E.push(x)}),E}var c="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],f=String.fromCharCode;function m(I,E){var k=0,x=[],b,j;if(E<=0||E>I.length)throw Error("Illegal len: "+E);for(;k<E;){if(b=I[k++]&255,x.push(c[b>>2&63]),b=(b&3)<<4,k>=E){x.push(c[b&63]);break}if(j=I[k++]&255,b|=j>>4&15,x.push(c[b&63]),b=(j&15)<<2,k>=E){x.push(c[b&63]);break}j=I[k++]&255,b|=j>>6&3,x.push(c[b&63]),x.push(c[j&63])}return x.join("")}function B(I,E){var k=0,x=I.length,b=0,j=[],U,Ce,se,Ne,Ue,Q;if(E<=0)throw Error("Illegal len: "+E);for(;k<x-1&&b<E&&(Q=I.charCodeAt(k++),U=Q<u.length?u[Q]:-1,Q=I.charCodeAt(k++),Ce=Q<u.length?u[Q]:-1,!(U==-1||Ce==-1||(Ue=U<<2>>>0,Ue|=(Ce&48)>>4,j.push(f(Ue)),++b>=E||k>=x)||(Q=I.charCodeAt(k++),se=Q<u.length?u[Q]:-1,se==-1)||(Ue=(Ce&15)<<4>>>0,Ue|=(se&60)>>2,j.push(f(Ue)),++b>=E||k>=x)));)Q=I.charCodeAt(k++),Ne=Q<u.length?u[Q]:-1,Ue=(se&3)<<6>>>0,Ue|=Ne,j.push(f(Ue)),++b;var ot=[];for(k=0;k<b;k++)ot.push(j[k].charCodeAt(0));return ot}var C=function(){var I={};return I.MAX_CODEPOINT=1114111,I.encodeUTF8=function(E,k){var x=null;for(typeof E=="number"&&(x=E,E=function(){return null});x!==null||(x=E())!==null;)x<128?k(x&127):x<2048?(k(x>>6&31|192),k(x&63|128)):x<65536?(k(x>>12&15|224),k(x>>6&63|128),k(x&63|128)):(k(x>>18&7|240),k(x>>12&63|128),k(x>>6&63|128),k(x&63|128)),x=null},I.decodeUTF8=function(E,k){for(var x,b,j,U,Ce=function(se){se=se.slice(0,se.indexOf(null));var Ne=Error(se.toString());throw Ne.name="TruncatedError",Ne.bytes=se,Ne};(x=E())!==null;)if(!(x&128))k(x);else if((x&224)===192)(b=E())===null&&Ce([x,b]),k((x&31)<<6|b&63);else if((x&240)===224)((b=E())===null||(j=E())===null)&&Ce([x,b,j]),k((x&15)<<12|(b&63)<<6|j&63);else if((x&248)===240)((b=E())===null||(j=E())===null||(U=E())===null)&&Ce([x,b,j,U]),k((x&7)<<18|(b&63)<<12|(j&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+x)},I.UTF16toUTF8=function(E,k){for(var x,b=null;(x=b!==null?b:E())!==null;){if(x>=55296&&x<=57343&&(b=E())!==null&&b>=56320&&b<=57343){k((x-55296)*1024+b-56320+65536),b=null;continue}k(x)}b!==null&&k(b)},I.UTF8toUTF16=function(E,k){var x=null;for(typeof E=="number"&&(x=E,E=function(){return null});x!==null||(x=E())!==null;)x<=65535?k(x):(x-=65536,k((x>>10)+55296),k(x%1024+56320)),x=null},I.encodeUTF16toUTF8=function(E,k){I.UTF16toUTF8(E,function(x){I.encodeUTF8(x,k)})},I.decodeUTF8toUTF16=function(E,k){I.decodeUTF8(E,function(x){I.UTF8toUTF16(x,k)})},I.calculateCodePoint=function(E){return E<128?1:E<2048?2:E<65536?3:4},I.calculateUTF8=function(E){for(var k,x=0;(k=E())!==null;)x+=I.calculateCodePoint(k);return x},I.calculateUTF16asUTF8=function(E){var k=0,x=0;return I.UTF16toUTF8(E,function(b){++k,x+=I.calculateCodePoint(b)}),[k,x]},I}();Date.now=Date.now||function(){return+new Date};var p=16,g=10,A=16,O=100,P=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],N=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],xe=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Le(I,E,k,x){var b,j=I[E],U=I[E+1];return j^=k[0],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[1],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[2],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[3],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[4],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[5],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[6],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[7],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[8],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[9],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[10],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[11],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[12],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[13],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[14],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[15],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[16],I[E]=U^k[A+1],I[E+1]=j,I}function qe(I,E){for(var k=0,x=0;k<4;++k)x=x<<8|I[E]&255,E=(E+1)%I.length;return{key:x,offp:E}}function Ze(I,E,k){for(var x=0,b=[0,0],j=E.length,U=k.length,Ce,se=0;se<j;se++)Ce=qe(I,x),x=Ce.offp,E[se]=E[se]^Ce.key;for(se=0;se<j;se+=2)b=Le(b,0,E,k),E[se]=b[0],E[se+1]=b[1];for(se=0;se<U;se+=2)b=Le(b,0,E,k),k[se]=b[0],k[se+1]=b[1]}function tt(I,E,k,x){for(var b=0,j=[0,0],U=k.length,Ce=x.length,se,Ne=0;Ne<U;Ne++)se=qe(E,b),b=se.offp,k[Ne]=k[Ne]^se.key;for(b=0,Ne=0;Ne<U;Ne+=2)se=qe(I,b),b=se.offp,j[0]^=se.key,se=qe(I,b),b=se.offp,j[1]^=se.key,j=Le(j,0,k,x),k[Ne]=j[0],k[Ne+1]=j[1];for(Ne=0;Ne<Ce;Ne+=2)se=qe(I,b),b=se.offp,j[0]^=se.key,se=qe(I,b),b=se.offp,j[1]^=se.key,j=Le(j,0,k,x),x[Ne]=j[0],x[Ne+1]=j[1]}function mt(I,E,k,x,b){var j=xe.slice(),U=j.length,Ce;if(k<4||k>31)if(Ce=Error("Illegal number of rounds (4-31): "+k),x){a(x.bind(this,Ce));return}else throw Ce;if(E.length!==p)if(Ce=Error("Illegal salt length: "+E.length+" != "+p),x){a(x.bind(this,Ce));return}else throw Ce;k=1<<k>>>0;var se,Ne,Ue=0,Q;Int32Array?(se=new Int32Array(P),Ne=new Int32Array(N)):(se=P.slice(),Ne=N.slice()),tt(E,I,se,Ne);function ot(){if(b&&b(Ue/k),Ue<k)for(var He=Date.now();Ue<k&&(Ue=Ue+1,Ze(I,se,Ne),Ze(E,se,Ne),!(Date.now()-He>O)););else{for(Ue=0;Ue<64;Ue++)for(Q=0;Q<U>>1;Q++)Le(j,Q<<1,se,Ne);var rt=[];for(Ue=0;Ue<U;Ue++)rt.push((j[Ue]>>24&255)>>>0),rt.push((j[Ue]>>16&255)>>>0),rt.push((j[Ue]>>8&255)>>>0),rt.push((j[Ue]&255)>>>0);if(x){x(null,rt);return}else return rt}x&&a(ot)}if(typeof x<"u")ot();else for(var Rn;;)if(typeof(Rn=ot())<"u")return Rn||[]}function Rt(I,E,k,x){var b;if(typeof I!="string"||typeof E!="string")if(b=Error("Invalid string / salt: Not a string"),k){a(k.bind(this,b));return}else throw b;var j,U;if(E.charAt(0)!=="$"||E.charAt(1)!=="2")if(b=Error("Invalid salt version: "+E.substring(0,2)),k){a(k.bind(this,b));return}else throw b;if(E.charAt(2)==="$")j="\0",U=3;else{if(j=E.charAt(2),j!=="a"&&j!=="b"&&j!=="y"||E.charAt(3)!=="$")if(b=Error("Invalid salt revision: "+E.substring(2,4)),k){a(k.bind(this,b));return}else throw b;U=4}if(E.charAt(U+2)>"$")if(b=Error("Missing salt rounds"),k){a(k.bind(this,b));return}else throw b;var Ce=parseInt(E.substring(U,U+1),10)*10,se=parseInt(E.substring(U+1,U+2),10),Ne=Ce+se,Ue=E.substring(U+3,U+25);I+=j>="a"?"\0":"";var Q=o(I),ot=B(Ue,p);function Rn(He){var rt=[];return rt.push("$2"),j>="a"&&rt.push(j),rt.push("$"),Ne<10&&rt.push("0"),rt.push(Ne.toString()),rt.push("$"),rt.push(m(ot,ot.length)),rt.push(m(He,xe.length*4-1)),rt.join("")}if(typeof k>"u")return Rn(mt(Q,ot,Ne));mt(Q,ot,Ne,function(He,rt){He?k(He,null):k(null,Rn(rt))},x)}return e.encodeBase64=m,e.decodeBase64=B,e})})($y);var L_=$y.exports;const q_=$_(L_),H_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let F_=r=>crypto.getRandomValues(new Uint8Array(r)),K_=(r,e,t)=>{let n=(2<<Math.log2(r.length-1))-1,i=-~(1.6*n*e/r.length);return(s=e)=>{let a="";for(;;){let o=t(i),c=i;for(;c--;)if(a+=r[o[c]&n]||"",a.length===s)return a}}},W_=(r,e=21)=>K_(r,e,F_),dc=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=H_[t[r]&63];return e};const z_=24;function G_(){return W_("0123456789abcdef",z_)()}function jh(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}async function Dy(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function J_({userAdapter:r,tenant_id:e,email:t}){var o;const{users:n}=await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),i=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(i.length===0)return;const s=i.filter(c=>!c.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const a=await r.get(e,(o=i[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}const ri=y.object({page:y.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:y.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:y.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:y.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:y.string().optional().openapi({description:"A lucene query string used to filter the results"})});function cs(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}function Zy(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}var Y_={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},X_=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(Y_))if(Q_(s))return i}return typeof(r==null?void 0:r.EdgeRuntime)=="string"?"edge-light":(r==null?void 0:r.fastly)!==void 0?"fastly":((n=(t=r==null?void 0:r.process)==null?void 0:t.release)==null?void 0:n.name)==="node"?"node":"other"},Q_=r=>navigator.userAgent.startsWith(r);function ew(r,e){X_()==="workerd"&&r.executionCtx.waitUntil(e)}const Th=jn.extend({users:y.array(vr)}),tw=jn.extend({sessions:y.array(yf)}),rw=new dt().openapi(ve({tags:["users"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(vr),Th])}},description:"List of users"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const f=s.split("=")[1],B=(await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,q:`email:${f}`})).users.filter(g=>g.linked_to),[C]=B;if(!C)return r.json([]);const p=await r.env.data.users.get(a,C.linked_to);if(!p)throw new ye(500,{message:"Primary account not found"});return r.json([vr.parse(p)])}const o=["-_exists_:linked_to"];s&&o.push(s);const c=await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,sort:cs(i),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(Th.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(y.array(vr).parse(u))}).openapi(ve({tags:["users"],method:"get",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:vr}},description:"List of users"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{"tenant-id":t}=r.req.valid("header"),n=await r.env.data.users.get(t,e);if(!n)throw new ye(404);if(n.linked_to)throw new ye(404,{message:"User is linked to another user"});return r.json(n)}).openapi(ve({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{"tenant-id":t}=r.req.valid("header");if(!await r.env.data.users.remove(t,e))throw new ye(404);return r.text("OK")}).openapi(ve({tags:["users"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object({...nc.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:vr}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");r.set("body",t);const{email:n}=t;if(!n)throw new ye(400,{message:"Email is required"});const i=n.toLowerCase(),s=`${t.provider}|${t.user_id||G_()}`;try{const a=await r.env.data.users.create(e,{email:i,user_id:s,name:t.name||i,provider:t.provider,connection:t.connection,email_verified:t.email_verified||!1,last_ip:"",login_count:0,is_social:!1,last_login:new Date().toISOString(),created_at:new Date().toISOString(),updated_at:new Date().toISOString()});r.set("user_id",a.user_id);const o=Zy(r,{type:iu.SUCCESS_API_OPERATION,description:"User created"});ew(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:jh(a.user_id),isSocial:a.is_social}]};return r.json(vr.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new ye(409,{message:"User already exists"}):a}}).openapi(ve({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object({...nc.shape,verify_email:y.boolean(),password:y.string()}).partial()}}},params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{var u;const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),{user_id:n}=r.req.valid("param"),{verify_email:i,password:s,...a}=t,o=await r.env.data.users.get(e,n);if(!o)throw new ye(404);if(a.email&&a.email!==o.email){const f=await Dy(r.env.data.users,e,a.email);if(f.length&&f.some(m=>m.user_id!==n))throw new ye(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new ye(404,{message:"User is linked to another user"});if(await r.env.data.users.update(e,n,a),s){const f=(u=o.identities)==null?void 0:u.find(m=>m.connection==="Username-Password-Authentication");if(!f)throw new ye(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${f.provider}|${f.user_id}`,password:q_.hashSync(s,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new ye(500);return r.json(c)}).openapi(ve({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.union([y.object({link_with:y.string()}),y.object({user_id:y.string(),provider:y.string(),connection:y.string().optional()})])}}},params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:y.array(y.object({connection:y.string(),provider:y.string(),user_id:y.string(),isSocial:y.boolean()}))}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),{user_id:n}=r.req.valid("param"),i="link_with"in t?t.link_with:t.user_id,s=await r.env.data.users.get(e,n);if(!s)throw new ye(400,{message:"Linking an inexistent identity is not allowed."});await r.env.data.users.update(e,i,{linked_to:n});const a=await r.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${n}`}),o=[s,...a.users].map(c=>({connection:c.connection,provider:c.provider,user_id:jh(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(ve({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string(),provider:y.string(),linked_user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:y.array(vr)}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{user_id:t,provider:n,linked_user_id:i}=r.req.valid("param");await r.env.data.users.unlink(e,t,n,i);const s=await r.env.data.users.get(e,t);if(!s)throw new ye(404);return r.json([vr.parse(s)])}).openapi(ve({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:ri,headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(yf),tw])}},description:"List of sessions"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{include_totals:t}=r.req.valid("query"),{"tenant-id":n}=r.req.valid("header"),i=await r.env.data.sessions.list(n,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return t?r.json(i):r.json(i.sessions)});/*! *****************************************************************************
6
6
  Copyright (C) Microsoft. All rights reserved.
7
7
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
8
8
  this file except in compliance with the License. You may obtain a copy of the
@@ -15,7 +15,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
15
15
 
16
16
  See the Apache Version 2.0 License for specific language governing permissions
17
17
  and limitations under the License.
18
- ***************************************************************************** */var Th;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof uc=="object"?uc:typeof self=="object"?self:typeof this=="object"?this:o(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(c,u){return function(f,m){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:m}),u&&u(f,m)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function o(){return s()||a()}})(function(e,t){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!o&&!c,f={create:o?function(){return Ju(Object.create(null))}:c?function(){return Ju({__proto__:null})}:function(){return Ju({})},has:u?function(_,S){return n.call(_,S)}:function(_,S){return S in _},get:u?function(_,S){return n.call(_,S)?_[S]:void 0}:function(_,S){return _[S]}},m=Object.getPrototypeOf(Function),B=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:X0(),C=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Q0(),p=typeof WeakMap=="function"?WeakMap:ev(),g=i?Symbol.for("@reflect-metadata:registry"):void 0,A=G0(),O=J0(A);function P(_,S,T,V){if(Q(T)){if(!oh(_))throw new TypeError;if(!ch(S))throw new TypeError;return E(_,S)}else{if(!oh(_))throw new TypeError;if(!He(S))throw new TypeError;if(!He(V)&&!Q(V)&&!ot(V))throw new TypeError;return ot(V)&&(V=void 0),T=yr(T),k(_,S,T,V)}}e("decorate",P);function N(_,S){function T(V,le){if(!He(V))throw new TypeError;if(!Q(le)&&!W0(le))throw new TypeError;Ce(_,S,V,le)}return T}e("metadata",N);function xe(_,S,T,V){if(!He(T))throw new TypeError;return Q(V)||(V=yr(V)),Ce(_,S,T,V)}e("defineMetadata",xe);function Le(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),x(_,S,T)}e("hasMetadata",Le);function qe(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),b(_,S,T)}e("hasOwnMetadata",qe);function Ze(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),j(_,S,T)}e("getMetadata",Ze);function tt(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),U(_,S,T)}e("getOwnMetadata",tt);function mt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),se(_,S)}e("getMetadataKeys",mt);function Rt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),Ne(_,S)}e("getOwnMetadataKeys",Rt);function I(_,S,T){if(!He(S))throw new TypeError;if(Q(T)||(T=yr(T)),!He(S))throw new TypeError;Q(T)||(T=yr(T));var V=bs(S,T,!1);return Q(V)?!1:V.OrdinaryDeleteMetadata(_,S,T)}e("deleteMetadata",I);function E(_,S){for(var T=_.length-1;T>=0;--T){var V=_[T],le=V(S);if(!Q(le)&&!ot(le)){if(!ch(le))throw new TypeError;S=le}}return S}function k(_,S,T,V){for(var le=_.length-1;le>=0;--le){var ct=_[le],nt=ct(S,T,V);if(!Q(nt)&&!ot(nt)){if(!He(nt))throw new TypeError;V=nt}}return V}function x(_,S,T){var V=b(_,S,T);if(V)return!0;var le=Gu(S);return ot(le)?!1:x(_,le,T)}function b(_,S,T){var V=bs(S,T,!1);return Q(V)?!1:ah(V.OrdinaryHasOwnMetadata(_,S,T))}function j(_,S,T){var V=b(_,S,T);if(V)return U(_,S,T);var le=Gu(S);if(!ot(le))return j(_,le,T)}function U(_,S,T){var V=bs(S,T,!1);if(!Q(V))return V.OrdinaryGetOwnMetadata(_,S,T)}function Ce(_,S,T,V){var le=bs(T,V,!0);le.OrdinaryDefineOwnMetadata(_,S,T,V)}function se(_,S){var T=Ne(_,S),V=Gu(_);if(V===null)return T;var le=se(V,S);if(le.length<=0)return T;if(T.length<=0)return le;for(var ct=new C,nt=[],je=0,W=T;je<W.length;je++){var ee=W[je],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}for(var ie=0,Be=le;ie<Be.length;ie++){var ee=Be[ie],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}return nt}function Ne(_,S){var T=bs(_,S,!1);return T?T.OrdinaryOwnMetadataKeys(_,S):[]}function Ue(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function Q(_){return _===void 0}function ot(_){return _===null}function Rn(_){return typeof _=="symbol"}function He(_){return typeof _=="object"?_!==null:typeof _=="function"}function rt(_,S){switch(Ue(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var T="string",V=uh(_,s);if(V!==void 0){var le=V.call(_,T);if(He(le))throw new TypeError;return le}return F0(_)}function F0(_,S){var T,V;{var le=_.toString;if(vo(le)){var V=le.call(_);if(!He(V))return V}var T=_.valueOf;if(vo(T)){var V=T.call(_);if(!He(V))return V}}throw new TypeError}function ah(_){return!!_}function K0(_){return""+_}function yr(_){var S=rt(_);return Rn(S)?S:K0(S)}function oh(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function vo(_){return typeof _=="function"}function ch(_){return typeof _=="function"}function W0(_){switch(Ue(_)){case 3:return!0;case 4:return!0;default:return!1}}function zu(_,S){return _===S||_!==_&&S!==S}function uh(_,S){var T=_[S];if(T!=null){if(!vo(T))throw new TypeError;return T}}function lh(_){var S=uh(_,a);if(!vo(S))throw new TypeError;var T=S.call(_);if(!He(T))throw new TypeError;return T}function dh(_){return _.value}function fh(_){var S=_.next();return S.done?!1:S}function hh(_){var S=_.return;S&&S.call(_)}function Gu(_){var S=Object.getPrototypeOf(_);if(typeof _!="function"||_===m||S!==m)return S;var T=_.prototype,V=T&&Object.getPrototypeOf(T);if(V==null||V===Object.prototype)return S;var le=V.constructor;return typeof le!="function"||le===_?S:le}function z0(){var _;!Q(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=Y0(t.Reflect));var S,T,V,le=new p,ct={registerProvider:nt,getProvider:W,setProvider:re};return ct;function nt(ie){if(!Object.isExtensible(ct))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===ie:break;case Q(S):S=ie;break;case S===ie:break;case Q(T):T=ie;break;case T===ie:break;default:V===void 0&&(V=new C),V.add(ie);break}}function je(ie,Be){if(!Q(S)){if(S.isProviderFor(ie,Be))return S;if(!Q(T)){if(T.isProviderFor(ie,Be))return S;if(!Q(V))for(var Fe=lh(V);;){var Xe=fh(Fe);if(!Xe)return;var Yt=dh(Xe);if(Yt.isProviderFor(ie,Be))return hh(Fe),Yt}}}if(!Q(_)&&_.isProviderFor(ie,Be))return _}function W(ie,Be){var Fe=le.get(ie),Xe;return Q(Fe)||(Xe=Fe.get(Be)),Q(Xe)&&(Xe=je(ie,Be),Q(Xe)||(Q(Fe)&&(Fe=new B,le.set(ie,Fe)),Fe.set(Be,Xe))),Xe}function ee(ie){if(Q(ie))throw new TypeError;return S===ie||T===ie||!Q(V)&&V.has(ie)}function re(ie,Be,Fe){if(!ee(Fe))throw new Error("Metadata provider not registered.");var Xe=W(ie,Be);if(Xe!==Fe){if(!Q(Xe))return!1;var Yt=le.get(ie);Q(Yt)&&(Yt=new B,le.set(ie,Yt)),Yt.set(Be,Fe)}return!0}}function G0(){var _;return!Q(g)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[g]),Q(_)&&(_=z0()),!Q(g)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function J0(_){var S=new p,T={isProviderFor:function(ee,re){var ie=S.get(ee);return Q(ie)?!1:ie.has(re)},OrdinaryDefineOwnMetadata:nt,OrdinaryHasOwnMetadata:le,OrdinaryGetOwnMetadata:ct,OrdinaryOwnMetadataKeys:je,OrdinaryDeleteMetadata:W};return A.registerProvider(T),T;function V(ee,re,ie){var Be=S.get(ee),Fe=!1;if(Q(Be)){if(!ie)return;Be=new B,S.set(ee,Be),Fe=!0}var Xe=Be.get(re);if(Q(Xe)){if(!ie)return;if(Xe=new B,Be.set(re,Xe),!_.setProvider(ee,re,T))throw Be.delete(re),Fe&&S.delete(ee),new Error("Wrong provider for target.")}return Xe}function le(ee,re,ie){var Be=V(re,ie,!1);return Q(Be)?!1:ah(Be.has(ee))}function ct(ee,re,ie){var Be=V(re,ie,!1);if(!Q(Be))return Be.get(ee)}function nt(ee,re,ie,Be){var Fe=V(ie,Be,!0);Fe.set(ee,re)}function je(ee,re){var ie=[],Be=V(ee,re,!1);if(Q(Be))return ie;for(var Fe=Be.keys(),Xe=lh(Fe),Yt=0;;){var ph=fh(Xe);if(!ph)return ie.length=Yt,ie;var tv=dh(ph);try{ie[Yt]=tv}catch(rv){try{hh(Xe)}finally{throw rv}}Yt++}}function W(ee,re,ie){var Be=V(re,ie,!1);if(Q(Be)||!Be.delete(ee))return!1;if(Be.size===0){var Fe=S.get(re);Q(Fe)||(Fe.delete(ie),Fe.size===0&&S.delete(Fe))}return!0}}function Y0(_){var S=_.defineMetadata,T=_.hasOwnMetadata,V=_.getOwnMetadata,le=_.getOwnMetadataKeys,ct=_.deleteMetadata,nt=new p,je={isProviderFor:function(W,ee){var re=nt.get(W);return!Q(re)&&re.has(ee)?!0:le(W,ee).length?(Q(re)&&(re=new C,nt.set(W,re)),re.add(ee),!0):!1},OrdinaryDefineOwnMetadata:S,OrdinaryHasOwnMetadata:T,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:le,OrdinaryDeleteMetadata:ct};return je}function bs(_,S,T){var V=A.getProvider(_,S);if(!Q(V))return V;if(T){if(A.setProvider(_,S,O))return O;throw new Error("Illegal state.")}}function X0(){var _={},S=[],T=function(){function je(W,ee,re){this._index=0,this._keys=W,this._values=ee,this._selector=re}return je.prototype["@@iterator"]=function(){return this},je.prototype[a]=function(){return this},je.prototype.next=function(){var W=this._index;if(W>=0&&W<this._keys.length){var ee=this._selector(this._keys[W],this._values[W]);return W+1>=this._keys.length?(this._index=-1,this._keys=S,this._values=S):this._index++,{value:ee,done:!1}}return{value:void 0,done:!0}},je.prototype.throw=function(W){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),W},je.prototype.return=function(W){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:W,done:!0}},je}(),V=function(){function je(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(je.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),je.prototype.has=function(W){return this._find(W,!1)>=0},je.prototype.get=function(W){var ee=this._find(W,!1);return ee>=0?this._values[ee]:void 0},je.prototype.set=function(W,ee){var re=this._find(W,!0);return this._values[re]=ee,this},je.prototype.delete=function(W){var ee=this._find(W,!1);if(ee>=0){for(var re=this._keys.length,ie=ee+1;ie<re;ie++)this._keys[ie-1]=this._keys[ie],this._values[ie-1]=this._values[ie];return this._keys.length--,this._values.length--,zu(W,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},je.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},je.prototype.keys=function(){return new T(this._keys,this._values,le)},je.prototype.values=function(){return new T(this._keys,this._values,ct)},je.prototype.entries=function(){return new T(this._keys,this._values,nt)},je.prototype["@@iterator"]=function(){return this.entries()},je.prototype[a]=function(){return this.entries()},je.prototype._find=function(W,ee){if(!zu(this._cacheKey,W)){this._cacheIndex=-1;for(var re=0;re<this._keys.length;re++)if(zu(this._keys[re],W)){this._cacheIndex=re;break}}return this._cacheIndex<0&&ee&&(this._cacheIndex=this._keys.length,this._keys.push(W),this._values.push(void 0)),this._cacheIndex},je}();return V;function le(je,W){return je}function ct(je,W){return W}function nt(je,W){return[je,W]}}function Q0(){var _=function(){function S(){this._map=new B}return Object.defineProperty(S.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),S.prototype.has=function(T){return this._map.has(T)},S.prototype.add=function(T){return this._map.set(T,T),this},S.prototype.delete=function(T){return this._map.delete(T)},S.prototype.clear=function(){this._map.clear()},S.prototype.keys=function(){return this._map.keys()},S.prototype.values=function(){return this._map.keys()},S.prototype.entries=function(){return this._map.entries()},S.prototype["@@iterator"]=function(){return this.keys()},S.prototype[a]=function(){return this.keys()},S}();return _}function ev(){var _=16,S=f.create(),T=V();return function(){function W(){this._key=V()}return W.prototype.has=function(ee){var re=le(ee,!1);return re!==void 0?f.has(re,this._key):!1},W.prototype.get=function(ee){var re=le(ee,!1);return re!==void 0?f.get(re,this._key):void 0},W.prototype.set=function(ee,re){var ie=le(ee,!0);return ie[this._key]=re,this},W.prototype.delete=function(ee){var re=le(ee,!1);return re!==void 0?delete re[this._key]:!1},W.prototype.clear=function(){this._key=V()},W}();function V(){var W;do W="@@WeakMap@@"+je();while(f.has(S,W));return S[W]=!0,W}function le(W,ee){if(!n.call(W,T)){if(!ee)return;Object.defineProperty(W,T,{value:f.create()})}return W[T]}function ct(W,ee){for(var re=0;re<ee;++re)W[re]=Math.random()*255|0;return W}function nt(W){if(typeof Uint8Array=="function"){var ee=new Uint8Array(W);return typeof crypto<"u"?crypto.getRandomValues(ee):typeof msCrypto<"u"?msCrypto.getRandomValues(ee):ct(ee,W),ee}return ct(new Array(W),W)}function je(){var W=nt(_);W[6]=W[6]&79|64,W[8]=W[8]&191|128;for(var ee="",re=0;re<_;++re){var ie=W[re];(re===4||re===6||re===8)&&(ee+="-"),ie<16&&(ee+="0"),ee+=ie.toString(16).toLowerCase()}return ee}}function Ju(_){return _.__=void 0,delete _.__,_}})})(Th||(Th={}));/*!
18
+ ***************************************************************************** */var Nh;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof lc=="object"?lc:typeof self=="object"?self:typeof this=="object"?this:o(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(c,u){return function(f,m){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:m}),u&&u(f,m)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function o(){return s()||a()}})(function(e,t){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!o&&!c,f={create:o?function(){return Yu(Object.create(null))}:c?function(){return Yu({__proto__:null})}:function(){return Yu({})},has:u?function(_,S){return n.call(_,S)}:function(_,S){return S in _},get:u?function(_,S){return n.call(_,S)?_[S]:void 0}:function(_,S){return _[S]}},m=Object.getPrototypeOf(Function),B=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Q0(),C=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:ev(),p=typeof WeakMap=="function"?WeakMap:tv(),g=i?Symbol.for("@reflect-metadata:registry"):void 0,A=J0(),O=Y0(A);function P(_,S,T,V){if(Q(T)){if(!ch(_))throw new TypeError;if(!uh(S))throw new TypeError;return E(_,S)}else{if(!ch(_))throw new TypeError;if(!He(S))throw new TypeError;if(!He(V)&&!Q(V)&&!ot(V))throw new TypeError;return ot(V)&&(V=void 0),T=yr(T),k(_,S,T,V)}}e("decorate",P);function N(_,S){function T(V,le){if(!He(V))throw new TypeError;if(!Q(le)&&!z0(le))throw new TypeError;Ce(_,S,V,le)}return T}e("metadata",N);function xe(_,S,T,V){if(!He(T))throw new TypeError;return Q(V)||(V=yr(V)),Ce(_,S,T,V)}e("defineMetadata",xe);function Le(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),x(_,S,T)}e("hasMetadata",Le);function qe(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),b(_,S,T)}e("hasOwnMetadata",qe);function Ze(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),j(_,S,T)}e("getMetadata",Ze);function tt(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),U(_,S,T)}e("getOwnMetadata",tt);function mt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),se(_,S)}e("getMetadataKeys",mt);function Rt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),Ne(_,S)}e("getOwnMetadataKeys",Rt);function I(_,S,T){if(!He(S))throw new TypeError;if(Q(T)||(T=yr(T)),!He(S))throw new TypeError;Q(T)||(T=yr(T));var V=bs(S,T,!1);return Q(V)?!1:V.OrdinaryDeleteMetadata(_,S,T)}e("deleteMetadata",I);function E(_,S){for(var T=_.length-1;T>=0;--T){var V=_[T],le=V(S);if(!Q(le)&&!ot(le)){if(!uh(le))throw new TypeError;S=le}}return S}function k(_,S,T,V){for(var le=_.length-1;le>=0;--le){var ct=_[le],nt=ct(S,T,V);if(!Q(nt)&&!ot(nt)){if(!He(nt))throw new TypeError;V=nt}}return V}function x(_,S,T){var V=b(_,S,T);if(V)return!0;var le=Ju(S);return ot(le)?!1:x(_,le,T)}function b(_,S,T){var V=bs(S,T,!1);return Q(V)?!1:oh(V.OrdinaryHasOwnMetadata(_,S,T))}function j(_,S,T){var V=b(_,S,T);if(V)return U(_,S,T);var le=Ju(S);if(!ot(le))return j(_,le,T)}function U(_,S,T){var V=bs(S,T,!1);if(!Q(V))return V.OrdinaryGetOwnMetadata(_,S,T)}function Ce(_,S,T,V){var le=bs(T,V,!0);le.OrdinaryDefineOwnMetadata(_,S,T,V)}function se(_,S){var T=Ne(_,S),V=Ju(_);if(V===null)return T;var le=se(V,S);if(le.length<=0)return T;if(T.length<=0)return le;for(var ct=new C,nt=[],je=0,W=T;je<W.length;je++){var ee=W[je],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}for(var ie=0,Be=le;ie<Be.length;ie++){var ee=Be[ie],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}return nt}function Ne(_,S){var T=bs(_,S,!1);return T?T.OrdinaryOwnMetadataKeys(_,S):[]}function Ue(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function Q(_){return _===void 0}function ot(_){return _===null}function Rn(_){return typeof _=="symbol"}function He(_){return typeof _=="object"?_!==null:typeof _=="function"}function rt(_,S){switch(Ue(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var T="string",V=lh(_,s);if(V!==void 0){var le=V.call(_,T);if(He(le))throw new TypeError;return le}return K0(_)}function K0(_,S){var T,V;{var le=_.toString;if(vo(le)){var V=le.call(_);if(!He(V))return V}var T=_.valueOf;if(vo(T)){var V=T.call(_);if(!He(V))return V}}throw new TypeError}function oh(_){return!!_}function W0(_){return""+_}function yr(_){var S=rt(_);return Rn(S)?S:W0(S)}function ch(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function vo(_){return typeof _=="function"}function uh(_){return typeof _=="function"}function z0(_){switch(Ue(_)){case 3:return!0;case 4:return!0;default:return!1}}function Gu(_,S){return _===S||_!==_&&S!==S}function lh(_,S){var T=_[S];if(T!=null){if(!vo(T))throw new TypeError;return T}}function dh(_){var S=lh(_,a);if(!vo(S))throw new TypeError;var T=S.call(_);if(!He(T))throw new TypeError;return T}function fh(_){return _.value}function hh(_){var S=_.next();return S.done?!1:S}function ph(_){var S=_.return;S&&S.call(_)}function Ju(_){var S=Object.getPrototypeOf(_);if(typeof _!="function"||_===m||S!==m)return S;var T=_.prototype,V=T&&Object.getPrototypeOf(T);if(V==null||V===Object.prototype)return S;var le=V.constructor;return typeof le!="function"||le===_?S:le}function G0(){var _;!Q(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=X0(t.Reflect));var S,T,V,le=new p,ct={registerProvider:nt,getProvider:W,setProvider:re};return ct;function nt(ie){if(!Object.isExtensible(ct))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===ie:break;case Q(S):S=ie;break;case S===ie:break;case Q(T):T=ie;break;case T===ie:break;default:V===void 0&&(V=new C),V.add(ie);break}}function je(ie,Be){if(!Q(S)){if(S.isProviderFor(ie,Be))return S;if(!Q(T)){if(T.isProviderFor(ie,Be))return S;if(!Q(V))for(var Fe=dh(V);;){var Xe=hh(Fe);if(!Xe)return;var Yt=fh(Xe);if(Yt.isProviderFor(ie,Be))return ph(Fe),Yt}}}if(!Q(_)&&_.isProviderFor(ie,Be))return _}function W(ie,Be){var Fe=le.get(ie),Xe;return Q(Fe)||(Xe=Fe.get(Be)),Q(Xe)&&(Xe=je(ie,Be),Q(Xe)||(Q(Fe)&&(Fe=new B,le.set(ie,Fe)),Fe.set(Be,Xe))),Xe}function ee(ie){if(Q(ie))throw new TypeError;return S===ie||T===ie||!Q(V)&&V.has(ie)}function re(ie,Be,Fe){if(!ee(Fe))throw new Error("Metadata provider not registered.");var Xe=W(ie,Be);if(Xe!==Fe){if(!Q(Xe))return!1;var Yt=le.get(ie);Q(Yt)&&(Yt=new B,le.set(ie,Yt)),Yt.set(Be,Fe)}return!0}}function J0(){var _;return!Q(g)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[g]),Q(_)&&(_=G0()),!Q(g)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function Y0(_){var S=new p,T={isProviderFor:function(ee,re){var ie=S.get(ee);return Q(ie)?!1:ie.has(re)},OrdinaryDefineOwnMetadata:nt,OrdinaryHasOwnMetadata:le,OrdinaryGetOwnMetadata:ct,OrdinaryOwnMetadataKeys:je,OrdinaryDeleteMetadata:W};return A.registerProvider(T),T;function V(ee,re,ie){var Be=S.get(ee),Fe=!1;if(Q(Be)){if(!ie)return;Be=new B,S.set(ee,Be),Fe=!0}var Xe=Be.get(re);if(Q(Xe)){if(!ie)return;if(Xe=new B,Be.set(re,Xe),!_.setProvider(ee,re,T))throw Be.delete(re),Fe&&S.delete(ee),new Error("Wrong provider for target.")}return Xe}function le(ee,re,ie){var Be=V(re,ie,!1);return Q(Be)?!1:oh(Be.has(ee))}function ct(ee,re,ie){var Be=V(re,ie,!1);if(!Q(Be))return Be.get(ee)}function nt(ee,re,ie,Be){var Fe=V(ie,Be,!0);Fe.set(ee,re)}function je(ee,re){var ie=[],Be=V(ee,re,!1);if(Q(Be))return ie;for(var Fe=Be.keys(),Xe=dh(Fe),Yt=0;;){var mh=hh(Xe);if(!mh)return ie.length=Yt,ie;var rv=fh(mh);try{ie[Yt]=rv}catch(nv){try{ph(Xe)}finally{throw nv}}Yt++}}function W(ee,re,ie){var Be=V(re,ie,!1);if(Q(Be)||!Be.delete(ee))return!1;if(Be.size===0){var Fe=S.get(re);Q(Fe)||(Fe.delete(ie),Fe.size===0&&S.delete(Fe))}return!0}}function X0(_){var S=_.defineMetadata,T=_.hasOwnMetadata,V=_.getOwnMetadata,le=_.getOwnMetadataKeys,ct=_.deleteMetadata,nt=new p,je={isProviderFor:function(W,ee){var re=nt.get(W);return!Q(re)&&re.has(ee)?!0:le(W,ee).length?(Q(re)&&(re=new C,nt.set(W,re)),re.add(ee),!0):!1},OrdinaryDefineOwnMetadata:S,OrdinaryHasOwnMetadata:T,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:le,OrdinaryDeleteMetadata:ct};return je}function bs(_,S,T){var V=A.getProvider(_,S);if(!Q(V))return V;if(T){if(A.setProvider(_,S,O))return O;throw new Error("Illegal state.")}}function Q0(){var _={},S=[],T=function(){function je(W,ee,re){this._index=0,this._keys=W,this._values=ee,this._selector=re}return je.prototype["@@iterator"]=function(){return this},je.prototype[a]=function(){return this},je.prototype.next=function(){var W=this._index;if(W>=0&&W<this._keys.length){var ee=this._selector(this._keys[W],this._values[W]);return W+1>=this._keys.length?(this._index=-1,this._keys=S,this._values=S):this._index++,{value:ee,done:!1}}return{value:void 0,done:!0}},je.prototype.throw=function(W){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),W},je.prototype.return=function(W){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:W,done:!0}},je}(),V=function(){function je(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(je.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),je.prototype.has=function(W){return this._find(W,!1)>=0},je.prototype.get=function(W){var ee=this._find(W,!1);return ee>=0?this._values[ee]:void 0},je.prototype.set=function(W,ee){var re=this._find(W,!0);return this._values[re]=ee,this},je.prototype.delete=function(W){var ee=this._find(W,!1);if(ee>=0){for(var re=this._keys.length,ie=ee+1;ie<re;ie++)this._keys[ie-1]=this._keys[ie],this._values[ie-1]=this._values[ie];return this._keys.length--,this._values.length--,Gu(W,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},je.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},je.prototype.keys=function(){return new T(this._keys,this._values,le)},je.prototype.values=function(){return new T(this._keys,this._values,ct)},je.prototype.entries=function(){return new T(this._keys,this._values,nt)},je.prototype["@@iterator"]=function(){return this.entries()},je.prototype[a]=function(){return this.entries()},je.prototype._find=function(W,ee){if(!Gu(this._cacheKey,W)){this._cacheIndex=-1;for(var re=0;re<this._keys.length;re++)if(Gu(this._keys[re],W)){this._cacheIndex=re;break}}return this._cacheIndex<0&&ee&&(this._cacheIndex=this._keys.length,this._keys.push(W),this._values.push(void 0)),this._cacheIndex},je}();return V;function le(je,W){return je}function ct(je,W){return W}function nt(je,W){return[je,W]}}function ev(){var _=function(){function S(){this._map=new B}return Object.defineProperty(S.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),S.prototype.has=function(T){return this._map.has(T)},S.prototype.add=function(T){return this._map.set(T,T),this},S.prototype.delete=function(T){return this._map.delete(T)},S.prototype.clear=function(){this._map.clear()},S.prototype.keys=function(){return this._map.keys()},S.prototype.values=function(){return this._map.keys()},S.prototype.entries=function(){return this._map.entries()},S.prototype["@@iterator"]=function(){return this.keys()},S.prototype[a]=function(){return this.keys()},S}();return _}function tv(){var _=16,S=f.create(),T=V();return function(){function W(){this._key=V()}return W.prototype.has=function(ee){var re=le(ee,!1);return re!==void 0?f.has(re,this._key):!1},W.prototype.get=function(ee){var re=le(ee,!1);return re!==void 0?f.get(re,this._key):void 0},W.prototype.set=function(ee,re){var ie=le(ee,!0);return ie[this._key]=re,this},W.prototype.delete=function(ee){var re=le(ee,!1);return re!==void 0?delete re[this._key]:!1},W.prototype.clear=function(){this._key=V()},W}();function V(){var W;do W="@@WeakMap@@"+je();while(f.has(S,W));return S[W]=!0,W}function le(W,ee){if(!n.call(W,T)){if(!ee)return;Object.defineProperty(W,T,{value:f.create()})}return W[T]}function ct(W,ee){for(var re=0;re<ee;++re)W[re]=Math.random()*255|0;return W}function nt(W){if(typeof Uint8Array=="function"){var ee=new Uint8Array(W);return typeof crypto<"u"?crypto.getRandomValues(ee):typeof msCrypto<"u"?msCrypto.getRandomValues(ee):ct(ee,W),ee}return ct(new Array(W),W)}function je(){var W=nt(_);W[6]=W[6]&79|64,W[8]=W[8]&191|128;for(var ee="",re=0;re<_;++re){var ie=W[re];(re===4||re===6||re===8)&&(ee+="-"),ie<16&&(ee+="0"),ee+=ie.toString(16).toLowerCase()}return ee}}function Yu(_){return _.__=void 0,delete _.__,_}})})(Nh||(Nh={}));/*!
19
19
  * MIT License
20
20
  *
21
21
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -38,9 +38,9 @@ and limitations under the License.
38
38
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
39
  * SOFTWARE.
40
40
  *
41
- */const rw="[object ArrayBuffer]";class q{static isArrayBuffer(e){return Object.prototype.toString.call(e)===rw}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=q.toUint8Array(e),i=q.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const a of t)n+=a.byteLength;const i=new Uint8Array(n);let s=0;for(const a of t){const o=this.toUint8Array(a);i.set(o,s),s+=o.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const rl="string",nw=/^[0-9a-f]+$/i,iw=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,sw=/^[a-zA-Z0-9-_]+$/;class Nh{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){const t=q.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class gr{static toString(e,t=!1){const n=q.toArrayBuffer(e),i=new DataView(n);let s="";for(let a=0;a<n.byteLength;a+=2){const o=i.getUint16(a,t);s+=String.fromCharCode(o)}return s}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}}class te{static isHex(e){return typeof e===rl&&nw.test(e)}static isBase64(e){return typeof e===rl&&iw.test(e)}static isBase64Url(e){return typeof e===rl&&sw.test(e)}static ToString(e,t="utf8"){const n=q.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return gr.toString(n,!0);case"utf16":case"utf16be":return gr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return gr.fromString(e,!0);case"utf16":case"utf16be":return gr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=q.toUint8Array(e);if(typeof btoa<"u"){const n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=te.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Nh.fromString(e);case"utf16":case"utf16be":return gr.fromString(e);case"utf16le":case"usc2":return gr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=te.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Nh.toString(e);case"utf16":case"utf16be":return gr.toString(e);case"utf16le":case"usc2":return gr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){const t=q.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){const t=q.toUint8Array(e);let n="";const i=t.length;for(let s=0;s<i;s++){const a=t[s];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i=i+2){const s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return gr.toString(e,t)}static FromUtf16String(e,t=!1){return gr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}te.DEFAULT_UTF8_ENCODING="utf8";function aw(...r){const e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e);let n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)t[n++]=s}),t.buffer}function Zy(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}/*!
41
+ */const nw="[object ArrayBuffer]";class q{static isArrayBuffer(e){return Object.prototype.toString.call(e)===nw}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=q.toUint8Array(e),i=q.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const a of t)n+=a.byteLength;const i=new Uint8Array(n);let s=0;for(const a of t){const o=this.toUint8Array(a);i.set(o,s),s+=o.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const nl="string",iw=/^[0-9a-f]+$/i,sw=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,aw=/^[a-zA-Z0-9-_]+$/;class Bh{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){const t=q.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class gr{static toString(e,t=!1){const n=q.toArrayBuffer(e),i=new DataView(n);let s="";for(let a=0;a<n.byteLength;a+=2){const o=i.getUint16(a,t);s+=String.fromCharCode(o)}return s}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}}class te{static isHex(e){return typeof e===nl&&iw.test(e)}static isBase64(e){return typeof e===nl&&sw.test(e)}static isBase64Url(e){return typeof e===nl&&aw.test(e)}static ToString(e,t="utf8"){const n=q.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return gr.toString(n,!0);case"utf16":case"utf16be":return gr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return gr.fromString(e,!0);case"utf16":case"utf16be":return gr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=q.toUint8Array(e);if(typeof btoa<"u"){const n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=te.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Bh.fromString(e);case"utf16":case"utf16be":return gr.fromString(e);case"utf16le":case"usc2":return gr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=te.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Bh.toString(e);case"utf16":case"utf16be":return gr.toString(e);case"utf16le":case"usc2":return gr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){const t=q.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){const t=q.toUint8Array(e);let n="";const i=t.length;for(let s=0;s<i;s++){const a=t[s];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i=i+2){const s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return gr.toString(e,t)}static FromUtf16String(e,t=!1){return gr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}te.DEFAULT_UTF8_ENCODING="utf8";function ow(...r){const e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e);let n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)t[n++]=s}),t.buffer}function My(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}/*!
42
42
  Copyright (c) Peculiar Ventures, LLC
43
- */function Wi(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function ni(r,e,t=-1){const n=t;let i=r,s=0,a=Math.pow(2,e);for(let o=1;o<8;o++){if(r<a){let c;if(n<0)c=new ArrayBuffer(o),s=o;else{if(n<o)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}const u=new Uint8Array(c);for(let f=o-1;f>=0;f--){const m=Math.pow(2,f*e);u[s-f-1]=Math.floor(i/m),i-=u[s-f-1]*m}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function Pl(...r){let e=0,t=0;for(const s of r)e+=s.length;const n=new ArrayBuffer(e),i=new Uint8Array(n);for(const s of r)i.set(s,t),t+=s.length;return i}function My(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const o=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(o||c)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let o=0;o<this.valueHex.byteLength;o++)t[o]=0;t[0]=r[0]&128;const n=Wi(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let o=0;o<this.valueHex.byteLength;o++)s[o]=r[o];return s[0]&=127,Wi(s,8)-n}function ow(r){const e=r<0?r*-1:r;let t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){const a=t-e,o=ni(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let i=ni(e,8,n),s=new Uint8Array(i);if(s[0]&128){const a=i.slice(0),o=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let c=0;c<a.byteLength;c++)s[c+1]=o[c];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function cw(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function Pt(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,i=new Array(n);for(let a=0;a<n;a++)i[a]="0";return i.join("").concat(t)}/*!
43
+ */function Wi(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function ni(r,e,t=-1){const n=t;let i=r,s=0,a=Math.pow(2,e);for(let o=1;o<8;o++){if(r<a){let c;if(n<0)c=new ArrayBuffer(o),s=o;else{if(n<o)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}const u=new Uint8Array(c);for(let f=o-1;f>=0;f--){const m=Math.pow(2,f*e);u[s-f-1]=Math.floor(i/m),i-=u[s-f-1]*m}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function $l(...r){let e=0,t=0;for(const s of r)e+=s.length;const n=new ArrayBuffer(e),i=new Uint8Array(n);for(const s of r)i.set(s,t),t+=s.length;return i}function Uy(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const o=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(o||c)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let o=0;o<this.valueHex.byteLength;o++)t[o]=0;t[0]=r[0]&128;const n=Wi(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let o=0;o<this.valueHex.byteLength;o++)s[o]=r[o];return s[0]&=127,Wi(s,8)-n}function cw(r){const e=r<0?r*-1:r;let t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){const a=t-e,o=ni(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let i=ni(e,8,n),s=new Uint8Array(i);if(s[0]&128){const a=i.slice(0),o=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let c=0;c<a.byteLength;c++)s[c+1]=o[c];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function uw(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function Pt(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,i=new Array(n);for(let a=0;a<n;a++)i[a]="0";return i.join("").concat(t)}/*!
44
44
  * Copyright (c) 2014, GMO GlobalSign
45
45
  * Copyright (c) 2015-2022, Peculiar Ventures
46
46
  * All rights reserved.
@@ -72,11 +72,11 @@ and limitations under the License.
72
72
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
73
73
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74
74
  *
75
- */function dc(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function yf(r){let e=0,t=0;for(let i=0;i<r.length;i++){const s=r[i];e+=s.byteLength}const n=new Uint8Array(e);for(let i=0;i<r.length;i++){const s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function Qr(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class iu{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return yf(this.items)}}const Ss=[new Uint8Array([1])],Bh="0123456789",nl="name",Rh="valueHexView",uw="isHexOnly",lw="idBlock",dw="tagClass",fw="tagNumber",hw="isConstructed",pw="fromBER",mw="toBER",yw="local",It="",pr=new ArrayBuffer(0),su=new Uint8Array(0),va="EndOfContent",Uy="OCTET STRING",Vy="BIT STRING";function jr(r){var e;return e=class extends r{constructor(...n){var i;super(...n);const s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?q.toUint8Array(s.valueHex):su}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){const a=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Qr(this,a,i,s))return-1;const o=i+s;return this.valueHexView=a.subarray(i,o),this.valueHexView.length?(this.blockLength=s,o):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",pr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:te.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class gi{constructor({blockLength:e=0,error:t=It,warnings:n=[],valueBeforeDecode:i=su}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=q.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:te.ToHex(this.valueBeforeDecodeView)}}}gi.NAME="baseBlock";class St extends gi{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}St.NAME="valueBlock";class Ly extends jr(gi){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?q.toUint8Array(e.valueHex):su,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",pr}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){const i=ni(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,o=new Uint8Array(a+1);if(o[0]=t|31,!e){for(let c=0;c<a-1;c++)o[c+1]=s[c]|128;o[a]=s[a-1]}return o.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const o=s[0]&31;if(o!==31)this.tagNumber=o,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;s[c]&128;){if(u[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;const B=new Uint8Array(f);for(let C=0;C<u.length;C++)B[C]=u[C];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=s[c]&127;const m=new Uint8Array(c);for(let B=0;B<c;B++)m[B]=u[B];u=this.valueHexView=new Uint8Array(c),u.set(m),this.blockLength<=9?this.tagNumber=Wi(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}Ly.NAME="identificationBlock";class qy extends gi{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;const a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const o=t+1,c=i.subarray(o,o+a);return c[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Wi(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){const i=ni(this.length,8);if(i.byteLength>127)return this.error="Too big length",pr;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)n[a+1]=s[a];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}qy.NAME="lengthBlock";const X={};class ft extends gi{constructor({name:e=It,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Ly(i),this.lenBlock=new qy(i),this.valueBlock=s?new s(i):new St(i)}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){const n=t||new iu;t||Hy(this);const i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(e);n.write(a),n.write(s)}return t?pr:n.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():te.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${te.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),n=e.toBER();return cw(t,n)}}ft.NAME="BaseBlock";function Hy(r){if(r instanceof X.Constructed)for(const e of r.valueBlock.value)Hy(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class gf extends ft{constructor({value:e=It,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}gf.NAME="BaseStringBlock";class Fy extends jr(St){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Fy.NAME="PrimitiveValueBlock";var Ky;class Xa extends ft{constructor(e={}){super(e,Fy),this.idBlock.isConstructed=!1}}Ky=Xa;X.Primitive=Ky;Xa.NAME="PRIMITIVE";function gw(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function us(r,e=0,t=r.length){const n=e;let i=new ft({},St);const s=new gi;if(!Qr(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let o=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),o===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=o,t-=i.idBlock.blockLength,o=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),o===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=o,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let c=ft;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};c=X.EndOfContent;break;case 1:c=X.Boolean;break;case 2:c=X.Integer;break;case 3:c=X.BitString;break;case 4:c=X.OctetString;break;case 5:c=X.Null;break;case 6:c=X.ObjectIdentifier;break;case 10:c=X.Enumerated;break;case 12:c=X.Utf8String;break;case 13:c=X.RelativeObjectIdentifier;break;case 14:c=X.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:c=X.Sequence;break;case 17:c=X.Set;break;case 18:c=X.NumericString;break;case 19:c=X.PrintableString;break;case 20:c=X.TeletexString;break;case 21:c=X.VideotexString;break;case 22:c=X.IA5String;break;case 23:c=X.UTCTime;break;case 24:c=X.GeneralizedTime;break;case 25:c=X.GraphicString;break;case 26:c=X.VisibleString;break;case 27:c=X.GeneralString;break;case 28:c=X.UniversalString;break;case 29:c=X.CharacterString;break;case 30:c=X.BmpString;break;case 31:c=X.DATE;break;case 32:c=X.TimeOfDay;break;case 33:c=X.DateTime;break;case 34:c=X.Duration;break;default:{const u=i.idBlock.isConstructed?new X.Constructed:new X.Primitive;u.idBlock=i.idBlock,u.lenBlock=i.lenBlock,u.warnings=i.warnings,i=u}}break;case 2:case 3:case 4:default:c=i.idBlock.isConstructed?X.Constructed:X.Primitive}return i=gw(i,c),o=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:o,result:i}}function Bi(r){if(!r.byteLength){const e=new ft({},St);return e.error="Input buffer has zero length",{offset:-1,result:e}}return us(q.toUint8Array(r).slice(),0,r.byteLength)}function vw(r,e){return r?1:e}class mn extends St{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;vw(this.isIndefiniteForm,n)>0;){const a=us(i,s,n);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,n-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===va)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===va?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const n=t||new iu;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?pr:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}mn.NAME="ConstructedValueBlock";var Wy;class Ct extends ft{constructor(e={}){super(e,mn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
75
+ */function fc(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function gf(r){let e=0,t=0;for(let i=0;i<r.length;i++){const s=r[i];e+=s.byteLength}const n=new Uint8Array(e);for(let i=0;i<r.length;i++){const s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function Qr(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class su{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return gf(this.items)}}const Ss=[new Uint8Array([1])],Rh="0123456789",il="name",Ph="valueHexView",lw="isHexOnly",dw="idBlock",fw="tagClass",hw="tagNumber",pw="isConstructed",mw="fromBER",yw="toBER",gw="local",It="",pr=new ArrayBuffer(0),au=new Uint8Array(0),va="EndOfContent",Vy="OCTET STRING",Ly="BIT STRING";function jr(r){var e;return e=class extends r{constructor(...n){var i;super(...n);const s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?q.toUint8Array(s.valueHex):au}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){const a=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Qr(this,a,i,s))return-1;const o=i+s;return this.valueHexView=a.subarray(i,o),this.valueHexView.length?(this.blockLength=s,o):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",pr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:te.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class gi{constructor({blockLength:e=0,error:t=It,warnings:n=[],valueBeforeDecode:i=au}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=q.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:te.ToHex(this.valueBeforeDecodeView)}}}gi.NAME="baseBlock";class St extends gi{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}St.NAME="valueBlock";class qy extends jr(gi){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?q.toUint8Array(e.valueHex):au,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",pr}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){const i=ni(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,o=new Uint8Array(a+1);if(o[0]=t|31,!e){for(let c=0;c<a-1;c++)o[c+1]=s[c]|128;o[a]=s[a-1]}return o.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const o=s[0]&31;if(o!==31)this.tagNumber=o,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;s[c]&128;){if(u[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;const B=new Uint8Array(f);for(let C=0;C<u.length;C++)B[C]=u[C];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=s[c]&127;const m=new Uint8Array(c);for(let B=0;B<c;B++)m[B]=u[B];u=this.valueHexView=new Uint8Array(c),u.set(m),this.blockLength<=9?this.tagNumber=Wi(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}qy.NAME="identificationBlock";class Hy extends gi{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;const a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const o=t+1,c=i.subarray(o,o+a);return c[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Wi(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){const i=ni(this.length,8);if(i.byteLength>127)return this.error="Too big length",pr;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)n[a+1]=s[a];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Hy.NAME="lengthBlock";const X={};class ft extends gi{constructor({name:e=It,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new qy(i),this.lenBlock=new Hy(i),this.valueBlock=s?new s(i):new St(i)}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){const n=t||new su;t||Fy(this);const i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(e);n.write(a),n.write(s)}return t?pr:n.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():te.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${te.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),n=e.toBER();return uw(t,n)}}ft.NAME="BaseBlock";function Fy(r){if(r instanceof X.Constructed)for(const e of r.valueBlock.value)Fy(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class vf extends ft{constructor({value:e=It,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}vf.NAME="BaseStringBlock";class Ky extends jr(St){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Ky.NAME="PrimitiveValueBlock";var Wy;class Xa extends ft{constructor(e={}){super(e,Ky),this.idBlock.isConstructed=!1}}Wy=Xa;X.Primitive=Wy;Xa.NAME="PRIMITIVE";function vw(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function us(r,e=0,t=r.length){const n=e;let i=new ft({},St);const s=new gi;if(!Qr(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let o=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),o===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=o,t-=i.idBlock.blockLength,o=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),o===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=o,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let c=ft;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};c=X.EndOfContent;break;case 1:c=X.Boolean;break;case 2:c=X.Integer;break;case 3:c=X.BitString;break;case 4:c=X.OctetString;break;case 5:c=X.Null;break;case 6:c=X.ObjectIdentifier;break;case 10:c=X.Enumerated;break;case 12:c=X.Utf8String;break;case 13:c=X.RelativeObjectIdentifier;break;case 14:c=X.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:c=X.Sequence;break;case 17:c=X.Set;break;case 18:c=X.NumericString;break;case 19:c=X.PrintableString;break;case 20:c=X.TeletexString;break;case 21:c=X.VideotexString;break;case 22:c=X.IA5String;break;case 23:c=X.UTCTime;break;case 24:c=X.GeneralizedTime;break;case 25:c=X.GraphicString;break;case 26:c=X.VisibleString;break;case 27:c=X.GeneralString;break;case 28:c=X.UniversalString;break;case 29:c=X.CharacterString;break;case 30:c=X.BmpString;break;case 31:c=X.DATE;break;case 32:c=X.TimeOfDay;break;case 33:c=X.DateTime;break;case 34:c=X.Duration;break;default:{const u=i.idBlock.isConstructed?new X.Constructed:new X.Primitive;u.idBlock=i.idBlock,u.lenBlock=i.lenBlock,u.warnings=i.warnings,i=u}}break;case 2:case 3:case 4:default:c=i.idBlock.isConstructed?X.Constructed:X.Primitive}return i=vw(i,c),o=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:o,result:i}}function Bi(r){if(!r.byteLength){const e=new ft({},St);return e.error="Input buffer has zero length",{offset:-1,result:e}}return us(q.toUint8Array(r).slice(),0,r.byteLength)}function bw(r,e){return r?1:e}class mn extends St{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;bw(this.isIndefiniteForm,n)>0;){const a=us(i,s,n);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,n-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===va)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===va?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const n=t||new su;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?pr:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}mn.NAME="ConstructedValueBlock";var zy;class Ct extends ft{constructor(e={}){super(e,mn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
76
76
  `).map(i=>` ${i}`).join(`
77
77
  `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
78
78
  ${e.join(`
79
- `)}`:`${t} :`}}Wy=Ct;X.Constructed=Wy;Ct.NAME="CONSTRUCTED";class zy extends St{fromBER(e,t,n){return t}toBER(e){return pr}}zy.override="EndOfContentValueBlock";var Gy;class vf extends ft{constructor(e={}){super(e,zy),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Gy=vf;X.EndOfContent=Gy;vf.NAME=va;var Jy;class ii extends ft{constructor(e={}){super(e,St),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const i=new Uint8Array(n);i[0]=5,i[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}Jy=ii;X.Null=Jy;ii.NAME="NULL";class Yy extends jr(St){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=q.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const i=q.toUint8Array(e);return Qr(this,i,t,n)?(this.valueHexView=i.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,My.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Yy.NAME="BooleanValueBlock";var Xy;let au=class extends ft{constructor(e={}){super(e,Yy),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Xy=au;X.Boolean=Xy;au.NAME="BOOLEAN";class Qy extends jr(mn){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=mn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===va){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Uy)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?mn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Qy.NAME="OctetStringValueBlock";var eg;let Jn=class tg extends ft{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Qy),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const a=us(s,0,s.byteLength);a.offset!==-1&&a.offset===n&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ct.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${te.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof tg&&e.push(t.valueBlock.valueHexView);return q.concat(e)}};eg=Jn;X.OctetString=eg;Jn.NAME=Uy;class rg extends jr(mn){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let i=-1;if(this.isConstructed){if(i=mn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(const o of this.value){const c=o.constructor.NAME;if(c===va){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Vy)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=o.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return i}const s=q.toUint8Array(e);if(!Qr(this,s,t,n))return-1;const a=s.subarray(t,t+n);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const o=a.subarray(1);try{if(o.byteLength){const c=us(o,0,o.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,t+n}toBER(e,t){if(this.isConstructed)return mn.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return pr;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}rg.NAME="BitStringValueBlock";var ng;let Yn=class extends ft{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},rg),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ct.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const i of t)e.push(i.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};ng=Yn;X.BitString=ng;Yn.NAME=Vy;var ig;function bw(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),i=new Uint8Array(e);let s=n.slice(0);const a=s.length-1,o=i.slice(0),c=o.length-1;let u=0;const f=c<a?a:c;let m=0;for(let B=f;B>=0;B--,m++){switch(!0){case m<o.length:u=s[a-m]+o[c-m]+t[0];break;default:u=s[a-m]+t[0]}switch(t[0]=u/10,!0){case m>=s.length:s=Pl(new Uint8Array([u%10]),s);break;default:s[a-m]=u%10}}return t[0]>0&&(s=Pl(t,s)),s}function Ph(r){if(r>=Ss.length)for(let e=Ss.length;e<=r;e++){const t=new Uint8Array([0]);let n=Ss[e-1].slice(0);for(let i=n.length-1;i>=0;i--){const s=new Uint8Array([(n[i]<<1)+t[0]]);t[0]=s[0]/10,n[i]=s[0]%10}t[0]>0&&(n=Pl(t,n)),Ss.push(n)}return Ss[r]}function xw(r,e){let t=0;const n=new Uint8Array(r),i=new Uint8Array(e),s=n.slice(0),a=s.length-1,o=i.slice(0),c=o.length-1;let u,f=0;for(let m=c;m>=0;m--,f++)switch(u=s[a-f]-o[c-f]-t,!0){case u<0:t=1,s[a-f]=u+10;break;default:t=0,s[a-f]=u}if(t>0)for(let m=a-c+1;m>=0;m--,f++)if(u=s[a-f]-t,u<0)t=1,s[a-f]=u+10;else{t=0,s[a-f]=u;break}return s.slice()}class bf extends jr(St){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=My.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(ow(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,i=0){const s=this.fromBER(e,t,n);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){const i=super.fromBER(e,t,n);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),n=0,i;const s=this.valueHexView;let a="",o=!1;for(let c=s.byteLength-1;c>=0;c--){i=s[c];for(let u=0;u<8;u++){if((i&1)===1)switch(n){case e:t=xw(Ph(n),t),a="-";break;default:t=bw(t,Ph(n))}n++,i>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Bh.charAt(t[c]));return o===!1&&(a+=Bh.charAt(0)),a}}ig=bf;bf.NAME="IntegerValueBlock";Object.defineProperty(ig.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var sg;class wr extends ft{constructor(e={}){super(e,bf),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return dc(),BigInt(this.valueBlock.toString())}static fromBigInt(e){dc();const t=BigInt(e),n=new iu,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(te.FromHex(i));if(t<0){const o=new Uint8Array(s.length+(s[0]&128?1:0));o[0]|=128;const u=BigInt(`0x${te.ToHex(o)}`)+t,f=q.toUint8Array(te.FromHex(u.toString(16)));f[0]|=128,n.write(f)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new wr({valueHex:n.final()})}convertToDER(){const e=new wr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new wr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}sg=wr;X.Integer=sg;wr.NAME="INTEGER";var ag;class ou extends wr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}ag=ou;X.Enumerated=ag;ou.NAME="ENUMERATED";class $l extends jr(St){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=s[o]&127,this.blockLength++,!!(s[o]&128));o++);const a=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength;o++)a[o]=this.valueHexView[o];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Wi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){dc();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(t.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ni(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",pr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=te.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}$l.NAME="sidBlock";class og extends St{constructor({value:e=It,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new $l;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,pr;t.push(i)}return yf(t)}fromString(e){this.value=[];let t=0,n=0,i="",s=!1;do if(n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1,s){const a=this.value[0];let o=0;switch(a.valueDec){case 0:break;case 1:o=40;break;case 2:o=80;break;default:this.value=[];return}const c=parseInt(i,10);if(isNaN(c))return;a.valueDec=c+o,s=!1}else{const a=new $l;if(i>Number.MAX_SAFE_INTEGER){dc();const o=BigInt(i);a.valueBigInt=o}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t?(i=`{${i}}`,this.value[n].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}og.NAME="ObjectIdentifierValueBlock";var cg;class cu extends ft{constructor(e={}){super(e,og),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}cg=cu;X.ObjectIdentifier=cg;cu.NAME="OBJECT IDENTIFIER";class Dl extends jr(gi){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=s[o]&127,this.blockLength++,!!(s[o]&128));o++);const a=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength;o++)a[o]=this.valueHexView[o];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Wi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ni(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",pr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=te.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Dl.NAME="relativeSidBlock";class ug extends St{constructor({value:e=It,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Dl;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,t){const n=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,pr;n.push(s)}return yf(n)}fromString(e){this.value=[];let t=0,n=0,i="";do{n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1;const s=new Dl;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}ug.NAME="RelativeObjectIdentifierValueBlock";var lg;class xf extends ft{constructor(e={}){super(e,ug),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}lg=xf;X.RelativeObjectIdentifier=lg;xf.NAME="RelativeObjectIdentifier";var dg;class Lr extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}dg=Lr;X.Sequence=dg;Lr.NAME="SEQUENCE";var fg;let qr=class extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};fg=qr;X.Set=fg;qr.NAME="SET";class hg extends jr(St){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=It}toJSON(){return{...super.toJSON(),value:this.value}}}hg.NAME="StringValueBlock";class pg extends hg{}pg.NAME="SimpleStringValueBlock";class Mt extends gf{constructor({...e}={}){super(e,pg)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,q.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}}Mt.NAME="SIMPLE STRING";class mg extends Mt{fromBuffer(e){this.valueBlock.valueHexView=q.toUint8Array(e);try{this.valueBlock.value=te.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=te.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(te.FromUtf8String(e)),this.valueBlock.value=e}}mg.NAME="Utf8StringValueBlock";var yg;class en extends mg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}yg=en;X.Utf8String=yg;en.NAME="UTF8String";class gg extends Mt{fromBuffer(e){this.valueBlock.value=te.ToUtf16String(e),this.valueBlock.valueHexView=q.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(te.FromUtf16String(e))}}gg.NAME="BmpStringValueBlock";var vg;class uu extends gg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}vg=uu;X.BmpString=vg;uu.NAME="BMPString";class bg extends Mt{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let i=0;i<t;i++){const s=ni(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;const o=4-a.length;for(let c=a.length-1;c>=0;c--)n[i*4+c+o]=a[c]}this.valueBlock.value=e}}bg.NAME="UniversalStringValueBlock";var xg;class lu extends bg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}xg=lu;X.UniversalString=xg;lu.NAME="UniversalString";var _g;class du extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}_g=du;X.NumericString=_g;du.NAME="NumericString";var wg;class fu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}wg=fu;X.PrintableString=wg;fu.NAME="PrintableString";var kg;class hu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}kg=hu;X.TeletexString=kg;hu.NAME="TeletexString";var Sg;class pu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Sg=pu;X.VideotexString=Sg;pu.NAME="VideotexString";var Ag;class mu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Ag=mu;X.IA5String=Ag;mu.NAME="IA5String";var Og;class yu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Og=yu;X.GraphicString=Og;yu.NAME="GraphicString";var Eg;class Qa extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Eg=Qa;X.VisibleString=Eg;Qa.NAME="VisibleString";var Ig;class gu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ig=gu;X.GeneralString=Ig;gu.NAME="GeneralString";var Cg;class vu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Cg=vu;X.CharacterString=Cg;vu.NAME="CharacterString";var jg;class eo extends Qa{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,q.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=Pt(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Pt(this.month,2),t[2]=Pt(this.day,2),t[3]=Pt(this.hour,2),t[4]=Pt(this.minute,2),t[5]=Pt(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}jg=eo;X.UTCTime=jg;eo.NAME="UTCTime";var Tg;class bu extends eo{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",i="",s=0,a,o=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const m=new Number(e[e.length-1]);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let m=1,B=n.indexOf("+"),C="";if(B===-1&&(B=n.indexOf("-"),m=-1),B!==-1){if(C=n.substring(B+1),n=n.substring(0,B),C.length!==2&&C.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(C.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(o=m*p,C.length===4){if(p=parseInt(C.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=m*p}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){const m=new Number(`0${n.substring(u)}`);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");s=m.valueOf(),i=n.substring(0,u)}else i=n;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*s;this.minute=Math.floor(m),m=60*(m-this.minute),this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*s;this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const m=1e3*s;this.millisecond=Math.floor(m)}break;default:throw new Error("Wrong input string for conversion")}const f=a.exec(i);if(f===null)throw new Error("Wrong input string for conversion");for(let m=1;m<f.length;m++)switch(m){case 1:this.year=parseInt(f[m],10);break;case 2:this.month=parseInt(f[m],10);break;case 3:this.day=parseInt(f[m],10);break;case 4:this.hour=parseInt(f[m],10)+o;break;case 5:this.minute=parseInt(f[m],10)+c;break;case 6:this.second=parseInt(f[m],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const m=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=m.getUTCFullYear(),this.month=m.getUTCMonth(),this.day=m.getUTCDay(),this.hour=m.getUTCHours(),this.minute=m.getUTCMinutes(),this.second=m.getUTCSeconds(),this.millisecond=m.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(Pt(this.year,4)),t.push(Pt(this.month,2)),t.push(Pt(this.day,2)),t.push(Pt(this.hour,2)),t.push(Pt(this.minute,2)),t.push(Pt(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Pt(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Tg=bu;X.GeneralizedTime=Tg;bu.NAME="GeneralizedTime";var Ng;class _f extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Ng=_f;X.DATE=Ng;_f.NAME="DATE";var Bg;class wf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Bg=wf;X.TimeOfDay=Bg;wf.NAME="TimeOfDay";var Rg;class kf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Rg=kf;X.DateTime=Rg;kf.NAME="DateTime";var Pg;class Sf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Pg=Sf;X.Duration=Pg;Sf.NAME="Duration";var $g;class Af extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}$g=Af;X.TIME=$g;Af.NAME="TIME";class si{constructor({name:e=It,optional:t=!1}={}){this.name=e,this.optional=t}}class Of extends si{constructor({value:e=[],...t}={}){super(t),this.value=e}}class fc extends si{constructor({value:e=new si,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class _w{constructor({data:e=su}={}){this.dataView=q.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=q.toUint8Array(e)}fromBER(e,t,n){const i=t+n;return this.dataView=q.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}}function Vn(r,e,t){if(t instanceof Of){for(let s=0;s<t.value.length;s++)if(Vn(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(nl)&&(s.name=t.name),s}}if(t instanceof si)return t.hasOwnProperty(nl)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(lw in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(pw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(mw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(dw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(fw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(hw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(uw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(Rh in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:r};for(let o=0;o<s.length;o++)if(s[o]!==a[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(r[t.name]=e)),t instanceof X.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},o=t.valueBlock.value.length;if(o>0&&t.valueBlock.value[0]instanceof fc&&(o=e.valueBlock.value.length),o===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let c=!0;for(let u=0;u<t.valueBlock.value.length;u++)c=c&&(t.valueBlock.value[u].optional||!1);return c?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let c=0;c<o;c++)if(c-s>=e.valueBlock.value.length){if(t.valueBlock.value[c].optional===!1){const u={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof fc){if(a=Vn(r,e.valueBlock.value[c],t.valueBlock.value[0].value),a.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),a;if(nl in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};yw in t.valueBlock.value[0]&&t.valueBlock.value[0].local?u=e:u=r,typeof u[t.valueBlock.value[0].name]>"u"&&(u[t.valueBlock.value[0].name]=[]),u[t.valueBlock.value[0].name].push(e.valueBlock.value[c])}}else if(a=Vn(r,e.valueBlock.value[c-s],t.valueBlock.value[c]),a.verified===!1)if(t.valueBlock.value[c].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),a;if(a.verified===!1){const c={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&Rh in e.valueBlock){const s=us(e.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],a.name=t.name)),a}return Vn(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function ww(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=us(q.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Vn(t.result,t.result,e)}const Dg=Object.freeze(Object.defineProperty({__proto__:null,Any:si,BaseBlock:ft,BaseStringBlock:gf,BitString:Yn,BmpString:uu,Boolean:au,CharacterString:vu,Choice:Of,Constructed:Ct,DATE:_f,DateTime:kf,Duration:Sf,EndOfContent:vf,Enumerated:ou,GeneralString:gu,GeneralizedTime:bu,GraphicString:yu,HexBlock:jr,IA5String:mu,Integer:wr,Null:ii,NumericString:du,ObjectIdentifier:cu,OctetString:Jn,Primitive:Xa,PrintableString:fu,RawData:_w,RelativeObjectIdentifier:xf,Repeated:fc,Sequence:Lr,Set:qr,TIME:Af,TeletexString:hu,TimeOfDay:wf,UTCTime:eo,UniversalString:lu,Utf8String:en,ValueBlock:St,VideotexString:pu,ViewWriter:iu,VisibleString:Qa,compareSchema:Vn,fromBER:Bi,verifySchema:ww},Symbol.toStringTag,{value:"Module"}));var R;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(R||(R={}));var v;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(v||(v={}));class xu{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(q.isBufferSource(e))this.unusedBits=t,this.value=q.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Yn))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new Yn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Yn({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;const i=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class De{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):q.isBufferSource(e)?this.buffer=q.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Jn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Jn({valueHex:this.buffer})}toSchema(e){return new Jn({name:e})}}const kw={fromASN:r=>r instanceof ii?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ii;const e=Bi(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Sw={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new wr({value:+r})},Aw={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new ou({value:r})},Ke={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new wr({valueHex:r})},Ow={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Yn({valueHex:r})},Ew={fromASN:r=>r.valueBlock.toString(),toASN:r=>new cu({value:r})},Iw={fromASN:r=>r.valueBlock.value,toASN:r=>new au({value:r})},hc={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Jn({valueHex:r})},Cw={fromASN:r=>new De(r.getValue()),toASN:r=>r.toASN()};function zt(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Zg=zt(en),jw=zt(uu),Tw=zt(lu),Nw=zt(du),Bw=zt(fu),Rw=zt(hu),Pw=zt(pu),$w=zt(mu),Dw=zt(yu),Zw=zt(Qa),Mw=zt(gu),Uw=zt(vu),Vw={fromASN:r=>r.toDate(),toASN:r=>new eo({valueDate:r})},Lw={fromASN:r=>r.toDate(),toASN:r=>new bu({valueDate:r})},qw={fromASN:()=>null,toASN:()=>new ii};function Ef(r){switch(r){case v.Any:return kw;case v.BitString:return Ow;case v.BmpString:return jw;case v.Boolean:return Iw;case v.CharacterString:return Uw;case v.Enumerated:return Aw;case v.GeneralString:return Mw;case v.GeneralizedTime:return Lw;case v.GraphicString:return Dw;case v.IA5String:return $w;case v.Integer:return Sw;case v.Null:return qw;case v.NumericString:return Nw;case v.ObjectIdentifier:return Ew;case v.OctetString:return hc;case v.PrintableString:return Bw;case v.TeletexString:return Rw;case v.UTCTime:return Vw;case v.UniversalString:return Tw;case v.Utf8String:return Zg;case v.VideotexString:return Pw;case v.VisibleString:return Zw;default:return null}}function Vr(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Vr(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Mg(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Mg(t)}return!1}function Hw(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}class Fw{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:R.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),i=[];for(const s in n.items){const a=n.items[s],o=t?s:"";let c;if(typeof a.type=="number"){const f=v[a.type],m=Dg[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else Vr(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===R.Choice?c=new si({name:o}):(c=this.create(a.type,!1),c.name=o):c=new si({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const f=a.repeated==="set"?qr:Lr;c=new f({name:"",value:[new fc({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Vr(a.type)){const f=a.repeated?Ct:Xa;i.push(new f({name:o,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const f=!!a.repeated;let m=f?c:this.get(a.type,!0).schema;m="valueBlock"in m?m.valueBlock.value:m.value,i.push(new Ct({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else i.push(new Ct({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,i.push(c)}switch(n.type){case R.Sequence:return new Lr({value:i,name:""});case R.Set:return new qr({value:i,name:""});case R.Choice:return new Of({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const qt=new Fw,$=r=>e=>{let t;qt.has(e)?t=qt.get(e):(t=qt.createDefault(e),qt.set(e,t)),Object.assign(t,r)},h=r=>(e,t)=>{let n;qt.has(e.constructor)?n=qt.get(e.constructor):(n=qt.createDefault(e.constructor),qt.set(e.constructor,n));const i=Object.assign({},r);if(typeof i.type=="number"&&!i.converter){const s=Ef(r.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);i.converter=s}n.items[t]=i};class $h extends Error{constructor(){super(...arguments),this.schemas=[]}}class Kw{static parse(e,t){const n=Bi(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){var n;try{if(Vr(t))return new t().fromASN(e);const i=qt.get(t);qt.cache(t);let s=i.schema;if(e.constructor===Ct&&i.type!==R.Choice){s=new Ct({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const c in i.items)delete e[c]}const a=Vn({},e,s);if(!a.verified)throw new $h(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(Mg(t)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const c=i.itemType;if(typeof c=="number"){const u=Ef(c);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,f=>u.fromASN(f))}else return t.from(e.valueBlock.value,u=>this.fromASN(u,c))}for(const c in i.items){const u=a.result[c];if(!u)continue;const f=i.items[c],m=f.type;if(typeof m=="number"||Vr(m)){const B=(n=f.converter)!==null&&n!==void 0?n:Vr(m)?new m:null;if(!B)throw new Error("Converter is empty");if(f.repeated)if(f.implicit){const C=f.repeated==="sequence"?Lr:qr,p=new C;p.valueBlock=u.valueBlock;const g=Bi(p.toBER(!1));if(g.offset===-1)throw new Error(`Cannot parse the child item. ${g.result.error}`);if(!("value"in g.result.valueBlock&&Array.isArray(g.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const A=g.result.valueBlock.value;o[c]=Array.from(A,O=>B.fromASN(O))}else o[c]=Array.from(u,C=>B.fromASN(C));else{let C=u;if(f.implicit){let p;if(Vr(m))p=new m().toSchema("");else{const g=v[m],A=Dg[g];if(!A)throw new Error(`Cannot get '${g}' class from asn1js module`);p=new A}p.valueBlock=C.valueBlock,C=Bi(p.toBER(!1)).result}o[c]=B.fromASN(C)}}else if(f.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");o[c]=Array.from(u,B=>this.fromASN(B,m))}else o[c]=this.fromASN(u,m)}return o}catch(i){throw i instanceof $h&&i.schemas.push(t.name),i}}}class If{static serialize(e){return e instanceof ft?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Vr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=qt.get(t);qt.cache(t);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const a=Ef(n.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);i=e.map(o=>a.toASN(o))}else i=e.map(a=>this.toAsnItem({type:n.itemType},"[]",t,a))}else for(const a in n.items){const o=n.items[a],c=e[a];if(c===void 0||o.defaultValue===c||typeof o.defaultValue=="object"&&typeof c=="object"&&Hw(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=If.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||Vr(o.type))){const f={};f.valueHex=u instanceof ii?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new Xa({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else i.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else i.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else o.repeated?i=i.concat(u):i.push(u)}let s;switch(n.type){case R.Sequence:s=new Lr({value:i});break;case R.Set:s=new qr({value:i});break;case R.Choice:if(!i[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,t,n,i){let s;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${t}' doesn't have converter for type ${v[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,u=>a.toASN(u)),c=e.repeated==="sequence"?Lr:qr;s=new c({value:o})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(i,c=>this.toASN(c)),o=e.repeated==="sequence"?Lr:qr;s=new o({value:a})}else s=this.toASN(i);return s}}class Ve extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class L{static serialize(e){return If.serialize(e)}static parse(e,t){return Kw.parse(e,t)}static toString(e){const t=q.isBufferSource(e)?q.toArrayBuffer(e):L.serialize(e),n=Bi(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function l(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}var Ug={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${t}\\.${t}\\.${t}\\.${t}(${a})?$`,"i")};function u(p,g){if(p.indexOf("::")!==p.lastIndexOf("::"))return null;let A=0,O=-1,P=(p.match(c.zoneIndex)||[])[0],N,xe;for(P&&(P=P.substring(1),p=p.replace(/%.+$/,""));(O=p.indexOf(":",O+1))>=0;)A++;if(p.substr(0,2)==="::"&&A--,p.substr(-2,2)==="::"&&A--,A>g)return null;for(xe=g-A,N=":";xe--;)N+="0:";return p=p.replace("::",N),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),g=function(){const Le=p.split(":"),qe=[];for(let Ze=0;Ze<Le.length;Ze++)qe.push(parseInt(Le[Ze],16));return qe}(),{parts:g,zoneId:P}}function f(p,g,A,O){if(p.length!==g.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let P=0,N;for(;O>0;){if(N=A-O,N<0&&(N=0),p[P]>>N!==g[P]>>N)return!1;O-=A,P+=1}return!0}function m(p){if(s.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(i.test(p))return parseInt(p,8);throw new Error(`ipaddr: cannot parse ${p} as octal`)}return parseInt(p,10)}function B(p,g){for(;p.length<g;)p=`0${p}`;return p}const C={};C.IPv4=function(){function p(g){if(g.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,O;for(A=0;A<g.length;A++)if(O=g[A],!(0<=O&&O<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=g}return p.prototype.SpecialRanges={unspecified:[[new p([0,0,0,0]),8]],broadcast:[[new p([255,255,255,255]),32]],multicast:[[new p([224,0,0,0]),4]],linkLocal:[[new p([169,254,0,0]),16]],loopback:[[new p([127,0,0,0]),8]],carrierGradeNat:[[new p([100,64,0,0]),10]],private:[[new p([10,0,0,0]),8],[new p([172,16,0,0]),12],[new p([192,168,0,0]),16]],reserved:[[new p([192,0,0,0]),24],[new p([192,0,2,0]),24],[new p([192,88,99,0]),24],[new p([198,18,0,0]),15],[new p([198,51,100,0]),24],[new p([203,0,113,0]),24],[new p([240,0,0,0]),4]],as112:[[new p([192,175,48,0]),24],[new p([192,31,196,0]),24]],amt:[[new p([192,52,193,0]),24]]},p.prototype.kind=function(){return"ipv4"},p.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,g.octets,8,A)},p.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let P,N,xe;for(P=3;P>=0;P-=1)if(N=this.octets[P],N in O){if(xe=O[N],A&&xe!==0)return null;xe!==8&&(A=!0),g+=xe}else return null;return 32-g},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){return this.octets.slice(0)},p.prototype.toIPv4MappedAddress=function(){return C.IPv6.parse(`::ffff:${this.toString()}`)},p.prototype.toNormalizedString=function(){return this.toString()},p.prototype.toString=function(){return this.octets.join(".")},p}(),C.IPv4.broadcastAddressFromCIDR=function(p){try{const g=this.parseCIDR(p),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[];let N=0;for(;N<4;)P.push(parseInt(A[N],10)|parseInt(O[N],10)^255),N++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},C.IPv4.isIPv4=function(p){return this.parser(p)!==null},C.IPv4.isValid=function(p){try{return new this(this.parser(p)),!0}catch{return!1}},C.IPv4.isValidCIDR=function(p){try{return this.parseCIDR(p),!0}catch{return!1}},C.IPv4.isValidFourPartDecimal=function(p){return!!(C.IPv4.isValid(p)&&p.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},C.IPv4.networkAddressFromCIDR=function(p){let g,A,O,P,N;try{for(g=this.parseCIDR(p),O=g[0].toByteArray(),N=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[],A=0;A<4;)P.push(parseInt(O[A],10)&parseInt(N[A],10)),A++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},C.IPv4.parse=function(p){const g=this.parser(p);if(g===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(g)},C.IPv4.parseCIDR=function(p){let g;if(g=p.match(/^(.+)\/(\d+)$/)){const A=parseInt(g[2]);if(A>=0&&A<=32){const O=[this.parse(g[1]),A];return Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},C.IPv4.parser=function(p){let g,A,O;if(g=p.match(n.fourOctet))return function(){const P=g.slice(1,6),N=[];for(let xe=0;xe<P.length;xe++)A=P[xe],N.push(m(A));return N}();if(g=p.match(n.longValue)){if(O=m(g[1]),O>4294967295||O<0)throw new Error("ipaddr: address outside defined range");return function(){const P=[];let N;for(N=0;N<=24;N+=8)P.push(O>>N&255);return P}().reverse()}else return(g=p.match(n.twoOctet))?function(){const P=g.slice(1,4),N=[];if(O=m(P[1]),O>16777215||O<0)throw new Error("ipaddr: address outside defined range");return N.push(m(P[0])),N.push(O>>16&255),N.push(O>>8&255),N.push(O&255),N}():(g=p.match(n.threeOctet))?function(){const P=g.slice(1,5),N=[];if(O=m(P[2]),O>65535||O<0)throw new Error("ipaddr: address outside defined range");return N.push(m(P[0])),N.push(m(P[1])),N.push(O>>8&255),N.push(O&255),N}():null},C.IPv4.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>32)throw new Error("ipaddr: invalid IPv4 prefix length");const g=[0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)g[A]=255,A++;return O<4&&(g[O]=Math.pow(2,p%8)-1<<8-p%8),new this(g)},C.IPv6=function(){function p(g,A){let O,P;if(g.length===16)for(this.parts=[],O=0;O<=14;O+=2)this.parts.push(g[O]<<8|g[O+1]);else if(g.length===8)this.parts=g;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(O=0;O<this.parts.length;O++)if(P=this.parts[O],!(0<=P&&P<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");A&&(this.zoneId=A)}return p.prototype.SpecialRanges={unspecified:[new p([0,0,0,0,0,0,0,0]),128],linkLocal:[new p([65152,0,0,0,0,0,0,0]),10],multicast:[new p([65280,0,0,0,0,0,0,0]),8],loopback:[new p([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new p([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new p([0,0,0,0,0,65535,0,0]),96],discard:[new p([256,0,0,0,0,0,0,0]),64],rfc6145:[new p([0,0,0,0,65535,0,0,0]),96],rfc6052:[new p([100,65435,0,0,0,0,0,0]),96],"6to4":[new p([8194,0,0,0,0,0,0,0]),16],teredo:[new p([8193,0,0,0,0,0,0,0]),32],benchmarking:[new p([8193,2,0,0,0,0,0,0]),48],amt:[new p([8193,3,0,0,0,0,0,0]),32],as112v6:[[new p([8193,4,274,0,0,0,0,0]),48],[new p([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new p([8193,16,0,0,0,0,0,0]),28],orchid2:[new p([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new p([8193,48,0,0,0,0,0,0]),28],reserved:[[new p([8193,0,0,0,0,0,0,0]),23],[new p([8193,3512,0,0,0,0,0,0]),32]]},p.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},p.prototype.kind=function(){return"ipv6"},p.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,g.parts,16,A)},p.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let P,N;for(let xe=7;xe>=0;xe-=1)if(P=this.parts[xe],P in O){if(N=O[P],A&&N!==0)return null;N!==16&&(A=!0),g+=N}else return null;return 128-g},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let g;const A=[],O=this.parts;for(let P=0;P<O.length;P++)g=O[P],A.push(g>>8),A.push(g&255);return A},p.prototype.toFixedLengthString=function(){const g=(function(){const O=[];for(let P=0;P<this.parts.length;P++)O.push(B(this.parts[P].toString(16),4));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},p.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const g=this.parts.slice(-2),A=g[0],O=g[1];return new C.IPv4([A>>8,A&255,O>>8,O&255])},p.prototype.toNormalizedString=function(){const g=(function(){const O=[];for(let P=0;P<this.parts.length;P++)O.push(this.parts[P].toString(16));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},p.prototype.toRFC5952String=function(){const g=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString();let O=0,P=-1,N;for(;N=g.exec(A);)N[0].length>P&&(O=N.index,P=N[0].length);return P<0?A:`${A.substring(0,O)}::${A.substring(O+P)}`},p.prototype.toString=function(){return this.toRFC5952String()},p}(),C.IPv6.broadcastAddressFromCIDR=function(p){try{const g=this.parseCIDR(p),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[];let N=0;for(;N<16;)P.push(parseInt(A[N],10)|parseInt(O[N],10)^255),N++;return new this(P)}catch(g){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${g})`)}},C.IPv6.isIPv6=function(p){return this.parser(p)!==null},C.IPv6.isValid=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{const g=this.parser(p);return new this(g.parts,g.zoneId),!0}catch{return!1}},C.IPv6.isValidCIDR=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{return this.parseCIDR(p),!0}catch{return!1}},C.IPv6.networkAddressFromCIDR=function(p){let g,A,O,P,N;try{for(g=this.parseCIDR(p),O=g[0].toByteArray(),N=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[],A=0;A<16;)P.push(parseInt(O[A],10)&parseInt(N[A],10)),A++;return new this(P)}catch(xe){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${xe})`)}},C.IPv6.parse=function(p){const g=this.parser(p);if(g.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(g.parts,g.zoneId)},C.IPv6.parseCIDR=function(p){let g,A,O;if((A=p.match(/^(.+)\/(\d+)$/))&&(g=parseInt(A[2]),g>=0&&g<=128))return O=[this.parse(A[1]),g],Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},C.IPv6.parser=function(p){let g,A,O,P,N,xe;if(O=p.match(c.deprecatedTransitional))return this.parser(`::ffff:${O[1]}`);if(c.native.test(p))return u(p,8);if((O=p.match(c.transitional))&&(xe=O[6]||"",g=O[1],O[1].endsWith("::")||(g=g.slice(0,-1)),g=u(g+xe,6),g.parts)){for(N=[parseInt(O[2]),parseInt(O[3]),parseInt(O[4]),parseInt(O[5])],A=0;A<N.length;A++)if(P=N[A],!(0<=P&&P<=255))return null;return g.parts.push(N[0]<<8|N[1]),g.parts.push(N[2]<<8|N[3]),{parts:g.parts,zoneId:g.zoneId}}return null},C.IPv6.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>128)throw new Error("ipaddr: invalid IPv6 prefix length");const g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)g[A]=255,A++;return O<16&&(g[O]=Math.pow(2,p%8)-1<<8-p%8),new this(g)},C.fromByteArray=function(p){const g=p.length;if(g===4)return new C.IPv4(p);if(g===16)return new C.IPv6(p);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},C.isValid=function(p){return C.IPv6.isValid(p)||C.IPv4.isValid(p)},C.isValidCIDR=function(p){return C.IPv6.isValidCIDR(p)||C.IPv4.isValidCIDR(p)},C.parse=function(p){if(C.IPv6.isValid(p))return C.IPv6.parse(p);if(C.IPv4.isValid(p))return C.IPv4.parse(p);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},C.parseCIDR=function(p){try{return C.IPv6.parseCIDR(p)}catch{try{return C.IPv4.parseCIDR(p)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},C.process=function(p){const g=this.parse(p);return g.kind()==="ipv6"&&g.isIPv4MappedAddress()?g.toIPv4Address():g},C.subnetMatch=function(p,g,A){let O,P,N,xe;A==null&&(A="unicast");for(P in g)if(Object.prototype.hasOwnProperty.call(g,P)){for(N=g[P],N[0]&&!(N[0]instanceof Array)&&(N=[N]),O=0;O<N.length;O++)if(xe=N[O],p.kind()===xe[0].kind()&&p.match.apply(p,xe))return P}return A},r.exports?r.exports=C:e.ipaddr=C})(uc)})(Ug);var Dh=Ug.exports;class Zh{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return Dh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(te.ToHex(e))}static fromString(e){const t=Dh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var Zl,Ml,Ul;let ht=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};l([h({type:v.TeletexString})],ht.prototype,"teletexString",void 0);l([h({type:v.PrintableString})],ht.prototype,"printableString",void 0);l([h({type:v.UniversalString})],ht.prototype,"universalString",void 0);l([h({type:v.Utf8String})],ht.prototype,"utf8String",void 0);l([h({type:v.BmpString})],ht.prototype,"bmpString",void 0);ht=l([$({type:R.Choice})],ht);let zi=class extends ht{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?te.ToHex(this.anyValue):super.toString())}};l([h({type:v.IA5String})],zi.prototype,"ia5String",void 0);l([h({type:v.Any})],zi.prototype,"anyValue",void 0);zi=l([$({type:R.Choice})],zi);class _u{constructor(e={}){this.type="",this.value=new zi,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],_u.prototype,"type",void 0);l([h({type:zi})],_u.prototype,"value",void 0);let Gi=Zl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Zl.prototype)}};Gi=Zl=l([$({type:R.Set,itemType:_u})],Gi);let Vl=Ml=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ml.prototype)}};Vl=Ml=l([$({type:R.Sequence,itemType:Gi})],Vl);let et=Ul=class extends Vl{constructor(e){super(e),Object.setPrototypeOf(this,Ul.prototype)}};et=Ul=l([$({type:R.Sequence})],et);const Ww={fromASN:r=>Zh.toString(hc.fromASN(r)),toASN:r=>hc.toASN(Zh.fromString(r))};class ba{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],ba.prototype,"typeId",void 0);l([h({type:v.Any,context:0})],ba.prototype,"value",void 0);class Cf{constructor(e={}){this.partyName=new ht,Object.assign(this,e)}}l([h({type:ht,optional:!0,context:0,implicit:!0})],Cf.prototype,"nameAssigner",void 0);l([h({type:ht,context:1,implicit:!0})],Cf.prototype,"partyName",void 0);let be=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ba,context:0,implicit:!0})],be.prototype,"otherName",void 0);l([h({type:v.IA5String,context:1,implicit:!0})],be.prototype,"rfc822Name",void 0);l([h({type:v.IA5String,context:2,implicit:!0})],be.prototype,"dNSName",void 0);l([h({type:v.Any,context:3,implicit:!0})],be.prototype,"x400Address",void 0);l([h({type:et,context:4,implicit:!1})],be.prototype,"directoryName",void 0);l([h({type:Cf,context:5})],be.prototype,"ediPartyName",void 0);l([h({type:v.IA5String,context:6,implicit:!0})],be.prototype,"uniformResourceIdentifier",void 0);l([h({type:v.OctetString,context:7,implicit:!0,converter:Ww})],be.prototype,"iPAddress",void 0);l([h({type:v.ObjectIdentifier,context:8,implicit:!0})],be.prototype,"registeredID",void 0);be=l([$({type:R.Choice})],be);const jf="1.3.6.1.5.5.7",zw=`${jf}.1`,ls=`${jf}.3`,wu=`${jf}.48`,Mh=`${wu}.1`,Uh=`${wu}.2`,Vh=`${wu}.3`,Lh=`${wu}.5`,Tn="2.5.29";var Ll;const ql=`${zw}.1`;class to{constructor(e={}){this.accessMethod="",this.accessLocation=new be,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],to.prototype,"accessMethod",void 0);l([h({type:be})],to.prototype,"accessLocation",void 0);let Ii=Ll=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};Ii=Ll=l([$({type:R.Sequence,itemType:to})],Ii);const Hl=`${Tn}.35`;class Tf extends De{}class Ln{constructor(e={}){e&&Object.assign(this,e)}}l([h({type:Tf,context:0,optional:!0,implicit:!0})],Ln.prototype,"keyIdentifier",void 0);l([h({type:be,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Ln.prototype,"authorityCertIssuer",void 0);l([h({type:v.Integer,context:2,optional:!0,implicit:!0,converter:Ke})],Ln.prototype,"authorityCertSerialNumber",void 0);const Vg=`${Tn}.19`;class pc{constructor(e={}){this.cA=!1,Object.assign(this,e)}}l([h({type:v.Boolean,defaultValue:!1})],pc.prototype,"cA",void 0);l([h({type:v.Integer,optional:!0})],pc.prototype,"pathLenConstraint",void 0);var Fl;let xt=Fl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Fl.prototype)}};xt=Fl=l([$({type:R.Sequence,itemType:be})],xt);var Kl;let qh=Kl=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};qh=Kl=l([$({type:R.Sequence})],qh);var Wl;const Lg=`${Tn}.32`;let Kr=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};l([h({type:v.IA5String})],Kr.prototype,"ia5String",void 0);l([h({type:v.VisibleString})],Kr.prototype,"visibleString",void 0);l([h({type:v.BmpString})],Kr.prototype,"bmpString",void 0);l([h({type:v.Utf8String})],Kr.prototype,"utf8String",void 0);Kr=l([$({type:R.Choice})],Kr);class Nf{constructor(e={}){this.organization=new Kr,this.noticeNumbers=[],Object.assign(this,e)}}l([h({type:Kr})],Nf.prototype,"organization",void 0);l([h({type:v.Integer,repeated:"sequence"})],Nf.prototype,"noticeNumbers",void 0);class Bf{constructor(e={}){Object.assign(this,e)}}l([h({type:Nf,optional:!0})],Bf.prototype,"noticeRef",void 0);l([h({type:Kr,optional:!0})],Bf.prototype,"explicitText",void 0);let mc=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.IA5String})],mc.prototype,"cPSuri",void 0);l([h({type:Bf})],mc.prototype,"userNotice",void 0);mc=l([$({type:R.Choice})],mc);class Rf{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Rf.prototype,"policyQualifierId",void 0);l([h({type:v.Any})],Rf.prototype,"qualifier",void 0);class ku{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],ku.prototype,"policyIdentifier",void 0);l([h({type:Rf,repeated:"sequence",optional:!0})],ku.prototype,"policyQualifiers",void 0);let yc=Wl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Wl.prototype)}};yc=Wl=l([$({type:R.Sequence,itemType:ku})],yc);let gc=class{constructor(e=0){this.value=e}};l([h({type:v.Integer})],gc.prototype,"value",void 0);gc=l([$({type:R.Choice})],gc);let Hh=class extends gc{};Hh=l([$({type:R.Choice})],Hh);var zl;const Gl=`${Tn}.31`;var Qt;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Qt||(Qt={}));class qg extends xu{toJSON(){const e=[],t=this.toNumber();return t&Qt.aACompromise&&e.push("aACompromise"),t&Qt.affiliationChanged&&e.push("affiliationChanged"),t&Qt.cACompromise&&e.push("cACompromise"),t&Qt.certificateHold&&e.push("certificateHold"),t&Qt.cessationOfOperation&&e.push("cessationOfOperation"),t&Qt.keyCompromise&&e.push("keyCompromise"),t&Qt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Qt.superseded&&e.push("superseded"),t&Qt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let ai=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,context:0,repeated:"sequence",implicit:!0})],ai.prototype,"fullName",void 0);l([h({type:Gi,context:1,implicit:!0})],ai.prototype,"nameRelativeToCRLIssuer",void 0);ai=l([$({type:R.Choice})],ai);class ds{constructor(e={}){Object.assign(this,e)}}l([h({type:ai,context:0,optional:!0})],ds.prototype,"distributionPoint",void 0);l([h({type:qg,context:1,optional:!0,implicit:!0})],ds.prototype,"reasons",void 0);l([h({type:be,context:2,optional:!0,repeated:"sequence",implicit:!0})],ds.prototype,"cRLIssuer",void 0);let Ri=zl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};Ri=zl=l([$({type:R.Sequence,itemType:ds})],Ri);var Jl;let Fh=Jl=class extends Ri{constructor(e){super(e),Object.setPrototypeOf(this,Jl.prototype)}};Fh=Jl=l([$({type:R.Sequence,itemType:ds})],Fh);class yt{constructor(e={}){this.onlyContainsUserCerts=yt.ONLY,this.onlyContainsCACerts=yt.ONLY,this.indirectCRL=yt.ONLY,this.onlyContainsAttributeCerts=yt.ONLY,Object.assign(this,e)}}yt.ONLY=!1;l([h({type:ai,context:0,optional:!0})],yt.prototype,"distributionPoint",void 0);l([h({type:v.Boolean,context:1,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsUserCerts",void 0);l([h({type:v.Boolean,context:2,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsCACerts",void 0);l([h({type:qg,context:3,optional:!0,implicit:!0})],yt.prototype,"onlySomeReasons",void 0);l([h({type:v.Boolean,context:4,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"indirectCRL",void 0);l([h({type:v.Boolean,context:5,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsAttributeCerts",void 0);var Zs;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Zs||(Zs={}));let Yl=class{constructor(e=Zs.unspecified){this.reason=Zs.unspecified,this.reason=e}toJSON(){return Zs[this.reason]}toString(){return this.toJSON()}};l([h({type:v.Enumerated})],Yl.prototype,"reason",void 0);Yl=l([$({type:R.Choice})],Yl);var Xl;const Hg=`${Tn}.37`;let vc=Xl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Xl.prototype)}};vc=Xl=l([$({type:R.Sequence,itemType:v.ObjectIdentifier})],vc);const Gw=`${ls}.1`,Jw=`${ls}.2`,Yw=`${ls}.3`,Xw=`${ls}.4`,Qw=`${ls}.8`,e1=`${ls}.9`;let Ql=class{constructor(e=new ArrayBuffer(0)){this.value=e}};l([h({type:v.Integer,converter:Ke})],Ql.prototype,"value",void 0);Ql=l([$({type:R.Choice})],Ql);let ed=class{constructor(e){this.value=new Date,e&&(this.value=e)}};l([h({type:v.GeneralizedTime})],ed.prototype,"value",void 0);ed=l([$({type:R.Choice})],ed);var td;let Kh=td=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,td.prototype)}};Kh=td=l([$({type:R.Sequence})],Kh);const Fg=`${Tn}.15`;var er;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(er||(er={}));class il extends xu{toJSON(){const e=this.toNumber(),t=[];return e&er.cRLSign&&t.push("crlSign"),e&er.dataEncipherment&&t.push("dataEncipherment"),e&er.decipherOnly&&t.push("decipherOnly"),e&er.digitalSignature&&t.push("digitalSignature"),e&er.encipherOnly&&t.push("encipherOnly"),e&er.keyAgreement&&t.push("keyAgreement"),e&er.keyCertSign&&t.push("keyCertSign"),e&er.keyEncipherment&&t.push("keyEncipherment"),e&er.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var rd;class Su{constructor(e={}){this.base=new be,this.minimum=0,Object.assign(this,e)}}l([h({type:be})],Su.prototype,"base",void 0);l([h({type:v.Integer,context:0,defaultValue:0,implicit:!0})],Su.prototype,"minimum",void 0);l([h({type:v.Integer,context:1,optional:!0,implicit:!0})],Su.prototype,"maximum",void 0);let bc=rd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,rd.prototype)}};bc=rd=l([$({type:R.Sequence,itemType:Su})],bc);class Kg{constructor(e={}){Object.assign(this,e)}}l([h({type:bc,context:0,optional:!0,implicit:!0})],Kg.prototype,"permittedSubtrees",void 0);l([h({type:bc,context:1,optional:!0,implicit:!0})],Kg.prototype,"excludedSubtrees",void 0);class Wg{constructor(e={}){Object.assign(this,e)}}l([h({type:v.Integer,context:0,implicit:!0,optional:!0,converter:Ke})],Wg.prototype,"requireExplicitPolicy",void 0);l([h({type:v.Integer,context:1,implicit:!0,optional:!0,converter:Ke})],Wg.prototype,"inhibitPolicyMapping",void 0);var nd;class Pf{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Pf.prototype,"issuerDomainPolicy",void 0);l([h({type:v.ObjectIdentifier})],Pf.prototype,"subjectDomainPolicy",void 0);let Wh=nd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,nd.prototype)}};Wh=nd=l([$({type:R.Sequence,itemType:Pf})],Wh);var id;const zg=`${Tn}.17`;let sd=id=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,id.prototype)}};sd=id=l([$({type:R.Sequence})],sd);let Wr=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],Wr.prototype,"type",void 0);l([h({type:v.Any,repeated:"set"})],Wr.prototype,"values",void 0);var ad;let zh=ad=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,ad.prototype)}};zh=ad=l([$({type:R.Sequence,itemType:Wr})],zh);const Gg=`${Tn}.14`;class yn extends Tf{}class Jg{constructor(e={}){Object.assign(this,e)}}l([h({type:v.GeneralizedTime,context:0,implicit:!0,optional:!0})],Jg.prototype,"notBefore",void 0);l([h({type:v.GeneralizedTime,context:1,implicit:!0,optional:!0})],Jg.prototype,"notAfter",void 0);var Ms;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Ms||(Ms={}));class Yg extends xu{toJSON(){const e=[],t=this.toNumber();return t&Ms.pKIXCertificate&&e.push("pKIXCertificate"),t&Ms.newExtensions&&e.push("newExtensions"),t&Ms.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Xg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Yg,Object.assign(this,e)}}l([h({type:v.GeneralString})],Xg.prototype,"entrustVers",void 0);l([h({type:Yg})],Xg.prototype,"entrustInfoFlags",void 0);var od;let Gh=od=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,od.prototype)}};Gh=od=l([$({type:R.Sequence,itemType:to})],Gh);class Y{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof Y&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Zy(e.parameters,this.parameters)||e.parameters===this.parameters)}}l([h({type:v.ObjectIdentifier})],Y.prototype,"algorithm",void 0);l([h({type:v.Any,optional:!0})],Y.prototype,"parameters",void 0);class sr{constructor(e={}){this.algorithm=new Y,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],sr.prototype,"algorithm",void 0);l([h({type:v.BitString})],sr.prototype,"subjectPublicKey",void 0);let lt=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};l([h({type:v.UTCTime})],lt.prototype,"utcTime",void 0);l([h({type:v.GeneralizedTime})],lt.prototype,"generalTime",void 0);lt=l([$({type:R.Choice})],lt);class ro{constructor(e){this.notBefore=new lt(new Date),this.notAfter=new lt(new Date),e&&(this.notBefore=new lt(e.notBefore),this.notAfter=new lt(e.notAfter))}}l([h({type:lt})],ro.prototype,"notBefore",void 0);l([h({type:lt})],ro.prototype,"notAfter",void 0);var cd;let Wt=class Qg{constructor(e={}){this.extnID="",this.critical=Qg.CRITICAL,this.extnValue=new De,Object.assign(this,e)}};Wt.CRITICAL=!1;l([h({type:v.ObjectIdentifier})],Wt.prototype,"extnID",void 0);l([h({type:v.Boolean,defaultValue:Wt.CRITICAL})],Wt.prototype,"critical",void 0);l([h({type:De})],Wt.prototype,"extnValue",void 0);let kn=cd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,cd.prototype)}};kn=cd=l([$({type:R.Sequence,itemType:Wt})],kn);var oi;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(oi||(oi={}));class Ut{constructor(e={}){this.version=oi.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new Y,this.issuer=new et,this.validity=new ro,this.subject=new et,this.subjectPublicKeyInfo=new sr,Object.assign(this,e)}}l([h({type:v.Integer,context:0,defaultValue:oi.v1})],Ut.prototype,"version",void 0);l([h({type:v.Integer,converter:Ke})],Ut.prototype,"serialNumber",void 0);l([h({type:Y})],Ut.prototype,"signature",void 0);l([h({type:et})],Ut.prototype,"issuer",void 0);l([h({type:ro})],Ut.prototype,"validity",void 0);l([h({type:et})],Ut.prototype,"subject",void 0);l([h({type:sr})],Ut.prototype,"subjectPublicKeyInfo",void 0);l([h({type:v.BitString,context:1,implicit:!0,optional:!0})],Ut.prototype,"issuerUniqueID",void 0);l([h({type:v.BitString,context:2,implicit:!0,optional:!0})],Ut.prototype,"subjectUniqueID",void 0);l([h({type:kn,context:3,optional:!0})],Ut.prototype,"extensions",void 0);class ci{constructor(e={}){this.tbsCertificate=new Ut,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Ut})],ci.prototype,"tbsCertificate",void 0);l([h({type:Y})],ci.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],ci.prototype,"signatureValue",void 0);class Au{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new lt,Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Au.prototype,"userCertificate",void 0);l([h({type:lt})],Au.prototype,"revocationDate",void 0);l([h({type:Wt,optional:!0,repeated:"sequence"})],Au.prototype,"crlEntryExtensions",void 0);class tn{constructor(e={}){this.signature=new Y,this.issuer=new et,this.thisUpdate=new lt,Object.assign(this,e)}}l([h({type:v.Integer,optional:!0})],tn.prototype,"version",void 0);l([h({type:Y})],tn.prototype,"signature",void 0);l([h({type:et})],tn.prototype,"issuer",void 0);l([h({type:lt})],tn.prototype,"thisUpdate",void 0);l([h({type:lt,optional:!0})],tn.prototype,"nextUpdate",void 0);l([h({type:Au,repeated:"sequence",optional:!0})],tn.prototype,"revokedCertificates",void 0);l([h({type:Wt,optional:!0,context:0,repeated:"sequence"})],tn.prototype,"crlExtensions",void 0);class $f{constructor(e={}){this.tbsCertList=new tn,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:tn})],$f.prototype,"tbsCertList",void 0);l([h({type:Y})],$f.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],$f.prototype,"signature",void 0);class fs{constructor(e={}){this.issuer=new et,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:et})],fs.prototype,"issuer",void 0);l([h({type:v.Integer,converter:Ke})],fs.prototype,"serialNumber",void 0);let Ji=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0})],Ji.prototype,"subjectKeyIdentifier",void 0);l([h({type:fs})],Ji.prototype,"issuerAndSerialNumber",void 0);Ji=l([$({type:R.Choice})],Ji);var zr;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(zr||(zr={}));let xa=class extends Y{};xa=l([$({type:R.Sequence})],xa);let xc=class extends Y{};xc=l([$({type:R.Sequence})],xc);let Er=class extends Y{};Er=l([$({type:R.Sequence})],Er);let _c=class extends Y{};_c=l([$({type:R.Sequence})],_c);let Jh=class extends Y{};Jh=l([$({type:R.Sequence})],Jh);let ud=class extends Y{};ud=l([$({type:R.Sequence})],ud);let hs=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],hs.prototype,"attrType",void 0);l([h({type:v.Any,repeated:"set"})],hs.prototype,"attrValues",void 0);var ld;class Tr{constructor(e={}){this.version=zr.v0,this.sid=new Ji,this.digestAlgorithm=new xa,this.signatureAlgorithm=new xc,this.signature=new De,Object.assign(this,e)}}l([h({type:v.Integer})],Tr.prototype,"version",void 0);l([h({type:Ji})],Tr.prototype,"sid",void 0);l([h({type:xa})],Tr.prototype,"digestAlgorithm",void 0);l([h({type:hs,repeated:"set",context:0,implicit:!0,optional:!0})],Tr.prototype,"signedAttrs",void 0);l([h({type:xc})],Tr.prototype,"signatureAlgorithm",void 0);l([h({type:De})],Tr.prototype,"signature",void 0);l([h({type:hs,repeated:"set",context:1,implicit:!0,optional:!0})],Tr.prototype,"unsignedAttrs",void 0);let wc=ld=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,ld.prototype)}};wc=ld=l([$({type:R.Set,itemType:Tr})],wc);let Yh=class extends lt{};Yh=l([$({type:R.Choice})],Yh);let Xh=class extends Tr{};Xh=l([$({type:R.Sequence})],Xh);class Df{constructor(e={}){this.acIssuer=new be,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}l([h({type:be})],Df.prototype,"acIssuer",void 0);l([h({type:v.Integer})],Df.prototype,"acSerial",void 0);l([h({type:Wr,repeated:"sequence"})],Df.prototype,"attrs",void 0);var dd;let kc=dd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,dd.prototype)}};kc=dd=l([$({type:R.Sequence,itemType:v.ObjectIdentifier})],kc);class Ou{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}l([h({type:v.Integer,optional:!0})],Ou.prototype,"pathLenConstraint",void 0);l([h({type:kc,implicit:!0,context:0,optional:!0})],Ou.prototype,"permittedAttrs",void 0);l([h({type:kc,implicit:!0,context:1,optional:!0})],Ou.prototype,"excludedAttrs",void 0);l([h({type:v.Boolean,defaultValue:!0})],Ou.prototype,"permitUnSpecified",void 0);class vi{constructor(e={}){this.issuer=new xt,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:xt})],vi.prototype,"issuer",void 0);l([h({type:v.Integer,converter:Ke})],vi.prototype,"serial",void 0);l([h({type:v.BitString,optional:!0})],vi.prototype,"issuerUID",void 0);var fd;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(fd||(fd={}));class bi{constructor(e={}){this.digestedObjectType=fd.publicKey,this.digestAlgorithm=new Y,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Enumerated})],bi.prototype,"digestedObjectType",void 0);l([h({type:v.ObjectIdentifier,optional:!0})],bi.prototype,"otherObjectTypeID",void 0);l([h({type:Y})],bi.prototype,"digestAlgorithm",void 0);l([h({type:v.BitString})],bi.prototype,"objectDigest",void 0);class Eu{constructor(e={}){Object.assign(this,e)}}l([h({type:xt,optional:!0})],Eu.prototype,"issuerName",void 0);l([h({type:vi,context:0,implicit:!0,optional:!0})],Eu.prototype,"baseCertificateID",void 0);l([h({type:bi,context:1,implicit:!0,optional:!0})],Eu.prototype,"objectDigestInfo",void 0);let Yi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,repeated:"sequence"})],Yi.prototype,"v1Form",void 0);l([h({type:Eu,context:0,implicit:!0})],Yi.prototype,"v2Form",void 0);Yi=l([$({type:R.Choice})],Yi);class Iu{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}l([h({type:v.GeneralizedTime})],Iu.prototype,"notBeforeTime",void 0);l([h({type:v.GeneralizedTime})],Iu.prototype,"notAfterTime",void 0);class no{constructor(e={}){Object.assign(this,e)}}l([h({type:vi,implicit:!0,context:0,optional:!0})],no.prototype,"baseCertificateID",void 0);l([h({type:xt,implicit:!0,context:1,optional:!0})],no.prototype,"entityName",void 0);l([h({type:bi,implicit:!0,context:2,optional:!0})],no.prototype,"objectDigestInfo",void 0);var hd;(function(r){r[r.v2=1]="v2"})(hd||(hd={}));class mr{constructor(e={}){this.version=hd.v2,this.holder=new no,this.issuer=new Yi,this.signature=new Y,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Iu,this.attributes=[],Object.assign(this,e)}}l([h({type:v.Integer})],mr.prototype,"version",void 0);l([h({type:no})],mr.prototype,"holder",void 0);l([h({type:Yi})],mr.prototype,"issuer",void 0);l([h({type:Y})],mr.prototype,"signature",void 0);l([h({type:v.Integer,converter:Ke})],mr.prototype,"serialNumber",void 0);l([h({type:Iu})],mr.prototype,"attrCertValidityPeriod",void 0);l([h({type:Wr,repeated:"sequence"})],mr.prototype,"attributes",void 0);l([h({type:v.BitString,optional:!0})],mr.prototype,"issuerUniqueID",void 0);l([h({type:kn,optional:!0})],mr.prototype,"extensions",void 0);class Cu{constructor(e={}){this.acinfo=new mr,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:mr})],Cu.prototype,"acinfo",void 0);l([h({type:Y})],Cu.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],Cu.prototype,"signatureValue",void 0);var Sc;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(Sc||(Sc={}));class pd extends xu{}class Zf{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier,implicit:!0,context:0})],Zf.prototype,"type",void 0);l([h({type:v.Any,implicit:!0,context:1})],Zf.prototype,"value",void 0);class Mf{constructor(e={}){this.policyId="",this.classList=new pd(Sc.unclassified),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Mf.prototype,"policyId",void 0);l([h({type:pd,defaultValue:new pd(Sc.unclassified)})],Mf.prototype,"classList",void 0);l([h({type:Zf,repeated:"set"})],Mf.prototype,"securityCategories",void 0);class ju{constructor(e={}){Object.assign(this,e)}}l([h({type:De})],ju.prototype,"cotets",void 0);l([h({type:v.ObjectIdentifier})],ju.prototype,"oid",void 0);l([h({type:v.Utf8String})],ju.prototype,"string",void 0);class e0{constructor(e={}){this.values=[],Object.assign(this,e)}}l([h({type:xt,implicit:!0,context:0,optional:!0})],e0.prototype,"policyAuthority",void 0);l([h({type:ju,repeated:"sequence"})],e0.prototype,"values",void 0);var md;class Tu{constructor(e={}){this.targetCertificate=new vi,Object.assign(this,e)}}l([h({type:vi})],Tu.prototype,"targetCertificate",void 0);l([h({type:be,optional:!0})],Tu.prototype,"targetName",void 0);l([h({type:bi,optional:!0})],Tu.prototype,"certDigestInfo",void 0);let Xi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,context:0,implicit:!0})],Xi.prototype,"targetName",void 0);l([h({type:be,context:1,implicit:!0})],Xi.prototype,"targetGroup",void 0);l([h({type:Tu,context:2,implicit:!0})],Xi.prototype,"targetCert",void 0);Xi=l([$({type:R.Choice})],Xi);let yd=md=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,md.prototype)}};yd=md=l([$({type:R.Sequence,itemType:Xi})],yd);var gd;let Qh=gd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,gd.prototype)}};Qh=gd=l([$({type:R.Sequence,itemType:yd})],Qh);class t0{constructor(e={}){Object.assign(this,e)}}l([h({type:xt,implicit:!0,context:0,optional:!0})],t0.prototype,"roleAuthority",void 0);l([h({type:be,implicit:!0,context:1})],t0.prototype,"roleName",void 0);class Uf{constructor(e={}){this.service=new be,this.ident=new be,Object.assign(this,e)}}l([h({type:be})],Uf.prototype,"service",void 0);l([h({type:be})],Uf.prototype,"ident",void 0);l([h({type:De,optional:!0})],Uf.prototype,"authInfo",void 0);var vd;class Vf{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Vf.prototype,"otherCertFormat",void 0);l([h({type:v.Any})],Vf.prototype,"otherCert",void 0);let Qi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ci})],Qi.prototype,"certificate",void 0);l([h({type:Cu,context:2,implicit:!0})],Qi.prototype,"v2AttrCert",void 0);l([h({type:Vf,context:3,implicit:!0})],Qi.prototype,"other",void 0);Qi=l([$({type:R.Choice})],Qi);let Ac=vd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,vd.prototype)}};Ac=vd=l([$({type:R.Set,itemType:Qi})],Ac);class ps{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],ps.prototype,"contentType",void 0);l([h({type:v.Any,context:0})],ps.prototype,"content",void 0);let _a=class{constructor(e={}){Object.assign(this,e)}};l([h({type:De})],_a.prototype,"single",void 0);l([h({type:v.Any})],_a.prototype,"any",void 0);_a=l([$({type:R.Choice})],_a);class Nu{constructor(e={}){this.eContentType="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Nu.prototype,"eContentType",void 0);l([h({type:_a,context:0,optional:!0})],Nu.prototype,"eContent",void 0);let wa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:De,context:0,implicit:!0,optional:!0})],wa.prototype,"value",void 0);l([h({type:De,converter:Cw,context:0,implicit:!0,optional:!0,repeated:"sequence"})],wa.prototype,"constructedValue",void 0);wa=l([$({type:R.Choice})],wa);class io{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new _c,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],io.prototype,"contentType",void 0);l([h({type:_c})],io.prototype,"contentEncryptionAlgorithm",void 0);l([h({type:wa,optional:!0})],io.prototype,"encryptedContent",void 0);class Bu{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Bu.prototype,"keyAttrId",void 0);l([h({type:v.Any,optional:!0})],Bu.prototype,"keyAttr",void 0);var bd;class Ru{constructor(e={}){this.subjectKeyIdentifier=new yn,Object.assign(this,e)}}l([h({type:yn})],Ru.prototype,"subjectKeyIdentifier",void 0);l([h({type:v.GeneralizedTime,optional:!0})],Ru.prototype,"date",void 0);l([h({type:Bu,optional:!0})],Ru.prototype,"other",void 0);let es=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Ru,context:0,implicit:!0,optional:!0})],es.prototype,"rKeyId",void 0);l([h({type:fs,optional:!0})],es.prototype,"issuerAndSerialNumber",void 0);es=l([$({type:R.Choice})],es);class Lf{constructor(e={}){this.rid=new es,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:es})],Lf.prototype,"rid",void 0);l([h({type:De})],Lf.prototype,"encryptedKey",void 0);let Oc=bd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,bd.prototype)}};Oc=bd=l([$({type:R.Sequence,itemType:Lf})],Oc);class qf{constructor(e={}){this.algorithm=new Y,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],qf.prototype,"algorithm",void 0);l([h({type:v.BitString})],qf.prototype,"publicKey",void 0);let ui=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0,optional:!0})],ui.prototype,"subjectKeyIdentifier",void 0);l([h({type:qf,context:1,implicit:!0,optional:!0})],ui.prototype,"originatorKey",void 0);l([h({type:fs,optional:!0})],ui.prototype,"issuerAndSerialNumber",void 0);ui=l([$({type:R.Choice})],ui);class ms{constructor(e={}){this.version=zr.v3,this.originator=new ui,this.keyEncryptionAlgorithm=new Er,this.recipientEncryptedKeys=new Oc,Object.assign(this,e)}}l([h({type:v.Integer})],ms.prototype,"version",void 0);l([h({type:ui,context:0})],ms.prototype,"originator",void 0);l([h({type:De,context:1,optional:!0})],ms.prototype,"ukm",void 0);l([h({type:Er})],ms.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Oc})],ms.prototype,"recipientEncryptedKeys",void 0);let ts=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0})],ts.prototype,"subjectKeyIdentifier",void 0);l([h({type:fs})],ts.prototype,"issuerAndSerialNumber",void 0);ts=l([$({type:R.Choice})],ts);class so{constructor(e={}){this.version=zr.v0,this.rid=new ts,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],so.prototype,"version",void 0);l([h({type:ts})],so.prototype,"rid",void 0);l([h({type:Er})],so.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],so.prototype,"encryptedKey",void 0);class ao{constructor(e={}){this.keyIdentifier=new De,Object.assign(this,e)}}l([h({type:De})],ao.prototype,"keyIdentifier",void 0);l([h({type:v.GeneralizedTime,optional:!0})],ao.prototype,"date",void 0);l([h({type:Bu,optional:!0})],ao.prototype,"other",void 0);class oo{constructor(e={}){this.version=zr.v4,this.kekid=new ao,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],oo.prototype,"version",void 0);l([h({type:ao})],oo.prototype,"kekid",void 0);l([h({type:Er})],oo.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],oo.prototype,"encryptedKey",void 0);class co{constructor(e={}){this.version=zr.v0,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],co.prototype,"version",void 0);l([h({type:ud,context:0,optional:!0})],co.prototype,"keyDerivationAlgorithm",void 0);l([h({type:Er})],co.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],co.prototype,"encryptedKey",void 0);class Hf{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Hf.prototype,"oriType",void 0);l([h({type:v.Any})],Hf.prototype,"oriValue",void 0);let Sn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:so,optional:!0})],Sn.prototype,"ktri",void 0);l([h({type:ms,context:1,implicit:!0,optional:!0})],Sn.prototype,"kari",void 0);l([h({type:oo,context:2,implicit:!0,optional:!0})],Sn.prototype,"kekri",void 0);l([h({type:co,context:3,implicit:!0,optional:!0})],Sn.prototype,"pwri",void 0);l([h({type:Hf,context:4,implicit:!0,optional:!0})],Sn.prototype,"ori",void 0);Sn=l([$({type:R.Choice})],Sn);var xd;let Ec=xd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,xd.prototype)}};Ec=xd=l([$({type:R.Set,itemType:Sn})],Ec);var _d;class Pu{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Pu.prototype,"otherRevInfoFormat",void 0);l([h({type:v.Any})],Pu.prototype,"otherRevInfo",void 0);let Ic=class{constructor(e={}){this.other=new Pu,Object.assign(this,e)}};l([h({type:Pu,context:1,implicit:!0})],Ic.prototype,"other",void 0);Ic=l([$({type:R.Choice})],Ic);let Cc=_d=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,_d.prototype)}};Cc=_d=l([$({type:R.Set,itemType:Ic})],Cc);class Ff{constructor(e={}){Object.assign(this,e)}}l([h({type:Ac,context:0,implicit:!0,optional:!0})],Ff.prototype,"certs",void 0);l([h({type:Cc,context:1,implicit:!0,optional:!0})],Ff.prototype,"crls",void 0);var wd;let kd=wd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,wd.prototype)}};kd=wd=l([$({type:R.Set,itemType:hs})],kd);class uo{constructor(e={}){this.version=zr.v0,this.recipientInfos=new Ec,this.encryptedContentInfo=new io,Object.assign(this,e)}}l([h({type:v.Integer})],uo.prototype,"version",void 0);l([h({type:Ff,context:0,implicit:!0,optional:!0})],uo.prototype,"originatorInfo",void 0);l([h({type:Ec})],uo.prototype,"recipientInfos",void 0);l([h({type:io})],uo.prototype,"encryptedContentInfo",void 0);l([h({type:kd,context:1,implicit:!0,optional:!0})],uo.prototype,"unprotectedAttrs",void 0);const t1="1.2.840.113549.1.7.2";var Sd;let jc=Sd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Sd.prototype)}};jc=Sd=l([$({type:R.Set,itemType:xa})],jc);class ys{constructor(e={}){this.version=zr.v0,this.digestAlgorithms=new jc,this.encapContentInfo=new Nu,this.signerInfos=new wc,Object.assign(this,e)}}l([h({type:v.Integer})],ys.prototype,"version",void 0);l([h({type:jc})],ys.prototype,"digestAlgorithms",void 0);l([h({type:Nu})],ys.prototype,"encapContentInfo",void 0);l([h({type:Ac,context:0,implicit:!0,optional:!0})],ys.prototype,"certificates",void 0);l([h({type:Cc,context:1,implicit:!0,optional:!0})],ys.prototype,"crls",void 0);l([h({type:wc})],ys.prototype,"signerInfos",void 0);const ka="1.2.840.10045.2.1",Kf="1.2.840.10045.4.1",r0="1.2.840.10045.4.3.1",Wf="1.2.840.10045.4.3.2",zf="1.2.840.10045.4.3.3",Gf="1.2.840.10045.4.3.4",ep="1.2.840.10045.3.1.7",tp="1.3.132.0.34",rp="1.3.132.0.35";function lo(r){return new Y({algorithm:r})}const r1=lo(Kf);lo(r0);const n1=lo(Wf),i1=lo(zf),s1=lo(Gf);let Sa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],Sa.prototype,"fieldType",void 0);l([h({type:v.Any})],Sa.prototype,"parameters",void 0);Sa=l([$({type:R.Sequence})],Sa);class a1 extends De{}let rs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.OctetString})],rs.prototype,"a",void 0);l([h({type:v.OctetString})],rs.prototype,"b",void 0);l([h({type:v.BitString,optional:!0})],rs.prototype,"seed",void 0);rs=l([$({type:R.Sequence})],rs);var Ad;(function(r){r[r.ecpVer1=1]="ecpVer1"})(Ad||(Ad={}));let Gr=class{constructor(e={}){this.version=Ad.ecpVer1,Object.assign(this,e)}};l([h({type:v.Integer})],Gr.prototype,"version",void 0);l([h({type:Sa})],Gr.prototype,"fieldID",void 0);l([h({type:rs})],Gr.prototype,"curve",void 0);l([h({type:a1})],Gr.prototype,"base",void 0);l([h({type:v.Integer,converter:Ke})],Gr.prototype,"order",void 0);l([h({type:v.Integer,optional:!0})],Gr.prototype,"cofactor",void 0);Gr=l([$({type:R.Sequence})],Gr);let An=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],An.prototype,"namedCurve",void 0);l([h({type:v.Null})],An.prototype,"implicitCurve",void 0);l([h({type:Gr})],An.prototype,"specifiedCurve",void 0);An=l([$({type:R.Choice})],An);class $u{constructor(e={}){this.version=1,this.privateKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],$u.prototype,"version",void 0);l([h({type:De})],$u.prototype,"privateKey",void 0);l([h({type:An,context:0,optional:!0})],$u.prototype,"parameters",void 0);l([h({type:v.BitString,context:1,optional:!0})],$u.prototype,"publicKey",void 0);class Tc{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Tc.prototype,"r",void 0);l([h({type:v.Integer,converter:Ke})],Tc.prototype,"s",void 0);const Nt="1.2.840.113549.1.1",li=`${Nt}.1`,o1=`${Nt}.7`,c1=`${Nt}.9`,Us=`${Nt}.10`,u1=`${Nt}.2`,l1=`${Nt}.4`,Nc=`${Nt}.5`,d1=`${Nt}.14`,Od=`${Nt}.11`,Bc=`${Nt}.12`,Rc=`${Nt}.13`,n0=`${Nt}.15`,i0=`${Nt}.16`,Pc="1.3.14.3.2.26",s0="2.16.840.1.101.3.4.2.4",$c="2.16.840.1.101.3.4.2.1",Dc="2.16.840.1.101.3.4.2.2",Zc="2.16.840.1.101.3.4.2.3",f1="2.16.840.1.101.3.4.2.5",h1="2.16.840.1.101.3.4.2.6",p1="1.2.840.113549.2.2",m1="1.2.840.113549.2.5",Du=`${Nt}.8`;function at(r){return new Y({algorithm:r,parameters:null})}at(p1);at(m1);const di=at(Pc);at(s0);at($c);at(Dc);at(Zc);at(f1);at(h1);const a0=new Y({algorithm:Du,parameters:L.serialize(di)}),o0=new Y({algorithm:c1,parameters:L.serialize(hc.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});at(li);at(u1);at(l1);at(Nc);at(n0);at(i0);at(Bc);at(Rc);at(n0);at(i0);class Zu{constructor(e={}){this.hashAlgorithm=new Y(di),this.maskGenAlgorithm=new Y({algorithm:Du,parameters:L.serialize(di)}),this.pSourceAlgorithm=new Y(o0),Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:di})],Zu.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:a0})],Zu.prototype,"maskGenAlgorithm",void 0);l([h({type:Y,context:2,defaultValue:o0})],Zu.prototype,"pSourceAlgorithm",void 0);new Y({algorithm:o1,parameters:L.serialize(new Zu)});class fi{constructor(e={}){this.hashAlgorithm=new Y(di),this.maskGenAlgorithm=new Y({algorithm:Du,parameters:L.serialize(di)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:di})],fi.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:a0})],fi.prototype,"maskGenAlgorithm",void 0);l([h({type:v.Integer,context:2,defaultValue:20})],fi.prototype,"saltLength",void 0);l([h({type:v.Integer,context:3,defaultValue:1})],fi.prototype,"trailerField",void 0);new Y({algorithm:Us,parameters:L.serialize(new fi)});class Mu{constructor(e={}){this.digestAlgorithm=new Y,this.digest=new De,Object.assign(this,e)}}l([h({type:Y})],Mu.prototype,"digestAlgorithm",void 0);l([h({type:De})],Mu.prototype,"digest",void 0);var Ed;class Uu{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Uu.prototype,"prime",void 0);l([h({type:v.Integer,converter:Ke})],Uu.prototype,"exponent",void 0);l([h({type:v.Integer,converter:Ke})],Uu.prototype,"coefficient",void 0);let Id=Ed=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ed.prototype)}};Id=Ed=l([$({type:R.Sequence,itemType:Uu})],Id);class Nr{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer})],Nr.prototype,"version",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"modulus",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"publicExponent",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"privateExponent",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"prime1",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"prime2",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"exponent1",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"exponent2",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"coefficient",void 0);l([h({type:Id,optional:!0})],Nr.prototype,"otherPrimeInfos",void 0);class Jf{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Jf.prototype,"modulus",void 0);l([h({type:v.Integer,converter:Ke})],Jf.prototype,"publicExponent",void 0);var Cd;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Cd||(Cd={}));const At=Cd;/*! *****************************************************************************
79
+ `)}`:`${t} :`}}zy=Ct;X.Constructed=zy;Ct.NAME="CONSTRUCTED";class Gy extends St{fromBER(e,t,n){return t}toBER(e){return pr}}Gy.override="EndOfContentValueBlock";var Jy;class bf extends ft{constructor(e={}){super(e,Gy),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Jy=bf;X.EndOfContent=Jy;bf.NAME=va;var Yy;class ii extends ft{constructor(e={}){super(e,St),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const i=new Uint8Array(n);i[0]=5,i[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}Yy=ii;X.Null=Yy;ii.NAME="NULL";class Xy extends jr(St){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=q.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const i=q.toUint8Array(e);return Qr(this,i,t,n)?(this.valueHexView=i.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Uy.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Xy.NAME="BooleanValueBlock";var Qy;let ou=class extends ft{constructor(e={}){super(e,Xy),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Qy=ou;X.Boolean=Qy;ou.NAME="BOOLEAN";class eg extends jr(mn){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=mn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===va){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Vy)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?mn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}eg.NAME="OctetStringValueBlock";var tg;let Jn=class rg extends ft{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},eg),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const a=us(s,0,s.byteLength);a.offset!==-1&&a.offset===n&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ct.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${te.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof rg&&e.push(t.valueBlock.valueHexView);return q.concat(e)}};tg=Jn;X.OctetString=tg;Jn.NAME=Vy;class ng extends jr(mn){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let i=-1;if(this.isConstructed){if(i=mn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(const o of this.value){const c=o.constructor.NAME;if(c===va){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ly)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=o.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return i}const s=q.toUint8Array(e);if(!Qr(this,s,t,n))return-1;const a=s.subarray(t,t+n);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const o=a.subarray(1);try{if(o.byteLength){const c=us(o,0,o.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,t+n}toBER(e,t){if(this.isConstructed)return mn.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return pr;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}ng.NAME="BitStringValueBlock";var ig;let Yn=class extends ft{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},ng),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ct.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const i of t)e.push(i.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};ig=Yn;X.BitString=ig;Yn.NAME=Ly;var sg;function xw(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),i=new Uint8Array(e);let s=n.slice(0);const a=s.length-1,o=i.slice(0),c=o.length-1;let u=0;const f=c<a?a:c;let m=0;for(let B=f;B>=0;B--,m++){switch(!0){case m<o.length:u=s[a-m]+o[c-m]+t[0];break;default:u=s[a-m]+t[0]}switch(t[0]=u/10,!0){case m>=s.length:s=$l(new Uint8Array([u%10]),s);break;default:s[a-m]=u%10}}return t[0]>0&&(s=$l(t,s)),s}function $h(r){if(r>=Ss.length)for(let e=Ss.length;e<=r;e++){const t=new Uint8Array([0]);let n=Ss[e-1].slice(0);for(let i=n.length-1;i>=0;i--){const s=new Uint8Array([(n[i]<<1)+t[0]]);t[0]=s[0]/10,n[i]=s[0]%10}t[0]>0&&(n=$l(t,n)),Ss.push(n)}return Ss[r]}function _w(r,e){let t=0;const n=new Uint8Array(r),i=new Uint8Array(e),s=n.slice(0),a=s.length-1,o=i.slice(0),c=o.length-1;let u,f=0;for(let m=c;m>=0;m--,f++)switch(u=s[a-f]-o[c-f]-t,!0){case u<0:t=1,s[a-f]=u+10;break;default:t=0,s[a-f]=u}if(t>0)for(let m=a-c+1;m>=0;m--,f++)if(u=s[a-f]-t,u<0)t=1,s[a-f]=u+10;else{t=0,s[a-f]=u;break}return s.slice()}class xf extends jr(St){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Uy.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(cw(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,i=0){const s=this.fromBER(e,t,n);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){const i=super.fromBER(e,t,n);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),n=0,i;const s=this.valueHexView;let a="",o=!1;for(let c=s.byteLength-1;c>=0;c--){i=s[c];for(let u=0;u<8;u++){if((i&1)===1)switch(n){case e:t=_w($h(n),t),a="-";break;default:t=xw(t,$h(n))}n++,i>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Rh.charAt(t[c]));return o===!1&&(a+=Rh.charAt(0)),a}}sg=xf;xf.NAME="IntegerValueBlock";Object.defineProperty(sg.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var ag;class wr extends ft{constructor(e={}){super(e,xf),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return fc(),BigInt(this.valueBlock.toString())}static fromBigInt(e){fc();const t=BigInt(e),n=new su,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(te.FromHex(i));if(t<0){const o=new Uint8Array(s.length+(s[0]&128?1:0));o[0]|=128;const u=BigInt(`0x${te.ToHex(o)}`)+t,f=q.toUint8Array(te.FromHex(u.toString(16)));f[0]|=128,n.write(f)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new wr({valueHex:n.final()})}convertToDER(){const e=new wr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new wr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}ag=wr;X.Integer=ag;wr.NAME="INTEGER";var og;class cu extends wr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}og=cu;X.Enumerated=og;cu.NAME="ENUMERATED";class Dl extends jr(St){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=s[o]&127,this.blockLength++,!!(s[o]&128));o++);const a=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength;o++)a[o]=this.valueHexView[o];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Wi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){fc();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(t.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ni(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",pr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=te.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}Dl.NAME="sidBlock";class cg extends St{constructor({value:e=It,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Dl;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,pr;t.push(i)}return gf(t)}fromString(e){this.value=[];let t=0,n=0,i="",s=!1;do if(n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1,s){const a=this.value[0];let o=0;switch(a.valueDec){case 0:break;case 1:o=40;break;case 2:o=80;break;default:this.value=[];return}const c=parseInt(i,10);if(isNaN(c))return;a.valueDec=c+o,s=!1}else{const a=new Dl;if(i>Number.MAX_SAFE_INTEGER){fc();const o=BigInt(i);a.valueBigInt=o}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t?(i=`{${i}}`,this.value[n].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}cg.NAME="ObjectIdentifierValueBlock";var ug;class uu extends ft{constructor(e={}){super(e,cg),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}ug=uu;X.ObjectIdentifier=ug;uu.NAME="OBJECT IDENTIFIER";class Zl extends jr(gi){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=s[o]&127,this.blockLength++,!!(s[o]&128));o++);const a=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength;o++)a[o]=this.valueHexView[o];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Wi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ni(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",pr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=te.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Zl.NAME="relativeSidBlock";class lg extends St{constructor({value:e=It,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Zl;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,t){const n=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,pr;n.push(s)}return gf(n)}fromString(e){this.value=[];let t=0,n=0,i="";do{n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1;const s=new Zl;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}lg.NAME="RelativeObjectIdentifierValueBlock";var dg;class _f extends ft{constructor(e={}){super(e,lg),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}dg=_f;X.RelativeObjectIdentifier=dg;_f.NAME="RelativeObjectIdentifier";var fg;class Lr extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}fg=Lr;X.Sequence=fg;Lr.NAME="SEQUENCE";var hg;let qr=class extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};hg=qr;X.Set=hg;qr.NAME="SET";class pg extends jr(St){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=It}toJSON(){return{...super.toJSON(),value:this.value}}}pg.NAME="StringValueBlock";class mg extends pg{}mg.NAME="SimpleStringValueBlock";class Mt extends vf{constructor({...e}={}){super(e,mg)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,q.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}}Mt.NAME="SIMPLE STRING";class yg extends Mt{fromBuffer(e){this.valueBlock.valueHexView=q.toUint8Array(e);try{this.valueBlock.value=te.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=te.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(te.FromUtf8String(e)),this.valueBlock.value=e}}yg.NAME="Utf8StringValueBlock";var gg;class en extends yg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}gg=en;X.Utf8String=gg;en.NAME="UTF8String";class vg extends Mt{fromBuffer(e){this.valueBlock.value=te.ToUtf16String(e),this.valueBlock.valueHexView=q.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(te.FromUtf16String(e))}}vg.NAME="BmpStringValueBlock";var bg;class lu extends vg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}bg=lu;X.BmpString=bg;lu.NAME="BMPString";class xg extends Mt{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let i=0;i<t;i++){const s=ni(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;const o=4-a.length;for(let c=a.length-1;c>=0;c--)n[i*4+c+o]=a[c]}this.valueBlock.value=e}}xg.NAME="UniversalStringValueBlock";var _g;class du extends xg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}_g=du;X.UniversalString=_g;du.NAME="UniversalString";var wg;class fu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}wg=fu;X.NumericString=wg;fu.NAME="NumericString";var kg;class hu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}kg=hu;X.PrintableString=kg;hu.NAME="PrintableString";var Sg;class pu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Sg=pu;X.TeletexString=Sg;pu.NAME="TeletexString";var Ag;class mu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Ag=mu;X.VideotexString=Ag;mu.NAME="VideotexString";var Og;class yu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Og=yu;X.IA5String=Og;yu.NAME="IA5String";var Eg;class gu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Eg=gu;X.GraphicString=Eg;gu.NAME="GraphicString";var Ig;class Qa extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Ig=Qa;X.VisibleString=Ig;Qa.NAME="VisibleString";var Cg;class vu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Cg=vu;X.GeneralString=Cg;vu.NAME="GeneralString";var jg;class bu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}jg=bu;X.CharacterString=jg;bu.NAME="CharacterString";var Tg;class eo extends Qa{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,q.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=Pt(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Pt(this.month,2),t[2]=Pt(this.day,2),t[3]=Pt(this.hour,2),t[4]=Pt(this.minute,2),t[5]=Pt(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Tg=eo;X.UTCTime=Tg;eo.NAME="UTCTime";var Ng;class xu extends eo{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",i="",s=0,a,o=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const m=new Number(e[e.length-1]);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let m=1,B=n.indexOf("+"),C="";if(B===-1&&(B=n.indexOf("-"),m=-1),B!==-1){if(C=n.substring(B+1),n=n.substring(0,B),C.length!==2&&C.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(C.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(o=m*p,C.length===4){if(p=parseInt(C.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=m*p}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){const m=new Number(`0${n.substring(u)}`);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");s=m.valueOf(),i=n.substring(0,u)}else i=n;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*s;this.minute=Math.floor(m),m=60*(m-this.minute),this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*s;this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const m=1e3*s;this.millisecond=Math.floor(m)}break;default:throw new Error("Wrong input string for conversion")}const f=a.exec(i);if(f===null)throw new Error("Wrong input string for conversion");for(let m=1;m<f.length;m++)switch(m){case 1:this.year=parseInt(f[m],10);break;case 2:this.month=parseInt(f[m],10);break;case 3:this.day=parseInt(f[m],10);break;case 4:this.hour=parseInt(f[m],10)+o;break;case 5:this.minute=parseInt(f[m],10)+c;break;case 6:this.second=parseInt(f[m],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const m=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=m.getUTCFullYear(),this.month=m.getUTCMonth(),this.day=m.getUTCDay(),this.hour=m.getUTCHours(),this.minute=m.getUTCMinutes(),this.second=m.getUTCSeconds(),this.millisecond=m.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(Pt(this.year,4)),t.push(Pt(this.month,2)),t.push(Pt(this.day,2)),t.push(Pt(this.hour,2)),t.push(Pt(this.minute,2)),t.push(Pt(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Pt(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Ng=xu;X.GeneralizedTime=Ng;xu.NAME="GeneralizedTime";var Bg;class wf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Bg=wf;X.DATE=Bg;wf.NAME="DATE";var Rg;class kf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Rg=kf;X.TimeOfDay=Rg;kf.NAME="TimeOfDay";var Pg;class Sf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Pg=Sf;X.DateTime=Pg;Sf.NAME="DateTime";var $g;class Af extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}$g=Af;X.Duration=$g;Af.NAME="Duration";var Dg;class Of extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Dg=Of;X.TIME=Dg;Of.NAME="TIME";class si{constructor({name:e=It,optional:t=!1}={}){this.name=e,this.optional=t}}class Ef extends si{constructor({value:e=[],...t}={}){super(t),this.value=e}}class hc extends si{constructor({value:e=new si,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class ww{constructor({data:e=au}={}){this.dataView=q.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=q.toUint8Array(e)}fromBER(e,t,n){const i=t+n;return this.dataView=q.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}}function Vn(r,e,t){if(t instanceof Ef){for(let s=0;s<t.value.length;s++)if(Vn(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(il)&&(s.name=t.name),s}}if(t instanceof si)return t.hasOwnProperty(il)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(dw in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(mw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(yw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(fw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(hw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(pw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(lw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(Ph in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:r};for(let o=0;o<s.length;o++)if(s[o]!==a[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(r[t.name]=e)),t instanceof X.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},o=t.valueBlock.value.length;if(o>0&&t.valueBlock.value[0]instanceof hc&&(o=e.valueBlock.value.length),o===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let c=!0;for(let u=0;u<t.valueBlock.value.length;u++)c=c&&(t.valueBlock.value[u].optional||!1);return c?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let c=0;c<o;c++)if(c-s>=e.valueBlock.value.length){if(t.valueBlock.value[c].optional===!1){const u={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof hc){if(a=Vn(r,e.valueBlock.value[c],t.valueBlock.value[0].value),a.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),a;if(il in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};gw in t.valueBlock.value[0]&&t.valueBlock.value[0].local?u=e:u=r,typeof u[t.valueBlock.value[0].name]>"u"&&(u[t.valueBlock.value[0].name]=[]),u[t.valueBlock.value[0].name].push(e.valueBlock.value[c])}}else if(a=Vn(r,e.valueBlock.value[c-s],t.valueBlock.value[c]),a.verified===!1)if(t.valueBlock.value[c].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),a;if(a.verified===!1){const c={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&Ph in e.valueBlock){const s=us(e.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],a.name=t.name)),a}return Vn(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function kw(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=us(q.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Vn(t.result,t.result,e)}const Zg=Object.freeze(Object.defineProperty({__proto__:null,Any:si,BaseBlock:ft,BaseStringBlock:vf,BitString:Yn,BmpString:lu,Boolean:ou,CharacterString:bu,Choice:Ef,Constructed:Ct,DATE:wf,DateTime:Sf,Duration:Af,EndOfContent:bf,Enumerated:cu,GeneralString:vu,GeneralizedTime:xu,GraphicString:gu,HexBlock:jr,IA5String:yu,Integer:wr,Null:ii,NumericString:fu,ObjectIdentifier:uu,OctetString:Jn,Primitive:Xa,PrintableString:hu,RawData:ww,RelativeObjectIdentifier:_f,Repeated:hc,Sequence:Lr,Set:qr,TIME:Of,TeletexString:pu,TimeOfDay:kf,UTCTime:eo,UniversalString:du,Utf8String:en,ValueBlock:St,VideotexString:mu,ViewWriter:su,VisibleString:Qa,compareSchema:Vn,fromBER:Bi,verifySchema:kw},Symbol.toStringTag,{value:"Module"}));var R;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(R||(R={}));var v;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(v||(v={}));class _u{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(q.isBufferSource(e))this.unusedBits=t,this.value=q.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Yn))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new Yn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Yn({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;const i=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class De{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):q.isBufferSource(e)?this.buffer=q.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Jn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Jn({valueHex:this.buffer})}toSchema(e){return new Jn({name:e})}}const Sw={fromASN:r=>r instanceof ii?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ii;const e=Bi(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Aw={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new wr({value:+r})},Ow={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new cu({value:r})},Ke={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new wr({valueHex:r})},Ew={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Yn({valueHex:r})},Iw={fromASN:r=>r.valueBlock.toString(),toASN:r=>new uu({value:r})},Cw={fromASN:r=>r.valueBlock.value,toASN:r=>new ou({value:r})},pc={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Jn({valueHex:r})},jw={fromASN:r=>new De(r.getValue()),toASN:r=>r.toASN()};function zt(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Mg=zt(en),Tw=zt(lu),Nw=zt(du),Bw=zt(fu),Rw=zt(hu),Pw=zt(pu),$w=zt(mu),Dw=zt(yu),Zw=zt(gu),Mw=zt(Qa),Uw=zt(vu),Vw=zt(bu),Lw={fromASN:r=>r.toDate(),toASN:r=>new eo({valueDate:r})},qw={fromASN:r=>r.toDate(),toASN:r=>new xu({valueDate:r})},Hw={fromASN:()=>null,toASN:()=>new ii};function If(r){switch(r){case v.Any:return Sw;case v.BitString:return Ew;case v.BmpString:return Tw;case v.Boolean:return Cw;case v.CharacterString:return Vw;case v.Enumerated:return Ow;case v.GeneralString:return Uw;case v.GeneralizedTime:return qw;case v.GraphicString:return Zw;case v.IA5String:return Dw;case v.Integer:return Aw;case v.Null:return Hw;case v.NumericString:return Bw;case v.ObjectIdentifier:return Iw;case v.OctetString:return pc;case v.PrintableString:return Rw;case v.TeletexString:return Pw;case v.UTCTime:return Lw;case v.UniversalString:return Nw;case v.Utf8String:return Mg;case v.VideotexString:return $w;case v.VisibleString:return Mw;default:return null}}function Vr(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Vr(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Ug(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Ug(t)}return!1}function Fw(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}class Kw{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:R.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),i=[];for(const s in n.items){const a=n.items[s],o=t?s:"";let c;if(typeof a.type=="number"){const f=v[a.type],m=Zg[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else Vr(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===R.Choice?c=new si({name:o}):(c=this.create(a.type,!1),c.name=o):c=new si({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const f=a.repeated==="set"?qr:Lr;c=new f({name:"",value:[new hc({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Vr(a.type)){const f=a.repeated?Ct:Xa;i.push(new f({name:o,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const f=!!a.repeated;let m=f?c:this.get(a.type,!0).schema;m="valueBlock"in m?m.valueBlock.value:m.value,i.push(new Ct({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else i.push(new Ct({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,i.push(c)}switch(n.type){case R.Sequence:return new Lr({value:i,name:""});case R.Set:return new qr({value:i,name:""});case R.Choice:return new Ef({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const qt=new Kw,$=r=>e=>{let t;qt.has(e)?t=qt.get(e):(t=qt.createDefault(e),qt.set(e,t)),Object.assign(t,r)},h=r=>(e,t)=>{let n;qt.has(e.constructor)?n=qt.get(e.constructor):(n=qt.createDefault(e.constructor),qt.set(e.constructor,n));const i=Object.assign({},r);if(typeof i.type=="number"&&!i.converter){const s=If(r.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);i.converter=s}n.items[t]=i};class Dh extends Error{constructor(){super(...arguments),this.schemas=[]}}class Ww{static parse(e,t){const n=Bi(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){var n;try{if(Vr(t))return new t().fromASN(e);const i=qt.get(t);qt.cache(t);let s=i.schema;if(e.constructor===Ct&&i.type!==R.Choice){s=new Ct({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const c in i.items)delete e[c]}const a=Vn({},e,s);if(!a.verified)throw new Dh(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(Ug(t)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const c=i.itemType;if(typeof c=="number"){const u=If(c);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,f=>u.fromASN(f))}else return t.from(e.valueBlock.value,u=>this.fromASN(u,c))}for(const c in i.items){const u=a.result[c];if(!u)continue;const f=i.items[c],m=f.type;if(typeof m=="number"||Vr(m)){const B=(n=f.converter)!==null&&n!==void 0?n:Vr(m)?new m:null;if(!B)throw new Error("Converter is empty");if(f.repeated)if(f.implicit){const C=f.repeated==="sequence"?Lr:qr,p=new C;p.valueBlock=u.valueBlock;const g=Bi(p.toBER(!1));if(g.offset===-1)throw new Error(`Cannot parse the child item. ${g.result.error}`);if(!("value"in g.result.valueBlock&&Array.isArray(g.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const A=g.result.valueBlock.value;o[c]=Array.from(A,O=>B.fromASN(O))}else o[c]=Array.from(u,C=>B.fromASN(C));else{let C=u;if(f.implicit){let p;if(Vr(m))p=new m().toSchema("");else{const g=v[m],A=Zg[g];if(!A)throw new Error(`Cannot get '${g}' class from asn1js module`);p=new A}p.valueBlock=C.valueBlock,C=Bi(p.toBER(!1)).result}o[c]=B.fromASN(C)}}else if(f.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");o[c]=Array.from(u,B=>this.fromASN(B,m))}else o[c]=this.fromASN(u,m)}return o}catch(i){throw i instanceof Dh&&i.schemas.push(t.name),i}}}class Cf{static serialize(e){return e instanceof ft?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Vr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=qt.get(t);qt.cache(t);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const a=If(n.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);i=e.map(o=>a.toASN(o))}else i=e.map(a=>this.toAsnItem({type:n.itemType},"[]",t,a))}else for(const a in n.items){const o=n.items[a],c=e[a];if(c===void 0||o.defaultValue===c||typeof o.defaultValue=="object"&&typeof c=="object"&&Fw(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=Cf.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||Vr(o.type))){const f={};f.valueHex=u instanceof ii?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new Xa({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else i.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else i.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else o.repeated?i=i.concat(u):i.push(u)}let s;switch(n.type){case R.Sequence:s=new Lr({value:i});break;case R.Set:s=new qr({value:i});break;case R.Choice:if(!i[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,t,n,i){let s;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${t}' doesn't have converter for type ${v[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,u=>a.toASN(u)),c=e.repeated==="sequence"?Lr:qr;s=new c({value:o})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(i,c=>this.toASN(c)),o=e.repeated==="sequence"?Lr:qr;s=new o({value:a})}else s=this.toASN(i);return s}}class Ve extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class L{static serialize(e){return Cf.serialize(e)}static parse(e,t){return Ww.parse(e,t)}static toString(e){const t=q.isBufferSource(e)?q.toArrayBuffer(e):L.serialize(e),n=Bi(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function l(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}var Vg={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${t}\\.${t}\\.${t}\\.${t}(${a})?$`,"i")};function u(p,g){if(p.indexOf("::")!==p.lastIndexOf("::"))return null;let A=0,O=-1,P=(p.match(c.zoneIndex)||[])[0],N,xe;for(P&&(P=P.substring(1),p=p.replace(/%.+$/,""));(O=p.indexOf(":",O+1))>=0;)A++;if(p.substr(0,2)==="::"&&A--,p.substr(-2,2)==="::"&&A--,A>g)return null;for(xe=g-A,N=":";xe--;)N+="0:";return p=p.replace("::",N),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),g=function(){const Le=p.split(":"),qe=[];for(let Ze=0;Ze<Le.length;Ze++)qe.push(parseInt(Le[Ze],16));return qe}(),{parts:g,zoneId:P}}function f(p,g,A,O){if(p.length!==g.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let P=0,N;for(;O>0;){if(N=A-O,N<0&&(N=0),p[P]>>N!==g[P]>>N)return!1;O-=A,P+=1}return!0}function m(p){if(s.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(i.test(p))return parseInt(p,8);throw new Error(`ipaddr: cannot parse ${p} as octal`)}return parseInt(p,10)}function B(p,g){for(;p.length<g;)p=`0${p}`;return p}const C={};C.IPv4=function(){function p(g){if(g.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,O;for(A=0;A<g.length;A++)if(O=g[A],!(0<=O&&O<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=g}return p.prototype.SpecialRanges={unspecified:[[new p([0,0,0,0]),8]],broadcast:[[new p([255,255,255,255]),32]],multicast:[[new p([224,0,0,0]),4]],linkLocal:[[new p([169,254,0,0]),16]],loopback:[[new p([127,0,0,0]),8]],carrierGradeNat:[[new p([100,64,0,0]),10]],private:[[new p([10,0,0,0]),8],[new p([172,16,0,0]),12],[new p([192,168,0,0]),16]],reserved:[[new p([192,0,0,0]),24],[new p([192,0,2,0]),24],[new p([192,88,99,0]),24],[new p([198,18,0,0]),15],[new p([198,51,100,0]),24],[new p([203,0,113,0]),24],[new p([240,0,0,0]),4]],as112:[[new p([192,175,48,0]),24],[new p([192,31,196,0]),24]],amt:[[new p([192,52,193,0]),24]]},p.prototype.kind=function(){return"ipv4"},p.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,g.octets,8,A)},p.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let P,N,xe;for(P=3;P>=0;P-=1)if(N=this.octets[P],N in O){if(xe=O[N],A&&xe!==0)return null;xe!==8&&(A=!0),g+=xe}else return null;return 32-g},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){return this.octets.slice(0)},p.prototype.toIPv4MappedAddress=function(){return C.IPv6.parse(`::ffff:${this.toString()}`)},p.prototype.toNormalizedString=function(){return this.toString()},p.prototype.toString=function(){return this.octets.join(".")},p}(),C.IPv4.broadcastAddressFromCIDR=function(p){try{const g=this.parseCIDR(p),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[];let N=0;for(;N<4;)P.push(parseInt(A[N],10)|parseInt(O[N],10)^255),N++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},C.IPv4.isIPv4=function(p){return this.parser(p)!==null},C.IPv4.isValid=function(p){try{return new this(this.parser(p)),!0}catch{return!1}},C.IPv4.isValidCIDR=function(p){try{return this.parseCIDR(p),!0}catch{return!1}},C.IPv4.isValidFourPartDecimal=function(p){return!!(C.IPv4.isValid(p)&&p.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},C.IPv4.networkAddressFromCIDR=function(p){let g,A,O,P,N;try{for(g=this.parseCIDR(p),O=g[0].toByteArray(),N=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[],A=0;A<4;)P.push(parseInt(O[A],10)&parseInt(N[A],10)),A++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},C.IPv4.parse=function(p){const g=this.parser(p);if(g===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(g)},C.IPv4.parseCIDR=function(p){let g;if(g=p.match(/^(.+)\/(\d+)$/)){const A=parseInt(g[2]);if(A>=0&&A<=32){const O=[this.parse(g[1]),A];return Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},C.IPv4.parser=function(p){let g,A,O;if(g=p.match(n.fourOctet))return function(){const P=g.slice(1,6),N=[];for(let xe=0;xe<P.length;xe++)A=P[xe],N.push(m(A));return N}();if(g=p.match(n.longValue)){if(O=m(g[1]),O>4294967295||O<0)throw new Error("ipaddr: address outside defined range");return function(){const P=[];let N;for(N=0;N<=24;N+=8)P.push(O>>N&255);return P}().reverse()}else return(g=p.match(n.twoOctet))?function(){const P=g.slice(1,4),N=[];if(O=m(P[1]),O>16777215||O<0)throw new Error("ipaddr: address outside defined range");return N.push(m(P[0])),N.push(O>>16&255),N.push(O>>8&255),N.push(O&255),N}():(g=p.match(n.threeOctet))?function(){const P=g.slice(1,5),N=[];if(O=m(P[2]),O>65535||O<0)throw new Error("ipaddr: address outside defined range");return N.push(m(P[0])),N.push(m(P[1])),N.push(O>>8&255),N.push(O&255),N}():null},C.IPv4.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>32)throw new Error("ipaddr: invalid IPv4 prefix length");const g=[0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)g[A]=255,A++;return O<4&&(g[O]=Math.pow(2,p%8)-1<<8-p%8),new this(g)},C.IPv6=function(){function p(g,A){let O,P;if(g.length===16)for(this.parts=[],O=0;O<=14;O+=2)this.parts.push(g[O]<<8|g[O+1]);else if(g.length===8)this.parts=g;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(O=0;O<this.parts.length;O++)if(P=this.parts[O],!(0<=P&&P<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");A&&(this.zoneId=A)}return p.prototype.SpecialRanges={unspecified:[new p([0,0,0,0,0,0,0,0]),128],linkLocal:[new p([65152,0,0,0,0,0,0,0]),10],multicast:[new p([65280,0,0,0,0,0,0,0]),8],loopback:[new p([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new p([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new p([0,0,0,0,0,65535,0,0]),96],discard:[new p([256,0,0,0,0,0,0,0]),64],rfc6145:[new p([0,0,0,0,65535,0,0,0]),96],rfc6052:[new p([100,65435,0,0,0,0,0,0]),96],"6to4":[new p([8194,0,0,0,0,0,0,0]),16],teredo:[new p([8193,0,0,0,0,0,0,0]),32],benchmarking:[new p([8193,2,0,0,0,0,0,0]),48],amt:[new p([8193,3,0,0,0,0,0,0]),32],as112v6:[[new p([8193,4,274,0,0,0,0,0]),48],[new p([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new p([8193,16,0,0,0,0,0,0]),28],orchid2:[new p([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new p([8193,48,0,0,0,0,0,0]),28],reserved:[[new p([8193,0,0,0,0,0,0,0]),23],[new p([8193,3512,0,0,0,0,0,0]),32]]},p.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},p.prototype.kind=function(){return"ipv6"},p.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,g.parts,16,A)},p.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let P,N;for(let xe=7;xe>=0;xe-=1)if(P=this.parts[xe],P in O){if(N=O[P],A&&N!==0)return null;N!==16&&(A=!0),g+=N}else return null;return 128-g},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let g;const A=[],O=this.parts;for(let P=0;P<O.length;P++)g=O[P],A.push(g>>8),A.push(g&255);return A},p.prototype.toFixedLengthString=function(){const g=(function(){const O=[];for(let P=0;P<this.parts.length;P++)O.push(B(this.parts[P].toString(16),4));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},p.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const g=this.parts.slice(-2),A=g[0],O=g[1];return new C.IPv4([A>>8,A&255,O>>8,O&255])},p.prototype.toNormalizedString=function(){const g=(function(){const O=[];for(let P=0;P<this.parts.length;P++)O.push(this.parts[P].toString(16));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},p.prototype.toRFC5952String=function(){const g=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString();let O=0,P=-1,N;for(;N=g.exec(A);)N[0].length>P&&(O=N.index,P=N[0].length);return P<0?A:`${A.substring(0,O)}::${A.substring(O+P)}`},p.prototype.toString=function(){return this.toRFC5952String()},p}(),C.IPv6.broadcastAddressFromCIDR=function(p){try{const g=this.parseCIDR(p),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[];let N=0;for(;N<16;)P.push(parseInt(A[N],10)|parseInt(O[N],10)^255),N++;return new this(P)}catch(g){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${g})`)}},C.IPv6.isIPv6=function(p){return this.parser(p)!==null},C.IPv6.isValid=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{const g=this.parser(p);return new this(g.parts,g.zoneId),!0}catch{return!1}},C.IPv6.isValidCIDR=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{return this.parseCIDR(p),!0}catch{return!1}},C.IPv6.networkAddressFromCIDR=function(p){let g,A,O,P,N;try{for(g=this.parseCIDR(p),O=g[0].toByteArray(),N=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[],A=0;A<16;)P.push(parseInt(O[A],10)&parseInt(N[A],10)),A++;return new this(P)}catch(xe){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${xe})`)}},C.IPv6.parse=function(p){const g=this.parser(p);if(g.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(g.parts,g.zoneId)},C.IPv6.parseCIDR=function(p){let g,A,O;if((A=p.match(/^(.+)\/(\d+)$/))&&(g=parseInt(A[2]),g>=0&&g<=128))return O=[this.parse(A[1]),g],Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},C.IPv6.parser=function(p){let g,A,O,P,N,xe;if(O=p.match(c.deprecatedTransitional))return this.parser(`::ffff:${O[1]}`);if(c.native.test(p))return u(p,8);if((O=p.match(c.transitional))&&(xe=O[6]||"",g=O[1],O[1].endsWith("::")||(g=g.slice(0,-1)),g=u(g+xe,6),g.parts)){for(N=[parseInt(O[2]),parseInt(O[3]),parseInt(O[4]),parseInt(O[5])],A=0;A<N.length;A++)if(P=N[A],!(0<=P&&P<=255))return null;return g.parts.push(N[0]<<8|N[1]),g.parts.push(N[2]<<8|N[3]),{parts:g.parts,zoneId:g.zoneId}}return null},C.IPv6.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>128)throw new Error("ipaddr: invalid IPv6 prefix length");const g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)g[A]=255,A++;return O<16&&(g[O]=Math.pow(2,p%8)-1<<8-p%8),new this(g)},C.fromByteArray=function(p){const g=p.length;if(g===4)return new C.IPv4(p);if(g===16)return new C.IPv6(p);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},C.isValid=function(p){return C.IPv6.isValid(p)||C.IPv4.isValid(p)},C.isValidCIDR=function(p){return C.IPv6.isValidCIDR(p)||C.IPv4.isValidCIDR(p)},C.parse=function(p){if(C.IPv6.isValid(p))return C.IPv6.parse(p);if(C.IPv4.isValid(p))return C.IPv4.parse(p);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},C.parseCIDR=function(p){try{return C.IPv6.parseCIDR(p)}catch{try{return C.IPv4.parseCIDR(p)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},C.process=function(p){const g=this.parse(p);return g.kind()==="ipv6"&&g.isIPv4MappedAddress()?g.toIPv4Address():g},C.subnetMatch=function(p,g,A){let O,P,N,xe;A==null&&(A="unicast");for(P in g)if(Object.prototype.hasOwnProperty.call(g,P)){for(N=g[P],N[0]&&!(N[0]instanceof Array)&&(N=[N]),O=0;O<N.length;O++)if(xe=N[O],p.kind()===xe[0].kind()&&p.match.apply(p,xe))return P}return A},r.exports?r.exports=C:e.ipaddr=C})(lc)})(Vg);var Zh=Vg.exports;class Mh{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return Zh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(te.ToHex(e))}static fromString(e){const t=Zh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var Ml,Ul,Vl;let ht=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};l([h({type:v.TeletexString})],ht.prototype,"teletexString",void 0);l([h({type:v.PrintableString})],ht.prototype,"printableString",void 0);l([h({type:v.UniversalString})],ht.prototype,"universalString",void 0);l([h({type:v.Utf8String})],ht.prototype,"utf8String",void 0);l([h({type:v.BmpString})],ht.prototype,"bmpString",void 0);ht=l([$({type:R.Choice})],ht);let zi=class extends ht{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?te.ToHex(this.anyValue):super.toString())}};l([h({type:v.IA5String})],zi.prototype,"ia5String",void 0);l([h({type:v.Any})],zi.prototype,"anyValue",void 0);zi=l([$({type:R.Choice})],zi);class wu{constructor(e={}){this.type="",this.value=new zi,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],wu.prototype,"type",void 0);l([h({type:zi})],wu.prototype,"value",void 0);let Gi=Ml=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ml.prototype)}};Gi=Ml=l([$({type:R.Set,itemType:wu})],Gi);let Ll=Ul=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ul.prototype)}};Ll=Ul=l([$({type:R.Sequence,itemType:Gi})],Ll);let et=Vl=class extends Ll{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};et=Vl=l([$({type:R.Sequence})],et);const zw={fromASN:r=>Mh.toString(pc.fromASN(r)),toASN:r=>pc.toASN(Mh.fromString(r))};class ba{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],ba.prototype,"typeId",void 0);l([h({type:v.Any,context:0})],ba.prototype,"value",void 0);class jf{constructor(e={}){this.partyName=new ht,Object.assign(this,e)}}l([h({type:ht,optional:!0,context:0,implicit:!0})],jf.prototype,"nameAssigner",void 0);l([h({type:ht,context:1,implicit:!0})],jf.prototype,"partyName",void 0);let be=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ba,context:0,implicit:!0})],be.prototype,"otherName",void 0);l([h({type:v.IA5String,context:1,implicit:!0})],be.prototype,"rfc822Name",void 0);l([h({type:v.IA5String,context:2,implicit:!0})],be.prototype,"dNSName",void 0);l([h({type:v.Any,context:3,implicit:!0})],be.prototype,"x400Address",void 0);l([h({type:et,context:4,implicit:!1})],be.prototype,"directoryName",void 0);l([h({type:jf,context:5})],be.prototype,"ediPartyName",void 0);l([h({type:v.IA5String,context:6,implicit:!0})],be.prototype,"uniformResourceIdentifier",void 0);l([h({type:v.OctetString,context:7,implicit:!0,converter:zw})],be.prototype,"iPAddress",void 0);l([h({type:v.ObjectIdentifier,context:8,implicit:!0})],be.prototype,"registeredID",void 0);be=l([$({type:R.Choice})],be);const Tf="1.3.6.1.5.5.7",Gw=`${Tf}.1`,ls=`${Tf}.3`,ku=`${Tf}.48`,Uh=`${ku}.1`,Vh=`${ku}.2`,Lh=`${ku}.3`,qh=`${ku}.5`,Tn="2.5.29";var ql;const Hl=`${Gw}.1`;class to{constructor(e={}){this.accessMethod="",this.accessLocation=new be,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],to.prototype,"accessMethod",void 0);l([h({type:be})],to.prototype,"accessLocation",void 0);let Ii=ql=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,ql.prototype)}};Ii=ql=l([$({type:R.Sequence,itemType:to})],Ii);const Fl=`${Tn}.35`;class Nf extends De{}class Ln{constructor(e={}){e&&Object.assign(this,e)}}l([h({type:Nf,context:0,optional:!0,implicit:!0})],Ln.prototype,"keyIdentifier",void 0);l([h({type:be,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Ln.prototype,"authorityCertIssuer",void 0);l([h({type:v.Integer,context:2,optional:!0,implicit:!0,converter:Ke})],Ln.prototype,"authorityCertSerialNumber",void 0);const Lg=`${Tn}.19`;class mc{constructor(e={}){this.cA=!1,Object.assign(this,e)}}l([h({type:v.Boolean,defaultValue:!1})],mc.prototype,"cA",void 0);l([h({type:v.Integer,optional:!0})],mc.prototype,"pathLenConstraint",void 0);var Kl;let xt=Kl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};xt=Kl=l([$({type:R.Sequence,itemType:be})],xt);var Wl;let Hh=Wl=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,Wl.prototype)}};Hh=Wl=l([$({type:R.Sequence})],Hh);var zl;const qg=`${Tn}.32`;let Kr=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};l([h({type:v.IA5String})],Kr.prototype,"ia5String",void 0);l([h({type:v.VisibleString})],Kr.prototype,"visibleString",void 0);l([h({type:v.BmpString})],Kr.prototype,"bmpString",void 0);l([h({type:v.Utf8String})],Kr.prototype,"utf8String",void 0);Kr=l([$({type:R.Choice})],Kr);class Bf{constructor(e={}){this.organization=new Kr,this.noticeNumbers=[],Object.assign(this,e)}}l([h({type:Kr})],Bf.prototype,"organization",void 0);l([h({type:v.Integer,repeated:"sequence"})],Bf.prototype,"noticeNumbers",void 0);class Rf{constructor(e={}){Object.assign(this,e)}}l([h({type:Bf,optional:!0})],Rf.prototype,"noticeRef",void 0);l([h({type:Kr,optional:!0})],Rf.prototype,"explicitText",void 0);let yc=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.IA5String})],yc.prototype,"cPSuri",void 0);l([h({type:Rf})],yc.prototype,"userNotice",void 0);yc=l([$({type:R.Choice})],yc);class Pf{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Pf.prototype,"policyQualifierId",void 0);l([h({type:v.Any})],Pf.prototype,"qualifier",void 0);class Su{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Su.prototype,"policyIdentifier",void 0);l([h({type:Pf,repeated:"sequence",optional:!0})],Su.prototype,"policyQualifiers",void 0);let gc=zl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};gc=zl=l([$({type:R.Sequence,itemType:Su})],gc);let vc=class{constructor(e=0){this.value=e}};l([h({type:v.Integer})],vc.prototype,"value",void 0);vc=l([$({type:R.Choice})],vc);let Fh=class extends vc{};Fh=l([$({type:R.Choice})],Fh);var Gl;const Jl=`${Tn}.31`;var Qt;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Qt||(Qt={}));class Hg extends _u{toJSON(){const e=[],t=this.toNumber();return t&Qt.aACompromise&&e.push("aACompromise"),t&Qt.affiliationChanged&&e.push("affiliationChanged"),t&Qt.cACompromise&&e.push("cACompromise"),t&Qt.certificateHold&&e.push("certificateHold"),t&Qt.cessationOfOperation&&e.push("cessationOfOperation"),t&Qt.keyCompromise&&e.push("keyCompromise"),t&Qt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Qt.superseded&&e.push("superseded"),t&Qt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let ai=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,context:0,repeated:"sequence",implicit:!0})],ai.prototype,"fullName",void 0);l([h({type:Gi,context:1,implicit:!0})],ai.prototype,"nameRelativeToCRLIssuer",void 0);ai=l([$({type:R.Choice})],ai);class ds{constructor(e={}){Object.assign(this,e)}}l([h({type:ai,context:0,optional:!0})],ds.prototype,"distributionPoint",void 0);l([h({type:Hg,context:1,optional:!0,implicit:!0})],ds.prototype,"reasons",void 0);l([h({type:be,context:2,optional:!0,repeated:"sequence",implicit:!0})],ds.prototype,"cRLIssuer",void 0);let Ri=Gl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Gl.prototype)}};Ri=Gl=l([$({type:R.Sequence,itemType:ds})],Ri);var Yl;let Kh=Yl=class extends Ri{constructor(e){super(e),Object.setPrototypeOf(this,Yl.prototype)}};Kh=Yl=l([$({type:R.Sequence,itemType:ds})],Kh);class yt{constructor(e={}){this.onlyContainsUserCerts=yt.ONLY,this.onlyContainsCACerts=yt.ONLY,this.indirectCRL=yt.ONLY,this.onlyContainsAttributeCerts=yt.ONLY,Object.assign(this,e)}}yt.ONLY=!1;l([h({type:ai,context:0,optional:!0})],yt.prototype,"distributionPoint",void 0);l([h({type:v.Boolean,context:1,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsUserCerts",void 0);l([h({type:v.Boolean,context:2,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsCACerts",void 0);l([h({type:Hg,context:3,optional:!0,implicit:!0})],yt.prototype,"onlySomeReasons",void 0);l([h({type:v.Boolean,context:4,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"indirectCRL",void 0);l([h({type:v.Boolean,context:5,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsAttributeCerts",void 0);var Zs;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Zs||(Zs={}));let Xl=class{constructor(e=Zs.unspecified){this.reason=Zs.unspecified,this.reason=e}toJSON(){return Zs[this.reason]}toString(){return this.toJSON()}};l([h({type:v.Enumerated})],Xl.prototype,"reason",void 0);Xl=l([$({type:R.Choice})],Xl);var Ql;const Fg=`${Tn}.37`;let bc=Ql=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ql.prototype)}};bc=Ql=l([$({type:R.Sequence,itemType:v.ObjectIdentifier})],bc);const Jw=`${ls}.1`,Yw=`${ls}.2`,Xw=`${ls}.3`,Qw=`${ls}.4`,e1=`${ls}.8`,t1=`${ls}.9`;let ed=class{constructor(e=new ArrayBuffer(0)){this.value=e}};l([h({type:v.Integer,converter:Ke})],ed.prototype,"value",void 0);ed=l([$({type:R.Choice})],ed);let td=class{constructor(e){this.value=new Date,e&&(this.value=e)}};l([h({type:v.GeneralizedTime})],td.prototype,"value",void 0);td=l([$({type:R.Choice})],td);var rd;let Wh=rd=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,rd.prototype)}};Wh=rd=l([$({type:R.Sequence})],Wh);const Kg=`${Tn}.15`;var er;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(er||(er={}));class sl extends _u{toJSON(){const e=this.toNumber(),t=[];return e&er.cRLSign&&t.push("crlSign"),e&er.dataEncipherment&&t.push("dataEncipherment"),e&er.decipherOnly&&t.push("decipherOnly"),e&er.digitalSignature&&t.push("digitalSignature"),e&er.encipherOnly&&t.push("encipherOnly"),e&er.keyAgreement&&t.push("keyAgreement"),e&er.keyCertSign&&t.push("keyCertSign"),e&er.keyEncipherment&&t.push("keyEncipherment"),e&er.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var nd;class Au{constructor(e={}){this.base=new be,this.minimum=0,Object.assign(this,e)}}l([h({type:be})],Au.prototype,"base",void 0);l([h({type:v.Integer,context:0,defaultValue:0,implicit:!0})],Au.prototype,"minimum",void 0);l([h({type:v.Integer,context:1,optional:!0,implicit:!0})],Au.prototype,"maximum",void 0);let xc=nd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,nd.prototype)}};xc=nd=l([$({type:R.Sequence,itemType:Au})],xc);class Wg{constructor(e={}){Object.assign(this,e)}}l([h({type:xc,context:0,optional:!0,implicit:!0})],Wg.prototype,"permittedSubtrees",void 0);l([h({type:xc,context:1,optional:!0,implicit:!0})],Wg.prototype,"excludedSubtrees",void 0);class zg{constructor(e={}){Object.assign(this,e)}}l([h({type:v.Integer,context:0,implicit:!0,optional:!0,converter:Ke})],zg.prototype,"requireExplicitPolicy",void 0);l([h({type:v.Integer,context:1,implicit:!0,optional:!0,converter:Ke})],zg.prototype,"inhibitPolicyMapping",void 0);var id;class $f{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],$f.prototype,"issuerDomainPolicy",void 0);l([h({type:v.ObjectIdentifier})],$f.prototype,"subjectDomainPolicy",void 0);let zh=id=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,id.prototype)}};zh=id=l([$({type:R.Sequence,itemType:$f})],zh);var sd;const Gg=`${Tn}.17`;let ad=sd=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,sd.prototype)}};ad=sd=l([$({type:R.Sequence})],ad);let Wr=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],Wr.prototype,"type",void 0);l([h({type:v.Any,repeated:"set"})],Wr.prototype,"values",void 0);var od;let Gh=od=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,od.prototype)}};Gh=od=l([$({type:R.Sequence,itemType:Wr})],Gh);const Jg=`${Tn}.14`;class yn extends Nf{}class Yg{constructor(e={}){Object.assign(this,e)}}l([h({type:v.GeneralizedTime,context:0,implicit:!0,optional:!0})],Yg.prototype,"notBefore",void 0);l([h({type:v.GeneralizedTime,context:1,implicit:!0,optional:!0})],Yg.prototype,"notAfter",void 0);var Ms;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Ms||(Ms={}));class Xg extends _u{toJSON(){const e=[],t=this.toNumber();return t&Ms.pKIXCertificate&&e.push("pKIXCertificate"),t&Ms.newExtensions&&e.push("newExtensions"),t&Ms.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Qg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Xg,Object.assign(this,e)}}l([h({type:v.GeneralString})],Qg.prototype,"entrustVers",void 0);l([h({type:Xg})],Qg.prototype,"entrustInfoFlags",void 0);var cd;let Jh=cd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,cd.prototype)}};Jh=cd=l([$({type:R.Sequence,itemType:to})],Jh);class Y{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof Y&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&My(e.parameters,this.parameters)||e.parameters===this.parameters)}}l([h({type:v.ObjectIdentifier})],Y.prototype,"algorithm",void 0);l([h({type:v.Any,optional:!0})],Y.prototype,"parameters",void 0);class sr{constructor(e={}){this.algorithm=new Y,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],sr.prototype,"algorithm",void 0);l([h({type:v.BitString})],sr.prototype,"subjectPublicKey",void 0);let lt=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};l([h({type:v.UTCTime})],lt.prototype,"utcTime",void 0);l([h({type:v.GeneralizedTime})],lt.prototype,"generalTime",void 0);lt=l([$({type:R.Choice})],lt);class ro{constructor(e){this.notBefore=new lt(new Date),this.notAfter=new lt(new Date),e&&(this.notBefore=new lt(e.notBefore),this.notAfter=new lt(e.notAfter))}}l([h({type:lt})],ro.prototype,"notBefore",void 0);l([h({type:lt})],ro.prototype,"notAfter",void 0);var ud;let Wt=class e0{constructor(e={}){this.extnID="",this.critical=e0.CRITICAL,this.extnValue=new De,Object.assign(this,e)}};Wt.CRITICAL=!1;l([h({type:v.ObjectIdentifier})],Wt.prototype,"extnID",void 0);l([h({type:v.Boolean,defaultValue:Wt.CRITICAL})],Wt.prototype,"critical",void 0);l([h({type:De})],Wt.prototype,"extnValue",void 0);let kn=ud=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,ud.prototype)}};kn=ud=l([$({type:R.Sequence,itemType:Wt})],kn);var oi;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(oi||(oi={}));class Ut{constructor(e={}){this.version=oi.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new Y,this.issuer=new et,this.validity=new ro,this.subject=new et,this.subjectPublicKeyInfo=new sr,Object.assign(this,e)}}l([h({type:v.Integer,context:0,defaultValue:oi.v1})],Ut.prototype,"version",void 0);l([h({type:v.Integer,converter:Ke})],Ut.prototype,"serialNumber",void 0);l([h({type:Y})],Ut.prototype,"signature",void 0);l([h({type:et})],Ut.prototype,"issuer",void 0);l([h({type:ro})],Ut.prototype,"validity",void 0);l([h({type:et})],Ut.prototype,"subject",void 0);l([h({type:sr})],Ut.prototype,"subjectPublicKeyInfo",void 0);l([h({type:v.BitString,context:1,implicit:!0,optional:!0})],Ut.prototype,"issuerUniqueID",void 0);l([h({type:v.BitString,context:2,implicit:!0,optional:!0})],Ut.prototype,"subjectUniqueID",void 0);l([h({type:kn,context:3,optional:!0})],Ut.prototype,"extensions",void 0);class ci{constructor(e={}){this.tbsCertificate=new Ut,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Ut})],ci.prototype,"tbsCertificate",void 0);l([h({type:Y})],ci.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],ci.prototype,"signatureValue",void 0);class Ou{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new lt,Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Ou.prototype,"userCertificate",void 0);l([h({type:lt})],Ou.prototype,"revocationDate",void 0);l([h({type:Wt,optional:!0,repeated:"sequence"})],Ou.prototype,"crlEntryExtensions",void 0);class tn{constructor(e={}){this.signature=new Y,this.issuer=new et,this.thisUpdate=new lt,Object.assign(this,e)}}l([h({type:v.Integer,optional:!0})],tn.prototype,"version",void 0);l([h({type:Y})],tn.prototype,"signature",void 0);l([h({type:et})],tn.prototype,"issuer",void 0);l([h({type:lt})],tn.prototype,"thisUpdate",void 0);l([h({type:lt,optional:!0})],tn.prototype,"nextUpdate",void 0);l([h({type:Ou,repeated:"sequence",optional:!0})],tn.prototype,"revokedCertificates",void 0);l([h({type:Wt,optional:!0,context:0,repeated:"sequence"})],tn.prototype,"crlExtensions",void 0);class Df{constructor(e={}){this.tbsCertList=new tn,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:tn})],Df.prototype,"tbsCertList",void 0);l([h({type:Y})],Df.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],Df.prototype,"signature",void 0);class fs{constructor(e={}){this.issuer=new et,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:et})],fs.prototype,"issuer",void 0);l([h({type:v.Integer,converter:Ke})],fs.prototype,"serialNumber",void 0);let Ji=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0})],Ji.prototype,"subjectKeyIdentifier",void 0);l([h({type:fs})],Ji.prototype,"issuerAndSerialNumber",void 0);Ji=l([$({type:R.Choice})],Ji);var zr;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(zr||(zr={}));let xa=class extends Y{};xa=l([$({type:R.Sequence})],xa);let _c=class extends Y{};_c=l([$({type:R.Sequence})],_c);let Er=class extends Y{};Er=l([$({type:R.Sequence})],Er);let wc=class extends Y{};wc=l([$({type:R.Sequence})],wc);let Yh=class extends Y{};Yh=l([$({type:R.Sequence})],Yh);let ld=class extends Y{};ld=l([$({type:R.Sequence})],ld);let hs=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],hs.prototype,"attrType",void 0);l([h({type:v.Any,repeated:"set"})],hs.prototype,"attrValues",void 0);var dd;class Tr{constructor(e={}){this.version=zr.v0,this.sid=new Ji,this.digestAlgorithm=new xa,this.signatureAlgorithm=new _c,this.signature=new De,Object.assign(this,e)}}l([h({type:v.Integer})],Tr.prototype,"version",void 0);l([h({type:Ji})],Tr.prototype,"sid",void 0);l([h({type:xa})],Tr.prototype,"digestAlgorithm",void 0);l([h({type:hs,repeated:"set",context:0,implicit:!0,optional:!0})],Tr.prototype,"signedAttrs",void 0);l([h({type:_c})],Tr.prototype,"signatureAlgorithm",void 0);l([h({type:De})],Tr.prototype,"signature",void 0);l([h({type:hs,repeated:"set",context:1,implicit:!0,optional:!0})],Tr.prototype,"unsignedAttrs",void 0);let kc=dd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,dd.prototype)}};kc=dd=l([$({type:R.Set,itemType:Tr})],kc);let Xh=class extends lt{};Xh=l([$({type:R.Choice})],Xh);let Qh=class extends Tr{};Qh=l([$({type:R.Sequence})],Qh);class Zf{constructor(e={}){this.acIssuer=new be,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}l([h({type:be})],Zf.prototype,"acIssuer",void 0);l([h({type:v.Integer})],Zf.prototype,"acSerial",void 0);l([h({type:Wr,repeated:"sequence"})],Zf.prototype,"attrs",void 0);var fd;let Sc=fd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,fd.prototype)}};Sc=fd=l([$({type:R.Sequence,itemType:v.ObjectIdentifier})],Sc);class Eu{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}l([h({type:v.Integer,optional:!0})],Eu.prototype,"pathLenConstraint",void 0);l([h({type:Sc,implicit:!0,context:0,optional:!0})],Eu.prototype,"permittedAttrs",void 0);l([h({type:Sc,implicit:!0,context:1,optional:!0})],Eu.prototype,"excludedAttrs",void 0);l([h({type:v.Boolean,defaultValue:!0})],Eu.prototype,"permitUnSpecified",void 0);class vi{constructor(e={}){this.issuer=new xt,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:xt})],vi.prototype,"issuer",void 0);l([h({type:v.Integer,converter:Ke})],vi.prototype,"serial",void 0);l([h({type:v.BitString,optional:!0})],vi.prototype,"issuerUID",void 0);var hd;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(hd||(hd={}));class bi{constructor(e={}){this.digestedObjectType=hd.publicKey,this.digestAlgorithm=new Y,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Enumerated})],bi.prototype,"digestedObjectType",void 0);l([h({type:v.ObjectIdentifier,optional:!0})],bi.prototype,"otherObjectTypeID",void 0);l([h({type:Y})],bi.prototype,"digestAlgorithm",void 0);l([h({type:v.BitString})],bi.prototype,"objectDigest",void 0);class Iu{constructor(e={}){Object.assign(this,e)}}l([h({type:xt,optional:!0})],Iu.prototype,"issuerName",void 0);l([h({type:vi,context:0,implicit:!0,optional:!0})],Iu.prototype,"baseCertificateID",void 0);l([h({type:bi,context:1,implicit:!0,optional:!0})],Iu.prototype,"objectDigestInfo",void 0);let Yi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,repeated:"sequence"})],Yi.prototype,"v1Form",void 0);l([h({type:Iu,context:0,implicit:!0})],Yi.prototype,"v2Form",void 0);Yi=l([$({type:R.Choice})],Yi);class Cu{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}l([h({type:v.GeneralizedTime})],Cu.prototype,"notBeforeTime",void 0);l([h({type:v.GeneralizedTime})],Cu.prototype,"notAfterTime",void 0);class no{constructor(e={}){Object.assign(this,e)}}l([h({type:vi,implicit:!0,context:0,optional:!0})],no.prototype,"baseCertificateID",void 0);l([h({type:xt,implicit:!0,context:1,optional:!0})],no.prototype,"entityName",void 0);l([h({type:bi,implicit:!0,context:2,optional:!0})],no.prototype,"objectDigestInfo",void 0);var pd;(function(r){r[r.v2=1]="v2"})(pd||(pd={}));class mr{constructor(e={}){this.version=pd.v2,this.holder=new no,this.issuer=new Yi,this.signature=new Y,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Cu,this.attributes=[],Object.assign(this,e)}}l([h({type:v.Integer})],mr.prototype,"version",void 0);l([h({type:no})],mr.prototype,"holder",void 0);l([h({type:Yi})],mr.prototype,"issuer",void 0);l([h({type:Y})],mr.prototype,"signature",void 0);l([h({type:v.Integer,converter:Ke})],mr.prototype,"serialNumber",void 0);l([h({type:Cu})],mr.prototype,"attrCertValidityPeriod",void 0);l([h({type:Wr,repeated:"sequence"})],mr.prototype,"attributes",void 0);l([h({type:v.BitString,optional:!0})],mr.prototype,"issuerUniqueID",void 0);l([h({type:kn,optional:!0})],mr.prototype,"extensions",void 0);class ju{constructor(e={}){this.acinfo=new mr,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:mr})],ju.prototype,"acinfo",void 0);l([h({type:Y})],ju.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],ju.prototype,"signatureValue",void 0);var Ac;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(Ac||(Ac={}));class md extends _u{}class Mf{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier,implicit:!0,context:0})],Mf.prototype,"type",void 0);l([h({type:v.Any,implicit:!0,context:1})],Mf.prototype,"value",void 0);class Uf{constructor(e={}){this.policyId="",this.classList=new md(Ac.unclassified),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Uf.prototype,"policyId",void 0);l([h({type:md,defaultValue:new md(Ac.unclassified)})],Uf.prototype,"classList",void 0);l([h({type:Mf,repeated:"set"})],Uf.prototype,"securityCategories",void 0);class Tu{constructor(e={}){Object.assign(this,e)}}l([h({type:De})],Tu.prototype,"cotets",void 0);l([h({type:v.ObjectIdentifier})],Tu.prototype,"oid",void 0);l([h({type:v.Utf8String})],Tu.prototype,"string",void 0);class t0{constructor(e={}){this.values=[],Object.assign(this,e)}}l([h({type:xt,implicit:!0,context:0,optional:!0})],t0.prototype,"policyAuthority",void 0);l([h({type:Tu,repeated:"sequence"})],t0.prototype,"values",void 0);var yd;class Nu{constructor(e={}){this.targetCertificate=new vi,Object.assign(this,e)}}l([h({type:vi})],Nu.prototype,"targetCertificate",void 0);l([h({type:be,optional:!0})],Nu.prototype,"targetName",void 0);l([h({type:bi,optional:!0})],Nu.prototype,"certDigestInfo",void 0);let Xi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,context:0,implicit:!0})],Xi.prototype,"targetName",void 0);l([h({type:be,context:1,implicit:!0})],Xi.prototype,"targetGroup",void 0);l([h({type:Nu,context:2,implicit:!0})],Xi.prototype,"targetCert",void 0);Xi=l([$({type:R.Choice})],Xi);let gd=yd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,yd.prototype)}};gd=yd=l([$({type:R.Sequence,itemType:Xi})],gd);var vd;let ep=vd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,vd.prototype)}};ep=vd=l([$({type:R.Sequence,itemType:gd})],ep);class r0{constructor(e={}){Object.assign(this,e)}}l([h({type:xt,implicit:!0,context:0,optional:!0})],r0.prototype,"roleAuthority",void 0);l([h({type:be,implicit:!0,context:1})],r0.prototype,"roleName",void 0);class Vf{constructor(e={}){this.service=new be,this.ident=new be,Object.assign(this,e)}}l([h({type:be})],Vf.prototype,"service",void 0);l([h({type:be})],Vf.prototype,"ident",void 0);l([h({type:De,optional:!0})],Vf.prototype,"authInfo",void 0);var bd;class Lf{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Lf.prototype,"otherCertFormat",void 0);l([h({type:v.Any})],Lf.prototype,"otherCert",void 0);let Qi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ci})],Qi.prototype,"certificate",void 0);l([h({type:ju,context:2,implicit:!0})],Qi.prototype,"v2AttrCert",void 0);l([h({type:Lf,context:3,implicit:!0})],Qi.prototype,"other",void 0);Qi=l([$({type:R.Choice})],Qi);let Oc=bd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,bd.prototype)}};Oc=bd=l([$({type:R.Set,itemType:Qi})],Oc);class ps{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],ps.prototype,"contentType",void 0);l([h({type:v.Any,context:0})],ps.prototype,"content",void 0);let _a=class{constructor(e={}){Object.assign(this,e)}};l([h({type:De})],_a.prototype,"single",void 0);l([h({type:v.Any})],_a.prototype,"any",void 0);_a=l([$({type:R.Choice})],_a);class Bu{constructor(e={}){this.eContentType="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Bu.prototype,"eContentType",void 0);l([h({type:_a,context:0,optional:!0})],Bu.prototype,"eContent",void 0);let wa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:De,context:0,implicit:!0,optional:!0})],wa.prototype,"value",void 0);l([h({type:De,converter:jw,context:0,implicit:!0,optional:!0,repeated:"sequence"})],wa.prototype,"constructedValue",void 0);wa=l([$({type:R.Choice})],wa);class io{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new wc,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],io.prototype,"contentType",void 0);l([h({type:wc})],io.prototype,"contentEncryptionAlgorithm",void 0);l([h({type:wa,optional:!0})],io.prototype,"encryptedContent",void 0);class Ru{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Ru.prototype,"keyAttrId",void 0);l([h({type:v.Any,optional:!0})],Ru.prototype,"keyAttr",void 0);var xd;class Pu{constructor(e={}){this.subjectKeyIdentifier=new yn,Object.assign(this,e)}}l([h({type:yn})],Pu.prototype,"subjectKeyIdentifier",void 0);l([h({type:v.GeneralizedTime,optional:!0})],Pu.prototype,"date",void 0);l([h({type:Ru,optional:!0})],Pu.prototype,"other",void 0);let es=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Pu,context:0,implicit:!0,optional:!0})],es.prototype,"rKeyId",void 0);l([h({type:fs,optional:!0})],es.prototype,"issuerAndSerialNumber",void 0);es=l([$({type:R.Choice})],es);class qf{constructor(e={}){this.rid=new es,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:es})],qf.prototype,"rid",void 0);l([h({type:De})],qf.prototype,"encryptedKey",void 0);let Ec=xd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,xd.prototype)}};Ec=xd=l([$({type:R.Sequence,itemType:qf})],Ec);class Hf{constructor(e={}){this.algorithm=new Y,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],Hf.prototype,"algorithm",void 0);l([h({type:v.BitString})],Hf.prototype,"publicKey",void 0);let ui=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0,optional:!0})],ui.prototype,"subjectKeyIdentifier",void 0);l([h({type:Hf,context:1,implicit:!0,optional:!0})],ui.prototype,"originatorKey",void 0);l([h({type:fs,optional:!0})],ui.prototype,"issuerAndSerialNumber",void 0);ui=l([$({type:R.Choice})],ui);class ms{constructor(e={}){this.version=zr.v3,this.originator=new ui,this.keyEncryptionAlgorithm=new Er,this.recipientEncryptedKeys=new Ec,Object.assign(this,e)}}l([h({type:v.Integer})],ms.prototype,"version",void 0);l([h({type:ui,context:0})],ms.prototype,"originator",void 0);l([h({type:De,context:1,optional:!0})],ms.prototype,"ukm",void 0);l([h({type:Er})],ms.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Ec})],ms.prototype,"recipientEncryptedKeys",void 0);let ts=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0})],ts.prototype,"subjectKeyIdentifier",void 0);l([h({type:fs})],ts.prototype,"issuerAndSerialNumber",void 0);ts=l([$({type:R.Choice})],ts);class so{constructor(e={}){this.version=zr.v0,this.rid=new ts,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],so.prototype,"version",void 0);l([h({type:ts})],so.prototype,"rid",void 0);l([h({type:Er})],so.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],so.prototype,"encryptedKey",void 0);class ao{constructor(e={}){this.keyIdentifier=new De,Object.assign(this,e)}}l([h({type:De})],ao.prototype,"keyIdentifier",void 0);l([h({type:v.GeneralizedTime,optional:!0})],ao.prototype,"date",void 0);l([h({type:Ru,optional:!0})],ao.prototype,"other",void 0);class oo{constructor(e={}){this.version=zr.v4,this.kekid=new ao,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],oo.prototype,"version",void 0);l([h({type:ao})],oo.prototype,"kekid",void 0);l([h({type:Er})],oo.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],oo.prototype,"encryptedKey",void 0);class co{constructor(e={}){this.version=zr.v0,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],co.prototype,"version",void 0);l([h({type:ld,context:0,optional:!0})],co.prototype,"keyDerivationAlgorithm",void 0);l([h({type:Er})],co.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],co.prototype,"encryptedKey",void 0);class Ff{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Ff.prototype,"oriType",void 0);l([h({type:v.Any})],Ff.prototype,"oriValue",void 0);let Sn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:so,optional:!0})],Sn.prototype,"ktri",void 0);l([h({type:ms,context:1,implicit:!0,optional:!0})],Sn.prototype,"kari",void 0);l([h({type:oo,context:2,implicit:!0,optional:!0})],Sn.prototype,"kekri",void 0);l([h({type:co,context:3,implicit:!0,optional:!0})],Sn.prototype,"pwri",void 0);l([h({type:Ff,context:4,implicit:!0,optional:!0})],Sn.prototype,"ori",void 0);Sn=l([$({type:R.Choice})],Sn);var _d;let Ic=_d=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,_d.prototype)}};Ic=_d=l([$({type:R.Set,itemType:Sn})],Ic);var wd;class $u{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],$u.prototype,"otherRevInfoFormat",void 0);l([h({type:v.Any})],$u.prototype,"otherRevInfo",void 0);let Cc=class{constructor(e={}){this.other=new $u,Object.assign(this,e)}};l([h({type:$u,context:1,implicit:!0})],Cc.prototype,"other",void 0);Cc=l([$({type:R.Choice})],Cc);let jc=wd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,wd.prototype)}};jc=wd=l([$({type:R.Set,itemType:Cc})],jc);class Kf{constructor(e={}){Object.assign(this,e)}}l([h({type:Oc,context:0,implicit:!0,optional:!0})],Kf.prototype,"certs",void 0);l([h({type:jc,context:1,implicit:!0,optional:!0})],Kf.prototype,"crls",void 0);var kd;let Sd=kd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,kd.prototype)}};Sd=kd=l([$({type:R.Set,itemType:hs})],Sd);class uo{constructor(e={}){this.version=zr.v0,this.recipientInfos=new Ic,this.encryptedContentInfo=new io,Object.assign(this,e)}}l([h({type:v.Integer})],uo.prototype,"version",void 0);l([h({type:Kf,context:0,implicit:!0,optional:!0})],uo.prototype,"originatorInfo",void 0);l([h({type:Ic})],uo.prototype,"recipientInfos",void 0);l([h({type:io})],uo.prototype,"encryptedContentInfo",void 0);l([h({type:Sd,context:1,implicit:!0,optional:!0})],uo.prototype,"unprotectedAttrs",void 0);const r1="1.2.840.113549.1.7.2";var Ad;let Tc=Ad=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ad.prototype)}};Tc=Ad=l([$({type:R.Set,itemType:xa})],Tc);class ys{constructor(e={}){this.version=zr.v0,this.digestAlgorithms=new Tc,this.encapContentInfo=new Bu,this.signerInfos=new kc,Object.assign(this,e)}}l([h({type:v.Integer})],ys.prototype,"version",void 0);l([h({type:Tc})],ys.prototype,"digestAlgorithms",void 0);l([h({type:Bu})],ys.prototype,"encapContentInfo",void 0);l([h({type:Oc,context:0,implicit:!0,optional:!0})],ys.prototype,"certificates",void 0);l([h({type:jc,context:1,implicit:!0,optional:!0})],ys.prototype,"crls",void 0);l([h({type:kc})],ys.prototype,"signerInfos",void 0);const ka="1.2.840.10045.2.1",Wf="1.2.840.10045.4.1",n0="1.2.840.10045.4.3.1",zf="1.2.840.10045.4.3.2",Gf="1.2.840.10045.4.3.3",Jf="1.2.840.10045.4.3.4",tp="1.2.840.10045.3.1.7",rp="1.3.132.0.34",np="1.3.132.0.35";function lo(r){return new Y({algorithm:r})}const n1=lo(Wf);lo(n0);const i1=lo(zf),s1=lo(Gf),a1=lo(Jf);let Sa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],Sa.prototype,"fieldType",void 0);l([h({type:v.Any})],Sa.prototype,"parameters",void 0);Sa=l([$({type:R.Sequence})],Sa);class o1 extends De{}let rs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.OctetString})],rs.prototype,"a",void 0);l([h({type:v.OctetString})],rs.prototype,"b",void 0);l([h({type:v.BitString,optional:!0})],rs.prototype,"seed",void 0);rs=l([$({type:R.Sequence})],rs);var Od;(function(r){r[r.ecpVer1=1]="ecpVer1"})(Od||(Od={}));let Gr=class{constructor(e={}){this.version=Od.ecpVer1,Object.assign(this,e)}};l([h({type:v.Integer})],Gr.prototype,"version",void 0);l([h({type:Sa})],Gr.prototype,"fieldID",void 0);l([h({type:rs})],Gr.prototype,"curve",void 0);l([h({type:o1})],Gr.prototype,"base",void 0);l([h({type:v.Integer,converter:Ke})],Gr.prototype,"order",void 0);l([h({type:v.Integer,optional:!0})],Gr.prototype,"cofactor",void 0);Gr=l([$({type:R.Sequence})],Gr);let An=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],An.prototype,"namedCurve",void 0);l([h({type:v.Null})],An.prototype,"implicitCurve",void 0);l([h({type:Gr})],An.prototype,"specifiedCurve",void 0);An=l([$({type:R.Choice})],An);class Du{constructor(e={}){this.version=1,this.privateKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],Du.prototype,"version",void 0);l([h({type:De})],Du.prototype,"privateKey",void 0);l([h({type:An,context:0,optional:!0})],Du.prototype,"parameters",void 0);l([h({type:v.BitString,context:1,optional:!0})],Du.prototype,"publicKey",void 0);class Nc{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Nc.prototype,"r",void 0);l([h({type:v.Integer,converter:Ke})],Nc.prototype,"s",void 0);const Nt="1.2.840.113549.1.1",li=`${Nt}.1`,c1=`${Nt}.7`,u1=`${Nt}.9`,Us=`${Nt}.10`,l1=`${Nt}.2`,d1=`${Nt}.4`,Bc=`${Nt}.5`,f1=`${Nt}.14`,Ed=`${Nt}.11`,Rc=`${Nt}.12`,Pc=`${Nt}.13`,i0=`${Nt}.15`,s0=`${Nt}.16`,$c="1.3.14.3.2.26",a0="2.16.840.1.101.3.4.2.4",Dc="2.16.840.1.101.3.4.2.1",Zc="2.16.840.1.101.3.4.2.2",Mc="2.16.840.1.101.3.4.2.3",h1="2.16.840.1.101.3.4.2.5",p1="2.16.840.1.101.3.4.2.6",m1="1.2.840.113549.2.2",y1="1.2.840.113549.2.5",Zu=`${Nt}.8`;function at(r){return new Y({algorithm:r,parameters:null})}at(m1);at(y1);const di=at($c);at(a0);at(Dc);at(Zc);at(Mc);at(h1);at(p1);const o0=new Y({algorithm:Zu,parameters:L.serialize(di)}),c0=new Y({algorithm:u1,parameters:L.serialize(pc.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});at(li);at(l1);at(d1);at(Bc);at(i0);at(s0);at(Rc);at(Pc);at(i0);at(s0);class Mu{constructor(e={}){this.hashAlgorithm=new Y(di),this.maskGenAlgorithm=new Y({algorithm:Zu,parameters:L.serialize(di)}),this.pSourceAlgorithm=new Y(c0),Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:di})],Mu.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:o0})],Mu.prototype,"maskGenAlgorithm",void 0);l([h({type:Y,context:2,defaultValue:c0})],Mu.prototype,"pSourceAlgorithm",void 0);new Y({algorithm:c1,parameters:L.serialize(new Mu)});class fi{constructor(e={}){this.hashAlgorithm=new Y(di),this.maskGenAlgorithm=new Y({algorithm:Zu,parameters:L.serialize(di)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:di})],fi.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:o0})],fi.prototype,"maskGenAlgorithm",void 0);l([h({type:v.Integer,context:2,defaultValue:20})],fi.prototype,"saltLength",void 0);l([h({type:v.Integer,context:3,defaultValue:1})],fi.prototype,"trailerField",void 0);new Y({algorithm:Us,parameters:L.serialize(new fi)});class Uu{constructor(e={}){this.digestAlgorithm=new Y,this.digest=new De,Object.assign(this,e)}}l([h({type:Y})],Uu.prototype,"digestAlgorithm",void 0);l([h({type:De})],Uu.prototype,"digest",void 0);var Id;class Vu{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Vu.prototype,"prime",void 0);l([h({type:v.Integer,converter:Ke})],Vu.prototype,"exponent",void 0);l([h({type:v.Integer,converter:Ke})],Vu.prototype,"coefficient",void 0);let Cd=Id=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Id.prototype)}};Cd=Id=l([$({type:R.Sequence,itemType:Vu})],Cd);class Nr{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer})],Nr.prototype,"version",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"modulus",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"publicExponent",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"privateExponent",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"prime1",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"prime2",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"exponent1",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"exponent2",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"coefficient",void 0);l([h({type:Cd,optional:!0})],Nr.prototype,"otherPrimeInfos",void 0);class Yf{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Yf.prototype,"modulus",void 0);l([h({type:v.Integer,converter:Ke})],Yf.prototype,"publicExponent",void 0);var jd;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(jd||(jd={}));const At=jd;/*! *****************************************************************************
80
80
  Copyright (c) Microsoft Corporation.
81
81
 
82
82
  Permission to use, copy, modify, and/or distribute this software for any
@@ -89,9 +89,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
89
89
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
90
90
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
91
91
  PERFORMANCE OF THIS SOFTWARE.
92
- ***************************************************************************** */var jd=function(r,e){return jd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},jd(r,e)};function Yf(r,e){jd(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function y1(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(f){try{u(n.next(f))}catch(m){a(m)}}function c(f){try{u(n.throw(f))}catch(m){a(m)}}function u(f){f.done?s(f.value):i(f.value).then(o,c)}u((n=n.apply(r,[])).next())})}function g1(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(u){return function(f){return c([u,f])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){t.label=u[1];break}if(u[0]===6&&t.label<s[1]){t.label=s[1],s=u;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(u);break}s[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(f){u=[6,f],i=0}finally{n=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function xo(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Mc(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s}function Zn(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Mc(arguments[e]));return r}var v1="injectionTokens";function b1(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(v1,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function c0(r){return!!r.useClass}function Td(r){return!!r.useFactory}var u0=function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},i=!1,s,a=function(){return i||(s=e(t.wrap()),i=!0),s};return new Proxy(n,this.createHandler(a))},r.prototype.createHandler=function(e){var t={},n=function(i){t[i]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var o=Reflect[i];return o.apply(void 0,Zn(s))}};return this.reflectMethods.forEach(n),t},r}();function wi(r){return typeof r=="string"||typeof r=="symbol"}function x1(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function np(r){return typeof r=="object"&&"token"in r&&"transform"in r}function _1(r){return typeof r=="function"||r instanceof u0}function No(r){return!!r.useToken}function Bo(r){return r.useValue!=null}function w1(r){return c0(r)||Bo(r)||No(r)||Td(r)}var Xf=function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r}(),k1=function(r){Yf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Xf),ip=function(){function r(){this.scopedResolutions=new Map}return r}();function S1(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function A1(r,e,t){return t===void 0&&(t=" "),Zn([r],e.message.split(`
92
+ ***************************************************************************** */var Td=function(r,e){return Td=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},Td(r,e)};function Xf(r,e){Td(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function g1(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(f){try{u(n.next(f))}catch(m){a(m)}}function c(f){try{u(n.throw(f))}catch(m){a(m)}}function u(f){f.done?s(f.value):i(f.value).then(o,c)}u((n=n.apply(r,[])).next())})}function v1(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(u){return function(f){return c([u,f])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){t.label=u[1];break}if(u[0]===6&&t.label<s[1]){t.label=s[1],s=u;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(u);break}s[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(f){u=[6,f],i=0}finally{n=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function xo(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Uc(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s}function Zn(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Uc(arguments[e]));return r}var b1="injectionTokens";function x1(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(b1,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function u0(r){return!!r.useClass}function Nd(r){return!!r.useFactory}var l0=function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},i=!1,s,a=function(){return i||(s=e(t.wrap()),i=!0),s};return new Proxy(n,this.createHandler(a))},r.prototype.createHandler=function(e){var t={},n=function(i){t[i]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var o=Reflect[i];return o.apply(void 0,Zn(s))}};return this.reflectMethods.forEach(n),t},r}();function wi(r){return typeof r=="string"||typeof r=="symbol"}function _1(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function ip(r){return typeof r=="object"&&"token"in r&&"transform"in r}function w1(r){return typeof r=="function"||r instanceof l0}function No(r){return!!r.useToken}function Bo(r){return r.useValue!=null}function k1(r){return u0(r)||Bo(r)||No(r)||Nd(r)}var Qf=function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r}(),S1=function(r){Xf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Qf),sp=function(){function r(){this.scopedResolutions=new Map}return r}();function A1(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function O1(r,e,t){return t===void 0&&(t=" "),Zn([r],e.message.split(`
93
93
  `).map(function(n){return t+n})).join(`
94
- `)}function O1(r,e,t){var n=Mc(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=n[1],s=i===void 0?null:i,a=S1(s,e);return A1("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function E1(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var I1=function(r){Yf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Xf),C1=function(r){Yf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Xf),j1=function(){function r(){this.preResolution=new I1,this.postResolution=new C1}return r}(),l0=new Map,T1=function(){function r(e){this.parent=e,this._registry=new k1,this.interceptors=new j1,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:At.Transient}),this.ensureNotDisposed();var i;if(w1(t)?i=t:i={useClass:t},No(i))for(var s=[e],a=i;a!=null;){var o=a.useToken;if(s.includes(o))throw new Error("Token registration cycle detected! "+Zn(s,[o]).join(" -> "));s.push(o);var c=this._registry.get(o);c&&No(c.provider)?a=c.provider:a=null}if((n.lifecycle===At.Singleton||n.lifecycle==At.ContainerScoped||n.lifecycle==At.ResolutionScoped)&&(Bo(i)||Td(i)))throw new Error('Cannot use lifecycle "'+At[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),wi(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),wi(e)){if(wi(t))return this.register(e,{useToken:t},{lifecycle:At.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:At.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!wi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:At.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new ip),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&wi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var i=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(_1(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=xo(this.interceptors.preResolution.getAll(e)),o=a.next();!o.done;o=a.next()){var c=o.value;c.options.frequency!="Once"&&s.push(c),c.callback(e,t)}}catch(u){n={error:u}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var i,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var o=xo(this.interceptors.postResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var u=c.value;u.options.frequency!="Once"&&a.push(u),u.callback(e,t,n)}}catch(f){i={error:f}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,a)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===At.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===At.Singleton,i=e.options.lifecycle===At.ContainerScoped,s=n||i,a;return Bo(e.provider)?a=e.provider.useValue:No(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):c0(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Td(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===At.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new ip),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&wi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(o){return n.resolveRegistration(o,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=xo(this._registry.entries()),i=n.next();!i.done;i=n.next()){var s=Mc(i.value,2),a=s[0],o=s[1];this._registry.setAll(a,o.filter(function(c){return!Bo(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var i=xo(this._registry.entries()),s=i.next();!s.done;s=i.next()){var a=Mc(s.value,2),o=a[0],c=a[1];c.some(function(u){var f=u.options;return f.lifecycle===At.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===At.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return y1(this,void 0,void 0,function(){var e;return g1(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var i=n.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof u0)return e.createProxy(function(s){return n.resolve(s,t)});var i=function(){var s=l0.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,Zn([void 0],a)))}();return E1(i)&&this.disposables.add(i),i},r.prototype.resolveParams=function(e,t){var n=this;return function(i,s){var a,o,c;try{return x1(i)?np(i)?i.multiple?(a=n.resolve(i.transform)).transform.apply(a,Zn([n.resolveAll(i.token)],i.transformArgs)):(o=n.resolve(i.transform)).transform.apply(o,Zn([n.resolve(i.token,e)],i.transformArgs)):i.multiple?n.resolveAll(i.token):n.resolve(i.token,e):np(i)?(c=n.resolve(i.transform,e)).transform.apply(c,Zn([n.resolve(i.token,e)],i.transformArgs)):n.resolve(i,e)}catch(u){throw new Error(O1(t,s,u))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),pt=new T1;function Vu(){return function(r){l0.set(r,b1(r))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Nd;class Lu{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}l([h({type:v.ObjectIdentifier})],Lu.prototype,"attrId",void 0);l([h({type:v.Any,repeated:"set"})],Lu.prototype,"attrValues",void 0);let sp=Nd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Nd.prototype)}};sp=Nd=l([$({type:R.Sequence,itemType:Lu})],sp);var Bd;let ap=Bd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Bd.prototype)}};ap=Bd=l([$({type:R.Sequence,itemType:ps})],ap);class d0{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],d0.prototype,"certId",void 0);l([h({type:v.Any,context:0})],d0.prototype,"certValue",void 0);class f0{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],f0.prototype,"crlId",void 0);l([h({type:v.Any,context:0})],f0.prototype,"crltValue",void 0);class h0 extends De{}let qu=class{constructor(e={}){this.encryptionAlgorithm=new Y,this.encryptedData=new h0,Object.assign(this,e)}};l([h({type:Y})],qu.prototype,"encryptionAlgorithm",void 0);l([h({type:h0})],qu.prototype,"encryptedData",void 0);var Rd,Pd;(function(r){r[r.v1=0]="v1"})(Pd||(Pd={}));class p0 extends De{}let $d=Rd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Rd.prototype)}};$d=Rd=l([$({type:R.Sequence,itemType:Wr})],$d);class fo{constructor(e={}){this.version=Pd.v1,this.privateKeyAlgorithm=new Y,this.privateKey=new p0,Object.assign(this,e)}}l([h({type:v.Integer})],fo.prototype,"version",void 0);l([h({type:Y})],fo.prototype,"privateKeyAlgorithm",void 0);l([h({type:p0})],fo.prototype,"privateKey",void 0);l([h({type:$d,implicit:!0,context:0,optional:!0})],fo.prototype,"attributes",void 0);let op=class extends fo{};op=l([$({type:R.Sequence})],op);let cp=class extends qu{};cp=l([$({type:R.Sequence})],cp);class m0{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],m0.prototype,"secretTypeId",void 0);l([h({type:v.Any,context:0})],m0.prototype,"secretValue",void 0);class ho{constructor(e={}){this.mac=new Mu,this.macSalt=new De,this.iterations=1,Object.assign(this,e)}}l([h({type:Mu})],ho.prototype,"mac",void 0);l([h({type:De})],ho.prototype,"macSalt",void 0);l([h({type:v.Integer,defaultValue:1})],ho.prototype,"iterations",void 0);class Hu{constructor(e={}){this.version=3,this.authSafe=new ps,this.macData=new ho,Object.assign(this,e)}}l([h({type:v.Integer})],Hu.prototype,"version",void 0);l([h({type:ps})],Hu.prototype,"authSafe",void 0);l([h({type:ho,optional:!0})],Hu.prototype,"macData",void 0);var Dd;class Fu{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Fu.prototype,"bagId",void 0);l([h({type:v.Any,context:0})],Fu.prototype,"bagValue",void 0);l([h({type:Lu,repeated:"set",optional:!0})],Fu.prototype,"bagAttributes",void 0);let up=Dd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Dd.prototype)}};up=Dd=l([$({type:R.Sequence,itemType:Fu})],up);var Zd,Md,Ud;const y0="1.2.840.113549.1.9",g0=`${y0}.7`,Qf=`${y0}.14`;let Uc=class extends ht{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};l([h({type:v.IA5String})],Uc.prototype,"ia5String",void 0);Uc=l([$({type:R.Choice})],Uc);let lp=class extends ps{};lp=l([$({type:R.Sequence})],lp);let dp=class extends Hu{};dp=l([$({type:R.Sequence})],dp);let fp=class extends qu{};fp=l([$({type:R.Sequence})],fp);let Vd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.IA5String})],Vd.prototype,"value",void 0);Vd=l([$({type:R.Choice})],Vd);let hp=class extends Uc{};hp=l([$({type:R.Choice})],hp);let pp=class extends ht{};pp=l([$({type:R.Choice})],pp);let Ld=class{constructor(e=new Date){this.value=e}};l([h({type:v.GeneralizedTime})],Ld.prototype,"value",void 0);Ld=l([$({type:R.Choice})],Ld);let mp=class extends ht{};mp=l([$({type:R.Choice})],mp);let qd=class{constructor(e="M"){this.value=e}toString(){return this.value}};l([h({type:v.PrintableString})],qd.prototype,"value",void 0);qd=l([$({type:R.Choice})],qd);let Vc=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.PrintableString})],Vc.prototype,"value",void 0);Vc=l([$({type:R.Choice})],Vc);let yp=class extends Vc{};yp=l([$({type:R.Choice})],yp);let gp=class extends ht{};gp=l([$({type:R.Choice})],gp);let Hd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.ObjectIdentifier})],Hd.prototype,"value",void 0);Hd=l([$({type:R.Choice})],Hd);let vp=class extends lt{};vp=l([$({type:R.Choice})],vp);let Fd=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};l([h({type:v.Integer})],Fd.prototype,"value",void 0);Fd=l([$({type:R.Choice})],Fd);let bp=class extends Tr{};bp=l([$({type:R.Sequence})],bp);let Lc=class extends ht{};Lc=l([$({type:R.Choice})],Lc);let xp=Zd=class extends kn{constructor(e){super(e),Object.setPrototypeOf(this,Zd.prototype)}};xp=Zd=l([$({type:R.Sequence})],xp);let _p=Md=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Md.prototype)}};_p=Md=l([$({type:R.Set,itemType:hs})],_p);let Kd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.BmpString})],Kd.prototype,"value",void 0);Kd=l([$({type:R.Choice})],Kd);let Wd=class extends Y{};Wd=l([$({type:R.Sequence})],Wd);let wp=Ud=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ud.prototype)}};wp=Ud=l([$({type:R.Sequence,itemType:Wd})],wp);var zd;let qc=zd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,zd.prototype)}};qc=zd=l([$({type:R.Sequence,itemType:Wr})],qc);class gs{constructor(e={}){this.version=0,this.subject=new et,this.subjectPKInfo=new sr,this.attributes=new qc,Object.assign(this,e)}}l([h({type:v.Integer})],gs.prototype,"version",void 0);l([h({type:et})],gs.prototype,"subject",void 0);l([h({type:sr})],gs.prototype,"subjectPKInfo",void 0);l([h({type:qc,implicit:!0,context:0})],gs.prototype,"attributes",void 0);class Aa{constructor(e={}){this.certificationRequestInfo=new gs,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:gs})],Aa.prototype,"certificationRequestInfo",void 0);l([h({type:Y})],Aa.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],Aa.prototype,"signature",void 0);/*!
94
+ `)}function E1(r,e,t){var n=Uc(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=n[1],s=i===void 0?null:i,a=A1(s,e);return O1("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function I1(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var C1=function(r){Xf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Qf),j1=function(r){Xf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Qf),T1=function(){function r(){this.preResolution=new C1,this.postResolution=new j1}return r}(),d0=new Map,N1=function(){function r(e){this.parent=e,this._registry=new S1,this.interceptors=new T1,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:At.Transient}),this.ensureNotDisposed();var i;if(k1(t)?i=t:i={useClass:t},No(i))for(var s=[e],a=i;a!=null;){var o=a.useToken;if(s.includes(o))throw new Error("Token registration cycle detected! "+Zn(s,[o]).join(" -> "));s.push(o);var c=this._registry.get(o);c&&No(c.provider)?a=c.provider:a=null}if((n.lifecycle===At.Singleton||n.lifecycle==At.ContainerScoped||n.lifecycle==At.ResolutionScoped)&&(Bo(i)||Nd(i)))throw new Error('Cannot use lifecycle "'+At[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),wi(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),wi(e)){if(wi(t))return this.register(e,{useToken:t},{lifecycle:At.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:At.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!wi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:At.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new sp),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&wi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var i=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(w1(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=xo(this.interceptors.preResolution.getAll(e)),o=a.next();!o.done;o=a.next()){var c=o.value;c.options.frequency!="Once"&&s.push(c),c.callback(e,t)}}catch(u){n={error:u}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var i,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var o=xo(this.interceptors.postResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var u=c.value;u.options.frequency!="Once"&&a.push(u),u.callback(e,t,n)}}catch(f){i={error:f}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,a)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===At.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===At.Singleton,i=e.options.lifecycle===At.ContainerScoped,s=n||i,a;return Bo(e.provider)?a=e.provider.useValue:No(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):u0(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Nd(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===At.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new sp),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&wi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(o){return n.resolveRegistration(o,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=xo(this._registry.entries()),i=n.next();!i.done;i=n.next()){var s=Uc(i.value,2),a=s[0],o=s[1];this._registry.setAll(a,o.filter(function(c){return!Bo(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var i=xo(this._registry.entries()),s=i.next();!s.done;s=i.next()){var a=Uc(s.value,2),o=a[0],c=a[1];c.some(function(u){var f=u.options;return f.lifecycle===At.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===At.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return g1(this,void 0,void 0,function(){var e;return v1(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var i=n.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof l0)return e.createProxy(function(s){return n.resolve(s,t)});var i=function(){var s=d0.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,Zn([void 0],a)))}();return I1(i)&&this.disposables.add(i),i},r.prototype.resolveParams=function(e,t){var n=this;return function(i,s){var a,o,c;try{return _1(i)?ip(i)?i.multiple?(a=n.resolve(i.transform)).transform.apply(a,Zn([n.resolveAll(i.token)],i.transformArgs)):(o=n.resolve(i.transform)).transform.apply(o,Zn([n.resolve(i.token,e)],i.transformArgs)):i.multiple?n.resolveAll(i.token):n.resolve(i.token,e):ip(i)?(c=n.resolve(i.transform,e)).transform.apply(c,Zn([n.resolve(i.token,e)],i.transformArgs)):n.resolve(i,e)}catch(u){throw new Error(E1(t,s,u))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),pt=new N1;function Lu(){return function(r){d0.set(r,x1(r))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Bd;class qu{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}l([h({type:v.ObjectIdentifier})],qu.prototype,"attrId",void 0);l([h({type:v.Any,repeated:"set"})],qu.prototype,"attrValues",void 0);let ap=Bd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Bd.prototype)}};ap=Bd=l([$({type:R.Sequence,itemType:qu})],ap);var Rd;let op=Rd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Rd.prototype)}};op=Rd=l([$({type:R.Sequence,itemType:ps})],op);class f0{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],f0.prototype,"certId",void 0);l([h({type:v.Any,context:0})],f0.prototype,"certValue",void 0);class h0{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],h0.prototype,"crlId",void 0);l([h({type:v.Any,context:0})],h0.prototype,"crltValue",void 0);class p0 extends De{}let Hu=class{constructor(e={}){this.encryptionAlgorithm=new Y,this.encryptedData=new p0,Object.assign(this,e)}};l([h({type:Y})],Hu.prototype,"encryptionAlgorithm",void 0);l([h({type:p0})],Hu.prototype,"encryptedData",void 0);var Pd,$d;(function(r){r[r.v1=0]="v1"})($d||($d={}));class m0 extends De{}let Dd=Pd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Pd.prototype)}};Dd=Pd=l([$({type:R.Sequence,itemType:Wr})],Dd);class fo{constructor(e={}){this.version=$d.v1,this.privateKeyAlgorithm=new Y,this.privateKey=new m0,Object.assign(this,e)}}l([h({type:v.Integer})],fo.prototype,"version",void 0);l([h({type:Y})],fo.prototype,"privateKeyAlgorithm",void 0);l([h({type:m0})],fo.prototype,"privateKey",void 0);l([h({type:Dd,implicit:!0,context:0,optional:!0})],fo.prototype,"attributes",void 0);let cp=class extends fo{};cp=l([$({type:R.Sequence})],cp);let up=class extends Hu{};up=l([$({type:R.Sequence})],up);class y0{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],y0.prototype,"secretTypeId",void 0);l([h({type:v.Any,context:0})],y0.prototype,"secretValue",void 0);class ho{constructor(e={}){this.mac=new Uu,this.macSalt=new De,this.iterations=1,Object.assign(this,e)}}l([h({type:Uu})],ho.prototype,"mac",void 0);l([h({type:De})],ho.prototype,"macSalt",void 0);l([h({type:v.Integer,defaultValue:1})],ho.prototype,"iterations",void 0);class Fu{constructor(e={}){this.version=3,this.authSafe=new ps,this.macData=new ho,Object.assign(this,e)}}l([h({type:v.Integer})],Fu.prototype,"version",void 0);l([h({type:ps})],Fu.prototype,"authSafe",void 0);l([h({type:ho,optional:!0})],Fu.prototype,"macData",void 0);var Zd;class Ku{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Ku.prototype,"bagId",void 0);l([h({type:v.Any,context:0})],Ku.prototype,"bagValue",void 0);l([h({type:qu,repeated:"set",optional:!0})],Ku.prototype,"bagAttributes",void 0);let lp=Zd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Zd.prototype)}};lp=Zd=l([$({type:R.Sequence,itemType:Ku})],lp);var Md,Ud,Vd;const g0="1.2.840.113549.1.9",v0=`${g0}.7`,eh=`${g0}.14`;let Vc=class extends ht{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};l([h({type:v.IA5String})],Vc.prototype,"ia5String",void 0);Vc=l([$({type:R.Choice})],Vc);let dp=class extends ps{};dp=l([$({type:R.Sequence})],dp);let fp=class extends Fu{};fp=l([$({type:R.Sequence})],fp);let hp=class extends Hu{};hp=l([$({type:R.Sequence})],hp);let Ld=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.IA5String})],Ld.prototype,"value",void 0);Ld=l([$({type:R.Choice})],Ld);let pp=class extends Vc{};pp=l([$({type:R.Choice})],pp);let mp=class extends ht{};mp=l([$({type:R.Choice})],mp);let qd=class{constructor(e=new Date){this.value=e}};l([h({type:v.GeneralizedTime})],qd.prototype,"value",void 0);qd=l([$({type:R.Choice})],qd);let yp=class extends ht{};yp=l([$({type:R.Choice})],yp);let Hd=class{constructor(e="M"){this.value=e}toString(){return this.value}};l([h({type:v.PrintableString})],Hd.prototype,"value",void 0);Hd=l([$({type:R.Choice})],Hd);let Lc=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.PrintableString})],Lc.prototype,"value",void 0);Lc=l([$({type:R.Choice})],Lc);let gp=class extends Lc{};gp=l([$({type:R.Choice})],gp);let vp=class extends ht{};vp=l([$({type:R.Choice})],vp);let Fd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.ObjectIdentifier})],Fd.prototype,"value",void 0);Fd=l([$({type:R.Choice})],Fd);let bp=class extends lt{};bp=l([$({type:R.Choice})],bp);let Kd=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};l([h({type:v.Integer})],Kd.prototype,"value",void 0);Kd=l([$({type:R.Choice})],Kd);let xp=class extends Tr{};xp=l([$({type:R.Sequence})],xp);let qc=class extends ht{};qc=l([$({type:R.Choice})],qc);let _p=Md=class extends kn{constructor(e){super(e),Object.setPrototypeOf(this,Md.prototype)}};_p=Md=l([$({type:R.Sequence})],_p);let wp=Ud=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ud.prototype)}};wp=Ud=l([$({type:R.Set,itemType:hs})],wp);let Wd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.BmpString})],Wd.prototype,"value",void 0);Wd=l([$({type:R.Choice})],Wd);let zd=class extends Y{};zd=l([$({type:R.Sequence})],zd);let kp=Vd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Vd.prototype)}};kp=Vd=l([$({type:R.Sequence,itemType:zd})],kp);var Gd;let Hc=Gd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Gd.prototype)}};Hc=Gd=l([$({type:R.Sequence,itemType:Wr})],Hc);class gs{constructor(e={}){this.version=0,this.subject=new et,this.subjectPKInfo=new sr,this.attributes=new Hc,Object.assign(this,e)}}l([h({type:v.Integer})],gs.prototype,"version",void 0);l([h({type:et})],gs.prototype,"subject",void 0);l([h({type:sr})],gs.prototype,"subjectPKInfo",void 0);l([h({type:Hc,implicit:!0,context:0})],gs.prototype,"attributes",void 0);class Aa{constructor(e={}){this.certificationRequestInfo=new gs,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:gs})],Aa.prototype,"certificationRequestInfo",void 0);l([h({type:Y})],Aa.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],Aa.prototype,"signature",void 0);/*!
95
95
  * MIT License
96
96
  *
97
97
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -114,12 +114,12 @@ PERFORMANCE OF THIS SOFTWARE.
114
114
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
115
115
  * SOFTWARE.
116
116
  *
117
- */const po="crypto.algorithm";class N1{getAlgorithms(){return pt.resolveAll(po)}toAsnAlgorithm(e){({...e});for(const t of this.getAlgorithms()){const n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){const t=new Y({algorithm:e.name});if("parameters"in e){const n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const n of this.getAlgorithms()){const i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const hi="crypto.algorithmProvider";pt.registerSingleton(hi,N1);var Ro;const Bt="1.3.36.3.3.2.8.1.1",kp=`${Bt}.1`,Sp=`${Bt}.2`,Ap=`${Bt}.3`,Op=`${Bt}.4`,Ep=`${Bt}.5`,Ip=`${Bt}.6`,Cp=`${Bt}.7`,jp=`${Bt}.8`,Tp=`${Bt}.9`,Np=`${Bt}.10`,Bp=`${Bt}.11`,Rp=`${Bt}.12`,Pp=`${Bt}.13`,$p=`${Bt}.14`,Dp="brainpoolP160r1",Zp="brainpoolP160t1",Mp="brainpoolP192r1",Up="brainpoolP192t1",Vp="brainpoolP224r1",Lp="brainpoolP224t1",qp="brainpoolP256r1",Hp="brainpoolP256t1",Fp="brainpoolP320r1",Kp="brainpoolP320t1",Wp="brainpoolP384r1",zp="brainpoolP384t1",Gp="brainpoolP512r1",Jp="brainpoolP512t1",ze="ECDSA";let Oa=Ro=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ze.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return r1;case"sha-256":return n1;case"sha-384":return i1;case"sha-512":return s1}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=ep;break;case"K-256":t=Ro.SECP256K1;break;case"P-384":t=tp;break;case"P-521":t=rp;break;case Dp:t=kp;break;case Zp:t=Sp;break;case Mp:t=Ap;break;case Up:t=Op;break;case Vp:t=Ep;break;case Lp:t=Ip;break;case qp:t=Cp;break;case Hp:t=jp;break;case Fp:t=Tp;break;case Kp:t=Np;break;case Wp:t=Bp;break;case zp:t=Rp;break;case Gp:t=Pp;break;case Jp:t=$p;break}if(t)return new Y({algorithm:ka,parameters:L.serialize(new An({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Kf:return{name:ze,hash:{name:"SHA-1"}};case Wf:return{name:ze,hash:{name:"SHA-256"}};case zf:return{name:ze,hash:{name:"SHA-384"}};case Gf:return{name:ze,hash:{name:"SHA-512"}};case ka:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(L.parse(e.parameters,An).namedCurve){case ep:return{name:ze,namedCurve:"P-256"};case Ro.SECP256K1:return{name:ze,namedCurve:"K-256"};case tp:return{name:ze,namedCurve:"P-384"};case rp:return{name:ze,namedCurve:"P-521"};case kp:return{name:ze,namedCurve:Dp};case Sp:return{name:ze,namedCurve:Zp};case Ap:return{name:ze,namedCurve:Mp};case Op:return{name:ze,namedCurve:Up};case Ep:return{name:ze,namedCurve:Vp};case Ip:return{name:ze,namedCurve:Lp};case Cp:return{name:ze,namedCurve:qp};case jp:return{name:ze,namedCurve:Hp};case Tp:return{name:ze,namedCurve:Fp};case Np:return{name:ze,namedCurve:Kp};case Bp:return{name:ze,namedCurve:Wp};case Rp:return{name:ze,namedCurve:zp};case Pp:return{name:ze,namedCurve:Gp};case $p:return{name:ze,namedCurve:Jp}}}}return null}};Oa.SECP256K1="1.3.132.0.10";Oa=Ro=l([Vu()],Oa);pt.registerSingleton(po,Oa);const v0=Symbol("name"),b0=Symbol("value");class Me{constructor(e,t={},n=""){this[v0]=e,this[b0]=n;for(const i in t)this[i]=t[i]}}Me.NAME=v0;Me.VALUE=b0;class B1{static toTextObject(e){const t=new Me("Algorithm Identifier",{},Nn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case ka:{const n=new Oa().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class Nn{static toString(e){const t=this.items[e];return t||e}}Nn.items={[Pc]:"sha1",[s0]:"sha224",[$c]:"sha256",[Dc]:"sha384",[Zc]:"sha512",[li]:"rsaEncryption",[Nc]:"sha1WithRSAEncryption",[d1]:"sha224WithRSAEncryption",[Od]:"sha256WithRSAEncryption",[Bc]:"sha384WithRSAEncryption",[Rc]:"sha512WithRSAEncryption",[ka]:"ecPublicKey",[Kf]:"ecdsaWithSHA1",[r0]:"ecdsaWithSHA224",[Wf]:"ecdsaWithSHA256",[zf]:"ecdsaWithSHA384",[Gf]:"ecdsaWithSHA512",[Gw]:"TLS WWW server authentication",[Jw]:"TLS WWW client authentication",[Yw]:"Code Signing",[Xw]:"E-mail Protection",[Qw]:"Time Stamping",[e1]:"OCSP Signing",[t1]:"Signed Data"};class pi{static serialize(e){return this.serializeObj(e).join(`
118
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let i=this.pad(t++),s="";const a=e[Me.VALUE];a&&(s=` ${a}`),n.push(`${i}${e[Me.NAME]}:${s}`),i=this.pad(t);for(const o in e){if(typeof o=="symbol")continue;const c=e[o],u=o?`${o}: `:"";if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`${i}${u}${c}`);else if(c instanceof Date)n.push(`${i}${u}${c.toUTCString()}`);else if(Array.isArray(c))for(const f of c)f[Me.NAME]=o,n.push(...this.serializeObj(f,t));else if(c instanceof Me)c[Me.NAME]=o,n.push(...this.serializeObj(c,t));else if(q.isBufferSource(c))o?(n.push(`${i}${u}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){const f=c.toTextObject();f[Me.NAME]=o,n.push(...this.serializeObj(f,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),i=q.toUint8Array(e),s=[];for(let a=0;a<i.length;){const o=[];for(let c=0;c<16&&a<i.length;c++){c===8&&o.push("");const u=i[a++].toString(16).padStart(2,"0");o.push(u)}s.push(`${n}${o.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}pi.oidSerializer=Nn;pi.algorithmSerializer=B1;class Bn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=L.serialize(t),this.onInit(t)}else{const t=L.parse(e[0],e[1]);this.rawData=q.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Bn?Zy(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return L.toString(this.rawData);case"text":return pi.serialize(this.toTextObject());case"hex":return te.ToHex(this.rawData);case"base64":return te.ToBase64(this.rawData);case"base64url":return te.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new Me(this.getTextName(),{},e)}}Bn.NAME="ASN";class Gt extends Bn{constructor(...e){let t;q.isBufferSource(e[0])?t=q.toArrayBuffer(e[0]):t=L.serialize(new Wt({extnID:e[0],critical:e[1],extnValue:new De(q.toArrayBuffer(e[2]))})),super(t,Wt)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[Me.NAME]===Gt.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}var x0;class hn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[x0]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(hn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(hn.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=hn.DEFAULT){const t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(hn.DEFAULT,e);return this}}x0=Symbol.toStringTag;hn.DEFAULT="default";const ut=new hn,R1=/^[0-2](?:\.[1-9][0-9]*)+$/;function P1(r){return new RegExp(R1).test(r)}class _0{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return P1(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const Tt=new _0;Tt.register("CN","2.5.4.3");Tt.register("L","2.5.4.7");Tt.register("ST","2.5.4.8");Tt.register("O","2.5.4.10");Tt.register("OU","2.5.4.11");Tt.register("C","2.5.4.6");Tt.register("DC","0.9.2342.19200300.100.1.25");Tt.register("E","1.2.840.113549.1.9.1");Tt.register("G","2.5.4.42");Tt.register("I","2.5.4.43");Tt.register("SN","2.5.4.4");Tt.register("T","2.5.4.12");function $1(r,e){return`\\${te.ToHex(te.FromUtf8String(e)).toUpperCase()}`}function D1(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,$1)}class Ht{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new _0,this.asn=new et;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=t[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof et?this.asn=e:q.isBufferSource(e)?this.asn=L.parse(e,et):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||Tt.findId(e),n=[];for(const i of this.asn)for(const s of i)s.type===t&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||Tt.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,i=t.value.anyValue?`#${te.ToHex(t.value.anyValue)}`:D1(t.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const i={};for(const s of n){const a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${te.ToHex(s.value.anyValue)}`:s.value.toString())}t.push(i)}return t}fromString(e){const t=new et,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=n.exec(`${e},`);){let[,a,o]=i;const c=o[o.length-1];(c===","||c==="+")&&(o=o.slice(0,o.length-1),i[3]=c);const u=i[3];a=this.getTypeOid(a);const f=this.createAttribute(a,o);s==="+"?t[t.length-1].push(f):t.push(new Gi([f])),s=u}return t}fromJSON(e){const t=new et;for(const n of e){const i=new Gi;for(const s in n){const a=this.getTypeOid(s),o=n[s];for(const c of o){const u=this.createAttribute(a,c);i.push(u)}}t.push(i)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){const n=new _u({type:e});if(typeof t=="object")for(const i in t)switch(i){case"ia5String":n.value.ia5String=t[i];break;case"utf8String":n.value.utf8String=t[i];break;case"universalString":n.value.universalString=t[i];break;case"bmpString":n.value.bmpString=t[i];break;case"printableString":n.value.printableString=t[i];break}else if(t[0]==="#")n.value.anyValue=te.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:Ht.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
119
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return L.serialize(this.asn)}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(i,this.toArrayBuffer())}}const w0="Cannot initialize GeneralName from ASN.1 data.",Yp=`${w0} Unsupported string format in use.`,Z1=`${w0} Value doesn't match to GUID regular expression.`,Xp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Qp="1.3.6.1.4.1.311.25.1",em="1.3.6.1.4.1.311.20.2.3",sl="dns",al="dn",ol="email",cl="ip",ul="url",ll="guid",dl="upn",_o="id";class pn extends Bn{constructor(...e){let t;if(e.length===2)switch(e[0]){case al:{const n=new Ht(e[1]).toArrayBuffer(),i=L.parse(n,et);t=new be({directoryName:i});break}case sl:t=new be({dNSName:e[1]});break;case ol:t=new be({rfc822Name:e[1]});break;case ll:{const n=new RegExp(Xp,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=n.slice(1).map((s,a)=>a<3?te.ToHex(new Uint8Array(te.FromHex(s)).reverse()):s).join("");t=new be({otherName:new ba({typeId:Qp,value:L.serialize(new De(te.FromHex(i)))})});break}case cl:t=new be({iPAddress:e[1]});break;case _o:t=new be({registeredID:e[1]});break;case dl:{t=new be({otherName:new ba({typeId:em,value:L.serialize(Zg.toASN(e[1]))})});break}case ul:t=new be({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else q.isBufferSource(e[0])?t=L.parse(e[0],be):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=sl,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=ol,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=cl,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=ul,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=_o,this.value=e.registeredID;else if(e.directoryName!=null)this.type=al,this.value=new Ht(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Qp){this.type=ll;const t=L.parse(e.otherName.value,De),n=new RegExp(Xp,"i").exec(te.ToHex(t));if(!n)throw new Error(Z1);this.value=n.slice(1).map((i,s)=>s<3?te.ToHex(new Uint8Array(te.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===em)this.type=dl,this.value=L.parse(e.otherName.value,ht).toString();else throw new Error(Yp);else throw new Error(Yp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case al:case sl:case ll:case cl:case _o:case dl:case ul:e=this.type.toUpperCase();break;case ol:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===_o&&(t=Nn.toString(t)),new Me(e,void 0,t)}}class Ea extends Bn{constructor(e){let t;if(e instanceof xt)t=e;else if(Array.isArray(e)){const n=[];for(const i of e)if(i instanceof be)n.push(i);else{const s=L.parse(new pn(i.type,i.value).rawData,be);n.push(s)}t=new xt(n)}else if(q.isBufferSource(e))t=L.parse(e,xt);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let i=null;try{i=new pn(n)}catch{continue}t.push(i)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let i=e[n[Me.NAME]];Array.isArray(i)||(i=[],e[n[Me.NAME]]=i),i.push(n)}return e}}Ea.NAME="GeneralNames";const Vs="-{5}",Ia="\\n",M1=`[^${Ia}]+`,U1=`${Vs}BEGIN (${M1}(?=${Vs}))${Vs}`,V1=`${Vs}END \\1${Vs}`,ns="\\n",L1=`[^:${Ia}]+`,q1=`(?:[^${Ia}]+${ns}(?: +[^${Ia}]+${ns})*)`,H1="[a-zA-Z0-9=+/]+",F1=`(?:${H1}${ns})+`,tm=`${U1}${ns}(?:((?:${L1}: ${q1})+))?${ns}?(${F1})${V1}`;class $t{static isPem(e){return typeof e=="string"&&new RegExp(tm,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(tm,"g"),n=[];let i=null;for(;i=t.exec(e);){const s=i[3].replace(new RegExp(`[${Ia}]+`,"g"),""),a={type:i[1],headers:[],rawData:te.FromBase64(s)},o=i[2];if(o){const c=o.split(new RegExp(ns,"g"));let u=null;for(const f of c){const[m,B]=f.split(/:(.*)/);if(B===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=m.trim()}else u&&a.headers.push(u),u={key:m,value:B.trim()}}u&&a.headers.push(u)}n.push(a)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){const t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){const n=new Array;return t?e.forEach(i=>{if(!q.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:q.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
117
+ */const po="crypto.algorithm";class B1{getAlgorithms(){return pt.resolveAll(po)}toAsnAlgorithm(e){({...e});for(const t of this.getAlgorithms()){const n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){const t=new Y({algorithm:e.name});if("parameters"in e){const n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const n of this.getAlgorithms()){const i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const hi="crypto.algorithmProvider";pt.registerSingleton(hi,B1);var Ro;const Bt="1.3.36.3.3.2.8.1.1",Sp=`${Bt}.1`,Ap=`${Bt}.2`,Op=`${Bt}.3`,Ep=`${Bt}.4`,Ip=`${Bt}.5`,Cp=`${Bt}.6`,jp=`${Bt}.7`,Tp=`${Bt}.8`,Np=`${Bt}.9`,Bp=`${Bt}.10`,Rp=`${Bt}.11`,Pp=`${Bt}.12`,$p=`${Bt}.13`,Dp=`${Bt}.14`,Zp="brainpoolP160r1",Mp="brainpoolP160t1",Up="brainpoolP192r1",Vp="brainpoolP192t1",Lp="brainpoolP224r1",qp="brainpoolP224t1",Hp="brainpoolP256r1",Fp="brainpoolP256t1",Kp="brainpoolP320r1",Wp="brainpoolP320t1",zp="brainpoolP384r1",Gp="brainpoolP384t1",Jp="brainpoolP512r1",Yp="brainpoolP512t1",ze="ECDSA";let Oa=Ro=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ze.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return n1;case"sha-256":return i1;case"sha-384":return s1;case"sha-512":return a1}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=tp;break;case"K-256":t=Ro.SECP256K1;break;case"P-384":t=rp;break;case"P-521":t=np;break;case Zp:t=Sp;break;case Mp:t=Ap;break;case Up:t=Op;break;case Vp:t=Ep;break;case Lp:t=Ip;break;case qp:t=Cp;break;case Hp:t=jp;break;case Fp:t=Tp;break;case Kp:t=Np;break;case Wp:t=Bp;break;case zp:t=Rp;break;case Gp:t=Pp;break;case Jp:t=$p;break;case Yp:t=Dp;break}if(t)return new Y({algorithm:ka,parameters:L.serialize(new An({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Wf:return{name:ze,hash:{name:"SHA-1"}};case zf:return{name:ze,hash:{name:"SHA-256"}};case Gf:return{name:ze,hash:{name:"SHA-384"}};case Jf:return{name:ze,hash:{name:"SHA-512"}};case ka:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(L.parse(e.parameters,An).namedCurve){case tp:return{name:ze,namedCurve:"P-256"};case Ro.SECP256K1:return{name:ze,namedCurve:"K-256"};case rp:return{name:ze,namedCurve:"P-384"};case np:return{name:ze,namedCurve:"P-521"};case Sp:return{name:ze,namedCurve:Zp};case Ap:return{name:ze,namedCurve:Mp};case Op:return{name:ze,namedCurve:Up};case Ep:return{name:ze,namedCurve:Vp};case Ip:return{name:ze,namedCurve:Lp};case Cp:return{name:ze,namedCurve:qp};case jp:return{name:ze,namedCurve:Hp};case Tp:return{name:ze,namedCurve:Fp};case Np:return{name:ze,namedCurve:Kp};case Bp:return{name:ze,namedCurve:Wp};case Rp:return{name:ze,namedCurve:zp};case Pp:return{name:ze,namedCurve:Gp};case $p:return{name:ze,namedCurve:Jp};case Dp:return{name:ze,namedCurve:Yp}}}}return null}};Oa.SECP256K1="1.3.132.0.10";Oa=Ro=l([Lu()],Oa);pt.registerSingleton(po,Oa);const b0=Symbol("name"),x0=Symbol("value");class Me{constructor(e,t={},n=""){this[b0]=e,this[x0]=n;for(const i in t)this[i]=t[i]}}Me.NAME=b0;Me.VALUE=x0;class R1{static toTextObject(e){const t=new Me("Algorithm Identifier",{},Nn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case ka:{const n=new Oa().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class Nn{static toString(e){const t=this.items[e];return t||e}}Nn.items={[$c]:"sha1",[a0]:"sha224",[Dc]:"sha256",[Zc]:"sha384",[Mc]:"sha512",[li]:"rsaEncryption",[Bc]:"sha1WithRSAEncryption",[f1]:"sha224WithRSAEncryption",[Ed]:"sha256WithRSAEncryption",[Rc]:"sha384WithRSAEncryption",[Pc]:"sha512WithRSAEncryption",[ka]:"ecPublicKey",[Wf]:"ecdsaWithSHA1",[n0]:"ecdsaWithSHA224",[zf]:"ecdsaWithSHA256",[Gf]:"ecdsaWithSHA384",[Jf]:"ecdsaWithSHA512",[Jw]:"TLS WWW server authentication",[Yw]:"TLS WWW client authentication",[Xw]:"Code Signing",[Qw]:"E-mail Protection",[e1]:"Time Stamping",[t1]:"OCSP Signing",[r1]:"Signed Data"};class pi{static serialize(e){return this.serializeObj(e).join(`
118
+ `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let i=this.pad(t++),s="";const a=e[Me.VALUE];a&&(s=` ${a}`),n.push(`${i}${e[Me.NAME]}:${s}`),i=this.pad(t);for(const o in e){if(typeof o=="symbol")continue;const c=e[o],u=o?`${o}: `:"";if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`${i}${u}${c}`);else if(c instanceof Date)n.push(`${i}${u}${c.toUTCString()}`);else if(Array.isArray(c))for(const f of c)f[Me.NAME]=o,n.push(...this.serializeObj(f,t));else if(c instanceof Me)c[Me.NAME]=o,n.push(...this.serializeObj(c,t));else if(q.isBufferSource(c))o?(n.push(`${i}${u}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){const f=c.toTextObject();f[Me.NAME]=o,n.push(...this.serializeObj(f,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),i=q.toUint8Array(e),s=[];for(let a=0;a<i.length;){const o=[];for(let c=0;c<16&&a<i.length;c++){c===8&&o.push("");const u=i[a++].toString(16).padStart(2,"0");o.push(u)}s.push(`${n}${o.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}pi.oidSerializer=Nn;pi.algorithmSerializer=R1;class Bn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=L.serialize(t),this.onInit(t)}else{const t=L.parse(e[0],e[1]);this.rawData=q.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Bn?My(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return L.toString(this.rawData);case"text":return pi.serialize(this.toTextObject());case"hex":return te.ToHex(this.rawData);case"base64":return te.ToBase64(this.rawData);case"base64url":return te.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new Me(this.getTextName(),{},e)}}Bn.NAME="ASN";class Gt extends Bn{constructor(...e){let t;q.isBufferSource(e[0])?t=q.toArrayBuffer(e[0]):t=L.serialize(new Wt({extnID:e[0],critical:e[1],extnValue:new De(q.toArrayBuffer(e[2]))})),super(t,Wt)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[Me.NAME]===Gt.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}var _0;class hn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[_0]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(hn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(hn.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=hn.DEFAULT){const t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(hn.DEFAULT,e);return this}}_0=Symbol.toStringTag;hn.DEFAULT="default";const ut=new hn,P1=/^[0-2](?:\.[1-9][0-9]*)+$/;function $1(r){return new RegExp(P1).test(r)}class w0{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return $1(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const Tt=new w0;Tt.register("CN","2.5.4.3");Tt.register("L","2.5.4.7");Tt.register("ST","2.5.4.8");Tt.register("O","2.5.4.10");Tt.register("OU","2.5.4.11");Tt.register("C","2.5.4.6");Tt.register("DC","0.9.2342.19200300.100.1.25");Tt.register("E","1.2.840.113549.1.9.1");Tt.register("G","2.5.4.42");Tt.register("I","2.5.4.43");Tt.register("SN","2.5.4.4");Tt.register("T","2.5.4.12");function D1(r,e){return`\\${te.ToHex(te.FromUtf8String(e)).toUpperCase()}`}function Z1(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,D1)}class Ht{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new w0,this.asn=new et;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=t[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof et?this.asn=e:q.isBufferSource(e)?this.asn=L.parse(e,et):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||Tt.findId(e),n=[];for(const i of this.asn)for(const s of i)s.type===t&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||Tt.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,i=t.value.anyValue?`#${te.ToHex(t.value.anyValue)}`:Z1(t.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const i={};for(const s of n){const a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${te.ToHex(s.value.anyValue)}`:s.value.toString())}t.push(i)}return t}fromString(e){const t=new et,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=n.exec(`${e},`);){let[,a,o]=i;const c=o[o.length-1];(c===","||c==="+")&&(o=o.slice(0,o.length-1),i[3]=c);const u=i[3];a=this.getTypeOid(a);const f=this.createAttribute(a,o);s==="+"?t[t.length-1].push(f):t.push(new Gi([f])),s=u}return t}fromJSON(e){const t=new et;for(const n of e){const i=new Gi;for(const s in n){const a=this.getTypeOid(s),o=n[s];for(const c of o){const u=this.createAttribute(a,c);i.push(u)}}t.push(i)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){const n=new wu({type:e});if(typeof t=="object")for(const i in t)switch(i){case"ia5String":n.value.ia5String=t[i];break;case"utf8String":n.value.utf8String=t[i];break;case"universalString":n.value.universalString=t[i];break;case"bmpString":n.value.bmpString=t[i];break;case"printableString":n.value.printableString=t[i];break}else if(t[0]==="#")n.value.anyValue=te.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:Ht.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
119
+ `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return L.serialize(this.asn)}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(i,this.toArrayBuffer())}}const k0="Cannot initialize GeneralName from ASN.1 data.",Xp=`${k0} Unsupported string format in use.`,M1=`${k0} Value doesn't match to GUID regular expression.`,Qp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,em="1.3.6.1.4.1.311.25.1",tm="1.3.6.1.4.1.311.20.2.3",al="dns",ol="dn",cl="email",ul="ip",ll="url",dl="guid",fl="upn",_o="id";class pn extends Bn{constructor(...e){let t;if(e.length===2)switch(e[0]){case ol:{const n=new Ht(e[1]).toArrayBuffer(),i=L.parse(n,et);t=new be({directoryName:i});break}case al:t=new be({dNSName:e[1]});break;case cl:t=new be({rfc822Name:e[1]});break;case dl:{const n=new RegExp(Qp,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=n.slice(1).map((s,a)=>a<3?te.ToHex(new Uint8Array(te.FromHex(s)).reverse()):s).join("");t=new be({otherName:new ba({typeId:em,value:L.serialize(new De(te.FromHex(i)))})});break}case ul:t=new be({iPAddress:e[1]});break;case _o:t=new be({registeredID:e[1]});break;case fl:{t=new be({otherName:new ba({typeId:tm,value:L.serialize(Mg.toASN(e[1]))})});break}case ll:t=new be({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else q.isBufferSource(e[0])?t=L.parse(e[0],be):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=al,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=cl,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=ul,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=ll,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=_o,this.value=e.registeredID;else if(e.directoryName!=null)this.type=ol,this.value=new Ht(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===em){this.type=dl;const t=L.parse(e.otherName.value,De),n=new RegExp(Qp,"i").exec(te.ToHex(t));if(!n)throw new Error(M1);this.value=n.slice(1).map((i,s)=>s<3?te.ToHex(new Uint8Array(te.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===tm)this.type=fl,this.value=L.parse(e.otherName.value,ht).toString();else throw new Error(Xp);else throw new Error(Xp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case ol:case al:case dl:case ul:case _o:case fl:case ll:e=this.type.toUpperCase();break;case cl:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===_o&&(t=Nn.toString(t)),new Me(e,void 0,t)}}class Ea extends Bn{constructor(e){let t;if(e instanceof xt)t=e;else if(Array.isArray(e)){const n=[];for(const i of e)if(i instanceof be)n.push(i);else{const s=L.parse(new pn(i.type,i.value).rawData,be);n.push(s)}t=new xt(n)}else if(q.isBufferSource(e))t=L.parse(e,xt);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let i=null;try{i=new pn(n)}catch{continue}t.push(i)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let i=e[n[Me.NAME]];Array.isArray(i)||(i=[],e[n[Me.NAME]]=i),i.push(n)}return e}}Ea.NAME="GeneralNames";const Vs="-{5}",Ia="\\n",U1=`[^${Ia}]+`,V1=`${Vs}BEGIN (${U1}(?=${Vs}))${Vs}`,L1=`${Vs}END \\1${Vs}`,ns="\\n",q1=`[^:${Ia}]+`,H1=`(?:[^${Ia}]+${ns}(?: +[^${Ia}]+${ns})*)`,F1="[a-zA-Z0-9=+/]+",K1=`(?:${F1}${ns})+`,rm=`${V1}${ns}(?:((?:${q1}: ${H1})+))?${ns}?(${K1})${L1}`;class $t{static isPem(e){return typeof e=="string"&&new RegExp(rm,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(rm,"g"),n=[];let i=null;for(;i=t.exec(e);){const s=i[3].replace(new RegExp(`[${Ia}]+`,"g"),""),a={type:i[1],headers:[],rawData:te.FromBase64(s)},o=i[2];if(o){const c=o.split(new RegExp(ns,"g"));let u=null;for(const f of c){const[m,B]=f.split(/:(.*)/);if(B===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=m.trim()}else u&&a.headers.push(u),u={key:m,value:B.trim()}}u&&a.headers.push(u)}n.push(a)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){const t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){const n=new Array;return t?e.forEach(i=>{if(!q.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:q.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
120
120
  `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:q.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const u of e.headers)i.push(`${u.key}: ${u.value}`);i.push("")}const s=te.ToBase64(e.rawData);let a,o=0;const c=Array();for(;o<s.length&&(s.length-o<64?a=s.substring(o):(a=s.substring(o,o+64),o+=64),a.length!==0);)if(c.push(a),a.length<64)break;return i.push(...c),i.push(`-----END ${n}-----`),i.join(`
121
- `)}}$t.CertificateTag="CERTIFICATE";$t.CrlTag="CRL";$t.CertificateRequestTag="CERTIFICATE REQUEST";$t.PublicKeyTag="PUBLIC KEY";$t.PrivateKeyTag="PRIVATE KEY";class Jr extends Bn{static isAsnEncoded(e){return q.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if($t.isPem(e))return $t.decode(e)[0];if(te.isHex(e))return te.FromHex(e);if(te.isBase64(e))return te.FromBase64(e);if(te.isBase64Url(e))return te.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=te.ToBinary(e);return $t.isPem(t)?$t.decode(t)[0]:te.isHex(t)?te.FromHex(t):te.isBase64(t)?te.FromBase64(t):te.isBase64Url(t)?te.FromBase64Url(t):q.toArrayBuffer(e)}}constructor(...e){Jr.isAsnEncoded(e[0])?super(Jr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return $t.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ur extends Jr{static async create(e,t=ut.get()){if(e instanceof ur)return e;if(hn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new ur(n)}else{if(e.publicKey)return e.publicKey;if(q.isBufferSource(e))return new ur(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Jr.isAsnEncoded(e)?super(e,sr):super(e),this.tag=$t.PublicKeyTag}async export(...e){let t,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,t=e[2]||ut.get()):t=e[0]||ut.get();let s=this.rawData;const a=L.parse(this.rawData,sr);return a.algorithm.algorithm===Us&&(s=K1(a,s)),t.subtle.importKey("spki",s,i,!0,n)}onInit(e){const t=pt.resolve(hi),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case li:{const i=L.parse(e.subjectPublicKey,Jf),s=q.toUint8Array(i.modulus);n.publicExponent=q.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=ut.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=ut.get();const i=L.parse(this.rawData,sr);return await t.subtle.digest(n,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,sr);switch(e.Algorithm=pi.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case ka:e["EC Point"]=t.subjectPublicKey;break;case li:default:e["Raw Data"]=t.subjectPublicKey}return e}}function K1(r,e){return r.algorithm=new Y({algorithm:li,parameters:null}),e=L.serialize(r),e}class Ca extends Gt{static async create(e,t=!1,n=ut.get()){if("name"in e&&"serialNumber"in e)return new Ca(e,t);const s=await(await ur.create(e,n)).getKeyIdentifier(n);return new Ca(te.ToHex(s),t)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Ln({keyIdentifier:new Tf(te.FromHex(e[0]))});super(Hl,e[1],L.serialize(t))}else{const t=e[0],n=t.name instanceof Ea?L.parse(t.name.rawData,xt):t.name,i=new Ln({authorityCertIssuer:n,authorityCertSerialNumber:te.FromHex(t.serialNumber)});super(Hl,e[1],L.serialize(i))}}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Ln);t.keyIdentifier&&(this.keyId=te.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?te.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,Ln);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Ea(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Ca.NAME="Authority Key Identifier";class eh extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,pc);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new pc({cA:e[0],pathLenConstraint:e[1]});super(Vg,e[2],L.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}eh.NAME="Basic Constraints";var rm;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(rm||(rm={}));class th extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,vc);this.usages=t.map(n=>n)}else{const t=new vc(e[0]);super(Hg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Nn.toString(t)).join(", "),e}}th.NAME="Extended Key Usages";var Hc;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Hc||(Hc={}));class rh extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,il);this.usages=t.toNumber()}else{const t=new il(e[0]);super(Fg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,il);return e[""]=t.toJSON().join(", "),e}}rh.NAME="Key Usages";class mo extends Gt{static async create(e,t=!1,n=ut.get()){const s=await(await ur.create(e,n)).getKeyIdentifier(n);return new mo(te.ToHex(s),t)}constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,yn);this.keyId=te.ToHex(t)}else{const t=typeof e[0]=="string"?te.FromHex(e[0]):e[0],n=new yn(t);super(Gg,e[1],L.serialize(n)),this.keyId=te.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,yn);return e[""]=t,e}}mo.NAME="Subject Key Identifier";class k0 extends Gt{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(zg,e[1],new Ea(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,sd);this.names=new Ea(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}k0.NAME="Subject Alternative Name";class Jt{static register(e,t){this.items.set(e,t)}static create(e){const t=new Gt(e),n=this.items.get(t.type);return n?new n(e):t}}Jt.items=new Map;class S0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0])){super(e[0]);const n=L.parse(this.value,yc);this.policies=n.map(i=>i.policyIdentifier)}else{const n=e[0],i=(t=e[1])!==null&&t!==void 0?t:!1,s=new yc(n.map(a=>new ku({policyIdentifier:a})));super(Lg,i,L.serialize(s)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Me("",{},Nn.toString(t))),e}}S0.NAME="Certificate Policies";Jt.register(Lg,S0);class A0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(a=>new ds({distributionPoint:new ai({fullName:[new be({uniformResourceIdentifier:a})]})})),s=new Ri(i);super(Gl,e[1],L.serialize(s))}else{const n=new Ri(e[0]);super(Gl,e[1],L.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Ri);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const i={};return t.distributionPoint&&(i[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new pn(s).toString()).join(", ")),t.reasons&&(i.Reasons=t.reasons.toString()),t.cRLIssuer&&(i["CRL Issuer"]=t.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}A0.NAME="CRL Distribution Points";class O0 extends Gt{constructor(...e){var t,n,i,s;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Ii){const a=new Ii(e[0]);super(ql,e[1],L.serialize(a))}else{const a=e[0],o=new Ii;ko(o,a,Mh,"ocsp"),ko(o,a,Uh,"caIssuers"),ko(o,a,Vh,"timeStamping"),ko(o,a,Lh,"caRepository"),super(ql,e[1],L.serialize(o))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],L.parse(e.extnValue,Ii).forEach(n=>{switch(n.accessMethod){case Mh:this.ocsp.push(new pn(n.accessLocation));break;case Uh:this.caIssuers.push(new pn(n.accessLocation));break;case Vh:this.timeStamping.push(new pn(n.accessLocation));break;case Lh:this.caRepository.push(new pn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&wo(e,"OCSP",this.ocsp),this.caIssuers.length&&wo(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&wo(e,"Time Stamping",this.timeStamping),this.caRepository.length&&wo(e,"CA Repository",this.caRepository),e}}O0.NAME="Authority Info Access";function wo(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new Me("");t.forEach((i,s)=>{const a=i.toTextObject(),o=`${a[Me.NAME]} ${s+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function ko(r,e,t,n){const i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new pn("url",a)),r.push(new to({accessMethod:t,accessLocation:L.parse(a.rawData,be)}))})}class vs extends Bn{constructor(...e){let t;if(q.isBufferSource(e[0]))t=q.toArrayBuffer(e[0]);else{const n=e[0],i=Array.isArray(e[1])?e[1].map(s=>q.toArrayBuffer(s)):[];t=L.serialize(new Wr({type:n,values:i}))}super(t,Wr)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Me("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[Me.NAME]===vs.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}vs.NAME="Attribute";class E0 extends vs{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=new Lc({printableString:e[0]});super(g0,[L.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],Lc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Me.VALUE]=this.password,e}}E0.NAME="Challenge Password";class nh extends vs{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=e[0],i=new kn;for(const s of n)i.push(L.parse(s.rawData,Wt));super(Qf,[L.serialize(i)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],kn);this.items=t.map(n=>Jt.create(L.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[Me.NAME]]=n;return e}}nh.NAME="Extensions";class Ku{static register(e,t){this.items.set(e,t)}static create(e){const t=new vs(e),n=this.items.get(t.type);return n?new n(e):t}}Ku.items=new Map;const yo="crypto.signatureFormatter";class W1{toAsnSignature(e,t){return q.toArrayBuffer(t)}toWebSignature(e,t){return q.toArrayBuffer(t)}}var Po;let Gd=Po=class{static createPssParams(e,t){const n=Po.getHashAlgorithm(e);return n?new fi({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:Du,parameters:L.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=pt.resolve(hi);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new Y({algorithm:Nc,parameters:null});case"sha-256":return new Y({algorithm:Od,parameters:null});case"sha-384":return new Y({algorithm:Bc,parameters:null});case"sha-512":return new Y({algorithm:Rc,parameters:null})}}else return new Y({algorithm:li,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=Po.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new Y({algorithm:Us,parameters:L.serialize(t)})}else return new Y({algorithm:Us,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case li:return{name:"RSASSA-PKCS1-v1_5"};case Nc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Od:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Bc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Rc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Us:if(e.parameters){const t=L.parse(e.parameters,fi);return{name:"RSA-PSS",hash:pt.resolve(hi).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Gd=Po=l([Vu()],Gd);pt.registerSingleton(po,Gd);let Jd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:Pc});case"sha-256":return new Y({algorithm:$c});case"sha-384":return new Y({algorithm:Dc});case"sha-512":return new Y({algorithm:Zc})}return null}toWebAlgorithm(e){switch(e.algorithm){case Pc:return{name:"SHA-1"};case $c:return{name:"SHA-256"};case Dc:return{name:"SHA-384"};case Zc:return{name:"SHA-512"}}return null}};Jd=l([Vu()],Jd);pt.registerSingleton(po,Jd);class Ft{addPadding(e,t){const n=q.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=q.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(t&&n[0]>127){const i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,i=Ft.namedCurveSize.get(n)||Ft.defaultNamedCurveSize,s=new Tc,a=q.toUint8Array(t);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),L.serialize(s)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=L.parse(t,Tc),i=e.namedCurve,s=Ft.namedCurveSize.get(i)||Ft.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(n.r)),o=this.addPadding(s,this.removePadding(n.s));return aw(a,o)}return null}}Ft.namedCurveSize=new Map;Ft.defaultNamedCurveSize=32;const fl="1.3.101.110",nm="1.3.101.111",hl="1.3.101.112",im="1.3.101.113";let Yd=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=hl;break;case"x25519":t=fl;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=hl;break;case"ed448":t=im;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=fl;break;case"x448":t=nm;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case hl:return{name:"Ed25519"};case im:return{name:"EdDSA",namedCurve:"Ed448"};case fl:return{name:"X25519"};case nm:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Yd=l([Vu()],Yd);pt.registerSingleton(po,Yd);class z1 extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,Aa):super(e),this.tag=$t.CertificateRequestTag}onInit(e){this.tbs=L.serialize(e.certificationRequestInfo),this.publicKey=new ur(e.certificationRequestInfo.subjectPKInfo);const t=pt.resolve(hi);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Ku.create(L.serialize(i)));const n=this.getAttribute(Qf);this.extensions=[],n instanceof nh&&(this.extensions=n.items),this.subjectName=new Ht(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=ut.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),i=pt.resolveAll(yo).reverse();let s=null;for(const o of i)if(s=o.toWebSignature(t,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,Aa),n=t.certificationRequestInfo,i=new Me("",{Version:`${oi[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new Me("");for(const a of this.attributes){const o=a.toTextObject();s[o[Me.NAME]]=o}i.Attributes=s}return e.Data=i,e.Signature=new Me("",{Algorithm:pi.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}z1.NAME="PKCS#10 Certificate Request";class ih extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,ci):super(e),this.tag=$t.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=L.serialize(t),this.serialNumber=te.ToHex(t.serialNumber),this.subjectName=new Ht(t.subject),this.subject=new Ht(t.subject).toString(),this.issuerName=new Ht(t.issuer),this.issuer=this.issuerName.toString();const n=pt.resolve(hi);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(a=>Jt.create(L.serialize(a)))),this.publicKey=new ur(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=ut.get()){let n,i;const s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],t);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],t);else if(s instanceof ur)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],t);else if(q.isBufferSource(s)){const u=new ur(s);n={...u.algorithm,...this.signatureAlgorithm},i=await u.export(n,["verify"],t)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const a=pt.resolveAll(yo).reverse();let o=null;for(const u of a)if(o=u.toWebSignature(n,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const c=await t.subtle.verify(this.signatureAlgorithm,i,o,this.tbs);if(e.signatureOnly)return c;{const f=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<f&&f<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=ut.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=ut.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,ci),n=t.tbsCertificate,i=new Me("",{Version:`${oi[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":pi.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Me("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const s=new Me("");for(const a of this.extensions){const o=a.toTextObject();s[o[Me.NAME]]=o}i.Extensions=s}return e.Data=i,e.Signature=new Me("",{Algorithm:pi.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}ih.NAME="Certificate";class G1{static async createSelfSigned(e,t=ut.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=ut.get()){var n;let i;e.publicKey instanceof ur?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?i=e.publicKey:i=await t.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?q.toUint8Array(te.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const a=e.notBefore||new Date,o=e.notAfter||new Date(a.getTime()+31536e6),c=new ci({tbsCertificate:new Ut({version:oi.v3,serialNumber:s,validity:new ro({notBefore:a,notAfter:o}),extensions:new kn(((n=e.extensions)===null||n===void 0?void 0:n.map(A=>L.parse(A.rawData,Wt)))||[]),subjectPublicKeyInfo:L.parse(i,sr)})});if(e.subject){const A=e.subject instanceof Ht?e.subject:new Ht(e.subject);c.tbsCertificate.subject=L.parse(A.toArrayBuffer(),et)}if(e.issuer){const A=e.issuer instanceof Ht?e.issuer:new Ht(e.issuer);c.tbsCertificate.issuer=L.parse(A.toArrayBuffer(),et)}const u={hash:"SHA-256"},f="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},m=pt.resolve(hi);c.tbsCertificate.signature=c.signatureAlgorithm=m.toAsnAlgorithm(f);const B=L.serialize(c.tbsCertificate),C="signingKey"in e?await t.subtle.sign(f,e.signingKey,B):e.signature,p=pt.resolveAll(yo).reverse();let g=null;for(const A of p)if(g=A.toAsnSignature(f,C),g)break;if(!g)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=g,new ih(L.serialize(c))}}var sm;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(sm||(sm={}));Jt.register(Vg,eh);Jt.register(Hg,th);Jt.register(Fg,rh);Jt.register(Gg,mo);Jt.register(Hl,Ca);Jt.register(zg,k0);Jt.register(Gl,A0);Jt.register(ql,O0);Ku.register(g0,E0);Ku.register(Qf,nh);pt.registerSingleton(yo,W1);pt.registerSingleton(yo,Ft);Ft.namedCurveSize.set("P-256",32);Ft.namedCurveSize.set("K-256",32);Ft.namedCurveSize.set("P-384",48);Ft.namedCurveSize.set("P-521",66);const am="0123456789abcdef";function Xd(r){const e=new Uint8Array(r);let t="";for(let n=0;n<e.length;n++){const i=e[n]>>4;t+=am[i];const s=e[n]&15;t+=am[s]}return t}class I0{constructor(e,t){ne(this,"alphabet");ne(this,"padding");ne(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",i=0,s=0;for(let o=0;o<e.length;o++)for(i=i<<8|e[o],s+=8;s>=5;)s-=5,n+=this.alphabet[i>>s&31];if(s>0&&(n+=this.alphabet[i<<5-s&31]),(t==null?void 0:t.includePadding)??!0){const o=(8-n.length%8)%8;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let a=0;a<i;a++){let o=0;const c=[];for(let f=0;f<8;f++){const m=e[a*8+f];if(m==="="){if(a+1!==i)throw new Error(`Invalid character: ${m}`);o+=1;continue}if(m===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const B=this.decodeMap.get(m)??null;if(B===null)throw new Error(`Invalid character: ${m}`);c.push(B)}if(o===8||o===7||o===5||o===2)throw new Error("Invalid padding");const u=(c[0]<<3)+(c[1]>>2);if(s.push(u),o<6){const f=((c[1]&3)<<6)+(c[2]<<1)+(c[3]>>4);s.push(f)}if(o<4){const f=((c[3]&255)<<4)+(c[4]>>1);s.push(f)}if(o<3){const f=((c[4]&1)<<7)+(c[5]<<2)+(c[6]>>3);s.push(f)}if(o<1){const f=((c[6]&7)<<5)+c[7];s.push(f)}}return Uint8Array.from(s)}}new I0("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new I0("0123456789ABCDEFGHIJKLMNOPQRSTUV");class C0{constructor(e,t){ne(this,"alphabet");ne(this,"padding");ne(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",i=0,s=0;for(let o=0;o<e.length;o++)for(i=i<<8|e[o],s+=8;s>=6;)s+=-6,n+=this.alphabet[i>>s&63];if(s>0&&(n+=this.alphabet[i<<6-s&63]),(t==null?void 0:t.includePadding)??!0){const o=(4-n.length%4)%4;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let a=0;a<i;a++){let o=0,c=0;for(let u=0;u<4;u++){const f=e[a*4+u];if(f==="="){if(a+1!==i)throw new Error(`Invalid character: ${f}`);o+=1;continue}if(f===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const m=this.decodeMap.get(f)??null;if(m===null)throw new Error(`Invalid character: ${f}`);c+=m<<6*(3-u)}s.push(c>>16&255),o<2&&s.push(c>>8&255),o<1&&s.push(c&255)}return Uint8Array.from(s)}}const J1=new C0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),$o=new C0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class Y1{constructor(e){ne(this,"hash");this.hash=e}async verify(e,t,n){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,t,n)}async sign(e,t){const n=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",n,t)}async generateKeyPair(e){const t=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),n=await crypto.subtle.exportKey("pkcs8",t.privateKey),i=await crypto.subtle.exportKey("spki",t.publicKey);return{privateKey:n,publicKey:i}}}async function j0(r){return await crypto.subtle.digest("SHA-256",r)}async function Qd(r){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},t=await crypto.subtle.generateKey(e,!0,["sign","verify"]),n=lc(),i=Xd(new TextEncoder().encode(n)),s=await G1.createSelfSigned({serialNumber:i,name:r.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:t,extensions:[new eh(!0,2,!0),new th(["1.3.6.1.5.5.7.3.1"],!0),new rh(Hc.keyCertSign|Hc.cRLSign,!0),await mo.create(t.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",t.privateKey),o=s.toString("pem"),c=await Q1(s),u=Xd(await s.getThumbprint()),f=X1("PRIVATE",a);return{kid:s.serialNumber,cert:o,thumbprint:u,fingerprint:c,pkcs7:f}}function X1(r,e){const t=J1.encode(new Uint8Array(e));let n=`-----BEGIN ${r} KEY-----\r
121
+ `)}}$t.CertificateTag="CERTIFICATE";$t.CrlTag="CRL";$t.CertificateRequestTag="CERTIFICATE REQUEST";$t.PublicKeyTag="PUBLIC KEY";$t.PrivateKeyTag="PRIVATE KEY";class Jr extends Bn{static isAsnEncoded(e){return q.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if($t.isPem(e))return $t.decode(e)[0];if(te.isHex(e))return te.FromHex(e);if(te.isBase64(e))return te.FromBase64(e);if(te.isBase64Url(e))return te.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=te.ToBinary(e);return $t.isPem(t)?$t.decode(t)[0]:te.isHex(t)?te.FromHex(t):te.isBase64(t)?te.FromBase64(t):te.isBase64Url(t)?te.FromBase64Url(t):q.toArrayBuffer(e)}}constructor(...e){Jr.isAsnEncoded(e[0])?super(Jr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return $t.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ur extends Jr{static async create(e,t=ut.get()){if(e instanceof ur)return e;if(hn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new ur(n)}else{if(e.publicKey)return e.publicKey;if(q.isBufferSource(e))return new ur(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Jr.isAsnEncoded(e)?super(e,sr):super(e),this.tag=$t.PublicKeyTag}async export(...e){let t,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,t=e[2]||ut.get()):t=e[0]||ut.get();let s=this.rawData;const a=L.parse(this.rawData,sr);return a.algorithm.algorithm===Us&&(s=W1(a,s)),t.subtle.importKey("spki",s,i,!0,n)}onInit(e){const t=pt.resolve(hi),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case li:{const i=L.parse(e.subjectPublicKey,Yf),s=q.toUint8Array(i.modulus);n.publicExponent=q.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=ut.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=ut.get();const i=L.parse(this.rawData,sr);return await t.subtle.digest(n,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,sr);switch(e.Algorithm=pi.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case ka:e["EC Point"]=t.subjectPublicKey;break;case li:default:e["Raw Data"]=t.subjectPublicKey}return e}}function W1(r,e){return r.algorithm=new Y({algorithm:li,parameters:null}),e=L.serialize(r),e}class Ca extends Gt{static async create(e,t=!1,n=ut.get()){if("name"in e&&"serialNumber"in e)return new Ca(e,t);const s=await(await ur.create(e,n)).getKeyIdentifier(n);return new Ca(te.ToHex(s),t)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Ln({keyIdentifier:new Nf(te.FromHex(e[0]))});super(Fl,e[1],L.serialize(t))}else{const t=e[0],n=t.name instanceof Ea?L.parse(t.name.rawData,xt):t.name,i=new Ln({authorityCertIssuer:n,authorityCertSerialNumber:te.FromHex(t.serialNumber)});super(Fl,e[1],L.serialize(i))}}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Ln);t.keyIdentifier&&(this.keyId=te.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?te.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,Ln);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Ea(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Ca.NAME="Authority Key Identifier";class th extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,mc);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new mc({cA:e[0],pathLenConstraint:e[1]});super(Lg,e[2],L.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}th.NAME="Basic Constraints";var nm;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(nm||(nm={}));class rh extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,bc);this.usages=t.map(n=>n)}else{const t=new bc(e[0]);super(Fg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Nn.toString(t)).join(", "),e}}rh.NAME="Extended Key Usages";var Fc;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Fc||(Fc={}));class nh extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,sl);this.usages=t.toNumber()}else{const t=new sl(e[0]);super(Kg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,sl);return e[""]=t.toJSON().join(", "),e}}nh.NAME="Key Usages";class mo extends Gt{static async create(e,t=!1,n=ut.get()){const s=await(await ur.create(e,n)).getKeyIdentifier(n);return new mo(te.ToHex(s),t)}constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,yn);this.keyId=te.ToHex(t)}else{const t=typeof e[0]=="string"?te.FromHex(e[0]):e[0],n=new yn(t);super(Jg,e[1],L.serialize(n)),this.keyId=te.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,yn);return e[""]=t,e}}mo.NAME="Subject Key Identifier";class S0 extends Gt{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(Gg,e[1],new Ea(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,ad);this.names=new Ea(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}S0.NAME="Subject Alternative Name";class Jt{static register(e,t){this.items.set(e,t)}static create(e){const t=new Gt(e),n=this.items.get(t.type);return n?new n(e):t}}Jt.items=new Map;class A0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0])){super(e[0]);const n=L.parse(this.value,gc);this.policies=n.map(i=>i.policyIdentifier)}else{const n=e[0],i=(t=e[1])!==null&&t!==void 0?t:!1,s=new gc(n.map(a=>new Su({policyIdentifier:a})));super(qg,i,L.serialize(s)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Me("",{},Nn.toString(t))),e}}A0.NAME="Certificate Policies";Jt.register(qg,A0);class O0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(a=>new ds({distributionPoint:new ai({fullName:[new be({uniformResourceIdentifier:a})]})})),s=new Ri(i);super(Jl,e[1],L.serialize(s))}else{const n=new Ri(e[0]);super(Jl,e[1],L.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Ri);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const i={};return t.distributionPoint&&(i[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new pn(s).toString()).join(", ")),t.reasons&&(i.Reasons=t.reasons.toString()),t.cRLIssuer&&(i["CRL Issuer"]=t.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}O0.NAME="CRL Distribution Points";class E0 extends Gt{constructor(...e){var t,n,i,s;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Ii){const a=new Ii(e[0]);super(Hl,e[1],L.serialize(a))}else{const a=e[0],o=new Ii;ko(o,a,Uh,"ocsp"),ko(o,a,Vh,"caIssuers"),ko(o,a,Lh,"timeStamping"),ko(o,a,qh,"caRepository"),super(Hl,e[1],L.serialize(o))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],L.parse(e.extnValue,Ii).forEach(n=>{switch(n.accessMethod){case Uh:this.ocsp.push(new pn(n.accessLocation));break;case Vh:this.caIssuers.push(new pn(n.accessLocation));break;case Lh:this.timeStamping.push(new pn(n.accessLocation));break;case qh:this.caRepository.push(new pn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&wo(e,"OCSP",this.ocsp),this.caIssuers.length&&wo(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&wo(e,"Time Stamping",this.timeStamping),this.caRepository.length&&wo(e,"CA Repository",this.caRepository),e}}E0.NAME="Authority Info Access";function wo(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new Me("");t.forEach((i,s)=>{const a=i.toTextObject(),o=`${a[Me.NAME]} ${s+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function ko(r,e,t,n){const i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new pn("url",a)),r.push(new to({accessMethod:t,accessLocation:L.parse(a.rawData,be)}))})}class vs extends Bn{constructor(...e){let t;if(q.isBufferSource(e[0]))t=q.toArrayBuffer(e[0]);else{const n=e[0],i=Array.isArray(e[1])?e[1].map(s=>q.toArrayBuffer(s)):[];t=L.serialize(new Wr({type:n,values:i}))}super(t,Wr)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Me("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[Me.NAME]===vs.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}vs.NAME="Attribute";class I0 extends vs{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=new qc({printableString:e[0]});super(v0,[L.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],qc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Me.VALUE]=this.password,e}}I0.NAME="Challenge Password";class ih extends vs{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=e[0],i=new kn;for(const s of n)i.push(L.parse(s.rawData,Wt));super(eh,[L.serialize(i)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],kn);this.items=t.map(n=>Jt.create(L.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[Me.NAME]]=n;return e}}ih.NAME="Extensions";class Wu{static register(e,t){this.items.set(e,t)}static create(e){const t=new vs(e),n=this.items.get(t.type);return n?new n(e):t}}Wu.items=new Map;const yo="crypto.signatureFormatter";class z1{toAsnSignature(e,t){return q.toArrayBuffer(t)}toWebSignature(e,t){return q.toArrayBuffer(t)}}var Po;let Jd=Po=class{static createPssParams(e,t){const n=Po.getHashAlgorithm(e);return n?new fi({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:Zu,parameters:L.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=pt.resolve(hi);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new Y({algorithm:Bc,parameters:null});case"sha-256":return new Y({algorithm:Ed,parameters:null});case"sha-384":return new Y({algorithm:Rc,parameters:null});case"sha-512":return new Y({algorithm:Pc,parameters:null})}}else return new Y({algorithm:li,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=Po.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new Y({algorithm:Us,parameters:L.serialize(t)})}else return new Y({algorithm:Us,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case li:return{name:"RSASSA-PKCS1-v1_5"};case Bc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Ed:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Rc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Pc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Us:if(e.parameters){const t=L.parse(e.parameters,fi);return{name:"RSA-PSS",hash:pt.resolve(hi).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Jd=Po=l([Lu()],Jd);pt.registerSingleton(po,Jd);let Yd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:$c});case"sha-256":return new Y({algorithm:Dc});case"sha-384":return new Y({algorithm:Zc});case"sha-512":return new Y({algorithm:Mc})}return null}toWebAlgorithm(e){switch(e.algorithm){case $c:return{name:"SHA-1"};case Dc:return{name:"SHA-256"};case Zc:return{name:"SHA-384"};case Mc:return{name:"SHA-512"}}return null}};Yd=l([Lu()],Yd);pt.registerSingleton(po,Yd);class Ft{addPadding(e,t){const n=q.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=q.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(t&&n[0]>127){const i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,i=Ft.namedCurveSize.get(n)||Ft.defaultNamedCurveSize,s=new Nc,a=q.toUint8Array(t);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),L.serialize(s)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=L.parse(t,Nc),i=e.namedCurve,s=Ft.namedCurveSize.get(i)||Ft.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(n.r)),o=this.addPadding(s,this.removePadding(n.s));return ow(a,o)}return null}}Ft.namedCurveSize=new Map;Ft.defaultNamedCurveSize=32;const hl="1.3.101.110",im="1.3.101.111",pl="1.3.101.112",sm="1.3.101.113";let Xd=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=pl;break;case"x25519":t=hl;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=pl;break;case"ed448":t=sm;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=hl;break;case"x448":t=im;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case pl:return{name:"Ed25519"};case sm:return{name:"EdDSA",namedCurve:"Ed448"};case hl:return{name:"X25519"};case im:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Xd=l([Lu()],Xd);pt.registerSingleton(po,Xd);class G1 extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,Aa):super(e),this.tag=$t.CertificateRequestTag}onInit(e){this.tbs=L.serialize(e.certificationRequestInfo),this.publicKey=new ur(e.certificationRequestInfo.subjectPKInfo);const t=pt.resolve(hi);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Wu.create(L.serialize(i)));const n=this.getAttribute(eh);this.extensions=[],n instanceof ih&&(this.extensions=n.items),this.subjectName=new Ht(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=ut.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),i=pt.resolveAll(yo).reverse();let s=null;for(const o of i)if(s=o.toWebSignature(t,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,Aa),n=t.certificationRequestInfo,i=new Me("",{Version:`${oi[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new Me("");for(const a of this.attributes){const o=a.toTextObject();s[o[Me.NAME]]=o}i.Attributes=s}return e.Data=i,e.Signature=new Me("",{Algorithm:pi.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}G1.NAME="PKCS#10 Certificate Request";class sh extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,ci):super(e),this.tag=$t.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=L.serialize(t),this.serialNumber=te.ToHex(t.serialNumber),this.subjectName=new Ht(t.subject),this.subject=new Ht(t.subject).toString(),this.issuerName=new Ht(t.issuer),this.issuer=this.issuerName.toString();const n=pt.resolve(hi);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(a=>Jt.create(L.serialize(a)))),this.publicKey=new ur(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=ut.get()){let n,i;const s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],t);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],t);else if(s instanceof ur)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],t);else if(q.isBufferSource(s)){const u=new ur(s);n={...u.algorithm,...this.signatureAlgorithm},i=await u.export(n,["verify"],t)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const a=pt.resolveAll(yo).reverse();let o=null;for(const u of a)if(o=u.toWebSignature(n,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const c=await t.subtle.verify(this.signatureAlgorithm,i,o,this.tbs);if(e.signatureOnly)return c;{const f=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<f&&f<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=ut.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=ut.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,ci),n=t.tbsCertificate,i=new Me("",{Version:`${oi[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":pi.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Me("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const s=new Me("");for(const a of this.extensions){const o=a.toTextObject();s[o[Me.NAME]]=o}i.Extensions=s}return e.Data=i,e.Signature=new Me("",{Algorithm:pi.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}sh.NAME="Certificate";class J1{static async createSelfSigned(e,t=ut.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=ut.get()){var n;let i;e.publicKey instanceof ur?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?i=e.publicKey:i=await t.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?q.toUint8Array(te.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const a=e.notBefore||new Date,o=e.notAfter||new Date(a.getTime()+31536e6),c=new ci({tbsCertificate:new Ut({version:oi.v3,serialNumber:s,validity:new ro({notBefore:a,notAfter:o}),extensions:new kn(((n=e.extensions)===null||n===void 0?void 0:n.map(A=>L.parse(A.rawData,Wt)))||[]),subjectPublicKeyInfo:L.parse(i,sr)})});if(e.subject){const A=e.subject instanceof Ht?e.subject:new Ht(e.subject);c.tbsCertificate.subject=L.parse(A.toArrayBuffer(),et)}if(e.issuer){const A=e.issuer instanceof Ht?e.issuer:new Ht(e.issuer);c.tbsCertificate.issuer=L.parse(A.toArrayBuffer(),et)}const u={hash:"SHA-256"},f="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},m=pt.resolve(hi);c.tbsCertificate.signature=c.signatureAlgorithm=m.toAsnAlgorithm(f);const B=L.serialize(c.tbsCertificate),C="signingKey"in e?await t.subtle.sign(f,e.signingKey,B):e.signature,p=pt.resolveAll(yo).reverse();let g=null;for(const A of p)if(g=A.toAsnSignature(f,C),g)break;if(!g)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=g,new sh(L.serialize(c))}}var am;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(am||(am={}));Jt.register(Lg,th);Jt.register(Fg,rh);Jt.register(Kg,nh);Jt.register(Jg,mo);Jt.register(Fl,Ca);Jt.register(Gg,S0);Jt.register(Jl,O0);Jt.register(Hl,E0);Wu.register(v0,I0);Wu.register(eh,ih);pt.registerSingleton(yo,z1);pt.registerSingleton(yo,Ft);Ft.namedCurveSize.set("P-256",32);Ft.namedCurveSize.set("K-256",32);Ft.namedCurveSize.set("P-384",48);Ft.namedCurveSize.set("P-521",66);const om="0123456789abcdef";function Qd(r){const e=new Uint8Array(r);let t="";for(let n=0;n<e.length;n++){const i=e[n]>>4;t+=om[i];const s=e[n]&15;t+=om[s]}return t}class C0{constructor(e,t){ne(this,"alphabet");ne(this,"padding");ne(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",i=0,s=0;for(let o=0;o<e.length;o++)for(i=i<<8|e[o],s+=8;s>=5;)s-=5,n+=this.alphabet[i>>s&31];if(s>0&&(n+=this.alphabet[i<<5-s&31]),(t==null?void 0:t.includePadding)??!0){const o=(8-n.length%8)%8;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let a=0;a<i;a++){let o=0;const c=[];for(let f=0;f<8;f++){const m=e[a*8+f];if(m==="="){if(a+1!==i)throw new Error(`Invalid character: ${m}`);o+=1;continue}if(m===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const B=this.decodeMap.get(m)??null;if(B===null)throw new Error(`Invalid character: ${m}`);c.push(B)}if(o===8||o===7||o===5||o===2)throw new Error("Invalid padding");const u=(c[0]<<3)+(c[1]>>2);if(s.push(u),o<6){const f=((c[1]&3)<<6)+(c[2]<<1)+(c[3]>>4);s.push(f)}if(o<4){const f=((c[3]&255)<<4)+(c[4]>>1);s.push(f)}if(o<3){const f=((c[4]&1)<<7)+(c[5]<<2)+(c[6]>>3);s.push(f)}if(o<1){const f=((c[6]&7)<<5)+c[7];s.push(f)}}return Uint8Array.from(s)}}new C0("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new C0("0123456789ABCDEFGHIJKLMNOPQRSTUV");class j0{constructor(e,t){ne(this,"alphabet");ne(this,"padding");ne(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",i=0,s=0;for(let o=0;o<e.length;o++)for(i=i<<8|e[o],s+=8;s>=6;)s+=-6,n+=this.alphabet[i>>s&63];if(s>0&&(n+=this.alphabet[i<<6-s&63]),(t==null?void 0:t.includePadding)??!0){const o=(4-n.length%4)%4;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let a=0;a<i;a++){let o=0,c=0;for(let u=0;u<4;u++){const f=e[a*4+u];if(f==="="){if(a+1!==i)throw new Error(`Invalid character: ${f}`);o+=1;continue}if(f===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const m=this.decodeMap.get(f)??null;if(m===null)throw new Error(`Invalid character: ${f}`);c+=m<<6*(3-u)}s.push(c>>16&255),o<2&&s.push(c>>8&255),o<1&&s.push(c&255)}return Uint8Array.from(s)}}const Y1=new j0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),$o=new j0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class X1{constructor(e){ne(this,"hash");this.hash=e}async verify(e,t,n){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,t,n)}async sign(e,t){const n=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",n,t)}async generateKeyPair(e){const t=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),n=await crypto.subtle.exportKey("pkcs8",t.privateKey),i=await crypto.subtle.exportKey("spki",t.publicKey);return{privateKey:n,publicKey:i}}}async function T0(r){return await crypto.subtle.digest("SHA-256",r)}async function ef(r){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},t=await crypto.subtle.generateKey(e,!0,["sign","verify"]),n=dc(),i=Qd(new TextEncoder().encode(n)),s=await J1.createSelfSigned({serialNumber:i,name:r.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:t,extensions:[new th(!0,2,!0),new rh(["1.3.6.1.5.5.7.3.1"],!0),new nh(Fc.keyCertSign|Fc.cRLSign,!0),await mo.create(t.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",t.privateKey),o=s.toString("pem"),c=await ek(s),u=Qd(await s.getThumbprint()),f=Q1("PRIVATE",a);return{kid:s.serialNumber,cert:o,thumbprint:u,fingerprint:c,pkcs7:f}}function Q1(r,e){const t=Y1.encode(new Uint8Array(e));let n=`-----BEGIN ${r} KEY-----\r
122
122
  `,i=0;for(;i<t.length;)i+64<=t.length?n+=t.substr(i,64)+`\r
123
123
  `:n+=t.substr(i)+`\r
124
124
  `,i+=64;return n+=`-----END ${r} KEY-----\r
125
- `,n}async function Q1(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),s=new TextEncoder().encode(n);return Xd(await j0(s))}const ek=1e3*60*60*24,tk=new dt().openapi(ve({tags:["keys"],method:"get",path:"/signing",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.array(Rl)}},description:"List of keys"}}}),async r=>{const t=(await r.env.data.keys.list()).filter(n=>"cert"in n).map(n=>n);return r.json(t)}).openapi(ve({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({kid:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Rl}},description:"The requested key"}}}),async r=>{const{kid:e}=r.req.valid("param"),n=(await r.env.data.keys.list()).find(i=>i.kid===e);if(!n)throw new ye(404,{message:"Key not found"});return r.json(n)}).openapi(ve({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const e=await r.env.data.keys.list();for await(const n of e)await r.env.data.keys.update(n.kid,{revoked_at:new Date(Date.now()+ek).toISOString()});const t=await Qd({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ve({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({kid:y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const{kid:e}=r.req.valid("param");if(!await r.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new ye(404,{message:"Key not found"});const n=await Qd({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),rk=new dt().openapi(ve({tags:["users"],method:"get",path:"/",request:{query:y.object({email:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:y.array(lf)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),i=(await $y(r.env.data.users,e,t)).filter(s=>!s.linked_to);return r.json(i)}),nk=jn.extend({clients:y.array(Mn)}),ik=new dt().openapi(ve({tags:["clients"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([nk,y.array(Mn)])}},description:"List of clients"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i,sort:s,q:a}=r.req.valid("query"),c=(await r.env.data.applications.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a})).applications;return i?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ve({tags:["clients"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),i=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===t);if(!i)throw new ye(404);return r.json(i)}).openapi(ve({tags:["clients"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.applications.remove(e,t))throw new ye(404,{message:"Application not found"});return r.text("OK")}).openapi(ve({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(nc.shape).partial()}}},params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),i=r.req.valid("json");await r.env.data.applications.update(e,t,i);const s=await r.env.data.applications.get(e,t);if(!s)throw new ye(404,{message:"Application not found"});return r.json(s)}).openapi(ve({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(nc.shape)}}},headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:y.object(Mn.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||lc(),client_secret:t.client_secret||lc()},i=await r.env.data.applications.create(e,n);return r.json(i,{status:201})});var $e;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})($e||($e={}));var ef;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(ef||(ef={}));const J=$e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),on=r=>{switch(typeof r){case"undefined":return J.undefined;case"string":return J.string;case"number":return isNaN(r)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(r)?J.array:r===null?J.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?J.promise:typeof Map<"u"&&r instanceof Map?J.map:typeof Set<"u"&&r instanceof Set?J.set:typeof Date<"u"&&r instanceof Date?J.date:J.object;default:return J.unknown}},M=$e.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"]),sk=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Zt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Zt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Zt.create=r=>new Zt(r);const is=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===J.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,$e.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${$e.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${$e.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${$e.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:$e.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,$e.assertNever(r)}return{message:t}};let T0=is;function ak(r){T0=r}function Fc(){return T0}const Kc=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},ok=[];function K(r,e){const t=Fc(),n=Kc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===is?void 0:is].filter(i=>!!i)});r.common.issues.push(n)}class vt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return me;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return vt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return me;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Ci=r=>({status:"dirty",value:r}),kt=r=>({status:"valid",value:r}),tf=r=>r.status==="aborted",rf=r=>r.status==="dirty",ja=r=>r.status==="valid",Ta=r=>typeof Promise<"u"&&r instanceof Promise;function Wc(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function N0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ce;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ce||(ce={}));var Ns,Bs;class Ir{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 om=(r,e)=>{if(ja(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Zt(r.common.issues);return this._error=t,this._error}}};function ke(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:i}}class Ie{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 on(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new vt,ctx:{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ta(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},s=this._parseSync({data:e,path:i.path,parent:i});return om(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Ta(i)?i:Promise.resolve(i));return om(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:M.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new hr({schema:this,typeName:he.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return kr.create(this,this._def)}nullable(){return Cn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lr.create(this,this._def)}promise(){return as.create(this,this._def)}or(e){return Pa.create([this,e],this._def)}and(e){return $a.create(this,e,this._def)}transform(e){return new hr({...ke(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Va({...ke(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new sh({typeName:he.ZodBranded,type:this,...ke(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new La({...ke(this._def),innerType:this,catchValue:t,typeName:he.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return go.create(this,e)}readonly(){return qa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ck=/^c[^\s-]{8,}$/i,uk=/^[0-9a-z]+$/,lk=/^[0-9A-HJKMNP-TV-Z]{26}$/,dk=/^[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,fk=/^[a-z0-9_-]{21}$/i,hk=/^[-+]?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)?)??$/,pk=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pl;const yk=/^(?:(?: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])$/,gk=/^(([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})))$/,vk=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,B0="((\\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])))",bk=new RegExp(`^${B0}$`);function R0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function xk(r){return new RegExp(`^${R0(r)}$`)}function P0(r){let e=`${B0}T${R0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function _k(r,e){return!!((e==="v4"||!e)&&yk.test(r)||(e==="v6"||!e)&&gk.test(r))}class ar extends Ie{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.string,received:s.parsedType}),me}const n=new vt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?K(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&K(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")pk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"email",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")pl||(pl=new RegExp(mk,"u")),pl.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"emoji",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")dk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"uuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")fk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"nanoid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")ck.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"cuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")uk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"cuid2",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")lk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"ulid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),K(i,{validation:"url",code:M.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"regex",code:M.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.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)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?P0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?bk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?xk(s).test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?hk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"duration",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?_k(e.data,s.version)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"ip",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?vk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"base64",code:M.invalid_string,message:s.message}),n.dirty()):$e.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new ar({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ce.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ce.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ce.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ce.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ce.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ce.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ce.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ce.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ce.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ce.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ce.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,...ce.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ce.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ce.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ce.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ce.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ce.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ce.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ce.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ce.errToObj(t)})}nonempty(e){return this.min(1,ce.errToObj(e))}trim(){return new ar({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ar({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ar({...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}}ar.create=r=>{var e;return new ar({checks:[],typeName:he.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ke(r)})};function wk(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class On extends Ie{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)!==J.number){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.number,received:s.parsedType}),me}let n;const i=new vt;for(const s of this._def.checks)s.kind==="int"?$e.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:M.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?wk(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_finite,message:s.message}),i.dirty()):$e.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,i){return new On({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(i)}]})}_addCheck(e){return new On({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ce.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ce.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ce.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ce.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"&&$e.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}On.create=r=>new On({checks:[],typeName:he.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ke(r)});class En extends Ie{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)!==J.bigint){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.bigint,received:s.parsedType}),me}let n;const i=new vt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):$e.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,i){return new En({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(i)}]})}_addCheck(e){return new En({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.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}}En.create=r=>{var e;return new En({checks:[],typeName:he.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ke(r)})};class Na extends Ie{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.boolean,received:n.parsedType}),me}return kt(e.data)}}Na.create=r=>new Na({typeName:he.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ke(r)});class mi extends Ie{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.date,received:s.parsedType}),me}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_date}),me}const n=new vt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):$e.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new mi({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ce.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ce.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}}mi.create=r=>new mi({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,...ke(r)});class zc extends Ie{_parse(e){if(this._getType(e)!==J.symbol){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.symbol,received:n.parsedType}),me}return kt(e.data)}}zc.create=r=>new zc({typeName:he.ZodSymbol,...ke(r)});class Ba extends Ie{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.undefined,received:n.parsedType}),me}return kt(e.data)}}Ba.create=r=>new Ba({typeName:he.ZodUndefined,...ke(r)});class Ra extends Ie{_parse(e){if(this._getType(e)!==J.null){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.null,received:n.parsedType}),me}return kt(e.data)}}Ra.create=r=>new Ra({typeName:he.ZodNull,...ke(r)});class ss extends Ie{constructor(){super(...arguments),this._any=!0}_parse(e){return kt(e.data)}}ss.create=r=>new ss({typeName:he.ZodAny,...ke(r)});class Xn extends Ie{constructor(){super(...arguments),this._unknown=!0}_parse(e){return kt(e.data)}}Xn.create=r=>new Xn({typeName:he.ZodUnknown,...ke(r)});class Yr extends Ie{_parse(e){const t=this._getOrReturnCtx(e);return K(t,{code:M.invalid_type,expected:J.never,received:t.parsedType}),me}}Yr.create=r=>new Yr({typeName:he.ZodNever,...ke(r)});class Gc extends Ie{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.void,received:n.parsedType}),me}return kt(e.data)}}Gc.create=r=>new Gc({typeName:he.ZodVoid,...ke(r)});class lr extends Ie{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==J.array)return K(t,{code:M.invalid_type,expected:J.array,received:t.parsedType}),me;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(K(t,{code:a?M.too_big:M.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(K(t,{code:M.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(K(t,{code:M.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Ir(t,a,t.path,o)))).then(a=>vt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Ir(t,a,t.path,o)));return vt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new lr({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new lr({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new lr({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}lr.create=(r,e)=>new lr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:he.ZodArray,...ke(e)});function Ai(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=kr.create(Ai(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof lr?new lr({...r._def,type:Ai(r.element)}):r instanceof kr?kr.create(Ai(r.unwrap())):r instanceof Cn?Cn.create(Ai(r.unwrap())):r instanceof Cr?Cr.create(r.items.map(e=>Ai(e))):r}class Ye extends Ie{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=$e.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const u=this._getOrReturnCtx(e);return K(u,{code:M.invalid_type,expected:J.object,received:u.parsedType}),me}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Yr&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],m=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Ir(i,m,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Yr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(K(i,{code:M.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Ir(i,m,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,B=await f.value;u.push({key:m,value:B,alwaysSet:f.alwaysSet})}return u}).then(u=>vt.mergeObjectSync(n,u)):vt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ce.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:he.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...this._def,catchall:e})}pick(e){const t={};return $e.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}omit(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return Ai(this)}partial(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof kr;)s=s._def.innerType;t[n]=s}}),new Ye({...this._def,shape:()=>t})}keyof(){return $0($e.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});class Pa extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Zt(o.ctx.common.issues));return K(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new Zt(c));return K(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Pa.create=(r,e)=>new Pa({options:r,typeName:he.ZodUnion,...ke(e)});const Rr=r=>r instanceof Za?Rr(r.schema):r instanceof hr?Rr(r.innerType()):r instanceof Ma?[r.value]:r instanceof In?r.options:r instanceof Ua?$e.objectValues(r.enum):r instanceof Va?Rr(r._def.innerType):r instanceof Ba?[void 0]:r instanceof Ra?[null]:r instanceof kr?[void 0,...Rr(r.unwrap())]:r instanceof Cn?[null,...Rr(r.unwrap())]:r instanceof sh||r instanceof qa?Rr(r.unwrap()):r instanceof La?Rr(r._def.innerType):[];class Wu extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return K(t,{code:M.invalid_type,expected:J.object,received:t.parsedType}),me;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(K(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=Rr(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new Wu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...ke(n)})}}function nf(r,e){const t=on(r),n=on(e);if(r===e)return{valid:!0,data:r};if(t===J.object&&n===J.object){const i=$e.objectKeys(e),s=$e.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=nf(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===J.array&&n===J.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=nf(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===J.date&&n===J.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class $a extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(tf(s)||tf(a))return me;const o=nf(s.value,a.value);return o.valid?((rf(s)||rf(a))&&t.dirty(),{status:t.value,value:o.data}):(K(n,{code:M.invalid_intersection_types}),me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}$a.create=(r,e,t)=>new $a({left:r,right:e,typeName:he.ZodIntersection,...ke(t)});class Cr extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return K(n,{code:M.invalid_type,expected:J.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return K(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(K(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Ir(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>vt.mergeArray(t,a)):vt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Cr({...this._def,rest:e})}}Cr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Cr({items:r,typeName:he.ZodTuple,rest:null,...ke(e)})};class Da extends Ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.object)return K(n,{code:M.invalid_type,expected:J.object,received:n.parsedType}),me;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Ir(n,o,n.path,o)),value:a._parse(new Ir(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?vt.mergeObjectAsync(t,i):vt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ie?new Da({keyType:e,valueType:t,typeName:he.ZodRecord,...ke(n)}):new Da({keyType:ar.create(),valueType:e,typeName:he.ZodRecord,...ke(t)})}}class Jc extends Ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.map)return K(n,{code:M.invalid_type,expected:J.map,received:n.parsedType}),me;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Ir(n,o,n.path,[u,"key"])),value:s._parse(new Ir(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Jc.create=(r,e,t)=>new Jc({valueType:e,keyType:r,typeName:he.ZodMap,...ke(t)});class yi extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return K(n,{code:M.invalid_type,expected:J.set,received:n.parsedType}),me;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(K(n,{code:M.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(K(n,{code:M.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return me;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Ir(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new yi({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new yi({...this._def,maxSize:{value:e,message:ce.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}yi.create=(r,e)=>new yi({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,...ke(e)});class Pi extends Ie{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return K(t,{code:M.invalid_type,expected:J.function,received:t.parsedType}),me;function n(o,c){return Kc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Fc(),is].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function i(o,c){return Kc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Fc(),is].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof as){const o=this;return kt(async function(...c){const u=new Zt([]),f=await o._def.args.parseAsync(c,s).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(C=>{throw u.addIssue(i(m,C)),u})})}else{const o=this;return kt(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new Zt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new Zt([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Pi({...this._def,args:Cr.create(e).rest(Xn.create())})}returns(e){return new Pi({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Pi({args:e||Cr.create([]).rest(Xn.create()),returns:t||Xn.create(),typeName:he.ZodFunction,...ke(n)})}}class Za extends Ie{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})}}Za.create=(r,e)=>new Za({getter:r,typeName:he.ZodLazy,...ke(e)});class Ma extends Ie{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return K(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ma.create=(r,e)=>new Ma({value:r,typeName:he.ZodLiteral,...ke(e)});function $0(r,e){return new In({values:r,typeName:he.ZodEnum,...ke(e)})}class In extends Ie{constructor(){super(...arguments),Ns.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{expected:$e.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(Wc(this,Ns)||N0(this,Ns,new Set(this._def.values)),!Wc(this,Ns).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{received:t.data,code:M.invalid_enum_value,options:n}),me}return kt(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 In.create(e,{...this._def,...t})}exclude(e,t=this._def){return In.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Ns=new WeakMap;In.create=$0;class Ua extends Ie{constructor(){super(...arguments),Bs.set(this,void 0)}_parse(e){const t=$e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const i=$e.objectValues(t);return K(n,{expected:$e.joinValues(i),received:n.parsedType,code:M.invalid_type}),me}if(Wc(this,Bs)||N0(this,Bs,new Set($e.getValidEnumValues(this._def.values))),!Wc(this,Bs).has(e.data)){const i=$e.objectValues(t);return K(n,{received:n.data,code:M.invalid_enum_value,options:i}),me}return kt(e.data)}get enum(){return this._def.values}}Bs=new WeakMap;Ua.create=(r,e)=>new Ua({values:r,typeName:he.ZodNativeEnum,...ke(e)});class as extends Ie{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return K(t,{code:M.invalid_type,expected:J.promise,received:t.parsedType}),me;const n=t.parsedType===J.promise?t.data:Promise.resolve(t.data);return kt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}as.create=(r,e)=>new as({type:r,typeName:he.ZodPromise,...ke(e)});class hr extends Ie{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===he.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{K(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return me;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?me:c.status==="dirty"||t.value==="dirty"?Ci(c.value):c});{if(t.value==="aborted")return me;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?me:o.status==="dirty"||t.value==="dirty"?Ci(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ja(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ja(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);$e.assertNever(i)}}hr.create=(r,e,t)=>new hr({schema:r,typeName:he.ZodEffects,effect:e,...ke(t)});hr.createWithPreprocess=(r,e,t)=>new hr({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,...ke(t)});class kr extends Ie{_parse(e){return this._getType(e)===J.undefined?kt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kr.create=(r,e)=>new kr({innerType:r,typeName:he.ZodOptional,...ke(e)});class Cn extends Ie{_parse(e){return this._getType(e)===J.null?kt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cn.create=(r,e)=>new Cn({innerType:r,typeName:he.ZodNullable,...ke(e)});class Va extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===J.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Va.create=(r,e)=>new Va({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ke(e)});class La extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ta(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}La.create=(r,e)=>new La({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ke(e)});class Yc extends Ie{_parse(e){if(this._getType(e)!==J.nan){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}Yc.create=r=>new Yc({typeName:he.ZodNaN,...ke(r)});const kk=Symbol("zod_brand");class sh extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class go extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),Ci(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?me:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new go({in:e,out:t,typeName:he.ZodPipeline})}}class qa extends Ie{_parse(e){const t=this._def.innerType._parse(e),n=i=>(ja(i)&&(i.value=Object.freeze(i.value)),i);return Ta(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}qa.create=(r,e)=>new qa({innerType:r,typeName:he.ZodReadonly,...ke(e)});function D0(r,e={},t){return r?ss.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):ss.create()}const Sk={object:Ye.lazycreate};var he;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(he||(he={}));const Ak=(r,e={message:`Input not instance of ${r.name}`})=>D0(t=>t instanceof r,e),Z0=ar.create,M0=On.create,Ok=Yc.create,Ek=En.create,U0=Na.create,Ik=mi.create,Ck=zc.create,jk=Ba.create,Tk=Ra.create,Nk=ss.create,Bk=Xn.create,Rk=Yr.create,Pk=Gc.create,$k=lr.create,Dk=Ye.create,Zk=Ye.strictCreate,Mk=Pa.create,Uk=Wu.create,Vk=$a.create,Lk=Cr.create,qk=Da.create,Hk=Jc.create,Fk=yi.create,Kk=Pi.create,Wk=Za.create,zk=Ma.create,Gk=In.create,Jk=Ua.create,Yk=as.create,cm=hr.create,Xk=kr.create,Qk=Cn.create,eS=hr.createWithPreprocess,tS=go.create,rS=()=>Z0().optional(),nS=()=>M0().optional(),iS=()=>U0().optional(),sS={string:r=>ar.create({...r,coerce:!0}),number:r=>On.create({...r,coerce:!0}),boolean:r=>Na.create({...r,coerce:!0}),bigint:r=>En.create({...r,coerce:!0}),date:r=>mi.create({...r,coerce:!0})},aS=me;var Lt=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:ak,getErrorMap:Fc,makeIssue:Kc,EMPTY_PATH:ok,addIssueToContext:K,ParseStatus:vt,INVALID:me,DIRTY:Ci,OK:kt,isAborted:tf,isDirty:rf,isValid:ja,isAsync:Ta,get util(){return $e},get objectUtil(){return ef},ZodParsedType:J,getParsedType:on,ZodType:Ie,datetimeRegex:P0,ZodString:ar,ZodNumber:On,ZodBigInt:En,ZodBoolean:Na,ZodDate:mi,ZodSymbol:zc,ZodUndefined:Ba,ZodNull:Ra,ZodAny:ss,ZodUnknown:Xn,ZodNever:Yr,ZodVoid:Gc,ZodArray:lr,ZodObject:Ye,ZodUnion:Pa,ZodDiscriminatedUnion:Wu,ZodIntersection:$a,ZodTuple:Cr,ZodRecord:Da,ZodMap:Jc,ZodSet:yi,ZodFunction:Pi,ZodLazy:Za,ZodLiteral:Ma,ZodEnum:In,ZodNativeEnum:Ua,ZodPromise:as,ZodEffects:hr,ZodTransformer:hr,ZodOptional:kr,ZodNullable:Cn,ZodDefault:Va,ZodCatch:La,ZodNaN:Yc,BRAND:kk,ZodBranded:sh,ZodPipeline:go,ZodReadonly:qa,custom:D0,Schema:Ie,ZodSchema:Ie,late:Sk,get ZodFirstPartyTypeKind(){return he},coerce:sS,any:Nk,array:$k,bigint:Ek,boolean:U0,date:Ik,discriminatedUnion:Uk,effect:cm,enum:Gk,function:Kk,instanceof:Ak,intersection:Vk,lazy:Wk,literal:zk,map:Hk,nan:Ok,nativeEnum:Jk,never:Rk,null:Tk,nullable:Qk,number:M0,object:Dk,oboolean:iS,onumber:nS,optional:Xk,ostring:rS,pipeline:tS,preprocess:eS,promise:Yk,record:qk,set:Fk,strictObject:Zk,string:Z0,symbol:Ck,transformer:cm,tuple:Lk,undefined:jk,union:Mk,unknown:Bk,void:Pk,NEVER:aS,ZodIssueCode:M,quotelessJson:sk,ZodError:Zt});Lt.object({start:Lt.number(),limit:Lt.number(),length:Lt.number()});ru.extend({email:Lt.string(),login_count:Lt.number(),multifactor:Lt.array(Lt.string()).optional(),last_ip:Lt.string().optional(),last_login:Lt.string().optional(),user_id:Lt.string()}).catchall(Lt.any());const oS=jn.extend({tenants:y.array(Ni)}),cS=new dt().openapi(ve({tags:["tenants"],method:"get",path:"/",request:{query:ri},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:y.union([y.array(Ni),oS])}},description:"List of tenants"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),a=await r.env.data.tenants.list({page:e,per_page:t,include_totals:n,sort:cs(i),q:s});return n?r.json(a):r.json(a.tenants)}).openapi(ve({tags:["tenants"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Ni}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new ye(404);return r.json(t)}).openapi(ve({tags:["tenants"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param");return await r.env.data.tenants.remove(e),r.text("OK")}).openapi(ve({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(sc.shape).partial()}}},params:y.object({id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param"),t=r.req.valid("json");return await r.env.data.tenants.update(e,t),r.text("OK")}).openapi(ve({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(sc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Ni}},description:"An tenant"}}}),async r=>{const e=r.req.valid("json"),t=await r.env.data.tenants.create(e);return r.json(t,{status:201})}),uS=jn.extend({logs:y.array(oc)}),lS=new dt().openapi(ve({tags:["logs"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(oc),uS])}},description:"List of log rows"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header"),o=await r.env.data.logs.list(a,{page:e,per_page:t,include_totals:n,sort:cs(i),q:s});return n?r.json(o):r.json(o.logs)}).openapi(ve({tags:["logs"],method:"get",path:"/{id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:oc}},description:"A log entry"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.logs.get(e,t);if(!n)throw new ye(404);return r.json(n)}),dS=jn.extend({hooks:y.array(Ei)}),fS=new dt().openapi(ve({tags:["hooks"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(Ei),dS])}},description:"List of hooks"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i,sort:s,q:a}=r.req.valid("query"),o=await r.env.data.hooks.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a});return i?r.json(o):r.json(o.hooks)}).openapi(ve({tags:["hooks"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(ac.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Ei}},description:"The created hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.hooks.create(e,t);return r.json(n,{status:201})}).openapi(ve({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()}),body:{content:{"application/json":{schema:y.object(ac.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ei.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=r.req.valid("json");await r.env.data.hooks.update(e,t,n);const i=await r.env.data.hooks.get(e,t);if(!i)throw new ye(404,{message:"Hook not found"});return r.json(i)}).openapi(ve({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ei}},description:"A hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=await r.env.data.hooks.get(e,t);if(!n)throw new ye(404,{message:"Hook not found"});return r.json(n)}).openapi(ve({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param");if(!await r.env.data.hooks.remove(e,t))throw new ye(404,{message:"Hook not found"});return r.text("OK")}),hS=jn.extend({connections:y.array(Un)}),pS=new dt().openapi(ve({tags:["connections"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(Un),hS])}},description:"List of connectionss"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i=!1,sort:s,q:a}=r.req.valid("query"),o=await r.env.data.connections.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a});return i?r.json(o):r.json(o.connections)}).openapi(ve({tags:["connections"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Un}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.connections.get(e,t);if(!n)throw new ye(404);return r.json(n)}).openapi(ve({tags:["connections"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.connections.remove(e,t))throw new ye(404,{message:"Connection not found"});return r.text("OK")}).openapi(ve({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(ic.shape).partial()}}},params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Un}},description:"The updated connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=r.req.valid("json");if(!await r.env.data.connections.update(e,t,n))throw new ye(404,{message:"Connection not found"});const s=await r.env.data.connections.get(e,t);if(!s)throw new ye(404,{message:"Connection not found"});return r.json(s)}).openapi(ve({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(ic.shape)}}},headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Un}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.connections.create(e,t);return r.json(n,{status:201})}),mS=new dt().openapi(ve({tags:["prompts"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:jo}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.promptSettings.get(e);return t?r.json(t):r.json(jo.parse({}))}).openapi(ve({tags:["prompts"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(jo.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.promptSettings.get(e);return Object.assign(n,t),await r.env.data.promptSettings.set(e,n),r.json(n)});let um=!1;function V0(r){r.use(async(e,t)=>(um||(r.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"}}}}),um=!0),await t()))}y.object({alg:y.literal("RS256"),kty:y.literal("RSA"),use:y.literal("sig"),n:y.string(),e:y.string(),kid:y.string(),x5t:y.string(),x5c:y.array(y.string())});async function yS(r){try{const e=await r.JWKS_SERVICE.fetch(r.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new ye(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function gS(r,e){const n=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(c=>c.charCodeAt(0))),a=(await yS(r.env)).find(c=>c.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const o=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",o,i,n)}function vS(r){const[e,t,n]=r.split(".");if(!e||!t||!n)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(t)),a=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:a,raw:{header:e,payload:t,signature:n}}}function L0(r){return async(e,t)=>{var i,s;const n=r.openAPIRegistry.definitions.find(a=>"route"in a&&a.route.path===e.req.path&&a.route.method.toUpperCase()===e.req.method);if(n&&"route"in n){const a=(s=(i=n.route.security)==null?void 0:i[0])==null?void 0:s.Bearer,o=e.req.header("authorization")||"",[c,u]=o.split(" ");if((c==null?void 0:c.toLowerCase())!=="bearer"||!u)throw new ye(401,{message:"Missing bearer token"});const f=vS(u);if(!f||!await gS(e,f))throw new ye(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub);const m=f.payload.permissions||[];if(a!=null&&a.length&&!a.some(B=>m.includes(B)))throw new ye(403,{message:"Unauthorized"})}return await t()}}const bS=new dt().openapi(ve({tags:["emails"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:To}},description:"Email provider"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.emailProviders.get(e);if(!t)throw new ye(404,{message:"Email provider not found"});return r.json(t)}).openapi(ve({tags:["emails"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(To.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.create(e,t),r.text("OK",{status:201})}).openapi(ve({tags:["emails"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(To.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.update(e,t),r.text("OK")});function xS(){const r=new dt;r.use(L0(r));const e=r.route("/branding",R_).route("/email/providers",bS).route("/users",tw).route("/keys",tk).route("/users-by-email",rk).route("/clients",ik).route("/tenants",cS).route("/logs",lS).route("/hooks",fS).route("/connections",pS).route("/prompts",mS);return V0(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}const So=60*5,_S=30*24*60*60,wS="auth-token",kS=new dt().openapi(ve({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Sy}},description:"List of tenants"}}}),async r=>{const e=await r.env.data.keys.list(),t=await Promise.all(e.map(async n=>{const s=await new ih(n.cert).publicKey.export(),a=await crypto.subtle.exportKey("jwk",s);return pf.parse({...a,kid:n.kid})}));return r.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})}).openapi(ve({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Bl}},description:"List of tenants"}}}),async r=>{const e=r.env.ISSUER,t=Bl.parse({issuer:e,authorization_endpoint:`${e}authorize`,token_endpoint:`${e}oauth/token`,device_authorization_endpoint:`${e}oauth/device/code`,userinfo_endpoint:`${e}userinfo`,mfa_challenge_endpoint:`${e}mfa/challenge`,jwks_uri:`${e}.well-known/jwks.json`,registration_endpoint:`${e}oidc/register`,revocation_endpoint:`${e}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:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],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 r.json(t,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})});class Xc{constructor(e,t){ne(this,"value");ne(this,"unit");this.value=e,this.unit=t}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Xc(Math.round(this.milliseconds()*e),"ms")}}async function lm(r,e,t,n){const i={alg:r,typ:"JWT",...n==null?void 0:n.headers},s={...t};(n==null?void 0:n.audiences)!==void 0&&(s.aud=n.audiences),(n==null?void 0:n.subject)!==void 0&&(s.sub=n.subject),(n==null?void 0:n.issuer)!==void 0&&(s.iss=n.issuer),(n==null?void 0:n.jwtId)!==void 0&&(s.jti=n.jwtId),(n==null?void 0:n.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+n.expiresIn.seconds()),(n==null?void 0:n.notBefore)!==void 0&&(s.nbf=Math.floor(n.notBefore.getTime()/1e3)),(n==null?void 0:n.includeIssuedTimestamp)===!0&&(s.iat=Math.floor(Date.now()/1e3));const a=new TextEncoder,o=$o.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),c=$o.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),u=a.encode([o,c].join(".")),f=await SS(r).sign(e,u),m=$o.encode(new Uint8Array(f),{includePadding:!1});return[o,c,m].join(".")}function SS(r){return new Y1(AS[r])}const AS={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function OS(r){try{const t=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(r);if(!t||!t[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(t[1].replace(/\s/g,"")),n=>n.charCodeAt(0)).buffer}finally{r=r.replace(/./g,"\0")}}async function ES(r,e){if(e==="plain")return r;const t=new TextEncoder().encode(r),n=await j0(t);return $o.encode(new Uint8Array(n))}async function q0(r,e){var m;const{authParams:t,user:n,sid:i}=e,a=(await r.env.data.keys.list()).filter(B=>!B.revoked_at||new Date(B.revoked_at)>new Date),o=a[a.length-1];if(!(o!=null&&o.pkcs7))throw new ye(500,{message:"No signing key available"});const c=OS(o.pkcs7),u=await lm("RS256",c,{aud:t.audience||"default",scope:t.scope||"",sub:(n==null?void 0:n.user_id)||t.client_id,iss:r.env.ISSUER,tenant_id:r.var.tenant_id,sid:i},{includeIssuedTimestamp:!0,expiresIn:new Xc(1,"d"),headers:{kid:o.kid}}),f=n&&((m=t.scope)!=null&&m.split(" ").includes("openid"))?await lm("RS256",c,{aud:t.client_id,sub:n.user_id,iss:r.env.ISSUER,sid:i,nonce:t.nonce,given_name:n.given_name,family_name:n.family_name,nickname:n.nickname,picture:n.picture,locale:n.locale,name:n.name,email:n.email,email_verified:n.email_verified},{includeIssuedTimestamp:!0,expiresIn:new Xc(1,"d"),headers:{kid:o.kid}}):void 0;return{access_token:u,id_token:f,token_type:"Bearer",expires_in:86400}}function IS(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}const H0=y.object({grant_type:y.literal("client_credentials"),scope:y.string().optional(),client_secret:y.string(),client_id:y.string(),audience:y.string().optional()});async function CS(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new ye(403,{message:"Invalid client credentials"});if(t.client_secret&&!IS(t.client_secret,e.client_secret))throw new ye(403,{message:"Invalid client credentials"});const n={client_id:t.id,scope:e.scope,audience:e.audience},i=await q0(r,{authParams:n});return r.json(i)}function jS(r,e,t){const n=[];return n.push([encodeURIComponent(r),encodeURIComponent(e)]),(t==null?void 0:t.domain)!==void 0&&n.push(["Domain",t.domain]),(t==null?void 0:t.expires)!==void 0&&n.push(["Expires",t.expires.toUTCString()]),n.push(["HttpOnly"]),(t==null?void 0:t.maxAge)!==void 0&&n.push(["Max-Age",t.maxAge.toString()]),(t==null?void 0:t.path)!==void 0&&n.push(["Path",t.path]),n.push(["SameSite","None"]),n.push(["Secure"]),n.map(i=>i.join("=")).join("; ")}const TS=y.object({grant_type:y.literal("authorization_code"),client_id:y.string(),code:y.string(),redirect_uri:y.string(),client_secret:y.string().optional(),code_verifier:y.string().optional()}).refine(r=>"client_secret"in r&&!("code_verifier"in r)||!("client_secret"in r)&&"code_verifier"in r,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function NS(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new ye(403,{message:"Invalid client credentials"});const n=await r.env.data.codes.get(t.tenant.id,e.code,"authorization_code");if(!n||!n.user_id)throw new ye(403,{message:"Invalid client credentials"});if(new Date(n.expires_at)<new Date)throw new ye(403,{message:"Code expired"});const i=await r.env.data.logins.get(t.tenant.id,n.login_id);if(!i)throw new ye(403,{message:"Invalid login"});if("client_secret"in e){if(t.client_secret!==e.client_secret)throw new ye(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"&&await ES(e.code_verifier,i.authParams.code_challenge_method)!==i.authParams.code_challenge)throw new ye(403,{message:"Invalid client credentials"});if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new ye(403,{message:"Invalid redirect uri"});const s=await r.env.data.users.get(t.tenant.id,n.user_id);if(!s)throw new ye(403,{message:"User not found"});await r.env.data.codes.remove(t.tenant.id,e.code);const a=await r.env.data.sessions.create(t.tenant.id,{session_id:lc(),user_id:s.user_id,client_id:t.id,expires_at:new Date(Date.now()+_S*1e3).toISOString(),used_at:new Date().toISOString()}),o=await q0(r,{authParams:i.authParams,user:s,sid:a.session_id});return r.json(o,{headers:{"set-cookie":jS(`${t.tenant.id}-${wS}`,a.session_id,{path:"/",httpOnly:!0,secure:!0,maxAge:60*60*24*7,sameSite:"none"})}})}const dm=y.object({client_id:y.string().optional(),client_secret:y.string().optional()}),BS=y.union([H0.extend(dm.shape),y.object({grant_type:y.literal("authorization_code"),client_id:y.string(),code:y.string(),redirect_uri:y.string(),code_verifier:y.string().min(43).max(128)}),y.object({grant_type:y.literal("authorization_code"),code:y.string(),redirect_uri:y.string(),...dm.shape})]);function RS(r){if(!r)return{};const[e,t]=r.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&t){const[n,i]=atob(t).split(":");return{client_id:n,client_secret:i}}return{}}const PS=new dt().openapi(ve({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:BS}}}},responses:{200:{content:{"application/json":{schema:y.object({access_token:y.string(),id_token:y.string().optional(),refresh_token:y.string().optional(),token_type:y.string(),expires_in:y.number()})}},description:"Tokens"}}}),async r=>{const e=r.req.valid("form"),t=RS(r.req.header("Authorization")),n={...e,...t};if(!n.client_id)throw new ye(400,{message:"client_id is required"});switch(e.grant_type){case cc.AuthorizationCode:return NS(r,TS.parse(n));case cc.ClientCredential:return CS(r,H0.parse(n));default:throw new ye(400,{message:"Not implemented"})}});function $S(){const r=new dt;r.use(L0(r));const e=new dt().route("/.well-known",kS).route("/oauth/token",PS);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),V0(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}function DS(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await G_({userAdapter:r.users,tenant_id:e,email:t.email});return n?(await r.users.create(e,{...t,linked_to:n.user_id}),n):r.users.create(e,t)}}async function ZS(r,e,t){for await(const n of e)if(!(await fetch(n.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const s=Dy(r,{type:nu.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,s)}}function MS(r,e){return async(t,n)=>{const{hooks:i}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await ZS(r,i,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function US(r,e){return async(t,n)=>{let i=await DS(e)(t,n);return await MS(r,e)(t,i),i}}function VS(r,e){return{...e,users:{...e.users,create:US(r,e)}}}function LS(r){const e=new dt;e.use(async(i,s)=>(i.env.data=VS(i,r.dataAdapter),s())),e.get("/",i=>i.json({name:"authhero"}));const t=xS();e.route("/api/v2",t);const n=$S();return e.route("/",n),{app:e,managementApp:t,oauthApp:n,createX509Certificate:Qd}}exports.Auth0Client=Oy;exports.AuthorizationResponseMode=ff;exports.AuthorizationResponseType=df;exports.CodeChallengeMethod=hf;exports.GrantType=cc;exports.LogTypes=nu;exports.applicationInsertSchema=nc;exports.applicationSchema=Mn;exports.auth0UserResponseSchema=vr;exports.authParamsSchema=xy;exports.baseUserSchema=ru;exports.bordersSchema=Cy;exports.brandingSchema=Nl;exports.codeInsertSchema=wy;exports.codeSchema=E_;exports.codeTypeSchema=_y;exports.colorsSchema=jy;exports.connectionInsertSchema=ic;exports.connectionSchema=Un;exports.domainInsertSchema=ky;exports.domainSchema=I_;exports.emailProviderSchema=To;exports.fontDetailsSchema=Dn;exports.fontsSchema=Ty;exports.hookInsertSchema=ac;exports.hookSchema=Ei;exports.identitySchema=vy;exports.init=LS;exports.jwksKeySchema=Sy;exports.jwksSchema=pf;exports.logSchema=oc;exports.loginInsertSchema=Ay;exports.loginSchema=C_;exports.openIDConfigurationSchema=Bl;exports.pageBackgroundSchema=Ny;exports.parseUserId=B_;exports.passwordInsertSchema=Ey;exports.passwordSchema=T_;exports.profileDataSchema=gy;exports.promptSettingSchema=jo;exports.samlpAddon=by;exports.sessionInsertSchema=Iy;exports.sessionSchema=mf;exports.signingKeySchema=Rl;exports.tenantInsertSchema=sc;exports.tenantSchema=Ni;exports.themeInsertSchema=Ry;exports.themeSchema=N_;exports.totalsSchema=jn;exports.userInsertSchema=rc;exports.userResponseSchema=w_;exports.userSchema=lf;exports.vendorSettingsSchema=A_;exports.widgetSchema=By;
125
+ `,n}async function ek(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),s=new TextEncoder().encode(n);return Qd(await T0(s))}const tk=1e3*60*60*24,rk=new dt().openapi(ve({tags:["keys"],method:"get",path:"/signing",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.array(Pl)}},description:"List of keys"}}}),async r=>{const t=(await r.env.data.keys.list()).filter(n=>"cert"in n).map(n=>n);return r.json(t)}).openapi(ve({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({kid:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Pl}},description:"The requested key"}}}),async r=>{const{kid:e}=r.req.valid("param"),n=(await r.env.data.keys.list()).find(i=>i.kid===e);if(!n)throw new ye(404,{message:"Key not found"});return r.json(n)}).openapi(ve({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const e=await r.env.data.keys.list();for await(const n of e)await r.env.data.keys.update(n.kid,{revoked_at:new Date(Date.now()+tk).toISOString()});const t=await ef({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ve({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({kid:y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const{kid:e}=r.req.valid("param");if(!await r.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new ye(404,{message:"Key not found"});const n=await ef({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),nk=new dt().openapi(ve({tags:["users"],method:"get",path:"/",request:{query:y.object({email:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:y.array(df)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),i=(await Dy(r.env.data.users,e,t)).filter(s=>!s.linked_to);return r.json(i)}),ik=jn.extend({clients:y.array(Mn)}),sk=new dt().openapi(ve({tags:["clients"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([ik,y.array(Mn)])}},description:"List of clients"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i,sort:s,q:a}=r.req.valid("query"),c=(await r.env.data.applications.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a})).applications;return i?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ve({tags:["clients"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),i=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===t);if(!i)throw new ye(404);return r.json(i)}).openapi(ve({tags:["clients"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.applications.remove(e,t))throw new ye(404,{message:"Application not found"});return r.text("OK")}).openapi(ve({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(ic.shape).partial()}}},params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),i=r.req.valid("json");await r.env.data.applications.update(e,t,i);const s=await r.env.data.applications.get(e,t);if(!s)throw new ye(404,{message:"Application not found"});return r.json(s)}).openapi(ve({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(ic.shape)}}},headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:y.object(Mn.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||dc(),client_secret:t.client_secret||dc()},i=await r.env.data.applications.create(e,n);return r.json(i,{status:201})});var $e;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})($e||($e={}));var tf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(tf||(tf={}));const J=$e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),on=r=>{switch(typeof r){case"undefined":return J.undefined;case"string":return J.string;case"number":return isNaN(r)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(r)?J.array:r===null?J.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?J.promise:typeof Map<"u"&&r instanceof Map?J.map:typeof Set<"u"&&r instanceof Set?J.set:typeof Date<"u"&&r instanceof Date?J.date:J.object;default:return J.unknown}},M=$e.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"]),ak=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Zt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Zt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Zt.create=r=>new Zt(r);const is=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===J.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,$e.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${$e.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${$e.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${$e.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:$e.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,$e.assertNever(r)}return{message:t}};let N0=is;function ok(r){N0=r}function Kc(){return N0}const Wc=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},ck=[];function K(r,e){const t=Kc(),n=Wc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===is?void 0:is].filter(i=>!!i)});r.common.issues.push(n)}class vt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return me;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return vt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return me;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Ci=r=>({status:"dirty",value:r}),kt=r=>({status:"valid",value:r}),rf=r=>r.status==="aborted",nf=r=>r.status==="dirty",ja=r=>r.status==="valid",Ta=r=>typeof Promise<"u"&&r instanceof Promise;function zc(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function B0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ce;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ce||(ce={}));var Ns,Bs;class Ir{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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 cm=(r,e)=>{if(ja(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Zt(r.common.issues);return this._error=t,this._error}}};function ke(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:i}}class Ie{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 on(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new vt,ctx:{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ta(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},s=this._parseSync({data:e,path:i.path,parent:i});return cm(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Ta(i)?i:Promise.resolve(i));return cm(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:M.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new hr({schema:this,typeName:he.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return kr.create(this,this._def)}nullable(){return Cn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lr.create(this,this._def)}promise(){return as.create(this,this._def)}or(e){return Pa.create([this,e],this._def)}and(e){return $a.create(this,e,this._def)}transform(e){return new hr({...ke(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Va({...ke(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new ah({typeName:he.ZodBranded,type:this,...ke(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new La({...ke(this._def),innerType:this,catchValue:t,typeName:he.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return go.create(this,e)}readonly(){return qa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const uk=/^c[^\s-]{8,}$/i,lk=/^[0-9a-z]+$/,dk=/^[0-9A-HJKMNP-TV-Z]{26}$/,fk=/^[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,hk=/^[a-z0-9_-]{21}$/i,pk=/^[-+]?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)?)??$/,mk=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ml;const gk=/^(?:(?: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])$/,vk=/^(([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})))$/,bk=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,R0="((\\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])))",xk=new RegExp(`^${R0}$`);function P0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function _k(r){return new RegExp(`^${P0(r)}$`)}function $0(r){let e=`${R0}T${P0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function wk(r,e){return!!((e==="v4"||!e)&&gk.test(r)||(e==="v6"||!e)&&vk.test(r))}class ar extends Ie{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.string,received:s.parsedType}),me}const n=new vt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?K(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&K(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")mk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"email",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")ml||(ml=new RegExp(yk,"u")),ml.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"emoji",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")fk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"uuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")hk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"nanoid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")uk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"cuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")lk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"cuid2",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")dk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"ulid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),K(i,{validation:"url",code:M.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"regex",code:M.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.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)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?$0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?xk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?_k(s).test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?pk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"duration",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?wk(e.data,s.version)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"ip",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?bk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"base64",code:M.invalid_string,message:s.message}),n.dirty()):$e.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new ar({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ce.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ce.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ce.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ce.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ce.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ce.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ce.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ce.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ce.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ce.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ce.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,...ce.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ce.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ce.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ce.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ce.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ce.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ce.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ce.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ce.errToObj(t)})}nonempty(e){return this.min(1,ce.errToObj(e))}trim(){return new ar({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ar({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ar({...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}}ar.create=r=>{var e;return new ar({checks:[],typeName:he.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ke(r)})};function kk(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class On extends Ie{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)!==J.number){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.number,received:s.parsedType}),me}let n;const i=new vt;for(const s of this._def.checks)s.kind==="int"?$e.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:M.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?kk(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_finite,message:s.message}),i.dirty()):$e.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,i){return new On({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(i)}]})}_addCheck(e){return new On({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ce.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ce.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ce.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ce.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"&&$e.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}On.create=r=>new On({checks:[],typeName:he.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ke(r)});class En extends Ie{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)!==J.bigint){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.bigint,received:s.parsedType}),me}let n;const i=new vt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):$e.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,i){return new En({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(i)}]})}_addCheck(e){return new En({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.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}}En.create=r=>{var e;return new En({checks:[],typeName:he.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ke(r)})};class Na extends Ie{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.boolean,received:n.parsedType}),me}return kt(e.data)}}Na.create=r=>new Na({typeName:he.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ke(r)});class mi extends Ie{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.date,received:s.parsedType}),me}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_date}),me}const n=new vt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):$e.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new mi({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ce.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ce.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}}mi.create=r=>new mi({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,...ke(r)});class Gc extends Ie{_parse(e){if(this._getType(e)!==J.symbol){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.symbol,received:n.parsedType}),me}return kt(e.data)}}Gc.create=r=>new Gc({typeName:he.ZodSymbol,...ke(r)});class Ba extends Ie{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.undefined,received:n.parsedType}),me}return kt(e.data)}}Ba.create=r=>new Ba({typeName:he.ZodUndefined,...ke(r)});class Ra extends Ie{_parse(e){if(this._getType(e)!==J.null){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.null,received:n.parsedType}),me}return kt(e.data)}}Ra.create=r=>new Ra({typeName:he.ZodNull,...ke(r)});class ss extends Ie{constructor(){super(...arguments),this._any=!0}_parse(e){return kt(e.data)}}ss.create=r=>new ss({typeName:he.ZodAny,...ke(r)});class Xn extends Ie{constructor(){super(...arguments),this._unknown=!0}_parse(e){return kt(e.data)}}Xn.create=r=>new Xn({typeName:he.ZodUnknown,...ke(r)});class Yr extends Ie{_parse(e){const t=this._getOrReturnCtx(e);return K(t,{code:M.invalid_type,expected:J.never,received:t.parsedType}),me}}Yr.create=r=>new Yr({typeName:he.ZodNever,...ke(r)});class Jc extends Ie{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.void,received:n.parsedType}),me}return kt(e.data)}}Jc.create=r=>new Jc({typeName:he.ZodVoid,...ke(r)});class lr extends Ie{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==J.array)return K(t,{code:M.invalid_type,expected:J.array,received:t.parsedType}),me;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(K(t,{code:a?M.too_big:M.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(K(t,{code:M.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(K(t,{code:M.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Ir(t,a,t.path,o)))).then(a=>vt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Ir(t,a,t.path,o)));return vt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new lr({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new lr({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new lr({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}lr.create=(r,e)=>new lr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:he.ZodArray,...ke(e)});function Ai(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=kr.create(Ai(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof lr?new lr({...r._def,type:Ai(r.element)}):r instanceof kr?kr.create(Ai(r.unwrap())):r instanceof Cn?Cn.create(Ai(r.unwrap())):r instanceof Cr?Cr.create(r.items.map(e=>Ai(e))):r}class Ye extends Ie{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=$e.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const u=this._getOrReturnCtx(e);return K(u,{code:M.invalid_type,expected:J.object,received:u.parsedType}),me}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Yr&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],m=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Ir(i,m,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Yr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(K(i,{code:M.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Ir(i,m,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,B=await f.value;u.push({key:m,value:B,alwaysSet:f.alwaysSet})}return u}).then(u=>vt.mergeObjectSync(n,u)):vt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ce.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:he.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...this._def,catchall:e})}pick(e){const t={};return $e.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}omit(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return Ai(this)}partial(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof kr;)s=s._def.innerType;t[n]=s}}),new Ye({...this._def,shape:()=>t})}keyof(){return D0($e.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});class Pa extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Zt(o.ctx.common.issues));return K(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new Zt(c));return K(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Pa.create=(r,e)=>new Pa({options:r,typeName:he.ZodUnion,...ke(e)});const Rr=r=>r instanceof Za?Rr(r.schema):r instanceof hr?Rr(r.innerType()):r instanceof Ma?[r.value]:r instanceof In?r.options:r instanceof Ua?$e.objectValues(r.enum):r instanceof Va?Rr(r._def.innerType):r instanceof Ba?[void 0]:r instanceof Ra?[null]:r instanceof kr?[void 0,...Rr(r.unwrap())]:r instanceof Cn?[null,...Rr(r.unwrap())]:r instanceof ah||r instanceof qa?Rr(r.unwrap()):r instanceof La?Rr(r._def.innerType):[];class zu extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return K(t,{code:M.invalid_type,expected:J.object,received:t.parsedType}),me;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(K(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=Rr(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new zu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...ke(n)})}}function sf(r,e){const t=on(r),n=on(e);if(r===e)return{valid:!0,data:r};if(t===J.object&&n===J.object){const i=$e.objectKeys(e),s=$e.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=sf(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===J.array&&n===J.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=sf(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===J.date&&n===J.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class $a extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(rf(s)||rf(a))return me;const o=sf(s.value,a.value);return o.valid?((nf(s)||nf(a))&&t.dirty(),{status:t.value,value:o.data}):(K(n,{code:M.invalid_intersection_types}),me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}$a.create=(r,e,t)=>new $a({left:r,right:e,typeName:he.ZodIntersection,...ke(t)});class Cr extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return K(n,{code:M.invalid_type,expected:J.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return K(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(K(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Ir(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>vt.mergeArray(t,a)):vt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Cr({...this._def,rest:e})}}Cr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Cr({items:r,typeName:he.ZodTuple,rest:null,...ke(e)})};class Da extends Ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.object)return K(n,{code:M.invalid_type,expected:J.object,received:n.parsedType}),me;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Ir(n,o,n.path,o)),value:a._parse(new Ir(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?vt.mergeObjectAsync(t,i):vt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ie?new Da({keyType:e,valueType:t,typeName:he.ZodRecord,...ke(n)}):new Da({keyType:ar.create(),valueType:e,typeName:he.ZodRecord,...ke(t)})}}class Yc extends Ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.map)return K(n,{code:M.invalid_type,expected:J.map,received:n.parsedType}),me;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Ir(n,o,n.path,[u,"key"])),value:s._parse(new Ir(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Yc.create=(r,e,t)=>new Yc({valueType:e,keyType:r,typeName:he.ZodMap,...ke(t)});class yi extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return K(n,{code:M.invalid_type,expected:J.set,received:n.parsedType}),me;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(K(n,{code:M.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(K(n,{code:M.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return me;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Ir(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new yi({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new yi({...this._def,maxSize:{value:e,message:ce.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}yi.create=(r,e)=>new yi({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,...ke(e)});class Pi extends Ie{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return K(t,{code:M.invalid_type,expected:J.function,received:t.parsedType}),me;function n(o,c){return Wc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Kc(),is].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function i(o,c){return Wc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Kc(),is].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof as){const o=this;return kt(async function(...c){const u=new Zt([]),f=await o._def.args.parseAsync(c,s).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(C=>{throw u.addIssue(i(m,C)),u})})}else{const o=this;return kt(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new Zt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new Zt([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Pi({...this._def,args:Cr.create(e).rest(Xn.create())})}returns(e){return new Pi({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Pi({args:e||Cr.create([]).rest(Xn.create()),returns:t||Xn.create(),typeName:he.ZodFunction,...ke(n)})}}class Za extends Ie{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})}}Za.create=(r,e)=>new Za({getter:r,typeName:he.ZodLazy,...ke(e)});class Ma extends Ie{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return K(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ma.create=(r,e)=>new Ma({value:r,typeName:he.ZodLiteral,...ke(e)});function D0(r,e){return new In({values:r,typeName:he.ZodEnum,...ke(e)})}class In extends Ie{constructor(){super(...arguments),Ns.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{expected:$e.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(zc(this,Ns)||B0(this,Ns,new Set(this._def.values)),!zc(this,Ns).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{received:t.data,code:M.invalid_enum_value,options:n}),me}return kt(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 In.create(e,{...this._def,...t})}exclude(e,t=this._def){return In.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Ns=new WeakMap;In.create=D0;class Ua extends Ie{constructor(){super(...arguments),Bs.set(this,void 0)}_parse(e){const t=$e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const i=$e.objectValues(t);return K(n,{expected:$e.joinValues(i),received:n.parsedType,code:M.invalid_type}),me}if(zc(this,Bs)||B0(this,Bs,new Set($e.getValidEnumValues(this._def.values))),!zc(this,Bs).has(e.data)){const i=$e.objectValues(t);return K(n,{received:n.data,code:M.invalid_enum_value,options:i}),me}return kt(e.data)}get enum(){return this._def.values}}Bs=new WeakMap;Ua.create=(r,e)=>new Ua({values:r,typeName:he.ZodNativeEnum,...ke(e)});class as extends Ie{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return K(t,{code:M.invalid_type,expected:J.promise,received:t.parsedType}),me;const n=t.parsedType===J.promise?t.data:Promise.resolve(t.data);return kt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}as.create=(r,e)=>new as({type:r,typeName:he.ZodPromise,...ke(e)});class hr extends Ie{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===he.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{K(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return me;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?me:c.status==="dirty"||t.value==="dirty"?Ci(c.value):c});{if(t.value==="aborted")return me;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?me:o.status==="dirty"||t.value==="dirty"?Ci(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ja(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ja(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);$e.assertNever(i)}}hr.create=(r,e,t)=>new hr({schema:r,typeName:he.ZodEffects,effect:e,...ke(t)});hr.createWithPreprocess=(r,e,t)=>new hr({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,...ke(t)});class kr extends Ie{_parse(e){return this._getType(e)===J.undefined?kt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kr.create=(r,e)=>new kr({innerType:r,typeName:he.ZodOptional,...ke(e)});class Cn extends Ie{_parse(e){return this._getType(e)===J.null?kt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cn.create=(r,e)=>new Cn({innerType:r,typeName:he.ZodNullable,...ke(e)});class Va extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===J.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Va.create=(r,e)=>new Va({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ke(e)});class La extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ta(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}La.create=(r,e)=>new La({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ke(e)});class Xc extends Ie{_parse(e){if(this._getType(e)!==J.nan){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}Xc.create=r=>new Xc({typeName:he.ZodNaN,...ke(r)});const Sk=Symbol("zod_brand");class ah extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class go extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),Ci(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?me:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new go({in:e,out:t,typeName:he.ZodPipeline})}}class qa extends Ie{_parse(e){const t=this._def.innerType._parse(e),n=i=>(ja(i)&&(i.value=Object.freeze(i.value)),i);return Ta(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}qa.create=(r,e)=>new qa({innerType:r,typeName:he.ZodReadonly,...ke(e)});function Z0(r,e={},t){return r?ss.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):ss.create()}const Ak={object:Ye.lazycreate};var he;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(he||(he={}));const Ok=(r,e={message:`Input not instance of ${r.name}`})=>Z0(t=>t instanceof r,e),M0=ar.create,U0=On.create,Ek=Xc.create,Ik=En.create,V0=Na.create,Ck=mi.create,jk=Gc.create,Tk=Ba.create,Nk=Ra.create,Bk=ss.create,Rk=Xn.create,Pk=Yr.create,$k=Jc.create,Dk=lr.create,Zk=Ye.create,Mk=Ye.strictCreate,Uk=Pa.create,Vk=zu.create,Lk=$a.create,qk=Cr.create,Hk=Da.create,Fk=Yc.create,Kk=yi.create,Wk=Pi.create,zk=Za.create,Gk=Ma.create,Jk=In.create,Yk=Ua.create,Xk=as.create,um=hr.create,Qk=kr.create,eS=Cn.create,tS=hr.createWithPreprocess,rS=go.create,nS=()=>M0().optional(),iS=()=>U0().optional(),sS=()=>V0().optional(),aS={string:r=>ar.create({...r,coerce:!0}),number:r=>On.create({...r,coerce:!0}),boolean:r=>Na.create({...r,coerce:!0}),bigint:r=>En.create({...r,coerce:!0}),date:r=>mi.create({...r,coerce:!0})},oS=me;var Lt=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:ok,getErrorMap:Kc,makeIssue:Wc,EMPTY_PATH:ck,addIssueToContext:K,ParseStatus:vt,INVALID:me,DIRTY:Ci,OK:kt,isAborted:rf,isDirty:nf,isValid:ja,isAsync:Ta,get util(){return $e},get objectUtil(){return tf},ZodParsedType:J,getParsedType:on,ZodType:Ie,datetimeRegex:$0,ZodString:ar,ZodNumber:On,ZodBigInt:En,ZodBoolean:Na,ZodDate:mi,ZodSymbol:Gc,ZodUndefined:Ba,ZodNull:Ra,ZodAny:ss,ZodUnknown:Xn,ZodNever:Yr,ZodVoid:Jc,ZodArray:lr,ZodObject:Ye,ZodUnion:Pa,ZodDiscriminatedUnion:zu,ZodIntersection:$a,ZodTuple:Cr,ZodRecord:Da,ZodMap:Yc,ZodSet:yi,ZodFunction:Pi,ZodLazy:Za,ZodLiteral:Ma,ZodEnum:In,ZodNativeEnum:Ua,ZodPromise:as,ZodEffects:hr,ZodTransformer:hr,ZodOptional:kr,ZodNullable:Cn,ZodDefault:Va,ZodCatch:La,ZodNaN:Xc,BRAND:Sk,ZodBranded:ah,ZodPipeline:go,ZodReadonly:qa,custom:Z0,Schema:Ie,ZodSchema:Ie,late:Ak,get ZodFirstPartyTypeKind(){return he},coerce:aS,any:Bk,array:Dk,bigint:Ik,boolean:V0,date:Ck,discriminatedUnion:Vk,effect:um,enum:Jk,function:Wk,instanceof:Ok,intersection:Lk,lazy:zk,literal:Gk,map:Fk,nan:Ek,nativeEnum:Yk,never:Pk,null:Nk,nullable:eS,number:U0,object:Zk,oboolean:sS,onumber:iS,optional:Qk,ostring:nS,pipeline:rS,preprocess:tS,promise:Xk,record:Hk,set:Kk,strictObject:Mk,string:M0,symbol:jk,transformer:um,tuple:qk,undefined:Tk,union:Uk,unknown:Rk,void:$k,NEVER:oS,ZodIssueCode:M,quotelessJson:ak,ZodError:Zt});Lt.object({start:Lt.number(),limit:Lt.number(),length:Lt.number()});nu.extend({email:Lt.string(),login_count:Lt.number(),multifactor:Lt.array(Lt.string()).optional(),last_ip:Lt.string().optional(),last_login:Lt.string().optional(),user_id:Lt.string()}).catchall(Lt.any());const cS=jn.extend({tenants:y.array(Ni)}),uS=new dt().openapi(ve({tags:["tenants"],method:"get",path:"/",request:{query:ri},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:y.union([y.array(Ni),cS])}},description:"List of tenants"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),a=await r.env.data.tenants.list({page:e,per_page:t,include_totals:n,sort:cs(i),q:s});return n?r.json(a):r.json(a.tenants)}).openapi(ve({tags:["tenants"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Ni}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new ye(404);return r.json(t)}).openapi(ve({tags:["tenants"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param");return await r.env.data.tenants.remove(e),r.text("OK")}).openapi(ve({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(ac.shape).partial()}}},params:y.object({id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param"),t=r.req.valid("json");return await r.env.data.tenants.update(e,t),r.text("OK")}).openapi(ve({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(ac.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Ni}},description:"An tenant"}}}),async r=>{const e=r.req.valid("json"),t=await r.env.data.tenants.create(e);return r.json(t,{status:201})}),lS=jn.extend({logs:y.array(cc)}),dS=new dt().openapi(ve({tags:["logs"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(cc),lS])}},description:"List of log rows"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header"),o=await r.env.data.logs.list(a,{page:e,per_page:t,include_totals:n,sort:cs(i),q:s});return n?r.json(o):r.json(o.logs)}).openapi(ve({tags:["logs"],method:"get",path:"/{id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:cc}},description:"A log entry"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.logs.get(e,t);if(!n)throw new ye(404);return r.json(n)}),fS=jn.extend({hooks:y.array(Ei)}),hS=new dt().openapi(ve({tags:["hooks"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(Ei),fS])}},description:"List of hooks"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i,sort:s,q:a}=r.req.valid("query"),o=await r.env.data.hooks.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a});return i?r.json(o):r.json(o.hooks)}).openapi(ve({tags:["hooks"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(oc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Ei}},description:"The created hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.hooks.create(e,t);return r.json(n,{status:201})}).openapi(ve({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()}),body:{content:{"application/json":{schema:y.object(oc.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ei.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=r.req.valid("json");await r.env.data.hooks.update(e,t,n);const i=await r.env.data.hooks.get(e,t);if(!i)throw new ye(404,{message:"Hook not found"});return r.json(i)}).openapi(ve({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ei}},description:"A hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=await r.env.data.hooks.get(e,t);if(!n)throw new ye(404,{message:"Hook not found"});return r.json(n)}).openapi(ve({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param");if(!await r.env.data.hooks.remove(e,t))throw new ye(404,{message:"Hook not found"});return r.text("OK")}),pS=jn.extend({connections:y.array(Un)}),mS=new dt().openapi(ve({tags:["connections"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(Un),pS])}},description:"List of connectionss"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i=!1,sort:s,q:a}=r.req.valid("query"),o=await r.env.data.connections.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a});return i?r.json(o):r.json(o.connections)}).openapi(ve({tags:["connections"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Un}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.connections.get(e,t);if(!n)throw new ye(404);return r.json(n)}).openapi(ve({tags:["connections"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.connections.remove(e,t))throw new ye(404,{message:"Connection not found"});return r.text("OK")}).openapi(ve({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(sc.shape).partial()}}},params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Un}},description:"The updated connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=r.req.valid("json");if(!await r.env.data.connections.update(e,t,n))throw new ye(404,{message:"Connection not found"});const s=await r.env.data.connections.get(e,t);if(!s)throw new ye(404,{message:"Connection not found"});return r.json(s)}).openapi(ve({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(sc.shape)}}},headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Un}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.connections.create(e,t);return r.json(n,{status:201})}),yS=new dt().openapi(ve({tags:["prompts"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:jo}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.promptSettings.get(e);return t?r.json(t):r.json(jo.parse({}))}).openapi(ve({tags:["prompts"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(jo.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.promptSettings.get(e);return Object.assign(n,t),await r.env.data.promptSettings.set(e,n),r.json(n)});let lm=!1;function L0(r){r.use(async(e,t)=>(lm||(r.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"}}}}),lm=!0),await t()))}y.object({alg:y.literal("RS256"),kty:y.literal("RSA"),use:y.literal("sig"),n:y.string(),e:y.string(),kid:y.string(),x5t:y.string(),x5c:y.array(y.string())});async function gS(r){try{const e=await r.JWKS_SERVICE.fetch(r.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new ye(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function vS(r,e){const n=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(c=>c.charCodeAt(0))),a=(await gS(r.env)).find(c=>c.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const o=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",o,i,n)}function bS(r){const[e,t,n]=r.split(".");if(!e||!t||!n)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(t)),a=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:a,raw:{header:e,payload:t,signature:n}}}function q0(r){return async(e,t)=>{var i,s;const n=r.openAPIRegistry.definitions.find(a=>"route"in a&&a.route.path===e.req.path&&a.route.method.toUpperCase()===e.req.method);if(n&&"route"in n){const a=(s=(i=n.route.security)==null?void 0:i[0])==null?void 0:s.Bearer,o=e.req.header("authorization")||"",[c,u]=o.split(" ");if((c==null?void 0:c.toLowerCase())!=="bearer"||!u)throw new ye(401,{message:"Missing bearer token"});const f=bS(u);if(!f||!await vS(e,f))throw new ye(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub);const m=f.payload.permissions||[];if(a!=null&&a.length&&!a.some(B=>m.includes(B)))throw new ye(403,{message:"Unauthorized"})}return await t()}}const xS=new dt().openapi(ve({tags:["emails"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:To}},description:"Email provider"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.emailProviders.get(e);if(!t)throw new ye(404,{message:"Email provider not found"});return r.json(t)}).openapi(ve({tags:["emails"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(To.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.create(e,t),r.text("OK",{status:201})}).openapi(ve({tags:["emails"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(To.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.update(e,t),r.text("OK")});function _S(){const r=new dt;r.use(q0(r));const e=r.route("/branding",P_).route("/email/providers",xS).route("/users",rw).route("/keys",rk).route("/users-by-email",nk).route("/clients",sk).route("/tenants",uS).route("/logs",dS).route("/hooks",hS).route("/connections",mS).route("/prompts",yS);return L0(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}const So=60*5,wS=30*24*60*60,kS="auth-token",SS=new dt().openapi(ve({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Ay}},description:"List of tenants"}}}),async r=>{const e=await r.env.data.keys.list(),t=await Promise.all(e.map(async n=>{const s=await new sh(n.cert).publicKey.export(),a=await crypto.subtle.exportKey("jwk",s);return mf.parse({...a,kid:n.kid})}));return r.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})}).openapi(ve({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Rl}},description:"List of tenants"}}}),async r=>{const e=r.env.ISSUER,t=Rl.parse({issuer:e,authorization_endpoint:`${e}authorize`,token_endpoint:`${e}oauth/token`,device_authorization_endpoint:`${e}oauth/device/code`,userinfo_endpoint:`${e}userinfo`,mfa_challenge_endpoint:`${e}mfa/challenge`,jwks_uri:`${e}.well-known/jwks.json`,registration_endpoint:`${e}oidc/register`,revocation_endpoint:`${e}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:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],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 r.json(t,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})});class Qc{constructor(e,t){ne(this,"value");ne(this,"unit");this.value=e,this.unit=t}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Qc(Math.round(this.milliseconds()*e),"ms")}}async function dm(r,e,t,n){const i={alg:r,typ:"JWT",...n==null?void 0:n.headers},s={...t};(n==null?void 0:n.audiences)!==void 0&&(s.aud=n.audiences),(n==null?void 0:n.subject)!==void 0&&(s.sub=n.subject),(n==null?void 0:n.issuer)!==void 0&&(s.iss=n.issuer),(n==null?void 0:n.jwtId)!==void 0&&(s.jti=n.jwtId),(n==null?void 0:n.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+n.expiresIn.seconds()),(n==null?void 0:n.notBefore)!==void 0&&(s.nbf=Math.floor(n.notBefore.getTime()/1e3)),(n==null?void 0:n.includeIssuedTimestamp)===!0&&(s.iat=Math.floor(Date.now()/1e3));const a=new TextEncoder,o=$o.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),c=$o.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),u=a.encode([o,c].join(".")),f=await AS(r).sign(e,u),m=$o.encode(new Uint8Array(f),{includePadding:!1});return[o,c,m].join(".")}function AS(r){return new X1(OS[r])}const OS={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function ES(r){try{const t=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(r);if(!t||!t[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(t[1].replace(/\s/g,"")),n=>n.charCodeAt(0)).buffer}finally{r=r.replace(/./g,"\0")}}async function IS(r,e){if(e==="plain")return r;const t=new TextEncoder().encode(r),n=await T0(t);return $o.encode(new Uint8Array(n))}async function H0(r,e){var m;const{authParams:t,user:n,sid:i}=e,a=(await r.env.data.keys.list()).filter(B=>!B.revoked_at||new Date(B.revoked_at)>new Date),o=a[a.length-1];if(!(o!=null&&o.pkcs7))throw new ye(500,{message:"No signing key available"});const c=ES(o.pkcs7),u=await dm("RS256",c,{aud:t.audience||"default",scope:t.scope||"",sub:(n==null?void 0:n.user_id)||t.client_id,iss:r.env.ISSUER,tenant_id:r.var.tenant_id,sid:i},{includeIssuedTimestamp:!0,expiresIn:new Qc(1,"d"),headers:{kid:o.kid}}),f=n&&((m=t.scope)!=null&&m.split(" ").includes("openid"))?await dm("RS256",c,{aud:t.client_id,sub:n.user_id,iss:r.env.ISSUER,sid:i,nonce:t.nonce,given_name:n.given_name,family_name:n.family_name,nickname:n.nickname,picture:n.picture,locale:n.locale,name:n.name,email:n.email,email_verified:n.email_verified},{includeIssuedTimestamp:!0,expiresIn:new Qc(1,"d"),headers:{kid:o.kid}}):void 0;return{access_token:u,id_token:f,token_type:"Bearer",expires_in:86400}}function Do(r,e){if(!r||!e||r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}const F0=y.object({grant_type:y.literal("client_credentials"),scope:y.string().optional(),client_secret:y.string(),client_id:y.string(),audience:y.string().optional()});async function CS(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new ye(403,{message:"Invalid client credentials"});if(t.client_secret&&!Do(t.client_secret,e.client_secret))throw new ye(403,{message:"Invalid client credentials"});const n={client_id:t.id,scope:e.scope,audience:e.audience},i=await H0(r,{authParams:n});return r.json(i)}function jS(r,e,t){const n=[];return n.push([encodeURIComponent(r),encodeURIComponent(e)]),(t==null?void 0:t.domain)!==void 0&&n.push(["Domain",t.domain]),(t==null?void 0:t.expires)!==void 0&&n.push(["Expires",t.expires.toUTCString()]),n.push(["HttpOnly"]),(t==null?void 0:t.maxAge)!==void 0&&n.push(["Max-Age",t.maxAge.toString()]),(t==null?void 0:t.path)!==void 0&&n.push(["Path",t.path]),n.push(["SameSite","None"]),n.push(["Secure"]),n.map(i=>i.join("=")).join("; ")}const TS=y.object({grant_type:y.literal("authorization_code"),client_id:y.string(),code:y.string(),redirect_uri:y.string().optional(),client_secret:y.string().optional(),code_verifier:y.string().optional()}).refine(r=>"client_secret"in r&&!("code_verifier"in r)||!("client_secret"in r)&&"code_verifier"in r,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function NS(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new ye(403,{message:"Invalid client"});const n=await r.env.data.codes.get(t.tenant.id,e.code,"authorization_code");if(!n||!n.user_id)throw new ye(403,{message:"Invalid client credentials"});if(new Date(n.expires_at)<new Date)throw new ye(403,{message:"Code expired"});const i=await r.env.data.logins.get(t.tenant.id,n.login_id);if(!i)throw new ye(403,{message:"Invalid login"});if("client_secret"in e){const c=await r.env.data.clients.get("DEFAULT_CLIENT");if(console.log("defaultClient",JSON.stringify(c)),!Do(t.client_secret,e.client_secret)&&!Do(c==null?void 0:c.client_secret,e.client_secret))throw new ye(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"){const c=await IS(e.code_verifier,i.authParams.code_challenge_method);if(!Do(c,i.authParams.code_challenge||""))throw new ye(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new ye(403,{message:"Invalid redirect uri"});const s=await r.env.data.users.get(t.tenant.id,n.user_id);if(!s)throw new ye(403,{message:"User not found"});await r.env.data.codes.remove(t.tenant.id,e.code);const a=await r.env.data.sessions.create(t.tenant.id,{session_id:dc(),user_id:s.user_id,client_id:t.id,expires_at:new Date(Date.now()+wS*1e3).toISOString(),used_at:new Date().toISOString()}),o=await H0(r,{authParams:i.authParams,user:s,sid:a.session_id});return r.json(o,{headers:{"set-cookie":jS(`${t.tenant.id}-${kS}`,a.session_id,{path:"/",httpOnly:!0,secure:!0,maxAge:60*60*24*7,sameSite:"none"})}})}const fm=y.object({client_id:y.string().optional(),client_secret:y.string().optional()}),BS=y.union([F0.extend(fm.shape),y.object({grant_type:y.literal("authorization_code"),client_id:y.string(),code:y.string(),redirect_uri:y.string(),code_verifier:y.string().min(43).max(128)}),y.object({grant_type:y.literal("authorization_code"),code:y.string(),redirect_uri:y.string().optional(),...fm.shape})]);function RS(r){if(!r)return{};const[e,t]=r.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&t){const[n,i]=atob(t).split(":");return{client_id:n,client_secret:i}}return{}}const PS=new dt().openapi(ve({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:BS}}}},responses:{200:{content:{"application/json":{schema:y.object({access_token:y.string(),id_token:y.string().optional(),refresh_token:y.string().optional(),token_type:y.string(),expires_in:y.number()})}},description:"Tokens"}}}),async r=>{const e=r.req.valid("form"),t=RS(r.req.header("Authorization")),n={...e,...t};if(!n.client_id)throw new ye(400,{message:"client_id is required"});switch(e.grant_type){case uc.AuthorizationCode:return NS(r,TS.parse(n));case uc.ClientCredential:return CS(r,F0.parse(n));default:throw new ye(400,{message:"Not implemented"})}});function $S(){const r=new dt;r.use(q0(r));const e=new dt().route("/.well-known",SS).route("/oauth/token",PS);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),L0(e),e}function DS(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await J_({userAdapter:r.users,tenant_id:e,email:t.email});return n?(await r.users.create(e,{...t,linked_to:n.user_id}),n):r.users.create(e,t)}}async function ZS(r,e,t){for await(const n of e)if(!(await fetch(n.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const s=Zy(r,{type:iu.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,s)}}function MS(r,e){return async(t,n)=>{const{hooks:i}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await ZS(r,i,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function US(r,e){return async(t,n)=>{let i=await DS(e)(t,n);return await MS(r,e)(t,i),i}}function VS(r,e){return{...e,users:{...e.users,create:US(r,e)}}}function LS(r){const e=new dt;e.use(async(i,s)=>(i.env.data=VS(i,r.dataAdapter),s())),e.get("/",i=>i.json({name:"authhero"}));const t=_S();e.route("/api/v2",t);const n=$S();return e.route("/",n),{app:e,managementApp:t,oauthApp:n,createX509Certificate:ef}}exports.Auth0Client=Ey;exports.AuthorizationResponseMode=hf;exports.AuthorizationResponseType=ff;exports.CodeChallengeMethod=pf;exports.GrantType=uc;exports.LogTypes=iu;exports.applicationInsertSchema=ic;exports.applicationSchema=Mn;exports.auth0UserResponseSchema=vr;exports.authParamsSchema=_y;exports.baseUserSchema=nu;exports.bordersSchema=jy;exports.brandingSchema=Bl;exports.codeInsertSchema=ky;exports.codeSchema=I_;exports.codeTypeSchema=wy;exports.colorsSchema=Ty;exports.connectionInsertSchema=sc;exports.connectionSchema=Un;exports.domainInsertSchema=Sy;exports.domainSchema=C_;exports.emailProviderSchema=To;exports.fontDetailsSchema=Dn;exports.fontsSchema=Ny;exports.hookInsertSchema=oc;exports.hookSchema=Ei;exports.identitySchema=by;exports.init=LS;exports.jwksKeySchema=Ay;exports.jwksSchema=mf;exports.logSchema=cc;exports.loginInsertSchema=Oy;exports.loginSchema=j_;exports.openIDConfigurationSchema=Rl;exports.pageBackgroundSchema=By;exports.parseUserId=R_;exports.passwordInsertSchema=Iy;exports.passwordSchema=N_;exports.profileDataSchema=vy;exports.promptSettingSchema=jo;exports.samlpAddon=xy;exports.sessionInsertSchema=Cy;exports.sessionSchema=yf;exports.signingKeySchema=Pl;exports.tenantInsertSchema=ac;exports.tenantSchema=Ni;exports.themeInsertSchema=Py;exports.themeSchema=B_;exports.totalsSchema=jn;exports.userInsertSchema=nc;exports.userResponseSchema=k_;exports.userSchema=df;exports.vendorSettingsSchema=O_;exports.widgetSchema=Ry;