authhero 0.6.0 → 0.7.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.
package/dist/authhero.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Rg=Object.defineProperty;var xf=r=>{throw TypeError(r)};var Pg=(r,e,t)=>e in r?Rg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var K=(r,e,t)=>Pg(r,typeof e!="symbol"?e+"":e,t),_f=(r,e,t)=>e.has(r)||xf("Cannot "+t);var V=(r,e,t)=>(_f(r,e,"read from private field"),t?t.call(r):e.get(r)),at=(r,e,t)=>e.has(r)?xf("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),je=(r,e,t,n)=>(_f(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Qs(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 _e(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function $g(r){return"_def"in r}function Ks(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 Zg(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const D=typeof s=="string"?i:s,j=D??{},{param:p}=j,g=Qs(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),B=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(_e(this,"ZodObject")){const T=this.extend;B.extend=function(...ye){var Me,Ve,Pe,Xe,lt,It;const E=T.apply(this,ye);return E._def.openapi={_internal:{extendedFrom:!((Ve=(Me=this._def.openapi)===null||Me===void 0?void 0:Me._internal)===null||Ve===void 0)&&Ve.refId?{refId:(Xe=(Pe=this._def.openapi)===null||Pe===void 0?void 0:Pe._internal)===null||Xe===void 0?void 0:Xe.refId,schema:this}:(lt=this._def.openapi)===null||lt===void 0?void 0:lt._internal.extendedFrom},metadata:(It=E._def.openapi)===null||It===void 0?void 0:It.metadata},E}}return B},Ks(r,"optional"),Ks(r,"nullable"),Ks(r,"default"),Ks(r,"transform"),Ks(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const 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 so(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=>so(r[n],e[n]))}class Dg{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=>so(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>so(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 ui(r){return r==null}function li(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function Mg(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function rs(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function wf(r){return r.filter(e=>!ui(e))}const Iu=so;function Vg(r){const e=new Dg;return r.forEach(t=>e.put(t)),[...e.values()]}function xp(r){return typeof r=="string"}class Ug{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 fc{constructor(e){this.message=e}}class Gs extends fc{constructor(e,t){super(e),this.data=t}}class io extends fc{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 Js(r,e){try{return r()}catch(t){throw t instanceof io?new io(Object.assign(Object.assign({},t.data),e)):t}}class Lg extends fc{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class Fe{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 rs(Mg(e,["param"]),ui)}static buildParameterMetadata(e){return rs(e,ui)}static applySchemaMetadata(e,t){return rs(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),ui)}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&&_e(e,t)?e:_e(e,"ZodOptional")||_e(e,"ZodNullable")||_e(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):_e(e,"ZodDefault")||_e(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):_e(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):_e(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return _e(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class qg{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 Hg{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class Fg{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=>Fe.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=Fe.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(_e(c,"ZodEnum")||_e(c,"ZodNativeEnum")){Object.values(c.enum).filter(xp).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 Wg{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class zg{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!_e(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class Kg{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function Gg(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 Jg{transform(e,t){const{type:n,values:s}=Gg(e._def.values);if(n==="mixed")throw new fc("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 Yg{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class Xg{transform(e,t,n,s){var i;const a=(i=Fe.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=li(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=li(u==null?void 0:u._def.shape(),s),D=Object.fromEntries(Object.entries(c).filter(([g,A])=>!Iu(m[g],A))),j=o.filter(g=>!f.includes(g)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:D}),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 _e(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!Fe.isOptionalSchema(n)).map(([t,n])=>t)}}class Qg{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(_e(i,"ZodEnum")||_e(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter(xp).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 e0{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 t0{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 r0{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 _e(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return _e(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class n0{constructor(e){this.versionSpecifics=e,this.objectTransformer=new Xg,this.stringTransformer=new e0,this.numberTransformer=new Yg,this.bigIntTransformer=new Hg,this.literalTransformer=new Kg,this.enumTransformer=new Wg,this.nativeEnumTransformer=new Jg,this.arrayTransformer=new qg,this.unionTransformer=new r0,this.discriminatedUnionTransformer=new Fg,this.intersectionTransformer=new zg,this.recordTransformer=new Qg,this.tupleTransformer=new t0(e)}transform(e,t,n,s,i){if(_e(e,"ZodNull"))return this.versionSpecifics.nullType;if(_e(e,"ZodUnknown")||_e(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(_e(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(_e(e,"ZodUnknown")||_e(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(_e(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(_e(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(_e(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(_e(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(_e(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(_e(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(_e(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(_e(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(_e(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=Fe.getRefId(e);throw new Lg({currentSchema:e._def,schemaName:i})}}class _p{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new n0(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=Fe.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 Gs(`Conflicting location for parameter ${u.name}`,{key:"in",values:wf([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 Gs("Conflicting names for parameter",{key:"name",values:wf([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=Fe.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(_e(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,D;const j=Fe.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 Gs("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new Gs(`Conflicting location for parameter ${(D=g.name)!==null&&D!==void 0?D: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 Gs(`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=Fe.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!Fe.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?Fe.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=Fe.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=Fe.unwrapChained(e),s=Fe.getMetadata(e),i=Fe.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?Fe.applySchemaMetadata(a,s.metadata):rs(a,ui)}constructReferencedOpenAPISchema(e){var t;const n=Fe.getMetadata(e),s=Fe.unwrapChained(e),i=Fe.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=Fe.getMetadata(e),s=Fe.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=rs(Fe.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||Iu(f,i[m]));if(o.type)return{allOf:[a,o]};const c=rs(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||Iu(f,i[m])),u=Fe.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=Fe.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=Qs(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=Js(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=Js(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=Js(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=Js(()=>{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 _e(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=Qs(e,["method","path","request","responses"]),o=li(i,m=>this.getResponse(m)),c=Js(()=>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=Qs(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=_e(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 li(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return li(e,t=>{if(!t||!$g(t.schema))return t;const{schema:n}=t,s=Qs(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 s0{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=Vg(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 i0{constructor(e){const t=new s0;this.generator=new _p(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class a0{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 o0(r){return"type"in r&&r.type==="webhook"}class c0{constructor(e){this.definitions=e,this.webhookRefs={};const t=new a0;this.generator=new _p(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(o0).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 wp=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},u0=r=>{const{groups:e,path:t}=l0(r),n=wp(t);return d0(n,e)},l0=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},d0=(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},Ha={},kf=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(Ha[r]||(e[2]?Ha[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:Ha[r]=[r,e[1],!0]),Ha[r]):null},f0=r=>{try{return decodeURI(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURI(e)}catch{return e}})}},kp=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 f0(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},h0=r=>{const e=kp(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},Fr=(...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},Sp=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)},lu=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),/%/.test(r)?ao(r):r):r,Ap=(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 lu(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=lu(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=lu(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},p0=Ap,m0=(r,e)=>Ap(r,e,!0),ao=decodeURIComponent,y0=/^[\w!#$%&'*.^`|~+-]+$/,g0=/^[ !#-:<-[\]-~]*$/,v0=(r,e)=>r.trim().split(";").reduce((n,s)=>{s=s.trim();const i=s.indexOf("=");if(i===-1)return n;const a=s.substring(0,i).trim();if(!y0.test(a))return n;let o=s.substring(i+1).trim();return o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),g0.test(o)&&(n[a]=ao(o)),n},{}),b0=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?v0(n):{}},Ue=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});K(this,"res");K(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})}},x0=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),_0=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,w0=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,k0=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,S0=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!_0.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new Ue(400,{message:o})}break;case"form":{if(!i||!(w0.test(i)||k0.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 x0(u,i),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new Ue(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=b0(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const Hn=(r,e,t)=>S0(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 A0=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof Op?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")?O0(r,{all:t,dot:n}):{}};async function O0(r,e){const t=await r.formData();return t?E0(t,e):{}}function E0(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?I0(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(C0(t,n,s),delete t[n])}),t}var I0=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},C0=(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])})},os,zt,gp,Op=(gp=class{constructor(r,e="/",t=[[]]){K(this,"raw");at(this,os);at(this,zt);K(this,"routeIndex",0);K(this,"path");K(this,"bodyCache",{});K(this,"cachedBody",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,je(this,zt,t),je(this,os,{})}param(r){return r?this.getDecodedParam(r):this.getAllDecodedParams()}getDecodedParam(r){const e=V(this,zt)[0][this.routeIndex][1][r],t=this.getParamValue(e);return t?/\%/.test(t)?ao(t):t:void 0}getAllDecodedParams(){const r={},e=Object.keys(V(this,zt)[0][this.routeIndex][1]);for(const t of e){const n=this.getParamValue(V(this,zt)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?ao(n):n)}return r}getParamValue(r){return V(this,zt)[1]?V(this,zt)[1][r]:r}query(r){return p0(this.url,r)}queries(r){return m0(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 A0(this,r))}json(){return this.cachedBody("json")}text(){return this.cachedBody("text")}arrayBuffer(){return this.cachedBody("arrayBuffer")}blob(){return this.cachedBody("blob")}formData(){return this.cachedBody("formData")}addValidatedData(r,e){V(this,os)[r]=e}valid(r){return V(this,os)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return V(this,zt)[0].map(([[,r]])=>r)}get routePath(){return V(this,zt)[0].map(([[,r]])=>r)[this.routeIndex].path}},os=new WeakMap,zt=new WeakMap,gp),j0={Stringify:1,BeforeStream:2,Stream:3},Ep=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=>Ep(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},T0="text/plain; charset=UTF-8",du=(r,e={})=>(Object.entries(e).forEach(([t,n])=>r.set(t,n)),r),xa,_a,Er,xn,Ir,ze,Ye,cr,Cr,wa,cs,us,ka,Sa,vp,Ja=(vp=class{constructor(r,e){at(this,xa);at(this,_a);K(this,"env",{});at(this,Er);K(this,"finalized",!1);K(this,"error");at(this,xn,200);at(this,Ir);at(this,ze);at(this,Ye);at(this,cr);at(this,Cr,!0);at(this,wa);at(this,cs);at(this,us);at(this,ka);at(this,Sa);K(this,"render",(...r)=>(V(this,cs)??je(this,cs,e=>this.html(e)),V(this,cs).call(this,...r)));K(this,"setLayout",r=>je(this,wa,r));K(this,"getLayout",()=>V(this,wa));K(this,"setRenderer",r=>{je(this,cs,r)});K(this,"header",(r,e,t)=>{if(e===void 0){V(this,ze)?V(this,ze).delete(r):V(this,Ye)&&delete V(this,Ye)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(V(this,ze)||(je(this,Cr,!1),je(this,ze,new Headers(V(this,Ye))),je(this,Ye,{})),V(this,ze).append(r,e)):V(this,ze)?V(this,ze).set(r,e):(V(this,Ye)??je(this,Ye,{}),V(this,Ye)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});K(this,"status",r=>{je(this,Cr,!1),je(this,xn,r)});K(this,"set",(r,e)=>{V(this,Er)??je(this,Er,new Map),V(this,Er).set(r,e)});K(this,"get",r=>V(this,Er)?V(this,Er).get(r):void 0);K(this,"newResponse",(r,e,t)=>{if(V(this,Cr)&&!t&&!e&&V(this,xn)===200)return new Response(r,{headers:V(this,Ye)});if(e&&typeof e!="number"){const s=new Headers(e.headers);V(this,ze)&&V(this,ze).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=du(s,V(this,Ye));return new Response(r,{headers:i,status:e.status??V(this,xn)})}const n=typeof e=="number"?e:V(this,xn);V(this,Ye)??je(this,Ye,{}),V(this,ze)??je(this,ze,new Headers),du(V(this,ze),V(this,Ye)),V(this,cr)&&(V(this,cr).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=V(this,ze))==null||a.append(i,s):(o=V(this,ze))==null||o.set(i,s)}),du(V(this,ze),V(this,Ye))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")V(this,ze).set(s,i);else{V(this,ze).delete(s);for(const a of i)V(this,ze).append(s,a)}return new Response(r,{status:n,headers:V(this,ze)})});K(this,"body",(r,e,t)=>typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e));K(this,"text",(r,e,t)=>{if(!V(this,Ye)){if(V(this,Cr)&&!t&&!e)return new Response(r);je(this,Ye,{})}return V(this,Ye)["content-type"]=T0,typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)});K(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return V(this,Ye)??je(this,Ye,{}),V(this,Ye)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)});K(this,"html",(r,e,t)=>(V(this,Ye)??je(this,Ye,{}),V(this,Ye)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Ep(r,j0.Stringify,!1,{}).then(n=>typeof e=="number"?this.newResponse(n,e,t):this.newResponse(n,e)):typeof e=="number"?this.newResponse(r,e,t):this.newResponse(r,e)));K(this,"redirect",(r,e)=>(V(this,ze)??je(this,ze,new Headers),V(this,ze).set("Location",r),this.newResponse(null,e??302)));K(this,"notFound",()=>(V(this,us)??je(this,us,()=>new Response),V(this,us).call(this,this)));je(this,xa,r),e&&(je(this,Ir,e.executionCtx),this.env=e.env,je(this,us,e.notFoundHandler),je(this,Sa,e.path),je(this,ka,e.matchResult))}get req(){return V(this,_a)??je(this,_a,new Op(V(this,xa),V(this,Sa),V(this,ka))),V(this,_a)}get event(){if(V(this,Ir)&&"respondWith"in V(this,Ir))return V(this,Ir);throw Error("This context has no FetchEvent")}get executionCtx(){if(V(this,Ir))return V(this,Ir);throw Error("This context has no ExecutionContext")}get res(){return je(this,Cr,!1),V(this,cr)||je(this,cr,new Response("404 Not Found",{status:404}))}set res(r){if(je(this,Cr,!1),V(this,cr)&&r)try{for(const[e,t]of V(this,cr).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=V(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}je(this,cr,r),this.finalized=!0}get var(){return V(this,Er)?Object.fromEntries(V(this,Er)):{}}},xa=new WeakMap,_a=new WeakMap,Er=new WeakMap,xn=new WeakMap,Ir=new WeakMap,ze=new WeakMap,Ye=new WeakMap,cr=new WeakMap,Cr=new WeakMap,wa=new WeakMap,cs=new WeakMap,us=new WeakMap,ka=new WeakMap,Sa=new WeakMap,vp),Sf=(r,e,t)=>(n,s)=>{let i=-1;return a(0);async function a(o){if(o<=i)throw new Error("next() called multiple times");i=o;let c,u=!1,f;if(r[o]?(f=r[o][0][0],n instanceof Ja&&(n.req.routeIndex=o)):f=o===r.length&&s||void 0,!f)n instanceof Ja&&n.finalized===!1&&t&&(c=await t(n));else try{c=await f(n,()=>a(o+1))}catch(m){if(m instanceof Error&&n instanceof Ja&&e)n.error=m,c=await e(m,n),u=!0;else throw m}return c&&(n.finalized===!1||u)&&(n.res=c),n}},tt="ALL",N0="all",B0=["get","post","put","delete","options","patch"],Ip="Can not add a route since the matcher is already built.",Cp=class extends Error{},R0=Symbol("composedHandler"),P0=r=>r.text("404 Not Found",404),Af=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),Kt,bp,jp=(bp=class{constructor(e={}){K(this,"get");K(this,"post");K(this,"put");K(this,"delete");K(this,"options");K(this,"patch");K(this,"all");K(this,"on");K(this,"use");K(this,"router");K(this,"getPath");K(this,"_basePath","/");at(this,Kt,"/");K(this,"routes",[]);K(this,"notFoundHandler",P0);K(this,"errorHandler",Af);K(this,"onError",e=>(this.errorHandler=e,this));K(this,"notFound",e=>(this.notFoundHandler=e,this));K(this,"fetch",(e,...t)=>this.dispatch(e,t[1],t[0],e.method));K(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${Fr("/",e)}`,a=new Request(i,t);return this.fetch(a,n,s)});K(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(this.dispatch(e.request,e,void 0,e.request.method))})});[...B0,N0].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?je(this,Kt,i):this.addRoute(s,V(this,Kt),i),a.forEach(o=>{typeof o!="string"&&this.addRoute(s,V(this,Kt),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){je(this,Kt,o);for(const c of[s].flat())a.map(u=>{this.addRoute(c.toUpperCase(),V(this,Kt),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?je(this,Kt,s):(je(this,Kt,"*"),i.unshift(s)),i.forEach(a=>{this.addRoute(tt,V(this,Kt),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??kp:h0}clone(){const e=new jp({router:this.router,getPath:this.getPath});return e.routes=this.routes,e}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{let i;t.errorHandler===Af?i=s.handler:(i=async(a,o)=>(await Sf([],t.errorHandler)(a,()=>s.handler(a,o))).res,i[R0]=s.handler),n.addRoute(s.method,s.path,i)}),this}basePath(e){const t=this.clone();return t._basePath=Fr(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=Fr(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 this.addRoute(tt,Fr(e,"*"),o),this}addRoute(e,t,n){e=e.toUpperCase(),t=Fr(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)}matchRoute(e,t){return this.router.match(e,t)}handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}dispatch(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await this.dispatch(e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.matchRoute(s,i),o=new Ja(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:this.notFoundHandler});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await this.notFoundHandler(o)})}catch(f){return this.handleError(f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:this.notFoundHandler(o))).catch(f=>this.handleError(f,o)):u??this.notFoundHandler(o)}const c=Sf(a[0],this.errorHandler,this.notFoundHandler);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 this.handleError(u,o)}})()}},Kt=new WeakMap,bp),oo="[^/]+",di=".*",fi="(?:|/.*)",ei=Symbol(),$0=new Set(".\\+*[^]$()");function Z0(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===di||r===fi?1:e===di||e===fi?-1:r===oo?1:e===oo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Cu=class{constructor(){K(this,"index");K(this,"varIndex");K(this,"children",Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(this.index!==void 0)throw ei;if(i)return;this.index=t;return}const[a,...o]=e,c=a==="*"?o.length===0?["","",di]:["","",oo]:a==="/*"?["","",fi]: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 ei;if(u=this.children[m],!u){if(Object.keys(this.children).some(D=>D!==di&&D!==fi))throw ei;if(i)return;u=this.children[m]=new Cu,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!==di&&f!==fi))throw ei;if(i)return;u=this.children[a]=new Cu}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(this.children).sort(Z0).map(n=>{const s=this.children[n];return(typeof s.varIndex=="number"?`(${n})@${s.varIndex}`:$0.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("|")+")"}},D0=class{constructor(){K(this,"context",{varIndex:0});K(this,"root",new Cu)}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)=>typeof i<"u"?(t[++e]=Number(i),"$()"):(typeof a<"u"&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},Tp=[],M0=[/^$/,[],Object.create(null)],Ya=Object.create(null);function Np(r){return Ya[r]??(Ya[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function V0(){Ya=Object.create(null)}function U0(r){var u;const e=new D0,t=[];if(r.length===0)return M0;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[D,j])=>f?1:D?-1:m.length-j.length),s=Object.create(null);for(let f=0,m=-1,D=n.length;f<D;f++){const[j,p,g]=n[f];j?s[p]=[g.map(([S])=>[S,Object.create(null)]),Tp]:m++;let A;try{A=e.insert(p,m,j)}catch(S){throw S===ei?new Cp(p):S}j||(t[m]=g.map(([S,B])=>{const T=Object.create(null);for(B-=1;B>=0;B--){const[ye,Me]=A[B];T[ye]=Me}return[S,T]}))}const[i,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let D=0,j=t[f].length;D<j;D++){const p=(u=t[f][D])==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 Fn(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(Np(t).test(e))return[...r[t]]}}var L0=class{constructor(){K(this,"name","RegExpRouter");K(this,"middleware");K(this,"routes");this.middleware={[tt]:Object.create(null)},this.routes={[tt]:Object.create(null)}}add(r,e,t){var o;const{middleware:n,routes:s}=this;if(!n||!s)throw new Error(Ip);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[tt]).forEach(u=>{c[r][u]=[...c[tt][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Np(e);r===tt?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=Fn(n[u],e)||Fn(n[tt],e)||[])}):(o=n[r])[e]||(o[e]=Fn(n[r],e)||Fn(n[tt],e)||[]),Object.keys(n).forEach(u=>{(r===tt||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,i])})}),Object.keys(s).forEach(u=>{(r===tt||r===u)&&Object.keys(s[u]).forEach(f=>c.test(f)&&s[u][f].push([t,i]))});return}const a=Sp(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(s).forEach(m=>{var D;(r===tt||r===m)&&((D=s[m])[f]||(D[f]=[...Fn(n[m],f)||Fn(n[tt],f)||[]]),s[m][f].push([t,i-u+c+1]))})}}match(r,e){V0();const t=this.buildAllMatchers();return this.match=(n,s)=>{const i=t[n]||t[tt],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],Tp];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}buildAllMatchers(){const r=Object.create(null);return[...Object.keys(this.routes),...Object.keys(this.middleware)].forEach(e=>{r[e]||(r[e]=this.buildMatcher(e))}),this.middleware=this.routes=void 0,r}buildMatcher(r){const e=[];let t=r===tt;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!==tt&&e.push(...Object.keys(n[tt]).map(i=>[i,n[tt][i]]))}),t?U0(e):null}},q0=class{constructor(r){K(this,"name","SmartRouter");K(this,"routers",[]);K(this,"routes",[]);Object.assign(this,r)}add(r,e,t){if(!this.routes)throw new Error(Ip);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 Cp)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]}},Bp=class{constructor(r,e,t){K(this,"methods");K(this,"children");K(this,"patterns");K(this,"order",0);K(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=u0(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 D=kf(f);D&&i.push(D[1]);continue}n.children[f]=new Bp;const m=kf(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}gHSets(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[tt],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 D=c.possibleKeys[f],j=u[c.score];c.params[D]=n[D]&&!j?n[D]:t[D]??n[D],u[c.score]=!0}s.push(c)}}return s}search(r,e){const t=[];this.params=Object.create(null);let s=[this];const i=wp(e);for(let o=0,c=i.length;o<c;o++){const u=i[o],f=o===c-1,m=[];for(let D=0,j=s.length;D<j;D++){const p=s[D],g=p.children[u];g&&(g.params=p.params,f?(g.children["*"]&&t.push(...this.gHSets(g.children["*"],r,p.params,Object.create(null))),t.push(...this.gHSets(g,r,p.params,Object.create(null)))):m.push(g));for(let A=0,S=p.patterns.length;A<S;A++){const B=p.patterns[A],T={...p.params};if(B==="*"){const lt=p.children["*"];lt&&(t.push(...this.gHSets(lt,r,p.params,Object.create(null))),m.push(lt));continue}if(u==="")continue;const[ye,Me,Ve]=B,Pe=p.children[ye],Xe=i.slice(o).join("/");if(Ve instanceof RegExp&&Ve.test(Xe)){T[Me]=Xe,t.push(...this.gHSets(Pe,r,p.params,T));continue}(Ve===!0||Ve.test(u))&&typeof ye=="string"&&(T[Me]=u,f?(t.push(...this.gHSets(Pe,r,T,p.params)),Pe.children["*"]&&t.push(...this.gHSets(Pe.children["*"],r,T,p.params))):(Pe.params=T,m.push(Pe)))}}s=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},H0=class{constructor(){K(this,"name","TrieRouter");K(this,"node");this.node=new Bp}add(r,e,t){const n=Sp(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)}},F0=class extends jp{constructor(r={}){super(r),this.router=r.router??new q0({routers:[new L0,new H0]})}},Te;(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})(Te||(Te={}));var ju;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(ju||(ju={}));const G=Te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Wr=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}},P=Te.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"]),W0=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Yt=class Rp 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 Rp))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Te.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 ls=(r,e)=>{let t;switch(r.code){case P.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case P.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Te.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:t=`Unrecognized key(s) in object: ${Te.joinValues(r.keys,", ")}`;break;case P.invalid_union:t="Invalid input";break;case P.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Te.joinValues(r.options)}`;break;case P.invalid_enum_value:t=`Invalid enum value. Expected ${Te.joinValues(r.options)}, received '${r.received}'`;break;case P.invalid_arguments:t="Invalid function arguments";break;case P.invalid_return_type:t="Invalid function return type";break;case P.invalid_date:t="Invalid date";break;case P.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}"`:Te.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case P.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 P.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 P.custom:t="Invalid input";break;case P.invalid_intersection_types:t="Intersection results could not be merged";break;case P.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case P.not_finite:t="Number must be finite";break;default:t=e.defaultError,Te.assertNever(r)}return{message:t}};let Pp=ls;function z0(r){Pp=r}function co(){return Pp}const uo=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}},K0=[];function q(r,e){const t=co(),n=uo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ls?void 0:ls].filter(s=>!!s)});r.common.issues.push(n)}let St=class $p{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 he;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 $p.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 he;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 he=Object.freeze({status:"aborted"}),Yn=r=>({status:"dirty",value:r}),yt=r=>({status:"valid",value:r}),Tu=r=>r.status==="aborted",Nu=r=>r.status==="dirty",vi=r=>r.status==="valid",bi=r=>typeof Promise<"u"&&r instanceof Promise;function lo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Zp(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 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 ti,ri;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 Of=(r,e)=>{if(vi(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 ve(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 Wr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Wr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new St,ctx:{common:e.parent.common,data:e.data,parsedType:Wr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(bi(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:Wr(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Of(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:Wr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(bi(s)?s:Promise.resolve(s));return Of(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:P.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 er({schema:this,typeName:le.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return lr.create(this,this._def)}nullable(){return tn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return On.create(this,this._def)}promise(){return hs.create(this,this._def)}or(e){return Oi.create([this,e],this._def)}and(e){return Ei.create(this,e,this._def)}transform(e){return new er({...ve(this._def),schema:this,typeName:le.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ti({...ve(this._def),innerType:this,defaultValue:t,typeName:le.ZodDefault})}brand(){return new gd({typeName:le.ZodBranded,type:this,...ve(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ni({...ve(this._def),innerType:this,catchValue:t,typeName:le.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return vd.create(this,e)}readonly(){return Bi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const G0=/^c[^\s-]{8,}$/i,J0=/^[0-9a-z]+$/,Y0=/^[0-9A-HJKMNP-TV-Z]{26}$/,X0=/^[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,Q0=/^[a-z0-9_-]{21}$/i,ev=/^[-+]?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)?)??$/,tv=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let fu;const nv=/^(?:(?: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])$/,sv=/^(([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})))$/,iv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dp="((\\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])))",av=new RegExp(`^${Dp}$`);function Mp(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 ov(r){return new RegExp(`^${Mp(r)}$`)}function Vp(r){let e=`${Dp}T${Mp(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 cv(r,e){return!!((e==="v4"||!e)&&nv.test(r)||(e==="v6"||!e)&&sv.test(r))}let ds=class ni extends we{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const i=this._getOrReturnCtx(e);return q(i,{code:P.invalid_type,expected:G.string,received:i.parsedType}),he}const n=new St;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:P.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:P.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:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&q(s,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")tv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"email",code:P.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")fu||(fu=new RegExp(rv,"u")),fu.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"emoji",code:P.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")X0.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"uuid",code:P.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Q0.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"nanoid",code:P.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")G0.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"cuid",code:P.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")J0.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"cuid2",code:P.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Y0.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"ulid",code:P.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:P.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:P.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:P.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:P.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:P.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Vp(i).test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{code:P.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?av.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{code:P.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?ov(i).test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{code:P.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?ev.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"duration",code:P.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?cv(e.data,i.version)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"ip",code:P.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?iv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"base64",code:P.invalid_string,message:i.message}),n.dirty()):Te.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:P.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new ni({...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 ni({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ni({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ni({...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}};ds.create=r=>{var e;return new ds({checks:[],typeName:le.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ve(r)})};function uv(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 xi=class Bu 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 q(i,{code:P.invalid_type,expected:G.number,received:i.parsedType}),he}let n;const s=new St;for(const i of this._def.checks)i.kind==="int"?Te.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:P.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:P.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:P.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?uv(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),q(n,{code:P.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:P.not_finite,message:i.message}),s.dirty()):Te.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 Bu({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new Bu({...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"&&Te.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)}};xi.create=r=>new xi({checks:[],typeName:le.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ve(r)});let _i=class Ru 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 q(i,{code:P.invalid_type,expected:G.bigint,received:i.parsedType}),he}let n;const s=new St;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:P.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:P.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:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Te.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 Ru({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new Ru({...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}};_i.create=r=>{var e;return new _i({checks:[],typeName:le.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ve(r)})};let wi=class extends we{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const n=this._getOrReturnCtx(e);return q(n,{code:P.invalid_type,expected:G.boolean,received:n.parsedType}),he}return yt(e.data)}};wi.create=r=>new wi({typeName:le.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ve(r)});let ki=class Up 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 q(i,{code:P.invalid_type,expected:G.date,received:i.parsedType}),he}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return q(i,{code:P.invalid_date}),he}const n=new St;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:P.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:P.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Te.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Up({...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}};ki.create=r=>new ki({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:le.ZodDate,...ve(r)});let fo=class extends we{_parse(e){if(this._getType(e)!==G.symbol){const n=this._getOrReturnCtx(e);return q(n,{code:P.invalid_type,expected:G.symbol,received:n.parsedType}),he}return yt(e.data)}};fo.create=r=>new fo({typeName:le.ZodSymbol,...ve(r)});let Si=class extends we{_parse(e){if(this._getType(e)!==G.undefined){const n=this._getOrReturnCtx(e);return q(n,{code:P.invalid_type,expected:G.undefined,received:n.parsedType}),he}return yt(e.data)}};Si.create=r=>new Si({typeName:le.ZodUndefined,...ve(r)});let Ai=class extends we{_parse(e){if(this._getType(e)!==G.null){const n=this._getOrReturnCtx(e);return q(n,{code:P.invalid_type,expected:G.null,received:n.parsedType}),he}return yt(e.data)}};Ai.create=r=>new Ai({typeName:le.ZodNull,...ve(r)});let fs=class extends we{constructor(){super(...arguments),this._any=!0}_parse(e){return yt(e.data)}};fs.create=r=>new fs({typeName:le.ZodAny,...ve(r)});let _n=class extends we{constructor(){super(...arguments),this._unknown=!0}_parse(e){return yt(e.data)}};_n.create=r=>new _n({typeName:le.ZodUnknown,...ve(r)});let Br=class extends we{_parse(e){const t=this._getOrReturnCtx(e);return q(t,{code:P.invalid_type,expected:G.never,received:t.parsedType}),he}};Br.create=r=>new Br({typeName:le.ZodNever,...ve(r)});let ho=class extends we{_parse(e){if(this._getType(e)!==G.undefined){const n=this._getOrReturnCtx(e);return q(n,{code:P.invalid_type,expected:G.void,received:n.parsedType}),he}return yt(e.data)}};ho.create=r=>new ho({typeName:le.ZodVoid,...ve(r)});let On=class Xa extends we{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==G.array)return q(t,{code:P.invalid_type,expected:G.array,received:t.parsedType}),he;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?P.too_big:P.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:P.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:P.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=>St.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new mr(t,a,t.path,o)));return St.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Xa({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new Xa({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new Xa({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};On.create=(r,e)=>new On({type:r,minLength:null,maxLength:null,exactLength:null,typeName:le.ZodArray,...ve(e)});function Kn(r){if(r instanceof Dt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=lr.create(Kn(n))}return new Dt({...r._def,shape:()=>e})}else return r instanceof On?new On({...r._def,type:Kn(r.element)}):r instanceof lr?lr.create(Kn(r.unwrap())):r instanceof tn?tn.create(Kn(r.unwrap())):r instanceof en?en.create(r.items.map(e=>Kn(e))):r}let Dt=class Ht 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=Te.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const u=this._getOrReturnCtx(e);return q(u,{code:P.invalid_type,expected:G.object,received:u.parsedType}),he}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Br&&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 Br){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:P.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,D=await f.value;u.push({key:m,value:D,alwaysSet:f.alwaysSet})}return u}).then(u=>St.mergeObjectSync(n,u)):St.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Ht({...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 Ht({...this._def,unknownKeys:"strip"})}passthrough(){return new Ht({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ht({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ht({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:le.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ht({...this._def,catchall:e})}pick(e){const t={};return Te.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ht({...this._def,shape:()=>t})}omit(e){const t={};return Te.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ht({...this._def,shape:()=>t})}deepPartial(){return Kn(this)}partial(e){const t={};return Te.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Ht({...this._def,shape:()=>t})}required(e){const t={};return Te.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof lr;)i=i._def.innerType;t[n]=i}}),new Ht({...this._def,shape:()=>t})}keyof(){return zp(Te.objectKeys(this.shape))}};Dt.create=(r,e)=>new Dt({shape:()=>r,unknownKeys:"strip",catchall:Br.create(),typeName:le.ZodObject,...ve(e)});Dt.strictCreate=(r,e)=>new Dt({shape:()=>r,unknownKeys:"strict",catchall:Br.create(),typeName:le.ZodObject,...ve(e)});Dt.lazycreate=(r,e)=>new Dt({shape:r,unknownKeys:"strip",catchall:Br.create(),typeName:le.ZodObject,...ve(e)});let Oi=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 q(t,{code:P.invalid_union,unionErrors:a}),he}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 q(t,{code:P.invalid_union,unionErrors:o}),he}}get options(){return this._def.options}};Oi.create=(r,e)=>new Oi({options:r,typeName:le.ZodUnion,...ve(e)});const Sr=r=>r instanceof Ii?Sr(r.schema):r instanceof er?Sr(r.innerType()):r instanceof Ci?[r.value]:r instanceof Aa?r.options:r instanceof ji?Te.objectValues(r.enum):r instanceof Ti?Sr(r._def.innerType):r instanceof Si?[void 0]:r instanceof Ai?[null]:r instanceof lr?[void 0,...Sr(r.unwrap())]:r instanceof tn?[null,...Sr(r.unwrap())]:r instanceof gd||r instanceof Bi?Sr(r.unwrap()):r instanceof Ni?Sr(r._def.innerType):[];let Lp=class qp extends we{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return q(t,{code:P.invalid_type,expected:G.object,received:t.parsedType}),he;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:P.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),he)}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=Sr(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 qp({typeName:le.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ve(n)})}};function Pu(r,e){const t=Wr(r),n=Wr(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const s=Te.objectKeys(e),i=Te.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Pu(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=Pu(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 Ei=class extends we{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Tu(i)||Tu(a))return he;const o=Pu(i.value,a.value);return o.valid?((Nu(i)||Nu(a))&&t.dirty(),{status:t.value,value:o.data}):(q(n,{code:P.invalid_intersection_types}),he)};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}))}};Ei.create=(r,e,t)=>new Ei({left:r,right:e,typeName:le.ZodIntersection,...ve(t)});let en=class Hp extends we{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return q(n,{code:P.invalid_type,expected:G.array,received:n.parsedType}),he;if(n.data.length<this._def.items.length)return q(n,{code:P.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),he;!this._def.rest&&n.data.length>this._def.items.length&&(q(n,{code:P.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=>St.mergeArray(t,a)):St.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Hp({...this._def,rest:e})}};en.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new en({items:r,typeName:le.ZodTuple,rest:null,...ve(e)})};let Fp=class $u 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 q(n,{code:P.invalid_type,expected:G.object,received:n.parsedType}),he;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?St.mergeObjectAsync(t,s):St.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof we?new $u({keyType:e,valueType:t,typeName:le.ZodRecord,...ve(n)}):new $u({keyType:ds.create(),valueType:e,typeName:le.ZodRecord,...ve(t)})}},po=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 q(n,{code:P.invalid_type,expected:G.map,received:n.parsedType}),he;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 he;(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 he;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};po.create=(r,e,t)=>new po({valueType:e,keyType:r,typeName:le.ZodMap,...ve(t)});let mo=class Zu extends we{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return q(n,{code:P.invalid_type,expected:G.set,received:n.parsedType}),he;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(q(n,{code:P.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:P.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 he;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 Zu({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Zu({...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)}};mo.create=(r,e)=>new mo({valueType:r,minSize:null,maxSize:null,typeName:le.ZodSet,...ve(e)});let Wp=class Qa extends we{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return q(t,{code:P.invalid_type,expected:G.function,received:t.parsedType}),he;function n(o,c){return uo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,co(),ls].filter(u=>!!u),issueData:{code:P.invalid_arguments,argumentsError:c}})}function s(o,c){return uo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,co(),ls].filter(u=>!!u),issueData:{code:P.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof hs){const o=this;return yt(async function(...c){const u=new Yt([]),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 yt(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 Qa({...this._def,args:en.create(e).rest(_n.create())})}returns(e){return new Qa({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Qa({args:e||en.create([]).rest(_n.create()),returns:t||_n.create(),typeName:le.ZodFunction,...ve(n)})}},Ii=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})}};Ii.create=(r,e)=>new Ii({getter:r,typeName:le.ZodLazy,...ve(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:P.invalid_literal,expected:this._def.value}),he}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ci.create=(r,e)=>new Ci({value:r,typeName:le.ZodLiteral,...ve(e)});function zp(r,e){return new Aa({values:r,typeName:le.ZodEnum,...ve(e)})}let Aa=class Du extends we{constructor(){super(...arguments),ti.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{expected:Te.joinValues(n),received:t.parsedType,code:P.invalid_type}),he}if(lo(this,ti)||Zp(this,ti,new Set(this._def.values)),!lo(this,ti).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{received:t.data,code:P.invalid_enum_value,options:n}),he}return yt(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 Du.create(e,{...this._def,...t})}exclude(e,t=this._def){return Du.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};ti=new WeakMap;Aa.create=zp;let ji=class extends we{constructor(){super(...arguments),ri.set(this,void 0)}_parse(e){const t=Te.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const s=Te.objectValues(t);return q(n,{expected:Te.joinValues(s),received:n.parsedType,code:P.invalid_type}),he}if(lo(this,ri)||Zp(this,ri,new Set(Te.getValidEnumValues(this._def.values))),!lo(this,ri).has(e.data)){const s=Te.objectValues(t);return q(n,{received:n.data,code:P.invalid_enum_value,options:s}),he}return yt(e.data)}get enum(){return this._def.values}};ri=new WeakMap;ji.create=(r,e)=>new ji({values:r,typeName:le.ZodNativeEnum,...ve(e)});let hs=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 q(t,{code:P.invalid_type,expected:G.promise,received:t.parsedType}),he;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return yt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};hs.create=(r,e)=>new hs({type:r,typeName:le.ZodPromise,...ve(e)});let er=class extends we{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===le.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 he;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?he:c.status==="dirty"||t.value==="dirty"?Yn(c.value):c});{if(t.value==="aborted")return he;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?he:o.status==="dirty"||t.value==="dirty"?Yn(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"?he:(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"?he:(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(!vi(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=>vi(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Te.assertNever(s)}};er.create=(r,e,t)=>new er({schema:r,typeName:le.ZodEffects,effect:e,...ve(t)});er.createWithPreprocess=(r,e,t)=>new er({schema:e,effect:{type:"preprocess",transform:r},typeName:le.ZodEffects,...ve(t)});let lr=class extends we{_parse(e){return this._getType(e)===G.undefined?yt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};lr.create=(r,e)=>new lr({innerType:r,typeName:le.ZodOptional,...ve(e)});let tn=class extends we{_parse(e){return this._getType(e)===G.null?yt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};tn.create=(r,e)=>new tn({innerType:r,typeName:le.ZodNullable,...ve(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:le.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ve(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 bi(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:le.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ve(e)});let yo=class extends we{_parse(e){if(this._getType(e)!==G.nan){const n=this._getOrReturnCtx(e);return q(n,{code:P.invalid_type,expected:G.nan,received:n.parsedType}),he}return{status:"valid",value:e.data}}};yo.create=r=>new yo({typeName:le.ZodNaN,...ve(r)});const lv=Symbol("zod_brand");let gd=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}},vd=class Kp 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"?he:i.status==="dirty"?(t.dirty(),Yn(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"?he: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 Kp({in:e,out:t,typeName:le.ZodPipeline})}},Bi=class extends we{_parse(e){const t=this._def.innerType._parse(e),n=s=>(vi(s)&&(s.value=Object.freeze(s.value)),s);return bi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};Bi.create=(r,e)=>new Bi({innerType:r,typeName:le.ZodReadonly,...ve(e)});function Gp(r,e={},t){return r?fs.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})}}):fs.create()}const dv={object:Dt.lazycreate};var le;(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"})(le||(le={}));const fv=(r,e={message:`Input not instance of ${r.name}`})=>Gp(t=>t instanceof r,e),Jp=ds.create,Yp=xi.create,hv=yo.create,pv=_i.create,Xp=wi.create,mv=ki.create,yv=fo.create,gv=Si.create,vv=Ai.create,bv=fs.create,xv=_n.create,_v=Br.create,wv=ho.create,kv=On.create,Sv=Dt.create,Av=Dt.strictCreate,Ov=Oi.create,Ev=Lp.create,Iv=Ei.create,Cv=en.create,jv=Fp.create,Tv=po.create,Nv=mo.create,Bv=Wp.create,Rv=Ii.create,Pv=Ci.create,$v=Aa.create,Zv=ji.create,Dv=hs.create,Ef=er.create,Mv=lr.create,Vv=tn.create,Uv=er.createWithPreprocess,Lv=vd.create,qv=()=>Jp().optional(),Hv=()=>Yp().optional(),Fv=()=>Xp().optional(),Wv={string:r=>ds.create({...r,coerce:!0}),number:r=>xi.create({...r,coerce:!0}),boolean:r=>wi.create({...r,coerce:!0}),bigint:r=>_i.create({...r,coerce:!0}),date:r=>ki.create({...r,coerce:!0})},zv=he;var _=Object.freeze({__proto__:null,defaultErrorMap:ls,setErrorMap:z0,getErrorMap:co,makeIssue:uo,EMPTY_PATH:K0,addIssueToContext:q,ParseStatus:St,INVALID:he,DIRTY:Yn,OK:yt,isAborted:Tu,isDirty:Nu,isValid:vi,isAsync:bi,get util(){return Te},get objectUtil(){return ju},ZodParsedType:G,getParsedType:Wr,ZodType:we,datetimeRegex:Vp,ZodString:ds,ZodNumber:xi,ZodBigInt:_i,ZodBoolean:wi,ZodDate:ki,ZodSymbol:fo,ZodUndefined:Si,ZodNull:Ai,ZodAny:fs,ZodUnknown:_n,ZodNever:Br,ZodVoid:ho,ZodArray:On,ZodObject:Dt,ZodUnion:Oi,ZodDiscriminatedUnion:Lp,ZodIntersection:Ei,ZodTuple:en,ZodRecord:Fp,ZodMap:po,ZodSet:mo,ZodFunction:Wp,ZodLazy:Ii,ZodLiteral:Ci,ZodEnum:Aa,ZodNativeEnum:ji,ZodPromise:hs,ZodEffects:er,ZodTransformer:er,ZodOptional:lr,ZodNullable:tn,ZodDefault:Ti,ZodCatch:Ni,ZodNaN:yo,BRAND:lv,ZodBranded:gd,ZodPipeline:vd,ZodReadonly:Bi,custom:Gp,Schema:we,ZodSchema:we,late:dv,get ZodFirstPartyTypeKind(){return le},coerce:Wv,any:bv,array:kv,bigint:pv,boolean:Xp,date:mv,discriminatedUnion:Ev,effect:Ef,enum:$v,function:Bv,instanceof:fv,intersection:Iv,lazy:Rv,literal:Pv,map:Tv,nan:hv,nativeEnum:Zv,never:_v,null:vv,nullable:Vv,number:Yp,object:Sv,oboolean:Fv,onumber:Hv,optional:Mv,ostring:qv,pipeline:Lv,preprocess:Uv,promise:Dv,record:jv,set:Nv,strictObject:Av,string:Jp,symbol:yv,transformer:Ef,tuple:Cv,undefined:gv,union:Ov,unknown:xv,void:wv,NEVER:zv,ZodIssueCode:P,quotelessJson:W0,ZodError:Yt}),Bt=class Mu extends F0{constructor(t){super(t);K(this,"openAPIRegistry");K(this,"defaultHook");K(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var u,f,m,D,j,p,g,A,S,B;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const T=Hn("query",n.request.query,i);a.push(T)}if((f=n.request)!=null&&f.params){const T=Hn("param",n.request.params,i);a.push(T)}if((m=n.request)!=null&&m.headers){const T=Hn("header",n.request.headers,i);a.push(T)}if((D=n.request)!=null&&D.cookies){const T=Hn("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 ye=o[T].schema;if(ye instanceof we){if(Cf(T)){const Me=Hn("json",ye,i);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Me);else{const Ve=async(Pe,Xe)=>{if(Pe.req.header("content-type")&&Cf(Pe.req.header("content-type")))return await Me(Pe,Xe);Pe.req.addValidatedData("json",{}),await Xe()};a.push(Ve)}}if(jf(T)){const Me=Hn("form",ye,i);if((B=(S=n.request)==null?void 0:S.body)!=null&&B.required)a.push(Me);else{const Ve=async(Pe,Xe)=>{if(Pe.req.header("content-type")&&jf(Pe.req.header("content-type")))return await Me(Pe,Xe);Pe.req.addValidatedData("form",{}),await Xe()};a.push(Ve)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,s),this});K(this,"getOpenAPIDocument",t=>{const s=new i0(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?If(s,this._basePath):s});K(this,"getOpenAPI31Document",t=>{const s=new c0(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?If(s,this._basePath):s});K(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)}}));K(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 Ug,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Mu?(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:Fr(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:Fr(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 Mu({...super.basePath(t),defaultHook:this.defaultHook})}},Ee=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};Zg(_);function If(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[Fr(e,n)]=r.paths[n]}),{...r,paths:t}}function Cf(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function jf(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function Kv(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 Gv(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function Ys(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 Jv(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const D=typeof s=="string"?i:s,j=D??{},{param:p}=j,g=Kv(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),B=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(Gv(this,"ZodObject")){const T=this.extend;B.extend=function(...ye){var Me,Ve,Pe,Xe,lt,It;const E=T.apply(this,ye);return E._def.openapi={_internal:{extendedFrom:!((Ve=(Me=this._def.openapi)===null||Me===void 0?void 0:Me._internal)===null||Ve===void 0)&&Ve.refId?{refId:(Xe=(Pe=this._def.openapi)===null||Pe===void 0?void 0:Pe._internal)===null||Xe===void 0?void 0:Xe.refId,schema:this}:(lt=this._def.openapi)===null||lt===void 0?void 0:lt._internal.extendedFrom},metadata:(It=E._def.openapi)===null||It===void 0?void 0:It.metadata},E}}return B},Ys(r,"optional"),Ys(r,"nullable"),Ys(r,"default"),Ys(r,"transform"),Ys(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 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 Vu;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Vu||(Vu={}));const J=Ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zr=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}},$=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"]),Yv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Tt 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 Tt))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()}}Tt.create=r=>new Tt(r);const ps=(r,e)=>{let t;switch(r.code){case $.invalid_type:r.received===J.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case $.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ne.jsonStringifyReplacer)}`;break;case $.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ne.joinValues(r.keys,", ")}`;break;case $.invalid_union:t="Invalid input";break;case $.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ne.joinValues(r.options)}`;break;case $.invalid_enum_value:t=`Invalid enum value. Expected ${Ne.joinValues(r.options)}, received '${r.received}'`;break;case $.invalid_arguments:t="Invalid function arguments";break;case $.invalid_return_type:t="Invalid function return type";break;case $.invalid_date:t="Invalid date";break;case $.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 $.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 $.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 $.custom:t="Invalid input";break;case $.invalid_intersection_types:t="Intersection results could not be merged";break;case $.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case $.not_finite:t="Number must be finite";break;default:t=e.defaultError,Ne.assertNever(r)}return{message:t}};let Qp=ps;function Xv(r){Qp=r}function go(){return Qp}const vo=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}},Qv=[];function H(r,e){const t=go(),n=vo({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 ft{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 ft.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"}),bo=r=>({status:"dirty",value:r}),gt=r=>({status:"valid",value:r}),Uu=r=>r.status==="aborted",Lu=r=>r.status==="dirty",Ri=r=>r.status==="valid",Pi=r=>typeof Promise<"u"&&r instanceof Promise;function xo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function em(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 si,ii;class yr{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 Tf=(r,e)=>{if(Ri(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 Tt(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:(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 zr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:zr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ft,ctx:{common:e.parent.common,data:e.data,parsedType:zr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Pi(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:zr(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Tf(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:zr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Pi(s)?s:Promise.resolve(s));return Tf(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:$.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:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return dr.create(this,this._def)}nullable(){return an.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xt.create(this,this._def)}promise(){return ys.create(this,this._def)}or(e){return Mi.create([this,e],this._def)}and(e){return Vi.create(this,e,this._def)}transform(e){return new tr({...be(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Fi({...be(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new bd({typeName:de.ZodBranded,type:this,...be(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Wi({...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 Oa.create(this,e)}readonly(){return zi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const eb=/^c[^\s-]{8,}$/i,tb=/^[0-9a-z]+$/,rb=/^[0-9A-HJKMNP-TV-Z]{26}$/,nb=/^[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,sb=/^[a-z0-9_-]{21}$/i,ib=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ab=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ob="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let hu;const cb=/^(?:(?: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])$/,ub=/^(([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})))$/,lb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,tm="((\\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])))",db=new RegExp(`^${tm}$`);function rm(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 fb(r){return new RegExp(`^${rm(r)}$`)}function nm(r){let e=`${tm}T${rm(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 hb(r,e){return!!((e==="v4"||!e)&&cb.test(r)||(e==="v6"||!e)&&ub.test(r))}class Gt extends ke{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const s=this._getOrReturnCtx(e);return H(s,{code:$.invalid_type,expected:J.string,received:s.parsedType}),me}const t=new ft;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:$.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:$.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:$.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&H(n,{code:$.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")ab.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"email",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")hu||(hu=new RegExp(ob,"u")),hu.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"emoji",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")nb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"uuid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")sb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"nanoid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")eb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cuid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")tb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cuid2",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")rb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"ulid",code:$.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:$.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:$.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:$.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:$.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:$.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?nm(s).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:$.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?db.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:$.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?fb(s).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:$.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?ib.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"duration",code:$.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?hb(e.data,s.version)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"ip",code:$.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?lb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"base64",code:$.invalid_string,message:s.message}),t.dirty()):Ne.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:$.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new Gt({...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 Gt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Gt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Gt({...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}}Gt.create=r=>{var e;return new Gt({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};function pb(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 rn 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)!==J.number){const s=this._getOrReturnCtx(e);return H(s,{code:$.invalid_type,expected:J.number,received:s.parsedType}),me}let t;const n=new ft;for(const s of this._def.checks)s.kind==="int"?Ne.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),H(t,{code:$.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:$.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:$.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?pb(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),H(t,{code:$.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:$.not_finite,message:s.message}),n.dirty()):Ne.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 rn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new rn({...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"&&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)}}rn.create=r=>new rn({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});class nn 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)!==J.bigint){const s=this._getOrReturnCtx(e);return H(s,{code:$.invalid_type,expected:J.bigint,received:s.parsedType}),me}let t;const n=new ft;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:$.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:$.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:$.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Ne.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 nn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new nn({...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}}nn.create=r=>{var e;return new nn({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};class $i extends ke{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const t=this._getOrReturnCtx(e);return H(t,{code:$.invalid_type,expected:J.boolean,received:t.parsedType}),me}return gt(e.data)}}$i.create=r=>new $i({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});class En extends ke{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const s=this._getOrReturnCtx(e);return H(s,{code:$.invalid_type,expected:J.date,received:s.parsedType}),me}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return H(s,{code:$.invalid_date}),me}const t=new ft;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:$.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:$.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Ne.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new En({...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}}En.create=r=>new En({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,...be(r)});class _o extends ke{_parse(e){if(this._getType(e)!==J.symbol){const t=this._getOrReturnCtx(e);return H(t,{code:$.invalid_type,expected:J.symbol,received:t.parsedType}),me}return gt(e.data)}}_o.create=r=>new _o({typeName:de.ZodSymbol,...be(r)});class Zi extends ke{_parse(e){if(this._getType(e)!==J.undefined){const t=this._getOrReturnCtx(e);return H(t,{code:$.invalid_type,expected:J.undefined,received:t.parsedType}),me}return gt(e.data)}}Zi.create=r=>new Zi({typeName:de.ZodUndefined,...be(r)});class Di extends ke{_parse(e){if(this._getType(e)!==J.null){const t=this._getOrReturnCtx(e);return H(t,{code:$.invalid_type,expected:J.null,received:t.parsedType}),me}return gt(e.data)}}Di.create=r=>new Di({typeName:de.ZodNull,...be(r)});class ms extends ke{constructor(){super(...arguments),this._any=!0}_parse(e){return gt(e.data)}}ms.create=r=>new ms({typeName:de.ZodAny,...be(r)});class wn extends ke{constructor(){super(...arguments),this._unknown=!0}_parse(e){return gt(e.data)}}wn.create=r=>new wn({typeName:de.ZodUnknown,...be(r)});class Rr extends ke{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:$.invalid_type,expected:J.never,received:t.parsedType}),me}}Rr.create=r=>new Rr({typeName:de.ZodNever,...be(r)});class wo extends ke{_parse(e){if(this._getType(e)!==J.undefined){const t=this._getOrReturnCtx(e);return H(t,{code:$.invalid_type,expected:J.void,received:t.parsedType}),me}return gt(e.data)}}wo.create=r=>new wo({typeName:de.ZodVoid,...be(r)});class Xt extends ke{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==J.array)return H(t,{code:$.invalid_type,expected:J.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)&&(H(t,{code:a?$.too_big:$.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:$.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:$.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 yr(t,a,t.path,o)))).then(a=>ft.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new yr(t,a,t.path,o)));return ft.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:de.ZodArray,...be(e)});function Gn(r){if(r instanceof Ke){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=dr.create(Gn(n))}return new Ke({...r._def,shape:()=>e})}else return r instanceof Xt?new Xt({...r._def,type:Gn(r.element)}):r instanceof dr?dr.create(Gn(r.unwrap())):r instanceof an?an.create(Gn(r.unwrap())):r instanceof gr?gr.create(r.items.map(e=>Gn(e))):r}class Ke 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=Ne.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const c=this._getOrReturnCtx(e);return H(c,{code:$.invalid_type,expected:J.object,received:c.parsedType}),me}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Rr&&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 yr(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Rr){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:$.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 yr(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=>ft.mergeObjectSync(t,c)):ft.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Ke({...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 Ke({...this._def,unknownKeys:"strip"})}passthrough(){return new Ke({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ke({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ke({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 Ke({...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 Ke({...this._def,shape:()=>t})}omit(e){const t={};return Ne.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ke({...this._def,shape:()=>t})}deepPartial(){return Gn(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 Ke({...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 s=this.shape[n];for(;s instanceof dr;)s=s._def.innerType;t[n]=s}}),new Ke({...this._def,shape:()=>t})}keyof(){return sm(Ne.objectKeys(this.shape))}}Ke.create=(r,e)=>new Ke({shape:()=>r,unknownKeys:"strip",catchall:Rr.create(),typeName:de.ZodObject,...be(e)});Ke.strictCreate=(r,e)=>new Ke({shape:()=>r,unknownKeys:"strict",catchall:Rr.create(),typeName:de.ZodObject,...be(e)});Ke.lazycreate=(r,e)=>new Ke({shape:r,unknownKeys:"strip",catchall:Rr.create(),typeName:de.ZodObject,...be(e)});class Mi 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 Tt(o.ctx.common.issues));return H(t,{code:$.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 Tt(c));return H(t,{code:$.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Mi.create=(r,e)=>new Mi({options:r,typeName:de.ZodUnion,...be(e)});const Hr=r=>r instanceof Li?Hr(r.schema):r instanceof tr?Hr(r.innerType()):r instanceof qi?[r.value]:r instanceof sn?r.options:r instanceof Hi?Ne.objectValues(r.enum):r instanceof Fi?Hr(r._def.innerType):r instanceof Zi?[void 0]:r instanceof Di?[null]:r instanceof dr?[void 0,...Hr(r.unwrap())]:r instanceof an?[null,...Hr(r.unwrap())]:r instanceof bd||r instanceof zi?Hr(r.unwrap()):r instanceof Wi?Hr(r._def.innerType):[];class hc extends ke{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return H(t,{code:$.invalid_type,expected:J.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}):(H(t,{code:$.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=Hr(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 hc({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...be(n)})}}function qu(r,e){const t=zr(r),n=zr(e);if(r===e)return{valid:!0,data:r};if(t===J.object&&n===J.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=qu(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=qu(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 Vi extends ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Uu(i)||Uu(a))return me;const o=qu(i.value,a.value);return o.valid?((Lu(i)||Lu(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:$.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}))}}Vi.create=(r,e,t)=>new Vi({left:r,right:e,typeName:de.ZodIntersection,...be(t)});class gr extends ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return H(n,{code:$.invalid_type,expected:J.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return H(n,{code:$.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:$.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 yr(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>ft.mergeArray(t,i)):ft.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new gr({...this._def,rest:e})}}gr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gr({items:r,typeName:de.ZodTuple,rest:null,...be(e)})};class Ui 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!==J.object)return H(n,{code:$.invalid_type,expected:J.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 yr(n,o,n.path,o)),value:a._parse(new yr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?ft.mergeObjectAsync(t,s):ft.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof ke?new Ui({keyType:e,valueType:t,typeName:de.ZodRecord,...be(n)}):new Ui({keyType:Gt.create(),valueType:e,typeName:de.ZodRecord,...be(t)})}}class ko 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!==J.map)return H(n,{code:$.invalid_type,expected:J.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 yr(n,o,n.path,[u,"key"])),value:i._parse(new yr(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}}}}ko.create=(r,e,t)=>new ko({valueType:e,keyType:r,typeName:de.ZodMap,...be(t)});class In extends ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return H(n,{code:$.invalid_type,expected:J.set,received:n.parsedType}),me;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(H(n,{code:$.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:$.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 yr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new In({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new In({...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)}}In.create=(r,e)=>new In({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,...be(e)});class ns extends ke{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return H(t,{code:$.invalid_type,expected:J.function,received:t.parsedType}),me;function n(o,c){return vo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,go(),ps].filter(u=>!!u),issueData:{code:$.invalid_arguments,argumentsError:c}})}function s(o,c){return vo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,go(),ps].filter(u=>!!u),issueData:{code:$.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ys){const o=this;return gt(async function(...c){const u=new Tt([]),f=await o._def.args.parseAsync(c,i).catch(D=>{throw u.addIssue(n(c,D)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(D=>{throw u.addIssue(s(m,D)),u})})}else{const o=this;return gt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Tt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Tt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ns({...this._def,args:gr.create(e).rest(wn.create())})}returns(e){return new ns({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ns({args:e||gr.create([]).rest(wn.create()),returns:t||wn.create(),typeName:de.ZodFunction,...be(n)})}}class Li 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})}}Li.create=(r,e)=>new Li({getter:r,typeName:de.ZodLazy,...be(e)});class qi extends ke{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:$.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}qi.create=(r,e)=>new qi({value:r,typeName:de.ZodLiteral,...be(e)});function sm(r,e){return new sn({values:r,typeName:de.ZodEnum,...be(e)})}class sn extends ke{constructor(){super(...arguments),si.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Ne.joinValues(n),received:t.parsedType,code:$.invalid_type}),me}if(xo(this,si)||em(this,si,new Set(this._def.values)),!xo(this,si).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:$.invalid_enum_value,options:n}),me}return gt(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})}}si=new WeakMap;sn.create=sm;class Hi extends ke{constructor(){super(...arguments),ii.set(this,void 0)}_parse(e){const t=Ne.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const s=Ne.objectValues(t);return H(n,{expected:Ne.joinValues(s),received:n.parsedType,code:$.invalid_type}),me}if(xo(this,ii)||em(this,ii,new Set(Ne.getValidEnumValues(this._def.values))),!xo(this,ii).has(e.data)){const s=Ne.objectValues(t);return H(n,{received:n.data,code:$.invalid_enum_value,options:s}),me}return gt(e.data)}get enum(){return this._def.values}}ii=new WeakMap;Hi.create=(r,e)=>new Hi({values:r,typeName:de.ZodNativeEnum,...be(e)});class ys extends ke{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return H(t,{code:$.invalid_type,expected:J.promise,received:t.parsedType}),me;const n=t.parsedType===J.promise?t.data:Promise.resolve(t.data);return gt(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)});class tr extends ke{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=>{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 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"?bo(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"?bo(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(!Ri(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=>Ri(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Ne.assertNever(s)}}tr.create=(r,e,t)=>new tr({schema:r,typeName:de.ZodEffects,effect:e,...be(t)});tr.createWithPreprocess=(r,e,t)=>new tr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,...be(t)});class dr extends ke{_parse(e){return this._getType(e)===J.undefined?gt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}dr.create=(r,e)=>new dr({innerType:r,typeName:de.ZodOptional,...be(e)});class an extends ke{_parse(e){return this._getType(e)===J.null?gt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}an.create=(r,e)=>new an({innerType:r,typeName:de.ZodNullable,...be(e)});class Fi extends ke{_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}}Fi.create=(r,e)=>new Fi({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...be(e)});class Wi 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 Pi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Tt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Tt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Wi.create=(r,e)=>new Wi({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...be(e)});class So extends ke{_parse(e){if(this._getType(e)!==J.nan){const t=this._getOrReturnCtx(e);return H(t,{code:$.invalid_type,expected:J.nan,received:t.parsedType}),me}return{status:"valid",value:e.data}}}So.create=r=>new So({typeName:de.ZodNaN,...be(r)});const mb=Symbol("zod_brand");class bd 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 Oa 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"?me:s.status==="dirty"?(t.dirty(),bo(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"?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 Oa({in:e,out:t,typeName:de.ZodPipeline})}}class zi extends ke{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Ri(s)&&(s.value=Object.freeze(s.value)),s);return Pi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}zi.create=(r,e)=>new zi({innerType:r,typeName:de.ZodReadonly,...be(e)});function im(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 yb={object:Ke.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 gb=(r,e={message:`Input not instance of ${r.name}`})=>im(t=>t instanceof r,e),am=Gt.create,om=rn.create,vb=So.create,bb=nn.create,cm=$i.create,xb=En.create,_b=_o.create,wb=Zi.create,kb=Di.create,Sb=ms.create,Ab=wn.create,Ob=Rr.create,Eb=wo.create,Ib=Xt.create,Cb=Ke.create,jb=Ke.strictCreate,Tb=Mi.create,Nb=hc.create,Bb=Vi.create,Rb=gr.create,Pb=Ui.create,$b=ko.create,Zb=In.create,Db=ns.create,Mb=Li.create,Vb=qi.create,Ub=sn.create,Lb=Hi.create,qb=ys.create,Nf=tr.create,Hb=dr.create,Fb=an.create,Wb=tr.createWithPreprocess,zb=Oa.create,Kb=()=>am().optional(),Gb=()=>om().optional(),Jb=()=>cm().optional(),Yb={string:r=>Gt.create({...r,coerce:!0}),number:r=>rn.create({...r,coerce:!0}),boolean:r=>$i.create({...r,coerce:!0}),bigint:r=>nn.create({...r,coerce:!0}),date:r=>En.create({...r,coerce:!0})},Xb=me;var d=Object.freeze({__proto__:null,defaultErrorMap:ps,setErrorMap:Xv,getErrorMap:go,makeIssue:vo,EMPTY_PATH:Qv,addIssueToContext:H,ParseStatus:ft,INVALID:me,DIRTY:bo,OK:gt,isAborted:Uu,isDirty:Lu,isValid:Ri,isAsync:Pi,get util(){return Ne},get objectUtil(){return Vu},ZodParsedType:J,getParsedType:zr,ZodType:ke,datetimeRegex:nm,ZodString:Gt,ZodNumber:rn,ZodBigInt:nn,ZodBoolean:$i,ZodDate:En,ZodSymbol:_o,ZodUndefined:Zi,ZodNull:Di,ZodAny:ms,ZodUnknown:wn,ZodNever:Rr,ZodVoid:wo,ZodArray:Xt,ZodObject:Ke,ZodUnion:Mi,ZodDiscriminatedUnion:hc,ZodIntersection:Vi,ZodTuple:gr,ZodRecord:Ui,ZodMap:ko,ZodSet:In,ZodFunction:ns,ZodLazy:Li,ZodLiteral:qi,ZodEnum:sn,ZodNativeEnum:Hi,ZodPromise:ys,ZodEffects:tr,ZodTransformer:tr,ZodOptional:dr,ZodNullable:an,ZodDefault:Fi,ZodCatch:Wi,ZodNaN:So,BRAND:mb,ZodBranded:bd,ZodPipeline:Oa,ZodReadonly:zi,custom:im,Schema:ke,ZodSchema:ke,late:yb,get ZodFirstPartyTypeKind(){return de},coerce:Yb,any:Sb,array:Ib,bigint:bb,boolean:cm,date:xb,discriminatedUnion:Nb,effect:Nf,enum:Ub,function:Db,instanceof:gb,intersection:Bb,lazy:Mb,literal:Vb,map:$b,nan:vb,nativeEnum:Lb,never:Ob,null:kb,nullable:Fb,number:om,object:Cb,oboolean:Jb,onumber:Gb,optional:Hb,ostring:Kb,pipeline:zb,preprocess:Wb,promise:qb,record:Pb,set:Zb,strictObject:jb,string:am,symbol:_b,transformer:Nf,tuple:Rb,undefined:wb,union:Tb,unknown:Ab,void:Eb,NEVER:Xb,ZodIssueCode:$,quotelessJson:Yv,ZodError:Tt});Jv(d);const Rs=d.object({start:d.number(),limit:d.number(),length:d.number()}),xd=d.object({created_at:d.string(),updated_at:d.string()}),Qb=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()),ex=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:Qb.optional()}),_d=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()}),Hu=_d.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")}),um=d.object({...Hu.shape,...xd.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(ex).optional()}),Ar=um;_d.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 tx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let rx=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=tx[t[r]&63];return e};const nx=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()}),Fu=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:nx.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(()=>rx()).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"})}),Xn=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...Fu.shape});var lm=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(lm||{}),dm=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(dm||{}),fm=(r=>(r.S265="S256",r.plain="plain",r))(fm||{});const sx=d.object({client_id:d.string(),vendor_id:d.string().optional(),response_type:d.nativeEnum(lm).optional(),response_mode:d.nativeEnum(dm).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(fm).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),Bf=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()}),Wu=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()}),Qn=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(Wu.shape),zu=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()}),hi=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...zu.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 ix=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({...Xn.shape,domains:d.array(ix),tenant:hi,connections:d.array(Qn)});const ax=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ox=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:ax,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()});d.object({...ox.shape,created_at:d.string()});const cx=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"])});xd.extend({...cx.shape,id:d.string()});const Ku=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()}),ai=Ku.extend({...xd.shape,hook_id:d.string()}),hm=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()}),ux=d.object({keys:d.array(hm)}),Rf=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())}),lx=d.object({auth0Client:d.string().optional(),authParams:sx,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional()}).openapi({description:"This represents a login sesion"});d.object({...lx.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 wd=(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))(wd||{});const dx=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"]),fx=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),Gu=d.object({type:dx,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:fx.optional()}),hx=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")});d.object({...hx.shape,created_at:d.string(),updated_at:d.string()});const px=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()});d.object({created_at:d.string(),...px.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 pm=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(pm||{});const kd=d.nativeEnum(pm);d.object({grant_type:kd.refine(r=>r==="authorization_code"),code:d.string(),client_secret:d.string(),client_id:d.string()});d.object({grant_type:kd.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:kd.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 mx=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()}),yx=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()}),Wn=d.object({bold:d.boolean(),size:d.number()}),gx=d.object({body_text:Wn,buttons_text:Wn,font_url:d.string(),input_labels:Wn,links:Wn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Wn,title:Wn}),vx=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),bx=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"])}),xx=d.object({borders:mx,colors:yx,displayName:d.string(),fonts:gx,page_background:vx,widget:bx});xx.extend({themeId:d.string()});const pu=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 Ao=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _x(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function wx(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
+ "use strict";var i0=Object.defineProperty;var Pf=r=>{throw TypeError(r)};var a0=(r,e,t)=>e in r?i0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var X=(r,e,t)=>a0(r,typeof e!="symbol"?e+"":e,t),wu=(r,e,t)=>e.has(r)||Pf("Cannot "+t);var P=(r,e,t)=>(wu(r,e,"read from private field"),t?t.call(r):e.get(r)),He=(r,e,t)=>e.has(r)?Pf("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),Te=(r,e,t,n)=>(wu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Ee=(r,e,t)=>(wu(r,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function di(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 _e(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function o0(r){return"_def"in r}function ai(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 c0(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=di(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(_e(this,"ZodObject")){const T=this.extend;R.extend=function(...ye){var Ue,Le,$e,et,ft,Tt;const E=T.apply(this,ye);return E._def.openapi={_internal:{extendedFrom:!((Le=(Ue=this._def.openapi)===null||Ue===void 0?void 0:Ue._internal)===null||Le===void 0)&&Le.refId?{refId:(et=($e=this._def.openapi)===null||$e===void 0?void 0:$e._internal)===null||et===void 0?void 0:et.refId,schema:this}:(ft=this._def.openapi)===null||ft===void 0?void 0:ft._internal.extendedFrom},metadata:(Tt=E._def.openapi)===null||Tt===void 0?void 0:Tt.metadata},E}}return R},ai(r,"optional"),ai(r,"nullable"),ai(r,"default"),ai(r,"transform"),ai(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 vo(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=>vo(r[n],e[n]))}class u0{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=>vo(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>vo(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 _i(r){return r==null}function wi(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function l0(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function ms(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function $f(r){return r.filter(e=>!_i(e))}const Uu=vo;function d0(r){const e=new u0;return r.forEach(t=>e.put(t)),[...e.values()]}function Zp(r){return typeof r=="string"}class f0{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 Sc{constructor(e){this.message=e}}class oi extends Sc{constructor(e,t){super(e),this.data=t}}class bo extends Sc{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 ci(r,e){try{return r()}catch(t){throw t instanceof bo?new bo(Object.assign(Object.assign({},t.data),e)):t}}class h0 extends Sc{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class ze{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 ms(l0(e,["param"]),_i)}static buildParameterMetadata(e){return ms(e,_i)}static applySchemaMetadata(e,t){return ms(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),_i)}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&&_e(e,t)?e:_e(e,"ZodOptional")||_e(e,"ZodNullable")||_e(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):_e(e,"ZodDefault")||_e(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):_e(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):_e(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return _e(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class p0{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 m0{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class y0{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=>ze.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=ze.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(_e(c,"ZodEnum")||_e(c,"ZodNativeEnum")){Object.values(c.enum).filter(Zp).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 g0{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class v0{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!_e(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class b0{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function x0(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 _0{transform(e,t){const{type:n,values:s}=x0(e._def.values);if(n==="mixed")throw new Sc("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 w0{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class k0{transform(e,t,n,s){var i;const a=(i=ze.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=wi(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=wi(u==null?void 0:u._def.shape(),s),B=Object.fromEntries(Object.entries(c).filter(([g,A])=>!Uu(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 _e(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!ze.isOptionalSchema(n)).map(([t,n])=>t)}}class S0{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(_e(i,"ZodEnum")||_e(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter(Zp).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 A0{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 O0{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 E0{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 _e(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return _e(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class C0{constructor(e){this.versionSpecifics=e,this.objectTransformer=new k0,this.stringTransformer=new A0,this.numberTransformer=new w0,this.bigIntTransformer=new m0,this.literalTransformer=new b0,this.enumTransformer=new g0,this.nativeEnumTransformer=new _0,this.arrayTransformer=new p0,this.unionTransformer=new E0,this.discriminatedUnionTransformer=new y0,this.intersectionTransformer=new v0,this.recordTransformer=new S0,this.tupleTransformer=new O0(e)}transform(e,t,n,s,i){if(_e(e,"ZodNull"))return this.versionSpecifics.nullType;if(_e(e,"ZodUnknown")||_e(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(_e(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(_e(e,"ZodUnknown")||_e(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(_e(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(_e(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(_e(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(_e(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(_e(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(_e(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(_e(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(_e(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(_e(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(_e(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=ze.getRefId(e);throw new h0({currentSchema:e._def,schemaName:i})}}class Dp{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new C0(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=ze.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 oi(`Conflicting location for parameter ${u.name}`,{key:"in",values:$f([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 oi("Conflicting names for parameter",{key:"name",values:$f([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=ze.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(_e(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,B;const j=ze.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 oi("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new oi(`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 oi(`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=ze.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!ze.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?ze.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=ze.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 bo({missingField:"name"});if(!a)throw new bo({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=ze.unwrapChained(e),s=ze.getMetadata(e),i=ze.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?ze.applySchemaMetadata(a,s.metadata):ms(a,_i)}constructReferencedOpenAPISchema(e){var t;const n=ze.getMetadata(e),s=ze.unwrapChained(e),i=ze.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=ze.getMetadata(e),s=ze.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=ms(ze.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||Uu(f,i[m]));if(o.type)return{allOf:[a,o]};const c=ms(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||Uu(f,i[m])),u=ze.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=ze.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=di(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=ci(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=ci(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=ci(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=ci(()=>{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 _e(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=di(e,["method","path","request","responses"]),o=wi(i,m=>this.getResponse(m)),c=ci(()=>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=di(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=_e(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 wi(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return wi(e,t=>{if(!t||!o0(t.schema))return t;const{schema:n}=t,s=di(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 I0{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=d0(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 j0{constructor(e){const t=new I0;this.generator=new Dp(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class T0{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 N0(r){return"type"in r&&r.type==="webhook"}class B0{constructor(e){this.definitions=e,this.webhookRefs={};const t=new T0;this.generator=new Dp(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(N0).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 Mp=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},R0=r=>{const{groups:e,path:t}=P0(r),n=Mp(t);return $0(n,e)},P0=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},$0=(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},ro={},Zf=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(ro[r]||(e[2]?ro[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:ro[r]=[r,e[1],!0]),ro[r]):null},Vp=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},Z0=r=>Vp(r,decodeURI),Up=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 Z0(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},D0=r=>{const e=Up(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},Xr=(...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},Lp=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?Td(r):r):r,qp=(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},M0=qp,V0=(r,e)=>qp(r,e,!0),Td=decodeURIComponent,U0=/^[\w!#$%&'*.^`|~+-]+$/,L0=/^[ !#-:<-[\]-~]*$/,q0=(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(!U0.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),L0.test(o)&&(n[a]=Td(o))}return n},H0=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?q0(n):{}},De=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});X(this,"res");X(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})}},F0=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),W0=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,z0=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,K0=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,G0=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!W0.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||!(z0.test(i)||K0.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 F0(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=H0(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const ns=(r,e,t)=>G0(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 J0=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof Hp?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")?Y0(r,{all:t,dot:n}):{}};async function Y0(r,e){const t=await r.formData();return t?X0(t,e):{}}function X0(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?Q0(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(ev(t,n,s),delete t[n])}),t}var Q0=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},ev=(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])})},Df=r=>Vp(r,Td),xs,Yt,zr,Fp,Wp,Lu,rn,Np,Hp=(Np=class{constructor(r,e="/",t=[[]]){He(this,zr);X(this,"raw");He(this,xs);He(this,Yt);X(this,"routeIndex",0);X(this,"path");X(this,"bodyCache",{});He(this,rn,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,Yt,t),Te(this,xs,{})}param(r){return r?Ee(this,zr,Fp).call(this,r):Ee(this,zr,Wp).call(this)}query(r){return M0(this.url,r)}queries(r){return V0(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 J0(this,r))}json(){return P(this,rn).call(this,"json")}text(){return P(this,rn).call(this,"text")}arrayBuffer(){return P(this,rn).call(this,"arrayBuffer")}blob(){return P(this,rn).call(this,"blob")}formData(){return P(this,rn).call(this,"formData")}addValidatedData(r,e){P(this,xs)[r]=e}valid(r){return P(this,xs)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return P(this,Yt)[0].map(([[,r]])=>r)}get routePath(){return P(this,Yt)[0].map(([[,r]])=>r)[this.routeIndex].path}},xs=new WeakMap,Yt=new WeakMap,zr=new WeakSet,Fp=function(r){const e=P(this,Yt)[0][this.routeIndex][1][r],t=Ee(this,zr,Lu).call(this,e);return t?/\%/.test(t)?Df(t):t:void 0},Wp=function(){const r={},e=Object.keys(P(this,Yt)[0][this.routeIndex][1]);for(const t of e){const n=Ee(this,zr,Lu).call(this,P(this,Yt)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?Df(n):n)}return r},Lu=function(r){return P(this,Yt)[1]?P(this,Yt)[1][r]:r},rn=new WeakMap,Np),tv={Stringify:1,BeforeStream:2,Stream:3},zp=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=>zp(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},rv="text/plain; charset=UTF-8",Su=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Na,Ba,Tr,Tn,Nr,Ge,Qe,fr,Br,Ra,_s,ws,Pa,$a,St,Dt,Bp,Kp=(Bp=class{constructor(r,e){He(this,St);He(this,Na);He(this,Ba);X(this,"env",{});He(this,Tr);X(this,"finalized",!1);X(this,"error");He(this,Tn,200);He(this,Nr);He(this,Ge);He(this,Qe);He(this,fr);He(this,Br,!0);He(this,Ra);He(this,_s);He(this,ws);He(this,Pa);He(this,$a);X(this,"render",(...r)=>(P(this,_s)??Te(this,_s,e=>this.html(e)),P(this,_s).call(this,...r)));X(this,"setLayout",r=>Te(this,Ra,r));X(this,"getLayout",()=>P(this,Ra));X(this,"setRenderer",r=>{Te(this,_s,r)});X(this,"header",(r,e,t)=>{if(e===void 0){P(this,Ge)?P(this,Ge).delete(r):P(this,Qe)&&delete P(this,Qe)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(P(this,Ge)||(Te(this,Br,!1),Te(this,Ge,new Headers(P(this,Qe))),Te(this,Qe,{})),P(this,Ge).append(r,e)):P(this,Ge)?P(this,Ge).set(r,e):(P(this,Qe)??Te(this,Qe,{}),P(this,Qe)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});X(this,"status",r=>{Te(this,Br,!1),Te(this,Tn,r)});X(this,"set",(r,e)=>{P(this,Tr)??Te(this,Tr,new Map),P(this,Tr).set(r,e)});X(this,"get",r=>P(this,Tr)?P(this,Tr).get(r):void 0);X(this,"newResponse",(...r)=>Ee(this,St,Dt).call(this,...r));X(this,"body",(r,e,t)=>typeof e=="number"?Ee(this,St,Dt).call(this,r,e,t):Ee(this,St,Dt).call(this,r,e));X(this,"text",(r,e,t)=>{if(!P(this,Qe)){if(P(this,Br)&&!t&&!e)return new Response(r);Te(this,Qe,{})}return P(this,Qe)["content-type"]=rv,typeof e=="number"?Ee(this,St,Dt).call(this,r,e,t):Ee(this,St,Dt).call(this,r,e)});X(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return P(this,Qe)??Te(this,Qe,{}),P(this,Qe)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Ee(this,St,Dt).call(this,n,e,t):Ee(this,St,Dt).call(this,n,e)});X(this,"html",(r,e,t)=>(P(this,Qe)??Te(this,Qe,{}),P(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?zp(r,tv.Stringify,!1,{}).then(n=>typeof e=="number"?Ee(this,St,Dt).call(this,n,e,t):Ee(this,St,Dt).call(this,n,e)):typeof e=="number"?Ee(this,St,Dt).call(this,r,e,t):Ee(this,St,Dt).call(this,r,e)));X(this,"redirect",(r,e)=>(P(this,Ge)??Te(this,Ge,new Headers),P(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));X(this,"notFound",()=>(P(this,ws)??Te(this,ws,()=>new Response),P(this,ws).call(this,this)));Te(this,Na,r),e&&(Te(this,Nr,e.executionCtx),this.env=e.env,Te(this,ws,e.notFoundHandler),Te(this,$a,e.path),Te(this,Pa,e.matchResult))}get req(){return P(this,Ba)??Te(this,Ba,new Hp(P(this,Na),P(this,$a),P(this,Pa))),P(this,Ba)}get event(){if(P(this,Nr)&&"respondWith"in P(this,Nr))return P(this,Nr);throw Error("This context has no FetchEvent")}get executionCtx(){if(P(this,Nr))return P(this,Nr);throw Error("This context has no ExecutionContext")}get res(){return Te(this,Br,!1),P(this,fr)||Te(this,fr,new Response("404 Not Found",{status:404}))}set res(r){if(Te(this,Br,!1),P(this,fr)&&r)try{for(const[e,t]of P(this,fr).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=P(this,fr).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,fr,r),this.finalized=!0}get var(){return P(this,Tr)?Object.fromEntries(P(this,Tr)):{}}},Na=new WeakMap,Ba=new WeakMap,Tr=new WeakMap,Tn=new WeakMap,Nr=new WeakMap,Ge=new WeakMap,Qe=new WeakMap,fr=new WeakMap,Br=new WeakMap,Ra=new WeakMap,_s=new WeakMap,ws=new WeakMap,Pa=new WeakMap,$a=new WeakMap,St=new WeakSet,Dt=function(r,e,t){if(P(this,Br)&&!t&&!e&&P(this,Tn)===200)return new Response(r,{headers:P(this,Qe)});if(e&&typeof e!="number"){const s=new Headers(e.headers);P(this,Ge)&&P(this,Ge).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=Su(s,P(this,Qe));return new Response(r,{headers:i,status:e.status??P(this,Tn)})}const n=typeof e=="number"?e:P(this,Tn);P(this,Qe)??Te(this,Qe,{}),P(this,Ge)??Te(this,Ge,new Headers),Su(P(this,Ge),P(this,Qe)),P(this,fr)&&(P(this,fr).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=P(this,Ge))==null||a.append(i,s):(o=P(this,Ge))==null||o.set(i,s)}),Su(P(this,Ge),P(this,Qe))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")P(this,Ge).set(s,i);else{P(this,Ge).delete(s);for(const a of i)P(this,Ge).append(s,a)}return new Response(r,{status:n,headers:P(this,Ge)})},Bp),Mf=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof Kp;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}},nt="ALL",nv="all",sv=["get","post","put","delete","options","patch"],Gp="Can not add a route since the matcher is already built.",Jp=class extends Error{},iv=Symbol("composedHandler"),av=r=>r.text("404 Not Found",404),Vf=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),Xt,st,Xp,Rr,nn,On,co,uo,Rp,Yp=(Rp=class{constructor(e={}){He(this,st);X(this,"get");X(this,"post");X(this,"put");X(this,"delete");X(this,"options");X(this,"patch");X(this,"all");X(this,"on");X(this,"use");X(this,"router");X(this,"getPath");X(this,"_basePath","/");He(this,Xt,"/");X(this,"routes",[]);He(this,Rr,av);He(this,nn,Vf);X(this,"onError",e=>(Te(this,nn,e),this));X(this,"notFound",e=>(Te(this,Rr,e),this));X(this,"fetch",(e,...t)=>Ee(this,st,uo).call(this,e,t[1],t[0],e.method));X(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${Xr("/",e)}`,a=new Request(i,t);return this.fetch(a,n,s)});X(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Ee(this,st,uo).call(this,e.request,e,void 0,e.request.method))})});[...sv,nv].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?Te(this,Xt,i):Ee(this,st,On).call(this,s,P(this,Xt),i),a.forEach(o=>{typeof o!="string"&&Ee(this,st,On).call(this,s,P(this,Xt),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){Te(this,Xt,o);for(const c of[s].flat())a.map(u=>{Ee(this,st,On).call(this,c.toUpperCase(),P(this,Xt),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?Te(this,Xt,s):(Te(this,Xt,"*"),i.unshift(s)),i.forEach(a=>{Ee(this,st,On).call(this,nt,P(this,Xt),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Up:D0}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{var a;let i;P(t,nn)===Vf?i=s.handler:(i=async(o,c)=>(await Mf([],P(t,nn))(o,()=>s.handler(o,c))).res,i[iv]=s.handler),Ee(a=n,st,On).call(a,s.method,s.path,i)}),this}basePath(e){const t=Ee(this,st,Xp).call(this);return t._basePath=Xr(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=Xr(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 Ee(this,st,On).call(this,nt,Xr(e,"*"),o),this}},Xt=new WeakMap,st=new WeakSet,Xp=function(){const e=new Yp({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Rr=new WeakMap,nn=new WeakMap,On=function(e,t,n){e=e.toUpperCase(),t=Xr(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)},co=function(e,t){if(e instanceof Error)return P(this,nn).call(this,e,t);throw e},uo=function(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await Ee(this,st,uo).call(this,e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.router.match(s,i),o=new Kp(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:P(this,Rr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await P(this,Rr).call(this,o)})}catch(f){return Ee(this,st,co).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:P(this,Rr).call(this,o))).catch(f=>Ee(this,st,co).call(this,f,o)):u??P(this,Rr).call(this,o)}const c=Mf(a[0],P(this,nn),P(this,Rr));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 Ee(this,st,co).call(this,u,o)}})()},Rp),xo="[^/]+",ki=".*",Si="(?:|/.*)",fi=Symbol(),ov=new Set(".\\+*[^]$()");function cv(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===ki||r===Si?1:e===ki||e===Si?-1:r===xo?1:e===xo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var qu=class{constructor(){X(this,"index");X(this,"varIndex");X(this,"children",Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(this.index!==void 0)throw fi;if(i)return;this.index=t;return}const[a,...o]=e,c=a==="*"?o.length===0?["","",ki]:["","",xo]:a==="/*"?["","",Si]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||xo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw fi;if(u=this.children[m],!u){if(Object.keys(this.children).some(B=>B!==ki&&B!==Si))throw fi;if(i)return;u=this.children[m]=new qu,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!==ki&&f!==Si))throw fi;if(i)return;u=this.children[a]=new qu}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(this.children).sort(cv).map(n=>{const s=this.children[n];return(typeof s.varIndex=="number"?`(${n})@${s.varIndex}`:ov.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("|")+")"}},uv=class{constructor(){X(this,"context",{varIndex:0});X(this,"root",new qu)}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]}},Qp=[],lv=[/^$/,[],Object.create(null)],lo=Object.create(null);function em(r){return lo[r]??(lo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function dv(){lo=Object.create(null)}function fv(r){var u;const e=new uv,t=[];if(r.length===0)return lv;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)]),Qp]:m++;let A;try{A=e.insert(p,m,j)}catch(S){throw S===fi?new Jp(p):S}j||(t[m]=g.map(([S,R])=>{const T=Object.create(null);for(R-=1;R>=0;R--){const[ye,Ue]=A[R];T[ye]=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 ss(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(em(t).test(e))return[...r[t]]}}var zs,tm,rm,Pp,hv=(Pp=class{constructor(){He(this,zs);X(this,"name","RegExpRouter");X(this,"middleware");X(this,"routes");this.middleware={[nt]:Object.create(null)},this.routes={[nt]:Object.create(null)}}add(r,e,t){var o;const{middleware:n,routes:s}=this;if(!n||!s)throw new Error(Gp);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[nt]).forEach(u=>{c[r][u]=[...c[nt][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=em(e);r===nt?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=ss(n[u],e)||ss(n[nt],e)||[])}):(o=n[r])[e]||(o[e]=ss(n[r],e)||ss(n[nt],e)||[]),Object.keys(n).forEach(u=>{(r===nt||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,i])})}),Object.keys(s).forEach(u=>{(r===nt||r===u)&&Object.keys(s[u]).forEach(f=>c.test(f)&&s[u][f].push([t,i]))});return}const a=Lp(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(s).forEach(m=>{var B;(r===nt||r===m)&&((B=s[m])[f]||(B[f]=[...ss(n[m],f)||ss(n[nt],f)||[]]),s[m][f].push([t,i-u+c+1]))})}}match(r,e){dv();const t=Ee(this,zs,tm).call(this);return this.match=(n,s)=>{const i=t[n]||t[nt],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],Qp];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},zs=new WeakSet,tm=function(){const r=Object.create(null);return Object.keys(this.routes).concat(Object.keys(this.middleware)).forEach(e=>{r[e]||(r[e]=Ee(this,zs,rm).call(this,e))}),this.middleware=this.routes=void 0,r},rm=function(r){const e=[];let t=r===nt;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!==nt&&e.push(...Object.keys(n[nt]).map(i=>[i,n[nt][i]]))}),t?fv(e):null},Pp),pv=class{constructor(r){X(this,"name","SmartRouter");X(this,"routers",[]);X(this,"routes",[]);Object.assign(this,r)}add(r,e,t){if(!this.routes)throw new Error(Gp);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 Jp)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]}},Pr,En,$p,nm=($p=class{constructor(r,e,t){He(this,Pr);X(this,"methods");X(this,"children");X(this,"patterns");X(this,"order",0);X(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=R0(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=Zf(f);B&&i.push(B[1]);continue}n.children[f]=new nm;const m=Zf(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=Mp(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(...Ee(this,Pr,En).call(this,g.children["*"],r,p.params,Object.create(null))),t.push(...Ee(this,Pr,En).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 ft=p.children["*"];ft&&(t.push(...Ee(this,Pr,En).call(this,ft,r,p.params,Object.create(null))),m.push(ft));continue}if(u==="")continue;const[ye,Ue,Le]=R,$e=p.children[ye],et=i.slice(o).join("/");if(Le instanceof RegExp&&Le.test(et)){T[Ue]=et,t.push(...Ee(this,Pr,En).call(this,$e,r,p.params,T));continue}(Le===!0||Le.test(u))&&typeof ye=="string"&&(T[Ue]=u,f?(t.push(...Ee(this,Pr,En).call(this,$e,r,T,p.params)),$e.children["*"]&&t.push(...Ee(this,Pr,En).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])]}},Pr=new WeakSet,En=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[nt],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},$p),mv=class{constructor(){X(this,"name","TrieRouter");X(this,"node");this.node=new nm}add(r,e,t){const n=Lp(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)}},yv=class extends Yp{constructor(r={}){super(r),this.router=r.router??new pv({routers:[new hv,new mv]})}},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 Hu;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Hu||(Hu={}));const K=Ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Qr=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"]),gv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let tr=class sm 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 sm))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()}};tr.create=r=>new tr(r);const ks=(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 im=ks;function vv(r){im=r}function _o(){return im}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}},bv=[];function q(r,e){const t=_o(),n=wo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ks?void 0:ks].filter(s=>!!s)});r.common.issues.push(n)}let Et=class am{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 he;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 am.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 he;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 he=Object.freeze({status:"aborted"}),ls=r=>({status:"dirty",value:r}),vt=r=>({status:"valid",value:r}),Fu=r=>r.status==="aborted",Wu=r=>r.status==="dirty",ji=r=>r.status==="valid",Ti=r=>typeof Promise<"u"&&r instanceof Promise;function ko(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 om(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 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 hi,pi;let br=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 Uf=(r,e)=>{if(ji(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 tr(r.common.issues);return this._error=t,this._error}}};function ve(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 Qr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Qr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Et,ctx:{common:e.parent.common,data:e.data,parsedType:Qr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ti(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:Qr(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Uf(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:Qr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ti(s)?s:Promise.resolve(s));return Uf(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 sr({schema:this,typeName:le.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return pr.create(this,this._def)}nullable(){return dn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Zn.create(this,this._def)}promise(){return Os.create(this,this._def)}or(e){return Di.create([this,e],this._def)}and(e){return Mi.create(this,e,this._def)}transform(e){return new sr({...ve(this._def),schema:this,typeName:le.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new qi({...ve(this._def),innerType:this,defaultValue:t,typeName:le.ZodDefault})}brand(){return new Nd({typeName:le.ZodBranded,type:this,...ve(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Hi({...ve(this._def),innerType:this,catchValue:t,typeName:le.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Bd.create(this,e)}readonly(){return Fi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const xv=/^c[^\s-]{8,}$/i,_v=/^[0-9a-z]+$/,wv=/^[0-9A-HJKMNP-TV-Z]{26}$/,kv=/^[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,Sv=/^[a-z0-9_-]{21}$/i,Av=/^[-+]?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)?)??$/,Ov=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ev="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Au;const Cv=/^(?:(?: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])$/,Iv=/^(([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})))$/,jv=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,cm="((\\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])))",Tv=new RegExp(`^${cm}$`);function um(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 Nv(r){return new RegExp(`^${um(r)}$`)}function lm(r){let e=`${cm}T${um(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 Bv(r,e){return!!((e==="v4"||!e)&&Cv.test(r)||(e==="v6"||!e)&&Iv.test(r))}let Ss=class mi 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}),he}const n=new Et;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")Ov.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")Au||(Au=new RegExp(Ev,"u")),Au.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")kv.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")Sv.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")xv.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")_v.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")wv.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"?lm(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"?Tv.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{code:Z.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Nv(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"?Av.test(e.data)||(s=this._getOrReturnCtx(e,s),q(s,{validation:"duration",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Bv(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"?jv.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 mi({...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 mi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new mi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new mi({...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}};Ss.create=r=>{var e;return new Ss({checks:[],typeName:le.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ve(r)})};function Rv(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 Ni=class zu 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}),he}let n;const s=new Et;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"?Rv(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 zu({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new zu({...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)}};Ni.create=r=>new Ni({checks:[],typeName:le.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ve(r)});let Bi=class Ku 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}),he}let n;const s=new Et;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 Ku({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new Ku({...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}};Bi.create=r=>{var e;return new Bi({checks:[],typeName:le.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ve(r)})};let Ri=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}),he}return vt(e.data)}};Ri.create=r=>new Ri({typeName:le.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ve(r)});let Pi=class dm 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}),he}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return q(i,{code:Z.invalid_date}),he}const n=new Et;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 dm({...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}};Pi.create=r=>new Pi({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:le.ZodDate,...ve(r)});let So=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}),he}return vt(e.data)}};So.create=r=>new So({typeName:le.ZodSymbol,...ve(r)});let $i=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}),he}return vt(e.data)}};$i.create=r=>new $i({typeName:le.ZodUndefined,...ve(r)});let Zi=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}),he}return vt(e.data)}};Zi.create=r=>new Zi({typeName:le.ZodNull,...ve(r)});let As=class extends we{constructor(){super(...arguments),this._any=!0}_parse(e){return vt(e.data)}};As.create=r=>new As({typeName:le.ZodAny,...ve(r)});let Nn=class extends we{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vt(e.data)}};Nn.create=r=>new Nn({typeName:le.ZodUnknown,...ve(r)});let Mr=class extends we{_parse(e){const t=this._getOrReturnCtx(e);return q(t,{code:Z.invalid_type,expected:K.never,received:t.parsedType}),he}};Mr.create=r=>new Mr({typeName:le.ZodNever,...ve(r)});let Ao=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}),he}return vt(e.data)}};Ao.create=r=>new Ao({typeName:le.ZodVoid,...ve(r)});let Zn=class fo 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}),he;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 br(t,a,t.path,o)))).then(a=>Et.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new br(t,a,t.path,o)));return Et.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new fo({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new fo({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new fo({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Zn.create=(r,e)=>new Zn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:le.ZodArray,...ve(e)});function os(r){if(r instanceof Lt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=pr.create(os(n))}return new Lt({...r._def,shape:()=>e})}else return r instanceof Zn?new Zn({...r._def,type:os(r.element)}):r instanceof pr?pr.create(os(r.unwrap())):r instanceof dn?dn.create(os(r.unwrap())):r instanceof ln?ln.create(r.items.map(e=>os(e))):r}let Lt=class Kt 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}),he}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Mr&&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 br(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Mr){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 br(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=>Et.mergeObjectSync(n,u)):Et.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Kt({...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 Kt({...this._def,unknownKeys:"strip"})}passthrough(){return new Kt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Kt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Kt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:le.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Kt({...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 Kt({...this._def,shape:()=>t})}omit(e){const t={};return Ne.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Kt({...this._def,shape:()=>t})}deepPartial(){return os(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 Kt({...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 pr;)i=i._def.innerType;t[n]=i}}),new Kt({...this._def,shape:()=>t})}keyof(){return gm(Ne.objectKeys(this.shape))}};Lt.create=(r,e)=>new Lt({shape:()=>r,unknownKeys:"strip",catchall:Mr.create(),typeName:le.ZodObject,...ve(e)});Lt.strictCreate=(r,e)=>new Lt({shape:()=>r,unknownKeys:"strict",catchall:Mr.create(),typeName:le.ZodObject,...ve(e)});Lt.lazycreate=(r,e)=>new Lt({shape:r,unknownKeys:"strip",catchall:Mr.create(),typeName:le.ZodObject,...ve(e)});let Di=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 tr(o.ctx.common.issues));return q(t,{code:Z.invalid_union,unionErrors:a}),he}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 tr(c));return q(t,{code:Z.invalid_union,unionErrors:o}),he}}get options(){return this._def.options}};Di.create=(r,e)=>new Di({options:r,typeName:le.ZodUnion,...ve(e)});const Cr=r=>r instanceof Vi?Cr(r.schema):r instanceof sr?Cr(r.innerType()):r instanceof Ui?[r.value]:r instanceof Za?r.options:r instanceof Li?Ne.objectValues(r.enum):r instanceof qi?Cr(r._def.innerType):r instanceof $i?[void 0]:r instanceof Zi?[null]:r instanceof pr?[void 0,...Cr(r.unwrap())]:r instanceof dn?[null,...Cr(r.unwrap())]:r instanceof Nd||r instanceof Fi?Cr(r.unwrap()):r instanceof Hi?Cr(r._def.innerType):[];let fm=class hm 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}),he;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]}),he)}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=Cr(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 hm({typeName:le.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ve(n)})}};function Gu(r,e){const t=Qr(r),n=Qr(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=Gu(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=Gu(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 Mi=class extends we{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Fu(i)||Fu(a))return he;const o=Gu(i.value,a.value);return o.valid?((Wu(i)||Wu(a))&&t.dirty(),{status:t.value,value:o.data}):(q(n,{code:Z.invalid_intersection_types}),he)};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}))}};Mi.create=(r,e,t)=>new Mi({left:r,right:e,typeName:le.ZodIntersection,...ve(t)});let ln=class pm 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}),he;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"}),he;!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 br(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>Et.mergeArray(t,a)):Et.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new pm({...this._def,rest:e})}};ln.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ln({items:r,typeName:le.ZodTuple,rest:null,...ve(e)})};let mm=class Ju 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}),he;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new br(n,o,n.path,o)),value:a._parse(new br(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?Et.mergeObjectAsync(t,s):Et.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof we?new Ju({keyType:e,valueType:t,typeName:le.ZodRecord,...ve(n)}):new Ju({keyType:Ss.create(),valueType:e,typeName:le.ZodRecord,...ve(t)})}},Oo=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}),he;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new br(n,o,n.path,[u,"key"])),value:i._parse(new br(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 he;(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 he;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};Oo.create=(r,e,t)=>new Oo({valueType:e,keyType:r,typeName:le.ZodMap,...ve(t)});let Eo=class Yu 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}),he;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 he;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 br(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Yu({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Yu({...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)}};Eo.create=(r,e)=>new Eo({valueType:r,minSize:null,maxSize:null,typeName:le.ZodSet,...ve(e)});let ym=class ho 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}),he;function n(o,c){return wo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_o(),ks].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return wo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_o(),ks].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 Os){const o=this;return vt(async function(...c){const u=new tr([]),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 tr([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new tr([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ho({...this._def,args:ln.create(e).rest(Nn.create())})}returns(e){return new ho({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ho({args:e||ln.create([]).rest(Nn.create()),returns:t||Nn.create(),typeName:le.ZodFunction,...ve(n)})}},Vi=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})}};Vi.create=(r,e)=>new Vi({getter:r,typeName:le.ZodLazy,...ve(e)});let Ui=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}),he}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ui.create=(r,e)=>new Ui({value:r,typeName:le.ZodLiteral,...ve(e)});function gm(r,e){return new Za({values:r,typeName:le.ZodEnum,...ve(e)})}let Za=class Xu extends we{constructor(){super(...arguments),hi.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}),he}if(ko(this,hi)||om(this,hi,new Set(this._def.values)),!ko(this,hi).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}),he}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 Xu.create(e,{...this._def,...t})}exclude(e,t=this._def){return Xu.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};hi=new WeakMap;Za.create=gm;let Li=class extends we{constructor(){super(...arguments),pi.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}),he}if(ko(this,pi)||om(this,pi,new Set(Ne.getValidEnumValues(this._def.values))),!ko(this,pi).has(e.data)){const s=Ne.objectValues(t);return q(n,{received:n.data,code:Z.invalid_enum_value,options:s}),he}return vt(e.data)}get enum(){return this._def.values}};pi=new WeakMap;Li.create=(r,e)=>new Li({values:r,typeName:le.ZodNativeEnum,...ve(e)});let Os=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}),he;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})))}};Os.create=(r,e)=>new Os({type:r,typeName:le.ZodPromise,...ve(e)});let sr=class extends we{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===le.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 he;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?he:c.status==="dirty"||t.value==="dirty"?ls(c.value):c});{if(t.value==="aborted")return he;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?he:o.status==="dirty"||t.value==="dirty"?ls(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"?he:(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"?he:(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(!ji(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=>ji(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Ne.assertNever(s)}};sr.create=(r,e,t)=>new sr({schema:r,typeName:le.ZodEffects,effect:e,...ve(t)});sr.createWithPreprocess=(r,e,t)=>new sr({schema:e,effect:{type:"preprocess",transform:r},typeName:le.ZodEffects,...ve(t)});let pr=class extends we{_parse(e){return this._getType(e)===K.undefined?vt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};pr.create=(r,e)=>new pr({innerType:r,typeName:le.ZodOptional,...ve(e)});let dn=class extends we{_parse(e){return this._getType(e)===K.null?vt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};dn.create=(r,e)=>new dn({innerType:r,typeName:le.ZodNullable,...ve(e)});let qi=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}};qi.create=(r,e)=>new qi({innerType:r,typeName:le.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ve(e)});let Hi=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 Ti(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new tr(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new tr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Hi.create=(r,e)=>new Hi({innerType:r,typeName:le.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ve(e)});let Co=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}),he}return{status:"valid",value:e.data}}};Co.create=r=>new Co({typeName:le.ZodNaN,...ve(r)});const Pv=Symbol("zod_brand");let Nd=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}},Bd=class vm 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"?he:i.status==="dirty"?(t.dirty(),ls(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"?he: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 vm({in:e,out:t,typeName:le.ZodPipeline})}},Fi=class extends we{_parse(e){const t=this._def.innerType._parse(e),n=s=>(ji(s)&&(s.value=Object.freeze(s.value)),s);return Ti(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};Fi.create=(r,e)=>new Fi({innerType:r,typeName:le.ZodReadonly,...ve(e)});function bm(r,e={},t){return r?As.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})}}):As.create()}const $v={object:Lt.lazycreate};var le;(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"})(le||(le={}));const Zv=(r,e={message:`Input not instance of ${r.name}`})=>bm(t=>t instanceof r,e),xm=Ss.create,_m=Ni.create,Dv=Co.create,Mv=Bi.create,wm=Ri.create,Vv=Pi.create,Uv=So.create,Lv=$i.create,qv=Zi.create,Hv=As.create,Fv=Nn.create,Wv=Mr.create,zv=Ao.create,Kv=Zn.create,Gv=Lt.create,Jv=Lt.strictCreate,Yv=Di.create,Xv=fm.create,Qv=Mi.create,eb=ln.create,tb=mm.create,rb=Oo.create,nb=Eo.create,sb=ym.create,ib=Vi.create,ab=Ui.create,ob=Za.create,cb=Li.create,ub=Os.create,Lf=sr.create,lb=pr.create,db=dn.create,fb=sr.createWithPreprocess,hb=Bd.create,pb=()=>xm().optional(),mb=()=>_m().optional(),yb=()=>wm().optional(),gb={string:r=>Ss.create({...r,coerce:!0}),number:r=>Ni.create({...r,coerce:!0}),boolean:r=>Ri.create({...r,coerce:!0}),bigint:r=>Bi.create({...r,coerce:!0}),date:r=>Pi.create({...r,coerce:!0})},vb=he;var x=Object.freeze({__proto__:null,defaultErrorMap:ks,setErrorMap:vv,getErrorMap:_o,makeIssue:wo,EMPTY_PATH:bv,addIssueToContext:q,ParseStatus:Et,INVALID:he,DIRTY:ls,OK:vt,isAborted:Fu,isDirty:Wu,isValid:ji,isAsync:Ti,get util(){return Ne},get objectUtil(){return Hu},ZodParsedType:K,getParsedType:Qr,ZodType:we,datetimeRegex:lm,ZodString:Ss,ZodNumber:Ni,ZodBigInt:Bi,ZodBoolean:Ri,ZodDate:Pi,ZodSymbol:So,ZodUndefined:$i,ZodNull:Zi,ZodAny:As,ZodUnknown:Nn,ZodNever:Mr,ZodVoid:Ao,ZodArray:Zn,ZodObject:Lt,ZodUnion:Di,ZodDiscriminatedUnion:fm,ZodIntersection:Mi,ZodTuple:ln,ZodRecord:mm,ZodMap:Oo,ZodSet:Eo,ZodFunction:ym,ZodLazy:Vi,ZodLiteral:Ui,ZodEnum:Za,ZodNativeEnum:Li,ZodPromise:Os,ZodEffects:sr,ZodTransformer:sr,ZodOptional:pr,ZodNullable:dn,ZodDefault:qi,ZodCatch:Hi,ZodNaN:Co,BRAND:Pv,ZodBranded:Nd,ZodPipeline:Bd,ZodReadonly:Fi,custom:bm,Schema:we,ZodSchema:we,late:$v,get ZodFirstPartyTypeKind(){return le},coerce:gb,any:Hv,array:Kv,bigint:Mv,boolean:wm,date:Vv,discriminatedUnion:Xv,effect:Lf,enum:ob,function:sb,instanceof:Zv,intersection:Qv,lazy:ib,literal:ab,map:rb,nan:Dv,nativeEnum:cb,never:Wv,null:qv,nullable:db,number:_m,object:Gv,oboolean:yb,onumber:mb,optional:lb,ostring:pb,pipeline:hb,preprocess:fb,promise:ub,record:tb,set:nb,strictObject:Jv,string:xm,symbol:Uv,transformer:Lf,tuple:eb,undefined:Lv,union:Yv,unknown:Fv,void:zv,NEVER:vb,ZodIssueCode:Z,quotelessJson:gv,ZodError:tr}),$t=class Qu extends yv{constructor(t){super(t);X(this,"openAPIRegistry");X(this,"defaultHook");X(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=ns("query",n.request.query,i);a.push(T)}if((f=n.request)!=null&&f.params){const T=ns("param",n.request.params,i);a.push(T)}if((m=n.request)!=null&&m.headers){const T=ns("header",n.request.headers,i);a.push(T)}if((B=n.request)!=null&&B.cookies){const T=ns("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 ye=o[T].schema;if(ye instanceof we){if(Hf(T)){const Ue=ns("json",ye,i);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Ue);else{const Le=async($e,et)=>{if($e.req.header("content-type")&&Hf($e.req.header("content-type")))return await Ue($e,et);$e.req.addValidatedData("json",{}),await et()};a.push(Le)}}if(Ff(T)){const Ue=ns("form",ye,i);if((R=(S=n.request)==null?void 0:S.body)!=null&&R.required)a.push(Ue);else{const Le=async($e,et)=>{if($e.req.header("content-type")&&Ff($e.req.header("content-type")))return await Ue($e,et);$e.req.addValidatedData("form",{}),await et()};a.push(Le)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,s),this});X(this,"getOpenAPIDocument",t=>{const s=new j0(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?qf(s,this._basePath):s});X(this,"getOpenAPI31Document",t=>{const s=new B0(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?qf(s,this._basePath):s});X(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)}}));X(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 f0,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Qu?(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:Xr(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:Xr(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 Qu({...super.basePath(t),defaultHook:this.defaultHook})}},Ce=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};c0(x);function qf(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[Xr(e,n)]=r.paths[n]}),{...r,paths:t}}function Hf(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function Ff(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function bb(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 xb(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ui(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 _b(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=bb(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(xb(this,"ZodObject")){const T=this.extend;R.extend=function(...ye){var Ue,Le,$e,et,ft,Tt;const E=T.apply(this,ye);return E._def.openapi={_internal:{extendedFrom:!((Le=(Ue=this._def.openapi)===null||Ue===void 0?void 0:Ue._internal)===null||Le===void 0)&&Le.refId?{refId:(et=($e=this._def.openapi)===null||$e===void 0?void 0:$e._internal)===null||et===void 0?void 0:et.refId,schema:this}:(ft=this._def.openapi)===null||ft===void 0?void 0:ft._internal.extendedFrom},metadata:(Tt=E._def.openapi)===null||Tt===void 0?void 0:Tt.metadata},E}}return R},ui(r,"optional"),ui(r,"nullable"),ui(r,"default"),ui(r,"transform"),ui(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 el;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(el||(el={}));const G=Be.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 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"]),wb=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 Es=(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 km=Es;function kb(r){km=r}function Io(){return km}const jo=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}},Sb=[];function H(r,e){const t=Io(),n=jo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Es?void 0:Es].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 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 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 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"}),To=r=>({status:"dirty",value:r}),bt=r=>({status:"valid",value:r}),tl=r=>r.status==="aborted",rl=r=>r.status==="dirty",Wi=r=>r.status==="valid",zi=r=>typeof Promise<"u"&&r instanceof Promise;function No(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 Sm(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 yi,gi;class xr{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 Wf=(r,e)=>{if(Wi(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 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:(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 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 pt,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(zi(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 Wf(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(zi(s)?s:Promise.resolve(s));return Wf(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 ir({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return mr.create(this,this._def)}nullable(){return mn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return rr.create(this,this._def)}promise(){return Is.create(this,this._def)}or(e){return Yi.create([this,e],this._def)}and(e){return Xi.create(this,e,this._def)}transform(e){return new ir({...be(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new na({...be(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new Rd({typeName:de.ZodBranded,type:this,...be(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new sa({...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 Da.create(this,e)}readonly(){return ia.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ab=/^c[^\s-]{8,}$/i,Ob=/^[0-9a-z]+$/,Eb=/^[0-9A-HJKMNP-TV-Z]{26}$/,Cb=/^[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,Ib=/^[a-z0-9_-]{21}$/i,jb=/^[-+]?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)?)??$/,Tb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ou;const Bb=/^(?:(?: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])$/,Rb=/^(([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})))$/,Pb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Am="((\\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])))",$b=new RegExp(`^${Am}$`);function Om(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 Zb(r){return new RegExp(`^${Om(r)}$`)}function Em(r){let e=`${Am}T${Om(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 Db(r,e){return!!((e==="v4"||!e)&&Bb.test(r)||(e==="v6"||!e)&&Rb.test(r))}class Qt 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}),me}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")Tb.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")Ou||(Ou=new RegExp(Nb,"u")),Ou.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")Cb.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")Ib.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")Ab.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")Ob.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")Eb.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"?Em(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"?$b.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Zb(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"?jb.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"duration",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Db(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"?Pb.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 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:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};function Mb(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 fn 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}),me}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"?Mb(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 fn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new fn({...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)}}fn.create=r=>new fn({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});class hn 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}),me}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 hn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_addCheck(e){return new hn({...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}}hn.create=r=>{var e;return new hn({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};class Ki 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}),me}return bt(e.data)}}Ki.create=r=>new Ki({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});class Dn 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}),me}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_date}),me}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 Dn({...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}}Dn.create=r=>new Dn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,...be(r)});class Bo 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}),me}return bt(e.data)}}Bo.create=r=>new Bo({typeName:de.ZodSymbol,...be(r)});class Gi 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}),me}return bt(e.data)}}Gi.create=r=>new Gi({typeName:de.ZodUndefined,...be(r)});class Ji 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}),me}return bt(e.data)}}Ji.create=r=>new Ji({typeName:de.ZodNull,...be(r)});class Cs extends ke{constructor(){super(...arguments),this._any=!0}_parse(e){return bt(e.data)}}Cs.create=r=>new Cs({typeName:de.ZodAny,...be(r)});class Bn extends ke{constructor(){super(...arguments),this._unknown=!0}_parse(e){return bt(e.data)}}Bn.create=r=>new Bn({typeName:de.ZodUnknown,...be(r)});class Vr extends ke{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:G.never,received:t.parsedType}),me}}Vr.create=r=>new Vr({typeName:de.ZodNever,...be(r)});class Ro 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}),me}return bt(e.data)}}Ro.create=r=>new Ro({typeName:de.ZodVoid,...be(r)});class rr 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}),me;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 xr(t,a,t.path,o)))).then(a=>pt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new xr(t,a,t.path,o)));return pt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new rr({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new rr({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new rr({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}rr.create=(r,e)=>new rr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,...be(e)});function cs(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=mr.create(cs(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof rr?new rr({...r._def,type:cs(r.element)}):r instanceof mr?mr.create(cs(r.unwrap())):r instanceof mn?mn.create(cs(r.unwrap())):r instanceof _r?_r.create(r.items.map(e=>cs(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}),me}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Vr&&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 xr(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Vr){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 xr(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:de.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 cs(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 mr;)s=s._def.innerType;t[n]=s}}),new Je({...this._def,shape:()=>t})}keyof(){return Cm(Be.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Vr.create(),typeName:de.ZodObject,...be(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Vr.create(),typeName:de.ZodObject,...be(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Vr.create(),typeName:de.ZodObject,...be(e)});class Yi 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}),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 Rt(c));return H(t,{code:D.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Yi.create=(r,e)=>new Yi({options:r,typeName:de.ZodUnion,...be(e)});const Yr=r=>r instanceof ea?Yr(r.schema):r instanceof ir?Yr(r.innerType()):r instanceof ta?[r.value]:r instanceof pn?r.options:r instanceof ra?Be.objectValues(r.enum):r instanceof na?Yr(r._def.innerType):r instanceof Gi?[void 0]:r instanceof Ji?[null]:r instanceof mr?[void 0,...Yr(r.unwrap())]:r instanceof mn?[null,...Yr(r.unwrap())]:r instanceof Rd||r instanceof ia?Yr(r.unwrap()):r instanceof sa?Yr(r._def.innerType):[];class Ac 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}),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}):(H(t,{code:D.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=Yr(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 Ac({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...be(n)})}}function nl(r,e){const t=en(r),n=en(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=nl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=nl(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 Xi extends ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(tl(i)||tl(a))return me;const o=nl(i.value,a.value);return o.valid?((rl(i)||rl(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:D.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}))}}Xi.create=(r,e,t)=>new Xi({left:r,right:e,typeName:de.ZodIntersection,...be(t)});class _r 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}),me;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"}),me;!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 xr(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 _r({...this._def,rest:e})}}_r.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new _r({items:r,typeName:de.ZodTuple,rest:null,...be(e)})};class Qi 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}),me;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new xr(n,o,n.path,o)),value:a._parse(new xr(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 Qi({keyType:e,valueType:t,typeName:de.ZodRecord,...be(n)}):new Qi({keyType:Qt.create(),valueType:e,typeName:de.ZodRecord,...be(t)})}}class Po 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}),me;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new xr(n,o,n.path,[u,"key"])),value:i._parse(new xr(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}}}}Po.create=(r,e,t)=>new Po({valueType:e,keyType:r,typeName:de.ZodMap,...be(t)});class Mn 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}),me;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 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 xr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Mn({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new Mn({...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)}}Mn.create=(r,e)=>new Mn({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,...be(e)});class ys 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}),me;function n(o,c){return jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Io(),Es].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function s(o,c){return jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Io(),Es].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 Is){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 ys({...this._def,args:_r.create(e).rest(Bn.create())})}returns(e){return new ys({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ys({args:e||_r.create([]).rest(Bn.create()),returns:t||Bn.create(),typeName:de.ZodFunction,...be(n)})}}class ea 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})}}ea.create=(r,e)=>new ea({getter:r,typeName:de.ZodLazy,...be(e)});class ta 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}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}ta.create=(r,e)=>new ta({value:r,typeName:de.ZodLiteral,...be(e)});function Cm(r,e){return new pn({values:r,typeName:de.ZodEnum,...be(e)})}class pn extends ke{constructor(){super(...arguments),yi.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}),me}if(No(this,yi)||Sm(this,yi,new Set(this._def.values)),!No(this,yi).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}),me}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 pn.create(e,{...this._def,...t})}exclude(e,t=this._def){return pn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}yi=new WeakMap;pn.create=Cm;class ra extends ke{constructor(){super(...arguments),gi.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}),me}if(No(this,gi)||Sm(this,gi,new Set(Be.getValidEnumValues(this._def.values))),!No(this,gi).has(e.data)){const s=Be.objectValues(t);return H(n,{received:n.data,code:D.invalid_enum_value,options:s}),me}return bt(e.data)}get enum(){return this._def.values}}gi=new WeakMap;ra.create=(r,e)=>new ra({values:r,typeName:de.ZodNativeEnum,...be(e)});class Is 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}),me;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})))}}Is.create=(r,e)=>new Is({type:r,typeName:de.ZodPromise,...be(e)});class ir extends ke{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=>{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 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"?To(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"?To(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(!Wi(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=>Wi(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Be.assertNever(s)}}ir.create=(r,e,t)=>new ir({schema:r,typeName:de.ZodEffects,effect:e,...be(t)});ir.createWithPreprocess=(r,e,t)=>new ir({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,...be(t)});class mr extends ke{_parse(e){return this._getType(e)===G.undefined?bt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mr.create=(r,e)=>new mr({innerType:r,typeName:de.ZodOptional,...be(e)});class mn extends ke{_parse(e){return this._getType(e)===G.null?bt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mn.create=(r,e)=>new mn({innerType:r,typeName:de.ZodNullable,...be(e)});class na 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}}na.create=(r,e)=>new na({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...be(e)});class sa 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 zi(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}}sa.create=(r,e)=>new sa({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...be(e)});class $o 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}),me}return{status:"valid",value:e.data}}}$o.create=r=>new $o({typeName:de.ZodNaN,...be(r)});const Vb=Symbol("zod_brand");class Rd 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 Da 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"?me:s.status==="dirty"?(t.dirty(),To(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"?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 Da({in:e,out:t,typeName:de.ZodPipeline})}}class ia extends ke{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Wi(s)&&(s.value=Object.freeze(s.value)),s);return zi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ia.create=(r,e)=>new ia({innerType:r,typeName:de.ZodReadonly,...be(e)});function Im(r,e={},t){return r?Cs.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})}}):Cs.create()}const Ub={object:Je.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 Lb=(r,e={message:`Input not instance of ${r.name}`})=>Im(t=>t instanceof r,e),jm=Qt.create,Tm=fn.create,qb=$o.create,Hb=hn.create,Nm=Ki.create,Fb=Dn.create,Wb=Bo.create,zb=Gi.create,Kb=Ji.create,Gb=Cs.create,Jb=Bn.create,Yb=Vr.create,Xb=Ro.create,Qb=rr.create,ex=Je.create,tx=Je.strictCreate,rx=Yi.create,nx=Ac.create,sx=Xi.create,ix=_r.create,ax=Qi.create,ox=Po.create,cx=Mn.create,ux=ys.create,lx=ea.create,dx=ta.create,fx=pn.create,hx=ra.create,px=Is.create,zf=ir.create,mx=mr.create,yx=mn.create,gx=ir.createWithPreprocess,vx=Da.create,bx=()=>jm().optional(),xx=()=>Tm().optional(),_x=()=>Nm().optional(),wx={string:r=>Qt.create({...r,coerce:!0}),number:r=>fn.create({...r,coerce:!0}),boolean:r=>Ki.create({...r,coerce:!0}),bigint:r=>hn.create({...r,coerce:!0}),date:r=>Dn.create({...r,coerce:!0})},kx=me;var d=Object.freeze({__proto__:null,defaultErrorMap:Es,setErrorMap:kb,getErrorMap:Io,makeIssue:jo,EMPTY_PATH:Sb,addIssueToContext:H,ParseStatus:pt,INVALID:me,DIRTY:To,OK:bt,isAborted:tl,isDirty:rl,isValid:Wi,isAsync:zi,get util(){return Be},get objectUtil(){return el},ZodParsedType:G,getParsedType:en,ZodType:ke,datetimeRegex:Em,ZodString:Qt,ZodNumber:fn,ZodBigInt:hn,ZodBoolean:Ki,ZodDate:Dn,ZodSymbol:Bo,ZodUndefined:Gi,ZodNull:Ji,ZodAny:Cs,ZodUnknown:Bn,ZodNever:Vr,ZodVoid:Ro,ZodArray:rr,ZodObject:Je,ZodUnion:Yi,ZodDiscriminatedUnion:Ac,ZodIntersection:Xi,ZodTuple:_r,ZodRecord:Qi,ZodMap:Po,ZodSet:Mn,ZodFunction:ys,ZodLazy:ea,ZodLiteral:ta,ZodEnum:pn,ZodNativeEnum:ra,ZodPromise:Is,ZodEffects:ir,ZodTransformer:ir,ZodOptional:mr,ZodNullable:mn,ZodDefault:na,ZodCatch:sa,ZodNaN:$o,BRAND:Vb,ZodBranded:Rd,ZodPipeline:Da,ZodReadonly:ia,custom:Im,Schema:ke,ZodSchema:ke,late:Ub,get ZodFirstPartyTypeKind(){return de},coerce:wx,any:Gb,array:Qb,bigint:Hb,boolean:Nm,date:Fb,discriminatedUnion:nx,effect:zf,enum:fx,function:ux,instanceof:Lb,intersection:sx,lazy:lx,literal:dx,map:ox,nan:qb,nativeEnum:hx,never:Yb,null:Kb,nullable:yx,number:Tm,object:ex,oboolean:_x,onumber:xx,optional:mx,ostring:bx,pipeline:vx,preprocess:gx,promise:px,record:ax,set:cx,strictObject:tx,string:jm,symbol:Wb,transformer:zf,tuple:ix,undefined:zb,union:rx,unknown:Jb,void:Xb,NEVER:kx,ZodIssueCode:D,quotelessJson:wb,ZodError:Rt});_b(d);const Qn=d.object({start:d.number(),limit:d.number(),length:d.number()}),Pd=d.object({created_at:d.string(),updated_at:d.string()}),Sx=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()),Ax=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:Sx.optional()}),$d=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()}),sl=$d.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")}),Bm=d.object({...sl.shape,...Pd.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(Ax).optional()}),Ir=Bm;$d.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 Ox="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ex=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=Ox[t[r]&63];return e};const Cx=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()}),il=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:Cx.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(()=>Ex()).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"})}),ds=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...il.shape});var Rm=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(Rm||{}),Pm=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(Pm||{}),$m=(r=>(r.S265="S256",r.plain="plain",r))($m||{});const Ix=d.object({client_id:d.string(),vendor_id:d.string().optional(),response_type:d.nativeEnum(Rm).optional(),response_mode:d.nativeEnum(Pm).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($m).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),Kf=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()}),al=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()}),fs=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(al.shape),ol=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()}),Ai=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...ol.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 jx=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({...ds.shape,domains:d.array(jx),tenant:Ai,connections:d.array(fs)});const Tx=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Nx=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:Tx,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()});d.object({...Nx.shape,created_at:d.string()});const Bx=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"])});Pd.extend({...Bx.shape,id:d.string()});const cl=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()}),vi=cl.extend({...Pd.shape,hook_id:d.string()}),Zm=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()}),Rx=d.object({keys:d.array(Zm)}),Gf=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())}),Px=d.object({auth0Client:d.string().optional(),authParams:Ix,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional()}).openapi({description:"This represents a login sesion"});d.object({...Px.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 Zd=(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))(Zd||{});const $x=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"]),Zx=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),ul=d.object({type:$x,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:Zx.optional()}),Dx=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")});d.object({...Dx.shape,created_at:d.string(),updated_at:d.string()});const Mx=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()}),Dm=d.object({created_at:d.string(),...Mx.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 Mm=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(Mm||{});const Dd=d.nativeEnum(Mm);d.object({grant_type:Dd.refine(r=>r==="authorization_code"),code:d.string(),client_secret:d.string(),client_id:d.string()});d.object({grant_type:Dd.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:Dd.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 Vx=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()}),Ux=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()}),is=d.object({bold:d.boolean(),size:d.number()}),Lx=d.object({body_text:is,buttons_text:is,font_url:d.string(),input_labels:is,links:is,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:is,title:is}),qx=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Hx=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"])}),Fx=d.object({borders:Vx,colors:Ux,displayName:d.string(),fonts:Lx,page_background:qx,widget:Hx});Fx.extend({themeId:d.string()});const Eu=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 Zo=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 zx(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 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
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 Pf;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof Ao=="object"?Ao: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 uu(Object.create(null))}:c?function(){return uu({__proto__:null})}:function(){return uu({})},has:u?function(x,k){return n.call(x,k)}:function(x,k){return k in x},get:u?function(x,k){return n.call(x,k)?x[k]:void 0}:function(x,k){return x[k]}},m=Object.getPrototypeOf(Function),D=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Cg(),j=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:jg(),p=typeof WeakMap=="function"?WeakMap:Tg(),g=s?Symbol.for("@reflect-metadata:registry"):void 0,A=Og(),S=Eg(A);function B(x,k,C,U){if(ee(C)){if(!ff(x))throw new TypeError;if(!hf(k))throw new TypeError;return O(x,k)}else{if(!ff(x))throw new TypeError;if(!Le(k))throw new TypeError;if(!Le(U)&&!ee(U)&&!st(U))throw new TypeError;return st(U)&&(U=void 0),C=ar(C),w(x,k,C,U)}}e("decorate",B);function T(x,k){function C(U,ue){if(!Le(U))throw new TypeError;if(!ee(ue)&&!Sg(ue))throw new TypeError;Ae(x,k,U,ue)}return C}e("metadata",T);function ye(x,k,C,U){if(!Le(C))throw new TypeError;return ee(U)||(U=ar(U)),Ae(x,k,C,U)}e("defineMetadata",ye);function Me(x,k,C){if(!Le(k))throw new TypeError;return ee(C)||(C=ar(C)),b(x,k,C)}e("hasMetadata",Me);function Ve(x,k,C){if(!Le(k))throw new TypeError;return ee(C)||(C=ar(C)),v(x,k,C)}e("hasOwnMetadata",Ve);function Pe(x,k,C){if(!Le(k))throw new TypeError;return ee(C)||(C=ar(C)),I(x,k,C)}e("getMetadata",Pe);function Xe(x,k,C){if(!Le(k))throw new TypeError;return ee(C)||(C=ar(C)),M(x,k,C)}e("getOwnMetadata",Xe);function lt(x,k){if(!Le(x))throw new TypeError;return ee(k)||(k=ar(k)),ie(x,k)}e("getMetadataKeys",lt);function It(x,k){if(!Le(x))throw new TypeError;return ee(k)||(k=ar(k)),Ie(x,k)}e("getOwnMetadataKeys",It);function E(x,k,C){if(!Le(k))throw new TypeError;if(ee(C)||(C=ar(C)),!Le(k))throw new TypeError;ee(C)||(C=ar(C));var U=zs(k,C,!1);return ee(U)?!1:U.OrdinaryDeleteMetadata(x,k,C)}e("deleteMetadata",E);function O(x,k){for(var C=x.length-1;C>=0;--C){var U=x[C],ue=U(k);if(!ee(ue)&&!st(ue)){if(!hf(ue))throw new TypeError;k=ue}}return k}function w(x,k,C,U){for(var ue=x.length-1;ue>=0;--ue){var it=x[ue],et=it(k,C,U);if(!ee(et)&&!st(et)){if(!Le(et))throw new TypeError;U=et}}return U}function b(x,k,C){var U=v(x,k,C);if(U)return!0;var ue=cu(k);return st(ue)?!1:b(x,ue,C)}function v(x,k,C){var U=zs(k,C,!1);return ee(U)?!1:df(U.OrdinaryHasOwnMetadata(x,k,C))}function I(x,k,C){var U=v(x,k,C);if(U)return M(x,k,C);var ue=cu(k);if(!st(ue))return I(x,ue,C)}function M(x,k,C){var U=zs(k,C,!1);if(!ee(U))return U.OrdinaryGetOwnMetadata(x,k,C)}function Ae(x,k,C,U){var ue=zs(C,U,!0);ue.OrdinaryDefineOwnMetadata(x,k,C,U)}function ie(x,k){var C=Ie(x,k),U=cu(x);if(U===null)return C;var ue=ie(U,k);if(ue.length<=0)return C;if(C.length<=0)return ue;for(var it=new j,et=[],Oe=0,z=C;Oe<z.length;Oe++){var te=z[Oe],re=it.has(te);re||(it.add(te),et.push(te))}for(var se=0,Ce=ue;se<Ce.length;se++){var te=Ce[se],re=it.has(te);re||(it.add(te),et.push(te))}return et}function Ie(x,k){var C=zs(x,k,!1);return C?C.OrdinaryOwnMetadataKeys(x,k):[]}function Ze(x){if(x===null)return 1;switch(typeof x){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return x===null?1:6;default:return 6}}function ee(x){return x===void 0}function st(x){return x===null}function yn(x){return typeof x=="symbol"}function Le(x){return typeof x=="object"?x!==null:typeof x=="function"}function Qe(x,k){switch(Ze(x)){case 0:return x;case 1:return x;case 2:return x;case 3:return x;case 4:return x;case 5:return x}var C="string",U=pf(x,i);if(U!==void 0){var ue=U.call(x,C);if(Le(ue))throw new TypeError;return ue}return wg(x)}function wg(x,k){var C,U;{var ue=x.toString;if(qa(ue)){var U=ue.call(x);if(!Le(U))return U}var C=x.valueOf;if(qa(C)){var U=C.call(x);if(!Le(U))return U}}throw new TypeError}function df(x){return!!x}function kg(x){return""+x}function ar(x){var k=Qe(x);return yn(k)?k:kg(k)}function ff(x){return Array.isArray?Array.isArray(x):x instanceof Object?x instanceof Array:Object.prototype.toString.call(x)==="[object Array]"}function qa(x){return typeof x=="function"}function hf(x){return typeof x=="function"}function Sg(x){switch(Ze(x)){case 3:return!0;case 4:return!0;default:return!1}}function ou(x,k){return x===k||x!==x&&k!==k}function pf(x,k){var C=x[k];if(C!=null){if(!qa(C))throw new TypeError;return C}}function mf(x){var k=pf(x,a);if(!qa(k))throw new TypeError;var C=k.call(x);if(!Le(C))throw new TypeError;return C}function yf(x){return x.value}function gf(x){var k=x.next();return k.done?!1:k}function vf(x){var k=x.return;k&&k.call(x)}function cu(x){var k=Object.getPrototypeOf(x);if(typeof x!="function"||x===m||k!==m)return k;var C=x.prototype,U=C&&Object.getPrototypeOf(C);if(U==null||U===Object.prototype)return k;var ue=U.constructor;return typeof ue!="function"||ue===x?k:ue}function Ag(){var x;!ee(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(x=Ig(t.Reflect));var k,C,U,ue=new p,it={registerProvider:et,getProvider:z,setProvider:re};return it;function et(se){if(!Object.isExtensible(it))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case x===se:break;case ee(k):k=se;break;case k===se:break;case ee(C):C=se;break;case C===se:break;default:U===void 0&&(U=new j),U.add(se);break}}function Oe(se,Ce){if(!ee(k)){if(k.isProviderFor(se,Ce))return k;if(!ee(C)){if(C.isProviderFor(se,Ce))return k;if(!ee(U))for(var qe=mf(U);;){var Je=gf(qe);if(!Je)return;var qt=yf(Je);if(qt.isProviderFor(se,Ce))return vf(qe),qt}}}if(!ee(x)&&x.isProviderFor(se,Ce))return x}function z(se,Ce){var qe=ue.get(se),Je;return ee(qe)||(Je=qe.get(Ce)),ee(Je)&&(Je=Oe(se,Ce),ee(Je)||(ee(qe)&&(qe=new D,ue.set(se,qe)),qe.set(Ce,Je))),Je}function te(se){if(ee(se))throw new TypeError;return k===se||C===se||!ee(U)&&U.has(se)}function re(se,Ce,qe){if(!te(qe))throw new Error("Metadata provider not registered.");var Je=z(se,Ce);if(Je!==qe){if(!ee(Je))return!1;var qt=ue.get(se);ee(qt)&&(qt=new D,ue.set(se,qt)),qt.set(Ce,qe)}return!0}}function Og(){var x;return!ee(g)&&Le(t.Reflect)&&Object.isExtensible(t.Reflect)&&(x=t.Reflect[g]),ee(x)&&(x=Ag()),!ee(g)&&Le(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:x}),x}function Eg(x){var k=new p,C={isProviderFor:function(te,re){var se=k.get(te);return ee(se)?!1:se.has(re)},OrdinaryDefineOwnMetadata:et,OrdinaryHasOwnMetadata:ue,OrdinaryGetOwnMetadata:it,OrdinaryOwnMetadataKeys:Oe,OrdinaryDeleteMetadata:z};return A.registerProvider(C),C;function U(te,re,se){var Ce=k.get(te),qe=!1;if(ee(Ce)){if(!se)return;Ce=new D,k.set(te,Ce),qe=!0}var Je=Ce.get(re);if(ee(Je)){if(!se)return;if(Je=new D,Ce.set(re,Je),!x.setProvider(te,re,C))throw Ce.delete(re),qe&&k.delete(te),new Error("Wrong provider for target.")}return Je}function ue(te,re,se){var Ce=U(re,se,!1);return ee(Ce)?!1:df(Ce.has(te))}function it(te,re,se){var Ce=U(re,se,!1);if(!ee(Ce))return Ce.get(te)}function et(te,re,se,Ce){var qe=U(se,Ce,!0);qe.set(te,re)}function Oe(te,re){var se=[],Ce=U(te,re,!1);if(ee(Ce))return se;for(var qe=Ce.keys(),Je=mf(qe),qt=0;;){var bf=gf(Je);if(!bf)return se.length=qt,se;var Ng=yf(bf);try{se[qt]=Ng}catch(Bg){try{vf(Je)}finally{throw Bg}}qt++}}function z(te,re,se){var Ce=U(re,se,!1);if(ee(Ce)||!Ce.delete(te))return!1;if(Ce.size===0){var qe=k.get(re);ee(qe)||(qe.delete(se),qe.size===0&&k.delete(qe))}return!0}}function Ig(x){var k=x.defineMetadata,C=x.hasOwnMetadata,U=x.getOwnMetadata,ue=x.getOwnMetadataKeys,it=x.deleteMetadata,et=new p,Oe={isProviderFor:function(z,te){var re=et.get(z);return!ee(re)&&re.has(te)?!0:ue(z,te).length?(ee(re)&&(re=new j,et.set(z,re)),re.add(te),!0):!1},OrdinaryDefineOwnMetadata:k,OrdinaryHasOwnMetadata:C,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:ue,OrdinaryDeleteMetadata:it};return Oe}function zs(x,k,C){var U=A.getProvider(x,k);if(!ee(U))return U;if(C){if(A.setProvider(x,k,S))return S;throw new Error("Illegal state.")}}function Cg(){var x={},k=[],C=function(){function Oe(z,te,re){this._index=0,this._keys=z,this._values=te,this._selector=re}return Oe.prototype["@@iterator"]=function(){return this},Oe.prototype[a]=function(){return this},Oe.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}},Oe.prototype.throw=function(z){throw this._index>=0&&(this._index=-1,this._keys=k,this._values=k),z},Oe.prototype.return=function(z){return this._index>=0&&(this._index=-1,this._keys=k,this._values=k),{value:z,done:!0}},Oe}(),U=function(){function Oe(){this._keys=[],this._values=[],this._cacheKey=x,this._cacheIndex=-2}return Object.defineProperty(Oe.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Oe.prototype.has=function(z){return this._find(z,!1)>=0},Oe.prototype.get=function(z){var te=this._find(z,!1);return te>=0?this._values[te]:void 0},Oe.prototype.set=function(z,te){var re=this._find(z,!0);return this._values[re]=te,this},Oe.prototype.delete=function(z){var te=this._find(z,!1);if(te>=0){for(var re=this._keys.length,se=te+1;se<re;se++)this._keys[se-1]=this._keys[se],this._values[se-1]=this._values[se];return this._keys.length--,this._values.length--,ou(z,this._cacheKey)&&(this._cacheKey=x,this._cacheIndex=-2),!0}return!1},Oe.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=x,this._cacheIndex=-2},Oe.prototype.keys=function(){return new C(this._keys,this._values,ue)},Oe.prototype.values=function(){return new C(this._keys,this._values,it)},Oe.prototype.entries=function(){return new C(this._keys,this._values,et)},Oe.prototype["@@iterator"]=function(){return this.entries()},Oe.prototype[a]=function(){return this.entries()},Oe.prototype._find=function(z,te){if(!ou(this._cacheKey,z)){this._cacheIndex=-1;for(var re=0;re<this._keys.length;re++)if(ou(this._keys[re],z)){this._cacheIndex=re;break}}return this._cacheIndex<0&&te&&(this._cacheIndex=this._keys.length,this._keys.push(z),this._values.push(void 0)),this._cacheIndex},Oe}();return U;function ue(Oe,z){return Oe}function it(Oe,z){return z}function et(Oe,z){return[Oe,z]}}function jg(){var x=function(){function k(){this._map=new D}return Object.defineProperty(k.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),k.prototype.has=function(C){return this._map.has(C)},k.prototype.add=function(C){return this._map.set(C,C),this},k.prototype.delete=function(C){return this._map.delete(C)},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 x}function Tg(){var x=16,k=f.create(),C=U();return function(){function z(){this._key=U()}return z.prototype.has=function(te){var re=ue(te,!1);return re!==void 0?f.has(re,this._key):!1},z.prototype.get=function(te){var re=ue(te,!1);return re!==void 0?f.get(re,this._key):void 0},z.prototype.set=function(te,re){var se=ue(te,!0);return se[this._key]=re,this},z.prototype.delete=function(te){var re=ue(te,!1);return re!==void 0?delete re[this._key]:!1},z.prototype.clear=function(){this._key=U()},z}();function U(){var z;do z="@@WeakMap@@"+Oe();while(f.has(k,z));return k[z]=!0,z}function ue(z,te){if(!n.call(z,C)){if(!te)return;Object.defineProperty(z,C,{value:f.create()})}return z[C]}function it(z,te){for(var re=0;re<te;++re)z[re]=Math.random()*255|0;return z}function et(z){if(typeof Uint8Array=="function"){var te=new Uint8Array(z);return typeof crypto<"u"?crypto.getRandomValues(te):typeof msCrypto<"u"?msCrypto.getRandomValues(te):it(te,z),te}return it(new Array(z),z)}function Oe(){var z=et(x);z[6]=z[6]&79|64,z[8]=z[8]&191|128;for(var te="",re=0;re<x;++re){var se=z[re];(re===4||re===6||re===8)&&(te+="-"),se<16&&(te+="0"),te+=se.toString(16).toLowerCase()}return te}}function uu(x){return x.__=void 0,delete x.__,x}})})(Pf||(Pf={}));/*!
14
+ ***************************************************************************** */var Jf;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof Zo=="object"?Zo: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 _u(Object.create(null))}:c?function(){return _u({__proto__:null})}:function(){return _u({})},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:e0(),j=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:t0(),p=typeof WeakMap=="function"?WeakMap:r0(),g=s?Symbol.for("@reflect-metadata:registry"):void 0,A=Yg(),S=Xg(A);function R(_,k,I,U){if(ee(I)){if(!Ef(_))throw new TypeError;if(!Cf(k))throw new TypeError;return O(_,k)}else{if(!Ef(_))throw new TypeError;if(!qe(k))throw new TypeError;if(!qe(U)&&!ee(U)&&!ot(U))throw new TypeError;return ot(U)&&(U=void 0),I=lr(I),w(_,k,I,U)}}e("decorate",R);function T(_,k){function I(U,ue){if(!qe(U))throw new TypeError;if(!ee(ue)&&!Gg(ue))throw new TypeError;Ae(_,k,U,ue)}return I}e("metadata",T);function ye(_,k,I,U){if(!qe(I))throw new TypeError;return ee(U)||(U=lr(U)),Ae(_,k,I,U)}e("defineMetadata",ye);function Ue(_,k,I){if(!qe(k))throw new TypeError;return ee(I)||(I=lr(I)),b(_,k,I)}e("hasMetadata",Ue);function Le(_,k,I){if(!qe(k))throw new TypeError;return ee(I)||(I=lr(I)),v(_,k,I)}e("hasOwnMetadata",Le);function $e(_,k,I){if(!qe(k))throw new TypeError;return ee(I)||(I=lr(I)),C(_,k,I)}e("getMetadata",$e);function et(_,k,I){if(!qe(k))throw new TypeError;return ee(I)||(I=lr(I)),V(_,k,I)}e("getOwnMetadata",et);function ft(_,k){if(!qe(_))throw new TypeError;return ee(k)||(k=lr(k)),ie(_,k)}e("getMetadataKeys",ft);function Tt(_,k){if(!qe(_))throw new TypeError;return ee(k)||(k=lr(k)),Ie(_,k)}e("getOwnMetadataKeys",Tt);function E(_,k,I){if(!qe(k))throw new TypeError;if(ee(I)||(I=lr(I)),!qe(k))throw new TypeError;ee(I)||(I=lr(I));var U=ii(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],ue=U(k);if(!ee(ue)&&!ot(ue)){if(!Cf(ue))throw new TypeError;k=ue}}return k}function w(_,k,I,U){for(var ue=_.length-1;ue>=0;--ue){var ct=_[ue],rt=ct(k,I,U);if(!ee(rt)&&!ot(rt)){if(!qe(rt))throw new TypeError;U=rt}}return U}function b(_,k,I){var U=v(_,k,I);if(U)return!0;var ue=xu(k);return ot(ue)?!1:b(_,ue,I)}function v(_,k,I){var U=ii(k,I,!1);return ee(U)?!1:Of(U.OrdinaryHasOwnMetadata(_,k,I))}function C(_,k,I){var U=v(_,k,I);if(U)return V(_,k,I);var ue=xu(k);if(!ot(ue))return C(_,ue,I)}function V(_,k,I){var U=ii(k,I,!1);if(!ee(U))return U.OrdinaryGetOwnMetadata(_,k,I)}function Ae(_,k,I,U){var ue=ii(I,U,!0);ue.OrdinaryDefineOwnMetadata(_,k,I,U)}function ie(_,k){var I=Ie(_,k),U=xu(_);if(U===null)return I;var ue=ie(U,k);if(ue.length<=0)return I;if(I.length<=0)return ue;for(var ct=new j,rt=[],Oe=0,z=I;Oe<z.length;Oe++){var te=z[Oe],re=ct.has(te);re||(ct.add(te),rt.push(te))}for(var se=0,je=ue;se<je.length;se++){var te=je[se],re=ct.has(te);re||(ct.add(te),rt.push(te))}return rt}function Ie(_,k){var I=ii(_,k,!1);return I?I.OrdinaryOwnMetadataKeys(_,k):[]}function Me(_){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 ot(_){return _===null}function An(_){return typeof _=="symbol"}function qe(_){return typeof _=="object"?_!==null:typeof _=="function"}function tt(_,k){switch(Me(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var I="string",U=If(_,i);if(U!==void 0){var ue=U.call(_,I);if(qe(ue))throw new TypeError;return ue}return zg(_)}function zg(_,k){var I,U;{var ue=_.toString;if(to(ue)){var U=ue.call(_);if(!qe(U))return U}var I=_.valueOf;if(to(I)){var U=I.call(_);if(!qe(U))return U}}throw new TypeError}function Of(_){return!!_}function Kg(_){return""+_}function lr(_){var k=tt(_);return An(k)?k:Kg(k)}function Ef(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function to(_){return typeof _=="function"}function Cf(_){return typeof _=="function"}function Gg(_){switch(Me(_)){case 3:return!0;case 4:return!0;default:return!1}}function bu(_,k){return _===k||_!==_&&k!==k}function If(_,k){var I=_[k];if(I!=null){if(!to(I))throw new TypeError;return I}}function jf(_){var k=If(_,a);if(!to(k))throw new TypeError;var I=k.call(_);if(!qe(I))throw new TypeError;return I}function Tf(_){return _.value}function Nf(_){var k=_.next();return k.done?!1:k}function Bf(_){var k=_.return;k&&k.call(_)}function xu(_){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 ue=U.constructor;return typeof ue!="function"||ue===_?k:ue}function Jg(){var _;!ee(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=Qg(t.Reflect));var k,I,U,ue=new p,ct={registerProvider:rt,getProvider:z,setProvider:re};return ct;function rt(se){if(!Object.isExtensible(ct))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 Oe(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 Fe=jf(U);;){var Xe=Nf(Fe);if(!Xe)return;var zt=Tf(Xe);if(zt.isProviderFor(se,je))return Bf(Fe),zt}}}if(!ee(_)&&_.isProviderFor(se,je))return _}function z(se,je){var Fe=ue.get(se),Xe;return ee(Fe)||(Xe=Fe.get(je)),ee(Xe)&&(Xe=Oe(se,je),ee(Xe)||(ee(Fe)&&(Fe=new B,ue.set(se,Fe)),Fe.set(je,Xe))),Xe}function te(se){if(ee(se))throw new TypeError;return k===se||I===se||!ee(U)&&U.has(se)}function re(se,je,Fe){if(!te(Fe))throw new Error("Metadata provider not registered.");var Xe=z(se,je);if(Xe!==Fe){if(!ee(Xe))return!1;var zt=ue.get(se);ee(zt)&&(zt=new B,ue.set(se,zt)),zt.set(je,Fe)}return!0}}function Yg(){var _;return!ee(g)&&qe(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[g]),ee(_)&&(_=Jg()),!ee(g)&&qe(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function Xg(_){var k=new p,I={isProviderFor:function(te,re){var se=k.get(te);return ee(se)?!1:se.has(re)},OrdinaryDefineOwnMetadata:rt,OrdinaryHasOwnMetadata:ue,OrdinaryGetOwnMetadata:ct,OrdinaryOwnMetadataKeys:Oe,OrdinaryDeleteMetadata:z};return A.registerProvider(I),I;function U(te,re,se){var je=k.get(te),Fe=!1;if(ee(je)){if(!se)return;je=new B,k.set(te,je),Fe=!0}var Xe=je.get(re);if(ee(Xe)){if(!se)return;if(Xe=new B,je.set(re,Xe),!_.setProvider(te,re,I))throw je.delete(re),Fe&&k.delete(te),new Error("Wrong provider for target.")}return Xe}function ue(te,re,se){var je=U(re,se,!1);return ee(je)?!1:Of(je.has(te))}function ct(te,re,se){var je=U(re,se,!1);if(!ee(je))return je.get(te)}function rt(te,re,se,je){var Fe=U(se,je,!0);Fe.set(te,re)}function Oe(te,re){var se=[],je=U(te,re,!1);if(ee(je))return se;for(var Fe=je.keys(),Xe=jf(Fe),zt=0;;){var Rf=Nf(Xe);if(!Rf)return se.length=zt,se;var n0=Tf(Rf);try{se[zt]=n0}catch(s0){try{Bf(Xe)}finally{throw s0}}zt++}}function z(te,re,se){var je=U(re,se,!1);if(ee(je)||!je.delete(te))return!1;if(je.size===0){var Fe=k.get(re);ee(Fe)||(Fe.delete(se),Fe.size===0&&k.delete(Fe))}return!0}}function Qg(_){var k=_.defineMetadata,I=_.hasOwnMetadata,U=_.getOwnMetadata,ue=_.getOwnMetadataKeys,ct=_.deleteMetadata,rt=new p,Oe={isProviderFor:function(z,te){var re=rt.get(z);return!ee(re)&&re.has(te)?!0:ue(z,te).length?(ee(re)&&(re=new j,rt.set(z,re)),re.add(te),!0):!1},OrdinaryDefineOwnMetadata:k,OrdinaryHasOwnMetadata:I,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:ue,OrdinaryDeleteMetadata:ct};return Oe}function ii(_,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 e0(){var _={},k=[],I=function(){function Oe(z,te,re){this._index=0,this._keys=z,this._values=te,this._selector=re}return Oe.prototype["@@iterator"]=function(){return this},Oe.prototype[a]=function(){return this},Oe.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}},Oe.prototype.throw=function(z){throw this._index>=0&&(this._index=-1,this._keys=k,this._values=k),z},Oe.prototype.return=function(z){return this._index>=0&&(this._index=-1,this._keys=k,this._values=k),{value:z,done:!0}},Oe}(),U=function(){function Oe(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(Oe.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Oe.prototype.has=function(z){return this._find(z,!1)>=0},Oe.prototype.get=function(z){var te=this._find(z,!1);return te>=0?this._values[te]:void 0},Oe.prototype.set=function(z,te){var re=this._find(z,!0);return this._values[re]=te,this},Oe.prototype.delete=function(z){var te=this._find(z,!1);if(te>=0){for(var re=this._keys.length,se=te+1;se<re;se++)this._keys[se-1]=this._keys[se],this._values[se-1]=this._values[se];return this._keys.length--,this._values.length--,bu(z,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},Oe.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},Oe.prototype.keys=function(){return new I(this._keys,this._values,ue)},Oe.prototype.values=function(){return new I(this._keys,this._values,ct)},Oe.prototype.entries=function(){return new I(this._keys,this._values,rt)},Oe.prototype["@@iterator"]=function(){return this.entries()},Oe.prototype[a]=function(){return this.entries()},Oe.prototype._find=function(z,te){if(!bu(this._cacheKey,z)){this._cacheIndex=-1;for(var re=0;re<this._keys.length;re++)if(bu(this._keys[re],z)){this._cacheIndex=re;break}}return this._cacheIndex<0&&te&&(this._cacheIndex=this._keys.length,this._keys.push(z),this._values.push(void 0)),this._cacheIndex},Oe}();return U;function ue(Oe,z){return Oe}function ct(Oe,z){return z}function rt(Oe,z){return[Oe,z]}}function t0(){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 r0(){var _=16,k=f.create(),I=U();return function(){function z(){this._key=U()}return z.prototype.has=function(te){var re=ue(te,!1);return re!==void 0?f.has(re,this._key):!1},z.prototype.get=function(te){var re=ue(te,!1);return re!==void 0?f.get(re,this._key):void 0},z.prototype.set=function(te,re){var se=ue(te,!0);return se[this._key]=re,this},z.prototype.delete=function(te){var re=ue(te,!1);return re!==void 0?delete re[this._key]:!1},z.prototype.clear=function(){this._key=U()},z}();function U(){var z;do z="@@WeakMap@@"+Oe();while(f.has(k,z));return k[z]=!0,z}function ue(z,te){if(!n.call(z,I)){if(!te)return;Object.defineProperty(z,I,{value:f.create()})}return z[I]}function ct(z,te){for(var re=0;re<te;++re)z[re]=Math.random()*255|0;return z}function rt(z){if(typeof Uint8Array=="function"){var te=new Uint8Array(z);return typeof crypto<"u"?crypto.getRandomValues(te):typeof msCrypto<"u"?msCrypto.getRandomValues(te):ct(te,z),te}return ct(new Array(z),z)}function Oe(){var z=rt(_);z[6]=z[6]&79|64,z[8]=z[8]&191|128;for(var te="",re=0;re<_;++re){var se=z[re];(re===4||re===6||re===8)&&(te+="-"),se<16&&(te+="0"),te+=se.toString(16).toLowerCase()}return te}}function _u(_){return _.__=void 0,delete _.__,_}})})(Jf||(Jf={}));/*!
15
15
  * MIT License
16
16
  *
17
17
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -34,9 +34,9 @@ and limitations under the License.
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 kx="[object ArrayBuffer]";class L{static isArrayBuffer(e){return Object.prototype.toString.call(e)===kx}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 mu="string",Sx=/^[0-9a-f]+$/i,Ax=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Ox=/^[a-zA-Z0-9-_]+$/;class $f{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 or{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 ne{static isHex(e){return typeof e===mu&&Sx.test(e)}static isBase64(e){return typeof e===mu&&Ax.test(e)}static isBase64Url(e){return typeof e===mu&&Ox.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 or.toString(n,!0);case"utf16":case"utf16be":return or.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 or.fromString(e,!0);case"utf16":case"utf16be":return or.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(!ne.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(!ne.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=ne.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return $f.fromString(e);case"utf16":case"utf16be":return or.fromString(e);case"utf16le":case"usc2":return or.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=ne.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return $f.toString(e);case"utf16":case"utf16be":return or.toString(e);case"utf16le":case"usc2":return or.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(!ne.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 or.toString(e,t)}static FromUtf16String(e,t=!1){return or.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,""))||""}}ne.DEFAULT_UTF8_ENCODING="utf8";function Ex(...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 mm(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 Kx="[object ArrayBuffer]";class L{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Kx}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 Cu="string",Gx=/^[0-9a-f]+$/i,Jx=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Yx=/^[a-zA-Z0-9-_]+$/;class Yf{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 dr{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 ne{static isHex(e){return typeof e===Cu&&Gx.test(e)}static isBase64(e){return typeof e===Cu&&Jx.test(e)}static isBase64Url(e){return typeof e===Cu&&Yx.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 dr.toString(n,!0);case"utf16":case"utf16be":return dr.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 dr.fromString(e,!0);case"utf16":case"utf16be":return dr.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(!ne.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(!ne.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=ne.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Yf.fromString(e);case"utf16":case"utf16be":return dr.fromString(e);case"utf16le":case"usc2":return dr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=ne.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Yf.toString(e);case"utf16":case"utf16be":return dr.toString(e);case"utf16le":case"usc2":return dr.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(!ne.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 dr.toString(e,t)}static FromUtf16String(e,t=!1){return dr.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,""))||""}}ne.DEFAULT_UTF8_ENCODING="utf8";function Xx(...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 Vm(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 gs(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 Cn(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 Ju(...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 ym(){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=gs(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,gs(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=Cn(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let s=Cn(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 Cx(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 Ct(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 js(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 Vn(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 ll(...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 Um(){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=js(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,js(i,8)-n}function Qx(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=Vn(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let s=Vn(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 e_(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 Nt(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 @@ and limitations under the License.
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 Oo(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Sd(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 Ur(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 pc{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Sd(this.items)}}const Xs=[new Uint8Array([1])],Zf="0123456789",yu="name",Df="valueHexView",jx="isHexOnly",Tx="idBlock",Nx="tagClass",Bx="tagNumber",Rx="isConstructed",Px="fromBER",$x="toBER",Zx="local",wt="",sr=new ArrayBuffer(0),mc=new Uint8Array(0),Ki="EndOfContent",gm="OCTET STRING",vm="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?L.toUint8Array(i.valueHex):mc}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(!Ur(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",sr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:ne.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Un{constructor({blockLength:e=0,error:t=wt,warnings:n=[],valueBeforeDecode:s=mc}={}){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:ne.ToHex(this.valueBeforeDecodeView)}}}Un.NAME="baseBlock";class xt extends Un{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 bm extends _r(Un){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):mc,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",sr}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=Cn(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(!Ur(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 D=new Uint8Array(f);for(let j=0;j<u.length;j++)D[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 D=0;D<c;D++)m[D]=u[D];u=this.valueHexView=new Uint8Array(c),u.set(m),this.blockLength<=9?this.tagNumber=gs(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}}}bm.NAME="identificationBlock";class xm extends Un{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(!Ur(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=gs(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=Cn(this.length,8);if(s.byteLength>127)return this.error="Too big length",sr;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}}}xm.NAME="lengthBlock";const Q={};class ct extends Un{constructor({name:e=wt,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new bm(s),this.lenBlock=new xm(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 pc;t||_m(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?sr: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():ne.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${ne.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 Cx(t,n)}}ct.NAME="BaseBlock";function _m(r){if(r instanceof Q.Constructed)for(const e of r.valueBlock.value)_m(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class Ad extends ct{constructor({value:e=wt,...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}'`}}Ad.NAME="BaseStringBlock";class wm extends _r(xt){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}wm.NAME="PrimitiveValueBlock";var km;class Ea extends ct{constructor(e={}){super(e,wm),this.idBlock.isConstructed=!1}}km=Ea;Q.Primitive=km;Ea.NAME="PRIMITIVE";function Dx(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 Ps(r,e=0,t=r.length){const n=e;let s=new ct({},xt);const i=new Un;if(!Ur(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=ct;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=Dx(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 ct({},xt);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Ps(L.toUint8Array(r).slice(),0,r.byteLength)}function Mx(r,e){return r?1:e}class Yr 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(!Ur(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(;Mx(this.isIndefiniteForm,n)>0;){const a=Ps(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===Ki)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Ki?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const n=t||new pc;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?sr:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}Yr.NAME="ConstructedValueBlock";var Sm;class kt extends ct{constructor(e={}){super(e,Yr),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 Do(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Md(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 Kr(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 Oc{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Md(this.items)}}const li=[new Uint8Array([1])],Xf="0123456789",Iu="name",Qf="valueHexView",t_="isHexOnly",r_="idBlock",n_="tagClass",s_="tagNumber",i_="isConstructed",a_="fromBER",o_="toBER",c_="local",At="",cr=new ArrayBuffer(0),Ec=new Uint8Array(0),aa="EndOfContent",Lm="OCTET STRING",qm="BIT STRING";function Ar(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):Ec}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(!Kr(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",cr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:ne.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class es{constructor({blockLength:e=0,error:t=At,warnings:n=[],valueBeforeDecode:s=Ec}={}){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:ne.ToHex(this.valueBeforeDecodeView)}}}es.NAME="baseBlock";class wt extends es{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 Hm extends Ar(es){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):Ec,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",cr}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=Vn(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(!Kr(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=js(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}}}Hm.NAME="identificationBlock";class Fm extends es{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(!Kr(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=js(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=Vn(this.length,8);if(s.byteLength>127)return this.error="Too big length",cr;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}}}Fm.NAME="lengthBlock";const Q={};class lt extends es{constructor({name:e=At,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Hm(s),this.lenBlock=new Fm(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 Oc;t||Wm(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?cr: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():ne.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${ne.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 e_(t,n)}}lt.NAME="BaseBlock";function Wm(r){if(r instanceof Q.Constructed)for(const e of r.valueBlock.value)Wm(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class Vd extends lt{constructor({value:e=At,...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}'`}}Vd.NAME="BaseStringBlock";class zm extends Ar(wt){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}zm.NAME="PrimitiveValueBlock";var Km;class Ma extends lt{constructor(e={}){super(e,zm),this.idBlock.isConstructed=!1}}Km=Ma;Q.Primitive=Km;Ma.NAME="PRIMITIVE";function u_(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 lt({},wt);const i=new es;if(!Kr(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=lt;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=u_(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 gs(r){if(!r.byteLength){const e=new lt({},wt);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Ks(L.toUint8Array(r).slice(),0,r.byteLength)}function l_(r,e){return r?1:e}class on extends wt{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(!Kr(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(;l_(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===aa)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===aa?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const n=t||new Oc;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?cr:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}on.NAME="ConstructedValueBlock";var Gm;class Ot extends lt{constructor(e={}){super(e,on),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} :`}}Sm=kt;Q.Constructed=Sm;kt.NAME="CONSTRUCTED";class Am extends xt{fromBER(e,t,n){return t}toBER(e){return sr}}Am.override="EndOfContentValueBlock";var Om;class Od extends ct{constructor(e={}){super(e,Am),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Om=Od;Q.EndOfContent=Om;Od.NAME=Ki;var Em;class jn extends ct{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}`}}Em=jn;Q.Null=Em;jn.NAME="NULL";class Im extends _r(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 Ur(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,ym.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Im.NAME="BooleanValueBlock";var Cm;let yc=class extends ct{constructor(e={}){super(e,Im),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}`}};Cm=yc;Q.Boolean=Cm;yc.NAME="BOOLEAN";class jm extends _r(Yr){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=Yr.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===Ki){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==gm)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?Yr.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}jm.NAME="OctetStringValueBlock";var Tm;let kn=class Nm extends ct{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},jm),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=Ps(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?kt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${ne.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 Nm&&e.push(t.valueBlock.valueHexView);return L.concat(e)}};Tm=kn;Q.OctetString=Tm;kn.NAME=gm;class Bm extends _r(Yr){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=Yr.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(const o of this.value){const c=o.constructor.NAME;if(c===Ki){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==vm)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(!Ur(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=Ps(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 Yr.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return sr;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}}}Bm.NAME="BitStringValueBlock";var Rm;let Sn=class extends ct{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},Bm),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 kt.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)}`}}};Rm=Sn;Q.BitString=Rm;Sn.NAME=vm;var Pm;function Vx(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 D=f;D>=0;D--,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=Ju(new Uint8Array([u%10]),i);break;default:i[a-m]=u%10}}return t[0]>0&&(i=Ju(t,i)),i}function Mf(r){if(r>=Xs.length)for(let e=Xs.length;e<=r;e++){const t=new Uint8Array([0]);let n=Xs[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=Ju(t,n)),Xs.push(n)}return Xs[r]}function Ux(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 Ed extends _r(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=ym.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=Ux(Mf(n),t),a="-";break;default:t=Vx(t,Mf(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Zf.charAt(t[c]));return o===!1&&(a+=Zf.charAt(0)),a}}Pm=Ed;Ed.NAME="IntegerValueBlock";Object.defineProperty(Pm.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var $m;class fr extends ct{constructor(e={}){super(e,Ed),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Oo(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Oo();const t=BigInt(e),n=new pc,s=t.toString(16).replace(/^-/,""),i=new Uint8Array(ne.FromHex(s));if(t<0){const o=new Uint8Array(i.length+(i[0]&128?1:0));o[0]|=128;const u=BigInt(`0x${ne.ToHex(o)}`)+t,f=L.toUint8Array(ne.FromHex(u.toString(16)));f[0]|=128,n.write(f)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new fr({valueHex:n.final()})}convertToDER(){const e=new fr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new fr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}$m=fr;Q.Integer=$m;fr.NAME="INTEGER";var Zm;class gc extends fr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Zm=gc;Q.Enumerated=Zm;gc.NAME="ENUMERATED";class Yu extends _r(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(!Ur(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=gs(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Oo();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=Cn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",sr;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=ne.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}}}Yu.NAME="sidBlock";class Dm extends xt{constructor({value:e=wt,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new Yu;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,sr;t.push(s)}return Sd(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 Yu;if(s>Number.MAX_SAFE_INTEGER){Oo();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}}Dm.NAME="ObjectIdentifierValueBlock";var Mm;class vc extends ct{constructor(e={}){super(e,Dm),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()}}}Mm=vc;Q.ObjectIdentifier=Mm;vc.NAME="OBJECT IDENTIFIER";class Xu extends _r(Un){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(!Ur(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=gs(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=Cn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",sr;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=ne.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Xu.NAME="relativeSidBlock";class Vm extends xt{constructor({value:e=wt,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new Xu;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,sr;n.push(i)}return Sd(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 Xu;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}}Vm.NAME="RelativeObjectIdentifierValueBlock";var Um;class Id extends ct{constructor(e={}){super(e,Vm),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()}}}Um=Id;Q.RelativeObjectIdentifier=Um;Id.NAME="RelativeObjectIdentifier";var Lm;class Tr extends kt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}Lm=Tr;Q.Sequence=Lm;Tr.NAME="SEQUENCE";var qm;let Nr=class extends kt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};qm=Nr;Q.Set=qm;Nr.NAME="SET";class Hm extends _r(xt){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=wt}toJSON(){return{...super.toJSON(),value:this.value}}}Hm.NAME="StringValueBlock";class Fm extends Hm{}Fm.NAME="SimpleStringValueBlock";class Rt extends Ad{constructor({...e}={}){super(e,Fm)}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}}Rt.NAME="SIMPLE STRING";class Wm extends Rt{fromBuffer(e){this.valueBlock.valueHexView=L.toUint8Array(e);try{this.valueBlock.value=ne.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=ne.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(ne.FromUtf8String(e)),this.valueBlock.value=e}}Wm.NAME="Utf8StringValueBlock";var zm;class Lr extends Wm{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}zm=Lr;Q.Utf8String=zm;Lr.NAME="UTF8String";class Km extends Rt{fromBuffer(e){this.valueBlock.value=ne.ToUtf16String(e),this.valueBlock.valueHexView=L.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(ne.FromUtf16String(e))}}Km.NAME="BmpStringValueBlock";var Gm;class bc extends Km{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Gm=bc;Q.BmpString=Gm;bc.NAME="BMPString";class Jm extends Rt{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=Cn(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}}Jm.NAME="UniversalStringValueBlock";var Ym;class xc extends Jm{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Ym=xc;Q.UniversalString=Ym;xc.NAME="UniversalString";var Xm;class _c extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Xm=_c;Q.NumericString=Xm;_c.NAME="NumericString";var Qm;class wc extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Qm=wc;Q.PrintableString=Qm;wc.NAME="PrintableString";var ey;class kc extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}ey=kc;Q.TeletexString=ey;kc.NAME="TeletexString";var ty;class Sc extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}ty=Sc;Q.VideotexString=ty;Sc.NAME="VideotexString";var ry;class Ac extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}ry=Ac;Q.IA5String=ry;Ac.NAME="IA5String";var ny;class Oc extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}ny=Oc;Q.GraphicString=ny;Oc.NAME="GraphicString";var sy;class Ia extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}sy=Ia;Q.VisibleString=sy;Ia.NAME="VisibleString";var iy;class Ec extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}iy=Ec;Q.GeneralString=iy;Ec.NAME="GeneralString";var ay;class Ic extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}ay=Ic;Q.CharacterString=ay;Ic.NAME="CharacterString";var oy;class Ca extends Ia{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]=Ct(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ct(this.month,2),t[2]=Ct(this.day,2),t[3]=Ct(this.hour,2),t[4]=Ct(this.minute,2),t[5]=Ct(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}}}oy=Ca;Q.UTCTime=oy;Ca.NAME="UTCTime";var cy;class Cc extends Ca{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,D=n.indexOf("+"),j="";if(D===-1&&(D=n.indexOf("-"),m=-1),D!==-1){if(j=n.substring(D+1),n=n.substring(0,D),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(Ct(this.year,4)),t.push(Ct(this.month,2)),t.push(Ct(this.day,2)),t.push(Ct(this.hour,2)),t.push(Ct(this.minute,2)),t.push(Ct(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ct(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}cy=Cc;Q.GeneralizedTime=cy;Cc.NAME="GeneralizedTime";var uy;class Cd extends Lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}uy=Cd;Q.DATE=uy;Cd.NAME="DATE";var ly;class jd extends Lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}ly=jd;Q.TimeOfDay=ly;jd.NAME="TimeOfDay";var dy;class Td extends Lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}dy=Td;Q.DateTime=dy;Td.NAME="DateTime";var fy;class Nd extends Lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}fy=Nd;Q.Duration=fy;Nd.NAME="Duration";var hy;class Bd extends Lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}hy=Bd;Q.TIME=hy;Bd.NAME="TIME";class Tn{constructor({name:e=wt,optional:t=!1}={}){this.name=e,this.optional=t}}class Rd extends Tn{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Eo extends Tn{constructor({value:e=new Tn,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class Lx{constructor({data:e=mc}={}){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 vn(r,e,t){if(t instanceof Rd){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(yu)&&(i.name=t.name),i}}if(t instanceof Tn)return t.hasOwnProperty(yu)&&(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(!(Tx in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Px in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!($x 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(Nx)===!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(Bx)===!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(Rx)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(jx 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(!(Df 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,wt),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 Eo&&(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,wt),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,wt),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof Eo){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,wt),t.name&&delete r[t.name]),a;if(yu in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};Zx 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,wt),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,wt),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&Df in e.valueBlock){const i=Ps(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,wt),t.name&&(delete r[t.name],a.name=t.name)),a}return vn(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function qx(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Ps(L.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:vn(t.result,t.result,e)}const py=Object.freeze(Object.defineProperty({__proto__:null,Any:Tn,BaseBlock:ct,BaseStringBlock:Ad,BitString:Sn,BmpString:bc,Boolean:yc,CharacterString:Ic,Choice:Rd,Constructed:kt,DATE:Cd,DateTime:Td,Duration:Nd,EndOfContent:Od,Enumerated:gc,GeneralString:Ec,GeneralizedTime:Cc,GraphicString:Oc,HexBlock:_r,IA5String:Ac,Integer:fr,Null:jn,NumericString:_c,ObjectIdentifier:vc,OctetString:kn,Primitive:Ea,PrintableString:wc,RawData:Lx,RelativeObjectIdentifier:Id,Repeated:Eo,Sequence:Tr,Set:Nr,TIME:Bd,TeletexString:kc,TimeOfDay:jd,UTCTime:Ca,UniversalString:xc,Utf8String:Lr,ValueBlock:xt,VideotexString:Sc,ViewWriter:pc,VisibleString:Ia,compareSchema:vn,fromBER:ss,verifySchema:qx},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 jc{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 Sn))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 Sn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Sn({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 kn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new kn({valueHex:this.buffer})}toSchema(e){return new kn({name:e})}}const Hx={fromASN:r=>r instanceof jn?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new jn;const e=ss(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Fx={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new fr({value:+r})},Wx={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new gc({value:r})},He={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new fr({valueHex:r})},zx={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Sn({valueHex:r})},Kx={fromASN:r=>r.valueBlock.toString(),toASN:r=>new vc({value:r})},Gx={fromASN:r=>r.valueBlock.value,toASN:r=>new yc({value:r})},Io={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new kn({valueHex:r})},Jx={fromASN:r=>new Re(r.getValue()),toASN:r=>r.toASN()};function Mt(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const my=Mt(Lr),Yx=Mt(bc),Xx=Mt(xc),Qx=Mt(_c),e_=Mt(wc),t_=Mt(kc),r_=Mt(Sc),n_=Mt(Ac),s_=Mt(Oc),i_=Mt(Ia),a_=Mt(Ec),o_=Mt(Ic),c_={fromASN:r=>r.toDate(),toASN:r=>new Ca({valueDate:r})},u_={fromASN:r=>r.toDate(),toASN:r=>new Cc({valueDate:r})},l_={fromASN:()=>null,toASN:()=>new jn};function Pd(r){switch(r){case y.Any:return Hx;case y.BitString:return zx;case y.BmpString:return Yx;case y.Boolean:return Gx;case y.CharacterString:return o_;case y.Enumerated:return Wx;case y.GeneralString:return a_;case y.GeneralizedTime:return u_;case y.GraphicString:return s_;case y.IA5String:return n_;case y.Integer:return Fx;case y.Null:return l_;case y.NumericString:return Qx;case y.ObjectIdentifier:return Kx;case y.OctetString:return Io;case y.PrintableString:return e_;case y.TeletexString:return t_;case y.UTCTime:return c_;case y.UniversalString:return Xx;case y.Utf8String:return my;case y.VideotexString:return r_;case y.VisibleString:return i_;default:return null}}function jr(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:jr(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function yy(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:yy(t)}return!1}function d_(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 f_{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=py[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else jr(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===N.Choice?c=new Tn({name:o}):(c=this.create(a.type,!1),c.name=o):c=new Tn({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const f=a.repeated==="set"?Nr:Tr;c=new f({name:"",value:[new Eo({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||jr(a.type)){const f=a.repeated?kt:Ea;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 kt({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else s.push(new kt({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 Tr({value:s,name:""});case N.Set:return new Nr({value:s,name:""});case N.Choice:return new Rd({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 $t=new f_,R=r=>e=>{let t;$t.has(e)?t=$t.get(e):(t=$t.createDefault(e),$t.set(e,t)),Object.assign(t,r)},h=r=>(e,t)=>{let n;$t.has(e.constructor)?n=$t.get(e.constructor):(n=$t.createDefault(e.constructor),$t.set(e.constructor,n));const s=Object.assign({},r);if(typeof s.type=="number"&&!s.converter){const i=Pd(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 Vf extends Error{constructor(){super(...arguments),this.schemas=[]}}class h_{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(jr(t))return new t().fromASN(e);const s=$t.get(t);$t.cache(t);let i=s.schema;if(e.constructor===kt&&s.type!==N.Choice){i=new kt({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 Vf(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(yy(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=Pd(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"||jr(m)){const D=(n=f.converter)!==null&&n!==void 0?n:jr(m)?new m:null;if(!D)throw new Error("Converter is empty");if(f.repeated)if(f.implicit){const j=f.repeated==="sequence"?Tr:Nr,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=>D.fromASN(S))}else o[c]=Array.from(u,j=>D.fromASN(j));else{let j=u;if(f.implicit){let p;if(jr(m))p=new m().toSchema("");else{const g=y[m],A=py[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]=D.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,D=>this.fromASN(D,m))}else o[c]=this.fromASN(u,m)}return o}catch(s){throw s instanceof Vf&&s.schemas.push(t.name),s}}}class $d{static serialize(e){return e instanceof ct?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&jr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=$t.get(t);$t.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=Pd(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"&&d_(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=$d.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||jr(o.type))){const f={};f.valueHex=u instanceof jn?u.valueBeforeDecodeView:u.valueBlock.toBER(),s.push(new Ea({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else s.push(new kt({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else s.push(new kt({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 Tr({value:s});break;case N.Set:i=new Nr({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"?Tr:Nr;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"?Tr:Nr;i=new o({value:a})}else i=this.toASN(s);return i}}class De extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class W{static serialize(e){return $d.serialize(e)}static parse(e,t){return h_.parse(e,t)}static toString(e){const t=L.isBufferSource(e)?L.toArrayBuffer(e):W.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}var gy={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,B=(p.match(c.zoneIndex)||[])[0],T,ye;for(B&&(B=B.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(ye=g-A,T=":";ye--;)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 Me=p.split(":"),Ve=[];for(let Pe=0;Pe<Me.length;Pe++)Ve.push(parseInt(Me[Pe],16));return Ve}(),{parts:g,zoneId:B}}function f(p,g,A,S){if(p.length!==g.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let B=0,T;for(;S>0;){if(T=A-S,T<0&&(T=0),p[B]>>T!==g[B]>>T)return!1;S-=A,B+=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 D(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 B,T,ye;for(B=3;B>=0;B-=1)if(T=this.octets[B],T in S){if(ye=S[T],A&&ye!==0)return null;ye!==8&&(A=!0),g+=ye}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(),B=[];let T=0;for(;T<4;)B.push(parseInt(A[T],10)|parseInt(S[T],10)^255),T++;return new this(B)}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,B,T;try{for(g=this.parseCIDR(p),S=g[0].toByteArray(),T=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),B=[],A=0;A<4;)B.push(parseInt(S[A],10)&parseInt(T[A],10)),A++;return new this(B)}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 B=g.slice(1,6),T=[];for(let ye=0;ye<B.length;ye++)A=B[ye],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 B=[];let T;for(T=0;T<=24;T+=8)B.push(S>>T&255);return B}().reverse()}else return(g=p.match(n.twoOctet))?function(){const B=g.slice(1,4),T=[];if(S=m(B[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return T.push(m(B[0])),T.push(S>>16&255),T.push(S>>8&255),T.push(S&255),T}():(g=p.match(n.threeOctet))?function(){const B=g.slice(1,5),T=[];if(S=m(B[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return T.push(m(B[0])),T.push(m(B[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,B;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(B=this.parts[S],!(0<=B&&B<=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 B,T;for(let ye=7;ye>=0;ye-=1)if(B=this.parts[ye],B in S){if(T=S[B],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 B=0;B<S.length;B++)g=S[B],A.push(g>>8),A.push(g&255);return A},p.prototype.toFixedLengthString=function(){const g=(function(){const S=[];for(let B=0;B<this.parts.length;B++)S.push(D(this.parts[B].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 B=0;B<this.parts.length;B++)S.push(this.parts[B].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,B=-1,T;for(;T=g.exec(A);)T[0].length>B&&(S=T.index,B=T[0].length);return B<0?A:`${A.substring(0,S)}::${A.substring(S+B)}`},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(),B=[];let T=0;for(;T<16;)B.push(parseInt(A[T],10)|parseInt(S[T],10)^255),T++;return new this(B)}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,B,T;try{for(g=this.parseCIDR(p),S=g[0].toByteArray(),T=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),B=[],A=0;A<16;)B.push(parseInt(S[A],10)&parseInt(T[A],10)),A++;return new this(B)}catch(ye){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ye})`)}},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,B,T,ye;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))&&(ye=S[6]||"",g=S[1],S[1].endsWith("::")||(g=g.slice(0,-1)),g=u(g+ye,6),g.parts)){for(T=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],A=0;A<T.length;A++)if(B=T[A],!(0<=B&&B<=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,B,T,ye;A==null&&(A="unicast");for(B in g)if(Object.prototype.hasOwnProperty.call(g,B)){for(T=g[B],T[0]&&!(T[0]instanceof Array)&&(T=[T]),S=0;S<T.length;S++)if(ye=T[S],p.kind()===ye[0].kind()&&p.match.apply(p,ye))return B}return A},r.exports?r.exports=j:e.ipaddr=j})(Ao)})(gy);var Uf=gy.exports;class Lf{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 Uf.fromByteArray(Array.from(t)).toString()}return this.decodeIP(ne.ToHex(e))}static fromString(e){const t=Uf.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var Qu,el,tl;let ut=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};l([h({type:y.TeletexString})],ut.prototype,"teletexString",void 0);l([h({type:y.PrintableString})],ut.prototype,"printableString",void 0);l([h({type:y.UniversalString})],ut.prototype,"universalString",void 0);l([h({type:y.Utf8String})],ut.prototype,"utf8String",void 0);l([h({type:y.BmpString})],ut.prototype,"bmpString",void 0);ut=l([R({type:N.Choice})],ut);let vs=class extends ut{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?ne.ToHex(this.anyValue):super.toString())}};l([h({type:y.IA5String})],vs.prototype,"ia5String",void 0);l([h({type:y.Any})],vs.prototype,"anyValue",void 0);vs=l([R({type:N.Choice})],vs);class Tc{constructor(e={}){this.type="",this.value=new vs,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Tc.prototype,"type",void 0);l([h({type:vs})],Tc.prototype,"value",void 0);let bs=Qu=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Qu.prototype)}};bs=Qu=l([R({type:N.Set,itemType:Tc})],bs);let rl=el=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,el.prototype)}};rl=el=l([R({type:N.Sequence,itemType:bs})],rl);let rt=tl=class extends rl{constructor(e){super(e),Object.setPrototypeOf(this,tl.prototype)}};rt=tl=l([R({type:N.Sequence})],rt);const p_={fromASN:r=>Lf.toString(Io.fromASN(r)),toASN:r=>Io.toASN(Lf.fromString(r))};class Gi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Gi.prototype,"typeId",void 0);l([h({type:y.Any,context:0})],Gi.prototype,"value",void 0);class Zd{constructor(e={}){this.partyName=new ut,Object.assign(this,e)}}l([h({type:ut,optional:!0,context:0,implicit:!0})],Zd.prototype,"nameAssigner",void 0);l([h({type:ut,context:1,implicit:!0})],Zd.prototype,"partyName",void 0);let ge=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Gi,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:rt,context:4,implicit:!1})],ge.prototype,"directoryName",void 0);l([h({type:Zd,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:p_})],ge.prototype,"iPAddress",void 0);l([h({type:y.ObjectIdentifier,context:8,implicit:!0})],ge.prototype,"registeredID",void 0);ge=l([R({type:N.Choice})],ge);const Dd="1.3.6.1.5.5.7",m_=`${Dd}.1`,$s=`${Dd}.3`,Nc=`${Dd}.48`,qf=`${Nc}.1`,Hf=`${Nc}.2`,Ff=`${Nc}.3`,Wf=`${Nc}.5`,hn="2.5.29";var nl;const sl=`${m_}.1`;class ja{constructor(e={}){this.accessMethod="",this.accessLocation=new ge,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],ja.prototype,"accessMethod",void 0);l([h({type:ge})],ja.prototype,"accessLocation",void 0);let es=nl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,nl.prototype)}};es=nl=l([R({type:N.Sequence,itemType:ja})],es);const il=`${hn}.35`;class Md extends Re{}class bn{constructor(e={}){e&&Object.assign(this,e)}}l([h({type:Md,context:0,optional:!0,implicit:!0})],bn.prototype,"keyIdentifier",void 0);l([h({type:ge,context:1,optional:!0,implicit:!0,repeated:"sequence"})],bn.prototype,"authorityCertIssuer",void 0);l([h({type:y.Integer,context:2,optional:!0,implicit:!0,converter:He})],bn.prototype,"authorityCertSerialNumber",void 0);const vy=`${hn}.19`;class Co{constructor(e={}){this.cA=!1,Object.assign(this,e)}}l([h({type:y.Boolean,defaultValue:!1})],Co.prototype,"cA",void 0);l([h({type:y.Integer,optional:!0})],Co.prototype,"pathLenConstraint",void 0);var al;let mt=al=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,al.prototype)}};mt=al=l([R({type:N.Sequence,itemType:ge})],mt);var ol;let zf=ol=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,ol.prototype)}};zf=ol=l([R({type:N.Sequence})],zf);var cl;const by=`${hn}.32`;let Pr=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};l([h({type:y.IA5String})],Pr.prototype,"ia5String",void 0);l([h({type:y.VisibleString})],Pr.prototype,"visibleString",void 0);l([h({type:y.BmpString})],Pr.prototype,"bmpString",void 0);l([h({type:y.Utf8String})],Pr.prototype,"utf8String",void 0);Pr=l([R({type:N.Choice})],Pr);class Vd{constructor(e={}){this.organization=new Pr,this.noticeNumbers=[],Object.assign(this,e)}}l([h({type:Pr})],Vd.prototype,"organization",void 0);l([h({type:y.Integer,repeated:"sequence"})],Vd.prototype,"noticeNumbers",void 0);class Ud{constructor(e={}){Object.assign(this,e)}}l([h({type:Vd,optional:!0})],Ud.prototype,"noticeRef",void 0);l([h({type:Pr,optional:!0})],Ud.prototype,"explicitText",void 0);let jo=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.IA5String})],jo.prototype,"cPSuri",void 0);l([h({type:Ud})],jo.prototype,"userNotice",void 0);jo=l([R({type:N.Choice})],jo);class Ld{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Ld.prototype,"policyQualifierId",void 0);l([h({type:y.Any})],Ld.prototype,"qualifier",void 0);class Bc{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Bc.prototype,"policyIdentifier",void 0);l([h({type:Ld,repeated:"sequence",optional:!0})],Bc.prototype,"policyQualifiers",void 0);let To=cl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,cl.prototype)}};To=cl=l([R({type:N.Sequence,itemType:Bc})],To);let No=class{constructor(e=0){this.value=e}};l([h({type:y.Integer})],No.prototype,"value",void 0);No=l([R({type:N.Choice})],No);let Kf=class extends No{};Kf=l([R({type:N.Choice})],Kf);var ul;const ll=`${hn}.31`;var Ft;(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"})(Ft||(Ft={}));class xy extends jc{toJSON(){const e=[],t=this.toNumber();return t&Ft.aACompromise&&e.push("aACompromise"),t&Ft.affiliationChanged&&e.push("affiliationChanged"),t&Ft.cACompromise&&e.push("cACompromise"),t&Ft.certificateHold&&e.push("certificateHold"),t&Ft.cessationOfOperation&&e.push("cessationOfOperation"),t&Ft.keyCompromise&&e.push("keyCompromise"),t&Ft.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Ft.superseded&&e.push("superseded"),t&Ft.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let Nn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,repeated:"sequence",implicit:!0})],Nn.prototype,"fullName",void 0);l([h({type:bs,context:1,implicit:!0})],Nn.prototype,"nameRelativeToCRLIssuer",void 0);Nn=l([R({type:N.Choice})],Nn);class Zs{constructor(e={}){Object.assign(this,e)}}l([h({type:Nn,context:0,optional:!0})],Zs.prototype,"distributionPoint",void 0);l([h({type:xy,context:1,optional:!0,implicit:!0})],Zs.prototype,"reasons",void 0);l([h({type:ge,context:2,optional:!0,repeated:"sequence",implicit:!0})],Zs.prototype,"cRLIssuer",void 0);let is=ul=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,ul.prototype)}};is=ul=l([R({type:N.Sequence,itemType:Zs})],is);var dl;let Gf=dl=class extends is{constructor(e){super(e),Object.setPrototypeOf(this,dl.prototype)}};Gf=dl=l([R({type:N.Sequence,itemType:Zs})],Gf);class dt{constructor(e={}){this.onlyContainsUserCerts=dt.ONLY,this.onlyContainsCACerts=dt.ONLY,this.indirectCRL=dt.ONLY,this.onlyContainsAttributeCerts=dt.ONLY,Object.assign(this,e)}}dt.ONLY=!1;l([h({type:Nn,context:0,optional:!0})],dt.prototype,"distributionPoint",void 0);l([h({type:y.Boolean,context:1,defaultValue:dt.ONLY,implicit:!0})],dt.prototype,"onlyContainsUserCerts",void 0);l([h({type:y.Boolean,context:2,defaultValue:dt.ONLY,implicit:!0})],dt.prototype,"onlyContainsCACerts",void 0);l([h({type:xy,context:3,optional:!0,implicit:!0})],dt.prototype,"onlySomeReasons",void 0);l([h({type:y.Boolean,context:4,defaultValue:dt.ONLY,implicit:!0})],dt.prototype,"indirectCRL",void 0);l([h({type:y.Boolean,context:5,defaultValue:dt.ONLY,implicit:!0})],dt.prototype,"onlyContainsAttributeCerts",void 0);var pi;(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"})(pi||(pi={}));let fl=class{constructor(e=pi.unspecified){this.reason=pi.unspecified,this.reason=e}toJSON(){return pi[this.reason]}toString(){return this.toJSON()}};l([h({type:y.Enumerated})],fl.prototype,"reason",void 0);fl=l([R({type:N.Choice})],fl);var hl;const _y=`${hn}.37`;let Bo=hl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,hl.prototype)}};Bo=hl=l([R({type:N.Sequence,itemType:y.ObjectIdentifier})],Bo);const y_=`${$s}.1`,g_=`${$s}.2`,v_=`${$s}.3`,b_=`${$s}.4`,x_=`${$s}.8`,__=`${$s}.9`;let pl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};l([h({type:y.Integer,converter:He})],pl.prototype,"value",void 0);pl=l([R({type:N.Choice})],pl);let ml=class{constructor(e){this.value=new Date,e&&(this.value=e)}};l([h({type:y.GeneralizedTime})],ml.prototype,"value",void 0);ml=l([R({type:N.Choice})],ml);var yl;let Jf=yl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,yl.prototype)}};Jf=yl=l([R({type:N.Sequence})],Jf);const wy=`${hn}.15`;var Wt;(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"})(Wt||(Wt={}));class gu extends jc{toJSON(){const e=this.toNumber(),t=[];return e&Wt.cRLSign&&t.push("crlSign"),e&Wt.dataEncipherment&&t.push("dataEncipherment"),e&Wt.decipherOnly&&t.push("decipherOnly"),e&Wt.digitalSignature&&t.push("digitalSignature"),e&Wt.encipherOnly&&t.push("encipherOnly"),e&Wt.keyAgreement&&t.push("keyAgreement"),e&Wt.keyCertSign&&t.push("keyCertSign"),e&Wt.keyEncipherment&&t.push("keyEncipherment"),e&Wt.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var gl;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 Ro=gl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,gl.prototype)}};Ro=gl=l([R({type:N.Sequence,itemType:Rc})],Ro);class ky{constructor(e={}){Object.assign(this,e)}}l([h({type:Ro,context:0,optional:!0,implicit:!0})],ky.prototype,"permittedSubtrees",void 0);l([h({type:Ro,context:1,optional:!0,implicit:!0})],ky.prototype,"excludedSubtrees",void 0);class Sy{constructor(e={}){Object.assign(this,e)}}l([h({type:y.Integer,context:0,implicit:!0,optional:!0,converter:He})],Sy.prototype,"requireExplicitPolicy",void 0);l([h({type:y.Integer,context:1,implicit:!0,optional:!0,converter:He})],Sy.prototype,"inhibitPolicyMapping",void 0);var vl;class qd{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],qd.prototype,"issuerDomainPolicy",void 0);l([h({type:y.ObjectIdentifier})],qd.prototype,"subjectDomainPolicy",void 0);let Yf=vl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,vl.prototype)}};Yf=vl=l([R({type:N.Sequence,itemType:qd})],Yf);var bl;const Ay=`${hn}.17`;let xl=bl=class extends mt{constructor(e){super(e),Object.setPrototypeOf(this,bl.prototype)}};xl=bl=l([R({type:N.Sequence})],xl);let $r=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],$r.prototype,"type",void 0);l([h({type:y.Any,repeated:"set"})],$r.prototype,"values",void 0);var _l;let Xf=_l=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,_l.prototype)}};Xf=_l=l([R({type:N.Sequence,itemType:$r})],Xf);const Oy=`${hn}.14`;class Xr extends Md{}class Ey{constructor(e={}){Object.assign(this,e)}}l([h({type:y.GeneralizedTime,context:0,implicit:!0,optional:!0})],Ey.prototype,"notBefore",void 0);l([h({type:y.GeneralizedTime,context:1,implicit:!0,optional:!0})],Ey.prototype,"notAfter",void 0);var mi;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(mi||(mi={}));class Iy extends jc{toJSON(){const e=[],t=this.toNumber();return t&mi.pKIXCertificate&&e.push("pKIXCertificate"),t&mi.newExtensions&&e.push("newExtensions"),t&mi.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Cy{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Iy,Object.assign(this,e)}}l([h({type:y.GeneralString})],Cy.prototype,"entrustVers",void 0);l([h({type:Iy})],Cy.prototype,"entrustInfoFlags",void 0);var wl;let Qf=wl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,wl.prototype)}};Qf=wl=l([R({type:N.Sequence,itemType:ja})],Qf);class X{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof X&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&mm(e.parameters,this.parameters)||e.parameters===this.parameters)}}l([h({type:y.ObjectIdentifier})],X.prototype,"algorithm",void 0);l([h({type:y.Any,optional:!0})],X.prototype,"parameters",void 0);class ur{constructor(e={}){this.algorithm=new X,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:X})],ur.prototype,"algorithm",void 0);l([h({type:y.BitString})],ur.prototype,"subjectPublicKey",void 0);let ot=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})],ot.prototype,"utcTime",void 0);l([h({type:y.GeneralizedTime})],ot.prototype,"generalTime",void 0);ot=l([R({type:N.Choice})],ot);class Pc{constructor(e){this.notBefore=new ot(new Date),this.notAfter=new ot(new Date),e&&(this.notBefore=new ot(e.notBefore),this.notAfter=new ot(e.notAfter))}}l([h({type:ot})],Pc.prototype,"notBefore",void 0);l([h({type:ot})],Pc.prototype,"notAfter",void 0);var kl;let rr=class jy{constructor(e={}){this.extnID="",this.critical=jy.CRITICAL,this.extnValue=new Re,Object.assign(this,e)}};rr.CRITICAL=!1;l([h({type:y.ObjectIdentifier})],rr.prototype,"extnID",void 0);l([h({type:y.Boolean,defaultValue:rr.CRITICAL})],rr.prototype,"critical",void 0);l([h({type:Re})],rr.prototype,"extnValue",void 0);let Bn=kl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,kl.prototype)}};Bn=kl=l([R({type:N.Sequence,itemType:rr})],Bn);var xs;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(xs||(xs={}));class Vt{constructor(e={}){this.version=xs.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new X,this.issuer=new rt,this.validity=new Pc,this.subject=new rt,this.subjectPublicKeyInfo=new ur,Object.assign(this,e)}}l([h({type:y.Integer,context:0,defaultValue:xs.v1})],Vt.prototype,"version",void 0);l([h({type:y.Integer,converter:He})],Vt.prototype,"serialNumber",void 0);l([h({type:X})],Vt.prototype,"signature",void 0);l([h({type:rt})],Vt.prototype,"issuer",void 0);l([h({type:Pc})],Vt.prototype,"validity",void 0);l([h({type:rt})],Vt.prototype,"subject",void 0);l([h({type:ur})],Vt.prototype,"subjectPublicKeyInfo",void 0);l([h({type:y.BitString,context:1,implicit:!0,optional:!0})],Vt.prototype,"issuerUniqueID",void 0);l([h({type:y.BitString,context:2,implicit:!0,optional:!0})],Vt.prototype,"subjectUniqueID",void 0);l([h({type:Bn,context:3,optional:!0})],Vt.prototype,"extensions",void 0);class _s{constructor(e={}){this.tbsCertificate=new Vt,this.signatureAlgorithm=new X,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Vt})],_s.prototype,"tbsCertificate",void 0);l([h({type:X})],_s.prototype,"signatureAlgorithm",void 0);l([h({type:y.BitString})],_s.prototype,"signatureValue",void 0);class $c{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new ot,Object.assign(this,e)}}l([h({type:y.Integer,converter:He})],$c.prototype,"userCertificate",void 0);l([h({type:ot})],$c.prototype,"revocationDate",void 0);l([h({type:rr,optional:!0,repeated:"sequence"})],$c.prototype,"crlEntryExtensions",void 0);class qr{constructor(e={}){this.signature=new X,this.issuer=new rt,this.thisUpdate=new ot,Object.assign(this,e)}}l([h({type:y.Integer,optional:!0})],qr.prototype,"version",void 0);l([h({type:X})],qr.prototype,"signature",void 0);l([h({type:rt})],qr.prototype,"issuer",void 0);l([h({type:ot})],qr.prototype,"thisUpdate",void 0);l([h({type:ot,optional:!0})],qr.prototype,"nextUpdate",void 0);l([h({type:$c,repeated:"sequence",optional:!0})],qr.prototype,"revokedCertificates",void 0);l([h({type:rr,optional:!0,context:0,repeated:"sequence"})],qr.prototype,"crlExtensions",void 0);class Hd{constructor(e={}){this.tbsCertList=new qr,this.signatureAlgorithm=new X,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:qr})],Hd.prototype,"tbsCertList",void 0);l([h({type:X})],Hd.prototype,"signatureAlgorithm",void 0);l([h({type:y.BitString})],Hd.prototype,"signature",void 0);class Ds{constructor(e={}){this.issuer=new rt,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:rt})],Ds.prototype,"issuer",void 0);l([h({type:y.Integer,converter:He})],Ds.prototype,"serialNumber",void 0);let ws=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Xr,context:0,implicit:!0})],ws.prototype,"subjectKeyIdentifier",void 0);l([h({type:Ds})],ws.prototype,"issuerAndSerialNumber",void 0);ws=l([R({type:N.Choice})],ws);var Zr;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(Zr||(Zr={}));let Ji=class extends X{};Ji=l([R({type:N.Sequence})],Ji);let Po=class extends X{};Po=l([R({type:N.Sequence})],Po);let vr=class extends X{};vr=l([R({type:N.Sequence})],vr);let $o=class extends X{};$o=l([R({type:N.Sequence})],$o);let eh=class extends X{};eh=l([R({type:N.Sequence})],eh);let Sl=class extends X{};Sl=l([R({type:N.Sequence})],Sl);let Ms=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],Ms.prototype,"attrType",void 0);l([h({type:y.Any,repeated:"set"})],Ms.prototype,"attrValues",void 0);var Al;class wr{constructor(e={}){this.version=Zr.v0,this.sid=new ws,this.digestAlgorithm=new Ji,this.signatureAlgorithm=new Po,this.signature=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],wr.prototype,"version",void 0);l([h({type:ws})],wr.prototype,"sid",void 0);l([h({type:Ji})],wr.prototype,"digestAlgorithm",void 0);l([h({type:Ms,repeated:"set",context:0,implicit:!0,optional:!0})],wr.prototype,"signedAttrs",void 0);l([h({type:Po})],wr.prototype,"signatureAlgorithm",void 0);l([h({type:Re})],wr.prototype,"signature",void 0);l([h({type:Ms,repeated:"set",context:1,implicit:!0,optional:!0})],wr.prototype,"unsignedAttrs",void 0);let Zo=Al=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Al.prototype)}};Zo=Al=l([R({type:N.Set,itemType:wr})],Zo);let th=class extends ot{};th=l([R({type:N.Choice})],th);let rh=class extends wr{};rh=l([R({type:N.Sequence})],rh);class Fd{constructor(e={}){this.acIssuer=new ge,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}l([h({type:ge})],Fd.prototype,"acIssuer",void 0);l([h({type:y.Integer})],Fd.prototype,"acSerial",void 0);l([h({type:$r,repeated:"sequence"})],Fd.prototype,"attrs",void 0);var Ol;let Do=Ol=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Ol.prototype)}};Do=Ol=l([R({type:N.Sequence,itemType:y.ObjectIdentifier})],Do);class Zc{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}l([h({type:y.Integer,optional:!0})],Zc.prototype,"pathLenConstraint",void 0);l([h({type:Do,implicit:!0,context:0,optional:!0})],Zc.prototype,"permittedAttrs",void 0);l([h({type:Do,implicit:!0,context:1,optional:!0})],Zc.prototype,"excludedAttrs",void 0);l([h({type:y.Boolean,defaultValue:!0})],Zc.prototype,"permitUnSpecified",void 0);class Ln{constructor(e={}){this.issuer=new mt,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:mt})],Ln.prototype,"issuer",void 0);l([h({type:y.Integer,converter:He})],Ln.prototype,"serial",void 0);l([h({type:y.BitString,optional:!0})],Ln.prototype,"issuerUID",void 0);var El;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(El||(El={}));class qn{constructor(e={}){this.digestedObjectType=El.publicKey,this.digestAlgorithm=new X,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Enumerated})],qn.prototype,"digestedObjectType",void 0);l([h({type:y.ObjectIdentifier,optional:!0})],qn.prototype,"otherObjectTypeID",void 0);l([h({type:X})],qn.prototype,"digestAlgorithm",void 0);l([h({type:y.BitString})],qn.prototype,"objectDigest",void 0);class Dc{constructor(e={}){Object.assign(this,e)}}l([h({type:mt,optional:!0})],Dc.prototype,"issuerName",void 0);l([h({type:Ln,context:0,implicit:!0,optional:!0})],Dc.prototype,"baseCertificateID",void 0);l([h({type:qn,context:1,implicit:!0,optional:!0})],Dc.prototype,"objectDigestInfo",void 0);let ks=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,repeated:"sequence"})],ks.prototype,"v1Form",void 0);l([h({type:Dc,context:0,implicit:!0})],ks.prototype,"v2Form",void 0);ks=l([R({type:N.Choice})],ks);class Mc{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}l([h({type:y.GeneralizedTime})],Mc.prototype,"notBeforeTime",void 0);l([h({type:y.GeneralizedTime})],Mc.prototype,"notAfterTime",void 0);class Ta{constructor(e={}){Object.assign(this,e)}}l([h({type:Ln,implicit:!0,context:0,optional:!0})],Ta.prototype,"baseCertificateID",void 0);l([h({type:mt,implicit:!0,context:1,optional:!0})],Ta.prototype,"entityName",void 0);l([h({type:qn,implicit:!0,context:2,optional:!0})],Ta.prototype,"objectDigestInfo",void 0);var Il;(function(r){r[r.v2=1]="v2"})(Il||(Il={}));class ir{constructor(e={}){this.version=Il.v2,this.holder=new Ta,this.issuer=new ks,this.signature=new X,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Mc,this.attributes=[],Object.assign(this,e)}}l([h({type:y.Integer})],ir.prototype,"version",void 0);l([h({type:Ta})],ir.prototype,"holder",void 0);l([h({type:ks})],ir.prototype,"issuer",void 0);l([h({type:X})],ir.prototype,"signature",void 0);l([h({type:y.Integer,converter:He})],ir.prototype,"serialNumber",void 0);l([h({type:Mc})],ir.prototype,"attrCertValidityPeriod",void 0);l([h({type:$r,repeated:"sequence"})],ir.prototype,"attributes",void 0);l([h({type:y.BitString,optional:!0})],ir.prototype,"issuerUniqueID",void 0);l([h({type:Bn,optional:!0})],ir.prototype,"extensions",void 0);class Vc{constructor(e={}){this.acinfo=new ir,this.signatureAlgorithm=new X,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:ir})],Vc.prototype,"acinfo",void 0);l([h({type:X})],Vc.prototype,"signatureAlgorithm",void 0);l([h({type:y.BitString})],Vc.prototype,"signatureValue",void 0);var Mo;(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"})(Mo||(Mo={}));class Cl extends jc{}class Wd{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier,implicit:!0,context:0})],Wd.prototype,"type",void 0);l([h({type:y.Any,implicit:!0,context:1})],Wd.prototype,"value",void 0);class zd{constructor(e={}){this.policyId="",this.classList=new Cl(Mo.unclassified),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],zd.prototype,"policyId",void 0);l([h({type:Cl,defaultValue:new Cl(Mo.unclassified)})],zd.prototype,"classList",void 0);l([h({type:Wd,repeated:"set"})],zd.prototype,"securityCategories",void 0);class Uc{constructor(e={}){Object.assign(this,e)}}l([h({type:Re})],Uc.prototype,"cotets",void 0);l([h({type:y.ObjectIdentifier})],Uc.prototype,"oid",void 0);l([h({type:y.Utf8String})],Uc.prototype,"string",void 0);class Ty{constructor(e={}){this.values=[],Object.assign(this,e)}}l([h({type:mt,implicit:!0,context:0,optional:!0})],Ty.prototype,"policyAuthority",void 0);l([h({type:Uc,repeated:"sequence"})],Ty.prototype,"values",void 0);var jl;class Lc{constructor(e={}){this.targetCertificate=new Ln,Object.assign(this,e)}}l([h({type:Ln})],Lc.prototype,"targetCertificate",void 0);l([h({type:ge,optional:!0})],Lc.prototype,"targetName",void 0);l([h({type:qn,optional:!0})],Lc.prototype,"certDigestInfo",void 0);let Ss=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,implicit:!0})],Ss.prototype,"targetName",void 0);l([h({type:ge,context:1,implicit:!0})],Ss.prototype,"targetGroup",void 0);l([h({type:Lc,context:2,implicit:!0})],Ss.prototype,"targetCert",void 0);Ss=l([R({type:N.Choice})],Ss);let Tl=jl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,jl.prototype)}};Tl=jl=l([R({type:N.Sequence,itemType:Ss})],Tl);var Nl;let nh=Nl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Nl.prototype)}};nh=Nl=l([R({type:N.Sequence,itemType:Tl})],nh);class Ny{constructor(e={}){Object.assign(this,e)}}l([h({type:mt,implicit:!0,context:0,optional:!0})],Ny.prototype,"roleAuthority",void 0);l([h({type:ge,implicit:!0,context:1})],Ny.prototype,"roleName",void 0);class Kd{constructor(e={}){this.service=new ge,this.ident=new ge,Object.assign(this,e)}}l([h({type:ge})],Kd.prototype,"service",void 0);l([h({type:ge})],Kd.prototype,"ident",void 0);l([h({type:Re,optional:!0})],Kd.prototype,"authInfo",void 0);var Bl;class Gd{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Gd.prototype,"otherCertFormat",void 0);l([h({type:y.Any})],Gd.prototype,"otherCert",void 0);let As=class{constructor(e={}){Object.assign(this,e)}};l([h({type:_s})],As.prototype,"certificate",void 0);l([h({type:Vc,context:2,implicit:!0})],As.prototype,"v2AttrCert",void 0);l([h({type:Gd,context:3,implicit:!0})],As.prototype,"other",void 0);As=l([R({type:N.Choice})],As);let Vo=Bl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Bl.prototype)}};Vo=Bl=l([R({type:N.Set,itemType:As})],Vo);class Vs{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Vs.prototype,"contentType",void 0);l([h({type:y.Any,context:0})],Vs.prototype,"content",void 0);let Yi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Re})],Yi.prototype,"single",void 0);l([h({type:y.Any})],Yi.prototype,"any",void 0);Yi=l([R({type:N.Choice})],Yi);class qc{constructor(e={}){this.eContentType="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],qc.prototype,"eContentType",void 0);l([h({type:Yi,context:0,optional:!0})],qc.prototype,"eContent",void 0);let Xi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Re,context:0,implicit:!0,optional:!0})],Xi.prototype,"value",void 0);l([h({type:Re,converter:Jx,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Xi.prototype,"constructedValue",void 0);Xi=l([R({type:N.Choice})],Xi);class Na{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new $o,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Na.prototype,"contentType",void 0);l([h({type:$o})],Na.prototype,"contentEncryptionAlgorithm",void 0);l([h({type:Xi,optional:!0})],Na.prototype,"encryptedContent",void 0);class Hc{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Hc.prototype,"keyAttrId",void 0);l([h({type:y.Any,optional:!0})],Hc.prototype,"keyAttr",void 0);var Rl;class Fc{constructor(e={}){this.subjectKeyIdentifier=new Xr,Object.assign(this,e)}}l([h({type:Xr})],Fc.prototype,"subjectKeyIdentifier",void 0);l([h({type:y.GeneralizedTime,optional:!0})],Fc.prototype,"date",void 0);l([h({type:Hc,optional:!0})],Fc.prototype,"other",void 0);let Os=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Fc,context:0,implicit:!0,optional:!0})],Os.prototype,"rKeyId",void 0);l([h({type:Ds,optional:!0})],Os.prototype,"issuerAndSerialNumber",void 0);Os=l([R({type:N.Choice})],Os);class Jd{constructor(e={}){this.rid=new Os,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:Os})],Jd.prototype,"rid",void 0);l([h({type:Re})],Jd.prototype,"encryptedKey",void 0);let Uo=Rl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Rl.prototype)}};Uo=Rl=l([R({type:N.Sequence,itemType:Jd})],Uo);class Yd{constructor(e={}){this.algorithm=new X,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:X})],Yd.prototype,"algorithm",void 0);l([h({type:y.BitString})],Yd.prototype,"publicKey",void 0);let Rn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Xr,context:0,implicit:!0,optional:!0})],Rn.prototype,"subjectKeyIdentifier",void 0);l([h({type:Yd,context:1,implicit:!0,optional:!0})],Rn.prototype,"originatorKey",void 0);l([h({type:Ds,optional:!0})],Rn.prototype,"issuerAndSerialNumber",void 0);Rn=l([R({type:N.Choice})],Rn);class Us{constructor(e={}){this.version=Zr.v3,this.originator=new Rn,this.keyEncryptionAlgorithm=new vr,this.recipientEncryptedKeys=new Uo,Object.assign(this,e)}}l([h({type:y.Integer})],Us.prototype,"version",void 0);l([h({type:Rn,context:0})],Us.prototype,"originator",void 0);l([h({type:Re,context:1,optional:!0})],Us.prototype,"ukm",void 0);l([h({type:vr})],Us.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Uo})],Us.prototype,"recipientEncryptedKeys",void 0);let Es=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Xr,context:0,implicit:!0})],Es.prototype,"subjectKeyIdentifier",void 0);l([h({type:Ds})],Es.prototype,"issuerAndSerialNumber",void 0);Es=l([R({type:N.Choice})],Es);class Ba{constructor(e={}){this.version=Zr.v0,this.rid=new Es,this.keyEncryptionAlgorithm=new vr,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],Ba.prototype,"version",void 0);l([h({type:Es})],Ba.prototype,"rid",void 0);l([h({type:vr})],Ba.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Re})],Ba.prototype,"encryptedKey",void 0);class Ra{constructor(e={}){this.keyIdentifier=new Re,Object.assign(this,e)}}l([h({type:Re})],Ra.prototype,"keyIdentifier",void 0);l([h({type:y.GeneralizedTime,optional:!0})],Ra.prototype,"date",void 0);l([h({type:Hc,optional:!0})],Ra.prototype,"other",void 0);class Pa{constructor(e={}){this.version=Zr.v4,this.kekid=new Ra,this.keyEncryptionAlgorithm=new vr,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],Pa.prototype,"version",void 0);l([h({type:Ra})],Pa.prototype,"kekid",void 0);l([h({type:vr})],Pa.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Re})],Pa.prototype,"encryptedKey",void 0);class $a{constructor(e={}){this.version=Zr.v0,this.keyEncryptionAlgorithm=new vr,this.encryptedKey=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],$a.prototype,"version",void 0);l([h({type:Sl,context:0,optional:!0})],$a.prototype,"keyDerivationAlgorithm",void 0);l([h({type:vr})],$a.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Re})],$a.prototype,"encryptedKey",void 0);class Xd{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Xd.prototype,"oriType",void 0);l([h({type:y.Any})],Xd.prototype,"oriValue",void 0);let on=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Ba,optional:!0})],on.prototype,"ktri",void 0);l([h({type:Us,context:1,implicit:!0,optional:!0})],on.prototype,"kari",void 0);l([h({type:Pa,context:2,implicit:!0,optional:!0})],on.prototype,"kekri",void 0);l([h({type:$a,context:3,implicit:!0,optional:!0})],on.prototype,"pwri",void 0);l([h({type:Xd,context:4,implicit:!0,optional:!0})],on.prototype,"ori",void 0);on=l([R({type:N.Choice})],on);var Pl;let Lo=Pl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};Lo=Pl=l([R({type:N.Set,itemType:on})],Lo);var $l;class Wc{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Wc.prototype,"otherRevInfoFormat",void 0);l([h({type:y.Any})],Wc.prototype,"otherRevInfo",void 0);let qo=class{constructor(e={}){this.other=new Wc,Object.assign(this,e)}};l([h({type:Wc,context:1,implicit:!0})],qo.prototype,"other",void 0);qo=l([R({type:N.Choice})],qo);let Ho=$l=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,$l.prototype)}};Ho=$l=l([R({type:N.Set,itemType:qo})],Ho);class Qd{constructor(e={}){Object.assign(this,e)}}l([h({type:Vo,context:0,implicit:!0,optional:!0})],Qd.prototype,"certs",void 0);l([h({type:Ho,context:1,implicit:!0,optional:!0})],Qd.prototype,"crls",void 0);var Zl;let Dl=Zl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Zl.prototype)}};Dl=Zl=l([R({type:N.Set,itemType:Ms})],Dl);class Za{constructor(e={}){this.version=Zr.v0,this.recipientInfos=new Lo,this.encryptedContentInfo=new Na,Object.assign(this,e)}}l([h({type:y.Integer})],Za.prototype,"version",void 0);l([h({type:Qd,context:0,implicit:!0,optional:!0})],Za.prototype,"originatorInfo",void 0);l([h({type:Lo})],Za.prototype,"recipientInfos",void 0);l([h({type:Na})],Za.prototype,"encryptedContentInfo",void 0);l([h({type:Dl,context:1,implicit:!0,optional:!0})],Za.prototype,"unprotectedAttrs",void 0);const w_="1.2.840.113549.1.7.2";var Ml;let Fo=Ml=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Ml.prototype)}};Fo=Ml=l([R({type:N.Set,itemType:Ji})],Fo);class Ls{constructor(e={}){this.version=Zr.v0,this.digestAlgorithms=new Fo,this.encapContentInfo=new qc,this.signerInfos=new Zo,Object.assign(this,e)}}l([h({type:y.Integer})],Ls.prototype,"version",void 0);l([h({type:Fo})],Ls.prototype,"digestAlgorithms",void 0);l([h({type:qc})],Ls.prototype,"encapContentInfo",void 0);l([h({type:Vo,context:0,implicit:!0,optional:!0})],Ls.prototype,"certificates",void 0);l([h({type:Ho,context:1,implicit:!0,optional:!0})],Ls.prototype,"crls",void 0);l([h({type:Zo})],Ls.prototype,"signerInfos",void 0);const Qi="1.2.840.10045.2.1",ef="1.2.840.10045.4.1",By="1.2.840.10045.4.3.1",tf="1.2.840.10045.4.3.2",rf="1.2.840.10045.4.3.3",nf="1.2.840.10045.4.3.4",sh="1.2.840.10045.3.1.7",ih="1.3.132.0.34",ah="1.3.132.0.35";function Da(r){return new X({algorithm:r})}const k_=Da(ef);Da(By);const S_=Da(tf),A_=Da(rf),O_=Da(nf);let ea=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],ea.prototype,"fieldType",void 0);l([h({type:y.Any})],ea.prototype,"parameters",void 0);ea=l([R({type:N.Sequence})],ea);class E_ extends Re{}let Is=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.OctetString})],Is.prototype,"a",void 0);l([h({type:y.OctetString})],Is.prototype,"b",void 0);l([h({type:y.BitString,optional:!0})],Is.prototype,"seed",void 0);Is=l([R({type:N.Sequence})],Is);var Vl;(function(r){r[r.ecpVer1=1]="ecpVer1"})(Vl||(Vl={}));let Dr=class{constructor(e={}){this.version=Vl.ecpVer1,Object.assign(this,e)}};l([h({type:y.Integer})],Dr.prototype,"version",void 0);l([h({type:ea})],Dr.prototype,"fieldID",void 0);l([h({type:Is})],Dr.prototype,"curve",void 0);l([h({type:E_})],Dr.prototype,"base",void 0);l([h({type:y.Integer,converter:He})],Dr.prototype,"order",void 0);l([h({type:y.Integer,optional:!0})],Dr.prototype,"cofactor",void 0);Dr=l([R({type:N.Sequence})],Dr);let cn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],cn.prototype,"namedCurve",void 0);l([h({type:y.Null})],cn.prototype,"implicitCurve",void 0);l([h({type:Dr})],cn.prototype,"specifiedCurve",void 0);cn=l([R({type:N.Choice})],cn);class zc{constructor(e={}){this.version=1,this.privateKey=new Re,Object.assign(this,e)}}l([h({type:y.Integer})],zc.prototype,"version",void 0);l([h({type:Re})],zc.prototype,"privateKey",void 0);l([h({type:cn,context:0,optional:!0})],zc.prototype,"parameters",void 0);l([h({type:y.BitString,context:1,optional:!0})],zc.prototype,"publicKey",void 0);class Wo{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Integer,converter:He})],Wo.prototype,"r",void 0);l([h({type:y.Integer,converter:He})],Wo.prototype,"s",void 0);const Ot="1.2.840.113549.1.1",Pn=`${Ot}.1`,I_=`${Ot}.7`,C_=`${Ot}.9`,yi=`${Ot}.10`,j_=`${Ot}.2`,T_=`${Ot}.4`,zo=`${Ot}.5`,N_=`${Ot}.14`,Ul=`${Ot}.11`,Ko=`${Ot}.12`,Go=`${Ot}.13`,Ry=`${Ot}.15`,Py=`${Ot}.16`,Jo="1.3.14.3.2.26",$y="2.16.840.1.101.3.4.2.4",Yo="2.16.840.1.101.3.4.2.1",Xo="2.16.840.1.101.3.4.2.2",Qo="2.16.840.1.101.3.4.2.3",B_="2.16.840.1.101.3.4.2.5",R_="2.16.840.1.101.3.4.2.6",P_="1.2.840.113549.2.2",$_="1.2.840.113549.2.5",Kc=`${Ot}.8`;function nt(r){return new X({algorithm:r,parameters:null})}nt(P_);nt($_);const $n=nt(Jo);nt($y);nt(Yo);nt(Xo);nt(Qo);nt(B_);nt(R_);const Zy=new X({algorithm:Kc,parameters:W.serialize($n)}),Dy=new X({algorithm:C_,parameters:W.serialize(Io.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});nt(Pn);nt(j_);nt(T_);nt(zo);nt(Ry);nt(Py);nt(Ko);nt(Go);nt(Ry);nt(Py);class Gc{constructor(e={}){this.hashAlgorithm=new X($n),this.maskGenAlgorithm=new X({algorithm:Kc,parameters:W.serialize($n)}),this.pSourceAlgorithm=new X(Dy),Object.assign(this,e)}}l([h({type:X,context:0,defaultValue:$n})],Gc.prototype,"hashAlgorithm",void 0);l([h({type:X,context:1,defaultValue:Zy})],Gc.prototype,"maskGenAlgorithm",void 0);l([h({type:X,context:2,defaultValue:Dy})],Gc.prototype,"pSourceAlgorithm",void 0);new X({algorithm:I_,parameters:W.serialize(new Gc)});class Zn{constructor(e={}){this.hashAlgorithm=new X($n),this.maskGenAlgorithm=new X({algorithm:Kc,parameters:W.serialize($n)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}l([h({type:X,context:0,defaultValue:$n})],Zn.prototype,"hashAlgorithm",void 0);l([h({type:X,context:1,defaultValue:Zy})],Zn.prototype,"maskGenAlgorithm",void 0);l([h({type:y.Integer,context:2,defaultValue:20})],Zn.prototype,"saltLength",void 0);l([h({type:y.Integer,context:3,defaultValue:1})],Zn.prototype,"trailerField",void 0);new X({algorithm:yi,parameters:W.serialize(new Zn)});class Jc{constructor(e={}){this.digestAlgorithm=new X,this.digest=new Re,Object.assign(this,e)}}l([h({type:X})],Jc.prototype,"digestAlgorithm",void 0);l([h({type:Re})],Jc.prototype,"digest",void 0);var Ll;class Yc{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:He})],Yc.prototype,"prime",void 0);l([h({type:y.Integer,converter:He})],Yc.prototype,"exponent",void 0);l([h({type:y.Integer,converter:He})],Yc.prototype,"coefficient",void 0);let ql=Ll=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};ql=Ll=l([R({type:N.Sequence,itemType:Yc})],ql);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:He})],kr.prototype,"modulus",void 0);l([h({type:y.Integer,converter:He})],kr.prototype,"publicExponent",void 0);l([h({type:y.Integer,converter:He})],kr.prototype,"privateExponent",void 0);l([h({type:y.Integer,converter:He})],kr.prototype,"prime1",void 0);l([h({type:y.Integer,converter:He})],kr.prototype,"prime2",void 0);l([h({type:y.Integer,converter:He})],kr.prototype,"exponent1",void 0);l([h({type:y.Integer,converter:He})],kr.prototype,"exponent2",void 0);l([h({type:y.Integer,converter:He})],kr.prototype,"coefficient",void 0);l([h({type:ql,optional:!0})],kr.prototype,"otherPrimeInfos",void 0);class sf{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Integer,converter:He})],sf.prototype,"modulus",void 0);l([h({type:y.Integer,converter:He})],sf.prototype,"publicExponent",void 0);var Hl;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Hl||(Hl={}));const _t=Hl;/*! *****************************************************************************
75
+ `)}`:`${t} :`}}Gm=Ot;Q.Constructed=Gm;Ot.NAME="CONSTRUCTED";class Jm extends wt{fromBER(e,t,n){return t}toBER(e){return cr}}Jm.override="EndOfContentValueBlock";var Ym;class Ud extends lt{constructor(e={}){super(e,Jm),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Ym=Ud;Q.EndOfContent=Ym;Ud.NAME=aa;var Xm;class Un extends lt{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}`}}Xm=Un;Q.Null=Xm;Un.NAME="NULL";class Qm extends Ar(wt){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 Kr(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,Um.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Qm.NAME="BooleanValueBlock";var ey;let Cc=class extends lt{constructor(e={}){super(e,Qm),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}`}};ey=Cc;Q.Boolean=ey;Cc.NAME="BOOLEAN";class ty extends Ar(on){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=on.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===aa){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Lm)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?on.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}ty.NAME="OctetStringValueBlock";var ry;let Rn=class ny extends lt{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},ty),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?Ot.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${ne.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 ny&&e.push(t.valueBlock.valueHexView);return L.concat(e)}};ry=Rn;Q.OctetString=ry;Rn.NAME=Lm;class sy extends Ar(on){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=on.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(const o of this.value){const c=o.constructor.NAME;if(c===aa){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==qm)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(!Kr(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 on.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return cr;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}}}sy.NAME="BitStringValueBlock";var iy;let Pn=class extends lt{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},sy),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 Ot.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)}`}}};iy=Pn;Q.BitString=iy;Pn.NAME=qm;var ay;function d_(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=ll(new Uint8Array([u%10]),i);break;default:i[a-m]=u%10}}return t[0]>0&&(i=ll(t,i)),i}function eh(r){if(r>=li.length)for(let e=li.length;e<=r;e++){const t=new Uint8Array([0]);let n=li[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=ll(t,n)),li.push(n)}return li[r]}function f_(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 Ld extends Ar(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=Um.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Qx(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=f_(eh(n),t),a="-";break;default:t=d_(t,eh(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Xf.charAt(t[c]));return o===!1&&(a+=Xf.charAt(0)),a}}ay=Ld;Ld.NAME="IntegerValueBlock";Object.defineProperty(ay.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var oy;class yr extends lt{constructor(e={}){super(e,Ld),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Do(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Do();const t=BigInt(e),n=new Oc,s=t.toString(16).replace(/^-/,""),i=new Uint8Array(ne.FromHex(s));if(t<0){const o=new Uint8Array(i.length+(i[0]&128?1:0));o[0]|=128;const u=BigInt(`0x${ne.ToHex(o)}`)+t,f=L.toUint8Array(ne.FromHex(u.toString(16)));f[0]|=128,n.write(f)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new yr({valueHex:n.final()})}convertToDER(){const e=new yr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new yr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}oy=yr;Q.Integer=oy;yr.NAME="INTEGER";var cy;class Ic extends yr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}cy=Ic;Q.Enumerated=cy;Ic.NAME="ENUMERATED";class dl extends Ar(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=L.toUint8Array(e);if(!Kr(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=js(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Do();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=Vn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",cr;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=ne.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}dl.NAME="sidBlock";class uy extends wt{constructor({value:e=At,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new dl;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,cr;t.push(s)}return Md(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 dl;if(s>Number.MAX_SAFE_INTEGER){Do();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}}uy.NAME="ObjectIdentifierValueBlock";var ly;class jc extends lt{constructor(e={}){super(e,uy),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()}}}ly=jc;Q.ObjectIdentifier=ly;jc.NAME="OBJECT IDENTIFIER";class fl extends Ar(es){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(!Kr(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=js(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=Vn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",cr;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=ne.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}fl.NAME="relativeSidBlock";class dy extends wt{constructor({value:e=At,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new fl;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,cr;n.push(i)}return Md(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 fl;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}}dy.NAME="RelativeObjectIdentifierValueBlock";var fy;class qd extends lt{constructor(e={}){super(e,dy),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()}}}fy=qd;Q.RelativeObjectIdentifier=fy;qd.NAME="RelativeObjectIdentifier";var hy;class Zr extends Ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}hy=Zr;Q.Sequence=hy;Zr.NAME="SEQUENCE";var py;let Dr=class extends Ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};py=Dr;Q.Set=py;Dr.NAME="SET";class my extends Ar(wt){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=At}toJSON(){return{...super.toJSON(),value:this.value}}}my.NAME="StringValueBlock";class yy extends my{}yy.NAME="SimpleStringValueBlock";class Zt extends Vd{constructor({...e}={}){super(e,yy)}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}}Zt.NAME="SIMPLE STRING";class gy extends Zt{fromBuffer(e){this.valueBlock.valueHexView=L.toUint8Array(e);try{this.valueBlock.value=ne.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=ne.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(ne.FromUtf8String(e)),this.valueBlock.value=e}}gy.NAME="Utf8StringValueBlock";var vy;class Gr extends gy{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}vy=Gr;Q.Utf8String=vy;Gr.NAME="UTF8String";class by extends Zt{fromBuffer(e){this.valueBlock.value=ne.ToUtf16String(e),this.valueBlock.valueHexView=L.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(ne.FromUtf16String(e))}}by.NAME="BmpStringValueBlock";var xy;class Tc extends by{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}xy=Tc;Q.BmpString=xy;Tc.NAME="BMPString";class _y extends Zt{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=Vn(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}}_y.NAME="UniversalStringValueBlock";var wy;class Nc extends _y{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}wy=Nc;Q.UniversalString=wy;Nc.NAME="UniversalString";var ky;class Bc extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}ky=Bc;Q.NumericString=ky;Bc.NAME="NumericString";var Sy;class Rc extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Sy=Rc;Q.PrintableString=Sy;Rc.NAME="PrintableString";var Ay;class Pc extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ay=Pc;Q.TeletexString=Ay;Pc.NAME="TeletexString";var Oy;class $c extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Oy=$c;Q.VideotexString=Oy;$c.NAME="VideotexString";var Ey;class Zc extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Ey=Zc;Q.IA5String=Ey;Zc.NAME="IA5String";var Cy;class Dc extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Cy=Dc;Q.GraphicString=Cy;Dc.NAME="GraphicString";var Iy;class Va extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Iy=Va;Q.VisibleString=Iy;Va.NAME="VisibleString";var jy;class Mc extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}jy=Mc;Q.GeneralString=jy;Mc.NAME="GeneralString";var Ty;class Vc extends Zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Ty=Vc;Q.CharacterString=Ty;Vc.NAME="CharacterString";var Ny;class Ua extends Va{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]=Nt(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Nt(this.month,2),t[2]=Nt(this.day,2),t[3]=Nt(this.hour,2),t[4]=Nt(this.minute,2),t[5]=Nt(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}}}Ny=Ua;Q.UTCTime=Ny;Ua.NAME="UTCTime";var By;class Uc extends Ua{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(Nt(this.year,4)),t.push(Nt(this.month,2)),t.push(Nt(this.day,2)),t.push(Nt(this.hour,2)),t.push(Nt(this.minute,2)),t.push(Nt(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Nt(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}By=Uc;Q.GeneralizedTime=By;Uc.NAME="GeneralizedTime";var Ry;class Hd extends Gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Ry=Hd;Q.DATE=Ry;Hd.NAME="DATE";var Py;class Fd extends Gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Py=Fd;Q.TimeOfDay=Py;Fd.NAME="TimeOfDay";var $y;class Wd extends Gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}$y=Wd;Q.DateTime=$y;Wd.NAME="DateTime";var Zy;class zd extends Gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Zy=zd;Q.Duration=Zy;zd.NAME="Duration";var Dy;class Kd extends Gr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Dy=Kd;Q.TIME=Dy;Kd.NAME="TIME";class Ln{constructor({name:e=At,optional:t=!1}={}){this.name=e,this.optional=t}}class Gd extends Ln{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Mo extends Ln{constructor({value:e=new Ln,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class h_{constructor({data:e=Ec}={}){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 In(r,e,t){if(t instanceof Gd){for(let i=0;i<t.value.length;i++)if(In(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(Iu)&&(i.name=t.name),i}}if(t instanceof Ln)return t.hasOwnProperty(Iu)&&(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(!(r_ in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(a_ in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(o_ 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(n_)===!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(s_)===!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(i_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(t_ 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(!(Qf 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,At),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 Mo&&(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,At),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,At),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof Mo){if(a=In(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,At),t.name&&delete r[t.name]),a;if(Iu in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};c_ 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=In(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,At),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,At),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&Qf 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,At),t.name&&(delete r[t.name],a.name=t.name)),a}return In(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function p_(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}:In(t.result,t.result,e)}const My=Object.freeze(Object.defineProperty({__proto__:null,Any:Ln,BaseBlock:lt,BaseStringBlock:Vd,BitString:Pn,BmpString:Tc,Boolean:Cc,CharacterString:Vc,Choice:Gd,Constructed:Ot,DATE:Hd,DateTime:Wd,Duration:zd,EndOfContent:Ud,Enumerated:Ic,GeneralString:Mc,GeneralizedTime:Uc,GraphicString:Dc,HexBlock:Ar,IA5String:Zc,Integer:yr,Null:Un,NumericString:Bc,ObjectIdentifier:jc,OctetString:Rn,Primitive:Ma,PrintableString:Rc,RawData:h_,RelativeObjectIdentifier:qd,Repeated:Mo,Sequence:Zr,Set:Dr,TIME:Kd,TeletexString:Pc,TimeOfDay:Fd,UTCTime:Ua,UniversalString:Nc,Utf8String:Gr,ValueBlock:wt,VideotexString:$c,ViewWriter:Oc,VisibleString:Va,compareSchema:In,fromBER:gs,verifySchema:p_},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 Lc{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 Pn))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 Pn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Pn({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 Pe{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 Rn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Rn({valueHex:this.buffer})}toSchema(e){return new Rn({name:e})}}const m_={fromASN:r=>r instanceof Un?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new Un;const e=gs(r);if(e.result.error)throw new Error(e.result.error);return e.result}},y_={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new yr({value:+r})},g_={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Ic({value:r})},We={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new yr({valueHex:r})},v_={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Pn({valueHex:r})},b_={fromASN:r=>r.valueBlock.toString(),toASN:r=>new jc({value:r})},x_={fromASN:r=>r.valueBlock.value,toASN:r=>new Cc({value:r})},Vo={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Rn({valueHex:r})},__={fromASN:r=>new Pe(r.getValue()),toASN:r=>r.toASN()};function qt(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Vy=qt(Gr),w_=qt(Tc),k_=qt(Nc),S_=qt(Bc),A_=qt(Rc),O_=qt(Pc),E_=qt($c),C_=qt(Zc),I_=qt(Dc),j_=qt(Va),T_=qt(Mc),N_=qt(Vc),B_={fromASN:r=>r.toDate(),toASN:r=>new Ua({valueDate:r})},R_={fromASN:r=>r.toDate(),toASN:r=>new Uc({valueDate:r})},P_={fromASN:()=>null,toASN:()=>new Un};function Jd(r){switch(r){case y.Any:return m_;case y.BitString:return v_;case y.BmpString:return w_;case y.Boolean:return x_;case y.CharacterString:return N_;case y.Enumerated:return g_;case y.GeneralString:return T_;case y.GeneralizedTime:return R_;case y.GraphicString:return I_;case y.IA5String:return C_;case y.Integer:return y_;case y.Null:return P_;case y.NumericString:return S_;case y.ObjectIdentifier:return b_;case y.OctetString:return Vo;case y.PrintableString:return A_;case y.TeletexString:return O_;case y.UTCTime:return B_;case y.UniversalString:return k_;case y.Utf8String:return Vy;case y.VideotexString:return E_;case y.VisibleString:return j_;default:return null}}function $r(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:$r(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Uy(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:Uy(t)}return!1}function $_(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 Z_{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=My[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else $r(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===N.Choice?c=new Ln({name:o}):(c=this.create(a.type,!1),c.name=o):c=new Ln({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const f=a.repeated==="set"?Dr:Zr;c=new f({name:"",value:[new Mo({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||$r(a.type)){const f=a.repeated?Ot:Ma;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 Ot({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else s.push(new Ot({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 Zr({value:s,name:""});case N.Set:return new Dr({value:s,name:""});case N.Choice:return new Gd({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 Vt=new Z_,$=r=>e=>{let t;Vt.has(e)?t=Vt.get(e):(t=Vt.createDefault(e),Vt.set(e,t)),Object.assign(t,r)},h=r=>(e,t)=>{let n;Vt.has(e.constructor)?n=Vt.get(e.constructor):(n=Vt.createDefault(e.constructor),Vt.set(e.constructor,n));const s=Object.assign({},r);if(typeof s.type=="number"&&!s.converter){const i=Jd(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 th extends Error{constructor(){super(...arguments),this.schemas=[]}}class D_{static parse(e,t){const n=gs(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($r(t))return new t().fromASN(e);const s=Vt.get(t);Vt.cache(t);let i=s.schema;if(e.constructor===Ot&&s.type!==N.Choice){i=new Ot({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:s.schema.valueBlock.value});for(const c in s.items)delete e[c]}const a=In({},e,i);if(!a.verified)throw new th(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(Uy(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=Jd(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"||$r(m)){const B=(n=f.converter)!==null&&n!==void 0?n:$r(m)?new m:null;if(!B)throw new Error("Converter is empty");if(f.repeated)if(f.implicit){const j=f.repeated==="sequence"?Zr:Dr,p=new j;p.valueBlock=u.valueBlock;const g=gs(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($r(m))p=new m().toSchema("");else{const g=y[m],A=My[g];if(!A)throw new Error(`Cannot get '${g}' class from asn1js module`);p=new A}p.valueBlock=j.valueBlock,j=gs(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 th&&s.schemas.push(t.name),s}}}class Yd{static serialize(e){return e instanceof lt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&$r(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=Vt.get(t);Vt.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=Jd(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"&&$_(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=Yd.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||$r(o.type))){const f={};f.valueHex=u instanceof Un?u.valueBeforeDecodeView:u.valueBlock.toBER(),s.push(new Ma({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else s.push(new Ot({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else s.push(new Ot({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 Zr({value:s});break;case N.Set:i=new Dr({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"?Zr:Dr;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"?Zr:Dr;i=new o({value:a})}else i=this.toASN(s);return i}}class Ve extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class W{static serialize(e){return Yd.serialize(e)}static parse(e,t){return D_.parse(e,t)}static toString(e){const t=L.isBufferSource(e)?L.toArrayBuffer(e):W.serialize(e),n=gs(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}var Ly={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,ye;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(ye=g-A,T=":";ye--;)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(":"),Le=[];for(let $e=0;$e<Ue.length;$e++)Le.push(parseInt(Ue[$e],16));return Le}(),{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,ye;for(R=3;R>=0;R-=1)if(T=this.octets[R],T in S){if(ye=S[T],A&&ye!==0)return null;ye!==8&&(A=!0),g+=ye}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 ye=0;ye<R.length;ye++)A=R[ye],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 ye=7;ye>=0;ye-=1)if(R=this.parts[ye],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(ye){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ye})`)}},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,ye;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))&&(ye=S[6]||"",g=S[1],S[1].endsWith("::")||(g=g.slice(0,-1)),g=u(g+ye,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,ye;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(ye=T[S],p.kind()===ye[0].kind()&&p.match.apply(p,ye))return R}return A},r.exports?r.exports=j:e.ipaddr=j})(Zo)})(Ly);var rh=Ly.exports;class nh{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 rh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(ne.ToHex(e))}static fromString(e){const t=rh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var hl,pl,ml;let dt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};l([h({type:y.TeletexString})],dt.prototype,"teletexString",void 0);l([h({type:y.PrintableString})],dt.prototype,"printableString",void 0);l([h({type:y.UniversalString})],dt.prototype,"universalString",void 0);l([h({type:y.Utf8String})],dt.prototype,"utf8String",void 0);l([h({type:y.BmpString})],dt.prototype,"bmpString",void 0);dt=l([$({type:N.Choice})],dt);let Ts=class extends dt{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?ne.ToHex(this.anyValue):super.toString())}};l([h({type:y.IA5String})],Ts.prototype,"ia5String",void 0);l([h({type:y.Any})],Ts.prototype,"anyValue",void 0);Ts=l([$({type:N.Choice})],Ts);class qc{constructor(e={}){this.type="",this.value=new Ts,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],qc.prototype,"type",void 0);l([h({type:Ts})],qc.prototype,"value",void 0);let Ns=hl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,hl.prototype)}};Ns=hl=l([$({type:N.Set,itemType:qc})],Ns);let yl=pl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,pl.prototype)}};yl=pl=l([$({type:N.Sequence,itemType:Ns})],yl);let it=ml=class extends yl{constructor(e){super(e),Object.setPrototypeOf(this,ml.prototype)}};it=ml=l([$({type:N.Sequence})],it);const M_={fromASN:r=>nh.toString(Vo.fromASN(r)),toASN:r=>Vo.toASN(nh.fromString(r))};class oa{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],oa.prototype,"typeId",void 0);l([h({type:y.Any,context:0})],oa.prototype,"value",void 0);class Xd{constructor(e={}){this.partyName=new dt,Object.assign(this,e)}}l([h({type:dt,optional:!0,context:0,implicit:!0})],Xd.prototype,"nameAssigner",void 0);l([h({type:dt,context:1,implicit:!0})],Xd.prototype,"partyName",void 0);let ge=class{constructor(e={}){Object.assign(this,e)}};l([h({type:oa,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:Xd,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 Qd="1.3.6.1.5.5.7",V_=`${Qd}.1`,Gs=`${Qd}.3`,Hc=`${Qd}.48`,sh=`${Hc}.1`,ih=`${Hc}.2`,ah=`${Hc}.3`,oh=`${Hc}.5`,wn="2.5.29";var gl;const vl=`${V_}.1`;class La{constructor(e={}){this.accessMethod="",this.accessLocation=new ge,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],La.prototype,"accessMethod",void 0);l([h({type:ge})],La.prototype,"accessLocation",void 0);let hs=gl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,gl.prototype)}};hs=gl=l([$({type:N.Sequence,itemType:La})],hs);const bl=`${wn}.35`;class ef extends Pe{}class jn{constructor(e={}){e&&Object.assign(this,e)}}l([h({type:ef,context:0,optional:!0,implicit:!0})],jn.prototype,"keyIdentifier",void 0);l([h({type:ge,context:1,optional:!0,implicit:!0,repeated:"sequence"})],jn.prototype,"authorityCertIssuer",void 0);l([h({type:y.Integer,context:2,optional:!0,implicit:!0,converter:We})],jn.prototype,"authorityCertSerialNumber",void 0);const qy=`${wn}.19`;class Uo{constructor(e={}){this.cA=!1,Object.assign(this,e)}}l([h({type:y.Boolean,defaultValue:!1})],Uo.prototype,"cA",void 0);l([h({type:y.Integer,optional:!0})],Uo.prototype,"pathLenConstraint",void 0);var xl;let gt=xl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,xl.prototype)}};gt=xl=l([$({type:N.Sequence,itemType:ge})],gt);var _l;let ch=_l=class extends gt{constructor(e){super(e),Object.setPrototypeOf(this,_l.prototype)}};ch=_l=l([$({type:N.Sequence})],ch);var wl;const Hy=`${wn}.32`;let Ur=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};l([h({type:y.IA5String})],Ur.prototype,"ia5String",void 0);l([h({type:y.VisibleString})],Ur.prototype,"visibleString",void 0);l([h({type:y.BmpString})],Ur.prototype,"bmpString",void 0);l([h({type:y.Utf8String})],Ur.prototype,"utf8String",void 0);Ur=l([$({type:N.Choice})],Ur);class tf{constructor(e={}){this.organization=new Ur,this.noticeNumbers=[],Object.assign(this,e)}}l([h({type:Ur})],tf.prototype,"organization",void 0);l([h({type:y.Integer,repeated:"sequence"})],tf.prototype,"noticeNumbers",void 0);class rf{constructor(e={}){Object.assign(this,e)}}l([h({type:tf,optional:!0})],rf.prototype,"noticeRef",void 0);l([h({type:Ur,optional:!0})],rf.prototype,"explicitText",void 0);let Lo=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.IA5String})],Lo.prototype,"cPSuri",void 0);l([h({type:rf})],Lo.prototype,"userNotice",void 0);Lo=l([$({type:N.Choice})],Lo);class nf{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],nf.prototype,"policyQualifierId",void 0);l([h({type:y.Any})],nf.prototype,"qualifier",void 0);class Fc{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Fc.prototype,"policyIdentifier",void 0);l([h({type:nf,repeated:"sequence",optional:!0})],Fc.prototype,"policyQualifiers",void 0);let qo=wl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,wl.prototype)}};qo=wl=l([$({type:N.Sequence,itemType:Fc})],qo);let Ho=class{constructor(e=0){this.value=e}};l([h({type:y.Integer})],Ho.prototype,"value",void 0);Ho=l([$({type:N.Choice})],Ho);let uh=class extends Ho{};uh=l([$({type:N.Choice})],uh);var kl;const Sl=`${wn}.31`;var Gt;(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"})(Gt||(Gt={}));class Fy extends Lc{toJSON(){const e=[],t=this.toNumber();return t&Gt.aACompromise&&e.push("aACompromise"),t&Gt.affiliationChanged&&e.push("affiliationChanged"),t&Gt.cACompromise&&e.push("cACompromise"),t&Gt.certificateHold&&e.push("certificateHold"),t&Gt.cessationOfOperation&&e.push("cessationOfOperation"),t&Gt.keyCompromise&&e.push("keyCompromise"),t&Gt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Gt.superseded&&e.push("superseded"),t&Gt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let qn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,repeated:"sequence",implicit:!0})],qn.prototype,"fullName",void 0);l([h({type:Ns,context:1,implicit:!0})],qn.prototype,"nameRelativeToCRLIssuer",void 0);qn=l([$({type:N.Choice})],qn);class Js{constructor(e={}){Object.assign(this,e)}}l([h({type:qn,context:0,optional:!0})],Js.prototype,"distributionPoint",void 0);l([h({type:Fy,context:1,optional:!0,implicit:!0})],Js.prototype,"reasons",void 0);l([h({type:ge,context:2,optional:!0,repeated:"sequence",implicit:!0})],Js.prototype,"cRLIssuer",void 0);let vs=kl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,kl.prototype)}};vs=kl=l([$({type:N.Sequence,itemType:Js})],vs);var Al;let lh=Al=class extends vs{constructor(e){super(e),Object.setPrototypeOf(this,Al.prototype)}};lh=Al=l([$({type:N.Sequence,itemType:Js})],lh);class ht{constructor(e={}){this.onlyContainsUserCerts=ht.ONLY,this.onlyContainsCACerts=ht.ONLY,this.indirectCRL=ht.ONLY,this.onlyContainsAttributeCerts=ht.ONLY,Object.assign(this,e)}}ht.ONLY=!1;l([h({type:qn,context:0,optional:!0})],ht.prototype,"distributionPoint",void 0);l([h({type:y.Boolean,context:1,defaultValue:ht.ONLY,implicit:!0})],ht.prototype,"onlyContainsUserCerts",void 0);l([h({type:y.Boolean,context:2,defaultValue:ht.ONLY,implicit:!0})],ht.prototype,"onlyContainsCACerts",void 0);l([h({type:Fy,context:3,optional:!0,implicit:!0})],ht.prototype,"onlySomeReasons",void 0);l([h({type:y.Boolean,context:4,defaultValue:ht.ONLY,implicit:!0})],ht.prototype,"indirectCRL",void 0);l([h({type:y.Boolean,context:5,defaultValue:ht.ONLY,implicit:!0})],ht.prototype,"onlyContainsAttributeCerts",void 0);var Oi;(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"})(Oi||(Oi={}));let Ol=class{constructor(e=Oi.unspecified){this.reason=Oi.unspecified,this.reason=e}toJSON(){return Oi[this.reason]}toString(){return this.toJSON()}};l([h({type:y.Enumerated})],Ol.prototype,"reason",void 0);Ol=l([$({type:N.Choice})],Ol);var El;const Wy=`${wn}.37`;let Fo=El=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,El.prototype)}};Fo=El=l([$({type:N.Sequence,itemType:y.ObjectIdentifier})],Fo);const U_=`${Gs}.1`,L_=`${Gs}.2`,q_=`${Gs}.3`,H_=`${Gs}.4`,F_=`${Gs}.8`,W_=`${Gs}.9`;let Cl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};l([h({type:y.Integer,converter:We})],Cl.prototype,"value",void 0);Cl=l([$({type:N.Choice})],Cl);let Il=class{constructor(e){this.value=new Date,e&&(this.value=e)}};l([h({type:y.GeneralizedTime})],Il.prototype,"value",void 0);Il=l([$({type:N.Choice})],Il);var jl;let dh=jl=class extends gt{constructor(e){super(e),Object.setPrototypeOf(this,jl.prototype)}};dh=jl=l([$({type:N.Sequence})],dh);const zy=`${wn}.15`;var Jt;(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"})(Jt||(Jt={}));class ju extends Lc{toJSON(){const e=this.toNumber(),t=[];return e&Jt.cRLSign&&t.push("crlSign"),e&Jt.dataEncipherment&&t.push("dataEncipherment"),e&Jt.decipherOnly&&t.push("decipherOnly"),e&Jt.digitalSignature&&t.push("digitalSignature"),e&Jt.encipherOnly&&t.push("encipherOnly"),e&Jt.keyAgreement&&t.push("keyAgreement"),e&Jt.keyCertSign&&t.push("keyCertSign"),e&Jt.keyEncipherment&&t.push("keyEncipherment"),e&Jt.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Tl;class Wc{constructor(e={}){this.base=new ge,this.minimum=0,Object.assign(this,e)}}l([h({type:ge})],Wc.prototype,"base",void 0);l([h({type:y.Integer,context:0,defaultValue:0,implicit:!0})],Wc.prototype,"minimum",void 0);l([h({type:y.Integer,context:1,optional:!0,implicit:!0})],Wc.prototype,"maximum",void 0);let Wo=Tl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Tl.prototype)}};Wo=Tl=l([$({type:N.Sequence,itemType:Wc})],Wo);class Ky{constructor(e={}){Object.assign(this,e)}}l([h({type:Wo,context:0,optional:!0,implicit:!0})],Ky.prototype,"permittedSubtrees",void 0);l([h({type:Wo,context:1,optional:!0,implicit:!0})],Ky.prototype,"excludedSubtrees",void 0);class Gy{constructor(e={}){Object.assign(this,e)}}l([h({type:y.Integer,context:0,implicit:!0,optional:!0,converter:We})],Gy.prototype,"requireExplicitPolicy",void 0);l([h({type:y.Integer,context:1,implicit:!0,optional:!0,converter:We})],Gy.prototype,"inhibitPolicyMapping",void 0);var Nl;class sf{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],sf.prototype,"issuerDomainPolicy",void 0);l([h({type:y.ObjectIdentifier})],sf.prototype,"subjectDomainPolicy",void 0);let fh=Nl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Nl.prototype)}};fh=Nl=l([$({type:N.Sequence,itemType:sf})],fh);var Bl;const Jy=`${wn}.17`;let Rl=Bl=class extends gt{constructor(e){super(e),Object.setPrototypeOf(this,Bl.prototype)}};Rl=Bl=l([$({type:N.Sequence})],Rl);let Lr=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],Lr.prototype,"type",void 0);l([h({type:y.Any,repeated:"set"})],Lr.prototype,"values",void 0);var Pl;let hh=Pl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};hh=Pl=l([$({type:N.Sequence,itemType:Lr})],hh);const Yy=`${wn}.14`;class cn extends ef{}class Xy{constructor(e={}){Object.assign(this,e)}}l([h({type:y.GeneralizedTime,context:0,implicit:!0,optional:!0})],Xy.prototype,"notBefore",void 0);l([h({type:y.GeneralizedTime,context:1,implicit:!0,optional:!0})],Xy.prototype,"notAfter",void 0);var Ei;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Ei||(Ei={}));class Qy extends Lc{toJSON(){const e=[],t=this.toNumber();return t&Ei.pKIXCertificate&&e.push("pKIXCertificate"),t&Ei.newExtensions&&e.push("newExtensions"),t&Ei.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class eg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Qy,Object.assign(this,e)}}l([h({type:y.GeneralString})],eg.prototype,"entrustVers",void 0);l([h({type:Qy})],eg.prototype,"entrustInfoFlags",void 0);var $l;let ph=$l=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,$l.prototype)}};ph=$l=l([$({type:N.Sequence,itemType:La})],ph);class Y{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof Y&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Vm(e.parameters,this.parameters)||e.parameters===this.parameters)}}l([h({type:y.ObjectIdentifier})],Y.prototype,"algorithm",void 0);l([h({type:y.Any,optional:!0})],Y.prototype,"parameters",void 0);class hr{constructor(e={}){this.algorithm=new Y,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],hr.prototype,"algorithm",void 0);l([h({type:y.BitString})],hr.prototype,"subjectPublicKey",void 0);let ut=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})],ut.prototype,"utcTime",void 0);l([h({type:y.GeneralizedTime})],ut.prototype,"generalTime",void 0);ut=l([$({type:N.Choice})],ut);class zc{constructor(e){this.notBefore=new ut(new Date),this.notAfter=new ut(new Date),e&&(this.notBefore=new ut(e.notBefore),this.notAfter=new ut(e.notAfter))}}l([h({type:ut})],zc.prototype,"notBefore",void 0);l([h({type:ut})],zc.prototype,"notAfter",void 0);var Zl;let ar=class tg{constructor(e={}){this.extnID="",this.critical=tg.CRITICAL,this.extnValue=new Pe,Object.assign(this,e)}};ar.CRITICAL=!1;l([h({type:y.ObjectIdentifier})],ar.prototype,"extnID",void 0);l([h({type:y.Boolean,defaultValue:ar.CRITICAL})],ar.prototype,"critical",void 0);l([h({type:Pe})],ar.prototype,"extnValue",void 0);let Hn=Zl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Zl.prototype)}};Hn=Zl=l([$({type:N.Sequence,itemType:ar})],Hn);var Bs;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(Bs||(Bs={}));class Ht{constructor(e={}){this.version=Bs.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new Y,this.issuer=new it,this.validity=new zc,this.subject=new it,this.subjectPublicKeyInfo=new hr,Object.assign(this,e)}}l([h({type:y.Integer,context:0,defaultValue:Bs.v1})],Ht.prototype,"version",void 0);l([h({type:y.Integer,converter:We})],Ht.prototype,"serialNumber",void 0);l([h({type:Y})],Ht.prototype,"signature",void 0);l([h({type:it})],Ht.prototype,"issuer",void 0);l([h({type:zc})],Ht.prototype,"validity",void 0);l([h({type:it})],Ht.prototype,"subject",void 0);l([h({type:hr})],Ht.prototype,"subjectPublicKeyInfo",void 0);l([h({type:y.BitString,context:1,implicit:!0,optional:!0})],Ht.prototype,"issuerUniqueID",void 0);l([h({type:y.BitString,context:2,implicit:!0,optional:!0})],Ht.prototype,"subjectUniqueID",void 0);l([h({type:Hn,context:3,optional:!0})],Ht.prototype,"extensions",void 0);class Rs{constructor(e={}){this.tbsCertificate=new Ht,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Ht})],Rs.prototype,"tbsCertificate",void 0);l([h({type:Y})],Rs.prototype,"signatureAlgorithm",void 0);l([h({type:y.BitString})],Rs.prototype,"signatureValue",void 0);class Kc{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new ut,Object.assign(this,e)}}l([h({type:y.Integer,converter:We})],Kc.prototype,"userCertificate",void 0);l([h({type:ut})],Kc.prototype,"revocationDate",void 0);l([h({type:ar,optional:!0,repeated:"sequence"})],Kc.prototype,"crlEntryExtensions",void 0);class Jr{constructor(e={}){this.signature=new Y,this.issuer=new it,this.thisUpdate=new ut,Object.assign(this,e)}}l([h({type:y.Integer,optional:!0})],Jr.prototype,"version",void 0);l([h({type:Y})],Jr.prototype,"signature",void 0);l([h({type:it})],Jr.prototype,"issuer",void 0);l([h({type:ut})],Jr.prototype,"thisUpdate",void 0);l([h({type:ut,optional:!0})],Jr.prototype,"nextUpdate",void 0);l([h({type:Kc,repeated:"sequence",optional:!0})],Jr.prototype,"revokedCertificates",void 0);l([h({type:ar,optional:!0,context:0,repeated:"sequence"})],Jr.prototype,"crlExtensions",void 0);class af{constructor(e={}){this.tbsCertList=new Jr,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Jr})],af.prototype,"tbsCertList",void 0);l([h({type:Y})],af.prototype,"signatureAlgorithm",void 0);l([h({type:y.BitString})],af.prototype,"signature",void 0);class Ys{constructor(e={}){this.issuer=new it,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:it})],Ys.prototype,"issuer",void 0);l([h({type:y.Integer,converter:We})],Ys.prototype,"serialNumber",void 0);let Ps=class{constructor(e={}){Object.assign(this,e)}};l([h({type:cn,context:0,implicit:!0})],Ps.prototype,"subjectKeyIdentifier",void 0);l([h({type:Ys})],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 ca=class extends Y{};ca=l([$({type:N.Sequence})],ca);let zo=class extends Y{};zo=l([$({type:N.Sequence})],zo);let wr=class extends Y{};wr=l([$({type:N.Sequence})],wr);let Ko=class extends Y{};Ko=l([$({type:N.Sequence})],Ko);let mh=class extends Y{};mh=l([$({type:N.Sequence})],mh);let Dl=class extends Y{};Dl=l([$({type:N.Sequence})],Dl);let Xs=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],Xs.prototype,"attrType",void 0);l([h({type:y.Any,repeated:"set"})],Xs.prototype,"attrValues",void 0);var Ml;class Or{constructor(e={}){this.version=qr.v0,this.sid=new Ps,this.digestAlgorithm=new ca,this.signatureAlgorithm=new zo,this.signature=new Pe,Object.assign(this,e)}}l([h({type:y.Integer})],Or.prototype,"version",void 0);l([h({type:Ps})],Or.prototype,"sid",void 0);l([h({type:ca})],Or.prototype,"digestAlgorithm",void 0);l([h({type:Xs,repeated:"set",context:0,implicit:!0,optional:!0})],Or.prototype,"signedAttrs",void 0);l([h({type:zo})],Or.prototype,"signatureAlgorithm",void 0);l([h({type:Pe})],Or.prototype,"signature",void 0);l([h({type:Xs,repeated:"set",context:1,implicit:!0,optional:!0})],Or.prototype,"unsignedAttrs",void 0);let Go=Ml=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ml.prototype)}};Go=Ml=l([$({type:N.Set,itemType:Or})],Go);let yh=class extends ut{};yh=l([$({type:N.Choice})],yh);let gh=class extends Or{};gh=l([$({type:N.Sequence})],gh);class of{constructor(e={}){this.acIssuer=new ge,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}l([h({type:ge})],of.prototype,"acIssuer",void 0);l([h({type:y.Integer})],of.prototype,"acSerial",void 0);l([h({type:Lr,repeated:"sequence"})],of.prototype,"attrs",void 0);var Vl;let Jo=Vl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};Jo=Vl=l([$({type:N.Sequence,itemType:y.ObjectIdentifier})],Jo);class Gc{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}l([h({type:y.Integer,optional:!0})],Gc.prototype,"pathLenConstraint",void 0);l([h({type:Jo,implicit:!0,context:0,optional:!0})],Gc.prototype,"permittedAttrs",void 0);l([h({type:Jo,implicit:!0,context:1,optional:!0})],Gc.prototype,"excludedAttrs",void 0);l([h({type:y.Boolean,defaultValue:!0})],Gc.prototype,"permitUnSpecified",void 0);class ts{constructor(e={}){this.issuer=new gt,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:gt})],ts.prototype,"issuer",void 0);l([h({type:y.Integer,converter:We})],ts.prototype,"serial",void 0);l([h({type:y.BitString,optional:!0})],ts.prototype,"issuerUID",void 0);var Ul;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(Ul||(Ul={}));class rs{constructor(e={}){this.digestedObjectType=Ul.publicKey,this.digestAlgorithm=new Y,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Enumerated})],rs.prototype,"digestedObjectType",void 0);l([h({type:y.ObjectIdentifier,optional:!0})],rs.prototype,"otherObjectTypeID",void 0);l([h({type:Y})],rs.prototype,"digestAlgorithm",void 0);l([h({type:y.BitString})],rs.prototype,"objectDigest",void 0);class Jc{constructor(e={}){Object.assign(this,e)}}l([h({type:gt,optional:!0})],Jc.prototype,"issuerName",void 0);l([h({type:ts,context:0,implicit:!0,optional:!0})],Jc.prototype,"baseCertificateID",void 0);l([h({type:rs,context:1,implicit:!0,optional:!0})],Jc.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:Jc,context:0,implicit:!0})],$s.prototype,"v2Form",void 0);$s=l([$({type:N.Choice})],$s);class Yc{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}l([h({type:y.GeneralizedTime})],Yc.prototype,"notBeforeTime",void 0);l([h({type:y.GeneralizedTime})],Yc.prototype,"notAfterTime",void 0);class qa{constructor(e={}){Object.assign(this,e)}}l([h({type:ts,implicit:!0,context:0,optional:!0})],qa.prototype,"baseCertificateID",void 0);l([h({type:gt,implicit:!0,context:1,optional:!0})],qa.prototype,"entityName",void 0);l([h({type:rs,implicit:!0,context:2,optional:!0})],qa.prototype,"objectDigestInfo",void 0);var Ll;(function(r){r[r.v2=1]="v2"})(Ll||(Ll={}));class ur{constructor(e={}){this.version=Ll.v2,this.holder=new qa,this.issuer=new $s,this.signature=new Y,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Yc,this.attributes=[],Object.assign(this,e)}}l([h({type:y.Integer})],ur.prototype,"version",void 0);l([h({type:qa})],ur.prototype,"holder",void 0);l([h({type:$s})],ur.prototype,"issuer",void 0);l([h({type:Y})],ur.prototype,"signature",void 0);l([h({type:y.Integer,converter:We})],ur.prototype,"serialNumber",void 0);l([h({type:Yc})],ur.prototype,"attrCertValidityPeriod",void 0);l([h({type:Lr,repeated:"sequence"})],ur.prototype,"attributes",void 0);l([h({type:y.BitString,optional:!0})],ur.prototype,"issuerUniqueID",void 0);l([h({type:Hn,optional:!0})],ur.prototype,"extensions",void 0);class Xc{constructor(e={}){this.acinfo=new ur,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:ur})],Xc.prototype,"acinfo",void 0);l([h({type:Y})],Xc.prototype,"signatureAlgorithm",void 0);l([h({type:y.BitString})],Xc.prototype,"signatureValue",void 0);var Yo;(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"})(Yo||(Yo={}));class ql extends Lc{}class cf{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier,implicit:!0,context:0})],cf.prototype,"type",void 0);l([h({type:y.Any,implicit:!0,context:1})],cf.prototype,"value",void 0);class uf{constructor(e={}){this.policyId="",this.classList=new ql(Yo.unclassified),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],uf.prototype,"policyId",void 0);l([h({type:ql,defaultValue:new ql(Yo.unclassified)})],uf.prototype,"classList",void 0);l([h({type:cf,repeated:"set"})],uf.prototype,"securityCategories",void 0);class Qc{constructor(e={}){Object.assign(this,e)}}l([h({type:Pe})],Qc.prototype,"cotets",void 0);l([h({type:y.ObjectIdentifier})],Qc.prototype,"oid",void 0);l([h({type:y.Utf8String})],Qc.prototype,"string",void 0);class rg{constructor(e={}){this.values=[],Object.assign(this,e)}}l([h({type:gt,implicit:!0,context:0,optional:!0})],rg.prototype,"policyAuthority",void 0);l([h({type:Qc,repeated:"sequence"})],rg.prototype,"values",void 0);var Hl;class eu{constructor(e={}){this.targetCertificate=new ts,Object.assign(this,e)}}l([h({type:ts})],eu.prototype,"targetCertificate",void 0);l([h({type:ge,optional:!0})],eu.prototype,"targetName",void 0);l([h({type:rs,optional:!0})],eu.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:eu,context:2,implicit:!0})],Zs.prototype,"targetCert",void 0);Zs=l([$({type:N.Choice})],Zs);let Fl=Hl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Hl.prototype)}};Fl=Hl=l([$({type:N.Sequence,itemType:Zs})],Fl);var Wl;let vh=Wl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Wl.prototype)}};vh=Wl=l([$({type:N.Sequence,itemType:Fl})],vh);class ng{constructor(e={}){Object.assign(this,e)}}l([h({type:gt,implicit:!0,context:0,optional:!0})],ng.prototype,"roleAuthority",void 0);l([h({type:ge,implicit:!0,context:1})],ng.prototype,"roleName",void 0);class lf{constructor(e={}){this.service=new ge,this.ident=new ge,Object.assign(this,e)}}l([h({type:ge})],lf.prototype,"service",void 0);l([h({type:ge})],lf.prototype,"ident",void 0);l([h({type:Pe,optional:!0})],lf.prototype,"authInfo",void 0);var zl;class df{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],df.prototype,"otherCertFormat",void 0);l([h({type:y.Any})],df.prototype,"otherCert",void 0);let Ds=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Rs})],Ds.prototype,"certificate",void 0);l([h({type:Xc,context:2,implicit:!0})],Ds.prototype,"v2AttrCert",void 0);l([h({type:df,context:3,implicit:!0})],Ds.prototype,"other",void 0);Ds=l([$({type:N.Choice})],Ds);let Xo=zl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};Xo=zl=l([$({type:N.Set,itemType:Ds})],Xo);class Qs{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Qs.prototype,"contentType",void 0);l([h({type:y.Any,context:0})],Qs.prototype,"content",void 0);let ua=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Pe})],ua.prototype,"single",void 0);l([h({type:y.Any})],ua.prototype,"any",void 0);ua=l([$({type:N.Choice})],ua);class tu{constructor(e={}){this.eContentType="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],tu.prototype,"eContentType",void 0);l([h({type:ua,context:0,optional:!0})],tu.prototype,"eContent",void 0);let la=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Pe,context:0,implicit:!0,optional:!0})],la.prototype,"value",void 0);l([h({type:Pe,converter:__,context:0,implicit:!0,optional:!0,repeated:"sequence"})],la.prototype,"constructedValue",void 0);la=l([$({type:N.Choice})],la);class Ha{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Ko,Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Ha.prototype,"contentType",void 0);l([h({type:Ko})],Ha.prototype,"contentEncryptionAlgorithm",void 0);l([h({type:la,optional:!0})],Ha.prototype,"encryptedContent",void 0);class ru{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],ru.prototype,"keyAttrId",void 0);l([h({type:y.Any,optional:!0})],ru.prototype,"keyAttr",void 0);var Kl;class nu{constructor(e={}){this.subjectKeyIdentifier=new cn,Object.assign(this,e)}}l([h({type:cn})],nu.prototype,"subjectKeyIdentifier",void 0);l([h({type:y.GeneralizedTime,optional:!0})],nu.prototype,"date",void 0);l([h({type:ru,optional:!0})],nu.prototype,"other",void 0);let Ms=class{constructor(e={}){Object.assign(this,e)}};l([h({type:nu,context:0,implicit:!0,optional:!0})],Ms.prototype,"rKeyId",void 0);l([h({type:Ys,optional:!0})],Ms.prototype,"issuerAndSerialNumber",void 0);Ms=l([$({type:N.Choice})],Ms);class ff{constructor(e={}){this.rid=new Ms,this.encryptedKey=new Pe,Object.assign(this,e)}}l([h({type:Ms})],ff.prototype,"rid",void 0);l([h({type:Pe})],ff.prototype,"encryptedKey",void 0);let Qo=Kl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};Qo=Kl=l([$({type:N.Sequence,itemType:ff})],Qo);class hf{constructor(e={}){this.algorithm=new Y,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],hf.prototype,"algorithm",void 0);l([h({type:y.BitString})],hf.prototype,"publicKey",void 0);let Fn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:cn,context:0,implicit:!0,optional:!0})],Fn.prototype,"subjectKeyIdentifier",void 0);l([h({type:hf,context:1,implicit:!0,optional:!0})],Fn.prototype,"originatorKey",void 0);l([h({type:Ys,optional:!0})],Fn.prototype,"issuerAndSerialNumber",void 0);Fn=l([$({type:N.Choice})],Fn);class ei{constructor(e={}){this.version=qr.v3,this.originator=new Fn,this.keyEncryptionAlgorithm=new wr,this.recipientEncryptedKeys=new Qo,Object.assign(this,e)}}l([h({type:y.Integer})],ei.prototype,"version",void 0);l([h({type:Fn,context:0})],ei.prototype,"originator",void 0);l([h({type:Pe,context:1,optional:!0})],ei.prototype,"ukm",void 0);l([h({type:wr})],ei.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Qo})],ei.prototype,"recipientEncryptedKeys",void 0);let Vs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:cn,context:0,implicit:!0})],Vs.prototype,"subjectKeyIdentifier",void 0);l([h({type:Ys})],Vs.prototype,"issuerAndSerialNumber",void 0);Vs=l([$({type:N.Choice})],Vs);class Fa{constructor(e={}){this.version=qr.v0,this.rid=new Vs,this.keyEncryptionAlgorithm=new wr,this.encryptedKey=new Pe,Object.assign(this,e)}}l([h({type:y.Integer})],Fa.prototype,"version",void 0);l([h({type:Vs})],Fa.prototype,"rid",void 0);l([h({type:wr})],Fa.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Pe})],Fa.prototype,"encryptedKey",void 0);class Wa{constructor(e={}){this.keyIdentifier=new Pe,Object.assign(this,e)}}l([h({type:Pe})],Wa.prototype,"keyIdentifier",void 0);l([h({type:y.GeneralizedTime,optional:!0})],Wa.prototype,"date",void 0);l([h({type:ru,optional:!0})],Wa.prototype,"other",void 0);class za{constructor(e={}){this.version=qr.v4,this.kekid=new Wa,this.keyEncryptionAlgorithm=new wr,this.encryptedKey=new Pe,Object.assign(this,e)}}l([h({type:y.Integer})],za.prototype,"version",void 0);l([h({type:Wa})],za.prototype,"kekid",void 0);l([h({type:wr})],za.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Pe})],za.prototype,"encryptedKey",void 0);class Ka{constructor(e={}){this.version=qr.v0,this.keyEncryptionAlgorithm=new wr,this.encryptedKey=new Pe,Object.assign(this,e)}}l([h({type:y.Integer})],Ka.prototype,"version",void 0);l([h({type:Dl,context:0,optional:!0})],Ka.prototype,"keyDerivationAlgorithm",void 0);l([h({type:wr})],Ka.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Pe})],Ka.prototype,"encryptedKey",void 0);class pf{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],pf.prototype,"oriType",void 0);l([h({type:y.Any})],pf.prototype,"oriValue",void 0);let yn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Fa,optional:!0})],yn.prototype,"ktri",void 0);l([h({type:ei,context:1,implicit:!0,optional:!0})],yn.prototype,"kari",void 0);l([h({type:za,context:2,implicit:!0,optional:!0})],yn.prototype,"kekri",void 0);l([h({type:Ka,context:3,implicit:!0,optional:!0})],yn.prototype,"pwri",void 0);l([h({type:pf,context:4,implicit:!0,optional:!0})],yn.prototype,"ori",void 0);yn=l([$({type:N.Choice})],yn);var Gl;let ec=Gl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Gl.prototype)}};ec=Gl=l([$({type:N.Set,itemType:yn})],ec);var Jl;class su{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],su.prototype,"otherRevInfoFormat",void 0);l([h({type:y.Any})],su.prototype,"otherRevInfo",void 0);let tc=class{constructor(e={}){this.other=new su,Object.assign(this,e)}};l([h({type:su,context:1,implicit:!0})],tc.prototype,"other",void 0);tc=l([$({type:N.Choice})],tc);let rc=Jl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Jl.prototype)}};rc=Jl=l([$({type:N.Set,itemType:tc})],rc);class mf{constructor(e={}){Object.assign(this,e)}}l([h({type:Xo,context:0,implicit:!0,optional:!0})],mf.prototype,"certs",void 0);l([h({type:rc,context:1,implicit:!0,optional:!0})],mf.prototype,"crls",void 0);var Yl;let Xl=Yl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Yl.prototype)}};Xl=Yl=l([$({type:N.Set,itemType:Xs})],Xl);class Ga{constructor(e={}){this.version=qr.v0,this.recipientInfos=new ec,this.encryptedContentInfo=new Ha,Object.assign(this,e)}}l([h({type:y.Integer})],Ga.prototype,"version",void 0);l([h({type:mf,context:0,implicit:!0,optional:!0})],Ga.prototype,"originatorInfo",void 0);l([h({type:ec})],Ga.prototype,"recipientInfos",void 0);l([h({type:Ha})],Ga.prototype,"encryptedContentInfo",void 0);l([h({type:Xl,context:1,implicit:!0,optional:!0})],Ga.prototype,"unprotectedAttrs",void 0);const z_="1.2.840.113549.1.7.2";var Ql;let nc=Ql=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ql.prototype)}};nc=Ql=l([$({type:N.Set,itemType:ca})],nc);class ti{constructor(e={}){this.version=qr.v0,this.digestAlgorithms=new nc,this.encapContentInfo=new tu,this.signerInfos=new Go,Object.assign(this,e)}}l([h({type:y.Integer})],ti.prototype,"version",void 0);l([h({type:nc})],ti.prototype,"digestAlgorithms",void 0);l([h({type:tu})],ti.prototype,"encapContentInfo",void 0);l([h({type:Xo,context:0,implicit:!0,optional:!0})],ti.prototype,"certificates",void 0);l([h({type:rc,context:1,implicit:!0,optional:!0})],ti.prototype,"crls",void 0);l([h({type:Go})],ti.prototype,"signerInfos",void 0);const da="1.2.840.10045.2.1",yf="1.2.840.10045.4.1",sg="1.2.840.10045.4.3.1",gf="1.2.840.10045.4.3.2",vf="1.2.840.10045.4.3.3",bf="1.2.840.10045.4.3.4",bh="1.2.840.10045.3.1.7",xh="1.3.132.0.34",_h="1.3.132.0.35";function Ja(r){return new Y({algorithm:r})}const K_=Ja(yf);Ja(sg);const G_=Ja(gf),J_=Ja(vf),Y_=Ja(bf);let fa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],fa.prototype,"fieldType",void 0);l([h({type:y.Any})],fa.prototype,"parameters",void 0);fa=l([$({type:N.Sequence})],fa);class X_ extends Pe{}let Us=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.OctetString})],Us.prototype,"a",void 0);l([h({type:y.OctetString})],Us.prototype,"b",void 0);l([h({type:y.BitString,optional:!0})],Us.prototype,"seed",void 0);Us=l([$({type:N.Sequence})],Us);var ed;(function(r){r[r.ecpVer1=1]="ecpVer1"})(ed||(ed={}));let Hr=class{constructor(e={}){this.version=ed.ecpVer1,Object.assign(this,e)}};l([h({type:y.Integer})],Hr.prototype,"version",void 0);l([h({type:fa})],Hr.prototype,"fieldID",void 0);l([h({type:Us})],Hr.prototype,"curve",void 0);l([h({type:X_})],Hr.prototype,"base",void 0);l([h({type:y.Integer,converter:We})],Hr.prototype,"order",void 0);l([h({type:y.Integer,optional:!0})],Hr.prototype,"cofactor",void 0);Hr=l([$({type:N.Sequence})],Hr);let gn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:y.ObjectIdentifier})],gn.prototype,"namedCurve",void 0);l([h({type:y.Null})],gn.prototype,"implicitCurve",void 0);l([h({type:Hr})],gn.prototype,"specifiedCurve",void 0);gn=l([$({type:N.Choice})],gn);class iu{constructor(e={}){this.version=1,this.privateKey=new Pe,Object.assign(this,e)}}l([h({type:y.Integer})],iu.prototype,"version",void 0);l([h({type:Pe})],iu.prototype,"privateKey",void 0);l([h({type:gn,context:0,optional:!0})],iu.prototype,"parameters",void 0);l([h({type:y.BitString,context:1,optional:!0})],iu.prototype,"publicKey",void 0);class sc{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Integer,converter:We})],sc.prototype,"r",void 0);l([h({type:y.Integer,converter:We})],sc.prototype,"s",void 0);const It="1.2.840.113549.1.1",Wn=`${It}.1`,Q_=`${It}.7`,ew=`${It}.9`,Ci=`${It}.10`,tw=`${It}.2`,rw=`${It}.4`,ic=`${It}.5`,nw=`${It}.14`,td=`${It}.11`,ac=`${It}.12`,oc=`${It}.13`,ig=`${It}.15`,ag=`${It}.16`,cc="1.3.14.3.2.26",og="2.16.840.1.101.3.4.2.4",uc="2.16.840.1.101.3.4.2.1",lc="2.16.840.1.101.3.4.2.2",dc="2.16.840.1.101.3.4.2.3",sw="2.16.840.1.101.3.4.2.5",iw="2.16.840.1.101.3.4.2.6",aw="1.2.840.113549.2.2",ow="1.2.840.113549.2.5",au=`${It}.8`;function at(r){return new Y({algorithm:r,parameters:null})}at(aw);at(ow);const zn=at(cc);at(og);at(uc);at(lc);at(dc);at(sw);at(iw);const cg=new Y({algorithm:au,parameters:W.serialize(zn)}),ug=new Y({algorithm:ew,parameters:W.serialize(Vo.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(tw);at(rw);at(ic);at(ig);at(ag);at(ac);at(oc);at(ig);at(ag);class ou{constructor(e={}){this.hashAlgorithm=new Y(zn),this.maskGenAlgorithm=new Y({algorithm:au,parameters:W.serialize(zn)}),this.pSourceAlgorithm=new Y(ug),Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:zn})],ou.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:cg})],ou.prototype,"maskGenAlgorithm",void 0);l([h({type:Y,context:2,defaultValue:ug})],ou.prototype,"pSourceAlgorithm",void 0);new Y({algorithm:Q_,parameters:W.serialize(new ou)});class Kn{constructor(e={}){this.hashAlgorithm=new Y(zn),this.maskGenAlgorithm=new Y({algorithm:au,parameters:W.serialize(zn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:zn})],Kn.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:cg})],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 Y({algorithm:Ci,parameters:W.serialize(new Kn)});class cu{constructor(e={}){this.digestAlgorithm=new Y,this.digest=new Pe,Object.assign(this,e)}}l([h({type:Y})],cu.prototype,"digestAlgorithm",void 0);l([h({type:Pe})],cu.prototype,"digest",void 0);var rd;class uu{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Integer,converter:We})],uu.prototype,"prime",void 0);l([h({type:y.Integer,converter:We})],uu.prototype,"exponent",void 0);l([h({type:y.Integer,converter:We})],uu.prototype,"coefficient",void 0);let nd=rd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,rd.prototype)}};nd=rd=l([$({type:N.Sequence,itemType:uu})],nd);class Er{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})],Er.prototype,"version",void 0);l([h({type:y.Integer,converter:We})],Er.prototype,"modulus",void 0);l([h({type:y.Integer,converter:We})],Er.prototype,"publicExponent",void 0);l([h({type:y.Integer,converter:We})],Er.prototype,"privateExponent",void 0);l([h({type:y.Integer,converter:We})],Er.prototype,"prime1",void 0);l([h({type:y.Integer,converter:We})],Er.prototype,"prime2",void 0);l([h({type:y.Integer,converter:We})],Er.prototype,"exponent1",void 0);l([h({type:y.Integer,converter:We})],Er.prototype,"exponent2",void 0);l([h({type:y.Integer,converter:We})],Er.prototype,"coefficient",void 0);l([h({type:nd,optional:!0})],Er.prototype,"otherPrimeInfos",void 0);class xf{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.Integer,converter:We})],xf.prototype,"modulus",void 0);l([h({type:y.Integer,converter:We})],xf.prototype,"publicExponent",void 0);var sd;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(sd||(sd={}));const kt=sd;/*! *****************************************************************************
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 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
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 Fl=function(r,e){return Fl=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])},Fl(r,e)};function af(r,e){Fl(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Z_(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 D_(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 Fa(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 ec(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(ec(arguments[e]));return r}var M_="injectionTokens";function V_(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(M_,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function My(r){return!!r.useClass}function Wl(r){return!!r.useFactory}var Vy=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 zn(r){return typeof r=="string"||typeof r=="symbol"}function U_(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function oh(r){return typeof r=="object"&&"token"in r&&"transform"in r}function L_(r){return typeof r=="function"||r instanceof Vy}function eo(r){return!!r.useToken}function to(r){return r.useValue!=null}function q_(r){return My(r)||to(r)||eo(r)||Wl(r)}var of=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}(),H_=function(r){af(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(of),ch=function(){function r(){this.scopedResolutions=new Map}return r}();function F_(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function W_(r,e,t){return t===void 0&&(t=" "),gn([r],e.message.split(`
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 _f(r,e){id(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function cw(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 uw(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 no(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 fc(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 Cn(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(fc(arguments[e]));return r}var lw="injectionTokens";function dw(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(lw,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function lg(r){return!!r.useClass}function ad(r){return!!r.useFactory}var dg=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,Cn(i))}};return this.reflectMethods.forEach(n),t},r}();function as(r){return typeof r=="string"||typeof r=="symbol"}function fw(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function wh(r){return typeof r=="object"&&"token"in r&&"transform"in r}function hw(r){return typeof r=="function"||r instanceof dg}function po(r){return!!r.useToken}function mo(r){return r.useValue!=null}function pw(r){return lg(r)||mo(r)||po(r)||ad(r)}var wf=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}(),mw=function(r){_f(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(wf),kh=function(){function r(){this.scopedResolutions=new Map}return r}();function yw(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function gw(r,e,t){return t===void 0&&(t=" "),Cn([r],e.message.split(`
89
89
  `).map(function(n){return t+n})).join(`
90
- `)}function z_(r,e,t){var n=ec(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],i=s===void 0?null:s,a=F_(i,e);return W_("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function K_(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var G_=function(r){af(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(of),J_=function(r){af(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(of),Y_=function(){function r(){this.preResolution=new G_,this.postResolution=new J_}return r}(),Uy=new Map,X_=function(){function r(e){this.parent=e,this._registry=new H_,this.interceptors=new Y_,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:_t.Transient}),this.ensureNotDisposed();var s;if(q_(t)?s=t:s={useClass:t},eo(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&&eo(c.provider)?a=c.provider:a=null}if((n.lifecycle===_t.Singleton||n.lifecycle==_t.ContainerScoped||n.lifecycle==_t.ResolutionScoped)&&(to(s)||Wl(s)))throw new Error('Cannot use lifecycle "'+_t[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(),zn(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(),zn(e)){if(zn(t))return this.register(e,{useToken:t},{lifecycle:_t.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:_t.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!zn(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:_t.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new ch),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&zn(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(L_(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=Fa(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=Fa(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===_t.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===_t.Singleton,s=e.options.lifecycle===_t.ContainerScoped,i=n||s,a;return to(e.provider)?a=e.provider.useValue:eo(e.provider)?a=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):My(e.provider)?a=i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Wl(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===_t.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new ch),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&zn(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=Fa(this._registry.entries()),s=n.next();!s.done;s=n.next()){var i=ec(s.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(c){return!to(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=Fa(this._registry.entries()),i=s.next();!i.done;i=s.next()){var a=ec(i.value,2),o=a[0],c=a[1];c.some(function(u){var f=u.options;return f.lifecycle===_t.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===_t.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 Z_(this,void 0,void 0,function(){var e;return D_(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 Vy)return e.createProxy(function(i){return n.resolve(i,t)});var s=function(){var i=Uy.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 K_(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 U_(s)?oh(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):oh(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(z_(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}(),vt=new X_;function Xc(){return function(r){Uy.set(r,V_(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 zl;class Qc{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}l([h({type:y.ObjectIdentifier})],Qc.prototype,"attrId",void 0);l([h({type:y.Any,repeated:"set"})],Qc.prototype,"attrValues",void 0);let uh=zl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};uh=zl=l([R({type:N.Sequence,itemType:Qc})],uh);var Kl;let lh=Kl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};lh=Kl=l([R({type:N.Sequence,itemType:Vs})],lh);class Ly{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Ly.prototype,"certId",void 0);l([h({type:y.Any,context:0})],Ly.prototype,"certValue",void 0);class qy{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],qy.prototype,"crlId",void 0);l([h({type:y.Any,context:0})],qy.prototype,"crltValue",void 0);class Hy extends Re{}let eu=class{constructor(e={}){this.encryptionAlgorithm=new X,this.encryptedData=new Hy,Object.assign(this,e)}};l([h({type:X})],eu.prototype,"encryptionAlgorithm",void 0);l([h({type:Hy})],eu.prototype,"encryptedData",void 0);var Gl,Jl;(function(r){r[r.v1=0]="v1"})(Jl||(Jl={}));class Fy extends Re{}let Yl=Gl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Gl.prototype)}};Yl=Gl=l([R({type:N.Sequence,itemType:$r})],Yl);class Ma{constructor(e={}){this.version=Jl.v1,this.privateKeyAlgorithm=new X,this.privateKey=new Fy,Object.assign(this,e)}}l([h({type:y.Integer})],Ma.prototype,"version",void 0);l([h({type:X})],Ma.prototype,"privateKeyAlgorithm",void 0);l([h({type:Fy})],Ma.prototype,"privateKey",void 0);l([h({type:Yl,implicit:!0,context:0,optional:!0})],Ma.prototype,"attributes",void 0);let dh=class extends Ma{};dh=l([R({type:N.Sequence})],dh);let fh=class extends eu{};fh=l([R({type:N.Sequence})],fh);class Wy{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],Wy.prototype,"secretTypeId",void 0);l([h({type:y.Any,context:0})],Wy.prototype,"secretValue",void 0);class Va{constructor(e={}){this.mac=new Jc,this.macSalt=new Re,this.iterations=1,Object.assign(this,e)}}l([h({type:Jc})],Va.prototype,"mac",void 0);l([h({type:Re})],Va.prototype,"macSalt",void 0);l([h({type:y.Integer,defaultValue:1})],Va.prototype,"iterations",void 0);class tu{constructor(e={}){this.version=3,this.authSafe=new Vs,this.macData=new Va,Object.assign(this,e)}}l([h({type:y.Integer})],tu.prototype,"version",void 0);l([h({type:Vs})],tu.prototype,"authSafe",void 0);l([h({type:Va,optional:!0})],tu.prototype,"macData",void 0);var Xl;class ru{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],ru.prototype,"bagId",void 0);l([h({type:y.Any,context:0})],ru.prototype,"bagValue",void 0);l([h({type:Qc,repeated:"set",optional:!0})],ru.prototype,"bagAttributes",void 0);let hh=Xl=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,Xl.prototype)}};hh=Xl=l([R({type:N.Sequence,itemType:ru})],hh);var Ql,ed,td;const zy="1.2.840.113549.1.9",Ky=`${zy}.7`,cf=`${zy}.14`;let tc=class extends ut{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};l([h({type:y.IA5String})],tc.prototype,"ia5String",void 0);tc=l([R({type:N.Choice})],tc);let ph=class extends Vs{};ph=l([R({type:N.Sequence})],ph);let mh=class extends tu{};mh=l([R({type:N.Sequence})],mh);let yh=class extends eu{};yh=l([R({type:N.Sequence})],yh);let rd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.IA5String})],rd.prototype,"value",void 0);rd=l([R({type:N.Choice})],rd);let gh=class extends tc{};gh=l([R({type:N.Choice})],gh);let vh=class extends ut{};vh=l([R({type:N.Choice})],vh);let nd=class{constructor(e=new Date){this.value=e}};l([h({type:y.GeneralizedTime})],nd.prototype,"value",void 0);nd=l([R({type:N.Choice})],nd);let bh=class extends ut{};bh=l([R({type:N.Choice})],bh);let sd=class{constructor(e="M"){this.value=e}toString(){return this.value}};l([h({type:y.PrintableString})],sd.prototype,"value",void 0);sd=l([R({type:N.Choice})],sd);let rc=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.PrintableString})],rc.prototype,"value",void 0);rc=l([R({type:N.Choice})],rc);let xh=class extends rc{};xh=l([R({type:N.Choice})],xh);let _h=class extends ut{};_h=l([R({type:N.Choice})],_h);let id=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.ObjectIdentifier})],id.prototype,"value",void 0);id=l([R({type:N.Choice})],id);let wh=class extends ot{};wh=l([R({type:N.Choice})],wh);let ad=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};l([h({type:y.Integer})],ad.prototype,"value",void 0);ad=l([R({type:N.Choice})],ad);let kh=class extends wr{};kh=l([R({type:N.Sequence})],kh);let nc=class extends ut{};nc=l([R({type:N.Choice})],nc);let Sh=Ql=class extends Bn{constructor(e){super(e),Object.setPrototypeOf(this,Ql.prototype)}};Sh=Ql=l([R({type:N.Sequence})],Sh);let Ah=ed=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,ed.prototype)}};Ah=ed=l([R({type:N.Set,itemType:Ms})],Ah);let od=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.BmpString})],od.prototype,"value",void 0);od=l([R({type:N.Choice})],od);let cd=class extends X{};cd=l([R({type:N.Sequence})],cd);let Oh=td=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,td.prototype)}};Oh=td=l([R({type:N.Sequence,itemType:cd})],Oh);var ud;let sc=ud=class extends De{constructor(e){super(e),Object.setPrototypeOf(this,ud.prototype)}};sc=ud=l([R({type:N.Sequence,itemType:$r})],sc);class qs{constructor(e={}){this.version=0,this.subject=new rt,this.subjectPKInfo=new ur,this.attributes=new sc,Object.assign(this,e)}}l([h({type:y.Integer})],qs.prototype,"version",void 0);l([h({type:rt})],qs.prototype,"subject",void 0);l([h({type:ur})],qs.prototype,"subjectPKInfo",void 0);l([h({type:sc,implicit:!0,context:0})],qs.prototype,"attributes",void 0);class ta{constructor(e={}){this.certificationRequestInfo=new qs,this.signatureAlgorithm=new X,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:qs})],ta.prototype,"certificationRequestInfo",void 0);l([h({type:X})],ta.prototype,"signatureAlgorithm",void 0);l([h({type:y.BitString})],ta.prototype,"signature",void 0);/*!
90
+ `)}function vw(r,e,t){var n=fc(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],i=s===void 0?null:s,a=yw(i,e);return gw("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function bw(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var xw=function(r){_f(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(wf),_w=function(r){_f(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(wf),ww=function(){function r(){this.preResolution=new xw,this.postResolution=new _w}return r}(),fg=new Map,kw=function(){function r(e){this.parent=e,this._registry=new mw,this.interceptors=new ww,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:kt.Transient}),this.ensureNotDisposed();var s;if(pw(t)?s=t:s={useClass:t},po(s))for(var i=[e],a=s;a!=null;){var o=a.useToken;if(i.includes(o))throw new Error("Token registration cycle detected! "+Cn(i,[o]).join(" -> "));i.push(o);var c=this._registry.get(o);c&&po(c.provider)?a=c.provider:a=null}if((n.lifecycle===kt.Singleton||n.lifecycle==kt.ContainerScoped||n.lifecycle==kt.ResolutionScoped)&&(mo(s)||ad(s)))throw new Error('Cannot use lifecycle "'+kt[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(),as(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(),as(e)){if(as(t))return this.register(e,{useToken:t},{lifecycle:kt.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:kt.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!as(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:kt.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new kh),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&as(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(hw(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=no(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=no(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===kt.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===kt.Singleton,s=e.options.lifecycle===kt.ContainerScoped,i=n||s,a;return mo(e.provider)?a=e.provider.useValue:po(e.provider)?a=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):lg(e.provider)?a=i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):ad(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===kt.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new kh),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&as(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=no(this._registry.entries()),s=n.next();!s.done;s=n.next()){var i=fc(s.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(c){return!mo(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=no(this._registry.entries()),i=s.next();!i.done;i=s.next()){var a=fc(i.value,2),o=a[0],c=a[1];c.some(function(u){var f=u.options;return f.lifecycle===kt.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===kt.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 cw(this,void 0,void 0,function(){var e;return uw(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 dg)return e.createProxy(function(i){return n.resolve(i,t)});var s=function(){var i=fg.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,Cn([void 0],a)))}();return bw(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 fw(s)?wh(s)?s.multiple?(a=n.resolve(s.transform)).transform.apply(a,Cn([n.resolveAll(s.token)],s.transformArgs)):(o=n.resolve(s.transform)).transform.apply(o,Cn([n.resolve(s.token,e)],s.transformArgs)):s.multiple?n.resolveAll(s.token):n.resolve(s.token,e):wh(s)?(c=n.resolve(s.transform,e)).transform.apply(c,Cn([n.resolve(s.token,e)],s.transformArgs)):n.resolve(s,e)}catch(u){throw new Error(vw(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}(),xt=new kw;function lu(){return function(r){fg.set(r,dw(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 od;class du{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}l([h({type:y.ObjectIdentifier})],du.prototype,"attrId",void 0);l([h({type:y.Any,repeated:"set"})],du.prototype,"attrValues",void 0);let Sh=od=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,od.prototype)}};Sh=od=l([$({type:N.Sequence,itemType:du})],Sh);var cd;let Ah=cd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,cd.prototype)}};Ah=cd=l([$({type:N.Sequence,itemType:Qs})],Ah);class hg{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],hg.prototype,"certId",void 0);l([h({type:y.Any,context:0})],hg.prototype,"certValue",void 0);class pg{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],pg.prototype,"crlId",void 0);l([h({type:y.Any,context:0})],pg.prototype,"crltValue",void 0);class mg extends Pe{}let fu=class{constructor(e={}){this.encryptionAlgorithm=new Y,this.encryptedData=new mg,Object.assign(this,e)}};l([h({type:Y})],fu.prototype,"encryptionAlgorithm",void 0);l([h({type:mg})],fu.prototype,"encryptedData",void 0);var ud,ld;(function(r){r[r.v1=0]="v1"})(ld||(ld={}));class yg extends Pe{}let dd=ud=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,ud.prototype)}};dd=ud=l([$({type:N.Sequence,itemType:Lr})],dd);class Ya{constructor(e={}){this.version=ld.v1,this.privateKeyAlgorithm=new Y,this.privateKey=new yg,Object.assign(this,e)}}l([h({type:y.Integer})],Ya.prototype,"version",void 0);l([h({type:Y})],Ya.prototype,"privateKeyAlgorithm",void 0);l([h({type:yg})],Ya.prototype,"privateKey",void 0);l([h({type:dd,implicit:!0,context:0,optional:!0})],Ya.prototype,"attributes",void 0);let Oh=class extends Ya{};Oh=l([$({type:N.Sequence})],Oh);let Eh=class extends fu{};Eh=l([$({type:N.Sequence})],Eh);class gg{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],gg.prototype,"secretTypeId",void 0);l([h({type:y.Any,context:0})],gg.prototype,"secretValue",void 0);class Xa{constructor(e={}){this.mac=new cu,this.macSalt=new Pe,this.iterations=1,Object.assign(this,e)}}l([h({type:cu})],Xa.prototype,"mac",void 0);l([h({type:Pe})],Xa.prototype,"macSalt",void 0);l([h({type:y.Integer,defaultValue:1})],Xa.prototype,"iterations",void 0);class hu{constructor(e={}){this.version=3,this.authSafe=new Qs,this.macData=new Xa,Object.assign(this,e)}}l([h({type:y.Integer})],hu.prototype,"version",void 0);l([h({type:Qs})],hu.prototype,"authSafe",void 0);l([h({type:Xa,optional:!0})],hu.prototype,"macData",void 0);var fd;class pu{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:y.ObjectIdentifier})],pu.prototype,"bagId",void 0);l([h({type:y.Any,context:0})],pu.prototype,"bagValue",void 0);l([h({type:du,repeated:"set",optional:!0})],pu.prototype,"bagAttributes",void 0);let Ch=fd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,fd.prototype)}};Ch=fd=l([$({type:N.Sequence,itemType:pu})],Ch);var hd,pd,md;const vg="1.2.840.113549.1.9",bg=`${vg}.7`,kf=`${vg}.14`;let hc=class extends dt{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};l([h({type:y.IA5String})],hc.prototype,"ia5String",void 0);hc=l([$({type:N.Choice})],hc);let Ih=class extends Qs{};Ih=l([$({type:N.Sequence})],Ih);let jh=class extends hu{};jh=l([$({type:N.Sequence})],jh);let Th=class extends fu{};Th=l([$({type:N.Sequence})],Th);let yd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.IA5String})],yd.prototype,"value",void 0);yd=l([$({type:N.Choice})],yd);let Nh=class extends hc{};Nh=l([$({type:N.Choice})],Nh);let Bh=class extends dt{};Bh=l([$({type:N.Choice})],Bh);let gd=class{constructor(e=new Date){this.value=e}};l([h({type:y.GeneralizedTime})],gd.prototype,"value",void 0);gd=l([$({type:N.Choice})],gd);let Rh=class extends dt{};Rh=l([$({type:N.Choice})],Rh);let vd=class{constructor(e="M"){this.value=e}toString(){return this.value}};l([h({type:y.PrintableString})],vd.prototype,"value",void 0);vd=l([$({type:N.Choice})],vd);let pc=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.PrintableString})],pc.prototype,"value",void 0);pc=l([$({type:N.Choice})],pc);let Ph=class extends pc{};Ph=l([$({type:N.Choice})],Ph);let $h=class extends dt{};$h=l([$({type:N.Choice})],$h);let bd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.ObjectIdentifier})],bd.prototype,"value",void 0);bd=l([$({type:N.Choice})],bd);let Zh=class extends ut{};Zh=l([$({type:N.Choice})],Zh);let xd=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};l([h({type:y.Integer})],xd.prototype,"value",void 0);xd=l([$({type:N.Choice})],xd);let Dh=class extends Or{};Dh=l([$({type:N.Sequence})],Dh);let mc=class extends dt{};mc=l([$({type:N.Choice})],mc);let Mh=hd=class extends Hn{constructor(e){super(e),Object.setPrototypeOf(this,hd.prototype)}};Mh=hd=l([$({type:N.Sequence})],Mh);let Vh=pd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,pd.prototype)}};Vh=pd=l([$({type:N.Set,itemType:Xs})],Vh);let _d=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:y.BmpString})],_d.prototype,"value",void 0);_d=l([$({type:N.Choice})],_d);let wd=class extends Y{};wd=l([$({type:N.Sequence})],wd);let Uh=md=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,md.prototype)}};Uh=md=l([$({type:N.Sequence,itemType:wd})],Uh);var kd;let yc=kd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,kd.prototype)}};yc=kd=l([$({type:N.Sequence,itemType:Lr})],yc);class ri{constructor(e={}){this.version=0,this.subject=new it,this.subjectPKInfo=new hr,this.attributes=new yc,Object.assign(this,e)}}l([h({type:y.Integer})],ri.prototype,"version",void 0);l([h({type:it})],ri.prototype,"subject",void 0);l([h({type:hr})],ri.prototype,"subjectPKInfo",void 0);l([h({type:yc,implicit:!0,context:0})],ri.prototype,"attributes",void 0);class ha{constructor(e={}){this.certificationRequestInfo=new ri,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:ri})],ha.prototype,"certificationRequestInfo",void 0);l([h({type:Y})],ha.prototype,"signatureAlgorithm",void 0);l([h({type:y.BitString})],ha.prototype,"signature",void 0);/*!
91
91
  * MIT License
92
92
  *
93
93
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -110,12 +110,12 @@ PERFORMANCE OF THIS SOFTWARE.
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 Ua="crypto.algorithm";class Q_{getAlgorithms(){return vt.resolveAll(Ua)}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 X({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 Cs="crypto.algorithmProvider";vt.registerSingleton(Cs,Q_);var ro;const Et="1.3.36.3.3.2.8.1.1",Eh=`${Et}.1`,Ih=`${Et}.2`,Ch=`${Et}.3`,jh=`${Et}.4`,Th=`${Et}.5`,Nh=`${Et}.6`,Bh=`${Et}.7`,Rh=`${Et}.8`,Ph=`${Et}.9`,$h=`${Et}.10`,Zh=`${Et}.11`,Dh=`${Et}.12`,Mh=`${Et}.13`,Vh=`${Et}.14`,Uh="brainpoolP160r1",Lh="brainpoolP160t1",qh="brainpoolP192r1",Hh="brainpoolP192t1",Fh="brainpoolP224r1",Wh="brainpoolP224t1",zh="brainpoolP256r1",Kh="brainpoolP256t1",Gh="brainpoolP320r1",Jh="brainpoolP320t1",Yh="brainpoolP384r1",Xh="brainpoolP384t1",Qh="brainpoolP512r1",ep="brainpoolP512t1",We="ECDSA";let ra=ro=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case We.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return k_;case"sha-256":return S_;case"sha-384":return A_;case"sha-512":return O_}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=sh;break;case"K-256":t=ro.SECP256K1;break;case"P-384":t=ih;break;case"P-521":t=ah;break;case Uh:t=Eh;break;case Lh:t=Ih;break;case qh:t=Ch;break;case Hh:t=jh;break;case Fh:t=Th;break;case Wh:t=Nh;break;case zh:t=Bh;break;case Kh:t=Rh;break;case Gh:t=Ph;break;case Jh:t=$h;break;case Yh:t=Zh;break;case Xh:t=Dh;break;case Qh:t=Mh;break;case ep:t=Vh;break}if(t)return new X({algorithm:Qi,parameters:W.serialize(new cn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case ef:return{name:We,hash:{name:"SHA-1"}};case tf:return{name:We,hash:{name:"SHA-256"}};case rf:return{name:We,hash:{name:"SHA-384"}};case nf:return{name:We,hash:{name:"SHA-512"}};case Qi:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(W.parse(e.parameters,cn).namedCurve){case sh:return{name:We,namedCurve:"P-256"};case ro.SECP256K1:return{name:We,namedCurve:"K-256"};case ih:return{name:We,namedCurve:"P-384"};case ah:return{name:We,namedCurve:"P-521"};case Eh:return{name:We,namedCurve:Uh};case Ih:return{name:We,namedCurve:Lh};case Ch:return{name:We,namedCurve:qh};case jh:return{name:We,namedCurve:Hh};case Th:return{name:We,namedCurve:Fh};case Nh:return{name:We,namedCurve:Wh};case Bh:return{name:We,namedCurve:zh};case Rh:return{name:We,namedCurve:Kh};case Ph:return{name:We,namedCurve:Gh};case $h:return{name:We,namedCurve:Jh};case Zh:return{name:We,namedCurve:Yh};case Dh:return{name:We,namedCurve:Xh};case Mh:return{name:We,namedCurve:Qh};case Vh:return{name:We,namedCurve:ep}}}}return null}};ra.SECP256K1="1.3.132.0.10";ra=ro=l([Xc()],ra);vt.registerSingleton(Ua,ra);const Gy=Symbol("name"),Jy=Symbol("value");class $e{constructor(e,t={},n=""){this[Gy]=e,this[Jy]=n;for(const s in t)this[s]=t[s]}}$e.NAME=Gy;$e.VALUE=Jy;class ew{static toTextObject(e){const t=new $e("Algorithm Identifier",{},pn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Qi:{const n=new ra().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class pn{static toString(e){const t=this.items[e];return t||e}}pn.items={[Jo]:"sha1",[$y]:"sha224",[Yo]:"sha256",[Xo]:"sha384",[Qo]:"sha512",[Pn]:"rsaEncryption",[zo]:"sha1WithRSAEncryption",[N_]:"sha224WithRSAEncryption",[Ul]:"sha256WithRSAEncryption",[Ko]:"sha384WithRSAEncryption",[Go]:"sha512WithRSAEncryption",[Qi]:"ecPublicKey",[ef]:"ecdsaWithSHA1",[By]:"ecdsaWithSHA224",[tf]:"ecdsaWithSHA256",[rf]:"ecdsaWithSHA384",[nf]:"ecdsaWithSHA512",[y_]:"TLS WWW server authentication",[g_]:"TLS WWW client authentication",[v_]:"Code Signing",[b_]:"E-mail Protection",[x_]:"Time Stamping",[__]:"OCSP Signing",[w_]:"Signed Data"};class Dn{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[$e.VALUE];a&&(i=` ${a}`),n.push(`${s}${e[$e.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[$e.NAME]=o,n.push(...this.serializeObj(f,t));else if(c instanceof $e)c[$e.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[$e.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)}}Dn.oidSerializer=pn;Dn.algorithmSerializer=ew;class mn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=W.serialize(t),this.onInit(t)}else{const t=W.parse(e[0],e[1]);this.rawData=L.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof mn?mm(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return W.toString(this.rawData);case"text":return Dn.serialize(this.toTextObject());case"hex":return ne.ToHex(this.rawData);case"base64":return ne.ToBase64(this.rawData);case"base64url":return ne.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 $e(this.getTextName(),{},e)}}mn.NAME="ASN";class Ut extends mn{constructor(...e){let t;L.isBufferSource(e[0])?t=L.toArrayBuffer(e[0]):t=W.serialize(new rr({extnID:e[0],critical:e[1],extnValue:new Re(L.toArrayBuffer(e[2]))})),super(t,rr)}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[$e.NAME]===Ut.NAME&&(e[$e.NAME]=pn.toString(this.type)),e}}var Yy;class Gr{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[Yy]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Gr.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Gr.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=Gr.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(Gr.DEFAULT,e);return this}}Yy=Symbol.toStringTag;Gr.DEFAULT="default";const pt=new Gr,tw=/^[0-2](?:\.[1-9][0-9]*)+$/;function rw(r){return new RegExp(tw).test(r)}class Xy{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return rw(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const At=new Xy;At.register("CN","2.5.4.3");At.register("L","2.5.4.7");At.register("ST","2.5.4.8");At.register("O","2.5.4.10");At.register("OU","2.5.4.11");At.register("C","2.5.4.6");At.register("DC","0.9.2342.19200300.100.1.25");At.register("E","1.2.840.113549.1.9.1");At.register("G","2.5.4.42");At.register("I","2.5.4.43");At.register("SN","2.5.4.4");At.register("T","2.5.4.12");function nw(r,e){return`\\${ne.ToHex(ne.FromUtf8String(e)).toUpperCase()}`}function sw(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,nw)}class Qr{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 Xy,this.asn=new rt;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 rt?this.asn=e:L.isBufferSource(e)?this.asn=W.parse(e,rt):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||At.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)||At.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,s=t.value.anyValue?`#${ne.ToHex(t.value.anyValue)}`:sw(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?`#${ne.ToHex(i.value.anyValue)}`:i.value.toString())}t.push(s)}return t}fromString(e){const t=new rt,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 bs([f])),i=u}return t}fromJSON(e){const t=new rt;for(const n of e){const s=new bs;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 Tc({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=ne.FromHex(t.slice(1));else{const s=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=s:Qr.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 W.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]||pt.get()):n=e[0]||pt.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const Qy="Cannot initialize GeneralName from ASN.1 data.",tp=`${Qy} Unsupported string format in use.`,iw=`${Qy} Value doesn't match to GUID regular expression.`,rp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,np="1.3.6.1.4.1.311.25.1",sp="1.3.6.1.4.1.311.20.2.3",vu="dns",bu="dn",xu="email",_u="ip",wu="url",ku="guid",Su="upn",Wa="id";class Jr extends mn{constructor(...e){let t;if(e.length===2)switch(e[0]){case bu:{const n=new Qr(e[1]).toArrayBuffer(),s=W.parse(n,rt);t=new ge({directoryName:s});break}case vu:t=new ge({dNSName:e[1]});break;case xu:t=new ge({rfc822Name:e[1]});break;case ku:{const n=new RegExp(rp,"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?ne.ToHex(new Uint8Array(ne.FromHex(i)).reverse()):i).join("");t=new ge({otherName:new Gi({typeId:np,value:W.serialize(new Re(ne.FromHex(s)))})});break}case _u:t=new ge({iPAddress:e[1]});break;case Wa:t=new ge({registeredID:e[1]});break;case Su:{t=new ge({otherName:new Gi({typeId:sp,value:W.serialize(my.toASN(e[1]))})});break}case wu: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=W.parse(e[0],ge):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=vu,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=xu,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=_u,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=wu,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Wa,this.value=e.registeredID;else if(e.directoryName!=null)this.type=bu,this.value=new Qr(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===np){this.type=ku;const t=W.parse(e.otherName.value,Re),n=new RegExp(rp,"i").exec(ne.ToHex(t));if(!n)throw new Error(iw);this.value=n.slice(1).map((s,i)=>i<3?ne.ToHex(new Uint8Array(ne.FromHex(s)).reverse()):s).join("-")}else if(e.otherName.typeId===sp)this.type=Su,this.value=W.parse(e.otherName.value,ut).toString();else throw new Error(tp);else throw new Error(tp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case bu:case vu:case ku:case _u:case Wa:case Su:case wu:e=this.type.toUpperCase();break;case xu:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===Wa&&(t=pn.toString(t)),new $e(e,void 0,t)}}class na extends mn{constructor(e){let t;if(e instanceof mt)t=e;else if(Array.isArray(e)){const n=[];for(const s of e)if(s instanceof ge)n.push(s);else{const i=W.parse(new Jr(s.type,s.value).rawData,ge);n.push(i)}t=new mt(n)}else if(L.isBufferSource(e))t=W.parse(e,mt);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 Jr(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[$e.NAME]];Array.isArray(s)||(s=[],e[n[$e.NAME]]=s),s.push(n)}return e}}na.NAME="GeneralNames";const gi="-{5}",sa="\\n",aw=`[^${sa}]+`,ow=`${gi}BEGIN (${aw}(?=${gi}))${gi}`,cw=`${gi}END \\1${gi}`,js="\\n",uw=`[^:${sa}]+`,lw=`(?:[^${sa}]+${js}(?: +[^${sa}]+${js})*)`,dw="[a-zA-Z0-9=+/]+",fw=`(?:${dw}${js})+`,ip=`${ow}${js}(?:((?:${uw}: ${lw})+))?${js}?(${fw})${cw}`;class jt{static isPem(e){return typeof e=="string"&&new RegExp(ip,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(ip,"g"),n=[];let s=null;for(;s=t.exec(e);){const i=s[3].replace(new RegExp(`[${sa}]+`,"g"),""),a={type:s[1],headers:[],rawData:ne.FromBase64(i)},o=s[2];if(o){const c=o.split(new RegExp(js,"g"));let u=null;for(const f of c){const[m,D]=f.split(/:(.*)/);if(D===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:D.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(`
113
+ */const Qa="crypto.algorithm";class Sw{getAlgorithms(){return xt.resolveAll(Qa)}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 Ls="crypto.algorithmProvider";xt.registerSingleton(Ls,Sw);var yo;const jt="1.3.36.3.3.2.8.1.1",Lh=`${jt}.1`,qh=`${jt}.2`,Hh=`${jt}.3`,Fh=`${jt}.4`,Wh=`${jt}.5`,zh=`${jt}.6`,Kh=`${jt}.7`,Gh=`${jt}.8`,Jh=`${jt}.9`,Yh=`${jt}.10`,Xh=`${jt}.11`,Qh=`${jt}.12`,ep=`${jt}.13`,tp=`${jt}.14`,rp="brainpoolP160r1",np="brainpoolP160t1",sp="brainpoolP192r1",ip="brainpoolP192t1",ap="brainpoolP224r1",op="brainpoolP224t1",cp="brainpoolP256r1",up="brainpoolP256t1",lp="brainpoolP320r1",dp="brainpoolP320t1",fp="brainpoolP384r1",hp="brainpoolP384t1",pp="brainpoolP512r1",mp="brainpoolP512t1",Ke="ECDSA";let pa=yo=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case Ke.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return K_;case"sha-256":return G_;case"sha-384":return J_;case"sha-512":return Y_}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=bh;break;case"K-256":t=yo.SECP256K1;break;case"P-384":t=xh;break;case"P-521":t=_h;break;case rp:t=Lh;break;case np:t=qh;break;case sp:t=Hh;break;case ip:t=Fh;break;case ap:t=Wh;break;case op:t=zh;break;case cp:t=Kh;break;case up:t=Gh;break;case lp:t=Jh;break;case dp:t=Yh;break;case fp:t=Xh;break;case hp:t=Qh;break;case pp:t=ep;break;case mp:t=tp;break}if(t)return new Y({algorithm:da,parameters:W.serialize(new gn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case yf:return{name:Ke,hash:{name:"SHA-1"}};case gf:return{name:Ke,hash:{name:"SHA-256"}};case vf:return{name:Ke,hash:{name:"SHA-384"}};case bf:return{name:Ke,hash:{name:"SHA-512"}};case da:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(W.parse(e.parameters,gn).namedCurve){case bh:return{name:Ke,namedCurve:"P-256"};case yo.SECP256K1:return{name:Ke,namedCurve:"K-256"};case xh:return{name:Ke,namedCurve:"P-384"};case _h:return{name:Ke,namedCurve:"P-521"};case Lh:return{name:Ke,namedCurve:rp};case qh:return{name:Ke,namedCurve:np};case Hh:return{name:Ke,namedCurve:sp};case Fh:return{name:Ke,namedCurve:ip};case Wh:return{name:Ke,namedCurve:ap};case zh:return{name:Ke,namedCurve:op};case Kh:return{name:Ke,namedCurve:cp};case Gh:return{name:Ke,namedCurve:up};case Jh:return{name:Ke,namedCurve:lp};case Yh:return{name:Ke,namedCurve:dp};case Xh:return{name:Ke,namedCurve:fp};case Qh:return{name:Ke,namedCurve:hp};case ep:return{name:Ke,namedCurve:pp};case tp:return{name:Ke,namedCurve:mp}}}}return null}};pa.SECP256K1="1.3.132.0.10";pa=yo=l([lu()],pa);xt.registerSingleton(Qa,pa);const xg=Symbol("name"),_g=Symbol("value");class Ze{constructor(e,t={},n=""){this[xg]=e,this[_g]=n;for(const s in t)this[s]=t[s]}}Ze.NAME=xg;Ze.VALUE=_g;class Aw{static toTextObject(e){const t=new Ze("Algorithm Identifier",{},kn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case da:{const n=new pa().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class kn{static toString(e){const t=this.items[e];return t||e}}kn.items={[cc]:"sha1",[og]:"sha224",[uc]:"sha256",[lc]:"sha384",[dc]:"sha512",[Wn]:"rsaEncryption",[ic]:"sha1WithRSAEncryption",[nw]:"sha224WithRSAEncryption",[td]:"sha256WithRSAEncryption",[ac]:"sha384WithRSAEncryption",[oc]:"sha512WithRSAEncryption",[da]:"ecPublicKey",[yf]:"ecdsaWithSHA1",[sg]:"ecdsaWithSHA224",[gf]:"ecdsaWithSHA256",[vf]:"ecdsaWithSHA384",[bf]:"ecdsaWithSHA512",[U_]:"TLS WWW server authentication",[L_]:"TLS WWW client authentication",[q_]:"Code Signing",[H_]:"E-mail Protection",[F_]:"Time Stamping",[W_]:"OCSP Signing",[z_]:"Signed Data"};class Gn{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)}}Gn.oidSerializer=kn;Gn.algorithmSerializer=Aw;class Sn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=W.serialize(t),this.onInit(t)}else{const t=W.parse(e[0],e[1]);this.rawData=L.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Sn?Vm(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return W.toString(this.rawData);case"text":return Gn.serialize(this.toTextObject());case"hex":return ne.ToHex(this.rawData);case"base64":return ne.ToBase64(this.rawData);case"base64url":return ne.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)}}Sn.NAME="ASN";class Ft extends Sn{constructor(...e){let t;L.isBufferSource(e[0])?t=L.toArrayBuffer(e[0]):t=W.serialize(new ar({extnID:e[0],critical:e[1],extnValue:new Pe(L.toArrayBuffer(e[2]))})),super(t,ar)}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]===Ft.NAME&&(e[Ze.NAME]=kn.toString(this.type)),e}}var wg;class sn{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[wg]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(sn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(sn.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=sn.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(sn.DEFAULT,e);return this}}wg=Symbol.toStringTag;sn.DEFAULT="default";const yt=new sn,Ow=/^[0-2](?:\.[1-9][0-9]*)+$/;function Ew(r){return new RegExp(Ow).test(r)}class kg{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return Ew(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const Ct=new kg;Ct.register("CN","2.5.4.3");Ct.register("L","2.5.4.7");Ct.register("ST","2.5.4.8");Ct.register("O","2.5.4.10");Ct.register("OU","2.5.4.11");Ct.register("C","2.5.4.6");Ct.register("DC","0.9.2342.19200300.100.1.25");Ct.register("E","1.2.840.113549.1.9.1");Ct.register("G","2.5.4.42");Ct.register("I","2.5.4.43");Ct.register("SN","2.5.4.4");Ct.register("T","2.5.4.12");function Cw(r,e){return`\\${ne.ToHex(ne.FromUtf8String(e)).toUpperCase()}`}function Iw(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Cw)}class un{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 kg,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=W.parse(e,it):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||Ct.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)||Ct.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,s=t.value.anyValue?`#${ne.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?`#${ne.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 Ns([f])),i=u}return t}fromJSON(e){const t=new it;for(const n of e){const s=new Ns;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 qc({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=ne.FromHex(t.slice(1));else{const s=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=s:un.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 W.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]||yt.get()):n=e[0]||yt.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const Sg="Cannot initialize GeneralName from ASN.1 data.",yp=`${Sg} Unsupported string format in use.`,jw=`${Sg} Value doesn't match to GUID regular expression.`,gp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,vp="1.3.6.1.4.1.311.25.1",bp="1.3.6.1.4.1.311.20.2.3",Tu="dns",Nu="dn",Bu="email",Ru="ip",Pu="url",$u="guid",Zu="upn",so="id";class an extends Sn{constructor(...e){let t;if(e.length===2)switch(e[0]){case Nu:{const n=new un(e[1]).toArrayBuffer(),s=W.parse(n,it);t=new ge({directoryName:s});break}case Tu:t=new ge({dNSName:e[1]});break;case Bu:t=new ge({rfc822Name:e[1]});break;case $u:{const n=new RegExp(gp,"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?ne.ToHex(new Uint8Array(ne.FromHex(i)).reverse()):i).join("");t=new ge({otherName:new oa({typeId:vp,value:W.serialize(new Pe(ne.FromHex(s)))})});break}case Ru:t=new ge({iPAddress:e[1]});break;case so:t=new ge({registeredID:e[1]});break;case Zu:{t=new ge({otherName:new oa({typeId:bp,value:W.serialize(Vy.toASN(e[1]))})});break}case Pu: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=W.parse(e[0],ge):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=Tu,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Bu,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Ru,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Pu,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=so,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Nu,this.value=new un(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===vp){this.type=$u;const t=W.parse(e.otherName.value,Pe),n=new RegExp(gp,"i").exec(ne.ToHex(t));if(!n)throw new Error(jw);this.value=n.slice(1).map((s,i)=>i<3?ne.ToHex(new Uint8Array(ne.FromHex(s)).reverse()):s).join("-")}else if(e.otherName.typeId===bp)this.type=Zu,this.value=W.parse(e.otherName.value,dt).toString();else throw new Error(yp);else throw new Error(yp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Nu:case Tu:case $u:case Ru:case so:case Zu:case Pu:e=this.type.toUpperCase();break;case Bu:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===so&&(t=kn.toString(t)),new Ze(e,void 0,t)}}class ma extends Sn{constructor(e){let t;if(e instanceof gt)t=e;else if(Array.isArray(e)){const n=[];for(const s of e)if(s instanceof ge)n.push(s);else{const i=W.parse(new an(s.type,s.value).rawData,ge);n.push(i)}t=new gt(n)}else if(L.isBufferSource(e))t=W.parse(e,gt);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 an(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}}ma.NAME="GeneralNames";const Ii="-{5}",ya="\\n",Tw=`[^${ya}]+`,Nw=`${Ii}BEGIN (${Tw}(?=${Ii}))${Ii}`,Bw=`${Ii}END \\1${Ii}`,qs="\\n",Rw=`[^:${ya}]+`,Pw=`(?:[^${ya}]+${qs}(?: +[^${ya}]+${qs})*)`,$w="[a-zA-Z0-9=+/]+",Zw=`(?:${$w}${qs})+`,xp=`${Nw}${qs}(?:((?:${Rw}: ${Pw})+))?${qs}?(${Zw})${Bw}`;class Bt{static isPem(e){return typeof e=="string"&&new RegExp(xp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(xp,"g"),n=[];let s=null;for(;s=t.exec(e);){const i=s[3].replace(new RegExp(`[${ya}]+`,"g"),""),a={type:s[1],headers:[],rawData:ne.FromBase64(i)},o=s[2];if(o){const c=o.split(new RegExp(qs,"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
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=ne.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
- `)}}jt.CertificateTag="CERTIFICATE";jt.CrlTag="CRL";jt.CertificateRequestTag="CERTIFICATE REQUEST";jt.PublicKeyTag="PUBLIC KEY";jt.PrivateKeyTag="PRIVATE KEY";class Mr extends mn{static isAsnEncoded(e){return L.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(jt.isPem(e))return jt.decode(e)[0];if(ne.isHex(e))return ne.FromHex(e);if(ne.isBase64(e))return ne.FromBase64(e);if(ne.isBase64Url(e))return ne.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=ne.ToBinary(e);return jt.isPem(t)?jt.decode(t)[0]:ne.isHex(t)?ne.FromHex(t):ne.isBase64(t)?ne.FromBase64(t):ne.isBase64Url(t)?ne.FromBase64Url(t):L.toArrayBuffer(e)}}constructor(...e){Mr.isAsnEncoded(e[0])?super(Mr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return jt.encode(this.rawData,this.tag);default:return super.toString(e)}}}class hr extends Mr{static async create(e,t=pt.get()){if(e instanceof hr)return e;if(Gr.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new hr(n)}else{if(e.publicKey)return e.publicKey;if(L.isBufferSource(e))return new hr(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Mr.isAsnEncoded(e)?super(e,ur):super(e),this.tag=jt.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]||pt.get()):t=e[0]||pt.get();let i=this.rawData;const a=W.parse(this.rawData,ur);return a.algorithm.algorithm===yi&&(i=hw(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=vt.resolve(Cs),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Pn:{const s=W.parse(e.subjectPublicKey,sf),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]||pt.get()):n=e[0]||pt.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=pt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=pt.get();const s=W.parse(this.rawData,ur);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=W.parse(this.rawData,ur);switch(e.Algorithm=Dn.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case Qi:e["EC Point"]=t.subjectPublicKey;break;case Pn:default:e["Raw Data"]=t.subjectPublicKey}return e}}function hw(r,e){return r.algorithm=new X({algorithm:Pn,parameters:null}),e=W.serialize(r),e}class ia extends Ut{static async create(e,t=!1,n=pt.get()){if("name"in e&&"serialNumber"in e)return new ia(e,t);const i=await(await hr.create(e,n)).getKeyIdentifier(n);return new ia(ne.ToHex(i),t)}constructor(...e){if(L.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new bn({keyIdentifier:new Md(ne.FromHex(e[0]))});super(il,e[1],W.serialize(t))}else{const t=e[0],n=t.name instanceof na?W.parse(t.name.rawData,mt):t.name,s=new bn({authorityCertIssuer:n,authorityCertSerialNumber:ne.FromHex(t.serialNumber)});super(il,e[1],W.serialize(s))}}onInit(e){super.onInit(e);const t=W.parse(e.extnValue,bn);t.keyIdentifier&&(this.keyId=ne.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?ne.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=W.parse(this.value,bn);return t.authorityCertIssuer&&(e["Authority Issuer"]=new na(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}ia.NAME="Authority Key Identifier";class eg extends Ut{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=W.parse(this.value,Co);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new Co({cA:e[0],pathLenConstraint:e[1]});super(vy,e[2],W.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}}eg.NAME="Basic Constraints";var ap;(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"})(ap||(ap={}));class tg extends Ut{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=W.parse(this.value,Bo);this.usages=t.map(n=>n)}else{const t=new Bo(e[0]);super(_y,e[1],W.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>pn.toString(t)).join(", "),e}}tg.NAME="Extended Key Usages";var op;(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"})(op||(op={}));class rg extends Ut{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=W.parse(this.value,gu);this.usages=t.toNumber()}else{const t=new gu(e[0]);super(wy,e[1],W.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=W.parse(this.value,gu);return e[""]=t.toJSON().join(", "),e}}rg.NAME="Key Usages";class nu extends Ut{static async create(e,t=!1,n=pt.get()){const i=await(await hr.create(e,n)).getKeyIdentifier(n);return new nu(ne.ToHex(i),t)}constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=W.parse(this.value,Xr);this.keyId=ne.ToHex(t)}else{const t=typeof e[0]=="string"?ne.FromHex(e[0]):e[0],n=new Xr(t);super(Oy,e[1],W.serialize(n)),this.keyId=ne.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=W.parse(this.value,Xr);return e[""]=t,e}}nu.NAME="Subject Key Identifier";class ng extends Ut{constructor(...e){L.isBufferSource(e[0])?super(e[0]):super(Ay,e[1],new na(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=W.parse(e.extnValue,xl);this.names=new na(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}ng.NAME="Subject Alternative Name";class Lt{static register(e,t){this.items.set(e,t)}static create(e){const t=new Ut(e),n=this.items.get(t.type);return n?new n(e):t}}Lt.items=new Map;class sg extends Ut{constructor(...e){var t;if(L.isBufferSource(e[0])){super(e[0]);const n=W.parse(this.value,To);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new To(n.map(a=>new Bc({policyIdentifier:a})));super(by,s,W.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new $e("",{},pn.toString(t))),e}}sg.NAME="Certificate Policies";Lt.register(by,sg);class ig extends Ut{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 Zs({distributionPoint:new Nn({fullName:[new ge({uniformResourceIdentifier:a})]})})),i=new is(s);super(ll,e[1],W.serialize(i))}else{const n=new is(e[0]);super(ll,e[1],W.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=W.parse(e.extnValue,is);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 Jr(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}ig.NAME="CRL Distribution Points";class ag extends Ut{constructor(...e){var t,n,s,i;if(L.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof es){const a=new es(e[0]);super(sl,e[1],W.serialize(a))}else{const a=e[0],o=new es;Ka(o,a,qf,"ocsp"),Ka(o,a,Hf,"caIssuers"),Ka(o,a,Ff,"timeStamping"),Ka(o,a,Wf,"caRepository"),super(sl,e[1],W.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=[],W.parse(e.extnValue,es).forEach(n=>{switch(n.accessMethod){case qf:this.ocsp.push(new Jr(n.accessLocation));break;case Hf:this.caIssuers.push(new Jr(n.accessLocation));break;case Ff:this.timeStamping.push(new Jr(n.accessLocation));break;case Wf:this.caRepository.push(new Jr(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&za(e,"OCSP",this.ocsp),this.caIssuers.length&&za(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&za(e,"Time Stamping",this.timeStamping),this.caRepository.length&&za(e,"CA Repository",this.caRepository),e}}ag.NAME="Authority Info Access";function za(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new $e("");t.forEach((s,i)=>{const a=s.toTextObject(),o=`${a[$e.NAME]} ${i+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function Ka(r,e,t,n){const s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new Jr("url",a)),r.push(new ja({accessMethod:t,accessLocation:W.parse(a.rawData,ge)}))})}class Hs extends mn{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=W.serialize(new $r({type:n,values:s}))}super(t,$r)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new $e("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[$e.NAME]===Hs.NAME&&(e[$e.NAME]=pn.toString(this.type)),e}}Hs.NAME="Attribute";class og extends Hs{constructor(...e){var t;if(L.isBufferSource(e[0]))super(e[0]);else{const n=new nc({printableString:e[0]});super(Ky,[W.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=W.parse(this.values[0],nc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[$e.VALUE]=this.password,e}}og.NAME="Challenge Password";class uf extends Hs{constructor(...e){var t;if(L.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new Bn;for(const i of n)s.push(W.parse(i.rawData,rr));super(cf,[W.serialize(s)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=W.parse(this.values[0],Bn);this.items=t.map(n=>Lt.create(W.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[$e.NAME]]=n;return e}}uf.NAME="Extensions";class su{static register(e,t){this.items.set(e,t)}static create(e){const t=new Hs(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 no;let ld=no=class{static createPssParams(e,t){const n=no.getHashAlgorithm(e);return n?new Zn({hashAlgorithm:n,maskGenAlgorithm:new X({algorithm:Kc,parameters:W.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=vt.resolve(Cs);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 X({algorithm:zo,parameters:null});case"sha-256":return new X({algorithm:Ul,parameters:null});case"sha-384":return new X({algorithm:Ko,parameters:null});case"sha-512":return new X({algorithm:Go,parameters:null})}}else return new X({algorithm:Pn,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=no.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new X({algorithm:yi,parameters:W.serialize(t)})}else return new X({algorithm:yi,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Pn:return{name:"RSASSA-PKCS1-v1_5"};case zo:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Ul:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ko:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Go:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case yi:if(e.parameters){const t=W.parse(e.parameters,Zn);return{name:"RSA-PSS",hash:vt.resolve(Cs).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};ld=no=l([Xc()],ld);vt.registerSingleton(Ua,ld);let dd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new X({algorithm:Jo});case"sha-256":return new X({algorithm:Yo});case"sha-384":return new X({algorithm:Xo});case"sha-512":return new X({algorithm:Qo})}return null}toWebAlgorithm(e){switch(e.algorithm){case Jo:return{name:"SHA-1"};case Yo:return{name:"SHA-256"};case Xo:return{name:"SHA-384"};case Qo:return{name:"SHA-512"}}return null}};dd=l([Xc()],dd);vt.registerSingleton(Ua,dd);class Zt{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=Zt.namedCurveSize.get(n)||Zt.defaultNamedCurveSize,i=new Wo,a=L.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),W.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=W.parse(t,Wo),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 Ex(a,o)}return null}}Zt.namedCurveSize=new Map;Zt.defaultNamedCurveSize=32;const Au="1.3.101.110",cp="1.3.101.111",Ou="1.3.101.112",up="1.3.101.113";let fd=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=Ou;break;case"x25519":t=Au;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=Ou;break;case"ed448":t=up;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=Au;break;case"x448":t=cp;break}}return t?new X({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case Ou:return{name:"Ed25519"};case up:return{name:"EdDSA",namedCurve:"Ed448"};case Au:return{name:"X25519"};case cp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};fd=l([Xc()],fd);vt.registerSingleton(Ua,fd);class mw extends Mr{constructor(e){Mr.isAsnEncoded(e)?super(e,ta):super(e),this.tag=jt.CertificateRequestTag}onInit(e){this.tbs=W.serialize(e.certificationRequestInfo),this.publicKey=new hr(e.certificationRequestInfo.subjectPKInfo);const t=vt.resolve(Cs);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>su.create(W.serialize(s)));const n=this.getAttribute(cf);this.extensions=[],n instanceof uf&&(this.extensions=n.items),this.subjectName=new Qr(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=pt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),s=vt.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=W.parse(this.rawData,ta),n=t.certificationRequestInfo,s=new $e("",{Version:`${xs[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new $e("");for(const a of this.attributes){const o=a.toTextObject();i[o[$e.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new $e("",{Algorithm:Dn.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}mw.NAME="PKCS#10 Certificate Request";class cg extends Mr{constructor(e){Mr.isAsnEncoded(e)?super(e,_s):super(e),this.tag=jt.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=W.serialize(t),this.serialNumber=ne.ToHex(t.serialNumber),this.subjectName=new Qr(t.subject),this.subject=new Qr(t.subject).toString(),this.issuerName=new Qr(t.issuer),this.issuer=this.issuerName.toString();const n=vt.resolve(Cs);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=>Lt.create(W.serialize(a)))),this.publicKey=new hr(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=pt.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 hr)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(L.isBufferSource(i)){const u=new hr(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=vt.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=pt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=pt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=W.parse(this.rawData,_s),n=t.tbsCertificate,s=new $e("",{Version:`${xs[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Dn.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new $e("",{"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 $e("");for(const a of this.extensions){const o=a.toTextObject();i[o[$e.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new $e("",{Algorithm:Dn.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}cg.NAME="Certificate";var lp;(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"})(lp||(lp={}));Lt.register(vy,eg);Lt.register(_y,tg);Lt.register(wy,rg);Lt.register(Oy,nu);Lt.register(il,ia);Lt.register(Ay,ng);Lt.register(ll,ig);Lt.register(sl,ag);su.register(Ky,og);su.register(cf,uf);vt.registerSingleton(iu,pw);vt.registerSingleton(iu,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 Ga=60*5;function yw(r){return new Bt().openapi(Ee({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:ux}},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 cg(i.cert).publicKey.export(),c=await crypto.subtle.exportKey("jwk",o);return hm.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=${Ga}, stale-while-revalidate=${Ga*2}, stale-if-error=86400`}})}).openapi(Ee({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Rf}},description:"List of tenants"}}}),async t=>{const{issuer:n}=r,s=Rf.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=${Ga}, stale-while-revalidate=${Ga*2}, stale-if-error=86400`}})})}async function ug(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 lg(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=lg(r,{type:wd.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(Ee({tags:["branding"],method:"get",path:"/",request:{headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Bf}},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(Ee({tags:["branding"],method:"patch",path:"/",request:{headers:_.object({"tenant-id":_.string()}),body:{content:{"application/json":{schema:_.object(Bf.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 dg={exports:{}};const Aw={},Ow=Object.freeze(Object.defineProperty({__proto__:null,default:Aw},Symbol.toStringTag,{value:"Module"})),Ew=wx(Ow);(function(r){/**
117
+ `)}}Bt.CertificateTag="CERTIFICATE";Bt.CrlTag="CRL";Bt.CertificateRequestTag="CERTIFICATE REQUEST";Bt.PublicKeyTag="PUBLIC KEY";Bt.PrivateKeyTag="PRIVATE KEY";class Fr extends Sn{static isAsnEncoded(e){return L.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Bt.isPem(e))return Bt.decode(e)[0];if(ne.isHex(e))return ne.FromHex(e);if(ne.isBase64(e))return ne.FromBase64(e);if(ne.isBase64Url(e))return ne.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=ne.ToBinary(e);return Bt.isPem(t)?Bt.decode(t)[0]:ne.isHex(t)?ne.FromHex(t):ne.isBase64(t)?ne.FromBase64(t):ne.isBase64Url(t)?ne.FromBase64Url(t):L.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 Bt.encode(this.rawData,this.tag);default:return super.toString(e)}}}class gr extends Fr{static async create(e,t=yt.get()){if(e instanceof gr)return e;if(sn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new gr(n)}else{if(e.publicKey)return e.publicKey;if(L.isBufferSource(e))return new gr(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Fr.isAsnEncoded(e)?super(e,hr):super(e),this.tag=Bt.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]||yt.get()):t=e[0]||yt.get();let i=this.rawData;const a=W.parse(this.rawData,hr);return a.algorithm.algorithm===Ci&&(i=Dw(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=xt.resolve(Ls),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Wn:{const s=W.parse(e.subjectPublicKey,xf),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]||yt.get()):n=e[0]||yt.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=yt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=yt.get();const s=W.parse(this.rawData,hr);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=W.parse(this.rawData,hr);switch(e.Algorithm=Gn.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case da:e["EC Point"]=t.subjectPublicKey;break;case Wn:default:e["Raw Data"]=t.subjectPublicKey}return e}}function Dw(r,e){return r.algorithm=new Y({algorithm:Wn,parameters:null}),e=W.serialize(r),e}class ga extends Ft{static async create(e,t=!1,n=yt.get()){if("name"in e&&"serialNumber"in e)return new ga(e,t);const i=await(await gr.create(e,n)).getKeyIdentifier(n);return new ga(ne.ToHex(i),t)}constructor(...e){if(L.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new jn({keyIdentifier:new ef(ne.FromHex(e[0]))});super(bl,e[1],W.serialize(t))}else{const t=e[0],n=t.name instanceof ma?W.parse(t.name.rawData,gt):t.name,s=new jn({authorityCertIssuer:n,authorityCertSerialNumber:ne.FromHex(t.serialNumber)});super(bl,e[1],W.serialize(s))}}onInit(e){super.onInit(e);const t=W.parse(e.extnValue,jn);t.keyIdentifier&&(this.keyId=ne.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?ne.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=W.parse(this.value,jn);return t.authorityCertIssuer&&(e["Authority Issuer"]=new ma(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}ga.NAME="Authority Key Identifier";class Ag extends Ft{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=W.parse(this.value,Uo);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new Uo({cA:e[0],pathLenConstraint:e[1]});super(qy,e[2],W.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}}Ag.NAME="Basic Constraints";var _p;(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"})(_p||(_p={}));class Og extends Ft{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=W.parse(this.value,Fo);this.usages=t.map(n=>n)}else{const t=new Fo(e[0]);super(Wy,e[1],W.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>kn.toString(t)).join(", "),e}}Og.NAME="Extended Key Usages";var wp;(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"})(wp||(wp={}));class Eg extends Ft{constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=W.parse(this.value,ju);this.usages=t.toNumber()}else{const t=new ju(e[0]);super(zy,e[1],W.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=W.parse(this.value,ju);return e[""]=t.toJSON().join(", "),e}}Eg.NAME="Key Usages";class mu extends Ft{static async create(e,t=!1,n=yt.get()){const i=await(await gr.create(e,n)).getKeyIdentifier(n);return new mu(ne.ToHex(i),t)}constructor(...e){if(L.isBufferSource(e[0])){super(e[0]);const t=W.parse(this.value,cn);this.keyId=ne.ToHex(t)}else{const t=typeof e[0]=="string"?ne.FromHex(e[0]):e[0],n=new cn(t);super(Yy,e[1],W.serialize(n)),this.keyId=ne.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=W.parse(this.value,cn);return e[""]=t,e}}mu.NAME="Subject Key Identifier";class Cg extends Ft{constructor(...e){L.isBufferSource(e[0])?super(e[0]):super(Jy,e[1],new ma(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=W.parse(e.extnValue,Rl);this.names=new ma(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}Cg.NAME="Subject Alternative Name";class Wt{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}}Wt.items=new Map;class Ig extends Ft{constructor(...e){var t;if(L.isBufferSource(e[0])){super(e[0]);const n=W.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 Fc({policyIdentifier:a})));super(Hy,s,W.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Ze("",{},kn.toString(t))),e}}Ig.NAME="Certificate Policies";Wt.register(Hy,Ig);class jg extends Ft{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 Js({distributionPoint:new qn({fullName:[new ge({uniformResourceIdentifier:a})]})})),i=new vs(s);super(Sl,e[1],W.serialize(i))}else{const n=new vs(e[0]);super(Sl,e[1],W.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=W.parse(e.extnValue,vs);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 an(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}jg.NAME="CRL Distribution Points";class Tg extends Ft{constructor(...e){var t,n,s,i;if(L.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof hs){const a=new hs(e[0]);super(vl,e[1],W.serialize(a))}else{const a=e[0],o=new hs;ao(o,a,sh,"ocsp"),ao(o,a,ih,"caIssuers"),ao(o,a,ah,"timeStamping"),ao(o,a,oh,"caRepository"),super(vl,e[1],W.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=[],W.parse(e.extnValue,hs).forEach(n=>{switch(n.accessMethod){case sh:this.ocsp.push(new an(n.accessLocation));break;case ih:this.caIssuers.push(new an(n.accessLocation));break;case ah:this.timeStamping.push(new an(n.accessLocation));break;case oh:this.caRepository.push(new an(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&io(e,"OCSP",this.ocsp),this.caIssuers.length&&io(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&io(e,"Time Stamping",this.timeStamping),this.caRepository.length&&io(e,"CA Repository",this.caRepository),e}}Tg.NAME="Authority Info Access";function io(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 ao(r,e,t,n){const s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new an("url",a)),r.push(new La({accessMethod:t,accessLocation:W.parse(a.rawData,ge)}))})}class ni extends Sn{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=W.serialize(new Lr({type:n,values:s}))}super(t,Lr)}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]===ni.NAME&&(e[Ze.NAME]=kn.toString(this.type)),e}}ni.NAME="Attribute";class Ng extends ni{constructor(...e){var t;if(L.isBufferSource(e[0]))super(e[0]);else{const n=new mc({printableString:e[0]});super(bg,[W.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=W.parse(this.values[0],mc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Ze.VALUE]=this.password,e}}Ng.NAME="Challenge Password";class Sf extends ni{constructor(...e){var t;if(L.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new Hn;for(const i of n)s.push(W.parse(i.rawData,ar));super(kf,[W.serialize(s)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=W.parse(this.values[0],Hn);this.items=t.map(n=>Wt.create(W.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 yu{static register(e,t){this.items.set(e,t)}static create(e){const t=new ni(e),n=this.items.get(t.type);return n?new n(e):t}}yu.items=new Map;const gu="crypto.signatureFormatter";class Mw{toAsnSignature(e,t){return L.toArrayBuffer(t)}toWebSignature(e,t){return L.toArrayBuffer(t)}}var go;let Sd=go=class{static createPssParams(e,t){const n=go.getHashAlgorithm(e);return n?new Kn({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:au,parameters:W.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=xt.resolve(Ls);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:ic,parameters:null});case"sha-256":return new Y({algorithm:td,parameters:null});case"sha-384":return new Y({algorithm:ac,parameters:null});case"sha-512":return new Y({algorithm:oc,parameters:null})}}else return new Y({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=go.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new Y({algorithm:Ci,parameters:W.serialize(t)})}else return new Y({algorithm:Ci,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 td:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case ac:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case oc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Ci:if(e.parameters){const t=W.parse(e.parameters,Kn);return{name:"RSA-PSS",hash:xt.resolve(Ls).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Sd=go=l([lu()],Sd);xt.registerSingleton(Qa,Sd);let Ad=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:cc});case"sha-256":return new Y({algorithm:uc});case"sha-384":return new Y({algorithm:lc});case"sha-512":return new Y({algorithm:dc})}return null}toWebAlgorithm(e){switch(e.algorithm){case cc:return{name:"SHA-1"};case uc:return{name:"SHA-256"};case lc:return{name:"SHA-384"};case dc:return{name:"SHA-512"}}return null}};Ad=l([lu()],Ad);xt.registerSingleton(Qa,Ad);class Ut{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=Ut.namedCurveSize.get(n)||Ut.defaultNamedCurveSize,i=new sc,a=L.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),W.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=W.parse(t,sc),s=e.namedCurve,i=Ut.namedCurveSize.get(s)||Ut.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return Xx(a,o)}return null}}Ut.namedCurveSize=new Map;Ut.defaultNamedCurveSize=32;const Du="1.3.101.110",kp="1.3.101.111",Mu="1.3.101.112",Sp="1.3.101.113";let Od=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=Mu;break;case"x25519":t=Du;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=Mu;break;case"ed448":t=Sp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=Du;break;case"x448":t=kp;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case Mu:return{name:"Ed25519"};case Sp:return{name:"EdDSA",namedCurve:"Ed448"};case Du:return{name:"X25519"};case kp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Od=l([lu()],Od);xt.registerSingleton(Qa,Od);class Vw extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,ha):super(e),this.tag=Bt.CertificateRequestTag}onInit(e){this.tbs=W.serialize(e.certificationRequestInfo),this.publicKey=new gr(e.certificationRequestInfo.subjectPKInfo);const t=xt.resolve(Ls);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>yu.create(W.serialize(s)));const n=this.getAttribute(kf);this.extensions=[],n instanceof Sf&&(this.extensions=n.items),this.subjectName=new un(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=yt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),s=xt.resolveAll(gu).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=W.parse(this.rawData,ha),n=t.certificationRequestInfo,s=new Ze("",{Version:`${Bs[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:Gn.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}Vw.NAME="PKCS#10 Certificate Request";class Bg extends Fr{constructor(e){Fr.isAsnEncoded(e)?super(e,Rs):super(e),this.tag=Bt.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=W.serialize(t),this.serialNumber=ne.ToHex(t.serialNumber),this.subjectName=new un(t.subject),this.subject=new un(t.subject).toString(),this.issuerName=new un(t.issuer),this.issuer=this.issuerName.toString();const n=xt.resolve(Ls);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=>Wt.create(W.serialize(a)))),this.publicKey=new gr(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=yt.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 gr)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(L.isBufferSource(i)){const u=new gr(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=xt.resolveAll(gu).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=yt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=yt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=W.parse(this.rawData,Rs),n=t.tbsCertificate,s=new Ze("",{Version:`${Bs[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Gn.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:Gn.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}Bg.NAME="Certificate";var Ap;(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"})(Ap||(Ap={}));Wt.register(qy,Ag);Wt.register(Wy,Og);Wt.register(zy,Eg);Wt.register(Yy,mu);Wt.register(bl,ga);Wt.register(Jy,Cg);Wt.register(Sl,jg);Wt.register(vl,Tg);yu.register(bg,Ng);yu.register(kf,Sf);xt.registerSingleton(gu,Mw);xt.registerSingleton(gu,Ut);Ut.namedCurveSize.set("P-256",32);Ut.namedCurveSize.set("K-256",32);Ut.namedCurveSize.set("P-384",48);Ut.namedCurveSize.set("P-521",66);const oo=60*5;function Uw(r){return new $t().openapi(Ce({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Rx}},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 Bg(i.cert).publicKey.export(),c=await crypto.subtle.exportKey("jwk",o);return Zm.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=${oo}, stale-while-revalidate=${oo*2}, stale-if-error=86400`}})}).openapi(Ce({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Gf}},description:"List of tenants"}}}),async t=>{const{issuer:n}=r,s=Gf.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=${oo}, stale-while-revalidate=${oo*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 Lw({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 qw(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await Lw({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 Pg(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 Hw(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=Pg(r,{type:Zd.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,i)}}function Fw(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 Hw(r,s,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function Ww(r,e){return async(t,n)=>{let s=await qw(e)(t,n);return await Fw(r,e)(t,s),s}}function zw(r,e){return{...e,users:{...e.users,create:Ww(r,e)}}}const Kw=new $t().openapi(Ce({tags:["branding"],method:"get",path:"/",request:{headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Kf}},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(Ce({tags:["branding"],method:"patch",path:"/",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object(Kf.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 Gw(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 $g={exports:{}};const Jw={},Yw=Object.freeze(Object.defineProperty({__proto__:null,default:Jw},Symbol.toStringTag,{value:"Module"})),Xw=zx(Yw);(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()})(Ao,function(){var e={},t=null;function n(E){if(r&&r.exports)try{return Ew.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(I){v(I)}})}if(w){if(typeof w!="function")throw Error("Illegal callback: "+typeof w);b(w)}else return new Promise(function(v,I){b(function(M,Ae){if(M){I(M);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 It(E,O)},e.hash=function(E,O,w,b){function v(I){typeof E=="string"&&typeof O=="number"?e.genSalt(O,function(M,Ae){It(E,Ae,I,b)}):typeof E=="string"&&typeof O=="string"?It(E,O,I,b):a(I.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(I,M){v(function(Ae,ie){if(Ae){M(Ae);return}I(ie)})})};function i(E,O){for(var w=0,b=0,v=0,I=E.length;v<I;++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(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(M,Ae){M?I(M):I(null,i(Ae,O))},b)}if(w){if(typeof w!="function")throw Error("Illegal callback: "+typeof w);v(w)}else return new Promise(function(I,M){v(function(Ae,ie){if(Ae){M(Ae);return}I(ie)})})},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,I;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(I=E[w++]&255,v|=I>>4&15,b.push(c[v&63]),v=(I&15)<<2,w>=O){b.push(c[v&63]);break}I=E[w++]&255,v|=I>>6&3,b.push(c[v&63]),b.push(c[I&63])}return b.join("")}function D(E,O){var w=0,b=E.length,v=0,I=[],M,Ae,ie,Ie,Ze,ee;if(O<=0)throw Error("Illegal len: "+O);for(;w<b-1&&v<O&&(ee=E.charCodeAt(w++),M=ee<u.length?u[ee]:-1,ee=E.charCodeAt(w++),Ae=ee<u.length?u[ee]:-1,!(M==-1||Ae==-1||(Ze=M<<2>>>0,Ze|=(Ae&48)>>4,I.push(f(Ze)),++v>=O||w>=b)||(ee=E.charCodeAt(w++),ie=ee<u.length?u[ee]:-1,ie==-1)||(Ze=(Ae&15)<<4>>>0,Ze|=(ie&60)>>2,I.push(f(Ze)),++v>=O||w>=b)));)ee=E.charCodeAt(w++),Ie=ee<u.length?u[ee]:-1,Ze=(ie&3)<<6>>>0,Ze|=Ie,I.push(f(Ze)),++v;var st=[];for(w=0;w<v;w++)st.push(I[w].charCodeAt(0));return st}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,I,M,Ae=function(ie){ie=ie.slice(0,ie.indexOf(null));var Ie=Error(ie.toString());throw Ie.name="TruncatedError",Ie.bytes=ie,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||(I=O())===null)&&Ae([b,v,I]),w((b&15)<<12|(v&63)<<6|I&63);else if((b&248)===240)((v=O())===null||(I=O())===null||(M=O())===null)&&Ae([b,v,I,M]),w((b&7)<<18|(v&63)<<12|(I&63)<<6|M&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,B=[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],ye=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Me(E,O,w,b){var v,I=E[O],M=E[O+1];return I^=w[0],v=b[I>>>24],v+=b[256|I>>16&255],v^=b[512|I>>8&255],v+=b[768|I&255],M^=v^w[1],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],I^=v^w[2],v=b[I>>>24],v+=b[256|I>>16&255],v^=b[512|I>>8&255],v+=b[768|I&255],M^=v^w[3],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],I^=v^w[4],v=b[I>>>24],v+=b[256|I>>16&255],v^=b[512|I>>8&255],v+=b[768|I&255],M^=v^w[5],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],I^=v^w[6],v=b[I>>>24],v+=b[256|I>>16&255],v^=b[512|I>>8&255],v+=b[768|I&255],M^=v^w[7],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],I^=v^w[8],v=b[I>>>24],v+=b[256|I>>16&255],v^=b[512|I>>8&255],v+=b[768|I&255],M^=v^w[9],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],I^=v^w[10],v=b[I>>>24],v+=b[256|I>>16&255],v^=b[512|I>>8&255],v+=b[768|I&255],M^=v^w[11],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],I^=v^w[12],v=b[I>>>24],v+=b[256|I>>16&255],v^=b[512|I>>8&255],v+=b[768|I&255],M^=v^w[13],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],I^=v^w[14],v=b[I>>>24],v+=b[256|I>>16&255],v^=b[512|I>>8&255],v+=b[768|I&255],M^=v^w[15],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],I^=v^w[16],E[O]=M^w[A+1],E[O+1]=I,E}function Ve(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 Pe(E,O,w){for(var b=0,v=[0,0],I=O.length,M=w.length,Ae,ie=0;ie<I;ie++)Ae=Ve(E,b),b=Ae.offp,O[ie]=O[ie]^Ae.key;for(ie=0;ie<I;ie+=2)v=Me(v,0,O,w),O[ie]=v[0],O[ie+1]=v[1];for(ie=0;ie<M;ie+=2)v=Me(v,0,O,w),w[ie]=v[0],w[ie+1]=v[1]}function Xe(E,O,w,b){for(var v=0,I=[0,0],M=w.length,Ae=b.length,ie,Ie=0;Ie<M;Ie++)ie=Ve(O,v),v=ie.offp,w[Ie]=w[Ie]^ie.key;for(v=0,Ie=0;Ie<M;Ie+=2)ie=Ve(E,v),v=ie.offp,I[0]^=ie.key,ie=Ve(E,v),v=ie.offp,I[1]^=ie.key,I=Me(I,0,w,b),w[Ie]=I[0],w[Ie+1]=I[1];for(Ie=0;Ie<Ae;Ie+=2)ie=Ve(E,v),v=ie.offp,I[0]^=ie.key,ie=Ve(E,v),v=ie.offp,I[1]^=ie.key,I=Me(I,0,w,b),b[Ie]=I[0],b[Ie+1]=I[1]}function lt(E,O,w,b,v){var I=ye.slice(),M=I.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 ie,Ie,Ze=0,ee;Int32Array?(ie=new Int32Array(B),Ie=new Int32Array(T)):(ie=B.slice(),Ie=T.slice()),Xe(O,E,ie,Ie);function st(){if(v&&v(Ze/w),Ze<w)for(var Le=Date.now();Ze<w&&(Ze=Ze+1,Pe(E,ie,Ie),Pe(O,ie,Ie),!(Date.now()-Le>S)););else{for(Ze=0;Ze<64;Ze++)for(ee=0;ee<M>>1;ee++)Me(I,ee<<1,ie,Ie);var Qe=[];for(Ze=0;Ze<M;Ze++)Qe.push((I[Ze]>>24&255)>>>0),Qe.push((I[Ze]>>16&255)>>>0),Qe.push((I[Ze]>>8&255)>>>0),Qe.push((I[Ze]&255)>>>0);if(b){b(null,Qe);return}else return Qe}b&&a(st)}if(typeof b<"u")st();else for(var yn;;)if(typeof(yn=st())<"u")return yn||[]}function It(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 I,M;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)==="$")I="\0",M=3;else{if(I=O.charAt(2),I!=="a"&&I!=="b"&&I!=="y"||O.charAt(3)!=="$")if(v=Error("Invalid salt revision: "+O.substring(2,4)),w){a(w.bind(this,v));return}else throw v;M=4}if(O.charAt(M+2)>"$")if(v=Error("Missing salt rounds"),w){a(w.bind(this,v));return}else throw v;var Ae=parseInt(O.substring(M,M+1),10)*10,ie=parseInt(O.substring(M+1,M+2),10),Ie=Ae+ie,Ze=O.substring(M+3,M+25);E+=I>="a"?"\0":"";var ee=o(E),st=D(Ze,p);function yn(Le){var Qe=[];return Qe.push("$2"),I>="a"&&Qe.push(I),Qe.push("$"),Ie<10&&Qe.push("0"),Qe.push(Ie.toString()),Qe.push("$"),Qe.push(m(st,st.length)),Qe.push(m(Le,ye.length*4-1)),Qe.join("")}if(typeof w>"u")return yn(lt(ee,st,Ie));lt(ee,st,Ie,function(Le,Qe){Le?w(Le,null):w(null,yn(Qe))},b)}return e.encodeBase64=m,e.decodeBase64=D,e})})(dg);var Iw=dg.exports;const Cw=_x(Iw),jw="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Tw=r=>crypto.getRandomValues(new Uint8Array(r)),Nw=(r,e,t)=>{let n=(2<<Math.log(r.length-1)/Math.LN2)-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}}},Bw=(r,e=21)=>Nw(r,e,Tw),dp=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=jw[t[r]&63];return e};const Rw=24;function Pw(){return Bw("0123456789abcdef",Rw)()}function fp(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}const Fs=_.object({page:_.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:_.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:_.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:_.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:_.string().optional().openapi({description:"A lucene query string used to filter the results"})});function Ws(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 $w={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},Zw=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[s,i]of Object.entries($w))if(Dw(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"},Dw=r=>navigator.userAgent.startsWith(r);function Mw(r,e){Zw()==="workerd"&&r.executionCtx.waitUntil(e)}const hp=Rs.extend({users:_.array(Ar)}),Vw=new Bt().openapi(Ee({tags:["users"],method:"get",path:"/",request:{query:Fs,headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:_.union([_.array(Ar),hp])}},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],D=(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]=D;if(!j)return r.json([]);const p=await r.env.data.users.get(a,j.linked_to);if(!p)throw new Ue(500,{message:"Primary account not found"});return r.json([Ar.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:Ws(s),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(hp.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(_.array(Ar).parse(u))}).openapi(Ee({tags:["users"],method:"get",path:"/{user_id}",request:{headers:_.object({"tenant-id":_.string()}),params:_.object({user_id:_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ar}},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 Ue(404);if(n.linked_to)throw new Ue(404,{message:"User is linked to another user"});return r.json(n)}).openapi(Ee({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:_.object({"tenant-id":_.string()}),params:_.object({user_id:_.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 Ue(404);return r.text("OK")}).openapi(Ee({tags:["users"],method:"post",path:"/",request:{headers:_.object({"tenant-id":_.string()}),body:{content:{"application/json":{schema:_.object({...Hu.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ar}},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 Ue(400,{message:"Email is required"});const s=n.toLowerCase(),i=`${t.provider}|${t.user_id||Pw()}`;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=lg(r,{type:wd.SUCCESS_API_OPERATION,description:"User created"});Mw(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:fp(a.user_id),isSocial:a.is_social}]};return r.json(Ar.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new Ue(409,{message:"User already exists"}):a}}).openapi(Ee({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:_.object({"tenant-id":_.string()}),body:{content:{"application/json":{schema:_.object({...Hu.shape,verify_email:_.boolean(),password:_.string()}).partial()}}},params:_.object({user_id:_.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 Ue(404);if(a.email&&a.email!==o.email){const f=await ug(r.env.data.users,e,a.email);if(f.length&&f.some(m=>m.user_id!==n))throw new Ue(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new Ue(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 Ue(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${f.provider}|${f.user_id}`,password:Cw.hashSync(i,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new Ue(500);return r.json(c)}).openapi(Ee({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:_.object({"tenant-id":_.string()}),body:{content:{"application/json":{schema:_.union([_.object({link_with:_.string()}),_.object({user_id:_.string(),provider:_.string(),connection:_.string().optional()})])}}},params:_.object({user_id:_.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{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 Ue(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:fp(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(Ee({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:_.object({"tenant-id":_.string()}),params:_.object({user_id:_.string(),provider:_.string(),linked_user_id:_.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:_.array(Ar)}},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 Ue(404);return r.json([Ar.parse(i)])}).openapi(Ee({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{headers:_.object({"tenant-id":_.string()}),params:_.object({user_id:_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"List of sessions"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{"tenant-id":t}=r.req.valid("header"),n=await r.env.data.sessions.list(t,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return r.json(n)}),Uw=new Bt().openapi(Ee({tags:["users"],method:"get",path:"/",request:{query:_.object({email:_.string()}),headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:_.array(um)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),s=(await ug(r.env.data.users,e,t)).filter(i=>!i.linked_to);return r.json(s)}),Lw=Rs.extend({clients:_.array(Xn)}),qw=new Bt().openapi(Ee({tags:["clients"],method:"get",path:"/",request:{query:Fs,headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:_.union([Lw,_.array(Xn)])}},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:Ws(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(Ee({tags:["clients"],method:"get",path:"/{id}",request:{params:_.object({id:_.string()}),headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Xn}},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 Ue(404);return r.json(s,{})}).openapi(Ee({tags:["clients"],method:"delete",path:"/{id}",request:{params:_.object({id:_.string()}),headers:_.object({"tenant-id":_.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 Ue(404,{message:"Application not found"});return r.text("OK")}).openapi(Ee({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:_.object(Fu.shape).partial()}}},params:_.object({id:_.string()}),headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Xn}},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 Ue(404,{message:"Application not found"});return r.json(i)}).openapi(Ee({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:_.object(Fu.shape)}}},headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:_.object(Xn.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||dp(),client_secret:t.client_secret||dp()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});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 hd;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(hd||(hd={}));const Y=Be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Kr=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}},Z=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"]),Hw=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Nt 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 Nt))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()}}Nt.create=r=>new Nt(r);const Ts=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===Y.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Be.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Be.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Be.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Be.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}"`:Be.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,Be.assertNever(r)}return{message:t}};let fg=Ts;function Fw(r){fg=r}function ic(){return fg}const ac=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}},Ww=[];function F(r,e){const t=ic(),n=ac({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ts?void 0:Ts].filter(s=>!!s)});r.common.issues.push(n)}class ht{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 ht.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"}),ts=r=>({status:"dirty",value:r}),bt=r=>({status:"valid",value:r}),pd=r=>r.status==="aborted",md=r=>r.status==="dirty",aa=r=>r.status==="valid",oa=r=>typeof Promise<"u"&&r instanceof Promise;function oc(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 hg(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 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 oi,ci;class br{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 pp=(r,e)=>{if(aa(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 Nt(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:(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 Kr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Kr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ht,ctx:{common:e.parent.common,data:e.data,parsedType:Kr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(oa(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:Kr(e)},i=this._parseSync({data:e,path:s.path,parent:s});return pp(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:Kr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(oa(s)?s:Promise.resolve(s));return pp(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 nr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return pr.create(this,this._def)}nullable(){return fn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qt.create(this,this._def)}promise(){return Bs.create(this,this._def)}or(e){return da.create([this,e],this._def)}and(e){return fa.create(this,e,this._def)}transform(e){return new nr({...xe(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ga({...xe(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new lf({typeName:fe.ZodBranded,type:this,...xe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new va({...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 La.create(this,e)}readonly(){return ba.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const zw=/^c[^\s-]{8,}$/i,Kw=/^[0-9a-z]+$/,Gw=/^[0-9A-HJKMNP-TV-Z]{26}$/,Jw=/^[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,Yw=/^[a-z0-9_-]{21}$/i,Xw=/^[-+]?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)?)??$/,Qw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,e1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Eu;const t1=/^(?:(?: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])$/,r1=/^(([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})))$/,n1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,pg="((\\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])))",s1=new RegExp(`^${pg}$`);function mg(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 i1(r){return new RegExp(`^${mg(r)}$`)}function yg(r){let e=`${pg}T${mg(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 a1(r,e){return!!((e==="v4"||!e)&&t1.test(r)||(e==="v6"||!e)&&r1.test(r))}class Jt extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Y.string){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:Y.string,received:i.parsedType}),pe}const n=new ht;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")Qw.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")Eu||(Eu=new RegExp(e1,"u")),Eu.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")Jw.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")Yw.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")zw.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")Kw.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")Gw.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"?yg(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"?s1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:Z.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?i1(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"?Xw.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"duration",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?a1(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"?n1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"base64",code:Z.invalid_string,message:i.message}),n.dirty()):Be.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,...ce.errToObj(n)})}_addCheck(e){return new Jt({...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 Jt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Jt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Jt({...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}}Jt.create=r=>{var e;return new Jt({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};function o1(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 un 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 F(i,{code:Z.invalid_type,expected:Y.number,received:i.parsedType}),pe}let n;const s=new ht;for(const i of this._def.checks)i.kind==="int"?Be.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"?o1(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()):Be.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 un({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new un({...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"&&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)}}un.create=r=>new un({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class ln 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 F(i,{code:Z.invalid_type,expected:Y.bigint,received:i.parsedType}),pe}let n;const s=new ht;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()):Be.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 ln({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new ln({...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}}ln.create=r=>{var e;return new ln({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};class ca extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Y.boolean){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:Y.boolean,received:n.parsedType}),pe}return bt(e.data)}}ca.create=r=>new ca({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class Mn 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 F(i,{code:Z.invalid_type,expected:Y.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 ht;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()):Be.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Mn({...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}}Mn.create=r=>new Mn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...xe(r)});class cc extends Se{_parse(e){if(this._getType(e)!==Y.symbol){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:Y.symbol,received:n.parsedType}),pe}return bt(e.data)}}cc.create=r=>new cc({typeName:fe.ZodSymbol,...xe(r)});class ua extends Se{_parse(e){if(this._getType(e)!==Y.undefined){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:Y.undefined,received:n.parsedType}),pe}return bt(e.data)}}ua.create=r=>new ua({typeName:fe.ZodUndefined,...xe(r)});class la extends Se{_parse(e){if(this._getType(e)!==Y.null){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:Y.null,received:n.parsedType}),pe}return bt(e.data)}}la.create=r=>new la({typeName:fe.ZodNull,...xe(r)});class Ns extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return bt(e.data)}}Ns.create=r=>new Ns({typeName:fe.ZodAny,...xe(r)});class An extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return bt(e.data)}}An.create=r=>new An({typeName:fe.ZodUnknown,...xe(r)});class Vr extends Se{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:Y.never,received:t.parsedType}),pe}}Vr.create=r=>new Vr({typeName:fe.ZodNever,...xe(r)});class uc extends Se{_parse(e){if(this._getType(e)!==Y.undefined){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:Y.void,received:n.parsedType}),pe}return bt(e.data)}}uc.create=r=>new uc({typeName:fe.ZodVoid,...xe(r)});class Qt extends Se{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==Y.array)return F(t,{code:Z.invalid_type,expected:Y.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 br(t,a,t.path,o)))).then(a=>ht.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new br(t,a,t.path,o)));return ht.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Qt({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new Qt({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new Qt({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}Qt.create=(r,e)=>new Qt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...xe(e)});function Jn(r){if(r instanceof Ge){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=pr.create(Jn(n))}return new Ge({...r._def,shape:()=>e})}else return r instanceof Qt?new Qt({...r._def,type:Jn(r.element)}):r instanceof pr?pr.create(Jn(r.unwrap())):r instanceof fn?fn.create(Jn(r.unwrap())):r instanceof xr?xr.create(r.items.map(e=>Jn(e))):r}class Ge 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)!==Y.object){const u=this._getOrReturnCtx(e);return F(u,{code:Z.invalid_type,expected:Y.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 Vr&&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 br(s,m,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Vr){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 br(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,D=await f.value;u.push({key:m,value:D,alwaysSet:f.alwaysSet})}return u}).then(u=>ht.mergeObjectSync(n,u)):ht.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ge({...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 Ge({...this._def,unknownKeys:"strip"})}passthrough(){return new Ge({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ge({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ge({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 Ge({...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 Ge({...this._def,shape:()=>t})}omit(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ge({...this._def,shape:()=>t})}deepPartial(){return Jn(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 Ge({...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 i=this.shape[n];for(;i instanceof pr;)i=i._def.innerType;t[n]=i}}),new Ge({...this._def,shape:()=>t})}keyof(){return gg(Be.objectKeys(this.shape))}}Ge.create=(r,e)=>new Ge({shape:()=>r,unknownKeys:"strip",catchall:Vr.create(),typeName:fe.ZodObject,...xe(e)});Ge.strictCreate=(r,e)=>new Ge({shape:()=>r,unknownKeys:"strict",catchall:Vr.create(),typeName:fe.ZodObject,...xe(e)});Ge.lazycreate=(r,e)=>new Ge({shape:r,unknownKeys:"strip",catchall:Vr.create(),typeName:fe.ZodObject,...xe(e)});class da 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 Nt(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 Nt(c));return F(t,{code:Z.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}}da.create=(r,e)=>new da({options:r,typeName:fe.ZodUnion,...xe(e)});const Or=r=>r instanceof pa?Or(r.schema):r instanceof nr?Or(r.innerType()):r instanceof ma?[r.value]:r instanceof dn?r.options:r instanceof ya?Be.objectValues(r.enum):r instanceof ga?Or(r._def.innerType):r instanceof ua?[void 0]:r instanceof la?[null]:r instanceof pr?[void 0,...Or(r.unwrap())]:r instanceof fn?[null,...Or(r.unwrap())]:r instanceof lf||r instanceof ba?Or(r.unwrap()):r instanceof va?Or(r._def.innerType):[];class au extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Y.object)return F(t,{code:Z.invalid_type,expected:Y.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=Or(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 au({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...xe(n)})}}function yd(r,e){const t=Kr(r),n=Kr(e);if(r===e)return{valid:!0,data:r};if(t===Y.object&&n===Y.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=yd(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=yd(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 fa extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(pd(i)||pd(a))return pe;const o=yd(i.value,a.value);return o.valid?((md(i)||md(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}))}}fa.create=(r,e,t)=>new fa({left:r,right:e,typeName:fe.ZodIntersection,...xe(t)});class xr extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.array)return F(n,{code:Z.invalid_type,expected:Y.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 br(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>ht.mergeArray(t,a)):ht.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new xr({...this._def,rest:e})}}xr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xr({items:r,typeName:fe.ZodTuple,rest:null,...xe(e)})};class ha 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 F(n,{code:Z.invalid_type,expected:Y.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 br(n,o,n.path,o)),value:a._parse(new br(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?ht.mergeObjectAsync(t,s):ht.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Se?new ha({keyType:e,valueType:t,typeName:fe.ZodRecord,...xe(n)}):new ha({keyType:Jt.create(),valueType:e,typeName:fe.ZodRecord,...xe(t)})}}class lc 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 F(n,{code:Z.invalid_type,expected:Y.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 br(n,o,n.path,[u,"key"])),value:i._parse(new br(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}}}}lc.create=(r,e,t)=>new lc({valueType:e,keyType:r,typeName:fe.ZodMap,...xe(t)});class Vn extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.set)return F(n,{code:Z.invalid_type,expected:Y.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 br(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Vn({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new Vn({...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)}}Vn.create=(r,e)=>new Vn({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...xe(e)});class as extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Y.function)return F(t,{code:Z.invalid_type,expected:Y.function,received:t.parsedType}),pe;function n(o,c){return ac({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ic(),Ts].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return ac({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ic(),Ts].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 Bs){const o=this;return bt(async function(...c){const u=new Nt([]),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 bt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Nt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Nt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new as({...this._def,args:xr.create(e).rest(An.create())})}returns(e){return new as({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new as({args:e||xr.create([]).rest(An.create()),returns:t||An.create(),typeName:fe.ZodFunction,...xe(n)})}}class pa 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})}}pa.create=(r,e)=>new pa({getter:r,typeName:fe.ZodLazy,...xe(e)});class ma extends Se{_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}}ma.create=(r,e)=>new ma({value:r,typeName:fe.ZodLiteral,...xe(e)});function gg(r,e){return new dn({values:r,typeName:fe.ZodEnum,...xe(e)})}class dn extends Se{constructor(){super(...arguments),oi.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Be.joinValues(n),received:t.parsedType,code:Z.invalid_type}),pe}if(oc(this,oi)||hg(this,oi,new Set(this._def.values)),!oc(this,oi).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 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 dn.create(e,{...this._def,...t})}exclude(e,t=this._def){return dn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}oi=new WeakMap;dn.create=gg;class ya extends Se{constructor(){super(...arguments),ci.set(this,void 0)}_parse(e){const t=Be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Y.string&&n.parsedType!==Y.number){const s=Be.objectValues(t);return F(n,{expected:Be.joinValues(s),received:n.parsedType,code:Z.invalid_type}),pe}if(oc(this,ci)||hg(this,ci,new Set(Be.getValidEnumValues(this._def.values))),!oc(this,ci).has(e.data)){const s=Be.objectValues(t);return F(n,{received:n.data,code:Z.invalid_enum_value,options:s}),pe}return bt(e.data)}get enum(){return this._def.values}}ci=new WeakMap;ya.create=(r,e)=>new ya({values:r,typeName:fe.ZodNativeEnum,...xe(e)});class Bs 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 F(t,{code:Z.invalid_type,expected:Y.promise,received:t.parsedType}),pe;const n=t.parsedType===Y.promise?t.data:Promise.resolve(t.data);return bt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Bs.create=(r,e)=>new Bs({type:r,typeName:fe.ZodPromise,...xe(e)});class nr 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=>{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"?ts(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"?ts(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(!aa(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=>aa(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Be.assertNever(s)}}nr.create=(r,e,t)=>new nr({schema:r,typeName:fe.ZodEffects,effect:e,...xe(t)});nr.createWithPreprocess=(r,e,t)=>new nr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...xe(t)});class pr extends Se{_parse(e){return this._getType(e)===Y.undefined?bt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}pr.create=(r,e)=>new pr({innerType:r,typeName:fe.ZodOptional,...xe(e)});class fn extends Se{_parse(e){return this._getType(e)===Y.null?bt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fn.create=(r,e)=>new fn({innerType:r,typeName:fe.ZodNullable,...xe(e)});class ga 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}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class va 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 oa(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Nt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Nt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}va.create=(r,e)=>new va({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class dc extends Se{_parse(e){if(this._getType(e)!==Y.nan){const n=this._getOrReturnCtx(e);return F(n,{code:Z.invalid_type,expected:Y.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}}dc.create=r=>new dc({typeName:fe.ZodNaN,...xe(r)});const c1=Symbol("zod_brand");class lf 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 La 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"?pe:i.status==="dirty"?(t.dirty(),ts(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 La({in:e,out:t,typeName:fe.ZodPipeline})}}class ba extends Se{_parse(e){const t=this._def.innerType._parse(e),n=s=>(aa(s)&&(s.value=Object.freeze(s.value)),s);return oa(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ba.create=(r,e)=>new ba({innerType:r,typeName:fe.ZodReadonly,...xe(e)});function vg(r,e={},t){return r?Ns.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})}}):Ns.create()}const u1={object:Ge.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 l1=(r,e={message:`Input not instance of ${r.name}`})=>vg(t=>t instanceof r,e),bg=Jt.create,xg=un.create,d1=dc.create,f1=ln.create,_g=ca.create,h1=Mn.create,p1=cc.create,m1=ua.create,y1=la.create,g1=Ns.create,v1=An.create,b1=Vr.create,x1=uc.create,_1=Qt.create,w1=Ge.create,k1=Ge.strictCreate,S1=da.create,A1=au.create,O1=fa.create,E1=xr.create,I1=ha.create,C1=lc.create,j1=Vn.create,T1=as.create,N1=pa.create,B1=ma.create,R1=dn.create,P1=ya.create,$1=Bs.create,mp=nr.create,Z1=pr.create,D1=fn.create,M1=nr.createWithPreprocess,V1=La.create,U1=()=>bg().optional(),L1=()=>xg().optional(),q1=()=>_g().optional(),H1={string:r=>Jt.create({...r,coerce:!0}),number:r=>un.create({...r,coerce:!0}),boolean:r=>ca.create({...r,coerce:!0}),bigint:r=>ln.create({...r,coerce:!0}),date:r=>Mn.create({...r,coerce:!0})},F1=pe;var Pt=Object.freeze({__proto__:null,defaultErrorMap:Ts,setErrorMap:Fw,getErrorMap:ic,makeIssue:ac,EMPTY_PATH:Ww,addIssueToContext:F,ParseStatus:ht,INVALID:pe,DIRTY:ts,OK:bt,isAborted:pd,isDirty:md,isValid:aa,isAsync:oa,get util(){return Be},get objectUtil(){return hd},ZodParsedType:Y,getParsedType:Kr,ZodType:Se,datetimeRegex:yg,ZodString:Jt,ZodNumber:un,ZodBigInt:ln,ZodBoolean:ca,ZodDate:Mn,ZodSymbol:cc,ZodUndefined:ua,ZodNull:la,ZodAny:Ns,ZodUnknown:An,ZodNever:Vr,ZodVoid:uc,ZodArray:Qt,ZodObject:Ge,ZodUnion:da,ZodDiscriminatedUnion:au,ZodIntersection:fa,ZodTuple:xr,ZodRecord:ha,ZodMap:lc,ZodSet:Vn,ZodFunction:as,ZodLazy:pa,ZodLiteral:ma,ZodEnum:dn,ZodNativeEnum:ya,ZodPromise:Bs,ZodEffects:nr,ZodTransformer:nr,ZodOptional:pr,ZodNullable:fn,ZodDefault:ga,ZodCatch:va,ZodNaN:dc,BRAND:c1,ZodBranded:lf,ZodPipeline:La,ZodReadonly:ba,custom:vg,Schema:Se,ZodSchema:Se,late:u1,get ZodFirstPartyTypeKind(){return fe},coerce:H1,any:g1,array:_1,bigint:f1,boolean:_g,date:h1,discriminatedUnion:A1,effect:mp,enum:R1,function:T1,instanceof:l1,intersection:O1,lazy:N1,literal:B1,map:C1,nan:d1,nativeEnum:P1,never:b1,null:y1,nullable:D1,number:xg,object:w1,oboolean:q1,onumber:L1,optional:Z1,ostring:U1,pipeline:V1,preprocess:M1,promise:$1,record:I1,set:j1,strictObject:k1,string:bg,symbol:p1,transformer:mp,tuple:E1,undefined:m1,union:S1,unknown:v1,void:x1,NEVER:F1,ZodIssueCode:Z,quotelessJson:Hw,ZodError:Nt});Pt.object({start:Pt.number(),limit:Pt.number(),length:Pt.number()});_d.extend({email:Pt.string(),login_count:Pt.number(),multifactor:Pt.array(Pt.string()).optional(),last_ip:Pt.string().optional(),last_login:Pt.string().optional(),user_id:Pt.string()}).catchall(Pt.any());const W1=Rs.extend({tenants:_.array(hi)}),z1=new Bt().openapi(Ee({tags:["tenants"],method:"get",path:"/",request:{query:Fs},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:_.union([_.array(hi),W1])}},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:Ws(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(Ee({tags:["tenants"],method:"get",path:"/{id}",request:{params:_.object({id:_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:hi}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new Ue(404);return console.log("tenant",t),r.json(t)}).openapi(Ee({tags:["tenants"],method:"delete",path:"/{id}",request:{params:_.object({id:_.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(Ee({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:_.object(zu.shape).partial()}}},params:_.object({id:_.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(Ee({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:_.object(zu.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:hi}},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})}),K1=Rs.extend({logs:_.array(Gu)}),G1=new Bt().openapi(Ee({tags:["logs"],method:"get",path:"/",request:{query:Fs,headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:_.union([_.array(Gu),K1])}},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:Ws(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(Ee({tags:["logs"],method:"get",path:"/{id}",request:{headers:_.object({"tenant-id":_.string()}),params:_.object({id:_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Gu}},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 Ue(404);return r.json(n)}),J1=Rs.extend({hooks:_.array(ai)}),Y1=new Bt().openapi(Ee({tags:["hooks"],method:"get",path:"/",request:{query:Fs,headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:_.union([_.array(ai),J1])}},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:Ws(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(Ee({tags:["hooks"],method:"post",path:"/",request:{headers:_.object({"tenant-id":_.string()}),body:{content:{"application/json":{schema:_.object(Ku.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:ai}},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(Ee({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:_.object({"tenant-id":_.string()}),params:_.object({hook_id:_.string()}),body:{content:{"application/json":{schema:_.object(Ku.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:ai.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 Ue(404,{message:"Hook not found"});return r.json(s)}).openapi(Ee({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:_.object({"tenant-id":_.string()}),params:_.object({hook_id:_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ai}},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 Ue(404,{message:"Hook not found"});return r.json(n)}).openapi(Ee({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:_.object({"tenant-id":_.string()}),params:_.object({hook_id:_.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 Ue(404,{message:"Hook not found"});return r.text("OK")}),X1=Rs.extend({connections:_.array(Qn)}),Q1=new Bt().openapi(Ee({tags:["connections"],method:"get",path:"/",request:{query:Fs,headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:_.union([_.array(Qn),X1])}},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:Ws(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(Ee({tags:["connections"],method:"get",path:"/{id}",request:{params:_.object({id:_.string()}),headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Qn}},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 Ue(404);return r.json(n)}).openapi(Ee({tags:["connections"],method:"delete",path:"/{id}",request:{params:_.object({id:_.string()}),headers:_.object({"tenant-id":_.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 Ue(404,{message:"Connection not found"});return r.text("OK")}).openapi(Ee({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:_.object(Wu.shape).partial()}}},params:_.object({id:_.string()}),headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Qn}},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 Ue(404,{message:"Connection not found"});const i=await r.env.data.connections.get(e,t);if(!i)throw new Ue(404,{message:"Connection not found"});return r.json(i)}).openapi(Ee({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:_.object(Wu.shape)}}},headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Qn}},description:"An 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})}),ek=new Bt().openapi(Ee({tags:["prompts"],method:"get",path:"/",request:{headers:_.object({"tenant-id":_.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:pu}},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(pu.parse({}))}).openapi(Ee({tags:["prompts"],method:"patch",path:"/",request:{headers:_.object({"tenant-id":_.string()}),body:{content:{"application/json":{schema:_.object(pu.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 yp=!1;function tk(r){r.use(async(e,t)=>(yp||(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"}}}}),yp=!0),await t()))}function rk(r){const e=new Bt;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",Vw).route("/api/v2/users-by-email",Uw).route("/api/v2/clients",qw).route("/api/v2/tenants",z1).route("/api/v2/logs",G1).route("/api/v2/hooks",Y1).route("/api/v2/connections",Q1).route("/api/v2/prompts",ek);return tk(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function nk(r){const e=new Bt;e.get("/",s=>s.text("Hello, authhero!"));const t=rk(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}}exports.init=nk;
121
+ */(function(e,t){typeof Gw=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(Zo,function(){var e={},t=null;function n(E){if(r&&r.exports)try{return Xw.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 Tt(E,O)},e.hash=function(E,O,w,b){function v(C){typeof E=="string"&&typeof O=="number"?e.genSalt(O,function(V,Ae){Tt(E,Ae,C,b)}):typeof E=="string"&&typeof O=="string"?Tt(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,ie){if(Ae){V(Ae);return}C(ie)})})};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,ie){if(Ae){V(Ae);return}C(ie)})})},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,ie,Ie,Me,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||(Me=V<<2>>>0,Me|=(Ae&48)>>4,C.push(f(Me)),++v>=O||w>=b)||(ee=E.charCodeAt(w++),ie=ee<u.length?u[ee]:-1,ie==-1)||(Me=(Ae&15)<<4>>>0,Me|=(ie&60)>>2,C.push(f(Me)),++v>=O||w>=b)));)ee=E.charCodeAt(w++),Ie=ee<u.length?u[ee]:-1,Me=(ie&3)<<6>>>0,Me|=Ie,C.push(f(Me)),++v;var ot=[];for(w=0;w<v;w++)ot.push(C[w].charCodeAt(0));return ot}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(ie){ie=ie.slice(0,ie.indexOf(null));var Ie=Error(ie.toString());throw Ie.name="TruncatedError",Ie.bytes=ie,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],ye=[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 Le(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,ie=0;ie<C;ie++)Ae=Le(E,b),b=Ae.offp,O[ie]=O[ie]^Ae.key;for(ie=0;ie<C;ie+=2)v=Ue(v,0,O,w),O[ie]=v[0],O[ie+1]=v[1];for(ie=0;ie<V;ie+=2)v=Ue(v,0,O,w),w[ie]=v[0],w[ie+1]=v[1]}function et(E,O,w,b){for(var v=0,C=[0,0],V=w.length,Ae=b.length,ie,Ie=0;Ie<V;Ie++)ie=Le(O,v),v=ie.offp,w[Ie]=w[Ie]^ie.key;for(v=0,Ie=0;Ie<V;Ie+=2)ie=Le(E,v),v=ie.offp,C[0]^=ie.key,ie=Le(E,v),v=ie.offp,C[1]^=ie.key,C=Ue(C,0,w,b),w[Ie]=C[0],w[Ie+1]=C[1];for(Ie=0;Ie<Ae;Ie+=2)ie=Le(E,v),v=ie.offp,C[0]^=ie.key,ie=Le(E,v),v=ie.offp,C[1]^=ie.key,C=Ue(C,0,w,b),b[Ie]=C[0],b[Ie+1]=C[1]}function ft(E,O,w,b,v){var C=ye.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 ie,Ie,Me=0,ee;Int32Array?(ie=new Int32Array(R),Ie=new Int32Array(T)):(ie=R.slice(),Ie=T.slice()),et(O,E,ie,Ie);function ot(){if(v&&v(Me/w),Me<w)for(var qe=Date.now();Me<w&&(Me=Me+1,$e(E,ie,Ie),$e(O,ie,Ie),!(Date.now()-qe>S)););else{for(Me=0;Me<64;Me++)for(ee=0;ee<V>>1;ee++)Ue(C,ee<<1,ie,Ie);var tt=[];for(Me=0;Me<V;Me++)tt.push((C[Me]>>24&255)>>>0),tt.push((C[Me]>>16&255)>>>0),tt.push((C[Me]>>8&255)>>>0),tt.push((C[Me]&255)>>>0);if(b){b(null,tt);return}else return tt}b&&a(ot)}if(typeof b<"u")ot();else for(var An;;)if(typeof(An=ot())<"u")return An||[]}function Tt(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,ie=parseInt(O.substring(V+1,V+2),10),Ie=Ae+ie,Me=O.substring(V+3,V+25);E+=C>="a"?"\0":"";var ee=o(E),ot=B(Me,p);function An(qe){var tt=[];return tt.push("$2"),C>="a"&&tt.push(C),tt.push("$"),Ie<10&&tt.push("0"),tt.push(Ie.toString()),tt.push("$"),tt.push(m(ot,ot.length)),tt.push(m(qe,ye.length*4-1)),tt.join("")}if(typeof w>"u")return An(ft(ee,ot,Ie));ft(ee,ot,Ie,function(qe,tt){qe?w(qe,null):w(null,An(tt))},b)}return e.encodeBase64=m,e.decodeBase64=B,e})})($g);var Qw=$g.exports;const e1=Wx(Qw),t1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let r1=r=>crypto.getRandomValues(new Uint8Array(r)),n1=(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}}},s1=(r,e=21)=>n1(r,e,r1),Op=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=t1[t[r]&63];return e};const i1=24;function a1(){return s1("0123456789abcdef",i1)()}function Ep(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}const Jn=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 si(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 o1={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},c1=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[s,i]of Object.entries(o1))if(u1(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"},u1=r=>navigator.userAgent.startsWith(r);function l1(r,e){c1()==="workerd"&&r.executionCtx.waitUntil(e)}const Cp=Qn.extend({users:x.array(Ir)}),d1=Qn.extend({sessions:x.array(Dm)}),f1=new $t().openapi(Ce({tags:["users"],method:"get",path:"/",request:{query:Jn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(Ir),Cp])}},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([Ir.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:si(s),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(Cp.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(x.array(Ir).parse(u))}).openapi(Ce({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:Ir}},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(Ce({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(Ce({tags:["users"],method:"post",path:"/",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object({...sl.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ir}},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||a1()}`;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=Pg(r,{type:Zd.SUCCESS_API_OPERATION,description:"User created"});l1(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:Ep(a.user_id),isSocial:a.is_social}]};return r.json(Ir.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new De(409,{message:"User already exists"}):a}}).openapi(Ce({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object({...sl.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:e1.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(Ce({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:Ep(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(Ce({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(Ir)}},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([Ir.parse(i)])}).openapi(Ce({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:Jn,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(Dm),d1])}},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)}),h1=new $t().openapi(Ce({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(Bm)}},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)}),p1=Qn.extend({clients:x.array(ds)}),m1=new $t().openapi(Ce({tags:["clients"],method:"get",path:"/",request:{query:Jn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([p1,x.array(ds)])}},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:si(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(Ce({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:ds}},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(Ce({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(Ce({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:x.object(il.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:ds}},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(Ce({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:x.object(il.shape)}}},headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:x.object(ds.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||Op(),client_secret:t.client_secret||Op()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var Re;(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})(Re||(Re={}));var Ed;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ed||(Ed={}));const J=Re.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 J.undefined;case"string":return J.string;case"number":return isNaN(r)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(r)?J.array:r===null?J.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?J.promise:typeof Map<"u"&&r instanceof Map?J.map:typeof Set<"u"&&r instanceof Set?J.set:typeof Date<"u"&&r instanceof Date?J.date:J.object;default:return J.unknown}},M=Re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),y1=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Pt 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 Pt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const 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()}}Pt.create=r=>new Pt(r);const Hs=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===J.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${Re.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}"`:Re.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,Re.assertNever(r)}return{message:t}};let Zg=Hs;function g1(r){Zg=r}function gc(){return Zg}const vc=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}},v1=[];function F(r,e){const t=gc(),n=vc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hs?void 0:Hs].filter(s=>!!s)});r.common.issues.push(n)}class mt{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 mt.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"}),ps=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),Cd=r=>r.status==="aborted",Id=r=>r.status==="dirty",va=r=>r.status==="valid",ba=r=>typeof Promise<"u"&&r instanceof Promise;function bc(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 Dg(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 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 bi,xi;class kr{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 Ip=(r,e)=>{if(va(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 Pt(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:(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 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 mt,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(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:tn(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Ip(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(ba(s)?s:Promise.resolve(s));return Ip(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:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return vr.create(this,this._def)}nullable(){return _n.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return nr.create(this,this._def)}promise(){return Ws.create(this,this._def)}or(e){return ka.create([this,e],this._def)}and(e){return Sa.create(this,e,this._def)}transform(e){return new or({...xe(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ia({...xe(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new Af({typeName:fe.ZodBranded,type:this,...xe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ja({...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 eo.create(this,e)}readonly(){return Ta.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const b1=/^c[^\s-]{8,}$/i,x1=/^[0-9a-z]+$/,_1=/^[0-9A-HJKMNP-TV-Z]{26}$/,w1=/^[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,k1=/^[a-z0-9_-]{21}$/i,S1=/^[-+]?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)?)??$/,A1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,O1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Vu;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])$/,C1=/^(([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})))$/,I1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Mg="((\\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])))",j1=new RegExp(`^${Mg}$`);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 T1(r){return new RegExp(`^${Vg(r)}$`)}function Ug(r){let e=`${Mg}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 N1(r,e){return!!((e==="v4"||!e)&&E1.test(r)||(e==="v6"||!e)&&C1.test(r))}class er extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const i=this._getOrReturnCtx(e);return F(i,{code:M.invalid_type,expected:J.string,received:i.parsedType}),pe}const n=new mt;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: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),F(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?F(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&F(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")A1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Vu||(Vu=new RegExp(O1,"u")),Vu.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")w1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")k1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")b1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")x1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")_1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(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),F(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),F(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),F(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),F(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),F(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Ug(i).test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?j1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?T1(i).test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?S1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?N1(e.data,i.version)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?I1.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):Re.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 er({...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 er({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new er({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new er({...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}}er.create=r=>{var e;return new er({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(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 vn 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 i=this._getOrReturnCtx(e);return F(i,{code:M.invalid_type,expected:J.number,received:i.parsedType}),pe}let n;const s=new mt;for(const i of this._def.checks)i.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),F(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),F(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),F(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),F(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),F(n,{code:M.not_finite,message:i.message}),s.dirty()):Re.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 vn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new vn({...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"&&Re.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}vn.create=r=>new vn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class bn 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 i=this._getOrReturnCtx(e);return F(i,{code:M.invalid_type,expected:J.bigint,received:i.parsedType}),pe}let n;const s=new mt;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: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),F(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),F(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Re.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 bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_addCheck(e){return new bn({...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}}bn.create=r=>{var e;return new bn({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};class xa extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const n=this._getOrReturnCtx(e);return F(n,{code:M.invalid_type,expected:J.boolean,received:n.parsedType}),pe}return _t(e.data)}}xa.create=r=>new xa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class Yn extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const i=this._getOrReturnCtx(e);return F(i,{code:M.invalid_type,expected:J.date,received:i.parsedType}),pe}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return F(i,{code:M.invalid_date}),pe}const n=new mt;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: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),F(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Re.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Yn({...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}}Yn.create=r=>new Yn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...xe(r)});class xc extends Se{_parse(e){if(this._getType(e)!==J.symbol){const n=this._getOrReturnCtx(e);return F(n,{code:M.invalid_type,expected:J.symbol,received:n.parsedType}),pe}return _t(e.data)}}xc.create=r=>new xc({typeName:fe.ZodSymbol,...xe(r)});class _a extends Se{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return F(n,{code:M.invalid_type,expected:J.undefined,received:n.parsedType}),pe}return _t(e.data)}}_a.create=r=>new _a({typeName:fe.ZodUndefined,...xe(r)});class wa extends Se{_parse(e){if(this._getType(e)!==J.null){const n=this._getOrReturnCtx(e);return F(n,{code:M.invalid_type,expected:J.null,received:n.parsedType}),pe}return _t(e.data)}}wa.create=r=>new wa({typeName:fe.ZodNull,...xe(r)});class Fs extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}}Fs.create=r=>new Fs({typeName:fe.ZodAny,...xe(r)});class $n extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}}$n.create=r=>new $n({typeName:fe.ZodUnknown,...xe(r)});class Wr extends Se{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:M.invalid_type,expected:J.never,received:t.parsedType}),pe}}Wr.create=r=>new Wr({typeName:fe.ZodNever,...xe(r)});class _c extends Se{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return F(n,{code:M.invalid_type,expected:J.void,received:n.parsedType}),pe}return _t(e.data)}}_c.create=r=>new _c({typeName:fe.ZodVoid,...xe(r)});class nr extends Se{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==J.array)return F(t,{code:M.invalid_type,expected:J.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?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&&(F(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&&(F(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 kr(t,a,t.path,o)))).then(a=>mt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new kr(t,a,t.path,o)));return mt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new nr({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new nr({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new nr({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}nr.create=(r,e)=>new nr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...xe(e)});function us(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=vr.create(us(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof nr?new nr({...r._def,type:us(r.element)}):r instanceof vr?vr.create(us(r.unwrap())):r instanceof _n?_n.create(us(r.unwrap())):r instanceof Sr?Sr.create(r.items.map(e=>us(e))):r}class Ye 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=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const u=this._getOrReturnCtx(e);return F(u,{code:M.invalid_type,expected:J.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 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 kr(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&&(F(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 kr(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=>mt.mergeObjectSync(n,u)):mt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var 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 Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...this._def,catchall:e})}pick(e){const t={};return Re.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}omit(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return us(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof vr;)i=i._def.innerType;t[n]=i}}),new Ye({...this._def,shape:()=>t})}keyof(){return Lg(Re.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Wr.create(),typeName:fe.ZodObject,...xe(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Wr.create(),typeName:fe.ZodObject,...xe(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Wr.create(),typeName:fe.ZodObject,...xe(e)});class ka 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 Pt(o.ctx.common.issues));return F(t,{code:M.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 Pt(c));return F(t,{code:M.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}}ka.create=(r,e)=>new ka({options:r,typeName:fe.ZodUnion,...xe(e)});const jr=r=>r instanceof Oa?jr(r.schema):r instanceof or?jr(r.innerType()):r instanceof Ea?[r.value]:r instanceof xn?r.options:r instanceof Ca?Re.objectValues(r.enum):r instanceof Ia?jr(r._def.innerType):r instanceof _a?[void 0]:r instanceof wa?[null]:r instanceof vr?[void 0,...jr(r.unwrap())]:r instanceof _n?[null,...jr(r.unwrap())]:r instanceof Af||r instanceof Ta?jr(r.unwrap()):r instanceof ja?jr(r._def.innerType):[];class vu extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return F(t,{code:M.invalid_type,expected:J.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:M.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=jr(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 vu({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...xe(n)})}}function jd(r,e){const t=tn(r),n=tn(e);if(r===e)return{valid:!0,data:r};if(t===J.object&&n===J.object){const s=Re.objectKeys(e),i=Re.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=jd(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=jd(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 Sa extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Cd(i)||Cd(a))return pe;const o=jd(i.value,a.value);return o.valid?((Id(i)||Id(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:M.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}))}}Sa.create=(r,e,t)=>new Sa({left:r,right:e,typeName:fe.ZodIntersection,...xe(t)});class Sr extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return F(n,{code:M.invalid_type,expected:J.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return F(n,{code:M.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: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 kr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>mt.mergeArray(t,a)):mt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Sr({...this._def,rest:e})}}Sr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Sr({items:r,typeName:fe.ZodTuple,rest:null,...xe(e)})};class Aa 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 F(n,{code:M.invalid_type,expected:J.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 kr(n,o,n.path,o)),value:a._parse(new kr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?mt.mergeObjectAsync(t,s):mt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Se?new Aa({keyType:e,valueType:t,typeName:fe.ZodRecord,...xe(n)}):new Aa({keyType:er.create(),valueType:e,typeName:fe.ZodRecord,...xe(t)})}}class wc 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 F(n,{code:M.invalid_type,expected:J.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 kr(n,o,n.path,[u,"key"])),value:i._parse(new kr(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}}}}wc.create=(r,e,t)=>new wc({valueType:e,keyType:r,typeName:fe.ZodMap,...xe(t)});class Xn extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return F(n,{code:M.invalid_type,expected:J.set,received:n.parsedType}),pe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(F(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&&(F(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 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 kr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Xn({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new Xn({...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)}}Xn.create=(r,e)=>new Xn({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...xe(e)});class bs extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return F(t,{code:M.invalid_type,expected:J.function,received:t.parsedType}),pe;function n(o,c){return vc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,gc(),Hs].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function s(o,c){return vc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,gc(),Hs].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 Ws){const o=this;return _t(async function(...c){const u=new Pt([]),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 _t(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Pt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Pt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new bs({...this._def,args:Sr.create(e).rest($n.create())})}returns(e){return new bs({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new bs({args:e||Sr.create([]).rest($n.create()),returns:t||$n.create(),typeName:fe.ZodFunction,...xe(n)})}}class Oa 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})}}Oa.create=(r,e)=>new Oa({getter:r,typeName:fe.ZodLazy,...xe(e)});class Ea extends Se{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ea.create=(r,e)=>new Ea({value:r,typeName:fe.ZodLiteral,...xe(e)});function Lg(r,e){return new xn({values:r,typeName:fe.ZodEnum,...xe(e)})}class xn extends Se{constructor(){super(...arguments),bi.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Re.joinValues(n),received:t.parsedType,code:M.invalid_type}),pe}if(bc(this,bi)||Dg(this,bi,new Set(this._def.values)),!bc(this,bi).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:M.invalid_enum_value,options:n}),pe}return _t(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return xn.create(e,{...this._def,...t})}exclude(e,t=this._def){return xn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}bi=new WeakMap;xn.create=Lg;class Ca extends Se{constructor(){super(...arguments),xi.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const s=Re.objectValues(t);return F(n,{expected:Re.joinValues(s),received:n.parsedType,code:M.invalid_type}),pe}if(bc(this,xi)||Dg(this,xi,new Set(Re.getValidEnumValues(this._def.values))),!bc(this,xi).has(e.data)){const s=Re.objectValues(t);return F(n,{received:n.data,code:M.invalid_enum_value,options:s}),pe}return _t(e.data)}get enum(){return this._def.values}}xi=new WeakMap;Ca.create=(r,e)=>new Ca({values:r,typeName:fe.ZodNativeEnum,...xe(e)});class Ws 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 F(t,{code:M.invalid_type,expected:J.promise,received:t.parsedType}),pe;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})))}}Ws.create=(r,e)=>new Ws({type:r,typeName:fe.ZodPromise,...xe(e)});class or 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=>{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"?ps(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"?ps(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(!va(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=>va(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Re.assertNever(s)}}or.create=(r,e,t)=>new or({schema:r,typeName:fe.ZodEffects,effect:e,...xe(t)});or.createWithPreprocess=(r,e,t)=>new or({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...xe(t)});class vr extends Se{_parse(e){return this._getType(e)===J.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}vr.create=(r,e)=>new vr({innerType:r,typeName:fe.ZodOptional,...xe(e)});class _n extends Se{_parse(e){return this._getType(e)===J.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_n.create=(r,e)=>new _n({innerType:r,typeName:fe.ZodNullable,...xe(e)});class Ia 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}}Ia.create=(r,e)=>new Ia({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class ja 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 Pt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Pt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ja.create=(r,e)=>new ja({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class kc extends Se{_parse(e){if(this._getType(e)!==J.nan){const n=this._getOrReturnCtx(e);return F(n,{code:M.invalid_type,expected:J.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}}kc.create=r=>new kc({typeName:fe.ZodNaN,...xe(r)});const R1=Symbol("zod_brand");class Af 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 eo 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"?pe:i.status==="dirty"?(t.dirty(),ps(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 eo({in:e,out:t,typeName:fe.ZodPipeline})}}class Ta extends Se{_parse(e){const t=this._def.innerType._parse(e),n=s=>(va(s)&&(s.value=Object.freeze(s.value)),s);return ba(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Ta.create=(r,e)=>new Ta({innerType:r,typeName:fe.ZodReadonly,...xe(e)});function qg(r,e={},t){return r?Fs.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})}}):Fs.create()}const P1={object:Ye.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 $1=(r,e={message:`Input not instance of ${r.name}`})=>qg(t=>t instanceof r,e),Hg=er.create,Fg=vn.create,Z1=kc.create,D1=bn.create,Wg=xa.create,M1=Yn.create,V1=xc.create,U1=_a.create,L1=wa.create,q1=Fs.create,H1=$n.create,F1=Wr.create,W1=_c.create,z1=nr.create,K1=Ye.create,G1=Ye.strictCreate,J1=ka.create,Y1=vu.create,X1=Sa.create,Q1=Sr.create,ek=Aa.create,tk=wc.create,rk=Xn.create,nk=bs.create,sk=Oa.create,ik=Ea.create,ak=xn.create,ok=Ca.create,ck=Ws.create,jp=or.create,uk=vr.create,lk=_n.create,dk=or.createWithPreprocess,fk=eo.create,hk=()=>Hg().optional(),pk=()=>Fg().optional(),mk=()=>Wg().optional(),yk={string:r=>er.create({...r,coerce:!0}),number:r=>vn.create({...r,coerce:!0}),boolean:r=>xa.create({...r,coerce:!0}),bigint:r=>bn.create({...r,coerce:!0}),date:r=>Yn.create({...r,coerce:!0})},gk=pe;var Mt=Object.freeze({__proto__:null,defaultErrorMap:Hs,setErrorMap:g1,getErrorMap:gc,makeIssue:vc,EMPTY_PATH:v1,addIssueToContext:F,ParseStatus:mt,INVALID:pe,DIRTY:ps,OK:_t,isAborted:Cd,isDirty:Id,isValid:va,isAsync:ba,get util(){return Re},get objectUtil(){return Ed},ZodParsedType:J,getParsedType:tn,ZodType:Se,datetimeRegex:Ug,ZodString:er,ZodNumber:vn,ZodBigInt:bn,ZodBoolean:xa,ZodDate:Yn,ZodSymbol:xc,ZodUndefined:_a,ZodNull:wa,ZodAny:Fs,ZodUnknown:$n,ZodNever:Wr,ZodVoid:_c,ZodArray:nr,ZodObject:Ye,ZodUnion:ka,ZodDiscriminatedUnion:vu,ZodIntersection:Sa,ZodTuple:Sr,ZodRecord:Aa,ZodMap:wc,ZodSet:Xn,ZodFunction:bs,ZodLazy:Oa,ZodLiteral:Ea,ZodEnum:xn,ZodNativeEnum:Ca,ZodPromise:Ws,ZodEffects:or,ZodTransformer:or,ZodOptional:vr,ZodNullable:_n,ZodDefault:Ia,ZodCatch:ja,ZodNaN:kc,BRAND:R1,ZodBranded:Af,ZodPipeline:eo,ZodReadonly:Ta,custom:qg,Schema:Se,ZodSchema:Se,late:P1,get ZodFirstPartyTypeKind(){return fe},coerce:yk,any:q1,array:z1,bigint:D1,boolean:Wg,date:M1,discriminatedUnion:Y1,effect:jp,enum:ak,function:nk,instanceof:$1,intersection:X1,lazy:sk,literal:ik,map:tk,nan:Z1,nativeEnum:ok,never:F1,null:L1,nullable:lk,number:Fg,object:K1,oboolean:mk,onumber:pk,optional:uk,ostring:hk,pipeline:fk,preprocess:dk,promise:ck,record:ek,set:rk,strictObject:G1,string:Hg,symbol:V1,transformer:jp,tuple:Q1,undefined:U1,union:J1,unknown:H1,void:W1,NEVER:gk,ZodIssueCode:M,quotelessJson:y1,ZodError:Pt});Mt.object({start:Mt.number(),limit:Mt.number(),length:Mt.number()});$d.extend({email:Mt.string(),login_count:Mt.number(),multifactor:Mt.array(Mt.string()).optional(),last_ip:Mt.string().optional(),last_login:Mt.string().optional(),user_id:Mt.string()}).catchall(Mt.any());const vk=Qn.extend({tenants:x.array(Ai)}),bk=new $t().openapi(Ce({tags:["tenants"],method:"get",path:"/",request:{query:Jn},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:x.union([x.array(Ai),vk])}},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:si(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(Ce({tags:["tenants"],method:"get",path:"/{id}",request:{params:x.object({id:x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Ai}},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(Ce({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(Ce({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:x.object(ol.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(Ce({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:x.object(ol.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Ai}},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})}),xk=Qn.extend({logs:x.array(ul)}),_k=new $t().openapi(Ce({tags:["logs"],method:"get",path:"/",request:{query:Jn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(ul),xk])}},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:si(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(Ce({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:ul}},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)}),wk=Qn.extend({hooks:x.array(vi)}),kk=new $t().openapi(Ce({tags:["hooks"],method:"get",path:"/",request:{query:Jn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(vi),wk])}},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:si(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(Ce({tags:["hooks"],method:"post",path:"/",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object(cl.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:vi}},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(Ce({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(cl.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:vi.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(Ce({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:vi}},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(Ce({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")}),Sk=Qn.extend({connections:x.array(fs)}),Ak=new $t().openapi(Ce({tags:["connections"],method:"get",path:"/",request:{query:Jn,headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:x.union([x.array(fs),Sk])}},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:si(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(Ce({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:fs}},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(Ce({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(Ce({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:x.object(al.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:fs}},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(Ce({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:x.object(al.shape)}}},headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:fs}},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 $t().openapi(Ce({tags:["prompts"],method:"get",path:"/",request:{headers:x.object({"tenant-id":x.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Eu}},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(Eu.parse({}))}).openapi(Ce({tags:["prompts"],method:"patch",path:"/",request:{headers:x.object({"tenant-id":x.string()}),body:{content:{"application/json":{schema:x.object(Eu.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 Tp=!1;function Ek(r){r.use(async(e,t)=>(Tp||(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"}}}}),Tp=!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 Ck(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 Ik(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 Ck(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 jk(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 Tk(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=jk(u);if(!f||!await Ik(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 Nk(r){const e=new $t;e.use(Tk(e)),e.use(async(n,s)=>(n.env.data=zw(n,r.dataAdapter),s()));const t=e.route("/api/v2/branding",Kw).route("/api/v2/users",f1).route("/api/v2/users-by-email",h1).route("/api/v2/clients",m1).route("/api/v2/tenants",bk).route("/api/v2/logs",_k).route("/api/v2/hooks",kk).route("/api/v2/connections",Ak).route("/api/v2/prompts",Ok);return Ek(t),t.doc("/api/v2/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function Bk(r){const e=new $t;e.get("/",s=>s.json({name:"authhero"}));const t=Nk(r);e.route("/api/v2",t);const n=new $t().route("/.well-known",Uw(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}}exports.init=Bk;