authhero 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var authhero=function(He){"use strict";var pk=Object.defineProperty;var Pg=He=>{throw TypeError(He)};var mk=(He,Le,ie)=>Le in He?pk(He,Le,{enumerable:!0,configurable:!0,writable:!0,value:ie}):He[Le]=ie;var Q=(He,Le,ie)=>mk(He,typeof Le!="symbol"?Le+"":Le,ie),xf=(He,Le,ie)=>Le.has(He)||Pg("Cannot "+ie);var P=(He,Le,ie)=>(xf(He,Le,"read from private field"),ie?ie.call(He):Le.get(He)),We=(He,Le,ie)=>Le.has(He)?Pg("Cannot add the same private member more than once"):Le instanceof WeakSet?Le.add(He):Le.set(He,ie),Te=(He,Le,ie,ro)=>(xf(He,Le,"write to private field"),ro?ro.call(He,ie):Le.set(He,ie),ie),Ce=(He,Le,ie)=>(xf(He,Le,"access private method"),ie);var ni,cr,zr,$g,Zg,_f,An,_g,Ga,Ja,Kr,ts,Gr,Qe,et,Cr,Jr,Ya,si,ii,Xa,Qa,Nt,Kt,wg,ur,ot,Dg,Yr,On,ns,gu,vu,kg,ai,Mg,Vg,Sg,Xr,ss,Ag;function Le(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 s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}typeof SuppressedError=="function"&&SuppressedError;function ie(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ro(r){return"_def"in r}function oi(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function Gg(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const B=typeof s=="string"?i:s,j=B??{},{param:p}=j,g=Le(j,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof s=="string"?{refId:s}:void 0),S=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),R=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(S).length>0?{metadata:S}:void 0)}));if(ie(this,"ZodObject")){const T=this.extend;R.extend=function(...ve){var Ue,qe,$e,rt,gt,Mt;const E=T.apply(this,ve);return E._def.openapi={_internal:{extendedFrom:!((qe=(Ue=this._def.openapi)===null||Ue===void 0?void 0:Ue._internal)===null||qe===void 0)&&qe.refId?{refId:(rt=($e=this._def.openapi)===null||$e===void 0?void 0:$e._internal)===null||rt===void 0?void 0:rt.refId,schema:this}:(gt=this._def.openapi)===null||gt===void 0?void 0:gt._internal.extendedFrom},metadata:(Mt=E._def.openapi)===null||Mt===void 0?void 0:Mt.metadata},E}}return R},oi(r,"optional"),oi(r,"nullable"),oi(r,"default"),oi(r,"transform"),oi(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}function no(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=>no(r[n],e[n]))}class Jg{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(i=>no(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>no(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const i of this.buckets.values())e+=1,t+=i.length,i.length>1&&(n+=1);const s=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:s}}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,s]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(s??"");return t}}function ci(r){return r==null}function ui(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function Yg(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function is(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function Cf(r){return r.filter(e=>!ci(e))}const _u=no;function Xg(r){const e=new Jg;return r.forEach(t=>e.put(t)),[...e.values()]}function If(r){return typeof r=="string"}class Qg{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,s,i;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:(i=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&i!==void 0?i: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 so{constructor(e){this.message=e}}class li extends so{constructor(e,t){super(e),this.data=t}}class io extends so{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 di(r,e){try{return r()}catch(t){throw t instanceof io?new io(Object.assign(Object.assign({},t.data),e)):t}}class e0 extends so{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class Ge{static getMetadata(e){var t;const n=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:n._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:i},s==null?void 0:s.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 s=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:s._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign(Object.assign({},i==null?void 0:i.metadata),{param:Object.assign({description:a},(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return is(Yg(e,["param"]),ci)}static buildParameterMetadata(e){return is(e,ci)}static applySchemaMetadata(e,t){return is(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),ci)}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&&ie(e,t)?e:ie(e,"ZodOptional")||ie(e,"ZodNullable")||ie(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):ie(e,"ZodDefault")||ie(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):ie(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):ie(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return ie(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class t0{transform(e,t,n){var s,i;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(i=e._def.maxLength)===null||i===void 0?void 0:i.value})}}class r0{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class n0{transform(e,t,n,s,i){const a=[...e.options.values()],o=a.map(s);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,i)}}mapDiscriminator(e,t,n){if(e.some(i=>Ge.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=Ge.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(ie(c,"ZodEnum")||ie(c,"ZodNativeEnum")){Object.values(c.enum).filter(If).forEach(m=>{s[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`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class s0{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class i0{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!ie(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class a0{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function o0(r){const t=Object.keys(r).filter(i=>typeof r[r[i]]!="number").map(i=>r[i]),n=t.filter(i=>typeof i=="number").length,s=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:s}}class c0{transform(e,t){const{type:n,values:s}=o0(e._def.values);if(n==="mixed")throw new so("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:s})}}class u0{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class l0{transform(e,t,n,s){var i;const a=(i=Ge.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=ui(e._def.shape(),s);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,s));const u=a.schema;s(u);const f=this.requiredKeysOf(u),m=ui(u==null?void 0:u._def.shape(),s),B=Object.fromEntries(Object.entries(c).filter(([g,A])=>!_u(m[g],A))),j=o.filter(g=>!f.includes(g)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:B}),j.length>0?{required:j}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return ie(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!Ge.isOptionalSchema(n)).map(([t,n])=>t)}}class d0{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(ie(i,"ZodEnum")||ie(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter(If).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 f0{transform(e,t){var n,s,i;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)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(i=e.maxLength)!==null&&i!==void 0?i: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 h0{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:s}=e._def,i=s.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(i))}}class p0{transform(e,t,n){const i=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(i)}}flattenUnionTypes(e){return ie(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return ie(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class m0{constructor(e){this.versionSpecifics=e,this.objectTransformer=new l0,this.stringTransformer=new f0,this.numberTransformer=new u0,this.bigIntTransformer=new r0,this.literalTransformer=new a0,this.enumTransformer=new s0,this.nativeEnumTransformer=new c0,this.arrayTransformer=new t0,this.unionTransformer=new p0,this.discriminatedUnionTransformer=new n0,this.intersectionTransformer=new i0,this.recordTransformer=new d0,this.tupleTransformer=new h0(e)}transform(e,t,n,s,i){if(ie(e,"ZodNull"))return this.versionSpecifics.nullType;if(ie(e,"ZodUnknown")||ie(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(ie(e,"ZodObject"))return this.objectTransformer.transform(e,i,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,s);return Object.assign(Object.assign({},a),{default:i})}transformSchemaWithoutDefault(e,t,n,s){if(ie(e,"ZodUnknown")||ie(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(ie(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(ie(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(ie(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ie(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ie(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(ie(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(ie(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(ie(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ie(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=Ge.getRefId(e);throw new e0({currentSchema:e._def,schemaName:i})}}class jf{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new m0(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:s,name:i,component:a})=>{var o;(o=n[s])!==null&&o!==void 0||(n[s]={}),n[s][i]=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 s=e.findIndex(a=>a===t.type),i=e.findIndex(a=>a===n.type);return s-i})}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=Ge.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,s,i,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(i=e._internal)===null||i===void 0?void 0:i.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 li(`Conflicting location for parameter ${u.name}`,{key:"in",values:Cf([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 li("Conflicting names for parameter",{key:"name",values:Cf([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 s=Ge.getMetadata(e),i=(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(s,{in:t});if(a)return[a];if(ie(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,B;const j=Ge.getMetadata(f),p=this.getParameterRef(j,{in:t,name:u});if(p)return p;const g=(m=j==null?void 0:j.metadata)===null||m===void 0?void 0:m.param;if(g!=null&&g.name&&g.name!==u)throw new li("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new li(`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(i!=null&&i.in&&i.in!==t)throw new li(`Conflicting location for parameter ${i.name}`,{key:"in",values:[t,i.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=Ge.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!Ge.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?Ge.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=Ge.getMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=s==null?void 0:s.name,a=s==null?void 0:s.in;if(!i)throw new io({missingField:"name"});if(!a)throw new io({missingField:"in",paramName:i});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:i})}generateSchemaWithMetadata(e){var t;const n=Ge.unwrapChained(e),s=Ge.getMetadata(e),i=Ge.getDefaultValue(e),a=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),i);return s!=null&&s.metadata?Ge.applySchemaMetadata(a,s.metadata):is(a,ci)}constructReferencedOpenAPISchema(e){var t;const n=Ge.getMetadata(e),s=Ge.unwrapChained(e),i=Ge.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(s,a,i)}generateSimpleSchema(e){var t;const n=Ge.getMetadata(e),s=Ge.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=is(Ge.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||_u(f,i[m]));if(o.type)return{allOf:[a,o]};const c=is(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||_u(f,i[m])),u=Ge.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=Ge.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=Le(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),s=this.cleanParameter(e.params),i=this.cleanParameter(e.cookies),a=di(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=di(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=di(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=di(()=>{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 ie(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=Le(e,["method","path","request","responses"]),o=ui(i,m=>this.getResponse(m)),c=di(()=>this.getParameters(s),{route:`${t} ${n}`}),u=this.getRequestBody(s==null?void 0:s.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,s=Le(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=ie(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},s),{headers:a}),i)}getResponseHeaders(e){const t=e._def.shape();return ui(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return ui(e,t=>{if(!t||!ro(t.schema))return t;const{schema:n}=t,s=Le(t,["schema"]),i=this.generateSchemaWithRef(n);return Object.assign({schema:i},s)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),n)}}class y0{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=Xg(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 g0{constructor(e){const t=new y0;this.generator=new jf(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class v0{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 b0(r){return"type"in r&&r.type==="webhook"}class x0{constructor(e){this.definitions=e,this.webhookRefs={};const t=new v0;this.generator=new jf(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(b0).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 Tf=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},_0=r=>{const{groups:e,path:t}=w0(r),n=Tf(t);return k0(n,e)},w0=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},k0=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let s=r.length-1;s>=0;s--)if(r[s].includes(n)){r[s]=r[s].replace(n,e[t][1]);break}}return r},ao={},Nf=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(ao[r]||(e[2]?ao[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:ao[r]=[r,e[1],!0]),ao[r]):null},Bf=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},S0=r=>Bf(r,decodeURI),Rf=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const s=e.charCodeAt(n);if(s===37){const i=e.indexOf("?",n),a=e.slice(t,i===-1?void 0:i);return S0(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},A0=r=>{const e=Rf(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},Qr=(...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},Pf=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))n+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&n===""?t.push("/"):t.push(n);const i=s.replace("?","");n+="/"+i,t.push(n)}else n+="/"+s}),t.filter((s,i,a)=>a.indexOf(s)===i)},wu=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?ku(r):r):r,$f=(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 wu(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 s={};n??(n=/[%+]/.test(r));let i=r.indexOf("?",8);for(;i!==-1;){const a=r.indexOf("&",i+1);let o=r.indexOf("=",i);o>a&&a!==-1&&(o=-1);let c=r.slice(i+1,o===-1?a===-1?void 0:a:o);if(n&&(c=wu(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=wu(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},O0=$f,E0=(r,e)=>$f(r,e,!0),ku=decodeURIComponent,C0=/^[\w!#$%&'*.^`|~+-]+$/,I0=/^[ !#-:<-[\]-~]*$/,j0=(r,e)=>{const t=r.trim().split(";"),n={};for(let s of t){s=s.trim();const i=s.indexOf("=");if(i===-1)continue;const a=s.substring(0,i).trim();if(!C0.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),I0.test(o)&&(n[a]=ku(o))}return n},T0=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?j0(n):{}},De=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});Q(this,"res");Q(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})}},N0=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),B0=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,R0=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,P0=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,$0=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!B0.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new De(400,{message:o})}break;case"form":{if(!i||!(R0.test(i)||P0.test(i)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await N0(u,i),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new De(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}),s=c;break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=T0(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const as=(r,e,t)=>$0(r,async(n,s)=>{const i=await e.safeParseAsync(n);if(t){const a=await t({data:n,...i,target:r},s);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return i.success?i.data:s.json(i,400)});var Z0=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof Df?r.raw.headers:r.headers).get("Content-Type");return i!=null&&i.startsWith("multipart/form-data")||i!=null&&i.startsWith("application/x-www-form-urlencoded")?D0(r,{all:t,dot:n}):{}};async function D0(r,e){const t=await r.formData();return t?M0(t,e):{}}function M0(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?V0(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(U0(t,n,s),delete t[n])}),t}var V0=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},U0=(r,e,t)=>{let n=r;const s=e.split(".");s.forEach((i,a)=>{a===s.length-1?n[i]=t:((!n[i]||typeof n[i]!="object"||Array.isArray(n[i])||n[i]instanceof File)&&(n[i]=Object.create(null)),n=n[i])})},Zf=r=>Bf(r,ku),Df=(_g=class{constructor(r,e="/",t=[[]]){We(this,zr);Q(this,"raw");We(this,ni);We(this,cr);Q(this,"routeIndex",0);Q(this,"path");Q(this,"bodyCache",{});We(this,An,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const s=Object.keys(e)[0];return s?e[s].then(i=>(s==="json"&&(i=JSON.stringify(i)),new Response(i)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,Te(this,cr,t),Te(this,ni,{})}param(r){return r?Ce(this,zr,$g).call(this,r):Ce(this,zr,Zg).call(this)}query(r){return O0(this.url,r)}queries(r){return E0(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 Z0(this,r))}json(){return P(this,An).call(this,"json")}text(){return P(this,An).call(this,"text")}arrayBuffer(){return P(this,An).call(this,"arrayBuffer")}blob(){return P(this,An).call(this,"blob")}formData(){return P(this,An).call(this,"formData")}addValidatedData(r,e){P(this,ni)[r]=e}valid(r){return P(this,ni)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return P(this,cr)[0].map(([[,r]])=>r)}get routePath(){return P(this,cr)[0].map(([[,r]])=>r)[this.routeIndex].path}},ni=new WeakMap,cr=new WeakMap,zr=new WeakSet,$g=function(r){const e=P(this,cr)[0][this.routeIndex][1][r],t=Ce(this,zr,_f).call(this,e);return t?/\%/.test(t)?Zf(t):t:void 0},Zg=function(){const r={},e=Object.keys(P(this,cr)[0][this.routeIndex][1]);for(const t of e){const n=Ce(this,zr,_f).call(this,P(this,cr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?Zf(n):n)}return r},_f=function(r){return P(this,cr)[1]?P(this,cr)[1][r]:r},An=new WeakMap,_g),L0={Stringify:1,BeforeStream:2,Stream:3},Mf=async(r,e,t,n,s)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const i=r.callbacks;return i!=null&&i.length?(s?s[0]+=r:s=[r],Promise.all(i.map(o=>o({phase:e,buffer:s,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Mf(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},q0="text/plain; charset=UTF-8",Su=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Vf=(wg=class{constructor(r,e){We(this,Nt);We(this,Ga);We(this,Ja);Q(this,"env",{});We(this,Kr);Q(this,"finalized",!1);Q(this,"error");We(this,ts,200);We(this,Gr);We(this,Qe);We(this,et);We(this,Cr);We(this,Jr,!0);We(this,Ya);We(this,si);We(this,ii);We(this,Xa);We(this,Qa);Q(this,"render",(...r)=>(P(this,si)??Te(this,si,e=>this.html(e)),P(this,si).call(this,...r)));Q(this,"setLayout",r=>Te(this,Ya,r));Q(this,"getLayout",()=>P(this,Ya));Q(this,"setRenderer",r=>{Te(this,si,r)});Q(this,"header",(r,e,t)=>{if(e===void 0){P(this,Qe)?P(this,Qe).delete(r):P(this,et)&&delete P(this,et)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(P(this,Qe)||(Te(this,Jr,!1),Te(this,Qe,new Headers(P(this,et))),Te(this,et,{})),P(this,Qe).append(r,e)):P(this,Qe)?P(this,Qe).set(r,e):(P(this,et)??Te(this,et,{}),P(this,et)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});Q(this,"status",r=>{Te(this,Jr,!1),Te(this,ts,r)});Q(this,"set",(r,e)=>{P(this,Kr)??Te(this,Kr,new Map),P(this,Kr).set(r,e)});Q(this,"get",r=>P(this,Kr)?P(this,Kr).get(r):void 0);Q(this,"newResponse",(...r)=>Ce(this,Nt,Kt).call(this,...r));Q(this,"body",(r,e,t)=>typeof e=="number"?Ce(this,Nt,Kt).call(this,r,e,t):Ce(this,Nt,Kt).call(this,r,e));Q(this,"text",(r,e,t)=>{if(!P(this,et)){if(P(this,Jr)&&!t&&!e)return new Response(r);Te(this,et,{})}return P(this,et)["content-type"]=q0,typeof e=="number"?Ce(this,Nt,Kt).call(this,r,e,t):Ce(this,Nt,Kt).call(this,r,e)});Q(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return P(this,et)??Te(this,et,{}),P(this,et)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Ce(this,Nt,Kt).call(this,n,e,t):Ce(this,Nt,Kt).call(this,n,e)});Q(this,"html",(r,e,t)=>(P(this,et)??Te(this,et,{}),P(this,et)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Mf(r,L0.Stringify,!1,{}).then(n=>typeof e=="number"?Ce(this,Nt,Kt).call(this,n,e,t):Ce(this,Nt,Kt).call(this,n,e)):typeof e=="number"?Ce(this,Nt,Kt).call(this,r,e,t):Ce(this,Nt,Kt).call(this,r,e)));Q(this,"redirect",(r,e)=>(P(this,Qe)??Te(this,Qe,new Headers),P(this,Qe).set("Location",String(r)),this.newResponse(null,e??302)));Q(this,"notFound",()=>(P(this,ii)??Te(this,ii,()=>new Response),P(this,ii).call(this,this)));Te(this,Ga,r),e&&(Te(this,Gr,e.executionCtx),this.env=e.env,Te(this,ii,e.notFoundHandler),Te(this,Qa,e.path),Te(this,Xa,e.matchResult))}get req(){return P(this,Ja)??Te(this,Ja,new Df(P(this,Ga),P(this,Qa),P(this,Xa))),P(this,Ja)}get event(){if(P(this,Gr)&&"respondWith"in P(this,Gr))return P(this,Gr);throw Error("This context has no FetchEvent")}get executionCtx(){if(P(this,Gr))return P(this,Gr);throw Error("This context has no ExecutionContext")}get res(){return Te(this,Jr,!1),P(this,Cr)||Te(this,Cr,new Response("404 Not Found",{status:404}))}set res(r){if(Te(this,Jr,!1),P(this,Cr)&&r)try{for(const[e,t]of P(this,Cr).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=P(this,Cr).headers.getSetCookie();r.headers.delete("set-cookie");for(const s of n)r.headers.append("set-cookie",s)}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}Te(this,Cr,r),this.finalized=!0}get var(){return P(this,Kr)?Object.fromEntries(P(this,Kr)):{}}},Ga=new WeakMap,Ja=new WeakMap,Kr=new WeakMap,ts=new WeakMap,Gr=new WeakMap,Qe=new WeakMap,et=new WeakMap,Cr=new WeakMap,Jr=new WeakMap,Ya=new WeakMap,si=new WeakMap,ii=new WeakMap,Xa=new WeakMap,Qa=new WeakMap,Nt=new WeakSet,Kt=function(r,e,t){if(P(this,Jr)&&!t&&!e&&P(this,ts)===200)return new Response(r,{headers:P(this,et)});if(e&&typeof e!="number"){const s=new Headers(e.headers);P(this,Qe)&&P(this,Qe).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=Su(s,P(this,et));return new Response(r,{headers:i,status:e.status??P(this,ts)})}const n=typeof e=="number"?e:P(this,ts);P(this,et)??Te(this,et,{}),P(this,Qe)??Te(this,Qe,new Headers),Su(P(this,Qe),P(this,et)),P(this,Cr)&&(P(this,Cr).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=P(this,Qe))==null||a.append(i,s):(o=P(this,Qe))==null||o.set(i,s)}),Su(P(this,Qe),P(this,et))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")P(this,Qe).set(s,i);else{P(this,Qe).delete(s);for(const a of i)P(this,Qe).append(s,a)}return new Response(r,{status:n,headers:P(this,Qe)})},wg),Uf=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof Vf;return o(0);async function o(c){if(c<=i)throw new Error("next() called multiple times");i=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&s||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}},st="ALL",H0="all",F0=["get","post","put","delete","options","patch"],Lf="Can not add a route since the matcher is already built.",qf=class extends Error{},W0=Symbol("composedHandler"),z0=r=>r.text("404 Not Found",404),Hf=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),Ff=(kg=class{constructor(e={}){We(this,ot);Q(this,"get");Q(this,"post");Q(this,"put");Q(this,"delete");Q(this,"options");Q(this,"patch");Q(this,"all");Q(this,"on");Q(this,"use");Q(this,"router");Q(this,"getPath");Q(this,"_basePath","/");We(this,ur,"/");Q(this,"routes",[]);We(this,Yr,z0);We(this,On,Hf);Q(this,"onError",e=>(Te(this,On,e),this));Q(this,"notFound",e=>(Te(this,Yr,e),this));Q(this,"fetch",(e,...t)=>Ce(this,ot,vu).call(this,e,t[1],t[0],e.method));Q(this,"request",(e,t,n,s)=>{if(e instanceof Request)return t!==void 0&&(e=new Request(e,t)),this.fetch(e,n,s);e=e.toString();const i=/^https?:\/\//.test(e)?e:`http://localhost${Qr("/",e)}`,a=new Request(i,t);return this.fetch(a,n,s)});Q(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Ce(this,ot,vu).call(this,e.request,e,void 0,e.request.method))})});[...F0,H0].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?Te(this,ur,i):Ce(this,ot,ns).call(this,s,P(this,ur),i),a.forEach(o=>{typeof o!="string"&&Ce(this,ot,ns).call(this,s,P(this,ur),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){Te(this,ur,o);for(const c of[s].flat())a.map(u=>{Ce(this,ot,ns).call(this,c.toUpperCase(),P(this,ur),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?Te(this,ur,s):(Te(this,ur,"*"),i.unshift(s)),i.forEach(a=>{Ce(this,ot,ns).call(this,st,P(this,ur),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Rf:A0}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{var a;let i;P(t,On)===Hf?i=s.handler:(i=async(o,c)=>(await Uf([],P(t,On))(o,()=>s.handler(o,c))).res,i[W0]=s.handler),Ce(a=n,ot,ns).call(a,s.method,s.path,i)}),this}basePath(e){const t=Ce(this,ot,Dg).call(this);return t._basePath=Qr(this._basePath,e),t}mount(e,t,n){let s,i;n&&(typeof n=="function"?i=n:(i=n.optionHandler,s=n.replaceRequest));const a=i?c=>{const u=i(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};s||(s=(()=>{const c=Qr(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(s(c.req.raw),...a(c));if(f)return f;await u()};return Ce(this,ot,ns).call(this,st,Qr(e,"*"),o),this}},ur=new WeakMap,ot=new WeakSet,Dg=function(){const e=new Ff({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Yr=new WeakMap,On=new WeakMap,ns=function(e,t,n){e=e.toUpperCase(),t=Qr(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)},gu=function(e,t){if(e instanceof Error)return P(this,On).call(this,e,t);throw e},vu=function(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await Ce(this,ot,vu).call(this,e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.router.match(s,i),o=new Vf(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:P(this,Yr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await P(this,Yr).call(this,o)})}catch(f){return Ce(this,ot,gu).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:P(this,Yr).call(this,o))).catch(f=>Ce(this,ot,gu).call(this,f,o)):u??P(this,Yr).call(this,o)}const c=Uf(a[0],P(this,On),P(this,Yr));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 Ce(this,ot,gu).call(this,u,o)}})()},kg),oo="[^/]+",fi=".*",hi="(?:|/.*)",pi=Symbol(),K0=new Set(".\\+*[^]$()");function G0(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===fi||r===hi?1:e===fi||e===hi?-1:r===oo?1:e===oo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Au=class{constructor(){Q(this,"index");Q(this,"varIndex");Q(this,"children",Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(this.index!==void 0)throw pi;if(i)return;this.index=t;return}const[a,...o]=e,c=a==="*"?o.length===0?["","",fi]:["","",oo]:a==="/*"?["","",hi]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||oo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw pi;if(u=this.children[m],!u){if(Object.keys(this.children).some(B=>B!==fi&&B!==hi))throw pi;if(i)return;u=this.children[m]=new Au,f!==""&&(u.varIndex=s.varIndex++)}!i&&f!==""&&n.push([f,u.varIndex])}else if(u=this.children[a],!u){if(Object.keys(this.children).some(f=>f.length>1&&f!==fi&&f!==hi))throw pi;if(i)return;u=this.children[a]=new Au}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(this.children).sort(G0).map(n=>{const s=this.children[n];return(typeof s.varIndex=="number"?`(${n})@${s.varIndex}`:K0.has(n)?`\\${n}`:n)+s.buildRegExpStr()});return typeof this.index=="number"&&t.unshift(`#${this.index}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},J0=class{constructor(){Q(this,"context",{varIndex:0});Q(this,"root",new Au)}insert(r,e,t){const n=[],s=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return s[a]=[u,c],a++,o=!0,u}),!o)break}const i=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=s.length-1;a>=0;a--){const[o]=s[a];for(let c=i.length-1;c>=0;c--)if(i[c].indexOf(o)!==-1){i[c]=i[c].replace(o,s[a][1]);break}}return this.root.insert(i,e,n,this.context,t),n}buildRegExp(){let r=this.root.buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,i,a)=>i!==void 0?(t[++e]=Number(i),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},Wf=[],Y0=[/^$/,[],Object.create(null)],co=Object.create(null);function zf(r){return co[r]??(co[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function X0(){co=Object.create(null)}function Q0(r){var u;const e=new J0,t=[];if(r.length===0)return Y0;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[B,j])=>f?1:B?-1:m.length-j.length),s=Object.create(null);for(let f=0,m=-1,B=n.length;f<B;f++){const[j,p,g]=n[f];j?s[p]=[g.map(([S])=>[S,Object.create(null)]),Wf]:m++;let A;try{A=e.insert(p,m,j)}catch(S){throw S===pi?new qf(p):S}j||(t[m]=g.map(([S,R])=>{const T=Object.create(null);for(R-=1;R>=0;R--){const[ve,Ue]=A[R];T[ve]=Ue}return[S,T]}))}const[i,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let B=0,j=t[f].length;B<j;B++){const p=(u=t[f][B])==null?void 0:u[1];if(!p)continue;const g=Object.keys(p);for(let A=0,S=g.length;A<S;A++)p[g[A]]=o[p[g[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[i,c,s]}function os(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(zf(t).test(e))return[...r[t]]}}var ev=(Sg=class{constructor(){We(this,ai);Q(this,"name","RegExpRouter");Q(this,"middleware");Q(this,"routes");this.middleware={[st]:Object.create(null)},this.routes={[st]:Object.create(null)}}add(r,e,t){var o;const{middleware:n,routes:s}=this;if(!n||!s)throw new Error(Lf);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[st]).forEach(u=>{c[r][u]=[...c[st][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=zf(e);r===st?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=os(n[u],e)||os(n[st],e)||[])}):(o=n[r])[e]||(o[e]=os(n[r],e)||os(n[st],e)||[]),Object.keys(n).forEach(u=>{(r===st||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,i])})}),Object.keys(s).forEach(u=>{(r===st||r===u)&&Object.keys(s[u]).forEach(f=>c.test(f)&&s[u][f].push([t,i]))});return}const a=Pf(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(s).forEach(m=>{var B;(r===st||r===m)&&((B=s[m])[f]||(B[f]=[...os(n[m],f)||os(n[st],f)||[]]),s[m][f].push([t,i-u+c+1]))})}}match(r,e){X0();const t=Ce(this,ai,Mg).call(this);return this.match=(n,s)=>{const i=t[n]||t[st],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],Wf];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},ai=new WeakSet,Mg=function(){const r=Object.create(null);return Object.keys(this.routes).concat(Object.keys(this.middleware)).forEach(e=>{r[e]||(r[e]=Ce(this,ai,Vg).call(this,e))}),this.middleware=this.routes=void 0,r},Vg=function(r){const e=[];let t=r===st;return[this.middleware,this.routes].forEach(n=>{const s=n[r]?Object.keys(n[r]).map(i=>[i,n[r][i]]):[];s.length!==0?(t||(t=!0),e.push(...s)):r!==st&&e.push(...Object.keys(n[st]).map(i=>[i,n[st][i]]))}),t?Q0(e):null},Sg),tv=class{constructor(r){Q(this,"name","SmartRouter");Q(this,"routers",[]);Q(this,"routes",[]);Object.assign(this,r)}add(r,e,t){if(!this.routes)throw new Error(Lf);this.routes.push([r,e,t])}match(r,e){if(!this.routes)throw new Error("Fatal error");const{routers:t,routes:n}=this,s=t.length;let i=0,a;for(;i<s;i++){const o=t[i];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 qf)continue;throw c}this.match=o.match.bind(o),this.routers=[o],this.routes=void 0;break}if(i===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(this.routes||this.routers.length!==1)throw new Error("No active router has been determined yet.");return this.routers[0]}},Kf=(Ag=class{constructor(r,e,t){We(this,Xr);Q(this,"methods");Q(this,"children");Q(this,"patterns");Q(this,"order",0);Q(this,"params",Object.create(null));if(this.children=t||Object.create(null),this.methods=[],r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},this.methods=[n]}this.patterns=[]}insert(r,e,t){this.order=++this.order;let n=this;const s=_0(e),i=[];for(let c=0,u=s.length;c<u;c++){const f=s[c];if(Object.keys(n.children).includes(f)){n=n.children[f];const B=Nf(f);B&&i.push(B[1]);continue}n.children[f]=new Kf;const m=Nf(f);m&&(n.patterns.push(m),i.push(m[1])),n=n.children[f]}n.methods.length||(n.methods=[]);const a=Object.create(null),o={handler:t,possibleKeys:i.filter((c,u,f)=>f.indexOf(c)===u),score:this.order};return a[r]=o,n.methods.push(a),n}search(r,e){const t=[];this.params=Object.create(null);let s=[this];const i=Tf(e);for(let o=0,c=i.length;o<c;o++){const u=i[o],f=o===c-1,m=[];for(let B=0,j=s.length;B<j;B++){const p=s[B],g=p.children[u];g&&(g.params=p.params,f?(g.children["*"]&&t.push(...Ce(this,Xr,ss).call(this,g.children["*"],r,p.params,Object.create(null))),t.push(...Ce(this,Xr,ss).call(this,g,r,p.params,Object.create(null)))):m.push(g));for(let A=0,S=p.patterns.length;A<S;A++){const R=p.patterns[A],T={...p.params};if(R==="*"){const gt=p.children["*"];gt&&(t.push(...Ce(this,Xr,ss).call(this,gt,r,p.params,Object.create(null))),m.push(gt));continue}if(u==="")continue;const[ve,Ue,qe]=R,$e=p.children[ve],rt=i.slice(o).join("/");if(qe instanceof RegExp&&qe.test(rt)){T[Ue]=rt,t.push(...Ce(this,Xr,ss).call(this,$e,r,p.params,T));continue}(qe===!0||qe.test(u))&&typeof ve=="string"&&(T[Ue]=u,f?(t.push(...Ce(this,Xr,ss).call(this,$e,r,T,p.params)),$e.children["*"]&&t.push(...Ce(this,Xr,ss).call(this,$e.children["*"],r,T,p.params))):($e.params=T,m.push($e)))}}s=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},Xr=new WeakSet,ss=function(r,e,t,n){const s=[];for(let i=0,a=r.methods.length;i<a;i++){const o=r.methods[i],c=o[e]||o[st],u=Object.create(null);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],j=u[c.score];c.params[B]=n[B]&&!j?n[B]:t[B]??n[B],u[c.score]=!0}s.push(c)}}return s},Ag),rv=class{constructor(){Q(this,"name","TrieRouter");Q(this,"node");this.node=new Kf}add(r,e,t){const n=Pf(e);if(n){for(let s=0,i=n.length;s<i;s++)this.node.insert(r,n[s],t);return}this.node.insert(r,e,t)}match(r,e){return this.node.search(r,e)}},nv=class extends Ff{constructor(r={}){super(r),this.router=r.router??new tv({routers:[new ev,new rv]})}},Ne;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Ne||(Ne={}));var Ou;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ou||(Ou={}));const K=Ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),en=r=>{switch(typeof r){case"undefined":return K.undefined;case"string":return K.string;case"number":return isNaN(r)?K.nan:K.number;case"boolean":return K.boolean;case"function":return K.function;case"bigint":return K.bigint;case"symbol":return K.symbol;case"object":return Array.isArray(r)?K.array:r===null?K.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?K.promise:typeof Map<"u"&&r instanceof Map?K.map:typeof Set<"u"&&r instanceof Set?K.set:typeof Date<"u"&&r instanceof Date?K.date:K.object;default:return K.unknown}},Z=Ne.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"]),sv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Gt=class Ug 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(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(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 s(this),n}static assert(e){if(!(e instanceof Ug))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Gt.create=r=>new Gt(r);const cs=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===K.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ne.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ne.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ne.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Ne.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}"`:Ne.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,Ne.assertNever(r)}return{message:t}};let Gf=cs;function iv(r){Gf=r}function uo(){return Gf}const lo=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.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{...s,path:i,message:o}},av=[];function q(r,e){const t=uo(),n=lo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===cs?void 0:cs].filter(s=>!!s)});r.common.issues.push(n)}let At=class Lg{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 s of t){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return Lg.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),us=r=>({status:"dirty",value:r}),vt=r=>({status:"valid",value:r}),Eu=r=>r.status==="aborted",Cu=r=>r.status==="dirty",mi=r=>r.status==="valid",yi=r=>typeof Promise<"u"&&r instanceof Promise;function fo(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 Jf(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!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}typeof SuppressedError=="function"&&SuppressedError;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 gi,vi;let fr=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const Yf=(r,e)=>{if(mi(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 Gt(r.common.issues);return this._error=t,this._error}}};function be(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=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:s}:{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:s}}let we=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 en(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:en(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new At,ctx:{common:e.parent.common,data:e.data,parsedType:en(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(yi(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 s={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:en(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Yf(s,i)}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:en(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(yi(s)?s:Promise.resolve(s));return Yf(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:Z.custom,...n(s)});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,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Jt({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return hr.create(this,this._def)}nullable(){return rn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Cn.create(this,this._def)}promise(){return hs.create(this,this._def)}or(e){return Ai.create([this,e],this._def)}and(e){return Oi.create(this,e,this._def)}transform(e){return new Jt({...be(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ti({...be(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new Tu({typeName:de.ZodBranded,type:this,...be(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ni({...be(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 Nu.create(this,e)}readonly(){return Bi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const ov=/^c[^\s-]{8,}$/i,cv=/^[0-9a-z]+$/,uv=/^[0-9A-HJKMNP-TV-Z]{26}$/,lv=/^[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,dv=/^[a-z0-9_-]{21}$/i,fv=/^[-+]?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)?)??$/,hv=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Iu;const mv=/^(?:(?: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])$/,yv=/^(([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})))$/,gv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xf="((\\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])))",vv=new RegExp(`^${Xf}$`);function Qf(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 bv(r){return new RegExp(`^${Qf(r)}$`)}function eh(r){let e=`${Xf}T${Qf(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 xv(r,e){return!!((e==="v4"||!e)&&mv.test(r)||(e==="v6"||!e)&&yv.test(r))}let ls=class to extends we{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==K.string){const i=this._getOrReturnCtx(e);return q(i,{code:Z.invalid_type,expected:K.string,received:i.parsedType}),pe}const n=new At;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),q(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),q(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?q(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&q(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")hv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"email",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Iu||(Iu=new RegExp(pv,"u")),Iu.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"emoji",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")lv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"uuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")dv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"nanoid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")ov.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"cuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")cv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"cuid2",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")uv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"ulid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),q(s,{validation:"url",code:Z.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"regex",code:Z.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),q(s,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.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)||(s=this._getOrReturnCtx(e,s),q(s,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),q(s,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?eh(i).test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{code:Z.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?vv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{code:Z.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?bv(i).test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{code:Z.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?fv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"duration",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?xv(e.data,i.version)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"ip",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?gv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"base64",code:Z.invalid_string,message:i.message}),n.dirty()):Ne.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new to({...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 to({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new to({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new to({...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}};ls.create=r=>{var e;return new ls({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};function _v(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}let bi=class wf extends we{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)!==K.number){const i=this._getOrReturnCtx(e);return q(i,{code:Z.invalid_type,expected:K.number,received:i.parsedType}),pe}let n;const s=new At;for(const i of this._def.checks)i.kind==="int"?Ne.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),q(n,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),q(n,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?_v(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),q(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:Z.not_finite,message:i.message}),s.dirty()):Ne.assertNever(i);return{status:s.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,s){return new wf({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new wf({...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"&&Ne.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)}};bi.create=r=>new bi({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let xi=class kf extends we{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)!==K.bigint){const i=this._getOrReturnCtx(e);return q(i,{code:Z.invalid_type,expected:K.bigint,received:i.parsedType}),pe}let n;const s=new At;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),q(n,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),q(n,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),q(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ne.assertNever(i);return{status:s.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,s){return new kf({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new kf({...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}};xi.create=r=>{var e;return new xi({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};let _i=class extends we{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==K.boolean){const n=this._getOrReturnCtx(e);return q(n,{code:Z.invalid_type,expected:K.boolean,received:n.parsedType}),pe}return vt(e.data)}};_i.create=r=>new _i({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let wi=class qg extends we{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==K.date){const i=this._getOrReturnCtx(e);return q(i,{code:Z.invalid_type,expected:K.date,received:i.parsedType}),pe}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return q(i,{code:Z.invalid_date}),pe}const n=new At;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),q(s,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),q(s,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Ne.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new qg({...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}};wi.create=r=>new wi({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,...be(r)});let ho=class extends we{_parse(e){if(this._getType(e)!==K.symbol){const n=this._getOrReturnCtx(e);return q(n,{code:Z.invalid_type,expected:K.symbol,received:n.parsedType}),pe}return vt(e.data)}};ho.create=r=>new ho({typeName:de.ZodSymbol,...be(r)});let ki=class extends we{_parse(e){if(this._getType(e)!==K.undefined){const n=this._getOrReturnCtx(e);return q(n,{code:Z.invalid_type,expected:K.undefined,received:n.parsedType}),pe}return vt(e.data)}};ki.create=r=>new ki({typeName:de.ZodUndefined,...be(r)});let Si=class extends we{_parse(e){if(this._getType(e)!==K.null){const n=this._getOrReturnCtx(e);return q(n,{code:Z.invalid_type,expected:K.null,received:n.parsedType}),pe}return vt(e.data)}};Si.create=r=>new Si({typeName:de.ZodNull,...be(r)});let ds=class extends we{constructor(){super(...arguments),this._any=!0}_parse(e){return vt(e.data)}};ds.create=r=>new ds({typeName:de.ZodAny,...be(r)});let En=class extends we{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vt(e.data)}};En.create=r=>new En({typeName:de.ZodUnknown,...be(r)});let jr=class extends we{_parse(e){const t=this._getOrReturnCtx(e);return q(t,{code:Z.invalid_type,expected:K.never,received:t.parsedType}),pe}};jr.create=r=>new jr({typeName:de.ZodNever,...be(r)});let po=class extends we{_parse(e){if(this._getType(e)!==K.undefined){const n=this._getOrReturnCtx(e);return q(n,{code:Z.invalid_type,expected:K.void,received:n.parsedType}),pe}return vt(e.data)}};po.create=r=>new po({typeName:de.ZodVoid,...be(r)});let Cn=class bu extends we{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==K.array)return q(t,{code:Z.invalid_type,expected:K.array,received:t.parsedType}),pe;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(q(t,{code:a?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(q(t,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(q(t,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new fr(t,a,t.path,o)))).then(a=>At.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new fr(t,a,t.path,o)));return At.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new bu({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new bu({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new bu({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Cn.create=(r,e)=>new Cn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,...be(e)});function fs(r){if(r instanceof Vt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=hr.create(fs(n))}return new Vt({...r._def,shape:()=>e})}else return r instanceof Cn?new Cn({...r._def,type:fs(r.element)}):r instanceof hr?hr.create(fs(r.unwrap())):r instanceof rn?rn.create(fs(r.unwrap())):r instanceof tn?tn.create(r.items.map(e=>fs(e))):r}let Vt=class dr extends we{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=Ne.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==K.object){const u=this._getOrReturnCtx(e);return q(u,{code:Z.invalid_type,expected:K.object,received:u.parsedType}),pe}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof jr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new fr(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof jr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(q(s,{code:Z.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=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new fr(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.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=>At.mergeObjectSync(n,u)):At.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new dr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,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 dr({...this._def,unknownKeys:"strip"})}passthrough(){return new dr({...this._def,unknownKeys:"passthrough"})}extend(e){return new dr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new dr({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 dr({...this._def,catchall:e})}pick(e){const t={};return Ne.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new dr({...this._def,shape:()=>t})}omit(e){const t={};return Ne.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new dr({...this._def,shape:()=>t})}deepPartial(){return fs(this)}partial(e){const t={};return Ne.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new dr({...this._def,shape:()=>t})}required(e){const t={};return Ne.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof hr;)i=i._def.innerType;t[n]=i}}),new dr({...this._def,shape:()=>t})}keyof(){return sh(Ne.objectKeys(this.shape))}};Vt.create=(r,e)=>new Vt({shape:()=>r,unknownKeys:"strip",catchall:jr.create(),typeName:de.ZodObject,...be(e)}),Vt.strictCreate=(r,e)=>new Vt({shape:()=>r,unknownKeys:"strict",catchall:jr.create(),typeName:de.ZodObject,...be(e)}),Vt.lazycreate=(r,e)=>new Vt({shape:r,unknownKeys:"strip",catchall:jr.create(),typeName:de.ZodObject,...be(e)});let Ai=class extends we{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Gt(o.ctx.common.issues));return q(t,{code:Z.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;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"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Gt(c));return q(t,{code:Z.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Ai.create=(r,e)=>new Ai({options:r,typeName:de.ZodUnion,...be(e)});const Tr=r=>r instanceof Ei?Tr(r.schema):r instanceof Jt?Tr(r.innerType()):r instanceof Ci?[r.value]:r instanceof Ii?r.options:r instanceof ji?Ne.objectValues(r.enum):r instanceof Ti?Tr(r._def.innerType):r instanceof ki?[void 0]:r instanceof Si?[null]:r instanceof hr?[void 0,...Tr(r.unwrap())]:r instanceof rn?[null,...Tr(r.unwrap())]:r instanceof Tu||r instanceof Bi?Tr(r.unwrap()):r instanceof Ni?Tr(r._def.innerType):[];let th=class Hg extends we{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==K.object)return q(t,{code:Z.invalid_type,expected:K.object,received:t.parsedType}),pe;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(q(t,{code:Z.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 s=new Map;for(const i of t){const a=Tr(i.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(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Hg({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...be(n)})}};function ju(r,e){const t=en(r),n=en(e);if(r===e)return{valid:!0,data:r};if(t===K.object&&n===K.object){const s=Ne.objectKeys(e),i=Ne.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=ju(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===K.array&&n===K.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=ju(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===K.date&&n===K.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Oi=class extends we{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Eu(i)||Eu(a))return pe;const o=ju(i.value,a.value);return o.valid?((Cu(i)||Cu(a))&&t.dirty(),{status:t.value,value:o.data}):(q(n,{code:Z.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(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Oi.create=(r,e,t)=>new Oi({left:r,right:e,typeName:de.ZodIntersection,...be(t)});let tn=class Fg extends we{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.array)return q(n,{code:Z.invalid_type,expected:K.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return q(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(q(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new fr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>At.mergeArray(t,a)):At.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Fg({...this._def,rest:e})}};tn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new tn({items:r,typeName:de.ZodTuple,rest:null,...be(e)})};let rh=class Sf extends we{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!==K.object)return q(n,{code:Z.invalid_type,expected:K.object,received:n.parsedType}),pe;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new fr(n,o,n.path,o)),value:a._parse(new fr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?At.mergeObjectAsync(t,s):At.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof we?new Sf({keyType:e,valueType:t,typeName:de.ZodRecord,...be(n)}):new Sf({keyType:ls.create(),valueType:e,typeName:de.ZodRecord,...be(t)})}},mo=class extends we{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!==K.map)return q(n,{code:Z.invalid_type,expected:K.map,received:n.parsedType}),pe;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new fr(n,o,n.path,[u,"key"])),value:i._parse(new fr(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}}}};mo.create=(r,e,t)=>new mo({valueType:e,keyType:r,typeName:de.ZodMap,...be(t)});let yo=class Af extends we{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==K.set)return q(n,{code:Z.invalid_type,expected:K.set,received:n.parsedType}),pe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(q(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(q(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=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)=>i._parse(new fr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Af({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Af({...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)}};yo.create=(r,e)=>new yo({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,...be(e)});let nh=class xu extends we{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==K.function)return q(t,{code:Z.invalid_type,expected:K.function,received:t.parsedType}),pe;function n(o,c){return lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,uo(),cs].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,uo(),cs].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof hs){const o=this;return vt(async function(...c){const u=new Gt([]),f=await o._def.args.parseAsync(c,i).catch(j=>{throw u.addIssue(n(c,j)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(j=>{throw u.addIssue(s(m,j)),u})})}else{const o=this;return vt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Gt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Gt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new xu({...this._def,args:tn.create(e).rest(En.create())})}returns(e){return new xu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new xu({args:e||tn.create([]).rest(En.create()),returns:t||En.create(),typeName:de.ZodFunction,...be(n)})}},Ei=class extends we{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})}};Ei.create=(r,e)=>new Ei({getter:r,typeName:de.ZodLazy,...be(e)});let Ci=class extends we{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return q(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ci.create=(r,e)=>new Ci({value:r,typeName:de.ZodLiteral,...be(e)});function sh(r,e){return new Ii({values:r,typeName:de.ZodEnum,...be(e)})}let Ii=class Of extends we{constructor(){super(...arguments),gi.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{expected:Ne.joinValues(n),received:t.parsedType,code:Z.invalid_type}),pe}if(fo(this,gi)||Jf(this,gi,new Set(this._def.values)),!fo(this,gi).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{received:t.data,code:Z.invalid_enum_value,options:n}),pe}return vt(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 Of.create(e,{...this._def,...t})}exclude(e,t=this._def){return Of.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};gi=new WeakMap,Ii.create=sh;let ji=class extends we{constructor(){super(...arguments),vi.set(this,void 0)}_parse(e){const t=Ne.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==K.string&&n.parsedType!==K.number){const s=Ne.objectValues(t);return q(n,{expected:Ne.joinValues(s),received:n.parsedType,code:Z.invalid_type}),pe}if(fo(this,vi)||Jf(this,vi,new Set(Ne.getValidEnumValues(this._def.values))),!fo(this,vi).has(e.data)){const s=Ne.objectValues(t);return q(n,{received:n.data,code:Z.invalid_enum_value,options:s}),pe}return vt(e.data)}get enum(){return this._def.values}};vi=new WeakMap,ji.create=(r,e)=>new ji({values:r,typeName:de.ZodNativeEnum,...be(e)});let hs=class extends we{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==K.promise&&t.common.async===!1)return q(t,{code:Z.invalid_type,expected:K.promise,received:t.parsedType}),pe;const n=t.parsedType===K.promise?t.data:Promise.resolve(t.data);return vt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};hs.create=(r,e)=>new hs({type:r,typeName:de.ZodPromise,...be(e)});let Jt=class extends we{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),s=this._def.effect||null,i={addIssue:a=>{q(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);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"?us(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"?us(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);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(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!mi(a))return a;const o=s.transform(a.value,i);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=>mi(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Ne.assertNever(s)}};Jt.create=(r,e,t)=>new Jt({schema:r,typeName:de.ZodEffects,effect:e,...be(t)}),Jt.createWithPreprocess=(r,e,t)=>new Jt({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,...be(t)});let hr=class extends we{_parse(e){return this._getType(e)===K.undefined?vt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};hr.create=(r,e)=>new hr({innerType:r,typeName:de.ZodOptional,...be(e)});let rn=class extends we{_parse(e){return this._getType(e)===K.null?vt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};rn.create=(r,e)=>new rn({innerType:r,typeName:de.ZodNullable,...be(e)});let Ti=class extends we{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===K.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ti.create=(r,e)=>new Ti({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...be(e)});let Ni=class extends we{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return yi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Gt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Gt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ni.create=(r,e)=>new Ni({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...be(e)});let go=class extends we{_parse(e){if(this._getType(e)!==K.nan){const n=this._getOrReturnCtx(e);return q(n,{code:Z.invalid_type,expected:K.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};go.create=r=>new go({typeName:de.ZodNaN,...be(r)});const wv=Symbol("zod_brand");let Tu=class extends we{_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}},Nu=class Wg extends we{_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"?pe:i.status==="dirty"?(t.dirty(),us(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Wg({in:e,out:t,typeName:de.ZodPipeline})}},Bi=class extends we{_parse(e){const t=this._def.innerType._parse(e),n=s=>(mi(s)&&(s.value=Object.freeze(s.value)),s);return yi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};Bi.create=(r,e)=>new Bi({innerType:r,typeName:de.ZodReadonly,...be(e)});function ih(r,e={},t){return r?ds.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):ds.create()}const kv={object:Vt.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 Sv=(r,e={message:`Input not instance of ${r.name}`})=>ih(t=>t instanceof r,e),ah=ls.create,oh=bi.create,Av=go.create,Ov=xi.create,ch=_i.create,Ev=wi.create,Cv=ho.create,Iv=ki.create,jv=Si.create,Tv=ds.create,Nv=En.create,Bv=jr.create,Rv=po.create,Pv=Cn.create,$v=Vt.create,Zv=Vt.strictCreate,Dv=Ai.create,Mv=th.create,Vv=Oi.create,Uv=tn.create,Lv=rh.create,qv=mo.create,Hv=yo.create,Fv=nh.create,Wv=Ei.create,zv=Ci.create,Kv=Ii.create,Gv=ji.create,Jv=hs.create,uh=Jt.create,Yv=hr.create,Xv=rn.create,Qv=Jt.createWithPreprocess,eb=Nu.create;var x=Object.freeze({__proto__:null,defaultErrorMap:cs,setErrorMap:iv,getErrorMap:uo,makeIssue:lo,EMPTY_PATH:av,addIssueToContext:q,ParseStatus:At,INVALID:pe,DIRTY:us,OK:vt,isAborted:Eu,isDirty:Cu,isValid:mi,isAsync:yi,get util(){return Ne},get objectUtil(){return Ou},ZodParsedType:K,getParsedType:en,ZodType:we,datetimeRegex:eh,ZodString:ls,ZodNumber:bi,ZodBigInt:xi,ZodBoolean:_i,ZodDate:wi,ZodSymbol:ho,ZodUndefined:ki,ZodNull:Si,ZodAny:ds,ZodUnknown:En,ZodNever:jr,ZodVoid:po,ZodArray:Cn,ZodObject:Vt,ZodUnion:Ai,ZodDiscriminatedUnion:th,ZodIntersection:Oi,ZodTuple:tn,ZodRecord:rh,ZodMap:mo,ZodSet:yo,ZodFunction:nh,ZodLazy:Ei,ZodLiteral:Ci,ZodEnum:Ii,ZodNativeEnum:ji,ZodPromise:hs,ZodEffects:Jt,ZodTransformer:Jt,ZodOptional:hr,ZodNullable:rn,ZodDefault:Ti,ZodCatch:Ni,ZodNaN:go,BRAND:wv,ZodBranded:Tu,ZodPipeline:Nu,ZodReadonly:Bi,custom:ih,Schema:we,ZodSchema:we,late:kv,get ZodFirstPartyTypeKind(){return de},coerce:{string:r=>ls.create({...r,coerce:!0}),number:r=>bi.create({...r,coerce:!0}),boolean:r=>_i.create({...r,coerce:!0}),bigint:r=>xi.create({...r,coerce:!0}),date:r=>wi.create({...r,coerce:!0})},any:Tv,array:Pv,bigint:Ov,boolean:ch,date:Ev,discriminatedUnion:Mv,effect:uh,enum:Kv,function:Fv,instanceof:Sv,intersection:Vv,lazy:Wv,literal:zv,map:qv,nan:Av,nativeEnum:Gv,never:Bv,null:jv,nullable:Xv,number:oh,object:$v,oboolean:()=>ch().optional(),onumber:()=>oh().optional(),optional:Yv,ostring:()=>ah().optional(),pipeline:eb,preprocess:Qv,promise:Jv,record:Lv,set:Hv,strictObject:Zv,string:ah,symbol:Cv,transformer:uh,tuple:Uv,undefined:Iv,union:Dv,unknown:Nv,void:Rv,NEVER:pe,ZodIssueCode:Z,quotelessJson:sv,ZodError:Gt}),Bt=class Ef extends nv{constructor(t){super(t);Q(this,"openAPIRegistry");Q(this,"defaultHook");Q(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var u,f,m,B,j,p,g,A,S,R;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const T=as("query",n.request.query,i);a.push(T)}if((f=n.request)!=null&&f.params){const T=as("param",n.request.params,i);a.push(T)}if((m=n.request)!=null&&m.headers){const T=as("header",n.request.headers,i);a.push(T)}if((B=n.request)!=null&&B.cookies){const T=as("cookie",n.request.cookies,i);a.push(T)}const o=(p=(j=n.request)==null?void 0:j.body)==null?void 0:p.content;if(o)for(const T of Object.keys(o)){if(!o[T])continue;const ve=o[T].schema;if(ve instanceof we){if(dh(T)){const Ue=as("json",ve,i);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Ue);else{const qe=async($e,rt)=>{if($e.req.header("content-type")&&dh($e.req.header("content-type")))return await Ue($e,rt);$e.req.addValidatedData("json",{}),await rt()};a.push(qe)}}if(fh(T)){const Ue=as("form",ve,i);if((R=(S=n.request)==null?void 0:S.body)!=null&&R.required)a.push(Ue);else{const qe=async($e,rt)=>{if($e.req.header("content-type")&&fh($e.req.header("content-type")))return await Ue($e,rt);$e.req.addValidatedData("form",{}),await rt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,s),this});Q(this,"getOpenAPIDocument",t=>{const s=new g0(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?lh(s,this._basePath):s});Q(this,"getOpenAPI31Document",t=>{const s=new x0(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?lh(s,this._basePath):s});Q(this,"doc",(t,n)=>this.get(t,s=>{const i=typeof n=="function"?n(s):n;try{const a=this.getOpenAPIDocument(i);return s.json(a)}catch(a){return s.json(a,500)}}));Q(this,"doc31",(t,n)=>this.get(t,s=>{const i=typeof n=="function"?n(s):n;try{const a=this.getOpenAPI31Document(i);return s.json(a)}catch(a){return s.json(a,500)}}));this.openAPIRegistry=new Qg,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Ef?(n.openAPIRegistry.definitions.forEach(i=>{switch(i.type){case"component":return this.openAPIRegistry.registerComponent(i.componentType,i.name,i.component);case"route":return this.openAPIRegistry.registerPath({...i.route,path:Qr(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:Qr(s,i.webhook.path)});case"schema":return this.openAPIRegistry.register(i.schema._def.openapi._internal.refId,i.schema);case"parameter":return this.openAPIRegistry.registerParameter(i.schema._def.openapi._internal.refId,i.schema);default:{const a=i;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new Ef({...super.basePath(t),defaultHook:this.defaultHook})}},Oe=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};Gg(x);function lh(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[Qr(e,n)]=r.paths[n]}),{...r,paths:t}}function dh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function fh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function tb(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 s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function rb(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function Ri(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function nb(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const B=typeof s=="string"?i:s,j=B??{},{param:p}=j,g=tb(j,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof s=="string"?{refId:s}:void 0),S=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),R=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(S).length>0?{metadata:S}:void 0)}));if(rb(this,"ZodObject")){const T=this.extend;R.extend=function(...ve){var Ue,qe,$e,rt,gt,Mt;const E=T.apply(this,ve);return E._def.openapi={_internal:{extendedFrom:!((qe=(Ue=this._def.openapi)===null||Ue===void 0?void 0:Ue._internal)===null||qe===void 0)&&qe.refId?{refId:(rt=($e=this._def.openapi)===null||$e===void 0?void 0:$e._internal)===null||rt===void 0?void 0:rt.refId,schema:this}:(gt=this._def.openapi)===null||gt===void 0?void 0:gt._internal.extendedFrom},metadata:(Mt=E._def.openapi)===null||Mt===void 0?void 0:Mt.metadata},E}}return R},Ri(r,"optional"),Ri(r,"nullable"),Ri(r,"default"),Ri(r,"transform"),Ri(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}new Set(".\\+*[^]$()");var Be;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Be||(Be={}));var Bu;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Bu||(Bu={}));const G=Be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),nn=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}},D=Be.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"]),sb=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Rt 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(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(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 s(this),n}static assert(e){if(!(e instanceof Rt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Rt.create=r=>new Rt(r);const ps=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Be.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Be.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Be.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Be.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}"`:Be.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,Be.assertNever(r)}return{message:t}};let hh=ps;function ib(r){hh=r}function vo(){return hh}const bo=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.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{...s,path:i,message:o}},ab=[];function H(r,e){const t=vo(),n=bo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ps?void 0:ps].filter(s=>!!s)});r.common.issues.push(n)}class pt{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 s of t){if(s.status==="aborted")return ye;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return pt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ye;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const ye=Object.freeze({status:"aborted"}),xo=r=>({status:"dirty",value:r}),bt=r=>({status:"valid",value:r}),Ru=r=>r.status==="aborted",Pu=r=>r.status==="dirty",Pi=r=>r.status==="valid",$i=r=>typeof Promise<"u"&&r instanceof Promise;function _o(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 ph(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!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 Zi,Di;class pr{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const mh=(r,e)=>{if(Pi(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 Rt(r.common.issues);return this._error=t,this._error}}};function xe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=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:s}:{errorMap:(i,a)=>{var o,c;const{message:u}=r;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:s}}class ke{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 nn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:nn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new pt,ctx:{common:e.parent.common,data:e.data,parsedType:nn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if($i(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 s={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:nn(e)},i=this._parseSync({data:e,path:s.path,parent:s});return mh(s,i)}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:nn(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await($i(s)?s:Promise.resolve(s));return mh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:D.custom,...n(s)});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,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Qt({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return yr.create(this,this._def)}nullable(){return un.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xt.create(this,this._def)}promise(){return vs.create(this,this._def)}or(e){return Li.create([this,e],this._def)}and(e){return qi.create(this,e,this._def)}transform(e){return new Qt({...xe(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ki({...xe(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new Du({typeName:fe.ZodBranded,type:this,...xe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Gi({...xe(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 Ji.create(this,e)}readonly(){return Yi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ob=/^c[^\s-]{8,}$/i,cb=/^[0-9a-z]+$/,ub=/^[0-9A-HJKMNP-TV-Z]{26}$/,lb=/^[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,db=/^[a-z0-9_-]{21}$/i,fb=/^[-+]?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)?)??$/,hb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let $u;const mb=/^(?:(?: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])$/,yb=/^(([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})))$/,gb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yh="((\\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])))",vb=new RegExp(`^${yh}$`);function gh(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 bb(r){return new RegExp(`^${gh(r)}$`)}function vh(r){let e=`${yh}T${gh(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 xb(r,e){return!!((e==="v4"||!e)&&mb.test(r)||(e==="v6"||!e)&&yb.test(r))}class Yt extends ke{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:G.string,received:s.parsedType}),ye}const t=new pt;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?H(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&H(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")hb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"email",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")$u||($u=new RegExp(pb,"u")),$u.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"emoji",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")lb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"uuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")db.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"nanoid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")ob.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")cb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cuid2",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")ub.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"ulid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),H(n,{validation:"url",code:D.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"regex",code:D.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?vh(s).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?vb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?bb(s).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?fb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"duration",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?xb(e.data,s.version)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"ip",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?gb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"base64",code:D.invalid_string,message:s.message}),t.dirty()):Be.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:D.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new Yt({...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 Yt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Yt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Yt({...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}}Yt.create=r=>{var e;return new Yt({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};function _b(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class sn extends ke{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 s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:G.number,received:s.parsedType}),ye}let t;const n=new pt;for(const s of this._def.checks)s.kind==="int"?Be.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),H(t,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),H(t,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),H(t,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?_b(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),H(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),H(t,{code:D.not_finite,message:s.message}),n.dirty()):Be.assertNever(s);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,s){return new sn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new sn({...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"&&Be.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)}}sn.create=r=>new sn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class an extends ke{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 s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:G.bigint,received:s.parsedType}),ye}let t;const n=new pt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),H(t,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),H(t,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),H(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Be.assertNever(s);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,s){return new an({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new an({...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}}an.create=r=>{var e;return new an({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};class Mi extends ke{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:G.boolean,received:t.parsedType}),ye}return bt(e.data)}}Mi.create=r=>new Mi({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class In extends ke{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:G.date,received:s.parsedType}),ye}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_date}),ye}const t=new pt;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Be.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new In({...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}}In.create=r=>new In({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...xe(r)});class wo extends ke{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:G.symbol,received:t.parsedType}),ye}return bt(e.data)}}wo.create=r=>new wo({typeName:fe.ZodSymbol,...xe(r)});class Vi extends ke{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:G.undefined,received:t.parsedType}),ye}return bt(e.data)}}Vi.create=r=>new Vi({typeName:fe.ZodUndefined,...xe(r)});class Ui extends ke{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:G.null,received:t.parsedType}),ye}return bt(e.data)}}Ui.create=r=>new Ui({typeName:fe.ZodNull,...xe(r)});class ms extends ke{constructor(){super(...arguments),this._any=!0}_parse(e){return bt(e.data)}}ms.create=r=>new ms({typeName:fe.ZodAny,...xe(r)});class jn extends ke{constructor(){super(...arguments),this._unknown=!0}_parse(e){return bt(e.data)}}jn.create=r=>new jn({typeName:fe.ZodUnknown,...xe(r)});class Nr extends ke{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:G.never,received:t.parsedType}),ye}}Nr.create=r=>new Nr({typeName:fe.ZodNever,...xe(r)});class ko extends ke{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:G.void,received:t.parsedType}),ye}return bt(e.data)}}ko.create=r=>new ko({typeName:fe.ZodVoid,...xe(r)});class Xt extends ke{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==G.array)return H(t,{code:D.invalid_type,expected:G.array,received:t.parsedType}),ye;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(H(t,{code:a?D.too_big:D.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(H(t,{code:D.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(H(t,{code:D.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new pr(t,a,t.path,o)))).then(a=>pt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new pr(t,a,t.path,o)));return pt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Xt({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new Xt({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new Xt({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}Xt.create=(r,e)=>new Xt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...xe(e)});function ys(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=yr.create(ys(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof Xt?new Xt({...r._def,type:ys(r.element)}):r instanceof yr?yr.create(ys(r.unwrap())):r instanceof un?un.create(ys(r.unwrap())):r instanceof mr?mr.create(r.items.map(e=>ys(e))):r}class Je extends ke{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=Be.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const c=this._getOrReturnCtx(e);return H(c,{code:D.invalid_type,expected:G.object,received:c.parsedType}),ye}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Nr&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||a.push(c);const o=[];for(const c of i){const u=s[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new pr(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Nr){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&&(H(n,{code:D.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 pr(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=>pt.mergeObjectSync(t,c)):pt.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 s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,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 Be.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 Be.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return ys(this)}partial(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof yr;)s=s._def.innerType;t[n]=s}}),new Je({...this._def,shape:()=>t})}keyof(){return bh(Be.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Nr.create(),typeName:fe.ZodObject,...xe(e)}),Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Nr.create(),typeName:fe.ZodObject,...xe(e)}),Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Nr.create(),typeName:fe.ZodObject,...xe(e)});class Li extends ke{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Rt(o.ctx.common.issues));return H(t,{code:D.invalid_union,unionErrors:a}),ye}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;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"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Rt(c));return H(t,{code:D.invalid_union,unionErrors:o}),ye}}get options(){return this._def.options}}Li.create=(r,e)=>new Li({options:r,typeName:fe.ZodUnion,...xe(e)});const on=r=>r instanceof Fi?on(r.schema):r instanceof Qt?on(r.innerType()):r instanceof Wi?[r.value]:r instanceof cn?r.options:r instanceof zi?Be.objectValues(r.enum):r instanceof Ki?on(r._def.innerType):r instanceof Vi?[void 0]:r instanceof Ui?[null]:r instanceof yr?[void 0,...on(r.unwrap())]:r instanceof un?[null,...on(r.unwrap())]:r instanceof Du||r instanceof Yi?on(r.unwrap()):r instanceof Gi?on(r._def.innerType):[];class So extends ke{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return H(t,{code:D.invalid_type,expected:G.object,received:t.parsedType}),ye;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ye)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=on(i.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(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new So({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...xe(n)})}}function Zu(r,e){const t=nn(r),n=nn(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const s=Be.objectKeys(e),i=Be.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Zu(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 s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Zu(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class qi extends ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Ru(i)||Ru(a))return ye;const o=Zu(i.value,a.value);return o.valid?((Pu(i)||Pu(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:D.invalid_intersection_types}),ye)};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(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}qi.create=(r,e,t)=>new qi({left:r,right:e,typeName:fe.ZodIntersection,...xe(t)});class mr extends ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return H(n,{code:D.invalid_type,expected:G.array,received:n.parsedType}),ye;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"}),ye;!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((i,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new pr(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>pt.mergeArray(t,i)):pt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new mr({...this._def,rest:e})}}mr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mr({items:r,typeName:fe.ZodTuple,rest:null,...xe(e)})};class Hi extends ke{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 H(n,{code:D.invalid_type,expected:G.object,received:n.parsedType}),ye;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new pr(n,o,n.path,o)),value:a._parse(new pr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?pt.mergeObjectAsync(t,s):pt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof ke?new Hi({keyType:e,valueType:t,typeName:fe.ZodRecord,...xe(n)}):new Hi({keyType:Yt.create(),valueType:e,typeName:fe.ZodRecord,...xe(t)})}}class Ao extends ke{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 H(n,{code:D.invalid_type,expected:G.map,received:n.parsedType}),ye;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new pr(n,o,n.path,[u,"key"])),value:i._parse(new pr(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 ye;(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 ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Ao.create=(r,e,t)=>new Ao({valueType:e,keyType:r,typeName:fe.ZodMap,...xe(t)});class Tn extends ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return H(n,{code:D.invalid_type,expected:G.set,received:n.parsedType}),ye;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(H(n,{code:D.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(H(n,{code:D.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ye;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new pr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Tn({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new Tn({...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)}}Tn.create=(r,e)=>new Tn({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...xe(e)});class gs extends ke{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return H(t,{code:D.invalid_type,expected:G.function,received:t.parsedType}),ye;function n(o,c){return bo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,vo(),ps].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function s(o,c){return bo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,vo(),ps].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof vs){const o=this;return bt(async function(...c){const u=new Rt([]),f=await o._def.args.parseAsync(c,i).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,i).catch(B=>{throw u.addIssue(s(m,B)),u})})}else{const o=this;return bt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Rt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Rt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new gs({...this._def,args:mr.create(e).rest(jn.create())})}returns(e){return new gs({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new gs({args:e||mr.create([]).rest(jn.create()),returns:t||jn.create(),typeName:fe.ZodFunction,...xe(n)})}}class Fi extends ke{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})}}Fi.create=(r,e)=>new Fi({getter:r,typeName:fe.ZodLazy,...xe(e)});class Wi extends ke{_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}),ye}return{status:"valid",value:e.data}}get value(){return this._def.value}}Wi.create=(r,e)=>new Wi({value:r,typeName:fe.ZodLiteral,...xe(e)});function bh(r,e){return new cn({values:r,typeName:fe.ZodEnum,...xe(e)})}class cn extends ke{constructor(){super(...arguments),Zi.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Be.joinValues(n),received:t.parsedType,code:D.invalid_type}),ye}if(_o(this,Zi)||ph(this,Zi,new Set(this._def.values)),!_o(this,Zi).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}),ye}return bt(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 cn.create(e,{...this._def,...t})}exclude(e,t=this._def){return cn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Zi=new WeakMap,cn.create=bh;class zi extends ke{constructor(){super(...arguments),Di.set(this,void 0)}_parse(e){const t=Be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const s=Be.objectValues(t);return H(n,{expected:Be.joinValues(s),received:n.parsedType,code:D.invalid_type}),ye}if(_o(this,Di)||ph(this,Di,new Set(Be.getValidEnumValues(this._def.values))),!_o(this,Di).has(e.data)){const s=Be.objectValues(t);return H(n,{received:n.data,code:D.invalid_enum_value,options:s}),ye}return bt(e.data)}get enum(){return this._def.values}}Di=new WeakMap,zi.create=(r,e)=>new zi({values:r,typeName:fe.ZodNativeEnum,...xe(e)});class vs extends ke{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return H(t,{code:D.invalid_type,expected:G.promise,received:t.parsedType}),ye;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return bt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}vs.create=(r,e)=>new vs({type:r,typeName:fe.ZodPromise,...xe(e)});class Qt extends ke{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),s=this._def.effect||null,i={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ye;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ye:c.status==="dirty"||t.value==="dirty"?xo(c.value):c});{if(t.value==="aborted")return ye;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ye:o.status==="dirty"||t.value==="dirty"?xo(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);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"?ye:(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"?ye:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Pi(a))return a;const o=s.transform(a.value,i);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=>Pi(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Be.assertNever(s)}}Qt.create=(r,e,t)=>new Qt({schema:r,typeName:fe.ZodEffects,effect:e,...xe(t)}),Qt.createWithPreprocess=(r,e,t)=>new Qt({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...xe(t)});class yr extends ke{_parse(e){return this._getType(e)===G.undefined?bt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}yr.create=(r,e)=>new yr({innerType:r,typeName:fe.ZodOptional,...xe(e)});class un extends ke{_parse(e){return this._getType(e)===G.null?bt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}un.create=(r,e)=>new un({innerType:r,typeName:fe.ZodNullable,...xe(e)});class Ki extends ke{_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}}Ki.create=(r,e)=>new Ki({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class Gi extends ke{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $i(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Gi.create=(r,e)=>new Gi({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class Oo extends ke{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:G.nan,received:t.parsedType}),ye}return{status:"valid",value:e.data}}}Oo.create=r=>new Oo({typeName:fe.ZodNaN,...xe(r)});const wb=Symbol("zod_brand");class Du extends ke{_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 Ji extends ke{_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"?ye:s.status==="dirty"?(t.dirty(),xo(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ji({in:e,out:t,typeName:fe.ZodPipeline})}}class Yi extends ke{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Pi(s)&&(s.value=Object.freeze(s.value)),s);return $i(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Yi.create=(r,e)=>new Yi({innerType:r,typeName:fe.ZodReadonly,...xe(e)});function xh(r,e={},t){return r?ms.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):ms.create()}const kb={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 Sb=(r,e={message:`Input not instance of ${r.name}`})=>xh(t=>t instanceof r,e),_h=Yt.create,wh=sn.create,Ab=Oo.create,Ob=an.create,kh=Mi.create,Eb=In.create,Cb=wo.create,Ib=Vi.create,jb=Ui.create,Tb=ms.create,Nb=jn.create,Bb=Nr.create,Rb=ko.create,Pb=Xt.create,$b=Je.create,Zb=Je.strictCreate,Db=Li.create,Mb=So.create,Vb=qi.create,Ub=mr.create,Lb=Hi.create,qb=Ao.create,Hb=Tn.create,Fb=gs.create,Wb=Fi.create,zb=Wi.create,Kb=cn.create,Gb=zi.create,Jb=vs.create,Sh=Qt.create,Yb=yr.create,Xb=un.create,Qb=Qt.createWithPreprocess,ex=Ji.create;var d=Object.freeze({__proto__:null,defaultErrorMap:ps,setErrorMap:ib,getErrorMap:vo,makeIssue:bo,EMPTY_PATH:ab,addIssueToContext:H,ParseStatus:pt,INVALID:ye,DIRTY:xo,OK:bt,isAborted:Ru,isDirty:Pu,isValid:Pi,isAsync:$i,get util(){return Be},get objectUtil(){return Bu},ZodParsedType:G,getParsedType:nn,ZodType:ke,datetimeRegex:vh,ZodString:Yt,ZodNumber:sn,ZodBigInt:an,ZodBoolean:Mi,ZodDate:In,ZodSymbol:wo,ZodUndefined:Vi,ZodNull:Ui,ZodAny:ms,ZodUnknown:jn,ZodNever:Nr,ZodVoid:ko,ZodArray:Xt,ZodObject:Je,ZodUnion:Li,ZodDiscriminatedUnion:So,ZodIntersection:qi,ZodTuple:mr,ZodRecord:Hi,ZodMap:Ao,ZodSet:Tn,ZodFunction:gs,ZodLazy:Fi,ZodLiteral:Wi,ZodEnum:cn,ZodNativeEnum:zi,ZodPromise:vs,ZodEffects:Qt,ZodTransformer:Qt,ZodOptional:yr,ZodNullable:un,ZodDefault:Ki,ZodCatch:Gi,ZodNaN:Oo,BRAND:wb,ZodBranded:Du,ZodPipeline:Ji,ZodReadonly:Yi,custom:xh,Schema:ke,ZodSchema:ke,late:kb,get ZodFirstPartyTypeKind(){return fe},coerce:{string:r=>Yt.create({...r,coerce:!0}),number:r=>sn.create({...r,coerce:!0}),boolean:r=>Mi.create({...r,coerce:!0}),bigint:r=>an.create({...r,coerce:!0}),date:r=>In.create({...r,coerce:!0})},any:Tb,array:Pb,bigint:Ob,boolean:kh,date:Eb,discriminatedUnion:Mb,effect:Sh,enum:Kb,function:Fb,instanceof:Sb,intersection:Vb,lazy:Wb,literal:zb,map:qb,nan:Ab,nativeEnum:Gb,never:Bb,null:jb,nullable:Xb,number:wh,object:$b,oboolean:()=>kh().optional(),onumber:()=>wh().optional(),optional:Yb,ostring:()=>_h().optional(),pipeline:ex,preprocess:Qb,promise:Jb,record:Lb,set:Hb,strictObject:Zb,string:_h,symbol:Cb,transformer:Sh,tuple:Ub,undefined:Ib,union:Db,unknown:Nb,void:Rb,NEVER:ye,ZodIssueCode:D,quotelessJson:sb,ZodError:Rt});nb(d);const Nn=d.object({start:d.number(),limit:d.number(),length:d.number()}),Mu=d.object({created_at:d.string(),updated_at:d.string()}),tx=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()),rx=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:tx.optional()}),Vu=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()}),Uu=Vu.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")}),Ah=d.object({...Uu.shape,...Mu.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(rx).optional()}),Br=Ah;Vu.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());const nx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let sx=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=nx[t[r]&63];return e};const ix=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()}),Lu=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:ix.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(()=>sx()).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"})}),bs=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...Lu.shape});var Oh=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(Oh||{}),Eh=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(Eh||{}),Ch=(r=>(r.S265="S256",r.plain="plain",r))(Ch||{});const ax=d.object({client_id:d.string(),vendor_id:d.string().optional(),response_type:d.nativeEnum(Oh).optional(),response_mode:d.nativeEnum(Eh).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(Ch).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),Ih=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()}),qu=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","Username-Password-Authentication","oidc","oauth2","custom"]).optional(),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()}),xs=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(qu.shape),Hu=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()}),Xi=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...Hu.shape});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()});const ox=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({...bs.shape,domains:d.array(ox),tenant:Xi,connections:d.array(xs)});const cx=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ux=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:cx,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()});d.object({...ux.shape,created_at:d.string()});const lx=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"])});Mu.extend({...lx.shape,id:d.string()});const Fu=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()}),Qi=Fu.extend({...Mu.shape,hook_id:d.string()}),jh=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()}),dx=d.object({keys:d.array(jh)}),Th=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())}),fx=d.object({auth0Client:d.string().optional(),authParams:ax,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional()}).openapi({description:"This represents a login sesion"});d.object({...fx.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 Wu=(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))(Wu||{});const hx=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"]),px=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),zu=d.object({type:hx,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:px.optional()}),mx=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")});d.object({...mx.shape,created_at:d.string(),updated_at:d.string()});const yx=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()}),Nh=d.object({created_at:d.string(),...yx.shape});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 Bh=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(Bh||{});const Ku=d.nativeEnum(Bh);d.object({grant_type:Ku.refine(r=>r==="authorization_code"),code:d.string(),client_secret:d.string(),client_id:d.string()}),d.object({grant_type:Ku.refine(r=>r==="authorization_code"),code:d.string(),code_verifier:d.string(),client_id:d.string().optional(),redirect_uri:d.string()}),d.object({grant_type:Ku.refine(r=>r==="client_credentials"),scope:d.string().optional(),client_secret:d.string(),client_id:d.string(),audience:d.string().optional()}),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 gx=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()}),vx=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()}),_s=d.object({bold:d.boolean(),size:d.number()}),bx=d.object({body_text:_s,buttons_text:_s,font_url:d.string(),input_labels:_s,links:_s,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:_s,title:_s}),xx=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),_x=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"])});d.object({borders:gx,colors:vx,displayName:d.string(),fonts:bx,page_background:xx,widget:_x}).extend({themeId:d.string()});const Gu=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()});var Eo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wx(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function kx(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 s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
1
+ var authhero=function(He){"use strict";var Ek=Object.defineProperty;var Ug=He=>{throw TypeError(He)};var Ck=(He,Le,ie)=>Le in He?Ek(He,Le,{enumerable:!0,configurable:!0,writable:!0,value:ie}):He[Le]=ie;var H=(He,Le,ie)=>Ck(He,typeof Le!="symbol"?Le+"":Le,ie),Ef=(He,Le,ie)=>Le.has(He)||Ug("Cannot "+ie);var P=(He,Le,ie)=>(Ef(He,Le,"read from private field"),ie?ie.call(He):Le.get(He)),We=(He,Le,ie)=>Le.has(He)?Ug("Cannot add the same private member more than once"):Le instanceof WeakSet?Le.add(He):Le.set(He,ie),Te=(He,Le,ie,io)=>(Ef(He,Le,"write to private field"),io?io.call(He,ie):Le.set(He,ie),ie),Ce=(He,Le,ie)=>(Ef(He,Le,"access private method"),ie);var ni,dr,zr,Lg,qg,Cf,On,Eg,Xa,Qa,Gr,ss,Jr,Qe,tt,Ir,Yr,eo,si,ii,to,ro,Bt,Jt,Cg,fr,ot,Hg,Xr,En,as,vu,bu,Ig,ai,Fg,Wg,jg,Qr,os,Tg;function Le(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 s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}typeof SuppressedError=="function"&&SuppressedError;function ie(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function io(r){return"_def"in r}function oi(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function t0(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const B=typeof s=="string"?i:s,C=B??{},{param:p}=C,y=Le(C,["param"]),S=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof s=="string"?{refId:s}:void 0),A=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),y),!((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),R=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(S).length>0?{_internal:S}:void 0),Object.keys(A).length>0?{metadata:A}:void 0)}));if(ie(this,"ZodObject")){const T=this.extend;R.extend=function(...ve){var Ue,qe,Ze,nt,bt,Vt;const E=T.apply(this,ve);return E._def.openapi={_internal:{extendedFrom:!((qe=(Ue=this._def.openapi)===null||Ue===void 0?void 0:Ue._internal)===null||qe===void 0)&&qe.refId?{refId:(nt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||nt===void 0?void 0:nt.refId,schema:this}:(bt=this._def.openapi)===null||bt===void 0?void 0:bt._internal.extendedFrom},metadata:(Vt=E._def.openapi)===null||Vt===void 0?void 0:Vt.metadata},E}}return R},oi(r,"optional"),oi(r,"nullable"),oi(r,"default"),oi(r,"transform"),oi(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}function ao(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=>ao(r[n],e[n]))}class r0{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(i=>ao(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>ao(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const i of this.buckets.values())e+=1,t+=i.length,i.length>1&&(n+=1);const s=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:s}}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,s]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(s??"");return t}}function ci(r){return r==null}function ui(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function n0(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function cs(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function Pf(r){return r.filter(e=>!ci(e))}const wu=ao;function s0(r){const e=new r0;return r.forEach(t=>e.put(t)),[...e.values()]}function $f(r){return typeof r=="string"}class i0{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,s,i;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:(i=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&i!==void 0?i: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 oo{constructor(e){this.message=e}}class li extends oo{constructor(e,t){super(e),this.data=t}}class co extends oo{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 di(r,e){try{return r()}catch(t){throw t instanceof co?new co(Object.assign(Object.assign({},t.data),e)):t}}class a0 extends oo{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class Ge{static getMetadata(e){var t;const n=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:n._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:i},s==null?void 0:s.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 s=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:s._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign(Object.assign({},i==null?void 0:i.metadata),{param:Object.assign({description:a},(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return cs(n0(e,["param"]),ci)}static buildParameterMetadata(e){return cs(e,ci)}static applySchemaMetadata(e,t){return cs(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),ci)}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&&ie(e,t)?e:ie(e,"ZodOptional")||ie(e,"ZodNullable")||ie(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):ie(e,"ZodDefault")||ie(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):ie(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):ie(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return ie(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class o0{transform(e,t,n){var s,i;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(i=e._def.maxLength)===null||i===void 0?void 0:i.value})}}class c0{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class u0{transform(e,t,n,s,i){const a=[...e.options.values()],o=a.map(s);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,i)}}mapDiscriminator(e,t,n){if(e.some(i=>Ge.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=Ge.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(ie(c,"ZodEnum")||ie(c,"ZodNativeEnum")){Object.values(c.enum).filter($f).forEach(m=>{s[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`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class l0{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class d0{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!ie(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class f0{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function h0(r){const t=Object.keys(r).filter(i=>typeof r[r[i]]!="number").map(i=>r[i]),n=t.filter(i=>typeof i=="number").length,s=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:s}}class p0{transform(e,t){const{type:n,values:s}=h0(e._def.values);if(n==="mixed")throw new oo("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:s})}}class m0{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class y0{transform(e,t,n,s){var i;const a=(i=Ge.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=ui(e._def.shape(),s);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,s));const u=a.schema;s(u);const f=this.requiredKeysOf(u),m=ui(u==null?void 0:u._def.shape(),s),B=Object.fromEntries(Object.entries(c).filter(([y,S])=>!wu(m[y],S))),C=o.filter(y=>!f.includes(y)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:B}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return ie(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!Ge.isOptionalSchema(n)).map(([t,n])=>t)}}class g0{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(ie(i,"ZodEnum")||ie(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter($f).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 v0{transform(e,t){var n,s,i;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)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(i=e.maxLength)!==null&&i!==void 0?i: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 b0{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:s}=e._def,i=s.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(i))}}class x0{transform(e,t,n){const i=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(i)}}flattenUnionTypes(e){return ie(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return ie(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class _0{constructor(e){this.versionSpecifics=e,this.objectTransformer=new y0,this.stringTransformer=new v0,this.numberTransformer=new m0,this.bigIntTransformer=new c0,this.literalTransformer=new f0,this.enumTransformer=new l0,this.nativeEnumTransformer=new p0,this.arrayTransformer=new o0,this.unionTransformer=new x0,this.discriminatedUnionTransformer=new u0,this.intersectionTransformer=new d0,this.recordTransformer=new g0,this.tupleTransformer=new b0(e)}transform(e,t,n,s,i){if(ie(e,"ZodNull"))return this.versionSpecifics.nullType;if(ie(e,"ZodUnknown")||ie(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(ie(e,"ZodObject"))return this.objectTransformer.transform(e,i,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,s);return Object.assign(Object.assign({},a),{default:i})}transformSchemaWithoutDefault(e,t,n,s){if(ie(e,"ZodUnknown")||ie(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(ie(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(ie(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(ie(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ie(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ie(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ie(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(ie(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(ie(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(ie(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ie(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=Ge.getRefId(e);throw new a0({currentSchema:e._def,schemaName:i})}}class Zf{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new _0(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:s,name:i,component:a})=>{var o;(o=n[s])!==null&&o!==void 0||(n[s]={}),n[s][i]=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 s=e.findIndex(a=>a===t.type),i=e.findIndex(a=>a===n.type);return s-i})}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=Ge.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,s,i,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(i=e._internal)===null||i===void 0?void 0:i.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 li(`Conflicting location for parameter ${u.name}`,{key:"in",values:Pf([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 li("Conflicting names for parameter",{key:"name",values:Pf([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 s=Ge.getMetadata(e),i=(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(s,{in:t});if(a)return[a];if(ie(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,B;const C=Ge.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const y=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(y!=null&&y.name&&y.name!==u)throw new li("Conflicting names for parameter",{key:"name",values:[u,y.name]});if(y!=null&&y.in&&y.in!==t)throw new li(`Conflicting location for parameter ${(B=y.name)!==null&&B!==void 0?B:u}`,{key:"in",values:[t,y.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(i!=null&&i.in&&i.in!==t)throw new li(`Conflicting location for parameter ${i.name}`,{key:"in",values:[t,i.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=Ge.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!Ge.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?Ge.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=Ge.getMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=s==null?void 0:s.name,a=s==null?void 0:s.in;if(!i)throw new co({missingField:"name"});if(!a)throw new co({missingField:"in",paramName:i});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:i})}generateSchemaWithMetadata(e){var t;const n=Ge.unwrapChained(e),s=Ge.getMetadata(e),i=Ge.getDefaultValue(e),a=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),i);return s!=null&&s.metadata?Ge.applySchemaMetadata(a,s.metadata):cs(a,ci)}constructReferencedOpenAPISchema(e){var t;const n=Ge.getMetadata(e),s=Ge.unwrapChained(e),i=Ge.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(s,a,i)}generateSimpleSchema(e){var t;const n=Ge.getMetadata(e),s=Ge.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=cs(Ge.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||wu(f,i[m]));if(o.type)return{allOf:[a,o]};const c=cs(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||wu(f,i[m])),u=Ge.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=Ge.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=Le(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),s=this.cleanParameter(e.params),i=this.cleanParameter(e.cookies),a=di(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=di(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=di(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=di(()=>{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 ie(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=Le(e,["method","path","request","responses"]),o=ui(i,m=>this.getResponse(m)),c=di(()=>this.getParameters(s),{route:`${t} ${n}`}),u=this.getRequestBody(s==null?void 0:s.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,s=Le(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=ie(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},s),{headers:a}),i)}getResponseHeaders(e){const t=e._def.shape();return ui(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return ui(e,t=>{if(!t||!io(t.schema))return t;const{schema:n}=t,s=Le(t,["schema"]),i=this.generateSchemaWithRef(n);return Object.assign({schema:i},s)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),n)}}class w0{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=s0(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 k0{constructor(e){const t=new w0;this.generator=new Zf(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class S0{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 A0(r){return"type"in r&&r.type==="webhook"}class O0{constructor(e){this.definitions=e,this.webhookRefs={};const t=new S0;this.generator=new Zf(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(A0).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 Df=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},E0=r=>{const{groups:e,path:t}=C0(r),n=Df(t);return I0(n,e)},C0=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},I0=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let s=r.length-1;s>=0;s--)if(r[s].includes(n)){r[s]=r[s].replace(n,e[t][1]);break}}return r},uo={},Mf=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(uo[r]||(e[2]?uo[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:uo[r]=[r,e[1],!0]),uo[r]):null},Vf=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},j0=r=>Vf(r,decodeURI),Uf=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const s=e.charCodeAt(n);if(s===37){const i=e.indexOf("?",n),a=e.slice(t,i===-1?void 0:i);return j0(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},T0=r=>{const e=Uf(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},en=(...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},Lf=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))n+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&n===""?t.push("/"):t.push(n);const i=s.replace("?","");n+="/"+i,t.push(n)}else n+="/"+s}),t.filter((s,i,a)=>a.indexOf(s)===i)},ku=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?Su(r):r):r,qf=(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 ku(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 s={};n??(n=/[%+]/.test(r));let i=r.indexOf("?",8);for(;i!==-1;){const a=r.indexOf("&",i+1);let o=r.indexOf("=",i);o>a&&a!==-1&&(o=-1);let c=r.slice(i+1,o===-1?a===-1?void 0:a:o);if(n&&(c=ku(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=ku(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},N0=qf,B0=(r,e)=>qf(r,e,!0),Su=decodeURIComponent,R0=/^[\w!#$%&'*.^`|~+-]+$/,P0=/^[ !#-:<-[\]-~]*$/,$0=(r,e)=>{const t=r.trim().split(";"),n={};for(let s of t){s=s.trim();const i=s.indexOf("=");if(i===-1)continue;const a=s.substring(0,i).trim();if(!R0.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),P0.test(o)&&(n[a]=Su(o))}return n},Z0=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?$0(n):{}},$e=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});H(this,"res");H(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})}},D0=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),M0=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,V0=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,U0=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,L0=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!M0.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new $e(400,{message:o})}break;case"form":{if(!i||!(V0.test(i)||U0.test(i)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await D0(u,i),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new $e(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}),s=c;break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=Z0(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const us=(r,e,t)=>L0(r,async(n,s)=>{const i=await e.safeParseAsync(n);if(t){const a=await t({data:n,...i,target:r},s);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return i.success?i.data:s.json(i,400)});var q0=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof Ff?r.raw.headers:r.headers).get("Content-Type");return i!=null&&i.startsWith("multipart/form-data")||i!=null&&i.startsWith("application/x-www-form-urlencoded")?H0(r,{all:t,dot:n}):{}};async function H0(r,e){const t=await r.formData();return t?F0(t,e):{}}function F0(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?W0(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(K0(t,n,s),delete t[n])}),t}var W0=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},K0=(r,e,t)=>{let n=r;const s=e.split(".");s.forEach((i,a)=>{a===s.length-1?n[i]=t:((!n[i]||typeof n[i]!="object"||Array.isArray(n[i])||n[i]instanceof File)&&(n[i]=Object.create(null)),n=n[i])})},Hf=r=>Vf(r,Su),Ff=(Eg=class{constructor(r,e="/",t=[[]]){We(this,zr);H(this,"raw");We(this,ni);We(this,dr);H(this,"routeIndex",0);H(this,"path");H(this,"bodyCache",{});We(this,On,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const s=Object.keys(e)[0];return s?e[s].then(i=>(s==="json"&&(i=JSON.stringify(i)),new Response(i)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,Te(this,dr,t),Te(this,ni,{})}param(r){return r?Ce(this,zr,Lg).call(this,r):Ce(this,zr,qg).call(this)}query(r){return N0(this.url,r)}queries(r){return B0(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 q0(this,r))}json(){return P(this,On).call(this,"json")}text(){return P(this,On).call(this,"text")}arrayBuffer(){return P(this,On).call(this,"arrayBuffer")}blob(){return P(this,On).call(this,"blob")}formData(){return P(this,On).call(this,"formData")}addValidatedData(r,e){P(this,ni)[r]=e}valid(r){return P(this,ni)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return P(this,dr)[0].map(([[,r]])=>r)}get routePath(){return P(this,dr)[0].map(([[,r]])=>r)[this.routeIndex].path}},ni=new WeakMap,dr=new WeakMap,zr=new WeakSet,Lg=function(r){const e=P(this,dr)[0][this.routeIndex][1][r],t=Ce(this,zr,Cf).call(this,e);return t?/\%/.test(t)?Hf(t):t:void 0},qg=function(){const r={},e=Object.keys(P(this,dr)[0][this.routeIndex][1]);for(const t of e){const n=Ce(this,zr,Cf).call(this,P(this,dr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?Hf(n):n)}return r},Cf=function(r){return P(this,dr)[1]?P(this,dr)[1][r]:r},On=new WeakMap,Eg),z0={Stringify:1,BeforeStream:2,Stream:3},Wf=async(r,e,t,n,s)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const i=r.callbacks;return i!=null&&i.length?(s?s[0]+=r:s=[r],Promise.all(i.map(o=>o({phase:e,buffer:s,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Wf(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},G0="text/plain; charset=UTF-8",Au=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Kf=(Cg=class{constructor(r,e){We(this,Bt);We(this,Xa);We(this,Qa);H(this,"env",{});We(this,Gr);H(this,"finalized",!1);H(this,"error");We(this,ss,200);We(this,Jr);We(this,Qe);We(this,tt);We(this,Ir);We(this,Yr,!0);We(this,eo);We(this,si);We(this,ii);We(this,to);We(this,ro);H(this,"render",(...r)=>(P(this,si)??Te(this,si,e=>this.html(e)),P(this,si).call(this,...r)));H(this,"setLayout",r=>Te(this,eo,r));H(this,"getLayout",()=>P(this,eo));H(this,"setRenderer",r=>{Te(this,si,r)});H(this,"header",(r,e,t)=>{if(e===void 0){P(this,Qe)?P(this,Qe).delete(r):P(this,tt)&&delete P(this,tt)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(P(this,Qe)||(Te(this,Yr,!1),Te(this,Qe,new Headers(P(this,tt))),Te(this,tt,{})),P(this,Qe).append(r,e)):P(this,Qe)?P(this,Qe).set(r,e):(P(this,tt)??Te(this,tt,{}),P(this,tt)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});H(this,"status",r=>{Te(this,Yr,!1),Te(this,ss,r)});H(this,"set",(r,e)=>{P(this,Gr)??Te(this,Gr,new Map),P(this,Gr).set(r,e)});H(this,"get",r=>P(this,Gr)?P(this,Gr).get(r):void 0);H(this,"newResponse",(...r)=>Ce(this,Bt,Jt).call(this,...r));H(this,"body",(r,e,t)=>typeof e=="number"?Ce(this,Bt,Jt).call(this,r,e,t):Ce(this,Bt,Jt).call(this,r,e));H(this,"text",(r,e,t)=>{if(!P(this,tt)){if(P(this,Yr)&&!t&&!e)return new Response(r);Te(this,tt,{})}return P(this,tt)["content-type"]=G0,typeof e=="number"?Ce(this,Bt,Jt).call(this,r,e,t):Ce(this,Bt,Jt).call(this,r,e)});H(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return P(this,tt)??Te(this,tt,{}),P(this,tt)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Ce(this,Bt,Jt).call(this,n,e,t):Ce(this,Bt,Jt).call(this,n,e)});H(this,"html",(r,e,t)=>(P(this,tt)??Te(this,tt,{}),P(this,tt)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Wf(r,z0.Stringify,!1,{}).then(n=>typeof e=="number"?Ce(this,Bt,Jt).call(this,n,e,t):Ce(this,Bt,Jt).call(this,n,e)):typeof e=="number"?Ce(this,Bt,Jt).call(this,r,e,t):Ce(this,Bt,Jt).call(this,r,e)));H(this,"redirect",(r,e)=>(P(this,Qe)??Te(this,Qe,new Headers),P(this,Qe).set("Location",String(r)),this.newResponse(null,e??302)));H(this,"notFound",()=>(P(this,ii)??Te(this,ii,()=>new Response),P(this,ii).call(this,this)));Te(this,Xa,r),e&&(Te(this,Jr,e.executionCtx),this.env=e.env,Te(this,ii,e.notFoundHandler),Te(this,ro,e.path),Te(this,to,e.matchResult))}get req(){return P(this,Qa)??Te(this,Qa,new Ff(P(this,Xa),P(this,ro),P(this,to))),P(this,Qa)}get event(){if(P(this,Jr)&&"respondWith"in P(this,Jr))return P(this,Jr);throw Error("This context has no FetchEvent")}get executionCtx(){if(P(this,Jr))return P(this,Jr);throw Error("This context has no ExecutionContext")}get res(){return Te(this,Yr,!1),P(this,Ir)||Te(this,Ir,new Response("404 Not Found",{status:404}))}set res(r){if(Te(this,Yr,!1),P(this,Ir)&&r)try{for(const[e,t]of P(this,Ir).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=P(this,Ir).headers.getSetCookie();r.headers.delete("set-cookie");for(const s of n)r.headers.append("set-cookie",s)}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}Te(this,Ir,r),this.finalized=!0}get var(){return P(this,Gr)?Object.fromEntries(P(this,Gr)):{}}},Xa=new WeakMap,Qa=new WeakMap,Gr=new WeakMap,ss=new WeakMap,Jr=new WeakMap,Qe=new WeakMap,tt=new WeakMap,Ir=new WeakMap,Yr=new WeakMap,eo=new WeakMap,si=new WeakMap,ii=new WeakMap,to=new WeakMap,ro=new WeakMap,Bt=new WeakSet,Jt=function(r,e,t){if(P(this,Yr)&&!t&&!e&&P(this,ss)===200)return new Response(r,{headers:P(this,tt)});if(e&&typeof e!="number"){const s=new Headers(e.headers);P(this,Qe)&&P(this,Qe).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=Au(s,P(this,tt));return new Response(r,{headers:i,status:e.status??P(this,ss)})}const n=typeof e=="number"?e:P(this,ss);P(this,tt)??Te(this,tt,{}),P(this,Qe)??Te(this,Qe,new Headers),Au(P(this,Qe),P(this,tt)),P(this,Ir)&&(P(this,Ir).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=P(this,Qe))==null||a.append(i,s):(o=P(this,Qe))==null||o.set(i,s)}),Au(P(this,Qe),P(this,tt))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")P(this,Qe).set(s,i);else{P(this,Qe).delete(s);for(const a of i)P(this,Qe).append(s,a)}return new Response(r,{status:n,headers:P(this,Qe)})},Cg),zf=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof Kf;return o(0);async function o(c){if(c<=i)throw new Error("next() called multiple times");i=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&s||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",J0="all",Y0=["get","post","put","delete","options","patch"],Gf="Can not add a route since the matcher is already built.",Jf=class extends Error{},X0=Symbol("composedHandler"),Q0=r=>r.text("404 Not Found",404),Yf=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),Xf=(Ig=class{constructor(e={}){We(this,ot);H(this,"get");H(this,"post");H(this,"put");H(this,"delete");H(this,"options");H(this,"patch");H(this,"all");H(this,"on");H(this,"use");H(this,"router");H(this,"getPath");H(this,"_basePath","/");We(this,fr,"/");H(this,"routes",[]);We(this,Xr,Q0);We(this,En,Yf);H(this,"onError",e=>(Te(this,En,e),this));H(this,"notFound",e=>(Te(this,Xr,e),this));H(this,"fetch",(e,...t)=>Ce(this,ot,bu).call(this,e,t[1],t[0],e.method));H(this,"request",(e,t,n,s)=>{if(e instanceof Request)return t!==void 0&&(e=new Request(e,t)),this.fetch(e,n,s);e=e.toString();const i=/^https?:\/\//.test(e)?e:`http://localhost${en("/",e)}`,a=new Request(i,t);return this.fetch(a,n,s)});H(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Ce(this,ot,bu).call(this,e.request,e,void 0,e.request.method))})});[...Y0,J0].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?Te(this,fr,i):Ce(this,ot,as).call(this,s,P(this,fr),i),a.forEach(o=>{typeof o!="string"&&Ce(this,ot,as).call(this,s,P(this,fr),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){Te(this,fr,o);for(const c of[s].flat())a.map(u=>{Ce(this,ot,as).call(this,c.toUpperCase(),P(this,fr),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?Te(this,fr,s):(Te(this,fr,"*"),i.unshift(s)),i.forEach(a=>{Ce(this,ot,as).call(this,it,P(this,fr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Uf:T0}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{var a;let i;P(t,En)===Yf?i=s.handler:(i=async(o,c)=>(await zf([],P(t,En))(o,()=>s.handler(o,c))).res,i[X0]=s.handler),Ce(a=n,ot,as).call(a,s.method,s.path,i)}),this}basePath(e){const t=Ce(this,ot,Hg).call(this);return t._basePath=en(this._basePath,e),t}mount(e,t,n){let s,i;n&&(typeof n=="function"?i=n:(i=n.optionHandler,s=n.replaceRequest));const a=i?c=>{const u=i(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};s||(s=(()=>{const c=en(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(s(c.req.raw),...a(c));if(f)return f;await u()};return Ce(this,ot,as).call(this,it,en(e,"*"),o),this}},fr=new WeakMap,ot=new WeakSet,Hg=function(){const e=new Xf({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Xr=new WeakMap,En=new WeakMap,as=function(e,t,n){e=e.toUpperCase(),t=en(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)},vu=function(e,t){if(e instanceof Error)return P(this,En).call(this,e,t);throw e},bu=function(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await Ce(this,ot,bu).call(this,e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.router.match(s,i),o=new Kf(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:P(this,Xr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await P(this,Xr).call(this,o)})}catch(f){return Ce(this,ot,vu).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:P(this,Xr).call(this,o))).catch(f=>Ce(this,ot,vu).call(this,f,o)):u??P(this,Xr).call(this,o)}const c=zf(a[0],P(this,En),P(this,Xr));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 Ce(this,ot,vu).call(this,u,o)}})()},Ig),lo="[^/]+",fi=".*",hi="(?:|/.*)",pi=Symbol(),ev=new Set(".\\+*[^]$()");function tv(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===fi||r===hi?1:e===fi||e===hi?-1:r===lo?1:e===lo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Ou=class{constructor(){H(this,"index");H(this,"varIndex");H(this,"children",Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(this.index!==void 0)throw pi;if(i)return;this.index=t;return}const[a,...o]=e,c=a==="*"?o.length===0?["","",fi]:["","",lo]:a==="/*"?["","",hi]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||lo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw pi;if(u=this.children[m],!u){if(Object.keys(this.children).some(B=>B!==fi&&B!==hi))throw pi;if(i)return;u=this.children[m]=new Ou,f!==""&&(u.varIndex=s.varIndex++)}!i&&f!==""&&n.push([f,u.varIndex])}else if(u=this.children[a],!u){if(Object.keys(this.children).some(f=>f.length>1&&f!==fi&&f!==hi))throw pi;if(i)return;u=this.children[a]=new Ou}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(this.children).sort(tv).map(n=>{const s=this.children[n];return(typeof s.varIndex=="number"?`(${n})@${s.varIndex}`:ev.has(n)?`\\${n}`:n)+s.buildRegExpStr()});return typeof this.index=="number"&&t.unshift(`#${this.index}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},rv=class{constructor(){H(this,"context",{varIndex:0});H(this,"root",new Ou)}insert(r,e,t){const n=[],s=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return s[a]=[u,c],a++,o=!0,u}),!o)break}const i=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=s.length-1;a>=0;a--){const[o]=s[a];for(let c=i.length-1;c>=0;c--)if(i[c].indexOf(o)!==-1){i[c]=i[c].replace(o,s[a][1]);break}}return this.root.insert(i,e,n,this.context,t),n}buildRegExp(){let r=this.root.buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(s,i,a)=>i!==void 0?(t[++e]=Number(i),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},Qf=[],nv=[/^$/,[],Object.create(null)],fo=Object.create(null);function eh(r){return fo[r]??(fo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function sv(){fo=Object.create(null)}function iv(r){var u;const e=new rv,t=[];if(r.length===0)return nv;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[B,C])=>f?1:B?-1:m.length-C.length),s=Object.create(null);for(let f=0,m=-1,B=n.length;f<B;f++){const[C,p,y]=n[f];C?s[p]=[y.map(([A])=>[A,Object.create(null)]),Qf]:m++;let S;try{S=e.insert(p,m,C)}catch(A){throw A===pi?new Jf(p):A}C||(t[m]=y.map(([A,R])=>{const T=Object.create(null);for(R-=1;R>=0;R--){const[ve,Ue]=S[R];T[ve]=Ue}return[A,T]}))}const[i,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 y=Object.keys(p);for(let S=0,A=y.length;S<A;S++)p[y[S]]=o[p[y[S]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[i,c,s]}function ls(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(eh(t).test(e))return[...r[t]]}}var av=(jg=class{constructor(){We(this,ai);H(this,"name","RegExpRouter");H(this,"middleware");H(this,"routes");this.middleware={[it]:Object.create(null)},this.routes={[it]:Object.create(null)}}add(r,e,t){var o;const{middleware:n,routes:s}=this;if(!n||!s)throw new Error(Gf);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[it]).forEach(u=>{c[r][u]=[...c[it][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=eh(e);r===it?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=ls(n[u],e)||ls(n[it],e)||[])}):(o=n[r])[e]||(o[e]=ls(n[r],e)||ls(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,i])})}),Object.keys(s).forEach(u=>{(r===it||r===u)&&Object.keys(s[u]).forEach(f=>c.test(f)&&s[u][f].push([t,i]))});return}const a=Lf(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(s).forEach(m=>{var B;(r===it||r===m)&&((B=s[m])[f]||(B[f]=[...ls(n[m],f)||ls(n[it],f)||[]]),s[m][f].push([t,i-u+c+1]))})}}match(r,e){sv();const t=Ce(this,ai,Fg).call(this);return this.match=(n,s)=>{const i=t[n]||t[it],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],Qf];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},ai=new WeakSet,Fg=function(){const r=Object.create(null);return Object.keys(this.routes).concat(Object.keys(this.middleware)).forEach(e=>{r[e]||(r[e]=Ce(this,ai,Wg).call(this,e))}),this.middleware=this.routes=void 0,r},Wg=function(r){const e=[];let t=r===it;return[this.middleware,this.routes].forEach(n=>{const s=n[r]?Object.keys(n[r]).map(i=>[i,n[r][i]]):[];s.length!==0?(t||(t=!0),e.push(...s)):r!==it&&e.push(...Object.keys(n[it]).map(i=>[i,n[it][i]]))}),t?iv(e):null},jg),ov=class{constructor(r){H(this,"name","SmartRouter");H(this,"routers",[]);H(this,"routes",[]);Object.assign(this,r)}add(r,e,t){if(!this.routes)throw new Error(Gf);this.routes.push([r,e,t])}match(r,e){if(!this.routes)throw new Error("Fatal error");const{routers:t,routes:n}=this,s=t.length;let i=0,a;for(;i<s;i++){const o=t[i];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 Jf)continue;throw c}this.match=o.match.bind(o),this.routers=[o],this.routes=void 0;break}if(i===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(this.routes||this.routers.length!==1)throw new Error("No active router has been determined yet.");return this.routers[0]}},th=(Tg=class{constructor(r,e,t){We(this,Qr);H(this,"methods");H(this,"children");H(this,"patterns");H(this,"order",0);H(this,"params",Object.create(null));if(this.children=t||Object.create(null),this.methods=[],r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},this.methods=[n]}this.patterns=[]}insert(r,e,t){this.order=++this.order;let n=this;const s=E0(e),i=[];for(let c=0,u=s.length;c<u;c++){const f=s[c];if(Object.keys(n.children).includes(f)){n=n.children[f];const B=Mf(f);B&&i.push(B[1]);continue}n.children[f]=new th;const m=Mf(f);m&&(n.patterns.push(m),i.push(m[1])),n=n.children[f]}n.methods.length||(n.methods=[]);const a=Object.create(null),o={handler:t,possibleKeys:i.filter((c,u,f)=>f.indexOf(c)===u),score:this.order};return a[r]=o,n.methods.push(a),n}search(r,e){const t=[];this.params=Object.create(null);let s=[this];const i=Df(e);for(let o=0,c=i.length;o<c;o++){const u=i[o],f=o===c-1,m=[];for(let B=0,C=s.length;B<C;B++){const p=s[B],y=p.children[u];y&&(y.params=p.params,f?(y.children["*"]&&t.push(...Ce(this,Qr,os).call(this,y.children["*"],r,p.params,Object.create(null))),t.push(...Ce(this,Qr,os).call(this,y,r,p.params,Object.create(null)))):m.push(y));for(let S=0,A=p.patterns.length;S<A;S++){const R=p.patterns[S],T={...p.params};if(R==="*"){const bt=p.children["*"];bt&&(t.push(...Ce(this,Qr,os).call(this,bt,r,p.params,Object.create(null))),m.push(bt));continue}if(u==="")continue;const[ve,Ue,qe]=R,Ze=p.children[ve],nt=i.slice(o).join("/");if(qe instanceof RegExp&&qe.test(nt)){T[Ue]=nt,t.push(...Ce(this,Qr,os).call(this,Ze,r,p.params,T));continue}(qe===!0||qe.test(u))&&typeof ve=="string"&&(T[Ue]=u,f?(t.push(...Ce(this,Qr,os).call(this,Ze,r,T,p.params)),Ze.children["*"]&&t.push(...Ce(this,Qr,os).call(this,Ze.children["*"],r,T,p.params))):(Ze.params=T,m.push(Ze)))}}s=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},Qr=new WeakSet,os=function(r,e,t,n){const s=[];for(let i=0,a=r.methods.length;i<a;i++){const o=r.methods[i],c=o[e]||o[it],u=Object.create(null);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}s.push(c)}}return s},Tg),cv=class{constructor(){H(this,"name","TrieRouter");H(this,"node");this.node=new th}add(r,e,t){const n=Lf(e);if(n){for(let s=0,i=n.length;s<i;s++)this.node.insert(r,n[s],t);return}this.node.insert(r,e,t)}match(r,e){return this.node.search(r,e)}},uv=class extends Xf{constructor(r={}){super(r),this.router=r.router??new ov({routers:[new av,new cv]})}},Ne;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Ne||(Ne={}));var Eu;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Eu||(Eu={}));const G=Ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),tn=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=Ne.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"]),lv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Yt=class Kg 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(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(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 s(this),n}static assert(e){if(!(e instanceof Kg))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Yt.create=r=>new Yt(r);const ds=(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,Ne.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ne.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ne.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Ne.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}"`:Ne.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,Ne.assertNever(r)}return{message:t}};let rh=ds;function dv(r){rh=r}function ho(){return rh}const po=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.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{...s,path:i,message:o}},fv=[];function F(r,e){const t=ho(),n=po({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ds?void 0:ds].filter(s=>!!s)});r.common.issues.push(n)}let At=class zg{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 s of t){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return zg.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),fs=r=>({status:"dirty",value:r}),xt=r=>({status:"valid",value:r}),Cu=r=>r.status==="aborted",Iu=r=>r.status==="dirty",mi=r=>r.status==="valid",yi=r=>typeof Promise<"u"&&r instanceof Promise;function mo(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 nh(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!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}typeof SuppressedError=="function"&&SuppressedError;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 gi,vi;let mr=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const sh=(r,e)=>{if(mi(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 Yt(r.common.issues);return this._error=t,this._error}}};function be(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=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:s}:{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:s}}let we=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 tn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:tn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new At,ctx:{common:e.parent.common,data:e.data,parsedType:tn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(yi(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 s={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:tn(e)},i=this._parseSync({data:e,path:s.path,parent:s});return sh(s,i)}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:tn(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(yi(s)?s:Promise.resolve(s));return sh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:Z.custom,...n(s)});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,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Xt({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return yr.create(this,this._def)}nullable(){return nn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return In.create(this,this._def)}promise(){return ys.create(this,this._def)}or(e){return Ai.create([this,e],this._def)}and(e){return Oi.create(this,e,this._def)}transform(e){return new Xt({...be(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ti({...be(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new Nu({typeName:de.ZodBranded,type:this,...be(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ni({...be(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 Bu.create(this,e)}readonly(){return Bi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const hv=/^c[^\s-]{8,}$/i,pv=/^[0-9a-z]+$/,mv=/^[0-9A-HJKMNP-TV-Z]{26}$/,yv=/^[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,gv=/^[a-z0-9_-]{21}$/i,vv=/^[-+]?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)?)??$/,bv=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ju;const _v=/^(?:(?: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])$/,wv=/^(([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})))$/,kv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ih="((\\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])))",Sv=new RegExp(`^${ih}$`);function ah(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 Av(r){return new RegExp(`^${ah(r)}$`)}function oh(r){let e=`${ih}T${ah(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 Ov(r,e){return!!((e==="v4"||!e)&&_v.test(r)||(e==="v6"||!e)&&wv.test(r))}let hs=class so extends we{_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}),pe}const n=new At;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?F(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&F(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")bv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"email",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")ju||(ju=new RegExp(xv,"u")),ju.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"emoji",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")yv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"uuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")gv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"nanoid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")hv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")pv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cuid2",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")mv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"ulid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),F(s,{validation:"url",code:Z.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"regex",code:Z.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),F(s,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.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)||(s=this._getOrReturnCtx(e,s),F(s,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),F(s,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?oh(i).test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:Z.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Sv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:Z.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Av(i).test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:Z.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?vv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"duration",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Ov(e.data,i.version)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"ip",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?kv.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"base64",code:Z.invalid_string,message:i.message}),n.dirty()):Ne.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new so({...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 so({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new so({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new so({...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}};hs.create=r=>{var e;return new hs({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};function Ev(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}let bi=class If extends we{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}),pe}let n;const s=new At;for(const i of this._def.checks)i.kind==="int"?Ne.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Ev(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.not_finite,message:i.message}),s.dirty()):Ne.assertNever(i);return{status:s.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,s){return new If({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new If({...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"&&Ne.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)}};bi.create=r=>new bi({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let xi=class jf extends we{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}),pe}let n;const s=new At;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ne.assertNever(i);return{status:s.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,s){return new jf({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new jf({...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}};xi.create=r=>{var e;return new xi({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};let _i=class extends we{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:G.boolean,received:n.parsedType}),pe}return xt(e.data)}};_i.create=r=>new _i({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let wi=class Gg extends we{_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}),pe}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_date}),pe}const n=new At;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Ne.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Gg({...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}};wi.create=r=>new wi({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,...be(r)});let yo=class extends we{_parse(e){if(this._getType(e)!==G.symbol){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:G.symbol,received:n.parsedType}),pe}return xt(e.data)}};yo.create=r=>new yo({typeName:de.ZodSymbol,...be(r)});let ki=class extends we{_parse(e){if(this._getType(e)!==G.undefined){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:G.undefined,received:n.parsedType}),pe}return xt(e.data)}};ki.create=r=>new ki({typeName:de.ZodUndefined,...be(r)});let Si=class extends we{_parse(e){if(this._getType(e)!==G.null){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:G.null,received:n.parsedType}),pe}return xt(e.data)}};Si.create=r=>new Si({typeName:de.ZodNull,...be(r)});let ps=class extends we{constructor(){super(...arguments),this._any=!0}_parse(e){return xt(e.data)}};ps.create=r=>new ps({typeName:de.ZodAny,...be(r)});let Cn=class extends we{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xt(e.data)}};Cn.create=r=>new Cn({typeName:de.ZodUnknown,...be(r)});let Tr=class extends we{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.never,received:t.parsedType}),pe}};Tr.create=r=>new Tr({typeName:de.ZodNever,...be(r)});let go=class extends we{_parse(e){if(this._getType(e)!==G.undefined){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:G.void,received:n.parsedType}),pe}return xt(e.data)}};go.create=r=>new go({typeName:de.ZodVoid,...be(r)});let In=class xu extends we{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==G.array)return F(t,{code:Z.invalid_type,expected:G.array,received:t.parsedType}),pe;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(F(t,{code:a?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(F(t,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(F(t,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new mr(t,a,t.path,o)))).then(a=>At.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new mr(t,a,t.path,o)));return At.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new xu({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new xu({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new xu({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};In.create=(r,e)=>new In({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,...be(e)});function ms(r){if(r instanceof Ut){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=yr.create(ms(n))}return new Ut({...r._def,shape:()=>e})}else return r instanceof In?new In({...r._def,type:ms(r.element)}):r instanceof yr?yr.create(ms(r.unwrap())):r instanceof nn?nn.create(ms(r.unwrap())):r instanceof rn?rn.create(r.items.map(e=>ms(e))):r}let Ut=class pr extends we{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=Ne.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const u=this._getOrReturnCtx(e);return F(u,{code:Z.invalid_type,expected:G.object,received:u.parsedType}),pe}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Tr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new mr(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Tr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(F(s,{code:Z.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=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new mr(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.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=>At.mergeObjectSync(n,u)):At.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new pr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,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 pr({...this._def,unknownKeys:"strip"})}passthrough(){return new pr({...this._def,unknownKeys:"passthrough"})}extend(e){return new pr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new pr({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 pr({...this._def,catchall:e})}pick(e){const t={};return Ne.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new pr({...this._def,shape:()=>t})}omit(e){const t={};return Ne.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new pr({...this._def,shape:()=>t})}deepPartial(){return ms(this)}partial(e){const t={};return Ne.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new pr({...this._def,shape:()=>t})}required(e){const t={};return Ne.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof yr;)i=i._def.innerType;t[n]=i}}),new pr({...this._def,shape:()=>t})}keyof(){return dh(Ne.objectKeys(this.shape))}};Ut.create=(r,e)=>new Ut({shape:()=>r,unknownKeys:"strip",catchall:Tr.create(),typeName:de.ZodObject,...be(e)}),Ut.strictCreate=(r,e)=>new Ut({shape:()=>r,unknownKeys:"strict",catchall:Tr.create(),typeName:de.ZodObject,...be(e)}),Ut.lazycreate=(r,e)=>new Ut({shape:r,unknownKeys:"strip",catchall:Tr.create(),typeName:de.ZodObject,...be(e)});let Ai=class extends we{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Yt(o.ctx.common.issues));return F(t,{code:Z.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;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"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Yt(c));return F(t,{code:Z.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Ai.create=(r,e)=>new Ai({options:r,typeName:de.ZodUnion,...be(e)});const Nr=r=>r instanceof Ei?Nr(r.schema):r instanceof Xt?Nr(r.innerType()):r instanceof Ci?[r.value]:r instanceof Ii?r.options:r instanceof ji?Ne.objectValues(r.enum):r instanceof Ti?Nr(r._def.innerType):r instanceof ki?[void 0]:r instanceof Si?[null]:r instanceof yr?[void 0,...Nr(r.unwrap())]:r instanceof nn?[null,...Nr(r.unwrap())]:r instanceof Nu||r instanceof Bi?Nr(r.unwrap()):r instanceof Ni?Nr(r._def.innerType):[];let ch=class Jg extends we{_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}),pe;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:Z.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 s=new Map;for(const i of t){const a=Nr(i.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(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Jg({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...be(n)})}};function Tu(r,e){const t=tn(r),n=tn(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const s=Ne.objectKeys(e),i=Ne.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Tu(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 s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Tu(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Oi=class extends we{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Cu(i)||Cu(a))return pe;const o=Tu(i.value,a.value);return o.valid?((Iu(i)||Iu(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:Z.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(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Oi.create=(r,e,t)=>new Oi({left:r,right:e,typeName:de.ZodIntersection,...be(t)});let rn=class Yg extends we{_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}),pe;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"}),pe;!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((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new mr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>At.mergeArray(t,a)):At.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Yg({...this._def,rest:e})}};rn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new rn({items:r,typeName:de.ZodTuple,rest:null,...be(e)})};let uh=class Tf extends we{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}),pe;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new mr(n,o,n.path,o)),value:a._parse(new mr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?At.mergeObjectAsync(t,s):At.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof we?new Tf({keyType:e,valueType:t,typeName:de.ZodRecord,...be(n)}):new Tf({keyType:hs.create(),valueType:e,typeName:de.ZodRecord,...be(t)})}},vo=class extends we{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}),pe;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new mr(n,o,n.path,[u,"key"])),value:i._parse(new mr(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}}}};vo.create=(r,e,t)=>new vo({valueType:e,keyType:r,typeName:de.ZodMap,...be(t)});let bo=class Nf extends we{_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}),pe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(F(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(F(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=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)=>i._parse(new mr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Nf({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Nf({...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)}};bo.create=(r,e)=>new bo({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,...be(e)});let lh=class _u extends we{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}),pe;function n(o,c){return po({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ho(),ds].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return po({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ho(),ds].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ys){const o=this;return xt(async function(...c){const u=new Yt([]),f=await o._def.args.parseAsync(c,i).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,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return xt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Yt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Yt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new _u({...this._def,args:rn.create(e).rest(Cn.create())})}returns(e){return new _u({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new _u({args:e||rn.create([]).rest(Cn.create()),returns:t||Cn.create(),typeName:de.ZodFunction,...be(n)})}},Ei=class extends we{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})}};Ei.create=(r,e)=>new Ei({getter:r,typeName:de.ZodLazy,...be(e)});let Ci=class extends we{_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}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ci.create=(r,e)=>new Ci({value:r,typeName:de.ZodLiteral,...be(e)});function dh(r,e){return new Ii({values:r,typeName:de.ZodEnum,...be(e)})}let Ii=class Bf extends we{constructor(){super(...arguments),gi.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Ne.joinValues(n),received:t.parsedType,code:Z.invalid_type}),pe}if(mo(this,gi)||nh(this,gi,new Set(this._def.values)),!mo(this,gi).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}),pe}return xt(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 Bf.create(e,{...this._def,...t})}exclude(e,t=this._def){return Bf.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};gi=new WeakMap,Ii.create=dh;let ji=class extends we{constructor(){super(...arguments),vi.set(this,void 0)}_parse(e){const t=Ne.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const s=Ne.objectValues(t);return F(n,{expected:Ne.joinValues(s),received:n.parsedType,code:Z.invalid_type}),pe}if(mo(this,vi)||nh(this,vi,new Set(Ne.getValidEnumValues(this._def.values))),!mo(this,vi).has(e.data)){const s=Ne.objectValues(t);return F(n,{received:n.data,code:Z.invalid_enum_value,options:s}),pe}return xt(e.data)}get enum(){return this._def.values}};vi=new WeakMap,ji.create=(r,e)=>new ji({values:r,typeName:de.ZodNativeEnum,...be(e)});let ys=class extends we{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}),pe;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return xt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ys.create=(r,e)=>new ys({type:r,typeName:de.ZodPromise,...be(e)});let Xt=class extends we{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),s=this._def.effect||null,i={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);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"?fs(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"?fs(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);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(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!mi(a))return a;const o=s.transform(a.value,i);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=>mi(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Ne.assertNever(s)}};Xt.create=(r,e,t)=>new Xt({schema:r,typeName:de.ZodEffects,effect:e,...be(t)}),Xt.createWithPreprocess=(r,e,t)=>new Xt({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,...be(t)});let yr=class extends we{_parse(e){return this._getType(e)===G.undefined?xt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};yr.create=(r,e)=>new yr({innerType:r,typeName:de.ZodOptional,...be(e)});let nn=class extends we{_parse(e){return this._getType(e)===G.null?xt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};nn.create=(r,e)=>new nn({innerType:r,typeName:de.ZodNullable,...be(e)});let Ti=class extends we{_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}};Ti.create=(r,e)=>new Ti({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...be(e)});let Ni=class extends we{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return yi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Yt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Yt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ni.create=(r,e)=>new Ni({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...be(e)});let xo=class extends we{_parse(e){if(this._getType(e)!==G.nan){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:G.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};xo.create=r=>new xo({typeName:de.ZodNaN,...be(r)});const Cv=Symbol("zod_brand");let Nu=class extends we{_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}},Bu=class Xg extends we{_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"?pe:i.status==="dirty"?(t.dirty(),fs(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Xg({in:e,out:t,typeName:de.ZodPipeline})}},Bi=class extends we{_parse(e){const t=this._def.innerType._parse(e),n=s=>(mi(s)&&(s.value=Object.freeze(s.value)),s);return yi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};Bi.create=(r,e)=>new Bi({innerType:r,typeName:de.ZodReadonly,...be(e)});function fh(r,e={},t){return r?ps.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):ps.create()}const Iv={object:Ut.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 jv=(r,e={message:`Input not instance of ${r.name}`})=>fh(t=>t instanceof r,e),hh=hs.create,ph=bi.create,Tv=xo.create,Nv=xi.create,mh=_i.create,Bv=wi.create,Rv=yo.create,Pv=ki.create,$v=Si.create,Zv=ps.create,Dv=Cn.create,Mv=Tr.create,Vv=go.create,Uv=In.create,Lv=Ut.create,qv=Ut.strictCreate,Hv=Ai.create,Fv=ch.create,Wv=Oi.create,Kv=rn.create,zv=uh.create,Gv=vo.create,Jv=bo.create,Yv=lh.create,Xv=Ei.create,Qv=Ci.create,eb=Ii.create,tb=ji.create,rb=ys.create,yh=Xt.create,nb=yr.create,sb=nn.create,ib=Xt.createWithPreprocess,ab=Bu.create;var v=Object.freeze({__proto__:null,defaultErrorMap:ds,setErrorMap:dv,getErrorMap:ho,makeIssue:po,EMPTY_PATH:fv,addIssueToContext:F,ParseStatus:At,INVALID:pe,DIRTY:fs,OK:xt,isAborted:Cu,isDirty:Iu,isValid:mi,isAsync:yi,get util(){return Ne},get objectUtil(){return Eu},ZodParsedType:G,getParsedType:tn,ZodType:we,datetimeRegex:oh,ZodString:hs,ZodNumber:bi,ZodBigInt:xi,ZodBoolean:_i,ZodDate:wi,ZodSymbol:yo,ZodUndefined:ki,ZodNull:Si,ZodAny:ps,ZodUnknown:Cn,ZodNever:Tr,ZodVoid:go,ZodArray:In,ZodObject:Ut,ZodUnion:Ai,ZodDiscriminatedUnion:ch,ZodIntersection:Oi,ZodTuple:rn,ZodRecord:uh,ZodMap:vo,ZodSet:bo,ZodFunction:lh,ZodLazy:Ei,ZodLiteral:Ci,ZodEnum:Ii,ZodNativeEnum:ji,ZodPromise:ys,ZodEffects:Xt,ZodTransformer:Xt,ZodOptional:yr,ZodNullable:nn,ZodDefault:Ti,ZodCatch:Ni,ZodNaN:xo,BRAND:Cv,ZodBranded:Nu,ZodPipeline:Bu,ZodReadonly:Bi,custom:fh,Schema:we,ZodSchema:we,late:Iv,get ZodFirstPartyTypeKind(){return de},coerce:{string:r=>hs.create({...r,coerce:!0}),number:r=>bi.create({...r,coerce:!0}),boolean:r=>_i.create({...r,coerce:!0}),bigint:r=>xi.create({...r,coerce:!0}),date:r=>wi.create({...r,coerce:!0})},any:Zv,array:Uv,bigint:Nv,boolean:mh,date:Bv,discriminatedUnion:Fv,effect:yh,enum:eb,function:Yv,instanceof:jv,intersection:Wv,lazy:Xv,literal:Qv,map:Gv,nan:Tv,nativeEnum:tb,never:Mv,null:$v,nullable:sb,number:ph,object:Lv,oboolean:()=>mh().optional(),onumber:()=>ph().optional(),optional:nb,ostring:()=>hh().optional(),pipeline:ab,preprocess:ib,promise:rb,record:zv,set:Jv,strictObject:qv,string:hh,symbol:Rv,transformer:yh,tuple:Kv,undefined:Pv,union:Hv,unknown:Dv,void:Vv,NEVER:pe,ZodIssueCode:Z,quotelessJson:lv,ZodError:Yt}),Ot=class Rf extends uv{constructor(t){super(t);H(this,"openAPIRegistry");H(this,"defaultHook");H(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var u,f,m,B,C,p,y,S,A,R;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const T=us("query",n.request.query,i);a.push(T)}if((f=n.request)!=null&&f.params){const T=us("param",n.request.params,i);a.push(T)}if((m=n.request)!=null&&m.headers){const T=us("header",n.request.headers,i);a.push(T)}if((B=n.request)!=null&&B.cookies){const T=us("cookie",n.request.cookies,i);a.push(T)}const o=(p=(C=n.request)==null?void 0:C.body)==null?void 0:p.content;if(o)for(const T of Object.keys(o)){if(!o[T])continue;const ve=o[T].schema;if(ve instanceof we){if(vh(T)){const Ue=us("json",ve,i);if((S=(y=n.request)==null?void 0:y.body)!=null&&S.required)a.push(Ue);else{const qe=async(Ze,nt)=>{if(Ze.req.header("content-type")&&vh(Ze.req.header("content-type")))return await Ue(Ze,nt);Ze.req.addValidatedData("json",{}),await nt()};a.push(qe)}}if(bh(T)){const Ue=us("form",ve,i);if((R=(A=n.request)==null?void 0:A.body)!=null&&R.required)a.push(Ue);else{const qe=async(Ze,nt)=>{if(Ze.req.header("content-type")&&bh(Ze.req.header("content-type")))return await Ue(Ze,nt);Ze.req.addValidatedData("form",{}),await nt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,s),this});H(this,"getOpenAPIDocument",t=>{const s=new k0(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?gh(s,this._basePath):s});H(this,"getOpenAPI31Document",t=>{const s=new O0(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?gh(s,this._basePath):s});H(this,"doc",(t,n)=>this.get(t,s=>{const i=typeof n=="function"?n(s):n;try{const a=this.getOpenAPIDocument(i);return s.json(a)}catch(a){return s.json(a,500)}}));H(this,"doc31",(t,n)=>this.get(t,s=>{const i=typeof n=="function"?n(s):n;try{const a=this.getOpenAPI31Document(i);return s.json(a)}catch(a){return s.json(a,500)}}));this.openAPIRegistry=new i0,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Rf?(n.openAPIRegistry.definitions.forEach(i=>{switch(i.type){case"component":return this.openAPIRegistry.registerComponent(i.componentType,i.name,i.component);case"route":return this.openAPIRegistry.registerPath({...i.route,path:en(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:en(s,i.webhook.path)});case"schema":return this.openAPIRegistry.register(i.schema._def.openapi._internal.refId,i.schema);case"parameter":return this.openAPIRegistry.registerParameter(i.schema._def.openapi._internal.refId,i.schema);default:{const a=i;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new Rf({...super.basePath(t),defaultHook:this.defaultHook})}},ke=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};t0(v);function gh(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[en(e,n)]=r.paths[n]}),{...r,paths:t}}function vh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function bh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function ob(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 s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function cb(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function Ri(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function ub(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const B=typeof s=="string"?i:s,C=B??{},{param:p}=C,y=ob(C,["param"]),S=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof s=="string"?{refId:s}:void 0),A=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),y),!((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),R=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(S).length>0?{_internal:S}:void 0),Object.keys(A).length>0?{metadata:A}:void 0)}));if(cb(this,"ZodObject")){const T=this.extend;R.extend=function(...ve){var Ue,qe,Ze,nt,bt,Vt;const E=T.apply(this,ve);return E._def.openapi={_internal:{extendedFrom:!((qe=(Ue=this._def.openapi)===null||Ue===void 0?void 0:Ue._internal)===null||qe===void 0)&&qe.refId?{refId:(nt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||nt===void 0?void 0:nt.refId,schema:this}:(bt=this._def.openapi)===null||bt===void 0?void 0:bt._internal.extendedFrom},metadata:(Vt=E._def.openapi)===null||Vt===void 0?void 0:Vt.metadata},E}}return R},Ri(r,"optional"),Ri(r,"nullable"),Ri(r,"default"),Ri(r,"transform"),Ri(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}new Set(".\\+*[^]$()");var Be;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Be||(Be={}));var Ru;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ru||(Ru={}));const J=Be.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 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}},D=Be.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"]),lb=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Rt 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(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(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 s(this),n}static assert(e){if(!(e instanceof Rt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Rt.create=r=>new Rt(r);const gs=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===J.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Be.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Be.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Be.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Be.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}"`:Be.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,Be.assertNever(r)}return{message:t}};let xh=gs;function db(r){xh=r}function _o(){return xh}const wo=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.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{...s,path:i,message:o}},fb=[];function W(r,e){const t=_o(),n=wo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===gs?void 0:gs].filter(s=>!!s)});r.common.issues.push(n)}class yt{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 s of t){if(s.status==="aborted")return ye;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ye;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const ye=Object.freeze({status:"aborted"}),ko=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),Pu=r=>r.status==="aborted",$u=r=>r.status==="dirty",Pi=r=>r.status==="valid",$i=r=>typeof Promise<"u"&&r instanceof Promise;function So(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 _h(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!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 Zi,Di;class gr{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const wh=(r,e)=>{if(Pi(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 Rt(r.common.issues);return this._error=t,this._error}}};function xe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=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:s}:{errorMap:(i,a)=>{var o,c;const{message:u}=r;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:s}}class Se{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 yt,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($i(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 s={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)},i=this._parseSync({data:e,path:s.path,parent:s});return wh(s,i)}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)},s=this._parse({data:e,path:n.path,parent:n}),i=await($i(s)?s:Promise.resolve(s));return wh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:D.custom,...n(s)});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,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new tr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return br.create(this,this._def)}nullable(){return ln.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this,this._def)}promise(){return _s.create(this,this._def)}or(e){return Li.create([this,e],this._def)}and(e){return qi.create(this,e,this._def)}transform(e){return new tr({...xe(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new zi({...xe(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new Mu({typeName:fe.ZodBranded,type:this,...xe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Gi({...xe(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 Ji.create(this,e)}readonly(){return Yi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const hb=/^c[^\s-]{8,}$/i,pb=/^[0-9a-z]+$/,mb=/^[0-9A-HJKMNP-TV-Z]{26}$/,yb=/^[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,gb=/^[a-z0-9_-]{21}$/i,vb=/^[-+]?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)?)??$/,bb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Zu;const _b=/^(?:(?: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])$/,wb=/^(([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})))$/,kb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kh="((\\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])))",Sb=new RegExp(`^${kh}$`);function Sh(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 Ab(r){return new RegExp(`^${Sh(r)}$`)}function Ah(r){let e=`${kh}T${Sh(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 Ob(r,e){return!!((e==="v4"||!e)&&_b.test(r)||(e==="v6"||!e)&&wb.test(r))}class Qt extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const s=this._getOrReturnCtx(e);return W(s,{code:D.invalid_type,expected:J.string,received:s.parsedType}),ye}const t=new yt;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?W(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&W(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")bb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"email",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Zu||(Zu=new RegExp(xb,"u")),Zu.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"emoji",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")yb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"uuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")gb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"nanoid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")hb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"cuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")pb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"cuid2",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")mb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"ulid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),W(n,{validation:"url",code:D.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"regex",code:D.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),W(n,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),W(n,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),W(n,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?Ah(s).test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:D.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Sb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:D.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Ab(s).test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:D.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?vb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"duration",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Ob(e.data,s.version)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"ip",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?kb.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:"base64",code:D.invalid_string,message:s.message}),t.dirty()):Be.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:D.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new Qt({...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 Qt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Qt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Qt({...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}}Qt.create=r=>{var e;return new Qt({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};function Eb(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class an extends Se{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 W(s,{code:D.invalid_type,expected:J.number,received:s.parsedType}),ye}let t;const n=new yt;for(const s of this._def.checks)s.kind==="int"?Be.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),W(t,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Eb(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),W(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),W(t,{code:D.not_finite,message:s.message}),n.dirty()):Be.assertNever(s);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,s){return new an({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new an({...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"&&Be.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)}}an.create=r=>new an({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class on extends Se{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 W(s,{code:D.invalid_type,expected:J.bigint,received:s.parsedType}),ye}let t;const n=new yt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),W(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Be.assertNever(s);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,s){return new on({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new on({...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}}on.create=r=>{var e;return new on({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};class Mi extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const t=this._getOrReturnCtx(e);return W(t,{code:D.invalid_type,expected:J.boolean,received:t.parsedType}),ye}return _t(e.data)}}Mi.create=r=>new Mi({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class jn extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const s=this._getOrReturnCtx(e);return W(s,{code:D.invalid_type,expected:J.date,received:s.parsedType}),ye}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return W(s,{code:D.invalid_date}),ye}const t=new yt;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Be.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new jn({...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}}jn.create=r=>new jn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...xe(r)});class Ao extends Se{_parse(e){if(this._getType(e)!==J.symbol){const t=this._getOrReturnCtx(e);return W(t,{code:D.invalid_type,expected:J.symbol,received:t.parsedType}),ye}return _t(e.data)}}Ao.create=r=>new Ao({typeName:fe.ZodSymbol,...xe(r)});class Vi extends Se{_parse(e){if(this._getType(e)!==J.undefined){const t=this._getOrReturnCtx(e);return W(t,{code:D.invalid_type,expected:J.undefined,received:t.parsedType}),ye}return _t(e.data)}}Vi.create=r=>new Vi({typeName:fe.ZodUndefined,...xe(r)});class Ui extends Se{_parse(e){if(this._getType(e)!==J.null){const t=this._getOrReturnCtx(e);return W(t,{code:D.invalid_type,expected:J.null,received:t.parsedType}),ye}return _t(e.data)}}Ui.create=r=>new Ui({typeName:fe.ZodNull,...xe(r)});class vs extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}}vs.create=r=>new vs({typeName:fe.ZodAny,...xe(r)});class Tn extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}}Tn.create=r=>new Tn({typeName:fe.ZodUnknown,...xe(r)});class Br extends Se{_parse(e){const t=this._getOrReturnCtx(e);return W(t,{code:D.invalid_type,expected:J.never,received:t.parsedType}),ye}}Br.create=r=>new Br({typeName:fe.ZodNever,...xe(r)});class Oo extends Se{_parse(e){if(this._getType(e)!==J.undefined){const t=this._getOrReturnCtx(e);return W(t,{code:D.invalid_type,expected:J.void,received:t.parsedType}),ye}return _t(e.data)}}Oo.create=r=>new Oo({typeName:fe.ZodVoid,...xe(r)});class er extends Se{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==J.array)return W(t,{code:D.invalid_type,expected:J.array,received:t.parsedType}),ye;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(W(t,{code:a?D.too_big:D.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(W(t,{code:D.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(W(t,{code:D.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new gr(t,a,t.path,o)))).then(a=>yt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new gr(t,a,t.path,o)));return yt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new er({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new er({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new er({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}er.create=(r,e)=>new er({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...xe(e)});function bs(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=br.create(bs(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof er?new er({...r._def,type:bs(r.element)}):r instanceof br?br.create(bs(r.unwrap())):r instanceof ln?ln.create(bs(r.unwrap())):r instanceof vr?vr.create(r.items.map(e=>bs(e))):r}class Je extends Se{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=Be.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const c=this._getOrReturnCtx(e);return W(c,{code:D.invalid_type,expected:J.object,received:c.parsedType}),ye}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Br&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||a.push(c);const o=[];for(const c of i){const u=s[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new gr(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Br){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&&(W(n,{code:D.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 gr(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=>yt.mergeObjectSync(t,c)):yt.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 s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,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 Be.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 Be.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return bs(this)}partial(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof br;)s=s._def.innerType;t[n]=s}}),new Je({...this._def,shape:()=>t})}keyof(){return Oh(Be.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Br.create(),typeName:fe.ZodObject,...xe(e)}),Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Br.create(),typeName:fe.ZodObject,...xe(e)}),Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Br.create(),typeName:fe.ZodObject,...xe(e)});class Li extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Rt(o.ctx.common.issues));return W(t,{code:D.invalid_union,unionErrors:a}),ye}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;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"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Rt(c));return W(t,{code:D.invalid_union,unionErrors:o}),ye}}get options(){return this._def.options}}Li.create=(r,e)=>new Li({options:r,typeName:fe.ZodUnion,...xe(e)});const cn=r=>r instanceof Fi?cn(r.schema):r instanceof tr?cn(r.innerType()):r instanceof Wi?[r.value]:r instanceof un?r.options:r instanceof Ki?Be.objectValues(r.enum):r instanceof zi?cn(r._def.innerType):r instanceof Vi?[void 0]:r instanceof Ui?[null]:r instanceof br?[void 0,...cn(r.unwrap())]:r instanceof ln?[null,...cn(r.unwrap())]:r instanceof Mu||r instanceof Yi?cn(r.unwrap()):r instanceof Gi?cn(r._def.innerType):[];class Eo extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return W(t,{code:D.invalid_type,expected:J.object,received:t.parsedType}),ye;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ye)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=cn(i.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(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new Eo({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...xe(n)})}}function Du(r,e){const t=sn(r),n=sn(e);if(r===e)return{valid:!0,data:r};if(t===J.object&&n===J.object){const s=Be.objectKeys(e),i=Be.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Du(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 s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Du(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===J.date&&n===J.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class qi extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Pu(i)||Pu(a))return ye;const o=Du(i.value,a.value);return o.valid?(($u(i)||$u(a))&&t.dirty(),{status:t.value,value:o.data}):(W(n,{code:D.invalid_intersection_types}),ye)};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(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}qi.create=(r,e,t)=>new qi({left:r,right:e,typeName:fe.ZodIntersection,...xe(t)});class vr extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return W(n,{code:D.invalid_type,expected:J.array,received:n.parsedType}),ye;if(n.data.length<this._def.items.length)return W(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ye;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((i,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new gr(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>yt.mergeArray(t,i)):yt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new vr({...this._def,rest:e})}}vr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new vr({items:r,typeName:fe.ZodTuple,rest:null,...xe(e)})};class Hi extends Se{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 W(n,{code:D.invalid_type,expected:J.object,received:n.parsedType}),ye;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new gr(n,o,n.path,o)),value:a._parse(new gr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?yt.mergeObjectAsync(t,s):yt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Se?new Hi({keyType:e,valueType:t,typeName:fe.ZodRecord,...xe(n)}):new Hi({keyType:Qt.create(),valueType:e,typeName:fe.ZodRecord,...xe(t)})}}class Co extends Se{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 W(n,{code:D.invalid_type,expected:J.map,received:n.parsedType}),ye;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new gr(n,o,n.path,[u,"key"])),value:i._parse(new gr(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 ye;(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 ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Co.create=(r,e,t)=>new Co({valueType:e,keyType:r,typeName:fe.ZodMap,...xe(t)});class Nn extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return W(n,{code:D.invalid_type,expected:J.set,received:n.parsedType}),ye;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:D.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:D.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ye;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new gr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Nn({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new Nn({...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)}}Nn.create=(r,e)=>new Nn({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...xe(e)});class xs extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return W(t,{code:D.invalid_type,expected:J.function,received:t.parsedType}),ye;function n(o,c){return wo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_o(),gs].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function s(o,c){return wo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_o(),gs].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof _s){const o=this;return _t(async function(...c){const u=new Rt([]),f=await o._def.args.parseAsync(c,i).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,i).catch(B=>{throw u.addIssue(s(m,B)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Rt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Rt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new xs({...this._def,args:vr.create(e).rest(Tn.create())})}returns(e){return new xs({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new xs({args:e||vr.create([]).rest(Tn.create()),returns:t||Tn.create(),typeName:fe.ZodFunction,...xe(n)})}}class Fi extends Se{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})}}Fi.create=(r,e)=>new Fi({getter:r,typeName:fe.ZodLazy,...xe(e)});class Wi extends Se{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),ye}return{status:"valid",value:e.data}}get value(){return this._def.value}}Wi.create=(r,e)=>new Wi({value:r,typeName:fe.ZodLiteral,...xe(e)});function Oh(r,e){return new un({values:r,typeName:fe.ZodEnum,...xe(e)})}class un extends Se{constructor(){super(...arguments),Zi.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:Be.joinValues(n),received:t.parsedType,code:D.invalid_type}),ye}if(So(this,Zi)||_h(this,Zi,new Set(this._def.values)),!So(this,Zi).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:D.invalid_enum_value,options:n}),ye}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 un.create(e,{...this._def,...t})}exclude(e,t=this._def){return un.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Zi=new WeakMap,un.create=Oh;class Ki extends Se{constructor(){super(...arguments),Di.set(this,void 0)}_parse(e){const t=Be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const s=Be.objectValues(t);return W(n,{expected:Be.joinValues(s),received:n.parsedType,code:D.invalid_type}),ye}if(So(this,Di)||_h(this,Di,new Set(Be.getValidEnumValues(this._def.values))),!So(this,Di).has(e.data)){const s=Be.objectValues(t);return W(n,{received:n.data,code:D.invalid_enum_value,options:s}),ye}return _t(e.data)}get enum(){return this._def.values}}Di=new WeakMap,Ki.create=(r,e)=>new Ki({values:r,typeName:fe.ZodNativeEnum,...xe(e)});class _s extends Se{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return W(t,{code:D.invalid_type,expected:J.promise,received:t.parsedType}),ye;const n=t.parsedType===J.promise?t.data:Promise.resolve(t.data);return _t(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}_s.create=(r,e)=>new _s({type:r,typeName:fe.ZodPromise,...xe(e)});class tr extends Se{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),s=this._def.effect||null,i={addIssue:a=>{W(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ye;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ye:c.status==="dirty"||t.value==="dirty"?ko(c.value):c});{if(t.value==="aborted")return ye;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ye:o.status==="dirty"||t.value==="dirty"?ko(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);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"?ye:(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"?ye:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Pi(a))return a;const o=s.transform(a.value,i);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=>Pi(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Be.assertNever(s)}}tr.create=(r,e,t)=>new tr({schema:r,typeName:fe.ZodEffects,effect:e,...xe(t)}),tr.createWithPreprocess=(r,e,t)=>new tr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...xe(t)});class br extends Se{_parse(e){return this._getType(e)===J.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}br.create=(r,e)=>new br({innerType:r,typeName:fe.ZodOptional,...xe(e)});class ln extends Se{_parse(e){return this._getType(e)===J.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ln.create=(r,e)=>new ln({innerType:r,typeName:fe.ZodNullable,...xe(e)});class zi extends Se{_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}}zi.create=(r,e)=>new zi({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class Gi extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $i(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Gi.create=(r,e)=>new Gi({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class Io extends Se{_parse(e){if(this._getType(e)!==J.nan){const t=this._getOrReturnCtx(e);return W(t,{code:D.invalid_type,expected:J.nan,received:t.parsedType}),ye}return{status:"valid",value:e.data}}}Io.create=r=>new Io({typeName:fe.ZodNaN,...xe(r)});const Cb=Symbol("zod_brand");class Mu extends Se{_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 Ji extends Se{_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"?ye:s.status==="dirty"?(t.dirty(),ko(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ji({in:e,out:t,typeName:fe.ZodPipeline})}}class Yi extends Se{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Pi(s)&&(s.value=Object.freeze(s.value)),s);return $i(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Yi.create=(r,e)=>new Yi({innerType:r,typeName:fe.ZodReadonly,...xe(e)});function Eh(r,e={},t){return r?vs.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):vs.create()}const Ib={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 jb=(r,e={message:`Input not instance of ${r.name}`})=>Eh(t=>t instanceof r,e),Ch=Qt.create,Ih=an.create,Tb=Io.create,Nb=on.create,jh=Mi.create,Bb=jn.create,Rb=Ao.create,Pb=Vi.create,$b=Ui.create,Zb=vs.create,Db=Tn.create,Mb=Br.create,Vb=Oo.create,Ub=er.create,Lb=Je.create,qb=Je.strictCreate,Hb=Li.create,Fb=Eo.create,Wb=qi.create,Kb=vr.create,zb=Hi.create,Gb=Co.create,Jb=Nn.create,Yb=xs.create,Xb=Fi.create,Qb=Wi.create,ex=un.create,tx=Ki.create,rx=_s.create,Th=tr.create,nx=br.create,sx=ln.create,ix=tr.createWithPreprocess,ax=Ji.create;var d=Object.freeze({__proto__:null,defaultErrorMap:gs,setErrorMap:db,getErrorMap:_o,makeIssue:wo,EMPTY_PATH:fb,addIssueToContext:W,ParseStatus:yt,INVALID:ye,DIRTY:ko,OK:_t,isAborted:Pu,isDirty:$u,isValid:Pi,isAsync:$i,get util(){return Be},get objectUtil(){return Ru},ZodParsedType:J,getParsedType:sn,ZodType:Se,datetimeRegex:Ah,ZodString:Qt,ZodNumber:an,ZodBigInt:on,ZodBoolean:Mi,ZodDate:jn,ZodSymbol:Ao,ZodUndefined:Vi,ZodNull:Ui,ZodAny:vs,ZodUnknown:Tn,ZodNever:Br,ZodVoid:Oo,ZodArray:er,ZodObject:Je,ZodUnion:Li,ZodDiscriminatedUnion:Eo,ZodIntersection:qi,ZodTuple:vr,ZodRecord:Hi,ZodMap:Co,ZodSet:Nn,ZodFunction:xs,ZodLazy:Fi,ZodLiteral:Wi,ZodEnum:un,ZodNativeEnum:Ki,ZodPromise:_s,ZodEffects:tr,ZodTransformer:tr,ZodOptional:br,ZodNullable:ln,ZodDefault:zi,ZodCatch:Gi,ZodNaN:Io,BRAND:Cb,ZodBranded:Mu,ZodPipeline:Ji,ZodReadonly:Yi,custom:Eh,Schema:Se,ZodSchema:Se,late:Ib,get ZodFirstPartyTypeKind(){return fe},coerce:{string:r=>Qt.create({...r,coerce:!0}),number:r=>an.create({...r,coerce:!0}),boolean:r=>Mi.create({...r,coerce:!0}),bigint:r=>on.create({...r,coerce:!0}),date:r=>jn.create({...r,coerce:!0})},any:Zb,array:Ub,bigint:Nb,boolean:jh,date:Bb,discriminatedUnion:Fb,effect:Th,enum:ex,function:Yb,instanceof:jb,intersection:Wb,lazy:Xb,literal:Qb,map:Gb,nan:Tb,nativeEnum:tx,never:Mb,null:$b,nullable:sx,number:Ih,object:Lb,oboolean:()=>jh().optional(),onumber:()=>Ih().optional(),optional:nx,ostring:()=>Ch().optional(),pipeline:ax,preprocess:ix,promise:rx,record:zb,set:Jb,strictObject:qb,string:Ch,symbol:Rb,transformer:Th,tuple:Kb,undefined:Pb,union:Hb,unknown:Db,void:Vb,NEVER:ye,ZodIssueCode:D,quotelessJson:lb,ZodError:Rt});ub(d);const Bn=d.object({start:d.number(),limit:d.number(),length:d.number()}),Vu=d.object({created_at:d.string(),updated_at:d.string()}),ox=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()),cx=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:ox.optional()}),Uu=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()}),Lu=Uu.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")}),Nh=d.object({...Lu.shape,...Vu.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(cx).optional()}),Rr=Nh;Uu.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());const ux="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let lx=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=ux[t[r]&63];return e};const dx=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()}),qu=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:dx.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(()=>lx()).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"})}),ws=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...qu.shape});var Bh=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(Bh||{}),Rh=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(Rh||{}),Ph=(r=>(r.S265="S256",r.plain="plain",r))(Ph||{});const fx=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(Bh).optional(),response_mode:d.nativeEnum(Rh).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(Ph).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),$h=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()}),Hu=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","Username-Password-Authentication","oidc","oauth2","custom"]).optional(),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()}),ks=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(Hu.shape),Fu=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()}),Xi=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...Fu.shape});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()});const hx=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({...ws.shape,domains:d.array(hx),tenant:Xi,connections:d.array(ks)});const px=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),mx=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:px,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()});d.object({...mx.shape,created_at:d.string()});const yx=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"])});Vu.extend({...yx.shape,id:d.string()});const Wu=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()}),Qi=Wu.extend({...Vu.shape,hook_id:d.string()}),Zh=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()}),gx=d.object({keys:d.array(Zh)}),Dh=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())}),vx=d.object({auth0Client:d.string().optional(),authParams:fx,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional()}).openapi({description:"This represents a login sesion"});d.object({...vx.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 Ku=(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))(Ku||{});const bx=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"]),xx=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),zu=d.object({type:bx,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:xx.optional()}),_x=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")});d.object({..._x.shape,created_at:d.string(),updated_at:d.string()});const wx=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()}),Mh=d.object({created_at:d.string(),...wx.shape}),Vh=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 Uh=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(Uh||{});const Gu=d.nativeEnum(Uh);d.object({grant_type:Gu.refine(r=>r==="authorization_code"),code:d.string(),client_secret:d.string(),client_id:d.string()}),d.object({grant_type:Gu.refine(r=>r==="authorization_code"),code:d.string(),code_verifier:d.string(),client_id:d.string().optional(),redirect_uri:d.string()}),d.object({grant_type:Gu.refine(r=>r==="client_credentials"),scope:d.string().optional(),client_secret:d.string(),client_id:d.string(),audience:d.string().optional()}),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 kx=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()}),Sx=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()}),Ss=d.object({bold:d.boolean(),size:d.number()}),Ax=d.object({body_text:Ss,buttons_text:Ss,font_url:d.string(),input_labels:Ss,links:Ss,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Ss,title:Ss}),Ox=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Ex=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"])});d.object({borders:kx,colors:Sx,displayName:d.string(),fonts:Ax,page_background:Ox,widget:Ex}).extend({themeId:d.string()});const Ju=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()});var jo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Cx(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Ix(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 s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
2
2
  Copyright (C) Microsoft. All rights reserved.
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -11,7 +11,7 @@ var authhero=function(He){"use strict";var pk=Object.defineProperty;var Pg=He=>{
11
11
 
12
12
  See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
- ***************************************************************************** */var Rh;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof Eo=="object"?Eo:typeof self=="object"?self:typeof this=="object"?this:o(),n=s(r);typeof t.Reflect<"u"&&(n=s(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function s(c,u){return function(f,m){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:m}),u&&u(f,m)}}function i(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function o(){return i()||a()}})(function(e,t){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",i=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!o&&!c,f={create:o?function(){return bf(Object.create(null))}:c?function(){return bf({__proto__:null})}:function(){return bf({})},has:u?function(_,k){return n.call(_,k)}:function(_,k){return k in _},get:u?function(_,k){return n.call(_,k)?_[k]:void 0}:function(_,k){return _[k]}},m=Object.getPrototypeOf(Function),B=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:uk(),j=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:lk(),p=typeof WeakMap=="function"?WeakMap:dk(),g=s?Symbol.for("@reflect-metadata:registry"):void 0,A=ak(),S=ok(A);function R(_,k,I,U){if(ee(I)){if(!Eg(_))throw new TypeError;if(!Cg(k))throw new TypeError;return O(_,k)}else{if(!Eg(_))throw new TypeError;if(!Fe(k))throw new TypeError;if(!Fe(U)&&!ee(U)&&!ut(U))throw new TypeError;return ut(U)&&(U=void 0),I=Ir(I),w(_,k,I,U)}}e("decorate",R);function T(_,k){function I(U,le){if(!Fe(U))throw new TypeError;if(!ee(le)&&!sk(le))throw new TypeError;Ae(_,k,U,le)}return I}e("metadata",T);function ve(_,k,I,U){if(!Fe(I))throw new TypeError;return ee(U)||(U=Ir(U)),Ae(_,k,I,U)}e("defineMetadata",ve);function Ue(_,k,I){if(!Fe(k))throw new TypeError;return ee(I)||(I=Ir(I)),b(_,k,I)}e("hasMetadata",Ue);function qe(_,k,I){if(!Fe(k))throw new TypeError;return ee(I)||(I=Ir(I)),v(_,k,I)}e("hasOwnMetadata",qe);function $e(_,k,I){if(!Fe(k))throw new TypeError;return ee(I)||(I=Ir(I)),C(_,k,I)}e("getMetadata",$e);function rt(_,k,I){if(!Fe(k))throw new TypeError;return ee(I)||(I=Ir(I)),V(_,k,I)}e("getOwnMetadata",rt);function gt(_,k){if(!Fe(_))throw new TypeError;return ee(k)||(k=Ir(k)),ue(_,k)}e("getMetadataKeys",gt);function Mt(_,k){if(!Fe(_))throw new TypeError;return ee(k)||(k=Ir(k)),Ie(_,k)}e("getOwnMetadataKeys",Mt);function E(_,k,I){if(!Fe(k))throw new TypeError;if(ee(I)||(I=Ir(I)),!Fe(k))throw new TypeError;ee(I)||(I=Ir(I));var U=eo(k,I,!1);return ee(U)?!1:U.OrdinaryDeleteMetadata(_,k,I)}e("deleteMetadata",E);function O(_,k){for(var I=_.length-1;I>=0;--I){var U=_[I],le=U(k);if(!ee(le)&&!ut(le)){if(!Cg(le))throw new TypeError;k=le}}return k}function w(_,k,I,U){for(var le=_.length-1;le>=0;--le){var lt=_[le],ct=lt(k,I,U);if(!ee(ct)&&!ut(ct)){if(!Fe(ct))throw new TypeError;U=ct}}return U}function b(_,k,I){var U=v(_,k,I);if(U)return!0;var le=vf(k);return ut(le)?!1:b(_,le,I)}function v(_,k,I){var U=eo(k,I,!1);return ee(U)?!1:Og(U.OrdinaryHasOwnMetadata(_,k,I))}function C(_,k,I){var U=v(_,k,I);if(U)return V(_,k,I);var le=vf(k);if(!ut(le))return C(_,le,I)}function V(_,k,I){var U=eo(k,I,!1);if(!ee(U))return U.OrdinaryGetOwnMetadata(_,k,I)}function Ae(_,k,I,U){var le=eo(I,U,!0);le.OrdinaryDefineOwnMetadata(_,k,I,U)}function ue(_,k){var I=Ie(_,k),U=vf(_);if(U===null)return I;var le=ue(U,k);if(le.length<=0)return I;if(I.length<=0)return le;for(var lt=new j,ct=[],Ee=0,z=I;Ee<z.length;Ee++){var te=z[Ee],ne=lt.has(te);ne||(lt.add(te),ct.push(te))}for(var se=0,je=le;se<je.length;se++){var te=je[se],ne=lt.has(te);ne||(lt.add(te),ct.push(te))}return ct}function Ie(_,k){var I=eo(_,k,!1);return I?I.OrdinaryOwnMetadataKeys(_,k):[]}function Ve(_){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 ee(_){return _===void 0}function ut(_){return _===null}function rs(_){return typeof _=="symbol"}function Fe(_){return typeof _=="object"?_!==null:typeof _=="function"}function nt(_,k){switch(Ve(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var I="string",U=Ig(_,i);if(U!==void 0){var le=U.call(_,I);if(Fe(le))throw new TypeError;return le}return rk(_)}function rk(_,k){var I,U;{var le=_.toString;if(yu(le)){var U=le.call(_);if(!Fe(U))return U}var I=_.valueOf;if(yu(I)){var U=I.call(_);if(!Fe(U))return U}}throw new TypeError}function Og(_){return!!_}function nk(_){return""+_}function Ir(_){var k=nt(_);return rs(k)?k:nk(k)}function Eg(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function yu(_){return typeof _=="function"}function Cg(_){return typeof _=="function"}function sk(_){switch(Ve(_)){case 3:return!0;case 4:return!0;default:return!1}}function gf(_,k){return _===k||_!==_&&k!==k}function Ig(_,k){var I=_[k];if(I!=null){if(!yu(I))throw new TypeError;return I}}function jg(_){var k=Ig(_,a);if(!yu(k))throw new TypeError;var I=k.call(_);if(!Fe(I))throw new TypeError;return I}function Tg(_){return _.value}function Ng(_){var k=_.next();return k.done?!1:k}function Bg(_){var k=_.return;k&&k.call(_)}function vf(_){var k=Object.getPrototypeOf(_);if(typeof _!="function"||_===m||k!==m)return k;var I=_.prototype,U=I&&Object.getPrototypeOf(I);if(U==null||U===Object.prototype)return k;var le=U.constructor;return typeof le!="function"||le===_?k:le}function ik(){var _;!ee(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=ck(t.Reflect));var k,I,U,le=new p,lt={registerProvider:ct,getProvider:z,setProvider:ne};return lt;function ct(se){if(!Object.isExtensible(lt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===se:break;case ee(k):k=se;break;case k===se:break;case ee(I):I=se;break;case I===se:break;default:U===void 0&&(U=new j),U.add(se);break}}function Ee(se,je){if(!ee(k)){if(k.isProviderFor(se,je))return k;if(!ee(I)){if(I.isProviderFor(se,je))return k;if(!ee(U))for(var Ke=jg(U);;){var tt=Ng(Ke);if(!tt)return;var lr=Tg(tt);if(lr.isProviderFor(se,je))return Bg(Ke),lr}}}if(!ee(_)&&_.isProviderFor(se,je))return _}function z(se,je){var Ke=le.get(se),tt;return ee(Ke)||(tt=Ke.get(je)),ee(tt)&&(tt=Ee(se,je),ee(tt)||(ee(Ke)&&(Ke=new B,le.set(se,Ke)),Ke.set(je,tt))),tt}function te(se){if(ee(se))throw new TypeError;return k===se||I===se||!ee(U)&&U.has(se)}function ne(se,je,Ke){if(!te(Ke))throw new Error("Metadata provider not registered.");var tt=z(se,je);if(tt!==Ke){if(!ee(tt))return!1;var lr=le.get(se);ee(lr)&&(lr=new B,le.set(se,lr)),lr.set(je,Ke)}return!0}}function ak(){var _;return!ee(g)&&Fe(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[g]),ee(_)&&(_=ik()),!ee(g)&&Fe(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function ok(_){var k=new p,I={isProviderFor:function(te,ne){var se=k.get(te);return ee(se)?!1:se.has(ne)},OrdinaryDefineOwnMetadata:ct,OrdinaryHasOwnMetadata:le,OrdinaryGetOwnMetadata:lt,OrdinaryOwnMetadataKeys:Ee,OrdinaryDeleteMetadata:z};return A.registerProvider(I),I;function U(te,ne,se){var je=k.get(te),Ke=!1;if(ee(je)){if(!se)return;je=new B,k.set(te,je),Ke=!0}var tt=je.get(ne);if(ee(tt)){if(!se)return;if(tt=new B,je.set(ne,tt),!_.setProvider(te,ne,I))throw je.delete(ne),Ke&&k.delete(te),new Error("Wrong provider for target.")}return tt}function le(te,ne,se){var je=U(ne,se,!1);return ee(je)?!1:Og(je.has(te))}function lt(te,ne,se){var je=U(ne,se,!1);if(!ee(je))return je.get(te)}function ct(te,ne,se,je){var Ke=U(se,je,!0);Ke.set(te,ne)}function Ee(te,ne){var se=[],je=U(te,ne,!1);if(ee(je))return se;for(var Ke=je.keys(),tt=jg(Ke),lr=0;;){var Rg=Ng(tt);if(!Rg)return se.length=lr,se;var fk=Tg(Rg);try{se[lr]=fk}catch(hk){try{Bg(tt)}finally{throw hk}}lr++}}function z(te,ne,se){var je=U(ne,se,!1);if(ee(je)||!je.delete(te))return!1;if(je.size===0){var Ke=k.get(ne);ee(Ke)||(Ke.delete(se),Ke.size===0&&k.delete(Ke))}return!0}}function ck(_){var k=_.defineMetadata,I=_.hasOwnMetadata,U=_.getOwnMetadata,le=_.getOwnMetadataKeys,lt=_.deleteMetadata,ct=new p,Ee={isProviderFor:function(z,te){var ne=ct.get(z);return!ee(ne)&&ne.has(te)?!0:le(z,te).length?(ee(ne)&&(ne=new j,ct.set(z,ne)),ne.add(te),!0):!1},OrdinaryDefineOwnMetadata:k,OrdinaryHasOwnMetadata:I,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:le,OrdinaryDeleteMetadata:lt};return Ee}function eo(_,k,I){var U=A.getProvider(_,k);if(!ee(U))return U;if(I){if(A.setProvider(_,k,S))return S;throw new Error("Illegal state.")}}function uk(){var _={},k=[],I=function(){function Ee(z,te,ne){this._index=0,this._keys=z,this._values=te,this._selector=ne}return Ee.prototype["@@iterator"]=function(){return this},Ee.prototype[a]=function(){return this},Ee.prototype.next=function(){var z=this._index;if(z>=0&&z<this._keys.length){var te=this._selector(this._keys[z],this._values[z]);return z+1>=this._keys.length?(this._index=-1,this._keys=k,this._values=k):this._index++,{value:te,done:!1}}return{value:void 0,done:!0}},Ee.prototype.throw=function(z){throw this._index>=0&&(this._index=-1,this._keys=k,this._values=k),z},Ee.prototype.return=function(z){return this._index>=0&&(this._index=-1,this._keys=k,this._values=k),{value:z,done:!0}},Ee}(),U=function(){function Ee(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(Ee.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ee.prototype.has=function(z){return this._find(z,!1)>=0},Ee.prototype.get=function(z){var te=this._find(z,!1);return te>=0?this._values[te]:void 0},Ee.prototype.set=function(z,te){var ne=this._find(z,!0);return this._values[ne]=te,this},Ee.prototype.delete=function(z){var te=this._find(z,!1);if(te>=0){for(var ne=this._keys.length,se=te+1;se<ne;se++)this._keys[se-1]=this._keys[se],this._values[se-1]=this._values[se];return this._keys.length--,this._values.length--,gf(z,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},Ee.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},Ee.prototype.keys=function(){return new I(this._keys,this._values,le)},Ee.prototype.values=function(){return new I(this._keys,this._values,lt)},Ee.prototype.entries=function(){return new I(this._keys,this._values,ct)},Ee.prototype["@@iterator"]=function(){return this.entries()},Ee.prototype[a]=function(){return this.entries()},Ee.prototype._find=function(z,te){if(!gf(this._cacheKey,z)){this._cacheIndex=-1;for(var ne=0;ne<this._keys.length;ne++)if(gf(this._keys[ne],z)){this._cacheIndex=ne;break}}return this._cacheIndex<0&&te&&(this._cacheIndex=this._keys.length,this._keys.push(z),this._values.push(void 0)),this._cacheIndex},Ee}();return U;function le(Ee,z){return Ee}function lt(Ee,z){return z}function ct(Ee,z){return[Ee,z]}}function lk(){var _=function(){function k(){this._map=new B}return Object.defineProperty(k.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),k.prototype.has=function(I){return this._map.has(I)},k.prototype.add=function(I){return this._map.set(I,I),this},k.prototype.delete=function(I){return this._map.delete(I)},k.prototype.clear=function(){this._map.clear()},k.prototype.keys=function(){return this._map.keys()},k.prototype.values=function(){return this._map.keys()},k.prototype.entries=function(){return this._map.entries()},k.prototype["@@iterator"]=function(){return this.keys()},k.prototype[a]=function(){return this.keys()},k}();return _}function dk(){var _=16,k=f.create(),I=U();return function(){function z(){this._key=U()}return z.prototype.has=function(te){var ne=le(te,!1);return ne!==void 0?f.has(ne,this._key):!1},z.prototype.get=function(te){var ne=le(te,!1);return ne!==void 0?f.get(ne,this._key):void 0},z.prototype.set=function(te,ne){var se=le(te,!0);return se[this._key]=ne,this},z.prototype.delete=function(te){var ne=le(te,!1);return ne!==void 0?delete ne[this._key]:!1},z.prototype.clear=function(){this._key=U()},z}();function U(){var z;do z="@@WeakMap@@"+Ee();while(f.has(k,z));return k[z]=!0,z}function le(z,te){if(!n.call(z,I)){if(!te)return;Object.defineProperty(z,I,{value:f.create()})}return z[I]}function lt(z,te){for(var ne=0;ne<te;++ne)z[ne]=Math.random()*255|0;return z}function ct(z){if(typeof Uint8Array=="function"){var te=new Uint8Array(z);return typeof crypto<"u"?crypto.getRandomValues(te):typeof msCrypto<"u"?msCrypto.getRandomValues(te):lt(te,z),te}return lt(new Array(z),z)}function Ee(){var z=ct(_);z[6]=z[6]&79|64,z[8]=z[8]&191|128;for(var te="",ne=0;ne<_;++ne){var se=z[ne];(ne===4||ne===6||ne===8)&&(te+="-"),se<16&&(te+="0"),te+=se.toString(16).toLowerCase()}return te}}function bf(_){return _.__=void 0,delete _.__,_}})})(Rh||(Rh={}));/*!
14
+ ***************************************************************************** */var Lh;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof jo=="object"?jo:typeof self=="object"?self:typeof this=="object"?this:o(),n=s(r);typeof t.Reflect<"u"&&(n=s(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function s(c,u){return function(f,m){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:m}),u&&u(f,m)}}function i(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function o(){return i()||a()}})(function(e,t){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",i=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!o&&!c,f={create:o?function(){return Of(Object.create(null))}:c?function(){return Of({__proto__:null})}:function(){return Of({})},has:u?function(_,k){return n.call(_,k)}:function(_,k){return k in _},get:u?function(_,k){return n.call(_,k)?_[k]:void 0}:function(_,k){return _[k]}},m=Object.getPrototypeOf(Function),B=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:wk(),C=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:kk(),p=typeof WeakMap=="function"?WeakMap:Sk(),y=s?Symbol.for("@reflect-metadata:registry"):void 0,S=bk(),A=xk(S);function R(_,k,j,L){if(ee(j)){if(!Bg(_))throw new TypeError;if(!Rg(k))throw new TypeError;return O(_,k)}else{if(!Bg(_))throw new TypeError;if(!Fe(k))throw new TypeError;if(!Fe(L)&&!ee(L)&&!ut(L))throw new TypeError;return ut(L)&&(L=void 0),j=jr(j),w(_,k,j,L)}}e("decorate",R);function T(_,k){function j(L,le){if(!Fe(L))throw new TypeError;if(!ee(le)&&!gk(le))throw new TypeError;Oe(_,k,L,le)}return j}e("metadata",T);function ve(_,k,j,L){if(!Fe(j))throw new TypeError;return ee(L)||(L=jr(L)),Oe(_,k,j,L)}e("defineMetadata",ve);function Ue(_,k,j){if(!Fe(k))throw new TypeError;return ee(j)||(j=jr(j)),x(_,k,j)}e("hasMetadata",Ue);function qe(_,k,j){if(!Fe(k))throw new TypeError;return ee(j)||(j=jr(j)),b(_,k,j)}e("hasOwnMetadata",qe);function Ze(_,k,j){if(!Fe(k))throw new TypeError;return ee(j)||(j=jr(j)),I(_,k,j)}e("getMetadata",Ze);function nt(_,k,j){if(!Fe(k))throw new TypeError;return ee(j)||(j=jr(j)),V(_,k,j)}e("getOwnMetadata",nt);function bt(_,k){if(!Fe(_))throw new TypeError;return ee(k)||(k=jr(k)),ue(_,k)}e("getMetadataKeys",bt);function Vt(_,k){if(!Fe(_))throw new TypeError;return ee(k)||(k=jr(k)),Ie(_,k)}e("getOwnMetadataKeys",Vt);function E(_,k,j){if(!Fe(k))throw new TypeError;if(ee(j)||(j=jr(j)),!Fe(k))throw new TypeError;ee(j)||(j=jr(j));var L=no(k,j,!1);return ee(L)?!1:L.OrdinaryDeleteMetadata(_,k,j)}e("deleteMetadata",E);function O(_,k){for(var j=_.length-1;j>=0;--j){var L=_[j],le=L(k);if(!ee(le)&&!ut(le)){if(!Rg(le))throw new TypeError;k=le}}return k}function w(_,k,j,L){for(var le=_.length-1;le>=0;--le){var lt=_[le],ct=lt(k,j,L);if(!ee(ct)&&!ut(ct)){if(!Fe(ct))throw new TypeError;L=ct}}return L}function x(_,k,j){var L=b(_,k,j);if(L)return!0;var le=Af(k);return ut(le)?!1:x(_,le,j)}function b(_,k,j){var L=no(k,j,!1);return ee(L)?!1:Ng(L.OrdinaryHasOwnMetadata(_,k,j))}function I(_,k,j){var L=b(_,k,j);if(L)return V(_,k,j);var le=Af(k);if(!ut(le))return I(_,le,j)}function V(_,k,j){var L=no(k,j,!1);if(!ee(L))return L.OrdinaryGetOwnMetadata(_,k,j)}function Oe(_,k,j,L){var le=no(j,L,!0);le.OrdinaryDefineOwnMetadata(_,k,j,L)}function ue(_,k){var j=Ie(_,k),L=Af(_);if(L===null)return j;var le=ue(L,k);if(le.length<=0)return j;if(j.length<=0)return le;for(var lt=new C,ct=[],Ee=0,z=j;Ee<z.length;Ee++){var te=z[Ee],ne=lt.has(te);ne||(lt.add(te),ct.push(te))}for(var se=0,je=le;se<je.length;se++){var te=je[se],ne=lt.has(te);ne||(lt.add(te),ct.push(te))}return ct}function Ie(_,k){var j=no(_,k,!1);return j?j.OrdinaryOwnMetadataKeys(_,k):[]}function Ve(_){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 ee(_){return _===void 0}function ut(_){return _===null}function is(_){return typeof _=="symbol"}function Fe(_){return typeof _=="object"?_!==null:typeof _=="function"}function st(_,k){switch(Ve(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var j="string",L=Pg(_,i);if(L!==void 0){var le=L.call(_,j);if(Fe(le))throw new TypeError;return le}return mk(_)}function mk(_,k){var j,L;{var le=_.toString;if(gu(le)){var L=le.call(_);if(!Fe(L))return L}var j=_.valueOf;if(gu(j)){var L=j.call(_);if(!Fe(L))return L}}throw new TypeError}function Ng(_){return!!_}function yk(_){return""+_}function jr(_){var k=st(_);return is(k)?k:yk(k)}function Bg(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function gu(_){return typeof _=="function"}function Rg(_){return typeof _=="function"}function gk(_){switch(Ve(_)){case 3:return!0;case 4:return!0;default:return!1}}function Sf(_,k){return _===k||_!==_&&k!==k}function Pg(_,k){var j=_[k];if(j!=null){if(!gu(j))throw new TypeError;return j}}function $g(_){var k=Pg(_,a);if(!gu(k))throw new TypeError;var j=k.call(_);if(!Fe(j))throw new TypeError;return j}function Zg(_){return _.value}function Dg(_){var k=_.next();return k.done?!1:k}function Mg(_){var k=_.return;k&&k.call(_)}function Af(_){var k=Object.getPrototypeOf(_);if(typeof _!="function"||_===m||k!==m)return k;var j=_.prototype,L=j&&Object.getPrototypeOf(j);if(L==null||L===Object.prototype)return k;var le=L.constructor;return typeof le!="function"||le===_?k:le}function vk(){var _;!ee(y)&&typeof t.Reflect<"u"&&!(y in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=_k(t.Reflect));var k,j,L,le=new p,lt={registerProvider:ct,getProvider:z,setProvider:ne};return lt;function ct(se){if(!Object.isExtensible(lt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===se:break;case ee(k):k=se;break;case k===se:break;case ee(j):j=se;break;case j===se:break;default:L===void 0&&(L=new C),L.add(se);break}}function Ee(se,je){if(!ee(k)){if(k.isProviderFor(se,je))return k;if(!ee(j)){if(j.isProviderFor(se,je))return k;if(!ee(L))for(var ze=$g(L);;){var rt=Dg(ze);if(!rt)return;var hr=Zg(rt);if(hr.isProviderFor(se,je))return Mg(ze),hr}}}if(!ee(_)&&_.isProviderFor(se,je))return _}function z(se,je){var ze=le.get(se),rt;return ee(ze)||(rt=ze.get(je)),ee(rt)&&(rt=Ee(se,je),ee(rt)||(ee(ze)&&(ze=new B,le.set(se,ze)),ze.set(je,rt))),rt}function te(se){if(ee(se))throw new TypeError;return k===se||j===se||!ee(L)&&L.has(se)}function ne(se,je,ze){if(!te(ze))throw new Error("Metadata provider not registered.");var rt=z(se,je);if(rt!==ze){if(!ee(rt))return!1;var hr=le.get(se);ee(hr)&&(hr=new B,le.set(se,hr)),hr.set(je,ze)}return!0}}function bk(){var _;return!ee(y)&&Fe(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[y]),ee(_)&&(_=vk()),!ee(y)&&Fe(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function xk(_){var k=new p,j={isProviderFor:function(te,ne){var se=k.get(te);return ee(se)?!1:se.has(ne)},OrdinaryDefineOwnMetadata:ct,OrdinaryHasOwnMetadata:le,OrdinaryGetOwnMetadata:lt,OrdinaryOwnMetadataKeys:Ee,OrdinaryDeleteMetadata:z};return S.registerProvider(j),j;function L(te,ne,se){var je=k.get(te),ze=!1;if(ee(je)){if(!se)return;je=new B,k.set(te,je),ze=!0}var rt=je.get(ne);if(ee(rt)){if(!se)return;if(rt=new B,je.set(ne,rt),!_.setProvider(te,ne,j))throw je.delete(ne),ze&&k.delete(te),new Error("Wrong provider for target.")}return rt}function le(te,ne,se){var je=L(ne,se,!1);return ee(je)?!1:Ng(je.has(te))}function lt(te,ne,se){var je=L(ne,se,!1);if(!ee(je))return je.get(te)}function ct(te,ne,se,je){var ze=L(se,je,!0);ze.set(te,ne)}function Ee(te,ne){var se=[],je=L(te,ne,!1);if(ee(je))return se;for(var ze=je.keys(),rt=$g(ze),hr=0;;){var Vg=Dg(rt);if(!Vg)return se.length=hr,se;var Ak=Zg(Vg);try{se[hr]=Ak}catch(Ok){try{Mg(rt)}finally{throw Ok}}hr++}}function z(te,ne,se){var je=L(ne,se,!1);if(ee(je)||!je.delete(te))return!1;if(je.size===0){var ze=k.get(ne);ee(ze)||(ze.delete(se),ze.size===0&&k.delete(ze))}return!0}}function _k(_){var k=_.defineMetadata,j=_.hasOwnMetadata,L=_.getOwnMetadata,le=_.getOwnMetadataKeys,lt=_.deleteMetadata,ct=new p,Ee={isProviderFor:function(z,te){var ne=ct.get(z);return!ee(ne)&&ne.has(te)?!0:le(z,te).length?(ee(ne)&&(ne=new C,ct.set(z,ne)),ne.add(te),!0):!1},OrdinaryDefineOwnMetadata:k,OrdinaryHasOwnMetadata:j,OrdinaryGetOwnMetadata:L,OrdinaryOwnMetadataKeys:le,OrdinaryDeleteMetadata:lt};return Ee}function no(_,k,j){var L=S.getProvider(_,k);if(!ee(L))return L;if(j){if(S.setProvider(_,k,A))return A;throw new Error("Illegal state.")}}function wk(){var _={},k=[],j=function(){function Ee(z,te,ne){this._index=0,this._keys=z,this._values=te,this._selector=ne}return Ee.prototype["@@iterator"]=function(){return this},Ee.prototype[a]=function(){return this},Ee.prototype.next=function(){var z=this._index;if(z>=0&&z<this._keys.length){var te=this._selector(this._keys[z],this._values[z]);return z+1>=this._keys.length?(this._index=-1,this._keys=k,this._values=k):this._index++,{value:te,done:!1}}return{value:void 0,done:!0}},Ee.prototype.throw=function(z){throw this._index>=0&&(this._index=-1,this._keys=k,this._values=k),z},Ee.prototype.return=function(z){return this._index>=0&&(this._index=-1,this._keys=k,this._values=k),{value:z,done:!0}},Ee}(),L=function(){function Ee(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(Ee.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ee.prototype.has=function(z){return this._find(z,!1)>=0},Ee.prototype.get=function(z){var te=this._find(z,!1);return te>=0?this._values[te]:void 0},Ee.prototype.set=function(z,te){var ne=this._find(z,!0);return this._values[ne]=te,this},Ee.prototype.delete=function(z){var te=this._find(z,!1);if(te>=0){for(var ne=this._keys.length,se=te+1;se<ne;se++)this._keys[se-1]=this._keys[se],this._values[se-1]=this._values[se];return this._keys.length--,this._values.length--,Sf(z,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},Ee.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},Ee.prototype.keys=function(){return new j(this._keys,this._values,le)},Ee.prototype.values=function(){return new j(this._keys,this._values,lt)},Ee.prototype.entries=function(){return new j(this._keys,this._values,ct)},Ee.prototype["@@iterator"]=function(){return this.entries()},Ee.prototype[a]=function(){return this.entries()},Ee.prototype._find=function(z,te){if(!Sf(this._cacheKey,z)){this._cacheIndex=-1;for(var ne=0;ne<this._keys.length;ne++)if(Sf(this._keys[ne],z)){this._cacheIndex=ne;break}}return this._cacheIndex<0&&te&&(this._cacheIndex=this._keys.length,this._keys.push(z),this._values.push(void 0)),this._cacheIndex},Ee}();return L;function le(Ee,z){return Ee}function lt(Ee,z){return z}function ct(Ee,z){return[Ee,z]}}function kk(){var _=function(){function k(){this._map=new B}return Object.defineProperty(k.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),k.prototype.has=function(j){return this._map.has(j)},k.prototype.add=function(j){return this._map.set(j,j),this},k.prototype.delete=function(j){return this._map.delete(j)},k.prototype.clear=function(){this._map.clear()},k.prototype.keys=function(){return this._map.keys()},k.prototype.values=function(){return this._map.keys()},k.prototype.entries=function(){return this._map.entries()},k.prototype["@@iterator"]=function(){return this.keys()},k.prototype[a]=function(){return this.keys()},k}();return _}function Sk(){var _=16,k=f.create(),j=L();return function(){function z(){this._key=L()}return z.prototype.has=function(te){var ne=le(te,!1);return ne!==void 0?f.has(ne,this._key):!1},z.prototype.get=function(te){var ne=le(te,!1);return ne!==void 0?f.get(ne,this._key):void 0},z.prototype.set=function(te,ne){var se=le(te,!0);return se[this._key]=ne,this},z.prototype.delete=function(te){var ne=le(te,!1);return ne!==void 0?delete ne[this._key]:!1},z.prototype.clear=function(){this._key=L()},z}();function L(){var z;do z="@@WeakMap@@"+Ee();while(f.has(k,z));return k[z]=!0,z}function le(z,te){if(!n.call(z,j)){if(!te)return;Object.defineProperty(z,j,{value:f.create()})}return z[j]}function lt(z,te){for(var ne=0;ne<te;++ne)z[ne]=Math.random()*255|0;return z}function ct(z){if(typeof Uint8Array=="function"){var te=new Uint8Array(z);return typeof crypto<"u"?crypto.getRandomValues(te):typeof msCrypto<"u"?msCrypto.getRandomValues(te):lt(te,z),te}return lt(new Array(z),z)}function Ee(){var z=ct(_);z[6]=z[6]&79|64,z[8]=z[8]&191|128;for(var te="",ne=0;ne<_;++ne){var se=z[ne];(ne===4||ne===6||ne===8)&&(te+="-"),se<16&&(te+="0"),te+=se.toString(16).toLowerCase()}return te}}function Of(_){return _.__=void 0,delete _.__,_}})})(Lh||(Lh={}));/*!
15
15
  * MIT License
16
16
  *
17
17
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -34,9 +34,9 @@ var authhero=function(He){"use strict";var pk=Object.defineProperty;var Pg=He=>{
34
34
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
35
  * SOFTWARE.
36
36
  *
37
- */const Sx="[object ArrayBuffer]";class L{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Sx}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=L.toUint8Array(e),s=L.toUint8Array(t);if(n.length!==s.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==s[i])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 s=new Uint8Array(n);let i=0;for(const a of t){const o=this.toUint8Array(a);s.set(o,i),i+=o.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}}const Ju="string",Ax=/^[0-9a-f]+$/i,Ox=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Ex=/^[a-zA-Z0-9-_]+$/;class Ph{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){const t=L.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}}class gr{static toString(e,t=!1){const n=L.toArrayBuffer(e),s=new DataView(n);let i="";for(let a=0;a<n.byteLength;a+=2){const o=s.getUint16(a,t);i+=String.fromCharCode(o)}return i}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let i=0;i<e.length;i++)s.setUint16(i*2,e.charCodeAt(i),t);return n}}class re{static isHex(e){return typeof e===Ju&&Ax.test(e)}static isBase64(e){return typeof e===Ju&&Ox.test(e)}static isBase64Url(e){return typeof e===Ju&&Ex.test(e)}static ToString(e,t="utf8"){const n=L.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=L.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(!re.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(!re.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=re.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Ph.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=re.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Ph.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 s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){const t=L.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){const t=L.toUint8Array(e);let n="";const s=t.length;for(let i=0;i<s;i++){const a=t[i];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(!re.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 s=0;s<t.length;s=s+2){const i=t.slice(s,s+2);n[s/2]=parseInt(i,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,""))||""}}re.DEFAULT_UTF8_ENCODING="utf8";function Cx(...r){const e=r.map(s=>s.byteLength).reduce((s,i)=>s+i),t=new Uint8Array(e);let n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(const i of s)t[n++]=i}),t.buffer}function $h(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}/*!
37
+ */const jx="[object ArrayBuffer]";class q{static isArrayBuffer(e){return Object.prototype.toString.call(e)===jx}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),s=q.toUint8Array(t);if(n.length!==s.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==s[i])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 s=new Uint8Array(n);let i=0;for(const a of t){const o=this.toUint8Array(a);s.set(o,i),i+=o.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}}const Yu="string",Tx=/^[0-9a-f]+$/i,Nx=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Bx=/^[a-zA-Z0-9-_]+$/;class qh{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){const t=q.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}}class xr{static toString(e,t=!1){const n=q.toArrayBuffer(e),s=new DataView(n);let i="";for(let a=0;a<n.byteLength;a+=2){const o=s.getUint16(a,t);i+=String.fromCharCode(o)}return i}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let i=0;i<e.length;i++)s.setUint16(i*2,e.charCodeAt(i),t);return n}}class re{static isHex(e){return typeof e===Yu&&Tx.test(e)}static isBase64(e){return typeof e===Yu&&Nx.test(e)}static isBase64Url(e){return typeof e===Yu&&Bx.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 xr.toString(n,!0);case"utf16":case"utf16be":return xr.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 xr.fromString(e,!0);case"utf16":case"utf16be":return xr.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(!re.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(!re.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=re.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return qh.fromString(e);case"utf16":case"utf16be":return xr.fromString(e);case"utf16le":case"usc2":return xr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=re.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return qh.toString(e);case"utf16":case"utf16be":return xr.toString(e);case"utf16le":case"usc2":return xr.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 s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){const t=q.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){const t=q.toUint8Array(e);let n="";const s=t.length;for(let i=0;i<s;i++){const a=t[i];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(!re.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 s=0;s<t.length;s=s+2){const i=t.slice(s,s+2);n[s/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return xr.toString(e,t)}static FromUtf16String(e,t=!1){return xr.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,""))||""}}re.DEFAULT_UTF8_ENCODING="utf8";function Rx(...r){const e=r.map(s=>s.byteLength).reduce((s,i)=>s+i),t=new Uint8Array(e);let n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(const i of s)t[n++]=i}),t.buffer}function Hh(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}/*!
38
38
  Copyright (c) Peculiar Ventures, LLC
39
- */function ws(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 Bn(r,e,t=-1){const n=t;let s=r,i=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),i=o;else{if(n<o)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}const u=new Uint8Array(c);for(let f=o-1;f>=0;f--){const m=Math.pow(2,f*e);u[i-f-1]=Math.floor(s/m),s-=u[i-f-1]*m}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function Yu(...r){let e=0,t=0;for(const i of r)e+=i.length;const n=new ArrayBuffer(e),s=new Uint8Array(n);for(const i of r)s.set(i,t),t+=i.length;return s}function Zh(){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=ws(t,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let o=0;o<this.valueHex.byteLength;o++)i[o]=r[o];return i[0]&=127,ws(i,8)-n}function Ix(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=Bn(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let s=Bn(e,8,n),i=new Uint8Array(s);if(i[0]&128){const a=s.slice(0),o=new Uint8Array(a);s=new ArrayBuffer(s.byteLength+1),i=new Uint8Array(s);for(let c=0;c<a.byteLength;c++)i[c+1]=o[c];i[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function jx(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function Pt(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,s=new Array(n);for(let a=0;a<n;a++)s[a]="0";return s.join("").concat(t)}/*!
39
+ */function As(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 Rn(r,e,t=-1){const n=t;let s=r,i=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),i=o;else{if(n<o)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}const u=new Uint8Array(c);for(let f=o-1;f>=0;f--){const m=Math.pow(2,f*e);u[i-f-1]=Math.floor(s/m),s-=u[i-f-1]*m}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function Xu(...r){let e=0,t=0;for(const i of r)e+=i.length;const n=new ArrayBuffer(e),s=new Uint8Array(n);for(const i of r)s.set(i,t),t+=i.length;return s}function Fh(){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=As(t,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let o=0;o<this.valueHex.byteLength;o++)i[o]=r[o];return i[0]&=127,As(i,8)-n}function Px(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=Rn(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let s=Rn(e,8,n),i=new Uint8Array(s);if(i[0]&128){const a=s.slice(0),o=new Uint8Array(a);s=new ArrayBuffer(s.byteLength+1),i=new Uint8Array(s);for(let c=0;c<a.byteLength;c++)i[c+1]=o[c];i[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function $x(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function Pt(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,s=new Array(n);for(let a=0;a<n;a++)s[a]="0";return s.join("").concat(t)}/*!
40
40
  * Copyright (c) 2014, GMO GlobalSign
41
41
  * Copyright (c) 2015-2022, Peculiar Ventures
42
42
  * All rights reserved.
@@ -68,11 +68,11 @@ var authhero=function(He){"use strict";var pk=Object.defineProperty;var Pg=He=>{
68
68
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
69
69
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70
70
  *
71
- */function Co(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Xu(r){let e=0,t=0;for(let s=0;s<r.length;s++){const i=r[s];e+=i.byteLength}const n=new Uint8Array(e);for(let s=0;s<r.length;s++){const i=r[s];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function Rr(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 Io{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Xu(this.items)}}const ea=[new Uint8Array([1])],Dh="0123456789",Qu="name",Mh="valueHexView",Tx="isHexOnly",Nx="idBlock",Bx="tagClass",Rx="tagNumber",Px="isConstructed",$x="fromBER",Zx="toBER",Dx="local",Ot="",er=new ArrayBuffer(0),jo=new Uint8Array(0),ta="EndOfContent",Vh="OCTET STRING",Uh="BIT STRING";function vr(r){var e;return e=class extends r{constructor(...n){var s;super(...n);const i=n[0]||{};this.isHexOnly=(s=i.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=i.valueHex?L.toUint8Array(i.valueHex):jo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,i){const a=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Rr(this,a,s,i))return-1;const o=s+i;return this.valueHexView=a.subarray(s,o),this.valueHexView.length?(this.blockLength=i,o):(this.warnings.push("Zero buffer length"),s)}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",er)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:re.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Rn{constructor({blockLength:e=0,error:t=Ot,warnings:n=[],valueBeforeDecode:s=jo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=L.toUint8Array(s)}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:re.ToHex(this.valueBeforeDecodeView)}}}Rn.NAME="baseBlock";class xt extends Rn{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'")}}xt.NAME="valueBlock";class Lh extends vr(Rn){constructor({idBlock:e={}}={}){var t,n,s,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?L.toUint8Array(e.valueHex):jo,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!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",er}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const s=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,s[0]=t}return s.buffer}if(!this.isHexOnly){const s=Bn(this.tagNumber,7),i=new Uint8Array(s),a=s.byteLength,o=new Uint8Array(a+1);if(o[0]=t|31,!e){for(let c=0;c<a-1;c++)o[c+1]=i[c]|128;o[a]=i[a-1]}return o.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const s=this.valueHexView;for(let i=0;i<s.length-1;i++)n[i+1]=s[i]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(e,t,n){const s=L.toUint8Array(e);if(!Rr(this,s,t,n))return-1;const i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[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=(i[0]&32)===32,this.isHexOnly=!1;const o=i[0]&31;if(o!==31)this.tagNumber=o,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;i[c]&128;){if(u[c-1]=i[c]&127,c++,c>=i.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 j=0;j<u.length;j++)B[j]=u[j];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=i[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=ws(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}}}Lh.NAME="identificationBlock";class qh extends Rn{constructor({lenBlock:e={}}={}){var t,n,s;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=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){const s=L.toUint8Array(e);if(!Rr(this,s,t,n))return-1;const i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;const a=i[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>i.length)return this.error="End of input reached before message was fully decoded",-1;const o=t+1,c=s.subarray(o,o+a);return c[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=ws(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 s=Bn(this.length,8);if(s.byteLength>127)return this.error="Too big length",er;if(t=new ArrayBuffer(s.byteLength+1),e)return t;const i=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let a=0;a<s.byteLength;a++)n[a+1]=i[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}}}qh.NAME="lengthBlock";const X={};class dt extends Rn{constructor({name:e=Ot,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Lh(s),this.lenBlock=new qh(s),this.valueBlock=i?new i(s):new xt(s)}fromBER(e,t,n){const s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}toBER(e,t){const n=t||new Io;t||Hh(this);const s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;const a=this.lenBlock.toBER(e);n.write(a),n.write(i)}return t?er: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():re.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${re.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 jx(t,n)}}dt.NAME="BaseBlock";function Hh(r){if(r instanceof X.Constructed)for(const e of r.valueBlock.value)Hh(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class el extends dt{constructor({value:e=Ot,...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 s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}el.NAME="BaseStringBlock";class Fh extends vr(xt){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Fh.NAME="PrimitiveValueBlock";var Wh;class ra extends dt{constructor(e={}){super(e,Fh),this.idBlock.isConstructed=!1}}Wh=ra,X.Primitive=Wh,ra.NAME="PRIMITIVE";function Mx(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 ks(r,e=0,t=r.length){const n=e;let s=new dt({},xt);const i=new Rn;if(!Rr(i,r,e,t))return s.error=i.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let o=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),o===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=o,t-=s.idBlock.blockLength,o=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),o===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=o,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=dt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};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 s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};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=s.idBlock.isConstructed?new X.Constructed:new X.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?X.Constructed:X.Primitive}return s=Mx(s,c),o=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:o,result:s}}function Ss(r){if(!r.byteLength){const e=new dt({},xt);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ks(L.toUint8Array(r).slice(),0,r.byteLength)}function Vx(r,e){return r?1:e}class ln extends xt{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const s=L.toUint8Array(e);if(!Rr(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;Vx(this.isIndefiniteForm,n)>0;){const a=ks(s,i,n);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(i=a.offset,this.blockLength+=a.result.blockLength,n-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===ta)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===ta?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const n=t||new Io;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?er:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}ln.NAME="ConstructedValueBlock";var zh;class Et extends dt{constructor(e={}){super(e,ln),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
71
+ */function To(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Qu(r){let e=0,t=0;for(let s=0;s<r.length;s++){const i=r[s];e+=i.byteLength}const n=new Uint8Array(e);for(let s=0;s<r.length;s++){const i=r[s];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function Pr(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 No{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Qu(this.items)}}const ea=[new Uint8Array([1])],Wh="0123456789",el="name",Kh="valueHexView",Zx="isHexOnly",Dx="idBlock",Mx="tagClass",Vx="tagNumber",Ux="isConstructed",Lx="fromBER",qx="toBER",Hx="local",Et="",rr=new ArrayBuffer(0),Bo=new Uint8Array(0),ta="EndOfContent",zh="OCTET STRING",Gh="BIT STRING";function _r(r){var e;return e=class extends r{constructor(...n){var s;super(...n);const i=n[0]||{};this.isHexOnly=(s=i.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=i.valueHex?q.toUint8Array(i.valueHex):Bo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,i){const a=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Pr(this,a,s,i))return-1;const o=s+i;return this.valueHexView=a.subarray(s,o),this.valueHexView.length?(this.blockLength=i,o):(this.warnings.push("Zero buffer length"),s)}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",rr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:re.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Pn{constructor({blockLength:e=0,error:t=Et,warnings:n=[],valueBeforeDecode:s=Bo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=q.toUint8Array(s)}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:re.ToHex(this.valueBeforeDecodeView)}}}Pn.NAME="baseBlock";class wt extends Pn{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'")}}wt.NAME="valueBlock";class Jh extends _r(Pn){constructor({idBlock:e={}}={}){var t,n,s,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?q.toUint8Array(e.valueHex):Bo,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!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",rr}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const s=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,s[0]=t}return s.buffer}if(!this.isHexOnly){const s=Rn(this.tagNumber,7),i=new Uint8Array(s),a=s.byteLength,o=new Uint8Array(a+1);if(o[0]=t|31,!e){for(let c=0;c<a-1;c++)o[c+1]=i[c]|128;o[a]=i[a-1]}return o.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const s=this.valueHexView;for(let i=0;i<s.length-1;i++)n[i+1]=s[i]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(e,t,n){const s=q.toUint8Array(e);if(!Pr(this,s,t,n))return-1;const i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[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=(i[0]&32)===32,this.isHexOnly=!1;const o=i[0]&31;if(o!==31)this.tagNumber=o,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;i[c]&128;){if(u[c-1]=i[c]&127,c++,c>=i.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]=i[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=As(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}}}Jh.NAME="identificationBlock";class Yh extends Pn{constructor({lenBlock:e={}}={}){var t,n,s;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=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){const s=q.toUint8Array(e);if(!Pr(this,s,t,n))return-1;const i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;const a=i[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>i.length)return this.error="End of input reached before message was fully decoded",-1;const o=t+1,c=s.subarray(o,o+a);return c[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=As(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 s=Rn(this.length,8);if(s.byteLength>127)return this.error="Too big length",rr;if(t=new ArrayBuffer(s.byteLength+1),e)return t;const i=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let a=0;a<s.byteLength;a++)n[a+1]=i[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}}}Yh.NAME="lengthBlock";const Q={};class dt extends Pn{constructor({name:e=Et,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Jh(s),this.lenBlock=new Yh(s),this.valueBlock=i?new i(s):new wt(s)}fromBER(e,t,n){const s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}toBER(e,t){const n=t||new No;t||Xh(this);const s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;const a=this.lenBlock.toBER(e);n.write(a),n.write(i)}return t?rr: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():re.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${re.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 $x(t,n)}}dt.NAME="BaseBlock";function Xh(r){if(r instanceof Q.Constructed)for(const e of r.valueBlock.value)Xh(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class tl extends dt{constructor({value:e=Et,...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 s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}tl.NAME="BaseStringBlock";class Qh extends _r(wt){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Qh.NAME="PrimitiveValueBlock";var ep;class ra extends dt{constructor(e={}){super(e,Qh),this.idBlock.isConstructed=!1}}ep=ra,Q.Primitive=ep,ra.NAME="PRIMITIVE";function Fx(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 Os(r,e=0,t=r.length){const n=e;let s=new dt({},wt);const i=new Pn;if(!Pr(i,r,e,t))return s.error=i.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let o=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),o===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=o,t-=s.idBlock.blockLength,o=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),o===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=o,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=dt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=Q.EndOfContent;break;case 1:c=Q.Boolean;break;case 2:c=Q.Integer;break;case 3:c=Q.BitString;break;case 4:c=Q.OctetString;break;case 5:c=Q.Null;break;case 6:c=Q.ObjectIdentifier;break;case 10:c=Q.Enumerated;break;case 12:c=Q.Utf8String;break;case 13:c=Q.RelativeObjectIdentifier;break;case 14:c=Q.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=Q.Sequence;break;case 17:c=Q.Set;break;case 18:c=Q.NumericString;break;case 19:c=Q.PrintableString;break;case 20:c=Q.TeletexString;break;case 21:c=Q.VideotexString;break;case 22:c=Q.IA5String;break;case 23:c=Q.UTCTime;break;case 24:c=Q.GeneralizedTime;break;case 25:c=Q.GraphicString;break;case 26:c=Q.VisibleString;break;case 27:c=Q.GeneralString;break;case 28:c=Q.UniversalString;break;case 29:c=Q.CharacterString;break;case 30:c=Q.BmpString;break;case 31:c=Q.DATE;break;case 32:c=Q.TimeOfDay;break;case 33:c=Q.DateTime;break;case 34:c=Q.Duration;break;default:{const u=s.idBlock.isConstructed?new Q.Constructed:new Q.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?Q.Constructed:Q.Primitive}return s=Fx(s,c),o=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:o,result:s}}function Es(r){if(!r.byteLength){const e=new dt({},wt);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Os(q.toUint8Array(r).slice(),0,r.byteLength)}function Wx(r,e){return r?1:e}class dn extends wt{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const s=q.toUint8Array(e);if(!Pr(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;Wx(this.isIndefiniteForm,n)>0;){const a=Os(s,i,n);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(i=a.offset,this.blockLength+=a.result.blockLength,n-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===ta)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===ta?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const n=t||new No;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?rr:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}dn.NAME="ConstructedValueBlock";var tp;class Ct extends dt{constructor(e={}){super(e,dn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
72
72
  `).map(s=>` ${s}`).join(`
73
73
  `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
74
74
  ${e.join(`
75
- `)}`:`${t} :`}}zh=Et,X.Constructed=zh,Et.NAME="CONSTRUCTED";class Kh extends xt{fromBER(e,t,n){return t}toBER(e){return er}}Kh.override="EndOfContentValueBlock";var Gh;class tl extends dt{constructor(e={}){super(e,Kh),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Gh=tl,X.EndOfContent=Gh,tl.NAME=ta;var Jh;class Pn extends dt{constructor(e={}){super(e,xt),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 s=new Uint8Array(n);s[0]=5,s[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}Jh=Pn,X.Null=Jh,Pn.NAME="NULL";class Yh extends vr(xt){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=L.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 s=L.toUint8Array(e);return Rr(this,s,t,n)?(this.valueHexView=s.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Zh.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Yh.NAME="BooleanValueBlock";var Xh;let To=class extends dt{constructor(e={}){super(e,Yh),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}`}};Xh=To,X.Boolean=Xh,To.NAME="BOOLEAN";class Qh extends vr(ln){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=ln.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let i=0;i<this.value.length;i++){const a=this.value[i].constructor.NAME;if(a===ta){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Vh)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,t,n),this.blockLength=n;return s}toBER(e,t){return this.isConstructed?ln.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Qh.NAME="OctetStringValueBlock";var ep;let $n=class zg extends dt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var s,i;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Qh),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 i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){const a=ks(i,0,i.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?Et.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${re.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 zg&&e.push(t.valueBlock.valueHexView);return L.concat(e)}};ep=$n,X.OctetString=ep,$n.NAME=Vh;class tp extends vr(ln){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 s=-1;if(this.isConstructed){if(s=ln.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(const o of this.value){const c=o.constructor.NAME;if(c===ta){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Uh)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 s}const i=L.toUint8Array(e);if(!Rr(this,i,t,n))return-1;const a=i.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=ks(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 ln.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return er;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}}}tp.NAME="BitStringValueBlock";var rp;let Zn=class extends dt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var s,i;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},tp),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 Et.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const s of t)e.push(s.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};rp=Zn,X.BitString=rp,Zn.NAME=Uh;var np;function Ux(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(e);let i=n.slice(0);const a=i.length-1,o=s.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=i[a-m]+o[c-m]+t[0];break;default:u=i[a-m]+t[0]}switch(t[0]=u/10,!0){case m>=i.length:i=Yu(new Uint8Array([u%10]),i);break;default:i[a-m]=u%10}}return t[0]>0&&(i=Yu(t,i)),i}function sp(r){if(r>=ea.length)for(let e=ea.length;e<=r;e++){const t=new Uint8Array([0]);let n=ea[e-1].slice(0);for(let s=n.length-1;s>=0;s--){const i=new Uint8Array([(n[s]<<1)+t[0]]);t[0]=i[0]/10,n[s]=i[0]%10}t[0]>0&&(n=Yu(t,n)),ea.push(n)}return ea[r]}function Lx(r,e){let t=0;const n=new Uint8Array(r),s=new Uint8Array(e),i=n.slice(0),a=i.length-1,o=s.slice(0),c=o.length-1;let u,f=0;for(let m=c;m>=0;m--,f++)switch(u=i[a-f]-o[c-f]-t,!0){case u<0:t=1,i[a-f]=u+10;break;default:t=0,i[a-f]=u}if(t>0)for(let m=a-c+1;m>=0;m--,f++)if(u=i[a-f]-t,u<0)t=1,i[a-f]=u+10;else{t=0,i[a-f]=u;break}return i.slice()}class rl extends vr(xt){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=Zh.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Ix(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,s=0){const i=this.fromBER(e,t,n);if(i===-1)return i;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):s!==0&&a.length<s&&(s-a.length>1&&(s=a.length+1),this.valueHexView=a.subarray(s-a.length)),i}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 s=super.fromBER(e,t,n);return s===-1||this.setValueHex(),s}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,s;const i=this.valueHexView;let a="",o=!1;for(let c=i.byteLength-1;c>=0;c--){s=i[c];for(let u=0;u<8;u++){if((s&1)===1)switch(n){case e:t=Lx(sp(n),t),a="-";break;default:t=Ux(t,sp(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Dh.charAt(t[c]));return o===!1&&(a+=Dh.charAt(0)),a}}np=rl,rl.NAME="IntegerValueBlock",Object.defineProperty(np.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var ip;class br extends dt{constructor(e={}){super(e,rl),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Co(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Co();const t=BigInt(e),n=new Io,s=t.toString(16).replace(/^-/,""),i=new Uint8Array(re.FromHex(s));if(t<0){const o=new Uint8Array(i.length+(i[0]&128?1:0));o[0]|=128;const u=BigInt(`0x${re.ToHex(o)}`)+t,f=L.toUint8Array(re.FromHex(u.toString(16)));f[0]|=128,n.write(f)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new br({valueHex:n.final()})}convertToDER(){const e=new br({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new br({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}ip=br,X.Integer=ip,br.NAME="INTEGER";var ap;class No extends br{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}ap=No,X.Enumerated=ap,No.NAME="ENUMERATED";class nl extends vr(xt){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 s=L.toUint8Array(e);if(!Rr(this,s,t,n))return-1;const i=s.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=i[o]&127,this.blockLength++,!!(i[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,i[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=ws(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Co();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(t.slice(s*7,s*7+7),2)+(s+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 s=this.valueHexView,i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)i[a]=s[a]|128;return i[this.blockLength-1]=s[this.blockLength-1],i.buffer}const t=Bn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",er;const n=new Uint8Array(t.byteLength);if(!e){const s=new Uint8Array(t),i=t.byteLength-1;for(let a=0;a<i;a++)n[a]=s[a]|128;n[i]=s[i]}return n}toString(){let e="";if(this.isHexOnly)e=re.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}}}nl.NAME="sidBlock";class op extends xt{constructor({value:e=Ot,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new nl;if(s=i.fromBER(e,s,n),s===-1)return this.blockLength=0,this.error=i.error,s;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return s}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const s=this.value[n].toBER(e);if(s.byteLength===0)return this.error=this.value[n].error,er;t.push(s)}return Xu(t)}fromString(e){this.value=[];let t=0,n=0,s="",i=!1;do if(n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1,i){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(s,10);if(isNaN(c))return;a.valueDec=c+o,i=!1}else{const a=new nl;if(s>Number.MAX_SAFE_INTEGER){Co();const o=BigInt(s);a.valueBigInt=o}else if(a.valueDec=parseInt(s,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,i=!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 s=this.value[n].toString();n!==0&&(e=`${e}.`),t?(s=`{${s}}`,this.value[n].isFirstSid?e=`2.{${s} - 80}`:e+=s):e+=s}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}}op.NAME="ObjectIdentifierValueBlock";var cp;class Bo extends dt{constructor(e={}){super(e,op),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()}}}cp=Bo,X.ObjectIdentifier=cp,Bo.NAME="OBJECT IDENTIFIER";class sl extends vr(Rn){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const s=L.toUint8Array(e);if(!Rr(this,s,t,n))return-1;const i=s.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=i[o]&127,this.blockLength++,!!(i[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,i[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=ws(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 s=this.valueHexView,i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)i[a]=s[a]|128;return i[this.blockLength-1]=s[this.blockLength-1],i.buffer}const t=Bn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",er;const n=new Uint8Array(t.byteLength);if(!e){const s=new Uint8Array(t),i=t.byteLength-1;for(let a=0;a<i;a++)n[a]=s[a]|128;n[i]=s[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=re.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}sl.NAME="relativeSidBlock";class up extends xt{constructor({value:e=Ot,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new sl;if(s=i.fromBER(e,s,n),s===-1)return this.blockLength=0,this.error=i.error,s;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return s}toBER(e,t){const n=[];for(let s=0;s<this.value.length;s++){const i=this.value[s].toBER(e);if(i.byteLength===0)return this.error=this.value[s].error,er;n.push(i)}return Xu(n)}fromString(e){this.value=[];let t=0,n=0,s="";do{n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1;const i=new sl;if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return!0;this.value.push(i)}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 s=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(s=`{${s}}`),e+=s}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}}up.NAME="RelativeObjectIdentifierValueBlock";var lp;class il extends dt{constructor(e={}){super(e,up),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()}}}lp=il,X.RelativeObjectIdentifier=lp,il.NAME="RelativeObjectIdentifier";var dp;class Pr extends Et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}dp=Pr,X.Sequence=dp,Pr.NAME="SEQUENCE";var fp;let $r=class extends Et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};fp=$r,X.Set=fp,$r.NAME="SET";class hp extends vr(xt){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ot}toJSON(){return{...super.toJSON(),value:this.value}}}hp.NAME="StringValueBlock";class pp extends hp{}pp.NAME="SimpleStringValueBlock";class $t extends el{constructor({...e}={}){super(e,pp)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,L.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);this.valueBlock.value=e}}$t.NAME="SIMPLE STRING";class mp extends $t{fromBuffer(e){this.valueBlock.valueHexView=L.toUint8Array(e);try{this.valueBlock.value=re.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=re.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(re.FromUtf8String(e)),this.valueBlock.value=e}}mp.NAME="Utf8StringValueBlock";var yp;class Zr extends mp{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}yp=Zr,X.Utf8String=yp,Zr.NAME="UTF8String";class gp extends $t{fromBuffer(e){this.valueBlock.value=re.ToUtf16String(e),this.valueBlock.valueHexView=L.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(re.FromUtf16String(e))}}gp.NAME="BmpStringValueBlock";var vp;class Ro extends gp{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}vp=Ro,X.BmpString=vp,Ro.NAME="BMPString";class bp extends $t{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let s=0;s<n.length;s+=4)n[s]=n[s+3],n[s+1]=n[s+2],n[s+2]=0,n[s+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 s=0;s<t;s++){const i=Bn(e.charCodeAt(s),8),a=new Uint8Array(i);if(a.length>4)continue;const o=4-a.length;for(let c=a.length-1;c>=0;c--)n[s*4+c+o]=a[c]}this.valueBlock.value=e}}bp.NAME="UniversalStringValueBlock";var xp;class Po extends bp{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}xp=Po,X.UniversalString=xp,Po.NAME="UniversalString";var _p;class $o extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}_p=$o,X.NumericString=_p,$o.NAME="NumericString";var wp;class Zo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}wp=Zo,X.PrintableString=wp,Zo.NAME="PrintableString";var kp;class Do extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}kp=Do,X.TeletexString=kp,Do.NAME="TeletexString";var Sp;class Mo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Sp=Mo,X.VideotexString=Sp,Mo.NAME="VideotexString";var Ap;class Vo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Ap=Vo,X.IA5String=Ap,Vo.NAME="IA5String";var Op;class Uo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Op=Uo,X.GraphicString=Op,Uo.NAME="GraphicString";var Ep;class na extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Ep=na,X.VisibleString=Ep,na.NAME="VisibleString";var Cp;class Lo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Cp=Lo,X.GeneralString=Cp,Lo.NAME="GeneralString";var Ip;class qo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Ip=qo,X.CharacterString=Ip,qo.NAME="CharacterString";var jp;class sa extends na{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 s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}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,L.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);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 s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,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}}}jp=sa,X.UTCTime=jp,sa.NAME="UTCTime";var Tp;class Ho extends sa{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="",s="",i=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("+"),j="";if(B===-1&&(B=n.indexOf("-"),m=-1),B!==-1){if(j=n.substring(B+1),n=n.substring(0,B),j.length!==2&&j.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(j.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(o=m*p,j.length===4){if(p=parseInt(j.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");i=m.valueOf(),s=n.substring(0,u)}else s=n;switch(!0){case s.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*i;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 s.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*i;this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case s.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const m=1e3*i;this.millisecond=Math.floor(m)}break;default:throw new Error("Wrong input string for conversion")}const f=a.exec(s);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}}}Tp=Ho,X.GeneralizedTime=Tp,Ho.NAME="GeneralizedTime";var Np;class al extends Zr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Np=al,X.DATE=Np,al.NAME="DATE";var Bp;class ol extends Zr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Bp=ol,X.TimeOfDay=Bp,ol.NAME="TimeOfDay";var Rp;class cl extends Zr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Rp=cl,X.DateTime=Rp,cl.NAME="DateTime";var Pp;class ul extends Zr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Pp=ul,X.Duration=Pp,ul.NAME="Duration";var $p;class ll extends Zr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}$p=ll,X.TIME=$p,ll.NAME="TIME";class Dn{constructor({name:e=Ot,optional:t=!1}={}){this.name=e,this.optional=t}}class dl extends Dn{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Fo extends Dn{constructor({value:e=new Dn,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class qx{constructor({data:e=jo}={}){this.dataView=L.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=L.toUint8Array(e)}fromBER(e,t,n){const s=t+n;return this.dataView=L.toUint8Array(e).subarray(t,s),s}toBER(e){return this.dataView.slice().buffer}}function Mn(r,e,t){if(t instanceof dl){for(let i=0;i<t.value.length;i++)if(Mn(r,e,t.value[i]).verified)return{verified:!0,result:r};{const i={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(Qu)&&(i.name=t.name),i}}if(t instanceof Dn)return t.hasOwnProperty(Qu)&&(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(!(Nx in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!($x in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Zx 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(Bx)===!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(Rx)===!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(Px)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(Tx 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(!(Mh in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=t.idBlock.valueHexView,a=e.idBlock.valueHexView;if(i.length!==a.length)return{verified:!1,result:r};for(let o=0;o<i.length;o++)if(i[o]!==a[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Ot),t.name&&(r[t.name]=e)),t instanceof X.Constructed){let i=0,a={verified:!1,result:{error:"Unknown error"}},o=t.valueBlock.value.length;if(o>0&&t.valueBlock.value[0]instanceof Fo&&(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,Ot),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let c=0;c<o;c++)if(c-i>=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,Ot),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof Fo){if(a=Mn(r,e.valueBlock.value[c],t.valueBlock.value[0].value),a.verified===!1)if(t.valueBlock.value[0].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Ot),t.name&&delete r[t.name]),a;if(Qu in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};Dx 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=Mn(r,e.valueBlock.value[c-i],t.valueBlock.value[c]),a.verified===!1)if(t.valueBlock.value[c].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Ot),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,Ot),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&Mh in e.valueBlock){const i=ks(e.valueBlock.valueHexView);if(i.offset===-1){const a={verified:!1,result:i.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Ot),t.name&&(delete r[t.name],a.name=t.name)),a}return Mn(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function Hx(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=ks(L.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Mn(t.result,t.result,e)}const Zp=Object.freeze(Object.defineProperty({__proto__:null,Any:Dn,BaseBlock:dt,BaseStringBlock:el,BitString:Zn,BmpString:Ro,Boolean:To,CharacterString:qo,Choice:dl,Constructed:Et,DATE:al,DateTime:cl,Duration:ul,EndOfContent:tl,Enumerated:No,GeneralString:Lo,GeneralizedTime:Ho,GraphicString:Uo,HexBlock:vr,IA5String:Vo,Integer:br,Null:Pn,NumericString:$o,ObjectIdentifier:Bo,OctetString:$n,Primitive:ra,PrintableString:Zo,RawData:qx,RelativeObjectIdentifier:il,Repeated:Fo,Sequence:Pr,Set:$r,TIME:ll,TeletexString:Do,TimeOfDay:ol,UTCTime:sa,UniversalString:Po,Utf8String:Zr,ValueBlock:xt,VideotexString:Mo,ViewWriter:Io,VisibleString:na,compareSchema:Mn,fromBER:Ss,verifySchema:Hx},Symbol.toStringTag,{value:"Module"}));var N;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(N||(N={}));var y;(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"})(y||(y={}));class Wo{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(L.isBufferSource(e))this.unusedBits=t,this.value=L.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Zn))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 Zn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Zn({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 s=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let i=0;for(;i<n;)s[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=s.buffer}}class Re{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):L.isBufferSource(e)?this.buffer=L.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof $n))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new $n({valueHex:this.buffer})}toSchema(e){return new $n({name:e})}}const Fx={fromASN:r=>r instanceof Pn?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new Pn;const e=Ss(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Wx={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new br({value:+r})},zx={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new No({value:r})},ze={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new br({valueHex:r})},Kx={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Zn({valueHex:r})},Gx={fromASN:r=>r.valueBlock.toString(),toASN:r=>new Bo({value:r})},Jx={fromASN:r=>r.valueBlock.value,toASN:r=>new To({value:r})},zo={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new $n({valueHex:r})},Yx={fromASN:r=>new Re(r.getValue()),toASN:r=>r.toASN()};function Ut(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Dp=Ut(Zr),Xx=Ut(Ro),Qx=Ut(Po),e_=Ut($o),t_=Ut(Zo),r_=Ut(Do),n_=Ut(Mo),s_=Ut(Vo),i_=Ut(Uo),a_=Ut(na),o_=Ut(Lo),c_=Ut(qo),u_={fromASN:r=>r.toDate(),toASN:r=>new sa({valueDate:r})},l_={fromASN:r=>r.toDate(),toASN:r=>new Ho({valueDate:r})},d_={fromASN:()=>null,toASN:()=>new Pn};function fl(r){switch(r){case y.Any:return Fx;case y.BitString:return Kx;case y.BmpString:return Xx;case y.Boolean:return Jx;case y.CharacterString:return c_;case y.Enumerated:return zx;case y.GeneralString:return o_;case y.GeneralizedTime:return l_;case y.GraphicString:return i_;case y.IA5String:return s_;case y.Integer:return Wx;case y.Null:return d_;case y.NumericString:return e_;case y.ObjectIdentifier:return Gx;case y.OctetString:return zo;case y.PrintableString:return t_;case y.TeletexString:return r_;case y.UTCTime:return u_;case y.UniversalString:return Qx;case y.Utf8String:return Dp;case y.VideotexString:return n_;case y.VisibleString:return a_;default:return null}}function Dr(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Dr(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Mp(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:Mp(t)}return!1}function f_(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}class h_{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:N.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),s=[];for(const i in n.items){const a=n.items[i],o=t?i:"";let c;if(typeof a.type=="number"){const f=y[a.type],m=Zp[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else Dr(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===N.Choice?c=new Dn({name:o}):(c=this.create(a.type,!1),c.name=o):c=new Dn({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const f=a.repeated==="set"?$r:Pr;c=new f({name:"",value:[new Fo({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Dr(a.type)){const f=a.repeated?Et:ra;s.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,s.push(new Et({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else s.push(new Et({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,s.push(c)}switch(n.type){case N.Sequence:return new Pr({value:s,name:""});case N.Set:return new $r({value:s,name:""});case N.Choice:return new dl({value:s,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 Lt=new h_,$=r=>e=>{let t;Lt.has(e)?t=Lt.get(e):(t=Lt.createDefault(e),Lt.set(e,t)),Object.assign(t,r)},h=r=>(e,t)=>{let n;Lt.has(e.constructor)?n=Lt.get(e.constructor):(n=Lt.createDefault(e.constructor),Lt.set(e.constructor,n));const s=Object.assign({},r);if(typeof s.type=="number"&&!s.converter){const i=fl(r.type);if(!i)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);s.converter=i}n.items[t]=s};class Vp extends Error{constructor(){super(...arguments),this.schemas=[]}}class p_{static parse(e,t){const n=Ss(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(Dr(t))return new t().fromASN(e);const s=Lt.get(t);Lt.cache(t);let i=s.schema;if(e.constructor===Et&&s.type!==N.Choice){i=new Et({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:s.schema.valueBlock.value});for(const c in s.items)delete e[c]}const a=Mn({},e,i);if(!a.verified)throw new Vp(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(Mp(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=s.itemType;if(typeof c=="number"){const u=fl(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 s.items){const u=a.result[c];if(!u)continue;const f=s.items[c],m=f.type;if(typeof m=="number"||Dr(m)){const B=(n=f.converter)!==null&&n!==void 0?n:Dr(m)?new m:null;if(!B)throw new Error("Converter is empty");if(f.repeated)if(f.implicit){const j=f.repeated==="sequence"?Pr:$r,p=new j;p.valueBlock=u.valueBlock;const g=Ss(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,S=>B.fromASN(S))}else o[c]=Array.from(u,j=>B.fromASN(j));else{let j=u;if(f.implicit){let p;if(Dr(m))p=new m().toSchema("");else{const g=y[m],A=Zp[g];if(!A)throw new Error(`Cannot get '${g}' class from asn1js module`);p=new A}p.valueBlock=j.valueBlock,j=Ss(p.toBER(!1)).result}o[c]=B.fromASN(j)}}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(s){throw s instanceof Vp&&s.schemas.push(t.name),s}}}class hl{static serialize(e){return e instanceof dt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Dr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=Lt.get(t);Lt.cache(t);let s=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const a=fl(n.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);s=e.map(o=>a.toASN(o))}else s=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"&&f_(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=hl.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||Dr(o.type))){const f={};f.valueHex=u instanceof Pn?u.valueBeforeDecodeView:u.valueBlock.toBER(),s.push(new ra({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else s.push(new Et({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else s.push(new Et({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else o.repeated?s=s.concat(u):s.push(u)}let i;switch(n.type){case N.Sequence:i=new Pr({value:s});break;case N.Set:i=new $r({value:s});break;case N.Choice:if(!s[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);i=s[0];break}return i}static toAsnItem(e,t,n,s){let i;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${t}' doesn't have converter for type ${y[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(s))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(s,u=>a.toASN(u)),c=e.repeated==="sequence"?Pr:$r;i=new c({value:o})}else i=a.toASN(s)}else if(e.repeated){if(!Array.isArray(s))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(s,c=>this.toASN(c)),o=e.repeated==="sequence"?Pr:$r;i=new o({value:a})}else i=this.toASN(s);return i}}class Me extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class F{static serialize(e){return hl.serialize(e)}static parse(e,t){return p_.parse(e,t)}static toString(e){const t=L.isBufferSource(e)?L.toArrayBuffer(e):F.serialize(e),n=Ss(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 s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(i=(s<3?a(i):s>3?a(e,t,i):a(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i}typeof SuppressedError=="function"&&SuppressedError;var Up={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")},s=new RegExp("^0[0-7]+$","i"),i=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,S=-1,R=(p.match(c.zoneIndex)||[])[0],T,ve;for(R&&(R=R.substring(1),p=p.replace(/%.+$/,""));(S=p.indexOf(":",S+1))>=0;)A++;if(p.substr(0,2)==="::"&&A--,p.substr(-2,2)==="::"&&A--,A>g)return null;for(ve=g-A,T=":";ve--;)T+="0:";return p=p.replace("::",T),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),g=function(){const Ue=p.split(":"),qe=[];for(let $e=0;$e<Ue.length;$e++)qe.push(parseInt(Ue[$e],16));return qe}(),{parts:g,zoneId:R}}function f(p,g,A,S){if(p.length!==g.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let R=0,T;for(;S>0;){if(T=A-S,T<0&&(T=0),p[R]>>T!==g[R]>>T)return!1;S-=A,R+=1}return!0}function m(p){if(i.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(s.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 j={};j.IPv4=function(){function p(g){if(g.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,S;for(A=0;A<g.length;A++)if(S=g[A],!(0<=S&&S<=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 S;if(A===void 0&&(S=g,g=S[0],A=S[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 S={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let R,T,ve;for(R=3;R>=0;R-=1)if(T=this.octets[R],T in S){if(ve=S[T],A&&ve!==0)return null;ve!==8&&(A=!0),g+=ve}else return null;return 32-g},p.prototype.range=function(){return j.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){return this.octets.slice(0)},p.prototype.toIPv4MappedAddress=function(){return j.IPv6.parse(`::ffff:${this.toString()}`)},p.prototype.toNormalizedString=function(){return this.toString()},p.prototype.toString=function(){return this.octets.join(".")},p}(),j.IPv4.broadcastAddressFromCIDR=function(p){try{const g=this.parseCIDR(p),A=g[0].toByteArray(),S=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),R=[];let T=0;for(;T<4;)R.push(parseInt(A[T],10)|parseInt(S[T],10)^255),T++;return new this(R)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},j.IPv4.isIPv4=function(p){return this.parser(p)!==null},j.IPv4.isValid=function(p){try{return new this(this.parser(p)),!0}catch{return!1}},j.IPv4.isValidCIDR=function(p){try{return this.parseCIDR(p),!0}catch{return!1}},j.IPv4.isValidFourPartDecimal=function(p){return!!(j.IPv4.isValid(p)&&p.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},j.IPv4.networkAddressFromCIDR=function(p){let g,A,S,R,T;try{for(g=this.parseCIDR(p),S=g[0].toByteArray(),T=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),R=[],A=0;A<4;)R.push(parseInt(S[A],10)&parseInt(T[A],10)),A++;return new this(R)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},j.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)},j.IPv4.parseCIDR=function(p){let g;if(g=p.match(/^(.+)\/(\d+)$/)){const A=parseInt(g[2]);if(A>=0&&A<=32){const S=[this.parse(g[1]),A];return Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},j.IPv4.parser=function(p){let g,A,S;if(g=p.match(n.fourOctet))return function(){const R=g.slice(1,6),T=[];for(let ve=0;ve<R.length;ve++)A=R[ve],T.push(m(A));return T}();if(g=p.match(n.longValue)){if(S=m(g[1]),S>4294967295||S<0)throw new Error("ipaddr: address outside defined range");return function(){const R=[];let T;for(T=0;T<=24;T+=8)R.push(S>>T&255);return R}().reverse()}else return(g=p.match(n.twoOctet))?function(){const R=g.slice(1,4),T=[];if(S=m(R[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return T.push(m(R[0])),T.push(S>>16&255),T.push(S>>8&255),T.push(S&255),T}():(g=p.match(n.threeOctet))?function(){const R=g.slice(1,5),T=[];if(S=m(R[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return T.push(m(R[0])),T.push(m(R[1])),T.push(S>>8&255),T.push(S&255),T}():null},j.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 S=Math.floor(p/8);for(;A<S;)g[A]=255,A++;return S<4&&(g[S]=Math.pow(2,p%8)-1<<8-p%8),new this(g)},j.IPv6=function(){function p(g,A){let S,R;if(g.length===16)for(this.parts=[],S=0;S<=14;S+=2)this.parts.push(g[S]<<8|g[S+1]);else if(g.length===8)this.parts=g;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(S=0;S<this.parts.length;S++)if(R=this.parts[S],!(0<=R&&R<=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 S;if(A===void 0&&(S=g,g=S[0],A=S[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 S={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 R,T;for(let ve=7;ve>=0;ve-=1)if(R=this.parts[ve],R in S){if(T=S[R],A&&T!==0)return null;T!==16&&(A=!0),g+=T}else return null;return 128-g},p.prototype.range=function(){return j.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let g;const A=[],S=this.parts;for(let R=0;R<S.length;R++)g=S[R],A.push(g>>8),A.push(g&255);return A},p.prototype.toFixedLengthString=function(){const g=(function(){const S=[];for(let R=0;R<this.parts.length;R++)S.push(B(this.parts[R].toString(16),4));return S}).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],S=g[1];return new j.IPv4([A>>8,A&255,S>>8,S&255])},p.prototype.toNormalizedString=function(){const g=(function(){const S=[];for(let R=0;R<this.parts.length;R++)S.push(this.parts[R].toString(16));return S}).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 S=0,R=-1,T;for(;T=g.exec(A);)T[0].length>R&&(S=T.index,R=T[0].length);return R<0?A:`${A.substring(0,S)}::${A.substring(S+R)}`},p.prototype.toString=function(){return this.toRFC5952String()},p}(),j.IPv6.broadcastAddressFromCIDR=function(p){try{const g=this.parseCIDR(p),A=g[0].toByteArray(),S=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),R=[];let T=0;for(;T<16;)R.push(parseInt(A[T],10)|parseInt(S[T],10)^255),T++;return new this(R)}catch(g){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${g})`)}},j.IPv6.isIPv6=function(p){return this.parser(p)!==null},j.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}},j.IPv6.isValidCIDR=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{return this.parseCIDR(p),!0}catch{return!1}},j.IPv6.networkAddressFromCIDR=function(p){let g,A,S,R,T;try{for(g=this.parseCIDR(p),S=g[0].toByteArray(),T=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),R=[],A=0;A<16;)R.push(parseInt(S[A],10)&parseInt(T[A],10)),A++;return new this(R)}catch(ve){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ve})`)}},j.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)},j.IPv6.parseCIDR=function(p){let g,A,S;if((A=p.match(/^(.+)\/(\d+)$/))&&(g=parseInt(A[2]),g>=0&&g<=128))return S=[this.parse(A[1]),g],Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},j.IPv6.parser=function(p){let g,A,S,R,T,ve;if(S=p.match(c.deprecatedTransitional))return this.parser(`::ffff:${S[1]}`);if(c.native.test(p))return u(p,8);if((S=p.match(c.transitional))&&(ve=S[6]||"",g=S[1],S[1].endsWith("::")||(g=g.slice(0,-1)),g=u(g+ve,6),g.parts)){for(T=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],A=0;A<T.length;A++)if(R=T[A],!(0<=R&&R<=255))return null;return g.parts.push(T[0]<<8|T[1]),g.parts.push(T[2]<<8|T[3]),{parts:g.parts,zoneId:g.zoneId}}return null},j.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 S=Math.floor(p/8);for(;A<S;)g[A]=255,A++;return S<16&&(g[S]=Math.pow(2,p%8)-1<<8-p%8),new this(g)},j.fromByteArray=function(p){const g=p.length;if(g===4)return new j.IPv4(p);if(g===16)return new j.IPv6(p);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},j.isValid=function(p){return j.IPv6.isValid(p)||j.IPv4.isValid(p)},j.isValidCIDR=function(p){return j.IPv6.isValidCIDR(p)||j.IPv4.isValidCIDR(p)},j.parse=function(p){if(j.IPv6.isValid(p))return j.IPv6.parse(p);if(j.IPv4.isValid(p))return j.IPv4.parse(p);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},j.parseCIDR=function(p){try{return j.IPv6.parseCIDR(p)}catch{try{return j.IPv4.parseCIDR(p)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},j.process=function(p){const g=this.parse(p);return g.kind()==="ipv6"&&g.isIPv4MappedAddress()?g.toIPv4Address():g},j.subnetMatch=function(p,g,A){let S,R,T,ve;A==null&&(A="unicast");for(R in g)if(Object.prototype.hasOwnProperty.call(g,R)){for(T=g[R],T[0]&&!(T[0]instanceof Array)&&(T=[T]),S=0;S<T.length;S++)if(ve=T[S],p.kind()===ve[0].kind()&&p.match.apply(p,ve))return R}return A},r.exports?r.exports=j:e.ipaddr=j})(Eo)})(Up);var Lp=Up.exports;class qp{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((s,i)=>s+ +i,0);let n=e.slice(0,8).replace(/(.{2})/g,s=>`${parseInt(s,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 Lp.fromByteArray(Array.from(t)).toString()}return this.decodeIP(re.ToHex(e))}static fromString(e){const t=Lp.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var pl,ml,yl;let ft=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};l([h({type:y.TeletexString})],ft.prototype,"teletexString",void 0),l([h({type:y.PrintableString})],ft.prototype,"printableString",void 0),l([h({type:y.UniversalString})],ft.prototype,"universalString",void 0),l([h({type:y.Utf8String})],ft.prototype,"utf8String",void 0),l([h({type:y.BmpString})],ft.prototype,"bmpString",void 0),ft=l([$({type:N.Choice})],ft);let As=class extends ft{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?re.ToHex(this.anyValue):super.toString())}};l([h({type:y.IA5String})],As.prototype,"ia5String",void 0),l([h({type:y.Any})],As.prototype,"anyValue",void 0),As=l([$({type:N.Choice})],As);class Ko{constructor(e={}){this.type="",this.value=new As,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Ko.prototype,"type",void 0),l([h({type:As})],Ko.prototype,"value",void 0);let Os=pl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,pl.prototype)}};Os=pl=l([$({type:N.Set,itemType:Ko})],Os);let gl=ml=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,ml.prototype)}};gl=ml=l([$({type:N.Sequence,itemType:Os})],gl);let it=yl=class extends gl{constructor(e){super(e),Object.setPrototypeOf(this,yl.prototype)}};it=yl=l([$({type:N.Sequence})],it);const m_={fromASN:r=>qp.toString(zo.fromASN(r)),toASN:r=>zo.toASN(qp.fromString(r))};class ia{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],ia.prototype,"typeId",void 0),l([h({type:y.Any,context:0})],ia.prototype,"value",void 0);class vl{constructor(e={}){this.partyName=new ft,Object.assign(this,e)}}l([h({type:ft,optional:!0,context:0,implicit:!0})],vl.prototype,"nameAssigner",void 0),l([h({type:ft,context:1,implicit:!0})],vl.prototype,"partyName",void 0);let ge=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ia,context:0,implicit:!0})],ge.prototype,"otherName",void 0),l([h({type:y.IA5String,context:1,implicit:!0})],ge.prototype,"rfc822Name",void 0),l([h({type:y.IA5String,context:2,implicit:!0})],ge.prototype,"dNSName",void 0),l([h({type:y.Any,context:3,implicit:!0})],ge.prototype,"x400Address",void 0),l([h({type:it,context:4,implicit:!1})],ge.prototype,"directoryName",void 0),l([h({type:vl,context:5})],ge.prototype,"ediPartyName",void 0),l([h({type:y.IA5String,context:6,implicit:!0})],ge.prototype,"uniformResourceIdentifier",void 0),l([h({type:y.OctetString,context:7,implicit:!0,converter:m_})],ge.prototype,"iPAddress",void 0),l([h({type:y.ObjectIdentifier,context:8,implicit:!0})],ge.prototype,"registeredID",void 0),ge=l([$({type:N.Choice})],ge);const bl="1.3.6.1.5.5.7",y_=`${bl}.1`,Es=`${bl}.3`,Go=`${bl}.48`,Hp=`${Go}.1`,Fp=`${Go}.2`,Wp=`${Go}.3`,zp=`${Go}.5`,dn="2.5.29";var xl;const _l=`${y_}.1`;class aa{constructor(e={}){this.accessMethod="",this.accessLocation=new ge,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],aa.prototype,"accessMethod",void 0),l([h({type:ge})],aa.prototype,"accessLocation",void 0);let Cs=xl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,xl.prototype)}};Cs=xl=l([$({type:N.Sequence,itemType:aa})],Cs);const wl=`${dn}.35`;class kl extends Re{}class Vn{constructor(e={}){e&&Object.assign(this,e)}}l([h({type:kl,context:0,optional:!0,implicit:!0})],Vn.prototype,"keyIdentifier",void 0),l([h({type:ge,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Vn.prototype,"authorityCertIssuer",void 0),l([h({type:y.Integer,context:2,optional:!0,implicit:!0,converter:ze})],Vn.prototype,"authorityCertSerialNumber",void 0);const Kp=`${dn}.19`;class Jo{constructor(e={}){this.cA=!1,Object.assign(this,e)}}l([h({type:y.Boolean,defaultValue:!1})],Jo.prototype,"cA",void 0),l([h({type:y.Integer,optional:!0})],Jo.prototype,"pathLenConstraint",void 0);var Sl;let _t=Sl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Sl.prototype)}};_t=Sl=l([$({type:N.Sequence,itemType:ge})],_t);var Al;let Gp=Al=class extends _t{constructor(e){super(e),Object.setPrototypeOf(this,Al.prototype)}};Gp=Al=l([$({type:N.Sequence})],Gp);var Ol;const Jp=`${dn}.32`;let Mr=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};l([h({type:y.IA5String})],Mr.prototype,"ia5String",void 0),l([h({type:y.VisibleString})],Mr.prototype,"visibleString",void 0),l([h({type:y.BmpString})],Mr.prototype,"bmpString",void 0),l([h({type:y.Utf8String})],Mr.prototype,"utf8String",void 0),Mr=l([$({type:N.Choice})],Mr);class El{constructor(e={}){this.organization=new Mr,this.noticeNumbers=[],Object.assign(this,e)}}l([h({type:Mr})],El.prototype,"organization",void 0),l([h({type:y.Integer,repeated:"sequence"})],El.prototype,"noticeNumbers",void 0);class Cl{constructor(e={}){Object.assign(this,e)}}l([h({type:El,optional:!0})],Cl.prototype,"noticeRef",void 0),l([h({type:Mr,optional:!0})],Cl.prototype,"explicitText",void 0);let Yo=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.IA5String})],Yo.prototype,"cPSuri",void 0),l([h({type:Cl})],Yo.prototype,"userNotice",void 0),Yo=l([$({type:N.Choice})],Yo);class Il{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Il.prototype,"policyQualifierId",void 0),l([h({type:y.Any})],Il.prototype,"qualifier",void 0);class Xo{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Xo.prototype,"policyIdentifier",void 0),l([h({type:Il,repeated:"sequence",optional:!0})],Xo.prototype,"policyQualifiers",void 0);let Qo=Ol=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Ol.prototype)}};Qo=Ol=l([$({type:N.Sequence,itemType:Xo})],Qo);let ec=class{constructor(e=0){this.value=e}};l([h({type:y.Integer})],ec.prototype,"value",void 0),ec=l([$({type:N.Choice})],ec);let Yp=class extends ec{};Yp=l([$({type:N.Choice})],Yp);var jl;const Tl=`${dn}.31`;var tr;(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"})(tr||(tr={}));class Xp extends Wo{toJSON(){const e=[],t=this.toNumber();return t&tr.aACompromise&&e.push("aACompromise"),t&tr.affiliationChanged&&e.push("affiliationChanged"),t&tr.cACompromise&&e.push("cACompromise"),t&tr.certificateHold&&e.push("certificateHold"),t&tr.cessationOfOperation&&e.push("cessationOfOperation"),t&tr.keyCompromise&&e.push("keyCompromise"),t&tr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&tr.superseded&&e.push("superseded"),t&tr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let Un=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,repeated:"sequence",implicit:!0})],Un.prototype,"fullName",void 0),l([h({type:Os,context:1,implicit:!0})],Un.prototype,"nameRelativeToCRLIssuer",void 0),Un=l([$({type:N.Choice})],Un);class Is{constructor(e={}){Object.assign(this,e)}}l([h({type:Un,context:0,optional:!0})],Is.prototype,"distributionPoint",void 0),l([h({type:Xp,context:1,optional:!0,implicit:!0})],Is.prototype,"reasons",void 0),l([h({type:ge,context:2,optional:!0,repeated:"sequence",implicit:!0})],Is.prototype,"cRLIssuer",void 0);let js=jl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,jl.prototype)}};js=jl=l([$({type:N.Sequence,itemType:Is})],js);var Nl;let Qp=Nl=class extends js{constructor(e){super(e),Object.setPrototypeOf(this,Nl.prototype)}};Qp=Nl=l([$({type:N.Sequence,itemType:Is})],Qp);class mt{constructor(e={}){this.onlyContainsUserCerts=mt.ONLY,this.onlyContainsCACerts=mt.ONLY,this.indirectCRL=mt.ONLY,this.onlyContainsAttributeCerts=mt.ONLY,Object.assign(this,e)}}mt.ONLY=!1,l([h({type:Un,context:0,optional:!0})],mt.prototype,"distributionPoint",void 0),l([h({type:y.Boolean,context:1,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsUserCerts",void 0),l([h({type:y.Boolean,context:2,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsCACerts",void 0),l([h({type:Xp,context:3,optional:!0,implicit:!0})],mt.prototype,"onlySomeReasons",void 0),l([h({type:y.Boolean,context:4,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"indirectCRL",void 0),l([h({type:y.Boolean,context:5,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsAttributeCerts",void 0);var oa;(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"})(oa||(oa={}));let Bl=class{constructor(e=oa.unspecified){this.reason=oa.unspecified,this.reason=e}toJSON(){return oa[this.reason]}toString(){return this.toJSON()}};l([h({type:y.Enumerated})],Bl.prototype,"reason",void 0),Bl=l([$({type:N.Choice})],Bl);var Rl;const em=`${dn}.37`;let tc=Rl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Rl.prototype)}};tc=Rl=l([$({type:N.Sequence,itemType:y.ObjectIdentifier})],tc);const g_=`${Es}.1`,v_=`${Es}.2`,b_=`${Es}.3`,x_=`${Es}.4`,__=`${Es}.8`,w_=`${Es}.9`;let Pl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};l([h({type:y.Integer,converter:ze})],Pl.prototype,"value",void 0),Pl=l([$({type:N.Choice})],Pl);let $l=class{constructor(e){this.value=new Date,e&&(this.value=e)}};l([h({type:y.GeneralizedTime})],$l.prototype,"value",void 0),$l=l([$({type:N.Choice})],$l);var Zl;let tm=Zl=class extends _t{constructor(e){super(e),Object.setPrototypeOf(this,Zl.prototype)}};tm=Zl=l([$({type:N.Sequence})],tm);const rm=`${dn}.15`;var rr;(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"})(rr||(rr={}));class Dl extends Wo{toJSON(){const e=this.toNumber(),t=[];return e&rr.cRLSign&&t.push("crlSign"),e&rr.dataEncipherment&&t.push("dataEncipherment"),e&rr.decipherOnly&&t.push("decipherOnly"),e&rr.digitalSignature&&t.push("digitalSignature"),e&rr.encipherOnly&&t.push("encipherOnly"),e&rr.keyAgreement&&t.push("keyAgreement"),e&rr.keyCertSign&&t.push("keyCertSign"),e&rr.keyEncipherment&&t.push("keyEncipherment"),e&rr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Ml;class rc{constructor(e={}){this.base=new ge,this.minimum=0,Object.assign(this,e)}}l([h({type:ge})],rc.prototype,"base",void 0),l([h({type:y.Integer,context:0,defaultValue:0,implicit:!0})],rc.prototype,"minimum",void 0),l([h({type:y.Integer,context:1,optional:!0,implicit:!0})],rc.prototype,"maximum",void 0);let nc=Ml=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Ml.prototype)}};nc=Ml=l([$({type:N.Sequence,itemType:rc})],nc);class nm{constructor(e={}){Object.assign(this,e)}}l([h({type:nc,context:0,optional:!0,implicit:!0})],nm.prototype,"permittedSubtrees",void 0),l([h({type:nc,context:1,optional:!0,implicit:!0})],nm.prototype,"excludedSubtrees",void 0);class sm{constructor(e={}){Object.assign(this,e)}}l([h({type:y.Integer,context:0,implicit:!0,optional:!0,converter:ze})],sm.prototype,"requireExplicitPolicy",void 0),l([h({type:y.Integer,context:1,implicit:!0,optional:!0,converter:ze})],sm.prototype,"inhibitPolicyMapping",void 0);var Vl;class Ul{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Ul.prototype,"issuerDomainPolicy",void 0),l([h({type:y.ObjectIdentifier})],Ul.prototype,"subjectDomainPolicy",void 0);let im=Vl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};im=Vl=l([$({type:N.Sequence,itemType:Ul})],im);var Ll;const am=`${dn}.17`;let ql=Ll=class extends _t{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};ql=Ll=l([$({type:N.Sequence})],ql);let Vr=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],Vr.prototype,"type",void 0),l([h({type:y.Any,repeated:"set"})],Vr.prototype,"values",void 0);var Hl;let om=Hl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Hl.prototype)}};om=Hl=l([$({type:N.Sequence,itemType:Vr})],om);const cm=`${dn}.14`;class fn extends kl{}class um{constructor(e={}){Object.assign(this,e)}}l([h({type:y.GeneralizedTime,context:0,implicit:!0,optional:!0})],um.prototype,"notBefore",void 0),l([h({type:y.GeneralizedTime,context:1,implicit:!0,optional:!0})],um.prototype,"notAfter",void 0);var ca;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(ca||(ca={}));class lm extends Wo{toJSON(){const e=[],t=this.toNumber();return t&ca.pKIXCertificate&&e.push("pKIXCertificate"),t&ca.newExtensions&&e.push("newExtensions"),t&ca.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class dm{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new lm,Object.assign(this,e)}}l([h({type:y.GeneralString})],dm.prototype,"entrustVers",void 0),l([h({type:lm})],dm.prototype,"entrustInfoFlags",void 0);var Fl;let fm=Fl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Fl.prototype)}};fm=Fl=l([$({type:N.Sequence,itemType:aa})],fm);class J{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof J&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&$h(e.parameters,this.parameters)||e.parameters===this.parameters)}}l([h({type:y.ObjectIdentifier})],J.prototype,"algorithm",void 0),l([h({type:y.Any,optional:!0})],J.prototype,"parameters",void 0);class xr{constructor(e={}){this.algorithm=new J,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:J})],xr.prototype,"algorithm",void 0),l([h({type:y.BitString})],xr.prototype,"subjectPublicKey",void 0);let ht=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:y.UTCTime})],ht.prototype,"utcTime",void 0),l([h({type:y.GeneralizedTime})],ht.prototype,"generalTime",void 0),ht=l([$({type:N.Choice})],ht);class sc{constructor(e){this.notBefore=new ht(new Date),this.notAfter=new ht(new Date),e&&(this.notBefore=new ht(e.notBefore),this.notAfter=new ht(e.notAfter))}}l([h({type:ht})],sc.prototype,"notBefore",void 0),l([h({type:ht})],sc.prototype,"notAfter",void 0);var Wl;let nr=class Kg{constructor(e={}){this.extnID="",this.critical=Kg.CRITICAL,this.extnValue=new Re,Object.assign(this,e)}};nr.CRITICAL=!1,l([h({type:y.ObjectIdentifier})],nr.prototype,"extnID",void 0),l([h({type:y.Boolean,defaultValue:nr.CRITICAL})],nr.prototype,"critical",void 0),l([h({type:Re})],nr.prototype,"extnValue",void 0);let Ln=Wl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Wl.prototype)}};Ln=Wl=l([$({type:N.Sequence,itemType:nr})],Ln);var Ts;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(Ts||(Ts={}));class qt{constructor(e={}){this.version=Ts.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new J,this.issuer=new it,this.validity=new sc,this.subject=new it,this.subjectPublicKeyInfo=new xr,Object.assign(this,e)}}l([h({type:y.Integer,context:0,defaultValue:Ts.v1})],qt.prototype,"version",void 0),l([h({type:y.Integer,converter:ze})],qt.prototype,"serialNumber",void 0),l([h({type:J})],qt.prototype,"signature",void 0),l([h({type:it})],qt.prototype,"issuer",void 0),l([h({type:sc})],qt.prototype,"validity",void 0),l([h({type:it})],qt.prototype,"subject",void 0),l([h({type:xr})],qt.prototype,"subjectPublicKeyInfo",void 0),l([h({type:y.BitString,context:1,implicit:!0,optional:!0})],qt.prototype,"issuerUniqueID",void 0),l([h({type:y.BitString,context:2,implicit:!0,optional:!0})],qt.prototype,"subjectUniqueID",void 0),l([h({type:Ln,context:3,optional:!0})],qt.prototype,"extensions",void 0);class Ns{constructor(e={}){this.tbsCertificate=new qt,this.signatureAlgorithm=new J,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:qt})],Ns.prototype,"tbsCertificate",void 0),l([h({type:J})],Ns.prototype,"signatureAlgorithm",void 0),l([h({type:y.BitString})],Ns.prototype,"signatureValue",void 0);class ic{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new ht,Object.assign(this,e)}}l([h({type:y.Integer,converter:ze})],ic.prototype,"userCertificate",void 0),l([h({type:ht})],ic.prototype,"revocationDate",void 0),l([h({type:nr,optional:!0,repeated:"sequence"})],ic.prototype,"crlEntryExtensions",void 0);class Ur{constructor(e={}){this.signature=new J,this.issuer=new it,this.thisUpdate=new ht,Object.assign(this,e)}}l([h({type:y.Integer,optional:!0})],Ur.prototype,"version",void 0),l([h({type:J})],Ur.prototype,"signature",void 0),l([h({type:it})],Ur.prototype,"issuer",void 0),l([h({type:ht})],Ur.prototype,"thisUpdate",void 0),l([h({type:ht,optional:!0})],Ur.prototype,"nextUpdate",void 0),l([h({type:ic,repeated:"sequence",optional:!0})],Ur.prototype,"revokedCertificates",void 0),l([h({type:nr,optional:!0,context:0,repeated:"sequence"})],Ur.prototype,"crlExtensions",void 0);class zl{constructor(e={}){this.tbsCertList=new Ur,this.signatureAlgorithm=new J,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Ur})],zl.prototype,"tbsCertList",void 0),l([h({type:J})],zl.prototype,"signatureAlgorithm",void 0),l([h({type:y.BitString})],zl.prototype,"signature",void 0);class Bs{constructor(e={}){this.issuer=new it,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:it})],Bs.prototype,"issuer",void 0),l([h({type:y.Integer,converter:ze})],Bs.prototype,"serialNumber",void 0);let Rs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:fn,context:0,implicit:!0})],Rs.prototype,"subjectKeyIdentifier",void 0),l([h({type:Bs})],Rs.prototype,"issuerAndSerialNumber",void 0),Rs=l([$({type:N.Choice})],Rs);var Lr;(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"})(Lr||(Lr={}));let ua=class extends J{};ua=l([$({type:N.Sequence})],ua);let ac=class extends J{};ac=l([$({type:N.Sequence})],ac);let _r=class extends J{};_r=l([$({type:N.Sequence})],_r);let oc=class extends J{};oc=l([$({type:N.Sequence})],oc);let hm=class extends J{};hm=l([$({type:N.Sequence})],hm);let Kl=class extends J{};Kl=l([$({type:N.Sequence})],Kl);let Ps=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],Ps.prototype,"attrType",void 0),l([h({type:y.Any,repeated:"set"})],Ps.prototype,"attrValues",void 0);var Gl;class wr{constructor(e={}){this.version=Lr.v0,this.sid=new Rs,this.digestAlgorithm=new ua,this.signatureAlgorithm=new ac,this.signature=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],wr.prototype,"version",void 0),l([h({type:Rs})],wr.prototype,"sid",void 0),l([h({type:ua})],wr.prototype,"digestAlgorithm",void 0),l([h({type:Ps,repeated:"set",context:0,implicit:!0,optional:!0})],wr.prototype,"signedAttrs",void 0),l([h({type:ac})],wr.prototype,"signatureAlgorithm",void 0),l([h({type:Re})],wr.prototype,"signature",void 0),l([h({type:Ps,repeated:"set",context:1,implicit:!0,optional:!0})],wr.prototype,"unsignedAttrs",void 0);let cc=Gl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Gl.prototype)}};cc=Gl=l([$({type:N.Set,itemType:wr})],cc);let pm=class extends ht{};pm=l([$({type:N.Choice})],pm);let mm=class extends wr{};mm=l([$({type:N.Sequence})],mm);class Jl{constructor(e={}){this.acIssuer=new ge,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}l([h({type:ge})],Jl.prototype,"acIssuer",void 0),l([h({type:y.Integer})],Jl.prototype,"acSerial",void 0),l([h({type:Vr,repeated:"sequence"})],Jl.prototype,"attrs",void 0);var Yl;let uc=Yl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Yl.prototype)}};uc=Yl=l([$({type:N.Sequence,itemType:y.ObjectIdentifier})],uc);class lc{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}l([h({type:y.Integer,optional:!0})],lc.prototype,"pathLenConstraint",void 0),l([h({type:uc,implicit:!0,context:0,optional:!0})],lc.prototype,"permittedAttrs",void 0),l([h({type:uc,implicit:!0,context:1,optional:!0})],lc.prototype,"excludedAttrs",void 0),l([h({type:y.Boolean,defaultValue:!0})],lc.prototype,"permitUnSpecified",void 0);class qn{constructor(e={}){this.issuer=new _t,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:_t})],qn.prototype,"issuer",void 0),l([h({type:y.Integer,converter:ze})],qn.prototype,"serial",void 0),l([h({type:y.BitString,optional:!0})],qn.prototype,"issuerUID",void 0);var Xl;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(Xl||(Xl={}));class Hn{constructor(e={}){this.digestedObjectType=Xl.publicKey,this.digestAlgorithm=new J,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Enumerated})],Hn.prototype,"digestedObjectType",void 0),l([h({type:y.ObjectIdentifier,optional:!0})],Hn.prototype,"otherObjectTypeID",void 0),l([h({type:J})],Hn.prototype,"digestAlgorithm",void 0),l([h({type:y.BitString})],Hn.prototype,"objectDigest",void 0);class dc{constructor(e={}){Object.assign(this,e)}}l([h({type:_t,optional:!0})],dc.prototype,"issuerName",void 0),l([h({type:qn,context:0,implicit:!0,optional:!0})],dc.prototype,"baseCertificateID",void 0),l([h({type:Hn,context:1,implicit:!0,optional:!0})],dc.prototype,"objectDigestInfo",void 0);let $s=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,repeated:"sequence"})],$s.prototype,"v1Form",void 0),l([h({type:dc,context:0,implicit:!0})],$s.prototype,"v2Form",void 0),$s=l([$({type:N.Choice})],$s);class fc{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}l([h({type:y.GeneralizedTime})],fc.prototype,"notBeforeTime",void 0),l([h({type:y.GeneralizedTime})],fc.prototype,"notAfterTime",void 0);class la{constructor(e={}){Object.assign(this,e)}}l([h({type:qn,implicit:!0,context:0,optional:!0})],la.prototype,"baseCertificateID",void 0),l([h({type:_t,implicit:!0,context:1,optional:!0})],la.prototype,"entityName",void 0),l([h({type:Hn,implicit:!0,context:2,optional:!0})],la.prototype,"objectDigestInfo",void 0);var Ql;(function(r){r[r.v2=1]="v2"})(Ql||(Ql={}));class sr{constructor(e={}){this.version=Ql.v2,this.holder=new la,this.issuer=new $s,this.signature=new J,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new fc,this.attributes=[],Object.assign(this,e)}}l([h({type:y.Integer})],sr.prototype,"version",void 0),l([h({type:la})],sr.prototype,"holder",void 0),l([h({type:$s})],sr.prototype,"issuer",void 0),l([h({type:J})],sr.prototype,"signature",void 0),l([h({type:y.Integer,converter:ze})],sr.prototype,"serialNumber",void 0),l([h({type:fc})],sr.prototype,"attrCertValidityPeriod",void 0),l([h({type:Vr,repeated:"sequence"})],sr.prototype,"attributes",void 0),l([h({type:y.BitString,optional:!0})],sr.prototype,"issuerUniqueID",void 0),l([h({type:Ln,optional:!0})],sr.prototype,"extensions",void 0);class hc{constructor(e={}){this.acinfo=new sr,this.signatureAlgorithm=new J,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:sr})],hc.prototype,"acinfo",void 0),l([h({type:J})],hc.prototype,"signatureAlgorithm",void 0),l([h({type:y.BitString})],hc.prototype,"signatureValue",void 0);var pc;(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"})(pc||(pc={}));class ed extends Wo{}class td{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier,implicit:!0,context:0})],td.prototype,"type",void 0),l([h({type:y.Any,implicit:!0,context:1})],td.prototype,"value",void 0);class rd{constructor(e={}){this.policyId="",this.classList=new ed(pc.unclassified),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],rd.prototype,"policyId",void 0),l([h({type:ed,defaultValue:new ed(pc.unclassified)})],rd.prototype,"classList",void 0),l([h({type:td,repeated:"set"})],rd.prototype,"securityCategories",void 0);class mc{constructor(e={}){Object.assign(this,e)}}l([h({type:Re})],mc.prototype,"cotets",void 0),l([h({type:y.ObjectIdentifier})],mc.prototype,"oid",void 0),l([h({type:y.Utf8String})],mc.prototype,"string",void 0);class ym{constructor(e={}){this.values=[],Object.assign(this,e)}}l([h({type:_t,implicit:!0,context:0,optional:!0})],ym.prototype,"policyAuthority",void 0),l([h({type:mc,repeated:"sequence"})],ym.prototype,"values",void 0);var nd;class yc{constructor(e={}){this.targetCertificate=new qn,Object.assign(this,e)}}l([h({type:qn})],yc.prototype,"targetCertificate",void 0),l([h({type:ge,optional:!0})],yc.prototype,"targetName",void 0),l([h({type:Hn,optional:!0})],yc.prototype,"certDigestInfo",void 0);let Zs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,implicit:!0})],Zs.prototype,"targetName",void 0),l([h({type:ge,context:1,implicit:!0})],Zs.prototype,"targetGroup",void 0),l([h({type:yc,context:2,implicit:!0})],Zs.prototype,"targetCert",void 0),Zs=l([$({type:N.Choice})],Zs);let sd=nd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,nd.prototype)}};sd=nd=l([$({type:N.Sequence,itemType:Zs})],sd);var id;let gm=id=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,id.prototype)}};gm=id=l([$({type:N.Sequence,itemType:sd})],gm);class vm{constructor(e={}){Object.assign(this,e)}}l([h({type:_t,implicit:!0,context:0,optional:!0})],vm.prototype,"roleAuthority",void 0),l([h({type:ge,implicit:!0,context:1})],vm.prototype,"roleName",void 0);class ad{constructor(e={}){this.service=new ge,this.ident=new ge,Object.assign(this,e)}}l([h({type:ge})],ad.prototype,"service",void 0),l([h({type:ge})],ad.prototype,"ident",void 0),l([h({type:Re,optional:!0})],ad.prototype,"authInfo",void 0);var od;class cd{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],cd.prototype,"otherCertFormat",void 0),l([h({type:y.Any})],cd.prototype,"otherCert",void 0);let Ds=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Ns})],Ds.prototype,"certificate",void 0),l([h({type:hc,context:2,implicit:!0})],Ds.prototype,"v2AttrCert",void 0),l([h({type:cd,context:3,implicit:!0})],Ds.prototype,"other",void 0),Ds=l([$({type:N.Choice})],Ds);let gc=od=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,od.prototype)}};gc=od=l([$({type:N.Set,itemType:Ds})],gc);class Ms{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Ms.prototype,"contentType",void 0),l([h({type:y.Any,context:0})],Ms.prototype,"content",void 0);let da=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Re})],da.prototype,"single",void 0),l([h({type:y.Any})],da.prototype,"any",void 0),da=l([$({type:N.Choice})],da);class vc{constructor(e={}){this.eContentType="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],vc.prototype,"eContentType",void 0),l([h({type:da,context:0,optional:!0})],vc.prototype,"eContent",void 0);let fa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Re,context:0,implicit:!0,optional:!0})],fa.prototype,"value",void 0),l([h({type:Re,converter:Yx,context:0,implicit:!0,optional:!0,repeated:"sequence"})],fa.prototype,"constructedValue",void 0),fa=l([$({type:N.Choice})],fa);class ha{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new oc,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],ha.prototype,"contentType",void 0),l([h({type:oc})],ha.prototype,"contentEncryptionAlgorithm",void 0),l([h({type:fa,optional:!0})],ha.prototype,"encryptedContent",void 0);class bc{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],bc.prototype,"keyAttrId",void 0),l([h({type:y.Any,optional:!0})],bc.prototype,"keyAttr",void 0);var ud;class xc{constructor(e={}){this.subjectKeyIdentifier=new fn,Object.assign(this,e)}}l([h({type:fn})],xc.prototype,"subjectKeyIdentifier",void 0),l([h({type:y.GeneralizedTime,optional:!0})],xc.prototype,"date",void 0),l([h({type:bc,optional:!0})],xc.prototype,"other",void 0);let Vs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:xc,context:0,implicit:!0,optional:!0})],Vs.prototype,"rKeyId",void 0),l([h({type:Bs,optional:!0})],Vs.prototype,"issuerAndSerialNumber",void 0),Vs=l([$({type:N.Choice})],Vs);class ld{constructor(e={}){this.rid=new Vs,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:Vs})],ld.prototype,"rid",void 0),l([h({type:Re})],ld.prototype,"encryptedKey",void 0);let _c=ud=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,ud.prototype)}};_c=ud=l([$({type:N.Sequence,itemType:ld})],_c);class dd{constructor(e={}){this.algorithm=new J,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:J})],dd.prototype,"algorithm",void 0),l([h({type:y.BitString})],dd.prototype,"publicKey",void 0);let Fn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:fn,context:0,implicit:!0,optional:!0})],Fn.prototype,"subjectKeyIdentifier",void 0),l([h({type:dd,context:1,implicit:!0,optional:!0})],Fn.prototype,"originatorKey",void 0),l([h({type:Bs,optional:!0})],Fn.prototype,"issuerAndSerialNumber",void 0),Fn=l([$({type:N.Choice})],Fn);class Us{constructor(e={}){this.version=Lr.v3,this.originator=new Fn,this.keyEncryptionAlgorithm=new _r,this.recipientEncryptedKeys=new _c,Object.assign(this,e)}}l([h({type:y.Integer})],Us.prototype,"version",void 0),l([h({type:Fn,context:0})],Us.prototype,"originator",void 0),l([h({type:Re,context:1,optional:!0})],Us.prototype,"ukm",void 0),l([h({type:_r})],Us.prototype,"keyEncryptionAlgorithm",void 0),l([h({type:_c})],Us.prototype,"recipientEncryptedKeys",void 0);let Ls=class{constructor(e={}){Object.assign(this,e)}};l([h({type:fn,context:0,implicit:!0})],Ls.prototype,"subjectKeyIdentifier",void 0),l([h({type:Bs})],Ls.prototype,"issuerAndSerialNumber",void 0),Ls=l([$({type:N.Choice})],Ls);class pa{constructor(e={}){this.version=Lr.v0,this.rid=new Ls,this.keyEncryptionAlgorithm=new _r,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],pa.prototype,"version",void 0),l([h({type:Ls})],pa.prototype,"rid",void 0),l([h({type:_r})],pa.prototype,"keyEncryptionAlgorithm",void 0),l([h({type:Re})],pa.prototype,"encryptedKey",void 0);class ma{constructor(e={}){this.keyIdentifier=new Re,Object.assign(this,e)}}l([h({type:Re})],ma.prototype,"keyIdentifier",void 0),l([h({type:y.GeneralizedTime,optional:!0})],ma.prototype,"date",void 0),l([h({type:bc,optional:!0})],ma.prototype,"other",void 0);class ya{constructor(e={}){this.version=Lr.v4,this.kekid=new ma,this.keyEncryptionAlgorithm=new _r,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],ya.prototype,"version",void 0),l([h({type:ma})],ya.prototype,"kekid",void 0),l([h({type:_r})],ya.prototype,"keyEncryptionAlgorithm",void 0),l([h({type:Re})],ya.prototype,"encryptedKey",void 0);class ga{constructor(e={}){this.version=Lr.v0,this.keyEncryptionAlgorithm=new _r,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],ga.prototype,"version",void 0),l([h({type:Kl,context:0,optional:!0})],ga.prototype,"keyDerivationAlgorithm",void 0),l([h({type:_r})],ga.prototype,"keyEncryptionAlgorithm",void 0),l([h({type:Re})],ga.prototype,"encryptedKey",void 0);class fd{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],fd.prototype,"oriType",void 0),l([h({type:y.Any})],fd.prototype,"oriValue",void 0);let hn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:pa,optional:!0})],hn.prototype,"ktri",void 0),l([h({type:Us,context:1,implicit:!0,optional:!0})],hn.prototype,"kari",void 0),l([h({type:ya,context:2,implicit:!0,optional:!0})],hn.prototype,"kekri",void 0),l([h({type:ga,context:3,implicit:!0,optional:!0})],hn.prototype,"pwri",void 0),l([h({type:fd,context:4,implicit:!0,optional:!0})],hn.prototype,"ori",void 0),hn=l([$({type:N.Choice})],hn);var hd;let wc=hd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,hd.prototype)}};wc=hd=l([$({type:N.Set,itemType:hn})],wc);var pd;class kc{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],kc.prototype,"otherRevInfoFormat",void 0),l([h({type:y.Any})],kc.prototype,"otherRevInfo",void 0);let Sc=class{constructor(e={}){this.other=new kc,Object.assign(this,e)}};l([h({type:kc,context:1,implicit:!0})],Sc.prototype,"other",void 0),Sc=l([$({type:N.Choice})],Sc);let Ac=pd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,pd.prototype)}};Ac=pd=l([$({type:N.Set,itemType:Sc})],Ac);class md{constructor(e={}){Object.assign(this,e)}}l([h({type:gc,context:0,implicit:!0,optional:!0})],md.prototype,"certs",void 0),l([h({type:Ac,context:1,implicit:!0,optional:!0})],md.prototype,"crls",void 0);var yd;let gd=yd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,yd.prototype)}};gd=yd=l([$({type:N.Set,itemType:Ps})],gd);class va{constructor(e={}){this.version=Lr.v0,this.recipientInfos=new wc,this.encryptedContentInfo=new ha,Object.assign(this,e)}}l([h({type:y.Integer})],va.prototype,"version",void 0),l([h({type:md,context:0,implicit:!0,optional:!0})],va.prototype,"originatorInfo",void 0),l([h({type:wc})],va.prototype,"recipientInfos",void 0),l([h({type:ha})],va.prototype,"encryptedContentInfo",void 0),l([h({type:gd,context:1,implicit:!0,optional:!0})],va.prototype,"unprotectedAttrs",void 0);const k_="1.2.840.113549.1.7.2";var vd;let Oc=vd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,vd.prototype)}};Oc=vd=l([$({type:N.Set,itemType:ua})],Oc);class qs{constructor(e={}){this.version=Lr.v0,this.digestAlgorithms=new Oc,this.encapContentInfo=new vc,this.signerInfos=new cc,Object.assign(this,e)}}l([h({type:y.Integer})],qs.prototype,"version",void 0),l([h({type:Oc})],qs.prototype,"digestAlgorithms",void 0),l([h({type:vc})],qs.prototype,"encapContentInfo",void 0),l([h({type:gc,context:0,implicit:!0,optional:!0})],qs.prototype,"certificates",void 0),l([h({type:Ac,context:1,implicit:!0,optional:!0})],qs.prototype,"crls",void 0),l([h({type:cc})],qs.prototype,"signerInfos",void 0);const ba="1.2.840.10045.2.1",bd="1.2.840.10045.4.1",bm="1.2.840.10045.4.3.1",xd="1.2.840.10045.4.3.2",_d="1.2.840.10045.4.3.3",wd="1.2.840.10045.4.3.4",xm="1.2.840.10045.3.1.7",_m="1.3.132.0.34",wm="1.3.132.0.35";function xa(r){return new J({algorithm:r})}const S_=xa(bd);xa(bm);const A_=xa(xd),O_=xa(_d),E_=xa(wd);let _a=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],_a.prototype,"fieldType",void 0),l([h({type:y.Any})],_a.prototype,"parameters",void 0),_a=l([$({type:N.Sequence})],_a);class C_ extends Re{}let Hs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.OctetString})],Hs.prototype,"a",void 0),l([h({type:y.OctetString})],Hs.prototype,"b",void 0),l([h({type:y.BitString,optional:!0})],Hs.prototype,"seed",void 0),Hs=l([$({type:N.Sequence})],Hs);var kd;(function(r){r[r.ecpVer1=1]="ecpVer1"})(kd||(kd={}));let qr=class{constructor(e={}){this.version=kd.ecpVer1,Object.assign(this,e)}};l([h({type:y.Integer})],qr.prototype,"version",void 0),l([h({type:_a})],qr.prototype,"fieldID",void 0),l([h({type:Hs})],qr.prototype,"curve",void 0),l([h({type:C_})],qr.prototype,"base",void 0),l([h({type:y.Integer,converter:ze})],qr.prototype,"order",void 0),l([h({type:y.Integer,optional:!0})],qr.prototype,"cofactor",void 0),qr=l([$({type:N.Sequence})],qr);let pn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],pn.prototype,"namedCurve",void 0),l([h({type:y.Null})],pn.prototype,"implicitCurve",void 0),l([h({type:qr})],pn.prototype,"specifiedCurve",void 0),pn=l([$({type:N.Choice})],pn);class Ec{constructor(e={}){this.version=1,this.privateKey=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],Ec.prototype,"version",void 0),l([h({type:Re})],Ec.prototype,"privateKey",void 0),l([h({type:pn,context:0,optional:!0})],Ec.prototype,"parameters",void 0),l([h({type:y.BitString,context:1,optional:!0})],Ec.prototype,"publicKey",void 0);class Cc{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Integer,converter:ze})],Cc.prototype,"r",void 0),l([h({type:y.Integer,converter:ze})],Cc.prototype,"s",void 0);const Ct="1.2.840.113549.1.1",Wn=`${Ct}.1`,I_=`${Ct}.7`,j_=`${Ct}.9`,wa=`${Ct}.10`,T_=`${Ct}.2`,N_=`${Ct}.4`,Ic=`${Ct}.5`,B_=`${Ct}.14`,Sd=`${Ct}.11`,jc=`${Ct}.12`,Tc=`${Ct}.13`,km=`${Ct}.15`,Sm=`${Ct}.16`,Nc="1.3.14.3.2.26",Am="2.16.840.1.101.3.4.2.4",Bc="2.16.840.1.101.3.4.2.1",Rc="2.16.840.1.101.3.4.2.2",Pc="2.16.840.1.101.3.4.2.3",R_="2.16.840.1.101.3.4.2.5",P_="2.16.840.1.101.3.4.2.6",$_="1.2.840.113549.2.2",Z_="1.2.840.113549.2.5",$c=`${Ct}.8`;function at(r){return new J({algorithm:r,parameters:null})}at($_),at(Z_);const zn=at(Nc);at(Am),at(Bc),at(Rc),at(Pc),at(R_),at(P_);const Om=new J({algorithm:$c,parameters:F.serialize(zn)}),Em=new J({algorithm:j_,parameters:F.serialize(zo.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(Wn),at(T_),at(N_),at(Ic),at(km),at(Sm),at(jc),at(Tc),at(km),at(Sm);class Zc{constructor(e={}){this.hashAlgorithm=new J(zn),this.maskGenAlgorithm=new J({algorithm:$c,parameters:F.serialize(zn)}),this.pSourceAlgorithm=new J(Em),Object.assign(this,e)}}l([h({type:J,context:0,defaultValue:zn})],Zc.prototype,"hashAlgorithm",void 0),l([h({type:J,context:1,defaultValue:Om})],Zc.prototype,"maskGenAlgorithm",void 0),l([h({type:J,context:2,defaultValue:Em})],Zc.prototype,"pSourceAlgorithm",void 0),new J({algorithm:I_,parameters:F.serialize(new Zc)});class Kn{constructor(e={}){this.hashAlgorithm=new J(zn),this.maskGenAlgorithm=new J({algorithm:$c,parameters:F.serialize(zn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}l([h({type:J,context:0,defaultValue:zn})],Kn.prototype,"hashAlgorithm",void 0),l([h({type:J,context:1,defaultValue:Om})],Kn.prototype,"maskGenAlgorithm",void 0),l([h({type:y.Integer,context:2,defaultValue:20})],Kn.prototype,"saltLength",void 0),l([h({type:y.Integer,context:3,defaultValue:1})],Kn.prototype,"trailerField",void 0),new J({algorithm:wa,parameters:F.serialize(new Kn)});class Dc{constructor(e={}){this.digestAlgorithm=new J,this.digest=new Re,Object.assign(this,e)}}l([h({type:J})],Dc.prototype,"digestAlgorithm",void 0),l([h({type:Re})],Dc.prototype,"digest",void 0);var Ad;class Mc{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Integer,converter:ze})],Mc.prototype,"prime",void 0),l([h({type:y.Integer,converter:ze})],Mc.prototype,"exponent",void 0),l([h({type:y.Integer,converter:ze})],Mc.prototype,"coefficient",void 0);let Od=Ad=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Ad.prototype)}};Od=Ad=l([$({type:N.Sequence,itemType:Mc})],Od);class kr{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:y.Integer})],kr.prototype,"version",void 0),l([h({type:y.Integer,converter:ze})],kr.prototype,"modulus",void 0),l([h({type:y.Integer,converter:ze})],kr.prototype,"publicExponent",void 0),l([h({type:y.Integer,converter:ze})],kr.prototype,"privateExponent",void 0),l([h({type:y.Integer,converter:ze})],kr.prototype,"prime1",void 0),l([h({type:y.Integer,converter:ze})],kr.prototype,"prime2",void 0),l([h({type:y.Integer,converter:ze})],kr.prototype,"exponent1",void 0),l([h({type:y.Integer,converter:ze})],kr.prototype,"exponent2",void 0),l([h({type:y.Integer,converter:ze})],kr.prototype,"coefficient",void 0),l([h({type:Od,optional:!0})],kr.prototype,"otherPrimeInfos",void 0);class Ed{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Integer,converter:ze})],Ed.prototype,"modulus",void 0),l([h({type:y.Integer,converter:ze})],Ed.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 It=Cd;/*! *****************************************************************************
75
+ `)}`:`${t} :`}}tp=Ct,Q.Constructed=tp,Ct.NAME="CONSTRUCTED";class rp extends wt{fromBER(e,t,n){return t}toBER(e){return rr}}rp.override="EndOfContentValueBlock";var np;class rl extends dt{constructor(e={}){super(e,rp),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}np=rl,Q.EndOfContent=np,rl.NAME=ta;var sp;class $n extends dt{constructor(e={}){super(e,wt),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 s=new Uint8Array(n);s[0]=5,s[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}sp=$n,Q.Null=sp,$n.NAME="NULL";class ip extends _r(wt){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 s=q.toUint8Array(e);return Pr(this,s,t,n)?(this.valueHexView=s.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Fh.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ip.NAME="BooleanValueBlock";var ap;let Ro=class extends dt{constructor(e={}){super(e,ip),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}`}};ap=Ro,Q.Boolean=ap,Ro.NAME="BOOLEAN";class op extends _r(dn){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=dn.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let i=0;i<this.value.length;i++){const a=this.value[i].constructor.NAME;if(a===ta){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==zh)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,t,n),this.blockLength=n;return s}toBER(e,t){return this.isConstructed?dn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}op.NAME="OctetStringValueBlock";var cp;let Zn=class Qg extends dt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var s,i;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},op),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 i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){const a=Os(i,0,i.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} : ${re.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 Qg&&e.push(t.valueBlock.valueHexView);return q.concat(e)}};cp=Zn,Q.OctetString=cp,Zn.NAME=zh;class up extends _r(dn){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 s=-1;if(this.isConstructed){if(s=dn.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(const o of this.value){const c=o.constructor.NAME;if(c===ta){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Gh)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 s}const i=q.toUint8Array(e);if(!Pr(this,i,t,n))return-1;const a=i.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=Os(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 dn.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return rr;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}}}up.NAME="BitStringValueBlock";var lp;let Dn=class extends dt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var s,i;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},up),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 s of t)e.push(s.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};lp=Dn,Q.BitString=lp,Dn.NAME=Gh;var dp;function Kx(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(e);let i=n.slice(0);const a=i.length-1,o=s.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=i[a-m]+o[c-m]+t[0];break;default:u=i[a-m]+t[0]}switch(t[0]=u/10,!0){case m>=i.length:i=Xu(new Uint8Array([u%10]),i);break;default:i[a-m]=u%10}}return t[0]>0&&(i=Xu(t,i)),i}function fp(r){if(r>=ea.length)for(let e=ea.length;e<=r;e++){const t=new Uint8Array([0]);let n=ea[e-1].slice(0);for(let s=n.length-1;s>=0;s--){const i=new Uint8Array([(n[s]<<1)+t[0]]);t[0]=i[0]/10,n[s]=i[0]%10}t[0]>0&&(n=Xu(t,n)),ea.push(n)}return ea[r]}function zx(r,e){let t=0;const n=new Uint8Array(r),s=new Uint8Array(e),i=n.slice(0),a=i.length-1,o=s.slice(0),c=o.length-1;let u,f=0;for(let m=c;m>=0;m--,f++)switch(u=i[a-f]-o[c-f]-t,!0){case u<0:t=1,i[a-f]=u+10;break;default:t=0,i[a-f]=u}if(t>0)for(let m=a-c+1;m>=0;m--,f++)if(u=i[a-f]-t,u<0)t=1,i[a-f]=u+10;else{t=0,i[a-f]=u;break}return i.slice()}class nl extends _r(wt){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=Fh.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Px(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,s=0){const i=this.fromBER(e,t,n);if(i===-1)return i;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):s!==0&&a.length<s&&(s-a.length>1&&(s=a.length+1),this.valueHexView=a.subarray(s-a.length)),i}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 s=super.fromBER(e,t,n);return s===-1||this.setValueHex(),s}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,s;const i=this.valueHexView;let a="",o=!1;for(let c=i.byteLength-1;c>=0;c--){s=i[c];for(let u=0;u<8;u++){if((s&1)===1)switch(n){case e:t=zx(fp(n),t),a="-";break;default:t=Kx(t,fp(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Wh.charAt(t[c]));return o===!1&&(a+=Wh.charAt(0)),a}}dp=nl,nl.NAME="IntegerValueBlock",Object.defineProperty(dp.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var hp;class wr extends dt{constructor(e={}){super(e,nl),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return To(),BigInt(this.valueBlock.toString())}static fromBigInt(e){To();const t=BigInt(e),n=new No,s=t.toString(16).replace(/^-/,""),i=new Uint8Array(re.FromHex(s));if(t<0){const o=new Uint8Array(i.length+(i[0]&128?1:0));o[0]|=128;const u=BigInt(`0x${re.ToHex(o)}`)+t,f=q.toUint8Array(re.FromHex(u.toString(16)));f[0]|=128,n.write(f)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);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()}`}}hp=wr,Q.Integer=hp,wr.NAME="INTEGER";var pp;class Po extends wr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}pp=Po,Q.Enumerated=pp,Po.NAME="ENUMERATED";class sl extends _r(wt){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 s=q.toUint8Array(e);if(!Pr(this,s,t,n))return-1;const i=s.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=i[o]&127,this.blockLength++,!!(i[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,i[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=As(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){To();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(t.slice(s*7,s*7+7),2)+(s+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 s=this.valueHexView,i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)i[a]=s[a]|128;return i[this.blockLength-1]=s[this.blockLength-1],i.buffer}const t=Rn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",rr;const n=new Uint8Array(t.byteLength);if(!e){const s=new Uint8Array(t),i=t.byteLength-1;for(let a=0;a<i;a++)n[a]=s[a]|128;n[i]=s[i]}return n}toString(){let e="";if(this.isHexOnly)e=re.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}}}sl.NAME="sidBlock";class mp extends wt{constructor({value:e=Et,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new sl;if(s=i.fromBER(e,s,n),s===-1)return this.blockLength=0,this.error=i.error,s;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return s}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const s=this.value[n].toBER(e);if(s.byteLength===0)return this.error=this.value[n].error,rr;t.push(s)}return Qu(t)}fromString(e){this.value=[];let t=0,n=0,s="",i=!1;do if(n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1,i){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(s,10);if(isNaN(c))return;a.valueDec=c+o,i=!1}else{const a=new sl;if(s>Number.MAX_SAFE_INTEGER){To();const o=BigInt(s);a.valueBigInt=o}else if(a.valueDec=parseInt(s,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,i=!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 s=this.value[n].toString();n!==0&&(e=`${e}.`),t?(s=`{${s}}`,this.value[n].isFirstSid?e=`2.{${s} - 80}`:e+=s):e+=s}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}}mp.NAME="ObjectIdentifierValueBlock";var yp;class $o extends dt{constructor(e={}){super(e,mp),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()}}}yp=$o,Q.ObjectIdentifier=yp,$o.NAME="OBJECT IDENTIFIER";class il extends _r(Pn){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const s=q.toUint8Array(e);if(!Pr(this,s,t,n))return-1;const i=s.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=i[o]&127,this.blockLength++,!!(i[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,i[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=As(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 s=this.valueHexView,i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)i[a]=s[a]|128;return i[this.blockLength-1]=s[this.blockLength-1],i.buffer}const t=Rn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",rr;const n=new Uint8Array(t.byteLength);if(!e){const s=new Uint8Array(t),i=t.byteLength-1;for(let a=0;a<i;a++)n[a]=s[a]|128;n[i]=s[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=re.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}il.NAME="relativeSidBlock";class gp extends wt{constructor({value:e=Et,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new il;if(s=i.fromBER(e,s,n),s===-1)return this.blockLength=0,this.error=i.error,s;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return s}toBER(e,t){const n=[];for(let s=0;s<this.value.length;s++){const i=this.value[s].toBER(e);if(i.byteLength===0)return this.error=this.value[s].error,rr;n.push(i)}return Qu(n)}fromString(e){this.value=[];let t=0,n=0,s="";do{n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1;const i=new il;if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return!0;this.value.push(i)}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 s=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(s=`{${s}}`),e+=s}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}}gp.NAME="RelativeObjectIdentifierValueBlock";var vp;class al extends dt{constructor(e={}){super(e,gp),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()}}}vp=al,Q.RelativeObjectIdentifier=vp,al.NAME="RelativeObjectIdentifier";var bp;class $r extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}bp=$r,Q.Sequence=bp,$r.NAME="SEQUENCE";var xp;let Zr=class extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};xp=Zr,Q.Set=xp,Zr.NAME="SET";class _p extends _r(wt){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Et}toJSON(){return{...super.toJSON(),value:this.value}}}_p.NAME="StringValueBlock";class wp extends _p{}wp.NAME="SimpleStringValueBlock";class $t extends tl{constructor({...e}={}){super(e,wp)}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 s=0;s<t;s++)n[s]=e.charCodeAt(s);this.valueBlock.value=e}}$t.NAME="SIMPLE STRING";class kp extends $t{fromBuffer(e){this.valueBlock.valueHexView=q.toUint8Array(e);try{this.valueBlock.value=re.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=re.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(re.FromUtf8String(e)),this.valueBlock.value=e}}kp.NAME="Utf8StringValueBlock";var Sp;class Dr extends kp{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Sp=Dr,Q.Utf8String=Sp,Dr.NAME="UTF8String";class Ap extends $t{fromBuffer(e){this.valueBlock.value=re.ToUtf16String(e),this.valueBlock.valueHexView=q.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(re.FromUtf16String(e))}}Ap.NAME="BmpStringValueBlock";var Op;class Zo extends Ap{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Op=Zo,Q.BmpString=Op,Zo.NAME="BMPString";class Ep extends $t{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let s=0;s<n.length;s+=4)n[s]=n[s+3],n[s+1]=n[s+2],n[s+2]=0,n[s+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 s=0;s<t;s++){const i=Rn(e.charCodeAt(s),8),a=new Uint8Array(i);if(a.length>4)continue;const o=4-a.length;for(let c=a.length-1;c>=0;c--)n[s*4+c+o]=a[c]}this.valueBlock.value=e}}Ep.NAME="UniversalStringValueBlock";var Cp;class Do extends Ep{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Cp=Do,Q.UniversalString=Cp,Do.NAME="UniversalString";var Ip;class Mo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Ip=Mo,Q.NumericString=Ip,Mo.NAME="NumericString";var jp;class Vo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}jp=Vo,Q.PrintableString=jp,Vo.NAME="PrintableString";var Tp;class Uo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Tp=Uo,Q.TeletexString=Tp,Uo.NAME="TeletexString";var Np;class Lo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Np=Lo,Q.VideotexString=Np,Lo.NAME="VideotexString";var Bp;class qo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Bp=qo,Q.IA5String=Bp,qo.NAME="IA5String";var Rp;class Ho extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Rp=Ho,Q.GraphicString=Rp,Ho.NAME="GraphicString";var Pp;class na extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Pp=na,Q.VisibleString=Pp,na.NAME="VisibleString";var $p;class Fo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}$p=Fo,Q.GeneralString=$p,Fo.NAME="GeneralString";var Zp;class Wo extends $t{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Zp=Wo,Q.CharacterString=Zp,Wo.NAME="CharacterString";var Dp;class sa extends na{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 s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}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 s=0;s<e.length;s++)n[s]=e.charCodeAt(s);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 s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,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}}}Dp=sa,Q.UTCTime=Dp,sa.NAME="UTCTime";var Mp;class Ko extends sa{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="",s="",i=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");i=m.valueOf(),s=n.substring(0,u)}else s=n;switch(!0){case s.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*i;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 s.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*i;this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case s.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const m=1e3*i;this.millisecond=Math.floor(m)}break;default:throw new Error("Wrong input string for conversion")}const f=a.exec(s);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}}}Mp=Ko,Q.GeneralizedTime=Mp,Ko.NAME="GeneralizedTime";var Vp;class ol extends Dr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Vp=ol,Q.DATE=Vp,ol.NAME="DATE";var Up;class cl extends Dr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Up=cl,Q.TimeOfDay=Up,cl.NAME="TimeOfDay";var Lp;class ul extends Dr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Lp=ul,Q.DateTime=Lp,ul.NAME="DateTime";var qp;class ll extends Dr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}qp=ll,Q.Duration=qp,ll.NAME="Duration";var Hp;class dl extends Dr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Hp=dl,Q.TIME=Hp,dl.NAME="TIME";class Mn{constructor({name:e=Et,optional:t=!1}={}){this.name=e,this.optional=t}}class fl extends Mn{constructor({value:e=[],...t}={}){super(t),this.value=e}}class zo extends Mn{constructor({value:e=new Mn,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class Gx{constructor({data:e=Bo}={}){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 s=t+n;return this.dataView=q.toUint8Array(e).subarray(t,s),s}toBER(e){return this.dataView.slice().buffer}}function Vn(r,e,t){if(t instanceof fl){for(let i=0;i<t.value.length;i++)if(Vn(r,e,t.value[i]).verified)return{verified:!0,result:r};{const i={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(el)&&(i.name=t.name),i}}if(t instanceof Mn)return t.hasOwnProperty(el)&&(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(!(Dx in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Lx in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(qx 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(Mx)===!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(Vx)===!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(Ux)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(Zx 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(!(Kh in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=t.idBlock.valueHexView,a=e.idBlock.valueHexView;if(i.length!==a.length)return{verified:!1,result:r};for(let o=0;o<i.length;o++)if(i[o]!==a[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&(r[t.name]=e)),t instanceof Q.Constructed){let i=0,a={verified:!1,result:{error:"Unknown error"}},o=t.valueBlock.value.length;if(o>0&&t.valueBlock.value[0]instanceof zo&&(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,Et),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let c=0;c<o;c++)if(c-i>=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,Et),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof zo){if(a=Vn(r,e.valueBlock.value[c],t.valueBlock.value[0].value),a.verified===!1)if(t.valueBlock.value[0].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&delete r[t.name]),a;if(el in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};Hx 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-i],t.valueBlock.value[c]),a.verified===!1)if(t.valueBlock.value[c].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),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,Et),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&Kh in e.valueBlock){const i=Os(e.valueBlock.valueHexView);if(i.offset===-1){const a={verified:!1,result:i.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&(delete r[t.name],a.name=t.name)),a}return Vn(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function Jx(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Os(q.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Vn(t.result,t.result,e)}const Fp=Object.freeze(Object.defineProperty({__proto__:null,Any:Mn,BaseBlock:dt,BaseStringBlock:tl,BitString:Dn,BmpString:Zo,Boolean:Ro,CharacterString:Wo,Choice:fl,Constructed:Ct,DATE:ol,DateTime:ul,Duration:ll,EndOfContent:rl,Enumerated:Po,GeneralString:Fo,GeneralizedTime:Ko,GraphicString:Ho,HexBlock:_r,IA5String:qo,Integer:wr,Null:$n,NumericString:Mo,ObjectIdentifier:$o,OctetString:Zn,Primitive:ra,PrintableString:Vo,RawData:Gx,RelativeObjectIdentifier:al,Repeated:zo,Sequence:$r,Set:Zr,TIME:dl,TeletexString:Uo,TimeOfDay:cl,UTCTime:sa,UniversalString:Do,Utf8String:Dr,ValueBlock:wt,VideotexString:Lo,ViewWriter:No,VisibleString:na,compareSchema:Vn,fromBER:Es,verifySchema:Jx},Symbol.toStringTag,{value:"Module"}));var N;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(N||(N={}));var g;(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"})(g||(g={}));class Go{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 Dn))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 Dn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Dn({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 s=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let i=0;for(;i<n;)s[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=s.buffer}}class Re{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 Zn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Zn({valueHex:this.buffer})}toSchema(e){return new Zn({name:e})}}const Yx={fromASN:r=>r instanceof $n?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new $n;const e=Es(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Xx={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new wr({value:+r})},Qx={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Po({value:r})},Ke={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new wr({valueHex:r})},e_={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Dn({valueHex:r})},t_={fromASN:r=>r.valueBlock.toString(),toASN:r=>new $o({value:r})},r_={fromASN:r=>r.valueBlock.value,toASN:r=>new Ro({value:r})},Jo={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Zn({valueHex:r})},n_={fromASN:r=>new Re(r.getValue()),toASN:r=>r.toASN()};function Lt(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Wp=Lt(Dr),s_=Lt(Zo),i_=Lt(Do),a_=Lt(Mo),o_=Lt(Vo),c_=Lt(Uo),u_=Lt(Lo),l_=Lt(qo),d_=Lt(Ho),f_=Lt(na),h_=Lt(Fo),p_=Lt(Wo),m_={fromASN:r=>r.toDate(),toASN:r=>new sa({valueDate:r})},y_={fromASN:r=>r.toDate(),toASN:r=>new Ko({valueDate:r})},g_={fromASN:()=>null,toASN:()=>new $n};function hl(r){switch(r){case g.Any:return Yx;case g.BitString:return e_;case g.BmpString:return s_;case g.Boolean:return r_;case g.CharacterString:return p_;case g.Enumerated:return Qx;case g.GeneralString:return h_;case g.GeneralizedTime:return y_;case g.GraphicString:return d_;case g.IA5String:return l_;case g.Integer:return Xx;case g.Null:return g_;case g.NumericString:return a_;case g.ObjectIdentifier:return t_;case g.OctetString:return Jo;case g.PrintableString:return o_;case g.TeletexString:return c_;case g.UTCTime:return m_;case g.UniversalString:return i_;case g.Utf8String:return Wp;case g.VideotexString:return u_;case g.VisibleString:return f_;default:return null}}function Mr(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Mr(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Kp(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:Kp(t)}return!1}function v_(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}class b_{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:N.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),s=[];for(const i in n.items){const a=n.items[i],o=t?i:"";let c;if(typeof a.type=="number"){const f=g[a.type],m=Fp[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else Mr(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===N.Choice?c=new Mn({name:o}):(c=this.create(a.type,!1),c.name=o):c=new Mn({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const f=a.repeated==="set"?Zr:$r;c=new f({name:"",value:[new zo({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Mr(a.type)){const f=a.repeated?Ct:ra;s.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,s.push(new Ct({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else s.push(new Ct({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,s.push(c)}switch(n.type){case N.Sequence:return new $r({value:s,name:""});case N.Set:return new Zr({value:s,name:""});case N.Choice:return new fl({value:s,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 b_,$=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 s=Object.assign({},r);if(typeof s.type=="number"&&!s.converter){const i=hl(r.type);if(!i)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);s.converter=i}n.items[t]=s};class zp extends Error{constructor(){super(...arguments),this.schemas=[]}}class x_{static parse(e,t){const n=Es(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(Mr(t))return new t().fromASN(e);const s=qt.get(t);qt.cache(t);let i=s.schema;if(e.constructor===Ct&&s.type!==N.Choice){i=new Ct({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:s.schema.valueBlock.value});for(const c in s.items)delete e[c]}const a=Vn({},e,i);if(!a.verified)throw new zp(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(Kp(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=s.itemType;if(typeof c=="number"){const u=hl(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 s.items){const u=a.result[c];if(!u)continue;const f=s.items[c],m=f.type;if(typeof m=="number"||Mr(m)){const B=(n=f.converter)!==null&&n!==void 0?n:Mr(m)?new m:null;if(!B)throw new Error("Converter is empty");if(f.repeated)if(f.implicit){const C=f.repeated==="sequence"?$r:Zr,p=new C;p.valueBlock=u.valueBlock;const y=Es(p.toBER(!1));if(y.offset===-1)throw new Error(`Cannot parse the child item. ${y.result.error}`);if(!("value"in y.result.valueBlock&&Array.isArray(y.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const S=y.result.valueBlock.value;o[c]=Array.from(S,A=>B.fromASN(A))}else o[c]=Array.from(u,C=>B.fromASN(C));else{let C=u;if(f.implicit){let p;if(Mr(m))p=new m().toSchema("");else{const y=g[m],S=Fp[y];if(!S)throw new Error(`Cannot get '${y}' class from asn1js module`);p=new S}p.valueBlock=C.valueBlock,C=Es(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(s){throw s instanceof zp&&s.schemas.push(t.name),s}}}class pl{static serialize(e){return e instanceof dt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Mr(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 s=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const a=hl(n.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);s=e.map(o=>a.toASN(o))}else s=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"&&v_(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=pl.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||Mr(o.type))){const f={};f.valueHex=u instanceof $n?u.valueBeforeDecodeView:u.valueBlock.toBER(),s.push(new ra({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else s.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else s.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else o.repeated?s=s.concat(u):s.push(u)}let i;switch(n.type){case N.Sequence:i=new $r({value:s});break;case N.Set:i=new Zr({value:s});break;case N.Choice:if(!s[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);i=s[0];break}return i}static toAsnItem(e,t,n,s){let i;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${t}' doesn't have converter for type ${g[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(s))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(s,u=>a.toASN(u)),c=e.repeated==="sequence"?$r:Zr;i=new c({value:o})}else i=a.toASN(s)}else if(e.repeated){if(!Array.isArray(s))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(s,c=>this.toASN(c)),o=e.repeated==="sequence"?$r:Zr;i=new o({value:a})}else i=this.toASN(s);return i}}class Me extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class U{static serialize(e){return pl.serialize(e)}static parse(e,t){return x_.parse(e,t)}static toString(e){const t=q.isBufferSource(e)?q.toArrayBuffer(e):U.serialize(e),n=Es(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 s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(i=(s<3?a(i):s>3?a(e,t,i):a(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i}typeof SuppressedError=="function"&&SuppressedError;var Gp={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")},s=new RegExp("^0[0-7]+$","i"),i=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,y){if(p.indexOf("::")!==p.lastIndexOf("::"))return null;let S=0,A=-1,R=(p.match(c.zoneIndex)||[])[0],T,ve;for(R&&(R=R.substring(1),p=p.replace(/%.+$/,""));(A=p.indexOf(":",A+1))>=0;)S++;if(p.substr(0,2)==="::"&&S--,p.substr(-2,2)==="::"&&S--,S>y)return null;for(ve=y-S,T=":";ve--;)T+="0:";return p=p.replace("::",T),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),y=function(){const Ue=p.split(":"),qe=[];for(let Ze=0;Ze<Ue.length;Ze++)qe.push(parseInt(Ue[Ze],16));return qe}(),{parts:y,zoneId:R}}function f(p,y,S,A){if(p.length!==y.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let R=0,T;for(;A>0;){if(T=S-A,T<0&&(T=0),p[R]>>T!==y[R]>>T)return!1;A-=S,R+=1}return!0}function m(p){if(i.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(s.test(p))return parseInt(p,8);throw new Error(`ipaddr: cannot parse ${p} as octal`)}return parseInt(p,10)}function B(p,y){for(;p.length<y;)p=`0${p}`;return p}const C={};C.IPv4=function(){function p(y){if(y.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let S,A;for(S=0;S<y.length;S++)if(A=y[S],!(0<=A&&A<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=y}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(y,S){let A;if(S===void 0&&(A=y,y=A[0],S=A[1]),y.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,y.octets,8,S)},p.prototype.prefixLengthFromSubnetMask=function(){let y=0,S=!1;const A={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let R,T,ve;for(R=3;R>=0;R-=1)if(T=this.octets[R],T in A){if(ve=A[T],S&&ve!==0)return null;ve!==8&&(S=!0),y+=ve}else return null;return 32-y},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 y=this.parseCIDR(p),S=y[0].toByteArray(),A=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),R=[];let T=0;for(;T<4;)R.push(parseInt(S[T],10)|parseInt(A[T],10)^255),T++;return new this(R)}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 y,S,A,R,T;try{for(y=this.parseCIDR(p),A=y[0].toByteArray(),T=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),R=[],S=0;S<4;)R.push(parseInt(A[S],10)&parseInt(T[S],10)),S++;return new this(R)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},C.IPv4.parse=function(p){const y=this.parser(p);if(y===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(y)},C.IPv4.parseCIDR=function(p){let y;if(y=p.match(/^(.+)\/(\d+)$/)){const S=parseInt(y[2]);if(S>=0&&S<=32){const A=[this.parse(y[1]),S];return Object.defineProperty(A,"toString",{value:function(){return this.join("/")}}),A}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},C.IPv4.parser=function(p){let y,S,A;if(y=p.match(n.fourOctet))return function(){const R=y.slice(1,6),T=[];for(let ve=0;ve<R.length;ve++)S=R[ve],T.push(m(S));return T}();if(y=p.match(n.longValue)){if(A=m(y[1]),A>4294967295||A<0)throw new Error("ipaddr: address outside defined range");return function(){const R=[];let T;for(T=0;T<=24;T+=8)R.push(A>>T&255);return R}().reverse()}else return(y=p.match(n.twoOctet))?function(){const R=y.slice(1,4),T=[];if(A=m(R[1]),A>16777215||A<0)throw new Error("ipaddr: address outside defined range");return T.push(m(R[0])),T.push(A>>16&255),T.push(A>>8&255),T.push(A&255),T}():(y=p.match(n.threeOctet))?function(){const R=y.slice(1,5),T=[];if(A=m(R[2]),A>65535||A<0)throw new Error("ipaddr: address outside defined range");return T.push(m(R[0])),T.push(m(R[1])),T.push(A>>8&255),T.push(A&255),T}():null},C.IPv4.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>32)throw new Error("ipaddr: invalid IPv4 prefix length");const y=[0,0,0,0];let S=0;const A=Math.floor(p/8);for(;S<A;)y[S]=255,S++;return A<4&&(y[A]=Math.pow(2,p%8)-1<<8-p%8),new this(y)},C.IPv6=function(){function p(y,S){let A,R;if(y.length===16)for(this.parts=[],A=0;A<=14;A+=2)this.parts.push(y[A]<<8|y[A+1]);else if(y.length===8)this.parts=y;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(A=0;A<this.parts.length;A++)if(R=this.parts[A],!(0<=R&&R<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");S&&(this.zoneId=S)}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(y,S){let A;if(S===void 0&&(A=y,y=A[0],S=A[1]),y.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,y.parts,16,S)},p.prototype.prefixLengthFromSubnetMask=function(){let y=0,S=!1;const A={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 R,T;for(let ve=7;ve>=0;ve-=1)if(R=this.parts[ve],R in A){if(T=A[R],S&&T!==0)return null;T!==16&&(S=!0),y+=T}else return null;return 128-y},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let y;const S=[],A=this.parts;for(let R=0;R<A.length;R++)y=A[R],S.push(y>>8),S.push(y&255);return S},p.prototype.toFixedLengthString=function(){const y=(function(){const A=[];for(let R=0;R<this.parts.length;R++)A.push(B(this.parts[R].toString(16),4));return A}).call(this).join(":");let S="";return this.zoneId&&(S=`%${this.zoneId}`),y+S},p.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const y=this.parts.slice(-2),S=y[0],A=y[1];return new C.IPv4([S>>8,S&255,A>>8,A&255])},p.prototype.toNormalizedString=function(){const y=(function(){const A=[];for(let R=0;R<this.parts.length;R++)A.push(this.parts[R].toString(16));return A}).call(this).join(":");let S="";return this.zoneId&&(S=`%${this.zoneId}`),y+S},p.prototype.toRFC5952String=function(){const y=/((^|:)(0(:|$)){2,})/g,S=this.toNormalizedString();let A=0,R=-1,T;for(;T=y.exec(S);)T[0].length>R&&(A=T.index,R=T[0].length);return R<0?S:`${S.substring(0,A)}::${S.substring(A+R)}`},p.prototype.toString=function(){return this.toRFC5952String()},p}(),C.IPv6.broadcastAddressFromCIDR=function(p){try{const y=this.parseCIDR(p),S=y[0].toByteArray(),A=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),R=[];let T=0;for(;T<16;)R.push(parseInt(S[T],10)|parseInt(A[T],10)^255),T++;return new this(R)}catch(y){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${y})`)}},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 y=this.parser(p);return new this(y.parts,y.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 y,S,A,R,T;try{for(y=this.parseCIDR(p),A=y[0].toByteArray(),T=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),R=[],S=0;S<16;)R.push(parseInt(A[S],10)&parseInt(T[S],10)),S++;return new this(R)}catch(ve){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ve})`)}},C.IPv6.parse=function(p){const y=this.parser(p);if(y.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(y.parts,y.zoneId)},C.IPv6.parseCIDR=function(p){let y,S,A;if((S=p.match(/^(.+)\/(\d+)$/))&&(y=parseInt(S[2]),y>=0&&y<=128))return A=[this.parse(S[1]),y],Object.defineProperty(A,"toString",{value:function(){return this.join("/")}}),A;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},C.IPv6.parser=function(p){let y,S,A,R,T,ve;if(A=p.match(c.deprecatedTransitional))return this.parser(`::ffff:${A[1]}`);if(c.native.test(p))return u(p,8);if((A=p.match(c.transitional))&&(ve=A[6]||"",y=A[1],A[1].endsWith("::")||(y=y.slice(0,-1)),y=u(y+ve,6),y.parts)){for(T=[parseInt(A[2]),parseInt(A[3]),parseInt(A[4]),parseInt(A[5])],S=0;S<T.length;S++)if(R=T[S],!(0<=R&&R<=255))return null;return y.parts.push(T[0]<<8|T[1]),y.parts.push(T[2]<<8|T[3]),{parts:y.parts,zoneId:y.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 y=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let S=0;const A=Math.floor(p/8);for(;S<A;)y[S]=255,S++;return A<16&&(y[A]=Math.pow(2,p%8)-1<<8-p%8),new this(y)},C.fromByteArray=function(p){const y=p.length;if(y===4)return new C.IPv4(p);if(y===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 y=this.parse(p);return y.kind()==="ipv6"&&y.isIPv4MappedAddress()?y.toIPv4Address():y},C.subnetMatch=function(p,y,S){let A,R,T,ve;S==null&&(S="unicast");for(R in y)if(Object.prototype.hasOwnProperty.call(y,R)){for(T=y[R],T[0]&&!(T[0]instanceof Array)&&(T=[T]),A=0;A<T.length;A++)if(ve=T[A],p.kind()===ve[0].kind()&&p.match.apply(p,ve))return R}return S},r.exports?r.exports=C:e.ipaddr=C})(jo)})(Gp);var Jp=Gp.exports;class Yp{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((s,i)=>s+ +i,0);let n=e.slice(0,8).replace(/(.{2})/g,s=>`${parseInt(s,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 Jp.fromByteArray(Array.from(t)).toString()}return this.decodeIP(re.ToHex(e))}static fromString(e){const t=Jp.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var ml,yl,gl;let ft=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};l([h({type:g.TeletexString})],ft.prototype,"teletexString",void 0),l([h({type:g.PrintableString})],ft.prototype,"printableString",void 0),l([h({type:g.UniversalString})],ft.prototype,"universalString",void 0),l([h({type:g.Utf8String})],ft.prototype,"utf8String",void 0),l([h({type:g.BmpString})],ft.prototype,"bmpString",void 0),ft=l([$({type:N.Choice})],ft);let Cs=class extends ft{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?re.ToHex(this.anyValue):super.toString())}};l([h({type:g.IA5String})],Cs.prototype,"ia5String",void 0),l([h({type:g.Any})],Cs.prototype,"anyValue",void 0),Cs=l([$({type:N.Choice})],Cs);class Yo{constructor(e={}){this.type="",this.value=new Cs,Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Yo.prototype,"type",void 0),l([h({type:Cs})],Yo.prototype,"value",void 0);let Is=ml=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,ml.prototype)}};Is=ml=l([$({type:N.Set,itemType:Yo})],Is);let vl=yl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,yl.prototype)}};vl=yl=l([$({type:N.Sequence,itemType:Is})],vl);let et=gl=class extends vl{constructor(e){super(e),Object.setPrototypeOf(this,gl.prototype)}};et=gl=l([$({type:N.Sequence})],et);const __={fromASN:r=>Yp.toString(Jo.fromASN(r)),toASN:r=>Jo.toASN(Yp.fromString(r))};class ia{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],ia.prototype,"typeId",void 0),l([h({type:g.Any,context:0})],ia.prototype,"value",void 0);class bl{constructor(e={}){this.partyName=new ft,Object.assign(this,e)}}l([h({type:ft,optional:!0,context:0,implicit:!0})],bl.prototype,"nameAssigner",void 0),l([h({type:ft,context:1,implicit:!0})],bl.prototype,"partyName",void 0);let ge=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ia,context:0,implicit:!0})],ge.prototype,"otherName",void 0),l([h({type:g.IA5String,context:1,implicit:!0})],ge.prototype,"rfc822Name",void 0),l([h({type:g.IA5String,context:2,implicit:!0})],ge.prototype,"dNSName",void 0),l([h({type:g.Any,context:3,implicit:!0})],ge.prototype,"x400Address",void 0),l([h({type:et,context:4,implicit:!1})],ge.prototype,"directoryName",void 0),l([h({type:bl,context:5})],ge.prototype,"ediPartyName",void 0),l([h({type:g.IA5String,context:6,implicit:!0})],ge.prototype,"uniformResourceIdentifier",void 0),l([h({type:g.OctetString,context:7,implicit:!0,converter:__})],ge.prototype,"iPAddress",void 0),l([h({type:g.ObjectIdentifier,context:8,implicit:!0})],ge.prototype,"registeredID",void 0),ge=l([$({type:N.Choice})],ge);const xl="1.3.6.1.5.5.7",w_=`${xl}.1`,js=`${xl}.3`,Xo=`${xl}.48`,Xp=`${Xo}.1`,Qp=`${Xo}.2`,em=`${Xo}.3`,tm=`${Xo}.5`,fn="2.5.29";var _l;const wl=`${w_}.1`;class aa{constructor(e={}){this.accessMethod="",this.accessLocation=new ge,Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],aa.prototype,"accessMethod",void 0),l([h({type:ge})],aa.prototype,"accessLocation",void 0);let Ts=_l=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,_l.prototype)}};Ts=_l=l([$({type:N.Sequence,itemType:aa})],Ts);const kl=`${fn}.35`;class Sl extends Re{}class Un{constructor(e={}){e&&Object.assign(this,e)}}l([h({type:Sl,context:0,optional:!0,implicit:!0})],Un.prototype,"keyIdentifier",void 0),l([h({type:ge,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Un.prototype,"authorityCertIssuer",void 0),l([h({type:g.Integer,context:2,optional:!0,implicit:!0,converter:Ke})],Un.prototype,"authorityCertSerialNumber",void 0);const rm=`${fn}.19`;class Qo{constructor(e={}){this.cA=!1,Object.assign(this,e)}}l([h({type:g.Boolean,defaultValue:!1})],Qo.prototype,"cA",void 0),l([h({type:g.Integer,optional:!0})],Qo.prototype,"pathLenConstraint",void 0);var Al;let kt=Al=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Al.prototype)}};kt=Al=l([$({type:N.Sequence,itemType:ge})],kt);var Ol;let nm=Ol=class extends kt{constructor(e){super(e),Object.setPrototypeOf(this,Ol.prototype)}};nm=Ol=l([$({type:N.Sequence})],nm);var El;const sm=`${fn}.32`;let Vr=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};l([h({type:g.IA5String})],Vr.prototype,"ia5String",void 0),l([h({type:g.VisibleString})],Vr.prototype,"visibleString",void 0),l([h({type:g.BmpString})],Vr.prototype,"bmpString",void 0),l([h({type:g.Utf8String})],Vr.prototype,"utf8String",void 0),Vr=l([$({type:N.Choice})],Vr);class Cl{constructor(e={}){this.organization=new Vr,this.noticeNumbers=[],Object.assign(this,e)}}l([h({type:Vr})],Cl.prototype,"organization",void 0),l([h({type:g.Integer,repeated:"sequence"})],Cl.prototype,"noticeNumbers",void 0);class Il{constructor(e={}){Object.assign(this,e)}}l([h({type:Cl,optional:!0})],Il.prototype,"noticeRef",void 0),l([h({type:Vr,optional:!0})],Il.prototype,"explicitText",void 0);let ec=class{constructor(e={}){Object.assign(this,e)}};l([h({type:g.IA5String})],ec.prototype,"cPSuri",void 0),l([h({type:Il})],ec.prototype,"userNotice",void 0),ec=l([$({type:N.Choice})],ec);class jl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],jl.prototype,"policyQualifierId",void 0),l([h({type:g.Any})],jl.prototype,"qualifier",void 0);class tc{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],tc.prototype,"policyIdentifier",void 0),l([h({type:jl,repeated:"sequence",optional:!0})],tc.prototype,"policyQualifiers",void 0);let rc=El=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,El.prototype)}};rc=El=l([$({type:N.Sequence,itemType:tc})],rc);let nc=class{constructor(e=0){this.value=e}};l([h({type:g.Integer})],nc.prototype,"value",void 0),nc=l([$({type:N.Choice})],nc);let im=class extends nc{};im=l([$({type:N.Choice})],im);var Tl;const Nl=`${fn}.31`;var nr;(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"})(nr||(nr={}));class am extends Go{toJSON(){const e=[],t=this.toNumber();return t&nr.aACompromise&&e.push("aACompromise"),t&nr.affiliationChanged&&e.push("affiliationChanged"),t&nr.cACompromise&&e.push("cACompromise"),t&nr.certificateHold&&e.push("certificateHold"),t&nr.cessationOfOperation&&e.push("cessationOfOperation"),t&nr.keyCompromise&&e.push("keyCompromise"),t&nr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&nr.superseded&&e.push("superseded"),t&nr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let Ln=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,repeated:"sequence",implicit:!0})],Ln.prototype,"fullName",void 0),l([h({type:Is,context:1,implicit:!0})],Ln.prototype,"nameRelativeToCRLIssuer",void 0),Ln=l([$({type:N.Choice})],Ln);class Ns{constructor(e={}){Object.assign(this,e)}}l([h({type:Ln,context:0,optional:!0})],Ns.prototype,"distributionPoint",void 0),l([h({type:am,context:1,optional:!0,implicit:!0})],Ns.prototype,"reasons",void 0),l([h({type:ge,context:2,optional:!0,repeated:"sequence",implicit:!0})],Ns.prototype,"cRLIssuer",void 0);let Bs=Tl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Tl.prototype)}};Bs=Tl=l([$({type:N.Sequence,itemType:Ns})],Bs);var Bl;let om=Bl=class extends Bs{constructor(e){super(e),Object.setPrototypeOf(this,Bl.prototype)}};om=Bl=l([$({type:N.Sequence,itemType:Ns})],om);class gt{constructor(e={}){this.onlyContainsUserCerts=gt.ONLY,this.onlyContainsCACerts=gt.ONLY,this.indirectCRL=gt.ONLY,this.onlyContainsAttributeCerts=gt.ONLY,Object.assign(this,e)}}gt.ONLY=!1,l([h({type:Ln,context:0,optional:!0})],gt.prototype,"distributionPoint",void 0),l([h({type:g.Boolean,context:1,defaultValue:gt.ONLY,implicit:!0})],gt.prototype,"onlyContainsUserCerts",void 0),l([h({type:g.Boolean,context:2,defaultValue:gt.ONLY,implicit:!0})],gt.prototype,"onlyContainsCACerts",void 0),l([h({type:am,context:3,optional:!0,implicit:!0})],gt.prototype,"onlySomeReasons",void 0),l([h({type:g.Boolean,context:4,defaultValue:gt.ONLY,implicit:!0})],gt.prototype,"indirectCRL",void 0),l([h({type:g.Boolean,context:5,defaultValue:gt.ONLY,implicit:!0})],gt.prototype,"onlyContainsAttributeCerts",void 0);var oa;(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"})(oa||(oa={}));let Rl=class{constructor(e=oa.unspecified){this.reason=oa.unspecified,this.reason=e}toJSON(){return oa[this.reason]}toString(){return this.toJSON()}};l([h({type:g.Enumerated})],Rl.prototype,"reason",void 0),Rl=l([$({type:N.Choice})],Rl);var Pl;const cm=`${fn}.37`;let sc=Pl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};sc=Pl=l([$({type:N.Sequence,itemType:g.ObjectIdentifier})],sc);const k_=`${js}.1`,S_=`${js}.2`,A_=`${js}.3`,O_=`${js}.4`,E_=`${js}.8`,C_=`${js}.9`;let $l=class{constructor(e=new ArrayBuffer(0)){this.value=e}};l([h({type:g.Integer,converter:Ke})],$l.prototype,"value",void 0),$l=l([$({type:N.Choice})],$l);let Zl=class{constructor(e){this.value=new Date,e&&(this.value=e)}};l([h({type:g.GeneralizedTime})],Zl.prototype,"value",void 0),Zl=l([$({type:N.Choice})],Zl);var Dl;let um=Dl=class extends kt{constructor(e){super(e),Object.setPrototypeOf(this,Dl.prototype)}};um=Dl=l([$({type:N.Sequence})],um);const lm=`${fn}.15`;var sr;(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"})(sr||(sr={}));class Ml extends Go{toJSON(){const e=this.toNumber(),t=[];return e&sr.cRLSign&&t.push("crlSign"),e&sr.dataEncipherment&&t.push("dataEncipherment"),e&sr.decipherOnly&&t.push("decipherOnly"),e&sr.digitalSignature&&t.push("digitalSignature"),e&sr.encipherOnly&&t.push("encipherOnly"),e&sr.keyAgreement&&t.push("keyAgreement"),e&sr.keyCertSign&&t.push("keyCertSign"),e&sr.keyEncipherment&&t.push("keyEncipherment"),e&sr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Vl;class ic{constructor(e={}){this.base=new ge,this.minimum=0,Object.assign(this,e)}}l([h({type:ge})],ic.prototype,"base",void 0),l([h({type:g.Integer,context:0,defaultValue:0,implicit:!0})],ic.prototype,"minimum",void 0),l([h({type:g.Integer,context:1,optional:!0,implicit:!0})],ic.prototype,"maximum",void 0);let ac=Vl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};ac=Vl=l([$({type:N.Sequence,itemType:ic})],ac);class dm{constructor(e={}){Object.assign(this,e)}}l([h({type:ac,context:0,optional:!0,implicit:!0})],dm.prototype,"permittedSubtrees",void 0),l([h({type:ac,context:1,optional:!0,implicit:!0})],dm.prototype,"excludedSubtrees",void 0);class fm{constructor(e={}){Object.assign(this,e)}}l([h({type:g.Integer,context:0,implicit:!0,optional:!0,converter:Ke})],fm.prototype,"requireExplicitPolicy",void 0),l([h({type:g.Integer,context:1,implicit:!0,optional:!0,converter:Ke})],fm.prototype,"inhibitPolicyMapping",void 0);var Ul;class Ll{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Ll.prototype,"issuerDomainPolicy",void 0),l([h({type:g.ObjectIdentifier})],Ll.prototype,"subjectDomainPolicy",void 0);let hm=Ul=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Ul.prototype)}};hm=Ul=l([$({type:N.Sequence,itemType:Ll})],hm);var ql;const pm=`${fn}.17`;let Hl=ql=class extends kt{constructor(e){super(e),Object.setPrototypeOf(this,ql.prototype)}};Hl=ql=l([$({type:N.Sequence})],Hl);let Ur=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};l([h({type:g.ObjectIdentifier})],Ur.prototype,"type",void 0),l([h({type:g.Any,repeated:"set"})],Ur.prototype,"values",void 0);var Fl;let mm=Fl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Fl.prototype)}};mm=Fl=l([$({type:N.Sequence,itemType:Ur})],mm);const ym=`${fn}.14`;class hn extends Sl{}class gm{constructor(e={}){Object.assign(this,e)}}l([h({type:g.GeneralizedTime,context:0,implicit:!0,optional:!0})],gm.prototype,"notBefore",void 0),l([h({type:g.GeneralizedTime,context:1,implicit:!0,optional:!0})],gm.prototype,"notAfter",void 0);var ca;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(ca||(ca={}));class vm extends Go{toJSON(){const e=[],t=this.toNumber();return t&ca.pKIXCertificate&&e.push("pKIXCertificate"),t&ca.newExtensions&&e.push("newExtensions"),t&ca.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class bm{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new vm,Object.assign(this,e)}}l([h({type:g.GeneralString})],bm.prototype,"entrustVers",void 0),l([h({type:vm})],bm.prototype,"entrustInfoFlags",void 0);var Wl;let xm=Wl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Wl.prototype)}};xm=Wl=l([$({type:N.Sequence,itemType:aa})],xm);class Y{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof Y&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Hh(e.parameters,this.parameters)||e.parameters===this.parameters)}}l([h({type:g.ObjectIdentifier})],Y.prototype,"algorithm",void 0),l([h({type:g.Any,optional:!0})],Y.prototype,"parameters",void 0);class ir{constructor(e={}){this.algorithm=new Y,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],ir.prototype,"algorithm",void 0),l([h({type:g.BitString})],ir.prototype,"subjectPublicKey",void 0);let ht=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:g.UTCTime})],ht.prototype,"utcTime",void 0),l([h({type:g.GeneralizedTime})],ht.prototype,"generalTime",void 0),ht=l([$({type:N.Choice})],ht);class ua{constructor(e){this.notBefore=new ht(new Date),this.notAfter=new ht(new Date),e&&(this.notBefore=new ht(e.notBefore),this.notAfter=new ht(e.notAfter))}}l([h({type:ht})],ua.prototype,"notBefore",void 0),l([h({type:ht})],ua.prototype,"notAfter",void 0);var Kl;let Ht=class e0{constructor(e={}){this.extnID="",this.critical=e0.CRITICAL,this.extnValue=new Re,Object.assign(this,e)}};Ht.CRITICAL=!1,l([h({type:g.ObjectIdentifier})],Ht.prototype,"extnID",void 0),l([h({type:g.Boolean,defaultValue:Ht.CRITICAL})],Ht.prototype,"critical",void 0),l([h({type:Re})],Ht.prototype,"extnValue",void 0);let pn=Kl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};pn=Kl=l([$({type:N.Sequence,itemType:Ht})],pn);var qn;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(qn||(qn={}));class Zt{constructor(e={}){this.version=qn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new Y,this.issuer=new et,this.validity=new ua,this.subject=new et,this.subjectPublicKeyInfo=new ir,Object.assign(this,e)}}l([h({type:g.Integer,context:0,defaultValue:qn.v1})],Zt.prototype,"version",void 0),l([h({type:g.Integer,converter:Ke})],Zt.prototype,"serialNumber",void 0),l([h({type:Y})],Zt.prototype,"signature",void 0),l([h({type:et})],Zt.prototype,"issuer",void 0),l([h({type:ua})],Zt.prototype,"validity",void 0),l([h({type:et})],Zt.prototype,"subject",void 0),l([h({type:ir})],Zt.prototype,"subjectPublicKeyInfo",void 0),l([h({type:g.BitString,context:1,implicit:!0,optional:!0})],Zt.prototype,"issuerUniqueID",void 0),l([h({type:g.BitString,context:2,implicit:!0,optional:!0})],Zt.prototype,"subjectUniqueID",void 0),l([h({type:pn,context:3,optional:!0})],Zt.prototype,"extensions",void 0);class Hn{constructor(e={}){this.tbsCertificate=new Zt,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Zt})],Hn.prototype,"tbsCertificate",void 0),l([h({type:Y})],Hn.prototype,"signatureAlgorithm",void 0),l([h({type:g.BitString})],Hn.prototype,"signatureValue",void 0);class oc{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new ht,Object.assign(this,e)}}l([h({type:g.Integer,converter:Ke})],oc.prototype,"userCertificate",void 0),l([h({type:ht})],oc.prototype,"revocationDate",void 0),l([h({type:Ht,optional:!0,repeated:"sequence"})],oc.prototype,"crlEntryExtensions",void 0);class Lr{constructor(e={}){this.signature=new Y,this.issuer=new et,this.thisUpdate=new ht,Object.assign(this,e)}}l([h({type:g.Integer,optional:!0})],Lr.prototype,"version",void 0),l([h({type:Y})],Lr.prototype,"signature",void 0),l([h({type:et})],Lr.prototype,"issuer",void 0),l([h({type:ht})],Lr.prototype,"thisUpdate",void 0),l([h({type:ht,optional:!0})],Lr.prototype,"nextUpdate",void 0),l([h({type:oc,repeated:"sequence",optional:!0})],Lr.prototype,"revokedCertificates",void 0),l([h({type:Ht,optional:!0,context:0,repeated:"sequence"})],Lr.prototype,"crlExtensions",void 0);class zl{constructor(e={}){this.tbsCertList=new Lr,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Lr})],zl.prototype,"tbsCertList",void 0),l([h({type:Y})],zl.prototype,"signatureAlgorithm",void 0),l([h({type:g.BitString})],zl.prototype,"signature",void 0);class Rs{constructor(e={}){this.issuer=new et,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:et})],Rs.prototype,"issuer",void 0),l([h({type:g.Integer,converter:Ke})],Rs.prototype,"serialNumber",void 0);let Ps=class{constructor(e={}){Object.assign(this,e)}};l([h({type:hn,context:0,implicit:!0})],Ps.prototype,"subjectKeyIdentifier",void 0),l([h({type:Rs})],Ps.prototype,"issuerAndSerialNumber",void 0),Ps=l([$({type:N.Choice})],Ps);var qr;(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"})(qr||(qr={}));let la=class extends Y{};la=l([$({type:N.Sequence})],la);let cc=class extends Y{};cc=l([$({type:N.Sequence})],cc);let kr=class extends Y{};kr=l([$({type:N.Sequence})],kr);let uc=class extends Y{};uc=l([$({type:N.Sequence})],uc);let _m=class extends Y{};_m=l([$({type:N.Sequence})],_m);let Gl=class extends Y{};Gl=l([$({type:N.Sequence})],Gl);let $s=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};l([h({type:g.ObjectIdentifier})],$s.prototype,"attrType",void 0),l([h({type:g.Any,repeated:"set"})],$s.prototype,"attrValues",void 0);var Jl;class Sr{constructor(e={}){this.version=qr.v0,this.sid=new Ps,this.digestAlgorithm=new la,this.signatureAlgorithm=new cc,this.signature=new Re,Object.assign(this,e)}}l([h({type:g.Integer})],Sr.prototype,"version",void 0),l([h({type:Ps})],Sr.prototype,"sid",void 0),l([h({type:la})],Sr.prototype,"digestAlgorithm",void 0),l([h({type:$s,repeated:"set",context:0,implicit:!0,optional:!0})],Sr.prototype,"signedAttrs",void 0),l([h({type:cc})],Sr.prototype,"signatureAlgorithm",void 0),l([h({type:Re})],Sr.prototype,"signature",void 0),l([h({type:$s,repeated:"set",context:1,implicit:!0,optional:!0})],Sr.prototype,"unsignedAttrs",void 0);let lc=Jl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Jl.prototype)}};lc=Jl=l([$({type:N.Set,itemType:Sr})],lc);let wm=class extends ht{};wm=l([$({type:N.Choice})],wm);let km=class extends Sr{};km=l([$({type:N.Sequence})],km);class Yl{constructor(e={}){this.acIssuer=new ge,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}l([h({type:ge})],Yl.prototype,"acIssuer",void 0),l([h({type:g.Integer})],Yl.prototype,"acSerial",void 0),l([h({type:Ur,repeated:"sequence"})],Yl.prototype,"attrs",void 0);var Xl;let dc=Xl=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Xl.prototype)}};dc=Xl=l([$({type:N.Sequence,itemType:g.ObjectIdentifier})],dc);class fc{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}l([h({type:g.Integer,optional:!0})],fc.prototype,"pathLenConstraint",void 0),l([h({type:dc,implicit:!0,context:0,optional:!0})],fc.prototype,"permittedAttrs",void 0),l([h({type:dc,implicit:!0,context:1,optional:!0})],fc.prototype,"excludedAttrs",void 0),l([h({type:g.Boolean,defaultValue:!0})],fc.prototype,"permitUnSpecified",void 0);class Fn{constructor(e={}){this.issuer=new kt,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:kt})],Fn.prototype,"issuer",void 0),l([h({type:g.Integer,converter:Ke})],Fn.prototype,"serial",void 0),l([h({type:g.BitString,optional:!0})],Fn.prototype,"issuerUID",void 0);var Ql;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(Ql||(Ql={}));class Wn{constructor(e={}){this.digestedObjectType=Ql.publicKey,this.digestAlgorithm=new Y,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.Enumerated})],Wn.prototype,"digestedObjectType",void 0),l([h({type:g.ObjectIdentifier,optional:!0})],Wn.prototype,"otherObjectTypeID",void 0),l([h({type:Y})],Wn.prototype,"digestAlgorithm",void 0),l([h({type:g.BitString})],Wn.prototype,"objectDigest",void 0);class hc{constructor(e={}){Object.assign(this,e)}}l([h({type:kt,optional:!0})],hc.prototype,"issuerName",void 0),l([h({type:Fn,context:0,implicit:!0,optional:!0})],hc.prototype,"baseCertificateID",void 0),l([h({type:Wn,context:1,implicit:!0,optional:!0})],hc.prototype,"objectDigestInfo",void 0);let Zs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,repeated:"sequence"})],Zs.prototype,"v1Form",void 0),l([h({type:hc,context:0,implicit:!0})],Zs.prototype,"v2Form",void 0),Zs=l([$({type:N.Choice})],Zs);class pc{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}l([h({type:g.GeneralizedTime})],pc.prototype,"notBeforeTime",void 0),l([h({type:g.GeneralizedTime})],pc.prototype,"notAfterTime",void 0);class da{constructor(e={}){Object.assign(this,e)}}l([h({type:Fn,implicit:!0,context:0,optional:!0})],da.prototype,"baseCertificateID",void 0),l([h({type:kt,implicit:!0,context:1,optional:!0})],da.prototype,"entityName",void 0),l([h({type:Wn,implicit:!0,context:2,optional:!0})],da.prototype,"objectDigestInfo",void 0);var ed;(function(r){r[r.v2=1]="v2"})(ed||(ed={}));class ar{constructor(e={}){this.version=ed.v2,this.holder=new da,this.issuer=new Zs,this.signature=new Y,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new pc,this.attributes=[],Object.assign(this,e)}}l([h({type:g.Integer})],ar.prototype,"version",void 0),l([h({type:da})],ar.prototype,"holder",void 0),l([h({type:Zs})],ar.prototype,"issuer",void 0),l([h({type:Y})],ar.prototype,"signature",void 0),l([h({type:g.Integer,converter:Ke})],ar.prototype,"serialNumber",void 0),l([h({type:pc})],ar.prototype,"attrCertValidityPeriod",void 0),l([h({type:Ur,repeated:"sequence"})],ar.prototype,"attributes",void 0),l([h({type:g.BitString,optional:!0})],ar.prototype,"issuerUniqueID",void 0),l([h({type:pn,optional:!0})],ar.prototype,"extensions",void 0);class mc{constructor(e={}){this.acinfo=new ar,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:ar})],mc.prototype,"acinfo",void 0),l([h({type:Y})],mc.prototype,"signatureAlgorithm",void 0),l([h({type:g.BitString})],mc.prototype,"signatureValue",void 0);var yc;(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"})(yc||(yc={}));class td extends Go{}class rd{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier,implicit:!0,context:0})],rd.prototype,"type",void 0),l([h({type:g.Any,implicit:!0,context:1})],rd.prototype,"value",void 0);class nd{constructor(e={}){this.policyId="",this.classList=new td(yc.unclassified),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],nd.prototype,"policyId",void 0),l([h({type:td,defaultValue:new td(yc.unclassified)})],nd.prototype,"classList",void 0),l([h({type:rd,repeated:"set"})],nd.prototype,"securityCategories",void 0);class gc{constructor(e={}){Object.assign(this,e)}}l([h({type:Re})],gc.prototype,"cotets",void 0),l([h({type:g.ObjectIdentifier})],gc.prototype,"oid",void 0),l([h({type:g.Utf8String})],gc.prototype,"string",void 0);class Sm{constructor(e={}){this.values=[],Object.assign(this,e)}}l([h({type:kt,implicit:!0,context:0,optional:!0})],Sm.prototype,"policyAuthority",void 0),l([h({type:gc,repeated:"sequence"})],Sm.prototype,"values",void 0);var sd;class vc{constructor(e={}){this.targetCertificate=new Fn,Object.assign(this,e)}}l([h({type:Fn})],vc.prototype,"targetCertificate",void 0),l([h({type:ge,optional:!0})],vc.prototype,"targetName",void 0),l([h({type:Wn,optional:!0})],vc.prototype,"certDigestInfo",void 0);let Ds=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,implicit:!0})],Ds.prototype,"targetName",void 0),l([h({type:ge,context:1,implicit:!0})],Ds.prototype,"targetGroup",void 0),l([h({type:vc,context:2,implicit:!0})],Ds.prototype,"targetCert",void 0),Ds=l([$({type:N.Choice})],Ds);let id=sd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,sd.prototype)}};id=sd=l([$({type:N.Sequence,itemType:Ds})],id);var ad;let Am=ad=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,ad.prototype)}};Am=ad=l([$({type:N.Sequence,itemType:id})],Am);class Om{constructor(e={}){Object.assign(this,e)}}l([h({type:kt,implicit:!0,context:0,optional:!0})],Om.prototype,"roleAuthority",void 0),l([h({type:ge,implicit:!0,context:1})],Om.prototype,"roleName",void 0);class od{constructor(e={}){this.service=new ge,this.ident=new ge,Object.assign(this,e)}}l([h({type:ge})],od.prototype,"service",void 0),l([h({type:ge})],od.prototype,"ident",void 0),l([h({type:Re,optional:!0})],od.prototype,"authInfo",void 0);var cd;class ud{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],ud.prototype,"otherCertFormat",void 0),l([h({type:g.Any})],ud.prototype,"otherCert",void 0);let Ms=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Hn})],Ms.prototype,"certificate",void 0),l([h({type:mc,context:2,implicit:!0})],Ms.prototype,"v2AttrCert",void 0),l([h({type:ud,context:3,implicit:!0})],Ms.prototype,"other",void 0),Ms=l([$({type:N.Choice})],Ms);let bc=cd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,cd.prototype)}};bc=cd=l([$({type:N.Set,itemType:Ms})],bc);class Vs{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Vs.prototype,"contentType",void 0),l([h({type:g.Any,context:0})],Vs.prototype,"content",void 0);let fa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Re})],fa.prototype,"single",void 0),l([h({type:g.Any})],fa.prototype,"any",void 0),fa=l([$({type:N.Choice})],fa);class xc{constructor(e={}){this.eContentType="",Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],xc.prototype,"eContentType",void 0),l([h({type:fa,context:0,optional:!0})],xc.prototype,"eContent",void 0);let ha=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Re,context:0,implicit:!0,optional:!0})],ha.prototype,"value",void 0),l([h({type:Re,converter:n_,context:0,implicit:!0,optional:!0,repeated:"sequence"})],ha.prototype,"constructedValue",void 0),ha=l([$({type:N.Choice})],ha);class pa{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new uc,Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],pa.prototype,"contentType",void 0),l([h({type:uc})],pa.prototype,"contentEncryptionAlgorithm",void 0),l([h({type:ha,optional:!0})],pa.prototype,"encryptedContent",void 0);class _c{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],_c.prototype,"keyAttrId",void 0),l([h({type:g.Any,optional:!0})],_c.prototype,"keyAttr",void 0);var ld;class wc{constructor(e={}){this.subjectKeyIdentifier=new hn,Object.assign(this,e)}}l([h({type:hn})],wc.prototype,"subjectKeyIdentifier",void 0),l([h({type:g.GeneralizedTime,optional:!0})],wc.prototype,"date",void 0),l([h({type:_c,optional:!0})],wc.prototype,"other",void 0);let Us=class{constructor(e={}){Object.assign(this,e)}};l([h({type:wc,context:0,implicit:!0,optional:!0})],Us.prototype,"rKeyId",void 0),l([h({type:Rs,optional:!0})],Us.prototype,"issuerAndSerialNumber",void 0),Us=l([$({type:N.Choice})],Us);class dd{constructor(e={}){this.rid=new Us,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:Us})],dd.prototype,"rid",void 0),l([h({type:Re})],dd.prototype,"encryptedKey",void 0);let kc=ld=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,ld.prototype)}};kc=ld=l([$({type:N.Sequence,itemType:dd})],kc);class fd{constructor(e={}){this.algorithm=new Y,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],fd.prototype,"algorithm",void 0),l([h({type:g.BitString})],fd.prototype,"publicKey",void 0);let Kn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:hn,context:0,implicit:!0,optional:!0})],Kn.prototype,"subjectKeyIdentifier",void 0),l([h({type:fd,context:1,implicit:!0,optional:!0})],Kn.prototype,"originatorKey",void 0),l([h({type:Rs,optional:!0})],Kn.prototype,"issuerAndSerialNumber",void 0),Kn=l([$({type:N.Choice})],Kn);class Ls{constructor(e={}){this.version=qr.v3,this.originator=new Kn,this.keyEncryptionAlgorithm=new kr,this.recipientEncryptedKeys=new kc,Object.assign(this,e)}}l([h({type:g.Integer})],Ls.prototype,"version",void 0),l([h({type:Kn,context:0})],Ls.prototype,"originator",void 0),l([h({type:Re,context:1,optional:!0})],Ls.prototype,"ukm",void 0),l([h({type:kr})],Ls.prototype,"keyEncryptionAlgorithm",void 0),l([h({type:kc})],Ls.prototype,"recipientEncryptedKeys",void 0);let qs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:hn,context:0,implicit:!0})],qs.prototype,"subjectKeyIdentifier",void 0),l([h({type:Rs})],qs.prototype,"issuerAndSerialNumber",void 0),qs=l([$({type:N.Choice})],qs);class ma{constructor(e={}){this.version=qr.v0,this.rid=new qs,this.keyEncryptionAlgorithm=new kr,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:g.Integer})],ma.prototype,"version",void 0),l([h({type:qs})],ma.prototype,"rid",void 0),l([h({type:kr})],ma.prototype,"keyEncryptionAlgorithm",void 0),l([h({type:Re})],ma.prototype,"encryptedKey",void 0);class ya{constructor(e={}){this.keyIdentifier=new Re,Object.assign(this,e)}}l([h({type:Re})],ya.prototype,"keyIdentifier",void 0),l([h({type:g.GeneralizedTime,optional:!0})],ya.prototype,"date",void 0),l([h({type:_c,optional:!0})],ya.prototype,"other",void 0);class ga{constructor(e={}){this.version=qr.v4,this.kekid=new ya,this.keyEncryptionAlgorithm=new kr,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:g.Integer})],ga.prototype,"version",void 0),l([h({type:ya})],ga.prototype,"kekid",void 0),l([h({type:kr})],ga.prototype,"keyEncryptionAlgorithm",void 0),l([h({type:Re})],ga.prototype,"encryptedKey",void 0);class va{constructor(e={}){this.version=qr.v0,this.keyEncryptionAlgorithm=new kr,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:g.Integer})],va.prototype,"version",void 0),l([h({type:Gl,context:0,optional:!0})],va.prototype,"keyDerivationAlgorithm",void 0),l([h({type:kr})],va.prototype,"keyEncryptionAlgorithm",void 0),l([h({type:Re})],va.prototype,"encryptedKey",void 0);class hd{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],hd.prototype,"oriType",void 0),l([h({type:g.Any})],hd.prototype,"oriValue",void 0);let mn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ma,optional:!0})],mn.prototype,"ktri",void 0),l([h({type:Ls,context:1,implicit:!0,optional:!0})],mn.prototype,"kari",void 0),l([h({type:ga,context:2,implicit:!0,optional:!0})],mn.prototype,"kekri",void 0),l([h({type:va,context:3,implicit:!0,optional:!0})],mn.prototype,"pwri",void 0),l([h({type:hd,context:4,implicit:!0,optional:!0})],mn.prototype,"ori",void 0),mn=l([$({type:N.Choice})],mn);var pd;let Sc=pd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,pd.prototype)}};Sc=pd=l([$({type:N.Set,itemType:mn})],Sc);var md;class Ac{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Ac.prototype,"otherRevInfoFormat",void 0),l([h({type:g.Any})],Ac.prototype,"otherRevInfo",void 0);let Oc=class{constructor(e={}){this.other=new Ac,Object.assign(this,e)}};l([h({type:Ac,context:1,implicit:!0})],Oc.prototype,"other",void 0),Oc=l([$({type:N.Choice})],Oc);let Ec=md=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,md.prototype)}};Ec=md=l([$({type:N.Set,itemType:Oc})],Ec);class yd{constructor(e={}){Object.assign(this,e)}}l([h({type:bc,context:0,implicit:!0,optional:!0})],yd.prototype,"certs",void 0),l([h({type:Ec,context:1,implicit:!0,optional:!0})],yd.prototype,"crls",void 0);var gd;let vd=gd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,gd.prototype)}};vd=gd=l([$({type:N.Set,itemType:$s})],vd);class ba{constructor(e={}){this.version=qr.v0,this.recipientInfos=new Sc,this.encryptedContentInfo=new pa,Object.assign(this,e)}}l([h({type:g.Integer})],ba.prototype,"version",void 0),l([h({type:yd,context:0,implicit:!0,optional:!0})],ba.prototype,"originatorInfo",void 0),l([h({type:Sc})],ba.prototype,"recipientInfos",void 0),l([h({type:pa})],ba.prototype,"encryptedContentInfo",void 0),l([h({type:vd,context:1,implicit:!0,optional:!0})],ba.prototype,"unprotectedAttrs",void 0);const I_="1.2.840.113549.1.7.2";var bd;let Cc=bd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,bd.prototype)}};Cc=bd=l([$({type:N.Set,itemType:la})],Cc);class Hs{constructor(e={}){this.version=qr.v0,this.digestAlgorithms=new Cc,this.encapContentInfo=new xc,this.signerInfos=new lc,Object.assign(this,e)}}l([h({type:g.Integer})],Hs.prototype,"version",void 0),l([h({type:Cc})],Hs.prototype,"digestAlgorithms",void 0),l([h({type:xc})],Hs.prototype,"encapContentInfo",void 0),l([h({type:bc,context:0,implicit:!0,optional:!0})],Hs.prototype,"certificates",void 0),l([h({type:Ec,context:1,implicit:!0,optional:!0})],Hs.prototype,"crls",void 0),l([h({type:lc})],Hs.prototype,"signerInfos",void 0);const xa="1.2.840.10045.2.1",xd="1.2.840.10045.4.1",Em="1.2.840.10045.4.3.1",_d="1.2.840.10045.4.3.2",wd="1.2.840.10045.4.3.3",kd="1.2.840.10045.4.3.4",Cm="1.2.840.10045.3.1.7",Im="1.3.132.0.34",jm="1.3.132.0.35";function _a(r){return new Y({algorithm:r})}const j_=_a(xd);_a(Em);const T_=_a(_d),N_=_a(wd),B_=_a(kd);let wa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:g.ObjectIdentifier})],wa.prototype,"fieldType",void 0),l([h({type:g.Any})],wa.prototype,"parameters",void 0),wa=l([$({type:N.Sequence})],wa);class R_ extends Re{}let Fs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:g.OctetString})],Fs.prototype,"a",void 0),l([h({type:g.OctetString})],Fs.prototype,"b",void 0),l([h({type:g.BitString,optional:!0})],Fs.prototype,"seed",void 0),Fs=l([$({type:N.Sequence})],Fs);var Sd;(function(r){r[r.ecpVer1=1]="ecpVer1"})(Sd||(Sd={}));let Hr=class{constructor(e={}){this.version=Sd.ecpVer1,Object.assign(this,e)}};l([h({type:g.Integer})],Hr.prototype,"version",void 0),l([h({type:wa})],Hr.prototype,"fieldID",void 0),l([h({type:Fs})],Hr.prototype,"curve",void 0),l([h({type:R_})],Hr.prototype,"base",void 0),l([h({type:g.Integer,converter:Ke})],Hr.prototype,"order",void 0),l([h({type:g.Integer,optional:!0})],Hr.prototype,"cofactor",void 0),Hr=l([$({type:N.Sequence})],Hr);let yn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:g.ObjectIdentifier})],yn.prototype,"namedCurve",void 0),l([h({type:g.Null})],yn.prototype,"implicitCurve",void 0),l([h({type:Hr})],yn.prototype,"specifiedCurve",void 0),yn=l([$({type:N.Choice})],yn);class Ic{constructor(e={}){this.version=1,this.privateKey=new Re,Object.assign(this,e)}}l([h({type:g.Integer})],Ic.prototype,"version",void 0),l([h({type:Re})],Ic.prototype,"privateKey",void 0),l([h({type:yn,context:0,optional:!0})],Ic.prototype,"parameters",void 0),l([h({type:g.BitString,context:1,optional:!0})],Ic.prototype,"publicKey",void 0);class jc{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.Integer,converter:Ke})],jc.prototype,"r",void 0),l([h({type:g.Integer,converter:Ke})],jc.prototype,"s",void 0);const It="1.2.840.113549.1.1",zn=`${It}.1`,P_=`${It}.7`,$_=`${It}.9`,ka=`${It}.10`,Z_=`${It}.2`,D_=`${It}.4`,Tc=`${It}.5`,M_=`${It}.14`,Ad=`${It}.11`,Nc=`${It}.12`,Bc=`${It}.13`,Tm=`${It}.15`,Nm=`${It}.16`,Rc="1.3.14.3.2.26",Bm="2.16.840.1.101.3.4.2.4",Pc="2.16.840.1.101.3.4.2.1",$c="2.16.840.1.101.3.4.2.2",Zc="2.16.840.1.101.3.4.2.3",V_="2.16.840.1.101.3.4.2.5",U_="2.16.840.1.101.3.4.2.6",L_="1.2.840.113549.2.2",q_="1.2.840.113549.2.5",Dc=`${It}.8`;function at(r){return new Y({algorithm:r,parameters:null})}at(L_),at(q_);const Gn=at(Rc);at(Bm),at(Pc),at($c),at(Zc),at(V_),at(U_);const Rm=new Y({algorithm:Dc,parameters:U.serialize(Gn)}),Pm=new Y({algorithm:$_,parameters:U.serialize(Jo.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(zn),at(Z_),at(D_),at(Tc),at(Tm),at(Nm),at(Nc),at(Bc),at(Tm),at(Nm);class Mc{constructor(e={}){this.hashAlgorithm=new Y(Gn),this.maskGenAlgorithm=new Y({algorithm:Dc,parameters:U.serialize(Gn)}),this.pSourceAlgorithm=new Y(Pm),Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:Gn})],Mc.prototype,"hashAlgorithm",void 0),l([h({type:Y,context:1,defaultValue:Rm})],Mc.prototype,"maskGenAlgorithm",void 0),l([h({type:Y,context:2,defaultValue:Pm})],Mc.prototype,"pSourceAlgorithm",void 0),new Y({algorithm:P_,parameters:U.serialize(new Mc)});class Jn{constructor(e={}){this.hashAlgorithm=new Y(Gn),this.maskGenAlgorithm=new Y({algorithm:Dc,parameters:U.serialize(Gn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:Gn})],Jn.prototype,"hashAlgorithm",void 0),l([h({type:Y,context:1,defaultValue:Rm})],Jn.prototype,"maskGenAlgorithm",void 0),l([h({type:g.Integer,context:2,defaultValue:20})],Jn.prototype,"saltLength",void 0),l([h({type:g.Integer,context:3,defaultValue:1})],Jn.prototype,"trailerField",void 0),new Y({algorithm:ka,parameters:U.serialize(new Jn)});class Vc{constructor(e={}){this.digestAlgorithm=new Y,this.digest=new Re,Object.assign(this,e)}}l([h({type:Y})],Vc.prototype,"digestAlgorithm",void 0),l([h({type:Re})],Vc.prototype,"digest",void 0);var Od;class Uc{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.Integer,converter:Ke})],Uc.prototype,"prime",void 0),l([h({type:g.Integer,converter:Ke})],Uc.prototype,"exponent",void 0),l([h({type:g.Integer,converter:Ke})],Uc.prototype,"coefficient",void 0);let Ed=Od=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Od.prototype)}};Ed=Od=l([$({type:N.Sequence,itemType:Uc})],Ed);class Ar{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:g.Integer})],Ar.prototype,"version",void 0),l([h({type:g.Integer,converter:Ke})],Ar.prototype,"modulus",void 0),l([h({type:g.Integer,converter:Ke})],Ar.prototype,"publicExponent",void 0),l([h({type:g.Integer,converter:Ke})],Ar.prototype,"privateExponent",void 0),l([h({type:g.Integer,converter:Ke})],Ar.prototype,"prime1",void 0),l([h({type:g.Integer,converter:Ke})],Ar.prototype,"prime2",void 0),l([h({type:g.Integer,converter:Ke})],Ar.prototype,"exponent1",void 0),l([h({type:g.Integer,converter:Ke})],Ar.prototype,"exponent2",void 0),l([h({type:g.Integer,converter:Ke})],Ar.prototype,"coefficient",void 0),l([h({type:Ed,optional:!0})],Ar.prototype,"otherPrimeInfos",void 0);class Cd{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.Integer,converter:Ke})],Cd.prototype,"modulus",void 0),l([h({type:g.Integer,converter:Ke})],Cd.prototype,"publicExponent",void 0);var Id;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Id||(Id={}));const jt=Id;/*! *****************************************************************************
76
76
  Copyright (c) Microsoft Corporation.
77
77
 
78
78
  Permission to use, copy, modify, and/or distribute this software for any
@@ -85,9 +85,9 @@ ${e.join(`
85
85
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
86
86
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
87
87
  PERFORMANCE OF THIS SOFTWARE.
88
- ***************************************************************************** */var Id=function(r,e){return Id=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)n.hasOwnProperty(s)&&(t[s]=n[s])},Id(r,e)};function jd(r,e){Id(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function D_(r,e,t,n){function s(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,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?i(f.value):s(f.value).then(o,c)}u((n=n.apply(r,[])).next())})}function M_(r,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,s,i,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,s&&(i=u[0]&2?s.return:u[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,u[1])).done)return i;switch(s=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,s=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1],i=u;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(u);break}i[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(f){u=[6,f],s=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Vc(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),s,i=[],a;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return i}function Gn(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Uc(arguments[e]));return r}var V_="injectionTokens";function U_(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(V_,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function Cm(r){return!!r.useClass}function Td(r){return!!r.useFactory}var Im=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={},s=!1,i,a=function(){return s||(i=e(t.wrap()),s=!0),i};return new Proxy(n,this.createHandler(a))},r.prototype.createHandler=function(e){var t={},n=function(s){t[s]=function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];i[0]=e();var o=Reflect[s];return o.apply(void 0,Gn(i))}};return this.reflectMethods.forEach(n),t},r}();function Fs(r){return typeof r=="string"||typeof r=="symbol"}function L_(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function jm(r){return typeof r=="object"&&"token"in r&&"transform"in r}function q_(r){return typeof r=="function"||r instanceof Im}function Lc(r){return!!r.useToken}function qc(r){return r.useValue!=null}function H_(r){return Cm(r)||qc(r)||Lc(r)||Td(r)}var Nd=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}(),F_=function(r){jd(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Nd),Tm=function(){function r(){this.scopedResolutions=new Map}return r}();function W_(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function z_(r,e,t){return t===void 0&&(t=" "),Gn([r],e.message.split(`
88
+ ***************************************************************************** */var jd=function(r,e){return jd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)n.hasOwnProperty(s)&&(t[s]=n[s])},jd(r,e)};function Td(r,e){jd(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function H_(r,e,t,n){function s(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,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?i(f.value):s(f.value).then(o,c)}u((n=n.apply(r,[])).next())})}function F_(r,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,s,i,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,s&&(i=u[0]&2?s.return:u[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,u[1])).done)return i;switch(s=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,s=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1],i=u;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(u);break}i[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(f){u=[6,f],s=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Lc(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 qc(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,i=[],a;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return i}function Yn(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(qc(arguments[e]));return r}var W_="injectionTokens";function K_(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(W_,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function $m(r){return!!r.useClass}function Nd(r){return!!r.useFactory}var Zm=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={},s=!1,i,a=function(){return s||(i=e(t.wrap()),s=!0),i};return new Proxy(n,this.createHandler(a))},r.prototype.createHandler=function(e){var t={},n=function(s){t[s]=function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];i[0]=e();var o=Reflect[s];return o.apply(void 0,Yn(i))}};return this.reflectMethods.forEach(n),t},r}();function Ws(r){return typeof r=="string"||typeof r=="symbol"}function z_(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function Dm(r){return typeof r=="object"&&"token"in r&&"transform"in r}function G_(r){return typeof r=="function"||r instanceof Zm}function Hc(r){return!!r.useToken}function Fc(r){return r.useValue!=null}function J_(r){return $m(r)||Fc(r)||Hc(r)||Nd(r)}var Bd=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}(),Y_=function(r){Td(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bd),Mm=function(){function r(){this.scopedResolutions=new Map}return r}();function X_(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function Q_(r,e,t){return t===void 0&&(t=" "),Yn([r],e.message.split(`
89
89
  `).map(function(n){return t+n})).join(`
90
- `)}function K_(r,e,t){var n=Uc(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],i=s===void 0?null:s,a=W_(i,e);return z_("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function G_(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var J_=function(r){jd(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Nd),Y_=function(r){jd(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Nd),X_=function(){function r(){this.preResolution=new J_,this.postResolution=new Y_}return r}(),Nm=new Map,Q_=function(){function r(e){this.parent=e,this._registry=new F_,this.interceptors=new X_,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:It.Transient}),this.ensureNotDisposed();var s;if(H_(t)?s=t:s={useClass:t},Lc(s))for(var i=[e],a=s;a!=null;){var o=a.useToken;if(i.includes(o))throw new Error("Token registration cycle detected! "+Gn(i,[o]).join(" -> "));i.push(o);var c=this._registry.get(o);c&&Lc(c.provider)?a=c.provider:a=null}if((n.lifecycle===It.Singleton||n.lifecycle==It.ContainerScoped||n.lifecycle==It.ResolutionScoped)&&(qc(s)||Td(s)))throw new Error('Cannot use lifecycle "'+It[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:s,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Fs(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(),Fs(e)){if(Fs(t))return this.register(e,{useToken:t},{lifecycle:It.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:It.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Fs(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:It.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new Tm),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&Fs(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var s=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(q_(e)){var s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}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,s;if(this.interceptors.preResolution.has(e)){var i=[];try{for(var a=Vc(this.interceptors.preResolution.getAll(e)),o=a.next();!o.done;o=a.next()){var c=o.value;c.options.frequency!="Once"&&i.push(c),c.callback(e,t)}}catch(u){n={error:u}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,i)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var s,i;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var o=Vc(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){s={error:f}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}this.interceptors.postResolution.setAll(e,a)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===It.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===It.Singleton,s=e.options.lifecycle===It.ContainerScoped,i=n||s,a;return qc(e.provider)?a=e.provider.useValue:Lc(e.provider)?a=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Cm(e.provider)?a=i?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===It.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new Tm),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&Fs(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),s){var i=s.map(function(o){return n.resolveRegistration(o,t)});return this.executePostResolutionInterceptor(e,i,"All"),i}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=Vc(this._registry.entries()),s=n.next();!s.done;s=n.next()){var i=Uc(s.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(c){return!qc(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{s&&!s.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 s=Vc(this._registry.entries()),i=s.next();!i.done;i=s.next()){var a=Uc(i.value,2),o=a[0],c=a[1];c.some(function(u){var f=u.options;return f.lifecycle===It.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===It.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(t=s.return)&&t.call(s)}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 D_(this,void 0,void 0,function(){var e;return M_(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var s=n.dispose();s&&e.push(s)}),[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 Im)return e.createProxy(function(i){return n.resolve(i,t)});var s=function(){var i=Nm.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=i.map(n.resolveParams(t,e));return new(e.bind.apply(e,Gn([void 0],a)))}();return G_(s)&&this.disposables.add(s),s},r.prototype.resolveParams=function(e,t){var n=this;return function(s,i){var a,o,c;try{return L_(s)?jm(s)?s.multiple?(a=n.resolve(s.transform)).transform.apply(a,Gn([n.resolveAll(s.token)],s.transformArgs)):(o=n.resolve(s.transform)).transform.apply(o,Gn([n.resolve(s.token,e)],s.transformArgs)):s.multiple?n.resolveAll(s.token):n.resolve(s.token,e):jm(s)?(c=n.resolve(s.transform,e)).transform.apply(c,Gn([n.resolve(s.token,e)],s.transformArgs)):n.resolve(s,e)}catch(u){throw new Error(K_(t,i,u))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),wt=new Q_;function Hc(){return function(r){Nm.set(r,U_(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 Fc{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}l([h({type:y.ObjectIdentifier})],Fc.prototype,"attrId",void 0),l([h({type:y.Any,repeated:"set"})],Fc.prototype,"attrValues",void 0);let Bm=Bd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Bd.prototype)}};Bm=Bd=l([$({type:N.Sequence,itemType:Fc})],Bm);var Rd;let Rm=Rd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Rd.prototype)}};Rm=Rd=l([$({type:N.Sequence,itemType:Ms})],Rm);class Pm{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Pm.prototype,"certId",void 0),l([h({type:y.Any,context:0})],Pm.prototype,"certValue",void 0);class $m{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],$m.prototype,"crlId",void 0),l([h({type:y.Any,context:0})],$m.prototype,"crltValue",void 0);class Zm extends Re{}let Wc=class{constructor(e={}){this.encryptionAlgorithm=new J,this.encryptedData=new Zm,Object.assign(this,e)}};l([h({type:J})],Wc.prototype,"encryptionAlgorithm",void 0),l([h({type:Zm})],Wc.prototype,"encryptedData",void 0);var Pd,$d;(function(r){r[r.v1=0]="v1"})($d||($d={}));class Dm extends Re{}let Zd=Pd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Pd.prototype)}};Zd=Pd=l([$({type:N.Sequence,itemType:Vr})],Zd);class ka{constructor(e={}){this.version=$d.v1,this.privateKeyAlgorithm=new J,this.privateKey=new Dm,Object.assign(this,e)}}l([h({type:y.Integer})],ka.prototype,"version",void 0),l([h({type:J})],ka.prototype,"privateKeyAlgorithm",void 0),l([h({type:Dm})],ka.prototype,"privateKey",void 0),l([h({type:Zd,implicit:!0,context:0,optional:!0})],ka.prototype,"attributes",void 0);let Mm=class extends ka{};Mm=l([$({type:N.Sequence})],Mm);let Vm=class extends Wc{};Vm=l([$({type:N.Sequence})],Vm);class Um{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Um.prototype,"secretTypeId",void 0),l([h({type:y.Any,context:0})],Um.prototype,"secretValue",void 0);class Sa{constructor(e={}){this.mac=new Dc,this.macSalt=new Re,this.iterations=1,Object.assign(this,e)}}l([h({type:Dc})],Sa.prototype,"mac",void 0),l([h({type:Re})],Sa.prototype,"macSalt",void 0),l([h({type:y.Integer,defaultValue:1})],Sa.prototype,"iterations",void 0);class zc{constructor(e={}){this.version=3,this.authSafe=new Ms,this.macData=new Sa,Object.assign(this,e)}}l([h({type:y.Integer})],zc.prototype,"version",void 0),l([h({type:Ms})],zc.prototype,"authSafe",void 0),l([h({type:Sa,optional:!0})],zc.prototype,"macData",void 0);var Dd;class Kc{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Kc.prototype,"bagId",void 0),l([h({type:y.Any,context:0})],Kc.prototype,"bagValue",void 0),l([h({type:Fc,repeated:"set",optional:!0})],Kc.prototype,"bagAttributes",void 0);let Lm=Dd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Dd.prototype)}};Lm=Dd=l([$({type:N.Sequence,itemType:Kc})],Lm);var Md,Vd,Ud;const qm="1.2.840.113549.1.9",Hm=`${qm}.7`,Ld=`${qm}.14`;let Gc=class extends ft{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};l([h({type:y.IA5String})],Gc.prototype,"ia5String",void 0),Gc=l([$({type:N.Choice})],Gc);let Fm=class extends Ms{};Fm=l([$({type:N.Sequence})],Fm);let Wm=class extends zc{};Wm=l([$({type:N.Sequence})],Wm);let zm=class extends Wc{};zm=l([$({type:N.Sequence})],zm);let qd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.IA5String})],qd.prototype,"value",void 0),qd=l([$({type:N.Choice})],qd);let Km=class extends Gc{};Km=l([$({type:N.Choice})],Km);let Gm=class extends ft{};Gm=l([$({type:N.Choice})],Gm);let Hd=class{constructor(e=new Date){this.value=e}};l([h({type:y.GeneralizedTime})],Hd.prototype,"value",void 0),Hd=l([$({type:N.Choice})],Hd);let Jm=class extends ft{};Jm=l([$({type:N.Choice})],Jm);let Fd=class{constructor(e="M"){this.value=e}toString(){return this.value}};l([h({type:y.PrintableString})],Fd.prototype,"value",void 0),Fd=l([$({type:N.Choice})],Fd);let Jc=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.PrintableString})],Jc.prototype,"value",void 0),Jc=l([$({type:N.Choice})],Jc);let Ym=class extends Jc{};Ym=l([$({type:N.Choice})],Ym);let Xm=class extends ft{};Xm=l([$({type:N.Choice})],Xm);let Wd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.ObjectIdentifier})],Wd.prototype,"value",void 0),Wd=l([$({type:N.Choice})],Wd);let Qm=class extends ht{};Qm=l([$({type:N.Choice})],Qm);let zd=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};l([h({type:y.Integer})],zd.prototype,"value",void 0),zd=l([$({type:N.Choice})],zd);let ey=class extends wr{};ey=l([$({type:N.Sequence})],ey);let Yc=class extends ft{};Yc=l([$({type:N.Choice})],Yc);let ty=Md=class extends Ln{constructor(e){super(e),Object.setPrototypeOf(this,Md.prototype)}};ty=Md=l([$({type:N.Sequence})],ty);let ry=Vd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Vd.prototype)}};ry=Vd=l([$({type:N.Set,itemType:Ps})],ry);let Kd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.BmpString})],Kd.prototype,"value",void 0),Kd=l([$({type:N.Choice})],Kd);let Gd=class extends J{};Gd=l([$({type:N.Sequence})],Gd);let ny=Ud=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Ud.prototype)}};ny=Ud=l([$({type:N.Sequence,itemType:Gd})],ny);var Jd;let Xc=Jd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Jd.prototype)}};Xc=Jd=l([$({type:N.Sequence,itemType:Vr})],Xc);class Ws{constructor(e={}){this.version=0,this.subject=new it,this.subjectPKInfo=new xr,this.attributes=new Xc,Object.assign(this,e)}}l([h({type:y.Integer})],Ws.prototype,"version",void 0),l([h({type:it})],Ws.prototype,"subject",void 0),l([h({type:xr})],Ws.prototype,"subjectPKInfo",void 0),l([h({type:Xc,implicit:!0,context:0})],Ws.prototype,"attributes",void 0);class Aa{constructor(e={}){this.certificationRequestInfo=new Ws,this.signatureAlgorithm=new J,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Ws})],Aa.prototype,"certificationRequestInfo",void 0),l([h({type:J})],Aa.prototype,"signatureAlgorithm",void 0),l([h({type:y.BitString})],Aa.prototype,"signature",void 0);/*!
90
+ `)}function ew(r,e,t){var n=qc(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],i=s===void 0?null:s,a=X_(i,e);return Q_("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function tw(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var rw=function(r){Td(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bd),nw=function(r){Td(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Bd),sw=function(){function r(){this.preResolution=new rw,this.postResolution=new nw}return r}(),Vm=new Map,iw=function(){function r(e){this.parent=e,this._registry=new Y_,this.interceptors=new sw,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:jt.Transient}),this.ensureNotDisposed();var s;if(J_(t)?s=t:s={useClass:t},Hc(s))for(var i=[e],a=s;a!=null;){var o=a.useToken;if(i.includes(o))throw new Error("Token registration cycle detected! "+Yn(i,[o]).join(" -> "));i.push(o);var c=this._registry.get(o);c&&Hc(c.provider)?a=c.provider:a=null}if((n.lifecycle===jt.Singleton||n.lifecycle==jt.ContainerScoped||n.lifecycle==jt.ResolutionScoped)&&(Fc(s)||Nd(s)))throw new Error('Cannot use lifecycle "'+jt[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:s,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Ws(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(),Ws(e)){if(Ws(t))return this.register(e,{useToken:t},{lifecycle:jt.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:jt.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Ws(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:jt.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new Mm),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&Ws(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var s=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(G_(e)){var s=this.construct(e,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}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,s;if(this.interceptors.preResolution.has(e)){var i=[];try{for(var a=Lc(this.interceptors.preResolution.getAll(e)),o=a.next();!o.done;o=a.next()){var c=o.value;c.options.frequency!="Once"&&i.push(c),c.callback(e,t)}}catch(u){n={error:u}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,i)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var s,i;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var o=Lc(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){s={error:f}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}this.interceptors.postResolution.setAll(e,a)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===jt.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===jt.Singleton,s=e.options.lifecycle===jt.ContainerScoped,i=n||s,a;return Fc(e.provider)?a=e.provider.useValue:Hc(e.provider)?a=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):$m(e.provider)?a=i?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===jt.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new Mm),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&Ws(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),s){var i=s.map(function(o){return n.resolveRegistration(o,t)});return this.executePostResolutionInterceptor(e,i,"All"),i}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=Lc(this._registry.entries()),s=n.next();!s.done;s=n.next()){var i=qc(s.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(c){return!Fc(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{s&&!s.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 s=Lc(this._registry.entries()),i=s.next();!i.done;i=s.next()){var a=qc(i.value,2),o=a[0],c=a[1];c.some(function(u){var f=u.options;return f.lifecycle===jt.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===jt.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(t=s.return)&&t.call(s)}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 H_(this,void 0,void 0,function(){var e;return F_(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var s=n.dispose();s&&e.push(s)}),[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 Zm)return e.createProxy(function(i){return n.resolve(i,t)});var s=function(){var i=Vm.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=i.map(n.resolveParams(t,e));return new(e.bind.apply(e,Yn([void 0],a)))}();return tw(s)&&this.disposables.add(s),s},r.prototype.resolveParams=function(e,t){var n=this;return function(s,i){var a,o,c;try{return z_(s)?Dm(s)?s.multiple?(a=n.resolve(s.transform)).transform.apply(a,Yn([n.resolveAll(s.token)],s.transformArgs)):(o=n.resolve(s.transform)).transform.apply(o,Yn([n.resolve(s.token,e)],s.transformArgs)):s.multiple?n.resolveAll(s.token):n.resolve(s.token,e):Dm(s)?(c=n.resolve(s.transform,e)).transform.apply(c,Yn([n.resolve(s.token,e)],s.transformArgs)):n.resolve(s,e)}catch(u){throw new Error(ew(t,i,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 iw;function Wc(){return function(r){Vm.set(r,K_(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 Rd;class Kc{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}l([h({type:g.ObjectIdentifier})],Kc.prototype,"attrId",void 0),l([h({type:g.Any,repeated:"set"})],Kc.prototype,"attrValues",void 0);let Um=Rd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Rd.prototype)}};Um=Rd=l([$({type:N.Sequence,itemType:Kc})],Um);var Pd;let Lm=Pd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Pd.prototype)}};Lm=Pd=l([$({type:N.Sequence,itemType:Vs})],Lm);class qm{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],qm.prototype,"certId",void 0),l([h({type:g.Any,context:0})],qm.prototype,"certValue",void 0);class Hm{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Hm.prototype,"crlId",void 0),l([h({type:g.Any,context:0})],Hm.prototype,"crltValue",void 0);class Fm extends Re{}let zc=class{constructor(e={}){this.encryptionAlgorithm=new Y,this.encryptedData=new Fm,Object.assign(this,e)}};l([h({type:Y})],zc.prototype,"encryptionAlgorithm",void 0),l([h({type:Fm})],zc.prototype,"encryptedData",void 0);var $d,Zd;(function(r){r[r.v1=0]="v1"})(Zd||(Zd={}));class Wm extends Re{}let Dd=$d=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,$d.prototype)}};Dd=$d=l([$({type:N.Sequence,itemType:Ur})],Dd);class Sa{constructor(e={}){this.version=Zd.v1,this.privateKeyAlgorithm=new Y,this.privateKey=new Wm,Object.assign(this,e)}}l([h({type:g.Integer})],Sa.prototype,"version",void 0),l([h({type:Y})],Sa.prototype,"privateKeyAlgorithm",void 0),l([h({type:Wm})],Sa.prototype,"privateKey",void 0),l([h({type:Dd,implicit:!0,context:0,optional:!0})],Sa.prototype,"attributes",void 0);let Km=class extends Sa{};Km=l([$({type:N.Sequence})],Km);let zm=class extends zc{};zm=l([$({type:N.Sequence})],zm);class Gm{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Gm.prototype,"secretTypeId",void 0),l([h({type:g.Any,context:0})],Gm.prototype,"secretValue",void 0);class Aa{constructor(e={}){this.mac=new Vc,this.macSalt=new Re,this.iterations=1,Object.assign(this,e)}}l([h({type:Vc})],Aa.prototype,"mac",void 0),l([h({type:Re})],Aa.prototype,"macSalt",void 0),l([h({type:g.Integer,defaultValue:1})],Aa.prototype,"iterations",void 0);class Gc{constructor(e={}){this.version=3,this.authSafe=new Vs,this.macData=new Aa,Object.assign(this,e)}}l([h({type:g.Integer})],Gc.prototype,"version",void 0),l([h({type:Vs})],Gc.prototype,"authSafe",void 0),l([h({type:Aa,optional:!0})],Gc.prototype,"macData",void 0);var Md;class Jc{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Jc.prototype,"bagId",void 0),l([h({type:g.Any,context:0})],Jc.prototype,"bagValue",void 0),l([h({type:Kc,repeated:"set",optional:!0})],Jc.prototype,"bagAttributes",void 0);let Jm=Md=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Md.prototype)}};Jm=Md=l([$({type:N.Sequence,itemType:Jc})],Jm);var Vd,Ud,Ld;const Ym="1.2.840.113549.1.9",Xm=`${Ym}.7`,qd=`${Ym}.14`;let Yc=class extends ft{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};l([h({type:g.IA5String})],Yc.prototype,"ia5String",void 0),Yc=l([$({type:N.Choice})],Yc);let Qm=class extends Vs{};Qm=l([$({type:N.Sequence})],Qm);let ey=class extends Gc{};ey=l([$({type:N.Sequence})],ey);let ty=class extends zc{};ty=l([$({type:N.Sequence})],ty);let Hd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:g.IA5String})],Hd.prototype,"value",void 0),Hd=l([$({type:N.Choice})],Hd);let ry=class extends Yc{};ry=l([$({type:N.Choice})],ry);let ny=class extends ft{};ny=l([$({type:N.Choice})],ny);let Fd=class{constructor(e=new Date){this.value=e}};l([h({type:g.GeneralizedTime})],Fd.prototype,"value",void 0),Fd=l([$({type:N.Choice})],Fd);let sy=class extends ft{};sy=l([$({type:N.Choice})],sy);let Wd=class{constructor(e="M"){this.value=e}toString(){return this.value}};l([h({type:g.PrintableString})],Wd.prototype,"value",void 0),Wd=l([$({type:N.Choice})],Wd);let Xc=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:g.PrintableString})],Xc.prototype,"value",void 0),Xc=l([$({type:N.Choice})],Xc);let iy=class extends Xc{};iy=l([$({type:N.Choice})],iy);let ay=class extends ft{};ay=l([$({type:N.Choice})],ay);let Kd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:g.ObjectIdentifier})],Kd.prototype,"value",void 0),Kd=l([$({type:N.Choice})],Kd);let oy=class extends ht{};oy=l([$({type:N.Choice})],oy);let zd=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};l([h({type:g.Integer})],zd.prototype,"value",void 0),zd=l([$({type:N.Choice})],zd);let cy=class extends Sr{};cy=l([$({type:N.Sequence})],cy);let Qc=class extends ft{};Qc=l([$({type:N.Choice})],Qc);let uy=Vd=class extends pn{constructor(e){super(e),Object.setPrototypeOf(this,Vd.prototype)}};uy=Vd=l([$({type:N.Sequence})],uy);let ly=Ud=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Ud.prototype)}};ly=Ud=l([$({type:N.Set,itemType:$s})],ly);let Gd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:g.BmpString})],Gd.prototype,"value",void 0),Gd=l([$({type:N.Choice})],Gd);let Jd=class extends Y{};Jd=l([$({type:N.Sequence})],Jd);let dy=Ld=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Ld.prototype)}};dy=Ld=l([$({type:N.Sequence,itemType:Jd})],dy);var Yd;let eu=Yd=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Yd.prototype)}};eu=Yd=l([$({type:N.Sequence,itemType:Ur})],eu);class Ks{constructor(e={}){this.version=0,this.subject=new et,this.subjectPKInfo=new ir,this.attributes=new eu,Object.assign(this,e)}}l([h({type:g.Integer})],Ks.prototype,"version",void 0),l([h({type:et})],Ks.prototype,"subject",void 0),l([h({type:ir})],Ks.prototype,"subjectPKInfo",void 0),l([h({type:eu,implicit:!0,context:0})],Ks.prototype,"attributes",void 0);class Oa{constructor(e={}){this.certificationRequestInfo=new Ks,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Ks})],Oa.prototype,"certificationRequestInfo",void 0),l([h({type:Y})],Oa.prototype,"signatureAlgorithm",void 0),l([h({type:g.BitString})],Oa.prototype,"signature",void 0);/*!
91
91
  * MIT License
92
92
  *
93
93
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -110,12 +110,16 @@ ${e.join(`
110
110
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
111
111
  * SOFTWARE.
112
112
  *
113
- */const Oa="crypto.algorithm";class ew{getAlgorithms(){return wt.resolveAll(Oa)}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 J({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 s=n.toWebAlgorithm(e);if(s)return s}return{name:e.algorithm,parameters:e.parameters}}}const zs="crypto.algorithmProvider";wt.registerSingleton(zs,ew);var Qc;const jt="1.3.36.3.3.2.8.1.1",sy=`${jt}.1`,iy=`${jt}.2`,ay=`${jt}.3`,oy=`${jt}.4`,cy=`${jt}.5`,uy=`${jt}.6`,ly=`${jt}.7`,dy=`${jt}.8`,fy=`${jt}.9`,hy=`${jt}.10`,py=`${jt}.11`,my=`${jt}.12`,yy=`${jt}.13`,gy=`${jt}.14`,vy="brainpoolP160r1",by="brainpoolP160t1",xy="brainpoolP192r1",_y="brainpoolP192t1",wy="brainpoolP224r1",ky="brainpoolP224t1",Sy="brainpoolP256r1",Ay="brainpoolP256t1",Oy="brainpoolP320r1",Ey="brainpoolP320t1",Cy="brainpoolP384r1",Iy="brainpoolP384t1",jy="brainpoolP512r1",Ty="brainpoolP512t1",Ye="ECDSA";let Ea=Qc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case Ye.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return S_;case"sha-256":return A_;case"sha-384":return O_;case"sha-512":return E_}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=xm;break;case"K-256":t=Qc.SECP256K1;break;case"P-384":t=_m;break;case"P-521":t=wm;break;case vy:t=sy;break;case by:t=iy;break;case xy:t=ay;break;case _y:t=oy;break;case wy:t=cy;break;case ky:t=uy;break;case Sy:t=ly;break;case Ay:t=dy;break;case Oy:t=fy;break;case Ey:t=hy;break;case Cy:t=py;break;case Iy:t=my;break;case jy:t=yy;break;case Ty:t=gy;break}if(t)return new J({algorithm:ba,parameters:F.serialize(new pn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case bd:return{name:Ye,hash:{name:"SHA-1"}};case xd:return{name:Ye,hash:{name:"SHA-256"}};case _d:return{name:Ye,hash:{name:"SHA-384"}};case wd:return{name:Ye,hash:{name:"SHA-512"}};case ba:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(F.parse(e.parameters,pn).namedCurve){case xm:return{name:Ye,namedCurve:"P-256"};case Qc.SECP256K1:return{name:Ye,namedCurve:"K-256"};case _m:return{name:Ye,namedCurve:"P-384"};case wm:return{name:Ye,namedCurve:"P-521"};case sy:return{name:Ye,namedCurve:vy};case iy:return{name:Ye,namedCurve:by};case ay:return{name:Ye,namedCurve:xy};case oy:return{name:Ye,namedCurve:_y};case cy:return{name:Ye,namedCurve:wy};case uy:return{name:Ye,namedCurve:ky};case ly:return{name:Ye,namedCurve:Sy};case dy:return{name:Ye,namedCurve:Ay};case fy:return{name:Ye,namedCurve:Oy};case hy:return{name:Ye,namedCurve:Ey};case py:return{name:Ye,namedCurve:Cy};case my:return{name:Ye,namedCurve:Iy};case yy:return{name:Ye,namedCurve:jy};case gy:return{name:Ye,namedCurve:Ty}}}}return null}};Ea.SECP256K1="1.3.132.0.10",Ea=Qc=l([Hc()],Ea),wt.registerSingleton(Oa,Ea);const Ny=Symbol("name"),By=Symbol("value");class Ze{constructor(e,t={},n=""){this[Ny]=e,this[By]=n;for(const s in t)this[s]=t[s]}}Ze.NAME=Ny,Ze.VALUE=By;class tw{static toTextObject(e){const t=new Ze("Algorithm Identifier",{},mn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case ba:{const n=new Ea().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class mn{static toString(e){const t=this.items[e];return t||e}}mn.items={[Nc]:"sha1",[Am]:"sha224",[Bc]:"sha256",[Rc]:"sha384",[Pc]:"sha512",[Wn]:"rsaEncryption",[Ic]:"sha1WithRSAEncryption",[B_]:"sha224WithRSAEncryption",[Sd]:"sha256WithRSAEncryption",[jc]:"sha384WithRSAEncryption",[Tc]:"sha512WithRSAEncryption",[ba]:"ecPublicKey",[bd]:"ecdsaWithSHA1",[bm]:"ecdsaWithSHA224",[xd]:"ecdsaWithSHA256",[_d]:"ecdsaWithSHA384",[wd]:"ecdsaWithSHA512",[g_]:"TLS WWW server authentication",[v_]:"TLS WWW client authentication",[b_]:"Code Signing",[x_]:"E-mail Protection",[__]:"Time Stamping",[w_]:"OCSP Signing",[k_]:"Signed Data"};class Jn{static serialize(e){return this.serializeObj(e).join(`
114
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let s=this.pad(t++),i="";const a=e[Ze.VALUE];a&&(i=` ${a}`),n.push(`${s}${e[Ze.NAME]}:${i}`),s=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(`${s}${u}${c}`);else if(c instanceof Date)n.push(`${s}${u}${c.toUTCString()}`);else if(Array.isArray(c))for(const f of c)f[Ze.NAME]=o,n.push(...this.serializeObj(f,t));else if(c instanceof Ze)c[Ze.NAME]=o,n.push(...this.serializeObj(c,t));else if(L.isBufferSource(c))o?(n.push(`${s}${u}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){const f=c.toTextObject();f[Ze.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),s=L.toUint8Array(e),i=[];for(let a=0;a<s.length;){const o=[];for(let c=0;c<16&&a<s.length;c++){c===8&&o.push("");const u=s[a++].toString(16).padStart(2,"0");o.push(u)}i.push(`${n}${o.join(" ")}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Jn.oidSerializer=mn,Jn.algorithmSerializer=tw;class yn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=F.serialize(t),this.onInit(t)}else{const t=F.parse(e[0],e[1]);this.rawData=L.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof yn?$h(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return F.toString(this.rawData);case"text":return Jn.serialize(this.toTextObject());case"hex":return re.ToHex(this.rawData);case"base64":return re.ToBase64(this.rawData);case"base64url":return re.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 Ze(this.getTextName(),{},e)}}yn.NAME="ASN";class Ht extends yn{constructor(...e){let t;L.isBufferSource(e[0])?t=L.toArrayBuffer(e[0]):t=F.serialize(new nr({extnID:e[0],critical:e[1],extnValue:new Re(L.toArrayBuffer(e[2]))})),super(t,nr)}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[Ze.NAME]===Ht.NAME&&(e[Ze.NAME]=mn.toString(this.type)),e}}var Ry;class gn{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[Ry]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(gn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(gn.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=gn.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(gn.DEFAULT,e);return this}}Ry=Symbol.toStringTag,gn.DEFAULT="default";const kt=new gn,rw=/^[0-2](?:\.[1-9][0-9]*)+$/;function nw(r){return new RegExp(rw).test(r)}class Py{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return nw(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const Tt=new Py;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 sw(r,e){return`\\${re.ToHex(re.FromUtf8String(e)).toUpperCase()}`}function iw(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,sw)}class vn{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 Py,this.asn=new it;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=t[n];this.extraNames.register(n,s)}typeof e=="string"?this.asn=this.fromString(e):e instanceof it?this.asn=e:L.isBufferSource(e)?this.asn=F.parse(e,it):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||Tt.findId(e),n=[];for(const s of this.asn)for(const i of s)i.type===t&&n.push(i.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,s=t.value.anyValue?`#${re.ToHex(t.value.anyValue)}`:iw(t.value.toString());return`${n}=${s}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const s={};for(const i of n){const a=this.getName(i.type)||i.type;(e=s[a])!==null&&e!==void 0||(s[a]=[]),s[a].push(i.value.anyValue?`#${re.ToHex(i.value.anyValue)}`:i.value.toString())}t.push(s)}return t}fromString(e){const t=new it,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let s=null,i=",";for(;s=n.exec(`${e},`);){let[,a,o]=s;const c=o[o.length-1];(c===","||c==="+")&&(o=o.slice(0,o.length-1),s[3]=c);const u=s[3];a=this.getTypeOid(a);const f=this.createAttribute(a,o);i==="+"?t[t.length-1].push(f):t.push(new Os([f])),i=u}return t}fromJSON(e){const t=new it;for(const n of e){const s=new Os;for(const i in n){const a=this.getTypeOid(i),o=n[i];for(const c of o){const u=this.createAttribute(a,c);s.push(u)}}t.push(s)}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 Ko({type:e});if(typeof t=="object")for(const s in t)switch(s){case"ia5String":n.value.ia5String=t[s];break;case"utf8String":n.value.utf8String=t[s];break;case"universalString":n.value.universalString=t[s];break;case"bmpString":n.value.bmpString=t[s];break;case"printableString":n.value.printableString=t[s];break}else if(t[0]==="#")n.value.anyValue=re.FromHex(t.slice(1));else{const s=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=s:vn.isPrintableString(s)?n.value.printableString=s:n.value.utf8String=s}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
115
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return F.serialize(this.asn)}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||kt.get()):n=e[0]||kt.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const $y="Cannot initialize GeneralName from ASN.1 data.",Zy=`${$y} Unsupported string format in use.`,aw=`${$y} Value doesn't match to GUID regular expression.`,Dy=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,My="1.3.6.1.4.1.311.25.1",Vy="1.3.6.1.4.1.311.20.2.3",Yd="dns",Xd="dn",Qd="email",ef="ip",tf="url",rf="guid",nf="upn",eu="id";class bn extends yn{constructor(...e){let t;if(e.length===2)switch(e[0]){case Xd:{const n=new vn(e[1]).toArrayBuffer(),s=F.parse(n,it);t=new ge({directoryName:s});break}case Yd:t=new ge({dNSName:e[1]});break;case Qd:t=new ge({rfc822Name:e[1]});break;case rf:{const n=new RegExp(Dy,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const s=n.slice(1).map((i,a)=>a<3?re.ToHex(new Uint8Array(re.FromHex(i)).reverse()):i).join("");t=new ge({otherName:new ia({typeId:My,value:F.serialize(new Re(re.FromHex(s)))})});break}case ef:t=new ge({iPAddress:e[1]});break;case eu:t=new ge({registeredID:e[1]});break;case nf:{t=new ge({otherName:new ia({typeId:Vy,value:F.serialize(Dp.toASN(e[1]))})});break}case tf:t=new ge({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else L.isBufferSource(e[0])?t=F.parse(e[0],ge):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=Yd,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Qd,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=ef,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=tf,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=eu,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Xd,this.value=new vn(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===My){this.type=rf;const t=F.parse(e.otherName.value,Re),n=new RegExp(Dy,"i").exec(re.ToHex(t));if(!n)throw new Error(aw);this.value=n.slice(1).map((s,i)=>i<3?re.ToHex(new Uint8Array(re.FromHex(s)).reverse()):s).join("-")}else if(e.otherName.typeId===Vy)this.type=nf,this.value=F.parse(e.otherName.value,ft).toString();else throw new Error(Zy);else throw new Error(Zy)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Xd:case Yd:case rf:case ef:case eu:case nf:case tf:e=this.type.toUpperCase();break;case Qd:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===eu&&(t=mn.toString(t)),new Ze(e,void 0,t)}}class Ca extends yn{constructor(e){let t;if(e instanceof _t)t=e;else if(Array.isArray(e)){const n=[];for(const s of e)if(s instanceof ge)n.push(s);else{const i=F.parse(new bn(s.type,s.value).rawData,ge);n.push(i)}t=new _t(n)}else if(L.isBufferSource(e))t=F.parse(e,_t);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let s=null;try{s=new bn(n)}catch{continue}t.push(s)}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 s=e[n[Ze.NAME]];Array.isArray(s)||(s=[],e[n[Ze.NAME]]=s),s.push(n)}return e}}Ca.NAME="GeneralNames";const Ia="-{5}",ja="\\n",ow=`[^${ja}]+`,cw=`${Ia}BEGIN (${ow}(?=${Ia}))${Ia}`,uw=`${Ia}END \\1${Ia}`,Ks="\\n",lw=`[^:${ja}]+`,dw=`(?:[^${ja}]+${Ks}(?: +[^${ja}]+${Ks})*)`,fw=`(?:[a-zA-Z0-9=+/]+${Ks})+`,Uy=`${cw}${Ks}(?:((?:${lw}: ${dw})+))?${Ks}?(${fw})${uw}`;class Zt{static isPem(e){return typeof e=="string"&&new RegExp(Uy,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Uy,"g"),n=[];let s=null;for(;s=t.exec(e);){const i=s[3].replace(new RegExp(`[${ja}]+`,"g"),""),a={type:s[1],headers:[],rawData:re.FromBase64(i)},o=s[2];if(o){const c=o.split(new RegExp(Ks,"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(s=>{if(!L.isBufferSource(s))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:L.toArrayBuffer(s)}))}):e.forEach(s=>{if(!("type"in s))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(s))}),n.join(`
116
- `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:L.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),s=[];if(s.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const u of e.headers)s.push(`${u.key}: ${u.value}`);s.push("")}const i=re.ToBase64(e.rawData);let a,o=0;const c=Array();for(;o<i.length&&(i.length-o<64?a=i.substring(o):(a=i.substring(o,o+64),o+=64),a.length!==0);)if(c.push(a),a.length<64)break;return s.push(...c),s.push(`-----END ${n}-----`),s.join(`
117
- `)}}Zt.CertificateTag="CERTIFICATE",Zt.CrlTag="CRL",Zt.CertificateRequestTag="CERTIFICATE REQUEST",Zt.PublicKeyTag="PUBLIC KEY",Zt.PrivateKeyTag="PRIVATE KEY";class Hr extends yn{static isAsnEncoded(e){return L.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Zt.isPem(e))return Zt.decode(e)[0];if(re.isHex(e))return re.FromHex(e);if(re.isBase64(e))return re.FromBase64(e);if(re.isBase64Url(e))return re.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=re.ToBinary(e);return Zt.isPem(t)?Zt.decode(t)[0]:re.isHex(t)?re.FromHex(t):re.isBase64(t)?re.FromBase64(t):re.isBase64Url(t)?re.FromBase64Url(t):L.toArrayBuffer(e)}}constructor(...e){Hr.isAsnEncoded(e[0])?super(Hr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Zt.encode(this.rawData,this.tag);default:return super.toString(e)}}}class Sr extends Hr{static async create(e,t=kt.get()){if(e instanceof Sr)return e;if(gn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new Sr(n)}else{if(e.publicKey)return e.publicKey;if(L.isBufferSource(e))return new Sr(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Hr.isAsnEncoded(e)?super(e,xr):super(e),this.tag=Zt.PublicKeyTag}async export(...e){let t,n=["verify"],s={hash:"SHA-256",...this.algorithm};e.length>1?(s=e[0]||s,n=e[1]||n,t=e[2]||kt.get()):t=e[0]||kt.get();let i=this.rawData;const a=F.parse(this.rawData,xr);return a.algorithm.algorithm===wa&&(i=hw(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=wt.resolve(zs),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Wn:{const s=F.parse(e.subjectPublicKey,Ed),i=L.toUint8Array(s.modulus);n.publicExponent=L.toUint8Array(s.publicExponent),n.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||kt.get()):n=e[0]||kt.get(),await n.subtle.digest(s,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=kt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=kt.get();const s=F.parse(this.rawData,xr);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=F.parse(this.rawData,xr);switch(e.Algorithm=Jn.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case ba:e["EC Point"]=t.subjectPublicKey;break;case Wn:default:e["Raw Data"]=t.subjectPublicKey}return e}}function hw(r,e){return r.algorithm=new J({algorithm:Wn,parameters:null}),e=F.serialize(r),e}class Ta extends Ht{static async create(e,t=!1,n=kt.get()){if("name"in e&&"serialNumber"in e)return new Ta(e,t);const i=await(await Sr.create(e,n)).getKeyIdentifier(n);return new Ta(re.ToHex(i),t)}constructor(...e){if(L.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Vn({keyIdentifier:new kl(re.FromHex(e[0]))});super(wl,e[1],F.serialize(t))}else{const t=e[0],n=t.name instanceof Ca?F.parse(t.name.rawData,_t):t.name,s=new Vn({authorityCertIssuer:n,authorityCertSerialNumber:re.FromHex(t.serialNumber)});super(wl,e[1],F.serialize(s))}}onInit(e){super.onInit(e);const t=F.parse(e.extnValue,Vn);t.keyIdentifier&&(this.keyId=re.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?re.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=F.parse(this.value,Vn);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Ca(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Ta.NAME="Authority Key Identifier";class Ly extends Ht{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=F.parse(this.value,Jo);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new Jo({cA:e[0],pathLenConstraint:e[1]});super(Kp,e[2],F.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}}Ly.NAME="Basic Constraints";var qy;(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"})(qy||(qy={}));class Hy extends Ht{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=F.parse(this.value,tc);this.usages=t.map(n=>n)}else{const t=new tc(e[0]);super(em,e[1],F.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>mn.toString(t)).join(", "),e}}Hy.NAME="Extended Key Usages";var Fy;(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"})(Fy||(Fy={}));class Wy extends Ht{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=F.parse(this.value,Dl);this.usages=t.toNumber()}else{const t=new Dl(e[0]);super(rm,e[1],F.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=F.parse(this.value,Dl);return e[""]=t.toJSON().join(", "),e}}Wy.NAME="Key Usages";class tu extends Ht{static async create(e,t=!1,n=kt.get()){const i=await(await Sr.create(e,n)).getKeyIdentifier(n);return new tu(re.ToHex(i),t)}constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=F.parse(this.value,fn);this.keyId=re.ToHex(t)}else{const t=typeof e[0]=="string"?re.FromHex(e[0]):e[0],n=new fn(t);super(cm,e[1],F.serialize(n)),this.keyId=re.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=F.parse(this.value,fn);return e[""]=t,e}}tu.NAME="Subject Key Identifier";class zy extends Ht{constructor(...e){L.isBufferSource(e[0])?super(e[0]):super(am,e[1],new Ca(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=F.parse(e.extnValue,ql);this.names=new Ca(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}zy.NAME="Subject Alternative Name";class Ft{static register(e,t){this.items.set(e,t)}static create(e){const t=new Ht(e),n=this.items.get(t.type);return n?new n(e):t}}Ft.items=new Map;class Ky extends Ht{constructor(...e){var t;if(L.isBufferSource(e[0])){super(e[0]);const n=F.parse(this.value,Qo);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new Qo(n.map(a=>new Xo({policyIdentifier:a})));super(Jp,s,F.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Ze("",{},mn.toString(t))),e}}Ky.NAME="Certificate Policies",Ft.register(Jp,Ky);class Gy extends Ht{constructor(...e){var t;if(L.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const s=e[0].map(a=>new Is({distributionPoint:new Un({fullName:[new ge({uniformResourceIdentifier:a})]})})),i=new js(s);super(Tl,e[1],F.serialize(i))}else{const n=new js(e[0]);super(Tl,e[1],F.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=F.parse(e.extnValue,js);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const s={};return t.distributionPoint&&(s[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(i=>new bn(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}Gy.NAME="CRL Distribution Points";class Jy extends Ht{constructor(...e){var t,n,s,i;if(L.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Cs){const a=new Cs(e[0]);super(_l,e[1],F.serialize(a))}else{const a=e[0],o=new Cs;nu(o,a,Hp,"ocsp"),nu(o,a,Fp,"caIssuers"),nu(o,a,Wp,"timeStamping"),nu(o,a,zp,"caRepository"),super(_l,e[1],F.serialize(o))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(s=this.timeStamping)!==null&&s!==void 0||(this.timeStamping=[]),(i=this.caRepository)!==null&&i!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],F.parse(e.extnValue,Cs).forEach(n=>{switch(n.accessMethod){case Hp:this.ocsp.push(new bn(n.accessLocation));break;case Fp:this.caIssuers.push(new bn(n.accessLocation));break;case Wp:this.timeStamping.push(new bn(n.accessLocation));break;case zp:this.caRepository.push(new bn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&ru(e,"OCSP",this.ocsp),this.caIssuers.length&&ru(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&ru(e,"Time Stamping",this.timeStamping),this.caRepository.length&&ru(e,"CA Repository",this.caRepository),e}}Jy.NAME="Authority Info Access";function ru(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new Ze("");t.forEach((s,i)=>{const a=s.toTextObject(),o=`${a[Ze.NAME]} ${i+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function nu(r,e,t,n){const s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new bn("url",a)),r.push(new aa({accessMethod:t,accessLocation:F.parse(a.rawData,ge)}))})}class Gs extends yn{constructor(...e){let t;if(L.isBufferSource(e[0]))t=L.toArrayBuffer(e[0]);else{const n=e[0],s=Array.isArray(e[1])?e[1].map(i=>L.toArrayBuffer(i)):[];t=F.serialize(new Vr({type:n,values:s}))}super(t,Vr)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Ze("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[Ze.NAME]===Gs.NAME&&(e[Ze.NAME]=mn.toString(this.type)),e}}Gs.NAME="Attribute";class Yy extends Gs{constructor(...e){var t;if(L.isBufferSource(e[0]))super(e[0]);else{const n=new Yc({printableString:e[0]});super(Hm,[F.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=F.parse(this.values[0],Yc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Ze.VALUE]=this.password,e}}Yy.NAME="Challenge Password";class sf extends Gs{constructor(...e){var t;if(L.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new Ln;for(const i of n)s.push(F.parse(i.rawData,nr));super(Ld,[F.serialize(s)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=F.parse(this.values[0],Ln);this.items=t.map(n=>Ft.create(F.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[Ze.NAME]]=n;return e}}sf.NAME="Extensions";class su{static register(e,t){this.items.set(e,t)}static create(e){const t=new Gs(e),n=this.items.get(t.type);return n?new n(e):t}}su.items=new Map;const iu="crypto.signatureFormatter";class pw{toAsnSignature(e,t){return L.toArrayBuffer(t)}toWebSignature(e,t){return L.toArrayBuffer(t)}}var au;let af=au=class{static createPssParams(e,t){const n=au.getHashAlgorithm(e);return n?new Kn({hashAlgorithm:n,maskGenAlgorithm:new J({algorithm:$c,parameters:F.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=wt.resolve(zs);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 J({algorithm:Ic,parameters:null});case"sha-256":return new J({algorithm:Sd,parameters:null});case"sha-384":return new J({algorithm:jc,parameters:null});case"sha-512":return new J({algorithm:Tc,parameters:null})}}else return new J({algorithm:Wn,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=au.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new J({algorithm:wa,parameters:F.serialize(t)})}else return new J({algorithm:wa,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Wn:return{name:"RSASSA-PKCS1-v1_5"};case Ic:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Sd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case jc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Tc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case wa:if(e.parameters){const t=F.parse(e.parameters,Kn);return{name:"RSA-PSS",hash:wt.resolve(zs).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};af=au=l([Hc()],af),wt.registerSingleton(Oa,af);let of=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new J({algorithm:Nc});case"sha-256":return new J({algorithm:Bc});case"sha-384":return new J({algorithm:Rc});case"sha-512":return new J({algorithm:Pc})}return null}toWebAlgorithm(e){switch(e.algorithm){case Nc:return{name:"SHA-1"};case Bc:return{name:"SHA-256"};case Rc:return{name:"SHA-384"};case Pc:return{name:"SHA-512"}}return null}};of=l([Hc()],of),wt.registerSingleton(Oa,of);class Wt{addPadding(e,t){const n=L.toUint8Array(t),s=new Uint8Array(e);return s.set(n,e-n.length),s}removePadding(e,t=!1){let n=L.toUint8Array(e);for(let s=0;s<n.length;s++)if(n[s]){n=n.slice(s);break}if(t&&n[0]>127){const s=new Uint8Array(n.length+1);return s.set(n,1),s.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,s=Wt.namedCurveSize.get(n)||Wt.defaultNamedCurveSize,i=new Cc,a=L.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),F.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=F.parse(t,Cc),s=e.namedCurve,i=Wt.namedCurveSize.get(s)||Wt.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return Cx(a,o)}return null}}Wt.namedCurveSize=new Map,Wt.defaultNamedCurveSize=32;const cf="1.3.101.110",Xy="1.3.101.111",uf="1.3.101.112",Qy="1.3.101.113";let lf=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=uf;break;case"x25519":t=cf;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=uf;break;case"ed448":t=Qy;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=cf;break;case"x448":t=Xy;break}}return t?new J({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case uf:return{name:"Ed25519"};case Qy:return{name:"EdDSA",namedCurve:"Ed448"};case cf:return{name:"X25519"};case Xy:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};lf=l([Hc()],lf),wt.registerSingleton(Oa,lf);class mw extends Hr{constructor(e){Hr.isAsnEncoded(e)?super(e,Aa):super(e),this.tag=Zt.CertificateRequestTag}onInit(e){this.tbs=F.serialize(e.certificationRequestInfo),this.publicKey=new Sr(e.certificationRequestInfo.subjectPKInfo);const t=wt.resolve(zs);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>su.create(F.serialize(s)));const n=this.getAttribute(Ld);this.extensions=[],n instanceof sf&&(this.extensions=n.items),this.subjectName=new vn(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=kt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),s=wt.resolveAll(iu).reverse();let i=null;for(const o of s)if(i=o.toWebSignature(t,this.signature),i)break;if(!i)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=F.parse(this.rawData,Aa),n=t.certificationRequestInfo,s=new Ze("",{Version:`${Ts[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new Ze("");for(const a of this.attributes){const o=a.toTextObject();i[o[Ze.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new Ze("",{Algorithm:Jn.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}mw.NAME="PKCS#10 Certificate Request";class eg extends Hr{constructor(e){Hr.isAsnEncoded(e)?super(e,Ns):super(e),this.tag=Zt.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=F.serialize(t),this.serialNumber=re.ToHex(t.serialNumber),this.subjectName=new vn(t.subject),this.subject=new vn(t.subject).toString(),this.issuerName=new vn(t.issuer),this.issuer=this.issuerName.toString();const n=wt.resolve(zs);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const s=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!s)throw new Error("Cannot get 'notBefore' value");this.notBefore=s;const i=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!i)throw new Error("Cannot get 'notAfter' value");this.notAfter=i,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(a=>Ft.create(F.serialize(a)))),this.publicKey=new Sr(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=kt.get()){let n,s;const i=e.publicKey;try{if(!i)n={...this.publicKey.algorithm,...this.signatureAlgorithm},s=await this.publicKey.export(n,["verify"],t);else if("publicKey"in i)n={...i.publicKey.algorithm,...this.signatureAlgorithm},s=await i.publicKey.export(n,["verify"],t);else if(i instanceof Sr)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(L.isBufferSource(i)){const u=new Sr(i);n={...u.algorithm,...this.signatureAlgorithm},s=await u.export(n,["verify"],t)}else n={...i.algorithm,...this.signatureAlgorithm},s=i}catch{return!1}const a=wt.resolveAll(iu).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,s,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=kt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=kt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=F.parse(this.rawData,Ns),n=t.tbsCertificate,s=new Ze("",{Version:`${Ts[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Jn.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Ze("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(s["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(s["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const i=new Ze("");for(const a of this.extensions){const o=a.toTextObject();i[o[Ze.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new Ze("",{Algorithm:Jn.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}eg.NAME="Certificate";var tg;(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"})(tg||(tg={})),Ft.register(Kp,Ly),Ft.register(em,Hy),Ft.register(rm,Wy),Ft.register(cm,tu),Ft.register(wl,Ta),Ft.register(am,zy),Ft.register(Tl,Gy),Ft.register(_l,Jy),su.register(Hm,Yy),su.register(Ld,sf),wt.registerSingleton(iu,pw),wt.registerSingleton(iu,Wt),Wt.namedCurveSize.set("P-256",32),Wt.namedCurveSize.set("K-256",32),Wt.namedCurveSize.set("P-384",48),Wt.namedCurveSize.set("P-521",66);const ou=60*5;function yw(r){return new Bt().openapi(Oe({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:dx}},description:"List of tenants"}}}),async t=>{const n=await t.env.data.keys.list(),s=await Promise.all(n.map(async i=>{const o=await new eg(i.cert).publicKey.export(),c=await crypto.subtle.exportKey("jwk",o);return jh.parse({...c,kid:i.kid})}));return t.json({keys:s},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${ou}, stale-while-revalidate=${ou*2}, stale-if-error=86400`}})}).openapi(Oe({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Th}},description:"List of tenants"}}}),async t=>{const{issuer:n}=r,s=Th.parse({issuer:n,authorization_endpoint:`${n}authorize`,token_endpoint:`${n}oauth/token`,device_authorization_endpoint:`${n}oauth/device/code`,userinfo_endpoint:`${n}userinfo`,mfa_challenge_endpoint:`${n}mfa/challenge`,jwks_uri:`${n}.well-known/jwks.json`,registration_endpoint:`${n}oidc/register`,revocation_endpoint:`${n}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(s,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${ou}, stale-while-revalidate=${ou*2}, stale-if-error=86400`}})})}async function rg(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function gw({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}`}),s=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(s.length===0)return;const i=s.filter(c=>!c.linked_to);if(i.length>0)return i.length>1&&console.error("More than one primary user found for same email"),i[0];const a=await r.get(e,(o=s[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}function vw(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await gw({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)}}function ng(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:[]}}async function bw(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 i=ng(r,{type:Wu.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,i)}}function xw(r,e){return async(t,n)=>{const{hooks:s}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await bw(r,s,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function _w(r,e){return async(t,n)=>{let s=await vw(e)(t,n);return await xw(r,e)(t,s),s}}function ww(r,e){return{...e,users:{...e.users,create:_w(r,e)}}}const kw=new Bt().openapi(Oe({tags:["branding"],method:"get",path:"/",request:{headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ih}},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(Oe({tags:["branding"],method:"patch",path:"/",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object(Ih.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")});function Sw(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 sg={exports:{}};const Aw=kx(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){/**
113
+ */const Ea="crypto.algorithm";class aw{getAlgorithms(){return pt.resolveAll(Ea)}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 s=n.toWebAlgorithm(e);if(s)return s}return{name:e.algorithm,parameters:e.parameters}}}const Xn="crypto.algorithmProvider";pt.registerSingleton(Xn,aw);var tu;const Tt="1.3.36.3.3.2.8.1.1",fy=`${Tt}.1`,hy=`${Tt}.2`,py=`${Tt}.3`,my=`${Tt}.4`,yy=`${Tt}.5`,gy=`${Tt}.6`,vy=`${Tt}.7`,by=`${Tt}.8`,xy=`${Tt}.9`,_y=`${Tt}.10`,wy=`${Tt}.11`,ky=`${Tt}.12`,Sy=`${Tt}.13`,Ay=`${Tt}.14`,Oy="brainpoolP160r1",Ey="brainpoolP160t1",Cy="brainpoolP192r1",Iy="brainpoolP192t1",jy="brainpoolP224r1",Ty="brainpoolP224t1",Ny="brainpoolP256r1",By="brainpoolP256t1",Ry="brainpoolP320r1",Py="brainpoolP320t1",$y="brainpoolP384r1",Zy="brainpoolP384t1",Dy="brainpoolP512r1",My="brainpoolP512t1",Ye="ECDSA";let Ca=tu=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case Ye.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return j_;case"sha-256":return T_;case"sha-384":return N_;case"sha-512":return B_}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=Cm;break;case"K-256":t=tu.SECP256K1;break;case"P-384":t=Im;break;case"P-521":t=jm;break;case Oy:t=fy;break;case Ey:t=hy;break;case Cy:t=py;break;case Iy:t=my;break;case jy:t=yy;break;case Ty:t=gy;break;case Ny:t=vy;break;case By:t=by;break;case Ry:t=xy;break;case Py:t=_y;break;case $y:t=wy;break;case Zy:t=ky;break;case Dy:t=Sy;break;case My:t=Ay;break}if(t)return new Y({algorithm:xa,parameters:U.serialize(new yn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case xd:return{name:Ye,hash:{name:"SHA-1"}};case _d:return{name:Ye,hash:{name:"SHA-256"}};case wd:return{name:Ye,hash:{name:"SHA-384"}};case kd:return{name:Ye,hash:{name:"SHA-512"}};case xa:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(U.parse(e.parameters,yn).namedCurve){case Cm:return{name:Ye,namedCurve:"P-256"};case tu.SECP256K1:return{name:Ye,namedCurve:"K-256"};case Im:return{name:Ye,namedCurve:"P-384"};case jm:return{name:Ye,namedCurve:"P-521"};case fy:return{name:Ye,namedCurve:Oy};case hy:return{name:Ye,namedCurve:Ey};case py:return{name:Ye,namedCurve:Cy};case my:return{name:Ye,namedCurve:Iy};case yy:return{name:Ye,namedCurve:jy};case gy:return{name:Ye,namedCurve:Ty};case vy:return{name:Ye,namedCurve:Ny};case by:return{name:Ye,namedCurve:By};case xy:return{name:Ye,namedCurve:Ry};case _y:return{name:Ye,namedCurve:Py};case wy:return{name:Ye,namedCurve:$y};case ky:return{name:Ye,namedCurve:Zy};case Sy:return{name:Ye,namedCurve:Dy};case Ay:return{name:Ye,namedCurve:My}}}}return null}};Ca.SECP256K1="1.3.132.0.10",Ca=tu=l([Wc()],Ca),pt.registerSingleton(Ea,Ca);const Vy=Symbol("name"),Uy=Symbol("value");class De{constructor(e,t={},n=""){this[Vy]=e,this[Uy]=n;for(const s in t)this[s]=t[s]}}De.NAME=Vy,De.VALUE=Uy;class ow{static toTextObject(e){const t=new De("Algorithm Identifier",{},gn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case xa:{const n=new Ca().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class gn{static toString(e){const t=this.items[e];return t||e}}gn.items={[Rc]:"sha1",[Bm]:"sha224",[Pc]:"sha256",[$c]:"sha384",[Zc]:"sha512",[zn]:"rsaEncryption",[Tc]:"sha1WithRSAEncryption",[M_]:"sha224WithRSAEncryption",[Ad]:"sha256WithRSAEncryption",[Nc]:"sha384WithRSAEncryption",[Bc]:"sha512WithRSAEncryption",[xa]:"ecPublicKey",[xd]:"ecdsaWithSHA1",[Em]:"ecdsaWithSHA224",[_d]:"ecdsaWithSHA256",[wd]:"ecdsaWithSHA384",[kd]:"ecdsaWithSHA512",[k_]:"TLS WWW server authentication",[S_]:"TLS WWW client authentication",[A_]:"Code Signing",[O_]:"E-mail Protection",[E_]:"Time Stamping",[C_]:"OCSP Signing",[I_]:"Signed Data"};class Qn{static serialize(e){return this.serializeObj(e).join(`
114
+ `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let s=this.pad(t++),i="";const a=e[De.VALUE];a&&(i=` ${a}`),n.push(`${s}${e[De.NAME]}:${i}`),s=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(`${s}${u}${c}`);else if(c instanceof Date)n.push(`${s}${u}${c.toUTCString()}`);else if(Array.isArray(c))for(const f of c)f[De.NAME]=o,n.push(...this.serializeObj(f,t));else if(c instanceof De)c[De.NAME]=o,n.push(...this.serializeObj(c,t));else if(q.isBufferSource(c))o?(n.push(`${s}${u}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){const f=c.toTextObject();f[De.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),s=q.toUint8Array(e),i=[];for(let a=0;a<s.length;){const o=[];for(let c=0;c<16&&a<s.length;c++){c===8&&o.push("");const u=s[a++].toString(16).padStart(2,"0");o.push(u)}i.push(`${n}${o.join(" ")}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Qn.oidSerializer=gn,Qn.algorithmSerializer=ow;class vn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=U.serialize(t),this.onInit(t)}else{const t=U.parse(e[0],e[1]);this.rawData=q.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof vn?Hh(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return U.toString(this.rawData);case"text":return Qn.serialize(this.toTextObject());case"hex":return re.ToHex(this.rawData);case"base64":return re.ToBase64(this.rawData);case"base64url":return re.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 De(this.getTextName(),{},e)}}vn.NAME="ASN";class Ft extends vn{constructor(...e){let t;q.isBufferSource(e[0])?t=q.toArrayBuffer(e[0]):t=U.serialize(new Ht({extnID:e[0],critical:e[1],extnValue:new Re(q.toArrayBuffer(e[2]))})),super(t,Ht)}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[De.NAME]===Ft.NAME&&(e[De.NAME]=gn.toString(this.type)),e}}var Ly;class bn{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[Ly]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(bn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(bn.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=bn.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(bn.DEFAULT,e);return this}}Ly=Symbol.toStringTag,bn.DEFAULT="default";const mt=new bn,cw=/^[0-2](?:\.[1-9][0-9]*)+$/;function uw(r){return new RegExp(cw).test(r)}class qy{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return uw(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const Nt=new qy;Nt.register("CN","2.5.4.3"),Nt.register("L","2.5.4.7"),Nt.register("ST","2.5.4.8"),Nt.register("O","2.5.4.10"),Nt.register("OU","2.5.4.11"),Nt.register("C","2.5.4.6"),Nt.register("DC","0.9.2342.19200300.100.1.25"),Nt.register("E","1.2.840.113549.1.9.1"),Nt.register("G","2.5.4.42"),Nt.register("I","2.5.4.43"),Nt.register("SN","2.5.4.4"),Nt.register("T","2.5.4.12");function lw(r,e){return`\\${re.ToHex(re.FromUtf8String(e)).toUpperCase()}`}function dw(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,lw)}class Wt{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 qy,this.asn=new et;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=t[n];this.extraNames.register(n,s)}typeof e=="string"?this.asn=this.fromString(e):e instanceof et?this.asn=e:q.isBufferSource(e)?this.asn=U.parse(e,et):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||Nt.findId(e),n=[];for(const s of this.asn)for(const i of s)i.type===t&&n.push(i.value.toString());return n}getName(e){return this.extraNames.get(e)||Nt.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,s=t.value.anyValue?`#${re.ToHex(t.value.anyValue)}`:dw(t.value.toString());return`${n}=${s}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const s={};for(const i of n){const a=this.getName(i.type)||i.type;(e=s[a])!==null&&e!==void 0||(s[a]=[]),s[a].push(i.value.anyValue?`#${re.ToHex(i.value.anyValue)}`:i.value.toString())}t.push(s)}return t}fromString(e){const t=new et,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let s=null,i=",";for(;s=n.exec(`${e},`);){let[,a,o]=s;const c=o[o.length-1];(c===","||c==="+")&&(o=o.slice(0,o.length-1),s[3]=c);const u=s[3];a=this.getTypeOid(a);const f=this.createAttribute(a,o);i==="+"?t[t.length-1].push(f):t.push(new Is([f])),i=u}return t}fromJSON(e){const t=new et;for(const n of e){const s=new Is;for(const i in n){const a=this.getTypeOid(i),o=n[i];for(const c of o){const u=this.createAttribute(a,c);s.push(u)}}t.push(s)}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 Yo({type:e});if(typeof t=="object")for(const s in t)switch(s){case"ia5String":n.value.ia5String=t[s];break;case"utf8String":n.value.utf8String=t[s];break;case"universalString":n.value.universalString=t[s];break;case"bmpString":n.value.bmpString=t[s];break;case"printableString":n.value.printableString=t[s];break}else if(t[0]==="#")n.value.anyValue=re.FromHex(t.slice(1));else{const s=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=s:Wt.isPrintableString(s)?n.value.printableString=s:n.value.utf8String=s}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
115
+ `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return U.serialize(this.asn)}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||mt.get()):n=e[0]||mt.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const Hy="Cannot initialize GeneralName from ASN.1 data.",Fy=`${Hy} Unsupported string format in use.`,fw=`${Hy} Value doesn't match to GUID regular expression.`,Wy=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Ky="1.3.6.1.4.1.311.25.1",zy="1.3.6.1.4.1.311.20.2.3",Xd="dns",Qd="dn",ef="email",tf="ip",rf="url",nf="guid",sf="upn",ru="id";class xn extends vn{constructor(...e){let t;if(e.length===2)switch(e[0]){case Qd:{const n=new Wt(e[1]).toArrayBuffer(),s=U.parse(n,et);t=new ge({directoryName:s});break}case Xd:t=new ge({dNSName:e[1]});break;case ef:t=new ge({rfc822Name:e[1]});break;case nf:{const n=new RegExp(Wy,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const s=n.slice(1).map((i,a)=>a<3?re.ToHex(new Uint8Array(re.FromHex(i)).reverse()):i).join("");t=new ge({otherName:new ia({typeId:Ky,value:U.serialize(new Re(re.FromHex(s)))})});break}case tf:t=new ge({iPAddress:e[1]});break;case ru:t=new ge({registeredID:e[1]});break;case sf:{t=new ge({otherName:new ia({typeId:zy,value:U.serialize(Wp.toASN(e[1]))})});break}case rf:t=new ge({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else q.isBufferSource(e[0])?t=U.parse(e[0],ge):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=Xd,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=ef,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=tf,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=rf,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=ru,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Qd,this.value=new Wt(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Ky){this.type=nf;const t=U.parse(e.otherName.value,Re),n=new RegExp(Wy,"i").exec(re.ToHex(t));if(!n)throw new Error(fw);this.value=n.slice(1).map((s,i)=>i<3?re.ToHex(new Uint8Array(re.FromHex(s)).reverse()):s).join("-")}else if(e.otherName.typeId===zy)this.type=sf,this.value=U.parse(e.otherName.value,ft).toString();else throw new Error(Fy);else throw new Error(Fy)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Qd:case Xd:case nf:case tf:case ru:case sf:case rf:e=this.type.toUpperCase();break;case ef:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===ru&&(t=gn.toString(t)),new De(e,void 0,t)}}class Ia extends vn{constructor(e){let t;if(e instanceof kt)t=e;else if(Array.isArray(e)){const n=[];for(const s of e)if(s instanceof ge)n.push(s);else{const i=U.parse(new xn(s.type,s.value).rawData,ge);n.push(i)}t=new kt(n)}else if(q.isBufferSource(e))t=U.parse(e,kt);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let s=null;try{s=new xn(n)}catch{continue}t.push(s)}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 s=e[n[De.NAME]];Array.isArray(s)||(s=[],e[n[De.NAME]]=s),s.push(n)}return e}}Ia.NAME="GeneralNames";const ja="-{5}",Ta="\\n",hw=`[^${Ta}]+`,pw=`${ja}BEGIN (${hw}(?=${ja}))${ja}`,mw=`${ja}END \\1${ja}`,zs="\\n",yw=`[^:${Ta}]+`,gw=`(?:[^${Ta}]+${zs}(?: +[^${Ta}]+${zs})*)`,vw=`(?:[a-zA-Z0-9=+/]+${zs})+`,Gy=`${pw}${zs}(?:((?:${yw}: ${gw})+))?${zs}?(${vw})${mw}`;class Dt{static isPem(e){return typeof e=="string"&&new RegExp(Gy,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Gy,"g"),n=[];let s=null;for(;s=t.exec(e);){const i=s[3].replace(new RegExp(`[${Ta}]+`,"g"),""),a={type:s[1],headers:[],rawData:re.FromBase64(i)},o=s[2];if(o){const c=o.split(new RegExp(zs,"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(s=>{if(!q.isBufferSource(s))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(s)}))}):e.forEach(s=>{if(!("type"in s))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(s))}),n.join(`
116
+ `)}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(),s=[];if(s.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const u of e.headers)s.push(`${u.key}: ${u.value}`);s.push("")}const i=re.ToBase64(e.rawData);let a,o=0;const c=Array();for(;o<i.length&&(i.length-o<64?a=i.substring(o):(a=i.substring(o,o+64),o+=64),a.length!==0);)if(c.push(a),a.length<64)break;return s.push(...c),s.push(`-----END ${n}-----`),s.join(`
117
+ `)}}Dt.CertificateTag="CERTIFICATE",Dt.CrlTag="CRL",Dt.CertificateRequestTag="CERTIFICATE REQUEST",Dt.PublicKeyTag="PUBLIC KEY",Dt.PrivateKeyTag="PRIVATE KEY";class Fr extends vn{static isAsnEncoded(e){return q.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Dt.isPem(e))return Dt.decode(e)[0];if(re.isHex(e))return re.FromHex(e);if(re.isBase64(e))return re.FromBase64(e);if(re.isBase64Url(e))return re.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=re.ToBinary(e);return Dt.isPem(t)?Dt.decode(t)[0]:re.isHex(t)?re.FromHex(t):re.isBase64(t)?re.FromBase64(t):re.isBase64Url(t)?re.FromBase64Url(t):q.toArrayBuffer(e)}}constructor(...e){Fr.isAsnEncoded(e[0])?super(Fr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Dt.encode(this.rawData,this.tag);default:return super.toString(e)}}}class or extends Fr{static async create(e,t=mt.get()){if(e instanceof or)return e;if(bn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new or(n)}else{if(e.publicKey)return e.publicKey;if(q.isBufferSource(e))return new or(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Fr.isAsnEncoded(e)?super(e,ir):super(e),this.tag=Dt.PublicKeyTag}async export(...e){let t,n=["verify"],s={hash:"SHA-256",...this.algorithm};e.length>1?(s=e[0]||s,n=e[1]||n,t=e[2]||mt.get()):t=e[0]||mt.get();let i=this.rawData;const a=U.parse(this.rawData,ir);return a.algorithm.algorithm===ka&&(i=bw(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=pt.resolve(Xn),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case zn:{const s=U.parse(e.subjectPublicKey,Cd),i=q.toUint8Array(s.modulus);n.publicExponent=q.toUint8Array(s.publicExponent),n.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||mt.get()):n=e[0]||mt.get(),await n.subtle.digest(s,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=mt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=mt.get();const s=U.parse(this.rawData,ir);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=U.parse(this.rawData,ir);switch(e.Algorithm=Qn.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case xa:e["EC Point"]=t.subjectPublicKey;break;case zn:default:e["Raw Data"]=t.subjectPublicKey}return e}}function bw(r,e){return r.algorithm=new Y({algorithm:zn,parameters:null}),e=U.serialize(r),e}class Na extends Ft{static async create(e,t=!1,n=mt.get()){if("name"in e&&"serialNumber"in e)return new Na(e,t);const i=await(await or.create(e,n)).getKeyIdentifier(n);return new Na(re.ToHex(i),t)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Un({keyIdentifier:new Sl(re.FromHex(e[0]))});super(kl,e[1],U.serialize(t))}else{const t=e[0],n=t.name instanceof Ia?U.parse(t.name.rawData,kt):t.name,s=new Un({authorityCertIssuer:n,authorityCertSerialNumber:re.FromHex(t.serialNumber)});super(kl,e[1],U.serialize(s))}}onInit(e){super.onInit(e);const t=U.parse(e.extnValue,Un);t.keyIdentifier&&(this.keyId=re.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?re.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=U.parse(this.value,Un);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Ia(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Na.NAME="Authority Key Identifier";class af extends Ft{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=U.parse(this.value,Qo);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new Qo({cA:e[0],pathLenConstraint:e[1]});super(rm,e[2],U.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}}af.NAME="Basic Constraints";var Jy;(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"})(Jy||(Jy={}));class of extends Ft{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=U.parse(this.value,sc);this.usages=t.map(n=>n)}else{const t=new sc(e[0]);super(cm,e[1],U.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>gn.toString(t)).join(", "),e}}of.NAME="Extended Key Usages";var nu;(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"})(nu||(nu={}));class cf extends Ft{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=U.parse(this.value,Ml);this.usages=t.toNumber()}else{const t=new Ml(e[0]);super(lm,e[1],U.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=U.parse(this.value,Ml);return e[""]=t.toJSON().join(", "),e}}cf.NAME="Key Usages";class Ba extends Ft{static async create(e,t=!1,n=mt.get()){const i=await(await or.create(e,n)).getKeyIdentifier(n);return new Ba(re.ToHex(i),t)}constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=U.parse(this.value,hn);this.keyId=re.ToHex(t)}else{const t=typeof e[0]=="string"?re.FromHex(e[0]):e[0],n=new hn(t);super(ym,e[1],U.serialize(n)),this.keyId=re.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=U.parse(this.value,hn);return e[""]=t,e}}Ba.NAME="Subject Key Identifier";class Yy extends Ft{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(pm,e[1],new Ia(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=U.parse(e.extnValue,Hl);this.names=new Ia(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}Yy.NAME="Subject Alternative Name";class Kt{static register(e,t){this.items.set(e,t)}static create(e){const t=new Ft(e),n=this.items.get(t.type);return n?new n(e):t}}Kt.items=new Map;class Xy extends Ft{constructor(...e){var t;if(q.isBufferSource(e[0])){super(e[0]);const n=U.parse(this.value,rc);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new rc(n.map(a=>new tc({policyIdentifier:a})));super(sm,s,U.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new De("",{},gn.toString(t))),e}}Xy.NAME="Certificate Policies",Kt.register(sm,Xy);class Qy extends Ft{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const s=e[0].map(a=>new Ns({distributionPoint:new Ln({fullName:[new ge({uniformResourceIdentifier:a})]})})),i=new Bs(s);super(Nl,e[1],U.serialize(i))}else{const n=new Bs(e[0]);super(Nl,e[1],U.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=U.parse(e.extnValue,Bs);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const s={};return t.distributionPoint&&(s[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(i=>new xn(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}Qy.NAME="CRL Distribution Points";class eg extends Ft{constructor(...e){var t,n,s,i;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Ts){const a=new Ts(e[0]);super(wl,e[1],U.serialize(a))}else{const a=e[0],o=new Ts;iu(o,a,Xp,"ocsp"),iu(o,a,Qp,"caIssuers"),iu(o,a,em,"timeStamping"),iu(o,a,tm,"caRepository"),super(wl,e[1],U.serialize(o))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(s=this.timeStamping)!==null&&s!==void 0||(this.timeStamping=[]),(i=this.caRepository)!==null&&i!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],U.parse(e.extnValue,Ts).forEach(n=>{switch(n.accessMethod){case Xp:this.ocsp.push(new xn(n.accessLocation));break;case Qp:this.caIssuers.push(new xn(n.accessLocation));break;case em:this.timeStamping.push(new xn(n.accessLocation));break;case tm:this.caRepository.push(new xn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&su(e,"OCSP",this.ocsp),this.caIssuers.length&&su(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&su(e,"Time Stamping",this.timeStamping),this.caRepository.length&&su(e,"CA Repository",this.caRepository),e}}eg.NAME="Authority Info Access";function su(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new De("");t.forEach((s,i)=>{const a=s.toTextObject(),o=`${a[De.NAME]} ${i+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function iu(r,e,t,n){const s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new xn("url",a)),r.push(new aa({accessMethod:t,accessLocation:U.parse(a.rawData,ge)}))})}class Gs extends vn{constructor(...e){let t;if(q.isBufferSource(e[0]))t=q.toArrayBuffer(e[0]);else{const n=e[0],s=Array.isArray(e[1])?e[1].map(i=>q.toArrayBuffer(i)):[];t=U.serialize(new Ur({type:n,values:s}))}super(t,Ur)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new De("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[De.NAME]===Gs.NAME&&(e[De.NAME]=gn.toString(this.type)),e}}Gs.NAME="Attribute";class tg extends Gs{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=new Qc({printableString:e[0]});super(Xm,[U.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=U.parse(this.values[0],Qc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[De.VALUE]=this.password,e}}tg.NAME="Challenge Password";class uf extends Gs{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new pn;for(const i of n)s.push(U.parse(i.rawData,Ht));super(qd,[U.serialize(s)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=U.parse(this.values[0],pn);this.items=t.map(n=>Kt.create(U.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[De.NAME]]=n;return e}}uf.NAME="Extensions";class au{static register(e,t){this.items.set(e,t)}static create(e){const t=new Gs(e),n=this.items.get(t.type);return n?new n(e):t}}au.items=new Map;const Ra="crypto.signatureFormatter";class xw{toAsnSignature(e,t){return q.toArrayBuffer(t)}toWebSignature(e,t){return q.toArrayBuffer(t)}}var ou;let lf=ou=class{static createPssParams(e,t){const n=ou.getHashAlgorithm(e);return n?new Jn({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:Dc,parameters:U.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=pt.resolve(Xn);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:Tc,parameters:null});case"sha-256":return new Y({algorithm:Ad,parameters:null});case"sha-384":return new Y({algorithm:Nc,parameters:null});case"sha-512":return new Y({algorithm:Bc,parameters:null})}}else return new Y({algorithm:zn,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=ou.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new Y({algorithm:ka,parameters:U.serialize(t)})}else return new Y({algorithm:ka,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case zn:return{name:"RSASSA-PKCS1-v1_5"};case Tc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Ad:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Nc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Bc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case ka:if(e.parameters){const t=U.parse(e.parameters,Jn);return{name:"RSA-PSS",hash:pt.resolve(Xn).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};lf=ou=l([Wc()],lf),pt.registerSingleton(Ea,lf);let df=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:Rc});case"sha-256":return new Y({algorithm:Pc});case"sha-384":return new Y({algorithm:$c});case"sha-512":return new Y({algorithm:Zc})}return null}toWebAlgorithm(e){switch(e.algorithm){case Rc:return{name:"SHA-1"};case Pc:return{name:"SHA-256"};case $c:return{name:"SHA-384"};case Zc:return{name:"SHA-512"}}return null}};df=l([Wc()],df),pt.registerSingleton(Ea,df);class zt{addPadding(e,t){const n=q.toUint8Array(t),s=new Uint8Array(e);return s.set(n,e-n.length),s}removePadding(e,t=!1){let n=q.toUint8Array(e);for(let s=0;s<n.length;s++)if(n[s]){n=n.slice(s);break}if(t&&n[0]>127){const s=new Uint8Array(n.length+1);return s.set(n,1),s.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,s=zt.namedCurveSize.get(n)||zt.defaultNamedCurveSize,i=new jc,a=q.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),U.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=U.parse(t,jc),s=e.namedCurve,i=zt.namedCurveSize.get(s)||zt.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return Rx(a,o)}return null}}zt.namedCurveSize=new Map,zt.defaultNamedCurveSize=32;const ff="1.3.101.110",rg="1.3.101.111",hf="1.3.101.112",ng="1.3.101.113";let pf=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=hf;break;case"x25519":t=ff;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=hf;break;case"ed448":t=ng;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=ff;break;case"x448":t=rg;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case hf:return{name:"Ed25519"};case ng:return{name:"EdDSA",namedCurve:"Ed448"};case ff:return{name:"X25519"};case rg:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};pf=l([Wc()],pf),pt.registerSingleton(Ea,pf);class _w extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,Oa):super(e),this.tag=Dt.CertificateRequestTag}onInit(e){this.tbs=U.serialize(e.certificationRequestInfo),this.publicKey=new or(e.certificationRequestInfo.subjectPKInfo);const t=pt.resolve(Xn);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>au.create(U.serialize(s)));const n=this.getAttribute(qd);this.extensions=[],n instanceof uf&&(this.extensions=n.items),this.subjectName=new Wt(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=mt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),s=pt.resolveAll(Ra).reverse();let i=null;for(const o of s)if(i=o.toWebSignature(t,this.signature),i)break;if(!i)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=U.parse(this.rawData,Oa),n=t.certificationRequestInfo,s=new De("",{Version:`${qn[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new De("");for(const a of this.attributes){const o=a.toTextObject();i[o[De.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new De("",{Algorithm:Qn.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}_w.NAME="PKCS#10 Certificate Request";class mf extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,Hn):super(e),this.tag=Dt.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=U.serialize(t),this.serialNumber=re.ToHex(t.serialNumber),this.subjectName=new Wt(t.subject),this.subject=new Wt(t.subject).toString(),this.issuerName=new Wt(t.issuer),this.issuer=this.issuerName.toString();const n=pt.resolve(Xn);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const s=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!s)throw new Error("Cannot get 'notBefore' value");this.notBefore=s;const i=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!i)throw new Error("Cannot get 'notAfter' value");this.notAfter=i,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(a=>Kt.create(U.serialize(a)))),this.publicKey=new or(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=mt.get()){let n,s;const i=e.publicKey;try{if(!i)n={...this.publicKey.algorithm,...this.signatureAlgorithm},s=await this.publicKey.export(n,["verify"],t);else if("publicKey"in i)n={...i.publicKey.algorithm,...this.signatureAlgorithm},s=await i.publicKey.export(n,["verify"],t);else if(i instanceof or)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(q.isBufferSource(i)){const u=new or(i);n={...u.algorithm,...this.signatureAlgorithm},s=await u.export(n,["verify"],t)}else n={...i.algorithm,...this.signatureAlgorithm},s=i}catch{return!1}const a=pt.resolveAll(Ra).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,s,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=mt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=mt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=U.parse(this.rawData,Hn),n=t.tbsCertificate,s=new De("",{Version:`${qn[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Qn.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new De("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(s["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(s["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const i=new De("");for(const a of this.extensions){const o=a.toTextObject();i[o[De.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new De("",{Algorithm:Qn.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}mf.NAME="Certificate";class ww{static async createSelfSigned(e,t=mt.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=mt.get()){var n;let s;e.publicKey instanceof or?s=e.publicKey.rawData:"publicKey"in e.publicKey?s=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?s=e.publicKey:s=await t.subtle.exportKey("spki",e.publicKey);const i=e.serialNumber?q.toUint8Array(re.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));i[0]>127&&(i[0]&=127),i.length>1&&i[0]===0&&(i[1]|=128);const a=e.notBefore||new Date,o=e.notAfter||new Date(a.getTime()+31536e6),c=new Hn({tbsCertificate:new Zt({version:qn.v3,serialNumber:i,validity:new ua({notBefore:a,notAfter:o}),extensions:new pn(((n=e.extensions)===null||n===void 0?void 0:n.map(S=>U.parse(S.rawData,Ht)))||[]),subjectPublicKeyInfo:U.parse(s,ir)})});if(e.subject){const S=e.subject instanceof Wt?e.subject:new Wt(e.subject);c.tbsCertificate.subject=U.parse(S.toArrayBuffer(),et)}if(e.issuer){const S=e.issuer instanceof Wt?e.issuer:new Wt(e.issuer);c.tbsCertificate.issuer=U.parse(S.toArrayBuffer(),et)}const u={hash:"SHA-256"},f="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},m=pt.resolve(Xn);c.tbsCertificate.signature=c.signatureAlgorithm=m.toAsnAlgorithm(f);const B=U.serialize(c.tbsCertificate),C="signingKey"in e?await t.subtle.sign(f,e.signingKey,B):e.signature,p=pt.resolveAll(Ra).reverse();let y=null;for(const S of p)if(y=S.toAsnSignature(f,C),y)break;if(!y)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=y,new mf(U.serialize(c))}}var sg;(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"})(sg||(sg={})),Kt.register(rm,af),Kt.register(cm,of),Kt.register(lm,cf),Kt.register(ym,Ba),Kt.register(kl,Na),Kt.register(pm,Yy),Kt.register(Nl,Qy),Kt.register(wl,eg),au.register(Xm,tg),au.register(qd,uf),pt.registerSingleton(Ra,xw),pt.registerSingleton(Ra,zt),zt.namedCurveSize.set("P-256",32),zt.namedCurveSize.set("K-256",32),zt.namedCurveSize.set("P-384",48),zt.namedCurveSize.set("P-521",66);const cu=60*5;function kw(r){return new Ot().openapi(ke({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:gx}},description:"List of tenants"}}}),async t=>{const n=await t.env.data.keys.list(),s=await Promise.all(n.map(async i=>{const o=await new mf(i.cert).publicKey.export(),c=await crypto.subtle.exportKey("jwk",o);return Zh.parse({...c,kid:i.kid})}));return t.json({keys:s},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${cu}, stale-while-revalidate=${cu*2}, stale-if-error=86400`}})}).openapi(ke({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Dh}},description:"List of tenants"}}}),async t=>{const{issuer:n}=r,s=Dh.parse({issuer:n,authorization_endpoint:`${n}authorize`,token_endpoint:`${n}oauth/token`,device_authorization_endpoint:`${n}oauth/device/code`,userinfo_endpoint:`${n}userinfo`,mfa_challenge_endpoint:`${n}mfa/challenge`,jwks_uri:`${n}.well-known/jwks.json`,registration_endpoint:`${n}oidc/register`,revocation_endpoint:`${n}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(s,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${cu}, stale-while-revalidate=${cu*2}, stale-if-error=86400`}})})}async function ig(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function Sw({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}`}),s=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(s.length===0)return;const i=s.filter(c=>!c.linked_to);if(i.length>0)return i.length>1&&console.error("More than one primary user found for same email"),i[0];const a=await r.get(e,(o=s[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}function Aw(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await Sw({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)}}function ag(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:[]}}async function Ow(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 i=ag(r,{type:Ku.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,i)}}function Ew(r,e){return async(t,n)=>{const{hooks:s}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await Ow(r,s,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function Cw(r,e){return async(t,n)=>{let s=await Aw(e)(t,n);return await Ew(r,e)(t,s),s}}function Iw(r,e){return{...e,users:{...e.users,create:Cw(r,e)}}}const jw=new Ot().openapi(ke({tags:["branding"],method:"get",path:"/",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:$h}},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(ke({tags:["branding"],method:"patch",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object($h.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")});function Tw(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 og={exports:{}};const Nw=Ix(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){/**
118
118
  * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
119
119
  * Released under the Apache License, Version 2.0
120
120
  * see: https://github.com/dcodeIO/bcrypt.js for details
121
- */(function(e,t){typeof Sw=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(Eo,function(){var e={},t=null;function n(E){if(r&&r.exports)try{return Aw.randomBytes(E)}catch{}try{var O;return(self.crypto||self.msCrypto).getRandomValues(O=new Uint32Array(E)),Array.prototype.slice.call(O)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t(E)}var s=!1;try{n(1),s=!0}catch{}t=null,e.setRandomFallback=function(E){t=E},e.genSaltSync=function(E,O){if(E=E||g,typeof E!="number")throw Error("Illegal arguments: "+typeof E+", "+typeof O);E<4?E=4:E>31&&(E=31);var w=[];return w.push("$2a$"),E<10&&w.push("0"),w.push(E.toString()),w.push("$"),w.push(m(n(p),p)),w.join("")},e.genSalt=function(E,O,w){if(typeof O=="function"&&(w=O,O=void 0),typeof E=="function"&&(w=E,E=void 0),typeof E>"u")E=g;else if(typeof E!="number")throw Error("illegal arguments: "+typeof E);function b(v){a(function(){try{v(null,e.genSaltSync(E))}catch(C){v(C)}})}if(w){if(typeof w!="function")throw Error("Illegal callback: "+typeof w);b(w)}else return new Promise(function(v,C){b(function(V,Ae){if(V){C(V);return}v(Ae)})})},e.hashSync=function(E,O){if(typeof O>"u"&&(O=g),typeof O=="number"&&(O=e.genSaltSync(O)),typeof E!="string"||typeof O!="string")throw Error("Illegal arguments: "+typeof E+", "+typeof O);return Mt(E,O)},e.hash=function(E,O,w,b){function v(C){typeof E=="string"&&typeof O=="number"?e.genSalt(O,function(V,Ae){Mt(E,Ae,C,b)}):typeof E=="string"&&typeof O=="string"?Mt(E,O,C,b):a(C.bind(this,Error("Illegal arguments: "+typeof E+", "+typeof O)))}if(w){if(typeof w!="function")throw Error("Illegal callback: "+typeof w);v(w)}else return new Promise(function(C,V){v(function(Ae,ue){if(Ae){V(Ae);return}C(ue)})})};function i(E,O){for(var w=0,b=0,v=0,C=E.length;v<C;++v)E.charCodeAt(v)===O.charCodeAt(v)?++w:++b;return w<0?!1:b===0}e.compareSync=function(E,O){if(typeof E!="string"||typeof O!="string")throw Error("Illegal arguments: "+typeof E+", "+typeof O);return O.length!==60?!1:i(e.hashSync(E,O.substr(0,O.length-31)),O)},e.compare=function(E,O,w,b){function v(C){if(typeof E!="string"||typeof O!="string"){a(C.bind(this,Error("Illegal arguments: "+typeof E+", "+typeof O)));return}if(O.length!==60){a(C.bind(this,null,!1));return}e.hash(E,O.substr(0,29),function(V,Ae){V?C(V):C(null,i(Ae,O))},b)}if(w){if(typeof w!="function")throw Error("Illegal callback: "+typeof w);v(w)}else return new Promise(function(C,V){v(function(Ae,ue){if(Ae){V(Ae);return}C(ue)})})},e.getRounds=function(E){if(typeof E!="string")throw Error("Illegal arguments: "+typeof E);return parseInt(E.split("$")[2],10)},e.getSalt=function(E){if(typeof E!="string")throw Error("Illegal arguments: "+typeof E);if(E.length!==60)throw Error("Illegal hash length: "+E.length+" != 60");return E.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function o(E){var O=[],w=0;return j.encodeUTF16toUTF8(function(){return w>=E.length?null:E.charCodeAt(w++)},function(b){O.push(b)}),O}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(E,O){var w=0,b=[],v,C;if(O<=0||O>E.length)throw Error("Illegal len: "+O);for(;w<O;){if(v=E[w++]&255,b.push(c[v>>2&63]),v=(v&3)<<4,w>=O){b.push(c[v&63]);break}if(C=E[w++]&255,v|=C>>4&15,b.push(c[v&63]),v=(C&15)<<2,w>=O){b.push(c[v&63]);break}C=E[w++]&255,v|=C>>6&3,b.push(c[v&63]),b.push(c[C&63])}return b.join("")}function B(E,O){var w=0,b=E.length,v=0,C=[],V,Ae,ue,Ie,Ve,ee;if(O<=0)throw Error("Illegal len: "+O);for(;w<b-1&&v<O&&(ee=E.charCodeAt(w++),V=ee<u.length?u[ee]:-1,ee=E.charCodeAt(w++),Ae=ee<u.length?u[ee]:-1,!(V==-1||Ae==-1||(Ve=V<<2>>>0,Ve|=(Ae&48)>>4,C.push(f(Ve)),++v>=O||w>=b)||(ee=E.charCodeAt(w++),ue=ee<u.length?u[ee]:-1,ue==-1)||(Ve=(Ae&15)<<4>>>0,Ve|=(ue&60)>>2,C.push(f(Ve)),++v>=O||w>=b)));)ee=E.charCodeAt(w++),Ie=ee<u.length?u[ee]:-1,Ve=(ue&3)<<6>>>0,Ve|=Ie,C.push(f(Ve)),++v;var ut=[];for(w=0;w<v;w++)ut.push(C[w].charCodeAt(0));return ut}var j=function(){var E={};return E.MAX_CODEPOINT=1114111,E.encodeUTF8=function(O,w){var b=null;for(typeof O=="number"&&(b=O,O=function(){return null});b!==null||(b=O())!==null;)b<128?w(b&127):b<2048?(w(b>>6&31|192),w(b&63|128)):b<65536?(w(b>>12&15|224),w(b>>6&63|128),w(b&63|128)):(w(b>>18&7|240),w(b>>12&63|128),w(b>>6&63|128),w(b&63|128)),b=null},E.decodeUTF8=function(O,w){for(var b,v,C,V,Ae=function(ue){ue=ue.slice(0,ue.indexOf(null));var Ie=Error(ue.toString());throw Ie.name="TruncatedError",Ie.bytes=ue,Ie};(b=O())!==null;)if(!(b&128))w(b);else if((b&224)===192)(v=O())===null&&Ae([b,v]),w((b&31)<<6|v&63);else if((b&240)===224)((v=O())===null||(C=O())===null)&&Ae([b,v,C]),w((b&15)<<12|(v&63)<<6|C&63);else if((b&248)===240)((v=O())===null||(C=O())===null||(V=O())===null)&&Ae([b,v,C,V]),w((b&7)<<18|(v&63)<<12|(C&63)<<6|V&63);else throw RangeError("Illegal starting byte: "+b)},E.UTF16toUTF8=function(O,w){for(var b,v=null;(b=v!==null?v:O())!==null;){if(b>=55296&&b<=57343&&(v=O())!==null&&v>=56320&&v<=57343){w((b-55296)*1024+v-56320+65536),v=null;continue}w(b)}v!==null&&w(v)},E.UTF8toUTF16=function(O,w){var b=null;for(typeof O=="number"&&(b=O,O=function(){return null});b!==null||(b=O())!==null;)b<=65535?w(b):(b-=65536,w((b>>10)+55296),w(b%1024+56320)),b=null},E.encodeUTF16toUTF8=function(O,w){E.UTF16toUTF8(O,function(b){E.encodeUTF8(b,w)})},E.decodeUTF8toUTF16=function(O,w){E.decodeUTF8(O,function(b){E.UTF8toUTF16(b,w)})},E.calculateCodePoint=function(O){return O<128?1:O<2048?2:O<65536?3:4},E.calculateUTF8=function(O){for(var w,b=0;(w=O())!==null;)b+=E.calculateCodePoint(w);return b},E.calculateUTF16asUTF8=function(O){var w=0,b=0;return E.UTF16toUTF8(O,function(v){++w,b+=E.calculateCodePoint(v)}),[w,b]},E}();Date.now=Date.now||function(){return+new Date};var p=16,g=10,A=16,S=100,R=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],T=[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],ve=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Ue(E,O,w,b){var v,C=E[O],V=E[O+1];return C^=w[0],v=b[C>>>24],v+=b[256|C>>16&255],v^=b[512|C>>8&255],v+=b[768|C&255],V^=v^w[1],v=b[V>>>24],v+=b[256|V>>16&255],v^=b[512|V>>8&255],v+=b[768|V&255],C^=v^w[2],v=b[C>>>24],v+=b[256|C>>16&255],v^=b[512|C>>8&255],v+=b[768|C&255],V^=v^w[3],v=b[V>>>24],v+=b[256|V>>16&255],v^=b[512|V>>8&255],v+=b[768|V&255],C^=v^w[4],v=b[C>>>24],v+=b[256|C>>16&255],v^=b[512|C>>8&255],v+=b[768|C&255],V^=v^w[5],v=b[V>>>24],v+=b[256|V>>16&255],v^=b[512|V>>8&255],v+=b[768|V&255],C^=v^w[6],v=b[C>>>24],v+=b[256|C>>16&255],v^=b[512|C>>8&255],v+=b[768|C&255],V^=v^w[7],v=b[V>>>24],v+=b[256|V>>16&255],v^=b[512|V>>8&255],v+=b[768|V&255],C^=v^w[8],v=b[C>>>24],v+=b[256|C>>16&255],v^=b[512|C>>8&255],v+=b[768|C&255],V^=v^w[9],v=b[V>>>24],v+=b[256|V>>16&255],v^=b[512|V>>8&255],v+=b[768|V&255],C^=v^w[10],v=b[C>>>24],v+=b[256|C>>16&255],v^=b[512|C>>8&255],v+=b[768|C&255],V^=v^w[11],v=b[V>>>24],v+=b[256|V>>16&255],v^=b[512|V>>8&255],v+=b[768|V&255],C^=v^w[12],v=b[C>>>24],v+=b[256|C>>16&255],v^=b[512|C>>8&255],v+=b[768|C&255],V^=v^w[13],v=b[V>>>24],v+=b[256|V>>16&255],v^=b[512|V>>8&255],v+=b[768|V&255],C^=v^w[14],v=b[C>>>24],v+=b[256|C>>16&255],v^=b[512|C>>8&255],v+=b[768|C&255],V^=v^w[15],v=b[V>>>24],v+=b[256|V>>16&255],v^=b[512|V>>8&255],v+=b[768|V&255],C^=v^w[16],E[O]=V^w[A+1],E[O+1]=C,E}function qe(E,O){for(var w=0,b=0;w<4;++w)b=b<<8|E[O]&255,O=(O+1)%E.length;return{key:b,offp:O}}function $e(E,O,w){for(var b=0,v=[0,0],C=O.length,V=w.length,Ae,ue=0;ue<C;ue++)Ae=qe(E,b),b=Ae.offp,O[ue]=O[ue]^Ae.key;for(ue=0;ue<C;ue+=2)v=Ue(v,0,O,w),O[ue]=v[0],O[ue+1]=v[1];for(ue=0;ue<V;ue+=2)v=Ue(v,0,O,w),w[ue]=v[0],w[ue+1]=v[1]}function rt(E,O,w,b){for(var v=0,C=[0,0],V=w.length,Ae=b.length,ue,Ie=0;Ie<V;Ie++)ue=qe(O,v),v=ue.offp,w[Ie]=w[Ie]^ue.key;for(v=0,Ie=0;Ie<V;Ie+=2)ue=qe(E,v),v=ue.offp,C[0]^=ue.key,ue=qe(E,v),v=ue.offp,C[1]^=ue.key,C=Ue(C,0,w,b),w[Ie]=C[0],w[Ie+1]=C[1];for(Ie=0;Ie<Ae;Ie+=2)ue=qe(E,v),v=ue.offp,C[0]^=ue.key,ue=qe(E,v),v=ue.offp,C[1]^=ue.key,C=Ue(C,0,w,b),b[Ie]=C[0],b[Ie+1]=C[1]}function gt(E,O,w,b,v){var C=ve.slice(),V=C.length,Ae;if(w<4||w>31)if(Ae=Error("Illegal number of rounds (4-31): "+w),b){a(b.bind(this,Ae));return}else throw Ae;if(O.length!==p)if(Ae=Error("Illegal salt length: "+O.length+" != "+p),b){a(b.bind(this,Ae));return}else throw Ae;w=1<<w>>>0;var ue,Ie,Ve=0,ee;Int32Array?(ue=new Int32Array(R),Ie=new Int32Array(T)):(ue=R.slice(),Ie=T.slice()),rt(O,E,ue,Ie);function ut(){if(v&&v(Ve/w),Ve<w)for(var Fe=Date.now();Ve<w&&(Ve=Ve+1,$e(E,ue,Ie),$e(O,ue,Ie),!(Date.now()-Fe>S)););else{for(Ve=0;Ve<64;Ve++)for(ee=0;ee<V>>1;ee++)Ue(C,ee<<1,ue,Ie);var nt=[];for(Ve=0;Ve<V;Ve++)nt.push((C[Ve]>>24&255)>>>0),nt.push((C[Ve]>>16&255)>>>0),nt.push((C[Ve]>>8&255)>>>0),nt.push((C[Ve]&255)>>>0);if(b){b(null,nt);return}else return nt}b&&a(ut)}if(typeof b<"u")ut();else for(var rs;;)if(typeof(rs=ut())<"u")return rs||[]}function Mt(E,O,w,b){var v;if(typeof E!="string"||typeof O!="string")if(v=Error("Invalid string / salt: Not a string"),w){a(w.bind(this,v));return}else throw v;var C,V;if(O.charAt(0)!=="$"||O.charAt(1)!=="2")if(v=Error("Invalid salt version: "+O.substring(0,2)),w){a(w.bind(this,v));return}else throw v;if(O.charAt(2)==="$")C="\0",V=3;else{if(C=O.charAt(2),C!=="a"&&C!=="b"&&C!=="y"||O.charAt(3)!=="$")if(v=Error("Invalid salt revision: "+O.substring(2,4)),w){a(w.bind(this,v));return}else throw v;V=4}if(O.charAt(V+2)>"$")if(v=Error("Missing salt rounds"),w){a(w.bind(this,v));return}else throw v;var Ae=parseInt(O.substring(V,V+1),10)*10,ue=parseInt(O.substring(V+1,V+2),10),Ie=Ae+ue,Ve=O.substring(V+3,V+25);E+=C>="a"?"\0":"";var ee=o(E),ut=B(Ve,p);function rs(Fe){var nt=[];return nt.push("$2"),C>="a"&&nt.push(C),nt.push("$"),Ie<10&&nt.push("0"),nt.push(Ie.toString()),nt.push("$"),nt.push(m(ut,ut.length)),nt.push(m(Fe,ve.length*4-1)),nt.join("")}if(typeof w>"u")return rs(gt(ee,ut,Ie));gt(ee,ut,Ie,function(Fe,nt){Fe?w(Fe,null):w(null,rs(nt))},b)}return e.encodeBase64=m,e.decodeBase64=B,e})})(sg);var Ow=sg.exports;const Ew=wx(Ow),Cw="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Iw=r=>crypto.getRandomValues(new Uint8Array(r)),jw=(r,e,t)=>{let n=(2<<Math.log2(r.length-1))-1,s=-~(1.6*n*e/r.length);return(i=e)=>{let a="";for(;;){let o=t(s),c=s;for(;c--;)if(a+=r[o[c]&n]||"",a.length===i)return a}}},Tw=(r,e=21)=>jw(r,e,Iw),ig=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Cw[t[r]&63];return e};const Nw=24;function Bw(){return Tw("0123456789abcdef",Nw)()}function ag(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}const Yn=x.object({page:x.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:x.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:x.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:x.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:x.string().optional().openapi({description:"A lucene query string used to filter the results"})});function Js(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}var Rw={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},Pw=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[s,i]of Object.entries(Rw))if($w(i))return s}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"},$w=r=>navigator.userAgent.startsWith(r);function Zw(r,e){Pw()==="workerd"&&r.executionCtx.waitUntil(e)}const og=Nn.extend({users:x.array(Br)}),Dw=Nn.extend({sessions:x.array(Nh)}),Mw=new Bt().openapi(Oe({tags:["users"],method:"get",path:"/",request:{query:Yn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(Br),og])}},description:"List of users"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header");if(i!=null&&i.includes("identities.profileData.email")){const f=i.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),[j]=B;if(!j)return r.json([]);const p=await r.env.data.users.get(a,j.linked_to);if(!p)throw new De(500,{message:"Primary account not found"});return r.json([Br.parse(p)])}const o=["-_exists_:linked_to"];i&&o.push(i);const c=await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,sort:Js(s),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(og.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(x.array(Br).parse(u))}).openapi(Oe({tags:["users"],method:"get",path:"/{user_id}",request:{headers:x.object({"tenant-id":x.string()}),params:x.object({user_id:x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Br}},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 De(404);if(n.linked_to)throw new De(404,{message:"User is linked to another user"});return r.json(n)}).openapi(Oe({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:x.object({"tenant-id":x.string()}),params:x.object({user_id:x.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 De(404);return r.text("OK")}).openapi(Oe({tags:["users"],method:"post",path:"/",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object({...Uu.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Br}},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 De(400,{message:"Email is required"});const s=n.toLowerCase(),i=`${t.provider}|${t.user_id||Bw()}`;try{const a=await r.env.data.users.create(e,{email:s,user_id:i,name:t.name||s,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=ng(r,{type:Wu.SUCCESS_API_OPERATION,description:"User created"});Zw(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:ag(a.user_id),isSocial:a.is_social}]};return r.json(Br.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new De(409,{message:"User already exists"}):a}}).openapi(Oe({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object({...Uu.shape,verify_email:x.boolean(),password:x.string()}).partial()}}},params:x.object({user_id:x.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:s,password:i,...a}=t,o=await r.env.data.users.get(e,n);if(!o)throw new De(404);if(a.email&&a.email!==o.email){const f=await rg(r.env.data.users,e,a.email);if(f.length&&f.some(m=>m.user_id!==n))throw new De(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new De(404,{message:"User is linked to another user"});if(await r.env.data.users.update(e,n,a),i){const f=(u=o.identities)==null?void 0:u.find(m=>m.connection==="Username-Password-Authentication");if(!f)throw new De(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${f.provider}|${f.user_id}`,password:Ew.hashSync(i,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new De(500);return r.json(c)}).openapi(Oe({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.union([x.object({link_with:x.string()}),x.object({user_id:x.string(),provider:x.string(),connection:x.string().optional()})])}}},params:x.object({user_id:x.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:x.array(x.object({connection:x.string(),provider:x.string(),user_id:x.string(),isSocial:x.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"),s="link_with"in t?t.link_with:t.user_id,i=await r.env.data.users.get(e,n);if(!i)throw new De(400,{message:"Linking an inexistent identity is not allowed."});await r.env.data.users.update(e,s,{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=[i,...a.users].map(c=>({connection:c.connection,provider:c.provider,user_id:ag(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(Oe({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:x.object({"tenant-id":x.string()}),params:x.object({user_id:x.string(),provider:x.string(),linked_user_id:x.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:x.array(Br)}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{user_id:t,provider:n,linked_user_id:s}=r.req.valid("param");await r.env.data.users.unlink(e,t,n,s);const i=await r.env.data.users.get(e,t);if(!i)throw new De(404);return r.json([Br.parse(i)])}).openapi(Oe({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:Yn,headers:x.object({"tenant-id":x.string()}),params:x.object({user_id:x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(Nh),Dw])}},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"),s=await r.env.data.sessions.list(n,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return t?r.json(s):r.json(s.sessions)}),Vw=new Bt().openapi(Oe({tags:["users"],method:"get",path:"/",request:{query:x.object({email:x.string()}),headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:x.array(Ah)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),s=(await rg(r.env.data.users,e,t)).filter(i=>!i.linked_to);return r.json(s)}),Uw=Nn.extend({clients:x.array(bs)}),Lw=new Bt().openapi(Oe({tags:["clients"],method:"get",path:"/",request:{query:Yn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([Uw,x.array(bs)])}},description:"List of clients"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s,sort:i,q:a}=r.req.valid("query"),c=(await r.env.data.applications.list(e,{page:t,per_page:n,include_totals:s,sort:Js(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(Oe({tags:["clients"],method:"get",path:"/{id}",request:{params:x.object({id:x.string()}),headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:bs}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(i=>i.id===t);if(!s)throw new De(404);return r.json(s)}).openapi(Oe({tags:["clients"],method:"delete",path:"/{id}",request:{params:x.object({id:x.string()}),headers:x.object({"tenant-id":x.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 De(404,{message:"Application not found"});return r.text("OK")}).openapi(Oe({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:x.object(Lu.shape).partial()}}},params:x.object({id:x.string()}),headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:bs}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=r.req.valid("json");await r.env.data.applications.update(e,t,s);const i=await r.env.data.applications.get(e,t);if(!i)throw new De(404,{message:"Application not found"});return r.json(i)}).openapi(Oe({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:x.object(Lu.shape)}}},headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:x.object(bs.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||ig(),client_secret:t.client_secret||ig()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var Pe;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Pe||(Pe={}));var df;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(df||(df={}));const Y=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xn=r=>{switch(typeof r){case"undefined":return Y.undefined;case"string":return Y.string;case"number":return isNaN(r)?Y.nan:Y.number;case"boolean":return Y.boolean;case"function":return Y.function;case"bigint":return Y.bigint;case"symbol":return Y.symbol;case"object":return Array.isArray(r)?Y.array:r===null?Y.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?Y.promise:typeof Map<"u"&&r instanceof Map?Y.map:typeof Set<"u"&&r instanceof Set?Y.set:typeof Date<"u"&&r instanceof Date?Y.date:Y.object;default:return Y.unknown}},M=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"]),qw=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(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(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 s(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 s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const Ys=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===Y.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.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}"`:Pe.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,Pe.assertNever(r)}return{message:t}};let cg=Ys;function Hw(r){cg=r}function cu(){return cg}const uu=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.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{...s,path:i,message:o}},Fw=[];function W(r,e){const t=cu(),n=uu({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ys?void 0:Ys].filter(s=>!!s)});r.common.issues.push(n)}class yt{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 s of t){if(s.status==="aborted")return me;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return me;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Xs=r=>({status:"dirty",value:r}),St=r=>({status:"valid",value:r}),ff=r=>r.status==="aborted",hf=r=>r.status==="dirty",Na=r=>r.status==="valid",Ba=r=>typeof Promise<"u"&&r instanceof Promise;function lu(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 ug(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!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}typeof SuppressedError=="function"&&SuppressedError;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 Ra,Pa;class Ar{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const lg=(r,e)=>{if(Na(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 _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=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:s}:{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:s}}class Se{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 xn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:xn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new yt,ctx:{common:e.parent.common,data:e.data,parsedType:xn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ba(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 s={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:xn(e)},i=this._parseSync({data:e,path:s.path,parent:s});return lg(s,i)}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:xn(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ba(s)?s:Promise.resolve(s));return lg(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:M.custom,...n(s)});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,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new or({schema:this,typeName:he.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Er.create(this,this._def)}nullable(){return Sn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ar.create(this,this._def)}promise(){return ri.create(this,this._def)}or(e){return Ma.create([this,e],this._def)}and(e){return Va.create(this,e,this._def)}transform(e){return new or({..._e(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Fa({..._e(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new yf({typeName:he.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Wa({..._e(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 za.create(this,e)}readonly(){return Ka.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ww=/^c[^\s-]{8,}$/i,zw=/^[0-9a-z]+$/,Kw=/^[0-9A-HJKMNP-TV-Z]{26}$/,Gw=/^[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,Jw=/^[a-z0-9_-]{21}$/i,Yw=/^[-+]?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)?)??$/,Xw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Qw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pf;const e1=/^(?:(?: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])$/,t1=/^(([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})))$/,r1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dg="((\\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])))",n1=new RegExp(`^${dg}$`);function fg(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 s1(r){return new RegExp(`^${fg(r)}$`)}function hg(r){let e=`${dg}T${fg(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 i1(r,e){return!!((e==="v4"||!e)&&e1.test(r)||(e==="v6"||!e)&&t1.test(r))}class ir extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Y.string){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:Y.string,received:i.parsedType}),me}const n=new yt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Xw.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")pf||(pf=new RegExp(Qw,"u")),pf.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Gw.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Jw.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Ww.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")zw.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Kw.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:M.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"regex",code:M.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.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)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?hg(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?n1.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?s1(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Yw.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?i1(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?r1.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new ir({...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 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:he.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function a1(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class _n extends Se{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)!==Y.number){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:Y.number,received:i.parsedType}),me}let n;const s=new yt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?a1(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_finite,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.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,s){return new _n({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new _n({...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"&&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)}}_n.create=r=>new _n({checks:[],typeName:he.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class wn extends Se{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)!==Y.bigint){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:Y.bigint,received:i.parsedType}),me}let n;const s=new yt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.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,s){return new wn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new wn({...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}}wn.create=r=>{var e;return new wn({checks:[],typeName:he.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};class $a extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Y.boolean){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:Y.boolean,received:n.parsedType}),me}return St(e.data)}}$a.create=r=>new $a({typeName:he.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class Xn extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Y.date){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:Y.date,received:i.parsedType}),me}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_date}),me}const n=new yt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xn({...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}}Xn.create=r=>new Xn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,..._e(r)});class du extends Se{_parse(e){if(this._getType(e)!==Y.symbol){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:Y.symbol,received:n.parsedType}),me}return St(e.data)}}du.create=r=>new du({typeName:he.ZodSymbol,..._e(r)});class Za extends Se{_parse(e){if(this._getType(e)!==Y.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:Y.undefined,received:n.parsedType}),me}return St(e.data)}}Za.create=r=>new Za({typeName:he.ZodUndefined,..._e(r)});class Da extends Se{_parse(e){if(this._getType(e)!==Y.null){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:Y.null,received:n.parsedType}),me}return St(e.data)}}Da.create=r=>new Da({typeName:he.ZodNull,..._e(r)});class Qs extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return St(e.data)}}Qs.create=r=>new Qs({typeName:he.ZodAny,..._e(r)});class Qn extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return St(e.data)}}Qn.create=r=>new Qn({typeName:he.ZodUnknown,..._e(r)});class Fr extends Se{_parse(e){const t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:Y.never,received:t.parsedType}),me}}Fr.create=r=>new Fr({typeName:he.ZodNever,..._e(r)});class fu extends Se{_parse(e){if(this._getType(e)!==Y.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:Y.void,received:n.parsedType}),me}return St(e.data)}}fu.create=r=>new fu({typeName:he.ZodVoid,..._e(r)});class ar extends Se{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==Y.array)return W(t,{code:M.invalid_type,expected:Y.array,received:t.parsedType}),me;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(W(t,{code:a?M.too_big:M.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(W(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(W(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>yt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ar(t,a,t.path,o)));return yt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new ar({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new ar({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new ar({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}ar.create=(r,e)=>new ar({type:r,minLength:null,maxLength:null,exactLength:null,typeName:he.ZodArray,..._e(e)});function ei(r){if(r instanceof Xe){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Er.create(ei(n))}return new Xe({...r._def,shape:()=>e})}else return r instanceof ar?new ar({...r._def,type:ei(r.element)}):r instanceof Er?Er.create(ei(r.unwrap())):r instanceof Sn?Sn.create(ei(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>ei(e))):r}class Xe extends Se{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)!==Y.object){const u=this._getOrReturnCtx(e);return W(u,{code:M.invalid_type,expected:Y.object,received:u.parsedType}),me}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Ar(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Fr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(W(s,{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=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Ar(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.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=>yt.mergeObjectSync(n,u)):yt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Xe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,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 Xe({...this._def,unknownKeys:"strip"})}passthrough(){return new Xe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xe({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 Xe({...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 Xe({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xe({...this._def,shape:()=>t})}deepPartial(){return ei(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Xe({...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 Er;)i=i._def.innerType;t[n]=i}}),new Xe({...this._def,shape:()=>t})}keyof(){return pg(Pe.objectKeys(this.shape))}}Xe.create=(r,e)=>new Xe({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:he.ZodObject,..._e(e)}),Xe.strictCreate=(r,e)=>new Xe({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:he.ZodObject,..._e(e)}),Xe.lazycreate=(r,e)=>new Xe({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:he.ZodObject,..._e(e)});class Ma extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Dt(o.ctx.common.issues));return W(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;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"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Dt(c));return W(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Ma.create=(r,e)=>new Ma({options:r,typeName:he.ZodUnion,..._e(e)});const Wr=r=>r instanceof La?Wr(r.schema):r instanceof or?Wr(r.innerType()):r instanceof qa?[r.value]:r instanceof kn?r.options:r instanceof Ha?Pe.objectValues(r.enum):r instanceof Fa?Wr(r._def.innerType):r instanceof Za?[void 0]:r instanceof Da?[null]:r instanceof Er?[void 0,...Wr(r.unwrap())]:r instanceof Sn?[null,...Wr(r.unwrap())]:r instanceof yf||r instanceof Ka?Wr(r.unwrap()):r instanceof Wa?Wr(r._def.innerType):[];class hu extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Y.object)return W(t,{code:M.invalid_type,expected:Y.object,received:t.parsedType}),me;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(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 s=new Map;for(const i of t){const a=Wr(i.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(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new hu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._e(n)})}}function mf(r,e){const t=xn(r),n=xn(e);if(r===e)return{valid:!0,data:r};if(t===Y.object&&n===Y.object){const s=Pe.objectKeys(e),i=Pe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=mf(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===Y.array&&n===Y.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=mf(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===Y.date&&n===Y.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Va extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(ff(i)||ff(a))return me;const o=mf(i.value,a.value);return o.valid?((hf(i)||hf(a))&&t.dirty(),{status:t.value,value:o.data}):(W(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(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Va.create=(r,e,t)=>new Va({left:r,right:e,typeName:he.ZodIntersection,..._e(t)});class Or extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.array)return W(n,{code:M.invalid_type,expected:Y.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return W(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&&(W(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Ar(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>yt.mergeArray(t,a)):yt.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:he.ZodTuple,rest:null,..._e(e)})};class Ua extends Se{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!==Y.object)return W(n,{code:M.invalid_type,expected:Y.object,received:n.parsedType}),me;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._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?yt.mergeObjectAsync(t,s):yt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Se?new Ua({keyType:e,valueType:t,typeName:he.ZodRecord,..._e(n)}):new Ua({keyType:ir.create(),valueType:e,typeName:he.ZodRecord,..._e(t)})}}class pu extends Se{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!==Y.map)return W(n,{code:M.invalid_type,expected:Y.map,received:n.parsedType}),me;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ar(n,o,n.path,[u,"key"])),value:i._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 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}}}}pu.create=(r,e,t)=>new pu({valueType:e,keyType:r,typeName:he.ZodMap,..._e(t)});class es extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.set)return W(n,{code:M.invalid_type,expected:Y.set,received:n.parsedType}),me;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=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)=>i._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 es({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new es({...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)}}es.create=(r,e)=>new es({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,..._e(e)});class ti extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Y.function)return W(t,{code:M.invalid_type,expected:Y.function,received:t.parsedType}),me;function n(o,c){return uu({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cu(),Ys].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function s(o,c){return uu({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cu(),Ys].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ri){const o=this;return St(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,i).catch(j=>{throw u.addIssue(n(c,j)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(j=>{throw u.addIssue(s(m,j)),u})})}else{const o=this;return St(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Dt([s(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(Qn.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(Qn.create()),returns:t||Qn.create(),typeName:he.ZodFunction,..._e(n)})}}class La extends Se{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})}}La.create=(r,e)=>new La({getter:r,typeName:he.ZodLazy,..._e(e)});class qa extends Se{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return W(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}}qa.create=(r,e)=>new qa({value:r,typeName:he.ZodLiteral,..._e(e)});function pg(r,e){return new kn({values:r,typeName:he.ZodEnum,..._e(e)})}class kn extends Se{constructor(){super(...arguments),Ra.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:Pe.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(lu(this,Ra)||ug(this,Ra,new Set(this._def.values)),!lu(this,Ra).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:M.invalid_enum_value,options:n}),me}return St(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 kn.create(e,{...this._def,...t})}exclude(e,t=this._def){return kn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Ra=new WeakMap,kn.create=pg;class Ha extends Se{constructor(){super(...arguments),Pa.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Y.string&&n.parsedType!==Y.number){const s=Pe.objectValues(t);return W(n,{expected:Pe.joinValues(s),received:n.parsedType,code:M.invalid_type}),me}if(lu(this,Pa)||ug(this,Pa,new Set(Pe.getValidEnumValues(this._def.values))),!lu(this,Pa).has(e.data)){const s=Pe.objectValues(t);return W(n,{received:n.data,code:M.invalid_enum_value,options:s}),me}return St(e.data)}get enum(){return this._def.values}}Pa=new WeakMap,Ha.create=(r,e)=>new Ha({values:r,typeName:he.ZodNativeEnum,..._e(e)});class ri extends Se{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Y.promise&&t.common.async===!1)return W(t,{code:M.invalid_type,expected:Y.promise,received:t.parsedType}),me;const n=t.parsedType===Y.promise?t.data:Promise.resolve(t.data);return St(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ri.create=(r,e)=>new ri({type:r,typeName:he.ZodPromise,..._e(e)});class or extends Se{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),s=this._def.effect||null,i={addIssue:a=>{W(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);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"?Xs(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"?Xs(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);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(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Na(a))return a;const o=s.transform(a.value,i);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=>Na(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(s)}}or.create=(r,e,t)=>new or({schema:r,typeName:he.ZodEffects,effect:e,..._e(t)}),or.createWithPreprocess=(r,e,t)=>new or({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,..._e(t)});class Er extends Se{_parse(e){return this._getType(e)===Y.undefined?St(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Er.create=(r,e)=>new Er({innerType:r,typeName:he.ZodOptional,..._e(e)});class Sn extends Se{_parse(e){return this._getType(e)===Y.null?St(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sn.create=(r,e)=>new Sn({innerType:r,typeName:he.ZodNullable,..._e(e)});class Fa extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===Y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Fa.create=(r,e)=>new Fa({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});class Wa extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ba(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Wa.create=(r,e)=>new Wa({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});class mu extends Se{_parse(e){if(this._getType(e)!==Y.nan){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:Y.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}mu.create=r=>new mu({typeName:he.ZodNaN,..._e(r)});const o1=Symbol("zod_brand");class yf extends Se{_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 za extends Se{_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"?me:i.status==="dirty"?(t.dirty(),Xs(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new za({in:e,out:t,typeName:he.ZodPipeline})}}class Ka extends Se{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Na(s)&&(s.value=Object.freeze(s.value)),s);return Ba(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Ka.create=(r,e)=>new Ka({innerType:r,typeName:he.ZodReadonly,..._e(e)});function mg(r,e={},t){return r?Qs.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Qs.create()}const c1={object:Xe.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 u1=(r,e={message:`Input not instance of ${r.name}`})=>mg(t=>t instanceof r,e),yg=ir.create,gg=_n.create,l1=mu.create,d1=wn.create,vg=$a.create,f1=Xn.create,h1=du.create,p1=Za.create,m1=Da.create,y1=Qs.create,g1=Qn.create,v1=Fr.create,b1=fu.create,x1=ar.create,_1=Xe.create,w1=Xe.strictCreate,k1=Ma.create,S1=hu.create,A1=Va.create,O1=Or.create,E1=Ua.create,C1=pu.create,I1=es.create,j1=ti.create,T1=La.create,N1=qa.create,B1=kn.create,R1=Ha.create,P1=ri.create,bg=or.create,$1=Er.create,Z1=Sn.create,D1=or.createWithPreprocess,M1=za.create;var zt=Object.freeze({__proto__:null,defaultErrorMap:Ys,setErrorMap:Hw,getErrorMap:cu,makeIssue:uu,EMPTY_PATH:Fw,addIssueToContext:W,ParseStatus:yt,INVALID:me,DIRTY:Xs,OK:St,isAborted:ff,isDirty:hf,isValid:Na,isAsync:Ba,get util(){return Pe},get objectUtil(){return df},ZodParsedType:Y,getParsedType:xn,ZodType:Se,datetimeRegex:hg,ZodString:ir,ZodNumber:_n,ZodBigInt:wn,ZodBoolean:$a,ZodDate:Xn,ZodSymbol:du,ZodUndefined:Za,ZodNull:Da,ZodAny:Qs,ZodUnknown:Qn,ZodNever:Fr,ZodVoid:fu,ZodArray:ar,ZodObject:Xe,ZodUnion:Ma,ZodDiscriminatedUnion:hu,ZodIntersection:Va,ZodTuple:Or,ZodRecord:Ua,ZodMap:pu,ZodSet:es,ZodFunction:ti,ZodLazy:La,ZodLiteral:qa,ZodEnum:kn,ZodNativeEnum:Ha,ZodPromise:ri,ZodEffects:or,ZodTransformer:or,ZodOptional:Er,ZodNullable:Sn,ZodDefault:Fa,ZodCatch:Wa,ZodNaN:mu,BRAND:o1,ZodBranded:yf,ZodPipeline:za,ZodReadonly:Ka,custom:mg,Schema:Se,ZodSchema:Se,late:c1,get ZodFirstPartyTypeKind(){return he},coerce:{string:r=>ir.create({...r,coerce:!0}),number:r=>_n.create({...r,coerce:!0}),boolean:r=>$a.create({...r,coerce:!0}),bigint:r=>wn.create({...r,coerce:!0}),date:r=>Xn.create({...r,coerce:!0})},any:y1,array:x1,bigint:d1,boolean:vg,date:f1,discriminatedUnion:S1,effect:bg,enum:B1,function:j1,instanceof:u1,intersection:A1,lazy:T1,literal:N1,map:C1,nan:l1,nativeEnum:R1,never:v1,null:m1,nullable:Z1,number:gg,object:_1,oboolean:()=>vg().optional(),onumber:()=>gg().optional(),optional:$1,ostring:()=>yg().optional(),pipeline:M1,preprocess:D1,promise:P1,record:E1,set:I1,strictObject:w1,string:yg,symbol:h1,transformer:bg,tuple:O1,undefined:p1,union:k1,unknown:g1,void:b1,NEVER:me,ZodIssueCode:M,quotelessJson:qw,ZodError:Dt});zt.object({start:zt.number(),limit:zt.number(),length:zt.number()}),Vu.extend({email:zt.string(),login_count:zt.number(),multifactor:zt.array(zt.string()).optional(),last_ip:zt.string().optional(),last_login:zt.string().optional(),user_id:zt.string()}).catchall(zt.any());const V1=Nn.extend({tenants:x.array(Xi)}),U1=new Bt().openapi(Oe({tags:["tenants"],method:"get",path:"/",request:{query:Yn},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:x.union([x.array(Xi),V1])}},description:"List of tenants"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),a=await r.env.data.tenants.list({page:e,per_page:t,include_totals:n,sort:Js(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(Oe({tags:["tenants"],method:"get",path:"/{id}",request:{params:x.object({id:x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Xi}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new De(404);return console.log("tenant",t),r.json(t)}).openapi(Oe({tags:["tenants"],method:"delete",path:"/{id}",request:{params:x.object({id:x.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(Oe({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:x.object(Hu.shape).partial()}}},params:x.object({id:x.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(Oe({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:x.object(Hu.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Xi}},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})}),L1=Nn.extend({logs:x.array(zu)}),q1=new Bt().openapi(Oe({tags:["logs"],method:"get",path:"/",request:{query:Yn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(zu),L1])}},description:"List of log rows"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=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:Js(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(Oe({tags:["logs"],method:"get",path:"/{id}",request:{headers:x.object({"tenant-id":x.string()}),params:x.object({id:x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:zu}},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 De(404);return r.json(n)}),H1=Nn.extend({hooks:x.array(Qi)}),F1=new Bt().openapi(Oe({tags:["hooks"],method:"get",path:"/",request:{query:Yn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(Qi),H1])}},description:"List of hooks"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s,sort:i,q:a}=r.req.valid("query"),o=await r.env.data.hooks.list(e,{page:t,per_page:n,include_totals:s,sort:Js(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(Oe({tags:["hooks"],method:"post",path:"/",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object(Fu.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Qi}},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(Oe({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:x.object({"tenant-id":x.string()}),params:x.object({hook_id:x.string()}),body:{content:{"application/json":{schema:x.object(Fu.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Qi.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 s=await r.env.data.hooks.get(e,t);if(!s)throw new De(404,{message:"Hook not found"});return r.json(s)}).openapi(Oe({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:x.object({"tenant-id":x.string()}),params:x.object({hook_id:x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Qi}},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 De(404,{message:"Hook not found"});return r.json(n)}).openapi(Oe({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:x.object({"tenant-id":x.string()}),params:x.object({hook_id:x.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 De(404,{message:"Hook not found"});return r.text("OK")}),W1=Nn.extend({connections:x.array(xs)}),z1=new Bt().openapi(Oe({tags:["connections"],method:"get",path:"/",request:{query:Yn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(xs),W1])}},description:"List of connectionss"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s=!1,sort:i,q:a}=r.req.valid("query"),o=await r.env.data.connections.list(e,{page:t,per_page:n,include_totals:s,sort:Js(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(Oe({tags:["connections"],method:"get",path:"/{id}",request:{params:x.object({id:x.string()}),headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:xs}},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 De(404);return r.json(n)}).openapi(Oe({tags:["connections"],method:"delete",path:"/{id}",request:{params:x.object({id:x.string()}),headers:x.object({"tenant-id":x.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 De(404,{message:"Connection not found"});return r.text("OK")}).openapi(Oe({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:x.object(qu.shape).partial()}}},params:x.object({id:x.string()}),headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:xs}},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 De(404,{message:"Connection not found"});const i=await r.env.data.connections.get(e,t);if(!i)throw new De(404,{message:"Connection not found"});return r.json(i)}).openapi(Oe({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:x.object(qu.shape)}}},headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:xs}},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})}),K1=new Bt().openapi(Oe({tags:["prompts"],method:"get",path:"/",request:{headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Gu}},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(Gu.parse({}))}).openapi(Oe({tags:["prompts"],method:"patch",path:"/",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object(Gu.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 xg=!1;function G1(r){r.use(async(e,t)=>(xg||(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"}}}}),xg=!0),await t()))}x.object({alg:x.literal("RS256"),kty:x.literal("RSA"),use:x.literal("sig"),n:x.string(),e:x.string(),kid:x.string(),x5t:x.string(),x5c:x.array(x.string())});async function J1(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 De(500,{message:"Failed to fetch jwks: "+e.message+", "+JSON.stringify(r)})}}async function Y1(r,e){const n=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),s=new Uint8Array(Array.from(e.signature).map(c=>c.charCodeAt(0))),a=(await J1(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,s,n)}function X1(r){const[e,t,n]=r.split(".");if(!e||!t||!n)return null;const s=JSON.parse(atob(e)),i=JSON.parse(atob(t)),a=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return{header:s,payload:i,signature:a,raw:{header:e,payload:t,signature:n}}}function Q1(r){return async(e,t)=>{var s,i;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=(i=(s=n.route.security)==null?void 0:s[0])==null?void 0:i.Bearer,o=e.req.header("authorization")||"",[c,u]=o.split(" ");if((c==null?void 0:c.toLowerCase())!=="bearer"||!u)throw new De(401,{message:"Missing bearer token"});const f=X1(u);if(!f||!await Y1(e,f))throw new De(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 De(403,{message:"Unauthorized"})}return await t()}}function ek(r){const e=new Bt;e.use(Q1(e)),e.use(async(n,s)=>(n.env.data=ww(n,r.dataAdapter),s()));const t=e.route("/api/v2/branding",kw).route("/api/v2/users",Mw).route("/api/v2/users-by-email",Vw).route("/api/v2/clients",Lw).route("/api/v2/tenants",U1).route("/api/v2/logs",q1).route("/api/v2/hooks",F1).route("/api/v2/connections",z1).route("/api/v2/prompts",K1);return G1(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function tk(r){const e=new Bt;e.get("/",s=>s.json({name:"authhero"}));const t=ek(r);e.route("/api/v2",t);const n=new Bt().route("/.well-known",yw(r));return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",n),{rootApp:e,managementApp:t,oauthApp:n}}return He.init=tk,Object.defineProperty(He,Symbol.toStringTag,{value:"Module"}),He}({});
121
+ */(function(e,t){typeof Tw=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(jo,function(){var e={},t=null;function n(E){if(r&&r.exports)try{return Nw.randomBytes(E)}catch{}try{var O;return(self.crypto||self.msCrypto).getRandomValues(O=new Uint32Array(E)),Array.prototype.slice.call(O)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t(E)}var s=!1;try{n(1),s=!0}catch{}t=null,e.setRandomFallback=function(E){t=E},e.genSaltSync=function(E,O){if(E=E||y,typeof E!="number")throw Error("Illegal arguments: "+typeof E+", "+typeof O);E<4?E=4:E>31&&(E=31);var w=[];return w.push("$2a$"),E<10&&w.push("0"),w.push(E.toString()),w.push("$"),w.push(m(n(p),p)),w.join("")},e.genSalt=function(E,O,w){if(typeof O=="function"&&(w=O,O=void 0),typeof E=="function"&&(w=E,E=void 0),typeof E>"u")E=y;else if(typeof E!="number")throw Error("illegal arguments: "+typeof E);function x(b){a(function(){try{b(null,e.genSaltSync(E))}catch(I){b(I)}})}if(w){if(typeof w!="function")throw Error("Illegal callback: "+typeof w);x(w)}else return new Promise(function(b,I){x(function(V,Oe){if(V){I(V);return}b(Oe)})})},e.hashSync=function(E,O){if(typeof O>"u"&&(O=y),typeof O=="number"&&(O=e.genSaltSync(O)),typeof E!="string"||typeof O!="string")throw Error("Illegal arguments: "+typeof E+", "+typeof O);return Vt(E,O)},e.hash=function(E,O,w,x){function b(I){typeof E=="string"&&typeof O=="number"?e.genSalt(O,function(V,Oe){Vt(E,Oe,I,x)}):typeof E=="string"&&typeof O=="string"?Vt(E,O,I,x):a(I.bind(this,Error("Illegal arguments: "+typeof E+", "+typeof O)))}if(w){if(typeof w!="function")throw Error("Illegal callback: "+typeof w);b(w)}else return new Promise(function(I,V){b(function(Oe,ue){if(Oe){V(Oe);return}I(ue)})})};function i(E,O){for(var w=0,x=0,b=0,I=E.length;b<I;++b)E.charCodeAt(b)===O.charCodeAt(b)?++w:++x;return w<0?!1:x===0}e.compareSync=function(E,O){if(typeof E!="string"||typeof O!="string")throw Error("Illegal arguments: "+typeof E+", "+typeof O);return O.length!==60?!1:i(e.hashSync(E,O.substr(0,O.length-31)),O)},e.compare=function(E,O,w,x){function b(I){if(typeof E!="string"||typeof O!="string"){a(I.bind(this,Error("Illegal arguments: "+typeof E+", "+typeof O)));return}if(O.length!==60){a(I.bind(this,null,!1));return}e.hash(E,O.substr(0,29),function(V,Oe){V?I(V):I(null,i(Oe,O))},x)}if(w){if(typeof w!="function")throw Error("Illegal callback: "+typeof w);b(w)}else return new Promise(function(I,V){b(function(Oe,ue){if(Oe){V(Oe);return}I(ue)})})},e.getRounds=function(E){if(typeof E!="string")throw Error("Illegal arguments: "+typeof E);return parseInt(E.split("$")[2],10)},e.getSalt=function(E){if(typeof E!="string")throw Error("Illegal arguments: "+typeof E);if(E.length!==60)throw Error("Illegal hash length: "+E.length+" != 60");return E.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function o(E){var O=[],w=0;return C.encodeUTF16toUTF8(function(){return w>=E.length?null:E.charCodeAt(w++)},function(x){O.push(x)}),O}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(E,O){var w=0,x=[],b,I;if(O<=0||O>E.length)throw Error("Illegal len: "+O);for(;w<O;){if(b=E[w++]&255,x.push(c[b>>2&63]),b=(b&3)<<4,w>=O){x.push(c[b&63]);break}if(I=E[w++]&255,b|=I>>4&15,x.push(c[b&63]),b=(I&15)<<2,w>=O){x.push(c[b&63]);break}I=E[w++]&255,b|=I>>6&3,x.push(c[b&63]),x.push(c[I&63])}return x.join("")}function B(E,O){var w=0,x=E.length,b=0,I=[],V,Oe,ue,Ie,Ve,ee;if(O<=0)throw Error("Illegal len: "+O);for(;w<x-1&&b<O&&(ee=E.charCodeAt(w++),V=ee<u.length?u[ee]:-1,ee=E.charCodeAt(w++),Oe=ee<u.length?u[ee]:-1,!(V==-1||Oe==-1||(Ve=V<<2>>>0,Ve|=(Oe&48)>>4,I.push(f(Ve)),++b>=O||w>=x)||(ee=E.charCodeAt(w++),ue=ee<u.length?u[ee]:-1,ue==-1)||(Ve=(Oe&15)<<4>>>0,Ve|=(ue&60)>>2,I.push(f(Ve)),++b>=O||w>=x)));)ee=E.charCodeAt(w++),Ie=ee<u.length?u[ee]:-1,Ve=(ue&3)<<6>>>0,Ve|=Ie,I.push(f(Ve)),++b;var ut=[];for(w=0;w<b;w++)ut.push(I[w].charCodeAt(0));return ut}var C=function(){var E={};return E.MAX_CODEPOINT=1114111,E.encodeUTF8=function(O,w){var x=null;for(typeof O=="number"&&(x=O,O=function(){return null});x!==null||(x=O())!==null;)x<128?w(x&127):x<2048?(w(x>>6&31|192),w(x&63|128)):x<65536?(w(x>>12&15|224),w(x>>6&63|128),w(x&63|128)):(w(x>>18&7|240),w(x>>12&63|128),w(x>>6&63|128),w(x&63|128)),x=null},E.decodeUTF8=function(O,w){for(var x,b,I,V,Oe=function(ue){ue=ue.slice(0,ue.indexOf(null));var Ie=Error(ue.toString());throw Ie.name="TruncatedError",Ie.bytes=ue,Ie};(x=O())!==null;)if(!(x&128))w(x);else if((x&224)===192)(b=O())===null&&Oe([x,b]),w((x&31)<<6|b&63);else if((x&240)===224)((b=O())===null||(I=O())===null)&&Oe([x,b,I]),w((x&15)<<12|(b&63)<<6|I&63);else if((x&248)===240)((b=O())===null||(I=O())===null||(V=O())===null)&&Oe([x,b,I,V]),w((x&7)<<18|(b&63)<<12|(I&63)<<6|V&63);else throw RangeError("Illegal starting byte: "+x)},E.UTF16toUTF8=function(O,w){for(var x,b=null;(x=b!==null?b:O())!==null;){if(x>=55296&&x<=57343&&(b=O())!==null&&b>=56320&&b<=57343){w((x-55296)*1024+b-56320+65536),b=null;continue}w(x)}b!==null&&w(b)},E.UTF8toUTF16=function(O,w){var x=null;for(typeof O=="number"&&(x=O,O=function(){return null});x!==null||(x=O())!==null;)x<=65535?w(x):(x-=65536,w((x>>10)+55296),w(x%1024+56320)),x=null},E.encodeUTF16toUTF8=function(O,w){E.UTF16toUTF8(O,function(x){E.encodeUTF8(x,w)})},E.decodeUTF8toUTF16=function(O,w){E.decodeUTF8(O,function(x){E.UTF8toUTF16(x,w)})},E.calculateCodePoint=function(O){return O<128?1:O<2048?2:O<65536?3:4},E.calculateUTF8=function(O){for(var w,x=0;(w=O())!==null;)x+=E.calculateCodePoint(w);return x},E.calculateUTF16asUTF8=function(O){var w=0,x=0;return E.UTF16toUTF8(O,function(b){++w,x+=E.calculateCodePoint(b)}),[w,x]},E}();Date.now=Date.now||function(){return+new Date};var p=16,y=10,S=16,A=100,R=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],T=[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],ve=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Ue(E,O,w,x){var b,I=E[O],V=E[O+1];return I^=w[0],b=x[I>>>24],b+=x[256|I>>16&255],b^=x[512|I>>8&255],b+=x[768|I&255],V^=b^w[1],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],I^=b^w[2],b=x[I>>>24],b+=x[256|I>>16&255],b^=x[512|I>>8&255],b+=x[768|I&255],V^=b^w[3],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],I^=b^w[4],b=x[I>>>24],b+=x[256|I>>16&255],b^=x[512|I>>8&255],b+=x[768|I&255],V^=b^w[5],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],I^=b^w[6],b=x[I>>>24],b+=x[256|I>>16&255],b^=x[512|I>>8&255],b+=x[768|I&255],V^=b^w[7],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],I^=b^w[8],b=x[I>>>24],b+=x[256|I>>16&255],b^=x[512|I>>8&255],b+=x[768|I&255],V^=b^w[9],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],I^=b^w[10],b=x[I>>>24],b+=x[256|I>>16&255],b^=x[512|I>>8&255],b+=x[768|I&255],V^=b^w[11],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],I^=b^w[12],b=x[I>>>24],b+=x[256|I>>16&255],b^=x[512|I>>8&255],b+=x[768|I&255],V^=b^w[13],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],I^=b^w[14],b=x[I>>>24],b+=x[256|I>>16&255],b^=x[512|I>>8&255],b+=x[768|I&255],V^=b^w[15],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],I^=b^w[16],E[O]=V^w[S+1],E[O+1]=I,E}function qe(E,O){for(var w=0,x=0;w<4;++w)x=x<<8|E[O]&255,O=(O+1)%E.length;return{key:x,offp:O}}function Ze(E,O,w){for(var x=0,b=[0,0],I=O.length,V=w.length,Oe,ue=0;ue<I;ue++)Oe=qe(E,x),x=Oe.offp,O[ue]=O[ue]^Oe.key;for(ue=0;ue<I;ue+=2)b=Ue(b,0,O,w),O[ue]=b[0],O[ue+1]=b[1];for(ue=0;ue<V;ue+=2)b=Ue(b,0,O,w),w[ue]=b[0],w[ue+1]=b[1]}function nt(E,O,w,x){for(var b=0,I=[0,0],V=w.length,Oe=x.length,ue,Ie=0;Ie<V;Ie++)ue=qe(O,b),b=ue.offp,w[Ie]=w[Ie]^ue.key;for(b=0,Ie=0;Ie<V;Ie+=2)ue=qe(E,b),b=ue.offp,I[0]^=ue.key,ue=qe(E,b),b=ue.offp,I[1]^=ue.key,I=Ue(I,0,w,x),w[Ie]=I[0],w[Ie+1]=I[1];for(Ie=0;Ie<Oe;Ie+=2)ue=qe(E,b),b=ue.offp,I[0]^=ue.key,ue=qe(E,b),b=ue.offp,I[1]^=ue.key,I=Ue(I,0,w,x),x[Ie]=I[0],x[Ie+1]=I[1]}function bt(E,O,w,x,b){var I=ve.slice(),V=I.length,Oe;if(w<4||w>31)if(Oe=Error("Illegal number of rounds (4-31): "+w),x){a(x.bind(this,Oe));return}else throw Oe;if(O.length!==p)if(Oe=Error("Illegal salt length: "+O.length+" != "+p),x){a(x.bind(this,Oe));return}else throw Oe;w=1<<w>>>0;var ue,Ie,Ve=0,ee;Int32Array?(ue=new Int32Array(R),Ie=new Int32Array(T)):(ue=R.slice(),Ie=T.slice()),nt(O,E,ue,Ie);function ut(){if(b&&b(Ve/w),Ve<w)for(var Fe=Date.now();Ve<w&&(Ve=Ve+1,Ze(E,ue,Ie),Ze(O,ue,Ie),!(Date.now()-Fe>A)););else{for(Ve=0;Ve<64;Ve++)for(ee=0;ee<V>>1;ee++)Ue(I,ee<<1,ue,Ie);var st=[];for(Ve=0;Ve<V;Ve++)st.push((I[Ve]>>24&255)>>>0),st.push((I[Ve]>>16&255)>>>0),st.push((I[Ve]>>8&255)>>>0),st.push((I[Ve]&255)>>>0);if(x){x(null,st);return}else return st}x&&a(ut)}if(typeof x<"u")ut();else for(var is;;)if(typeof(is=ut())<"u")return is||[]}function Vt(E,O,w,x){var b;if(typeof E!="string"||typeof O!="string")if(b=Error("Invalid string / salt: Not a string"),w){a(w.bind(this,b));return}else throw b;var I,V;if(O.charAt(0)!=="$"||O.charAt(1)!=="2")if(b=Error("Invalid salt version: "+O.substring(0,2)),w){a(w.bind(this,b));return}else throw b;if(O.charAt(2)==="$")I="\0",V=3;else{if(I=O.charAt(2),I!=="a"&&I!=="b"&&I!=="y"||O.charAt(3)!=="$")if(b=Error("Invalid salt revision: "+O.substring(2,4)),w){a(w.bind(this,b));return}else throw b;V=4}if(O.charAt(V+2)>"$")if(b=Error("Missing salt rounds"),w){a(w.bind(this,b));return}else throw b;var Oe=parseInt(O.substring(V,V+1),10)*10,ue=parseInt(O.substring(V+1,V+2),10),Ie=Oe+ue,Ve=O.substring(V+3,V+25);E+=I>="a"?"\0":"";var ee=o(E),ut=B(Ve,p);function is(Fe){var st=[];return st.push("$2"),I>="a"&&st.push(I),st.push("$"),Ie<10&&st.push("0"),st.push(Ie.toString()),st.push("$"),st.push(m(ut,ut.length)),st.push(m(Fe,ve.length*4-1)),st.join("")}if(typeof w>"u")return is(bt(ee,ut,Ie));bt(ee,ut,Ie,function(Fe,st){Fe?w(Fe,null):w(null,is(st))},x)}return e.encodeBase64=m,e.decodeBase64=B,e})})(og);var Bw=og.exports;const Rw=Cx(Bw),Pw="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let $w=r=>crypto.getRandomValues(new Uint8Array(r)),Zw=(r,e,t)=>{let n=(2<<Math.log2(r.length-1))-1,s=-~(1.6*n*e/r.length);return(i=e)=>{let a="";for(;;){let o=t(s),c=s;for(;c--;)if(a+=r[o[c]&n]||"",a.length===i)return a}}},Dw=(r,e=21)=>Zw(r,e,$w),yf=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Pw[t[r]&63];return e};const Mw=24;function Vw(){return Dw("0123456789abcdef",Mw)()}function cg(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}const es=v.object({page:v.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:v.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:v.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:v.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:v.string().optional().openapi({description:"A lucene query string used to filter the results"})});function Js(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}var Uw={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},Lw=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[s,i]of Object.entries(Uw))if(qw(i))return s}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"},qw=r=>navigator.userAgent.startsWith(r);function Hw(r,e){Lw()==="workerd"&&r.executionCtx.waitUntil(e)}const ug=Bn.extend({users:v.array(Rr)}),Fw=Bn.extend({sessions:v.array(Mh)}),Ww=new Ot().openapi(ke({tags:["users"],method:"get",path:"/",request:{query:es,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Rr),ug])}},description:"List of users"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header");if(i!=null&&i.includes("identities.profileData.email")){const f=i.split("=")[1],B=(await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,q:`email:${f}`})).users.filter(y=>y.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 $e(500,{message:"Primary account not found"});return r.json([Rr.parse(p)])}const o=["-_exists_:linked_to"];i&&o.push(i);const c=await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,sort:Js(s),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(ug.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(v.array(Rr).parse(u))}).openapi(ke({tags:["users"],method:"get",path:"/{user_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({user_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Rr}},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 $e(404);if(n.linked_to)throw new $e(404,{message:"User is linked to another user"});return r.json(n)}).openapi(ke({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({user_id:v.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 $e(404);return r.text("OK")}).openapi(ke({tags:["users"],method:"post",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object({...Lu.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Rr}},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 $e(400,{message:"Email is required"});const s=n.toLowerCase(),i=`${t.provider}|${t.user_id||Vw()}`;try{const a=await r.env.data.users.create(e,{email:s,user_id:i,name:t.name||s,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=ag(r,{type:Ku.SUCCESS_API_OPERATION,description:"User created"});Hw(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:cg(a.user_id),isSocial:a.is_social}]};return r.json(Rr.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new $e(409,{message:"User already exists"}):a}}).openapi(ke({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object({...Lu.shape,verify_email:v.boolean(),password:v.string()}).partial()}}},params:v.object({user_id:v.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:s,password:i,...a}=t,o=await r.env.data.users.get(e,n);if(!o)throw new $e(404);if(a.email&&a.email!==o.email){const f=await ig(r.env.data.users,e,a.email);if(f.length&&f.some(m=>m.user_id!==n))throw new $e(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new $e(404,{message:"User is linked to another user"});if(await r.env.data.users.update(e,n,a),i){const f=(u=o.identities)==null?void 0:u.find(m=>m.connection==="Username-Password-Authentication");if(!f)throw new $e(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${f.provider}|${f.user_id}`,password:Rw.hashSync(i,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new $e(500);return r.json(c)}).openapi(ke({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.union([v.object({link_with:v.string()}),v.object({user_id:v.string(),provider:v.string(),connection:v.string().optional()})])}}},params:v.object({user_id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:v.array(v.object({connection:v.string(),provider:v.string(),user_id:v.string(),isSocial:v.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"),s="link_with"in t?t.link_with:t.user_id,i=await r.env.data.users.get(e,n);if(!i)throw new $e(400,{message:"Linking an inexistent identity is not allowed."});await r.env.data.users.update(e,s,{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=[i,...a.users].map(c=>({connection:c.connection,provider:c.provider,user_id:cg(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(ke({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({user_id:v.string(),provider:v.string(),linked_user_id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:v.array(Rr)}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{user_id:t,provider:n,linked_user_id:s}=r.req.valid("param");await r.env.data.users.unlink(e,t,n,s);const i=await r.env.data.users.get(e,t);if(!i)throw new $e(404);return r.json([Rr.parse(i)])}).openapi(ke({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:es,headers:v.object({"tenant-id":v.string()}),params:v.object({user_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Mh),Fw])}},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"),s=await r.env.data.sessions.list(n,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return t?r.json(s):r.json(s.sessions)}),lg="0123456789abcdef";function gf(r){const e=new Uint8Array(r);let t="";for(let n=0;n<e.length;n++){const s=e[n]>>4;t+=lg[s];const i=e[n]&15;t+=lg[i]}return t}class dg{constructor(e,t){H(this,"alphabet");H(this,"padding");H(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="",s=0,i=0;for(let o=0;o<e.length;o++)for(s=s<<8|e[o],i+=8;i>=5;)i-=5,n+=this.alphabet[s>>i&31];if(i>0&&(n+=this.alphabet[s<<5-i&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,s=Math.ceil(e.length/8),i=[];for(let a=0;a<s;a++){let o=0;const c=[];for(let f=0;f<8;f++){const m=e[a*8+f];if(m==="="){if(a+1!==s)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(i.push(u),o<6){const f=((c[1]&3)<<6)+(c[2]<<1)+(c[3]>>4);i.push(f)}if(o<4){const f=((c[3]&255)<<4)+(c[4]>>1);i.push(f)}if(o<3){const f=((c[4]&1)<<7)+(c[5]<<2)+(c[6]>>3);i.push(f)}if(o<1){const f=((c[6]&7)<<5)+c[7];i.push(f)}}return Uint8Array.from(i)}}new dg("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),new dg("0123456789ABCDEFGHIJKLMNOPQRSTUV");class fg{constructor(e,t){H(this,"alphabet");H(this,"padding");H(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="",s=0,i=0;for(let o=0;o<e.length;o++)for(s=s<<8|e[o],i+=8;i>=6;)i+=-6,n+=this.alphabet[s>>i&63];if(i>0&&(n+=this.alphabet[s<<6-i&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,s=Math.ceil(e.length/4),i=[];for(let a=0;a<s;a++){let o=0,c=0;for(let u=0;u<4;u++){const f=e[a*4+u];if(f==="="){if(a+1!==s)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)}i.push(c>>16&255),o<2&&i.push(c>>8&255),o<1&&i.push(c&255)}return Uint8Array.from(i)}}const Kw=new fg("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");new fg("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function zw(r){return await crypto.subtle.digest("SHA-256",r)}async function hg(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=yf(),s=gf(new TextEncoder().encode(n)),i=await ww.createSelfSigned({serialNumber:s,name:r.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:t,extensions:[new af(!0,2,!0),new of(["1.3.6.1.5.5.7.3.1"],!0),new cf(nu.keyCertSign|nu.cRLSign,!0),await Ba.create(t.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",t.privateKey),o=i.toString("pem"),c=await Jw(i),u=gf(await i.getThumbprint()),f=Gw("PRIVATE",a);return{kid:i.serialNumber,cert:o,thumbprint:u,fingerprint:c,pkcs7:f}}function Gw(r,e){const t=Kw.encode(new Uint8Array(e));let n=`-----BEGIN ${r} KEY-----\r
122
+ `,s=0;for(;s<t.length;)s+64<=t.length?n+=t.substr(s,64)+`\r
123
+ `:n+=t.substr(s)+`\r
124
+ `,s+=64;return n+=`-----END ${r} KEY-----\r
125
+ `,n}async function Jw(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),i=new TextEncoder().encode(n);return gf(await zw(i))}const Yw=1e3*60*60*24,Xw=new Ot().openapi(ke({tags:["keys"],method:"get",path:"/signing",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.array(Vh)}},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(ke({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({kid:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vh}},description:"The requested key"}}}),async r=>{const{kid:e}=r.req.valid("param"),n=(await r.env.data.keys.list()).find(s=>s.kid===e);if(!n)throw new $e(404,{message:"Key not found"});return r.json(n)}).openapi(ke({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:v.object({"tenant-id":v.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()+Yw).toISOString()});const t=await hg({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ke({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({kid:v.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 $e(404,{message:"Key not found"});const n=await hg({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),Qw=new Ot().openapi(ke({tags:["users"],method:"get",path:"/",request:{query:v.object({email:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:v.array(Nh)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),s=(await ig(r.env.data.users,e,t)).filter(i=>!i.linked_to);return r.json(s)}),e1=Bn.extend({clients:v.array(ws)}),t1=new Ot().openapi(ke({tags:["clients"],method:"get",path:"/",request:{query:es,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([e1,v.array(ws)])}},description:"List of clients"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s,sort:i,q:a}=r.req.valid("query"),c=(await r.env.data.applications.list(e,{page:t,per_page:n,include_totals:s,sort:Js(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ke({tags:["clients"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ws}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(i=>i.id===t);if(!s)throw new $e(404);return r.json(s)}).openapi(ke({tags:["clients"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.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 $e(404,{message:"Application not found"});return r.text("OK")}).openapi(ke({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(qu.shape).partial()}}},params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:ws}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=r.req.valid("json");await r.env.data.applications.update(e,t,s);const i=await r.env.data.applications.get(e,t);if(!i)throw new $e(404,{message:"Application not found"});return r.json(i)}).openapi(ke({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(qu.shape)}}},headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:v.object(ws.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||yf(),client_secret:t.client_secret||yf()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var Pe;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Pe||(Pe={}));var vf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(vf||(vf={}));const X=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_n=r=>{switch(typeof r){case"undefined":return X.undefined;case"string":return X.string;case"number":return isNaN(r)?X.nan:X.number;case"boolean":return X.boolean;case"function":return X.function;case"bigint":return X.bigint;case"symbol":return X.symbol;case"object":return Array.isArray(r)?X.array:r===null?X.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?X.promise:typeof Map<"u"&&r instanceof Map?X.map:typeof Set<"u"&&r instanceof Set?X.set:typeof Date<"u"&&r instanceof Date?X.date:X.object;default:return X.unknown}},M=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"]),r1=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Mt 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(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(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 s(this),n}static assert(e){if(!(e instanceof Mt))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 s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Mt.create=r=>new Mt(r);const Ys=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===X.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.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}"`:Pe.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,Pe.assertNever(r)}return{message:t}};let pg=Ys;function n1(r){pg=r}function uu(){return pg}const lu=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.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{...s,path:i,message:o}},s1=[];function K(r,e){const t=uu(),n=lu({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ys?void 0:Ys].filter(s=>!!s)});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 s of t){if(s.status==="aborted")return me;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return vt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return me;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Xs=r=>({status:"dirty",value:r}),St=r=>({status:"valid",value:r}),bf=r=>r.status==="aborted",xf=r=>r.status==="dirty",Pa=r=>r.status==="valid",$a=r=>typeof Promise<"u"&&r instanceof Promise;function du(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 mg(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!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}typeof SuppressedError=="function"&&SuppressedError;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 Za,Da;class Or{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const yg=(r,e)=>{if(Pa(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 Mt(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:s}=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:s}:{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:s}}class Ae{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 _n(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:_n(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:_n(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if($a(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 s={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:_n(e)},i=this._parseSync({data:e,path:s.path,parent:s});return yg(s,i)}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:_n(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await($a(s)?s:Promise.resolve(s));return yg(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:M.custom,...n(s)});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,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new lr({schema:this,typeName:he.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Cr.create(this,this._def)}nullable(){return An.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ur.create(this,this._def)}promise(){return ri.create(this,this._def)}or(e){return La.create([this,e],this._def)}and(e){return qa.create(this,e,this._def)}transform(e){return new lr({..._e(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new za({..._e(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new kf({typeName:he.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ga({..._e(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 Ja.create(this,e)}readonly(){return Ya.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const i1=/^c[^\s-]{8,}$/i,a1=/^[0-9a-z]+$/,o1=/^[0-9A-HJKMNP-TV-Z]{26}$/,c1=/^[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,u1=/^[a-z0-9_-]{21}$/i,l1=/^[-+]?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)?)??$/,d1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,f1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let _f;const h1=/^(?:(?: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])$/,p1=/^(([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})))$/,m1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,gg="((\\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])))",y1=new RegExp(`^${gg}$`);function vg(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 g1(r){return new RegExp(`^${vg(r)}$`)}function bg(r){let e=`${gg}T${vg(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 v1(r,e){return!!((e==="v4"||!e)&&h1.test(r)||(e==="v6"||!e)&&p1.test(r))}class cr extends Ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==X.string){const i=this._getOrReturnCtx(e);return K(i,{code:M.invalid_type,expected:X.string,received:i.parsedType}),me}const n=new vt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),K(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),K(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?K(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&K(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")d1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")_f||(_f=new RegExp(f1,"u")),_f.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")c1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")u1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")i1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")a1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")o1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"ulid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),K(s,{validation:"url",code:M.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"regex",code:M.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),K(s,{code:M.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.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)||(s=this._getOrReturnCtx(e,s),K(s,{code:M.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),K(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?bg(i).test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?y1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?g1(i).test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?l1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?v1(e.data,i.version)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?m1.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new cr({...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 cr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new cr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new cr({...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}}cr.create=r=>{var e;return new cr({checks:[],typeName:he.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function b1(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,i=parseInt(r.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class wn 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)!==X.number){const i=this._getOrReturnCtx(e);return K(i,{code:M.invalid_type,expected:X.number,received:i.parsedType}),me}let n;const s=new vt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:M.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?b1(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_finite,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.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,s){return new wn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new wn({...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"&&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)}}wn.create=r=>new wn({checks:[],typeName:he.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class kn 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)!==X.bigint){const i=this._getOrReturnCtx(e);return K(i,{code:M.invalid_type,expected:X.bigint,received:i.parsedType}),me}let n;const s=new vt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.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,s){return new kn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new kn({...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}}kn.create=r=>{var e;return new kn({checks:[],typeName:he.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};class Ma extends Ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==X.boolean){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:X.boolean,received:n.parsedType}),me}return St(e.data)}}Ma.create=r=>new Ma({typeName:he.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class ts extends Ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==X.date){const i=this._getOrReturnCtx(e);return K(i,{code:M.invalid_type,expected:X.date,received:i.parsedType}),me}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return K(i,{code:M.invalid_date}),me}const n=new vt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),K(s,{code:M.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),K(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ts({...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}}ts.create=r=>new ts({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,..._e(r)});class fu extends Ae{_parse(e){if(this._getType(e)!==X.symbol){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:X.symbol,received:n.parsedType}),me}return St(e.data)}}fu.create=r=>new fu({typeName:he.ZodSymbol,..._e(r)});class Va extends Ae{_parse(e){if(this._getType(e)!==X.undefined){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:X.undefined,received:n.parsedType}),me}return St(e.data)}}Va.create=r=>new Va({typeName:he.ZodUndefined,..._e(r)});class Ua extends Ae{_parse(e){if(this._getType(e)!==X.null){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:X.null,received:n.parsedType}),me}return St(e.data)}}Ua.create=r=>new Ua({typeName:he.ZodNull,..._e(r)});class Qs extends Ae{constructor(){super(...arguments),this._any=!0}_parse(e){return St(e.data)}}Qs.create=r=>new Qs({typeName:he.ZodAny,..._e(r)});class rs extends Ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return St(e.data)}}rs.create=r=>new rs({typeName:he.ZodUnknown,..._e(r)});class Wr extends Ae{_parse(e){const t=this._getOrReturnCtx(e);return K(t,{code:M.invalid_type,expected:X.never,received:t.parsedType}),me}}Wr.create=r=>new Wr({typeName:he.ZodNever,..._e(r)});class hu extends Ae{_parse(e){if(this._getType(e)!==X.undefined){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:X.void,received:n.parsedType}),me}return St(e.data)}}hu.create=r=>new hu({typeName:he.ZodVoid,..._e(r)});class ur extends Ae{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==X.array)return K(t,{code:M.invalid_type,expected:X.array,received:t.parsedType}),me;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(K(t,{code:a?M.too_big:M.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(K(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(K(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Or(t,a,t.path,o)))).then(a=>vt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Or(t,a,t.path,o)));return vt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new ur({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new ur({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new ur({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}ur.create=(r,e)=>new ur({type:r,minLength:null,maxLength:null,exactLength:null,typeName:he.ZodArray,..._e(e)});function ei(r){if(r instanceof Xe){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Cr.create(ei(n))}return new Xe({...r._def,shape:()=>e})}else return r instanceof ur?new ur({...r._def,type:ei(r.element)}):r instanceof Cr?Cr.create(ei(r.unwrap())):r instanceof An?An.create(ei(r.unwrap())):r instanceof Er?Er.create(r.items.map(e=>ei(e))):r}class Xe 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=Pe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==X.object){const u=this._getOrReturnCtx(e);return K(u,{code:M.invalid_type,expected:X.object,received:u.parsedType}),me}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Wr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Or(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Wr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")o.length>0&&(K(s,{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=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Or(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.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 Xe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,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 Xe({...this._def,unknownKeys:"strip"})}passthrough(){return new Xe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xe({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 Xe({...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 Xe({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xe({...this._def,shape:()=>t})}deepPartial(){return ei(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Xe({...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 Cr;)i=i._def.innerType;t[n]=i}}),new Xe({...this._def,shape:()=>t})}keyof(){return xg(Pe.objectKeys(this.shape))}}Xe.create=(r,e)=>new Xe({shape:()=>r,unknownKeys:"strip",catchall:Wr.create(),typeName:he.ZodObject,..._e(e)}),Xe.strictCreate=(r,e)=>new Xe({shape:()=>r,unknownKeys:"strict",catchall:Wr.create(),typeName:he.ZodObject,..._e(e)}),Xe.lazycreate=(r,e)=>new Xe({shape:r,unknownKeys:"strip",catchall:Wr.create(),typeName:he.ZodObject,..._e(e)});class La extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Mt(o.ctx.common.issues));return K(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;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"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Mt(c));return K(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}La.create=(r,e)=>new La({options:r,typeName:he.ZodUnion,..._e(e)});const Kr=r=>r instanceof Fa?Kr(r.schema):r instanceof lr?Kr(r.innerType()):r instanceof Wa?[r.value]:r instanceof Sn?r.options:r instanceof Ka?Pe.objectValues(r.enum):r instanceof za?Kr(r._def.innerType):r instanceof Va?[void 0]:r instanceof Ua?[null]:r instanceof Cr?[void 0,...Kr(r.unwrap())]:r instanceof An?[null,...Kr(r.unwrap())]:r instanceof kf||r instanceof Ya?Kr(r.unwrap()):r instanceof Ga?Kr(r._def.innerType):[];class pu extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==X.object)return K(t,{code:M.invalid_type,expected:X.object,received:t.parsedType}),me;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._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 s=new Map;for(const i of t){const a=Kr(i.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(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new pu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._e(n)})}}function wf(r,e){const t=_n(r),n=_n(e);if(r===e)return{valid:!0,data:r};if(t===X.object&&n===X.object){const s=Pe.objectKeys(e),i=Pe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=wf(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===X.array&&n===X.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=wf(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===X.date&&n===X.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class qa extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(bf(i)||bf(a))return me;const o=wf(i.value,a.value);return o.valid?((xf(i)||xf(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(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}qa.create=(r,e,t)=>new qa({left:r,right:e,typeName:he.ZodIntersection,..._e(t)});class Er extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==X.array)return K(n,{code:M.invalid_type,expected:X.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 i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Or(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>vt.mergeArray(t,a)):vt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Er({...this._def,rest:e})}}Er.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Er({items:r,typeName:he.ZodTuple,rest:null,..._e(e)})};class Ha 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!==X.object)return K(n,{code:M.invalid_type,expected:X.object,received:n.parsedType}),me;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Or(n,o,n.path,o)),value:a._parse(new Or(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?vt.mergeObjectAsync(t,s):vt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ae?new Ha({keyType:e,valueType:t,typeName:he.ZodRecord,..._e(n)}):new Ha({keyType:cr.create(),valueType:e,typeName:he.ZodRecord,..._e(t)})}}class mu 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!==X.map)return K(n,{code:M.invalid_type,expected:X.map,received:n.parsedType}),me;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Or(n,o,n.path,[u,"key"])),value:i._parse(new Or(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}}}}mu.create=(r,e,t)=>new mu({valueType:e,keyType:r,typeName:he.ZodMap,..._e(t)});class ns extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==X.set)return K(n,{code:M.invalid_type,expected:X.set,received:n.parsedType}),me;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(K(n,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(K(n,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=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)=>i._parse(new Or(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ns({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new ns({...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)}}ns.create=(r,e)=>new ns({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,..._e(e)});class ti extends Ae{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==X.function)return K(t,{code:M.invalid_type,expected:X.function,received:t.parsedType}),me;function n(o,c){return lu({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,uu(),Ys].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function s(o,c){return lu({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,uu(),Ys].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ri){const o=this;return St(async function(...c){const u=new Mt([]),f=await o._def.args.parseAsync(c,i).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,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return St(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Mt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Mt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ti({...this._def,args:Er.create(e).rest(rs.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||Er.create([]).rest(rs.create()),returns:t||rs.create(),typeName:he.ZodFunction,..._e(n)})}}class Fa 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})}}Fa.create=(r,e)=>new Fa({getter:r,typeName:he.ZodLazy,..._e(e)});class Wa extends Ae{_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}}Wa.create=(r,e)=>new Wa({value:r,typeName:he.ZodLiteral,..._e(e)});function xg(r,e){return new Sn({values:r,typeName:he.ZodEnum,..._e(e)})}class Sn extends Ae{constructor(){super(...arguments),Za.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{expected:Pe.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(du(this,Za)||mg(this,Za,new Set(this._def.values)),!du(this,Za).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 St(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 Sn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Sn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Za=new WeakMap,Sn.create=xg;class Ka extends Ae{constructor(){super(...arguments),Da.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==X.string&&n.parsedType!==X.number){const s=Pe.objectValues(t);return K(n,{expected:Pe.joinValues(s),received:n.parsedType,code:M.invalid_type}),me}if(du(this,Da)||mg(this,Da,new Set(Pe.getValidEnumValues(this._def.values))),!du(this,Da).has(e.data)){const s=Pe.objectValues(t);return K(n,{received:n.data,code:M.invalid_enum_value,options:s}),me}return St(e.data)}get enum(){return this._def.values}}Da=new WeakMap,Ka.create=(r,e)=>new Ka({values:r,typeName:he.ZodNativeEnum,..._e(e)});class ri extends Ae{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==X.promise&&t.common.async===!1)return K(t,{code:M.invalid_type,expected:X.promise,received:t.parsedType}),me;const n=t.parsedType===X.promise?t.data:Promise.resolve(t.data);return St(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ri.create=(r,e)=>new ri({type:r,typeName:he.ZodPromise,..._e(e)});class lr extends Ae{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),s=this._def.effect||null,i={addIssue:a=>{K(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);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"?Xs(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"?Xs(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);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(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Pa(a))return a;const o=s.transform(a.value,i);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=>Pa(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(s)}}lr.create=(r,e,t)=>new lr({schema:r,typeName:he.ZodEffects,effect:e,..._e(t)}),lr.createWithPreprocess=(r,e,t)=>new lr({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,..._e(t)});class Cr extends Ae{_parse(e){return this._getType(e)===X.undefined?St(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cr.create=(r,e)=>new Cr({innerType:r,typeName:he.ZodOptional,..._e(e)});class An extends Ae{_parse(e){return this._getType(e)===X.null?St(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}An.create=(r,e)=>new An({innerType:r,typeName:he.ZodNullable,..._e(e)});class za extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===X.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}za.create=(r,e)=>new za({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});class Ga extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $a(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Mt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Mt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ga.create=(r,e)=>new Ga({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});class yu extends Ae{_parse(e){if(this._getType(e)!==X.nan){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:X.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}yu.create=r=>new yu({typeName:he.ZodNaN,..._e(r)});const x1=Symbol("zod_brand");class kf 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}}class Ja extends Ae{_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"?me:i.status==="dirty"?(t.dirty(),Xs(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ja({in:e,out:t,typeName:he.ZodPipeline})}}class Ya extends Ae{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Pa(s)&&(s.value=Object.freeze(s.value)),s);return $a(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Ya.create=(r,e)=>new Ya({innerType:r,typeName:he.ZodReadonly,..._e(e)});function _g(r,e={},t){return r?Qs.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Qs.create()}const _1={object:Xe.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 w1=(r,e={message:`Input not instance of ${r.name}`})=>_g(t=>t instanceof r,e),wg=cr.create,kg=wn.create,k1=yu.create,S1=kn.create,Sg=Ma.create,A1=ts.create,O1=fu.create,E1=Va.create,C1=Ua.create,I1=Qs.create,j1=rs.create,T1=Wr.create,N1=hu.create,B1=ur.create,R1=Xe.create,P1=Xe.strictCreate,$1=La.create,Z1=pu.create,D1=qa.create,M1=Er.create,V1=Ha.create,U1=mu.create,L1=ns.create,q1=ti.create,H1=Fa.create,F1=Wa.create,W1=Sn.create,K1=Ka.create,z1=ri.create,Ag=lr.create,G1=Cr.create,J1=An.create,Y1=lr.createWithPreprocess,X1=Ja.create;var Gt=Object.freeze({__proto__:null,defaultErrorMap:Ys,setErrorMap:n1,getErrorMap:uu,makeIssue:lu,EMPTY_PATH:s1,addIssueToContext:K,ParseStatus:vt,INVALID:me,DIRTY:Xs,OK:St,isAborted:bf,isDirty:xf,isValid:Pa,isAsync:$a,get util(){return Pe},get objectUtil(){return vf},ZodParsedType:X,getParsedType:_n,ZodType:Ae,datetimeRegex:bg,ZodString:cr,ZodNumber:wn,ZodBigInt:kn,ZodBoolean:Ma,ZodDate:ts,ZodSymbol:fu,ZodUndefined:Va,ZodNull:Ua,ZodAny:Qs,ZodUnknown:rs,ZodNever:Wr,ZodVoid:hu,ZodArray:ur,ZodObject:Xe,ZodUnion:La,ZodDiscriminatedUnion:pu,ZodIntersection:qa,ZodTuple:Er,ZodRecord:Ha,ZodMap:mu,ZodSet:ns,ZodFunction:ti,ZodLazy:Fa,ZodLiteral:Wa,ZodEnum:Sn,ZodNativeEnum:Ka,ZodPromise:ri,ZodEffects:lr,ZodTransformer:lr,ZodOptional:Cr,ZodNullable:An,ZodDefault:za,ZodCatch:Ga,ZodNaN:yu,BRAND:x1,ZodBranded:kf,ZodPipeline:Ja,ZodReadonly:Ya,custom:_g,Schema:Ae,ZodSchema:Ae,late:_1,get ZodFirstPartyTypeKind(){return he},coerce:{string:r=>cr.create({...r,coerce:!0}),number:r=>wn.create({...r,coerce:!0}),boolean:r=>Ma.create({...r,coerce:!0}),bigint:r=>kn.create({...r,coerce:!0}),date:r=>ts.create({...r,coerce:!0})},any:I1,array:B1,bigint:S1,boolean:Sg,date:A1,discriminatedUnion:Z1,effect:Ag,enum:W1,function:q1,instanceof:w1,intersection:D1,lazy:H1,literal:F1,map:U1,nan:k1,nativeEnum:K1,never:T1,null:C1,nullable:J1,number:kg,object:R1,oboolean:()=>Sg().optional(),onumber:()=>kg().optional(),optional:G1,ostring:()=>wg().optional(),pipeline:X1,preprocess:Y1,promise:z1,record:V1,set:L1,strictObject:P1,string:wg,symbol:O1,transformer:Ag,tuple:M1,undefined:E1,union:$1,unknown:j1,void:N1,NEVER:me,ZodIssueCode:M,quotelessJson:r1,ZodError:Mt});Gt.object({start:Gt.number(),limit:Gt.number(),length:Gt.number()}),Uu.extend({email:Gt.string(),login_count:Gt.number(),multifactor:Gt.array(Gt.string()).optional(),last_ip:Gt.string().optional(),last_login:Gt.string().optional(),user_id:Gt.string()}).catchall(Gt.any());const Q1=Bn.extend({tenants:v.array(Xi)}),ek=new Ot().openapi(ke({tags:["tenants"],method:"get",path:"/",request:{query:es},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:v.union([v.array(Xi),Q1])}},description:"List of tenants"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),a=await r.env.data.tenants.list({page:e,per_page:t,include_totals:n,sort:Js(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(ke({tags:["tenants"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Xi}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new $e(404);return console.log("tenant",t),r.json(t)}).openapi(ke({tags:["tenants"],method:"delete",path:"/{id}",request:{params:v.object({id:v.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(ke({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(Fu.shape).partial()}}},params:v.object({id:v.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(ke({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(Fu.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Xi}},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})}),tk=Bn.extend({logs:v.array(zu)}),rk=new Ot().openapi(ke({tags:["logs"],method:"get",path:"/",request:{query:es,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(zu),tk])}},description:"List of log rows"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=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:Js(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(ke({tags:["logs"],method:"get",path:"/{id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:zu}},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 $e(404);return r.json(n)}),nk=Bn.extend({hooks:v.array(Qi)}),sk=new Ot().openapi(ke({tags:["hooks"],method:"get",path:"/",request:{query:es,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Qi),nk])}},description:"List of hooks"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s,sort:i,q:a}=r.req.valid("query"),o=await r.env.data.hooks.list(e,{page:t,per_page:n,include_totals:s,sort:Js(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(ke({tags:["hooks"],method:"post",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(Wu.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Qi}},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(ke({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()}),body:{content:{"application/json":{schema:v.object(Wu.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Qi.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 s=await r.env.data.hooks.get(e,t);if(!s)throw new $e(404,{message:"Hook not found"});return r.json(s)}).openapi(ke({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Qi}},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 $e(404,{message:"Hook not found"});return r.json(n)}).openapi(ke({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.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 $e(404,{message:"Hook not found"});return r.text("OK")}),ik=Bn.extend({connections:v.array(ks)}),ak=new Ot().openapi(ke({tags:["connections"],method:"get",path:"/",request:{query:es,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(ks),ik])}},description:"List of connectionss"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:s=!1,sort:i,q:a}=r.req.valid("query"),o=await r.env.data.connections.list(e,{page:t,per_page:n,include_totals:s,sort:Js(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(ke({tags:["connections"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ks}},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 $e(404);return r.json(n)}).openapi(ke({tags:["connections"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.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 $e(404,{message:"Connection not found"});return r.text("OK")}).openapi(ke({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(Hu.shape).partial()}}},params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:ks}},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 $e(404,{message:"Connection not found"});const i=await r.env.data.connections.get(e,t);if(!i)throw new $e(404,{message:"Connection not found"});return r.json(i)}).openapi(ke({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(Hu.shape)}}},headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:ks}},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})}),ok=new Ot().openapi(ke({tags:["prompts"],method:"get",path:"/",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ju}},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(Ju.parse({}))}).openapi(ke({tags:["prompts"],method:"patch",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(Ju.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 Og=!1;function ck(r){r.use(async(e,t)=>(Og||(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"}}}}),Og=!0),await t()))}v.object({alg:v.literal("RS256"),kty:v.literal("RSA"),use:v.literal("sig"),n:v.string(),e:v.string(),kid:v.string(),x5t:v.string(),x5c:v.array(v.string())});async function uk(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 $e(500,{message:"Failed to fetch jwks: "+e.message+", "+JSON.stringify(r)})}}async function lk(r,e){const n=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),s=new Uint8Array(Array.from(e.signature).map(c=>c.charCodeAt(0))),a=(await uk(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,s,n)}function dk(r){const[e,t,n]=r.split(".");if(!e||!t||!n)return null;const s=JSON.parse(atob(e)),i=JSON.parse(atob(t)),a=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return{header:s,payload:i,signature:a,raw:{header:e,payload:t,signature:n}}}function fk(r){return async(e,t)=>{var s,i;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=(i=(s=n.route.security)==null?void 0:s[0])==null?void 0:i.Bearer,o=e.req.header("authorization")||"",[c,u]=o.split(" ");if((c==null?void 0:c.toLowerCase())!=="bearer"||!u)throw new $e(401,{message:"Missing bearer token"});const f=dk(u);if(!f||!await lk(e,f))throw new $e(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 $e(403,{message:"Unauthorized"})}return await t()}}function hk(r){const e=new Ot;e.use(fk(e)),e.use(async(n,s)=>(n.env.data=Iw(n,r.dataAdapter),s()));const t=e.route("/api/v2/branding",jw).route("/api/v2/users",Ww).route("/api/v2/keys",Xw).route("/api/v2/users-by-email",Qw).route("/api/v2/clients",t1).route("/api/v2/tenants",ek).route("/api/v2/logs",rk).route("/api/v2/hooks",sk).route("/api/v2/connections",ak).route("/api/v2/prompts",ok);return ck(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function pk(r){const e=new Ot;e.get("/",s=>s.json({name:"authhero"}));const t=hk(r);e.route("/api/v2",t);const n=new Ot().route("/.well-known",kw(r));return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",n),{rootApp:e,managementApp:t,oauthApp:n}}return He.init=pk,Object.defineProperty(He,Symbol.toStringTag,{value:"Module"}),He}({});