authhero 0.20.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/authhero.cjs +19 -143
  2. package/dist/authhero.mjs +8599 -32954
  3. package/package.json +1 -1
package/dist/authhero.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";var c5=Object.defineProperty;var l2=r=>{throw TypeError(r)};var u5=(r,e,t)=>e in r?c5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Pe=(r,e,t)=>u5(r,typeof e!="symbol"?e+"":e,t),L0=(r,e,t)=>e.has(r)||l2("Cannot "+t);var V=(r,e,t)=>(L0(r,e,"read from private field"),t?t.call(r):e.get(r)),At=(r,e,t)=>e.has(r)?l2("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),Fe=(r,e,t,n)=>(L0(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Pt=(r,e,t)=>(L0(r,e,"access private method"),t);var d2=(r,e,t,n)=>({set _(s){Fe(r,e,s,t)},get _(){return V(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Gl(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 wt(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function l5(r){return"_def"in r}function $l(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 d5(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,l,h;const R=typeof s=="string"?i:s,B=R??{},{param:d}=B,g=Gl(B,["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),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||d?{param:Object.assign(Object.assign({},(h=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||h===void 0?void 0:h.param),d)}:void 0),$=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(wt(this,"ZodObject")){const P=this.extend;$.extend=function(...ae){var Re,He,Te,Nt,Gt,Jt;const C=P.apply(this,ae);return C._def.openapi={_internal:{extendedFrom:!((He=(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal)===null||He===void 0)&&He.refId?{refId:(Nt=(Te=this._def.openapi)===null||Te===void 0?void 0:Te._internal)===null||Nt===void 0?void 0:Nt.refId,schema:this}:(Gt=this._def.openapi)===null||Gt===void 0?void 0:Gt._internal.extendedFrom},metadata:(Jt=C._def.openapi)===null||Jt===void 0?void 0:Jt.metadata},C}}return $},$l(r,"optional"),$l(r,"nullable"),$l(r,"default"),$l(r,"transform"),$l(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,l;c._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.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 mm(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=>mm(r[n],e[n]))}class h5{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=>mm(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>mm(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 fd(r){return r==null}function md(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function p5(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function ru(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function h2(r){return r.filter(e=>!fd(e))}const jb=mm;function f5(r){const e=new h5;return r.forEach(t=>e.put(t)),[...e.values()]}function C4(r){return typeof r=="string"}class m5{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 Hg{constructor(e){this.message=e}}class Zl extends Hg{constructor(e,t){super(e),this.data=t}}class ym extends Hg{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 Dl(r,e){try{return r()}catch(t){throw t instanceof ym?new ym(Object.assign(Object.assign({},t.data),e)):t}}class y5 extends Hg{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class tr{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 ru(p5(e,["param"]),fd)}static buildParameterMetadata(e){return ru(e,fd)}static applySchemaMetadata(e,t){return ru(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),fd)}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&&wt(e,t)?e:wt(e,"ZodOptional")||wt(e,"ZodNullable")||wt(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):wt(e,"ZodDefault")||wt(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):wt(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):wt(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return wt(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class g5{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 v5{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class b5{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=>tr.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=tr.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(wt(c,"ZodEnum")||wt(c,"ZodNativeEnum")){Object.values(c.enum).filter(C4).forEach(h=>{s[h]=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 _5{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class w5{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!wt(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class x5{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function k5(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 S5{transform(e,t){const{type:n,values:s}=k5(e._def.values);if(n==="mixed")throw new Hg("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 A5{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class O5{transform(e,t,n,s){var i;const a=(i=tr.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=md(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 l=this.requiredKeysOf(u),h=md(u==null?void 0:u._def.shape(),s),R=Object.fromEntries(Object.entries(c).filter(([g,A])=>!jb(h[g],A))),B=o.filter(g=>!l.includes(g)),d=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:R}),B.length>0?{required:B}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},d]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return wt(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!tr.isOptionalSchema(n)).map(([t,n])=>t)}}class j5{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(wt(i,"ZodEnum")||wt(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter(C4).reduce((u,l)=>Object.assign(Object.assign({},u),{[l]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class C5{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 E5{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 I5{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 wt(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return wt(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class T5{constructor(e){this.versionSpecifics=e,this.objectTransformer=new O5,this.stringTransformer=new C5,this.numberTransformer=new A5,this.bigIntTransformer=new v5,this.literalTransformer=new x5,this.enumTransformer=new _5,this.nativeEnumTransformer=new S5,this.arrayTransformer=new g5,this.unionTransformer=new I5,this.discriminatedUnionTransformer=new b5,this.intersectionTransformer=new w5,this.recordTransformer=new j5,this.tupleTransformer=new E5(e)}transform(e,t,n,s,i){if(wt(e,"ZodNull"))return this.versionSpecifics.nullType;if(wt(e,"ZodUnknown")||wt(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(wt(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(wt(e,"ZodUnknown")||wt(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(wt(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(wt(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(wt(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(wt(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(wt(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(wt(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(wt(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(wt(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(wt(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(wt(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(wt(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(wt(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(wt(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(wt(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=tr.getRefId(e);throw new y5({currentSchema:e._def,schemaName:i})}}class E4{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new T5(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=tr.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 Zl(`Conflicting location for parameter ${u.name}`,{key:"in",values:h2([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 Zl("Conflicting names for parameter",{key:"name",values:h2([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=tr.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(wt(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,l])=>{var h,R;const B=tr.getMetadata(l),d=this.getParameterRef(B,{in:t,name:u});if(d)return d;const g=(h=B==null?void 0:B.metadata)===null||h===void 0?void 0:h.param;if(g!=null&&g.name&&g.name!==u)throw new Zl("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new Zl(`Conflicting location for parameter ${(R=g.name)!==null&&R!==void 0?R:u}`,{key:"in",values:[t,g.in]});return this.generateParameter(l.openapi({param:{name:u,in:t}}))})}if(i!=null&&i.in&&i.in!==t)throw new Zl(`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=tr.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!tr.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?tr.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=tr.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 ym({missingField:"name"});if(!a)throw new ym({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=tr.unwrapChained(e),s=tr.getMetadata(e),i=tr.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?tr.applySchemaMetadata(a,s.metadata):ru(a,fd)}constructReferencedOpenAPISchema(e){var t;const n=tr.getMetadata(e),s=tr.unwrapChained(e),i=tr.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=tr.getMetadata(e),s=tr.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=ru(tr.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(l,h)=>l===void 0||jb(l,i[h]));if(o.type)return{allOf:[a,o]};const c=ru(this.constructReferencedOpenAPISchema(e),(l,h)=>l===void 0||jb(l,i[h])),u=tr.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=tr.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=Gl(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=Dl(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=Dl(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=Dl(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=Dl(()=>{if(Array.isArray(t))return t.flatMap(h=>this.generateInlineParameters(h,"header"));const l=this.cleanParameter(t);return l?this.generateInlineParameters(l,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return wt(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=Gl(e,["method","path","request","responses"]),o=md(i,h=>this.getResponse(h)),c=Dl(()=>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=Gl(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=wt(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 md(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return md(e,t=>{if(!t||!l5(t.schema))return t;const{schema:n}=t,s=Gl(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 N5{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=f5(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 B5{constructor(e){const t=new N5;this.generator=new E4(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class R5{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 P5(r){return"type"in r&&r.type==="webhook"}class $5{constructor(e){this.definitions=e,this.webhookRefs={};const t=new R5;this.generator=new E4(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(P5).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 I4=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Z5=r=>{const{groups:e,path:t}=D5(r),n=I4(t);return M5(n,e)},D5=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},M5=(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},Ef={},p2=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(Ef[r]||(e[2]?Ef[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:Ef[r]=[r,e[1],!0]),Ef[r]):null},T4=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},U5=r=>T4(r,decodeURI),N4=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 U5(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},V5=r=>{const e=N4(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},sa=(...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},B4=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)},q0=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?dx(r):r):r,R4=(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 q0(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=q0(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=q0(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},L5=R4,q5=(r,e)=>R4(r,e,!0),dx=decodeURIComponent,H5=/^[\w!#$%&'*.^`|~+-]+$/,F5=/^[ !#-:<-[\]-~]*$/,K5=(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(!H5.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),F5.test(o)&&(n[a]=dx(o))}return n},z5=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?K5(n):{}},nt=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});Pe(this,"res");Pe(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})}},W5=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),G5=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,J5=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Y5=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,X5=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!G5.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new nt(400,{message:o})}break;case"form":{if(!i||!(J5.test(i)||Y5.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 W5(u,i),t.req.bodyCache.formData=o}catch(u){let l="Malformed FormData request.";throw l+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new nt(400,{message:l})}const c={};o.forEach((u,l)=>{l.endsWith("[]")?(c[l]??(c[l]=[])).push(u):Array.isArray(c[l])?c[l].push(u):l in c?c[l]=[c[l],u]:c[l]=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=z5(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const Ec=(r,e,t)=>X5(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 Q5=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof P4?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")?e8(r,{all:t,dot:n}):{}};async function e8(r,e){const t=await r.formData();return t?t8(t,e):{}}function t8(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?r8(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(n8(t,n,s),delete t[n])}),t}var r8=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},n8=(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])})},f2=r=>T4(r,dx),hu,rs,Li,$4,Z4,Cb,ha,b4,P4=(b4=class{constructor(r,e="/",t=[[]]){At(this,Li);Pe(this,"raw");At(this,hu);At(this,rs);Pe(this,"routeIndex",0);Pe(this,"path");Pe(this,"bodyCache",{});At(this,ha,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,Fe(this,rs,t),Fe(this,hu,{})}param(r){return r?Pt(this,Li,$4).call(this,r):Pt(this,Li,Z4).call(this)}query(r){return L5(this.url,r)}queries(r){return q5(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 Q5(this,r))}json(){return V(this,ha).call(this,"json")}text(){return V(this,ha).call(this,"text")}arrayBuffer(){return V(this,ha).call(this,"arrayBuffer")}blob(){return V(this,ha).call(this,"blob")}formData(){return V(this,ha).call(this,"formData")}addValidatedData(r,e){V(this,hu)[r]=e}valid(r){return V(this,hu)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return V(this,rs)[0].map(([[,r]])=>r)}get routePath(){return V(this,rs)[0].map(([[,r]])=>r)[this.routeIndex].path}},hu=new WeakMap,rs=new WeakMap,Li=new WeakSet,$4=function(r){const e=V(this,rs)[0][this.routeIndex][1][r],t=Pt(this,Li,Cb).call(this,e);return t?/\%/.test(t)?f2(t):t:void 0},Z4=function(){const r={},e=Object.keys(V(this,rs)[0][this.routeIndex][1]);for(const t of e){const n=Pt(this,Li,Cb).call(this,V(this,rs)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?f2(n):n)}return r},Cb=function(r){return V(this,rs)[1]?V(this,rs)[1][r]:r},ha=new WeakMap,b4),s8={Stringify:1,BeforeStream:2,Stream:3},D4=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=>D4(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},i8="text/plain; charset=UTF-8",H0=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Pp,$p,fi,Oo,mi,ar,hr,$s,yi,Zp,pu,fu,Dp,Mp,Xr,In,_4,M4=(_4=class{constructor(r,e){At(this,Xr);At(this,Pp);At(this,$p);Pe(this,"env",{});At(this,fi);Pe(this,"finalized",!1);Pe(this,"error");At(this,Oo,200);At(this,mi);At(this,ar);At(this,hr);At(this,$s);At(this,yi,!0);At(this,Zp);At(this,pu);At(this,fu);At(this,Dp);At(this,Mp);Pe(this,"render",(...r)=>(V(this,pu)??Fe(this,pu,e=>this.html(e)),V(this,pu).call(this,...r)));Pe(this,"setLayout",r=>Fe(this,Zp,r));Pe(this,"getLayout",()=>V(this,Zp));Pe(this,"setRenderer",r=>{Fe(this,pu,r)});Pe(this,"header",(r,e,t)=>{if(e===void 0){V(this,ar)?V(this,ar).delete(r):V(this,hr)&&delete V(this,hr)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(V(this,ar)||(Fe(this,yi,!1),Fe(this,ar,new Headers(V(this,hr))),Fe(this,hr,{})),V(this,ar).append(r,e)):V(this,ar)?V(this,ar).set(r,e):(V(this,hr)??Fe(this,hr,{}),V(this,hr)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});Pe(this,"status",r=>{Fe(this,yi,!1),Fe(this,Oo,r)});Pe(this,"set",(r,e)=>{V(this,fi)??Fe(this,fi,new Map),V(this,fi).set(r,e)});Pe(this,"get",r=>V(this,fi)?V(this,fi).get(r):void 0);Pe(this,"newResponse",(...r)=>Pt(this,Xr,In).call(this,...r));Pe(this,"body",(r,e,t)=>typeof e=="number"?Pt(this,Xr,In).call(this,r,e,t):Pt(this,Xr,In).call(this,r,e));Pe(this,"text",(r,e,t)=>{if(!V(this,hr)){if(V(this,yi)&&!t&&!e)return new Response(r);Fe(this,hr,{})}return V(this,hr)["content-type"]=i8,typeof e=="number"?Pt(this,Xr,In).call(this,r,e,t):Pt(this,Xr,In).call(this,r,e)});Pe(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return V(this,hr)??Fe(this,hr,{}),V(this,hr)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Pt(this,Xr,In).call(this,n,e,t):Pt(this,Xr,In).call(this,n,e)});Pe(this,"html",(r,e,t)=>(V(this,hr)??Fe(this,hr,{}),V(this,hr)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?D4(r,s8.Stringify,!1,{}).then(n=>typeof e=="number"?Pt(this,Xr,In).call(this,n,e,t):Pt(this,Xr,In).call(this,n,e)):typeof e=="number"?Pt(this,Xr,In).call(this,r,e,t):Pt(this,Xr,In).call(this,r,e)));Pe(this,"redirect",(r,e)=>(V(this,ar)??Fe(this,ar,new Headers),V(this,ar).set("Location",String(r)),this.newResponse(null,e??302)));Pe(this,"notFound",()=>(V(this,fu)??Fe(this,fu,()=>new Response),V(this,fu).call(this,this)));Fe(this,Pp,r),e&&(Fe(this,mi,e.executionCtx),this.env=e.env,Fe(this,fu,e.notFoundHandler),Fe(this,Mp,e.path),Fe(this,Dp,e.matchResult))}get req(){return V(this,$p)??Fe(this,$p,new P4(V(this,Pp),V(this,Mp),V(this,Dp))),V(this,$p)}get event(){if(V(this,mi)&&"respondWith"in V(this,mi))return V(this,mi);throw Error("This context has no FetchEvent")}get executionCtx(){if(V(this,mi))return V(this,mi);throw Error("This context has no ExecutionContext")}get res(){return Fe(this,yi,!1),V(this,$s)||Fe(this,$s,new Response("404 Not Found",{status:404}))}set res(r){if(Fe(this,yi,!1),V(this,$s)&&r)try{for(const[e,t]of V(this,$s).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=V(this,$s).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}Fe(this,$s,r),this.finalized=!0}get var(){return V(this,fi)?Object.fromEntries(V(this,fi)):{}}},Pp=new WeakMap,$p=new WeakMap,fi=new WeakMap,Oo=new WeakMap,mi=new WeakMap,ar=new WeakMap,hr=new WeakMap,$s=new WeakMap,yi=new WeakMap,Zp=new WeakMap,pu=new WeakMap,fu=new WeakMap,Dp=new WeakMap,Mp=new WeakMap,Xr=new WeakSet,In=function(r,e,t){if(V(this,yi)&&!t&&!e&&V(this,Oo)===200)return new Response(r,{headers:V(this,hr)});if(e&&typeof e!="number"){const s=new Headers(e.headers);V(this,ar)&&V(this,ar).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=H0(s,V(this,hr));return new Response(r,{headers:i,status:e.status??V(this,Oo)})}const n=typeof e=="number"?e:V(this,Oo);V(this,hr)??Fe(this,hr,{}),V(this,ar)??Fe(this,ar,new Headers),H0(V(this,ar),V(this,hr)),V(this,$s)&&(V(this,$s).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=V(this,ar))==null||a.append(i,s):(o=V(this,ar))==null||o.set(i,s)}),H0(V(this,ar),V(this,hr))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")V(this,ar).set(s,i);else{V(this,ar).delete(s);for(const a of i)V(this,ar).append(s,a)}return new Response(r,{status:n,headers:V(this,ar)})},_4),m2=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof M4;return o(0);async function o(c){if(c<=i)throw new Error("next() called multiple times");i=c;let u,l=!1,h;if(r[c]?(h=r[c][0][0],a&&(n.req.routeIndex=c)):h=c===r.length&&s||void 0,!h)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await h(n,()=>o(c+1))}catch(R){if(R instanceof Error&&a&&e)n.error=R,u=await e(R,n),l=!0;else throw R}return u&&(n.finalized===!1||l)&&(n.res=u),n}},mr="ALL",a8="all",o8=["get","post","put","delete","options","patch"],U4="Can not add a route since the matcher is already built.",V4=class extends Error{},c8=Symbol("composedHandler"),u8=r=>r.text("404 Not Found",404),y2=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),ns,gr,q4,gi,fo,Gf,Jf,w4,L4=(w4=class{constructor(e={}){At(this,gr);Pe(this,"get");Pe(this,"post");Pe(this,"put");Pe(this,"delete");Pe(this,"options");Pe(this,"patch");Pe(this,"all");Pe(this,"on");Pe(this,"use");Pe(this,"router");Pe(this,"getPath");Pe(this,"_basePath","/");At(this,ns,"/");Pe(this,"routes",[]);At(this,gi,u8);Pe(this,"errorHandler",y2);Pe(this,"onError",e=>(this.errorHandler=e,this));Pe(this,"notFound",e=>(Fe(this,gi,e),this));Pe(this,"fetch",(e,...t)=>Pt(this,gr,Jf).call(this,e,t[1],t[0],e.method));Pe(this,"request",(e,t,n,s)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,s):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${sa("/",e)}`,t),n,s)));Pe(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Pt(this,gr,Jf).call(this,e.request,e,void 0,e.request.method))})});[...o8,a8].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?Fe(this,ns,i):Pt(this,gr,fo).call(this,s,V(this,ns),i),a.forEach(o=>{Pt(this,gr,fo).call(this,s,V(this,ns),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){Fe(this,ns,o);for(const c of[s].flat())a.map(u=>{Pt(this,gr,fo).call(this,c.toUpperCase(),V(this,ns),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?Fe(this,ns,s):(Fe(this,ns,"*"),i.unshift(s)),i.forEach(a=>{Pt(this,gr,fo).call(this,mr,V(this,ns),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??N4:V5}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{var a;let i;t.errorHandler===y2?i=s.handler:(i=async(o,c)=>(await m2([],t.errorHandler)(o,()=>s.handler(o,c))).res,i[c8]=s.handler),Pt(a=n,gr,fo).call(a,s.method,s.path,i)}),this}basePath(e){const t=Pt(this,gr,q4).call(this);return t._basePath=sa(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=sa(this._basePath,e),u=c==="/"?0:c.length;return l=>{const h=new URL(l.url);return h.pathname=h.pathname.slice(u)||"/",new Request(h,l)}})());const o=async(c,u)=>{const l=await t(s(c.req.raw),...a(c));if(l)return l;await u()};return Pt(this,gr,fo).call(this,mr,sa(e,"*"),o),this}},ns=new WeakMap,gr=new WeakSet,q4=function(){const e=new L4({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},gi=new WeakMap,fo=function(e,t,n){e=e.toUpperCase(),t=sa(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)},Gf=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Jf=function(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await Pt(this,gr,Jf).call(this,e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.router.match(s,i),o=new M4(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:V(this,gi)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await V(this,gi).call(this,o)})}catch(l){return Pt(this,gr,Gf).call(this,l,o)}return u instanceof Promise?u.then(l=>l||(o.finalized?o.res:V(this,gi).call(this,o))).catch(l=>Pt(this,gr,Gf).call(this,l,o)):u??V(this,gi).call(this,o)}const c=m2(a[0],this.errorHandler,V(this,gi));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 Pt(this,gr,Gf).call(this,u,o)}})()},w4),gm="[^/]+",yd=".*",gd="(?:|/.*)",Jl=Symbol(),l8=new Set(".\\+*[^]$()");function d8(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===yd||r===gd?1:e===yd||e===gd?-1:r===gm?1:e===gm?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var jo,Co,ss,x4,Eb=(x4=class{constructor(){At(this,jo);At(this,Co);At(this,ss,Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(V(this,jo)!==void 0)throw Jl;if(i)return;Fe(this,jo,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",yd]:["","",gm]:a==="/*"?["","",gd]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const l=c[1];let h=c[2]||gm;if(l&&c[2]&&(h=h.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(h)))throw Jl;if(u=V(this,ss)[h],!u){if(Object.keys(V(this,ss)).some(R=>R!==yd&&R!==gd))throw Jl;if(i)return;u=V(this,ss)[h]=new Eb,l!==""&&Fe(u,Co,s.varIndex++)}!i&&l!==""&&n.push([l,V(u,Co)])}else if(u=V(this,ss)[a],!u){if(Object.keys(V(this,ss)).some(l=>l.length>1&&l!==yd&&l!==gd))throw Jl;if(i)return;u=V(this,ss)[a]=new Eb}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(V(this,ss)).sort(d8).map(n=>{const s=V(this,ss)[n];return(typeof V(s,Co)=="number"?`(${n})@${V(s,Co)}`:l8.has(n)?`\\${n}`:n)+s.buildRegExpStr()});return typeof V(this,jo)=="number"&&t.unshift(`#${V(this,jo)}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},jo=new WeakMap,Co=new WeakMap,ss=new WeakMap,x4),qg,Up,k4,h8=(k4=class{constructor(){At(this,qg,{varIndex:0});At(this,Up,new Eb)}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 V(this,Up).insert(i,e,n,V(this,qg),t),n}buildRegExp(){let r=V(this,Up).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]}},qg=new WeakMap,Up=new WeakMap,k4),H4=[],p8=[/^$/,[],Object.create(null)],Yf=Object.create(null);function F4(r){return Yf[r]??(Yf[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function f8(){Yf=Object.create(null)}function m8(r){var u;const e=new h8,t=[];if(r.length===0)return p8;const n=r.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,h],[R,B])=>l?1:R?-1:h.length-B.length),s=Object.create(null);for(let l=0,h=-1,R=n.length;l<R;l++){const[B,d,g]=n[l];B?s[d]=[g.map(([O])=>[O,Object.create(null)]),H4]:h++;let A;try{A=e.insert(d,h,B)}catch(O){throw O===Jl?new V4(d):O}B||(t[h]=g.map(([O,$])=>{const P=Object.create(null);for($-=1;$>=0;$--){const[ae,Re]=A[$];P[ae]=Re}return[O,P]}))}const[i,a,o]=e.buildRegExp();for(let l=0,h=t.length;l<h;l++)for(let R=0,B=t[l].length;R<B;R++){const d=(u=t[l][R])==null?void 0:u[1];if(!d)continue;const g=Object.keys(d);for(let A=0,O=g.length;A<O;A++)d[g[A]]=o[d[g[A]]]}const c=[];for(const l in a)c[l]=t[a[l]];return[i,c,s]}function Ic(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(F4(t).test(e))return[...r[t]]}}var pa,fa,sl,K4,z4,S4,y8=(S4=class{constructor(){At(this,sl);Pe(this,"name","RegExpRouter");At(this,pa);At(this,fa);Fe(this,pa,{[mr]:Object.create(null)}),Fe(this,fa,{[mr]:Object.create(null)})}add(r,e,t){var o;const n=V(this,pa),s=V(this,fa);if(!n||!s)throw new Error(U4);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[mr]).forEach(u=>{c[r][u]=[...c[mr][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=F4(e);r===mr?Object.keys(n).forEach(u=>{var l;(l=n[u])[e]||(l[e]=Ic(n[u],e)||Ic(n[mr],e)||[])}):(o=n[r])[e]||(o[e]=Ic(n[r],e)||Ic(n[mr],e)||[]),Object.keys(n).forEach(u=>{(r===mr||r===u)&&Object.keys(n[u]).forEach(l=>{c.test(l)&&n[u][l].push([t,i])})}),Object.keys(s).forEach(u=>{(r===mr||r===u)&&Object.keys(s[u]).forEach(l=>c.test(l)&&s[u][l].push([t,i]))});return}const a=B4(e)||[e];for(let c=0,u=a.length;c<u;c++){const l=a[c];Object.keys(s).forEach(h=>{var R;(r===mr||r===h)&&((R=s[h])[l]||(R[l]=[...Ic(n[h],l)||Ic(n[mr],l)||[]]),s[h][l].push([t,i-u+c+1]))})}}match(r,e){f8();const t=Pt(this,sl,K4).call(this);return this.match=(n,s)=>{const i=t[n]||t[mr],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],H4];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},pa=new WeakMap,fa=new WeakMap,sl=new WeakSet,K4=function(){const r=Object.create(null);return Object.keys(V(this,fa)).concat(Object.keys(V(this,pa))).forEach(e=>{r[e]||(r[e]=Pt(this,sl,z4).call(this,e))}),Fe(this,pa,Fe(this,fa,void 0)),r},z4=function(r){const e=[];let t=r===mr;return[V(this,pa),V(this,fa)].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!==mr&&e.push(...Object.keys(n[mr]).map(i=>[i,n[mr][i]]))}),t?m8(e):null},S4),ma,vi,A4,g8=(A4=class{constructor(r){Pe(this,"name","SmartRouter");At(this,ma,[]);At(this,vi,[]);Fe(this,ma,r.routers)}add(r,e,t){if(!V(this,vi))throw new Error(U4);V(this,vi).push([r,e,t])}match(r,e){if(!V(this,vi))throw new Error("Fatal error");const t=V(this,ma),n=V(this,vi),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 V4)continue;throw c}this.match=o.match.bind(o),Fe(this,ma,[o]),Fe(this,vi,void 0);break}if(i===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(V(this,vi)||V(this,ma).length!==1)throw new Error("No active router has been determined yet.");return V(this,ma)[0]}},ma=new WeakMap,vi=new WeakMap,A4),ya,Dr,Eo,mu,Qr,bi,mo,O4,W4=(O4=class{constructor(r,e,t){At(this,bi);At(this,ya);At(this,Dr);At(this,Eo);At(this,mu,0);At(this,Qr,Object.create(null));if(Fe(this,Dr,t||Object.create(null)),Fe(this,ya,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},Fe(this,ya,[n])}Fe(this,Eo,[])}insert(r,e,t){Fe(this,mu,++d2(this,mu)._);let n=this;const s=Z5(e),i=[];for(let c=0,u=s.length;c<u;c++){const l=s[c];if(Object.keys(V(n,Dr)).includes(l)){n=V(n,Dr)[l];const R=p2(l);R&&i.push(R[1]);continue}V(n,Dr)[l]=new W4;const h=p2(l);h&&(V(n,Eo).push(h),i.push(h[1])),n=V(n,Dr)[l]}const a=Object.create(null),o={handler:t,possibleKeys:i.filter((c,u,l)=>l.indexOf(c)===u),score:V(this,mu)};return a[r]=o,V(n,ya).push(a),n}search(r,e){const t=[];Fe(this,Qr,Object.create(null));let s=[this];const i=I4(e);for(let o=0,c=i.length;o<c;o++){const u=i[o],l=o===c-1,h=[];for(let R=0,B=s.length;R<B;R++){const d=s[R],g=V(d,Dr)[u];g&&(Fe(g,Qr,V(d,Qr)),l?(V(g,Dr)["*"]&&t.push(...Pt(this,bi,mo).call(this,V(g,Dr)["*"],r,V(d,Qr),Object.create(null))),t.push(...Pt(this,bi,mo).call(this,g,r,V(d,Qr),Object.create(null)))):h.push(g));for(let A=0,O=V(d,Eo).length;A<O;A++){const $=V(d,Eo)[A],P={...V(d,Qr)};if($==="*"){const Gt=V(d,Dr)["*"];Gt&&(t.push(...Pt(this,bi,mo).call(this,Gt,r,V(d,Qr),Object.create(null))),h.push(Gt));continue}if(u==="")continue;const[ae,Re,He]=$,Te=V(d,Dr)[ae],Nt=i.slice(o).join("/");if(He instanceof RegExp&&He.test(Nt)){P[Re]=Nt,t.push(...Pt(this,bi,mo).call(this,Te,r,V(d,Qr),P));continue}(He===!0||He.test(u))&&(P[Re]=u,l?(t.push(...Pt(this,bi,mo).call(this,Te,r,P,V(d,Qr))),V(Te,Dr)["*"]&&t.push(...Pt(this,bi,mo).call(this,V(Te,Dr)["*"],r,P,V(d,Qr)))):(Fe(Te,Qr,P),h.push(Te)))}}s=h}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},ya=new WeakMap,Dr=new WeakMap,Eo=new WeakMap,mu=new WeakMap,Qr=new WeakMap,bi=new WeakSet,mo=function(r,e,t,n){const s=[];for(let i=0,a=V(r,ya).length;i<a;i++){const o=V(r,ya)[i],c=o[e]||o[mr],u={};if(c!==void 0){c.params=Object.create(null);for(let l=0,h=c.possibleKeys.length;l<h;l++){const R=c.possibleKeys[l],B=u[c.score];c.params[R]=n[R]&&!B?n[R]:t[R]??n[R],u[c.score]=!0}s.push(c)}}return s},O4),Io,j4,v8=(j4=class{constructor(){Pe(this,"name","TrieRouter");At(this,Io);Fe(this,Io,new W4)}add(r,e,t){const n=B4(e);if(n){for(let s=0,i=n.length;s<i;s++)V(this,Io).insert(r,n[s],t);return}V(this,Io).insert(r,e,t)}match(r,e){return V(this,Io).search(r,e)}},Io=new WeakMap,j4),b8=class extends L4{constructor(r={}){super(r),this.router=r.router??new g8({routers:[new y8,new v8]})}},Zt;(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})(Zt||(Zt={}));var Ib;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ib||(Ib={}));const we=Zt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ia=r=>{switch(typeof r){case"undefined":return we.undefined;case"string":return we.string;case"number":return isNaN(r)?we.nan:we.number;case"boolean":return we.boolean;case"function":return we.function;case"bigint":return we.bigint;case"symbol":return we.symbol;case"object":return Array.isArray(r)?we.array:r===null?we.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?we.promise:typeof Map<"u"&&r instanceof Map?we.map:typeof Set<"u"&&r instanceof Set?we.set:typeof Date<"u"&&r instanceof Date?we.date:we.object;default:return we.unknown}},ee=Zt.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"]),_8=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let ds=class G4 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 G4))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Zt.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()}};ds.create=r=>new ds(r);const yu=(r,e)=>{let t;switch(r.code){case ee.invalid_type:r.received===we.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case ee.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Zt.jsonStringifyReplacer)}`;break;case ee.unrecognized_keys:t=`Unrecognized key(s) in object: ${Zt.joinValues(r.keys,", ")}`;break;case ee.invalid_union:t="Invalid input";break;case ee.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Zt.joinValues(r.options)}`;break;case ee.invalid_enum_value:t=`Invalid enum value. Expected ${Zt.joinValues(r.options)}, received '${r.received}'`;break;case ee.invalid_arguments:t="Invalid function arguments";break;case ee.invalid_return_type:t="Invalid function return type";break;case ee.invalid_date:t="Invalid date";break;case ee.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}"`:Zt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case ee.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 ee.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 ee.custom:t="Invalid input";break;case ee.invalid_intersection_types:t="Intersection results could not be merged";break;case ee.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case ee.not_finite:t="Number must be finite";break;default:t=e.defaultError,Zt.assertNever(r)}return{message:t}};let J4=yu;function w8(r){J4=r}function vm(){return J4}const bm=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}},x8=[];function me(r,e){const t=vm(),n=bm({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===yu?void 0:yu].filter(s=>!!s)});r.common.issues.push(n)}let sn=class Y4{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 tt;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 Y4.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 tt;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 tt=Object.freeze({status:"aborted"}),Jc=r=>({status:"dirty",value:r}),Vr=r=>({status:"valid",value:r}),Tb=r=>r.status==="aborted",Nb=r=>r.status==="dirty",Td=r=>r.status==="valid",Nd=r=>typeof Promise<"u"&&r instanceof Promise;function _m(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 X4(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 De;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(De||(De={}));var Yl,Xl;let Fs=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 g2=(r,e)=>{if(Td(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 ds(r.common.issues);return this._error=t,this._error}}};function ft(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:l}=r;return a.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(c=l??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}let kt=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 ia(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ia(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new sn,ctx:{common:e.parent.common,data:e.data,parsedType:ia(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Nd(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:ia(e)},i=this._parseSync({data:e,path:s.path,parent:s});return g2(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:ia(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Nd(s)?s:Promise.resolve(s));return g2(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:ee.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 bs({schema:this,typeName:Ge.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Zs.create(this,this._def)}nullable(){return Oa.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Vo.create(this,this._def)}promise(){return bu.create(this,this._def)}or(e){return Md.create([this,e],this._def)}and(e){return Ud.create(this,e,this._def)}transform(e){return new bs({...ft(this._def),schema:this,typeName:Ge.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Hd({...ft(this._def),innerType:this,defaultValue:t,typeName:Ge.ZodDefault})}brand(){return new hx({typeName:Ge.ZodBranded,type:this,...ft(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Fd({...ft(this._def),innerType:this,catchValue:t,typeName:Ge.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return px.create(this,e)}readonly(){return Kd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const k8=/^c[^\s-]{8,}$/i,S8=/^[0-9a-z]+$/,A8=/^[0-9A-HJKMNP-TV-Z]{26}$/,O8=/^[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,j8=/^[a-z0-9_-]{21}$/i,C8=/^[-+]?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)?)??$/,E8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,I8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let F0;const T8=/^(?:(?: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])$/,N8=/^(([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})))$/,B8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Q4="((\\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])))",R8=new RegExp(`^${Q4}$`);function ej(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 P8(r){return new RegExp(`^${ej(r)}$`)}function tj(r){let e=`${Q4}T${ej(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 $8(r,e){return!!((e==="v4"||!e)&&T8.test(r)||(e==="v6"||!e)&&N8.test(r))}let gu=class Ql extends kt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==we.string){const i=this._getOrReturnCtx(e);return me(i,{code:ee.invalid_type,expected:we.string,received:i.parsedType}),tt}const n=new sn;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),me(s,{code:ee.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),me(s,{code:ee.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?me(s,{code:ee.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&me(s,{code:ee.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")E8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"email",code:ee.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")F0||(F0=new RegExp(I8,"u")),F0.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"emoji",code:ee.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")O8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"uuid",code:ee.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")j8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"nanoid",code:ee.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")k8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"cuid",code:ee.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")S8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"cuid2",code:ee.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")A8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"ulid",code:ee.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),me(s,{validation:"url",code:ee.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),me(s,{validation:"regex",code:ee.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),me(s,{code:ee.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),me(s,{code:ee.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),me(s,{code:ee.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?tj(i).test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{code:ee.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?R8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{code:ee.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?P8(i).test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{code:ee.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?C8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"duration",code:ee.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?$8(e.data,i.version)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"ip",code:ee.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?B8.test(e.data)||(s=this._getOrReturnCtx(e,s),me(s,{validation:"base64",code:ee.invalid_string,message:i.message}),n.dirty()):Zt.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:ee.invalid_string,...De.errToObj(n)})}_addCheck(e){return new Ql({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...De.errToObj(e)})}url(e){return this._addCheck({kind:"url",...De.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...De.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...De.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...De.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...De.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...De.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...De.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...De.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...De.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,...De.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,...De.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...De.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...De.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...De.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...De.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...De.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...De.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...De.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...De.errToObj(t)})}nonempty(e){return this.min(1,De.errToObj(e))}trim(){return new Ql({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ql({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ql({...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}};gu.create=r=>{var e;return new gu({checks:[],typeName:Ge.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ft(r)})};function Z8(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 Bd=class Bb extends kt{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)!==we.number){const i=this._getOrReturnCtx(e);return me(i,{code:ee.invalid_type,expected:we.number,received:i.parsedType}),tt}let n;const s=new sn;for(const i of this._def.checks)i.kind==="int"?Zt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),me(n,{code:ee.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),me(n,{code:ee.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),me(n,{code:ee.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Z8(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),me(n,{code:ee.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),me(n,{code:ee.not_finite,message:i.message}),s.dirty()):Zt.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,De.toString(t))}gt(e,t){return this.setLimit("min",e,!1,De.toString(t))}lte(e,t){return this.setLimit("max",e,!0,De.toString(t))}lt(e,t){return this.setLimit("max",e,!1,De.toString(t))}setLimit(e,t,n,s){return new Bb({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:De.toString(s)}]})}_addCheck(e){return new Bb({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:De.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:De.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:De.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:De.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:De.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:De.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:De.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:De.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:De.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"&&Zt.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)}};Bd.create=r=>new Bd({checks:[],typeName:Ge.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ft(r)});let Rd=class Rb extends kt{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)!==we.bigint){const i=this._getOrReturnCtx(e);return me(i,{code:ee.invalid_type,expected:we.bigint,received:i.parsedType}),tt}let n;const s=new sn;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),me(n,{code:ee.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),me(n,{code:ee.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),me(n,{code:ee.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Zt.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,De.toString(t))}gt(e,t){return this.setLimit("min",e,!1,De.toString(t))}lte(e,t){return this.setLimit("max",e,!0,De.toString(t))}lt(e,t){return this.setLimit("max",e,!1,De.toString(t))}setLimit(e,t,n,s){return new Rb({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:De.toString(s)}]})}_addCheck(e){return new Rb({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:De.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:De.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:De.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:De.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:De.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}};Rd.create=r=>{var e;return new Rd({checks:[],typeName:Ge.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ft(r)})};let Pd=class extends kt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==we.boolean){const n=this._getOrReturnCtx(e);return me(n,{code:ee.invalid_type,expected:we.boolean,received:n.parsedType}),tt}return Vr(e.data)}};Pd.create=r=>new Pd({typeName:Ge.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ft(r)});let $d=class rj extends kt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==we.date){const i=this._getOrReturnCtx(e);return me(i,{code:ee.invalid_type,expected:we.date,received:i.parsedType}),tt}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return me(i,{code:ee.invalid_date}),tt}const n=new sn;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),me(s,{code:ee.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),me(s,{code:ee.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Zt.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new rj({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:De.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:De.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}};$d.create=r=>new $d({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Ge.ZodDate,...ft(r)});let wm=class extends kt{_parse(e){if(this._getType(e)!==we.symbol){const n=this._getOrReturnCtx(e);return me(n,{code:ee.invalid_type,expected:we.symbol,received:n.parsedType}),tt}return Vr(e.data)}};wm.create=r=>new wm({typeName:Ge.ZodSymbol,...ft(r)});let Zd=class extends kt{_parse(e){if(this._getType(e)!==we.undefined){const n=this._getOrReturnCtx(e);return me(n,{code:ee.invalid_type,expected:we.undefined,received:n.parsedType}),tt}return Vr(e.data)}};Zd.create=r=>new Zd({typeName:Ge.ZodUndefined,...ft(r)});let Dd=class extends kt{_parse(e){if(this._getType(e)!==we.null){const n=this._getOrReturnCtx(e);return me(n,{code:ee.invalid_type,expected:we.null,received:n.parsedType}),tt}return Vr(e.data)}};Dd.create=r=>new Dd({typeName:Ge.ZodNull,...ft(r)});let vu=class extends kt{constructor(){super(...arguments),this._any=!0}_parse(e){return Vr(e.data)}};vu.create=r=>new vu({typeName:Ge.ZodAny,...ft(r)});let To=class extends kt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Vr(e.data)}};To.create=r=>new To({typeName:Ge.ZodUnknown,...ft(r)});let Oi=class extends kt{_parse(e){const t=this._getOrReturnCtx(e);return me(t,{code:ee.invalid_type,expected:we.never,received:t.parsedType}),tt}};Oi.create=r=>new Oi({typeName:Ge.ZodNever,...ft(r)});let xm=class extends kt{_parse(e){if(this._getType(e)!==we.undefined){const n=this._getOrReturnCtx(e);return me(n,{code:ee.invalid_type,expected:we.void,received:n.parsedType}),tt}return Vr(e.data)}};xm.create=r=>new xm({typeName:Ge.ZodVoid,...ft(r)});let Vo=class Xf extends kt{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==we.array)return me(t,{code:ee.invalid_type,expected:we.array,received:t.parsedType}),tt;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(me(t,{code:a?ee.too_big:ee.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&&(me(t,{code:ee.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&&(me(t,{code:ee.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 Fs(t,a,t.path,o)))).then(a=>sn.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Fs(t,a,t.path,o)));return sn.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Xf({...this._def,minLength:{value:e,message:De.toString(t)}})}max(e,t){return new Xf({...this._def,maxLength:{value:e,message:De.toString(t)}})}length(e,t){return new Xf({...this._def,exactLength:{value:e,message:De.toString(t)}})}nonempty(e){return this.min(1,e)}};Vo.create=(r,e)=>new Vo({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Ge.ZodArray,...ft(e)});function Hc(r){if(r instanceof Mn){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Zs.create(Hc(n))}return new Mn({...r._def,shape:()=>e})}else return r instanceof Vo?new Vo({...r._def,type:Hc(r.element)}):r instanceof Zs?Zs.create(Hc(r.unwrap())):r instanceof Oa?Oa.create(Hc(r.unwrap())):r instanceof Aa?Aa.create(r.items.map(e=>Hc(e))):r}let Mn=class Jn extends kt{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=Zt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==we.object){const u=this._getOrReturnCtx(e);return me(u,{code:ee.invalid_type,expected:we.object,received:u.parsedType}),tt}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Oi&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const l=i[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Fs(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Oi){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(me(s,{code:ee.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 l of o){const h=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Fs(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const h=await l.key,R=await l.value;u.push({key:h,value:R,alwaysSet:l.alwaysSet})}return u}).then(u=>sn.mergeObjectSync(n,u)):sn.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return De.errToObj,new Jn({...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=De.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Jn({...this._def,unknownKeys:"strip"})}passthrough(){return new Jn({...this._def,unknownKeys:"passthrough"})}extend(e){return new Jn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Jn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ge.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Jn({...this._def,catchall:e})}pick(e){const t={};return Zt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Jn({...this._def,shape:()=>t})}omit(e){const t={};return Zt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Jn({...this._def,shape:()=>t})}deepPartial(){return Hc(this)}partial(e){const t={};return Zt.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Jn({...this._def,shape:()=>t})}required(e){const t={};return Zt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof Zs;)i=i._def.innerType;t[n]=i}}),new Jn({...this._def,shape:()=>t})}keyof(){return cj(Zt.objectKeys(this.shape))}};Mn.create=(r,e)=>new Mn({shape:()=>r,unknownKeys:"strip",catchall:Oi.create(),typeName:Ge.ZodObject,...ft(e)});Mn.strictCreate=(r,e)=>new Mn({shape:()=>r,unknownKeys:"strict",catchall:Oi.create(),typeName:Ge.ZodObject,...ft(e)});Mn.lazycreate=(r,e)=>new Mn({shape:r,unknownKeys:"strip",catchall:Oi.create(),typeName:Ge.ZodObject,...ft(e)});let Md=class extends kt{_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 ds(o.ctx.common.issues));return me(t,{code:ee.invalid_union,unionErrors:a}),tt}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},l=c._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,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 ds(c));return me(t,{code:ee.invalid_union,unionErrors:o}),tt}}get options(){return this._def.options}};Md.create=(r,e)=>new Md({options:r,typeName:Ge.ZodUnion,...ft(e)});const di=r=>r instanceof Vd?di(r.schema):r instanceof bs?di(r.innerType()):r instanceof Ld?[r.value]:r instanceof Vp?r.options:r instanceof qd?Zt.objectValues(r.enum):r instanceof Hd?di(r._def.innerType):r instanceof Zd?[void 0]:r instanceof Dd?[null]:r instanceof Zs?[void 0,...di(r.unwrap())]:r instanceof Oa?[null,...di(r.unwrap())]:r instanceof hx||r instanceof Kd?di(r.unwrap()):r instanceof Fd?di(r._def.innerType):[];let nj=class sj extends kt{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.object)return me(t,{code:ee.invalid_type,expected:we.object,received:t.parsedType}),tt;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}):(me(t,{code:ee.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),tt)}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=di(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 sj({typeName:Ge.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ft(n)})}};function Pb(r,e){const t=ia(r),n=ia(e);if(r===e)return{valid:!0,data:r};if(t===we.object&&n===we.object){const s=Zt.objectKeys(e),i=Zt.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Pb(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===we.array&&n===we.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=Pb(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===we.date&&n===we.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Ud=class extends kt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Tb(i)||Tb(a))return tt;const o=Pb(i.value,a.value);return o.valid?((Nb(i)||Nb(a))&&t.dirty(),{status:t.value,value:o.data}):(me(n,{code:ee.invalid_intersection_types}),tt)};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}))}};Ud.create=(r,e,t)=>new Ud({left:r,right:e,typeName:Ge.ZodIntersection,...ft(t)});let Aa=class ij extends kt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==we.array)return me(n,{code:ee.invalid_type,expected:we.array,received:n.parsedType}),tt;if(n.data.length<this._def.items.length)return me(n,{code:ee.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),tt;!this._def.rest&&n.data.length>this._def.items.length&&(me(n,{code:ee.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 Fs(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>sn.mergeArray(t,a)):sn.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new ij({...this._def,rest:e})}};Aa.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Aa({items:r,typeName:Ge.ZodTuple,rest:null,...ft(e)})};let aj=class $b extends kt{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!==we.object)return me(n,{code:ee.invalid_type,expected:we.object,received:n.parsedType}),tt;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Fs(n,o,n.path,o)),value:a._parse(new Fs(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?sn.mergeObjectAsync(t,s):sn.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof kt?new $b({keyType:e,valueType:t,typeName:Ge.ZodRecord,...ft(n)}):new $b({keyType:gu.create(),valueType:e,typeName:Ge.ZodRecord,...ft(t)})}},km=class extends kt{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!==we.map)return me(n,{code:ee.invalid_type,expected:we.map,received:n.parsedType}),tt;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Fs(n,o,n.path,[u,"key"])),value:i._parse(new Fs(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,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return tt;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return tt;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}};km.create=(r,e,t)=>new km({valueType:e,keyType:r,typeName:Ge.ZodMap,...ft(t)});let Sm=class Zb extends kt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==we.set)return me(n,{code:ee.invalid_type,expected:we.set,received:n.parsedType}),tt;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(me(n,{code:ee.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&&(me(n,{code:ee.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 l of c){if(l.status==="aborted")return tt;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Fs(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Zb({...this._def,minSize:{value:e,message:De.toString(t)}})}max(e,t){return new Zb({...this._def,maxSize:{value:e,message:De.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Sm.create=(r,e)=>new Sm({valueType:r,minSize:null,maxSize:null,typeName:Ge.ZodSet,...ft(e)});let oj=class Qf extends kt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.function)return me(t,{code:ee.invalid_type,expected:we.function,received:t.parsedType}),tt;function n(o,c){return bm({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,vm(),yu].filter(u=>!!u),issueData:{code:ee.invalid_arguments,argumentsError:c}})}function s(o,c){return bm({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,vm(),yu].filter(u=>!!u),issueData:{code:ee.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof bu){const o=this;return Vr(async function(...c){const u=new ds([]),l=await o._def.args.parseAsync(c,i).catch(B=>{throw u.addIssue(n(c,B)),u}),h=await Reflect.apply(a,this,l);return await o._def.returns._def.type.parseAsync(h,i).catch(B=>{throw u.addIssue(s(h,B)),u})})}else{const o=this;return Vr(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new ds([n(c,u.error)]);const l=Reflect.apply(a,this,u.data),h=o._def.returns.safeParse(l,i);if(!h.success)throw new ds([s(l,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Qf({...this._def,args:Aa.create(e).rest(To.create())})}returns(e){return new Qf({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Qf({args:e||Aa.create([]).rest(To.create()),returns:t||To.create(),typeName:Ge.ZodFunction,...ft(n)})}},Vd=class extends kt{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})}};Vd.create=(r,e)=>new Vd({getter:r,typeName:Ge.ZodLazy,...ft(e)});let Ld=class extends kt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return me(t,{received:t.data,code:ee.invalid_literal,expected:this._def.value}),tt}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ld.create=(r,e)=>new Ld({value:r,typeName:Ge.ZodLiteral,...ft(e)});function cj(r,e){return new Vp({values:r,typeName:Ge.ZodEnum,...ft(e)})}let Vp=class Db extends kt{constructor(){super(...arguments),Yl.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return me(t,{expected:Zt.joinValues(n),received:t.parsedType,code:ee.invalid_type}),tt}if(_m(this,Yl)||X4(this,Yl,new Set(this._def.values)),!_m(this,Yl).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return me(t,{received:t.data,code:ee.invalid_enum_value,options:n}),tt}return Vr(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 Db.create(e,{...this._def,...t})}exclude(e,t=this._def){return Db.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Yl=new WeakMap;Vp.create=cj;let qd=class extends kt{constructor(){super(...arguments),Xl.set(this,void 0)}_parse(e){const t=Zt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==we.string&&n.parsedType!==we.number){const s=Zt.objectValues(t);return me(n,{expected:Zt.joinValues(s),received:n.parsedType,code:ee.invalid_type}),tt}if(_m(this,Xl)||X4(this,Xl,new Set(Zt.getValidEnumValues(this._def.values))),!_m(this,Xl).has(e.data)){const s=Zt.objectValues(t);return me(n,{received:n.data,code:ee.invalid_enum_value,options:s}),tt}return Vr(e.data)}get enum(){return this._def.values}};Xl=new WeakMap;qd.create=(r,e)=>new qd({values:r,typeName:Ge.ZodNativeEnum,...ft(e)});let bu=class extends kt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==we.promise&&t.common.async===!1)return me(t,{code:ee.invalid_type,expected:we.promise,received:t.parsedType}),tt;const n=t.parsedType===we.promise?t.data:Promise.resolve(t.data);return Vr(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};bu.create=(r,e)=>new bu({type:r,typeName:Ge.ZodPromise,...ft(e)});let bs=class extends kt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ge.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=>{me(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 tt;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?tt:c.status==="dirty"||t.value==="dirty"?Jc(c.value):c});{if(t.value==="aborted")return tt;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?tt:o.status==="dirty"||t.value==="dirty"?Jc(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"?tt:(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"?tt:(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(!Td(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=>Td(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Zt.assertNever(s)}};bs.create=(r,e,t)=>new bs({schema:r,typeName:Ge.ZodEffects,effect:e,...ft(t)});bs.createWithPreprocess=(r,e,t)=>new bs({schema:e,effect:{type:"preprocess",transform:r},typeName:Ge.ZodEffects,...ft(t)});let Zs=class extends kt{_parse(e){return this._getType(e)===we.undefined?Vr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Zs.create=(r,e)=>new Zs({innerType:r,typeName:Ge.ZodOptional,...ft(e)});let Oa=class extends kt{_parse(e){return this._getType(e)===we.null?Vr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Oa.create=(r,e)=>new Oa({innerType:r,typeName:Ge.ZodNullable,...ft(e)});let Hd=class extends kt{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===we.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Hd.create=(r,e)=>new Hd({innerType:r,typeName:Ge.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ft(e)});let Fd=class extends kt{_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 Nd(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ds(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ds(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Fd.create=(r,e)=>new Fd({innerType:r,typeName:Ge.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ft(e)});let Am=class extends kt{_parse(e){if(this._getType(e)!==we.nan){const n=this._getOrReturnCtx(e);return me(n,{code:ee.invalid_type,expected:we.nan,received:n.parsedType}),tt}return{status:"valid",value:e.data}}};Am.create=r=>new Am({typeName:Ge.ZodNaN,...ft(r)});const D8=Symbol("zod_brand");let hx=class extends kt{_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}},px=class uj extends kt{_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"?tt:i.status==="dirty"?(t.dirty(),Jc(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"?tt: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 uj({in:e,out:t,typeName:Ge.ZodPipeline})}},Kd=class extends kt{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Td(s)&&(s.value=Object.freeze(s.value)),s);return Nd(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};Kd.create=(r,e)=>new Kd({innerType:r,typeName:Ge.ZodReadonly,...ft(e)});function lj(r,e={},t){return r?vu.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})}}):vu.create()}const M8={object:Mn.lazycreate};var Ge;(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"})(Ge||(Ge={}));const U8=(r,e={message:`Input not instance of ${r.name}`})=>lj(t=>t instanceof r,e),dj=gu.create,hj=Bd.create,V8=Am.create,L8=Rd.create,pj=Pd.create,q8=$d.create,H8=wm.create,F8=Zd.create,K8=Dd.create,z8=vu.create,W8=To.create,G8=Oi.create,J8=xm.create,Y8=Vo.create,X8=Mn.create,Q8=Mn.strictCreate,eT=Md.create,tT=nj.create,rT=Ud.create,nT=Aa.create,sT=aj.create,iT=km.create,aT=Sm.create,oT=oj.create,cT=Vd.create,uT=Ld.create,lT=Vp.create,dT=qd.create,hT=bu.create,v2=bs.create,pT=Zs.create,fT=Oa.create,mT=bs.createWithPreprocess,yT=px.create,gT=()=>dj().optional(),vT=()=>hj().optional(),bT=()=>pj().optional(),_T={string:r=>gu.create({...r,coerce:!0}),number:r=>Bd.create({...r,coerce:!0}),boolean:r=>Pd.create({...r,coerce:!0}),bigint:r=>Rd.create({...r,coerce:!0}),date:r=>$d.create({...r,coerce:!0})},wT=tt;var T=Object.freeze({__proto__:null,defaultErrorMap:yu,setErrorMap:w8,getErrorMap:vm,makeIssue:bm,EMPTY_PATH:x8,addIssueToContext:me,ParseStatus:sn,INVALID:tt,DIRTY:Jc,OK:Vr,isAborted:Tb,isDirty:Nb,isValid:Td,isAsync:Nd,get util(){return Zt},get objectUtil(){return Ib},ZodParsedType:we,getParsedType:ia,ZodType:kt,datetimeRegex:tj,ZodString:gu,ZodNumber:Bd,ZodBigInt:Rd,ZodBoolean:Pd,ZodDate:$d,ZodSymbol:wm,ZodUndefined:Zd,ZodNull:Dd,ZodAny:vu,ZodUnknown:To,ZodNever:Oi,ZodVoid:xm,ZodArray:Vo,ZodObject:Mn,ZodUnion:Md,ZodDiscriminatedUnion:nj,ZodIntersection:Ud,ZodTuple:Aa,ZodRecord:aj,ZodMap:km,ZodSet:Sm,ZodFunction:oj,ZodLazy:Vd,ZodLiteral:Ld,ZodEnum:Vp,ZodNativeEnum:qd,ZodPromise:bu,ZodEffects:bs,ZodTransformer:bs,ZodOptional:Zs,ZodNullable:Oa,ZodDefault:Hd,ZodCatch:Fd,ZodNaN:Am,BRAND:D8,ZodBranded:hx,ZodPipeline:px,ZodReadonly:Kd,custom:lj,Schema:kt,ZodSchema:kt,late:M8,get ZodFirstPartyTypeKind(){return Ge},coerce:_T,any:z8,array:Y8,bigint:L8,boolean:pj,date:q8,discriminatedUnion:tT,effect:v2,enum:lT,function:oT,instanceof:U8,intersection:rT,lazy:cT,literal:uT,map:iT,nan:V8,nativeEnum:dT,never:G8,null:K8,nullable:fT,number:hj,object:X8,oboolean:bT,onumber:vT,optional:pT,ostring:gT,pipeline:yT,preprocess:mT,promise:hT,record:sT,set:aT,strictObject:Q8,string:dj,symbol:H8,transformer:v2,tuple:nT,undefined:F8,union:eT,unknown:W8,void:J8,NEVER:wT,ZodIssueCode:ee,quotelessJson:_8,ZodError:ds}),Sr=class Mb extends b8{constructor(t){super(t);Pe(this,"openAPIRegistry");Pe(this,"defaultHook");Pe(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var u,l,h,R,B,d,g,A,O,$;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const P=Ec("query",n.request.query,i);a.push(P)}if((l=n.request)!=null&&l.params){const P=Ec("param",n.request.params,i);a.push(P)}if((h=n.request)!=null&&h.headers){const P=Ec("header",n.request.headers,i);a.push(P)}if((R=n.request)!=null&&R.cookies){const P=Ec("cookie",n.request.cookies,i);a.push(P)}const o=(d=(B=n.request)==null?void 0:B.body)==null?void 0:d.content;if(o)for(const P of Object.keys(o)){if(!o[P])continue;const ae=o[P].schema;if(ae instanceof kt){if(_2(P)){const Re=Ec("json",ae,i);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Re);else{const He=async(Te,Nt)=>{if(Te.req.header("content-type")&&_2(Te.req.header("content-type")))return await Re(Te,Nt);Te.req.addValidatedData("json",{}),await Nt()};a.push(He)}}if(w2(P)){const Re=Ec("form",ae,i);if(($=(O=n.request)==null?void 0:O.body)!=null&&$.required)a.push(Re);else{const He=async(Te,Nt)=>{if(Te.req.header("content-type")&&w2(Te.req.header("content-type")))return await Re(Te,Nt);Te.req.addValidatedData("form",{}),await Nt()};a.push(He)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,s),this});Pe(this,"getOpenAPIDocument",t=>{const s=new B5(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?b2(s,this._basePath):s});Pe(this,"getOpenAPI31Document",t=>{const s=new $5(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?b2(s,this._basePath):s});Pe(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)}}));Pe(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 m5,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Mb?(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:sa(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:sa(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 Mb({...super.basePath(t),defaultHook:this.defaultHook})}},ct=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};d5(T);function b2(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[sa(e,n)]=r.paths[n]}),{...r,paths:t}}function _2(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function w2(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function xT(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 kT(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function Ml(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 ST(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,l,h;const R=typeof s=="string"?i:s,B=R??{},{param:d}=B,g=xT(B,["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),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||d?{param:Object.assign(Object.assign({},(h=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||h===void 0?void 0:h.param),d)}:void 0),$=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(kT(this,"ZodObject")){const P=this.extend;$.extend=function(...ae){var Re,He,Te,Nt,Gt,Jt;const C=P.apply(this,ae);return C._def.openapi={_internal:{extendedFrom:!((He=(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal)===null||He===void 0)&&He.refId?{refId:(Nt=(Te=this._def.openapi)===null||Te===void 0?void 0:Te._internal)===null||Nt===void 0?void 0:Nt.refId,schema:this}:(Gt=this._def.openapi)===null||Gt===void 0?void 0:Gt._internal.extendedFrom},metadata:(Jt=C._def.openapi)===null||Jt===void 0?void 0:Jt.metadata},C}}return $},Ml(r,"optional"),Ml(r,"nullable"),Ml(r,"default"),Ml(r,"transform"),Ml(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,l;c._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.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 Dt;(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})(Dt||(Dt={}));var Ub;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ub||(Ub={}));const xe=Dt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),aa=r=>{switch(typeof r){case"undefined":return xe.undefined;case"string":return xe.string;case"number":return isNaN(r)?xe.nan:xe.number;case"boolean":return xe.boolean;case"function":return xe.function;case"bigint":return xe.bigint;case"symbol":return xe.symbol;case"object":return Array.isArray(r)?xe.array:r===null?xe.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?xe.promise:typeof Map<"u"&&r instanceof Map?xe.map:typeof Set<"u"&&r instanceof Set?xe.set:typeof Date<"u"&&r instanceof Date?xe.date:xe.object;default:return xe.unknown}},te=Dt.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"]),AT=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class _n 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 _n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Dt.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()}}_n.create=r=>new _n(r);const _u=(r,e)=>{let t;switch(r.code){case te.invalid_type:r.received===xe.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case te.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Dt.jsonStringifyReplacer)}`;break;case te.unrecognized_keys:t=`Unrecognized key(s) in object: ${Dt.joinValues(r.keys,", ")}`;break;case te.invalid_union:t="Invalid input";break;case te.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Dt.joinValues(r.options)}`;break;case te.invalid_enum_value:t=`Invalid enum value. Expected ${Dt.joinValues(r.options)}, received '${r.received}'`;break;case te.invalid_arguments:t="Invalid function arguments";break;case te.invalid_return_type:t="Invalid function return type";break;case te.invalid_date:t="Invalid date";break;case te.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}"`:Dt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case te.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 te.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 te.custom:t="Invalid input";break;case te.invalid_intersection_types:t="Intersection results could not be merged";break;case te.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case te.not_finite:t="Number must be finite";break;default:t=e.defaultError,Dt.assertNever(r)}return{message:t}};let fj=_u;function OT(r){fj=r}function Om(){return fj}const jm=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}},jT=[];function ye(r,e){const t=Om(),n=jm({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===_u?void 0:_u].filter(s=>!!s)});r.common.issues.push(n)}let an=class mj{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 st;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 mj.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 st;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 st=Object.freeze({status:"aborted"}),Cm=r=>({status:"dirty",value:r}),Lr=r=>({status:"valid",value:r}),Vb=r=>r.status==="aborted",Lb=r=>r.status==="dirty",zd=r=>r.status==="valid",Wd=r=>typeof Promise<"u"&&r instanceof Promise;function Em(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 yj(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 Me;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Me||(Me={}));var ed,td;class Ks{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 x2=(r,e)=>{if(zd(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 _n(r.common.issues);return this._error=t,this._error}}};function mt(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}}let Ot=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 aa(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:aa(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new an,ctx:{common:e.parent.common,data:e.data,parsedType:aa(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Wd(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:aa(e)},i=this._parseSync({data:e,path:s.path,parent:s});return x2(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:aa(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Wd(s)?s:Promise.resolve(s));return x2(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:te.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 _s({schema:this,typeName:Je.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Ds.create(this,this._def)}nullable(){return Ea.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return hs.create(this,this._def)}promise(){return xu.create(this,this._def)}or(e){return Qd.create([this,e],this._def)}and(e){return eh.create(this,e,this._def)}transform(e){return new _s({...mt(this._def),schema:this,typeName:Je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new sh({...mt(this._def),innerType:this,defaultValue:t,typeName:Je.ZodDefault})}brand(){return new fx({typeName:Je.ZodBranded,type:this,...mt(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ih({...mt(this._def),innerType:this,catchValue:t,typeName:Je.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return mx.create(this,e)}readonly(){return ah.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const CT=/^c[^\s-]{8,}$/i,ET=/^[0-9a-z]+$/,IT=/^[0-9A-HJKMNP-TV-Z]{26}$/,TT=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,NT=/^[a-z0-9_-]{21}$/i,BT=/^[-+]?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)?)??$/,RT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,PT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let K0;const $T=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ZT=/^(([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})))$/,DT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,gj="((\\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])))",MT=new RegExp(`^${gj}$`);function vj(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 UT(r){return new RegExp(`^${vj(r)}$`)}function bj(r){let e=`${gj}T${vj(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 VT(r,e){return!!((e==="v4"||!e)&&$T.test(r)||(e==="v6"||!e)&&ZT.test(r))}class is extends Ot{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==xe.string){const s=this._getOrReturnCtx(e);return ye(s,{code:te.invalid_type,expected:xe.string,received:s.parsedType}),st}const t=new an;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),ye(n,{code:te.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),ye(n,{code:te.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?ye(n,{code:te.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ye(n,{code:te.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")RT.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"email",code:te.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")K0||(K0=new RegExp(PT,"u")),K0.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"emoji",code:te.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")TT.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"uuid",code:te.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")NT.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"nanoid",code:te.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")CT.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"cuid",code:te.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")ET.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"cuid2",code:te.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")IT.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"ulid",code:te.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),ye(n,{validation:"url",code:te.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),ye(n,{validation:"regex",code:te.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),ye(n,{code:te.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),ye(n,{code:te.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),ye(n,{code:te.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?bj(s).test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{code:te.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?MT.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{code:te.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?UT(s).test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{code:te.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?BT.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"duration",code:te.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?VT(e.data,s.version)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"ip",code:te.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?DT.test(e.data)||(n=this._getOrReturnCtx(e,n),ye(n,{validation:"base64",code:te.invalid_string,message:s.message}),t.dirty()):Dt.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:te.invalid_string,...Me.errToObj(n)})}_addCheck(e){return new is({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Me.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Me.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Me.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Me.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Me.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Me.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Me.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Me.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Me.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Me.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,...Me.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,...Me.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Me.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Me.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Me.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Me.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Me.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Me.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Me.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Me.errToObj(t)})}nonempty(e){return this.min(1,Me.errToObj(e))}trim(){return new is({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new is({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new is({...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}}is.create=r=>{var e;return new is({checks:[],typeName:Je.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...mt(r)})};function LT(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 ja extends Ot{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)!==xe.number){const s=this._getOrReturnCtx(e);return ye(s,{code:te.invalid_type,expected:xe.number,received:s.parsedType}),st}let t;const n=new an;for(const s of this._def.checks)s.kind==="int"?Dt.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),ye(t,{code:te.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),ye(t,{code:te.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),ye(t,{code:te.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?LT(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),ye(t,{code:te.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),ye(t,{code:te.not_finite,message:s.message}),n.dirty()):Dt.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Me.toString(t))}setLimit(e,t,n,s){return new ja({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Me.toString(s)}]})}_addCheck(e){return new ja({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Me.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Me.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Me.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Me.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Me.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"&&Dt.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)}}ja.create=r=>new ja({checks:[],typeName:Je.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...mt(r)});let Gd=class qb extends Ot{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)!==xe.bigint){const s=this._getOrReturnCtx(e);return ye(s,{code:te.invalid_type,expected:xe.bigint,received:s.parsedType}),st}let t;const n=new an;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),ye(t,{code:te.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),ye(t,{code:te.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),ye(t,{code:te.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Dt.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Me.toString(t))}setLimit(e,t,n,s){return new qb({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Me.toString(s)}]})}_addCheck(e){return new qb({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Me.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}};Gd.create=r=>{var e;return new Gd({checks:[],typeName:Je.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...mt(r)})};let Jd=class extends Ot{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==xe.boolean){const t=this._getOrReturnCtx(e);return ye(t,{code:te.invalid_type,expected:xe.boolean,received:t.parsedType}),st}return Lr(e.data)}};Jd.create=r=>new Jd({typeName:Je.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...mt(r)});class Lo extends Ot{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==xe.date){const s=this._getOrReturnCtx(e);return ye(s,{code:te.invalid_type,expected:xe.date,received:s.parsedType}),st}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return ye(s,{code:te.invalid_date}),st}const t=new an;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),ye(n,{code:te.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),ye(n,{code:te.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Dt.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Lo({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Me.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Me.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}}Lo.create=r=>new Lo({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Je.ZodDate,...mt(r)});let Im=class extends Ot{_parse(e){if(this._getType(e)!==xe.symbol){const t=this._getOrReturnCtx(e);return ye(t,{code:te.invalid_type,expected:xe.symbol,received:t.parsedType}),st}return Lr(e.data)}};Im.create=r=>new Im({typeName:Je.ZodSymbol,...mt(r)});class Yd extends Ot{_parse(e){if(this._getType(e)!==xe.undefined){const t=this._getOrReturnCtx(e);return ye(t,{code:te.invalid_type,expected:xe.undefined,received:t.parsedType}),st}return Lr(e.data)}}Yd.create=r=>new Yd({typeName:Je.ZodUndefined,...mt(r)});class Xd extends Ot{_parse(e){if(this._getType(e)!==xe.null){const t=this._getOrReturnCtx(e);return ye(t,{code:te.invalid_type,expected:xe.null,received:t.parsedType}),st}return Lr(e.data)}}Xd.create=r=>new Xd({typeName:Je.ZodNull,...mt(r)});let wu=class extends Ot{constructor(){super(...arguments),this._any=!0}_parse(e){return Lr(e.data)}};wu.create=r=>new wu({typeName:Je.ZodAny,...mt(r)});let No=class extends Ot{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Lr(e.data)}};No.create=r=>new No({typeName:Je.ZodUnknown,...mt(r)});let ji=class extends Ot{_parse(e){const t=this._getOrReturnCtx(e);return ye(t,{code:te.invalid_type,expected:xe.never,received:t.parsedType}),st}};ji.create=r=>new ji({typeName:Je.ZodNever,...mt(r)});let Tm=class extends Ot{_parse(e){if(this._getType(e)!==xe.undefined){const t=this._getOrReturnCtx(e);return ye(t,{code:te.invalid_type,expected:xe.void,received:t.parsedType}),st}return Lr(e.data)}};Tm.create=r=>new Tm({typeName:Je.ZodVoid,...mt(r)});class hs extends Ot{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==xe.array)return ye(t,{code:te.invalid_type,expected:xe.array,received:t.parsedType}),st;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(ye(t,{code:a?te.too_big:te.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&&(ye(t,{code:te.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&&(ye(t,{code:te.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 Ks(t,a,t.path,o)))).then(a=>an.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ks(t,a,t.path,o)));return an.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new hs({...this._def,minLength:{value:e,message:Me.toString(t)}})}max(e,t){return new hs({...this._def,maxLength:{value:e,message:Me.toString(t)}})}length(e,t){return new hs({...this._def,exactLength:{value:e,message:Me.toString(t)}})}nonempty(e){return this.min(1,e)}}hs.create=(r,e)=>new hs({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Je.ZodArray,...mt(e)});function Fc(r){if(r instanceof or){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Ds.create(Fc(n))}return new or({...r._def,shape:()=>e})}else return r instanceof hs?new hs({...r._def,type:Fc(r.element)}):r instanceof Ds?Ds.create(Fc(r.unwrap())):r instanceof Ea?Ea.create(Fc(r.unwrap())):r instanceof zs?zs.create(r.items.map(e=>Fc(e))):r}class or extends Ot{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=Dt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==xe.object){const c=this._getOrReturnCtx(e);return ye(c,{code:te.invalid_type,expected:xe.object,received:c.parsedType}),st}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ji&&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],l=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ks(n,l,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof ji){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&&(ye(n,{code:te.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 l=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ks(n,l,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const l=await u.key,h=await u.value;c.push({key:l,value:h,alwaysSet:u.alwaysSet})}return c}).then(c=>an.mergeObjectSync(t,c)):an.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Me.errToObj,new or({...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=Me.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new or({...this._def,unknownKeys:"strip"})}passthrough(){return new or({...this._def,unknownKeys:"passthrough"})}extend(e){return new or({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new or({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new or({...this._def,catchall:e})}pick(e){const t={};return Dt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new or({...this._def,shape:()=>t})}omit(e){const t={};return Dt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new or({...this._def,shape:()=>t})}deepPartial(){return Fc(this)}partial(e){const t={};return Dt.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new or({...this._def,shape:()=>t})}required(e){const t={};return Dt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Ds;)s=s._def.innerType;t[n]=s}}),new or({...this._def,shape:()=>t})}keyof(){return xj(Dt.objectKeys(this.shape))}}or.create=(r,e)=>new or({shape:()=>r,unknownKeys:"strip",catchall:ji.create(),typeName:Je.ZodObject,...mt(e)});or.strictCreate=(r,e)=>new or({shape:()=>r,unknownKeys:"strict",catchall:ji.create(),typeName:Je.ZodObject,...mt(e)});or.lazycreate=(r,e)=>new or({shape:r,unknownKeys:"strip",catchall:ji.create(),typeName:Je.ZodObject,...mt(e)});let Qd=class extends Ot{_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 _n(o.ctx.common.issues));return ye(t,{code:te.invalid_union,unionErrors:a}),st}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},l=c._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,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 _n(c));return ye(t,{code:te.invalid_union,unionErrors:o}),st}}get options(){return this._def.options}};Qd.create=(r,e)=>new Qd({options:r,typeName:Je.ZodUnion,...mt(e)});const ea=r=>r instanceof th?ea(r.schema):r instanceof _s?ea(r.innerType()):r instanceof rh?[r.value]:r instanceof Ca?r.options:r instanceof nh?Dt.objectValues(r.enum):r instanceof sh?ea(r._def.innerType):r instanceof Yd?[void 0]:r instanceof Xd?[null]:r instanceof Ds?[void 0,...ea(r.unwrap())]:r instanceof Ea?[null,...ea(r.unwrap())]:r instanceof fx||r instanceof ah?ea(r.unwrap()):r instanceof ih?ea(r._def.innerType):[];class Fg extends Ot{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.object)return ye(t,{code:te.invalid_type,expected:xe.object,received:t.parsedType}),st;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}):(ye(t,{code:te.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),st)}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=ea(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 Fg({typeName:Je.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...mt(n)})}}function Hb(r,e){const t=aa(r),n=aa(e);if(r===e)return{valid:!0,data:r};if(t===xe.object&&n===xe.object){const s=Dt.objectKeys(e),i=Dt.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Hb(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===xe.array&&n===xe.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=Hb(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===xe.date&&n===xe.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class eh extends Ot{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Vb(i)||Vb(a))return st;const o=Hb(i.value,a.value);return o.valid?((Lb(i)||Lb(a))&&t.dirty(),{status:t.value,value:o.data}):(ye(n,{code:te.invalid_intersection_types}),st)};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}))}}eh.create=(r,e,t)=>new eh({left:r,right:e,typeName:Je.ZodIntersection,...mt(t)});class zs extends Ot{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==xe.array)return ye(n,{code:te.invalid_type,expected:xe.array,received:n.parsedType}),st;if(n.data.length<this._def.items.length)return ye(n,{code:te.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),st;!this._def.rest&&n.data.length>this._def.items.length&&(ye(n,{code:te.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 Ks(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>an.mergeArray(t,i)):an.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new zs({...this._def,rest:e})}}zs.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new zs({items:r,typeName:Je.ZodTuple,rest:null,...mt(e)})};let _j=class Fb extends Ot{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!==xe.object)return ye(n,{code:te.invalid_type,expected:xe.object,received:n.parsedType}),st;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Ks(n,o,n.path,o)),value:a._parse(new Ks(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?an.mergeObjectAsync(t,s):an.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ot?new Fb({keyType:e,valueType:t,typeName:Je.ZodRecord,...mt(n)}):new Fb({keyType:is.create(),valueType:e,typeName:Je.ZodRecord,...mt(t)})}},Nm=class extends Ot{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!==xe.map)return ye(n,{code:te.invalid_type,expected:xe.map,received:n.parsedType}),st;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ks(n,o,n.path,[u,"key"])),value:i._parse(new Ks(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,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return st;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return st;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}};Nm.create=(r,e,t)=>new Nm({valueType:e,keyType:r,typeName:Je.ZodMap,...mt(t)});let Bm=class Kb extends Ot{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==xe.set)return ye(n,{code:te.invalid_type,expected:xe.set,received:n.parsedType}),st;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(ye(n,{code:te.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&&(ye(n,{code:te.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 l of c){if(l.status==="aborted")return st;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ks(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Kb({...this._def,minSize:{value:e,message:Me.toString(t)}})}max(e,t){return new Kb({...this._def,maxSize:{value:e,message:Me.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Bm.create=(r,e)=>new Bm({valueType:r,minSize:null,maxSize:null,typeName:Je.ZodSet,...mt(e)});let wj=class em extends Ot{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.function)return ye(t,{code:te.invalid_type,expected:xe.function,received:t.parsedType}),st;function n(o,c){return jm({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Om(),_u].filter(u=>!!u),issueData:{code:te.invalid_arguments,argumentsError:c}})}function s(o,c){return jm({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Om(),_u].filter(u=>!!u),issueData:{code:te.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof xu){const o=this;return Lr(async function(...c){const u=new _n([]),l=await o._def.args.parseAsync(c,i).catch(R=>{throw u.addIssue(n(c,R)),u}),h=await Reflect.apply(a,this,l);return await o._def.returns._def.type.parseAsync(h,i).catch(R=>{throw u.addIssue(s(h,R)),u})})}else{const o=this;return Lr(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new _n([n(c,u.error)]);const l=Reflect.apply(a,this,u.data),h=o._def.returns.safeParse(l,i);if(!h.success)throw new _n([s(l,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new em({...this._def,args:zs.create(e).rest(No.create())})}returns(e){return new em({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new em({args:e||zs.create([]).rest(No.create()),returns:t||No.create(),typeName:Je.ZodFunction,...mt(n)})}},th=class extends Ot{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})}};th.create=(r,e)=>new th({getter:r,typeName:Je.ZodLazy,...mt(e)});let rh=class extends Ot{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return ye(t,{received:t.data,code:te.invalid_literal,expected:this._def.value}),st}return{status:"valid",value:e.data}}get value(){return this._def.value}};rh.create=(r,e)=>new rh({value:r,typeName:Je.ZodLiteral,...mt(e)});function xj(r,e){return new Ca({values:r,typeName:Je.ZodEnum,...mt(e)})}class Ca extends Ot{constructor(){super(...arguments),ed.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return ye(t,{expected:Dt.joinValues(n),received:t.parsedType,code:te.invalid_type}),st}if(Em(this,ed)||yj(this,ed,new Set(this._def.values)),!Em(this,ed).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return ye(t,{received:t.data,code:te.invalid_enum_value,options:n}),st}return Lr(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 Ca.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ca.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}ed=new WeakMap;Ca.create=xj;class nh extends Ot{constructor(){super(...arguments),td.set(this,void 0)}_parse(e){const t=Dt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==xe.string&&n.parsedType!==xe.number){const s=Dt.objectValues(t);return ye(n,{expected:Dt.joinValues(s),received:n.parsedType,code:te.invalid_type}),st}if(Em(this,td)||yj(this,td,new Set(Dt.getValidEnumValues(this._def.values))),!Em(this,td).has(e.data)){const s=Dt.objectValues(t);return ye(n,{received:n.data,code:te.invalid_enum_value,options:s}),st}return Lr(e.data)}get enum(){return this._def.values}}td=new WeakMap;nh.create=(r,e)=>new nh({values:r,typeName:Je.ZodNativeEnum,...mt(e)});let xu=class extends Ot{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.promise&&t.common.async===!1)return ye(t,{code:te.invalid_type,expected:xe.promise,received:t.parsedType}),st;const n=t.parsedType===xe.promise?t.data:Promise.resolve(t.data);return Lr(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};xu.create=(r,e)=>new xu({type:r,typeName:Je.ZodPromise,...mt(e)});class _s extends Ot{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Je.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=>{ye(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 st;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?st:c.status==="dirty"||t.value==="dirty"?Cm(c.value):c});{if(t.value==="aborted")return st;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?st:o.status==="dirty"||t.value==="dirty"?Cm(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"?st:(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"?st:(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(!zd(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=>zd(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Dt.assertNever(s)}}_s.create=(r,e,t)=>new _s({schema:r,typeName:Je.ZodEffects,effect:e,...mt(t)});_s.createWithPreprocess=(r,e,t)=>new _s({schema:e,effect:{type:"preprocess",transform:r},typeName:Je.ZodEffects,...mt(t)});class Ds extends Ot{_parse(e){return this._getType(e)===xe.undefined?Lr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ds.create=(r,e)=>new Ds({innerType:r,typeName:Je.ZodOptional,...mt(e)});let Ea=class extends Ot{_parse(e){return this._getType(e)===xe.null?Lr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ea.create=(r,e)=>new Ea({innerType:r,typeName:Je.ZodNullable,...mt(e)});let sh=class extends Ot{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===xe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};sh.create=(r,e)=>new sh({innerType:r,typeName:Je.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...mt(e)});let ih=class extends Ot{_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 Wd(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new _n(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new _n(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ih.create=(r,e)=>new ih({innerType:r,typeName:Je.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...mt(e)});let Rm=class extends Ot{_parse(e){if(this._getType(e)!==xe.nan){const t=this._getOrReturnCtx(e);return ye(t,{code:te.invalid_type,expected:xe.nan,received:t.parsedType}),st}return{status:"valid",value:e.data}}};Rm.create=r=>new Rm({typeName:Je.ZodNaN,...mt(r)});const qT=Symbol("zod_brand");let fx=class extends Ot{_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}},mx=class kj extends Ot{_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"?st:s.status==="dirty"?(t.dirty(),Cm(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"?st: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 kj({in:e,out:t,typeName:Je.ZodPipeline})}},ah=class extends Ot{_parse(e){const t=this._def.innerType._parse(e),n=s=>(zd(s)&&(s.value=Object.freeze(s.value)),s);return Wd(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};ah.create=(r,e)=>new ah({innerType:r,typeName:Je.ZodReadonly,...mt(e)});function Sj(r,e={},t){return r?wu.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})}}):wu.create()}const HT={object:or.lazycreate};var Je;(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"})(Je||(Je={}));const FT=(r,e={message:`Input not instance of ${r.name}`})=>Sj(t=>t instanceof r,e),Aj=is.create,Oj=ja.create,KT=Rm.create,zT=Gd.create,jj=Jd.create,WT=Lo.create,GT=Im.create,JT=Yd.create,YT=Xd.create,XT=wu.create,QT=No.create,eN=ji.create,tN=Tm.create,rN=hs.create,nN=or.create,sN=or.strictCreate,iN=Qd.create,aN=Fg.create,oN=eh.create,cN=zs.create,uN=_j.create,lN=Nm.create,dN=Bm.create,hN=wj.create,pN=th.create,fN=rh.create,mN=Ca.create,yN=nh.create,gN=xu.create,k2=_s.create,vN=Ds.create,bN=Ea.create,_N=_s.createWithPreprocess,wN=mx.create,xN=()=>Aj().optional(),kN=()=>Oj().optional(),SN=()=>jj().optional(),AN={string:r=>is.create({...r,coerce:!0}),number:r=>ja.create({...r,coerce:!0}),boolean:r=>Jd.create({...r,coerce:!0}),bigint:r=>Gd.create({...r,coerce:!0}),date:r=>Lo.create({...r,coerce:!0})},ON=st;var m=Object.freeze({__proto__:null,defaultErrorMap:_u,setErrorMap:OT,getErrorMap:Om,makeIssue:jm,EMPTY_PATH:jT,addIssueToContext:ye,ParseStatus:an,INVALID:st,DIRTY:Cm,OK:Lr,isAborted:Vb,isDirty:Lb,isValid:zd,isAsync:Wd,get util(){return Dt},get objectUtil(){return Ub},ZodParsedType:xe,getParsedType:aa,ZodType:Ot,datetimeRegex:bj,ZodString:is,ZodNumber:ja,ZodBigInt:Gd,ZodBoolean:Jd,ZodDate:Lo,ZodSymbol:Im,ZodUndefined:Yd,ZodNull:Xd,ZodAny:wu,ZodUnknown:No,ZodNever:ji,ZodVoid:Tm,ZodArray:hs,ZodObject:or,ZodUnion:Qd,ZodDiscriminatedUnion:Fg,ZodIntersection:eh,ZodTuple:zs,ZodRecord:_j,ZodMap:Nm,ZodSet:Bm,ZodFunction:wj,ZodLazy:th,ZodLiteral:rh,ZodEnum:Ca,ZodNativeEnum:nh,ZodPromise:xu,ZodEffects:_s,ZodTransformer:_s,ZodOptional:Ds,ZodNullable:Ea,ZodDefault:sh,ZodCatch:ih,ZodNaN:Rm,BRAND:qT,ZodBranded:fx,ZodPipeline:mx,ZodReadonly:ah,custom:Sj,Schema:Ot,ZodSchema:Ot,late:HT,get ZodFirstPartyTypeKind(){return Je},coerce:AN,any:XT,array:rN,bigint:zT,boolean:jj,date:WT,discriminatedUnion:aN,effect:k2,enum:mN,function:hN,instanceof:FT,intersection:oN,lazy:pN,literal:fN,map:lN,nan:KT,nativeEnum:yN,never:eN,null:YT,nullable:bN,number:Oj,object:nN,oboolean:SN,onumber:kN,optional:vN,ostring:xN,pipeline:wN,preprocess:_N,promise:gN,record:uN,set:dN,strictObject:sN,string:Aj,symbol:GT,transformer:k2,tuple:cN,undefined:JT,union:iN,unknown:QT,void:tN,NEVER:ON,ZodIssueCode:te,quotelessJson:AT,ZodError:_n});ST(m);const Ja=m.object({start:m.number(),limit:m.number(),length:m.number()}),yx=m.object({created_at:m.string(),updated_at:m.string()}),Cj=m.object({email:m.string().optional(),email_verified:m.boolean().optional(),name:m.string().optional(),username:m.string().optional(),given_name:m.string().optional(),phone_number:m.string().optional(),phone_verified:m.boolean().optional(),family_name:m.string().optional()}).catchall(m.any()),Ej=m.object({connection:m.string(),user_id:m.string(),provider:m.string(),isSocial:m.boolean(),access_token:m.string().optional(),access_token_secret:m.string().optional(),refresh_token:m.string().optional(),profileData:Cj.optional()}),Kg=m.object({email:m.string().optional(),username:m.string().optional(),given_name:m.string().optional(),family_name:m.string().optional(),nickname:m.string().optional(),name:m.string().optional(),picture:m.string().optional(),locale:m.string().optional(),linked_to:m.string().optional(),profileData:m.string().optional(),user_id:m.string().optional(),app_metadata:m.any().default({}).optional(),user_metadata:m.any().default({}).optional()}),Pm=Kg.extend({email_verified:m.boolean().default(!1),verify_email:m.boolean().optional(),last_ip:m.string().optional(),last_login:m.string().optional(),user_id:m.string().optional(),provider:m.string().default("email"),connection:m.string().default("email")}),gx=m.object({...Pm.shape,...yx.shape,user_id:m.string(),email:m.string(),is_social:m.boolean(),login_count:m.number(),identities:m.array(Ej).optional()}),Ps=gx,jN=Kg.extend({email:m.string(),login_count:m.number(),multifactor:m.array(m.string()).optional(),last_ip:m.string().optional(),last_login:m.string().optional(),user_id:m.string()}).catchall(m.any()),CN="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let EN=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=CN[t[r]&63];return e};const Ij=m.object({audience:m.string().optional(),recipient:m.string().optional(),createUpnClaim:m.boolean().optional(),mapUnknownClaimsAsIs:m.boolean().optional(),passthroughClaimsWithNoMapping:m.boolean().optional(),mapIdentities:m.boolean().optional(),signatureAlgorithm:m.string().optional(),digestAlgorithm:m.string().optional(),issuer:m.string().optional(),destination:m.string().optional(),lifetimeInSeconds:m.number().optional(),signResponse:m.boolean().optional(),nameIdentifierFormat:m.string().optional(),nameIdentifierProbes:m.array(m.string()).optional(),authnContextClassRef:m.string().optional(),mappings:m.record(m.string()).optional()}),$m=m.object({id:m.string(),name:m.string(),callbacks:m.array(m.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:m.array(m.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:m.array(m.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:m.array(m.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:m.array(m.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:m.object({samlp:Ij.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:m.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:m.string().default(()=>EN()).optional(),disable_sign_ups:m.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),bo=m.object({created_at:m.string().transform(r=>r===null?"":r),updated_at:m.string().transform(r=>r===null?"":r),...$m.shape});var vx=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(vx||{}),bx=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(bx||{}),_x=(r=>(r.S256="S256",r.Plain="plain",r))(_x||{});const Tj=m.object({client_id:m.string(),vendor_id:m.string().optional(),act_as:m.string().optional(),response_type:m.nativeEnum(vx).optional(),response_mode:m.nativeEnum(bx).optional(),redirect_uri:m.string().optional(),audience:m.string().optional(),state:m.string().optional(),nonce:m.string().optional(),scope:m.string().optional(),prompt:m.string().optional(),code_challenge_method:m.nativeEnum(_x).optional(),code_challenge:m.string().optional(),username:m.string().optional(),ui_locales:m.string().optional()}),zb=m.object({colors:m.object({primary:m.string(),page_background:m.object({type:m.string().optional(),start:m.string().optional(),end:m.string().optional(),angle_deg:m.number().optional()}).optional()}).optional(),logo_url:m.string().optional(),favicon_url:m.string().optional(),font:m.object({url:m.string()}).optional()}),Zm=m.object({id:m.string().optional(),name:m.string(),strategy:m.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:m.object({kid:m.string().optional(),team_id:m.string().optional(),realms:m.string().optional(),client_id:m.string().optional(),client_secret:m.string().optional(),app_secret:m.string().optional(),scope:m.string().optional(),authorization_endpoint:m.string().default("").optional(),token_endpoint:m.string().default("").optional(),userinfo_endpoint:m.string().default("").optional(),jwks_uri:m.string().default("").optional(),discovery_url:m.string().default("").optional(),issuer:m.string().default("").optional()}).default({}).optional(),enabled_clients:m.array(m.string()).default([]).optional(),response_type:m.custom().optional(),response_mode:m.custom().optional()}),_o=m.object({id:m.string(),created_at:m.string().transform(r=>r===null?"":r),updated_at:m.string().transform(r=>r===null?"":r)}).extend(Zm.shape),Dm=m.object({name:m.string(),audience:m.string(),sender_email:m.string().email(),sender_name:m.string(),support_url:m.string().url().optional(),logo:m.string().url().optional(),primary_color:m.string().optional(),secondary_color:m.string().optional(),language:m.string().optional()}),nu=m.object({created_at:m.string().transform(r=>r===null?"":r),updated_at:m.string().transform(r=>r===null?"":r),id:m.string(),...Dm.shape}),IN=m.object({logoUrl:m.string(),loginBackgroundImage:m.string().nullish(),style:m.object({primaryColor:m.string(),buttonTextColor:m.string(),primaryHoverColor:m.string()}),supportEmail:m.string().nullable(),supportUrl:m.string().nullable(),name:m.string(),showGreyishBackground:m.boolean().optional(),termsAndConditionsUrl:m.string().nullable(),companyName:m.string().optional(),checkoutHideSocial:m.boolean().optional(),siteUrl:m.string().nullable(),manageSubscriptionsUrl:m.string().optional()}),TN=m.object({domain:m.string(),dkim_private_key:m.string().optional(),dkim_public_key:m.string().optional(),email_api_key:m.string().optional(),email_service:m.union([m.literal("mailgun"),m.literal("mailchannels")]).optional()});m.object({...bo.shape,domains:m.array(TN),tenant:nu,connections:m.array(_o)});const Nj=m.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Bj=m.object({code_id:m.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:m.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:m.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:Nj,expires_at:m.string(),used_at:m.string().optional(),user_id:m.string().optional()}),NN=m.object({...Bj.shape,created_at:m.string()}),Rj=m.object({domain:m.string(),dkim_private_key:m.string().optional(),dkim_public_key:m.string().optional(),email_api_key:m.string().optional(),email_service:m.enum(["mailgun","mailchannels"])}),BN=yx.extend({...Rj.shape,id:m.string()}),Mm=m.object({trigger_id:m.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:m.boolean().default(!1),url:m.string(),hook_id:m.string().optional(),synchronous:m.boolean().default(!1),priority:m.number().optional()}),Yc=Mm.extend({...yx.shape,hook_id:m.string()}),wx=m.object({alg:m.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:m.string(),kid:m.string(),kty:m.enum(["RSA","EC","oct"]),n:m.string(),x5t:m.string().optional(),x5c:m.array(m.string()).optional(),use:m.enum(["sig","enc"]).optional()}),Pj=m.object({keys:m.array(wx)}),Wb=m.object({issuer:m.string(),authorization_endpoint:m.string(),token_endpoint:m.string(),device_authorization_endpoint:m.string(),userinfo_endpoint:m.string(),mfa_challenge_endpoint:m.string(),jwks_uri:m.string(),registration_endpoint:m.string(),revocation_endpoint:m.string(),scopes_supported:m.array(m.string()),response_types_supported:m.array(m.string()),code_challenge_methods_supported:m.array(m.string()),response_modes_supported:m.array(m.string()),subject_types_supported:m.array(m.string()),id_token_signing_alg_values_supported:m.array(m.string()),token_endpoint_auth_methods_supported:m.array(m.string()),claims_supported:m.array(m.string()),request_uri_parameter_supported:m.boolean(),request_parameter_supported:m.boolean(),token_endpoint_auth_signing_alg_values_supported:m.array(m.string())}),$j=m.object({auth0Client:m.string().optional(),authParams:Tj,expires_at:m.string(),deleted_at:m.string().optional(),ip:m.string().optional(),useragent:m.string().optional()}).openapi({description:"This represents a login sesion"}),RN=m.object({...$j.shape,login_id:m.string().openapi({description:"This is is used as the state in the universal login"}),created_at:m.string(),updated_at:m.string()});var zg=(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))(zg||{});const PN=m.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"]),Zj=m.object({name:m.string(),version:m.string(),env:m.object({node:m.string().optional()}).optional()}),Um=m.object({type:PN,date:m.string(),description:m.string().optional(),log_id:m.string().optional(),_id:m.string().optional(),ip:m.string(),user_agent:m.string(),details:m.any().optional(),isMobile:m.boolean(),user_id:m.string().optional(),user_name:m.string().optional(),connection:m.string().optional(),connection_id:m.string().optional(),client_id:m.string().optional(),client_name:m.string().optional(),audience:m.string().optional(),scope:m.array(m.string()).optional(),strategy:m.string().optional(),strategy_type:m.string().optional(),hostname:m.string().optional(),auth0_client:Zj.optional()}),Dj=m.object({user_id:m.string(),password:m.string(),algorithm:m.enum(["bcrypt","argon2id"]).default("argon2id")}),$N=m.object({...Dj.shape,created_at:m.string(),updated_at:m.string()}),Mj=m.object({session_id:m.string(),client_id:m.string(),expires_at:m.string(),used_at:m.string(),deleted_at:m.string().optional(),user_id:m.string()}),xx=m.object({created_at:m.string(),...Mj.shape}),Gb=m.object({kid:m.string().openapi({description:"The key id of the signing key"}),cert:m.string().openapi({description:"The public certificate of the signing key"}),fingerprint:m.string().openapi({description:"The cert fingerprint"}),thumbprint:m.string().openapi({description:"The cert thumbprint"}),pkcs7:m.string().optional().openapi({description:"The private key in pkcs7 format"}),current:m.boolean().optional().openapi({description:"True if the key is the current key"}),next:m.boolean().optional().openapi({description:"True if the key is the next key"}),previous:m.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:m.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:m.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:m.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:m.string().optional().openapi({description:"The date and time when the key was revoked"})});var Vm=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(Vm||{});m.object({access_token:m.string(),id_token:m.string().optional(),scope:m.string().optional(),state:m.string().optional(),refresh_token:m.string().optional(),token_type:m.string(),expires_in:m.number()});m.object({code:m.string(),state:m.string().optional()});const Uj=m.object({button_border_radius:m.number(),button_border_weight:m.number(),buttons_style:m.enum(["pill"]),input_border_radius:m.number(),input_border_weight:m.number(),inputs_style:m.enum(["pill"]),show_widget_shadow:m.boolean(),widget_border_weight:m.number(),widget_corner_radius:m.number()}),Vj=m.object({base_focus_color:m.string(),base_hover_color:m.string(),body_text:m.string(),captcha_widget_theme:m.enum(["auto"]),error:m.string(),header:m.string(),icons:m.string(),input_background:m.string(),input_border:m.string(),input_filled_text:m.string(),input_labels_placeholders:m.string(),links_focused_components:m.string(),primary_button:m.string(),primary_button_label:m.string(),secondary_button_border:m.string(),secondary_button_label:m.string(),success:m.string(),widget_background:m.string(),widget_border:m.string()}),yo=m.object({bold:m.boolean(),size:m.number()}),Lj=m.object({body_text:yo,buttons_text:yo,font_url:m.string(),input_labels:yo,links:yo,links_style:m.enum(["normal"]),reference_text_size:m.number(),subtitle:yo,title:yo}),qj=m.object({background_color:m.string(),background_image_url:m.string(),page_layout:m.enum(["center"])}),Hj=m.object({header_text_alignment:m.enum(["center"]),logo_height:m.number(),logo_position:m.enum(["center"]),logo_url:m.string(),social_buttons_layout:m.enum(["bottom"])}),Fj=m.object({borders:Uj,colors:Vj,displayName:m.string(),fonts:Lj,page_background:qj,widget:Hj}),ZN=Fj.extend({themeId:m.string()}),tm=m.object({universal_login_experience:m.enum(["new","classic"]).default("new"),identifier_first:m.boolean().default(!0),password_first:m.boolean().default(!1),webauthn_platform_first_factor:m.boolean()}),rm=m.object({name:m.string(),enabled:m.boolean().optional().default(!0),default_from_address:m.string().optional(),credentials:m.union([m.object({accessKeyId:m.string(),secretAccessKey:m.string(),region:m.string()}),m.object({smtp_host:m.array(m.string()),smtp_port:m.number(),smtp_user:m.string(),smtp_pass:m.string()}),m.object({api_key:m.string(),domain:m.string().optional()}),m.object({connectionString:m.string()}),m.object({tenantId:m.string(),clientId:m.string(),clientSecret:m.string()})]),settings:m.object({}).optional()});function DN(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}const MN=new Sr().openapi(ct({tags:["branding"],method:"get",path:"/",request:{headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:zb}},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(ct({tags:["branding"],method:"patch",path:"/",request:{headers:T.object({"tenant-id":T.string()}),body:{content:{"application/json":{schema:T.object(zb.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});var Lm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function UN(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function VN(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}function LN(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 Kj={exports:{}};const qN={},HN=Object.freeze(Object.defineProperty({__proto__:null,default:qN},Symbol.toStringTag,{value:"Module"})),FN=VN(HN);(function(r){/**
1
+ "use strict";var iv=Object.defineProperty;var yh=r=>{throw TypeError(r)};var sv=(r,e,t)=>e in r?iv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ne=(r,e,t)=>sv(r,typeof e!="symbol"?e+"":e,t),Xu=(r,e,t)=>e.has(r)||yh("Cannot "+t);var w=(r,e,t)=>(Xu(r,e,"read from private field"),t?t.call(r):e.get(r)),Oe=(r,e,t)=>e.has(r)?yh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Xu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Te=(r,e,t)=>(Xu(r,e,"access private method"),t);var gh=(r,e,t,n)=>({set _(i){ue(r,e,i,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function As(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function Se(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function av(r){return"_def"in r}function xs(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function ov(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=As(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(Se(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xs(r,"optional"),xs(r,"nullable"),xs(r,"default"),xs(r,"transform"),xs(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}function Zo(r,e){if(r==null||e===null||e===void 0)return r===e;if(r===e||r.valueOf()===e.valueOf())return!0;if(Array.isArray(r)&&(!Array.isArray(e)||r.length!==e.length)||!(r instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(r);return Object.keys(e).every(n=>t.indexOf(n)!==-1)&&t.every(n=>Zo(r[n],e[n]))}class cv{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(s=>Zo(s,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(i=>Zo(i,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const s of this.buckets.values())e+=1,t+=s.length,s.length>1&&(n+=1);const i=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:i}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if(typeof e=="string"){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[n,i]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(i??"");return t}}function Rs(r){return r==null}function Ps(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{t[n]=e(i)}),t}function uv(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e.some(s=>s===n)||(t[n]=i)}),t}function ji(r,e){const t={};return Object.entries(r).forEach(([n,i])=>{e(i,n)||(t[n]=i)}),t}function vh(r){return r.filter(e=>!Rs(e))}const yl=Zo;function lv(r){const e=new cv;return r.forEach(t=>e.put(t)),[...e.values()]}function wm(r){return typeof r=="string"}class dv{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(i=>i.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,i,s;const a=this.schemaWithRefId(e,t),o=(n=a._def.openapi)===null||n===void 0?void 0:n.metadata,c=a.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(s=(i=o==null?void 0:o.param)===null||i===void 0?void 0:i.name)!==null&&s!==void 0?s:e})}));return this._definitions.push({type:"parameter",schema:c}),c}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:"component",componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class tu{constructor(e){this.message=e}}class _s extends tu{constructor(e,t){super(e),this.data=t}}class Mo extends tu{constructor(e){super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``),this.data=e}}function ws(r,e){try{return r()}catch(t){throw t instanceof Mo?new Mo(Object.assign(Object.assign({},t.data),e)):t}}class fv extends tu{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class We{static getMetadata(e){var t;const n=this.unwrapChained(e),i=e._def.openapi?e._def.openapi:n._def.openapi,s=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:i==null?void 0:i._internal,metadata:Object.assign({description:s},i==null?void 0:i.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return n==null?void 0:n._internal}static getParamMetadata(e){var t,n;const i=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:i._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:i.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign(Object.assign({},s==null?void 0:s.metadata),{param:Object.assign({description:a},(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return ji(uv(e,["param"]),Rs)}static buildParameterMetadata(e){return ji(e,Rs)}static applySchemaMetadata(e,t){return ji(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Rs)}static getRefId(e){var t;return(t=this.getInternalMetadata(e))===null||t===void 0?void 0:t.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){const t=this.unwrapUntil(e,"ZodDefault");return t==null?void 0:t._def.defaultValue()}static unwrapUntil(e,t){return t&&Se(e,t)?e:Se(e,"ZodOptional")||Se(e,"ZodNullable")||Se(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):Se(e,"ZodDefault")||Se(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):Se(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):Se(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return Se(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class hv{transform(e,t,n){var i,s;const a=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(a),minItems:(i=e._def.minLength)===null||i===void 0?void 0:i.value,maxItems:(s=e._def.maxLength)===null||s===void 0?void 0:s.value})}}class pv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class mv{transform(e,t,n,i,s){const a=[...e.options.values()],o=a.map(i);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(a,e.discriminator,s)}}mapDiscriminator(e,t,n){if(e.some(s=>We.getRefId(s)===void 0))return;const i={};return e.forEach(s=>{var a;const o=We.getRefId(s),c=(a=s.shape)===null||a===void 0?void 0:a[t];if(Se(c,"ZodEnum")||Se(c,"ZodNativeEnum")){Object.values(c.enum).filter(wm).forEach(m=>{i[m]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);i[u]=n(o)}),{propertyName:t,mapping:i}}}class yv{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class gv{transform(e,t,n,i){const a={allOf:this.flattenIntersectionTypes(e).map(i)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!Se(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class vv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function bv(r){const t=Object.keys(r).filter(s=>typeof r[r[s]]!="number").map(s=>r[s]),n=t.filter(s=>typeof s=="number").length,i=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:i}}class xv{transform(e,t){const{type:n,values:i}=bv(e._def.values);if(n==="mixed")throw new tu("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:i})}}class _v{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class wv{transform(e,t,n,i){var s;const a=(s=We.getInternalMetadata(e))===null||s===void 0?void 0:s.extendedFrom,o=this.requiredKeysOf(e),c=Ps(e._def.shape(),i);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,i));const u=a.schema;i(u);const f=this.requiredKeysOf(u),m=Ps(u==null?void 0:u._def.shape(),i),B=Object.fromEntries(Object.entries(c).filter(([g,A])=>!yl(m[g],A))),C=o.filter(g=>!f.includes(g)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:B}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,i));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,i=e._def.catchall;return Se(i,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(i)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!We.isOptionalSchema(n)).map(([t,n])=>t)}}class kv{transform(e,t,n){const i=e._def.valueType,s=e._def.keyType,a=n(i);if(Se(s,"ZodEnum")||Se(s,"ZodNativeEnum")){const c=Object.values(s.enum).filter(wm).reduce((u,f)=>Object.assign(Object.assign({},u),{[f]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class Sv{transform(e,t){var n,i,s;const a=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(i=e.minLength)!==null&&i!==void 0?i:void 0,u=Number.isFinite(e.maxLength)&&(s=e.maxLength)!==null&&s!==void 0?s:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:a==null?void 0:a.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time"}getZodStringCheck(e,t){return e._def.checks.find(n=>n.kind===t)}}class Av{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:i}=e._def,s=i.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(s))}}class Ov{transform(e,t,n){const s=this.flattenUnionTypes(e).map(a=>{const o=this.unwrapNullable(a);return n(o)});return{anyOf:t(s)}}flattenUnionTypes(e){return Se(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return Se(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class Ev{constructor(e){this.versionSpecifics=e,this.objectTransformer=new wv,this.stringTransformer=new Sv,this.numberTransformer=new _v,this.bigIntTransformer=new pv,this.literalTransformer=new vv,this.enumTransformer=new yv,this.nativeEnumTransformer=new xv,this.arrayTransformer=new hv,this.unionTransformer=new Ov,this.discriminatedUnionTransformer=new mv,this.intersectionTransformer=new gv,this.recordTransformer=new kv,this.tupleTransformer=new Av(e)}transform(e,t,n,i,s){if(Se(e,"ZodNull"))return this.versionSpecifics.nullType;if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodObject"))return this.objectTransformer.transform(e,s,o=>this.versionSpecifics.mapNullableType(o,t),n);const a=this.transformSchemaWithoutDefault(e,t,n,i);return Object.assign(Object.assign({},a),{default:s})}transformSchemaWithoutDefault(e,t,n,i){if(Se(e,"ZodUnknown")||Se(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(Se(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(Se(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(Se(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(Se(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,i);if(Se(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(Se(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(Se(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const s=We.getRefId(e);throw new fv({currentSchema:e._def,schemaName:s})}}class km{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new Ev(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const n={};return this.rawComponents.forEach(({componentType:i,name:s,component:a})=>{var o;(o=n[i])!==null&&o!==void 0||(n[i]={}),n[i][s]=a}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},(e=n.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=n.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const i=e.findIndex(a=>a===t.type),s=e.findIndex(a=>a===n.type);return i-s})}generateSingle(e){if(!("type"in e)){this.generateSchemaWithRef(e);return}switch(e.type){case"parameter":this.generateParameterDefinition(e.schema);return;case"schema":this.generateSchemaWithRef(e.schema);return;case"route":this.generateSingleRoute(e.route);return;case"component":this.rawComponents.push(e);return}}generateParameterDefinition(e){const t=We.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,i,s,a,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId?this.paramRefs[(s=e._internal)===null||s===void 0?void 0:s.refId]:void 0;if(!(!(!((a=e==null?void 0:e._internal)===null||a===void 0)&&a.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new _s(`Conflicting location for parameter ${u.name}`,{key:"in",values:vh([u.in,t==null?void 0:t.in,c==null?void 0:c.in])});if(c&&u.name!==c.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new _s("Conflicting names for parameter",{key:"name",values:vh([u.name,t==null?void 0:t.name,c==null?void 0:c.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var n;const i=We.getMetadata(e),s=(n=i==null?void 0:i.metadata)===null||n===void 0?void 0:n.param,a=this.getParameterRef(i,{in:t});if(a)return[a];if(Se(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,B;const C=We.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const g=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(g!=null&&g.name&&g.name!==u)throw new _s("Conflicting names for parameter",{key:"name",values:[u,g.name]});if(g!=null&&g.in&&g.in!==t)throw new _s(`Conflicting location for parameter ${(B=g.name)!==null&&B!==void 0?B:u}`,{key:"in",values:[t,g.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(s!=null&&s.in&&s.in!==t)throw new _s(`Conflicting location for parameter ${s.name}`,{key:"in",values:[t,s.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=We.getParamMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=!We.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:s},i?We.buildParameterMetadata(i):{})}generateParameter(e){var t;const n=We.getMetadata(e),i=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,s=i==null?void 0:i.name,a=i==null?void 0:i.in;if(!s)throw new Mo({missingField:"name"});if(!a)throw new Mo({missingField:"in",paramName:s});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:a,name:s})}generateSchemaWithMetadata(e){var t;const n=We.unwrapChained(e),i=We.getMetadata(e),s=We.getDefaultValue(e),a=!((t=i==null?void 0:i.metadata)===null||t===void 0)&&t.type?{type:i==null?void 0:i.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),s);return i!=null&&i.metadata?We.applySchemaMetadata(a,i.metadata):ji(a,Rs)}constructReferencedOpenAPISchema(e){var t;const n=We.getMetadata(e),i=We.unwrapChained(e),s=We.getDefaultValue(e),a=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,a):this.toOpenAPISchema(i,a,s)}generateSimpleSchema(e){var t;const n=We.getMetadata(e),i=We.getRefId(e);if(!i||!this.schemaRefs[i])return this.generateSchemaWithMetadata(e);const s=this.schemaRefs[i],a={$ref:this.generateSchemaRef(i)},o=ji(We.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||yl(f,s[m]));if(o.type)return{allOf:[a,o]};const c=ji(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||yl(f,s[m])),u=We.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=We.getRefId(e),n=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=As(e,["content"]),i=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:i})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),i=this.cleanParameter(e.params),s=this.cleanParameter(e.cookies),a=ws(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=ws(()=>i?this.generateInlineParameters(i,"path"):[],{location:"path"}),c=ws(()=>s?this.generateInlineParameters(s,"cookie"):[],{location:"cookie"}),u=ws(()=>{if(Array.isArray(t))return t.flatMap(m=>this.generateInlineParameters(m,"header"));const f=this.cleanParameter(t);return f?this.generateInlineParameters(f,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return Se(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:i,responses:s}=e,a=As(e,["method","path","request","responses"]),o=Ps(s,m=>this.getResponse(m)),c=ws(()=>this.getParameters(i),{route:`${t} ${n}`}),u=this.getRequestBody(i==null?void 0:i.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},a),c.length>0?{parameters:[...a.parameters||[],...c]}:{}),u?{requestBody:u}:{}),{responses:o})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){var{content:t,headers:n}=e,i=As(e,["content","headers"]);const s=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},i),s);const a=Se(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},i),{headers:a}),s)}getResponseHeaders(e){const t=e._def.shape();return Ps(t,i=>this.generateSimpleParameter(i))}getBodyContent(e){return Ps(e,t=>{if(!t||!av(t.schema))return t;const{schema:n}=t,i=As(t,["schema"]),s=this.generateSchemaWithRef(n);return Object.assign({schema:s},i)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,i=>this.generateSchemaWithRef(i),i=>this.generateSchemaRef(i),n)}}class Iv{get nullType(){return{nullable:!0}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return Object.assign(Object.assign({},e?{type:e}:void 0),t?this.nullType:void 0)}mapTupleItems(e){const t=lv(e);return{items:t.length===1?t[0]:{anyOf:t},minItems:e.length,maxItems:e.length}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{minimum:Number(t.value),exclusiveMinimum:!0};case"max":return t.inclusive?{maximum:Number(t.value)}:{maximum:Number(t.value),exclusiveMaximum:!0};default:return{}}}))}}class Cv{constructor(e){const t=new Iv;this.generator=new km(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class jv{get nullType(){return{type:"null"}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return e?t?{type:Array.isArray(e)?[...e,"null"]:[e,"null"]}:{type:e}:{}}mapTupleItems(e){return{prefixItems:e}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{exclusiveMinimum:Number(t.value)};case"max":return t.inclusive?{maximum:Number(t.value)}:{exclusiveMaximum:Number(t.value)};default:return{}}}))}}function Tv(r){return"type"in r&&r.type==="webhook"}class Nv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new jv;this.generator=new km(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(Tv).forEach(n=>this.generateSingleWebhook(n.webhook)),Object.assign(Object.assign(Object.assign({},e),t),{webhooks:this.webhookRefs})}generateComponents(){return this.generator.generateComponents()}generateSingleWebhook(e){const t=this.generator.generatePath(e);return this.webhookRefs[e.path]=Object.assign(Object.assign({},this.webhookRefs[e.path]),t),t}}var Sm=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Bv=r=>{const{groups:e,path:t}=Rv(r),n=Sm(t);return Pv(n,e)},Rv=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const i=`@${n}`;return e.push([i,t]),i}),{groups:e,path:r}},Pv=(r,e)=>{for(let t=e.length-1;t>=0;t--){const[n]=e[t];for(let i=r.length-1;i>=0;i--)if(r[i].includes(n)){r[i]=r[i].replace(n,e[t][1]);break}}return r},bo={},bh=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(bo[r]||(e[2]?bo[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:bo[r]=[r,e[1],!0]),bo[r]):null},Am=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},$v=r=>Am(r,decodeURI),Om=r=>{const e=r.url,t=e.indexOf("/",8);let n=t;for(;n<e.length;n++){const i=e.charCodeAt(n);if(i===37){const s=e.indexOf("?",n),a=e.slice(t,s===-1?void 0:s);return $v(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(i===63)break}return e.slice(t,n)},Dv=r=>{const e=Om(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},nn=(...r)=>{let e="",t=!1;for(let n of r)e[e.length-1]==="/"&&(e=e.slice(0,-1),t=!0),n[0]!=="/"&&(n=`/${n}`),n==="/"&&t?e=`${e}/`:n!=="/"&&(e=`${e}${n}`),n==="/"&&e===""&&(e="/");return e},Em=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(i=>{if(i!==""&&!/\:/.test(i))n+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){t.length===0&&n===""?t.push("/"):t.push(n);const s=i.replace("?","");n+="/"+s,t.push(n)}else n+="/"+i}),t.filter((i,s,a)=>a.indexOf(i)===s)},Qu=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?af(r):r):r,Im=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let a=r.indexOf(`?${e}`,8);for(a===-1&&(a=r.indexOf(`&${e}`,8));a!==-1;){const o=r.charCodeAt(a+e.length+1);if(o===61){const c=a+e.length+2,u=r.indexOf("&",c);return Qu(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";a=r.indexOf(`&${e}`,a+1)}if(n=/[%+]/.test(r),!n)return}const i={};n??(n=/[%+]/.test(r));let s=r.indexOf("?",8);for(;s!==-1;){const a=r.indexOf("&",s+1);let o=r.indexOf("=",s);o>a&&a!==-1&&(o=-1);let c=r.slice(s+1,o===-1?a===-1?void 0:a:o);if(n&&(c=Qu(c)),s=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=Qu(u))),t?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(u)):i[c]??(i[c]=u)}return e?i[e]:i},Zv=Im,Mv=(r,e)=>Im(r,e,!0),af=decodeURIComponent,Uv=/^[\w!#$%&'*.^`|~+-]+$/,Vv=/^[ !#-:<-[\]-~]*$/,Lv=(r,e)=>{const t=r.trim().split(";"),n={};for(let i of t){i=i.trim();const s=i.indexOf("=");if(s===-1)continue;const a=i.substring(0,s).trim();if(!Uv.test(a))continue;let o=i.substring(s+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Vv.test(o)&&(n[a]=af(o))}return n},qv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Lv(n):{}},ye=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});ne(this,"res");ne(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},Hv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),Fv=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Kv=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Wv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,zv=(r,e)=>async(t,n)=>{let i={};const s=t.req.header("Content-Type");switch(r){case"json":if(!s||!Fv.test(s))break;try{i=await t.req.json()}catch{const o="Malformed JSON in request body";throw new ye(400,{message:o})}break;case"form":{if(!s||!(Kv.test(s)||Wv.test(s)))break;let o;if(t.req.bodyCache.formData)o=await t.req.bodyCache.formData;else try{const u=await t.req.arrayBuffer();o=await Hv(u,s),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new ye(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),i=c;break}case"query":i=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":i=t.req.param();break;case"header":i=t.req.header();break;case"cookie":i=qv(t);break}const a=await e(i,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xi=(r,e,t)=>zv(r,async(n,i)=>{const s=await e.safeParseAsync(n);if(t){const a=await t({data:n,...s,target:r},i);if(a){if(a instanceof Response)return a;if("response"in a)return a.response}}return s.success?s.data:i.json(s,400)});var Gv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,s=(r instanceof Cm?r.raw.headers:r.headers).get("Content-Type");return s!=null&&s.startsWith("multipart/form-data")||s!=null&&s.startsWith("application/x-www-form-urlencoded")?Jv(r,{all:t,dot:n}):{}};async function Jv(r,e){const t=await r.formData();return t?Yv(t,e):{}}function Yv(r,e){const t=Object.create(null);return r.forEach((n,i)=>{e.all||i.endsWith("[]")?Xv(t,i,n):t[i]=n}),e.dot&&Object.entries(t).forEach(([n,i])=>{n.includes(".")&&(Qv(t,n,i),delete t[n])}),t}var Xv=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},Qv=(r,e,t)=>{let n=r;const i=e.split(".");i.forEach((s,a)=>{a===i.length-1?n[s]=t:((!n[s]||typeof n[s]!="object"||Array.isArray(n[s])||n[s]instanceof File)&&(n[s]=Object.create(null)),n=n[s])})},xh=r=>Am(r,af),$i,tr,Xr,jm,Tm,gl,cn,hm,Cm=(hm=class{constructor(r,e="/",t=[[]]){Oe(this,Xr);ne(this,"raw");Oe(this,$i);Oe(this,tr);ne(this,"routeIndex",0);ne(this,"path");ne(this,"bodyCache",{});Oe(this,cn,r=>{const{bodyCache:e,raw:t}=this,n=e[r];if(n)return n;const i=Object.keys(e)[0];return i?e[i].then(s=>(i==="json"&&(s=JSON.stringify(s)),new Response(s)[r]())):e[r]=t[r]()});this.raw=r,this.path=e,ue(this,tr,t),ue(this,$i,{})}param(r){return r?Te(this,Xr,jm).call(this,r):Te(this,Xr,Tm).call(this)}query(r){return Zv(this.url,r)}queries(r){return Mv(this.url,r)}header(r){if(r)return this.raw.headers.get(r.toLowerCase())??void 0;const e={};return this.raw.headers.forEach((t,n)=>{e[n]=t}),e}async parseBody(r){var e;return(e=this.bodyCache).parsedBody??(e.parsedBody=await Gv(this,r))}json(){return w(this,cn).call(this,"json")}text(){return w(this,cn).call(this,"text")}arrayBuffer(){return w(this,cn).call(this,"arrayBuffer")}blob(){return w(this,cn).call(this,"blob")}formData(){return w(this,cn).call(this,"formData")}addValidatedData(r,e){w(this,$i)[r]=e}valid(r){return w(this,$i)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return w(this,tr)[0].map(([[,r]])=>r)}get routePath(){return w(this,tr)[0].map(([[,r]])=>r)[this.routeIndex].path}},$i=new WeakMap,tr=new WeakMap,Xr=new WeakSet,jm=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=Te(this,Xr,gl).call(this,e);return t?/\%/.test(t)?xh(t):t:void 0},Tm=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=Te(this,Xr,gl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?xh(n):n)}return r},gl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,hm),eb={Stringify:1,BeforeStream:2,Stream:3},Nm=async(r,e,t,n,i)=>{typeof r=="object"&&!(r instanceof String)&&(r instanceof Promise||(r=r.toString()),r instanceof Promise&&(r=await r));const s=r.callbacks;return s!=null&&s.length?(i?i[0]+=r:i=[r],Promise.all(s.map(o=>o({phase:e,buffer:i,context:n}))).then(o=>Promise.all(o.filter(Boolean).map(c=>Nm(c,e,!1,n,i))).then(()=>i[0]))):Promise.resolve(r)},tb="text/plain; charset=UTF-8",el=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Dr,Ka,Di,Zi,Wa,za,Ot,Vt,pm,Bm=(pm=class{constructor(r,e){Oe(this,Ot);Oe(this,Ha);Oe(this,Fa);ne(this,"env",{});Oe(this,Pr);ne(this,"finalized",!1);ne(this,"error");Oe(this,qn,200);Oe(this,$r);Oe(this,Ge);Oe(this,Qe);Oe(this,br);Oe(this,Dr,!0);Oe(this,Ka);Oe(this,Di);Oe(this,Zi);Oe(this,Wa);Oe(this,za);ne(this,"render",(...r)=>(w(this,Di)??ue(this,Di,e=>this.html(e)),w(this,Di).call(this,...r)));ne(this,"setLayout",r=>ue(this,Ka,r));ne(this,"getLayout",()=>w(this,Ka));ne(this,"setRenderer",r=>{ue(this,Di,r)});ne(this,"header",(r,e,t)=>{if(e===void 0){w(this,Ge)?w(this,Ge).delete(r):w(this,Qe)&&delete w(this,Qe)[r.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(r);return}t!=null&&t.append?(w(this,Ge)||(ue(this,Dr,!1),ue(this,Ge,new Headers(w(this,Qe))),ue(this,Qe,{})),w(this,Ge).append(r,e)):w(this,Ge)?w(this,Ge).set(r,e):(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)[r.toLowerCase()]=e),this.finalized&&(t!=null&&t.append?this.res.headers.append(r,e):this.res.headers.set(r,e))});ne(this,"status",r=>{ue(this,Dr,!1),ue(this,qn,r)});ne(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});ne(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);ne(this,"newResponse",(...r)=>Te(this,Ot,Vt).call(this,...r));ne(this,"body",(r,e,t)=>typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e));ne(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Dr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=tb,typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)});ne(this,"json",(r,e,t)=>{const n=JSON.stringify(r);return w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="application/json; charset=UTF-8",typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)});ne(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Nm(r,eb.Stringify,!1,{}).then(n=>typeof e=="number"?Te(this,Ot,Vt).call(this,n,e,t):Te(this,Ot,Vt).call(this,n,e)):typeof e=="number"?Te(this,Ot,Vt).call(this,r,e,t):Te(this,Ot,Vt).call(this,r,e)));ne(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));ne(this,"notFound",()=>(w(this,Zi)??ue(this,Zi,()=>new Response),w(this,Zi).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Zi,e.notFoundHandler),ue(this,za,e.path),ue(this,Wa,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Cm(w(this,Ha),w(this,za),w(this,Wa))),w(this,Fa)}get event(){if(w(this,$r)&&"respondWith"in w(this,$r))return w(this,$r);throw Error("This context has no FetchEvent")}get executionCtx(){if(w(this,$r))return w(this,$r);throw Error("This context has no ExecutionContext")}get res(){return ue(this,Dr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Dr,!1),w(this,br)&&r)try{for(const[e,t]of w(this,br).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=w(this,br).headers.getSetCookie();r.headers.delete("set-cookie");for(const i of n)r.headers.append("set-cookie",i)}else r.headers.set(e,t)}catch(e){if(e instanceof TypeError&&e.message.includes("immutable")){this.res=new Response(r.body,{headers:r.headers,status:r.status});return}else throw e}ue(this,br,r),this.finalized=!0}get var(){return w(this,Pr)?Object.fromEntries(w(this,Pr)):{}}},Ha=new WeakMap,Fa=new WeakMap,Pr=new WeakMap,qn=new WeakMap,$r=new WeakMap,Ge=new WeakMap,Qe=new WeakMap,br=new WeakMap,Dr=new WeakMap,Ka=new WeakMap,Di=new WeakMap,Zi=new WeakMap,Wa=new WeakMap,za=new WeakMap,Ot=new WeakSet,Vt=function(r,e,t){if(w(this,Dr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const i=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?i.append(o,a):i.set(o,a)});const s=el(i,w(this,Qe));return new Response(r,{headers:s,status:e.status??w(this,qn)})}const n=typeof e=="number"?e:w(this,qn);w(this,Qe)??ue(this,Qe,{}),w(this,Ge)??ue(this,Ge,new Headers),el(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((i,s)=>{var a,o;s==="set-cookie"?(a=w(this,Ge))==null||a.append(s,i):(o=w(this,Ge))==null||o.set(s,i)}),el(w(this,Ge),w(this,Qe))),t??(t={});for(const[i,s]of Object.entries(t))if(typeof s=="string")w(this,Ge).set(i,s);else{w(this,Ge).delete(i);for(const a of s)w(this,Ge).append(i,a)}return new Response(r,{status:n,headers:w(this,Ge)})},pm),_h=(r,e,t)=>(n,i)=>{let s=-1;const a=n instanceof Bm;return o(0);async function o(c){if(c<=s)throw new Error("next() called multiple times");s=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&i||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(B){if(B instanceof Error&&a&&e)n.error=B,u=await e(B,n),f=!0;else throw B}return u&&(n.finalized===!1||f)&&(n.res=u),n}},it="ALL",rb="all",nb=["get","post","put","delete","options","patch"],Rm="Can not add a route since the matcher is already built.",Pm=class extends Error{},ib=Symbol("composedHandler"),sb=r=>r.text("404 Not Found",404),wh=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,st,Dm,Zr,Pn,Ao,Oo,mm,$m=(mm=class{constructor(e={}){Oe(this,st);ne(this,"get");ne(this,"post");ne(this,"put");ne(this,"delete");ne(this,"options");ne(this,"patch");ne(this,"all");ne(this,"on");ne(this,"use");ne(this,"router");ne(this,"getPath");ne(this,"_basePath","/");Oe(this,rr,"/");ne(this,"routes",[]);Oe(this,Zr,sb);ne(this,"errorHandler",wh);ne(this,"onError",e=>(this.errorHandler=e,this));ne(this,"notFound",e=>(ue(this,Zr,e),this));ne(this,"fetch",(e,...t)=>Te(this,st,Oo).call(this,e,t[1],t[0],e.method));ne(this,"request",(e,t,n,i)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,i):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${nn("/",e)}`,t),n,i)));ne(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(Te(this,st,Oo).call(this,e.request,e,void 0,e.request.method))})});[...nb,rb].forEach(i=>{this[i]=(s,...a)=>(typeof s=="string"?ue(this,rr,s):Te(this,st,Pn).call(this,i,w(this,rr),s),a.forEach(o=>{Te(this,st,Pn).call(this,i,w(this,rr),o)}),this)}),this.on=(i,s,...a)=>{for(const o of[s].flat()){ue(this,rr,o);for(const c of[i].flat())a.map(u=>{Te(this,st,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(i,...s)=>(typeof i=="string"?ue(this,rr,i):(ue(this,rr,"*"),s.unshift(i)),s.forEach(a=>{Te(this,st,Pn).call(this,it,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??Om:Dv}route(e,t){const n=this.basePath(e);return t.routes.map(i=>{var a;let s;t.errorHandler===wh?s=i.handler:(s=async(o,c)=>(await _h([],t.errorHandler)(o,()=>i.handler(o,c))).res,s[ib]=i.handler),Te(a=n,st,Pn).call(a,i.method,i.path,s)}),this}basePath(e){const t=Te(this,st,Dm).call(this);return t._basePath=nn(this._basePath,e),t}mount(e,t,n){let i,s;n&&(typeof n=="function"?s=n:(s=n.optionHandler,i=n.replaceRequest));const a=s?c=>{const u=s(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};i||(i=(()=>{const c=nn(this._basePath,e),u=c==="/"?0:c.length;return f=>{const m=new URL(f.url);return m.pathname=m.pathname.slice(u)||"/",new Request(m,f)}})());const o=async(c,u)=>{const f=await t(i(c.req.raw),...a(c));if(f)return f;await u()};return Te(this,st,Pn).call(this,it,nn(e,"*"),o),this}},rr=new WeakMap,st=new WeakSet,Dm=function(){const e=new $m({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Zr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const i={path:t,method:e,handler:n};this.router.add(e,t,[n,i]),this.routes.push(i)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,i){if(i==="HEAD")return(async()=>new Response(null,await Te(this,st,Oo).call(this,e,t,n,"GET")))();const s=this.getPath(e,{env:n}),a=this.router.match(i,s),o=new Bm(e,{path:s,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Zr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Zr).call(this,o)})}catch(f){return Te(this,st,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Zr).call(this,o))).catch(f=>Te(this,st,Ao).call(this,f,o)):u??w(this,Zr).call(this,o)}const c=_h(a[0],this.errorHandler,w(this,Zr));return(async()=>{try{const u=await c(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return Te(this,st,Ao).call(this,u,o)}})()},mm),Uo="[^/]+",$s=".*",Ds="(?:|/.*)",Os=Symbol(),ab=new Set(".\\+*[^]$()");function ob(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$s||r===Ds?1:e===$s||e===Ds?-1:r===Uo?1:e===Uo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,ym,vl=(ym=class{constructor(){Oe(this,Hn);Oe(this,Fn);Oe(this,nr,Object.create(null))}insert(e,t,n,i,s){if(e.length===0){if(w(this,Hn)!==void 0)throw Os;if(s)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$s]:["","",Uo]:a==="/*"?["","",Ds]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Uo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Os;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(B=>B!==$s&&B!==Ds))throw Os;if(s)return;u=w(this,nr)[m]=new vl,f!==""&&ue(u,Fn,i.varIndex++)}!s&&f!==""&&n.push([f,w(u,Fn)])}else if(u=w(this,nr)[a],!u){if(Object.keys(w(this,nr)).some(f=>f.length>1&&f!==$s&&f!==Ds))throw Os;if(s)return;u=w(this,nr)[a]=new vl}u.insert(o,t,n,i,s)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(ob).map(n=>{const i=w(this,nr)[n];return(typeof w(i,Fn)=="number"?`(${n})@${w(i,Fn)}`:ab.has(n)?`\\${n}`:n)+i.buildRegExpStr()});return typeof w(this,Hn)=="number"&&t.unshift(`#${w(this,Hn)}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}},Hn=new WeakMap,Fn=new WeakMap,nr=new WeakMap,ym),eu,Ga,gm,cb=(gm=class{constructor(){Oe(this,eu,{varIndex:0});Oe(this,Ga,new vl)}insert(r,e,t){const n=[],i=[];for(let a=0;;){let o=!1;if(r=r.replace(/\{[^}]+\}/g,c=>{const u=`@\\${a}`;return i[a]=[u,c],a++,o=!0,u}),!o)break}const s=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let a=i.length-1;a>=0;a--){const[o]=i[a];for(let c=s.length-1;c>=0;c--)if(s[c].indexOf(o)!==-1){s[c]=s[c].replace(o,i[a][1]);break}}return w(this,Ga).insert(s,e,n,w(this,eu),t),n}buildRegExp(){let r=w(this,Ga).buildRegExpStr();if(r==="")return[/^$/,[],[]];let e=0;const t=[],n=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,s,a)=>s!==void 0?(t[++e]=Number(s),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},eu=new WeakMap,Ga=new WeakMap,gm),Zm=[],ub=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Mm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function lb(){Eo=Object.create(null)}function db(r){var u;const e=new cb,t=[];if(r.length===0)return ub;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[B,C])=>f?1:B?-1:m.length-C.length),i=Object.create(null);for(let f=0,m=-1,B=n.length;f<B;f++){const[C,p,g]=n[f];C?i[p]=[g.map(([O])=>[O,Object.create(null)]),Zm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Os?new Pm(p):O}C||(t[m]=g.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[xe,Le]=A[P];N[xe]=Le}return[O,N]}))}const[s,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let B=0,C=t[f].length;B<C;B++){const p=(u=t[f][B])==null?void 0:u[1];if(!p)continue;const g=Object.keys(p);for(let A=0,O=g.length;A<O;A++)p[g[A]]=o[p[g[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[s,c,i]}function _i(r,e){if(r){for(const t of Object.keys(r).sort((n,i)=>i.length-n.length))if(Mm(t).test(e))return[...r[t]]}}var un,ln,os,Um,Vm,vm,fb=(vm=class{constructor(){Oe(this,os);ne(this,"name","RegExpRouter");Oe(this,un);Oe(this,ln);ue(this,un,{[it]:Object.create(null)}),ue(this,ln,{[it]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),i=w(this,ln);if(!n||!i)throw new Error(Rm);n[r]||[n,i].forEach(c=>{c[r]=Object.create(null),Object.keys(c[it]).forEach(u=>{c[r][u]=[...c[it][u]]})}),e==="/*"&&(e="*");const s=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Mm(e);r===it?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_i(n[u],e)||_i(n[it],e)||[])}):(o=n[r])[e]||(o[e]=_i(n[r],e)||_i(n[it],e)||[]),Object.keys(n).forEach(u=>{(r===it||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,s])})}),Object.keys(i).forEach(u=>{(r===it||r===u)&&Object.keys(i[u]).forEach(f=>c.test(f)&&i[u][f].push([t,s]))});return}const a=Em(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(i).forEach(m=>{var B;(r===it||r===m)&&((B=i[m])[f]||(B[f]=[..._i(n[m],f)||_i(n[it],f)||[]]),i[m][f].push([t,s-u+c+1]))})}}match(r,e){lb();const t=Te(this,os,Um).call(this);return this.match=(n,i)=>{const s=t[n]||t[it],a=s[2][i];if(a)return a;const o=i.match(s[0]);if(!o)return[[],Zm];const c=o.indexOf("",1);return[s[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,os=new WeakSet,Um=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=Te(this,os,Vm).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},Vm=function(r){const e=[];let t=r===it;return[w(this,un),w(this,ln)].forEach(n=>{const i=n[r]?Object.keys(n[r]).map(s=>[s,n[r][s]]):[];i.length!==0?(t||(t=!0),e.push(...i)):r!==it&&e.push(...Object.keys(n[it]).map(s=>[s,n[it][s]]))}),t?db(e):null},vm),dn,Mr,bm,hb=(bm=class{constructor(r){ne(this,"name","SmartRouter");Oe(this,dn,[]);Oe(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(Rm);w(this,Mr).push([r,e,t])}match(r,e){if(!w(this,Mr))throw new Error("Fatal error");const t=w(this,dn),n=w(this,Mr),i=t.length;let s=0,a;for(;s<i;s++){const o=t[s];try{for(let c=0,u=n.length;c<u;c++)o.add(...n[c]);a=o.match(r,e)}catch(c){if(c instanceof Pm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(s===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(w(this,Mr)||w(this,dn).length!==1)throw new Error("No active router has been determined yet.");return w(this,dn)[0]}},dn=new WeakMap,Mr=new WeakMap,bm),fn,bt,Kn,Mi,Et,Ur,$n,xm,Lm=(xm=class{constructor(r,e,t){Oe(this,Ur);Oe(this,fn);Oe(this,bt);Oe(this,Kn);Oe(this,Mi,0);Oe(this,Et,Object.create(null));if(ue(this,bt,t||Object.create(null)),ue(this,fn,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},ue(this,fn,[n])}ue(this,Kn,[])}insert(r,e,t){ue(this,Mi,++gh(this,Mi)._);let n=this;const i=Bv(e),s=[];for(let c=0,u=i.length;c<u;c++){const f=i[c];if(Object.keys(w(n,bt)).includes(f)){n=w(n,bt)[f];const B=bh(f);B&&s.push(B[1]);continue}w(n,bt)[f]=new Lm;const m=bh(f);m&&(w(n,Kn).push(m),s.push(m[1])),n=w(n,bt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:s.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Mi)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Et,Object.create(null));let i=[this];const s=Sm(e);for(let o=0,c=s.length;o<c;o++){const u=s[o],f=o===c-1,m=[];for(let B=0,C=i.length;B<C;B++){const p=i[B],g=w(p,bt)[u];g&&(ue(g,Et,w(p,Et)),f?(w(g,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(g,bt)["*"],r,w(p,Et),Object.create(null))),t.push(...Te(this,Ur,$n).call(this,g,r,w(p,Et),Object.create(null)))):m.push(g));for(let A=0,O=w(p,Kn).length;A<O;A++){const P=w(p,Kn)[A],N={...w(p,Et)};if(P==="*"){const mt=w(p,bt)["*"];mt&&(t.push(...Te(this,Ur,$n).call(this,mt,r,w(p,Et),Object.create(null))),m.push(mt));continue}if(u==="")continue;const[xe,Le,qe]=P,Ze=w(p,bt)[xe],tt=s.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...Te(this,Ur,$n).call(this,Ze,r,w(p,Et),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...Te(this,Ur,$n).call(this,Ze,r,N,w(p,Et))),w(Ze,bt)["*"]&&t.push(...Te(this,Ur,$n).call(this,w(Ze,bt)["*"],r,N,w(p,Et)))):(ue(Ze,Et,N),m.push(Ze)))}}i=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,bt=new WeakMap,Kn=new WeakMap,Mi=new WeakMap,Et=new WeakMap,Ur=new WeakSet,$n=function(r,e,t,n){const i=[];for(let s=0,a=w(r,fn).length;s<a;s++){const o=w(r,fn)[s],c=o[e]||o[it],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const B=c.possibleKeys[f],C=u[c.score];c.params[B]=n[B]&&!C?n[B]:t[B]??n[B],u[c.score]=!0}i.push(c)}}return i},xm),Wn,_m,pb=(_m=class{constructor(){ne(this,"name","TrieRouter");Oe(this,Wn);ue(this,Wn,new Lm)}add(r,e,t){const n=Em(e);if(n){for(let i=0,s=n.length;i<s;i++)w(this,Wn).insert(r,n[i],t);return}w(this,Wn).insert(r,e,t)}match(r,e){return w(this,Wn).search(r,e)}},Wn=new WeakMap,_m),mb=class extends $m{constructor(r={}){super(r),this.router=r.router??new hb({routers:[new fb,new pb]})}},Re;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Re||(Re={}));var bl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(bl||(bl={}));const z=Re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),sn=r=>{switch(typeof r){case"undefined":return z.undefined;case"string":return z.string;case"number":return isNaN(r)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(r)?z.array:r===null?z.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?z.promise:typeof Map<"u"&&r instanceof Map?z.map:typeof Set<"u"&&r instanceof Set?z.set:typeof Date<"u"&&r instanceof Date?z.date:z.object;default:return z.unknown}},D=Re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),yb=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class qm extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof qm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Ui=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Re.joinValues(r.options)}, received '${r.received}'`;break;case D.invalid_arguments:t="Invalid function arguments";break;case D.invalid_return_type:t="Invalid function return type";break;case D.invalid_date:t="Invalid date";break;case D.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Re.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case D.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case D.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case D.custom:t="Invalid input";break;case D.invalid_intersection_types:t="Intersection results could not be merged";break;case D.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case D.not_finite:t="Number must be finite";break;default:t=e.defaultError,Re.assertNever(r)}return{message:t}};let Hm=Ui;function gb(r){Hm=r}function Vo(){return Hm}const Lo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},vb=[];function H(r,e){const t=Vo(),n=Lo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ui?void 0:Ui].filter(i=>!!i)});r.common.issues.push(n)}let jt=class Fm{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return Fm.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Oi=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),xl=r=>r.status==="aborted",_l=r=>r.status==="dirty",Ls=r=>r.status==="valid",qs=r=>typeof Promise<"u"&&r instanceof Promise;function qo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Km(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Es,Is;let Sr=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const kh=(r,e)=>{if(Ls(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new or(r.common.issues);return this._error=t,this._error}}};function _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:i}}let Ae=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return sn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new jt,ctx:{common:e.parent.common,data:e.data,parsedType:sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(qs(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return kh(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(qs(i)?i:Promise.resolve(i));return kh(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:D.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new dr({schema:this,typeName:de.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qn.create(this,this._def)}promise(){return qi.create(this,this._def)}or(e){return Js.create([this,e],this._def)}and(e){return Ys.create(this,e,this._def)}transform(e){return new dr({..._e(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({..._e(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new of({typeName:de.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({..._e(this._def),innerType:this,catchValue:t,typeName:de.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return cf.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const bb=/^c[^\s-]{8,}$/i,xb=/^[0-9a-z]+$/,_b=/^[0-9A-HJKMNP-TV-Z]{26}$/,wb=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,kb=/^[a-z0-9_-]{21}$/i,Sb=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ab=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ob="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tl;const Eb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ib=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Cb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wm="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",jb=new RegExp(`^${Wm}$`);function zm(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Tb(r){return new RegExp(`^${zm(r)}$`)}function Gm(r){let e=`${Wm}T${zm(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Nb(r,e){return!!((e==="v4"||!e)&&Eb.test(r)||(e==="v6"||!e)&&Ib.test(r))}let Vi=class Cs extends Ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.string,received:s.parsedType}),pe}const n=new jt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?H(i,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&H(i,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Ab.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"email",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")tl||(tl=new RegExp(Ob,"u")),tl.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"emoji",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")wb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"uuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")kb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"nanoid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")bb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")xb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"cuid2",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")_b.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ulid",code:D.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),H(i,{validation:"url",code:D.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"regex",code:D.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Gm(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?jb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Tb(s).test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:D.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Sb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"duration",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Nb(e.data,s.version)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"ip",code:D.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Cb.test(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{validation:"base64",code:D.invalid_string,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:D.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Cs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ae.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ae.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...ae.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ae.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ae.errToObj(t)})}nonempty(e){return this.min(1,ae.errToObj(e))}trim(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Cs({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Vi.create=r=>{var e;return new Vi({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function Bb(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}let Hs=class wl extends Ae{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.number,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Bb(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_finite,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new wl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new wl({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ae.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ae.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Re.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Hs.create=r=>new Hs({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Fs=class kl extends Ae{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==z.bigint){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.bigint,received:s.parsedType}),pe}let n;const i=new jt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Re.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,i){return new kl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(i)}]})}_addCheck(e){return new kl({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ae.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Fs.create=r=>{var e;return new Fs({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};let Ks=class extends Ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return _t(e.data)}};Ks.create=r=>new Ks({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});let Ws=class Jm extends Ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_type,expected:z.date,received:s.parsedType}),pe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return H(s,{code:D.invalid_date}),pe}const n=new jt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),H(i,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Re.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Jm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Ws.create=r=>new Ws({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,..._e(r)});let Ho=class extends Ae{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return _t(e.data)}};Ho.create=r=>new Ho({typeName:de.ZodSymbol,..._e(r)});let zs=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return _t(e.data)}};zs.create=r=>new zs({typeName:de.ZodUndefined,..._e(r)});let Gs=class extends Ae{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.null,received:n.parsedType}),pe}return _t(e.data)}};Gs.create=r=>new Gs({typeName:de.ZodNull,..._e(r)});let Li=class extends Ae{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}};Li.create=r=>new Li({typeName:de.ZodAny,..._e(r)});let zn=class extends Ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,..._e(r)});let Hr=class extends Ae{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:D.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,..._e(r)});let Fo=class extends Ae{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.void,received:n.parsedType}),pe}return _t(e.data)}};Fo.create=r=>new Fo({typeName:de.ZodVoid,..._e(r)});let Qn=class Io extends Ae{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==z.array)return H(t,{code:D.invalid_type,expected:z.array,received:t.parsedType}),pe;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(H(t,{code:a?D.too_big:D.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(H(t,{code:D.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(H(t,{code:D.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>jt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Sr(t,a,t.path,o)));return jt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Io({...this._def,minLength:{value:e,message:ae.toString(t)}})}max(e,t){return new Io({...this._def,maxLength:{value:e,message:ae.toString(t)}})}length(e,t){return new Io({...this._def,exactLength:{value:e,message:ae.toString(t)}})}nonempty(e){return this.min(1,e)}};Qn.create=(r,e)=>new Qn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:de.ZodArray,..._e(e)});function ki(r){if(r instanceof Kt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ki(n))}return new Kt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ki(r.element)}):r instanceof xr?xr.create(ki(r.unwrap())):r instanceof vn?vn.create(ki(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ki(e))):r}let Kt=class Xt extends Ae{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:D.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],m=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(i,m,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Hr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(H(i,{code:D.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(i,m,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,B=await f.value;u.push({key:m,value:B,alwaysSet:f.alwaysSet})}return u}).then(u=>jt.mergeObjectSync(n,u)):jt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ae.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:de.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){const t={};return Re.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}omit(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return ki(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof xr;)s=s._def.innerType;t[n]=s}}),new Xt({...this._def,shape:()=>t})}keyof(){return ry(Re.objectKeys(this.shape))}};Kt.create=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.strictCreate=(r,e)=>new Kt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});Kt.lazycreate=(r,e)=>new Kt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,..._e(e)});let Js=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new or(o.ctx.common.issues));return H(t,{code:D.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new or(c));return H(t,{code:D.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Js.create=(r,e)=>new Js({options:r,typeName:de.ZodUnion,..._e(e)});const Br=r=>r instanceof Xs?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qs?[r.value]:r instanceof Ja?r.options:r instanceof ea?Re.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zs?[void 0]:r instanceof Gs?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof of||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Ym=class Xm extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:D.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=Br(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new Xm({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,..._e(n)})}};function Sl(r,e){const t=sn(r),n=sn(e);if(r===e)return{valid:!0,data:r};if(t===z.object&&n===z.object){const i=Re.objectKeys(e),s=Re.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Sl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===z.array&&n===z.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Sl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Ys=class extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(xl(s)||xl(a))return pe;const o=Sl(s.value,a.value);return o.valid?((_l(s)||_l(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:D.invalid_intersection_types}),pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ys.create=(r,e,t)=>new Ys({left:r,right:e,typeName:de.ZodIntersection,..._e(t)});let gn=class Qm extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:D.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>jt.mergeArray(t,a)):jt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qm({...this._def,rest:e})}};gn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new gn({items:r,typeName:de.ZodTuple,rest:null,..._e(e)})};let ey=class Al extends Ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return H(n,{code:D.invalid_type,expected:z.object,received:n.parsedType}),pe;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Sr(n,o,n.path,o)),value:a._parse(new Sr(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?jt.mergeObjectAsync(t,i):jt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ae?new Al({keyType:e,valueType:t,typeName:de.ZodRecord,..._e(n)}):new Al({keyType:Vi.create(),valueType:e,typeName:de.ZodRecord,..._e(t)})}},Ko=class extends Ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return H(n,{code:D.invalid_type,expected:z.map,received:n.parsedType}),pe;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Sr(n,o,n.path,[u,"key"])),value:s._parse(new Sr(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return pe;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}};Ko.create=(r,e,t)=>new Ko({valueType:e,keyType:r,typeName:de.ZodMap,..._e(t)});let Wo=class Ol extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:D.invalid_type,expected:z.set,received:n.parsedType}),pe;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(H(n,{code:D.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(H(n,{code:D.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Ol({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new Ol({...this._def,maxSize:{value:e,message:ae.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Wo.create=(r,e)=>new Wo({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,..._e(e)});let ty=class Co extends Ae{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:D.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function i(o,c){return Lo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vo(),Ui].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qi){const o=this;return _t(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,s).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(C=>{throw u.addIssue(i(m,C)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new or([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Co({...this._def,args:gn.create(e).rest(zn.create())})}returns(e){return new Co({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Co({args:e||gn.create([]).rest(zn.create()),returns:t||zn.create(),typeName:de.ZodFunction,..._e(n)})}},Xs=class extends Ae{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Xs.create=(r,e)=>new Xs({getter:r,typeName:de.ZodLazy,..._e(e)});let Qs=class extends Ae{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qs.create=(r,e)=>new Qs({value:r,typeName:de.ZodLiteral,..._e(e)});function ry(r,e){return new Ja({values:r,typeName:de.ZodEnum,..._e(e)})}let Ja=class El extends Ae{constructor(){super(...arguments),Es.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Re.joinValues(n),received:t.parsedType,code:D.invalid_type}),pe}if(qo(this,Es)||Km(this,Es,new Set(this._def.values)),!qo(this,Es).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:D.invalid_enum_value,options:n}),pe}return _t(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return El.create(e,{...this._def,...t})}exclude(e,t=this._def){return El.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Es=new WeakMap;Ja.create=ry;let ea=class extends Ae{constructor(){super(...arguments),Is.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){const i=Re.objectValues(t);return H(n,{expected:Re.joinValues(i),received:n.parsedType,code:D.invalid_type}),pe}if(qo(this,Is)||Km(this,Is,new Set(Re.getValidEnumValues(this._def.values))),!qo(this,Is).has(e.data)){const i=Re.objectValues(t);return H(n,{received:n.data,code:D.invalid_enum_value,options:i}),pe}return _t(e.data)}get enum(){return this._def.values}};Is=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,..._e(e)});let qi=class extends Ae{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.promise&&t.common.async===!1)return H(t,{code:D.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return _t(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qi.create=(r,e)=>new qi({type:r,typeName:de.ZodPromise,..._e(e)});let dr=class extends Ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return pe;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?pe:c.status==="dirty"||t.value==="dirty"?Oi(c.value):c});{if(t.value==="aborted")return pe;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?pe:o.status==="dirty"||t.value==="dirty"?Oi(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ls(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Ls(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Re.assertNever(i)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,..._e(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,..._e(t)});let xr=class extends Ae{_parse(e){return this._getType(e)===z.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,..._e(e)});let vn=class extends Ae{_parse(e){return this._getType(e)===z.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,..._e(e)});let ta=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ta.create=(r,e)=>new ta({innerType:r,typeName:de.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});let ra=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qs(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ra.create=(r,e)=>new ra({innerType:r,typeName:de.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});let zo=class extends Ae{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:D.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};zo.create=r=>new zo({typeName:de.ZodNaN,..._e(r)});const Rb=Symbol("zod_brand");let of=class extends Ae{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},cf=class ny extends Ae{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),Oi(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new ny({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Ae{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Ls(i)&&(i.value=Object.freeze(i.value)),i);return qs(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,..._e(e)});function iy(r,e={},t){return r?Li.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Li.create()}const Pb={object:Kt.lazycreate};var de;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(de||(de={}));const $b=(r,e={message:`Input not instance of ${r.name}`})=>iy(t=>t instanceof r,e),sy=Vi.create,ay=Hs.create,Db=zo.create,Zb=Fs.create,oy=Ks.create,Mb=Ws.create,Ub=Ho.create,Vb=zs.create,Lb=Gs.create,qb=Li.create,Hb=zn.create,Fb=Hr.create,Kb=Fo.create,Wb=Qn.create,zb=Kt.create,Gb=Kt.strictCreate,Jb=Js.create,Yb=Ym.create,Xb=Ys.create,Qb=gn.create,ex=ey.create,tx=Ko.create,rx=Wo.create,nx=ty.create,ix=Xs.create,sx=Qs.create,ax=Ja.create,ox=ea.create,cx=qi.create,Sh=dr.create,ux=xr.create,lx=vn.create,dx=dr.createWithPreprocess,fx=cf.create,hx=()=>sy().optional(),px=()=>ay().optional(),mx=()=>oy().optional(),yx={string:r=>Vi.create({...r,coerce:!0}),number:r=>Hs.create({...r,coerce:!0}),boolean:r=>Ks.create({...r,coerce:!0}),bigint:r=>Fs.create({...r,coerce:!0}),date:r=>Ws.create({...r,coerce:!0})},gx=pe;var y=Object.freeze({__proto__:null,defaultErrorMap:Ui,setErrorMap:gb,getErrorMap:Vo,makeIssue:Lo,EMPTY_PATH:vb,addIssueToContext:H,ParseStatus:jt,INVALID:pe,DIRTY:Oi,OK:_t,isAborted:xl,isDirty:_l,isValid:Ls,isAsync:qs,get util(){return Re},get objectUtil(){return bl},ZodParsedType:z,getParsedType:sn,ZodType:Ae,datetimeRegex:Gm,ZodString:Vi,ZodNumber:Hs,ZodBigInt:Fs,ZodBoolean:Ks,ZodDate:Ws,ZodSymbol:Ho,ZodUndefined:zs,ZodNull:Gs,ZodAny:Li,ZodUnknown:zn,ZodNever:Hr,ZodVoid:Fo,ZodArray:Qn,ZodObject:Kt,ZodUnion:Js,ZodDiscriminatedUnion:Ym,ZodIntersection:Ys,ZodTuple:gn,ZodRecord:ey,ZodMap:Ko,ZodSet:Wo,ZodFunction:ty,ZodLazy:Xs,ZodLiteral:Qs,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qi,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:zo,BRAND:Rb,ZodBranded:of,ZodPipeline:cf,ZodReadonly:na,custom:iy,Schema:Ae,ZodSchema:Ae,late:Pb,get ZodFirstPartyTypeKind(){return de},coerce:yx,any:qb,array:Wb,bigint:Zb,boolean:oy,date:Mb,discriminatedUnion:Yb,effect:Sh,enum:ax,function:nx,instanceof:$b,intersection:Xb,lazy:ix,literal:sx,map:tx,nan:Db,nativeEnum:ox,never:Fb,null:Lb,nullable:lx,number:ay,object:zb,oboolean:mx,onumber:px,optional:ux,ostring:hx,pipeline:fx,preprocess:dx,promise:cx,record:ex,set:rx,strictObject:Gb,string:sy,symbol:Ub,transformer:Sh,tuple:Qb,undefined:Vb,union:Jb,unknown:Hb,void:Kb,NEVER:gx,ZodIssueCode:D,quotelessJson:yb,ZodError:or}),dt=class Il extends mb{constructor(t){super(t);ne(this,"openAPIRegistry");ne(this,"defaultHook");ne(this,"openapi",({middleware:t,...n},i,s=this.defaultHook)=>{var u,f,m,B,C,p,g,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xi("query",n.request.query,s);a.push(N)}if((f=n.request)!=null&&f.params){const N=xi("param",n.request.params,s);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xi("header",n.request.headers,s);a.push(N)}if((B=n.request)!=null&&B.cookies){const N=xi("cookie",n.request.cookies,s);a.push(N)}const o=(p=(C=n.request)==null?void 0:C.body)==null?void 0:p.content;if(o)for(const N of Object.keys(o)){if(!o[N])continue;const xe=o[N].schema;if(xe instanceof Ae){if(Oh(N)){const Le=xi("json",xe,s);if((A=(g=n.request)==null?void 0:g.body)!=null&&A.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Oh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(Eh(N)){const Le=xi("form",xe,s);if((P=(O=n.request)==null?void 0:O.body)!=null&&P.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&Eh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("form",{}),await tt()};a.push(qe)}}}}const c=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...c,...a,i),this});ne(this,"getOpenAPIDocument",t=>{const i=new Cv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Ah(i,this._basePath):i});ne(this,"getOpenAPI31Document",t=>{const i=new Nv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?Ah(i,this._basePath):i});ne(this,"doc",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPIDocument(s);return i.json(a)}catch(a){return i.json(a,500)}}));ne(this,"doc31",(t,n)=>this.get(t,i=>{const s=typeof n=="function"?n(i):n;try{const a=this.getOpenAPI31Document(s);return i.json(a)}catch(a){return i.json(a,500)}}));this.openAPIRegistry=new dv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const i=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof Il?(n.openAPIRegistry.definitions.forEach(s=>{switch(s.type){case"component":return this.openAPIRegistry.registerComponent(s.componentType,s.name,s.component);case"route":return this.openAPIRegistry.registerPath({...s.route,path:nn(i,s.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...s.webhook,path:nn(i,s.webhook.path)});case"schema":return this.openAPIRegistry.register(s.schema._def.openapi._internal.refId,s.schema);case"parameter":return this.openAPIRegistry.registerParameter(s.schema._def.openapi._internal.refId,s.schema);default:{const a=s;throw new Error(`Unknown registry type: ${a}`)}}}),this):this}basePath(t){return new Il({...super.basePath(t),defaultHook:this.defaultHook})}},ve=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};ov(y);function Ah(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function Oh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function Eh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function vx(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function bx(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ks(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const i=t.apply(this,n);return i._def.openapi=this._def.openapi,i}}function xx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(i,s){var a,o,c,u,f,m;const B=typeof i=="string"?s:i,C=B??{},{param:p}=C,g=vx(C,["param"]),A=Object.assign(Object.assign({},(a=this._def.openapi)===null||a===void 0?void 0:a._internal),typeof i=="string"?{refId:i}:void 0),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),P=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(bx(this,"ZodObject")){const N=this.extend;P.extend=function(...xe){var Le,qe,Ze,tt,mt,Rt;const I=N.apply(this,xe);return I._def.openapi={_internal:{extendedFrom:!((qe=(Le=this._def.openapi)===null||Le===void 0?void 0:Le._internal)===null||qe===void 0)&&qe.refId?{refId:(tt=(Ze=this._def.openapi)===null||Ze===void 0?void 0:Ze._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(mt=this._def.openapi)===null||mt===void 0?void 0:mt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ks(r,"optional"),ks(r,"nullable"),ks(r,"default"),ks(r,"transform"),ks(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const i=this._def.shape(),s=e.apply(this),a=s._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=i[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),s._def.openapi=void 0,s};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...i){const s=t.apply(this,i);return s._def.openapi=void 0,s};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...i){const s=n.apply(this,i);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var Pe;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Pe||(Pe={}));var Cl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Cl||(Cl={}));const G=Pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),an=r=>{switch(typeof r){case"undefined":return G.undefined;case"string":return G.string;case"number":return isNaN(r)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(r)?G.array:r===null?G.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?G.promise:typeof Map<"u"&&r instanceof Map?G.map:typeof Set<"u"&&r instanceof Set?G.set:typeof Date<"u"&&r instanceof Date?G.date:G.object;default:return G.unknown}},Z=Pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),_x=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Dt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const Hi=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Pe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(r)}return{message:t}};let cy=Hi;function wx(r){cy=r}function Go(){return cy}const Jo=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},kx=[];function F(r,e){const t=Go(),n=Jo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hi?void 0:Hi].filter(i=>!!i)});r.common.issues.push(n)}class gt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return ge;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return ge;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const ge=Object.freeze({status:"aborted"}),Yo=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),jl=r=>r.status==="aborted",Tl=r=>r.status==="dirty",ia=r=>r.status==="valid",sa=r=>typeof Promise<"u"&&r instanceof Promise;function Xo(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function uy(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var js,Ts;class Ar{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ih=(r,e)=>{if(ia(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Dt(r.common.issues);return this._error=t,this._error}}};function we(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{var o,c;const{message:u}=r;return s.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:i}}class Ee{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return an(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gt,ctx:{common:e.parent.common,data:e.data,parsedType:an(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(sa(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Ih(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(sa(i)?i:Promise.resolve(i));return Ih(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:Z.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new fr({schema:this,typeName:fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return wn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return cr.create(this,this._def)}promise(){return Ki.create(this,this._def)}or(e){return ua.create([this,e],this._def)}and(e){return la.create(this,e,this._def)}transform(e){return new fr({...we(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({...we(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new uf({typeName:fe.ZodBranded,type:this,...we(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({...we(this._def),innerType:this,catchValue:t,typeName:fe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ya.create(this,e)}readonly(){return ga.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Sx=/^c[^\s-]{8,}$/i,Ax=/^[0-9a-z]+$/,Ox=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ex=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ix=/^[a-z0-9_-]{21}$/i,Cx=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,jx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let rl;const Nx=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Bx=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Rx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ly="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Px=new RegExp(`^${ly}$`);function dy(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function $x(r){return new RegExp(`^${dy(r)}$`)}function fy(r){let e=`${ly}T${dy(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Dx(r,e){return!!((e==="v4"||!e)&&Nx.test(r)||(e==="v6"||!e)&&Bx.test(r))}class ir extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.string,received:i.parsedType}),ge}const t=new gt;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="length"){const s=e.data.length>i.value,a=e.data.length<i.value;(s||a)&&(n=this._getOrReturnCtx(e,n),s?F(n,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&F(n,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if(i.kind==="email")jx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="emoji")rl||(rl=new RegExp(Tx,"u")),rl.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="uuid")Ex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="nanoid")Ix.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid")Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="cuid2")Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="ulid")Ox.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:Z.invalid_string,message:i.message}),t.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:Z.invalid_string,message:i.message}),t.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:Z.invalid_string,message:i.message}),t.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty()):i.kind==="datetime"?fy(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"datetime",message:i.message}),t.dirty()):i.kind==="date"?Px.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"date",message:i.message}),t.dirty()):i.kind==="time"?$x(i).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:Z.invalid_string,validation:"time",message:i.message}),t.dirty()):i.kind==="duration"?Cx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="ip"?Dx(e.data,i.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:Z.invalid_string,message:i.message}),t.dirty()):i.kind==="base64"?Rx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:Z.invalid_string,message:i.message}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Z.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new ir({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...oe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...oe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...oe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...oe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...oe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...oe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...oe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...oe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...oe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...oe.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...oe.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...oe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...oe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...oe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...oe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...oe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...oe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...oe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...oe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...oe.errToObj(t)})}nonempty(e){return this.min(1,oe.errToObj(e))}trim(){return new ir({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ir({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ir({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ir.create=r=>{var e;return new ir({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};function Zx(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class bn extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.number,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?Zx(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_finite,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new bn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:oe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:oe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:oe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:oe.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Pe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}bn.create=r=>new bn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class xn extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==G.bigint){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.bigint,received:i.parsedType}),ge}let t;const n=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,i){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(i)}]})}_addCheck(e){return new xn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:oe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:oe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oe.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}xn.create=r=>{var e;return new xn({checks:[],typeName:fe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...we(r)})};class aa extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.boolean,received:t.parsedType}),ge}return wt(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...we(r)});class ei extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_type,expected:G.date,received:i.parsedType}),ge}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return F(i,{code:Z.invalid_date}),ge}const t=new gt;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):Pe.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:oe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:oe.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ei.create=r=>new ei({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...we(r)});class Qo extends Ee{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.symbol,received:t.parsedType}),ge}return wt(e.data)}}Qo.create=r=>new Qo({typeName:fe.ZodSymbol,...we(r)});class oa extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.undefined,received:t.parsedType}),ge}return wt(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,...we(r)});class ca extends Ee{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.null,received:t.parsedType}),ge}return wt(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,...we(r)});class Fi extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Fi.create=r=>new Fi({typeName:fe.ZodAny,...we(r)});class Gn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,...we(r)});class Fr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.never,received:t.parsedType}),ge}}Fr.create=r=>new Fr({typeName:fe.ZodNever,...we(r)});class ec extends Ee{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.void,received:t.parsedType}),ge}return wt(e.data)}}ec.create=r=>new ec({typeName:fe.ZodVoid,...we(r)});class cr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==G.array)return F(t,{code:Z.invalid_type,expected:G.array,received:t.parsedType}),ge;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(F(t,{code:a?Z.too_big:Z.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(F(t,{code:Z.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(F(t,{code:Z.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Ar(t,a,t.path,o)));return gt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new cr({...this._def,minLength:{value:e,message:oe.toString(t)}})}max(e,t){return new cr({...this._def,maxLength:{value:e,message:oe.toString(t)}})}length(e,t){return new cr({...this._def,exactLength:{value:e,message:oe.toString(t)}})}nonempty(e){return this.min(1,e)}}cr.create=(r,e)=>new cr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:fe.ZodArray,...we(e)});function Si(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Si(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Si(r.element)}):r instanceof _r?_r.create(Si(r.unwrap())):r instanceof wn?wn.create(Si(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Si(e))):r}class Je extends Ee{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Pe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==G.object){const c=this._getOrReturnCtx(e);return F(c,{code:Z.invalid_type,expected:G.object,received:c.parsedType}),ge}const{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)s.includes(c)||a.push(c);const o=[];for(const c of s){const u=i[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ar(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Fr){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)o.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")a.length>0&&(F(n,{code:Z.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ar(n,f,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const f=await u.key,m=await u.value;c.push({key:f,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>gt.mergeObjectSync(t,c)):gt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return Pe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return Si(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Je({...this._def,shape:()=>t})}required(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof _r;)i=i._def.innerType;t[n]=i}}),new Je({...this._def,shape:()=>t})}keyof(){return hy(Pe.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...we(e)});class ua extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Dt(o.ctx.common.issues));return F(t,{code:Z.invalid_union,unionErrors:a}),ge}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new Dt(c));return F(t,{code:Z.invalid_union,unionErrors:o}),ge}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,...we(e)});const rn=r=>r instanceof fa?rn(r.schema):r instanceof fr?rn(r.innerType()):r instanceof ha?[r.value]:r instanceof _n?r.options:r instanceof pa?Pe.objectValues(r.enum):r instanceof ma?rn(r._def.innerType):r instanceof oa?[void 0]:r instanceof ca?[null]:r instanceof _r?[void 0,...rn(r.unwrap())]:r instanceof wn?[null,...rn(r.unwrap())]:r instanceof uf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class ru extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:Z.invalid_type,expected:G.object,received:t.parsedType}),ge;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ge)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=rn(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new ru({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...we(n)})}}function Nl(r,e){const t=an(r),n=an(e);if(r===e)return{valid:!0,data:r};if(t===G.object&&n===G.object){const i=Pe.objectKeys(e),s=Pe.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=Nl(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=Nl(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(jl(s)||jl(a))return ge;const o=Nl(s.value,a.value);return o.valid?((Tl(s)||Tl(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:Z.invalid_intersection_types}),ge)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,...we(t)});class Or extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:Z.invalid_type,expected:G.array,received:n.parsedType}),ge;if(n.data.length<this._def.items.length)return F(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ge;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((s,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>gt.mergeArray(t,s)):gt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Or({...this._def,rest:e})}}Or.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Or({items:r,typeName:fe.ZodTuple,rest:null,...we(e)})};class da extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return F(n,{code:Z.invalid_type,expected:G.object,received:n.parsedType}),ge;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?gt.mergeObjectAsync(t,i):gt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,...we(n)}):new da({keyType:ir.create(),valueType:e,typeName:fe.ZodRecord,...we(t)})}}class tc extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return F(n,{code:Z.invalid_type,expected:G.map,received:n.parsedType}),ge;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Ar(n,o,n.path,[u,"key"])),value:s._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ge;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}tc.create=(r,e,t)=>new tc({valueType:e,keyType:r,typeName:fe.ZodMap,...we(t)});class ti extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:Z.invalid_type,expected:G.set,received:n.parsedType}),ge;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(F(n,{code:Z.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(F(n,{code:Z.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ge;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ti({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ti({...this._def,maxSize:{value:e,message:oe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ti.create=(r,e)=>new ti({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...we(e)});class Ti extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:Z.invalid_type,expected:G.function,received:t.parsedType}),ge;function n(o,c){return Jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Go(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function i(o,c){return Jo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Go(),Hi].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ki){const o=this;return wt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,s).catch(B=>{throw u.addIssue(n(c,B)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(B=>{throw u.addIssue(i(m,B)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new Dt([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ti({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ti({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ti({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,...we(n)})}}class fa extends Ee{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}fa.create=(r,e)=>new fa({getter:r,typeName:fe.ZodLazy,...we(e)});class ha extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),ge}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,...we(e)});function hy(r,e){return new _n({values:r,typeName:fe.ZodEnum,...we(e)})}class _n extends Ee{constructor(){super(...arguments),js.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Pe.joinValues(n),received:t.parsedType,code:Z.invalid_type}),ge}if(Xo(this,js)||uy(this,js,new Set(this._def.values)),!Xo(this,js).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:Z.invalid_enum_value,options:n}),ge}return wt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return _n.create(e,{...this._def,...t})}exclude(e,t=this._def){return _n.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}js=new WeakMap;_n.create=hy;class pa extends Ee{constructor(){super(...arguments),Ts.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const i=Pe.objectValues(t);return F(n,{expected:Pe.joinValues(i),received:n.parsedType,code:Z.invalid_type}),ge}if(Xo(this,Ts)||uy(this,Ts,new Set(Pe.getValidEnumValues(this._def.values))),!Xo(this,Ts).has(e.data)){const i=Pe.objectValues(t);return F(n,{received:n.data,code:Z.invalid_enum_value,options:i}),ge}return wt(e.data)}get enum(){return this._def.values}}Ts=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,...we(e)});class Ki extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.promise&&t.common.async===!1)return F(t,{code:Z.invalid_type,expected:G.promise,received:t.parsedType}),ge;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return wt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ki.create=(r,e)=>new Ki({type:r,typeName:fe.ZodPromise,...we(e)});class fr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ge;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ge:c.status==="dirty"||t.value==="dirty"?Yo(c.value):c});{if(t.value==="aborted")return ge;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ge:o.status==="dirty"||t.value==="dirty"?Yo(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ge:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ge:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ia(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ia(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(i)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,...we(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...we(t)});class _r extends Ee{_parse(e){return this._getType(e)===G.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:fe.ZodOptional,...we(e)});class wn extends Ee{_parse(e){return this._getType(e)===G.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wn.create=(r,e)=>new wn({innerType:r,typeName:fe.ZodNullable,...we(e)});class ma extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ma.create=(r,e)=>new ma({innerType:r,typeName:fe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...we(e)});class ya extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return sa(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ya.create=(r,e)=>new ya({innerType:r,typeName:fe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...we(e)});class rc extends Ee{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:Z.invalid_type,expected:G.nan,received:t.parsedType}),ge}return{status:"valid",value:e.data}}}rc.create=r=>new rc({typeName:fe.ZodNaN,...we(r)});const Mx=Symbol("zod_brand");class uf extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ya extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),Yo(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ge:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=i=>(ia(i)&&(i.value=Object.freeze(i.value)),i);return sa(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,...we(e)});function py(r,e={},t){return r?Fi.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):Fi.create()}const Ux={object:Je.lazycreate};var fe;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(fe||(fe={}));const Vx=(r,e={message:`Input not instance of ${r.name}`})=>py(t=>t instanceof r,e),my=ir.create,yy=bn.create,Lx=rc.create,qx=xn.create,gy=aa.create,Hx=ei.create,Fx=Qo.create,Kx=oa.create,Wx=ca.create,zx=Fi.create,Gx=Gn.create,Jx=Fr.create,Yx=ec.create,Xx=cr.create,Qx=Je.create,e_=Je.strictCreate,t_=ua.create,r_=ru.create,n_=la.create,i_=Or.create,s_=da.create,a_=tc.create,o_=ti.create,c_=Ti.create,u_=fa.create,l_=ha.create,d_=_n.create,f_=pa.create,h_=Ki.create,Ch=fr.create,p_=_r.create,m_=wn.create,y_=fr.createWithPreprocess,g_=Ya.create,v_=()=>my().optional(),b_=()=>yy().optional(),x_=()=>gy().optional(),__={string:r=>ir.create({...r,coerce:!0}),number:r=>bn.create({...r,coerce:!0}),boolean:r=>aa.create({...r,coerce:!0}),bigint:r=>xn.create({...r,coerce:!0}),date:r=>ei.create({...r,coerce:!0})},w_=ge;var d=Object.freeze({__proto__:null,defaultErrorMap:Hi,setErrorMap:wx,getErrorMap:Go,makeIssue:Jo,EMPTY_PATH:kx,addIssueToContext:F,ParseStatus:gt,INVALID:ge,DIRTY:Yo,OK:wt,isAborted:jl,isDirty:Tl,isValid:ia,isAsync:sa,get util(){return Pe},get objectUtil(){return Cl},ZodParsedType:G,getParsedType:an,ZodType:Ee,datetimeRegex:fy,ZodString:ir,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:ei,ZodSymbol:Qo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fi,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:ec,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:ru,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:tc,ZodSet:ti,ZodFunction:Ti,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ki,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:rc,BRAND:Mx,ZodBranded:uf,ZodPipeline:Ya,ZodReadonly:ga,custom:py,Schema:Ee,ZodSchema:Ee,late:Ux,get ZodFirstPartyTypeKind(){return fe},coerce:__,any:zx,array:Xx,bigint:qx,boolean:gy,date:Hx,discriminatedUnion:r_,effect:Ch,enum:d_,function:c_,instanceof:Vx,intersection:n_,lazy:u_,literal:l_,map:a_,nan:Lx,nativeEnum:f_,never:Jx,null:Wx,nullable:m_,number:yy,object:Qx,oboolean:x_,onumber:b_,optional:p_,ostring:v_,pipeline:g_,preprocess:y_,promise:h_,record:s_,set:o_,strictObject:e_,string:my,symbol:Fx,transformer:Ch,tuple:i_,undefined:Kx,union:t_,unknown:Gx,void:Yx,NEVER:w_,ZodIssueCode:Z,quotelessJson:_x,ZodError:Dt});xx(d);const jn=d.object({start:d.number(),limit:d.number(),length:d.number()}),lf=d.object({created_at:d.string(),updated_at:d.string()}),vy=d.object({email:d.string().optional(),email_verified:d.boolean().optional(),name:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),phone_number:d.string().optional(),phone_verified:d.boolean().optional(),family_name:d.string().optional()}).catchall(d.any()),by=d.object({connection:d.string(),user_id:d.string(),provider:d.string(),isSocial:d.boolean(),access_token:d.string().optional(),access_token_secret:d.string().optional(),refresh_token:d.string().optional(),profileData:vy.optional()}),nu=d.object({email:d.string().optional(),username:d.string().optional(),given_name:d.string().optional(),family_name:d.string().optional(),nickname:d.string().optional(),name:d.string().optional(),picture:d.string().optional(),locale:d.string().optional(),linked_to:d.string().optional(),profileData:d.string().optional(),user_id:d.string().optional(),app_metadata:d.any().default({}).optional(),user_metadata:d.any().default({}).optional()}),nc=nu.extend({email_verified:d.boolean().default(!1),verify_email:d.boolean().optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string().optional(),provider:d.string().default("email"),connection:d.string().default("email")}),df=d.object({...nc.shape,...lf.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(by).optional()}),vr=df,k_=nu.extend({email:d.string(),login_count:d.number(),multifactor:d.array(d.string()).optional(),last_ip:d.string().optional(),last_login:d.string().optional(),user_id:d.string()}).catchall(d.any()),S_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let A_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=S_[t[r]&63];return e};const xy=d.object({audience:d.string().optional(),recipient:d.string().optional(),createUpnClaim:d.boolean().optional(),mapUnknownClaimsAsIs:d.boolean().optional(),passthroughClaimsWithNoMapping:d.boolean().optional(),mapIdentities:d.boolean().optional(),signatureAlgorithm:d.string().optional(),digestAlgorithm:d.string().optional(),issuer:d.string().optional(),destination:d.string().optional(),lifetimeInSeconds:d.number().optional(),signResponse:d.boolean().optional(),nameIdentifierFormat:d.string().optional(),nameIdentifierProbes:d.array(d.string()).optional(),authnContextClassRef:d.string().optional(),mappings:d.record(d.string()).optional()}),ic=d.object({id:d.string(),name:d.string(),callbacks:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:d.array(d.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:d.array(d.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:d.object({samlp:xy.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:d.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:d.string().default(()=>A_()).optional(),disable_sign_ups:d.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Mn=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),...ic.shape});var ff=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(ff||{}),hf=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(hf||{}),pf=(r=>(r.S256="S256",r.Plain="plain",r))(pf||{});const _y=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(ff).optional(),response_mode:d.nativeEnum(hf).optional(),redirect_uri:d.string().optional(),audience:d.string().optional(),state:d.string().optional(),nonce:d.string().optional(),scope:d.string().optional(),prompt:d.string().optional(),code_challenge_method:d.nativeEnum(pf).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),Bl=d.object({colors:d.object({primary:d.string(),page_background:d.object({type:d.string().optional(),start:d.string().optional(),end:d.string().optional(),angle_deg:d.number().optional()}).optional()}).optional(),logo_url:d.string().optional(),favicon_url:d.string().optional(),font:d.object({url:d.string()}).optional()}),sc=d.object({id:d.string().optional(),name:d.string(),strategy:d.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:d.object({kid:d.string().optional(),team_id:d.string().optional(),realms:d.string().optional(),client_id:d.string().optional(),client_secret:d.string().optional(),app_secret:d.string().optional(),scope:d.string().optional(),authorization_endpoint:d.string().default("").optional(),token_endpoint:d.string().default("").optional(),userinfo_endpoint:d.string().default("").optional(),jwks_uri:d.string().default("").optional(),discovery_url:d.string().default("").optional(),issuer:d.string().default("").optional()}).default({}).optional(),enabled_clients:d.array(d.string()).default([]).optional(),response_type:d.custom().optional(),response_mode:d.custom().optional()}),Un=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(sc.shape),ac=d.object({name:d.string(),audience:d.string(),sender_email:d.string().email(),sender_name:d.string(),support_url:d.string().url().optional(),logo:d.string().url().optional(),primary_color:d.string().optional(),secondary_color:d.string().optional(),language:d.string().optional()}),Ni=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...ac.shape}),O_=d.object({logoUrl:d.string(),loginBackgroundImage:d.string().nullish(),style:d.object({primaryColor:d.string(),buttonTextColor:d.string(),primaryHoverColor:d.string()}),supportEmail:d.string().nullable(),supportUrl:d.string().nullable(),name:d.string(),showGreyishBackground:d.boolean().optional(),termsAndConditionsUrl:d.string().nullable(),companyName:d.string().optional(),checkoutHideSocial:d.boolean().optional(),siteUrl:d.string().nullable(),manageSubscriptionsUrl:d.string().optional()}),E_=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.union([d.literal("mailgun"),d.literal("mailchannels")]).optional()});d.object({...Mn.shape,domains:d.array(E_),tenant:Ni,connections:d.array(Un)});const wy=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ky=d.object({code_id:d.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:d.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:d.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:wy,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()}),I_=d.object({...ky.shape,created_at:d.string()}),Sy=d.object({domain:d.string(),dkim_private_key:d.string().optional(),dkim_public_key:d.string().optional(),email_api_key:d.string().optional(),email_service:d.enum(["mailgun","mailchannels"])}),C_=lf.extend({...Sy.shape,id:d.string()}),oc=d.object({trigger_id:d.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:d.boolean().default(!1),url:d.string(),hook_id:d.string().optional(),synchronous:d.boolean().default(!1),priority:d.number().optional()}),Ei=oc.extend({...lf.shape,hook_id:d.string()}),mf=d.object({alg:d.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:d.string(),kid:d.string(),kty:d.enum(["RSA","EC","oct"]),n:d.string(),x5t:d.string().optional(),x5c:d.array(d.string()).optional(),use:d.enum(["sig","enc"]).optional()}),Ay=d.object({keys:d.array(mf)}),Rl=d.object({issuer:d.string(),authorization_endpoint:d.string(),token_endpoint:d.string(),device_authorization_endpoint:d.string(),userinfo_endpoint:d.string(),mfa_challenge_endpoint:d.string(),jwks_uri:d.string(),registration_endpoint:d.string(),revocation_endpoint:d.string(),scopes_supported:d.array(d.string()),response_types_supported:d.array(d.string()),code_challenge_methods_supported:d.array(d.string()),response_modes_supported:d.array(d.string()),subject_types_supported:d.array(d.string()),id_token_signing_alg_values_supported:d.array(d.string()),token_endpoint_auth_methods_supported:d.array(d.string()),claims_supported:d.array(d.string()),request_uri_parameter_supported:d.boolean(),request_parameter_supported:d.boolean(),token_endpoint_auth_signing_alg_values_supported:d.array(d.string())}),Oy=d.object({auth0Client:d.string().optional(),authParams:_y,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional(),useragent:d.string().optional()}).openapi({description:"This represents a login sesion"}),j_=d.object({...Oy.shape,login_id:d.string().openapi({description:"This is is used as the state in the universal login"}),created_at:d.string(),updated_at:d.string()});var iu=(r=>(r.FAILED_SILENT_AUTH="fsa",r.FAILED_SIGNUP="fs",r.FAILED_LOGIN="f",r.FAILED_LOGIN_INCORRECT_PASSWORD="fp",r.FAILED_CHANGE_PASSWORD="fcp",r.FAILED_BY_CONNECTOR="fc",r.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",r.FAILED_HOOK="fh",r.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",r.SUCCESS_API_OPERATION="sapi",r.SUCCESS_CHANGE_PASSWORD="scp",r.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",r.SUCCESS_CHANGE_USERNAME="scu",r.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",r.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",r.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",r.SUCCESS_LOGIN="s",r.SUCCESS_LOGOUT="slo",r.SUCCESS_SIGNUP="ss",r.SUCCESS_SILENT_AUTH="ssa",r.SUCCESS_VERIFICATION_EMAIL="sv",r.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",r.CODE_LINK_SENT="cls",r))(iu||{});const T_=d.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),Ey=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),cc=d.object({type:T_,date:d.string(),description:d.string().optional(),log_id:d.string().optional(),_id:d.string().optional(),ip:d.string(),user_agent:d.string(),details:d.any().optional(),isMobile:d.boolean(),user_id:d.string().optional(),user_name:d.string().optional(),connection:d.string().optional(),connection_id:d.string().optional(),client_id:d.string().optional(),client_name:d.string().optional(),audience:d.string().optional(),scope:d.array(d.string()).optional(),strategy:d.string().optional(),strategy_type:d.string().optional(),hostname:d.string().optional(),auth0_client:Ey.optional()}),Iy=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")}),N_=d.object({...Iy.shape,created_at:d.string(),updated_at:d.string()}),Cy=d.object({session_id:d.string(),client_id:d.string(),expires_at:d.string(),used_at:d.string(),deleted_at:d.string().optional(),user_id:d.string()}),yf=d.object({created_at:d.string(),...Cy.shape}),Pl=d.object({kid:d.string().openapi({description:"The key id of the signing key"}),cert:d.string().openapi({description:"The public certificate of the signing key"}),fingerprint:d.string().openapi({description:"The cert fingerprint"}),thumbprint:d.string().openapi({description:"The cert thumbprint"}),pkcs7:d.string().optional().openapi({description:"The private key in pkcs7 format"}),current:d.boolean().optional().openapi({description:"True if the key is the current key"}),next:d.boolean().optional().openapi({description:"True if the key is the next key"}),previous:d.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:d.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:d.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:d.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:d.string().optional().openapi({description:"The date and time when the key was revoked"})});var uc=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(uc||{});d.object({access_token:d.string(),id_token:d.string().optional(),scope:d.string().optional(),state:d.string().optional(),refresh_token:d.string().optional(),token_type:d.string(),expires_in:d.number()});d.object({code:d.string(),state:d.string().optional()});const jy=d.object({button_border_radius:d.number(),button_border_weight:d.number(),buttons_style:d.enum(["pill"]),input_border_radius:d.number(),input_border_weight:d.number(),inputs_style:d.enum(["pill"]),show_widget_shadow:d.boolean(),widget_border_weight:d.number(),widget_corner_radius:d.number()}),Ty=d.object({base_focus_color:d.string(),base_hover_color:d.string(),body_text:d.string(),captcha_widget_theme:d.enum(["auto"]),error:d.string(),header:d.string(),icons:d.string(),input_background:d.string(),input_border:d.string(),input_filled_text:d.string(),input_labels_placeholders:d.string(),links_focused_components:d.string(),primary_button:d.string(),primary_button_label:d.string(),secondary_button_border:d.string(),secondary_button_label:d.string(),success:d.string(),widget_background:d.string(),widget_border:d.string()}),Dn=d.object({bold:d.boolean(),size:d.number()}),Ny=d.object({body_text:Dn,buttons_text:Dn,font_url:d.string(),input_labels:Dn,links:Dn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Dn,title:Dn}),By=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Ry=d.object({header_text_alignment:d.enum(["center"]),logo_height:d.number(),logo_position:d.enum(["center"]),logo_url:d.string(),social_buttons_layout:d.enum(["bottom"])}),Py=d.object({borders:jy,colors:Ty,displayName:d.string(),fonts:Ny,page_background:By,widget:Ry}),B_=Py.extend({themeId:d.string()}),jo=d.object({universal_login_experience:d.enum(["new","classic"]).default("new"),identifier_first:d.boolean().default(!0),password_first:d.boolean().default(!1),webauthn_platform_first_factor:d.boolean()}),To=d.object({name:d.string(),enabled:d.boolean().optional().default(!0),default_from_address:d.string().optional(),credentials:d.union([d.object({accessKeyId:d.string(),secretAccessKey:d.string(),region:d.string()}),d.object({smtp_host:d.array(d.string()),smtp_port:d.number(),smtp_user:d.string(),smtp_pass:d.string()}),d.object({api_key:d.string(),domain:d.string().optional()}),d.object({connectionString:d.string()}),d.object({tenantId:d.string(),clientId:d.string(),clientSecret:d.string()})]),settings:d.object({}).optional()});function R_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}const P_=new dt().openapi(ve({tags:["branding"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Bl}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.branding.get(e);return t?r.json(t):r.json({})}).openapi(ve({tags:["branding"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(Bl.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});var lc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function D_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}function Z_(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var $y={exports:{}};const M_={},U_=Object.freeze(Object.defineProperty({__proto__:null,default:M_},Symbol.toStringTag,{value:"Module"})),V_=D_(U_);(function(r){/**
2
2
  * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
3
3
  * Released under the Apache License, Version 2.0
4
4
  * see: https://github.com/dcodeIO/bcrypt.js for details
5
- */(function(e,t){typeof LN=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(Lm,function(){var e={},t=null;function n(C){if(r&&r.exports)try{return FN.randomBytes(C)}catch{}try{var j;return(self.crypto||self.msCrypto).getRandomValues(j=new Uint32Array(C)),Array.prototype.slice.call(j)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t(C)}var s=!1;try{n(1),s=!0}catch{}t=null,e.setRandomFallback=function(C){t=C},e.genSaltSync=function(C,j){if(C=C||g,typeof C!="number")throw Error("Illegal arguments: "+typeof C+", "+typeof j);C<4?C=4:C>31&&(C=31);var k=[];return k.push("$2a$"),C<10&&k.push("0"),k.push(C.toString()),k.push("$"),k.push(h(n(d),d)),k.join("")},e.genSalt=function(C,j,k){if(typeof j=="function"&&(k=j,j=void 0),typeof C=="function"&&(k=C,C=void 0),typeof C>"u")C=g;else if(typeof C!="number")throw Error("illegal arguments: "+typeof C);function b(v){a(function(){try{v(null,e.genSaltSync(C))}catch(E){v(E)}})}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(v,E){b(function(M,ue){if(M){E(M);return}v(ue)})})},e.hashSync=function(C,j){if(typeof j>"u"&&(j=g),typeof j=="number"&&(j=e.genSaltSync(j)),typeof C!="string"||typeof j!="string")throw Error("Illegal arguments: "+typeof C+", "+typeof j);return Jt(C,j)},e.hash=function(C,j,k,b){function v(E){typeof C=="string"&&typeof j=="number"?e.genSalt(j,function(M,ue){Jt(C,ue,E,b)}):typeof C=="string"&&typeof j=="string"?Jt(C,j,E,b):a(E.bind(this,Error("Illegal arguments: "+typeof C+", "+typeof j)))}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);v(k)}else return new Promise(function(E,M){v(function(ue,W){if(ue){M(ue);return}E(W)})})};function i(C,j){for(var k=0,b=0,v=0,E=C.length;v<E;++v)C.charCodeAt(v)===j.charCodeAt(v)?++k:++b;return k<0?!1:b===0}e.compareSync=function(C,j){if(typeof C!="string"||typeof j!="string")throw Error("Illegal arguments: "+typeof C+", "+typeof j);return j.length!==60?!1:i(e.hashSync(C,j.substr(0,j.length-31)),j)},e.compare=function(C,j,k,b){function v(E){if(typeof C!="string"||typeof j!="string"){a(E.bind(this,Error("Illegal arguments: "+typeof C+", "+typeof j)));return}if(j.length!==60){a(E.bind(this,null,!1));return}e.hash(C,j.substr(0,29),function(M,ue){M?E(M):E(null,i(ue,j))},b)}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);v(k)}else return new Promise(function(E,M){v(function(ue,W){if(ue){M(ue);return}E(W)})})},e.getRounds=function(C){if(typeof C!="string")throw Error("Illegal arguments: "+typeof C);return parseInt(C.split("$")[2],10)},e.getSalt=function(C){if(typeof C!="string")throw Error("Illegal arguments: "+typeof C);if(C.length!==60)throw Error("Illegal hash length: "+C.length+" != 60");return C.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function o(C){var j=[],k=0;return B.encodeUTF16toUTF8(function(){return k>=C.length?null:C.charCodeAt(k++)},function(b){j.push(b)}),j}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],l=String.fromCharCode;function h(C,j){var k=0,b=[],v,E;if(j<=0||j>C.length)throw Error("Illegal len: "+j);for(;k<j;){if(v=C[k++]&255,b.push(c[v>>2&63]),v=(v&3)<<4,k>=j){b.push(c[v&63]);break}if(E=C[k++]&255,v|=E>>4&15,b.push(c[v&63]),v=(E&15)<<2,k>=j){b.push(c[v&63]);break}E=C[k++]&255,v|=E>>6&3,b.push(c[v&63]),b.push(c[E&63])}return b.join("")}function R(C,j){var k=0,b=C.length,v=0,E=[],M,ue,W,pe,Ze,H;if(j<=0)throw Error("Illegal len: "+j);for(;k<b-1&&v<j&&(H=C.charCodeAt(k++),M=H<u.length?u[H]:-1,H=C.charCodeAt(k++),ue=H<u.length?u[H]:-1,!(M==-1||ue==-1||(Ze=M<<2>>>0,Ze|=(ue&48)>>4,E.push(l(Ze)),++v>=j||k>=b)||(H=C.charCodeAt(k++),W=H<u.length?u[H]:-1,W==-1)||(Ze=(ue&15)<<4>>>0,Ze|=(W&60)>>2,E.push(l(Ze)),++v>=j||k>=b)));)H=C.charCodeAt(k++),pe=H<u.length?u[H]:-1,Ze=(W&3)<<6>>>0,Ze|=pe,E.push(l(Ze)),++v;var Bt=[];for(k=0;k<v;k++)Bt.push(E[k].charCodeAt(0));return Bt}var B=function(){var C={};return C.MAX_CODEPOINT=1114111,C.encodeUTF8=function(j,k){var b=null;for(typeof j=="number"&&(b=j,j=function(){return null});b!==null||(b=j())!==null;)b<128?k(b&127):b<2048?(k(b>>6&31|192),k(b&63|128)):b<65536?(k(b>>12&15|224),k(b>>6&63|128),k(b&63|128)):(k(b>>18&7|240),k(b>>12&63|128),k(b>>6&63|128),k(b&63|128)),b=null},C.decodeUTF8=function(j,k){for(var b,v,E,M,ue=function(W){W=W.slice(0,W.indexOf(null));var pe=Error(W.toString());throw pe.name="TruncatedError",pe.bytes=W,pe};(b=j())!==null;)if(!(b&128))k(b);else if((b&224)===192)(v=j())===null&&ue([b,v]),k((b&31)<<6|v&63);else if((b&240)===224)((v=j())===null||(E=j())===null)&&ue([b,v,E]),k((b&15)<<12|(v&63)<<6|E&63);else if((b&248)===240)((v=j())===null||(E=j())===null||(M=j())===null)&&ue([b,v,E,M]),k((b&7)<<18|(v&63)<<12|(E&63)<<6|M&63);else throw RangeError("Illegal starting byte: "+b)},C.UTF16toUTF8=function(j,k){for(var b,v=null;(b=v!==null?v:j())!==null;){if(b>=55296&&b<=57343&&(v=j())!==null&&v>=56320&&v<=57343){k((b-55296)*1024+v-56320+65536),v=null;continue}k(b)}v!==null&&k(v)},C.UTF8toUTF16=function(j,k){var b=null;for(typeof j=="number"&&(b=j,j=function(){return null});b!==null||(b=j())!==null;)b<=65535?k(b):(b-=65536,k((b>>10)+55296),k(b%1024+56320)),b=null},C.encodeUTF16toUTF8=function(j,k){C.UTF16toUTF8(j,function(b){C.encodeUTF8(b,k)})},C.decodeUTF8toUTF16=function(j,k){C.decodeUTF8(j,function(b){C.UTF8toUTF16(b,k)})},C.calculateCodePoint=function(j){return j<128?1:j<2048?2:j<65536?3:4},C.calculateUTF8=function(j){for(var k,b=0;(k=j())!==null;)b+=C.calculateCodePoint(k);return b},C.calculateUTF16asUTF8=function(j){var k=0,b=0;return C.UTF16toUTF8(j,function(v){++k,b+=C.calculateCodePoint(v)}),[k,b]},C}();Date.now=Date.now||function(){return+new Date};var d=16,g=10,A=16,O=100,$=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],P=[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],ae=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Re(C,j,k,b){var v,E=C[j],M=C[j+1];return E^=k[0],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[1],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[2],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[3],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[4],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[5],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[6],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[7],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[8],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[9],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[10],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[11],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[12],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[13],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[14],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[15],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[16],C[j]=M^k[A+1],C[j+1]=E,C}function He(C,j){for(var k=0,b=0;k<4;++k)b=b<<8|C[j]&255,j=(j+1)%C.length;return{key:b,offp:j}}function Te(C,j,k){for(var b=0,v=[0,0],E=j.length,M=k.length,ue,W=0;W<E;W++)ue=He(C,b),b=ue.offp,j[W]=j[W]^ue.key;for(W=0;W<E;W+=2)v=Re(v,0,j,k),j[W]=v[0],j[W+1]=v[1];for(W=0;W<M;W+=2)v=Re(v,0,j,k),k[W]=v[0],k[W+1]=v[1]}function Nt(C,j,k,b){for(var v=0,E=[0,0],M=k.length,ue=b.length,W,pe=0;pe<M;pe++)W=He(j,v),v=W.offp,k[pe]=k[pe]^W.key;for(v=0,pe=0;pe<M;pe+=2)W=He(C,v),v=W.offp,E[0]^=W.key,W=He(C,v),v=W.offp,E[1]^=W.key,E=Re(E,0,k,b),k[pe]=E[0],k[pe+1]=E[1];for(pe=0;pe<ue;pe+=2)W=He(C,v),v=W.offp,E[0]^=W.key,W=He(C,v),v=W.offp,E[1]^=W.key,E=Re(E,0,k,b),b[pe]=E[0],b[pe+1]=E[1]}function Gt(C,j,k,b,v){var E=ae.slice(),M=E.length,ue;if(k<4||k>31)if(ue=Error("Illegal number of rounds (4-31): "+k),b){a(b.bind(this,ue));return}else throw ue;if(j.length!==d)if(ue=Error("Illegal salt length: "+j.length+" != "+d),b){a(b.bind(this,ue));return}else throw ue;k=1<<k>>>0;var W,pe,Ze=0,H;Int32Array?(W=new Int32Array($),pe=new Int32Array(P)):(W=$.slice(),pe=P.slice()),Nt(j,C,W,pe);function Bt(){if(v&&v(Ze/k),Ze<k)for(var Ke=Date.now();Ze<k&&(Ze=Ze+1,Te(C,W,pe),Te(j,W,pe),!(Date.now()-Ke>O)););else{for(Ze=0;Ze<64;Ze++)for(H=0;H<M>>1;H++)Re(E,H<<1,W,pe);var _t=[];for(Ze=0;Ze<M;Ze++)_t.push((E[Ze]>>24&255)>>>0),_t.push((E[Ze]>>16&255)>>>0),_t.push((E[Ze]>>8&255)>>>0),_t.push((E[Ze]&255)>>>0);if(b){b(null,_t);return}else return _t}b&&a(Bt)}if(typeof b<"u")Bt();else for(var $r;;)if(typeof($r=Bt())<"u")return $r||[]}function Jt(C,j,k,b){var v;if(typeof C!="string"||typeof j!="string")if(v=Error("Invalid string / salt: Not a string"),k){a(k.bind(this,v));return}else throw v;var E,M;if(j.charAt(0)!=="$"||j.charAt(1)!=="2")if(v=Error("Invalid salt version: "+j.substring(0,2)),k){a(k.bind(this,v));return}else throw v;if(j.charAt(2)==="$")E="\0",M=3;else{if(E=j.charAt(2),E!=="a"&&E!=="b"&&E!=="y"||j.charAt(3)!=="$")if(v=Error("Invalid salt revision: "+j.substring(2,4)),k){a(k.bind(this,v));return}else throw v;M=4}if(j.charAt(M+2)>"$")if(v=Error("Missing salt rounds"),k){a(k.bind(this,v));return}else throw v;var ue=parseInt(j.substring(M,M+1),10)*10,W=parseInt(j.substring(M+1,M+2),10),pe=ue+W,Ze=j.substring(M+3,M+25);C+=E>="a"?"\0":"";var H=o(C),Bt=R(Ze,d);function $r(Ke){var _t=[];return _t.push("$2"),E>="a"&&_t.push(E),_t.push("$"),pe<10&&_t.push("0"),_t.push(pe.toString()),_t.push("$"),_t.push(h(Bt,Bt.length)),_t.push(h(Ke,ae.length*4-1)),_t.join("")}if(typeof k>"u")return $r(Gt(H,Bt,pe));Gt(H,Bt,pe,function(Ke,_t){Ke?k(Ke,null):k(null,$r(_t))},b)}return e.encodeBase64=h,e.decodeBase64=R,e})})(Kj);var KN=Kj.exports;const zN=UN(KN),WN="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let GN=r=>crypto.getRandomValues(new Uint8Array(r)),JN=(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}}},YN=(r,e=21)=>JN(r,e,GN),qm=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=WN[t[r]&63];return e};const XN=24;function QN(){return YN("0123456789abcdef",XN)()}function S2(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}async function zj(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function e9({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}const qo=T.object({page:T.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:T.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:T.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:T.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:T.string().optional().openapi({description:"A lucene query string used to filter the results"})});function il(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}function Wj(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}var t9={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},r9=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[s,i]of Object.entries(t9))if(n9(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"},n9=r=>navigator.userAgent.startsWith(r);function s9(r,e){r9()==="workerd"&&r.executionCtx.waitUntil(e)}const A2=Ja.extend({users:T.array(Ps)}),i9=Ja.extend({sessions:T.array(xx)}),a9=new Sr().openapi(ct({tags:["users"],method:"get",path:"/",request:{query:qo,headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:T.union([T.array(Ps),A2])}},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 l=i.split("=")[1],R=(await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,q:`email:${l}`})).users.filter(g=>g.linked_to),[B]=R;if(!B)return r.json([]);const d=await r.env.data.users.get(a,B.linked_to);if(!d)throw new nt(500,{message:"Primary account not found"});return r.json([Ps.parse(d)])}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:il(s),q:o.join(" ")}),u=c.users.filter(l=>!l.linked_to);return n?r.json(A2.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(T.array(Ps).parse(u))}).openapi(ct({tags:["users"],method:"get",path:"/{user_id}",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({user_id:T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ps}},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 nt(404);if(n.linked_to)throw new nt(404,{message:"User is linked to another user"});return r.json(n)}).openapi(ct({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({user_id:T.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 nt(404);return r.text("OK")}).openapi(ct({tags:["users"],method:"post",path:"/",request:{headers:T.object({"tenant-id":T.string()}),body:{content:{"application/json":{schema:T.object({...Pm.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ps}},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 nt(400,{message:"Email is required"});const s=n.toLowerCase(),i=`${t.provider}|${t.user_id||QN()}`;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=Wj(r,{type:zg.SUCCESS_API_OPERATION,description:"User created"});s9(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:S2(a.user_id),isSocial:a.is_social}]};return r.json(Ps.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new nt(409,{message:"User already exists"}):a}}).openapi(ct({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:T.object({"tenant-id":T.string()}),body:{content:{"application/json":{schema:T.object({...Pm.shape,verify_email:T.boolean(),password:T.string()}).partial()}}},params:T.object({user_id:T.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 nt(404);if(a.email&&a.email!==o.email){const l=await zj(r.env.data.users,e,a.email);if(l.length&&l.some(h=>h.user_id!==n))throw new nt(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new nt(404,{message:"User is linked to another user"});if(await r.env.data.users.update(e,n,a),i){const l=(u=o.identities)==null?void 0:u.find(h=>h.connection==="Username-Password-Authentication");if(!l)throw new nt(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${l.provider}|${l.user_id}`,password:zN.hashSync(i,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new nt(500);return r.json(c)}).openapi(ct({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:T.object({"tenant-id":T.string()}),body:{content:{"application/json":{schema:T.union([T.object({link_with:T.string()}),T.object({user_id:T.string(),provider:T.string(),connection:T.string().optional()})])}}},params:T.object({user_id:T.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:T.array(T.object({connection:T.string(),provider:T.string(),user_id:T.string(),isSocial:T.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 nt(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:S2(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(ct({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({user_id:T.string(),provider:T.string(),linked_user_id:T.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:T.array(Ps)}},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 nt(404);return r.json([Ps.parse(i)])}).openapi(ct({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:qo,headers:T.object({"tenant-id":T.string()}),params:T.object({user_id:T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:T.union([T.array(xx),i9])}},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)});/*! *****************************************************************************
5
+ */(function(e,t){typeof Z_=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(lc,function(){var e={},t=null;function n(I){if(r&&r.exports)try{return V_.randomBytes(I)}catch{}try{var E;return(self.crypto||self.msCrypto).getRandomValues(E=new Uint32Array(I)),Array.prototype.slice.call(E)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t(I)}var i=!1;try{n(1),i=!0}catch{}t=null,e.setRandomFallback=function(I){t=I},e.genSaltSync=function(I,E){if(I=I||g,typeof I!="number")throw Error("Illegal arguments: "+typeof I+", "+typeof E);I<4?I=4:I>31&&(I=31);var k=[];return k.push("$2a$"),I<10&&k.push("0"),k.push(I.toString()),k.push("$"),k.push(m(n(p),p)),k.join("")},e.genSalt=function(I,E,k){if(typeof E=="function"&&(k=E,E=void 0),typeof I=="function"&&(k=I,I=void 0),typeof I>"u")I=g;else if(typeof I!="number")throw Error("illegal arguments: "+typeof I);function x(b){a(function(){try{b(null,e.genSaltSync(I))}catch(j){b(j)}})}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);x(k)}else return new Promise(function(b,j){x(function(U,Ce){if(U){j(U);return}b(Ce)})})},e.hashSync=function(I,E){if(typeof E>"u"&&(E=g),typeof E=="number"&&(E=e.genSaltSync(E)),typeof I!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof I+", "+typeof E);return Rt(I,E)},e.hash=function(I,E,k,x){function b(j){typeof I=="string"&&typeof E=="number"?e.genSalt(E,function(U,Ce){Rt(I,Ce,j,x)}):typeof I=="string"&&typeof E=="string"?Rt(I,E,j,x):a(j.bind(this,Error("Illegal arguments: "+typeof I+", "+typeof E)))}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(j,U){b(function(Ce,se){if(Ce){U(Ce);return}j(se)})})};function s(I,E){for(var k=0,x=0,b=0,j=I.length;b<j;++b)I.charCodeAt(b)===E.charCodeAt(b)?++k:++x;return k<0?!1:x===0}e.compareSync=function(I,E){if(typeof I!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof I+", "+typeof E);return E.length!==60?!1:s(e.hashSync(I,E.substr(0,E.length-31)),E)},e.compare=function(I,E,k,x){function b(j){if(typeof I!="string"||typeof E!="string"){a(j.bind(this,Error("Illegal arguments: "+typeof I+", "+typeof E)));return}if(E.length!==60){a(j.bind(this,null,!1));return}e.hash(I,E.substr(0,29),function(U,Ce){U?j(U):j(null,s(Ce,E))},x)}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(j,U){b(function(Ce,se){if(Ce){U(Ce);return}j(se)})})},e.getRounds=function(I){if(typeof I!="string")throw Error("Illegal arguments: "+typeof I);return parseInt(I.split("$")[2],10)},e.getSalt=function(I){if(typeof I!="string")throw Error("Illegal arguments: "+typeof I);if(I.length!==60)throw Error("Illegal hash length: "+I.length+" != 60");return I.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function o(I){var E=[],k=0;return C.encodeUTF16toUTF8(function(){return k>=I.length?null:I.charCodeAt(k++)},function(x){E.push(x)}),E}var c="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],f=String.fromCharCode;function m(I,E){var k=0,x=[],b,j;if(E<=0||E>I.length)throw Error("Illegal len: "+E);for(;k<E;){if(b=I[k++]&255,x.push(c[b>>2&63]),b=(b&3)<<4,k>=E){x.push(c[b&63]);break}if(j=I[k++]&255,b|=j>>4&15,x.push(c[b&63]),b=(j&15)<<2,k>=E){x.push(c[b&63]);break}j=I[k++]&255,b|=j>>6&3,x.push(c[b&63]),x.push(c[j&63])}return x.join("")}function B(I,E){var k=0,x=I.length,b=0,j=[],U,Ce,se,Ne,Ue,Q;if(E<=0)throw Error("Illegal len: "+E);for(;k<x-1&&b<E&&(Q=I.charCodeAt(k++),U=Q<u.length?u[Q]:-1,Q=I.charCodeAt(k++),Ce=Q<u.length?u[Q]:-1,!(U==-1||Ce==-1||(Ue=U<<2>>>0,Ue|=(Ce&48)>>4,j.push(f(Ue)),++b>=E||k>=x)||(Q=I.charCodeAt(k++),se=Q<u.length?u[Q]:-1,se==-1)||(Ue=(Ce&15)<<4>>>0,Ue|=(se&60)>>2,j.push(f(Ue)),++b>=E||k>=x)));)Q=I.charCodeAt(k++),Ne=Q<u.length?u[Q]:-1,Ue=(se&3)<<6>>>0,Ue|=Ne,j.push(f(Ue)),++b;var ot=[];for(k=0;k<b;k++)ot.push(j[k].charCodeAt(0));return ot}var C=function(){var I={};return I.MAX_CODEPOINT=1114111,I.encodeUTF8=function(E,k){var x=null;for(typeof E=="number"&&(x=E,E=function(){return null});x!==null||(x=E())!==null;)x<128?k(x&127):x<2048?(k(x>>6&31|192),k(x&63|128)):x<65536?(k(x>>12&15|224),k(x>>6&63|128),k(x&63|128)):(k(x>>18&7|240),k(x>>12&63|128),k(x>>6&63|128),k(x&63|128)),x=null},I.decodeUTF8=function(E,k){for(var x,b,j,U,Ce=function(se){se=se.slice(0,se.indexOf(null));var Ne=Error(se.toString());throw Ne.name="TruncatedError",Ne.bytes=se,Ne};(x=E())!==null;)if(!(x&128))k(x);else if((x&224)===192)(b=E())===null&&Ce([x,b]),k((x&31)<<6|b&63);else if((x&240)===224)((b=E())===null||(j=E())===null)&&Ce([x,b,j]),k((x&15)<<12|(b&63)<<6|j&63);else if((x&248)===240)((b=E())===null||(j=E())===null||(U=E())===null)&&Ce([x,b,j,U]),k((x&7)<<18|(b&63)<<12|(j&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+x)},I.UTF16toUTF8=function(E,k){for(var x,b=null;(x=b!==null?b:E())!==null;){if(x>=55296&&x<=57343&&(b=E())!==null&&b>=56320&&b<=57343){k((x-55296)*1024+b-56320+65536),b=null;continue}k(x)}b!==null&&k(b)},I.UTF8toUTF16=function(E,k){var x=null;for(typeof E=="number"&&(x=E,E=function(){return null});x!==null||(x=E())!==null;)x<=65535?k(x):(x-=65536,k((x>>10)+55296),k(x%1024+56320)),x=null},I.encodeUTF16toUTF8=function(E,k){I.UTF16toUTF8(E,function(x){I.encodeUTF8(x,k)})},I.decodeUTF8toUTF16=function(E,k){I.decodeUTF8(E,function(x){I.UTF8toUTF16(x,k)})},I.calculateCodePoint=function(E){return E<128?1:E<2048?2:E<65536?3:4},I.calculateUTF8=function(E){for(var k,x=0;(k=E())!==null;)x+=I.calculateCodePoint(k);return x},I.calculateUTF16asUTF8=function(E){var k=0,x=0;return I.UTF16toUTF8(E,function(b){++k,x+=I.calculateCodePoint(b)}),[k,x]},I}();Date.now=Date.now||function(){return+new Date};var p=16,g=10,A=16,O=100,P=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],N=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],xe=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Le(I,E,k,x){var b,j=I[E],U=I[E+1];return j^=k[0],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[1],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[2],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[3],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[4],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[5],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[6],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[7],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[8],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[9],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[10],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[11],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[12],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[13],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[14],b=x[j>>>24],b+=x[256|j>>16&255],b^=x[512|j>>8&255],b+=x[768|j&255],U^=b^k[15],b=x[U>>>24],b+=x[256|U>>16&255],b^=x[512|U>>8&255],b+=x[768|U&255],j^=b^k[16],I[E]=U^k[A+1],I[E+1]=j,I}function qe(I,E){for(var k=0,x=0;k<4;++k)x=x<<8|I[E]&255,E=(E+1)%I.length;return{key:x,offp:E}}function Ze(I,E,k){for(var x=0,b=[0,0],j=E.length,U=k.length,Ce,se=0;se<j;se++)Ce=qe(I,x),x=Ce.offp,E[se]=E[se]^Ce.key;for(se=0;se<j;se+=2)b=Le(b,0,E,k),E[se]=b[0],E[se+1]=b[1];for(se=0;se<U;se+=2)b=Le(b,0,E,k),k[se]=b[0],k[se+1]=b[1]}function tt(I,E,k,x){for(var b=0,j=[0,0],U=k.length,Ce=x.length,se,Ne=0;Ne<U;Ne++)se=qe(E,b),b=se.offp,k[Ne]=k[Ne]^se.key;for(b=0,Ne=0;Ne<U;Ne+=2)se=qe(I,b),b=se.offp,j[0]^=se.key,se=qe(I,b),b=se.offp,j[1]^=se.key,j=Le(j,0,k,x),k[Ne]=j[0],k[Ne+1]=j[1];for(Ne=0;Ne<Ce;Ne+=2)se=qe(I,b),b=se.offp,j[0]^=se.key,se=qe(I,b),b=se.offp,j[1]^=se.key,j=Le(j,0,k,x),x[Ne]=j[0],x[Ne+1]=j[1]}function mt(I,E,k,x,b){var j=xe.slice(),U=j.length,Ce;if(k<4||k>31)if(Ce=Error("Illegal number of rounds (4-31): "+k),x){a(x.bind(this,Ce));return}else throw Ce;if(E.length!==p)if(Ce=Error("Illegal salt length: "+E.length+" != "+p),x){a(x.bind(this,Ce));return}else throw Ce;k=1<<k>>>0;var se,Ne,Ue=0,Q;Int32Array?(se=new Int32Array(P),Ne=new Int32Array(N)):(se=P.slice(),Ne=N.slice()),tt(E,I,se,Ne);function ot(){if(b&&b(Ue/k),Ue<k)for(var He=Date.now();Ue<k&&(Ue=Ue+1,Ze(I,se,Ne),Ze(E,se,Ne),!(Date.now()-He>O)););else{for(Ue=0;Ue<64;Ue++)for(Q=0;Q<U>>1;Q++)Le(j,Q<<1,se,Ne);var rt=[];for(Ue=0;Ue<U;Ue++)rt.push((j[Ue]>>24&255)>>>0),rt.push((j[Ue]>>16&255)>>>0),rt.push((j[Ue]>>8&255)>>>0),rt.push((j[Ue]&255)>>>0);if(x){x(null,rt);return}else return rt}x&&a(ot)}if(typeof x<"u")ot();else for(var Rn;;)if(typeof(Rn=ot())<"u")return Rn||[]}function Rt(I,E,k,x){var b;if(typeof I!="string"||typeof E!="string")if(b=Error("Invalid string / salt: Not a string"),k){a(k.bind(this,b));return}else throw b;var j,U;if(E.charAt(0)!=="$"||E.charAt(1)!=="2")if(b=Error("Invalid salt version: "+E.substring(0,2)),k){a(k.bind(this,b));return}else throw b;if(E.charAt(2)==="$")j="\0",U=3;else{if(j=E.charAt(2),j!=="a"&&j!=="b"&&j!=="y"||E.charAt(3)!=="$")if(b=Error("Invalid salt revision: "+E.substring(2,4)),k){a(k.bind(this,b));return}else throw b;U=4}if(E.charAt(U+2)>"$")if(b=Error("Missing salt rounds"),k){a(k.bind(this,b));return}else throw b;var Ce=parseInt(E.substring(U,U+1),10)*10,se=parseInt(E.substring(U+1,U+2),10),Ne=Ce+se,Ue=E.substring(U+3,U+25);I+=j>="a"?"\0":"";var Q=o(I),ot=B(Ue,p);function Rn(He){var rt=[];return rt.push("$2"),j>="a"&&rt.push(j),rt.push("$"),Ne<10&&rt.push("0"),rt.push(Ne.toString()),rt.push("$"),rt.push(m(ot,ot.length)),rt.push(m(He,xe.length*4-1)),rt.join("")}if(typeof k>"u")return Rn(mt(Q,ot,Ne));mt(Q,ot,Ne,function(He,rt){He?k(He,null):k(null,Rn(rt))},x)}return e.encodeBase64=m,e.decodeBase64=B,e})})($y);var L_=$y.exports;const q_=$_(L_),H_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let F_=r=>crypto.getRandomValues(new Uint8Array(r)),K_=(r,e,t)=>{let n=(2<<Math.log2(r.length-1))-1,i=-~(1.6*n*e/r.length);return(s=e)=>{let a="";for(;;){let o=t(i),c=i;for(;c--;)if(a+=r[o[c]&n]||"",a.length===s)return a}}},W_=(r,e=21)=>K_(r,e,F_),dc=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=H_[t[r]&63];return e};const z_=24;function G_(){return W_("0123456789abcdef",z_)()}function jh(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}async function Dy(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function J_({userAdapter:r,tenant_id:e,email:t}){var o;const{users:n}=await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),i=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(i.length===0)return;const s=i.filter(c=>!c.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const a=await r.get(e,(o=i[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}const ri=y.object({page:y.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:y.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:y.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:y.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:y.string().optional().openapi({description:"A lucene query string used to filter the results"})});function cs(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}function Zy(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}var Y_={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},X_=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(Y_))if(Q_(s))return i}return typeof(r==null?void 0:r.EdgeRuntime)=="string"?"edge-light":(r==null?void 0:r.fastly)!==void 0?"fastly":((n=(t=r==null?void 0:r.process)==null?void 0:t.release)==null?void 0:n.name)==="node"?"node":"other"},Q_=r=>navigator.userAgent.startsWith(r);function ew(r,e){X_()==="workerd"&&r.executionCtx.waitUntil(e)}const Th=jn.extend({users:y.array(vr)}),tw=jn.extend({sessions:y.array(yf)}),rw=new dt().openapi(ve({tags:["users"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(vr),Th])}},description:"List of users"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const f=s.split("=")[1],B=(await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,q:`email:${f}`})).users.filter(g=>g.linked_to),[C]=B;if(!C)return r.json([]);const p=await r.env.data.users.get(a,C.linked_to);if(!p)throw new ye(500,{message:"Primary account not found"});return r.json([vr.parse(p)])}const o=["-_exists_:linked_to"];s&&o.push(s);const c=await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,sort:cs(i),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(Th.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(y.array(vr).parse(u))}).openapi(ve({tags:["users"],method:"get",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:vr}},description:"List of users"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{"tenant-id":t}=r.req.valid("header"),n=await r.env.data.users.get(t,e);if(!n)throw new ye(404);if(n.linked_to)throw new ye(404,{message:"User is linked to another user"});return r.json(n)}).openapi(ve({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{"tenant-id":t}=r.req.valid("header");if(!await r.env.data.users.remove(t,e))throw new ye(404);return r.text("OK")}).openapi(ve({tags:["users"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object({...nc.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:vr}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");r.set("body",t);const{email:n}=t;if(!n)throw new ye(400,{message:"Email is required"});const i=n.toLowerCase(),s=`${t.provider}|${t.user_id||G_()}`;try{const a=await r.env.data.users.create(e,{email:i,user_id:s,name:t.name||i,provider:t.provider,connection:t.connection,email_verified:t.email_verified||!1,last_ip:"",login_count:0,is_social:!1,last_login:new Date().toISOString(),created_at:new Date().toISOString(),updated_at:new Date().toISOString()});r.set("user_id",a.user_id);const o=Zy(r,{type:iu.SUCCESS_API_OPERATION,description:"User created"});ew(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:jh(a.user_id),isSocial:a.is_social}]};return r.json(vr.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new ye(409,{message:"User already exists"}):a}}).openapi(ve({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object({...nc.shape,verify_email:y.boolean(),password:y.string()}).partial()}}},params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{var u;const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),{user_id:n}=r.req.valid("param"),{verify_email:i,password:s,...a}=t,o=await r.env.data.users.get(e,n);if(!o)throw new ye(404);if(a.email&&a.email!==o.email){const f=await Dy(r.env.data.users,e,a.email);if(f.length&&f.some(m=>m.user_id!==n))throw new ye(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new ye(404,{message:"User is linked to another user"});if(await r.env.data.users.update(e,n,a),s){const f=(u=o.identities)==null?void 0:u.find(m=>m.connection==="Username-Password-Authentication");if(!f)throw new ye(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${f.provider}|${f.user_id}`,password:q_.hashSync(s,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new ye(500);return r.json(c)}).openapi(ve({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.union([y.object({link_with:y.string()}),y.object({user_id:y.string(),provider:y.string(),connection:y.string().optional()})])}}},params:y.object({user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:y.array(y.object({connection:y.string(),provider:y.string(),user_id:y.string(),isSocial:y.boolean()}))}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),{user_id:n}=r.req.valid("param"),i="link_with"in t?t.link_with:t.user_id,s=await r.env.data.users.get(e,n);if(!s)throw new ye(400,{message:"Linking an inexistent identity is not allowed."});await r.env.data.users.update(e,i,{linked_to:n});const a=await r.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${n}`}),o=[s,...a.users].map(c=>({connection:c.connection,provider:c.provider,user_id:jh(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(ve({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string(),provider:y.string(),linked_user_id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:y.array(vr)}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{user_id:t,provider:n,linked_user_id:i}=r.req.valid("param");await r.env.data.users.unlink(e,t,n,i);const s=await r.env.data.users.get(e,t);if(!s)throw new ye(404);return r.json([vr.parse(s)])}).openapi(ve({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:ri,headers:y.object({"tenant-id":y.string()}),params:y.object({user_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(yf),tw])}},description:"List of sessions"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{include_totals:t}=r.req.valid("query"),{"tenant-id":n}=r.req.valid("header"),i=await r.env.data.sessions.list(n,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return t?r.json(i):r.json(i.sessions)});/*! *****************************************************************************
6
6
  Copyright (C) Microsoft. All rights reserved.
7
7
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
8
8
  this file except in compliance with the License. You may obtain a copy of the
@@ -15,7 +15,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
15
15
 
16
16
  See the Apache Version 2.0 License for specific language governing permissions
17
17
  and limitations under the License.
18
- ***************************************************************************** */var O2;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof Lm=="object"?Lm: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(l,h){Object.defineProperty(c,l,{configurable:!0,writable:!0,value:h}),u&&u(l,h)}}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,l={create:o?function(){return io(Object.create(null))}:c?function(){return io({__proto__:null})}:function(){return io({})},has:u?function(x,S){return n.call(x,S)}:function(x,S){return S in x},get:u?function(x,S){return n.call(x,S)?x[S]:void 0}:function(x,S){return x[S]}},h=Object.getPrototypeOf(Function),R=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Z0(),B=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:D0(),d=typeof WeakMap=="function"?WeakMap:M0(),g=s?Symbol.for("@reflect-metadata:registry"):void 0,A=R0(),O=P0(A);function $(x,S,I,U){if(H(I)){if(!Cl(x))throw new TypeError;if(!El(S))throw new TypeError;return j(x,S)}else{if(!Cl(x))throw new TypeError;if(!Ke(S))throw new TypeError;if(!Ke(U)&&!H(U)&&!Bt(U))throw new TypeError;return Bt(U)&&(U=void 0),I=dr(I),k(x,S,I,U)}}e("decorate",$);function P(x,S){function I(U,Y){if(!Ke(U))throw new TypeError;if(!H(Y)&&!N0(Y))throw new TypeError;ue(x,S,U,Y)}return I}e("metadata",P);function ae(x,S,I,U){if(!Ke(I))throw new TypeError;return H(U)||(U=dr(U)),ue(x,S,I,U)}e("defineMetadata",ae);function Re(x,S,I){if(!Ke(S))throw new TypeError;return H(I)||(I=dr(I)),b(x,S,I)}e("hasMetadata",Re);function He(x,S,I){if(!Ke(S))throw new TypeError;return H(I)||(I=dr(I)),v(x,S,I)}e("hasOwnMetadata",He);function Te(x,S,I){if(!Ke(S))throw new TypeError;return H(I)||(I=dr(I)),E(x,S,I)}e("getMetadata",Te);function Nt(x,S,I){if(!Ke(S))throw new TypeError;return H(I)||(I=dr(I)),M(x,S,I)}e("getOwnMetadata",Nt);function Gt(x,S){if(!Ke(x))throw new TypeError;return H(S)||(S=dr(S)),W(x,S)}e("getMetadataKeys",Gt);function Jt(x,S){if(!Ke(x))throw new TypeError;return H(S)||(S=dr(S)),pe(x,S)}e("getOwnMetadataKeys",Jt);function C(x,S,I){if(!Ke(S))throw new TypeError;if(H(I)||(I=dr(I)),!Ke(S))throw new TypeError;H(I)||(I=dr(I));var U=Gn(S,I,!1);return H(U)?!1:U.OrdinaryDeleteMetadata(x,S,I)}e("deleteMetadata",C);function j(x,S){for(var I=x.length-1;I>=0;--I){var U=x[I],Y=U(S);if(!H(Y)&&!Bt(Y)){if(!El(Y))throw new TypeError;S=Y}}return S}function k(x,S,I,U){for(var Y=x.length-1;Y>=0;--Y){var Rt=x[Y],It=Rt(S,I,U);if(!H(It)&&!Bt(It)){if(!Ke(It))throw new TypeError;U=It}}return U}function b(x,S,I){var U=v(x,S,I);if(U)return!0;var Y=so(S);return Bt(Y)?!1:b(x,Y,I)}function v(x,S,I){var U=Gn(S,I,!1);return H(U)?!1:jl(U.OrdinaryHasOwnMetadata(x,S,I))}function E(x,S,I){var U=v(x,S,I);if(U)return M(x,S,I);var Y=so(S);if(!Bt(Y))return E(x,Y,I)}function M(x,S,I){var U=Gn(S,I,!1);if(!H(U))return U.OrdinaryGetOwnMetadata(x,S,I)}function ue(x,S,I,U){var Y=Gn(I,U,!0);Y.OrdinaryDefineOwnMetadata(x,S,I,U)}function W(x,S){var I=pe(x,S),U=so(x);if(U===null)return I;var Y=W(U,S);if(Y.length<=0)return I;if(I.length<=0)return Y;for(var Rt=new B,It=[],he=0,q=I;he<q.length;he++){var F=q[he],K=Rt.has(F);K||(Rt.add(F),It.push(F))}for(var z=0,fe=Y;z<fe.length;z++){var F=fe[z],K=Rt.has(F);K||(Rt.add(F),It.push(F))}return It}function pe(x,S){var I=Gn(x,S,!1);return I?I.OrdinaryOwnMetadataKeys(x,S):[]}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 H(x){return x===void 0}function Bt(x){return x===null}function $r(x){return typeof x=="symbol"}function Ke(x){return typeof x=="object"?x!==null:typeof x=="function"}function _t(x,S){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 I="string",U=Il(x,i);if(U!==void 0){var Y=U.call(x,I);if(Ke(Y))throw new TypeError;return Y}return I0(x)}function I0(x,S){var I,U;{var Y=x.toString;if(ui(Y)){var U=Y.call(x);if(!Ke(U))return U}var I=x.valueOf;if(ui(I)){var U=I.call(x);if(!Ke(U))return U}}throw new TypeError}function jl(x){return!!x}function T0(x){return""+x}function dr(x){var S=_t(x);return $r(S)?S:T0(S)}function Cl(x){return Array.isArray?Array.isArray(x):x instanceof Object?x instanceof Array:Object.prototype.toString.call(x)==="[object Array]"}function ui(x){return typeof x=="function"}function El(x){return typeof x=="function"}function N0(x){switch(Ze(x)){case 3:return!0;case 4:return!0;default:return!1}}function no(x,S){return x===S||x!==x&&S!==S}function Il(x,S){var I=x[S];if(I!=null){if(!ui(I))throw new TypeError;return I}}function Tl(x){var S=Il(x,a);if(!ui(S))throw new TypeError;var I=S.call(x);if(!Ke(I))throw new TypeError;return I}function Nl(x){return x.value}function Bl(x){var S=x.next();return S.done?!1:S}function Rl(x){var S=x.return;S&&S.call(x)}function so(x){var S=Object.getPrototypeOf(x);if(typeof x!="function"||x===h||S!==h)return S;var I=x.prototype,U=I&&Object.getPrototypeOf(I);if(U==null||U===Object.prototype)return S;var Y=U.constructor;return typeof Y!="function"||Y===x?S:Y}function B0(){var x;!H(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(x=$0(t.Reflect));var S,I,U,Y=new d,Rt={registerProvider:It,getProvider:q,setProvider:K};return Rt;function It(z){if(!Object.isExtensible(Rt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case x===z:break;case H(S):S=z;break;case S===z:break;case H(I):I=z;break;case I===z:break;default:U===void 0&&(U=new B),U.add(z);break}}function he(z,fe){if(!H(S)){if(S.isProviderFor(z,fe))return S;if(!H(I)){if(I.isProviderFor(z,fe))return S;if(!H(U))for(var We=Tl(U);;){var pt=Bl(We);if(!pt)return;var nr=Nl(pt);if(nr.isProviderFor(z,fe))return Rl(We),nr}}}if(!H(x)&&x.isProviderFor(z,fe))return x}function q(z,fe){var We=Y.get(z),pt;return H(We)||(pt=We.get(fe)),H(pt)&&(pt=he(z,fe),H(pt)||(H(We)&&(We=new R,Y.set(z,We)),We.set(fe,pt))),pt}function F(z){if(H(z))throw new TypeError;return S===z||I===z||!H(U)&&U.has(z)}function K(z,fe,We){if(!F(We))throw new Error("Metadata provider not registered.");var pt=q(z,fe);if(pt!==We){if(!H(pt))return!1;var nr=Y.get(z);H(nr)&&(nr=new R,Y.set(z,nr)),nr.set(fe,We)}return!0}}function R0(){var x;return!H(g)&&Ke(t.Reflect)&&Object.isExtensible(t.Reflect)&&(x=t.Reflect[g]),H(x)&&(x=B0()),!H(g)&&Ke(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:x}),x}function P0(x){var S=new d,I={isProviderFor:function(F,K){var z=S.get(F);return H(z)?!1:z.has(K)},OrdinaryDefineOwnMetadata:It,OrdinaryHasOwnMetadata:Y,OrdinaryGetOwnMetadata:Rt,OrdinaryOwnMetadataKeys:he,OrdinaryDeleteMetadata:q};return A.registerProvider(I),I;function U(F,K,z){var fe=S.get(F),We=!1;if(H(fe)){if(!z)return;fe=new R,S.set(F,fe),We=!0}var pt=fe.get(K);if(H(pt)){if(!z)return;if(pt=new R,fe.set(K,pt),!x.setProvider(F,K,I))throw fe.delete(K),We&&S.delete(F),new Error("Wrong provider for target.")}return pt}function Y(F,K,z){var fe=U(K,z,!1);return H(fe)?!1:jl(fe.has(F))}function Rt(F,K,z){var fe=U(K,z,!1);if(!H(fe))return fe.get(F)}function It(F,K,z,fe){var We=U(z,fe,!0);We.set(F,K)}function he(F,K){var z=[],fe=U(F,K,!1);if(H(fe))return z;for(var We=fe.keys(),pt=Tl(We),nr=0;;){var Pl=Bl(pt);if(!Pl)return z.length=nr,z;var U0=Nl(Pl);try{z[nr]=U0}catch(V0){try{Rl(pt)}finally{throw V0}}nr++}}function q(F,K,z){var fe=U(K,z,!1);if(H(fe)||!fe.delete(F))return!1;if(fe.size===0){var We=S.get(K);H(We)||(We.delete(z),We.size===0&&S.delete(We))}return!0}}function $0(x){var S=x.defineMetadata,I=x.hasOwnMetadata,U=x.getOwnMetadata,Y=x.getOwnMetadataKeys,Rt=x.deleteMetadata,It=new d,he={isProviderFor:function(q,F){var K=It.get(q);return!H(K)&&K.has(F)?!0:Y(q,F).length?(H(K)&&(K=new B,It.set(q,K)),K.add(F),!0):!1},OrdinaryDefineOwnMetadata:S,OrdinaryHasOwnMetadata:I,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:Y,OrdinaryDeleteMetadata:Rt};return he}function Gn(x,S,I){var U=A.getProvider(x,S);if(!H(U))return U;if(I){if(A.setProvider(x,S,O))return O;throw new Error("Illegal state.")}}function Z0(){var x={},S=[],I=function(){function he(q,F,K){this._index=0,this._keys=q,this._values=F,this._selector=K}return he.prototype["@@iterator"]=function(){return this},he.prototype[a]=function(){return this},he.prototype.next=function(){var q=this._index;if(q>=0&&q<this._keys.length){var F=this._selector(this._keys[q],this._values[q]);return q+1>=this._keys.length?(this._index=-1,this._keys=S,this._values=S):this._index++,{value:F,done:!1}}return{value:void 0,done:!0}},he.prototype.throw=function(q){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),q},he.prototype.return=function(q){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:q,done:!0}},he}(),U=function(){function he(){this._keys=[],this._values=[],this._cacheKey=x,this._cacheIndex=-2}return Object.defineProperty(he.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),he.prototype.has=function(q){return this._find(q,!1)>=0},he.prototype.get=function(q){var F=this._find(q,!1);return F>=0?this._values[F]:void 0},he.prototype.set=function(q,F){var K=this._find(q,!0);return this._values[K]=F,this},he.prototype.delete=function(q){var F=this._find(q,!1);if(F>=0){for(var K=this._keys.length,z=F+1;z<K;z++)this._keys[z-1]=this._keys[z],this._values[z-1]=this._values[z];return this._keys.length--,this._values.length--,no(q,this._cacheKey)&&(this._cacheKey=x,this._cacheIndex=-2),!0}return!1},he.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=x,this._cacheIndex=-2},he.prototype.keys=function(){return new I(this._keys,this._values,Y)},he.prototype.values=function(){return new I(this._keys,this._values,Rt)},he.prototype.entries=function(){return new I(this._keys,this._values,It)},he.prototype["@@iterator"]=function(){return this.entries()},he.prototype[a]=function(){return this.entries()},he.prototype._find=function(q,F){if(!no(this._cacheKey,q)){this._cacheIndex=-1;for(var K=0;K<this._keys.length;K++)if(no(this._keys[K],q)){this._cacheIndex=K;break}}return this._cacheIndex<0&&F&&(this._cacheIndex=this._keys.length,this._keys.push(q),this._values.push(void 0)),this._cacheIndex},he}();return U;function Y(he,q){return he}function Rt(he,q){return q}function It(he,q){return[he,q]}}function D0(){var x=function(){function S(){this._map=new R}return Object.defineProperty(S.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),S.prototype.has=function(I){return this._map.has(I)},S.prototype.add=function(I){return this._map.set(I,I),this},S.prototype.delete=function(I){return this._map.delete(I)},S.prototype.clear=function(){this._map.clear()},S.prototype.keys=function(){return this._map.keys()},S.prototype.values=function(){return this._map.keys()},S.prototype.entries=function(){return this._map.entries()},S.prototype["@@iterator"]=function(){return this.keys()},S.prototype[a]=function(){return this.keys()},S}();return x}function M0(){var x=16,S=l.create(),I=U();return function(){function q(){this._key=U()}return q.prototype.has=function(F){var K=Y(F,!1);return K!==void 0?l.has(K,this._key):!1},q.prototype.get=function(F){var K=Y(F,!1);return K!==void 0?l.get(K,this._key):void 0},q.prototype.set=function(F,K){var z=Y(F,!0);return z[this._key]=K,this},q.prototype.delete=function(F){var K=Y(F,!1);return K!==void 0?delete K[this._key]:!1},q.prototype.clear=function(){this._key=U()},q}();function U(){var q;do q="@@WeakMap@@"+he();while(l.has(S,q));return S[q]=!0,q}function Y(q,F){if(!n.call(q,I)){if(!F)return;Object.defineProperty(q,I,{value:l.create()})}return q[I]}function Rt(q,F){for(var K=0;K<F;++K)q[K]=Math.random()*255|0;return q}function It(q){if(typeof Uint8Array=="function"){var F=new Uint8Array(q);return typeof crypto<"u"?crypto.getRandomValues(F):typeof msCrypto<"u"?msCrypto.getRandomValues(F):Rt(F,q),F}return Rt(new Array(q),q)}function he(){var q=It(x);q[6]=q[6]&79|64,q[8]=q[8]&191|128;for(var F="",K=0;K<x;++K){var z=q[K];(K===4||K===6||K===8)&&(F+="-"),z<16&&(F+="0"),F+=z.toString(16).toLowerCase()}return F}}function io(x){return x.__=void 0,delete x.__,x}})})(O2||(O2={}));/*!
18
+ ***************************************************************************** */var Nh;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof lc=="object"?lc:typeof self=="object"?self:typeof this=="object"?this:o(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(c,u){return function(f,m){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:m}),u&&u(f,m)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function o(){return s()||a()}})(function(e,t){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!o&&!c,f={create:o?function(){return Yu(Object.create(null))}:c?function(){return Yu({__proto__:null})}:function(){return Yu({})},has:u?function(_,S){return n.call(_,S)}:function(_,S){return S in _},get:u?function(_,S){return n.call(_,S)?_[S]:void 0}:function(_,S){return _[S]}},m=Object.getPrototypeOf(Function),B=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Q0(),C=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:ev(),p=typeof WeakMap=="function"?WeakMap:tv(),g=i?Symbol.for("@reflect-metadata:registry"):void 0,A=J0(),O=Y0(A);function P(_,S,T,V){if(Q(T)){if(!ch(_))throw new TypeError;if(!uh(S))throw new TypeError;return E(_,S)}else{if(!ch(_))throw new TypeError;if(!He(S))throw new TypeError;if(!He(V)&&!Q(V)&&!ot(V))throw new TypeError;return ot(V)&&(V=void 0),T=yr(T),k(_,S,T,V)}}e("decorate",P);function N(_,S){function T(V,le){if(!He(V))throw new TypeError;if(!Q(le)&&!z0(le))throw new TypeError;Ce(_,S,V,le)}return T}e("metadata",N);function xe(_,S,T,V){if(!He(T))throw new TypeError;return Q(V)||(V=yr(V)),Ce(_,S,T,V)}e("defineMetadata",xe);function Le(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),x(_,S,T)}e("hasMetadata",Le);function qe(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),b(_,S,T)}e("hasOwnMetadata",qe);function Ze(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),j(_,S,T)}e("getMetadata",Ze);function tt(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),U(_,S,T)}e("getOwnMetadata",tt);function mt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),se(_,S)}e("getMetadataKeys",mt);function Rt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),Ne(_,S)}e("getOwnMetadataKeys",Rt);function I(_,S,T){if(!He(S))throw new TypeError;if(Q(T)||(T=yr(T)),!He(S))throw new TypeError;Q(T)||(T=yr(T));var V=bs(S,T,!1);return Q(V)?!1:V.OrdinaryDeleteMetadata(_,S,T)}e("deleteMetadata",I);function E(_,S){for(var T=_.length-1;T>=0;--T){var V=_[T],le=V(S);if(!Q(le)&&!ot(le)){if(!uh(le))throw new TypeError;S=le}}return S}function k(_,S,T,V){for(var le=_.length-1;le>=0;--le){var ct=_[le],nt=ct(S,T,V);if(!Q(nt)&&!ot(nt)){if(!He(nt))throw new TypeError;V=nt}}return V}function x(_,S,T){var V=b(_,S,T);if(V)return!0;var le=Ju(S);return ot(le)?!1:x(_,le,T)}function b(_,S,T){var V=bs(S,T,!1);return Q(V)?!1:oh(V.OrdinaryHasOwnMetadata(_,S,T))}function j(_,S,T){var V=b(_,S,T);if(V)return U(_,S,T);var le=Ju(S);if(!ot(le))return j(_,le,T)}function U(_,S,T){var V=bs(S,T,!1);if(!Q(V))return V.OrdinaryGetOwnMetadata(_,S,T)}function Ce(_,S,T,V){var le=bs(T,V,!0);le.OrdinaryDefineOwnMetadata(_,S,T,V)}function se(_,S){var T=Ne(_,S),V=Ju(_);if(V===null)return T;var le=se(V,S);if(le.length<=0)return T;if(T.length<=0)return le;for(var ct=new C,nt=[],je=0,W=T;je<W.length;je++){var ee=W[je],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}for(var ie=0,Be=le;ie<Be.length;ie++){var ee=Be[ie],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}return nt}function Ne(_,S){var T=bs(_,S,!1);return T?T.OrdinaryOwnMetadataKeys(_,S):[]}function Ue(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function Q(_){return _===void 0}function ot(_){return _===null}function Rn(_){return typeof _=="symbol"}function He(_){return typeof _=="object"?_!==null:typeof _=="function"}function rt(_,S){switch(Ue(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var T="string",V=lh(_,s);if(V!==void 0){var le=V.call(_,T);if(He(le))throw new TypeError;return le}return K0(_)}function K0(_,S){var T,V;{var le=_.toString;if(vo(le)){var V=le.call(_);if(!He(V))return V}var T=_.valueOf;if(vo(T)){var V=T.call(_);if(!He(V))return V}}throw new TypeError}function oh(_){return!!_}function W0(_){return""+_}function yr(_){var S=rt(_);return Rn(S)?S:W0(S)}function ch(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function vo(_){return typeof _=="function"}function uh(_){return typeof _=="function"}function z0(_){switch(Ue(_)){case 3:return!0;case 4:return!0;default:return!1}}function Gu(_,S){return _===S||_!==_&&S!==S}function lh(_,S){var T=_[S];if(T!=null){if(!vo(T))throw new TypeError;return T}}function dh(_){var S=lh(_,a);if(!vo(S))throw new TypeError;var T=S.call(_);if(!He(T))throw new TypeError;return T}function fh(_){return _.value}function hh(_){var S=_.next();return S.done?!1:S}function ph(_){var S=_.return;S&&S.call(_)}function Ju(_){var S=Object.getPrototypeOf(_);if(typeof _!="function"||_===m||S!==m)return S;var T=_.prototype,V=T&&Object.getPrototypeOf(T);if(V==null||V===Object.prototype)return S;var le=V.constructor;return typeof le!="function"||le===_?S:le}function G0(){var _;!Q(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=X0(t.Reflect));var S,T,V,le=new p,ct={registerProvider:nt,getProvider:W,setProvider:re};return ct;function nt(ie){if(!Object.isExtensible(ct))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===ie:break;case Q(S):S=ie;break;case S===ie:break;case Q(T):T=ie;break;case T===ie:break;default:V===void 0&&(V=new C),V.add(ie);break}}function je(ie,Be){if(!Q(S)){if(S.isProviderFor(ie,Be))return S;if(!Q(T)){if(T.isProviderFor(ie,Be))return S;if(!Q(V))for(var Fe=dh(V);;){var Xe=hh(Fe);if(!Xe)return;var Yt=fh(Xe);if(Yt.isProviderFor(ie,Be))return ph(Fe),Yt}}}if(!Q(_)&&_.isProviderFor(ie,Be))return _}function W(ie,Be){var Fe=le.get(ie),Xe;return Q(Fe)||(Xe=Fe.get(Be)),Q(Xe)&&(Xe=je(ie,Be),Q(Xe)||(Q(Fe)&&(Fe=new B,le.set(ie,Fe)),Fe.set(Be,Xe))),Xe}function ee(ie){if(Q(ie))throw new TypeError;return S===ie||T===ie||!Q(V)&&V.has(ie)}function re(ie,Be,Fe){if(!ee(Fe))throw new Error("Metadata provider not registered.");var Xe=W(ie,Be);if(Xe!==Fe){if(!Q(Xe))return!1;var Yt=le.get(ie);Q(Yt)&&(Yt=new B,le.set(ie,Yt)),Yt.set(Be,Fe)}return!0}}function J0(){var _;return!Q(g)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[g]),Q(_)&&(_=G0()),!Q(g)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function Y0(_){var S=new p,T={isProviderFor:function(ee,re){var ie=S.get(ee);return Q(ie)?!1:ie.has(re)},OrdinaryDefineOwnMetadata:nt,OrdinaryHasOwnMetadata:le,OrdinaryGetOwnMetadata:ct,OrdinaryOwnMetadataKeys:je,OrdinaryDeleteMetadata:W};return A.registerProvider(T),T;function V(ee,re,ie){var Be=S.get(ee),Fe=!1;if(Q(Be)){if(!ie)return;Be=new B,S.set(ee,Be),Fe=!0}var Xe=Be.get(re);if(Q(Xe)){if(!ie)return;if(Xe=new B,Be.set(re,Xe),!_.setProvider(ee,re,T))throw Be.delete(re),Fe&&S.delete(ee),new Error("Wrong provider for target.")}return Xe}function le(ee,re,ie){var Be=V(re,ie,!1);return Q(Be)?!1:oh(Be.has(ee))}function ct(ee,re,ie){var Be=V(re,ie,!1);if(!Q(Be))return Be.get(ee)}function nt(ee,re,ie,Be){var Fe=V(ie,Be,!0);Fe.set(ee,re)}function je(ee,re){var ie=[],Be=V(ee,re,!1);if(Q(Be))return ie;for(var Fe=Be.keys(),Xe=dh(Fe),Yt=0;;){var mh=hh(Xe);if(!mh)return ie.length=Yt,ie;var rv=fh(mh);try{ie[Yt]=rv}catch(nv){try{ph(Xe)}finally{throw nv}}Yt++}}function W(ee,re,ie){var Be=V(re,ie,!1);if(Q(Be)||!Be.delete(ee))return!1;if(Be.size===0){var Fe=S.get(re);Q(Fe)||(Fe.delete(ie),Fe.size===0&&S.delete(Fe))}return!0}}function X0(_){var S=_.defineMetadata,T=_.hasOwnMetadata,V=_.getOwnMetadata,le=_.getOwnMetadataKeys,ct=_.deleteMetadata,nt=new p,je={isProviderFor:function(W,ee){var re=nt.get(W);return!Q(re)&&re.has(ee)?!0:le(W,ee).length?(Q(re)&&(re=new C,nt.set(W,re)),re.add(ee),!0):!1},OrdinaryDefineOwnMetadata:S,OrdinaryHasOwnMetadata:T,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:le,OrdinaryDeleteMetadata:ct};return je}function bs(_,S,T){var V=A.getProvider(_,S);if(!Q(V))return V;if(T){if(A.setProvider(_,S,O))return O;throw new Error("Illegal state.")}}function Q0(){var _={},S=[],T=function(){function je(W,ee,re){this._index=0,this._keys=W,this._values=ee,this._selector=re}return je.prototype["@@iterator"]=function(){return this},je.prototype[a]=function(){return this},je.prototype.next=function(){var W=this._index;if(W>=0&&W<this._keys.length){var ee=this._selector(this._keys[W],this._values[W]);return W+1>=this._keys.length?(this._index=-1,this._keys=S,this._values=S):this._index++,{value:ee,done:!1}}return{value:void 0,done:!0}},je.prototype.throw=function(W){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),W},je.prototype.return=function(W){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:W,done:!0}},je}(),V=function(){function je(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(je.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),je.prototype.has=function(W){return this._find(W,!1)>=0},je.prototype.get=function(W){var ee=this._find(W,!1);return ee>=0?this._values[ee]:void 0},je.prototype.set=function(W,ee){var re=this._find(W,!0);return this._values[re]=ee,this},je.prototype.delete=function(W){var ee=this._find(W,!1);if(ee>=0){for(var re=this._keys.length,ie=ee+1;ie<re;ie++)this._keys[ie-1]=this._keys[ie],this._values[ie-1]=this._values[ie];return this._keys.length--,this._values.length--,Gu(W,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},je.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},je.prototype.keys=function(){return new T(this._keys,this._values,le)},je.prototype.values=function(){return new T(this._keys,this._values,ct)},je.prototype.entries=function(){return new T(this._keys,this._values,nt)},je.prototype["@@iterator"]=function(){return this.entries()},je.prototype[a]=function(){return this.entries()},je.prototype._find=function(W,ee){if(!Gu(this._cacheKey,W)){this._cacheIndex=-1;for(var re=0;re<this._keys.length;re++)if(Gu(this._keys[re],W)){this._cacheIndex=re;break}}return this._cacheIndex<0&&ee&&(this._cacheIndex=this._keys.length,this._keys.push(W),this._values.push(void 0)),this._cacheIndex},je}();return V;function le(je,W){return je}function ct(je,W){return W}function nt(je,W){return[je,W]}}function ev(){var _=function(){function S(){this._map=new B}return Object.defineProperty(S.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),S.prototype.has=function(T){return this._map.has(T)},S.prototype.add=function(T){return this._map.set(T,T),this},S.prototype.delete=function(T){return this._map.delete(T)},S.prototype.clear=function(){this._map.clear()},S.prototype.keys=function(){return this._map.keys()},S.prototype.values=function(){return this._map.keys()},S.prototype.entries=function(){return this._map.entries()},S.prototype["@@iterator"]=function(){return this.keys()},S.prototype[a]=function(){return this.keys()},S}();return _}function tv(){var _=16,S=f.create(),T=V();return function(){function W(){this._key=V()}return W.prototype.has=function(ee){var re=le(ee,!1);return re!==void 0?f.has(re,this._key):!1},W.prototype.get=function(ee){var re=le(ee,!1);return re!==void 0?f.get(re,this._key):void 0},W.prototype.set=function(ee,re){var ie=le(ee,!0);return ie[this._key]=re,this},W.prototype.delete=function(ee){var re=le(ee,!1);return re!==void 0?delete re[this._key]:!1},W.prototype.clear=function(){this._key=V()},W}();function V(){var W;do W="@@WeakMap@@"+je();while(f.has(S,W));return S[W]=!0,W}function le(W,ee){if(!n.call(W,T)){if(!ee)return;Object.defineProperty(W,T,{value:f.create()})}return W[T]}function ct(W,ee){for(var re=0;re<ee;++re)W[re]=Math.random()*255|0;return W}function nt(W){if(typeof Uint8Array=="function"){var ee=new Uint8Array(W);return typeof crypto<"u"?crypto.getRandomValues(ee):typeof msCrypto<"u"?msCrypto.getRandomValues(ee):ct(ee,W),ee}return ct(new Array(W),W)}function je(){var W=nt(_);W[6]=W[6]&79|64,W[8]=W[8]&191|128;for(var ee="",re=0;re<_;++re){var ie=W[re];(re===4||re===6||re===8)&&(ee+="-"),ie<16&&(ee+="0"),ee+=ie.toString(16).toLowerCase()}return ee}}function Yu(_){return _.__=void 0,delete _.__,_}})})(Nh||(Nh={}));/*!
19
19
  * MIT License
20
20
  *
21
21
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -38,9 +38,9 @@ and limitations under the License.
38
38
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
39
  * SOFTWARE.
40
40
  *
41
- */const o9="[object ArrayBuffer]";class le{static isArrayBuffer(e){return Object.prototype.toString.call(e)===o9}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=le.toUint8Array(e),s=le.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 z0="string",c9=/^[0-9a-f]+$/i,u9=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,l9=/^[a-zA-Z0-9-_]+$/;class j2{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=le.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}}class Es{static toString(e,t=!1){const n=le.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===z0&&c9.test(e)}static isBase64(e){return typeof e===z0&&u9.test(e)}static isBase64Url(e){return typeof e===z0&&l9.test(e)}static ToString(e,t="utf8"){const n=le.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 Es.toString(n,!0);case"utf16":case"utf16be":return Es.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 Es.fromString(e,!0);case"utf16":case"utf16be":return Es.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=le.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 j2.fromString(e);case"utf16":case"utf16be":return Es.fromString(e);case"utf16le":case"usc2":return Es.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 j2.toString(e);case"utf16":case"utf16be":return Es.toString(e);case"utf16le":case"usc2":return Es.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=le.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){const t=le.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 Es.toString(e,t)}static FromUtf16String(e,t=!1){return Es.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 d9(...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 Gj(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}/*!
41
+ */const nw="[object ArrayBuffer]";class q{static isArrayBuffer(e){return Object.prototype.toString.call(e)===nw}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=q.toUint8Array(e),i=q.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const a of t)n+=a.byteLength;const i=new Uint8Array(n);let s=0;for(const a of t){const o=this.toUint8Array(a);i.set(o,s),s+=o.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const nl="string",iw=/^[0-9a-f]+$/i,sw=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,aw=/^[a-zA-Z0-9-_]+$/;class Bh{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){const t=q.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class gr{static toString(e,t=!1){const n=q.toArrayBuffer(e),i=new DataView(n);let s="";for(let a=0;a<n.byteLength;a+=2){const o=i.getUint16(a,t);s+=String.fromCharCode(o)}return s}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}}class te{static isHex(e){return typeof e===nl&&iw.test(e)}static isBase64(e){return typeof e===nl&&sw.test(e)}static isBase64Url(e){return typeof e===nl&&aw.test(e)}static ToString(e,t="utf8"){const n=q.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return gr.toString(n,!0);case"utf16":case"utf16be":return gr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return gr.fromString(e,!0);case"utf16":case"utf16be":return gr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=q.toUint8Array(e);if(typeof btoa<"u"){const n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=te.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Bh.fromString(e);case"utf16":case"utf16be":return gr.fromString(e);case"utf16le":case"usc2":return gr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=te.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Bh.toString(e);case"utf16":case"utf16be":return gr.toString(e);case"utf16le":case"usc2":return gr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){const t=q.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){const t=q.toUint8Array(e);let n="";const i=t.length;for(let s=0;s<i;s++){const a=t[s];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!te.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i=i+2){const s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return gr.toString(e,t)}static FromUtf16String(e,t=!1){return gr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}te.DEFAULT_UTF8_ENCODING="utf8";function ow(...r){const e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e);let n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)t[n++]=s}),t.buffer}function My(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}/*!
42
42
  Copyright (c) Peculiar Ventures, LLC
43
- */function ku(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 Ho(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 l=o-1;l>=0;l--){const h=Math.pow(2,l*e);u[i-l-1]=Math.floor(s/h),s-=u[i-l-1]*h}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function Jb(...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 Jj(){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=ku(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,ku(i,8)-n}function h9(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=Ho(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let s=Ho(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 p9(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 yn(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)}/*!
43
+ */function Wi(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function ni(r,e,t=-1){const n=t;let i=r,s=0,a=Math.pow(2,e);for(let o=1;o<8;o++){if(r<a){let c;if(n<0)c=new ArrayBuffer(o),s=o;else{if(n<o)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}const u=new Uint8Array(c);for(let f=o-1;f>=0;f--){const m=Math.pow(2,f*e);u[s-f-1]=Math.floor(i/m),i-=u[s-f-1]*m}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function $l(...r){let e=0,t=0;for(const s of r)e+=s.length;const n=new ArrayBuffer(e),i=new Uint8Array(n);for(const s of r)i.set(s,t),t+=s.length;return i}function Uy(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const o=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(o||c)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let o=0;o<this.valueHex.byteLength;o++)t[o]=0;t[0]=r[0]&128;const n=Wi(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let o=0;o<this.valueHex.byteLength;o++)s[o]=r[o];return s[0]&=127,Wi(s,8)-n}function cw(r){const e=r<0?r*-1:r;let t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){const a=t-e,o=ni(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let i=ni(e,8,n),s=new Uint8Array(i);if(s[0]&128){const a=i.slice(0),o=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let c=0;c<a.byteLength;c++)s[c+1]=o[c];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function uw(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function Pt(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,i=new Array(n);for(let a=0;a<n;a++)i[a]="0";return i.join("").concat(t)}/*!
44
44
  * Copyright (c) 2014, GMO GlobalSign
45
45
  * Copyright (c) 2015-2022, Peculiar Ventures
46
46
  * All rights reserved.
@@ -72,11 +72,11 @@ and limitations under the License.
72
72
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
73
73
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74
74
  *
75
- */function Hm(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function kx(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 qi(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 Wg{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return kx(this.items)}}const Ul=[new Uint8Array([1])],C2="0123456789",W0="name",E2="valueHexView",f9="isHexOnly",m9="idBlock",y9="tagClass",g9="tagNumber",v9="isConstructed",b9="fromBER",_9="toBER",w9="local",en="",As=new ArrayBuffer(0),Gg=new Uint8Array(0),oh="EndOfContent",Yj="OCTET STRING",Xj="BIT STRING";function ni(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?le.toUint8Array(i.valueHex):Gg}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(!qi(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",As)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Ne.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class xc{constructor({blockLength:e=0,error:t=en,warnings:n=[],valueBeforeDecode:s=Gg}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=le.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)}}}xc.NAME="baseBlock";class zr extends xc{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'")}}zr.NAME="valueBlock";class Qj extends ni(xc){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?le.toUint8Array(e.valueHex):Gg,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",As}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=Ho(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=le.toUint8Array(e);if(!qi(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),l=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===l){l+=255;const R=new Uint8Array(l);for(let B=0;B<u.length;B++)R[B]=u[B];u=this.valueHexView=new Uint8Array(l)}}this.blockLength=c+1,u[c-1]=i[c]&127;const h=new Uint8Array(c);for(let R=0;R<c;R++)h[R]=u[R];u=this.valueHexView=new Uint8Array(c),u.set(h),this.blockLength<=9?this.tagNumber=ku(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}}}Qj.NAME="identificationBlock";class e3 extends xc{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=le.toUint8Array(e);if(!qi(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=ku(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=Ho(this.length,8);if(s.byteLength>127)return this.error="Too big length",As;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}}}e3.NAME="lengthBlock";const Ee={};class Ar extends xc{constructor({name:e=en,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Qj(s),this.lenBlock=new e3(s),this.valueBlock=i?new i(s):new zr(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 Wg;t||t3(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?As: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 p9(t,n)}}Ar.NAME="BaseBlock";function t3(r){if(r instanceof Ee.Constructed)for(const e of r.valueBlock.value)t3(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class Sx extends Ar{constructor({value:e=en,...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}'`}}Sx.NAME="BaseStringBlock";class r3 extends ni(zr){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}r3.NAME="PrimitiveValueBlock";var n3;class Lp extends Ar{constructor(e={}){super(e,r3),this.idBlock.isConstructed=!1}}n3=Lp;Ee.Primitive=n3;Lp.NAME="PRIMITIVE";function x9(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 al(r,e=0,t=r.length){const n=e;let s=new Ar({},zr);const i=new xc;if(!qi(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=Ar;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=Ee.EndOfContent;break;case 1:c=Ee.Boolean;break;case 2:c=Ee.Integer;break;case 3:c=Ee.BitString;break;case 4:c=Ee.OctetString;break;case 5:c=Ee.Null;break;case 6:c=Ee.ObjectIdentifier;break;case 10:c=Ee.Enumerated;break;case 12:c=Ee.Utf8String;break;case 13:c=Ee.RelativeObjectIdentifier;break;case 14:c=Ee.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=Ee.Sequence;break;case 17:c=Ee.Set;break;case 18:c=Ee.NumericString;break;case 19:c=Ee.PrintableString;break;case 20:c=Ee.TeletexString;break;case 21:c=Ee.VideotexString;break;case 22:c=Ee.IA5String;break;case 23:c=Ee.UTCTime;break;case 24:c=Ee.GeneralizedTime;break;case 25:c=Ee.GraphicString;break;case 26:c=Ee.VisibleString;break;case 27:c=Ee.GeneralString;break;case 28:c=Ee.UniversalString;break;case 29:c=Ee.CharacterString;break;case 30:c=Ee.BmpString;break;case 31:c=Ee.DATE;break;case 32:c=Ee.TimeOfDay;break;case 33:c=Ee.DateTime;break;case 34:c=Ee.Duration;break;default:{const u=s.idBlock.isConstructed?new Ee.Constructed:new Ee.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?Ee.Constructed:Ee.Primitive}return s=x9(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 su(r){if(!r.byteLength){const e=new Ar({},zr);return e.error="Input buffer has zero length",{offset:-1,result:e}}return al(le.toUint8Array(r).slice(),0,r.byteLength)}function k9(r,e){return r?1:e}class wa extends zr{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const s=le.toUint8Array(e);if(!qi(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(;k9(this.isIndefiniteForm,n)>0;){const a=al(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===oh)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===oh?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const n=t||new Wg;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?As:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}wa.NAME="ConstructedValueBlock";var s3;class rn extends Ar{constructor(e={}){super(e,wa),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(`
76
- `).map(s=>` ${s}`).join(`
75
+ */function fc(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function gf(r){let e=0,t=0;for(let i=0;i<r.length;i++){const s=r[i];e+=s.byteLength}const n=new Uint8Array(e);for(let i=0;i<r.length;i++){const s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function Qr(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class su{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return gf(this.items)}}const Ss=[new Uint8Array([1])],Rh="0123456789",il="name",Ph="valueHexView",lw="isHexOnly",dw="idBlock",fw="tagClass",hw="tagNumber",pw="isConstructed",mw="fromBER",yw="toBER",gw="local",It="",pr=new ArrayBuffer(0),au=new Uint8Array(0),va="EndOfContent",Vy="OCTET STRING",Ly="BIT STRING";function jr(r){var e;return e=class extends r{constructor(...n){var i;super(...n);const s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?q.toUint8Array(s.valueHex):au}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){const a=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Qr(this,a,i,s))return-1;const o=i+s;return this.valueHexView=a.subarray(i,o),this.valueHexView.length?(this.blockLength=s,o):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",pr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:te.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class gi{constructor({blockLength:e=0,error:t=It,warnings:n=[],valueBeforeDecode:i=au}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=q.toUint8Array(i)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:te.ToHex(this.valueBeforeDecodeView)}}}gi.NAME="baseBlock";class St extends gi{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}St.NAME="valueBlock";class qy extends jr(gi){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?q.toUint8Array(e.valueHex):au,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",pr}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){const i=ni(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,o=new Uint8Array(a+1);if(o[0]=t|31,!e){for(let c=0;c<a-1;c++)o[c+1]=s[c]|128;o[a]=s[a-1]}return o.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const o=s[0]&31;if(o!==31)this.tagNumber=o,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;s[c]&128;){if(u[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;const B=new Uint8Array(f);for(let C=0;C<u.length;C++)B[C]=u[C];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=s[c]&127;const m=new Uint8Array(c);for(let B=0;B<c;B++)m[B]=u[B];u=this.valueHexView=new Uint8Array(c),u.set(m),this.blockLength<=9?this.tagNumber=Wi(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}qy.NAME="identificationBlock";class Hy extends gi{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;const a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const o=t+1,c=i.subarray(o,o+a);return c[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Wi(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){const i=ni(this.length,8);if(i.byteLength>127)return this.error="Too big length",pr;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)n[a+1]=s[a];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Hy.NAME="lengthBlock";const X={};class ft extends gi{constructor({name:e=It,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new qy(i),this.lenBlock=new Hy(i),this.valueBlock=s?new s(i):new St(i)}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){const n=t||new su;t||Fy(this);const i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(e);n.write(a),n.write(s)}return t?pr:n.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():te.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${te.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),n=e.toBER();return uw(t,n)}}ft.NAME="BaseBlock";function Fy(r){if(r instanceof X.Constructed)for(const e of r.valueBlock.value)Fy(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class vf extends ft{constructor({value:e=It,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}vf.NAME="BaseStringBlock";class Ky extends jr(St){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Ky.NAME="PrimitiveValueBlock";var Wy;class Xa extends ft{constructor(e={}){super(e,Ky),this.idBlock.isConstructed=!1}}Wy=Xa;X.Primitive=Wy;Xa.NAME="PRIMITIVE";function vw(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function us(r,e=0,t=r.length){const n=e;let i=new ft({},St);const s=new gi;if(!Qr(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let o=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),o===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=o,t-=i.idBlock.blockLength,o=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),o===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=o,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let c=ft;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};c=X.EndOfContent;break;case 1:c=X.Boolean;break;case 2:c=X.Integer;break;case 3:c=X.BitString;break;case 4:c=X.OctetString;break;case 5:c=X.Null;break;case 6:c=X.ObjectIdentifier;break;case 10:c=X.Enumerated;break;case 12:c=X.Utf8String;break;case 13:c=X.RelativeObjectIdentifier;break;case 14:c=X.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:c=X.Sequence;break;case 17:c=X.Set;break;case 18:c=X.NumericString;break;case 19:c=X.PrintableString;break;case 20:c=X.TeletexString;break;case 21:c=X.VideotexString;break;case 22:c=X.IA5String;break;case 23:c=X.UTCTime;break;case 24:c=X.GeneralizedTime;break;case 25:c=X.GraphicString;break;case 26:c=X.VisibleString;break;case 27:c=X.GeneralString;break;case 28:c=X.UniversalString;break;case 29:c=X.CharacterString;break;case 30:c=X.BmpString;break;case 31:c=X.DATE;break;case 32:c=X.TimeOfDay;break;case 33:c=X.DateTime;break;case 34:c=X.Duration;break;default:{const u=i.idBlock.isConstructed?new X.Constructed:new X.Primitive;u.idBlock=i.idBlock,u.lenBlock=i.lenBlock,u.warnings=i.warnings,i=u}}break;case 2:case 3:case 4:default:c=i.idBlock.isConstructed?X.Constructed:X.Primitive}return i=vw(i,c),o=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:o,result:i}}function Bi(r){if(!r.byteLength){const e=new ft({},St);return e.error="Input buffer has zero length",{offset:-1,result:e}}return us(q.toUint8Array(r).slice(),0,r.byteLength)}function bw(r,e){return r?1:e}class mn extends St{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;bw(this.isIndefiniteForm,n)>0;){const a=us(i,s,n);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,n-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===va)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===va?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const n=t||new su;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?pr:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}mn.NAME="ConstructedValueBlock";var zy;class Ct extends ft{constructor(e={}){super(e,mn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
76
+ `).map(i=>` ${i}`).join(`
77
77
  `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
78
78
  ${e.join(`
79
- `)}`:`${t} :`}}s3=rn;Ee.Constructed=s3;rn.NAME="CONSTRUCTED";class i3 extends zr{fromBER(e,t,n){return t}toBER(e){return As}}i3.override="EndOfContentValueBlock";var a3;class Ax extends Ar{constructor(e={}){super(e,i3),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}a3=Ax;Ee.EndOfContent=a3;Ax.NAME=oh;var o3;class Fo extends Ar{constructor(e={}){super(e,zr),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}`}}o3=Fo;Ee.Null=o3;Fo.NAME="NULL";class c3 extends ni(zr){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=le.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=le.toUint8Array(e);return qi(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,Jj.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}c3.NAME="BooleanValueBlock";var u3;let Jg=class extends Ar{constructor(e={}){super(e,c3),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}`}};u3=Jg;Ee.Boolean=u3;Jg.NAME="BOOLEAN";class l3 extends ni(wa){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=wa.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===oh){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Yj)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?wa.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}l3.NAME="OctetStringValueBlock";var d3;let Bo=class h3 extends Ar{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},l3),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=al(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?rn.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 h3&&e.push(t.valueBlock.valueHexView);return le.concat(e)}};d3=Bo;Ee.OctetString=d3;Bo.NAME=Yj;class p3 extends ni(wa){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=wa.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(const o of this.value){const c=o.constructor.NAME;if(c===oh){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Xj)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=le.toUint8Array(e);if(!qi(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=al(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 wa.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return As;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}}}p3.NAME="BitStringValueBlock";var f3;let Ro=class extends Ar{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},p3),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 rn.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)}`}}};f3=Ro;Ee.BitString=f3;Ro.NAME=Xj;var m3;function S9(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 l=c<a?a:c;let h=0;for(let R=l;R>=0;R--,h++){switch(!0){case h<o.length:u=i[a-h]+o[c-h]+t[0];break;default:u=i[a-h]+t[0]}switch(t[0]=u/10,!0){case h>=i.length:i=Jb(new Uint8Array([u%10]),i);break;default:i[a-h]=u%10}}return t[0]>0&&(i=Jb(t,i)),i}function I2(r){if(r>=Ul.length)for(let e=Ul.length;e<=r;e++){const t=new Uint8Array([0]);let n=Ul[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=Jb(t,n)),Ul.push(n)}return Ul[r]}function A9(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,l=0;for(let h=c;h>=0;h--,l++)switch(u=i[a-l]-o[c-l]-t,!0){case u<0:t=1,i[a-l]=u+10;break;default:t=0,i[a-l]=u}if(t>0)for(let h=a-c+1;h>=0;h--,l++)if(u=i[a-l]-t,u<0)t=1,i[a-l]=u+10;else{t=0,i[a-l]=u;break}return i.slice()}class Ox extends ni(zr){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=Jj.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(h9(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=A9(I2(n),t),a="-";break;default:t=S9(t,I2(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=C2.charAt(t[c]));return o===!1&&(a+=C2.charAt(0)),a}}m3=Ox;Ox.NAME="IntegerValueBlock";Object.defineProperty(m3.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var y3;class Ms extends Ar{constructor(e={}){super(e,Ox),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Hm(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Hm();const t=BigInt(e),n=new Wg,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,l=le.toUint8Array(Ne.FromHex(u.toString(16)));l[0]|=128,n.write(l)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new Ms({valueHex:n.final()})}convertToDER(){const e=new Ms({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Ms({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}y3=Ms;Ee.Integer=y3;Ms.NAME="INTEGER";var g3;class Yg extends Ms{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}g3=Yg;Ee.Enumerated=g3;Yg.NAME="ENUMERATED";class Yb extends ni(zr){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=le.toUint8Array(e);if(!qi(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=ku(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Hm();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=Ho(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",As;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}}}Yb.NAME="sidBlock";class v3 extends zr{constructor({value:e=en,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new Yb;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,As;t.push(s)}return kx(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 Yb;if(s>Number.MAX_SAFE_INTEGER){Hm();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}}v3.NAME="ObjectIdentifierValueBlock";var b3;class Xg extends Ar{constructor(e={}){super(e,v3),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()}}}b3=Xg;Ee.ObjectIdentifier=b3;Xg.NAME="OBJECT IDENTIFIER";class Xb extends ni(xc){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const s=le.toUint8Array(e);if(!qi(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=ku(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=Ho(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",As;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}}}Xb.NAME="relativeSidBlock";class _3 extends zr{constructor({value:e=en,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new Xb;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,As;n.push(i)}return kx(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 Xb;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}}_3.NAME="RelativeObjectIdentifierValueBlock";var w3;class jx extends Ar{constructor(e={}){super(e,_3),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()}}}w3=jx;Ee.RelativeObjectIdentifier=w3;jx.NAME="RelativeObjectIdentifier";var x3;class xi extends rn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}x3=xi;Ee.Sequence=x3;xi.NAME="SEQUENCE";var k3;let ki=class extends rn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};k3=ki;Ee.Set=k3;ki.NAME="SET";class S3 extends ni(zr){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=en}toJSON(){return{...super.toJSON(),value:this.value}}}S3.NAME="StringValueBlock";class A3 extends S3{}A3.NAME="SimpleStringValueBlock";class Sn extends Sx{constructor({...e}={}){super(e,A3)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,le.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}}Sn.NAME="SIMPLE STRING";class O3 extends Sn{fromBuffer(e){this.valueBlock.valueHexView=le.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}}O3.NAME="Utf8StringValueBlock";var j3;class Hi extends O3{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}j3=Hi;Ee.Utf8String=j3;Hi.NAME="UTF8String";class C3 extends Sn{fromBuffer(e){this.valueBlock.value=Ne.ToUtf16String(e),this.valueBlock.valueHexView=le.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Ne.FromUtf16String(e))}}C3.NAME="BmpStringValueBlock";var E3;class Qg extends C3{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}E3=Qg;Ee.BmpString=E3;Qg.NAME="BMPString";class I3 extends Sn{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=Ho(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}}I3.NAME="UniversalStringValueBlock";var T3;class ev extends I3{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}T3=ev;Ee.UniversalString=T3;ev.NAME="UniversalString";var N3;class tv extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}N3=tv;Ee.NumericString=N3;tv.NAME="NumericString";var B3;class rv extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}B3=rv;Ee.PrintableString=B3;rv.NAME="PrintableString";var R3;class nv extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}R3=nv;Ee.TeletexString=R3;nv.NAME="TeletexString";var P3;class sv extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}P3=sv;Ee.VideotexString=P3;sv.NAME="VideotexString";var $3;class iv extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}$3=iv;Ee.IA5String=$3;iv.NAME="IA5String";var Z3;class av extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Z3=av;Ee.GraphicString=Z3;av.NAME="GraphicString";var D3;class qp extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}D3=qp;Ee.VisibleString=D3;qp.NAME="VisibleString";var M3;class ov extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}M3=ov;Ee.GeneralString=M3;ov.NAME="GeneralString";var U3;class cv extends Sn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}U3=cv;Ee.CharacterString=U3;cv.NAME="CharacterString";var V3;class Hp extends qp{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,le.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]=yn(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=yn(this.month,2),t[2]=yn(this.day,2),t[3]=yn(this.hour,2),t[4]=yn(this.minute,2),t[5]=yn(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}}}V3=Hp;Ee.UTCTime=V3;Hp.NAME="UTCTime";var L3;class uv extends Hp{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 h=new Number(e[e.length-1]);if(isNaN(h.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 h=1,R=n.indexOf("+"),B="";if(R===-1&&(R=n.indexOf("-"),h=-1),R!==-1){if(B=n.substring(R+1),n=n.substring(0,R),B.length!==2&&B.length!==4)throw new Error("Wrong input string for conversion");let d=parseInt(B.substring(0,2),10);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");if(o=h*d,B.length===4){if(d=parseInt(B.substring(2,4),10),isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");c=h*d}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){const h=new Number(`0${n.substring(u)}`);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");i=h.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 h=60*i;this.minute=Math.floor(h),h=60*(h-this.minute),this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case s.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*i;this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case s.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const h=1e3*i;this.millisecond=Math.floor(h)}break;default:throw new Error("Wrong input string for conversion")}const l=a.exec(s);if(l===null)throw new Error("Wrong input string for conversion");for(let h=1;h<l.length;h++)switch(h){case 1:this.year=parseInt(l[h],10);break;case 2:this.month=parseInt(l[h],10);break;case 3:this.day=parseInt(l[h],10);break;case 4:this.hour=parseInt(l[h],10)+o;break;case 5:this.minute=parseInt(l[h],10)+c;break;case 6:this.second=parseInt(l[h],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const h=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=h.getUTCFullYear(),this.month=h.getUTCMonth(),this.day=h.getUTCDay(),this.hour=h.getUTCHours(),this.minute=h.getUTCMinutes(),this.second=h.getUTCSeconds(),this.millisecond=h.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(yn(this.year,4)),t.push(yn(this.month,2)),t.push(yn(this.day,2)),t.push(yn(this.hour,2)),t.push(yn(this.minute,2)),t.push(yn(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(yn(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}L3=uv;Ee.GeneralizedTime=L3;uv.NAME="GeneralizedTime";var q3;class Cx extends Hi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}q3=Cx;Ee.DATE=q3;Cx.NAME="DATE";var H3;class Ex extends Hi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}H3=Ex;Ee.TimeOfDay=H3;Ex.NAME="TimeOfDay";var F3;class Ix extends Hi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}F3=Ix;Ee.DateTime=F3;Ix.NAME="DateTime";var K3;class Tx extends Hi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}K3=Tx;Ee.Duration=K3;Tx.NAME="Duration";var z3;class Nx extends Hi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}z3=Nx;Ee.TIME=z3;Nx.NAME="TIME";class Ko{constructor({name:e=en,optional:t=!1}={}){this.name=e,this.optional=t}}class Bx extends Ko{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Fm extends Ko{constructor({value:e=new Ko,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class O9{constructor({data:e=Gg}={}){this.dataView=le.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=le.toUint8Array(e)}fromBER(e,t,n){const s=t+n;return this.dataView=le.toUint8Array(e).subarray(t,s),s}toBER(e){return this.dataView.slice().buffer}}function wo(r,e,t){if(t instanceof Bx){for(let i=0;i<t.value.length;i++)if(wo(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(W0)&&(i.name=t.name),i}}if(t instanceof Ko)return t.hasOwnProperty(W0)&&(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(!(m9 in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(b9 in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(_9 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(y9)===!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(g9)===!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(v9)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(f9 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(!(E2 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,en),t.name&&(r[t.name]=e)),t instanceof Ee.Constructed){let i=0,a={verified:!1,result:{error:"Unknown error"}},o=t.valueBlock.value.length;if(o>0&&t.valueBlock.value[0]instanceof Fm&&(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,en),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,en),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof Fm){if(a=wo(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,en),t.name&&delete r[t.name]),a;if(W0 in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};w9 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=wo(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,en),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,en),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&E2 in e.valueBlock){const i=al(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,en),t.name&&(delete r[t.name],a.name=t.name)),a}return wo(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function j9(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=al(le.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:wo(t.result,t.result,e)}const W3=Object.freeze(Object.defineProperty({__proto__:null,Any:Ko,BaseBlock:Ar,BaseStringBlock:Sx,BitString:Ro,BmpString:Qg,Boolean:Jg,CharacterString:cv,Choice:Bx,Constructed:rn,DATE:Cx,DateTime:Ix,Duration:Tx,EndOfContent:Ax,Enumerated:Yg,GeneralString:ov,GeneralizedTime:uv,GraphicString:av,HexBlock:ni,IA5String:iv,Integer:Ms,Null:Fo,NumericString:tv,ObjectIdentifier:Xg,OctetString:Bo,Primitive:Lp,PrintableString:rv,RawData:O9,RelativeObjectIdentifier:jx,Repeated:Fm,Sequence:xi,Set:ki,TIME:Nx,TeletexString:nv,TimeOfDay:Ex,UTCTime:Hp,UniversalString:ev,Utf8String:Hi,ValueBlock:zr,VideotexString:sv,ViewWriter:Wg,VisibleString:qp,compareSchema:wo,fromBER:su,verifySchema:j9},Symbol.toStringTag,{value:"Module"}));var G;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(G||(G={}));var Z;(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"})(Z||(Z={}));class lv{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(le.isBufferSource(e))this.unusedBits=t,this.value=le.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Ro))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 Ro({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Ro({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 qt{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):le.isBufferSource(e)?this.buffer=le.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Bo))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Bo({valueHex:this.buffer})}toSchema(e){return new Bo({name:e})}}const C9={fromASN:r=>r instanceof Fo?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new Fo;const e=su(r);if(e.result.error)throw new Error(e.result.error);return e.result}},E9={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new Ms({value:+r})},I9={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Yg({value:r})},Yt={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Ms({valueHex:r})},T9={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Ro({valueHex:r})},N9={fromASN:r=>r.valueBlock.toString(),toASN:r=>new Xg({value:r})},B9={fromASN:r=>r.valueBlock.value,toASN:r=>new Jg({value:r})},Km={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Bo({valueHex:r})},R9={fromASN:r=>new qt(r.getValue()),toASN:r=>r.toASN()};function qn(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const G3=qn(Hi),P9=qn(Qg),$9=qn(ev),Z9=qn(tv),D9=qn(rv),M9=qn(nv),U9=qn(sv),V9=qn(iv),L9=qn(av),q9=qn(qp),H9=qn(ov),F9=qn(cv),K9={fromASN:r=>r.toDate(),toASN:r=>new Hp({valueDate:r})},z9={fromASN:r=>r.toDate(),toASN:r=>new uv({valueDate:r})},W9={fromASN:()=>null,toASN:()=>new Fo};function Rx(r){switch(r){case Z.Any:return C9;case Z.BitString:return T9;case Z.BmpString:return P9;case Z.Boolean:return B9;case Z.CharacterString:return F9;case Z.Enumerated:return I9;case Z.GeneralString:return H9;case Z.GeneralizedTime:return z9;case Z.GraphicString:return L9;case Z.IA5String:return V9;case Z.Integer:return E9;case Z.Null:return W9;case Z.NumericString:return Z9;case Z.ObjectIdentifier:return N9;case Z.OctetString:return Km;case Z.PrintableString:return D9;case Z.TeletexString:return M9;case Z.UTCTime:return K9;case Z.UniversalString:return $9;case Z.Utf8String:return G3;case Z.VideotexString:return U9;case Z.VisibleString:return q9;default:return null}}function _i(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:_i(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function J3(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:J3(t)}return!1}function G9(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 J9{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:G.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 l=Z[a.type],h=W3[l];if(!h)throw new Error(`Cannot get ASN1 class by name '${l}'`);c=new h({name:o})}else _i(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===G.Choice?c=new Ko({name:o}):(c=this.create(a.type,!1),c.name=o):c=new Ko({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const l=a.repeated==="set"?ki:xi;c=new l({name:"",value:[new Fm({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||_i(a.type)){const l=a.repeated?rn:Lp;s.push(new l({name:o,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const l=!!a.repeated;let h=l?c:this.get(a.type,!0).schema;h="valueBlock"in h?h.valueBlock.value:h.value,s.push(new rn({name:l?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:h}))}else s.push(new rn({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,s.push(c)}switch(n.type){case G.Sequence:return new xi({value:s,name:""});case G.Set:return new ki({value:s,name:""});case G.Choice:return new Bx({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 Bn=new J9,X=r=>e=>{let t;Bn.has(e)?t=Bn.get(e):(t=Bn.createDefault(e),Bn.set(e,t)),Object.assign(t,r)},_=r=>(e,t)=>{let n;Bn.has(e.constructor)?n=Bn.get(e.constructor):(n=Bn.createDefault(e.constructor),Bn.set(e.constructor,n));const s=Object.assign({},r);if(typeof s.type=="number"&&!s.converter){const i=Rx(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 T2 extends Error{constructor(){super(...arguments),this.schemas=[]}}class Y9{static parse(e,t){const n=su(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(_i(t))return new t().fromASN(e);const s=Bn.get(t);Bn.cache(t);let i=s.schema;if(e.constructor===rn&&s.type!==G.Choice){i=new rn({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:s.schema.valueBlock.value});for(const c in s.items)delete e[c]}const a=wo({},e,i);if(!a.verified)throw new T2(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(J3(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=Rx(c);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,l=>u.fromASN(l))}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 l=s.items[c],h=l.type;if(typeof h=="number"||_i(h)){const R=(n=l.converter)!==null&&n!==void 0?n:_i(h)?new h:null;if(!R)throw new Error("Converter is empty");if(l.repeated)if(l.implicit){const B=l.repeated==="sequence"?xi:ki,d=new B;d.valueBlock=u.valueBlock;const g=su(d.toBER(!1));if(g.offset===-1)throw new Error(`Cannot parse the child item. ${g.result.error}`);if(!("value"in g.result.valueBlock&&Array.isArray(g.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const A=g.result.valueBlock.value;o[c]=Array.from(A,O=>R.fromASN(O))}else o[c]=Array.from(u,B=>R.fromASN(B));else{let B=u;if(l.implicit){let d;if(_i(h))d=new h().toSchema("");else{const g=Z[h],A=W3[g];if(!A)throw new Error(`Cannot get '${g}' class from asn1js module`);d=new A}d.valueBlock=B.valueBlock,B=su(d.toBER(!1)).result}o[c]=R.fromASN(B)}}else if(l.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,R=>this.fromASN(R,h))}else o[c]=this.fromASN(u,h)}return o}catch(s){throw s instanceof T2&&s.schemas.push(t.name),s}}}class Px{static serialize(e){return e instanceof Ar?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&_i(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=Bn.get(t);Bn.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=Rx(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"&&G9(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=Px.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||_i(o.type))){const l={};l.valueHex=u instanceof Fo?u.valueBeforeDecodeView:u.valueBlock.toBER(),s.push(new Lp({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...l}))}else s.push(new rn({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else s.push(new rn({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 G.Sequence:i=new xi({value:s});break;case G.Set:i=new ki({value:s});break;case G.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 ${Z[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"?xi:ki;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"?xi:ki;i=new o({value:a})}else i=this.toASN(s);return i}}class zt extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class oe{static serialize(e){return Px.serialize(e)}static parse(e,t){return Y9.parse(e,t)}static toString(e){const t=le.isBufferSource(e)?le.toArrayBuffer(e):oe.serialize(e),n=su(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function p(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 Y3={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(d,g){if(d.indexOf("::")!==d.lastIndexOf("::"))return null;let A=0,O=-1,$=(d.match(c.zoneIndex)||[])[0],P,ae;for($&&($=$.substring(1),d=d.replace(/%.+$/,""));(O=d.indexOf(":",O+1))>=0;)A++;if(d.substr(0,2)==="::"&&A--,d.substr(-2,2)==="::"&&A--,A>g)return null;for(ae=g-A,P=":";ae--;)P+="0:";return d=d.replace("::",P),d[0]===":"&&(d=d.slice(1)),d[d.length-1]===":"&&(d=d.slice(0,-1)),g=function(){const Re=d.split(":"),He=[];for(let Te=0;Te<Re.length;Te++)He.push(parseInt(Re[Te],16));return He}(),{parts:g,zoneId:$}}function l(d,g,A,O){if(d.length!==g.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let $=0,P;for(;O>0;){if(P=A-O,P<0&&(P=0),d[$]>>P!==g[$]>>P)return!1;O-=A,$+=1}return!0}function h(d){if(i.test(d))return parseInt(d,16);if(d[0]==="0"&&!isNaN(parseInt(d[1],10))){if(s.test(d))return parseInt(d,8);throw new Error(`ipaddr: cannot parse ${d} as octal`)}return parseInt(d,10)}function R(d,g){for(;d.length<g;)d=`0${d}`;return d}const B={};B.IPv4=function(){function d(g){if(g.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,O;for(A=0;A<g.length;A++)if(O=g[A],!(0<=O&&O<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=g}return d.prototype.SpecialRanges={unspecified:[[new d([0,0,0,0]),8]],broadcast:[[new d([255,255,255,255]),32]],multicast:[[new d([224,0,0,0]),4]],linkLocal:[[new d([169,254,0,0]),16]],loopback:[[new d([127,0,0,0]),8]],carrierGradeNat:[[new d([100,64,0,0]),10]],private:[[new d([10,0,0,0]),8],[new d([172,16,0,0]),12],[new d([192,168,0,0]),16]],reserved:[[new d([192,0,0,0]),24],[new d([192,0,2,0]),24],[new d([192,88,99,0]),24],[new d([198,18,0,0]),15],[new d([198,51,100,0]),24],[new d([203,0,113,0]),24],[new d([240,0,0,0]),4]],as112:[[new d([192,175,48,0]),24],[new d([192,31,196,0]),24]],amt:[[new d([192,52,193,0]),24]]},d.prototype.kind=function(){return"ipv4"},d.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return l(this.octets,g.octets,8,A)},d.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let $,P,ae;for($=3;$>=0;$-=1)if(P=this.octets[$],P in O){if(ae=O[P],A&&ae!==0)return null;ae!==8&&(A=!0),g+=ae}else return null;return 32-g},d.prototype.range=function(){return B.subnetMatch(this,this.SpecialRanges)},d.prototype.toByteArray=function(){return this.octets.slice(0)},d.prototype.toIPv4MappedAddress=function(){return B.IPv6.parse(`::ffff:${this.toString()}`)},d.prototype.toNormalizedString=function(){return this.toString()},d.prototype.toString=function(){return this.octets.join(".")},d}(),B.IPv4.broadcastAddressFromCIDR=function(d){try{const g=this.parseCIDR(d),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),$=[];let P=0;for(;P<4;)$.push(parseInt(A[P],10)|parseInt(O[P],10)^255),P++;return new this($)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},B.IPv4.isIPv4=function(d){return this.parser(d)!==null},B.IPv4.isValid=function(d){try{return new this(this.parser(d)),!0}catch{return!1}},B.IPv4.isValidCIDR=function(d){try{return this.parseCIDR(d),!0}catch{return!1}},B.IPv4.isValidFourPartDecimal=function(d){return!!(B.IPv4.isValid(d)&&d.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},B.IPv4.networkAddressFromCIDR=function(d){let g,A,O,$,P;try{for(g=this.parseCIDR(d),O=g[0].toByteArray(),P=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),$=[],A=0;A<4;)$.push(parseInt(O[A],10)&parseInt(P[A],10)),A++;return new this($)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},B.IPv4.parse=function(d){const g=this.parser(d);if(g===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(g)},B.IPv4.parseCIDR=function(d){let g;if(g=d.match(/^(.+)\/(\d+)$/)){const A=parseInt(g[2]);if(A>=0&&A<=32){const O=[this.parse(g[1]),A];return Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},B.IPv4.parser=function(d){let g,A,O;if(g=d.match(n.fourOctet))return function(){const $=g.slice(1,6),P=[];for(let ae=0;ae<$.length;ae++)A=$[ae],P.push(h(A));return P}();if(g=d.match(n.longValue)){if(O=h(g[1]),O>4294967295||O<0)throw new Error("ipaddr: address outside defined range");return function(){const $=[];let P;for(P=0;P<=24;P+=8)$.push(O>>P&255);return $}().reverse()}else return(g=d.match(n.twoOctet))?function(){const $=g.slice(1,4),P=[];if(O=h($[1]),O>16777215||O<0)throw new Error("ipaddr: address outside defined range");return P.push(h($[0])),P.push(O>>16&255),P.push(O>>8&255),P.push(O&255),P}():(g=d.match(n.threeOctet))?function(){const $=g.slice(1,5),P=[];if(O=h($[2]),O>65535||O<0)throw new Error("ipaddr: address outside defined range");return P.push(h($[0])),P.push(h($[1])),P.push(O>>8&255),P.push(O&255),P}():null},B.IPv4.subnetMaskFromPrefixLength=function(d){if(d=parseInt(d),d<0||d>32)throw new Error("ipaddr: invalid IPv4 prefix length");const g=[0,0,0,0];let A=0;const O=Math.floor(d/8);for(;A<O;)g[A]=255,A++;return O<4&&(g[O]=Math.pow(2,d%8)-1<<8-d%8),new this(g)},B.IPv6=function(){function d(g,A){let O,$;if(g.length===16)for(this.parts=[],O=0;O<=14;O+=2)this.parts.push(g[O]<<8|g[O+1]);else if(g.length===8)this.parts=g;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(O=0;O<this.parts.length;O++)if($=this.parts[O],!(0<=$&&$<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");A&&(this.zoneId=A)}return d.prototype.SpecialRanges={unspecified:[new d([0,0,0,0,0,0,0,0]),128],linkLocal:[new d([65152,0,0,0,0,0,0,0]),10],multicast:[new d([65280,0,0,0,0,0,0,0]),8],loopback:[new d([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new d([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new d([0,0,0,0,0,65535,0,0]),96],discard:[new d([256,0,0,0,0,0,0,0]),64],rfc6145:[new d([0,0,0,0,65535,0,0,0]),96],rfc6052:[new d([100,65435,0,0,0,0,0,0]),96],"6to4":[new d([8194,0,0,0,0,0,0,0]),16],teredo:[new d([8193,0,0,0,0,0,0,0]),32],benchmarking:[new d([8193,2,0,0,0,0,0,0]),48],amt:[new d([8193,3,0,0,0,0,0,0]),32],as112v6:[[new d([8193,4,274,0,0,0,0,0]),48],[new d([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new d([8193,16,0,0,0,0,0,0]),28],orchid2:[new d([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new d([8193,48,0,0,0,0,0,0]),28],reserved:[[new d([8193,0,0,0,0,0,0,0]),23],[new d([8193,3512,0,0,0,0,0,0]),32]]},d.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},d.prototype.kind=function(){return"ipv6"},d.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return l(this.parts,g.parts,16,A)},d.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let $,P;for(let ae=7;ae>=0;ae-=1)if($=this.parts[ae],$ in O){if(P=O[$],A&&P!==0)return null;P!==16&&(A=!0),g+=P}else return null;return 128-g},d.prototype.range=function(){return B.subnetMatch(this,this.SpecialRanges)},d.prototype.toByteArray=function(){let g;const A=[],O=this.parts;for(let $=0;$<O.length;$++)g=O[$],A.push(g>>8),A.push(g&255);return A},d.prototype.toFixedLengthString=function(){const g=(function(){const O=[];for(let $=0;$<this.parts.length;$++)O.push(R(this.parts[$].toString(16),4));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},d.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const g=this.parts.slice(-2),A=g[0],O=g[1];return new B.IPv4([A>>8,A&255,O>>8,O&255])},d.prototype.toNormalizedString=function(){const g=(function(){const O=[];for(let $=0;$<this.parts.length;$++)O.push(this.parts[$].toString(16));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},d.prototype.toRFC5952String=function(){const g=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString();let O=0,$=-1,P;for(;P=g.exec(A);)P[0].length>$&&(O=P.index,$=P[0].length);return $<0?A:`${A.substring(0,O)}::${A.substring(O+$)}`},d.prototype.toString=function(){return this.toRFC5952String()},d}(),B.IPv6.broadcastAddressFromCIDR=function(d){try{const g=this.parseCIDR(d),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),$=[];let P=0;for(;P<16;)$.push(parseInt(A[P],10)|parseInt(O[P],10)^255),P++;return new this($)}catch(g){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${g})`)}},B.IPv6.isIPv6=function(d){return this.parser(d)!==null},B.IPv6.isValid=function(d){if(typeof d=="string"&&d.indexOf(":")===-1)return!1;try{const g=this.parser(d);return new this(g.parts,g.zoneId),!0}catch{return!1}},B.IPv6.isValidCIDR=function(d){if(typeof d=="string"&&d.indexOf(":")===-1)return!1;try{return this.parseCIDR(d),!0}catch{return!1}},B.IPv6.networkAddressFromCIDR=function(d){let g,A,O,$,P;try{for(g=this.parseCIDR(d),O=g[0].toByteArray(),P=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),$=[],A=0;A<16;)$.push(parseInt(O[A],10)&parseInt(P[A],10)),A++;return new this($)}catch(ae){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ae})`)}},B.IPv6.parse=function(d){const g=this.parser(d);if(g.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(g.parts,g.zoneId)},B.IPv6.parseCIDR=function(d){let g,A,O;if((A=d.match(/^(.+)\/(\d+)$/))&&(g=parseInt(A[2]),g>=0&&g<=128))return O=[this.parse(A[1]),g],Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},B.IPv6.parser=function(d){let g,A,O,$,P,ae;if(O=d.match(c.deprecatedTransitional))return this.parser(`::ffff:${O[1]}`);if(c.native.test(d))return u(d,8);if((O=d.match(c.transitional))&&(ae=O[6]||"",g=O[1],O[1].endsWith("::")||(g=g.slice(0,-1)),g=u(g+ae,6),g.parts)){for(P=[parseInt(O[2]),parseInt(O[3]),parseInt(O[4]),parseInt(O[5])],A=0;A<P.length;A++)if($=P[A],!(0<=$&&$<=255))return null;return g.parts.push(P[0]<<8|P[1]),g.parts.push(P[2]<<8|P[3]),{parts:g.parts,zoneId:g.zoneId}}return null},B.IPv6.subnetMaskFromPrefixLength=function(d){if(d=parseInt(d),d<0||d>128)throw new Error("ipaddr: invalid IPv6 prefix length");const g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let A=0;const O=Math.floor(d/8);for(;A<O;)g[A]=255,A++;return O<16&&(g[O]=Math.pow(2,d%8)-1<<8-d%8),new this(g)},B.fromByteArray=function(d){const g=d.length;if(g===4)return new B.IPv4(d);if(g===16)return new B.IPv6(d);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},B.isValid=function(d){return B.IPv6.isValid(d)||B.IPv4.isValid(d)},B.isValidCIDR=function(d){return B.IPv6.isValidCIDR(d)||B.IPv4.isValidCIDR(d)},B.parse=function(d){if(B.IPv6.isValid(d))return B.IPv6.parse(d);if(B.IPv4.isValid(d))return B.IPv4.parse(d);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},B.parseCIDR=function(d){try{return B.IPv6.parseCIDR(d)}catch{try{return B.IPv4.parseCIDR(d)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},B.process=function(d){const g=this.parse(d);return g.kind()==="ipv6"&&g.isIPv4MappedAddress()?g.toIPv4Address():g},B.subnetMatch=function(d,g,A){let O,$,P,ae;A==null&&(A="unicast");for($ in g)if(Object.prototype.hasOwnProperty.call(g,$)){for(P=g[$],P[0]&&!(P[0]instanceof Array)&&(P=[P]),O=0;O<P.length;O++)if(ae=P[O],d.kind()===ae[0].kind()&&d.match.apply(d,ae))return $}return A},r.exports?r.exports=B:e.ipaddr=B})(Lm)})(Y3);var N2=Y3.exports;class B2{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 N2.fromByteArray(Array.from(t)).toString()}return this.decodeIP(Ne.ToHex(e))}static fromString(e){const t=N2.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var Qb,e1,t1;let Or=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};p([_({type:Z.TeletexString})],Or.prototype,"teletexString",void 0);p([_({type:Z.PrintableString})],Or.prototype,"printableString",void 0);p([_({type:Z.UniversalString})],Or.prototype,"universalString",void 0);p([_({type:Z.Utf8String})],Or.prototype,"utf8String",void 0);p([_({type:Z.BmpString})],Or.prototype,"bmpString",void 0);Or=p([X({type:G.Choice})],Or);let Su=class extends Or{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?Ne.ToHex(this.anyValue):super.toString())}};p([_({type:Z.IA5String})],Su.prototype,"ia5String",void 0);p([_({type:Z.Any})],Su.prototype,"anyValue",void 0);Su=p([X({type:G.Choice})],Su);class dv{constructor(e={}){this.type="",this.value=new Su,Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],dv.prototype,"type",void 0);p([_({type:Su})],dv.prototype,"value",void 0);let Au=Qb=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,Qb.prototype)}};Au=Qb=p([X({type:G.Set,itemType:dv})],Au);let r1=e1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,e1.prototype)}};r1=e1=p([X({type:G.Sequence,itemType:Au})],r1);let pr=t1=class extends r1{constructor(e){super(e),Object.setPrototypeOf(this,t1.prototype)}};pr=t1=p([X({type:G.Sequence})],pr);const X9={fromASN:r=>B2.toString(Km.fromASN(r)),toASN:r=>Km.toASN(B2.fromString(r))};class ch{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],ch.prototype,"typeId",void 0);p([_({type:Z.Any,context:0})],ch.prototype,"value",void 0);class $x{constructor(e={}){this.partyName=new Or,Object.assign(this,e)}}p([_({type:Or,optional:!0,context:0,implicit:!0})],$x.prototype,"nameAssigner",void 0);p([_({type:Or,context:1,implicit:!0})],$x.prototype,"partyName",void 0);let dt=class{constructor(e={}){Object.assign(this,e)}};p([_({type:ch,context:0,implicit:!0})],dt.prototype,"otherName",void 0);p([_({type:Z.IA5String,context:1,implicit:!0})],dt.prototype,"rfc822Name",void 0);p([_({type:Z.IA5String,context:2,implicit:!0})],dt.prototype,"dNSName",void 0);p([_({type:Z.Any,context:3,implicit:!0})],dt.prototype,"x400Address",void 0);p([_({type:pr,context:4,implicit:!1})],dt.prototype,"directoryName",void 0);p([_({type:$x,context:5})],dt.prototype,"ediPartyName",void 0);p([_({type:Z.IA5String,context:6,implicit:!0})],dt.prototype,"uniformResourceIdentifier",void 0);p([_({type:Z.OctetString,context:7,implicit:!0,converter:X9})],dt.prototype,"iPAddress",void 0);p([_({type:Z.ObjectIdentifier,context:8,implicit:!0})],dt.prototype,"registeredID",void 0);dt=p([X({type:G.Choice})],dt);const Zx="1.3.6.1.5.5.7",Q9=`${Zx}.1`,ol=`${Zx}.3`,hv=`${Zx}.48`,R2=`${hv}.1`,P2=`${hv}.2`,$2=`${hv}.3`,Z2=`${hv}.5`,Ya="2.5.29";var n1;const s1=`${Q9}.1`;class Fp{constructor(e={}){this.accessMethod="",this.accessLocation=new dt,Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Fp.prototype,"accessMethod",void 0);p([_({type:dt})],Fp.prototype,"accessLocation",void 0);let Xc=n1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,n1.prototype)}};Xc=n1=p([X({type:G.Sequence,itemType:Fp})],Xc);const i1=`${Ya}.35`;class Dx extends qt{}class xo{constructor(e={}){e&&Object.assign(this,e)}}p([_({type:Dx,context:0,optional:!0,implicit:!0})],xo.prototype,"keyIdentifier",void 0);p([_({type:dt,context:1,optional:!0,implicit:!0,repeated:"sequence"})],xo.prototype,"authorityCertIssuer",void 0);p([_({type:Z.Integer,context:2,optional:!0,implicit:!0,converter:Yt})],xo.prototype,"authorityCertSerialNumber",void 0);const X3=`${Ya}.19`;class zm{constructor(e={}){this.cA=!1,Object.assign(this,e)}}p([_({type:Z.Boolean,defaultValue:!1})],zm.prototype,"cA",void 0);p([_({type:Z.Integer,optional:!0})],zm.prototype,"pathLenConstraint",void 0);var a1;let Mr=a1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,a1.prototype)}};Mr=a1=p([X({type:G.Sequence,itemType:dt})],Mr);var o1;let D2=o1=class extends Mr{constructor(e){super(e),Object.setPrototypeOf(this,o1.prototype)}};D2=o1=p([X({type:G.Sequence})],D2);var c1;const Q3=`${Ya}.32`;let Ci=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};p([_({type:Z.IA5String})],Ci.prototype,"ia5String",void 0);p([_({type:Z.VisibleString})],Ci.prototype,"visibleString",void 0);p([_({type:Z.BmpString})],Ci.prototype,"bmpString",void 0);p([_({type:Z.Utf8String})],Ci.prototype,"utf8String",void 0);Ci=p([X({type:G.Choice})],Ci);class Mx{constructor(e={}){this.organization=new Ci,this.noticeNumbers=[],Object.assign(this,e)}}p([_({type:Ci})],Mx.prototype,"organization",void 0);p([_({type:Z.Integer,repeated:"sequence"})],Mx.prototype,"noticeNumbers",void 0);class Ux{constructor(e={}){Object.assign(this,e)}}p([_({type:Mx,optional:!0})],Ux.prototype,"noticeRef",void 0);p([_({type:Ci,optional:!0})],Ux.prototype,"explicitText",void 0);let Wm=class{constructor(e={}){Object.assign(this,e)}};p([_({type:Z.IA5String})],Wm.prototype,"cPSuri",void 0);p([_({type:Ux})],Wm.prototype,"userNotice",void 0);Wm=p([X({type:G.Choice})],Wm);class Vx{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Vx.prototype,"policyQualifierId",void 0);p([_({type:Z.Any})],Vx.prototype,"qualifier",void 0);class pv{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],pv.prototype,"policyIdentifier",void 0);p([_({type:Vx,repeated:"sequence",optional:!0})],pv.prototype,"policyQualifiers",void 0);let Gm=c1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,c1.prototype)}};Gm=c1=p([X({type:G.Sequence,itemType:pv})],Gm);let Jm=class{constructor(e=0){this.value=e}};p([_({type:Z.Integer})],Jm.prototype,"value",void 0);Jm=p([X({type:G.Choice})],Jm);let M2=class extends Jm{};M2=p([X({type:G.Choice})],M2);var u1;const l1=`${Ya}.31`;var Xn;(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"})(Xn||(Xn={}));class eC extends lv{toJSON(){const e=[],t=this.toNumber();return t&Xn.aACompromise&&e.push("aACompromise"),t&Xn.affiliationChanged&&e.push("affiliationChanged"),t&Xn.cACompromise&&e.push("cACompromise"),t&Xn.certificateHold&&e.push("certificateHold"),t&Xn.cessationOfOperation&&e.push("cessationOfOperation"),t&Xn.keyCompromise&&e.push("keyCompromise"),t&Xn.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Xn.superseded&&e.push("superseded"),t&Xn.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let zo=class{constructor(e={}){Object.assign(this,e)}};p([_({type:dt,context:0,repeated:"sequence",implicit:!0})],zo.prototype,"fullName",void 0);p([_({type:Au,context:1,implicit:!0})],zo.prototype,"nameRelativeToCRLIssuer",void 0);zo=p([X({type:G.Choice})],zo);class cl{constructor(e={}){Object.assign(this,e)}}p([_({type:zo,context:0,optional:!0})],cl.prototype,"distributionPoint",void 0);p([_({type:eC,context:1,optional:!0,implicit:!0})],cl.prototype,"reasons",void 0);p([_({type:dt,context:2,optional:!0,repeated:"sequence",implicit:!0})],cl.prototype,"cRLIssuer",void 0);let iu=u1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,u1.prototype)}};iu=u1=p([X({type:G.Sequence,itemType:cl})],iu);var d1;let U2=d1=class extends iu{constructor(e){super(e),Object.setPrototypeOf(this,d1.prototype)}};U2=d1=p([X({type:G.Sequence,itemType:cl})],U2);class Tr{constructor(e={}){this.onlyContainsUserCerts=Tr.ONLY,this.onlyContainsCACerts=Tr.ONLY,this.indirectCRL=Tr.ONLY,this.onlyContainsAttributeCerts=Tr.ONLY,Object.assign(this,e)}}Tr.ONLY=!1;p([_({type:zo,context:0,optional:!0})],Tr.prototype,"distributionPoint",void 0);p([_({type:Z.Boolean,context:1,defaultValue:Tr.ONLY,implicit:!0})],Tr.prototype,"onlyContainsUserCerts",void 0);p([_({type:Z.Boolean,context:2,defaultValue:Tr.ONLY,implicit:!0})],Tr.prototype,"onlyContainsCACerts",void 0);p([_({type:eC,context:3,optional:!0,implicit:!0})],Tr.prototype,"onlySomeReasons",void 0);p([_({type:Z.Boolean,context:4,defaultValue:Tr.ONLY,implicit:!0})],Tr.prototype,"indirectCRL",void 0);p([_({type:Z.Boolean,context:5,defaultValue:Tr.ONLY,implicit:!0})],Tr.prototype,"onlyContainsAttributeCerts",void 0);var vd;(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"})(vd||(vd={}));let h1=class{constructor(e=vd.unspecified){this.reason=vd.unspecified,this.reason=e}toJSON(){return vd[this.reason]}toString(){return this.toJSON()}};p([_({type:Z.Enumerated})],h1.prototype,"reason",void 0);h1=p([X({type:G.Choice})],h1);var p1;const tC=`${Ya}.37`;let Ym=p1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,p1.prototype)}};Ym=p1=p([X({type:G.Sequence,itemType:Z.ObjectIdentifier})],Ym);const eB=`${ol}.1`,tB=`${ol}.2`,rB=`${ol}.3`,nB=`${ol}.4`,sB=`${ol}.8`,iB=`${ol}.9`;let f1=class{constructor(e=new ArrayBuffer(0)){this.value=e}};p([_({type:Z.Integer,converter:Yt})],f1.prototype,"value",void 0);f1=p([X({type:G.Choice})],f1);let m1=class{constructor(e){this.value=new Date,e&&(this.value=e)}};p([_({type:Z.GeneralizedTime})],m1.prototype,"value",void 0);m1=p([X({type:G.Choice})],m1);var y1;let V2=y1=class extends Mr{constructor(e){super(e),Object.setPrototypeOf(this,y1.prototype)}};V2=y1=p([X({type:G.Sequence})],V2);const rC=`${Ya}.15`;var Qn;(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"})(Qn||(Qn={}));class G0 extends lv{toJSON(){const e=this.toNumber(),t=[];return e&Qn.cRLSign&&t.push("crlSign"),e&Qn.dataEncipherment&&t.push("dataEncipherment"),e&Qn.decipherOnly&&t.push("decipherOnly"),e&Qn.digitalSignature&&t.push("digitalSignature"),e&Qn.encipherOnly&&t.push("encipherOnly"),e&Qn.keyAgreement&&t.push("keyAgreement"),e&Qn.keyCertSign&&t.push("keyCertSign"),e&Qn.keyEncipherment&&t.push("keyEncipherment"),e&Qn.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var g1;class fv{constructor(e={}){this.base=new dt,this.minimum=0,Object.assign(this,e)}}p([_({type:dt})],fv.prototype,"base",void 0);p([_({type:Z.Integer,context:0,defaultValue:0,implicit:!0})],fv.prototype,"minimum",void 0);p([_({type:Z.Integer,context:1,optional:!0,implicit:!0})],fv.prototype,"maximum",void 0);let Xm=g1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,g1.prototype)}};Xm=g1=p([X({type:G.Sequence,itemType:fv})],Xm);class nC{constructor(e={}){Object.assign(this,e)}}p([_({type:Xm,context:0,optional:!0,implicit:!0})],nC.prototype,"permittedSubtrees",void 0);p([_({type:Xm,context:1,optional:!0,implicit:!0})],nC.prototype,"excludedSubtrees",void 0);class sC{constructor(e={}){Object.assign(this,e)}}p([_({type:Z.Integer,context:0,implicit:!0,optional:!0,converter:Yt})],sC.prototype,"requireExplicitPolicy",void 0);p([_({type:Z.Integer,context:1,implicit:!0,optional:!0,converter:Yt})],sC.prototype,"inhibitPolicyMapping",void 0);var v1;class Lx{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Lx.prototype,"issuerDomainPolicy",void 0);p([_({type:Z.ObjectIdentifier})],Lx.prototype,"subjectDomainPolicy",void 0);let L2=v1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,v1.prototype)}};L2=v1=p([X({type:G.Sequence,itemType:Lx})],L2);var b1;const iC=`${Ya}.17`;let _1=b1=class extends Mr{constructor(e){super(e),Object.setPrototypeOf(this,b1.prototype)}};_1=b1=p([X({type:G.Sequence})],_1);let Ei=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};p([_({type:Z.ObjectIdentifier})],Ei.prototype,"type",void 0);p([_({type:Z.Any,repeated:"set"})],Ei.prototype,"values",void 0);var w1;let q2=w1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,w1.prototype)}};q2=w1=p([X({type:G.Sequence,itemType:Ei})],q2);const aC=`${Ya}.14`;class xa extends Dx{}class oC{constructor(e={}){Object.assign(this,e)}}p([_({type:Z.GeneralizedTime,context:0,implicit:!0,optional:!0})],oC.prototype,"notBefore",void 0);p([_({type:Z.GeneralizedTime,context:1,implicit:!0,optional:!0})],oC.prototype,"notAfter",void 0);var bd;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(bd||(bd={}));class cC extends lv{toJSON(){const e=[],t=this.toNumber();return t&bd.pKIXCertificate&&e.push("pKIXCertificate"),t&bd.newExtensions&&e.push("newExtensions"),t&bd.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class uC{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new cC,Object.assign(this,e)}}p([_({type:Z.GeneralString})],uC.prototype,"entrustVers",void 0);p([_({type:cC})],uC.prototype,"entrustInfoFlags",void 0);var x1;let H2=x1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,x1.prototype)}};H2=x1=p([X({type:G.Sequence,itemType:Fp})],H2);class je{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof je&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Gj(e.parameters,this.parameters)||e.parameters===this.parameters)}}p([_({type:Z.ObjectIdentifier})],je.prototype,"algorithm",void 0);p([_({type:Z.Any,optional:!0})],je.prototype,"parameters",void 0);class as{constructor(e={}){this.algorithm=new je,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:je})],as.prototype,"algorithm",void 0);p([_({type:Z.BitString})],as.prototype,"subjectPublicKey",void 0);let xr=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}};p([_({type:Z.UTCTime})],xr.prototype,"utcTime",void 0);p([_({type:Z.GeneralizedTime})],xr.prototype,"generalTime",void 0);xr=p([X({type:G.Choice})],xr);class Kp{constructor(e){this.notBefore=new xr(new Date),this.notAfter=new xr(new Date),e&&(this.notBefore=new xr(e.notBefore),this.notAfter=new xr(e.notAfter))}}p([_({type:xr})],Kp.prototype,"notBefore",void 0);p([_({type:xr})],Kp.prototype,"notAfter",void 0);var k1;let Un=class lC{constructor(e={}){this.extnID="",this.critical=lC.CRITICAL,this.extnValue=new qt,Object.assign(this,e)}};Un.CRITICAL=!1;p([_({type:Z.ObjectIdentifier})],Un.prototype,"extnID",void 0);p([_({type:Z.Boolean,defaultValue:Un.CRITICAL})],Un.prototype,"critical",void 0);p([_({type:qt})],Un.prototype,"extnValue",void 0);let Ia=k1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,k1.prototype)}};Ia=k1=p([X({type:G.Sequence,itemType:Un})],Ia);var Wo;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(Wo||(Wo={}));class An{constructor(e={}){this.version=Wo.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new je,this.issuer=new pr,this.validity=new Kp,this.subject=new pr,this.subjectPublicKeyInfo=new as,Object.assign(this,e)}}p([_({type:Z.Integer,context:0,defaultValue:Wo.v1})],An.prototype,"version",void 0);p([_({type:Z.Integer,converter:Yt})],An.prototype,"serialNumber",void 0);p([_({type:je})],An.prototype,"signature",void 0);p([_({type:pr})],An.prototype,"issuer",void 0);p([_({type:Kp})],An.prototype,"validity",void 0);p([_({type:pr})],An.prototype,"subject",void 0);p([_({type:as})],An.prototype,"subjectPublicKeyInfo",void 0);p([_({type:Z.BitString,context:1,implicit:!0,optional:!0})],An.prototype,"issuerUniqueID",void 0);p([_({type:Z.BitString,context:2,implicit:!0,optional:!0})],An.prototype,"subjectUniqueID",void 0);p([_({type:Ia,context:3,optional:!0})],An.prototype,"extensions",void 0);class Go{constructor(e={}){this.tbsCertificate=new An,this.signatureAlgorithm=new je,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:An})],Go.prototype,"tbsCertificate",void 0);p([_({type:je})],Go.prototype,"signatureAlgorithm",void 0);p([_({type:Z.BitString})],Go.prototype,"signatureValue",void 0);class mv{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new xr,Object.assign(this,e)}}p([_({type:Z.Integer,converter:Yt})],mv.prototype,"userCertificate",void 0);p([_({type:xr})],mv.prototype,"revocationDate",void 0);p([_({type:Un,optional:!0,repeated:"sequence"})],mv.prototype,"crlEntryExtensions",void 0);class Fi{constructor(e={}){this.signature=new je,this.issuer=new pr,this.thisUpdate=new xr,Object.assign(this,e)}}p([_({type:Z.Integer,optional:!0})],Fi.prototype,"version",void 0);p([_({type:je})],Fi.prototype,"signature",void 0);p([_({type:pr})],Fi.prototype,"issuer",void 0);p([_({type:xr})],Fi.prototype,"thisUpdate",void 0);p([_({type:xr,optional:!0})],Fi.prototype,"nextUpdate",void 0);p([_({type:mv,repeated:"sequence",optional:!0})],Fi.prototype,"revokedCertificates",void 0);p([_({type:Un,optional:!0,context:0,repeated:"sequence"})],Fi.prototype,"crlExtensions",void 0);class qx{constructor(e={}){this.tbsCertList=new Fi,this.signatureAlgorithm=new je,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Fi})],qx.prototype,"tbsCertList",void 0);p([_({type:je})],qx.prototype,"signatureAlgorithm",void 0);p([_({type:Z.BitString})],qx.prototype,"signature",void 0);class ul{constructor(e={}){this.issuer=new pr,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:pr})],ul.prototype,"issuer",void 0);p([_({type:Z.Integer,converter:Yt})],ul.prototype,"serialNumber",void 0);let Ou=class{constructor(e={}){Object.assign(this,e)}};p([_({type:xa,context:0,implicit:!0})],Ou.prototype,"subjectKeyIdentifier",void 0);p([_({type:ul})],Ou.prototype,"issuerAndSerialNumber",void 0);Ou=p([X({type:G.Choice})],Ou);var Ii;(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"})(Ii||(Ii={}));let uh=class extends je{};uh=p([X({type:G.Sequence})],uh);let Qm=class extends je{};Qm=p([X({type:G.Sequence})],Qm);let Ws=class extends je{};Ws=p([X({type:G.Sequence})],Ws);let ey=class extends je{};ey=p([X({type:G.Sequence})],ey);let F2=class extends je{};F2=p([X({type:G.Sequence})],F2);let S1=class extends je{};S1=p([X({type:G.Sequence})],S1);let ll=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};p([_({type:Z.ObjectIdentifier})],ll.prototype,"attrType",void 0);p([_({type:Z.Any,repeated:"set"})],ll.prototype,"attrValues",void 0);var A1;class si{constructor(e={}){this.version=Ii.v0,this.sid=new Ou,this.digestAlgorithm=new uh,this.signatureAlgorithm=new Qm,this.signature=new qt,Object.assign(this,e)}}p([_({type:Z.Integer})],si.prototype,"version",void 0);p([_({type:Ou})],si.prototype,"sid",void 0);p([_({type:uh})],si.prototype,"digestAlgorithm",void 0);p([_({type:ll,repeated:"set",context:0,implicit:!0,optional:!0})],si.prototype,"signedAttrs",void 0);p([_({type:Qm})],si.prototype,"signatureAlgorithm",void 0);p([_({type:qt})],si.prototype,"signature",void 0);p([_({type:ll,repeated:"set",context:1,implicit:!0,optional:!0})],si.prototype,"unsignedAttrs",void 0);let ty=A1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,A1.prototype)}};ty=A1=p([X({type:G.Set,itemType:si})],ty);let K2=class extends xr{};K2=p([X({type:G.Choice})],K2);let z2=class extends si{};z2=p([X({type:G.Sequence})],z2);class Hx{constructor(e={}){this.acIssuer=new dt,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}p([_({type:dt})],Hx.prototype,"acIssuer",void 0);p([_({type:Z.Integer})],Hx.prototype,"acSerial",void 0);p([_({type:Ei,repeated:"sequence"})],Hx.prototype,"attrs",void 0);var O1;let ry=O1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,O1.prototype)}};ry=O1=p([X({type:G.Sequence,itemType:Z.ObjectIdentifier})],ry);class yv{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}p([_({type:Z.Integer,optional:!0})],yv.prototype,"pathLenConstraint",void 0);p([_({type:ry,implicit:!0,context:0,optional:!0})],yv.prototype,"permittedAttrs",void 0);p([_({type:ry,implicit:!0,context:1,optional:!0})],yv.prototype,"excludedAttrs",void 0);p([_({type:Z.Boolean,defaultValue:!0})],yv.prototype,"permitUnSpecified",void 0);class kc{constructor(e={}){this.issuer=new Mr,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Mr})],kc.prototype,"issuer",void 0);p([_({type:Z.Integer,converter:Yt})],kc.prototype,"serial",void 0);p([_({type:Z.BitString,optional:!0})],kc.prototype,"issuerUID",void 0);var j1;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(j1||(j1={}));class Sc{constructor(e={}){this.digestedObjectType=j1.publicKey,this.digestAlgorithm=new je,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.Enumerated})],Sc.prototype,"digestedObjectType",void 0);p([_({type:Z.ObjectIdentifier,optional:!0})],Sc.prototype,"otherObjectTypeID",void 0);p([_({type:je})],Sc.prototype,"digestAlgorithm",void 0);p([_({type:Z.BitString})],Sc.prototype,"objectDigest",void 0);class gv{constructor(e={}){Object.assign(this,e)}}p([_({type:Mr,optional:!0})],gv.prototype,"issuerName",void 0);p([_({type:kc,context:0,implicit:!0,optional:!0})],gv.prototype,"baseCertificateID",void 0);p([_({type:Sc,context:1,implicit:!0,optional:!0})],gv.prototype,"objectDigestInfo",void 0);let ju=class{constructor(e={}){Object.assign(this,e)}};p([_({type:dt,repeated:"sequence"})],ju.prototype,"v1Form",void 0);p([_({type:gv,context:0,implicit:!0})],ju.prototype,"v2Form",void 0);ju=p([X({type:G.Choice})],ju);class vv{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}p([_({type:Z.GeneralizedTime})],vv.prototype,"notBeforeTime",void 0);p([_({type:Z.GeneralizedTime})],vv.prototype,"notAfterTime",void 0);class zp{constructor(e={}){Object.assign(this,e)}}p([_({type:kc,implicit:!0,context:0,optional:!0})],zp.prototype,"baseCertificateID",void 0);p([_({type:Mr,implicit:!0,context:1,optional:!0})],zp.prototype,"entityName",void 0);p([_({type:Sc,implicit:!0,context:2,optional:!0})],zp.prototype,"objectDigestInfo",void 0);var C1;(function(r){r[r.v2=1]="v2"})(C1||(C1={}));class Os{constructor(e={}){this.version=C1.v2,this.holder=new zp,this.issuer=new ju,this.signature=new je,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new vv,this.attributes=[],Object.assign(this,e)}}p([_({type:Z.Integer})],Os.prototype,"version",void 0);p([_({type:zp})],Os.prototype,"holder",void 0);p([_({type:ju})],Os.prototype,"issuer",void 0);p([_({type:je})],Os.prototype,"signature",void 0);p([_({type:Z.Integer,converter:Yt})],Os.prototype,"serialNumber",void 0);p([_({type:vv})],Os.prototype,"attrCertValidityPeriod",void 0);p([_({type:Ei,repeated:"sequence"})],Os.prototype,"attributes",void 0);p([_({type:Z.BitString,optional:!0})],Os.prototype,"issuerUniqueID",void 0);p([_({type:Ia,optional:!0})],Os.prototype,"extensions",void 0);class bv{constructor(e={}){this.acinfo=new Os,this.signatureAlgorithm=new je,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Os})],bv.prototype,"acinfo",void 0);p([_({type:je})],bv.prototype,"signatureAlgorithm",void 0);p([_({type:Z.BitString})],bv.prototype,"signatureValue",void 0);var ny;(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"})(ny||(ny={}));class E1 extends lv{}class Fx{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier,implicit:!0,context:0})],Fx.prototype,"type",void 0);p([_({type:Z.Any,implicit:!0,context:1})],Fx.prototype,"value",void 0);class Kx{constructor(e={}){this.policyId="",this.classList=new E1(ny.unclassified),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Kx.prototype,"policyId",void 0);p([_({type:E1,defaultValue:new E1(ny.unclassified)})],Kx.prototype,"classList",void 0);p([_({type:Fx,repeated:"set"})],Kx.prototype,"securityCategories",void 0);class _v{constructor(e={}){Object.assign(this,e)}}p([_({type:qt})],_v.prototype,"cotets",void 0);p([_({type:Z.ObjectIdentifier})],_v.prototype,"oid",void 0);p([_({type:Z.Utf8String})],_v.prototype,"string",void 0);class dC{constructor(e={}){this.values=[],Object.assign(this,e)}}p([_({type:Mr,implicit:!0,context:0,optional:!0})],dC.prototype,"policyAuthority",void 0);p([_({type:_v,repeated:"sequence"})],dC.prototype,"values",void 0);var I1;class wv{constructor(e={}){this.targetCertificate=new kc,Object.assign(this,e)}}p([_({type:kc})],wv.prototype,"targetCertificate",void 0);p([_({type:dt,optional:!0})],wv.prototype,"targetName",void 0);p([_({type:Sc,optional:!0})],wv.prototype,"certDigestInfo",void 0);let Cu=class{constructor(e={}){Object.assign(this,e)}};p([_({type:dt,context:0,implicit:!0})],Cu.prototype,"targetName",void 0);p([_({type:dt,context:1,implicit:!0})],Cu.prototype,"targetGroup",void 0);p([_({type:wv,context:2,implicit:!0})],Cu.prototype,"targetCert",void 0);Cu=p([X({type:G.Choice})],Cu);let T1=I1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,I1.prototype)}};T1=I1=p([X({type:G.Sequence,itemType:Cu})],T1);var N1;let W2=N1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,N1.prototype)}};W2=N1=p([X({type:G.Sequence,itemType:T1})],W2);class hC{constructor(e={}){Object.assign(this,e)}}p([_({type:Mr,implicit:!0,context:0,optional:!0})],hC.prototype,"roleAuthority",void 0);p([_({type:dt,implicit:!0,context:1})],hC.prototype,"roleName",void 0);class zx{constructor(e={}){this.service=new dt,this.ident=new dt,Object.assign(this,e)}}p([_({type:dt})],zx.prototype,"service",void 0);p([_({type:dt})],zx.prototype,"ident",void 0);p([_({type:qt,optional:!0})],zx.prototype,"authInfo",void 0);var B1;class Wx{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Wx.prototype,"otherCertFormat",void 0);p([_({type:Z.Any})],Wx.prototype,"otherCert",void 0);let Eu=class{constructor(e={}){Object.assign(this,e)}};p([_({type:Go})],Eu.prototype,"certificate",void 0);p([_({type:bv,context:2,implicit:!0})],Eu.prototype,"v2AttrCert",void 0);p([_({type:Wx,context:3,implicit:!0})],Eu.prototype,"other",void 0);Eu=p([X({type:G.Choice})],Eu);let sy=B1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,B1.prototype)}};sy=B1=p([X({type:G.Set,itemType:Eu})],sy);class dl{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],dl.prototype,"contentType",void 0);p([_({type:Z.Any,context:0})],dl.prototype,"content",void 0);let lh=class{constructor(e={}){Object.assign(this,e)}};p([_({type:qt})],lh.prototype,"single",void 0);p([_({type:Z.Any})],lh.prototype,"any",void 0);lh=p([X({type:G.Choice})],lh);class xv{constructor(e={}){this.eContentType="",Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],xv.prototype,"eContentType",void 0);p([_({type:lh,context:0,optional:!0})],xv.prototype,"eContent",void 0);let dh=class{constructor(e={}){Object.assign(this,e)}};p([_({type:qt,context:0,implicit:!0,optional:!0})],dh.prototype,"value",void 0);p([_({type:qt,converter:R9,context:0,implicit:!0,optional:!0,repeated:"sequence"})],dh.prototype,"constructedValue",void 0);dh=p([X({type:G.Choice})],dh);class Wp{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new ey,Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Wp.prototype,"contentType",void 0);p([_({type:ey})],Wp.prototype,"contentEncryptionAlgorithm",void 0);p([_({type:dh,optional:!0})],Wp.prototype,"encryptedContent",void 0);class kv{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],kv.prototype,"keyAttrId",void 0);p([_({type:Z.Any,optional:!0})],kv.prototype,"keyAttr",void 0);var R1;class Sv{constructor(e={}){this.subjectKeyIdentifier=new xa,Object.assign(this,e)}}p([_({type:xa})],Sv.prototype,"subjectKeyIdentifier",void 0);p([_({type:Z.GeneralizedTime,optional:!0})],Sv.prototype,"date",void 0);p([_({type:kv,optional:!0})],Sv.prototype,"other",void 0);let Iu=class{constructor(e={}){Object.assign(this,e)}};p([_({type:Sv,context:0,implicit:!0,optional:!0})],Iu.prototype,"rKeyId",void 0);p([_({type:ul,optional:!0})],Iu.prototype,"issuerAndSerialNumber",void 0);Iu=p([X({type:G.Choice})],Iu);class Gx{constructor(e={}){this.rid=new Iu,this.encryptedKey=new qt,Object.assign(this,e)}}p([_({type:Iu})],Gx.prototype,"rid",void 0);p([_({type:qt})],Gx.prototype,"encryptedKey",void 0);let iy=R1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,R1.prototype)}};iy=R1=p([X({type:G.Sequence,itemType:Gx})],iy);class Jx{constructor(e={}){this.algorithm=new je,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:je})],Jx.prototype,"algorithm",void 0);p([_({type:Z.BitString})],Jx.prototype,"publicKey",void 0);let Jo=class{constructor(e={}){Object.assign(this,e)}};p([_({type:xa,context:0,implicit:!0,optional:!0})],Jo.prototype,"subjectKeyIdentifier",void 0);p([_({type:Jx,context:1,implicit:!0,optional:!0})],Jo.prototype,"originatorKey",void 0);p([_({type:ul,optional:!0})],Jo.prototype,"issuerAndSerialNumber",void 0);Jo=p([X({type:G.Choice})],Jo);class hl{constructor(e={}){this.version=Ii.v3,this.originator=new Jo,this.keyEncryptionAlgorithm=new Ws,this.recipientEncryptedKeys=new iy,Object.assign(this,e)}}p([_({type:Z.Integer})],hl.prototype,"version",void 0);p([_({type:Jo,context:0})],hl.prototype,"originator",void 0);p([_({type:qt,context:1,optional:!0})],hl.prototype,"ukm",void 0);p([_({type:Ws})],hl.prototype,"keyEncryptionAlgorithm",void 0);p([_({type:iy})],hl.prototype,"recipientEncryptedKeys",void 0);let Tu=class{constructor(e={}){Object.assign(this,e)}};p([_({type:xa,context:0,implicit:!0})],Tu.prototype,"subjectKeyIdentifier",void 0);p([_({type:ul})],Tu.prototype,"issuerAndSerialNumber",void 0);Tu=p([X({type:G.Choice})],Tu);class Gp{constructor(e={}){this.version=Ii.v0,this.rid=new Tu,this.keyEncryptionAlgorithm=new Ws,this.encryptedKey=new qt,Object.assign(this,e)}}p([_({type:Z.Integer})],Gp.prototype,"version",void 0);p([_({type:Tu})],Gp.prototype,"rid",void 0);p([_({type:Ws})],Gp.prototype,"keyEncryptionAlgorithm",void 0);p([_({type:qt})],Gp.prototype,"encryptedKey",void 0);class Jp{constructor(e={}){this.keyIdentifier=new qt,Object.assign(this,e)}}p([_({type:qt})],Jp.prototype,"keyIdentifier",void 0);p([_({type:Z.GeneralizedTime,optional:!0})],Jp.prototype,"date",void 0);p([_({type:kv,optional:!0})],Jp.prototype,"other",void 0);class Yp{constructor(e={}){this.version=Ii.v4,this.kekid=new Jp,this.keyEncryptionAlgorithm=new Ws,this.encryptedKey=new qt,Object.assign(this,e)}}p([_({type:Z.Integer})],Yp.prototype,"version",void 0);p([_({type:Jp})],Yp.prototype,"kekid",void 0);p([_({type:Ws})],Yp.prototype,"keyEncryptionAlgorithm",void 0);p([_({type:qt})],Yp.prototype,"encryptedKey",void 0);class Xp{constructor(e={}){this.version=Ii.v0,this.keyEncryptionAlgorithm=new Ws,this.encryptedKey=new qt,Object.assign(this,e)}}p([_({type:Z.Integer})],Xp.prototype,"version",void 0);p([_({type:S1,context:0,optional:!0})],Xp.prototype,"keyDerivationAlgorithm",void 0);p([_({type:Ws})],Xp.prototype,"keyEncryptionAlgorithm",void 0);p([_({type:qt})],Xp.prototype,"encryptedKey",void 0);class Yx{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Yx.prototype,"oriType",void 0);p([_({type:Z.Any})],Yx.prototype,"oriValue",void 0);let Ta=class{constructor(e={}){Object.assign(this,e)}};p([_({type:Gp,optional:!0})],Ta.prototype,"ktri",void 0);p([_({type:hl,context:1,implicit:!0,optional:!0})],Ta.prototype,"kari",void 0);p([_({type:Yp,context:2,implicit:!0,optional:!0})],Ta.prototype,"kekri",void 0);p([_({type:Xp,context:3,implicit:!0,optional:!0})],Ta.prototype,"pwri",void 0);p([_({type:Yx,context:4,implicit:!0,optional:!0})],Ta.prototype,"ori",void 0);Ta=p([X({type:G.Choice})],Ta);var P1;let ay=P1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,P1.prototype)}};ay=P1=p([X({type:G.Set,itemType:Ta})],ay);var $1;class Av{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Av.prototype,"otherRevInfoFormat",void 0);p([_({type:Z.Any})],Av.prototype,"otherRevInfo",void 0);let oy=class{constructor(e={}){this.other=new Av,Object.assign(this,e)}};p([_({type:Av,context:1,implicit:!0})],oy.prototype,"other",void 0);oy=p([X({type:G.Choice})],oy);let cy=$1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,$1.prototype)}};cy=$1=p([X({type:G.Set,itemType:oy})],cy);class Xx{constructor(e={}){Object.assign(this,e)}}p([_({type:sy,context:0,implicit:!0,optional:!0})],Xx.prototype,"certs",void 0);p([_({type:cy,context:1,implicit:!0,optional:!0})],Xx.prototype,"crls",void 0);var Z1;let D1=Z1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,Z1.prototype)}};D1=Z1=p([X({type:G.Set,itemType:ll})],D1);class Qp{constructor(e={}){this.version=Ii.v0,this.recipientInfos=new ay,this.encryptedContentInfo=new Wp,Object.assign(this,e)}}p([_({type:Z.Integer})],Qp.prototype,"version",void 0);p([_({type:Xx,context:0,implicit:!0,optional:!0})],Qp.prototype,"originatorInfo",void 0);p([_({type:ay})],Qp.prototype,"recipientInfos",void 0);p([_({type:Wp})],Qp.prototype,"encryptedContentInfo",void 0);p([_({type:D1,context:1,implicit:!0,optional:!0})],Qp.prototype,"unprotectedAttrs",void 0);const aB="1.2.840.113549.1.7.2";var M1;let uy=M1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,M1.prototype)}};uy=M1=p([X({type:G.Set,itemType:uh})],uy);class pl{constructor(e={}){this.version=Ii.v0,this.digestAlgorithms=new uy,this.encapContentInfo=new xv,this.signerInfos=new ty,Object.assign(this,e)}}p([_({type:Z.Integer})],pl.prototype,"version",void 0);p([_({type:uy})],pl.prototype,"digestAlgorithms",void 0);p([_({type:xv})],pl.prototype,"encapContentInfo",void 0);p([_({type:sy,context:0,implicit:!0,optional:!0})],pl.prototype,"certificates",void 0);p([_({type:cy,context:1,implicit:!0,optional:!0})],pl.prototype,"crls",void 0);p([_({type:ty})],pl.prototype,"signerInfos",void 0);const hh="1.2.840.10045.2.1",Qx="1.2.840.10045.4.1",pC="1.2.840.10045.4.3.1",ek="1.2.840.10045.4.3.2",tk="1.2.840.10045.4.3.3",rk="1.2.840.10045.4.3.4",G2="1.2.840.10045.3.1.7",J2="1.3.132.0.34",Y2="1.3.132.0.35";function ef(r){return new je({algorithm:r})}const oB=ef(Qx);ef(pC);const cB=ef(ek),uB=ef(tk),lB=ef(rk);let ph=class{constructor(e={}){Object.assign(this,e)}};p([_({type:Z.ObjectIdentifier})],ph.prototype,"fieldType",void 0);p([_({type:Z.Any})],ph.prototype,"parameters",void 0);ph=p([X({type:G.Sequence})],ph);class dB extends qt{}let Nu=class{constructor(e={}){Object.assign(this,e)}};p([_({type:Z.OctetString})],Nu.prototype,"a",void 0);p([_({type:Z.OctetString})],Nu.prototype,"b",void 0);p([_({type:Z.BitString,optional:!0})],Nu.prototype,"seed",void 0);Nu=p([X({type:G.Sequence})],Nu);var U1;(function(r){r[r.ecpVer1=1]="ecpVer1"})(U1||(U1={}));let Ti=class{constructor(e={}){this.version=U1.ecpVer1,Object.assign(this,e)}};p([_({type:Z.Integer})],Ti.prototype,"version",void 0);p([_({type:ph})],Ti.prototype,"fieldID",void 0);p([_({type:Nu})],Ti.prototype,"curve",void 0);p([_({type:dB})],Ti.prototype,"base",void 0);p([_({type:Z.Integer,converter:Yt})],Ti.prototype,"order",void 0);p([_({type:Z.Integer,optional:!0})],Ti.prototype,"cofactor",void 0);Ti=p([X({type:G.Sequence})],Ti);let Na=class{constructor(e={}){Object.assign(this,e)}};p([_({type:Z.ObjectIdentifier})],Na.prototype,"namedCurve",void 0);p([_({type:Z.Null})],Na.prototype,"implicitCurve",void 0);p([_({type:Ti})],Na.prototype,"specifiedCurve",void 0);Na=p([X({type:G.Choice})],Na);class Ov{constructor(e={}){this.version=1,this.privateKey=new qt,Object.assign(this,e)}}p([_({type:Z.Integer})],Ov.prototype,"version",void 0);p([_({type:qt})],Ov.prototype,"privateKey",void 0);p([_({type:Na,context:0,optional:!0})],Ov.prototype,"parameters",void 0);p([_({type:Z.BitString,context:1,optional:!0})],Ov.prototype,"publicKey",void 0);class ly{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.Integer,converter:Yt})],ly.prototype,"r",void 0);p([_({type:Z.Integer,converter:Yt})],ly.prototype,"s",void 0);const ln="1.2.840.113549.1.1",Yo=`${ln}.1`,hB=`${ln}.7`,pB=`${ln}.9`,_d=`${ln}.10`,fB=`${ln}.2`,mB=`${ln}.4`,dy=`${ln}.5`,yB=`${ln}.14`,V1=`${ln}.11`,hy=`${ln}.12`,py=`${ln}.13`,fC=`${ln}.15`,mC=`${ln}.16`,fy="1.3.14.3.2.26",yC="2.16.840.1.101.3.4.2.4",my="2.16.840.1.101.3.4.2.1",yy="2.16.840.1.101.3.4.2.2",gy="2.16.840.1.101.3.4.2.3",gB="2.16.840.1.101.3.4.2.5",vB="2.16.840.1.101.3.4.2.6",bB="1.2.840.113549.2.2",_B="1.2.840.113549.2.5",jv=`${ln}.8`;function vr(r){return new je({algorithm:r,parameters:null})}vr(bB);vr(_B);const Xo=vr(fy);vr(yC);vr(my);vr(yy);vr(gy);vr(gB);vr(vB);const gC=new je({algorithm:jv,parameters:oe.serialize(Xo)}),vC=new je({algorithm:pB,parameters:oe.serialize(Km.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});vr(Yo);vr(fB);vr(mB);vr(dy);vr(fC);vr(mC);vr(hy);vr(py);vr(fC);vr(mC);class Cv{constructor(e={}){this.hashAlgorithm=new je(Xo),this.maskGenAlgorithm=new je({algorithm:jv,parameters:oe.serialize(Xo)}),this.pSourceAlgorithm=new je(vC),Object.assign(this,e)}}p([_({type:je,context:0,defaultValue:Xo})],Cv.prototype,"hashAlgorithm",void 0);p([_({type:je,context:1,defaultValue:gC})],Cv.prototype,"maskGenAlgorithm",void 0);p([_({type:je,context:2,defaultValue:vC})],Cv.prototype,"pSourceAlgorithm",void 0);new je({algorithm:hB,parameters:oe.serialize(new Cv)});class Qo{constructor(e={}){this.hashAlgorithm=new je(Xo),this.maskGenAlgorithm=new je({algorithm:jv,parameters:oe.serialize(Xo)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}p([_({type:je,context:0,defaultValue:Xo})],Qo.prototype,"hashAlgorithm",void 0);p([_({type:je,context:1,defaultValue:gC})],Qo.prototype,"maskGenAlgorithm",void 0);p([_({type:Z.Integer,context:2,defaultValue:20})],Qo.prototype,"saltLength",void 0);p([_({type:Z.Integer,context:3,defaultValue:1})],Qo.prototype,"trailerField",void 0);new je({algorithm:_d,parameters:oe.serialize(new Qo)});class Ev{constructor(e={}){this.digestAlgorithm=new je,this.digest=new qt,Object.assign(this,e)}}p([_({type:je})],Ev.prototype,"digestAlgorithm",void 0);p([_({type:qt})],Ev.prototype,"digest",void 0);var L1;class Iv{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.Integer,converter:Yt})],Iv.prototype,"prime",void 0);p([_({type:Z.Integer,converter:Yt})],Iv.prototype,"exponent",void 0);p([_({type:Z.Integer,converter:Yt})],Iv.prototype,"coefficient",void 0);let q1=L1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,L1.prototype)}};q1=L1=p([X({type:G.Sequence,itemType:Iv})],q1);class ii{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)}}p([_({type:Z.Integer})],ii.prototype,"version",void 0);p([_({type:Z.Integer,converter:Yt})],ii.prototype,"modulus",void 0);p([_({type:Z.Integer,converter:Yt})],ii.prototype,"publicExponent",void 0);p([_({type:Z.Integer,converter:Yt})],ii.prototype,"privateExponent",void 0);p([_({type:Z.Integer,converter:Yt})],ii.prototype,"prime1",void 0);p([_({type:Z.Integer,converter:Yt})],ii.prototype,"prime2",void 0);p([_({type:Z.Integer,converter:Yt})],ii.prototype,"exponent1",void 0);p([_({type:Z.Integer,converter:Yt})],ii.prototype,"exponent2",void 0);p([_({type:Z.Integer,converter:Yt})],ii.prototype,"coefficient",void 0);p([_({type:q1,optional:!0})],ii.prototype,"otherPrimeInfos",void 0);class nk{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.Integer,converter:Yt})],nk.prototype,"modulus",void 0);p([_({type:Z.Integer,converter:Yt})],nk.prototype,"publicExponent",void 0);var H1;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(H1||(H1={}));const Gr=H1;/*! *****************************************************************************
79
+ `)}`:`${t} :`}}zy=Ct;X.Constructed=zy;Ct.NAME="CONSTRUCTED";class Gy extends St{fromBER(e,t,n){return t}toBER(e){return pr}}Gy.override="EndOfContentValueBlock";var Jy;class bf extends ft{constructor(e={}){super(e,Gy),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Jy=bf;X.EndOfContent=Jy;bf.NAME=va;var Yy;class ii extends ft{constructor(e={}){super(e,St),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const i=new Uint8Array(n);i[0]=5,i[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}Yy=ii;X.Null=Yy;ii.NAME="NULL";class Xy extends jr(St){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=q.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const i=q.toUint8Array(e);return Qr(this,i,t,n)?(this.valueHexView=i.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Uy.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Xy.NAME="BooleanValueBlock";var Qy;let ou=class extends ft{constructor(e={}){super(e,Xy),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Qy=ou;X.Boolean=Qy;ou.NAME="BOOLEAN";class eg extends jr(mn){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=mn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===va){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Vy)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?mn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}eg.NAME="OctetStringValueBlock";var tg;let Jn=class rg extends ft{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},eg),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const a=us(s,0,s.byteLength);a.offset!==-1&&a.offset===n&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ct.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${te.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof rg&&e.push(t.valueBlock.valueHexView);return q.concat(e)}};tg=Jn;X.OctetString=tg;Jn.NAME=Vy;class ng extends jr(mn){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let i=-1;if(this.isConstructed){if(i=mn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(const o of this.value){const c=o.constructor.NAME;if(c===va){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ly)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=o.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return i}const s=q.toUint8Array(e);if(!Qr(this,s,t,n))return-1;const a=s.subarray(t,t+n);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const o=a.subarray(1);try{if(o.byteLength){const c=us(o,0,o.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,t+n}toBER(e,t){if(this.isConstructed)return mn.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return pr;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}ng.NAME="BitStringValueBlock";var ig;let Yn=class extends ft{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},ng),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ct.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const i of t)e.push(i.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};ig=Yn;X.BitString=ig;Yn.NAME=Ly;var sg;function xw(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),i=new Uint8Array(e);let s=n.slice(0);const a=s.length-1,o=i.slice(0),c=o.length-1;let u=0;const f=c<a?a:c;let m=0;for(let B=f;B>=0;B--,m++){switch(!0){case m<o.length:u=s[a-m]+o[c-m]+t[0];break;default:u=s[a-m]+t[0]}switch(t[0]=u/10,!0){case m>=s.length:s=$l(new Uint8Array([u%10]),s);break;default:s[a-m]=u%10}}return t[0]>0&&(s=$l(t,s)),s}function $h(r){if(r>=Ss.length)for(let e=Ss.length;e<=r;e++){const t=new Uint8Array([0]);let n=Ss[e-1].slice(0);for(let i=n.length-1;i>=0;i--){const s=new Uint8Array([(n[i]<<1)+t[0]]);t[0]=s[0]/10,n[i]=s[0]%10}t[0]>0&&(n=$l(t,n)),Ss.push(n)}return Ss[r]}function _w(r,e){let t=0;const n=new Uint8Array(r),i=new Uint8Array(e),s=n.slice(0),a=s.length-1,o=i.slice(0),c=o.length-1;let u,f=0;for(let m=c;m>=0;m--,f++)switch(u=s[a-f]-o[c-f]-t,!0){case u<0:t=1,s[a-f]=u+10;break;default:t=0,s[a-f]=u}if(t>0)for(let m=a-c+1;m>=0;m--,f++)if(u=s[a-f]-t,u<0)t=1,s[a-f]=u+10;else{t=0,s[a-f]=u;break}return s.slice()}class xf extends jr(St){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Uy.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(cw(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,i=0){const s=this.fromBER(e,t,n);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){const i=super.fromBER(e,t,n);return i===-1||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),n=0,i;const s=this.valueHexView;let a="",o=!1;for(let c=s.byteLength-1;c>=0;c--){i=s[c];for(let u=0;u<8;u++){if((i&1)===1)switch(n){case e:t=_w($h(n),t),a="-";break;default:t=xw(t,$h(n))}n++,i>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Rh.charAt(t[c]));return o===!1&&(a+=Rh.charAt(0)),a}}sg=xf;xf.NAME="IntegerValueBlock";Object.defineProperty(sg.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var ag;class wr extends ft{constructor(e={}){super(e,xf),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return fc(),BigInt(this.valueBlock.toString())}static fromBigInt(e){fc();const t=BigInt(e),n=new su,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(te.FromHex(i));if(t<0){const o=new Uint8Array(s.length+(s[0]&128?1:0));o[0]|=128;const u=BigInt(`0x${te.ToHex(o)}`)+t,f=q.toUint8Array(te.FromHex(u.toString(16)));f[0]|=128,n.write(f)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new wr({valueHex:n.final()})}convertToDER(){const e=new wr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new wr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}ag=wr;X.Integer=ag;wr.NAME="INTEGER";var og;class cu extends wr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}og=cu;X.Enumerated=og;cu.NAME="ENUMERATED";class Dl extends jr(St){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=s[o]&127,this.blockLength++,!!(s[o]&128));o++);const a=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength;o++)a[o]=this.valueHexView[o];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Wi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){fc();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(t.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ni(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",pr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=te.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}Dl.NAME="sidBlock";class cg extends St{constructor({value:e=It,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Dl;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,pr;t.push(i)}return gf(t)}fromString(e){this.value=[];let t=0,n=0,i="",s=!1;do if(n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1,s){const a=this.value[0];let o=0;switch(a.valueDec){case 0:break;case 1:o=40;break;case 2:o=80;break;default:this.value=[];return}const c=parseInt(i,10);if(isNaN(c))return;a.valueDec=c+o,s=!1}else{const a=new Dl;if(i>Number.MAX_SAFE_INTEGER){fc();const o=BigInt(i);a.valueBigInt=o}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t?(i=`{${i}}`,this.value[n].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}cg.NAME="ObjectIdentifierValueBlock";var ug;class uu extends ft{constructor(e={}){super(e,cg),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}ug=uu;X.ObjectIdentifier=ug;uu.NAME="OBJECT IDENTIFIER";class Zl extends jr(gi){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const i=q.toUint8Array(e);if(!Qr(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let o=0;o<n&&(this.valueHexView[o]=s[o]&127,this.blockLength++,!!(s[o]&128));o++);const a=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength;o++)a[o]=this.valueHexView[o];return this.valueHexView=a,s[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Wi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ni(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",pr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let a=0;a<s;a++)n[a]=i[a]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=te.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Zl.NAME="relativeSidBlock";class lg extends St{constructor({value:e=It,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Zl;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,t){const n=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,pr;n.push(s)}return gf(n)}fromString(e){this.value=[];let t=0,n=0,i="";do{n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1;const s=new Zl;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(i=`{${i}}`),e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}lg.NAME="RelativeObjectIdentifierValueBlock";var dg;class _f extends ft{constructor(e={}){super(e,lg),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}dg=_f;X.RelativeObjectIdentifier=dg;_f.NAME="RelativeObjectIdentifier";var fg;class Lr extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}fg=Lr;X.Sequence=fg;Lr.NAME="SEQUENCE";var hg;let qr=class extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};hg=qr;X.Set=hg;qr.NAME="SET";class pg extends jr(St){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=It}toJSON(){return{...super.toJSON(),value:this.value}}}pg.NAME="StringValueBlock";class mg extends pg{}mg.NAME="SimpleStringValueBlock";class Mt extends vf{constructor({...e}={}){super(e,mg)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,q.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}}Mt.NAME="SIMPLE STRING";class yg extends Mt{fromBuffer(e){this.valueBlock.valueHexView=q.toUint8Array(e);try{this.valueBlock.value=te.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=te.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(te.FromUtf8String(e)),this.valueBlock.value=e}}yg.NAME="Utf8StringValueBlock";var gg;class en extends yg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}gg=en;X.Utf8String=gg;en.NAME="UTF8String";class vg extends Mt{fromBuffer(e){this.valueBlock.value=te.ToUtf16String(e),this.valueBlock.valueHexView=q.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(te.FromUtf16String(e))}}vg.NAME="BmpStringValueBlock";var bg;class lu extends vg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}bg=lu;X.BmpString=bg;lu.NAME="BMPString";class xg extends Mt{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let i=0;i<t;i++){const s=ni(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;const o=4-a.length;for(let c=a.length-1;c>=0;c--)n[i*4+c+o]=a[c]}this.valueBlock.value=e}}xg.NAME="UniversalStringValueBlock";var _g;class du extends xg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}_g=du;X.UniversalString=_g;du.NAME="UniversalString";var wg;class fu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}wg=fu;X.NumericString=wg;fu.NAME="NumericString";var kg;class hu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}kg=hu;X.PrintableString=kg;hu.NAME="PrintableString";var Sg;class pu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Sg=pu;X.TeletexString=Sg;pu.NAME="TeletexString";var Ag;class mu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Ag=mu;X.VideotexString=Ag;mu.NAME="VideotexString";var Og;class yu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Og=yu;X.IA5String=Og;yu.NAME="IA5String";var Eg;class gu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Eg=gu;X.GraphicString=Eg;gu.NAME="GraphicString";var Ig;class Qa extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Ig=Qa;X.VisibleString=Ig;Qa.NAME="VisibleString";var Cg;class vu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Cg=vu;X.GeneralString=Cg;vu.NAME="GeneralString";var jg;class bu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}jg=bu;X.CharacterString=jg;bu.NAME="CharacterString";var Tg;class eo extends Qa{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,q.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=Pt(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Pt(this.month,2),t[2]=Pt(this.day,2),t[3]=Pt(this.hour,2),t[4]=Pt(this.minute,2),t[5]=Pt(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Tg=eo;X.UTCTime=Tg;eo.NAME="UTCTime";var Ng;class xu extends eo{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",i="",s=0,a,o=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const m=new Number(e[e.length-1]);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let m=1,B=n.indexOf("+"),C="";if(B===-1&&(B=n.indexOf("-"),m=-1),B!==-1){if(C=n.substring(B+1),n=n.substring(0,B),C.length!==2&&C.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(C.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(o=m*p,C.length===4){if(p=parseInt(C.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=m*p}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){const m=new Number(`0${n.substring(u)}`);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");s=m.valueOf(),i=n.substring(0,u)}else i=n;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*s;this.minute=Math.floor(m),m=60*(m-this.minute),this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*s;this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const m=1e3*s;this.millisecond=Math.floor(m)}break;default:throw new Error("Wrong input string for conversion")}const f=a.exec(i);if(f===null)throw new Error("Wrong input string for conversion");for(let m=1;m<f.length;m++)switch(m){case 1:this.year=parseInt(f[m],10);break;case 2:this.month=parseInt(f[m],10);break;case 3:this.day=parseInt(f[m],10);break;case 4:this.hour=parseInt(f[m],10)+o;break;case 5:this.minute=parseInt(f[m],10)+c;break;case 6:this.second=parseInt(f[m],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const m=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=m.getUTCFullYear(),this.month=m.getUTCMonth(),this.day=m.getUTCDay(),this.hour=m.getUTCHours(),this.minute=m.getUTCMinutes(),this.second=m.getUTCSeconds(),this.millisecond=m.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(Pt(this.year,4)),t.push(Pt(this.month,2)),t.push(Pt(this.day,2)),t.push(Pt(this.hour,2)),t.push(Pt(this.minute,2)),t.push(Pt(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Pt(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Ng=xu;X.GeneralizedTime=Ng;xu.NAME="GeneralizedTime";var Bg;class wf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Bg=wf;X.DATE=Bg;wf.NAME="DATE";var Rg;class kf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Rg=kf;X.TimeOfDay=Rg;kf.NAME="TimeOfDay";var Pg;class Sf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Pg=Sf;X.DateTime=Pg;Sf.NAME="DateTime";var $g;class Af extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}$g=Af;X.Duration=$g;Af.NAME="Duration";var Dg;class Of extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Dg=Of;X.TIME=Dg;Of.NAME="TIME";class si{constructor({name:e=It,optional:t=!1}={}){this.name=e,this.optional=t}}class Ef extends si{constructor({value:e=[],...t}={}){super(t),this.value=e}}class hc extends si{constructor({value:e=new si,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class ww{constructor({data:e=au}={}){this.dataView=q.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=q.toUint8Array(e)}fromBER(e,t,n){const i=t+n;return this.dataView=q.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}}function Vn(r,e,t){if(t instanceof Ef){for(let s=0;s<t.value.length;s++)if(Vn(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(il)&&(s.name=t.name),s}}if(t instanceof si)return t.hasOwnProperty(il)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(dw in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(mw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(yw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(fw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(hw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(pw)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(lw in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(Ph in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:r};for(let o=0;o<s.length;o++)if(s[o]!==a[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(r[t.name]=e)),t instanceof X.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},o=t.valueBlock.value.length;if(o>0&&t.valueBlock.value[0]instanceof hc&&(o=e.valueBlock.value.length),o===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let c=!0;for(let u=0;u<t.valueBlock.value.length;u++)c=c&&(t.valueBlock.value[u].optional||!1);return c?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let c=0;c<o;c++)if(c-s>=e.valueBlock.value.length){if(t.valueBlock.value[c].optional===!1){const u={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof hc){if(a=Vn(r,e.valueBlock.value[c],t.valueBlock.value[0].value),a.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),a;if(il in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};gw in t.valueBlock.value[0]&&t.valueBlock.value[0].local?u=e:u=r,typeof u[t.valueBlock.value[0].name]>"u"&&(u[t.valueBlock.value[0].name]=[]),u[t.valueBlock.value[0].name].push(e.valueBlock.value[c])}}else if(a=Vn(r,e.valueBlock.value[c-s],t.valueBlock.value[c]),a.verified===!1)if(t.valueBlock.value[c].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&delete r[t.name]),a;if(a.verified===!1){const c={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&Ph in e.valueBlock){const s=us(e.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,It),t.name&&(delete r[t.name],a.name=t.name)),a}return Vn(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function kw(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=us(q.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Vn(t.result,t.result,e)}const Zg=Object.freeze(Object.defineProperty({__proto__:null,Any:si,BaseBlock:ft,BaseStringBlock:vf,BitString:Yn,BmpString:lu,Boolean:ou,CharacterString:bu,Choice:Ef,Constructed:Ct,DATE:wf,DateTime:Sf,Duration:Af,EndOfContent:bf,Enumerated:cu,GeneralString:vu,GeneralizedTime:xu,GraphicString:gu,HexBlock:jr,IA5String:yu,Integer:wr,Null:ii,NumericString:fu,ObjectIdentifier:uu,OctetString:Jn,Primitive:Xa,PrintableString:hu,RawData:ww,RelativeObjectIdentifier:_f,Repeated:hc,Sequence:Lr,Set:qr,TIME:Of,TeletexString:pu,TimeOfDay:kf,UTCTime:eo,UniversalString:du,Utf8String:en,ValueBlock:St,VideotexString:mu,ViewWriter:su,VisibleString:Qa,compareSchema:Vn,fromBER:Bi,verifySchema:kw},Symbol.toStringTag,{value:"Module"}));var R;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(R||(R={}));var v;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(v||(v={}));class _u{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(q.isBufferSource(e))this.unusedBits=t,this.value=q.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Yn))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new Yn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Yn({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;const i=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class De{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):q.isBufferSource(e)?this.buffer=q.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Jn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Jn({valueHex:this.buffer})}toSchema(e){return new Jn({name:e})}}const Sw={fromASN:r=>r instanceof ii?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ii;const e=Bi(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Aw={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new wr({value:+r})},Ow={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new cu({value:r})},Ke={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new wr({valueHex:r})},Ew={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Yn({valueHex:r})},Iw={fromASN:r=>r.valueBlock.toString(),toASN:r=>new uu({value:r})},Cw={fromASN:r=>r.valueBlock.value,toASN:r=>new ou({value:r})},pc={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Jn({valueHex:r})},jw={fromASN:r=>new De(r.getValue()),toASN:r=>r.toASN()};function zt(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Mg=zt(en),Tw=zt(lu),Nw=zt(du),Bw=zt(fu),Rw=zt(hu),Pw=zt(pu),$w=zt(mu),Dw=zt(yu),Zw=zt(gu),Mw=zt(Qa),Uw=zt(vu),Vw=zt(bu),Lw={fromASN:r=>r.toDate(),toASN:r=>new eo({valueDate:r})},qw={fromASN:r=>r.toDate(),toASN:r=>new xu({valueDate:r})},Hw={fromASN:()=>null,toASN:()=>new ii};function If(r){switch(r){case v.Any:return Sw;case v.BitString:return Ew;case v.BmpString:return Tw;case v.Boolean:return Cw;case v.CharacterString:return Vw;case v.Enumerated:return Ow;case v.GeneralString:return Uw;case v.GeneralizedTime:return qw;case v.GraphicString:return Zw;case v.IA5String:return Dw;case v.Integer:return Aw;case v.Null:return Hw;case v.NumericString:return Bw;case v.ObjectIdentifier:return Iw;case v.OctetString:return pc;case v.PrintableString:return Rw;case v.TeletexString:return Pw;case v.UTCTime:return Lw;case v.UniversalString:return Nw;case v.Utf8String:return Mg;case v.VideotexString:return $w;case v.VisibleString:return Mw;default:return null}}function Vr(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Vr(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Ug(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Ug(t)}return!1}function Fw(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}class Kw{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:R.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),i=[];for(const s in n.items){const a=n.items[s],o=t?s:"";let c;if(typeof a.type=="number"){const f=v[a.type],m=Zg[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else Vr(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===R.Choice?c=new si({name:o}):(c=this.create(a.type,!1),c.name=o):c=new si({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const f=a.repeated==="set"?qr:Lr;c=new f({name:"",value:[new hc({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Vr(a.type)){const f=a.repeated?Ct:Xa;i.push(new f({name:o,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const f=!!a.repeated;let m=f?c:this.get(a.type,!0).schema;m="valueBlock"in m?m.valueBlock.value:m.value,i.push(new Ct({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else i.push(new Ct({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,i.push(c)}switch(n.type){case R.Sequence:return new Lr({value:i,name:""});case R.Set:return new qr({value:i,name:""});case R.Choice:return new Ef({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const qt=new Kw,$=r=>e=>{let t;qt.has(e)?t=qt.get(e):(t=qt.createDefault(e),qt.set(e,t)),Object.assign(t,r)},h=r=>(e,t)=>{let n;qt.has(e.constructor)?n=qt.get(e.constructor):(n=qt.createDefault(e.constructor),qt.set(e.constructor,n));const i=Object.assign({},r);if(typeof i.type=="number"&&!i.converter){const s=If(r.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);i.converter=s}n.items[t]=i};class Dh extends Error{constructor(){super(...arguments),this.schemas=[]}}class Ww{static parse(e,t){const n=Bi(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){var n;try{if(Vr(t))return new t().fromASN(e);const i=qt.get(t);qt.cache(t);let s=i.schema;if(e.constructor===Ct&&i.type!==R.Choice){s=new Ct({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const c in i.items)delete e[c]}const a=Vn({},e,s);if(!a.verified)throw new Dh(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(Ug(t)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const c=i.itemType;if(typeof c=="number"){const u=If(c);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,f=>u.fromASN(f))}else return t.from(e.valueBlock.value,u=>this.fromASN(u,c))}for(const c in i.items){const u=a.result[c];if(!u)continue;const f=i.items[c],m=f.type;if(typeof m=="number"||Vr(m)){const B=(n=f.converter)!==null&&n!==void 0?n:Vr(m)?new m:null;if(!B)throw new Error("Converter is empty");if(f.repeated)if(f.implicit){const C=f.repeated==="sequence"?Lr:qr,p=new C;p.valueBlock=u.valueBlock;const g=Bi(p.toBER(!1));if(g.offset===-1)throw new Error(`Cannot parse the child item. ${g.result.error}`);if(!("value"in g.result.valueBlock&&Array.isArray(g.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const A=g.result.valueBlock.value;o[c]=Array.from(A,O=>B.fromASN(O))}else o[c]=Array.from(u,C=>B.fromASN(C));else{let C=u;if(f.implicit){let p;if(Vr(m))p=new m().toSchema("");else{const g=v[m],A=Zg[g];if(!A)throw new Error(`Cannot get '${g}' class from asn1js module`);p=new A}p.valueBlock=C.valueBlock,C=Bi(p.toBER(!1)).result}o[c]=B.fromASN(C)}}else if(f.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");o[c]=Array.from(u,B=>this.fromASN(B,m))}else o[c]=this.fromASN(u,m)}return o}catch(i){throw i instanceof Dh&&i.schemas.push(t.name),i}}}class Cf{static serialize(e){return e instanceof ft?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Vr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=qt.get(t);qt.cache(t);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const a=If(n.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);i=e.map(o=>a.toASN(o))}else i=e.map(a=>this.toAsnItem({type:n.itemType},"[]",t,a))}else for(const a in n.items){const o=n.items[a],c=e[a];if(c===void 0||o.defaultValue===c||typeof o.defaultValue=="object"&&typeof c=="object"&&Fw(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=Cf.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||Vr(o.type))){const f={};f.valueHex=u instanceof ii?u.valueBeforeDecodeView:u.valueBlock.toBER(),i.push(new Xa({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else i.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else i.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else o.repeated?i=i.concat(u):i.push(u)}let s;switch(n.type){case R.Sequence:s=new Lr({value:i});break;case R.Set:s=new qr({value:i});break;case R.Choice:if(!i[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,t,n,i){let s;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${t}' doesn't have converter for type ${v[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,u=>a.toASN(u)),c=e.repeated==="sequence"?Lr:qr;s=new c({value:o})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(i,c=>this.toASN(c)),o=e.repeated==="sequence"?Lr:qr;s=new o({value:a})}else s=this.toASN(i);return s}}class Ve extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class L{static serialize(e){return Cf.serialize(e)}static parse(e,t){return Ww.parse(e,t)}static toString(e){const t=q.isBufferSource(e)?q.toArrayBuffer(e):L.serialize(e),n=Bi(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function l(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(s=(i<3?a(s):i>3?a(e,t,s):a(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}var Vg={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${t}\\.${t}\\.${t}\\.${t}(${a})?$`,"i")};function u(p,g){if(p.indexOf("::")!==p.lastIndexOf("::"))return null;let A=0,O=-1,P=(p.match(c.zoneIndex)||[])[0],N,xe;for(P&&(P=P.substring(1),p=p.replace(/%.+$/,""));(O=p.indexOf(":",O+1))>=0;)A++;if(p.substr(0,2)==="::"&&A--,p.substr(-2,2)==="::"&&A--,A>g)return null;for(xe=g-A,N=":";xe--;)N+="0:";return p=p.replace("::",N),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),g=function(){const Le=p.split(":"),qe=[];for(let Ze=0;Ze<Le.length;Ze++)qe.push(parseInt(Le[Ze],16));return qe}(),{parts:g,zoneId:P}}function f(p,g,A,O){if(p.length!==g.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let P=0,N;for(;O>0;){if(N=A-O,N<0&&(N=0),p[P]>>N!==g[P]>>N)return!1;O-=A,P+=1}return!0}function m(p){if(s.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(i.test(p))return parseInt(p,8);throw new Error(`ipaddr: cannot parse ${p} as octal`)}return parseInt(p,10)}function B(p,g){for(;p.length<g;)p=`0${p}`;return p}const C={};C.IPv4=function(){function p(g){if(g.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,O;for(A=0;A<g.length;A++)if(O=g[A],!(0<=O&&O<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=g}return p.prototype.SpecialRanges={unspecified:[[new p([0,0,0,0]),8]],broadcast:[[new p([255,255,255,255]),32]],multicast:[[new p([224,0,0,0]),4]],linkLocal:[[new p([169,254,0,0]),16]],loopback:[[new p([127,0,0,0]),8]],carrierGradeNat:[[new p([100,64,0,0]),10]],private:[[new p([10,0,0,0]),8],[new p([172,16,0,0]),12],[new p([192,168,0,0]),16]],reserved:[[new p([192,0,0,0]),24],[new p([192,0,2,0]),24],[new p([192,88,99,0]),24],[new p([198,18,0,0]),15],[new p([198,51,100,0]),24],[new p([203,0,113,0]),24],[new p([240,0,0,0]),4]],as112:[[new p([192,175,48,0]),24],[new p([192,31,196,0]),24]],amt:[[new p([192,52,193,0]),24]]},p.prototype.kind=function(){return"ipv4"},p.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,g.octets,8,A)},p.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let P,N,xe;for(P=3;P>=0;P-=1)if(N=this.octets[P],N in O){if(xe=O[N],A&&xe!==0)return null;xe!==8&&(A=!0),g+=xe}else return null;return 32-g},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){return this.octets.slice(0)},p.prototype.toIPv4MappedAddress=function(){return C.IPv6.parse(`::ffff:${this.toString()}`)},p.prototype.toNormalizedString=function(){return this.toString()},p.prototype.toString=function(){return this.octets.join(".")},p}(),C.IPv4.broadcastAddressFromCIDR=function(p){try{const g=this.parseCIDR(p),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[];let N=0;for(;N<4;)P.push(parseInt(A[N],10)|parseInt(O[N],10)^255),N++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},C.IPv4.isIPv4=function(p){return this.parser(p)!==null},C.IPv4.isValid=function(p){try{return new this(this.parser(p)),!0}catch{return!1}},C.IPv4.isValidCIDR=function(p){try{return this.parseCIDR(p),!0}catch{return!1}},C.IPv4.isValidFourPartDecimal=function(p){return!!(C.IPv4.isValid(p)&&p.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},C.IPv4.networkAddressFromCIDR=function(p){let g,A,O,P,N;try{for(g=this.parseCIDR(p),O=g[0].toByteArray(),N=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[],A=0;A<4;)P.push(parseInt(O[A],10)&parseInt(N[A],10)),A++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},C.IPv4.parse=function(p){const g=this.parser(p);if(g===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(g)},C.IPv4.parseCIDR=function(p){let g;if(g=p.match(/^(.+)\/(\d+)$/)){const A=parseInt(g[2]);if(A>=0&&A<=32){const O=[this.parse(g[1]),A];return Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},C.IPv4.parser=function(p){let g,A,O;if(g=p.match(n.fourOctet))return function(){const P=g.slice(1,6),N=[];for(let xe=0;xe<P.length;xe++)A=P[xe],N.push(m(A));return N}();if(g=p.match(n.longValue)){if(O=m(g[1]),O>4294967295||O<0)throw new Error("ipaddr: address outside defined range");return function(){const P=[];let N;for(N=0;N<=24;N+=8)P.push(O>>N&255);return P}().reverse()}else return(g=p.match(n.twoOctet))?function(){const P=g.slice(1,4),N=[];if(O=m(P[1]),O>16777215||O<0)throw new Error("ipaddr: address outside defined range");return N.push(m(P[0])),N.push(O>>16&255),N.push(O>>8&255),N.push(O&255),N}():(g=p.match(n.threeOctet))?function(){const P=g.slice(1,5),N=[];if(O=m(P[2]),O>65535||O<0)throw new Error("ipaddr: address outside defined range");return N.push(m(P[0])),N.push(m(P[1])),N.push(O>>8&255),N.push(O&255),N}():null},C.IPv4.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>32)throw new Error("ipaddr: invalid IPv4 prefix length");const g=[0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)g[A]=255,A++;return O<4&&(g[O]=Math.pow(2,p%8)-1<<8-p%8),new this(g)},C.IPv6=function(){function p(g,A){let O,P;if(g.length===16)for(this.parts=[],O=0;O<=14;O+=2)this.parts.push(g[O]<<8|g[O+1]);else if(g.length===8)this.parts=g;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(O=0;O<this.parts.length;O++)if(P=this.parts[O],!(0<=P&&P<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");A&&(this.zoneId=A)}return p.prototype.SpecialRanges={unspecified:[new p([0,0,0,0,0,0,0,0]),128],linkLocal:[new p([65152,0,0,0,0,0,0,0]),10],multicast:[new p([65280,0,0,0,0,0,0,0]),8],loopback:[new p([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new p([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new p([0,0,0,0,0,65535,0,0]),96],discard:[new p([256,0,0,0,0,0,0,0]),64],rfc6145:[new p([0,0,0,0,65535,0,0,0]),96],rfc6052:[new p([100,65435,0,0,0,0,0,0]),96],"6to4":[new p([8194,0,0,0,0,0,0,0]),16],teredo:[new p([8193,0,0,0,0,0,0,0]),32],benchmarking:[new p([8193,2,0,0,0,0,0,0]),48],amt:[new p([8193,3,0,0,0,0,0,0]),32],as112v6:[[new p([8193,4,274,0,0,0,0,0]),48],[new p([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new p([8193,16,0,0,0,0,0,0]),28],orchid2:[new p([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new p([8193,48,0,0,0,0,0,0]),28],reserved:[[new p([8193,0,0,0,0,0,0,0]),23],[new p([8193,3512,0,0,0,0,0,0]),32]]},p.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},p.prototype.kind=function(){return"ipv6"},p.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,g.parts,16,A)},p.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let P,N;for(let xe=7;xe>=0;xe-=1)if(P=this.parts[xe],P in O){if(N=O[P],A&&N!==0)return null;N!==16&&(A=!0),g+=N}else return null;return 128-g},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let g;const A=[],O=this.parts;for(let P=0;P<O.length;P++)g=O[P],A.push(g>>8),A.push(g&255);return A},p.prototype.toFixedLengthString=function(){const g=(function(){const O=[];for(let P=0;P<this.parts.length;P++)O.push(B(this.parts[P].toString(16),4));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},p.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const g=this.parts.slice(-2),A=g[0],O=g[1];return new C.IPv4([A>>8,A&255,O>>8,O&255])},p.prototype.toNormalizedString=function(){const g=(function(){const O=[];for(let P=0;P<this.parts.length;P++)O.push(this.parts[P].toString(16));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},p.prototype.toRFC5952String=function(){const g=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString();let O=0,P=-1,N;for(;N=g.exec(A);)N[0].length>P&&(O=N.index,P=N[0].length);return P<0?A:`${A.substring(0,O)}::${A.substring(O+P)}`},p.prototype.toString=function(){return this.toRFC5952String()},p}(),C.IPv6.broadcastAddressFromCIDR=function(p){try{const g=this.parseCIDR(p),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[];let N=0;for(;N<16;)P.push(parseInt(A[N],10)|parseInt(O[N],10)^255),N++;return new this(P)}catch(g){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${g})`)}},C.IPv6.isIPv6=function(p){return this.parser(p)!==null},C.IPv6.isValid=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{const g=this.parser(p);return new this(g.parts,g.zoneId),!0}catch{return!1}},C.IPv6.isValidCIDR=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{return this.parseCIDR(p),!0}catch{return!1}},C.IPv6.networkAddressFromCIDR=function(p){let g,A,O,P,N;try{for(g=this.parseCIDR(p),O=g[0].toByteArray(),N=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),P=[],A=0;A<16;)P.push(parseInt(O[A],10)&parseInt(N[A],10)),A++;return new this(P)}catch(xe){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${xe})`)}},C.IPv6.parse=function(p){const g=this.parser(p);if(g.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(g.parts,g.zoneId)},C.IPv6.parseCIDR=function(p){let g,A,O;if((A=p.match(/^(.+)\/(\d+)$/))&&(g=parseInt(A[2]),g>=0&&g<=128))return O=[this.parse(A[1]),g],Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},C.IPv6.parser=function(p){let g,A,O,P,N,xe;if(O=p.match(c.deprecatedTransitional))return this.parser(`::ffff:${O[1]}`);if(c.native.test(p))return u(p,8);if((O=p.match(c.transitional))&&(xe=O[6]||"",g=O[1],O[1].endsWith("::")||(g=g.slice(0,-1)),g=u(g+xe,6),g.parts)){for(N=[parseInt(O[2]),parseInt(O[3]),parseInt(O[4]),parseInt(O[5])],A=0;A<N.length;A++)if(P=N[A],!(0<=P&&P<=255))return null;return g.parts.push(N[0]<<8|N[1]),g.parts.push(N[2]<<8|N[3]),{parts:g.parts,zoneId:g.zoneId}}return null},C.IPv6.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>128)throw new Error("ipaddr: invalid IPv6 prefix length");const g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)g[A]=255,A++;return O<16&&(g[O]=Math.pow(2,p%8)-1<<8-p%8),new this(g)},C.fromByteArray=function(p){const g=p.length;if(g===4)return new C.IPv4(p);if(g===16)return new C.IPv6(p);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},C.isValid=function(p){return C.IPv6.isValid(p)||C.IPv4.isValid(p)},C.isValidCIDR=function(p){return C.IPv6.isValidCIDR(p)||C.IPv4.isValidCIDR(p)},C.parse=function(p){if(C.IPv6.isValid(p))return C.IPv6.parse(p);if(C.IPv4.isValid(p))return C.IPv4.parse(p);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},C.parseCIDR=function(p){try{return C.IPv6.parseCIDR(p)}catch{try{return C.IPv4.parseCIDR(p)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},C.process=function(p){const g=this.parse(p);return g.kind()==="ipv6"&&g.isIPv4MappedAddress()?g.toIPv4Address():g},C.subnetMatch=function(p,g,A){let O,P,N,xe;A==null&&(A="unicast");for(P in g)if(Object.prototype.hasOwnProperty.call(g,P)){for(N=g[P],N[0]&&!(N[0]instanceof Array)&&(N=[N]),O=0;O<N.length;O++)if(xe=N[O],p.kind()===xe[0].kind()&&p.match.apply(p,xe))return P}return A},r.exports?r.exports=C:e.ipaddr=C})(lc)})(Vg);var Zh=Vg.exports;class Mh{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return Zh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(te.ToHex(e))}static fromString(e){const t=Zh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var Ml,Ul,Vl;let ht=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};l([h({type:v.TeletexString})],ht.prototype,"teletexString",void 0);l([h({type:v.PrintableString})],ht.prototype,"printableString",void 0);l([h({type:v.UniversalString})],ht.prototype,"universalString",void 0);l([h({type:v.Utf8String})],ht.prototype,"utf8String",void 0);l([h({type:v.BmpString})],ht.prototype,"bmpString",void 0);ht=l([$({type:R.Choice})],ht);let zi=class extends ht{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?te.ToHex(this.anyValue):super.toString())}};l([h({type:v.IA5String})],zi.prototype,"ia5String",void 0);l([h({type:v.Any})],zi.prototype,"anyValue",void 0);zi=l([$({type:R.Choice})],zi);class wu{constructor(e={}){this.type="",this.value=new zi,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],wu.prototype,"type",void 0);l([h({type:zi})],wu.prototype,"value",void 0);let Gi=Ml=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ml.prototype)}};Gi=Ml=l([$({type:R.Set,itemType:wu})],Gi);let Ll=Ul=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ul.prototype)}};Ll=Ul=l([$({type:R.Sequence,itemType:Gi})],Ll);let et=Vl=class extends Ll{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};et=Vl=l([$({type:R.Sequence})],et);const zw={fromASN:r=>Mh.toString(pc.fromASN(r)),toASN:r=>pc.toASN(Mh.fromString(r))};class ba{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],ba.prototype,"typeId",void 0);l([h({type:v.Any,context:0})],ba.prototype,"value",void 0);class jf{constructor(e={}){this.partyName=new ht,Object.assign(this,e)}}l([h({type:ht,optional:!0,context:0,implicit:!0})],jf.prototype,"nameAssigner",void 0);l([h({type:ht,context:1,implicit:!0})],jf.prototype,"partyName",void 0);let be=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ba,context:0,implicit:!0})],be.prototype,"otherName",void 0);l([h({type:v.IA5String,context:1,implicit:!0})],be.prototype,"rfc822Name",void 0);l([h({type:v.IA5String,context:2,implicit:!0})],be.prototype,"dNSName",void 0);l([h({type:v.Any,context:3,implicit:!0})],be.prototype,"x400Address",void 0);l([h({type:et,context:4,implicit:!1})],be.prototype,"directoryName",void 0);l([h({type:jf,context:5})],be.prototype,"ediPartyName",void 0);l([h({type:v.IA5String,context:6,implicit:!0})],be.prototype,"uniformResourceIdentifier",void 0);l([h({type:v.OctetString,context:7,implicit:!0,converter:zw})],be.prototype,"iPAddress",void 0);l([h({type:v.ObjectIdentifier,context:8,implicit:!0})],be.prototype,"registeredID",void 0);be=l([$({type:R.Choice})],be);const Tf="1.3.6.1.5.5.7",Gw=`${Tf}.1`,ls=`${Tf}.3`,ku=`${Tf}.48`,Uh=`${ku}.1`,Vh=`${ku}.2`,Lh=`${ku}.3`,qh=`${ku}.5`,Tn="2.5.29";var ql;const Hl=`${Gw}.1`;class to{constructor(e={}){this.accessMethod="",this.accessLocation=new be,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],to.prototype,"accessMethod",void 0);l([h({type:be})],to.prototype,"accessLocation",void 0);let Ii=ql=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,ql.prototype)}};Ii=ql=l([$({type:R.Sequence,itemType:to})],Ii);const Fl=`${Tn}.35`;class Nf extends De{}class Ln{constructor(e={}){e&&Object.assign(this,e)}}l([h({type:Nf,context:0,optional:!0,implicit:!0})],Ln.prototype,"keyIdentifier",void 0);l([h({type:be,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Ln.prototype,"authorityCertIssuer",void 0);l([h({type:v.Integer,context:2,optional:!0,implicit:!0,converter:Ke})],Ln.prototype,"authorityCertSerialNumber",void 0);const Lg=`${Tn}.19`;class mc{constructor(e={}){this.cA=!1,Object.assign(this,e)}}l([h({type:v.Boolean,defaultValue:!1})],mc.prototype,"cA",void 0);l([h({type:v.Integer,optional:!0})],mc.prototype,"pathLenConstraint",void 0);var Kl;let xt=Kl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};xt=Kl=l([$({type:R.Sequence,itemType:be})],xt);var Wl;let Hh=Wl=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,Wl.prototype)}};Hh=Wl=l([$({type:R.Sequence})],Hh);var zl;const qg=`${Tn}.32`;let Kr=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};l([h({type:v.IA5String})],Kr.prototype,"ia5String",void 0);l([h({type:v.VisibleString})],Kr.prototype,"visibleString",void 0);l([h({type:v.BmpString})],Kr.prototype,"bmpString",void 0);l([h({type:v.Utf8String})],Kr.prototype,"utf8String",void 0);Kr=l([$({type:R.Choice})],Kr);class Bf{constructor(e={}){this.organization=new Kr,this.noticeNumbers=[],Object.assign(this,e)}}l([h({type:Kr})],Bf.prototype,"organization",void 0);l([h({type:v.Integer,repeated:"sequence"})],Bf.prototype,"noticeNumbers",void 0);class Rf{constructor(e={}){Object.assign(this,e)}}l([h({type:Bf,optional:!0})],Rf.prototype,"noticeRef",void 0);l([h({type:Kr,optional:!0})],Rf.prototype,"explicitText",void 0);let yc=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.IA5String})],yc.prototype,"cPSuri",void 0);l([h({type:Rf})],yc.prototype,"userNotice",void 0);yc=l([$({type:R.Choice})],yc);class Pf{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Pf.prototype,"policyQualifierId",void 0);l([h({type:v.Any})],Pf.prototype,"qualifier",void 0);class Su{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Su.prototype,"policyIdentifier",void 0);l([h({type:Pf,repeated:"sequence",optional:!0})],Su.prototype,"policyQualifiers",void 0);let gc=zl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};gc=zl=l([$({type:R.Sequence,itemType:Su})],gc);let vc=class{constructor(e=0){this.value=e}};l([h({type:v.Integer})],vc.prototype,"value",void 0);vc=l([$({type:R.Choice})],vc);let Fh=class extends vc{};Fh=l([$({type:R.Choice})],Fh);var Gl;const Jl=`${Tn}.31`;var Qt;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Qt||(Qt={}));class Hg extends _u{toJSON(){const e=[],t=this.toNumber();return t&Qt.aACompromise&&e.push("aACompromise"),t&Qt.affiliationChanged&&e.push("affiliationChanged"),t&Qt.cACompromise&&e.push("cACompromise"),t&Qt.certificateHold&&e.push("certificateHold"),t&Qt.cessationOfOperation&&e.push("cessationOfOperation"),t&Qt.keyCompromise&&e.push("keyCompromise"),t&Qt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Qt.superseded&&e.push("superseded"),t&Qt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let ai=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,context:0,repeated:"sequence",implicit:!0})],ai.prototype,"fullName",void 0);l([h({type:Gi,context:1,implicit:!0})],ai.prototype,"nameRelativeToCRLIssuer",void 0);ai=l([$({type:R.Choice})],ai);class ds{constructor(e={}){Object.assign(this,e)}}l([h({type:ai,context:0,optional:!0})],ds.prototype,"distributionPoint",void 0);l([h({type:Hg,context:1,optional:!0,implicit:!0})],ds.prototype,"reasons",void 0);l([h({type:be,context:2,optional:!0,repeated:"sequence",implicit:!0})],ds.prototype,"cRLIssuer",void 0);let Ri=Gl=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Gl.prototype)}};Ri=Gl=l([$({type:R.Sequence,itemType:ds})],Ri);var Yl;let Kh=Yl=class extends Ri{constructor(e){super(e),Object.setPrototypeOf(this,Yl.prototype)}};Kh=Yl=l([$({type:R.Sequence,itemType:ds})],Kh);class yt{constructor(e={}){this.onlyContainsUserCerts=yt.ONLY,this.onlyContainsCACerts=yt.ONLY,this.indirectCRL=yt.ONLY,this.onlyContainsAttributeCerts=yt.ONLY,Object.assign(this,e)}}yt.ONLY=!1;l([h({type:ai,context:0,optional:!0})],yt.prototype,"distributionPoint",void 0);l([h({type:v.Boolean,context:1,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsUserCerts",void 0);l([h({type:v.Boolean,context:2,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsCACerts",void 0);l([h({type:Hg,context:3,optional:!0,implicit:!0})],yt.prototype,"onlySomeReasons",void 0);l([h({type:v.Boolean,context:4,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"indirectCRL",void 0);l([h({type:v.Boolean,context:5,defaultValue:yt.ONLY,implicit:!0})],yt.prototype,"onlyContainsAttributeCerts",void 0);var Zs;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Zs||(Zs={}));let Xl=class{constructor(e=Zs.unspecified){this.reason=Zs.unspecified,this.reason=e}toJSON(){return Zs[this.reason]}toString(){return this.toJSON()}};l([h({type:v.Enumerated})],Xl.prototype,"reason",void 0);Xl=l([$({type:R.Choice})],Xl);var Ql;const Fg=`${Tn}.37`;let bc=Ql=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ql.prototype)}};bc=Ql=l([$({type:R.Sequence,itemType:v.ObjectIdentifier})],bc);const Jw=`${ls}.1`,Yw=`${ls}.2`,Xw=`${ls}.3`,Qw=`${ls}.4`,e1=`${ls}.8`,t1=`${ls}.9`;let ed=class{constructor(e=new ArrayBuffer(0)){this.value=e}};l([h({type:v.Integer,converter:Ke})],ed.prototype,"value",void 0);ed=l([$({type:R.Choice})],ed);let td=class{constructor(e){this.value=new Date,e&&(this.value=e)}};l([h({type:v.GeneralizedTime})],td.prototype,"value",void 0);td=l([$({type:R.Choice})],td);var rd;let Wh=rd=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,rd.prototype)}};Wh=rd=l([$({type:R.Sequence})],Wh);const Kg=`${Tn}.15`;var er;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(er||(er={}));class sl extends _u{toJSON(){const e=this.toNumber(),t=[];return e&er.cRLSign&&t.push("crlSign"),e&er.dataEncipherment&&t.push("dataEncipherment"),e&er.decipherOnly&&t.push("decipherOnly"),e&er.digitalSignature&&t.push("digitalSignature"),e&er.encipherOnly&&t.push("encipherOnly"),e&er.keyAgreement&&t.push("keyAgreement"),e&er.keyCertSign&&t.push("keyCertSign"),e&er.keyEncipherment&&t.push("keyEncipherment"),e&er.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var nd;class Au{constructor(e={}){this.base=new be,this.minimum=0,Object.assign(this,e)}}l([h({type:be})],Au.prototype,"base",void 0);l([h({type:v.Integer,context:0,defaultValue:0,implicit:!0})],Au.prototype,"minimum",void 0);l([h({type:v.Integer,context:1,optional:!0,implicit:!0})],Au.prototype,"maximum",void 0);let xc=nd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,nd.prototype)}};xc=nd=l([$({type:R.Sequence,itemType:Au})],xc);class Wg{constructor(e={}){Object.assign(this,e)}}l([h({type:xc,context:0,optional:!0,implicit:!0})],Wg.prototype,"permittedSubtrees",void 0);l([h({type:xc,context:1,optional:!0,implicit:!0})],Wg.prototype,"excludedSubtrees",void 0);class zg{constructor(e={}){Object.assign(this,e)}}l([h({type:v.Integer,context:0,implicit:!0,optional:!0,converter:Ke})],zg.prototype,"requireExplicitPolicy",void 0);l([h({type:v.Integer,context:1,implicit:!0,optional:!0,converter:Ke})],zg.prototype,"inhibitPolicyMapping",void 0);var id;class $f{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],$f.prototype,"issuerDomainPolicy",void 0);l([h({type:v.ObjectIdentifier})],$f.prototype,"subjectDomainPolicy",void 0);let zh=id=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,id.prototype)}};zh=id=l([$({type:R.Sequence,itemType:$f})],zh);var sd;const Gg=`${Tn}.17`;let ad=sd=class extends xt{constructor(e){super(e),Object.setPrototypeOf(this,sd.prototype)}};ad=sd=l([$({type:R.Sequence})],ad);let Wr=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],Wr.prototype,"type",void 0);l([h({type:v.Any,repeated:"set"})],Wr.prototype,"values",void 0);var od;let Gh=od=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,od.prototype)}};Gh=od=l([$({type:R.Sequence,itemType:Wr})],Gh);const Jg=`${Tn}.14`;class yn extends Nf{}class Yg{constructor(e={}){Object.assign(this,e)}}l([h({type:v.GeneralizedTime,context:0,implicit:!0,optional:!0})],Yg.prototype,"notBefore",void 0);l([h({type:v.GeneralizedTime,context:1,implicit:!0,optional:!0})],Yg.prototype,"notAfter",void 0);var Ms;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Ms||(Ms={}));class Xg extends _u{toJSON(){const e=[],t=this.toNumber();return t&Ms.pKIXCertificate&&e.push("pKIXCertificate"),t&Ms.newExtensions&&e.push("newExtensions"),t&Ms.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Qg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Xg,Object.assign(this,e)}}l([h({type:v.GeneralString})],Qg.prototype,"entrustVers",void 0);l([h({type:Xg})],Qg.prototype,"entrustInfoFlags",void 0);var cd;let Jh=cd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,cd.prototype)}};Jh=cd=l([$({type:R.Sequence,itemType:to})],Jh);class Y{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof Y&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&My(e.parameters,this.parameters)||e.parameters===this.parameters)}}l([h({type:v.ObjectIdentifier})],Y.prototype,"algorithm",void 0);l([h({type:v.Any,optional:!0})],Y.prototype,"parameters",void 0);class sr{constructor(e={}){this.algorithm=new Y,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],sr.prototype,"algorithm",void 0);l([h({type:v.BitString})],sr.prototype,"subjectPublicKey",void 0);let lt=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};l([h({type:v.UTCTime})],lt.prototype,"utcTime",void 0);l([h({type:v.GeneralizedTime})],lt.prototype,"generalTime",void 0);lt=l([$({type:R.Choice})],lt);class ro{constructor(e){this.notBefore=new lt(new Date),this.notAfter=new lt(new Date),e&&(this.notBefore=new lt(e.notBefore),this.notAfter=new lt(e.notAfter))}}l([h({type:lt})],ro.prototype,"notBefore",void 0);l([h({type:lt})],ro.prototype,"notAfter",void 0);var ud;let Wt=class e0{constructor(e={}){this.extnID="",this.critical=e0.CRITICAL,this.extnValue=new De,Object.assign(this,e)}};Wt.CRITICAL=!1;l([h({type:v.ObjectIdentifier})],Wt.prototype,"extnID",void 0);l([h({type:v.Boolean,defaultValue:Wt.CRITICAL})],Wt.prototype,"critical",void 0);l([h({type:De})],Wt.prototype,"extnValue",void 0);let kn=ud=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,ud.prototype)}};kn=ud=l([$({type:R.Sequence,itemType:Wt})],kn);var oi;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(oi||(oi={}));class Ut{constructor(e={}){this.version=oi.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new Y,this.issuer=new et,this.validity=new ro,this.subject=new et,this.subjectPublicKeyInfo=new sr,Object.assign(this,e)}}l([h({type:v.Integer,context:0,defaultValue:oi.v1})],Ut.prototype,"version",void 0);l([h({type:v.Integer,converter:Ke})],Ut.prototype,"serialNumber",void 0);l([h({type:Y})],Ut.prototype,"signature",void 0);l([h({type:et})],Ut.prototype,"issuer",void 0);l([h({type:ro})],Ut.prototype,"validity",void 0);l([h({type:et})],Ut.prototype,"subject",void 0);l([h({type:sr})],Ut.prototype,"subjectPublicKeyInfo",void 0);l([h({type:v.BitString,context:1,implicit:!0,optional:!0})],Ut.prototype,"issuerUniqueID",void 0);l([h({type:v.BitString,context:2,implicit:!0,optional:!0})],Ut.prototype,"subjectUniqueID",void 0);l([h({type:kn,context:3,optional:!0})],Ut.prototype,"extensions",void 0);class ci{constructor(e={}){this.tbsCertificate=new Ut,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Ut})],ci.prototype,"tbsCertificate",void 0);l([h({type:Y})],ci.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],ci.prototype,"signatureValue",void 0);class Ou{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new lt,Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Ou.prototype,"userCertificate",void 0);l([h({type:lt})],Ou.prototype,"revocationDate",void 0);l([h({type:Wt,optional:!0,repeated:"sequence"})],Ou.prototype,"crlEntryExtensions",void 0);class tn{constructor(e={}){this.signature=new Y,this.issuer=new et,this.thisUpdate=new lt,Object.assign(this,e)}}l([h({type:v.Integer,optional:!0})],tn.prototype,"version",void 0);l([h({type:Y})],tn.prototype,"signature",void 0);l([h({type:et})],tn.prototype,"issuer",void 0);l([h({type:lt})],tn.prototype,"thisUpdate",void 0);l([h({type:lt,optional:!0})],tn.prototype,"nextUpdate",void 0);l([h({type:Ou,repeated:"sequence",optional:!0})],tn.prototype,"revokedCertificates",void 0);l([h({type:Wt,optional:!0,context:0,repeated:"sequence"})],tn.prototype,"crlExtensions",void 0);class Df{constructor(e={}){this.tbsCertList=new tn,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:tn})],Df.prototype,"tbsCertList",void 0);l([h({type:Y})],Df.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],Df.prototype,"signature",void 0);class fs{constructor(e={}){this.issuer=new et,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:et})],fs.prototype,"issuer",void 0);l([h({type:v.Integer,converter:Ke})],fs.prototype,"serialNumber",void 0);let Ji=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0})],Ji.prototype,"subjectKeyIdentifier",void 0);l([h({type:fs})],Ji.prototype,"issuerAndSerialNumber",void 0);Ji=l([$({type:R.Choice})],Ji);var zr;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(zr||(zr={}));let xa=class extends Y{};xa=l([$({type:R.Sequence})],xa);let _c=class extends Y{};_c=l([$({type:R.Sequence})],_c);let Er=class extends Y{};Er=l([$({type:R.Sequence})],Er);let wc=class extends Y{};wc=l([$({type:R.Sequence})],wc);let Yh=class extends Y{};Yh=l([$({type:R.Sequence})],Yh);let ld=class extends Y{};ld=l([$({type:R.Sequence})],ld);let hs=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],hs.prototype,"attrType",void 0);l([h({type:v.Any,repeated:"set"})],hs.prototype,"attrValues",void 0);var dd;class Tr{constructor(e={}){this.version=zr.v0,this.sid=new Ji,this.digestAlgorithm=new xa,this.signatureAlgorithm=new _c,this.signature=new De,Object.assign(this,e)}}l([h({type:v.Integer})],Tr.prototype,"version",void 0);l([h({type:Ji})],Tr.prototype,"sid",void 0);l([h({type:xa})],Tr.prototype,"digestAlgorithm",void 0);l([h({type:hs,repeated:"set",context:0,implicit:!0,optional:!0})],Tr.prototype,"signedAttrs",void 0);l([h({type:_c})],Tr.prototype,"signatureAlgorithm",void 0);l([h({type:De})],Tr.prototype,"signature",void 0);l([h({type:hs,repeated:"set",context:1,implicit:!0,optional:!0})],Tr.prototype,"unsignedAttrs",void 0);let kc=dd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,dd.prototype)}};kc=dd=l([$({type:R.Set,itemType:Tr})],kc);let Xh=class extends lt{};Xh=l([$({type:R.Choice})],Xh);let Qh=class extends Tr{};Qh=l([$({type:R.Sequence})],Qh);class Zf{constructor(e={}){this.acIssuer=new be,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}l([h({type:be})],Zf.prototype,"acIssuer",void 0);l([h({type:v.Integer})],Zf.prototype,"acSerial",void 0);l([h({type:Wr,repeated:"sequence"})],Zf.prototype,"attrs",void 0);var fd;let Sc=fd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,fd.prototype)}};Sc=fd=l([$({type:R.Sequence,itemType:v.ObjectIdentifier})],Sc);class Eu{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}l([h({type:v.Integer,optional:!0})],Eu.prototype,"pathLenConstraint",void 0);l([h({type:Sc,implicit:!0,context:0,optional:!0})],Eu.prototype,"permittedAttrs",void 0);l([h({type:Sc,implicit:!0,context:1,optional:!0})],Eu.prototype,"excludedAttrs",void 0);l([h({type:v.Boolean,defaultValue:!0})],Eu.prototype,"permitUnSpecified",void 0);class vi{constructor(e={}){this.issuer=new xt,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:xt})],vi.prototype,"issuer",void 0);l([h({type:v.Integer,converter:Ke})],vi.prototype,"serial",void 0);l([h({type:v.BitString,optional:!0})],vi.prototype,"issuerUID",void 0);var hd;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(hd||(hd={}));class bi{constructor(e={}){this.digestedObjectType=hd.publicKey,this.digestAlgorithm=new Y,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Enumerated})],bi.prototype,"digestedObjectType",void 0);l([h({type:v.ObjectIdentifier,optional:!0})],bi.prototype,"otherObjectTypeID",void 0);l([h({type:Y})],bi.prototype,"digestAlgorithm",void 0);l([h({type:v.BitString})],bi.prototype,"objectDigest",void 0);class Iu{constructor(e={}){Object.assign(this,e)}}l([h({type:xt,optional:!0})],Iu.prototype,"issuerName",void 0);l([h({type:vi,context:0,implicit:!0,optional:!0})],Iu.prototype,"baseCertificateID",void 0);l([h({type:bi,context:1,implicit:!0,optional:!0})],Iu.prototype,"objectDigestInfo",void 0);let Yi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,repeated:"sequence"})],Yi.prototype,"v1Form",void 0);l([h({type:Iu,context:0,implicit:!0})],Yi.prototype,"v2Form",void 0);Yi=l([$({type:R.Choice})],Yi);class Cu{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}l([h({type:v.GeneralizedTime})],Cu.prototype,"notBeforeTime",void 0);l([h({type:v.GeneralizedTime})],Cu.prototype,"notAfterTime",void 0);class no{constructor(e={}){Object.assign(this,e)}}l([h({type:vi,implicit:!0,context:0,optional:!0})],no.prototype,"baseCertificateID",void 0);l([h({type:xt,implicit:!0,context:1,optional:!0})],no.prototype,"entityName",void 0);l([h({type:bi,implicit:!0,context:2,optional:!0})],no.prototype,"objectDigestInfo",void 0);var pd;(function(r){r[r.v2=1]="v2"})(pd||(pd={}));class mr{constructor(e={}){this.version=pd.v2,this.holder=new no,this.issuer=new Yi,this.signature=new Y,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Cu,this.attributes=[],Object.assign(this,e)}}l([h({type:v.Integer})],mr.prototype,"version",void 0);l([h({type:no})],mr.prototype,"holder",void 0);l([h({type:Yi})],mr.prototype,"issuer",void 0);l([h({type:Y})],mr.prototype,"signature",void 0);l([h({type:v.Integer,converter:Ke})],mr.prototype,"serialNumber",void 0);l([h({type:Cu})],mr.prototype,"attrCertValidityPeriod",void 0);l([h({type:Wr,repeated:"sequence"})],mr.prototype,"attributes",void 0);l([h({type:v.BitString,optional:!0})],mr.prototype,"issuerUniqueID",void 0);l([h({type:kn,optional:!0})],mr.prototype,"extensions",void 0);class ju{constructor(e={}){this.acinfo=new mr,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:mr})],ju.prototype,"acinfo",void 0);l([h({type:Y})],ju.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],ju.prototype,"signatureValue",void 0);var Ac;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(Ac||(Ac={}));class md extends _u{}class Mf{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier,implicit:!0,context:0})],Mf.prototype,"type",void 0);l([h({type:v.Any,implicit:!0,context:1})],Mf.prototype,"value",void 0);class Uf{constructor(e={}){this.policyId="",this.classList=new md(Ac.unclassified),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Uf.prototype,"policyId",void 0);l([h({type:md,defaultValue:new md(Ac.unclassified)})],Uf.prototype,"classList",void 0);l([h({type:Mf,repeated:"set"})],Uf.prototype,"securityCategories",void 0);class Tu{constructor(e={}){Object.assign(this,e)}}l([h({type:De})],Tu.prototype,"cotets",void 0);l([h({type:v.ObjectIdentifier})],Tu.prototype,"oid",void 0);l([h({type:v.Utf8String})],Tu.prototype,"string",void 0);class t0{constructor(e={}){this.values=[],Object.assign(this,e)}}l([h({type:xt,implicit:!0,context:0,optional:!0})],t0.prototype,"policyAuthority",void 0);l([h({type:Tu,repeated:"sequence"})],t0.prototype,"values",void 0);var yd;class Nu{constructor(e={}){this.targetCertificate=new vi,Object.assign(this,e)}}l([h({type:vi})],Nu.prototype,"targetCertificate",void 0);l([h({type:be,optional:!0})],Nu.prototype,"targetName",void 0);l([h({type:bi,optional:!0})],Nu.prototype,"certDigestInfo",void 0);let Xi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:be,context:0,implicit:!0})],Xi.prototype,"targetName",void 0);l([h({type:be,context:1,implicit:!0})],Xi.prototype,"targetGroup",void 0);l([h({type:Nu,context:2,implicit:!0})],Xi.prototype,"targetCert",void 0);Xi=l([$({type:R.Choice})],Xi);let gd=yd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,yd.prototype)}};gd=yd=l([$({type:R.Sequence,itemType:Xi})],gd);var vd;let ep=vd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,vd.prototype)}};ep=vd=l([$({type:R.Sequence,itemType:gd})],ep);class r0{constructor(e={}){Object.assign(this,e)}}l([h({type:xt,implicit:!0,context:0,optional:!0})],r0.prototype,"roleAuthority",void 0);l([h({type:be,implicit:!0,context:1})],r0.prototype,"roleName",void 0);class Vf{constructor(e={}){this.service=new be,this.ident=new be,Object.assign(this,e)}}l([h({type:be})],Vf.prototype,"service",void 0);l([h({type:be})],Vf.prototype,"ident",void 0);l([h({type:De,optional:!0})],Vf.prototype,"authInfo",void 0);var bd;class Lf{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Lf.prototype,"otherCertFormat",void 0);l([h({type:v.Any})],Lf.prototype,"otherCert",void 0);let Qi=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ci})],Qi.prototype,"certificate",void 0);l([h({type:ju,context:2,implicit:!0})],Qi.prototype,"v2AttrCert",void 0);l([h({type:Lf,context:3,implicit:!0})],Qi.prototype,"other",void 0);Qi=l([$({type:R.Choice})],Qi);let Oc=bd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,bd.prototype)}};Oc=bd=l([$({type:R.Set,itemType:Qi})],Oc);class ps{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],ps.prototype,"contentType",void 0);l([h({type:v.Any,context:0})],ps.prototype,"content",void 0);let _a=class{constructor(e={}){Object.assign(this,e)}};l([h({type:De})],_a.prototype,"single",void 0);l([h({type:v.Any})],_a.prototype,"any",void 0);_a=l([$({type:R.Choice})],_a);class Bu{constructor(e={}){this.eContentType="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Bu.prototype,"eContentType",void 0);l([h({type:_a,context:0,optional:!0})],Bu.prototype,"eContent",void 0);let wa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:De,context:0,implicit:!0,optional:!0})],wa.prototype,"value",void 0);l([h({type:De,converter:jw,context:0,implicit:!0,optional:!0,repeated:"sequence"})],wa.prototype,"constructedValue",void 0);wa=l([$({type:R.Choice})],wa);class io{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new wc,Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],io.prototype,"contentType",void 0);l([h({type:wc})],io.prototype,"contentEncryptionAlgorithm",void 0);l([h({type:wa,optional:!0})],io.prototype,"encryptedContent",void 0);class Ru{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Ru.prototype,"keyAttrId",void 0);l([h({type:v.Any,optional:!0})],Ru.prototype,"keyAttr",void 0);var xd;class Pu{constructor(e={}){this.subjectKeyIdentifier=new yn,Object.assign(this,e)}}l([h({type:yn})],Pu.prototype,"subjectKeyIdentifier",void 0);l([h({type:v.GeneralizedTime,optional:!0})],Pu.prototype,"date",void 0);l([h({type:Ru,optional:!0})],Pu.prototype,"other",void 0);let es=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Pu,context:0,implicit:!0,optional:!0})],es.prototype,"rKeyId",void 0);l([h({type:fs,optional:!0})],es.prototype,"issuerAndSerialNumber",void 0);es=l([$({type:R.Choice})],es);class qf{constructor(e={}){this.rid=new es,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:es})],qf.prototype,"rid",void 0);l([h({type:De})],qf.prototype,"encryptedKey",void 0);let Ec=xd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,xd.prototype)}};Ec=xd=l([$({type:R.Sequence,itemType:qf})],Ec);class Hf{constructor(e={}){this.algorithm=new Y,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],Hf.prototype,"algorithm",void 0);l([h({type:v.BitString})],Hf.prototype,"publicKey",void 0);let ui=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0,optional:!0})],ui.prototype,"subjectKeyIdentifier",void 0);l([h({type:Hf,context:1,implicit:!0,optional:!0})],ui.prototype,"originatorKey",void 0);l([h({type:fs,optional:!0})],ui.prototype,"issuerAndSerialNumber",void 0);ui=l([$({type:R.Choice})],ui);class ms{constructor(e={}){this.version=zr.v3,this.originator=new ui,this.keyEncryptionAlgorithm=new Er,this.recipientEncryptedKeys=new Ec,Object.assign(this,e)}}l([h({type:v.Integer})],ms.prototype,"version",void 0);l([h({type:ui,context:0})],ms.prototype,"originator",void 0);l([h({type:De,context:1,optional:!0})],ms.prototype,"ukm",void 0);l([h({type:Er})],ms.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:Ec})],ms.prototype,"recipientEncryptedKeys",void 0);let ts=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0})],ts.prototype,"subjectKeyIdentifier",void 0);l([h({type:fs})],ts.prototype,"issuerAndSerialNumber",void 0);ts=l([$({type:R.Choice})],ts);class so{constructor(e={}){this.version=zr.v0,this.rid=new ts,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],so.prototype,"version",void 0);l([h({type:ts})],so.prototype,"rid",void 0);l([h({type:Er})],so.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],so.prototype,"encryptedKey",void 0);class ao{constructor(e={}){this.keyIdentifier=new De,Object.assign(this,e)}}l([h({type:De})],ao.prototype,"keyIdentifier",void 0);l([h({type:v.GeneralizedTime,optional:!0})],ao.prototype,"date",void 0);l([h({type:Ru,optional:!0})],ao.prototype,"other",void 0);class oo{constructor(e={}){this.version=zr.v4,this.kekid=new ao,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],oo.prototype,"version",void 0);l([h({type:ao})],oo.prototype,"kekid",void 0);l([h({type:Er})],oo.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],oo.prototype,"encryptedKey",void 0);class co{constructor(e={}){this.version=zr.v0,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],co.prototype,"version",void 0);l([h({type:ld,context:0,optional:!0})],co.prototype,"keyDerivationAlgorithm",void 0);l([h({type:Er})],co.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:De})],co.prototype,"encryptedKey",void 0);class Ff{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Ff.prototype,"oriType",void 0);l([h({type:v.Any})],Ff.prototype,"oriValue",void 0);let Sn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:so,optional:!0})],Sn.prototype,"ktri",void 0);l([h({type:ms,context:1,implicit:!0,optional:!0})],Sn.prototype,"kari",void 0);l([h({type:oo,context:2,implicit:!0,optional:!0})],Sn.prototype,"kekri",void 0);l([h({type:co,context:3,implicit:!0,optional:!0})],Sn.prototype,"pwri",void 0);l([h({type:Ff,context:4,implicit:!0,optional:!0})],Sn.prototype,"ori",void 0);Sn=l([$({type:R.Choice})],Sn);var _d;let Ic=_d=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,_d.prototype)}};Ic=_d=l([$({type:R.Set,itemType:Sn})],Ic);var wd;class $u{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],$u.prototype,"otherRevInfoFormat",void 0);l([h({type:v.Any})],$u.prototype,"otherRevInfo",void 0);let Cc=class{constructor(e={}){this.other=new $u,Object.assign(this,e)}};l([h({type:$u,context:1,implicit:!0})],Cc.prototype,"other",void 0);Cc=l([$({type:R.Choice})],Cc);let jc=wd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,wd.prototype)}};jc=wd=l([$({type:R.Set,itemType:Cc})],jc);class Kf{constructor(e={}){Object.assign(this,e)}}l([h({type:Oc,context:0,implicit:!0,optional:!0})],Kf.prototype,"certs",void 0);l([h({type:jc,context:1,implicit:!0,optional:!0})],Kf.prototype,"crls",void 0);var kd;let Sd=kd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,kd.prototype)}};Sd=kd=l([$({type:R.Set,itemType:hs})],Sd);class uo{constructor(e={}){this.version=zr.v0,this.recipientInfos=new Ic,this.encryptedContentInfo=new io,Object.assign(this,e)}}l([h({type:v.Integer})],uo.prototype,"version",void 0);l([h({type:Kf,context:0,implicit:!0,optional:!0})],uo.prototype,"originatorInfo",void 0);l([h({type:Ic})],uo.prototype,"recipientInfos",void 0);l([h({type:io})],uo.prototype,"encryptedContentInfo",void 0);l([h({type:Sd,context:1,implicit:!0,optional:!0})],uo.prototype,"unprotectedAttrs",void 0);const r1="1.2.840.113549.1.7.2";var Ad;let Tc=Ad=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ad.prototype)}};Tc=Ad=l([$({type:R.Set,itemType:xa})],Tc);class ys{constructor(e={}){this.version=zr.v0,this.digestAlgorithms=new Tc,this.encapContentInfo=new Bu,this.signerInfos=new kc,Object.assign(this,e)}}l([h({type:v.Integer})],ys.prototype,"version",void 0);l([h({type:Tc})],ys.prototype,"digestAlgorithms",void 0);l([h({type:Bu})],ys.prototype,"encapContentInfo",void 0);l([h({type:Oc,context:0,implicit:!0,optional:!0})],ys.prototype,"certificates",void 0);l([h({type:jc,context:1,implicit:!0,optional:!0})],ys.prototype,"crls",void 0);l([h({type:kc})],ys.prototype,"signerInfos",void 0);const ka="1.2.840.10045.2.1",Wf="1.2.840.10045.4.1",n0="1.2.840.10045.4.3.1",zf="1.2.840.10045.4.3.2",Gf="1.2.840.10045.4.3.3",Jf="1.2.840.10045.4.3.4",tp="1.2.840.10045.3.1.7",rp="1.3.132.0.34",np="1.3.132.0.35";function lo(r){return new Y({algorithm:r})}const n1=lo(Wf);lo(n0);const i1=lo(zf),s1=lo(Gf),a1=lo(Jf);let Sa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],Sa.prototype,"fieldType",void 0);l([h({type:v.Any})],Sa.prototype,"parameters",void 0);Sa=l([$({type:R.Sequence})],Sa);class o1 extends De{}let rs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.OctetString})],rs.prototype,"a",void 0);l([h({type:v.OctetString})],rs.prototype,"b",void 0);l([h({type:v.BitString,optional:!0})],rs.prototype,"seed",void 0);rs=l([$({type:R.Sequence})],rs);var Od;(function(r){r[r.ecpVer1=1]="ecpVer1"})(Od||(Od={}));let Gr=class{constructor(e={}){this.version=Od.ecpVer1,Object.assign(this,e)}};l([h({type:v.Integer})],Gr.prototype,"version",void 0);l([h({type:Sa})],Gr.prototype,"fieldID",void 0);l([h({type:rs})],Gr.prototype,"curve",void 0);l([h({type:o1})],Gr.prototype,"base",void 0);l([h({type:v.Integer,converter:Ke})],Gr.prototype,"order",void 0);l([h({type:v.Integer,optional:!0})],Gr.prototype,"cofactor",void 0);Gr=l([$({type:R.Sequence})],Gr);let An=class{constructor(e={}){Object.assign(this,e)}};l([h({type:v.ObjectIdentifier})],An.prototype,"namedCurve",void 0);l([h({type:v.Null})],An.prototype,"implicitCurve",void 0);l([h({type:Gr})],An.prototype,"specifiedCurve",void 0);An=l([$({type:R.Choice})],An);class Du{constructor(e={}){this.version=1,this.privateKey=new De,Object.assign(this,e)}}l([h({type:v.Integer})],Du.prototype,"version",void 0);l([h({type:De})],Du.prototype,"privateKey",void 0);l([h({type:An,context:0,optional:!0})],Du.prototype,"parameters",void 0);l([h({type:v.BitString,context:1,optional:!0})],Du.prototype,"publicKey",void 0);class Nc{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Nc.prototype,"r",void 0);l([h({type:v.Integer,converter:Ke})],Nc.prototype,"s",void 0);const Nt="1.2.840.113549.1.1",li=`${Nt}.1`,c1=`${Nt}.7`,u1=`${Nt}.9`,Us=`${Nt}.10`,l1=`${Nt}.2`,d1=`${Nt}.4`,Bc=`${Nt}.5`,f1=`${Nt}.14`,Ed=`${Nt}.11`,Rc=`${Nt}.12`,Pc=`${Nt}.13`,i0=`${Nt}.15`,s0=`${Nt}.16`,$c="1.3.14.3.2.26",a0="2.16.840.1.101.3.4.2.4",Dc="2.16.840.1.101.3.4.2.1",Zc="2.16.840.1.101.3.4.2.2",Mc="2.16.840.1.101.3.4.2.3",h1="2.16.840.1.101.3.4.2.5",p1="2.16.840.1.101.3.4.2.6",m1="1.2.840.113549.2.2",y1="1.2.840.113549.2.5",Zu=`${Nt}.8`;function at(r){return new Y({algorithm:r,parameters:null})}at(m1);at(y1);const di=at($c);at(a0);at(Dc);at(Zc);at(Mc);at(h1);at(p1);const o0=new Y({algorithm:Zu,parameters:L.serialize(di)}),c0=new Y({algorithm:u1,parameters:L.serialize(pc.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});at(li);at(l1);at(d1);at(Bc);at(i0);at(s0);at(Rc);at(Pc);at(i0);at(s0);class Mu{constructor(e={}){this.hashAlgorithm=new Y(di),this.maskGenAlgorithm=new Y({algorithm:Zu,parameters:L.serialize(di)}),this.pSourceAlgorithm=new Y(c0),Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:di})],Mu.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:o0})],Mu.prototype,"maskGenAlgorithm",void 0);l([h({type:Y,context:2,defaultValue:c0})],Mu.prototype,"pSourceAlgorithm",void 0);new Y({algorithm:c1,parameters:L.serialize(new Mu)});class fi{constructor(e={}){this.hashAlgorithm=new Y(di),this.maskGenAlgorithm=new Y({algorithm:Zu,parameters:L.serialize(di)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:di})],fi.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:o0})],fi.prototype,"maskGenAlgorithm",void 0);l([h({type:v.Integer,context:2,defaultValue:20})],fi.prototype,"saltLength",void 0);l([h({type:v.Integer,context:3,defaultValue:1})],fi.prototype,"trailerField",void 0);new Y({algorithm:Us,parameters:L.serialize(new fi)});class Uu{constructor(e={}){this.digestAlgorithm=new Y,this.digest=new De,Object.assign(this,e)}}l([h({type:Y})],Uu.prototype,"digestAlgorithm",void 0);l([h({type:De})],Uu.prototype,"digest",void 0);var Id;class Vu{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Vu.prototype,"prime",void 0);l([h({type:v.Integer,converter:Ke})],Vu.prototype,"exponent",void 0);l([h({type:v.Integer,converter:Ke})],Vu.prototype,"coefficient",void 0);let Cd=Id=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Id.prototype)}};Cd=Id=l([$({type:R.Sequence,itemType:Vu})],Cd);class Nr{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer})],Nr.prototype,"version",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"modulus",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"publicExponent",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"privateExponent",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"prime1",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"prime2",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"exponent1",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"exponent2",void 0);l([h({type:v.Integer,converter:Ke})],Nr.prototype,"coefficient",void 0);l([h({type:Cd,optional:!0})],Nr.prototype,"otherPrimeInfos",void 0);class Yf{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.Integer,converter:Ke})],Yf.prototype,"modulus",void 0);l([h({type:v.Integer,converter:Ke})],Yf.prototype,"publicExponent",void 0);var jd;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(jd||(jd={}));const At=jd;/*! *****************************************************************************
80
80
  Copyright (c) Microsoft Corporation.
81
81
 
82
82
  Permission to use, copy, modify, and/or distribute this software for any
@@ -89,9 +89,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
89
89
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
90
90
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
91
91
  PERFORMANCE OF THIS SOFTWARE.
92
- ***************************************************************************** */var F1=function(r,e){return F1=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])},F1(r,e)};function sk(r,e){F1(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function wB(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(l){try{u(n.next(l))}catch(h){a(h)}}function c(l){try{u(n.throw(l))}catch(h){a(h)}}function u(l){l.done?i(l.value):s(l.value).then(o,c)}u((n=n.apply(r,[])).next())})}function xB(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(l){return c([u,l])}}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(l){u=[6,l],s=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function If(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 vy(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 go(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(vy(arguments[e]));return r}var kB="injectionTokens";function SB(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(kB,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function bC(r){return!!r.useClass}function K1(r){return!!r.useFactory}var _C=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,go(i))}};return this.reflectMethods.forEach(n),t},r}();function Tc(r){return typeof r=="string"||typeof r=="symbol"}function AB(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function X2(r){return typeof r=="object"&&"token"in r&&"transform"in r}function OB(r){return typeof r=="function"||r instanceof _C}function nm(r){return!!r.useToken}function sm(r){return r.useValue!=null}function jB(r){return bC(r)||sm(r)||nm(r)||K1(r)}var ik=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}(),CB=function(r){sk(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(ik),Q2=function(){function r(){this.scopedResolutions=new Map}return r}();function EB(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function IB(r,e,t){return t===void 0&&(t=" "),go([r],e.message.split(`
92
+ ***************************************************************************** */var Td=function(r,e){return Td=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},Td(r,e)};function Xf(r,e){Td(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function g1(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(f){try{u(n.next(f))}catch(m){a(m)}}function c(f){try{u(n.throw(f))}catch(m){a(m)}}function u(f){f.done?s(f.value):i(f.value).then(o,c)}u((n=n.apply(r,[])).next())})}function v1(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(u){return function(f){return c([u,f])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){t.label=u[1];break}if(u[0]===6&&t.label<s[1]){t.label=s[1],s=u;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(u);break}s[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(f){u=[6,f],i=0}finally{n=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function xo(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Uc(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s}function Zn(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Uc(arguments[e]));return r}var b1="injectionTokens";function x1(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(b1,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function u0(r){return!!r.useClass}function Nd(r){return!!r.useFactory}var l0=function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},i=!1,s,a=function(){return i||(s=e(t.wrap()),i=!0),s};return new Proxy(n,this.createHandler(a))},r.prototype.createHandler=function(e){var t={},n=function(i){t[i]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var o=Reflect[i];return o.apply(void 0,Zn(s))}};return this.reflectMethods.forEach(n),t},r}();function wi(r){return typeof r=="string"||typeof r=="symbol"}function _1(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function ip(r){return typeof r=="object"&&"token"in r&&"transform"in r}function w1(r){return typeof r=="function"||r instanceof l0}function No(r){return!!r.useToken}function Bo(r){return r.useValue!=null}function k1(r){return u0(r)||Bo(r)||No(r)||Nd(r)}var Qf=function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r}(),S1=function(r){Xf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Qf),sp=function(){function r(){this.scopedResolutions=new Map}return r}();function A1(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function O1(r,e,t){return t===void 0&&(t=" "),Zn([r],e.message.split(`
93
93
  `).map(function(n){return t+n})).join(`
94
- `)}function TB(r,e,t){var n=vy(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],i=s===void 0?null:s,a=EB(i,e);return IB("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function NB(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var BB=function(r){sk(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(ik),RB=function(r){sk(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(ik),PB=function(){function r(){this.preResolution=new BB,this.postResolution=new RB}return r}(),wC=new Map,$B=function(){function r(e){this.parent=e,this._registry=new CB,this.interceptors=new PB,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:Gr.Transient}),this.ensureNotDisposed();var s;if(jB(t)?s=t:s={useClass:t},nm(s))for(var i=[e],a=s;a!=null;){var o=a.useToken;if(i.includes(o))throw new Error("Token registration cycle detected! "+go(i,[o]).join(" -> "));i.push(o);var c=this._registry.get(o);c&&nm(c.provider)?a=c.provider:a=null}if((n.lifecycle===Gr.Singleton||n.lifecycle==Gr.ContainerScoped||n.lifecycle==Gr.ResolutionScoped)&&(sm(s)||K1(s)))throw new Error('Cannot use lifecycle "'+Gr[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(),Tc(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(),Tc(e)){if(Tc(t))return this.register(e,{useToken:t},{lifecycle:Gr.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Gr.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Tc(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:Gr.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new Q2),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&Tc(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(OB(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=If(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=If(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(l){s={error:l}}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===Gr.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===Gr.Singleton,s=e.options.lifecycle===Gr.ContainerScoped,i=n||s,a;return sm(e.provider)?a=e.provider.useValue:nm(e.provider)?a=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):bC(e.provider)?a=i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):K1(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===Gr.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new Q2),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&Tc(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=If(this._registry.entries()),s=n.next();!s.done;s=n.next()){var i=vy(s.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(c){return!sm(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=If(this._registry.entries()),i=s.next();!i.done;i=s.next()){var a=vy(i.value,2),o=a[0],c=a[1];c.some(function(u){var l=u.options;return l.lifecycle===Gr.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===Gr.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 wB(this,void 0,void 0,function(){var e;return xB(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 _C)return e.createProxy(function(i){return n.resolve(i,t)});var s=function(){var i=wC.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,go([void 0],a)))}();return NB(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 AB(s)?X2(s)?s.multiple?(a=n.resolve(s.transform)).transform.apply(a,go([n.resolveAll(s.token)],s.transformArgs)):(o=n.resolve(s.transform)).transform.apply(o,go([n.resolve(s.token,e)],s.transformArgs)):s.multiple?n.resolveAll(s.token):n.resolve(s.token,e):X2(s)?(c=n.resolve(s.transform,e)).transform.apply(c,go([n.resolve(s.token,e)],s.transformArgs)):n.resolve(s,e)}catch(u){throw new Error(TB(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}(),jr=new $B;function Tv(){return function(r){wC.set(r,SB(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 z1;class Nv{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}p([_({type:Z.ObjectIdentifier})],Nv.prototype,"attrId",void 0);p([_({type:Z.Any,repeated:"set"})],Nv.prototype,"attrValues",void 0);let eS=z1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,z1.prototype)}};eS=z1=p([X({type:G.Sequence,itemType:Nv})],eS);var W1;let tS=W1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,W1.prototype)}};tS=W1=p([X({type:G.Sequence,itemType:dl})],tS);class xC{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],xC.prototype,"certId",void 0);p([_({type:Z.Any,context:0})],xC.prototype,"certValue",void 0);class kC{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],kC.prototype,"crlId",void 0);p([_({type:Z.Any,context:0})],kC.prototype,"crltValue",void 0);class SC extends qt{}let Bv=class{constructor(e={}){this.encryptionAlgorithm=new je,this.encryptedData=new SC,Object.assign(this,e)}};p([_({type:je})],Bv.prototype,"encryptionAlgorithm",void 0);p([_({type:SC})],Bv.prototype,"encryptedData",void 0);var G1,J1;(function(r){r[r.v1=0]="v1"})(J1||(J1={}));class AC extends qt{}let Y1=G1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,G1.prototype)}};Y1=G1=p([X({type:G.Sequence,itemType:Ei})],Y1);class tf{constructor(e={}){this.version=J1.v1,this.privateKeyAlgorithm=new je,this.privateKey=new AC,Object.assign(this,e)}}p([_({type:Z.Integer})],tf.prototype,"version",void 0);p([_({type:je})],tf.prototype,"privateKeyAlgorithm",void 0);p([_({type:AC})],tf.prototype,"privateKey",void 0);p([_({type:Y1,implicit:!0,context:0,optional:!0})],tf.prototype,"attributes",void 0);let rS=class extends tf{};rS=p([X({type:G.Sequence})],rS);let nS=class extends Bv{};nS=p([X({type:G.Sequence})],nS);class OC{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],OC.prototype,"secretTypeId",void 0);p([_({type:Z.Any,context:0})],OC.prototype,"secretValue",void 0);class rf{constructor(e={}){this.mac=new Ev,this.macSalt=new qt,this.iterations=1,Object.assign(this,e)}}p([_({type:Ev})],rf.prototype,"mac",void 0);p([_({type:qt})],rf.prototype,"macSalt",void 0);p([_({type:Z.Integer,defaultValue:1})],rf.prototype,"iterations",void 0);class Rv{constructor(e={}){this.version=3,this.authSafe=new dl,this.macData=new rf,Object.assign(this,e)}}p([_({type:Z.Integer})],Rv.prototype,"version",void 0);p([_({type:dl})],Rv.prototype,"authSafe",void 0);p([_({type:rf,optional:!0})],Rv.prototype,"macData",void 0);var X1;class Pv{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:Z.ObjectIdentifier})],Pv.prototype,"bagId",void 0);p([_({type:Z.Any,context:0})],Pv.prototype,"bagValue",void 0);p([_({type:Nv,repeated:"set",optional:!0})],Pv.prototype,"bagAttributes",void 0);let sS=X1=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,X1.prototype)}};sS=X1=p([X({type:G.Sequence,itemType:Pv})],sS);var Q1,e_,t_;const jC="1.2.840.113549.1.9",CC=`${jC}.7`,ak=`${jC}.14`;let by=class extends Or{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};p([_({type:Z.IA5String})],by.prototype,"ia5String",void 0);by=p([X({type:G.Choice})],by);let iS=class extends dl{};iS=p([X({type:G.Sequence})],iS);let aS=class extends Rv{};aS=p([X({type:G.Sequence})],aS);let oS=class extends Bv{};oS=p([X({type:G.Sequence})],oS);let r_=class{constructor(e=""){this.value=e}toString(){return this.value}};p([_({type:Z.IA5String})],r_.prototype,"value",void 0);r_=p([X({type:G.Choice})],r_);let cS=class extends by{};cS=p([X({type:G.Choice})],cS);let uS=class extends Or{};uS=p([X({type:G.Choice})],uS);let n_=class{constructor(e=new Date){this.value=e}};p([_({type:Z.GeneralizedTime})],n_.prototype,"value",void 0);n_=p([X({type:G.Choice})],n_);let lS=class extends Or{};lS=p([X({type:G.Choice})],lS);let s_=class{constructor(e="M"){this.value=e}toString(){return this.value}};p([_({type:Z.PrintableString})],s_.prototype,"value",void 0);s_=p([X({type:G.Choice})],s_);let _y=class{constructor(e=""){this.value=e}toString(){return this.value}};p([_({type:Z.PrintableString})],_y.prototype,"value",void 0);_y=p([X({type:G.Choice})],_y);let dS=class extends _y{};dS=p([X({type:G.Choice})],dS);let hS=class extends Or{};hS=p([X({type:G.Choice})],hS);let i_=class{constructor(e=""){this.value=e}toString(){return this.value}};p([_({type:Z.ObjectIdentifier})],i_.prototype,"value",void 0);i_=p([X({type:G.Choice})],i_);let pS=class extends xr{};pS=p([X({type:G.Choice})],pS);let a_=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};p([_({type:Z.Integer})],a_.prototype,"value",void 0);a_=p([X({type:G.Choice})],a_);let fS=class extends si{};fS=p([X({type:G.Sequence})],fS);let wy=class extends Or{};wy=p([X({type:G.Choice})],wy);let mS=Q1=class extends Ia{constructor(e){super(e),Object.setPrototypeOf(this,Q1.prototype)}};mS=Q1=p([X({type:G.Sequence})],mS);let yS=e_=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,e_.prototype)}};yS=e_=p([X({type:G.Set,itemType:ll})],yS);let o_=class{constructor(e=""){this.value=e}toString(){return this.value}};p([_({type:Z.BmpString})],o_.prototype,"value",void 0);o_=p([X({type:G.Choice})],o_);let c_=class extends je{};c_=p([X({type:G.Sequence})],c_);let gS=t_=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,t_.prototype)}};gS=t_=p([X({type:G.Sequence,itemType:c_})],gS);var u_;let xy=u_=class extends zt{constructor(e){super(e),Object.setPrototypeOf(this,u_.prototype)}};xy=u_=p([X({type:G.Sequence,itemType:Ei})],xy);class fl{constructor(e={}){this.version=0,this.subject=new pr,this.subjectPKInfo=new as,this.attributes=new xy,Object.assign(this,e)}}p([_({type:Z.Integer})],fl.prototype,"version",void 0);p([_({type:pr})],fl.prototype,"subject",void 0);p([_({type:as})],fl.prototype,"subjectPKInfo",void 0);p([_({type:xy,implicit:!0,context:0})],fl.prototype,"attributes",void 0);class fh{constructor(e={}){this.certificationRequestInfo=new fl,this.signatureAlgorithm=new je,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}p([_({type:fl})],fh.prototype,"certificationRequestInfo",void 0);p([_({type:je})],fh.prototype,"signatureAlgorithm",void 0);p([_({type:Z.BitString})],fh.prototype,"signature",void 0);/*!
94
+ `)}function E1(r,e,t){var n=Uc(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=n[1],s=i===void 0?null:i,a=A1(s,e);return O1("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function I1(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var C1=function(r){Xf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Qf),j1=function(r){Xf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Qf),T1=function(){function r(){this.preResolution=new C1,this.postResolution=new j1}return r}(),d0=new Map,N1=function(){function r(e){this.parent=e,this._registry=new S1,this.interceptors=new T1,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:At.Transient}),this.ensureNotDisposed();var i;if(k1(t)?i=t:i={useClass:t},No(i))for(var s=[e],a=i;a!=null;){var o=a.useToken;if(s.includes(o))throw new Error("Token registration cycle detected! "+Zn(s,[o]).join(" -> "));s.push(o);var c=this._registry.get(o);c&&No(c.provider)?a=c.provider:a=null}if((n.lifecycle===At.Singleton||n.lifecycle==At.ContainerScoped||n.lifecycle==At.ResolutionScoped)&&(Bo(i)||Nd(i)))throw new Error('Cannot use lifecycle "'+At[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),wi(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),wi(e)){if(wi(t))return this.register(e,{useToken:t},{lifecycle:At.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:At.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!wi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:At.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new sp),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&wi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var i=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(w1(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=xo(this.interceptors.preResolution.getAll(e)),o=a.next();!o.done;o=a.next()){var c=o.value;c.options.frequency!="Once"&&s.push(c),c.callback(e,t)}}catch(u){n={error:u}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var i,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var o=xo(this.interceptors.postResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var u=c.value;u.options.frequency!="Once"&&a.push(u),u.callback(e,t,n)}}catch(f){i={error:f}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,a)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===At.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===At.Singleton,i=e.options.lifecycle===At.ContainerScoped,s=n||i,a;return Bo(e.provider)?a=e.provider.useValue:No(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):u0(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Nd(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===At.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new sp),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&wi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(o){return n.resolveRegistration(o,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=xo(this._registry.entries()),i=n.next();!i.done;i=n.next()){var s=Uc(i.value,2),a=s[0],o=s[1];this._registry.setAll(a,o.filter(function(c){return!Bo(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var i=xo(this._registry.entries()),s=i.next();!s.done;s=i.next()){var a=Uc(s.value,2),o=a[0],c=a[1];c.some(function(u){var f=u.options;return f.lifecycle===At.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===At.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return g1(this,void 0,void 0,function(){var e;return v1(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var i=n.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof l0)return e.createProxy(function(s){return n.resolve(s,t)});var i=function(){var s=d0.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,Zn([void 0],a)))}();return I1(i)&&this.disposables.add(i),i},r.prototype.resolveParams=function(e,t){var n=this;return function(i,s){var a,o,c;try{return _1(i)?ip(i)?i.multiple?(a=n.resolve(i.transform)).transform.apply(a,Zn([n.resolveAll(i.token)],i.transformArgs)):(o=n.resolve(i.transform)).transform.apply(o,Zn([n.resolve(i.token,e)],i.transformArgs)):i.multiple?n.resolveAll(i.token):n.resolve(i.token,e):ip(i)?(c=n.resolve(i.transform,e)).transform.apply(c,Zn([n.resolve(i.token,e)],i.transformArgs)):n.resolve(i,e)}catch(u){throw new Error(E1(t,s,u))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),pt=new N1;function Lu(){return function(r){d0.set(r,x1(r))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Bd;class qu{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}l([h({type:v.ObjectIdentifier})],qu.prototype,"attrId",void 0);l([h({type:v.Any,repeated:"set"})],qu.prototype,"attrValues",void 0);let ap=Bd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Bd.prototype)}};ap=Bd=l([$({type:R.Sequence,itemType:qu})],ap);var Rd;let op=Rd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Rd.prototype)}};op=Rd=l([$({type:R.Sequence,itemType:ps})],op);class f0{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],f0.prototype,"certId",void 0);l([h({type:v.Any,context:0})],f0.prototype,"certValue",void 0);class h0{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],h0.prototype,"crlId",void 0);l([h({type:v.Any,context:0})],h0.prototype,"crltValue",void 0);class p0 extends De{}let Hu=class{constructor(e={}){this.encryptionAlgorithm=new Y,this.encryptedData=new p0,Object.assign(this,e)}};l([h({type:Y})],Hu.prototype,"encryptionAlgorithm",void 0);l([h({type:p0})],Hu.prototype,"encryptedData",void 0);var Pd,$d;(function(r){r[r.v1=0]="v1"})($d||($d={}));class m0 extends De{}let Dd=Pd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Pd.prototype)}};Dd=Pd=l([$({type:R.Sequence,itemType:Wr})],Dd);class fo{constructor(e={}){this.version=$d.v1,this.privateKeyAlgorithm=new Y,this.privateKey=new m0,Object.assign(this,e)}}l([h({type:v.Integer})],fo.prototype,"version",void 0);l([h({type:Y})],fo.prototype,"privateKeyAlgorithm",void 0);l([h({type:m0})],fo.prototype,"privateKey",void 0);l([h({type:Dd,implicit:!0,context:0,optional:!0})],fo.prototype,"attributes",void 0);let cp=class extends fo{};cp=l([$({type:R.Sequence})],cp);let up=class extends Hu{};up=l([$({type:R.Sequence})],up);class y0{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],y0.prototype,"secretTypeId",void 0);l([h({type:v.Any,context:0})],y0.prototype,"secretValue",void 0);class ho{constructor(e={}){this.mac=new Uu,this.macSalt=new De,this.iterations=1,Object.assign(this,e)}}l([h({type:Uu})],ho.prototype,"mac",void 0);l([h({type:De})],ho.prototype,"macSalt",void 0);l([h({type:v.Integer,defaultValue:1})],ho.prototype,"iterations",void 0);class Fu{constructor(e={}){this.version=3,this.authSafe=new ps,this.macData=new ho,Object.assign(this,e)}}l([h({type:v.Integer})],Fu.prototype,"version",void 0);l([h({type:ps})],Fu.prototype,"authSafe",void 0);l([h({type:ho,optional:!0})],Fu.prototype,"macData",void 0);var Zd;class Ku{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:v.ObjectIdentifier})],Ku.prototype,"bagId",void 0);l([h({type:v.Any,context:0})],Ku.prototype,"bagValue",void 0);l([h({type:qu,repeated:"set",optional:!0})],Ku.prototype,"bagAttributes",void 0);let lp=Zd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Zd.prototype)}};lp=Zd=l([$({type:R.Sequence,itemType:Ku})],lp);var Md,Ud,Vd;const g0="1.2.840.113549.1.9",v0=`${g0}.7`,eh=`${g0}.14`;let Vc=class extends ht{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};l([h({type:v.IA5String})],Vc.prototype,"ia5String",void 0);Vc=l([$({type:R.Choice})],Vc);let dp=class extends ps{};dp=l([$({type:R.Sequence})],dp);let fp=class extends Fu{};fp=l([$({type:R.Sequence})],fp);let hp=class extends Hu{};hp=l([$({type:R.Sequence})],hp);let Ld=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.IA5String})],Ld.prototype,"value",void 0);Ld=l([$({type:R.Choice})],Ld);let pp=class extends Vc{};pp=l([$({type:R.Choice})],pp);let mp=class extends ht{};mp=l([$({type:R.Choice})],mp);let qd=class{constructor(e=new Date){this.value=e}};l([h({type:v.GeneralizedTime})],qd.prototype,"value",void 0);qd=l([$({type:R.Choice})],qd);let yp=class extends ht{};yp=l([$({type:R.Choice})],yp);let Hd=class{constructor(e="M"){this.value=e}toString(){return this.value}};l([h({type:v.PrintableString})],Hd.prototype,"value",void 0);Hd=l([$({type:R.Choice})],Hd);let Lc=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.PrintableString})],Lc.prototype,"value",void 0);Lc=l([$({type:R.Choice})],Lc);let gp=class extends Lc{};gp=l([$({type:R.Choice})],gp);let vp=class extends ht{};vp=l([$({type:R.Choice})],vp);let Fd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.ObjectIdentifier})],Fd.prototype,"value",void 0);Fd=l([$({type:R.Choice})],Fd);let bp=class extends lt{};bp=l([$({type:R.Choice})],bp);let Kd=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};l([h({type:v.Integer})],Kd.prototype,"value",void 0);Kd=l([$({type:R.Choice})],Kd);let xp=class extends Tr{};xp=l([$({type:R.Sequence})],xp);let qc=class extends ht{};qc=l([$({type:R.Choice})],qc);let _p=Md=class extends kn{constructor(e){super(e),Object.setPrototypeOf(this,Md.prototype)}};_p=Md=l([$({type:R.Sequence})],_p);let wp=Ud=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Ud.prototype)}};wp=Ud=l([$({type:R.Set,itemType:hs})],wp);let Wd=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:v.BmpString})],Wd.prototype,"value",void 0);Wd=l([$({type:R.Choice})],Wd);let zd=class extends Y{};zd=l([$({type:R.Sequence})],zd);let kp=Vd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Vd.prototype)}};kp=Vd=l([$({type:R.Sequence,itemType:zd})],kp);var Gd;let Hc=Gd=class extends Ve{constructor(e){super(e),Object.setPrototypeOf(this,Gd.prototype)}};Hc=Gd=l([$({type:R.Sequence,itemType:Wr})],Hc);class gs{constructor(e={}){this.version=0,this.subject=new et,this.subjectPKInfo=new sr,this.attributes=new Hc,Object.assign(this,e)}}l([h({type:v.Integer})],gs.prototype,"version",void 0);l([h({type:et})],gs.prototype,"subject",void 0);l([h({type:sr})],gs.prototype,"subjectPKInfo",void 0);l([h({type:Hc,implicit:!0,context:0})],gs.prototype,"attributes",void 0);class Aa{constructor(e={}){this.certificationRequestInfo=new gs,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:gs})],Aa.prototype,"certificationRequestInfo",void 0);l([h({type:Y})],Aa.prototype,"signatureAlgorithm",void 0);l([h({type:v.BitString})],Aa.prototype,"signature",void 0);/*!
95
95
  * MIT License
96
96
  *
97
97
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -114,136 +114,12 @@ PERFORMANCE OF THIS SOFTWARE.
114
114
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
115
115
  * SOFTWARE.
116
116
  *
117
- */const nf="crypto.algorithm";class ZB{getAlgorithms(){return jr.resolveAll(nf)}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 je({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 ec="crypto.algorithmProvider";jr.registerSingleton(ec,ZB);var im;const dn="1.3.36.3.3.2.8.1.1",vS=`${dn}.1`,bS=`${dn}.2`,_S=`${dn}.3`,wS=`${dn}.4`,xS=`${dn}.5`,kS=`${dn}.6`,SS=`${dn}.7`,AS=`${dn}.8`,OS=`${dn}.9`,jS=`${dn}.10`,CS=`${dn}.11`,ES=`${dn}.12`,IS=`${dn}.13`,TS=`${dn}.14`,NS="brainpoolP160r1",BS="brainpoolP160t1",RS="brainpoolP192r1",PS="brainpoolP192t1",$S="brainpoolP224r1",ZS="brainpoolP224t1",DS="brainpoolP256r1",MS="brainpoolP256t1",US="brainpoolP320r1",VS="brainpoolP320t1",LS="brainpoolP384r1",qS="brainpoolP384t1",HS="brainpoolP512r1",FS="brainpoolP512t1",sr="ECDSA";let mh=im=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case sr.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return oB;case"sha-256":return cB;case"sha-384":return uB;case"sha-512":return lB}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=G2;break;case"K-256":t=im.SECP256K1;break;case"P-384":t=J2;break;case"P-521":t=Y2;break;case NS:t=vS;break;case BS:t=bS;break;case RS:t=_S;break;case PS:t=wS;break;case $S:t=xS;break;case ZS:t=kS;break;case DS:t=SS;break;case MS:t=AS;break;case US:t=OS;break;case VS:t=jS;break;case LS:t=CS;break;case qS:t=ES;break;case HS:t=IS;break;case FS:t=TS;break}if(t)return new je({algorithm:hh,parameters:oe.serialize(new Na({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Qx:return{name:sr,hash:{name:"SHA-1"}};case ek:return{name:sr,hash:{name:"SHA-256"}};case tk:return{name:sr,hash:{name:"SHA-384"}};case rk:return{name:sr,hash:{name:"SHA-512"}};case hh:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(oe.parse(e.parameters,Na).namedCurve){case G2:return{name:sr,namedCurve:"P-256"};case im.SECP256K1:return{name:sr,namedCurve:"K-256"};case J2:return{name:sr,namedCurve:"P-384"};case Y2:return{name:sr,namedCurve:"P-521"};case vS:return{name:sr,namedCurve:NS};case bS:return{name:sr,namedCurve:BS};case _S:return{name:sr,namedCurve:RS};case wS:return{name:sr,namedCurve:PS};case xS:return{name:sr,namedCurve:$S};case kS:return{name:sr,namedCurve:ZS};case SS:return{name:sr,namedCurve:DS};case AS:return{name:sr,namedCurve:MS};case OS:return{name:sr,namedCurve:US};case jS:return{name:sr,namedCurve:VS};case CS:return{name:sr,namedCurve:LS};case ES:return{name:sr,namedCurve:qS};case IS:return{name:sr,namedCurve:HS};case TS:return{name:sr,namedCurve:FS}}}}return null}};mh.SECP256K1="1.3.132.0.10";mh=im=p([Tv()],mh);jr.registerSingleton(nf,mh);const EC=Symbol("name"),IC=Symbol("value");class Ft{constructor(e,t={},n=""){this[EC]=e,this[IC]=n;for(const s in t)this[s]=t[s]}}Ft.NAME=EC;Ft.VALUE=IC;class DB{static toTextObject(e){const t=new Ft("Algorithm Identifier",{},Xa.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case hh:{const n=new mh().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class Xa{static toString(e){const t=this.items[e];return t||e}}Xa.items={[fy]:"sha1",[yC]:"sha224",[my]:"sha256",[yy]:"sha384",[gy]:"sha512",[Yo]:"rsaEncryption",[dy]:"sha1WithRSAEncryption",[yB]:"sha224WithRSAEncryption",[V1]:"sha256WithRSAEncryption",[hy]:"sha384WithRSAEncryption",[py]:"sha512WithRSAEncryption",[hh]:"ecPublicKey",[Qx]:"ecdsaWithSHA1",[pC]:"ecdsaWithSHA224",[ek]:"ecdsaWithSHA256",[tk]:"ecdsaWithSHA384",[rk]:"ecdsaWithSHA512",[eB]:"TLS WWW server authentication",[tB]:"TLS WWW client authentication",[rB]:"Code Signing",[nB]:"E-mail Protection",[sB]:"Time Stamping",[iB]:"OCSP Signing",[aB]:"Signed Data"};class tc{static serialize(e){return this.serializeObj(e).join(`
118
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let s=this.pad(t++),i="";const a=e[Ft.VALUE];a&&(i=` ${a}`),n.push(`${s}${e[Ft.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 l of c)l[Ft.NAME]=o,n.push(...this.serializeObj(l,t));else if(c instanceof Ft)c[Ft.NAME]=o,n.push(...this.serializeObj(c,t));else if(le.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 l=c.toTextObject();l[Ft.NAME]=o,n.push(...this.serializeObj(l,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=le.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)}}tc.oidSerializer=Xa;tc.algorithmSerializer=DB;class Qa{constructor(...e){if(e.length===1){const t=e[0];this.rawData=oe.serialize(t),this.onInit(t)}else{const t=oe.parse(e[0],e[1]);this.rawData=le.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Qa?Gj(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return oe.toString(this.rawData);case"text":return tc.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 Ft(this.getTextName(),{},e)}}Qa.NAME="ASN";class Hn extends Qa{constructor(...e){let t;le.isBufferSource(e[0])?t=le.toArrayBuffer(e[0]):t=oe.serialize(new Un({extnID:e[0],critical:e[1],extnValue:new qt(le.toArrayBuffer(e[2]))})),super(t,Un)}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[Ft.NAME]===Hn.NAME&&(e[Ft.NAME]=Xa.toString(this.type)),e}}var TC;class ga{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[TC]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(ga.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(ga.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=ga.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(ga.DEFAULT,e);return this}}TC=Symbol.toStringTag;ga.DEFAULT="default";const _r=new ga,MB=/^[0-2](?:\.[1-9][0-9]*)+$/;function UB(r){return new RegExp(MB).test(r)}class NC{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return UB(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const on=new NC;on.register("CN","2.5.4.3");on.register("L","2.5.4.7");on.register("ST","2.5.4.8");on.register("O","2.5.4.10");on.register("OU","2.5.4.11");on.register("C","2.5.4.6");on.register("DC","0.9.2342.19200300.100.1.25");on.register("E","1.2.840.113549.1.9.1");on.register("G","2.5.4.42");on.register("I","2.5.4.43");on.register("SN","2.5.4.4");on.register("T","2.5.4.12");function VB(r,e){return`\\${Ne.ToHex(Ne.FromUtf8String(e)).toUpperCase()}`}function LB(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,VB)}class Rn{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 NC,this.asn=new pr;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 pr?this.asn=e:le.isBufferSource(e)?this.asn=oe.parse(e,pr):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||on.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)||on.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)}`:LB(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 pr,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 l=this.createAttribute(a,o);i==="+"?t[t.length-1].push(l):t.push(new Au([l])),i=u}return t}fromJSON(e){const t=new pr;for(const n of e){const s=new Au;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 dv({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:Rn.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,`
119
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return oe.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]||_r.get()):n=e[0]||_r.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const BC="Cannot initialize GeneralName from ASN.1 data.",KS=`${BC} Unsupported string format in use.`,qB=`${BC} Value doesn't match to GUID regular expression.`,zS=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,WS="1.3.6.1.4.1.311.25.1",GS="1.3.6.1.4.1.311.20.2.3",J0="dns",Y0="dn",X0="email",Q0="ip",eb="url",tb="guid",rb="upn",Tf="id";class va extends Qa{constructor(...e){let t;if(e.length===2)switch(e[0]){case Y0:{const n=new Rn(e[1]).toArrayBuffer(),s=oe.parse(n,pr);t=new dt({directoryName:s});break}case J0:t=new dt({dNSName:e[1]});break;case X0:t=new dt({rfc822Name:e[1]});break;case tb:{const n=new RegExp(zS,"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 dt({otherName:new ch({typeId:WS,value:oe.serialize(new qt(Ne.FromHex(s)))})});break}case Q0:t=new dt({iPAddress:e[1]});break;case Tf:t=new dt({registeredID:e[1]});break;case rb:{t=new dt({otherName:new ch({typeId:GS,value:oe.serialize(G3.toASN(e[1]))})});break}case eb:t=new dt({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else le.isBufferSource(e[0])?t=oe.parse(e[0],dt):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=J0,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=X0,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Q0,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=eb,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Tf,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Y0,this.value=new Rn(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===WS){this.type=tb;const t=oe.parse(e.otherName.value,qt),n=new RegExp(zS,"i").exec(Ne.ToHex(t));if(!n)throw new Error(qB);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===GS)this.type=rb,this.value=oe.parse(e.otherName.value,Or).toString();else throw new Error(KS);else throw new Error(KS)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Y0:case J0:case tb:case Q0:case Tf:case rb:case eb:e=this.type.toUpperCase();break;case X0:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===Tf&&(t=Xa.toString(t)),new Ft(e,void 0,t)}}class yh extends Qa{constructor(e){let t;if(e instanceof Mr)t=e;else if(Array.isArray(e)){const n=[];for(const s of e)if(s instanceof dt)n.push(s);else{const i=oe.parse(new va(s.type,s.value).rawData,dt);n.push(i)}t=new Mr(n)}else if(le.isBufferSource(e))t=oe.parse(e,Mr);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 va(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[Ft.NAME]];Array.isArray(s)||(s=[],e[n[Ft.NAME]]=s),s.push(n)}return e}}yh.NAME="GeneralNames";const wd="-{5}",gh="\\n",HB=`[^${gh}]+`,FB=`${wd}BEGIN (${HB}(?=${wd}))${wd}`,KB=`${wd}END \\1${wd}`,Bu="\\n",zB=`[^:${gh}]+`,WB=`(?:[^${gh}]+${Bu}(?: +[^${gh}]+${Bu})*)`,GB="[a-zA-Z0-9=+/]+",JB=`(?:${GB}${Bu})+`,JS=`${FB}${Bu}(?:((?:${zB}: ${WB})+))?${Bu}?(${JB})${KB}`;class vn{static isPem(e){return typeof e=="string"&&new RegExp(JS,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(JS,"g"),n=[];let s=null;for(;s=t.exec(e);){const i=s[3].replace(new RegExp(`[${gh}]+`,"g"),""),a={type:s[1],headers:[],rawData:Ne.FromBase64(i)},o=s[2];if(o){const c=o.split(new RegExp(Bu,"g"));let u=null;for(const l of c){const[h,R]=l.split(/:(.*)/);if(R===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=h.trim()}else u&&a.headers.push(u),u={key:h,value:R.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(!le.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:le.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(`
120
- `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:le.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(`
121
- `)}}vn.CertificateTag="CERTIFICATE";vn.CrlTag="CRL";vn.CertificateRequestTag="CERTIFICATE REQUEST";vn.PublicKeyTag="PUBLIC KEY";vn.PrivateKeyTag="PRIVATE KEY";class Ni extends Qa{static isAsnEncoded(e){return le.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(vn.isPem(e))return vn.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 vn.isPem(t)?vn.decode(t)[0]:Ne.isHex(t)?Ne.FromHex(t):Ne.isBase64(t)?Ne.FromBase64(t):Ne.isBase64Url(t)?Ne.FromBase64Url(t):le.toArrayBuffer(e)}}constructor(...e){Ni.isAsnEncoded(e[0])?super(Ni.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return vn.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ps extends Ni{static async create(e,t=_r.get()){if(e instanceof ps)return e;if(ga.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new ps(n)}else{if(e.publicKey)return e.publicKey;if(le.isBufferSource(e))return new ps(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Ni.isAsnEncoded(e)?super(e,as):super(e),this.tag=vn.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]||_r.get()):t=e[0]||_r.get();let i=this.rawData;const a=oe.parse(this.rawData,as);return a.algorithm.algorithm===_d&&(i=YB(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=jr.resolve(ec),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Yo:{const s=oe.parse(e.subjectPublicKey,nk),i=le.toUint8Array(s.modulus);n.publicExponent=le.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]||_r.get()):n=e[0]||_r.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=_r.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=_r.get();const s=oe.parse(this.rawData,as);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=oe.parse(this.rawData,as);switch(e.Algorithm=tc.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case hh:e["EC Point"]=t.subjectPublicKey;break;case Yo:default:e["Raw Data"]=t.subjectPublicKey}return e}}function YB(r,e){return r.algorithm=new je({algorithm:Yo,parameters:null}),e=oe.serialize(r),e}class vh extends Hn{static async create(e,t=!1,n=_r.get()){if("name"in e&&"serialNumber"in e)return new vh(e,t);const i=await(await ps.create(e,n)).getKeyIdentifier(n);return new vh(Ne.ToHex(i),t)}constructor(...e){if(le.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new xo({keyIdentifier:new Dx(Ne.FromHex(e[0]))});super(i1,e[1],oe.serialize(t))}else{const t=e[0],n=t.name instanceof yh?oe.parse(t.name.rawData,Mr):t.name,s=new xo({authorityCertIssuer:n,authorityCertSerialNumber:Ne.FromHex(t.serialNumber)});super(i1,e[1],oe.serialize(s))}}onInit(e){super.onInit(e);const t=oe.parse(e.extnValue,xo);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=oe.parse(this.value,xo);return t.authorityCertIssuer&&(e["Authority Issuer"]=new yh(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}vh.NAME="Authority Key Identifier";class ok extends Hn{constructor(...e){if(le.isBufferSource(e[0])){super(e[0]);const t=oe.parse(this.value,zm);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new zm({cA:e[0],pathLenConstraint:e[1]});super(X3,e[2],oe.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}}ok.NAME="Basic Constraints";var YS;(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"})(YS||(YS={}));class ck extends Hn{constructor(...e){if(le.isBufferSource(e[0])){super(e[0]);const t=oe.parse(this.value,Ym);this.usages=t.map(n=>n)}else{const t=new Ym(e[0]);super(tC,e[1],oe.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Xa.toString(t)).join(", "),e}}ck.NAME="Extended Key Usages";var ky;(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"})(ky||(ky={}));class uk extends Hn{constructor(...e){if(le.isBufferSource(e[0])){super(e[0]);const t=oe.parse(this.value,G0);this.usages=t.toNumber()}else{const t=new G0(e[0]);super(rC,e[1],oe.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=oe.parse(this.value,G0);return e[""]=t.toJSON().join(", "),e}}uk.NAME="Key Usages";class sf extends Hn{static async create(e,t=!1,n=_r.get()){const i=await(await ps.create(e,n)).getKeyIdentifier(n);return new sf(Ne.ToHex(i),t)}constructor(...e){if(le.isBufferSource(e[0])){super(e[0]);const t=oe.parse(this.value,xa);this.keyId=Ne.ToHex(t)}else{const t=typeof e[0]=="string"?Ne.FromHex(e[0]):e[0],n=new xa(t);super(aC,e[1],oe.serialize(n)),this.keyId=Ne.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=oe.parse(this.value,xa);return e[""]=t,e}}sf.NAME="Subject Key Identifier";class RC extends Hn{constructor(...e){le.isBufferSource(e[0])?super(e[0]):super(iC,e[1],new yh(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=oe.parse(e.extnValue,_1);this.names=new yh(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}RC.NAME="Subject Alternative Name";class Fn{static register(e,t){this.items.set(e,t)}static create(e){const t=new Hn(e),n=this.items.get(t.type);return n?new n(e):t}}Fn.items=new Map;class PC extends Hn{constructor(...e){var t;if(le.isBufferSource(e[0])){super(e[0]);const n=oe.parse(this.value,Gm);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new Gm(n.map(a=>new pv({policyIdentifier:a})));super(Q3,s,oe.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Ft("",{},Xa.toString(t))),e}}PC.NAME="Certificate Policies";Fn.register(Q3,PC);class $C extends Hn{constructor(...e){var t;if(le.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const s=e[0].map(a=>new cl({distributionPoint:new zo({fullName:[new dt({uniformResourceIdentifier:a})]})})),i=new iu(s);super(l1,e[1],oe.serialize(i))}else{const n=new iu(e[0]);super(l1,e[1],oe.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=oe.parse(e.extnValue,iu);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 va(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}$C.NAME="CRL Distribution Points";class ZC extends Hn{constructor(...e){var t,n,s,i;if(le.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Xc){const a=new Xc(e[0]);super(s1,e[1],oe.serialize(a))}else{const a=e[0],o=new Xc;Bf(o,a,R2,"ocsp"),Bf(o,a,P2,"caIssuers"),Bf(o,a,$2,"timeStamping"),Bf(o,a,Z2,"caRepository"),super(s1,e[1],oe.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=[],oe.parse(e.extnValue,Xc).forEach(n=>{switch(n.accessMethod){case R2:this.ocsp.push(new va(n.accessLocation));break;case P2:this.caIssuers.push(new va(n.accessLocation));break;case $2:this.timeStamping.push(new va(n.accessLocation));break;case Z2:this.caRepository.push(new va(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Nf(e,"OCSP",this.ocsp),this.caIssuers.length&&Nf(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Nf(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Nf(e,"CA Repository",this.caRepository),e}}ZC.NAME="Authority Info Access";function Nf(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new Ft("");t.forEach((s,i)=>{const a=s.toTextObject(),o=`${a[Ft.NAME]} ${i+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function Bf(r,e,t,n){const s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new va("url",a)),r.push(new Fp({accessMethod:t,accessLocation:oe.parse(a.rawData,dt)}))})}class ml extends Qa{constructor(...e){let t;if(le.isBufferSource(e[0]))t=le.toArrayBuffer(e[0]);else{const n=e[0],s=Array.isArray(e[1])?e[1].map(i=>le.toArrayBuffer(i)):[];t=oe.serialize(new Ei({type:n,values:s}))}super(t,Ei)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Ft("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[Ft.NAME]===ml.NAME&&(e[Ft.NAME]=Xa.toString(this.type)),e}}ml.NAME="Attribute";class DC extends ml{constructor(...e){var t;if(le.isBufferSource(e[0]))super(e[0]);else{const n=new wy({printableString:e[0]});super(CC,[oe.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=oe.parse(this.values[0],wy);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Ft.VALUE]=this.password,e}}DC.NAME="Challenge Password";class lk extends ml{constructor(...e){var t;if(le.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new Ia;for(const i of n)s.push(oe.parse(i.rawData,Un));super(ak,[oe.serialize(s)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=oe.parse(this.values[0],Ia);this.items=t.map(n=>Fn.create(oe.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[Ft.NAME]]=n;return e}}lk.NAME="Extensions";class $v{static register(e,t){this.items.set(e,t)}static create(e){const t=new ml(e),n=this.items.get(t.type);return n?new n(e):t}}$v.items=new Map;const af="crypto.signatureFormatter";class XB{toAsnSignature(e,t){return le.toArrayBuffer(t)}toWebSignature(e,t){return le.toArrayBuffer(t)}}var am;let l_=am=class{static createPssParams(e,t){const n=am.getHashAlgorithm(e);return n?new Qo({hashAlgorithm:n,maskGenAlgorithm:new je({algorithm:jv,parameters:oe.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=jr.resolve(ec);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 je({algorithm:dy,parameters:null});case"sha-256":return new je({algorithm:V1,parameters:null});case"sha-384":return new je({algorithm:hy,parameters:null});case"sha-512":return new je({algorithm:py,parameters:null})}}else return new je({algorithm:Yo,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=am.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new je({algorithm:_d,parameters:oe.serialize(t)})}else return new je({algorithm:_d,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Yo:return{name:"RSASSA-PKCS1-v1_5"};case dy:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case V1:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case hy:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case py:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case _d:if(e.parameters){const t=oe.parse(e.parameters,Qo);return{name:"RSA-PSS",hash:jr.resolve(ec).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};l_=am=p([Tv()],l_);jr.registerSingleton(nf,l_);let d_=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new je({algorithm:fy});case"sha-256":return new je({algorithm:my});case"sha-384":return new je({algorithm:yy});case"sha-512":return new je({algorithm:gy})}return null}toWebAlgorithm(e){switch(e.algorithm){case fy:return{name:"SHA-1"};case my:return{name:"SHA-256"};case yy:return{name:"SHA-384"};case gy:return{name:"SHA-512"}}return null}};d_=p([Tv()],d_);jr.registerSingleton(nf,d_);class Pn{addPadding(e,t){const n=le.toUint8Array(t),s=new Uint8Array(e);return s.set(n,e-n.length),s}removePadding(e,t=!1){let n=le.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=Pn.namedCurveSize.get(n)||Pn.defaultNamedCurveSize,i=new ly,a=le.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),oe.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=oe.parse(t,ly),s=e.namedCurve,i=Pn.namedCurveSize.get(s)||Pn.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return d9(a,o)}return null}}Pn.namedCurveSize=new Map;Pn.defaultNamedCurveSize=32;const nb="1.3.101.110",XS="1.3.101.111",sb="1.3.101.112",QS="1.3.101.113";let h_=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=sb;break;case"x25519":t=nb;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=sb;break;case"ed448":t=QS;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=nb;break;case"x448":t=XS;break}}return t?new je({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case sb:return{name:"Ed25519"};case QS:return{name:"EdDSA",namedCurve:"Ed448"};case nb:return{name:"X25519"};case XS:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};h_=p([Tv()],h_);jr.registerSingleton(nf,h_);class QB extends Ni{constructor(e){Ni.isAsnEncoded(e)?super(e,fh):super(e),this.tag=vn.CertificateRequestTag}onInit(e){this.tbs=oe.serialize(e.certificationRequestInfo),this.publicKey=new ps(e.certificationRequestInfo.subjectPKInfo);const t=jr.resolve(ec);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>$v.create(oe.serialize(s)));const n=this.getAttribute(ak);this.extensions=[],n instanceof lk&&(this.extensions=n.items),this.subjectName=new Rn(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=_r.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),s=jr.resolveAll(af).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=oe.parse(this.rawData,fh),n=t.certificationRequestInfo,s=new Ft("",{Version:`${Wo[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new Ft("");for(const a of this.attributes){const o=a.toTextObject();i[o[Ft.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new Ft("",{Algorithm:tc.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}QB.NAME="PKCS#10 Certificate Request";class dk extends Ni{constructor(e){Ni.isAsnEncoded(e)?super(e,Go):super(e),this.tag=vn.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=oe.serialize(t),this.serialNumber=Ne.ToHex(t.serialNumber),this.subjectName=new Rn(t.subject),this.subject=new Rn(t.subject).toString(),this.issuerName=new Rn(t.issuer),this.issuer=this.issuerName.toString();const n=jr.resolve(ec);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=>Fn.create(oe.serialize(a)))),this.publicKey=new ps(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=_r.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 ps)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(le.isBufferSource(i)){const u=new ps(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=jr.resolveAll(af).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 l=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<l&&l<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=_r.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=_r.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=oe.parse(this.rawData,Go),n=t.tbsCertificate,s=new Ft("",{Version:`${Wo[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":tc.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Ft("",{"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 Ft("");for(const a of this.extensions){const o=a.toTextObject();i[o[Ft.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new Ft("",{Algorithm:tc.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}dk.NAME="Certificate";class eR{static async createSelfSigned(e,t=_r.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=_r.get()){var n;let s;e.publicKey instanceof ps?s=e.publicKey.rawData:"publicKey"in e.publicKey?s=e.publicKey.publicKey.rawData:le.isBufferSource(e.publicKey)?s=e.publicKey:s=await t.subtle.exportKey("spki",e.publicKey);const i=e.serialNumber?le.toUint8Array(Ne.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));i[0]>127&&(i[0]&=127),i.length>1&&i[0]===0&&(i[1]|=128);const a=e.notBefore||new Date,o=e.notAfter||new Date(a.getTime()+31536e6),c=new Go({tbsCertificate:new An({version:Wo.v3,serialNumber:i,validity:new Kp({notBefore:a,notAfter:o}),extensions:new Ia(((n=e.extensions)===null||n===void 0?void 0:n.map(A=>oe.parse(A.rawData,Un)))||[]),subjectPublicKeyInfo:oe.parse(s,as)})});if(e.subject){const A=e.subject instanceof Rn?e.subject:new Rn(e.subject);c.tbsCertificate.subject=oe.parse(A.toArrayBuffer(),pr)}if(e.issuer){const A=e.issuer instanceof Rn?e.issuer:new Rn(e.issuer);c.tbsCertificate.issuer=oe.parse(A.toArrayBuffer(),pr)}const u={hash:"SHA-256"},l="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},h=jr.resolve(ec);c.tbsCertificate.signature=c.signatureAlgorithm=h.toAsnAlgorithm(l);const R=oe.serialize(c.tbsCertificate),B="signingKey"in e?await t.subtle.sign(l,e.signingKey,R):e.signature,d=jr.resolveAll(af).reverse();let g=null;for(const A of d)if(g=A.toAsnSignature(l,B),g)break;if(!g)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=g,new dk(oe.serialize(c))}}var eA;(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"})(eA||(eA={}));Fn.register(X3,ok);Fn.register(tC,ck);Fn.register(rC,uk);Fn.register(aC,sf);Fn.register(i1,vh);Fn.register(iC,RC);Fn.register(l1,$C);Fn.register(s1,ZC);$v.register(CC,DC);$v.register(ak,lk);jr.registerSingleton(af,XB);jr.registerSingleton(af,Pn);Pn.namedCurveSize.set("P-256",32);Pn.namedCurveSize.set("K-256",32);Pn.namedCurveSize.set("P-384",48);Pn.namedCurveSize.set("P-521",66);const tA="0123456789abcdef";function p_(r){const e=new Uint8Array(r);let t="";for(let n=0;n<e.length;n++){const s=e[n]>>4;t+=tA[s];const i=e[n]&15;t+=tA[i]}return t}class MC{constructor(e,t){Pe(this,"alphabet");Pe(this,"padding");Pe(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",s=0,i=0;for(let o=0;o<e.length;o++)for(s=s<<8|e[o],i+=8;i>=5;)i-=5,n+=this.alphabet[s>>i&31];if(i>0&&(n+=this.alphabet[s<<5-i&31]),(t==null?void 0:t.includePadding)??!0){const o=(8-n.length%8)%8;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,s=Math.ceil(e.length/8),i=[];for(let a=0;a<s;a++){let o=0;const c=[];for(let l=0;l<8;l++){const h=e[a*8+l];if(h==="="){if(a+1!==s)throw new Error(`Invalid character: ${h}`);o+=1;continue}if(h===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const R=this.decodeMap.get(h)??null;if(R===null)throw new Error(`Invalid character: ${h}`);c.push(R)}if(o===8||o===7||o===5||o===2)throw new Error("Invalid padding");const u=(c[0]<<3)+(c[1]>>2);if(i.push(u),o<6){const l=((c[1]&3)<<6)+(c[2]<<1)+(c[3]>>4);i.push(l)}if(o<4){const l=((c[3]&255)<<4)+(c[4]>>1);i.push(l)}if(o<3){const l=((c[4]&1)<<7)+(c[5]<<2)+(c[6]>>3);i.push(l)}if(o<1){const l=((c[6]&7)<<5)+c[7];i.push(l)}}return Uint8Array.from(i)}}new MC("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new MC("0123456789ABCDEFGHIJKLMNOPQRSTUV");class UC{constructor(e,t){Pe(this,"alphabet");Pe(this,"padding");Pe(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",s=0,i=0;for(let o=0;o<e.length;o++)for(s=s<<8|e[o],i+=8;i>=6;)i+=-6,n+=this.alphabet[s>>i&63];if(i>0&&(n+=this.alphabet[s<<6-i&63]),(t==null?void 0:t.includePadding)??!0){const o=(4-n.length%4)%4;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,s=Math.ceil(e.length/4),i=[];for(let a=0;a<s;a++){let o=0,c=0;for(let u=0;u<4;u++){const l=e[a*4+u];if(l==="="){if(a+1!==s)throw new Error(`Invalid character: ${l}`);o+=1;continue}if(l===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const h=this.decodeMap.get(l)??null;if(h===null)throw new Error(`Invalid character: ${l}`);c+=h<<6*(3-u)}i.push(c>>16&255),o<2&&i.push(c>>8&255),o<1&&i.push(c&255)}return Uint8Array.from(i)}}const tR=new UC("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),om=new UC("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class rR{constructor(e){Pe(this,"hash");this.hash=e}async verify(e,t,n){const s=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",s,t,n)}async sign(e,t){const n=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",n,t)}async generateKeyPair(e){const t=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),n=await crypto.subtle.exportKey("pkcs8",t.privateKey),s=await crypto.subtle.exportKey("spki",t.publicKey);return{privateKey:n,publicKey:s}}}async function VC(r){return await crypto.subtle.digest("SHA-256",r)}async function f_(r){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},t=await crypto.subtle.generateKey(e,!0,["sign","verify"]),n=qm(),s=p_(new TextEncoder().encode(n)),i=await eR.createSelfSigned({serialNumber:s,name:r.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:t,extensions:[new ok(!0,2,!0),new ck(["1.3.6.1.5.5.7.3.1"],!0),new uk(ky.keyCertSign|ky.cRLSign,!0),await sf.create(t.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",t.privateKey),o=i.toString("pem"),c=await sR(i),u=p_(await i.getThumbprint()),l=nR("PRIVATE",a);return{kid:i.serialNumber,cert:o,thumbprint:u,fingerprint:c,pkcs7:l}}function nR(r,e){const t=tR.encode(new Uint8Array(e));let n=`-----BEGIN ${r} KEY-----\r
122
- `,s=0;for(;s<t.length;)s+64<=t.length?n+=t.substr(s,64)+`\r
123
- `:n+=t.substr(s)+`\r
124
- `,s+=64;return n+=`-----END ${r} KEY-----\r
125
- `,n}async function sR(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),i=new TextEncoder().encode(n);return p_(await VC(i))}const iR=1e3*60*60*24,aR=new Sr().openapi(ct({tags:["keys"],method:"get",path:"/signing",request:{headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:T.array(Gb)}},description:"List of keys"}}}),async r=>{const t=(await r.env.data.keys.list()).filter(n=>"cert"in n).map(n=>n);return r.json(t)}).openapi(ct({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({kid:T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Gb}},description:"The requested key"}}}),async r=>{const{kid:e}=r.req.valid("param"),n=(await r.env.data.keys.list()).find(s=>s.kid===e);if(!n)throw new nt(404,{message:"Key not found"});return r.json(n)}).openapi(ct({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const e=await r.env.data.keys.list();for await(const n of e)await r.env.data.keys.update(n.kid,{revoked_at:new Date(Date.now()+iR).toISOString()});const t=await f_({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ct({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({kid:T.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const{kid:e}=r.req.valid("param");if(!await r.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new nt(404,{message:"Key not found"});const n=await f_({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),oR=new Sr().openapi(ct({tags:["users"],method:"get",path:"/",request:{query:T.object({email:T.string()}),headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:T.array(gx)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),s=(await zj(r.env.data.users,e,t)).filter(i=>!i.linked_to);return r.json(s)}),cR=Ja.extend({clients:T.array(bo)}),uR=new Sr().openapi(ct({tags:["clients"],method:"get",path:"/",request:{query:qo,headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:T.union([cR,T.array(bo)])}},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:il(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ct({tags:["clients"],method:"get",path:"/{id}",request:{params:T.object({id:T.string()}),headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:bo}},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 nt(404);return r.json(s)}).openapi(ct({tags:["clients"],method:"delete",path:"/{id}",request:{params:T.object({id:T.string()}),headers:T.object({"tenant-id":T.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 nt(404,{message:"Application not found"});return r.text("OK")}).openapi(ct({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:T.object($m.shape).partial()}}},params:T.object({id:T.string()}),headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:bo}},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 nt(404,{message:"Application not found"});return r.json(i)}).openapi(ct({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:T.object($m.shape)}}},headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:T.object(bo.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||qm(),client_secret:t.client_secret||qm()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var Mt;(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})(Mt||(Mt={}));var m_;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(m_||(m_={}));const ke=Mt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oa=r=>{switch(typeof r){case"undefined":return ke.undefined;case"string":return ke.string;case"number":return isNaN(r)?ke.nan:ke.number;case"boolean":return ke.boolean;case"function":return ke.function;case"bigint":return ke.bigint;case"symbol":return ke.symbol;case"object":return Array.isArray(r)?ke.array:r===null?ke.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ke.promise:typeof Map<"u"&&r instanceof Map?ke.map:typeof Set<"u"&&r instanceof Set?ke.set:typeof Date<"u"&&r instanceof Date?ke.date:ke.object;default:return ke.unknown}},re=Mt.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"]),lR=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class wn 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 wn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Mt.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()}}wn.create=r=>new wn(r);const Ru=(r,e)=>{let t;switch(r.code){case re.invalid_type:r.received===ke.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case re.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Mt.jsonStringifyReplacer)}`;break;case re.unrecognized_keys:t=`Unrecognized key(s) in object: ${Mt.joinValues(r.keys,", ")}`;break;case re.invalid_union:t="Invalid input";break;case re.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Mt.joinValues(r.options)}`;break;case re.invalid_enum_value:t=`Invalid enum value. Expected ${Mt.joinValues(r.options)}, received '${r.received}'`;break;case re.invalid_arguments:t="Invalid function arguments";break;case re.invalid_return_type:t="Invalid function return type";break;case re.invalid_date:t="Invalid date";break;case re.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}"`:Mt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case re.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 re.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 re.custom:t="Invalid input";break;case re.invalid_intersection_types:t="Intersection results could not be merged";break;case re.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case re.not_finite:t="Number must be finite";break;default:t=e.defaultError,Mt.assertNever(r)}return{message:t}};let LC=Ru;function dR(r){LC=r}function Sy(){return LC}const Ay=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}},hR=[];function ge(r,e){const t=Sy(),n=Ay({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ru?void 0:Ru].filter(s=>!!s)});r.common.issues.push(n)}class Br{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 rt;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 Br.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 rt;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 rt=Object.freeze({status:"aborted"}),Qc=r=>({status:"dirty",value:r}),qr=r=>({status:"valid",value:r}),y_=r=>r.status==="aborted",g_=r=>r.status==="dirty",bh=r=>r.status==="valid",_h=r=>typeof Promise<"u"&&r instanceof Promise;function Oy(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 qC(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 Ue;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ue||(Ue={}));var rd,nd;class Gs{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 rA=(r,e)=>{if(bh(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 wn(r.common.issues);return this._error=t,this._error}}};function yt(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:l}=r;return a.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(c=l??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class jt{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 oa(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:oa(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Br,ctx:{common:e.parent.common,data:e.data,parsedType:oa(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(_h(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:oa(e)},i=this._parseSync({data:e,path:s.path,parent:s});return rA(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:oa(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(_h(s)?s:Promise.resolve(s));return rA(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:re.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 ws({schema:this,typeName:Ye.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Us.create(this,this._def)}nullable(){return $a.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fs.create(this,this._def)}promise(){return $u.create(this,this._def)}or(e){return Sh.create([this,e],this._def)}and(e){return Ah.create(this,e,this._def)}transform(e){return new ws({...yt(this._def),schema:this,typeName:Ye.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ih({...yt(this._def),innerType:this,defaultValue:t,typeName:Ye.ZodDefault})}brand(){return new hk({typeName:Ye.ZodBranded,type:this,...yt(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Th({...yt(this._def),innerType:this,catchValue:t,typeName:Ye.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return of.create(this,e)}readonly(){return Nh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const pR=/^c[^\s-]{8,}$/i,fR=/^[0-9a-z]+$/,mR=/^[0-9A-HJKMNP-TV-Z]{26}$/,yR=/^[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,gR=/^[a-z0-9_-]{21}$/i,vR=/^[-+]?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)?)??$/,bR=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_R="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ib;const wR=/^(?:(?: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])$/,xR=/^(([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})))$/,kR=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,HC="((\\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])))",SR=new RegExp(`^${HC}$`);function FC(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 AR(r){return new RegExp(`^${FC(r)}$`)}function KC(r){let e=`${HC}T${FC(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 OR(r,e){return!!((e==="v4"||!e)&&wR.test(r)||(e==="v6"||!e)&&xR.test(r))}class os extends jt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ke.string){const i=this._getOrReturnCtx(e);return ge(i,{code:re.invalid_type,expected:ke.string,received:i.parsedType}),rt}const n=new Br;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),ge(s,{code:re.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),ge(s,{code:re.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?ge(s,{code:re.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&ge(s,{code:re.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")bR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"email",code:re.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")ib||(ib=new RegExp(_R,"u")),ib.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"emoji",code:re.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")yR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"uuid",code:re.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")gR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"nanoid",code:re.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")pR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"cuid",code:re.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")fR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"cuid2",code:re.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")mR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"ulid",code:re.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),ge(s,{validation:"url",code:re.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),ge(s,{validation:"regex",code:re.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),ge(s,{code:re.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),ge(s,{code:re.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),ge(s,{code:re.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?KC(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{code:re.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?SR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{code:re.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?AR(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{code:re.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?vR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"duration",code:re.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?OR(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"ip",code:re.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?kR.test(e.data)||(s=this._getOrReturnCtx(e,s),ge(s,{validation:"base64",code:re.invalid_string,message:i.message}),n.dirty()):Mt.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:re.invalid_string,...Ue.errToObj(n)})}_addCheck(e){return new os({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ue.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ue.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ue.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ue.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ue.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ue.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ue.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ue.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ue.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ue.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,...Ue.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,...Ue.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ue.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ue.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ue.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ue.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ue.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ue.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ue.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ue.errToObj(t)})}nonempty(e){return this.min(1,Ue.errToObj(e))}trim(){return new os({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new os({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new os({...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}}os.create=r=>{var e;return new os({checks:[],typeName:Ye.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...yt(r)})};function jR(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 Ba extends jt{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)!==ke.number){const i=this._getOrReturnCtx(e);return ge(i,{code:re.invalid_type,expected:ke.number,received:i.parsedType}),rt}let n;const s=new Br;for(const i of this._def.checks)i.kind==="int"?Mt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ge(n,{code:re.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),ge(n,{code:re.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),ge(n,{code:re.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?jR(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),ge(n,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ge(n,{code:re.not_finite,message:i.message}),s.dirty()):Mt.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ue.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ue.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ue.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ue.toString(t))}setLimit(e,t,n,s){return new Ba({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ue.toString(s)}]})}_addCheck(e){return new Ba({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ue.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ue.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ue.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ue.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ue.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ue.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"&&Mt.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)}}Ba.create=r=>new Ba({checks:[],typeName:Ye.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...yt(r)});class Ra extends jt{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)!==ke.bigint){const i=this._getOrReturnCtx(e);return ge(i,{code:re.invalid_type,expected:ke.bigint,received:i.parsedType}),rt}let n;const s=new Br;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),ge(n,{code:re.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),ge(n,{code:re.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),ge(n,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Mt.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ue.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ue.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ue.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ue.toString(t))}setLimit(e,t,n,s){return new Ra({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ue.toString(s)}]})}_addCheck(e){return new Ra({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ue.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ue.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ue.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}}Ra.create=r=>{var e;return new Ra({checks:[],typeName:Ye.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...yt(r)})};class wh extends jt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ke.boolean){const n=this._getOrReturnCtx(e);return ge(n,{code:re.invalid_type,expected:ke.boolean,received:n.parsedType}),rt}return qr(e.data)}}wh.create=r=>new wh({typeName:Ye.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...yt(r)});class rc extends jt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ke.date){const i=this._getOrReturnCtx(e);return ge(i,{code:re.invalid_type,expected:ke.date,received:i.parsedType}),rt}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return ge(i,{code:re.invalid_date}),rt}const n=new Br;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),ge(s,{code:re.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),ge(s,{code:re.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Mt.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new rc({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ue.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ue.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}}rc.create=r=>new rc({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Ye.ZodDate,...yt(r)});class jy extends jt{_parse(e){if(this._getType(e)!==ke.symbol){const n=this._getOrReturnCtx(e);return ge(n,{code:re.invalid_type,expected:ke.symbol,received:n.parsedType}),rt}return qr(e.data)}}jy.create=r=>new jy({typeName:Ye.ZodSymbol,...yt(r)});class xh extends jt{_parse(e){if(this._getType(e)!==ke.undefined){const n=this._getOrReturnCtx(e);return ge(n,{code:re.invalid_type,expected:ke.undefined,received:n.parsedType}),rt}return qr(e.data)}}xh.create=r=>new xh({typeName:Ye.ZodUndefined,...yt(r)});class kh extends jt{_parse(e){if(this._getType(e)!==ke.null){const n=this._getOrReturnCtx(e);return ge(n,{code:re.invalid_type,expected:ke.null,received:n.parsedType}),rt}return qr(e.data)}}kh.create=r=>new kh({typeName:Ye.ZodNull,...yt(r)});class Pu extends jt{constructor(){super(...arguments),this._any=!0}_parse(e){return qr(e.data)}}Pu.create=r=>new Pu({typeName:Ye.ZodAny,...yt(r)});class Po extends jt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return qr(e.data)}}Po.create=r=>new Po({typeName:Ye.ZodUnknown,...yt(r)});class Bi extends jt{_parse(e){const t=this._getOrReturnCtx(e);return ge(t,{code:re.invalid_type,expected:ke.never,received:t.parsedType}),rt}}Bi.create=r=>new Bi({typeName:Ye.ZodNever,...yt(r)});class Cy extends jt{_parse(e){if(this._getType(e)!==ke.undefined){const n=this._getOrReturnCtx(e);return ge(n,{code:re.invalid_type,expected:ke.void,received:n.parsedType}),rt}return qr(e.data)}}Cy.create=r=>new Cy({typeName:Ye.ZodVoid,...yt(r)});class fs extends jt{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==ke.array)return ge(t,{code:re.invalid_type,expected:ke.array,received:t.parsedType}),rt;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(ge(t,{code:a?re.too_big:re.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&&(ge(t,{code:re.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&&(ge(t,{code:re.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 Gs(t,a,t.path,o)))).then(a=>Br.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Gs(t,a,t.path,o)));return Br.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new fs({...this._def,minLength:{value:e,message:Ue.toString(t)}})}max(e,t){return new fs({...this._def,maxLength:{value:e,message:Ue.toString(t)}})}length(e,t){return new fs({...this._def,exactLength:{value:e,message:Ue.toString(t)}})}nonempty(e){return this.min(1,e)}}fs.create=(r,e)=>new fs({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Ye.ZodArray,...yt(e)});function Kc(r){if(r instanceof cr){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Us.create(Kc(n))}return new cr({...r._def,shape:()=>e})}else return r instanceof fs?new fs({...r._def,type:Kc(r.element)}):r instanceof Us?Us.create(Kc(r.unwrap())):r instanceof $a?$a.create(Kc(r.unwrap())):r instanceof Js?Js.create(r.items.map(e=>Kc(e))):r}class cr extends jt{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=Mt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ke.object){const u=this._getOrReturnCtx(e);return ge(u,{code:re.invalid_type,expected:ke.object,received:u.parsedType}),rt}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Bi&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const l=i[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Gs(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Bi){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(ge(s,{code:re.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 l of o){const h=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Gs(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const h=await l.key,R=await l.value;u.push({key:h,value:R,alwaysSet:l.alwaysSet})}return u}).then(u=>Br.mergeObjectSync(n,u)):Br.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Ue.errToObj,new cr({...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=Ue.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new cr({...this._def,unknownKeys:"strip"})}passthrough(){return new cr({...this._def,unknownKeys:"passthrough"})}extend(e){return new cr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new cr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ye.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new cr({...this._def,catchall:e})}pick(e){const t={};return Mt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new cr({...this._def,shape:()=>t})}omit(e){const t={};return Mt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new cr({...this._def,shape:()=>t})}deepPartial(){return Kc(this)}partial(e){const t={};return Mt.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new cr({...this._def,shape:()=>t})}required(e){const t={};return Mt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof Us;)i=i._def.innerType;t[n]=i}}),new cr({...this._def,shape:()=>t})}keyof(){return zC(Mt.objectKeys(this.shape))}}cr.create=(r,e)=>new cr({shape:()=>r,unknownKeys:"strip",catchall:Bi.create(),typeName:Ye.ZodObject,...yt(e)});cr.strictCreate=(r,e)=>new cr({shape:()=>r,unknownKeys:"strict",catchall:Bi.create(),typeName:Ye.ZodObject,...yt(e)});cr.lazycreate=(r,e)=>new cr({shape:r,unknownKeys:"strip",catchall:Bi.create(),typeName:Ye.ZodObject,...yt(e)});class Sh extends jt{_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 wn(o.ctx.common.issues));return ge(t,{code:re.invalid_union,unionErrors:a}),rt}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},l=c._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,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 wn(c));return ge(t,{code:re.invalid_union,unionErrors:o}),rt}}get options(){return this._def.options}}Sh.create=(r,e)=>new Sh({options:r,typeName:Ye.ZodUnion,...yt(e)});const hi=r=>r instanceof jh?hi(r.schema):r instanceof ws?hi(r.innerType()):r instanceof Ch?[r.value]:r instanceof Pa?r.options:r instanceof Eh?Mt.objectValues(r.enum):r instanceof Ih?hi(r._def.innerType):r instanceof xh?[void 0]:r instanceof kh?[null]:r instanceof Us?[void 0,...hi(r.unwrap())]:r instanceof $a?[null,...hi(r.unwrap())]:r instanceof hk||r instanceof Nh?hi(r.unwrap()):r instanceof Th?hi(r._def.innerType):[];class Zv extends jt{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.object)return ge(t,{code:re.invalid_type,expected:ke.object,received:t.parsedType}),rt;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}):(ge(t,{code:re.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),rt)}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=hi(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 Zv({typeName:Ye.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...yt(n)})}}function v_(r,e){const t=oa(r),n=oa(e);if(r===e)return{valid:!0,data:r};if(t===ke.object&&n===ke.object){const s=Mt.objectKeys(e),i=Mt.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=v_(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===ke.array&&n===ke.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=v_(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===ke.date&&n===ke.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Ah extends jt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(y_(i)||y_(a))return rt;const o=v_(i.value,a.value);return o.valid?((g_(i)||g_(a))&&t.dirty(),{status:t.value,value:o.data}):(ge(n,{code:re.invalid_intersection_types}),rt)};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}))}}Ah.create=(r,e,t)=>new Ah({left:r,right:e,typeName:Ye.ZodIntersection,...yt(t)});class Js extends jt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.array)return ge(n,{code:re.invalid_type,expected:ke.array,received:n.parsedType}),rt;if(n.data.length<this._def.items.length)return ge(n,{code:re.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),rt;!this._def.rest&&n.data.length>this._def.items.length&&(ge(n,{code:re.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 Gs(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>Br.mergeArray(t,a)):Br.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Js({...this._def,rest:e})}}Js.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Js({items:r,typeName:Ye.ZodTuple,rest:null,...yt(e)})};class Oh extends jt{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!==ke.object)return ge(n,{code:re.invalid_type,expected:ke.object,received:n.parsedType}),rt;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Gs(n,o,n.path,o)),value:a._parse(new Gs(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?Br.mergeObjectAsync(t,s):Br.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof jt?new Oh({keyType:e,valueType:t,typeName:Ye.ZodRecord,...yt(n)}):new Oh({keyType:os.create(),valueType:e,typeName:Ye.ZodRecord,...yt(t)})}}class Ey extends jt{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!==ke.map)return ge(n,{code:re.invalid_type,expected:ke.map,received:n.parsedType}),rt;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Gs(n,o,n.path,[u,"key"])),value:i._parse(new Gs(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,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return rt;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return rt;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}Ey.create=(r,e,t)=>new Ey({valueType:e,keyType:r,typeName:Ye.ZodMap,...yt(t)});class nc extends jt{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ke.set)return ge(n,{code:re.invalid_type,expected:ke.set,received:n.parsedType}),rt;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(ge(n,{code:re.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&&(ge(n,{code:re.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 l of c){if(l.status==="aborted")return rt;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Gs(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new nc({...this._def,minSize:{value:e,message:Ue.toString(t)}})}max(e,t){return new nc({...this._def,maxSize:{value:e,message:Ue.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}nc.create=(r,e)=>new nc({valueType:r,minSize:null,maxSize:null,typeName:Ye.ZodSet,...yt(e)});class au extends jt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.function)return ge(t,{code:re.invalid_type,expected:ke.function,received:t.parsedType}),rt;function n(o,c){return Ay({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sy(),Ru].filter(u=>!!u),issueData:{code:re.invalid_arguments,argumentsError:c}})}function s(o,c){return Ay({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sy(),Ru].filter(u=>!!u),issueData:{code:re.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof $u){const o=this;return qr(async function(...c){const u=new wn([]),l=await o._def.args.parseAsync(c,i).catch(B=>{throw u.addIssue(n(c,B)),u}),h=await Reflect.apply(a,this,l);return await o._def.returns._def.type.parseAsync(h,i).catch(B=>{throw u.addIssue(s(h,B)),u})})}else{const o=this;return qr(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new wn([n(c,u.error)]);const l=Reflect.apply(a,this,u.data),h=o._def.returns.safeParse(l,i);if(!h.success)throw new wn([s(l,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new au({...this._def,args:Js.create(e).rest(Po.create())})}returns(e){return new au({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new au({args:e||Js.create([]).rest(Po.create()),returns:t||Po.create(),typeName:Ye.ZodFunction,...yt(n)})}}class jh extends jt{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})}}jh.create=(r,e)=>new jh({getter:r,typeName:Ye.ZodLazy,...yt(e)});class Ch extends jt{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return ge(t,{received:t.data,code:re.invalid_literal,expected:this._def.value}),rt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ch.create=(r,e)=>new Ch({value:r,typeName:Ye.ZodLiteral,...yt(e)});function zC(r,e){return new Pa({values:r,typeName:Ye.ZodEnum,...yt(e)})}class Pa extends jt{constructor(){super(...arguments),rd.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return ge(t,{expected:Mt.joinValues(n),received:t.parsedType,code:re.invalid_type}),rt}if(Oy(this,rd)||qC(this,rd,new Set(this._def.values)),!Oy(this,rd).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return ge(t,{received:t.data,code:re.invalid_enum_value,options:n}),rt}return qr(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 Pa.create(e,{...this._def,...t})}exclude(e,t=this._def){return Pa.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}rd=new WeakMap;Pa.create=zC;class Eh extends jt{constructor(){super(...arguments),nd.set(this,void 0)}_parse(e){const t=Mt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ke.string&&n.parsedType!==ke.number){const s=Mt.objectValues(t);return ge(n,{expected:Mt.joinValues(s),received:n.parsedType,code:re.invalid_type}),rt}if(Oy(this,nd)||qC(this,nd,new Set(Mt.getValidEnumValues(this._def.values))),!Oy(this,nd).has(e.data)){const s=Mt.objectValues(t);return ge(n,{received:n.data,code:re.invalid_enum_value,options:s}),rt}return qr(e.data)}get enum(){return this._def.values}}nd=new WeakMap;Eh.create=(r,e)=>new Eh({values:r,typeName:Ye.ZodNativeEnum,...yt(e)});class $u extends jt{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ke.promise&&t.common.async===!1)return ge(t,{code:re.invalid_type,expected:ke.promise,received:t.parsedType}),rt;const n=t.parsedType===ke.promise?t.data:Promise.resolve(t.data);return qr(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}$u.create=(r,e)=>new $u({type:r,typeName:Ye.ZodPromise,...yt(e)});class ws extends jt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ye.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=>{ge(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 rt;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?rt:c.status==="dirty"||t.value==="dirty"?Qc(c.value):c});{if(t.value==="aborted")return rt;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?rt:o.status==="dirty"||t.value==="dirty"?Qc(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"?rt:(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"?rt:(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(!bh(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=>bh(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Mt.assertNever(s)}}ws.create=(r,e,t)=>new ws({schema:r,typeName:Ye.ZodEffects,effect:e,...yt(t)});ws.createWithPreprocess=(r,e,t)=>new ws({schema:e,effect:{type:"preprocess",transform:r},typeName:Ye.ZodEffects,...yt(t)});class Us extends jt{_parse(e){return this._getType(e)===ke.undefined?qr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Us.create=(r,e)=>new Us({innerType:r,typeName:Ye.ZodOptional,...yt(e)});class $a extends jt{_parse(e){return this._getType(e)===ke.null?qr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$a.create=(r,e)=>new $a({innerType:r,typeName:Ye.ZodNullable,...yt(e)});class Ih extends jt{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ke.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ih.create=(r,e)=>new Ih({innerType:r,typeName:Ye.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...yt(e)});class Th extends jt{_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 _h(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new wn(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new wn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Th.create=(r,e)=>new Th({innerType:r,typeName:Ye.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...yt(e)});class Iy extends jt{_parse(e){if(this._getType(e)!==ke.nan){const n=this._getOrReturnCtx(e);return ge(n,{code:re.invalid_type,expected:ke.nan,received:n.parsedType}),rt}return{status:"valid",value:e.data}}}Iy.create=r=>new Iy({typeName:Ye.ZodNaN,...yt(r)});const CR=Symbol("zod_brand");class hk extends jt{_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 of extends jt{_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"?rt:i.status==="dirty"?(t.dirty(),Qc(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"?rt: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 of({in:e,out:t,typeName:Ye.ZodPipeline})}}class Nh extends jt{_parse(e){const t=this._def.innerType._parse(e),n=s=>(bh(s)&&(s.value=Object.freeze(s.value)),s);return _h(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Nh.create=(r,e)=>new Nh({innerType:r,typeName:Ye.ZodReadonly,...yt(e)});function WC(r,e={},t){return r?Pu.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})}}):Pu.create()}const ER={object:cr.lazycreate};var Ye;(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"})(Ye||(Ye={}));const IR=(r,e={message:`Input not instance of ${r.name}`})=>WC(t=>t instanceof r,e),GC=os.create,JC=Ba.create,TR=Iy.create,NR=Ra.create,YC=wh.create,BR=rc.create,RR=jy.create,PR=xh.create,$R=kh.create,ZR=Pu.create,DR=Po.create,MR=Bi.create,UR=Cy.create,VR=fs.create,LR=cr.create,qR=cr.strictCreate,HR=Sh.create,FR=Zv.create,KR=Ah.create,zR=Js.create,WR=Oh.create,GR=Ey.create,JR=nc.create,YR=au.create,XR=jh.create,QR=Ch.create,e7=Pa.create,t7=Eh.create,r7=$u.create,nA=ws.create,n7=Us.create,s7=$a.create,i7=ws.createWithPreprocess,a7=of.create,o7=()=>GC().optional(),c7=()=>JC().optional(),u7=()=>YC().optional(),l7={string:r=>os.create({...r,coerce:!0}),number:r=>Ba.create({...r,coerce:!0}),boolean:r=>wh.create({...r,coerce:!0}),bigint:r=>Ra.create({...r,coerce:!0}),date:r=>rc.create({...r,coerce:!0})},d7=rt;var Tn=Object.freeze({__proto__:null,defaultErrorMap:Ru,setErrorMap:dR,getErrorMap:Sy,makeIssue:Ay,EMPTY_PATH:hR,addIssueToContext:ge,ParseStatus:Br,INVALID:rt,DIRTY:Qc,OK:qr,isAborted:y_,isDirty:g_,isValid:bh,isAsync:_h,get util(){return Mt},get objectUtil(){return m_},ZodParsedType:ke,getParsedType:oa,ZodType:jt,datetimeRegex:KC,ZodString:os,ZodNumber:Ba,ZodBigInt:Ra,ZodBoolean:wh,ZodDate:rc,ZodSymbol:jy,ZodUndefined:xh,ZodNull:kh,ZodAny:Pu,ZodUnknown:Po,ZodNever:Bi,ZodVoid:Cy,ZodArray:fs,ZodObject:cr,ZodUnion:Sh,ZodDiscriminatedUnion:Zv,ZodIntersection:Ah,ZodTuple:Js,ZodRecord:Oh,ZodMap:Ey,ZodSet:nc,ZodFunction:au,ZodLazy:jh,ZodLiteral:Ch,ZodEnum:Pa,ZodNativeEnum:Eh,ZodPromise:$u,ZodEffects:ws,ZodTransformer:ws,ZodOptional:Us,ZodNullable:$a,ZodDefault:Ih,ZodCatch:Th,ZodNaN:Iy,BRAND:CR,ZodBranded:hk,ZodPipeline:of,ZodReadonly:Nh,custom:WC,Schema:jt,ZodSchema:jt,late:ER,get ZodFirstPartyTypeKind(){return Ye},coerce:l7,any:ZR,array:VR,bigint:NR,boolean:YC,date:BR,discriminatedUnion:FR,effect:nA,enum:e7,function:YR,instanceof:IR,intersection:KR,lazy:XR,literal:QR,map:GR,nan:TR,nativeEnum:t7,never:MR,null:$R,nullable:s7,number:JC,object:LR,oboolean:u7,onumber:c7,optional:n7,ostring:o7,pipeline:a7,preprocess:i7,promise:r7,record:WR,set:JR,strictObject:qR,string:GC,symbol:RR,transformer:nA,tuple:zR,undefined:PR,union:HR,unknown:DR,void:UR,NEVER:d7,ZodIssueCode:re,quotelessJson:lR,ZodError:wn});Tn.object({start:Tn.number(),limit:Tn.number(),length:Tn.number()});Kg.extend({email:Tn.string(),login_count:Tn.number(),multifactor:Tn.array(Tn.string()).optional(),last_ip:Tn.string().optional(),last_login:Tn.string().optional(),user_id:Tn.string()}).catchall(Tn.any());const h7=Ja.extend({tenants:T.array(nu)}),p7=new Sr().openapi(ct({tags:["tenants"],method:"get",path:"/",request:{query:qo},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:T.union([T.array(nu),h7])}},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:il(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(ct({tags:["tenants"],method:"get",path:"/{id}",request:{params:T.object({id:T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:nu}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new nt(404);return r.json(t)}).openapi(ct({tags:["tenants"],method:"delete",path:"/{id}",request:{params:T.object({id:T.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(ct({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:T.object(Dm.shape).partial()}}},params:T.object({id:T.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(ct({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:T.object(Dm.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:nu}},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})}),f7=Ja.extend({logs:T.array(Um)}),m7=new Sr().openapi(ct({tags:["logs"],method:"get",path:"/",request:{query:qo,headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:T.union([T.array(Um),f7])}},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:il(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(ct({tags:["logs"],method:"get",path:"/{id}",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({id:T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Um}},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 nt(404);return r.json(n)}),y7=Ja.extend({hooks:T.array(Yc)}),g7=new Sr().openapi(ct({tags:["hooks"],method:"get",path:"/",request:{query:qo,headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:T.union([T.array(Yc),y7])}},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:il(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(ct({tags:["hooks"],method:"post",path:"/",request:{headers:T.object({"tenant-id":T.string()}),body:{content:{"application/json":{schema:T.object(Mm.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Yc}},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(ct({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({hook_id:T.string()}),body:{content:{"application/json":{schema:T.object(Mm.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Yc.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 nt(404,{message:"Hook not found"});return r.json(s)}).openapi(ct({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({hook_id:T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Yc}},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 nt(404,{message:"Hook not found"});return r.json(n)}).openapi(ct({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:T.object({"tenant-id":T.string()}),params:T.object({hook_id:T.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 nt(404,{message:"Hook not found"});return r.text("OK")}),v7=Ja.extend({connections:T.array(_o)}),b7=new Sr().openapi(ct({tags:["connections"],method:"get",path:"/",request:{query:qo,headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:T.union([T.array(_o),v7])}},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:il(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(ct({tags:["connections"],method:"get",path:"/{id}",request:{params:T.object({id:T.string()}),headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:_o}},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 nt(404);return r.json(n)}).openapi(ct({tags:["connections"],method:"delete",path:"/{id}",request:{params:T.object({id:T.string()}),headers:T.object({"tenant-id":T.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 nt(404,{message:"Connection not found"});return r.text("OK")}).openapi(ct({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:T.object(Zm.shape).partial()}}},params:T.object({id:T.string()}),headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:_o}},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 nt(404,{message:"Connection not found"});const i=await r.env.data.connections.get(e,t);if(!i)throw new nt(404,{message:"Connection not found"});return r.json(i)}).openapi(ct({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:T.object(Zm.shape)}}},headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:_o}},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})}),_7=new Sr().openapi(ct({tags:["prompts"],method:"get",path:"/",request:{headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:tm}},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(tm.parse({}))}).openapi(ct({tags:["prompts"],method:"patch",path:"/",request:{headers:T.object({"tenant-id":T.string()}),body:{content:{"application/json":{schema:T.object(tm.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 sA=!1;function XC(r){r.use(async(e,t)=>(sA||(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"}}}}),sA=!0),await t()))}T.object({alg:T.literal("RS256"),kty:T.literal("RSA"),use:T.literal("sig"),n:T.string(),e:T.string(),kid:T.string(),x5t:T.string(),x5c:T.array(T.string())});async function w7(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 nt(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function x7(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 w7(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 k7(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 QC(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 nt(401,{message:"Missing bearer token"});const l=k7(u);if(!l||!await x7(e,l))throw new nt(403,{message:"Invalid JWT signature"});e.set("user_id",l.payload.sub);const h=l.payload.permissions||[];if(a!=null&&a.length&&!a.some(R=>h.includes(R)))throw new nt(403,{message:"Unauthorized"})}return await t()}}const S7=new Sr().openapi(ct({tags:["emails"],method:"get",path:"/",request:{headers:T.object({"tenant-id":T.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:rm}},description:"Email provider"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.emailProviders.get(e);if(!t)throw new nt(404,{message:"Email provider not found"});return r.json(t)}).openapi(ct({tags:["emails"],method:"post",path:"/",request:{headers:T.object({"tenant-id":T.string()}),body:{content:{"application/json":{schema:T.object(rm.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.create(e,t),r.text("OK",{status:201})}).openapi(ct({tags:["emails"],method:"patch",path:"/",request:{headers:T.object({"tenant-id":T.string()}),body:{content:{"application/json":{schema:T.object(rm.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.update(e,t),r.text("OK")});function A7(){const r=new Sr;r.use(QC(r));const e=r.route("/branding",MN).route("/email/providers",S7).route("/users",a9).route("/keys",aR).route("/users-by-email",oR).route("/clients",uR).route("/tenants",p7).route("/logs",m7).route("/hooks",g7).route("/connections",b7).route("/prompts",_7);return XC(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}const Rf=60*5,O7=30*24*60*60,j7="auth-token",C7=new Sr().openapi(ct({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Pj}},description:"List of tenants"}}}),async r=>{const e=await r.env.data.keys.list(),t=await Promise.all(e.map(async n=>{const i=await new dk(n.cert).publicKey.export(),a=await crypto.subtle.exportKey("jwk",i);return wx.parse({...a,kid:n.kid})}));return r.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Rf}, stale-while-revalidate=${Rf*2}, stale-if-error=86400`}})}).openapi(ct({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Wb}},description:"List of tenants"}}}),async r=>{const e=r.env.ISSUER,t=Wb.parse({issuer:e,authorization_endpoint:`${e}authorize`,token_endpoint:`${e}oauth/token`,device_authorization_endpoint:`${e}oauth/device/code`,userinfo_endpoint:`${e}userinfo`,mfa_challenge_endpoint:`${e}mfa/challenge`,jwks_uri:`${e}.well-known/jwks.json`,registration_endpoint:`${e}oidc/register`,revocation_endpoint:`${e}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return r.json(t,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Rf}, stale-while-revalidate=${Rf*2}, stale-if-error=86400`}})});class Ty{constructor(e,t){Pe(this,"value");Pe(this,"unit");this.value=e,this.unit=t}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Ty(Math.round(this.milliseconds()*e),"ms")}}async function iA(r,e,t,n){const s={alg:r,typ:"JWT",...n==null?void 0:n.headers},i={...t};(n==null?void 0:n.audiences)!==void 0&&(i.aud=n.audiences),(n==null?void 0:n.subject)!==void 0&&(i.sub=n.subject),(n==null?void 0:n.issuer)!==void 0&&(i.iss=n.issuer),(n==null?void 0:n.jwtId)!==void 0&&(i.jti=n.jwtId),(n==null?void 0:n.expiresIn)!==void 0&&(i.exp=Math.floor(Date.now()/1e3)+n.expiresIn.seconds()),(n==null?void 0:n.notBefore)!==void 0&&(i.nbf=Math.floor(n.notBefore.getTime()/1e3)),(n==null?void 0:n.includeIssuedTimestamp)===!0&&(i.iat=Math.floor(Date.now()/1e3));const a=new TextEncoder,o=om.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),c=om.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),u=a.encode([o,c].join(".")),l=await E7(r).sign(e,u),h=om.encode(new Uint8Array(l),{includePadding:!1});return[o,c,h].join(".")}function E7(r){return new rR(I7[r])}const I7={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function T7(r){try{const t=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(r);if(!t||!t[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(t[1].replace(/\s/g,"")),n=>n.charCodeAt(0)).buffer}finally{r=r.replace(/./g,"\0")}}async function N7(r,e){if(e==="plain")return r;const t=new TextEncoder().encode(r),n=await VC(t);return om.encode(new Uint8Array(n))}async function eE(r,e){var h;const{authParams:t,user:n,sid:s}=e,a=(await r.env.data.keys.list()).filter(R=>!R.revoked_at||new Date(R.revoked_at)>new Date),o=a[a.length-1];if(!(o!=null&&o.pkcs7))throw new nt(500,{message:"No signing key available"});const c=T7(o.pkcs7),u=await iA("RS256",c,{aud:t.audience||"default",scope:t.scope||"",sub:(n==null?void 0:n.user_id)||t.client_id,iss:r.env.ISSUER,tenant_id:r.var.tenant_id,sid:s},{includeIssuedTimestamp:!0,expiresIn:new Ty(1,"d"),headers:{kid:o.kid}}),l=n&&((h=t.scope)!=null&&h.split(" ").includes("openid"))?await iA("RS256",c,{aud:t.client_id,sub:n.user_id,iss:r.env.ISSUER,sid:s,nonce:t.nonce,given_name:n.given_name,family_name:n.family_name,nickname:n.nickname,picture:n.picture,locale:n.locale,name:n.name,email:n.email,email_verified:n.email_verified},{includeIssuedTimestamp:!0,expiresIn:new Ty(1,"d"),headers:{kid:o.kid}}):void 0;return{access_token:u,id_token:l,token_type:"Bearer",expires_in:86400}}function B7(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}const tE=T.object({grant_type:T.literal("client_credentials"),scope:T.string().optional(),client_secret:T.string(),client_id:T.string(),audience:T.string().optional()});async function R7(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new nt(403,{message:"Invalid client credentials"});if(t.client_secret&&!B7(t.client_secret,e.client_secret))throw new nt(403,{message:"Invalid client credentials"});const n={client_id:t.id,scope:e.scope,audience:e.audience},s=await eE(r,{authParams:n});return r.json(s)}function P7(r,e,t){const n=[];return n.push([encodeURIComponent(r),encodeURIComponent(e)]),(t==null?void 0:t.domain)!==void 0&&n.push(["Domain",t.domain]),(t==null?void 0:t.expires)!==void 0&&n.push(["Expires",t.expires.toUTCString()]),n.push(["HttpOnly"]),(t==null?void 0:t.maxAge)!==void 0&&n.push(["Max-Age",t.maxAge.toString()]),(t==null?void 0:t.path)!==void 0&&n.push(["Path",t.path]),n.push(["SameSite","None"]),n.push(["Secure"]),n.map(s=>s.join("=")).join("; ")}var $7=Object.defineProperty,rE=r=>{throw TypeError(r)},Z7=(r,e,t)=>e in r?$7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,$e=(r,e,t)=>Z7(r,typeof e!="symbol"?e+"":e,t),pk=(r,e,t)=>e.has(r)||rE("Cannot "+t),L=(r,e,t)=>(pk(r,e,"read from private field"),t?t.call(r):e.get(r)),Tt=(r,e,t)=>e.has(r)?rE("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ze=(r,e,t,n)=>(pk(r,e,"write to private field"),e.set(r,t),t),$t=(r,e,t)=>(pk(r,e,"access private method"),t),D7=(r,e,t,n)=>({set _(s){ze(r,e,s)},get _(){return L(r,e,n)}});function sd(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 xt(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function M7(r){return"_def"in r}function Vl(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 U7(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,l,h;const R=typeof s=="string"?i:s,B=R??{},{param:d}=B,g=sd(B,["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),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||d?{param:Object.assign(Object.assign({},(h=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||h===void 0?void 0:h.param),d)}:void 0),$=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(xt(this,"ZodObject")){const P=this.extend;$.extend=function(...ae){var Re,He,Te,Nt,Gt,Jt;const C=P.apply(this,ae);return C._def.openapi={_internal:{extendedFrom:!((He=(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal)===null||He===void 0)&&He.refId?{refId:(Nt=(Te=this._def.openapi)===null||Te===void 0?void 0:Te._internal)===null||Nt===void 0?void 0:Nt.refId,schema:this}:(Gt=this._def.openapi)===null||Gt===void 0?void 0:Gt._internal.extendedFrom},metadata:(Jt=C._def.openapi)===null||Jt===void 0?void 0:Jt.metadata},C}}return $},Vl(r,"optional"),Vl(r,"nullable"),Vl(r,"default"),Vl(r,"transform"),Vl(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,l;c._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.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 Ny(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=>Ny(r[n],e[n]))}class V7{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(s=>Ny(s,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>Ny(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 xd(r){return r==null}function kd(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function L7(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function ou(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function aA(r){return r.filter(e=>!xd(e))}const b_=Ny;function q7(r){const e=new V7;return r.forEach(t=>e.put(t)),[...e.values()]}function nE(r){return typeof r=="string"}class H7{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(n=>n.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 Dv{constructor(e){this.message=e}}class Ll extends Dv{constructor(e,t){super(e),this.data=t}}class By extends Dv{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 ql(r,e){try{return r()}catch(t){throw t instanceof By?new By(Object.assign(Object.assign({},t.data),e)):t}}class F7 extends Dv{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class rr{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 ou(L7(e,["param"]),xd)}static buildParameterMetadata(e){return ou(e,xd)}static applySchemaMetadata(e,t){return ou(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),xd)}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&&xt(e,t)?e:xt(e,"ZodOptional")||xt(e,"ZodNullable")||xt(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):xt(e,"ZodDefault")||xt(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):xt(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):xt(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return xt(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class K7{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 z7{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class W7{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=>rr.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=rr.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(xt(c,"ZodEnum")||xt(c,"ZodNativeEnum")){Object.values(c.enum).filter(nE).forEach(l=>{s[l]=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 G7{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class J7{transform(e,t,n,s){const i={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([i],t)}:i}flattenIntersectionTypes(e){if(!xt(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class Y7{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function X7(r){const e=Object.keys(r).filter(s=>typeof r[r[s]]!="number").map(s=>r[s]),t=e.filter(s=>typeof s=="number").length,n=t===0?"string":t===e.length?"numeric":"mixed";return{values:e,type:n}}class Q7{transform(e,t){const{type:n,values:s}=X7(e._def.values);if(n==="mixed")throw new Dv("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 eP{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class tP{transform(e,t,n,s){var i;const a=(i=rr.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=kd(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 l=this.requiredKeysOf(u),h=kd(u==null?void 0:u._def.shape(),s),R=Object.fromEntries(Object.entries(c).filter(([g,A])=>!b_(h[g],A))),B=o.filter(g=>!l.includes(g)),d=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:R}),B.length>0?{required:B}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},d]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return xt(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!rr.isOptionalSchema(n)).map(([t,n])=>t)}}class rP{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(xt(i,"ZodEnum")||xt(i,"ZodNativeEnum")){const o=Object.values(i.enum).filter(nE).reduce((c,u)=>Object.assign(Object.assign({},c),{[u]:a}),{});return Object.assign(Object.assign({},t("object")),{properties:o})}return Object.assign(Object.assign({},t("object")),{additionalProperties:a})}}class nP{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 sP{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 iP{transform(e,t,n){const s=this.flattenUnionTypes(e).map(i=>{const a=this.unwrapNullable(i);return n(a)});return{anyOf:t(s)}}flattenUnionTypes(e){return xt(e,"ZodUnion")?e._def.options.flatMap(t=>this.flattenUnionTypes(t)):[e]}unwrapNullable(e){return xt(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class aP{constructor(e){this.versionSpecifics=e,this.objectTransformer=new tP,this.stringTransformer=new nP,this.numberTransformer=new eP,this.bigIntTransformer=new z7,this.literalTransformer=new Y7,this.enumTransformer=new G7,this.nativeEnumTransformer=new Q7,this.arrayTransformer=new K7,this.unionTransformer=new iP,this.discriminatedUnionTransformer=new W7,this.intersectionTransformer=new J7,this.recordTransformer=new rP,this.tupleTransformer=new sP(e)}transform(e,t,n,s,i){if(xt(e,"ZodNull"))return this.versionSpecifics.nullType;if(xt(e,"ZodUnknown")||xt(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(xt(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(xt(e,"ZodUnknown")||xt(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(xt(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(xt(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(xt(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(xt(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(xt(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(xt(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(xt(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(xt(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(xt(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(xt(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(xt(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(xt(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(xt(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(xt(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=rr.getRefId(e);throw new F7({currentSchema:e._def,schemaName:i})}}class sE{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new aP(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=rr.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 Ll(`Conflicting location for parameter ${u.name}`,{key:"in",values:aA([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 Ll("Conflicting names for parameter",{key:"name",values:aA([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=rr.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(xt(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([c,u])=>{var l,h;const R=rr.getMetadata(u),B=this.getParameterRef(R,{in:t,name:c});if(B)return B;const d=(l=R==null?void 0:R.metadata)===null||l===void 0?void 0:l.param;if(d!=null&&d.name&&d.name!==c)throw new Ll("Conflicting names for parameter",{key:"name",values:[c,d.name]});if(d!=null&&d.in&&d.in!==t)throw new Ll(`Conflicting location for parameter ${(h=d.name)!==null&&h!==void 0?h:c}`,{key:"in",values:[t,d.in]});return this.generateParameter(u.openapi({param:{name:c,in:t}}))})}if(i!=null&&i.in&&i.in!==t)throw new Ll(`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=rr.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!rr.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?rr.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=rr.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 By({missingField:"name"});if(!a)throw new By({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=rr.unwrapChained(e),s=rr.getMetadata(e),i=rr.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?rr.applySchemaMetadata(a,s.metadata):ou(a,xd)}constructReferencedOpenAPISchema(e){var t;const n=rr.getMetadata(e),s=rr.unwrapChained(e),i=rr.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=rr.getMetadata(e),s=rr.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=ou(rr.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(l,h)=>l===void 0||b_(l,i[h]));if(o.type)return{allOf:[a,o]};const c=ou(this.constructReferencedOpenAPISchema(e),(l,h)=>l===void 0||b_(l,i[h])),u=rr.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=rr.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=sd(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=ql(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=ql(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=ql(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=ql(()=>{if(Array.isArray(t))return t.flatMap(h=>this.generateInlineParameters(h,"header"));const l=this.cleanParameter(t);return l?this.generateInlineParameters(l,"header"):[]},{location:"header"});return[...o,...a,...u,...c]}cleanParameter(e){if(e)return xt(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=sd(e,["method","path","request","responses"]),o=kd(i,l=>this.getResponse(l)),c=ql(()=>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=sd(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=xt(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 kd(t,n=>this.generateSimpleParameter(n))}getBodyContent(e){return kd(e,t=>{if(!t||!M7(t.schema))return t;const{schema:n}=t,s=sd(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 oP{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=q7(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 cP{constructor(e){const t=new oP;this.generator=new sE(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class uP{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 lP(r){return"type"in r&&r.type==="webhook"}class dP{constructor(e){this.definitions=e,this.webhookRefs={};const t=new uP;this.generator=new sE(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(lP).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 iE=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},hP=r=>{const{groups:e,path:t}=pP(r),n=iE(t);return fP(n,e)},pP=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},fP=(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},Pf={},oA=r=>{if(r==="*")return"*";const e=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);return e?(Pf[r]||(e[2]?Pf[r]=[r,e[1],new RegExp("^"+e[2]+"$")]:Pf[r]=[r,e[1],!0]),Pf[r]):null},aE=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},mP=r=>aE(r,decodeURI),oE=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 mP(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},yP=r=>{const e=oE(r);return e.length>1&&e[e.length-1]==="/"?e.slice(0,-1):e},ca=(...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},cE=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)},ab=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?fk(r):r):r,uE=(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 ab(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=ab(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=ab(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},gP=uE,vP=(r,e)=>uE(r,e,!0),fk=decodeURIComponent,bP=/^[\w!#$%&'*.^`|~+-]+$/,_P=/^[ !#-:<-[\]-~]*$/,wP=(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(!bP.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),_P.test(o)&&(n[a]=fk(o))}return n},xP=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?wP(n):{}},lt=class extends Error{constructor(r=500,e){super(e==null?void 0:e.message,{cause:e==null?void 0:e.cause}),$e(this,"res"),$e(this,"status"),this.res=e==null?void 0:e.res,this.status=r}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},kP=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),SP=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,AP=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,OP=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,jP=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!SP.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new lt(400,{message:o})}break;case"form":{if(!i||!(AP.test(i)||OP.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 kP(u,i),t.req.bodyCache.formData=o}catch(u){let l="Malformed FormData request.";throw l+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new lt(400,{message:l})}const c={};o.forEach((u,l)=>{l.endsWith("[]")?(c[l]??(c[l]=[])).push(u):Array.isArray(c[l])?c[l].push(u):l in c?c[l]=[c[l],u]:c[l]=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=xP(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const Nc=(r,e,t)=>jP(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 CP=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,s=(r instanceof lE?r.raw.headers:r.headers).get("Content-Type");return s!=null&&s.startsWith("multipart/form-data")||s!=null&&s.startsWith("application/x-www-form-urlencoded")?EP(r,{all:t,dot:n}):{}};async function EP(r,e){const t=await r.formData();return t?IP(t,e):{}}function IP(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?TP(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(NP(t,n,s),delete t[n])}),t}var TP=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},NP=(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])})},cA=r=>aE(r,fk),Hl,Is,Bc,uA,lA,ob,ao,dA,lE=(dA=class{constructor(r,e="/",t=[[]]){Tt(this,Bc),$e(this,"raw"),Tt(this,Hl),Tt(this,Is),$e(this,"routeIndex",0),$e(this,"path"),$e(this,"bodyCache",{}),Tt(this,ao,n=>{const{bodyCache:s,raw:i}=this,a=s[n];if(a)return a;const o=Object.keys(s)[0];return o?s[o].then(c=>(o==="json"&&(c=JSON.stringify(c)),new Response(c)[n]())):s[n]=i[n]()}),this.raw=r,this.path=e,ze(this,Is,t),ze(this,Hl,{})}param(r){return r?$t(this,Bc,uA).call(this,r):$t(this,Bc,lA).call(this)}query(r){return gP(this.url,r)}queries(r){return vP(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 CP(this,r))}json(){return L(this,ao).call(this,"json")}text(){return L(this,ao).call(this,"text")}arrayBuffer(){return L(this,ao).call(this,"arrayBuffer")}blob(){return L(this,ao).call(this,"blob")}formData(){return L(this,ao).call(this,"formData")}addValidatedData(r,e){L(this,Hl)[r]=e}valid(r){return L(this,Hl)[r]}get url(){return this.raw.url}get method(){return this.raw.method}get matchedRoutes(){return L(this,Is)[0].map(([[,r]])=>r)}get routePath(){return L(this,Is)[0].map(([[,r]])=>r)[this.routeIndex].path}},Hl=new WeakMap,Is=new WeakMap,Bc=new WeakSet,uA=function(r){const e=L(this,Is)[0][this.routeIndex][1][r],t=$t(this,Bc,ob).call(this,e);return t?/\%/.test(t)?cA(t):t:void 0},lA=function(){const r={},e=Object.keys(L(this,Is)[0][this.routeIndex][1]);for(const t of e){const n=$t(this,Bc,ob).call(this,L(this,Is)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?cA(n):n)}return r},ob=function(r){return L(this,Is)[1]?L(this,Is)[1][r]:r},ao=new WeakMap,dA),BP={Stringify:1,BeforeStream:2,Stream:3},dE=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(a=>a({phase:e,buffer:s,context:n}))).then(a=>Promise.all(a.filter(Boolean).map(o=>dE(o,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},RP="text/plain; charset=UTF-8",cb=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},$f,Fl,li,Rc,Gi,Qt,er,Ts,Ji,Zf,Pc,$c,Df,Mf,fn,En,hA,hE=(hA=class{constructor(r,e){Tt(this,fn),Tt(this,$f),Tt(this,Fl),$e(this,"env",{}),Tt(this,li),$e(this,"finalized",!1),$e(this,"error"),Tt(this,Rc,200),Tt(this,Gi),Tt(this,Qt),Tt(this,er),Tt(this,Ts),Tt(this,Ji,!0),Tt(this,Zf),Tt(this,Pc),Tt(this,$c),Tt(this,Df),Tt(this,Mf),$e(this,"render",(...t)=>(L(this,Pc)??ze(this,Pc,n=>this.html(n)),L(this,Pc).call(this,...t))),$e(this,"setLayout",t=>ze(this,Zf,t)),$e(this,"getLayout",()=>L(this,Zf)),$e(this,"setRenderer",t=>{ze(this,Pc,t)}),$e(this,"header",(t,n,s)=>{if(n===void 0){L(this,Qt)?L(this,Qt).delete(t):L(this,er)&&delete L(this,er)[t.toLocaleLowerCase()],this.finalized&&this.res.headers.delete(t);return}s!=null&&s.append?(L(this,Qt)||(ze(this,Ji,!1),ze(this,Qt,new Headers(L(this,er))),ze(this,er,{})),L(this,Qt).append(t,n)):L(this,Qt)?L(this,Qt).set(t,n):(L(this,er)??ze(this,er,{}),L(this,er)[t.toLowerCase()]=n),this.finalized&&(s!=null&&s.append?this.res.headers.append(t,n):this.res.headers.set(t,n))}),$e(this,"status",t=>{ze(this,Ji,!1),ze(this,Rc,t)}),$e(this,"set",(t,n)=>{L(this,li)??ze(this,li,new Map),L(this,li).set(t,n)}),$e(this,"get",t=>L(this,li)?L(this,li).get(t):void 0),$e(this,"newResponse",(...t)=>$t(this,fn,En).call(this,...t)),$e(this,"body",(t,n,s)=>typeof n=="number"?$t(this,fn,En).call(this,t,n,s):$t(this,fn,En).call(this,t,n)),$e(this,"text",(t,n,s)=>{if(!L(this,er)){if(L(this,Ji)&&!s&&!n)return new Response(t);ze(this,er,{})}return L(this,er)["content-type"]=RP,typeof n=="number"?$t(this,fn,En).call(this,t,n,s):$t(this,fn,En).call(this,t,n)}),$e(this,"json",(t,n,s)=>{const i=JSON.stringify(t);return L(this,er)??ze(this,er,{}),L(this,er)["content-type"]="application/json; charset=UTF-8",typeof n=="number"?$t(this,fn,En).call(this,i,n,s):$t(this,fn,En).call(this,i,n)}),$e(this,"html",(t,n,s)=>(L(this,er)??ze(this,er,{}),L(this,er)["content-type"]="text/html; charset=UTF-8",typeof t=="object"?dE(t,BP.Stringify,!1,{}).then(i=>typeof n=="number"?$t(this,fn,En).call(this,i,n,s):$t(this,fn,En).call(this,i,n)):typeof n=="number"?$t(this,fn,En).call(this,t,n,s):$t(this,fn,En).call(this,t,n))),$e(this,"redirect",(t,n)=>(L(this,Qt)??ze(this,Qt,new Headers),L(this,Qt).set("Location",String(t)),this.newResponse(null,n??302))),$e(this,"notFound",()=>(L(this,$c)??ze(this,$c,()=>new Response),L(this,$c).call(this,this))),ze(this,$f,r),e&&(ze(this,Gi,e.executionCtx),this.env=e.env,ze(this,$c,e.notFoundHandler),ze(this,Mf,e.path),ze(this,Df,e.matchResult))}get req(){return L(this,Fl)??ze(this,Fl,new lE(L(this,$f),L(this,Mf),L(this,Df))),L(this,Fl)}get event(){if(L(this,Gi)&&"respondWith"in L(this,Gi))return L(this,Gi);throw Error("This context has no FetchEvent")}get executionCtx(){if(L(this,Gi))return L(this,Gi);throw Error("This context has no ExecutionContext")}get res(){return ze(this,Ji,!1),L(this,Ts)||ze(this,Ts,new Response("404 Not Found",{status:404}))}set res(r){if(ze(this,Ji,!1),L(this,Ts)&&r)try{for(const[e,t]of L(this,Ts).headers.entries())if(e!=="content-type")if(e==="set-cookie"){const n=L(this,Ts).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}ze(this,Ts,r),this.finalized=!0}get var(){return L(this,li)?Object.fromEntries(L(this,li)):{}}},$f=new WeakMap,Fl=new WeakMap,li=new WeakMap,Rc=new WeakMap,Gi=new WeakMap,Qt=new WeakMap,er=new WeakMap,Ts=new WeakMap,Ji=new WeakMap,Zf=new WeakMap,Pc=new WeakMap,$c=new WeakMap,Df=new WeakMap,Mf=new WeakMap,fn=new WeakSet,En=function(r,e,t){if(L(this,Ji)&&!t&&!e&&L(this,Rc)===200)return new Response(r,{headers:L(this,er)});if(e&&typeof e!="number"){const s=new Headers(e.headers);L(this,Qt)&&L(this,Qt).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=cb(s,L(this,er));return new Response(r,{headers:i,status:e.status??L(this,Rc)})}const n=typeof e=="number"?e:L(this,Rc);L(this,er)??ze(this,er,{}),L(this,Qt)??ze(this,Qt,new Headers),cb(L(this,Qt),L(this,er)),L(this,Ts)&&(L(this,Ts).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=L(this,Qt))==null||a.append(i,s):(o=L(this,Qt))==null||o.set(i,s)}),cb(L(this,Qt),L(this,er))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")L(this,Qt).set(s,i);else{L(this,Qt).delete(s);for(const a of i)L(this,Qt).append(s,a)}return new Response(r,{status:n,headers:L(this,Qt)})},hA),pA=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof hE;return o(0);async function o(c){if(c<=i)throw new Error("next() called multiple times");i=c;let u,l=!1,h;if(r[c]?(h=r[c][0][0],a&&(n.req.routeIndex=c)):h=c===r.length&&s||void 0,!h)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await h(n,()=>o(c+1))}catch(R){if(R instanceof Error&&a&&e)n.error=R,u=await e(R,n),l=!0;else throw R}return u&&(n.finalized===!1||l)&&(n.res=u),n}},yr="ALL",PP="all",$P=["get","post","put","delete","options","patch"],pE="Can not add a route since the matcher is already built.",fE=class extends Error{},ZP=Symbol("composedHandler"),DP=r=>r.text("404 Not Found",404),fA=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),Ns,Zr,mA,Yi,oo,Uf,Vf,yA,mE=(yA=class{constructor(r={}){Tt(this,Zr),$e(this,"get"),$e(this,"post"),$e(this,"put"),$e(this,"delete"),$e(this,"options"),$e(this,"patch"),$e(this,"all"),$e(this,"on"),$e(this,"use"),$e(this,"router"),$e(this,"getPath"),$e(this,"_basePath","/"),Tt(this,Ns,"/"),$e(this,"routes",[]),Tt(this,Yi,DP),$e(this,"errorHandler",fA),$e(this,"onError",t=>(this.errorHandler=t,this)),$e(this,"notFound",t=>(ze(this,Yi,t),this)),$e(this,"fetch",(t,...n)=>$t(this,Zr,Vf).call(this,t,n[1],n[0],t.method)),$e(this,"request",(t,n,s,i)=>t instanceof Request?this.fetch(n?new Request(t,n):t,s,i):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${ca("/",t)}`,n),s,i))),$e(this,"fire",()=>{addEventListener("fetch",t=>{t.respondWith($t(this,Zr,Vf).call(this,t.request,t,void 0,t.request.method))})}),[...$P,PP].forEach(t=>{this[t]=(n,...s)=>(typeof n=="string"?ze(this,Ns,n):$t(this,Zr,oo).call(this,t,L(this,Ns),n),s.forEach(i=>{$t(this,Zr,oo).call(this,t,L(this,Ns),i)}),this)}),this.on=(t,n,...s)=>{for(const i of[n].flat()){ze(this,Ns,i);for(const a of[t].flat())s.map(o=>{$t(this,Zr,oo).call(this,a.toUpperCase(),L(this,Ns),o)})}return this},this.use=(t,...n)=>(typeof t=="string"?ze(this,Ns,t):(ze(this,Ns,"*"),n.unshift(t)),n.forEach(s=>{$t(this,Zr,oo).call(this,yr,L(this,Ns),s)}),this);const e=r.strict??!0;delete r.strict,Object.assign(this,r),this.getPath=e?r.getPath??oE:yP}route(r,e){const t=this.basePath(r);return e.routes.map(n=>{var s;let i;e.errorHandler===fA?i=n.handler:(i=async(a,o)=>(await pA([],e.errorHandler)(a,()=>n.handler(a,o))).res,i[ZP]=n.handler),$t(s=t,Zr,oo).call(s,n.method,n.path,i)}),this}basePath(r){const e=$t(this,Zr,mA).call(this);return e._basePath=ca(this._basePath,r),e}mount(r,e,t){let n,s;t&&(typeof t=="function"?s=t:(s=t.optionHandler,n=t.replaceRequest));const i=s?o=>{const c=s(o);return Array.isArray(c)?c:[c]}:o=>{let c;try{c=o.executionCtx}catch{}return[o.env,c]};n||(n=(()=>{const o=ca(this._basePath,r),c=o==="/"?0:o.length;return u=>{const l=new URL(u.url);return l.pathname=l.pathname.slice(c)||"/",new Request(l,u)}})());const a=async(o,c)=>{const u=await e(n(o.req.raw),...i(o));if(u)return u;await c()};return $t(this,Zr,oo).call(this,yr,ca(r,"*"),a),this}},Ns=new WeakMap,Zr=new WeakSet,mA=function(){const r=new mE({router:this.router,getPath:this.getPath});return r.routes=this.routes,r},Yi=new WeakMap,oo=function(r,e,t){r=r.toUpperCase(),e=ca(this._basePath,e);const n={path:e,method:r,handler:t};this.router.add(r,e,[t,n]),this.routes.push(n)},Uf=function(r,e){if(r instanceof Error)return this.errorHandler(r,e);throw r},Vf=function(r,e,t,n){if(n==="HEAD")return(async()=>new Response(null,await $t(this,Zr,Vf).call(this,r,e,t,"GET")))();const s=this.getPath(r,{env:t}),i=this.router.match(n,s),a=new hE(r,{path:s,matchResult:i,env:t,executionCtx:e,notFoundHandler:L(this,Yi)});if(i[0].length===1){let c;try{c=i[0][0][0][0](a,async()=>{a.res=await L(this,Yi).call(this,a)})}catch(u){return $t(this,Zr,Uf).call(this,u,a)}return c instanceof Promise?c.then(u=>u||(a.finalized?a.res:L(this,Yi).call(this,a))).catch(u=>$t(this,Zr,Uf).call(this,u,a)):c??L(this,Yi).call(this,a)}const o=pA(i[0],this.errorHandler,L(this,Yi));return(async()=>{try{const c=await o(a);if(!c.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return c.res}catch(c){return $t(this,Zr,Uf).call(this,c,a)}})()},yA),Ry="[^/]+",Sd=".*",Ad="(?:|/.*)",id=Symbol(),MP=new Set(".\\+*[^]$()");function UP(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===Sd||r===Ad?1:e===Sd||e===Ad?-1:r===Ry?1:e===Ry?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Zc,Dc,Bs,gA,__=(gA=class{constructor(){Tt(this,Zc),Tt(this,Dc),Tt(this,Bs,Object.create(null))}insert(r,e,t,n,s){if(r.length===0){if(L(this,Zc)!==void 0)throw id;if(s)return;ze(this,Zc,e);return}const[i,...a]=r,o=i==="*"?a.length===0?["","",Sd]:["","",Ry]:i==="/*"?["","",Ad]:i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let c;if(o){const u=o[1];let l=o[2]||Ry;if(u&&o[2]&&(l=l.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(l)))throw id;if(c=L(this,Bs)[l],!c){if(Object.keys(L(this,Bs)).some(h=>h!==Sd&&h!==Ad))throw id;if(s)return;c=L(this,Bs)[l]=new __,u!==""&&ze(c,Dc,n.varIndex++)}!s&&u!==""&&t.push([u,L(c,Dc)])}else if(c=L(this,Bs)[i],!c){if(Object.keys(L(this,Bs)).some(u=>u.length>1&&u!==Sd&&u!==Ad))throw id;if(s)return;c=L(this,Bs)[i]=new __}c.insert(a,e,t,n,s)}buildRegExpStr(){const r=Object.keys(L(this,Bs)).sort(UP).map(e=>{const t=L(this,Bs)[e];return(typeof L(t,Dc)=="number"?`(${e})@${L(t,Dc)}`:MP.has(e)?`\\${e}`:e)+t.buildRegExpStr()});return typeof L(this,Zc)=="number"&&r.unshift(`#${L(this,Zc)}`),r.length===0?"":r.length===1?r[0]:"(?:"+r.join("|")+")"}},Zc=new WeakMap,Dc=new WeakMap,Bs=new WeakMap,gA),ub,Lf,vA,VP=(vA=class{constructor(){Tt(this,ub,{varIndex:0}),Tt(this,Lf,new __)}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 L(this,Lf).insert(i,e,n,L(this,ub),t),n}buildRegExp(){let r=L(this,Lf).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]}},ub=new WeakMap,Lf=new WeakMap,vA),yE=[],LP=[/^$/,[],Object.create(null)],w_=Object.create(null);function gE(r){return w_[r]??(w_[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function qP(){w_=Object.create(null)}function HP(r){var e;const t=new VP,n=[];if(r.length===0)return LP;const s=r.map(l=>[!/\*|\/:/.test(l[0]),...l]).sort(([l,h],[R,B])=>l?1:R?-1:h.length-B.length),i=Object.create(null);for(let l=0,h=-1,R=s.length;l<R;l++){const[B,d,g]=s[l];B?i[d]=[g.map(([O])=>[O,Object.create(null)]),yE]:h++;let A;try{A=t.insert(d,h,B)}catch(O){throw O===id?new fE(d):O}B||(n[h]=g.map(([O,$])=>{const P=Object.create(null);for($-=1;$>=0;$--){const[ae,Re]=A[$];P[ae]=Re}return[O,P]}))}const[a,o,c]=t.buildRegExp();for(let l=0,h=n.length;l<h;l++)for(let R=0,B=n[l].length;R<B;R++){const d=(e=n[l][R])==null?void 0:e[1];if(!d)continue;const g=Object.keys(d);for(let A=0,O=g.length;A<O;A++)d[g[A]]=c[d[g[A]]]}const u=[];for(const l in o)u[l]=n[o[l]];return[a,u,i]}function Mc(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(gE(t).test(e))return[...r[t]]}}var co,uo,qf,bA,_A,wA,FP=(wA=class{constructor(){Tt(this,qf),$e(this,"name","RegExpRouter"),Tt(this,co),Tt(this,uo),ze(this,co,{[yr]:Object.create(null)}),ze(this,uo,{[yr]:Object.create(null)})}add(r,e,t){var n;const s=L(this,co),i=L(this,uo);if(!s||!i)throw new Error(pE);s[r]||[s,i].forEach(c=>{c[r]=Object.create(null),Object.keys(c[yr]).forEach(u=>{c[r][u]=[...c[yr][u]]})}),e==="/*"&&(e="*");const a=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=gE(e);r===yr?Object.keys(s).forEach(u=>{var l;(l=s[u])[e]||(l[e]=Mc(s[u],e)||Mc(s[yr],e)||[])}):(n=s[r])[e]||(n[e]=Mc(s[r],e)||Mc(s[yr],e)||[]),Object.keys(s).forEach(u=>{(r===yr||r===u)&&Object.keys(s[u]).forEach(l=>{c.test(l)&&s[u][l].push([t,a])})}),Object.keys(i).forEach(u=>{(r===yr||r===u)&&Object.keys(i[u]).forEach(l=>c.test(l)&&i[u][l].push([t,a]))});return}const o=cE(e)||[e];for(let c=0,u=o.length;c<u;c++){const l=o[c];Object.keys(i).forEach(h=>{var R;(r===yr||r===h)&&((R=i[h])[l]||(R[l]=[...Mc(s[h],l)||Mc(s[yr],l)||[]]),i[h][l].push([t,a-u+c+1]))})}}match(r,e){qP();const t=$t(this,qf,bA).call(this);return this.match=(n,s)=>{const i=t[n]||t[yr],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],yE];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},co=new WeakMap,uo=new WeakMap,qf=new WeakSet,bA=function(){const r=Object.create(null);return Object.keys(L(this,uo)).concat(Object.keys(L(this,co))).forEach(e=>{r[e]||(r[e]=$t(this,qf,_A).call(this,e))}),ze(this,co,ze(this,uo,void 0)),r},_A=function(r){const e=[];let t=r===yr;return[L(this,co),L(this,uo)].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!==yr&&e.push(...Object.keys(n[yr]).map(i=>[i,n[yr][i]]))}),t?HP(e):null},wA),lo,Xi,xA,KP=(xA=class{constructor(r){$e(this,"name","SmartRouter"),Tt(this,lo,[]),Tt(this,Xi,[]),ze(this,lo,r.routers)}add(r,e,t){if(!L(this,Xi))throw new Error(pE);L(this,Xi).push([r,e,t])}match(r,e){if(!L(this,Xi))throw new Error("Fatal error");const t=L(this,lo),n=L(this,Xi),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 fE)continue;throw c}this.match=o.match.bind(o),ze(this,lo,[o]),ze(this,Xi,void 0);break}if(i===s)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,a}get activeRouter(){if(L(this,Xi)||L(this,lo).length!==1)throw new Error("No active router has been determined yet.");return L(this,lo)[0]}},lo=new WeakMap,Xi=new WeakMap,xA),ho,Jr,Uc,Kl,mn,Qi,po,kA,vE=(kA=class{constructor(r,e,t){if(Tt(this,Qi),Tt(this,ho),Tt(this,Jr),Tt(this,Uc),Tt(this,Kl,0),Tt(this,mn,Object.create(null)),ze(this,Jr,t||Object.create(null)),ze(this,ho,[]),r&&e){const n=Object.create(null);n[r]={handler:e,possibleKeys:[],score:0},ze(this,ho,[n])}ze(this,Uc,[])}insert(r,e,t){ze(this,Kl,++D7(this,Kl)._);let n=this;const s=hP(e),i=[];for(let c=0,u=s.length;c<u;c++){const l=s[c];if(Object.keys(L(n,Jr)).includes(l)){n=L(n,Jr)[l];const R=oA(l);R&&i.push(R[1]);continue}L(n,Jr)[l]=new vE;const h=oA(l);h&&(L(n,Uc).push(h),i.push(h[1])),n=L(n,Jr)[l]}const a=Object.create(null),o={handler:t,possibleKeys:i.filter((c,u,l)=>l.indexOf(c)===u),score:L(this,Kl)};return a[r]=o,L(n,ho).push(a),n}search(r,e){const t=[];ze(this,mn,Object.create(null));let n=[this];const s=iE(e);for(let i=0,a=s.length;i<a;i++){const o=s[i],c=i===a-1,u=[];for(let l=0,h=n.length;l<h;l++){const R=n[l],B=L(R,Jr)[o];B&&(ze(B,mn,L(R,mn)),c?(L(B,Jr)["*"]&&t.push(...$t(this,Qi,po).call(this,L(B,Jr)["*"],r,L(R,mn),Object.create(null))),t.push(...$t(this,Qi,po).call(this,B,r,L(R,mn),Object.create(null)))):u.push(B));for(let d=0,g=L(R,Uc).length;d<g;d++){const A=L(R,Uc)[d],O={...L(R,mn)};if(A==="*"){const Te=L(R,Jr)["*"];Te&&(t.push(...$t(this,Qi,po).call(this,Te,r,L(R,mn),Object.create(null))),u.push(Te));continue}if(o==="")continue;const[$,P,ae]=A,Re=L(R,Jr)[$],He=s.slice(i).join("/");if(ae instanceof RegExp&&ae.test(He)){O[P]=He,t.push(...$t(this,Qi,po).call(this,Re,r,L(R,mn),O));continue}(ae===!0||ae.test(o))&&(O[P]=o,c?(t.push(...$t(this,Qi,po).call(this,Re,r,O,L(R,mn))),L(Re,Jr)["*"]&&t.push(...$t(this,Qi,po).call(this,L(Re,Jr)["*"],r,O,L(R,mn)))):(ze(Re,mn,O),u.push(Re)))}}n=u}return[t.sort((i,a)=>i.score-a.score).map(({handler:i,params:a})=>[i,a])]}},ho=new WeakMap,Jr=new WeakMap,Uc=new WeakMap,Kl=new WeakMap,mn=new WeakMap,Qi=new WeakSet,po=function(r,e,t,n){const s=[];for(let i=0,a=L(r,ho).length;i<a;i++){const o=L(r,ho)[i],c=o[e]||o[yr],u={};if(c!==void 0){c.params=Object.create(null);for(let l=0,h=c.possibleKeys.length;l<h;l++){const R=c.possibleKeys[l],B=u[c.score];c.params[R]=n[R]&&!B?n[R]:t[R]??n[R],u[c.score]=!0}s.push(c)}}return s},kA),Vc,SA,zP=(SA=class{constructor(){$e(this,"name","TrieRouter"),Tt(this,Vc),ze(this,Vc,new vE)}add(r,e,t){const n=cE(e);if(n){for(let s=0,i=n.length;s<i;s++)L(this,Vc).insert(r,n[s],t);return}L(this,Vc).insert(r,e,t)}match(r,e){return L(this,Vc).search(r,e)}},Vc=new WeakMap,SA),WP=class extends mE{constructor(r={}){super(r),this.router=r.router??new KP({routers:[new FP,new zP]})}},Ut;(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})(Ut||(Ut={}));var x_;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(x_||(x_={}));const Se=Ut.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ua=r=>{switch(typeof r){case"undefined":return Se.undefined;case"string":return Se.string;case"number":return isNaN(r)?Se.nan:Se.number;case"boolean":return Se.boolean;case"function":return Se.function;case"bigint":return Se.bigint;case"symbol":return Se.symbol;case"object":return Array.isArray(r)?Se.array:r===null?Se.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?Se.promise:typeof Map<"u"&&r instanceof Map?Se.map:typeof Set<"u"&&r instanceof Set?Se.set:typeof Date<"u"&&r instanceof Date?Se.date:Se.object;default:return Se.unknown}},ne=Ut.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"]),GP=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let ms=class bE 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 bE))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ut.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()}};ms.create=r=>new ms(r);const Zu=(r,e)=>{let t;switch(r.code){case ne.invalid_type:r.received===Se.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case ne.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ut.jsonStringifyReplacer)}`;break;case ne.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ut.joinValues(r.keys,", ")}`;break;case ne.invalid_union:t="Invalid input";break;case ne.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ut.joinValues(r.options)}`;break;case ne.invalid_enum_value:t=`Invalid enum value. Expected ${Ut.joinValues(r.options)}, received '${r.received}'`;break;case ne.invalid_arguments:t="Invalid function arguments";break;case ne.invalid_return_type:t="Invalid function return type";break;case ne.invalid_date:t="Invalid date";break;case ne.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}"`:Ut.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case ne.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 ne.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 ne.custom:t="Invalid input";break;case ne.invalid_intersection_types:t="Intersection results could not be merged";break;case ne.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case ne.not_finite:t="Number must be finite";break;default:t=e.defaultError,Ut.assertNever(r)}return{message:t}};let _E=Zu;function JP(r){_E=r}function Py(){return _E}const $y=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}},YP=[];function ve(r,e){const t=Py(),n=$y({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Zu?void 0:Zu].filter(s=>!!s)});r.common.issues.push(n)}let cn=class wE{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 it;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 wE.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 it;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 it=Object.freeze({status:"aborted"}),Zy=r=>({status:"dirty",value:r}),Hr=r=>({status:"valid",value:r}),k_=r=>r.status==="aborted",S_=r=>r.status==="dirty",Bh=r=>r.status==="valid",Rh=r=>typeof Promise<"u"&&r instanceof Promise;function Dy(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 xE(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 Ve;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ve||(Ve={}));var ad,od;let Ys=class{constructor(r,e,t,n){this._cachedPath=[],this.parent=r,this.data=e,this._path=t,this._key=n}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 AA=(r,e)=>{if(Bh(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 ms(r.common.issues);return this._error=t,this._error}}};function gt(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}}let St=class{constructor(r){this.spa=this.safeParseAsync,this._def=r,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(r){return ua(r.data)}_getOrReturnCtx(r,e){return e||{common:r.parent.common,data:r.data,parsedType:ua(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}_processInputParams(r){return{status:new cn,ctx:{common:r.parent.common,data:r.data,parsedType:ua(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}}_parseSync(r){const e=this._parse(r);if(Rh(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(r){const e=this._parse(r);return Promise.resolve(e)}parse(r,e){const t=this.safeParse(r,e);if(t.success)return t.data;throw t.error}safeParse(r,e){var t;const n={common:{issues:[],async:(t=e==null?void 0:e.async)!==null&&t!==void 0?t:!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:ua(r)},s=this._parseSync({data:r,path:n.path,parent:n});return AA(n,s)}async parseAsync(r,e){const t=await this.safeParseAsync(r,e);if(t.success)return t.data;throw t.error}async safeParseAsync(r,e){const t={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:ua(r)},n=this._parse({data:r,path:t.path,parent:t}),s=await(Rh(n)?n:Promise.resolve(n));return AA(t,s)}refine(r,e){const t=n=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(n):e;return this._refinement((n,s)=>{const i=r(n),a=()=>s.addIssue({code:ne.custom,...t(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(o=>o?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(r,e){return this._refinement((t,n)=>r(t)?!0:(n.addIssue(typeof e=="function"?e(t,n):e),!1))}_refinement(r){return new xs({schema:this,typeName:Xe.ZodEffects,effect:{type:"refinement",refinement:r}})}superRefine(r){return this._refinement(r)}optional(){return Vs.create(this,this._def)}nullable(){return Da.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return sc.create(this,this._def)}promise(){return Uu.create(this,this._def)}or(r){return Vh.create([this,r],this._def)}and(r){return Lh.create(this,r,this._def)}transform(r){return new xs({...gt(this._def),schema:this,typeName:Xe.ZodEffects,effect:{type:"transform",transform:r}})}default(r){const e=typeof r=="function"?r:()=>r;return new Kh({...gt(this._def),innerType:this,defaultValue:e,typeName:Xe.ZodDefault})}brand(){return new mk({typeName:Xe.ZodBranded,type:this,...gt(this._def)})}catch(r){const e=typeof r=="function"?r:()=>r;return new zh({...gt(this._def),innerType:this,catchValue:e,typeName:Xe.ZodCatch})}describe(r){const e=this.constructor;return new e({...this._def,description:r})}pipe(r){return yk.create(this,r)}readonly(){return Wh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const XP=/^c[^\s-]{8,}$/i,QP=/^[0-9a-z]+$/,e$=/^[0-9A-HJKMNP-TV-Z]{26}$/,t$=/^[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,r$=/^[a-z0-9_-]{21}$/i,n$=/^[-+]?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)?)??$/,s$=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,i$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let lb;const a$=/^(?:(?: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])$/,o$=/^(([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})))$/,c$=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kE="((\\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])))",u$=new RegExp(`^${kE}$`);function SE(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 l$(r){return new RegExp(`^${SE(r)}$`)}function AE(r){let e=`${kE}T${SE(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 d$(r,e){return!!((e==="v4"||!e)&&a$.test(r)||(e==="v6"||!e)&&o$.test(r))}let Du=class cd extends St{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Se.string){const s=this._getOrReturnCtx(e);return ve(s,{code:ne.invalid_type,expected:Se.string,received:s.parsedType}),it}const t=new cn;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),ve(n,{code:ne.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),ve(n,{code:ne.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?ve(n,{code:ne.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ve(n,{code:ne.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")s$.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"email",code:ne.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")lb||(lb=new RegExp(i$,"u")),lb.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"emoji",code:ne.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")t$.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"uuid",code:ne.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")r$.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"nanoid",code:ne.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")XP.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"cuid",code:ne.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")QP.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"cuid2",code:ne.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")e$.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"ulid",code:ne.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),ve(n,{validation:"url",code:ne.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),ve(n,{validation:"regex",code:ne.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),ve(n,{code:ne.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),ve(n,{code:ne.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),ve(n,{code:ne.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?AE(s).test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{code:ne.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?u$.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{code:ne.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?l$(s).test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{code:ne.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?n$.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"duration",code:ne.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?d$(e.data,s.version)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"ip",code:ne.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?c$.test(e.data)||(n=this._getOrReturnCtx(e,n),ve(n,{validation:"base64",code:ne.invalid_string,message:s.message}),t.dirty()):Ut.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:ne.invalid_string,...Ve.errToObj(n)})}_addCheck(e){return new cd({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ve.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ve.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ve.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ve.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ve.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ve.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ve.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ve.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ve.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ve.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,...Ve.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,...Ve.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ve.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ve.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ve.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ve.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ve.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ve.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ve.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ve.errToObj(t)})}nonempty(e){return this.min(1,Ve.errToObj(e))}trim(){return new cd({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new cd({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new cd({...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}};Du.create=r=>{var e;return new Du({checks:[],typeName:Xe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...gt(r)})};function h$(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 Ph=class A_ extends St{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)!==Se.number){const s=this._getOrReturnCtx(e);return ve(s,{code:ne.invalid_type,expected:Se.number,received:s.parsedType}),it}let t;const n=new cn;for(const s of this._def.checks)s.kind==="int"?Ut.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),ve(t,{code:ne.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),ve(t,{code:ne.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),ve(t,{code:ne.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?h$(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),ve(t,{code:ne.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),ve(t,{code:ne.not_finite,message:s.message}),n.dirty()):Ut.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ve.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ve.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ve.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ve.toString(t))}setLimit(e,t,n,s){return new A_({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ve.toString(s)}]})}_addCheck(e){return new A_({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ve.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ve.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ve.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ve.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ve.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ve.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ve.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ve.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ve.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"&&Ut.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)}};Ph.create=r=>new Ph({checks:[],typeName:Xe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...gt(r)});let $h=class O_ extends St{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)!==Se.bigint){const s=this._getOrReturnCtx(e);return ve(s,{code:ne.invalid_type,expected:Se.bigint,received:s.parsedType}),it}let t;const n=new cn;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),ve(t,{code:ne.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),ve(t,{code:ne.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),ve(t,{code:ne.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Ut.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ve.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ve.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ve.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ve.toString(t))}setLimit(e,t,n,s){return new O_({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ve.toString(s)}]})}_addCheck(e){return new O_({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ve.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ve.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ve.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ve.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ve.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}};$h.create=r=>{var e;return new $h({checks:[],typeName:Xe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...gt(r)})};let Zh=class extends St{_parse(r){if(this._def.coerce&&(r.data=!!r.data),this._getType(r)!==Se.boolean){const e=this._getOrReturnCtx(r);return ve(e,{code:ne.invalid_type,expected:Se.boolean,received:e.parsedType}),it}return Hr(r.data)}};Zh.create=r=>new Zh({typeName:Xe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...gt(r)});let Dh=class OE extends St{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Se.date){const s=this._getOrReturnCtx(e);return ve(s,{code:ne.invalid_type,expected:Se.date,received:s.parsedType}),it}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return ve(s,{code:ne.invalid_date}),it}const t=new cn;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),ve(n,{code:ne.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),ve(n,{code:ne.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Ut.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new OE({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ve.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ve.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}};Dh.create=r=>new Dh({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Xe.ZodDate,...gt(r)});let My=class extends St{_parse(r){if(this._getType(r)!==Se.symbol){const e=this._getOrReturnCtx(r);return ve(e,{code:ne.invalid_type,expected:Se.symbol,received:e.parsedType}),it}return Hr(r.data)}};My.create=r=>new My({typeName:Xe.ZodSymbol,...gt(r)});let Mh=class extends St{_parse(r){if(this._getType(r)!==Se.undefined){const e=this._getOrReturnCtx(r);return ve(e,{code:ne.invalid_type,expected:Se.undefined,received:e.parsedType}),it}return Hr(r.data)}};Mh.create=r=>new Mh({typeName:Xe.ZodUndefined,...gt(r)});let Uh=class extends St{_parse(r){if(this._getType(r)!==Se.null){const e=this._getOrReturnCtx(r);return ve(e,{code:ne.invalid_type,expected:Se.null,received:e.parsedType}),it}return Hr(r.data)}};Uh.create=r=>new Uh({typeName:Xe.ZodNull,...gt(r)});let Mu=class extends St{constructor(){super(...arguments),this._any=!0}_parse(r){return Hr(r.data)}};Mu.create=r=>new Mu({typeName:Xe.ZodAny,...gt(r)});let $o=class extends St{constructor(){super(...arguments),this._unknown=!0}_parse(r){return Hr(r.data)}};$o.create=r=>new $o({typeName:Xe.ZodUnknown,...gt(r)});let Ri=class extends St{_parse(r){const e=this._getOrReturnCtx(r);return ve(e,{code:ne.invalid_type,expected:Se.never,received:e.parsedType}),it}};Ri.create=r=>new Ri({typeName:Xe.ZodNever,...gt(r)});let Uy=class extends St{_parse(r){if(this._getType(r)!==Se.undefined){const e=this._getOrReturnCtx(r);return ve(e,{code:ne.invalid_type,expected:Se.void,received:e.parsedType}),it}return Hr(r.data)}};Uy.create=r=>new Uy({typeName:Xe.ZodVoid,...gt(r)});let sc=class cm extends St{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==Se.array)return ve(t,{code:ne.invalid_type,expected:Se.array,received:t.parsedType}),it;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(ve(t,{code:a?ne.too_big:ne.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&&(ve(t,{code:ne.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&&(ve(t,{code:ne.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 Ys(t,a,t.path,o)))).then(a=>cn.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ys(t,a,t.path,o)));return cn.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new cm({...this._def,minLength:{value:e,message:Ve.toString(t)}})}max(e,t){return new cm({...this._def,maxLength:{value:e,message:Ve.toString(t)}})}length(e,t){return new cm({...this._def,exactLength:{value:e,message:Ve.toString(t)}})}nonempty(e){return this.min(1,e)}};sc.create=(r,e)=>new sc({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Xe.ZodArray,...gt(e)});function zc(r){if(r instanceof Vn){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Vs.create(zc(n))}return new Vn({...r._def,shape:()=>e})}else return r instanceof sc?new sc({...r._def,type:zc(r.element)}):r instanceof Vs?Vs.create(zc(r.unwrap())):r instanceof Da?Da.create(zc(r.unwrap())):r instanceof Za?Za.create(r.items.map(e=>zc(e))):r}let Vn=class Yn extends St{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=Ut.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Se.object){const c=this._getOrReturnCtx(e);return ve(c,{code:ne.invalid_type,expected:Se.object,received:c.parsedType}),it}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ri&&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],l=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Ys(n,l,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Ri){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&&(ve(n,{code:ne.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 l=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Ys(n,l,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const l=await u.key,h=await u.value;c.push({key:l,value:h,alwaysSet:u.alwaysSet})}return c}).then(c=>cn.mergeObjectSync(t,c)):cn.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Ve.errToObj,new Yn({...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=Ve.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Yn({...this._def,unknownKeys:"strip"})}passthrough(){return new Yn({...this._def,unknownKeys:"passthrough"})}extend(e){return new Yn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Yn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Xe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Yn({...this._def,catchall:e})}pick(e){const t={};return Ut.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Yn({...this._def,shape:()=>t})}omit(e){const t={};return Ut.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Yn({...this._def,shape:()=>t})}deepPartial(){return zc(this)}partial(e){const t={};return Ut.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Yn({...this._def,shape:()=>t})}required(e){const t={};return Ut.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Vs;)s=s._def.innerType;t[n]=s}}),new Yn({...this._def,shape:()=>t})}keyof(){return NE(Ut.objectKeys(this.shape))}};Vn.create=(r,e)=>new Vn({shape:()=>r,unknownKeys:"strip",catchall:Ri.create(),typeName:Xe.ZodObject,...gt(e)});Vn.strictCreate=(r,e)=>new Vn({shape:()=>r,unknownKeys:"strict",catchall:Ri.create(),typeName:Xe.ZodObject,...gt(e)});Vn.lazycreate=(r,e)=>new Vn({shape:r,unknownKeys:"strip",catchall:Ri.create(),typeName:Xe.ZodObject,...gt(e)});let Vh=class extends St{_parse(r){const{ctx:e}=this._processInputParams(r),t=this._def.options;function n(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return e.common.issues.push(...a.ctx.common.issues),a.result;const i=s.map(a=>new ms(a.ctx.common.issues));return ve(e,{code:ne.invalid_union,unionErrors:i}),it}if(e.common.async)return Promise.all(t.map(async s=>{const i={...e,common:{...e.common,issues:[]},parent:null};return{result:await s._parseAsync({data:e.data,path:e.path,parent:i}),ctx:i}})).then(n);{let s;const i=[];for(const o of t){const c={...e,common:{...e.common,issues:[]},parent:null},u=o._parseSync({data:e.data,path:e.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(s)return e.common.issues.push(...s.ctx.common.issues),s.result;const a=i.map(o=>new ms(o));return ve(e,{code:ne.invalid_union,unionErrors:a}),it}}get options(){return this._def.options}};Vh.create=(r,e)=>new Vh({options:r,typeName:Xe.ZodUnion,...gt(e)});const ta=r=>r instanceof qh?ta(r.schema):r instanceof xs?ta(r.innerType()):r instanceof Hh?[r.value]:r instanceof cf?r.options:r instanceof Fh?Ut.objectValues(r.enum):r instanceof Kh?ta(r._def.innerType):r instanceof Mh?[void 0]:r instanceof Uh?[null]:r instanceof Vs?[void 0,...ta(r.unwrap())]:r instanceof Da?[null,...ta(r.unwrap())]:r instanceof mk||r instanceof Wh?ta(r.unwrap()):r instanceof zh?ta(r._def.innerType):[];let jE=class CE extends St{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Se.object)return ve(t,{code:ne.invalid_type,expected:Se.object,received:t.parsedType}),it;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}):(ve(t,{code:ne.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),it)}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=ta(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 CE({typeName:Xe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...gt(n)})}};function j_(r,e){const t=ua(r),n=ua(e);if(r===e)return{valid:!0,data:r};if(t===Se.object&&n===Se.object){const s=Ut.objectKeys(e),i=Ut.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=j_(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===Se.array&&n===Se.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=j_(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===Se.date&&n===Se.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Lh=class extends St{_parse(r){const{status:e,ctx:t}=this._processInputParams(r),n=(s,i)=>{if(k_(s)||k_(i))return it;const a=j_(s.value,i.value);return a.valid?((S_(s)||S_(i))&&e.dirty(),{status:e.value,value:a.data}):(ve(t,{code:ne.invalid_intersection_types}),it)};return t.common.async?Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([s,i])=>n(s,i)):n(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};Lh.create=(r,e,t)=>new Lh({left:r,right:e,typeName:Xe.ZodIntersection,...gt(t)});let Za=class EE extends St{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Se.array)return ve(n,{code:ne.invalid_type,expected:Se.array,received:n.parsedType}),it;if(n.data.length<this._def.items.length)return ve(n,{code:ne.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),it;!this._def.rest&&n.data.length>this._def.items.length&&(ve(n,{code:ne.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 Ys(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>cn.mergeArray(t,i)):cn.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new EE({...this._def,rest:e})}};Za.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Za({items:r,typeName:Xe.ZodTuple,rest:null,...gt(e)})};let IE=class C_ extends St{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!==Se.object)return ve(n,{code:ne.invalid_type,expected:Se.object,received:n.parsedType}),it;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Ys(n,o,n.path,o)),value:a._parse(new Ys(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?cn.mergeObjectAsync(t,s):cn.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof St?new C_({keyType:e,valueType:t,typeName:Xe.ZodRecord,...gt(n)}):new C_({keyType:Du.create(),valueType:e,typeName:Xe.ZodRecord,...gt(t)})}},Vy=class extends St{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(r){const{status:e,ctx:t}=this._processInputParams(r);if(t.parsedType!==Se.map)return ve(t,{code:ne.invalid_type,expected:Se.map,received:t.parsedType}),it;const n=this._def.keyType,s=this._def.valueType,i=[...t.data.entries()].map(([a,o],c)=>({key:n._parse(new Ys(t,a,t.path,[c,"key"])),value:s._parse(new Ys(t,o,t.path,[c,"value"]))}));if(t.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const o of i){const c=await o.key,u=await o.value;if(c.status==="aborted"||u.status==="aborted")return it;(c.status==="dirty"||u.status==="dirty")&&e.dirty(),a.set(c.value,u.value)}return{status:e.value,value:a}})}else{const a=new Map;for(const o of i){const c=o.key,u=o.value;if(c.status==="aborted"||u.status==="aborted")return it;(c.status==="dirty"||u.status==="dirty")&&e.dirty(),a.set(c.value,u.value)}return{status:e.value,value:a}}}};Vy.create=(r,e,t)=>new Vy({valueType:e,keyType:r,typeName:Xe.ZodMap,...gt(t)});let Ly=class E_ extends St{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Se.set)return ve(n,{code:ne.invalid_type,expected:Se.set,received:n.parsedType}),it;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(ve(n,{code:ne.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&&(ve(n,{code:ne.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 l of c){if(l.status==="aborted")return it;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ys(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new E_({...this._def,minSize:{value:e,message:Ve.toString(t)}})}max(e,t){return new E_({...this._def,maxSize:{value:e,message:Ve.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ly.create=(r,e)=>new Ly({valueType:r,minSize:null,maxSize:null,typeName:Xe.ZodSet,...gt(e)});let TE=class um extends St{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Se.function)return ve(t,{code:ne.invalid_type,expected:Se.function,received:t.parsedType}),it;function n(o,c){return $y({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Py(),Zu].filter(u=>!!u),issueData:{code:ne.invalid_arguments,argumentsError:c}})}function s(o,c){return $y({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Py(),Zu].filter(u=>!!u),issueData:{code:ne.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Uu){const o=this;return Hr(async function(...c){const u=new ms([]),l=await o._def.args.parseAsync(c,i).catch(R=>{throw u.addIssue(n(c,R)),u}),h=await Reflect.apply(a,this,l);return await o._def.returns._def.type.parseAsync(h,i).catch(R=>{throw u.addIssue(s(h,R)),u})})}else{const o=this;return Hr(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new ms([n(c,u.error)]);const l=Reflect.apply(a,this,u.data),h=o._def.returns.safeParse(l,i);if(!h.success)throw new ms([s(l,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new um({...this._def,args:Za.create(e).rest($o.create())})}returns(e){return new um({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new um({args:e||Za.create([]).rest($o.create()),returns:t||$o.create(),typeName:Xe.ZodFunction,...gt(n)})}},qh=class extends St{get schema(){return this._def.getter()}_parse(r){const{ctx:e}=this._processInputParams(r);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};qh.create=(r,e)=>new qh({getter:r,typeName:Xe.ZodLazy,...gt(e)});let Hh=class extends St{_parse(r){if(r.data!==this._def.value){const e=this._getOrReturnCtx(r);return ve(e,{received:e.data,code:ne.invalid_literal,expected:this._def.value}),it}return{status:"valid",value:r.data}}get value(){return this._def.value}};Hh.create=(r,e)=>new Hh({value:r,typeName:Xe.ZodLiteral,...gt(e)});function NE(r,e){return new cf({values:r,typeName:Xe.ZodEnum,...gt(e)})}let cf=class I_ extends St{constructor(){super(...arguments),ad.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return ve(t,{expected:Ut.joinValues(n),received:t.parsedType,code:ne.invalid_type}),it}if(Dy(this,ad)||xE(this,ad,new Set(this._def.values)),!Dy(this,ad).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return ve(t,{received:t.data,code:ne.invalid_enum_value,options:n}),it}return Hr(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 I_.create(e,{...this._def,...t})}exclude(e,t=this._def){return I_.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};ad=new WeakMap;cf.create=NE;let Fh=class extends St{constructor(){super(...arguments),od.set(this,void 0)}_parse(r){const e=Ut.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(r);if(t.parsedType!==Se.string&&t.parsedType!==Se.number){const n=Ut.objectValues(e);return ve(t,{expected:Ut.joinValues(n),received:t.parsedType,code:ne.invalid_type}),it}if(Dy(this,od)||xE(this,od,new Set(Ut.getValidEnumValues(this._def.values))),!Dy(this,od).has(r.data)){const n=Ut.objectValues(e);return ve(t,{received:t.data,code:ne.invalid_enum_value,options:n}),it}return Hr(r.data)}get enum(){return this._def.values}};od=new WeakMap;Fh.create=(r,e)=>new Fh({values:r,typeName:Xe.ZodNativeEnum,...gt(e)});let Uu=class extends St{unwrap(){return this._def.type}_parse(r){const{ctx:e}=this._processInputParams(r);if(e.parsedType!==Se.promise&&e.common.async===!1)return ve(e,{code:ne.invalid_type,expected:Se.promise,received:e.parsedType}),it;const t=e.parsedType===Se.promise?e.data:Promise.resolve(e.data);return Hr(t.then(n=>this._def.type.parseAsync(n,{path:e.path,errorMap:e.common.contextualErrorMap})))}};Uu.create=(r,e)=>new Uu({type:r,typeName:Xe.ZodPromise,...gt(e)});let xs=class extends St{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Xe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(r){const{status:e,ctx:t}=this._processInputParams(r),n=this._def.effect||null,s={addIssue:i=>{ve(t,i),i.fatal?e.abort():e.dirty()},get path(){return t.path}};if(s.addIssue=s.addIssue.bind(s),n.type==="preprocess"){const i=n.transform(t.data,s);if(t.common.async)return Promise.resolve(i).then(async a=>{if(e.value==="aborted")return it;const o=await this._def.schema._parseAsync({data:a,path:t.path,parent:t});return o.status==="aborted"?it:o.status==="dirty"||e.value==="dirty"?Zy(o.value):o});{if(e.value==="aborted")return it;const a=this._def.schema._parseSync({data:i,path:t.path,parent:t});return a.status==="aborted"?it:a.status==="dirty"||e.value==="dirty"?Zy(a.value):a}}if(n.type==="refinement"){const i=a=>{const o=n.refinement(a,s);if(t.common.async)return Promise.resolve(o);if(o instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(t.common.async===!1){const a=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});return a.status==="aborted"?it:(a.status==="dirty"&&e.dirty(),i(a.value),{status:e.value,value:a.value})}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(a=>a.status==="aborted"?it:(a.status==="dirty"&&e.dirty(),i(a.value).then(()=>({status:e.value,value:a.value}))))}if(n.type==="transform")if(t.common.async===!1){const i=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!Bh(i))return i;const a=n.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:a}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(i=>Bh(i)?Promise.resolve(n.transform(i.value,s)).then(a=>({status:e.value,value:a})):i);Ut.assertNever(n)}};xs.create=(r,e,t)=>new xs({schema:r,typeName:Xe.ZodEffects,effect:e,...gt(t)});xs.createWithPreprocess=(r,e,t)=>new xs({schema:e,effect:{type:"preprocess",transform:r},typeName:Xe.ZodEffects,...gt(t)});let Vs=class extends St{_parse(r){return this._getType(r)===Se.undefined?Hr(void 0):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}};Vs.create=(r,e)=>new Vs({innerType:r,typeName:Xe.ZodOptional,...gt(e)});let Da=class extends St{_parse(r){return this._getType(r)===Se.null?Hr(null):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}};Da.create=(r,e)=>new Da({innerType:r,typeName:Xe.ZodNullable,...gt(e)});let Kh=class extends St{_parse(r){const{ctx:e}=this._processInputParams(r);let t=e.data;return e.parsedType===Se.undefined&&(t=this._def.defaultValue()),this._def.innerType._parse({data:t,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};Kh.create=(r,e)=>new Kh({innerType:r,typeName:Xe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...gt(e)});let zh=class extends St{_parse(r){const{ctx:e}=this._processInputParams(r),t={...e,common:{...e.common,issues:[]}},n=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});return Rh(n)?n.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ms(t.common.issues)},input:t.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ms(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};zh.create=(r,e)=>new zh({innerType:r,typeName:Xe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...gt(e)});let qy=class extends St{_parse(r){if(this._getType(r)!==Se.nan){const e=this._getOrReturnCtx(r);return ve(e,{code:ne.invalid_type,expected:Se.nan,received:e.parsedType}),it}return{status:"valid",value:r.data}}};qy.create=r=>new qy({typeName:Xe.ZodNaN,...gt(r)});const p$=Symbol("zod_brand");let mk=class extends St{_parse(r){const{ctx:e}=this._processInputParams(r),t=e.data;return this._def.type._parse({data:t,path:e.path,parent:e})}unwrap(){return this._def.type}},yk=class BE extends St{_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"?it:s.status==="dirty"?(t.dirty(),Zy(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"?it: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 BE({in:e,out:t,typeName:Xe.ZodPipeline})}},Wh=class extends St{_parse(r){const e=this._def.innerType._parse(r),t=n=>(Bh(n)&&(n.value=Object.freeze(n.value)),n);return Rh(e)?e.then(n=>t(n)):t(e)}unwrap(){return this._def.innerType}};Wh.create=(r,e)=>new Wh({innerType:r,typeName:Xe.ZodReadonly,...gt(e)});function RE(r,e={},t){return r?Mu.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})}}):Mu.create()}const f$={object:Vn.lazycreate};var Xe;(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"})(Xe||(Xe={}));const m$=(r,e={message:`Input not instance of ${r.name}`})=>RE(t=>t instanceof r,e),PE=Du.create,$E=Ph.create,y$=qy.create,g$=$h.create,ZE=Zh.create,v$=Dh.create,b$=My.create,_$=Mh.create,w$=Uh.create,x$=Mu.create,k$=$o.create,S$=Ri.create,A$=Uy.create,O$=sc.create,j$=Vn.create,C$=Vn.strictCreate,E$=Vh.create,I$=jE.create,T$=Lh.create,N$=Za.create,B$=IE.create,R$=Vy.create,P$=Ly.create,$$=TE.create,Z$=qh.create,D$=Hh.create,M$=cf.create,U$=Fh.create,V$=Uu.create,OA=xs.create,L$=Vs.create,q$=Da.create,H$=xs.createWithPreprocess,F$=yk.create,K$=()=>PE().optional(),z$=()=>$E().optional(),W$=()=>ZE().optional(),G$={string:r=>Du.create({...r,coerce:!0}),number:r=>Ph.create({...r,coerce:!0}),boolean:r=>Zh.create({...r,coerce:!0}),bigint:r=>$h.create({...r,coerce:!0}),date:r=>Dh.create({...r,coerce:!0})},J$=it;var N=Object.freeze({__proto__:null,defaultErrorMap:Zu,setErrorMap:JP,getErrorMap:Py,makeIssue:$y,EMPTY_PATH:YP,addIssueToContext:ve,ParseStatus:cn,INVALID:it,DIRTY:Zy,OK:Hr,isAborted:k_,isDirty:S_,isValid:Bh,isAsync:Rh,get util(){return Ut},get objectUtil(){return x_},ZodParsedType:Se,getParsedType:ua,ZodType:St,datetimeRegex:AE,ZodString:Du,ZodNumber:Ph,ZodBigInt:$h,ZodBoolean:Zh,ZodDate:Dh,ZodSymbol:My,ZodUndefined:Mh,ZodNull:Uh,ZodAny:Mu,ZodUnknown:$o,ZodNever:Ri,ZodVoid:Uy,ZodArray:sc,ZodObject:Vn,ZodUnion:Vh,ZodDiscriminatedUnion:jE,ZodIntersection:Lh,ZodTuple:Za,ZodRecord:IE,ZodMap:Vy,ZodSet:Ly,ZodFunction:TE,ZodLazy:qh,ZodLiteral:Hh,ZodEnum:cf,ZodNativeEnum:Fh,ZodPromise:Uu,ZodEffects:xs,ZodTransformer:xs,ZodOptional:Vs,ZodNullable:Da,ZodDefault:Kh,ZodCatch:zh,ZodNaN:qy,BRAND:p$,ZodBranded:mk,ZodPipeline:yk,ZodReadonly:Wh,custom:RE,Schema:St,ZodSchema:St,late:f$,get ZodFirstPartyTypeKind(){return Xe},coerce:G$,any:x$,array:O$,bigint:g$,boolean:ZE,date:v$,discriminatedUnion:I$,effect:OA,enum:M$,function:$$,instanceof:m$,intersection:T$,lazy:Z$,literal:D$,map:R$,nan:y$,nativeEnum:U$,never:S$,null:w$,nullable:q$,number:$E,object:j$,oboolean:W$,onumber:z$,optional:L$,ostring:K$,pipeline:F$,preprocess:H$,promise:V$,record:B$,set:P$,strictObject:C$,string:PE,symbol:b$,transformer:OA,tuple:N$,undefined:_$,union:E$,unknown:k$,void:A$,NEVER:J$,ZodIssueCode:ne,quotelessJson:GP,ZodError:ms}),On=class T_ extends WP{constructor(e){super(e),$e(this,"openAPIRegistry"),$e(this,"defaultHook"),$e(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var a,o,c,u,l,h,R,B,d,g;this.openAPIRegistry.registerPath(n);const A=[];if((a=n.request)!=null&&a.query){const P=Nc("query",n.request.query,i);A.push(P)}if((o=n.request)!=null&&o.params){const P=Nc("param",n.request.params,i);A.push(P)}if((c=n.request)!=null&&c.headers){const P=Nc("header",n.request.headers,i);A.push(P)}if((u=n.request)!=null&&u.cookies){const P=Nc("cookie",n.request.cookies,i);A.push(P)}const O=(h=(l=n.request)==null?void 0:l.body)==null?void 0:h.content;if(O)for(const P of Object.keys(O)){if(!O[P])continue;const ae=O[P].schema;if(ae instanceof St){if(CA(P)){const Re=Nc("json",ae,i);if((B=(R=n.request)==null?void 0:R.body)!=null&&B.required)A.push(Re);else{const He=async(Te,Nt)=>{if(Te.req.header("content-type")&&CA(Te.req.header("content-type")))return await Re(Te,Nt);Te.req.addValidatedData("json",{}),await Nt()};A.push(He)}}if(EA(P)){const Re=Nc("form",ae,i);if((g=(d=n.request)==null?void 0:d.body)!=null&&g.required)A.push(Re);else{const He=async(Te,Nt)=>{if(Te.req.header("content-type")&&EA(Te.req.header("content-type")))return await Re(Te,Nt);Te.req.addValidatedData("form",{}),await Nt()};A.push(He)}}}}const $=t?Array.isArray(t)?t:[t]:[];return this.on([n.method],n.path.replaceAll(/\/{(.+?)}/g,"/:$1"),...$,...A,s),this}),$e(this,"getOpenAPIDocument",t=>{const n=new cP(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?jA(n,this._basePath):n}),$e(this,"getOpenAPI31Document",t=>{const n=new dP(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?jA(n,this._basePath):n}),$e(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)}})),$e(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 H7,this.defaultHook=e==null?void 0:e.defaultHook}route(e,t){const n=e.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(e,t),t instanceof T_?(t.openAPIRegistry.definitions.forEach(s=>{switch(s.type){case"component":return this.openAPIRegistry.registerComponent(s.componentType,s.name,s.component);case"route":return this.openAPIRegistry.registerPath({...s.route,path:ca(n,s.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...s.webhook,path:ca(n,s.webhook.path)});case"schema":return this.openAPIRegistry.register(s.schema._def.openapi._internal.refId,s.schema);case"parameter":return this.openAPIRegistry.registerParameter(s.schema._def.openapi._internal.refId,s.schema);default:{const i=s;throw new Error(`Unknown registry type: ${i}`)}}}),this):this}basePath(e){return new T_({...super.basePath(e),defaultHook:this.defaultHook})}},ut=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};U7(N);function jA(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[ca(e,n)]=r.paths[n]}),{...r,paths:t}}function CA(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function EA(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function Y$(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 X$(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function zl(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 Q$(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,l,h;const R=typeof s=="string"?i:s,B=R??{},{param:d}=B,g=Y$(B,["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),O=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),g),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||d?{param:Object.assign(Object.assign({},(h=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||h===void 0?void 0:h.param),d)}:void 0),$=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(A).length>0?{_internal:A}:void 0),Object.keys(O).length>0?{metadata:O}:void 0)}));if(X$(this,"ZodObject")){const P=this.extend;$.extend=function(...ae){var Re,He,Te,Nt,Gt,Jt;const C=P.apply(this,ae);return C._def.openapi={_internal:{extendedFrom:!((He=(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal)===null||He===void 0)&&He.refId?{refId:(Nt=(Te=this._def.openapi)===null||Te===void 0?void 0:Te._internal)===null||Nt===void 0?void 0:Nt.refId,schema:this}:(Gt=this._def.openapi)===null||Gt===void 0?void 0:Gt._internal.extendedFrom},metadata:(Jt=C._def.openapi)===null||Jt===void 0?void 0:Jt.metadata},C}}return $},zl(r,"optional"),zl(r,"nullable"),zl(r,"default"),zl(r,"transform"),zl(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,l;c._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.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 Vt;(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})(Vt||(Vt={}));var N_;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(N_||(N_={}));const Ae=Vt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),la=r=>{switch(typeof r){case"undefined":return Ae.undefined;case"string":return Ae.string;case"number":return isNaN(r)?Ae.nan:Ae.number;case"boolean":return Ae.boolean;case"function":return Ae.function;case"bigint":return Ae.bigint;case"symbol":return Ae.symbol;case"object":return Array.isArray(r)?Ae.array:r===null?Ae.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?Ae.promise:typeof Map<"u"&&r instanceof Map?Ae.map:typeof Set<"u"&&r instanceof Set?Ae.set:typeof Date<"u"&&r instanceof Date?Ae.date:Ae.object;default:return Ae.unknown}},se=Vt.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"]),eZ=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class xn 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 xn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Vt.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()}}xn.create=r=>new xn(r);const Vu=(r,e)=>{let t;switch(r.code){case se.invalid_type:r.received===Ae.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case se.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Vt.jsonStringifyReplacer)}`;break;case se.unrecognized_keys:t=`Unrecognized key(s) in object: ${Vt.joinValues(r.keys,", ")}`;break;case se.invalid_union:t="Invalid input";break;case se.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Vt.joinValues(r.options)}`;break;case se.invalid_enum_value:t=`Invalid enum value. Expected ${Vt.joinValues(r.options)}, received '${r.received}'`;break;case se.invalid_arguments:t="Invalid function arguments";break;case se.invalid_return_type:t="Invalid function return type";break;case se.invalid_date:t="Invalid date";break;case se.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}"`:Vt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case se.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 se.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 se.custom:t="Invalid input";break;case se.invalid_intersection_types:t="Intersection results could not be merged";break;case se.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case se.not_finite:t="Number must be finite";break;default:t=e.defaultError,Vt.assertNever(r)}return{message:t}};let DE=Vu;function tZ(r){DE=r}function Hy(){return DE}const Fy=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}},rZ=[];function be(r,e){const t=Hy(),n=Fy({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Vu?void 0:Vu].filter(s=>!!s)});r.common.issues.push(n)}class Rr{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 at;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 Rr.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 at;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 at=Object.freeze({status:"aborted"}),Ky=r=>({status:"dirty",value:r}),Fr=r=>({status:"valid",value:r}),B_=r=>r.status==="aborted",R_=r=>r.status==="dirty",Gh=r=>r.status==="valid",Jh=r=>typeof Promise<"u"&&r instanceof Promise;function zy(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 ME(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 Le;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Le||(Le={}));var ud,ld;class Xs{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 IA=(r,e)=>{if(Gh(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 xn(r.common.issues);return this._error=t,this._error}}};function vt(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 Ct{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 la(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:la(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Rr,ctx:{common:e.parent.common,data:e.data,parsedType:la(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Jh(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:la(e)},i=this._parseSync({data:e,path:s.path,parent:s});return IA(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:la(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Jh(s)?s:Promise.resolve(s));return IA(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:se.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 ks({schema:this,typeName:Qe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Ls.create(this,this._def)}nullable(){return La.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ys.create(this,this._def)}promise(){return qu.create(this,this._def)}or(e){return ep.create([this,e],this._def)}and(e){return tp.create(this,e,this._def)}transform(e){return new ks({...vt(this._def),schema:this,typeName:Qe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ap({...vt(this._def),innerType:this,defaultValue:t,typeName:Qe.ZodDefault})}brand(){return new gk({typeName:Qe.ZodBranded,type:this,...vt(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new op({...vt(this._def),innerType:this,catchValue:t,typeName:Qe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return uf.create(this,e)}readonly(){return cp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const nZ=/^c[^\s-]{8,}$/i,sZ=/^[0-9a-z]+$/,iZ=/^[0-9A-HJKMNP-TV-Z]{26}$/,aZ=/^[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,oZ=/^[a-z0-9_-]{21}$/i,cZ=/^[-+]?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)?)??$/,uZ=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,lZ="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let db;const dZ=/^(?:(?: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])$/,hZ=/^(([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})))$/,pZ=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,UE="((\\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])))",fZ=new RegExp(`^${UE}$`);function VE(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 mZ(r){return new RegExp(`^${VE(r)}$`)}function LE(r){let e=`${UE}T${VE(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 yZ(r,e){return!!((e==="v4"||!e)&&dZ.test(r)||(e==="v6"||!e)&&hZ.test(r))}class cs extends Ct{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Ae.string){const s=this._getOrReturnCtx(e);return be(s,{code:se.invalid_type,expected:Ae.string,received:s.parsedType}),at}const t=new Rr;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),be(n,{code:se.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),be(n,{code:se.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?be(n,{code:se.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&be(n,{code:se.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")uZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"email",code:se.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")db||(db=new RegExp(lZ,"u")),db.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"emoji",code:se.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")aZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"uuid",code:se.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")oZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"nanoid",code:se.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")nZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"cuid",code:se.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")sZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"cuid2",code:se.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")iZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"ulid",code:se.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),be(n,{validation:"url",code:se.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),be(n,{validation:"regex",code:se.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),be(n,{code:se.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),be(n,{code:se.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),be(n,{code:se.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?LE(s).test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{code:se.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?fZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{code:se.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?mZ(s).test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{code:se.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?cZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"duration",code:se.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?yZ(e.data,s.version)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"ip",code:se.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?pZ.test(e.data)||(n=this._getOrReturnCtx(e,n),be(n,{validation:"base64",code:se.invalid_string,message:s.message}),t.dirty()):Vt.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:se.invalid_string,...Le.errToObj(n)})}_addCheck(e){return new cs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Le.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Le.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Le.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Le.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Le.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Le.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Le.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Le.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Le.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Le.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,...Le.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,...Le.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Le.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Le.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Le.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Le.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Le.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Le.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Le.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Le.errToObj(t)})}nonempty(e){return this.min(1,Le.errToObj(e))}trim(){return new cs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new cs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new cs({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}cs.create=r=>{var e;return new cs({checks:[],typeName:Qe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...vt(r)})};function gZ(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 Ma extends Ct{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)!==Ae.number){const s=this._getOrReturnCtx(e);return be(s,{code:se.invalid_type,expected:Ae.number,received:s.parsedType}),at}let t;const n=new Rr;for(const s of this._def.checks)s.kind==="int"?Vt.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),be(t,{code:se.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),be(t,{code:se.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),be(t,{code:se.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?gZ(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),be(t,{code:se.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),be(t,{code:se.not_finite,message:s.message}),n.dirty()):Vt.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Le.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Le.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Le.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Le.toString(t))}setLimit(e,t,n,s){return new Ma({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Le.toString(s)}]})}_addCheck(e){return new Ma({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Le.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Le.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Le.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Le.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Le.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Le.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"&&Vt.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)}}Ma.create=r=>new Ma({checks:[],typeName:Qe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...vt(r)});class Ua extends Ct{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)!==Ae.bigint){const s=this._getOrReturnCtx(e);return be(s,{code:se.invalid_type,expected:Ae.bigint,received:s.parsedType}),at}let t;const n=new Rr;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),be(t,{code:se.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),be(t,{code:se.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),be(t,{code:se.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Vt.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Le.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Le.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Le.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Le.toString(t))}setLimit(e,t,n,s){return new Ua({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Le.toString(s)}]})}_addCheck(e){return new Ua({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Le.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Le.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}}Ua.create=r=>{var e;return new Ua({checks:[],typeName:Qe.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...vt(r)})};class Yh extends Ct{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Ae.boolean){const t=this._getOrReturnCtx(e);return be(t,{code:se.invalid_type,expected:Ae.boolean,received:t.parsedType}),at}return Fr(e.data)}}Yh.create=r=>new Yh({typeName:Qe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...vt(r)});class ic extends Ct{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Ae.date){const s=this._getOrReturnCtx(e);return be(s,{code:se.invalid_type,expected:Ae.date,received:s.parsedType}),at}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return be(s,{code:se.invalid_date}),at}const t=new Rr;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),be(n,{code:se.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),be(n,{code:se.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Vt.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ic({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Le.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Le.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}}ic.create=r=>new ic({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Qe.ZodDate,...vt(r)});class Wy extends Ct{_parse(e){if(this._getType(e)!==Ae.symbol){const t=this._getOrReturnCtx(e);return be(t,{code:se.invalid_type,expected:Ae.symbol,received:t.parsedType}),at}return Fr(e.data)}}Wy.create=r=>new Wy({typeName:Qe.ZodSymbol,...vt(r)});class Xh extends Ct{_parse(e){if(this._getType(e)!==Ae.undefined){const t=this._getOrReturnCtx(e);return be(t,{code:se.invalid_type,expected:Ae.undefined,received:t.parsedType}),at}return Fr(e.data)}}Xh.create=r=>new Xh({typeName:Qe.ZodUndefined,...vt(r)});class Qh extends Ct{_parse(e){if(this._getType(e)!==Ae.null){const t=this._getOrReturnCtx(e);return be(t,{code:se.invalid_type,expected:Ae.null,received:t.parsedType}),at}return Fr(e.data)}}Qh.create=r=>new Qh({typeName:Qe.ZodNull,...vt(r)});class Lu extends Ct{constructor(){super(...arguments),this._any=!0}_parse(e){return Fr(e.data)}}Lu.create=r=>new Lu({typeName:Qe.ZodAny,...vt(r)});class Zo extends Ct{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fr(e.data)}}Zo.create=r=>new Zo({typeName:Qe.ZodUnknown,...vt(r)});class Pi extends Ct{_parse(e){const t=this._getOrReturnCtx(e);return be(t,{code:se.invalid_type,expected:Ae.never,received:t.parsedType}),at}}Pi.create=r=>new Pi({typeName:Qe.ZodNever,...vt(r)});class Gy extends Ct{_parse(e){if(this._getType(e)!==Ae.undefined){const t=this._getOrReturnCtx(e);return be(t,{code:se.invalid_type,expected:Ae.void,received:t.parsedType}),at}return Fr(e.data)}}Gy.create=r=>new Gy({typeName:Qe.ZodVoid,...vt(r)});class ys extends Ct{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==Ae.array)return be(t,{code:se.invalid_type,expected:Ae.array,received:t.parsedType}),at;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(be(t,{code:a?se.too_big:se.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&&(be(t,{code:se.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&&(be(t,{code:se.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 Xs(t,a,t.path,o)))).then(a=>Rr.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Xs(t,a,t.path,o)));return Rr.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new ys({...this._def,minLength:{value:e,message:Le.toString(t)}})}max(e,t){return new ys({...this._def,maxLength:{value:e,message:Le.toString(t)}})}length(e,t){return new ys({...this._def,exactLength:{value:e,message:Le.toString(t)}})}nonempty(e){return this.min(1,e)}}ys.create=(r,e)=>new ys({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Qe.ZodArray,...vt(e)});function Wc(r){if(r instanceof ur){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Ls.create(Wc(n))}return new ur({...r._def,shape:()=>e})}else return r instanceof ys?new ys({...r._def,type:Wc(r.element)}):r instanceof Ls?Ls.create(Wc(r.unwrap())):r instanceof La?La.create(Wc(r.unwrap())):r instanceof Qs?Qs.create(r.items.map(e=>Wc(e))):r}class ur extends Ct{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=Vt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Ae.object){const c=this._getOrReturnCtx(e);return be(c,{code:se.invalid_type,expected:Ae.object,received:c.parsedType}),at}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Pi&&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],l=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new Xs(n,l,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Pi){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&&(be(n,{code:se.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 l=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new Xs(n,l,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const l=await u.key,h=await u.value;c.push({key:l,value:h,alwaysSet:u.alwaysSet})}return c}).then(c=>Rr.mergeObjectSync(t,c)):Rr.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Le.errToObj,new ur({...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=Le.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new ur({...this._def,unknownKeys:"strip"})}passthrough(){return new ur({...this._def,unknownKeys:"passthrough"})}extend(e){return new ur({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ur({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Qe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ur({...this._def,catchall:e})}pick(e){const t={};return Vt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new ur({...this._def,shape:()=>t})}omit(e){const t={};return Vt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new ur({...this._def,shape:()=>t})}deepPartial(){return Wc(this)}partial(e){const t={};return Vt.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new ur({...this._def,shape:()=>t})}required(e){const t={};return Vt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Ls;)s=s._def.innerType;t[n]=s}}),new ur({...this._def,shape:()=>t})}keyof(){return qE(Vt.objectKeys(this.shape))}}ur.create=(r,e)=>new ur({shape:()=>r,unknownKeys:"strip",catchall:Pi.create(),typeName:Qe.ZodObject,...vt(e)});ur.strictCreate=(r,e)=>new ur({shape:()=>r,unknownKeys:"strict",catchall:Pi.create(),typeName:Qe.ZodObject,...vt(e)});ur.lazycreate=(r,e)=>new ur({shape:r,unknownKeys:"strip",catchall:Pi.create(),typeName:Qe.ZodObject,...vt(e)});class ep extends Ct{_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 xn(o.ctx.common.issues));return be(t,{code:se.invalid_union,unionErrors:a}),at}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},l=c._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,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 xn(c));return be(t,{code:se.invalid_union,unionErrors:o}),at}}get options(){return this._def.options}}ep.create=(r,e)=>new ep({options:r,typeName:Qe.ZodUnion,...vt(e)});const ra=r=>r instanceof np?ra(r.schema):r instanceof ks?ra(r.innerType()):r instanceof sp?[r.value]:r instanceof Va?r.options:r instanceof ip?Vt.objectValues(r.enum):r instanceof ap?ra(r._def.innerType):r instanceof Xh?[void 0]:r instanceof Qh?[null]:r instanceof Ls?[void 0,...ra(r.unwrap())]:r instanceof La?[null,...ra(r.unwrap())]:r instanceof gk||r instanceof cp?ra(r.unwrap()):r instanceof op?ra(r._def.innerType):[];class Mv extends Ct{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ae.object)return be(t,{code:se.invalid_type,expected:Ae.object,received:t.parsedType}),at;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}):(be(t,{code:se.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),at)}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=ra(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 Mv({typeName:Qe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...vt(n)})}}function P_(r,e){const t=la(r),n=la(e);if(r===e)return{valid:!0,data:r};if(t===Ae.object&&n===Ae.object){const s=Vt.objectKeys(e),i=Vt.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=P_(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===Ae.array&&n===Ae.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=P_(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===Ae.date&&n===Ae.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class tp extends Ct{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(B_(i)||B_(a))return at;const o=P_(i.value,a.value);return o.valid?((R_(i)||R_(a))&&t.dirty(),{status:t.value,value:o.data}):(be(n,{code:se.invalid_intersection_types}),at)};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}))}}tp.create=(r,e,t)=>new tp({left:r,right:e,typeName:Qe.ZodIntersection,...vt(t)});class Qs extends Ct{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ae.array)return be(n,{code:se.invalid_type,expected:Ae.array,received:n.parsedType}),at;if(n.data.length<this._def.items.length)return be(n,{code:se.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),at;!this._def.rest&&n.data.length>this._def.items.length&&(be(n,{code:se.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 Xs(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>Rr.mergeArray(t,i)):Rr.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qs({...this._def,rest:e})}}Qs.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qs({items:r,typeName:Qe.ZodTuple,rest:null,...vt(e)})};class rp extends Ct{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!==Ae.object)return be(n,{code:se.invalid_type,expected:Ae.object,received:n.parsedType}),at;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Xs(n,o,n.path,o)),value:a._parse(new Xs(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?Rr.mergeObjectAsync(t,s):Rr.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ct?new rp({keyType:e,valueType:t,typeName:Qe.ZodRecord,...vt(n)}):new rp({keyType:cs.create(),valueType:e,typeName:Qe.ZodRecord,...vt(t)})}}class Jy extends Ct{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!==Ae.map)return be(n,{code:se.invalid_type,expected:Ae.map,received:n.parsedType}),at;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Xs(n,o,n.path,[u,"key"])),value:i._parse(new Xs(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,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return at;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return at;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}Jy.create=(r,e,t)=>new Jy({valueType:e,keyType:r,typeName:Qe.ZodMap,...vt(t)});class ac extends Ct{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Ae.set)return be(n,{code:se.invalid_type,expected:Ae.set,received:n.parsedType}),at;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(be(n,{code:se.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&&(be(n,{code:se.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 l of c){if(l.status==="aborted")return at;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Xs(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ac({...this._def,minSize:{value:e,message:Le.toString(t)}})}max(e,t){return new ac({...this._def,maxSize:{value:e,message:Le.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ac.create=(r,e)=>new ac({valueType:r,minSize:null,maxSize:null,typeName:Qe.ZodSet,...vt(e)});class cu extends Ct{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ae.function)return be(t,{code:se.invalid_type,expected:Ae.function,received:t.parsedType}),at;function n(o,c){return Fy({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Hy(),Vu].filter(u=>!!u),issueData:{code:se.invalid_arguments,argumentsError:c}})}function s(o,c){return Fy({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Hy(),Vu].filter(u=>!!u),issueData:{code:se.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qu){const o=this;return Fr(async function(...c){const u=new xn([]),l=await o._def.args.parseAsync(c,i).catch(R=>{throw u.addIssue(n(c,R)),u}),h=await Reflect.apply(a,this,l);return await o._def.returns._def.type.parseAsync(h,i).catch(R=>{throw u.addIssue(s(h,R)),u})})}else{const o=this;return Fr(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new xn([n(c,u.error)]);const l=Reflect.apply(a,this,u.data),h=o._def.returns.safeParse(l,i);if(!h.success)throw new xn([s(l,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new cu({...this._def,args:Qs.create(e).rest(Zo.create())})}returns(e){return new cu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new cu({args:e||Qs.create([]).rest(Zo.create()),returns:t||Zo.create(),typeName:Qe.ZodFunction,...vt(n)})}}class np extends Ct{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})}}np.create=(r,e)=>new np({getter:r,typeName:Qe.ZodLazy,...vt(e)});class sp extends Ct{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return be(t,{received:t.data,code:se.invalid_literal,expected:this._def.value}),at}return{status:"valid",value:e.data}}get value(){return this._def.value}}sp.create=(r,e)=>new sp({value:r,typeName:Qe.ZodLiteral,...vt(e)});function qE(r,e){return new Va({values:r,typeName:Qe.ZodEnum,...vt(e)})}class Va extends Ct{constructor(){super(...arguments),ud.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return be(t,{expected:Vt.joinValues(n),received:t.parsedType,code:se.invalid_type}),at}if(zy(this,ud)||ME(this,ud,new Set(this._def.values)),!zy(this,ud).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return be(t,{received:t.data,code:se.invalid_enum_value,options:n}),at}return Fr(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 Va.create(e,{...this._def,...t})}exclude(e,t=this._def){return Va.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}ud=new WeakMap;Va.create=qE;class ip extends Ct{constructor(){super(...arguments),ld.set(this,void 0)}_parse(e){const t=Vt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Ae.string&&n.parsedType!==Ae.number){const s=Vt.objectValues(t);return be(n,{expected:Vt.joinValues(s),received:n.parsedType,code:se.invalid_type}),at}if(zy(this,ld)||ME(this,ld,new Set(Vt.getValidEnumValues(this._def.values))),!zy(this,ld).has(e.data)){const s=Vt.objectValues(t);return be(n,{received:n.data,code:se.invalid_enum_value,options:s}),at}return Fr(e.data)}get enum(){return this._def.values}}ld=new WeakMap;ip.create=(r,e)=>new ip({values:r,typeName:Qe.ZodNativeEnum,...vt(e)});class qu extends Ct{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Ae.promise&&t.common.async===!1)return be(t,{code:se.invalid_type,expected:Ae.promise,received:t.parsedType}),at;const n=t.parsedType===Ae.promise?t.data:Promise.resolve(t.data);return Fr(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}qu.create=(r,e)=>new qu({type:r,typeName:Qe.ZodPromise,...vt(e)});class ks extends Ct{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Qe.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=>{be(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 at;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?at:c.status==="dirty"||t.value==="dirty"?Ky(c.value):c});{if(t.value==="aborted")return at;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?at:o.status==="dirty"||t.value==="dirty"?Ky(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"?at:(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"?at:(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(!Gh(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=>Gh(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Vt.assertNever(s)}}ks.create=(r,e,t)=>new ks({schema:r,typeName:Qe.ZodEffects,effect:e,...vt(t)});ks.createWithPreprocess=(r,e,t)=>new ks({schema:e,effect:{type:"preprocess",transform:r},typeName:Qe.ZodEffects,...vt(t)});class Ls extends Ct{_parse(e){return this._getType(e)===Ae.undefined?Fr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ls.create=(r,e)=>new Ls({innerType:r,typeName:Qe.ZodOptional,...vt(e)});class La extends Ct{_parse(e){return this._getType(e)===Ae.null?Fr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}La.create=(r,e)=>new La({innerType:r,typeName:Qe.ZodNullable,...vt(e)});class ap extends Ct{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===Ae.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ap.create=(r,e)=>new ap({innerType:r,typeName:Qe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...vt(e)});class op extends Ct{_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 Jh(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new xn(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new xn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}op.create=(r,e)=>new op({innerType:r,typeName:Qe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...vt(e)});class Yy extends Ct{_parse(e){if(this._getType(e)!==Ae.nan){const t=this._getOrReturnCtx(e);return be(t,{code:se.invalid_type,expected:Ae.nan,received:t.parsedType}),at}return{status:"valid",value:e.data}}}Yy.create=r=>new Yy({typeName:Qe.ZodNaN,...vt(r)});const vZ=Symbol("zod_brand");class gk extends Ct{_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 uf extends Ct{_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"?at:s.status==="dirty"?(t.dirty(),Ky(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"?at: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 uf({in:e,out:t,typeName:Qe.ZodPipeline})}}class cp extends Ct{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Gh(s)&&(s.value=Object.freeze(s.value)),s);return Jh(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}cp.create=(r,e)=>new cp({innerType:r,typeName:Qe.ZodReadonly,...vt(e)});function HE(r,e={},t){return r?Lu.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})}}):Lu.create()}const bZ={object:ur.lazycreate};var Qe;(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"})(Qe||(Qe={}));const _Z=(r,e={message:`Input not instance of ${r.name}`})=>HE(t=>t instanceof r,e),FE=cs.create,KE=Ma.create,wZ=Yy.create,xZ=Ua.create,zE=Yh.create,kZ=ic.create,SZ=Wy.create,AZ=Xh.create,OZ=Qh.create,jZ=Lu.create,CZ=Zo.create,EZ=Pi.create,IZ=Gy.create,TZ=ys.create,NZ=ur.create,BZ=ur.strictCreate,RZ=ep.create,PZ=Mv.create,$Z=tp.create,ZZ=Qs.create,DZ=rp.create,MZ=Jy.create,UZ=ac.create,VZ=cu.create,LZ=np.create,qZ=sp.create,HZ=Va.create,FZ=ip.create,KZ=qu.create,TA=ks.create,zZ=Ls.create,WZ=La.create,GZ=ks.createWithPreprocess,JZ=uf.create,YZ=()=>FE().optional(),XZ=()=>KE().optional(),QZ=()=>zE().optional(),eD={string:r=>cs.create({...r,coerce:!0}),number:r=>Ma.create({...r,coerce:!0}),boolean:r=>Yh.create({...r,coerce:!0}),bigint:r=>Ua.create({...r,coerce:!0}),date:r=>ic.create({...r,coerce:!0})},tD=at;var y=Object.freeze({__proto__:null,defaultErrorMap:Vu,setErrorMap:tZ,getErrorMap:Hy,makeIssue:Fy,EMPTY_PATH:rZ,addIssueToContext:be,ParseStatus:Rr,INVALID:at,DIRTY:Ky,OK:Fr,isAborted:B_,isDirty:R_,isValid:Gh,isAsync:Jh,get util(){return Vt},get objectUtil(){return N_},ZodParsedType:Ae,getParsedType:la,ZodType:Ct,datetimeRegex:LE,ZodString:cs,ZodNumber:Ma,ZodBigInt:Ua,ZodBoolean:Yh,ZodDate:ic,ZodSymbol:Wy,ZodUndefined:Xh,ZodNull:Qh,ZodAny:Lu,ZodUnknown:Zo,ZodNever:Pi,ZodVoid:Gy,ZodArray:ys,ZodObject:ur,ZodUnion:ep,ZodDiscriminatedUnion:Mv,ZodIntersection:tp,ZodTuple:Qs,ZodRecord:rp,ZodMap:Jy,ZodSet:ac,ZodFunction:cu,ZodLazy:np,ZodLiteral:sp,ZodEnum:Va,ZodNativeEnum:ip,ZodPromise:qu,ZodEffects:ks,ZodTransformer:ks,ZodOptional:Ls,ZodNullable:La,ZodDefault:ap,ZodCatch:op,ZodNaN:Yy,BRAND:vZ,ZodBranded:gk,ZodPipeline:uf,ZodReadonly:cp,custom:HE,Schema:Ct,ZodSchema:Ct,late:bZ,get ZodFirstPartyTypeKind(){return Qe},coerce:eD,any:jZ,array:TZ,bigint:xZ,boolean:zE,date:kZ,discriminatedUnion:PZ,effect:TA,enum:HZ,function:VZ,instanceof:_Z,intersection:$Z,lazy:LZ,literal:qZ,map:MZ,nan:wZ,nativeEnum:FZ,never:EZ,null:OZ,nullable:WZ,number:KE,object:NZ,oboolean:QZ,onumber:XZ,optional:zZ,ostring:YZ,pipeline:JZ,preprocess:GZ,promise:KZ,record:DZ,set:UZ,strictObject:BZ,string:FE,symbol:SZ,transformer:TA,tuple:ZZ,undefined:AZ,union:RZ,unknown:CZ,void:IZ,NEVER:tD,ZodIssueCode:se,quotelessJson:eZ,ZodError:xn});Q$(y);const Ac=y.object({start:y.number(),limit:y.number(),length:y.number()}),vk=y.object({created_at:y.string(),updated_at:y.string()}),rD=y.object({email:y.string().optional(),email_verified:y.boolean().optional(),name:y.string().optional(),username:y.string().optional(),given_name:y.string().optional(),phone_number:y.string().optional(),phone_verified:y.boolean().optional(),family_name:y.string().optional()}).catchall(y.any()),nD=y.object({connection:y.string(),user_id:y.string(),provider:y.string(),isSocial:y.boolean(),access_token:y.string().optional(),access_token_secret:y.string().optional(),refresh_token:y.string().optional(),profileData:rD.optional()}),bk=y.object({email:y.string().optional(),username:y.string().optional(),given_name:y.string().optional(),family_name:y.string().optional(),nickname:y.string().optional(),name:y.string().optional(),picture:y.string().optional(),locale:y.string().optional(),linked_to:y.string().optional(),profileData:y.string().optional(),user_id:y.string().optional(),app_metadata:y.any().default({}).optional(),user_metadata:y.any().default({}).optional()}),$_=bk.extend({email_verified:y.boolean().default(!1),verify_email:y.boolean().optional(),last_ip:y.string().optional(),last_login:y.string().optional(),user_id:y.string().optional(),provider:y.string().default("email"),connection:y.string().default("email")}),WE=y.object({...$_.shape,...vk.shape,user_id:y.string(),email:y.string(),is_social:y.boolean(),login_count:y.number(),identities:y.array(nD).optional()}),pi=WE;bk.extend({email:y.string(),login_count:y.number(),multifactor:y.array(y.string()).optional(),last_ip:y.string().optional(),last_login:y.string().optional(),user_id:y.string()}).catchall(y.any());const sD="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let iD=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=sD[t[r]&63];return e};const aD=y.object({audience:y.string().optional(),recipient:y.string().optional(),createUpnClaim:y.boolean().optional(),mapUnknownClaimsAsIs:y.boolean().optional(),passthroughClaimsWithNoMapping:y.boolean().optional(),mapIdentities:y.boolean().optional(),signatureAlgorithm:y.string().optional(),digestAlgorithm:y.string().optional(),issuer:y.string().optional(),destination:y.string().optional(),lifetimeInSeconds:y.number().optional(),signResponse:y.boolean().optional(),nameIdentifierFormat:y.string().optional(),nameIdentifierProbes:y.array(y.string()).optional(),authnContextClassRef:y.string().optional(),mappings:y.record(y.string()).optional()}),Z_=y.object({id:y.string(),name:y.string(),callbacks:y.array(y.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:y.array(y.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:y.array(y.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:y.array(y.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:y.array(y.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:y.object({samlp:aD.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:y.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:y.string().default(()=>iD()).optional(),disable_sign_ups:y.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),eu=y.object({created_at:y.string().transform(r=>r===null?"":r),updated_at:y.string().transform(r=>r===null?"":r),...Z_.shape});var GE=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(GE||{}),JE=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(JE||{}),YE=(r=>(r.S256="S256",r.Plain="plain",r))(YE||{});const oD=y.object({client_id:y.string(),vendor_id:y.string().optional(),act_as:y.string().optional(),response_type:y.nativeEnum(GE).optional(),response_mode:y.nativeEnum(JE).optional(),redirect_uri:y.string().optional(),audience:y.string().optional(),state:y.string().optional(),nonce:y.string().optional(),scope:y.string().optional(),prompt:y.string().optional(),code_challenge_method:y.nativeEnum(YE).optional(),code_challenge:y.string().optional(),username:y.string().optional(),ui_locales:y.string().optional()}),NA=y.object({colors:y.object({primary:y.string(),page_background:y.object({type:y.string().optional(),start:y.string().optional(),end:y.string().optional(),angle_deg:y.number().optional()}).optional()}).optional(),logo_url:y.string().optional(),favicon_url:y.string().optional(),font:y.object({url:y.string()}).optional()}),D_=y.object({id:y.string().optional(),name:y.string(),strategy:y.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:y.object({kid:y.string().optional(),team_id:y.string().optional(),realms:y.string().optional(),client_id:y.string().optional(),client_secret:y.string().optional(),app_secret:y.string().optional(),scope:y.string().optional(),authorization_endpoint:y.string().default("").optional(),token_endpoint:y.string().default("").optional(),userinfo_endpoint:y.string().default("").optional(),jwks_uri:y.string().default("").optional(),discovery_url:y.string().default("").optional(),issuer:y.string().default("").optional()}).default({}).optional(),enabled_clients:y.array(y.string()).default([]).optional(),response_type:y.custom().optional(),response_mode:y.custom().optional()}),ko=y.object({id:y.string(),created_at:y.string().transform(r=>r===null?"":r),updated_at:y.string().transform(r=>r===null?"":r)}).extend(D_.shape),M_=y.object({name:y.string(),audience:y.string(),sender_email:y.string().email(),sender_name:y.string(),support_url:y.string().url().optional(),logo:y.string().url().optional(),primary_color:y.string().optional(),secondary_color:y.string().optional(),language:y.string().optional()}),Od=y.object({created_at:y.string().transform(r=>r===null?"":r),updated_at:y.string().transform(r=>r===null?"":r),id:y.string(),...M_.shape});y.object({logoUrl:y.string(),loginBackgroundImage:y.string().nullish(),style:y.object({primaryColor:y.string(),buttonTextColor:y.string(),primaryHoverColor:y.string()}),supportEmail:y.string().nullable(),supportUrl:y.string().nullable(),name:y.string(),showGreyishBackground:y.boolean().optional(),termsAndConditionsUrl:y.string().nullable(),companyName:y.string().optional(),checkoutHideSocial:y.boolean().optional(),siteUrl:y.string().nullable(),manageSubscriptionsUrl:y.string().optional()});const cD=y.object({domain:y.string(),dkim_private_key:y.string().optional(),dkim_public_key:y.string().optional(),email_api_key:y.string().optional(),email_service:y.union([y.literal("mailgun"),y.literal("mailchannels")]).optional()});y.object({...eu.shape,domains:y.array(cD),tenant:Od,connections:y.array(ko)});const uD=y.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),lD=y.object({code_id:y.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:y.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:y.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:uD,expires_at:y.string(),used_at:y.string().optional(),user_id:y.string().optional()});y.object({...lD.shape,created_at:y.string()});const dD=y.object({domain:y.string(),dkim_private_key:y.string().optional(),dkim_public_key:y.string().optional(),email_api_key:y.string().optional(),email_service:y.enum(["mailgun","mailchannels"])});vk.extend({...dD.shape,id:y.string()});const U_=y.object({trigger_id:y.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:y.boolean().default(!1),url:y.string(),hook_id:y.string().optional(),synchronous:y.boolean().default(!1),priority:y.number().optional()}),dd=U_.extend({...vk.shape,hook_id:y.string()}),XE=y.object({alg:y.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:y.string(),kid:y.string(),kty:y.enum(["RSA","EC","oct"]),n:y.string(),x5t:y.string().optional(),x5c:y.array(y.string()).optional(),use:y.enum(["sig","enc"]).optional()}),hD=y.object({keys:y.array(XE)}),BA=y.object({issuer:y.string(),authorization_endpoint:y.string(),token_endpoint:y.string(),device_authorization_endpoint:y.string(),userinfo_endpoint:y.string(),mfa_challenge_endpoint:y.string(),jwks_uri:y.string(),registration_endpoint:y.string(),revocation_endpoint:y.string(),scopes_supported:y.array(y.string()),response_types_supported:y.array(y.string()),code_challenge_methods_supported:y.array(y.string()),response_modes_supported:y.array(y.string()),subject_types_supported:y.array(y.string()),id_token_signing_alg_values_supported:y.array(y.string()),token_endpoint_auth_methods_supported:y.array(y.string()),claims_supported:y.array(y.string()),request_uri_parameter_supported:y.boolean(),request_parameter_supported:y.boolean(),token_endpoint_auth_signing_alg_values_supported:y.array(y.string())}),pD=y.object({auth0Client:y.string().optional(),authParams:oD,expires_at:y.string(),deleted_at:y.string().optional(),ip:y.string().optional(),useragent:y.string().optional()}).openapi({description:"This represents a login sesion"});y.object({...pD.shape,login_id:y.string().openapi({description:"This is is used as the state in the universal login"}),created_at:y.string(),updated_at:y.string()});var QE=(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))(QE||{});const fD=y.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"]),mD=y.object({name:y.string(),version:y.string(),env:y.object({node:y.string().optional()}).optional()}),V_=y.object({type:fD,date:y.string(),description:y.string().optional(),log_id:y.string().optional(),_id:y.string().optional(),ip:y.string(),user_agent:y.string(),details:y.any().optional(),isMobile:y.boolean(),user_id:y.string().optional(),user_name:y.string().optional(),connection:y.string().optional(),connection_id:y.string().optional(),client_id:y.string().optional(),client_name:y.string().optional(),audience:y.string().optional(),scope:y.array(y.string()).optional(),strategy:y.string().optional(),strategy_type:y.string().optional(),hostname:y.string().optional(),auth0_client:mD.optional()}),yD=y.object({user_id:y.string(),password:y.string(),algorithm:y.enum(["bcrypt","argon2id"]).default("argon2id")});y.object({...yD.shape,created_at:y.string(),updated_at:y.string()});const gD=y.object({session_id:y.string(),client_id:y.string(),expires_at:y.string(),used_at:y.string(),deleted_at:y.string().optional(),user_id:y.string()}),e6=y.object({created_at:y.string(),...gD.shape}),RA=y.object({kid:y.string().openapi({description:"The key id of the signing key"}),cert:y.string().openapi({description:"The public certificate of the signing key"}),fingerprint:y.string().openapi({description:"The cert fingerprint"}),thumbprint:y.string().openapi({description:"The cert thumbprint"}),pkcs7:y.string().optional().openapi({description:"The private key in pkcs7 format"}),current:y.boolean().optional().openapi({description:"True if the key is the current key"}),next:y.boolean().optional().openapi({description:"True if the key is the next key"}),previous:y.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:y.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:y.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:y.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:y.string().optional().openapi({description:"The date and time when the key was revoked"})});var L_=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(L_||{});y.object({access_token:y.string(),id_token:y.string().optional(),scope:y.string().optional(),state:y.string().optional(),refresh_token:y.string().optional(),token_type:y.string(),expires_in:y.number()});y.object({code:y.string(),state:y.string().optional()});const vD=y.object({button_border_radius:y.number(),button_border_weight:y.number(),buttons_style:y.enum(["pill"]),input_border_radius:y.number(),input_border_weight:y.number(),inputs_style:y.enum(["pill"]),show_widget_shadow:y.boolean(),widget_border_weight:y.number(),widget_corner_radius:y.number()}),bD=y.object({base_focus_color:y.string(),base_hover_color:y.string(),body_text:y.string(),captcha_widget_theme:y.enum(["auto"]),error:y.string(),header:y.string(),icons:y.string(),input_background:y.string(),input_border:y.string(),input_filled_text:y.string(),input_labels_placeholders:y.string(),links_focused_components:y.string(),primary_button:y.string(),primary_button_label:y.string(),secondary_button_border:y.string(),secondary_button_label:y.string(),success:y.string(),widget_background:y.string(),widget_border:y.string()}),Lc=y.object({bold:y.boolean(),size:y.number()}),_D=y.object({body_text:Lc,buttons_text:Lc,font_url:y.string(),input_labels:Lc,links:Lc,links_style:y.enum(["normal"]),reference_text_size:y.number(),subtitle:Lc,title:Lc}),wD=y.object({background_color:y.string(),background_image_url:y.string(),page_layout:y.enum(["center"])}),xD=y.object({header_text_alignment:y.enum(["center"]),logo_height:y.number(),logo_position:y.enum(["center"]),logo_url:y.string(),social_buttons_layout:y.enum(["bottom"])}),kD=y.object({borders:vD,colors:bD,displayName:y.string(),fonts:_D,page_background:wD,widget:xD});kD.extend({themeId:y.string()});const hb=y.object({universal_login_experience:y.enum(["new","classic"]).default("new"),identifier_first:y.boolean().default(!0),password_first:y.boolean().default(!1),webauthn_platform_first_factor:y.boolean()}),pb=y.object({name:y.string(),enabled:y.boolean().optional().default(!0),default_from_address:y.string().optional(),credentials:y.union([y.object({accessKeyId:y.string(),secretAccessKey:y.string(),region:y.string()}),y.object({smtp_host:y.array(y.string()),smtp_port:y.number(),smtp_user:y.string(),smtp_pass:y.string()}),y.object({api_key:y.string(),domain:y.string().optional()}),y.object({connectionString:y.string()}),y.object({tenantId:y.string(),clientId:y.string(),clientSecret:y.string()})]),settings:y.object({}).optional()});new On().openapi(ut({tags:["branding"],method:"get",path:"/",request:{headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:NA}},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(ut({tags:["branding"],method:"patch",path:"/",request:{headers:N.object({"tenant-id":N.string()}),body:{content:{"application/json":{schema:N.object(NA.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});var Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function SD(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function AD(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}function OD(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 t6={exports:{}};const jD={},CD=Object.freeze(Object.defineProperty({__proto__:null,default:jD},Symbol.toStringTag,{value:"Module"})),ED=AD(CD);(function(r){/**
126
- * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
127
- * Released under the Apache License, Version 2.0
128
- * see: https://github.com/dcodeIO/bcrypt.js for details
129
- */(function(e,t){typeof OD=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(Xy,function(){var e={},t=null;function n(C){if(r&&r.exports)try{return ED.randomBytes(C)}catch{}try{var j;return(self.crypto||self.msCrypto).getRandomValues(j=new Uint32Array(C)),Array.prototype.slice.call(j)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t(C)}var s=!1;try{n(1),s=!0}catch{}t=null,e.setRandomFallback=function(C){t=C},e.genSaltSync=function(C,j){if(C=C||g,typeof C!="number")throw Error("Illegal arguments: "+typeof C+", "+typeof j);C<4?C=4:C>31&&(C=31);var k=[];return k.push("$2a$"),C<10&&k.push("0"),k.push(C.toString()),k.push("$"),k.push(h(n(d),d)),k.join("")},e.genSalt=function(C,j,k){if(typeof j=="function"&&(k=j,j=void 0),typeof C=="function"&&(k=C,C=void 0),typeof C>"u")C=g;else if(typeof C!="number")throw Error("illegal arguments: "+typeof C);function b(v){a(function(){try{v(null,e.genSaltSync(C))}catch(E){v(E)}})}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(v,E){b(function(M,ue){if(M){E(M);return}v(ue)})})},e.hashSync=function(C,j){if(typeof j>"u"&&(j=g),typeof j=="number"&&(j=e.genSaltSync(j)),typeof C!="string"||typeof j!="string")throw Error("Illegal arguments: "+typeof C+", "+typeof j);return Jt(C,j)},e.hash=function(C,j,k,b){function v(E){typeof C=="string"&&typeof j=="number"?e.genSalt(j,function(M,ue){Jt(C,ue,E,b)}):typeof C=="string"&&typeof j=="string"?Jt(C,j,E,b):a(E.bind(this,Error("Illegal arguments: "+typeof C+", "+typeof j)))}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);v(k)}else return new Promise(function(E,M){v(function(ue,W){if(ue){M(ue);return}E(W)})})};function i(C,j){for(var k=0,b=0,v=0,E=C.length;v<E;++v)C.charCodeAt(v)===j.charCodeAt(v)?++k:++b;return k<0?!1:b===0}e.compareSync=function(C,j){if(typeof C!="string"||typeof j!="string")throw Error("Illegal arguments: "+typeof C+", "+typeof j);return j.length!==60?!1:i(e.hashSync(C,j.substr(0,j.length-31)),j)},e.compare=function(C,j,k,b){function v(E){if(typeof C!="string"||typeof j!="string"){a(E.bind(this,Error("Illegal arguments: "+typeof C+", "+typeof j)));return}if(j.length!==60){a(E.bind(this,null,!1));return}e.hash(C,j.substr(0,29),function(M,ue){M?E(M):E(null,i(ue,j))},b)}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);v(k)}else return new Promise(function(E,M){v(function(ue,W){if(ue){M(ue);return}E(W)})})},e.getRounds=function(C){if(typeof C!="string")throw Error("Illegal arguments: "+typeof C);return parseInt(C.split("$")[2],10)},e.getSalt=function(C){if(typeof C!="string")throw Error("Illegal arguments: "+typeof C);if(C.length!==60)throw Error("Illegal hash length: "+C.length+" != 60");return C.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function o(C){var j=[],k=0;return B.encodeUTF16toUTF8(function(){return k>=C.length?null:C.charCodeAt(k++)},function(b){j.push(b)}),j}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],l=String.fromCharCode;function h(C,j){var k=0,b=[],v,E;if(j<=0||j>C.length)throw Error("Illegal len: "+j);for(;k<j;){if(v=C[k++]&255,b.push(c[v>>2&63]),v=(v&3)<<4,k>=j){b.push(c[v&63]);break}if(E=C[k++]&255,v|=E>>4&15,b.push(c[v&63]),v=(E&15)<<2,k>=j){b.push(c[v&63]);break}E=C[k++]&255,v|=E>>6&3,b.push(c[v&63]),b.push(c[E&63])}return b.join("")}function R(C,j){var k=0,b=C.length,v=0,E=[],M,ue,W,pe,Ze,H;if(j<=0)throw Error("Illegal len: "+j);for(;k<b-1&&v<j&&(H=C.charCodeAt(k++),M=H<u.length?u[H]:-1,H=C.charCodeAt(k++),ue=H<u.length?u[H]:-1,!(M==-1||ue==-1||(Ze=M<<2>>>0,Ze|=(ue&48)>>4,E.push(l(Ze)),++v>=j||k>=b)||(H=C.charCodeAt(k++),W=H<u.length?u[H]:-1,W==-1)||(Ze=(ue&15)<<4>>>0,Ze|=(W&60)>>2,E.push(l(Ze)),++v>=j||k>=b)));)H=C.charCodeAt(k++),pe=H<u.length?u[H]:-1,Ze=(W&3)<<6>>>0,Ze|=pe,E.push(l(Ze)),++v;var Bt=[];for(k=0;k<v;k++)Bt.push(E[k].charCodeAt(0));return Bt}var B=function(){var C={};return C.MAX_CODEPOINT=1114111,C.encodeUTF8=function(j,k){var b=null;for(typeof j=="number"&&(b=j,j=function(){return null});b!==null||(b=j())!==null;)b<128?k(b&127):b<2048?(k(b>>6&31|192),k(b&63|128)):b<65536?(k(b>>12&15|224),k(b>>6&63|128),k(b&63|128)):(k(b>>18&7|240),k(b>>12&63|128),k(b>>6&63|128),k(b&63|128)),b=null},C.decodeUTF8=function(j,k){for(var b,v,E,M,ue=function(W){W=W.slice(0,W.indexOf(null));var pe=Error(W.toString());throw pe.name="TruncatedError",pe.bytes=W,pe};(b=j())!==null;)if(!(b&128))k(b);else if((b&224)===192)(v=j())===null&&ue([b,v]),k((b&31)<<6|v&63);else if((b&240)===224)((v=j())===null||(E=j())===null)&&ue([b,v,E]),k((b&15)<<12|(v&63)<<6|E&63);else if((b&248)===240)((v=j())===null||(E=j())===null||(M=j())===null)&&ue([b,v,E,M]),k((b&7)<<18|(v&63)<<12|(E&63)<<6|M&63);else throw RangeError("Illegal starting byte: "+b)},C.UTF16toUTF8=function(j,k){for(var b,v=null;(b=v!==null?v:j())!==null;){if(b>=55296&&b<=57343&&(v=j())!==null&&v>=56320&&v<=57343){k((b-55296)*1024+v-56320+65536),v=null;continue}k(b)}v!==null&&k(v)},C.UTF8toUTF16=function(j,k){var b=null;for(typeof j=="number"&&(b=j,j=function(){return null});b!==null||(b=j())!==null;)b<=65535?k(b):(b-=65536,k((b>>10)+55296),k(b%1024+56320)),b=null},C.encodeUTF16toUTF8=function(j,k){C.UTF16toUTF8(j,function(b){C.encodeUTF8(b,k)})},C.decodeUTF8toUTF16=function(j,k){C.decodeUTF8(j,function(b){C.UTF8toUTF16(b,k)})},C.calculateCodePoint=function(j){return j<128?1:j<2048?2:j<65536?3:4},C.calculateUTF8=function(j){for(var k,b=0;(k=j())!==null;)b+=C.calculateCodePoint(k);return b},C.calculateUTF16asUTF8=function(j){var k=0,b=0;return C.UTF16toUTF8(j,function(v){++k,b+=C.calculateCodePoint(v)}),[k,b]},C}();Date.now=Date.now||function(){return+new Date};var d=16,g=10,A=16,O=100,$=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],P=[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],ae=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Re(C,j,k,b){var v,E=C[j],M=C[j+1];return E^=k[0],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[1],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[2],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[3],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[4],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[5],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[6],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[7],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[8],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[9],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[10],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[11],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[12],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[13],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[14],v=b[E>>>24],v+=b[256|E>>16&255],v^=b[512|E>>8&255],v+=b[768|E&255],M^=v^k[15],v=b[M>>>24],v+=b[256|M>>16&255],v^=b[512|M>>8&255],v+=b[768|M&255],E^=v^k[16],C[j]=M^k[A+1],C[j+1]=E,C}function He(C,j){for(var k=0,b=0;k<4;++k)b=b<<8|C[j]&255,j=(j+1)%C.length;return{key:b,offp:j}}function Te(C,j,k){for(var b=0,v=[0,0],E=j.length,M=k.length,ue,W=0;W<E;W++)ue=He(C,b),b=ue.offp,j[W]=j[W]^ue.key;for(W=0;W<E;W+=2)v=Re(v,0,j,k),j[W]=v[0],j[W+1]=v[1];for(W=0;W<M;W+=2)v=Re(v,0,j,k),k[W]=v[0],k[W+1]=v[1]}function Nt(C,j,k,b){for(var v=0,E=[0,0],M=k.length,ue=b.length,W,pe=0;pe<M;pe++)W=He(j,v),v=W.offp,k[pe]=k[pe]^W.key;for(v=0,pe=0;pe<M;pe+=2)W=He(C,v),v=W.offp,E[0]^=W.key,W=He(C,v),v=W.offp,E[1]^=W.key,E=Re(E,0,k,b),k[pe]=E[0],k[pe+1]=E[1];for(pe=0;pe<ue;pe+=2)W=He(C,v),v=W.offp,E[0]^=W.key,W=He(C,v),v=W.offp,E[1]^=W.key,E=Re(E,0,k,b),b[pe]=E[0],b[pe+1]=E[1]}function Gt(C,j,k,b,v){var E=ae.slice(),M=E.length,ue;if(k<4||k>31)if(ue=Error("Illegal number of rounds (4-31): "+k),b){a(b.bind(this,ue));return}else throw ue;if(j.length!==d)if(ue=Error("Illegal salt length: "+j.length+" != "+d),b){a(b.bind(this,ue));return}else throw ue;k=1<<k>>>0;var W,pe,Ze=0,H;Int32Array?(W=new Int32Array($),pe=new Int32Array(P)):(W=$.slice(),pe=P.slice()),Nt(j,C,W,pe);function Bt(){if(v&&v(Ze/k),Ze<k)for(var Ke=Date.now();Ze<k&&(Ze=Ze+1,Te(C,W,pe),Te(j,W,pe),!(Date.now()-Ke>O)););else{for(Ze=0;Ze<64;Ze++)for(H=0;H<M>>1;H++)Re(E,H<<1,W,pe);var _t=[];for(Ze=0;Ze<M;Ze++)_t.push((E[Ze]>>24&255)>>>0),_t.push((E[Ze]>>16&255)>>>0),_t.push((E[Ze]>>8&255)>>>0),_t.push((E[Ze]&255)>>>0);if(b){b(null,_t);return}else return _t}b&&a(Bt)}if(typeof b<"u")Bt();else for(var $r;;)if(typeof($r=Bt())<"u")return $r||[]}function Jt(C,j,k,b){var v;if(typeof C!="string"||typeof j!="string")if(v=Error("Invalid string / salt: Not a string"),k){a(k.bind(this,v));return}else throw v;var E,M;if(j.charAt(0)!=="$"||j.charAt(1)!=="2")if(v=Error("Invalid salt version: "+j.substring(0,2)),k){a(k.bind(this,v));return}else throw v;if(j.charAt(2)==="$")E="\0",M=3;else{if(E=j.charAt(2),E!=="a"&&E!=="b"&&E!=="y"||j.charAt(3)!=="$")if(v=Error("Invalid salt revision: "+j.substring(2,4)),k){a(k.bind(this,v));return}else throw v;M=4}if(j.charAt(M+2)>"$")if(v=Error("Missing salt rounds"),k){a(k.bind(this,v));return}else throw v;var ue=parseInt(j.substring(M,M+1),10)*10,W=parseInt(j.substring(M+1,M+2),10),pe=ue+W,Ze=j.substring(M+3,M+25);C+=E>="a"?"\0":"";var H=o(C),Bt=R(Ze,d);function $r(Ke){var _t=[];return _t.push("$2"),E>="a"&&_t.push(E),_t.push("$"),pe<10&&_t.push("0"),_t.push(pe.toString()),_t.push("$"),_t.push(h(Bt,Bt.length)),_t.push(h(Ke,ae.length*4-1)),_t.join("")}if(typeof k>"u")return $r(Gt(H,Bt,pe));Gt(H,Bt,pe,function(Ke,_t){Ke?k(Ke,null):k(null,$r(_t))},b)}return e.encodeBase64=h,e.decodeBase64=R,e})})(t6);var ID=t6.exports;const TD=SD(ID),ND="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let BD=r=>crypto.getRandomValues(new Uint8Array(r)),RD=(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}}},PD=(r,e=21)=>RD(r,e,BD),Qy=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=ND[t[r]&63];return e};const $D=24;function ZD(){return PD("0123456789abcdef",$D)()}function PA(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}async function r6(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}const oc=N.object({page:N.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:N.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:N.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:N.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:N.string().optional().openapi({description:"A lucene query string used to filter the results"})});function yl(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}function DD(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}var MD={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},UD=()=>{var r,e;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[n,s]of Object.entries(MD))if(VD(s))return n}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((e=(r=t==null?void 0:t.process)==null?void 0:r.release)==null?void 0:e.name)==="node"?"node":"other"},VD=r=>navigator.userAgent.startsWith(r);function LD(r,e){UD()==="workerd"&&r.executionCtx.waitUntil(e)}const $A=Ac.extend({users:N.array(pi)}),qD=Ac.extend({sessions:N.array(e6)});new On().openapi(ut({tags:["users"],method:"get",path:"/",request:{query:oc,headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:N.union([N.array(pi),$A])}},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 l=i.split("=")[1],h=(await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,q:`email:${l}`})).users.filter(d=>d.linked_to),[R]=h;if(!R)return r.json([]);const B=await r.env.data.users.get(a,R.linked_to);if(!B)throw new lt(500,{message:"Primary account not found"});return r.json([pi.parse(B)])}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:yl(s),q:o.join(" ")}),u=c.users.filter(l=>!l.linked_to);return n?r.json($A.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(N.array(pi).parse(u))}).openapi(ut({tags:["users"],method:"get",path:"/{user_id}",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({user_id:N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:pi}},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 lt(404);if(n.linked_to)throw new lt(404,{message:"User is linked to another user"});return r.json(n)}).openapi(ut({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({user_id:N.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 lt(404);return r.text("OK")}).openapi(ut({tags:["users"],method:"post",path:"/",request:{headers:N.object({"tenant-id":N.string()}),body:{content:{"application/json":{schema:N.object({...$_.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:pi}},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 lt(400,{message:"Email is required"});const s=n.toLowerCase(),i=`${t.provider}|${t.user_id||ZD()}`;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=DD(r,{type:QE.SUCCESS_API_OPERATION,description:"User created"});LD(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:PA(a.user_id),isSocial:a.is_social}]};return r.json(pi.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new lt(409,{message:"User already exists"}):a}}).openapi(ut({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:N.object({"tenant-id":N.string()}),body:{content:{"application/json":{schema:N.object({...$_.shape,verify_email:N.boolean(),password:N.string()}).partial()}}},params:N.object({user_id:N.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{var e;const{"tenant-id":t}=r.req.valid("header"),n=r.req.valid("json"),{user_id:s}=r.req.valid("param"),{verify_email:i,password:a,...o}=n,c=await r.env.data.users.get(t,s);if(!c)throw new lt(404);if(o.email&&o.email!==c.email){const l=await r6(r.env.data.users,t,o.email);if(l.length&&l.some(h=>h.user_id!==s))throw new lt(409,{message:"Another user with the same email address already exists."})}if(c.linked_to)throw new lt(404,{message:"User is linked to another user"});if(await r.env.data.users.update(t,s,o),a){const l=(e=c.identities)==null?void 0:e.find(h=>h.connection==="Username-Password-Authentication");if(!l)throw new lt(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(t,{user_id:`${l.provider}|${l.user_id}`,password:TD.hashSync(a,10),algorithm:"bcrypt"})}const u=await r.env.data.users.get(t,s);if(!u)throw new lt(500);return r.json(u)}).openapi(ut({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:N.object({"tenant-id":N.string()}),body:{content:{"application/json":{schema:N.union([N.object({link_with:N.string()}),N.object({user_id:N.string(),provider:N.string(),connection:N.string().optional()})])}}},params:N.object({user_id:N.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:N.array(N.object({connection:N.string(),provider:N.string(),user_id:N.string(),isSocial:N.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 lt(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:PA(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(ut({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({user_id:N.string(),provider:N.string(),linked_user_id:N.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:N.array(pi)}},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 lt(404);return r.json([pi.parse(i)])}).openapi(ut({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:oc,headers:N.object({"tenant-id":N.string()}),params:N.object({user_id:N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:N.union([N.array(e6),qD])}},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)});/*! *****************************************************************************
130
- Copyright (C) Microsoft. All rights reserved.
131
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
132
- this file except in compliance with the License. You may obtain a copy of the
133
- License at http://www.apache.org/licenses/LICENSE-2.0
134
-
135
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
136
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
137
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
138
- MERCHANTABLITY OR NON-INFRINGEMENT.
139
-
140
- See the Apache Version 2.0 License for specific language governing permissions
141
- and limitations under the License.
142
- ***************************************************************************** */var ZA;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof Xy=="object"?Xy: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(l,h){Object.defineProperty(c,l,{configurable:!0,writable:!0,value:h}),u&&u(l,h)}}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,l={create:o?function(){return io(Object.create(null))}:c?function(){return io({__proto__:null})}:function(){return io({})},has:u?function(x,S){return n.call(x,S)}:function(x,S){return S in x},get:u?function(x,S){return n.call(x,S)?x[S]:void 0}:function(x,S){return x[S]}},h=Object.getPrototypeOf(Function),R=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Z0(),B=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:D0(),d=typeof WeakMap=="function"?WeakMap:M0(),g=s?Symbol.for("@reflect-metadata:registry"):void 0,A=R0(),O=P0(A);function $(x,S,I,U){if(H(I)){if(!Cl(x))throw new TypeError;if(!El(S))throw new TypeError;return j(x,S)}else{if(!Cl(x))throw new TypeError;if(!Ke(S))throw new TypeError;if(!Ke(U)&&!H(U)&&!Bt(U))throw new TypeError;return Bt(U)&&(U=void 0),I=dr(I),k(x,S,I,U)}}e("decorate",$);function P(x,S){function I(U,Y){if(!Ke(U))throw new TypeError;if(!H(Y)&&!N0(Y))throw new TypeError;ue(x,S,U,Y)}return I}e("metadata",P);function ae(x,S,I,U){if(!Ke(I))throw new TypeError;return H(U)||(U=dr(U)),ue(x,S,I,U)}e("defineMetadata",ae);function Re(x,S,I){if(!Ke(S))throw new TypeError;return H(I)||(I=dr(I)),b(x,S,I)}e("hasMetadata",Re);function He(x,S,I){if(!Ke(S))throw new TypeError;return H(I)||(I=dr(I)),v(x,S,I)}e("hasOwnMetadata",He);function Te(x,S,I){if(!Ke(S))throw new TypeError;return H(I)||(I=dr(I)),E(x,S,I)}e("getMetadata",Te);function Nt(x,S,I){if(!Ke(S))throw new TypeError;return H(I)||(I=dr(I)),M(x,S,I)}e("getOwnMetadata",Nt);function Gt(x,S){if(!Ke(x))throw new TypeError;return H(S)||(S=dr(S)),W(x,S)}e("getMetadataKeys",Gt);function Jt(x,S){if(!Ke(x))throw new TypeError;return H(S)||(S=dr(S)),pe(x,S)}e("getOwnMetadataKeys",Jt);function C(x,S,I){if(!Ke(S))throw new TypeError;if(H(I)||(I=dr(I)),!Ke(S))throw new TypeError;H(I)||(I=dr(I));var U=Gn(S,I,!1);return H(U)?!1:U.OrdinaryDeleteMetadata(x,S,I)}e("deleteMetadata",C);function j(x,S){for(var I=x.length-1;I>=0;--I){var U=x[I],Y=U(S);if(!H(Y)&&!Bt(Y)){if(!El(Y))throw new TypeError;S=Y}}return S}function k(x,S,I,U){for(var Y=x.length-1;Y>=0;--Y){var Rt=x[Y],It=Rt(S,I,U);if(!H(It)&&!Bt(It)){if(!Ke(It))throw new TypeError;U=It}}return U}function b(x,S,I){var U=v(x,S,I);if(U)return!0;var Y=so(S);return Bt(Y)?!1:b(x,Y,I)}function v(x,S,I){var U=Gn(S,I,!1);return H(U)?!1:jl(U.OrdinaryHasOwnMetadata(x,S,I))}function E(x,S,I){var U=v(x,S,I);if(U)return M(x,S,I);var Y=so(S);if(!Bt(Y))return E(x,Y,I)}function M(x,S,I){var U=Gn(S,I,!1);if(!H(U))return U.OrdinaryGetOwnMetadata(x,S,I)}function ue(x,S,I,U){var Y=Gn(I,U,!0);Y.OrdinaryDefineOwnMetadata(x,S,I,U)}function W(x,S){var I=pe(x,S),U=so(x);if(U===null)return I;var Y=W(U,S);if(Y.length<=0)return I;if(I.length<=0)return Y;for(var Rt=new B,It=[],he=0,q=I;he<q.length;he++){var F=q[he],K=Rt.has(F);K||(Rt.add(F),It.push(F))}for(var z=0,fe=Y;z<fe.length;z++){var F=fe[z],K=Rt.has(F);K||(Rt.add(F),It.push(F))}return It}function pe(x,S){var I=Gn(x,S,!1);return I?I.OrdinaryOwnMetadataKeys(x,S):[]}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 H(x){return x===void 0}function Bt(x){return x===null}function $r(x){return typeof x=="symbol"}function Ke(x){return typeof x=="object"?x!==null:typeof x=="function"}function _t(x,S){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 I="string",U=Il(x,i);if(U!==void 0){var Y=U.call(x,I);if(Ke(Y))throw new TypeError;return Y}return I0(x)}function I0(x,S){var I,U;{var Y=x.toString;if(ui(Y)){var U=Y.call(x);if(!Ke(U))return U}var I=x.valueOf;if(ui(I)){var U=I.call(x);if(!Ke(U))return U}}throw new TypeError}function jl(x){return!!x}function T0(x){return""+x}function dr(x){var S=_t(x);return $r(S)?S:T0(S)}function Cl(x){return Array.isArray?Array.isArray(x):x instanceof Object?x instanceof Array:Object.prototype.toString.call(x)==="[object Array]"}function ui(x){return typeof x=="function"}function El(x){return typeof x=="function"}function N0(x){switch(Ze(x)){case 3:return!0;case 4:return!0;default:return!1}}function no(x,S){return x===S||x!==x&&S!==S}function Il(x,S){var I=x[S];if(I!=null){if(!ui(I))throw new TypeError;return I}}function Tl(x){var S=Il(x,a);if(!ui(S))throw new TypeError;var I=S.call(x);if(!Ke(I))throw new TypeError;return I}function Nl(x){return x.value}function Bl(x){var S=x.next();return S.done?!1:S}function Rl(x){var S=x.return;S&&S.call(x)}function so(x){var S=Object.getPrototypeOf(x);if(typeof x!="function"||x===h||S!==h)return S;var I=x.prototype,U=I&&Object.getPrototypeOf(I);if(U==null||U===Object.prototype)return S;var Y=U.constructor;return typeof Y!="function"||Y===x?S:Y}function B0(){var x;!H(g)&&typeof t.Reflect<"u"&&!(g in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(x=$0(t.Reflect));var S,I,U,Y=new d,Rt={registerProvider:It,getProvider:q,setProvider:K};return Rt;function It(z){if(!Object.isExtensible(Rt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case x===z:break;case H(S):S=z;break;case S===z:break;case H(I):I=z;break;case I===z:break;default:U===void 0&&(U=new B),U.add(z);break}}function he(z,fe){if(!H(S)){if(S.isProviderFor(z,fe))return S;if(!H(I)){if(I.isProviderFor(z,fe))return S;if(!H(U))for(var We=Tl(U);;){var pt=Bl(We);if(!pt)return;var nr=Nl(pt);if(nr.isProviderFor(z,fe))return Rl(We),nr}}}if(!H(x)&&x.isProviderFor(z,fe))return x}function q(z,fe){var We=Y.get(z),pt;return H(We)||(pt=We.get(fe)),H(pt)&&(pt=he(z,fe),H(pt)||(H(We)&&(We=new R,Y.set(z,We)),We.set(fe,pt))),pt}function F(z){if(H(z))throw new TypeError;return S===z||I===z||!H(U)&&U.has(z)}function K(z,fe,We){if(!F(We))throw new Error("Metadata provider not registered.");var pt=q(z,fe);if(pt!==We){if(!H(pt))return!1;var nr=Y.get(z);H(nr)&&(nr=new R,Y.set(z,nr)),nr.set(fe,We)}return!0}}function R0(){var x;return!H(g)&&Ke(t.Reflect)&&Object.isExtensible(t.Reflect)&&(x=t.Reflect[g]),H(x)&&(x=B0()),!H(g)&&Ke(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,g,{enumerable:!1,configurable:!1,writable:!1,value:x}),x}function P0(x){var S=new d,I={isProviderFor:function(F,K){var z=S.get(F);return H(z)?!1:z.has(K)},OrdinaryDefineOwnMetadata:It,OrdinaryHasOwnMetadata:Y,OrdinaryGetOwnMetadata:Rt,OrdinaryOwnMetadataKeys:he,OrdinaryDeleteMetadata:q};return A.registerProvider(I),I;function U(F,K,z){var fe=S.get(F),We=!1;if(H(fe)){if(!z)return;fe=new R,S.set(F,fe),We=!0}var pt=fe.get(K);if(H(pt)){if(!z)return;if(pt=new R,fe.set(K,pt),!x.setProvider(F,K,I))throw fe.delete(K),We&&S.delete(F),new Error("Wrong provider for target.")}return pt}function Y(F,K,z){var fe=U(K,z,!1);return H(fe)?!1:jl(fe.has(F))}function Rt(F,K,z){var fe=U(K,z,!1);if(!H(fe))return fe.get(F)}function It(F,K,z,fe){var We=U(z,fe,!0);We.set(F,K)}function he(F,K){var z=[],fe=U(F,K,!1);if(H(fe))return z;for(var We=fe.keys(),pt=Tl(We),nr=0;;){var Pl=Bl(pt);if(!Pl)return z.length=nr,z;var U0=Nl(Pl);try{z[nr]=U0}catch(V0){try{Rl(pt)}finally{throw V0}}nr++}}function q(F,K,z){var fe=U(K,z,!1);if(H(fe)||!fe.delete(F))return!1;if(fe.size===0){var We=S.get(K);H(We)||(We.delete(z),We.size===0&&S.delete(We))}return!0}}function $0(x){var S=x.defineMetadata,I=x.hasOwnMetadata,U=x.getOwnMetadata,Y=x.getOwnMetadataKeys,Rt=x.deleteMetadata,It=new d,he={isProviderFor:function(q,F){var K=It.get(q);return!H(K)&&K.has(F)?!0:Y(q,F).length?(H(K)&&(K=new B,It.set(q,K)),K.add(F),!0):!1},OrdinaryDefineOwnMetadata:S,OrdinaryHasOwnMetadata:I,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:Y,OrdinaryDeleteMetadata:Rt};return he}function Gn(x,S,I){var U=A.getProvider(x,S);if(!H(U))return U;if(I){if(A.setProvider(x,S,O))return O;throw new Error("Illegal state.")}}function Z0(){var x={},S=[],I=function(){function he(q,F,K){this._index=0,this._keys=q,this._values=F,this._selector=K}return he.prototype["@@iterator"]=function(){return this},he.prototype[a]=function(){return this},he.prototype.next=function(){var q=this._index;if(q>=0&&q<this._keys.length){var F=this._selector(this._keys[q],this._values[q]);return q+1>=this._keys.length?(this._index=-1,this._keys=S,this._values=S):this._index++,{value:F,done:!1}}return{value:void 0,done:!0}},he.prototype.throw=function(q){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),q},he.prototype.return=function(q){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:q,done:!0}},he}(),U=function(){function he(){this._keys=[],this._values=[],this._cacheKey=x,this._cacheIndex=-2}return Object.defineProperty(he.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),he.prototype.has=function(q){return this._find(q,!1)>=0},he.prototype.get=function(q){var F=this._find(q,!1);return F>=0?this._values[F]:void 0},he.prototype.set=function(q,F){var K=this._find(q,!0);return this._values[K]=F,this},he.prototype.delete=function(q){var F=this._find(q,!1);if(F>=0){for(var K=this._keys.length,z=F+1;z<K;z++)this._keys[z-1]=this._keys[z],this._values[z-1]=this._values[z];return this._keys.length--,this._values.length--,no(q,this._cacheKey)&&(this._cacheKey=x,this._cacheIndex=-2),!0}return!1},he.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=x,this._cacheIndex=-2},he.prototype.keys=function(){return new I(this._keys,this._values,Y)},he.prototype.values=function(){return new I(this._keys,this._values,Rt)},he.prototype.entries=function(){return new I(this._keys,this._values,It)},he.prototype["@@iterator"]=function(){return this.entries()},he.prototype[a]=function(){return this.entries()},he.prototype._find=function(q,F){if(!no(this._cacheKey,q)){this._cacheIndex=-1;for(var K=0;K<this._keys.length;K++)if(no(this._keys[K],q)){this._cacheIndex=K;break}}return this._cacheIndex<0&&F&&(this._cacheIndex=this._keys.length,this._keys.push(q),this._values.push(void 0)),this._cacheIndex},he}();return U;function Y(he,q){return he}function Rt(he,q){return q}function It(he,q){return[he,q]}}function D0(){var x=function(){function S(){this._map=new R}return Object.defineProperty(S.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),S.prototype.has=function(I){return this._map.has(I)},S.prototype.add=function(I){return this._map.set(I,I),this},S.prototype.delete=function(I){return this._map.delete(I)},S.prototype.clear=function(){this._map.clear()},S.prototype.keys=function(){return this._map.keys()},S.prototype.values=function(){return this._map.keys()},S.prototype.entries=function(){return this._map.entries()},S.prototype["@@iterator"]=function(){return this.keys()},S.prototype[a]=function(){return this.keys()},S}();return x}function M0(){var x=16,S=l.create(),I=U();return function(){function q(){this._key=U()}return q.prototype.has=function(F){var K=Y(F,!1);return K!==void 0?l.has(K,this._key):!1},q.prototype.get=function(F){var K=Y(F,!1);return K!==void 0?l.get(K,this._key):void 0},q.prototype.set=function(F,K){var z=Y(F,!0);return z[this._key]=K,this},q.prototype.delete=function(F){var K=Y(F,!1);return K!==void 0?delete K[this._key]:!1},q.prototype.clear=function(){this._key=U()},q}();function U(){var q;do q="@@WeakMap@@"+he();while(l.has(S,q));return S[q]=!0,q}function Y(q,F){if(!n.call(q,I)){if(!F)return;Object.defineProperty(q,I,{value:l.create()})}return q[I]}function Rt(q,F){for(var K=0;K<F;++K)q[K]=Math.random()*255|0;return q}function It(q){if(typeof Uint8Array=="function"){var F=new Uint8Array(q);return typeof crypto<"u"?crypto.getRandomValues(F):typeof msCrypto<"u"?msCrypto.getRandomValues(F):Rt(F,q),F}return Rt(new Array(q),q)}function he(){var q=It(x);q[6]=q[6]&79|64,q[8]=q[8]&191|128;for(var F="",K=0;K<x;++K){var z=q[K];(K===4||K===6||K===8)&&(F+="-"),z<16&&(F+="0"),F+=z.toString(16).toLowerCase()}return F}}function io(x){return x.__=void 0,delete x.__,x}})})(ZA||(ZA={}));/*!
143
- * MIT License
144
- *
145
- * Copyright (c) 2017-2022 Peculiar Ventures, LLC
146
- *
147
- * Permission is hereby granted, free of charge, to any person obtaining a copy
148
- * of this software and associated documentation files (the "Software"), to deal
149
- * in the Software without restriction, including without limitation the rights
150
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
151
- * copies of the Software, and to permit persons to whom the Software is
152
- * furnished to do so, subject to the following conditions:
153
- *
154
- * The above copyright notice and this permission notice shall be included in all
155
- * copies or substantial portions of the Software.
156
- *
157
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
159
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
160
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
161
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
162
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
163
- * SOFTWARE.
164
- *
165
- */const HD="[object ArrayBuffer]";class de{static isArrayBuffer(e){return Object.prototype.toString.call(e)===HD}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=de.toUint8Array(e),s=de.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 fb="string",FD=/^[0-9a-f]+$/i,KD=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,zD=/^[a-zA-Z0-9-_]+$/;class DA{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=de.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class Rs{static toString(e,t=!1){const n=de.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 Be{static isHex(e){return typeof e===fb&&FD.test(e)}static isBase64(e){return typeof e===fb&&KD.test(e)}static isBase64Url(e){return typeof e===fb&&zD.test(e)}static ToString(e,t="utf8"){const n=de.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 Rs.toString(n,!0);case"utf16":case"utf16be":return Rs.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 Rs.fromString(e,!0);case"utf16":case"utf16be":return Rs.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=de.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(!Be.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(!Be.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=Be.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return DA.fromString(e);case"utf16":case"utf16be":return Rs.fromString(e);case"utf16le":case"usc2":return Rs.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=Be.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return DA.toString(e);case"utf16":case"utf16be":return Rs.toString(e);case"utf16le":case"usc2":return Rs.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=de.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){const t=de.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(!Be.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 Rs.toString(e,t)}static FromUtf16String(e,t=!1){return Rs.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,""))||""}}Be.DEFAULT_UTF8_ENCODING="utf8";function WD(...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 n6(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}/*!
166
- Copyright (c) Peculiar Ventures, LLC
167
- */function Hu(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 cc(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 l=o-1;l>=0;l--){const h=Math.pow(2,l*e);u[i-l-1]=Math.floor(s/h),s-=u[i-l-1]*h}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function q_(...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 s6(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const a=r[0]===255&&r[1]&128,o=r[0]===0&&(r[1]&128)===0;(a||o)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;const n=Hu(t,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,Hu(i,8)-n}function GD(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=cc(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let s=cc(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 JD(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 gn(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(t)}/*!
168
- * Copyright (c) 2014, GMO GlobalSign
169
- * Copyright (c) 2015-2022, Peculiar Ventures
170
- * All rights reserved.
171
- *
172
- * Author 2014-2019, Yury Strozhevsky
173
- *
174
- * Redistribution and use in source and binary forms, with or without modification,
175
- * are permitted provided that the following conditions are met:
176
- *
177
- * * Redistributions of source code must retain the above copyright notice, this
178
- * list of conditions and the following disclaimer.
179
- *
180
- * * Redistributions in binary form must reproduce the above copyright notice, this
181
- * list of conditions and the following disclaimer in the documentation and/or
182
- * other materials provided with the distribution.
183
- *
184
- * * Neither the name of the copyright holder nor the names of its
185
- * contributors may be used to endorse or promote products derived from
186
- * this software without specific prior written permission.
187
- *
188
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
189
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
190
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
191
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
192
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
193
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
194
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
195
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
196
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
197
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
198
- *
199
- */function eg(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function _k(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 Ki(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 Uv{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return _k(this.items)}}const Wl=[new Uint8Array([1])],MA="0123456789",mb="name",UA="valueHexView",YD="isHexOnly",XD="idBlock",QD="tagClass",eM="tagNumber",tM="isConstructed",rM="fromBER",nM="toBER",sM="local",tn="",js=new ArrayBuffer(0),Vv=new Uint8Array(0),up="EndOfContent",i6="OCTET STRING",a6="BIT STRING";function ai(r){var e;return e=class extends r{constructor(...t){var n;super(...t);const s=t[0]||{};this.isHexOnly=(n=s.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=s.valueHex?de.toUint8Array(s.valueHex):Vv}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(t){this.valueHexView=new Uint8Array(t)}fromBER(t,n,s){const i=t instanceof ArrayBuffer?new Uint8Array(t):t;if(!Ki(this,i,n,s))return-1;const a=n+s;return this.valueHexView=i.subarray(n,a),this.valueHexView.length?(this.blockLength=s,a):(this.warnings.push("Zero buffer length"),n)}toBER(t=!1){return this.isHexOnly?t?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",js)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Be.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Oc{constructor({blockLength:e=0,error:t=tn,warnings:n=[],valueBeforeDecode:s=Vv}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=de.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:Be.ToHex(this.valueBeforeDecodeView)}}}Oc.NAME="baseBlock";class Wr extends Oc{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'")}}Wr.NAME="valueBlock";class o6 extends ai(Oc){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?de.toUint8Array(e.valueHex):Vv,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",js}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=cc(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=de.toUint8Array(e);if(!Ki(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 a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let o=1,c=this.valueHexView=new Uint8Array(255),u=255;for(;i[o]&128;){if(c[o-1]=i[o]&127,o++,o>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(o===u){u+=255;const h=new Uint8Array(u);for(let R=0;R<c.length;R++)h[R]=c[R];c=this.valueHexView=new Uint8Array(u)}}this.blockLength=o+1,c[o-1]=i[o]&127;const l=new Uint8Array(o);for(let h=0;h<o;h++)l[h]=c[h];c=this.valueHexView=new Uint8Array(o),c.set(l),this.blockLength<=9?this.tagNumber=Hu(c,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}}}o6.NAME="identificationBlock";class c6 extends Oc{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=de.toUint8Array(e);if(!Ki(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=Hu(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=cc(this.length,8);if(s.byteLength>127)return this.error="Too big length",js;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}}}c6.NAME="lengthBlock";const Ie={};class Cr extends Oc{constructor({name:e=tn,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new o6(s),this.lenBlock=new c6(s),this.valueBlock=i?new i(s):new Wr(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 Uv;t||u6(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?js: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():Be.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${Be.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 JD(t,n)}}Cr.NAME="BaseBlock";function u6(r){if(r instanceof Ie.Constructed)for(const e of r.valueBlock.value)u6(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class wk extends Cr{constructor({value:e=tn,...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}'`}}wk.NAME="BaseStringBlock";class l6 extends ai(Wr){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}l6.NAME="PrimitiveValueBlock";var d6;class lf extends Cr{constructor(e={}){super(e,l6),this.idBlock.isConstructed=!1}}d6=lf;Ie.Primitive=d6;lf.NAME="PRIMITIVE";function iM(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 gl(r,e=0,t=r.length){const n=e;let s=new Cr({},Wr);const i=new Oc;if(!Ki(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 a=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=a,t-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=a,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 o=Cr;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};o=Ie.EndOfContent;break;case 1:o=Ie.Boolean;break;case 2:o=Ie.Integer;break;case 3:o=Ie.BitString;break;case 4:o=Ie.OctetString;break;case 5:o=Ie.Null;break;case 6:o=Ie.ObjectIdentifier;break;case 10:o=Ie.Enumerated;break;case 12:o=Ie.Utf8String;break;case 13:o=Ie.RelativeObjectIdentifier;break;case 14:o=Ie.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:o=Ie.Sequence;break;case 17:o=Ie.Set;break;case 18:o=Ie.NumericString;break;case 19:o=Ie.PrintableString;break;case 20:o=Ie.TeletexString;break;case 21:o=Ie.VideotexString;break;case 22:o=Ie.IA5String;break;case 23:o=Ie.UTCTime;break;case 24:o=Ie.GeneralizedTime;break;case 25:o=Ie.GraphicString;break;case 26:o=Ie.VisibleString;break;case 27:o=Ie.GeneralString;break;case 28:o=Ie.UniversalString;break;case 29:o=Ie.CharacterString;break;case 30:o=Ie.BmpString;break;case 31:o=Ie.DATE;break;case 32:o=Ie.TimeOfDay;break;case 33:o=Ie.DateTime;break;case 34:o=Ie.Duration;break;default:{const c=s.idBlock.isConstructed?new Ie.Constructed:new Ie.Primitive;c.idBlock=s.idBlock,c.lenBlock=s.lenBlock,c.warnings=s.warnings,s=c}}break;case 2:case 3:case 4:default:o=s.idBlock.isConstructed?Ie.Constructed:Ie.Primitive}return s=iM(s,o),a=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function uu(r){if(!r.byteLength){const e=new Cr({},Wr);return e.error="Input buffer has zero length",{offset:-1,result:e}}return gl(de.toUint8Array(r).slice(),0,r.byteLength)}function aM(r,e){return r?1:e}class ka extends Wr{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const s=de.toUint8Array(e);if(!Ki(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(;aM(this.isIndefiniteForm,n)>0;){const a=gl(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===up)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===up?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const n=t||new Uv;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?js:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}ka.NAME="ConstructedValueBlock";var h6;class nn extends Cr{constructor(e={}){super(e,ka),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(`
200
- `).map(s=>` ${s}`).join(`
201
- `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
202
- ${e.join(`
203
- `)}`:`${t} :`}}h6=nn;Ie.Constructed=h6;nn.NAME="CONSTRUCTED";class p6 extends Wr{fromBER(e,t,n){return t}toBER(e){return js}}p6.override="EndOfContentValueBlock";var f6;class xk extends Cr{constructor(e={}){super(e,p6),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}f6=xk;Ie.EndOfContent=f6;xk.NAME=up;var m6;class uc extends Cr{constructor(e={}){super(e,Wr),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}`}}m6=uc;Ie.Null=m6;uc.NAME="NULL";class y6 extends ai(Wr){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=de.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=de.toUint8Array(e);return Ki(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,s6.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}y6.NAME="BooleanValueBlock";var g6;let Lv=class extends Cr{constructor(r={}){super(r,y6),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(r){this.valueBlock.value=r}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};g6=Lv;Ie.Boolean=g6;Lv.NAME="BOOLEAN";class v6 extends ai(ka){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=ka.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===up){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==i6)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?ka.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}v6.NAME="OctetStringValueBlock";var b6;let Do=class _6 extends Cr{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},v6),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const i=gl(s,0,s.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?nn.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${Be.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 _6&&e.push(t.valueBlock.valueHexView);return de.concat(e)}};b6=Do;Ie.OctetString=b6;Do.NAME=i6;class w6 extends ai(ka){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=ka.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(const o of this.value){const c=o.constructor.NAME;if(c===up){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==a6)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=de.toUint8Array(e);if(!Ki(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=gl(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 ka.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return js;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}}}w6.NAME="BitStringValueBlock";var x6;let Mo=class extends Cr{constructor({idBlock:r={},lenBlock:e={},...t}={}){var n,s;(n=t.isConstructed)!==null&&n!==void 0||(t.isConstructed=!!(!((s=t.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:t.isConstructed,...r},lenBlock:{...e,isIndefiniteForm:!!t.isIndefiniteForm},...t},w6),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(r,e,t){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(r,e,t)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return nn.prototype.onAsciiEncoding.call(this);{const r=[],e=this.valueBlock.valueHexView;for(const n of e)r.push(n.toString(2).padStart(8,"0"));const t=r.join("");return`${this.constructor.NAME} : ${t.substring(0,t.length-this.valueBlock.unusedBits)}`}}};x6=Mo;Ie.BitString=x6;Mo.NAME=a6;var k6;function oM(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 l=c<a?a:c;let h=0;for(let R=l;R>=0;R--,h++){switch(!0){case h<o.length:u=i[a-h]+o[c-h]+t[0];break;default:u=i[a-h]+t[0]}switch(t[0]=u/10,!0){case h>=i.length:i=q_(new Uint8Array([u%10]),i);break;default:i[a-h]=u%10}}return t[0]>0&&(i=q_(t,i)),i}function VA(r){if(r>=Wl.length)for(let e=Wl.length;e<=r;e++){const t=new Uint8Array([0]);let n=Wl[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=q_(t,n)),Wl.push(n)}return Wl[r]}function cM(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,l=0;for(let h=c;h>=0;h--,l++)switch(u=i[a-l]-o[c-l]-t,!0){case u<0:t=1,i[a-l]=u+10;break;default:t=0,i[a-l]=u}if(t>0)for(let h=a-c+1;h>=0;h--,l++)if(u=i[a-l]-t,u<0)t=1,i[a-l]=u+10;else{t=0,i[a-l]=u;break}return i.slice()}class kk extends ai(Wr){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=s6.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(GD(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=cM(VA(n),t),a="-";break;default:t=oM(t,VA(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=MA.charAt(t[c]));return o===!1&&(a+=MA.charAt(0)),a}}k6=kk;kk.NAME="IntegerValueBlock";Object.defineProperty(k6.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var S6;class qs extends Cr{constructor(e={}){super(e,kk),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return eg(),BigInt(this.valueBlock.toString())}static fromBigInt(e){eg();const t=BigInt(e),n=new Uv,s=t.toString(16).replace(/^-/,""),i=new Uint8Array(Be.FromHex(s));if(t<0){const a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;const o=BigInt(`0x${Be.ToHex(a)}`)+t,c=de.toUint8Array(Be.FromHex(o.toString(16)));c[0]|=128,n.write(c)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new qs({valueHex:n.final()})}convertToDER(){const e=new qs({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new qs({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}S6=qs;Ie.Integer=S6;qs.NAME="INTEGER";var A6;class qv extends qs{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}A6=qv;Ie.Enumerated=A6;qv.NAME="ENUMERATED";class H_ extends ai(Wr){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=de.toUint8Array(e);if(!Ki(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=Hu(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){eg();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=cc(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",js;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=Be.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}}}H_.NAME="sidBlock";class O6 extends Wr{constructor({value:e=tn,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new H_;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,js;t.push(s)}return _k(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 H_;if(s>Number.MAX_SAFE_INTEGER){eg();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}}O6.NAME="ObjectIdentifierValueBlock";var j6;class Hv extends Cr{constructor(e={}){super(e,O6),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()}}}j6=Hv;Ie.ObjectIdentifier=j6;Hv.NAME="OBJECT IDENTIFIER";class F_ extends ai(Oc){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const s=de.toUint8Array(e);if(!Ki(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=Hu(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=cc(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",js;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=Be.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}F_.NAME="relativeSidBlock";class C6 extends Wr{constructor({value:e=tn,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new F_;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,js;n.push(i)}return _k(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 F_;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}}C6.NAME="RelativeObjectIdentifierValueBlock";var E6;class Sk extends Cr{constructor(e={}){super(e,C6),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()}}}E6=Sk;Ie.RelativeObjectIdentifier=E6;Sk.NAME="RelativeObjectIdentifier";var I6;class Si extends nn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}I6=Si;Ie.Sequence=I6;Si.NAME="SEQUENCE";var T6;let Ai=class extends nn{constructor(r={}){super(r),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};T6=Ai;Ie.Set=T6;Ai.NAME="SET";class N6 extends ai(Wr){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=tn}toJSON(){return{...super.toJSON(),value:this.value}}}N6.NAME="StringValueBlock";class B6 extends N6{}B6.NAME="SimpleStringValueBlock";class jn extends wk{constructor({...e}={}){super(e,B6)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,de.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}}jn.NAME="SIMPLE STRING";class R6 extends jn{fromBuffer(e){this.valueBlock.valueHexView=de.toUint8Array(e);try{this.valueBlock.value=Be.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=Be.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Be.FromUtf8String(e)),this.valueBlock.value=e}}R6.NAME="Utf8StringValueBlock";var P6;class zi extends R6{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}P6=zi;Ie.Utf8String=P6;zi.NAME="UTF8String";class $6 extends jn{fromBuffer(e){this.valueBlock.value=Be.ToUtf16String(e),this.valueBlock.valueHexView=de.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Be.FromUtf16String(e))}}$6.NAME="BmpStringValueBlock";var Z6;class Fv extends $6{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Z6=Fv;Ie.BmpString=Z6;Fv.NAME="BMPString";class D6 extends jn{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=cc(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}}D6.NAME="UniversalStringValueBlock";var M6;class Kv extends D6{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}M6=Kv;Ie.UniversalString=M6;Kv.NAME="UniversalString";var U6;class zv extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}U6=zv;Ie.NumericString=U6;zv.NAME="NumericString";var V6;class Wv extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}V6=Wv;Ie.PrintableString=V6;Wv.NAME="PrintableString";var L6;class Gv extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}L6=Gv;Ie.TeletexString=L6;Gv.NAME="TeletexString";var q6;class Jv extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}q6=Jv;Ie.VideotexString=q6;Jv.NAME="VideotexString";var H6;class Yv extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}H6=Yv;Ie.IA5String=H6;Yv.NAME="IA5String";var F6;class Xv extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}F6=Xv;Ie.GraphicString=F6;Xv.NAME="GraphicString";var K6;class df extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}K6=df;Ie.VisibleString=K6;df.NAME="VisibleString";var z6;class Qv extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}z6=Qv;Ie.GeneralString=z6;Qv.NAME="GeneralString";var W6;class e0 extends jn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}W6=e0;Ie.CharacterString=W6;e0.NAME="CharacterString";var G6;class hf extends df{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,de.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 t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(t===null){this.error="Wrong input string for conversion";return}const n=parseInt(t[1],10);n>=50?this.year=1900+n:this.year=2e3+n,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=gn(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=gn(this.month,2),t[2]=gn(this.day,2),t[3]=gn(this.hour,2),t[4]=gn(this.minute,2),t[5]=gn(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}}}G6=hf;Ie.UTCTime=G6;hf.NAME="UTCTime";var J6;class t0 extends hf{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 h=new Number(e[e.length-1]);if(isNaN(h.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 h=1,R=n.indexOf("+"),B="";if(R===-1&&(R=n.indexOf("-"),h=-1),R!==-1){if(B=n.substring(R+1),n=n.substring(0,R),B.length!==2&&B.length!==4)throw new Error("Wrong input string for conversion");let d=parseInt(B.substring(0,2),10);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");if(o=h*d,B.length===4){if(d=parseInt(B.substring(2,4),10),isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");c=h*d}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){const h=new Number(`0${n.substring(u)}`);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");i=h.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 h=60*i;this.minute=Math.floor(h),h=60*(h-this.minute),this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case s.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let h=60*i;this.second=Math.floor(h),h=1e3*(h-this.second),this.millisecond=Math.floor(h)}break;case s.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const h=1e3*i;this.millisecond=Math.floor(h)}break;default:throw new Error("Wrong input string for conversion")}const l=a.exec(s);if(l===null)throw new Error("Wrong input string for conversion");for(let h=1;h<l.length;h++)switch(h){case 1:this.year=parseInt(l[h],10);break;case 2:this.month=parseInt(l[h],10);break;case 3:this.day=parseInt(l[h],10);break;case 4:this.hour=parseInt(l[h],10)+o;break;case 5:this.minute=parseInt(l[h],10)+c;break;case 6:this.second=parseInt(l[h],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const h=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=h.getUTCFullYear(),this.month=h.getUTCMonth(),this.day=h.getUTCDay(),this.hour=h.getUTCHours(),this.minute=h.getUTCMinutes(),this.second=h.getUTCSeconds(),this.millisecond=h.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(gn(this.year,4)),t.push(gn(this.month,2)),t.push(gn(this.day,2)),t.push(gn(this.hour,2)),t.push(gn(this.minute,2)),t.push(gn(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(gn(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}J6=t0;Ie.GeneralizedTime=J6;t0.NAME="GeneralizedTime";var Y6;class Ak extends zi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Y6=Ak;Ie.DATE=Y6;Ak.NAME="DATE";var X6;class Ok extends zi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}X6=Ok;Ie.TimeOfDay=X6;Ok.NAME="TimeOfDay";var Q6;class jk extends zi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Q6=jk;Ie.DateTime=Q6;jk.NAME="DateTime";var eI;class Ck extends zi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}eI=Ck;Ie.Duration=eI;Ck.NAME="Duration";var tI;class Ek extends zi{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}tI=Ek;Ie.TIME=tI;Ek.NAME="TIME";class lc{constructor({name:e=tn,optional:t=!1}={}){this.name=e,this.optional=t}}class Ik extends lc{constructor({value:e=[],...t}={}){super(t),this.value=e}}class tg extends lc{constructor({value:e=new lc,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class uM{constructor({data:e=Vv}={}){this.dataView=de.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=de.toUint8Array(e)}fromBER(e,t,n){const s=t+n;return this.dataView=de.toUint8Array(e).subarray(t,s),s}toBER(e){return this.dataView.slice().buffer}}function So(r,e,t){if(t instanceof Ik){for(let s=0;s<t.value.length;s++)if(So(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(mb)&&(s.name=t.name),s}}if(t instanceof lc)return t.hasOwnProperty(mb)&&(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(!(XD in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(rM in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(nM 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(QD)===!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(eM)===!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(tM)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(YD 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(!(UA in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,i=e.idBlock.valueHexView;if(s.length!==i.length)return{verified:!1,result:r};for(let a=0;a<s.length;a++)if(s[a]!==i[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,tn),t.name&&(r[t.name]=e)),t instanceof Ie.Constructed){let s=0,i={verified:!1,result:{error:"Unknown error"}},a=t.valueBlock.value.length;if(a>0&&t.valueBlock.value[0]instanceof tg&&(a=e.valueBlock.value.length),a===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let o=!0;for(let c=0;c<t.valueBlock.value.length;c++)o=o&&(t.valueBlock.value[c].optional||!1);return o?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,tn),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let o=0;o<a;o++)if(o-s>=e.valueBlock.value.length){if(t.valueBlock.value[o].optional===!1){const c={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,tn),t.name&&(delete r[t.name],c.name=t.name)),c}}else if(t.valueBlock.value[0]instanceof tg){if(i=So(r,e.valueBlock.value[o],t.valueBlock.value[0].value),i.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,tn),t.name&&delete r[t.name]),i;if(mb in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let c={};sM in t.valueBlock.value[0]&&t.valueBlock.value[0].local?c=e:c=r,typeof c[t.valueBlock.value[0].name]>"u"&&(c[t.valueBlock.value[0].name]=[]),c[t.valueBlock.value[0].name].push(e.valueBlock.value[o])}}else if(i=So(r,e.valueBlock.value[o-s],t.valueBlock.value[o]),i.verified===!1)if(t.valueBlock.value[o].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,tn),t.name&&delete r[t.name]),i;if(i.verified===!1){const o={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,tn),t.name&&(delete r[t.name],o.name=t.name)),o}return{verified:!0,result:r}}if(t.primitiveSchema&&UA in e.valueBlock){const s=gl(e.valueBlock.valueHexView);if(s.offset===-1){const i={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,tn),t.name&&(delete r[t.name],i.name=t.name)),i}return So(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function lM(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=gl(de.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:So(t.result,t.result,e)}const rI=Object.freeze(Object.defineProperty({__proto__:null,Any:lc,BaseBlock:Cr,BaseStringBlock:wk,BitString:Mo,BmpString:Fv,Boolean:Lv,CharacterString:e0,Choice:Ik,Constructed:nn,DATE:Ak,DateTime:jk,Duration:Ck,EndOfContent:xk,Enumerated:qv,GeneralString:Qv,GeneralizedTime:t0,GraphicString:Xv,HexBlock:ai,IA5String:Yv,Integer:qs,Null:uc,NumericString:zv,ObjectIdentifier:Hv,OctetString:Do,Primitive:lf,PrintableString:Wv,RawData:uM,RelativeObjectIdentifier:Sk,Repeated:tg,Sequence:Si,Set:Ai,TIME:Ek,TeletexString:Gv,TimeOfDay:Ok,UTCTime:hf,UniversalString:Kv,Utf8String:zi,ValueBlock:Wr,VideotexString:Jv,ViewWriter:Uv,VisibleString:df,compareSchema:So,fromBER:uu,verifySchema:lM},Symbol.toStringTag,{value:"Module"}));var J;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(J||(J={}));var D;(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"})(D||(D={}));class r0{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(de.isBufferSource(e))this.unusedBits=t,this.value=de.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Mo))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 Mo({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Mo({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 Ht{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):de.isBufferSource(e)?this.buffer=de.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Do))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Do({valueHex:this.buffer})}toSchema(e){return new Do({name:e})}}const dM={fromASN:r=>r instanceof uc?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new uc;const e=uu(r);if(e.result.error)throw new Error(e.result.error);return e.result}},hM={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new qs({value:+r})},pM={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new qv({value:r})},Xt={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new qs({valueHex:r})},fM={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Mo({valueHex:r})},mM={fromASN:r=>r.valueBlock.toString(),toASN:r=>new Hv({value:r})},yM={fromASN:r=>r.valueBlock.value,toASN:r=>new Lv({value:r})},rg={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Do({valueHex:r})},gM={fromASN:r=>new Ht(r.getValue()),toASN:r=>r.toASN()};function Kn(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const nI=Kn(zi),vM=Kn(Fv),bM=Kn(Kv),_M=Kn(zv),wM=Kn(Wv),xM=Kn(Gv),kM=Kn(Jv),SM=Kn(Yv),AM=Kn(Xv),OM=Kn(df),jM=Kn(Qv),CM=Kn(e0),EM={fromASN:r=>r.toDate(),toASN:r=>new hf({valueDate:r})},IM={fromASN:r=>r.toDate(),toASN:r=>new t0({valueDate:r})},TM={fromASN:()=>null,toASN:()=>new uc};function Tk(r){switch(r){case D.Any:return dM;case D.BitString:return fM;case D.BmpString:return vM;case D.Boolean:return yM;case D.CharacterString:return CM;case D.Enumerated:return pM;case D.GeneralString:return jM;case D.GeneralizedTime:return IM;case D.GraphicString:return AM;case D.IA5String:return SM;case D.Integer:return hM;case D.Null:return TM;case D.NumericString:return _M;case D.ObjectIdentifier:return mM;case D.OctetString:return rg;case D.PrintableString:return wM;case D.TeletexString:return xM;case D.UTCTime:return EM;case D.UniversalString:return bM;case D.Utf8String:return nI;case D.VideotexString:return kM;case D.VisibleString:return OM;default:return null}}function wi(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:wi(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function sI(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:sI(t)}return!1}function NM(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 BM{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:J.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 l=D[a.type],h=rI[l];if(!h)throw new Error(`Cannot get ASN1 class by name '${l}'`);c=new h({name:o})}else wi(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===J.Choice?c=new lc({name:o}):(c=this.create(a.type,!1),c.name=o):c=new lc({name:o});const u=!!a.optional||a.defaultValue!==void 0;if(a.repeated){c.name="";const l=a.repeated==="set"?Ai:Si;c=new l({name:"",value:[new tg({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||wi(a.type)){const l=a.repeated?nn:lf;s.push(new l({name:o,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const l=!!a.repeated;let h=l?c:this.get(a.type,!0).schema;h="valueBlock"in h?h.valueBlock.value:h.value,s.push(new nn({name:l?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:h}))}else s.push(new nn({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,s.push(c)}switch(n.type){case J.Sequence:return new Si({value:s,name:""});case J.Set:return new Ai({value:s,name:""});case J.Choice:return new Ik({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 $n=new BM,Q=r=>e=>{let t;$n.has(e)?t=$n.get(e):(t=$n.createDefault(e),$n.set(e,t)),Object.assign(t,r)},w=r=>(e,t)=>{let n;$n.has(e.constructor)?n=$n.get(e.constructor):(n=$n.createDefault(e.constructor),$n.set(e.constructor,n));const s=Object.assign({},r);if(typeof s.type=="number"&&!s.converter){const i=Tk(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 LA extends Error{constructor(){super(...arguments),this.schemas=[]}}class RM{static parse(e,t){const n=uu(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(wi(t))return new t().fromASN(e);const s=$n.get(t);$n.cache(t);let i=s.schema;if(e.constructor===nn&&s.type!==J.Choice){i=new nn({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:s.schema.valueBlock.value});for(const c in s.items)delete e[c]}const a=So({},e,i);if(!a.verified)throw new LA(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(sI(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=Tk(c);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,l=>u.fromASN(l))}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 l=s.items[c],h=l.type;if(typeof h=="number"||wi(h)){const R=(n=l.converter)!==null&&n!==void 0?n:wi(h)?new h:null;if(!R)throw new Error("Converter is empty");if(l.repeated)if(l.implicit){const B=l.repeated==="sequence"?Si:Ai,d=new B;d.valueBlock=u.valueBlock;const g=uu(d.toBER(!1));if(g.offset===-1)throw new Error(`Cannot parse the child item. ${g.result.error}`);if(!("value"in g.result.valueBlock&&Array.isArray(g.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const A=g.result.valueBlock.value;o[c]=Array.from(A,O=>R.fromASN(O))}else o[c]=Array.from(u,B=>R.fromASN(B));else{let B=u;if(l.implicit){let d;if(wi(h))d=new h().toSchema("");else{const g=D[h],A=rI[g];if(!A)throw new Error(`Cannot get '${g}' class from asn1js module`);d=new A}d.valueBlock=B.valueBlock,B=uu(d.toBER(!1)).result}o[c]=R.fromASN(B)}}else if(l.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,R=>this.fromASN(R,h))}else o[c]=this.fromASN(u,h)}return o}catch(s){throw s instanceof LA&&s.schemas.push(t.name),s}}}class Nk{static serialize(e){return e instanceof Cr?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&wi(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=$n.get(t);$n.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=Tk(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"&&NM(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=Nk.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||wi(o.type))){const l={};l.valueHex=u instanceof uc?u.valueBeforeDecodeView:u.valueBlock.toBER(),s.push(new lf({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...l}))}else s.push(new nn({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else s.push(new nn({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 J.Sequence:i=new Si({value:s});break;case J.Set:i=new Ai({value:s});break;case J.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 ${D[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"?Si:Ai;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"?Si:Ai;i=new o({value:a})}else i=this.toASN(s);return i}}class Wt extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class ce{static serialize(e){return Nk.serialize(e)}static parse(e,t){return RM.parse(e,t)}static toString(e){const t=de.isBufferSource(e)?de.toArrayBuffer(e):ce.serialize(e),n=uu(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function f(r,e,t,n){var s=arguments.length,i=s<3?e: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 iI={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(d,g){if(d.indexOf("::")!==d.lastIndexOf("::"))return null;let A=0,O=-1,$=(d.match(c.zoneIndex)||[])[0],P,ae;for($&&($=$.substring(1),d=d.replace(/%.+$/,""));(O=d.indexOf(":",O+1))>=0;)A++;if(d.substr(0,2)==="::"&&A--,d.substr(-2,2)==="::"&&A--,A>g)return null;for(ae=g-A,P=":";ae--;)P+="0:";return d=d.replace("::",P),d[0]===":"&&(d=d.slice(1)),d[d.length-1]===":"&&(d=d.slice(0,-1)),g=function(){const Re=d.split(":"),He=[];for(let Te=0;Te<Re.length;Te++)He.push(parseInt(Re[Te],16));return He}(),{parts:g,zoneId:$}}function l(d,g,A,O){if(d.length!==g.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let $=0,P;for(;O>0;){if(P=A-O,P<0&&(P=0),d[$]>>P!==g[$]>>P)return!1;O-=A,$+=1}return!0}function h(d){if(i.test(d))return parseInt(d,16);if(d[0]==="0"&&!isNaN(parseInt(d[1],10))){if(s.test(d))return parseInt(d,8);throw new Error(`ipaddr: cannot parse ${d} as octal`)}return parseInt(d,10)}function R(d,g){for(;d.length<g;)d=`0${d}`;return d}const B={};B.IPv4=function(){function d(g){if(g.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,O;for(A=0;A<g.length;A++)if(O=g[A],!(0<=O&&O<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=g}return d.prototype.SpecialRanges={unspecified:[[new d([0,0,0,0]),8]],broadcast:[[new d([255,255,255,255]),32]],multicast:[[new d([224,0,0,0]),4]],linkLocal:[[new d([169,254,0,0]),16]],loopback:[[new d([127,0,0,0]),8]],carrierGradeNat:[[new d([100,64,0,0]),10]],private:[[new d([10,0,0,0]),8],[new d([172,16,0,0]),12],[new d([192,168,0,0]),16]],reserved:[[new d([192,0,0,0]),24],[new d([192,0,2,0]),24],[new d([192,88,99,0]),24],[new d([198,18,0,0]),15],[new d([198,51,100,0]),24],[new d([203,0,113,0]),24],[new d([240,0,0,0]),4]],as112:[[new d([192,175,48,0]),24],[new d([192,31,196,0]),24]],amt:[[new d([192,52,193,0]),24]]},d.prototype.kind=function(){return"ipv4"},d.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return l(this.octets,g.octets,8,A)},d.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let $,P,ae;for($=3;$>=0;$-=1)if(P=this.octets[$],P in O){if(ae=O[P],A&&ae!==0)return null;ae!==8&&(A=!0),g+=ae}else return null;return 32-g},d.prototype.range=function(){return B.subnetMatch(this,this.SpecialRanges)},d.prototype.toByteArray=function(){return this.octets.slice(0)},d.prototype.toIPv4MappedAddress=function(){return B.IPv6.parse(`::ffff:${this.toString()}`)},d.prototype.toNormalizedString=function(){return this.toString()},d.prototype.toString=function(){return this.octets.join(".")},d}(),B.IPv4.broadcastAddressFromCIDR=function(d){try{const g=this.parseCIDR(d),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),$=[];let P=0;for(;P<4;)$.push(parseInt(A[P],10)|parseInt(O[P],10)^255),P++;return new this($)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},B.IPv4.isIPv4=function(d){return this.parser(d)!==null},B.IPv4.isValid=function(d){try{return new this(this.parser(d)),!0}catch{return!1}},B.IPv4.isValidCIDR=function(d){try{return this.parseCIDR(d),!0}catch{return!1}},B.IPv4.isValidFourPartDecimal=function(d){return!!(B.IPv4.isValid(d)&&d.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},B.IPv4.networkAddressFromCIDR=function(d){let g,A,O,$,P;try{for(g=this.parseCIDR(d),O=g[0].toByteArray(),P=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),$=[],A=0;A<4;)$.push(parseInt(O[A],10)&parseInt(P[A],10)),A++;return new this($)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},B.IPv4.parse=function(d){const g=this.parser(d);if(g===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(g)},B.IPv4.parseCIDR=function(d){let g;if(g=d.match(/^(.+)\/(\d+)$/)){const A=parseInt(g[2]);if(A>=0&&A<=32){const O=[this.parse(g[1]),A];return Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},B.IPv4.parser=function(d){let g,A,O;if(g=d.match(n.fourOctet))return function(){const $=g.slice(1,6),P=[];for(let ae=0;ae<$.length;ae++)A=$[ae],P.push(h(A));return P}();if(g=d.match(n.longValue)){if(O=h(g[1]),O>4294967295||O<0)throw new Error("ipaddr: address outside defined range");return function(){const $=[];let P;for(P=0;P<=24;P+=8)$.push(O>>P&255);return $}().reverse()}else return(g=d.match(n.twoOctet))?function(){const $=g.slice(1,4),P=[];if(O=h($[1]),O>16777215||O<0)throw new Error("ipaddr: address outside defined range");return P.push(h($[0])),P.push(O>>16&255),P.push(O>>8&255),P.push(O&255),P}():(g=d.match(n.threeOctet))?function(){const $=g.slice(1,5),P=[];if(O=h($[2]),O>65535||O<0)throw new Error("ipaddr: address outside defined range");return P.push(h($[0])),P.push(h($[1])),P.push(O>>8&255),P.push(O&255),P}():null},B.IPv4.subnetMaskFromPrefixLength=function(d){if(d=parseInt(d),d<0||d>32)throw new Error("ipaddr: invalid IPv4 prefix length");const g=[0,0,0,0];let A=0;const O=Math.floor(d/8);for(;A<O;)g[A]=255,A++;return O<4&&(g[O]=Math.pow(2,d%8)-1<<8-d%8),new this(g)},B.IPv6=function(){function d(g,A){let O,$;if(g.length===16)for(this.parts=[],O=0;O<=14;O+=2)this.parts.push(g[O]<<8|g[O+1]);else if(g.length===8)this.parts=g;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(O=0;O<this.parts.length;O++)if($=this.parts[O],!(0<=$&&$<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");A&&(this.zoneId=A)}return d.prototype.SpecialRanges={unspecified:[new d([0,0,0,0,0,0,0,0]),128],linkLocal:[new d([65152,0,0,0,0,0,0,0]),10],multicast:[new d([65280,0,0,0,0,0,0,0]),8],loopback:[new d([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new d([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new d([0,0,0,0,0,65535,0,0]),96],discard:[new d([256,0,0,0,0,0,0,0]),64],rfc6145:[new d([0,0,0,0,65535,0,0,0]),96],rfc6052:[new d([100,65435,0,0,0,0,0,0]),96],"6to4":[new d([8194,0,0,0,0,0,0,0]),16],teredo:[new d([8193,0,0,0,0,0,0,0]),32],benchmarking:[new d([8193,2,0,0,0,0,0,0]),48],amt:[new d([8193,3,0,0,0,0,0,0]),32],as112v6:[[new d([8193,4,274,0,0,0,0,0]),48],[new d([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new d([8193,16,0,0,0,0,0,0]),28],orchid2:[new d([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new d([8193,48,0,0,0,0,0,0]),28],reserved:[[new d([8193,0,0,0,0,0,0,0]),23],[new d([8193,3512,0,0,0,0,0,0]),32]]},d.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},d.prototype.kind=function(){return"ipv6"},d.prototype.match=function(g,A){let O;if(A===void 0&&(O=g,g=O[0],A=O[1]),g.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return l(this.parts,g.parts,16,A)},d.prototype.prefixLengthFromSubnetMask=function(){let g=0,A=!1;const O={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let $,P;for(let ae=7;ae>=0;ae-=1)if($=this.parts[ae],$ in O){if(P=O[$],A&&P!==0)return null;P!==16&&(A=!0),g+=P}else return null;return 128-g},d.prototype.range=function(){return B.subnetMatch(this,this.SpecialRanges)},d.prototype.toByteArray=function(){let g;const A=[],O=this.parts;for(let $=0;$<O.length;$++)g=O[$],A.push(g>>8),A.push(g&255);return A},d.prototype.toFixedLengthString=function(){const g=(function(){const O=[];for(let $=0;$<this.parts.length;$++)O.push(R(this.parts[$].toString(16),4));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},d.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const g=this.parts.slice(-2),A=g[0],O=g[1];return new B.IPv4([A>>8,A&255,O>>8,O&255])},d.prototype.toNormalizedString=function(){const g=(function(){const O=[];for(let $=0;$<this.parts.length;$++)O.push(this.parts[$].toString(16));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),g+A},d.prototype.toRFC5952String=function(){const g=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString();let O=0,$=-1,P;for(;P=g.exec(A);)P[0].length>$&&(O=P.index,$=P[0].length);return $<0?A:`${A.substring(0,O)}::${A.substring(O+$)}`},d.prototype.toString=function(){return this.toRFC5952String()},d}(),B.IPv6.broadcastAddressFromCIDR=function(d){try{const g=this.parseCIDR(d),A=g[0].toByteArray(),O=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),$=[];let P=0;for(;P<16;)$.push(parseInt(A[P],10)|parseInt(O[P],10)^255),P++;return new this($)}catch(g){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${g})`)}},B.IPv6.isIPv6=function(d){return this.parser(d)!==null},B.IPv6.isValid=function(d){if(typeof d=="string"&&d.indexOf(":")===-1)return!1;try{const g=this.parser(d);return new this(g.parts,g.zoneId),!0}catch{return!1}},B.IPv6.isValidCIDR=function(d){if(typeof d=="string"&&d.indexOf(":")===-1)return!1;try{return this.parseCIDR(d),!0}catch{return!1}},B.IPv6.networkAddressFromCIDR=function(d){let g,A,O,$,P;try{for(g=this.parseCIDR(d),O=g[0].toByteArray(),P=this.subnetMaskFromPrefixLength(g[1]).toByteArray(),$=[],A=0;A<16;)$.push(parseInt(O[A],10)&parseInt(P[A],10)),A++;return new this($)}catch(ae){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ae})`)}},B.IPv6.parse=function(d){const g=this.parser(d);if(g.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(g.parts,g.zoneId)},B.IPv6.parseCIDR=function(d){let g,A,O;if((A=d.match(/^(.+)\/(\d+)$/))&&(g=parseInt(A[2]),g>=0&&g<=128))return O=[this.parse(A[1]),g],Object.defineProperty(O,"toString",{value:function(){return this.join("/")}}),O;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},B.IPv6.parser=function(d){let g,A,O,$,P,ae;if(O=d.match(c.deprecatedTransitional))return this.parser(`::ffff:${O[1]}`);if(c.native.test(d))return u(d,8);if((O=d.match(c.transitional))&&(ae=O[6]||"",g=O[1],O[1].endsWith("::")||(g=g.slice(0,-1)),g=u(g+ae,6),g.parts)){for(P=[parseInt(O[2]),parseInt(O[3]),parseInt(O[4]),parseInt(O[5])],A=0;A<P.length;A++)if($=P[A],!(0<=$&&$<=255))return null;return g.parts.push(P[0]<<8|P[1]),g.parts.push(P[2]<<8|P[3]),{parts:g.parts,zoneId:g.zoneId}}return null},B.IPv6.subnetMaskFromPrefixLength=function(d){if(d=parseInt(d),d<0||d>128)throw new Error("ipaddr: invalid IPv6 prefix length");const g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let A=0;const O=Math.floor(d/8);for(;A<O;)g[A]=255,A++;return O<16&&(g[O]=Math.pow(2,d%8)-1<<8-d%8),new this(g)},B.fromByteArray=function(d){const g=d.length;if(g===4)return new B.IPv4(d);if(g===16)return new B.IPv6(d);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},B.isValid=function(d){return B.IPv6.isValid(d)||B.IPv4.isValid(d)},B.isValidCIDR=function(d){return B.IPv6.isValidCIDR(d)||B.IPv4.isValidCIDR(d)},B.parse=function(d){if(B.IPv6.isValid(d))return B.IPv6.parse(d);if(B.IPv4.isValid(d))return B.IPv4.parse(d);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},B.parseCIDR=function(d){try{return B.IPv6.parseCIDR(d)}catch{try{return B.IPv4.parseCIDR(d)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},B.process=function(d){const g=this.parse(d);return g.kind()==="ipv6"&&g.isIPv4MappedAddress()?g.toIPv4Address():g},B.subnetMatch=function(d,g,A){let O,$,P,ae;A==null&&(A="unicast");for($ in g)if(Object.prototype.hasOwnProperty.call(g,$)){for(P=g[$],P[0]&&!(P[0]instanceof Array)&&(P=[P]),O=0;O<P.length;O++)if(ae=P[O],d.kind()===ae[0].kind()&&d.match.apply(d,ae))return $}return A},r.exports?r.exports=B:e.ipaddr=B})(Xy)})(iI);var qA=iI.exports;class HA{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 qA.fromByteArray(Array.from(t)).toString()}return this.decodeIP(Be.ToHex(e))}static fromString(e){const t=qA.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var K_,z_,W_;let Er=class{constructor(r={}){Object.assign(this,r)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};f([w({type:D.TeletexString})],Er.prototype,"teletexString",void 0);f([w({type:D.PrintableString})],Er.prototype,"printableString",void 0);f([w({type:D.UniversalString})],Er.prototype,"universalString",void 0);f([w({type:D.Utf8String})],Er.prototype,"utf8String",void 0);f([w({type:D.BmpString})],Er.prototype,"bmpString",void 0);Er=f([Q({type:J.Choice})],Er);let Fu=class extends Er{constructor(r={}){super(r),Object.assign(this,r)}toString(){return this.ia5String||(this.anyValue?Be.ToHex(this.anyValue):super.toString())}};f([w({type:D.IA5String})],Fu.prototype,"ia5String",void 0);f([w({type:D.Any})],Fu.prototype,"anyValue",void 0);Fu=f([Q({type:J.Choice})],Fu);class n0{constructor(e={}){this.type="",this.value=new Fu,Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],n0.prototype,"type",void 0);f([w({type:Fu})],n0.prototype,"value",void 0);let Ku=K_=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,K_.prototype)}};Ku=K_=f([Q({type:J.Set,itemType:n0})],Ku);let G_=z_=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,z_.prototype)}};G_=z_=f([Q({type:J.Sequence,itemType:Ku})],G_);let fr=W_=class extends G_{constructor(r){super(r),Object.setPrototypeOf(this,W_.prototype)}};fr=W_=f([Q({type:J.Sequence})],fr);const PM={fromASN:r=>HA.toString(rg.fromASN(r)),toASN:r=>rg.toASN(HA.fromString(r))};class lp{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],lp.prototype,"typeId",void 0);f([w({type:D.Any,context:0})],lp.prototype,"value",void 0);class Bk{constructor(e={}){this.partyName=new Er,Object.assign(this,e)}}f([w({type:Er,optional:!0,context:0,implicit:!0})],Bk.prototype,"nameAssigner",void 0);f([w({type:Er,context:1,implicit:!0})],Bk.prototype,"partyName",void 0);let ht=class{constructor(r={}){Object.assign(this,r)}};f([w({type:lp,context:0,implicit:!0})],ht.prototype,"otherName",void 0);f([w({type:D.IA5String,context:1,implicit:!0})],ht.prototype,"rfc822Name",void 0);f([w({type:D.IA5String,context:2,implicit:!0})],ht.prototype,"dNSName",void 0);f([w({type:D.Any,context:3,implicit:!0})],ht.prototype,"x400Address",void 0);f([w({type:fr,context:4,implicit:!1})],ht.prototype,"directoryName",void 0);f([w({type:Bk,context:5})],ht.prototype,"ediPartyName",void 0);f([w({type:D.IA5String,context:6,implicit:!0})],ht.prototype,"uniformResourceIdentifier",void 0);f([w({type:D.OctetString,context:7,implicit:!0,converter:PM})],ht.prototype,"iPAddress",void 0);f([w({type:D.ObjectIdentifier,context:8,implicit:!0})],ht.prototype,"registeredID",void 0);ht=f([Q({type:J.Choice})],ht);const Rk="1.3.6.1.5.5.7",$M=`${Rk}.1`,vl=`${Rk}.3`,s0=`${Rk}.48`,FA=`${s0}.1`,KA=`${s0}.2`,zA=`${s0}.3`,WA=`${s0}.5`,eo="2.5.29";var J_;const Y_=`${$M}.1`;class pf{constructor(e={}){this.accessMethod="",this.accessLocation=new ht,Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],pf.prototype,"accessMethod",void 0);f([w({type:ht})],pf.prototype,"accessLocation",void 0);let tu=J_=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,J_.prototype)}};tu=J_=f([Q({type:J.Sequence,itemType:pf})],tu);const X_=`${eo}.35`;class Pk extends Ht{}class Ao{constructor(e={}){e&&Object.assign(this,e)}}f([w({type:Pk,context:0,optional:!0,implicit:!0})],Ao.prototype,"keyIdentifier",void 0);f([w({type:ht,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Ao.prototype,"authorityCertIssuer",void 0);f([w({type:D.Integer,context:2,optional:!0,implicit:!0,converter:Xt})],Ao.prototype,"authorityCertSerialNumber",void 0);const aI=`${eo}.19`;class ng{constructor(e={}){this.cA=!1,Object.assign(this,e)}}f([w({type:D.Boolean,defaultValue:!1})],ng.prototype,"cA",void 0);f([w({type:D.Integer,optional:!0})],ng.prototype,"pathLenConstraint",void 0);var Q_;let Ur=Q_=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Q_.prototype)}};Ur=Q_=f([Q({type:J.Sequence,itemType:ht})],Ur);var ew;let GA=ew=class extends Ur{constructor(r){super(r),Object.setPrototypeOf(this,ew.prototype)}};GA=ew=f([Q({type:J.Sequence})],GA);var tw;const oI=`${eo}.32`;let $i=class{constructor(r={}){Object.assign(this,r)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};f([w({type:D.IA5String})],$i.prototype,"ia5String",void 0);f([w({type:D.VisibleString})],$i.prototype,"visibleString",void 0);f([w({type:D.BmpString})],$i.prototype,"bmpString",void 0);f([w({type:D.Utf8String})],$i.prototype,"utf8String",void 0);$i=f([Q({type:J.Choice})],$i);class $k{constructor(e={}){this.organization=new $i,this.noticeNumbers=[],Object.assign(this,e)}}f([w({type:$i})],$k.prototype,"organization",void 0);f([w({type:D.Integer,repeated:"sequence"})],$k.prototype,"noticeNumbers",void 0);class Zk{constructor(e={}){Object.assign(this,e)}}f([w({type:$k,optional:!0})],Zk.prototype,"noticeRef",void 0);f([w({type:$i,optional:!0})],Zk.prototype,"explicitText",void 0);let sg=class{constructor(r={}){Object.assign(this,r)}};f([w({type:D.IA5String})],sg.prototype,"cPSuri",void 0);f([w({type:Zk})],sg.prototype,"userNotice",void 0);sg=f([Q({type:J.Choice})],sg);class Dk{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],Dk.prototype,"policyQualifierId",void 0);f([w({type:D.Any})],Dk.prototype,"qualifier",void 0);class i0{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],i0.prototype,"policyIdentifier",void 0);f([w({type:Dk,repeated:"sequence",optional:!0})],i0.prototype,"policyQualifiers",void 0);let ig=tw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,tw.prototype)}};ig=tw=f([Q({type:J.Sequence,itemType:i0})],ig);let ag=class{constructor(r=0){this.value=r}};f([w({type:D.Integer})],ag.prototype,"value",void 0);ag=f([Q({type:J.Choice})],ag);let JA=class extends ag{};JA=f([Q({type:J.Choice})],JA);var rw;const nw=`${eo}.31`;var es;(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"})(es||(es={}));class cI extends r0{toJSON(){const e=[],t=this.toNumber();return t&es.aACompromise&&e.push("aACompromise"),t&es.affiliationChanged&&e.push("affiliationChanged"),t&es.cACompromise&&e.push("cACompromise"),t&es.certificateHold&&e.push("certificateHold"),t&es.cessationOfOperation&&e.push("cessationOfOperation"),t&es.keyCompromise&&e.push("keyCompromise"),t&es.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&es.superseded&&e.push("superseded"),t&es.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let dc=class{constructor(r={}){Object.assign(this,r)}};f([w({type:ht,context:0,repeated:"sequence",implicit:!0})],dc.prototype,"fullName",void 0);f([w({type:Ku,context:1,implicit:!0})],dc.prototype,"nameRelativeToCRLIssuer",void 0);dc=f([Q({type:J.Choice})],dc);class bl{constructor(e={}){Object.assign(this,e)}}f([w({type:dc,context:0,optional:!0})],bl.prototype,"distributionPoint",void 0);f([w({type:cI,context:1,optional:!0,implicit:!0})],bl.prototype,"reasons",void 0);f([w({type:ht,context:2,optional:!0,repeated:"sequence",implicit:!0})],bl.prototype,"cRLIssuer",void 0);let lu=rw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,rw.prototype)}};lu=rw=f([Q({type:J.Sequence,itemType:bl})],lu);var sw;let YA=sw=class extends lu{constructor(r){super(r),Object.setPrototypeOf(this,sw.prototype)}};YA=sw=f([Q({type:J.Sequence,itemType:bl})],YA);class Nr{constructor(e={}){this.onlyContainsUserCerts=Nr.ONLY,this.onlyContainsCACerts=Nr.ONLY,this.indirectCRL=Nr.ONLY,this.onlyContainsAttributeCerts=Nr.ONLY,Object.assign(this,e)}}Nr.ONLY=!1;f([w({type:dc,context:0,optional:!0})],Nr.prototype,"distributionPoint",void 0);f([w({type:D.Boolean,context:1,defaultValue:Nr.ONLY,implicit:!0})],Nr.prototype,"onlyContainsUserCerts",void 0);f([w({type:D.Boolean,context:2,defaultValue:Nr.ONLY,implicit:!0})],Nr.prototype,"onlyContainsCACerts",void 0);f([w({type:cI,context:3,optional:!0,implicit:!0})],Nr.prototype,"onlySomeReasons",void 0);f([w({type:D.Boolean,context:4,defaultValue:Nr.ONLY,implicit:!0})],Nr.prototype,"indirectCRL",void 0);f([w({type:D.Boolean,context:5,defaultValue:Nr.ONLY,implicit:!0})],Nr.prototype,"onlyContainsAttributeCerts",void 0);var jd;(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"})(jd||(jd={}));let iw=class{constructor(r=jd.unspecified){this.reason=jd.unspecified,this.reason=r}toJSON(){return jd[this.reason]}toString(){return this.toJSON()}};f([w({type:D.Enumerated})],iw.prototype,"reason",void 0);iw=f([Q({type:J.Choice})],iw);var aw;const uI=`${eo}.37`;let og=aw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,aw.prototype)}};og=aw=f([Q({type:J.Sequence,itemType:D.ObjectIdentifier})],og);const ZM=`${vl}.1`,DM=`${vl}.2`,MM=`${vl}.3`,UM=`${vl}.4`,VM=`${vl}.8`,LM=`${vl}.9`;let ow=class{constructor(r=new ArrayBuffer(0)){this.value=r}};f([w({type:D.Integer,converter:Xt})],ow.prototype,"value",void 0);ow=f([Q({type:J.Choice})],ow);let cw=class{constructor(r){this.value=new Date,r&&(this.value=r)}};f([w({type:D.GeneralizedTime})],cw.prototype,"value",void 0);cw=f([Q({type:J.Choice})],cw);var uw;let XA=uw=class extends Ur{constructor(r){super(r),Object.setPrototypeOf(this,uw.prototype)}};XA=uw=f([Q({type:J.Sequence})],XA);const lI=`${eo}.15`;var ts;(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"})(ts||(ts={}));class yb extends r0{toJSON(){const e=this.toNumber(),t=[];return e&ts.cRLSign&&t.push("crlSign"),e&ts.dataEncipherment&&t.push("dataEncipherment"),e&ts.decipherOnly&&t.push("decipherOnly"),e&ts.digitalSignature&&t.push("digitalSignature"),e&ts.encipherOnly&&t.push("encipherOnly"),e&ts.keyAgreement&&t.push("keyAgreement"),e&ts.keyCertSign&&t.push("keyCertSign"),e&ts.keyEncipherment&&t.push("keyEncipherment"),e&ts.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var lw;class a0{constructor(e={}){this.base=new ht,this.minimum=0,Object.assign(this,e)}}f([w({type:ht})],a0.prototype,"base",void 0);f([w({type:D.Integer,context:0,defaultValue:0,implicit:!0})],a0.prototype,"minimum",void 0);f([w({type:D.Integer,context:1,optional:!0,implicit:!0})],a0.prototype,"maximum",void 0);let cg=lw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,lw.prototype)}};cg=lw=f([Q({type:J.Sequence,itemType:a0})],cg);class dI{constructor(e={}){Object.assign(this,e)}}f([w({type:cg,context:0,optional:!0,implicit:!0})],dI.prototype,"permittedSubtrees",void 0);f([w({type:cg,context:1,optional:!0,implicit:!0})],dI.prototype,"excludedSubtrees",void 0);class hI{constructor(e={}){Object.assign(this,e)}}f([w({type:D.Integer,context:0,implicit:!0,optional:!0,converter:Xt})],hI.prototype,"requireExplicitPolicy",void 0);f([w({type:D.Integer,context:1,implicit:!0,optional:!0,converter:Xt})],hI.prototype,"inhibitPolicyMapping",void 0);var dw;class Mk{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],Mk.prototype,"issuerDomainPolicy",void 0);f([w({type:D.ObjectIdentifier})],Mk.prototype,"subjectDomainPolicy",void 0);let QA=dw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,dw.prototype)}};QA=dw=f([Q({type:J.Sequence,itemType:Mk})],QA);var hw;const pI=`${eo}.17`;let pw=hw=class extends Ur{constructor(r){super(r),Object.setPrototypeOf(this,hw.prototype)}};pw=hw=f([Q({type:J.Sequence})],pw);let Zi=class{constructor(r={}){this.type="",this.values=[],Object.assign(this,r)}};f([w({type:D.ObjectIdentifier})],Zi.prototype,"type",void 0);f([w({type:D.Any,repeated:"set"})],Zi.prototype,"values",void 0);var fw;let eO=fw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,fw.prototype)}};eO=fw=f([Q({type:J.Sequence,itemType:Zi})],eO);const fI=`${eo}.14`;class Sa extends Pk{}class mI{constructor(e={}){Object.assign(this,e)}}f([w({type:D.GeneralizedTime,context:0,implicit:!0,optional:!0})],mI.prototype,"notBefore",void 0);f([w({type:D.GeneralizedTime,context:1,implicit:!0,optional:!0})],mI.prototype,"notAfter",void 0);var Cd;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Cd||(Cd={}));class yI extends r0{toJSON(){const e=[],t=this.toNumber();return t&Cd.pKIXCertificate&&e.push("pKIXCertificate"),t&Cd.newExtensions&&e.push("newExtensions"),t&Cd.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class gI{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new yI,Object.assign(this,e)}}f([w({type:D.GeneralString})],gI.prototype,"entrustVers",void 0);f([w({type:yI})],gI.prototype,"entrustInfoFlags",void 0);var mw;let tO=mw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,mw.prototype)}};tO=mw=f([Q({type:J.Sequence,itemType:pf})],tO);class Ce{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof Ce&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&n6(e.parameters,this.parameters)||e.parameters===this.parameters)}}f([w({type:D.ObjectIdentifier})],Ce.prototype,"algorithm",void 0);f([w({type:D.Any,optional:!0})],Ce.prototype,"parameters",void 0);class us{constructor(e={}){this.algorithm=new Ce,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:Ce})],us.prototype,"algorithm",void 0);f([w({type:D.BitString})],us.prototype,"subjectPublicKey",void 0);let kr=class{constructor(r){if(r)if(typeof r=="string"||typeof r=="number"||r instanceof Date){const e=new Date(r);e.getUTCFullYear()>2049?this.generalTime=e:this.utcTime=e}else Object.assign(this,r)}getTime(){const r=this.utcTime||this.generalTime;if(!r)throw new Error("Cannot get time from CHOICE object");return r}};f([w({type:D.UTCTime})],kr.prototype,"utcTime",void 0);f([w({type:D.GeneralizedTime})],kr.prototype,"generalTime",void 0);kr=f([Q({type:J.Choice})],kr);class ff{constructor(e){this.notBefore=new kr(new Date),this.notAfter=new kr(new Date),e&&(this.notBefore=new kr(e.notBefore),this.notAfter=new kr(e.notAfter))}}f([w({type:kr})],ff.prototype,"notBefore",void 0);f([w({type:kr})],ff.prototype,"notAfter",void 0);var yw;let Ln=class vI{constructor(e={}){this.extnID="",this.critical=vI.CRITICAL,this.extnValue=new Ht,Object.assign(this,e)}};Ln.CRITICAL=!1;f([w({type:D.ObjectIdentifier})],Ln.prototype,"extnID",void 0);f([w({type:D.Boolean,defaultValue:Ln.CRITICAL})],Ln.prototype,"critical",void 0);f([w({type:Ht})],Ln.prototype,"extnValue",void 0);let qa=yw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,yw.prototype)}};qa=yw=f([Q({type:J.Sequence,itemType:Ln})],qa);var hc;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(hc||(hc={}));class Cn{constructor(e={}){this.version=hc.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new Ce,this.issuer=new fr,this.validity=new ff,this.subject=new fr,this.subjectPublicKeyInfo=new us,Object.assign(this,e)}}f([w({type:D.Integer,context:0,defaultValue:hc.v1})],Cn.prototype,"version",void 0);f([w({type:D.Integer,converter:Xt})],Cn.prototype,"serialNumber",void 0);f([w({type:Ce})],Cn.prototype,"signature",void 0);f([w({type:fr})],Cn.prototype,"issuer",void 0);f([w({type:ff})],Cn.prototype,"validity",void 0);f([w({type:fr})],Cn.prototype,"subject",void 0);f([w({type:us})],Cn.prototype,"subjectPublicKeyInfo",void 0);f([w({type:D.BitString,context:1,implicit:!0,optional:!0})],Cn.prototype,"issuerUniqueID",void 0);f([w({type:D.BitString,context:2,implicit:!0,optional:!0})],Cn.prototype,"subjectUniqueID",void 0);f([w({type:qa,context:3,optional:!0})],Cn.prototype,"extensions",void 0);class pc{constructor(e={}){this.tbsCertificate=new Cn,this.signatureAlgorithm=new Ce,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:Cn})],pc.prototype,"tbsCertificate",void 0);f([w({type:Ce})],pc.prototype,"signatureAlgorithm",void 0);f([w({type:D.BitString})],pc.prototype,"signatureValue",void 0);class o0{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new kr,Object.assign(this,e)}}f([w({type:D.Integer,converter:Xt})],o0.prototype,"userCertificate",void 0);f([w({type:kr})],o0.prototype,"revocationDate",void 0);f([w({type:Ln,optional:!0,repeated:"sequence"})],o0.prototype,"crlEntryExtensions",void 0);class Wi{constructor(e={}){this.signature=new Ce,this.issuer=new fr,this.thisUpdate=new kr,Object.assign(this,e)}}f([w({type:D.Integer,optional:!0})],Wi.prototype,"version",void 0);f([w({type:Ce})],Wi.prototype,"signature",void 0);f([w({type:fr})],Wi.prototype,"issuer",void 0);f([w({type:kr})],Wi.prototype,"thisUpdate",void 0);f([w({type:kr,optional:!0})],Wi.prototype,"nextUpdate",void 0);f([w({type:o0,repeated:"sequence",optional:!0})],Wi.prototype,"revokedCertificates",void 0);f([w({type:Ln,optional:!0,context:0,repeated:"sequence"})],Wi.prototype,"crlExtensions",void 0);class Uk{constructor(e={}){this.tbsCertList=new Wi,this.signatureAlgorithm=new Ce,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:Wi})],Uk.prototype,"tbsCertList",void 0);f([w({type:Ce})],Uk.prototype,"signatureAlgorithm",void 0);f([w({type:D.BitString})],Uk.prototype,"signature",void 0);class _l{constructor(e={}){this.issuer=new fr,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:fr})],_l.prototype,"issuer",void 0);f([w({type:D.Integer,converter:Xt})],_l.prototype,"serialNumber",void 0);let zu=class{constructor(r={}){Object.assign(this,r)}};f([w({type:Sa,context:0,implicit:!0})],zu.prototype,"subjectKeyIdentifier",void 0);f([w({type:_l})],zu.prototype,"issuerAndSerialNumber",void 0);zu=f([Q({type:J.Choice})],zu);var Di;(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"})(Di||(Di={}));let dp=class extends Ce{};dp=f([Q({type:J.Sequence})],dp);let ug=class extends Ce{};ug=f([Q({type:J.Sequence})],ug);let ei=class extends Ce{};ei=f([Q({type:J.Sequence})],ei);let lg=class extends Ce{};lg=f([Q({type:J.Sequence})],lg);let rO=class extends Ce{};rO=f([Q({type:J.Sequence})],rO);let gw=class extends Ce{};gw=f([Q({type:J.Sequence})],gw);let wl=class{constructor(r={}){this.attrType="",this.attrValues=[],Object.assign(this,r)}};f([w({type:D.ObjectIdentifier})],wl.prototype,"attrType",void 0);f([w({type:D.Any,repeated:"set"})],wl.prototype,"attrValues",void 0);var vw;class oi{constructor(e={}){this.version=Di.v0,this.sid=new zu,this.digestAlgorithm=new dp,this.signatureAlgorithm=new ug,this.signature=new Ht,Object.assign(this,e)}}f([w({type:D.Integer})],oi.prototype,"version",void 0);f([w({type:zu})],oi.prototype,"sid",void 0);f([w({type:dp})],oi.prototype,"digestAlgorithm",void 0);f([w({type:wl,repeated:"set",context:0,implicit:!0,optional:!0})],oi.prototype,"signedAttrs",void 0);f([w({type:ug})],oi.prototype,"signatureAlgorithm",void 0);f([w({type:Ht})],oi.prototype,"signature",void 0);f([w({type:wl,repeated:"set",context:1,implicit:!0,optional:!0})],oi.prototype,"unsignedAttrs",void 0);let dg=vw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,vw.prototype)}};dg=vw=f([Q({type:J.Set,itemType:oi})],dg);let nO=class extends kr{};nO=f([Q({type:J.Choice})],nO);let sO=class extends oi{};sO=f([Q({type:J.Sequence})],sO);class Vk{constructor(e={}){this.acIssuer=new ht,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}f([w({type:ht})],Vk.prototype,"acIssuer",void 0);f([w({type:D.Integer})],Vk.prototype,"acSerial",void 0);f([w({type:Zi,repeated:"sequence"})],Vk.prototype,"attrs",void 0);var bw;let hg=bw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,bw.prototype)}};hg=bw=f([Q({type:J.Sequence,itemType:D.ObjectIdentifier})],hg);class c0{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}f([w({type:D.Integer,optional:!0})],c0.prototype,"pathLenConstraint",void 0);f([w({type:hg,implicit:!0,context:0,optional:!0})],c0.prototype,"permittedAttrs",void 0);f([w({type:hg,implicit:!0,context:1,optional:!0})],c0.prototype,"excludedAttrs",void 0);f([w({type:D.Boolean,defaultValue:!0})],c0.prototype,"permitUnSpecified",void 0);class jc{constructor(e={}){this.issuer=new Ur,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:Ur})],jc.prototype,"issuer",void 0);f([w({type:D.Integer,converter:Xt})],jc.prototype,"serial",void 0);f([w({type:D.BitString,optional:!0})],jc.prototype,"issuerUID",void 0);var _w;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(_w||(_w={}));class Cc{constructor(e={}){this.digestedObjectType=_w.publicKey,this.digestAlgorithm=new Ce,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.Enumerated})],Cc.prototype,"digestedObjectType",void 0);f([w({type:D.ObjectIdentifier,optional:!0})],Cc.prototype,"otherObjectTypeID",void 0);f([w({type:Ce})],Cc.prototype,"digestAlgorithm",void 0);f([w({type:D.BitString})],Cc.prototype,"objectDigest",void 0);class u0{constructor(e={}){Object.assign(this,e)}}f([w({type:Ur,optional:!0})],u0.prototype,"issuerName",void 0);f([w({type:jc,context:0,implicit:!0,optional:!0})],u0.prototype,"baseCertificateID",void 0);f([w({type:Cc,context:1,implicit:!0,optional:!0})],u0.prototype,"objectDigestInfo",void 0);let Wu=class{constructor(r={}){Object.assign(this,r)}};f([w({type:ht,repeated:"sequence"})],Wu.prototype,"v1Form",void 0);f([w({type:u0,context:0,implicit:!0})],Wu.prototype,"v2Form",void 0);Wu=f([Q({type:J.Choice})],Wu);class l0{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}f([w({type:D.GeneralizedTime})],l0.prototype,"notBeforeTime",void 0);f([w({type:D.GeneralizedTime})],l0.prototype,"notAfterTime",void 0);class mf{constructor(e={}){Object.assign(this,e)}}f([w({type:jc,implicit:!0,context:0,optional:!0})],mf.prototype,"baseCertificateID",void 0);f([w({type:Ur,implicit:!0,context:1,optional:!0})],mf.prototype,"entityName",void 0);f([w({type:Cc,implicit:!0,context:2,optional:!0})],mf.prototype,"objectDigestInfo",void 0);var ww;(function(r){r[r.v2=1]="v2"})(ww||(ww={}));class Cs{constructor(e={}){this.version=ww.v2,this.holder=new mf,this.issuer=new Wu,this.signature=new Ce,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new l0,this.attributes=[],Object.assign(this,e)}}f([w({type:D.Integer})],Cs.prototype,"version",void 0);f([w({type:mf})],Cs.prototype,"holder",void 0);f([w({type:Wu})],Cs.prototype,"issuer",void 0);f([w({type:Ce})],Cs.prototype,"signature",void 0);f([w({type:D.Integer,converter:Xt})],Cs.prototype,"serialNumber",void 0);f([w({type:l0})],Cs.prototype,"attrCertValidityPeriod",void 0);f([w({type:Zi,repeated:"sequence"})],Cs.prototype,"attributes",void 0);f([w({type:D.BitString,optional:!0})],Cs.prototype,"issuerUniqueID",void 0);f([w({type:qa,optional:!0})],Cs.prototype,"extensions",void 0);class d0{constructor(e={}){this.acinfo=new Cs,this.signatureAlgorithm=new Ce,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:Cs})],d0.prototype,"acinfo",void 0);f([w({type:Ce})],d0.prototype,"signatureAlgorithm",void 0);f([w({type:D.BitString})],d0.prototype,"signatureValue",void 0);var pg;(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"})(pg||(pg={}));class xw extends r0{}class Lk{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier,implicit:!0,context:0})],Lk.prototype,"type",void 0);f([w({type:D.Any,implicit:!0,context:1})],Lk.prototype,"value",void 0);class qk{constructor(e={}){this.policyId="",this.classList=new xw(pg.unclassified),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],qk.prototype,"policyId",void 0);f([w({type:xw,defaultValue:new xw(pg.unclassified)})],qk.prototype,"classList",void 0);f([w({type:Lk,repeated:"set"})],qk.prototype,"securityCategories",void 0);class h0{constructor(e={}){Object.assign(this,e)}}f([w({type:Ht})],h0.prototype,"cotets",void 0);f([w({type:D.ObjectIdentifier})],h0.prototype,"oid",void 0);f([w({type:D.Utf8String})],h0.prototype,"string",void 0);class bI{constructor(e={}){this.values=[],Object.assign(this,e)}}f([w({type:Ur,implicit:!0,context:0,optional:!0})],bI.prototype,"policyAuthority",void 0);f([w({type:h0,repeated:"sequence"})],bI.prototype,"values",void 0);var kw;class p0{constructor(e={}){this.targetCertificate=new jc,Object.assign(this,e)}}f([w({type:jc})],p0.prototype,"targetCertificate",void 0);f([w({type:ht,optional:!0})],p0.prototype,"targetName",void 0);f([w({type:Cc,optional:!0})],p0.prototype,"certDigestInfo",void 0);let Gu=class{constructor(r={}){Object.assign(this,r)}};f([w({type:ht,context:0,implicit:!0})],Gu.prototype,"targetName",void 0);f([w({type:ht,context:1,implicit:!0})],Gu.prototype,"targetGroup",void 0);f([w({type:p0,context:2,implicit:!0})],Gu.prototype,"targetCert",void 0);Gu=f([Q({type:J.Choice})],Gu);let Sw=kw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,kw.prototype)}};Sw=kw=f([Q({type:J.Sequence,itemType:Gu})],Sw);var Aw;let iO=Aw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Aw.prototype)}};iO=Aw=f([Q({type:J.Sequence,itemType:Sw})],iO);class _I{constructor(e={}){Object.assign(this,e)}}f([w({type:Ur,implicit:!0,context:0,optional:!0})],_I.prototype,"roleAuthority",void 0);f([w({type:ht,implicit:!0,context:1})],_I.prototype,"roleName",void 0);class Hk{constructor(e={}){this.service=new ht,this.ident=new ht,Object.assign(this,e)}}f([w({type:ht})],Hk.prototype,"service",void 0);f([w({type:ht})],Hk.prototype,"ident",void 0);f([w({type:Ht,optional:!0})],Hk.prototype,"authInfo",void 0);var Ow;class Fk{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],Fk.prototype,"otherCertFormat",void 0);f([w({type:D.Any})],Fk.prototype,"otherCert",void 0);let Ju=class{constructor(r={}){Object.assign(this,r)}};f([w({type:pc})],Ju.prototype,"certificate",void 0);f([w({type:d0,context:2,implicit:!0})],Ju.prototype,"v2AttrCert",void 0);f([w({type:Fk,context:3,implicit:!0})],Ju.prototype,"other",void 0);Ju=f([Q({type:J.Choice})],Ju);let fg=Ow=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Ow.prototype)}};fg=Ow=f([Q({type:J.Set,itemType:Ju})],fg);class xl{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],xl.prototype,"contentType",void 0);f([w({type:D.Any,context:0})],xl.prototype,"content",void 0);let hp=class{constructor(r={}){Object.assign(this,r)}};f([w({type:Ht})],hp.prototype,"single",void 0);f([w({type:D.Any})],hp.prototype,"any",void 0);hp=f([Q({type:J.Choice})],hp);class f0{constructor(e={}){this.eContentType="",Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],f0.prototype,"eContentType",void 0);f([w({type:hp,context:0,optional:!0})],f0.prototype,"eContent",void 0);let pp=class{constructor(r={}){Object.assign(this,r)}};f([w({type:Ht,context:0,implicit:!0,optional:!0})],pp.prototype,"value",void 0);f([w({type:Ht,converter:gM,context:0,implicit:!0,optional:!0,repeated:"sequence"})],pp.prototype,"constructedValue",void 0);pp=f([Q({type:J.Choice})],pp);class yf{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new lg,Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],yf.prototype,"contentType",void 0);f([w({type:lg})],yf.prototype,"contentEncryptionAlgorithm",void 0);f([w({type:pp,optional:!0})],yf.prototype,"encryptedContent",void 0);class m0{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],m0.prototype,"keyAttrId",void 0);f([w({type:D.Any,optional:!0})],m0.prototype,"keyAttr",void 0);var jw;class y0{constructor(e={}){this.subjectKeyIdentifier=new Sa,Object.assign(this,e)}}f([w({type:Sa})],y0.prototype,"subjectKeyIdentifier",void 0);f([w({type:D.GeneralizedTime,optional:!0})],y0.prototype,"date",void 0);f([w({type:m0,optional:!0})],y0.prototype,"other",void 0);let Yu=class{constructor(r={}){Object.assign(this,r)}};f([w({type:y0,context:0,implicit:!0,optional:!0})],Yu.prototype,"rKeyId",void 0);f([w({type:_l,optional:!0})],Yu.prototype,"issuerAndSerialNumber",void 0);Yu=f([Q({type:J.Choice})],Yu);class Kk{constructor(e={}){this.rid=new Yu,this.encryptedKey=new Ht,Object.assign(this,e)}}f([w({type:Yu})],Kk.prototype,"rid",void 0);f([w({type:Ht})],Kk.prototype,"encryptedKey",void 0);let mg=jw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,jw.prototype)}};mg=jw=f([Q({type:J.Sequence,itemType:Kk})],mg);class zk{constructor(e={}){this.algorithm=new Ce,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:Ce})],zk.prototype,"algorithm",void 0);f([w({type:D.BitString})],zk.prototype,"publicKey",void 0);let fc=class{constructor(r={}){Object.assign(this,r)}};f([w({type:Sa,context:0,implicit:!0,optional:!0})],fc.prototype,"subjectKeyIdentifier",void 0);f([w({type:zk,context:1,implicit:!0,optional:!0})],fc.prototype,"originatorKey",void 0);f([w({type:_l,optional:!0})],fc.prototype,"issuerAndSerialNumber",void 0);fc=f([Q({type:J.Choice})],fc);class kl{constructor(e={}){this.version=Di.v3,this.originator=new fc,this.keyEncryptionAlgorithm=new ei,this.recipientEncryptedKeys=new mg,Object.assign(this,e)}}f([w({type:D.Integer})],kl.prototype,"version",void 0);f([w({type:fc,context:0})],kl.prototype,"originator",void 0);f([w({type:Ht,context:1,optional:!0})],kl.prototype,"ukm",void 0);f([w({type:ei})],kl.prototype,"keyEncryptionAlgorithm",void 0);f([w({type:mg})],kl.prototype,"recipientEncryptedKeys",void 0);let Xu=class{constructor(r={}){Object.assign(this,r)}};f([w({type:Sa,context:0,implicit:!0})],Xu.prototype,"subjectKeyIdentifier",void 0);f([w({type:_l})],Xu.prototype,"issuerAndSerialNumber",void 0);Xu=f([Q({type:J.Choice})],Xu);class gf{constructor(e={}){this.version=Di.v0,this.rid=new Xu,this.keyEncryptionAlgorithm=new ei,this.encryptedKey=new Ht,Object.assign(this,e)}}f([w({type:D.Integer})],gf.prototype,"version",void 0);f([w({type:Xu})],gf.prototype,"rid",void 0);f([w({type:ei})],gf.prototype,"keyEncryptionAlgorithm",void 0);f([w({type:Ht})],gf.prototype,"encryptedKey",void 0);class vf{constructor(e={}){this.keyIdentifier=new Ht,Object.assign(this,e)}}f([w({type:Ht})],vf.prototype,"keyIdentifier",void 0);f([w({type:D.GeneralizedTime,optional:!0})],vf.prototype,"date",void 0);f([w({type:m0,optional:!0})],vf.prototype,"other",void 0);class bf{constructor(e={}){this.version=Di.v4,this.kekid=new vf,this.keyEncryptionAlgorithm=new ei,this.encryptedKey=new Ht,Object.assign(this,e)}}f([w({type:D.Integer})],bf.prototype,"version",void 0);f([w({type:vf})],bf.prototype,"kekid",void 0);f([w({type:ei})],bf.prototype,"keyEncryptionAlgorithm",void 0);f([w({type:Ht})],bf.prototype,"encryptedKey",void 0);class _f{constructor(e={}){this.version=Di.v0,this.keyEncryptionAlgorithm=new ei,this.encryptedKey=new Ht,Object.assign(this,e)}}f([w({type:D.Integer})],_f.prototype,"version",void 0);f([w({type:gw,context:0,optional:!0})],_f.prototype,"keyDerivationAlgorithm",void 0);f([w({type:ei})],_f.prototype,"keyEncryptionAlgorithm",void 0);f([w({type:Ht})],_f.prototype,"encryptedKey",void 0);class Wk{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],Wk.prototype,"oriType",void 0);f([w({type:D.Any})],Wk.prototype,"oriValue",void 0);let Ha=class{constructor(r={}){Object.assign(this,r)}};f([w({type:gf,optional:!0})],Ha.prototype,"ktri",void 0);f([w({type:kl,context:1,implicit:!0,optional:!0})],Ha.prototype,"kari",void 0);f([w({type:bf,context:2,implicit:!0,optional:!0})],Ha.prototype,"kekri",void 0);f([w({type:_f,context:3,implicit:!0,optional:!0})],Ha.prototype,"pwri",void 0);f([w({type:Wk,context:4,implicit:!0,optional:!0})],Ha.prototype,"ori",void 0);Ha=f([Q({type:J.Choice})],Ha);var Cw;let yg=Cw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Cw.prototype)}};yg=Cw=f([Q({type:J.Set,itemType:Ha})],yg);var Ew;class g0{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],g0.prototype,"otherRevInfoFormat",void 0);f([w({type:D.Any})],g0.prototype,"otherRevInfo",void 0);let gg=class{constructor(r={}){this.other=new g0,Object.assign(this,r)}};f([w({type:g0,context:1,implicit:!0})],gg.prototype,"other",void 0);gg=f([Q({type:J.Choice})],gg);let vg=Ew=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Ew.prototype)}};vg=Ew=f([Q({type:J.Set,itemType:gg})],vg);class Gk{constructor(e={}){Object.assign(this,e)}}f([w({type:fg,context:0,implicit:!0,optional:!0})],Gk.prototype,"certs",void 0);f([w({type:vg,context:1,implicit:!0,optional:!0})],Gk.prototype,"crls",void 0);var Iw;let Tw=Iw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Iw.prototype)}};Tw=Iw=f([Q({type:J.Set,itemType:wl})],Tw);class wf{constructor(e={}){this.version=Di.v0,this.recipientInfos=new yg,this.encryptedContentInfo=new yf,Object.assign(this,e)}}f([w({type:D.Integer})],wf.prototype,"version",void 0);f([w({type:Gk,context:0,implicit:!0,optional:!0})],wf.prototype,"originatorInfo",void 0);f([w({type:yg})],wf.prototype,"recipientInfos",void 0);f([w({type:yf})],wf.prototype,"encryptedContentInfo",void 0);f([w({type:Tw,context:1,implicit:!0,optional:!0})],wf.prototype,"unprotectedAttrs",void 0);const qM="1.2.840.113549.1.7.2";var Nw;let bg=Nw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Nw.prototype)}};bg=Nw=f([Q({type:J.Set,itemType:dp})],bg);class Sl{constructor(e={}){this.version=Di.v0,this.digestAlgorithms=new bg,this.encapContentInfo=new f0,this.signerInfos=new dg,Object.assign(this,e)}}f([w({type:D.Integer})],Sl.prototype,"version",void 0);f([w({type:bg})],Sl.prototype,"digestAlgorithms",void 0);f([w({type:f0})],Sl.prototype,"encapContentInfo",void 0);f([w({type:fg,context:0,implicit:!0,optional:!0})],Sl.prototype,"certificates",void 0);f([w({type:vg,context:1,implicit:!0,optional:!0})],Sl.prototype,"crls",void 0);f([w({type:dg})],Sl.prototype,"signerInfos",void 0);const fp="1.2.840.10045.2.1",Jk="1.2.840.10045.4.1",wI="1.2.840.10045.4.3.1",Yk="1.2.840.10045.4.3.2",Xk="1.2.840.10045.4.3.3",Qk="1.2.840.10045.4.3.4",aO="1.2.840.10045.3.1.7",oO="1.3.132.0.34",cO="1.3.132.0.35";function xf(r){return new Ce({algorithm:r})}const HM=xf(Jk);xf(wI);const FM=xf(Yk),KM=xf(Xk),zM=xf(Qk);let mp=class{constructor(r={}){Object.assign(this,r)}};f([w({type:D.ObjectIdentifier})],mp.prototype,"fieldType",void 0);f([w({type:D.Any})],mp.prototype,"parameters",void 0);mp=f([Q({type:J.Sequence})],mp);class WM extends Ht{}let Qu=class{constructor(r={}){Object.assign(this,r)}};f([w({type:D.OctetString})],Qu.prototype,"a",void 0);f([w({type:D.OctetString})],Qu.prototype,"b",void 0);f([w({type:D.BitString,optional:!0})],Qu.prototype,"seed",void 0);Qu=f([Q({type:J.Sequence})],Qu);var Bw;(function(r){r[r.ecpVer1=1]="ecpVer1"})(Bw||(Bw={}));let Mi=class{constructor(r={}){this.version=Bw.ecpVer1,Object.assign(this,r)}};f([w({type:D.Integer})],Mi.prototype,"version",void 0);f([w({type:mp})],Mi.prototype,"fieldID",void 0);f([w({type:Qu})],Mi.prototype,"curve",void 0);f([w({type:WM})],Mi.prototype,"base",void 0);f([w({type:D.Integer,converter:Xt})],Mi.prototype,"order",void 0);f([w({type:D.Integer,optional:!0})],Mi.prototype,"cofactor",void 0);Mi=f([Q({type:J.Sequence})],Mi);let Fa=class{constructor(r={}){Object.assign(this,r)}};f([w({type:D.ObjectIdentifier})],Fa.prototype,"namedCurve",void 0);f([w({type:D.Null})],Fa.prototype,"implicitCurve",void 0);f([w({type:Mi})],Fa.prototype,"specifiedCurve",void 0);Fa=f([Q({type:J.Choice})],Fa);class v0{constructor(e={}){this.version=1,this.privateKey=new Ht,Object.assign(this,e)}}f([w({type:D.Integer})],v0.prototype,"version",void 0);f([w({type:Ht})],v0.prototype,"privateKey",void 0);f([w({type:Fa,context:0,optional:!0})],v0.prototype,"parameters",void 0);f([w({type:D.BitString,context:1,optional:!0})],v0.prototype,"publicKey",void 0);class _g{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.Integer,converter:Xt})],_g.prototype,"r",void 0);f([w({type:D.Integer,converter:Xt})],_g.prototype,"s",void 0);const hn="1.2.840.113549.1.1",mc=`${hn}.1`,GM=`${hn}.7`,JM=`${hn}.9`,Ed=`${hn}.10`,YM=`${hn}.2`,XM=`${hn}.4`,wg=`${hn}.5`,QM=`${hn}.14`,Rw=`${hn}.11`,xg=`${hn}.12`,kg=`${hn}.13`,xI=`${hn}.15`,kI=`${hn}.16`,Sg="1.3.14.3.2.26",SI="2.16.840.1.101.3.4.2.4",Ag="2.16.840.1.101.3.4.2.1",Og="2.16.840.1.101.3.4.2.2",jg="2.16.840.1.101.3.4.2.3",eU="2.16.840.1.101.3.4.2.5",tU="2.16.840.1.101.3.4.2.6",rU="1.2.840.113549.2.2",nU="1.2.840.113549.2.5",b0=`${hn}.8`;function br(r){return new Ce({algorithm:r,parameters:null})}br(rU);br(nU);const yc=br(Sg);br(SI);br(Ag);br(Og);br(jg);br(eU);br(tU);const AI=new Ce({algorithm:b0,parameters:ce.serialize(yc)}),OI=new Ce({algorithm:JM,parameters:ce.serialize(rg.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});br(mc);br(YM);br(XM);br(wg);br(xI);br(kI);br(xg);br(kg);br(xI);br(kI);class _0{constructor(e={}){this.hashAlgorithm=new Ce(yc),this.maskGenAlgorithm=new Ce({algorithm:b0,parameters:ce.serialize(yc)}),this.pSourceAlgorithm=new Ce(OI),Object.assign(this,e)}}f([w({type:Ce,context:0,defaultValue:yc})],_0.prototype,"hashAlgorithm",void 0);f([w({type:Ce,context:1,defaultValue:AI})],_0.prototype,"maskGenAlgorithm",void 0);f([w({type:Ce,context:2,defaultValue:OI})],_0.prototype,"pSourceAlgorithm",void 0);new Ce({algorithm:GM,parameters:ce.serialize(new _0)});class gc{constructor(e={}){this.hashAlgorithm=new Ce(yc),this.maskGenAlgorithm=new Ce({algorithm:b0,parameters:ce.serialize(yc)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}f([w({type:Ce,context:0,defaultValue:yc})],gc.prototype,"hashAlgorithm",void 0);f([w({type:Ce,context:1,defaultValue:AI})],gc.prototype,"maskGenAlgorithm",void 0);f([w({type:D.Integer,context:2,defaultValue:20})],gc.prototype,"saltLength",void 0);f([w({type:D.Integer,context:3,defaultValue:1})],gc.prototype,"trailerField",void 0);new Ce({algorithm:Ed,parameters:ce.serialize(new gc)});class w0{constructor(e={}){this.digestAlgorithm=new Ce,this.digest=new Ht,Object.assign(this,e)}}f([w({type:Ce})],w0.prototype,"digestAlgorithm",void 0);f([w({type:Ht})],w0.prototype,"digest",void 0);var Pw;class x0{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.Integer,converter:Xt})],x0.prototype,"prime",void 0);f([w({type:D.Integer,converter:Xt})],x0.prototype,"exponent",void 0);f([w({type:D.Integer,converter:Xt})],x0.prototype,"coefficient",void 0);let $w=Pw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Pw.prototype)}};$w=Pw=f([Q({type:J.Sequence,itemType:x0})],$w);class ci{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)}}f([w({type:D.Integer})],ci.prototype,"version",void 0);f([w({type:D.Integer,converter:Xt})],ci.prototype,"modulus",void 0);f([w({type:D.Integer,converter:Xt})],ci.prototype,"publicExponent",void 0);f([w({type:D.Integer,converter:Xt})],ci.prototype,"privateExponent",void 0);f([w({type:D.Integer,converter:Xt})],ci.prototype,"prime1",void 0);f([w({type:D.Integer,converter:Xt})],ci.prototype,"prime2",void 0);f([w({type:D.Integer,converter:Xt})],ci.prototype,"exponent1",void 0);f([w({type:D.Integer,converter:Xt})],ci.prototype,"exponent2",void 0);f([w({type:D.Integer,converter:Xt})],ci.prototype,"coefficient",void 0);f([w({type:$w,optional:!0})],ci.prototype,"otherPrimeInfos",void 0);class e2{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.Integer,converter:Xt})],e2.prototype,"modulus",void 0);f([w({type:D.Integer,converter:Xt})],e2.prototype,"publicExponent",void 0);var Zw;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Zw||(Zw={}));const Yr=Zw;/*! *****************************************************************************
204
- Copyright (c) Microsoft Corporation.
205
-
206
- Permission to use, copy, modify, and/or distribute this software for any
207
- purpose with or without fee is hereby granted.
208
-
209
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
210
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
211
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
212
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
213
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
214
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
215
- PERFORMANCE OF THIS SOFTWARE.
216
- ***************************************************************************** */var Dw=function(r,e){return Dw=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])},Dw(r,e)};function t2(r,e){Dw(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function sU(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(l){try{u(n.next(l))}catch(h){a(h)}}function c(l){try{u(n.throw(l))}catch(h){a(h)}}function u(l){l.done?i(l.value):s(l.value).then(o,c)}u((n=n.apply(r,[])).next())})}function iU(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(l){return c([u,l])}}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(l){u=[6,l],s=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Hf(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 Cg(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 vo(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Cg(arguments[e]));return r}var aU="injectionTokens";function oU(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(aU,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function jI(r){return!!r.useClass}function Mw(r){return!!r.useFactory}var CI=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,vo(i))}};return this.reflectMethods.forEach(n),t},r}();function qc(r){return typeof r=="string"||typeof r=="symbol"}function cU(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function uO(r){return typeof r=="object"&&"token"in r&&"transform"in r}function uU(r){return typeof r=="function"||r instanceof CI}function lm(r){return!!r.useToken}function dm(r){return r.useValue!=null}function lU(r){return jI(r)||dm(r)||lm(r)||Mw(r)}var r2=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}(),dU=function(r){t2(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(r2),lO=function(){function r(){this.scopedResolutions=new Map}return r}();function hU(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function pU(r,e,t){return t===void 0&&(t=" "),vo([r],e.message.split(`
217
- `).map(function(n){return t+n})).join(`
218
- `)}function fU(r,e,t){var n=Cg(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],i=s===void 0?null:s,a=hU(i,e);return pU("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function mU(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var yU=function(r){t2(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(r2),gU=function(r){t2(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(r2),vU=function(){function r(){this.preResolution=new yU,this.postResolution=new gU}return r}(),EI=new Map,bU=function(){function r(e){this.parent=e,this._registry=new dU,this.interceptors=new vU,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:Yr.Transient}),this.ensureNotDisposed();var s;if(lU(t)?s=t:s={useClass:t},lm(s))for(var i=[e],a=s;a!=null;){var o=a.useToken;if(i.includes(o))throw new Error("Token registration cycle detected! "+vo(i,[o]).join(" -> "));i.push(o);var c=this._registry.get(o);c&&lm(c.provider)?a=c.provider:a=null}if((n.lifecycle===Yr.Singleton||n.lifecycle==Yr.ContainerScoped||n.lifecycle==Yr.ResolutionScoped)&&(dm(s)||Mw(s)))throw new Error('Cannot use lifecycle "'+Yr[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(),qc(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(),qc(e)){if(qc(t))return this.register(e,{useToken:t},{lifecycle:Yr.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Yr.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!qc(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:Yr.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new lO),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&qc(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(uU(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=Hf(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=Hf(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(l){s={error:l}}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===Yr.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===Yr.Singleton,s=e.options.lifecycle===Yr.ContainerScoped,i=n||s,a;return dm(e.provider)?a=e.provider.useValue:lm(e.provider)?a=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):jI(e.provider)?a=i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Mw(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===Yr.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new lO),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&qc(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=Hf(this._registry.entries()),s=n.next();!s.done;s=n.next()){var i=Cg(s.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(c){return!dm(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=Hf(this._registry.entries()),i=s.next();!i.done;i=s.next()){var a=Cg(i.value,2),o=a[0],c=a[1];c.some(function(u){var l=u.options;return l.lifecycle===Yr.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===Yr.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 sU(this,void 0,void 0,function(){var e;return iU(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 CI)return e.createProxy(function(i){return n.resolve(i,t)});var s=function(){var i=EI.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,vo([void 0],a)))}();return mU(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 cU(s)?uO(s)?s.multiple?(a=n.resolve(s.transform)).transform.apply(a,vo([n.resolveAll(s.token)],s.transformArgs)):(o=n.resolve(s.transform)).transform.apply(o,vo([n.resolve(s.token,e)],s.transformArgs)):s.multiple?n.resolveAll(s.token):n.resolve(s.token,e):uO(s)?(c=n.resolve(s.transform,e)).transform.apply(c,vo([n.resolve(s.token,e)],s.transformArgs)):n.resolve(s,e)}catch(u){throw new Error(fU(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}(),Ir=new bU;function k0(){return function(r){EI.set(r,oU(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 Uw;class S0{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}f([w({type:D.ObjectIdentifier})],S0.prototype,"attrId",void 0);f([w({type:D.Any,repeated:"set"})],S0.prototype,"attrValues",void 0);let dO=Uw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Uw.prototype)}};dO=Uw=f([Q({type:J.Sequence,itemType:S0})],dO);var Vw;let hO=Vw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Vw.prototype)}};hO=Vw=f([Q({type:J.Sequence,itemType:xl})],hO);class II{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],II.prototype,"certId",void 0);f([w({type:D.Any,context:0})],II.prototype,"certValue",void 0);class TI{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],TI.prototype,"crlId",void 0);f([w({type:D.Any,context:0})],TI.prototype,"crltValue",void 0);class NI extends Ht{}let A0=class{constructor(r={}){this.encryptionAlgorithm=new Ce,this.encryptedData=new NI,Object.assign(this,r)}};f([w({type:Ce})],A0.prototype,"encryptionAlgorithm",void 0);f([w({type:NI})],A0.prototype,"encryptedData",void 0);var Lw,qw;(function(r){r[r.v1=0]="v1"})(qw||(qw={}));class BI extends Ht{}let Hw=Lw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Lw.prototype)}};Hw=Lw=f([Q({type:J.Sequence,itemType:Zi})],Hw);class kf{constructor(e={}){this.version=qw.v1,this.privateKeyAlgorithm=new Ce,this.privateKey=new BI,Object.assign(this,e)}}f([w({type:D.Integer})],kf.prototype,"version",void 0);f([w({type:Ce})],kf.prototype,"privateKeyAlgorithm",void 0);f([w({type:BI})],kf.prototype,"privateKey",void 0);f([w({type:Hw,implicit:!0,context:0,optional:!0})],kf.prototype,"attributes",void 0);let pO=class extends kf{};pO=f([Q({type:J.Sequence})],pO);let fO=class extends A0{};fO=f([Q({type:J.Sequence})],fO);class RI{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],RI.prototype,"secretTypeId",void 0);f([w({type:D.Any,context:0})],RI.prototype,"secretValue",void 0);class Sf{constructor(e={}){this.mac=new w0,this.macSalt=new Ht,this.iterations=1,Object.assign(this,e)}}f([w({type:w0})],Sf.prototype,"mac",void 0);f([w({type:Ht})],Sf.prototype,"macSalt",void 0);f([w({type:D.Integer,defaultValue:1})],Sf.prototype,"iterations",void 0);class O0{constructor(e={}){this.version=3,this.authSafe=new xl,this.macData=new Sf,Object.assign(this,e)}}f([w({type:D.Integer})],O0.prototype,"version",void 0);f([w({type:xl})],O0.prototype,"authSafe",void 0);f([w({type:Sf,optional:!0})],O0.prototype,"macData",void 0);var Fw;class j0{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:D.ObjectIdentifier})],j0.prototype,"bagId",void 0);f([w({type:D.Any,context:0})],j0.prototype,"bagValue",void 0);f([w({type:S0,repeated:"set",optional:!0})],j0.prototype,"bagAttributes",void 0);let mO=Fw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Fw.prototype)}};mO=Fw=f([Q({type:J.Sequence,itemType:j0})],mO);var Kw,zw,Ww;const PI="1.2.840.113549.1.9",$I=`${PI}.7`,n2=`${PI}.14`;let Eg=class extends Er{constructor(r={}){super(r)}toString(){return this.ia5String||super.toString()}};f([w({type:D.IA5String})],Eg.prototype,"ia5String",void 0);Eg=f([Q({type:J.Choice})],Eg);let yO=class extends xl{};yO=f([Q({type:J.Sequence})],yO);let gO=class extends O0{};gO=f([Q({type:J.Sequence})],gO);let vO=class extends A0{};vO=f([Q({type:J.Sequence})],vO);let Gw=class{constructor(r=""){this.value=r}toString(){return this.value}};f([w({type:D.IA5String})],Gw.prototype,"value",void 0);Gw=f([Q({type:J.Choice})],Gw);let bO=class extends Eg{};bO=f([Q({type:J.Choice})],bO);let _O=class extends Er{};_O=f([Q({type:J.Choice})],_O);let Jw=class{constructor(r=new Date){this.value=r}};f([w({type:D.GeneralizedTime})],Jw.prototype,"value",void 0);Jw=f([Q({type:J.Choice})],Jw);let wO=class extends Er{};wO=f([Q({type:J.Choice})],wO);let Yw=class{constructor(r="M"){this.value=r}toString(){return this.value}};f([w({type:D.PrintableString})],Yw.prototype,"value",void 0);Yw=f([Q({type:J.Choice})],Yw);let Ig=class{constructor(r=""){this.value=r}toString(){return this.value}};f([w({type:D.PrintableString})],Ig.prototype,"value",void 0);Ig=f([Q({type:J.Choice})],Ig);let xO=class extends Ig{};xO=f([Q({type:J.Choice})],xO);let kO=class extends Er{};kO=f([Q({type:J.Choice})],kO);let Xw=class{constructor(r=""){this.value=r}toString(){return this.value}};f([w({type:D.ObjectIdentifier})],Xw.prototype,"value",void 0);Xw=f([Q({type:J.Choice})],Xw);let SO=class extends kr{};SO=f([Q({type:J.Choice})],SO);let Qw=class{constructor(r=0){this.value=r}toString(){return this.value.toString()}};f([w({type:D.Integer})],Qw.prototype,"value",void 0);Qw=f([Q({type:J.Choice})],Qw);let AO=class extends oi{};AO=f([Q({type:J.Sequence})],AO);let Tg=class extends Er{};Tg=f([Q({type:J.Choice})],Tg);let OO=Kw=class extends qa{constructor(r){super(r),Object.setPrototypeOf(this,Kw.prototype)}};OO=Kw=f([Q({type:J.Sequence})],OO);let jO=zw=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,zw.prototype)}};jO=zw=f([Q({type:J.Set,itemType:wl})],jO);let ex=class{constructor(r=""){this.value=r}toString(){return this.value}};f([w({type:D.BmpString})],ex.prototype,"value",void 0);ex=f([Q({type:J.Choice})],ex);let tx=class extends Ce{};tx=f([Q({type:J.Sequence})],tx);let CO=Ww=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,Ww.prototype)}};CO=Ww=f([Q({type:J.Sequence,itemType:tx})],CO);var rx;let Ng=rx=class extends Wt{constructor(r){super(r),Object.setPrototypeOf(this,rx.prototype)}};Ng=rx=f([Q({type:J.Sequence,itemType:Zi})],Ng);class Al{constructor(e={}){this.version=0,this.subject=new fr,this.subjectPKInfo=new us,this.attributes=new Ng,Object.assign(this,e)}}f([w({type:D.Integer})],Al.prototype,"version",void 0);f([w({type:fr})],Al.prototype,"subject",void 0);f([w({type:us})],Al.prototype,"subjectPKInfo",void 0);f([w({type:Ng,implicit:!0,context:0})],Al.prototype,"attributes",void 0);class yp{constructor(e={}){this.certificationRequestInfo=new Al,this.signatureAlgorithm=new Ce,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([w({type:Al})],yp.prototype,"certificationRequestInfo",void 0);f([w({type:Ce})],yp.prototype,"signatureAlgorithm",void 0);f([w({type:D.BitString})],yp.prototype,"signature",void 0);/*!
219
- * MIT License
220
- *
221
- * Copyright (c) Peculiar Ventures. All rights reserved.
222
- *
223
- * Permission is hereby granted, free of charge, to any person obtaining a copy
224
- * of this software and associated documentation files (the "Software"), to deal
225
- * in the Software without restriction, including without limitation the rights
226
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
227
- * copies of the Software, and to permit persons to whom the Software is
228
- * furnished to do so, subject to the following conditions:
229
- *
230
- * The above copyright notice and this permission notice shall be included in all
231
- * copies or substantial portions of the Software.
232
- *
233
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
234
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
235
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
236
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
237
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
238
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
239
- * SOFTWARE.
240
- *
241
- */const Af="crypto.algorithm";class _U{getAlgorithms(){return Ir.resolveAll(Af)}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 Ce({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 t of this.getAlgorithms()){const n=t.toWebAlgorithm(e);if(n)return n}return{name:e.algorithm,parameters:e.parameters}}}const vc="crypto.algorithmProvider";Ir.registerSingleton(vc,_U);var hm;const pn="1.3.36.3.3.2.8.1.1",EO=`${pn}.1`,IO=`${pn}.2`,TO=`${pn}.3`,NO=`${pn}.4`,BO=`${pn}.5`,RO=`${pn}.6`,PO=`${pn}.7`,$O=`${pn}.8`,ZO=`${pn}.9`,DO=`${pn}.10`,MO=`${pn}.11`,UO=`${pn}.12`,VO=`${pn}.13`,LO=`${pn}.14`,qO="brainpoolP160r1",HO="brainpoolP160t1",FO="brainpoolP192r1",KO="brainpoolP192t1",zO="brainpoolP224r1",WO="brainpoolP224t1",GO="brainpoolP256r1",JO="brainpoolP256t1",YO="brainpoolP320r1",XO="brainpoolP320t1",QO="brainpoolP384r1",e4="brainpoolP384t1",t4="brainpoolP512r1",r4="brainpoolP512t1",ir="ECDSA";let gp=hm=class{toAsnAlgorithm(r){switch(r.name.toLowerCase()){case ir.toLowerCase():if("hash"in r)switch((typeof r.hash=="string"?r.hash:r.hash.name).toLowerCase()){case"sha-1":return HM;case"sha-256":return FM;case"sha-384":return KM;case"sha-512":return zM}else if("namedCurve"in r){let e="";switch(r.namedCurve){case"P-256":e=aO;break;case"K-256":e=hm.SECP256K1;break;case"P-384":e=oO;break;case"P-521":e=cO;break;case qO:e=EO;break;case HO:e=IO;break;case FO:e=TO;break;case KO:e=NO;break;case zO:e=BO;break;case WO:e=RO;break;case GO:e=PO;break;case JO:e=$O;break;case YO:e=ZO;break;case XO:e=DO;break;case QO:e=MO;break;case e4:e=UO;break;case t4:e=VO;break;case r4:e=LO;break}if(e)return new Ce({algorithm:fp,parameters:ce.serialize(new Fa({namedCurve:e}))})}}return null}toWebAlgorithm(r){switch(r.algorithm){case Jk:return{name:ir,hash:{name:"SHA-1"}};case Yk:return{name:ir,hash:{name:"SHA-256"}};case Xk:return{name:ir,hash:{name:"SHA-384"}};case Qk:return{name:ir,hash:{name:"SHA-512"}};case fp:{if(!r.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(ce.parse(r.parameters,Fa).namedCurve){case aO:return{name:ir,namedCurve:"P-256"};case hm.SECP256K1:return{name:ir,namedCurve:"K-256"};case oO:return{name:ir,namedCurve:"P-384"};case cO:return{name:ir,namedCurve:"P-521"};case EO:return{name:ir,namedCurve:qO};case IO:return{name:ir,namedCurve:HO};case TO:return{name:ir,namedCurve:FO};case NO:return{name:ir,namedCurve:KO};case BO:return{name:ir,namedCurve:zO};case RO:return{name:ir,namedCurve:WO};case PO:return{name:ir,namedCurve:GO};case $O:return{name:ir,namedCurve:JO};case ZO:return{name:ir,namedCurve:YO};case DO:return{name:ir,namedCurve:XO};case MO:return{name:ir,namedCurve:QO};case UO:return{name:ir,namedCurve:e4};case VO:return{name:ir,namedCurve:t4};case LO:return{name:ir,namedCurve:r4}}}}return null}};gp.SECP256K1="1.3.132.0.10";gp=hm=f([k0()],gp);Ir.registerSingleton(Af,gp);const ZI=Symbol("name"),DI=Symbol("value");class Kt{constructor(e,t={},n=""){this[ZI]=e,this[DI]=n;for(const s in t)this[s]=t[s]}}Kt.NAME=ZI;Kt.VALUE=DI;class wU{static toTextObject(e){const t=new Kt("Algorithm Identifier",{},to.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case fp:{const n=new gp().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class to{static toString(e){return this.items[e]||e}}to.items={[Sg]:"sha1",[SI]:"sha224",[Ag]:"sha256",[Og]:"sha384",[jg]:"sha512",[mc]:"rsaEncryption",[wg]:"sha1WithRSAEncryption",[QM]:"sha224WithRSAEncryption",[Rw]:"sha256WithRSAEncryption",[xg]:"sha384WithRSAEncryption",[kg]:"sha512WithRSAEncryption",[fp]:"ecPublicKey",[Jk]:"ecdsaWithSHA1",[wI]:"ecdsaWithSHA224",[Yk]:"ecdsaWithSHA256",[Xk]:"ecdsaWithSHA384",[Qk]:"ecdsaWithSHA512",[ZM]:"TLS WWW server authentication",[DM]:"TLS WWW client authentication",[MM]:"Code Signing",[UM]:"E-mail Protection",[VM]:"Time Stamping",[LM]:"OCSP Signing",[qM]:"Signed Data"};class bc{static serialize(e){return this.serializeObj(e).join(`
242
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let s=this.pad(t++),i="";const a=e[Kt.VALUE];a&&(i=` ${a}`),n.push(`${s}${e[Kt.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 l of c)l[Kt.NAME]=o,n.push(...this.serializeObj(l,t));else if(c instanceof Kt)c[Kt.NAME]=o,n.push(...this.serializeObj(c,t));else if(de.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 l=c.toTextObject();l[Kt.NAME]=o,n.push(...this.serializeObj(l,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=de.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)}}bc.oidSerializer=to;bc.algorithmSerializer=wU;class ro{constructor(...e){if(e.length===1){const t=e[0];this.rawData=ce.serialize(t),this.onInit(t)}else{const t=ce.parse(e[0],e[1]);this.rawData=de.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof ro?n6(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return ce.toString(this.rawData);case"text":return bc.serialize(this.toTextObject());case"hex":return Be.ToHex(this.rawData);case"base64":return Be.ToBase64(this.rawData);case"base64url":return Be.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 Kt(this.getTextName(),{},e)}}ro.NAME="ASN";class zn extends ro{constructor(...e){let t;de.isBufferSource(e[0])?t=de.toArrayBuffer(e[0]):t=ce.serialize(new Ln({extnID:e[0],critical:e[1],extnValue:new Ht(de.toArrayBuffer(e[2]))})),super(t,Ln)}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[Kt.NAME]===zn.NAME&&(e[Kt.NAME]=to.toString(this.type)),e}}var MI;class ba{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[MI]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(ba.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(ba.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=ba.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(ba.DEFAULT,e);return this}}MI=Symbol.toStringTag;ba.DEFAULT="default";const wr=new ba,xU=/^[0-2](?:\.[1-9][0-9]*)+$/;function kU(r){return new RegExp(xU).test(r)}class UI{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return kU(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const un=new UI;un.register("CN","2.5.4.3");un.register("L","2.5.4.7");un.register("ST","2.5.4.8");un.register("O","2.5.4.10");un.register("OU","2.5.4.11");un.register("C","2.5.4.6");un.register("DC","0.9.2342.19200300.100.1.25");un.register("E","1.2.840.113549.1.9.1");un.register("G","2.5.4.42");un.register("I","2.5.4.43");un.register("SN","2.5.4.4");un.register("T","2.5.4.12");function SU(r,e){return`\\${Be.ToHex(Be.FromUtf8String(e)).toUpperCase()}`}function AU(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,SU)}class Zn{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 UI,this.asn=new fr;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 fr?this.asn=e:de.isBufferSource(e)?this.asn=ce.parse(e,fr):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||un.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)||un.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,s=t.value.anyValue?`#${Be.ToHex(t.value.anyValue)}`:AU(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?`#${Be.ToHex(i.value.anyValue)}`:i.value.toString())}t.push(s)}return t}fromString(e){const t=new fr,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 l=this.createAttribute(a,o);i==="+"?t[t.length-1].push(l):t.push(new Ku([l])),i=u}return t}fromJSON(e){const t=new fr;for(const n of e){const s=new Ku;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 n0({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=Be.FromHex(t.slice(1));else{const s=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=s:Zn.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,`
243
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return ce.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]||wr.get()):n=e[0]||wr.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const VI="Cannot initialize GeneralName from ASN.1 data.",n4=`${VI} Unsupported string format in use.`,OU=`${VI} Value doesn't match to GUID regular expression.`,s4=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,i4="1.3.6.1.4.1.311.25.1",a4="1.3.6.1.4.1.311.20.2.3",gb="dns",vb="dn",bb="email",_b="ip",wb="url",xb="guid",kb="upn",Ff="id";class _a extends ro{constructor(...e){let t;if(e.length===2)switch(e[0]){case vb:{const n=new Zn(e[1]).toArrayBuffer(),s=ce.parse(n,fr);t=new ht({directoryName:s});break}case gb:t=new ht({dNSName:e[1]});break;case bb:t=new ht({rfc822Name:e[1]});break;case xb:{const n=new RegExp(s4,"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?Be.ToHex(new Uint8Array(Be.FromHex(i)).reverse()):i).join("");t=new ht({otherName:new lp({typeId:i4,value:ce.serialize(new Ht(Be.FromHex(s)))})});break}case _b:t=new ht({iPAddress:e[1]});break;case Ff:t=new ht({registeredID:e[1]});break;case kb:{t=new ht({otherName:new lp({typeId:a4,value:ce.serialize(nI.toASN(e[1]))})});break}case wb:t=new ht({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else de.isBufferSource(e[0])?t=ce.parse(e[0],ht):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=gb,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=bb,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=_b,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=wb,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Ff,this.value=e.registeredID;else if(e.directoryName!=null)this.type=vb,this.value=new Zn(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===i4){this.type=xb;const t=ce.parse(e.otherName.value,Ht),n=new RegExp(s4,"i").exec(Be.ToHex(t));if(!n)throw new Error(OU);this.value=n.slice(1).map((s,i)=>i<3?Be.ToHex(new Uint8Array(Be.FromHex(s)).reverse()):s).join("-")}else if(e.otherName.typeId===a4)this.type=kb,this.value=ce.parse(e.otherName.value,Er).toString();else throw new Error(n4);else throw new Error(n4)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case vb:case gb:case xb:case _b:case Ff:case kb:case wb:e=this.type.toUpperCase();break;case bb:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===Ff&&(t=to.toString(t)),new Kt(e,void 0,t)}}class vp extends ro{constructor(e){let t;if(e instanceof Ur)t=e;else if(Array.isArray(e)){const n=[];for(const s of e)if(s instanceof ht)n.push(s);else{const i=ce.parse(new _a(s.type,s.value).rawData,ht);n.push(i)}t=new Ur(n)}else if(de.isBufferSource(e))t=ce.parse(e,Ur);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 _a(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[Kt.NAME]];Array.isArray(s)||(s=[],e[n[Kt.NAME]]=s),s.push(n)}return e}}vp.NAME="GeneralNames";const Id="-{5}",bp="\\n",jU=`[^${bp}]+`,CU=`${Id}BEGIN (${jU}(?=${Id}))${Id}`,EU=`${Id}END \\1${Id}`,el="\\n",IU=`[^:${bp}]+`,TU=`(?:[^${bp}]+${el}(?: +[^${bp}]+${el})*)`,NU="[a-zA-Z0-9=+/]+",BU=`(?:${NU}${el})+`,o4=`${CU}${el}(?:((?:${IU}: ${TU})+))?${el}?(${BU})${EU}`;class bn{static isPem(e){return typeof e=="string"&&new RegExp(o4,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(o4,"g"),n=[];let s=null;for(;s=t.exec(e);){const i=s[3].replace(new RegExp(`[${bp}]+`,"g"),""),a={type:s[1],headers:[],rawData:Be.FromBase64(i)},o=s[2];if(o){const c=o.split(new RegExp(el,"g"));let u=null;for(const l of c){const[h,R]=l.split(/:(.*)/);if(R===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=h.trim()}else u&&a.headers.push(u),u={key:h,value:R.trim()}}u&&a.headers.push(u)}n.push(a)}return n}static decode(e){return this.decodeWithHeaders(e).map(t=>t.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(!de.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:de.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(`
244
- `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:de.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=Be.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)&&(c.push(a),!(a.length<64)););return s.push(...c),s.push(`-----END ${n}-----`),s.join(`
245
- `)}}bn.CertificateTag="CERTIFICATE";bn.CrlTag="CRL";bn.CertificateRequestTag="CERTIFICATE REQUEST";bn.PublicKeyTag="PUBLIC KEY";bn.PrivateKeyTag="PRIVATE KEY";class Ui extends ro{static isAsnEncoded(e){return de.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(bn.isPem(e))return bn.decode(e)[0];if(Be.isHex(e))return Be.FromHex(e);if(Be.isBase64(e))return Be.FromBase64(e);if(Be.isBase64Url(e))return Be.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=Be.ToBinary(e);return bn.isPem(t)?bn.decode(t)[0]:Be.isHex(t)?Be.FromHex(t):Be.isBase64(t)?Be.FromBase64(t):Be.isBase64Url(t)?Be.FromBase64Url(t):de.toArrayBuffer(e)}}constructor(...e){Ui.isAsnEncoded(e[0])?super(Ui.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return bn.encode(this.rawData,this.tag);default:return super.toString(e)}}}class gs extends Ui{static async create(e,t=wr.get()){if(e instanceof gs)return e;if(ba.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new gs(n)}else{if(e.publicKey)return e.publicKey;if(de.isBufferSource(e))return new gs(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Ui.isAsnEncoded(e)?super(e,us):super(e),this.tag=bn.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]||wr.get()):t=e[0]||wr.get();let i=this.rawData;const a=ce.parse(this.rawData,us);return a.algorithm.algorithm===Ed&&(i=RU(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=Ir.resolve(vc),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case mc:{const s=ce.parse(e.subjectPublicKey,e2),i=de.toUint8Array(s.modulus);n.publicExponent=de.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]||wr.get()):n=e[0]||wr.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=wr.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=wr.get();const s=ce.parse(this.rawData,us);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=ce.parse(this.rawData,us);switch(e.Algorithm=bc.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case fp:e["EC Point"]=t.subjectPublicKey;break;case mc:default:e["Raw Data"]=t.subjectPublicKey}return e}}function RU(r,e){return r.algorithm=new Ce({algorithm:mc,parameters:null}),e=ce.serialize(r),e}class _p extends zn{static async create(e,t=!1,n=wr.get()){if("name"in e&&"serialNumber"in e)return new _p(e,t);const s=await(await gs.create(e,n)).getKeyIdentifier(n);return new _p(Be.ToHex(s),t)}constructor(...e){if(de.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Ao({keyIdentifier:new Pk(Be.FromHex(e[0]))});super(X_,e[1],ce.serialize(t))}else{const t=e[0],n=t.name instanceof vp?ce.parse(t.name.rawData,Ur):t.name,s=new Ao({authorityCertIssuer:n,authorityCertSerialNumber:Be.FromHex(t.serialNumber)});super(X_,e[1],ce.serialize(s))}}onInit(e){super.onInit(e);const t=ce.parse(e.extnValue,Ao);t.keyIdentifier&&(this.keyId=Be.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?Be.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=ce.parse(this.value,Ao);return t.authorityCertIssuer&&(e["Authority Issuer"]=new vp(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}_p.NAME="Authority Key Identifier";class s2 extends zn{constructor(...e){if(de.isBufferSource(e[0])){super(e[0]);const t=ce.parse(this.value,ng);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new ng({cA:e[0],pathLenConstraint:e[1]});super(aI,e[2],ce.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}}s2.NAME="Basic Constraints";var c4;(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"})(c4||(c4={}));class i2 extends zn{constructor(...e){if(de.isBufferSource(e[0])){super(e[0]);const t=ce.parse(this.value,og);this.usages=t.map(n=>n)}else{const t=new og(e[0]);super(uI,e[1],ce.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>to.toString(t)).join(", "),e}}i2.NAME="Extended Key Usages";var Bg;(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"})(Bg||(Bg={}));class a2 extends zn{constructor(...e){if(de.isBufferSource(e[0])){super(e[0]);const t=ce.parse(this.value,yb);this.usages=t.toNumber()}else{const t=new yb(e[0]);super(lI,e[1],ce.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=ce.parse(this.value,yb);return e[""]=t.toJSON().join(", "),e}}a2.NAME="Key Usages";class Of extends zn{static async create(e,t=!1,n=wr.get()){const s=await(await gs.create(e,n)).getKeyIdentifier(n);return new Of(Be.ToHex(s),t)}constructor(...e){if(de.isBufferSource(e[0])){super(e[0]);const t=ce.parse(this.value,Sa);this.keyId=Be.ToHex(t)}else{const t=typeof e[0]=="string"?Be.FromHex(e[0]):e[0],n=new Sa(t);super(fI,e[1],ce.serialize(n)),this.keyId=Be.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=ce.parse(this.value,Sa);return e[""]=t,e}}Of.NAME="Subject Key Identifier";class LI extends zn{constructor(...e){de.isBufferSource(e[0])?super(e[0]):super(pI,e[1],new vp(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=ce.parse(e.extnValue,pw);this.names=new vp(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}LI.NAME="Subject Alternative Name";class Wn{static register(e,t){this.items.set(e,t)}static create(e){const t=new zn(e),n=this.items.get(t.type);return n?new n(e):t}}Wn.items=new Map;class qI extends zn{constructor(...e){var t;if(de.isBufferSource(e[0])){super(e[0]);const n=ce.parse(this.value,ig);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new ig(n.map(a=>new i0({policyIdentifier:a})));super(oI,s,ce.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Kt("",{},to.toString(t))),e}}qI.NAME="Certificate Policies";Wn.register(oI,qI);class HI extends zn{constructor(...e){var t;if(de.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const n=e[0].map(i=>new bl({distributionPoint:new dc({fullName:[new ht({uniformResourceIdentifier:i})]})})),s=new lu(n);super(nw,e[1],ce.serialize(s))}else{const n=new lu(e[0]);super(nw,e[1],ce.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=ce.parse(e.extnValue,lu);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 _a(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}HI.NAME="CRL Distribution Points";class FI extends zn{constructor(...e){var t,n,s,i;if(de.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof tu){const a=new tu(e[0]);super(Y_,e[1],ce.serialize(a))}else{const a=e[0],o=new tu;zf(o,a,FA,"ocsp"),zf(o,a,KA,"caIssuers"),zf(o,a,zA,"timeStamping"),zf(o,a,WA,"caRepository"),super(Y_,e[1],ce.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=[],ce.parse(e.extnValue,tu).forEach(t=>{switch(t.accessMethod){case FA:this.ocsp.push(new _a(t.accessLocation));break;case KA:this.caIssuers.push(new _a(t.accessLocation));break;case zA:this.timeStamping.push(new _a(t.accessLocation));break;case WA:this.caRepository.push(new _a(t.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Kf(e,"OCSP",this.ocsp),this.caIssuers.length&&Kf(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Kf(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Kf(e,"CA Repository",this.caRepository),e}}FI.NAME="Authority Info Access";function Kf(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new Kt("");t.forEach((s,i)=>{const a=s.toTextObject(),o=`${a[Kt.NAME]} ${i+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function zf(r,e,t,n){const s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(i=>{typeof i=="string"&&(i=new _a("url",i)),r.push(new pf({accessMethod:t,accessLocation:ce.parse(i.rawData,ht)}))})}class Ol extends ro{constructor(...e){let t;if(de.isBufferSource(e[0]))t=de.toArrayBuffer(e[0]);else{const n=e[0],s=Array.isArray(e[1])?e[1].map(i=>de.toArrayBuffer(i)):[];t=ce.serialize(new Zi({type:n,values:s}))}super(t,Zi)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Kt("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[Kt.NAME]===Ol.NAME&&(e[Kt.NAME]=to.toString(this.type)),e}}Ol.NAME="Attribute";class KI extends Ol{constructor(...e){var t;if(de.isBufferSource(e[0]))super(e[0]);else{const n=new Tg({printableString:e[0]});super($I,[ce.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=ce.parse(this.values[0],Tg);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Kt.VALUE]=this.password,e}}KI.NAME="Challenge Password";class o2 extends Ol{constructor(...e){var t;if(de.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new qa;for(const i of n)s.push(ce.parse(i.rawData,Ln));super(n2,[ce.serialize(s)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=ce.parse(this.values[0],qa);this.items=t.map(n=>Wn.create(ce.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[Kt.NAME]]=n;return e}}o2.NAME="Extensions";class C0{static register(e,t){this.items.set(e,t)}static create(e){const t=new Ol(e),n=this.items.get(t.type);return n?new n(e):t}}C0.items=new Map;const jf="crypto.signatureFormatter";class PU{toAsnSignature(e,t){return de.toArrayBuffer(t)}toWebSignature(e,t){return de.toArrayBuffer(t)}}var pm;let nx=pm=class{static createPssParams(r,e){const t=pm.getHashAlgorithm(r);return t?new gc({hashAlgorithm:t,maskGenAlgorithm:new Ce({algorithm:b0,parameters:ce.serialize(t)}),saltLength:e}):null}static getHashAlgorithm(r){const e=Ir.resolve(vc);return typeof r=="string"?e.toAsnAlgorithm({name:r}):typeof r=="object"&&r&&"name"in r?e.toAsnAlgorithm(r):null}toAsnAlgorithm(r){switch(r.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in r){let e;if(typeof r.hash=="string")e=r.hash;else if(r.hash&&typeof r.hash=="object"&&"name"in r.hash&&typeof r.hash.name=="string")e=r.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(e.toLowerCase()){case"sha-1":return new Ce({algorithm:wg,parameters:null});case"sha-256":return new Ce({algorithm:Rw,parameters:null});case"sha-384":return new Ce({algorithm:xg,parameters:null});case"sha-512":return new Ce({algorithm:kg,parameters:null})}}else return new Ce({algorithm:mc,parameters:null});break;case"rsa-pss":if("hash"in r){if(!("saltLength"in r&&typeof r.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const e=pm.createPssParams(r.hash,r.saltLength);if(!e)throw new Error("Cannot create PSS parameters");return new Ce({algorithm:Ed,parameters:ce.serialize(e)})}else return new Ce({algorithm:Ed,parameters:null})}return null}toWebAlgorithm(r){switch(r.algorithm){case mc:return{name:"RSASSA-PKCS1-v1_5"};case wg:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Rw:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case xg:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case kg:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Ed:if(r.parameters){const e=ce.parse(r.parameters,gc);return{name:"RSA-PSS",hash:Ir.resolve(vc).toWebAlgorithm(e.hashAlgorithm),saltLength:e.saltLength}}else return{name:"RSA-PSS"}}return null}};nx=pm=f([k0()],nx);Ir.registerSingleton(Af,nx);let sx=class{toAsnAlgorithm(r){switch(r.name.toLowerCase()){case"sha-1":return new Ce({algorithm:Sg});case"sha-256":return new Ce({algorithm:Ag});case"sha-384":return new Ce({algorithm:Og});case"sha-512":return new Ce({algorithm:jg})}return null}toWebAlgorithm(r){switch(r.algorithm){case Sg:return{name:"SHA-1"};case Ag:return{name:"SHA-256"};case Og:return{name:"SHA-384"};case jg:return{name:"SHA-512"}}return null}};sx=f([k0()],sx);Ir.registerSingleton(Af,sx);class Dn{addPadding(e,t){const n=de.toUint8Array(t),s=new Uint8Array(e);return s.set(n,e-n.length),s}removePadding(e,t=!1){let n=de.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=Dn.namedCurveSize.get(n)||Dn.defaultNamedCurveSize,i=new _g,a=de.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),ce.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=ce.parse(t,_g),s=e.namedCurve,i=Dn.namedCurveSize.get(s)||Dn.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return WD(a,o)}return null}}Dn.namedCurveSize=new Map;Dn.defaultNamedCurveSize=32;const Sb="1.3.101.110",u4="1.3.101.111",Ab="1.3.101.112",l4="1.3.101.113";let ix=class{toAsnAlgorithm(r){let e=null;switch(r.name.toLowerCase()){case"ed25519":e=Ab;break;case"x25519":e=Sb;break;case"eddsa":switch(r.namedCurve.toLowerCase()){case"ed25519":e=Ab;break;case"ed448":e=l4;break}break;case"ecdh-es":switch(r.namedCurve.toLowerCase()){case"x25519":e=Sb;break;case"x448":e=u4;break}}return e?new Ce({algorithm:e}):null}toWebAlgorithm(r){switch(r.algorithm){case Ab:return{name:"Ed25519"};case l4:return{name:"EdDSA",namedCurve:"Ed448"};case Sb:return{name:"X25519"};case u4:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};ix=f([k0()],ix);Ir.registerSingleton(Af,ix);class $U extends Ui{constructor(e){Ui.isAsnEncoded(e)?super(e,yp):super(e),this.tag=bn.CertificateRequestTag}onInit(e){this.tbs=ce.serialize(e.certificationRequestInfo),this.publicKey=new gs(e.certificationRequestInfo.subjectPKInfo);const t=Ir.resolve(vc);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>C0.create(ce.serialize(s)));const n=this.getAttribute(n2);this.extensions=[],n instanceof o2&&(this.extensions=n.items),this.subjectName=new Zn(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=wr.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),s=Ir.resolveAll(jf).reverse();let i=null;for(const a of s)if(i=a.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=ce.parse(this.rawData,yp),n=t.certificationRequestInfo,s=new Kt("",{Version:`${hc[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new Kt("");for(const a of this.attributes){const o=a.toTextObject();i[o[Kt.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new Kt("",{Algorithm:bc.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}$U.NAME="PKCS#10 Certificate Request";class c2 extends Ui{constructor(e){Ui.isAsnEncoded(e)?super(e,pc):super(e),this.tag=bn.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=ce.serialize(t),this.serialNumber=Be.ToHex(t.serialNumber),this.subjectName=new Zn(t.subject),this.subject=new Zn(t.subject).toString(),this.issuerName=new Zn(t.issuer),this.issuer=this.issuerName.toString();const n=Ir.resolve(vc);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=>Wn.create(ce.serialize(a)))),this.publicKey=new gs(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=wr.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 gs)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(de.isBufferSource(i)){const u=new gs(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=Ir.resolveAll(jf).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 u=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<u&&u<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=wr.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=wr.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=ce.parse(this.rawData,pc),n=t.tbsCertificate,s=new Kt("",{Version:`${hc[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":bc.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Kt("",{"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 Kt("");for(const a of this.extensions){const o=a.toTextObject();i[o[Kt.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new Kt("",{Algorithm:bc.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}c2.NAME="Certificate";class ZU{static async createSelfSigned(e,t=wr.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=wr.get()){var n;let s;e.publicKey instanceof gs?s=e.publicKey.rawData:"publicKey"in e.publicKey?s=e.publicKey.publicKey.rawData:de.isBufferSource(e.publicKey)?s=e.publicKey:s=await t.subtle.exportKey("spki",e.publicKey);const i=e.serialNumber?de.toUint8Array(Be.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));i[0]>127&&(i[0]&=127),i.length>1&&i[0]===0&&(i[1]|=128);const a=e.notBefore||new Date,o=e.notAfter||new Date(a.getTime()+31536e6),c=new pc({tbsCertificate:new Cn({version:hc.v3,serialNumber:i,validity:new ff({notBefore:a,notAfter:o}),extensions:new qa(((n=e.extensions)===null||n===void 0?void 0:n.map(A=>ce.parse(A.rawData,Ln)))||[]),subjectPublicKeyInfo:ce.parse(s,us)})});if(e.subject){const A=e.subject instanceof Zn?e.subject:new Zn(e.subject);c.tbsCertificate.subject=ce.parse(A.toArrayBuffer(),fr)}if(e.issuer){const A=e.issuer instanceof Zn?e.issuer:new Zn(e.issuer);c.tbsCertificate.issuer=ce.parse(A.toArrayBuffer(),fr)}const u={hash:"SHA-256"},l="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},h=Ir.resolve(vc);c.tbsCertificate.signature=c.signatureAlgorithm=h.toAsnAlgorithm(l);const R=ce.serialize(c.tbsCertificate),B="signingKey"in e?await t.subtle.sign(l,e.signingKey,R):e.signature,d=Ir.resolveAll(jf).reverse();let g=null;for(const A of d)if(g=A.toAsnSignature(l,B),g)break;if(!g)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=g,new c2(ce.serialize(c))}}var d4;(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"})(d4||(d4={}));Wn.register(aI,s2);Wn.register(uI,i2);Wn.register(lI,a2);Wn.register(fI,Of);Wn.register(X_,_p);Wn.register(pI,LI);Wn.register(nw,HI);Wn.register(Y_,FI);C0.register($I,KI);C0.register(n2,o2);Ir.registerSingleton(jf,PU);Ir.registerSingleton(jf,Dn);Dn.namedCurveSize.set("P-256",32);Dn.namedCurveSize.set("K-256",32);Dn.namedCurveSize.set("P-384",48);Dn.namedCurveSize.set("P-521",66);const h4="0123456789abcdef";function ax(r){const e=new Uint8Array(r);let t="";for(let n=0;n<e.length;n++){const s=e[n]>>4;t+=h4[s];const i=e[n]&15;t+=h4[i]}return t}class zI{constructor(e,t){if($e(this,"alphabet"),$e(this,"padding"),$e(this,"decodeMap",new Map),e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",s=0,i=0;for(let a=0;a<e.length;a++)for(s=s<<8|e[a],i+=8;i>=5;)i-=5,n+=this.alphabet[s>>i&31];if(i>0&&(n+=this.alphabet[s<<5-i&31]),(t==null?void 0:t.includePadding)??!0){const a=(8-n.length%8)%8;for(let o=0;o<a;o++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,s=Math.ceil(e.length/8),i=[];for(let a=0;a<s;a++){let o=0;const c=[];for(let l=0;l<8;l++){const h=e[a*8+l];if(h==="="){if(a+1!==s)throw new Error(`Invalid character: ${h}`);o+=1;continue}if(h===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const R=this.decodeMap.get(h)??null;if(R===null)throw new Error(`Invalid character: ${h}`);c.push(R)}if(o===8||o===7||o===5||o===2)throw new Error("Invalid padding");const u=(c[0]<<3)+(c[1]>>2);if(i.push(u),o<6){const l=((c[1]&3)<<6)+(c[2]<<1)+(c[3]>>4);i.push(l)}if(o<4){const l=((c[3]&255)<<4)+(c[4]>>1);i.push(l)}if(o<3){const l=((c[4]&1)<<7)+(c[5]<<2)+(c[6]>>3);i.push(l)}if(o<1){const l=((c[6]&7)<<5)+c[7];i.push(l)}}return Uint8Array.from(i)}}new zI("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new zI("0123456789ABCDEFGHIJKLMNOPQRSTUV");class WI{constructor(e,t){if($e(this,"alphabet"),$e(this,"padding"),$e(this,"decodeMap",new Map),e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",s=0,i=0;for(let a=0;a<e.length;a++)for(s=s<<8|e[a],i+=8;i>=6;)i+=-6,n+=this.alphabet[s>>i&63];if(i>0&&(n+=this.alphabet[s<<6-i&63]),(t==null?void 0:t.includePadding)??!0){const a=(4-n.length%4)%4;for(let o=0;o<a;o++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,s=Math.ceil(e.length/4),i=[];for(let a=0;a<s;a++){let o=0,c=0;for(let u=0;u<4;u++){const l=e[a*4+u];if(l==="="){if(a+1!==s)throw new Error(`Invalid character: ${l}`);o+=1;continue}if(l===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const h=this.decodeMap.get(l)??null;if(h===null)throw new Error(`Invalid character: ${l}`);c+=h<<6*(3-u)}i.push(c>>16&255),o<2&&i.push(c>>8&255),o<1&&i.push(c&255)}return Uint8Array.from(i)}}const DU=new WI("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),fm=new WI("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class MU{constructor(e){$e(this,"hash"),this.hash=e}async verify(e,t,n){const s=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",s,t,n)}async sign(e,t){const n=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",n,t)}async generateKeyPair(e){const t=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),n=await crypto.subtle.exportKey("pkcs8",t.privateKey),s=await crypto.subtle.exportKey("spki",t.publicKey);return{privateKey:n,publicKey:s}}}async function GI(r){return await crypto.subtle.digest("SHA-256",r)}async function p4(r){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},t=await crypto.subtle.generateKey(e,!0,["sign","verify"]),n=Qy(),s=ax(new TextEncoder().encode(n)),i=await ZU.createSelfSigned({serialNumber:s,name:r.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:t,extensions:[new s2(!0,2,!0),new i2(["1.3.6.1.5.5.7.3.1"],!0),new a2(Bg.keyCertSign|Bg.cRLSign,!0),await Of.create(t.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",t.privateKey),o=i.toString("pem"),c=await VU(i),u=ax(await i.getThumbprint()),l=UU("PRIVATE",a);return{kid:i.serialNumber,cert:o,thumbprint:u,fingerprint:c,pkcs7:l}}function UU(r,e){const t=DU.encode(new Uint8Array(e));let n=`-----BEGIN ${r} KEY-----\r
246
- `,s=0;for(;s<t.length;)s+64<=t.length?n+=t.substr(s,64)+`\r
247
- `:n+=t.substr(s)+`\r
248
- `,s+=64;return n+=`-----END ${r} KEY-----\r
249
- `,n}async function VU(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),s=new TextEncoder().encode(n);return ax(await GI(s))}const LU=1e3*60*60*24;new On().openapi(ut({tags:["keys"],method:"get",path:"/signing",request:{headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:N.array(RA)}},description:"List of keys"}}}),async r=>{const e=(await r.env.data.keys.list()).filter(t=>"cert"in t).map(t=>t);return r.json(e)}).openapi(ut({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({kid:N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:RA}},description:"The requested key"}}}),async r=>{const{kid:e}=r.req.valid("param"),t=(await r.env.data.keys.list()).find(n=>n.kid===e);if(!t)throw new lt(404,{message:"Key not found"});return r.json(t)}).openapi(ut({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const e=await r.env.data.keys.list();for await(const n of e)await r.env.data.keys.update(n.kid,{revoked_at:new Date(Date.now()+LU).toISOString()});const t=await p4({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ut({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({kid:N.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const{kid:e}=r.req.valid("param");if(!await r.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new lt(404,{message:"Key not found"});const t=await p4({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK")});new On().openapi(ut({tags:["users"],method:"get",path:"/",request:{query:N.object({email:N.string()}),headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:N.array(WE)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),n=(await r6(r.env.data.users,e,t)).filter(s=>!s.linked_to);return r.json(n)});const qU=Ac.extend({clients:N.array(eu)});new On().openapi(ut({tags:["clients"],method:"get",path:"/",request:{query:oc,headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:N.union([qU,N.array(eu)])}},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"),o=(await r.env.data.applications.list(e,{page:t,per_page:n,include_totals:s,sort:yl(i),q:a})).applications;return s?r.json({clients:o,start:0,limit:10,length:o.length}):r.json(o)}).openapi(ut({tags:["clients"],method:"get",path:"/{id}",request:{params:N.object({id:N.string()}),headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:eu}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===t);if(!n)throw new lt(404);return r.json(n)}).openapi(ut({tags:["clients"],method:"delete",path:"/{id}",request:{params:N.object({id:N.string()}),headers:N.object({"tenant-id":N.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 lt(404,{message:"Application not found"});return r.text("OK")}).openapi(ut({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:N.object(Z_.shape).partial()}}},params:N.object({id:N.string()}),headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:eu}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=r.req.valid("json");await r.env.data.applications.update(e,t,n);const s=await r.env.data.applications.get(e,t);if(!s)throw new lt(404,{message:"Application not found"});return r.json(s)}).openapi(ut({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:N.object(Z_.shape)}}},headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:N.object(eu.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||Qy(),client_secret:t.client_secret||Qy()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var Lt;(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})(Lt||(Lt={}));var ox;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(ox||(ox={}));const Oe=Lt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),da=r=>{switch(typeof r){case"undefined":return Oe.undefined;case"string":return Oe.string;case"number":return isNaN(r)?Oe.nan:Oe.number;case"boolean":return Oe.boolean;case"function":return Oe.function;case"bigint":return Oe.bigint;case"symbol":return Oe.symbol;case"object":return Array.isArray(r)?Oe.array:r===null?Oe.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?Oe.promise:typeof Map<"u"&&r instanceof Map?Oe.map:typeof Set<"u"&&r instanceof Set?Oe.set:typeof Date<"u"&&r instanceof Date?Oe.date:Oe.object;default:return Oe.unknown}},ie=Lt.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"]),HU=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class kn 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 kn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Lt.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()}}kn.create=r=>new kn(r);const tl=(r,e)=>{let t;switch(r.code){case ie.invalid_type:r.received===Oe.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case ie.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Lt.jsonStringifyReplacer)}`;break;case ie.unrecognized_keys:t=`Unrecognized key(s) in object: ${Lt.joinValues(r.keys,", ")}`;break;case ie.invalid_union:t="Invalid input";break;case ie.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Lt.joinValues(r.options)}`;break;case ie.invalid_enum_value:t=`Invalid enum value. Expected ${Lt.joinValues(r.options)}, received '${r.received}'`;break;case ie.invalid_arguments:t="Invalid function arguments";break;case ie.invalid_return_type:t="Invalid function return type";break;case ie.invalid_date:t="Invalid date";break;case ie.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}"`:Lt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case ie.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 ie.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 ie.custom:t="Invalid input";break;case ie.invalid_intersection_types:t="Intersection results could not be merged";break;case ie.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case ie.not_finite:t="Number must be finite";break;default:t=e.defaultError,Lt.assertNever(r)}return{message:t}};let JI=tl;function FU(r){JI=r}function Rg(){return JI}const Pg=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}},KU=[];function _e(r,e){const t=Rg(),n=Pg({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===tl?void 0:tl].filter(s=>!!s)});r.common.issues.push(n)}class Pr{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 ot;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 Pr.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 ot;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 ot=Object.freeze({status:"aborted"}),$g=r=>({status:"dirty",value:r}),Kr=r=>({status:"valid",value:r}),cx=r=>r.status==="aborted",ux=r=>r.status==="dirty",wp=r=>r.status==="valid",xp=r=>typeof Promise<"u"&&r instanceof Promise;function Zg(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 YI(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 qe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(qe||(qe={}));var hd,pd;class ti{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 f4=(r,e)=>{if(wp(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 kn(r.common.issues);return this._error=t,this._error}}};function bt(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 Et{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 da(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:da(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Pr,ctx:{common:e.parent.common,data:e.data,parsedType:da(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(xp(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:da(e)},i=this._parseSync({data:e,path:s.path,parent:s});return f4(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:da(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(xp(s)?s:Promise.resolve(s));return f4(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:ie.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 Ss({schema:this,typeName:et.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Hs.create(this,this._def)}nullable(){return Ga.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return vs.create(this,this._def)}promise(){return nl.create(this,this._def)}or(e){return Op.create([this,e],this._def)}and(e){return jp.create(this,e,this._def)}transform(e){return new Ss({...bt(this._def),schema:this,typeName:et.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Np({...bt(this._def),innerType:this,defaultValue:t,typeName:et.ZodDefault})}brand(){return new u2({typeName:et.ZodBranded,type:this,...bt(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Bp({...bt(this._def),innerType:this,catchValue:t,typeName:et.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Cf.create(this,e)}readonly(){return Rp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const zU=/^c[^\s-]{8,}$/i,WU=/^[0-9a-z]+$/,GU=/^[0-9A-HJKMNP-TV-Z]{26}$/,JU=/^[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,YU=/^[a-z0-9_-]{21}$/i,XU=/^[-+]?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)?)??$/,QU=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,eV="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ob;const tV=/^(?:(?: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])$/,rV=/^(([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})))$/,nV=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,XI="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",sV=new RegExp(`^${XI}$`);function QI(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 iV(r){return new RegExp(`^${QI(r)}$`)}function e5(r){let e=`${XI}T${QI(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 aV(r,e){return!!((e==="v4"||!e)&&tV.test(r)||(e==="v6"||!e)&&rV.test(r))}class ls extends Et{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Oe.string){const s=this._getOrReturnCtx(e);return _e(s,{code:ie.invalid_type,expected:Oe.string,received:s.parsedType}),ot}const t=new Pr;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),_e(n,{code:ie.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),_e(n,{code:ie.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?_e(n,{code:ie.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&_e(n,{code:ie.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")QU.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"email",code:ie.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Ob||(Ob=new RegExp(eV,"u")),Ob.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"emoji",code:ie.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")JU.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"uuid",code:ie.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")YU.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"nanoid",code:ie.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")zU.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"cuid",code:ie.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")WU.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"cuid2",code:ie.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")GU.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"ulid",code:ie.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),_e(n,{validation:"url",code:ie.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),_e(n,{validation:"regex",code:ie.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),_e(n,{code:ie.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),_e(n,{code:ie.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),_e(n,{code:ie.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?e5(s).test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{code:ie.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?sV.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{code:ie.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?iV(s).test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{code:ie.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?XU.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"duration",code:ie.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?aV(e.data,s.version)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"ip",code:ie.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?nV.test(e.data)||(n=this._getOrReturnCtx(e,n),_e(n,{validation:"base64",code:ie.invalid_string,message:s.message}),t.dirty()):Lt.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:ie.invalid_string,...qe.errToObj(n)})}_addCheck(e){return new ls({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...qe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...qe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...qe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...qe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...qe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...qe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...qe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...qe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...qe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...qe.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,...qe.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,...qe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...qe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...qe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...qe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...qe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...qe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...qe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...qe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...qe.errToObj(t)})}nonempty(e){return this.min(1,qe.errToObj(e))}trim(){return new ls({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ls({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ls({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ls.create=r=>{var e;return new ls({checks:[],typeName:et.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...bt(r)})};function oV(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 Ka extends Et{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)!==Oe.number){const s=this._getOrReturnCtx(e);return _e(s,{code:ie.invalid_type,expected:Oe.number,received:s.parsedType}),ot}let t;const n=new Pr;for(const s of this._def.checks)s.kind==="int"?Lt.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),_e(t,{code:ie.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),_e(t,{code:ie.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),_e(t,{code:ie.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?oV(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),_e(t,{code:ie.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),_e(t,{code:ie.not_finite,message:s.message}),n.dirty()):Lt.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,qe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,qe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,qe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,qe.toString(t))}setLimit(e,t,n,s){return new Ka({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:qe.toString(s)}]})}_addCheck(e){return new Ka({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:qe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:qe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:qe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:qe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:qe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:qe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:qe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:qe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:qe.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"&&Lt.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)}}Ka.create=r=>new Ka({checks:[],typeName:et.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...bt(r)});class za extends Et{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)!==Oe.bigint){const s=this._getOrReturnCtx(e);return _e(s,{code:ie.invalid_type,expected:Oe.bigint,received:s.parsedType}),ot}let t;const n=new Pr;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),_e(t,{code:ie.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),_e(t,{code:ie.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),_e(t,{code:ie.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Lt.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,qe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,qe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,qe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,qe.toString(t))}setLimit(e,t,n,s){return new za({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:qe.toString(s)}]})}_addCheck(e){return new za({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:qe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:qe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:qe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:qe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:qe.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}}za.create=r=>{var e;return new za({checks:[],typeName:et.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...bt(r)})};class kp extends Et{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Oe.boolean){const t=this._getOrReturnCtx(e);return _e(t,{code:ie.invalid_type,expected:Oe.boolean,received:t.parsedType}),ot}return Kr(e.data)}}kp.create=r=>new kp({typeName:et.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...bt(r)});class _c extends Et{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Oe.date){const s=this._getOrReturnCtx(e);return _e(s,{code:ie.invalid_type,expected:Oe.date,received:s.parsedType}),ot}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return _e(s,{code:ie.invalid_date}),ot}const t=new Pr;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),_e(n,{code:ie.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),_e(n,{code:ie.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Lt.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new _c({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:qe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:qe.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}}_c.create=r=>new _c({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:et.ZodDate,...bt(r)});class Dg extends Et{_parse(e){if(this._getType(e)!==Oe.symbol){const t=this._getOrReturnCtx(e);return _e(t,{code:ie.invalid_type,expected:Oe.symbol,received:t.parsedType}),ot}return Kr(e.data)}}Dg.create=r=>new Dg({typeName:et.ZodSymbol,...bt(r)});class Sp extends Et{_parse(e){if(this._getType(e)!==Oe.undefined){const t=this._getOrReturnCtx(e);return _e(t,{code:ie.invalid_type,expected:Oe.undefined,received:t.parsedType}),ot}return Kr(e.data)}}Sp.create=r=>new Sp({typeName:et.ZodUndefined,...bt(r)});class Ap extends Et{_parse(e){if(this._getType(e)!==Oe.null){const t=this._getOrReturnCtx(e);return _e(t,{code:ie.invalid_type,expected:Oe.null,received:t.parsedType}),ot}return Kr(e.data)}}Ap.create=r=>new Ap({typeName:et.ZodNull,...bt(r)});class rl extends Et{constructor(){super(...arguments),this._any=!0}_parse(e){return Kr(e.data)}}rl.create=r=>new rl({typeName:et.ZodAny,...bt(r)});class Uo extends Et{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Kr(e.data)}}Uo.create=r=>new Uo({typeName:et.ZodUnknown,...bt(r)});class Vi extends Et{_parse(e){const t=this._getOrReturnCtx(e);return _e(t,{code:ie.invalid_type,expected:Oe.never,received:t.parsedType}),ot}}Vi.create=r=>new Vi({typeName:et.ZodNever,...bt(r)});class Mg extends Et{_parse(e){if(this._getType(e)!==Oe.undefined){const t=this._getOrReturnCtx(e);return _e(t,{code:ie.invalid_type,expected:Oe.void,received:t.parsedType}),ot}return Kr(e.data)}}Mg.create=r=>new Mg({typeName:et.ZodVoid,...bt(r)});class vs extends Et{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==Oe.array)return _e(t,{code:ie.invalid_type,expected:Oe.array,received:t.parsedType}),ot;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(_e(t,{code:a?ie.too_big:ie.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&&(_e(t,{code:ie.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&&(_e(t,{code:ie.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 ti(t,a,t.path,o)))).then(a=>Pr.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new ti(t,a,t.path,o)));return Pr.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new vs({...this._def,minLength:{value:e,message:qe.toString(t)}})}max(e,t){return new vs({...this._def,maxLength:{value:e,message:qe.toString(t)}})}length(e,t){return new vs({...this._def,exactLength:{value:e,message:qe.toString(t)}})}nonempty(e){return this.min(1,e)}}vs.create=(r,e)=>new vs({type:r,minLength:null,maxLength:null,exactLength:null,typeName:et.ZodArray,...bt(e)});function Gc(r){if(r instanceof lr){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Hs.create(Gc(n))}return new lr({...r._def,shape:()=>e})}else return r instanceof vs?new vs({...r._def,type:Gc(r.element)}):r instanceof Hs?Hs.create(Gc(r.unwrap())):r instanceof Ga?Ga.create(Gc(r.unwrap())):r instanceof ri?ri.create(r.items.map(e=>Gc(e))):r}class lr extends Et{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=Lt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Oe.object){const c=this._getOrReturnCtx(e);return _e(c,{code:ie.invalid_type,expected:Oe.object,received:c.parsedType}),ot}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Vi&&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],l=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new ti(n,l,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Vi){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&&(_e(n,{code:ie.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 l=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new ti(n,l,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of o){const l=await u.key,h=await u.value;c.push({key:l,value:h,alwaysSet:u.alwaysSet})}return c}).then(c=>Pr.mergeObjectSync(t,c)):Pr.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return qe.errToObj,new lr({...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=qe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new lr({...this._def,unknownKeys:"strip"})}passthrough(){return new lr({...this._def,unknownKeys:"passthrough"})}extend(e){return new lr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new lr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:et.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new lr({...this._def,catchall:e})}pick(e){const t={};return Lt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new lr({...this._def,shape:()=>t})}omit(e){const t={};return Lt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new lr({...this._def,shape:()=>t})}deepPartial(){return Gc(this)}partial(e){const t={};return Lt.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new lr({...this._def,shape:()=>t})}required(e){const t={};return Lt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Hs;)s=s._def.innerType;t[n]=s}}),new lr({...this._def,shape:()=>t})}keyof(){return t5(Lt.objectKeys(this.shape))}}lr.create=(r,e)=>new lr({shape:()=>r,unknownKeys:"strip",catchall:Vi.create(),typeName:et.ZodObject,...bt(e)});lr.strictCreate=(r,e)=>new lr({shape:()=>r,unknownKeys:"strict",catchall:Vi.create(),typeName:et.ZodObject,...bt(e)});lr.lazycreate=(r,e)=>new lr({shape:r,unknownKeys:"strip",catchall:Vi.create(),typeName:et.ZodObject,...bt(e)});class Op extends Et{_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 kn(o.ctx.common.issues));return _e(t,{code:ie.invalid_union,unionErrors:a}),ot}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},l=c._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,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 kn(c));return _e(t,{code:ie.invalid_union,unionErrors:o}),ot}}get options(){return this._def.options}}Op.create=(r,e)=>new Op({options:r,typeName:et.ZodUnion,...bt(e)});const na=r=>r instanceof Ep?na(r.schema):r instanceof Ss?na(r.innerType()):r instanceof Ip?[r.value]:r instanceof Wa?r.options:r instanceof Tp?Lt.objectValues(r.enum):r instanceof Np?na(r._def.innerType):r instanceof Sp?[void 0]:r instanceof Ap?[null]:r instanceof Hs?[void 0,...na(r.unwrap())]:r instanceof Ga?[null,...na(r.unwrap())]:r instanceof u2||r instanceof Rp?na(r.unwrap()):r instanceof Bp?na(r._def.innerType):[];class E0 extends Et{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Oe.object)return _e(t,{code:ie.invalid_type,expected:Oe.object,received:t.parsedType}),ot;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}):(_e(t,{code:ie.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ot)}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=na(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 E0({typeName:et.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...bt(n)})}}function lx(r,e){const t=da(r),n=da(e);if(r===e)return{valid:!0,data:r};if(t===Oe.object&&n===Oe.object){const s=Lt.objectKeys(e),i=Lt.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=lx(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===Oe.array&&n===Oe.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=lx(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===Oe.date&&n===Oe.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class jp extends Et{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(cx(i)||cx(a))return ot;const o=lx(i.value,a.value);return o.valid?((ux(i)||ux(a))&&t.dirty(),{status:t.value,value:o.data}):(_e(n,{code:ie.invalid_intersection_types}),ot)};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}))}}jp.create=(r,e,t)=>new jp({left:r,right:e,typeName:et.ZodIntersection,...bt(t)});class ri extends Et{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.array)return _e(n,{code:ie.invalid_type,expected:Oe.array,received:n.parsedType}),ot;if(n.data.length<this._def.items.length)return _e(n,{code:ie.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ot;!this._def.rest&&n.data.length>this._def.items.length&&(_e(n,{code:ie.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 ti(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>Pr.mergeArray(t,i)):Pr.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ri({...this._def,rest:e})}}ri.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ri({items:r,typeName:et.ZodTuple,rest:null,...bt(e)})};class Cp extends Et{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!==Oe.object)return _e(n,{code:ie.invalid_type,expected:Oe.object,received:n.parsedType}),ot;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new ti(n,o,n.path,o)),value:a._parse(new ti(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?Pr.mergeObjectAsync(t,s):Pr.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Et?new Cp({keyType:e,valueType:t,typeName:et.ZodRecord,...bt(n)}):new Cp({keyType:ls.create(),valueType:e,typeName:et.ZodRecord,...bt(t)})}}class Ug extends Et{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!==Oe.map)return _e(n,{code:ie.invalid_type,expected:Oe.map,received:n.parsedType}),ot;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new ti(n,o,n.path,[u,"key"])),value:i._parse(new ti(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,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return ot;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return ot;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}Ug.create=(r,e,t)=>new Ug({valueType:e,keyType:r,typeName:et.ZodMap,...bt(t)});class wc extends Et{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Oe.set)return _e(n,{code:ie.invalid_type,expected:Oe.set,received:n.parsedType}),ot;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(_e(n,{code:ie.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&&(_e(n,{code:ie.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 l of c){if(l.status==="aborted")return ot;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new ti(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new wc({...this._def,minSize:{value:e,message:qe.toString(t)}})}max(e,t){return new wc({...this._def,maxSize:{value:e,message:qe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}wc.create=(r,e)=>new wc({valueType:r,minSize:null,maxSize:null,typeName:et.ZodSet,...bt(e)});class du extends Et{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Oe.function)return _e(t,{code:ie.invalid_type,expected:Oe.function,received:t.parsedType}),ot;function n(o,c){return Pg({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rg(),tl].filter(u=>!!u),issueData:{code:ie.invalid_arguments,argumentsError:c}})}function s(o,c){return Pg({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rg(),tl].filter(u=>!!u),issueData:{code:ie.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof nl){const o=this;return Kr(async function(...c){const u=new kn([]),l=await o._def.args.parseAsync(c,i).catch(R=>{throw u.addIssue(n(c,R)),u}),h=await Reflect.apply(a,this,l);return await o._def.returns._def.type.parseAsync(h,i).catch(R=>{throw u.addIssue(s(h,R)),u})})}else{const o=this;return Kr(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new kn([n(c,u.error)]);const l=Reflect.apply(a,this,u.data),h=o._def.returns.safeParse(l,i);if(!h.success)throw new kn([s(l,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new du({...this._def,args:ri.create(e).rest(Uo.create())})}returns(e){return new du({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new du({args:e||ri.create([]).rest(Uo.create()),returns:t||Uo.create(),typeName:et.ZodFunction,...bt(n)})}}class Ep extends Et{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})}}Ep.create=(r,e)=>new Ep({getter:r,typeName:et.ZodLazy,...bt(e)});class Ip extends Et{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _e(t,{received:t.data,code:ie.invalid_literal,expected:this._def.value}),ot}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ip.create=(r,e)=>new Ip({value:r,typeName:et.ZodLiteral,...bt(e)});function t5(r,e){return new Wa({values:r,typeName:et.ZodEnum,...bt(e)})}class Wa extends Et{constructor(){super(...arguments),hd.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return _e(t,{expected:Lt.joinValues(n),received:t.parsedType,code:ie.invalid_type}),ot}if(Zg(this,hd)||YI(this,hd,new Set(this._def.values)),!Zg(this,hd).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return _e(t,{received:t.data,code:ie.invalid_enum_value,options:n}),ot}return Kr(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 Wa.create(e,{...this._def,...t})}exclude(e,t=this._def){return Wa.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}hd=new WeakMap;Wa.create=t5;class Tp extends Et{constructor(){super(...arguments),pd.set(this,void 0)}_parse(e){const t=Lt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Oe.string&&n.parsedType!==Oe.number){const s=Lt.objectValues(t);return _e(n,{expected:Lt.joinValues(s),received:n.parsedType,code:ie.invalid_type}),ot}if(Zg(this,pd)||YI(this,pd,new Set(Lt.getValidEnumValues(this._def.values))),!Zg(this,pd).has(e.data)){const s=Lt.objectValues(t);return _e(n,{received:n.data,code:ie.invalid_enum_value,options:s}),ot}return Kr(e.data)}get enum(){return this._def.values}}pd=new WeakMap;Tp.create=(r,e)=>new Tp({values:r,typeName:et.ZodNativeEnum,...bt(e)});class nl extends Et{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Oe.promise&&t.common.async===!1)return _e(t,{code:ie.invalid_type,expected:Oe.promise,received:t.parsedType}),ot;const n=t.parsedType===Oe.promise?t.data:Promise.resolve(t.data);return Kr(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}nl.create=(r,e)=>new nl({type:r,typeName:et.ZodPromise,...bt(e)});class Ss extends Et{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===et.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=>{_e(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 ot;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ot:c.status==="dirty"||t.value==="dirty"?$g(c.value):c});{if(t.value==="aborted")return ot;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ot:o.status==="dirty"||t.value==="dirty"?$g(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"?ot:(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"?ot:(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(!wp(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=>wp(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Lt.assertNever(s)}}Ss.create=(r,e,t)=>new Ss({schema:r,typeName:et.ZodEffects,effect:e,...bt(t)});Ss.createWithPreprocess=(r,e,t)=>new Ss({schema:e,effect:{type:"preprocess",transform:r},typeName:et.ZodEffects,...bt(t)});class Hs extends Et{_parse(e){return this._getType(e)===Oe.undefined?Kr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Hs.create=(r,e)=>new Hs({innerType:r,typeName:et.ZodOptional,...bt(e)});class Ga extends Et{_parse(e){return this._getType(e)===Oe.null?Kr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ga.create=(r,e)=>new Ga({innerType:r,typeName:et.ZodNullable,...bt(e)});class Np extends Et{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===Oe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Np.create=(r,e)=>new Np({innerType:r,typeName:et.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...bt(e)});class Bp extends Et{_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 xp(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kn(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new kn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Bp.create=(r,e)=>new Bp({innerType:r,typeName:et.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...bt(e)});class Vg extends Et{_parse(e){if(this._getType(e)!==Oe.nan){const t=this._getOrReturnCtx(e);return _e(t,{code:ie.invalid_type,expected:Oe.nan,received:t.parsedType}),ot}return{status:"valid",value:e.data}}}Vg.create=r=>new Vg({typeName:et.ZodNaN,...bt(r)});const cV=Symbol("zod_brand");class u2 extends Et{_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 Cf extends Et{_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"?ot:s.status==="dirty"?(t.dirty(),$g(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"?ot: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 Cf({in:e,out:t,typeName:et.ZodPipeline})}}class Rp extends Et{_parse(e){const t=this._def.innerType._parse(e),n=s=>(wp(s)&&(s.value=Object.freeze(s.value)),s);return xp(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Rp.create=(r,e)=>new Rp({innerType:r,typeName:et.ZodReadonly,...bt(e)});function r5(r,e={},t){return r?rl.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})}}):rl.create()}const uV={object:lr.lazycreate};var et;(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"})(et||(et={}));const lV=(r,e={message:`Input not instance of ${r.name}`})=>r5(t=>t instanceof r,e),n5=ls.create,s5=Ka.create,dV=Vg.create,hV=za.create,i5=kp.create,pV=_c.create,fV=Dg.create,mV=Sp.create,yV=Ap.create,gV=rl.create,vV=Uo.create,bV=Vi.create,_V=Mg.create,wV=vs.create,xV=lr.create,kV=lr.strictCreate,SV=Op.create,AV=E0.create,OV=jp.create,jV=ri.create,CV=Cp.create,EV=Ug.create,IV=wc.create,TV=du.create,NV=Ep.create,BV=Ip.create,RV=Wa.create,PV=Tp.create,$V=nl.create,m4=Ss.create,ZV=Hs.create,DV=Ga.create,MV=Ss.createWithPreprocess,UV=Cf.create,VV=()=>n5().optional(),LV=()=>s5().optional(),qV=()=>i5().optional(),HV={string:r=>ls.create({...r,coerce:!0}),number:r=>Ka.create({...r,coerce:!0}),boolean:r=>kp.create({...r,coerce:!0}),bigint:r=>za.create({...r,coerce:!0}),date:r=>_c.create({...r,coerce:!0})},FV=ot;var Nn=Object.freeze({__proto__:null,defaultErrorMap:tl,setErrorMap:FU,getErrorMap:Rg,makeIssue:Pg,EMPTY_PATH:KU,addIssueToContext:_e,ParseStatus:Pr,INVALID:ot,DIRTY:$g,OK:Kr,isAborted:cx,isDirty:ux,isValid:wp,isAsync:xp,get util(){return Lt},get objectUtil(){return ox},ZodParsedType:Oe,getParsedType:da,ZodType:Et,datetimeRegex:e5,ZodString:ls,ZodNumber:Ka,ZodBigInt:za,ZodBoolean:kp,ZodDate:_c,ZodSymbol:Dg,ZodUndefined:Sp,ZodNull:Ap,ZodAny:rl,ZodUnknown:Uo,ZodNever:Vi,ZodVoid:Mg,ZodArray:vs,ZodObject:lr,ZodUnion:Op,ZodDiscriminatedUnion:E0,ZodIntersection:jp,ZodTuple:ri,ZodRecord:Cp,ZodMap:Ug,ZodSet:wc,ZodFunction:du,ZodLazy:Ep,ZodLiteral:Ip,ZodEnum:Wa,ZodNativeEnum:Tp,ZodPromise:nl,ZodEffects:Ss,ZodTransformer:Ss,ZodOptional:Hs,ZodNullable:Ga,ZodDefault:Np,ZodCatch:Bp,ZodNaN:Vg,BRAND:cV,ZodBranded:u2,ZodPipeline:Cf,ZodReadonly:Rp,custom:r5,Schema:Et,ZodSchema:Et,late:uV,get ZodFirstPartyTypeKind(){return et},coerce:HV,any:gV,array:wV,bigint:hV,boolean:i5,date:pV,discriminatedUnion:AV,effect:m4,enum:RV,function:TV,instanceof:lV,intersection:OV,lazy:NV,literal:BV,map:EV,nan:dV,nativeEnum:PV,never:bV,null:yV,nullable:DV,number:s5,object:xV,oboolean:qV,onumber:LV,optional:ZV,ostring:VV,pipeline:UV,preprocess:MV,promise:$V,record:CV,set:IV,strictObject:kV,string:n5,symbol:fV,transformer:m4,tuple:jV,undefined:mV,union:SV,unknown:vV,void:_V,NEVER:FV,ZodIssueCode:ie,quotelessJson:HU,ZodError:kn});Nn.object({start:Nn.number(),limit:Nn.number(),length:Nn.number()});bk.extend({email:Nn.string(),login_count:Nn.number(),multifactor:Nn.array(Nn.string()).optional(),last_ip:Nn.string().optional(),last_login:Nn.string().optional(),user_id:Nn.string()}).catchall(Nn.any());const KV=Ac.extend({tenants:N.array(Od)});new On().openapi(ut({tags:["tenants"],method:"get",path:"/",request:{query:oc},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:N.union([N.array(Od),KV])}},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:yl(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(ut({tags:["tenants"],method:"get",path:"/{id}",request:{params:N.object({id:N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Od}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new lt(404);return r.json(t)}).openapi(ut({tags:["tenants"],method:"delete",path:"/{id}",request:{params:N.object({id:N.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(ut({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:N.object(M_.shape).partial()}}},params:N.object({id:N.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(ut({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:N.object(M_.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Od}},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})});const zV=Ac.extend({logs:N.array(V_)});new On().openapi(ut({tags:["logs"],method:"get",path:"/",request:{query:oc,headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:N.union([N.array(V_),zV])}},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:yl(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(ut({tags:["logs"],method:"get",path:"/{id}",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({id:N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:V_}},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 lt(404);return r.json(n)});const WV=Ac.extend({hooks:N.array(dd)});new On().openapi(ut({tags:["hooks"],method:"get",path:"/",request:{query:oc,headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:N.union([N.array(dd),WV])}},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:yl(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(ut({tags:["hooks"],method:"post",path:"/",request:{headers:N.object({"tenant-id":N.string()}),body:{content:{"application/json":{schema:N.object(U_.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:dd}},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(ut({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({hook_id:N.string()}),body:{content:{"application/json":{schema:N.object(U_.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:dd.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 lt(404,{message:"Hook not found"});return r.json(s)}).openapi(ut({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({hook_id:N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:dd}},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 lt(404,{message:"Hook not found"});return r.json(n)}).openapi(ut({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:N.object({"tenant-id":N.string()}),params:N.object({hook_id:N.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 lt(404,{message:"Hook not found"});return r.text("OK")});const GV=Ac.extend({connections:N.array(ko)});new On().openapi(ut({tags:["connections"],method:"get",path:"/",request:{query:oc,headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:N.union([N.array(ko),GV])}},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:yl(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(ut({tags:["connections"],method:"get",path:"/{id}",request:{params:N.object({id:N.string()}),headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ko}},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 lt(404);return r.json(n)}).openapi(ut({tags:["connections"],method:"delete",path:"/{id}",request:{params:N.object({id:N.string()}),headers:N.object({"tenant-id":N.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 lt(404,{message:"Connection not found"});return r.text("OK")}).openapi(ut({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:N.object(D_.shape).partial()}}},params:N.object({id:N.string()}),headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:ko}},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 lt(404,{message:"Connection not found"});const s=await r.env.data.connections.get(e,t);if(!s)throw new lt(404,{message:"Connection not found"});return r.json(s)}).openapi(ut({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:N.object(D_.shape)}}},headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:ko}},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})});new On().openapi(ut({tags:["prompts"],method:"get",path:"/",request:{headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:hb}},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(hb.parse({}))}).openapi(ut({tags:["prompts"],method:"patch",path:"/",request:{headers:N.object({"tenant-id":N.string()}),body:{content:{"application/json":{schema:N.object(hb.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)});N.object({alg:N.literal("RS256"),kty:N.literal("RSA"),use:N.literal("sig"),n:N.string(),e:N.string(),kid:N.string(),x5t:N.string(),x5c:N.array(N.string())});new On().openapi(ut({tags:["emails"],method:"get",path:"/",request:{headers:N.object({"tenant-id":N.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:pb}},description:"Email provider"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.emailProviders.get(e);if(!t)throw new lt(404,{message:"Email provider not found"});return r.json(t)}).openapi(ut({tags:["emails"],method:"post",path:"/",request:{headers:N.object({"tenant-id":N.string()}),body:{content:{"application/json":{schema:N.object(pb.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.create(e,t),r.text("OK",{status:201})}).openapi(ut({tags:["emails"],method:"patch",path:"/",request:{headers:N.object({"tenant-id":N.string()}),body:{content:{"application/json":{schema:N.object(pb.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.update(e,t),r.text("OK")});const Wf=60*5,JV=30*24*60*60,YV="auth-token";new On().openapi(ut({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:hD}},description:"List of tenants"}}}),async r=>{const e=await r.env.data.keys.list(),t=await Promise.all(e.map(async n=>{const s=await new c2(n.cert).publicKey.export(),i=await crypto.subtle.exportKey("jwk",s);return XE.parse({...i,kid:n.kid})}));return r.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Wf}, stale-while-revalidate=${Wf*2}, stale-if-error=86400`}})}).openapi(ut({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:BA}},description:"List of tenants"}}}),async r=>{const e=r.env.ISSUER,t=BA.parse({issuer:e,authorization_endpoint:`${e}authorize`,token_endpoint:`${e}oauth/token`,device_authorization_endpoint:`${e}oauth/device/code`,userinfo_endpoint:`${e}userinfo`,mfa_challenge_endpoint:`${e}mfa/challenge`,jwks_uri:`${e}.well-known/jwks.json`,registration_endpoint:`${e}oidc/register`,revocation_endpoint:`${e}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return r.json(t,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Wf}, stale-while-revalidate=${Wf*2}, stale-if-error=86400`}})});class Lg{constructor(e,t){$e(this,"value"),$e(this,"unit"),this.value=e,this.unit=t}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Lg(Math.round(this.milliseconds()*e),"ms")}}async function y4(r,e,t,n){const s={alg:r,typ:"JWT",...n==null?void 0:n.headers},i={...t};(n==null?void 0:n.audiences)!==void 0&&(i.aud=n.audiences),(n==null?void 0:n.subject)!==void 0&&(i.sub=n.subject),(n==null?void 0:n.issuer)!==void 0&&(i.iss=n.issuer),(n==null?void 0:n.jwtId)!==void 0&&(i.jti=n.jwtId),(n==null?void 0:n.expiresIn)!==void 0&&(i.exp=Math.floor(Date.now()/1e3)+n.expiresIn.seconds()),(n==null?void 0:n.notBefore)!==void 0&&(i.nbf=Math.floor(n.notBefore.getTime()/1e3)),(n==null?void 0:n.includeIssuedTimestamp)===!0&&(i.iat=Math.floor(Date.now()/1e3));const a=new TextEncoder,o=fm.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),c=fm.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),u=a.encode([o,c].join(".")),l=await XV(r).sign(e,u),h=fm.encode(new Uint8Array(l),{includePadding:!1});return[o,c,h].join(".")}function XV(r){return new MU(QV[r])}const QV={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function eL(r){try{const e=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(r);if(!e||!e[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(e[1].replace(/\s/g,"")),t=>t.charCodeAt(0)).buffer}finally{r=r.replace(/./g,"\0")}}async function tL(r,e){if(e==="plain")return r;const t=new TextEncoder().encode(r),n=await GI(t);return fm.encode(new Uint8Array(n))}async function a5(r,e){var t;const{authParams:n,user:s,sid:i}=e,a=(await r.env.data.keys.list()).filter(h=>!h.revoked_at||new Date(h.revoked_at)>new Date),o=a[a.length-1];if(!(o!=null&&o.pkcs7))throw new lt(500,{message:"No signing key available"});const c=eL(o.pkcs7),u=await y4("RS256",c,{aud:n.audience||"default",scope:n.scope||"",sub:(s==null?void 0:s.user_id)||n.client_id,iss:r.env.ISSUER,tenant_id:r.var.tenant_id,sid:i},{includeIssuedTimestamp:!0,expiresIn:new Lg(1,"d"),headers:{kid:o.kid}}),l=s&&(t=n.scope)!=null&&t.split(" ").includes("openid")?await y4("RS256",c,{aud:n.client_id,sub:s.user_id,iss:r.env.ISSUER,sid:i,nonce:n.nonce,given_name:s.given_name,family_name:s.family_name,nickname:s.nickname,picture:s.picture,locale:s.locale,name:s.name,email:s.email,email_verified:s.email_verified},{includeIssuedTimestamp:!0,expiresIn:new Lg(1,"d"),headers:{kid:o.kid}}):void 0;return{access_token:u,id_token:l,token_type:"Bearer",expires_in:86400}}function rL(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}const o5=N.object({grant_type:N.literal("client_credentials"),scope:N.string().optional(),client_secret:N.string(),client_id:N.string(),audience:N.string().optional()});async function nL(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new lt(403,{message:"Invalid client credentials"});if(t.client_secret&&!rL(t.client_secret,e.client_secret))throw new lt(403,{message:"Invalid client credentials"});const n={client_id:t.id,scope:e.scope,audience:e.audience},s=await a5(r,{authParams:n});return r.json(s)}function sL(r,e,t){const n=[];return n.push([encodeURIComponent(r),encodeURIComponent(e)]),(t==null?void 0:t.domain)!==void 0&&n.push(["Domain",t.domain]),(t==null?void 0:t.expires)!==void 0&&n.push(["Expires",t.expires.toUTCString()]),n.push(["HttpOnly"]),(t==null?void 0:t.maxAge)!==void 0&&n.push(["Max-Age",t.maxAge.toString()]),(t==null?void 0:t.path)!==void 0&&n.push(["Path",t.path]),n.push(["SameSite","None"]),n.push(["Secure"]),n.map(s=>s.join("=")).join("; ")}const iL=N.object({grant_type:N.literal("authorization_code"),client_id:N.string(),code:N.string(),redirect_uri:N.string(),client_secret:N.string().optional(),code_verifier:N.string().optional()}).refine(r=>"client_secret"in r&&!("code_verifier"in r)||!("client_secret"in r)&&"code_verifier"in r,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function aL(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new lt(403,{message:"Invalid client credentials"});const n=await r.env.data.codes.get(t.tenant.id,e.code,"authorization_code");if(!n||!n.user_id)throw new lt(403,{message:"Invalid client credentials"});if(new Date(n.expires_at)<new Date)throw new lt(403,{message:"Code expired"});const s=await r.env.data.logins.get(t.tenant.id,n.login_id);if(!s)throw new lt(403,{message:"Invalid login"});if("client_secret"in e){if(t.client_secret!==e.client_secret)throw new lt(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in s.authParams&&typeof s.authParams.code_challenge_method=="string"&&await tL(e.code_verifier,s.authParams.code_challenge_method)!==s.authParams.code_challenge)throw new lt(403,{message:"Invalid client credentials"});if(s.authParams.redirect_uri&&s.authParams.redirect_uri!==e.redirect_uri)throw new lt(403,{message:"Invalid redirect uri"});const i=await r.env.data.users.get(t.tenant.id,n.user_id);if(!i)throw new lt(403,{message:"User not found"});await r.env.data.codes.remove(t.tenant.id,e.code);const a=await r.env.data.sessions.create(t.tenant.id,{session_id:Qy(),user_id:i.user_id,client_id:t.id,expires_at:new Date(Date.now()+JV*1e3).toISOString(),used_at:new Date().toISOString()}),o=await a5(r,{authParams:s.authParams,user:i,sid:a.session_id});return r.json(o,{headers:{"set-cookie":sL(`${t.tenant.id}-${YV}`,a.session_id,{path:"/",httpOnly:!0,secure:!0,maxAge:60*60*24*7,sameSite:"none"})}})}const g4=N.object({client_id:N.string().optional(),client_secret:N.string().optional()}),oL=N.union([o5.extend(g4.shape),N.object({grant_type:N.literal("authorization_code"),client_id:N.string(),code:N.string(),redirect_uri:N.string(),code_verifier:N.string().min(43).max(128)}),N.object({grant_type:N.literal("authorization_code"),code:N.string(),redirect_uri:N.string(),...g4.shape})]);function cL(r){if(!r)return{};const[e,t]=r.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&t){const[n,s]=atob(t).split(":");return{client_id:n,client_secret:s}}return{}}new On().openapi(ut({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:oL}}}},responses:{200:{content:{"application/json":{schema:N.object({access_token:N.string(),id_token:N.string().optional(),refresh_token:N.string().optional(),token_type:N.string(),expires_in:N.number()})}},description:"Tokens"}}}),async r=>{const e=r.req.valid("form"),t=cL(r.req.header("Authorization")),n={...e,...t};if(!n.client_id)throw new lt(400,{message:"client_id is required"});switch(e.grant_type){case L_.AuthorizationCode:return aL(r,iL.parse(n));case L_.ClientCredential:return nL(r,o5.parse(n));default:throw new lt(400,{message:"Not implemented"})}});async function uL(r,e){const t=await r.data.clients.get(e);if(!t)throw new nt(403,{message:"Client not found"});const n=await r.data.clients.get("DEFAULT_CLIENT"),s=n?t.connections.map(i=>{var c;const a=(c=n==null?void 0:n.connections)==null?void 0:c.find(u=>u.name===i.name);return ko.parse({...a||{},...i,options:{...(a==null?void 0:a.options)||{},...i.options}})}).filter(i=>i):t.connections;return{...t,web_origins:[...(n==null?void 0:n.web_origins)||[],...t.web_origins||[],`${r.ISSUER}u/login`],allowed_logout_urls:[...(n==null?void 0:n.allowed_logout_urls)||[],...t.allowed_logout_urls||[],r.ISSUER],callbacks:[...(n==null?void 0:n.callbacks)||[],...t.callbacks||[],`${r.ISSUER}u/info`],connections:s,domains:[...t.domains||[],...(n==null?void 0:n.domains)||[]],tenant:{...(n==null?void 0:n.tenant)||{},...t.tenant}}}const lL=T.object({grant_type:T.literal("authorization_code"),client_id:T.string(),code:T.string(),redirect_uri:T.string().optional(),client_secret:T.string().optional(),code_verifier:T.string().optional()}).refine(r=>"client_secret"in r&&!("code_verifier"in r)||!("client_secret"in r)&&"code_verifier"in r,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function dL(r,e){const t=await uL(r.env,e.client_id),n=await r.env.data.codes.get(t.tenant.id,e.code,"authorization_code");if(!n||!n.user_id)throw new nt(403,{message:"Invalid client credentials"});if(new Date(n.expires_at)<new Date)throw new nt(403,{message:"Code expired"});const s=await r.env.data.logins.get(t.tenant.id,n.login_id);if(!s)throw new nt(403,{message:"Invalid login"});if("client_secret"in e){if(console.log("cliet",JSON.stringify(t,null,2)),t.client_secret!==e.client_secret)throw new nt(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in s.authParams&&typeof s.authParams.code_challenge_method=="string"&&await N7(e.code_verifier,s.authParams.code_challenge_method)!==s.authParams.code_challenge)throw new nt(403,{message:"Invalid client credentials"});if(s.authParams.redirect_uri&&s.authParams.redirect_uri!==e.redirect_uri)throw new nt(403,{message:"Invalid redirect uri"});const i=await r.env.data.users.get(t.tenant.id,n.user_id);if(!i)throw new nt(403,{message:"User not found"});await r.env.data.codes.remove(t.tenant.id,e.code);const a=await r.env.data.sessions.create(t.tenant.id,{session_id:qm(),user_id:i.user_id,client_id:t.id,expires_at:new Date(Date.now()+O7*1e3).toISOString(),used_at:new Date().toISOString()}),o=await eE(r,{authParams:s.authParams,user:i,sid:a.session_id});return r.json(o,{headers:{"set-cookie":P7(`${t.tenant.id}-${j7}`,a.session_id,{path:"/",httpOnly:!0,secure:!0,maxAge:60*60*24*7,sameSite:"none"})}})}const v4=T.object({client_id:T.string().optional(),client_secret:T.string().optional()}),hL=T.union([tE.extend(v4.shape),T.object({grant_type:T.literal("authorization_code"),client_id:T.string(),code:T.string(),redirect_uri:T.string(),code_verifier:T.string().min(43).max(128)}),T.object({grant_type:T.literal("authorization_code"),code:T.string(),redirect_uri:T.string().optional(),...v4.shape})]);function pL(r){if(!r)return{};const[e,t]=r.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&t){const[n,s]=atob(t).split(":");return{client_id:n,client_secret:s}}return{}}const fL=new Sr().openapi(ct({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:hL}}}},responses:{200:{content:{"application/json":{schema:T.object({access_token:T.string(),id_token:T.string().optional(),refresh_token:T.string().optional(),token_type:T.string(),expires_in:T.number()})}},description:"Tokens"}}}),async r=>{const e=r.req.valid("form"),t=pL(r.req.header("Authorization")),n={...e,...t};if(!n.client_id)throw new nt(400,{message:"client_id is required"});switch(e.grant_type){case Vm.AuthorizationCode:return dL(r,lL.parse(n));case Vm.ClientCredential:return R7(r,tE.parse(n));default:throw new nt(400,{message:"Not implemented"})}});function mL(){const r=new Sr;r.use(QC(r));const e=new Sr().route("/.well-known",C7).route("/oauth/token",fL);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),XC(e),e}function yL(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await e9({userAdapter:r.users,tenant_id:e,email:t.email});return n?(await r.users.create(e,{...t,linked_to:n.user_id}),n):r.users.create(e,t)}}async function gL(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=Wj(r,{type:zg.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,i)}}function vL(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 gL(r,s,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function bL(r,e){return async(t,n)=>{let s=await yL(e)(t,n);return await vL(r,e)(t,s),s}}function _L(r,e){return{...e,users:{...e.users,create:bL(r,e)}}}function wL(r){const e=new Sr;e.use(async(s,i)=>(s.env.data=_L(s,r.dataAdapter),i())),e.get("/",s=>s.json({name:"authhero"}));const t=A7();e.route("/api/v2",t);const n=mL();return e.route("/",n),{app:e,managementApp:t,oauthApp:n,createX509Certificate:f_}}exports.Auth0Client=Zj;exports.AuthorizationResponseMode=bx;exports.AuthorizationResponseType=vx;exports.CodeChallengeMethod=_x;exports.GrantType=Vm;exports.LogTypes=zg;exports.applicationInsertSchema=$m;exports.applicationSchema=bo;exports.auth0UserResponseSchema=Ps;exports.authParamsSchema=Tj;exports.baseUserSchema=Kg;exports.bordersSchema=Uj;exports.brandingSchema=zb;exports.codeInsertSchema=Bj;exports.codeSchema=NN;exports.codeTypeSchema=Nj;exports.colorsSchema=Vj;exports.connectionInsertSchema=Zm;exports.connectionSchema=_o;exports.domainInsertSchema=Rj;exports.domainSchema=BN;exports.emailProviderSchema=rm;exports.fontDetailsSchema=yo;exports.fontsSchema=Lj;exports.hookInsertSchema=Mm;exports.hookSchema=Yc;exports.identitySchema=Ej;exports.init=wL;exports.jwksKeySchema=Pj;exports.jwksSchema=wx;exports.logSchema=Um;exports.loginInsertSchema=$j;exports.loginSchema=RN;exports.openIDConfigurationSchema=Wb;exports.pageBackgroundSchema=qj;exports.parseUserId=DN;exports.passwordInsertSchema=Dj;exports.passwordSchema=$N;exports.profileDataSchema=Cj;exports.promptSettingSchema=tm;exports.samlpAddon=Ij;exports.sessionInsertSchema=Mj;exports.sessionSchema=xx;exports.signingKeySchema=Gb;exports.tenantInsertSchema=Dm;exports.tenantSchema=nu;exports.themeInsertSchema=Fj;exports.themeSchema=ZN;exports.totalsSchema=Ja;exports.userInsertSchema=Pm;exports.userResponseSchema=jN;exports.userSchema=gx;exports.vendorSettingsSchema=IN;exports.widgetSchema=Hj;
117
+ */const po="crypto.algorithm";class B1{getAlgorithms(){return pt.resolveAll(po)}toAsnAlgorithm(e){({...e});for(const t of this.getAlgorithms()){const n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){const t=new Y({algorithm:e.name});if("parameters"in e){const n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const n of this.getAlgorithms()){const i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const hi="crypto.algorithmProvider";pt.registerSingleton(hi,B1);var Ro;const Bt="1.3.36.3.3.2.8.1.1",Sp=`${Bt}.1`,Ap=`${Bt}.2`,Op=`${Bt}.3`,Ep=`${Bt}.4`,Ip=`${Bt}.5`,Cp=`${Bt}.6`,jp=`${Bt}.7`,Tp=`${Bt}.8`,Np=`${Bt}.9`,Bp=`${Bt}.10`,Rp=`${Bt}.11`,Pp=`${Bt}.12`,$p=`${Bt}.13`,Dp=`${Bt}.14`,Zp="brainpoolP160r1",Mp="brainpoolP160t1",Up="brainpoolP192r1",Vp="brainpoolP192t1",Lp="brainpoolP224r1",qp="brainpoolP224t1",Hp="brainpoolP256r1",Fp="brainpoolP256t1",Kp="brainpoolP320r1",Wp="brainpoolP320t1",zp="brainpoolP384r1",Gp="brainpoolP384t1",Jp="brainpoolP512r1",Yp="brainpoolP512t1",ze="ECDSA";let Oa=Ro=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ze.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return n1;case"sha-256":return i1;case"sha-384":return s1;case"sha-512":return a1}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=tp;break;case"K-256":t=Ro.SECP256K1;break;case"P-384":t=rp;break;case"P-521":t=np;break;case Zp:t=Sp;break;case Mp:t=Ap;break;case Up:t=Op;break;case Vp:t=Ep;break;case Lp:t=Ip;break;case qp:t=Cp;break;case Hp:t=jp;break;case Fp:t=Tp;break;case Kp:t=Np;break;case Wp:t=Bp;break;case zp:t=Rp;break;case Gp:t=Pp;break;case Jp:t=$p;break;case Yp:t=Dp;break}if(t)return new Y({algorithm:ka,parameters:L.serialize(new An({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Wf:return{name:ze,hash:{name:"SHA-1"}};case zf:return{name:ze,hash:{name:"SHA-256"}};case Gf:return{name:ze,hash:{name:"SHA-384"}};case Jf:return{name:ze,hash:{name:"SHA-512"}};case ka:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(L.parse(e.parameters,An).namedCurve){case tp:return{name:ze,namedCurve:"P-256"};case Ro.SECP256K1:return{name:ze,namedCurve:"K-256"};case rp:return{name:ze,namedCurve:"P-384"};case np:return{name:ze,namedCurve:"P-521"};case Sp:return{name:ze,namedCurve:Zp};case Ap:return{name:ze,namedCurve:Mp};case Op:return{name:ze,namedCurve:Up};case Ep:return{name:ze,namedCurve:Vp};case Ip:return{name:ze,namedCurve:Lp};case Cp:return{name:ze,namedCurve:qp};case jp:return{name:ze,namedCurve:Hp};case Tp:return{name:ze,namedCurve:Fp};case Np:return{name:ze,namedCurve:Kp};case Bp:return{name:ze,namedCurve:Wp};case Rp:return{name:ze,namedCurve:zp};case Pp:return{name:ze,namedCurve:Gp};case $p:return{name:ze,namedCurve:Jp};case Dp:return{name:ze,namedCurve:Yp}}}}return null}};Oa.SECP256K1="1.3.132.0.10";Oa=Ro=l([Lu()],Oa);pt.registerSingleton(po,Oa);const b0=Symbol("name"),x0=Symbol("value");class Me{constructor(e,t={},n=""){this[b0]=e,this[x0]=n;for(const i in t)this[i]=t[i]}}Me.NAME=b0;Me.VALUE=x0;class R1{static toTextObject(e){const t=new Me("Algorithm Identifier",{},Nn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case ka:{const n=new Oa().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class Nn{static toString(e){const t=this.items[e];return t||e}}Nn.items={[$c]:"sha1",[a0]:"sha224",[Dc]:"sha256",[Zc]:"sha384",[Mc]:"sha512",[li]:"rsaEncryption",[Bc]:"sha1WithRSAEncryption",[f1]:"sha224WithRSAEncryption",[Ed]:"sha256WithRSAEncryption",[Rc]:"sha384WithRSAEncryption",[Pc]:"sha512WithRSAEncryption",[ka]:"ecPublicKey",[Wf]:"ecdsaWithSHA1",[n0]:"ecdsaWithSHA224",[zf]:"ecdsaWithSHA256",[Gf]:"ecdsaWithSHA384",[Jf]:"ecdsaWithSHA512",[Jw]:"TLS WWW server authentication",[Yw]:"TLS WWW client authentication",[Xw]:"Code Signing",[Qw]:"E-mail Protection",[e1]:"Time Stamping",[t1]:"OCSP Signing",[r1]:"Signed Data"};class pi{static serialize(e){return this.serializeObj(e).join(`
118
+ `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let i=this.pad(t++),s="";const a=e[Me.VALUE];a&&(s=` ${a}`),n.push(`${i}${e[Me.NAME]}:${s}`),i=this.pad(t);for(const o in e){if(typeof o=="symbol")continue;const c=e[o],u=o?`${o}: `:"";if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`${i}${u}${c}`);else if(c instanceof Date)n.push(`${i}${u}${c.toUTCString()}`);else if(Array.isArray(c))for(const f of c)f[Me.NAME]=o,n.push(...this.serializeObj(f,t));else if(c instanceof Me)c[Me.NAME]=o,n.push(...this.serializeObj(c,t));else if(q.isBufferSource(c))o?(n.push(`${i}${u}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){const f=c.toTextObject();f[Me.NAME]=o,n.push(...this.serializeObj(f,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),i=q.toUint8Array(e),s=[];for(let a=0;a<i.length;){const o=[];for(let c=0;c<16&&a<i.length;c++){c===8&&o.push("");const u=i[a++].toString(16).padStart(2,"0");o.push(u)}s.push(`${n}${o.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}pi.oidSerializer=Nn;pi.algorithmSerializer=R1;class Bn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=L.serialize(t),this.onInit(t)}else{const t=L.parse(e[0],e[1]);this.rawData=q.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Bn?My(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return L.toString(this.rawData);case"text":return pi.serialize(this.toTextObject());case"hex":return te.ToHex(this.rawData);case"base64":return te.ToBase64(this.rawData);case"base64url":return te.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new Me(this.getTextName(),{},e)}}Bn.NAME="ASN";class Gt extends Bn{constructor(...e){let t;q.isBufferSource(e[0])?t=q.toArrayBuffer(e[0]):t=L.serialize(new Wt({extnID:e[0],critical:e[1],extnValue:new De(q.toArrayBuffer(e[2]))})),super(t,Wt)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[Me.NAME]===Gt.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}var _0;class hn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[_0]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(hn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(hn.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=hn.DEFAULT){const t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(hn.DEFAULT,e);return this}}_0=Symbol.toStringTag;hn.DEFAULT="default";const ut=new hn,P1=/^[0-2](?:\.[1-9][0-9]*)+$/;function $1(r){return new RegExp(P1).test(r)}class w0{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return $1(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const Tt=new w0;Tt.register("CN","2.5.4.3");Tt.register("L","2.5.4.7");Tt.register("ST","2.5.4.8");Tt.register("O","2.5.4.10");Tt.register("OU","2.5.4.11");Tt.register("C","2.5.4.6");Tt.register("DC","0.9.2342.19200300.100.1.25");Tt.register("E","1.2.840.113549.1.9.1");Tt.register("G","2.5.4.42");Tt.register("I","2.5.4.43");Tt.register("SN","2.5.4.4");Tt.register("T","2.5.4.12");function D1(r,e){return`\\${te.ToHex(te.FromUtf8String(e)).toUpperCase()}`}function Z1(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,D1)}class Ht{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new w0,this.asn=new et;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=t[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof et?this.asn=e:q.isBufferSource(e)?this.asn=L.parse(e,et):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||Tt.findId(e),n=[];for(const i of this.asn)for(const s of i)s.type===t&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||Tt.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,i=t.value.anyValue?`#${te.ToHex(t.value.anyValue)}`:Z1(t.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const i={};for(const s of n){const a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${te.ToHex(s.value.anyValue)}`:s.value.toString())}t.push(i)}return t}fromString(e){const t=new et,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=n.exec(`${e},`);){let[,a,o]=i;const c=o[o.length-1];(c===","||c==="+")&&(o=o.slice(0,o.length-1),i[3]=c);const u=i[3];a=this.getTypeOid(a);const f=this.createAttribute(a,o);s==="+"?t[t.length-1].push(f):t.push(new Gi([f])),s=u}return t}fromJSON(e){const t=new et;for(const n of e){const i=new Gi;for(const s in n){const a=this.getTypeOid(s),o=n[s];for(const c of o){const u=this.createAttribute(a,c);i.push(u)}}t.push(i)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){const n=new wu({type:e});if(typeof t=="object")for(const i in t)switch(i){case"ia5String":n.value.ia5String=t[i];break;case"utf8String":n.value.utf8String=t[i];break;case"universalString":n.value.universalString=t[i];break;case"bmpString":n.value.bmpString=t[i];break;case"printableString":n.value.printableString=t[i];break}else if(t[0]==="#")n.value.anyValue=te.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:Ht.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
119
+ `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return L.serialize(this.asn)}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(i,this.toArrayBuffer())}}const k0="Cannot initialize GeneralName from ASN.1 data.",Xp=`${k0} Unsupported string format in use.`,M1=`${k0} Value doesn't match to GUID regular expression.`,Qp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,em="1.3.6.1.4.1.311.25.1",tm="1.3.6.1.4.1.311.20.2.3",al="dns",ol="dn",cl="email",ul="ip",ll="url",dl="guid",fl="upn",_o="id";class pn extends Bn{constructor(...e){let t;if(e.length===2)switch(e[0]){case ol:{const n=new Ht(e[1]).toArrayBuffer(),i=L.parse(n,et);t=new be({directoryName:i});break}case al:t=new be({dNSName:e[1]});break;case cl:t=new be({rfc822Name:e[1]});break;case dl:{const n=new RegExp(Qp,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=n.slice(1).map((s,a)=>a<3?te.ToHex(new Uint8Array(te.FromHex(s)).reverse()):s).join("");t=new be({otherName:new ba({typeId:em,value:L.serialize(new De(te.FromHex(i)))})});break}case ul:t=new be({iPAddress:e[1]});break;case _o:t=new be({registeredID:e[1]});break;case fl:{t=new be({otherName:new ba({typeId:tm,value:L.serialize(Mg.toASN(e[1]))})});break}case ll:t=new be({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else q.isBufferSource(e[0])?t=L.parse(e[0],be):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=al,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=cl,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=ul,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=ll,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=_o,this.value=e.registeredID;else if(e.directoryName!=null)this.type=ol,this.value=new Ht(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===em){this.type=dl;const t=L.parse(e.otherName.value,De),n=new RegExp(Qp,"i").exec(te.ToHex(t));if(!n)throw new Error(M1);this.value=n.slice(1).map((i,s)=>s<3?te.ToHex(new Uint8Array(te.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===tm)this.type=fl,this.value=L.parse(e.otherName.value,ht).toString();else throw new Error(Xp);else throw new Error(Xp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case ol:case al:case dl:case ul:case _o:case fl:case ll:e=this.type.toUpperCase();break;case cl:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===_o&&(t=Nn.toString(t)),new Me(e,void 0,t)}}class Ea extends Bn{constructor(e){let t;if(e instanceof xt)t=e;else if(Array.isArray(e)){const n=[];for(const i of e)if(i instanceof be)n.push(i);else{const s=L.parse(new pn(i.type,i.value).rawData,be);n.push(s)}t=new xt(n)}else if(q.isBufferSource(e))t=L.parse(e,xt);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let i=null;try{i=new pn(n)}catch{continue}t.push(i)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let i=e[n[Me.NAME]];Array.isArray(i)||(i=[],e[n[Me.NAME]]=i),i.push(n)}return e}}Ea.NAME="GeneralNames";const Vs="-{5}",Ia="\\n",U1=`[^${Ia}]+`,V1=`${Vs}BEGIN (${U1}(?=${Vs}))${Vs}`,L1=`${Vs}END \\1${Vs}`,ns="\\n",q1=`[^:${Ia}]+`,H1=`(?:[^${Ia}]+${ns}(?: +[^${Ia}]+${ns})*)`,F1="[a-zA-Z0-9=+/]+",K1=`(?:${F1}${ns})+`,rm=`${V1}${ns}(?:((?:${q1}: ${H1})+))?${ns}?(${K1})${L1}`;class $t{static isPem(e){return typeof e=="string"&&new RegExp(rm,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(rm,"g"),n=[];let i=null;for(;i=t.exec(e);){const s=i[3].replace(new RegExp(`[${Ia}]+`,"g"),""),a={type:i[1],headers:[],rawData:te.FromBase64(s)},o=i[2];if(o){const c=o.split(new RegExp(ns,"g"));let u=null;for(const f of c){const[m,B]=f.split(/:(.*)/);if(B===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=m.trim()}else u&&a.headers.push(u),u={key:m,value:B.trim()}}u&&a.headers.push(u)}n.push(a)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){const t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){const n=new Array;return t?e.forEach(i=>{if(!q.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:q.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
120
+ `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:q.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const u of e.headers)i.push(`${u.key}: ${u.value}`);i.push("")}const s=te.ToBase64(e.rawData);let a,o=0;const c=Array();for(;o<s.length&&(s.length-o<64?a=s.substring(o):(a=s.substring(o,o+64),o+=64),a.length!==0);)if(c.push(a),a.length<64)break;return i.push(...c),i.push(`-----END ${n}-----`),i.join(`
121
+ `)}}$t.CertificateTag="CERTIFICATE";$t.CrlTag="CRL";$t.CertificateRequestTag="CERTIFICATE REQUEST";$t.PublicKeyTag="PUBLIC KEY";$t.PrivateKeyTag="PRIVATE KEY";class Jr extends Bn{static isAsnEncoded(e){return q.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if($t.isPem(e))return $t.decode(e)[0];if(te.isHex(e))return te.FromHex(e);if(te.isBase64(e))return te.FromBase64(e);if(te.isBase64Url(e))return te.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=te.ToBinary(e);return $t.isPem(t)?$t.decode(t)[0]:te.isHex(t)?te.FromHex(t):te.isBase64(t)?te.FromBase64(t):te.isBase64Url(t)?te.FromBase64Url(t):q.toArrayBuffer(e)}}constructor(...e){Jr.isAsnEncoded(e[0])?super(Jr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return $t.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ur extends Jr{static async create(e,t=ut.get()){if(e instanceof ur)return e;if(hn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new ur(n)}else{if(e.publicKey)return e.publicKey;if(q.isBufferSource(e))return new ur(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Jr.isAsnEncoded(e)?super(e,sr):super(e),this.tag=$t.PublicKeyTag}async export(...e){let t,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,t=e[2]||ut.get()):t=e[0]||ut.get();let s=this.rawData;const a=L.parse(this.rawData,sr);return a.algorithm.algorithm===Us&&(s=W1(a,s)),t.subtle.importKey("spki",s,i,!0,n)}onInit(e){const t=pt.resolve(hi),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case li:{const i=L.parse(e.subjectPublicKey,Yf),s=q.toUint8Array(i.modulus);n.publicExponent=q.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=ut.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=ut.get();const i=L.parse(this.rawData,sr);return await t.subtle.digest(n,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,sr);switch(e.Algorithm=pi.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case ka:e["EC Point"]=t.subjectPublicKey;break;case li:default:e["Raw Data"]=t.subjectPublicKey}return e}}function W1(r,e){return r.algorithm=new Y({algorithm:li,parameters:null}),e=L.serialize(r),e}class Ca extends Gt{static async create(e,t=!1,n=ut.get()){if("name"in e&&"serialNumber"in e)return new Ca(e,t);const s=await(await ur.create(e,n)).getKeyIdentifier(n);return new Ca(te.ToHex(s),t)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Ln({keyIdentifier:new Nf(te.FromHex(e[0]))});super(Fl,e[1],L.serialize(t))}else{const t=e[0],n=t.name instanceof Ea?L.parse(t.name.rawData,xt):t.name,i=new Ln({authorityCertIssuer:n,authorityCertSerialNumber:te.FromHex(t.serialNumber)});super(Fl,e[1],L.serialize(i))}}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Ln);t.keyIdentifier&&(this.keyId=te.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?te.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,Ln);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Ea(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Ca.NAME="Authority Key Identifier";class th extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,mc);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new mc({cA:e[0],pathLenConstraint:e[1]});super(Lg,e[2],L.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}th.NAME="Basic Constraints";var nm;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(nm||(nm={}));class rh extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,bc);this.usages=t.map(n=>n)}else{const t=new bc(e[0]);super(Fg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Nn.toString(t)).join(", "),e}}rh.NAME="Extended Key Usages";var Fc;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Fc||(Fc={}));class nh extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,sl);this.usages=t.toNumber()}else{const t=new sl(e[0]);super(Kg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,sl);return e[""]=t.toJSON().join(", "),e}}nh.NAME="Key Usages";class mo extends Gt{static async create(e,t=!1,n=ut.get()){const s=await(await ur.create(e,n)).getKeyIdentifier(n);return new mo(te.ToHex(s),t)}constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,yn);this.keyId=te.ToHex(t)}else{const t=typeof e[0]=="string"?te.FromHex(e[0]):e[0],n=new yn(t);super(Jg,e[1],L.serialize(n)),this.keyId=te.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,yn);return e[""]=t,e}}mo.NAME="Subject Key Identifier";class S0 extends Gt{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(Gg,e[1],new Ea(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,ad);this.names=new Ea(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}S0.NAME="Subject Alternative Name";class Jt{static register(e,t){this.items.set(e,t)}static create(e){const t=new Gt(e),n=this.items.get(t.type);return n?new n(e):t}}Jt.items=new Map;class A0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0])){super(e[0]);const n=L.parse(this.value,gc);this.policies=n.map(i=>i.policyIdentifier)}else{const n=e[0],i=(t=e[1])!==null&&t!==void 0?t:!1,s=new gc(n.map(a=>new Su({policyIdentifier:a})));super(qg,i,L.serialize(s)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Me("",{},Nn.toString(t))),e}}A0.NAME="Certificate Policies";Jt.register(qg,A0);class O0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(a=>new ds({distributionPoint:new ai({fullName:[new be({uniformResourceIdentifier:a})]})})),s=new Ri(i);super(Jl,e[1],L.serialize(s))}else{const n=new Ri(e[0]);super(Jl,e[1],L.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,Ri);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const i={};return t.distributionPoint&&(i[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new pn(s).toString()).join(", ")),t.reasons&&(i.Reasons=t.reasons.toString()),t.cRLIssuer&&(i["CRL Issuer"]=t.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}O0.NAME="CRL Distribution Points";class E0 extends Gt{constructor(...e){var t,n,i,s;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Ii){const a=new Ii(e[0]);super(Hl,e[1],L.serialize(a))}else{const a=e[0],o=new Ii;ko(o,a,Uh,"ocsp"),ko(o,a,Vh,"caIssuers"),ko(o,a,Lh,"timeStamping"),ko(o,a,qh,"caRepository"),super(Hl,e[1],L.serialize(o))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],L.parse(e.extnValue,Ii).forEach(n=>{switch(n.accessMethod){case Uh:this.ocsp.push(new pn(n.accessLocation));break;case Vh:this.caIssuers.push(new pn(n.accessLocation));break;case Lh:this.timeStamping.push(new pn(n.accessLocation));break;case qh:this.caRepository.push(new pn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&wo(e,"OCSP",this.ocsp),this.caIssuers.length&&wo(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&wo(e,"Time Stamping",this.timeStamping),this.caRepository.length&&wo(e,"CA Repository",this.caRepository),e}}E0.NAME="Authority Info Access";function wo(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new Me("");t.forEach((i,s)=>{const a=i.toTextObject(),o=`${a[Me.NAME]} ${s+1}`;let c=n[o];Array.isArray(c)||(c=[],n[o]=c),c.push(a)}),r[e]=n}}function ko(r,e,t,n){const i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new pn("url",a)),r.push(new to({accessMethod:t,accessLocation:L.parse(a.rawData,be)}))})}class vs extends Bn{constructor(...e){let t;if(q.isBufferSource(e[0]))t=q.toArrayBuffer(e[0]);else{const n=e[0],i=Array.isArray(e[1])?e[1].map(s=>q.toArrayBuffer(s)):[];t=L.serialize(new Wr({type:n,values:i}))}super(t,Wr)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Me("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[Me.NAME]===vs.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}vs.NAME="Attribute";class I0 extends vs{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=new qc({printableString:e[0]});super(v0,[L.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],qc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Me.VALUE]=this.password,e}}I0.NAME="Challenge Password";class ih extends vs{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=e[0],i=new kn;for(const s of n)i.push(L.parse(s.rawData,Wt));super(eh,[L.serialize(i)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=L.parse(this.values[0],kn);this.items=t.map(n=>Jt.create(L.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[Me.NAME]]=n;return e}}ih.NAME="Extensions";class Wu{static register(e,t){this.items.set(e,t)}static create(e){const t=new vs(e),n=this.items.get(t.type);return n?new n(e):t}}Wu.items=new Map;const yo="crypto.signatureFormatter";class z1{toAsnSignature(e,t){return q.toArrayBuffer(t)}toWebSignature(e,t){return q.toArrayBuffer(t)}}var Po;let Jd=Po=class{static createPssParams(e,t){const n=Po.getHashAlgorithm(e);return n?new fi({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:Zu,parameters:L.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=pt.resolve(hi);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new Y({algorithm:Bc,parameters:null});case"sha-256":return new Y({algorithm:Ed,parameters:null});case"sha-384":return new Y({algorithm:Rc,parameters:null});case"sha-512":return new Y({algorithm:Pc,parameters:null})}}else return new Y({algorithm:li,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=Po.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new Y({algorithm:Us,parameters:L.serialize(t)})}else return new Y({algorithm:Us,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case li:return{name:"RSASSA-PKCS1-v1_5"};case Bc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Ed:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Rc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Pc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Us:if(e.parameters){const t=L.parse(e.parameters,fi);return{name:"RSA-PSS",hash:pt.resolve(hi).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Jd=Po=l([Lu()],Jd);pt.registerSingleton(po,Jd);let Yd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:$c});case"sha-256":return new Y({algorithm:Dc});case"sha-384":return new Y({algorithm:Zc});case"sha-512":return new Y({algorithm:Mc})}return null}toWebAlgorithm(e){switch(e.algorithm){case $c:return{name:"SHA-1"};case Dc:return{name:"SHA-256"};case Zc:return{name:"SHA-384"};case Mc:return{name:"SHA-512"}}return null}};Yd=l([Lu()],Yd);pt.registerSingleton(po,Yd);class Ft{addPadding(e,t){const n=q.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=q.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(t&&n[0]>127){const i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,i=Ft.namedCurveSize.get(n)||Ft.defaultNamedCurveSize,s=new Nc,a=q.toUint8Array(t);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),L.serialize(s)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=L.parse(t,Nc),i=e.namedCurve,s=Ft.namedCurveSize.get(i)||Ft.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(n.r)),o=this.addPadding(s,this.removePadding(n.s));return ow(a,o)}return null}}Ft.namedCurveSize=new Map;Ft.defaultNamedCurveSize=32;const hl="1.3.101.110",im="1.3.101.111",pl="1.3.101.112",sm="1.3.101.113";let Xd=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=pl;break;case"x25519":t=hl;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=pl;break;case"ed448":t=sm;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=hl;break;case"x448":t=im;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case pl:return{name:"Ed25519"};case sm:return{name:"EdDSA",namedCurve:"Ed448"};case hl:return{name:"X25519"};case im:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Xd=l([Lu()],Xd);pt.registerSingleton(po,Xd);class G1 extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,Aa):super(e),this.tag=$t.CertificateRequestTag}onInit(e){this.tbs=L.serialize(e.certificationRequestInfo),this.publicKey=new ur(e.certificationRequestInfo.subjectPKInfo);const t=pt.resolve(hi);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Wu.create(L.serialize(i)));const n=this.getAttribute(eh);this.extensions=[],n instanceof ih&&(this.extensions=n.items),this.subjectName=new Ht(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(const t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=ut.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),i=pt.resolveAll(yo).reverse();let s=null;for(const o of i)if(s=o.toWebSignature(t,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,Aa),n=t.certificationRequestInfo,i=new Me("",{Version:`${oi[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new Me("");for(const a of this.attributes){const o=a.toTextObject();s[o[Me.NAME]]=o}i.Attributes=s}return e.Data=i,e.Signature=new Me("",{Algorithm:pi.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}G1.NAME="PKCS#10 Certificate Request";class sh extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,ci):super(e),this.tag=$t.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=L.serialize(t),this.serialNumber=te.ToHex(t.serialNumber),this.subjectName=new Ht(t.subject),this.subject=new Ht(t.subject).toString(),this.issuerName=new Ht(t.issuer),this.issuer=this.issuerName.toString();const n=pt.resolve(hi);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(a=>Jt.create(L.serialize(a)))),this.publicKey=new ur(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=ut.get()){let n,i;const s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],t);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],t);else if(s instanceof ur)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],t);else if(q.isBufferSource(s)){const u=new ur(s);n={...u.algorithm,...this.signatureAlgorithm},i=await u.export(n,["verify"],t)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const a=pt.resolveAll(yo).reverse();let o=null;for(const u of a)if(o=u.toWebSignature(n,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const c=await t.subtle.verify(this.signatureAlgorithm,i,o,this.tbs);if(e.signatureOnly)return c;{const f=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<f&&f<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=ut.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=ut.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,ci),n=t.tbsCertificate,i=new Me("",{Version:`${oi[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":pi.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Me("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const s=new Me("");for(const a of this.extensions){const o=a.toTextObject();s[o[Me.NAME]]=o}i.Extensions=s}return e.Data=i,e.Signature=new Me("",{Algorithm:pi.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}sh.NAME="Certificate";class J1{static async createSelfSigned(e,t=ut.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=ut.get()){var n;let i;e.publicKey instanceof ur?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?i=e.publicKey:i=await t.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?q.toUint8Array(te.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const a=e.notBefore||new Date,o=e.notAfter||new Date(a.getTime()+31536e6),c=new ci({tbsCertificate:new Ut({version:oi.v3,serialNumber:s,validity:new ro({notBefore:a,notAfter:o}),extensions:new kn(((n=e.extensions)===null||n===void 0?void 0:n.map(A=>L.parse(A.rawData,Wt)))||[]),subjectPublicKeyInfo:L.parse(i,sr)})});if(e.subject){const A=e.subject instanceof Ht?e.subject:new Ht(e.subject);c.tbsCertificate.subject=L.parse(A.toArrayBuffer(),et)}if(e.issuer){const A=e.issuer instanceof Ht?e.issuer:new Ht(e.issuer);c.tbsCertificate.issuer=L.parse(A.toArrayBuffer(),et)}const u={hash:"SHA-256"},f="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},m=pt.resolve(hi);c.tbsCertificate.signature=c.signatureAlgorithm=m.toAsnAlgorithm(f);const B=L.serialize(c.tbsCertificate),C="signingKey"in e?await t.subtle.sign(f,e.signingKey,B):e.signature,p=pt.resolveAll(yo).reverse();let g=null;for(const A of p)if(g=A.toAsnSignature(f,C),g)break;if(!g)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=g,new sh(L.serialize(c))}}var am;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(am||(am={}));Jt.register(Lg,th);Jt.register(Fg,rh);Jt.register(Kg,nh);Jt.register(Jg,mo);Jt.register(Fl,Ca);Jt.register(Gg,S0);Jt.register(Jl,O0);Jt.register(Hl,E0);Wu.register(v0,I0);Wu.register(eh,ih);pt.registerSingleton(yo,z1);pt.registerSingleton(yo,Ft);Ft.namedCurveSize.set("P-256",32);Ft.namedCurveSize.set("K-256",32);Ft.namedCurveSize.set("P-384",48);Ft.namedCurveSize.set("P-521",66);const om="0123456789abcdef";function Qd(r){const e=new Uint8Array(r);let t="";for(let n=0;n<e.length;n++){const i=e[n]>>4;t+=om[i];const s=e[n]&15;t+=om[s]}return t}class C0{constructor(e,t){ne(this,"alphabet");ne(this,"padding");ne(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",i=0,s=0;for(let o=0;o<e.length;o++)for(i=i<<8|e[o],s+=8;s>=5;)s-=5,n+=this.alphabet[i>>s&31];if(s>0&&(n+=this.alphabet[i<<5-s&31]),(t==null?void 0:t.includePadding)??!0){const o=(8-n.length%8)%8;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let a=0;a<i;a++){let o=0;const c=[];for(let f=0;f<8;f++){const m=e[a*8+f];if(m==="="){if(a+1!==i)throw new Error(`Invalid character: ${m}`);o+=1;continue}if(m===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const B=this.decodeMap.get(m)??null;if(B===null)throw new Error(`Invalid character: ${m}`);c.push(B)}if(o===8||o===7||o===5||o===2)throw new Error("Invalid padding");const u=(c[0]<<3)+(c[1]>>2);if(s.push(u),o<6){const f=((c[1]&3)<<6)+(c[2]<<1)+(c[3]>>4);s.push(f)}if(o<4){const f=((c[3]&255)<<4)+(c[4]>>1);s.push(f)}if(o<3){const f=((c[4]&1)<<7)+(c[5]<<2)+(c[6]>>3);s.push(f)}if(o<1){const f=((c[6]&7)<<5)+c[7];s.push(f)}}return Uint8Array.from(s)}}new C0("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new C0("0123456789ABCDEFGHIJKLMNOPQRSTUV");class j0{constructor(e,t){ne(this,"alphabet");ne(this,"padding");ne(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",i=0,s=0;for(let o=0;o<e.length;o++)for(i=i<<8|e[o],s+=8;s>=6;)s+=-6,n+=this.alphabet[i>>s&63];if(s>0&&(n+=this.alphabet[i<<6-s&63]),(t==null?void 0:t.includePadding)??!0){const o=(4-n.length%4)%4;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let a=0;a<i;a++){let o=0,c=0;for(let u=0;u<4;u++){const f=e[a*4+u];if(f==="="){if(a+1!==i)throw new Error(`Invalid character: ${f}`);o+=1;continue}if(f===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const m=this.decodeMap.get(f)??null;if(m===null)throw new Error(`Invalid character: ${f}`);c+=m<<6*(3-u)}s.push(c>>16&255),o<2&&s.push(c>>8&255),o<1&&s.push(c&255)}return Uint8Array.from(s)}}const Y1=new j0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),$o=new j0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class X1{constructor(e){ne(this,"hash");this.hash=e}async verify(e,t,n){const i=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",i,t,n)}async sign(e,t){const n=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",n,t)}async generateKeyPair(e){const t=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),n=await crypto.subtle.exportKey("pkcs8",t.privateKey),i=await crypto.subtle.exportKey("spki",t.publicKey);return{privateKey:n,publicKey:i}}}async function T0(r){return await crypto.subtle.digest("SHA-256",r)}async function ef(r){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},t=await crypto.subtle.generateKey(e,!0,["sign","verify"]),n=dc(),i=Qd(new TextEncoder().encode(n)),s=await J1.createSelfSigned({serialNumber:i,name:r.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:t,extensions:[new th(!0,2,!0),new rh(["1.3.6.1.5.5.7.3.1"],!0),new nh(Fc.keyCertSign|Fc.cRLSign,!0),await mo.create(t.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",t.privateKey),o=s.toString("pem"),c=await ek(s),u=Qd(await s.getThumbprint()),f=Q1("PRIVATE",a);return{kid:s.serialNumber,cert:o,thumbprint:u,fingerprint:c,pkcs7:f}}function Q1(r,e){const t=Y1.encode(new Uint8Array(e));let n=`-----BEGIN ${r} KEY-----\r
122
+ `,i=0;for(;i<t.length;)i+64<=t.length?n+=t.substr(i,64)+`\r
123
+ `:n+=t.substr(i)+`\r
124
+ `,i+=64;return n+=`-----END ${r} KEY-----\r
125
+ `,n}async function ek(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),s=new TextEncoder().encode(n);return Qd(await T0(s))}const tk=1e3*60*60*24,rk=new dt().openapi(ve({tags:["keys"],method:"get",path:"/signing",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.array(Pl)}},description:"List of keys"}}}),async r=>{const t=(await r.env.data.keys.list()).filter(n=>"cert"in n).map(n=>n);return r.json(t)}).openapi(ve({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({kid:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Pl}},description:"The requested key"}}}),async r=>{const{kid:e}=r.req.valid("param"),n=(await r.env.data.keys.list()).find(i=>i.kid===e);if(!n)throw new ye(404,{message:"Key not found"});return r.json(n)}).openapi(ve({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const e=await r.env.data.keys.list();for await(const n of e)await r.env.data.keys.update(n.kid,{revoked_at:new Date(Date.now()+tk).toISOString()});const t=await ef({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ve({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({kid:y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const{kid:e}=r.req.valid("param");if(!await r.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new ye(404,{message:"Key not found"});const n=await ef({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),nk=new dt().openapi(ve({tags:["users"],method:"get",path:"/",request:{query:y.object({email:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:y.array(df)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),i=(await Dy(r.env.data.users,e,t)).filter(s=>!s.linked_to);return r.json(i)}),ik=jn.extend({clients:y.array(Mn)}),sk=new dt().openapi(ve({tags:["clients"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([ik,y.array(Mn)])}},description:"List of clients"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i,sort:s,q:a}=r.req.valid("query"),c=(await r.env.data.applications.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a})).applications;return i?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ve({tags:["clients"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),i=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===t);if(!i)throw new ye(404);return r.json(i)}).openapi(ve({tags:["clients"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.applications.remove(e,t))throw new ye(404,{message:"Application not found"});return r.text("OK")}).openapi(ve({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(ic.shape).partial()}}},params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),i=r.req.valid("json");await r.env.data.applications.update(e,t,i);const s=await r.env.data.applications.get(e,t);if(!s)throw new ye(404,{message:"Application not found"});return r.json(s)}).openapi(ve({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(ic.shape)}}},headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:y.object(Mn.shape)}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n={...t,id:t.id||dc(),client_secret:t.client_secret||dc()},i=await r.env.data.applications.create(e,n);return r.json(i,{status:201})});var $e;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})($e||($e={}));var tf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(tf||(tf={}));const J=$e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),on=r=>{switch(typeof r){case"undefined":return J.undefined;case"string":return J.string;case"number":return isNaN(r)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(r)?J.array:r===null?J.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?J.promise:typeof Map<"u"&&r instanceof Map?J.map:typeof Set<"u"&&r instanceof Set?J.set:typeof Date<"u"&&r instanceof Date?J.date:J.object;default:return J.unknown}},M=$e.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ak=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Zt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof Zt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Zt.create=r=>new Zt(r);const is=(r,e)=>{let t;switch(r.code){case M.invalid_type:r.received===J.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case M.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,$e.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${$e.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${$e.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${$e.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:$e.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,$e.assertNever(r)}return{message:t}};let N0=is;function ok(r){N0=r}function Kc(){return N0}const Wc=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...i,path:s,message:o}},ck=[];function K(r,e){const t=Kc(),n=Wc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===is?void 0:is].filter(i=>!!i)});r.common.issues.push(n)}class vt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return me;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,a=await i.value;n.push({key:s,value:a})}return vt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return me;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Ci=r=>({status:"dirty",value:r}),kt=r=>({status:"valid",value:r}),rf=r=>r.status==="aborted",nf=r=>r.status==="dirty",ja=r=>r.status==="valid",Ta=r=>typeof Promise<"u"&&r instanceof Promise;function zc(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function B0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ce;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ce||(ce={}));var Ns,Bs;class Ir{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const cm=(r,e)=>{if(ja(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Zt(r.common.issues);return this._error=t,this._error}}};function ke(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:i}}class Ie{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return on(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new vt,ctx:{common:e.parent.common,data:e.data,parsedType:on(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ta(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},s=this._parseSync({data:e,path:i.path,parent:i});return cm(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:on(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Ta(i)?i:Promise.resolve(i));return cm(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:M.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new hr({schema:this,typeName:he.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return kr.create(this,this._def)}nullable(){return Cn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lr.create(this,this._def)}promise(){return as.create(this,this._def)}or(e){return Pa.create([this,e],this._def)}and(e){return $a.create(this,e,this._def)}transform(e){return new hr({...ke(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Va({...ke(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new ah({typeName:he.ZodBranded,type:this,...ke(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new La({...ke(this._def),innerType:this,catchValue:t,typeName:he.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return go.create(this,e)}readonly(){return qa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const uk=/^c[^\s-]{8,}$/i,lk=/^[0-9a-z]+$/,dk=/^[0-9A-HJKMNP-TV-Z]{26}$/,fk=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,hk=/^[a-z0-9_-]{21}$/i,pk=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,mk=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ml;const gk=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vk=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,bk=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,R0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",xk=new RegExp(`^${R0}$`);function P0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function _k(r){return new RegExp(`^${P0(r)}$`)}function $0(r){let e=`${R0}T${P0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function wk(r,e){return!!((e==="v4"||!e)&&gk.test(r)||(e==="v6"||!e)&&vk.test(r))}class ar extends Ie{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.string,received:s.parsedType}),me}const n=new vt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?K(i,{code:M.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&K(i,{code:M.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")mk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"email",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")ml||(ml=new RegExp(yk,"u")),ml.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"emoji",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")fk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"uuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")hk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"nanoid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")uk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"cuid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")lk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"cuid2",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")dk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"ulid",code:M.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),K(i,{validation:"url",code:M.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"regex",code:M.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?$0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?xk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?_k(s).test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{code:M.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?pk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"duration",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?wk(e.data,s.version)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"ip",code:M.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?bk.test(e.data)||(i=this._getOrReturnCtx(e,i),K(i,{validation:"base64",code:M.invalid_string,message:s.message}),n.dirty()):$e.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new ar({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ce.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ce.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ce.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ce.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ce.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ce.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ce.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ce.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ce.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ce.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ce.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...ce.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ce.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ce.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ce.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ce.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ce.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ce.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ce.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ce.errToObj(t)})}nonempty(e){return this.min(1,ce.errToObj(e))}trim(){return new ar({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ar({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ar({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ar.create=r=>{var e;return new ar({checks:[],typeName:he.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ke(r)})};function kk(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class On extends Ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==J.number){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.number,received:s.parsedType}),me}let n;const i=new vt;for(const s of this._def.checks)s.kind==="int"?$e.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:M.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?kk(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_finite,message:s.message}),i.dirty()):$e.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,i){return new On({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(i)}]})}_addCheck(e){return new On({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ce.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ce.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ce.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ce.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&$e.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}On.create=r=>new On({checks:[],typeName:he.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ke(r)});class En extends Ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==J.bigint){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.bigint,received:s.parsedType}),me}let n;const i=new vt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),K(n,{code:M.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):$e.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,i){return new En({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(i)}]})}_addCheck(e){return new En({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ce.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}En.create=r=>{var e;return new En({checks:[],typeName:he.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ke(r)})};class Na extends Ie{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.boolean,received:n.parsedType}),me}return kt(e.data)}}Na.create=r=>new Na({typeName:he.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ke(r)});class mi extends Ie{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_type,expected:J.date,received:s.parsedType}),me}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return K(s,{code:M.invalid_date}),me}const n=new vt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),K(i,{code:M.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):$e.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new mi({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ce.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ce.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}mi.create=r=>new mi({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,...ke(r)});class Gc extends Ie{_parse(e){if(this._getType(e)!==J.symbol){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.symbol,received:n.parsedType}),me}return kt(e.data)}}Gc.create=r=>new Gc({typeName:he.ZodSymbol,...ke(r)});class Ba extends Ie{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.undefined,received:n.parsedType}),me}return kt(e.data)}}Ba.create=r=>new Ba({typeName:he.ZodUndefined,...ke(r)});class Ra extends Ie{_parse(e){if(this._getType(e)!==J.null){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.null,received:n.parsedType}),me}return kt(e.data)}}Ra.create=r=>new Ra({typeName:he.ZodNull,...ke(r)});class ss extends Ie{constructor(){super(...arguments),this._any=!0}_parse(e){return kt(e.data)}}ss.create=r=>new ss({typeName:he.ZodAny,...ke(r)});class Xn extends Ie{constructor(){super(...arguments),this._unknown=!0}_parse(e){return kt(e.data)}}Xn.create=r=>new Xn({typeName:he.ZodUnknown,...ke(r)});class Yr extends Ie{_parse(e){const t=this._getOrReturnCtx(e);return K(t,{code:M.invalid_type,expected:J.never,received:t.parsedType}),me}}Yr.create=r=>new Yr({typeName:he.ZodNever,...ke(r)});class Jc extends Ie{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.void,received:n.parsedType}),me}return kt(e.data)}}Jc.create=r=>new Jc({typeName:he.ZodVoid,...ke(r)});class lr extends Ie{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==J.array)return K(t,{code:M.invalid_type,expected:J.array,received:t.parsedType}),me;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.length<i.exactLength.value;(a||o)&&(K(t,{code:a?M.too_big:M.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(K(t,{code:M.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(K(t,{code:M.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new Ir(t,a,t.path,o)))).then(a=>vt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new Ir(t,a,t.path,o)));return vt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new lr({...this._def,minLength:{value:e,message:ce.toString(t)}})}max(e,t){return new lr({...this._def,maxLength:{value:e,message:ce.toString(t)}})}length(e,t){return new lr({...this._def,exactLength:{value:e,message:ce.toString(t)}})}nonempty(e){return this.min(1,e)}}lr.create=(r,e)=>new lr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:he.ZodArray,...ke(e)});function Ai(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=kr.create(Ai(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof lr?new lr({...r._def,type:Ai(r.element)}):r instanceof kr?kr.create(Ai(r.unwrap())):r instanceof Cn?Cn.create(Ai(r.unwrap())):r instanceof Cr?Cr.create(r.items.map(e=>Ai(e))):r}class Ye extends Ie{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=$e.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const u=this._getOrReturnCtx(e);return K(u,{code:M.invalid_type,expected:J.object,received:u.parsedType}),me}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Yr&&this._def.unknownKeys==="strip"))for(const u in i.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=s[u],m=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Ir(i,m,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Yr){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")o.length>0&&(K(i,{code:M.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Ir(i,m,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,B=await f.value;u.push({key:m,value:B,alwaysSet:f.alwaysSet})}return u}).then(u=>vt.mergeObjectSync(n,u)):vt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const c=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ce.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:he.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...this._def,catchall:e})}pick(e){const t={};return $e.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}omit(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return Ai(this)}partial(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof kr;)s=s._def.innerType;t[n]=s}}),new Ye({...this._def,shape:()=>t})}keyof(){return D0($e.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,...ke(e)});class Pa extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Zt(o.ctx.common.issues));return K(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(c=>new Zt(c));return K(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Pa.create=(r,e)=>new Pa({options:r,typeName:he.ZodUnion,...ke(e)});const Rr=r=>r instanceof Za?Rr(r.schema):r instanceof hr?Rr(r.innerType()):r instanceof Ma?[r.value]:r instanceof In?r.options:r instanceof Ua?$e.objectValues(r.enum):r instanceof Va?Rr(r._def.innerType):r instanceof Ba?[void 0]:r instanceof Ra?[null]:r instanceof kr?[void 0,...Rr(r.unwrap())]:r instanceof Cn?[null,...Rr(r.unwrap())]:r instanceof ah||r instanceof qa?Rr(r.unwrap()):r instanceof La?Rr(r._def.innerType):[];class zu extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return K(t,{code:M.invalid_type,expected:J.object,received:t.parsedType}),me;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(K(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=Rr(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new zu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...ke(n)})}}function sf(r,e){const t=on(r),n=on(e);if(r===e)return{valid:!0,data:r};if(t===J.object&&n===J.object){const i=$e.objectKeys(e),s=$e.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const c=sf(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===J.array&&n===J.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const a=r[s],o=e[s],c=sf(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return t===J.date&&n===J.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class $a extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,a)=>{if(rf(s)||rf(a))return me;const o=sf(s.value,a.value);return o.valid?((nf(s)||nf(a))&&t.dirty(),{status:t.value,value:o.data}):(K(n,{code:M.invalid_intersection_types}),me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}$a.create=(r,e,t)=>new $a({left:r,right:e,typeName:he.ZodIntersection,...ke(t)});class Cr extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return K(n,{code:M.invalid_type,expected:J.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return K(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(K(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Ir(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>vt.mergeArray(t,a)):vt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Cr({...this._def,rest:e})}}Cr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Cr({items:r,typeName:he.ZodTuple,rest:null,...ke(e)})};class Da extends Ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.object)return K(n,{code:M.invalid_type,expected:J.object,received:n.parsedType}),me;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new Ir(n,o,n.path,o)),value:a._parse(new Ir(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?vt.mergeObjectAsync(t,i):vt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ie?new Da({keyType:e,valueType:t,typeName:he.ZodRecord,...ke(n)}):new Da({keyType:ar.create(),valueType:e,typeName:he.ZodRecord,...ke(t)})}}class Yc extends Ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.map)return K(n,{code:M.invalid_type,expected:J.map,received:n.parsedType}),me;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:i._parse(new Ir(n,o,n.path,[u,"key"])),value:s._parse(new Ir(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return me;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Yc.create=(r,e,t)=>new Yc({valueType:e,keyType:r,typeName:he.ZodMap,...ke(t)});class yi extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return K(n,{code:M.invalid_type,expected:J.set,received:n.parsedType}),me;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(K(n,{code:M.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(K(n,{code:M.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return me;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>s._parse(new Ir(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new yi({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new yi({...this._def,maxSize:{value:e,message:ce.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}yi.create=(r,e)=>new yi({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,...ke(e)});class Pi extends Ie{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return K(t,{code:M.invalid_type,expected:J.function,received:t.parsedType}),me;function n(o,c){return Wc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Kc(),is].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function i(o,c){return Wc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Kc(),is].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof as){const o=this;return kt(async function(...c){const u=new Zt([]),f=await o._def.args.parseAsync(c,s).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,s).catch(C=>{throw u.addIssue(i(m,C)),u})})}else{const o=this;return kt(function(...c){const u=o._def.args.safeParse(c,s);if(!u.success)throw new Zt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,s);if(!m.success)throw new Zt([i(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Pi({...this._def,args:Cr.create(e).rest(Xn.create())})}returns(e){return new Pi({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Pi({args:e||Cr.create([]).rest(Xn.create()),returns:t||Xn.create(),typeName:he.ZodFunction,...ke(n)})}}class Za extends Ie{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Za.create=(r,e)=>new Za({getter:r,typeName:he.ZodLazy,...ke(e)});class Ma extends Ie{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return K(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ma.create=(r,e)=>new Ma({value:r,typeName:he.ZodLiteral,...ke(e)});function D0(r,e){return new In({values:r,typeName:he.ZodEnum,...ke(e)})}class In extends Ie{constructor(){super(...arguments),Ns.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{expected:$e.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(zc(this,Ns)||B0(this,Ns,new Set(this._def.values)),!zc(this,Ns).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{received:t.data,code:M.invalid_enum_value,options:n}),me}return kt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return In.create(e,{...this._def,...t})}exclude(e,t=this._def){return In.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Ns=new WeakMap;In.create=D0;class Ua extends Ie{constructor(){super(...arguments),Bs.set(this,void 0)}_parse(e){const t=$e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const i=$e.objectValues(t);return K(n,{expected:$e.joinValues(i),received:n.parsedType,code:M.invalid_type}),me}if(zc(this,Bs)||B0(this,Bs,new Set($e.getValidEnumValues(this._def.values))),!zc(this,Bs).has(e.data)){const i=$e.objectValues(t);return K(n,{received:n.data,code:M.invalid_enum_value,options:i}),me}return kt(e.data)}get enum(){return this._def.values}}Bs=new WeakMap;Ua.create=(r,e)=>new Ua({values:r,typeName:he.ZodNativeEnum,...ke(e)});class as extends Ie{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return K(t,{code:M.invalid_type,expected:J.promise,received:t.parsedType}),me;const n=t.parsedType===J.promise?t.data:Promise.resolve(t.data);return kt(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}as.create=(r,e)=>new as({type:r,typeName:he.ZodPromise,...ke(e)});class hr extends Ie{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===he.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{K(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return me;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?me:c.status==="dirty"||t.value==="dirty"?Ci(c.value):c});{if(t.value==="aborted")return me;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?me:o.status==="dirty"||t.value==="dirty"?Ci(o.value):o}}if(i.type==="refinement"){const a=o=>{const c=i.refinement(o,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ja(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ja(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);$e.assertNever(i)}}hr.create=(r,e,t)=>new hr({schema:r,typeName:he.ZodEffects,effect:e,...ke(t)});hr.createWithPreprocess=(r,e,t)=>new hr({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,...ke(t)});class kr extends Ie{_parse(e){return this._getType(e)===J.undefined?kt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kr.create=(r,e)=>new kr({innerType:r,typeName:he.ZodOptional,...ke(e)});class Cn extends Ie{_parse(e){return this._getType(e)===J.null?kt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cn.create=(r,e)=>new Cn({innerType:r,typeName:he.ZodNullable,...ke(e)});class Va extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===J.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Va.create=(r,e)=>new Va({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ke(e)});class La extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ta(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}La.create=(r,e)=>new La({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ke(e)});class Xc extends Ie{_parse(e){if(this._getType(e)!==J.nan){const n=this._getOrReturnCtx(e);return K(n,{code:M.invalid_type,expected:J.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}Xc.create=r=>new Xc({typeName:he.ZodNaN,...ke(r)});const Sk=Symbol("zod_brand");class ah extends Ie{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class go extends Ie{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),Ci(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?me:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new go({in:e,out:t,typeName:he.ZodPipeline})}}class qa extends Ie{_parse(e){const t=this._def.innerType._parse(e),n=i=>(ja(i)&&(i.value=Object.freeze(i.value)),i);return Ta(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}qa.create=(r,e)=>new qa({innerType:r,typeName:he.ZodReadonly,...ke(e)});function Z0(r,e={},t){return r?ss.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...u,fatal:c})}}):ss.create()}const Ak={object:Ye.lazycreate};var he;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(he||(he={}));const Ok=(r,e={message:`Input not instance of ${r.name}`})=>Z0(t=>t instanceof r,e),M0=ar.create,U0=On.create,Ek=Xc.create,Ik=En.create,V0=Na.create,Ck=mi.create,jk=Gc.create,Tk=Ba.create,Nk=Ra.create,Bk=ss.create,Rk=Xn.create,Pk=Yr.create,$k=Jc.create,Dk=lr.create,Zk=Ye.create,Mk=Ye.strictCreate,Uk=Pa.create,Vk=zu.create,Lk=$a.create,qk=Cr.create,Hk=Da.create,Fk=Yc.create,Kk=yi.create,Wk=Pi.create,zk=Za.create,Gk=Ma.create,Jk=In.create,Yk=Ua.create,Xk=as.create,um=hr.create,Qk=kr.create,eS=Cn.create,tS=hr.createWithPreprocess,rS=go.create,nS=()=>M0().optional(),iS=()=>U0().optional(),sS=()=>V0().optional(),aS={string:r=>ar.create({...r,coerce:!0}),number:r=>On.create({...r,coerce:!0}),boolean:r=>Na.create({...r,coerce:!0}),bigint:r=>En.create({...r,coerce:!0}),date:r=>mi.create({...r,coerce:!0})},oS=me;var Lt=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:ok,getErrorMap:Kc,makeIssue:Wc,EMPTY_PATH:ck,addIssueToContext:K,ParseStatus:vt,INVALID:me,DIRTY:Ci,OK:kt,isAborted:rf,isDirty:nf,isValid:ja,isAsync:Ta,get util(){return $e},get objectUtil(){return tf},ZodParsedType:J,getParsedType:on,ZodType:Ie,datetimeRegex:$0,ZodString:ar,ZodNumber:On,ZodBigInt:En,ZodBoolean:Na,ZodDate:mi,ZodSymbol:Gc,ZodUndefined:Ba,ZodNull:Ra,ZodAny:ss,ZodUnknown:Xn,ZodNever:Yr,ZodVoid:Jc,ZodArray:lr,ZodObject:Ye,ZodUnion:Pa,ZodDiscriminatedUnion:zu,ZodIntersection:$a,ZodTuple:Cr,ZodRecord:Da,ZodMap:Yc,ZodSet:yi,ZodFunction:Pi,ZodLazy:Za,ZodLiteral:Ma,ZodEnum:In,ZodNativeEnum:Ua,ZodPromise:as,ZodEffects:hr,ZodTransformer:hr,ZodOptional:kr,ZodNullable:Cn,ZodDefault:Va,ZodCatch:La,ZodNaN:Xc,BRAND:Sk,ZodBranded:ah,ZodPipeline:go,ZodReadonly:qa,custom:Z0,Schema:Ie,ZodSchema:Ie,late:Ak,get ZodFirstPartyTypeKind(){return he},coerce:aS,any:Bk,array:Dk,bigint:Ik,boolean:V0,date:Ck,discriminatedUnion:Vk,effect:um,enum:Jk,function:Wk,instanceof:Ok,intersection:Lk,lazy:zk,literal:Gk,map:Fk,nan:Ek,nativeEnum:Yk,never:Pk,null:Nk,nullable:eS,number:U0,object:Zk,oboolean:sS,onumber:iS,optional:Qk,ostring:nS,pipeline:rS,preprocess:tS,promise:Xk,record:Hk,set:Kk,strictObject:Mk,string:M0,symbol:jk,transformer:um,tuple:qk,undefined:Tk,union:Uk,unknown:Rk,void:$k,NEVER:oS,ZodIssueCode:M,quotelessJson:ak,ZodError:Zt});Lt.object({start:Lt.number(),limit:Lt.number(),length:Lt.number()});nu.extend({email:Lt.string(),login_count:Lt.number(),multifactor:Lt.array(Lt.string()).optional(),last_ip:Lt.string().optional(),last_login:Lt.string().optional(),user_id:Lt.string()}).catchall(Lt.any());const cS=jn.extend({tenants:y.array(Ni)}),uS=new dt().openapi(ve({tags:["tenants"],method:"get",path:"/",request:{query:ri},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:y.union([y.array(Ni),cS])}},description:"List of tenants"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),a=await r.env.data.tenants.list({page:e,per_page:t,include_totals:n,sort:cs(i),q:s});return n?r.json(a):r.json(a.tenants)}).openapi(ve({tags:["tenants"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Ni}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new ye(404);return r.json(t)}).openapi(ve({tags:["tenants"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param");return await r.env.data.tenants.remove(e),r.text("OK")}).openapi(ve({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(ac.shape).partial()}}},params:y.object({id:y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param"),t=r.req.valid("json");return await r.env.data.tenants.update(e,t),r.text("OK")}).openapi(ve({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(ac.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Ni}},description:"An tenant"}}}),async r=>{const e=r.req.valid("json"),t=await r.env.data.tenants.create(e);return r.json(t,{status:201})}),lS=jn.extend({logs:y.array(cc)}),dS=new dt().openapi(ve({tags:["logs"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(cc),lS])}},description:"List of log rows"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:i,q:s}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header"),o=await r.env.data.logs.list(a,{page:e,per_page:t,include_totals:n,sort:cs(i),q:s});return n?r.json(o):r.json(o.logs)}).openapi(ve({tags:["logs"],method:"get",path:"/{id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:cc}},description:"A log entry"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.logs.get(e,t);if(!n)throw new ye(404);return r.json(n)}),fS=jn.extend({hooks:y.array(Ei)}),hS=new dt().openapi(ve({tags:["hooks"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(Ei),fS])}},description:"List of hooks"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i,sort:s,q:a}=r.req.valid("query"),o=await r.env.data.hooks.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a});return i?r.json(o):r.json(o.hooks)}).openapi(ve({tags:["hooks"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(oc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Ei}},description:"The created hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.hooks.create(e,t);return r.json(n,{status:201})}).openapi(ve({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()}),body:{content:{"application/json":{schema:y.object(oc.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Ei.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=r.req.valid("json");await r.env.data.hooks.update(e,t,n);const i=await r.env.data.hooks.get(e,t);if(!i)throw new ye(404,{message:"Hook not found"});return r.json(i)}).openapi(ve({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ei}},description:"A hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=await r.env.data.hooks.get(e,t);if(!n)throw new ye(404,{message:"Hook not found"});return r.json(n)}).openapi(ve({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:y.object({"tenant-id":y.string()}),params:y.object({hook_id:y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param");if(!await r.env.data.hooks.remove(e,t))throw new ye(404,{message:"Hook not found"});return r.text("OK")}),pS=jn.extend({connections:y.array(Un)}),mS=new dt().openapi(ve({tags:["connections"],method:"get",path:"/",request:{query:ri,headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:y.union([y.array(Un),pS])}},description:"List of connectionss"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{page:t,per_page:n,include_totals:i=!1,sort:s,q:a}=r.req.valid("query"),o=await r.env.data.connections.list(e,{page:t,per_page:n,include_totals:i,sort:cs(s),q:a});return i?r.json(o):r.json(o.connections)}).openapi(ve({tags:["connections"],method:"get",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Un}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.connections.get(e,t);if(!n)throw new ye(404);return r.json(n)}).openapi(ve({tags:["connections"],method:"delete",path:"/{id}",request:{params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.connections.remove(e,t))throw new ye(404,{message:"Connection not found"});return r.text("OK")}).openapi(ve({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:y.object(sc.shape).partial()}}},params:y.object({id:y.string()}),headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Un}},description:"The updated connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=r.req.valid("json");if(!await r.env.data.connections.update(e,t,n))throw new ye(404,{message:"Connection not found"});const s=await r.env.data.connections.get(e,t);if(!s)throw new ye(404,{message:"Connection not found"});return r.json(s)}).openapi(ve({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:y.object(sc.shape)}}},headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Un}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.connections.create(e,t);return r.json(n,{status:201})}),yS=new dt().openapi(ve({tags:["prompts"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:jo}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.promptSettings.get(e);return t?r.json(t):r.json(jo.parse({}))}).openapi(ve({tags:["prompts"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(jo.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.promptSettings.get(e);return Object.assign(n,t),await r.env.data.promptSettings.set(e,n),r.json(n)});let lm=!1;function L0(r){r.use(async(e,t)=>(lm||(r.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),lm=!0),await t()))}y.object({alg:y.literal("RS256"),kty:y.literal("RSA"),use:y.literal("sig"),n:y.string(),e:y.string(),kid:y.string(),x5t:y.string(),x5c:y.array(y.string())});async function gS(r){try{const e=await r.JWKS_SERVICE.fetch(r.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new ye(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function vS(r,e){const n=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(c=>c.charCodeAt(0))),a=(await gS(r.env)).find(c=>c.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const o=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",o,i,n)}function bS(r){const[e,t,n]=r.split(".");if(!e||!t||!n)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(t)),a=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:a,raw:{header:e,payload:t,signature:n}}}function q0(r){return async(e,t)=>{var i,s;const n=r.openAPIRegistry.definitions.find(a=>"route"in a&&a.route.path===e.req.path&&a.route.method.toUpperCase()===e.req.method);if(n&&"route"in n){const a=(s=(i=n.route.security)==null?void 0:i[0])==null?void 0:s.Bearer,o=e.req.header("authorization")||"",[c,u]=o.split(" ");if((c==null?void 0:c.toLowerCase())!=="bearer"||!u)throw new ye(401,{message:"Missing bearer token"});const f=bS(u);if(!f||!await vS(e,f))throw new ye(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub);const m=f.payload.permissions||[];if(a!=null&&a.length&&!a.some(B=>m.includes(B)))throw new ye(403,{message:"Unauthorized"})}return await t()}}const xS=new dt().openapi(ve({tags:["emails"],method:"get",path:"/",request:{headers:y.object({"tenant-id":y.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:To}},description:"Email provider"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.emailProviders.get(e);if(!t)throw new ye(404,{message:"Email provider not found"});return r.json(t)}).openapi(ve({tags:["emails"],method:"post",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(To.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.create(e,t),r.text("OK",{status:201})}).openapi(ve({tags:["emails"],method:"patch",path:"/",request:{headers:y.object({"tenant-id":y.string()}),body:{content:{"application/json":{schema:y.object(To.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.emailProviders.update(e,t),r.text("OK")});function _S(){const r=new dt;r.use(q0(r));const e=r.route("/branding",P_).route("/email/providers",xS).route("/users",rw).route("/keys",rk).route("/users-by-email",nk).route("/clients",sk).route("/tenants",uS).route("/logs",dS).route("/hooks",hS).route("/connections",mS).route("/prompts",yS);return L0(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}const So=60*5,wS=30*24*60*60,kS="auth-token",SS=new dt().openapi(ve({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Ay}},description:"List of tenants"}}}),async r=>{const e=await r.env.data.keys.list(),t=await Promise.all(e.map(async n=>{const s=await new sh(n.cert).publicKey.export(),a=await crypto.subtle.exportKey("jwk",s);return mf.parse({...a,kid:n.kid})}));return r.json({keys:t},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})}).openapi(ve({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Rl}},description:"List of tenants"}}}),async r=>{const e=r.env.ISSUER,t=Rl.parse({issuer:e,authorization_endpoint:`${e}authorize`,token_endpoint:`${e}oauth/token`,device_authorization_endpoint:`${e}oauth/device/code`,userinfo_endpoint:`${e}userinfo`,mfa_challenge_endpoint:`${e}mfa/challenge`,jwks_uri:`${e}.well-known/jwks.json`,registration_endpoint:`${e}oidc/register`,revocation_endpoint:`${e}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return r.json(t,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${So}, stale-while-revalidate=${So*2}, stale-if-error=86400`}})});class Qc{constructor(e,t){ne(this,"value");ne(this,"unit");this.value=e,this.unit=t}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Qc(Math.round(this.milliseconds()*e),"ms")}}async function dm(r,e,t,n){const i={alg:r,typ:"JWT",...n==null?void 0:n.headers},s={...t};(n==null?void 0:n.audiences)!==void 0&&(s.aud=n.audiences),(n==null?void 0:n.subject)!==void 0&&(s.sub=n.subject),(n==null?void 0:n.issuer)!==void 0&&(s.iss=n.issuer),(n==null?void 0:n.jwtId)!==void 0&&(s.jti=n.jwtId),(n==null?void 0:n.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+n.expiresIn.seconds()),(n==null?void 0:n.notBefore)!==void 0&&(s.nbf=Math.floor(n.notBefore.getTime()/1e3)),(n==null?void 0:n.includeIssuedTimestamp)===!0&&(s.iat=Math.floor(Date.now()/1e3));const a=new TextEncoder,o=$o.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),c=$o.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),u=a.encode([o,c].join(".")),f=await AS(r).sign(e,u),m=$o.encode(new Uint8Array(f),{includePadding:!1});return[o,c,m].join(".")}function AS(r){return new X1(OS[r])}const OS={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function ES(r){try{const t=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(r);if(!t||!t[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(t[1].replace(/\s/g,"")),n=>n.charCodeAt(0)).buffer}finally{r=r.replace(/./g,"\0")}}async function IS(r,e){if(e==="plain")return r;const t=new TextEncoder().encode(r),n=await T0(t);return $o.encode(new Uint8Array(n))}async function H0(r,e){var m;const{authParams:t,user:n,sid:i}=e,a=(await r.env.data.keys.list()).filter(B=>!B.revoked_at||new Date(B.revoked_at)>new Date),o=a[a.length-1];if(!(o!=null&&o.pkcs7))throw new ye(500,{message:"No signing key available"});const c=ES(o.pkcs7),u=await dm("RS256",c,{aud:t.audience||"default",scope:t.scope||"",sub:(n==null?void 0:n.user_id)||t.client_id,iss:r.env.ISSUER,tenant_id:r.var.tenant_id,sid:i},{includeIssuedTimestamp:!0,expiresIn:new Qc(1,"d"),headers:{kid:o.kid}}),f=n&&((m=t.scope)!=null&&m.split(" ").includes("openid"))?await dm("RS256",c,{aud:t.client_id,sub:n.user_id,iss:r.env.ISSUER,sid:i,nonce:t.nonce,given_name:n.given_name,family_name:n.family_name,nickname:n.nickname,picture:n.picture,locale:n.locale,name:n.name,email:n.email,email_verified:n.email_verified},{includeIssuedTimestamp:!0,expiresIn:new Qc(1,"d"),headers:{kid:o.kid}}):void 0;return{access_token:u,id_token:f,token_type:"Bearer",expires_in:86400}}function Do(r,e){if(!r||!e||r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}const F0=y.object({grant_type:y.literal("client_credentials"),scope:y.string().optional(),client_secret:y.string(),client_id:y.string(),audience:y.string().optional()});async function CS(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new ye(403,{message:"Invalid client credentials"});if(t.client_secret&&!Do(t.client_secret,e.client_secret))throw new ye(403,{message:"Invalid client credentials"});const n={client_id:t.id,scope:e.scope,audience:e.audience},i=await H0(r,{authParams:n});return r.json(i)}function jS(r,e,t){const n=[];return n.push([encodeURIComponent(r),encodeURIComponent(e)]),(t==null?void 0:t.domain)!==void 0&&n.push(["Domain",t.domain]),(t==null?void 0:t.expires)!==void 0&&n.push(["Expires",t.expires.toUTCString()]),n.push(["HttpOnly"]),(t==null?void 0:t.maxAge)!==void 0&&n.push(["Max-Age",t.maxAge.toString()]),(t==null?void 0:t.path)!==void 0&&n.push(["Path",t.path]),n.push(["SameSite","None"]),n.push(["Secure"]),n.map(i=>i.join("=")).join("; ")}const TS=y.object({grant_type:y.literal("authorization_code"),client_id:y.string(),code:y.string(),redirect_uri:y.string().optional(),client_secret:y.string().optional(),code_verifier:y.string().optional()}).refine(r=>"client_secret"in r&&!("code_verifier"in r)||!("client_secret"in r)&&"code_verifier"in r,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function NS(r,e){const t=await r.env.data.clients.get(e.client_id);if(!t)throw new ye(403,{message:"Invalid client"});const n=await r.env.data.codes.get(t.tenant.id,e.code,"authorization_code");if(!n||!n.user_id)throw new ye(403,{message:"Invalid client credentials"});if(new Date(n.expires_at)<new Date)throw new ye(403,{message:"Code expired"});const i=await r.env.data.logins.get(t.tenant.id,n.login_id);if(!i)throw new ye(403,{message:"Invalid login"});if("client_secret"in e){const c=await r.env.data.clients.get("DEFAULT_CLIENT");if(console.log("defaultClient",JSON.stringify(c)),!Do(t.client_secret,e.client_secret)&&!Do(c==null?void 0:c.client_secret,e.client_secret))throw new ye(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"){const c=await IS(e.code_verifier,i.authParams.code_challenge_method);if(!Do(c,i.authParams.code_challenge||""))throw new ye(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new ye(403,{message:"Invalid redirect uri"});const s=await r.env.data.users.get(t.tenant.id,n.user_id);if(!s)throw new ye(403,{message:"User not found"});await r.env.data.codes.remove(t.tenant.id,e.code);const a=await r.env.data.sessions.create(t.tenant.id,{session_id:dc(),user_id:s.user_id,client_id:t.id,expires_at:new Date(Date.now()+wS*1e3).toISOString(),used_at:new Date().toISOString()}),o=await H0(r,{authParams:i.authParams,user:s,sid:a.session_id});return r.json(o,{headers:{"set-cookie":jS(`${t.tenant.id}-${kS}`,a.session_id,{path:"/",httpOnly:!0,secure:!0,maxAge:60*60*24*7,sameSite:"none"})}})}const fm=y.object({client_id:y.string().optional(),client_secret:y.string().optional()}),BS=y.union([F0.extend(fm.shape),y.object({grant_type:y.literal("authorization_code"),client_id:y.string(),code:y.string(),redirect_uri:y.string(),code_verifier:y.string().min(43).max(128)}),y.object({grant_type:y.literal("authorization_code"),code:y.string(),redirect_uri:y.string().optional(),...fm.shape})]);function RS(r){if(!r)return{};const[e,t]=r.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&t){const[n,i]=atob(t).split(":");return{client_id:n,client_secret:i}}return{}}const PS=new dt().openapi(ve({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:BS}}}},responses:{200:{content:{"application/json":{schema:y.object({access_token:y.string(),id_token:y.string().optional(),refresh_token:y.string().optional(),token_type:y.string(),expires_in:y.number()})}},description:"Tokens"}}}),async r=>{const e=r.req.valid("form"),t=RS(r.req.header("Authorization")),n={...e,...t};if(!n.client_id)throw new ye(400,{message:"client_id is required"});switch(e.grant_type){case uc.AuthorizationCode:return NS(r,TS.parse(n));case uc.ClientCredential:return CS(r,F0.parse(n));default:throw new ye(400,{message:"Not implemented"})}});function $S(){const r=new dt;r.use(q0(r));const e=new dt().route("/.well-known",SS).route("/oauth/token",PS);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),L0(e),e}function DS(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await J_({userAdapter:r.users,tenant_id:e,email:t.email});return n?(await r.users.create(e,{...t,linked_to:n.user_id}),n):r.users.create(e,t)}}async function ZS(r,e,t){for await(const n of e)if(!(await fetch(n.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok){const s=Zy(r,{type:iu.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,s)}}function MS(r,e){return async(t,n)=>{const{hooks:i}=await e.hooks.list(t,{q:"trigger_id:post-user-registration",page:0,per_page:100,include_totals:!1});return await ZS(r,i,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function US(r,e){return async(t,n)=>{let i=await DS(e)(t,n);return await MS(r,e)(t,i),i}}function VS(r,e){return{...e,users:{...e.users,create:US(r,e)}}}function LS(r){const e=new dt;e.use(async(i,s)=>(i.env.data=VS(i,r.dataAdapter),s())),e.get("/",i=>i.json({name:"authhero"}));const t=_S();e.route("/api/v2",t);const n=$S();return e.route("/",n),{app:e,managementApp:t,oauthApp:n,createX509Certificate:ef}}exports.Auth0Client=Ey;exports.AuthorizationResponseMode=hf;exports.AuthorizationResponseType=ff;exports.CodeChallengeMethod=pf;exports.GrantType=uc;exports.LogTypes=iu;exports.applicationInsertSchema=ic;exports.applicationSchema=Mn;exports.auth0UserResponseSchema=vr;exports.authParamsSchema=_y;exports.baseUserSchema=nu;exports.bordersSchema=jy;exports.brandingSchema=Bl;exports.codeInsertSchema=ky;exports.codeSchema=I_;exports.codeTypeSchema=wy;exports.colorsSchema=Ty;exports.connectionInsertSchema=sc;exports.connectionSchema=Un;exports.domainInsertSchema=Sy;exports.domainSchema=C_;exports.emailProviderSchema=To;exports.fontDetailsSchema=Dn;exports.fontsSchema=Ny;exports.hookInsertSchema=oc;exports.hookSchema=Ei;exports.identitySchema=by;exports.init=LS;exports.jwksKeySchema=Ay;exports.jwksSchema=mf;exports.logSchema=cc;exports.loginInsertSchema=Oy;exports.loginSchema=j_;exports.openIDConfigurationSchema=Rl;exports.pageBackgroundSchema=By;exports.parseUserId=R_;exports.passwordInsertSchema=Iy;exports.passwordSchema=N_;exports.profileDataSchema=vy;exports.promptSettingSchema=jo;exports.samlpAddon=xy;exports.sessionInsertSchema=Cy;exports.sessionSchema=yf;exports.signingKeySchema=Pl;exports.tenantInsertSchema=ac;exports.tenantSchema=Ni;exports.themeInsertSchema=Py;exports.themeSchema=B_;exports.totalsSchema=jn;exports.userInsertSchema=nc;exports.userResponseSchema=k_;exports.userSchema=df;exports.vendorSettingsSchema=O_;exports.widgetSchema=Ry;