authhero 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authhero.cjs +14 -14
- package/dist/authhero.d.ts +244 -24
- package/dist/authhero.mjs +3560 -3431
- package/package.json +3 -3
package/dist/authhero.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var z0=Object.defineProperty;var fh=r=>{throw TypeError(r)};var G0=(r,e,t)=>e in r?z0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var se=(r,e,t)=>G0(r,typeof e!="symbol"?e+"":e,t),Wu=(r,e,t)=>e.has(r)||fh("Cannot "+t);var w=(r,e,t)=>(Wu(r,e,"read from private field"),t?t.call(r):e.get(r)),Ae=(r,e,t)=>e.has(r)?fh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Wu(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),je=(r,e,t)=>(Wu(r,e,"access private method"),t);var hh=(r,e,t,n)=>({set _(s){ue(r,e,s,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ai(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 we(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function J0(r){return"_def"in r}function xi(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 Y0(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const R=typeof s=="string"?i:s,C=R??{},{param:p}=C,y=Ai(C,["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),y),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),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(we(this,"ZodObject")){const N=this.extend;P.extend=function(...ve){var Le,qe,Ze,tt,pt,Rt;const I=N.apply(this,ve);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}:(pt=this._def.openapi)===null||pt===void 0?void 0:pt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xi(r,"optional"),xi(r,"nullable"),xi(r,"default"),xi(r,"transform"),xi(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}function Po(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=>Po(r[n],e[n]))}class X0{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=>Po(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>Po(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 Ri(r){return r==null}function Pi(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function Q0(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function js(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function ph(r){return r.filter(e=>!Ri(e))}const ll=Po;function ev(r){const e=new X0;return r.forEach(t=>e.put(t)),[...e.values()]}function gm(r){return typeof r=="string"}class tv{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 Gc{constructor(e){this.message=e}}class _i extends Gc{constructor(e,t){super(e),this.data=t}}class $o extends Gc{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 wi(r,e){try{return r()}catch(t){throw t instanceof $o?new $o(Object.assign(Object.assign({},t.data),e)):t}}class rv extends Gc{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class Ke{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 js(Q0(e,["param"]),Ri)}static buildParameterMetadata(e){return js(e,Ri)}static applySchemaMetadata(e,t){return js(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Ri)}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&&we(e,t)?e:we(e,"ZodOptional")||we(e,"ZodNullable")||we(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):we(e,"ZodDefault")||we(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):we(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):we(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return we(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class nv{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 sv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class iv{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=>Ke.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=Ke.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(we(c,"ZodEnum")||we(c,"ZodNativeEnum")){Object.values(c.enum).filter(gm).forEach(m=>{s[m]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class av{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class ov{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!we(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class cv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function uv(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 lv{transform(e,t){const{type:n,values:s}=uv(e._def.values);if(n==="mixed")throw new Gc("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 dv{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class fv{transform(e,t,n,s){var i;const a=(i=Ke.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=Pi(e._def.shape(),s);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=a.schema;s(u);const f=this.requiredKeysOf(u),m=Pi(u==null?void 0:u._def.shape(),s),R=Object.fromEntries(Object.entries(c).filter(([y,A])=>!ll(m[y],A))),C=o.filter(y=>!f.includes(y)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:R}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return we(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!Ke.isOptionalSchema(n)).map(([t,n])=>t)}}class hv{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(we(i,"ZodEnum")||we(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter(gm).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 pv{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 mv{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 yv{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 we(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return we(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class gv{constructor(e){this.versionSpecifics=e,this.objectTransformer=new fv,this.stringTransformer=new pv,this.numberTransformer=new dv,this.bigIntTransformer=new sv,this.literalTransformer=new cv,this.enumTransformer=new av,this.nativeEnumTransformer=new lv,this.arrayTransformer=new nv,this.unionTransformer=new yv,this.discriminatedUnionTransformer=new iv,this.intersectionTransformer=new ov,this.recordTransformer=new hv,this.tupleTransformer=new mv(e)}transform(e,t,n,s,i){if(we(e,"ZodNull"))return this.versionSpecifics.nullType;if(we(e,"ZodUnknown")||we(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(we(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(we(e,"ZodUnknown")||we(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(we(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(we(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(we(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(we(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(we(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(we(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(we(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(we(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=Ke.getRefId(e);throw new rv({currentSchema:e._def,schemaName:i})}}class vm{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new gv(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=Ke.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 _i(`Conflicting location for parameter ${u.name}`,{key:"in",values:ph([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 _i("Conflicting names for parameter",{key:"name",values:ph([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=Ke.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(we(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,R;const C=Ke.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const y=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(y!=null&&y.name&&y.name!==u)throw new _i("Conflicting names for parameter",{key:"name",values:[u,y.name]});if(y!=null&&y.in&&y.in!==t)throw new _i(`Conflicting location for parameter ${(R=y.name)!==null&&R!==void 0?R:u}`,{key:"in",values:[t,y.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(i!=null&&i.in&&i.in!==t)throw new _i(`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=Ke.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!Ke.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?Ke.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=Ke.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 $o({missingField:"name"});if(!a)throw new $o({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=Ke.unwrapChained(e),s=Ke.getMetadata(e),i=Ke.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?Ke.applySchemaMetadata(a,s.metadata):js(a,Ri)}constructReferencedOpenAPISchema(e){var t;const n=Ke.getMetadata(e),s=Ke.unwrapChained(e),i=Ke.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=Ke.getMetadata(e),s=Ke.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=js(Ke.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||ll(f,i[m]));if(o.type)return{allOf:[a,o]};const c=js(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||ll(f,i[m])),u=Ke.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=Ke.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=Ai(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=wi(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=wi(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=wi(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=wi(()=>{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 we(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=Ai(e,["method","path","request","responses"]),o=Pi(i,m=>this.getResponse(m)),c=wi(()=>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=Ai(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=we(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 Pi(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return Pi(e,t=>{if(!t||!J0(t.schema))return t;const{schema:n}=t,s=Ai(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 vv{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=ev(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 bv{constructor(e){const t=new vv;this.generator=new vm(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class xv{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 _v(r){return"type"in r&&r.type==="webhook"}class wv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new xv;this.generator=new vm(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(_v).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 bm=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},kv=r=>{const{groups:e,path:t}=Sv(r),n=bm(t);return Av(n,e)},Sv=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},Av=(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},bo={},mh=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},xm=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},Ov=r=>xm(r,decodeURI),_m=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 Ov(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},Ev=r=>{const e=_m(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},wm=r=>{if(!r.match(/\:.+\?$/))return null;const e=r.split("/"),t=[];let n="";return e.forEach(s=>{if(s!==""&&!/\:/.test(s))n+="/"+s;else if(/\:/.test(s))if(/\?/.test(s)){t.length===0&&n===""?t.push("/"):t.push(n);const i=s.replace("?","");n+="/"+i,t.push(n)}else n+="/"+s}),t.filter((s,i,a)=>a.indexOf(s)===i)},Ku=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?Qd(r):r):r,km=(r,e,t)=>{let n;if(!t&&e&&!/[%+]/.test(e)){let a=r.indexOf(`?${e}`,8);for(a===-1&&(a=r.indexOf(`&${e}`,8));a!==-1;){const o=r.charCodeAt(a+e.length+1);if(o===61){const c=a+e.length+2,u=r.indexOf("&",c);return Ku(r.slice(c,u===-1?void 0:u))}else if(o==38||isNaN(o))return"";a=r.indexOf(`&${e}`,a+1)}if(n=/[%+]/.test(r),!n)return}const s={};n??(n=/[%+]/.test(r));let i=r.indexOf("?",8);for(;i!==-1;){const a=r.indexOf("&",i+1);let o=r.indexOf("=",i);o>a&&a!==-1&&(o=-1);let c=r.slice(i+1,o===-1?a===-1?void 0:a:o);if(n&&(c=Ku(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=Ku(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},Iv=km,Cv=(r,e)=>km(r,e,!0),Qd=decodeURIComponent,jv=/^[\w!#$%&'*.^`|~+-]+$/,Tv=/^[ !#-:<-[\]-~]*$/,Nv=(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(!jv.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Tv.test(o)&&(n[a]=Qd(o))}return n},Bv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Nv(n):{}},De=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});se(this,"res");se(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})}},Rv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),Pv=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,$v=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Zv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Dv=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!Pv.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new De(400,{message:o})}break;case"form":{if(!i||!($v.test(i)||Zv.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 Rv(u,i),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new De(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),s=c;break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=Bv(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xs=(r,e,t)=>Dv(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 Mv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof Sm?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")?Vv(r,{all:t,dot:n}):{}};async function Vv(r,e){const t=await r.formData();return t?Uv(t,e):{}}function Uv(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?Lv(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(qv(t,n,s),delete t[n])}),t}var Lv=(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 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])})},yh=r=>xm(r,Qd),$s,tr,Xr,Am,Om,dl,cn,cm,Sm=(cm=class{constructor(r,e="/",t=[[]]){Ae(this,Xr);se(this,"raw");Ae(this,$s);Ae(this,tr);se(this,"routeIndex",0);se(this,"path");se(this,"bodyCache",{});Ae(this,cn,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,ue(this,tr,t),ue(this,$s,{})}param(r){return r?je(this,Xr,Am).call(this,r):je(this,Xr,Om).call(this)}query(r){return Iv(this.url,r)}queries(r){return Cv(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 Mv(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,$s)[r]=e}valid(r){return w(this,$s)[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}},$s=new WeakMap,tr=new WeakMap,Xr=new WeakSet,Am=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=je(this,Xr,dl).call(this,e);return t?/\%/.test(t)?yh(t):t:void 0},Om=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=je(this,Xr,dl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?yh(n):n)}return r},dl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,cm),Hv={Stringify:1,BeforeStream:2,Stream:3},Em=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=>Em(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},Fv="text/plain; charset=UTF-8",zu=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Zr,Wa,Zs,Ds,Ka,za,At,Ut,um,Im=(um=class{constructor(r,e){Ae(this,At);Ae(this,Ha);Ae(this,Fa);se(this,"env",{});Ae(this,Pr);se(this,"finalized",!1);se(this,"error");Ae(this,qn,200);Ae(this,$r);Ae(this,Ge);Ae(this,Qe);Ae(this,br);Ae(this,Zr,!0);Ae(this,Wa);Ae(this,Zs);Ae(this,Ds);Ae(this,Ka);Ae(this,za);se(this,"render",(...r)=>(w(this,Zs)??ue(this,Zs,e=>this.html(e)),w(this,Zs).call(this,...r)));se(this,"setLayout",r=>ue(this,Wa,r));se(this,"getLayout",()=>w(this,Wa));se(this,"setRenderer",r=>{ue(this,Zs,r)});se(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,Zr,!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))});se(this,"status",r=>{ue(this,Zr,!1),ue(this,qn,r)});se(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});se(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);se(this,"newResponse",(...r)=>je(this,At,Ut).call(this,...r));se(this,"body",(r,e,t)=>typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e));se(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Zr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=Fv,typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e)});se(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"?je(this,At,Ut).call(this,n,e,t):je(this,At,Ut).call(this,n,e)});se(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Em(r,Hv.Stringify,!1,{}).then(n=>typeof e=="number"?je(this,At,Ut).call(this,n,e,t):je(this,At,Ut).call(this,n,e)):typeof e=="number"?je(this,At,Ut).call(this,r,e,t):je(this,At,Ut).call(this,r,e)));se(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));se(this,"notFound",()=>(w(this,Ds)??ue(this,Ds,()=>new Response),w(this,Ds).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Ds,e.notFoundHandler),ue(this,za,e.path),ue(this,Ka,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Sm(w(this,Ha),w(this,za),w(this,Ka))),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,Zr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Zr,!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 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}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,Zr=new WeakMap,Wa=new WeakMap,Zs=new WeakMap,Ds=new WeakMap,Ka=new WeakMap,za=new WeakMap,At=new WeakSet,Ut=function(r,e,t){if(w(this,Zr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const s=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=zu(s,w(this,Qe));return new Response(r,{headers:i,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),zu(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=w(this,Ge))==null||a.append(i,s):(o=w(this,Ge))==null||o.set(i,s)}),zu(w(this,Ge),w(this,Qe))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")w(this,Ge).set(s,i);else{w(this,Ge).delete(s);for(const a of i)w(this,Ge).append(s,a)}return new Response(r,{status:n,headers:w(this,Ge)})},um),gh=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof Im;return o(0);async function o(c){if(c<=i)throw new Error("next() called multiple times");i=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&s||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(R){if(R instanceof Error&&a&&e)n.error=R,u=await e(R,n),f=!0;else throw R}return u&&(n.finalized===!1||f)&&(n.res=u),n}},st="ALL",Wv="all",Kv=["get","post","put","delete","options","patch"],Cm="Can not add a route since the matcher is already built.",jm=class extends Error{},zv=Symbol("composedHandler"),Gv=r=>r.text("404 Not Found",404),vh=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,it,Nm,Dr,Pn,Ao,Oo,lm,Tm=(lm=class{constructor(e={}){Ae(this,it);se(this,"get");se(this,"post");se(this,"put");se(this,"delete");se(this,"options");se(this,"patch");se(this,"all");se(this,"on");se(this,"use");se(this,"router");se(this,"getPath");se(this,"_basePath","/");Ae(this,rr,"/");se(this,"routes",[]);Ae(this,Dr,Gv);se(this,"errorHandler",vh);se(this,"onError",e=>(this.errorHandler=e,this));se(this,"notFound",e=>(ue(this,Dr,e),this));se(this,"fetch",(e,...t)=>je(this,it,Oo).call(this,e,t[1],t[0],e.method));se(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${nn("/",e)}`,t),n,s)));se(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(je(this,it,Oo).call(this,e.request,e,void 0,e.request.method))})});[...Kv,Wv].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?ue(this,rr,i):je(this,it,Pn).call(this,s,w(this,rr),i),a.forEach(o=>{je(this,it,Pn).call(this,s,w(this,rr),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){ue(this,rr,o);for(const c of[s].flat())a.map(u=>{je(this,it,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?ue(this,rr,s):(ue(this,rr,"*"),i.unshift(s)),i.forEach(a=>{je(this,it,Pn).call(this,st,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??_m:Ev}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{var a;let i;t.errorHandler===vh?i=s.handler:(i=async(o,c)=>(await gh([],t.errorHandler)(o,()=>s.handler(o,c))).res,i[zv]=s.handler),je(a=n,it,Pn).call(a,s.method,s.path,i)}),this}basePath(e){const t=je(this,it,Nm).call(this);return t._basePath=nn(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=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(s(c.req.raw),...a(c));if(f)return f;await u()};return je(this,it,Pn).call(this,st,nn(e,"*"),o),this}},rr=new WeakMap,it=new WeakSet,Nm=function(){const e=new Tm({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Dr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await je(this,it,Oo).call(this,e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.router.match(s,i),o=new Im(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Dr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Dr).call(this,o)})}catch(f){return je(this,it,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Dr).call(this,o))).catch(f=>je(this,it,Ao).call(this,f,o)):u??w(this,Dr).call(this,o)}const c=gh(a[0],this.errorHandler,w(this,Dr));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 je(this,it,Ao).call(this,u,o)}})()},lm),Zo="[^/]+",$i=".*",Zi="(?:|/.*)",Oi=Symbol(),Jv=new Set(".\\+*[^]$()");function Yv(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$i||r===Zi?1:e===$i||e===Zi?-1:r===Zo?1:e===Zo?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,dm,fl=(dm=class{constructor(){Ae(this,Hn);Ae(this,Fn);Ae(this,nr,Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(w(this,Hn)!==void 0)throw Oi;if(i)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$i]:["","",Zo]:a==="/*"?["","",Zi]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Zo;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Oi;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(R=>R!==$i&&R!==Zi))throw Oi;if(i)return;u=w(this,nr)[m]=new fl,f!==""&&ue(u,Fn,s.varIndex++)}!i&&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!==$i&&f!==Zi))throw Oi;if(i)return;u=w(this,nr)[a]=new fl}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(Yv).map(n=>{const s=w(this,nr)[n];return(typeof w(s,Fn)=="number"?`(${n})@${w(s,Fn)}`:Jv.has(n)?`\\${n}`:n)+s.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,dm),zc,Ga,fm,Xv=(fm=class{constructor(){Ae(this,zc,{varIndex:0});Ae(this,Ga,new fl)}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 w(this,Ga).insert(i,e,n,w(this,zc),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,(s,i,a)=>i!==void 0?(t[++e]=Number(i),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},zc=new WeakMap,Ga=new WeakMap,fm),Bm=[],Qv=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Rm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function eb(){Eo=Object.create(null)}function tb(r){var u;const e=new Xv,t=[];if(r.length===0)return Qv;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[R,C])=>f?1:R?-1:m.length-C.length),s=Object.create(null);for(let f=0,m=-1,R=n.length;f<R;f++){const[C,p,y]=n[f];C?s[p]=[y.map(([O])=>[O,Object.create(null)]),Bm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Oi?new jm(p):O}C||(t[m]=y.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[ve,Le]=A[P];N[ve]=Le}return[O,N]}))}const[i,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let R=0,C=t[f].length;R<C;R++){const p=(u=t[f][R])==null?void 0:u[1];if(!p)continue;const y=Object.keys(p);for(let A=0,O=y.length;A<O;A++)p[y[A]]=o[p[y[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[i,c,s]}function _s(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(Rm(t).test(e))return[...r[t]]}}var un,ln,oi,Pm,$m,hm,rb=(hm=class{constructor(){Ae(this,oi);se(this,"name","RegExpRouter");Ae(this,un);Ae(this,ln);ue(this,un,{[st]:Object.create(null)}),ue(this,ln,{[st]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),s=w(this,ln);if(!n||!s)throw new Error(Cm);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[st]).forEach(u=>{c[r][u]=[...c[st][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Rm(e);r===st?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_s(n[u],e)||_s(n[st],e)||[])}):(o=n[r])[e]||(o[e]=_s(n[r],e)||_s(n[st],e)||[]),Object.keys(n).forEach(u=>{(r===st||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,i])})}),Object.keys(s).forEach(u=>{(r===st||r===u)&&Object.keys(s[u]).forEach(f=>c.test(f)&&s[u][f].push([t,i]))});return}const a=wm(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(s).forEach(m=>{var R;(r===st||r===m)&&((R=s[m])[f]||(R[f]=[..._s(n[m],f)||_s(n[st],f)||[]]),s[m][f].push([t,i-u+c+1]))})}}match(r,e){eb();const t=je(this,oi,Pm).call(this);return this.match=(n,s)=>{const i=t[n]||t[st],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],Bm];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,oi=new WeakSet,Pm=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=je(this,oi,$m).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},$m=function(r){const e=[];let t=r===st;return[w(this,un),w(this,ln)].forEach(n=>{const s=n[r]?Object.keys(n[r]).map(i=>[i,n[r][i]]):[];s.length!==0?(t||(t=!0),e.push(...s)):r!==st&&e.push(...Object.keys(n[st]).map(i=>[i,n[st][i]]))}),t?tb(e):null},hm),dn,Mr,pm,nb=(pm=class{constructor(r){se(this,"name","SmartRouter");Ae(this,dn,[]);Ae(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(Cm);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),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 jm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(i===s)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,pm),fn,vt,Wn,Ms,Ot,Vr,$n,mm,Zm=(mm=class{constructor(r,e,t){Ae(this,Vr);Ae(this,fn);Ae(this,vt);Ae(this,Wn);Ae(this,Ms,0);Ae(this,Ot,Object.create(null));if(ue(this,vt,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,Wn,[])}insert(r,e,t){ue(this,Ms,++hh(this,Ms)._);let n=this;const s=kv(e),i=[];for(let c=0,u=s.length;c<u;c++){const f=s[c];if(Object.keys(w(n,vt)).includes(f)){n=w(n,vt)[f];const R=mh(f);R&&i.push(R[1]);continue}w(n,vt)[f]=new Zm;const m=mh(f);m&&(w(n,Wn).push(m),i.push(m[1])),n=w(n,vt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:i.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Ms)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Ot,Object.create(null));let s=[this];const i=bm(e);for(let o=0,c=i.length;o<c;o++){const u=i[o],f=o===c-1,m=[];for(let R=0,C=s.length;R<C;R++){const p=s[R],y=w(p,vt)[u];y&&(ue(y,Ot,w(p,Ot)),f?(w(y,vt)["*"]&&t.push(...je(this,Vr,$n).call(this,w(y,vt)["*"],r,w(p,Ot),Object.create(null))),t.push(...je(this,Vr,$n).call(this,y,r,w(p,Ot),Object.create(null)))):m.push(y));for(let A=0,O=w(p,Wn).length;A<O;A++){const P=w(p,Wn)[A],N={...w(p,Ot)};if(P==="*"){const pt=w(p,vt)["*"];pt&&(t.push(...je(this,Vr,$n).call(this,pt,r,w(p,Ot),Object.create(null))),m.push(pt));continue}if(u==="")continue;const[ve,Le,qe]=P,Ze=w(p,vt)[ve],tt=i.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...je(this,Vr,$n).call(this,Ze,r,w(p,Ot),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...je(this,Vr,$n).call(this,Ze,r,N,w(p,Ot))),w(Ze,vt)["*"]&&t.push(...je(this,Vr,$n).call(this,w(Ze,vt)["*"],r,N,w(p,Ot)))):(ue(Ze,Ot,N),m.push(Ze)))}}s=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,vt=new WeakMap,Wn=new WeakMap,Ms=new WeakMap,Ot=new WeakMap,Vr=new WeakSet,$n=function(r,e,t,n){const s=[];for(let i=0,a=w(r,fn).length;i<a;i++){const o=w(r,fn)[i],c=o[e]||o[st],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const R=c.possibleKeys[f],C=u[c.score];c.params[R]=n[R]&&!C?n[R]:t[R]??n[R],u[c.score]=!0}s.push(c)}}return s},mm),Kn,ym,sb=(ym=class{constructor(){se(this,"name","TrieRouter");Ae(this,Kn);ue(this,Kn,new Zm)}add(r,e,t){const n=wm(e);if(n){for(let s=0,i=n.length;s<i;s++)w(this,Kn).insert(r,n[s],t);return}w(this,Kn).insert(r,e,t)}match(r,e){return w(this,Kn).search(r,e)}},Kn=new WeakMap,ym),ib=class extends Tm{constructor(r={}){super(r),this.router=r.router??new nb({routers:[new rb,new sb]})}},Be;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Be||(Be={}));var hl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(hl||(hl={}));const z=Be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),sn=r=>{switch(typeof r){case"undefined":return 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}},Z=Be.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ab=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class Dm 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 Dm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Vs=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Be.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Be.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Be.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Be.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,Be.assertNever(r)}return{message:t}};let Mm=Vs;function ob(r){Mm=r}function Do(){return Mm}const Mo=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}},cb=[];function H(r,e){const t=Do(),n=Mo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Vs?void 0:Vs].filter(s=>!!s)});r.common.issues.push(n)}let Ct=class Vm{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return Vm.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Os=r=>({status:"dirty",value:r}),xt=r=>({status:"valid",value:r}),pl=r=>r.status==="aborted",ml=r=>r.status==="dirty",Li=r=>r.status==="valid",qi=r=>typeof Promise<"u"&&r instanceof Promise;function Vo(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 Um(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Ei,Ii;let Sr=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 bh=(r,e)=>{if(Li(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 be(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}let Se=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 Ct,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(qi(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},i=this._parseSync({data:e,path:s.path,parent:s});return bh(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(qi(s)?s:Promise.resolve(s));return bh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:Z.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new 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 qs.create(this,this._def)}or(e){return Ji.create([this,e],this._def)}and(e){return Yi.create(this,e,this._def)}transform(e){return new dr({...be(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({...be(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new ef({typeName:de.ZodBranded,type:this,...be(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({...be(this._def),innerType:this,catchValue:t,typeName:de.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return tf.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const ub=/^c[^\s-]{8,}$/i,lb=/^[0-9a-z]+$/,db=/^[0-9A-HJKMNP-TV-Z]{26}$/,fb=/^[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,hb=/^[a-z0-9_-]{21}$/i,pb=/^[-+]?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)?)??$/,mb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Gu;const gb=/^(?:(?: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])$/,vb=/^(([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})))$/,bb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lm="((\\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])))",xb=new RegExp(`^${Lm}$`);function qm(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 _b(r){return new RegExp(`^${qm(r)}$`)}function Hm(r){let e=`${Lm}T${qm(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 wb(r,e){return!!((e==="v4"||!e)&&gb.test(r)||(e==="v6"||!e)&&vb.test(r))}let Us=class Ci extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.string,received:i.parsedType}),pe}const n=new Ct;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?H(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&H(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")mb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"email",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Gu||(Gu=new RegExp(yb,"u")),Gu.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"emoji",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")fb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"uuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")hb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"nanoid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")ub.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")lb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid2",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")db.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"ulid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),H(s,{validation:"url",code:Z.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"regex",code:Z.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Hm(i).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?xb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?_b(i).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?pb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"duration",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?wb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"ip",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?bb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"base64",code:Z.invalid_string,message:i.message}),n.dirty()):Be.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Ci({...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 Ci({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ci({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ci({...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}};Us.create=r=>{var e;return new Us({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};function kb(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 Hi=class yl extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.number,received:i.parsedType}),pe}let n;const s=new Ct;for(const i of this._def.checks)i.kind==="int"?Be.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?kb(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_finite,message:i.message}),s.dirty()):Be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,s){return new yl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new yl({...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"&&Be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Hi.create=r=>new Hi({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let Fi=class gl extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==z.bigint){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.bigint,received:i.parsedType}),pe}let n;const s=new Ct;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),H(n,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,s){return new gl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new gl({...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}};Fi.create=r=>{var e;return new Fi({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...be(r)})};let Wi=class extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return xt(e.data)}};Wi.create=r=>new Wi({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...be(r)});let Ki=class Fm extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.date,received:i.parsedType}),pe}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_date}),pe}const n=new Ct;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Be.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Fm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Ki.create=r=>new Ki({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,...be(r)});let Uo=class extends Se{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return xt(e.data)}};Uo.create=r=>new Uo({typeName:de.ZodSymbol,...be(r)});let zi=class extends Se{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return xt(e.data)}};zi.create=r=>new zi({typeName:de.ZodUndefined,...be(r)});let Gi=class extends Se{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.null,received:n.parsedType}),pe}return xt(e.data)}};Gi.create=r=>new Gi({typeName:de.ZodNull,...be(r)});let Ls=class extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return xt(e.data)}};Ls.create=r=>new Ls({typeName:de.ZodAny,...be(r)});let zn=class extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xt(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,...be(r)});let Hr=class extends Se{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:Z.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,...be(r)});let Lo=class extends Se{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.void,received:n.parsedType}),pe}return xt(e.data)}};Lo.create=r=>new Lo({typeName:de.ZodVoid,...be(r)});let Qn=class Io extends Se{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==z.array)return H(t,{code:Z.invalid_type,expected:z.array,received:t.parsedType}),pe;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(H(t,{code:a?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(H(t,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(H(t,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>Ct.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Sr(t,a,t.path,o)));return Ct.mergeArray(n,i)}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,...be(e)});function ks(r){if(r instanceof Wt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ks(n))}return new Wt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ks(r.element)}):r instanceof xr?xr.create(ks(r.unwrap())):r instanceof vn?vn.create(ks(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ks(e))):r}let Wt=class Xt extends Se{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Be.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:Z.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(s,m,s.path,u)),alwaysSet:u in s.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:s.data[f]}});else if(u==="strict")o.length>0&&(H(s,{code:Z.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,R=await f.value;u.push({key:m,value:R,alwaysSet:f.alwaysSet})}return u}).then(u=>Ct.mergeObjectSync(n,u)):Ct.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 s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new 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 Be.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 Be.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Xt({...this._def,shape:()=>t})}deepPartial(){return ks(this)}partial(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Xt({...this._def,shape:()=>t})}required(e){const t={};return Be.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof xr;)i=i._def.innerType;t[n]=i}}),new Xt({...this._def,shape:()=>t})}keyof(){return Ym(Be.objectKeys(this.shape))}};Wt.create=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});Wt.strictCreate=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});Wt.lazycreate=(r,e)=>new Wt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,...be(e)});let Ji=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new or(o.ctx.common.issues));return H(t,{code:Z.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new or(c));return H(t,{code:Z.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Ji.create=(r,e)=>new Ji({options:r,typeName:de.ZodUnion,...be(e)});const Br=r=>r instanceof Xi?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qi?[r.value]:r instanceof Ja?r.options:r instanceof ea?Be.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zi?[void 0]:r instanceof Gi?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof ef||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Wm=class Km extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:Z.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=Br(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 Km({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...be(n)})}};function vl(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 s=Be.objectKeys(e),i=Be.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=vl(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 s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=vl(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Yi=class extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(pl(i)||pl(a))return pe;const o=vl(i.value,a.value);return o.valid?((ml(i)||ml(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:Z.invalid_intersection_types}),pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Yi.create=(r,e,t)=>new Yi({left:r,right:e,typeName:de.ZodIntersection,...be(t)});let gn=class zm extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:Z.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>Ct.mergeArray(t,a)):Ct.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new zm({...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,...be(e)})};let Gm=class bl extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return H(n,{code:Z.invalid_type,expected:z.object,received:n.parsedType}),pe;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new 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?Ct.mergeObjectAsync(t,s):Ct.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Se?new bl({keyType:e,valueType:t,typeName:de.ZodRecord,...be(n)}):new bl({keyType:Us.create(),valueType:e,typeName:de.ZodRecord,...be(t)})}},qo=class extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return H(n,{code:Z.invalid_type,expected:z.map,received:n.parsedType}),pe;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Sr(n,o,n.path,[u,"key"])),value:i._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}}}};qo.create=(r,e,t)=>new qo({valueType:e,keyType:r,typeName:de.ZodMap,...be(t)});let Ho=class xl extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:Z.invalid_type,expected:z.set,received:n.parsedType}),pe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(H(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(H(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new xl({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new xl({...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)}};Ho.create=(r,e)=>new Ho({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,...be(e)});let Jm=class Co extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:Z.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Mo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Do(),Vs].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return Mo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Do(),Vs].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qs){const o=this;return xt(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,i).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return xt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new or([s(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,...be(n)})}},Xi=class extends Se{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Xi.create=(r,e)=>new Xi({getter:r,typeName:de.ZodLazy,...be(e)});let Qi=class extends Se{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qi.create=(r,e)=>new Qi({value:r,typeName:de.ZodLiteral,...be(e)});function Ym(r,e){return new Ja({values:r,typeName:de.ZodEnum,...be(e)})}let Ja=class _l extends Se{constructor(){super(...arguments),Ei.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{expected:Be.joinValues(n),received:t.parsedType,code:Z.invalid_type}),pe}if(Vo(this,Ei)||Um(this,Ei,new Set(this._def.values)),!Vo(this,Ei).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:Z.invalid_enum_value,options:n}),pe}return xt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return _l.create(e,{...this._def,...t})}exclude(e,t=this._def){return _l.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Ei=new WeakMap;Ja.create=Ym;let ea=class extends Se{constructor(){super(...arguments),Ii.set(this,void 0)}_parse(e){const t=Be.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){const s=Be.objectValues(t);return H(n,{expected:Be.joinValues(s),received:n.parsedType,code:Z.invalid_type}),pe}if(Vo(this,Ii)||Um(this,Ii,new Set(Be.getValidEnumValues(this._def.values))),!Vo(this,Ii).has(e.data)){const s=Be.objectValues(t);return H(n,{received:n.data,code:Z.invalid_enum_value,options:s}),pe}return xt(e.data)}get enum(){return this._def.values}};Ii=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,...be(e)});let qs=class extends Se{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:Z.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return xt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qs.create=(r,e)=>new qs({type:r,typeName:de.ZodPromise,...be(e)});let dr=class extends Se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return 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"?Os(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"?Os(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Li(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=>Li(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Be.assertNever(s)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,...be(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,...be(t)});let xr=class extends Se{_parse(e){return this._getType(e)===z.undefined?xt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,...be(e)});let vn=class extends Se{_parse(e){return this._getType(e)===z.null?xt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,...be(e)});let ta=class extends Se{_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,...be(e)});let ra=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.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,...be(e)});let Fo=class extends Se{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};Fo.create=r=>new Fo({typeName:de.ZodNaN,...be(r)});const Sb=Symbol("zod_brand");let ef=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},tf=class Xm extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),Os(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Xm({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Se{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Li(s)&&(s.value=Object.freeze(s.value)),s);return qi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,...be(e)});function Qm(r,e={},t){return r?Ls.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})}}):Ls.create()}const Ab={object:Wt.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 Ob=(r,e={message:`Input not instance of ${r.name}`})=>Qm(t=>t instanceof r,e),ey=Us.create,ty=Hi.create,Eb=Fo.create,Ib=Fi.create,ry=Wi.create,Cb=Ki.create,jb=Uo.create,Tb=zi.create,Nb=Gi.create,Bb=Ls.create,Rb=zn.create,Pb=Hr.create,$b=Lo.create,Zb=Qn.create,Db=Wt.create,Mb=Wt.strictCreate,Vb=Ji.create,Ub=Wm.create,Lb=Yi.create,qb=gn.create,Hb=Gm.create,Fb=qo.create,Wb=Ho.create,Kb=Jm.create,zb=Xi.create,Gb=Qi.create,Jb=Ja.create,Yb=ea.create,Xb=qs.create,xh=dr.create,Qb=xr.create,ex=vn.create,tx=dr.createWithPreprocess,rx=tf.create,nx=()=>ey().optional(),sx=()=>ty().optional(),ix=()=>ry().optional(),ax={string:r=>Us.create({...r,coerce:!0}),number:r=>Hi.create({...r,coerce:!0}),boolean:r=>Wi.create({...r,coerce:!0}),bigint:r=>Fi.create({...r,coerce:!0}),date:r=>Ki.create({...r,coerce:!0})},ox=pe;var v=Object.freeze({__proto__:null,defaultErrorMap:Vs,setErrorMap:ob,getErrorMap:Do,makeIssue:Mo,EMPTY_PATH:cb,addIssueToContext:H,ParseStatus:Ct,INVALID:pe,DIRTY:Os,OK:xt,isAborted:pl,isDirty:ml,isValid:Li,isAsync:qi,get util(){return Be},get objectUtil(){return hl},ZodParsedType:z,getParsedType:sn,ZodType:Se,datetimeRegex:Hm,ZodString:Us,ZodNumber:Hi,ZodBigInt:Fi,ZodBoolean:Wi,ZodDate:Ki,ZodSymbol:Uo,ZodUndefined:zi,ZodNull:Gi,ZodAny:Ls,ZodUnknown:zn,ZodNever:Hr,ZodVoid:Lo,ZodArray:Qn,ZodObject:Wt,ZodUnion:Ji,ZodDiscriminatedUnion:Wm,ZodIntersection:Yi,ZodTuple:gn,ZodRecord:Gm,ZodMap:qo,ZodSet:Ho,ZodFunction:Jm,ZodLazy:Xi,ZodLiteral:Qi,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qs,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:Fo,BRAND:Sb,ZodBranded:ef,ZodPipeline:tf,ZodReadonly:na,custom:Qm,Schema:Se,ZodSchema:Se,late:Ab,get ZodFirstPartyTypeKind(){return de},coerce:ax,any:Bb,array:Zb,bigint:Ib,boolean:ry,date:Cb,discriminatedUnion:Ub,effect:xh,enum:Jb,function:Kb,instanceof:Ob,intersection:Lb,lazy:zb,literal:Gb,map:Fb,nan:Eb,nativeEnum:Yb,never:Pb,null:Nb,nullable:ex,number:ty,object:Db,oboolean:ix,onumber:sx,optional:Qb,ostring:nx,pipeline:rx,preprocess:tx,promise:Xb,record:Hb,set:Wb,strictObject:Mb,string:ey,symbol:jb,transformer:xh,tuple:qb,undefined:Tb,union:Vb,unknown:Rb,void:$b,NEVER:ox,ZodIssueCode:Z,quotelessJson:ab,ZodError:or}),jt=class wl extends ib{constructor(t){super(t);se(this,"openAPIRegistry");se(this,"defaultHook");se(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var u,f,m,R,C,p,y,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xs("query",n.request.query,i);a.push(N)}if((f=n.request)!=null&&f.params){const N=xs("param",n.request.params,i);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xs("header",n.request.headers,i);a.push(N)}if((R=n.request)!=null&&R.cookies){const N=xs("cookie",n.request.cookies,i);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 ve=o[N].schema;if(ve instanceof Se){if(wh(N)){const Le=xs("json",ve,i);if((A=(y=n.request)==null?void 0:y.body)!=null&&A.required)a.push(Le);else{const qe=async(Ze,tt)=>{if(Ze.req.header("content-type")&&wh(Ze.req.header("content-type")))return await Le(Ze,tt);Ze.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(kh(N)){const Le=xs("form",ve,i);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")&&kh(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,s),this});se(this,"getOpenAPIDocument",t=>{const s=new bv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?_h(s,this._basePath):s});se(this,"getOpenAPI31Document",t=>{const s=new wv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?_h(s,this._basePath):s});se(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)}}));se(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 tv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof wl?(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:nn(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:nn(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 wl({...super.basePath(t),defaultHook:this.defaultHook})}},ke=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};Y0(v);function _h(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function wh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function kh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function cx(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 ux(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ki(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 lx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const R=typeof s=="string"?i:s,C=R??{},{param:p}=C,y=cx(C,["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),y),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),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(ux(this,"ZodObject")){const N=this.extend;P.extend=function(...ve){var Le,qe,Ze,tt,pt,Rt;const I=N.apply(this,ve);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}:(pt=this._def.openapi)===null||pt===void 0?void 0:pt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ki(r,"optional"),ki(r,"nullable"),ki(r,"default"),ki(r,"transform"),ki(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}new Set(".\\+*[^]$()");var Re;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Re||(Re={}));var kl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(kl||(kl={}));const G=Re.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}},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"]),dx=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(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 Zt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Zt.create=r=>new Zt(r);const Hs=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,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 ny=Hs;function fx(r){ny=r}function Wo(){return ny}const Ko=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}},hx=[];function F(r,e){const t=Wo(),n=Ko({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hs?void 0:Hs].filter(s=>!!s)});r.common.issues.push(n)}class yt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return ye;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ye;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const ye=Object.freeze({status:"aborted"}),zo=r=>({status:"dirty",value:r}),_t=r=>({status:"valid",value:r}),Sl=r=>r.status==="aborted",Al=r=>r.status==="dirty",sa=r=>r.status==="valid",ia=r=>typeof Promise<"u"&&r instanceof Promise;function Go(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 sy(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var ji,Ti;class Ar{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Sh=(r,e)=>{if(sa(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 xe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>{var o,c;const{message:u}=r;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:(o=u??n)!==null&&o!==void 0?o:a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:a.defaultError}},description:s}}class Oe{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 yt,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(ia(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:an(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Sh(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:an(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(ia(s)?s:Promise.resolve(s));return Sh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:D.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new 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 Ws.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({...xe(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({...xe(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new rf({typeName:fe.ZodBranded,type:this,...xe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({...xe(this._def),innerType:this,catchValue:t,typeName:fe.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ya.create(this,e)}readonly(){return ga.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const px=/^c[^\s-]{8,}$/i,mx=/^[0-9a-z]+$/,yx=/^[0-9A-HJKMNP-TV-Z]{26}$/,gx=/^[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,vx=/^[a-z0-9_-]{21}$/i,bx=/^[-+]?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)?)??$/,xx=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_x="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ju;const wx=/^(?:(?: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])$/,kx=/^(([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})))$/,Sx=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,iy="((\\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])))",Ax=new RegExp(`^${iy}$`);function ay(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 Ox(r){return new RegExp(`^${ay(r)}$`)}function oy(r){let e=`${iy}T${ay(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 Ex(r,e){return!!((e==="v4"||!e)&&wx.test(r)||(e==="v6"||!e)&&kx.test(r))}class sr extends Oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.string,received:s.parsedType}),ye}const t=new yt;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?F(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&F(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")xx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Ju||(Ju=new RegExp(_x,"u")),Ju.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")gx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")vx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")px.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")mx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")yx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:D.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:D.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?oy(s).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Ox(s).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?bx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Ex(e.data,s.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?Sx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:D.invalid_string,message:s.message}),t.dirty()):Re.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:D.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new sr({...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 sr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new sr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new sr({...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}}sr.create=r=>{var e;return new sr({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};function Ix(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 bn extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.number,received:s.parsedType}),ye}let t;const n=new yt;for(const s of this._def.checks)s.kind==="int"?Re.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Ix(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_finite,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,s){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_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"&&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)}}bn.create=r=>new bn({checks:[],typeName:fe.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class xn extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==G.bigint){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.bigint,received:s.parsedType}),ye}let t;const n=new yt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Re.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,s){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_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,...xe(r)})};class aa extends Oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.boolean,received:t.parsedType}),ye}return _t(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});class es extends Oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.date,received:s.parsedType}),ye}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_date}),ye}const t=new yt;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Re.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new es({...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}}es.create=r=>new es({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,...xe(r)});class Jo extends Oe{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.symbol,received:t.parsedType}),ye}return _t(e.data)}}Jo.create=r=>new Jo({typeName:fe.ZodSymbol,...xe(r)});class oa extends Oe{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.undefined,received:t.parsedType}),ye}return _t(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,...xe(r)});class ca extends Oe{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.null,received:t.parsedType}),ye}return _t(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,...xe(r)});class Fs extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return _t(e.data)}}Fs.create=r=>new Fs({typeName:fe.ZodAny,...xe(r)});class Gn extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _t(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,...xe(r)});class Fr extends Oe{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.never,received:t.parsedType}),ye}}Fr.create=r=>new Fr({typeName:fe.ZodNever,...xe(r)});class Yo extends Oe{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.void,received:t.parsedType}),ye}return _t(e.data)}}Yo.create=r=>new Yo({typeName:fe.ZodVoid,...xe(r)});class cr extends Oe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==G.array)return F(t,{code:D.invalid_type,expected:G.array,received:t.parsedType}),ye;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(F(t,{code:a?D.too_big:D.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(F(t,{code:D.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(F(t,{code:D.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>yt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ar(t,a,t.path,o)));return yt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new 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,...xe(e)});function Ss(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Ss(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Ss(r.element)}):r instanceof _r?_r.create(Ss(r.unwrap())):r instanceof wn?wn.create(Ss(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Ss(e))):r}class Je extends Oe{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)!==G.object){const c=this._getOrReturnCtx(e);return F(c,{code:D.invalid_type,expected:G.object,received:c.parsedType}),ye}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||a.push(c);const o=[];for(const c of i){const u=s[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new 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:D.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new 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=>yt.mergeObjectSync(t,c)):yt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return Re.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 Re.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Je({...this._def,shape:()=>t})}deepPartial(){return Ss(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Je({...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 _r;)s=s._def.innerType;t[n]=s}}),new Je({...this._def,shape:()=>t})}keyof(){return cy(Re.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,...xe(e)});class ua extends Oe{_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 Zt(o.ctx.common.issues));return F(t,{code:D.invalid_union,unionErrors:a}),ye}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Zt(c));return F(t,{code:D.invalid_union,unionErrors:o}),ye}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,...xe(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?Re.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 rf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class Jc extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:D.invalid_type,expected:G.object,received:t.parsedType}),ye;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ye)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=rn(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 Jc({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...xe(n)})}}function Ol(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 s=Re.objectKeys(e),i=Re.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Ol(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Ol(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Sl(i)||Sl(a))return ye;const o=Ol(i.value,a.value);return o.valid?((Al(i)||Al(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:D.invalid_intersection_types}),ye)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,...xe(t)});class Or extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:D.invalid_type,expected:G.array,received:n.parsedType}),ye;if(n.data.length<this._def.items.length)return F(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ye;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((i,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>yt.mergeArray(t,i)):yt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new 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,...xe(e)})};class da extends Oe{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:D.invalid_type,expected:G.object,received:n.parsedType}),ye;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?yt.mergeObjectAsync(t,s):yt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Oe?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,...xe(n)}):new da({keyType:sr.create(),valueType:e,typeName:fe.ZodRecord,...xe(t)})}}class Xo extends Oe{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:D.invalid_type,expected:G.map,received:n.parsedType}),ye;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ar(n,o,n.path,[u,"key"])),value:i._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Xo.create=(r,e,t)=>new Xo({valueType:e,keyType:r,typeName:fe.ZodMap,...xe(t)});class ts extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:D.invalid_type,expected:G.set,received:n.parsedType}),ye;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(F(n,{code:D.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(F(n,{code:D.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ye;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ts({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ts({...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)}}ts.create=(r,e)=>new ts({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,...xe(e)});class Ts extends Oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:D.invalid_type,expected:G.function,received:t.parsedType}),ye;function n(o,c){return Ko({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wo(),Hs].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function s(o,c){return Ko({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Wo(),Hs].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ws){const o=this;return _t(async function(...c){const u=new Zt([]),f=await o._def.args.parseAsync(c,i).catch(R=>{throw u.addIssue(n(c,R)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(R=>{throw u.addIssue(s(m,R)),u})})}else{const o=this;return _t(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Zt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Zt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ts({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ts({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ts({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,...xe(n)})}}class fa extends Oe{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,...xe(e)});class ha extends Oe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),ye}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,...xe(e)});function cy(r,e){return new _n({values:r,typeName:fe.ZodEnum,...xe(e)})}class _n extends Oe{constructor(){super(...arguments),ji.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:Re.joinValues(n),received:t.parsedType,code:D.invalid_type}),ye}if(Go(this,ji)||sy(this,ji,new Set(this._def.values)),!Go(this,ji).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:D.invalid_enum_value,options:n}),ye}return _t(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return _n.create(e,{...this._def,...t})}exclude(e,t=this._def){return _n.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}ji=new WeakMap;_n.create=cy;class pa extends Oe{constructor(){super(...arguments),Ti.set(this,void 0)}_parse(e){const t=Re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){const s=Re.objectValues(t);return F(n,{expected:Re.joinValues(s),received:n.parsedType,code:D.invalid_type}),ye}if(Go(this,Ti)||sy(this,Ti,new Set(Re.getValidEnumValues(this._def.values))),!Go(this,Ti).has(e.data)){const s=Re.objectValues(t);return F(n,{received:n.data,code:D.invalid_enum_value,options:s}),ye}return _t(e.data)}get enum(){return this._def.values}}Ti=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,...xe(e)});class Ws extends Oe{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:D.invalid_type,expected:G.promise,received:t.parsedType}),ye;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return _t(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ws.create=(r,e)=>new Ws({type:r,typeName:fe.ZodPromise,...xe(e)});class fr extends Oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ye;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ye:c.status==="dirty"||t.value==="dirty"?zo(c.value):c});{if(t.value==="aborted")return ye;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ye:o.status==="dirty"||t.value==="dirty"?zo(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!sa(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=>sa(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Re.assertNever(s)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,...xe(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,...xe(t)});class _r extends Oe{_parse(e){return this._getType(e)===G.undefined?_t(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}_r.create=(r,e)=>new _r({innerType:r,typeName:fe.ZodOptional,...xe(e)});class wn extends Oe{_parse(e){return this._getType(e)===G.null?_t(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}wn.create=(r,e)=>new wn({innerType:r,typeName:fe.ZodNullable,...xe(e)});class ma extends Oe{_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,...xe(e)});class ya extends Oe{_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 ia(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Zt(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,...xe(e)});class Qo extends Oe{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.nan,received:t.parsedType}),ye}return{status:"valid",value:e.data}}}Qo.create=r=>new Qo({typeName:fe.ZodNaN,...xe(r)});const Cx=Symbol("zod_brand");class rf extends Oe{_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 Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),zo(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Oe{_parse(e){const t=this._def.innerType._parse(e),n=s=>(sa(s)&&(s.value=Object.freeze(s.value)),s);return ia(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,...xe(e)});function uy(r,e={},t){return r?Fs.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Fs.create()}const jx={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 Tx=(r,e={message:`Input not instance of ${r.name}`})=>uy(t=>t instanceof r,e),ly=sr.create,dy=bn.create,Nx=Qo.create,Bx=xn.create,fy=aa.create,Rx=es.create,Px=Jo.create,$x=oa.create,Zx=ca.create,Dx=Fs.create,Mx=Gn.create,Vx=Fr.create,Ux=Yo.create,Lx=cr.create,qx=Je.create,Hx=Je.strictCreate,Fx=ua.create,Wx=Jc.create,Kx=la.create,zx=Or.create,Gx=da.create,Jx=Xo.create,Yx=ts.create,Xx=Ts.create,Qx=fa.create,e_=ha.create,t_=_n.create,r_=pa.create,n_=Ws.create,Ah=fr.create,s_=_r.create,i_=wn.create,a_=fr.createWithPreprocess,o_=Ya.create,c_=()=>ly().optional(),u_=()=>dy().optional(),l_=()=>fy().optional(),d_={string:r=>sr.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=>es.create({...r,coerce:!0})},f_=ye;var d=Object.freeze({__proto__:null,defaultErrorMap:Hs,setErrorMap:fx,getErrorMap:Wo,makeIssue:Ko,EMPTY_PATH:hx,addIssueToContext:F,ParseStatus:yt,INVALID:ye,DIRTY:zo,OK:_t,isAborted:Sl,isDirty:Al,isValid:sa,isAsync:ia,get util(){return Re},get objectUtil(){return kl},ZodParsedType:G,getParsedType:an,ZodType:Oe,datetimeRegex:oy,ZodString:sr,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:es,ZodSymbol:Jo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fs,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:Yo,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:Jc,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:Xo,ZodSet:ts,ZodFunction:Ts,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ws,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:Qo,BRAND:Cx,ZodBranded:rf,ZodPipeline:Ya,ZodReadonly:ga,custom:uy,Schema:Oe,ZodSchema:Oe,late:jx,get ZodFirstPartyTypeKind(){return fe},coerce:d_,any:Dx,array:Lx,bigint:Bx,boolean:fy,date:Rx,discriminatedUnion:Wx,effect:Ah,enum:t_,function:Xx,instanceof:Tx,intersection:Kx,lazy:Qx,literal:e_,map:Jx,nan:Nx,nativeEnum:r_,never:Vx,null:Zx,nullable:i_,number:dy,object:qx,oboolean:l_,onumber:u_,optional:s_,ostring:c_,pipeline:o_,preprocess:a_,promise:n_,record:Gx,set:Yx,strictObject:Hx,string:ly,symbol:Px,transformer:Ah,tuple:zx,undefined:$x,union:Fx,unknown:Mx,void:Ux,NEVER:f_,ZodIssueCode:D,quotelessJson:dx,ZodError:Zt});lx(d);const jn=d.object({start:d.number(),limit:d.number(),length:d.number()}),nf=d.object({created_at:d.string(),updated_at:d.string()}),hy=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()),py=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:hy.optional()}),Yc=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()}),ec=Yc.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")}),sf=d.object({...ec.shape,...nf.shape,user_id:d.string(),email:d.string(),is_social:d.boolean(),login_count:d.number(),identities:d.array(py).optional()}),vr=sf,h_=Yc.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()),p_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let m_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=p_[t[r]&63];return e};const my=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()}),tc=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:my.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(()=>m_()).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),...tc.shape});var af=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(af||{}),of=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(of||{}),cf=(r=>(r.S265="S256",r.plain="plain",r))(cf||{});const yy=d.object({client_id:d.string(),vendor_id:d.string().optional(),act_as:d.string().optional(),response_type:d.nativeEnum(af).optional(),response_mode:d.nativeEnum(of).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(cf).optional(),code_challenge:d.string().optional(),username:d.string().optional(),ui_locales:d.string().optional()}),El=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()}),rc=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()}),Vn=d.object({id:d.string(),created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r)}).extend(rc.shape),nc=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()}),Ns=d.object({created_at:d.string().transform(r=>r===null?"":r),updated_at:d.string().transform(r=>r===null?"":r),id:d.string(),...nc.shape}),y_=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()}),g_=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(g_),tenant:Ns,connections:d.array(Vn)});const gy=d.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),vy=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:gy,expires_at:d.string(),used_at:d.string().optional(),user_id:d.string().optional()}),v_=d.object({...vy.shape,created_at:d.string()}),by=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"])}),b_=nf.extend({...by.shape,id:d.string()}),sc=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()}),Es=sc.extend({...nf.shape,hook_id:d.string()}),uf=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()}),xy=d.object({keys:d.array(uf)}),Il=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())}),_y=d.object({auth0Client:d.string().optional(),authParams:yy,expires_at:d.string(),deleted_at:d.string().optional(),ip:d.string().optional()}).openapi({description:"This represents a login sesion"}),x_=d.object({..._y.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 Xc=(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))(Xc||{});const __=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"]),wy=d.object({name:d.string(),version:d.string(),env:d.object({node:d.string().optional()}).optional()}),ic=d.object({type:__,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:wy.optional()}),ky=d.object({user_id:d.string(),password:d.string(),algorithm:d.enum(["bcrypt","argon2id"]).default("argon2id")}),w_=d.object({...ky.shape,created_at:d.string(),updated_at:d.string()}),Sy=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()}),lf=d.object({created_at:d.string(),...Sy.shape}),Cl=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 df=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(df||{});const ff=d.nativeEnum(df),k_=d.object({grant_type:ff.refine(r=>r==="authorization_code"),code:d.string(),client_secret:d.string(),client_id:d.string()}),S_=d.object({grant_type:ff.refine(r=>r==="authorization_code"),code:d.string(),code_verifier:d.string(),client_id:d.string().optional(),redirect_uri:d.string()}),A_=d.object({grant_type:ff.refine(r=>r==="client_credentials"),scope:d.string().optional(),client_secret:d.string(),client_id:d.string(),audience:d.string().optional()});d.object({access_token:d.string(),id_token:d.string().optional(),scope:d.string().optional(),state:d.string().optional(),refresh_token:d.string().optional(),token_type:d.string(),expires_in:d.number()});d.object({code:d.string(),state:d.string().optional()});const Ay=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()}),Oy=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()}),Zn=d.object({bold:d.boolean(),size:d.number()}),Ey=d.object({body_text:Zn,buttons_text:Zn,font_url:d.string(),input_labels:Zn,links:Zn,links_style:d.enum(["normal"]),reference_text_size:d.number(),subtitle:Zn,title:Zn}),Iy=d.object({background_color:d.string(),background_image_url:d.string(),page_layout:d.enum(["center"])}),Cy=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"])}),jy=d.object({borders:Ay,colors:Oy,displayName:d.string(),fonts:Ey,page_background:Iy,widget:Cy}),O_=jy.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()});function E_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}var ac=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function I_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function C_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
|
|
1
|
+
"use strict";var G0=Object.defineProperty;var hh=r=>{throw TypeError(r)};var J0=(r,e,t)=>e in r?G0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var se=(r,e,t)=>J0(r,typeof e!="symbol"?e+"":e,t),Ku=(r,e,t)=>e.has(r)||hh("Cannot "+t);var w=(r,e,t)=>(Ku(r,e,"read from private field"),t?t.call(r):e.get(r)),Ae=(r,e,t)=>e.has(r)?hh("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),ue=(r,e,t,n)=>(Ku(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),je=(r,e,t)=>(Ku(r,e,"access private method"),t);var ph=(r,e,t,n)=>({set _(s){ue(r,e,s,t)},get _(){return w(r,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ai(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 ke(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function Y0(r){return"_def"in r}function xi(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 X0(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const R=typeof s=="string"?i:s,C=R??{},{param:p}=C,y=Ai(C,["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),y),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),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(ke(this,"ZodObject")){const N=this.extend;P.extend=function(...be){var Le,qe,De,tt,pt,Rt;const I=N.apply(this,be);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=(De=this._def.openapi)===null||De===void 0?void 0:De._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(pt=this._def.openapi)===null||pt===void 0?void 0:pt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},xi(r,"optional"),xi(r,"nullable"),xi(r,"default"),xi(r,"transform"),xi(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}function $o(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=>$o(r[n],e[n]))}class Q0{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=>$o(i,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>$o(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 Ri(r){return r==null}function Pi(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function ev(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(i=>i===n)||(t[n]=s)}),t}function js(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function mh(r){return r.filter(e=>!Ri(e))}const dl=$o;function tv(r){const e=new Q0;return r.forEach(t=>e.put(t)),[...e.values()]}function vm(r){return typeof r=="string"}class rv{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 Jc{constructor(e){this.message=e}}class _i extends Jc{constructor(e,t){super(e),this.data=t}}class Zo extends Jc{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 wi(r,e){try{return r()}catch(t){throw t instanceof Zo?new Zo(Object.assign(Object.assign({},t.data),e)):t}}class nv extends Jc{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class Ke{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 js(ev(e,["param"]),Ri)}static buildParameterMetadata(e){return js(e,Ri)}static applySchemaMetadata(e,t){return js(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),Ri)}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&&ke(e,t)?e:ke(e,"ZodOptional")||ke(e,"ZodNullable")||ke(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):ke(e,"ZodDefault")||ke(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):ke(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):ke(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return ke(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class sv{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 iv{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class av{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=>Ke.getRefId(i)===void 0))return;const s={};return e.forEach(i=>{var a;const o=Ke.getRefId(i),c=(a=i.shape)===null||a===void 0?void 0:a[t];if(ke(c,"ZodEnum")||ke(c,"ZodNativeEnum")){Object.values(c.enum).filter(vm).forEach(m=>{s[m]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class ov{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class cv{transform(e,t,n,s){const a={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([a],t)}:a}flattenIntersectionTypes(e){if(!ke(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class uv{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function lv(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 dv{transform(e,t){const{type:n,values:s}=lv(e._def.values);if(n==="mixed")throw new Jc("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 fv{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class hv{transform(e,t,n,s){var i;const a=(i=Ke.getInternalMetadata(e))===null||i===void 0?void 0:i.extendedFrom,o=this.requiredKeysOf(e),c=Pi(e._def.shape(),s);if(!a)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=a.schema;s(u);const f=this.requiredKeysOf(u),m=Pi(u==null?void 0:u._def.shape(),s),R=Object.fromEntries(Object.entries(c).filter(([y,A])=>!dl(m[y],A))),C=o.filter(y=>!f.includes(y)),p=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:R}),C.length>0?{required:C}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${a.refId}`},p]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return ke(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!Ke.isOptionalSchema(n)).map(([t,n])=>t)}}class pv{transform(e,t,n){const s=e._def.valueType,i=e._def.keyType,a=n(s);if(ke(i,"ZodEnum")||ke(i,"ZodNativeEnum")){const c=Object.values(i.enum).filter(vm).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 mv{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 yv{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 gv{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 ke(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return ke(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class vv{constructor(e){this.versionSpecifics=e,this.objectTransformer=new hv,this.stringTransformer=new mv,this.numberTransformer=new fv,this.bigIntTransformer=new iv,this.literalTransformer=new uv,this.enumTransformer=new ov,this.nativeEnumTransformer=new dv,this.arrayTransformer=new sv,this.unionTransformer=new gv,this.discriminatedUnionTransformer=new av,this.intersectionTransformer=new cv,this.recordTransformer=new pv,this.tupleTransformer=new yv(e)}transform(e,t,n,s,i){if(ke(e,"ZodNull"))return this.versionSpecifics.nullType;if(ke(e,"ZodUnknown")||ke(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(ke(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(ke(e,"ZodUnknown")||ke(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(ke(e,"ZodString"))return this.stringTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ke(e,"ZodNumber"))return this.numberTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),a=>this.versionSpecifics.getNumberChecks(a));if(ke(e,"ZodBigInt"))return this.bigIntTransformer.transform(a=>this.versionSpecifics.mapNullableType(a,t));if(ke(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(ke(e,"ZodLiteral"))return this.literalTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ke(e,"ZodEnum"))return this.enumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ke(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t));if(ke(e,"ZodArray"))return this.arrayTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ke(e,"ZodTuple"))return this.tupleTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ke(e,"ZodUnion"))return this.unionTransformer.transform(e,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(ke(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n,s);if(ke(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,a=>this.versionSpecifics.mapNullableOfArray(a,t),n);if(ke(e,"ZodRecord"))return this.recordTransformer.transform(e,a=>this.versionSpecifics.mapNullableType(a,t),n);if(ke(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const i=Ke.getRefId(e);throw new nv({currentSchema:e._def,schemaName:i})}}class bm{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new vv(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=Ke.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 _i(`Conflicting location for parameter ${u.name}`,{key:"in",values:mh([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 _i("Conflicting names for parameter",{key:"name",values:mh([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=Ke.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(ke(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,f])=>{var m,R;const C=Ke.getMetadata(f),p=this.getParameterRef(C,{in:t,name:u});if(p)return p;const y=(m=C==null?void 0:C.metadata)===null||m===void 0?void 0:m.param;if(y!=null&&y.name&&y.name!==u)throw new _i("Conflicting names for parameter",{key:"name",values:[u,y.name]});if(y!=null&&y.in&&y.in!==t)throw new _i(`Conflicting location for parameter ${(R=y.name)!==null&&R!==void 0?R:u}`,{key:"in",values:[t,y.in]});return this.generateParameter(f.openapi({param:{name:u,in:t}}))})}if(i!=null&&i.in&&i.in!==t)throw new _i(`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=Ke.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,i=!Ke.isOptionalSchema(e)&&!e.isNullable(),a=this.generateSchemaWithRef(e);return Object.assign({schema:a,required:i},s?Ke.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=Ke.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 Zo({missingField:"name"});if(!a)throw new Zo({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=Ke.unwrapChained(e),s=Ke.getMetadata(e),i=Ke.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?Ke.applySchemaMetadata(a,s.metadata):js(a,Ri)}constructReferencedOpenAPISchema(e){var t;const n=Ke.getMetadata(e),s=Ke.unwrapChained(e),i=Ke.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=Ke.getMetadata(e),s=Ke.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const i=this.schemaRefs[s],a={$ref:this.generateSchemaRef(s)},o=js(Ke.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(f,m)=>f===void 0||dl(f,i[m]));if(o.type)return{allOf:[a,o]};const c=js(this.constructReferencedOpenAPISchema(e),(f,m)=>f===void 0||dl(f,i[m])),u=Ke.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[a,u]}:a}generateSchemaWithRef(e){const t=Ke.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=Ai(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=wi(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=wi(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=wi(()=>i?this.generateInlineParameters(i,"cookie"):[],{location:"cookie"}),u=wi(()=>{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 ke(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:i}=e,a=Ai(e,["method","path","request","responses"]),o=Pi(i,m=>this.getResponse(m)),c=wi(()=>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=Ai(e,["content","headers"]);const i=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),i);const a=ke(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 Pi(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return Pi(e,t=>{if(!t||!Y0(t.schema))return t;const{schema:n}=t,s=Ai(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 bv{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=tv(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 xv{constructor(e){const t=new bv;this.generator=new bm(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}class _v{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 wv(r){return"type"in r&&r.type==="webhook"}class kv{constructor(e){this.definitions=e,this.webhookRefs={};const t=new _v;this.generator=new bm(this.definitions,t)}generateDocument(e){const t=this.generator.generateDocumentData();return this.definitions.filter(wv).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 xm=r=>{const e=r.split("/");return e[0]===""&&e.shift(),e},Sv=r=>{const{groups:e,path:t}=Av(r),n=xm(t);return Ov(n,e)},Av=r=>{const e=[];return r=r.replace(/\{[^}]+\}/g,(t,n)=>{const s=`@${n}`;return e.push([s,t]),s}),{groups:e,path:r}},Ov=(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},bo={},yh=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},_m=(r,e)=>{try{return e(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,t=>{try{return e(t)}catch{return t}})}},Ev=r=>_m(r,decodeURI),wm=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 Ev(a.includes("%25")?a.replace(/%25/g,"%2525"):a)}else if(s===63)break}return e.slice(t,n)},Iv=r=>{const e=wm(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},km=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)},zu=r=>/[%+]/.test(r)?(r.indexOf("+")!==-1&&(r=r.replace(/\+/g," ")),r.indexOf("%")!==-1?ef(r):r):r,Sm=(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 zu(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=zu(c)),i=a,c==="")continue;let u;o===-1?u="":(u=r.slice(o+1,a===-1?void 0:a),n&&(u=zu(u))),t?(s[c]&&Array.isArray(s[c])||(s[c]=[]),s[c].push(u)):s[c]??(s[c]=u)}return e?s[e]:s},Cv=Sm,jv=(r,e)=>Sm(r,e,!0),ef=decodeURIComponent,Tv=/^[\w!#$%&'*.^`|~+-]+$/,Nv=/^[ !#-:<-[\]-~]*$/,Bv=(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(!Tv.test(a))continue;let o=s.substring(i+1).trim();o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),Nv.test(o)&&(n[a]=ef(o))}return n},Rv=(r,e,t)=>{const n=r.req.raw.headers.get("Cookie");return n?Bv(n):{}},Be=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});se(this,"res");se(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})}},Pv=(r,e)=>new Response(r,{headers:{"Content-Type":e}}).formData(),$v=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Zv=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Dv=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Mv=(r,e)=>async(t,n)=>{let s={};const i=t.req.header("Content-Type");switch(r){case"json":if(!i||!$v.test(i))break;try{s=await t.req.json()}catch{const o="Malformed JSON in request body";throw new Be(400,{message:o})}break;case"form":{if(!i||!(Zv.test(i)||Dv.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 Pv(u,i),t.req.bodyCache.formData=o}catch(u){let f="Malformed FormData request.";throw f+=u instanceof Error?` ${u.message}`:` ${String(u)}`,new Be(400,{message:f})}const c={};o.forEach((u,f)=>{f.endsWith("[]")?(c[f]??(c[f]=[])).push(u):Array.isArray(c[f])?c[f].push(u):f in c?c[f]=[c[f],u]:c[f]=u}),s=c;break}case"query":s=Object.fromEntries(Object.entries(t.req.queries()).map(([o,c])=>c.length===1?[o,c[0]]:[o,c]));break;case"param":s=t.req.param();break;case"header":s=t.req.header();break;case"cookie":s=Rv(t);break}const a=await e(s,t);if(a instanceof Response)return a;t.req.addValidatedData(r,a),await n()};const xs=(r,e,t)=>Mv(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 Vv=async(r,e=Object.create(null))=>{const{all:t=!1,dot:n=!1}=e,i=(r instanceof Am?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")?Uv(r,{all:t,dot:n}):{}};async function Uv(r,e){const t=await r.formData();return t?Lv(t,e):{}}function Lv(r,e){const t=Object.create(null);return r.forEach((n,s)=>{e.all||s.endsWith("[]")?qv(t,s,n):t[s]=n}),e.dot&&Object.entries(t).forEach(([n,s])=>{n.includes(".")&&(Hv(t,n,s),delete t[n])}),t}var qv=(r,e,t)=>{r[e]!==void 0?Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]:r[e]=t},Hv=(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])})},gh=r=>_m(r,ef),$s,tr,Xr,Om,Em,fl,cn,um,Am=(um=class{constructor(r,e="/",t=[[]]){Ae(this,Xr);se(this,"raw");Ae(this,$s);Ae(this,tr);se(this,"routeIndex",0);se(this,"path");se(this,"bodyCache",{});Ae(this,cn,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,ue(this,tr,t),ue(this,$s,{})}param(r){return r?je(this,Xr,Om).call(this,r):je(this,Xr,Em).call(this)}query(r){return Cv(this.url,r)}queries(r){return jv(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 Vv(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,$s)[r]=e}valid(r){return w(this,$s)[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}},$s=new WeakMap,tr=new WeakMap,Xr=new WeakSet,Om=function(r){const e=w(this,tr)[0][this.routeIndex][1][r],t=je(this,Xr,fl).call(this,e);return t?/\%/.test(t)?gh(t):t:void 0},Em=function(){const r={},e=Object.keys(w(this,tr)[0][this.routeIndex][1]);for(const t of e){const n=je(this,Xr,fl).call(this,w(this,tr)[0][this.routeIndex][1][t]);n&&typeof n=="string"&&(r[t]=/\%/.test(n)?gh(n):n)}return r},fl=function(r){return w(this,tr)[1]?w(this,tr)[1][r]:r},cn=new WeakMap,um),Fv={Stringify:1,BeforeStream:2,Stream:3},Im=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=>Im(c,e,!1,n,s))).then(()=>s[0]))):Promise.resolve(r)},Wv="text/plain; charset=UTF-8",Gu=(r,e={})=>{for(const t of Object.keys(e))r.set(t,e[t]);return r},Ha,Fa,Pr,qn,$r,Ge,Qe,br,Zr,Wa,Zs,Ds,Ka,za,Ot,Ut,lm,Cm=(lm=class{constructor(r,e){Ae(this,Ot);Ae(this,Ha);Ae(this,Fa);se(this,"env",{});Ae(this,Pr);se(this,"finalized",!1);se(this,"error");Ae(this,qn,200);Ae(this,$r);Ae(this,Ge);Ae(this,Qe);Ae(this,br);Ae(this,Zr,!0);Ae(this,Wa);Ae(this,Zs);Ae(this,Ds);Ae(this,Ka);Ae(this,za);se(this,"render",(...r)=>(w(this,Zs)??ue(this,Zs,e=>this.html(e)),w(this,Zs).call(this,...r)));se(this,"setLayout",r=>ue(this,Wa,r));se(this,"getLayout",()=>w(this,Wa));se(this,"setRenderer",r=>{ue(this,Zs,r)});se(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,Zr,!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))});se(this,"status",r=>{ue(this,Zr,!1),ue(this,qn,r)});se(this,"set",(r,e)=>{w(this,Pr)??ue(this,Pr,new Map),w(this,Pr).set(r,e)});se(this,"get",r=>w(this,Pr)?w(this,Pr).get(r):void 0);se(this,"newResponse",(...r)=>je(this,Ot,Ut).call(this,...r));se(this,"body",(r,e,t)=>typeof e=="number"?je(this,Ot,Ut).call(this,r,e,t):je(this,Ot,Ut).call(this,r,e));se(this,"text",(r,e,t)=>{if(!w(this,Qe)){if(w(this,Zr)&&!t&&!e)return new Response(r);ue(this,Qe,{})}return w(this,Qe)["content-type"]=Wv,typeof e=="number"?je(this,Ot,Ut).call(this,r,e,t):je(this,Ot,Ut).call(this,r,e)});se(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"?je(this,Ot,Ut).call(this,n,e,t):je(this,Ot,Ut).call(this,n,e)});se(this,"html",(r,e,t)=>(w(this,Qe)??ue(this,Qe,{}),w(this,Qe)["content-type"]="text/html; charset=UTF-8",typeof r=="object"?Im(r,Fv.Stringify,!1,{}).then(n=>typeof e=="number"?je(this,Ot,Ut).call(this,n,e,t):je(this,Ot,Ut).call(this,n,e)):typeof e=="number"?je(this,Ot,Ut).call(this,r,e,t):je(this,Ot,Ut).call(this,r,e)));se(this,"redirect",(r,e)=>(w(this,Ge)??ue(this,Ge,new Headers),w(this,Ge).set("Location",String(r)),this.newResponse(null,e??302)));se(this,"notFound",()=>(w(this,Ds)??ue(this,Ds,()=>new Response),w(this,Ds).call(this,this)));ue(this,Ha,r),e&&(ue(this,$r,e.executionCtx),this.env=e.env,ue(this,Ds,e.notFoundHandler),ue(this,za,e.path),ue(this,Ka,e.matchResult))}get req(){return w(this,Fa)??ue(this,Fa,new Am(w(this,Ha),w(this,za),w(this,Ka))),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,Zr,!1),w(this,br)||ue(this,br,new Response("404 Not Found",{status:404}))}set res(r){if(ue(this,Zr,!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 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}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,Zr=new WeakMap,Wa=new WeakMap,Zs=new WeakMap,Ds=new WeakMap,Ka=new WeakMap,za=new WeakMap,Ot=new WeakSet,Ut=function(r,e,t){if(w(this,Zr)&&!t&&!e&&w(this,qn)===200)return new Response(r,{headers:w(this,Qe)});if(e&&typeof e!="number"){const s=new Headers(e.headers);w(this,Ge)&&w(this,Ge).forEach((a,o)=>{o==="set-cookie"?s.append(o,a):s.set(o,a)});const i=Gu(s,w(this,Qe));return new Response(r,{headers:i,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),Gu(w(this,Ge),w(this,Qe)),w(this,br)&&(w(this,br).headers.forEach((s,i)=>{var a,o;i==="set-cookie"?(a=w(this,Ge))==null||a.append(i,s):(o=w(this,Ge))==null||o.set(i,s)}),Gu(w(this,Ge),w(this,Qe))),t??(t={});for(const[s,i]of Object.entries(t))if(typeof i=="string")w(this,Ge).set(s,i);else{w(this,Ge).delete(s);for(const a of i)w(this,Ge).append(s,a)}return new Response(r,{status:n,headers:w(this,Ge)})},lm),vh=(r,e,t)=>(n,s)=>{let i=-1;const a=n instanceof Cm;return o(0);async function o(c){if(c<=i)throw new Error("next() called multiple times");i=c;let u,f=!1,m;if(r[c]?(m=r[c][0][0],a&&(n.req.routeIndex=c)):m=c===r.length&&s||void 0,!m)a&&n.finalized===!1&&t&&(u=await t(n));else try{u=await m(n,()=>o(c+1))}catch(R){if(R instanceof Error&&a&&e)n.error=R,u=await e(R,n),f=!0;else throw R}return u&&(n.finalized===!1||f)&&(n.res=u),n}},st="ALL",Kv="all",zv=["get","post","put","delete","options","patch"],jm="Can not add a route since the matcher is already built.",Tm=class extends Error{},Gv=Symbol("composedHandler"),Jv=r=>r.text("404 Not Found",404),bh=(r,e)=>"getResponse"in r?r.getResponse():(console.error(r),e.text("Internal Server Error",500)),rr,it,Bm,Dr,Pn,Ao,Oo,dm,Nm=(dm=class{constructor(e={}){Ae(this,it);se(this,"get");se(this,"post");se(this,"put");se(this,"delete");se(this,"options");se(this,"patch");se(this,"all");se(this,"on");se(this,"use");se(this,"router");se(this,"getPath");se(this,"_basePath","/");Ae(this,rr,"/");se(this,"routes",[]);Ae(this,Dr,Jv);se(this,"errorHandler",bh);se(this,"onError",e=>(this.errorHandler=e,this));se(this,"notFound",e=>(ue(this,Dr,e),this));se(this,"fetch",(e,...t)=>je(this,it,Oo).call(this,e,t[1],t[0],e.method));se(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${nn("/",e)}`,t),n,s)));se(this,"fire",()=>{addEventListener("fetch",e=>{e.respondWith(je(this,it,Oo).call(this,e.request,e,void 0,e.request.method))})});[...zv,Kv].forEach(s=>{this[s]=(i,...a)=>(typeof i=="string"?ue(this,rr,i):je(this,it,Pn).call(this,s,w(this,rr),i),a.forEach(o=>{je(this,it,Pn).call(this,s,w(this,rr),o)}),this)}),this.on=(s,i,...a)=>{for(const o of[i].flat()){ue(this,rr,o);for(const c of[s].flat())a.map(u=>{je(this,it,Pn).call(this,c.toUpperCase(),w(this,rr),u)})}return this},this.use=(s,...i)=>(typeof s=="string"?ue(this,rr,s):(ue(this,rr,"*"),i.unshift(s)),i.forEach(a=>{je(this,it,Pn).call(this,st,w(this,rr),a)}),this);const n=e.strict??!0;delete e.strict,Object.assign(this,e),this.getPath=n?e.getPath??wm:Iv}route(e,t){const n=this.basePath(e);return t.routes.map(s=>{var a;let i;t.errorHandler===bh?i=s.handler:(i=async(o,c)=>(await vh([],t.errorHandler)(o,()=>s.handler(o,c))).res,i[Gv]=s.handler),je(a=n,it,Pn).call(a,s.method,s.path,i)}),this}basePath(e){const t=je(this,it,Bm).call(this);return t._basePath=nn(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=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(s(c.req.raw),...a(c));if(f)return f;await u()};return je(this,it,Pn).call(this,st,nn(e,"*"),o),this}},rr=new WeakMap,it=new WeakSet,Bm=function(){const e=new Nm({router:this.router,getPath:this.getPath});return e.routes=this.routes,e},Dr=new WeakMap,Pn=function(e,t,n){e=e.toUpperCase(),t=nn(this._basePath,t);const s={path:t,method:e,handler:n};this.router.add(e,t,[n,s]),this.routes.push(s)},Ao=function(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e},Oo=function(e,t,n,s){if(s==="HEAD")return(async()=>new Response(null,await je(this,it,Oo).call(this,e,t,n,"GET")))();const i=this.getPath(e,{env:n}),a=this.router.match(s,i),o=new Cm(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:w(this,Dr)});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await w(this,Dr).call(this,o)})}catch(f){return je(this,it,Ao).call(this,f,o)}return u instanceof Promise?u.then(f=>f||(o.finalized?o.res:w(this,Dr).call(this,o))).catch(f=>je(this,it,Ao).call(this,f,o)):u??w(this,Dr).call(this,o)}const c=vh(a[0],this.errorHandler,w(this,Dr));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 je(this,it,Ao).call(this,u,o)}})()},dm),Do="[^/]+",$i=".*",Zi="(?:|/.*)",Oi=Symbol(),Yv=new Set(".\\+*[^]$()");function Xv(r,e){return r.length===1?e.length===1?r<e?-1:1:-1:e.length===1||r===$i||r===Zi?1:e===$i||e===Zi?-1:r===Do?1:e===Do?-1:r.length===e.length?r<e?-1:1:e.length-r.length}var Hn,Fn,nr,fm,hl=(fm=class{constructor(){Ae(this,Hn);Ae(this,Fn);Ae(this,nr,Object.create(null))}insert(e,t,n,s,i){if(e.length===0){if(w(this,Hn)!==void 0)throw Oi;if(i)return;ue(this,Hn,t);return}const[a,...o]=e,c=a==="*"?o.length===0?["","",$i]:["","",Do]:a==="/*"?["","",Zi]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(c){const f=c[1];let m=c[2]||Do;if(f&&c[2]&&(m=m.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(m)))throw Oi;if(u=w(this,nr)[m],!u){if(Object.keys(w(this,nr)).some(R=>R!==$i&&R!==Zi))throw Oi;if(i)return;u=w(this,nr)[m]=new hl,f!==""&&ue(u,Fn,s.varIndex++)}!i&&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!==$i&&f!==Zi))throw Oi;if(i)return;u=w(this,nr)[a]=new hl}u.insert(o,t,n,s,i)}buildRegExpStr(){const t=Object.keys(w(this,nr)).sort(Xv).map(n=>{const s=w(this,nr)[n];return(typeof w(s,Fn)=="number"?`(${n})@${w(s,Fn)}`:Yv.has(n)?`\\${n}`:n)+s.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,fm),Gc,Ga,hm,Qv=(hm=class{constructor(){Ae(this,Gc,{varIndex:0});Ae(this,Ga,new hl)}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 w(this,Ga).insert(i,e,n,w(this,Gc),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,(s,i,a)=>i!==void 0?(t[++e]=Number(i),"$()"):(a!==void 0&&(n[Number(a)]=++e),"")),[new RegExp(`^${r}`),t,n]}},Gc=new WeakMap,Ga=new WeakMap,hm),Rm=[],eb=[/^$/,[],Object.create(null)],Eo=Object.create(null);function Pm(r){return Eo[r]??(Eo[r]=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:"(?:|/.*)")}$`))}function tb(){Eo=Object.create(null)}function rb(r){var u;const e=new Qv,t=[];if(r.length===0)return eb;const n=r.map(f=>[!/\*|\/:/.test(f[0]),...f]).sort(([f,m],[R,C])=>f?1:R?-1:m.length-C.length),s=Object.create(null);for(let f=0,m=-1,R=n.length;f<R;f++){const[C,p,y]=n[f];C?s[p]=[y.map(([O])=>[O,Object.create(null)]),Rm]:m++;let A;try{A=e.insert(p,m,C)}catch(O){throw O===Oi?new Tm(p):O}C||(t[m]=y.map(([O,P])=>{const N=Object.create(null);for(P-=1;P>=0;P--){const[be,Le]=A[P];N[be]=Le}return[O,N]}))}const[i,a,o]=e.buildRegExp();for(let f=0,m=t.length;f<m;f++)for(let R=0,C=t[f].length;R<C;R++){const p=(u=t[f][R])==null?void 0:u[1];if(!p)continue;const y=Object.keys(p);for(let A=0,O=y.length;A<O;A++)p[y[A]]=o[p[y[A]]]}const c=[];for(const f in a)c[f]=t[a[f]];return[i,c,s]}function _s(r,e){if(r){for(const t of Object.keys(r).sort((n,s)=>s.length-n.length))if(Pm(t).test(e))return[...r[t]]}}var un,ln,oi,$m,Zm,pm,nb=(pm=class{constructor(){Ae(this,oi);se(this,"name","RegExpRouter");Ae(this,un);Ae(this,ln);ue(this,un,{[st]:Object.create(null)}),ue(this,ln,{[st]:Object.create(null)})}add(r,e,t){var o;const n=w(this,un),s=w(this,ln);if(!n||!s)throw new Error(jm);n[r]||[n,s].forEach(c=>{c[r]=Object.create(null),Object.keys(c[st]).forEach(u=>{c[r][u]=[...c[st][u]]})}),e==="/*"&&(e="*");const i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){const c=Pm(e);r===st?Object.keys(n).forEach(u=>{var f;(f=n[u])[e]||(f[e]=_s(n[u],e)||_s(n[st],e)||[])}):(o=n[r])[e]||(o[e]=_s(n[r],e)||_s(n[st],e)||[]),Object.keys(n).forEach(u=>{(r===st||r===u)&&Object.keys(n[u]).forEach(f=>{c.test(f)&&n[u][f].push([t,i])})}),Object.keys(s).forEach(u=>{(r===st||r===u)&&Object.keys(s[u]).forEach(f=>c.test(f)&&s[u][f].push([t,i]))});return}const a=km(e)||[e];for(let c=0,u=a.length;c<u;c++){const f=a[c];Object.keys(s).forEach(m=>{var R;(r===st||r===m)&&((R=s[m])[f]||(R[f]=[..._s(n[m],f)||_s(n[st],f)||[]]),s[m][f].push([t,i-u+c+1]))})}}match(r,e){tb();const t=je(this,oi,$m).call(this);return this.match=(n,s)=>{const i=t[n]||t[st],a=i[2][s];if(a)return a;const o=s.match(i[0]);if(!o)return[[],Rm];const c=o.indexOf("",1);return[i[1][c],o]},this.match(r,e)}},un=new WeakMap,ln=new WeakMap,oi=new WeakSet,$m=function(){const r=Object.create(null);return Object.keys(w(this,ln)).concat(Object.keys(w(this,un))).forEach(e=>{r[e]||(r[e]=je(this,oi,Zm).call(this,e))}),ue(this,un,ue(this,ln,void 0)),r},Zm=function(r){const e=[];let t=r===st;return[w(this,un),w(this,ln)].forEach(n=>{const s=n[r]?Object.keys(n[r]).map(i=>[i,n[r][i]]):[];s.length!==0?(t||(t=!0),e.push(...s)):r!==st&&e.push(...Object.keys(n[st]).map(i=>[i,n[st][i]]))}),t?rb(e):null},pm),dn,Mr,mm,sb=(mm=class{constructor(r){se(this,"name","SmartRouter");Ae(this,dn,[]);Ae(this,Mr,[]);ue(this,dn,r.routers)}add(r,e,t){if(!w(this,Mr))throw new Error(jm);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),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 Tm)continue;throw c}this.match=o.match.bind(o),ue(this,dn,[o]),ue(this,Mr,void 0);break}if(i===s)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,mm),fn,vt,Wn,Ms,Et,Vr,$n,ym,Dm=(ym=class{constructor(r,e,t){Ae(this,Vr);Ae(this,fn);Ae(this,vt);Ae(this,Wn);Ae(this,Ms,0);Ae(this,Et,Object.create(null));if(ue(this,vt,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,Wn,[])}insert(r,e,t){ue(this,Ms,++ph(this,Ms)._);let n=this;const s=Sv(e),i=[];for(let c=0,u=s.length;c<u;c++){const f=s[c];if(Object.keys(w(n,vt)).includes(f)){n=w(n,vt)[f];const R=yh(f);R&&i.push(R[1]);continue}w(n,vt)[f]=new Dm;const m=yh(f);m&&(w(n,Wn).push(m),i.push(m[1])),n=w(n,vt)[f]}const a=Object.create(null),o={handler:t,possibleKeys:i.filter((c,u,f)=>f.indexOf(c)===u),score:w(this,Ms)};return a[r]=o,w(n,fn).push(a),n}search(r,e){const t=[];ue(this,Et,Object.create(null));let s=[this];const i=xm(e);for(let o=0,c=i.length;o<c;o++){const u=i[o],f=o===c-1,m=[];for(let R=0,C=s.length;R<C;R++){const p=s[R],y=w(p,vt)[u];y&&(ue(y,Et,w(p,Et)),f?(w(y,vt)["*"]&&t.push(...je(this,Vr,$n).call(this,w(y,vt)["*"],r,w(p,Et),Object.create(null))),t.push(...je(this,Vr,$n).call(this,y,r,w(p,Et),Object.create(null)))):m.push(y));for(let A=0,O=w(p,Wn).length;A<O;A++){const P=w(p,Wn)[A],N={...w(p,Et)};if(P==="*"){const pt=w(p,vt)["*"];pt&&(t.push(...je(this,Vr,$n).call(this,pt,r,w(p,Et),Object.create(null))),m.push(pt));continue}if(u==="")continue;const[be,Le,qe]=P,De=w(p,vt)[be],tt=i.slice(o).join("/");if(qe instanceof RegExp&&qe.test(tt)){N[Le]=tt,t.push(...je(this,Vr,$n).call(this,De,r,w(p,Et),N));continue}(qe===!0||qe.test(u))&&(N[Le]=u,f?(t.push(...je(this,Vr,$n).call(this,De,r,N,w(p,Et))),w(De,vt)["*"]&&t.push(...je(this,Vr,$n).call(this,w(De,vt)["*"],r,N,w(p,Et)))):(ue(De,Et,N),m.push(De)))}}s=m}return[t.sort((o,c)=>o.score-c.score).map(({handler:o,params:c})=>[o,c])]}},fn=new WeakMap,vt=new WeakMap,Wn=new WeakMap,Ms=new WeakMap,Et=new WeakMap,Vr=new WeakSet,$n=function(r,e,t,n){const s=[];for(let i=0,a=w(r,fn).length;i<a;i++){const o=w(r,fn)[i],c=o[e]||o[st],u={};if(c!==void 0){c.params=Object.create(null);for(let f=0,m=c.possibleKeys.length;f<m;f++){const R=c.possibleKeys[f],C=u[c.score];c.params[R]=n[R]&&!C?n[R]:t[R]??n[R],u[c.score]=!0}s.push(c)}}return s},ym),Kn,gm,ib=(gm=class{constructor(){se(this,"name","TrieRouter");Ae(this,Kn);ue(this,Kn,new Dm)}add(r,e,t){const n=km(e);if(n){for(let s=0,i=n.length;s<i;s++)w(this,Kn).insert(r,n[s],t);return}w(this,Kn).insert(r,e,t)}match(r,e){return w(this,Kn).search(r,e)}},Kn=new WeakMap,gm),ab=class extends Nm{constructor(r={}){super(r),this.router=r.router??new sb({routers:[new nb,new ib]})}},Re;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Re||(Re={}));var pl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(pl||(pl={}));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}},Z=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"]),ob=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let or=class Mm 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 Mm))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Re.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};or.create=r=>new or(r);const Vs=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===z.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Re.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${Re.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Re.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${Re.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}"`:Re.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,Re.assertNever(r)}return{message:t}};let Vm=Vs;function cb(r){Vm=r}function Mo(){return Vm}const Vo=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},ub=[];function H(r,e){const t=Mo(),n=Vo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Vs?void 0:Vs].filter(s=>!!s)});r.common.issues.push(n)}let jt=class Um{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return Um.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}};const pe=Object.freeze({status:"aborted"}),Os=r=>({status:"dirty",value:r}),xt=r=>({status:"valid",value:r}),ml=r=>r.status==="aborted",yl=r=>r.status==="dirty",Li=r=>r.status==="valid",qi=r=>typeof Promise<"u"&&r instanceof Promise;function Uo(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 Lm(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ae||(ae={}));var Ei,Ii;let Sr=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 xh=(r,e)=>{if(Li(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 xe(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}let Se=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(qi(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},i=this._parseSync({data:e,path:s.path,parent:s});return xh(s,i)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sn(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(qi(s)?s:Promise.resolve(s));return xh(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:Z.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new 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 qs.create(this,this._def)}or(e){return Ji.create([this,e],this._def)}and(e){return Yi.create(this,e,this._def)}transform(e){return new dr({...xe(this._def),schema:this,typeName:de.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ta({...xe(this._def),innerType:this,defaultValue:t,typeName:de.ZodDefault})}brand(){return new tf({typeName:de.ZodBranded,type:this,...xe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ra({...xe(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 rf.create(this,e)}readonly(){return na.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const lb=/^c[^\s-]{8,}$/i,db=/^[0-9a-z]+$/,fb=/^[0-9A-HJKMNP-TV-Z]{26}$/,hb=/^[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,pb=/^[a-z0-9_-]{21}$/i,mb=/^[-+]?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)?)??$/,yb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ju;const vb=/^(?:(?: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])$/,bb=/^(([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})))$/,xb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qm="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_b=new RegExp(`^${qm}$`);function Hm(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 wb(r){return new RegExp(`^${Hm(r)}$`)}function Fm(r){let e=`${qm}T${Hm(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 kb(r,e){return!!((e==="v4"||!e)&&vb.test(r)||(e==="v6"||!e)&&bb.test(r))}let Us=class Ci extends Se{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.string,received:i.parsedType}),pe}const n=new jt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?H(s,{code:Z.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&H(s,{code:Z.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")yb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"email",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Ju||(Ju=new RegExp(gb,"u")),Ju.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"emoji",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")hb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"uuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")pb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"nanoid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")lb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")db.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"cuid2",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")fb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"ulid",code:Z.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),H(s,{validation:"url",code:Z.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"regex",code:Z.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Fm(i).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?_b.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?wb(i).test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{code:Z.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?mb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"duration",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?kb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"ip",code:Z.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?xb.test(e.data)||(s=this._getOrReturnCtx(e,s),H(s,{validation:"base64",code:Z.invalid_string,message:i.message}),n.dirty()):Re.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...ae.errToObj(n)})}_addCheck(e){return new Ci({...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 Ci({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ci({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ci({...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}};Us.create=r=>{var e;return new Us({checks:[],typeName:de.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};function Sb(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 Hi=class gl extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==z.number){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.number,received:i.parsedType}),pe}let n;const s=new jt;for(const i of this._def.checks)i.kind==="int"?Re.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:Z.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Sb(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_finite,message:i.message}),s.dirty()):Re.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,s){return new gl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new gl({...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)}};Hi.create=r=>new Hi({checks:[],typeName:de.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});let Fi=class vl extends Se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==z.bigint){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.bigint,received:i.parsedType}),pe}let n;const s=new jt;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),H(n,{code:Z.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),H(n,{code:Z.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Re.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ae.toString(t))}setLimit(e,t,n,s){return new vl({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ae.toString(s)}]})}_addCheck(e){return new vl({...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}};Fi.create=r=>{var e;return new Fi({checks:[],typeName:de.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...xe(r)})};let Wi=class extends Se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.boolean,received:n.parsedType}),pe}return xt(e.data)}};Wi.create=r=>new Wi({typeName:de.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...xe(r)});let Ki=class Wm extends Se{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_type,expected:z.date,received:i.parsedType}),pe}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return H(i,{code:Z.invalid_date}),pe}const n=new jt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),H(s,{code:Z.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Re.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Wm({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ae.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Ki.create=r=>new Ki({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:de.ZodDate,...xe(r)});let Lo=class extends Se{_parse(e){if(this._getType(e)!==z.symbol){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.symbol,received:n.parsedType}),pe}return xt(e.data)}};Lo.create=r=>new Lo({typeName:de.ZodSymbol,...xe(r)});let zi=class extends Se{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.undefined,received:n.parsedType}),pe}return xt(e.data)}};zi.create=r=>new zi({typeName:de.ZodUndefined,...xe(r)});let Gi=class extends Se{_parse(e){if(this._getType(e)!==z.null){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.null,received:n.parsedType}),pe}return xt(e.data)}};Gi.create=r=>new Gi({typeName:de.ZodNull,...xe(r)});let Ls=class extends Se{constructor(){super(...arguments),this._any=!0}_parse(e){return xt(e.data)}};Ls.create=r=>new Ls({typeName:de.ZodAny,...xe(r)});let zn=class extends Se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xt(e.data)}};zn.create=r=>new zn({typeName:de.ZodUnknown,...xe(r)});let Hr=class extends Se{_parse(e){const t=this._getOrReturnCtx(e);return H(t,{code:Z.invalid_type,expected:z.never,received:t.parsedType}),pe}};Hr.create=r=>new Hr({typeName:de.ZodNever,...xe(r)});let qo=class extends Se{_parse(e){if(this._getType(e)!==z.undefined){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.void,received:n.parsedType}),pe}return xt(e.data)}};qo.create=r=>new qo({typeName:de.ZodVoid,...xe(r)});let Qn=class Io extends Se{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==z.array)return H(t,{code:Z.invalid_type,expected:z.array,received:t.parsedType}),pe;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(H(t,{code:a?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(H(t,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(H(t,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Sr(t,a,t.path,o)))).then(a=>jt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Sr(t,a,t.path,o)));return jt.mergeArray(n,i)}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,...xe(e)});function ks(r){if(r instanceof Wt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(ks(n))}return new Wt({...r._def,shape:()=>e})}else return r instanceof Qn?new Qn({...r._def,type:ks(r.element)}):r instanceof xr?xr.create(ks(r.unwrap())):r instanceof vn?vn.create(ks(r.unwrap())):r instanceof gn?gn.create(r.items.map(e=>ks(e))):r}let Wt=class Xt extends Se{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Re.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==z.object){const u=this._getOrReturnCtx(e);return H(u,{code:Z.invalid_type,expected:z.object,received:u.parsedType}),pe}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Hr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Sr(s,m,s.path,u)),alwaysSet:u in s.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:s.data[f]}});else if(u==="strict")o.length>0&&(H(s,{code:Z.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Sr(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,R=await f.value;u.push({key:m,value:R,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 s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ae.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new 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 ks(this)}partial(e){const t={};return Re.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new 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 i=this.shape[n];for(;i instanceof xr;)i=i._def.innerType;t[n]=i}}),new Xt({...this._def,shape:()=>t})}keyof(){return Xm(Re.objectKeys(this.shape))}};Wt.create=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,...xe(e)});Wt.strictCreate=(r,e)=>new Wt({shape:()=>r,unknownKeys:"strict",catchall:Hr.create(),typeName:de.ZodObject,...xe(e)});Wt.lazycreate=(r,e)=>new Wt({shape:r,unknownKeys:"strip",catchall:Hr.create(),typeName:de.ZodObject,...xe(e)});let Ji=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new or(o.ctx.common.issues));return H(t,{code:Z.invalid_union,unionErrors:a}),pe}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new or(c));return H(t,{code:Z.invalid_union,unionErrors:o}),pe}}get options(){return this._def.options}};Ji.create=(r,e)=>new Ji({options:r,typeName:de.ZodUnion,...xe(e)});const Br=r=>r instanceof Xi?Br(r.schema):r instanceof dr?Br(r.innerType()):r instanceof Qi?[r.value]:r instanceof Ja?r.options:r instanceof ea?Re.objectValues(r.enum):r instanceof ta?Br(r._def.innerType):r instanceof zi?[void 0]:r instanceof Gi?[null]:r instanceof xr?[void 0,...Br(r.unwrap())]:r instanceof vn?[null,...Br(r.unwrap())]:r instanceof tf||r instanceof na?Br(r.unwrap()):r instanceof ra?Br(r._def.innerType):[];let Km=class zm extends Se{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.object)return H(t,{code:Z.invalid_type,expected:z.object,received:t.parsedType}),pe;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(H(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=Br(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 zm({typeName:de.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...xe(n)})}};function bl(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 s=Re.objectKeys(e),i=Re.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=bl(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 s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=bl(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===z.date&&n===z.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Yi=class extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(ml(i)||ml(a))return pe;const o=bl(i.value,a.value);return o.valid?((yl(i)||yl(a))&&t.dirty(),{status:t.value,value:o.data}):(H(n,{code:Z.invalid_intersection_types}),pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Yi.create=(r,e,t)=>new Yi({left:r,right:e,typeName:de.ZodIntersection,...xe(t)});let gn=class Gm extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return H(n,{code:Z.invalid_type,expected:z.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return H(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(H(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Sr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>jt.mergeArray(t,a)):jt.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Gm({...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,...xe(e)})};let Jm=class xl extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.object)return H(n,{code:Z.invalid_type,expected:z.object,received:n.parsedType}),pe;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new 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,s):jt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Se?new xl({keyType:e,valueType:t,typeName:de.ZodRecord,...xe(n)}):new xl({keyType:Us.create(),valueType:e,typeName:de.ZodRecord,...xe(t)})}},Ho=class extends Se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.map)return H(n,{code:Z.invalid_type,expected:z.map,received:n.parsedType}),pe;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Sr(n,o,n.path,[u,"key"])),value:i._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}}}};Ho.create=(r,e,t)=>new Ho({valueType:e,keyType:r,typeName:de.ZodMap,...xe(t)});let Fo=class _l extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return H(n,{code:Z.invalid_type,expected:z.set,received:n.parsedType}),pe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(H(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(H(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return pe;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Sr(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new _l({...this._def,minSize:{value:e,message:ae.toString(t)}})}max(e,t){return new _l({...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)}};Fo.create=(r,e)=>new Fo({valueType:r,minSize:null,maxSize:null,typeName:de.ZodSet,...xe(e)});let Ym=class Co extends Se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==z.function)return H(t,{code:Z.invalid_type,expected:z.function,received:t.parsedType}),pe;function n(o,c){return Vo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Mo(),Vs].filter(u=>!!u),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return Vo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Mo(),Vs].filter(u=>!!u),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof qs){const o=this;return xt(async function(...c){const u=new or([]),f=await o._def.args.parseAsync(c,i).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return xt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new or([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new or([s(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,...xe(n)})}},Xi=class extends Se{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Xi.create=(r,e)=>new Xi({getter:r,typeName:de.ZodLazy,...xe(e)});let Qi=class extends Se{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return H(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Qi.create=(r,e)=>new Qi({value:r,typeName:de.ZodLiteral,...xe(e)});function Xm(r,e){return new Ja({values:r,typeName:de.ZodEnum,...xe(e)})}let Ja=class wl extends Se{constructor(){super(...arguments),Ei.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:Z.invalid_type}),pe}if(Uo(this,Ei)||Lm(this,Ei,new Set(this._def.values)),!Uo(this,Ei).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return H(t,{received:t.data,code:Z.invalid_enum_value,options:n}),pe}return xt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return wl.create(e,{...this._def,...t})}exclude(e,t=this._def){return wl.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Ei=new WeakMap;Ja.create=Xm;let ea=class extends Se{constructor(){super(...arguments),Ii.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 s=Re.objectValues(t);return H(n,{expected:Re.joinValues(s),received:n.parsedType,code:Z.invalid_type}),pe}if(Uo(this,Ii)||Lm(this,Ii,new Set(Re.getValidEnumValues(this._def.values))),!Uo(this,Ii).has(e.data)){const s=Re.objectValues(t);return H(n,{received:n.data,code:Z.invalid_enum_value,options:s}),pe}return xt(e.data)}get enum(){return this._def.values}};Ii=new WeakMap;ea.create=(r,e)=>new ea({values:r,typeName:de.ZodNativeEnum,...xe(e)});let qs=class extends Se{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:Z.invalid_type,expected:z.promise,received:t.parsedType}),pe;const n=t.parsedType===z.promise?t.data:Promise.resolve(t.data);return xt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};qs.create=(r,e)=>new qs({type:r,typeName:de.ZodPromise,...xe(e)});let dr=class extends Se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===de.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{H(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return 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"?Os(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"?Os(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?pe:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Li(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=>Li(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Re.assertNever(s)}};dr.create=(r,e,t)=>new dr({schema:r,typeName:de.ZodEffects,effect:e,...xe(t)});dr.createWithPreprocess=(r,e,t)=>new dr({schema:e,effect:{type:"preprocess",transform:r},typeName:de.ZodEffects,...xe(t)});let xr=class extends Se{_parse(e){return this._getType(e)===z.undefined?xt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xr.create=(r,e)=>new xr({innerType:r,typeName:de.ZodOptional,...xe(e)});let vn=class extends Se{_parse(e){return this._getType(e)===z.null?xt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vn.create=(r,e)=>new vn({innerType:r,typeName:de.ZodNullable,...xe(e)});let ta=class extends Se{_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,...xe(e)});let ra=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return qi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new or(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.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,...xe(e)});let Wo=class extends Se{_parse(e){if(this._getType(e)!==z.nan){const n=this._getOrReturnCtx(e);return H(n,{code:Z.invalid_type,expected:z.nan,received:n.parsedType}),pe}return{status:"valid",value:e.data}}};Wo.create=r=>new Wo({typeName:de.ZodNaN,...xe(r)});const Ab=Symbol("zod_brand");let tf=class extends Se{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},rf=class Qm extends Se{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?pe:i.status==="dirty"?(t.dirty(),Os(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?pe:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Qm({in:e,out:t,typeName:de.ZodPipeline})}},na=class extends Se{_parse(e){const t=this._def.innerType._parse(e),n=s=>(Li(s)&&(s.value=Object.freeze(s.value)),s);return qi(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};na.create=(r,e)=>new na({innerType:r,typeName:de.ZodReadonly,...xe(e)});function ey(r,e={},t){return r?Ls.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})}}):Ls.create()}const Ob={object:Wt.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 Eb=(r,e={message:`Input not instance of ${r.name}`})=>ey(t=>t instanceof r,e),ty=Us.create,ry=Hi.create,Ib=Wo.create,Cb=Fi.create,ny=Wi.create,jb=Ki.create,Tb=Lo.create,Nb=zi.create,Bb=Gi.create,Rb=Ls.create,Pb=zn.create,$b=Hr.create,Zb=qo.create,Db=Qn.create,Mb=Wt.create,Vb=Wt.strictCreate,Ub=Ji.create,Lb=Km.create,qb=Yi.create,Hb=gn.create,Fb=Jm.create,Wb=Ho.create,Kb=Fo.create,zb=Ym.create,Gb=Xi.create,Jb=Qi.create,Yb=Ja.create,Xb=ea.create,Qb=qs.create,_h=dr.create,ex=xr.create,tx=vn.create,rx=dr.createWithPreprocess,nx=rf.create,sx=()=>ty().optional(),ix=()=>ry().optional(),ax=()=>ny().optional(),ox={string:r=>Us.create({...r,coerce:!0}),number:r=>Hi.create({...r,coerce:!0}),boolean:r=>Wi.create({...r,coerce:!0}),bigint:r=>Fi.create({...r,coerce:!0}),date:r=>Ki.create({...r,coerce:!0})},cx=pe;var g=Object.freeze({__proto__:null,defaultErrorMap:Vs,setErrorMap:cb,getErrorMap:Mo,makeIssue:Vo,EMPTY_PATH:ub,addIssueToContext:H,ParseStatus:jt,INVALID:pe,DIRTY:Os,OK:xt,isAborted:ml,isDirty:yl,isValid:Li,isAsync:qi,get util(){return Re},get objectUtil(){return pl},ZodParsedType:z,getParsedType:sn,ZodType:Se,datetimeRegex:Fm,ZodString:Us,ZodNumber:Hi,ZodBigInt:Fi,ZodBoolean:Wi,ZodDate:Ki,ZodSymbol:Lo,ZodUndefined:zi,ZodNull:Gi,ZodAny:Ls,ZodUnknown:zn,ZodNever:Hr,ZodVoid:qo,ZodArray:Qn,ZodObject:Wt,ZodUnion:Ji,ZodDiscriminatedUnion:Km,ZodIntersection:Yi,ZodTuple:gn,ZodRecord:Jm,ZodMap:Ho,ZodSet:Fo,ZodFunction:Ym,ZodLazy:Xi,ZodLiteral:Qi,ZodEnum:Ja,ZodNativeEnum:ea,ZodPromise:qs,ZodEffects:dr,ZodTransformer:dr,ZodOptional:xr,ZodNullable:vn,ZodDefault:ta,ZodCatch:ra,ZodNaN:Wo,BRAND:Ab,ZodBranded:tf,ZodPipeline:rf,ZodReadonly:na,custom:ey,Schema:Se,ZodSchema:Se,late:Ob,get ZodFirstPartyTypeKind(){return de},coerce:ox,any:Rb,array:Db,bigint:Cb,boolean:ny,date:jb,discriminatedUnion:Lb,effect:_h,enum:Yb,function:zb,instanceof:Eb,intersection:qb,lazy:Gb,literal:Jb,map:Wb,nan:Ib,nativeEnum:Xb,never:$b,null:Bb,nullable:tx,number:ry,object:Mb,oboolean:ax,onumber:ix,optional:ex,ostring:sx,pipeline:nx,preprocess:rx,promise:Qb,record:Fb,set:Kb,strictObject:Vb,string:ty,symbol:Tb,transformer:_h,tuple:Hb,undefined:Nb,union:Ub,unknown:Pb,void:Zb,NEVER:cx,ZodIssueCode:Z,quotelessJson:ob,ZodError:or}),_t=class kl extends ab{constructor(t){super(t);se(this,"openAPIRegistry");se(this,"defaultHook");se(this,"openapi",({middleware:t,...n},s,i=this.defaultHook)=>{var u,f,m,R,C,p,y,A,O,P;this.openAPIRegistry.registerPath(n);const a=[];if((u=n.request)!=null&&u.query){const N=xs("query",n.request.query,i);a.push(N)}if((f=n.request)!=null&&f.params){const N=xs("param",n.request.params,i);a.push(N)}if((m=n.request)!=null&&m.headers){const N=xs("header",n.request.headers,i);a.push(N)}if((R=n.request)!=null&&R.cookies){const N=xs("cookie",n.request.cookies,i);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 be=o[N].schema;if(be instanceof Se){if(kh(N)){const Le=xs("json",be,i);if((A=(y=n.request)==null?void 0:y.body)!=null&&A.required)a.push(Le);else{const qe=async(De,tt)=>{if(De.req.header("content-type")&&kh(De.req.header("content-type")))return await Le(De,tt);De.req.addValidatedData("json",{}),await tt()};a.push(qe)}}if(Sh(N)){const Le=xs("form",be,i);if((P=(O=n.request)==null?void 0:O.body)!=null&&P.required)a.push(Le);else{const qe=async(De,tt)=>{if(De.req.header("content-type")&&Sh(De.req.header("content-type")))return await Le(De,tt);De.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,s),this});se(this,"getOpenAPIDocument",t=>{const s=new xv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?wh(s,this._basePath):s});se(this,"getOpenAPI31Document",t=>{const s=new kv(this.openAPIRegistry.definitions).generateDocument(t);return this._basePath?wh(s,this._basePath):s});se(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)}}));se(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 rv,this.defaultHook=t==null?void 0:t.defaultHook}route(t,n){const s=t.replaceAll(/:([^\/]+)/g,"{$1}");return super.route(t,n),n instanceof kl?(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:nn(s,i.route.path)});case"webhook":return this.openAPIRegistry.registerWebhook({...i.webhook,path:nn(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 kl({...super.basePath(t),defaultHook:this.defaultHook})}},ge=r=>{const e={...r,getRoutingPath(){return r.path.replaceAll(/\/{(.+?)}/g,"/:$1")}};return Object.defineProperty(e,"getRoutingPath",{enumerable:!1})};X0(g);function wh(r,e){const t={};return Object.keys(r.paths).forEach(n=>{t[nn(e,n)]=r.paths[n]}),{...r,paths:t}}function kh(r){return/^application\/([a-z-\.]+\+)?json/.test(r)}function Sh(r){return r.startsWith("multipart/form-data")||r.startsWith("application/x-www-form-urlencoded")}function ux(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 lx(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ki(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 dx(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,i){var a,o,c,u,f,m;const R=typeof s=="string"?i:s,C=R??{},{param:p}=C,y=ux(C,["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),y),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||p?{param:Object.assign(Object.assign({},(m=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||m===void 0?void 0:m.param),p)}:void 0),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(lx(this,"ZodObject")){const N=this.extend;P.extend=function(...be){var Le,qe,De,tt,pt,Rt;const I=N.apply(this,be);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=(De=this._def.openapi)===null||De===void 0?void 0:De._internal)===null||tt===void 0?void 0:tt.refId,schema:this}:(pt=this._def.openapi)===null||pt===void 0?void 0:pt._internal.extendedFrom},metadata:(Rt=I._def.openapi)===null||Rt===void 0?void 0:Rt.metadata},I}}return P},ki(r,"optional"),ki(r,"nullable"),ki(r,"default"),ki(r,"transform"),ki(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),i=e.apply(this),a=i._def.shape();return Object.entries(a).forEach(([o,c])=>{var u,f;c._def.openapi=(f=(u=s[o])===null||u===void 0?void 0:u._def)===null||f===void 0?void 0:f.openapi}),i._def.openapi=void 0,i};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const i=t.apply(this,s);return i._def.openapi=void 0,i};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const i=n.apply(this,s);return i._def.openapi=void 0,i}}new Set(".\\+*[^]$()");var Pe;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Pe||(Pe={}));var Sl;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Sl||(Sl={}));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}},D=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"]),fx=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(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 Zt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Zt.create=r=>new Zt(r);const Hs=(r,e)=>{let t;switch(r.code){case D.invalid_type:r.received===G.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case D.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Pe.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case D.invalid_union:t="Invalid input";break;case D.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case D.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.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}"`:Pe.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,Pe.assertNever(r)}return{message:t}};let sy=Hs;function hx(r){sy=r}function Ko(){return sy}const zo=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}},px=[];function F(r,e){const t=Ko(),n=zo({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Hs?void 0:Hs].filter(s=>!!s)});r.common.issues.push(n)}class yt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return ye;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ye;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const ye=Object.freeze({status:"aborted"}),Go=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Al=r=>r.status==="aborted",Ol=r=>r.status==="dirty",sa=r=>r.status==="valid",ia=r=>typeof Promise<"u"&&r instanceof Promise;function Jo(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 iy(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var oe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(oe||(oe={}));var ji,Ti;class Ar{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ah=(r,e)=>{if(sa(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 _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(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 Oe{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 yt,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(ia(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:an(e)},i=this._parseSync({data:e,path:s.path,parent:s});return Ah(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:an(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(ia(s)?s:Promise.resolve(s));return Ah(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:D.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new 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 Ws.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({..._e(this._def),schema:this,typeName:fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ma({..._e(this._def),innerType:this,defaultValue:t,typeName:fe.ZodDefault})}brand(){return new nf({typeName:fe.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ya({..._e(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 mx=/^c[^\s-]{8,}$/i,yx=/^[0-9a-z]+$/,gx=/^[0-9A-HJKMNP-TV-Z]{26}$/,vx=/^[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,bx=/^[a-z0-9_-]{21}$/i,xx=/^[-+]?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)?)??$/,_x=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Yu;const kx=/^(?:(?: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])$/,Sx=/^(([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})))$/,Ax=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ay="((\\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])))",Ox=new RegExp(`^${ay}$`);function oy(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 Ex(r){return new RegExp(`^${oy(r)}$`)}function cy(r){let e=`${ay}T${oy(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 Ix(r,e){return!!((e==="v4"||!e)&&kx.test(r)||(e==="v6"||!e)&&Sx.test(r))}class sr extends Oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.string,received:s.parsedType}),ye}const t=new yt;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?F(n,{code:D.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&F(n,{code:D.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")_x.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Yu||(Yu=new RegExp(wx,"u")),Yu.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")vx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")bx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")mx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")yx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")gx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:D.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:D.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:D.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?cy(s).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?Ox.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?Ex(s).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:D.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?xx.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?Ix(e.data,s.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:D.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?Ax.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:D.invalid_string,message:s.message}),t.dirty()):Pe.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:D.invalid_string,...oe.errToObj(n)})}_addCheck(e){return new sr({...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 sr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new sr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new sr({...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}}sr.create=r=>{var e;return new sr({checks:[],typeName:fe.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,..._e(r)})};function Cx(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 bn extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.number,received:s.parsedType}),ye}let t;const n=new yt;for(const s of this._def.checks)s.kind==="int"?Pe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:D.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Cx(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_finite,message:s.message}),n.dirty()):Pe.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,s){return new bn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_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,..._e(r)});class xn extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==G.bigint){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.bigint,received:s.parsedType}),ye}let t;const n=new yt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:D.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Pe.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oe.toString(t))}setLimit(e,t,n,s){return new xn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:oe.toString(s)}]})}_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,..._e(r)})};class aa extends Oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.boolean,received:t.parsedType}),ye}return wt(e.data)}}aa.create=r=>new aa({typeName:fe.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class es extends Oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_type,expected:G.date,received:s.parsedType}),ye}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return F(s,{code:D.invalid_date}),ye}const t=new yt;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:D.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Pe.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new es({...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}}es.create=r=>new es({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:fe.ZodDate,..._e(r)});class Yo extends Oe{_parse(e){if(this._getType(e)!==G.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.symbol,received:t.parsedType}),ye}return wt(e.data)}}Yo.create=r=>new Yo({typeName:fe.ZodSymbol,..._e(r)});class oa extends Oe{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.undefined,received:t.parsedType}),ye}return wt(e.data)}}oa.create=r=>new oa({typeName:fe.ZodUndefined,..._e(r)});class ca extends Oe{_parse(e){if(this._getType(e)!==G.null){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.null,received:t.parsedType}),ye}return wt(e.data)}}ca.create=r=>new ca({typeName:fe.ZodNull,..._e(r)});class Fs extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Fs.create=r=>new Fs({typeName:fe.ZodAny,..._e(r)});class Gn extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Gn.create=r=>new Gn({typeName:fe.ZodUnknown,..._e(r)});class Fr extends Oe{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.never,received:t.parsedType}),ye}}Fr.create=r=>new Fr({typeName:fe.ZodNever,..._e(r)});class Xo extends Oe{_parse(e){if(this._getType(e)!==G.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.void,received:t.parsedType}),ye}return wt(e.data)}}Xo.create=r=>new Xo({typeName:fe.ZodVoid,..._e(r)});class cr extends Oe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==G.array)return F(t,{code:D.invalid_type,expected:G.array,received:t.parsedType}),ye;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(F(t,{code:a?D.too_big:D.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(F(t,{code:D.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(F(t,{code:D.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ar(t,a,t.path,o)))).then(a=>yt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ar(t,a,t.path,o)));return yt.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new 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,..._e(e)});function Ss(r){if(r instanceof Je){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Ss(n))}return new Je({...r._def,shape:()=>e})}else return r instanceof cr?new cr({...r._def,type:Ss(r.element)}):r instanceof _r?_r.create(Ss(r.unwrap())):r instanceof wn?wn.create(Ss(r.unwrap())):r instanceof Or?Or.create(r.items.map(e=>Ss(e))):r}class Je extends Oe{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:D.invalid_type,expected:G.object,received:c.parsedType}),ye}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fr&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||a.push(c);const o=[];for(const c of i){const u=s[c],f=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new 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:D.unrecognized_keys,keys:a}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const f=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new 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=>yt.mergeObjectSync(t,c)):yt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return oe.errToObj,new Je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=oe.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Je({...this._def,unknownKeys:"strip"})}passthrough(){return new Je({...this._def,unknownKeys:"passthrough"})}extend(e){return new Je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Je({...this._def,catchall:e})}pick(e){const t={};return 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 Ss(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new 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 s=this.shape[n];for(;s instanceof _r;)s=s._def.innerType;t[n]=s}}),new Je({...this._def,shape:()=>t})}keyof(){return uy(Pe.objectKeys(this.shape))}}Je.create=(r,e)=>new Je({shape:()=>r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,..._e(e)});Je.strictCreate=(r,e)=>new Je({shape:()=>r,unknownKeys:"strict",catchall:Fr.create(),typeName:fe.ZodObject,..._e(e)});Je.lazycreate=(r,e)=>new Je({shape:r,unknownKeys:"strip",catchall:Fr.create(),typeName:fe.ZodObject,..._e(e)});class ua extends Oe{_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 Zt(o.ctx.common.issues));return F(t,{code:D.invalid_union,unionErrors:a}),ye}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Zt(c));return F(t,{code:D.invalid_union,unionErrors:o}),ye}}get options(){return this._def.options}}ua.create=(r,e)=>new ua({options:r,typeName:fe.ZodUnion,..._e(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 nf||r instanceof ga?rn(r.unwrap()):r instanceof ya?rn(r._def.innerType):[];class Yc extends Oe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return F(t,{code:D.invalid_type,expected:G.object,received:t.parsedType}),ye;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ye)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=rn(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 Yc({typeName:fe.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._e(n)})}}function El(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 s=Pe.objectKeys(e),i=Pe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=El(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===G.array&&n===G.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=El(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===G.date&&n===G.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class la extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Al(i)||Al(a))return ye;const o=El(i.value,a.value);return o.valid?((Ol(i)||Ol(a))&&t.dirty(),{status:t.value,value:o.data}):(F(n,{code:D.invalid_intersection_types}),ye)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}la.create=(r,e,t)=>new la({left:r,right:e,typeName:fe.ZodIntersection,..._e(t)});class Or extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return F(n,{code:D.invalid_type,expected:G.array,received:n.parsedType}),ye;if(n.data.length<this._def.items.length)return F(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ye;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((i,a)=>{const o=this._def.items[a]||this._def.rest;return o?o._parse(new Ar(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>yt.mergeArray(t,i)):yt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new 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,..._e(e)})};class da extends Oe{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:D.invalid_type,expected:G.object,received:n.parsedType}),ye;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new Ar(n,o,n.path,o)),value:a._parse(new Ar(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?yt.mergeObjectAsync(t,s):yt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Oe?new da({keyType:e,valueType:t,typeName:fe.ZodRecord,..._e(n)}):new da({keyType:sr.create(),valueType:e,typeName:fe.ZodRecord,..._e(t)})}}class Qo extends Oe{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:D.invalid_type,expected:G.map,received:n.parsedType}),ye;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ar(n,o,n.path,[u,"key"])),value:i._parse(new Ar(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return ye;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}Qo.create=(r,e,t)=>new Qo({valueType:e,keyType:r,typeName:fe.ZodMap,..._e(t)});class ts extends Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return F(n,{code:D.invalid_type,expected:G.set,received:n.parsedType}),ye;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(F(n,{code:D.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(F(n,{code:D.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return ye;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ar(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ts({...this._def,minSize:{value:e,message:oe.toString(t)}})}max(e,t){return new ts({...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)}}ts.create=(r,e)=>new ts({valueType:r,minSize:null,maxSize:null,typeName:fe.ZodSet,..._e(e)});class Ts extends Oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return F(t,{code:D.invalid_type,expected:G.function,received:t.parsedType}),ye;function n(o,c){return zo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ko(),Hs].filter(u=>!!u),issueData:{code:D.invalid_arguments,argumentsError:c}})}function s(o,c){return zo({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ko(),Hs].filter(u=>!!u),issueData:{code:D.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ws){const o=this;return wt(async function(...c){const u=new Zt([]),f=await o._def.args.parseAsync(c,i).catch(R=>{throw u.addIssue(n(c,R)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(R=>{throw u.addIssue(s(m,R)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Zt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Zt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ts({...this._def,args:Or.create(e).rest(Gn.create())})}returns(e){return new Ts({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ts({args:e||Or.create([]).rest(Gn.create()),returns:t||Gn.create(),typeName:fe.ZodFunction,..._e(n)})}}class fa extends Oe{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,..._e(e)});class ha extends Oe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),ye}return{status:"valid",value:e.data}}get value(){return this._def.value}}ha.create=(r,e)=>new ha({value:r,typeName:fe.ZodLiteral,..._e(e)});function uy(r,e){return new _n({values:r,typeName:fe.ZodEnum,..._e(e)})}class _n extends Oe{constructor(){super(...arguments),ji.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:D.invalid_type}),ye}if(Jo(this,ji)||iy(this,ji,new Set(this._def.values)),!Jo(this,ji).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:D.invalid_enum_value,options:n}),ye}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})}}ji=new WeakMap;_n.create=uy;class pa extends Oe{constructor(){super(...arguments),Ti.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 s=Pe.objectValues(t);return F(n,{expected:Pe.joinValues(s),received:n.parsedType,code:D.invalid_type}),ye}if(Jo(this,Ti)||iy(this,Ti,new Set(Pe.getValidEnumValues(this._def.values))),!Jo(this,Ti).has(e.data)){const s=Pe.objectValues(t);return F(n,{received:n.data,code:D.invalid_enum_value,options:s}),ye}return wt(e.data)}get enum(){return this._def.values}}Ti=new WeakMap;pa.create=(r,e)=>new pa({values:r,typeName:fe.ZodNativeEnum,..._e(e)});class Ws extends Oe{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:D.invalid_type,expected:G.promise,received:t.parsedType}),ye;const n=t.parsedType===G.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ws.create=(r,e)=>new Ws({type:r,typeName:fe.ZodPromise,..._e(e)});class fr extends Oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{F(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return ye;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?ye:c.status==="dirty"||t.value==="dirty"?Go(c.value):c});{if(t.value==="aborted")return ye;const o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?ye:o.status==="dirty"||t.value==="dirty"?Go(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ye:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!sa(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=>sa(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(s)}}fr.create=(r,e,t)=>new fr({schema:r,typeName:fe.ZodEffects,effect:e,..._e(t)});fr.createWithPreprocess=(r,e,t)=>new fr({schema:e,effect:{type:"preprocess",transform:r},typeName:fe.ZodEffects,..._e(t)});class _r extends Oe{_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,..._e(e)});class wn extends Oe{_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,..._e(e)});class ma extends Oe{_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,..._e(e)});class ya extends Oe{_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 ia(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Zt(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,..._e(e)});class ec extends Oe{_parse(e){if(this._getType(e)!==G.nan){const t=this._getOrReturnCtx(e);return F(t,{code:D.invalid_type,expected:G.nan,received:t.parsedType}),ye}return{status:"valid",value:e.data}}}ec.create=r=>new ec({typeName:fe.ZodNaN,..._e(r)});const jx=Symbol("zod_brand");class nf extends Oe{_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 Oe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),Go(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ye:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ya({in:e,out:t,typeName:fe.ZodPipeline})}}class ga extends Oe{_parse(e){const t=this._def.innerType._parse(e),n=s=>(sa(s)&&(s.value=Object.freeze(s.value)),s);return ia(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ga.create=(r,e)=>new ga({innerType:r,typeName:fe.ZodReadonly,..._e(e)});function ly(r,e={},t){return r?Fs.create().superRefine((n,s)=>{var i,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):Fs.create()}const Tx={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 Nx=(r,e={message:`Input not instance of ${r.name}`})=>ly(t=>t instanceof r,e),dy=sr.create,fy=bn.create,Bx=ec.create,Rx=xn.create,hy=aa.create,Px=es.create,$x=Yo.create,Zx=oa.create,Dx=ca.create,Mx=Fs.create,Vx=Gn.create,Ux=Fr.create,Lx=Xo.create,qx=cr.create,Hx=Je.create,Fx=Je.strictCreate,Wx=ua.create,Kx=Yc.create,zx=la.create,Gx=Or.create,Jx=da.create,Yx=Qo.create,Xx=ts.create,Qx=Ts.create,e_=fa.create,t_=ha.create,r_=_n.create,n_=pa.create,s_=Ws.create,Oh=fr.create,i_=_r.create,a_=wn.create,o_=fr.createWithPreprocess,c_=Ya.create,u_=()=>dy().optional(),l_=()=>fy().optional(),d_=()=>hy().optional(),f_={string:r=>sr.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=>es.create({...r,coerce:!0})},h_=ye;var l=Object.freeze({__proto__:null,defaultErrorMap:Hs,setErrorMap:hx,getErrorMap:Ko,makeIssue:zo,EMPTY_PATH:px,addIssueToContext:F,ParseStatus:yt,INVALID:ye,DIRTY:Go,OK:wt,isAborted:Al,isDirty:Ol,isValid:sa,isAsync:ia,get util(){return Pe},get objectUtil(){return Sl},ZodParsedType:G,getParsedType:an,ZodType:Oe,datetimeRegex:cy,ZodString:sr,ZodNumber:bn,ZodBigInt:xn,ZodBoolean:aa,ZodDate:es,ZodSymbol:Yo,ZodUndefined:oa,ZodNull:ca,ZodAny:Fs,ZodUnknown:Gn,ZodNever:Fr,ZodVoid:Xo,ZodArray:cr,ZodObject:Je,ZodUnion:ua,ZodDiscriminatedUnion:Yc,ZodIntersection:la,ZodTuple:Or,ZodRecord:da,ZodMap:Qo,ZodSet:ts,ZodFunction:Ts,ZodLazy:fa,ZodLiteral:ha,ZodEnum:_n,ZodNativeEnum:pa,ZodPromise:Ws,ZodEffects:fr,ZodTransformer:fr,ZodOptional:_r,ZodNullable:wn,ZodDefault:ma,ZodCatch:ya,ZodNaN:ec,BRAND:jx,ZodBranded:nf,ZodPipeline:Ya,ZodReadonly:ga,custom:ly,Schema:Oe,ZodSchema:Oe,late:Tx,get ZodFirstPartyTypeKind(){return fe},coerce:f_,any:Mx,array:qx,bigint:Rx,boolean:hy,date:Px,discriminatedUnion:Kx,effect:Oh,enum:r_,function:Qx,instanceof:Nx,intersection:zx,lazy:e_,literal:t_,map:Yx,nan:Bx,nativeEnum:n_,never:Ux,null:Dx,nullable:a_,number:fy,object:Hx,oboolean:d_,onumber:l_,optional:i_,ostring:u_,pipeline:c_,preprocess:o_,promise:s_,record:Jx,set:Xx,strictObject:Fx,string:dy,symbol:$x,transformer:Oh,tuple:Gx,undefined:Zx,union:Wx,unknown:Vx,void:Lx,NEVER:h_,ZodIssueCode:D,quotelessJson:fx,ZodError:Zt});dx(l);const jn=l.object({start:l.number(),limit:l.number(),length:l.number()}),sf=l.object({created_at:l.string(),updated_at:l.string()}),py=l.object({email:l.string().optional(),email_verified:l.boolean().optional(),name:l.string().optional(),username:l.string().optional(),given_name:l.string().optional(),phone_number:l.string().optional(),phone_verified:l.boolean().optional(),family_name:l.string().optional()}).catchall(l.any()),my=l.object({connection:l.string(),user_id:l.string(),provider:l.string(),isSocial:l.boolean(),access_token:l.string().optional(),access_token_secret:l.string().optional(),refresh_token:l.string().optional(),profileData:py.optional()}),Xc=l.object({email:l.string().optional(),username:l.string().optional(),given_name:l.string().optional(),family_name:l.string().optional(),nickname:l.string().optional(),name:l.string().optional(),picture:l.string().optional(),locale:l.string().optional(),linked_to:l.string().optional(),profileData:l.string().optional(),user_id:l.string().optional(),app_metadata:l.any().default({}).optional(),user_metadata:l.any().default({}).optional()}),tc=Xc.extend({email_verified:l.boolean().default(!1),verify_email:l.boolean().optional(),last_ip:l.string().optional(),last_login:l.string().optional(),user_id:l.string().optional(),provider:l.string().default("email"),connection:l.string().default("email")}),af=l.object({...tc.shape,...sf.shape,user_id:l.string(),email:l.string(),is_social:l.boolean(),login_count:l.number(),identities:l.array(my).optional()}),vr=af,p_=Xc.extend({email:l.string(),login_count:l.number(),multifactor:l.array(l.string()).optional(),last_ip:l.string().optional(),last_login:l.string().optional(),user_id:l.string()}).catchall(l.any()),m_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let y_=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=m_[t[r]&63];return e};const yy=l.object({audience:l.string().optional(),recipient:l.string().optional(),createUpnClaim:l.boolean().optional(),mapUnknownClaimsAsIs:l.boolean().optional(),passthroughClaimsWithNoMapping:l.boolean().optional(),mapIdentities:l.boolean().optional(),signatureAlgorithm:l.string().optional(),digestAlgorithm:l.string().optional(),issuer:l.string().optional(),destination:l.string().optional(),lifetimeInSeconds:l.number().optional(),signResponse:l.boolean().optional(),nameIdentifierFormat:l.string().optional(),nameIdentifierProbes:l.array(l.string()).optional(),authnContextClassRef:l.string().optional(),mappings:l.record(l.string()).optional()}),rc=l.object({id:l.string(),name:l.string(),callbacks:l.array(l.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:l.array(l.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:l.array(l.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:l.array(l.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:l.array(l.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:l.object({samlp:yy.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:l.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:l.string().default(()=>y_()).optional(),disable_sign_ups:l.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Mn=l.object({created_at:l.string().transform(r=>r===null?"":r),updated_at:l.string().transform(r=>r===null?"":r),...rc.shape});var of=(r=>(r.TOKEN="token",r.TOKEN_ID_TOKEN="token id_token",r.CODE="code",r))(of||{}),cf=(r=>(r.QUERY="query",r.FRAGMENT="fragment",r.FORM_POST="form_post",r.WEB_MESSAGE="web_message",r.SAML_POST="saml_post",r))(cf||{}),uf=(r=>(r.S265="S256",r.plain="plain",r))(uf||{});const gy=l.object({client_id:l.string(),vendor_id:l.string().optional(),act_as:l.string().optional(),response_type:l.nativeEnum(of).optional(),response_mode:l.nativeEnum(cf).optional(),redirect_uri:l.string().optional(),audience:l.string().optional(),state:l.string().optional(),nonce:l.string().optional(),scope:l.string().optional(),prompt:l.string().optional(),code_challenge_method:l.nativeEnum(uf).optional(),code_challenge:l.string().optional(),username:l.string().optional(),ui_locales:l.string().optional()}),Il=l.object({colors:l.object({primary:l.string(),page_background:l.object({type:l.string().optional(),start:l.string().optional(),end:l.string().optional(),angle_deg:l.number().optional()}).optional()}).optional(),logo_url:l.string().optional(),favicon_url:l.string().optional(),font:l.object({url:l.string()}).optional()}),nc=l.object({id:l.string().optional(),name:l.string(),strategy:l.enum(["google-oauth2","facebook","vipps","freja","apple","email","auth0","authhero","Username-Password-Authentication","oidc","oauth2","custom"]),options:l.object({kid:l.string().optional(),team_id:l.string().optional(),realms:l.string().optional(),client_id:l.string().optional(),client_secret:l.string().optional(),app_secret:l.string().optional(),scope:l.string().optional(),authorization_endpoint:l.string().default("").optional(),token_endpoint:l.string().default("").optional(),userinfo_endpoint:l.string().default("").optional(),jwks_uri:l.string().default("").optional(),discovery_url:l.string().default("").optional(),issuer:l.string().default("").optional()}).default({}).optional(),enabled_clients:l.array(l.string()).default([]).optional(),response_type:l.custom().optional(),response_mode:l.custom().optional()}),Vn=l.object({id:l.string(),created_at:l.string().transform(r=>r===null?"":r),updated_at:l.string().transform(r=>r===null?"":r)}).extend(nc.shape),sc=l.object({name:l.string(),audience:l.string(),sender_email:l.string().email(),sender_name:l.string(),support_url:l.string().url().optional(),logo:l.string().url().optional(),primary_color:l.string().optional(),secondary_color:l.string().optional(),language:l.string().optional()}),Ns=l.object({created_at:l.string().transform(r=>r===null?"":r),updated_at:l.string().transform(r=>r===null?"":r),id:l.string(),...sc.shape}),g_=l.object({logoUrl:l.string(),loginBackgroundImage:l.string().nullish(),style:l.object({primaryColor:l.string(),buttonTextColor:l.string(),primaryHoverColor:l.string()}),supportEmail:l.string().nullable(),supportUrl:l.string().nullable(),name:l.string(),showGreyishBackground:l.boolean().optional(),termsAndConditionsUrl:l.string().nullable(),companyName:l.string().optional(),checkoutHideSocial:l.boolean().optional(),siteUrl:l.string().nullable(),manageSubscriptionsUrl:l.string().optional()}),v_=l.object({domain:l.string(),dkim_private_key:l.string().optional(),dkim_public_key:l.string().optional(),email_api_key:l.string().optional(),email_service:l.union([l.literal("mailgun"),l.literal("mailchannels")]).optional()});l.object({...Mn.shape,domains:l.array(v_),tenant:Ns,connections:l.array(Vn)});const vy=l.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),by=l.object({code_id:l.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:l.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:l.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:vy,code_verifier:l.string().optional(),expires_at:l.string(),used_at:l.string().optional(),user_id:l.string().optional()}),b_=l.object({...by.shape,created_at:l.string()}),xy=l.object({domain:l.string(),dkim_private_key:l.string().optional(),dkim_public_key:l.string().optional(),email_api_key:l.string().optional(),email_service:l.enum(["mailgun","mailchannels"])}),x_=sf.extend({...xy.shape,id:l.string()}),ic=l.object({trigger_id:l.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:l.boolean().default(!1),url:l.string(),hook_id:l.string().optional(),synchronous:l.boolean().default(!1),priority:l.number().optional()}),Es=ic.extend({...sf.shape,hook_id:l.string()}),lf=l.object({alg:l.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:l.string(),kid:l.string(),kty:l.enum(["RSA","EC","oct"]),n:l.string(),x5t:l.string().optional(),x5c:l.array(l.string()).optional(),use:l.enum(["sig","enc"]).optional()}),_y=l.object({keys:l.array(lf)}),Cl=l.object({issuer:l.string(),authorization_endpoint:l.string(),token_endpoint:l.string(),device_authorization_endpoint:l.string(),userinfo_endpoint:l.string(),mfa_challenge_endpoint:l.string(),jwks_uri:l.string(),registration_endpoint:l.string(),revocation_endpoint:l.string(),scopes_supported:l.array(l.string()),response_types_supported:l.array(l.string()),code_challenge_methods_supported:l.array(l.string()),response_modes_supported:l.array(l.string()),subject_types_supported:l.array(l.string()),id_token_signing_alg_values_supported:l.array(l.string()),token_endpoint_auth_methods_supported:l.array(l.string()),claims_supported:l.array(l.string()),request_uri_parameter_supported:l.boolean(),request_parameter_supported:l.boolean(),token_endpoint_auth_signing_alg_values_supported:l.array(l.string())}),wy=l.object({auth0Client:l.string().optional(),authParams:gy,expires_at:l.string(),deleted_at:l.string().optional(),ip:l.string().optional()}).openapi({description:"This represents a login sesion"}),__=l.object({...wy.shape,login_id:l.string().openapi({description:"This is is used as the state in the universal login"}),created_at:l.string(),updated_at:l.string()});var Qc=(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))(Qc||{});const w_=l.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"]),ky=l.object({name:l.string(),version:l.string(),env:l.object({node:l.string().optional()}).optional()}),ac=l.object({type:w_,date:l.string(),description:l.string().optional(),log_id:l.string().optional(),_id:l.string().optional(),ip:l.string(),user_agent:l.string(),details:l.any().optional(),isMobile:l.boolean(),user_id:l.string().optional(),user_name:l.string().optional(),connection:l.string().optional(),connection_id:l.string().optional(),client_id:l.string().optional(),client_name:l.string().optional(),audience:l.string().optional(),scope:l.array(l.string()).optional(),strategy:l.string().optional(),strategy_type:l.string().optional(),hostname:l.string().optional(),auth0_client:ky.optional()}),Sy=l.object({user_id:l.string(),password:l.string(),algorithm:l.enum(["bcrypt","argon2id"]).default("argon2id")}),k_=l.object({...Sy.shape,created_at:l.string(),updated_at:l.string()}),Ay=l.object({session_id:l.string(),client_id:l.string(),expires_at:l.string(),used_at:l.string(),deleted_at:l.string().optional(),user_id:l.string()}),df=l.object({created_at:l.string(),...Ay.shape}),jl=l.object({kid:l.string().openapi({description:"The key id of the signing key"}),cert:l.string().openapi({description:"The public certificate of the signing key"}),fingerprint:l.string().openapi({description:"The cert fingerprint"}),thumbprint:l.string().openapi({description:"The cert thumbprint"}),pkcs7:l.string().optional().openapi({description:"The private key in pkcs7 format"}),current:l.boolean().optional().openapi({description:"True if the key is the current key"}),next:l.boolean().optional().openapi({description:"True if the key is the next key"}),previous:l.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:l.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:l.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:l.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:l.string().optional().openapi({description:"The date and time when the key was revoked"})});var ff=(r=>(r.RefreshToken="refresh_token",r.AuthorizationCode="authorization_code",r.ClientCredential="client_credentials",r.Passwordless="passwordless",r.Password="password",r))(ff||{});const hf=l.nativeEnum(ff),S_=l.object({grant_type:hf.refine(r=>r==="authorization_code"),code:l.string(),client_secret:l.string(),client_id:l.string()}),A_=l.object({grant_type:hf.refine(r=>r==="authorization_code"),code:l.string(),code_verifier:l.string(),client_id:l.string().optional(),redirect_uri:l.string()}),O_=l.object({grant_type:hf.refine(r=>r==="client_credentials"),scope:l.string().optional(),client_secret:l.string(),client_id:l.string(),audience:l.string().optional()});l.object({access_token:l.string(),id_token:l.string().optional(),scope:l.string().optional(),state:l.string().optional(),refresh_token:l.string().optional(),token_type:l.string(),expires_in:l.number()});l.object({code:l.string(),state:l.string().optional()});const Oy=l.object({button_border_radius:l.number(),button_border_weight:l.number(),buttons_style:l.enum(["pill"]),input_border_radius:l.number(),input_border_weight:l.number(),inputs_style:l.enum(["pill"]),show_widget_shadow:l.boolean(),widget_border_weight:l.number(),widget_corner_radius:l.number()}),Ey=l.object({base_focus_color:l.string(),base_hover_color:l.string(),body_text:l.string(),captcha_widget_theme:l.enum(["auto"]),error:l.string(),header:l.string(),icons:l.string(),input_background:l.string(),input_border:l.string(),input_filled_text:l.string(),input_labels_placeholders:l.string(),links_focused_components:l.string(),primary_button:l.string(),primary_button_label:l.string(),secondary_button_border:l.string(),secondary_button_label:l.string(),success:l.string(),widget_background:l.string(),widget_border:l.string()}),Zn=l.object({bold:l.boolean(),size:l.number()}),Iy=l.object({body_text:Zn,buttons_text:Zn,font_url:l.string(),input_labels:Zn,links:Zn,links_style:l.enum(["normal"]),reference_text_size:l.number(),subtitle:Zn,title:Zn}),Cy=l.object({background_color:l.string(),background_image_url:l.string(),page_layout:l.enum(["center"])}),jy=l.object({header_text_alignment:l.enum(["center"]),logo_height:l.number(),logo_position:l.enum(["center"]),logo_url:l.string(),social_buttons_layout:l.enum(["bottom"])}),Ty=l.object({borders:Oy,colors:Ey,displayName:l.string(),fonts:Iy,page_background:Cy,widget:jy}),E_=Ty.extend({themeId:l.string()}),jo=l.object({universal_login_experience:l.enum(["new","classic"]).default("new"),identifier_first:l.boolean().default(!0),password_first:l.boolean().default(!1),webauthn_platform_first_factor:l.boolean()}),To=l.object({name:l.string(),enabled:l.boolean().optional().default(!0),default_from_address:l.string().optional(),credentials:l.union([l.object({accessKeyId:l.string(),secretAccessKey:l.string(),region:l.string()}),l.object({smtp_host:l.array(l.string()),smtp_port:l.number(),smtp_user:l.string(),smtp_pass:l.string()}),l.object({api_key:l.string(),domain:l.string().optional()}),l.object({connectionString:l.string()}),l.object({tenantId:l.string(),clientId:l.string(),clientSecret:l.string()})]),settings:l.object({}).optional()});function I_(r){const[e,t]=r.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${r}`);return{connection:e,id:t}}var oc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function C_(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function j_(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
|
|
2
2
|
Copyright (C) Microsoft. All rights reserved.
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
4
|
this file except in compliance with the License. You may obtain a copy of the
|
|
@@ -11,7 +11,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
11
11
|
|
|
12
12
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
13
13
|
and limitations under the License.
|
|
14
|
-
***************************************************************************** */var Oh;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof ac=="object"?ac:typeof self=="object"?self:typeof this=="object"?this:o(),n=s(r);typeof t.Reflect<"u"&&(n=s(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function s(c,u){return function(f,m){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:m}),u&&u(f,m)}}function i(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function o(){return i()||a()}})(function(e,t){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",i=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!o&&!c,f={create:o?function(){return Fu(Object.create(null))}:c?function(){return Fu({__proto__:null})}:function(){return Fu({})},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),R=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:q0(),C=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:H0(),p=typeof WeakMap=="function"?WeakMap:F0(),y=s?Symbol.for("@reflect-metadata:registry"):void 0,A=V0(),O=U0(A);function P(_,S,T,U){if(Q(T)){if(!sh(_))throw new TypeError;if(!ih(S))throw new TypeError;return E(_,S)}else{if(!sh(_))throw new TypeError;if(!He(S))throw new TypeError;if(!He(U)&&!Q(U)&&!ot(U))throw new TypeError;return ot(U)&&(U=void 0),T=yr(T),k(_,S,T,U)}}e("decorate",P);function N(_,S){function T(U,le){if(!He(U))throw new TypeError;if(!Q(le)&&!D0(le))throw new TypeError;Ie(_,S,U,le)}return T}e("metadata",N);function ve(_,S,T,U){if(!He(T))throw new TypeError;return Q(U)||(U=yr(U)),Ie(_,S,T,U)}e("defineMetadata",ve);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)),V(_,S,T)}e("getOwnMetadata",tt);function pt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),ie(_,S)}e("getMetadataKeys",pt);function Rt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),Te(_,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 U=bi(S,T,!1);return Q(U)?!1:U.OrdinaryDeleteMetadata(_,S,T)}e("deleteMetadata",I);function E(_,S){for(var T=_.length-1;T>=0;--T){var U=_[T],le=U(S);if(!Q(le)&&!ot(le)){if(!ih(le))throw new TypeError;S=le}}return S}function k(_,S,T,U){for(var le=_.length-1;le>=0;--le){var ct=_[le],nt=ct(S,T,U);if(!Q(nt)&&!ot(nt)){if(!He(nt))throw new TypeError;U=nt}}return U}function x(_,S,T){var U=b(_,S,T);if(U)return!0;var le=Hu(S);return ot(le)?!1:x(_,le,T)}function b(_,S,T){var U=bi(S,T,!1);return Q(U)?!1:nh(U.OrdinaryHasOwnMetadata(_,S,T))}function j(_,S,T){var U=b(_,S,T);if(U)return V(_,S,T);var le=Hu(S);if(!ot(le))return j(_,le,T)}function V(_,S,T){var U=bi(S,T,!1);if(!Q(U))return U.OrdinaryGetOwnMetadata(_,S,T)}function Ie(_,S,T,U){var le=bi(T,U,!0);le.OrdinaryDefineOwnMetadata(_,S,T,U)}function ie(_,S){var T=Te(_,S),U=Hu(_);if(U===null)return T;var le=ie(U,S);if(le.length<=0)return T;if(T.length<=0)return le;for(var ct=new C,nt=[],Ce=0,K=T;Ce<K.length;Ce++){var ee=K[Ce],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}for(var ne=0,Ne=le;ne<Ne.length;ne++){var ee=Ne[ne],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}return nt}function Te(_,S){var T=bi(_,S,!1);return T?T.OrdinaryOwnMetadataKeys(_,S):[]}function Ve(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function 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(Ve(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var T="string",U=ah(_,i);if(U!==void 0){var le=U.call(_,T);if(He(le))throw new TypeError;return le}return $0(_)}function $0(_,S){var T,U;{var le=_.toString;if(vo(le)){var U=le.call(_);if(!He(U))return U}var T=_.valueOf;if(vo(T)){var U=T.call(_);if(!He(U))return U}}throw new TypeError}function nh(_){return!!_}function Z0(_){return""+_}function yr(_){var S=rt(_);return Rn(S)?S:Z0(S)}function sh(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function vo(_){return typeof _=="function"}function ih(_){return typeof _=="function"}function D0(_){switch(Ve(_)){case 3:return!0;case 4:return!0;default:return!1}}function qu(_,S){return _===S||_!==_&&S!==S}function ah(_,S){var T=_[S];if(T!=null){if(!vo(T))throw new TypeError;return T}}function oh(_){var S=ah(_,a);if(!vo(S))throw new TypeError;var T=S.call(_);if(!He(T))throw new TypeError;return T}function ch(_){return _.value}function uh(_){var S=_.next();return S.done?!1:S}function lh(_){var S=_.return;S&&S.call(_)}function Hu(_){var S=Object.getPrototypeOf(_);if(typeof _!="function"||_===m||S!==m)return S;var T=_.prototype,U=T&&Object.getPrototypeOf(T);if(U==null||U===Object.prototype)return S;var le=U.constructor;return typeof le!="function"||le===_?S:le}function M0(){var _;!Q(y)&&typeof t.Reflect<"u"&&!(y in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=L0(t.Reflect));var S,T,U,le=new p,ct={registerProvider:nt,getProvider:K,setProvider:re};return ct;function nt(ne){if(!Object.isExtensible(ct))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===ne:break;case Q(S):S=ne;break;case S===ne:break;case Q(T):T=ne;break;case T===ne:break;default:U===void 0&&(U=new C),U.add(ne);break}}function Ce(ne,Ne){if(!Q(S)){if(S.isProviderFor(ne,Ne))return S;if(!Q(T)){if(T.isProviderFor(ne,Ne))return S;if(!Q(U))for(var Fe=oh(U);;){var Xe=uh(Fe);if(!Xe)return;var Yt=ch(Xe);if(Yt.isProviderFor(ne,Ne))return lh(Fe),Yt}}}if(!Q(_)&&_.isProviderFor(ne,Ne))return _}function K(ne,Ne){var Fe=le.get(ne),Xe;return Q(Fe)||(Xe=Fe.get(Ne)),Q(Xe)&&(Xe=Ce(ne,Ne),Q(Xe)||(Q(Fe)&&(Fe=new R,le.set(ne,Fe)),Fe.set(Ne,Xe))),Xe}function ee(ne){if(Q(ne))throw new TypeError;return S===ne||T===ne||!Q(U)&&U.has(ne)}function re(ne,Ne,Fe){if(!ee(Fe))throw new Error("Metadata provider not registered.");var Xe=K(ne,Ne);if(Xe!==Fe){if(!Q(Xe))return!1;var Yt=le.get(ne);Q(Yt)&&(Yt=new R,le.set(ne,Yt)),Yt.set(Ne,Fe)}return!0}}function V0(){var _;return!Q(y)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[y]),Q(_)&&(_=M0()),!Q(y)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function U0(_){var S=new p,T={isProviderFor:function(ee,re){var ne=S.get(ee);return Q(ne)?!1:ne.has(re)},OrdinaryDefineOwnMetadata:nt,OrdinaryHasOwnMetadata:le,OrdinaryGetOwnMetadata:ct,OrdinaryOwnMetadataKeys:Ce,OrdinaryDeleteMetadata:K};return A.registerProvider(T),T;function U(ee,re,ne){var Ne=S.get(ee),Fe=!1;if(Q(Ne)){if(!ne)return;Ne=new R,S.set(ee,Ne),Fe=!0}var Xe=Ne.get(re);if(Q(Xe)){if(!ne)return;if(Xe=new R,Ne.set(re,Xe),!_.setProvider(ee,re,T))throw Ne.delete(re),Fe&&S.delete(ee),new Error("Wrong provider for target.")}return Xe}function le(ee,re,ne){var Ne=U(re,ne,!1);return Q(Ne)?!1:nh(Ne.has(ee))}function ct(ee,re,ne){var Ne=U(re,ne,!1);if(!Q(Ne))return Ne.get(ee)}function nt(ee,re,ne,Ne){var Fe=U(ne,Ne,!0);Fe.set(ee,re)}function Ce(ee,re){var ne=[],Ne=U(ee,re,!1);if(Q(Ne))return ne;for(var Fe=Ne.keys(),Xe=oh(Fe),Yt=0;;){var dh=uh(Xe);if(!dh)return ne.length=Yt,ne;var W0=ch(dh);try{ne[Yt]=W0}catch(K0){try{lh(Xe)}finally{throw K0}}Yt++}}function K(ee,re,ne){var Ne=U(re,ne,!1);if(Q(Ne)||!Ne.delete(ee))return!1;if(Ne.size===0){var Fe=S.get(re);Q(Fe)||(Fe.delete(ne),Fe.size===0&&S.delete(Fe))}return!0}}function L0(_){var S=_.defineMetadata,T=_.hasOwnMetadata,U=_.getOwnMetadata,le=_.getOwnMetadataKeys,ct=_.deleteMetadata,nt=new p,Ce={isProviderFor:function(K,ee){var re=nt.get(K);return!Q(re)&&re.has(ee)?!0:le(K,ee).length?(Q(re)&&(re=new C,nt.set(K,re)),re.add(ee),!0):!1},OrdinaryDefineOwnMetadata:S,OrdinaryHasOwnMetadata:T,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:le,OrdinaryDeleteMetadata:ct};return Ce}function bi(_,S,T){var U=A.getProvider(_,S);if(!Q(U))return U;if(T){if(A.setProvider(_,S,O))return O;throw new Error("Illegal state.")}}function q0(){var _={},S=[],T=function(){function Ce(K,ee,re){this._index=0,this._keys=K,this._values=ee,this._selector=re}return Ce.prototype["@@iterator"]=function(){return this},Ce.prototype[a]=function(){return this},Ce.prototype.next=function(){var K=this._index;if(K>=0&&K<this._keys.length){var ee=this._selector(this._keys[K],this._values[K]);return K+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}},Ce.prototype.throw=function(K){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),K},Ce.prototype.return=function(K){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:K,done:!0}},Ce}(),U=function(){function Ce(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(Ce.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ce.prototype.has=function(K){return this._find(K,!1)>=0},Ce.prototype.get=function(K){var ee=this._find(K,!1);return ee>=0?this._values[ee]:void 0},Ce.prototype.set=function(K,ee){var re=this._find(K,!0);return this._values[re]=ee,this},Ce.prototype.delete=function(K){var ee=this._find(K,!1);if(ee>=0){for(var re=this._keys.length,ne=ee+1;ne<re;ne++)this._keys[ne-1]=this._keys[ne],this._values[ne-1]=this._values[ne];return this._keys.length--,this._values.length--,qu(K,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},Ce.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},Ce.prototype.keys=function(){return new T(this._keys,this._values,le)},Ce.prototype.values=function(){return new T(this._keys,this._values,ct)},Ce.prototype.entries=function(){return new T(this._keys,this._values,nt)},Ce.prototype["@@iterator"]=function(){return this.entries()},Ce.prototype[a]=function(){return this.entries()},Ce.prototype._find=function(K,ee){if(!qu(this._cacheKey,K)){this._cacheIndex=-1;for(var re=0;re<this._keys.length;re++)if(qu(this._keys[re],K)){this._cacheIndex=re;break}}return this._cacheIndex<0&&ee&&(this._cacheIndex=this._keys.length,this._keys.push(K),this._values.push(void 0)),this._cacheIndex},Ce}();return U;function le(Ce,K){return Ce}function ct(Ce,K){return K}function nt(Ce,K){return[Ce,K]}}function H0(){var _=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(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 F0(){var _=16,S=f.create(),T=U();return function(){function K(){this._key=U()}return K.prototype.has=function(ee){var re=le(ee,!1);return re!==void 0?f.has(re,this._key):!1},K.prototype.get=function(ee){var re=le(ee,!1);return re!==void 0?f.get(re,this._key):void 0},K.prototype.set=function(ee,re){var ne=le(ee,!0);return ne[this._key]=re,this},K.prototype.delete=function(ee){var re=le(ee,!1);return re!==void 0?delete re[this._key]:!1},K.prototype.clear=function(){this._key=U()},K}();function U(){var K;do K="@@WeakMap@@"+Ce();while(f.has(S,K));return S[K]=!0,K}function le(K,ee){if(!n.call(K,T)){if(!ee)return;Object.defineProperty(K,T,{value:f.create()})}return K[T]}function ct(K,ee){for(var re=0;re<ee;++re)K[re]=Math.random()*255|0;return K}function nt(K){if(typeof Uint8Array=="function"){var ee=new Uint8Array(K);return typeof crypto<"u"?crypto.getRandomValues(ee):typeof msCrypto<"u"?msCrypto.getRandomValues(ee):ct(ee,K),ee}return ct(new Array(K),K)}function Ce(){var K=nt(_);K[6]=K[6]&79|64,K[8]=K[8]&191|128;for(var ee="",re=0;re<_;++re){var ne=K[re];(re===4||re===6||re===8)&&(ee+="-"),ne<16&&(ee+="0"),ee+=ne.toString(16).toLowerCase()}return ee}}function Fu(_){return _.__=void 0,delete _.__,_}})})(Oh||(Oh={}));/*!
|
|
14
|
+
***************************************************************************** */var Eh;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof oc=="object"?oc:typeof self=="object"?self:typeof this=="object"?this:o(),n=s(r);typeof t.Reflect<"u"&&(n=s(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function s(c,u){return function(f,m){Object.defineProperty(c,f,{configurable:!0,writable:!0,value:m}),u&&u(f,m)}}function i(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function o(){return i()||a()}})(function(e,t){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",i=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",o=typeof Object.create=="function",c={__proto__:[]}instanceof Array,u=!o&&!c,f={create:o?function(){return Wu(Object.create(null))}:c?function(){return Wu({__proto__:null})}:function(){return Wu({})},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),R=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:H0(),C=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:F0(),p=typeof WeakMap=="function"?WeakMap:W0(),y=s?Symbol.for("@reflect-metadata:registry"):void 0,A=U0(),O=L0(A);function P(_,S,T,U){if(Q(T)){if(!ih(_))throw new TypeError;if(!ah(S))throw new TypeError;return E(_,S)}else{if(!ih(_))throw new TypeError;if(!He(S))throw new TypeError;if(!He(U)&&!Q(U)&&!ot(U))throw new TypeError;return ot(U)&&(U=void 0),T=yr(T),k(_,S,T,U)}}e("decorate",P);function N(_,S){function T(U,le){if(!He(U))throw new TypeError;if(!Q(le)&&!M0(le))throw new TypeError;Ie(_,S,U,le)}return T}e("metadata",N);function be(_,S,T,U){if(!He(T))throw new TypeError;return Q(U)||(U=yr(U)),Ie(_,S,T,U)}e("defineMetadata",be);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 De(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),j(_,S,T)}e("getMetadata",De);function tt(_,S,T){if(!He(S))throw new TypeError;return Q(T)||(T=yr(T)),V(_,S,T)}e("getOwnMetadata",tt);function pt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),ie(_,S)}e("getMetadataKeys",pt);function Rt(_,S){if(!He(_))throw new TypeError;return Q(S)||(S=yr(S)),Te(_,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 U=bi(S,T,!1);return Q(U)?!1:U.OrdinaryDeleteMetadata(_,S,T)}e("deleteMetadata",I);function E(_,S){for(var T=_.length-1;T>=0;--T){var U=_[T],le=U(S);if(!Q(le)&&!ot(le)){if(!ah(le))throw new TypeError;S=le}}return S}function k(_,S,T,U){for(var le=_.length-1;le>=0;--le){var ct=_[le],nt=ct(S,T,U);if(!Q(nt)&&!ot(nt)){if(!He(nt))throw new TypeError;U=nt}}return U}function x(_,S,T){var U=b(_,S,T);if(U)return!0;var le=Fu(S);return ot(le)?!1:x(_,le,T)}function b(_,S,T){var U=bi(S,T,!1);return Q(U)?!1:sh(U.OrdinaryHasOwnMetadata(_,S,T))}function j(_,S,T){var U=b(_,S,T);if(U)return V(_,S,T);var le=Fu(S);if(!ot(le))return j(_,le,T)}function V(_,S,T){var U=bi(S,T,!1);if(!Q(U))return U.OrdinaryGetOwnMetadata(_,S,T)}function Ie(_,S,T,U){var le=bi(T,U,!0);le.OrdinaryDefineOwnMetadata(_,S,T,U)}function ie(_,S){var T=Te(_,S),U=Fu(_);if(U===null)return T;var le=ie(U,S);if(le.length<=0)return T;if(T.length<=0)return le;for(var ct=new C,nt=[],Ce=0,K=T;Ce<K.length;Ce++){var ee=K[Ce],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}for(var ne=0,Ne=le;ne<Ne.length;ne++){var ee=Ne[ne],re=ct.has(ee);re||(ct.add(ee),nt.push(ee))}return nt}function Te(_,S){var T=bi(_,S,!1);return T?T.OrdinaryOwnMetadataKeys(_,S):[]}function Ve(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function 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(Ve(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var T="string",U=oh(_,i);if(U!==void 0){var le=U.call(_,T);if(He(le))throw new TypeError;return le}return Z0(_)}function Z0(_,S){var T,U;{var le=_.toString;if(vo(le)){var U=le.call(_);if(!He(U))return U}var T=_.valueOf;if(vo(T)){var U=T.call(_);if(!He(U))return U}}throw new TypeError}function sh(_){return!!_}function D0(_){return""+_}function yr(_){var S=rt(_);return Rn(S)?S:D0(S)}function ih(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function vo(_){return typeof _=="function"}function ah(_){return typeof _=="function"}function M0(_){switch(Ve(_)){case 3:return!0;case 4:return!0;default:return!1}}function Hu(_,S){return _===S||_!==_&&S!==S}function oh(_,S){var T=_[S];if(T!=null){if(!vo(T))throw new TypeError;return T}}function ch(_){var S=oh(_,a);if(!vo(S))throw new TypeError;var T=S.call(_);if(!He(T))throw new TypeError;return T}function uh(_){return _.value}function lh(_){var S=_.next();return S.done?!1:S}function dh(_){var S=_.return;S&&S.call(_)}function Fu(_){var S=Object.getPrototypeOf(_);if(typeof _!="function"||_===m||S!==m)return S;var T=_.prototype,U=T&&Object.getPrototypeOf(T);if(U==null||U===Object.prototype)return S;var le=U.constructor;return typeof le!="function"||le===_?S:le}function V0(){var _;!Q(y)&&typeof t.Reflect<"u"&&!(y in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=q0(t.Reflect));var S,T,U,le=new p,ct={registerProvider:nt,getProvider:K,setProvider:re};return ct;function nt(ne){if(!Object.isExtensible(ct))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===ne:break;case Q(S):S=ne;break;case S===ne:break;case Q(T):T=ne;break;case T===ne:break;default:U===void 0&&(U=new C),U.add(ne);break}}function Ce(ne,Ne){if(!Q(S)){if(S.isProviderFor(ne,Ne))return S;if(!Q(T)){if(T.isProviderFor(ne,Ne))return S;if(!Q(U))for(var Fe=ch(U);;){var Xe=lh(Fe);if(!Xe)return;var Yt=uh(Xe);if(Yt.isProviderFor(ne,Ne))return dh(Fe),Yt}}}if(!Q(_)&&_.isProviderFor(ne,Ne))return _}function K(ne,Ne){var Fe=le.get(ne),Xe;return Q(Fe)||(Xe=Fe.get(Ne)),Q(Xe)&&(Xe=Ce(ne,Ne),Q(Xe)||(Q(Fe)&&(Fe=new R,le.set(ne,Fe)),Fe.set(Ne,Xe))),Xe}function ee(ne){if(Q(ne))throw new TypeError;return S===ne||T===ne||!Q(U)&&U.has(ne)}function re(ne,Ne,Fe){if(!ee(Fe))throw new Error("Metadata provider not registered.");var Xe=K(ne,Ne);if(Xe!==Fe){if(!Q(Xe))return!1;var Yt=le.get(ne);Q(Yt)&&(Yt=new R,le.set(ne,Yt)),Yt.set(Ne,Fe)}return!0}}function U0(){var _;return!Q(y)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[y]),Q(_)&&(_=V0()),!Q(y)&&He(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function L0(_){var S=new p,T={isProviderFor:function(ee,re){var ne=S.get(ee);return Q(ne)?!1:ne.has(re)},OrdinaryDefineOwnMetadata:nt,OrdinaryHasOwnMetadata:le,OrdinaryGetOwnMetadata:ct,OrdinaryOwnMetadataKeys:Ce,OrdinaryDeleteMetadata:K};return A.registerProvider(T),T;function U(ee,re,ne){var Ne=S.get(ee),Fe=!1;if(Q(Ne)){if(!ne)return;Ne=new R,S.set(ee,Ne),Fe=!0}var Xe=Ne.get(re);if(Q(Xe)){if(!ne)return;if(Xe=new R,Ne.set(re,Xe),!_.setProvider(ee,re,T))throw Ne.delete(re),Fe&&S.delete(ee),new Error("Wrong provider for target.")}return Xe}function le(ee,re,ne){var Ne=U(re,ne,!1);return Q(Ne)?!1:sh(Ne.has(ee))}function ct(ee,re,ne){var Ne=U(re,ne,!1);if(!Q(Ne))return Ne.get(ee)}function nt(ee,re,ne,Ne){var Fe=U(ne,Ne,!0);Fe.set(ee,re)}function Ce(ee,re){var ne=[],Ne=U(ee,re,!1);if(Q(Ne))return ne;for(var Fe=Ne.keys(),Xe=ch(Fe),Yt=0;;){var fh=lh(Xe);if(!fh)return ne.length=Yt,ne;var K0=uh(fh);try{ne[Yt]=K0}catch(z0){try{dh(Xe)}finally{throw z0}}Yt++}}function K(ee,re,ne){var Ne=U(re,ne,!1);if(Q(Ne)||!Ne.delete(ee))return!1;if(Ne.size===0){var Fe=S.get(re);Q(Fe)||(Fe.delete(ne),Fe.size===0&&S.delete(Fe))}return!0}}function q0(_){var S=_.defineMetadata,T=_.hasOwnMetadata,U=_.getOwnMetadata,le=_.getOwnMetadataKeys,ct=_.deleteMetadata,nt=new p,Ce={isProviderFor:function(K,ee){var re=nt.get(K);return!Q(re)&&re.has(ee)?!0:le(K,ee).length?(Q(re)&&(re=new C,nt.set(K,re)),re.add(ee),!0):!1},OrdinaryDefineOwnMetadata:S,OrdinaryHasOwnMetadata:T,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:le,OrdinaryDeleteMetadata:ct};return Ce}function bi(_,S,T){var U=A.getProvider(_,S);if(!Q(U))return U;if(T){if(A.setProvider(_,S,O))return O;throw new Error("Illegal state.")}}function H0(){var _={},S=[],T=function(){function Ce(K,ee,re){this._index=0,this._keys=K,this._values=ee,this._selector=re}return Ce.prototype["@@iterator"]=function(){return this},Ce.prototype[a]=function(){return this},Ce.prototype.next=function(){var K=this._index;if(K>=0&&K<this._keys.length){var ee=this._selector(this._keys[K],this._values[K]);return K+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}},Ce.prototype.throw=function(K){throw this._index>=0&&(this._index=-1,this._keys=S,this._values=S),K},Ce.prototype.return=function(K){return this._index>=0&&(this._index=-1,this._keys=S,this._values=S),{value:K,done:!0}},Ce}(),U=function(){function Ce(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(Ce.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ce.prototype.has=function(K){return this._find(K,!1)>=0},Ce.prototype.get=function(K){var ee=this._find(K,!1);return ee>=0?this._values[ee]:void 0},Ce.prototype.set=function(K,ee){var re=this._find(K,!0);return this._values[re]=ee,this},Ce.prototype.delete=function(K){var ee=this._find(K,!1);if(ee>=0){for(var re=this._keys.length,ne=ee+1;ne<re;ne++)this._keys[ne-1]=this._keys[ne],this._values[ne-1]=this._values[ne];return this._keys.length--,this._values.length--,Hu(K,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},Ce.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},Ce.prototype.keys=function(){return new T(this._keys,this._values,le)},Ce.prototype.values=function(){return new T(this._keys,this._values,ct)},Ce.prototype.entries=function(){return new T(this._keys,this._values,nt)},Ce.prototype["@@iterator"]=function(){return this.entries()},Ce.prototype[a]=function(){return this.entries()},Ce.prototype._find=function(K,ee){if(!Hu(this._cacheKey,K)){this._cacheIndex=-1;for(var re=0;re<this._keys.length;re++)if(Hu(this._keys[re],K)){this._cacheIndex=re;break}}return this._cacheIndex<0&&ee&&(this._cacheIndex=this._keys.length,this._keys.push(K),this._values.push(void 0)),this._cacheIndex},Ce}();return U;function le(Ce,K){return Ce}function ct(Ce,K){return K}function nt(Ce,K){return[Ce,K]}}function F0(){var _=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(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 W0(){var _=16,S=f.create(),T=U();return function(){function K(){this._key=U()}return K.prototype.has=function(ee){var re=le(ee,!1);return re!==void 0?f.has(re,this._key):!1},K.prototype.get=function(ee){var re=le(ee,!1);return re!==void 0?f.get(re,this._key):void 0},K.prototype.set=function(ee,re){var ne=le(ee,!0);return ne[this._key]=re,this},K.prototype.delete=function(ee){var re=le(ee,!1);return re!==void 0?delete re[this._key]:!1},K.prototype.clear=function(){this._key=U()},K}();function U(){var K;do K="@@WeakMap@@"+Ce();while(f.has(S,K));return S[K]=!0,K}function le(K,ee){if(!n.call(K,T)){if(!ee)return;Object.defineProperty(K,T,{value:f.create()})}return K[T]}function ct(K,ee){for(var re=0;re<ee;++re)K[re]=Math.random()*255|0;return K}function nt(K){if(typeof Uint8Array=="function"){var ee=new Uint8Array(K);return typeof crypto<"u"?crypto.getRandomValues(ee):typeof msCrypto<"u"?msCrypto.getRandomValues(ee):ct(ee,K),ee}return ct(new Array(K),K)}function Ce(){var K=nt(_);K[6]=K[6]&79|64,K[8]=K[8]&191|128;for(var ee="",re=0;re<_;++re){var ne=K[re];(re===4||re===6||re===8)&&(ee+="-"),ne<16&&(ee+="0"),ee+=ne.toString(16).toLowerCase()}return ee}}function Wu(_){return _.__=void 0,delete _.__,_}})})(Eh||(Eh={}));/*!
|
|
15
15
|
* MIT License
|
|
16
16
|
*
|
|
17
17
|
* Copyright (c) 2017-2022 Peculiar Ventures, LLC
|
|
@@ -34,9 +34,9 @@ and limitations under the License.
|
|
|
34
34
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
35
|
* SOFTWARE.
|
|
36
36
|
*
|
|
37
|
-
*/const
|
|
37
|
+
*/const T_="[object ArrayBuffer]";class q{static isArrayBuffer(e){return Object.prototype.toString.call(e)===T_}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=q.toUint8Array(e),s=q.toUint8Array(t);if(n.length!==s.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==s[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const a of t)n+=a.byteLength;const s=new Uint8Array(n);let i=0;for(const a of t){const o=this.toUint8Array(a);s.set(o,i),i+=o.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}}const Xu="string",N_=/^[0-9a-f]+$/i,B_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,R_=/^[a-zA-Z0-9-_]+$/;class Ih{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){const t=q.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}}class gr{static toString(e,t=!1){const n=q.toArrayBuffer(e),s=new DataView(n);let i="";for(let a=0;a<n.byteLength;a+=2){const o=s.getUint16(a,t);i+=String.fromCharCode(o)}return i}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let i=0;i<e.length;i++)s.setUint16(i*2,e.charCodeAt(i),t);return n}}class te{static isHex(e){return typeof e===Xu&&N_.test(e)}static isBase64(e){return typeof e===Xu&&B_.test(e)}static isBase64Url(e){return typeof e===Xu&&R_.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 Ih.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 Ih.toString(e);case"utf16":case"utf16be":return gr.toString(e);case"utf16le":case"usc2":return gr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){const t=q.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){const t=q.toUint8Array(e);let n="";const s=t.length;for(let i=0;i<s;i++){const a=t[i];a<16&&(n+="0"),n+=a.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!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 s=0;s<t.length;s=s+2){const i=t.slice(s,s+2);n[s/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return gr.toString(e,t)}static FromUtf16String(e,t=!1){return gr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}te.DEFAULT_UTF8_ENCODING="utf8";function P_(...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 Ny(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}/*!
|
|
38
38
|
Copyright (c) Peculiar Ventures, LLC
|
|
39
|
-
*/function Ks(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 rs(r,e,t=-1){const n=t;let s=r,i=0,a=Math.pow(2,e);for(let o=1;o<8;o++){if(r<a){let c;if(n<0)c=new ArrayBuffer(o),i=o;else{if(n<o)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}const u=new Uint8Array(c);for(let f=o-1;f>=0;f--){const m=Math.pow(2,f*e);u[i-f-1]=Math.floor(s/m),s-=u[i-f-1]*m}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function
|
|
39
|
+
*/function Ks(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 rs(r,e,t=-1){const n=t;let s=r,i=0,a=Math.pow(2,e);for(let o=1;o<8;o++){if(r<a){let c;if(n<0)c=new ArrayBuffer(o),i=o;else{if(n<o)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}const u=new Uint8Array(c);for(let f=o-1;f>=0;f--){const m=Math.pow(2,f*e);u[i-f-1]=Math.floor(s/m),s-=u[i-f-1]*m}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function Tl(...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 By(){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=Ks(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,Ks(i,8)-n}function $_(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=rs(a,8,n),c=new Uint8Array(o);return c[0]|=128,o}let s=rs(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 Z_(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function Pt(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,s=new Array(n);for(let a=0;a<n;a++)s[a]="0";return s.join("").concat(t)}/*!
|
|
40
40
|
* Copyright (c) 2014, GMO GlobalSign
|
|
41
41
|
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
42
42
|
* All rights reserved.
|
|
@@ -68,11 +68,11 @@ and limitations under the License.
|
|
|
68
68
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
69
69
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
70
70
|
*
|
|
71
|
-
*/function oc(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function hf(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 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 Qc{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return hf(this.items)}}const Si=[new Uint8Array([1])],Ih="0123456789",Xu="name",Ch="valueHexView",Z_="isHexOnly",D_="idBlock",M_="tagClass",V_="tagNumber",U_="isConstructed",L_="fromBER",q_="toBER",H_="local",Et="",pr=new ArrayBuffer(0),eu=new Uint8Array(0),va="EndOfContent",By="OCTET STRING",Ry="BIT STRING";function jr(r){var e;return e=class extends r{constructor(...n){var s;super(...n);const i=n[0]||{};this.isHexOnly=(s=i.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=i.valueHex?q.toUint8Array(i.valueHex):eu}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(!Qr(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",pr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:te.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class gs{constructor({blockLength:e=0,error:t=Et,warnings:n=[],valueBeforeDecode:s=eu}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=q.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:te.ToHex(this.valueBeforeDecodeView)}}}gs.NAME="baseBlock";class kt extends gs{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'")}}kt.NAME="valueBlock";class Py extends jr(gs){constructor({idBlock:e={}}={}){var t,n,s,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?q.toUint8Array(e.valueHex):eu,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",pr}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=rs(this.tagNumber,7),i=new Uint8Array(s),a=s.byteLength,o=new Uint8Array(a+1);if(o[0]=t|31,!e){for(let c=0;c<a-1;c++)o[c+1]=i[c]|128;o[a]=i[a-1]}return o.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const s=this.valueHexView;for(let i=0;i<s.length-1;i++)n[i+1]=s[i]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(e,t,n){const s=q.toUint8Array(e);if(!Qr(this,s,t,n))return-1;const i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;const o=i[0]&31;if(o!==31)this.tagNumber=o,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;i[c]&128;){if(u[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;const R=new Uint8Array(f);for(let C=0;C<u.length;C++)R[C]=u[C];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=i[c]&127;const m=new Uint8Array(c);for(let R=0;R<c;R++)m[R]=u[R];u=this.valueHexView=new Uint8Array(c),u.set(m),this.blockLength<=9?this.tagNumber=Ks(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}}}Py.NAME="identificationBlock";class $y extends gs{constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){const s=q.toUint8Array(e);if(!Qr(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=Ks(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=rs(this.length,8);if(s.byteLength>127)return this.error="Too big length",pr;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}}}$y.NAME="lengthBlock";const X={};class dt extends gs{constructor({name:e=Et,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Py(s),this.lenBlock=new $y(s),this.valueBlock=i?new i(s):new kt(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 Qc;t||Zy(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?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 $_(t,n)}}dt.NAME="BaseBlock";function Zy(r){if(r instanceof X.Constructed)for(const e of r.valueBlock.value)Zy(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class pf extends dt{constructor({value:e=Et,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}pf.NAME="BaseStringBlock";class Dy extends jr(kt){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Dy.NAME="PrimitiveValueBlock";var My;class Xa extends dt{constructor(e={}){super(e,Dy),this.idBlock.isConstructed=!1}}My=Xa;X.Primitive=My;Xa.NAME="PRIMITIVE";function F_(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 ci(r,e=0,t=r.length){const n=e;let s=new dt({},kt);const i=new gs;if(!Qr(i,r,e,t))return s.error=i.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let o=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),o===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=o,t-=s.idBlock.blockLength,o=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),o===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=o,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=dt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=X.EndOfContent;break;case 1:c=X.Boolean;break;case 2:c=X.Integer;break;case 3:c=X.BitString;break;case 4:c=X.OctetString;break;case 5:c=X.Null;break;case 6:c=X.ObjectIdentifier;break;case 10:c=X.Enumerated;break;case 12:c=X.Utf8String;break;case 13:c=X.RelativeObjectIdentifier;break;case 14:c=X.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=X.Sequence;break;case 17:c=X.Set;break;case 18:c=X.NumericString;break;case 19:c=X.PrintableString;break;case 20:c=X.TeletexString;break;case 21:c=X.VideotexString;break;case 22:c=X.IA5String;break;case 23:c=X.UTCTime;break;case 24:c=X.GeneralizedTime;break;case 25:c=X.GraphicString;break;case 26:c=X.VisibleString;break;case 27:c=X.GeneralString;break;case 28:c=X.UniversalString;break;case 29:c=X.CharacterString;break;case 30:c=X.BmpString;break;case 31:c=X.DATE;break;case 32:c=X.TimeOfDay;break;case 33:c=X.DateTime;break;case 34:c=X.Duration;break;default:{const u=s.idBlock.isConstructed?new X.Constructed:new X.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?X.Constructed:X.Primitive}return s=F_(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 Bs(r){if(!r.byteLength){const e=new dt({},kt);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ci(q.toUint8Array(r).slice(),0,r.byteLength)}function W_(r,e){return r?1:e}class mn extends kt{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const s=q.toUint8Array(e);if(!Qr(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(;W_(this.isIndefiniteForm,n)>0;){const a=ci(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===va)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===va?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const n=t||new Qc;for(let s=0;s<this.value.length;s++)this.value[s].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 Vy;class It extends dt{constructor(e={}){super(e,mn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
71
|
+
*/function cc(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function pf(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 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 eu{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return pf(this.items)}}const Si=[new Uint8Array([1])],Ch="0123456789",Qu="name",jh="valueHexView",D_="isHexOnly",M_="idBlock",V_="tagClass",U_="tagNumber",L_="isConstructed",q_="fromBER",H_="toBER",F_="local",It="",pr=new ArrayBuffer(0),tu=new Uint8Array(0),va="EndOfContent",Ry="OCTET STRING",Py="BIT STRING";function jr(r){var e;return e=class extends r{constructor(...n){var s;super(...n);const i=n[0]||{};this.isHexOnly=(s=i.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=i.valueHex?q.toUint8Array(i.valueHex):tu}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(!Qr(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",pr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:te.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class gs{constructor({blockLength:e=0,error:t=It,warnings:n=[],valueBeforeDecode:s=tu}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=q.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:te.ToHex(this.valueBeforeDecodeView)}}}gs.NAME="baseBlock";class St extends gs{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 $y extends jr(gs){constructor({idBlock:e={}}={}){var t,n,s,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?q.toUint8Array(e.valueHex):tu,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",pr}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=rs(this.tagNumber,7),i=new Uint8Array(s),a=s.byteLength,o=new Uint8Array(a+1);if(o[0]=t|31,!e){for(let c=0;c<a-1;c++)o[c+1]=i[c]|128;o[a]=i[a-1]}return o.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const s=this.valueHexView;for(let i=0;i<s.length-1;i++)n[i+1]=s[i]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(e,t,n){const s=q.toUint8Array(e);if(!Qr(this,s,t,n))return-1;const i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;const o=i[0]&31;if(o!==31)this.tagNumber=o,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;i[c]&128;){if(u[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;const R=new Uint8Array(f);for(let C=0;C<u.length;C++)R[C]=u[C];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=i[c]&127;const m=new Uint8Array(c);for(let R=0;R<c;R++)m[R]=u[R];u=this.valueHexView=new Uint8Array(c),u.set(m),this.blockLength<=9?this.tagNumber=Ks(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}}}$y.NAME="identificationBlock";class Zy extends gs{constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){const s=q.toUint8Array(e);if(!Qr(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=Ks(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=rs(this.length,8);if(s.byteLength>127)return this.error="Too big length",pr;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}}}Zy.NAME="lengthBlock";const X={};class dt extends gs{constructor({name:e=It,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new $y(s),this.lenBlock=new Zy(s),this.valueBlock=i?new i(s):new St(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 eu;t||Dy(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?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 Z_(t,n)}}dt.NAME="BaseBlock";function Dy(r){if(r instanceof X.Constructed)for(const e of r.valueBlock.value)Dy(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class mf extends dt{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 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}'`}}mf.NAME="BaseStringBlock";class My extends jr(St){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}My.NAME="PrimitiveValueBlock";var Vy;class Xa extends dt{constructor(e={}){super(e,My),this.idBlock.isConstructed=!1}}Vy=Xa;X.Primitive=Vy;Xa.NAME="PRIMITIVE";function W_(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 ci(r,e=0,t=r.length){const n=e;let s=new dt({},St);const i=new gs;if(!Qr(i,r,e,t))return s.error=i.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let o=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),o===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=o,t-=s.idBlock.blockLength,o=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),o===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=o,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=dt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=X.EndOfContent;break;case 1:c=X.Boolean;break;case 2:c=X.Integer;break;case 3:c=X.BitString;break;case 4:c=X.OctetString;break;case 5:c=X.Null;break;case 6:c=X.ObjectIdentifier;break;case 10:c=X.Enumerated;break;case 12:c=X.Utf8String;break;case 13:c=X.RelativeObjectIdentifier;break;case 14:c=X.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=X.Sequence;break;case 17:c=X.Set;break;case 18:c=X.NumericString;break;case 19:c=X.PrintableString;break;case 20:c=X.TeletexString;break;case 21:c=X.VideotexString;break;case 22:c=X.IA5String;break;case 23:c=X.UTCTime;break;case 24:c=X.GeneralizedTime;break;case 25:c=X.GraphicString;break;case 26:c=X.VisibleString;break;case 27:c=X.GeneralString;break;case 28:c=X.UniversalString;break;case 29:c=X.CharacterString;break;case 30:c=X.BmpString;break;case 31:c=X.DATE;break;case 32:c=X.TimeOfDay;break;case 33:c=X.DateTime;break;case 34:c=X.Duration;break;default:{const u=s.idBlock.isConstructed?new X.Constructed:new X.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?X.Constructed:X.Primitive}return s=W_(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 Bs(r){if(!r.byteLength){const e=new dt({},St);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ci(q.toUint8Array(r).slice(),0,r.byteLength)}function K_(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 s=q.toUint8Array(e);if(!Qr(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(;K_(this.isIndefiniteForm,n)>0;){const a=ci(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===va)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===va?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const n=t||new eu;for(let s=0;s<this.value.length;s++)this.value[s].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 Uy;class Ct extends dt{constructor(e={}){super(e,mn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
72
72
|
`).map(s=>` ${s}`).join(`
|
|
73
73
|
`));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
|
|
74
74
|
${e.join(`
|
|
75
|
-
`)}`:`${t} :`}}Vy=It;X.Constructed=Vy;It.NAME="CONSTRUCTED";class Uy extends kt{fromBER(e,t,n){return t}toBER(e){return pr}}Uy.override="EndOfContentValueBlock";var Ly;class mf extends dt{constructor(e={}){super(e,Uy),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Ly=mf;X.EndOfContent=Ly;mf.NAME=va;var qy;class ns extends dt{constructor(e={}){super(e,kt),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}`}}qy=ns;X.Null=qy;ns.NAME="NULL";class Hy extends jr(kt){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=q.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const s=q.toUint8Array(e);return Qr(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,Ny.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Hy.NAME="BooleanValueBlock";var Fy;let tu=class extends dt{constructor(e={}){super(e,Hy),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}`}};Fy=tu;X.Boolean=Fy;tu.NAME="BOOLEAN";class Wy extends jr(mn){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=mn.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===va){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==By)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?mn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Wy.NAME="OctetStringValueBlock";var Ky;let Jn=class zy extends dt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var s,i;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Wy),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=ci(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?It.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 zy&&e.push(t.valueBlock.valueHexView);return q.concat(e)}};Ky=Jn;X.OctetString=Ky;Jn.NAME=By;class Gy 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 s=-1;if(this.isConstructed){if(s=mn.prototype.fromBER.call(this,e,t,n),s===-1)return s;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!==Ry)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=o.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return s}const i=q.toUint8Array(e);if(!Qr(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=ci(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}}}Gy.NAME="BitStringValueBlock";var Jy;let Yn=class extends dt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var s,i;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Gy),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 It.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)}`}}};Jy=Yn;X.BitString=Jy;Yn.NAME=Ry;var Yy;function K_(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(e);let i=n.slice(0);const a=i.length-1,o=s.slice(0),c=o.length-1;let u=0;const f=c<a?a:c;let m=0;for(let R=f;R>=0;R--,m++){switch(!0){case m<o.length:u=i[a-m]+o[c-m]+t[0];break;default:u=i[a-m]+t[0]}switch(t[0]=u/10,!0){case m>=i.length:i=jl(new Uint8Array([u%10]),i);break;default:i[a-m]=u%10}}return t[0]>0&&(i=jl(t,i)),i}function jh(r){if(r>=Si.length)for(let e=Si.length;e<=r;e++){const t=new Uint8Array([0]);let n=Si[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=jl(t,n)),Si.push(n)}return Si[r]}function z_(r,e){let t=0;const n=new Uint8Array(r),s=new Uint8Array(e),i=n.slice(0),a=i.length-1,o=s.slice(0),c=o.length-1;let u,f=0;for(let m=c;m>=0;m--,f++)switch(u=i[a-f]-o[c-f]-t,!0){case u<0:t=1,i[a-f]=u+10;break;default:t=0,i[a-f]=u}if(t>0)for(let m=a-c+1;m>=0;m--,f++)if(u=i[a-f]-t,u<0)t=1,i[a-f]=u+10;else{t=0,i[a-f]=u;break}return i.slice()}class yf extends jr(kt){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=Ny.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(P_(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=z_(jh(n),t),a="-";break;default:t=K_(t,jh(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Ih.charAt(t[c]));return o===!1&&(a+=Ih.charAt(0)),a}}Yy=yf;yf.NAME="IntegerValueBlock";Object.defineProperty(Yy.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Xy;class wr extends dt{constructor(e={}){super(e,yf),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return oc(),BigInt(this.valueBlock.toString())}static fromBigInt(e){oc();const t=BigInt(e),n=new Qc,s=t.toString(16).replace(/^-/,""),i=new Uint8Array(te.FromHex(s));if(t<0){const o=new Uint8Array(i.length+(i[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 i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new wr({valueHex:n.final()})}convertToDER(){const e=new wr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new wr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Xy=wr;X.Integer=Xy;wr.NAME="INTEGER";var Qy;class ru extends wr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Qy=ru;X.Enumerated=Qy;ru.NAME="ENUMERATED";class Tl extends jr(kt){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const s=q.toUint8Array(e);if(!Qr(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=Ks(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){oc();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=rs(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 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=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}}}Tl.NAME="sidBlock";class eg extends kt{constructor({value:e=Et,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new Tl;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,pr;t.push(s)}return hf(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 Tl;if(s>Number.MAX_SAFE_INTEGER){oc();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}}eg.NAME="ObjectIdentifierValueBlock";var tg;class nu extends dt{constructor(e={}){super(e,eg),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()}}}tg=nu;X.ObjectIdentifier=tg;nu.NAME="OBJECT IDENTIFIER";class Nl extends jr(gs){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const s=q.toUint8Array(e);if(!Qr(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=Ks(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=rs(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 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=te.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Nl.NAME="relativeSidBlock";class rg extends kt{constructor({value:e=Et,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new Nl;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,pr;n.push(i)}return hf(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 Nl;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}}rg.NAME="RelativeObjectIdentifierValueBlock";var ng;class gf extends dt{constructor(e={}){super(e,rg),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()}}}ng=gf;X.RelativeObjectIdentifier=ng;gf.NAME="RelativeObjectIdentifier";var sg;class Lr extends It{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}sg=Lr;X.Sequence=sg;Lr.NAME="SEQUENCE";var ig;let qr=class extends It{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};ig=qr;X.Set=ig;qr.NAME="SET";class ag extends jr(kt){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Et}toJSON(){return{...super.toJSON(),value:this.value}}}ag.NAME="StringValueBlock";class og extends ag{}og.NAME="SimpleStringValueBlock";class Mt extends pf{constructor({...e}={}){super(e,og)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,q.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);this.valueBlock.value=e}}Mt.NAME="SIMPLE STRING";class cg 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}}cg.NAME="Utf8StringValueBlock";var ug;class en extends cg{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}ug=en;X.Utf8String=ug;en.NAME="UTF8String";class lg 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))}}lg.NAME="BmpStringValueBlock";var dg;class su extends lg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}dg=su;X.BmpString=dg;su.NAME="BMPString";class fg extends Mt{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=rs(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}}fg.NAME="UniversalStringValueBlock";var hg;class iu extends fg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}hg=iu;X.UniversalString=hg;iu.NAME="UniversalString";var pg;class au extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}pg=au;X.NumericString=pg;au.NAME="NumericString";var mg;class ou extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}mg=ou;X.PrintableString=mg;ou.NAME="PrintableString";var yg;class cu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}yg=cu;X.TeletexString=yg;cu.NAME="TeletexString";var gg;class uu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}gg=uu;X.VideotexString=gg;uu.NAME="VideotexString";var vg;class lu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}vg=lu;X.IA5String=vg;lu.NAME="IA5String";var bg;class du extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}bg=du;X.GraphicString=bg;du.NAME="GraphicString";var xg;class Qa extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}xg=Qa;X.VisibleString=xg;Qa.NAME="VisibleString";var _g;class fu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}_g=fu;X.GeneralString=_g;fu.NAME="GeneralString";var wg;class hu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}wg=hu;X.CharacterString=wg;hu.NAME="CharacterString";var kg;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 s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,q.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=Pt(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Pt(this.month,2),t[2]=Pt(this.day,2),t[3]=Pt(this.hour,2),t[4]=Pt(this.minute,2),t[5]=Pt(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}kg=eo;X.UTCTime=kg;eo.NAME="UTCTime";var Sg;class pu 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="",s="",i=0,a,o=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const m=new Number(e[e.length-1]);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let m=1,R=n.indexOf("+"),C="";if(R===-1&&(R=n.indexOf("-"),m=-1),R!==-1){if(C=n.substring(R+1),n=n.substring(0,R),C.length!==2&&C.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(C.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(o=m*p,C.length===4){if(p=parseInt(C.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=m*p}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){const m=new Number(`0${n.substring(u)}`);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");i=m.valueOf(),s=n.substring(0,u)}else s=n;switch(!0){case s.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*i;this.minute=Math.floor(m),m=60*(m-this.minute),this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case s.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*i;this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case s.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const m=1e3*i;this.millisecond=Math.floor(m)}break;default:throw new Error("Wrong input string for conversion")}const f=a.exec(s);if(f===null)throw new Error("Wrong input string for conversion");for(let m=1;m<f.length;m++)switch(m){case 1:this.year=parseInt(f[m],10);break;case 2:this.month=parseInt(f[m],10);break;case 3:this.day=parseInt(f[m],10);break;case 4:this.hour=parseInt(f[m],10)+o;break;case 5:this.minute=parseInt(f[m],10)+c;break;case 6:this.second=parseInt(f[m],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const m=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=m.getUTCFullYear(),this.month=m.getUTCMonth(),this.day=m.getUTCDay(),this.hour=m.getUTCHours(),this.minute=m.getUTCMinutes(),this.second=m.getUTCSeconds(),this.millisecond=m.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(Pt(this.year,4)),t.push(Pt(this.month,2)),t.push(Pt(this.day,2)),t.push(Pt(this.hour,2)),t.push(Pt(this.minute,2)),t.push(Pt(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Pt(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Sg=pu;X.GeneralizedTime=Sg;pu.NAME="GeneralizedTime";var Ag;class vf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Ag=vf;X.DATE=Ag;vf.NAME="DATE";var Og;class bf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Og=bf;X.TimeOfDay=Og;bf.NAME="TimeOfDay";var Eg;class xf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Eg=xf;X.DateTime=Eg;xf.NAME="DateTime";var Ig;class _f extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Ig=_f;X.Duration=Ig;_f.NAME="Duration";var Cg;class wf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Cg=wf;X.TIME=Cg;wf.NAME="TIME";class ss{constructor({name:e=Et,optional:t=!1}={}){this.name=e,this.optional=t}}class kf extends ss{constructor({value:e=[],...t}={}){super(t),this.value=e}}class cc extends ss{constructor({value:e=new ss,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class G_{constructor({data:e=eu}={}){this.dataView=q.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=q.toUint8Array(e)}fromBER(e,t,n){const s=t+n;return this.dataView=q.toUint8Array(e).subarray(t,s),s}toBER(e){return this.dataView.slice().buffer}}function Un(r,e,t){if(t instanceof kf){for(let i=0;i<t.value.length;i++)if(Un(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(Xu)&&(i.name=t.name),i}}if(t instanceof ss)return t.hasOwnProperty(Xu)&&(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(!(D_ in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(L_ in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(q_ 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(M_)===!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(V_)===!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(U_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(Z_ 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(!(Ch in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=t.idBlock.valueHexView,a=e.idBlock.valueHexView;if(i.length!==a.length)return{verified:!1,result:r};for(let o=0;o<i.length;o++)if(i[o]!==a[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&(r[t.name]=e)),t instanceof X.Constructed){let i=0,a={verified:!1,result:{error:"Unknown error"}},o=t.valueBlock.value.length;if(o>0&&t.valueBlock.value[0]instanceof cc&&(o=e.valueBlock.value.length),o===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let c=!0;for(let u=0;u<t.valueBlock.value.length;u++)c=c&&(t.valueBlock.value[u].optional||!1);return c?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let c=0;c<o;c++)if(c-i>=e.valueBlock.value.length){if(t.valueBlock.value[c].optional===!1){const u={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof cc){if(a=Un(r,e.valueBlock.value[c],t.valueBlock.value[0].value),a.verified===!1)if(t.valueBlock.value[0].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&delete r[t.name]),a;if(Xu in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};H_ 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=Un(r,e.valueBlock.value[c-i],t.valueBlock.value[c]),a.verified===!1)if(t.valueBlock.value[c].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&delete r[t.name]),a;if(a.verified===!1){const c={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&Ch in e.valueBlock){const i=ci(e.valueBlock.valueHexView);if(i.offset===-1){const a={verified:!1,result:i.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Et),t.name&&(delete r[t.name],a.name=t.name)),a}return Un(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function J_(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=ci(q.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Un(t.result,t.result,e)}const jg=Object.freeze(Object.defineProperty({__proto__:null,Any:ss,BaseBlock:dt,BaseStringBlock:pf,BitString:Yn,BmpString:su,Boolean:tu,CharacterString:hu,Choice:kf,Constructed:It,DATE:vf,DateTime:xf,Duration:_f,EndOfContent:mf,Enumerated:ru,GeneralString:fu,GeneralizedTime:pu,GraphicString:du,HexBlock:jr,IA5String:lu,Integer:wr,Null:ns,NumericString:au,ObjectIdentifier:nu,OctetString:Jn,Primitive:Xa,PrintableString:ou,RawData:G_,RelativeObjectIdentifier:gf,Repeated:cc,Sequence:Lr,Set:qr,TIME:wf,TeletexString:cu,TimeOfDay:bf,UTCTime:eo,UniversalString:iu,Utf8String:en,ValueBlock:kt,VideotexString:uu,ViewWriter:Qc,VisibleString:Qa,compareSchema:Un,fromBER:Bs,verifySchema:J_},Symbol.toStringTag,{value:"Module"}));var B;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(B||(B={}));var g;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(g||(g={}));class mu{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 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 $e{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 Y_={fromASN:r=>r instanceof ns?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ns;const e=Bs(r);if(e.result.error)throw new Error(e.result.error);return e.result}},X_={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new wr({value:+r})},Q_={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new ru({value:r})},We={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new wr({valueHex:r})},ew={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Yn({valueHex:r})},tw={fromASN:r=>r.valueBlock.toString(),toASN:r=>new nu({value:r})},rw={fromASN:r=>r.valueBlock.value,toASN:r=>new tu({value:r})},uc={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Jn({valueHex:r})},nw={fromASN:r=>new $e(r.getValue()),toASN:r=>r.toASN()};function zt(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Tg=zt(en),sw=zt(su),iw=zt(iu),aw=zt(au),ow=zt(ou),cw=zt(cu),uw=zt(uu),lw=zt(lu),dw=zt(du),fw=zt(Qa),hw=zt(fu),pw=zt(hu),mw={fromASN:r=>r.toDate(),toASN:r=>new eo({valueDate:r})},yw={fromASN:r=>r.toDate(),toASN:r=>new pu({valueDate:r})},gw={fromASN:()=>null,toASN:()=>new ns};function Sf(r){switch(r){case g.Any:return Y_;case g.BitString:return ew;case g.BmpString:return sw;case g.Boolean:return rw;case g.CharacterString:return pw;case g.Enumerated:return Q_;case g.GeneralString:return hw;case g.GeneralizedTime:return yw;case g.GraphicString:return dw;case g.IA5String:return lw;case g.Integer:return X_;case g.Null:return gw;case g.NumericString:return aw;case g.ObjectIdentifier:return tw;case g.OctetString:return uc;case g.PrintableString:return ow;case g.TeletexString:return cw;case g.UTCTime:return mw;case g.UniversalString:return iw;case g.Utf8String:return Tg;case g.VideotexString:return uw;case g.VisibleString:return fw;default:return null}}function Ur(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Ur(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Ng(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:Ng(t)}return!1}function vw(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 bw{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:B.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),s=[];for(const i in n.items){const a=n.items[i],o=t?i:"";let c;if(typeof a.type=="number"){const f=g[a.type],m=jg[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else Ur(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===B.Choice?c=new ss({name:o}):(c=this.create(a.type,!1),c.name=o):c=new ss({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 cc({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Ur(a.type)){const f=a.repeated?It:Xa;s.push(new f({name:o,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const f=!!a.repeated;let m=f?c:this.get(a.type,!0).schema;m="valueBlock"in m?m.valueBlock.value:m.value,s.push(new It({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else s.push(new It({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,s.push(c)}switch(n.type){case B.Sequence:return new Lr({value:s,name:""});case B.Set:return new qr({value:s,name:""});case B.Choice:return new kf({value:s,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const qt=new bw,$=r=>e=>{let t;qt.has(e)?t=qt.get(e):(t=qt.createDefault(e),qt.set(e,t)),Object.assign(t,r)},h=r=>(e,t)=>{let n;qt.has(e.constructor)?n=qt.get(e.constructor):(n=qt.createDefault(e.constructor),qt.set(e.constructor,n));const s=Object.assign({},r);if(typeof s.type=="number"&&!s.converter){const i=Sf(r.type);if(!i)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);s.converter=i}n.items[t]=s};class Th extends Error{constructor(){super(...arguments),this.schemas=[]}}class xw{static parse(e,t){const n=Bs(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(Ur(t))return new t().fromASN(e);const s=qt.get(t);qt.cache(t);let i=s.schema;if(e.constructor===It&&s.type!==B.Choice){i=new It({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:s.schema.valueBlock.value});for(const c in s.items)delete e[c]}const a=Un({},e,i);if(!a.verified)throw new Th(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(Ng(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=Sf(c);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,f=>u.fromASN(f))}else return t.from(e.valueBlock.value,u=>this.fromASN(u,c))}for(const c in s.items){const u=a.result[c];if(!u)continue;const f=s.items[c],m=f.type;if(typeof m=="number"||Ur(m)){const R=(n=f.converter)!==null&&n!==void 0?n:Ur(m)?new m:null;if(!R)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 y=Bs(p.toBER(!1));if(y.offset===-1)throw new Error(`Cannot parse the child item. ${y.result.error}`);if(!("value"in y.result.valueBlock&&Array.isArray(y.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const A=y.result.valueBlock.value;o[c]=Array.from(A,O=>R.fromASN(O))}else o[c]=Array.from(u,C=>R.fromASN(C));else{let C=u;if(f.implicit){let p;if(Ur(m))p=new m().toSchema("");else{const y=g[m],A=jg[y];if(!A)throw new Error(`Cannot get '${y}' class from asn1js module`);p=new A}p.valueBlock=C.valueBlock,C=Bs(p.toBER(!1)).result}o[c]=R.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,R=>this.fromASN(R,m))}else o[c]=this.fromASN(u,m)}return o}catch(s){throw s instanceof Th&&s.schemas.push(t.name),s}}}class Af{static serialize(e){return e instanceof dt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Ur(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=qt.get(t);qt.cache(t);let s=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const a=Sf(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"&&vw(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=Af.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||Ur(o.type))){const f={};f.valueHex=u instanceof ns?u.valueBeforeDecodeView:u.valueBlock.toBER(),s.push(new Xa({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else s.push(new It({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else s.push(new It({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 B.Sequence:i=new Lr({value:s});break;case B.Set:i=new qr({value:s});break;case B.Choice:if(!s[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);i=s[0];break}return i}static toAsnItem(e,t,n,s){let i;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${t}' doesn't have converter for type ${g[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(s))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(s,u=>a.toASN(u)),c=e.repeated==="sequence"?Lr:qr;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"?Lr:qr;i=new o({value:a})}else i=this.toASN(s);return i}}class Ue 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 Af.serialize(e)}static parse(e,t){return xw.parse(e,t)}static toString(e){const t=q.isBufferSource(e)?q.toArrayBuffer(e):L.serialize(e),n=Bs(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function l(r,e,t,n){var s=arguments.length,i=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var o=r.length-1;o>=0;o--)(a=r[o])&&(i=(s<3?a(i):s>3?a(e,t,i):a(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i}var Bg={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},s=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${t}\\.${t}\\.${t}\\.${t}(${a})?$`,"i")};function u(p,y){if(p.indexOf("::")!==p.lastIndexOf("::"))return null;let A=0,O=-1,P=(p.match(c.zoneIndex)||[])[0],N,ve;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>y)return null;for(ve=y-A,N=":";ve--;)N+="0:";return p=p.replace("::",N),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),y=function(){const Le=p.split(":"),qe=[];for(let Ze=0;Ze<Le.length;Ze++)qe.push(parseInt(Le[Ze],16));return qe}(),{parts:y,zoneId:P}}function f(p,y,A,O){if(p.length!==y.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!==y[P]>>N)return!1;O-=A,P+=1}return!0}function m(p){if(i.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(s.test(p))return parseInt(p,8);throw new Error(`ipaddr: cannot parse ${p} as octal`)}return parseInt(p,10)}function R(p,y){for(;p.length<y;)p=`0${p}`;return p}const C={};C.IPv4=function(){function p(y){if(y.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,O;for(A=0;A<y.length;A++)if(O=y[A],!(0<=O&&O<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=y}return p.prototype.SpecialRanges={unspecified:[[new p([0,0,0,0]),8]],broadcast:[[new p([255,255,255,255]),32]],multicast:[[new p([224,0,0,0]),4]],linkLocal:[[new p([169,254,0,0]),16]],loopback:[[new p([127,0,0,0]),8]],carrierGradeNat:[[new p([100,64,0,0]),10]],private:[[new p([10,0,0,0]),8],[new p([172,16,0,0]),12],[new p([192,168,0,0]),16]],reserved:[[new p([192,0,0,0]),24],[new p([192,0,2,0]),24],[new p([192,88,99,0]),24],[new p([198,18,0,0]),15],[new p([198,51,100,0]),24],[new p([203,0,113,0]),24],[new p([240,0,0,0]),4]],as112:[[new p([192,175,48,0]),24],[new p([192,31,196,0]),24]],amt:[[new p([192,52,193,0]),24]]},p.prototype.kind=function(){return"ipv4"},p.prototype.match=function(y,A){let O;if(A===void 0&&(O=y,y=O[0],A=O[1]),y.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,y.octets,8,A)},p.prototype.prefixLengthFromSubnetMask=function(){let y=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,ve;for(P=3;P>=0;P-=1)if(N=this.octets[P],N in O){if(ve=O[N],A&&ve!==0)return null;ve!==8&&(A=!0),y+=ve}else return null;return 32-y},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){return this.octets.slice(0)},p.prototype.toIPv4MappedAddress=function(){return C.IPv6.parse(`::ffff:${this.toString()}`)},p.prototype.toNormalizedString=function(){return this.toString()},p.prototype.toString=function(){return this.octets.join(".")},p}(),C.IPv4.broadcastAddressFromCIDR=function(p){try{const y=this.parseCIDR(p),A=y[0].toByteArray(),O=this.subnetMaskFromPrefixLength(y[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 y,A,O,P,N;try{for(y=this.parseCIDR(p),O=y[0].toByteArray(),N=this.subnetMaskFromPrefixLength(y[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 y=this.parser(p);if(y===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(y)},C.IPv4.parseCIDR=function(p){let y;if(y=p.match(/^(.+)\/(\d+)$/)){const A=parseInt(y[2]);if(A>=0&&A<=32){const O=[this.parse(y[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 y,A,O;if(y=p.match(n.fourOctet))return function(){const P=y.slice(1,6),N=[];for(let ve=0;ve<P.length;ve++)A=P[ve],N.push(m(A));return N}();if(y=p.match(n.longValue)){if(O=m(y[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(y=p.match(n.twoOctet))?function(){const P=y.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}():(y=p.match(n.threeOctet))?function(){const P=y.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 y=[0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)y[A]=255,A++;return O<4&&(y[O]=Math.pow(2,p%8)-1<<8-p%8),new this(y)},C.IPv6=function(){function p(y,A){let O,P;if(y.length===16)for(this.parts=[],O=0;O<=14;O+=2)this.parts.push(y[O]<<8|y[O+1]);else if(y.length===8)this.parts=y;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(y,A){let O;if(A===void 0&&(O=y,y=O[0],A=O[1]),y.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,y.parts,16,A)},p.prototype.prefixLengthFromSubnetMask=function(){let y=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 ve=7;ve>=0;ve-=1)if(P=this.parts[ve],P in O){if(N=O[P],A&&N!==0)return null;N!==16&&(A=!0),y+=N}else return null;return 128-y},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let y;const A=[],O=this.parts;for(let P=0;P<O.length;P++)y=O[P],A.push(y>>8),A.push(y&255);return A},p.prototype.toFixedLengthString=function(){const y=(function(){const O=[];for(let P=0;P<this.parts.length;P++)O.push(R(this.parts[P].toString(16),4));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),y+A},p.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const y=this.parts.slice(-2),A=y[0],O=y[1];return new C.IPv4([A>>8,A&255,O>>8,O&255])},p.prototype.toNormalizedString=function(){const y=(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}`),y+A},p.prototype.toRFC5952String=function(){const y=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString();let O=0,P=-1,N;for(;N=y.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 y=this.parseCIDR(p),A=y[0].toByteArray(),O=this.subnetMaskFromPrefixLength(y[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(y){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${y})`)}},C.IPv6.isIPv6=function(p){return this.parser(p)!==null},C.IPv6.isValid=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{const y=this.parser(p);return new this(y.parts,y.zoneId),!0}catch{return!1}},C.IPv6.isValidCIDR=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{return this.parseCIDR(p),!0}catch{return!1}},C.IPv6.networkAddressFromCIDR=function(p){let y,A,O,P,N;try{for(y=this.parseCIDR(p),O=y[0].toByteArray(),N=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),P=[],A=0;A<16;)P.push(parseInt(O[A],10)&parseInt(N[A],10)),A++;return new this(P)}catch(ve){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${ve})`)}},C.IPv6.parse=function(p){const y=this.parser(p);if(y.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(y.parts,y.zoneId)},C.IPv6.parseCIDR=function(p){let y,A,O;if((A=p.match(/^(.+)\/(\d+)$/))&&(y=parseInt(A[2]),y>=0&&y<=128))return O=[this.parse(A[1]),y],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 y,A,O,P,N,ve;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))&&(ve=O[6]||"",y=O[1],O[1].endsWith("::")||(y=y.slice(0,-1)),y=u(y+ve,6),y.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 y.parts.push(N[0]<<8|N[1]),y.parts.push(N[2]<<8|N[3]),{parts:y.parts,zoneId:y.zoneId}}return null},C.IPv6.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>128)throw new Error("ipaddr: invalid IPv6 prefix length");const y=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)y[A]=255,A++;return O<16&&(y[O]=Math.pow(2,p%8)-1<<8-p%8),new this(y)},C.fromByteArray=function(p){const y=p.length;if(y===4)return new C.IPv4(p);if(y===16)return new C.IPv6(p);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},C.isValid=function(p){return C.IPv6.isValid(p)||C.IPv4.isValid(p)},C.isValidCIDR=function(p){return C.IPv6.isValidCIDR(p)||C.IPv4.isValidCIDR(p)},C.parse=function(p){if(C.IPv6.isValid(p))return C.IPv6.parse(p);if(C.IPv4.isValid(p))return C.IPv4.parse(p);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},C.parseCIDR=function(p){try{return C.IPv6.parseCIDR(p)}catch{try{return C.IPv4.parseCIDR(p)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},C.process=function(p){const y=this.parse(p);return y.kind()==="ipv6"&&y.isIPv4MappedAddress()?y.toIPv4Address():y},C.subnetMatch=function(p,y,A){let O,P,N,ve;A==null&&(A="unicast");for(P in y)if(Object.prototype.hasOwnProperty.call(y,P)){for(N=y[P],N[0]&&!(N[0]instanceof Array)&&(N=[N]),O=0;O<N.length;O++)if(ve=N[O],p.kind()===ve[0].kind()&&p.match.apply(p,ve))return P}return A},r.exports?r.exports=C:e.ipaddr=C})(ac)})(Bg);var Nh=Bg.exports;class Bh{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 Nh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(te.ToHex(e))}static fromString(e){const t=Nh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var Bl,Rl,Pl;let ft=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};l([h({type:g.TeletexString})],ft.prototype,"teletexString",void 0);l([h({type:g.PrintableString})],ft.prototype,"printableString",void 0);l([h({type:g.UniversalString})],ft.prototype,"universalString",void 0);l([h({type:g.Utf8String})],ft.prototype,"utf8String",void 0);l([h({type:g.BmpString})],ft.prototype,"bmpString",void 0);ft=l([$({type:B.Choice})],ft);let zs=class extends ft{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?te.ToHex(this.anyValue):super.toString())}};l([h({type:g.IA5String})],zs.prototype,"ia5String",void 0);l([h({type:g.Any})],zs.prototype,"anyValue",void 0);zs=l([$({type:B.Choice})],zs);class yu{constructor(e={}){this.type="",this.value=new zs,Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],yu.prototype,"type",void 0);l([h({type:zs})],yu.prototype,"value",void 0);let Gs=Bl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Bl.prototype)}};Gs=Bl=l([$({type:B.Set,itemType:yu})],Gs);let $l=Rl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Rl.prototype)}};$l=Rl=l([$({type:B.Sequence,itemType:Gs})],$l);let et=Pl=class extends $l{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};et=Pl=l([$({type:B.Sequence})],et);const _w={fromASN:r=>Bh.toString(uc.fromASN(r)),toASN:r=>uc.toASN(Bh.fromString(r))};class ba{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],ba.prototype,"typeId",void 0);l([h({type:g.Any,context:0})],ba.prototype,"value",void 0);class Of{constructor(e={}){this.partyName=new ft,Object.assign(this,e)}}l([h({type:ft,optional:!0,context:0,implicit:!0})],Of.prototype,"nameAssigner",void 0);l([h({type:ft,context:1,implicit:!0})],Of.prototype,"partyName",void 0);let ge=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ba,context:0,implicit:!0})],ge.prototype,"otherName",void 0);l([h({type:g.IA5String,context:1,implicit:!0})],ge.prototype,"rfc822Name",void 0);l([h({type:g.IA5String,context:2,implicit:!0})],ge.prototype,"dNSName",void 0);l([h({type:g.Any,context:3,implicit:!0})],ge.prototype,"x400Address",void 0);l([h({type:et,context:4,implicit:!1})],ge.prototype,"directoryName",void 0);l([h({type:Of,context:5})],ge.prototype,"ediPartyName",void 0);l([h({type:g.IA5String,context:6,implicit:!0})],ge.prototype,"uniformResourceIdentifier",void 0);l([h({type:g.OctetString,context:7,implicit:!0,converter:_w})],ge.prototype,"iPAddress",void 0);l([h({type:g.ObjectIdentifier,context:8,implicit:!0})],ge.prototype,"registeredID",void 0);ge=l([$({type:B.Choice})],ge);const Ef="1.3.6.1.5.5.7",ww=`${Ef}.1`,ui=`${Ef}.3`,gu=`${Ef}.48`,Rh=`${gu}.1`,Ph=`${gu}.2`,$h=`${gu}.3`,Zh=`${gu}.5`,Tn="2.5.29";var Zl;const Dl=`${ww}.1`;class to{constructor(e={}){this.accessMethod="",this.accessLocation=new ge,Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],to.prototype,"accessMethod",void 0);l([h({type:ge})],to.prototype,"accessLocation",void 0);let Is=Zl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Zl.prototype)}};Is=Zl=l([$({type:B.Sequence,itemType:to})],Is);const Ml=`${Tn}.35`;class If extends $e{}class Ln{constructor(e={}){e&&Object.assign(this,e)}}l([h({type:If,context:0,optional:!0,implicit:!0})],Ln.prototype,"keyIdentifier",void 0);l([h({type:ge,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Ln.prototype,"authorityCertIssuer",void 0);l([h({type:g.Integer,context:2,optional:!0,implicit:!0,converter:We})],Ln.prototype,"authorityCertSerialNumber",void 0);const Rg=`${Tn}.19`;class lc{constructor(e={}){this.cA=!1,Object.assign(this,e)}}l([h({type:g.Boolean,defaultValue:!1})],lc.prototype,"cA",void 0);l([h({type:g.Integer,optional:!0})],lc.prototype,"pathLenConstraint",void 0);var Vl;let bt=Vl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};bt=Vl=l([$({type:B.Sequence,itemType:ge})],bt);var Ul;let Dh=Ul=class extends bt{constructor(e){super(e),Object.setPrototypeOf(this,Ul.prototype)}};Dh=Ul=l([$({type:B.Sequence})],Dh);var Ll;const Pg=`${Tn}.32`;let Wr=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};l([h({type:g.IA5String})],Wr.prototype,"ia5String",void 0);l([h({type:g.VisibleString})],Wr.prototype,"visibleString",void 0);l([h({type:g.BmpString})],Wr.prototype,"bmpString",void 0);l([h({type:g.Utf8String})],Wr.prototype,"utf8String",void 0);Wr=l([$({type:B.Choice})],Wr);class Cf{constructor(e={}){this.organization=new Wr,this.noticeNumbers=[],Object.assign(this,e)}}l([h({type:Wr})],Cf.prototype,"organization",void 0);l([h({type:g.Integer,repeated:"sequence"})],Cf.prototype,"noticeNumbers",void 0);class jf{constructor(e={}){Object.assign(this,e)}}l([h({type:Cf,optional:!0})],jf.prototype,"noticeRef",void 0);l([h({type:Wr,optional:!0})],jf.prototype,"explicitText",void 0);let dc=class{constructor(e={}){Object.assign(this,e)}};l([h({type:g.IA5String})],dc.prototype,"cPSuri",void 0);l([h({type:jf})],dc.prototype,"userNotice",void 0);dc=l([$({type:B.Choice})],dc);class Tf{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Tf.prototype,"policyQualifierId",void 0);l([h({type:g.Any})],Tf.prototype,"qualifier",void 0);class vu{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],vu.prototype,"policyIdentifier",void 0);l([h({type:Tf,repeated:"sequence",optional:!0})],vu.prototype,"policyQualifiers",void 0);let fc=Ll=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};fc=Ll=l([$({type:B.Sequence,itemType:vu})],fc);let hc=class{constructor(e=0){this.value=e}};l([h({type:g.Integer})],hc.prototype,"value",void 0);hc=l([$({type:B.Choice})],hc);let Mh=class extends hc{};Mh=l([$({type:B.Choice})],Mh);var ql;const Hl=`${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 $g extends mu{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 is=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,repeated:"sequence",implicit:!0})],is.prototype,"fullName",void 0);l([h({type:Gs,context:1,implicit:!0})],is.prototype,"nameRelativeToCRLIssuer",void 0);is=l([$({type:B.Choice})],is);class li{constructor(e={}){Object.assign(this,e)}}l([h({type:is,context:0,optional:!0})],li.prototype,"distributionPoint",void 0);l([h({type:$g,context:1,optional:!0,implicit:!0})],li.prototype,"reasons",void 0);l([h({type:ge,context:2,optional:!0,repeated:"sequence",implicit:!0})],li.prototype,"cRLIssuer",void 0);let Rs=ql=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,ql.prototype)}};Rs=ql=l([$({type:B.Sequence,itemType:li})],Rs);var Fl;let Vh=Fl=class extends Rs{constructor(e){super(e),Object.setPrototypeOf(this,Fl.prototype)}};Vh=Fl=l([$({type:B.Sequence,itemType:li})],Vh);class mt{constructor(e={}){this.onlyContainsUserCerts=mt.ONLY,this.onlyContainsCACerts=mt.ONLY,this.indirectCRL=mt.ONLY,this.onlyContainsAttributeCerts=mt.ONLY,Object.assign(this,e)}}mt.ONLY=!1;l([h({type:is,context:0,optional:!0})],mt.prototype,"distributionPoint",void 0);l([h({type:g.Boolean,context:1,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsUserCerts",void 0);l([h({type:g.Boolean,context:2,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsCACerts",void 0);l([h({type:$g,context:3,optional:!0,implicit:!0})],mt.prototype,"onlySomeReasons",void 0);l([h({type:g.Boolean,context:4,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"indirectCRL",void 0);l([h({type:g.Boolean,context:5,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsAttributeCerts",void 0);var Di;(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"})(Di||(Di={}));let Wl=class{constructor(e=Di.unspecified){this.reason=Di.unspecified,this.reason=e}toJSON(){return Di[this.reason]}toString(){return this.toJSON()}};l([h({type:g.Enumerated})],Wl.prototype,"reason",void 0);Wl=l([$({type:B.Choice})],Wl);var Kl;const Zg=`${Tn}.37`;let pc=Kl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};pc=Kl=l([$({type:B.Sequence,itemType:g.ObjectIdentifier})],pc);const kw=`${ui}.1`,Sw=`${ui}.2`,Aw=`${ui}.3`,Ow=`${ui}.4`,Ew=`${ui}.8`,Iw=`${ui}.9`;let zl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};l([h({type:g.Integer,converter:We})],zl.prototype,"value",void 0);zl=l([$({type:B.Choice})],zl);let Gl=class{constructor(e){this.value=new Date,e&&(this.value=e)}};l([h({type:g.GeneralizedTime})],Gl.prototype,"value",void 0);Gl=l([$({type:B.Choice})],Gl);var Jl;let Uh=Jl=class extends bt{constructor(e){super(e),Object.setPrototypeOf(this,Jl.prototype)}};Uh=Jl=l([$({type:B.Sequence})],Uh);const Dg=`${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 Qu extends mu{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 Yl;class bu{constructor(e={}){this.base=new ge,this.minimum=0,Object.assign(this,e)}}l([h({type:ge})],bu.prototype,"base",void 0);l([h({type:g.Integer,context:0,defaultValue:0,implicit:!0})],bu.prototype,"minimum",void 0);l([h({type:g.Integer,context:1,optional:!0,implicit:!0})],bu.prototype,"maximum",void 0);let mc=Yl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Yl.prototype)}};mc=Yl=l([$({type:B.Sequence,itemType:bu})],mc);class Mg{constructor(e={}){Object.assign(this,e)}}l([h({type:mc,context:0,optional:!0,implicit:!0})],Mg.prototype,"permittedSubtrees",void 0);l([h({type:mc,context:1,optional:!0,implicit:!0})],Mg.prototype,"excludedSubtrees",void 0);class Vg{constructor(e={}){Object.assign(this,e)}}l([h({type:g.Integer,context:0,implicit:!0,optional:!0,converter:We})],Vg.prototype,"requireExplicitPolicy",void 0);l([h({type:g.Integer,context:1,implicit:!0,optional:!0,converter:We})],Vg.prototype,"inhibitPolicyMapping",void 0);var Xl;class Nf{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Nf.prototype,"issuerDomainPolicy",void 0);l([h({type:g.ObjectIdentifier})],Nf.prototype,"subjectDomainPolicy",void 0);let Lh=Xl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Xl.prototype)}};Lh=Xl=l([$({type:B.Sequence,itemType:Nf})],Lh);var Ql;const Ug=`${Tn}.17`;let ed=Ql=class extends bt{constructor(e){super(e),Object.setPrototypeOf(this,Ql.prototype)}};ed=Ql=l([$({type:B.Sequence})],ed);let Kr=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};l([h({type:g.ObjectIdentifier})],Kr.prototype,"type",void 0);l([h({type:g.Any,repeated:"set"})],Kr.prototype,"values",void 0);var td;let qh=td=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,td.prototype)}};qh=td=l([$({type:B.Sequence,itemType:Kr})],qh);const Lg=`${Tn}.14`;class yn extends If{}class qg{constructor(e={}){Object.assign(this,e)}}l([h({type:g.GeneralizedTime,context:0,implicit:!0,optional:!0})],qg.prototype,"notBefore",void 0);l([h({type:g.GeneralizedTime,context:1,implicit:!0,optional:!0})],qg.prototype,"notAfter",void 0);var Mi;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Mi||(Mi={}));class Hg extends mu{toJSON(){const e=[],t=this.toNumber();return t&Mi.pKIXCertificate&&e.push("pKIXCertificate"),t&Mi.newExtensions&&e.push("newExtensions"),t&Mi.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Fg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Hg,Object.assign(this,e)}}l([h({type:g.GeneralString})],Fg.prototype,"entrustVers",void 0);l([h({type:Hg})],Fg.prototype,"entrustInfoFlags",void 0);var rd;let Hh=rd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,rd.prototype)}};Hh=rd=l([$({type:B.Sequence,itemType:to})],Hh);class Y{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof Y&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Ty(e.parameters,this.parameters)||e.parameters===this.parameters)}}l([h({type:g.ObjectIdentifier})],Y.prototype,"algorithm",void 0);l([h({type:g.Any,optional:!0})],Y.prototype,"parameters",void 0);class ir{constructor(e={}){this.algorithm=new Y,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],ir.prototype,"algorithm",void 0);l([h({type:g.BitString})],ir.prototype,"subjectPublicKey",void 0);let 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:g.UTCTime})],lt.prototype,"utcTime",void 0);l([h({type:g.GeneralizedTime})],lt.prototype,"generalTime",void 0);lt=l([$({type:B.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 nd;let Kt=class Wg{constructor(e={}){this.extnID="",this.critical=Wg.CRITICAL,this.extnValue=new $e,Object.assign(this,e)}};Kt.CRITICAL=!1;l([h({type:g.ObjectIdentifier})],Kt.prototype,"extnID",void 0);l([h({type:g.Boolean,defaultValue:Kt.CRITICAL})],Kt.prototype,"critical",void 0);l([h({type:$e})],Kt.prototype,"extnValue",void 0);let kn=nd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,nd.prototype)}};kn=nd=l([$({type:B.Sequence,itemType:Kt})],kn);var as;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(as||(as={}));class Vt{constructor(e={}){this.version=as.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 ir,Object.assign(this,e)}}l([h({type:g.Integer,context:0,defaultValue:as.v1})],Vt.prototype,"version",void 0);l([h({type:g.Integer,converter:We})],Vt.prototype,"serialNumber",void 0);l([h({type:Y})],Vt.prototype,"signature",void 0);l([h({type:et})],Vt.prototype,"issuer",void 0);l([h({type:ro})],Vt.prototype,"validity",void 0);l([h({type:et})],Vt.prototype,"subject",void 0);l([h({type:ir})],Vt.prototype,"subjectPublicKeyInfo",void 0);l([h({type:g.BitString,context:1,implicit:!0,optional:!0})],Vt.prototype,"issuerUniqueID",void 0);l([h({type:g.BitString,context:2,implicit:!0,optional:!0})],Vt.prototype,"subjectUniqueID",void 0);l([h({type:kn,context:3,optional:!0})],Vt.prototype,"extensions",void 0);class os{constructor(e={}){this.tbsCertificate=new Vt,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Vt})],os.prototype,"tbsCertificate",void 0);l([h({type:Y})],os.prototype,"signatureAlgorithm",void 0);l([h({type:g.BitString})],os.prototype,"signatureValue",void 0);class xu{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new lt,Object.assign(this,e)}}l([h({type:g.Integer,converter:We})],xu.prototype,"userCertificate",void 0);l([h({type:lt})],xu.prototype,"revocationDate",void 0);l([h({type:Kt,optional:!0,repeated:"sequence"})],xu.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:g.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:xu,repeated:"sequence",optional:!0})],tn.prototype,"revokedCertificates",void 0);l([h({type:Kt,optional:!0,context:0,repeated:"sequence"})],tn.prototype,"crlExtensions",void 0);class Bf{constructor(e={}){this.tbsCertList=new tn,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:tn})],Bf.prototype,"tbsCertList",void 0);l([h({type:Y})],Bf.prototype,"signatureAlgorithm",void 0);l([h({type:g.BitString})],Bf.prototype,"signature",void 0);class di{constructor(e={}){this.issuer=new et,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:et})],di.prototype,"issuer",void 0);l([h({type:g.Integer,converter:We})],di.prototype,"serialNumber",void 0);let Js=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0})],Js.prototype,"subjectKeyIdentifier",void 0);l([h({type:di})],Js.prototype,"issuerAndSerialNumber",void 0);Js=l([$({type:B.Choice})],Js);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:B.Sequence})],xa);let yc=class extends Y{};yc=l([$({type:B.Sequence})],yc);let Er=class extends Y{};Er=l([$({type:B.Sequence})],Er);let gc=class extends Y{};gc=l([$({type:B.Sequence})],gc);let Fh=class extends Y{};Fh=l([$({type:B.Sequence})],Fh);let sd=class extends Y{};sd=l([$({type:B.Sequence})],sd);let fi=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};l([h({type:g.ObjectIdentifier})],fi.prototype,"attrType",void 0);l([h({type:g.Any,repeated:"set"})],fi.prototype,"attrValues",void 0);var id;class Tr{constructor(e={}){this.version=zr.v0,this.sid=new Js,this.digestAlgorithm=new xa,this.signatureAlgorithm=new yc,this.signature=new $e,Object.assign(this,e)}}l([h({type:g.Integer})],Tr.prototype,"version",void 0);l([h({type:Js})],Tr.prototype,"sid",void 0);l([h({type:xa})],Tr.prototype,"digestAlgorithm",void 0);l([h({type:fi,repeated:"set",context:0,implicit:!0,optional:!0})],Tr.prototype,"signedAttrs",void 0);l([h({type:yc})],Tr.prototype,"signatureAlgorithm",void 0);l([h({type:$e})],Tr.prototype,"signature",void 0);l([h({type:fi,repeated:"set",context:1,implicit:!0,optional:!0})],Tr.prototype,"unsignedAttrs",void 0);let vc=id=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,id.prototype)}};vc=id=l([$({type:B.Set,itemType:Tr})],vc);let Wh=class extends lt{};Wh=l([$({type:B.Choice})],Wh);let Kh=class extends Tr{};Kh=l([$({type:B.Sequence})],Kh);class Rf{constructor(e={}){this.acIssuer=new ge,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}l([h({type:ge})],Rf.prototype,"acIssuer",void 0);l([h({type:g.Integer})],Rf.prototype,"acSerial",void 0);l([h({type:Kr,repeated:"sequence"})],Rf.prototype,"attrs",void 0);var ad;let bc=ad=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,ad.prototype)}};bc=ad=l([$({type:B.Sequence,itemType:g.ObjectIdentifier})],bc);class _u{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}l([h({type:g.Integer,optional:!0})],_u.prototype,"pathLenConstraint",void 0);l([h({type:bc,implicit:!0,context:0,optional:!0})],_u.prototype,"permittedAttrs",void 0);l([h({type:bc,implicit:!0,context:1,optional:!0})],_u.prototype,"excludedAttrs",void 0);l([h({type:g.Boolean,defaultValue:!0})],_u.prototype,"permitUnSpecified",void 0);class vs{constructor(e={}){this.issuer=new bt,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:bt})],vs.prototype,"issuer",void 0);l([h({type:g.Integer,converter:We})],vs.prototype,"serial",void 0);l([h({type:g.BitString,optional:!0})],vs.prototype,"issuerUID",void 0);var od;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(od||(od={}));class bs{constructor(e={}){this.digestedObjectType=od.publicKey,this.digestAlgorithm=new Y,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.Enumerated})],bs.prototype,"digestedObjectType",void 0);l([h({type:g.ObjectIdentifier,optional:!0})],bs.prototype,"otherObjectTypeID",void 0);l([h({type:Y})],bs.prototype,"digestAlgorithm",void 0);l([h({type:g.BitString})],bs.prototype,"objectDigest",void 0);class wu{constructor(e={}){Object.assign(this,e)}}l([h({type:bt,optional:!0})],wu.prototype,"issuerName",void 0);l([h({type:vs,context:0,implicit:!0,optional:!0})],wu.prototype,"baseCertificateID",void 0);l([h({type:bs,context:1,implicit:!0,optional:!0})],wu.prototype,"objectDigestInfo",void 0);let Ys=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,repeated:"sequence"})],Ys.prototype,"v1Form",void 0);l([h({type:wu,context:0,implicit:!0})],Ys.prototype,"v2Form",void 0);Ys=l([$({type:B.Choice})],Ys);class ku{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}l([h({type:g.GeneralizedTime})],ku.prototype,"notBeforeTime",void 0);l([h({type:g.GeneralizedTime})],ku.prototype,"notAfterTime",void 0);class no{constructor(e={}){Object.assign(this,e)}}l([h({type:vs,implicit:!0,context:0,optional:!0})],no.prototype,"baseCertificateID",void 0);l([h({type:bt,implicit:!0,context:1,optional:!0})],no.prototype,"entityName",void 0);l([h({type:bs,implicit:!0,context:2,optional:!0})],no.prototype,"objectDigestInfo",void 0);var cd;(function(r){r[r.v2=1]="v2"})(cd||(cd={}));class mr{constructor(e={}){this.version=cd.v2,this.holder=new no,this.issuer=new Ys,this.signature=new Y,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new ku,this.attributes=[],Object.assign(this,e)}}l([h({type:g.Integer})],mr.prototype,"version",void 0);l([h({type:no})],mr.prototype,"holder",void 0);l([h({type:Ys})],mr.prototype,"issuer",void 0);l([h({type:Y})],mr.prototype,"signature",void 0);l([h({type:g.Integer,converter:We})],mr.prototype,"serialNumber",void 0);l([h({type:ku})],mr.prototype,"attrCertValidityPeriod",void 0);l([h({type:Kr,repeated:"sequence"})],mr.prototype,"attributes",void 0);l([h({type:g.BitString,optional:!0})],mr.prototype,"issuerUniqueID",void 0);l([h({type:kn,optional:!0})],mr.prototype,"extensions",void 0);class Su{constructor(e={}){this.acinfo=new mr,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:mr})],Su.prototype,"acinfo",void 0);l([h({type:Y})],Su.prototype,"signatureAlgorithm",void 0);l([h({type:g.BitString})],Su.prototype,"signatureValue",void 0);var xc;(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"})(xc||(xc={}));class ud extends mu{}class Pf{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier,implicit:!0,context:0})],Pf.prototype,"type",void 0);l([h({type:g.Any,implicit:!0,context:1})],Pf.prototype,"value",void 0);class $f{constructor(e={}){this.policyId="",this.classList=new ud(xc.unclassified),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],$f.prototype,"policyId",void 0);l([h({type:ud,defaultValue:new ud(xc.unclassified)})],$f.prototype,"classList",void 0);l([h({type:Pf,repeated:"set"})],$f.prototype,"securityCategories",void 0);class Au{constructor(e={}){Object.assign(this,e)}}l([h({type:$e})],Au.prototype,"cotets",void 0);l([h({type:g.ObjectIdentifier})],Au.prototype,"oid",void 0);l([h({type:g.Utf8String})],Au.prototype,"string",void 0);class Kg{constructor(e={}){this.values=[],Object.assign(this,e)}}l([h({type:bt,implicit:!0,context:0,optional:!0})],Kg.prototype,"policyAuthority",void 0);l([h({type:Au,repeated:"sequence"})],Kg.prototype,"values",void 0);var ld;class Ou{constructor(e={}){this.targetCertificate=new vs,Object.assign(this,e)}}l([h({type:vs})],Ou.prototype,"targetCertificate",void 0);l([h({type:ge,optional:!0})],Ou.prototype,"targetName",void 0);l([h({type:bs,optional:!0})],Ou.prototype,"certDigestInfo",void 0);let Xs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:ge,context:0,implicit:!0})],Xs.prototype,"targetName",void 0);l([h({type:ge,context:1,implicit:!0})],Xs.prototype,"targetGroup",void 0);l([h({type:Ou,context:2,implicit:!0})],Xs.prototype,"targetCert",void 0);Xs=l([$({type:B.Choice})],Xs);let dd=ld=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,ld.prototype)}};dd=ld=l([$({type:B.Sequence,itemType:Xs})],dd);var fd;let zh=fd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,fd.prototype)}};zh=fd=l([$({type:B.Sequence,itemType:dd})],zh);class zg{constructor(e={}){Object.assign(this,e)}}l([h({type:bt,implicit:!0,context:0,optional:!0})],zg.prototype,"roleAuthority",void 0);l([h({type:ge,implicit:!0,context:1})],zg.prototype,"roleName",void 0);class Zf{constructor(e={}){this.service=new ge,this.ident=new ge,Object.assign(this,e)}}l([h({type:ge})],Zf.prototype,"service",void 0);l([h({type:ge})],Zf.prototype,"ident",void 0);l([h({type:$e,optional:!0})],Zf.prototype,"authInfo",void 0);var hd;class Df{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Df.prototype,"otherCertFormat",void 0);l([h({type:g.Any})],Df.prototype,"otherCert",void 0);let Qs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:os})],Qs.prototype,"certificate",void 0);l([h({type:Su,context:2,implicit:!0})],Qs.prototype,"v2AttrCert",void 0);l([h({type:Df,context:3,implicit:!0})],Qs.prototype,"other",void 0);Qs=l([$({type:B.Choice})],Qs);let _c=hd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,hd.prototype)}};_c=hd=l([$({type:B.Set,itemType:Qs})],_c);class hi{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],hi.prototype,"contentType",void 0);l([h({type:g.Any,context:0})],hi.prototype,"content",void 0);let _a=class{constructor(e={}){Object.assign(this,e)}};l([h({type:$e})],_a.prototype,"single",void 0);l([h({type:g.Any})],_a.prototype,"any",void 0);_a=l([$({type:B.Choice})],_a);class Eu{constructor(e={}){this.eContentType="",Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Eu.prototype,"eContentType",void 0);l([h({type:_a,context:0,optional:!0})],Eu.prototype,"eContent",void 0);let wa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:$e,context:0,implicit:!0,optional:!0})],wa.prototype,"value",void 0);l([h({type:$e,converter:nw,context:0,implicit:!0,optional:!0,repeated:"sequence"})],wa.prototype,"constructedValue",void 0);wa=l([$({type:B.Choice})],wa);class so{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new gc,Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],so.prototype,"contentType",void 0);l([h({type:gc})],so.prototype,"contentEncryptionAlgorithm",void 0);l([h({type:wa,optional:!0})],so.prototype,"encryptedContent",void 0);class Iu{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Iu.prototype,"keyAttrId",void 0);l([h({type:g.Any,optional:!0})],Iu.prototype,"keyAttr",void 0);var pd;class Cu{constructor(e={}){this.subjectKeyIdentifier=new yn,Object.assign(this,e)}}l([h({type:yn})],Cu.prototype,"subjectKeyIdentifier",void 0);l([h({type:g.GeneralizedTime,optional:!0})],Cu.prototype,"date",void 0);l([h({type:Iu,optional:!0})],Cu.prototype,"other",void 0);let ei=class{constructor(e={}){Object.assign(this,e)}};l([h({type:Cu,context:0,implicit:!0,optional:!0})],ei.prototype,"rKeyId",void 0);l([h({type:di,optional:!0})],ei.prototype,"issuerAndSerialNumber",void 0);ei=l([$({type:B.Choice})],ei);class Mf{constructor(e={}){this.rid=new ei,this.encryptedKey=new $e,Object.assign(this,e)}}l([h({type:ei})],Mf.prototype,"rid",void 0);l([h({type:$e})],Mf.prototype,"encryptedKey",void 0);let wc=pd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,pd.prototype)}};wc=pd=l([$({type:B.Sequence,itemType:Mf})],wc);class Vf{constructor(e={}){this.algorithm=new Y,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:Y})],Vf.prototype,"algorithm",void 0);l([h({type:g.BitString})],Vf.prototype,"publicKey",void 0);let cs=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0,optional:!0})],cs.prototype,"subjectKeyIdentifier",void 0);l([h({type:Vf,context:1,implicit:!0,optional:!0})],cs.prototype,"originatorKey",void 0);l([h({type:di,optional:!0})],cs.prototype,"issuerAndSerialNumber",void 0);cs=l([$({type:B.Choice})],cs);class pi{constructor(e={}){this.version=zr.v3,this.originator=new cs,this.keyEncryptionAlgorithm=new Er,this.recipientEncryptedKeys=new wc,Object.assign(this,e)}}l([h({type:g.Integer})],pi.prototype,"version",void 0);l([h({type:cs,context:0})],pi.prototype,"originator",void 0);l([h({type:$e,context:1,optional:!0})],pi.prototype,"ukm",void 0);l([h({type:Er})],pi.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:wc})],pi.prototype,"recipientEncryptedKeys",void 0);let ti=class{constructor(e={}){Object.assign(this,e)}};l([h({type:yn,context:0,implicit:!0})],ti.prototype,"subjectKeyIdentifier",void 0);l([h({type:di})],ti.prototype,"issuerAndSerialNumber",void 0);ti=l([$({type:B.Choice})],ti);class io{constructor(e={}){this.version=zr.v0,this.rid=new ti,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new $e,Object.assign(this,e)}}l([h({type:g.Integer})],io.prototype,"version",void 0);l([h({type:ti})],io.prototype,"rid",void 0);l([h({type:Er})],io.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:$e})],io.prototype,"encryptedKey",void 0);class ao{constructor(e={}){this.keyIdentifier=new $e,Object.assign(this,e)}}l([h({type:$e})],ao.prototype,"keyIdentifier",void 0);l([h({type:g.GeneralizedTime,optional:!0})],ao.prototype,"date",void 0);l([h({type:Iu,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 $e,Object.assign(this,e)}}l([h({type:g.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:$e})],oo.prototype,"encryptedKey",void 0);class co{constructor(e={}){this.version=zr.v0,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new $e,Object.assign(this,e)}}l([h({type:g.Integer})],co.prototype,"version",void 0);l([h({type:sd,context:0,optional:!0})],co.prototype,"keyDerivationAlgorithm",void 0);l([h({type:Er})],co.prototype,"keyEncryptionAlgorithm",void 0);l([h({type:$e})],co.prototype,"encryptedKey",void 0);class Uf{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Uf.prototype,"oriType",void 0);l([h({type:g.Any})],Uf.prototype,"oriValue",void 0);let Sn=class{constructor(e={}){Object.assign(this,e)}};l([h({type:io,optional:!0})],Sn.prototype,"ktri",void 0);l([h({type:pi,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:Uf,context:4,implicit:!0,optional:!0})],Sn.prototype,"ori",void 0);Sn=l([$({type:B.Choice})],Sn);var md;let kc=md=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,md.prototype)}};kc=md=l([$({type:B.Set,itemType:Sn})],kc);var yd;class ju{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],ju.prototype,"otherRevInfoFormat",void 0);l([h({type:g.Any})],ju.prototype,"otherRevInfo",void 0);let Sc=class{constructor(e={}){this.other=new ju,Object.assign(this,e)}};l([h({type:ju,context:1,implicit:!0})],Sc.prototype,"other",void 0);Sc=l([$({type:B.Choice})],Sc);let Ac=yd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,yd.prototype)}};Ac=yd=l([$({type:B.Set,itemType:Sc})],Ac);class Lf{constructor(e={}){Object.assign(this,e)}}l([h({type:_c,context:0,implicit:!0,optional:!0})],Lf.prototype,"certs",void 0);l([h({type:Ac,context:1,implicit:!0,optional:!0})],Lf.prototype,"crls",void 0);var gd;let vd=gd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,gd.prototype)}};vd=gd=l([$({type:B.Set,itemType:fi})],vd);class uo{constructor(e={}){this.version=zr.v0,this.recipientInfos=new kc,this.encryptedContentInfo=new so,Object.assign(this,e)}}l([h({type:g.Integer})],uo.prototype,"version",void 0);l([h({type:Lf,context:0,implicit:!0,optional:!0})],uo.prototype,"originatorInfo",void 0);l([h({type:kc})],uo.prototype,"recipientInfos",void 0);l([h({type:so})],uo.prototype,"encryptedContentInfo",void 0);l([h({type:vd,context:1,implicit:!0,optional:!0})],uo.prototype,"unprotectedAttrs",void 0);const Cw="1.2.840.113549.1.7.2";var bd;let Oc=bd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,bd.prototype)}};Oc=bd=l([$({type:B.Set,itemType:xa})],Oc);class mi{constructor(e={}){this.version=zr.v0,this.digestAlgorithms=new Oc,this.encapContentInfo=new Eu,this.signerInfos=new vc,Object.assign(this,e)}}l([h({type:g.Integer})],mi.prototype,"version",void 0);l([h({type:Oc})],mi.prototype,"digestAlgorithms",void 0);l([h({type:Eu})],mi.prototype,"encapContentInfo",void 0);l([h({type:_c,context:0,implicit:!0,optional:!0})],mi.prototype,"certificates",void 0);l([h({type:Ac,context:1,implicit:!0,optional:!0})],mi.prototype,"crls",void 0);l([h({type:vc})],mi.prototype,"signerInfos",void 0);const ka="1.2.840.10045.2.1",qf="1.2.840.10045.4.1",Gg="1.2.840.10045.4.3.1",Hf="1.2.840.10045.4.3.2",Ff="1.2.840.10045.4.3.3",Wf="1.2.840.10045.4.3.4",Gh="1.2.840.10045.3.1.7",Jh="1.3.132.0.34",Yh="1.3.132.0.35";function lo(r){return new Y({algorithm:r})}const jw=lo(qf);lo(Gg);const Tw=lo(Hf),Nw=lo(Ff),Bw=lo(Wf);let Sa=class{constructor(e={}){Object.assign(this,e)}};l([h({type:g.ObjectIdentifier})],Sa.prototype,"fieldType",void 0);l([h({type:g.Any})],Sa.prototype,"parameters",void 0);Sa=l([$({type:B.Sequence})],Sa);class Rw extends $e{}let ri=class{constructor(e={}){Object.assign(this,e)}};l([h({type:g.OctetString})],ri.prototype,"a",void 0);l([h({type:g.OctetString})],ri.prototype,"b",void 0);l([h({type:g.BitString,optional:!0})],ri.prototype,"seed",void 0);ri=l([$({type:B.Sequence})],ri);var xd;(function(r){r[r.ecpVer1=1]="ecpVer1"})(xd||(xd={}));let Gr=class{constructor(e={}){this.version=xd.ecpVer1,Object.assign(this,e)}};l([h({type:g.Integer})],Gr.prototype,"version",void 0);l([h({type:Sa})],Gr.prototype,"fieldID",void 0);l([h({type:ri})],Gr.prototype,"curve",void 0);l([h({type:Rw})],Gr.prototype,"base",void 0);l([h({type:g.Integer,converter:We})],Gr.prototype,"order",void 0);l([h({type:g.Integer,optional:!0})],Gr.prototype,"cofactor",void 0);Gr=l([$({type:B.Sequence})],Gr);let An=class{constructor(e={}){Object.assign(this,e)}};l([h({type:g.ObjectIdentifier})],An.prototype,"namedCurve",void 0);l([h({type:g.Null})],An.prototype,"implicitCurve",void 0);l([h({type:Gr})],An.prototype,"specifiedCurve",void 0);An=l([$({type:B.Choice})],An);class Tu{constructor(e={}){this.version=1,this.privateKey=new $e,Object.assign(this,e)}}l([h({type:g.Integer})],Tu.prototype,"version",void 0);l([h({type:$e})],Tu.prototype,"privateKey",void 0);l([h({type:An,context:0,optional:!0})],Tu.prototype,"parameters",void 0);l([h({type:g.BitString,context:1,optional:!0})],Tu.prototype,"publicKey",void 0);class Ec{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.Integer,converter:We})],Ec.prototype,"r",void 0);l([h({type:g.Integer,converter:We})],Ec.prototype,"s",void 0);const Nt="1.2.840.113549.1.1",us=`${Nt}.1`,Pw=`${Nt}.7`,$w=`${Nt}.9`,Vi=`${Nt}.10`,Zw=`${Nt}.2`,Dw=`${Nt}.4`,Ic=`${Nt}.5`,Mw=`${Nt}.14`,_d=`${Nt}.11`,Cc=`${Nt}.12`,jc=`${Nt}.13`,Jg=`${Nt}.15`,Yg=`${Nt}.16`,Tc="1.3.14.3.2.26",Xg="2.16.840.1.101.3.4.2.4",Nc="2.16.840.1.101.3.4.2.1",Bc="2.16.840.1.101.3.4.2.2",Rc="2.16.840.1.101.3.4.2.3",Vw="2.16.840.1.101.3.4.2.5",Uw="2.16.840.1.101.3.4.2.6",Lw="1.2.840.113549.2.2",qw="1.2.840.113549.2.5",Nu=`${Nt}.8`;function at(r){return new Y({algorithm:r,parameters:null})}at(Lw);at(qw);const ls=at(Tc);at(Xg);at(Nc);at(Bc);at(Rc);at(Vw);at(Uw);const Qg=new Y({algorithm:Nu,parameters:L.serialize(ls)}),e0=new Y({algorithm:$w,parameters:L.serialize(uc.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(us);at(Zw);at(Dw);at(Ic);at(Jg);at(Yg);at(Cc);at(jc);at(Jg);at(Yg);class Bu{constructor(e={}){this.hashAlgorithm=new Y(ls),this.maskGenAlgorithm=new Y({algorithm:Nu,parameters:L.serialize(ls)}),this.pSourceAlgorithm=new Y(e0),Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:ls})],Bu.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:Qg})],Bu.prototype,"maskGenAlgorithm",void 0);l([h({type:Y,context:2,defaultValue:e0})],Bu.prototype,"pSourceAlgorithm",void 0);new Y({algorithm:Pw,parameters:L.serialize(new Bu)});class ds{constructor(e={}){this.hashAlgorithm=new Y(ls),this.maskGenAlgorithm=new Y({algorithm:Nu,parameters:L.serialize(ls)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}l([h({type:Y,context:0,defaultValue:ls})],ds.prototype,"hashAlgorithm",void 0);l([h({type:Y,context:1,defaultValue:Qg})],ds.prototype,"maskGenAlgorithm",void 0);l([h({type:g.Integer,context:2,defaultValue:20})],ds.prototype,"saltLength",void 0);l([h({type:g.Integer,context:3,defaultValue:1})],ds.prototype,"trailerField",void 0);new Y({algorithm:Vi,parameters:L.serialize(new ds)});class Ru{constructor(e={}){this.digestAlgorithm=new Y,this.digest=new $e,Object.assign(this,e)}}l([h({type:Y})],Ru.prototype,"digestAlgorithm",void 0);l([h({type:$e})],Ru.prototype,"digest",void 0);var wd;class Pu{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.Integer,converter:We})],Pu.prototype,"prime",void 0);l([h({type:g.Integer,converter:We})],Pu.prototype,"exponent",void 0);l([h({type:g.Integer,converter:We})],Pu.prototype,"coefficient",void 0);let kd=wd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,wd.prototype)}};kd=wd=l([$({type:B.Sequence,itemType:Pu})],kd);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:g.Integer})],Nr.prototype,"version",void 0);l([h({type:g.Integer,converter:We})],Nr.prototype,"modulus",void 0);l([h({type:g.Integer,converter:We})],Nr.prototype,"publicExponent",void 0);l([h({type:g.Integer,converter:We})],Nr.prototype,"privateExponent",void 0);l([h({type:g.Integer,converter:We})],Nr.prototype,"prime1",void 0);l([h({type:g.Integer,converter:We})],Nr.prototype,"prime2",void 0);l([h({type:g.Integer,converter:We})],Nr.prototype,"exponent1",void 0);l([h({type:g.Integer,converter:We})],Nr.prototype,"exponent2",void 0);l([h({type:g.Integer,converter:We})],Nr.prototype,"coefficient",void 0);l([h({type:kd,optional:!0})],Nr.prototype,"otherPrimeInfos",void 0);class Kf{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.Integer,converter:We})],Kf.prototype,"modulus",void 0);l([h({type:g.Integer,converter:We})],Kf.prototype,"publicExponent",void 0);var Sd;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Sd||(Sd={}));const St=Sd;/*! *****************************************************************************
|
|
75
|
+
`)}`:`${t} :`}}Uy=Ct;X.Constructed=Uy;Ct.NAME="CONSTRUCTED";class Ly extends St{fromBER(e,t,n){return t}toBER(e){return pr}}Ly.override="EndOfContentValueBlock";var qy;class yf extends dt{constructor(e={}){super(e,Ly),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}qy=yf;X.EndOfContent=qy;yf.NAME=va;var Hy;class ns extends dt{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 s=new Uint8Array(n);s[0]=5,s[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}Hy=ns;X.Null=Hy;ns.NAME="NULL";class Fy 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 s=q.toUint8Array(e);return Qr(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,By.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Fy.NAME="BooleanValueBlock";var Wy;let ru=class extends dt{constructor(e={}){super(e,Fy),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}`}};Wy=ru;X.Boolean=Wy;ru.NAME="BOOLEAN";class Ky extends jr(mn){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=mn.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===va){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Ry)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?mn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Ky.NAME="OctetStringValueBlock";var zy;let Jn=class Gy extends dt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var s,i;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Ky),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=ci(i,0,i.byteLength);a.offset!==-1&&a.offset===n&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ct.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${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 Gy&&e.push(t.valueBlock.valueHexView);return q.concat(e)}};zy=Jn;X.OctetString=zy;Jn.NAME=Ry;class Jy 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 s=-1;if(this.isConstructed){if(s=mn.prototype.fromBER.call(this,e,t,n),s===-1)return s;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!==Py)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=o.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return s}const i=q.toUint8Array(e);if(!Qr(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=ci(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}}}Jy.NAME="BitStringValueBlock";var Yy;let Yn=class extends dt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var s,i;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Jy),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ct.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const s of t)e.push(s.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Yy=Yn;X.BitString=Yy;Yn.NAME=Py;var Xy;function z_(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(e);let i=n.slice(0);const a=i.length-1,o=s.slice(0),c=o.length-1;let u=0;const f=c<a?a:c;let m=0;for(let R=f;R>=0;R--,m++){switch(!0){case m<o.length:u=i[a-m]+o[c-m]+t[0];break;default:u=i[a-m]+t[0]}switch(t[0]=u/10,!0){case m>=i.length:i=Tl(new Uint8Array([u%10]),i);break;default:i[a-m]=u%10}}return t[0]>0&&(i=Tl(t,i)),i}function Th(r){if(r>=Si.length)for(let e=Si.length;e<=r;e++){const t=new Uint8Array([0]);let n=Si[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=Tl(t,n)),Si.push(n)}return Si[r]}function G_(r,e){let t=0;const n=new Uint8Array(r),s=new Uint8Array(e),i=n.slice(0),a=i.length-1,o=s.slice(0),c=o.length-1;let u,f=0;for(let m=c;m>=0;m--,f++)switch(u=i[a-f]-o[c-f]-t,!0){case u<0:t=1,i[a-f]=u+10;break;default:t=0,i[a-f]=u}if(t>0)for(let m=a-c+1;m>=0;m--,f++)if(u=i[a-f]-t,u<0)t=1,i[a-f]=u+10;else{t=0,i[a-f]=u;break}return i.slice()}class gf 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=By.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array($_(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=G_(Th(n),t),a="-";break;default:t=z_(t,Th(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(o=!0),o&&(a+=Ch.charAt(t[c]));return o===!1&&(a+=Ch.charAt(0)),a}}Xy=gf;gf.NAME="IntegerValueBlock";Object.defineProperty(Xy.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Qy;class wr extends dt{constructor(e={}){super(e,gf),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return cc(),BigInt(this.valueBlock.toString())}static fromBigInt(e){cc();const t=BigInt(e),n=new eu,s=t.toString(16).replace(/^-/,""),i=new Uint8Array(te.FromHex(s));if(t<0){const o=new Uint8Array(i.length+(i[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 i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new wr({valueHex:n.final()})}convertToDER(){const e=new wr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new wr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Qy=wr;X.Integer=Qy;wr.NAME="INTEGER";var eg;class nu extends wr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}eg=nu;X.Enumerated=eg;nu.NAME="ENUMERATED";class Nl 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 s=q.toUint8Array(e);if(!Qr(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=Ks(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){cc();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=rs(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 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=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}}}Nl.NAME="sidBlock";class tg extends St{constructor({value:e=It,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new Nl;if(s=i.fromBER(e,s,n),s===-1)return this.blockLength=0,this.error=i.error,s;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return s}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const s=this.value[n].toBER(e);if(s.byteLength===0)return this.error=this.value[n].error,pr;t.push(s)}return pf(t)}fromString(e){this.value=[];let t=0,n=0,s="",i=!1;do if(n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1,i){const a=this.value[0];let o=0;switch(a.valueDec){case 0:break;case 1:o=40;break;case 2:o=80;break;default:this.value=[];return}const c=parseInt(s,10);if(isNaN(c))return;a.valueDec=c+o,i=!1}else{const a=new Nl;if(s>Number.MAX_SAFE_INTEGER){cc();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}}tg.NAME="ObjectIdentifierValueBlock";var rg;class su extends dt{constructor(e={}){super(e,tg),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()}}}rg=su;X.ObjectIdentifier=rg;su.NAME="OBJECT IDENTIFIER";class Bl extends jr(gs){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const s=q.toUint8Array(e);if(!Qr(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=Ks(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=rs(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 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=te.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Bl.NAME="relativeSidBlock";class ng extends St{constructor({value:e=It,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){const i=new Bl;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,pr;n.push(i)}return pf(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 Bl;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}}ng.NAME="RelativeObjectIdentifierValueBlock";var sg;class vf extends dt{constructor(e={}){super(e,ng),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()}}}sg=vf;X.RelativeObjectIdentifier=sg;vf.NAME="RelativeObjectIdentifier";var ig;class Lr extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}ig=Lr;X.Sequence=ig;Lr.NAME="SEQUENCE";var ag;let qr=class extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};ag=qr;X.Set=ag;qr.NAME="SET";class og extends jr(St){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=It}toJSON(){return{...super.toJSON(),value:this.value}}}og.NAME="StringValueBlock";class cg extends og{}cg.NAME="SimpleStringValueBlock";class Mt extends mf{constructor({...e}={}){super(e,cg)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,q.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);this.valueBlock.value=e}}Mt.NAME="SIMPLE STRING";class ug 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}}ug.NAME="Utf8StringValueBlock";var lg;class en extends ug{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}lg=en;X.Utf8String=lg;en.NAME="UTF8String";class dg 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))}}dg.NAME="BmpStringValueBlock";var fg;class iu extends dg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}fg=iu;X.BmpString=fg;iu.NAME="BMPString";class hg extends Mt{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=rs(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}}hg.NAME="UniversalStringValueBlock";var pg;class au extends hg{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}pg=au;X.UniversalString=pg;au.NAME="UniversalString";var mg;class ou extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}mg=ou;X.NumericString=mg;ou.NAME="NumericString";var yg;class cu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}yg=cu;X.PrintableString=yg;cu.NAME="PrintableString";var gg;class uu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}gg=uu;X.TeletexString=gg;uu.NAME="TeletexString";var vg;class lu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}vg=lu;X.VideotexString=vg;lu.NAME="VideotexString";var bg;class du extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}bg=du;X.IA5String=bg;du.NAME="IA5String";var xg;class fu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}xg=fu;X.GraphicString=xg;fu.NAME="GraphicString";var _g;class Qa extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}_g=Qa;X.VisibleString=_g;Qa.NAME="VisibleString";var wg;class hu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}wg=hu;X.GeneralString=wg;hu.NAME="GeneralString";var kg;class pu extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}kg=pu;X.CharacterString=kg;pu.NAME="CharacterString";var Sg;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 s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,q.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=Pt(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Pt(this.month,2),t[2]=Pt(this.day,2),t[3]=Pt(this.hour,2),t[4]=Pt(this.minute,2),t[5]=Pt(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Sg=eo;X.UTCTime=Sg;eo.NAME="UTCTime";var Ag;class mu 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="",s="",i=0,a,o=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const m=new Number(e[e.length-1]);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let m=1,R=n.indexOf("+"),C="";if(R===-1&&(R=n.indexOf("-"),m=-1),R!==-1){if(C=n.substring(R+1),n=n.substring(0,R),C.length!==2&&C.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(C.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(o=m*p,C.length===4){if(p=parseInt(C.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=m*p}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){const m=new Number(`0${n.substring(u)}`);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");i=m.valueOf(),s=n.substring(0,u)}else s=n;switch(!0){case s.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*i;this.minute=Math.floor(m),m=60*(m-this.minute),this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case s.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let m=60*i;this.second=Math.floor(m),m=1e3*(m-this.second),this.millisecond=Math.floor(m)}break;case s.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const m=1e3*i;this.millisecond=Math.floor(m)}break;default:throw new Error("Wrong input string for conversion")}const f=a.exec(s);if(f===null)throw new Error("Wrong input string for conversion");for(let m=1;m<f.length;m++)switch(m){case 1:this.year=parseInt(f[m],10);break;case 2:this.month=parseInt(f[m],10);break;case 3:this.day=parseInt(f[m],10);break;case 4:this.hour=parseInt(f[m],10)+o;break;case 5:this.minute=parseInt(f[m],10)+c;break;case 6:this.second=parseInt(f[m],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const m=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=m.getUTCFullYear(),this.month=m.getUTCMonth(),this.day=m.getUTCDay(),this.hour=m.getUTCHours(),this.minute=m.getUTCMinutes(),this.second=m.getUTCSeconds(),this.millisecond=m.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(Pt(this.year,4)),t.push(Pt(this.month,2)),t.push(Pt(this.day,2)),t.push(Pt(this.hour,2)),t.push(Pt(this.minute,2)),t.push(Pt(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Pt(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Ag=mu;X.GeneralizedTime=Ag;mu.NAME="GeneralizedTime";var Og;class bf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Og=bf;X.DATE=Og;bf.NAME="DATE";var Eg;class xf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Eg=xf;X.TimeOfDay=Eg;xf.NAME="TimeOfDay";var Ig;class _f extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Ig=_f;X.DateTime=Ig;_f.NAME="DateTime";var Cg;class wf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Cg=wf;X.Duration=Cg;wf.NAME="Duration";var jg;class kf extends en{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}jg=kf;X.TIME=jg;kf.NAME="TIME";class ss{constructor({name:e=It,optional:t=!1}={}){this.name=e,this.optional=t}}class Sf extends ss{constructor({value:e=[],...t}={}){super(t),this.value=e}}class uc extends ss{constructor({value:e=new ss,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class J_{constructor({data:e=tu}={}){this.dataView=q.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=q.toUint8Array(e)}fromBER(e,t,n){const s=t+n;return this.dataView=q.toUint8Array(e).subarray(t,s),s}toBER(e){return this.dataView.slice().buffer}}function Un(r,e,t){if(t instanceof Sf){for(let i=0;i<t.value.length;i++)if(Un(r,e,t.value[i]).verified)return{verified:!0,result:r};{const i={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(Qu)&&(i.name=t.name),i}}if(t instanceof ss)return t.hasOwnProperty(Qu)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(M_ in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(q_ in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(H_ 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(V_)===!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(U_)===!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(L_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(D_ 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(!(jh 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,It),t.name&&(r[t.name]=e)),t instanceof X.Constructed){let i=0,a={verified:!1,result:{error:"Unknown error"}},o=t.valueBlock.value.length;if(o>0&&t.valueBlock.value[0]instanceof uc&&(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-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,It),t.name&&(delete r[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof uc){if(a=Un(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,It),t.name&&delete r[t.name]),a;if(Qu in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};F_ 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=Un(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,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&&jh in e.valueBlock){const i=ci(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,It),t.name&&(delete r[t.name],a.name=t.name)),a}return Un(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function Y_(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=ci(q.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:Un(t.result,t.result,e)}const Tg=Object.freeze(Object.defineProperty({__proto__:null,Any:ss,BaseBlock:dt,BaseStringBlock:mf,BitString:Yn,BmpString:iu,Boolean:ru,CharacterString:pu,Choice:Sf,Constructed:Ct,DATE:bf,DateTime:_f,Duration:wf,EndOfContent:yf,Enumerated:nu,GeneralString:hu,GeneralizedTime:mu,GraphicString:fu,HexBlock:jr,IA5String:du,Integer:wr,Null:ns,NumericString:ou,ObjectIdentifier:su,OctetString:Jn,Primitive:Xa,PrintableString:cu,RawData:J_,RelativeObjectIdentifier:vf,Repeated:uc,Sequence:Lr,Set:qr,TIME:kf,TeletexString:uu,TimeOfDay:xf,UTCTime:eo,UniversalString:au,Utf8String:en,ValueBlock:St,VideotexString:lu,ViewWriter:eu,VisibleString:Qa,compareSchema:Un,fromBER:Bs,verifySchema:Y_},Symbol.toStringTag,{value:"Module"}));var B;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(B||(B={}));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 yu{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 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 Ze{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 X_={fromASN:r=>r instanceof ns?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ns;const e=Bs(r);if(e.result.error)throw new Error(e.result.error);return e.result}},Q_={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new wr({value:+r})},ew={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new nu({value:r})},We={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new wr({valueHex:r})},tw={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Yn({valueHex:r})},rw={fromASN:r=>r.valueBlock.toString(),toASN:r=>new su({value:r})},nw={fromASN:r=>r.valueBlock.value,toASN:r=>new ru({value:r})},lc={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Jn({valueHex:r})},sw={fromASN:r=>new Ze(r.getValue()),toASN:r=>r.toASN()};function zt(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const Ng=zt(en),iw=zt(iu),aw=zt(au),ow=zt(ou),cw=zt(cu),uw=zt(uu),lw=zt(lu),dw=zt(du),fw=zt(fu),hw=zt(Qa),pw=zt(hu),mw=zt(pu),yw={fromASN:r=>r.toDate(),toASN:r=>new eo({valueDate:r})},gw={fromASN:r=>r.toDate(),toASN:r=>new mu({valueDate:r})},vw={fromASN:()=>null,toASN:()=>new ns};function Af(r){switch(r){case v.Any:return X_;case v.BitString:return tw;case v.BmpString:return iw;case v.Boolean:return nw;case v.CharacterString:return mw;case v.Enumerated:return ew;case v.GeneralString:return pw;case v.GeneralizedTime:return gw;case v.GraphicString:return fw;case v.IA5String:return dw;case v.Integer:return Q_;case v.Null:return vw;case v.NumericString:return ow;case v.ObjectIdentifier:return rw;case v.OctetString:return lc;case v.PrintableString:return cw;case v.TeletexString:return uw;case v.UTCTime:return yw;case v.UniversalString:return aw;case v.Utf8String:return Ng;case v.VideotexString:return lw;case v.VisibleString:return hw;default:return null}}function Ur(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:Ur(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Bg(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:Bg(t)}return!1}function bw(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 xw{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:B.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),s=[];for(const i in n.items){const a=n.items[i],o=t?i:"";let c;if(typeof a.type=="number"){const f=v[a.type],m=Tg[f];if(!m)throw new Error(`Cannot get ASN1 class by name '${f}'`);c=new m({name:o})}else Ur(a.type)?c=new a.type().toSchema(o):a.optional?this.get(a.type).type===B.Choice?c=new ss({name:o}):(c=this.create(a.type,!1),c.name=o):c=new ss({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 uc({name:o,value:c})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Ur(a.type)){const f=a.repeated?Ct:Xa;s.push(new f({name:o,optional:u,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const f=!!a.repeated;let m=f?c:this.get(a.type,!0).schema;m="valueBlock"in m?m.valueBlock.value:m.value,s.push(new Ct({name:f?"":o,optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:m}))}else s.push(new Ct({optional:u,idBlock:{tagClass:3,tagNumber:a.context},value:[c]}));else c.optional=u,s.push(c)}switch(n.type){case B.Sequence:return new Lr({value:s,name:""});case B.Set:return new qr({value:s,name:""});case B.Choice:return new Sf({value:s,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const qt=new xw,$=r=>e=>{let t;qt.has(e)?t=qt.get(e):(t=qt.createDefault(e),qt.set(e,t)),Object.assign(t,r)},h=r=>(e,t)=>{let n;qt.has(e.constructor)?n=qt.get(e.constructor):(n=qt.createDefault(e.constructor),qt.set(e.constructor,n));const s=Object.assign({},r);if(typeof s.type=="number"&&!s.converter){const i=Af(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 Nh extends Error{constructor(){super(...arguments),this.schemas=[]}}class _w{static parse(e,t){const n=Bs(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(Ur(t))return new t().fromASN(e);const s=qt.get(t);qt.cache(t);let i=s.schema;if(e.constructor===Ct&&s.type!==B.Choice){i=new Ct({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:s.schema.valueBlock.value});for(const c in s.items)delete e[c]}const a=Un({},e,i);if(!a.verified)throw new Nh(`Data does not match to ${t.name} ASN1 schema. ${a.result.error}`);const o=new t;if(Bg(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=Af(c);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,f=>u.fromASN(f))}else return t.from(e.valueBlock.value,u=>this.fromASN(u,c))}for(const c in s.items){const u=a.result[c];if(!u)continue;const f=s.items[c],m=f.type;if(typeof m=="number"||Ur(m)){const R=(n=f.converter)!==null&&n!==void 0?n:Ur(m)?new m:null;if(!R)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 y=Bs(p.toBER(!1));if(y.offset===-1)throw new Error(`Cannot parse the child item. ${y.result.error}`);if(!("value"in y.result.valueBlock&&Array.isArray(y.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const A=y.result.valueBlock.value;o[c]=Array.from(A,O=>R.fromASN(O))}else o[c]=Array.from(u,C=>R.fromASN(C));else{let C=u;if(f.implicit){let p;if(Ur(m))p=new m().toSchema("");else{const y=v[m],A=Tg[y];if(!A)throw new Error(`Cannot get '${y}' class from asn1js module`);p=new A}p.valueBlock=C.valueBlock,C=Bs(p.toBER(!1)).result}o[c]=R.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,R=>this.fromASN(R,m))}else o[c]=this.fromASN(u,m)}return o}catch(s){throw s instanceof Nh&&s.schemas.push(t.name),s}}}class Of{static serialize(e){return e instanceof dt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Ur(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=qt.get(t);qt.cache(t);let s=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const a=Af(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"&&bw(this.serialize(o.defaultValue),this.serialize(c)))continue;const u=Of.toAsnItem(o,a,t,c);if(typeof o.context=="number")if(o.implicit)if(!o.repeated&&(typeof o.type=="number"||Ur(o.type))){const f={};f.valueHex=u instanceof ns?u.valueBeforeDecodeView:u.valueBlock.toBER(),s.push(new Xa({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...f}))}else s.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:u.valueBlock.value}));else s.push(new Ct({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else o.repeated?s=s.concat(u):s.push(u)}let i;switch(n.type){case B.Sequence:i=new Lr({value:s});break;case B.Set:i=new qr({value:s});break;case B.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 ${v[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"?Lr:qr;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"?Lr:qr;i=new o({value:a})}else i=this.toASN(s);return i}}class Ue 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 Of.serialize(e)}static parse(e,t){return _w.parse(e,t)}static toString(e){const t=q.isBufferSource(e)?q.toArrayBuffer(e):L.serialize(e),n=Bs(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function d(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 Rg={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},s=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${t}\\.${t}\\.${t}\\.${t}(${a})?$`,"i")};function u(p,y){if(p.indexOf("::")!==p.lastIndexOf("::"))return null;let A=0,O=-1,P=(p.match(c.zoneIndex)||[])[0],N,be;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>y)return null;for(be=y-A,N=":";be--;)N+="0:";return p=p.replace("::",N),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),y=function(){const Le=p.split(":"),qe=[];for(let De=0;De<Le.length;De++)qe.push(parseInt(Le[De],16));return qe}(),{parts:y,zoneId:P}}function f(p,y,A,O){if(p.length!==y.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!==y[P]>>N)return!1;O-=A,P+=1}return!0}function m(p){if(i.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(s.test(p))return parseInt(p,8);throw new Error(`ipaddr: cannot parse ${p} as octal`)}return parseInt(p,10)}function R(p,y){for(;p.length<y;)p=`0${p}`;return p}const C={};C.IPv4=function(){function p(y){if(y.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,O;for(A=0;A<y.length;A++)if(O=y[A],!(0<=O&&O<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=y}return p.prototype.SpecialRanges={unspecified:[[new p([0,0,0,0]),8]],broadcast:[[new p([255,255,255,255]),32]],multicast:[[new p([224,0,0,0]),4]],linkLocal:[[new p([169,254,0,0]),16]],loopback:[[new p([127,0,0,0]),8]],carrierGradeNat:[[new p([100,64,0,0]),10]],private:[[new p([10,0,0,0]),8],[new p([172,16,0,0]),12],[new p([192,168,0,0]),16]],reserved:[[new p([192,0,0,0]),24],[new p([192,0,2,0]),24],[new p([192,88,99,0]),24],[new p([198,18,0,0]),15],[new p([198,51,100,0]),24],[new p([203,0,113,0]),24],[new p([240,0,0,0]),4]],as112:[[new p([192,175,48,0]),24],[new p([192,31,196,0]),24]],amt:[[new p([192,52,193,0]),24]]},p.prototype.kind=function(){return"ipv4"},p.prototype.match=function(y,A){let O;if(A===void 0&&(O=y,y=O[0],A=O[1]),y.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,y.octets,8,A)},p.prototype.prefixLengthFromSubnetMask=function(){let y=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,be;for(P=3;P>=0;P-=1)if(N=this.octets[P],N in O){if(be=O[N],A&&be!==0)return null;be!==8&&(A=!0),y+=be}else return null;return 32-y},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){return this.octets.slice(0)},p.prototype.toIPv4MappedAddress=function(){return C.IPv6.parse(`::ffff:${this.toString()}`)},p.prototype.toNormalizedString=function(){return this.toString()},p.prototype.toString=function(){return this.octets.join(".")},p}(),C.IPv4.broadcastAddressFromCIDR=function(p){try{const y=this.parseCIDR(p),A=y[0].toByteArray(),O=this.subnetMaskFromPrefixLength(y[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 y,A,O,P,N;try{for(y=this.parseCIDR(p),O=y[0].toByteArray(),N=this.subnetMaskFromPrefixLength(y[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 y=this.parser(p);if(y===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(y)},C.IPv4.parseCIDR=function(p){let y;if(y=p.match(/^(.+)\/(\d+)$/)){const A=parseInt(y[2]);if(A>=0&&A<=32){const O=[this.parse(y[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 y,A,O;if(y=p.match(n.fourOctet))return function(){const P=y.slice(1,6),N=[];for(let be=0;be<P.length;be++)A=P[be],N.push(m(A));return N}();if(y=p.match(n.longValue)){if(O=m(y[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(y=p.match(n.twoOctet))?function(){const P=y.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}():(y=p.match(n.threeOctet))?function(){const P=y.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 y=[0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)y[A]=255,A++;return O<4&&(y[O]=Math.pow(2,p%8)-1<<8-p%8),new this(y)},C.IPv6=function(){function p(y,A){let O,P;if(y.length===16)for(this.parts=[],O=0;O<=14;O+=2)this.parts.push(y[O]<<8|y[O+1]);else if(y.length===8)this.parts=y;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(y,A){let O;if(A===void 0&&(O=y,y=O[0],A=O[1]),y.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,y.parts,16,A)},p.prototype.prefixLengthFromSubnetMask=function(){let y=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 be=7;be>=0;be-=1)if(P=this.parts[be],P in O){if(N=O[P],A&&N!==0)return null;N!==16&&(A=!0),y+=N}else return null;return 128-y},p.prototype.range=function(){return C.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let y;const A=[],O=this.parts;for(let P=0;P<O.length;P++)y=O[P],A.push(y>>8),A.push(y&255);return A},p.prototype.toFixedLengthString=function(){const y=(function(){const O=[];for(let P=0;P<this.parts.length;P++)O.push(R(this.parts[P].toString(16),4));return O}).call(this).join(":");let A="";return this.zoneId&&(A=`%${this.zoneId}`),y+A},p.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const y=this.parts.slice(-2),A=y[0],O=y[1];return new C.IPv4([A>>8,A&255,O>>8,O&255])},p.prototype.toNormalizedString=function(){const y=(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}`),y+A},p.prototype.toRFC5952String=function(){const y=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString();let O=0,P=-1,N;for(;N=y.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 y=this.parseCIDR(p),A=y[0].toByteArray(),O=this.subnetMaskFromPrefixLength(y[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(y){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${y})`)}},C.IPv6.isIPv6=function(p){return this.parser(p)!==null},C.IPv6.isValid=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{const y=this.parser(p);return new this(y.parts,y.zoneId),!0}catch{return!1}},C.IPv6.isValidCIDR=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{return this.parseCIDR(p),!0}catch{return!1}},C.IPv6.networkAddressFromCIDR=function(p){let y,A,O,P,N;try{for(y=this.parseCIDR(p),O=y[0].toByteArray(),N=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),P=[],A=0;A<16;)P.push(parseInt(O[A],10)&parseInt(N[A],10)),A++;return new this(P)}catch(be){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${be})`)}},C.IPv6.parse=function(p){const y=this.parser(p);if(y.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(y.parts,y.zoneId)},C.IPv6.parseCIDR=function(p){let y,A,O;if((A=p.match(/^(.+)\/(\d+)$/))&&(y=parseInt(A[2]),y>=0&&y<=128))return O=[this.parse(A[1]),y],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 y,A,O,P,N,be;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))&&(be=O[6]||"",y=O[1],O[1].endsWith("::")||(y=y.slice(0,-1)),y=u(y+be,6),y.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 y.parts.push(N[0]<<8|N[1]),y.parts.push(N[2]<<8|N[3]),{parts:y.parts,zoneId:y.zoneId}}return null},C.IPv6.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>128)throw new Error("ipaddr: invalid IPv6 prefix length");const y=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let A=0;const O=Math.floor(p/8);for(;A<O;)y[A]=255,A++;return O<16&&(y[O]=Math.pow(2,p%8)-1<<8-p%8),new this(y)},C.fromByteArray=function(p){const y=p.length;if(y===4)return new C.IPv4(p);if(y===16)return new C.IPv6(p);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},C.isValid=function(p){return C.IPv6.isValid(p)||C.IPv4.isValid(p)},C.isValidCIDR=function(p){return C.IPv6.isValidCIDR(p)||C.IPv4.isValidCIDR(p)},C.parse=function(p){if(C.IPv6.isValid(p))return C.IPv6.parse(p);if(C.IPv4.isValid(p))return C.IPv4.parse(p);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},C.parseCIDR=function(p){try{return C.IPv6.parseCIDR(p)}catch{try{return C.IPv4.parseCIDR(p)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},C.process=function(p){const y=this.parse(p);return y.kind()==="ipv6"&&y.isIPv4MappedAddress()?y.toIPv4Address():y},C.subnetMatch=function(p,y,A){let O,P,N,be;A==null&&(A="unicast");for(P in y)if(Object.prototype.hasOwnProperty.call(y,P)){for(N=y[P],N[0]&&!(N[0]instanceof Array)&&(N=[N]),O=0;O<N.length;O++)if(be=N[O],p.kind()===be[0].kind()&&p.match.apply(p,be))return P}return A},r.exports?r.exports=C:e.ipaddr=C})(oc)})(Rg);var Bh=Rg.exports;class Rh{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 Bh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(te.ToHex(e))}static fromString(e){const t=Bh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var Rl,Pl,$l;let ft=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([h({type:v.TeletexString})],ft.prototype,"teletexString",void 0);d([h({type:v.PrintableString})],ft.prototype,"printableString",void 0);d([h({type:v.UniversalString})],ft.prototype,"universalString",void 0);d([h({type:v.Utf8String})],ft.prototype,"utf8String",void 0);d([h({type:v.BmpString})],ft.prototype,"bmpString",void 0);ft=d([$({type:B.Choice})],ft);let zs=class extends ft{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?te.ToHex(this.anyValue):super.toString())}};d([h({type:v.IA5String})],zs.prototype,"ia5String",void 0);d([h({type:v.Any})],zs.prototype,"anyValue",void 0);zs=d([$({type:B.Choice})],zs);class gu{constructor(e={}){this.type="",this.value=new zs,Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],gu.prototype,"type",void 0);d([h({type:zs})],gu.prototype,"value",void 0);let Gs=Rl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Rl.prototype)}};Gs=Rl=d([$({type:B.Set,itemType:gu})],Gs);let Zl=Pl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};Zl=Pl=d([$({type:B.Sequence,itemType:Gs})],Zl);let et=$l=class extends Zl{constructor(e){super(e),Object.setPrototypeOf(this,$l.prototype)}};et=$l=d([$({type:B.Sequence})],et);const ww={fromASN:r=>Rh.toString(lc.fromASN(r)),toASN:r=>lc.toASN(Rh.fromString(r))};class ba{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],ba.prototype,"typeId",void 0);d([h({type:v.Any,context:0})],ba.prototype,"value",void 0);class Ef{constructor(e={}){this.partyName=new ft,Object.assign(this,e)}}d([h({type:ft,optional:!0,context:0,implicit:!0})],Ef.prototype,"nameAssigner",void 0);d([h({type:ft,context:1,implicit:!0})],Ef.prototype,"partyName",void 0);let ve=class{constructor(e={}){Object.assign(this,e)}};d([h({type:ba,context:0,implicit:!0})],ve.prototype,"otherName",void 0);d([h({type:v.IA5String,context:1,implicit:!0})],ve.prototype,"rfc822Name",void 0);d([h({type:v.IA5String,context:2,implicit:!0})],ve.prototype,"dNSName",void 0);d([h({type:v.Any,context:3,implicit:!0})],ve.prototype,"x400Address",void 0);d([h({type:et,context:4,implicit:!1})],ve.prototype,"directoryName",void 0);d([h({type:Ef,context:5})],ve.prototype,"ediPartyName",void 0);d([h({type:v.IA5String,context:6,implicit:!0})],ve.prototype,"uniformResourceIdentifier",void 0);d([h({type:v.OctetString,context:7,implicit:!0,converter:ww})],ve.prototype,"iPAddress",void 0);d([h({type:v.ObjectIdentifier,context:8,implicit:!0})],ve.prototype,"registeredID",void 0);ve=d([$({type:B.Choice})],ve);const If="1.3.6.1.5.5.7",kw=`${If}.1`,ui=`${If}.3`,vu=`${If}.48`,Ph=`${vu}.1`,$h=`${vu}.2`,Zh=`${vu}.3`,Dh=`${vu}.5`,Tn="2.5.29";var Dl;const Ml=`${kw}.1`;class to{constructor(e={}){this.accessMethod="",this.accessLocation=new ve,Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],to.prototype,"accessMethod",void 0);d([h({type:ve})],to.prototype,"accessLocation",void 0);let Is=Dl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Dl.prototype)}};Is=Dl=d([$({type:B.Sequence,itemType:to})],Is);const Vl=`${Tn}.35`;class Cf extends Ze{}class Ln{constructor(e={}){e&&Object.assign(this,e)}}d([h({type:Cf,context:0,optional:!0,implicit:!0})],Ln.prototype,"keyIdentifier",void 0);d([h({type:ve,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Ln.prototype,"authorityCertIssuer",void 0);d([h({type:v.Integer,context:2,optional:!0,implicit:!0,converter:We})],Ln.prototype,"authorityCertSerialNumber",void 0);const Pg=`${Tn}.19`;class dc{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([h({type:v.Boolean,defaultValue:!1})],dc.prototype,"cA",void 0);d([h({type:v.Integer,optional:!0})],dc.prototype,"pathLenConstraint",void 0);var Ul;let bt=Ul=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Ul.prototype)}};bt=Ul=d([$({type:B.Sequence,itemType:ve})],bt);var Ll;let Mh=Ll=class extends bt{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};Mh=Ll=d([$({type:B.Sequence})],Mh);var ql;const $g=`${Tn}.32`;let Wr=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([h({type:v.IA5String})],Wr.prototype,"ia5String",void 0);d([h({type:v.VisibleString})],Wr.prototype,"visibleString",void 0);d([h({type:v.BmpString})],Wr.prototype,"bmpString",void 0);d([h({type:v.Utf8String})],Wr.prototype,"utf8String",void 0);Wr=d([$({type:B.Choice})],Wr);class jf{constructor(e={}){this.organization=new Wr,this.noticeNumbers=[],Object.assign(this,e)}}d([h({type:Wr})],jf.prototype,"organization",void 0);d([h({type:v.Integer,repeated:"sequence"})],jf.prototype,"noticeNumbers",void 0);class Tf{constructor(e={}){Object.assign(this,e)}}d([h({type:jf,optional:!0})],Tf.prototype,"noticeRef",void 0);d([h({type:Wr,optional:!0})],Tf.prototype,"explicitText",void 0);let fc=class{constructor(e={}){Object.assign(this,e)}};d([h({type:v.IA5String})],fc.prototype,"cPSuri",void 0);d([h({type:Tf})],fc.prototype,"userNotice",void 0);fc=d([$({type:B.Choice})],fc);class Nf{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Nf.prototype,"policyQualifierId",void 0);d([h({type:v.Any})],Nf.prototype,"qualifier",void 0);class bu{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],bu.prototype,"policyIdentifier",void 0);d([h({type:Nf,repeated:"sequence",optional:!0})],bu.prototype,"policyQualifiers",void 0);let hc=ql=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,ql.prototype)}};hc=ql=d([$({type:B.Sequence,itemType:bu})],hc);let pc=class{constructor(e=0){this.value=e}};d([h({type:v.Integer})],pc.prototype,"value",void 0);pc=d([$({type:B.Choice})],pc);let Vh=class extends pc{};Vh=d([$({type:B.Choice})],Vh);var Hl;const Fl=`${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 Zg extends yu{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 is=class{constructor(e={}){Object.assign(this,e)}};d([h({type:ve,context:0,repeated:"sequence",implicit:!0})],is.prototype,"fullName",void 0);d([h({type:Gs,context:1,implicit:!0})],is.prototype,"nameRelativeToCRLIssuer",void 0);is=d([$({type:B.Choice})],is);class li{constructor(e={}){Object.assign(this,e)}}d([h({type:is,context:0,optional:!0})],li.prototype,"distributionPoint",void 0);d([h({type:Zg,context:1,optional:!0,implicit:!0})],li.prototype,"reasons",void 0);d([h({type:ve,context:2,optional:!0,repeated:"sequence",implicit:!0})],li.prototype,"cRLIssuer",void 0);let Rs=Hl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Hl.prototype)}};Rs=Hl=d([$({type:B.Sequence,itemType:li})],Rs);var Wl;let Uh=Wl=class extends Rs{constructor(e){super(e),Object.setPrototypeOf(this,Wl.prototype)}};Uh=Wl=d([$({type:B.Sequence,itemType:li})],Uh);class mt{constructor(e={}){this.onlyContainsUserCerts=mt.ONLY,this.onlyContainsCACerts=mt.ONLY,this.indirectCRL=mt.ONLY,this.onlyContainsAttributeCerts=mt.ONLY,Object.assign(this,e)}}mt.ONLY=!1;d([h({type:is,context:0,optional:!0})],mt.prototype,"distributionPoint",void 0);d([h({type:v.Boolean,context:1,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsUserCerts",void 0);d([h({type:v.Boolean,context:2,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsCACerts",void 0);d([h({type:Zg,context:3,optional:!0,implicit:!0})],mt.prototype,"onlySomeReasons",void 0);d([h({type:v.Boolean,context:4,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"indirectCRL",void 0);d([h({type:v.Boolean,context:5,defaultValue:mt.ONLY,implicit:!0})],mt.prototype,"onlyContainsAttributeCerts",void 0);var Di;(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"})(Di||(Di={}));let Kl=class{constructor(e=Di.unspecified){this.reason=Di.unspecified,this.reason=e}toJSON(){return Di[this.reason]}toString(){return this.toJSON()}};d([h({type:v.Enumerated})],Kl.prototype,"reason",void 0);Kl=d([$({type:B.Choice})],Kl);var zl;const Dg=`${Tn}.37`;let mc=zl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};mc=zl=d([$({type:B.Sequence,itemType:v.ObjectIdentifier})],mc);const Sw=`${ui}.1`,Aw=`${ui}.2`,Ow=`${ui}.3`,Ew=`${ui}.4`,Iw=`${ui}.8`,Cw=`${ui}.9`;let Gl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([h({type:v.Integer,converter:We})],Gl.prototype,"value",void 0);Gl=d([$({type:B.Choice})],Gl);let Jl=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([h({type:v.GeneralizedTime})],Jl.prototype,"value",void 0);Jl=d([$({type:B.Choice})],Jl);var Yl;let Lh=Yl=class extends bt{constructor(e){super(e),Object.setPrototypeOf(this,Yl.prototype)}};Lh=Yl=d([$({type:B.Sequence})],Lh);const Mg=`${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 el extends yu{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 Xl;class xu{constructor(e={}){this.base=new ve,this.minimum=0,Object.assign(this,e)}}d([h({type:ve})],xu.prototype,"base",void 0);d([h({type:v.Integer,context:0,defaultValue:0,implicit:!0})],xu.prototype,"minimum",void 0);d([h({type:v.Integer,context:1,optional:!0,implicit:!0})],xu.prototype,"maximum",void 0);let yc=Xl=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Xl.prototype)}};yc=Xl=d([$({type:B.Sequence,itemType:xu})],yc);class Vg{constructor(e={}){Object.assign(this,e)}}d([h({type:yc,context:0,optional:!0,implicit:!0})],Vg.prototype,"permittedSubtrees",void 0);d([h({type:yc,context:1,optional:!0,implicit:!0})],Vg.prototype,"excludedSubtrees",void 0);class Ug{constructor(e={}){Object.assign(this,e)}}d([h({type:v.Integer,context:0,implicit:!0,optional:!0,converter:We})],Ug.prototype,"requireExplicitPolicy",void 0);d([h({type:v.Integer,context:1,implicit:!0,optional:!0,converter:We})],Ug.prototype,"inhibitPolicyMapping",void 0);var Ql;class Bf{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Bf.prototype,"issuerDomainPolicy",void 0);d([h({type:v.ObjectIdentifier})],Bf.prototype,"subjectDomainPolicy",void 0);let qh=Ql=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Ql.prototype)}};qh=Ql=d([$({type:B.Sequence,itemType:Bf})],qh);var ed;const Lg=`${Tn}.17`;let td=ed=class extends bt{constructor(e){super(e),Object.setPrototypeOf(this,ed.prototype)}};td=ed=d([$({type:B.Sequence})],td);let Kr=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([h({type:v.ObjectIdentifier})],Kr.prototype,"type",void 0);d([h({type:v.Any,repeated:"set"})],Kr.prototype,"values",void 0);var rd;let Hh=rd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,rd.prototype)}};Hh=rd=d([$({type:B.Sequence,itemType:Kr})],Hh);const qg=`${Tn}.14`;class yn extends Cf{}class Hg{constructor(e={}){Object.assign(this,e)}}d([h({type:v.GeneralizedTime,context:0,implicit:!0,optional:!0})],Hg.prototype,"notBefore",void 0);d([h({type:v.GeneralizedTime,context:1,implicit:!0,optional:!0})],Hg.prototype,"notAfter",void 0);var Mi;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Mi||(Mi={}));class Fg extends yu{toJSON(){const e=[],t=this.toNumber();return t&Mi.pKIXCertificate&&e.push("pKIXCertificate"),t&Mi.newExtensions&&e.push("newExtensions"),t&Mi.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Wg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Fg,Object.assign(this,e)}}d([h({type:v.GeneralString})],Wg.prototype,"entrustVers",void 0);d([h({type:Fg})],Wg.prototype,"entrustInfoFlags",void 0);var nd;let Fh=nd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,nd.prototype)}};Fh=nd=d([$({type:B.Sequence,itemType:to})],Fh);class Y{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof Y&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Ny(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([h({type:v.ObjectIdentifier})],Y.prototype,"algorithm",void 0);d([h({type:v.Any,optional:!0})],Y.prototype,"parameters",void 0);class ir{constructor(e={}){this.algorithm=new Y,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:Y})],ir.prototype,"algorithm",void 0);d([h({type:v.BitString})],ir.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}};d([h({type:v.UTCTime})],lt.prototype,"utcTime",void 0);d([h({type:v.GeneralizedTime})],lt.prototype,"generalTime",void 0);lt=d([$({type:B.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))}}d([h({type:lt})],ro.prototype,"notBefore",void 0);d([h({type:lt})],ro.prototype,"notAfter",void 0);var sd;let Kt=class Kg{constructor(e={}){this.extnID="",this.critical=Kg.CRITICAL,this.extnValue=new Ze,Object.assign(this,e)}};Kt.CRITICAL=!1;d([h({type:v.ObjectIdentifier})],Kt.prototype,"extnID",void 0);d([h({type:v.Boolean,defaultValue:Kt.CRITICAL})],Kt.prototype,"critical",void 0);d([h({type:Ze})],Kt.prototype,"extnValue",void 0);let kn=sd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,sd.prototype)}};kn=sd=d([$({type:B.Sequence,itemType:Kt})],kn);var as;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(as||(as={}));class Vt{constructor(e={}){this.version=as.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 ir,Object.assign(this,e)}}d([h({type:v.Integer,context:0,defaultValue:as.v1})],Vt.prototype,"version",void 0);d([h({type:v.Integer,converter:We})],Vt.prototype,"serialNumber",void 0);d([h({type:Y})],Vt.prototype,"signature",void 0);d([h({type:et})],Vt.prototype,"issuer",void 0);d([h({type:ro})],Vt.prototype,"validity",void 0);d([h({type:et})],Vt.prototype,"subject",void 0);d([h({type:ir})],Vt.prototype,"subjectPublicKeyInfo",void 0);d([h({type:v.BitString,context:1,implicit:!0,optional:!0})],Vt.prototype,"issuerUniqueID",void 0);d([h({type:v.BitString,context:2,implicit:!0,optional:!0})],Vt.prototype,"subjectUniqueID",void 0);d([h({type:kn,context:3,optional:!0})],Vt.prototype,"extensions",void 0);class os{constructor(e={}){this.tbsCertificate=new Vt,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:Vt})],os.prototype,"tbsCertificate",void 0);d([h({type:Y})],os.prototype,"signatureAlgorithm",void 0);d([h({type:v.BitString})],os.prototype,"signatureValue",void 0);class _u{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new lt,Object.assign(this,e)}}d([h({type:v.Integer,converter:We})],_u.prototype,"userCertificate",void 0);d([h({type:lt})],_u.prototype,"revocationDate",void 0);d([h({type:Kt,optional:!0,repeated:"sequence"})],_u.prototype,"crlEntryExtensions",void 0);class tn{constructor(e={}){this.signature=new Y,this.issuer=new et,this.thisUpdate=new lt,Object.assign(this,e)}}d([h({type:v.Integer,optional:!0})],tn.prototype,"version",void 0);d([h({type:Y})],tn.prototype,"signature",void 0);d([h({type:et})],tn.prototype,"issuer",void 0);d([h({type:lt})],tn.prototype,"thisUpdate",void 0);d([h({type:lt,optional:!0})],tn.prototype,"nextUpdate",void 0);d([h({type:_u,repeated:"sequence",optional:!0})],tn.prototype,"revokedCertificates",void 0);d([h({type:Kt,optional:!0,context:0,repeated:"sequence"})],tn.prototype,"crlExtensions",void 0);class Rf{constructor(e={}){this.tbsCertList=new tn,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:tn})],Rf.prototype,"tbsCertList",void 0);d([h({type:Y})],Rf.prototype,"signatureAlgorithm",void 0);d([h({type:v.BitString})],Rf.prototype,"signature",void 0);class di{constructor(e={}){this.issuer=new et,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:et})],di.prototype,"issuer",void 0);d([h({type:v.Integer,converter:We})],di.prototype,"serialNumber",void 0);let Js=class{constructor(e={}){Object.assign(this,e)}};d([h({type:yn,context:0,implicit:!0})],Js.prototype,"subjectKeyIdentifier",void 0);d([h({type:di})],Js.prototype,"issuerAndSerialNumber",void 0);Js=d([$({type:B.Choice})],Js);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=d([$({type:B.Sequence})],xa);let gc=class extends Y{};gc=d([$({type:B.Sequence})],gc);let Er=class extends Y{};Er=d([$({type:B.Sequence})],Er);let vc=class extends Y{};vc=d([$({type:B.Sequence})],vc);let Wh=class extends Y{};Wh=d([$({type:B.Sequence})],Wh);let id=class extends Y{};id=d([$({type:B.Sequence})],id);let fi=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([h({type:v.ObjectIdentifier})],fi.prototype,"attrType",void 0);d([h({type:v.Any,repeated:"set"})],fi.prototype,"attrValues",void 0);var ad;class Tr{constructor(e={}){this.version=zr.v0,this.sid=new Js,this.digestAlgorithm=new xa,this.signatureAlgorithm=new gc,this.signature=new Ze,Object.assign(this,e)}}d([h({type:v.Integer})],Tr.prototype,"version",void 0);d([h({type:Js})],Tr.prototype,"sid",void 0);d([h({type:xa})],Tr.prototype,"digestAlgorithm",void 0);d([h({type:fi,repeated:"set",context:0,implicit:!0,optional:!0})],Tr.prototype,"signedAttrs",void 0);d([h({type:gc})],Tr.prototype,"signatureAlgorithm",void 0);d([h({type:Ze})],Tr.prototype,"signature",void 0);d([h({type:fi,repeated:"set",context:1,implicit:!0,optional:!0})],Tr.prototype,"unsignedAttrs",void 0);let bc=ad=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,ad.prototype)}};bc=ad=d([$({type:B.Set,itemType:Tr})],bc);let Kh=class extends lt{};Kh=d([$({type:B.Choice})],Kh);let zh=class extends Tr{};zh=d([$({type:B.Sequence})],zh);class Pf{constructor(e={}){this.acIssuer=new ve,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([h({type:ve})],Pf.prototype,"acIssuer",void 0);d([h({type:v.Integer})],Pf.prototype,"acSerial",void 0);d([h({type:Kr,repeated:"sequence"})],Pf.prototype,"attrs",void 0);var od;let xc=od=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,od.prototype)}};xc=od=d([$({type:B.Sequence,itemType:v.ObjectIdentifier})],xc);class wu{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([h({type:v.Integer,optional:!0})],wu.prototype,"pathLenConstraint",void 0);d([h({type:xc,implicit:!0,context:0,optional:!0})],wu.prototype,"permittedAttrs",void 0);d([h({type:xc,implicit:!0,context:1,optional:!0})],wu.prototype,"excludedAttrs",void 0);d([h({type:v.Boolean,defaultValue:!0})],wu.prototype,"permitUnSpecified",void 0);class vs{constructor(e={}){this.issuer=new bt,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:bt})],vs.prototype,"issuer",void 0);d([h({type:v.Integer,converter:We})],vs.prototype,"serial",void 0);d([h({type:v.BitString,optional:!0})],vs.prototype,"issuerUID",void 0);var cd;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(cd||(cd={}));class bs{constructor(e={}){this.digestedObjectType=cd.publicKey,this.digestAlgorithm=new Y,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.Enumerated})],bs.prototype,"digestedObjectType",void 0);d([h({type:v.ObjectIdentifier,optional:!0})],bs.prototype,"otherObjectTypeID",void 0);d([h({type:Y})],bs.prototype,"digestAlgorithm",void 0);d([h({type:v.BitString})],bs.prototype,"objectDigest",void 0);class ku{constructor(e={}){Object.assign(this,e)}}d([h({type:bt,optional:!0})],ku.prototype,"issuerName",void 0);d([h({type:vs,context:0,implicit:!0,optional:!0})],ku.prototype,"baseCertificateID",void 0);d([h({type:bs,context:1,implicit:!0,optional:!0})],ku.prototype,"objectDigestInfo",void 0);let Ys=class{constructor(e={}){Object.assign(this,e)}};d([h({type:ve,repeated:"sequence"})],Ys.prototype,"v1Form",void 0);d([h({type:ku,context:0,implicit:!0})],Ys.prototype,"v2Form",void 0);Ys=d([$({type:B.Choice})],Ys);class Su{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([h({type:v.GeneralizedTime})],Su.prototype,"notBeforeTime",void 0);d([h({type:v.GeneralizedTime})],Su.prototype,"notAfterTime",void 0);class no{constructor(e={}){Object.assign(this,e)}}d([h({type:vs,implicit:!0,context:0,optional:!0})],no.prototype,"baseCertificateID",void 0);d([h({type:bt,implicit:!0,context:1,optional:!0})],no.prototype,"entityName",void 0);d([h({type:bs,implicit:!0,context:2,optional:!0})],no.prototype,"objectDigestInfo",void 0);var ud;(function(r){r[r.v2=1]="v2"})(ud||(ud={}));class mr{constructor(e={}){this.version=ud.v2,this.holder=new no,this.issuer=new Ys,this.signature=new Y,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Su,this.attributes=[],Object.assign(this,e)}}d([h({type:v.Integer})],mr.prototype,"version",void 0);d([h({type:no})],mr.prototype,"holder",void 0);d([h({type:Ys})],mr.prototype,"issuer",void 0);d([h({type:Y})],mr.prototype,"signature",void 0);d([h({type:v.Integer,converter:We})],mr.prototype,"serialNumber",void 0);d([h({type:Su})],mr.prototype,"attrCertValidityPeriod",void 0);d([h({type:Kr,repeated:"sequence"})],mr.prototype,"attributes",void 0);d([h({type:v.BitString,optional:!0})],mr.prototype,"issuerUniqueID",void 0);d([h({type:kn,optional:!0})],mr.prototype,"extensions",void 0);class Au{constructor(e={}){this.acinfo=new mr,this.signatureAlgorithm=new Y,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:mr})],Au.prototype,"acinfo",void 0);d([h({type:Y})],Au.prototype,"signatureAlgorithm",void 0);d([h({type:v.BitString})],Au.prototype,"signatureValue",void 0);var _c;(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"})(_c||(_c={}));class ld extends yu{}class $f{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier,implicit:!0,context:0})],$f.prototype,"type",void 0);d([h({type:v.Any,implicit:!0,context:1})],$f.prototype,"value",void 0);class Zf{constructor(e={}){this.policyId="",this.classList=new ld(_c.unclassified),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Zf.prototype,"policyId",void 0);d([h({type:ld,defaultValue:new ld(_c.unclassified)})],Zf.prototype,"classList",void 0);d([h({type:$f,repeated:"set"})],Zf.prototype,"securityCategories",void 0);class Ou{constructor(e={}){Object.assign(this,e)}}d([h({type:Ze})],Ou.prototype,"cotets",void 0);d([h({type:v.ObjectIdentifier})],Ou.prototype,"oid",void 0);d([h({type:v.Utf8String})],Ou.prototype,"string",void 0);class zg{constructor(e={}){this.values=[],Object.assign(this,e)}}d([h({type:bt,implicit:!0,context:0,optional:!0})],zg.prototype,"policyAuthority",void 0);d([h({type:Ou,repeated:"sequence"})],zg.prototype,"values",void 0);var dd;class Eu{constructor(e={}){this.targetCertificate=new vs,Object.assign(this,e)}}d([h({type:vs})],Eu.prototype,"targetCertificate",void 0);d([h({type:ve,optional:!0})],Eu.prototype,"targetName",void 0);d([h({type:bs,optional:!0})],Eu.prototype,"certDigestInfo",void 0);let Xs=class{constructor(e={}){Object.assign(this,e)}};d([h({type:ve,context:0,implicit:!0})],Xs.prototype,"targetName",void 0);d([h({type:ve,context:1,implicit:!0})],Xs.prototype,"targetGroup",void 0);d([h({type:Eu,context:2,implicit:!0})],Xs.prototype,"targetCert",void 0);Xs=d([$({type:B.Choice})],Xs);let fd=dd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,dd.prototype)}};fd=dd=d([$({type:B.Sequence,itemType:Xs})],fd);var hd;let Gh=hd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,hd.prototype)}};Gh=hd=d([$({type:B.Sequence,itemType:fd})],Gh);class Gg{constructor(e={}){Object.assign(this,e)}}d([h({type:bt,implicit:!0,context:0,optional:!0})],Gg.prototype,"roleAuthority",void 0);d([h({type:ve,implicit:!0,context:1})],Gg.prototype,"roleName",void 0);class Df{constructor(e={}){this.service=new ve,this.ident=new ve,Object.assign(this,e)}}d([h({type:ve})],Df.prototype,"service",void 0);d([h({type:ve})],Df.prototype,"ident",void 0);d([h({type:Ze,optional:!0})],Df.prototype,"authInfo",void 0);var pd;class Mf{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Mf.prototype,"otherCertFormat",void 0);d([h({type:v.Any})],Mf.prototype,"otherCert",void 0);let Qs=class{constructor(e={}){Object.assign(this,e)}};d([h({type:os})],Qs.prototype,"certificate",void 0);d([h({type:Au,context:2,implicit:!0})],Qs.prototype,"v2AttrCert",void 0);d([h({type:Mf,context:3,implicit:!0})],Qs.prototype,"other",void 0);Qs=d([$({type:B.Choice})],Qs);let wc=pd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,pd.prototype)}};wc=pd=d([$({type:B.Set,itemType:Qs})],wc);class hi{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],hi.prototype,"contentType",void 0);d([h({type:v.Any,context:0})],hi.prototype,"content",void 0);let _a=class{constructor(e={}){Object.assign(this,e)}};d([h({type:Ze})],_a.prototype,"single",void 0);d([h({type:v.Any})],_a.prototype,"any",void 0);_a=d([$({type:B.Choice})],_a);class Iu{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Iu.prototype,"eContentType",void 0);d([h({type:_a,context:0,optional:!0})],Iu.prototype,"eContent",void 0);let wa=class{constructor(e={}){Object.assign(this,e)}};d([h({type:Ze,context:0,implicit:!0,optional:!0})],wa.prototype,"value",void 0);d([h({type:Ze,converter:sw,context:0,implicit:!0,optional:!0,repeated:"sequence"})],wa.prototype,"constructedValue",void 0);wa=d([$({type:B.Choice})],wa);class so{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new vc,Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],so.prototype,"contentType",void 0);d([h({type:vc})],so.prototype,"contentEncryptionAlgorithm",void 0);d([h({type:wa,optional:!0})],so.prototype,"encryptedContent",void 0);class Cu{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Cu.prototype,"keyAttrId",void 0);d([h({type:v.Any,optional:!0})],Cu.prototype,"keyAttr",void 0);var md;class ju{constructor(e={}){this.subjectKeyIdentifier=new yn,Object.assign(this,e)}}d([h({type:yn})],ju.prototype,"subjectKeyIdentifier",void 0);d([h({type:v.GeneralizedTime,optional:!0})],ju.prototype,"date",void 0);d([h({type:Cu,optional:!0})],ju.prototype,"other",void 0);let ei=class{constructor(e={}){Object.assign(this,e)}};d([h({type:ju,context:0,implicit:!0,optional:!0})],ei.prototype,"rKeyId",void 0);d([h({type:di,optional:!0})],ei.prototype,"issuerAndSerialNumber",void 0);ei=d([$({type:B.Choice})],ei);class Vf{constructor(e={}){this.rid=new ei,this.encryptedKey=new Ze,Object.assign(this,e)}}d([h({type:ei})],Vf.prototype,"rid",void 0);d([h({type:Ze})],Vf.prototype,"encryptedKey",void 0);let kc=md=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,md.prototype)}};kc=md=d([$({type:B.Sequence,itemType:Vf})],kc);class Uf{constructor(e={}){this.algorithm=new Y,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:Y})],Uf.prototype,"algorithm",void 0);d([h({type:v.BitString})],Uf.prototype,"publicKey",void 0);let cs=class{constructor(e={}){Object.assign(this,e)}};d([h({type:yn,context:0,implicit:!0,optional:!0})],cs.prototype,"subjectKeyIdentifier",void 0);d([h({type:Uf,context:1,implicit:!0,optional:!0})],cs.prototype,"originatorKey",void 0);d([h({type:di,optional:!0})],cs.prototype,"issuerAndSerialNumber",void 0);cs=d([$({type:B.Choice})],cs);class pi{constructor(e={}){this.version=zr.v3,this.originator=new cs,this.keyEncryptionAlgorithm=new Er,this.recipientEncryptedKeys=new kc,Object.assign(this,e)}}d([h({type:v.Integer})],pi.prototype,"version",void 0);d([h({type:cs,context:0})],pi.prototype,"originator",void 0);d([h({type:Ze,context:1,optional:!0})],pi.prototype,"ukm",void 0);d([h({type:Er})],pi.prototype,"keyEncryptionAlgorithm",void 0);d([h({type:kc})],pi.prototype,"recipientEncryptedKeys",void 0);let ti=class{constructor(e={}){Object.assign(this,e)}};d([h({type:yn,context:0,implicit:!0})],ti.prototype,"subjectKeyIdentifier",void 0);d([h({type:di})],ti.prototype,"issuerAndSerialNumber",void 0);ti=d([$({type:B.Choice})],ti);class io{constructor(e={}){this.version=zr.v0,this.rid=new ti,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new Ze,Object.assign(this,e)}}d([h({type:v.Integer})],io.prototype,"version",void 0);d([h({type:ti})],io.prototype,"rid",void 0);d([h({type:Er})],io.prototype,"keyEncryptionAlgorithm",void 0);d([h({type:Ze})],io.prototype,"encryptedKey",void 0);class ao{constructor(e={}){this.keyIdentifier=new Ze,Object.assign(this,e)}}d([h({type:Ze})],ao.prototype,"keyIdentifier",void 0);d([h({type:v.GeneralizedTime,optional:!0})],ao.prototype,"date",void 0);d([h({type:Cu,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 Ze,Object.assign(this,e)}}d([h({type:v.Integer})],oo.prototype,"version",void 0);d([h({type:ao})],oo.prototype,"kekid",void 0);d([h({type:Er})],oo.prototype,"keyEncryptionAlgorithm",void 0);d([h({type:Ze})],oo.prototype,"encryptedKey",void 0);class co{constructor(e={}){this.version=zr.v0,this.keyEncryptionAlgorithm=new Er,this.encryptedKey=new Ze,Object.assign(this,e)}}d([h({type:v.Integer})],co.prototype,"version",void 0);d([h({type:id,context:0,optional:!0})],co.prototype,"keyDerivationAlgorithm",void 0);d([h({type:Er})],co.prototype,"keyEncryptionAlgorithm",void 0);d([h({type:Ze})],co.prototype,"encryptedKey",void 0);class Lf{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Lf.prototype,"oriType",void 0);d([h({type:v.Any})],Lf.prototype,"oriValue",void 0);let Sn=class{constructor(e={}){Object.assign(this,e)}};d([h({type:io,optional:!0})],Sn.prototype,"ktri",void 0);d([h({type:pi,context:1,implicit:!0,optional:!0})],Sn.prototype,"kari",void 0);d([h({type:oo,context:2,implicit:!0,optional:!0})],Sn.prototype,"kekri",void 0);d([h({type:co,context:3,implicit:!0,optional:!0})],Sn.prototype,"pwri",void 0);d([h({type:Lf,context:4,implicit:!0,optional:!0})],Sn.prototype,"ori",void 0);Sn=d([$({type:B.Choice})],Sn);var yd;let Sc=yd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,yd.prototype)}};Sc=yd=d([$({type:B.Set,itemType:Sn})],Sc);var gd;class Tu{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Tu.prototype,"otherRevInfoFormat",void 0);d([h({type:v.Any})],Tu.prototype,"otherRevInfo",void 0);let Ac=class{constructor(e={}){this.other=new Tu,Object.assign(this,e)}};d([h({type:Tu,context:1,implicit:!0})],Ac.prototype,"other",void 0);Ac=d([$({type:B.Choice})],Ac);let Oc=gd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,gd.prototype)}};Oc=gd=d([$({type:B.Set,itemType:Ac})],Oc);class qf{constructor(e={}){Object.assign(this,e)}}d([h({type:wc,context:0,implicit:!0,optional:!0})],qf.prototype,"certs",void 0);d([h({type:Oc,context:1,implicit:!0,optional:!0})],qf.prototype,"crls",void 0);var vd;let bd=vd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,vd.prototype)}};bd=vd=d([$({type:B.Set,itemType:fi})],bd);class uo{constructor(e={}){this.version=zr.v0,this.recipientInfos=new Sc,this.encryptedContentInfo=new so,Object.assign(this,e)}}d([h({type:v.Integer})],uo.prototype,"version",void 0);d([h({type:qf,context:0,implicit:!0,optional:!0})],uo.prototype,"originatorInfo",void 0);d([h({type:Sc})],uo.prototype,"recipientInfos",void 0);d([h({type:so})],uo.prototype,"encryptedContentInfo",void 0);d([h({type:bd,context:1,implicit:!0,optional:!0})],uo.prototype,"unprotectedAttrs",void 0);const jw="1.2.840.113549.1.7.2";var xd;let Ec=xd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,xd.prototype)}};Ec=xd=d([$({type:B.Set,itemType:xa})],Ec);class mi{constructor(e={}){this.version=zr.v0,this.digestAlgorithms=new Ec,this.encapContentInfo=new Iu,this.signerInfos=new bc,Object.assign(this,e)}}d([h({type:v.Integer})],mi.prototype,"version",void 0);d([h({type:Ec})],mi.prototype,"digestAlgorithms",void 0);d([h({type:Iu})],mi.prototype,"encapContentInfo",void 0);d([h({type:wc,context:0,implicit:!0,optional:!0})],mi.prototype,"certificates",void 0);d([h({type:Oc,context:1,implicit:!0,optional:!0})],mi.prototype,"crls",void 0);d([h({type:bc})],mi.prototype,"signerInfos",void 0);const ka="1.2.840.10045.2.1",Hf="1.2.840.10045.4.1",Jg="1.2.840.10045.4.3.1",Ff="1.2.840.10045.4.3.2",Wf="1.2.840.10045.4.3.3",Kf="1.2.840.10045.4.3.4",Jh="1.2.840.10045.3.1.7",Yh="1.3.132.0.34",Xh="1.3.132.0.35";function lo(r){return new Y({algorithm:r})}const Tw=lo(Hf);lo(Jg);const Nw=lo(Ff),Bw=lo(Wf),Rw=lo(Kf);let Sa=class{constructor(e={}){Object.assign(this,e)}};d([h({type:v.ObjectIdentifier})],Sa.prototype,"fieldType",void 0);d([h({type:v.Any})],Sa.prototype,"parameters",void 0);Sa=d([$({type:B.Sequence})],Sa);class Pw extends Ze{}let ri=class{constructor(e={}){Object.assign(this,e)}};d([h({type:v.OctetString})],ri.prototype,"a",void 0);d([h({type:v.OctetString})],ri.prototype,"b",void 0);d([h({type:v.BitString,optional:!0})],ri.prototype,"seed",void 0);ri=d([$({type:B.Sequence})],ri);var _d;(function(r){r[r.ecpVer1=1]="ecpVer1"})(_d||(_d={}));let Gr=class{constructor(e={}){this.version=_d.ecpVer1,Object.assign(this,e)}};d([h({type:v.Integer})],Gr.prototype,"version",void 0);d([h({type:Sa})],Gr.prototype,"fieldID",void 0);d([h({type:ri})],Gr.prototype,"curve",void 0);d([h({type:Pw})],Gr.prototype,"base",void 0);d([h({type:v.Integer,converter:We})],Gr.prototype,"order",void 0);d([h({type:v.Integer,optional:!0})],Gr.prototype,"cofactor",void 0);Gr=d([$({type:B.Sequence})],Gr);let An=class{constructor(e={}){Object.assign(this,e)}};d([h({type:v.ObjectIdentifier})],An.prototype,"namedCurve",void 0);d([h({type:v.Null})],An.prototype,"implicitCurve",void 0);d([h({type:Gr})],An.prototype,"specifiedCurve",void 0);An=d([$({type:B.Choice})],An);class Nu{constructor(e={}){this.version=1,this.privateKey=new Ze,Object.assign(this,e)}}d([h({type:v.Integer})],Nu.prototype,"version",void 0);d([h({type:Ze})],Nu.prototype,"privateKey",void 0);d([h({type:An,context:0,optional:!0})],Nu.prototype,"parameters",void 0);d([h({type:v.BitString,context:1,optional:!0})],Nu.prototype,"publicKey",void 0);class Ic{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.Integer,converter:We})],Ic.prototype,"r",void 0);d([h({type:v.Integer,converter:We})],Ic.prototype,"s",void 0);const Nt="1.2.840.113549.1.1",us=`${Nt}.1`,$w=`${Nt}.7`,Zw=`${Nt}.9`,Vi=`${Nt}.10`,Dw=`${Nt}.2`,Mw=`${Nt}.4`,Cc=`${Nt}.5`,Vw=`${Nt}.14`,wd=`${Nt}.11`,jc=`${Nt}.12`,Tc=`${Nt}.13`,Yg=`${Nt}.15`,Xg=`${Nt}.16`,Nc="1.3.14.3.2.26",Qg="2.16.840.1.101.3.4.2.4",Bc="2.16.840.1.101.3.4.2.1",Rc="2.16.840.1.101.3.4.2.2",Pc="2.16.840.1.101.3.4.2.3",Uw="2.16.840.1.101.3.4.2.5",Lw="2.16.840.1.101.3.4.2.6",qw="1.2.840.113549.2.2",Hw="1.2.840.113549.2.5",Bu=`${Nt}.8`;function at(r){return new Y({algorithm:r,parameters:null})}at(qw);at(Hw);const ls=at(Nc);at(Qg);at(Bc);at(Rc);at(Pc);at(Uw);at(Lw);const e0=new Y({algorithm:Bu,parameters:L.serialize(ls)}),t0=new Y({algorithm:Zw,parameters:L.serialize(lc.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(us);at(Dw);at(Mw);at(Cc);at(Yg);at(Xg);at(jc);at(Tc);at(Yg);at(Xg);class Ru{constructor(e={}){this.hashAlgorithm=new Y(ls),this.maskGenAlgorithm=new Y({algorithm:Bu,parameters:L.serialize(ls)}),this.pSourceAlgorithm=new Y(t0),Object.assign(this,e)}}d([h({type:Y,context:0,defaultValue:ls})],Ru.prototype,"hashAlgorithm",void 0);d([h({type:Y,context:1,defaultValue:e0})],Ru.prototype,"maskGenAlgorithm",void 0);d([h({type:Y,context:2,defaultValue:t0})],Ru.prototype,"pSourceAlgorithm",void 0);new Y({algorithm:$w,parameters:L.serialize(new Ru)});class ds{constructor(e={}){this.hashAlgorithm=new Y(ls),this.maskGenAlgorithm=new Y({algorithm:Bu,parameters:L.serialize(ls)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([h({type:Y,context:0,defaultValue:ls})],ds.prototype,"hashAlgorithm",void 0);d([h({type:Y,context:1,defaultValue:e0})],ds.prototype,"maskGenAlgorithm",void 0);d([h({type:v.Integer,context:2,defaultValue:20})],ds.prototype,"saltLength",void 0);d([h({type:v.Integer,context:3,defaultValue:1})],ds.prototype,"trailerField",void 0);new Y({algorithm:Vi,parameters:L.serialize(new ds)});class Pu{constructor(e={}){this.digestAlgorithm=new Y,this.digest=new Ze,Object.assign(this,e)}}d([h({type:Y})],Pu.prototype,"digestAlgorithm",void 0);d([h({type:Ze})],Pu.prototype,"digest",void 0);var kd;class $u{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.Integer,converter:We})],$u.prototype,"prime",void 0);d([h({type:v.Integer,converter:We})],$u.prototype,"exponent",void 0);d([h({type:v.Integer,converter:We})],$u.prototype,"coefficient",void 0);let Sd=kd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,kd.prototype)}};Sd=kd=d([$({type:B.Sequence,itemType:$u})],Sd);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)}}d([h({type:v.Integer})],Nr.prototype,"version",void 0);d([h({type:v.Integer,converter:We})],Nr.prototype,"modulus",void 0);d([h({type:v.Integer,converter:We})],Nr.prototype,"publicExponent",void 0);d([h({type:v.Integer,converter:We})],Nr.prototype,"privateExponent",void 0);d([h({type:v.Integer,converter:We})],Nr.prototype,"prime1",void 0);d([h({type:v.Integer,converter:We})],Nr.prototype,"prime2",void 0);d([h({type:v.Integer,converter:We})],Nr.prototype,"exponent1",void 0);d([h({type:v.Integer,converter:We})],Nr.prototype,"exponent2",void 0);d([h({type:v.Integer,converter:We})],Nr.prototype,"coefficient",void 0);d([h({type:Sd,optional:!0})],Nr.prototype,"otherPrimeInfos",void 0);class zf{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.Integer,converter:We})],zf.prototype,"modulus",void 0);d([h({type:v.Integer,converter:We})],zf.prototype,"publicExponent",void 0);var Ad;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Ad||(Ad={}));const At=Ad;/*! *****************************************************************************
|
|
76
76
|
Copyright (c) Microsoft Corporation.
|
|
77
77
|
|
|
78
78
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -85,9 +85,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
85
85
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
86
86
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
87
87
|
PERFORMANCE OF THIS SOFTWARE.
|
|
88
|
-
***************************************************************************** */var
|
|
88
|
+
***************************************************************************** */var Od=function(r,e){return Od=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])},Od(r,e)};function Gf(r,e){Od(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Fw(r,e,t,n){function s(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function o(f){try{u(n.next(f))}catch(m){a(m)}}function c(f){try{u(n.throw(f))}catch(m){a(m)}}function u(f){f.done?i(f.value):s(f.value).then(o,c)}u((n=n.apply(r,[])).next())})}function Ww(r,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,s,i,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(u){return function(f){return c([u,f])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,s&&(i=u[0]&2?s.return:u[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,u[1])).done)return i;switch(s=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,s=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1],i=u;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(u);break}i[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(f){u=[6,f],s=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function 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 $c(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 Dn(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat($c(arguments[e]));return r}var Kw="injectionTokens";function zw(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(Kw,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function r0(r){return!!r.useClass}function Ed(r){return!!r.useFactory}var n0=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,Dn(i))}};return this.reflectMethods.forEach(n),t},r}();function ws(r){return typeof r=="string"||typeof r=="symbol"}function Gw(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function Qh(r){return typeof r=="object"&&"token"in r&&"transform"in r}function Jw(r){return typeof r=="function"||r instanceof n0}function No(r){return!!r.useToken}function Bo(r){return r.useValue!=null}function Yw(r){return r0(r)||Bo(r)||No(r)||Ed(r)}var Jf=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}(),Xw=function(r){Gf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Jf),ep=function(){function r(){this.scopedResolutions=new Map}return r}();function Qw(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function e1(r,e,t){return t===void 0&&(t=" "),Dn([r],e.message.split(`
|
|
89
89
|
`).map(function(n){return t+n})).join(`
|
|
90
|
-
`)}function e1(r,e,t){var n=Pc(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],i=s===void 0?null:s,a=Xw(i,e);return Qw("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function t1(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var r1=function(r){zf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Gf),n1=function(r){zf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Gf),s1=function(){function r(){this.preResolution=new r1,this.postResolution=new n1}return r}(),n0=new Map,i1=function(){function r(e){this.parent=e,this._registry=new Yw,this.interceptors=new s1,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:St.Transient}),this.ensureNotDisposed();var s;if(Jw(t)?s=t:s={useClass:t},To(s))for(var i=[e],a=s;a!=null;){var o=a.useToken;if(i.includes(o))throw new Error("Token registration cycle detected! "+Dn(i,[o]).join(" -> "));i.push(o);var c=this._registry.get(o);c&&To(c.provider)?a=c.provider:a=null}if((n.lifecycle===St.Singleton||n.lifecycle==St.ContainerScoped||n.lifecycle==St.ResolutionScoped)&&(No(s)||Od(s)))throw new Error('Cannot use lifecycle "'+St[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:s,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),ws(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),ws(e)){if(ws(t))return this.register(e,{useToken:t},{lifecycle:St.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:St.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!ws(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:St.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new Qh),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&ws(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var s=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(Gw(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=xo(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=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){s={error:f}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}this.interceptors.postResolution.setAll(e,a)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===St.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===St.Singleton,s=e.options.lifecycle===St.ContainerScoped,i=n||s,a;return No(e.provider)?a=e.provider.useValue:To(e.provider)?a=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):t0(e.provider)?a=i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Od(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,t),e.options.lifecycle===St.ResolutionScoped&&t.scopedResolutions.set(e,a),a},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new Qh),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&ws(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),s){var i=s.map(function(o){return n.resolveRegistration(o,t)});return this.executePostResolutionInterceptor(e,i,"All"),i}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=xo(this._registry.entries()),s=n.next();!s.done;s=n.next()){var i=Pc(s.value,2),a=i[0],o=i[1];this._registry.setAll(a,o.filter(function(c){return!No(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=xo(this._registry.entries()),i=s.next();!i.done;i=s.next()){var a=Pc(i.value,2),o=a[0],c=a[1];c.some(function(u){var f=u.options;return f.lifecycle===St.ContainerScoped})&&n._registry.setAll(o,c.map(function(u){return u.options.lifecycle===St.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 Hw(this,void 0,void 0,function(){var e;return Fw(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 r0)return e.createProxy(function(i){return n.resolve(i,t)});var s=function(){var i=n0.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,Dn([void 0],a)))}();return t1(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 zw(s)?Xh(s)?s.multiple?(a=n.resolve(s.transform)).transform.apply(a,Dn([n.resolveAll(s.token)],s.transformArgs)):(o=n.resolve(s.transform)).transform.apply(o,Dn([n.resolve(s.token,e)],s.transformArgs)):s.multiple?n.resolveAll(s.token):n.resolve(s.token,e):Xh(s)?(c=n.resolve(s.transform,e)).transform.apply(c,Dn([n.resolve(s.token,e)],s.transformArgs)):n.resolve(s,e)}catch(u){throw new Error(e1(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}(),ht=new i1;function $u(){return function(r){n0.set(r,Kw(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 Ed;class Zu{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}l([h({type:g.ObjectIdentifier})],Zu.prototype,"attrId",void 0);l([h({type:g.Any,repeated:"set"})],Zu.prototype,"attrValues",void 0);let ep=Ed=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Ed.prototype)}};ep=Ed=l([$({type:B.Sequence,itemType:Zu})],ep);var Id;let tp=Id=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Id.prototype)}};tp=Id=l([$({type:B.Sequence,itemType:hi})],tp);class s0{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],s0.prototype,"certId",void 0);l([h({type:g.Any,context:0})],s0.prototype,"certValue",void 0);class i0{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],i0.prototype,"crlId",void 0);l([h({type:g.Any,context:0})],i0.prototype,"crltValue",void 0);class a0 extends $e{}let Du=class{constructor(e={}){this.encryptionAlgorithm=new Y,this.encryptedData=new a0,Object.assign(this,e)}};l([h({type:Y})],Du.prototype,"encryptionAlgorithm",void 0);l([h({type:a0})],Du.prototype,"encryptedData",void 0);var Cd,jd;(function(r){r[r.v1=0]="v1"})(jd||(jd={}));class o0 extends $e{}let Td=Cd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Cd.prototype)}};Td=Cd=l([$({type:B.Sequence,itemType:Kr})],Td);class fo{constructor(e={}){this.version=jd.v1,this.privateKeyAlgorithm=new Y,this.privateKey=new o0,Object.assign(this,e)}}l([h({type:g.Integer})],fo.prototype,"version",void 0);l([h({type:Y})],fo.prototype,"privateKeyAlgorithm",void 0);l([h({type:o0})],fo.prototype,"privateKey",void 0);l([h({type:Td,implicit:!0,context:0,optional:!0})],fo.prototype,"attributes",void 0);let rp=class extends fo{};rp=l([$({type:B.Sequence})],rp);let np=class extends Du{};np=l([$({type:B.Sequence})],np);class c0{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],c0.prototype,"secretTypeId",void 0);l([h({type:g.Any,context:0})],c0.prototype,"secretValue",void 0);class ho{constructor(e={}){this.mac=new Ru,this.macSalt=new $e,this.iterations=1,Object.assign(this,e)}}l([h({type:Ru})],ho.prototype,"mac",void 0);l([h({type:$e})],ho.prototype,"macSalt",void 0);l([h({type:g.Integer,defaultValue:1})],ho.prototype,"iterations",void 0);class Mu{constructor(e={}){this.version=3,this.authSafe=new hi,this.macData=new ho,Object.assign(this,e)}}l([h({type:g.Integer})],Mu.prototype,"version",void 0);l([h({type:hi})],Mu.prototype,"authSafe",void 0);l([h({type:ho,optional:!0})],Mu.prototype,"macData",void 0);var Nd;class Vu{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:g.ObjectIdentifier})],Vu.prototype,"bagId",void 0);l([h({type:g.Any,context:0})],Vu.prototype,"bagValue",void 0);l([h({type:Zu,repeated:"set",optional:!0})],Vu.prototype,"bagAttributes",void 0);let sp=Nd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Nd.prototype)}};sp=Nd=l([$({type:B.Sequence,itemType:Vu})],sp);var Bd,Rd,Pd;const u0="1.2.840.113549.1.9",l0=`${u0}.7`,Jf=`${u0}.14`;let $c=class extends ft{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};l([h({type:g.IA5String})],$c.prototype,"ia5String",void 0);$c=l([$({type:B.Choice})],$c);let ip=class extends hi{};ip=l([$({type:B.Sequence})],ip);let ap=class extends Mu{};ap=l([$({type:B.Sequence})],ap);let op=class extends Du{};op=l([$({type:B.Sequence})],op);let $d=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:g.IA5String})],$d.prototype,"value",void 0);$d=l([$({type:B.Choice})],$d);let cp=class extends $c{};cp=l([$({type:B.Choice})],cp);let up=class extends ft{};up=l([$({type:B.Choice})],up);let Zd=class{constructor(e=new Date){this.value=e}};l([h({type:g.GeneralizedTime})],Zd.prototype,"value",void 0);Zd=l([$({type:B.Choice})],Zd);let lp=class extends ft{};lp=l([$({type:B.Choice})],lp);let Dd=class{constructor(e="M"){this.value=e}toString(){return this.value}};l([h({type:g.PrintableString})],Dd.prototype,"value",void 0);Dd=l([$({type:B.Choice})],Dd);let Zc=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:g.PrintableString})],Zc.prototype,"value",void 0);Zc=l([$({type:B.Choice})],Zc);let dp=class extends Zc{};dp=l([$({type:B.Choice})],dp);let fp=class extends ft{};fp=l([$({type:B.Choice})],fp);let Md=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:g.ObjectIdentifier})],Md.prototype,"value",void 0);Md=l([$({type:B.Choice})],Md);let hp=class extends lt{};hp=l([$({type:B.Choice})],hp);let Vd=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};l([h({type:g.Integer})],Vd.prototype,"value",void 0);Vd=l([$({type:B.Choice})],Vd);let pp=class extends Tr{};pp=l([$({type:B.Sequence})],pp);let Dc=class extends ft{};Dc=l([$({type:B.Choice})],Dc);let mp=Bd=class extends kn{constructor(e){super(e),Object.setPrototypeOf(this,Bd.prototype)}};mp=Bd=l([$({type:B.Sequence})],mp);let yp=Rd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Rd.prototype)}};yp=Rd=l([$({type:B.Set,itemType:fi})],yp);let Ud=class{constructor(e=""){this.value=e}toString(){return this.value}};l([h({type:g.BmpString})],Ud.prototype,"value",void 0);Ud=l([$({type:B.Choice})],Ud);let Ld=class extends Y{};Ld=l([$({type:B.Sequence})],Ld);let gp=Pd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Pd.prototype)}};gp=Pd=l([$({type:B.Sequence,itemType:Ld})],gp);var qd;let Mc=qd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,qd.prototype)}};Mc=qd=l([$({type:B.Sequence,itemType:Kr})],Mc);class yi{constructor(e={}){this.version=0,this.subject=new et,this.subjectPKInfo=new ir,this.attributes=new Mc,Object.assign(this,e)}}l([h({type:g.Integer})],yi.prototype,"version",void 0);l([h({type:et})],yi.prototype,"subject",void 0);l([h({type:ir})],yi.prototype,"subjectPKInfo",void 0);l([h({type:Mc,implicit:!0,context:0})],yi.prototype,"attributes",void 0);class Aa{constructor(e={}){this.certificationRequestInfo=new yi,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}l([h({type:yi})],Aa.prototype,"certificationRequestInfo",void 0);l([h({type:Y})],Aa.prototype,"signatureAlgorithm",void 0);l([h({type:g.BitString})],Aa.prototype,"signature",void 0);/*!
|
|
90
|
+
`)}function t1(r,e,t){var n=$c(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),s=n[1],i=s===void 0?null:s,a=Qw(i,e);return e1("Cannot inject the dependency "+a+' of "'+r.name+'" constructor. Reason:',t)}function r1(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var n1=function(r){Gf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Jf),s1=function(r){Gf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Jf),i1=function(){function r(){this.preResolution=new n1,this.postResolution=new s1}return r}(),s0=new Map,a1=function(){function r(e){this.parent=e,this._registry=new Xw,this.interceptors=new i1,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 s;if(Yw(t)?s=t:s={useClass:t},No(s))for(var i=[e],a=s;a!=null;){var o=a.useToken;if(i.includes(o))throw new Error("Token registration cycle detected! "+Dn(i,[o]).join(" -> "));i.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(s)||Ed(s)))throw new Error('Cannot use lifecycle "'+At[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:s,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),ws(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),ws(e)){if(ws(t))return this.register(e,{useToken:t},{lifecycle: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&&!ws(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:At.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new ep),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&ws(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var s=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,s,"Single"),s}if(Jw(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=xo(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=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){s={error:f}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}this.interceptors.postResolution.setAll(e,a)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===At.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===At.Singleton,s=e.options.lifecycle===At.ContainerScoped,i=n||s,a;return Bo(e.provider)?a=e.provider.useValue:No(e.provider)?a=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):r0(e.provider)?a=i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):Ed(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 ep),this.ensureNotDisposed();var s=this.getAllRegistrations(e);if(!s&&ws(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),s){var i=s.map(function(o){return n.resolveRegistration(o,t)});return this.executePostResolutionInterceptor(e,i,"All"),i}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=xo(this._registry.entries()),s=n.next();!s.done;s=n.next()){var i=$c(s.value,2),a=i[0],o=i[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{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=xo(this._registry.entries()),i=s.next();!i.done;i=s.next()){var a=$c(i.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{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 Fw(this,void 0,void 0,function(){var e;return Ww(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 n0)return e.createProxy(function(i){return n.resolve(i,t)});var s=function(){var i=s0.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,Dn([void 0],a)))}();return r1(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 Gw(s)?Qh(s)?s.multiple?(a=n.resolve(s.transform)).transform.apply(a,Dn([n.resolveAll(s.token)],s.transformArgs)):(o=n.resolve(s.transform)).transform.apply(o,Dn([n.resolve(s.token,e)],s.transformArgs)):s.multiple?n.resolveAll(s.token):n.resolve(s.token,e):Qh(s)?(c=n.resolve(s.transform,e)).transform.apply(c,Dn([n.resolve(s.token,e)],s.transformArgs)):n.resolve(s,e)}catch(u){throw new Error(t1(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}(),ht=new a1;function Zu(){return function(r){s0.set(r,zw(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 Id;class Du{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([h({type:v.ObjectIdentifier})],Du.prototype,"attrId",void 0);d([h({type:v.Any,repeated:"set"})],Du.prototype,"attrValues",void 0);let tp=Id=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Id.prototype)}};tp=Id=d([$({type:B.Sequence,itemType:Du})],tp);var Cd;let rp=Cd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Cd.prototype)}};rp=Cd=d([$({type:B.Sequence,itemType:hi})],rp);class i0{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],i0.prototype,"certId",void 0);d([h({type:v.Any,context:0})],i0.prototype,"certValue",void 0);class a0{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],a0.prototype,"crlId",void 0);d([h({type:v.Any,context:0})],a0.prototype,"crltValue",void 0);class o0 extends Ze{}let Mu=class{constructor(e={}){this.encryptionAlgorithm=new Y,this.encryptedData=new o0,Object.assign(this,e)}};d([h({type:Y})],Mu.prototype,"encryptionAlgorithm",void 0);d([h({type:o0})],Mu.prototype,"encryptedData",void 0);var jd,Td;(function(r){r[r.v1=0]="v1"})(Td||(Td={}));class c0 extends Ze{}let Nd=jd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,jd.prototype)}};Nd=jd=d([$({type:B.Sequence,itemType:Kr})],Nd);class fo{constructor(e={}){this.version=Td.v1,this.privateKeyAlgorithm=new Y,this.privateKey=new c0,Object.assign(this,e)}}d([h({type:v.Integer})],fo.prototype,"version",void 0);d([h({type:Y})],fo.prototype,"privateKeyAlgorithm",void 0);d([h({type:c0})],fo.prototype,"privateKey",void 0);d([h({type:Nd,implicit:!0,context:0,optional:!0})],fo.prototype,"attributes",void 0);let np=class extends fo{};np=d([$({type:B.Sequence})],np);let sp=class extends Mu{};sp=d([$({type:B.Sequence})],sp);class u0{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],u0.prototype,"secretTypeId",void 0);d([h({type:v.Any,context:0})],u0.prototype,"secretValue",void 0);class ho{constructor(e={}){this.mac=new Pu,this.macSalt=new Ze,this.iterations=1,Object.assign(this,e)}}d([h({type:Pu})],ho.prototype,"mac",void 0);d([h({type:Ze})],ho.prototype,"macSalt",void 0);d([h({type:v.Integer,defaultValue:1})],ho.prototype,"iterations",void 0);class Vu{constructor(e={}){this.version=3,this.authSafe=new hi,this.macData=new ho,Object.assign(this,e)}}d([h({type:v.Integer})],Vu.prototype,"version",void 0);d([h({type:hi})],Vu.prototype,"authSafe",void 0);d([h({type:ho,optional:!0})],Vu.prototype,"macData",void 0);var Bd;class Uu{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:v.ObjectIdentifier})],Uu.prototype,"bagId",void 0);d([h({type:v.Any,context:0})],Uu.prototype,"bagValue",void 0);d([h({type:Du,repeated:"set",optional:!0})],Uu.prototype,"bagAttributes",void 0);let ip=Bd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Bd.prototype)}};ip=Bd=d([$({type:B.Sequence,itemType:Uu})],ip);var Rd,Pd,$d;const l0="1.2.840.113549.1.9",d0=`${l0}.7`,Yf=`${l0}.14`;let Zc=class extends ft{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([h({type:v.IA5String})],Zc.prototype,"ia5String",void 0);Zc=d([$({type:B.Choice})],Zc);let ap=class extends hi{};ap=d([$({type:B.Sequence})],ap);let op=class extends Vu{};op=d([$({type:B.Sequence})],op);let cp=class extends Mu{};cp=d([$({type:B.Sequence})],cp);let Zd=class{constructor(e=""){this.value=e}toString(){return this.value}};d([h({type:v.IA5String})],Zd.prototype,"value",void 0);Zd=d([$({type:B.Choice})],Zd);let up=class extends Zc{};up=d([$({type:B.Choice})],up);let lp=class extends ft{};lp=d([$({type:B.Choice})],lp);let Dd=class{constructor(e=new Date){this.value=e}};d([h({type:v.GeneralizedTime})],Dd.prototype,"value",void 0);Dd=d([$({type:B.Choice})],Dd);let dp=class extends ft{};dp=d([$({type:B.Choice})],dp);let Md=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([h({type:v.PrintableString})],Md.prototype,"value",void 0);Md=d([$({type:B.Choice})],Md);let Dc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([h({type:v.PrintableString})],Dc.prototype,"value",void 0);Dc=d([$({type:B.Choice})],Dc);let fp=class extends Dc{};fp=d([$({type:B.Choice})],fp);let hp=class extends ft{};hp=d([$({type:B.Choice})],hp);let Vd=class{constructor(e=""){this.value=e}toString(){return this.value}};d([h({type:v.ObjectIdentifier})],Vd.prototype,"value",void 0);Vd=d([$({type:B.Choice})],Vd);let pp=class extends lt{};pp=d([$({type:B.Choice})],pp);let Ud=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};d([h({type:v.Integer})],Ud.prototype,"value",void 0);Ud=d([$({type:B.Choice})],Ud);let mp=class extends Tr{};mp=d([$({type:B.Sequence})],mp);let Mc=class extends ft{};Mc=d([$({type:B.Choice})],Mc);let yp=Rd=class extends kn{constructor(e){super(e),Object.setPrototypeOf(this,Rd.prototype)}};yp=Rd=d([$({type:B.Sequence})],yp);let gp=Pd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Pd.prototype)}};gp=Pd=d([$({type:B.Set,itemType:fi})],gp);let Ld=class{constructor(e=""){this.value=e}toString(){return this.value}};d([h({type:v.BmpString})],Ld.prototype,"value",void 0);Ld=d([$({type:B.Choice})],Ld);let qd=class extends Y{};qd=d([$({type:B.Sequence})],qd);let vp=$d=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,$d.prototype)}};vp=$d=d([$({type:B.Sequence,itemType:qd})],vp);var Hd;let Vc=Hd=class extends Ue{constructor(e){super(e),Object.setPrototypeOf(this,Hd.prototype)}};Vc=Hd=d([$({type:B.Sequence,itemType:Kr})],Vc);class yi{constructor(e={}){this.version=0,this.subject=new et,this.subjectPKInfo=new ir,this.attributes=new Vc,Object.assign(this,e)}}d([h({type:v.Integer})],yi.prototype,"version",void 0);d([h({type:et})],yi.prototype,"subject",void 0);d([h({type:ir})],yi.prototype,"subjectPKInfo",void 0);d([h({type:Vc,implicit:!0,context:0})],yi.prototype,"attributes",void 0);class Aa{constructor(e={}){this.certificationRequestInfo=new yi,this.signatureAlgorithm=new Y,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([h({type:yi})],Aa.prototype,"certificationRequestInfo",void 0);d([h({type:Y})],Aa.prototype,"signatureAlgorithm",void 0);d([h({type:v.BitString})],Aa.prototype,"signature",void 0);/*!
|
|
91
91
|
* MIT License
|
|
92
92
|
*
|
|
93
93
|
* Copyright (c) Peculiar Ventures. All rights reserved.
|
|
@@ -110,16 +110,16 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
110
110
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
111
111
|
* SOFTWARE.
|
|
112
112
|
*
|
|
113
|
-
*/const po="crypto.algorithm";class
|
|
114
|
-
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let s=this.pad(t++),i="";const a=e[Me.VALUE];a&&(i=` ${a}`),n.push(`${s}${e[Me.NAME]}:${i}`),s=this.pad(t);for(const o in e){if(typeof o=="symbol")continue;const c=e[o],u=o?`${o}: `:"";if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`${s}${u}${c}`);else if(c instanceof Date)n.push(`${s}${u}${c.toUTCString()}`);else if(Array.isArray(c))for(const f of c)f[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(`${s}${u}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){const f=c.toTextObject();f[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),s=q.toUint8Array(e),i=[];for(let a=0;a<s.length;){const o=[];for(let c=0;c<16&&a<s.length;c++){c===8&&o.push("");const u=s[a++].toString(16).padStart(2,"0");o.push(u)}i.push(`${n}${o.join(" ")}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}hs.oidSerializer=Nn;hs.algorithmSerializer=
|
|
115
|
-
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return L.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]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const
|
|
113
|
+
*/const po="crypto.algorithm";class o1{getAlgorithms(){return ht.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 s=n.toWebAlgorithm(e);if(s)return s}return{name:e.algorithm,parameters:e.parameters}}}const fs="crypto.algorithmProvider";ht.registerSingleton(fs,o1);var Ro;const Bt="1.3.36.3.3.2.8.1.1",bp=`${Bt}.1`,xp=`${Bt}.2`,_p=`${Bt}.3`,wp=`${Bt}.4`,kp=`${Bt}.5`,Sp=`${Bt}.6`,Ap=`${Bt}.7`,Op=`${Bt}.8`,Ep=`${Bt}.9`,Ip=`${Bt}.10`,Cp=`${Bt}.11`,jp=`${Bt}.12`,Tp=`${Bt}.13`,Np=`${Bt}.14`,Bp="brainpoolP160r1",Rp="brainpoolP160t1",Pp="brainpoolP192r1",$p="brainpoolP192t1",Zp="brainpoolP224r1",Dp="brainpoolP224t1",Mp="brainpoolP256r1",Vp="brainpoolP256t1",Up="brainpoolP320r1",Lp="brainpoolP320t1",qp="brainpoolP384r1",Hp="brainpoolP384t1",Fp="brainpoolP512r1",Wp="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 Tw;case"sha-256":return Nw;case"sha-384":return Bw;case"sha-512":return Rw}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=Jh;break;case"K-256":t=Ro.SECP256K1;break;case"P-384":t=Yh;break;case"P-521":t=Xh;break;case Bp:t=bp;break;case Rp:t=xp;break;case Pp:t=_p;break;case $p:t=wp;break;case Zp:t=kp;break;case Dp:t=Sp;break;case Mp:t=Ap;break;case Vp:t=Op;break;case Up:t=Ep;break;case Lp:t=Ip;break;case qp:t=Cp;break;case Hp:t=jp;break;case Fp:t=Tp;break;case Wp:t=Np;break}if(t)return new Y({algorithm:ka,parameters:L.serialize(new An({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Hf:return{name:ze,hash:{name:"SHA-1"}};case Ff:return{name:ze,hash:{name:"SHA-256"}};case Wf:return{name:ze,hash:{name:"SHA-384"}};case Kf: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 Jh:return{name:ze,namedCurve:"P-256"};case Ro.SECP256K1:return{name:ze,namedCurve:"K-256"};case Yh:return{name:ze,namedCurve:"P-384"};case Xh:return{name:ze,namedCurve:"P-521"};case bp:return{name:ze,namedCurve:Bp};case xp:return{name:ze,namedCurve:Rp};case _p:return{name:ze,namedCurve:Pp};case wp:return{name:ze,namedCurve:$p};case kp:return{name:ze,namedCurve:Zp};case Sp:return{name:ze,namedCurve:Dp};case Ap:return{name:ze,namedCurve:Mp};case Op:return{name:ze,namedCurve:Vp};case Ep:return{name:ze,namedCurve:Up};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:Wp}}}}return null}};Oa.SECP256K1="1.3.132.0.10";Oa=Ro=d([Zu()],Oa);ht.registerSingleton(po,Oa);const f0=Symbol("name"),h0=Symbol("value");class Me{constructor(e,t={},n=""){this[f0]=e,this[h0]=n;for(const s in t)this[s]=t[s]}}Me.NAME=f0;Me.VALUE=h0;class c1{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={[Nc]:"sha1",[Qg]:"sha224",[Bc]:"sha256",[Rc]:"sha384",[Pc]:"sha512",[us]:"rsaEncryption",[Cc]:"sha1WithRSAEncryption",[Vw]:"sha224WithRSAEncryption",[wd]:"sha256WithRSAEncryption",[jc]:"sha384WithRSAEncryption",[Tc]:"sha512WithRSAEncryption",[ka]:"ecPublicKey",[Hf]:"ecdsaWithSHA1",[Jg]:"ecdsaWithSHA224",[Ff]:"ecdsaWithSHA256",[Wf]:"ecdsaWithSHA384",[Kf]:"ecdsaWithSHA512",[Sw]:"TLS WWW server authentication",[Aw]:"TLS WWW client authentication",[Ow]:"Code Signing",[Ew]:"E-mail Protection",[Iw]:"Time Stamping",[Cw]:"OCSP Signing",[jw]:"Signed Data"};class hs{static serialize(e){return this.serializeObj(e).join(`
|
|
114
|
+
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let s=this.pad(t++),i="";const a=e[Me.VALUE];a&&(i=` ${a}`),n.push(`${s}${e[Me.NAME]}:${i}`),s=this.pad(t);for(const o in e){if(typeof o=="symbol")continue;const c=e[o],u=o?`${o}: `:"";if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`${s}${u}${c}`);else if(c instanceof Date)n.push(`${s}${u}${c.toUTCString()}`);else if(Array.isArray(c))for(const f of c)f[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(`${s}${u}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){const f=c.toTextObject();f[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),s=q.toUint8Array(e),i=[];for(let a=0;a<s.length;){const o=[];for(let c=0;c<16&&a<s.length;c++){c===8&&o.push("");const u=s[a++].toString(16).padStart(2,"0");o.push(u)}i.push(`${n}${o.join(" ")}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}hs.oidSerializer=Nn;hs.algorithmSerializer=c1;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?Ny(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return L.toString(this.rawData);case"text":return hs.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 Kt({extnID:e[0],critical:e[1],extnValue:new Ze(q.toArrayBuffer(e[2]))})),super(t,Kt)}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 p0;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[p0]="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}}p0=Symbol.toStringTag;hn.DEFAULT="default";const ut=new hn,u1=/^[0-2](?:\.[1-9][0-9]*)+$/;function l1(r){return new RegExp(u1).test(r)}class m0{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return l1(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const Tt=new m0;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 f1(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 m0,this.asn=new et;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const s=t[n];this.extraNames.register(n,s)}typeof e=="string"?this.asn=this.fromString(e):e instanceof et?this.asn=e:q.isBufferSource(e)?this.asn=L.parse(e,et):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||Tt.findId(e),n=[];for(const s of this.asn)for(const i of s)i.type===t&&n.push(i.value.toString());return n}getName(e){return this.extraNames.get(e)||Tt.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,s=t.value.anyValue?`#${te.ToHex(t.value.anyValue)}`:f1(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?`#${te.ToHex(i.value.anyValue)}`:i.value.toString())}t.push(s)}return t}fromString(e){const t=new et,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let s=null,i=",";for(;s=n.exec(`${e},`);){let[,a,o]=s;const c=o[o.length-1];(c===","||c==="+")&&(o=o.slice(0,o.length-1),s[3]=c);const u=s[3];a=this.getTypeOid(a);const f=this.createAttribute(a,o);i==="+"?t[t.length-1].push(f):t.push(new Gs([f])),i=u}return t}fromJSON(e){const t=new et;for(const n of e){const s=new Gs;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 gu({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=te.FromHex(t.slice(1));else{const s=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=s:Ht.isPrintableString(s)?n.value.printableString=s:n.value.utf8String=s}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
|
|
115
|
+
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return L.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]||ut.get()):n=e[0]||ut.get(),await n.subtle.digest(s,this.toArrayBuffer())}}const y0="Cannot initialize GeneralName from ASN.1 data.",Kp=`${y0} Unsupported string format in use.`,h1=`${y0} Value doesn't match to GUID regular expression.`,zp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Gp="1.3.6.1.4.1.311.25.1",Jp="1.3.6.1.4.1.311.20.2.3",tl="dns",rl="dn",nl="email",sl="ip",il="url",al="guid",ol="upn",_o="id";class pn extends Bn{constructor(...e){let t;if(e.length===2)switch(e[0]){case rl:{const n=new Ht(e[1]).toArrayBuffer(),s=L.parse(n,et);t=new ve({directoryName:s});break}case tl:t=new ve({dNSName:e[1]});break;case nl:t=new ve({rfc822Name:e[1]});break;case al:{const n=new RegExp(zp,"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?te.ToHex(new Uint8Array(te.FromHex(i)).reverse()):i).join("");t=new ve({otherName:new ba({typeId:Gp,value:L.serialize(new Ze(te.FromHex(s)))})});break}case sl:t=new ve({iPAddress:e[1]});break;case _o:t=new ve({registeredID:e[1]});break;case ol:{t=new ve({otherName:new ba({typeId:Jp,value:L.serialize(Ng.toASN(e[1]))})});break}case il:t=new ve({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],ve):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=tl,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=nl,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=sl,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=il,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=_o,this.value=e.registeredID;else if(e.directoryName!=null)this.type=rl,this.value=new Ht(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Gp){this.type=al;const t=L.parse(e.otherName.value,Ze),n=new RegExp(zp,"i").exec(te.ToHex(t));if(!n)throw new Error(h1);this.value=n.slice(1).map((s,i)=>i<3?te.ToHex(new Uint8Array(te.FromHex(s)).reverse()):s).join("-")}else if(e.otherName.typeId===Jp)this.type=ol,this.value=L.parse(e.otherName.value,ft).toString();else throw new Error(Kp);else throw new Error(Kp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case rl:case tl:case al:case sl:case _o:case ol:case il:e=this.type.toUpperCase();break;case nl: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 bt)t=e;else if(Array.isArray(e)){const n=[];for(const s of e)if(s instanceof ve)n.push(s);else{const i=L.parse(new pn(s.type,s.value).rawData,ve);n.push(i)}t=new bt(n)}else if(q.isBufferSource(e))t=L.parse(e,bt);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 pn(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[Me.NAME]];Array.isArray(s)||(s=[],e[n[Me.NAME]]=s),s.push(n)}return e}}Ea.NAME="GeneralNames";const Ui="-{5}",Ia="\\n",p1=`[^${Ia}]+`,m1=`${Ui}BEGIN (${p1}(?=${Ui}))${Ui}`,y1=`${Ui}END \\1${Ui}`,ni="\\n",g1=`[^:${Ia}]+`,v1=`(?:[^${Ia}]+${ni}(?: +[^${Ia}]+${ni})*)`,b1="[a-zA-Z0-9=+/]+",x1=`(?:${b1}${ni})+`,Yp=`${m1}${ni}(?:((?:${g1}: ${v1})+))?${ni}?(${x1})${y1}`;class $t{static isPem(e){return typeof e=="string"&&new RegExp(Yp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Yp,"g"),n=[];let s=null;for(;s=t.exec(e);){const i=s[3].replace(new RegExp(`[${Ia}]+`,"g"),""),a={type:s[1],headers:[],rawData:te.FromBase64(i)},o=s[2];if(o){const c=o.split(new RegExp(ni,"g"));let u=null;for(const f of c){const[m,R]=f.split(/:(.*)/);if(R===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: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(!q.isBufferSource(s))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:q.toArrayBuffer(s)}))}):e.forEach(s=>{if(!("type"in s))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(s))}),n.join(`
|
|
116
116
|
`)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:q.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),s=[];if(s.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const u of e.headers)s.push(`${u.key}: ${u.value}`);s.push("")}const i=te.ToBase64(e.rawData);let a,o=0;const c=Array();for(;o<i.length&&(i.length-o<64?a=i.substring(o):(a=i.substring(o,o+64),o+=64),a.length!==0);)if(c.push(a),a.length<64)break;return s.push(...c),s.push(`-----END ${n}-----`),s.join(`
|
|
117
|
-
`)}}$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,ir):super(e),this.tag=$t.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]||ut.get()):t=e[0]||ut.get();let i=this.rawData;const a=L.parse(this.rawData,ir);return a.algorithm.algorithm===Vi&&(i=x1(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=ht.resolve(fs),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case us:{const s=L.parse(e.subjectPublicKey,Kf),i=q.toUint8Array(s.modulus);n.publicExponent=q.toUint8Array(s.publicExponent),n.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||ut.get()):n=e[0]||ut.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=ut.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=ut.get();const s=L.parse(this.rawData,ir);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,ir);switch(e.Algorithm=hs.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case ka:e["EC Point"]=t.subjectPublicKey;break;case us:default:e["Raw Data"]=t.subjectPublicKey}return e}}function x1(r,e){return r.algorithm=new Y({algorithm:us,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 i=await(await ur.create(e,n)).getKeyIdentifier(n);return new Ca(te.ToHex(i),t)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Ln({keyIdentifier:new If(te.FromHex(e[0]))});super(Ml,e[1],L.serialize(t))}else{const t=e[0],n=t.name instanceof Ea?L.parse(t.name.rawData,bt):t.name,s=new Ln({authorityCertIssuer:n,authorityCertSerialNumber:te.FromHex(t.serialNumber)});super(Ml,e[1],L.serialize(s))}}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 Yf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,lc);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new lc({cA:e[0],pathLenConstraint:e[1]});super(Rg,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}}Yf.NAME="Basic Constraints";var Yp;(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"})(Yp||(Yp={}));class Xf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,pc);this.usages=t.map(n=>n)}else{const t=new pc(e[0]);super(Zg,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}}Xf.NAME="Extended Key Usages";var Vc;(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"})(Vc||(Vc={}));class Qf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,Qu);this.usages=t.toNumber()}else{const t=new Qu(e[0]);super(Dg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,Qu);return e[""]=t.toJSON().join(", "),e}}Qf.NAME="Key Usages";class mo extends Gt{static async create(e,t=!1,n=ut.get()){const i=await(await ur.create(e,n)).getKeyIdentifier(n);return new mo(te.ToHex(i),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(Lg,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 y0 extends Gt{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(Ug,e[1],new Ea(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,ed);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}}y0.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 g0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0])){super(e[0]);const n=L.parse(this.value,fc);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new fc(n.map(a=>new vu({policyIdentifier:a})));super(Pg,s,L.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Me("",{},Nn.toString(t))),e}}g0.NAME="Certificate Policies";Jt.register(Pg,g0);class v0 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 s=e[0].map(a=>new li({distributionPoint:new is({fullName:[new ge({uniformResourceIdentifier:a})]})})),i=new Rs(s);super(Hl,e[1],L.serialize(i))}else{const n=new Rs(e[0]);super(Hl,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,Rs);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 pn(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}v0.NAME="CRL Distribution Points";class b0 extends Gt{constructor(...e){var t,n,s,i;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Is){const a=new Is(e[0]);super(Dl,e[1],L.serialize(a))}else{const a=e[0],o=new Is;ko(o,a,Rh,"ocsp"),ko(o,a,Ph,"caIssuers"),ko(o,a,$h,"timeStamping"),ko(o,a,Zh,"caRepository"),super(Dl,e[1],L.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=[],L.parse(e.extnValue,Is).forEach(n=>{switch(n.accessMethod){case Rh:this.ocsp.push(new pn(n.accessLocation));break;case Ph:this.caIssuers.push(new pn(n.accessLocation));break;case $h:this.timeStamping.push(new pn(n.accessLocation));break;case Zh: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}}b0.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((s,i)=>{const a=s.toTextObject(),o=`${a[Me.NAME]} ${i+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 s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new pn("url",a)),r.push(new to({accessMethod:t,accessLocation:L.parse(a.rawData,ge)}))})}class gi extends Bn{constructor(...e){let t;if(q.isBufferSource(e[0]))t=q.toArrayBuffer(e[0]);else{const n=e[0],s=Array.isArray(e[1])?e[1].map(i=>q.toArrayBuffer(i)):[];t=L.serialize(new Kr({type:n,values:s}))}super(t,Kr)}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]===gi.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}gi.NAME="Attribute";class x0 extends gi{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=new Dc({printableString:e[0]});super(l0,[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],Dc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Me.VALUE]=this.password,e}}x0.NAME="Challenge Password";class eh extends gi{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new kn;for(const i of n)s.push(L.parse(i.rawData,Kt));super(Jf,[L.serialize(s)])}(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}}eh.NAME="Extensions";class Uu{static register(e,t){this.items.set(e,t)}static create(e){const t=new gi(e),n=this.items.get(t.type);return n?new n(e):t}}Uu.items=new Map;const yo="crypto.signatureFormatter";class _1{toAsnSignature(e,t){return q.toArrayBuffer(t)}toWebSignature(e,t){return q.toArrayBuffer(t)}}var Ro;let Hd=Ro=class{static createPssParams(e,t){const n=Ro.getHashAlgorithm(e);return n?new ds({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:Nu,parameters:L.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=ht.resolve(fs);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new Y({algorithm:Ic,parameters:null});case"sha-256":return new Y({algorithm:_d,parameters:null});case"sha-384":return new Y({algorithm:Cc,parameters:null});case"sha-512":return new Y({algorithm:jc,parameters:null})}}else return new Y({algorithm:us,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=Ro.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new Y({algorithm:Vi,parameters:L.serialize(t)})}else return new Y({algorithm:Vi,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case us:return{name:"RSASSA-PKCS1-v1_5"};case Ic:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case _d:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Cc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case jc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Vi:if(e.parameters){const t=L.parse(e.parameters,ds);return{name:"RSA-PSS",hash:ht.resolve(fs).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Hd=Ro=l([$u()],Hd);ht.registerSingleton(po,Hd);let Fd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:Tc});case"sha-256":return new Y({algorithm:Nc});case"sha-384":return new Y({algorithm:Bc});case"sha-512":return new Y({algorithm:Rc})}return null}toWebAlgorithm(e){switch(e.algorithm){case Tc:return{name:"SHA-1"};case Nc:return{name:"SHA-256"};case Bc:return{name:"SHA-384"};case Rc:return{name:"SHA-512"}}return null}};Fd=l([$u()],Fd);ht.registerSingleton(po,Fd);class Ft{addPadding(e,t){const n=q.toUint8Array(t),s=new Uint8Array(e);return s.set(n,e-n.length),s}removePadding(e,t=!1){let n=q.toUint8Array(e);for(let s=0;s<n.length;s++)if(n[s]){n=n.slice(s);break}if(t&&n[0]>127){const s=new Uint8Array(n.length+1);return s.set(n,1),s.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,s=Ft.namedCurveSize.get(n)||Ft.defaultNamedCurveSize,i=new Ec,a=q.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),L.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=L.parse(t,Ec),s=e.namedCurve,i=Ft.namedCurveSize.get(s)||Ft.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return R_(a,o)}return null}}Ft.namedCurveSize=new Map;Ft.defaultNamedCurveSize=32;const ol="1.3.101.110",Xp="1.3.101.111",cl="1.3.101.112",Qp="1.3.101.113";let Wd=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=cl;break;case"x25519":t=ol;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=cl;break;case"ed448":t=Qp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=ol;break;case"x448":t=Xp;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case cl:return{name:"Ed25519"};case Qp:return{name:"EdDSA",namedCurve:"Ed448"};case ol:return{name:"X25519"};case Xp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Wd=l([$u()],Wd);ht.registerSingleton(po,Wd);class w1 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=ht.resolve(fs);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>Uu.create(L.serialize(s)));const n=this.getAttribute(Jf);this.extensions=[],n instanceof eh&&(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),s=ht.resolveAll(yo).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=L.parse(this.rawData,Aa),n=t.certificationRequestInfo,s=new Me("",{Version:`${as[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new Me("");for(const a of this.attributes){const o=a.toTextObject();i[o[Me.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new Me("",{Algorithm:hs.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}w1.NAME="PKCS#10 Certificate Request";class th extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,os):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=ht.resolve(fs);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=>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,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 ur)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(q.isBufferSource(i)){const u=new ur(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=ht.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,s,o,this.tbs);if(e.signatureOnly)return c;{const f=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<f&&f<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=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,os),n=t.tbsCertificate,s=new Me("",{Version:`${as[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":hs.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&&(s["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(s["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const i=new Me("");for(const a of this.extensions){const o=a.toTextObject();i[o[Me.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new Me("",{Algorithm:hs.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}th.NAME="Certificate";class k1{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 s;e.publicKey instanceof ur?s=e.publicKey.rawData:"publicKey"in e.publicKey?s=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?s=e.publicKey:s=await t.subtle.exportKey("spki",e.publicKey);const i=e.serialNumber?q.toUint8Array(te.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 os({tbsCertificate:new Vt({version:as.v3,serialNumber:i,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,Kt)))||[]),subjectPublicKeyInfo:L.parse(s,ir)})});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=ht.resolve(fs);c.tbsCertificate.signature=c.signatureAlgorithm=m.toAsnAlgorithm(f);const R=L.serialize(c.tbsCertificate),C="signingKey"in e?await t.subtle.sign(f,e.signingKey,R):e.signature,p=ht.resolveAll(yo).reverse();let y=null;for(const A of p)if(y=A.toAsnSignature(f,C),y)break;if(!y)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=y,new th(L.serialize(c))}}var em;(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"})(em||(em={}));Jt.register(Rg,Yf);Jt.register(Zg,Xf);Jt.register(Dg,Qf);Jt.register(Lg,mo);Jt.register(Ml,Ca);Jt.register(Ug,y0);Jt.register(Hl,v0);Jt.register(Dl,b0);Uu.register(l0,x0);Uu.register(Jf,eh);ht.registerSingleton(yo,_1);ht.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 So=60*5;function S1(){return new jt().openapi(ke({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:xy}},description:"List of tenants"}}}),async e=>{const t=await e.env.data.keys.list(),n=await Promise.all(t.map(async s=>{const a=await new th(s.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",a);return uf.parse({...o,kid:s.kid})}));return e.json({keys:n},{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(ke({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Il}},description:"List of tenants"}}}),async e=>{const t=e.env.ISSUER,n=Il.parse({issuer:t,authorization_endpoint:`${t}authorize`,token_endpoint:`${t}oauth/token`,device_authorization_endpoint:`${t}oauth/device/code`,userinfo_endpoint:`${t}userinfo`,mfa_challenge_endpoint:`${t}mfa/challenge`,jwks_uri:`${t}.well-known/jwks.json`,registration_endpoint:`${t}oidc/register`,revocation_endpoint:`${t}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return e.json(n,{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`}})})}async function _0(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function A1({userAdapter:r,tenant_id:e,email:t}){var o;const{users:n}=await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),s=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(s.length===0)return;const i=s.filter(c=>!c.linked_to);if(i.length>0)return i.length>1&&console.error("More than one primary user found for same email"),i[0];const a=await r.get(e,(o=s[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}function O1(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await A1({userAdapter:r.users,tenant_id:e,email:t.email});return n?(await r.users.create(e,{...t,linked_to:n.user_id}),n):r.users.create(e,t)}}function w0(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}async function E1(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=w0(r,{type:Xc.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,i)}}function I1(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 E1(r,s,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function C1(r,e){return async(t,n)=>{let s=await O1(e)(t,n);return await I1(r,e)(t,s),s}}function j1(r,e){return{...e,users:{...e.users,create:C1(r,e)}}}const T1=new jt().openapi(ke({tags:["branding"],method:"get",path:"/",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:El}},description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=await r.env.data.branding.get(e);return t?r.json(t):r.json({})}).openapi(ke({tags:["branding"],method:"patch",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(El.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});function N1(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 k0={exports:{}};const B1={},R1=Object.freeze(Object.defineProperty({__proto__:null,default:B1},Symbol.toStringTag,{value:"Module"})),P1=C_(R1);(function(r){/**
|
|
117
|
+
`)}}$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,ir):super(e),this.tag=$t.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]||ut.get()):t=e[0]||ut.get();let i=this.rawData;const a=L.parse(this.rawData,ir);return a.algorithm.algorithm===Vi&&(i=_1(a,i)),t.subtle.importKey("spki",i,s,!0,n)}onInit(e){const t=ht.resolve(fs),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case us:{const s=L.parse(e.subjectPublicKey,zf),i=q.toUint8Array(s.modulus);n.publicExponent=q.toUint8Array(s.publicExponent),n.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,s="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(s=e[0]||s,n=e[1]||ut.get()):n=e[0]||ut.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=ut.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=ut.get();const s=L.parse(this.rawData,ir);return await t.subtle.digest(n,s.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=L.parse(this.rawData,ir);switch(e.Algorithm=hs.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case ka:e["EC Point"]=t.subjectPublicKey;break;case us:default:e["Raw Data"]=t.subjectPublicKey}return e}}function _1(r,e){return r.algorithm=new Y({algorithm:us,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 i=await(await ur.create(e,n)).getKeyIdentifier(n);return new Ca(te.ToHex(i),t)}constructor(...e){if(q.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new Ln({keyIdentifier:new Cf(te.FromHex(e[0]))});super(Vl,e[1],L.serialize(t))}else{const t=e[0],n=t.name instanceof Ea?L.parse(t.name.rawData,bt):t.name,s=new Ln({authorityCertIssuer:n,authorityCertSerialNumber:te.FromHex(t.serialNumber)});super(Vl,e[1],L.serialize(s))}}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 Xf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,dc);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new dc({cA:e[0],pathLenConstraint:e[1]});super(Pg,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}}Xf.NAME="Basic Constraints";var Xp;(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"})(Xp||(Xp={}));class Qf extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,mc);this.usages=t.map(n=>n)}else{const t=new mc(e[0]);super(Dg,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}}Qf.NAME="Extended Key Usages";var Uc;(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"})(Uc||(Uc={}));class eh extends Gt{constructor(...e){if(q.isBufferSource(e[0])){super(e[0]);const t=L.parse(this.value,el);this.usages=t.toNumber()}else{const t=new el(e[0]);super(Mg,e[1],L.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=L.parse(this.value,el);return e[""]=t.toJSON().join(", "),e}}eh.NAME="Key Usages";class mo extends Gt{static async create(e,t=!1,n=ut.get()){const i=await(await ur.create(e,n)).getKeyIdentifier(n);return new mo(te.ToHex(i),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(qg,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 g0 extends Gt{constructor(...e){q.isBufferSource(e[0])?super(e[0]):super(Lg,e[1],new Ea(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=L.parse(e.extnValue,td);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}}g0.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 v0 extends Gt{constructor(...e){var t;if(q.isBufferSource(e[0])){super(e[0]);const n=L.parse(this.value,hc);this.policies=n.map(s=>s.policyIdentifier)}else{const n=e[0],s=(t=e[1])!==null&&t!==void 0?t:!1,i=new hc(n.map(a=>new bu({policyIdentifier:a})));super($g,s,L.serialize(i)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Me("",{},Nn.toString(t))),e}}v0.NAME="Certificate Policies";Jt.register($g,v0);class b0 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 s=e[0].map(a=>new li({distributionPoint:new is({fullName:[new ve({uniformResourceIdentifier:a})]})})),i=new Rs(s);super(Fl,e[1],L.serialize(i))}else{const n=new Rs(e[0]);super(Fl,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,Rs);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 pn(i).toString()).join(", ")),t.reasons&&(s.Reasons=t.reasons.toString()),t.cRLIssuer&&(s["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),s}),e}}b0.NAME="CRL Distribution Points";class x0 extends Gt{constructor(...e){var t,n,s,i;if(q.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Is){const a=new Is(e[0]);super(Ml,e[1],L.serialize(a))}else{const a=e[0],o=new Is;ko(o,a,Ph,"ocsp"),ko(o,a,$h,"caIssuers"),ko(o,a,Zh,"timeStamping"),ko(o,a,Dh,"caRepository"),super(Ml,e[1],L.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=[],L.parse(e.extnValue,Is).forEach(n=>{switch(n.accessMethod){case Ph:this.ocsp.push(new pn(n.accessLocation));break;case $h:this.caIssuers.push(new pn(n.accessLocation));break;case Zh:this.timeStamping.push(new pn(n.accessLocation));break;case Dh: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}}x0.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((s,i)=>{const a=s.toTextObject(),o=`${a[Me.NAME]} ${i+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 s=e[n];s&&(Array.isArray(s)?s:[s]).forEach(a=>{typeof a=="string"&&(a=new pn("url",a)),r.push(new to({accessMethod:t,accessLocation:L.parse(a.rawData,ve)}))})}class gi extends Bn{constructor(...e){let t;if(q.isBufferSource(e[0]))t=q.toArrayBuffer(e[0]);else{const n=e[0],s=Array.isArray(e[1])?e[1].map(i=>q.toArrayBuffer(i)):[];t=L.serialize(new Kr({type:n,values:s}))}super(t,Kr)}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]===gi.NAME&&(e[Me.NAME]=Nn.toString(this.type)),e}}gi.NAME="Attribute";class _0 extends gi{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=new Mc({printableString:e[0]});super(d0,[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],Mc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[Me.VALUE]=this.password,e}}_0.NAME="Challenge Password";class th extends gi{constructor(...e){var t;if(q.isBufferSource(e[0]))super(e[0]);else{const n=e[0],s=new kn;for(const i of n)s.push(L.parse(i.rawData,Kt));super(Yf,[L.serialize(s)])}(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}}th.NAME="Extensions";class Lu{static register(e,t){this.items.set(e,t)}static create(e){const t=new gi(e),n=this.items.get(t.type);return n?new n(e):t}}Lu.items=new Map;const yo="crypto.signatureFormatter";class w1{toAsnSignature(e,t){return q.toArrayBuffer(t)}toWebSignature(e,t){return q.toArrayBuffer(t)}}var Po;let Fd=Po=class{static createPssParams(e,t){const n=Po.getHashAlgorithm(e);return n?new ds({hashAlgorithm:n,maskGenAlgorithm:new Y({algorithm:Bu,parameters:L.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=ht.resolve(fs);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:Cc,parameters:null});case"sha-256":return new Y({algorithm:wd,parameters:null});case"sha-384":return new Y({algorithm:jc,parameters:null});case"sha-512":return new Y({algorithm:Tc,parameters:null})}}else return new Y({algorithm:us,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:Vi,parameters:L.serialize(t)})}else return new Y({algorithm:Vi,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case us:return{name:"RSASSA-PKCS1-v1_5"};case Cc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case wd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case jc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Tc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Vi:if(e.parameters){const t=L.parse(e.parameters,ds);return{name:"RSA-PSS",hash:ht.resolve(fs).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Fd=Po=d([Zu()],Fd);ht.registerSingleton(po,Fd);let Wd=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new Y({algorithm:Nc});case"sha-256":return new Y({algorithm:Bc});case"sha-384":return new Y({algorithm:Rc});case"sha-512":return new Y({algorithm:Pc})}return null}toWebAlgorithm(e){switch(e.algorithm){case Nc:return{name:"SHA-1"};case Bc:return{name:"SHA-256"};case Rc:return{name:"SHA-384"};case Pc:return{name:"SHA-512"}}return null}};Wd=d([Zu()],Wd);ht.registerSingleton(po,Wd);class Ft{addPadding(e,t){const n=q.toUint8Array(t),s=new Uint8Array(e);return s.set(n,e-n.length),s}removePadding(e,t=!1){let n=q.toUint8Array(e);for(let s=0;s<n.length;s++)if(n[s]){n=n.slice(s);break}if(t&&n[0]>127){const s=new Uint8Array(n.length+1);return s.set(n,1),s.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,s=Ft.namedCurveSize.get(n)||Ft.defaultNamedCurveSize,i=new Ic,a=q.toUint8Array(t);return i.r=this.removePadding(a.slice(0,s),!0),i.s=this.removePadding(a.slice(s,s+s),!0),L.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=L.parse(t,Ic),s=e.namedCurve,i=Ft.namedCurveSize.get(s)||Ft.defaultNamedCurveSize,a=this.addPadding(i,this.removePadding(n.r)),o=this.addPadding(i,this.removePadding(n.s));return P_(a,o)}return null}}Ft.namedCurveSize=new Map;Ft.defaultNamedCurveSize=32;const cl="1.3.101.110",Qp="1.3.101.111",ul="1.3.101.112",em="1.3.101.113";let Kd=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=ul;break;case"x25519":t=cl;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=ul;break;case"ed448":t=em;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=cl;break;case"x448":t=Qp;break}}return t?new Y({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case ul:return{name:"Ed25519"};case em:return{name:"EdDSA",namedCurve:"Ed448"};case cl:return{name:"X25519"};case Qp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Kd=d([Zu()],Kd);ht.registerSingleton(po,Kd);class k1 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=ht.resolve(fs);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(s=>Lu.create(L.serialize(s)));const n=this.getAttribute(Yf);this.extensions=[],n instanceof th&&(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),s=ht.resolveAll(yo).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=L.parse(this.rawData,Aa),n=t.certificationRequestInfo,s=new Me("",{Version:`${as[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const i=new Me("");for(const a of this.attributes){const o=a.toTextObject();i[o[Me.NAME]]=o}s.Attributes=i}return e.Data=s,e.Signature=new Me("",{Algorithm:hs.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}k1.NAME="PKCS#10 Certificate Request";class rh extends Jr{constructor(e){Jr.isAsnEncoded(e)?super(e,os):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=ht.resolve(fs);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=>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,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 ur)n={...i.algorithm,...this.signatureAlgorithm},s=await i.export(n,["verify"],t);else if(q.isBufferSource(i)){const u=new ur(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=ht.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,s,o,this.tbs);if(e.signatureOnly)return c;{const f=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<f&&f<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=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,os),n=t.tbsCertificate,s=new Me("",{Version:`${as[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":hs.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&&(s["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(s["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const i=new Me("");for(const a of this.extensions){const o=a.toTextObject();i[o[Me.NAME]]=o}s.Extensions=i}return e.Data=s,e.Signature=new Me("",{Algorithm:hs.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}rh.NAME="Certificate";class S1{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 s;e.publicKey instanceof ur?s=e.publicKey.rawData:"publicKey"in e.publicKey?s=e.publicKey.publicKey.rawData:q.isBufferSource(e.publicKey)?s=e.publicKey:s=await t.subtle.exportKey("spki",e.publicKey);const i=e.serialNumber?q.toUint8Array(te.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 os({tbsCertificate:new Vt({version:as.v3,serialNumber:i,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,Kt)))||[]),subjectPublicKeyInfo:L.parse(s,ir)})});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=ht.resolve(fs);c.tbsCertificate.signature=c.signatureAlgorithm=m.toAsnAlgorithm(f);const R=L.serialize(c.tbsCertificate),C="signingKey"in e?await t.subtle.sign(f,e.signingKey,R):e.signature,p=ht.resolveAll(yo).reverse();let y=null;for(const A of p)if(y=A.toAsnSignature(f,C),y)break;if(!y)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=y,new rh(L.serialize(c))}}var tm;(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"})(tm||(tm={}));Jt.register(Pg,Xf);Jt.register(Dg,Qf);Jt.register(Mg,eh);Jt.register(qg,mo);Jt.register(Vl,Ca);Jt.register(Lg,g0);Jt.register(Fl,b0);Jt.register(Ml,x0);Lu.register(d0,_0);Lu.register(Yf,th);ht.registerSingleton(yo,w1);ht.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 So=60*5;function A1(){return new _t().openapi(ge({tags:["jwks"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:_y}},description:"List of tenants"}}}),async e=>{const t=await e.env.data.keys.list(),n=await Promise.all(t.map(async s=>{const a=await new rh(s.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",a);return lf.parse({...o,kid:s.kid})}));return e.json({keys:n},{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(ge({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Cl}},description:"List of tenants"}}}),async e=>{const t=e.env.ISSUER,n=Cl.parse({issuer:t,authorization_endpoint:`${t}authorize`,token_endpoint:`${t}oauth/token`,device_authorization_endpoint:`${t}oauth/device/code`,userinfo_endpoint:`${t}userinfo`,mfa_challenge_endpoint:`${t}mfa/challenge`,jwks_uri:`${t}.well-known/jwks.json`,registration_endpoint:`${t}oidc/register`,revocation_endpoint:`${t}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["HS256","RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post","private_key_jwt"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return e.json(n,{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`}})})}async function w0(r,e,t){return(await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function O1({userAdapter:r,tenant_id:e,email:t}){var o;const{users:n}=await r.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),s=n.filter(c=>!(c.provider==="auth2"&&!c.email_verified));if(s.length===0)return;const i=s.filter(c=>!c.linked_to);if(i.length>0)return i.length>1&&console.error("More than one primary user found for same email"),i[0];const a=await r.get(e,(o=s[0])==null?void 0:o.linked_to);if(!a)throw new Error("Primary account not found");return a}function E1(r){return async(e,t)=>{if(!t.email||!t.email_verified)return r.users.create(e,t);const n=await O1({userAdapter:r.users,tenant_id:e,email:t.email});return n?(await r.users.create(e,{...t,linked_to:n.user_id}),n):r.users.create(e,t)}}function k0(r,e){return{type:e.type,description:e.description||"",ip:r.req.header("x-real-ip")||"",user_agent:r.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:r.req.method,path:r.req.path,qs:r.req.queries(),body:e.body||r.var.body||""}},isMobile:!1,client_id:r.var.client_id,client_name:"",user_id:e.userId||r.var.user_id||"",hostname:r.req.header("host")||"",user_name:r.var.username||"",connection_id:"",connection:r.var.connection||"",strategy:"",strategy_type:"",audience:"",scope:[]}}async function I1(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=k0(r,{type:Qc.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await t.logs.create(r.var.tenant_id,i)}}function C1(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 I1(r,s,{tenant_id:t,user:n,trigger_id:"post-user-registration"}),n}}function j1(r,e){return async(t,n)=>{let s=await E1(e)(t,n);return await C1(r,e)(t,s),s}}function T1(r,e){return{...e,users:{...e.users,create:j1(r,e)}}}const N1=new _t().openapi(ge({tags:["branding"],method:"get",path:"/",request:{headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Il}},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(ge({tags:["branding"],method:"patch",path:"/",request:{headers:g.object({"tenant-id":g.string()}),body:{content:{"application/json":{schema:g.object(Il.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json");return await r.env.data.branding.set(e,t),r.text("OK")});function B1(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 S0={exports:{}};const R1={},P1=Object.freeze(Object.defineProperty({__proto__:null,default:R1},Symbol.toStringTag,{value:"Module"})),$1=j_(P1);(function(r){/**
|
|
118
118
|
* @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
|
|
119
119
|
* Released under the Apache License, Version 2.0
|
|
120
120
|
* see: https://github.com/dcodeIO/bcrypt.js for details
|
|
121
|
-
*/(function(e,t){typeof N1=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(ac,function(){var e={},t=null;function n(I){if(r&&r.exports)try{return P1.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 s=!1;try{n(1),s=!0}catch{}t=null,e.setRandomFallback=function(I){t=I},e.genSaltSync=function(I,E){if(I=I||y,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=y;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(V,Ie){if(V){j(V);return}b(Ie)})})},e.hashSync=function(I,E){if(typeof E>"u"&&(E=y),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(V,Ie){Rt(I,Ie,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,V){b(function(Ie,ie){if(Ie){V(Ie);return}j(ie)})})};function i(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:i(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(V,Ie){V?j(V):j(null,i(Ie,E))},x)}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(j,V){b(function(Ie,ie){if(Ie){V(Ie);return}j(ie)})})},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 R(I,E){var k=0,x=I.length,b=0,j=[],V,Ie,ie,Te,Ve,Q;if(E<=0)throw Error("Illegal len: "+E);for(;k<x-1&&b<E&&(Q=I.charCodeAt(k++),V=Q<u.length?u[Q]:-1,Q=I.charCodeAt(k++),Ie=Q<u.length?u[Q]:-1,!(V==-1||Ie==-1||(Ve=V<<2>>>0,Ve|=(Ie&48)>>4,j.push(f(Ve)),++b>=E||k>=x)||(Q=I.charCodeAt(k++),ie=Q<u.length?u[Q]:-1,ie==-1)||(Ve=(Ie&15)<<4>>>0,Ve|=(ie&60)>>2,j.push(f(Ve)),++b>=E||k>=x)));)Q=I.charCodeAt(k++),Te=Q<u.length?u[Q]:-1,Ve=(ie&3)<<6>>>0,Ve|=Te,j.push(f(Ve)),++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,V,Ie=function(ie){ie=ie.slice(0,ie.indexOf(null));var Te=Error(ie.toString());throw Te.name="TruncatedError",Te.bytes=ie,Te};(x=E())!==null;)if(!(x&128))k(x);else if((x&224)===192)(b=E())===null&&Ie([x,b]),k((x&31)<<6|b&63);else if((x&240)===224)((b=E())===null||(j=E())===null)&&Ie([x,b,j]),k((x&15)<<12|(b&63)<<6|j&63);else if((x&248)===240)((b=E())===null||(j=E())===null||(V=E())===null)&&Ie([x,b,j,V]),k((x&7)<<18|(b&63)<<12|(j&63)<<6|V&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,y=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],ve=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Le(I,E,k,x){var b,j=I[E],V=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],V^=b^k[1],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[3],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[5],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[7],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[9],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[11],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[13],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[15],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],j^=b^k[16],I[E]=V^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,V=k.length,Ie,ie=0;ie<j;ie++)Ie=qe(I,x),x=Ie.offp,E[ie]=E[ie]^Ie.key;for(ie=0;ie<j;ie+=2)b=Le(b,0,E,k),E[ie]=b[0],E[ie+1]=b[1];for(ie=0;ie<V;ie+=2)b=Le(b,0,E,k),k[ie]=b[0],k[ie+1]=b[1]}function tt(I,E,k,x){for(var b=0,j=[0,0],V=k.length,Ie=x.length,ie,Te=0;Te<V;Te++)ie=qe(E,b),b=ie.offp,k[Te]=k[Te]^ie.key;for(b=0,Te=0;Te<V;Te+=2)ie=qe(I,b),b=ie.offp,j[0]^=ie.key,ie=qe(I,b),b=ie.offp,j[1]^=ie.key,j=Le(j,0,k,x),k[Te]=j[0],k[Te+1]=j[1];for(Te=0;Te<Ie;Te+=2)ie=qe(I,b),b=ie.offp,j[0]^=ie.key,ie=qe(I,b),b=ie.offp,j[1]^=ie.key,j=Le(j,0,k,x),x[Te]=j[0],x[Te+1]=j[1]}function pt(I,E,k,x,b){var j=ve.slice(),V=j.length,Ie;if(k<4||k>31)if(Ie=Error("Illegal number of rounds (4-31): "+k),x){a(x.bind(this,Ie));return}else throw Ie;if(E.length!==p)if(Ie=Error("Illegal salt length: "+E.length+" != "+p),x){a(x.bind(this,Ie));return}else throw Ie;k=1<<k>>>0;var ie,Te,Ve=0,Q;Int32Array?(ie=new Int32Array(P),Te=new Int32Array(N)):(ie=P.slice(),Te=N.slice()),tt(E,I,ie,Te);function ot(){if(b&&b(Ve/k),Ve<k)for(var He=Date.now();Ve<k&&(Ve=Ve+1,Ze(I,ie,Te),Ze(E,ie,Te),!(Date.now()-He>O)););else{for(Ve=0;Ve<64;Ve++)for(Q=0;Q<V>>1;Q++)Le(j,Q<<1,ie,Te);var rt=[];for(Ve=0;Ve<V;Ve++)rt.push((j[Ve]>>24&255)>>>0),rt.push((j[Ve]>>16&255)>>>0),rt.push((j[Ve]>>8&255)>>>0),rt.push((j[Ve]&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,V;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",V=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;V=4}if(E.charAt(V+2)>"$")if(b=Error("Missing salt rounds"),k){a(k.bind(this,b));return}else throw b;var Ie=parseInt(E.substring(V,V+1),10)*10,ie=parseInt(E.substring(V+1,V+2),10),Te=Ie+ie,Ve=E.substring(V+3,V+25);I+=j>="a"?"\0":"";var Q=o(I),ot=R(Ve,p);function Rn(He){var rt=[];return rt.push("$2"),j>="a"&&rt.push(j),rt.push("$"),Te<10&&rt.push("0"),rt.push(Te.toString()),rt.push("$"),rt.push(m(ot,ot.length)),rt.push(m(He,ve.length*4-1)),rt.join("")}if(typeof k>"u")return Rn(pt(Q,ot,Te));pt(Q,ot,Te,function(He,rt){He?k(He,null):k(null,Rn(rt))},x)}return e.encodeBase64=m,e.decodeBase64=R,e})})(k0);var $1=k0.exports;const Z1=I_($1),D1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let M1=r=>crypto.getRandomValues(new Uint8Array(r)),V1=(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}}},U1=(r,e=21)=>V1(r,e,M1),Kd=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=D1[t[r]&63];return e};const L1=24;function q1(){return U1("0123456789abcdef",L1)()}function tm(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}const ps=v.object({page:v.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:v.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:v.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:v.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:v.string().optional().openapi({description:"A lucene query string used to filter the results"})});function vi(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}var H1={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},F1=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[s,i]of Object.entries(H1))if(W1(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"},W1=r=>navigator.userAgent.startsWith(r);function K1(r,e){F1()==="workerd"&&r.executionCtx.waitUntil(e)}const rm=jn.extend({users:v.array(vr)}),z1=jn.extend({sessions:v.array(lf)}),G1=new jt().openapi(ke({tags:["users"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(vr),rm])}},description:"List of users"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header");if(i!=null&&i.includes("identities.profileData.email")){const f=i.split("=")[1],R=(await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,q:`email:${f}`})).users.filter(y=>y.linked_to),[C]=R;if(!C)return r.json([]);const p=await r.env.data.users.get(a,C.linked_to);if(!p)throw new De(500,{message:"Primary account not found"});return r.json([vr.parse(p)])}const o=["-_exists_:linked_to"];i&&o.push(i);const c=await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,sort:vi(s),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(rm.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(v.array(vr).parse(u))}).openapi(ke({tags:["users"],method:"get",path:"/{user_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({user_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema: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 De(404);if(n.linked_to)throw new De(404,{message:"User is linked to another user"});return r.json(n)}).openapi(ke({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({user_id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{user_id:e}=r.req.valid("param"),{"tenant-id":t}=r.req.valid("header");if(!await r.env.data.users.remove(t,e))throw new De(404);return r.text("OK")}).openapi(ke({tags:["users"],method:"post",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object({...ec.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 De(400,{message:"Email is required"});const s=n.toLowerCase(),i=`${t.provider}|${t.user_id||q1()}`;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=w0(r,{type:Xc.SUCCESS_API_OPERATION,description:"User created"});K1(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:tm(a.user_id),isSocial:a.is_social}]};return r.json(vr.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new De(409,{message:"User already exists"}):a}}).openapi(ke({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object({...ec.shape,verify_email:v.boolean(),password:v.string()}).partial()}}},params:v.object({user_id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{var u;const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),{user_id:n}=r.req.valid("param"),{verify_email:s,password:i,...a}=t,o=await r.env.data.users.get(e,n);if(!o)throw new De(404);if(a.email&&a.email!==o.email){const f=await _0(r.env.data.users,e,a.email);if(f.length&&f.some(m=>m.user_id!==n))throw new De(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new De(404,{message:"User is linked to another user"});if(await r.env.data.users.update(e,n,a),i){const f=(u=o.identities)==null?void 0:u.find(m=>m.connection==="Username-Password-Authentication");if(!f)throw new De(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${f.provider}|${f.user_id}`,password:Z1.hashSync(i,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new De(500);return r.json(c)}).openapi(ke({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.union([v.object({link_with:v.string()}),v.object({user_id:v.string(),provider:v.string(),connection:v.string().optional()})])}}},params:v.object({user_id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:v.array(v.object({connection:v.string(),provider:v.string(),user_id:v.string(),isSocial:v.boolean()}))}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),{user_id:n}=r.req.valid("param"),s="link_with"in t?t.link_with:t.user_id,i=await r.env.data.users.get(e,n);if(!i)throw new De(400,{message:"Linking an inexistent identity is not allowed."});await r.env.data.users.update(e,s,{linked_to:n});const a=await r.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${n}`}),o=[i,...a.users].map(c=>({connection:c.connection,provider:c.provider,user_id:tm(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(ke({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({user_id:v.string(),provider:v.string(),linked_user_id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:v.array(vr)}},description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{user_id:t,provider:n,linked_user_id:s}=r.req.valid("param");await r.env.data.users.unlink(e,t,n,s);const i=await r.env.data.users.get(e,t);if(!i)throw new De(404);return r.json([vr.parse(i)])}).openapi(ke({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:ps,headers:v.object({"tenant-id":v.string()}),params:v.object({user_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(lf),z1])}},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)}),nm="0123456789abcdef";function zd(r){const e=new Uint8Array(r);let t="";for(let n=0;n<e.length;n++){const s=e[n]>>4;t+=nm[s];const i=e[n]&15;t+=nm[i]}return t}class S0{constructor(e,t){se(this,"alphabet");se(this,"padding");se(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",s=0,i=0;for(let o=0;o<e.length;o++)for(s=s<<8|e[o],i+=8;i>=5;)i-=5,n+=this.alphabet[s>>i&31];if(i>0&&(n+=this.alphabet[s<<5-i&31]),(t==null?void 0:t.includePadding)??!0){const o=(8-n.length%8)%8;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,s=Math.ceil(e.length/8),i=[];for(let a=0;a<s;a++){let o=0;const c=[];for(let f=0;f<8;f++){const m=e[a*8+f];if(m==="="){if(a+1!==s)throw new Error(`Invalid character: ${m}`);o+=1;continue}if(m===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const R=this.decodeMap.get(m)??null;if(R===null)throw new Error(`Invalid character: ${m}`);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 f=((c[1]&3)<<6)+(c[2]<<1)+(c[3]>>4);i.push(f)}if(o<4){const f=((c[3]&255)<<4)+(c[4]>>1);i.push(f)}if(o<3){const f=((c[4]&1)<<7)+(c[5]<<2)+(c[6]>>3);i.push(f)}if(o<1){const f=((c[6]&7)<<5)+c[7];i.push(f)}}return Uint8Array.from(i)}}new S0("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new S0("0123456789ABCDEFGHIJKLMNOPQRSTUV");class A0{constructor(e,t){se(this,"alphabet");se(this,"padding");se(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",s=0,i=0;for(let o=0;o<e.length;o++)for(s=s<<8|e[o],i+=8;i>=6;)i+=-6,n+=this.alphabet[s>>i&63];if(i>0&&(n+=this.alphabet[s<<6-i&63]),(t==null?void 0:t.includePadding)??!0){const o=(4-n.length%4)%4;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,s=Math.ceil(e.length/4),i=[];for(let a=0;a<s;a++){let o=0,c=0;for(let u=0;u<4;u++){const f=e[a*4+u];if(f==="="){if(a+1!==s)throw new Error(`Invalid character: ${f}`);o+=1;continue}if(f===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const m=this.decodeMap.get(f)??null;if(m===null)throw new Error(`Invalid character: ${f}`);c+=m<<6*(3-u)}i.push(c>>16&255),o<2&&i.push(c>>8&255),o<1&&i.push(c&255)}return Uint8Array.from(i)}}const J1=new A0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");new A0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function Y1(r){return await crypto.subtle.digest("SHA-256",r)}async function sm(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=Kd(),s=zd(new TextEncoder().encode(n)),i=await k1.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 Yf(!0,2,!0),new Xf(["1.3.6.1.5.5.7.3.1"],!0),new Qf(Vc.keyCertSign|Vc.cRLSign,!0),await mo.create(t.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",t.privateKey),o=i.toString("pem"),c=await Q1(i),u=zd(await i.getThumbprint()),f=X1("PRIVATE",a);return{kid:i.serialNumber,cert:o,thumbprint:u,fingerprint:c,pkcs7:f}}function X1(r,e){const t=J1.encode(new Uint8Array(e));let n=`-----BEGIN ${r} KEY-----\r
|
|
121
|
+
*/(function(e,t){typeof B1=="function"&&r&&r.exports?r.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(oc,function(){var e={},t=null;function n(I){if(r&&r.exports)try{return $1.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 s=!1;try{n(1),s=!0}catch{}t=null,e.setRandomFallback=function(I){t=I},e.genSaltSync=function(I,E){if(I=I||y,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=y;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(V,Ie){if(V){j(V);return}b(Ie)})})},e.hashSync=function(I,E){if(typeof E>"u"&&(E=y),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(V,Ie){Rt(I,Ie,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,V){b(function(Ie,ie){if(Ie){V(Ie);return}j(ie)})})};function i(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:i(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(V,Ie){V?j(V):j(null,i(Ie,E))},x)}if(k){if(typeof k!="function")throw Error("Illegal callback: "+typeof k);b(k)}else return new Promise(function(j,V){b(function(Ie,ie){if(Ie){V(Ie);return}j(ie)})})},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 R(I,E){var k=0,x=I.length,b=0,j=[],V,Ie,ie,Te,Ve,Q;if(E<=0)throw Error("Illegal len: "+E);for(;k<x-1&&b<E&&(Q=I.charCodeAt(k++),V=Q<u.length?u[Q]:-1,Q=I.charCodeAt(k++),Ie=Q<u.length?u[Q]:-1,!(V==-1||Ie==-1||(Ve=V<<2>>>0,Ve|=(Ie&48)>>4,j.push(f(Ve)),++b>=E||k>=x)||(Q=I.charCodeAt(k++),ie=Q<u.length?u[Q]:-1,ie==-1)||(Ve=(Ie&15)<<4>>>0,Ve|=(ie&60)>>2,j.push(f(Ve)),++b>=E||k>=x)));)Q=I.charCodeAt(k++),Te=Q<u.length?u[Q]:-1,Ve=(ie&3)<<6>>>0,Ve|=Te,j.push(f(Ve)),++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,V,Ie=function(ie){ie=ie.slice(0,ie.indexOf(null));var Te=Error(ie.toString());throw Te.name="TruncatedError",Te.bytes=ie,Te};(x=E())!==null;)if(!(x&128))k(x);else if((x&224)===192)(b=E())===null&&Ie([x,b]),k((x&31)<<6|b&63);else if((x&240)===224)((b=E())===null||(j=E())===null)&&Ie([x,b,j]),k((x&15)<<12|(b&63)<<6|j&63);else if((x&248)===240)((b=E())===null||(j=E())===null||(V=E())===null)&&Ie([x,b,j,V]),k((x&7)<<18|(b&63)<<12|(j&63)<<6|V&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,y=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],be=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Le(I,E,k,x){var b,j=I[E],V=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],V^=b^k[1],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[3],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[5],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[7],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[9],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[11],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[13],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&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],V^=b^k[15],b=x[V>>>24],b+=x[256|V>>16&255],b^=x[512|V>>8&255],b+=x[768|V&255],j^=b^k[16],I[E]=V^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 De(I,E,k){for(var x=0,b=[0,0],j=E.length,V=k.length,Ie,ie=0;ie<j;ie++)Ie=qe(I,x),x=Ie.offp,E[ie]=E[ie]^Ie.key;for(ie=0;ie<j;ie+=2)b=Le(b,0,E,k),E[ie]=b[0],E[ie+1]=b[1];for(ie=0;ie<V;ie+=2)b=Le(b,0,E,k),k[ie]=b[0],k[ie+1]=b[1]}function tt(I,E,k,x){for(var b=0,j=[0,0],V=k.length,Ie=x.length,ie,Te=0;Te<V;Te++)ie=qe(E,b),b=ie.offp,k[Te]=k[Te]^ie.key;for(b=0,Te=0;Te<V;Te+=2)ie=qe(I,b),b=ie.offp,j[0]^=ie.key,ie=qe(I,b),b=ie.offp,j[1]^=ie.key,j=Le(j,0,k,x),k[Te]=j[0],k[Te+1]=j[1];for(Te=0;Te<Ie;Te+=2)ie=qe(I,b),b=ie.offp,j[0]^=ie.key,ie=qe(I,b),b=ie.offp,j[1]^=ie.key,j=Le(j,0,k,x),x[Te]=j[0],x[Te+1]=j[1]}function pt(I,E,k,x,b){var j=be.slice(),V=j.length,Ie;if(k<4||k>31)if(Ie=Error("Illegal number of rounds (4-31): "+k),x){a(x.bind(this,Ie));return}else throw Ie;if(E.length!==p)if(Ie=Error("Illegal salt length: "+E.length+" != "+p),x){a(x.bind(this,Ie));return}else throw Ie;k=1<<k>>>0;var ie,Te,Ve=0,Q;Int32Array?(ie=new Int32Array(P),Te=new Int32Array(N)):(ie=P.slice(),Te=N.slice()),tt(E,I,ie,Te);function ot(){if(b&&b(Ve/k),Ve<k)for(var He=Date.now();Ve<k&&(Ve=Ve+1,De(I,ie,Te),De(E,ie,Te),!(Date.now()-He>O)););else{for(Ve=0;Ve<64;Ve++)for(Q=0;Q<V>>1;Q++)Le(j,Q<<1,ie,Te);var rt=[];for(Ve=0;Ve<V;Ve++)rt.push((j[Ve]>>24&255)>>>0),rt.push((j[Ve]>>16&255)>>>0),rt.push((j[Ve]>>8&255)>>>0),rt.push((j[Ve]&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,V;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",V=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;V=4}if(E.charAt(V+2)>"$")if(b=Error("Missing salt rounds"),k){a(k.bind(this,b));return}else throw b;var Ie=parseInt(E.substring(V,V+1),10)*10,ie=parseInt(E.substring(V+1,V+2),10),Te=Ie+ie,Ve=E.substring(V+3,V+25);I+=j>="a"?"\0":"";var Q=o(I),ot=R(Ve,p);function Rn(He){var rt=[];return rt.push("$2"),j>="a"&&rt.push(j),rt.push("$"),Te<10&&rt.push("0"),rt.push(Te.toString()),rt.push("$"),rt.push(m(ot,ot.length)),rt.push(m(He,be.length*4-1)),rt.join("")}if(typeof k>"u")return Rn(pt(Q,ot,Te));pt(Q,ot,Te,function(He,rt){He?k(He,null):k(null,Rn(rt))},x)}return e.encodeBase64=m,e.decodeBase64=R,e})})(S0);var Z1=S0.exports;const D1=C_(Z1),M1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let V1=r=>crypto.getRandomValues(new Uint8Array(r)),U1=(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}}},L1=(r,e=21)=>U1(r,e,V1),zd=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=M1[t[r]&63];return e};const q1=24;function H1(){return L1("0123456789abcdef",q1)()}function rm(r){if(!r.includes("|"))return console.error("Invalid user_id format"),r;const[,e]=r.split("|");return e}const ps=g.object({page:g.string().min(0).optional().default("0").transform(r=>parseInt(r,10)).openapi({description:"The page number where 0 is the first page"}),per_page:g.string().min(1).optional().default("10").transform(r=>parseInt(r,10)).openapi({description:"The number of items per page"}),include_totals:g.string().optional().default("false").transform(r=>r==="true").openapi({description:"If the total number of items should be included in the response"}),sort:g.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:g.string().optional().openapi({description:"A lucene query string used to filter the results"})});function vi(r){if(!r)return;const[e,t]=r.split(":"),n=t==="1"?"asc":"desc";if(!(!e||!n))return{sort_by:e,sort_order:n}}var F1={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},W1=()=>{var t,n;const r=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[s,i]of Object.entries(F1))if(K1(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"},K1=r=>navigator.userAgent.startsWith(r);function z1(r,e){W1()==="workerd"&&r.executionCtx.waitUntil(e)}const nm=jn.extend({users:g.array(vr)}),G1=jn.extend({sessions:g.array(df)}),J1=new _t().openapi(ge({tags:["users"],method:"get",path:"/",request:{query:ps,headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:g.union([g.array(vr),nm])}},description:"List of users"}}}),async r=>{const{page:e,per_page:t,include_totals:n,sort:s,q:i}=r.req.valid("query"),{"tenant-id":a}=r.req.valid("header");if(i!=null&&i.includes("identities.profileData.email")){const f=i.split("=")[1],R=(await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,q:`email:${f}`})).users.filter(y=>y.linked_to),[C]=R;if(!C)return r.json([]);const p=await r.env.data.users.get(a,C.linked_to);if(!p)throw new Be(500,{message:"Primary account not found"});return r.json([vr.parse(p)])}const o=["-_exists_:linked_to"];i&&o.push(i);const c=await r.env.data.users.list(a,{page:e,per_page:t,include_totals:n,sort:vi(s),q:o.join(" ")}),u=c.users.filter(f=>!f.linked_to);return n?r.json(nm.parse({users:u,length:c.length,start:c.start,limit:c.limit})):r.json(g.array(vr).parse(u))}).openapi(ge({tags:["users"],method:"get",path:"/{user_id}",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({user_id:g.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 Be(404);if(n.linked_to)throw new Be(404,{message:"User is linked to another user"});return r.json(n)}).openapi(ge({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({user_id:g.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 Be(404);return r.text("OK")}).openapi(ge({tags:["users"],method:"post",path:"/",request:{headers:g.object({"tenant-id":g.string()}),body:{content:{"application/json":{schema:g.object({...tc.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 Be(400,{message:"Email is required"});const s=n.toLowerCase(),i=`${t.provider}|${t.user_id||H1()}`;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=k0(r,{type:Qc.SUCCESS_API_OPERATION,description:"User created"});z1(r,r.env.data.logs.create(e,o));const c={...a,identities:[{connection:a.connection,provider:a.provider,user_id:rm(a.user_id),isSocial:a.is_social}]};return r.json(vr.parse(c),{status:201})}catch(a){throw a.message==="User already exists"?new Be(409,{message:"User already exists"}):a}}).openapi(ge({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:g.object({"tenant-id":g.string()}),body:{content:{"application/json":{schema:g.object({...tc.shape,verify_email:g.boolean(),password:g.string()}).partial()}}},params:g.object({user_id:g.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 Be(404);if(a.email&&a.email!==o.email){const f=await w0(r.env.data.users,e,a.email);if(f.length&&f.some(m=>m.user_id!==n))throw new Be(409,{message:"Another user with the same email address already exists."})}if(o.linked_to)throw new Be(404,{message:"User is linked to another user"});if(await r.env.data.users.update(e,n,a),i){const f=(u=o.identities)==null?void 0:u.find(m=>m.connection==="Username-Password-Authentication");if(!f)throw new Be(400,{message:"User does not have a password identity"});await r.env.data.passwords.update(e,{user_id:`${f.provider}|${f.user_id}`,password:D1.hashSync(i,10),algorithm:"bcrypt"})}const c=await r.env.data.users.get(e,n);if(!c)throw new Be(500);return r.json(c)}).openapi(ge({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:g.object({"tenant-id":g.string()}),body:{content:{"application/json":{schema:g.union([g.object({link_with:g.string()}),g.object({user_id:g.string(),provider:g.string(),connection:g.string().optional()})])}}},params:g.object({user_id:g.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:g.array(g.object({connection:g.string(),provider:g.string(),user_id:g.string(),isSocial:g.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 Be(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:rm(c.user_id),isSocial:c.is_social}));return r.json(o,{status:201})}).openapi(ge({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({user_id:g.string(),provider:g.string(),linked_user_id:g.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:g.array(vr)}},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 Be(404);return r.json([vr.parse(i)])}).openapi(ge({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:ps,headers:g.object({"tenant-id":g.string()}),params:g.object({user_id:g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:g.union([g.array(df),G1])}},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)}),sm="0123456789abcdef";function Gd(r){const e=new Uint8Array(r);let t="";for(let n=0;n<e.length;n++){const s=e[n]>>4;t+=sm[s];const i=e[n]&15;t+=sm[i]}return t}class A0{constructor(e,t){se(this,"alphabet");se(this,"padding");se(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",s=0,i=0;for(let o=0;o<e.length;o++)for(s=s<<8|e[o],i+=8;i>=5;)i-=5,n+=this.alphabet[s>>i&31];if(i>0&&(n+=this.alphabet[s<<5-i&31]),(t==null?void 0:t.includePadding)??!0){const o=(8-n.length%8)%8;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,s=Math.ceil(e.length/8),i=[];for(let a=0;a<s;a++){let o=0;const c=[];for(let f=0;f<8;f++){const m=e[a*8+f];if(m==="="){if(a+1!==s)throw new Error(`Invalid character: ${m}`);o+=1;continue}if(m===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const R=this.decodeMap.get(m)??null;if(R===null)throw new Error(`Invalid character: ${m}`);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 f=((c[1]&3)<<6)+(c[2]<<1)+(c[3]>>4);i.push(f)}if(o<4){const f=((c[3]&255)<<4)+(c[4]>>1);i.push(f)}if(o<3){const f=((c[4]&1)<<7)+(c[5]<<2)+(c[6]>>3);i.push(f)}if(o<1){const f=((c[6]&7)<<5)+c[7];i.push(f)}}return Uint8Array.from(i)}}new A0("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new A0("0123456789ABCDEFGHIJKLMNOPQRSTUV");class O0{constructor(e,t){se(this,"alphabet");se(this,"padding");se(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(t==null?void 0:t.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let n=0;n<e.length;n++)this.decodeMap.set(e[n],n)}encode(e,t){let n="",s=0,i=0;for(let o=0;o<e.length;o++)for(s=s<<8|e[o],i+=8;i>=6;)i+=-6,n+=this.alphabet[s>>i&63];if(i>0&&(n+=this.alphabet[s<<6-i&63]),(t==null?void 0:t.includePadding)??!0){const o=(4-n.length%4)%4;for(let c=0;c<o;c++)n+="="}return n}decode(e,t){const n=(t==null?void 0:t.strict)??!0,s=Math.ceil(e.length/4),i=[];for(let a=0;a<s;a++){let o=0,c=0;for(let u=0;u<4;u++){const f=e[a*4+u];if(f==="="){if(a+1!==s)throw new Error(`Invalid character: ${f}`);o+=1;continue}if(f===void 0){if(n)throw new Error("Invalid data");o+=1;continue}const m=this.decodeMap.get(f)??null;if(m===null)throw new Error(`Invalid character: ${f}`);c+=m<<6*(3-u)}i.push(c>>16&255),o<2&&i.push(c>>8&255),o<1&&i.push(c&255)}return Uint8Array.from(i)}}const Y1=new O0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");new O0("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function X1(r){return await crypto.subtle.digest("SHA-256",r)}async function im(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=zd(),s=Gd(new TextEncoder().encode(n)),i=await S1.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 Xf(!0,2,!0),new Qf(["1.3.6.1.5.5.7.3.1"],!0),new eh(Uc.keyCertSign|Uc.cRLSign,!0),await mo.create(t.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",t.privateKey),o=i.toString("pem"),c=await ek(i),u=Gd(await i.getThumbprint()),f=Q1("PRIVATE",a);return{kid:i.serialNumber,cert:o,thumbprint:u,fingerprint:c,pkcs7:f}}function Q1(r,e){const t=Y1.encode(new Uint8Array(e));let n=`-----BEGIN ${r} KEY-----\r
|
|
122
122
|
`,s=0;for(;s<t.length;)s+64<=t.length?n+=t.substr(s,64)+`\r
|
|
123
123
|
`:n+=t.substr(s)+`\r
|
|
124
124
|
`,s+=64;return n+=`-----END ${r} KEY-----\r
|
|
125
|
-
`,n}async function Q1(r){const e=await r.publicKey.export(),t=await crypto.subtle.exportKey("jwk",e),n=JSON.stringify(t,Object.keys(t).sort()),i=new TextEncoder().encode(n);return zd(await Y1(i))}const ek=1e3*60*60*24,tk=new jt().openapi(ke({tags:["keys"],method:"get",path:"/signing",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.array(Cl)}},description:"List of keys"}}}),async r=>{const t=(await r.env.data.keys.list()).filter(n=>"cert"in n).map(n=>n);return r.json(t)}).openapi(ke({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({kid:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Cl}},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 De(404,{message:"Key not found"});return r.json(n)}).openapi(ke({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const e=await r.env.data.keys.list();for await(const n of e)await r.env.data.keys.update(n.kid,{revoked_at:new Date(Date.now()+ek).toISOString()});const t=await sm({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ke({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({kid:v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async r=>{const{kid:e}=r.req.valid("param");if(!await r.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new De(404,{message:"Key not found"});const n=await sm({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),rk=new jt().openapi(ke({tags:["users"],method:"get",path:"/",request:{query:v.object({email:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:v.array(sf)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),s=(await _0(r.env.data.users,e,t)).filter(i=>!i.linked_to);return r.json(s)}),nk=jn.extend({clients:v.array(Mn)}),sk=new jt().openapi(ke({tags:["clients"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([nk,v.array(Mn)])}},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:vi(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ke({tags:["clients"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"An application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=(await r.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(i=>i.id===t);if(!s)throw new De(404);return r.json(s)}).openapi(ke({tags:["clients"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.applications.remove(e,t))throw new De(404,{message:"Application not found"});return r.text("OK")}).openapi(ke({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(tc.shape).partial()}}},params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Mn}},description:"The update application"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),s=r.req.valid("json");await r.env.data.applications.update(e,t,s);const i=await r.env.data.applications.get(e,t);if(!i)throw new De(404,{message:"Application not found"});return r.json(i)}).openapi(ke({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(tc.shape)}}},headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:v.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||Kd(),client_secret:t.client_secret||Kd()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var Pe;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return r.objectValues(a)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},r.find=(s,i)=>{for(const a of s)if(i(a))return a},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}r.joinValues=n,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Pe||(Pe={}));var Gd;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Gd||(Gd={}));const J=Pe.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=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"]),ik=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Dt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const si=(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,Pe.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:t=`Unrecognized key(s) in object: ${Pe.joinValues(r.keys,", ")}`;break;case M.invalid_union:t="Invalid input";break;case M.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Pe.joinValues(r.options)}`;break;case M.invalid_enum_value:t=`Invalid enum value. Expected ${Pe.joinValues(r.options)}, received '${r.received}'`;break;case M.invalid_arguments:t="Invalid function arguments";break;case M.invalid_return_type:t="Invalid function return type";break;case M.invalid_date:t="Invalid date";break;case M.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Pe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case M.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case M.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case M.custom:t="Invalid input";break;case M.invalid_intersection_types:t="Intersection results could not be merged";break;case M.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case M.not_finite:t="Number must be finite";break;default:t=e.defaultError,Pe.assertNever(r)}return{message:t}};let O0=si;function ak(r){O0=r}function Uc(){return O0}const Lc=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}},ok=[];function W(r,e){const t=Uc(),n=Lc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===si?void 0:si].filter(s=>!!s)});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 s of t){if(s.status==="aborted")return me;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return me;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Cs=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Jd=r=>r.status==="aborted",Yd=r=>r.status==="dirty",ja=r=>r.status==="valid",Ta=r=>typeof Promise<"u"&&r instanceof Promise;function qc(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 E0(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ce;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ce||(ce={}));var Ni,Bi;class Ir{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 im=(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 Dt(r.common.issues);return this._error=t,this._error}}};function _e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class 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 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 gt,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 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:on(e)},i=this._parseSync({data:e,path:s.path,parent:s});return im(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:on(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ta(s)?s:Promise.resolve(s));return im(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:M.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new 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 ai.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({..._e(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ua({..._e(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new rh({typeName:he.ZodBranded,type:this,..._e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new La({..._e(this._def),innerType:this,catchValue:t,typeName:he.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return go.create(this,e)}readonly(){return qa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ck=/^c[^\s-]{8,}$/i,uk=/^[0-9a-z]+$/,lk=/^[0-9A-HJKMNP-TV-Z]{26}$/,dk=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,fk=/^[a-z0-9_-]{21}$/i,hk=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,pk=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ul;const yk=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,gk=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,vk=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,I0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",bk=new RegExp(`^${I0}$`);function C0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function xk(r){return new RegExp(`^${C0(r)}$`)}function j0(r){let e=`${I0}T${C0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function _k(r,e){return!!((e==="v4"||!e)&&yk.test(r)||(e==="v6"||!e)&&gk.test(r))}class ar extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.string,received:i.parsedType}),me}const n=new gt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")pk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")ul||(ul=new RegExp(mk,"u")),ul.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")dk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")fk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")ck.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")uk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")lk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:M.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"regex",code:M.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?j0(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?bk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?xk(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?hk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?_k(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?vk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new 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,..._e(r)})};function wk(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 On 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)!==J.number){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.number,received:i.parsedType}),me}let n;const s=new gt;for(const i of this._def.checks)i.kind==="int"?Pe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?wk(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_finite,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,s){return new On({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_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"&&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)}}On.create=r=>new On({checks:[],typeName:he.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class En 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)!==J.bigint){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.bigint,received:i.parsedType}),me}let n;const s=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Pe.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,s){return new En({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_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,..._e(r)})};class Na extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.boolean,received:n.parsedType}),me}return wt(e.data)}}Na.create=r=>new Na({typeName:he.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._e(r)});class ms extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.date,received:i.parsedType}),me}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_date}),me}const n=new gt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Pe.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ms({...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}}ms.create=r=>new ms({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,..._e(r)});class Hc extends Ee{_parse(e){if(this._getType(e)!==J.symbol){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.symbol,received:n.parsedType}),me}return wt(e.data)}}Hc.create=r=>new Hc({typeName:he.ZodSymbol,..._e(r)});class Ba extends Ee{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.undefined,received:n.parsedType}),me}return wt(e.data)}}Ba.create=r=>new Ba({typeName:he.ZodUndefined,..._e(r)});class Ra extends Ee{_parse(e){if(this._getType(e)!==J.null){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.null,received:n.parsedType}),me}return wt(e.data)}}Ra.create=r=>new Ra({typeName:he.ZodNull,..._e(r)});class ii extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}ii.create=r=>new ii({typeName:he.ZodAny,..._e(r)});class Xn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}Xn.create=r=>new Xn({typeName:he.ZodUnknown,..._e(r)});class Yr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:J.never,received:t.parsedType}),me}}Yr.create=r=>new Yr({typeName:he.ZodNever,..._e(r)});class Fc extends Ee{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.void,received:n.parsedType}),me}return wt(e.data)}}Fc.create=r=>new Fc({typeName:he.ZodVoid,..._e(r)});class lr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==J.array)return W(t,{code:M.invalid_type,expected:J.array,received:t.parsedType}),me;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(W(t,{code:a?M.too_big:M.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(W(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(W(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ir(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ir(t,a,t.path,o)));return gt.mergeArray(n,i)}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,..._e(e)});function As(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=kr.create(As(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof lr?new lr({...r._def,type:As(r.element)}):r instanceof kr?kr.create(As(r.unwrap())):r instanceof Cn?Cn.create(As(r.unwrap())):r instanceof Cr?Cr.create(r.items.map(e=>As(e))):r}class Ye 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)!==J.object){const u=this._getOrReturnCtx(e);return W(u,{code:M.invalid_type,expected:J.object,received:u.parsedType}),me}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Yr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Ir(s,m,s.path,u)),alwaysSet:u in s.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:s.data[f]}});else if(u==="strict")o.length>0&&(W(s,{code:M.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Ir(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,R=await f.value;u.push({key:m,value:R,alwaysSet:f.alwaysSet})}return u}).then(u=>gt.mergeObjectSync(n,u)):gt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ce.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:he.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...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 Ye({...this._def,shape:()=>t})}omit(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return As(this)}partial(e){const t={};return Pe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Ye({...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 kr;)i=i._def.innerType;t[n]=i}}),new Ye({...this._def,shape:()=>t})}keyof(){return T0(Pe.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,..._e(e)});class Pa extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Dt(o.ctx.common.issues));return W(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Dt(c));return W(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Pa.create=(r,e)=>new Pa({options:r,typeName:he.ZodUnion,..._e(e)});const Rr=r=>r instanceof Da?Rr(r.schema):r instanceof hr?Rr(r.innerType()):r instanceof Ma?[r.value]:r instanceof In?r.options:r instanceof Va?Pe.objectValues(r.enum):r instanceof Ua?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 rh||r instanceof qa?Rr(r.unwrap()):r instanceof La?Rr(r._def.innerType):[];class Lu extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return W(t,{code:M.invalid_type,expected:J.object,received:t.parsedType}),me;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=Rr(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 Lu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._e(n)})}}function Xd(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 s=Pe.objectKeys(e),i=Pe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Xd(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===J.array&&n===J.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Xd(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===J.date&&n===J.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class $a extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Jd(i)||Jd(a))return me;const o=Xd(i.value,a.value);return o.valid?((Yd(i)||Yd(a))&&t.dirty(),{status:t.value,value:o.data}):(W(n,{code:M.invalid_intersection_types}),me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}$a.create=(r,e,t)=>new $a({left:r,right:e,typeName:he.ZodIntersection,..._e(t)});class Cr extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return W(n,{code:M.invalid_type,expected:J.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return W(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Ir(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>gt.mergeArray(t,a)):gt.mergeArray(t,i)}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,..._e(e)})};class Za 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!==J.object)return W(n,{code:M.invalid_type,expected:J.object,received:n.parsedType}),me;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new 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?gt.mergeObjectAsync(t,s):gt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new Za({keyType:e,valueType:t,typeName:he.ZodRecord,..._e(n)}):new Za({keyType:ar.create(),valueType:e,typeName:he.ZodRecord,..._e(t)})}}class Wc 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!==J.map)return W(n,{code:M.invalid_type,expected:J.map,received:n.parsedType}),me;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ir(n,o,n.path,[u,"key"])),value:i._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}}}}Wc.create=(r,e,t)=>new Wc({valueType:e,keyType:r,typeName:he.ZodMap,..._e(t)});class ys extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return W(n,{code:M.invalid_type,expected:J.set,received:n.parsedType}),me;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return me;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ir(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ys({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new ys({...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)}}ys.create=(r,e)=>new ys({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,..._e(e)});class Ps extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return W(t,{code:M.invalid_type,expected:J.function,received:t.parsedType}),me;function n(o,c){return Lc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Uc(),si].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function s(o,c){return Lc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Uc(),si].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ai){const o=this;return wt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,i).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return wt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Dt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ps({...this._def,args:Cr.create(e).rest(Xn.create())})}returns(e){return new Ps({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ps({args:e||Cr.create([]).rest(Xn.create()),returns:t||Xn.create(),typeName:he.ZodFunction,..._e(n)})}}class Da 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})}}Da.create=(r,e)=>new Da({getter:r,typeName:he.ZodLazy,..._e(e)});class Ma extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ma.create=(r,e)=>new Ma({value:r,typeName:he.ZodLiteral,..._e(e)});function T0(r,e){return new In({values:r,typeName:he.ZodEnum,..._e(e)})}class In extends Ee{constructor(){super(...arguments),Ni.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:Pe.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(qc(this,Ni)||E0(this,Ni,new Set(this._def.values)),!qc(this,Ni).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:M.invalid_enum_value,options:n}),me}return 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 In.create(e,{...this._def,...t})}exclude(e,t=this._def){return In.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}Ni=new WeakMap;In.create=T0;class Va extends Ee{constructor(){super(...arguments),Bi.set(this,void 0)}_parse(e){const t=Pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==J.string&&n.parsedType!==J.number){const s=Pe.objectValues(t);return W(n,{expected:Pe.joinValues(s),received:n.parsedType,code:M.invalid_type}),me}if(qc(this,Bi)||E0(this,Bi,new Set(Pe.getValidEnumValues(this._def.values))),!qc(this,Bi).has(e.data)){const s=Pe.objectValues(t);return W(n,{received:n.data,code:M.invalid_enum_value,options:s}),me}return wt(e.data)}get enum(){return this._def.values}}Bi=new WeakMap;Va.create=(r,e)=>new Va({values:r,typeName:he.ZodNativeEnum,..._e(e)});class ai extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return W(t,{code:M.invalid_type,expected:J.promise,received:t.parsedType}),me;const n=t.parsedType===J.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ai.create=(r,e)=>new ai({type:r,typeName:he.ZodPromise,..._e(e)});class hr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===he.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{W(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return me;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?me:c.status==="dirty"||t.value==="dirty"?Cs(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"?Cs(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ja(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=>ja(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);Pe.assertNever(s)}}hr.create=(r,e,t)=>new hr({schema:r,typeName:he.ZodEffects,effect:e,..._e(t)});hr.createWithPreprocess=(r,e,t)=>new hr({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,..._e(t)});class kr extends Ee{_parse(e){return this._getType(e)===J.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kr.create=(r,e)=>new kr({innerType:r,typeName:he.ZodOptional,..._e(e)});class Cn extends Ee{_parse(e){return this._getType(e)===J.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cn.create=(r,e)=>new Cn({innerType:r,typeName:he.ZodNullable,..._e(e)});class Ua extends Ee{_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}}Ua.create=(r,e)=>new Ua({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._e(e)});class La extends Ee{_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 Ta(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}La.create=(r,e)=>new La({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._e(e)});class Kc extends Ee{_parse(e){if(this._getType(e)!==J.nan){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}Kc.create=r=>new Kc({typeName:he.ZodNaN,..._e(r)});const kk=Symbol("zod_brand");class rh 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 go 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"?me:i.status==="dirty"?(t.dirty(),Cs(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new go({in:e,out:t,typeName:he.ZodPipeline})}}class qa extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=s=>(ja(s)&&(s.value=Object.freeze(s.value)),s);return Ta(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}qa.create=(r,e)=>new qa({innerType:r,typeName:he.ZodReadonly,..._e(e)});function N0(r,e={},t){return r?ii.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})}}):ii.create()}const Sk={object:Ye.lazycreate};var he;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(he||(he={}));const Ak=(r,e={message:`Input not instance of ${r.name}`})=>N0(t=>t instanceof r,e),B0=ar.create,R0=On.create,Ok=Kc.create,Ek=En.create,P0=Na.create,Ik=ms.create,Ck=Hc.create,jk=Ba.create,Tk=Ra.create,Nk=ii.create,Bk=Xn.create,Rk=Yr.create,Pk=Fc.create,$k=lr.create,Zk=Ye.create,Dk=Ye.strictCreate,Mk=Pa.create,Vk=Lu.create,Uk=$a.create,Lk=Cr.create,qk=Za.create,Hk=Wc.create,Fk=ys.create,Wk=Ps.create,Kk=Da.create,zk=Ma.create,Gk=In.create,Jk=Va.create,Yk=ai.create,am=hr.create,Xk=kr.create,Qk=Cn.create,eS=hr.createWithPreprocess,tS=go.create,rS=()=>B0().optional(),nS=()=>R0().optional(),sS=()=>P0().optional(),iS={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=>ms.create({...r,coerce:!0})},aS=me;var Lt=Object.freeze({__proto__:null,defaultErrorMap:si,setErrorMap:ak,getErrorMap:Uc,makeIssue:Lc,EMPTY_PATH:ok,addIssueToContext:W,ParseStatus:gt,INVALID:me,DIRTY:Cs,OK:wt,isAborted:Jd,isDirty:Yd,isValid:ja,isAsync:Ta,get util(){return Pe},get objectUtil(){return Gd},ZodParsedType:J,getParsedType:on,ZodType:Ee,datetimeRegex:j0,ZodString:ar,ZodNumber:On,ZodBigInt:En,ZodBoolean:Na,ZodDate:ms,ZodSymbol:Hc,ZodUndefined:Ba,ZodNull:Ra,ZodAny:ii,ZodUnknown:Xn,ZodNever:Yr,ZodVoid:Fc,ZodArray:lr,ZodObject:Ye,ZodUnion:Pa,ZodDiscriminatedUnion:Lu,ZodIntersection:$a,ZodTuple:Cr,ZodRecord:Za,ZodMap:Wc,ZodSet:ys,ZodFunction:Ps,ZodLazy:Da,ZodLiteral:Ma,ZodEnum:In,ZodNativeEnum:Va,ZodPromise:ai,ZodEffects:hr,ZodTransformer:hr,ZodOptional:kr,ZodNullable:Cn,ZodDefault:Ua,ZodCatch:La,ZodNaN:Kc,BRAND:kk,ZodBranded:rh,ZodPipeline:go,ZodReadonly:qa,custom:N0,Schema:Ee,ZodSchema:Ee,late:Sk,get ZodFirstPartyTypeKind(){return he},coerce:iS,any:Nk,array:$k,bigint:Ek,boolean:P0,date:Ik,discriminatedUnion:Vk,effect:am,enum:Gk,function:Wk,instanceof:Ak,intersection:Uk,lazy:Kk,literal:zk,map:Hk,nan:Ok,nativeEnum:Jk,never:Rk,null:Tk,nullable:Qk,number:R0,object:Zk,oboolean:sS,onumber:nS,optional:Xk,ostring:rS,pipeline:tS,preprocess:eS,promise:Yk,record:qk,set:Fk,strictObject:Dk,string:B0,symbol:Ck,transformer:am,tuple:Lk,undefined:jk,union:Mk,unknown:Bk,void:Pk,NEVER:aS,ZodIssueCode:M,quotelessJson:ik,ZodError:Dt});Lt.object({start:Lt.number(),limit:Lt.number(),length:Lt.number()});Yc.extend({email:Lt.string(),login_count:Lt.number(),multifactor:Lt.array(Lt.string()).optional(),last_ip:Lt.string().optional(),last_login:Lt.string().optional(),user_id:Lt.string()}).catchall(Lt.any());const oS=jn.extend({tenants:v.array(Ns)}),cS=new jt().openapi(ke({tags:["tenants"],method:"get",path:"/",request:{query:ps},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:v.union([v.array(Ns),oS])}},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:vi(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(ke({tags:["tenants"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Ns}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new De(404);return console.log("tenant",t),r.json(t)}).openapi(ke({tags:["tenants"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param");return await r.env.data.tenants.remove(e),r.text("OK")}).openapi(ke({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(nc.shape).partial()}}},params:v.object({id:v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{id:e}=r.req.valid("param"),t=r.req.valid("json");return await r.env.data.tenants.update(e,t),r.text("OK")}).openapi(ke({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(nc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Ns}},description:"An tenant"}}}),async r=>{const e=r.req.valid("json"),t=await r.env.data.tenants.create(e);return r.json(t,{status:201})}),uS=jn.extend({logs:v.array(ic)}),lS=new jt().openapi(ke({tags:["logs"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(ic),uS])}},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:vi(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(ke({tags:["logs"],method:"get",path:"/{id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ic}},description:"A log entry"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.logs.get(e,t);if(!n)throw new De(404);return r.json(n)}),dS=jn.extend({hooks:v.array(Es)}),fS=new jt().openapi(ke({tags:["hooks"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Es),dS])}},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:vi(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(ke({tags:["hooks"],method:"post",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.object(sc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Es}},description:"The created hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.hooks.create(e,t);return r.json(n,{status:201})}).openapi(ke({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()}),body:{content:{"application/json":{schema:v.object(sc.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Es.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=r.req.valid("json");await r.env.data.hooks.update(e,t,n);const s=await r.env.data.hooks.get(e,t);if(!s)throw new De(404,{message:"Hook not found"});return r.json(s)}).openapi(ke({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Es}},description:"A hook"},404:{description:"Hook not found"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param"),n=await r.env.data.hooks.get(e,t);if(!n)throw new De(404,{message:"Hook not found"});return r.json(n)}).openapi(ke({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:v.object({"tenant-id":v.string()}),params:v.object({hook_id:v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{hook_id:t}=r.req.valid("param");if(!await r.env.data.hooks.remove(e,t))throw new De(404,{message:"Hook not found"});return r.text("OK")}),hS=jn.extend({connections:v.array(Vn)}),pS=new jt().openapi(ke({tags:["connections"],method:"get",path:"/",request:{query:ps,headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:v.union([v.array(Vn),hS])}},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:vi(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(ke({tags:["connections"],method:"get",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vn}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=await r.env.data.connections.get(e,t);if(!n)throw new De(404);return r.json(n)}).openapi(ke({tags:["connections"],method:"delete",path:"/{id}",request:{params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param");if(!await r.env.data.connections.remove(e,t))throw new De(404,{message:"Connection not found"});return r.text("OK")}).openapi(ke({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:v.object(rc.shape).partial()}}},params:v.object({id:v.string()}),headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Vn}},description:"The updated connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{id:t}=r.req.valid("param"),n=r.req.valid("json");if(!await r.env.data.connections.update(e,t,n))throw new De(404,{message:"Connection not found"});const i=await r.env.data.connections.get(e,t);if(!i)throw new De(404,{message:"Connection not found"});return r.json(i)}).openapi(ke({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:v.object(rc.shape)}}},headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Vn}},description:"A connection"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),t=r.req.valid("json"),n=await r.env.data.connections.create(e,t);return r.json(n,{status:201})}),mS=new jt().openapi(ke({tags:["prompts"],method:"get",path:"/",request:{headers:v.object({"tenant-id":v.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema: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(ke({tags:["prompts"],method:"patch",path:"/",request:{headers:v.object({"tenant-id":v.string()}),body:{content:{"application/json":{schema:v.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 om=!1;function yS(r){r.use(async(e,t)=>(om||(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"}}}}),om=!0),await t()))}v.object({alg:v.literal("RS256"),kty:v.literal("RSA"),use:v.literal("sig"),n:v.string(),e:v.string(),kid:v.string(),x5t:v.string(),x5c:v.array(v.string())});async function 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 De(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(".")),s=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,s,n)}function bS(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 xS(r){return async(e,t)=>{var s,i;const n=r.openAPIRegistry.definitions.find(a=>"route"in a&&a.route.path===e.req.path&&a.route.method.toUpperCase()===e.req.method);if(n&&"route"in n){const a=(i=(s=n.route.security)==null?void 0:s[0])==null?void 0:i.Bearer,o=e.req.header("authorization")||"",[c,u]=o.split(" ");if((c==null?void 0:c.toLowerCase())!=="bearer"||!u)throw new De(401,{message:"Missing bearer token"});const f=bS(u);if(!f||!await vS(e,f))throw new De(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub);const m=f.payload.permissions||[];if(a!=null&&a.length&&!a.some(R=>m.includes(R)))throw new De(403,{message:"Unauthorized"})}return await t()}}function _S(r){const e=new jt;e.use(xS(e)),e.use(async(n,s)=>(n.env.data=j1(n,r.dataAdapter),s()));const t=e.route("/branding",T1).route("/users",G1).route("/keys",tk).route("/users-by-email",rk).route("/clients",sk).route("/tenants",cS).route("/logs",lS).route("/hooks",fS).route("/connections",pS).route("/prompts",mS);return yS(t),t.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function wS(r){const e=new jt;e.get("/",s=>s.json({name:"authhero"}));const t=_S(r);e.route("/api/v2",t);const n=new jt().route("/.well-known",S1());return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",n),{app:e,managementApp:t,oauthApp:n}}exports.Auth0Client=wy;exports.AuthorizationResponseMode=of;exports.AuthorizationResponseType=af;exports.CodeChallengeMethod=cf;exports.GrantType=df;exports.LogTypes=Xc;exports.applicationInsertSchema=tc;exports.applicationSchema=Mn;exports.auth0UserResponseSchema=vr;exports.authParamsSchema=yy;exports.authorizationCodeGrantTypeParamsSchema=k_;exports.baseUserSchema=Yc;exports.bordersSchema=Ay;exports.brandingSchema=El;exports.clientCredentialGrantTypeParamsSchema=A_;exports.codeInsertSchema=vy;exports.codeSchema=v_;exports.codeTypeSchema=gy;exports.colorsSchema=Oy;exports.connectionInsertSchema=rc;exports.connectionSchema=Vn;exports.domainInsertSchema=by;exports.domainSchema=b_;exports.fontDetailsSchema=Zn;exports.fontsSchema=Ey;exports.hookInsertSchema=sc;exports.hookSchema=Es;exports.identitySchema=py;exports.init=wS;exports.jwksKeySchema=xy;exports.jwksSchema=uf;exports.logSchema=ic;exports.loginInsertSchema=_y;exports.loginSchema=x_;exports.openIDConfigurationSchema=Il;exports.pageBackgroundSchema=Iy;exports.parseUserId=E_;exports.passwordInsertSchema=ky;exports.passwordSchema=w_;exports.pkceAuthorizationCodeGrantTypeParamsSchema=S_;exports.profileDataSchema=hy;exports.promptSettingSchema=jo;exports.samlpAddon=my;exports.sessionInsertSchema=Sy;exports.sessionSchema=lf;exports.signingKeySchema=Cl;exports.tenantInsertSchema=nc;exports.tenantSchema=Ns;exports.themeInsertSchema=jy;exports.themeSchema=O_;exports.totalsSchema=jn;exports.userInsertSchema=ec;exports.userResponseSchema=h_;exports.userSchema=sf;exports.vendorSettingsSchema=y_;exports.widgetSchema=Cy;
|
|
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()),i=new TextEncoder().encode(n);return Gd(await X1(i))}const tk=1e3*60*60*24,rk=new _t().openapi(ge({tags:["keys"],method:"get",path:"/signing",request:{headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:g.array(jl)}},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(ge({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({kid:g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:jl}},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 Be(404,{message:"Key not found"});return r.json(n)}).openapi(ge({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:g.object({"tenant-id":g.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 im({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(t),r.text("OK",{status:201})}).openapi(ge({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({kid:g.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 Be(404,{message:"Key not found"});const n=await im({name:`CN=${r.env.ORGANIZATION_NAME}`});return await r.env.data.keys.create(n),r.text("OK")}),nk=new _t().openapi(ge({tags:["users"],method:"get",path:"/",request:{query:g.object({email:g.string()}),headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:g.array(af)}},description:"List of users"}}}),async r=>{const{"tenant-id":e}=r.req.valid("header"),{email:t}=r.req.valid("query"),s=(await w0(r.env.data.users,e,t)).filter(i=>!i.linked_to);return r.json(s)}),sk=jn.extend({clients:g.array(Mn)}),ik=new _t().openapi(ge({tags:["clients"],method:"get",path:"/",request:{query:ps,headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:g.union([sk,g.array(Mn)])}},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:vi(i),q:a})).applications;return s?r.json({clients:c,start:0,limit:10,length:c.length}):r.json(c)}).openapi(ge({tags:["clients"],method:"get",path:"/{id}",request:{params:g.object({id:g.string()}),headers:g.object({"tenant-id":g.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"),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 Be(404);return r.json(s)}).openapi(ge({tags:["clients"],method:"delete",path:"/{id}",request:{params:g.object({id:g.string()}),headers:g.object({"tenant-id":g.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 Be(404,{message:"Application not found"});return r.text("OK")}).openapi(ge({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:g.object(rc.shape).partial()}}},params:g.object({id:g.string()}),headers:g.object({"tenant-id":g.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"),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 Be(404,{message:"Application not found"});return r.json(i)}).openapi(ge({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:g.object(rc.shape)}}},headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:g.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||zd(),client_secret:t.client_secret||zd()},s=await r.env.data.applications.create(e,n);return r.json(s,{status:201})});var $e;(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})($e||($e={}));var Jd;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Jd||(Jd={}));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 Dt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(i){return i.message},n={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,c=0;for(;c<a.path.length;){const u=a.path[c];c===a.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(a))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof Dt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Dt.create=r=>new Dt(r);const si=(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 E0=si;function ok(r){E0=r}function Lc(){return E0}const qc=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}},ck=[];function W(r,e){const t=Lc(),n=qc({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===si?void 0:si].filter(s=>!!s)});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 s of t){if(s.status==="aborted")return me;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const i=await s.key,a=await s.value;n.push({key:i,value:a})}return gt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return me;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}}const me=Object.freeze({status:"aborted"}),Cs=r=>({status:"dirty",value:r}),kt=r=>({status:"valid",value:r}),Yd=r=>r.status==="aborted",Xd=r=>r.status==="dirty",ja=r=>r.status==="valid",Ta=r=>typeof Promise<"u"&&r instanceof Promise;function Hc(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 I0(r,e,t,n,s){if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ce;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ce||(ce={}));var Ni,Bi;class Ir{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 am=(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 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:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,u;const{message:f}=r;return a.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(c=f??n)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:s}}class 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 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 gt,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 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:on(e)},i=this._parseSync({data:e,path:s.path,parent:s});return am(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:on(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ta(s)?s:Promise.resolve(s));return am(n,i)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:M.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new 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 ai.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({...we(this._def),schema:this,typeName:he.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ua({...we(this._def),innerType:this,defaultValue:t,typeName:he.ZodDefault})}brand(){return new nh({typeName:he.ZodBranded,type:this,...we(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new La({...we(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 ll;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}=))?$/,C0="((\\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(`^${C0}$`);function j0(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(`^${j0(r)}$`)}function T0(r){let e=`${C0}T${j0(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 Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.string,received:i.parsedType}),me}const n=new gt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?W(s,{code:M.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&W(s,{code:M.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")mk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")ll||(ll=new RegExp(yk,"u")),ll.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")fk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")hk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")uk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")lk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")dk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:M.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:M.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"regex",code:M.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?T0(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?xk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?_k(i).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:M.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?pk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?wk(e.data,i.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:M.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?bk.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:M.invalid_string,message:i.message}),n.dirty()):$e.assertNever(i);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:M.invalid_string,...ce.errToObj(n)})}_addCheck(e){return new 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,...we(r)})};function kk(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 On 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)!==J.number){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.number,received:i.parsedType}),me}let n;const s=new gt;for(const i of this._def.checks)i.kind==="int"?$e.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?kk(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_finite,message:i.message}),s.dirty()):$e.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,s){return new On({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_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,...we(r)});class En 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)!==J.bigint){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.bigint,received:i.parsedType}),me}let n;const s=new gt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),W(n,{code:M.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):$e.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ce.toString(t))}setLimit(e,t,n,s){return new En({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ce.toString(s)}]})}_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,...we(r)})};class Na extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){const n=this._getOrReturnCtx(e);return W(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,...we(r)});class ms extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_type,expected:J.date,received:i.parsedType}),me}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return W(i,{code:M.invalid_date}),me}const n=new gt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:M.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):$e.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ms({...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}}ms.create=r=>new ms({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:he.ZodDate,...we(r)});class Fc extends Ee{_parse(e){if(this._getType(e)!==J.symbol){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.symbol,received:n.parsedType}),me}return kt(e.data)}}Fc.create=r=>new Fc({typeName:he.ZodSymbol,...we(r)});class Ba extends Ee{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.undefined,received:n.parsedType}),me}return kt(e.data)}}Ba.create=r=>new Ba({typeName:he.ZodUndefined,...we(r)});class Ra extends Ee{_parse(e){if(this._getType(e)!==J.null){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.null,received:n.parsedType}),me}return kt(e.data)}}Ra.create=r=>new Ra({typeName:he.ZodNull,...we(r)});class ii extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return kt(e.data)}}ii.create=r=>new ii({typeName:he.ZodAny,...we(r)});class Xn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return kt(e.data)}}Xn.create=r=>new Xn({typeName:he.ZodUnknown,...we(r)});class Yr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return W(t,{code:M.invalid_type,expected:J.never,received:t.parsedType}),me}}Yr.create=r=>new Yr({typeName:he.ZodNever,...we(r)});class Wc extends Ee{_parse(e){if(this._getType(e)!==J.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.void,received:n.parsedType}),me}return kt(e.data)}}Wc.create=r=>new Wc({typeName:he.ZodVoid,...we(r)});class lr extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==J.array)return W(t,{code:M.invalid_type,expected:J.array,received:t.parsedType}),me;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(W(t,{code:a?M.too_big:M.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(W(t,{code:M.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(W(t,{code:M.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new Ir(t,a,t.path,o)))).then(a=>gt.mergeArray(n,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new Ir(t,a,t.path,o)));return gt.mergeArray(n,i)}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,...we(e)});function As(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=kr.create(As(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof lr?new lr({...r._def,type:As(r.element)}):r instanceof kr?kr.create(As(r.unwrap())):r instanceof Cn?Cn.create(As(r.unwrap())):r instanceof Cr?Cr.create(r.items.map(e=>As(e))):r}class Ye 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=$e.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==J.object){const u=this._getOrReturnCtx(e);return W(u,{code:M.invalid_type,expected:J.object,received:u.parsedType}),me}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Yr&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||o.push(u);const c=[];for(const u of a){const f=i[u],m=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new Ir(s,m,s.path,u)),alwaysSet:u in s.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:s.data[f]}});else if(u==="strict")o.length>0&&(W(s,{code:M.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const m=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new Ir(s,m,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of c){const m=await f.key,R=await f.value;u.push({key:m,value:R,alwaysSet:f.alwaysSet})}return u}).then(u=>gt.mergeObjectSync(n,u)):gt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return ce.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=ce.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName: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 As(this)}partial(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return $e.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof kr;)i=i._def.innerType;t[n]=i}}),new Ye({...this._def,shape:()=>t})}keyof(){return N0($e.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,...we(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Yr.create(),typeName:he.ZodObject,...we(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Yr.create(),typeName:he.ZodObject,...we(e)});class Pa extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new Dt(o.ctx.common.issues));return W(t,{code:M.invalid_union,unionErrors:a}),me}if(t.common.async)return Promise.all(n.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},f=c._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new Dt(c));return W(t,{code:M.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Pa.create=(r,e)=>new Pa({options:r,typeName:he.ZodUnion,...we(e)});const Rr=r=>r instanceof Da?Rr(r.schema):r instanceof hr?Rr(r.innerType()):r instanceof Ma?[r.value]:r instanceof In?r.options:r instanceof Va?$e.objectValues(r.enum):r instanceof Ua?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 nh||r instanceof qa?Rr(r.unwrap()):r instanceof La?Rr(r._def.innerType):[];class qu extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.object)return W(t,{code:M.invalid_type,expected:J.object,received:t.parsedType}),me;const n=this.discriminator,s=t.data[n],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const i of t){const a=Rr(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 qu({typeName:he.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...we(n)})}}function Qd(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 s=$e.objectKeys(e),i=$e.objectKeys(r).filter(o=>s.indexOf(o)!==-1),a={...r,...e};for(const o of i){const c=Qd(r[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===J.array&&n===J.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const a=r[i],o=e[i],c=Qd(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===J.date&&n===J.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class $a extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Yd(i)||Yd(a))return me;const o=Qd(i.value,a.value);return o.valid?((Xd(i)||Xd(a))&&t.dirty(),{status:t.value,value:o.data}):(W(n,{code:M.invalid_intersection_types}),me)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}$a.create=(r,e,t)=>new $a({left:r,right:e,typeName:he.ZodIntersection,...we(t)});class Cr extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.array)return W(n,{code:M.invalid_type,expected:J.array,received:n.parsedType}),me;if(n.data.length<this._def.items.length)return W(n,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Ir(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>gt.mergeArray(t,a)):gt.mergeArray(t,i)}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,...we(e)})};class Za 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!==J.object)return W(n,{code:M.invalid_type,expected:J.object,received:n.parsedType}),me;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in n.data)s.push({key:i._parse(new 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?gt.mergeObjectAsync(t,s):gt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new Za({keyType:e,valueType:t,typeName:he.ZodRecord,...we(n)}):new Za({keyType:ar.create(),valueType:e,typeName:he.ZodRecord,...we(t)})}}class Kc 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!==J.map)return W(n,{code:M.invalid_type,expected:J.map,received:n.parsedType}),me;const s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new Ir(n,o,n.path,[u,"key"])),value:i._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}}}}Kc.create=(r,e,t)=>new Kc({valueType:e,keyType:r,typeName:he.ZodMap,...we(t)});class ys extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==J.set)return W(n,{code:M.invalid_type,expected:J.set,received:n.parsedType}),me;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:M.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(W(n,{code:M.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const u=new Set;for(const f of c){if(f.status==="aborted")return me;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>i._parse(new Ir(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new ys({...this._def,minSize:{value:e,message:ce.toString(t)}})}max(e,t){return new ys({...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)}}ys.create=(r,e)=>new ys({valueType:r,minSize:null,maxSize:null,typeName:he.ZodSet,...we(e)});class Ps extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.function)return W(t,{code:M.invalid_type,expected:J.function,received:t.parsedType}),me;function n(o,c){return qc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Lc(),si].filter(u=>!!u),issueData:{code:M.invalid_arguments,argumentsError:c}})}function s(o,c){return qc({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Lc(),si].filter(u=>!!u),issueData:{code:M.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ai){const o=this;return kt(async function(...c){const u=new Dt([]),f=await o._def.args.parseAsync(c,i).catch(C=>{throw u.addIssue(n(c,C)),u}),m=await Reflect.apply(a,this,f);return await o._def.returns._def.type.parseAsync(m,i).catch(C=>{throw u.addIssue(s(m,C)),u})})}else{const o=this;return kt(function(...c){const u=o._def.args.safeParse(c,i);if(!u.success)throw new Dt([n(c,u.error)]);const f=Reflect.apply(a,this,u.data),m=o._def.returns.safeParse(f,i);if(!m.success)throw new Dt([s(f,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ps({...this._def,args:Cr.create(e).rest(Xn.create())})}returns(e){return new Ps({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ps({args:e||Cr.create([]).rest(Xn.create()),returns:t||Xn.create(),typeName:he.ZodFunction,...we(n)})}}class Da 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})}}Da.create=(r,e)=>new Da({getter:r,typeName:he.ZodLazy,...we(e)});class Ma extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:M.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ma.create=(r,e)=>new Ma({value:r,typeName:he.ZodLiteral,...we(e)});function N0(r,e){return new In({values:r,typeName:he.ZodEnum,...we(e)})}class In extends Ee{constructor(){super(...arguments),Ni.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:$e.joinValues(n),received:t.parsedType,code:M.invalid_type}),me}if(Hc(this,Ni)||I0(this,Ni,new Set(this._def.values)),!Hc(this,Ni).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:M.invalid_enum_value,options:n}),me}return 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})}}Ni=new WeakMap;In.create=N0;class Va extends Ee{constructor(){super(...arguments),Bi.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 s=$e.objectValues(t);return W(n,{expected:$e.joinValues(s),received:n.parsedType,code:M.invalid_type}),me}if(Hc(this,Bi)||I0(this,Bi,new Set($e.getValidEnumValues(this._def.values))),!Hc(this,Bi).has(e.data)){const s=$e.objectValues(t);return W(n,{received:n.data,code:M.invalid_enum_value,options:s}),me}return kt(e.data)}get enum(){return this._def.values}}Bi=new WeakMap;Va.create=(r,e)=>new Va({values:r,typeName:he.ZodNativeEnum,...we(e)});class ai extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==J.promise&&t.common.async===!1)return W(t,{code: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(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ai.create=(r,e)=>new ai({type:r,typeName:he.ZodPromise,...we(e)});class hr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===he.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{W(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return me;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?me:c.status==="dirty"||t.value==="dirty"?Cs(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"?Cs(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ja(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=>ja(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);$e.assertNever(s)}}hr.create=(r,e,t)=>new hr({schema:r,typeName:he.ZodEffects,effect:e,...we(t)});hr.createWithPreprocess=(r,e,t)=>new hr({schema:e,effect:{type:"preprocess",transform:r},typeName:he.ZodEffects,...we(t)});class kr extends Ee{_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,...we(e)});class Cn extends Ee{_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,...we(e)});class Ua extends Ee{_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}}Ua.create=(r,e)=>new Ua({innerType:r,typeName:he.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...we(e)});class La extends Ee{_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 Ta(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}La.create=(r,e)=>new La({innerType:r,typeName:he.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...we(e)});class zc extends Ee{_parse(e){if(this._getType(e)!==J.nan){const n=this._getOrReturnCtx(e);return W(n,{code:M.invalid_type,expected:J.nan,received:n.parsedType}),me}return{status:"valid",value:e.data}}}zc.create=r=>new zc({typeName:he.ZodNaN,...we(r)});const Sk=Symbol("zod_brand");class nh 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 go 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"?me:i.status==="dirty"?(t.dirty(),Cs(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?me:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new go({in:e,out:t,typeName:he.ZodPipeline})}}class qa extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=s=>(ja(s)&&(s.value=Object.freeze(s.value)),s);return Ta(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}qa.create=(r,e)=>new qa({innerType:r,typeName:he.ZodReadonly,...we(e)});function B0(r,e={},t){return r?ii.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})}}):ii.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}`})=>B0(t=>t instanceof r,e),R0=ar.create,P0=On.create,Ek=zc.create,Ik=En.create,$0=Na.create,Ck=ms.create,jk=Fc.create,Tk=Ba.create,Nk=Ra.create,Bk=ii.create,Rk=Xn.create,Pk=Yr.create,$k=Wc.create,Zk=lr.create,Dk=Ye.create,Mk=Ye.strictCreate,Vk=Pa.create,Uk=qu.create,Lk=$a.create,qk=Cr.create,Hk=Za.create,Fk=Kc.create,Wk=ys.create,Kk=Ps.create,zk=Da.create,Gk=Ma.create,Jk=In.create,Yk=Va.create,Xk=ai.create,om=hr.create,Qk=kr.create,eS=Cn.create,tS=hr.createWithPreprocess,rS=go.create,nS=()=>R0().optional(),sS=()=>P0().optional(),iS=()=>$0().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=>ms.create({...r,coerce:!0})},oS=me;var Lt=Object.freeze({__proto__:null,defaultErrorMap:si,setErrorMap:ok,getErrorMap:Lc,makeIssue:qc,EMPTY_PATH:ck,addIssueToContext:W,ParseStatus:gt,INVALID:me,DIRTY:Cs,OK:kt,isAborted:Yd,isDirty:Xd,isValid:ja,isAsync:Ta,get util(){return $e},get objectUtil(){return Jd},ZodParsedType:J,getParsedType:on,ZodType:Ee,datetimeRegex:T0,ZodString:ar,ZodNumber:On,ZodBigInt:En,ZodBoolean:Na,ZodDate:ms,ZodSymbol:Fc,ZodUndefined:Ba,ZodNull:Ra,ZodAny:ii,ZodUnknown:Xn,ZodNever:Yr,ZodVoid:Wc,ZodArray:lr,ZodObject:Ye,ZodUnion:Pa,ZodDiscriminatedUnion:qu,ZodIntersection:$a,ZodTuple:Cr,ZodRecord:Za,ZodMap:Kc,ZodSet:ys,ZodFunction:Ps,ZodLazy:Da,ZodLiteral:Ma,ZodEnum:In,ZodNativeEnum:Va,ZodPromise:ai,ZodEffects:hr,ZodTransformer:hr,ZodOptional:kr,ZodNullable:Cn,ZodDefault:Ua,ZodCatch:La,ZodNaN:zc,BRAND:Sk,ZodBranded:nh,ZodPipeline:go,ZodReadonly:qa,custom:B0,Schema:Ee,ZodSchema:Ee,late:Ak,get ZodFirstPartyTypeKind(){return he},coerce:aS,any:Bk,array:Zk,bigint:Ik,boolean:$0,date:Ck,discriminatedUnion:Uk,effect:om,enum:Jk,function:Kk,instanceof:Ok,intersection:Lk,lazy:zk,literal:Gk,map:Fk,nan:Ek,nativeEnum:Yk,never:Pk,null:Nk,nullable:eS,number:P0,object:Dk,oboolean:iS,onumber:sS,optional:Qk,ostring:nS,pipeline:rS,preprocess:tS,promise:Xk,record:Hk,set:Wk,strictObject:Mk,string:R0,symbol:jk,transformer:om,tuple:qk,undefined:Tk,union:Vk,unknown:Rk,void:$k,NEVER:oS,ZodIssueCode:M,quotelessJson:ak,ZodError:Dt});Lt.object({start:Lt.number(),limit:Lt.number(),length:Lt.number()});Xc.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:g.array(Ns)}),uS=new _t().openapi(ge({tags:["tenants"],method:"get",path:"/",request:{query:ps},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:g.union([g.array(Ns),cS])}},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:vi(s),q:i});return n?r.json(a):r.json(a.tenants)}).openapi(ge({tags:["tenants"],method:"get",path:"/{id}",request:{params:g.object({id:g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Ns}},description:"A tenant"}}}),async r=>{const{id:e}=r.req.valid("param"),t=await r.env.data.tenants.get(e);if(!t)throw new Be(404);return r.json(t)}).openapi(ge({tags:["tenants"],method:"delete",path:"/{id}",request:{params:g.object({id:g.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(ge({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:g.object(sc.shape).partial()}}},params:g.object({id:g.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(ge({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:g.object(sc.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Ns}},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:g.array(ac)}),dS=new _t().openapi(ge({tags:["logs"],method:"get",path:"/",request:{query:ps,headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:g.union([g.array(ac),lS])}},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:vi(s),q:i});return n?r.json(o):r.json(o.logs)}).openapi(ge({tags:["logs"],method:"get",path:"/{id}",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({id:g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ac}},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 Be(404);return r.json(n)}),fS=jn.extend({hooks:g.array(Es)}),hS=new _t().openapi(ge({tags:["hooks"],method:"get",path:"/",request:{query:ps,headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:g.union([g.array(Es),fS])}},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:vi(i),q:a});return s?r.json(o):r.json(o.hooks)}).openapi(ge({tags:["hooks"],method:"post",path:"/",request:{headers:g.object({"tenant-id":g.string()}),body:{content:{"application/json":{schema:g.object(ic.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Es}},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(ge({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({hook_id:g.string()}),body:{content:{"application/json":{schema:g.object(ic.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Es.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 Be(404,{message:"Hook not found"});return r.json(s)}).openapi(ge({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({hook_id:g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Es}},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 Be(404,{message:"Hook not found"});return r.json(n)}).openapi(ge({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:g.object({"tenant-id":g.string()}),params:g.object({hook_id:g.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 Be(404,{message:"Hook not found"});return r.text("OK")}),pS=jn.extend({connections:g.array(Vn)}),mS=new _t().openapi(ge({tags:["connections"],method:"get",path:"/",request:{query:ps,headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:g.union([g.array(Vn),pS])}},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:vi(i),q:a});return s?r.json(o):r.json(o.connections)}).openapi(ge({tags:["connections"],method:"get",path:"/{id}",request:{params:g.object({id:g.string()}),headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vn}},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 Be(404);return r.json(n)}).openapi(ge({tags:["connections"],method:"delete",path:"/{id}",request:{params:g.object({id:g.string()}),headers:g.object({"tenant-id":g.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 Be(404,{message:"Connection not found"});return r.text("OK")}).openapi(ge({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:g.object(nc.shape).partial()}}},params:g.object({id:g.string()}),headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Vn}},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 Be(404,{message:"Connection not found"});const i=await r.env.data.connections.get(e,t);if(!i)throw new Be(404,{message:"Connection not found"});return r.json(i)}).openapi(ge({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:g.object(nc.shape)}}},headers:g.object({"tenant-id":g.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Vn}},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 _t().openapi(ge({tags:["prompts"],method:"get",path:"/",request:{headers:g.object({"tenant-id":g.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(ge({tags:["prompts"],method:"patch",path:"/",request:{headers:g.object({"tenant-id":g.string()}),body:{content:{"application/json":{schema:g.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 cm=!1;function gS(r){r.use(async(e,t)=>(cm||(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"}}}}),cm=!0),await t()))}g.object({alg:g.literal("RS256"),kty:g.literal("RSA"),use:g.literal("sig"),n:g.string(),e:g.string(),kid:g.string(),x5t:g.string(),x5c:g.array(g.string())});async function vS(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 Be(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function bS(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 vS(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 xS(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 _S(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 Be(401,{message:"Missing bearer token"});const f=xS(u);if(!f||!await bS(e,f))throw new Be(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub);const m=f.payload.permissions||[];if(a!=null&&a.length&&!a.some(R=>m.includes(R)))throw new Be(403,{message:"Unauthorized"})}return await t()}}const wS=new _t().openapi(ge({tags:["emails"],method:"get",path:"/",request:{headers:g.object({"tenant-id":g.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 Be(404,{message:"Email provider not found"});return r.json(t)}).openapi(ge({tags:["emails"],method:"post",path:"/",request:{headers:g.object({"tenant-id":g.string()}),body:{content:{"application/json":{schema:g.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(ge({tags:["emails"],method:"patch",path:"/",request:{headers:g.object({"tenant-id":g.string()}),body:{content:{"application/json":{schema:g.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 kS(r){const e=new _t;e.use(_S(e)),e.use(async(n,s)=>(n.env.data=T1(n,r.dataAdapter),s()));const t=e.route("/branding",N1).route("/email/providers",wS).route("/users",J1).route("/keys",rk).route("/users-by-email",nk).route("/clients",ik).route("/tenants",uS).route("/logs",dS).route("/hooks",hS).route("/connections",mS).route("/prompts",yS);return gS(t),t.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),t}function SS(r){const e=new _t;e.get("/",s=>s.json({name:"authhero"}));const t=kS(r);e.route("/api/v2",t);const n=new _t().route("/.well-known",A1());return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth endpoints"}}),e.route("/",n),{app:e,managementApp:t,oauthApp:n}}exports.Auth0Client=ky;exports.AuthorizationResponseMode=cf;exports.AuthorizationResponseType=of;exports.CodeChallengeMethod=uf;exports.GrantType=ff;exports.LogTypes=Qc;exports.applicationInsertSchema=rc;exports.applicationSchema=Mn;exports.auth0UserResponseSchema=vr;exports.authParamsSchema=gy;exports.authorizationCodeGrantTypeParamsSchema=S_;exports.baseUserSchema=Xc;exports.bordersSchema=Oy;exports.brandingSchema=Il;exports.clientCredentialGrantTypeParamsSchema=O_;exports.codeInsertSchema=by;exports.codeSchema=b_;exports.codeTypeSchema=vy;exports.colorsSchema=Ey;exports.connectionInsertSchema=nc;exports.connectionSchema=Vn;exports.domainInsertSchema=xy;exports.domainSchema=x_;exports.emailProviderSchema=To;exports.fontDetailsSchema=Zn;exports.fontsSchema=Iy;exports.hookInsertSchema=ic;exports.hookSchema=Es;exports.identitySchema=my;exports.init=SS;exports.jwksKeySchema=_y;exports.jwksSchema=lf;exports.logSchema=ac;exports.loginInsertSchema=wy;exports.loginSchema=__;exports.openIDConfigurationSchema=Cl;exports.pageBackgroundSchema=Cy;exports.parseUserId=I_;exports.passwordInsertSchema=Sy;exports.passwordSchema=k_;exports.pkceAuthorizationCodeGrantTypeParamsSchema=A_;exports.profileDataSchema=py;exports.promptSettingSchema=jo;exports.samlpAddon=yy;exports.sessionInsertSchema=Ay;exports.sessionSchema=df;exports.signingKeySchema=jl;exports.tenantInsertSchema=sc;exports.tenantSchema=Ns;exports.themeInsertSchema=Ty;exports.themeSchema=E_;exports.totalsSchema=jn;exports.userInsertSchema=tc;exports.userResponseSchema=p_;exports.userSchema=af;exports.vendorSettingsSchema=g_;exports.widgetSchema=jy;
|