-
Notifications
You must be signed in to change notification settings - Fork 2
/
x509.js
76 lines (73 loc) · 198 KB
/
x509.js
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
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*!
* MIT License
*
* Copyright (c) Peculiar Ventures. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
var x509=function(e){"use strict";var t,r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
/*! *****************************************************************************
Copyright (C) Microsoft. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */!function(e){!function(t){var i="object"==typeof globalThis?globalThis:"object"==typeof r?r:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=s(e);function s(e,t){return function(r,i){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:i}),t&&t(r,i)}}void 0!==i.Reflect&&(n=s(i.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,i="function"==typeof Symbol,n=i&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=i&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,u={create:o?function(){return pe(Object.create(null))}:a?function(){return pe({__proto__:null})}:function(){return pe({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},l=Object.getPrototypeOf(Function),p="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),h="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:ue(),f="function"==typeof WeakMap?WeakMap:le(),y=i?Symbol.for("@reflect-metadata:registry"):void 0,d=ne(),g=se(d);function v(e,t,r,i){if(V(r)){if(!q(e))throw new TypeError;if(!G(t))throw new TypeError;return C(e,t)}if(!q(e))throw new TypeError;if(!$(t))throw new TypeError;if(!$(i)&&!V(i)&&!L(i))throw new TypeError;return L(i)&&(i=void 0),O(e,t,r=z(r),i)}function m(e,t){function r(r,i){if(!$(r))throw new TypeError;if(!V(i)&&!J(i))throw new TypeError;P(e,t,r,i)}return r}function w(e,t,r,i){if(!$(r))throw new TypeError;return V(i)||(i=z(i)),P(e,t,r,i)}function b(e,t,r){if(!$(t))throw new TypeError;return V(r)||(r=z(r)),I(e,t,r)}function A(e,t,r){if(!$(t))throw new TypeError;return V(r)||(r=z(r)),N(e,t,r)}function S(e,t,r){if(!$(t))throw new TypeError;return V(r)||(r=z(r)),T(e,t,r)}function x(e,t,r){if(!$(t))throw new TypeError;return V(r)||(r=z(r)),j(e,t,r)}function B(e,t){if(!$(e))throw new TypeError;return V(t)||(t=z(t)),U(e,t)}function k(e,t){if(!$(e))throw new TypeError;return V(t)||(t=z(t)),R(e,t)}function E(e,t,r){if(!$(t))throw new TypeError;if(V(r)||(r=z(r)),!$(t))throw new TypeError;V(r)||(r=z(r));var i=ae(t,r,!1);return!V(i)&&i.OrdinaryDeleteMetadata(e,t,r)}function C(e,t){for(var r=e.length-1;r>=0;--r){var i=(0,e[r])(t);if(!V(i)&&!L(i)){if(!G(i))throw new TypeError;t=i}}return t}function O(e,t,r,i){for(var n=e.length-1;n>=0;--n){var s=(0,e[n])(t,r,i);if(!V(s)&&!L(s)){if(!$(s))throw new TypeError;i=s}}return i}function I(e,t,r){if(N(e,t,r))return!0;var i=re(t);return!L(i)&&I(e,i,r)}function N(e,t,r){var i=ae(t,r,!1);return!V(i)&&K(i.OrdinaryHasOwnMetadata(e,t,r))}function T(e,t,r){if(N(e,t,r))return j(e,t,r);var i=re(t);return L(i)?void 0:T(e,i,r)}function j(e,t,r){var i=ae(t,r,!1);if(!V(i))return i.OrdinaryGetOwnMetadata(e,t,r)}function P(e,t,r,i){ae(r,i,!0).OrdinaryDefineOwnMetadata(e,t,r,i)}function U(e,t){var r=R(e,t),i=re(e);if(null===i)return r;var n=U(i,t);if(n.length<=0)return r;if(r.length<=0)return n;for(var s=new h,o=[],a=0,c=r;a<c.length;a++){var u=c[a];s.has(u)||(s.add(u),o.push(u))}for(var l=0,p=n;l<p.length;l++){u=p[l];s.has(u)||(s.add(u),o.push(u))}return o}function R(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function D(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function V(e){return void 0===e}function L(e){return null===e}function H(e){return"symbol"==typeof e}function $(e){return"object"==typeof e?null!==e:"function"==typeof e}function M(e,t){switch(D(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r="string",i=Z(e,n);if(void 0!==i){var s=i.call(e,r);if($(s))throw new TypeError;return s}return F(e)}function F(e,t){var r,i,n=e.toString;if(W(n)&&!$(i=n.call(e)))return i;if(W(r=e.valueOf)&&!$(i=r.call(e)))return i;throw new TypeError}function K(e){return!!e}function _(e){return""+e}function z(e){var t=M(e);return H(t)?t:_(t)}function q(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function W(e){return"function"==typeof e}function G(e){return"function"==typeof e}function J(e){switch(D(e)){case 3:case 4:return!0;default:return!1}}function X(e,t){return e===t||e!=e&&t!=t}function Z(e,t){var r=e[t];if(null!=r){if(!W(r))throw new TypeError;return r}}function Y(e){var t=Z(e,s);if(!W(t))throw new TypeError;var r=t.call(e);if(!$(r))throw new TypeError;return r}function Q(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===l)return t;if(t!==l)return t;var r=e.prototype,i=r&&Object.getPrototypeOf(r);if(null==i||i===Object.prototype)return t;var n=i.constructor;return"function"!=typeof n||n===e?t:n}function ie(){var e,r,i,n;V(y)||void 0===t.Reflect||y in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=oe(t.Reflect));var s=new f,o={registerProvider:a,getProvider:u,setProvider:d};return o;function a(t){if(!Object.isExtensible(o))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case V(r):r=t;break;case r===t:break;case V(i):i=t;break;case i===t:break;default:void 0===n&&(n=new h),n.add(t)}}function c(t,s){if(!V(r)){if(r.isProviderFor(t,s))return r;if(!V(i)){if(i.isProviderFor(t,s))return r;if(!V(n))for(var o=Y(n);;){var a=ee(o);if(!a)return;var c=Q(a);if(c.isProviderFor(t,s))return te(o),c}}}if(!V(e)&&e.isProviderFor(t,s))return e}function u(e,t){var r,i=s.get(e);return V(i)||(r=i.get(t)),V(r)?(V(r=c(e,t))||(V(i)&&(i=new p,s.set(e,i)),i.set(t,r)),r):r}function l(e){if(V(e))throw new TypeError;return r===e||i===e||!V(n)&&n.has(e)}function d(e,t,r){if(!l(r))throw new Error("Metadata provider not registered.");var i=u(e,t);if(i!==r){if(!V(i))return!1;var n=s.get(e);V(n)&&(n=new p,s.set(e,n)),n.set(t,r)}return!0}}function ne(){var e;return!V(y)&&$(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[y]),V(e)&&(e=ie()),!V(y)&&$(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function se(e){var t=new f,r={isProviderFor:function(e,r){var i=t.get(e);return!V(i)&&i.has(r)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:s,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:c};return d.registerProvider(r),r;function i(i,n,s){var o=t.get(i),a=!1;if(V(o)){if(!s)return;o=new p,t.set(i,o),a=!0}var c=o.get(n);if(V(c)){if(!s)return;if(c=new p,o.set(n,c),!e.setProvider(i,n,r))throw o.delete(n),a&&t.delete(i),new Error("Wrong provider for target.")}return c}function n(e,t,r){var n=i(t,r,!1);return!V(n)&&K(n.has(e))}function s(e,t,r){var n=i(t,r,!1);if(!V(n))return n.get(e)}function o(e,t,r,n){i(r,n,!0).set(e,t)}function a(e,t){var r=[],n=i(e,t,!1);if(V(n))return r;for(var s=Y(n.keys()),o=0;;){var a=ee(s);if(!a)return r.length=o,r;var c=Q(a);try{r[o]=c}catch(e){try{te(s)}finally{throw e}}o++}}function c(e,r,n){var s=i(r,n,!1);if(V(s))return!1;if(!s.delete(e))return!1;if(0===s.size){var o=t.get(r);V(o)||(o.delete(n),0===o.size&&t.delete(o))}return!0}}function oe(e){var t=e.defineMetadata,r=e.hasOwnMetadata,i=e.getOwnMetadata,n=e.getOwnMetadataKeys,s=e.deleteMetadata,o=new f;return{isProviderFor:function(e,t){var r=o.get(e);return!(V(r)||!r.has(t))||!!n(e,t).length&&(V(r)&&(r=new h,o.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:i,OrdinaryOwnMetadataKeys:n,OrdinaryDeleteMetadata:s}}function ae(e,t,r){var i=d.getProvider(e,t);if(!V(i))return i;if(r){if(d.setProvider(e,t,g))return g;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[s]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var i=this._keys.length,n=r+1;n<i;n++)this._keys[n-1]=this._keys[n],this._values[n-1]=this._values[n];return this._keys.length--,this._values.length--,X(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,i)},t.prototype.values=function(){return new r(this._keys,this._values,n)},t.prototype.entries=function(){return new r(this._keys,this._values,o)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[s]=function(){return this.entries()},t.prototype._find=function(e,t){if(!X(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(X(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function i(e,t){return e}function n(e,t){return t}function o(e,t){return[e,t]}}function ue(){return function(){function e(){this._map=new p}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[s]=function(){return this.keys()},e}()}function le(){var e=16,t=u.create(),i=n();return function(){function e(){this._key=n()}return e.prototype.has=function(e){var t=s(e,!1);return void 0!==t&&u.has(t,this._key)},e.prototype.get=function(e){var t=s(e,!1);return void 0!==t?u.get(t,this._key):void 0},e.prototype.set=function(e,t){return s(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=s(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=n()},e}();function n(){var e;do{e="@@WeakMap@@"+c()}while(u.has(t,e));return t[e]=!0,e}function s(e,t){if(!r.call(e,i)){if(!t)return;Object.defineProperty(e,i,{value:u.create()})}return e[i]}function o(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,e),t}return o(new Array(e),e)}function c(){var t=a(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",i=0;i<e;++i){var n=t[i];4!==i&&6!==i&&8!==i||(r+="-"),n<16&&(r+="0"),r+=n.toString(16).toLowerCase()}return r}}function pe(e){return e.__=void 0,delete e.__,e}e("decorate",v),e("metadata",m),e("defineMetadata",w),e("hasMetadata",b),e("hasOwnMetadata",A),e("getMetadata",S),e("getOwnMetadata",x),e("getMetadataKeys",B),e("getOwnMetadataKeys",k),e("deleteMetadata",E)}(n,i),void 0===i.Reflect&&(i.Reflect=e)}()}(t||(t={}));class i{static isArrayBuffer(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||0===e.byteOffset&&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 r=i.toUint8Array(e),n=i.toUint8Array(t);if(r.length!==n.byteLength)return!1;for(let e=0;e<r.length;e++)if(r[e]!==n[e])return!1;return!0}static concat(...e){let t;t=!Array.isArray(e[0])||e[1]instanceof Function?Array.isArray(e[0])&&e[1]instanceof Function?e[0]:e[e.length-1]instanceof Function?e.slice(0,e.length-1):e:e[0];let r=0;for(const e of t)r+=e.byteLength;const i=new Uint8Array(r);let n=0;for(const e of t){const t=this.toUint8Array(e);i.set(t,n),n+=t.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const n="string",s=/^[0-9a-f]+$/i,o=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,a=/^[a-zA-Z0-9-_]+$/;class c{static fromString(e){const t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r.buffer}static toString(e){const t=i.toUint8Array(e);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return decodeURIComponent(escape(r))}}class u{static toString(e,t=!1){const r=i.toArrayBuffer(e),n=new DataView(r);let s="";for(let e=0;e<r.byteLength;e+=2){const r=n.getUint16(e,t);s+=String.fromCharCode(r)}return s}static fromString(e,t=!1){const r=new ArrayBuffer(2*e.length),i=new DataView(r);for(let r=0;r<e.length;r++)i.setUint16(2*r,e.charCodeAt(r),t);return r}}class l{static isHex(e){return typeof e===n&&s.test(e)}static isBase64(e){return typeof e===n&&o.test(e)}static isBase64Url(e){return typeof e===n&&a.test(e)}static ToString(e,t="utf8"){const r=i.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return u.toString(r,!0);case"utf16":case"utf16be":return u.toString(r);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 u.fromString(e,!0);case"utf16":case"utf16be":return u.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=i.toUint8Array(e);if("undefined"!=typeof btoa){const e=this.ToString(t,"binary");return btoa(e)}return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!l.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!=typeof atob?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(!l.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=l.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return c.fromString(e);case"utf16":case"utf16be":return u.fromString(e);case"utf16le":case"usc2":return u.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=l.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return c.toString(e);case"utf16":case"utf16be":return u.toString(e);case"utf16le":case"usc2":return u.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.charCodeAt(i);return r.buffer}static ToBinary(e){const t=i.toUint8Array(e);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return r}static ToHex(e){const t=i.toUint8Array(e);let r="";const n=t.length;for(let e=0;e<n;e++){const i=t[e];i<16&&(r+="0"),r+=i.toString(16)}return r}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!l.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const r=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2){const i=t.slice(e,e+2);r[e/2]=parseInt(i,16)}return r.buffer}static ToUtf16String(e,t=!1){return u.toString(e,t)}static FromUtf16String(e,t=!1){return u.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let r=0;r<t;r++)e+="=";return e}static formatString(e){return(null==e?void 0:e.replace(/[\n\r\t ]/g,""))||""}}function p(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==i[t])return!1;return!0}
/*!
Copyright (c) Peculiar Ventures, LLC
*/function h(e,t){let r=0;if(1===e.length)return e[0];for(let i=e.length-1;i>=0;i--)r+=e[e.length-1-i]*Math.pow(2,t*i);return r}function f(e,t,r=-1){const i=r;let n=e,s=0,o=Math.pow(2,t);for(let r=1;r<8;r++){if(e<o){let e;if(i<0)e=new ArrayBuffer(r),s=r;else{if(i<r)return new ArrayBuffer(0);e=new ArrayBuffer(i),s=i}const o=new Uint8Array(e);for(let e=r-1;e>=0;e--){const r=Math.pow(2,e*t);o[s-e-1]=Math.floor(n/r),n-=o[s-e-1]*r}return e}o*=Math.pow(2,t)}return new ArrayBuffer(0)}function y(...e){let t=0,r=0;for(const r of e)t+=r.length;const i=new ArrayBuffer(t),n=new Uint8Array(i);for(const t of e)n.set(t,r),r+=t.length;return n}function d(){const e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const t=255===e[0]&&128&e[1],r=0===e[0]&&0==(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)r[e]=0;r[0]=128&e[0];const i=h(r,8),n=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(n);for(let t=0;t<this.valueHex.byteLength;t++)s[t]=e[t];s[0]&=127;return h(s,8)-i}function g(e,t){const r=e.toString(10);if(t<r.length)return"";const i=t-r.length,n=new Array(i);for(let e=0;e<i;e++)n[e]="0";return n.join("").concat(r)}
/*!
* Copyright (c) 2014, GMO GlobalSign
* Copyright (c) 2015-2022, Peculiar Ventures
* All rights reserved.
*
* Author 2014-2019, Yury Strozhevsky
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/function v(){if("undefined"==typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function m(e){let t=0,r=0;for(let r=0;r<e.length;r++){t+=e[r].byteLength}const i=new Uint8Array(t);for(let t=0;t<e.length;t++){const n=e[t];i.set(new Uint8Array(n),r),r+=n.byteLength}return i.buffer}function w(e,t,r,i){return t instanceof Uint8Array?t.byteLength?r<0?(e.error="Wrong parameter: inputOffset less than zero",!1):i<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-r-i<0)||(e.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):(e.error="Wrong parameter: inputBuffer has zero length",!1):(e.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}l.DEFAULT_UTF8_ENCODING="utf8";class b{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return m(this.items)}}const A=[new Uint8Array([1])],S="0123456789",x="name",B="valueHexView",k="isHexOnly",E="idBlock",C="tagClass",O="tagNumber",I="isConstructed",N="fromBER",T="toBER",j="local",P="",U=new ArrayBuffer(0),R=new Uint8Array(0),D="EndOfContent",V="OCTET STRING",L="BIT STRING";function H(e){var t;return(t=class extends e{constructor(...e){var t;super(...e);const r=e[0]||{};this.isHexOnly=null!==(t=r.isHexOnly)&&void 0!==t&&t,this.valueHexView=r.valueHex?i.toUint8Array(r.valueHex):R}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}fromBER(e,t,r){const i=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!w(this,i,t,r))return-1;const n=t+r;return this.valueHexView=i.subarray(t,n),this.valueHexView.length?(this.blockLength=r,n):(this.warnings.push("Zero buffer length"),t)}toBER(e=!1){return this.isHexOnly?e?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",U)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:l.ToHex(this.valueHexView)}}}).NAME="hexBlock",t}class ${constructor({blockLength:e=0,error:t=P,warnings:r=[],valueBeforeDecode:n=R}={}){this.blockLength=e,this.error=t,this.warnings=r,this.valueBeforeDecodeView=i.toUint8Array(n)}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:l.ToHex(this.valueBeforeDecodeView)}}}$.NAME="baseBlock";class M extends ${fromBER(e,t,r){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'")}}M.NAME="valueBlock";class F extends(H($)){constructor({idBlock:e={}}={}){var t,r,n,s;super(),e?(this.isHexOnly=null!==(t=e.isHexOnly)&&void 0!==t&&t,this.valueHexView=e.valueHex?i.toUint8Array(e.valueHex):R,this.tagClass=null!==(r=e.tagClass)&&void 0!==r?r:-1,this.tagNumber=null!==(n=e.tagNumber)&&void 0!==n?n:-1,this.isConstructed=null!==(s=e.isConstructed)&&void 0!==s&&s):(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",U}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const r=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,r[0]=t}return r.buffer}if(!this.isHexOnly){const r=f(this.tagNumber,7),i=new Uint8Array(r),n=r.byteLength,s=new Uint8Array(n+1);if(s[0]=31|t,!e){for(let e=0;e<n-1;e++)s[e+1]=128|i[e];s[n]=i[n-1]}return s.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=31|t,!e){const e=this.valueHexView;for(let t=0;t<e.length-1;t++)r[t+1]=128|e[t];r[this.valueHexView.byteLength]=e[e.length-1]}return r.buffer}fromBER(e,t,r){const n=i.toUint8Array(e);if(!w(this,n,t,r))return-1;const s=n.subarray(t,t+r);if(0===s.length)return this.error="Zero buffer length",-1;switch(192&s[0]){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=32==(32&s[0]),this.isHexOnly=!1;const o=31&s[0];if(31!==o)this.tagNumber=o,this.blockLength=1;else{let e=1,t=this.valueHexView=new Uint8Array(255),r=255;for(;128&s[e];){if(t[e-1]=127&s[e],e++,e>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(e===r){r+=255;const e=new Uint8Array(r);for(let r=0;r<t.length;r++)e[r]=t[r];t=this.valueHexView=new Uint8Array(r)}}this.blockLength=e+1,t[e-1]=127&s[e];const i=new Uint8Array(e);for(let r=0;r<e;r++)i[r]=t[r];t=this.valueHexView=new Uint8Array(e),t.set(i),this.blockLength<=9?this.tagNumber=h(t,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&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}}}F.NAME="identificationBlock";class K extends ${constructor({lenBlock:e={}}={}){var t,r,i;super(),this.isIndefiniteForm=null!==(t=e.isIndefiniteForm)&&void 0!==t&&t,this.longFormUsed=null!==(r=e.longFormUsed)&&void 0!==r&&r,this.length=null!==(i=e.length)&&void 0!==i?i:0}fromBER(e,t,r){const n=i.toUint8Array(e);if(!w(this,n,t,r))return-1;const s=n.subarray(t,t+r);if(0===s.length)return this.error="Zero buffer length",-1;if(255===s[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===s[0],this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&s[0]),!1===this.longFormUsed)return this.length=s[0],this.blockLength=1,t+this.blockLength;const o=127&s[0];if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const a=t+1,c=n.subarray(a,a+o);return 0===c[o-1]&&this.warnings.push("Needlessly long encoded length"),this.length=h(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=128),t;if(this.longFormUsed){const i=f(this.length,8);if(i.byteLength>127)return this.error="Too big length",U;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const n=new Uint8Array(i);r=new Uint8Array(t),r[0]=128|i.byteLength;for(let e=0;e<i.byteLength;e++)r[e+1]=n[e];return t}return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}K.NAME="lengthBlock";const _={};class z extends ${constructor({name:e=P,optional:t=!1,primitiveSchema:r,...i}={},n){super(i),this.name=e,this.optional=t,r&&(this.primitiveSchema=r),this.idBlock=new F(i),this.lenBlock=new K(i),this.valueBlock=n?new n(i):new M(i)}fromBER(e,t,r){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===i?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){const r=t||new b;t||q(this);const i=this.idBlock.toBER(e);if(r.write(i),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;const i=this.lenBlock.toBER(e);r.write(i),r.write(t)}return t?U:r.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"ascii"===e?this.onAsciiEncoding():l.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${l.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;return function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let e=0;e<r.length;e++)if(r[e]!==i[e])return!1;return!0}(this.toBER(),e.toBER())}}function q(e){if(e instanceof _.Constructed)for(const t of e.valueBlock.value)q(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock.isIndefiniteForm}z.NAME="BaseBlock";class W extends z{constructor({value:e=P,...t}={},r){super(t,r),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,r){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===i?(this.error=this.valueBlock.error,i):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}W.NAME="BaseStringBlock";class G extends(H(M)){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}var J,X,Z,Y,Q,ee;G.NAME="PrimitiveValueBlock";class te extends z{constructor(e={}){super(e,G),this.idBlock.isConstructed=!1}}function re(e,t=0,r=e.length){const i=t;let n=new z({},M);const s=new $;if(!w(s,e,t,r))return n.error=s.error,{offset:-1,result:n};if(!e.subarray(t,t+r).length)return n.error="Zero buffer length",{offset:-1,result:n};let o=n.idBlock.fromBER(e,t,r);if(n.idBlock.warnings.length&&n.warnings.concat(n.idBlock.warnings),-1===o)return n.error=n.idBlock.error,{offset:-1,result:n};if(t=o,r-=n.idBlock.blockLength,o=n.lenBlock.fromBER(e,t,r),n.lenBlock.warnings.length&&n.warnings.concat(n.lenBlock.warnings),-1===o)return n.error=n.lenBlock.error,{offset:-1,result:n};if(t=o,r-=n.lenBlock.blockLength,!n.idBlock.isConstructed&&n.lenBlock.isIndefiniteForm)return n.error="Indefinite length form used for primitive encoding form",{offset:-1,result:n};let a=z;if(1===n.idBlock.tagClass){if(n.idBlock.tagNumber>=37&&!1===n.idBlock.isHexOnly)return n.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:n};switch(n.idBlock.tagNumber){case 0:if(n.idBlock.isConstructed&&n.lenBlock.length>0)return n.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:n};a=_.EndOfContent;break;case 1:a=_.Boolean;break;case 2:a=_.Integer;break;case 3:a=_.BitString;break;case 4:a=_.OctetString;break;case 5:a=_.Null;break;case 6:a=_.ObjectIdentifier;break;case 10:a=_.Enumerated;break;case 12:a=_.Utf8String;break;case 13:a=_.RelativeObjectIdentifier;break;case 14:a=_.TIME;break;case 15:return n.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:n};case 16:a=_.Sequence;break;case 17:a=_.Set;break;case 18:a=_.NumericString;break;case 19:a=_.PrintableString;break;case 20:a=_.TeletexString;break;case 21:a=_.VideotexString;break;case 22:a=_.IA5String;break;case 23:a=_.UTCTime;break;case 24:a=_.GeneralizedTime;break;case 25:a=_.GraphicString;break;case 26:a=_.VisibleString;break;case 27:a=_.GeneralString;break;case 28:a=_.UniversalString;break;case 29:a=_.CharacterString;break;case 30:a=_.BmpString;break;case 31:a=_.DATE;break;case 32:a=_.TimeOfDay;break;case 33:a=_.DateTime;break;case 34:a=_.Duration;break;default:{const e=n.idBlock.isConstructed?new _.Constructed:new _.Primitive;e.idBlock=n.idBlock,e.lenBlock=n.lenBlock,e.warnings=n.warnings,n=e}}}else a=n.idBlock.isConstructed?_.Constructed:_.Primitive;return n=function(e,t){if(e instanceof t)return e;const r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecodeView=e.valueBeforeDecodeView,r}(n,a),o=n.fromBER(e,t,n.lenBlock.isIndefiniteForm?r:n.lenBlock.length),n.valueBeforeDecodeView=e.subarray(i,i+n.blockLength),{offset:o,result:n}}function ie(e){if(!e.byteLength){const e=new z({},M);return e.error="Input buffer has zero length",{offset:-1,result:e}}return re(i.toUint8Array(e).slice(),0,e.byteLength)}J=te,_.Primitive=J,te.NAME="PRIMITIVE";class ne extends M{constructor({value:e=[],isIndefiniteForm:t=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,r){const n=i.toUint8Array(e);if(!w(this,n,t,r))return-1;if(this.valueBeforeDecodeView=n.subarray(t,t+r),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;let s=t;for(;o=this.isIndefiniteForm,a=r,(o?1:a)>0;){const e=re(n,s,r);if(-1===e.offset)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,r-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===D)break}var o,a;return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===D?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const r=t||new b;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,r);return t?U:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}ne.NAME="ConstructedValueBlock";class se extends z{constructor(e={}){super(e,ne),this.idBlock.isConstructed=!0}fromBER(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===i?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){const e=[];for(const t of this.valueBlock.value)e.push(t.toString("ascii").split("\n").map((e=>` ${e}`)).join("\n"));const t=3===this.idBlock.tagClass?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join("\n")}`:`${t} :`}}X=se,_.Constructed=X,se.NAME="CONSTRUCTED";class oe extends M{fromBER(e,t,r){return t}toBER(e){return U}}oe.override="EndOfContentValueBlock";class ae extends z{constructor(e={}){super(e,oe),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Z=ae,_.EndOfContent=Z,ae.NAME=D;class ce extends z{constructor(e={}){super(e,M),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,r){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+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}toBER(e,t){const r=new ArrayBuffer(2);if(!e){const e=new Uint8Array(r);e[0]=5,e[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}Y=ce,_.Null=Y,ce.NAME="NULL";class ue extends(H(M)){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=i.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,r){const n=i.toUint8Array(e);return w(this,n,t,r)?(this.valueHexView=n.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,d.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ue.NAME="BooleanValueBlock";class le extends z{constructor(e={}){super(e,ue),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}`}}Q=le,_.Boolean=Q,le.NAME="BOOLEAN";class pe extends(H(ne)){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=ne.prototype.fromBER.call(this,e,t,r),-1===i)return i;for(let e=0;e<this.value.length;e++){const t=this.value[e].constructor.NAME;if(t===D){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(t!==V)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,r),this.blockLength=r;return i}toBER(e,t){return this.isConstructed?ne.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}pe.NAME="OctetStringValueBlock";let he=class e extends z{constructor({idBlock:e={},lenBlock:t={},...r}={}){var i,n;null!==(i=r.isConstructed)&&void 0!==i||(r.isConstructed=!!(null===(n=r.value)||void 0===n?void 0:n.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},pe),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===r)return 0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+r);try{if(i.byteLength){const e=re(i,0,i.byteLength);-1!==e.offset&&e.offset===r&&(this.valueBlock.value=[e.result])}}catch(e){}}return super.fromBER(e,t,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?se.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${l.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const t=[];for(const r of this.valueBlock.value)r instanceof e&&t.push(r.valueBlock.valueHexView);return i.concat(t)}};ee=he,_.OctetString=ee,he.NAME=V;class fe extends(H(ne)){constructor({unusedBits:e=0,isConstructed:t=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,r){if(!r)return t;let n=-1;if(this.isConstructed){if(n=ne.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(const e of this.value){const t=e.constructor.NAME;if(t===D){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(t!==L)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const r=e.valueBlock;if(this.unusedBits>0&&r.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=r.unusedBits}return n}const s=i.toUint8Array(e);if(!w(this,s,t,r))return-1;const o=s.subarray(t,t+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const e=o.subarray(1);try{if(e.byteLength){const t=re(e,0,e.byteLength);-1!==t.offset&&t.offset===r-1&&(this.value=[t.result])}}catch(e){}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+r}toBER(e,t){if(this.isConstructed)return ne.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return U;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}var ye;fe.NAME="BitStringValueBlock";let de=class extends z{constructor({idBlock:e={},lenBlock:t={},...r}={}){var i,n;null!==(i=r.isConstructed)&&void 0!==i||(r.isConstructed=!!(null===(n=r.value)||void 0===n?void 0:n.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},fe),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return se.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const r of t)e.push(r.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};var ge,ve,me,we,be,Ae,Se;function xe(e,t){const r=new Uint8Array([0]),i=new Uint8Array(e),n=new Uint8Array(t);let s=i.slice(0);const o=s.length-1,a=n.slice(0),c=a.length-1;let u=0;let l=0;for(let e=c<o?o:c;e>=0;e--,l++){if(!0==l<a.length)u=s[o-l]+a[c-l]+r[0];else u=s[o-l]+r[0];if(r[0]=u/10,!0==l>=s.length)s=y(new Uint8Array([u%10]),s);else s[o-l]=u%10}return r[0]>0&&(s=y(r,s)),s}function Be(e){if(e>=A.length)for(let t=A.length;t<=e;t++){const e=new Uint8Array([0]);let r=A[t-1].slice(0);for(let t=r.length-1;t>=0;t--){const i=new Uint8Array([(r[t]<<1)+e[0]]);e[0]=i[0]/10,r[t]=i[0]%10}e[0]>0&&(r=y(e,r)),A.push(r)}return A[e]}function ke(e,t){let r=0;const i=new Uint8Array(e),n=new Uint8Array(t),s=i.slice(0),o=s.length-1,a=n.slice(0),c=a.length-1;let u,l=0;for(let e=c;e>=0;e--,l++)if(u=s[o-l]-a[c-l]-r,!0==u<0)r=1,s[o-l]=u+10;else r=0,s[o-l]=u;if(r>0)for(let e=o-c+1;e>=0;e--,l++){if(u=s[o-l]-r,!(u<0)){r=0,s[o-l]=u;break}r=1,s[o-l]=u+10}return s.slice()}ye=de,_.BitString=ye,de.NAME=L;class Ee extends(H(M)){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),void 0!==e&&(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=d.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(function(e){const t=e<0?-1*e:e;let r=128;for(let i=1;i<8;i++){if(t<=r){if(e<0){const e=f(r-t,8,i);return new Uint8Array(e)[0]|=128,e}let n=f(t,8,i),s=new Uint8Array(n);if(128&s[0]){const e=n.slice(0),t=new Uint8Array(e);n=new ArrayBuffer(n.byteLength+1),s=new Uint8Array(n);for(let r=0;r<e.byteLength;r++)s[r+1]=t[r];s[0]=0}return n}r*=Math.pow(2,8)}return new ArrayBuffer(0)}(e))}get valueDec(){return this._valueDec}fromDER(e,t,r,i=0){const n=this.fromBER(e,t,r);if(-1===n)return n;const s=this.valueHexView;return 0===s[0]&&0!=(128&s[1])?this.valueHexView=s.subarray(1):0!==i&&s.length<i&&(i-s.length>1&&(i=s.length+1),this.valueHexView=s.subarray(i-s.length)),n}toDER(e=!1){const t=this.valueHexView;switch(!0){case 0!=(128&t[0]):{const e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case 0===t[0]&&0==(128&t[1]):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,r){const i=super.fromBER(e,t,r);return-1===i||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=8*this.valueHexView.length-1;let t,r=new Uint8Array(8*this.valueHexView.length/3),i=0;const n=this.valueHexView;let s="",o=!1;for(let o=n.byteLength-1;o>=0;o--){t=n[o];for(let n=0;n<8;n++){if(1==(1&t))if(i===e)r=ke(Be(i),r),s="-";else r=xe(r,Be(i));i++,t>>=1}}for(let e=0;e<r.length;e++)r[e]&&(o=!0),o&&(s+=S.charAt(r[e]));return!1===o&&(s+=S.charAt(0)),s}}ge=Ee,Ee.NAME="IntegerValueBlock",Object.defineProperty(ge.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class Ce extends z{constructor(e={}){super(e,Ee),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return v(),BigInt(this.valueBlock.toString())}static fromBigInt(e){v();const t=BigInt(e),r=new b,n=t.toString(16).replace(/^-/,""),s=new Uint8Array(l.FromHex(n));if(t<0){const e=new Uint8Array(s.length+(128&s[0]?1:0));e[0]|=128;const n=BigInt(`0x${l.ToHex(e)}`)+t,o=i.toUint8Array(l.FromHex(n.toString(16)));o[0]|=128,r.write(o)}else 128&s[0]&&r.write(new Uint8Array([0])),r.write(s);return new Ce({valueHex:r.final()})}convertToDER(){const e=new Ce({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Ce({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}ve=Ce,_.Integer=ve,Ce.NAME="INTEGER";class Oe extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}me=Oe,_.Enumerated=me,Oe.NAME="ENUMERATED";class Ie extends(H(M)){constructor({valueDec:e=-1,isFirstSid:t=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,r){if(!r)return t;const n=i.toUint8Array(e);if(!w(this,n,t,r))return-1;const s=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let e=0;e<r&&(this.valueHexView[e]=127&s[e],this.blockLength++,0!=(128&s[e]));e++);const o=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)o[e]=this.valueHexView[e];return this.valueHexView=o,0!=(128&s[this.blockLength-1])?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=h(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){v();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const r=new Uint8Array(t.length/7);for(let e=0;e<r.length;e++)r[e]=parseInt(t.slice(7*e,7*e+7),2)+(e+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=f(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",U;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),i=t.byteLength-1;for(let t=0;t<i;t++)r[t]=128|e[t];r[i]=e[i]}return r}toString(){let e="";if(this.isHexOnly)e=l.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}}}Ie.NAME="sidBlock";class Ne extends M{constructor({value:e=P,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let i=t;for(;r>0;){const t=new Ie;if(i=t.fromBER(e,i,r),-1===i)return this.blockLength=0,this.error=t.error,i;0===this.value.length&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return i}toBER(e){const t=[];for(let r=0;r<this.value.length;r++){const i=this.value[r].toBER(e);if(0===i.byteLength)return this.error=this.value[r].error,U;t.push(i)}return m(t)}fromString(e){this.value=[];let t=0,r=0,i="",n=!1;do{if(r=e.indexOf(".",t),i=-1===r?e.substring(t):e.substring(t,r),t=r+1,n){const e=this.value[0];let t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:return void(this.value=[])}const r=parseInt(i,10);if(isNaN(r))return;e.valueDec=r+t,n=!1}else{const e=new Ie;if(i>Number.MAX_SAFE_INTEGER){v();const t=BigInt(i);e.valueBigInt=t}else if(e.valueDec=parseInt(i,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,n=!0),this.value.push(e)}}while(-1!==r)}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let i=this.value[r].toString();0!==r&&(e=`${e}.`),t?(i=`{${i}}`,this.value[r].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Ne.NAME="ObjectIdentifierValueBlock";class Te extends z{constructor(e={}){super(e,Ne),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()}}}we=Te,_.ObjectIdentifier=we,Te.NAME="OBJECT IDENTIFIER";class je extends(H($)){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,r){if(0===r)return t;const n=i.toUint8Array(e);if(!w(this,n,t,r))return-1;const s=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let e=0;e<r&&(this.valueHexView[e]=127&s[e],this.blockLength++,0!=(128&s[e]));e++);const o=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)o[e]=this.valueHexView[e];return this.valueHexView=o,0!=(128&s[this.blockLength-1])?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=h(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 t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=f(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",U;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),i=t.byteLength-1;for(let t=0;t<i;t++)r[t]=128|e[t];r[i]=e[i]}return r.buffer}toString(){let e="";return e=this.isHexOnly?l.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}je.NAME="relativeSidBlock";class Pe extends M{constructor({value:e=P,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let i=t;for(;r>0;){const t=new je;if(i=t.fromBER(e,i,r),-1===i)return this.blockLength=0,this.error=t.error,i;this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return i}toBER(e,t){const r=[];for(let t=0;t<this.value.length;t++){const i=this.value[t].toBER(e);if(0===i.byteLength)return this.error=this.value[t].error,U;r.push(i)}return m(r)}fromString(e){this.value=[];let t=0,r=0,i="";do{r=e.indexOf(".",t),i=-1===r?e.substring(t):e.substring(t,r),t=r+1;const n=new je;if(n.valueDec=parseInt(i,10),isNaN(n.valueDec))return!0;this.value.push(n)}while(-1!==r);return!0}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let i=this.value[r].toString();0!==r&&(e=`${e}.`),t?(i=`{${i}}`,e+=i):e+=i}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}Pe.NAME="RelativeObjectIdentifierValueBlock";class Ue extends z{constructor(e={}){super(e,Pe),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()}}}be=Ue,_.RelativeObjectIdentifier=be,Ue.NAME="RelativeObjectIdentifier";class Re extends se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}Ae=Re,_.Sequence=Ae,Re.NAME="SEQUENCE";let De=class extends se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Se=De,_.Set=Se,De.NAME="SET";class Ve extends(H(M)){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=P}toJSON(){return{...super.toJSON(),value:this.value}}}Ve.NAME="StringValueBlock";class Le extends Ve{}Le.NAME="SimpleStringValueBlock";class He extends W{constructor({...e}={}){super(e,Le)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,i.toUint8Array(e))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.charCodeAt(i);this.valueBlock.value=e}}He.NAME="SIMPLE STRING";class $e extends He{fromBuffer(e){this.valueBlock.valueHexView=i.toUint8Array(e);try{this.valueBlock.value=l.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=l.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(l.FromUtf8String(e)),this.valueBlock.value=e}}var Me,Fe,Ke,_e,ze,qe,We,Ge,Je,Xe,Ze,Ye,Qe,et,tt,rt,it,nt,st;$e.NAME="Utf8StringValueBlock";class ot extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Me=ot,_.Utf8String=Me,ot.NAME="UTF8String";class at extends He{fromBuffer(e){this.valueBlock.value=l.ToUtf16String(e),this.valueBlock.valueHexView=i.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(l.FromUtf16String(e))}}at.NAME="BmpStringValueBlock";class ct extends at{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Fe=ct,_.BmpString=Fe,ct.NAME="BMPString";class ut extends He{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(t);for(let e=0;e<r.length;e+=4)r[e]=r[e+3],r[e+1]=r[e+2],r[e+2]=0,r[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(4*t);for(let i=0;i<t;i++){const t=f(e.charCodeAt(i),8),n=new Uint8Array(t);if(n.length>4)continue;const s=4-n.length;for(let e=n.length-1;e>=0;e--)r[4*i+e+s]=n[e]}this.valueBlock.value=e}}ut.NAME="UniversalStringValueBlock";class lt extends ut{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Ke=lt,_.UniversalString=Ke,lt.NAME="UniversalString";class pt extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}_e=pt,_.NumericString=_e,pt.NAME="NumericString";class ht extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}ze=ht,_.PrintableString=ze,ht.NAME="PrintableString";class ft extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}qe=ft,_.TeletexString=qe,ft.NAME="TeletexString";class yt extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}We=yt,_.VideotexString=We,yt.NAME="VideotexString";class dt extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Ge=dt,_.IA5String=Ge,dt.NAME="IA5String";class gt extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Je=gt,_.GraphicString=Je,gt.NAME="GraphicString";class vt extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Xe=vt,_.VisibleString=Xe,vt.NAME="VisibleString";class mt extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ze=mt,_.GeneralString=Ze,mt.NAME="GeneralString";class wt extends He{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Ye=wt,_.CharacterString=Ye,wt.NAME="CharacterString";class bt extends vt{constructor({value:e,valueDate:t,...r}={}){if(super(r),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 t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}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,i.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(null===t)return void(this.error="Wrong input string for conversion");const r=parseInt(t[1],10);this.year=r>=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e="iso"){if("iso"===e){const e=new Array(7);return e[0]=g(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=g(this.month,2),e[2]=g(this.day,2),e[3]=g(this.hour,2),e[4]=g(this.minute,2),e[5]=g(this.second,2),e[6]="Z",e.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}}}Qe=bt,_.UTCTime=Qe,bt.NAME="UTCTime";class At extends bt{constructor(e={}){var t;super(e),null!==(t=this.millisecond)&&void 0!==t||(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,r=!1,i="",n="",s=0,o=0,a=0;if("Z"===e[e.length-1])i=e.substring(0,e.length-1),r=!0;else{const t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw new Error("Wrong input string for conversion");i=e}if(r){if(-1!==i.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==i.indexOf("-"))throw new Error("Wrong input string for conversion")}else{let e=1,t=i.indexOf("+"),r="";if(-1===t&&(t=i.indexOf("-"),e=-1),-1!==t){if(r=i.substring(t+1),i=i.substring(0,t),2!==r.length&&4!==r.length)throw new Error("Wrong input string for conversion");let n=parseInt(r.substring(0,2),10);if(isNaN(n.valueOf()))throw new Error("Wrong input string for conversion");if(o=e*n,4===r.length){if(n=parseInt(r.substring(2,4),10),isNaN(n.valueOf()))throw new Error("Wrong input string for conversion");a=e*n}}}let c=i.indexOf(".");if(-1===c&&(c=i.indexOf(",")),-1!==c){const e=new Number(`0${i.substring(c)}`);if(isNaN(e.valueOf()))throw new Error("Wrong input string for conversion");s=e.valueOf(),n=i.substring(0,c)}else n=i;switch(!0){case 8===n.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==c)throw new Error("Wrong input string for conversion");break;case 10===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*s;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 12===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*s;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 14===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){const e=1e3*s;this.millisecond=Math.floor(e)}break;default:throw new Error("Wrong input string for conversion")}const u=t.exec(n);if(null===u)throw new Error("Wrong input string for conversion");for(let e=1;e<u.length;e++)switch(e){case 1:this.year=parseInt(u[e],10);break;case 2:this.month=parseInt(u[e],10);break;case 3:this.day=parseInt(u[e],10);break;case 4:this.hour=parseInt(u[e],10)+o;break;case 5:this.minute=parseInt(u[e],10)+a;break;case 6:this.second=parseInt(u[e],10);break;default:throw new Error("Wrong input string for conversion")}if(!1===r){const e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(e="iso"){if("iso"===e){const e=[];return e.push(g(this.year,4)),e.push(g(this.month,2)),e.push(g(this.day,2)),e.push(g(this.hour,2)),e.push(g(this.minute,2)),e.push(g(this.second,2)),0!==this.millisecond&&(e.push("."),e.push(g(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}et=At,_.GeneralizedTime=et,At.NAME="GeneralizedTime";class St extends ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}tt=St,_.DATE=tt,St.NAME="DATE";class xt extends ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}rt=xt,_.TimeOfDay=rt,xt.NAME="TimeOfDay";class Bt extends ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}it=Bt,_.DateTime=it,Bt.NAME="DateTime";class kt extends ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}nt=kt,_.Duration=nt,kt.NAME="Duration";class Et extends ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}st=Et,_.TIME=st,Et.NAME="TIME";class Ct{constructor({name:e=P,optional:t=!1}={}){this.name=e,this.optional=t}}class Ot extends Ct{constructor({value:e=[],...t}={}){super(t),this.value=e}}class It extends Ct{constructor({value:e=new Ct,local:t=!1,...r}={}){super(r),this.value=e,this.local=t}}function Nt(e,t,r){if(r instanceof Ot){for(let i=0;i<r.value.length;i++){if(Nt(e,t,r.value[i]).verified)return{verified:!0,result:e}}{const e={verified:!1,result:{error:"Wrong values for Choice type"}};return r.hasOwnProperty(x)&&(e.name=r.name),e}}if(r instanceof Ct)return r.hasOwnProperty(x)&&(e[r.name]=t),{verified:!0,result:e};if(e instanceof Object==!1)return{verified:!1,result:{error:"Wrong root object"}};if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(r instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(E in r==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(N in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(T in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=r.idBlock.toBER(!1);if(0===i.byteLength)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(-1===r.idBlock.fromBER(i,0,i.byteLength))return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(!1===r.idBlock.hasOwnProperty(C))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty(O))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty(I))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!(k in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(r.idBlock.isHexOnly){if(B in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=r.idBlock.valueHexView,n=t.idBlock.valueHexView;if(i.length!==n.length)return{verified:!1,result:e};for(let t=0;t<i.length;t++)if(i[t]!==n[1])return{verified:!1,result:e}}if(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,P),r.name&&(e[r.name]=t)),r instanceof _.Constructed){let i=0,n={verified:!1,result:{error:"Unknown error"}},s=r.valueBlock.value.length;if(s>0&&r.valueBlock.value[0]instanceof It&&(s=t.valueBlock.value.length),0===s)return{verified:!0,result:e};if(0===t.valueBlock.value.length&&0!==r.valueBlock.value.length){let t=!0;for(let e=0;e<r.valueBlock.value.length;e++)t=t&&(r.valueBlock.value[e].optional||!1);return t?{verified:!0,result:e}:(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,P),r.name&&delete e[r.name]),e.error="Inconsistent object length",{verified:!1,result:e})}for(let o=0;o<s;o++)if(o-i>=t.valueBlock.value.length){if(!1===r.valueBlock.value[o].optional){const t={verified:!1,result:e};return e.error="Inconsistent length between ASN.1 data and schema",r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,P),r.name&&(delete e[r.name],t.name=r.name)),t}}else if(r.valueBlock.value[0]instanceof It){if(n=Nt(e,t.valueBlock.value[o],r.valueBlock.value[0].value),!1===n.verified){if(!r.valueBlock.value[0].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,P),r.name&&delete e[r.name]),n;i++}if(x in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){let i={};i=j in r.valueBlock.value[0]&&r.valueBlock.value[0].local?t:e,void 0===i[r.valueBlock.value[0].name]&&(i[r.valueBlock.value[0].name]=[]),i[r.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(n=Nt(e,t.valueBlock.value[o-i],r.valueBlock.value[o]),!1===n.verified){if(!r.valueBlock.value[o].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,P),r.name&&delete e[r.name]),n;i++}if(!1===n.verified){const t={verified:!1,result:e};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,P),r.name&&(delete e[r.name],t.name=r.name)),t}return{verified:!0,result:e}}if(r.primitiveSchema&&B in t.valueBlock){const i=re(t.valueBlock.valueHexView);if(-1===i.offset){const t={verified:!1,result:i.result};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,P),r.name&&(delete e[r.name],t.name=r.name)),t}return Nt(e,i.result,r.primitiveSchema)}return{verified:!0,result:e}}var Tt,jt,Pt=Object.freeze({__proto__:null,Any:Ct,BaseBlock:z,BaseStringBlock:W,BitString:de,BmpString:ct,Boolean:le,CharacterString:wt,Choice:Ot,Constructed:se,DATE:St,DateTime:Bt,Duration:kt,EndOfContent:ae,Enumerated:Oe,GeneralString:mt,GeneralizedTime:At,GraphicString:gt,HexBlock:H,IA5String:dt,Integer:Ce,Null:ce,NumericString:pt,ObjectIdentifier:Te,OctetString:he,Primitive:te,PrintableString:ht,RawData:class{constructor({data:e=R}={}){this.dataView=i.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=i.toUint8Array(e)}fromBER(e,t,r){const n=t+r;return this.dataView=i.toUint8Array(e).subarray(t,n),n}toBER(e){return this.dataView.slice().buffer}},RelativeObjectIdentifier:Ue,Repeated:It,Sequence:Re,Set:De,TIME:Et,TeletexString:ft,TimeOfDay:xt,UTCTime:bt,UniversalString:lt,Utf8String:ot,ValueBlock:M,VideotexString:yt,ViewWriter:b,VisibleString:vt,compareSchema:Nt,fromBER:ie,verifySchema:function(e,t){if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const r=re(i.toUint8Array(e));return-1===r.offset?{verified:!1,result:r.result}:Nt(r.result,r.result,t)}});!function(e){e[e.Sequence=0]="Sequence",e[e.Set=1]="Set",e[e.Choice=2]="Choice"}(Tt||(Tt={})),function(e){e[e.Any=1]="Any",e[e.Boolean=2]="Boolean",e[e.OctetString=3]="OctetString",e[e.BitString=4]="BitString",e[e.Integer=5]="Integer",e[e.Enumerated=6]="Enumerated",e[e.ObjectIdentifier=7]="ObjectIdentifier",e[e.Utf8String=8]="Utf8String",e[e.BmpString=9]="BmpString",e[e.UniversalString=10]="UniversalString",e[e.NumericString=11]="NumericString",e[e.PrintableString=12]="PrintableString",e[e.TeletexString=13]="TeletexString",e[e.VideotexString=14]="VideotexString",e[e.IA5String=15]="IA5String",e[e.GraphicString=16]="GraphicString",e[e.VisibleString=17]="VisibleString",e[e.GeneralString=18]="GeneralString",e[e.CharacterString=19]="CharacterString",e[e.UTCTime=20]="UTCTime",e[e.GeneralizedTime=21]="GeneralizedTime",e[e.DATE=22]="DATE",e[e.TimeOfDay=23]="TimeOfDay",e[e.DateTime=24]="DateTime",e[e.Duration=25]="Duration",e[e.TIME=26]="TIME",e[e.Null=27]="Null"}(jt||(jt={}));class Ut{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if("number"==typeof e)this.fromNumber(e);else{if(!i.isBufferSource(e))throw TypeError("Unsupported type of 'params' argument for BitString");this.unusedBits=t,this.value=i.toArrayBuffer(e)}}fromASN(e){if(!(e instanceof de))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 de({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new de({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const r of t)e+=r.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 r=t.length+7>>3;this.unusedBits=(r<<3)-t.length;const i=new Uint8Array(r);t=t.padStart(r<<3,"0").split("").reverse().join("");let n=0;for(;n<r;)i[n]=parseInt(t.slice(n<<3,8+(n<<3)),2),n++;this.value=i.buffer}}class Rt{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){"number"==typeof e?this.buffer=new ArrayBuffer(e):i.isBufferSource(e)?this.buffer=i.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof he))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new he({valueHex:this.buffer})}toSchema(e){return new he({name:e})}}const Dt={fromASN:e=>e instanceof ce?null:e.valueBeforeDecodeView,toASN:e=>{if(null===e)return new ce;const t=ie(e);if(t.result.error)throw new Error(t.result.error);return t.result}},Vt={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new Ce({value:+e})},Lt={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new Oe({value:e})},Ht={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Ce({valueHex:e})},$t={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new de({valueHex:e})},Mt={fromASN:e=>e.valueBlock.toString(),toASN:e=>new Te({value:e})},Ft={fromASN:e=>e.valueBlock.value,toASN:e=>new le({value:e})},Kt={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new he({valueHex:e})},_t={fromASN:e=>new Rt(e.getValue()),toASN:e=>e.toASN()};function zt(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}const qt=zt(ot),Wt=zt(ct),Gt=zt(lt),Jt=zt(pt),Xt=zt(ht),Zt=zt(ft),Yt=zt(yt),Qt=zt(dt),er=zt(gt),tr=zt(vt),rr=zt(mt),ir=zt(wt),nr={fromASN:e=>e.toDate(),toASN:e=>new bt({valueDate:e})},sr={fromASN:e=>e.toDate(),toASN:e=>new At({valueDate:e})},or={fromASN:()=>null,toASN:()=>new ce};function ar(e){switch(e){case jt.Any:return Dt;case jt.BitString:return $t;case jt.BmpString:return Wt;case jt.Boolean:return Ft;case jt.CharacterString:return ir;case jt.Enumerated:return Lt;case jt.GeneralString:return rr;case jt.GeneralizedTime:return sr;case jt.GraphicString:return er;case jt.IA5String:return Qt;case jt.Integer:return Vt;case jt.Null:return or;case jt.NumericString:return Jt;case jt.ObjectIdentifier:return Mt;case jt.OctetString:return Kt;case jt.PrintableString:return Xt;case jt.TeletexString:return Zt;case jt.UTCTime:return nr;case jt.UniversalString:return Gt;case jt.Utf8String:return qt;case jt.VideotexString:return Yt;case jt.VisibleString:return tr;default:return null}}function cr(e){return"function"==typeof e&&e.prototype?!(!e.prototype.toASN||!e.prototype.fromASN)||cr(e.prototype):!!(e&&"object"==typeof e&&"toASN"in e&&"fromASN"in e)}function ur(e){var t;if(e){const r=Object.getPrototypeOf(e);return(null===(t=null==r?void 0:r.prototype)||void 0===t?void 0:t.constructor)===Array||ur(r)}return!1}function lr(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==i[t])return!1;return!0}const pr=new class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:Tt.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(t,r),t.items=Object.assign({},t.items,r.items)),t}create(e,t){const r=this.items.get(e)||this.createDefault(e),i=[];for(const e in r.items){const n=r.items[e],s=t?e:"";let o;if("number"==typeof n.type){const e=jt[n.type],t=Pt[e];if(!t)throw new Error(`Cannot get ASN1 class by name '${e}'`);o=new t({name:s})}else if(cr(n.type)){o=(new n.type).toSchema(s)}else if(n.optional){this.get(n.type).type===Tt.Choice?o=new Ct({name:s}):(o=this.create(n.type,!1),o.name=s)}else o=new Ct({name:s});const a=!!n.optional||void 0!==n.defaultValue;if(n.repeated){o.name="";o=new("set"===n.repeated?De:Re)({name:"",value:[new It({name:s,value:o})]})}if(null!==n.context&&void 0!==n.context)if(n.implicit)if("number"==typeof n.type||cr(n.type)){const e=n.repeated?se:te;i.push(new e({name:s,optional:a,idBlock:{tagClass:3,tagNumber:n.context}}))}else{this.cache(n.type);const e=!!n.repeated;let t=e?o:this.get(n.type,!0).schema;t="valueBlock"in t?t.valueBlock.value:t.value,i.push(new se({name:e?"":s,optional:a,idBlock:{tagClass:3,tagNumber:n.context},value:t}))}else i.push(new se({optional:a,idBlock:{tagClass:3,tagNumber:n.context},value:[o]}));else o.optional=a,i.push(o)}switch(r.type){case Tt.Sequence:return new Re({value:i,name:""});case Tt.Set:return new De({value:i,name:""});case Tt.Choice:return new Ot({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);if(t){return this.items.get(t)||this.findParentSchema(t)}return null}},hr=e=>t=>{let r;pr.has(t)?r=pr.get(t):(r=pr.createDefault(t),pr.set(t,r)),Object.assign(r,e)},fr=e=>(t,r)=>{let i;pr.has(t.constructor)?i=pr.get(t.constructor):(i=pr.createDefault(t.constructor),pr.set(t.constructor,i));const n=Object.assign({},e);if("number"==typeof n.type&&!n.converter){const i=ar(e.type);if(!i)throw new Error(`Cannot get default converter for property '${r}' of ${t.constructor.name}`);n.converter=i}i.items[r]=n};class yr extends Error{constructor(){super(...arguments),this.schemas=[]}}class dr{static parse(e,t){const r=ie(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,t)}static fromASN(e,t){var r;try{if(cr(t)){return(new t).fromASN(e)}const i=pr.get(t);pr.cache(t);let n=i.schema;if(e.constructor===se&&i.type!==Tt.Choice){n=new se({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const t in i.items)delete e[t]}const s=Nt({},e,n);if(!s.verified)throw new yr(`Data does not match to ${t.name} ASN1 schema. ${s.result.error}`);const o=new t;if(ur(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 r=i.itemType;if("number"==typeof r){const i=ar(r);if(!i)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,(e=>i.fromASN(e)))}return t.from(e.valueBlock.value,(e=>this.fromASN(e,r)))}for(const e in i.items){const t=s.result[e];if(!t)continue;const n=i.items[e],a=n.type;if("number"==typeof a||cr(a)){const i=null!==(r=n.converter)&&void 0!==r?r:cr(a)?new a:null;if(!i)throw new Error("Converter is empty");if(n.repeated)if(n.implicit){const r=new("sequence"===n.repeated?Re:De);r.valueBlock=t.valueBlock;const s=ie(r.toBER(!1));if(-1===s.offset)throw new Error(`Cannot parse the child item. ${s.result.error}`);if(!("value"in s.result.valueBlock)||!Array.isArray(s.result.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const a=s.result.valueBlock.value;o[e]=Array.from(a,(e=>i.fromASN(e)))}else o[e]=Array.from(t,(e=>i.fromASN(e)));else{let r=t;if(n.implicit){let e;if(cr(a))e=(new a).toSchema("");else{const t=jt[a],r=Pt[t];if(!r)throw new Error(`Cannot get '${t}' class from asn1js module`);e=new r}e.valueBlock=r.valueBlock,r=ie(e.toBER(!1)).result}o[e]=i.fromASN(r)}}else if(n.repeated){if(!Array.isArray(t))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");o[e]=Array.from(t,(e=>this.fromASN(e,a)))}else o[e]=this.fromASN(t,a)}return o}catch(e){throw e instanceof yr&&e.schemas.push(t.name),e}}}class gr{static serialize(e){return e instanceof z?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&"object"==typeof e&&cr(e))return e.toASN();if(!e||"object"!=typeof e)throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,r=pr.get(t);pr.cache(t);let i,n=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if("number"==typeof r.itemType){const i=ar(r.itemType);if(!i)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);n=e.map((e=>i.toASN(e)))}else n=e.map((e=>this.toAsnItem({type:r.itemType},"[]",t,e)))}else for(const i in r.items){const s=r.items[i],o=e[i];if(void 0===o||s.defaultValue===o||"object"==typeof s.defaultValue&&"object"==typeof o&&lr(this.serialize(s.defaultValue),this.serialize(o)))continue;const a=gr.toAsnItem(s,i,t,o);if("number"==typeof s.context)if(s.implicit)if(s.repeated||"number"!=typeof s.type&&!cr(s.type))n.push(new se({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},value:a.valueBlock.value}));else{const e={};e.valueHex=a instanceof ce?a.valueBeforeDecodeView:a.valueBlock.toBER(),n.push(new te({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},...e}))}else n.push(new se({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},value:[a]}));else s.repeated?n=n.concat(a):n.push(a)}switch(r.type){case Tt.Sequence:i=new Re({value:n});break;case Tt.Set:i=new De({value:n});break;case Tt.Choice:if(!n[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);i=n[0]}return i}static toAsnItem(e,t,r,i){let n;if("number"==typeof e.type){const s=e.converter;if(!s)throw new Error(`Property '${t}' doesn't have converter for type ${jt[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(i,(e=>s.toASN(e)));n=new("sequence"===e.repeated?Re:De)({value:t})}else n=s.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(i,(e=>this.toASN(e)));n=new("sequence"===e.repeated?Re:De)({value:t})}else n=this.toASN(i);return n}}class vr extends Array{constructor(e=[]){if("number"==typeof e)super(e);else{super();for(const t of e)this.push(t)}}}class mr{static serialize(e){return gr.serialize(e)}static parse(e,t){return dr.parse(e,t)}static toString(e){const t=ie(i.isBufferSource(e)?i.toArrayBuffer(e):mr.serialize(e));if(-1===t.offset)throw new Error(`Cannot decode ASN.1 data. ${t.result.error}`);return t.result.toString()}}var wr=function(e,t){return wr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},wr(e,t)};function br(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}wr(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Ar(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function Sr(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function xr(e,t){var r,i,n,s,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function Br(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function kr(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function Er(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(kr(arguments[t]));return e}"function"==typeof SuppressedError&&SuppressedError;var Cr,Or={exports:{}};Cr=Or,function(e){const t="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),n=new RegExp("^0x[a-f0-9]+$","i"),s="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(s,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${s})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${s})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${t}\\.${t}\\.${t}\\.${t}(${s})?$`,"i")};function c(e,t){if(e.indexOf("::")!==e.lastIndexOf("::"))return null;let r,i,n=0,s=-1,o=(e.match(a.zoneIndex)||[])[0];for(o&&(o=o.substring(1),e=e.replace(/%.+$/,""));(s=e.indexOf(":",s+1))>=0;)n++;if("::"===e.substr(0,2)&&n--,"::"===e.substr(-2,2)&&n--,n>t)return null;for(i=t-n,r=":";i--;)r+="0:";return":"===(e=e.replace("::",r))[0]&&(e=e.slice(1)),":"===e[e.length-1]&&(e=e.slice(0,-1)),{parts:t=function(){const t=e.split(":"),r=[];for(let e=0;e<t.length;e++)r.push(parseInt(t[e],16));return r}(),zoneId:o}}function u(e,t,r,i){if(e.length!==t.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let n,s=0;for(;i>0;){if(n=r-i,n<0&&(n=0),e[s]>>n!=t[s]>>n)return!1;i-=r,s+=1}return!0}function l(e){if(n.test(e))return parseInt(e,16);if("0"===e[0]&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw new Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function p(e,t){for(;e.length<t;)e=`0${e}`;return e}const h={};h.IPv4=function(){function e(e){if(4!==e.length)throw new Error("ipaddr: ipv4 octet count should be 4");let t,r;for(t=0;t<e.length;t++)if(r=e[t],!(0<=r&&r<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=e}return e.prototype.SpecialRanges={unspecified:[[new e([0,0,0,0]),8]],broadcast:[[new e([255,255,255,255]),32]],multicast:[[new e([224,0,0,0]),4]],linkLocal:[[new e([169,254,0,0]),16]],loopback:[[new e([127,0,0,0]),8]],carrierGradeNat:[[new e([100,64,0,0]),10]],private:[[new e([10,0,0,0]),8],[new e([172,16,0,0]),12],[new e([192,168,0,0]),16]],reserved:[[new e([192,0,0,0]),24],[new e([192,0,2,0]),24],[new e([192,88,99,0]),24],[new e([198,18,0,0]),15],[new e([198,51,100,0]),24],[new e([203,0,113,0]),24],[new e([240,0,0,0]),4]]},e.prototype.kind=function(){return"ipv4"},e.prototype.match=function(e,t){let r;if(void 0===t&&(r=e,e=r[0],t=r[1]),"ipv4"!==e.kind())throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return u(this.octets,e.octets,8,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1;const r={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let i,n,s;for(i=3;i>=0;i-=1){if(n=this.octets[i],!(n in r))return null;if(s=r[n],t&&0!==s)return null;8!==s&&(t=!0),e+=s}return 32-e},e.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return h.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(".")},e}(),h.IPv4.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),i=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),n=[];let s=0;for(;s<4;)n.push(parseInt(r[s],10)|255^parseInt(i[s],10)),s++;return new this(n)}catch(e){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.isIPv4=function(e){return null!==this.parser(e)},h.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch(e){return!1}},h.IPv4.isValidFourPartDecimal=function(e){return!(!h.IPv4.isValid(e)||!e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},h.IPv4.networkAddressFromCIDR=function(e){let t,r,i,n,s;try{for(t=this.parseCIDR(e),i=t[0].toByteArray(),s=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),n=[],r=0;r<4;)n.push(parseInt(i[r],10)&parseInt(s[r],10)),r++;return new this(n)}catch(e){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.parse=function(e){const t=this.parser(e);if(null===t)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(t)},h.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){const e=parseInt(t[2]);if(e>=0&&e<=32){const r=[this.parse(t[1]),e];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},h.IPv4.parser=function(e){let t,i,n;if(t=e.match(r.fourOctet))return function(){const e=t.slice(1,6),r=[];for(let t=0;t<e.length;t++)i=e[t],r.push(l(i));return r}();if(t=e.match(r.longValue)){if(n=l(t[1]),n>4294967295||n<0)throw new Error("ipaddr: address outside defined range");return function(){const e=[];let t;for(t=0;t<=24;t+=8)e.push(n>>t&255);return e}().reverse()}return(t=e.match(r.twoOctet))?function(){const e=t.slice(1,4),r=[];if(n=l(e[1]),n>16777215||n<0)throw new Error("ipaddr: address outside defined range");return r.push(l(e[0])),r.push(n>>16&255),r.push(n>>8&255),r.push(255&n),r}():(t=e.match(r.threeOctet))?function(){const e=t.slice(1,5),r=[];if(n=l(e[2]),n>65535||n<0)throw new Error("ipaddr: address outside defined range");return r.push(l(e[0])),r.push(l(e[1])),r.push(n>>8&255),r.push(255&n),r}():null},h.IPv4.subnetMaskFromPrefixLength=function(e){if((e=parseInt(e))<0||e>32)throw new Error("ipaddr: invalid IPv4 prefix length");const t=[0,0,0,0];let r=0;const i=Math.floor(e/8);for(;r<i;)t[r]=255,r++;return i<4&&(t[i]=Math.pow(2,e%8)-1<<8-e%8),new this(t)},h.IPv6=function(){function e(e,t){let r,i;if(16===e.length)for(this.parts=[],r=0;r<=14;r+=2)this.parts.push(e[r]<<8|e[r+1]);else{if(8!==e.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=e}for(r=0;r<this.parts.length;r++)if(i=this.parts[r],!(0<=i&&i<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");t&&(this.zoneId=t)}return e.prototype.SpecialRanges={unspecified:[new e([0,0,0,0,0,0,0,0]),128],linkLocal:[new e([65152,0,0,0,0,0,0,0]),10],multicast:[new e([65280,0,0,0,0,0,0,0]),8],loopback:[new e([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new e([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new e([0,0,0,0,0,65535,0,0]),96],rfc6145:[new e([0,0,0,0,65535,0,0,0]),96],rfc6052:[new e([100,65435,0,0,0,0,0,0]),96],"6to4":[new e([8194,0,0,0,0,0,0,0]),16],teredo:[new e([8193,0,0,0,0,0,0,0]),32],reserved:[[new e([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new e([8193,2,0,0,0,0,0,0]),48],amt:[new e([8193,3,0,0,0,0,0,0]),32],as112v6:[new e([8193,4,274,0,0,0,0,0]),48],deprecated:[new e([8193,16,0,0,0,0,0,0]),28],orchid2:[new e([8193,32,0,0,0,0,0,0]),28]},e.prototype.isIPv4MappedAddress=function(){return"ipv4Mapped"===this.range()},e.prototype.kind=function(){return"ipv6"},e.prototype.match=function(e,t){let r;if(void 0===t&&(r=e,e=r[0],t=r[1]),"ipv6"!==e.kind())throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return u(this.parts,e.parts,16,t)},e.prototype.prefixLengthFromSubnetMask=function(){let e=0,t=!1;const r={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 i,n;for(let s=7;s>=0;s-=1){if(i=this.parts[s],!(i in r))return null;if(n=r[i],t&&0!==n)return null;16!==n&&(t=!0),e+=n}return 128-e},e.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e;const t=[],r=this.parts;for(let i=0;i<r.length;i++)e=r[i],t.push(e>>8),t.push(255&e);return t},e.prototype.toFixedLengthString=function(){const e=function(){const e=[];for(let t=0;t<this.parts.length;t++)e.push(p(this.parts[t].toString(16),4));return e}.call(this).join(":");let t="";return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const e=this.parts.slice(-2),t=e[0],r=e[1];return new h.IPv4([t>>8,255&t,r>>8,255&r])},e.prototype.toNormalizedString=function(){const e=function(){const e=[];for(let t=0;t<this.parts.length;t++)e.push(this.parts[t].toString(16));return e}.call(this).join(":");let t="";return this.zoneId&&(t=`%${this.zoneId}`),e+t},e.prototype.toRFC5952String=function(){const e=/((^|:)(0(:|$)){2,})/g,t=this.toNormalizedString();let r,i=0,n=-1;for(;r=e.exec(t);)r[0].length>n&&(i=r.index,n=r[0].length);return n<0?t:`${t.substring(0,i)}::${t.substring(i+n)}`},e.prototype.toString=function(){return this.toRFC5952String()},e}(),h.IPv6.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),i=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),n=[];let s=0;for(;s<16;)n.push(parseInt(r[s],10)|255^parseInt(i[s],10)),s++;return new this(n)}catch(e){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},h.IPv6.isIPv6=function(e){return null!==this.parser(e)},h.IPv6.isValid=function(e){if("string"==typeof e&&-1===e.indexOf(":"))return!1;try{const t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch(e){return!1}},h.IPv6.networkAddressFromCIDR=function(e){let t,r,i,n,s;try{for(t=this.parseCIDR(e),i=t[0].toByteArray(),s=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),n=[],r=0;r<16;)n.push(parseInt(i[r],10)&parseInt(s[r],10)),r++;return new this(n)}catch(e){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},h.IPv6.parse=function(e){const t=this.parser(e);if(null===t.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(t.parts,t.zoneId)},h.IPv6.parseCIDR=function(e){let t,r,i;if((r=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(r[2]),t>=0&&t<=128))return i=[this.parse(r[1]),t],Object.defineProperty(i,"toString",{value:function(){return this.join("/")}}),i;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},h.IPv6.parser=function(e){let t,r,i,n,s,o;if(i=e.match(a.deprecatedTransitional))return this.parser(`::ffff:${i[1]}`);if(a.native.test(e))return c(e,8);if((i=e.match(a.transitional))&&(o=i[6]||"",t=c(i[1].slice(0,-1)+o,6),t.parts)){for(s=[parseInt(i[2]),parseInt(i[3]),parseInt(i[4]),parseInt(i[5])],r=0;r<s.length;r++)if(n=s[r],!(0<=n&&n<=255))return null;return t.parts.push(s[0]<<8|s[1]),t.parts.push(s[2]<<8|s[3]),{parts:t.parts,zoneId:t.zoneId}}return null},h.IPv6.subnetMaskFromPrefixLength=function(e){if((e=parseInt(e))<0||e>128)throw new Error("ipaddr: invalid IPv6 prefix length");const t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const i=Math.floor(e/8);for(;r<i;)t[r]=255,r++;return i<16&&(t[i]=Math.pow(2,e%8)-1<<8-e%8),new this(t)},h.fromByteArray=function(e){const t=e.length;if(4===t)return new h.IPv4(e);if(16===t)return new h.IPv6(e);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},h.isValid=function(e){return h.IPv6.isValid(e)||h.IPv4.isValid(e)},h.parse=function(e){if(h.IPv6.isValid(e))return h.IPv6.parse(e);if(h.IPv4.isValid(e))return h.IPv4.parse(e);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},h.parseCIDR=function(e){try{return h.IPv6.parseCIDR(e)}catch(t){try{return h.IPv4.parseCIDR(e)}catch(e){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},h.process=function(e){const t=this.parse(e);return"ipv6"===t.kind()&&t.isIPv4MappedAddress()?t.toIPv4Address():t},h.subnetMatch=function(e,t,r){let i,n,s,o;for(n in null==r&&(r="unicast"),t)if(Object.prototype.hasOwnProperty.call(t,n))for(s=t[n],!s[0]||s[0]instanceof Array||(s=[s]),i=0;i<s.length;i++)if(o=s[i],e.kind()===o[0].kind()&&e.match.apply(e,o))return n;return r},Cr.exports?Cr.exports=h:e.ipaddr=h}(r);var Ir,Nr,Tr,jr=Or.exports;class Pr{static decodeIP(e){if(64===e.length&&0===parseInt(e,16))return"::/0";if(16!==e.length)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce(((e,t)=>e+ +t),0);let r=e.slice(0,8).replace(/(.{2})/g,(e=>`${parseInt(e,16)}.`));return r=r.slice(0,-1),`${r}/${t}`}static toString(e){if(4===e.byteLength||16===e.byteLength){const t=new Uint8Array(e);return jr.fromByteArray(Array.from(t)).toString()}return this.decodeIP(l.ToHex(e))}static fromString(e){const t=jr.parse(e);return new Uint8Array(t.toByteArray()).buffer}}let Ur=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};Ar([fr({type:jt.TeletexString})],Ur.prototype,"teletexString",void 0),Ar([fr({type:jt.PrintableString})],Ur.prototype,"printableString",void 0),Ar([fr({type:jt.UniversalString})],Ur.prototype,"universalString",void 0),Ar([fr({type:jt.Utf8String})],Ur.prototype,"utf8String",void 0),Ar([fr({type:jt.BmpString})],Ur.prototype,"bmpString",void 0),Ur=Ar([hr({type:Tt.Choice})],Ur);let Rr=class extends Ur{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?l.ToHex(this.anyValue):super.toString())}};Ar([fr({type:jt.IA5String})],Rr.prototype,"ia5String",void 0),Ar([fr({type:jt.Any})],Rr.prototype,"anyValue",void 0),Rr=Ar([hr({type:Tt.Choice})],Rr);class Dr{constructor(e={}){this.type="",this.value=new Rr,Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],Dr.prototype,"type",void 0),Ar([fr({type:Rr})],Dr.prototype,"value",void 0);let Vr=Ir=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Ir.prototype)}};Vr=Ir=Ar([hr({type:Tt.Set,itemType:Dr})],Vr);let Lr=Nr=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Nr.prototype)}};Lr=Nr=Ar([hr({type:Tt.Sequence,itemType:Vr})],Lr);let Hr=Tr=class extends Lr{constructor(e){super(e),Object.setPrototypeOf(this,Tr.prototype)}};Hr=Tr=Ar([hr({type:Tt.Sequence})],Hr);const $r={fromASN:e=>Pr.toString(Kt.fromASN(e)),toASN:e=>Kt.toASN(Pr.fromString(e))};class Mr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],Mr.prototype,"typeId",void 0),Ar([fr({type:jt.Any,context:0})],Mr.prototype,"value",void 0);class Fr{constructor(e={}){this.partyName=new Ur,Object.assign(this,e)}}Ar([fr({type:Ur,optional:!0,context:0,implicit:!0})],Fr.prototype,"nameAssigner",void 0),Ar([fr({type:Ur,context:1,implicit:!0})],Fr.prototype,"partyName",void 0);let Kr=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:Mr,context:0,implicit:!0})],Kr.prototype,"otherName",void 0),Ar([fr({type:jt.IA5String,context:1,implicit:!0})],Kr.prototype,"rfc822Name",void 0),Ar([fr({type:jt.IA5String,context:2,implicit:!0})],Kr.prototype,"dNSName",void 0),Ar([fr({type:jt.Any,context:3,implicit:!0})],Kr.prototype,"x400Address",void 0),Ar([fr({type:Hr,context:4,implicit:!1})],Kr.prototype,"directoryName",void 0),Ar([fr({type:Fr,context:5})],Kr.prototype,"ediPartyName",void 0),Ar([fr({type:jt.IA5String,context:6,implicit:!0})],Kr.prototype,"uniformResourceIdentifier",void 0),Ar([fr({type:jt.OctetString,context:7,implicit:!0,converter:$r})],Kr.prototype,"iPAddress",void 0),Ar([fr({type:jt.ObjectIdentifier,context:8,implicit:!0})],Kr.prototype,"registeredID",void 0),Kr=Ar([hr({type:Tt.Choice})],Kr);const _r="1.3.6.1.5.5.7.3",zr="2.5.29";var qr;class Wr{constructor(e={}){this.accessMethod="",this.accessLocation=new Kr,Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],Wr.prototype,"accessMethod",void 0),Ar([fr({type:Kr})],Wr.prototype,"accessLocation",void 0);let Gr=qr=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,qr.prototype)}};Gr=qr=Ar([hr({type:Tt.Sequence,itemType:Wr})],Gr);const Jr=`${zr}.35`;class Xr extends Rt{}class Zr{constructor(e={}){e&&Object.assign(this,e)}}Ar([fr({type:Xr,context:0,optional:!0,implicit:!0})],Zr.prototype,"keyIdentifier",void 0),Ar([fr({type:Kr,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Zr.prototype,"authorityCertIssuer",void 0),Ar([fr({type:jt.Integer,context:2,optional:!0,implicit:!0,converter:Ht})],Zr.prototype,"authorityCertSerialNumber",void 0);const Yr=`${zr}.19`;class Qr{constructor(e={}){this.cA=!1,Object.assign(this,e)}}var ei;Ar([fr({type:jt.Boolean,defaultValue:!1})],Qr.prototype,"cA",void 0),Ar([fr({type:jt.Integer,optional:!0})],Qr.prototype,"pathLenConstraint",void 0);let ti=ei=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,ei.prototype)}};var ri;ti=ei=Ar([hr({type:Tt.Sequence,itemType:Kr})],ti);const ii=`${zr}.29`;let ni=ri=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,ri.prototype)}};var si;ni=ri=Ar([hr({type:Tt.Sequence})],ni);const oi=`${zr}.32`;let ai=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};Ar([fr({type:jt.IA5String})],ai.prototype,"ia5String",void 0),Ar([fr({type:jt.VisibleString})],ai.prototype,"visibleString",void 0),Ar([fr({type:jt.BmpString})],ai.prototype,"bmpString",void 0),Ar([fr({type:jt.Utf8String})],ai.prototype,"utf8String",void 0),ai=Ar([hr({type:Tt.Choice})],ai);class ci{constructor(e={}){this.organization=new ai,this.noticeNumbers=[],Object.assign(this,e)}}Ar([fr({type:ai})],ci.prototype,"organization",void 0),Ar([fr({type:jt.Integer,repeated:"sequence"})],ci.prototype,"noticeNumbers",void 0);class ui{constructor(e={}){Object.assign(this,e)}}Ar([fr({type:ci,optional:!0})],ui.prototype,"noticeRef",void 0),Ar([fr({type:ai,optional:!0})],ui.prototype,"explicitText",void 0);let li=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:jt.IA5String})],li.prototype,"cPSuri",void 0),Ar([fr({type:ui})],li.prototype,"userNotice",void 0),li=Ar([hr({type:Tt.Choice})],li);class pi{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],pi.prototype,"policyQualifierId",void 0),Ar([fr({type:jt.Any})],pi.prototype,"qualifier",void 0);class hi{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],hi.prototype,"policyIdentifier",void 0),Ar([fr({type:pi,repeated:"sequence",optional:!0})],hi.prototype,"policyQualifiers",void 0);let fi=si=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,si.prototype)}};fi=si=Ar([hr({type:Tt.Sequence,itemType:hi})],fi);let yi=class{constructor(e=0){this.value=e}};Ar([fr({type:jt.Integer})],yi.prototype,"value",void 0),yi=Ar([hr({type:Tt.Choice})],yi);let di=class extends yi{};var gi,vi;di=Ar([hr({type:Tt.Choice})],di),function(e){e[e.unused=1]="unused",e[e.keyCompromise=2]="keyCompromise",e[e.cACompromise=4]="cACompromise",e[e.affiliationChanged=8]="affiliationChanged",e[e.superseded=16]="superseded",e[e.cessationOfOperation=32]="cessationOfOperation",e[e.certificateHold=64]="certificateHold",e[e.privilegeWithdrawn=128]="privilegeWithdrawn",e[e.aACompromise=256]="aACompromise"}(vi||(vi={}));class mi extends Ut{toJSON(){const e=[],t=this.toNumber();return t&vi.aACompromise&&e.push("aACompromise"),t&vi.affiliationChanged&&e.push("affiliationChanged"),t&vi.cACompromise&&e.push("cACompromise"),t&vi.certificateHold&&e.push("certificateHold"),t&vi.cessationOfOperation&&e.push("cessationOfOperation"),t&vi.keyCompromise&&e.push("keyCompromise"),t&vi.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&vi.superseded&&e.push("superseded"),t&vi.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let wi=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:Kr,context:0,repeated:"sequence",implicit:!0})],wi.prototype,"fullName",void 0),Ar([fr({type:Vr,context:1,implicit:!0})],wi.prototype,"nameRelativeToCRLIssuer",void 0),wi=Ar([hr({type:Tt.Choice})],wi);class bi{constructor(e={}){Object.assign(this,e)}}Ar([fr({type:wi,context:0,optional:!0})],bi.prototype,"distributionPoint",void 0),Ar([fr({type:mi,context:1,optional:!0,implicit:!0})],bi.prototype,"reasons",void 0),Ar([fr({type:Kr,context:2,optional:!0,repeated:"sequence",implicit:!0})],bi.prototype,"cRLIssuer",void 0);let Ai=gi=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,gi.prototype)}};var Si;Ai=gi=Ar([hr({type:Tt.Sequence,itemType:bi})],Ai);let xi=Si=class extends Ai{constructor(e){super(e),Object.setPrototypeOf(this,Si.prototype)}};xi=Si=Ar([hr({type:Tt.Sequence,itemType:bi})],xi);class Bi{constructor(e={}){this.onlyContainsUserCerts=Bi.ONLY,this.onlyContainsCACerts=Bi.ONLY,this.indirectCRL=Bi.ONLY,this.onlyContainsAttributeCerts=Bi.ONLY,Object.assign(this,e)}}Bi.ONLY=!1,Ar([fr({type:wi,context:0,optional:!0})],Bi.prototype,"distributionPoint",void 0),Ar([fr({type:jt.Boolean,context:1,defaultValue:Bi.ONLY,implicit:!0})],Bi.prototype,"onlyContainsUserCerts",void 0),Ar([fr({type:jt.Boolean,context:2,defaultValue:Bi.ONLY,implicit:!0})],Bi.prototype,"onlyContainsCACerts",void 0),Ar([fr({type:mi,context:3,optional:!0,implicit:!0})],Bi.prototype,"onlySomeReasons",void 0),Ar([fr({type:jt.Boolean,context:4,defaultValue:Bi.ONLY,implicit:!0})],Bi.prototype,"indirectCRL",void 0),Ar([fr({type:jt.Boolean,context:5,defaultValue:Bi.ONLY,implicit:!0})],Bi.prototype,"onlyContainsAttributeCerts",void 0);const ki=`${zr}.21`;var Ei;!function(e){e[e.unspecified=0]="unspecified",e[e.keyCompromise=1]="keyCompromise",e[e.cACompromise=2]="cACompromise",e[e.affiliationChanged=3]="affiliationChanged",e[e.superseded=4]="superseded",e[e.cessationOfOperation=5]="cessationOfOperation",e[e.certificateHold=6]="certificateHold",e[e.removeFromCRL=8]="removeFromCRL",e[e.privilegeWithdrawn=9]="privilegeWithdrawn",e[e.aACompromise=10]="aACompromise"}(Ei||(Ei={}));let Ci=class{constructor(e=Ei.unspecified){this.reason=Ei.unspecified,this.reason=e}toJSON(){return Ei[this.reason]}toString(){return this.toJSON()}};var Oi;Ar([fr({type:jt.Enumerated})],Ci.prototype,"reason",void 0),Ci=Ar([hr({type:Tt.Choice})],Ci);const Ii=`${zr}.37`;let Ni=Oi=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Oi.prototype)}};Ni=Oi=Ar([hr({type:Tt.Sequence,itemType:jt.ObjectIdentifier})],Ni);const Ti=`${_r}.1`,ji=`${_r}.2`,Pi=`${_r}.3`,Ui=`${_r}.4`,Ri=`${_r}.8`,Di=`${_r}.9`;let Vi=class{constructor(e=new ArrayBuffer(0)){this.value=e}};Ar([fr({type:jt.Integer,converter:Ht})],Vi.prototype,"value",void 0),Vi=Ar([hr({type:Tt.Choice})],Vi);const Li=`${zr}.24`;let Hi=class{constructor(e){this.value=new Date,e&&(this.value=e)}};var $i;Ar([fr({type:jt.GeneralizedTime})],Hi.prototype,"value",void 0),Hi=Ar([hr({type:Tt.Choice})],Hi);let Mi=$i=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,$i.prototype)}};Mi=$i=Ar([hr({type:Tt.Sequence})],Mi);const Fi=`${zr}.15`;var Ki,_i;!function(e){e[e.digitalSignature=1]="digitalSignature",e[e.nonRepudiation=2]="nonRepudiation",e[e.keyEncipherment=4]="keyEncipherment",e[e.dataEncipherment=8]="dataEncipherment",e[e.keyAgreement=16]="keyAgreement",e[e.keyCertSign=32]="keyCertSign",e[e.cRLSign=64]="cRLSign",e[e.encipherOnly=128]="encipherOnly",e[e.decipherOnly=256]="decipherOnly"}(Ki||(Ki={}));class zi extends Ut{toJSON(){const e=this.toNumber(),t=[];return e&Ki.cRLSign&&t.push("crlSign"),e&Ki.dataEncipherment&&t.push("dataEncipherment"),e&Ki.decipherOnly&&t.push("decipherOnly"),e&Ki.digitalSignature&&t.push("digitalSignature"),e&Ki.encipherOnly&&t.push("encipherOnly"),e&Ki.keyAgreement&&t.push("keyAgreement"),e&Ki.keyCertSign&&t.push("keyCertSign"),e&Ki.keyEncipherment&&t.push("keyEncipherment"),e&Ki.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}class qi{constructor(e={}){this.base=new Kr,this.minimum=0,Object.assign(this,e)}}Ar([fr({type:Kr})],qi.prototype,"base",void 0),Ar([fr({type:jt.Integer,context:0,defaultValue:0,implicit:!0})],qi.prototype,"minimum",void 0),Ar([fr({type:jt.Integer,context:1,optional:!0,implicit:!0})],qi.prototype,"maximum",void 0);let Wi=_i=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,_i.prototype)}};Wi=_i=Ar([hr({type:Tt.Sequence,itemType:qi})],Wi);class Gi{constructor(e={}){Object.assign(this,e)}}Ar([fr({type:Wi,context:0,optional:!0,implicit:!0})],Gi.prototype,"permittedSubtrees",void 0),Ar([fr({type:Wi,context:1,optional:!0,implicit:!0})],Gi.prototype,"excludedSubtrees",void 0);class Ji{constructor(e={}){Object.assign(this,e)}}var Xi;Ar([fr({type:jt.Integer,context:0,implicit:!0,optional:!0,converter:Ht})],Ji.prototype,"requireExplicitPolicy",void 0),Ar([fr({type:jt.Integer,context:1,implicit:!0,optional:!0,converter:Ht})],Ji.prototype,"inhibitPolicyMapping",void 0);class Zi{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],Zi.prototype,"issuerDomainPolicy",void 0),Ar([fr({type:jt.ObjectIdentifier})],Zi.prototype,"subjectDomainPolicy",void 0);let Yi=Xi=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Xi.prototype)}};var Qi;Yi=Xi=Ar([hr({type:Tt.Sequence,itemType:Zi})],Yi);const en=`${zr}.17`;let tn=Qi=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,Qi.prototype)}};tn=Qi=Ar([hr({type:Tt.Sequence})],tn);let rn=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};var nn;Ar([fr({type:jt.ObjectIdentifier})],rn.prototype,"type",void 0),Ar([fr({type:jt.Any,repeated:"set"})],rn.prototype,"values",void 0);let sn=nn=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,nn.prototype)}};sn=nn=Ar([hr({type:Tt.Sequence,itemType:rn})],sn);const on=`${zr}.14`;class an extends Xr{}class cn{constructor(e={}){Object.assign(this,e)}}var un,ln;Ar([fr({type:jt.GeneralizedTime,context:0,implicit:!0,optional:!0})],cn.prototype,"notBefore",void 0),Ar([fr({type:jt.GeneralizedTime,context:1,implicit:!0,optional:!0})],cn.prototype,"notAfter",void 0),function(e){e[e.keyUpdateAllowed=1]="keyUpdateAllowed",e[e.newExtensions=2]="newExtensions",e[e.pKIXCertificate=4]="pKIXCertificate"}(un||(un={}));class pn extends Ut{toJSON(){const e=[],t=this.toNumber();return t&un.pKIXCertificate&&e.push("pKIXCertificate"),t&un.newExtensions&&e.push("newExtensions"),t&un.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class hn{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new pn,Object.assign(this,e)}}Ar([fr({type:jt.GeneralString})],hn.prototype,"entrustVers",void 0),Ar([fr({type:pn})],hn.prototype,"entrustInfoFlags",void 0);let fn=ln=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,ln.prototype)}};fn=ln=Ar([hr({type:Tt.Sequence,itemType:Wr})],fn);class yn{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof yn&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&p(e.parameters,this.parameters)||e.parameters===this.parameters)}}Ar([fr({type:jt.ObjectIdentifier})],yn.prototype,"algorithm",void 0),Ar([fr({type:jt.Any,optional:!0})],yn.prototype,"parameters",void 0);class dn{constructor(e={}){this.algorithm=new yn,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:yn})],dn.prototype,"algorithm",void 0),Ar([fr({type:jt.BitString})],dn.prototype,"subjectPublicKey",void 0);let gn=class{constructor(e){if(e)if("string"==typeof e||"number"==typeof e||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}};Ar([fr({type:jt.UTCTime})],gn.prototype,"utcTime",void 0),Ar([fr({type:jt.GeneralizedTime})],gn.prototype,"generalTime",void 0),gn=Ar([hr({type:Tt.Choice})],gn);class vn{constructor(e){this.notBefore=new gn(new Date),this.notAfter=new gn(new Date),e&&(this.notBefore=new gn(e.notBefore),this.notAfter=new gn(e.notAfter))}}var mn;Ar([fr({type:gn})],vn.prototype,"notBefore",void 0),Ar([fr({type:gn})],vn.prototype,"notAfter",void 0);let wn=class e{constructor(t={}){this.extnID="",this.critical=e.CRITICAL,this.extnValue=new Rt,Object.assign(this,t)}};wn.CRITICAL=!1,Ar([fr({type:jt.ObjectIdentifier})],wn.prototype,"extnID",void 0),Ar([fr({type:jt.Boolean,defaultValue:wn.CRITICAL})],wn.prototype,"critical",void 0),Ar([fr({type:Rt})],wn.prototype,"extnValue",void 0);let bn=mn=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,mn.prototype)}};var An;bn=mn=Ar([hr({type:Tt.Sequence,itemType:wn})],bn),function(e){e[e.v1=0]="v1",e[e.v2=1]="v2",e[e.v3=2]="v3"}(An||(An={}));class Sn{constructor(e={}){this.version=An.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new yn,this.issuer=new Hr,this.validity=new vn,this.subject=new Hr,this.subjectPublicKeyInfo=new dn,Object.assign(this,e)}}Ar([fr({type:jt.Integer,context:0,defaultValue:An.v1})],Sn.prototype,"version",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Sn.prototype,"serialNumber",void 0),Ar([fr({type:yn})],Sn.prototype,"signature",void 0),Ar([fr({type:Hr})],Sn.prototype,"issuer",void 0),Ar([fr({type:vn})],Sn.prototype,"validity",void 0),Ar([fr({type:Hr})],Sn.prototype,"subject",void 0),Ar([fr({type:dn})],Sn.prototype,"subjectPublicKeyInfo",void 0),Ar([fr({type:jt.BitString,context:1,implicit:!0,optional:!0})],Sn.prototype,"issuerUniqueID",void 0),Ar([fr({type:jt.BitString,context:2,implicit:!0,optional:!0})],Sn.prototype,"subjectUniqueID",void 0),Ar([fr({type:bn,context:3,optional:!0})],Sn.prototype,"extensions",void 0);class xn{constructor(e={}){this.tbsCertificate=new Sn,this.signatureAlgorithm=new yn,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:Sn})],xn.prototype,"tbsCertificate",void 0),Ar([fr({type:yn})],xn.prototype,"signatureAlgorithm",void 0),Ar([fr({type:jt.BitString})],xn.prototype,"signatureValue",void 0);class Bn{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new gn,Object.assign(this,e)}}Ar([fr({type:jt.Integer,converter:Ht})],Bn.prototype,"userCertificate",void 0),Ar([fr({type:gn})],Bn.prototype,"revocationDate",void 0),Ar([fr({type:wn,optional:!0,repeated:"sequence"})],Bn.prototype,"crlEntryExtensions",void 0);class kn{constructor(e={}){this.signature=new yn,this.issuer=new Hr,this.thisUpdate=new gn,Object.assign(this,e)}}Ar([fr({type:jt.Integer,optional:!0})],kn.prototype,"version",void 0),Ar([fr({type:yn})],kn.prototype,"signature",void 0),Ar([fr({type:Hr})],kn.prototype,"issuer",void 0),Ar([fr({type:gn})],kn.prototype,"thisUpdate",void 0),Ar([fr({type:gn,optional:!0})],kn.prototype,"nextUpdate",void 0),Ar([fr({type:Bn,repeated:"sequence",optional:!0})],kn.prototype,"revokedCertificates",void 0),Ar([fr({type:wn,optional:!0,context:0,repeated:"sequence"})],kn.prototype,"crlExtensions",void 0);class En{constructor(e={}){this.tbsCertList=new kn,this.signatureAlgorithm=new yn,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:kn})],En.prototype,"tbsCertList",void 0),Ar([fr({type:yn})],En.prototype,"signatureAlgorithm",void 0),Ar([fr({type:jt.BitString})],En.prototype,"signature",void 0);class Cn{constructor(e={}){this.issuer=new Hr,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:Hr})],Cn.prototype,"issuer",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Cn.prototype,"serialNumber",void 0);let On=class{constructor(e={}){Object.assign(this,e)}};var In;Ar([fr({type:an,context:0,implicit:!0})],On.prototype,"subjectKeyIdentifier",void 0),Ar([fr({type:Cn})],On.prototype,"issuerAndSerialNumber",void 0),On=Ar([hr({type:Tt.Choice})],On),function(e){e[e.v0=0]="v0",e[e.v1=1]="v1",e[e.v2=2]="v2",e[e.v3=3]="v3",e[e.v4=4]="v4",e[e.v5=5]="v5"}(In||(In={}));let Nn=class extends yn{};Nn=Ar([hr({type:Tt.Sequence})],Nn);let Tn=class extends yn{};Tn=Ar([hr({type:Tt.Sequence})],Tn);let jn=class extends yn{};jn=Ar([hr({type:Tt.Sequence})],jn);let Pn=class extends yn{};Pn=Ar([hr({type:Tt.Sequence})],Pn);let Un=class extends yn{};Un=Ar([hr({type:Tt.Sequence})],Un);let Rn=class extends yn{};Rn=Ar([hr({type:Tt.Sequence})],Rn);let Dn=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};var Vn;Ar([fr({type:jt.ObjectIdentifier})],Dn.prototype,"attrType",void 0),Ar([fr({type:jt.Any,repeated:"set"})],Dn.prototype,"attrValues",void 0);class Ln{constructor(e={}){this.version=In.v0,this.sid=new On,this.digestAlgorithm=new Nn,this.signatureAlgorithm=new Tn,this.signature=new Rt,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],Ln.prototype,"version",void 0),Ar([fr({type:On})],Ln.prototype,"sid",void 0),Ar([fr({type:Nn})],Ln.prototype,"digestAlgorithm",void 0),Ar([fr({type:Dn,repeated:"set",context:0,implicit:!0,optional:!0})],Ln.prototype,"signedAttrs",void 0),Ar([fr({type:Tn})],Ln.prototype,"signatureAlgorithm",void 0),Ar([fr({type:Rt})],Ln.prototype,"signature",void 0),Ar([fr({type:Dn,repeated:"set",context:1,implicit:!0,optional:!0})],Ln.prototype,"unsignedAttrs",void 0);let Hn=Vn=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Vn.prototype)}};Hn=Vn=Ar([hr({type:Tt.Set,itemType:Ln})],Hn);let $n=class extends gn{};$n=Ar([hr({type:Tt.Choice})],$n);let Mn=class extends Ln{};Mn=Ar([hr({type:Tt.Sequence})],Mn);class Fn{constructor(e={}){this.acIssuer=new Kr,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}var Kn;Ar([fr({type:Kr})],Fn.prototype,"acIssuer",void 0),Ar([fr({type:jt.Integer})],Fn.prototype,"acSerial",void 0),Ar([fr({type:rn,repeated:"sequence"})],Fn.prototype,"attrs",void 0);let _n=Kn=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Kn.prototype)}};_n=Kn=Ar([hr({type:Tt.Sequence,itemType:jt.ObjectIdentifier})],_n);class zn{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}Ar([fr({type:jt.Integer,optional:!0})],zn.prototype,"pathLenConstraint",void 0),Ar([fr({type:_n,implicit:!0,context:0,optional:!0})],zn.prototype,"permittedAttrs",void 0),Ar([fr({type:_n,implicit:!0,context:1,optional:!0})],zn.prototype,"excludedAttrs",void 0),Ar([fr({type:jt.Boolean,defaultValue:!0})],zn.prototype,"permitUnSpecified",void 0);class qn{constructor(e={}){this.issuer=new ti,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}var Wn;Ar([fr({type:ti})],qn.prototype,"issuer",void 0),Ar([fr({type:jt.Integer,converter:Ht})],qn.prototype,"serial",void 0),Ar([fr({type:jt.BitString,optional:!0})],qn.prototype,"issuerUID",void 0),function(e){e[e.publicKey=0]="publicKey",e[e.publicKeyCert=1]="publicKeyCert",e[e.otherObjectTypes=2]="otherObjectTypes"}(Wn||(Wn={}));class Gn{constructor(e={}){this.digestedObjectType=Wn.publicKey,this.digestAlgorithm=new yn,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.Enumerated})],Gn.prototype,"digestedObjectType",void 0),Ar([fr({type:jt.ObjectIdentifier,optional:!0})],Gn.prototype,"otherObjectTypeID",void 0),Ar([fr({type:yn})],Gn.prototype,"digestAlgorithm",void 0),Ar([fr({type:jt.BitString})],Gn.prototype,"objectDigest",void 0);class Jn{constructor(e={}){Object.assign(this,e)}}Ar([fr({type:ti,optional:!0})],Jn.prototype,"issuerName",void 0),Ar([fr({type:qn,context:0,implicit:!0,optional:!0})],Jn.prototype,"baseCertificateID",void 0),Ar([fr({type:Gn,context:1,implicit:!0,optional:!0})],Jn.prototype,"objectDigestInfo",void 0);let Xn=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:Kr,repeated:"sequence"})],Xn.prototype,"v1Form",void 0),Ar([fr({type:Jn,context:0,implicit:!0})],Xn.prototype,"v2Form",void 0),Xn=Ar([hr({type:Tt.Choice})],Xn);class Zn{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}Ar([fr({type:jt.GeneralizedTime})],Zn.prototype,"notBeforeTime",void 0),Ar([fr({type:jt.GeneralizedTime})],Zn.prototype,"notAfterTime",void 0);class Yn{constructor(e={}){Object.assign(this,e)}}var Qn,es,ts;Ar([fr({type:qn,implicit:!0,context:0,optional:!0})],Yn.prototype,"baseCertificateID",void 0),Ar([fr({type:ti,implicit:!0,context:1,optional:!0})],Yn.prototype,"entityName",void 0),Ar([fr({type:Gn,implicit:!0,context:2,optional:!0})],Yn.prototype,"objectDigestInfo",void 0),function(e){e[e.v2=1]="v2"}(Qn||(Qn={}));class rs{constructor(e={}){this.version=Qn.v2,this.holder=new Yn,this.issuer=new Xn,this.signature=new yn,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Zn,this.attributes=[],Object.assign(this,e)}}Ar([fr({type:jt.Integer})],rs.prototype,"version",void 0),Ar([fr({type:Yn})],rs.prototype,"holder",void 0),Ar([fr({type:Xn})],rs.prototype,"issuer",void 0),Ar([fr({type:yn})],rs.prototype,"signature",void 0),Ar([fr({type:jt.Integer,converter:Ht})],rs.prototype,"serialNumber",void 0),Ar([fr({type:Zn})],rs.prototype,"attrCertValidityPeriod",void 0),Ar([fr({type:rn,repeated:"sequence"})],rs.prototype,"attributes",void 0),Ar([fr({type:jt.BitString,optional:!0})],rs.prototype,"issuerUniqueID",void 0),Ar([fr({type:bn,optional:!0})],rs.prototype,"extensions",void 0);class is{constructor(e={}){this.acinfo=new rs,this.signatureAlgorithm=new yn,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:rs})],is.prototype,"acinfo",void 0),Ar([fr({type:yn})],is.prototype,"signatureAlgorithm",void 0),Ar([fr({type:jt.BitString})],is.prototype,"signatureValue",void 0),function(e){e[e.unmarked=1]="unmarked",e[e.unclassified=2]="unclassified",e[e.restricted=4]="restricted",e[e.confidential=8]="confidential",e[e.secret=16]="secret",e[e.topSecret=32]="topSecret"}(es||(es={}));class ns extends Ut{}class ss{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier,implicit:!0,context:0})],ss.prototype,"type",void 0),Ar([fr({type:jt.Any,implicit:!0,context:1})],ss.prototype,"value",void 0);class os{constructor(e={}){this.policyId="",this.classList=new ns(es.unclassified),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],os.prototype,"policyId",void 0),Ar([fr({type:ns,defaultValue:new ns(es.unclassified)})],os.prototype,"classList",void 0),Ar([fr({type:ss,repeated:"set"})],os.prototype,"securityCategories",void 0);class as{constructor(e={}){Object.assign(this,e)}}Ar([fr({type:Rt})],as.prototype,"cotets",void 0),Ar([fr({type:jt.ObjectIdentifier})],as.prototype,"oid",void 0),Ar([fr({type:jt.Utf8String})],as.prototype,"string",void 0);class cs{constructor(e={}){this.values=[],Object.assign(this,e)}}Ar([fr({type:ti,implicit:!0,context:0,optional:!0})],cs.prototype,"policyAuthority",void 0),Ar([fr({type:as,repeated:"sequence"})],cs.prototype,"values",void 0);class us{constructor(e={}){this.targetCertificate=new qn,Object.assign(this,e)}}Ar([fr({type:qn})],us.prototype,"targetCertificate",void 0),Ar([fr({type:Kr,optional:!0})],us.prototype,"targetName",void 0),Ar([fr({type:Gn,optional:!0})],us.prototype,"certDigestInfo",void 0);let ls=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:Kr,context:0,implicit:!0})],ls.prototype,"targetName",void 0),Ar([fr({type:Kr,context:1,implicit:!0})],ls.prototype,"targetGroup",void 0),Ar([fr({type:us,context:2,implicit:!0})],ls.prototype,"targetCert",void 0),ls=Ar([hr({type:Tt.Choice})],ls);let ps=ts=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,ts.prototype)}};var hs;ps=ts=Ar([hr({type:Tt.Sequence,itemType:ls})],ps);let fs=hs=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,hs.prototype)}};fs=hs=Ar([hr({type:Tt.Sequence,itemType:ps})],fs);class ys{constructor(e={}){Object.assign(this,e)}}Ar([fr({type:ti,implicit:!0,context:0,optional:!0})],ys.prototype,"roleAuthority",void 0),Ar([fr({type:Kr,implicit:!0,context:1})],ys.prototype,"roleName",void 0);class ds{constructor(e={}){this.service=new Kr,this.ident=new Kr,Object.assign(this,e)}}var gs;Ar([fr({type:Kr})],ds.prototype,"service",void 0),Ar([fr({type:Kr})],ds.prototype,"ident",void 0),Ar([fr({type:Rt,optional:!0})],ds.prototype,"authInfo",void 0);class vs{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],vs.prototype,"otherCertFormat",void 0),Ar([fr({type:jt.Any})],vs.prototype,"otherCert",void 0);let ms=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:xn})],ms.prototype,"certificate",void 0),Ar([fr({type:is,context:2,implicit:!0})],ms.prototype,"v2AttrCert",void 0),Ar([fr({type:vs,context:3,implicit:!0})],ms.prototype,"other",void 0),ms=Ar([hr({type:Tt.Choice})],ms);let ws=gs=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,gs.prototype)}};ws=gs=Ar([hr({type:Tt.Set,itemType:ms})],ws);class bs{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],bs.prototype,"contentType",void 0),Ar([fr({type:jt.Any,context:0})],bs.prototype,"content",void 0);let As=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:Rt})],As.prototype,"single",void 0),Ar([fr({type:jt.Any})],As.prototype,"any",void 0),As=Ar([hr({type:Tt.Choice})],As);class Ss{constructor(e={}){this.eContentType="",Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],Ss.prototype,"eContentType",void 0),Ar([fr({type:As,context:0,optional:!0})],Ss.prototype,"eContent",void 0);let xs=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:Rt,context:0,implicit:!0,optional:!0})],xs.prototype,"value",void 0),Ar([fr({type:Rt,converter:_t,context:0,implicit:!0,optional:!0,repeated:"sequence"})],xs.prototype,"constructedValue",void 0),xs=Ar([hr({type:Tt.Choice})],xs);class Bs{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Pn,Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],Bs.prototype,"contentType",void 0),Ar([fr({type:Pn})],Bs.prototype,"contentEncryptionAlgorithm",void 0),Ar([fr({type:xs,optional:!0})],Bs.prototype,"encryptedContent",void 0);class ks{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}var Es;Ar([fr({type:jt.ObjectIdentifier})],ks.prototype,"keyAttrId",void 0),Ar([fr({type:jt.Any,optional:!0})],ks.prototype,"keyAttr",void 0);class Cs{constructor(e={}){this.subjectKeyIdentifier=new an,Object.assign(this,e)}}Ar([fr({type:an})],Cs.prototype,"subjectKeyIdentifier",void 0),Ar([fr({type:jt.GeneralizedTime,optional:!0})],Cs.prototype,"date",void 0),Ar([fr({type:ks,optional:!0})],Cs.prototype,"other",void 0);let Os=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:Cs,context:0,implicit:!0,optional:!0})],Os.prototype,"rKeyId",void 0),Ar([fr({type:Cn,optional:!0})],Os.prototype,"issuerAndSerialNumber",void 0),Os=Ar([hr({type:Tt.Choice})],Os);class Is{constructor(e={}){this.rid=new Os,this.encryptedKey=new Rt,Object.assign(this,e)}}Ar([fr({type:Os})],Is.prototype,"rid",void 0),Ar([fr({type:Rt})],Is.prototype,"encryptedKey",void 0);let Ns=Es=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Es.prototype)}};Ns=Es=Ar([hr({type:Tt.Sequence,itemType:Is})],Ns);class Ts{constructor(e={}){this.algorithm=new yn,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:yn})],Ts.prototype,"algorithm",void 0),Ar([fr({type:jt.BitString})],Ts.prototype,"publicKey",void 0);let js=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:an,context:0,implicit:!0,optional:!0})],js.prototype,"subjectKeyIdentifier",void 0),Ar([fr({type:Ts,context:1,implicit:!0,optional:!0})],js.prototype,"originatorKey",void 0),Ar([fr({type:Cn,optional:!0})],js.prototype,"issuerAndSerialNumber",void 0),js=Ar([hr({type:Tt.Choice})],js);class Ps{constructor(e={}){this.version=In.v3,this.originator=new js,this.keyEncryptionAlgorithm=new jn,this.recipientEncryptedKeys=new Ns,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],Ps.prototype,"version",void 0),Ar([fr({type:js,context:0})],Ps.prototype,"originator",void 0),Ar([fr({type:Rt,context:1,optional:!0})],Ps.prototype,"ukm",void 0),Ar([fr({type:jn})],Ps.prototype,"keyEncryptionAlgorithm",void 0),Ar([fr({type:Ns})],Ps.prototype,"recipientEncryptedKeys",void 0);let Us=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:an,context:0,implicit:!0})],Us.prototype,"subjectKeyIdentifier",void 0),Ar([fr({type:Cn})],Us.prototype,"issuerAndSerialNumber",void 0),Us=Ar([hr({type:Tt.Choice})],Us);class Rs{constructor(e={}){this.version=In.v0,this.rid=new Us,this.keyEncryptionAlgorithm=new jn,this.encryptedKey=new Rt,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],Rs.prototype,"version",void 0),Ar([fr({type:Us})],Rs.prototype,"rid",void 0),Ar([fr({type:jn})],Rs.prototype,"keyEncryptionAlgorithm",void 0),Ar([fr({type:Rt})],Rs.prototype,"encryptedKey",void 0);class Ds{constructor(e={}){this.keyIdentifier=new Rt,Object.assign(this,e)}}Ar([fr({type:Rt})],Ds.prototype,"keyIdentifier",void 0),Ar([fr({type:jt.GeneralizedTime,optional:!0})],Ds.prototype,"date",void 0),Ar([fr({type:ks,optional:!0})],Ds.prototype,"other",void 0);class Vs{constructor(e={}){this.version=In.v4,this.kekid=new Ds,this.keyEncryptionAlgorithm=new jn,this.encryptedKey=new Rt,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],Vs.prototype,"version",void 0),Ar([fr({type:Ds})],Vs.prototype,"kekid",void 0),Ar([fr({type:jn})],Vs.prototype,"keyEncryptionAlgorithm",void 0),Ar([fr({type:Rt})],Vs.prototype,"encryptedKey",void 0);class Ls{constructor(e={}){this.version=In.v0,this.keyEncryptionAlgorithm=new jn,this.encryptedKey=new Rt,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],Ls.prototype,"version",void 0),Ar([fr({type:Rn,context:0,optional:!0})],Ls.prototype,"keyDerivationAlgorithm",void 0),Ar([fr({type:jn})],Ls.prototype,"keyEncryptionAlgorithm",void 0),Ar([fr({type:Rt})],Ls.prototype,"encryptedKey",void 0);class Hs{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],Hs.prototype,"oriType",void 0),Ar([fr({type:jt.Any})],Hs.prototype,"oriValue",void 0);let $s=class{constructor(e={}){Object.assign(this,e)}};var Ms;Ar([fr({type:Rs,optional:!0})],$s.prototype,"ktri",void 0),Ar([fr({type:Ps,context:1,implicit:!0,optional:!0})],$s.prototype,"kari",void 0),Ar([fr({type:Vs,context:2,implicit:!0,optional:!0})],$s.prototype,"kekri",void 0),Ar([fr({type:Ls,context:3,implicit:!0,optional:!0})],$s.prototype,"pwri",void 0),Ar([fr({type:Hs,context:4,implicit:!0,optional:!0})],$s.prototype,"ori",void 0),$s=Ar([hr({type:Tt.Choice})],$s);let Fs=Ms=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Ms.prototype)}};var Ks;Fs=Ms=Ar([hr({type:Tt.Set,itemType:$s})],Fs);class _s{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],_s.prototype,"otherRevInfoFormat",void 0),Ar([fr({type:jt.Any})],_s.prototype,"otherRevInfo",void 0);let zs=class{constructor(e={}){this.other=new _s,Object.assign(this,e)}};Ar([fr({type:_s,context:1,implicit:!0})],zs.prototype,"other",void 0),zs=Ar([hr({type:Tt.Choice})],zs);let qs=Ks=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Ks.prototype)}};qs=Ks=Ar([hr({type:Tt.Set,itemType:zs})],qs);class Ws{constructor(e={}){Object.assign(this,e)}}var Gs;Ar([fr({type:ws,context:0,implicit:!0,optional:!0})],Ws.prototype,"certs",void 0),Ar([fr({type:qs,context:1,implicit:!0,optional:!0})],Ws.prototype,"crls",void 0);let Js=Gs=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Gs.prototype)}};Js=Gs=Ar([hr({type:Tt.Set,itemType:Dn})],Js);class Xs{constructor(e={}){this.version=In.v0,this.recipientInfos=new Fs,this.encryptedContentInfo=new Bs,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],Xs.prototype,"version",void 0),Ar([fr({type:Ws,context:0,implicit:!0,optional:!0})],Xs.prototype,"originatorInfo",void 0),Ar([fr({type:Fs})],Xs.prototype,"recipientInfos",void 0),Ar([fr({type:Bs})],Xs.prototype,"encryptedContentInfo",void 0),Ar([fr({type:Js,context:1,implicit:!0,optional:!0})],Xs.prototype,"unprotectedAttrs",void 0);const Zs="1.2.840.113549.1.7.2";var Ys;let Qs=Ys=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Ys.prototype)}};Qs=Ys=Ar([hr({type:Tt.Set,itemType:Nn})],Qs);class eo{constructor(e={}){this.version=In.v0,this.digestAlgorithms=new Qs,this.encapContentInfo=new Ss,this.signerInfos=new Hn,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],eo.prototype,"version",void 0),Ar([fr({type:Qs})],eo.prototype,"digestAlgorithms",void 0),Ar([fr({type:Ss})],eo.prototype,"encapContentInfo",void 0),Ar([fr({type:ws,context:0,implicit:!0,optional:!0})],eo.prototype,"certificates",void 0),Ar([fr({type:zs,context:1,implicit:!0,optional:!0})],eo.prototype,"crls",void 0),Ar([fr({type:Hn})],eo.prototype,"signerInfos",void 0);const to="1.2.840.10045.2.1",ro="1.2.840.10045.4.1",io="1.2.840.10045.4.3.1",no="1.2.840.10045.4.3.2",so="1.2.840.10045.4.3.3",oo="1.2.840.10045.4.3.4",ao="1.2.840.10045.3.1.7",co="1.3.132.0.34",uo="1.3.132.0.35";function lo(e){return new yn({algorithm:e})}const po=lo(ro);lo(io);const ho=lo(no),fo=lo(so),yo=lo(oo);let go=class{constructor(e={}){Object.assign(this,e)}};Ar([fr({type:jt.ObjectIdentifier})],go.prototype,"namedCurve",void 0),go=Ar([hr({type:Tt.Choice})],go);class vo{constructor(e={}){this.version=1,this.privateKey=new Rt,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],vo.prototype,"version",void 0),Ar([fr({type:Rt})],vo.prototype,"privateKey",void 0),Ar([fr({type:go,context:0,optional:!0})],vo.prototype,"parameters",void 0),Ar([fr({type:jt.BitString,context:1,optional:!0})],vo.prototype,"publicKey",void 0);class mo{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.Integer,converter:Ht})],mo.prototype,"r",void 0),Ar([fr({type:jt.Integer,converter:Ht})],mo.prototype,"s",void 0);const wo="1.2.840.113549.1.1",bo=`${wo}.1`,Ao=`${wo}.7`,So=`${wo}.9`,xo=`${wo}.10`,Bo=`${wo}.2`,ko=`${wo}.4`,Eo=`${wo}.5`,Co=`${wo}.14`,Oo=`${wo}.11`,Io=`${wo}.12`,No=`${wo}.13`,To=`${wo}.15`,jo=`${wo}.16`,Po="1.3.14.3.2.26",Uo="2.16.840.1.101.3.4.2.4",Ro="2.16.840.1.101.3.4.2.1",Do="2.16.840.1.101.3.4.2.2",Vo="2.16.840.1.101.3.4.2.3",Lo=`${wo}.8`;function Ho(e){return new yn({algorithm:e,parameters:null})}Ho("1.2.840.113549.2.2"),Ho("1.2.840.113549.2.5");const $o=Ho(Po);Ho(Uo),Ho(Ro),Ho(Do),Ho(Vo),Ho("2.16.840.1.101.3.4.2.5"),Ho("2.16.840.1.101.3.4.2.6");const Mo=new yn({algorithm:Lo,parameters:mr.serialize($o)}),Fo=new yn({algorithm:So,parameters:mr.serialize(Kt.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ho(bo),Ho(Bo),Ho(ko),Ho(Eo),Ho(To),Ho(jo),Ho(Io),Ho(No),Ho(To),Ho(jo);class Ko{constructor(e={}){this.hashAlgorithm=new yn($o),this.maskGenAlgorithm=new yn({algorithm:Lo,parameters:mr.serialize($o)}),this.pSourceAlgorithm=new yn(Fo),Object.assign(this,e)}}Ar([fr({type:yn,context:0,defaultValue:$o})],Ko.prototype,"hashAlgorithm",void 0),Ar([fr({type:yn,context:1,defaultValue:Mo})],Ko.prototype,"maskGenAlgorithm",void 0),Ar([fr({type:yn,context:2,defaultValue:Fo})],Ko.prototype,"pSourceAlgorithm",void 0),new yn({algorithm:Ao,parameters:mr.serialize(new Ko)});class _o{constructor(e={}){this.hashAlgorithm=new yn($o),this.maskGenAlgorithm=new yn({algorithm:Lo,parameters:mr.serialize($o)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}Ar([fr({type:yn,context:0,defaultValue:$o})],_o.prototype,"hashAlgorithm",void 0),Ar([fr({type:yn,context:1,defaultValue:Mo})],_o.prototype,"maskGenAlgorithm",void 0),Ar([fr({type:jt.Integer,context:2,defaultValue:20})],_o.prototype,"saltLength",void 0),Ar([fr({type:jt.Integer,context:3,defaultValue:1})],_o.prototype,"trailerField",void 0),new yn({algorithm:xo,parameters:mr.serialize(new _o)});class zo{constructor(e={}){this.digestAlgorithm=new yn,this.digest=new Rt,Object.assign(this,e)}}var qo;Ar([fr({type:yn})],zo.prototype,"digestAlgorithm",void 0),Ar([fr({type:Rt})],zo.prototype,"digest",void 0);class Wo{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.Integer,converter:Ht})],Wo.prototype,"prime",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Wo.prototype,"exponent",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Wo.prototype,"coefficient",void 0);let Go=qo=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,qo.prototype)}};Go=qo=Ar([hr({type:Tt.Sequence,itemType:Wo})],Go);class Jo{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)}}Ar([fr({type:jt.Integer})],Jo.prototype,"version",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Jo.prototype,"modulus",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Jo.prototype,"publicExponent",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Jo.prototype,"privateExponent",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Jo.prototype,"prime1",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Jo.prototype,"prime2",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Jo.prototype,"exponent1",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Jo.prototype,"exponent2",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Jo.prototype,"coefficient",void 0),Ar([fr({type:Go,optional:!0})],Jo.prototype,"otherPrimeInfos",void 0);class Xo{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}var Zo;Ar([fr({type:jt.Integer,converter:Ht})],Xo.prototype,"modulus",void 0),Ar([fr({type:jt.Integer,converter:Ht})],Xo.prototype,"publicExponent",void 0),function(e){e[e.Transient=0]="Transient",e[e.Singleton=1]="Singleton",e[e.ResolutionScoped=2]="ResolutionScoped",e[e.ContainerScoped=3]="ContainerScoped"}(Zo||(Zo={}));var Yo=Zo,Qo="injectionTokens";function ea(e){return!!e.useClass}function ta(e){return!!e.useFactory}var ra=function(){function e(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return e.prototype.createProxy=function(e){var t,r=this,i=!1;return new Proxy({},this.createHandler((function(){return i||(t=e(r.wrap()),i=!0),t})))},e.prototype.createHandler=function(e){var t={};return this.reflectMethods.forEach((function(r){t[r]=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return t[0]=e(),Reflect[r].apply(void 0,Er(t))}})),t},e}();function ia(e){return"string"==typeof e||"symbol"==typeof e}function na(e){return"object"==typeof e&&"token"in e&&"transform"in e}function sa(e){return!!e.useToken}function oa(e){return null!=e.useValue}var aa=function(){function e(){this._registryMap=new Map}return e.prototype.entries=function(){return this._registryMap.entries()},e.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},e.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},e.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},e.prototype.setAll=function(e,t){this._registryMap.set(e,t)},e.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},e.prototype.clear=function(){this._registryMap.clear()},e.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},e}(),ca=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return br(t,e),t}(aa),ua=function(){this.scopedResolutions=new Map};function la(e,t,r){var i,n,s=kr(e.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1],o=function(e,t){return null===e?"at position #"+t:'"'+e.split(",")[t].trim()+'" at position #'+t}(void 0===s?null:s,t);return i="Cannot inject the dependency "+o+' of "'+e.name+'" constructor. Reason:',void 0===n&&(n=" "),Er([i],r.message.split("\n").map((function(e){return n+e}))).join("\n")}var pa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return br(t,e),t}(aa),ha=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return br(t,e),t}(aa),fa=function(){this.preResolution=new pa,this.postResolution=new ha},ya=new Map,da=function(){function e(e){this.parent=e,this._registry=new ca,this.interceptors=new fa,this.disposed=!1,this.disposables=new Set}return e.prototype.register=function(e,t,r){var i;if(void 0===r&&(r={lifecycle:Yo.Transient}),this.ensureNotDisposed(),i=function(e){return ea(e)||oa(e)||sa(e)||ta(e)}(t)?t:{useClass:t},sa(i))for(var n=[e],s=i;null!=s;){var o=s.useToken;if(n.includes(o))throw new Error("Token registration cycle detected! "+Er(n,[o]).join(" -> "));n.push(o);var a=this._registry.get(o);s=a&&sa(a.provider)?a.provider:null}if((r.lifecycle===Yo.Singleton||r.lifecycle==Yo.ContainerScoped||r.lifecycle==Yo.ResolutionScoped)&&(oa(i)||ta(i)))throw new Error('Cannot use lifecycle "'+Yo[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},e.prototype.registerType=function(e,t){return this.ensureNotDisposed(),ia(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},e.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},e.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),ia(e)){if(ia(t))return this.register(e,{useToken:t},{lifecycle:Yo.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Yo.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return t&&!ia(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:Yo.Singleton})},e.prototype.resolve=function(e,t){void 0===t&&(t=new ua),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&ia(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),r){var i=this.resolveRegistration(r,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(function(e){return"function"==typeof e||e instanceof ra}(e)){i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},e.prototype.executePreResolutionInterceptor=function(e,t){var r,i;if(this.interceptors.preResolution.has(e)){var n=[];try{for(var s=Br(this.interceptors.preResolution.getAll(e)),o=s.next();!o.done;o=s.next()){var a=o.value;"Once"!=a.options.frequency&&n.push(a),a.callback(e,t)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,n)}},e.prototype.executePostResolutionInterceptor=function(e,t,r){var i,n;if(this.interceptors.postResolution.has(e)){var s=[];try{for(var o=Br(this.interceptors.postResolution.getAll(e)),a=o.next();!a.done;a=o.next()){var c=a.value;"Once"!=c.options.frequency&&s.push(c),c.callback(e,t,r)}}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,s)}},e.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Yo.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var r,i=e.options.lifecycle===Yo.Singleton,n=e.options.lifecycle===Yo.ContainerScoped,s=i||n;return r=oa(e.provider)?e.provider.useValue:sa(e.provider)?s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):ea(e.provider)?s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):ta(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===Yo.ResolutionScoped&&t.scopedResolutions.set(e,r),r},e.prototype.resolveAll=function(e,t){var r=this;void 0===t&&(t=new ua),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&ia(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var n=i.map((function(e){return r.resolveRegistration(e,t)}));return this.executePostResolutionInterceptor(e,n,"All"),n}var s=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,s,"All"),s},e.prototype.isRegistered=function(e,t){return void 0===t&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},e.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},e.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var r=Br(this._registry.entries()),i=r.next();!i.done;i=r.next()){var n=kr(i.value,2),s=n[0],o=n[1];this._registry.setAll(s,o.filter((function(e){return!oa(e.provider)})).map((function(e){return e.instance=void 0,e})))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.createChildContainer=function(){var t,r;this.ensureNotDisposed();var i=new e(this);try{for(var n=Br(this._registry.entries()),s=n.next();!s.done;s=n.next()){var o=kr(s.value,2),a=o[0],c=o[1];c.some((function(e){return e.options.lifecycle===Yo.ContainerScoped}))&&i._registry.setAll(a,c.map((function(e){return e.options.lifecycle===Yo.ContainerScoped?{provider:e.provider,options:e.options}:e})))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return i},e.prototype.beforeResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:r})},e.prototype.afterResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:r})},e.prototype.dispose=function(){return Sr(this,void 0,void 0,(function(){var e;return xr(this,(function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach((function(t){var r=t.dispose();r&&e.push(r)})),[4,Promise.all(e)];case 1:return t.sent(),[2]}}))}))},e.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},e.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},e.prototype.construct=function(e,t){var r=this;if(e instanceof ra)return e.createProxy((function(e){return r.resolve(e,t)}));var i,n=function(){var i=ya.get(e);if(!i||0===i.length){if(0===e.length)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var n=i.map(r.resolveParams(t,e));return new(e.bind.apply(e,Er([void 0],n)))}();return"function"!=typeof(i=n).dispose||i.dispose.length>0||this.disposables.add(n),n},e.prototype.resolveParams=function(e,t){var r=this;return function(i,n){var s,o,a,c;try{return"object"==typeof(c=i)&&"token"in c&&"multiple"in c?na(i)?i.multiple?(s=r.resolve(i.transform)).transform.apply(s,Er([r.resolveAll(i.token)],i.transformArgs)):(o=r.resolve(i.transform)).transform.apply(o,Er([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):na(i)?(a=r.resolve(i.transform,e)).transform.apply(a,Er([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(e){throw new Error(la(t,n,e))}}},e.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},e}(),ga=new da;function va(){return function(e){ya.set(e,function(e){var t=Reflect.getMetadata("design:paramtypes",e)||[],r=Reflect.getOwnMetadata(Qo,e)||{};return Object.keys(r).forEach((function(e){t[+e]=r[e]})),t}(e))}}if("undefined"==typeof Reflect||!Reflect.getMetadata)throw new Error("tsyringe requires a reflect polyfill. Please add 'import \"reflect-metadata\"' to the top of your entry point.");const ma="crypto.algorithm";class wa{getAlgorithms(){return ga.resolveAll(ma)}toAsnAlgorithm(e){for(const t of this.getAlgorithms()){const r=t.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){const t=new yn({algorithm:e.name});if("parameters"in e){const r=e;t.parameters=r.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const t of this.getAlgorithms()){const r=t.toWebAlgorithm(e);if(r)return r}return{name:e.algorithm,parameters:e.parameters}}}const ba="crypto.algorithmProvider";var Aa;ga.registerSingleton(ba,wa);const Sa="1.3.36.3.3.2.8.1.1",xa=`${Sa}.1`,Ba=`${Sa}.2`,ka=`${Sa}.3`,Ea=`${Sa}.4`,Ca=`${Sa}.5`,Oa=`${Sa}.6`,Ia=`${Sa}.7`,Na=`${Sa}.8`,Ta=`${Sa}.9`,ja=`${Sa}.10`,Pa=`${Sa}.11`,Ua=`${Sa}.12`,Ra=`${Sa}.13`,Da=`${Sa}.14`,Va="brainpoolP160r1",La="brainpoolP160t1",Ha="brainpoolP192r1",$a="brainpoolP192t1",Ma="brainpoolP224r1",Fa="brainpoolP224t1",Ka="brainpoolP256r1",_a="brainpoolP256t1",za="brainpoolP320r1",qa="brainpoolP320t1",Wa="brainpoolP384r1",Ga="brainpoolP384t1",Ja="brainpoolP512r1",Xa="brainpoolP512t1",Za="ECDSA";e.EcAlgorithm=Aa=class{toAsnAlgorithm(e){if(e.name.toLowerCase()===Za.toLowerCase())if("hash"in e){switch(("string"==typeof e.hash?e.hash:e.hash.name).toLowerCase()){case"sha-1":return po;case"sha-256":return ho;case"sha-384":return fo;case"sha-512":return yo}}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=ao;break;case"K-256":t=Aa.SECP256K1;break;case"P-384":t=co;break;case"P-521":t=uo;break;case Va:t=xa;break;case La:t=Ba;break;case Ha:t=ka;break;case $a:t=Ea;break;case Ma:t=Ca;break;case Fa:t=Oa;break;case Ka:t=Ia;break;case _a:t=Na;break;case za:t=Ta;break;case qa:t=ja;break;case Wa:t=Pa;break;case Ga:t=Ua;break;case Ja:t=Ra;break;case Xa:t=Da}if(t)return new yn({algorithm:to,parameters:mr.serialize(new go({namedCurve:t}))})}return null}toWebAlgorithm(e){switch(e.algorithm){case ro:return{name:Za,hash:{name:"SHA-1"}};case no:return{name:Za,hash:{name:"SHA-256"}};case so:return{name:Za,hash:{name:"SHA-384"}};case oo:return{name:Za,hash:{name:"SHA-512"}};case to:if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(mr.parse(e.parameters,go).namedCurve){case ao:return{name:Za,namedCurve:"P-256"};case Aa.SECP256K1:return{name:Za,namedCurve:"K-256"};case co:return{name:Za,namedCurve:"P-384"};case uo:return{name:Za,namedCurve:"P-521"};case xa:return{name:Za,namedCurve:Va};case Ba:return{name:Za,namedCurve:La};case ka:return{name:Za,namedCurve:Ha};case Ea:return{name:Za,namedCurve:$a};case Ca:return{name:Za,namedCurve:Ma};case Oa:return{name:Za,namedCurve:Fa};case Ia:return{name:Za,namedCurve:Ka};case Na:return{name:Za,namedCurve:_a};case Ta:return{name:Za,namedCurve:za};case ja:return{name:Za,namedCurve:qa};case Pa:return{name:Za,namedCurve:Wa};case Ua:return{name:Za,namedCurve:Ga};case Ra:return{name:Za,namedCurve:Ja};case Da:return{name:Za,namedCurve:Xa}}}return null}},e.EcAlgorithm.SECP256K1="1.3.132.0.10",e.EcAlgorithm=Aa=Ar([va()],e.EcAlgorithm),ga.registerSingleton(ma,e.EcAlgorithm);const Ya=Symbol("name"),Qa=Symbol("value");class ec{constructor(e,t={},r=""){this[Ya]=e,this[Qa]=r;for(const e in t)this[e]=t[e]}}ec.NAME=Ya,ec.VALUE=Qa;class tc{static toTextObject(t){const r=new ec("Algorithm Identifier",{},rc.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case to:{const i=(new e.EcAlgorithm).toWebAlgorithm(t);i&&"namedCurve"in i?r["Named Curve"]=i.namedCurve:r.Parameters=t.parameters;break}default:r.Parameters=t.parameters}return r}}class rc{static toString(e){const t=this.items[e];return t||e}}rc.items={[Po]:"sha1",[Uo]:"sha224",[Ro]:"sha256",[Do]:"sha384",[Vo]:"sha512",[bo]:"rsaEncryption",[Eo]:"sha1WithRSAEncryption",[Co]:"sha224WithRSAEncryption",[Oo]:"sha256WithRSAEncryption",[Io]:"sha384WithRSAEncryption",[No]:"sha512WithRSAEncryption",[to]:"ecPublicKey",[ro]:"ecdsaWithSHA1",[io]:"ecdsaWithSHA224",[no]:"ecdsaWithSHA256",[so]:"ecdsaWithSHA384",[oo]:"ecdsaWithSHA512",[Ti]:"TLS WWW server authentication",[ji]:"TLS WWW client authentication",[Pi]:"Code Signing",[Ui]:"E-mail Protection",[Ri]:"Time Stamping",[Di]:"OCSP Signing",[Zs]:"Signed Data"};class ic{static serialize(e){return this.serializeObj(e).join("\n")}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const r=[];let n=this.pad(t++),s="";const o=e[ec.VALUE];o&&(s=` ${o}`),r.push(`${n}${e[ec.NAME]}:${s}`),n=this.pad(t);for(const s in e){if("symbol"==typeof s)continue;const o=e[s],a=s?`${s}: `:"";if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)r.push(`${n}${a}${o}`);else if(o instanceof Date)r.push(`${n}${a}${o.toUTCString()}`);else if(Array.isArray(o))for(const e of o)e[ec.NAME]=s,r.push(...this.serializeObj(e,t));else if(o instanceof ec)o[ec.NAME]=s,r.push(...this.serializeObj(o,t));else if(i.isBufferSource(o))s?(r.push(`${n}${a}`),r.push(...this.serializeBufferSource(o,t+1))):r.push(...this.serializeBufferSource(o,t));else{if(!("toTextObject"in o))throw new TypeError("Cannot serialize data in text format. Unsupported type.");{const e=o.toTextObject();e[ec.NAME]=s,r.push(...this.serializeObj(e,t))}}}return r}static serializeBufferSource(e,t=0){const r=this.pad(t),n=i.toUint8Array(e),s=[];for(let e=0;e<n.length;){const t=[];for(let r=0;r<16&&e<n.length;r++){8===r&&t.push("");const i=n[e++].toString(16).padStart(2,"0");t.push(i)}s.push(`${r}${t.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}ic.oidSerializer=rc,ic.algorithmSerializer=tc;class nc{constructor(...e){if(1===e.length){const t=e[0];this.rawData=mr.serialize(t),this.onInit(t)}else{const t=mr.parse(e[0],e[1]);this.rawData=i.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof nc&&p(e.rawData,this.rawData)}toString(e="text"){switch(e){case"asn":return mr.toString(this.rawData);case"text":return ic.serialize(this.toTextObject());case"hex":return l.ToHex(this.rawData);case"base64":return l.ToBase64(this.rawData);case"base64url":return l.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 ec(this.getTextName(),{},e)}}nc.NAME="ASN";class sc extends nc{constructor(...e){let t;t=i.isBufferSource(e[0])?i.toArrayBuffer(e[0]):mr.serialize(new wn({extnID:e[0],critical:e[1],extnValue:new Rt(i.toArrayBuffer(e[2]))})),super(t,wn)}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[ec.NAME]===sc.NAME&&(e[ec.NAME]=rc.toString(this.type)),e}}var oc;class ac{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&void 0!==e.extractable}constructor(){this.items=new Map,this[oc]="CryptoProvider","undefined"!=typeof self&&"undefined"!=typeof crypto?this.set(ac.DEFAULT,crypto):"undefined"!=typeof global&&global.crypto&&global.crypto.subtle&&this.set(ac.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=ac.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("string"==typeof e){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(ac.DEFAULT,e);return this}}oc=Symbol.toStringTag,ac.DEFAULT="default";const cc=new ac,uc=/^[0-2](?:\.[1-9][0-9]*)+$/;class lc{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return t=e,new RegExp(uc).test(t)?e:this.get(e);var t}register(e,t){this.items[e]=t,this.items[t]=e}}const pc=new lc;function hc(e,t){return`\\${l.ToHex(l.FromUtf8String(t)).toUpperCase()}`}pc.register("CN","2.5.4.3"),pc.register("L","2.5.4.7"),pc.register("ST","2.5.4.8"),pc.register("O","2.5.4.10"),pc.register("OU","2.5.4.11"),pc.register("C","2.5.4.6"),pc.register("DC","0.9.2342.19200300.100.1.25"),pc.register("E","1.2.840.113549.1.9.1"),pc.register("G","2.5.4.42"),pc.register("I","2.5.4.43"),pc.register("SN","2.5.4.4"),pc.register("T","2.5.4.12");class fc{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 lc,this.asn=new Hr;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e];this.extraNames.register(e,r)}"string"==typeof e?this.asn=this.fromString(e):e instanceof Hr?this.asn=e:i.isBufferSource(e)?this.asn=mr.parse(e,Hr):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||pc.findId(e),r=[];for(const e of this.asn)for(const i of e)i.type===t&&r.push(i.value.toString());return r}getName(e){return this.extraNames.get(e)||pc.get(e)}toString(){return this.asn.map((e=>e.map((e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${l.ToHex(e.value.anyValue)}`:e.value.toString().replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,hc)}`)).join("+"))).join(", ")}toJSON(){var e;const t=[];for(const r of this.asn){const i={};for(const t of r){const r=this.getName(t.type)||t.type;null!==(e=i[r])&&void 0!==e||(i[r]=[]),i[r].push(t.value.anyValue?`#${l.ToHex(t.value.anyValue)}`:t.value.toString())}t.push(i)}return t}fromString(e){const t=new Hr,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,n=",";for(;i=r.exec(`${e},`);){let[,e,r]=i;const s=r[r.length-1];","!==s&&"+"!==s||(r=r.slice(0,r.length-1),i[3]=s);const o=i[3];if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);const a=new Dr({type:e});if("#"===r.charAt(0))a.value.anyValue=l.FromHex(r.slice(1));else{const t=/"(.*?[^\\])?"/.exec(r);t&&(r=t[1]),r=r.replace(/\\0a/gi,"\n").replace(/\\0d/gi,"\r").replace(/\\0g/gi,"\t").replace(/\\(.)/g,"$1"),e===this.getName("E")||e===this.getName("DC")?a.value.ia5String=r:fc.isPrintableString(r)?a.value.printableString=r:a.value.utf8String=r}"+"===n?t[t.length-1].push(a):t.push(new Vr([a])),n=o}return t}fromJSON(e){const t=new Hr;for(const r of e){const e=new Vr;for(const t in r){let i=t;if(/[\d.]+/.test(t)||(i=this.getName(t)||""),!i)throw new Error(`Cannot get OID for name type '${t}'`);const n=r[t];for(const t of n){const r=new Dr({type:i});if("object"==typeof t)for(const e in t)switch(e){case"ia5String":r.value.ia5String=t[e];break;case"utf8String":r.value.utf8String=t[e];break;case"universalString":r.value.universalString=t[e];break;case"bmpString":r.value.bmpString=t[e];break;case"printableString":r.value.printableString=t[e]}else"#"===t[0]?r.value.anyValue=l.FromHex(t.slice(1)):i===this.getName("E")||i===this.getName("DC")?r.value.ia5String=t:r.value.printableString=t;e.push(r)}}t.push(e)}return t}toArrayBuffer(){return mr.serialize(this.asn)}async getThumbprint(...e){var t;let r,i="SHA-1";return e.length>=1&&!(null===(t=e[0])||void 0===t?void 0:t.subtle)?(i=e[0]||i,r=e[1]||cc.get()):r=e[0]||cc.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const yc="Cannot initialize GeneralName from ASN.1 data.",dc=`${yc} Unsupported string format in use.`,gc=`${yc} Value doesn't match to GUID regular expression.`,vc=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,mc="1.3.6.1.4.1.311.25.1",wc="1.3.6.1.4.1.311.20.2.3",bc="dns",Ac="dn",Sc="email",xc="ip",Bc="url",kc="guid",Ec="upn",Cc="id";class Oc extends nc{constructor(...e){let t;if(2===e.length)switch(e[0]){case Ac:{const r=new fc(e[1]).toArrayBuffer(),i=mr.parse(r,Hr);t=new Kr({directoryName:i});break}case bc:t=new Kr({dNSName:e[1]});break;case Sc:t=new Kr({rfc822Name:e[1]});break;case kc:{const r=new RegExp(vc,"i").exec(e[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map(((e,t)=>t<3?l.ToHex(new Uint8Array(l.FromHex(e)).reverse()):e)).join("");t=new Kr({otherName:new Mr({typeId:mc,value:mr.serialize(new Rt(l.FromHex(i)))})});break}case xc:t=new Kr({iPAddress:e[1]});break;case Cc:t=new Kr({registeredID:e[1]});break;case Ec:t=new Kr({otherName:new Mr({typeId:wc,value:mr.serialize(qt.toASN(e[1]))})});break;case Bc:t=new Kr({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else t=i.isBufferSource(e[0])?mr.parse(e[0],Kr):e[0];super(t)}onInit(e){if(null!=e.dNSName)this.type=bc,this.value=e.dNSName;else if(null!=e.rfc822Name)this.type=Sc,this.value=e.rfc822Name;else if(null!=e.iPAddress)this.type=xc,this.value=e.iPAddress;else if(null!=e.uniformResourceIdentifier)this.type=Bc,this.value=e.uniformResourceIdentifier;else if(null!=e.registeredID)this.type=Cc,this.value=e.registeredID;else if(null!=e.directoryName)this.type=Ac,this.value=new fc(e.directoryName).toString();else{if(null==e.otherName)throw new Error(dc);if(e.otherName.typeId===mc){this.type=kc;const t=mr.parse(e.otherName.value,Rt),r=new RegExp(vc,"i").exec(l.ToHex(t));if(!r)throw new Error(gc);this.value=r.slice(1).map(((e,t)=>t<3?l.ToHex(new Uint8Array(l.FromHex(e)).reverse()):e)).join("-")}else{if(e.otherName.typeId!==wc)throw new Error(dc);this.type=Ec,this.value=mr.parse(e.otherName.value,Ur).toString()}}}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Ac:case bc:case kc:case xc:case Cc:case Ec:case Bc:e=this.type.toUpperCase();break;case Sc:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===Cc&&(t=rc.toString(t)),new ec(e,void 0,t)}}class Ic extends nc{constructor(e){let t;if(e instanceof ti)t=e;else if(Array.isArray(e)){const r=[];for(const t of e)if(t instanceof Kr)r.push(t);else{const e=mr.parse(new Oc(t.type,t.value).rawData,Kr);r.push(e)}t=new ti(r)}else{if(!i.isBufferSource(e))throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");t=mr.parse(e,ti)}super(t)}onInit(e){const t=[];for(const r of e){let e=null;try{e=new Oc(r)}catch(e){continue}t.push(e)}this.items=t}toJSON(){return this.items.map((e=>e.toJSON()))}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const r=t.toTextObject();let i=e[r[ec.NAME]];Array.isArray(i)||(i=[],e[r[ec.NAME]]=i),i.push(r)}return e}}Ic.NAME="GeneralNames";const Nc="-{5}",Tc="\\n",jc="\\n",Pc=`${`${Nc}BEGIN (${`[^${Tc}]+`}(?=${Nc}))${Nc}`}${jc}(?:((?:${`[^:${Tc}]+`}: ${`(?:[^${Tc}]+${jc}(?: +[^${Tc}]+${jc})*)`})+))?${jc}?(${`(?:[a-zA-Z0-9=+/]+${jc})+`})${`${Nc}END \\1${Nc}`}`;class Uc{static isPem(e){return"string"==typeof e&&new RegExp(Pc,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Pc,"g"),r=[];let i=null;for(;i=t.exec(e);){const e=i[3].replace(new RegExp(`[${Tc}]+`,"g"),""),t={type:i[1],headers:[],rawData:l.FromBase64(e)},n=i[2];if(n){const e=n.split(new RegExp(jc,"g"));let r=null;for(const i of e){const[e,n]=i.split(/:(.*)/);if(void 0===n){if(!r)throw new Error("Cannot parse PEM string. Incorrect header value");r.value+=e.trim()}else r&&t.headers.push(r),r={key:e,value:n.trim()}}r&&t.headers.push(r)}r.push(t)}return r}static decode(e){return this.decodeWithHeaders(e).map((e=>e.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 r=new Array;return t?e.forEach((e=>{if(!i.isBufferSource(e))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:t,rawData:i.toArrayBuffer(e)}))})):e.forEach((e=>{if(!("type"in e))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(e))})),r.join("\n")}if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:i.toArrayBuffer(e)})}static encodeStruct(e){var t;const r=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${r}-----`),null===(t=e.headers)||void 0===t?void 0:t.length){for(const t of e.headers)i.push(`${t.key}: ${t.value}`);i.push("")}const n=l.ToBase64(e.rawData);let s,o=0;const a=Array();for(;o<n.length&&(n.length-o<64?s=n.substring(o):(s=n.substring(o,o+64),o+=64),0!==s.length)&&(a.push(s),!(s.length<64)););return i.push(...a),i.push(`-----END ${r}-----`),i.join("\n")}}Uc.CertificateTag="CERTIFICATE",Uc.CrlTag="CRL",Uc.CertificateRequestTag="CERTIFICATE REQUEST",Uc.PublicKeyTag="PUBLIC KEY",Uc.PrivateKeyTag="PRIVATE KEY";class Rc extends nc{static isAsnEncoded(e){return i.isBufferSource(e)||"string"==typeof e}static toArrayBuffer(e){if("string"==typeof e){if(Uc.isPem(e))return Uc.decode(e)[0];if(l.isHex(e))return l.FromHex(e);if(l.isBase64(e))return l.FromBase64(e);if(l.isBase64Url(e))return l.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}{const t=l.ToBinary(e);return Uc.isPem(t)?Uc.decode(t)[0]:l.isHex(t)?l.FromHex(t):l.isBase64(t)?l.FromBase64(t):l.isBase64Url(t)?l.FromBase64Url(t):i.toArrayBuffer(e)}}constructor(...e){Rc.isAsnEncoded(e[0])?super(Rc.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){return"pem"===e?Uc.encode(this.rawData,this.tag):super.toString(e)}}class Dc extends Rc{constructor(e){Rc.isAsnEncoded(e)?super(e,dn):super(e),this.tag=Uc.PublicKeyTag}async export(...e){let t,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,t=e[2]||cc.get()):t=e[0]||cc.get();let n=this.rawData;const s=mr.parse(this.rawData,dn);return s.algorithm.algorithm===xo&&(n=function(e,t){return e.algorithm=new yn({algorithm:bo,parameters:null}),t=mr.serialize(e),t}(s,n)),t.subtle.importKey("spki",n,i,!0,r)}onInit(e){const t=ga.resolve(ba),r=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case bo:{const t=mr.parse(e.subjectPublicKey,Xo),n=i.toUint8Array(t.modulus);r.publicExponent=i.toUint8Array(t.publicExponent),r.modulusLength=(n[0]?n:n.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let r,i="SHA-1";return e.length>=1&&!(null===(t=e[0])||void 0===t?void 0:t.subtle)?(i=e[0]||i,r=e[1]||cc.get()):r=e[0]||cc.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(e){e||(e=cc.get());const t=mr.parse(this.rawData,dn);return await e.subtle.digest("SHA-1",t.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=mr.parse(this.rawData,dn);if(e.Algorithm=ic.serializeAlgorithm(t.algorithm),t.algorithm.algorithm===to)e["EC Point"]=t.subjectPublicKey;else e["Raw Data"]=t.subjectPublicKey;return e}}class Vc{static register(e,t){this.items.set(e,t)}static create(e){const t=new sc(e),r=this.items.get(t.type);return r?new r(e):t}}Vc.items=new Map;const Lc="crypto.signatureFormatter";class Hc{toAsnSignature(e,t){return i.toArrayBuffer(t)}toWebSignature(e,t){return i.toArrayBuffer(t)}}class $c extends Rc{constructor(e){Rc.isAsnEncoded(e)?super(e,xn):super(e),this.tag=Uc.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=mr.serialize(t),this.serialNumber=l.ToHex(t.serialNumber),this.subjectName=new fc(t.subject),this.subject=new fc(t.subject).toString(),this.issuerName=new fc(t.issuer),this.issuer=this.issuerName.toString();const r=ga.resolve(ba);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const n=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!n)throw new Error("Cannot get 'notAfter' value");this.notAfter=n,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map((e=>Vc.create(mr.serialize(e))))),this.publicKey=new Dc(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if("string"==typeof e){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter((t=>"string"==typeof e?t.type===e:t instanceof e))}async verify(e={},t=cc.get()){let r,n;const s=e.publicKey;try{if(s)if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},n=await s.publicKey.export(r,["verify"],t);else if(s instanceof Dc)r={...s.algorithm,...this.signatureAlgorithm},n=await s.export(r,["verify"],t);else if(i.isBufferSource(s)){const e=new Dc(s);r={...e.algorithm,...this.signatureAlgorithm},n=await e.export(r,["verify"],t)}else r={...s.algorithm,...this.signatureAlgorithm},n=s;else r={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(r,["verify"],t)}catch(e){return!1}const o=ga.resolveAll(Lc).reverse();let a=null;for(const e of o)if(a=e.toWebSignature(r,this.signature),a)break;if(!a)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const c=await t.subtle.verify(this.signatureAlgorithm,n,a,this.tbs);if(e.signatureOnly)return c;{const t=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<t&&t<this.notAfter.getTime()}}async getThumbprint(...e){let t,r="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(r=e[0]||r,t=e[1])),null!=t||(t=cc.get()),await t.subtle.digest(r,this.rawData)}async isSelfSigned(e=cc.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=mr.parse(this.rawData,xn),r=t.tbsCertificate,i=new ec("",{Version:`${An[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":ic.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new ec("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const e=new ec("");for(const t of this.extensions){const r=t.toTextObject();e[r[ec.NAME]]=r}i.Extensions=e}return e.Data=i,e.Signature=new ec("",{Algorithm:ic.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}$c.NAME="Certificate";class Mc extends sc{static async create(e,t=!1,r=cc.get()){if(e instanceof $c||ac.isCryptoKey(e)){const i=e instanceof $c?await e.publicKey.export(r):e,n=await r.subtle.exportKey("spki",i),s=new Dc(n),o=await s.getKeyIdentifier(r);return new Mc(l.ToHex(o),t)}return new Mc(e,t)}constructor(...e){if(i.isBufferSource(e[0]))super(e[0]);else if("string"==typeof e[0]){const t=new Zr({keyIdentifier:new Xr(l.FromHex(e[0]))});super(Jr,e[1],mr.serialize(t))}else{const t=e[0],r=t.name instanceof Ic?mr.parse(t.name.rawData,ti):t.name,i=new Zr({authorityCertIssuer:r,authorityCertSerialNumber:l.FromHex(t.serialNumber)});super(Jr,e[1],mr.serialize(i))}}onInit(e){super.onInit(e);const t=mr.parse(e.extnValue,Zr);t.keyIdentifier&&(this.keyId=l.ToHex(t.keyIdentifier)),t.authorityCertIssuer&&t.authorityCertSerialNumber&&(this.certId={name:t.authorityCertIssuer,serialNumber:l.ToHex(t.authorityCertSerialNumber)})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=mr.parse(this.value,Zr);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Ic(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Mc.NAME="Authority Key Identifier";class Fc extends sc{constructor(...e){if(i.isBufferSource(e[0])){super(e[0]);const t=mr.parse(this.value,Qr);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new Qr({cA:e[0],pathLenConstraint:e[1]});super(Yr,e[2],mr.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),void 0!==this.pathLength&&(e["Path Length"]=this.pathLength),e}}Fc.NAME="Basic Constraints",e.ExtendedKeyUsage=void 0,function(e){e.serverAuth="1.3.6.1.5.5.7.3.1",e.clientAuth="1.3.6.1.5.5.7.3.2",e.codeSigning="1.3.6.1.5.5.7.3.3",e.emailProtection="1.3.6.1.5.5.7.3.4",e.timeStamping="1.3.6.1.5.5.7.3.8",e.ocspSigning="1.3.6.1.5.5.7.3.9"}(e.ExtendedKeyUsage||(e.ExtendedKeyUsage={}));class Kc extends sc{constructor(...e){if(i.isBufferSource(e[0])){super(e[0]);const t=mr.parse(this.value,Ni);this.usages=t.map((e=>e))}else{const t=new Ni(e[0]);super(Ii,e[1],mr.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map((e=>rc.toString(e))).join(", "),e}}Kc.NAME="Extended Key Usages",e.KeyUsageFlags=void 0,function(e){e[e.digitalSignature=1]="digitalSignature",e[e.nonRepudiation=2]="nonRepudiation",e[e.keyEncipherment=4]="keyEncipherment",e[e.dataEncipherment=8]="dataEncipherment",e[e.keyAgreement=16]="keyAgreement",e[e.keyCertSign=32]="keyCertSign",e[e.cRLSign=64]="cRLSign",e[e.encipherOnly=128]="encipherOnly",e[e.decipherOnly=256]="decipherOnly"}(e.KeyUsageFlags||(e.KeyUsageFlags={}));class _c extends sc{constructor(...e){if(i.isBufferSource(e[0])){super(e[0]);const t=mr.parse(this.value,zi);this.usages=t.toNumber()}else{const t=new zi(e[0]);super(Fi,e[1],mr.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=mr.parse(this.value,zi);return e[""]=t.toJSON().join(", "),e}}_c.NAME="Key Usages";class zc extends sc{static async create(e,t=!1,r=cc.get()){let n;n=e instanceof Dc?e.rawData:"publicKey"in e?e.publicKey.rawData:i.isBufferSource(e)?e:await r.subtle.exportKey("spki",e);const s=new Dc(n),o=await s.getKeyIdentifier(r);return new zc(l.ToHex(o),t)}constructor(...e){if(i.isBufferSource(e[0])){super(e[0]);const t=mr.parse(this.value,an);this.keyId=l.ToHex(t)}else{const t="string"==typeof e[0]?l.FromHex(e[0]):e[0],r=new an(t);super(on,e[1],mr.serialize(r)),this.keyId=l.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=mr.parse(this.value,an);return e[""]=t,e}}zc.NAME="Subject Key Identifier";class qc extends sc{constructor(...e){i.isBufferSource(e[0])?super(e[0]):super(en,e[1],new Ic(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=mr.parse(e.extnValue,tn);this.names=new Ic(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const r in t)e[r]=t[r];return e}}qc.NAME="Subject Alternative Name";class Wc extends sc{constructor(...e){var t;if(i.isBufferSource(e[0])){super(e[0]);const t=mr.parse(this.value,fi);this.policies=t.map((e=>e.policyIdentifier))}else{const r=e[0],i=null!==(t=e[1])&&void 0!==t&&t,n=new fi(r.map((e=>new hi({policyIdentifier:e}))));super(oi,i,mr.serialize(n)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map((e=>new ec("",{},rc.toString(e)))),e}}var Gc;Wc.NAME="Certificate Policies",Vc.register(oi,Wc);class Jc{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}Ar([fr({type:jt.ObjectIdentifier})],Jc.prototype,"attrId",void 0),Ar([fr({type:jt.Any,repeated:"set"})],Jc.prototype,"attrValues",void 0);let Xc=Gc=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Gc.prototype)}};var Zc;Xc=Gc=Ar([hr({type:Tt.Sequence,itemType:Jc})],Xc);let Yc=Zc=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,Zc.prototype)}};Yc=Zc=Ar([hr({type:Tt.Sequence,itemType:bs})],Yc);class Qc{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],Qc.prototype,"certId",void 0),Ar([fr({type:jt.Any,context:0})],Qc.prototype,"certValue",void 0);class eu{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],eu.prototype,"crlId",void 0),Ar([fr({type:jt.Any,context:0})],eu.prototype,"crltValue",void 0);class tu extends Rt{}let ru=class{constructor(e={}){this.encryptionAlgorithm=new yn,this.encryptedData=new tu,Object.assign(this,e)}};var iu,nu;Ar([fr({type:yn})],ru.prototype,"encryptionAlgorithm",void 0),Ar([fr({type:tu})],ru.prototype,"encryptedData",void 0),function(e){e[e.v1=0]="v1"}(nu||(nu={}));class su extends Rt{}let ou=iu=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,iu.prototype)}};ou=iu=Ar([hr({type:Tt.Sequence,itemType:rn})],ou);class au{constructor(e={}){this.version=nu.v1,this.privateKeyAlgorithm=new yn,this.privateKey=new su,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],au.prototype,"version",void 0),Ar([fr({type:yn})],au.prototype,"privateKeyAlgorithm",void 0),Ar([fr({type:su})],au.prototype,"privateKey",void 0),Ar([fr({type:ou,implicit:!0,context:0,optional:!0})],au.prototype,"attributes",void 0);let cu=class extends au{};cu=Ar([hr({type:Tt.Sequence})],cu);let uu=class extends ru{};uu=Ar([hr({type:Tt.Sequence})],uu);class lu{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],lu.prototype,"secretTypeId",void 0),Ar([fr({type:jt.Any,context:0})],lu.prototype,"secretValue",void 0);class pu{constructor(e={}){this.mac=new zo,this.macSalt=new Rt,this.iterations=1,Object.assign(this,e)}}Ar([fr({type:zo})],pu.prototype,"mac",void 0),Ar([fr({type:Rt})],pu.prototype,"macSalt",void 0),Ar([fr({type:jt.Integer,defaultValue:1})],pu.prototype,"iterations",void 0);class hu{constructor(e={}){this.version=3,this.authSafe=new bs,this.macData=new pu,Object.assign(this,e)}}var fu;Ar([fr({type:jt.Integer})],hu.prototype,"version",void 0),Ar([fr({type:bs})],hu.prototype,"authSafe",void 0),Ar([fr({type:pu,optional:!0})],hu.prototype,"macData",void 0);class yu{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:jt.ObjectIdentifier})],yu.prototype,"bagId",void 0),Ar([fr({type:jt.Any,context:0})],yu.prototype,"bagValue",void 0),Ar([fr({type:Jc,repeated:"set",optional:!0})],yu.prototype,"bagAttributes",void 0);let du=fu=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,fu.prototype)}};var gu,vu,mu;du=fu=Ar([hr({type:Tt.Sequence,itemType:yu})],du);const wu="1.2.840.113549.1.9",bu=`${wu}.7`,Au=`${wu}.14`;let Su=class extends Ur{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};Ar([fr({type:jt.IA5String})],Su.prototype,"ia5String",void 0),Su=Ar([hr({type:Tt.Choice})],Su);let xu=class extends bs{};xu=Ar([hr({type:Tt.Sequence})],xu);let Bu=class extends hu{};Bu=Ar([hr({type:Tt.Sequence})],Bu);let ku=class extends ru{};ku=Ar([hr({type:Tt.Sequence})],ku);let Eu=class{constructor(e=""){this.value=e}toString(){return this.value}};Ar([fr({type:jt.IA5String})],Eu.prototype,"value",void 0),Eu=Ar([hr({type:Tt.Choice})],Eu);let Cu=class extends Su{};Cu=Ar([hr({type:Tt.Choice})],Cu);let Ou=class extends Ur{};Ou=Ar([hr({type:Tt.Choice})],Ou);let Iu=class{constructor(e=new Date){this.value=e}};Ar([fr({type:jt.GeneralizedTime})],Iu.prototype,"value",void 0),Iu=Ar([hr({type:Tt.Choice})],Iu);let Nu=class extends Ur{};Nu=Ar([hr({type:Tt.Choice})],Nu);let Tu=class{constructor(e="M"){this.value=e}toString(){return this.value}};Ar([fr({type:jt.PrintableString})],Tu.prototype,"value",void 0),Tu=Ar([hr({type:Tt.Choice})],Tu);let ju=class{constructor(e=""){this.value=e}toString(){return this.value}};Ar([fr({type:jt.PrintableString})],ju.prototype,"value",void 0),ju=Ar([hr({type:Tt.Choice})],ju);let Pu=class extends ju{};Pu=Ar([hr({type:Tt.Choice})],Pu);let Uu=class extends Ur{};Uu=Ar([hr({type:Tt.Choice})],Uu);let Ru=class{constructor(e=""){this.value=e}toString(){return this.value}};Ar([fr({type:jt.ObjectIdentifier})],Ru.prototype,"value",void 0),Ru=Ar([hr({type:Tt.Choice})],Ru);let Du=class extends gn{};Du=Ar([hr({type:Tt.Choice})],Du);let Vu=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};Ar([fr({type:jt.Integer})],Vu.prototype,"value",void 0),Vu=Ar([hr({type:Tt.Choice})],Vu);let Lu=class extends Ln{};Lu=Ar([hr({type:Tt.Sequence})],Lu);let Hu=class extends Ur{};Hu=Ar([hr({type:Tt.Choice})],Hu);let $u=gu=class extends bn{constructor(e){super(e),Object.setPrototypeOf(this,gu.prototype)}};$u=gu=Ar([hr({type:Tt.Sequence})],$u);let Mu=vu=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,vu.prototype)}};Mu=vu=Ar([hr({type:Tt.Set,itemType:Dn})],Mu);let Fu=class{constructor(e=""){this.value=e}toString(){return this.value}};Ar([fr({type:jt.BmpString})],Fu.prototype,"value",void 0),Fu=Ar([hr({type:Tt.Choice})],Fu);let Ku=class extends yn{};Ku=Ar([hr({type:Tt.Sequence})],Ku);let _u=mu=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,mu.prototype)}};_u=mu=Ar([hr({type:Tt.Sequence,itemType:Ku})],_u);class zu extends nc{constructor(...e){let t;if(i.isBufferSource(e[0]))t=i.toArrayBuffer(e[0]);else{const r=e[0],n=Array.isArray(e[1])?e[1].map((e=>i.toArrayBuffer(e))):[];t=mr.serialize(new rn({type:r,values:n}))}super(t,rn)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map((e=>new ec("",{"":e}))),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[ec.NAME]===zu.NAME&&(e[ec.NAME]=rc.toString(this.type)),e}}zu.NAME="Attribute";class qu extends zu{constructor(...e){var t;if(i.isBufferSource(e[0]))super(e[0]);else{const t=new Hu({printableString:e[0]});super(bu,[mr.serialize(t)])}null!==(t=this.password)&&void 0!==t||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const e=mr.parse(this.values[0],Hu);this.password=e.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[ec.VALUE]=this.password,e}}qu.NAME="Challenge Password";class Wu extends zu{constructor(...e){var t;if(i.isBufferSource(e[0]))super(e[0]);else{const t=e[0],r=new bn;for(const e of t)r.push(mr.parse(e.rawData,wn));super(Au,[mr.serialize(r)])}null!==(t=this.items)&&void 0!==t||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const e=mr.parse(this.values[0],bn);this.items=e.map((e=>Vc.create(mr.serialize(e))))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map((e=>e.toTextObject()));for(const r of t)e[r[ec.NAME]]=r;return e}}Wu.NAME="Extensions";class Gu{static register(e,t){this.items.set(e,t)}static create(e){const t=new zu(e),r=this.items.get(t.type);return r?new r(e):t}}var Ju;Gu.items=new Map,e.RsaAlgorithm=Ju=class{static createPssParams(e,t){const r=Ju.getHashAlgorithm(e);return r?new _o({hashAlgorithm:r,maskGenAlgorithm:new yn({algorithm:Lo,parameters:mr.serialize(r)}),saltLength:t}):null}static getHashAlgorithm(e){const t=ga.resolve(ba);return"string"==typeof e?t.toAsnAlgorithm({name:e}):"object"==typeof e&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if(!("hash"in e))return new yn({algorithm:bo,parameters:null});{let t;if("string"==typeof e.hash)t=e.hash;else{if(!e.hash||"object"!=typeof e.hash||!("name"in e.hash)||"string"!=typeof e.hash.name)throw new Error("Cannot get hash algorithm name");t=e.hash.name.toUpperCase()}switch(t.toLowerCase()){case"sha-1":return new yn({algorithm:Eo,parameters:null});case"sha-256":return new yn({algorithm:Oo,parameters:null});case"sha-384":return new yn({algorithm:Io,parameters:null});case"sha-512":return new yn({algorithm:No,parameters:null})}}break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e)||"number"!=typeof e.saltLength)throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=Ju.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new yn({algorithm:xo,parameters:mr.serialize(t)})}return new yn({algorithm:xo,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case bo:return{name:"RSASSA-PKCS1-v1_5"};case Eo:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Oo:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Io:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case No:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case xo:if(e.parameters){const t=mr.parse(e.parameters,_o);return{name:"RSA-PSS",hash:ga.resolve(ba).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}return{name:"RSA-PSS"}}return null}},e.RsaAlgorithm=Ju=Ar([va()],e.RsaAlgorithm),ga.registerSingleton(ma,e.RsaAlgorithm),e.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new yn({algorithm:Po});case"sha-256":return new yn({algorithm:Ro});case"sha-384":return new yn({algorithm:Do});case"sha-512":return new yn({algorithm:Vo})}return null}toWebAlgorithm(e){switch(e.algorithm){case Po:return{name:"SHA-1"};case Ro:return{name:"SHA-256"};case Do:return{name:"SHA-384"};case Vo:return{name:"SHA-512"}}return null}},e.ShaAlgorithm=Ar([va()],e.ShaAlgorithm),ga.registerSingleton(ma,e.ShaAlgorithm);class Xu{addPadding(e,t){const r=i.toUint8Array(t),n=new Uint8Array(e);return n.set(r,e-r.length),n}removePadding(e,t=!1){let r=i.toUint8Array(e);for(let e=0;e<r.length;e++)if(r[e]){r=r.slice(e);break}if(t&&r[0]>127){const e=new Uint8Array(r.length+1);return e.set(r,1),e.buffer}return r.buffer}toAsnSignature(e,t){if("ECDSA"===e.name){const r=e.namedCurve,n=Xu.namedCurveSize.get(r)||Xu.defaultNamedCurveSize,s=new mo,o=i.toUint8Array(t);return s.r=this.removePadding(o.slice(0,n),!0),s.s=this.removePadding(o.slice(n,n+n),!0),mr.serialize(s)}return null}toWebSignature(e,t){if("ECDSA"===e.name){const r=mr.parse(t,mo),i=e.namedCurve,n=Xu.namedCurveSize.get(i)||Xu.defaultNamedCurveSize;return function(...e){const t=e.map((e=>e.byteLength)).reduce(((e,t)=>e+t)),r=new Uint8Array(t);let i=0;return e.map((e=>new Uint8Array(e))).forEach((e=>{for(const t of e)r[i++]=t})),r.buffer}(this.addPadding(n,this.removePadding(r.r)),this.addPadding(n,this.removePadding(r.s)))}return null}}Xu.namedCurveSize=new Map,Xu.defaultNamedCurveSize=32;const Zu="1.3.101.110",Yu="1.3.101.111",Qu="1.3.101.112",el="1.3.101.113";var tl;e.EdAlgorithm=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=Qu;break;case"ed448":t=el}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=Zu;break;case"x448":t=Yu}}return t?new yn({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case Qu:return{name:"EdDSA",namedCurve:"Ed25519"};case el:return{name:"EdDSA",namedCurve:"Ed448"};case Zu:return{name:"ECDH-ES",namedCurve:"X25519"};case Yu:return{name:"ECDH-ES",namedCurve:"X448"}}return null}},e.EdAlgorithm=Ar([va()],e.EdAlgorithm),ga.registerSingleton(ma,e.EdAlgorithm);let rl=tl=class extends vr{constructor(e){super(e),Object.setPrototypeOf(this,tl.prototype)}};rl=tl=Ar([hr({type:Tt.Sequence,itemType:rn})],rl);class il{constructor(e={}){this.version=0,this.subject=new Hr,this.subjectPKInfo=new dn,this.attributes=new rl,Object.assign(this,e)}}Ar([fr({type:jt.Integer})],il.prototype,"version",void 0),Ar([fr({type:Hr})],il.prototype,"subject",void 0),Ar([fr({type:dn})],il.prototype,"subjectPKInfo",void 0),Ar([fr({type:rl,implicit:!0,context:0})],il.prototype,"attributes",void 0);class nl{constructor(e={}){this.certificationRequestInfo=new il,this.signatureAlgorithm=new yn,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}Ar([fr({type:il})],nl.prototype,"certificationRequestInfo",void 0),Ar([fr({type:yn})],nl.prototype,"signatureAlgorithm",void 0),Ar([fr({type:jt.BitString})],nl.prototype,"signature",void 0);class sl extends Rc{constructor(e){Rc.isAsnEncoded(e)?super(e,nl):super(e),this.tag=Uc.CertificateRequestTag}onInit(e){this.tbs=mr.serialize(e.certificationRequestInfo),this.publicKey=new Dc(e.certificationRequestInfo.subjectPKInfo);const t=ga.resolve(ba);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map((e=>Gu.create(mr.serialize(e))));const r=this.getAttribute(Au);this.extensions=[],r instanceof Wu&&(this.extensions=r.items),this.subjectName=new fc(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=cc.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(t,["verify"],e),i=ga.resolveAll(Lc).reverse();let n=null;for(const e of i)if(n=e.toWebSignature(t,this.signature),n)break;if(!n)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,r,n,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=mr.parse(this.rawData,nl),r=t.certificationRequestInfo,i=new ec("",{Version:`${An[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const e=new ec("");for(const t of this.attributes){const r=t.toTextObject();e[r[ec.NAME]]=r}i.Attributes=e}return e.Data=i,e.Signature=new ec("",{Algorithm:ic.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}sl.NAME="PKCS#10 Certificate Request";class ol extends Array{constructor(e){if(super(),Rc.isAsnEncoded(e))this.import(e);else if(e instanceof $c)this.push(e);else if(Array.isArray(e))for(const t of e)this.push(t)}export(e){const t=new eo;t.version=1,t.encapContentInfo.eContentType="1.2.840.113549.1.7.1",t.encapContentInfo.eContent=new As({single:new Rt}),t.certificates=new ws(this.map((e=>new ms({certificate:mr.parse(e.rawData,xn)}))));const r=new bs({contentType:Zs,content:mr.serialize(t)}),i=mr.serialize(r);return"raw"===e?i:this.toString(e)}import(e){const t=Rc.toArrayBuffer(e),r=mr.parse(t,bs);if(r.contentType!==Zs)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");const i=mr.parse(r.content,eo);this.clear();for(const e of i.certificates||[])e.certificate&&this.push(new $c(e.certificate))}clear(){for(;this.pop(););}toString(e="pem"){const t=this.export("raw");switch(e){case"pem":return Uc.encode(t,"CMS");case"pem-chain":return this.map((e=>e.toString("pem"))).join("\n");case"asn":return mr.toString(t);case"hex":return l.ToHex(t);case"base64":return l.ToBase64(t);case"base64url":return l.ToBase64Url(t);case"text":return ic.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){const e=mr.parse(this.export("raw"),bs),t=mr.parse(e.content,eo);return new ec("X509Certificates",{"Content Type":rc.toString(e.contentType),Content:new ec("",{Version:`${In[t.version]} (${t.version})`,Certificates:new ec("",{Certificate:this.map((e=>e.toTextObject()))})})})}}var al;e.X509CrlReason=void 0,(al=e.X509CrlReason||(e.X509CrlReason={}))[al.unspecified=0]="unspecified",al[al.keyCompromise=1]="keyCompromise",al[al.cACompromise=2]="cACompromise",al[al.affiliationChanged=3]="affiliationChanged",al[al.superseded=4]="superseded",al[al.cessationOfOperation=5]="cessationOfOperation",al[al.certificateHold=6]="certificateHold",al[al.removeFromCRL=8]="removeFromCRL",al[al.privilegeWithdrawn=9]="privilegeWithdrawn",al[al.aACompromise=10]="aACompromise";class cl extends nc{constructor(...e){let t;t=i.isBufferSource(e[0])?i.toArrayBuffer(e[0]):mr.serialize(new Bn({userCertificate:e[0],revocationDate:new gn(e[1]),crlEntryExtensions:e[2]})),super(t,Bn)}onInit(e){this.serialNumber=l.ToHex(e.userCertificate),this.revocationDate=e.revocationDate.getTime(),this.extensions=[],e.crlEntryExtensions&&(this.extensions=e.crlEntryExtensions.map((e=>{const t=Vc.create(mr.serialize(e));switch(t.type){case ki:this.reason=mr.parse(t.value,Ci).reason;break;case Li:this.invalidity=mr.parse(t.value,Hi).value}return t})))}}class ul extends Rc{constructor(e){Rc.isAsnEncoded(e)?super(e,En):super(e),this.tag=Uc.CrlTag}onInit(e){var t,r;const i=e.tbsCertList;this.tbs=mr.serialize(i),this.version=i.version;const n=ga.resolve(ba);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.tbsCertListSignatureAlgorithm=i.signature,this.certListSignatureAlgorithm=e.signatureAlgorithm,this.signature=e.signature,this.issuerName=new fc(i.issuer),this.issuer=this.issuerName.toString();const s=i.thisUpdate.getTime();if(!s)throw new Error("Cannot get 'thisUpdate' value");this.thisUpdate=s;const o=null===(t=i.nextUpdate)||void 0===t?void 0:t.getTime();this.nextUpdate=o,this.entries=(null===(r=i.revokedCertificates)||void 0===r?void 0:r.map((e=>new cl(mr.serialize(e)))))||[],this.extensions=[],i.crlExtensions&&(this.extensions=i.crlExtensions.map((e=>Vc.create(mr.serialize(e)))))}getExtension(e){for(const t of this.extensions)if("string"==typeof e){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter((t=>"string"==typeof e?t.type===e:t instanceof e))}async verify(e,t=cc.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw new Error("algorithm identifier in the sequence tbsCertList and CertificateList mismatch");let r,i;const n=e.publicKey;try{n instanceof $c?(r={...n.publicKey.algorithm,...n.signatureAlgorithm},i=await n.publicKey.export(r,["verify"])):n instanceof Dc?(r={...n.algorithm,...this.signature},i=await n.export(r,["verify"])):(r={...n.algorithm,...this.signature},i=n)}catch(e){return!1}const s=ga.resolveAll(Lc).reverse();let o=null;for(const e of s)if(o=e.toWebSignature(r,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return await t.subtle.verify(this.signatureAlgorithm,i,o,this.tbs)}async getThumbprint(...e){let t,r="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(r=e[0]||r,t=e[1])),null!=t||(t=cc.get()),await t.subtle.digest(r,this.rawData)}findRevoked(e){const t="string"==typeof e?e:e.serialNumber;for(const e of this.entries)if(e.serialNumber===t)return e;return null}}return Vc.register(Yr,Fc),Vc.register(Ii,Kc),Vc.register(Fi,_c),Vc.register(on,zc),Vc.register(Jr,Mc),Vc.register(en,qc),Gu.register(bu,qu),Gu.register(Au,Wu),ga.registerSingleton(Lc,Hc),ga.registerSingleton(Lc,Xu),Xu.namedCurveSize.set("P-256",32),Xu.namedCurveSize.set("K-256",32),Xu.namedCurveSize.set("P-384",48),Xu.namedCurveSize.set("P-521",66),e.AlgorithmProvider=wa,e.AsnData=nc,e.AsnDefaultSignatureFormatter=Hc,e.AsnEcSignatureFormatter=Xu,e.Attribute=zu,e.AttributeFactory=Gu,e.AuthorityKeyIdentifierExtension=Mc,e.BasicConstraintsExtension=Fc,e.CertificatePolicyExtension=Wc,e.ChallengePasswordAttribute=qu,e.CryptoProvider=ac,e.DefaultAlgorithmSerializer=tc,e.ExtendedKeyUsageExtension=Kc,e.Extension=sc,e.ExtensionFactory=Vc,e.ExtensionsAttribute=Wu,e.GeneralName=Oc,e.GeneralNames=Ic,e.KeyUsagesExtension=_c,e.Name=fc,e.NameIdentifier=lc,e.OidSerializer=rc,e.PemConverter=Uc,e.Pkcs10CertificateRequest=sl,e.Pkcs10CertificateRequestGenerator=class{static async create(e,t=cc.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");const r=await t.subtle.exportKey("spki",e.keys.publicKey),i=new nl({certificationRequestInfo:new il({subjectPKInfo:mr.parse(r,dn)})});if(e.name){const t=e.name instanceof fc?e.name:new fc(e.name);i.certificationRequestInfo.subject=mr.parse(t.toArrayBuffer(),Hr)}if(e.attributes)for(const t of e.attributes)i.certificationRequestInfo.attributes.push(mr.parse(t.rawData,rn));if(e.extensions&&e.extensions.length){const t=new rn({type:Au}),r=new bn;for(const t of e.extensions)r.push(mr.parse(t.rawData,wn));t.values.push(mr.serialize(r)),i.certificationRequestInfo.attributes.push(t)}const n={...e.signingAlgorithm,...e.keys.privateKey.algorithm},s=ga.resolve(ba);i.signatureAlgorithm=s.toAsnAlgorithm(n);const o=mr.serialize(i.certificationRequestInfo),a=await t.subtle.sign(n,e.keys.privateKey,o),c=ga.resolveAll(Lc).reverse();let u=null;for(const e of c)if(u=e.toAsnSignature(n,a),u)break;if(!u)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return i.signature=u,new sl(mr.serialize(i))}},e.PublicKey=Dc,e.SubjectAlternativeNameExtension=qc,e.SubjectKeyIdentifierExtension=zc,e.TextConverter=ic,e.TextObject=ec,e.X509Certificate=$c,e.X509CertificateGenerator=class{static async createSelfSigned(e,t=cc.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=cc.get()){var r;let n;n=e.publicKey instanceof Dc?e.publicKey.rawData:"publicKey"in e.publicKey?e.publicKey.publicKey.rawData:i.isBufferSource(e.publicKey)?e.publicKey:await t.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?i.toUint8Array(l.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&0===s[0]&&(s[1]|=128);const o=e.notBefore||new Date,a=e.notAfter||new Date(o.getTime()+31536e6),c=new xn({tbsCertificate:new Sn({version:An.v3,serialNumber:s,validity:new vn({notBefore:o,notAfter:a}),extensions:new bn((null===(r=e.extensions)||void 0===r?void 0:r.map((e=>mr.parse(e.rawData,wn))))||[]),subjectPublicKeyInfo:mr.parse(n,dn)})});if(e.subject){const t=e.subject instanceof fc?e.subject:new fc(e.subject);c.tbsCertificate.subject=mr.parse(t.toArrayBuffer(),Hr)}if(e.issuer){const t=e.issuer instanceof fc?e.issuer:new fc(e.issuer);c.tbsCertificate.issuer=mr.parse(t.toArrayBuffer(),Hr)}const u="signingKey"in e?{hash:"SHA-256",...e.signingAlgorithm,...e.signingKey.algorithm}:e.publicKey.algorithm,p=ga.resolve(ba);c.tbsCertificate.signature=c.signatureAlgorithm=p.toAsnAlgorithm(u);const h=mr.serialize(c.tbsCertificate),f="signingKey"in e?await t.subtle.sign(u,e.signingKey,h):e.signature,y=ga.resolveAll(Lc).reverse();let d=null;for(const e of y)if(d=e.toAsnSignature(u,f),d)break;if(!d)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=d,new $c(mr.serialize(c))}},e.X509Certificates=ol,e.X509ChainBuilder=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=cc.get()){const r=new ol(e);let i=e;for(;i=await this.findIssuer(i,t);){const e=await i.getThumbprint(t);for(const i of r){if(p(e,await i.getThumbprint(t)))throw new Error("Cannot build a certificate chain. Circular dependency.")}r.push(i)}return r}async findIssuer(e,t=cc.get()){if(!await e.isSelfSigned(t)){const r=e.getExtension(Jr);for(const i of this.certificates)if(i.subject===e.issuer){if(r)if(r.keyId){const e=i.getExtension(on);if(e&&e.keyId!==r.keyId)continue}else if(r.certId){const e=i.getExtension(en);if(e&&(r.certId.serialNumber!==i.serialNumber||!p(mr.serialize(r.certId.name),mr.serialize(e))))continue}try{const r={...i.publicKey.algorithm,...e.signatureAlgorithm},n=await i.publicKey.export(r,["verify"],t);if(!await e.verify({publicKey:n,signatureOnly:!0},t))continue}catch(e){continue}return i}}return null}},e.X509Crl=ul,e.X509CrlEntry=cl,e.X509CrlGenerator=class{static async create(e,t=cc.get()){var r;const i=e.issuer instanceof fc?e.issuer:new fc(e.issuer),n=new En({tbsCertList:new kn({version:An.v2,issuer:mr.parse(i.toArrayBuffer(),Hr),thisUpdate:new gn(e.thisUpdate||new Date)})});if(e.nextUpdate&&(n.tbsCertList.nextUpdate=new gn(e.nextUpdate)),e.extensions&&e.extensions.length&&(n.tbsCertList.crlExtensions=new bn(e.extensions.map((e=>mr.parse(e.rawData,wn)))||[])),e.entries&&e.entries.length){n.tbsCertList.revokedCertificates=[];for(const t of e.entries){const i=Rc.toArrayBuffer(t.serialNumber);if(n.tbsCertList.revokedCertificates.findIndex((e=>p(e.userCertificate,i)))>-1)throw new Error(`Certificate serial number ${t.serialNumber} already exists in tbsCertList`);const s=new Bn({userCertificate:i,revocationDate:new gn(t.revocationDate||new Date)});if("extensions"in t&&(null===(r=t.extensions)||void 0===r?void 0:r.length)?s.crlEntryExtensions=t.extensions.map((e=>mr.parse(e.rawData,wn))):s.crlEntryExtensions=[],!(t instanceof cl)&&(t.reason&&s.crlEntryExtensions.push(new wn({extnID:ki,critical:!1,extnValue:new Rt(mr.serialize(new Ci(t.reason)))})),t.invalidity&&s.crlEntryExtensions.push(new wn({extnID:Li,critical:!1,extnValue:new Rt(mr.serialize(new Hi(t.invalidity)))})),t.issuer)){const t=e.issuer instanceof fc?e.issuer:new fc(e.issuer);s.crlEntryExtensions.push(new wn({extnID:ii,critical:!1,extnValue:new Rt(mr.serialize(mr.parse(t.toArrayBuffer(),Hr)))}))}n.tbsCertList.revokedCertificates.push(s)}}const s={...e.signingAlgorithm,...e.signingKey.algorithm},o=ga.resolve(ba);n.tbsCertList.signature=n.signatureAlgorithm=o.toAsnAlgorithm(s);const a=mr.serialize(n.tbsCertList),c=await t.subtle.sign(s,e.signingKey,a),u=ga.resolveAll(Lc).reverse();let l=null;for(const e of u)if(l=e.toAsnSignature(s,c),l)break;if(!l)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return n.signature=l,new ul(mr.serialize(n))}},e.cryptoProvider=cc,e.diAlgorithm=ma,e.diAlgorithmProvider=ba,e.diAsnSignatureFormatter=Lc,e.idEd25519=Qu,e.idEd448=el,e.idX25519=Zu,e.idX448=Yu,e}({});