@catena/cli 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +16 -0
  2. package/dist/index.mjs +41 -25
  3. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{C as e,S as t,_ as n,b as r,g as i,v as a,x as o,y as s}from"./dist-B0qgGwAq.mjs";import{n as c}from"./base64-WTSXTrii.mjs";import{defineCommand as l,renderUsage as u,runMain as d}from"citty";import*as f from"valibot";import{ECDH as p,createECDH as m,createHash as h,createPrivateKey as g,randomBytes as _,sign as v}from"node:crypto";import{execFile as y,spawn as b}from"node:child_process";import{accessSync as x,chmodSync as S,constants as C,existsSync as w,mkdirSync as T,readFileSync as E,realpathSync as D,renameSync as O,rmSync as k,statSync as A,writeFileSync as j}from"node:fs";import{homedir as M}from"node:os";import{dirname as N,isAbsolute as ee,join as te,resolve as ne}from"node:path";import{createServer as P}from"node:http";import{constants as re,isUtf8 as ie}from"node:buffer";import F from"semver";var ae=`@catena/cli`,oe=`0.5.0`;function se(e){return e instanceof Error?e.message:String(e)}function I(e){console.error(se(e)),process.exit(1)}const L=f.string(),ce=f.boolean();function le(e){return e===void 0}function ue(e){return e.issues?.[0]?.message??`Invalid value`}function de(e,t,n,r){return I(`${e}: ${t}${r?` (got: ${String(n)})`:``}`)}function fe(e,t,n,r){let i=f.safeParse(e,t);return i.success?i.output:de(n,ue(i),t,r)}function R(e,t){let n=t.schema??L;return{type:e,description:t.description,negativeDescription:t.negativeDescription,required:t.required,default:t.default,parseValue(e,r){let i=le(e)?t.default:e;if(le(i)){t.required===!0&&I(`${r} is required`);return}return fe(n,i,r,t.showValueInError===!0)}}}function z(e){return R(`string`,e)}function pe(e){return R(`positional`,e)}function B(e){let t=e.schema??L;return{type:`string`,description:e.description,repeatable:!0,parseValue(n,r){return(Array.isArray(n)?n:[]).map(n=>fe(t,n,r,e.showValueInError===!0))}}}function me(e){return{type:`boolean`,description:e.description,negativeDescription:e.negativeDescription,required:e.required,default:e.default,parseValue(t,n){let r=le(t)?e.default:t;if(le(r)){e.required===!0&&I(`${n} is required`);return}return fe(ce,r,n,!1)}}}function V(e){return he(`string`,e)}function he(e,t){return R(e,{description:t.description,required:t.required,default:t.default,schema:f.picklist(t.choices,`must be one of ${t.choices.join(`|`)}`),showValueInError:!0})}function ge(e,t){return t.type===`positional`?`<${e}>`:`--${e}`}function H(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z0-9])([A-Z][a-z])/g,`$1 $2`).split(/[ _-]/).filter(e=>e.length>0)}function _e(e){return H(e).join(`-`).toLowerCase()}function ve(e){return H(e).map((e,t)=>t===0?e.charAt(0).toLowerCase()+e.slice(1):e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function U(e){return[`--${e}`,`--${_e(e)}`,`--${ve(e)}`]}function ye(e){let t=e.indexOf(`=`);return t===-1?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}function be(e,t,n){let r=e.indexOf(`--`),i=r===-1?e.length:r,a=[...e.slice(0,i).filter(e=>!e.startsWith(`--no-`)),...e.slice(i)],o=new Set(U(t)),s=new Set(Object.entries(n).filter(([e,n])=>e!==t&&n.type===`string`).flatMap(([e])=>U(e))),c=[];for(let e=0;e<a.length;e++){let t=a[e];if(t===`--`)break;let[n,r]=ye(t);if(o.has(n)){r===void 0?(c.push(a[e+1]??``),e++):c.push(r);continue}s.has(n)&&r===void 0&&e++}return c}function xe(e){let t=e.required??(e.type!==`positional`&&void 0);return e.type===`boolean`?{type:e.type,description:e.description,negativeDescription:e.negativeDescription,required:t,default:typeof e.default==`boolean`?e.default:void 0}:{type:e.type,description:e.description,required:t,default:typeof e.default==`string`?e.default:void 0}}function W(e){return{args:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,xe(t)])),label(t){return ge(t,e[t])},parse(t,n){let r=(r,i)=>{if(i.repeatable!==!0)return t[r];if(n===void 0)throw Error(`parse() needs the command's raw argv to collect the repeatable --${r} flag`);return be(n,r,e)};return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.parseValue(r(e,t),ge(e,t))]))}}}const Se=z({description:`Credential profile name`}),Ce=me({description:`Print compact single-line JSON (for piping)`,default:!1}),G=/^[a-zA-Z0-9_-]+$/,we=f.pipe(f.string(`ID must be a string`),f.minLength(1,`ID must not be empty`),f.maxLength(256,`ID is too long (max 256 characters)`),f.regex(G,`ID may only contain letters, digits, hyphens, and underscores`)),Te=[`base`,`base-sepolia`],Ee=[`usdc`],De=`base`,Oe=f.pipe(f.string(),f.trim(),f.guard(e=>/^0x[0-9a-fA-F]{40}$/.test(e),`Must be a 0x-prefixed hex wallet address`));function ke(e){return V({description:e.description,choices:Te,...e.default===void 0?{}:{default:e.default}})}var Ae=[`u8`,`u16`,`u32`,`u64`,`u128`,`i8`,`i16`,`i32`,`i64`,`i128`,`f32`,`f64`],je=function(){function e(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return e.prototype.resize_if_necessary=function(e){if(this.buffer_size-this.offset<e){this.buffer_size=Math.max(this.buffer_size*2,this.buffer_size+e);var t=new ArrayBuffer(this.buffer_size);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t,this.view=new DataView(t)}},e.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},e.prototype.store_value=function(e,t){var n=t.substring(1),r=parseInt(n)/8;this.resize_if_necessary(r);var i=t[0]===`f`?`setFloat${n}`:t[0]===`i`?`setInt${n}`:`setUint${n}`;this.view[i](this.offset,e,!0),this.offset+=r},e.prototype.store_bytes=function(e){this.resize_if_necessary(e.length),new Uint8Array(this.buffer).set(new Uint8Array(e),this.offset),this.offset+=e.length},e}(),Me=function(){function e(e){this.offset=0,this.buffer_size=e.length,this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e),this.view=new DataView(this.buffer)}return e.prototype.assert_enough_buffer=function(e){if(this.offset+e>this.buffer.byteLength)throw Error(`Error in schema, the buffer is smaller than expected`)},e.prototype.consume_value=function(e){var t=e.substring(1),n=parseInt(t)/8;this.assert_enough_buffer(n);var r=e[0]===`f`?`getFloat${t}`:e[0]===`i`?`getInt${t}`:`getUint${t}`,i=this.view[r](this.offset,!0);return this.offset+=n,i},e.prototype.consume_bytes=function(e){this.assert_enough_buffer(e);var t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t},e}(),Ne=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();function Pe(e){return Array.isArray(e)||!!e&&typeof e==`object`&&`length`in e&&typeof e.length==`number`&&(e.length===0||e.length>0&&e.length-1 in e)}function Fe(e,t,n){if(typeof e!==t)throw Error(`Expected ${t} not ${typeof e}(${e}) at ${n.join(`.`)}`)}function K(e,t){var n=[`number`,`string`,`bigint`,`boolean`].includes(typeof e),r=typeof e==`object`&&!!e&&`toString`in e;if(!n&&!r)throw Error(`Expected bigint, number, boolean or string not ${typeof e}(${e}) at ${t.join(`.`)}`)}function Ie(e,t,n){if(e!==t)throw Error(`Array length ${e} does not match schema length ${t} at ${n.join(`.`)}`)}function Le(e,t){if(typeof e!=`object`||!e)throw Error(`Expected object not ${typeof e}(${e}) at ${t.join(`.`)}`)}Ae.concat([`bool`,`string`]),function(e){Ne(t,e);function t(t,n){var r=`Invalid schema: ${JSON.stringify(t)} expected ${n}`;return e.call(this,r)||this}return t}(Error),function(){function e(e){this.encoded=new je,this.fieldPath=[`value`],this.checkTypes=e}return e.prototype.encode=function(e,t){return this.encode_value(e,t),this.encoded.get_used_buffer()},e.prototype.encode_value=function(e,t){if(typeof t==`string`){if(Ae.includes(t))return this.encode_integer(e,t);if(t===`string`)return this.encode_string(e);if(t===`bool`)return this.encode_boolean(e)}if(typeof t==`object`){if(`option`in t)return this.encode_option(e,t);if(`enum`in t)return this.encode_enum(e,t);if(`array`in t)return this.encode_array(e,t);if(`set`in t)return this.encode_set(e,t);if(`map`in t)return this.encode_map(e,t);if(`struct`in t)return this.encode_struct(e,t)}},e.prototype.encode_integer=function(e,t){var n=parseInt(t.substring(1));n<=32||t==`f64`?(this.checkTypes&&Fe(e,`number`,this.fieldPath),this.encoded.store_value(e,t)):(this.checkTypes&&K(e,this.fieldPath),this.encode_bigint(BigInt(e),n))},e.prototype.encode_bigint=function(e,t){for(var n=t/8,r=new Uint8Array(n),i=0;i<n;i++)r[i]=Number(e&BigInt(255)),e>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(r))},e.prototype.encode_string=function(e){this.checkTypes&&Fe(e,`string`,this.fieldPath);for(var t=e,n=[],r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?n.push(i):i<2048?n.push(192|i>>6,128|i&63):i<55296||i>=57344?n.push(224|i>>12,128|i>>6&63,128|i&63):(r++,i=65536+((i&1023)<<10|t.charCodeAt(r)&1023),n.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}this.encoded.store_value(n.length,`u32`),this.encoded.store_bytes(new Uint8Array(n))},e.prototype.encode_boolean=function(e){this.checkTypes&&Fe(e,`boolean`,this.fieldPath),this.encoded.store_value(+!!e,`u8`)},e.prototype.encode_option=function(e,t){e==null?this.encoded.store_value(0,`u8`):(this.encoded.store_value(1,`u8`),this.encode_value(e,t.option))},e.prototype.encode_enum=function(e,t){this.checkTypes&&Le(e,this.fieldPath);for(var n=Object.keys(e)[0],r=0;r<t.enum.length;r++){var i=t.enum[r];if(n===Object.keys(i.struct)[0])return this.encoded.store_value(r,`u8`),this.encode_struct(e,i)}throw Error(`Enum key (${n}) not found in enum schema: ${JSON.stringify(t)} at ${this.fieldPath.join(`.`)}`)},e.prototype.encode_array=function(e,t){if(Pe(e))return this.encode_arraylike(e,t);if(e instanceof ArrayBuffer)return this.encode_buffer(e,t);throw Error(`Expected Array-like not ${typeof e}(${e}) at ${this.fieldPath.join(`.`)}`)},e.prototype.encode_arraylike=function(e,t){t.array.len?Ie(e.length,t.array.len,this.fieldPath):this.encoded.store_value(e.length,`u32`);for(var n=0;n<e.length;n++)this.encode_value(e[n],t.array.type)},e.prototype.encode_buffer=function(e,t){t.array.len?Ie(e.byteLength,t.array.len,this.fieldPath):this.encoded.store_value(e.byteLength,`u32`),this.encoded.store_bytes(new Uint8Array(e))},e.prototype.encode_set=function(e,t){this.checkTypes&&Fe(e,`object`,this.fieldPath);var n=e instanceof Set?Array.from(e.values()):Object.values(e);this.encoded.store_value(n.length,`u32`);for(var r=0,i=n;r<i.length;r++){var a=i[r];this.encode_value(a,t.set)}},e.prototype.encode_map=function(e,t){this.checkTypes&&Fe(e,`object`,this.fieldPath);var n=e instanceof Map,r=n?Array.from(e.keys()):Object.keys(e);this.encoded.store_value(r.length,`u32`);for(var i=0,a=r;i<a.length;i++){var o=a[i];this.encode_value(o,t.map.key),this.encode_value(n?e.get(o):e[o],t.map.value)}},e.prototype.encode_struct=function(e,t){this.checkTypes&&Fe(e,`object`,this.fieldPath);for(var n=0,r=Object.keys(t.struct);n<r.length;n++){var i=r[n];this.fieldPath.push(i),this.encode_value(e[i],t.struct[i]),this.fieldPath.pop()}},e}(),function(){function e(e){this.buffer=new Me(e)}return e.prototype.decode=function(e){return this.decode_value(e)},e.prototype.decode_value=function(e){if(typeof e==`string`){if(Ae.includes(e))return this.decode_integer(e);if(e===`string`)return this.decode_string();if(e===`bool`)return this.decode_boolean()}if(typeof e==`object`){if(`option`in e)return this.decode_option(e);if(`enum`in e)return this.decode_enum(e);if(`array`in e)return this.decode_array(e);if(`set`in e)return this.decode_set(e);if(`map`in e)return this.decode_map(e);if(`struct`in e)return this.decode_struct(e)}throw Error(`Unsupported type: ${e}`)},e.prototype.decode_integer=function(e){var t=parseInt(e.substring(1));return t<=32||e==`f64`?this.buffer.consume_value(e):this.decode_bigint(t,e.startsWith(`i`))},e.prototype.decode_bigint=function(e,t){t===void 0&&(t=!1);var n=e/8,r=new Uint8Array(this.buffer.consume_bytes(n)),i=r.reduceRight(function(e,t){return e+t.toString(16).padStart(2,`0`)},``);return t&&r[n-1]?BigInt.asIntN(e,BigInt(`0x${i}`)):BigInt(`0x${i}`)},e.prototype.decode_string=function(){for(var e=this.decode_integer(`u32`),t=new Uint8Array(this.buffer.consume_bytes(e)),n=[],r=0;r<e;++r){var i=t[r];if(i<128)n.push(i);else if(i<224)n.push((i&31)<<6|t[++r]&63);else if(i<240)n.push((i&15)<<12|(t[++r]&63)<<6|t[++r]&63);else{var a=(i&7)<<18|(t[++r]&63)<<12|(t[++r]&63)<<6|t[++r]&63;n.push(a)}}return String.fromCodePoint.apply(String,n)},e.prototype.decode_boolean=function(){return this.buffer.consume_value(`u8`)>0},e.prototype.decode_option=function(e){var t=this.buffer.consume_value(`u8`);if(t===1)return this.decode_value(e.option);if(t!==0)throw Error(`Invalid option ${t}`);return null},e.prototype.decode_enum=function(e){var t,n=this.buffer.consume_value(`u8`);if(n>e.enum.length)throw Error(`Enum option ${n} is not available`);var r=e.enum[n].struct,i=Object.keys(r)[0];return t={},t[i]=this.decode_value(r[i]),t},e.prototype.decode_array=function(e){for(var t=[],n=e.array.len?e.array.len:this.decode_integer(`u32`),r=0;r<n;++r)t.push(this.decode_value(e.array.type));return t},e.prototype.decode_set=function(e){for(var t=this.decode_integer(`u32`),n=new Set,r=0;r<t;++r)n.add(this.decode_value(e.set));return n},e.prototype.decode_map=function(e){for(var t=this.decode_integer(`u32`),n=new Map,r=0;r<t;++r){var i=this.decode_value(e.map.key),a=this.decode_value(e.map.value);n.set(i,a)}return n},e.prototype.decode_struct=function(e){var t={};for(var n in e.struct)t[n]=this.decode_value(e.struct[n]);return t},e}(),new Uint8Array([75,69,77,0,16]),new Uint8Array([72,80,75,69,0,16,0,1,0,2]),new Uint8Array([72,80,75,69,45,118,49]),new Uint8Array([115,101,99,114,101,116]),new Uint8Array([101,97,101,95,112,114,107]),new Uint8Array([115,104,97,114,101,100,95,115,101,99,114,101,116]),new Uint8Array([0,32,72,80,75,69,45,118,49,72,80,75,69,0,16,0,1,0,2,107,101,121,0,143,195,174,184,50,73,10,75,90,179,228,32,35,40,125,178,154,31,75,199,194,34,192,223,34,135,39,183,10,64,33,18,47,63,4,233,32,108,209,36,19,80,53,41,180,122,198,166,48,185,46,196,207,125,35,69,8,208,175,151,113,201,158,80]),new Uint8Array([0,12,72,80,75,69,45,118,49,72,80,75,69,0,16,0,1,0,2,98,97,115,101,95,110,111,110,99,101,0,143,195,174,184,50,73,10,75,90,179,228,32,35,40,125,178,154,31,75,199,194,34,192,223,34,135,39,183,10,64,33,18,47,63,4,233,32,108,209,36,19,80,53,41,180,122,198,166,48,185,46,196,207,125,35,69,8,208,175,151,113,201,158,80]),new Uint8Array([113,111,115,95,101,110,99,114,121,112,116,105,111,110,95,104,109,97,99,95,109,101,115,115,97,103,101]);const Re=e=>{let t=n(e);if(t.length<2)throw Error(`failed to convert DER-encoded signature: insufficient length`);if(t[0]!==48)throw Error(`failed to convert DER-encoded signature: invalid format (missing SEQUENCE tag)`);let r=1,a=t[r];if(a<=127){if(t.length<2+a)throw Error(`failed to convert DER-encoded signature: inconsistent message length header`);r+=1}else throw Error(`failed to convert DER-encoded signature: unexpectedly large or invalid signature length`);if(t[r]!==2)throw Error(`failed to convert DER-encoded signature: invalid tag for r`);r++;let o=t[r];if(o>33)throw Error(`failed to convert DER-encoded signature: unexpected length for r`);r++;let s=t.slice(r,r+o);if(r+=o,t[r]!==2)throw Error(`failed to convert DER-encoded signature: invalid tag for s`);r++;let c=t[r];if(c>33)throw Error(`failed to convert DER-encoded signature: unexpected length for s`);r++;let l=t.slice(r,r+c),u=i(s,32),d=i(l,32);return new Uint8Array([...u,...d])};var ze;(function(e){e.NOTARIZER=`notarizer`,e.SIGNER=`signer`,e.EVM_PARSER=`evm-parser`,e.TLS_FETCHER=`tls-fetcher`,e.UMP=`ump`})(ze||={});var Be=s(((e,t)=>{(function(e,n){var r=2**-24,i=2**32,a=2**53;function o(e){var t=new ArrayBuffer(256),r=new DataView(t),o,s=0;function c(e){for(var n=t.byteLength,i=s+e;n<i;)n*=2;if(n!==t.byteLength){var a=r;t=new ArrayBuffer(n),r=new DataView(t);for(var c=s+3>>2,l=0;l<c;++l)r.setUint32(l*4,a.getUint32(l*4))}return o=e,r}function l(){s+=o}function u(e){l(c(8).setFloat64(s,e))}function d(e){l(c(1).setUint8(s,e))}function f(e){for(var t=c(e.length),n=0;n<e.length;++n)t.setUint8(s+n,e[n]);l()}function p(e){l(c(2).setUint16(s,e))}function m(e){l(c(4).setUint32(s,e))}function h(e){var t=e%i,n=(e-t)/i,r=c(8);r.setUint32(s,n),r.setUint32(s+4,t),l()}function g(e,t){t<24?d(e<<5|t):t<256?(d(e<<5|24),d(t)):t<65536?(d(e<<5|25),p(t)):t<4294967296?(d(e<<5|26),m(t)):(d(e<<5|27),h(t))}function _(e){var t;if(e===!1)return d(244);if(e===!0)return d(245);if(e===null)return d(246);if(e===n)return d(247);switch(typeof e){case`number`:if(Math.floor(e)===e){if(0<=e&&e<=a)return g(0,e);if(-a<=e&&e<0)return g(1,-(e+1))}return d(251),u(e);case`string`:var r=[];for(t=0;t<e.length;++t){var i=e.charCodeAt(t);i<128?r.push(i):i<2048?(r.push(192|i>>6),r.push(128|i&63)):i<55296?(r.push(224|i>>12),r.push(128|i>>6&63),r.push(128|i&63)):(i=(i&1023)<<10,i|=e.charCodeAt(++t)&1023,i+=65536,r.push(240|i>>18),r.push(128|i>>12&63),r.push(128|i>>6&63),r.push(128|i&63))}return g(3,r.length),f(r);default:var o;if(Array.isArray(e))for(o=e.length,g(4,o),t=0;t<o;++t)_(e[t]);else if(e instanceof Uint8Array)g(2,e.length),f(e);else{var s=Object.keys(e);for(o=s.length,g(5,o),t=0;t<o;++t){var c=s[t];_(c),_(e[c])}}}}if(_(e),`slice`in t)return t.slice(0,s);for(var v=new ArrayBuffer(s),y=new DataView(v),b=0;b<s;++b)y.setUint8(b,r.getUint8(b));return v}function s(e,t,a){var o=new DataView(e),s=0;typeof t!=`function`&&(t=function(e){return e}),typeof a!=`function`&&(a=function(){return n});function c(e,t){return s+=t,e}function l(t){return c(new Uint8Array(e,s,t),t)}function u(){var e=new DataView(new ArrayBuffer(4)),t=m(),n=t&32768,i=t&31744,a=t&1023;if(i===31744)i=261120;else if(i!==0)i+=114688;else if(a!==0)return a*r;return e.setUint32(0,n<<16|i<<13|a<<13),e.getFloat32(0)}function d(){return c(o.getFloat32(s),4)}function f(){return c(o.getFloat64(s),8)}function p(){return c(o.getUint8(s),1)}function m(){return c(o.getUint16(s),2)}function h(){return c(o.getUint32(s),4)}function g(){return h()*i+h()}function _(){return o.getUint8(s)===255&&(s+=1,!0)}function v(e){if(e<24)return e;if(e===24)return p();if(e===25)return m();if(e===26)return h();if(e===27)return g();if(e===31)return-1;throw`Invalid length encoding`}function y(e){var t=p();if(t===255)return-1;var n=v(t&31);if(n<0||t>>5!==e)throw`Invalid indefinite length element`;return n}function b(e,t){for(var n=0;n<t;++n){var r=p();r&128&&(r<224?(r=(r&31)<<6|p()&63,--t):r<240?(r=(r&15)<<12|(p()&63)<<6|p()&63,t-=2):(r=(r&15)<<18|(p()&63)<<12|(p()&63)<<6|p()&63,t-=3)),r<65536?e.push(r):(r-=65536,e.push(55296|r>>10),e.push(56320|r&1023))}}function x(){var e=p(),r=e>>5,i=e&31,o,s;if(r===7)switch(i){case 25:return u();case 26:return d();case 27:return f()}if(s=v(i),s<0&&(r<2||6<r))throw`Invalid length`;switch(r){case 0:return s;case 1:return-1-s;case 2:if(s<0){for(var c=[],m=0;(s=y(r))>=0;)m+=s,c.push(l(s));var h=new Uint8Array(m),g=0;for(o=0;o<c.length;++o)h.set(c[o],g),g+=c[o].length;return h}return l(s);case 3:var S=[];if(s<0)for(;(s=y(r))>=0;)b(S,s);else b(S,s);return String.fromCharCode.apply(null,S);case 4:var C;if(s<0)for(C=[];!_();)C.push(x());else for(C=Array(s),o=0;o<s;++o)C[o]=x();return C;case 5:var w={};for(o=0;o<s||s<0&&!_();++o){var T=x();w[T]=x()}return w;case 6:return t(x(),s);case 7:switch(s){case 20:return!1;case 21:return!0;case 22:return null;case 23:return n;default:return a(s)}}}var S=x();if(s!==e.byteLength)throw`Remaining bytes`;return S}var c={encode:o,decode:s};typeof define==`function`&&define.amd?define(`cbor/cbor`,c):t!==void 0&&t.exports?t.exports=c:e.CBOR||=c})(e)})),Ve=s((()=>{
2
+ import{C as e,S as t,_ as n,b as r,g as i,v as a,x as o,y as s}from"./dist-B0qgGwAq.mjs";import{n as c}from"./base64-WTSXTrii.mjs";import{defineCommand as l,renderUsage as u,runMain as d}from"citty";import*as f from"valibot";import{ECDH as p,createECDH as m,createHash as h,createPrivateKey as g,randomBytes as _,sign as v}from"node:crypto";import{execFile as y,spawn as b}from"node:child_process";import{accessSync as x,chmodSync as S,constants as C,existsSync as w,mkdirSync as T,readFileSync as ee,realpathSync as E,renameSync as D,rmSync as O,statSync as k,writeFileSync as A}from"node:fs";import{homedir as j}from"node:os";import{dirname as M,isAbsolute as te,join as ne,resolve as re}from"node:path";import{createServer as N}from"node:http";import{constants as ie,isUtf8 as ae}from"node:buffer";import P from"semver";var oe=`@catena/cli`,se=`0.5.2`,ce=[`u8`,`u16`,`u32`,`u64`,`u128`,`i8`,`i16`,`i32`,`i64`,`i128`,`f32`,`f64`],le=function(){function e(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return e.prototype.resize_if_necessary=function(e){if(this.buffer_size-this.offset<e){this.buffer_size=Math.max(this.buffer_size*2,this.buffer_size+e);var t=new ArrayBuffer(this.buffer_size);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t,this.view=new DataView(t)}},e.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},e.prototype.store_value=function(e,t){var n=t.substring(1),r=parseInt(n)/8;this.resize_if_necessary(r);var i=t[0]===`f`?`setFloat${n}`:t[0]===`i`?`setInt${n}`:`setUint${n}`;this.view[i](this.offset,e,!0),this.offset+=r},e.prototype.store_bytes=function(e){this.resize_if_necessary(e.length),new Uint8Array(this.buffer).set(new Uint8Array(e),this.offset),this.offset+=e.length},e}(),ue=function(){function e(e){this.offset=0,this.buffer_size=e.length,this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e),this.view=new DataView(this.buffer)}return e.prototype.assert_enough_buffer=function(e){if(this.offset+e>this.buffer.byteLength)throw Error(`Error in schema, the buffer is smaller than expected`)},e.prototype.consume_value=function(e){var t=e.substring(1),n=parseInt(t)/8;this.assert_enough_buffer(n);var r=e[0]===`f`?`getFloat${t}`:e[0]===`i`?`getInt${t}`:`getUint${t}`,i=this.view[r](this.offset,!0);return this.offset+=n,i},e.prototype.consume_bytes=function(e){this.assert_enough_buffer(e);var t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t},e}(),de=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();function fe(e){return Array.isArray(e)||!!e&&typeof e==`object`&&`length`in e&&typeof e.length==`number`&&(e.length===0||e.length>0&&e.length-1 in e)}function pe(e,t,n){if(typeof e!==t)throw Error(`Expected ${t} not ${typeof e}(${e}) at ${n.join(`.`)}`)}function me(e,t){var n=[`number`,`string`,`bigint`,`boolean`].includes(typeof e),r=typeof e==`object`&&!!e&&`toString`in e;if(!n&&!r)throw Error(`Expected bigint, number, boolean or string not ${typeof e}(${e}) at ${t.join(`.`)}`)}function he(e,t,n){if(e!==t)throw Error(`Array length ${e} does not match schema length ${t} at ${n.join(`.`)}`)}function F(e,t){if(typeof e!=`object`||!e)throw Error(`Expected object not ${typeof e}(${e}) at ${t.join(`.`)}`)}ce.concat([`bool`,`string`]),function(e){de(t,e);function t(t,n){var r=`Invalid schema: ${JSON.stringify(t)} expected ${n}`;return e.call(this,r)||this}return t}(Error),function(){function e(e){this.encoded=new le,this.fieldPath=[`value`],this.checkTypes=e}return e.prototype.encode=function(e,t){return this.encode_value(e,t),this.encoded.get_used_buffer()},e.prototype.encode_value=function(e,t){if(typeof t==`string`){if(ce.includes(t))return this.encode_integer(e,t);if(t===`string`)return this.encode_string(e);if(t===`bool`)return this.encode_boolean(e)}if(typeof t==`object`){if(`option`in t)return this.encode_option(e,t);if(`enum`in t)return this.encode_enum(e,t);if(`array`in t)return this.encode_array(e,t);if(`set`in t)return this.encode_set(e,t);if(`map`in t)return this.encode_map(e,t);if(`struct`in t)return this.encode_struct(e,t)}},e.prototype.encode_integer=function(e,t){var n=parseInt(t.substring(1));n<=32||t==`f64`?(this.checkTypes&&pe(e,`number`,this.fieldPath),this.encoded.store_value(e,t)):(this.checkTypes&&me(e,this.fieldPath),this.encode_bigint(BigInt(e),n))},e.prototype.encode_bigint=function(e,t){for(var n=t/8,r=new Uint8Array(n),i=0;i<n;i++)r[i]=Number(e&BigInt(255)),e>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(r))},e.prototype.encode_string=function(e){this.checkTypes&&pe(e,`string`,this.fieldPath);for(var t=e,n=[],r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?n.push(i):i<2048?n.push(192|i>>6,128|i&63):i<55296||i>=57344?n.push(224|i>>12,128|i>>6&63,128|i&63):(r++,i=65536+((i&1023)<<10|t.charCodeAt(r)&1023),n.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}this.encoded.store_value(n.length,`u32`),this.encoded.store_bytes(new Uint8Array(n))},e.prototype.encode_boolean=function(e){this.checkTypes&&pe(e,`boolean`,this.fieldPath),this.encoded.store_value(+!!e,`u8`)},e.prototype.encode_option=function(e,t){e==null?this.encoded.store_value(0,`u8`):(this.encoded.store_value(1,`u8`),this.encode_value(e,t.option))},e.prototype.encode_enum=function(e,t){this.checkTypes&&F(e,this.fieldPath);for(var n=Object.keys(e)[0],r=0;r<t.enum.length;r++){var i=t.enum[r];if(n===Object.keys(i.struct)[0])return this.encoded.store_value(r,`u8`),this.encode_struct(e,i)}throw Error(`Enum key (${n}) not found in enum schema: ${JSON.stringify(t)} at ${this.fieldPath.join(`.`)}`)},e.prototype.encode_array=function(e,t){if(fe(e))return this.encode_arraylike(e,t);if(e instanceof ArrayBuffer)return this.encode_buffer(e,t);throw Error(`Expected Array-like not ${typeof e}(${e}) at ${this.fieldPath.join(`.`)}`)},e.prototype.encode_arraylike=function(e,t){t.array.len?he(e.length,t.array.len,this.fieldPath):this.encoded.store_value(e.length,`u32`);for(var n=0;n<e.length;n++)this.encode_value(e[n],t.array.type)},e.prototype.encode_buffer=function(e,t){t.array.len?he(e.byteLength,t.array.len,this.fieldPath):this.encoded.store_value(e.byteLength,`u32`),this.encoded.store_bytes(new Uint8Array(e))},e.prototype.encode_set=function(e,t){this.checkTypes&&pe(e,`object`,this.fieldPath);var n=e instanceof Set?Array.from(e.values()):Object.values(e);this.encoded.store_value(n.length,`u32`);for(var r=0,i=n;r<i.length;r++){var a=i[r];this.encode_value(a,t.set)}},e.prototype.encode_map=function(e,t){this.checkTypes&&pe(e,`object`,this.fieldPath);var n=e instanceof Map,r=n?Array.from(e.keys()):Object.keys(e);this.encoded.store_value(r.length,`u32`);for(var i=0,a=r;i<a.length;i++){var o=a[i];this.encode_value(o,t.map.key),this.encode_value(n?e.get(o):e[o],t.map.value)}},e.prototype.encode_struct=function(e,t){this.checkTypes&&pe(e,`object`,this.fieldPath);for(var n=0,r=Object.keys(t.struct);n<r.length;n++){var i=r[n];this.fieldPath.push(i),this.encode_value(e[i],t.struct[i]),this.fieldPath.pop()}},e}(),function(){function e(e){this.buffer=new ue(e)}return e.prototype.decode=function(e){return this.decode_value(e)},e.prototype.decode_value=function(e){if(typeof e==`string`){if(ce.includes(e))return this.decode_integer(e);if(e===`string`)return this.decode_string();if(e===`bool`)return this.decode_boolean()}if(typeof e==`object`){if(`option`in e)return this.decode_option(e);if(`enum`in e)return this.decode_enum(e);if(`array`in e)return this.decode_array(e);if(`set`in e)return this.decode_set(e);if(`map`in e)return this.decode_map(e);if(`struct`in e)return this.decode_struct(e)}throw Error(`Unsupported type: ${e}`)},e.prototype.decode_integer=function(e){var t=parseInt(e.substring(1));return t<=32||e==`f64`?this.buffer.consume_value(e):this.decode_bigint(t,e.startsWith(`i`))},e.prototype.decode_bigint=function(e,t){t===void 0&&(t=!1);var n=e/8,r=new Uint8Array(this.buffer.consume_bytes(n)),i=r.reduceRight(function(e,t){return e+t.toString(16).padStart(2,`0`)},``);return t&&r[n-1]?BigInt.asIntN(e,BigInt(`0x${i}`)):BigInt(`0x${i}`)},e.prototype.decode_string=function(){for(var e=this.decode_integer(`u32`),t=new Uint8Array(this.buffer.consume_bytes(e)),n=[],r=0;r<e;++r){var i=t[r];if(i<128)n.push(i);else if(i<224)n.push((i&31)<<6|t[++r]&63);else if(i<240)n.push((i&15)<<12|(t[++r]&63)<<6|t[++r]&63);else{var a=(i&7)<<18|(t[++r]&63)<<12|(t[++r]&63)<<6|t[++r]&63;n.push(a)}}return String.fromCodePoint.apply(String,n)},e.prototype.decode_boolean=function(){return this.buffer.consume_value(`u8`)>0},e.prototype.decode_option=function(e){var t=this.buffer.consume_value(`u8`);if(t===1)return this.decode_value(e.option);if(t!==0)throw Error(`Invalid option ${t}`);return null},e.prototype.decode_enum=function(e){var t,n=this.buffer.consume_value(`u8`);if(n>e.enum.length)throw Error(`Enum option ${n} is not available`);var r=e.enum[n].struct,i=Object.keys(r)[0];return t={},t[i]=this.decode_value(r[i]),t},e.prototype.decode_array=function(e){for(var t=[],n=e.array.len?e.array.len:this.decode_integer(`u32`),r=0;r<n;++r)t.push(this.decode_value(e.array.type));return t},e.prototype.decode_set=function(e){for(var t=this.decode_integer(`u32`),n=new Set,r=0;r<t;++r)n.add(this.decode_value(e.set));return n},e.prototype.decode_map=function(e){for(var t=this.decode_integer(`u32`),n=new Map,r=0;r<t;++r){var i=this.decode_value(e.map.key),a=this.decode_value(e.map.value);n.set(i,a)}return n},e.prototype.decode_struct=function(e){var t={};for(var n in e.struct)t[n]=this.decode_value(e.struct[n]);return t},e}(),new Uint8Array([75,69,77,0,16]),new Uint8Array([72,80,75,69,0,16,0,1,0,2]),new Uint8Array([72,80,75,69,45,118,49]),new Uint8Array([115,101,99,114,101,116]),new Uint8Array([101,97,101,95,112,114,107]),new Uint8Array([115,104,97,114,101,100,95,115,101,99,114,101,116]),new Uint8Array([0,32,72,80,75,69,45,118,49,72,80,75,69,0,16,0,1,0,2,107,101,121,0,143,195,174,184,50,73,10,75,90,179,228,32,35,40,125,178,154,31,75,199,194,34,192,223,34,135,39,183,10,64,33,18,47,63,4,233,32,108,209,36,19,80,53,41,180,122,198,166,48,185,46,196,207,125,35,69,8,208,175,151,113,201,158,80]),new Uint8Array([0,12,72,80,75,69,45,118,49,72,80,75,69,0,16,0,1,0,2,98,97,115,101,95,110,111,110,99,101,0,143,195,174,184,50,73,10,75,90,179,228,32,35,40,125,178,154,31,75,199,194,34,192,223,34,135,39,183,10,64,33,18,47,63,4,233,32,108,209,36,19,80,53,41,180,122,198,166,48,185,46,196,207,125,35,69,8,208,175,151,113,201,158,80]),new Uint8Array([113,111,115,95,101,110,99,114,121,112,116,105,111,110,95,104,109,97,99,95,109,101,115,115,97,103,101]);const ge=e=>{let t=n(e);if(t.length<2)throw Error(`failed to convert DER-encoded signature: insufficient length`);if(t[0]!==48)throw Error(`failed to convert DER-encoded signature: invalid format (missing SEQUENCE tag)`);let r=1,a=t[r];if(a<=127){if(t.length<2+a)throw Error(`failed to convert DER-encoded signature: inconsistent message length header`);r+=1}else throw Error(`failed to convert DER-encoded signature: unexpectedly large or invalid signature length`);if(t[r]!==2)throw Error(`failed to convert DER-encoded signature: invalid tag for r`);r++;let o=t[r];if(o>33)throw Error(`failed to convert DER-encoded signature: unexpected length for r`);r++;let s=t.slice(r,r+o);if(r+=o,t[r]!==2)throw Error(`failed to convert DER-encoded signature: invalid tag for s`);r++;let c=t[r];if(c>33)throw Error(`failed to convert DER-encoded signature: unexpected length for s`);r++;let l=t.slice(r,r+c),u=i(s,32),d=i(l,32);return new Uint8Array([...u,...d])};var _e;(function(e){e.NOTARIZER=`notarizer`,e.SIGNER=`signer`,e.EVM_PARSER=`evm-parser`,e.TLS_FETCHER=`tls-fetcher`,e.UMP=`ump`})(_e||={});var I=s(((e,t)=>{(function(e,n){var r=2**-24,i=2**32,a=2**53;function o(e){var t=new ArrayBuffer(256),r=new DataView(t),o,s=0;function c(e){for(var n=t.byteLength,i=s+e;n<i;)n*=2;if(n!==t.byteLength){var a=r;t=new ArrayBuffer(n),r=new DataView(t);for(var c=s+3>>2,l=0;l<c;++l)r.setUint32(l*4,a.getUint32(l*4))}return o=e,r}function l(){s+=o}function u(e){l(c(8).setFloat64(s,e))}function d(e){l(c(1).setUint8(s,e))}function f(e){for(var t=c(e.length),n=0;n<e.length;++n)t.setUint8(s+n,e[n]);l()}function p(e){l(c(2).setUint16(s,e))}function m(e){l(c(4).setUint32(s,e))}function h(e){var t=e%i,n=(e-t)/i,r=c(8);r.setUint32(s,n),r.setUint32(s+4,t),l()}function g(e,t){t<24?d(e<<5|t):t<256?(d(e<<5|24),d(t)):t<65536?(d(e<<5|25),p(t)):t<4294967296?(d(e<<5|26),m(t)):(d(e<<5|27),h(t))}function _(e){var t;if(e===!1)return d(244);if(e===!0)return d(245);if(e===null)return d(246);if(e===n)return d(247);switch(typeof e){case`number`:if(Math.floor(e)===e){if(0<=e&&e<=a)return g(0,e);if(-a<=e&&e<0)return g(1,-(e+1))}return d(251),u(e);case`string`:var r=[];for(t=0;t<e.length;++t){var i=e.charCodeAt(t);i<128?r.push(i):i<2048?(r.push(192|i>>6),r.push(128|i&63)):i<55296?(r.push(224|i>>12),r.push(128|i>>6&63),r.push(128|i&63)):(i=(i&1023)<<10,i|=e.charCodeAt(++t)&1023,i+=65536,r.push(240|i>>18),r.push(128|i>>12&63),r.push(128|i>>6&63),r.push(128|i&63))}return g(3,r.length),f(r);default:var o;if(Array.isArray(e))for(o=e.length,g(4,o),t=0;t<o;++t)_(e[t]);else if(e instanceof Uint8Array)g(2,e.length),f(e);else{var s=Object.keys(e);for(o=s.length,g(5,o),t=0;t<o;++t){var c=s[t];_(c),_(e[c])}}}}if(_(e),`slice`in t)return t.slice(0,s);for(var v=new ArrayBuffer(s),y=new DataView(v),b=0;b<s;++b)y.setUint8(b,r.getUint8(b));return v}function s(e,t,a){var o=new DataView(e),s=0;typeof t!=`function`&&(t=function(e){return e}),typeof a!=`function`&&(a=function(){return n});function c(e,t){return s+=t,e}function l(t){return c(new Uint8Array(e,s,t),t)}function u(){var e=new DataView(new ArrayBuffer(4)),t=m(),n=t&32768,i=t&31744,a=t&1023;if(i===31744)i=261120;else if(i!==0)i+=114688;else if(a!==0)return a*r;return e.setUint32(0,n<<16|i<<13|a<<13),e.getFloat32(0)}function d(){return c(o.getFloat32(s),4)}function f(){return c(o.getFloat64(s),8)}function p(){return c(o.getUint8(s),1)}function m(){return c(o.getUint16(s),2)}function h(){return c(o.getUint32(s),4)}function g(){return h()*i+h()}function _(){return o.getUint8(s)===255&&(s+=1,!0)}function v(e){if(e<24)return e;if(e===24)return p();if(e===25)return m();if(e===26)return h();if(e===27)return g();if(e===31)return-1;throw`Invalid length encoding`}function y(e){var t=p();if(t===255)return-1;var n=v(t&31);if(n<0||t>>5!==e)throw`Invalid indefinite length element`;return n}function b(e,t){for(var n=0;n<t;++n){var r=p();r&128&&(r<224?(r=(r&31)<<6|p()&63,--t):r<240?(r=(r&15)<<12|(p()&63)<<6|p()&63,t-=2):(r=(r&15)<<18|(p()&63)<<12|(p()&63)<<6|p()&63,t-=3)),r<65536?e.push(r):(r-=65536,e.push(55296|r>>10),e.push(56320|r&1023))}}function x(){var e=p(),r=e>>5,i=e&31,o,s;if(r===7)switch(i){case 25:return u();case 26:return d();case 27:return f()}if(s=v(i),s<0&&(r<2||6<r))throw`Invalid length`;switch(r){case 0:return s;case 1:return-1-s;case 2:if(s<0){for(var c=[],m=0;(s=y(r))>=0;)m+=s,c.push(l(s));var h=new Uint8Array(m),g=0;for(o=0;o<c.length;++o)h.set(c[o],g),g+=c[o].length;return h}return l(s);case 3:var S=[];if(s<0)for(;(s=y(r))>=0;)b(S,s);else b(S,s);return String.fromCharCode.apply(null,S);case 4:var C;if(s<0)for(C=[];!_();)C.push(x());else for(C=Array(s),o=0;o<s;++o)C[o]=x();return C;case 5:var w={};for(o=0;o<s||s<0&&!_();++o){var T=x();w[T]=x()}return w;case 6:return t(x(),s);case 7:switch(s){case 20:return!1;case 21:return!0;case 22:return null;case 23:return n;default:return a(s)}}}var S=x();if(s!==e.byteLength)throw`Remaining bytes`;return S}var c={encode:o,decode:s};typeof define==`function`&&define.amd?define(`cbor/cbor`,c):t!==void 0&&t.exports?t.exports=c:e.CBOR||=c})(e)})),ve=s((()=>{
3
3
  /*! *****************************************************************************
4
4
  Copyright (C) Microsoft. All rights reserved.
5
5
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -14,7 +14,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
14
14
  See the Apache Version 2.0 License for specific language governing permissions
15
15
  and limitations under the License.
16
16
  ***************************************************************************** */
17
- var e;(function(e){(function(t){var n=typeof globalThis==`object`?globalThis:typeof global==`object`?global:typeof self==`object`?self:typeof this==`object`?this:s(),r=i(e);n.Reflect!==void 0&&(r=i(n.Reflect,r)),t(r,n),n.Reflect===void 0&&(n.Reflect=e);function i(e,t){return function(n,r){Object.defineProperty(e,n,{configurable:!0,writable:!0,value:r}),t&&t(n,r)}}function a(){try{return Function(`return this;`)()}catch{}}function o(){try{return(0,eval)(`(function() { return this; })()`)}catch{}}function s(){return a()||o()}})(function(e,t){var n=Object.prototype.hasOwnProperty,r=typeof Symbol==`function`,i=r&&Symbol.toPrimitive!==void 0?Symbol.toPrimitive:`@@toPrimitive`,a=r&&Symbol.iterator!==void 0?Symbol.iterator:`@@iterator`,o=typeof Object.create==`function`,s={__proto__:[]}instanceof Array,c=!o&&!s,l={create:o?function(){return xe(Object.create(null))}:s?function(){return xe({__proto__:null})}:function(){return xe({})},has:c?function(e,t){return n.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return n.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),d=typeof Map==`function`&&typeof Map.prototype.entries==`function`?Map:U(),f=typeof Set==`function`&&typeof Set.prototype.entries==`function`?Set:ye(),p=typeof WeakMap==`function`?WeakMap:be(),m=r?Symbol.for(`@reflect-metadata:registry`):void 0,h=ge(),g=H(h);function _(e,t,n,r){if(P(n)){if(!ce(e)||!ue(t))throw TypeError();return D(e,t)}if(!ce(e)||!F(t)||!F(r)&&!P(r)&&!re(r))throw TypeError();return re(r)&&(r=void 0),n=L(n),O(e,t,n,r)}e(`decorate`,_);function v(e,t){function n(n,r){if(!F(n)||!P(r)&&!de(r))throw TypeError();N(e,t,n,r)}return n}e(`metadata`,v);function y(e,t,n,r){if(!F(n))throw TypeError();return P(r)||(r=L(r)),N(e,t,n,r)}e(`defineMetadata`,y);function b(e,t,n){if(!F(t))throw TypeError();return P(n)||(n=L(n)),k(e,t,n)}e(`hasMetadata`,b);function x(e,t,n){if(!F(t))throw TypeError();return P(n)||(n=L(n)),A(e,t,n)}e(`hasOwnMetadata`,x);function S(e,t,n){if(!F(t))throw TypeError();return P(n)||(n=L(n)),j(e,t,n)}e(`getMetadata`,S);function C(e,t,n){if(!F(t))throw TypeError();return P(n)||(n=L(n)),M(e,t,n)}e(`getOwnMetadata`,C);function w(e,t){if(!F(e))throw TypeError();return P(t)||(t=L(t)),ee(e,t)}e(`getMetadataKeys`,w);function T(e,t){if(!F(e))throw TypeError();return P(t)||(t=L(t)),te(e,t)}e(`getOwnMetadataKeys`,T);function E(e,t,n){if(!F(t)||(P(n)||(n=L(n)),!F(t)))throw TypeError();P(n)||(n=L(n));var r=ve(t,n,!1);return!P(r)&&r.OrdinaryDeleteMetadata(e,t,n)}e(`deleteMetadata`,E);function D(e,t){for(var n=e.length-1;n>=0;--n){var r=e[n],i=r(t);if(!P(i)&&!re(i)){if(!ue(i))throw TypeError();t=i}}return t}function O(e,t,n,r){for(var i=e.length-1;i>=0;--i){var a=e[i],o=a(t,n,r);if(!P(o)&&!re(o)){if(!F(o))throw TypeError();r=o}}return r}function k(e,t,n){if(A(e,t,n))return!0;var r=V(t);return!re(r)&&k(e,r,n)}function A(e,t,n){var r=ve(t,n,!1);return!P(r)&&se(r.OrdinaryHasOwnMetadata(e,t,n))}function j(e,t,n){if(A(e,t,n))return M(e,t,n);var r=V(t);if(!re(r))return j(e,r,n)}function M(e,t,n){var r=ve(t,n,!1);if(!P(r))return r.OrdinaryGetOwnMetadata(e,t,n)}function N(e,t,n,r){ve(n,r,!0).OrdinaryDefineOwnMetadata(e,t,n,r)}function ee(e,t){var n=te(e,t),r=V(e);if(r===null)return n;var i=ee(r,t);if(i.length<=0)return n;if(n.length<=0)return i;for(var a=new f,o=[],s=0,c=n;s<c.length;s++){var l=c[s],u=a.has(l);u||(a.add(l),o.push(l))}for(var d=0,p=i;d<p.length;d++){var l=p[d],u=a.has(l);u||(a.add(l),o.push(l))}return o}function te(e,t){var n=ve(e,t,!1);return n?n.OrdinaryOwnMetadataKeys(e,t):[]}function ne(e){if(e===null)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 e===null?1:6;default:return 6}}function P(e){return e===void 0}function re(e){return e===null}function ie(e){return typeof e==`symbol`}function F(e){return typeof e==`object`?e!==null:typeof e==`function`}function ae(e,t){switch(ne(e)){case 0:return e;case 1:return e;case 2:return e;case 3:return e;case 4:return e;case 5:return e}var n=t===3?`string`:t===5?`number`:`default`,r=R(e,i);if(r!==void 0){var a=r.call(e,n);if(F(a))throw TypeError();return a}return oe(e,n==="default"?`number`:n)}function oe(e,t){if(t===`string`){var n=e.toString;if(le(n)){var r=n.call(e);if(!F(r))return r}var i=e.valueOf;if(le(i)){var r=i.call(e);if(!F(r))return r}}else{var i=e.valueOf;if(le(i)){var r=i.call(e);if(!F(r))return r}var a=e.toString;if(le(a)){var r=a.call(e);if(!F(r))return r}}throw TypeError()}function se(e){return!!e}function I(e){return``+e}function L(e){var t=ae(e,3);return ie(t)?t:I(t)}function ce(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:Object.prototype.toString.call(e)===`[object Array]`}function le(e){return typeof e==`function`}function ue(e){return typeof e==`function`}function de(e){switch(ne(e)){case 3:return!0;case 4:return!0;default:return!1}}function fe(e,t){return e===t||e!==e&&t!==t}function R(e,t){var n=e[t];if(n!=null){if(!le(n))throw TypeError();return n}}function z(e){var t=R(e,a);if(!le(t))throw TypeError();var n=t.call(e);if(!F(n))throw TypeError();return n}function pe(e){return e.value}function B(e){var t=e.next();return!t.done&&t}function me(e){var t=e.return;t&&t.call(e)}function V(e){var t=Object.getPrototypeOf(e);if(typeof e!=`function`||e===u||t!==u)return t;var n=e.prototype,r=n&&Object.getPrototypeOf(n);if(r==null||r===Object.prototype)return t;var i=r.constructor;return typeof i!=`function`||i===e?t:i}function he(){var e;!P(m)&&t.Reflect!==void 0&&!(m in t.Reflect)&&typeof t.Reflect.defineMetadata==`function`&&(e=_e(t.Reflect));var n,r,i,a=new p,o={registerProvider:s,getProvider:l,setProvider:h};return o;function s(t){if(!Object.isExtensible(o))throw Error(`Cannot add provider to a frozen registry.`);switch(!0){case e===t:break;case P(n):n=t;break;case n===t:break;case P(r):r=t;break;case r===t:break;default:i===void 0&&(i=new f),i.add(t)}}function c(t,a){if(!P(n)){if(n.isProviderFor(t,a))return n;if(!P(r)){if(r.isProviderFor(t,a))return n;if(!P(i))for(var o=z(i);;){var s=B(o);if(!s)return;var c=pe(s);if(c.isProviderFor(t,a))return me(o),c}}}if(!P(e)&&e.isProviderFor(t,a))return e}function l(e,t){var n=a.get(e),r;return P(n)||(r=n.get(t)),P(r)?(r=c(e,t),P(r)||(P(n)&&(n=new d,a.set(e,n)),n.set(t,r)),r):r}function u(e){if(P(e))throw TypeError();return n===e||r===e||!P(i)&&i.has(e)}function h(e,t,n){if(!u(n))throw Error(`Metadata provider not registered.`);var r=l(e,t);if(r!==n){if(!P(r))return!1;var i=a.get(e);P(i)&&(i=new d,a.set(e,i)),i.set(t,n)}return!0}}function ge(){var e;return!P(m)&&F(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[m]),P(e)&&(e=he()),!P(m)&&F(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function H(e){var t=new p,n={isProviderFor:function(e,n){var r=t.get(e);return!P(r)&&r.has(n)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return h.registerProvider(n),n;function r(r,i,a){var o=t.get(r),s=!1;if(P(o)){if(!a)return;o=new d,t.set(r,o),s=!0}var c=o.get(i);if(P(c)){if(!a)return;if(c=new d,o.set(i,c),!e.setProvider(r,i,n))throw o.delete(i),s&&t.delete(r),Error(`Wrong provider for target.`)}return c}function i(e,t,n){var i=r(t,n,!1);return!P(i)&&se(i.has(e))}function a(e,t,n){var i=r(t,n,!1);if(!P(i))return i.get(e)}function o(e,t,n,i){r(n,i,!0).set(e,t)}function s(e,t){var n=[],i=r(e,t,!1);if(P(i))return n;for(var a=z(i.keys()),o=0;;){var s=B(a);if(!s)return n.length=o,n;var c=pe(s);try{n[o]=c}catch(e){try{me(a)}finally{throw e}}o++}}function c(e,n,i){var a=r(n,i,!1);if(P(a)||!a.delete(e))return!1;if(a.size===0){var o=t.get(n);P(o)||(o.delete(i),o.size===0&&t.delete(o))}return!0}}function _e(e){var t=e.defineMetadata,n=e.hasOwnMetadata,r=e.getOwnMetadata,i=e.getOwnMetadataKeys,a=e.deleteMetadata,o=new p;return{isProviderFor:function(e,t){var n=o.get(e);return!P(n)&&n.has(t)?!0:i(e,t).length?(P(n)&&(n=new f,o.set(e,n)),n.add(t),!0):!1},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:a}}function ve(e,t,n){var r=h.getProvider(e,t);if(!P(r))return r;if(n){if(h.setProvider(e,t,g))return g;throw Error(`Illegal state.`)}}function U(){var e={},t=[],n=function(){function e(e,t,n){this._index=0,this._keys=e,this._values=t,this._selector=n}return e.prototype[`@@iterator`]=function(){return this},e.prototype[a]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var n=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:n,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 n=this._find(e,!0);return this._values[n]=t,this},t.prototype.delete=function(t){var n=this._find(t,!1);if(n>=0){for(var r=this._keys.length,i=n+1;i<r;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,fe(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 n(this._keys,this._values,r)},t.prototype.values=function(){return new n(this._keys,this._values,i)},t.prototype.entries=function(){return new n(this._keys,this._values,o)},t.prototype[`@@iterator`]=function(){return this.entries()},t.prototype[a]=function(){return this.entries()},t.prototype._find=function(e,t){if(!fe(this._cacheKey,e)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(fe(this._keys[n],e)){this._cacheIndex=n;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function r(e,t){return e}function i(e,t){return t}function o(e,t){return[e,t]}}function ye(){return function(){function e(){this._map=new d}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[a]=function(){return this.keys()},e}()}function be(){var e=l.create(),t=r();return function(){function e(){this._key=r()}return e.prototype.has=function(e){var t=i(e,!1);return t!==void 0&&l.has(t,this._key)},e.prototype.get=function(e){var t=i(e,!1);return t===void 0?void 0:l.get(t,this._key)},e.prototype.set=function(e,t){var n=i(e,!0);return n[this._key]=t,this},e.prototype.delete=function(e){var t=i(e,!1);return t!==void 0&&delete t[this._key]},e.prototype.clear=function(){this._key=r()},e}();function r(){var t;do t=`@@WeakMap@@`+s();while(l.has(e,t));return e[t]=!0,t}function i(e,r){if(!n.call(e,t)){if(!r)return;Object.defineProperty(e,t,{value:l.create()})}return e[t]}function a(e,t){for(var n=0;n<t;++n)e[n]=Math.random()*255|0;return e}function o(e){if(typeof Uint8Array==`function`){var t=new Uint8Array(e);return typeof crypto<`u`?crypto.getRandomValues(t):typeof msCrypto<`u`?msCrypto.getRandomValues(t):a(t,e),t}return a(Array(e),e)}function s(){var e=o(16);e[6]=e[6]&79|64,e[8]=e[8]&191|128;for(var t=``,n=0;n<16;++n){var r=e[n];(n===4||n===6||n===8)&&(t+=`-`),r<16&&(t+=`0`),t+=r.toString(16).toLowerCase()}return t}}function xe(e){return e.__=void 0,delete e.__,e}})})(e||={})})),q=o({__addDisposableResource:()=>pt,__assign:()=>_t,__asyncDelegator:()=>at,__asyncGenerator:()=>it,__asyncValues:()=>ot,__await:()=>Y,__awaiter:()=>Xe,__classPrivateFieldGet:()=>ut,__classPrivateFieldIn:()=>ft,__classPrivateFieldSet:()=>dt,__createBinding:()=>vt,__decorate:()=>We,__disposeResources:()=>mt,__esDecorate:()=>J,__exportStar:()=>Qe,__extends:()=>He,__generator:()=>Ze,__importDefault:()=>lt,__importStar:()=>ct,__makeTemplateObject:()=>st,__metadata:()=>Ye,__param:()=>Ge,__propKey:()=>qe,__read:()=>et,__rest:()=>Ue,__rewriteRelativeImportExtension:()=>ht,__runInitializers:()=>Ke,__setFunctionName:()=>Je,__spread:()=>tt,__spreadArray:()=>rt,__spreadArrays:()=>nt,__values:()=>$e,default:()=>St});function He(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);gt(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Ue(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function We(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Ge(e,t){return function(n,r){t(n,r,e)}}function J(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function Ke(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function qe(e){return typeof e==`symbol`?e:`${e}`}function Je(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,"name",{configurable:!0,value:n?`${n} ${t}`:t})}function Ye(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Xe(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Ze(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function Qe(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&vt(t,e,n)}function $e(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function et(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function tt(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(et(arguments[t]));return e}function nt(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function rt(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function Y(e){return this instanceof Y?(this.v=e,this):new Y(e)}function it(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof Y?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function at(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:Y(e[r](t)),done:!1}:i?i(t):t}:i}}function ot(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof $e==`function`?$e(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function st(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function ct(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=bt(e),r=0;r<n.length;r++)n[r]!=="default"&&vt(t,e,n[r]);return yt(t,e),t}function lt(e){return e&&e.__esModule?e:{default:e}}function ut(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function dt(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function ft(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function pt(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function mt(e){function t(t){e.error=e.hasError?new xt(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function ht(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var gt,_t,vt,yt,bt,xt,St,X=r((()=>{gt=function(e,t){return gt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},gt(e,t)},_t=function(){return _t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},_t.apply(this,arguments)},vt=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),yt=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},bt=function(e){return bt=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},bt(e)},xt=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},St={__extends:He,__assign:_t,__rest:Ue,__decorate:We,__param:Ge,__esDecorate:J,__runInitializers:Ke,__propKey:qe,__setFunctionName:Je,__metadata:Ye,__awaiter:Xe,__generator:Ze,__createBinding:vt,__exportStar:Qe,__values:$e,__read:et,__spread:tt,__spreadArrays:nt,__spreadArray:rt,__await:Y,__asyncGenerator:it,__asyncDelegator:at,__asyncValues:ot,__makeTemplateObject:st,__importStar:ct,__importDefault:lt,__classPrivateFieldGet:ut,__classPrivateFieldSet:dt,__classPrivateFieldIn:ft,__addDisposableResource:pt,__disposeResources:mt,__rewriteRelativeImportExtension:ht}})),Ct=s((e=>{
17
+ var e;(function(e){(function(t){var n=typeof globalThis==`object`?globalThis:typeof global==`object`?global:typeof self==`object`?self:typeof this==`object`?this:s(),r=i(e);n.Reflect!==void 0&&(r=i(n.Reflect,r)),t(r,n),n.Reflect===void 0&&(n.Reflect=e);function i(e,t){return function(n,r){Object.defineProperty(e,n,{configurable:!0,writable:!0,value:r}),t&&t(n,r)}}function a(){try{return Function(`return this;`)()}catch{}}function o(){try{return(0,eval)(`(function() { return this; })()`)}catch{}}function s(){return a()||o()}})(function(e,t){var n=Object.prototype.hasOwnProperty,r=typeof Symbol==`function`,i=r&&Symbol.toPrimitive!==void 0?Symbol.toPrimitive:`@@toPrimitive`,a=r&&Symbol.iterator!==void 0?Symbol.iterator:`@@iterator`,o=typeof Object.create==`function`,s={__proto__:[]}instanceof Array,c=!o&&!s,l={create:o?function(){return we(Object.create(null))}:s?function(){return we({__proto__:null})}:function(){return we({})},has:c?function(e,t){return n.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return n.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),d=typeof Map==`function`&&typeof Map.prototype.entries==`function`?Map:Se(),f=typeof Set==`function`&&typeof Set.prototype.entries==`function`?Set:Ce(),p=typeof WeakMap==`function`?WeakMap:B(),m=r?Symbol.for(`@reflect-metadata:registry`):void 0,h=R(),g=be(h);function _(e,t,n,r){if(N(n)){if(!de(e)||!pe(t))throw TypeError();return E(e,t)}if(!de(e)||!P(t)||!P(r)&&!N(r)&&!ie(r))throw TypeError();return ie(r)&&(r=void 0),n=ue(n),D(e,t,n,r)}e(`decorate`,_);function v(e,t){function n(n,r){if(!P(n)||!N(r)&&!me(r))throw TypeError();M(e,t,n,r)}return n}e(`metadata`,v);function y(e,t,n,r){if(!P(n))throw TypeError();return N(r)||(r=ue(r)),M(e,t,n,r)}e(`defineMetadata`,y);function b(e,t,n){if(!P(t))throw TypeError();return N(n)||(n=ue(n)),O(e,t,n)}e(`hasMetadata`,b);function x(e,t,n){if(!P(t))throw TypeError();return N(n)||(n=ue(n)),k(e,t,n)}e(`hasOwnMetadata`,x);function S(e,t,n){if(!P(t))throw TypeError();return N(n)||(n=ue(n)),A(e,t,n)}e(`getMetadata`,S);function C(e,t,n){if(!P(t))throw TypeError();return N(n)||(n=ue(n)),j(e,t,n)}e(`getOwnMetadata`,C);function w(e,t){if(!P(e))throw TypeError();return N(t)||(t=ue(t)),te(e,t)}e(`getMetadataKeys`,w);function T(e,t){if(!P(e))throw TypeError();return N(t)||(t=ue(t)),ne(e,t)}e(`getOwnMetadataKeys`,T);function ee(e,t,n){if(!P(t)||(N(n)||(n=ue(n)),!P(t)))throw TypeError();N(n)||(n=ue(n));var r=z(t,n,!1);return!N(r)&&r.OrdinaryDeleteMetadata(e,t,n)}e(`deleteMetadata`,ee);function E(e,t){for(var n=e.length-1;n>=0;--n){var r=e[n],i=r(t);if(!N(i)&&!ie(i)){if(!pe(i))throw TypeError();t=i}}return t}function D(e,t,n,r){for(var i=e.length-1;i>=0;--i){var a=e[i],o=a(t,n,r);if(!N(o)&&!ie(o)){if(!P(o))throw TypeError();r=o}}return r}function O(e,t,n){if(k(e,t,n))return!0;var r=L(t);return!ie(r)&&O(e,r,n)}function k(e,t,n){var r=z(t,n,!1);return!N(r)&&ce(r.OrdinaryHasOwnMetadata(e,t,n))}function A(e,t,n){if(k(e,t,n))return j(e,t,n);var r=L(t);if(!ie(r))return A(e,r,n)}function j(e,t,n){var r=z(t,n,!1);if(!N(r))return r.OrdinaryGetOwnMetadata(e,t,n)}function M(e,t,n,r){z(n,r,!0).OrdinaryDefineOwnMetadata(e,t,n,r)}function te(e,t){var n=ne(e,t),r=L(e);if(r===null)return n;var i=te(r,t);if(i.length<=0)return n;if(n.length<=0)return i;for(var a=new f,o=[],s=0,c=n;s<c.length;s++){var l=c[s],u=a.has(l);u||(a.add(l),o.push(l))}for(var d=0,p=i;d<p.length;d++){var l=p[d],u=a.has(l);u||(a.add(l),o.push(l))}return o}function ne(e,t){var n=z(e,t,!1);return n?n.OrdinaryOwnMetadataKeys(e,t):[]}function re(e){if(e===null)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 e===null?1:6;default:return 6}}function N(e){return e===void 0}function ie(e){return e===null}function ae(e){return typeof e==`symbol`}function P(e){return typeof e==`object`?e!==null:typeof e==`function`}function oe(e,t){switch(re(e)){case 0:return e;case 1:return e;case 2:return e;case 3:return e;case 4:return e;case 5:return e}var n=t===3?`string`:t===5?`number`:`default`,r=F(e,i);if(r!==void 0){var a=r.call(e,n);if(P(a))throw TypeError();return a}return se(e,n==="default"?`number`:n)}function se(e,t){if(t===`string`){var n=e.toString;if(fe(n)){var r=n.call(e);if(!P(r))return r}var i=e.valueOf;if(fe(i)){var r=i.call(e);if(!P(r))return r}}else{var i=e.valueOf;if(fe(i)){var r=i.call(e);if(!P(r))return r}var a=e.toString;if(fe(a)){var r=a.call(e);if(!P(r))return r}}throw TypeError()}function ce(e){return!!e}function le(e){return``+e}function ue(e){var t=oe(e,3);return ae(t)?t:le(t)}function de(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:Object.prototype.toString.call(e)===`[object Array]`}function fe(e){return typeof e==`function`}function pe(e){return typeof e==`function`}function me(e){switch(re(e)){case 3:return!0;case 4:return!0;default:return!1}}function he(e,t){return e===t||e!==e&&t!==t}function F(e,t){var n=e[t];if(n!=null){if(!fe(n))throw TypeError();return n}}function ge(e){var t=F(e,a);if(!fe(t))throw TypeError();var n=t.call(e);if(!P(n))throw TypeError();return n}function _e(e){return e.value}function I(e){var t=e.next();return!t.done&&t}function ve(e){var t=e.return;t&&t.call(e)}function L(e){var t=Object.getPrototypeOf(e);if(typeof e!=`function`||e===u||t!==u)return t;var n=e.prototype,r=n&&Object.getPrototypeOf(n);if(r==null||r===Object.prototype)return t;var i=r.constructor;return typeof i!=`function`||i===e?t:i}function ye(){var e;!N(m)&&t.Reflect!==void 0&&!(m in t.Reflect)&&typeof t.Reflect.defineMetadata==`function`&&(e=xe(t.Reflect));var n,r,i,a=new p,o={registerProvider:s,getProvider:l,setProvider:h};return o;function s(t){if(!Object.isExtensible(o))throw Error(`Cannot add provider to a frozen registry.`);switch(!0){case e===t:break;case N(n):n=t;break;case n===t:break;case N(r):r=t;break;case r===t:break;default:i===void 0&&(i=new f),i.add(t)}}function c(t,a){if(!N(n)){if(n.isProviderFor(t,a))return n;if(!N(r)){if(r.isProviderFor(t,a))return n;if(!N(i))for(var o=ge(i);;){var s=I(o);if(!s)return;var c=_e(s);if(c.isProviderFor(t,a))return ve(o),c}}}if(!N(e)&&e.isProviderFor(t,a))return e}function l(e,t){var n=a.get(e),r;return N(n)||(r=n.get(t)),N(r)?(r=c(e,t),N(r)||(N(n)&&(n=new d,a.set(e,n)),n.set(t,r)),r):r}function u(e){if(N(e))throw TypeError();return n===e||r===e||!N(i)&&i.has(e)}function h(e,t,n){if(!u(n))throw Error(`Metadata provider not registered.`);var r=l(e,t);if(r!==n){if(!N(r))return!1;var i=a.get(e);N(i)&&(i=new d,a.set(e,i)),i.set(t,n)}return!0}}function R(){var e;return!N(m)&&P(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[m]),N(e)&&(e=ye()),!N(m)&&P(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function be(e){var t=new p,n={isProviderFor:function(e,n){var r=t.get(e);return!N(r)&&r.has(n)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return h.registerProvider(n),n;function r(r,i,a){var o=t.get(r),s=!1;if(N(o)){if(!a)return;o=new d,t.set(r,o),s=!0}var c=o.get(i);if(N(c)){if(!a)return;if(c=new d,o.set(i,c),!e.setProvider(r,i,n))throw o.delete(i),s&&t.delete(r),Error(`Wrong provider for target.`)}return c}function i(e,t,n){var i=r(t,n,!1);return!N(i)&&ce(i.has(e))}function a(e,t,n){var i=r(t,n,!1);if(!N(i))return i.get(e)}function o(e,t,n,i){r(n,i,!0).set(e,t)}function s(e,t){var n=[],i=r(e,t,!1);if(N(i))return n;for(var a=ge(i.keys()),o=0;;){var s=I(a);if(!s)return n.length=o,n;var c=_e(s);try{n[o]=c}catch(e){try{ve(a)}finally{throw e}}o++}}function c(e,n,i){var a=r(n,i,!1);if(N(a)||!a.delete(e))return!1;if(a.size===0){var o=t.get(n);N(o)||(o.delete(i),o.size===0&&t.delete(o))}return!0}}function xe(e){var t=e.defineMetadata,n=e.hasOwnMetadata,r=e.getOwnMetadata,i=e.getOwnMetadataKeys,a=e.deleteMetadata,o=new p;return{isProviderFor:function(e,t){var n=o.get(e);return!N(n)&&n.has(t)?!0:i(e,t).length?(N(n)&&(n=new f,o.set(e,n)),n.add(t),!0):!1},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:a}}function z(e,t,n){var r=h.getProvider(e,t);if(!N(r))return r;if(n){if(h.setProvider(e,t,g))return g;throw Error(`Illegal state.`)}}function Se(){var e={},t=[],n=function(){function e(e,t,n){this._index=0,this._keys=e,this._values=t,this._selector=n}return e.prototype[`@@iterator`]=function(){return this},e.prototype[a]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var n=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:n,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 n=this._find(e,!0);return this._values[n]=t,this},t.prototype.delete=function(t){var n=this._find(t,!1);if(n>=0){for(var r=this._keys.length,i=n+1;i<r;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,he(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 n(this._keys,this._values,r)},t.prototype.values=function(){return new n(this._keys,this._values,i)},t.prototype.entries=function(){return new n(this._keys,this._values,o)},t.prototype[`@@iterator`]=function(){return this.entries()},t.prototype[a]=function(){return this.entries()},t.prototype._find=function(e,t){if(!he(this._cacheKey,e)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(he(this._keys[n],e)){this._cacheIndex=n;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function r(e,t){return e}function i(e,t){return t}function o(e,t){return[e,t]}}function Ce(){return function(){function e(){this._map=new d}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[a]=function(){return this.keys()},e}()}function B(){var e=l.create(),t=r();return function(){function e(){this._key=r()}return e.prototype.has=function(e){var t=i(e,!1);return t!==void 0&&l.has(t,this._key)},e.prototype.get=function(e){var t=i(e,!1);return t===void 0?void 0:l.get(t,this._key)},e.prototype.set=function(e,t){var n=i(e,!0);return n[this._key]=t,this},e.prototype.delete=function(e){var t=i(e,!1);return t!==void 0&&delete t[this._key]},e.prototype.clear=function(){this._key=r()},e}();function r(){var t;do t=`@@WeakMap@@`+s();while(l.has(e,t));return e[t]=!0,t}function i(e,r){if(!n.call(e,t)){if(!r)return;Object.defineProperty(e,t,{value:l.create()})}return e[t]}function a(e,t){for(var n=0;n<t;++n)e[n]=Math.random()*255|0;return e}function o(e){if(typeof Uint8Array==`function`){var t=new Uint8Array(e);return typeof crypto<`u`?crypto.getRandomValues(t):typeof msCrypto<`u`?msCrypto.getRandomValues(t):a(t,e),t}return a(Array(e),e)}function s(){var e=o(16);e[6]=e[6]&79|64,e[8]=e[8]&191|128;for(var t=``,n=0;n<16;++n){var r=e[n];(n===4||n===6||n===8)&&(t+=`-`),r<16&&(t+=`0`),t+=r.toString(16).toLowerCase()}return t}}function we(e){return e.__=void 0,delete e.__,e}})})(e||={})})),L=o({__addDisposableResource:()=>W,__assign:()=>He,__asyncDelegator:()=>Ne,__asyncGenerator:()=>Me,__asyncValues:()=>Pe,__await:()=>je,__awaiter:()=>Te,__classPrivateFieldGet:()=>Re,__classPrivateFieldIn:()=>ze,__classPrivateFieldSet:()=>U,__createBinding:()=>Ue,__decorate:()=>be,__disposeResources:()=>G,__esDecorate:()=>z,__exportStar:()=>V,__extends:()=>ye,__generator:()=>Ee,__importDefault:()=>Le,__importStar:()=>Ie,__makeTemplateObject:()=>Fe,__metadata:()=>we,__param:()=>xe,__propKey:()=>Ce,__read:()=>Oe,__rest:()=>R,__rewriteRelativeImportExtension:()=>Be,__runInitializers:()=>Se,__setFunctionName:()=>B,__spread:()=>H,__spreadArray:()=>Ae,__spreadArrays:()=>ke,__values:()=>De,default:()=>qe});function ye(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Ve(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function R(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function be(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function xe(e,t){return function(n,r){t(n,r,e)}}function z(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function Se(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function Ce(e){return typeof e==`symbol`?e:`${e}`}function B(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,"name",{configurable:!0,value:n?`${n} ${t}`:t})}function we(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Te(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Ee(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function V(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&Ue(t,e,n)}function De(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Oe(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function H(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Oe(arguments[t]));return e}function ke(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function Ae(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function je(e){return this instanceof je?(this.v=e,this):new je(e)}function Me(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof je?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function Ne(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:je(e[r](t)),done:!1}:i?i(t):t}:i}}function Pe(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof De==`function`?De(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Fe(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Ie(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Ge(e),r=0;r<n.length;r++)n[r]!=="default"&&Ue(t,e,n[r]);return We(t,e),t}function Le(e){return e&&e.__esModule?e:{default:e}}function Re(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function U(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function ze(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function W(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function G(e){function t(t){e.error=e.hasError?new Ke(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Be(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var Ve,He,Ue,We,Ge,Ke,qe,K=r((()=>{Ve=function(e,t){return Ve=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ve(e,t)},He=function(){return He=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},He.apply(this,arguments)},Ue=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),We=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},Ge=function(e){return Ge=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Ge(e)},Ke=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},qe={__extends:ye,__assign:He,__rest:R,__decorate:be,__param:xe,__esDecorate:z,__runInitializers:Se,__propKey:Ce,__setFunctionName:B,__metadata:we,__awaiter:Te,__generator:Ee,__createBinding:Ue,__exportStar:V,__values:De,__read:Oe,__spread:H,__spreadArrays:ke,__spreadArray:Ae,__await:je,__asyncGenerator:Me,__asyncDelegator:Ne,__asyncValues:Pe,__makeTemplateObject:Fe,__importStar:Ie,__importDefault:Le,__classPrivateFieldGet:Re,__classPrivateFieldSet:U,__classPrivateFieldIn:ze,__addDisposableResource:W,__disposeResources:G,__rewriteRelativeImportExtension:Be}})),Je=s((e=>{
18
18
  /*!
19
19
  * MIT License
20
20
  *
@@ -39,11 +39,11 @@ var e;(function(e){(function(t){var n=typeof globalThis==`object`?globalThis:typ
39
39
  * SOFTWARE.
40
40
  *
41
41
  */
42
- var t=class e{static isArrayBuffer(e){return Object.prototype.toString.call(e)===`[object ArrayBuffer]`}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw 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(t,n){let r=e.toUint8Array(t),i=e.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let e=0;e<r.length;e++)if(r[e]!==i[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;let n=0;for(let e of t)n+=e.byteLength;let r=new Uint8Array(n),i=0;for(let e of t){let t=this.toUint8Array(e);r.set(t,i),i+=t.length}return e[e.length-1]instanceof Function?this.toView(r,e[e.length-1]):r.buffer}};let n=`string`,r=/^[0-9a-f\s]+$/i,i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,a=/^[a-zA-Z0-9-_]+$/;var o=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}static toString(e){let n=t.toUint8Array(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return decodeURIComponent(escape(r))}},s=class{static toString(e,n=!1){let r=t.toArrayBuffer(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2){let t=i.getUint16(e,n);a+=String.fromCharCode(t)}return a}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t);return n}},c=class e{static isHex(e){return typeof e==n&&r.test(e)}static isBase64(e){return typeof e==n&&i.test(e)}static isBase64Url(e){return typeof e==n&&a.test(e)}static ToString(e,n=`utf8`){let r=t.toUint8Array(e);switch(n.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 s.toString(r,!0);case`utf16`:case`utf16be`:return s.toString(r);default:throw Error(`Unknown type of encoding '${n}'`)}}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 s.fromString(e,!0);case`utf16`:case`utf16be`:return s.fromString(e);default:throw Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let n=t.toUint8Array(e);if(typeof btoa<`u`){let e=this.ToString(n,`binary`);return btoa(e)}return Buffer.from(n).toString(`base64`)}static FromBase64(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64(n))throw TypeError(`Argument 'base64Text' is not Base64 encoded`);return typeof atob<`u`?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,`base64`)).buffer}static FromBase64Url(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64Url(n))throw TypeError(`Argument 'base64url' is not Base64Url encoded`);return this.FromBase64(this.Base64Padding(n.replace(/\-/g,`+`).replace(/\_/g,`/`)))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/\=/g,``)}static FromUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.FromBinary(t);case`utf8`:return o.fromString(t);case`utf16`:case`utf16be`:return s.fromString(t);case`utf16le`:case`usc2`:return s.fromString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.ToBinary(t);case`utf8`:return o.toString(t);case`utf16`:case`utf16be`:return s.toString(t);case`utf16le`:case`usc2`:return s.toString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return n.buffer}static ToBinary(e){let n=t.toUint8Array(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return r}static ToHex(e){let n=t.toUint8Array(e),r=``,i=n.length;for(let e=0;e<i;e++){let t=n[e];t<16&&(r+=`0`),r+=t.toString(16)}return r}static FromHex(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isHex(n))throw TypeError(`Argument 'hexString' is not HEX encoded`);n.length%2&&(n=`0${n}`);let r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2){let t=n.slice(e,e+2);r[e/2]=parseInt(t,16)}return r.buffer}static ToUtf16String(e,t=!1){return s.toString(e,t)}static FromUtf16String(e,t=!1){return s.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+=`=`;return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,``)||``}};c.DEFAULT_UTF8_ENCODING=`utf8`;function l(e,...t){let n=arguments[0];for(let e=1;e<arguments.length;e++){let t=arguments[e];for(let e in t)n[e]=t[e]}return n}function u(...e){let t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),n=new Uint8Array(t),r=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(let t of e)n[r++]=t}),n.buffer}function d(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}e.BufferSourceConverter=t,e.Convert=c,e.assign=l,e.combine=u,e.isEqual=d})),wt=s((e=>{
42
+ var t=class e{static isArrayBuffer(e){return Object.prototype.toString.call(e)===`[object ArrayBuffer]`}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw 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(t,n){let r=e.toUint8Array(t),i=e.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let e=0;e<r.length;e++)if(r[e]!==i[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;let n=0;for(let e of t)n+=e.byteLength;let r=new Uint8Array(n),i=0;for(let e of t){let t=this.toUint8Array(e);r.set(t,i),i+=t.length}return e[e.length-1]instanceof Function?this.toView(r,e[e.length-1]):r.buffer}};let n=`string`,r=/^[0-9a-f\s]+$/i,i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,a=/^[a-zA-Z0-9-_]+$/;var o=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}static toString(e){let n=t.toUint8Array(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return decodeURIComponent(escape(r))}},s=class{static toString(e,n=!1){let r=t.toArrayBuffer(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2){let t=i.getUint16(e,n);a+=String.fromCharCode(t)}return a}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t);return n}},c=class e{static isHex(e){return typeof e==n&&r.test(e)}static isBase64(e){return typeof e==n&&i.test(e)}static isBase64Url(e){return typeof e==n&&a.test(e)}static ToString(e,n=`utf8`){let r=t.toUint8Array(e);switch(n.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 s.toString(r,!0);case`utf16`:case`utf16be`:return s.toString(r);default:throw Error(`Unknown type of encoding '${n}'`)}}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 s.fromString(e,!0);case`utf16`:case`utf16be`:return s.fromString(e);default:throw Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let n=t.toUint8Array(e);if(typeof btoa<`u`){let e=this.ToString(n,`binary`);return btoa(e)}return Buffer.from(n).toString(`base64`)}static FromBase64(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64(n))throw TypeError(`Argument 'base64Text' is not Base64 encoded`);return typeof atob<`u`?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,`base64`)).buffer}static FromBase64Url(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64Url(n))throw TypeError(`Argument 'base64url' is not Base64Url encoded`);return this.FromBase64(this.Base64Padding(n.replace(/\-/g,`+`).replace(/\_/g,`/`)))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/\=/g,``)}static FromUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.FromBinary(t);case`utf8`:return o.fromString(t);case`utf16`:case`utf16be`:return s.fromString(t);case`utf16le`:case`usc2`:return s.fromString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.ToBinary(t);case`utf8`:return o.toString(t);case`utf16`:case`utf16be`:return s.toString(t);case`utf16le`:case`usc2`:return s.toString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return n.buffer}static ToBinary(e){let n=t.toUint8Array(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return r}static ToHex(e){let n=t.toUint8Array(e),r=``,i=n.length;for(let e=0;e<i;e++){let t=n[e];t<16&&(r+=`0`),r+=t.toString(16)}return r}static FromHex(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isHex(n))throw TypeError(`Argument 'hexString' is not HEX encoded`);n.length%2&&(n=`0${n}`);let r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2){let t=n.slice(e,e+2);r[e/2]=parseInt(t,16)}return r.buffer}static ToUtf16String(e,t=!1){return s.toString(e,t)}static FromUtf16String(e,t=!1){return s.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+=`=`;return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,``)||``}};c.DEFAULT_UTF8_ENCODING=`utf8`;function l(e,...t){let n=arguments[0];for(let e=1;e<arguments.length;e++){let t=arguments[e];for(let e in t)n[e]=t[e]}return n}function u(...e){let t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),n=new Uint8Array(t),r=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(let t of e)n[r++]=t}),n.buffer}function d(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}e.BufferSourceConverter=t,e.Convert=c,e.assign=l,e.combine=u,e.isEqual=d})),Ye=s((e=>{
43
43
  /*!
44
44
  Copyright (c) Peculiar Ventures, LLC
45
45
  */
46
- Object.defineProperty(e,"__esModule",{value:!0});function t(e){return new Date(e.getTime()+e.getTimezoneOffset()*6e4)}function n(e,t,n){return e instanceof Object?e[t]??n:n}function r(e,t=0,n=e.byteLength-t,r=!1){let i=``;for(let a of new Uint8Array(e,t,n)){let e=a.toString(16).toUpperCase();e.length===1&&(i+=`0`),i+=e,r&&(i+=` `)}return i.trim()}function i(e,t,n,r){return t instanceof ArrayBuffer?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be "ArrayBuffer"`,!1)}function a(e,t){let n=0;if(e.length===1)return e[0];for(let r=e.length-1;r>=0;r--)n+=e[e.length-1-r]*2**(t*r);return n}function o(e,t,n=-1){let r=n,i=e,a=0,o=2**t;for(let n=1;n<8;n++){if(e<o){let e;if(r<0)e=new ArrayBuffer(n),a=n;else{if(r<n)return new ArrayBuffer(0);e=new ArrayBuffer(r),a=r}let o=new Uint8Array(e);for(let e=n-1;e>=0;e--){let n=2**(e*t);o[a-e-1]=Math.floor(i/n),i-=o[a-e-1]*n}return e}o*=2**t}return new ArrayBuffer(0)}function s(...e){let t=0,n=0;for(let n of e)t+=n.byteLength;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return r}function c(...e){let t=0,n=0;for(let n of e)t+=n.length;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(t,n),n+=t.length;return i}function l(){let e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let t=e[0]===255&&e[1]&128,n=e[0]===0&&!(e[1]&128);(t||n)&&this.warnings.push(`Needlessly long format`)}let t=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)n[e]=0;n[0]=e[0]&128;let r=a(n,8),i=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(i);for(let t=0;t<this.valueHex.byteLength;t++)o[t]=e[t];return o[0]&=127,a(o,8)-r}function u(e){let t=e<0?e*-1:e,n=128;for(let r=1;r<8;r++){if(t<=n){if(e<0){let e=o(n-t,8,r),i=new Uint8Array(e);return i[0]|=128,e}let i=o(t,8,r),a=new Uint8Array(i);if(a[0]&128){let e=i.slice(0),t=new Uint8Array(e);i=new ArrayBuffer(i.byteLength+1),a=new Uint8Array(i);for(let n=0;n<e.byteLength;n++)a[n+1]=t[n];a[0]=0}return i}n*=2**8}return new ArrayBuffer(0)}function d(e,t){if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function f(e,t){let n=e.toString(10);if(t<n.length)return``;let r=t-n.length,i=Array(r);for(let e=0;e<r;e++)i[e]=`0`;return i.join(``).concat(n)}let p=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,m=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=`;function h(e,t=!1,n=!1,r=!1){let i=0,a=0,o=0,s=``,c=t?m:p;if(r){let t=0;for(let n=0;n<e.length;n++)if(e.charCodeAt(n)!==0){t=n;break}e=e.slice(t)}for(;i<e.length;){let t=e.charCodeAt(i++);i>=e.length&&(a=1);let r=e.charCodeAt(i++);i>=e.length&&(o=1);let l=e.charCodeAt(i++),u=t>>2,d=(t&3)<<4|r>>4,f=(r&15)<<2|l>>6,p=l&63;a===1?f=p=64:o===1&&(p=64),s+=n?f===64?`${c.charAt(u)}${c.charAt(d)}`:p===64?`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}`:`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}${c.charAt(p)}`:`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}${c.charAt(p)}`}return s}function g(e,t=!1,n=!1){let r=t?m:p;function i(e){for(let t=0;t<64;t++)if(r.charAt(t)===e)return t;return 64}function a(e){return e===64?0:e}let o=0,s=``;for(;o<e.length;){let t=i(e.charAt(o++)),n=o>=e.length?0:i(e.charAt(o++)),r=o>=e.length?0:i(e.charAt(o++)),c=o>=e.length?0:i(e.charAt(o++)),l=a(t)<<2|a(n)>>4,u=(a(n)&15)<<4|a(r)>>2,d=(a(r)&3)<<6|a(c);s+=String.fromCharCode(l),r!==64&&(s+=String.fromCharCode(u)),c!==64&&(s+=String.fromCharCode(d))}if(n){let e=s.length,t=-1;for(let n=e-1;n>=0;n--)if(s.charCodeAt(n)!==0){t=n;break}s=t===-1?``:s.slice(0,t+1)}return s}function _(e){let t=``,n=new Uint8Array(e);for(let e of n)t+=String.fromCharCode(e);return t}function v(e){let t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return n}let y=Math.log(2);function b(e){let t=Math.log(e)/y,n=Math.floor(t),r=Math.round(t);return n===r?n:r}function x(e,t){for(let n of t)delete e[n]}e.arrayBufferToString=_,e.bufferToHexCodes=r,e.checkBufferParams=i,e.clearProps=x,e.fromBase64=g,e.getParametersValue=n,e.getUTCDate=t,e.isEqualBuffer=d,e.nearestPowerOf2=b,e.padNumber=f,e.stringToArrayBuffer=v,e.toBase64=h,e.utilConcatBuf=s,e.utilConcatView=c,e.utilDecodeTC=l,e.utilEncodeTC=u,e.utilFromBase=a,e.utilToBase=o})),Tt=s((e=>{
46
+ Object.defineProperty(e,"__esModule",{value:!0});function t(e){return new Date(e.getTime()+e.getTimezoneOffset()*6e4)}function n(e,t,n){return e instanceof Object?e[t]??n:n}function r(e,t=0,n=e.byteLength-t,r=!1){let i=``;for(let a of new Uint8Array(e,t,n)){let e=a.toString(16).toUpperCase();e.length===1&&(i+=`0`),i+=e,r&&(i+=` `)}return i.trim()}function i(e,t,n,r){return t instanceof ArrayBuffer?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be "ArrayBuffer"`,!1)}function a(e,t){let n=0;if(e.length===1)return e[0];for(let r=e.length-1;r>=0;r--)n+=e[e.length-1-r]*2**(t*r);return n}function o(e,t,n=-1){let r=n,i=e,a=0,o=2**t;for(let n=1;n<8;n++){if(e<o){let e;if(r<0)e=new ArrayBuffer(n),a=n;else{if(r<n)return new ArrayBuffer(0);e=new ArrayBuffer(r),a=r}let o=new Uint8Array(e);for(let e=n-1;e>=0;e--){let n=2**(e*t);o[a-e-1]=Math.floor(i/n),i-=o[a-e-1]*n}return e}o*=2**t}return new ArrayBuffer(0)}function s(...e){let t=0,n=0;for(let n of e)t+=n.byteLength;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return r}function c(...e){let t=0,n=0;for(let n of e)t+=n.length;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(t,n),n+=t.length;return i}function l(){let e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let t=e[0]===255&&e[1]&128,n=e[0]===0&&!(e[1]&128);(t||n)&&this.warnings.push(`Needlessly long format`)}let t=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)n[e]=0;n[0]=e[0]&128;let r=a(n,8),i=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(i);for(let t=0;t<this.valueHex.byteLength;t++)o[t]=e[t];return o[0]&=127,a(o,8)-r}function u(e){let t=e<0?e*-1:e,n=128;for(let r=1;r<8;r++){if(t<=n){if(e<0){let e=o(n-t,8,r),i=new Uint8Array(e);return i[0]|=128,e}let i=o(t,8,r),a=new Uint8Array(i);if(a[0]&128){let e=i.slice(0),t=new Uint8Array(e);i=new ArrayBuffer(i.byteLength+1),a=new Uint8Array(i);for(let n=0;n<e.byteLength;n++)a[n+1]=t[n];a[0]=0}return i}n*=2**8}return new ArrayBuffer(0)}function d(e,t){if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function f(e,t){let n=e.toString(10);if(t<n.length)return``;let r=t-n.length,i=Array(r);for(let e=0;e<r;e++)i[e]=`0`;return i.join(``).concat(n)}let p=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,m=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=`;function h(e,t=!1,n=!1,r=!1){let i=0,a=0,o=0,s=``,c=t?m:p;if(r){let t=0;for(let n=0;n<e.length;n++)if(e.charCodeAt(n)!==0){t=n;break}e=e.slice(t)}for(;i<e.length;){let t=e.charCodeAt(i++);i>=e.length&&(a=1);let r=e.charCodeAt(i++);i>=e.length&&(o=1);let l=e.charCodeAt(i++),u=t>>2,d=(t&3)<<4|r>>4,f=(r&15)<<2|l>>6,p=l&63;a===1?f=p=64:o===1&&(p=64),s+=n?f===64?`${c.charAt(u)}${c.charAt(d)}`:p===64?`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}`:`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}${c.charAt(p)}`:`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}${c.charAt(p)}`}return s}function g(e,t=!1,n=!1){let r=t?m:p;function i(e){for(let t=0;t<64;t++)if(r.charAt(t)===e)return t;return 64}function a(e){return e===64?0:e}let o=0,s=``;for(;o<e.length;){let t=i(e.charAt(o++)),n=o>=e.length?0:i(e.charAt(o++)),r=o>=e.length?0:i(e.charAt(o++)),c=o>=e.length?0:i(e.charAt(o++)),l=a(t)<<2|a(n)>>4,u=(a(n)&15)<<4|a(r)>>2,d=(a(r)&3)<<6|a(c);s+=String.fromCharCode(l),r!==64&&(s+=String.fromCharCode(u)),c!==64&&(s+=String.fromCharCode(d))}if(n){let e=s.length,t=-1;for(let n=e-1;n>=0;n--)if(s.charCodeAt(n)!==0){t=n;break}s=t===-1?``:s.slice(0,t+1)}return s}function _(e){let t=``,n=new Uint8Array(e);for(let e of n)t+=String.fromCharCode(e);return t}function v(e){let t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return n}let y=Math.log(2);function b(e){let t=Math.log(e)/y,n=Math.floor(t),r=Math.round(t);return n===r?n:r}function x(e,t){for(let n of t)delete e[n]}e.arrayBufferToString=_,e.bufferToHexCodes=r,e.checkBufferParams=i,e.clearProps=x,e.fromBase64=g,e.getParametersValue=n,e.getUTCDate=t,e.isEqualBuffer=d,e.nearestPowerOf2=b,e.padNumber=f,e.stringToArrayBuffer=v,e.toBase64=h,e.utilConcatBuf=s,e.utilConcatView=c,e.utilDecodeTC=l,e.utilEncodeTC=u,e.utilFromBase=a,e.utilToBase=o})),Xe=s((e=>{
47
47
  /*!
48
48
  * Copyright (c) 2014, GMO GlobalSign
49
49
  * Copyright (c) 2015-2022, Peculiar Ventures
@@ -77,15 +77,15 @@ Object.defineProperty(e,"__esModule",{value:!0});function t(e){return new Date(e
77
77
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78
78
  *
79
79
  */
80
- var t=Ct(),n=wt();function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var i=r(t),a=r(n);function o(){if(typeof BigInt>`u`)throw Error(`BigInt is not defined. Your environment doesn't implement BigInt.`)}function s(e){let t=0,n=0;for(let n=0;n<e.length;n++){let r=e[n];t+=r.byteLength}let r=new Uint8Array(t);for(let t=0;t<e.length;t++){let i=e[t];r.set(new Uint8Array(i),n),n+=i.byteLength}return r.buffer}function c(e,t,n,r){return t instanceof Uint8Array?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be 'Uint8Array'`,!1)}var l=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return s(this.items)}};let u=[new Uint8Array([1])],d=`0123456789`,f=`name`,p=`valueHexView`,m=new ArrayBuffer(0),h=new Uint8Array,g=`EndOfContent`,_=`OCTET STRING`,v=`BIT STRING`;function y(e){var t;return t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(...e){super(...e);let t=e[0]||{};this.isHexOnly=t.isHexOnly??!1,this.valueHexView=t.valueHex?i.BufferSourceConverter.toUint8Array(t.valueHex):h}fromBER(e,t,n,r){let i=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!c(this,i,t,n))return-1;let a=t+n;return this.valueHexView=i.subarray(t,a),this.valueHexView.length?(this.blockLength=n,a):(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`,m)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:i.Convert.ToHex(this.valueHexView)}}},t.NAME=`hexBlock`,t}var b=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=``,warnings:n=[],valueBeforeDecode:r=h}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=i.BufferSourceConverter.toUint8Array(r)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:i.Convert.ToHex(this.valueBeforeDecodeView)}}};b.NAME=`baseBlock`;var x=class extends b{fromBER(e,t,n,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'`)}};x.NAME=`valueBlock`;var S=class extends y(b){constructor({idBlock:e={}}={}){super(),e?(this.isHexOnly=e.isHexOnly??!1,this.valueHexView=e.valueHex?i.BufferSourceConverter.toUint8Array(e.valueHex):h,this.tagClass=e.tagClass??-1,this.tagNumber=e.tagNumber??-1,this.isConstructed=e.isConstructed??!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error=`Unknown tag class`,m}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let n=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,n[0]=t}return n.buffer}if(!this.isHexOnly){let n=a.utilToBase(this.tagNumber,7),r=new Uint8Array(n),i=n.byteLength,o=new Uint8Array(i+1);if(o[0]=t|31,!e){for(let e=0;e<i-1;e++)o[e+1]=r[e]|128;o[i]=r[i-1]}return o.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let e=this.valueHexView;for(let t=0;t<e.length-1;t++)n[t+1]=e[t]|128;n[this.valueHexView.byteLength]=e[e.length-1]}return n.buffer}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);if(o.length===0)return this.error=`Zero buffer length`,-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error=`Unknown tag class`,-1}this.isConstructed=(o[0]&32)==32,this.isHexOnly=!1;let s=o[0]&31;if(s!==31)this.tagNumber=s,this.blockLength=1;else{let e=0;for(;;){let t=e+1;if(t>=o.length)return this.error=`End of input reached before message was fully decoded`,-1;if(e++,!(o[t]&128))break}this.blockLength=e+1;let t=this.valueHexView=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=o[n+1]&127;this.blockLength<=9?this.tagNumber=a.utilFromBase(t,7):(this.isHexOnly=!0,this.warnings.push(`Tag too long, represented as hex-coded`))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error=`Constructed encoding used for primitive type`,-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};S.NAME=`identificationBlock`;var C=class extends b{constructor({lenBlock:e={}}={}){super(),this.isIndefiniteForm=e.isIndefiniteForm??!1,this.longFormUsed=e.longFormUsed??!1,this.length=e.length??0}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);if(o.length===0)return this.error=`Zero buffer length`,-1;if(o[0]===255)return this.error=`Length block 0xFF is reserved by standard`,-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+this.blockLength;let s=o[0]&127;if(s>8)return this.error=`Too big integer`,-1;if(s+1>o.length)return this.error=`End of input reached before message was fully decoded`,-1;let l=t+1,u=r.subarray(l,l+s);return u[s-1]===0&&this.warnings.push(`Needlessly long encoded length`),this.length=a.utilFromBase(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push(`Unnecessary usage of long length form`),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let r=a.utilToBase(this.length,8);if(r.byteLength>127)return this.error=`Too big length`,m;if(t=new ArrayBuffer(r.byteLength+1),e)return t;let i=new Uint8Array(r);n=new Uint8Array(t),n[0]=r.byteLength|128;for(let e=0;e<r.byteLength;e++)n[e+1]=i[e];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};C.NAME=`lengthBlock`;let w={};var T=class extends b{constructor({name:e=``,optional:t=!1,primitiveSchema:n,...r}={},i){super(r),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new S(r),this.lenBlock=new C(r),this.valueBlock=i?new i(r):new x(r)}fromBER(e,t,n,r){let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,r);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){let n=t||new l;t||E(this);let r=this.idBlock.toBER(e);if(n.write(r),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;let r=this.lenBlock.toBER(e);n.write(r),n.write(t)}return t?m:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e=`ascii`){return e===`ascii`?this.onAsciiEncoding():i.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return a.isEqualBuffer(t,n)}};T.NAME=`BaseBlock`;function E(e){if(e instanceof w.Constructed)for(let t of e.valueBlock.value)E(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock?.isIndefiniteForm}var D=class extends T{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=``,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(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),r)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};D.NAME=`BaseStringBlock`;var O=class extends y(x){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};O.NAME=`PrimitiveValueBlock`;var k,A=class extends T{constructor(e={}){super(e,O),this.idBlock.isConstructed=!1}};k=A,w.Primitive=k,A.NAME=`PRIMITIVE`;let j=1e4,M=16777216;function N(e={}){return{depth:0,maxDepth:e.maxDepth??100,nodesCount:0,maxNodes:e.maxNodes??j,maxContentLength:e.maxContentLength??M}}function ee(e){let t=new T({},x);return t.error=e,{offset:-1,result:t}}function te(e){if(e.nodesCount+=1,e.nodesCount>e.maxNodes)return`Maximum ASN.1 node count exceeded`}function ne(e,t){if(e>t.maxContentLength)return`Maximum ASN.1 content length exceeded`}function P(e,t,n,r){let i=r.depth+1;if(i>r.maxDepth)return ee(`Maximum ASN.1 nesting depth exceeded`);r.depth=i;try{return ie(e,t,n,r)}finally{--r.depth}}function re(e,t){if(e instanceof t)return e;let n=new t;return n.idBlock=e.idBlock,n.lenBlock=e.lenBlock,n.warnings=e.warnings,n.valueBeforeDecodeView=e.valueBeforeDecodeView,n}function ie(e,t=0,n=e.length,r=N()){let i=t,a=new T({},x),o=new b;if(!c(o,e,t,n))return a.error=o.error,{offset:-1,result:a};if(!e.subarray(t,t+n).length)return a.error=`Zero buffer length`,{offset:-1,result:a};let s=te(r);if(s)return a.error=s,{offset:-1,result:a};let l=a.idBlock.fromBER(e,t,n);if(a.idBlock.warnings.length&&a.warnings.concat(a.idBlock.warnings),l===-1)return a.error=a.idBlock.error,{offset:-1,result:a};if(t=l,n-=a.idBlock.blockLength,l=a.lenBlock.fromBER(e,t,n),a.lenBlock.warnings.length&&a.warnings.concat(a.lenBlock.warnings),l===-1)return a.error=a.lenBlock.error,{offset:-1,result:a};t=l,n-=a.lenBlock.blockLength;let u=a.lenBlock.isIndefiniteForm?n:a.lenBlock.length,d=ne(u,r);if(d)return a.error=d,{offset:-1,result:a};if(!a.idBlock.isConstructed&&a.lenBlock.isIndefiniteForm)return a.error=`Indefinite length form used for primitive encoding form`,{offset:-1,result:a};let f=T;switch(a.idBlock.tagClass){case 1:if(a.idBlock.tagNumber>=37&&a.idBlock.isHexOnly===!1)return a.error=`UNIVERSAL 37 and upper tags are reserved by ASN.1 standard`,{offset:-1,result:a};switch(a.idBlock.tagNumber){case 0:if(a.idBlock.isConstructed&&a.lenBlock.length>0)return a.error=`Type [UNIVERSAL 0] is reserved`,{offset:-1,result:a};f=w.EndOfContent;break;case 1:f=w.Boolean;break;case 2:f=w.Integer;break;case 3:f=w.BitString;break;case 4:f=w.OctetString;break;case 5:f=w.Null;break;case 6:f=w.ObjectIdentifier;break;case 10:f=w.Enumerated;break;case 12:f=w.Utf8String;break;case 13:f=w.RelativeObjectIdentifier;break;case 14:f=w.TIME;break;case 15:return a.error=`[UNIVERSAL 15] is reserved by ASN.1 standard`,{offset:-1,result:a};case 16:f=w.Sequence;break;case 17:f=w.Set;break;case 18:f=w.NumericString;break;case 19:f=w.PrintableString;break;case 20:f=w.TeletexString;break;case 21:f=w.VideotexString;break;case 22:f=w.IA5String;break;case 23:f=w.UTCTime;break;case 24:f=w.GeneralizedTime;break;case 25:f=w.GraphicString;break;case 26:f=w.VisibleString;break;case 27:f=w.GeneralString;break;case 28:f=w.UniversalString;break;case 29:f=w.CharacterString;break;case 30:f=w.BmpString;break;case 31:f=w.DATE;break;case 32:f=w.TimeOfDay;break;case 33:f=w.DateTime;break;case 34:f=w.Duration;break;default:{let e=a.idBlock.isConstructed?new w.Constructed:new w.Primitive;e.idBlock=a.idBlock,e.lenBlock=a.lenBlock,e.warnings=a.warnings,a=e}}break;default:f=a.idBlock.isConstructed?w.Constructed:w.Primitive}return a=re(a,f),l=a.fromBER(e,t,u,r),a.valueBeforeDecodeView=e.subarray(i,i+a.blockLength),{offset:l,result:a}}function F(e,t={}){if(!e.byteLength){let e=new T({},x);return e.error=`Input buffer has zero length`,{offset:-1,result:e}}return ie(i.BufferSourceConverter.toUint8Array(e).slice(),0,e.byteLength,N(t))}function ae(e,t){return e?1:t}var oe=class extends x{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n,r){let a=i.BufferSourceConverter.toUint8Array(e),o=r??N();if(!c(this,a,t,n))return-1;if(this.valueBeforeDecodeView=a.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push(`Zero buffer length`),t;let s=t;for(;ae(this.isIndefiniteForm,n)>0;){let e=P(a,s,n,o);if(e.offset===-1)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,n-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===g)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===g?this.value.pop():this.warnings.push(`No EndOfContent block encoded`)),s}toBER(e,t){let n=t||new l;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,n);return t?m:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};oe.NAME=`ConstructedValueBlock`;var se,I=class extends T{constructor(e={}){super(e,oe),this.idBlock.isConstructed=!0}fromBER(e,t,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,r);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){let e=[];for(let t of this.valueBlock.value)e.push(t.toString(`ascii`).split(`
80
+ var t=Je(),n=Ye();function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var i=r(t),a=r(n);function o(){if(typeof BigInt>`u`)throw Error(`BigInt is not defined. Your environment doesn't implement BigInt.`)}function s(e){let t=0,n=0;for(let n=0;n<e.length;n++){let r=e[n];t+=r.byteLength}let r=new Uint8Array(t);for(let t=0;t<e.length;t++){let i=e[t];r.set(new Uint8Array(i),n),n+=i.byteLength}return r.buffer}function c(e,t,n,r){return t instanceof Uint8Array?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be 'Uint8Array'`,!1)}var l=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return s(this.items)}};let u=[new Uint8Array([1])],d=`0123456789`,f=`name`,p=`valueHexView`,m=new ArrayBuffer(0),h=new Uint8Array,g=`EndOfContent`,_=`OCTET STRING`,v=`BIT STRING`;function y(e){var t;return t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(...e){super(...e);let t=e[0]||{};this.isHexOnly=t.isHexOnly??!1,this.valueHexView=t.valueHex?i.BufferSourceConverter.toUint8Array(t.valueHex):h}fromBER(e,t,n,r){let i=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!c(this,i,t,n))return-1;let a=t+n;return this.valueHexView=i.subarray(t,a),this.valueHexView.length?(this.blockLength=n,a):(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`,m)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:i.Convert.ToHex(this.valueHexView)}}},t.NAME=`hexBlock`,t}var b=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=``,warnings:n=[],valueBeforeDecode:r=h}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=i.BufferSourceConverter.toUint8Array(r)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:i.Convert.ToHex(this.valueBeforeDecodeView)}}};b.NAME=`baseBlock`;var x=class extends b{fromBER(e,t,n,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'`)}};x.NAME=`valueBlock`;var S=class extends y(b){constructor({idBlock:e={}}={}){super(),e?(this.isHexOnly=e.isHexOnly??!1,this.valueHexView=e.valueHex?i.BufferSourceConverter.toUint8Array(e.valueHex):h,this.tagClass=e.tagClass??-1,this.tagNumber=e.tagNumber??-1,this.isConstructed=e.isConstructed??!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error=`Unknown tag class`,m}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let n=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,n[0]=t}return n.buffer}if(!this.isHexOnly){let n=a.utilToBase(this.tagNumber,7),r=new Uint8Array(n),i=n.byteLength,o=new Uint8Array(i+1);if(o[0]=t|31,!e){for(let e=0;e<i-1;e++)o[e+1]=r[e]|128;o[i]=r[i-1]}return o.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let e=this.valueHexView;for(let t=0;t<e.length-1;t++)n[t+1]=e[t]|128;n[this.valueHexView.byteLength]=e[e.length-1]}return n.buffer}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);if(o.length===0)return this.error=`Zero buffer length`,-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error=`Unknown tag class`,-1}this.isConstructed=(o[0]&32)==32,this.isHexOnly=!1;let s=o[0]&31;if(s!==31)this.tagNumber=s,this.blockLength=1;else{let e=0;for(;;){let t=e+1;if(t>=o.length)return this.error=`End of input reached before message was fully decoded`,-1;if(e++,!(o[t]&128))break}this.blockLength=e+1;let t=this.valueHexView=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=o[n+1]&127;this.blockLength<=9?this.tagNumber=a.utilFromBase(t,7):(this.isHexOnly=!0,this.warnings.push(`Tag too long, represented as hex-coded`))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error=`Constructed encoding used for primitive type`,-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};S.NAME=`identificationBlock`;var C=class extends b{constructor({lenBlock:e={}}={}){super(),this.isIndefiniteForm=e.isIndefiniteForm??!1,this.longFormUsed=e.longFormUsed??!1,this.length=e.length??0}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);if(o.length===0)return this.error=`Zero buffer length`,-1;if(o[0]===255)return this.error=`Length block 0xFF is reserved by standard`,-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+this.blockLength;let s=o[0]&127;if(s>8)return this.error=`Too big integer`,-1;if(s+1>o.length)return this.error=`End of input reached before message was fully decoded`,-1;let l=t+1,u=r.subarray(l,l+s);return u[s-1]===0&&this.warnings.push(`Needlessly long encoded length`),this.length=a.utilFromBase(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push(`Unnecessary usage of long length form`),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let r=a.utilToBase(this.length,8);if(r.byteLength>127)return this.error=`Too big length`,m;if(t=new ArrayBuffer(r.byteLength+1),e)return t;let i=new Uint8Array(r);n=new Uint8Array(t),n[0]=r.byteLength|128;for(let e=0;e<r.byteLength;e++)n[e+1]=i[e];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};C.NAME=`lengthBlock`;let w={};var T=class extends b{constructor({name:e=``,optional:t=!1,primitiveSchema:n,...r}={},i){super(r),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new S(r),this.lenBlock=new C(r),this.valueBlock=i?new i(r):new x(r)}fromBER(e,t,n,r){let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,r);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){let n=t||new l;t||ee(this);let r=this.idBlock.toBER(e);if(n.write(r),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;let r=this.lenBlock.toBER(e);n.write(r),n.write(t)}return t?m:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e=`ascii`){return e===`ascii`?this.onAsciiEncoding():i.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return a.isEqualBuffer(t,n)}};T.NAME=`BaseBlock`;function ee(e){if(e instanceof w.Constructed)for(let t of e.valueBlock.value)ee(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock?.isIndefiniteForm}var E=class extends T{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=``,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(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),r)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};E.NAME=`BaseStringBlock`;var D=class extends y(x){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};D.NAME=`PrimitiveValueBlock`;var O,k=class extends T{constructor(e={}){super(e,D),this.idBlock.isConstructed=!1}};O=k,w.Primitive=O,k.NAME=`PRIMITIVE`;let A=1e4,j=16777216;function M(e={}){return{depth:0,maxDepth:e.maxDepth??100,nodesCount:0,maxNodes:e.maxNodes??A,maxContentLength:e.maxContentLength??j}}function te(e){let t=new T({},x);return t.error=e,{offset:-1,result:t}}function ne(e){if(e.nodesCount+=1,e.nodesCount>e.maxNodes)return`Maximum ASN.1 node count exceeded`}function re(e,t){if(e>t.maxContentLength)return`Maximum ASN.1 content length exceeded`}function N(e,t,n,r){let i=r.depth+1;if(i>r.maxDepth)return te(`Maximum ASN.1 nesting depth exceeded`);r.depth=i;try{return ae(e,t,n,r)}finally{--r.depth}}function ie(e,t){if(e instanceof t)return e;let n=new t;return n.idBlock=e.idBlock,n.lenBlock=e.lenBlock,n.warnings=e.warnings,n.valueBeforeDecodeView=e.valueBeforeDecodeView,n}function ae(e,t=0,n=e.length,r=M()){let i=t,a=new T({},x),o=new b;if(!c(o,e,t,n))return a.error=o.error,{offset:-1,result:a};if(!e.subarray(t,t+n).length)return a.error=`Zero buffer length`,{offset:-1,result:a};let s=ne(r);if(s)return a.error=s,{offset:-1,result:a};let l=a.idBlock.fromBER(e,t,n);if(a.idBlock.warnings.length&&a.warnings.concat(a.idBlock.warnings),l===-1)return a.error=a.idBlock.error,{offset:-1,result:a};if(t=l,n-=a.idBlock.blockLength,l=a.lenBlock.fromBER(e,t,n),a.lenBlock.warnings.length&&a.warnings.concat(a.lenBlock.warnings),l===-1)return a.error=a.lenBlock.error,{offset:-1,result:a};t=l,n-=a.lenBlock.blockLength;let u=a.lenBlock.isIndefiniteForm?n:a.lenBlock.length,d=re(u,r);if(d)return a.error=d,{offset:-1,result:a};if(!a.idBlock.isConstructed&&a.lenBlock.isIndefiniteForm)return a.error=`Indefinite length form used for primitive encoding form`,{offset:-1,result:a};let f=T;switch(a.idBlock.tagClass){case 1:if(a.idBlock.tagNumber>=37&&a.idBlock.isHexOnly===!1)return a.error=`UNIVERSAL 37 and upper tags are reserved by ASN.1 standard`,{offset:-1,result:a};switch(a.idBlock.tagNumber){case 0:if(a.idBlock.isConstructed&&a.lenBlock.length>0)return a.error=`Type [UNIVERSAL 0] is reserved`,{offset:-1,result:a};f=w.EndOfContent;break;case 1:f=w.Boolean;break;case 2:f=w.Integer;break;case 3:f=w.BitString;break;case 4:f=w.OctetString;break;case 5:f=w.Null;break;case 6:f=w.ObjectIdentifier;break;case 10:f=w.Enumerated;break;case 12:f=w.Utf8String;break;case 13:f=w.RelativeObjectIdentifier;break;case 14:f=w.TIME;break;case 15:return a.error=`[UNIVERSAL 15] is reserved by ASN.1 standard`,{offset:-1,result:a};case 16:f=w.Sequence;break;case 17:f=w.Set;break;case 18:f=w.NumericString;break;case 19:f=w.PrintableString;break;case 20:f=w.TeletexString;break;case 21:f=w.VideotexString;break;case 22:f=w.IA5String;break;case 23:f=w.UTCTime;break;case 24:f=w.GeneralizedTime;break;case 25:f=w.GraphicString;break;case 26:f=w.VisibleString;break;case 27:f=w.GeneralString;break;case 28:f=w.UniversalString;break;case 29:f=w.CharacterString;break;case 30:f=w.BmpString;break;case 31:f=w.DATE;break;case 32:f=w.TimeOfDay;break;case 33:f=w.DateTime;break;case 34:f=w.Duration;break;default:{let e=a.idBlock.isConstructed?new w.Constructed:new w.Primitive;e.idBlock=a.idBlock,e.lenBlock=a.lenBlock,e.warnings=a.warnings,a=e}}break;default:f=a.idBlock.isConstructed?w.Constructed:w.Primitive}return a=ie(a,f),l=a.fromBER(e,t,u,r),a.valueBeforeDecodeView=e.subarray(i,i+a.blockLength),{offset:l,result:a}}function P(e,t={}){if(!e.byteLength){let e=new T({},x);return e.error=`Input buffer has zero length`,{offset:-1,result:e}}return ae(i.BufferSourceConverter.toUint8Array(e).slice(),0,e.byteLength,M(t))}function oe(e,t){return e?1:t}var se=class extends x{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n,r){let a=i.BufferSourceConverter.toUint8Array(e),o=r??M();if(!c(this,a,t,n))return-1;if(this.valueBeforeDecodeView=a.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push(`Zero buffer length`),t;let s=t;for(;oe(this.isIndefiniteForm,n)>0;){let e=N(a,s,n,o);if(e.offset===-1)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,n-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===g)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===g?this.value.pop():this.warnings.push(`No EndOfContent block encoded`)),s}toBER(e,t){let n=t||new l;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,n);return t?m:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};se.NAME=`ConstructedValueBlock`;var ce,le=class extends T{constructor(e={}){super(e,se),this.idBlock.isConstructed=!0}fromBER(e,t,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,r);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){let e=[];for(let t of this.valueBlock.value)e.push(t.toString(`ascii`).split(`
81
81
  `).map(e=>` ${e}`).join(`
82
82
  `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join(`
83
- `)}`:`${t} :`}};se=I,w.Constructed=se,I.NAME=`CONSTRUCTED`;var L=class extends x{fromBER(e,t,n){return t}toBER(e){return m}};L.override=`EndOfContentValueBlock`;var ce,le=class extends T{constructor(e={}){super(e,L),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};ce=le,w.EndOfContent=ce,le.NAME=g;var ue,de=class extends T{constructor(e={}){super(e,x),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push(`Non-zero length of value block for Null type`),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let e=new Uint8Array(n);e[0]=5,e[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};ue=de,w.Null=ue,de.NAME=`NULL`;var fe=class extends y(x){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),this.valueHexView=t.valueHex?i.BufferSourceConverter.toUint8Array(t.valueHex):new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);return c(this,r,t,n)?(this.valueHexView=r.subarray(t,t+n),n>1&&this.warnings.push(`Boolean value encoded in more then 1 octet`),this.isHexOnly=!0,a.utilDecodeTC.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};fe.NAME=`BooleanValueBlock`;var R,z=class extends T{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,fe),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};R=z,w.Boolean=R,z.NAME=`BOOLEAN`;var pe=class extends y(oe){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=oe.prototype.fromBER.call(this,e,t,n,r),i===-1)return i;for(let e=0;e<this.value.length;e++){let t=this.value[e].constructor.NAME;if(t===g){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only`,-1}if(t!==_)return this.error=`OCTET STRING may consists of OCTET STRINGs only`,-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?oe.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`;var B,me=class extends T{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},pe),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let e=r??N(),t=P(i,0,i.byteLength,e);t.offset!==-1&&t.offset===n&&(this.valueBlock.value=[t.result])}}catch{}}return super.fromBER(e,t,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?I.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof B&&e.push(t.valueBlock.valueHexView);return i.BufferSourceConverter.concat(e)}};B=me,w.OctetString=B,me.NAME=_;var V=class extends y(oe){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n,r){if(!n)return t;let a=-1;if(this.isConstructed){if(a=oe.prototype.fromBER.call(this,e,t,n,r),a===-1)return a;for(let e of this.value){let t=e.constructor.NAME;if(t===g){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only`,-1}if(t!==v)return this.error=`BIT STRING may consists of BIT STRINGs only`,-1;let n=e.valueBlock;if(this.unusedBits>0&&n.unusedBits>0)return this.error=`Using of "unused bits" inside constructive BIT STRING allowed for least one only`,-1;this.unusedBits=n.unusedBits}return a}let o=i.BufferSourceConverter.toUint8Array(e);if(!c(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error=`Unused bits for BitString must be in range 0-7`,-1;if(!this.unusedBits){let e=s.subarray(1);try{if(e.byteLength){let t=r??N(),i=P(e,0,e.byteLength,t);i.offset!==-1&&i.offset===n-1&&(this.value=[i.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return oe.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){let e=new Uint8Array(1);return e[0]=0,e.buffer}let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};V.NAME=`BitStringValueBlock`;var he,ge=class extends T{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},V),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return I.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let n of t)e.push(n.toString(2).padStart(8,`0`));let n=e.join(``);return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};he=ge,w.BitString=he,ge.NAME=v;var H;function _e(e,t){let n=new Uint8Array([0]),r=new Uint8Array(e),i=new Uint8Array(t),o=r.slice(0),s=o.length-1,c=i.slice(0),l=c.length-1,u=0,d=l<s?s:l,f=0;for(let e=d;e>=0;e--,f++){switch(!0){case f<c.length:u=o[s-f]+c[l-f]+n[0];break;default:u=o[s-f]+n[0]}switch(n[0]=u/10,!0){case f>=o.length:o=a.utilConcatView(new Uint8Array([u%10]),o);break;default:o[s-f]=u%10}}return n[0]>0&&(o=a.utilConcatView(n,o)),o}function ve(e){if(e>=u.length)for(let t=u.length;t<=e;t++){let e=new Uint8Array([0]),n=u[t-1].slice(0);for(let t=n.length-1;t>=0;t--){let r=new Uint8Array([(n[t]<<1)+e[0]]);e[0]=r[0]/10,n[t]=r[0]%10}e[0]>0&&(n=a.utilConcatView(e,n)),u.push(n)}return u[e]}function U(e,t){let n=0,r=new Uint8Array(e),i=new Uint8Array(t),a=r.slice(0),o=a.length-1,s=i.slice(0),c=s.length-1,l,u=0;for(let e=c;e>=0;e--,u++)switch(l=a[o-u]-s[c-u]-n,!0){case l<0:n=1,a[o-u]=l+10;break;default:n=0,a[o-u]=l}if(n>0)for(let e=o-c+1;e>=0;e--,u++)if(l=a[o-u]-n,l<0)n=1,a[o-u]=l+10;else{n=0,a[o-u]=l;break}return a.slice()}var ye=class extends y(x){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=a.utilDecodeTC.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(a.utilEncodeTC(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,r=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):r!==0&&a.length<r&&(r-a.length>1&&(r=a.length+1),this.valueHexView=a.subarray(r-a.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case!!(t[0]&128):{let e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case t[0]===0&&!(t[1]&128):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,n){let r=super.fromBER(e,t,n);return r===-1||this.setValueHex(),r}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,r,i=this.valueHexView,a=``,o=!1;for(let o=i.byteLength-1;o>=0;o--){r=i[o];for(let i=0;i<8;i++){if((r&1)==1)switch(n){case e:t=U(ve(n),t),a=`-`;break;default:t=_e(t,ve(n))}n++,r>>=1}}for(let e=0;e<t.length;e++)t[e]&&(o=!0),o&&(a+=d.charAt(t[e]));return o===!1&&(a+=d.charAt(0)),a}};H=ye,ye.NAME=`IntegerValueBlock`,Object.defineProperty(H.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var be,xe=class extends T{constructor(e={}){super(e,ye),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return o(),BigInt(this.valueBlock.toString())}static fromBigInt(e){o();let t=BigInt(e),n=new l,r=t.toString(16).replace(/^-/,``),a=new Uint8Array(i.Convert.FromHex(r));if(t<0){let e=new Uint8Array(a.length+(a[0]&128?1:0));e[0]|=128;let r=BigInt(`0x${i.Convert.ToHex(e)}`)+t,o=i.BufferSourceConverter.toUint8Array(i.Convert.FromHex(r.toString(16)));o[0]|=128,n.write(o)}else a[0]&128&&n.write(new Uint8Array([0])),n.write(a);return new be({valueHex:n.final()})}convertToDER(){let e=new be({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new be({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};be=xe,w.Integer=be,xe.NAME=`INTEGER`;var W,Se=class extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};W=Se,w.Enumerated=W,Se.NAME=`ENUMERATED`;var Ce=class extends y(x){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=o[e]&127,this.blockLength++,o[e]&128);e++);let s=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)s[e]=this.valueHexView[e];return this.valueHexView=s,o[this.blockLength-1]&128?(this.error=`End of input reached before message was fully decoded`,-1):(this.valueHexView[0]===0&&this.warnings.push(`Needlessly long format of SID encoding`),this.blockLength<=8?this.valueDec=a.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push(`Too big SID for decoding, hex only`)),t+this.blockLength)}set valueBigInt(e){o();let t=BigInt(e).toString(2);for(;t.length%7;)t=`0`+t;let n=new Uint8Array(t.length/7);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*7,e*7+7),2)+(e+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=a.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,m;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n}toString(){let e=``;if(this.isHexOnly)e=i.Convert.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}}};Ce.NAME=`sidBlock`;var G=class extends x{constructor({value:e=``,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new Ce;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.value.length===0&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let r=this.value[n].toBER(e);if(r.byteLength===0)return this.error=this.value[n].error,m;t.push(r)}return s(t)}fromString(e){this.value=[];let t=0,n=0,r=``,i=!1;do if(n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1,i){let e=this.value[0],t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:this.value=[];return}let n=parseInt(r,10);if(isNaN(n))return;e.valueDec=n+t,i=!1}else{let e=new Ce;if(r>2**53-1)o(),e.valueBigInt=BigInt(r);else if(e.valueDec=parseInt(r,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,i=!0),this.value.push(e)}while(n!==-1)}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t?(r=`{${r}}`,this.value[n].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}return e}toJSON(){let 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}};G.NAME=`ObjectIdentifierValueBlock`;var we,Te=class extends T{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,G),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};we=Te,w.ObjectIdentifier=we,Te.NAME=`OBJECT IDENTIFIER`;var Ee=class extends y(b){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=o[e]&127,this.blockLength++,o[e]&128);e++);let s=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)s[e]=this.valueHexView[e];return this.valueHexView=s,o[this.blockLength-1]&128?(this.error=`End of input reached before message was fully decoded`,-1):(this.valueHexView[0]===0&&this.warnings.push(`Needlessly long format of SID encoding`),this.blockLength<=8?this.valueDec=a.utilFromBase(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);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=a.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,m;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n.buffer}toString(){let e=``;return e=this.isHexOnly?i.Convert.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Ee.NAME=`relativeSidBlock`;var De=class extends x{constructor({value:e=``,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new Ee;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e,t){let n=[];for(let t=0;t<this.value.length;t++){let r=this.value[t].toBER(e);if(r.byteLength===0)return this.error=this.value[t].error,m;n.push(r)}return s(n)}fromString(e){this.value=[];let t=0,n=0,r=``;do{n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1;let i=new Ee;if(i.valueDec=parseInt(r,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(r=`{${r}}`),e+=r}return e}toJSON(){let 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}};De.NAME=`RelativeObjectIdentifierValueBlock`;var Oe,ke=class extends T{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,De),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Oe=ke,w.RelativeObjectIdentifier=Oe,ke.NAME=`RelativeObjectIdentifier`;var Ae,je=class extends I{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Ae=je,w.Sequence=Ae,je.NAME=`SEQUENCE`;var Me,Ne=class extends I{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Me=Ne,w.Set=Me,Ne.NAME=`SET`;var Pe=class extends y(x){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=``}toJSON(){return{...super.toJSON(),value:this.value}}};Pe.NAME=`StringValueBlock`;var Fe=class extends Pe{};Fe.NAME=`SimpleStringValueBlock`;var K=class extends D{constructor({...e}={}){super(e,Fe)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,i.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);this.valueBlock.value=e}};K.NAME=`SIMPLE STRING`;var Ie=class extends K{fromBuffer(e){this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=i.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=i.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Ie.NAME=`Utf8StringValueBlock`;var Le,Re=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Le=Re,w.Utf8String=Le,Re.NAME=`UTF8String`;var ze=class extends K{fromBuffer(e){this.valueBlock.value=i.Convert.ToUtf16String(e),this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf16String(e))}};ze.NAME=`BmpStringValueBlock`;var Be,Ve=class extends ze{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Be=Ve,w.BmpString=Be,Ve.NAME=`BMPString`;var q=class extends K{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let e=0;e<n.length;e+=4)n[e]=n[e+3],n[e+1]=n[e+2],n[e+2]=0,n[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let r=0;r<t;r++){let t=a.utilToBase(e.charCodeAt(r),8),i=new Uint8Array(t);if(i.length>4)continue;let o=4-i.length;for(let e=i.length-1;e>=0;e--)n[r*4+e+o]=i[e]}this.valueBlock.value=e}};q.NAME=`UniversalStringValueBlock`;var He,Ue=class extends q{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};He=Ue,w.UniversalString=He,Ue.NAME=`UniversalString`;var We,Ge=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};We=Ge,w.NumericString=We,Ge.NAME=`NumericString`;var J,Ke=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};J=Ke,w.PrintableString=J,Ke.NAME=`PrintableString`;var qe,Je=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};qe=Je,w.TeletexString=qe,Je.NAME=`TeletexString`;var Ye,Xe=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Ye=Xe,w.VideotexString=Ye,Xe.NAME=`VideotexString`;var Ze,Qe=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Ze=Qe,w.IA5String=Ze,Qe.NAME=`IA5String`;var $e,et=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};$e=et,w.GraphicString=$e,et.NAME=`GraphicString`;var tt,nt=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};tt=nt,w.VisibleString=tt,nt.NAME=`VisibleString`;var rt,Y=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};rt=Y,w.GeneralString=rt,Y.NAME=`GeneralString`;var it,at=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};it=at,w.CharacterString=it,at.NAME=`CharacterString`;var ot,st=class extends nt{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let 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.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[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){let t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(t===null){this.error=`Wrong input string for conversion`;return}let n=parseInt(t[1],10);this.year=n>=50?1900+n:2e3+n,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e=`iso`){if(e===`iso`){let e=Array(7);return e[0]=a.padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=a.padNumber(this.month,2),e[2]=a.padNumber(this.day,2),e[3]=a.padNumber(this.hour,2),e[4]=a.padNumber(this.minute,2),e[5]=a.padNumber(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}}};ot=st,w.UTCTime=ot,st.NAME=`UTCTime`;var ct,lt=class extends st{constructor(e={}){super(e),this.millisecond??=0,this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,n=``,r=``,i=0,a,o=0,s=0;if(e[e.length-1]===`Z`)n=e.substring(0,e.length-1),t=!0;else{let t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw Error(`Wrong input string for conversion`);n=e}if(t){if(n.indexOf(`+`)!==-1||n.indexOf(`-`)!==-1)throw Error(`Wrong input string for conversion`)}else{let e=1,t=n.indexOf(`+`),r=``;if(t===-1&&(t=n.indexOf(`-`),e=-1),t!==-1){if(r=n.substring(t+1),n=n.substring(0,t),r.length!==2&&r.length!==4)throw Error(`Wrong input string for conversion`);let i=parseInt(r.substring(0,2),10);if(isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);if(o=e*i,r.length===4){if(i=parseInt(r.substring(2,4),10),isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);s=e*i}}}let c=n.indexOf(`.`);if(c===-1&&(c=n.indexOf(`,`)),c!==-1){let e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw Error(`Wrong input string for conversion`);i=e.valueOf(),r=n.substring(0,c)}else r=n;switch(!0){case r.length===8:if(a=/(\d{4})(\d{2})(\d{2})/gi,c!==-1)throw Error(`Wrong input string for conversion`);break;case r.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;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 r.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw Error(`Wrong input string for conversion`)}let l=a.exec(r);if(l===null)throw Error(`Wrong input string for conversion`);for(let e=1;e<l.length;e++)switch(e){case 1:this.year=parseInt(l[e],10);break;case 2:this.month=parseInt(l[e],10);break;case 3:this.day=parseInt(l[e],10);break;case 4:this.hour=parseInt(l[e],10)+o;break;case 5:this.minute=parseInt(l[e],10)+s;break;case 6:this.second=parseInt(l[e],10);break;default:throw Error(`Wrong input string for conversion`)}if(t===!1){let 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(e===`iso`){let e=[];return e.push(a.padNumber(this.year,4)),e.push(a.padNumber(this.month,2)),e.push(a.padNumber(this.day,2)),e.push(a.padNumber(this.hour,2)),e.push(a.padNumber(this.minute,2)),e.push(a.padNumber(this.second,2)),this.millisecond!==0&&(e.push(`.`),e.push(a.padNumber(this.millisecond,3))),e.push(`Z`),e.join(``)}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};ct=lt,w.GeneralizedTime=ct,lt.NAME=`GeneralizedTime`;var ut,dt=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};ut=dt,w.DATE=ut,dt.NAME=`DATE`;var ft,pt=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};ft=pt,w.TimeOfDay=ft,pt.NAME=`TimeOfDay`;var mt,ht=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};mt=ht,w.DateTime=mt,ht.NAME=`DateTime`;var gt,_t=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};gt=_t,w.Duration=gt,_t.NAME=`Duration`;var vt,yt=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};vt=yt,w.TIME=vt,yt.NAME=`TIME`;var bt=class{constructor({name:e=``,optional:t=!1}={}){this.name=e,this.optional=t}},xt=class extends bt{constructor({value:e=[],...t}={}){super(t),this.value=e}},St=class extends bt{constructor({value:e=new bt,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}},X=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=i.BufferSourceConverter.toUint8Array(e)}constructor({data:e=h}={}){this.dataView=i.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,n){let r=t+n;return this.dataView=i.BufferSourceConverter.toUint8Array(e).subarray(t,r),r}toBER(e){return this.dataView.slice().buffer}};function Tt(e,t,n){if(n instanceof xt){for(let r of n.value)if(Tt(e,t,r).verified)return{verified:!0,result:e};{let e={verified:!1,result:{error:`Wrong values for Choice type`}};return n.hasOwnProperty(f)&&(e.name=n.name),e}}if(n instanceof bt)return n.hasOwnProperty(f)&&(e[n.name]=t),{verified:!0,result:e};if(!(e instanceof Object))return{verified:!1,result:{error:`Wrong root object`}};if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 data`}};if(!(n instanceof Object)||!(`idBlock`in n)||!(`fromBER`in n.idBlock)||!(`toBER`in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:`Error encoding idBlock for ASN.1 schema`}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:`Error decoding idBlock for ASN.1 schema`}};if(n.idBlock.hasOwnProperty(`tagClass`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(`tagNumber`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(`isConstructed`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!(`isHexOnly`in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(n.idBlock.isHexOnly){if(!(p in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.valueHexView,i=t.idBlock.valueHexView;if(r.length!==i.length)return{verified:!1,result:e};for(let t=0;t<r.length;t++)if(r[t]!==i[1])return{verified:!1,result:e}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(e[n.name]=t)),n instanceof w.Constructed){let r=0,i={verified:!1,result:{error:`Unknown error`}},a=n.valueBlock.value.length;if(a>0&&n.valueBlock.value[0]instanceof St&&(a=t.valueBlock.value.length),a===0)return{verified:!0,result:e};if(t.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let t=!0;for(let e=0;e<n.valueBlock.value.length;e++)t&&=n.valueBlock.value[e].optional||!1;return t?{verified:!0,result:e}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),e.error=`Inconsistent object length`,{verified:!1,result:e})}for(let o=0;o<a;o++)if(o-r>=t.valueBlock.value.length){if(n.valueBlock.value[o].optional===!1){let t={verified:!1,result:e};return e.error=`Inconsistent length between ASN.1 data and schema`,n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}}else if(n.valueBlock.value[0]instanceof St){if(i=Tt(e,t.valueBlock.value[o],n.valueBlock.value[0].value),i.verified===!1)if(n.valueBlock.value[0].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),i;if(f in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let r={};r=`local`in n.valueBlock.value[0]&&n.valueBlock.value[0].local?t:e,r[n.valueBlock.value[0].name]===void 0&&(r[n.valueBlock.value[0].name]=[]),r[n.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(i=Tt(e,t.valueBlock.value[o-r],n.valueBlock.value[o]),i.verified===!1)if(n.valueBlock.value[o].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),i;if(i.verified===!1){let t={verified:!1,result:e};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}return{verified:!0,result:e}}if(n.primitiveSchema&&p in t.valueBlock){let r=ie(t.valueBlock.valueHexView);if(r.offset===-1){let t={verified:!1,result:r.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}return Tt(e,r.result,n.primitiveSchema)}return{verified:!0,result:e}}function Et(e,t){if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 schema type`}};let n=ie(i.BufferSourceConverter.toUint8Array(e));return n.offset===-1?{verified:!1,result:n.result}:Tt(n.result,n.result,t)}e.Any=bt,e.BaseBlock=T,e.BaseStringBlock=D,e.BitString=ge,e.BmpString=Ve,e.Boolean=z,e.CharacterString=at,e.Choice=xt,e.Constructed=I,e.DATE=dt,e.DEFAULT_MAX_CONTENT_LENGTH=M,e.DEFAULT_MAX_DEPTH=100,e.DEFAULT_MAX_NODES=j,e.DateTime=ht,e.Duration=_t,e.EndOfContent=le,e.Enumerated=Se,e.GeneralString=Y,e.GeneralizedTime=lt,e.GraphicString=et,e.HexBlock=y,e.IA5String=Qe,e.Integer=xe,e.Null=de,e.NumericString=Ge,e.ObjectIdentifier=Te,e.OctetString=me,e.Primitive=A,e.PrintableString=Ke,e.RawData=X,e.RelativeObjectIdentifier=ke,e.Repeated=St,e.Sequence=je,e.Set=Ne,e.TIME=yt,e.TeletexString=Je,e.TimeOfDay=pt,e.UTCTime=st,e.UniversalString=Ue,e.Utf8String=Re,e.ValueBlock=x,e.VideotexString=Xe,e.ViewWriter=l,e.VisibleString=nt,e.compareSchema=Tt,e.fromBER=F,e.verifySchema=Et})),Et=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isArrayBuffer=o,e.isSharedArrayBuffer=s,e.isArrayBufferLike=c,e.isArrayBufferView=l,e.isBufferSource=u,e.assertBufferSource=d,e.toUint8Array=f,e.toUint8ArrayCopy=p,e.toArrayBuffer=m,e.toArrayBufferLike=h,e.toView=g,e.toViewCopy=_;function t(e){return Object.prototype.toString.call(e)}function n(e){return e===DataView||e.prototype instanceof DataView}function r(e){return n(e)?1:e.BYTES_PER_ELEMENT??1}function i(e){if(ArrayBuffer.isView(e))return!0;if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.byteOffset==`number`&&typeof t.byteLength==`number`&&c(t.buffer)}function a(e){let t=f(e),n=new Uint8Array(t.byteLength);return n.set(t),n}function o(e){return t(e)===`[object ArrayBuffer]`}function s(e){return typeof SharedArrayBuffer<`u`&&t(e)===`[object SharedArrayBuffer]`}function c(e){return o(e)||s(e)}function l(e){return i(e)}function u(e){return c(e)||l(e)}function d(e){if(!u(e))throw TypeError(`Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView`)}function f(e){return d(e),c(e)?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function p(e){return a(e)}function m(e){if(d(e),o(e))return e;let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(f(e)),t}function h(e){return d(e),c(e)?e:e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:a(e).buffer}function g(e,t){if(d(e),ArrayBuffer.isView(e)&&e.constructor===t)return e;let i=f(e),a=r(t);if(i.byteOffset%a!==0||i.byteLength%a!==0)throw RangeError(`Cannot create ${t.name} over unaligned byte range`);return n(t)?new t(i.buffer,i.byteOffset,i.byteLength):new t(i.buffer,i.byteOffset,i.byteLength/a)}function _(e,t){return g(p(e),t)}})),Dt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.concatToUint8Array=n,e.concat=r;let t=Et();function n(e){let n=[],r=0;for(let i of e){let e=(0,t.toUint8Array)(i);n.push(e),r+=e.byteLength}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return i}function r(e,r,...i){let a,o;typeof r==`function`?(a=Array.from(e),o=r):(0,t.isBufferSource)(e)?a=[e,r,...i].filter(t.isBufferSource):(a=Array.from(e),r&&a.push(r),a.push(...i));let s=n(a);return o?(0,t.toView)(s,o):s.buffer}})),Ot=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.equal=n;let t=Et();function n(e,n,r={}){let i=(0,t.toUint8Array)(e),a=(0,t.toUint8Array)(n);if(!r.constantTime&&i.byteLength!==a.byteLength)return!1;let o=Math.max(i.byteLength,a.byteLength),s=i.byteLength^a.byteLength;for(let e=0;e<o;e++)s|=(i[e]??0)^(a[e]??0);return s===0}})),kt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.indexOf=u,e.lastIndexOf=d,e.includes=f,e.startsWith=p,e.endsWith=m,e.slice=h,e.tail=g,e.copy=_,e.compare=v;let t=Et();function n(e,t,n){let r=Number.isFinite(e)?Math.trunc(e):t;return r<=0?0:r>=n?n:r}function r(e,t){let r=n(t?.start,0,e),i=n(t?.end,e,e);return i>=r?[r,i]:[r,r]}function i(e,t){let r=n(t?.start,e,e),i=n(t?.end,0,e);return r>=i?[i,r]:[r,r]}function a(e,t,n){let r=Number.isFinite(e)?Math.trunc(e):t;return r<0?Math.max(n+r,0):r>n?n:r}function o(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function s(e){return new TextEncoder().encode(e)}function c(e,n){return typeof e==`string`?n?.encoding===`utf8`?s(e):o(e):(0,t.toUint8Array)(e)}function l(e,t,n){for(let r=0;r<t.byteLength;r++)if(e[n+r]!==t[r])return!1;return!0}function u(e,n,i){let a=(0,t.toUint8Array)(e),o=c(n,i),[s,u]=r(a.byteLength,i);if(o.byteLength===0)return s;let d=u-o.byteLength;if(d<s)return-1;for(let e=s;e<=d;e++)if(l(a,o,e))return e;return-1}function d(e,n,r){let a=(0,t.toUint8Array)(e),o=c(n,r),[s,u]=i(a.byteLength,r);if(o.byteLength===0)return u;let d=u-o.byteLength;if(d<s)return-1;for(let e=d;e>=s;e--)if(l(a,o,e))return e;return-1}function f(e,t,n){return u(e,t,n)!==-1}function p(e,n,r){let i=(0,t.toUint8Array)(e),a=c(n,r);return a.byteLength>i.byteLength?!1:l(i,a,0)}function m(e,n,r){let i=(0,t.toUint8Array)(e),a=c(n,r);return a.byteLength>i.byteLength?!1:l(i,a,i.byteLength-a.byteLength)}function h(e,n,r){let i=(0,t.toUint8Array)(e),o=a(n,0,i.byteLength),s=a(r,i.byteLength,i.byteLength);return s<=o?i.subarray(o,o):i.subarray(o,s)}function g(e,n){let r=(0,t.toUint8Array)(e),i=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return i>=r.byteLength?r:r.subarray(r.byteLength-i)}function _(e){return(0,t.toUint8ArrayCopy)(e)}function v(e,n){let r=(0,t.toUint8Array)(e),i=(0,t.toUint8Array)(n),a=Math.min(r.byteLength,i.byteLength);for(let e=0;e<a;e++){if(r[e]<i[e])return-1;if(r[e]>i[e])return 1}return r.byteLength<i.byteLength?-1:+(r.byteLength>i.byteLength)}})),At=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tail=e.startsWith=e.slice=e.lastIndexOf=e.indexOf=e.includes=e.endsWith=e.copy=e.compare=e.equal=e.concatToUint8Array=e.concat=e.toViewCopy=e.toView=e.toUint8ArrayCopy=e.toUint8Array=e.toArrayBufferLike=e.toArrayBuffer=e.isSharedArrayBuffer=e.isBufferSource=e.isArrayBufferView=e.isArrayBufferLike=e.isArrayBuffer=e.assertBufferSource=void 0;var t=Et();Object.defineProperty(e,"assertBufferSource",{enumerable:!0,get:function(){return t.assertBufferSource}}),Object.defineProperty(e,"isArrayBuffer",{enumerable:!0,get:function(){return t.isArrayBuffer}}),Object.defineProperty(e,"isArrayBufferLike",{enumerable:!0,get:function(){return t.isArrayBufferLike}}),Object.defineProperty(e,"isArrayBufferView",{enumerable:!0,get:function(){return t.isArrayBufferView}}),Object.defineProperty(e,"isBufferSource",{enumerable:!0,get:function(){return t.isBufferSource}}),Object.defineProperty(e,"isSharedArrayBuffer",{enumerable:!0,get:function(){return t.isSharedArrayBuffer}}),Object.defineProperty(e,"toArrayBuffer",{enumerable:!0,get:function(){return t.toArrayBuffer}}),Object.defineProperty(e,"toArrayBufferLike",{enumerable:!0,get:function(){return t.toArrayBufferLike}}),Object.defineProperty(e,"toUint8Array",{enumerable:!0,get:function(){return t.toUint8Array}}),Object.defineProperty(e,"toUint8ArrayCopy",{enumerable:!0,get:function(){return t.toUint8ArrayCopy}}),Object.defineProperty(e,"toView",{enumerable:!0,get:function(){return t.toView}}),Object.defineProperty(e,"toViewCopy",{enumerable:!0,get:function(){return t.toViewCopy}});var n=Dt();Object.defineProperty(e,"concat",{enumerable:!0,get:function(){return n.concat}}),Object.defineProperty(e,"concatToUint8Array",{enumerable:!0,get:function(){return n.concatToUint8Array}});var r=Ot();Object.defineProperty(e,"equal",{enumerable:!0,get:function(){return r.equal}});var i=kt();Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return i.compare}}),Object.defineProperty(e,"copy",{enumerable:!0,get:function(){return i.copy}}),Object.defineProperty(e,"endsWith",{enumerable:!0,get:function(){return i.endsWith}}),Object.defineProperty(e,"includes",{enumerable:!0,get:function(){return i.includes}}),Object.defineProperty(e,"indexOf",{enumerable:!0,get:function(){return i.indexOf}}),Object.defineProperty(e,"lastIndexOf",{enumerable:!0,get:function(){return i.lastIndexOf}}),Object.defineProperty(e,"slice",{enumerable:!0,get:function(){return i.slice}}),Object.defineProperty(e,"startsWith",{enumerable:!0,get:function(){return i.startsWith}}),Object.defineProperty(e,"tail",{enumerable:!0,get:function(){return i.tail}})})),jt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnPropTypes=e.AsnTypeTypes=void 0;var t;(function(e){e[e.Sequence=0]=`Sequence`,e[e.Set=1]=`Set`,e[e.Choice=2]=`Choice`})(t||(e.AsnTypeTypes=t={}));var n;(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`})(n||(e.AsnPropTypes=n={}))})),Mt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BitString=void 0;let n=(X(),t(q)).__importStar(Tt()),r=At();e.BitString=class{unusedBits=0;value=new ArrayBuffer(0);constructor(e,t=0){if(e)if(typeof e==`number`)this.fromNumber(e);else if((0,r.isBufferSource)(e))this.unusedBits=t,this.value=(0,r.toArrayBuffer)(e);else throw TypeError(`Unsupported type of 'params' argument for BitString`)}fromASN(e){if(!(e instanceof n.BitString))throw TypeError(`Argument 'asn' is not instance of ASN.1 BitString`);return this.unusedBits=e.valueBlock.unusedBits,this.value=(0,r.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new n.BitString({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new n.BitString({name:e})}toNumber(){let e=``,t=new Uint8Array(this.value);for(let n of t)e+=n.toString(2).padStart(8,`0`);return e=e.split(``).reverse().join(``),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,`0`)),parseInt(e,2)}fromNumber(e){let t=e.toString(2),n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;let r=new Uint8Array(n);t=t.padStart(n<<3,`0`).split(``).reverse().join(``);let i=0;for(;i<n;)r[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=r.buffer}}})),Nt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OctetString=void 0;let n=(X(),t(q)).__importStar(Tt()),r=At();e.OctetString=class{buffer;get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){this.buffer=typeof e==`number`?new ArrayBuffer(e):(0,r.isBufferSource)(e)?(0,r.toArrayBuffer)(e):Array.isArray(e)?new Uint8Array(e).buffer:new ArrayBuffer(0)}fromASN(e){if(!(e instanceof n.OctetString))throw TypeError(`Argument 'asn' is not instance of ASN.1 OctetString`);return this.buffer=(0,r.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new n.OctetString({valueHex:this.buffer})}toSchema(e){return new n.OctetString({name:e})}}})),Pt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(Mt(),e),n.__exportStar(Nt(),e)})),Ft=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnNullConverter=e.AsnGeneralizedTimeConverter=e.AsnUTCTimeConverter=e.AsnCharacterStringConverter=e.AsnGeneralStringConverter=e.AsnVisibleStringConverter=e.AsnGraphicStringConverter=e.AsnIA5StringConverter=e.AsnVideotexStringConverter=e.AsnTeletexStringConverter=e.AsnPrintableStringConverter=e.AsnNumericStringConverter=e.AsnUniversalStringConverter=e.AsnBmpStringConverter=e.AsnUtf8StringConverter=e.AsnConstructedOctetStringConverter=e.AsnOctetStringConverter=e.AsnBooleanConverter=e.AsnObjectIdentifierConverter=e.AsnBitStringConverter=e.AsnIntegerBigIntConverter=e.AsnIntegerArrayBufferConverter=e.AsnEnumeratedConverter=e.AsnIntegerConverter=e.AsnAnyConverter=void 0,e.defaultConverter=s;let n=(X(),t(q)).__importStar(Tt()),r=At(),i=jt(),a=Pt();e.AsnAnyConverter={fromASN:e=>e instanceof n.Null?null:(0,r.toArrayBuffer)(e.valueBeforeDecodeView),toASN:e=>{if(e===null)return new n.Null;let t=n.fromBER(e);if(t.result.error)throw Error(t.result.error);return t.result}},e.AsnIntegerConverter={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new n.Integer({value:+e})},e.AsnEnumeratedConverter={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new n.Enumerated({value:e})},e.AsnIntegerArrayBufferConverter={fromASN:e=>(0,r.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new n.Integer({valueHex:e})},e.AsnIntegerBigIntConverter={fromASN:e=>e.toBigInt(),toASN:e=>n.Integer.fromBigInt(e)},e.AsnBitStringConverter={fromASN:e=>(0,r.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new n.BitString({valueHex:e})},e.AsnObjectIdentifierConverter={fromASN:e=>e.valueBlock.toString(),toASN:e=>new n.ObjectIdentifier({value:e})},e.AsnBooleanConverter={fromASN:e=>e.valueBlock.value,toASN:e=>new n.Boolean({value:e})},e.AsnOctetStringConverter={fromASN:e=>(0,r.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new n.OctetString({valueHex:e})},e.AsnConstructedOctetStringConverter={fromASN:e=>new a.OctetString(e.getValue()),toASN:e=>e.toASN()};function o(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}e.AsnUtf8StringConverter=o(n.Utf8String),e.AsnBmpStringConverter=o(n.BmpString),e.AsnUniversalStringConverter=o(n.UniversalString),e.AsnNumericStringConverter=o(n.NumericString),e.AsnPrintableStringConverter=o(n.PrintableString),e.AsnTeletexStringConverter=o(n.TeletexString),e.AsnVideotexStringConverter=o(n.VideotexString),e.AsnIA5StringConverter=o(n.IA5String),e.AsnGraphicStringConverter=o(n.GraphicString),e.AsnVisibleStringConverter=o(n.VisibleString),e.AsnGeneralStringConverter=o(n.GeneralString),e.AsnCharacterStringConverter=o(n.CharacterString),e.AsnUTCTimeConverter={fromASN:e=>e.toDate(),toASN:e=>new n.UTCTime({valueDate:e})},e.AsnGeneralizedTimeConverter={fromASN:e=>e.toDate(),toASN:e=>new n.GeneralizedTime({valueDate:e})},e.AsnNullConverter={fromASN:()=>null,toASN:()=>new n.Null};function s(t){switch(t){case i.AsnPropTypes.Any:return e.AsnAnyConverter;case i.AsnPropTypes.BitString:return e.AsnBitStringConverter;case i.AsnPropTypes.BmpString:return e.AsnBmpStringConverter;case i.AsnPropTypes.Boolean:return e.AsnBooleanConverter;case i.AsnPropTypes.CharacterString:return e.AsnCharacterStringConverter;case i.AsnPropTypes.Enumerated:return e.AsnEnumeratedConverter;case i.AsnPropTypes.GeneralString:return e.AsnGeneralStringConverter;case i.AsnPropTypes.GeneralizedTime:return e.AsnGeneralizedTimeConverter;case i.AsnPropTypes.GraphicString:return e.AsnGraphicStringConverter;case i.AsnPropTypes.IA5String:return e.AsnIA5StringConverter;case i.AsnPropTypes.Integer:return e.AsnIntegerConverter;case i.AsnPropTypes.Null:return e.AsnNullConverter;case i.AsnPropTypes.NumericString:return e.AsnNumericStringConverter;case i.AsnPropTypes.ObjectIdentifier:return e.AsnObjectIdentifierConverter;case i.AsnPropTypes.OctetString:return e.AsnOctetStringConverter;case i.AsnPropTypes.PrintableString:return e.AsnPrintableStringConverter;case i.AsnPropTypes.TeletexString:return e.AsnTeletexStringConverter;case i.AsnPropTypes.UTCTime:return e.AsnUTCTimeConverter;case i.AsnPropTypes.UniversalString:return e.AsnUniversalStringConverter;case i.AsnPropTypes.Utf8String:return e.AsnUtf8StringConverter;case i.AsnPropTypes.VideotexString:return e.AsnVideotexStringConverter;case i.AsnPropTypes.VisibleString:return e.AsnVisibleStringConverter;default:return null}}})),It=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isConvertible=t,e.isTypeOfArray=n,e.isArrayEqual=r;function t(e){return typeof e==`function`&&e.prototype?e.prototype.toASN&&e.prototype.fromASN?!0:t(e.prototype):!!(e&&typeof e==`object`&&`toASN`in e&&`fromASN`in e)}function n(e){if(e){let t=Object.getPrototypeOf(e);return t?.prototype?.constructor===Array||n(t)}return!1}function r(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}})),Lt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSchemaStorage=void 0;let n=(X(),t(q)).__importStar(Tt()),r=jt(),i=It();e.AsnSchemaStorage=class{items=new WeakMap;has(e){return this.items.has(e)}get(e,t=!1){let n=this.items.get(e);if(!n)throw Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let t=this.get(e);t.schema||=this.create(e,!0)}createDefault(e){let t={type:r.AsnTypeTypes.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){let a=this.items.get(e)||this.createDefault(e),o=[];for(let e in a.items){let s=a.items[e],c=t?e:``,l;if(typeof s.type==`number`){let e=r.AsnPropTypes[s.type],t=n[e];if(!t)throw Error(`Cannot get ASN1 class by name '${e}'`);l=new t({name:c})}else(0,i.isConvertible)(s.type)?l=new s.type().toSchema(c):s.optional?this.get(s.type).type===r.AsnTypeTypes.Choice?l=new n.Any({name:c}):(l=this.create(s.type,!1),l.name=c):l=new n.Any({name:c});let u=!!s.optional||s.defaultValue!==void 0;if(s.repeated&&(l.name=``,l=new(s.repeated===`set`?n.Set:n.Sequence)({name:``,value:[new n.Repeated({name:c,value:l})]})),s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type==`number`||(0,i.isConvertible)(s.type)){let e=s.repeated?n.Constructed:n.Primitive;o.push(new e({name:c,optional:u,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);let e=!!s.repeated,t=e?l:this.get(s.type,!0).schema;t=`valueBlock`in t?t.valueBlock.value:t.value,o.push(new n.Constructed({name:e?``:c,optional:u,idBlock:{tagClass:3,tagNumber:s.context},value:t}))}else o.push(new n.Constructed({optional:u,idBlock:{tagClass:3,tagNumber:s.context},value:[l]}));else l.optional=u,o.push(l)}switch(a.type){case r.AsnTypeTypes.Sequence:return new n.Sequence({value:o,name:``});case r.AsnTypeTypes.Set:return new n.Set({value:o,name:``});case r.AsnTypeTypes.Choice:return new n.Choice({value:o,name:``});default:throw Error(`Unsupported ASN1 type in use`)}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){let t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}})),Rt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.schemaStorage=void 0,e.schemaStorage=new(Lt()).AsnSchemaStorage})),zt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnProp=e.AsnSequenceType=e.AsnSetType=e.AsnChoiceType=e.AsnType=void 0;let n=(X(),t(q)).__importStar(Ft()),r=jt(),i=Rt();e.AsnType=e=>t=>{let n;i.schemaStorage.has(t)?n=i.schemaStorage.get(t):(n=i.schemaStorage.createDefault(t),i.schemaStorage.set(t,n)),Object.assign(n,e)},e.AsnChoiceType=()=>(0,e.AsnType)({type:r.AsnTypeTypes.Choice}),e.AsnSetType=t=>(0,e.AsnType)({type:r.AsnTypeTypes.Set,...t}),e.AsnSequenceType=t=>(0,e.AsnType)({type:r.AsnTypeTypes.Sequence,...t}),e.AsnProp=e=>(t,r)=>{let a;i.schemaStorage.has(t.constructor)?a=i.schemaStorage.get(t.constructor):(a=i.schemaStorage.createDefault(t.constructor),i.schemaStorage.set(t.constructor,a));let o=Object.assign({},e);if(typeof o.type==`number`&&!o.converter){let i=n.defaultConverter(e.type);if(!i)throw Error(`Cannot get default converter for property '${r}' of ${t.constructor.name}`);o.converter=i}o.raw=e.raw,a.items[r]=o}})),Bt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSchemaValidationError=void 0,e.AsnSchemaValidationError=class extends Error{schemas=[]}})),Vt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),(X(),t(q)).__exportStar(Bt(),e)})),Ht=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnParser=void 0;let n=(X(),t(q)),r=n.__importStar(Tt()),i=At(),a=jt(),o=n.__importStar(Ft()),s=Vt(),c=It(),l=Rt();e.AsnParser=class{static parse(e,t,n){let a=r.fromBER((0,i.toArrayBuffer)(e),n?.berOptions);if(a.result.error)throw Error(a.result.error);return this.fromASN(a.result,t,n)}static fromASN(e,t,n){try{if((0,c.isConvertible)(t))return new t().fromASN(e);let r=l.schemaStorage.get(t);l.schemaStorage.cache(t);let i=r.schema,a=this.handleChoiceTypes(e,r,t,i,n);if(a?.result)return a.result;a?.targetSchema&&(i=a.targetSchema);let o=this.handleSequenceTypes(e,r,t,i),s=new t;return(0,c.isTypeOfArray)(t)?this.handleArrayTypes(e,r,t,n):(this.processSchemaItems(r,o,s,n),s)}catch(e){throw e instanceof s.AsnSchemaValidationError&&e.schemas.push(t.name),e}}static handleChoiceTypes(e,t,n,i,o){if(e.constructor===r.Constructed&&t.type===a.AsnTypeTypes.Choice&&e.idBlock.tagClass===3)for(let i in t.items){let s=t.items[i];if(s.context===e.idBlock.tagNumber&&s.implicit&&typeof s.type==`function`&&l.schemaStorage.has(s.type)){let t=l.schemaStorage.get(s.type);if(t&&t.type===a.AsnTypeTypes.Sequence){let t=new r.Sequence;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock){t.valueBlock.value=e.valueBlock.value;let r=this.fromASN(t,s.type,o),a=new n;return a[i]=r,{result:a}}}}}else if(e.constructor===r.Constructed&&t.type!==a.AsnTypeTypes.Choice){let n=new r.Constructed({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(let n in t.items)delete e[n];return{targetSchema:n}}return null}static handleSequenceTypes(e,t,n,i){if(t.type===a.AsnTypeTypes.Sequence){let t=r.compareSchema({},e,i);if(!t.verified)throw new s.AsnSchemaValidationError(`Data does not match to ${n.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}{let t=r.compareSchema({},e,i);if(!t.verified)throw new s.AsnSchemaValidationError(`Data does not match to ${n.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}}static processRepeatedField(e,t,n){let r=e.slice(t);if(r.length===1&&r[0].constructor.name===`Sequence`){let e=r[0];e.valueBlock&&e.valueBlock.value&&Array.isArray(e.valueBlock.value)&&(r=e.valueBlock.value)}if(typeof n.type==`number`){let e=o.defaultConverter(n.type);if(!e)throw Error(`No converter for ASN.1 type ${n.type}`);return r.filter(e=>e&&e.valueBlock).map(t=>{try{return e.fromASN(t)}catch{return}}).filter(e=>e!==void 0)}return r.filter(e=>e&&e.valueBlock).map(e=>{try{return this.fromASN(e,n.type)}catch{return}}).filter(e=>e!==void 0)}static processPrimitiveField(e,t){let n=o.defaultConverter(t.type);if(!n)throw Error(`No converter for ASN.1 type ${t.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type==`function`&&l.schemaStorage.has(e.type)&&l.schemaStorage.get(e.type).type===a.AsnTypeTypes.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(e){if(e instanceof s.AsnSchemaValidationError&&/Wrong values for Choice type/.test(e.message))return{processed:!1};throw e}}static handleArrayTypes(e,t,n,r){if(!(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let i=t.itemType;if(typeof i==`number`){let t=o.defaultConverter(i);if(!t)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,e=>t.fromASN(e))}return n.from(e.valueBlock.value,e=>this.fromASN(e,i,r))}static processSchemaItems(e,t,n,r){for(let i in e.items){let a=t.result[i];if(!a)continue;let o=e.items[i],s=o.type,l;l=typeof s==`number`||(0,c.isConvertible)(s)?this.processPrimitiveSchemaItem(a,o,s,r):this.processComplexSchemaItem(a,o,s,r),l&&typeof l==`object`&&`value`in l&&`raw`in l?(n[i]=l.value,n[`${i}Raw`]=l.raw):n[i]=l}}static processPrimitiveSchemaItem(e,t,n,r){let i=t.converter??((0,c.isConvertible)(n)?new n:null);if(!i)throw Error(`Converter is empty`);return t.repeated?this.processRepeatedPrimitiveItem(e,t,i,r):this.processSinglePrimitiveItem(e,t,n,i,r)}static processRepeatedPrimitiveItem(e,t,n,i){if(t.implicit){let a=new(t.repeated===`sequence`?r.Sequence:r.Set);a.valueBlock=e.valueBlock;let o=r.fromBER(a.toBER(!1),i?.berOptions);if(o.offset===-1)throw Error(`Cannot parse the child item. ${o.result.error}`);if(!(`value`in o.result.valueBlock&&Array.isArray(o.result.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let s=o.result.valueBlock.value;return Array.from(s,e=>n.fromASN(e))}return Array.from(e,e=>n.fromASN(e))}static processSinglePrimitiveItem(e,t,n,i,o){let s=e;if(t.implicit){let e;if((0,c.isConvertible)(n))e=new n().toSchema(``);else{let t=a.AsnPropTypes[n],i=r[t];if(!i)throw Error(`Cannot get '${t}' class from asn1js module`);e=new i}e.valueBlock=s.valueBlock,s=r.fromBER(e.toBER(!1),o?.berOptions).result}return i.fromASN(s)}static processComplexSchemaItem(e,t,n,r){if(t.repeated){if(!Array.isArray(e))throw Error(`Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.`);return Array.from(e,e=>this.fromASN(e,n,r))}{let i=this.handleImplicitTagging(e,t,n);if(this.isOptionalChoiceField(t))try{return this.fromASN(i,n,r)}catch(e){if(e instanceof s.AsnSchemaValidationError&&/Wrong values for Choice type/.test(e.message))return;throw e}{let a=this.fromASN(i,n,r);return t.raw?{value:a,raw:e.valueBeforeDecodeView}:a}}}static handleImplicitTagging(e,t,n){if(t.implicit&&typeof t.context==`number`){let t=l.schemaStorage.get(n);if(t.type===a.AsnTypeTypes.Sequence){let t=new r.Sequence;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}else if(t.type===a.AsnTypeTypes.Set){let t=new r.Set;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}}return e}}})),Ut=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSerializer=void 0;let n=(X(),t(q)),r=n.__importStar(Tt()),i=At(),a=n.__importStar(Ft()),o=jt(),s=It(),c=Rt();e.AsnSerializer=class e{static serialize(e){return e instanceof r.BaseBlock?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(t){if(t&&typeof t==`object`&&(0,s.isConvertible)(t))return t.toASN();if(!(t&&typeof t==`object`))throw TypeError(`Parameter 1 should be type of Object.`);let n=t.constructor,l=c.schemaStorage.get(n);c.schemaStorage.cache(n);let u=[];if(l.itemType){if(!Array.isArray(t))throw TypeError(`Parameter 1 should be type of Array.`);if(typeof l.itemType==`number`){let e=a.defaultConverter(l.itemType);if(!e)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);u=t.map(t=>e.toASN(t))}else u=t.map(e=>this.toAsnItem({type:l.itemType},`[]`,n,e))}else for(let a in l.items){let o=l.items[a],c=t[a];if(c===void 0||o.defaultValue===c||typeof o.defaultValue==`object`&&typeof c==`object`&&(0,s.isArrayEqual)(this.serialize(o.defaultValue),this.serialize(c)))continue;let d=e.toAsnItem(o,a,n,c);if(typeof o.context==`number`)if(o.implicit)if(!o.repeated&&(typeof o.type==`number`||(0,s.isConvertible)(o.type))){let e={};e.valueHex=d instanceof r.Null?(0,i.toArrayBuffer)(d.valueBeforeDecodeView):d.valueBlock.toBER(),u.push(new r.Primitive({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...e}))}else u.push(new r.Constructed({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:d.valueBlock.value}));else u.push(new r.Constructed({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[d]}));else o.repeated?u=u.concat(d):u.push(d)}let d;switch(l.type){case o.AsnTypeTypes.Sequence:d=new r.Sequence({value:u});break;case o.AsnTypeTypes.Set:d=new r.Set({value:u});break;case o.AsnTypeTypes.Choice:if(!u[0])throw Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);d=u[0]}return d}static toAsnItem(e,t,n,i){let a;if(typeof e.type==`number`){let s=e.converter;if(!s)throw Error(`Property '${t}' doesn't have converter for type ${o.AsnPropTypes[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(i,e=>s.toASN(e));a=new(e.repeated===`sequence`?r.Sequence:r.Set)({value:t})}else a=s.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(i,e=>this.toASN(e));a=new(e.repeated===`sequence`?r.Sequence:r.Set)({value:t})}else a=this.toASN(i);return a}}})),Wt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnArray=void 0,e.AsnArray=class extends Array{constructor(e=[]){if(typeof e==`number`)super(e);else{super();for(let t of e)this.push(t)}}}})),Gt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnConvert=void 0;let n=(X(),t(q)).__importStar(Tt()),r=At(),i=Ht(),a=Ut();e.AsnConvert=class e{static serialize(e){return a.AsnSerializer.serialize(e)}static parse(e,t,n){return i.AsnParser.parse(e,t,n)}static toString(t,i){let a=(0,r.isBufferSource)(t)?(0,r.toArrayBuffer)(t):e.serialize(t),o=n.fromBER(a,i?.berOptions);if(o.offset===-1)throw Error(`Cannot decode ASN.1 data. ${o.result.error}`);return o.result.toString()}}})),Z=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSerializer=e.AsnParser=e.AsnPropTypes=e.AsnTypeTypes=e.AsnSetType=e.AsnSequenceType=e.AsnChoiceType=e.AsnType=e.AsnProp=void 0;let n=(X(),t(q));n.__exportStar(Ft(),e),n.__exportStar(Pt(),e);var r=zt();Object.defineProperty(e,"AsnProp",{enumerable:!0,get:function(){return r.AsnProp}}),Object.defineProperty(e,"AsnType",{enumerable:!0,get:function(){return r.AsnType}}),Object.defineProperty(e,"AsnChoiceType",{enumerable:!0,get:function(){return r.AsnChoiceType}}),Object.defineProperty(e,"AsnSequenceType",{enumerable:!0,get:function(){return r.AsnSequenceType}}),Object.defineProperty(e,"AsnSetType",{enumerable:!0,get:function(){return r.AsnSetType}});var i=jt();Object.defineProperty(e,"AsnTypeTypes",{enumerable:!0,get:function(){return i.AsnTypeTypes}}),Object.defineProperty(e,"AsnPropTypes",{enumerable:!0,get:function(){return i.AsnPropTypes}});var a=Ht();Object.defineProperty(e,"AsnParser",{enumerable:!0,get:function(){return a.AsnParser}});var o=Ut();Object.defineProperty(e,"AsnSerializer",{enumerable:!0,get:function(){return o.AsnSerializer}}),n.__exportStar(Vt(),e),n.__exportStar(Wt(),e),n.__exportStar(Gt(),e)})),Kt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.binary=void 0,e.encode=n,e.decode=r,e.is=i;let t=At();function n(e){let n=(0,t.toUint8Array)(e),r=``;for(let e of n)r+=String.fromCharCode(e);return r}function r(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function i(e){return typeof e==`string`}e.binary={encode:n,decode:r,is:i}})),qt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hex=e.formats=void 0,e.normalize=m,e.is=h,e.encode=g,e.decode=_,e.parse=v,e.format=y;let t=At(),n=/^[0-9a-f]$/i,r=[` `,` `,`
83
+ `)}`:`${t} :`}};ce=le,w.Constructed=ce,le.NAME=`CONSTRUCTED`;var ue=class extends x{fromBER(e,t,n){return t}toBER(e){return m}};ue.override=`EndOfContentValueBlock`;var de,fe=class extends T{constructor(e={}){super(e,ue),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};de=fe,w.EndOfContent=de,fe.NAME=g;var pe,me=class extends T{constructor(e={}){super(e,x),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push(`Non-zero length of value block for Null type`),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let e=new Uint8Array(n);e[0]=5,e[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};pe=me,w.Null=pe,me.NAME=`NULL`;var he=class extends y(x){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),this.valueHexView=t.valueHex?i.BufferSourceConverter.toUint8Array(t.valueHex):new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);return c(this,r,t,n)?(this.valueHexView=r.subarray(t,t+n),n>1&&this.warnings.push(`Boolean value encoded in more then 1 octet`),this.isHexOnly=!0,a.utilDecodeTC.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};he.NAME=`BooleanValueBlock`;var F,ge=class extends T{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,he),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};F=ge,w.Boolean=F,ge.NAME=`BOOLEAN`;var _e=class extends y(se){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=se.prototype.fromBER.call(this,e,t,n,r),i===-1)return i;for(let e=0;e<this.value.length;e++){let t=this.value[e].constructor.NAME;if(t===g){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only`,-1}if(t!==_)return this.error=`OCTET STRING may consists of OCTET STRINGs only`,-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?se.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};_e.NAME=`OctetStringValueBlock`;var I,ve=class extends T{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},_e),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let e=r??M(),t=N(i,0,i.byteLength,e);t.offset!==-1&&t.offset===n&&(this.valueBlock.value=[t.result])}}catch{}}return super.fromBER(e,t,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?le.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof I&&e.push(t.valueBlock.valueHexView);return i.BufferSourceConverter.concat(e)}};I=ve,w.OctetString=I,ve.NAME=_;var L=class extends y(se){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n,r){if(!n)return t;let a=-1;if(this.isConstructed){if(a=se.prototype.fromBER.call(this,e,t,n,r),a===-1)return a;for(let e of this.value){let t=e.constructor.NAME;if(t===g){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only`,-1}if(t!==v)return this.error=`BIT STRING may consists of BIT STRINGs only`,-1;let n=e.valueBlock;if(this.unusedBits>0&&n.unusedBits>0)return this.error=`Using of "unused bits" inside constructive BIT STRING allowed for least one only`,-1;this.unusedBits=n.unusedBits}return a}let o=i.BufferSourceConverter.toUint8Array(e);if(!c(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error=`Unused bits for BitString must be in range 0-7`,-1;if(!this.unusedBits){let e=s.subarray(1);try{if(e.byteLength){let t=r??M(),i=N(e,0,e.byteLength,t);i.offset!==-1&&i.offset===n-1&&(this.value=[i.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return se.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){let e=new Uint8Array(1);return e[0]=0,e.buffer}let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};L.NAME=`BitStringValueBlock`;var ye,R=class extends T{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},L),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return le.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let n of t)e.push(n.toString(2).padStart(8,`0`));let n=e.join(``);return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};ye=R,w.BitString=ye,R.NAME=v;var be;function xe(e,t){let n=new Uint8Array([0]),r=new Uint8Array(e),i=new Uint8Array(t),o=r.slice(0),s=o.length-1,c=i.slice(0),l=c.length-1,u=0,d=l<s?s:l,f=0;for(let e=d;e>=0;e--,f++){switch(!0){case f<c.length:u=o[s-f]+c[l-f]+n[0];break;default:u=o[s-f]+n[0]}switch(n[0]=u/10,!0){case f>=o.length:o=a.utilConcatView(new Uint8Array([u%10]),o);break;default:o[s-f]=u%10}}return n[0]>0&&(o=a.utilConcatView(n,o)),o}function z(e){if(e>=u.length)for(let t=u.length;t<=e;t++){let e=new Uint8Array([0]),n=u[t-1].slice(0);for(let t=n.length-1;t>=0;t--){let r=new Uint8Array([(n[t]<<1)+e[0]]);e[0]=r[0]/10,n[t]=r[0]%10}e[0]>0&&(n=a.utilConcatView(e,n)),u.push(n)}return u[e]}function Se(e,t){let n=0,r=new Uint8Array(e),i=new Uint8Array(t),a=r.slice(0),o=a.length-1,s=i.slice(0),c=s.length-1,l,u=0;for(let e=c;e>=0;e--,u++)switch(l=a[o-u]-s[c-u]-n,!0){case l<0:n=1,a[o-u]=l+10;break;default:n=0,a[o-u]=l}if(n>0)for(let e=o-c+1;e>=0;e--,u++)if(l=a[o-u]-n,l<0)n=1,a[o-u]=l+10;else{n=0,a[o-u]=l;break}return a.slice()}var Ce=class extends y(x){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=a.utilDecodeTC.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(a.utilEncodeTC(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,r=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):r!==0&&a.length<r&&(r-a.length>1&&(r=a.length+1),this.valueHexView=a.subarray(r-a.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case!!(t[0]&128):{let e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case t[0]===0&&!(t[1]&128):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,n){let r=super.fromBER(e,t,n);return r===-1||this.setValueHex(),r}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,r,i=this.valueHexView,a=``,o=!1;for(let o=i.byteLength-1;o>=0;o--){r=i[o];for(let i=0;i<8;i++){if((r&1)==1)switch(n){case e:t=Se(z(n),t),a=`-`;break;default:t=xe(t,z(n))}n++,r>>=1}}for(let e=0;e<t.length;e++)t[e]&&(o=!0),o&&(a+=d.charAt(t[e]));return o===!1&&(a+=d.charAt(0)),a}};be=Ce,Ce.NAME=`IntegerValueBlock`,Object.defineProperty(be.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var B,we=class extends T{constructor(e={}){super(e,Ce),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return o(),BigInt(this.valueBlock.toString())}static fromBigInt(e){o();let t=BigInt(e),n=new l,r=t.toString(16).replace(/^-/,``),a=new Uint8Array(i.Convert.FromHex(r));if(t<0){let e=new Uint8Array(a.length+(a[0]&128?1:0));e[0]|=128;let r=BigInt(`0x${i.Convert.ToHex(e)}`)+t,o=i.BufferSourceConverter.toUint8Array(i.Convert.FromHex(r.toString(16)));o[0]|=128,n.write(o)}else a[0]&128&&n.write(new Uint8Array([0])),n.write(a);return new B({valueHex:n.final()})}convertToDER(){let e=new B({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new B({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};B=we,w.Integer=B,we.NAME=`INTEGER`;var Te,Ee=class extends we{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Te=Ee,w.Enumerated=Te,Ee.NAME=`ENUMERATED`;var V=class extends y(x){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=o[e]&127,this.blockLength++,o[e]&128);e++);let s=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)s[e]=this.valueHexView[e];return this.valueHexView=s,o[this.blockLength-1]&128?(this.error=`End of input reached before message was fully decoded`,-1):(this.valueHexView[0]===0&&this.warnings.push(`Needlessly long format of SID encoding`),this.blockLength<=8?this.valueDec=a.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push(`Too big SID for decoding, hex only`)),t+this.blockLength)}set valueBigInt(e){o();let t=BigInt(e).toString(2);for(;t.length%7;)t=`0`+t;let n=new Uint8Array(t.length/7);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*7,e*7+7),2)+(e+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=a.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,m;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n}toString(){let e=``;if(this.isHexOnly)e=i.Convert.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}}};V.NAME=`sidBlock`;var De=class extends x{constructor({value:e=``,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new V;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.value.length===0&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let r=this.value[n].toBER(e);if(r.byteLength===0)return this.error=this.value[n].error,m;t.push(r)}return s(t)}fromString(e){this.value=[];let t=0,n=0,r=``,i=!1;do if(n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1,i){let e=this.value[0],t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:this.value=[];return}let n=parseInt(r,10);if(isNaN(n))return;e.valueDec=n+t,i=!1}else{let e=new V;if(r>2**53-1)o(),e.valueBigInt=BigInt(r);else if(e.valueDec=parseInt(r,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,i=!0),this.value.push(e)}while(n!==-1)}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t?(r=`{${r}}`,this.value[n].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}return e}toJSON(){let 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}};De.NAME=`ObjectIdentifierValueBlock`;var Oe,H=class extends T{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,De),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Oe=H,w.ObjectIdentifier=Oe,H.NAME=`OBJECT IDENTIFIER`;var ke=class extends y(b){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=o[e]&127,this.blockLength++,o[e]&128);e++);let s=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)s[e]=this.valueHexView[e];return this.valueHexView=s,o[this.blockLength-1]&128?(this.error=`End of input reached before message was fully decoded`,-1):(this.valueHexView[0]===0&&this.warnings.push(`Needlessly long format of SID encoding`),this.blockLength<=8?this.valueDec=a.utilFromBase(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);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=a.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,m;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n.buffer}toString(){let e=``;return e=this.isHexOnly?i.Convert.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};ke.NAME=`relativeSidBlock`;var Ae=class extends x{constructor({value:e=``,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new ke;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e,t){let n=[];for(let t=0;t<this.value.length;t++){let r=this.value[t].toBER(e);if(r.byteLength===0)return this.error=this.value[t].error,m;n.push(r)}return s(n)}fromString(e){this.value=[];let t=0,n=0,r=``;do{n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1;let i=new ke;if(i.valueDec=parseInt(r,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(r=`{${r}}`),e+=r}return e}toJSON(){let 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}};Ae.NAME=`RelativeObjectIdentifierValueBlock`;var je,Me=class extends T{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Ae),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};je=Me,w.RelativeObjectIdentifier=je,Me.NAME=`RelativeObjectIdentifier`;var Ne,Pe=class extends le{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Ne=Pe,w.Sequence=Ne,Pe.NAME=`SEQUENCE`;var Fe,Ie=class extends le{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Fe=Ie,w.Set=Fe,Ie.NAME=`SET`;var Le=class extends y(x){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=``}toJSON(){return{...super.toJSON(),value:this.value}}};Le.NAME=`StringValueBlock`;var Re=class extends Le{};Re.NAME=`SimpleStringValueBlock`;var U=class extends E{constructor({...e}={}){super(e,Re)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,i.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);this.valueBlock.value=e}};U.NAME=`SIMPLE STRING`;var ze=class extends U{fromBuffer(e){this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=i.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=i.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ze.NAME=`Utf8StringValueBlock`;var W,G=class extends ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};W=G,w.Utf8String=W,G.NAME=`UTF8String`;var Be=class extends U{fromBuffer(e){this.valueBlock.value=i.Convert.ToUtf16String(e),this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf16String(e))}};Be.NAME=`BmpStringValueBlock`;var Ve,He=class extends Be{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Ve=He,w.BmpString=Ve,He.NAME=`BMPString`;var Ue=class extends U{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let e=0;e<n.length;e+=4)n[e]=n[e+3],n[e+1]=n[e+2],n[e+2]=0,n[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let r=0;r<t;r++){let t=a.utilToBase(e.charCodeAt(r),8),i=new Uint8Array(t);if(i.length>4)continue;let o=4-i.length;for(let e=i.length-1;e>=0;e--)n[r*4+e+o]=i[e]}this.valueBlock.value=e}};Ue.NAME=`UniversalStringValueBlock`;var We,Ge=class extends Ue{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};We=Ge,w.UniversalString=We,Ge.NAME=`UniversalString`;var Ke,qe=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Ke=qe,w.NumericString=Ke,qe.NAME=`NumericString`;var K,Xe=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};K=Xe,w.PrintableString=K,Xe.NAME=`PrintableString`;var Ze,Qe=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Ze=Qe,w.TeletexString=Ze,Qe.NAME=`TeletexString`;var $e,et=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};$e=et,w.VideotexString=$e,et.NAME=`VideotexString`;var q,tt=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};q=tt,w.IA5String=q,tt.NAME=`IA5String`;var nt,rt=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};nt=rt,w.GraphicString=nt,rt.NAME=`GraphicString`;var it,at=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};it=at,w.VisibleString=it,at.NAME=`VisibleString`;var ot,st=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};ot=st,w.GeneralString=ot,st.NAME=`GeneralString`;var ct,lt=class extends U{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};ct=lt,w.CharacterString=ct,lt.NAME=`CharacterString`;var ut,dt=class extends at{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let 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.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[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){let t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(t===null){this.error=`Wrong input string for conversion`;return}let n=parseInt(t[1],10);this.year=n>=50?1900+n:2e3+n,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e=`iso`){if(e===`iso`){let e=Array(7);return e[0]=a.padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=a.padNumber(this.month,2),e[2]=a.padNumber(this.day,2),e[3]=a.padNumber(this.hour,2),e[4]=a.padNumber(this.minute,2),e[5]=a.padNumber(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}}};ut=dt,w.UTCTime=ut,dt.NAME=`UTCTime`;var ft,pt=class extends dt{constructor(e={}){super(e),this.millisecond??=0,this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,n=``,r=``,i=0,a,o=0,s=0;if(e[e.length-1]===`Z`)n=e.substring(0,e.length-1),t=!0;else{let t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw Error(`Wrong input string for conversion`);n=e}if(t){if(n.indexOf(`+`)!==-1||n.indexOf(`-`)!==-1)throw Error(`Wrong input string for conversion`)}else{let e=1,t=n.indexOf(`+`),r=``;if(t===-1&&(t=n.indexOf(`-`),e=-1),t!==-1){if(r=n.substring(t+1),n=n.substring(0,t),r.length!==2&&r.length!==4)throw Error(`Wrong input string for conversion`);let i=parseInt(r.substring(0,2),10);if(isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);if(o=e*i,r.length===4){if(i=parseInt(r.substring(2,4),10),isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);s=e*i}}}let c=n.indexOf(`.`);if(c===-1&&(c=n.indexOf(`,`)),c!==-1){let e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw Error(`Wrong input string for conversion`);i=e.valueOf(),r=n.substring(0,c)}else r=n;switch(!0){case r.length===8:if(a=/(\d{4})(\d{2})(\d{2})/gi,c!==-1)throw Error(`Wrong input string for conversion`);break;case r.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;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 r.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw Error(`Wrong input string for conversion`)}let l=a.exec(r);if(l===null)throw Error(`Wrong input string for conversion`);for(let e=1;e<l.length;e++)switch(e){case 1:this.year=parseInt(l[e],10);break;case 2:this.month=parseInt(l[e],10);break;case 3:this.day=parseInt(l[e],10);break;case 4:this.hour=parseInt(l[e],10)+o;break;case 5:this.minute=parseInt(l[e],10)+s;break;case 6:this.second=parseInt(l[e],10);break;default:throw Error(`Wrong input string for conversion`)}if(t===!1){let 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(e===`iso`){let e=[];return e.push(a.padNumber(this.year,4)),e.push(a.padNumber(this.month,2)),e.push(a.padNumber(this.day,2)),e.push(a.padNumber(this.hour,2)),e.push(a.padNumber(this.minute,2)),e.push(a.padNumber(this.second,2)),this.millisecond!==0&&(e.push(`.`),e.push(a.padNumber(this.millisecond,3))),e.push(`Z`),e.join(``)}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};ft=pt,w.GeneralizedTime=ft,pt.NAME=`GeneralizedTime`;var mt,ht=class extends G{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};mt=ht,w.DATE=mt,ht.NAME=`DATE`;var J,gt=class extends G{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};J=gt,w.TimeOfDay=J,gt.NAME=`TimeOfDay`;var _t,vt=class extends G{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};_t=vt,w.DateTime=_t,vt.NAME=`DateTime`;var yt,bt=class extends G{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};yt=bt,w.Duration=yt,bt.NAME=`Duration`;var xt,St=class extends G{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};xt=St,w.TIME=xt,St.NAME=`TIME`;var Ct=class{constructor({name:e=``,optional:t=!1}={}){this.name=e,this.optional=t}},wt=class extends Ct{constructor({value:e=[],...t}={}){super(t),this.value=e}},Tt=class extends Ct{constructor({value:e=new Ct,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}},Y=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=i.BufferSourceConverter.toUint8Array(e)}constructor({data:e=h}={}){this.dataView=i.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,n){let r=t+n;return this.dataView=i.BufferSourceConverter.toUint8Array(e).subarray(t,r),r}toBER(e){return this.dataView.slice().buffer}};function Et(e,t,n){if(n instanceof wt){for(let r of n.value)if(Et(e,t,r).verified)return{verified:!0,result:e};{let e={verified:!1,result:{error:`Wrong values for Choice type`}};return n.hasOwnProperty(f)&&(e.name=n.name),e}}if(n instanceof Ct)return n.hasOwnProperty(f)&&(e[n.name]=t),{verified:!0,result:e};if(!(e instanceof Object))return{verified:!1,result:{error:`Wrong root object`}};if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 data`}};if(!(n instanceof Object)||!(`idBlock`in n)||!(`fromBER`in n.idBlock)||!(`toBER`in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:`Error encoding idBlock for ASN.1 schema`}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:`Error decoding idBlock for ASN.1 schema`}};if(n.idBlock.hasOwnProperty(`tagClass`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(`tagNumber`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(`isConstructed`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!(`isHexOnly`in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(n.idBlock.isHexOnly){if(!(p in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.valueHexView,i=t.idBlock.valueHexView;if(r.length!==i.length)return{verified:!1,result:e};for(let t=0;t<r.length;t++)if(r[t]!==i[1])return{verified:!1,result:e}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(e[n.name]=t)),n instanceof w.Constructed){let r=0,i={verified:!1,result:{error:`Unknown error`}},a=n.valueBlock.value.length;if(a>0&&n.valueBlock.value[0]instanceof Tt&&(a=t.valueBlock.value.length),a===0)return{verified:!0,result:e};if(t.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let t=!0;for(let e=0;e<n.valueBlock.value.length;e++)t&&=n.valueBlock.value[e].optional||!1;return t?{verified:!0,result:e}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),e.error=`Inconsistent object length`,{verified:!1,result:e})}for(let o=0;o<a;o++)if(o-r>=t.valueBlock.value.length){if(n.valueBlock.value[o].optional===!1){let t={verified:!1,result:e};return e.error=`Inconsistent length between ASN.1 data and schema`,n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}}else if(n.valueBlock.value[0]instanceof Tt){if(i=Et(e,t.valueBlock.value[o],n.valueBlock.value[0].value),i.verified===!1)if(n.valueBlock.value[0].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),i;if(f in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let r={};r=`local`in n.valueBlock.value[0]&&n.valueBlock.value[0].local?t:e,r[n.valueBlock.value[0].name]===void 0&&(r[n.valueBlock.value[0].name]=[]),r[n.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(i=Et(e,t.valueBlock.value[o-r],n.valueBlock.value[o]),i.verified===!1)if(n.valueBlock.value[o].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),i;if(i.verified===!1){let t={verified:!1,result:e};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}return{verified:!0,result:e}}if(n.primitiveSchema&&p in t.valueBlock){let r=ae(t.valueBlock.valueHexView);if(r.offset===-1){let t={verified:!1,result:r.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}return Et(e,r.result,n.primitiveSchema)}return{verified:!0,result:e}}function Dt(e,t){if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 schema type`}};let n=ae(i.BufferSourceConverter.toUint8Array(e));return n.offset===-1?{verified:!1,result:n.result}:Et(n.result,n.result,t)}e.Any=Ct,e.BaseBlock=T,e.BaseStringBlock=E,e.BitString=R,e.BmpString=He,e.Boolean=ge,e.CharacterString=lt,e.Choice=wt,e.Constructed=le,e.DATE=ht,e.DEFAULT_MAX_CONTENT_LENGTH=j,e.DEFAULT_MAX_DEPTH=100,e.DEFAULT_MAX_NODES=A,e.DateTime=vt,e.Duration=bt,e.EndOfContent=fe,e.Enumerated=Ee,e.GeneralString=st,e.GeneralizedTime=pt,e.GraphicString=rt,e.HexBlock=y,e.IA5String=tt,e.Integer=we,e.Null=me,e.NumericString=qe,e.ObjectIdentifier=H,e.OctetString=ve,e.Primitive=k,e.PrintableString=Xe,e.RawData=Y,e.RelativeObjectIdentifier=Me,e.Repeated=Tt,e.Sequence=Pe,e.Set=Ie,e.TIME=St,e.TeletexString=Qe,e.TimeOfDay=gt,e.UTCTime=dt,e.UniversalString=Ge,e.Utf8String=G,e.ValueBlock=x,e.VideotexString=et,e.ViewWriter=l,e.VisibleString=at,e.compareSchema=Et,e.fromBER=P,e.verifySchema=Dt})),Ze=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isArrayBuffer=o,e.isSharedArrayBuffer=s,e.isArrayBufferLike=c,e.isArrayBufferView=l,e.isBufferSource=u,e.assertBufferSource=d,e.toUint8Array=f,e.toUint8ArrayCopy=p,e.toArrayBuffer=m,e.toArrayBufferLike=h,e.toView=g,e.toViewCopy=_;function t(e){return Object.prototype.toString.call(e)}function n(e){return e===DataView||e.prototype instanceof DataView}function r(e){return n(e)?1:e.BYTES_PER_ELEMENT??1}function i(e){if(ArrayBuffer.isView(e))return!0;if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.byteOffset==`number`&&typeof t.byteLength==`number`&&c(t.buffer)}function a(e){let t=f(e),n=new Uint8Array(t.byteLength);return n.set(t),n}function o(e){return t(e)===`[object ArrayBuffer]`}function s(e){return typeof SharedArrayBuffer<`u`&&t(e)===`[object SharedArrayBuffer]`}function c(e){return o(e)||s(e)}function l(e){return i(e)}function u(e){return c(e)||l(e)}function d(e){if(!u(e))throw TypeError(`Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView`)}function f(e){return d(e),c(e)?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function p(e){return a(e)}function m(e){if(d(e),o(e))return e;let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(f(e)),t}function h(e){return d(e),c(e)?e:e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:a(e).buffer}function g(e,t){if(d(e),ArrayBuffer.isView(e)&&e.constructor===t)return e;let i=f(e),a=r(t);if(i.byteOffset%a!==0||i.byteLength%a!==0)throw RangeError(`Cannot create ${t.name} over unaligned byte range`);return n(t)?new t(i.buffer,i.byteOffset,i.byteLength):new t(i.buffer,i.byteOffset,i.byteLength/a)}function _(e,t){return g(p(e),t)}})),Qe=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.concatToUint8Array=n,e.concat=r;let t=Ze();function n(e){let n=[],r=0;for(let i of e){let e=(0,t.toUint8Array)(i);n.push(e),r+=e.byteLength}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return i}function r(e,r,...i){let a,o;typeof r==`function`?(a=Array.from(e),o=r):(0,t.isBufferSource)(e)?a=[e,r,...i].filter(t.isBufferSource):(a=Array.from(e),r&&a.push(r),a.push(...i));let s=n(a);return o?(0,t.toView)(s,o):s.buffer}})),$e=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.equal=n;let t=Ze();function n(e,n,r={}){let i=(0,t.toUint8Array)(e),a=(0,t.toUint8Array)(n);if(!r.constantTime&&i.byteLength!==a.byteLength)return!1;let o=Math.max(i.byteLength,a.byteLength),s=i.byteLength^a.byteLength;for(let e=0;e<o;e++)s|=(i[e]??0)^(a[e]??0);return s===0}})),et=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.indexOf=u,e.lastIndexOf=d,e.includes=f,e.startsWith=p,e.endsWith=m,e.slice=h,e.tail=g,e.copy=_,e.compare=v;let t=Ze();function n(e,t,n){let r=Number.isFinite(e)?Math.trunc(e):t;return r<=0?0:r>=n?n:r}function r(e,t){let r=n(t?.start,0,e),i=n(t?.end,e,e);return i>=r?[r,i]:[r,r]}function i(e,t){let r=n(t?.start,e,e),i=n(t?.end,0,e);return r>=i?[i,r]:[r,r]}function a(e,t,n){let r=Number.isFinite(e)?Math.trunc(e):t;return r<0?Math.max(n+r,0):r>n?n:r}function o(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function s(e){return new TextEncoder().encode(e)}function c(e,n){return typeof e==`string`?n?.encoding===`utf8`?s(e):o(e):(0,t.toUint8Array)(e)}function l(e,t,n){for(let r=0;r<t.byteLength;r++)if(e[n+r]!==t[r])return!1;return!0}function u(e,n,i){let a=(0,t.toUint8Array)(e),o=c(n,i),[s,u]=r(a.byteLength,i);if(o.byteLength===0)return s;let d=u-o.byteLength;if(d<s)return-1;for(let e=s;e<=d;e++)if(l(a,o,e))return e;return-1}function d(e,n,r){let a=(0,t.toUint8Array)(e),o=c(n,r),[s,u]=i(a.byteLength,r);if(o.byteLength===0)return u;let d=u-o.byteLength;if(d<s)return-1;for(let e=d;e>=s;e--)if(l(a,o,e))return e;return-1}function f(e,t,n){return u(e,t,n)!==-1}function p(e,n,r){let i=(0,t.toUint8Array)(e),a=c(n,r);return a.byteLength>i.byteLength?!1:l(i,a,0)}function m(e,n,r){let i=(0,t.toUint8Array)(e),a=c(n,r);return a.byteLength>i.byteLength?!1:l(i,a,i.byteLength-a.byteLength)}function h(e,n,r){let i=(0,t.toUint8Array)(e),o=a(n,0,i.byteLength),s=a(r,i.byteLength,i.byteLength);return s<=o?i.subarray(o,o):i.subarray(o,s)}function g(e,n){let r=(0,t.toUint8Array)(e),i=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return i>=r.byteLength?r:r.subarray(r.byteLength-i)}function _(e){return(0,t.toUint8ArrayCopy)(e)}function v(e,n){let r=(0,t.toUint8Array)(e),i=(0,t.toUint8Array)(n),a=Math.min(r.byteLength,i.byteLength);for(let e=0;e<a;e++){if(r[e]<i[e])return-1;if(r[e]>i[e])return 1}return r.byteLength<i.byteLength?-1:+(r.byteLength>i.byteLength)}})),q=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tail=e.startsWith=e.slice=e.lastIndexOf=e.indexOf=e.includes=e.endsWith=e.copy=e.compare=e.equal=e.concatToUint8Array=e.concat=e.toViewCopy=e.toView=e.toUint8ArrayCopy=e.toUint8Array=e.toArrayBufferLike=e.toArrayBuffer=e.isSharedArrayBuffer=e.isBufferSource=e.isArrayBufferView=e.isArrayBufferLike=e.isArrayBuffer=e.assertBufferSource=void 0;var t=Ze();Object.defineProperty(e,"assertBufferSource",{enumerable:!0,get:function(){return t.assertBufferSource}}),Object.defineProperty(e,"isArrayBuffer",{enumerable:!0,get:function(){return t.isArrayBuffer}}),Object.defineProperty(e,"isArrayBufferLike",{enumerable:!0,get:function(){return t.isArrayBufferLike}}),Object.defineProperty(e,"isArrayBufferView",{enumerable:!0,get:function(){return t.isArrayBufferView}}),Object.defineProperty(e,"isBufferSource",{enumerable:!0,get:function(){return t.isBufferSource}}),Object.defineProperty(e,"isSharedArrayBuffer",{enumerable:!0,get:function(){return t.isSharedArrayBuffer}}),Object.defineProperty(e,"toArrayBuffer",{enumerable:!0,get:function(){return t.toArrayBuffer}}),Object.defineProperty(e,"toArrayBufferLike",{enumerable:!0,get:function(){return t.toArrayBufferLike}}),Object.defineProperty(e,"toUint8Array",{enumerable:!0,get:function(){return t.toUint8Array}}),Object.defineProperty(e,"toUint8ArrayCopy",{enumerable:!0,get:function(){return t.toUint8ArrayCopy}}),Object.defineProperty(e,"toView",{enumerable:!0,get:function(){return t.toView}}),Object.defineProperty(e,"toViewCopy",{enumerable:!0,get:function(){return t.toViewCopy}});var n=Qe();Object.defineProperty(e,"concat",{enumerable:!0,get:function(){return n.concat}}),Object.defineProperty(e,"concatToUint8Array",{enumerable:!0,get:function(){return n.concatToUint8Array}});var r=$e();Object.defineProperty(e,"equal",{enumerable:!0,get:function(){return r.equal}});var i=et();Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return i.compare}}),Object.defineProperty(e,"copy",{enumerable:!0,get:function(){return i.copy}}),Object.defineProperty(e,"endsWith",{enumerable:!0,get:function(){return i.endsWith}}),Object.defineProperty(e,"includes",{enumerable:!0,get:function(){return i.includes}}),Object.defineProperty(e,"indexOf",{enumerable:!0,get:function(){return i.indexOf}}),Object.defineProperty(e,"lastIndexOf",{enumerable:!0,get:function(){return i.lastIndexOf}}),Object.defineProperty(e,"slice",{enumerable:!0,get:function(){return i.slice}}),Object.defineProperty(e,"startsWith",{enumerable:!0,get:function(){return i.startsWith}}),Object.defineProperty(e,"tail",{enumerable:!0,get:function(){return i.tail}})})),tt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnPropTypes=e.AsnTypeTypes=void 0;var t;(function(e){e[e.Sequence=0]=`Sequence`,e[e.Set=1]=`Set`,e[e.Choice=2]=`Choice`})(t||(e.AsnTypeTypes=t={}));var n;(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`})(n||(e.AsnPropTypes=n={}))})),nt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BitString=void 0;let n=(K(),t(L)).__importStar(Xe()),r=q();e.BitString=class{unusedBits=0;value=new ArrayBuffer(0);constructor(e,t=0){if(e)if(typeof e==`number`)this.fromNumber(e);else if((0,r.isBufferSource)(e))this.unusedBits=t,this.value=(0,r.toArrayBuffer)(e);else throw TypeError(`Unsupported type of 'params' argument for BitString`)}fromASN(e){if(!(e instanceof n.BitString))throw TypeError(`Argument 'asn' is not instance of ASN.1 BitString`);return this.unusedBits=e.valueBlock.unusedBits,this.value=(0,r.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new n.BitString({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new n.BitString({name:e})}toNumber(){let e=``,t=new Uint8Array(this.value);for(let n of t)e+=n.toString(2).padStart(8,`0`);return e=e.split(``).reverse().join(``),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,`0`)),parseInt(e,2)}fromNumber(e){let t=e.toString(2),n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;let r=new Uint8Array(n);t=t.padStart(n<<3,`0`).split(``).reverse().join(``);let i=0;for(;i<n;)r[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=r.buffer}}})),rt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OctetString=void 0;let n=(K(),t(L)).__importStar(Xe()),r=q();e.OctetString=class{buffer;get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){this.buffer=typeof e==`number`?new ArrayBuffer(e):(0,r.isBufferSource)(e)?(0,r.toArrayBuffer)(e):Array.isArray(e)?new Uint8Array(e).buffer:new ArrayBuffer(0)}fromASN(e){if(!(e instanceof n.OctetString))throw TypeError(`Argument 'asn' is not instance of ASN.1 OctetString`);return this.buffer=(0,r.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new n.OctetString({valueHex:this.buffer})}toSchema(e){return new n.OctetString({name:e})}}})),it=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(nt(),e),n.__exportStar(rt(),e)})),at=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnNullConverter=e.AsnGeneralizedTimeConverter=e.AsnUTCTimeConverter=e.AsnCharacterStringConverter=e.AsnGeneralStringConverter=e.AsnVisibleStringConverter=e.AsnGraphicStringConverter=e.AsnIA5StringConverter=e.AsnVideotexStringConverter=e.AsnTeletexStringConverter=e.AsnPrintableStringConverter=e.AsnNumericStringConverter=e.AsnUniversalStringConverter=e.AsnBmpStringConverter=e.AsnUtf8StringConverter=e.AsnConstructedOctetStringConverter=e.AsnOctetStringConverter=e.AsnBooleanConverter=e.AsnObjectIdentifierConverter=e.AsnBitStringConverter=e.AsnIntegerBigIntConverter=e.AsnIntegerArrayBufferConverter=e.AsnEnumeratedConverter=e.AsnIntegerConverter=e.AsnAnyConverter=void 0,e.defaultConverter=s;let n=(K(),t(L)).__importStar(Xe()),r=q(),i=tt(),a=it();e.AsnAnyConverter={fromASN:e=>e instanceof n.Null?null:(0,r.toArrayBuffer)(e.valueBeforeDecodeView),toASN:e=>{if(e===null)return new n.Null;let t=n.fromBER(e);if(t.result.error)throw Error(t.result.error);return t.result}},e.AsnIntegerConverter={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new n.Integer({value:+e})},e.AsnEnumeratedConverter={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new n.Enumerated({value:e})},e.AsnIntegerArrayBufferConverter={fromASN:e=>(0,r.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new n.Integer({valueHex:e})},e.AsnIntegerBigIntConverter={fromASN:e=>e.toBigInt(),toASN:e=>n.Integer.fromBigInt(e)},e.AsnBitStringConverter={fromASN:e=>(0,r.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new n.BitString({valueHex:e})},e.AsnObjectIdentifierConverter={fromASN:e=>e.valueBlock.toString(),toASN:e=>new n.ObjectIdentifier({value:e})},e.AsnBooleanConverter={fromASN:e=>e.valueBlock.value,toASN:e=>new n.Boolean({value:e})},e.AsnOctetStringConverter={fromASN:e=>(0,r.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new n.OctetString({valueHex:e})},e.AsnConstructedOctetStringConverter={fromASN:e=>new a.OctetString(e.getValue()),toASN:e=>e.toASN()};function o(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}e.AsnUtf8StringConverter=o(n.Utf8String),e.AsnBmpStringConverter=o(n.BmpString),e.AsnUniversalStringConverter=o(n.UniversalString),e.AsnNumericStringConverter=o(n.NumericString),e.AsnPrintableStringConverter=o(n.PrintableString),e.AsnTeletexStringConverter=o(n.TeletexString),e.AsnVideotexStringConverter=o(n.VideotexString),e.AsnIA5StringConverter=o(n.IA5String),e.AsnGraphicStringConverter=o(n.GraphicString),e.AsnVisibleStringConverter=o(n.VisibleString),e.AsnGeneralStringConverter=o(n.GeneralString),e.AsnCharacterStringConverter=o(n.CharacterString),e.AsnUTCTimeConverter={fromASN:e=>e.toDate(),toASN:e=>new n.UTCTime({valueDate:e})},e.AsnGeneralizedTimeConverter={fromASN:e=>e.toDate(),toASN:e=>new n.GeneralizedTime({valueDate:e})},e.AsnNullConverter={fromASN:()=>null,toASN:()=>new n.Null};function s(t){switch(t){case i.AsnPropTypes.Any:return e.AsnAnyConverter;case i.AsnPropTypes.BitString:return e.AsnBitStringConverter;case i.AsnPropTypes.BmpString:return e.AsnBmpStringConverter;case i.AsnPropTypes.Boolean:return e.AsnBooleanConverter;case i.AsnPropTypes.CharacterString:return e.AsnCharacterStringConverter;case i.AsnPropTypes.Enumerated:return e.AsnEnumeratedConverter;case i.AsnPropTypes.GeneralString:return e.AsnGeneralStringConverter;case i.AsnPropTypes.GeneralizedTime:return e.AsnGeneralizedTimeConverter;case i.AsnPropTypes.GraphicString:return e.AsnGraphicStringConverter;case i.AsnPropTypes.IA5String:return e.AsnIA5StringConverter;case i.AsnPropTypes.Integer:return e.AsnIntegerConverter;case i.AsnPropTypes.Null:return e.AsnNullConverter;case i.AsnPropTypes.NumericString:return e.AsnNumericStringConverter;case i.AsnPropTypes.ObjectIdentifier:return e.AsnObjectIdentifierConverter;case i.AsnPropTypes.OctetString:return e.AsnOctetStringConverter;case i.AsnPropTypes.PrintableString:return e.AsnPrintableStringConverter;case i.AsnPropTypes.TeletexString:return e.AsnTeletexStringConverter;case i.AsnPropTypes.UTCTime:return e.AsnUTCTimeConverter;case i.AsnPropTypes.UniversalString:return e.AsnUniversalStringConverter;case i.AsnPropTypes.Utf8String:return e.AsnUtf8StringConverter;case i.AsnPropTypes.VideotexString:return e.AsnVideotexStringConverter;case i.AsnPropTypes.VisibleString:return e.AsnVisibleStringConverter;default:return null}}})),ot=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isConvertible=t,e.isTypeOfArray=n,e.isArrayEqual=r;function t(e){return typeof e==`function`&&e.prototype?e.prototype.toASN&&e.prototype.fromASN?!0:t(e.prototype):!!(e&&typeof e==`object`&&`toASN`in e&&`fromASN`in e)}function n(e){if(e){let t=Object.getPrototypeOf(e);return t?.prototype?.constructor===Array||n(t)}return!1}function r(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}})),st=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSchemaStorage=void 0;let n=(K(),t(L)).__importStar(Xe()),r=tt(),i=ot();e.AsnSchemaStorage=class{items=new WeakMap;has(e){return this.items.has(e)}get(e,t=!1){let n=this.items.get(e);if(!n)throw Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let t=this.get(e);t.schema||=this.create(e,!0)}createDefault(e){let t={type:r.AsnTypeTypes.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){let a=this.items.get(e)||this.createDefault(e),o=[];for(let e in a.items){let s=a.items[e],c=t?e:``,l;if(typeof s.type==`number`){let e=r.AsnPropTypes[s.type],t=n[e];if(!t)throw Error(`Cannot get ASN1 class by name '${e}'`);l=new t({name:c})}else(0,i.isConvertible)(s.type)?l=new s.type().toSchema(c):s.optional?this.get(s.type).type===r.AsnTypeTypes.Choice?l=new n.Any({name:c}):(l=this.create(s.type,!1),l.name=c):l=new n.Any({name:c});let u=!!s.optional||s.defaultValue!==void 0;if(s.repeated&&(l.name=``,l=new(s.repeated===`set`?n.Set:n.Sequence)({name:``,value:[new n.Repeated({name:c,value:l})]})),s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type==`number`||(0,i.isConvertible)(s.type)){let e=s.repeated?n.Constructed:n.Primitive;o.push(new e({name:c,optional:u,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);let e=!!s.repeated,t=e?l:this.get(s.type,!0).schema;t=`valueBlock`in t?t.valueBlock.value:t.value,o.push(new n.Constructed({name:e?``:c,optional:u,idBlock:{tagClass:3,tagNumber:s.context},value:t}))}else o.push(new n.Constructed({optional:u,idBlock:{tagClass:3,tagNumber:s.context},value:[l]}));else l.optional=u,o.push(l)}switch(a.type){case r.AsnTypeTypes.Sequence:return new n.Sequence({value:o,name:``});case r.AsnTypeTypes.Set:return new n.Set({value:o,name:``});case r.AsnTypeTypes.Choice:return new n.Choice({value:o,name:``});default:throw Error(`Unsupported ASN1 type in use`)}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){let t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}})),ct=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.schemaStorage=void 0,e.schemaStorage=new(st()).AsnSchemaStorage})),lt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnProp=e.AsnSequenceType=e.AsnSetType=e.AsnChoiceType=e.AsnType=void 0;let n=(K(),t(L)).__importStar(at()),r=tt(),i=ct();e.AsnType=e=>t=>{let n;i.schemaStorage.has(t)?n=i.schemaStorage.get(t):(n=i.schemaStorage.createDefault(t),i.schemaStorage.set(t,n)),Object.assign(n,e)},e.AsnChoiceType=()=>(0,e.AsnType)({type:r.AsnTypeTypes.Choice}),e.AsnSetType=t=>(0,e.AsnType)({type:r.AsnTypeTypes.Set,...t}),e.AsnSequenceType=t=>(0,e.AsnType)({type:r.AsnTypeTypes.Sequence,...t}),e.AsnProp=e=>(t,r)=>{let a;i.schemaStorage.has(t.constructor)?a=i.schemaStorage.get(t.constructor):(a=i.schemaStorage.createDefault(t.constructor),i.schemaStorage.set(t.constructor,a));let o=Object.assign({},e);if(typeof o.type==`number`&&!o.converter){let i=n.defaultConverter(e.type);if(!i)throw Error(`Cannot get default converter for property '${r}' of ${t.constructor.name}`);o.converter=i}o.raw=e.raw,a.items[r]=o}})),ut=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSchemaValidationError=void 0,e.AsnSchemaValidationError=class extends Error{schemas=[]}})),dt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),(K(),t(L)).__exportStar(ut(),e)})),ft=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnParser=void 0;let n=(K(),t(L)),r=n.__importStar(Xe()),i=q(),a=tt(),o=n.__importStar(at()),s=dt(),c=ot(),l=ct();e.AsnParser=class{static parse(e,t,n){let a=r.fromBER((0,i.toArrayBuffer)(e),n?.berOptions);if(a.result.error)throw Error(a.result.error);return this.fromASN(a.result,t,n)}static fromASN(e,t,n){try{if((0,c.isConvertible)(t))return new t().fromASN(e);let r=l.schemaStorage.get(t);l.schemaStorage.cache(t);let i=r.schema,a=this.handleChoiceTypes(e,r,t,i,n);if(a?.result)return a.result;a?.targetSchema&&(i=a.targetSchema);let o=this.handleSequenceTypes(e,r,t,i),s=new t;return(0,c.isTypeOfArray)(t)?this.handleArrayTypes(e,r,t,n):(this.processSchemaItems(r,o,s,n),s)}catch(e){throw e instanceof s.AsnSchemaValidationError&&e.schemas.push(t.name),e}}static handleChoiceTypes(e,t,n,i,o){if(e.constructor===r.Constructed&&t.type===a.AsnTypeTypes.Choice&&e.idBlock.tagClass===3)for(let i in t.items){let s=t.items[i];if(s.context===e.idBlock.tagNumber&&s.implicit&&typeof s.type==`function`&&l.schemaStorage.has(s.type)){let t=l.schemaStorage.get(s.type);if(t&&t.type===a.AsnTypeTypes.Sequence){let t=new r.Sequence;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock){t.valueBlock.value=e.valueBlock.value;let r=this.fromASN(t,s.type,o),a=new n;return a[i]=r,{result:a}}}}}else if(e.constructor===r.Constructed&&t.type!==a.AsnTypeTypes.Choice){let n=new r.Constructed({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(let n in t.items)delete e[n];return{targetSchema:n}}return null}static handleSequenceTypes(e,t,n,i){if(t.type===a.AsnTypeTypes.Sequence){let t=r.compareSchema({},e,i);if(!t.verified)throw new s.AsnSchemaValidationError(`Data does not match to ${n.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}{let t=r.compareSchema({},e,i);if(!t.verified)throw new s.AsnSchemaValidationError(`Data does not match to ${n.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}}static processRepeatedField(e,t,n){let r=e.slice(t);if(r.length===1&&r[0].constructor.name===`Sequence`){let e=r[0];e.valueBlock&&e.valueBlock.value&&Array.isArray(e.valueBlock.value)&&(r=e.valueBlock.value)}if(typeof n.type==`number`){let e=o.defaultConverter(n.type);if(!e)throw Error(`No converter for ASN.1 type ${n.type}`);return r.filter(e=>e&&e.valueBlock).map(t=>{try{return e.fromASN(t)}catch{return}}).filter(e=>e!==void 0)}return r.filter(e=>e&&e.valueBlock).map(e=>{try{return this.fromASN(e,n.type)}catch{return}}).filter(e=>e!==void 0)}static processPrimitiveField(e,t){let n=o.defaultConverter(t.type);if(!n)throw Error(`No converter for ASN.1 type ${t.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type==`function`&&l.schemaStorage.has(e.type)&&l.schemaStorage.get(e.type).type===a.AsnTypeTypes.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(e){if(e instanceof s.AsnSchemaValidationError&&/Wrong values for Choice type/.test(e.message))return{processed:!1};throw e}}static handleArrayTypes(e,t,n,r){if(!(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let i=t.itemType;if(typeof i==`number`){let t=o.defaultConverter(i);if(!t)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,e=>t.fromASN(e))}return n.from(e.valueBlock.value,e=>this.fromASN(e,i,r))}static processSchemaItems(e,t,n,r){for(let i in e.items){let a=t.result[i];if(!a)continue;let o=e.items[i],s=o.type,l;l=typeof s==`number`||(0,c.isConvertible)(s)?this.processPrimitiveSchemaItem(a,o,s,r):this.processComplexSchemaItem(a,o,s,r),l&&typeof l==`object`&&`value`in l&&`raw`in l?(n[i]=l.value,n[`${i}Raw`]=l.raw):n[i]=l}}static processPrimitiveSchemaItem(e,t,n,r){let i=t.converter??((0,c.isConvertible)(n)?new n:null);if(!i)throw Error(`Converter is empty`);return t.repeated?this.processRepeatedPrimitiveItem(e,t,i,r):this.processSinglePrimitiveItem(e,t,n,i,r)}static processRepeatedPrimitiveItem(e,t,n,i){if(t.implicit){let a=new(t.repeated===`sequence`?r.Sequence:r.Set);a.valueBlock=e.valueBlock;let o=r.fromBER(a.toBER(!1),i?.berOptions);if(o.offset===-1)throw Error(`Cannot parse the child item. ${o.result.error}`);if(!(`value`in o.result.valueBlock&&Array.isArray(o.result.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let s=o.result.valueBlock.value;return Array.from(s,e=>n.fromASN(e))}return Array.from(e,e=>n.fromASN(e))}static processSinglePrimitiveItem(e,t,n,i,o){let s=e;if(t.implicit){let e;if((0,c.isConvertible)(n))e=new n().toSchema(``);else{let t=a.AsnPropTypes[n],i=r[t];if(!i)throw Error(`Cannot get '${t}' class from asn1js module`);e=new i}e.valueBlock=s.valueBlock,s=r.fromBER(e.toBER(!1),o?.berOptions).result}return i.fromASN(s)}static processComplexSchemaItem(e,t,n,r){if(t.repeated){if(!Array.isArray(e))throw Error(`Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.`);return Array.from(e,e=>this.fromASN(e,n,r))}{let i=this.handleImplicitTagging(e,t,n);if(this.isOptionalChoiceField(t))try{return this.fromASN(i,n,r)}catch(e){if(e instanceof s.AsnSchemaValidationError&&/Wrong values for Choice type/.test(e.message))return;throw e}{let a=this.fromASN(i,n,r);return t.raw?{value:a,raw:e.valueBeforeDecodeView}:a}}}static handleImplicitTagging(e,t,n){if(t.implicit&&typeof t.context==`number`){let t=l.schemaStorage.get(n);if(t.type===a.AsnTypeTypes.Sequence){let t=new r.Sequence;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}else if(t.type===a.AsnTypeTypes.Set){let t=new r.Set;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}}return e}}})),pt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSerializer=void 0;let n=(K(),t(L)),r=n.__importStar(Xe()),i=q(),a=n.__importStar(at()),o=tt(),s=ot(),c=ct();e.AsnSerializer=class e{static serialize(e){return e instanceof r.BaseBlock?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(t){if(t&&typeof t==`object`&&(0,s.isConvertible)(t))return t.toASN();if(!(t&&typeof t==`object`))throw TypeError(`Parameter 1 should be type of Object.`);let n=t.constructor,l=c.schemaStorage.get(n);c.schemaStorage.cache(n);let u=[];if(l.itemType){if(!Array.isArray(t))throw TypeError(`Parameter 1 should be type of Array.`);if(typeof l.itemType==`number`){let e=a.defaultConverter(l.itemType);if(!e)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);u=t.map(t=>e.toASN(t))}else u=t.map(e=>this.toAsnItem({type:l.itemType},`[]`,n,e))}else for(let a in l.items){let o=l.items[a],c=t[a];if(c===void 0||o.defaultValue===c||typeof o.defaultValue==`object`&&typeof c==`object`&&(0,s.isArrayEqual)(this.serialize(o.defaultValue),this.serialize(c)))continue;let d=e.toAsnItem(o,a,n,c);if(typeof o.context==`number`)if(o.implicit)if(!o.repeated&&(typeof o.type==`number`||(0,s.isConvertible)(o.type))){let e={};e.valueHex=d instanceof r.Null?(0,i.toArrayBuffer)(d.valueBeforeDecodeView):d.valueBlock.toBER(),u.push(new r.Primitive({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},...e}))}else u.push(new r.Constructed({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:d.valueBlock.value}));else u.push(new r.Constructed({optional:o.optional,idBlock:{tagClass:3,tagNumber:o.context},value:[d]}));else o.repeated?u=u.concat(d):u.push(d)}let d;switch(l.type){case o.AsnTypeTypes.Sequence:d=new r.Sequence({value:u});break;case o.AsnTypeTypes.Set:d=new r.Set({value:u});break;case o.AsnTypeTypes.Choice:if(!u[0])throw Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);d=u[0]}return d}static toAsnItem(e,t,n,i){let a;if(typeof e.type==`number`){let s=e.converter;if(!s)throw Error(`Property '${t}' doesn't have converter for type ${o.AsnPropTypes[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(i,e=>s.toASN(e));a=new(e.repeated===`sequence`?r.Sequence:r.Set)({value:t})}else a=s.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(i,e=>this.toASN(e));a=new(e.repeated===`sequence`?r.Sequence:r.Set)({value:t})}else a=this.toASN(i);return a}}})),mt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnArray=void 0,e.AsnArray=class extends Array{constructor(e=[]){if(typeof e==`number`)super(e);else{super();for(let t of e)this.push(t)}}}})),ht=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnConvert=void 0;let n=(K(),t(L)).__importStar(Xe()),r=q(),i=ft(),a=pt();e.AsnConvert=class e{static serialize(e){return a.AsnSerializer.serialize(e)}static parse(e,t,n){return i.AsnParser.parse(e,t,n)}static toString(t,i){let a=(0,r.isBufferSource)(t)?(0,r.toArrayBuffer)(t):e.serialize(t),o=n.fromBER(a,i?.berOptions);if(o.offset===-1)throw Error(`Cannot decode ASN.1 data. ${o.result.error}`);return o.result.toString()}}})),J=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSerializer=e.AsnParser=e.AsnPropTypes=e.AsnTypeTypes=e.AsnSetType=e.AsnSequenceType=e.AsnChoiceType=e.AsnType=e.AsnProp=void 0;let n=(K(),t(L));n.__exportStar(at(),e),n.__exportStar(it(),e);var r=lt();Object.defineProperty(e,"AsnProp",{enumerable:!0,get:function(){return r.AsnProp}}),Object.defineProperty(e,"AsnType",{enumerable:!0,get:function(){return r.AsnType}}),Object.defineProperty(e,"AsnChoiceType",{enumerable:!0,get:function(){return r.AsnChoiceType}}),Object.defineProperty(e,"AsnSequenceType",{enumerable:!0,get:function(){return r.AsnSequenceType}}),Object.defineProperty(e,"AsnSetType",{enumerable:!0,get:function(){return r.AsnSetType}});var i=tt();Object.defineProperty(e,"AsnTypeTypes",{enumerable:!0,get:function(){return i.AsnTypeTypes}}),Object.defineProperty(e,"AsnPropTypes",{enumerable:!0,get:function(){return i.AsnPropTypes}});var a=ft();Object.defineProperty(e,"AsnParser",{enumerable:!0,get:function(){return a.AsnParser}});var o=pt();Object.defineProperty(e,"AsnSerializer",{enumerable:!0,get:function(){return o.AsnSerializer}}),n.__exportStar(dt(),e),n.__exportStar(mt(),e),n.__exportStar(ht(),e)})),gt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.binary=void 0,e.encode=n,e.decode=r,e.is=i;let t=q();function n(e){let n=(0,t.toUint8Array)(e),r=``;for(let e of n)r+=String.fromCharCode(e);return r}function r(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function i(e){return typeof e==`string`}e.binary={encode:n,decode:r,is:i}})),_t=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hex=e.formats=void 0,e.normalize=m,e.is=h,e.encode=g,e.decode=_,e.parse=v,e.format=y;let t=q(),n=/^[0-9a-f]$/i,r=[` `,` `,`
84
84
  `,`\r`,`:`,`-`,`.`];function i(e){return e.separators===`none`?[]:!e.separators||e.separators===`common`?r:e.separators}function a(e){if(!e)throw TypeError(`Hex separators must be non-empty strings`)}function o(e,t,n){for(let r of n)if(e.startsWith(r,t))return r}function s(e){let t=/[A-F]/.test(e),n=/[a-f]/.test(e);return t&&!n?`upper`:`lower`}function c(e){let t=/\r\n|\n/.exec(e);if(t)return t[0]===`\r
85
85
  `?`\r
86
86
  `:`
87
87
  `}function l(e){return e.replace(/[^0-9a-f]/gi,``)}function u(e){let t=e.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g)??[];if(t.length<3)return;let n=t.filter((e,t)=>t%2==0),r=t.filter((e,t)=>t%2==1),i=r[0];if(!i||r.some(e=>e!==i)||n.some(e=>e.length===0||e.length%2!=0))return;let a=n[0]?.length??0;if(a&&!n.slice(0,-1).some(e=>e.length!==a)&&!((n[n.length-1]?.length??0)>a))return{size:a/2,separator:i}}function d(e){let t=e.trim(),n=/^0x/i.test(t)?`0x`:``,r=n?t.slice(2):t,i=c(r),a=r.split(/\r\n|\n/).filter(e=>e.length>0),o=u(a[0]?.trim()??``),d={case:s(t),prefix:n};if(o&&(d.group=o),i&&a.length>1){let e=l(a[0]??``).length/2;e>0&&a.slice(0,-1).every(t=>l(t).length/2===e)&&(d.line={bytesPerLine:e,separator:i})}return d}function f(e,t){let r=t.allowPrefix??!0,s=[...i(t)].sort((e,t)=>t.length-e.length);for(let e of s)a(e);let c=e.trim();if(/^0x/i.test(c)){if(!r)throw TypeError(`Hexadecimal text must not include a 0x prefix`);c=c.slice(2)}let l=``,u=!1;for(let e=0;e<c.length;){let r=c[e]??``;if(n.test(r)){l+=r,u=!1,e+=1;continue}let i=o(c,e,s);if(!i)throw TypeError(`Input is not valid hexadecimal text`);if(t.strict&&(u||l.length===0))throw TypeError(`Hexadecimal text contains misplaced separators`);u=!0,e+=i.length}if(t.strict&&u&&l.length>0)throw TypeError(`Hexadecimal text must not end with a separator`);if(l.length%2!=0){if(!t.allowOddLength)throw TypeError(`Hexadecimal text must contain an even number of characters`);l=`0${l}`}return l.toLowerCase()}function p(e,t){if(!t)return e.join(``);if(!Number.isInteger(t.size)||t.size<1)throw RangeError(`Hex group size must be a positive integer`);let n=[];for(let r=0;r<e.length;r+=t.size)n.push(e.slice(r,r+t.size).join(``));return n.join(t.separator)}function m(e,t={}){return f(e,t)}function h(e,t={}){if(typeof e!=`string`)return!1;try{return m(e,t),!0}catch{return!1}}function g(e,n={}){let r=(0,t.toUint8Array)(e),i=n.case??`lower`,a=Array.from(r,e=>{let t=e.toString(16).padStart(2,`0`);return i===`upper`?t.toUpperCase():t}),o=``;if(n.line){let e=n.line.bytesPerLine;if(!Number.isInteger(e)||e<1)throw RangeError(`Hex bytesPerLine must be a positive integer`);let t=n.line.separator??`
88
- `,r=[];for(let t=0;t<a.length;t+=e)r.push(p(a.slice(t,t+e),n.group));o=r.join(t)}else o=p(a,n.group);return`${n.prefix??``}${o}`}function _(e,t={}){let n=m(e,t),r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2)r[e/2]=Number.parseInt(n.slice(e,e+2),16);return r}function v(e,t={}){let n=m(e,t);return{bytes:_(n),format:d(e),normalized:n}}function y(e,t){return g(e,t)}e.formats={compact:Object.freeze({}),upper:Object.freeze({case:`upper`}),colon:Object.freeze({group:{size:1,separator:`:`}}),colonUpper:Object.freeze({case:`upper`,group:{size:1,separator:`:`}}),groupsOf4:Object.freeze({group:{size:4,separator:` `}}),prefixed:Object.freeze({prefix:`0x`})},e.hex={encode:g,decode:_,format:y,formats:e.formats,is:h,normalize:m,parse:v}})),Jt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utf8=void 0,e.encode=n,e.decode=r;let t=At();function n(e){return new TextEncoder().encode(e)}function r(e){return new TextDecoder(`utf-8`,{fatal:!1}).decode((0,t.toUint8Array)(e))}e.utf8={encode:n,decode:r}})),Yt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utf16=void 0,e.encode=n,e.decode=r;let t=At();function n(e,t={}){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t.littleEndian??!1);return new Uint8Array(n)}function r(e,n={}){let r=(0,t.toArrayBuffer)(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2)a+=String.fromCharCode(i.getUint16(e,n.littleEndian??!1));return a}e.utf16={encode:n,decode:r}})),Xt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64=void 0,e.normalize=a,e.pad=o,e.is=s,e.encode=c,e.decode=l;let t=At(),n=Kt(),r=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function i(){return globalThis.Buffer}function a(e){return e.replace(/[\n\r\t ]/g,``)}function o(e){let t=e.length%4;return t?e+`=`.repeat(4-t):e}function s(e){if(typeof e!=`string`)return!1;let t=a(e);return t===``||r.test(t)}function c(e,r){let a=(0,t.toUint8Array)(e),o=i();return o?o.from(a).toString(`base64`):btoa((0,n.encode)(a))}function l(e,t){let r=a(e);if(!s(r))throw TypeError(`Input is not valid Base64 text`);let o=i();return o?new Uint8Array(o.from(r,`base64`)):(0,n.decode)(atob(r))}e.base64={encode:c,decode:l,is:s,normalize:a,pad:o}})),Zt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64url=void 0,e.normalize=r,e.is=i,e.encode=a,e.decode=o;let t=Xt(),n=/^[A-Za-z0-9_-]*$/;function r(e){return e.replace(/[\n\r\t ]/g,``)}function i(e){return typeof e==`string`&&n.test(r(e))}function a(e,n){return t.base64.encode(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}function o(e,n){let a=r(e);if(!i(a))throw TypeError(`Input is not valid Base64Url text`);return t.base64.decode(t.base64.pad(a.replace(/-/g,`+`).replace(/_/g,`/`)))}e.base64url={encode:a,decode:o,is:i,normalize:r}})),Qt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64url=e.base64=e.utf16=e.utf8=e.hex=e.binary=void 0;let n=(X(),t(q));e.binary=n.__importStar(Kt()),e.hex=n.__importStar(qt()),e.utf8=n.__importStar(Jt()),e.utf16=n.__importStar(Yt()),e.base64=n.__importStar(Xt()),e.base64url=n.__importStar(Zt())})),$t=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IpConverter=void 0;let t=Qt();e.IpConverter=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let t=e.split(`.`);if(t.length!==4)throw Error(`Invalid IPv4 address`);return t.map(e=>{let t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw Error(`Invalid IPv4 address part`);return t})}static parseIPv6(e){let t=this.expandIPv6(e).split(`:`);if(t.length!==8)throw Error(`Invalid IPv6 address`);return t.reduce((e,t)=>{let n=parseInt(t,16);if(isNaN(n)||n<0||n>65535)throw Error(`Invalid IPv6 address part`);return e.push(n>>8&255),e.push(n&255),e},[])}static expandIPv6(e){if(!e.includes(`::`))return e;let t=e.split(`::`);if(t.length>2)throw Error(`Invalid IPv6 address`);let n=t[0]?t[0].split(`:`):[],r=t[1]?t[1].split(`:`):[],i=8-(n.length+r.length);if(i<0)throw Error(`Invalid IPv6 address`);return[...n,...Array(i).fill(`0`),...r].join(`:`)}static formatIPv6(e){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(t.join(`:`))}static compressIPv6(e){let t=e.split(`:`),n=-1,r=0,i=-1,a=0;for(let e=0;e<t.length;e++)t[e]===`0`?(i===-1&&(i=e),a++):(a>r&&(n=i,r=a),i=-1,a=0);return a>r&&(n=i,r=a),r>1?`${t.slice(0,n).join(`:`)}::${t.slice(n+r).join(`:`)}`:e}static parseCIDR(e){let[t,n]=e.split(`/`),r=parseInt(n,10);if(this.isIPv4(t)){if(r<0||r>32)throw Error(`Invalid IPv4 prefix length`);return[this.parseIPv4(t),r]}if(r<0||r>128)throw Error(`Invalid IPv6 prefix length`);return[this.parseIPv6(t),r]}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return`::/0`;if(e.length!==16)return e;let t=parseInt(e.slice(8),16).toString(2).split(``).reduce((e,t)=>e+ +t,0),n=e.slice(0,8).replace(/(.{2})/g,e=>`${parseInt(e,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){let n=new Uint8Array(e);if(n.length===4)return Array.from(n).join(`.`);if(n.length===16)return this.formatIPv6(n);if(n.length===8||n.length===32){let e=n.length/2,t=n.slice(0,e),r=n.slice(e);if(n.every(e=>e===0))return n.length===8?`0.0.0.0/0`:`::/0`;let i=r.reduce((e,t)=>e+(t.toString(2).match(/1/g)||[]).length,0);return n.length===8?`${Array.from(t).join(`.`)}/${i}`:`${this.formatIPv6(t)}/${i}`}return this.decodeIP(t.hex.encode(e))}static fromString(e){if(e.includes(`/`)){let[t,n]=this.parseCIDR(e),r=new Uint8Array(t.length),i=n;for(let e=0;e<r.length;e++)i>=8?(r[e]=255,i-=8):i>0&&(r[e]=255<<8-i,i=0);let a=new Uint8Array(t.length*2);return a.set(t,0),a.set(r,t.length),a.buffer}let t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}}})),en=s((e=>{var n,r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.Name=e.RDNSequence=e.RelativeDistinguishedName=e.AttributeTypeAndValue=e.AttributeValue=e.DirectoryString=void 0;let a=(X(),t(q)),o=Z(),s=Qt(),c=class{teletexString;printableString;universalString;utf8String;bmpString;constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||``}};e.DirectoryString=c,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.TeletexString})],c.prototype,`teletexString`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.PrintableString})],c.prototype,`printableString`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.UniversalString})],c.prototype,`universalString`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.Utf8String})],c.prototype,`utf8String`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.BmpString})],c.prototype,`bmpString`,void 0),e.DirectoryString=c=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],c);let l=class extends c{ia5String;anyValue;constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?s.hex.encode(this.anyValue):super.toString())}};e.AttributeValue=l,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.IA5String})],l.prototype,`ia5String`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.Any})],l.prototype,`anyValue`,void 0),e.AttributeValue=l=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],l);var u=class{type=``;value=new l;constructor(e={}){Object.assign(this,e)}};e.AttributeTypeAndValue=u,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.ObjectIdentifier})],u.prototype,`type`,void 0),a.__decorate([(0,o.AsnProp)({type:l})],u.prototype,`value`,void 0);let d=n=class extends o.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RelativeDistinguishedName=d,e.RelativeDistinguishedName=d=n=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Set,itemType:u})],d);let f=r=class extends o.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};e.RDNSequence=f,e.RDNSequence=f=r=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence,itemType:d})],f);let p=i=class extends f{constructor(e){super(e),Object.setPrototypeOf(this,i.prototype)}};e.Name=p,e.Name=p=i=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],p)})),tn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GeneralName=e.EDIPartyName=e.OtherName=e.AsnIpConverter=void 0;let n=(X(),t(q)),r=Z(),i=$t(),a=en();e.AsnIpConverter={fromASN:e=>i.IpConverter.toString(r.AsnOctetStringConverter.fromASN(e)),toASN:e=>r.AsnOctetStringConverter.toASN(i.IpConverter.fromString(e))};var o=class{typeId=``;value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherName=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],o.prototype,`typeId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],o.prototype,`value`,void 0);var s=class{nameAssigner;partyName=new a.DirectoryString;constructor(e={}){Object.assign(this,e)}};e.EDIPartyName=s,n.__decorate([(0,r.AsnProp)({type:a.DirectoryString,optional:!0,context:0,implicit:!0})],s.prototype,`nameAssigner`,void 0),n.__decorate([(0,r.AsnProp)({type:a.DirectoryString,context:1,implicit:!0})],s.prototype,`partyName`,void 0);let c=class{otherName;rfc822Name;dNSName;x400Address;directoryName;ediPartyName;uniformResourceIdentifier;iPAddress;registeredID;constructor(e={}){Object.assign(this,e)}};e.GeneralName=c,n.__decorate([(0,r.AsnProp)({type:o,context:0,implicit:!0})],c.prototype,`otherName`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String,context:1,implicit:!0})],c.prototype,`rfc822Name`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String,context:2,implicit:!0})],c.prototype,`dNSName`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:3,implicit:!0})],c.prototype,`x400Address`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Name,context:4,implicit:!1})],c.prototype,`directoryName`,void 0),n.__decorate([(0,r.AsnProp)({type:s,context:5})],c.prototype,`ediPartyName`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String,context:6,implicit:!0})],c.prototype,`uniformResourceIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.OctetString,context:7,implicit:!0,converter:e.AsnIpConverter})],c.prototype,`iPAddress`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier,context:8,implicit:!0})],c.prototype,`registeredID`,void 0),e.GeneralName=c=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],c)})),Q=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_ce=e.id_ad_caRepository=e.id_ad_timeStamping=e.id_ad_caIssuers=e.id_ad_ocsp=e.id_qt_unotice=e.id_qt_csp=e.id_ad=e.id_kp=e.id_qt=e.id_pe=e.id_pkix=void 0,e.id_pkix=`1.3.6.1.5.5.7`,e.id_pe=`${e.id_pkix}.1`,e.id_qt=`${e.id_pkix}.2`,e.id_kp=`${e.id_pkix}.3`,e.id_ad=`${e.id_pkix}.48`,e.id_qt_csp=`${e.id_qt}.1`,e.id_qt_unotice=`${e.id_qt}.2`,e.id_ad_ocsp=`${e.id_ad}.1`,e.id_ad_caIssuers=`${e.id_ad}.2`,e.id_ad_timeStamping=`${e.id_ad}.3`,e.id_ad_caRepository=`${e.id_ad}.5`,e.id_ce=`2.5.29`})),nn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.AuthorityInfoAccessSyntax=e.AccessDescription=e.id_pe_authorityInfoAccess=void 0;let r=(X(),t(q)),i=Z(),a=tn();e.id_pe_authorityInfoAccess=`${Q().id_pe}.1`;var o=class{accessMethod=``;accessLocation=new a.GeneralName;constructor(e={}){Object.assign(this,e)}};e.AccessDescription=o,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],o.prototype,`accessMethod`,void 0),r.__decorate([(0,i.AsnProp)({type:a.GeneralName})],o.prototype,`accessLocation`,void 0);let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.AuthorityInfoAccessSyntax=s,e.AuthorityInfoAccessSyntax=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o})],s)})),rn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AuthorityKeyIdentifier=e.KeyIdentifier=e.id_ce_authorityKeyIdentifier=void 0;let n=(X(),t(q)),r=Z(),i=tn();e.id_ce_authorityKeyIdentifier=`${Q().id_ce}.35`;var a=class extends r.OctetString{};e.KeyIdentifier=a;var o=class{keyIdentifier;authorityCertIssuer;authorityCertSerialNumber;constructor(e={}){e&&Object.assign(this,e)}};e.AuthorityKeyIdentifier=o,n.__decorate([(0,r.AsnProp)({type:a,context:0,optional:!0,implicit:!0})],o.prototype,`keyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName,context:1,optional:!0,implicit:!0,repeated:`sequence`})],o.prototype,`authorityCertIssuer`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:2,optional:!0,implicit:!0,converter:r.AsnIntegerArrayBufferConverter})],o.prototype,`authorityCertSerialNumber`,void 0)})),an=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BasicConstraints=e.id_ce_basicConstraints=void 0;let n=(X(),t(q)),r=Z();e.id_ce_basicConstraints=`${Q().id_ce}.19`;var i=class{cA=!1;pathLenConstraint;constructor(e={}){Object.assign(this,e)}};e.BasicConstraints=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,defaultValue:!1})],i.prototype,`cA`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,optional:!0})],i.prototype,`pathLenConstraint`,void 0)})),on=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.GeneralNames=void 0;let r=(X(),t(q)),i=Z(),a=tn(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.GeneralNames=o,e.GeneralNames=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.GeneralName})],o)})),sn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateIssuer=e.id_ce_certificateIssuer=void 0;let r=(X(),t(q)),i=Z(),a=on();e.id_ce_certificateIssuer=`${Q().id_ce}.29`;let o=n=class extends a.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.CertificateIssuer=o,e.CertificateIssuer=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],o)})),cn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificatePolicies=e.PolicyInformation=e.PolicyQualifierInfo=e.Qualifier=e.UserNotice=e.NoticeReference=e.DisplayText=e.id_ce_certificatePolicies_anyPolicy=e.id_ce_certificatePolicies=void 0;let r=(X(),t(q)),i=Z();e.id_ce_certificatePolicies=`${Q().id_ce}.32`,e.id_ce_certificatePolicies_anyPolicy=`${e.id_ce_certificatePolicies}.0`;let a=class{ia5String;visibleString;bmpString;utf8String;constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||``}};e.DisplayText=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.IA5String})],a.prototype,`ia5String`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.VisibleString})],a.prototype,`visibleString`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.BmpString})],a.prototype,`bmpString`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Utf8String})],a.prototype,`utf8String`,void 0),e.DisplayText=a=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],a);var o=class{organization=new a;noticeNumbers=[];constructor(e={}){Object.assign(this,e)}};e.NoticeReference=o,r.__decorate([(0,i.AsnProp)({type:a})],o.prototype,`organization`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,repeated:`sequence`})],o.prototype,`noticeNumbers`,void 0);var s=class{noticeRef;explicitText;constructor(e={}){Object.assign(this,e)}};e.UserNotice=s,r.__decorate([(0,i.AsnProp)({type:o,optional:!0})],s.prototype,`noticeRef`,void 0),r.__decorate([(0,i.AsnProp)({type:a,optional:!0})],s.prototype,`explicitText`,void 0);let c=class{cPSuri;userNotice;constructor(e={}){Object.assign(this,e)}};e.Qualifier=c,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.IA5String})],c.prototype,`cPSuri`,void 0),r.__decorate([(0,i.AsnProp)({type:s})],c.prototype,`userNotice`,void 0),e.Qualifier=c=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],c);var l=class{policyQualifierId=``;qualifier=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.PolicyQualifierInfo=l,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],l.prototype,`policyQualifierId`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any})],l.prototype,`qualifier`,void 0);var u=class{policyIdentifier=``;policyQualifiers;constructor(e={}){Object.assign(this,e)}};e.PolicyInformation=u,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],u.prototype,`policyIdentifier`,void 0),r.__decorate([(0,i.AsnProp)({type:l,repeated:`sequence`,optional:!0})],u.prototype,`policyQualifiers`,void 0);let d=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.CertificatePolicies=d,e.CertificatePolicies=d=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:u})],d)})),ln=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CRLNumber=e.id_ce_cRLNumber=void 0;let n=(X(),t(q)),r=Z();e.id_ce_cRLNumber=`${Q().id_ce}.20`;let i=class{value;constructor(e=0){this.value=e}};e.CRLNumber=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],i.prototype,`value`,void 0),e.CRLNumber=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),un=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseCRLNumber=e.id_ce_deltaCRLIndicator=void 0;let n=(X(),t(q)),r=Z(),i=Q(),a=ln();e.id_ce_deltaCRLIndicator=`${i.id_ce}.27`;let o=class extends a.CRLNumber{};e.BaseCRLNumber=o,e.BaseCRLNumber=o=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],o)})),dn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.CRLDistributionPoints=e.DistributionPoint=e.DistributionPointName=e.Reason=e.ReasonFlags=e.id_ce_cRLDistributionPoints=void 0;let r=(X(),t(q)),i=Z(),a=en(),o=tn();e.id_ce_cRLDistributionPoints=`${Q().id_ce}.31`;var s;(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`})(s||(e.ReasonFlags=s={}));var c=class extends i.BitString{toJSON(){let e=[],t=this.toNumber();return t&s.aACompromise&&e.push(`aACompromise`),t&s.affiliationChanged&&e.push(`affiliationChanged`),t&s.cACompromise&&e.push(`cACompromise`),t&s.certificateHold&&e.push(`certificateHold`),t&s.cessationOfOperation&&e.push(`cessationOfOperation`),t&s.keyCompromise&&e.push(`keyCompromise`),t&s.privilegeWithdrawn&&e.push(`privilegeWithdrawn`),t&s.superseded&&e.push(`superseded`),t&s.unused&&e.push(`unused`),e}toString(){return`[${this.toJSON().join(`, `)}]`}};e.Reason=c;let l=class{fullName;nameRelativeToCRLIssuer;constructor(e={}){Object.assign(this,e)}};e.DistributionPointName=l,r.__decorate([(0,i.AsnProp)({type:o.GeneralName,context:0,repeated:`sequence`,implicit:!0})],l.prototype,`fullName`,void 0),r.__decorate([(0,i.AsnProp)({type:a.RelativeDistinguishedName,context:1,implicit:!0})],l.prototype,`nameRelativeToCRLIssuer`,void 0),e.DistributionPointName=l=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],l);var u=class{distributionPoint;reasons;cRLIssuer;constructor(e={}){Object.assign(this,e)}};e.DistributionPoint=u,r.__decorate([(0,i.AsnProp)({type:l,context:0,optional:!0})],u.prototype,`distributionPoint`,void 0),r.__decorate([(0,i.AsnProp)({type:c,context:1,optional:!0,implicit:!0})],u.prototype,`reasons`,void 0),r.__decorate([(0,i.AsnProp)({type:o.GeneralName,context:2,optional:!0,repeated:`sequence`,implicit:!0})],u.prototype,`cRLIssuer`,void 0);let d=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.CRLDistributionPoints=d,e.CRLDistributionPoints=d=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:u})],d)})),fn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.FreshestCRL=e.id_ce_freshestCRL=void 0;let r=(X(),t(q)),i=Z(),a=Q(),o=dn();e.id_ce_freshestCRL=`${a.id_ce}.46`;let s=n=class extends o.CRLDistributionPoints{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.FreshestCRL=s,e.FreshestCRL=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o.DistributionPoint})],s)})),pn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuingDistributionPoint=e.id_ce_issuingDistributionPoint=void 0;let n=(X(),t(q)),r=Z(),i=Q(),a=dn();e.id_ce_issuingDistributionPoint=`${i.id_ce}.28`;var o=class e{static ONLY=!1;distributionPoint;onlyContainsUserCerts=e.ONLY;onlyContainsCACerts=e.ONLY;onlySomeReasons;indirectCRL=e.ONLY;onlyContainsAttributeCerts=e.ONLY;constructor(e={}){Object.assign(this,e)}};e.IssuingDistributionPoint=o,n.__decorate([(0,r.AsnProp)({type:a.DistributionPointName,context:0,optional:!0})],o.prototype,`distributionPoint`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,context:1,defaultValue:o.ONLY,implicit:!0})],o.prototype,`onlyContainsUserCerts`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,context:2,defaultValue:o.ONLY,implicit:!0})],o.prototype,`onlyContainsCACerts`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Reason,context:3,optional:!0,implicit:!0})],o.prototype,`onlySomeReasons`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,context:4,defaultValue:o.ONLY,implicit:!0})],o.prototype,`indirectCRL`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,context:5,defaultValue:o.ONLY,implicit:!0})],o.prototype,`onlyContainsAttributeCerts`,void 0)})),mn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CRLReason=e.CRLReasons=e.id_ce_cRLReasons=void 0;let n=(X(),t(q)),r=Z();e.id_ce_cRLReasons=`${Q().id_ce}.21`;var i;(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`})(i||(e.CRLReasons=i={}));let a=class{reason=i.unspecified;constructor(e=i.unspecified){this.reason=e}toJSON(){return i[this.reason]}toString(){return this.toJSON()}};e.CRLReason=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Enumerated})],a.prototype,`reason`,void 0),e.CRLReason=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],a)})),hn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.id_kp_OCSPSigning=e.id_kp_timeStamping=e.id_kp_emailProtection=e.id_kp_codeSigning=e.id_kp_clientAuth=e.id_kp_serverAuth=e.anyExtendedKeyUsage=e.ExtendedKeyUsage=e.id_ce_extKeyUsage=void 0;let r=(X(),t(q)),i=Z(),a=Q();e.id_ce_extKeyUsage=`${a.id_ce}.37`;let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.ExtendedKeyUsage=o,e.ExtendedKeyUsage=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:i.AsnPropTypes.ObjectIdentifier})],o),e.anyExtendedKeyUsage=`${e.id_ce_extKeyUsage}.0`,e.id_kp_serverAuth=`${a.id_kp}.1`,e.id_kp_clientAuth=`${a.id_kp}.2`,e.id_kp_codeSigning=`${a.id_kp}.3`,e.id_kp_emailProtection=`${a.id_kp}.4`,e.id_kp_timeStamping=`${a.id_kp}.8`,e.id_kp_OCSPSigning=`${a.id_kp}.9`})),gn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InhibitAnyPolicy=e.id_ce_inhibitAnyPolicy=void 0;let n=(X(),t(q)),r=Z();e.id_ce_inhibitAnyPolicy=`${Q().id_ce}.54`;let i=class{value;constructor(e=new ArrayBuffer(0)){this.value=e}};e.InhibitAnyPolicy=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`value`,void 0),e.InhibitAnyPolicy=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),_n=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidityDate=e.id_ce_invalidityDate=void 0;let n=(X(),t(q)),r=Z();e.id_ce_invalidityDate=`${Q().id_ce}.24`;let i=class{value=new Date;constructor(e){e&&(this.value=e)}};e.InvalidityDate=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime})],i.prototype,`value`,void 0),e.InvalidityDate=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),vn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.IssueAlternativeName=e.id_ce_issuerAltName=void 0;let r=(X(),t(q)),i=Z(),a=on();e.id_ce_issuerAltName=`${Q().id_ce}.18`;let o=n=class extends a.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.IssueAlternativeName=o,e.IssueAlternativeName=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],o)})),yn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyUsage=e.KeyUsageFlags=e.id_ce_keyUsage=void 0;let t=Z();e.id_ce_keyUsage=`${Q().id_ce}.15`;var n;(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`})(n||(e.KeyUsageFlags=n={})),e.KeyUsage=class extends t.BitString{toJSON(){let e=this.toNumber(),t=[];return e&n.cRLSign&&t.push(`crlSign`),e&n.dataEncipherment&&t.push(`dataEncipherment`),e&n.decipherOnly&&t.push(`decipherOnly`),e&n.digitalSignature&&t.push(`digitalSignature`),e&n.encipherOnly&&t.push(`encipherOnly`),e&n.keyAgreement&&t.push(`keyAgreement`),e&n.keyCertSign&&t.push(`keyCertSign`),e&n.keyEncipherment&&t.push(`keyEncipherment`),e&n.nonRepudiation&&t.push(`nonRepudiation`),t}toString(){return`[${this.toJSON().join(`, `)}]`}}})),bn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.NameConstraints=e.GeneralSubtrees=e.GeneralSubtree=e.id_ce_nameConstraints=void 0;let r=(X(),t(q)),i=Z(),a=tn();e.id_ce_nameConstraints=`${Q().id_ce}.30`;var o=class{base=new a.GeneralName;minimum=0;maximum;constructor(e={}){Object.assign(this,e)}};e.GeneralSubtree=o,r.__decorate([(0,i.AsnProp)({type:a.GeneralName})],o.prototype,`base`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,context:0,defaultValue:0,implicit:!0})],o.prototype,`minimum`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,context:1,optional:!0,implicit:!0})],o.prototype,`maximum`,void 0);let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.GeneralSubtrees=s,e.GeneralSubtrees=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o})],s);var c=class{permittedSubtrees;excludedSubtrees;constructor(e={}){Object.assign(this,e)}};e.NameConstraints=c,r.__decorate([(0,i.AsnProp)({type:s,context:0,optional:!0,implicit:!0})],c.prototype,`permittedSubtrees`,void 0),r.__decorate([(0,i.AsnProp)({type:s,context:1,optional:!0,implicit:!0})],c.prototype,`excludedSubtrees`,void 0)})),xn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PolicyConstraints=e.id_ce_policyConstraints=void 0;let n=(X(),t(q)),r=Z();e.id_ce_policyConstraints=`${Q().id_ce}.36`;var i=class{requireExplicitPolicy;inhibitPolicyMapping;constructor(e={}){Object.assign(this,e)}};e.PolicyConstraints=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:0,implicit:!0,optional:!0,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`requireExplicitPolicy`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:1,implicit:!0,optional:!0,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`inhibitPolicyMapping`,void 0)})),Sn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.PolicyMappings=e.PolicyMapping=e.id_ce_policyMappings=void 0;let r=(X(),t(q)),i=Z();e.id_ce_policyMappings=`${Q().id_ce}.33`;var a=class{issuerDomainPolicy=``;subjectDomainPolicy=``;constructor(e={}){Object.assign(this,e)}};e.PolicyMapping=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`issuerDomainPolicy`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`subjectDomainPolicy`,void 0);let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.PolicyMappings=o,e.PolicyMappings=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a})],o)})),Cn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectAlternativeName=e.id_ce_subjectAltName=void 0;let r=(X(),t(q)),i=Z(),a=on();e.id_ce_subjectAltName=`${Q().id_ce}.17`;let o=n=class extends a.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SubjectAlternativeName=o,e.SubjectAlternativeName=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],o)})),wn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;let n=(X(),t(q)),r=Z();var i=class{type=``;values=[];constructor(e={}){Object.assign(this,e)}};e.Attribute=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`type`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,repeated:`set`})],i.prototype,`values`,void 0)})),Tn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectDirectoryAttributes=e.id_ce_subjectDirectoryAttributes=void 0;let r=(X(),t(q)),i=Z(),a=wn();e.id_ce_subjectDirectoryAttributes=`${Q().id_ce}.9`;let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SubjectDirectoryAttributes=o,e.SubjectDirectoryAttributes=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.Attribute})],o)})),En=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectKeyIdentifier=e.id_ce_subjectKeyIdentifier=void 0;let t=Q(),n=rn();e.id_ce_subjectKeyIdentifier=`${t.id_ce}.14`,e.SubjectKeyIdentifier=class extends n.KeyIdentifier{}})),Dn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PrivateKeyUsagePeriod=e.id_ce_privateKeyUsagePeriod=void 0;let n=(X(),t(q)),r=Z();e.id_ce_privateKeyUsagePeriod=`${Q().id_ce}.16`;var i=class{notBefore;notAfter;constructor(e={}){Object.assign(this,e)}};e.PrivateKeyUsagePeriod=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime,context:0,implicit:!0,optional:!0})],i.prototype,`notBefore`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime,context:1,implicit:!0,optional:!0})],i.prototype,`notAfter`,void 0)})),On=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EntrustVersionInfo=e.EntrustInfo=e.EntrustInfoFlags=e.id_entrust_entrustVersInfo=void 0;let n=(X(),t(q)),r=Z();e.id_entrust_entrustVersInfo=`1.2.840.113533.7.65.0`;var i;(function(e){e[e.keyUpdateAllowed=1]=`keyUpdateAllowed`,e[e.newExtensions=2]=`newExtensions`,e[e.pKIXCertificate=4]=`pKIXCertificate`})(i||(e.EntrustInfoFlags=i={}));var a=class extends r.BitString{toJSON(){let e=[],t=this.toNumber();return t&i.pKIXCertificate&&e.push(`pKIXCertificate`),t&i.newExtensions&&e.push(`newExtensions`),t&i.keyUpdateAllowed&&e.push(`keyUpdateAllowed`),e}toString(){return`[${this.toJSON().join(`, `)}]`}};e.EntrustInfo=a;var o=class{entrustVers=``;entrustInfoFlags=new a;constructor(e={}){Object.assign(this,e)}};e.EntrustVersionInfo=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralString})],o.prototype,`entrustVers`,void 0),n.__decorate([(0,r.AsnProp)({type:a})],o.prototype,`entrustInfoFlags`,void 0)})),kn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectInfoAccessSyntax=e.id_pe_subjectInfoAccess=void 0;let r=(X(),t(q)),i=Z(),a=Q(),o=nn();e.id_pe_subjectInfoAccess=`${a.id_pe}.11`;let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SubjectInfoAccessSyntax=s,e.SubjectInfoAccessSyntax=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o.AccessDescription})],s)})),An=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(nn(),e),n.__exportStar(rn(),e),n.__exportStar(an(),e),n.__exportStar(sn(),e),n.__exportStar(cn(),e),n.__exportStar(un(),e),n.__exportStar(dn(),e),n.__exportStar(fn(),e),n.__exportStar(pn(),e),n.__exportStar(ln(),e),n.__exportStar(mn(),e),n.__exportStar(hn(),e),n.__exportStar(gn(),e),n.__exportStar(_n(),e),n.__exportStar(vn(),e),n.__exportStar(yn(),e),n.__exportStar(bn(),e),n.__exportStar(xn(),e),n.__exportStar(Sn(),e),n.__exportStar(Cn(),e),n.__exportStar(Tn(),e),n.__exportStar(En(),e),n.__exportStar(Dn(),e),n.__exportStar(On(),e),n.__exportStar(kn(),e)})),jn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AlgorithmIdentifier=void 0;let n=(X(),t(q)),r=Z(),i=At();var a=class e{algorithm=``;parameters;constructor(e={}){Object.assign(this,e)}isEqual(t){return t instanceof e&&t.algorithm==this.algorithm&&(t.parameters&&this.parameters&&(0,i.equal)(t.parameters,this.parameters)||t.parameters===this.parameters)}};e.AlgorithmIdentifier=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`algorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,optional:!0})],a.prototype,`parameters`,void 0)})),Mn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectPublicKeyInfo=void 0;let n=(X(),t(q)),r=Z(),i=jn();var a=class{algorithm=new i.AlgorithmIdentifier;subjectPublicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SubjectPublicKeyInfo=a,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],a.prototype,`algorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],a.prototype,`subjectPublicKey`,void 0)})),Nn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Time=void 0;let n=(X(),t(q)),r=Z(),i=class{utcTime;generalTime;constructor(e){if(e)if(typeof e==`string`||typeof e==`number`||e instanceof Date){let t=new Date(e);t.setMilliseconds(0),t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw Error(`Cannot get time from CHOICE object`);return e}};e.Time=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.UTCTime})],i.prototype,`utcTime`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime})],i.prototype,`generalTime`,void 0),e.Time=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),Pn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Validity=void 0;let n=(X(),t(q)),r=Z(),i=Nn();var a=class{notBefore=new i.Time(new Date);notAfter=new i.Time(new Date);constructor(e){e&&(this.notBefore=new i.Time(e.notBefore),this.notAfter=new i.Time(e.notAfter))}};e.Validity=a,n.__decorate([(0,r.AsnProp)({type:i.Time})],a.prototype,`notBefore`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Time})],a.prototype,`notAfter`,void 0)})),Fn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.Extensions=e.Extension=void 0;let r=(X(),t(q)),i=Z();var a=class e{static CRITICAL=!1;extnID=``;critical=e.CRITICAL;extnValue=new i.OctetString;constructor(e={}){Object.assign(this,e)}};e.Extension=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`extnID`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Boolean,defaultValue:a.CRITICAL})],a.prototype,`critical`,void 0),r.__decorate([(0,i.AsnProp)({type:i.OctetString})],a.prototype,`extnValue`,void 0);let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.Extensions=o,e.Extensions=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a})],o)})),In=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Version=void 0;var t;(function(e){e[e.v1=0]=`v1`,e[e.v2=1]=`v2`,e[e.v3=2]=`v3`})(t||(e.Version=t={}))})),Ln=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TBSCertificate=void 0;let n=(X(),t(q)),r=Z(),i=jn(),a=en(),o=Mn(),s=Pn(),c=Fn(),l=In();var u=class{version=l.Version.v1;serialNumber=new ArrayBuffer(0);signature=new i.AlgorithmIdentifier;issuer=new a.Name;validity=new s.Validity;subject=new a.Name;subjectPublicKeyInfo=new o.SubjectPublicKeyInfo;issuerUniqueID;subjectUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};e.TBSCertificate=u,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:0,defaultValue:l.Version.v1})],u.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],u.prototype,`serialNumber`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],u.prototype,`signature`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Name})],u.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:s.Validity})],u.prototype,`validity`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Name})],u.prototype,`subject`,void 0),n.__decorate([(0,r.AsnProp)({type:o.SubjectPublicKeyInfo})],u.prototype,`subjectPublicKeyInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,context:1,implicit:!0,optional:!0})],u.prototype,`issuerUniqueID`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,context:2,implicit:!0,optional:!0})],u.prototype,`subjectUniqueID`,void 0),n.__decorate([(0,r.AsnProp)({type:c.Extensions,context:3,optional:!0})],u.prototype,`extensions`,void 0)})),Rn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Certificate=void 0;let n=(X(),t(q)),r=Z(),i=jn(),a=Ln();var o=class{tbsCertificate=new a.TBSCertificate;tbsCertificateRaw;signatureAlgorithm=new i.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.Certificate=o,n.__decorate([(0,r.AsnProp)({type:a.TBSCertificate,raw:!0})],o.prototype,`tbsCertificate`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`signatureValue`,void 0)})),zn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TBSCertList=e.RevokedCertificate=void 0;let n=(X(),t(q)),r=Z(),i=jn(),a=en(),o=Nn(),s=Fn();var c=class{userCertificate=new ArrayBuffer(0);revocationDate=new o.Time;crlEntryExtensions;constructor(e={}){Object.assign(this,e)}};e.RevokedCertificate=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],c.prototype,`userCertificate`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Time})],c.prototype,`revocationDate`,void 0),n.__decorate([(0,r.AsnProp)({type:s.Extension,optional:!0,repeated:`sequence`})],c.prototype,`crlEntryExtensions`,void 0);var l=class{version;signature=new i.AlgorithmIdentifier;issuer=new a.Name;thisUpdate=new o.Time;nextUpdate;revokedCertificates;crlExtensions;constructor(e={}){Object.assign(this,e)}};e.TBSCertList=l,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,optional:!0})],l.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],l.prototype,`signature`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Name})],l.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Time})],l.prototype,`thisUpdate`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Time,optional:!0})],l.prototype,`nextUpdate`,void 0),n.__decorate([(0,r.AsnProp)({type:c,repeated:`sequence`,optional:!0})],l.prototype,`revokedCertificates`,void 0),n.__decorate([(0,r.AsnProp)({type:s.Extension,optional:!0,context:0,repeated:`sequence`})],l.prototype,`crlExtensions`,void 0)})),Bn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateList=void 0;let n=(X(),t(q)),r=Z(),i=jn(),a=zn();var o=class{tbsCertList=new a.TBSCertList;tbsCertListRaw;signatureAlgorithm=new i.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertificateList=o,n.__decorate([(0,r.AsnProp)({type:a.TBSCertList,raw:!0})],o.prototype,`tbsCertList`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`signature`,void 0)})),$=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(An(),e),n.__exportStar(jn(),e),n.__exportStar(wn(),e),n.__exportStar(Rn(),e),n.__exportStar(Bn(),e),n.__exportStar(Fn(),e),n.__exportStar(tn(),e),n.__exportStar(on(),e),n.__exportStar(en(),e),n.__exportStar(Q(),e),n.__exportStar(Mn(),e),n.__exportStar(zn(),e),n.__exportStar(Ln(),e),n.__exportStar(Nn(),e),n.__exportStar(In(),e),n.__exportStar(Pn(),e)})),Vn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuerAndSerialNumber=void 0;let n=(X(),t(q)),r=Z(),i=$();var a=class{issuer=new i.Name;serialNumber=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.IssuerAndSerialNumber=a,n.__decorate([(0,r.AsnProp)({type:i.Name})],a.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`serialNumber`,void 0)})),Hn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SignerIdentifier=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=Vn(),o=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.SignerIdentifier=o,n.__decorate([(0,r.AsnProp)({type:i.SubjectKeyIdentifier,context:0,implicit:!0})],o.prototype,`subjectKeyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:a.IssuerAndSerialNumber})],o.prototype,`issuerAndSerialNumber`,void 0),e.SignerIdentifier=o=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],o)})),Un=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyDerivationAlgorithmIdentifier=e.MessageAuthenticationCodeAlgorithm=e.ContentEncryptionAlgorithmIdentifier=e.KeyEncryptionAlgorithmIdentifier=e.SignatureAlgorithmIdentifier=e.DigestAlgorithmIdentifier=e.CMSVersion=void 0;let n=(X(),t(q)),r=$(),i=Z();var a;(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`})(a||(e.CMSVersion=a={}));let o=class extends r.AlgorithmIdentifier{};e.DigestAlgorithmIdentifier=o,e.DigestAlgorithmIdentifier=o=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],o);let s=class extends r.AlgorithmIdentifier{};e.SignatureAlgorithmIdentifier=s,e.SignatureAlgorithmIdentifier=s=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],s);let c=class extends r.AlgorithmIdentifier{};e.KeyEncryptionAlgorithmIdentifier=c,e.KeyEncryptionAlgorithmIdentifier=c=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],c);let l=class extends r.AlgorithmIdentifier{};e.ContentEncryptionAlgorithmIdentifier=l,e.ContentEncryptionAlgorithmIdentifier=l=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],l);let u=class extends r.AlgorithmIdentifier{};e.MessageAuthenticationCodeAlgorithm=u,e.MessageAuthenticationCodeAlgorithm=u=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],u);let d=class extends r.AlgorithmIdentifier{};e.KeyDerivationAlgorithmIdentifier=d,e.KeyDerivationAlgorithmIdentifier=d=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],d)})),Wn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;let n=(X(),t(q)),r=Z();var i=class{attrType=``;attrValues=[];constructor(e={}){Object.assign(this,e)}};e.Attribute=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`attrType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,repeated:`set`})],i.prototype,`attrValues`,void 0)})),Gn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SignerInfos=e.SignerInfo=void 0;let r=(X(),t(q)),i=Z(),a=Hn(),o=Un(),s=Wn();var c=class{version=o.CMSVersion.v0;sid=new a.SignerIdentifier;digestAlgorithm=new o.DigestAlgorithmIdentifier;signedAttrs;signedAttrsRaw;signatureAlgorithm=new o.SignatureAlgorithmIdentifier;signature=new i.OctetString;unsignedAttrs;constructor(e={}){Object.assign(this,e)}};e.SignerInfo=c,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],c.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:a.SignerIdentifier})],c.prototype,`sid`,void 0),r.__decorate([(0,i.AsnProp)({type:o.DigestAlgorithmIdentifier})],c.prototype,`digestAlgorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:s.Attribute,repeated:`set`,context:0,implicit:!0,optional:!0,raw:!0})],c.prototype,`signedAttrs`,void 0),r.__decorate([(0,i.AsnProp)({type:o.SignatureAlgorithmIdentifier})],c.prototype,`signatureAlgorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:i.OctetString})],c.prototype,`signature`,void 0),r.__decorate([(0,i.AsnProp)({type:s.Attribute,repeated:`set`,context:1,implicit:!0,optional:!0})],c.prototype,`unsignedAttrs`,void 0);let l=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SignerInfos=l,e.SignerInfos=l=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:c})],l)})),Kn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CounterSignature=e.id_counterSignature=void 0;let n=(X(),t(q)),r=Z(),i=Gn();e.id_counterSignature=`1.2.840.113549.1.9.6`;let a=class extends i.SignerInfo{};e.CounterSignature=a,e.CounterSignature=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a)})),qn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MessageDigest=e.id_messageDigest=void 0;let t=Z();e.id_messageDigest=`1.2.840.113549.1.9.4`,e.MessageDigest=class extends t.OctetString{}})),Jn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SigningTime=e.id_signingTime=void 0;let n=(X(),t(q)),r=$(),i=Z();e.id_signingTime=`1.2.840.113549.1.9.5`;let a=class extends r.Time{};e.SigningTime=a,e.SigningTime=a=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],a)})),Yn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_contentType=void 0;let n=(X(),t(q));n.__exportStar(Kn(),e),n.__exportStar(qn(),e),n.__exportStar(Jn(),e),e.id_contentType=`1.2.840.113549.1.9.3`})),Xn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ACClearAttrs=void 0;let n=(X(),t(q)),r=Z(),i=$();var a=class{acIssuer=new i.GeneralName;acSerial=0;attrs=[];constructor(e={}){Object.assign(this,e)}};e.ACClearAttrs=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`acIssuer`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],a.prototype,`acSerial`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Attribute,repeated:`sequence`})],a.prototype,`attrs`,void 0)})),Zn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.AttrSpec=void 0;let r=(X(),t(q)),i=Z(),a=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.AttrSpec=a,e.AttrSpec=a=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:i.AsnPropTypes.ObjectIdentifier})],a)})),Qn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AAControls=void 0;let n=(X(),t(q)),r=Z(),i=Zn();var a=class{pathLenConstraint;permittedAttrs;excludedAttrs;permitUnSpecified=!0;constructor(e={}){Object.assign(this,e)}};e.AAControls=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,optional:!0})],a.prototype,`pathLenConstraint`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AttrSpec,implicit:!0,context:0,optional:!0})],a.prototype,`permittedAttrs`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AttrSpec,implicit:!0,context:1,optional:!0})],a.prototype,`excludedAttrs`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,defaultValue:!0})],a.prototype,`permitUnSpecified`,void 0)})),$n=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuerSerial=void 0;let n=(X(),t(q)),r=Z(),i=$();var a=class{issuer=new i.GeneralNames;serial=new ArrayBuffer(0);issuerUID=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.IssuerSerial=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralNames})],a.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`serial`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,optional:!0})],a.prototype,`issuerUID`,void 0)})),er=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectDigestInfo=e.DigestedObjectType=void 0;let n=(X(),t(q)),r=Z(),i=$();var a;(function(e){e[e.publicKey=0]=`publicKey`,e[e.publicKeyCert=1]=`publicKeyCert`,e[e.otherObjectTypes=2]=`otherObjectTypes`})(a||(e.DigestedObjectType=a={}));var o=class{digestedObjectType=a.publicKey;otherObjectTypeID;digestAlgorithm=new i.AlgorithmIdentifier;objectDigest=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ObjectDigestInfo=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Enumerated})],o.prototype,`digestedObjectType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier,optional:!0})],o.prototype,`otherObjectTypeID`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`digestAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`objectDigest`,void 0)})),tr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.V2Form=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=$n(),o=er();var s=class{issuerName;baseCertificateID;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};e.V2Form=s,n.__decorate([(0,r.AsnProp)({type:i.GeneralNames,optional:!0})],s.prototype,`issuerName`,void 0),n.__decorate([(0,r.AsnProp)({type:a.IssuerSerial,context:0,implicit:!0,optional:!0})],s.prototype,`baseCertificateID`,void 0),n.__decorate([(0,r.AsnProp)({type:o.ObjectDigestInfo,context:1,implicit:!0,optional:!0})],s.prototype,`objectDigestInfo`,void 0)})),nr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttCertIssuer=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=tr(),o=class{v1Form;v2Form;constructor(e={}){Object.assign(this,e)}};e.AttCertIssuer=o,n.__decorate([(0,r.AsnProp)({type:i.GeneralName,repeated:`sequence`})],o.prototype,`v1Form`,void 0),n.__decorate([(0,r.AsnProp)({type:a.V2Form,context:0,implicit:!0})],o.prototype,`v2Form`,void 0),e.AttCertIssuer=o=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],o)})),rr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttCertValidityPeriod=void 0;let n=(X(),t(q)),r=Z();var i=class{notBeforeTime=new Date;notAfterTime=new Date;constructor(e={}){Object.assign(this,e)}};e.AttCertValidityPeriod=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime})],i.prototype,`notBeforeTime`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime})],i.prototype,`notAfterTime`,void 0)})),ir=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Holder=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=$n(),o=er();var s=class{baseCertificateID;entityName;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};e.Holder=s,n.__decorate([(0,r.AsnProp)({type:a.IssuerSerial,implicit:!0,context:0,optional:!0})],s.prototype,`baseCertificateID`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralNames,implicit:!0,context:1,optional:!0})],s.prototype,`entityName`,void 0),n.__decorate([(0,r.AsnProp)({type:o.ObjectDigestInfo,implicit:!0,context:2,optional:!0})],s.prototype,`objectDigestInfo`,void 0)})),ar=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeCertificateInfo=e.AttCertVersion=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=ir(),o=nr(),s=rr();var c;(function(e){e[e.v2=1]=`v2`})(c||(e.AttCertVersion=c={}));var l=class{version=c.v2;holder=new a.Holder;issuer=new o.AttCertIssuer;signature=new i.AlgorithmIdentifier;serialNumber=new ArrayBuffer(0);attrCertValidityPeriod=new s.AttCertValidityPeriod;attributes=[];issuerUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};e.AttributeCertificateInfo=l,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],l.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Holder})],l.prototype,`holder`,void 0),n.__decorate([(0,r.AsnProp)({type:o.AttCertIssuer})],l.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],l.prototype,`signature`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],l.prototype,`serialNumber`,void 0),n.__decorate([(0,r.AsnProp)({type:s.AttCertValidityPeriod})],l.prototype,`attrCertValidityPeriod`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Attribute,repeated:`sequence`})],l.prototype,`attributes`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,optional:!0})],l.prototype,`issuerUniqueID`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Extensions,optional:!0})],l.prototype,`extensions`,void 0)})),or=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeCertificate=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=ar();var o=class{acinfo=new a.AttributeCertificateInfo;signatureAlgorithm=new i.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.AttributeCertificate=o,n.__decorate([(0,r.AsnProp)({type:a.AttributeCertificateInfo})],o.prototype,`acinfo`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`signatureValue`,void 0)})),sr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ClassList=e.ClassListFlags=void 0;let t=Z();var n;(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`})(n||(e.ClassListFlags=n={})),e.ClassList=class extends t.BitString{}})),cr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SecurityCategory=void 0;let n=(X(),t(q)),r=Z();var i=class{type=``;value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SecurityCategory=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier,implicit:!0,context:0})],i.prototype,`type`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,implicit:!0,context:1})],i.prototype,`value`,void 0)})),lr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Clearance=void 0;let n=(X(),t(q)),r=Z(),i=sr(),a=cr();var o=class{policyId=``;classList=new i.ClassList(i.ClassListFlags.unclassified);securityCategories;constructor(e={}){Object.assign(this,e)}};e.Clearance=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],o.prototype,`policyId`,void 0),n.__decorate([(0,r.AsnProp)({type:i.ClassList,defaultValue:new i.ClassList(i.ClassListFlags.unclassified)})],o.prototype,`classList`,void 0),n.__decorate([(0,r.AsnProp)({type:a.SecurityCategory,repeated:`set`})],o.prototype,`securityCategories`,void 0)})),ur=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IetfAttrSyntax=e.IetfAttrSyntaxValueChoices=void 0;let n=(X(),t(q)),r=Z(),i=$();var a=class{cotets;oid;string;constructor(e={}){Object.assign(this,e)}};e.IetfAttrSyntaxValueChoices=a,n.__decorate([(0,r.AsnProp)({type:r.OctetString})],a.prototype,`cotets`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`oid`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Utf8String})],a.prototype,`string`,void 0);var o=class{policyAuthority;values=[];constructor(e={}){Object.assign(this,e)}};e.IetfAttrSyntax=o,n.__decorate([(0,r.AsnProp)({type:i.GeneralNames,implicit:!0,context:0,optional:!0})],o.prototype,`policyAuthority`,void 0),n.__decorate([(0,r.AsnProp)({type:a,repeated:`sequence`})],o.prototype,`values`,void 0)})),dr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_at_clearance=e.id_at_role=e.id_at=e.id_aca_encAttrs=e.id_aca_group=e.id_aca_chargingIdentity=e.id_aca_accessIdentity=e.id_aca_authenticationInfo=e.id_aca=e.id_ce_targetInformation=e.id_pe_ac_proxying=e.id_pe_aaControls=e.id_pe_ac_auditIdentity=void 0;let t=$();e.id_pe_ac_auditIdentity=`${t.id_pe}.4`,e.id_pe_aaControls=`${t.id_pe}.6`,e.id_pe_ac_proxying=`${t.id_pe}.10`,e.id_ce_targetInformation=`${t.id_ce}.55`,e.id_aca=`${t.id_pkix}.10`,e.id_aca_authenticationInfo=`${e.id_aca}.1`,e.id_aca_accessIdentity=`${e.id_aca}.2`,e.id_aca_chargingIdentity=`${e.id_aca}.3`,e.id_aca_group=`${e.id_aca}.4`,e.id_aca_encAttrs=`${e.id_aca}.6`,e.id_at=`2.5.4`,e.id_at_role=`${e.id_at}.72`,e.id_at_clearance=`2.5.1.5.55`})),fr=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.Targets=e.Target=e.TargetCert=void 0;let r=(X(),t(q)),i=Z(),a=$(),o=$n(),s=er();var c=class{targetCertificate=new o.IssuerSerial;targetName;certDigestInfo;constructor(e={}){Object.assign(this,e)}};e.TargetCert=c,r.__decorate([(0,i.AsnProp)({type:o.IssuerSerial})],c.prototype,`targetCertificate`,void 0),r.__decorate([(0,i.AsnProp)({type:a.GeneralName,optional:!0})],c.prototype,`targetName`,void 0),r.__decorate([(0,i.AsnProp)({type:s.ObjectDigestInfo,optional:!0})],c.prototype,`certDigestInfo`,void 0);let l=class{targetName;targetGroup;targetCert;constructor(e={}){Object.assign(this,e)}};e.Target=l,r.__decorate([(0,i.AsnProp)({type:a.GeneralName,context:0,implicit:!0})],l.prototype,`targetName`,void 0),r.__decorate([(0,i.AsnProp)({type:a.GeneralName,context:1,implicit:!0})],l.prototype,`targetGroup`,void 0),r.__decorate([(0,i.AsnProp)({type:c,context:2,implicit:!0})],l.prototype,`targetCert`,void 0),e.Target=l=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],l);let u=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.Targets=u,e.Targets=u=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:l})],u)})),pr=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.ProxyInfo=void 0;let r=(X(),t(q)),i=Z(),a=fr(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.ProxyInfo=o,e.ProxyInfo=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.Targets})],o)})),mr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RoleSyntax=void 0;let n=(X(),t(q)),r=Z(),i=$();var a=class{roleAuthority;roleName;constructor(e={}){Object.assign(this,e)}};e.RoleSyntax=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralNames,implicit:!0,context:0,optional:!0})],a.prototype,`roleAuthority`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName,implicit:!0,context:1})],a.prototype,`roleName`,void 0)})),hr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SvceAuthInfo=void 0;let n=(X(),t(q)),r=Z(),i=$();var a=class{service=new i.GeneralName;ident=new i.GeneralName;authInfo;constructor(e={}){Object.assign(this,e)}};e.SvceAuthInfo=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`service`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`ident`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString,optional:!0})],a.prototype,`authInfo`,void 0)})),gr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(Xn(),e),n.__exportStar(Qn(),e),n.__exportStar(nr(),e),n.__exportStar(rr(),e),n.__exportStar(Zn(),e),n.__exportStar(or(),e),n.__exportStar(ar(),e),n.__exportStar(sr(),e),n.__exportStar(lr(),e),n.__exportStar(ir(),e),n.__exportStar(ur(),e),n.__exportStar($n(),e),n.__exportStar(er(),e),n.__exportStar(dr(),e),n.__exportStar(pr(),e),n.__exportStar(mr(),e),n.__exportStar(cr(),e),n.__exportStar(hr(),e),n.__exportStar(fr(),e),n.__exportStar(tr(),e)})),_r=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateSet=e.CertificateChoices=e.OtherCertificateFormat=void 0;let r=(X(),t(q)),i=Z(),a=$(),o=gr();var s=class{otherCertFormat=``;otherCert=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherCertificateFormat=s,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],s.prototype,`otherCertFormat`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any})],s.prototype,`otherCert`,void 0);let c=class{certificate;v2AttrCert;other;constructor(e={}){Object.assign(this,e)}};e.CertificateChoices=c,r.__decorate([(0,i.AsnProp)({type:a.Certificate})],c.prototype,`certificate`,void 0),r.__decorate([(0,i.AsnProp)({type:o.AttributeCertificate,context:2,implicit:!0})],c.prototype,`v2AttrCert`,void 0),r.__decorate([(0,i.AsnProp)({type:s,context:3,implicit:!0})],c.prototype,`other`,void 0),e.CertificateChoices=c=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],c);let l=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.CertificateSet=l,e.CertificateSet=l=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:c})],l)})),vr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ContentInfo=void 0;let n=(X(),t(q)),r=Z();var i=class{contentType=``;content=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ContentInfo=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`contentType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],i.prototype,`content`,void 0)})),yr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncapsulatedContentInfo=e.EncapsulatedContent=void 0;let n=(X(),t(q)),r=Z(),i=class{single;any;constructor(e={}){Object.assign(this,e)}};e.EncapsulatedContent=i,n.__decorate([(0,r.AsnProp)({type:r.OctetString})],i.prototype,`single`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],i.prototype,`any`,void 0),e.EncapsulatedContent=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i);var a=class{eContentType=``;eContent;constructor(e={}){Object.assign(this,e)}};e.EncapsulatedContentInfo=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`eContentType`,void 0),n.__decorate([(0,r.AsnProp)({type:i,context:0,optional:!0})],a.prototype,`eContent`,void 0)})),br=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncryptedContentInfo=e.EncryptedContent=void 0;let n=(X(),t(q)),r=Z(),i=Un(),a=class{value;constructedValue;constructor(e={}){Object.assign(this,e)}};e.EncryptedContent=a,n.__decorate([(0,r.AsnProp)({type:r.OctetString,context:0,implicit:!0,optional:!0})],a.prototype,`value`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString,converter:r.AsnConstructedOctetStringConverter,context:0,implicit:!0,optional:!0,repeated:`sequence`})],a.prototype,`constructedValue`,void 0),e.EncryptedContent=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],a);var o=class{contentType=``;contentEncryptionAlgorithm=new i.ContentEncryptionAlgorithmIdentifier;encryptedContent;constructor(e={}){Object.assign(this,e)}};e.EncryptedContentInfo=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],o.prototype,`contentType`,void 0),n.__decorate([(0,r.AsnProp)({type:i.ContentEncryptionAlgorithmIdentifier})],o.prototype,`contentEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:a,optional:!0})],o.prototype,`encryptedContent`,void 0)})),xr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OtherKeyAttribute=void 0;let n=(X(),t(q)),r=Z();var i=class{keyAttrId=``;keyAttr;constructor(e={}){Object.assign(this,e)}};e.OtherKeyAttribute=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`keyAttrId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,optional:!0})],i.prototype,`keyAttr`,void 0)})),Sr=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.KeyAgreeRecipientInfo=e.OriginatorIdentifierOrKey=e.OriginatorPublicKey=e.RecipientEncryptedKeys=e.RecipientEncryptedKey=e.KeyAgreeRecipientIdentifier=e.RecipientKeyIdentifier=void 0;let r=(X(),t(q)),i=Z(),a=$(),o=Un(),s=Vn(),c=xr();var l=class{subjectKeyIdentifier=new a.SubjectKeyIdentifier;date;other;constructor(e={}){Object.assign(this,e)}};e.RecipientKeyIdentifier=l,r.__decorate([(0,i.AsnProp)({type:a.SubjectKeyIdentifier})],l.prototype,`subjectKeyIdentifier`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.GeneralizedTime,optional:!0})],l.prototype,`date`,void 0),r.__decorate([(0,i.AsnProp)({type:c.OtherKeyAttribute,optional:!0})],l.prototype,`other`,void 0);let u=class{rKeyId;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.KeyAgreeRecipientIdentifier=u,r.__decorate([(0,i.AsnProp)({type:l,context:0,implicit:!0,optional:!0})],u.prototype,`rKeyId`,void 0),r.__decorate([(0,i.AsnProp)({type:s.IssuerAndSerialNumber,optional:!0})],u.prototype,`issuerAndSerialNumber`,void 0),e.KeyAgreeRecipientIdentifier=u=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],u);var d=class{rid=new u;encryptedKey=new i.OctetString;constructor(e={}){Object.assign(this,e)}};e.RecipientEncryptedKey=d,r.__decorate([(0,i.AsnProp)({type:u})],d.prototype,`rid`,void 0),r.__decorate([(0,i.AsnProp)({type:i.OctetString})],d.prototype,`encryptedKey`,void 0);let f=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RecipientEncryptedKeys=f,e.RecipientEncryptedKeys=f=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:d})],f);var p=class{algorithm=new a.AlgorithmIdentifier;publicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OriginatorPublicKey=p,r.__decorate([(0,i.AsnProp)({type:a.AlgorithmIdentifier})],p.prototype,`algorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.BitString})],p.prototype,`publicKey`,void 0);let m=class{subjectKeyIdentifier;originatorKey;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.OriginatorIdentifierOrKey=m,r.__decorate([(0,i.AsnProp)({type:a.SubjectKeyIdentifier,context:0,implicit:!0,optional:!0})],m.prototype,`subjectKeyIdentifier`,void 0),r.__decorate([(0,i.AsnProp)({type:p,context:1,implicit:!0,optional:!0})],m.prototype,`originatorKey`,void 0),r.__decorate([(0,i.AsnProp)({type:s.IssuerAndSerialNumber,optional:!0})],m.prototype,`issuerAndSerialNumber`,void 0),e.OriginatorIdentifierOrKey=m=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],m);var h=class{version=o.CMSVersion.v3;originator=new m;ukm;keyEncryptionAlgorithm=new o.KeyEncryptionAlgorithmIdentifier;recipientEncryptedKeys=new f;constructor(e={}){Object.assign(this,e)}};e.KeyAgreeRecipientInfo=h,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],h.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:m,context:0})],h.prototype,`originator`,void 0),r.__decorate([(0,i.AsnProp)({type:i.OctetString,context:1,optional:!0})],h.prototype,`ukm`,void 0),r.__decorate([(0,i.AsnProp)({type:o.KeyEncryptionAlgorithmIdentifier})],h.prototype,`keyEncryptionAlgorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:f})],h.prototype,`recipientEncryptedKeys`,void 0)})),Cr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyTransRecipientInfo=e.RecipientIdentifier=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=Un(),o=Vn(),s=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.RecipientIdentifier=s,n.__decorate([(0,r.AsnProp)({type:i.SubjectKeyIdentifier,context:0,implicit:!0})],s.prototype,`subjectKeyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:o.IssuerAndSerialNumber})],s.prototype,`issuerAndSerialNumber`,void 0),e.RecipientIdentifier=s=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],s);var c=class{version=a.CMSVersion.v0;rid=new s;keyEncryptionAlgorithm=new a.KeyEncryptionAlgorithmIdentifier;encryptedKey=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.KeyTransRecipientInfo=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],c.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:s})],c.prototype,`rid`,void 0),n.__decorate([(0,r.AsnProp)({type:a.KeyEncryptionAlgorithmIdentifier})],c.prototype,`keyEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],c.prototype,`encryptedKey`,void 0)})),wr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KEKRecipientInfo=e.KEKIdentifier=void 0;let n=(X(),t(q)),r=Z(),i=xr(),a=Un();var o=class{keyIdentifier=new r.OctetString;date;other;constructor(e={}){Object.assign(this,e)}};e.KEKIdentifier=o,n.__decorate([(0,r.AsnProp)({type:r.OctetString})],o.prototype,`keyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime,optional:!0})],o.prototype,`date`,void 0),n.__decorate([(0,r.AsnProp)({type:i.OtherKeyAttribute,optional:!0})],o.prototype,`other`,void 0);var s=class{version=a.CMSVersion.v4;kekid=new o;keyEncryptionAlgorithm=new a.KeyEncryptionAlgorithmIdentifier;encryptedKey=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.KEKRecipientInfo=s,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],s.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:o})],s.prototype,`kekid`,void 0),n.__decorate([(0,r.AsnProp)({type:a.KeyEncryptionAlgorithmIdentifier})],s.prototype,`keyEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],s.prototype,`encryptedKey`,void 0)})),Tr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PasswordRecipientInfo=void 0;let n=(X(),t(q)),r=Z(),i=Un();var a=class{version=i.CMSVersion.v0;keyDerivationAlgorithm;keyEncryptionAlgorithm=new i.KeyEncryptionAlgorithmIdentifier;encryptedKey=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.PasswordRecipientInfo=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],a.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.KeyDerivationAlgorithmIdentifier,context:0,optional:!0})],a.prototype,`keyDerivationAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:i.KeyEncryptionAlgorithmIdentifier})],a.prototype,`keyEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],a.prototype,`encryptedKey`,void 0)})),Er=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RecipientInfo=e.OtherRecipientInfo=void 0;let n=(X(),t(q)),r=Z(),i=Sr(),a=Cr(),o=wr(),s=Tr();var c=class{oriType=``;oriValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherRecipientInfo=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],c.prototype,`oriType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],c.prototype,`oriValue`,void 0);let l=class{ktri;kari;kekri;pwri;ori;constructor(e={}){Object.assign(this,e)}};e.RecipientInfo=l,n.__decorate([(0,r.AsnProp)({type:a.KeyTransRecipientInfo,optional:!0})],l.prototype,`ktri`,void 0),n.__decorate([(0,r.AsnProp)({type:i.KeyAgreeRecipientInfo,context:1,implicit:!0,optional:!0})],l.prototype,`kari`,void 0),n.__decorate([(0,r.AsnProp)({type:o.KEKRecipientInfo,context:2,implicit:!0,optional:!0})],l.prototype,`kekri`,void 0),n.__decorate([(0,r.AsnProp)({type:s.PasswordRecipientInfo,context:3,implicit:!0,optional:!0})],l.prototype,`pwri`,void 0),n.__decorate([(0,r.AsnProp)({type:c,context:4,implicit:!0,optional:!0})],l.prototype,`ori`,void 0),e.RecipientInfo=l=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],l)})),Dr=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.RecipientInfos=void 0;let r=(X(),t(q)),i=Z(),a=Er(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RecipientInfos=o,e.RecipientInfos=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:a.RecipientInfo})],o)})),Or=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.RevocationInfoChoices=e.RevocationInfoChoice=e.OtherRevocationInfoFormat=e.id_ri_scvp=e.id_ri_ocsp_response=e.id_ri=void 0;let r=(X(),t(q)),i=Z();e.id_ri=`${$().id_pkix}.16`,e.id_ri_ocsp_response=`${e.id_ri}.2`,e.id_ri_scvp=`${e.id_ri}.4`;var a=class{otherRevInfoFormat=``;otherRevInfo=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherRevocationInfoFormat=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`otherRevInfoFormat`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any})],a.prototype,`otherRevInfo`,void 0);let o=class{other=new a;constructor(e={}){Object.assign(this,e)}};e.RevocationInfoChoice=o,r.__decorate([(0,i.AsnProp)({type:a,context:1,implicit:!0})],o.prototype,`other`,void 0),e.RevocationInfoChoice=o=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],o);let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RevocationInfoChoices=s,e.RevocationInfoChoices=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:o})],s)})),kr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OriginatorInfo=void 0;let n=(X(),t(q)),r=Z(),i=_r(),a=Or();var o=class{certs;crls;constructor(e={}){Object.assign(this,e)}};e.OriginatorInfo=o,n.__decorate([(0,r.AsnProp)({type:i.CertificateSet,context:0,implicit:!0,optional:!0})],o.prototype,`certs`,void 0),n.__decorate([(0,r.AsnProp)({type:a.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],o.prototype,`crls`,void 0)})),Ar=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.EnvelopedData=e.UnprotectedAttributes=void 0;let r=(X(),t(q)),i=Z(),a=Un(),o=Wn(),s=Dr(),c=kr(),l=br(),u=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.UnprotectedAttributes=u,e.UnprotectedAttributes=u=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:o.Attribute})],u);var d=class{version=a.CMSVersion.v0;originatorInfo;recipientInfos=new s.RecipientInfos;encryptedContentInfo=new l.EncryptedContentInfo;unprotectedAttrs;constructor(e={}){Object.assign(this,e)}};e.EnvelopedData=d,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],d.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:c.OriginatorInfo,context:0,implicit:!0,optional:!0})],d.prototype,`originatorInfo`,void 0),r.__decorate([(0,i.AsnProp)({type:s.RecipientInfos})],d.prototype,`recipientInfos`,void 0),r.__decorate([(0,i.AsnProp)({type:l.EncryptedContentInfo})],d.prototype,`encryptedContentInfo`,void 0),r.__decorate([(0,i.AsnProp)({type:u,context:1,implicit:!0,optional:!0})],d.prototype,`unprotectedAttrs`,void 0)})),jr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_authData=e.id_encryptedData=e.id_digestedData=e.id_envelopedData=e.id_signedData=e.id_data=e.id_ct_contentInfo=void 0,e.id_ct_contentInfo=`1.2.840.113549.1.9.16.1.6`,e.id_data=`1.2.840.113549.1.7.1`,e.id_signedData=`1.2.840.113549.1.7.2`,e.id_envelopedData=`1.2.840.113549.1.7.3`,e.id_digestedData=`1.2.840.113549.1.7.5`,e.id_encryptedData=`1.2.840.113549.1.7.6`,e.id_authData=`1.2.840.113549.1.9.16.1.2`})),Mr=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SignedData=e.DigestAlgorithmIdentifiers=void 0;let r=(X(),t(q)),i=Z(),a=_r(),o=Un(),s=yr(),c=Or(),l=Gn(),u=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.DigestAlgorithmIdentifiers=u,e.DigestAlgorithmIdentifiers=u=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:o.DigestAlgorithmIdentifier})],u);var d=class{version=o.CMSVersion.v0;digestAlgorithms=new u;encapContentInfo=new s.EncapsulatedContentInfo;certificates;crls;signerInfos=new l.SignerInfos;constructor(e={}){Object.assign(this,e)}};e.SignedData=d,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],d.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:u})],d.prototype,`digestAlgorithms`,void 0),r.__decorate([(0,i.AsnProp)({type:s.EncapsulatedContentInfo})],d.prototype,`encapContentInfo`,void 0),r.__decorate([(0,i.AsnProp)({type:a.CertificateSet,context:0,implicit:!0,optional:!0})],d.prototype,`certificates`,void 0),r.__decorate([(0,i.AsnProp)({type:c.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],d.prototype,`crls`,void 0),r.__decorate([(0,i.AsnProp)({type:l.SignerInfos})],d.prototype,`signerInfos`,void 0)})),Nr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(Yn(),e),n.__exportStar(Wn(),e),n.__exportStar(_r(),e),n.__exportStar(vr(),e),n.__exportStar(yr(),e),n.__exportStar(br(),e),n.__exportStar(Ar(),e),n.__exportStar(Vn(),e),n.__exportStar(wr(),e),n.__exportStar(Sr(),e),n.__exportStar(Cr(),e),n.__exportStar(jr(),e),n.__exportStar(kr(),e),n.__exportStar(Tr(),e),n.__exportStar(Er(),e),n.__exportStar(Dr(),e),n.__exportStar(Or(),e),n.__exportStar(Mr(),e),n.__exportStar(Hn(),e),n.__exportStar(Gn(),e),n.__exportStar(Un(),e)})),Pr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_sect571r1=e.id_sect571k1=e.id_secp521r1=e.id_sect409r1=e.id_sect409k1=e.id_secp384r1=e.id_sect283r1=e.id_sect283k1=e.id_secp256r1=e.id_sect233r1=e.id_sect233k1=e.id_secp224r1=e.id_sect163r2=e.id_sect163k1=e.id_secp192r1=e.id_ecdsaWithSHA512=e.id_ecdsaWithSHA384=e.id_ecdsaWithSHA256=e.id_ecdsaWithSHA224=e.id_ecdsaWithSHA1=e.id_ecMQV=e.id_ecDH=e.id_ecPublicKey=void 0,e.id_ecPublicKey=`1.2.840.10045.2.1`,e.id_ecDH=`1.3.132.1.12`,e.id_ecMQV=`1.3.132.1.13`,e.id_ecdsaWithSHA1=`1.2.840.10045.4.1`,e.id_ecdsaWithSHA224=`1.2.840.10045.4.3.1`,e.id_ecdsaWithSHA256=`1.2.840.10045.4.3.2`,e.id_ecdsaWithSHA384=`1.2.840.10045.4.3.3`,e.id_ecdsaWithSHA512=`1.2.840.10045.4.3.4`,e.id_secp192r1=`1.2.840.10045.3.1.1`,e.id_sect163k1=`1.3.132.0.1`,e.id_sect163r2=`1.3.132.0.15`,e.id_secp224r1=`1.3.132.0.33`,e.id_sect233k1=`1.3.132.0.26`,e.id_sect233r1=`1.3.132.0.27`,e.id_secp256r1=`1.2.840.10045.3.1.7`,e.id_sect283k1=`1.3.132.0.16`,e.id_sect283r1=`1.3.132.0.17`,e.id_secp384r1=`1.3.132.0.34`,e.id_sect409k1=`1.3.132.0.36`,e.id_sect409r1=`1.3.132.0.37`,e.id_secp521r1=`1.3.132.0.35`,e.id_sect571k1=`1.3.132.0.38`,e.id_sect571r1=`1.3.132.0.39`})),Fr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ecdsaWithSHA512=e.ecdsaWithSHA384=e.ecdsaWithSHA256=e.ecdsaWithSHA224=e.ecdsaWithSHA1=void 0;let n=(X(),t(q)),r=$(),i=n.__importStar(Pr());function a(e){return new r.AlgorithmIdentifier({algorithm:e})}e.ecdsaWithSHA1=a(i.id_ecdsaWithSHA1),e.ecdsaWithSHA224=a(i.id_ecdsaWithSHA224),e.ecdsaWithSHA256=a(i.id_ecdsaWithSHA256),e.ecdsaWithSHA384=a(i.id_ecdsaWithSHA384),e.ecdsaWithSHA512=a(i.id_ecdsaWithSHA512)})),Ir=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SpecifiedECDomain=e.ECPVer=e.Curve=e.FieldElement=e.ECPoint=e.FieldID=void 0;let n=(X(),t(q)),r=Z(),i=class{fieldType;parameters;constructor(e={}){Object.assign(this,e)}};e.FieldID=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`fieldType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],i.prototype,`parameters`,void 0),e.FieldID=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],i);var a=class extends r.OctetString{};e.ECPoint=a,e.FieldElement=class extends r.OctetString{};let o=class{a;b;seed;constructor(e={}){Object.assign(this,e)}};e.Curve=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.OctetString})],o.prototype,`a`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.OctetString})],o.prototype,`b`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,optional:!0})],o.prototype,`seed`,void 0),e.Curve=o=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],o);var s;(function(e){e[e.ecpVer1=1]=`ecpVer1`})(s||(e.ECPVer=s={}));let c=class{version=s.ecpVer1;fieldID;curve;base;order;cofactor;constructor(e={}){Object.assign(this,e)}};e.SpecifiedECDomain=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],c.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i})],c.prototype,`fieldID`,void 0),n.__decorate([(0,r.AsnProp)({type:o})],c.prototype,`curve`,void 0),n.__decorate([(0,r.AsnProp)({type:a})],c.prototype,`base`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],c.prototype,`order`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,optional:!0})],c.prototype,`cofactor`,void 0),e.SpecifiedECDomain=c=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],c)})),Lr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECParameters=void 0;let n=(X(),t(q)),r=Z(),i=Ir(),a=class{namedCurve;implicitCurve;specifiedCurve;constructor(e={}){Object.assign(this,e)}};e.ECParameters=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`namedCurve`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Null})],a.prototype,`implicitCurve`,void 0),n.__decorate([(0,r.AsnProp)({type:i.SpecifiedECDomain})],a.prototype,`specifiedCurve`,void 0),e.ECParameters=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],a)})),Rr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECPrivateKey=void 0;let n=(X(),t(q)),r=Z(),i=Lr();var a=class{version=1;privateKey=new r.OctetString;parameters;publicKey;constructor(e={}){Object.assign(this,e)}};e.ECPrivateKey=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],a.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],a.prototype,`privateKey`,void 0),n.__decorate([(0,r.AsnProp)({type:i.ECParameters,context:0,optional:!0})],a.prototype,`parameters`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,context:1,optional:!0})],a.prototype,`publicKey`,void 0)})),zr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECDSASigValue=void 0;let n=(X(),t(q)),r=Z();var i=class{r=new ArrayBuffer(0);s=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ECDSASigValue=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`r`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`s`,void 0)})),Br=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(Fr(),e),n.__exportStar(Lr(),e),n.__exportStar(Rr(),e),n.__exportStar(zr(),e),n.__exportStar(Pr(),e),n.__exportStar(Ir(),e)})),Vr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_mgf1=e.id_md5=e.id_md2=e.id_sha512_256=e.id_sha512_224=e.id_sha512=e.id_sha384=e.id_sha256=e.id_sha224=e.id_sha1=e.id_sha512_256WithRSAEncryption=e.id_sha512_224WithRSAEncryption=e.id_sha512WithRSAEncryption=e.id_sha384WithRSAEncryption=e.id_sha256WithRSAEncryption=e.id_ssha224WithRSAEncryption=e.id_sha224WithRSAEncryption=e.id_sha1WithRSAEncryption=e.id_md5WithRSAEncryption=e.id_md2WithRSAEncryption=e.id_RSASSA_PSS=e.id_pSpecified=e.id_RSAES_OAEP=e.id_rsaEncryption=e.id_pkcs_1=void 0,e.id_pkcs_1=`1.2.840.113549.1.1`,e.id_rsaEncryption=`${e.id_pkcs_1}.1`,e.id_RSAES_OAEP=`${e.id_pkcs_1}.7`,e.id_pSpecified=`${e.id_pkcs_1}.9`,e.id_RSASSA_PSS=`${e.id_pkcs_1}.10`,e.id_md2WithRSAEncryption=`${e.id_pkcs_1}.2`,e.id_md5WithRSAEncryption=`${e.id_pkcs_1}.4`,e.id_sha1WithRSAEncryption=`${e.id_pkcs_1}.5`,e.id_sha224WithRSAEncryption=`${e.id_pkcs_1}.14`,e.id_ssha224WithRSAEncryption=e.id_sha224WithRSAEncryption,e.id_sha256WithRSAEncryption=`${e.id_pkcs_1}.11`,e.id_sha384WithRSAEncryption=`${e.id_pkcs_1}.12`,e.id_sha512WithRSAEncryption=`${e.id_pkcs_1}.13`,e.id_sha512_224WithRSAEncryption=`${e.id_pkcs_1}.15`,e.id_sha512_256WithRSAEncryption=`${e.id_pkcs_1}.16`,e.id_sha1=`1.3.14.3.2.26`,e.id_sha224=`2.16.840.1.101.3.4.2.4`,e.id_sha256=`2.16.840.1.101.3.4.2.1`,e.id_sha384=`2.16.840.1.101.3.4.2.2`,e.id_sha512=`2.16.840.1.101.3.4.2.3`,e.id_sha512_224=`2.16.840.1.101.3.4.2.5`,e.id_sha512_256=`2.16.840.1.101.3.4.2.6`,e.id_md2=`1.2.840.113549.2.2`,e.id_md5=`1.2.840.113549.2.5`,e.id_mgf1=`${e.id_pkcs_1}.8`})),Hr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha512_256WithRSAEncryption=e.sha512_224WithRSAEncryption=e.sha512WithRSAEncryption=e.sha384WithRSAEncryption=e.sha256WithRSAEncryption=e.sha224WithRSAEncryption=e.sha1WithRSAEncryption=e.md5WithRSAEncryption=e.md2WithRSAEncryption=e.rsaEncryption=e.pSpecifiedEmpty=e.mgf1SHA1=e.sha512_256=e.sha512_224=e.sha512=e.sha384=e.sha256=e.sha224=e.sha1=e.md4=e.md2=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=n.__importStar(Vr());function o(e){return new i.AlgorithmIdentifier({algorithm:e,parameters:null})}e.md2=o(a.id_md2),e.md4=o(a.id_md5),e.sha1=o(a.id_sha1),e.sha224=o(a.id_sha224),e.sha256=o(a.id_sha256),e.sha384=o(a.id_sha384),e.sha512=o(a.id_sha512),e.sha512_224=o(a.id_sha512_224),e.sha512_256=o(a.id_sha512_256),e.mgf1SHA1=new i.AlgorithmIdentifier({algorithm:a.id_mgf1,parameters:r.AsnConvert.serialize(e.sha1)}),e.pSpecifiedEmpty=new i.AlgorithmIdentifier({algorithm:a.id_pSpecified,parameters:r.AsnConvert.serialize(r.AsnOctetStringConverter.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))}),e.rsaEncryption=o(a.id_rsaEncryption),e.md2WithRSAEncryption=o(a.id_md2WithRSAEncryption),e.md5WithRSAEncryption=o(a.id_md5WithRSAEncryption),e.sha1WithRSAEncryption=o(a.id_sha1WithRSAEncryption),e.sha224WithRSAEncryption=o(a.id_sha512_224WithRSAEncryption),e.sha256WithRSAEncryption=o(a.id_sha512_256WithRSAEncryption),e.sha384WithRSAEncryption=o(a.id_sha384WithRSAEncryption),e.sha512WithRSAEncryption=o(a.id_sha512WithRSAEncryption),e.sha512_224WithRSAEncryption=o(a.id_sha512_224WithRSAEncryption),e.sha512_256WithRSAEncryption=o(a.id_sha512_256WithRSAEncryption)})),Ur=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAES_OAEP=e.RsaEsOaepParams=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=Vr(),o=Hr();var s=class{hashAlgorithm=new i.AlgorithmIdentifier(o.sha1);maskGenAlgorithm=new i.AlgorithmIdentifier({algorithm:a.id_mgf1,parameters:r.AsnConvert.serialize(o.sha1)});pSourceAlgorithm=new i.AlgorithmIdentifier(o.pSpecifiedEmpty);constructor(e={}){Object.assign(this,e)}};e.RsaEsOaepParams=s,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:0,defaultValue:o.sha1})],s.prototype,`hashAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:1,defaultValue:o.mgf1SHA1})],s.prototype,`maskGenAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:2,defaultValue:o.pSpecifiedEmpty})],s.prototype,`pSourceAlgorithm`,void 0),e.RSAES_OAEP=new i.AlgorithmIdentifier({algorithm:a.id_RSAES_OAEP,parameters:r.AsnConvert.serialize(new s)})})),Wr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSASSA_PSS=e.RsaSaPssParams=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=Vr(),o=Hr();var s=class{hashAlgorithm=new i.AlgorithmIdentifier(o.sha1);maskGenAlgorithm=new i.AlgorithmIdentifier({algorithm:a.id_mgf1,parameters:r.AsnConvert.serialize(o.sha1)});saltLength=20;trailerField=1;constructor(e={}){Object.assign(this,e)}};e.RsaSaPssParams=s,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:0,defaultValue:o.sha1})],s.prototype,`hashAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:1,defaultValue:o.mgf1SHA1})],s.prototype,`maskGenAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:2,defaultValue:20})],s.prototype,`saltLength`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:3,defaultValue:1})],s.prototype,`trailerField`,void 0),e.RSASSA_PSS=new i.AlgorithmIdentifier({algorithm:a.id_RSASSA_PSS,parameters:r.AsnConvert.serialize(new s)})})),Gr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DigestInfo=void 0;let n=(X(),t(q)),r=$(),i=Z();var a=class{digestAlgorithm=new r.AlgorithmIdentifier;digest=new i.OctetString;constructor(e={}){Object.assign(this,e)}};e.DigestInfo=a,n.__decorate([(0,i.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`digestAlgorithm`,void 0),n.__decorate([(0,i.AsnProp)({type:i.OctetString})],a.prototype,`digest`,void 0)})),Kr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(Ur(),e),n.__exportStar(Wr(),e),n.__exportStar(Gr(),e)})),qr=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.OtherPrimeInfos=e.OtherPrimeInfo=void 0;let r=(X(),t(q)),i=Z();var a=class{prime=new ArrayBuffer(0);exponent=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherPrimeInfo=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,converter:i.AsnIntegerArrayBufferConverter})],a.prototype,`prime`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,converter:i.AsnIntegerArrayBufferConverter})],a.prototype,`exponent`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,converter:i.AsnIntegerArrayBufferConverter})],a.prototype,`coefficient`,void 0);let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.OtherPrimeInfos=o,e.OtherPrimeInfos=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a})],o)})),Jr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAPrivateKey=void 0;let n=(X(),t(q)),r=Z(),i=qr();var a=class{version=0;modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);privateExponent=new ArrayBuffer(0);prime1=new ArrayBuffer(0);prime2=new ArrayBuffer(0);exponent1=new ArrayBuffer(0);exponent2=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);otherPrimeInfos;constructor(e={}){Object.assign(this,e)}};e.RSAPrivateKey=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],a.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`modulus`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`publicExponent`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`privateExponent`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`prime1`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`prime2`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`exponent1`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`exponent2`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`coefficient`,void 0),n.__decorate([(0,r.AsnProp)({type:i.OtherPrimeInfos,optional:!0})],a.prototype,`otherPrimeInfos`,void 0)})),Yr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAPublicKey=void 0;let n=(X(),t(q)),r=Z();var i=class{modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.RSAPublicKey=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`modulus`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`publicExponent`,void 0)})),Xr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(Kr(),e),n.__exportStar(Hr(),e),n.__exportStar(Vr(),e),n.__exportStar(qr(),e),n.__exportStar(Jr(),e),n.__exportStar(Yr(),e)})),Zr=o({__assign:()=>xi,__asyncDelegator:()=>pi,__asyncGenerator:()=>fi,__asyncValues:()=>mi,__await:()=>di,__awaiter:()=>ri,__classPrivateFieldGet:()=>vi,__classPrivateFieldSet:()=>yi,__createBinding:()=>ai,__decorate:()=>ei,__exportStar:()=>oi,__extends:()=>Qr,__generator:()=>ii,__importDefault:()=>_i,__importStar:()=>gi,__makeTemplateObject:()=>hi,__metadata:()=>ni,__param:()=>ti,__read:()=>ci,__rest:()=>$r,__spread:()=>li,__spreadArrays:()=>ui,__values:()=>si});
88
+ `,r=[];for(let t=0;t<a.length;t+=e)r.push(p(a.slice(t,t+e),n.group));o=r.join(t)}else o=p(a,n.group);return`${n.prefix??``}${o}`}function _(e,t={}){let n=m(e,t),r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2)r[e/2]=Number.parseInt(n.slice(e,e+2),16);return r}function v(e,t={}){let n=m(e,t);return{bytes:_(n),format:d(e),normalized:n}}function y(e,t){return g(e,t)}e.formats={compact:Object.freeze({}),upper:Object.freeze({case:`upper`}),colon:Object.freeze({group:{size:1,separator:`:`}}),colonUpper:Object.freeze({case:`upper`,group:{size:1,separator:`:`}}),groupsOf4:Object.freeze({group:{size:4,separator:` `}}),prefixed:Object.freeze({prefix:`0x`})},e.hex={encode:g,decode:_,format:y,formats:e.formats,is:h,normalize:m,parse:v}})),vt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utf8=void 0,e.encode=n,e.decode=r;let t=q();function n(e){return new TextEncoder().encode(e)}function r(e){return new TextDecoder(`utf-8`,{fatal:!1}).decode((0,t.toUint8Array)(e))}e.utf8={encode:n,decode:r}})),yt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utf16=void 0,e.encode=n,e.decode=r;let t=q();function n(e,t={}){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t.littleEndian??!1);return new Uint8Array(n)}function r(e,n={}){let r=(0,t.toArrayBuffer)(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2)a+=String.fromCharCode(i.getUint16(e,n.littleEndian??!1));return a}e.utf16={encode:n,decode:r}})),bt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64=void 0,e.normalize=a,e.pad=o,e.is=s,e.encode=c,e.decode=l;let t=q(),n=gt(),r=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function i(){return globalThis.Buffer}function a(e){return e.replace(/[\n\r\t ]/g,``)}function o(e){let t=e.length%4;return t?e+`=`.repeat(4-t):e}function s(e){if(typeof e!=`string`)return!1;let t=a(e);return t===``||r.test(t)}function c(e,r){let a=(0,t.toUint8Array)(e),o=i();return o?o.from(a).toString(`base64`):btoa((0,n.encode)(a))}function l(e,t){let r=a(e);if(!s(r))throw TypeError(`Input is not valid Base64 text`);let o=i();return o?new Uint8Array(o.from(r,`base64`)):(0,n.decode)(atob(r))}e.base64={encode:c,decode:l,is:s,normalize:a,pad:o}})),xt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64url=void 0,e.normalize=r,e.is=i,e.encode=a,e.decode=o;let t=bt(),n=/^[A-Za-z0-9_-]*$/;function r(e){return e.replace(/[\n\r\t ]/g,``)}function i(e){return typeof e==`string`&&n.test(r(e))}function a(e,n){return t.base64.encode(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}function o(e,n){let a=r(e);if(!i(a))throw TypeError(`Input is not valid Base64Url text`);return t.base64.decode(t.base64.pad(a.replace(/-/g,`+`).replace(/_/g,`/`)))}e.base64url={encode:a,decode:o,is:i,normalize:r}})),St=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64url=e.base64=e.utf16=e.utf8=e.hex=e.binary=void 0;let n=(K(),t(L));e.binary=n.__importStar(gt()),e.hex=n.__importStar(_t()),e.utf8=n.__importStar(vt()),e.utf16=n.__importStar(yt()),e.base64=n.__importStar(bt()),e.base64url=n.__importStar(xt())})),Ct=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IpConverter=void 0;let t=St();e.IpConverter=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let t=e.split(`.`);if(t.length!==4)throw Error(`Invalid IPv4 address`);return t.map(e=>{let t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw Error(`Invalid IPv4 address part`);return t})}static parseIPv6(e){let t=this.expandIPv6(e).split(`:`);if(t.length!==8)throw Error(`Invalid IPv6 address`);return t.reduce((e,t)=>{let n=parseInt(t,16);if(isNaN(n)||n<0||n>65535)throw Error(`Invalid IPv6 address part`);return e.push(n>>8&255),e.push(n&255),e},[])}static expandIPv6(e){if(!e.includes(`::`))return e;let t=e.split(`::`);if(t.length>2)throw Error(`Invalid IPv6 address`);let n=t[0]?t[0].split(`:`):[],r=t[1]?t[1].split(`:`):[],i=8-(n.length+r.length);if(i<0)throw Error(`Invalid IPv6 address`);return[...n,...Array(i).fill(`0`),...r].join(`:`)}static formatIPv6(e){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(t.join(`:`))}static compressIPv6(e){let t=e.split(`:`),n=-1,r=0,i=-1,a=0;for(let e=0;e<t.length;e++)t[e]===`0`?(i===-1&&(i=e),a++):(a>r&&(n=i,r=a),i=-1,a=0);return a>r&&(n=i,r=a),r>1?`${t.slice(0,n).join(`:`)}::${t.slice(n+r).join(`:`)}`:e}static parseCIDR(e){let[t,n]=e.split(`/`),r=parseInt(n,10);if(this.isIPv4(t)){if(r<0||r>32)throw Error(`Invalid IPv4 prefix length`);return[this.parseIPv4(t),r]}if(r<0||r>128)throw Error(`Invalid IPv6 prefix length`);return[this.parseIPv6(t),r]}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return`::/0`;if(e.length!==16)return e;let t=parseInt(e.slice(8),16).toString(2).split(``).reduce((e,t)=>e+ +t,0),n=e.slice(0,8).replace(/(.{2})/g,e=>`${parseInt(e,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){let n=new Uint8Array(e);if(n.length===4)return Array.from(n).join(`.`);if(n.length===16)return this.formatIPv6(n);if(n.length===8||n.length===32){let e=n.length/2,t=n.slice(0,e),r=n.slice(e);if(n.every(e=>e===0))return n.length===8?`0.0.0.0/0`:`::/0`;let i=r.reduce((e,t)=>e+(t.toString(2).match(/1/g)||[]).length,0);return n.length===8?`${Array.from(t).join(`.`)}/${i}`:`${this.formatIPv6(t)}/${i}`}return this.decodeIP(t.hex.encode(e))}static fromString(e){if(e.includes(`/`)){let[t,n]=this.parseCIDR(e),r=new Uint8Array(t.length),i=n;for(let e=0;e<r.length;e++)i>=8?(r[e]=255,i-=8):i>0&&(r[e]=255<<8-i,i=0);let a=new Uint8Array(t.length*2);return a.set(t,0),a.set(r,t.length),a.buffer}let t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}}})),wt=s((e=>{var n,r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.Name=e.RDNSequence=e.RelativeDistinguishedName=e.AttributeTypeAndValue=e.AttributeValue=e.DirectoryString=void 0;let a=(K(),t(L)),o=J(),s=St(),c=class{teletexString;printableString;universalString;utf8String;bmpString;constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||``}};e.DirectoryString=c,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.TeletexString})],c.prototype,`teletexString`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.PrintableString})],c.prototype,`printableString`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.UniversalString})],c.prototype,`universalString`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.Utf8String})],c.prototype,`utf8String`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.BmpString})],c.prototype,`bmpString`,void 0),e.DirectoryString=c=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],c);let l=class extends c{ia5String;anyValue;constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?s.hex.encode(this.anyValue):super.toString())}};e.AttributeValue=l,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.IA5String})],l.prototype,`ia5String`,void 0),a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.Any})],l.prototype,`anyValue`,void 0),e.AttributeValue=l=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],l);var u=class{type=``;value=new l;constructor(e={}){Object.assign(this,e)}};e.AttributeTypeAndValue=u,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.ObjectIdentifier})],u.prototype,`type`,void 0),a.__decorate([(0,o.AsnProp)({type:l})],u.prototype,`value`,void 0);let d=n=class extends o.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RelativeDistinguishedName=d,e.RelativeDistinguishedName=d=n=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Set,itemType:u})],d);let f=r=class extends o.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};e.RDNSequence=f,e.RDNSequence=f=r=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence,itemType:d})],f);let p=i=class extends f{constructor(e){super(e),Object.setPrototypeOf(this,i.prototype)}};e.Name=p,e.Name=p=i=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],p)})),Tt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GeneralName=e.EDIPartyName=e.OtherName=e.AsnIpConverter=void 0;let n=(K(),t(L)),r=J(),i=Ct(),a=wt();e.AsnIpConverter={fromASN:e=>i.IpConverter.toString(r.AsnOctetStringConverter.fromASN(e)),toASN:e=>r.AsnOctetStringConverter.toASN(i.IpConverter.fromString(e))};var o=class{typeId=``;value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherName=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],o.prototype,`typeId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],o.prototype,`value`,void 0);var s=class{nameAssigner;partyName=new a.DirectoryString;constructor(e={}){Object.assign(this,e)}};e.EDIPartyName=s,n.__decorate([(0,r.AsnProp)({type:a.DirectoryString,optional:!0,context:0,implicit:!0})],s.prototype,`nameAssigner`,void 0),n.__decorate([(0,r.AsnProp)({type:a.DirectoryString,context:1,implicit:!0})],s.prototype,`partyName`,void 0);let c=class{otherName;rfc822Name;dNSName;x400Address;directoryName;ediPartyName;uniformResourceIdentifier;iPAddress;registeredID;constructor(e={}){Object.assign(this,e)}};e.GeneralName=c,n.__decorate([(0,r.AsnProp)({type:o,context:0,implicit:!0})],c.prototype,`otherName`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String,context:1,implicit:!0})],c.prototype,`rfc822Name`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String,context:2,implicit:!0})],c.prototype,`dNSName`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:3,implicit:!0})],c.prototype,`x400Address`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Name,context:4,implicit:!1})],c.prototype,`directoryName`,void 0),n.__decorate([(0,r.AsnProp)({type:s,context:5})],c.prototype,`ediPartyName`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String,context:6,implicit:!0})],c.prototype,`uniformResourceIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.OctetString,context:7,implicit:!0,converter:e.AsnIpConverter})],c.prototype,`iPAddress`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier,context:8,implicit:!0})],c.prototype,`registeredID`,void 0),e.GeneralName=c=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],c)})),Y=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_ce=e.id_ad_caRepository=e.id_ad_timeStamping=e.id_ad_caIssuers=e.id_ad_ocsp=e.id_qt_unotice=e.id_qt_csp=e.id_ad=e.id_kp=e.id_qt=e.id_pe=e.id_pkix=void 0,e.id_pkix=`1.3.6.1.5.5.7`,e.id_pe=`${e.id_pkix}.1`,e.id_qt=`${e.id_pkix}.2`,e.id_kp=`${e.id_pkix}.3`,e.id_ad=`${e.id_pkix}.48`,e.id_qt_csp=`${e.id_qt}.1`,e.id_qt_unotice=`${e.id_qt}.2`,e.id_ad_ocsp=`${e.id_ad}.1`,e.id_ad_caIssuers=`${e.id_ad}.2`,e.id_ad_timeStamping=`${e.id_ad}.3`,e.id_ad_caRepository=`${e.id_ad}.5`,e.id_ce=`2.5.29`})),Et=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.AuthorityInfoAccessSyntax=e.AccessDescription=e.id_pe_authorityInfoAccess=void 0;let r=(K(),t(L)),i=J(),a=Tt();e.id_pe_authorityInfoAccess=`${Y().id_pe}.1`;var o=class{accessMethod=``;accessLocation=new a.GeneralName;constructor(e={}){Object.assign(this,e)}};e.AccessDescription=o,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],o.prototype,`accessMethod`,void 0),r.__decorate([(0,i.AsnProp)({type:a.GeneralName})],o.prototype,`accessLocation`,void 0);let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.AuthorityInfoAccessSyntax=s,e.AuthorityInfoAccessSyntax=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o})],s)})),Dt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AuthorityKeyIdentifier=e.KeyIdentifier=e.id_ce_authorityKeyIdentifier=void 0;let n=(K(),t(L)),r=J(),i=Tt();e.id_ce_authorityKeyIdentifier=`${Y().id_ce}.35`;var a=class extends r.OctetString{};e.KeyIdentifier=a;var o=class{keyIdentifier;authorityCertIssuer;authorityCertSerialNumber;constructor(e={}){e&&Object.assign(this,e)}};e.AuthorityKeyIdentifier=o,n.__decorate([(0,r.AsnProp)({type:a,context:0,optional:!0,implicit:!0})],o.prototype,`keyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName,context:1,optional:!0,implicit:!0,repeated:`sequence`})],o.prototype,`authorityCertIssuer`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:2,optional:!0,implicit:!0,converter:r.AsnIntegerArrayBufferConverter})],o.prototype,`authorityCertSerialNumber`,void 0)})),Ot=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BasicConstraints=e.id_ce_basicConstraints=void 0;let n=(K(),t(L)),r=J();e.id_ce_basicConstraints=`${Y().id_ce}.19`;var i=class{cA=!1;pathLenConstraint;constructor(e={}){Object.assign(this,e)}};e.BasicConstraints=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,defaultValue:!1})],i.prototype,`cA`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,optional:!0})],i.prototype,`pathLenConstraint`,void 0)})),kt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.GeneralNames=void 0;let r=(K(),t(L)),i=J(),a=Tt(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.GeneralNames=o,e.GeneralNames=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.GeneralName})],o)})),At=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateIssuer=e.id_ce_certificateIssuer=void 0;let r=(K(),t(L)),i=J(),a=kt();e.id_ce_certificateIssuer=`${Y().id_ce}.29`;let o=n=class extends a.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.CertificateIssuer=o,e.CertificateIssuer=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],o)})),jt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificatePolicies=e.PolicyInformation=e.PolicyQualifierInfo=e.Qualifier=e.UserNotice=e.NoticeReference=e.DisplayText=e.id_ce_certificatePolicies_anyPolicy=e.id_ce_certificatePolicies=void 0;let r=(K(),t(L)),i=J();e.id_ce_certificatePolicies=`${Y().id_ce}.32`,e.id_ce_certificatePolicies_anyPolicy=`${e.id_ce_certificatePolicies}.0`;let a=class{ia5String;visibleString;bmpString;utf8String;constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||``}};e.DisplayText=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.IA5String})],a.prototype,`ia5String`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.VisibleString})],a.prototype,`visibleString`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.BmpString})],a.prototype,`bmpString`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Utf8String})],a.prototype,`utf8String`,void 0),e.DisplayText=a=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],a);var o=class{organization=new a;noticeNumbers=[];constructor(e={}){Object.assign(this,e)}};e.NoticeReference=o,r.__decorate([(0,i.AsnProp)({type:a})],o.prototype,`organization`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,repeated:`sequence`})],o.prototype,`noticeNumbers`,void 0);var s=class{noticeRef;explicitText;constructor(e={}){Object.assign(this,e)}};e.UserNotice=s,r.__decorate([(0,i.AsnProp)({type:o,optional:!0})],s.prototype,`noticeRef`,void 0),r.__decorate([(0,i.AsnProp)({type:a,optional:!0})],s.prototype,`explicitText`,void 0);let c=class{cPSuri;userNotice;constructor(e={}){Object.assign(this,e)}};e.Qualifier=c,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.IA5String})],c.prototype,`cPSuri`,void 0),r.__decorate([(0,i.AsnProp)({type:s})],c.prototype,`userNotice`,void 0),e.Qualifier=c=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],c);var l=class{policyQualifierId=``;qualifier=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.PolicyQualifierInfo=l,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],l.prototype,`policyQualifierId`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any})],l.prototype,`qualifier`,void 0);var u=class{policyIdentifier=``;policyQualifiers;constructor(e={}){Object.assign(this,e)}};e.PolicyInformation=u,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],u.prototype,`policyIdentifier`,void 0),r.__decorate([(0,i.AsnProp)({type:l,repeated:`sequence`,optional:!0})],u.prototype,`policyQualifiers`,void 0);let d=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.CertificatePolicies=d,e.CertificatePolicies=d=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:u})],d)})),Mt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CRLNumber=e.id_ce_cRLNumber=void 0;let n=(K(),t(L)),r=J();e.id_ce_cRLNumber=`${Y().id_ce}.20`;let i=class{value;constructor(e=0){this.value=e}};e.CRLNumber=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],i.prototype,`value`,void 0),e.CRLNumber=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),Nt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseCRLNumber=e.id_ce_deltaCRLIndicator=void 0;let n=(K(),t(L)),r=J(),i=Y(),a=Mt();e.id_ce_deltaCRLIndicator=`${i.id_ce}.27`;let o=class extends a.CRLNumber{};e.BaseCRLNumber=o,e.BaseCRLNumber=o=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],o)})),Pt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.CRLDistributionPoints=e.DistributionPoint=e.DistributionPointName=e.Reason=e.ReasonFlags=e.id_ce_cRLDistributionPoints=void 0;let r=(K(),t(L)),i=J(),a=wt(),o=Tt();e.id_ce_cRLDistributionPoints=`${Y().id_ce}.31`;var s;(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`})(s||(e.ReasonFlags=s={}));var c=class extends i.BitString{toJSON(){let e=[],t=this.toNumber();return t&s.aACompromise&&e.push(`aACompromise`),t&s.affiliationChanged&&e.push(`affiliationChanged`),t&s.cACompromise&&e.push(`cACompromise`),t&s.certificateHold&&e.push(`certificateHold`),t&s.cessationOfOperation&&e.push(`cessationOfOperation`),t&s.keyCompromise&&e.push(`keyCompromise`),t&s.privilegeWithdrawn&&e.push(`privilegeWithdrawn`),t&s.superseded&&e.push(`superseded`),t&s.unused&&e.push(`unused`),e}toString(){return`[${this.toJSON().join(`, `)}]`}};e.Reason=c;let l=class{fullName;nameRelativeToCRLIssuer;constructor(e={}){Object.assign(this,e)}};e.DistributionPointName=l,r.__decorate([(0,i.AsnProp)({type:o.GeneralName,context:0,repeated:`sequence`,implicit:!0})],l.prototype,`fullName`,void 0),r.__decorate([(0,i.AsnProp)({type:a.RelativeDistinguishedName,context:1,implicit:!0})],l.prototype,`nameRelativeToCRLIssuer`,void 0),e.DistributionPointName=l=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],l);var u=class{distributionPoint;reasons;cRLIssuer;constructor(e={}){Object.assign(this,e)}};e.DistributionPoint=u,r.__decorate([(0,i.AsnProp)({type:l,context:0,optional:!0})],u.prototype,`distributionPoint`,void 0),r.__decorate([(0,i.AsnProp)({type:c,context:1,optional:!0,implicit:!0})],u.prototype,`reasons`,void 0),r.__decorate([(0,i.AsnProp)({type:o.GeneralName,context:2,optional:!0,repeated:`sequence`,implicit:!0})],u.prototype,`cRLIssuer`,void 0);let d=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.CRLDistributionPoints=d,e.CRLDistributionPoints=d=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:u})],d)})),Ft=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.FreshestCRL=e.id_ce_freshestCRL=void 0;let r=(K(),t(L)),i=J(),a=Y(),o=Pt();e.id_ce_freshestCRL=`${a.id_ce}.46`;let s=n=class extends o.CRLDistributionPoints{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.FreshestCRL=s,e.FreshestCRL=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o.DistributionPoint})],s)})),It=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuingDistributionPoint=e.id_ce_issuingDistributionPoint=void 0;let n=(K(),t(L)),r=J(),i=Y(),a=Pt();e.id_ce_issuingDistributionPoint=`${i.id_ce}.28`;var o=class e{static ONLY=!1;distributionPoint;onlyContainsUserCerts=e.ONLY;onlyContainsCACerts=e.ONLY;onlySomeReasons;indirectCRL=e.ONLY;onlyContainsAttributeCerts=e.ONLY;constructor(e={}){Object.assign(this,e)}};e.IssuingDistributionPoint=o,n.__decorate([(0,r.AsnProp)({type:a.DistributionPointName,context:0,optional:!0})],o.prototype,`distributionPoint`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,context:1,defaultValue:o.ONLY,implicit:!0})],o.prototype,`onlyContainsUserCerts`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,context:2,defaultValue:o.ONLY,implicit:!0})],o.prototype,`onlyContainsCACerts`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Reason,context:3,optional:!0,implicit:!0})],o.prototype,`onlySomeReasons`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,context:4,defaultValue:o.ONLY,implicit:!0})],o.prototype,`indirectCRL`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,context:5,defaultValue:o.ONLY,implicit:!0})],o.prototype,`onlyContainsAttributeCerts`,void 0)})),Lt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CRLReason=e.CRLReasons=e.id_ce_cRLReasons=void 0;let n=(K(),t(L)),r=J();e.id_ce_cRLReasons=`${Y().id_ce}.21`;var i;(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`})(i||(e.CRLReasons=i={}));let a=class{reason=i.unspecified;constructor(e=i.unspecified){this.reason=e}toJSON(){return i[this.reason]}toString(){return this.toJSON()}};e.CRLReason=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Enumerated})],a.prototype,`reason`,void 0),e.CRLReason=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],a)})),Rt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.id_kp_OCSPSigning=e.id_kp_timeStamping=e.id_kp_emailProtection=e.id_kp_codeSigning=e.id_kp_clientAuth=e.id_kp_serverAuth=e.anyExtendedKeyUsage=e.ExtendedKeyUsage=e.id_ce_extKeyUsage=void 0;let r=(K(),t(L)),i=J(),a=Y();e.id_ce_extKeyUsage=`${a.id_ce}.37`;let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.ExtendedKeyUsage=o,e.ExtendedKeyUsage=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:i.AsnPropTypes.ObjectIdentifier})],o),e.anyExtendedKeyUsage=`${e.id_ce_extKeyUsage}.0`,e.id_kp_serverAuth=`${a.id_kp}.1`,e.id_kp_clientAuth=`${a.id_kp}.2`,e.id_kp_codeSigning=`${a.id_kp}.3`,e.id_kp_emailProtection=`${a.id_kp}.4`,e.id_kp_timeStamping=`${a.id_kp}.8`,e.id_kp_OCSPSigning=`${a.id_kp}.9`})),zt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InhibitAnyPolicy=e.id_ce_inhibitAnyPolicy=void 0;let n=(K(),t(L)),r=J();e.id_ce_inhibitAnyPolicy=`${Y().id_ce}.54`;let i=class{value;constructor(e=new ArrayBuffer(0)){this.value=e}};e.InhibitAnyPolicy=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`value`,void 0),e.InhibitAnyPolicy=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),Bt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidityDate=e.id_ce_invalidityDate=void 0;let n=(K(),t(L)),r=J();e.id_ce_invalidityDate=`${Y().id_ce}.24`;let i=class{value=new Date;constructor(e){e&&(this.value=e)}};e.InvalidityDate=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime})],i.prototype,`value`,void 0),e.InvalidityDate=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),Vt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.IssueAlternativeName=e.id_ce_issuerAltName=void 0;let r=(K(),t(L)),i=J(),a=kt();e.id_ce_issuerAltName=`${Y().id_ce}.18`;let o=n=class extends a.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.IssueAlternativeName=o,e.IssueAlternativeName=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],o)})),Ht=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyUsage=e.KeyUsageFlags=e.id_ce_keyUsage=void 0;let t=J();e.id_ce_keyUsage=`${Y().id_ce}.15`;var n;(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`})(n||(e.KeyUsageFlags=n={})),e.KeyUsage=class extends t.BitString{toJSON(){let e=this.toNumber(),t=[];return e&n.cRLSign&&t.push(`crlSign`),e&n.dataEncipherment&&t.push(`dataEncipherment`),e&n.decipherOnly&&t.push(`decipherOnly`),e&n.digitalSignature&&t.push(`digitalSignature`),e&n.encipherOnly&&t.push(`encipherOnly`),e&n.keyAgreement&&t.push(`keyAgreement`),e&n.keyCertSign&&t.push(`keyCertSign`),e&n.keyEncipherment&&t.push(`keyEncipherment`),e&n.nonRepudiation&&t.push(`nonRepudiation`),t}toString(){return`[${this.toJSON().join(`, `)}]`}}})),Ut=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.NameConstraints=e.GeneralSubtrees=e.GeneralSubtree=e.id_ce_nameConstraints=void 0;let r=(K(),t(L)),i=J(),a=Tt();e.id_ce_nameConstraints=`${Y().id_ce}.30`;var o=class{base=new a.GeneralName;minimum=0;maximum;constructor(e={}){Object.assign(this,e)}};e.GeneralSubtree=o,r.__decorate([(0,i.AsnProp)({type:a.GeneralName})],o.prototype,`base`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,context:0,defaultValue:0,implicit:!0})],o.prototype,`minimum`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,context:1,optional:!0,implicit:!0})],o.prototype,`maximum`,void 0);let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.GeneralSubtrees=s,e.GeneralSubtrees=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o})],s);var c=class{permittedSubtrees;excludedSubtrees;constructor(e={}){Object.assign(this,e)}};e.NameConstraints=c,r.__decorate([(0,i.AsnProp)({type:s,context:0,optional:!0,implicit:!0})],c.prototype,`permittedSubtrees`,void 0),r.__decorate([(0,i.AsnProp)({type:s,context:1,optional:!0,implicit:!0})],c.prototype,`excludedSubtrees`,void 0)})),Wt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PolicyConstraints=e.id_ce_policyConstraints=void 0;let n=(K(),t(L)),r=J();e.id_ce_policyConstraints=`${Y().id_ce}.36`;var i=class{requireExplicitPolicy;inhibitPolicyMapping;constructor(e={}){Object.assign(this,e)}};e.PolicyConstraints=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:0,implicit:!0,optional:!0,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`requireExplicitPolicy`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:1,implicit:!0,optional:!0,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`inhibitPolicyMapping`,void 0)})),Gt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.PolicyMappings=e.PolicyMapping=e.id_ce_policyMappings=void 0;let r=(K(),t(L)),i=J();e.id_ce_policyMappings=`${Y().id_ce}.33`;var a=class{issuerDomainPolicy=``;subjectDomainPolicy=``;constructor(e={}){Object.assign(this,e)}};e.PolicyMapping=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`issuerDomainPolicy`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`subjectDomainPolicy`,void 0);let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.PolicyMappings=o,e.PolicyMappings=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a})],o)})),Kt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectAlternativeName=e.id_ce_subjectAltName=void 0;let r=(K(),t(L)),i=J(),a=kt();e.id_ce_subjectAltName=`${Y().id_ce}.17`;let o=n=class extends a.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SubjectAlternativeName=o,e.SubjectAlternativeName=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],o)})),qt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;let n=(K(),t(L)),r=J();var i=class{type=``;values=[];constructor(e={}){Object.assign(this,e)}};e.Attribute=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`type`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,repeated:`set`})],i.prototype,`values`,void 0)})),Jt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectDirectoryAttributes=e.id_ce_subjectDirectoryAttributes=void 0;let r=(K(),t(L)),i=J(),a=qt();e.id_ce_subjectDirectoryAttributes=`${Y().id_ce}.9`;let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SubjectDirectoryAttributes=o,e.SubjectDirectoryAttributes=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.Attribute})],o)})),Yt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectKeyIdentifier=e.id_ce_subjectKeyIdentifier=void 0;let t=Y(),n=Dt();e.id_ce_subjectKeyIdentifier=`${t.id_ce}.14`,e.SubjectKeyIdentifier=class extends n.KeyIdentifier{}})),Xt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PrivateKeyUsagePeriod=e.id_ce_privateKeyUsagePeriod=void 0;let n=(K(),t(L)),r=J();e.id_ce_privateKeyUsagePeriod=`${Y().id_ce}.16`;var i=class{notBefore;notAfter;constructor(e={}){Object.assign(this,e)}};e.PrivateKeyUsagePeriod=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime,context:0,implicit:!0,optional:!0})],i.prototype,`notBefore`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime,context:1,implicit:!0,optional:!0})],i.prototype,`notAfter`,void 0)})),Zt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EntrustVersionInfo=e.EntrustInfo=e.EntrustInfoFlags=e.id_entrust_entrustVersInfo=void 0;let n=(K(),t(L)),r=J();e.id_entrust_entrustVersInfo=`1.2.840.113533.7.65.0`;var i;(function(e){e[e.keyUpdateAllowed=1]=`keyUpdateAllowed`,e[e.newExtensions=2]=`newExtensions`,e[e.pKIXCertificate=4]=`pKIXCertificate`})(i||(e.EntrustInfoFlags=i={}));var a=class extends r.BitString{toJSON(){let e=[],t=this.toNumber();return t&i.pKIXCertificate&&e.push(`pKIXCertificate`),t&i.newExtensions&&e.push(`newExtensions`),t&i.keyUpdateAllowed&&e.push(`keyUpdateAllowed`),e}toString(){return`[${this.toJSON().join(`, `)}]`}};e.EntrustInfo=a;var o=class{entrustVers=``;entrustInfoFlags=new a;constructor(e={}){Object.assign(this,e)}};e.EntrustVersionInfo=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralString})],o.prototype,`entrustVers`,void 0),n.__decorate([(0,r.AsnProp)({type:a})],o.prototype,`entrustInfoFlags`,void 0)})),Qt=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectInfoAccessSyntax=e.id_pe_subjectInfoAccess=void 0;let r=(K(),t(L)),i=J(),a=Y(),o=Et();e.id_pe_subjectInfoAccess=`${a.id_pe}.11`;let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SubjectInfoAccessSyntax=s,e.SubjectInfoAccessSyntax=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o.AccessDescription})],s)})),$t=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(Et(),e),n.__exportStar(Dt(),e),n.__exportStar(Ot(),e),n.__exportStar(At(),e),n.__exportStar(jt(),e),n.__exportStar(Nt(),e),n.__exportStar(Pt(),e),n.__exportStar(Ft(),e),n.__exportStar(It(),e),n.__exportStar(Mt(),e),n.__exportStar(Lt(),e),n.__exportStar(Rt(),e),n.__exportStar(zt(),e),n.__exportStar(Bt(),e),n.__exportStar(Vt(),e),n.__exportStar(Ht(),e),n.__exportStar(Ut(),e),n.__exportStar(Wt(),e),n.__exportStar(Gt(),e),n.__exportStar(Kt(),e),n.__exportStar(Jt(),e),n.__exportStar(Yt(),e),n.__exportStar(Xt(),e),n.__exportStar(Zt(),e),n.__exportStar(Qt(),e)})),en=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AlgorithmIdentifier=void 0;let n=(K(),t(L)),r=J(),i=q();var a=class e{algorithm=``;parameters;constructor(e={}){Object.assign(this,e)}isEqual(t){return t instanceof e&&t.algorithm==this.algorithm&&(t.parameters&&this.parameters&&(0,i.equal)(t.parameters,this.parameters)||t.parameters===this.parameters)}};e.AlgorithmIdentifier=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`algorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,optional:!0})],a.prototype,`parameters`,void 0)})),tn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectPublicKeyInfo=void 0;let n=(K(),t(L)),r=J(),i=en();var a=class{algorithm=new i.AlgorithmIdentifier;subjectPublicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SubjectPublicKeyInfo=a,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],a.prototype,`algorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],a.prototype,`subjectPublicKey`,void 0)})),nn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Time=void 0;let n=(K(),t(L)),r=J(),i=class{utcTime;generalTime;constructor(e){if(e)if(typeof e==`string`||typeof e==`number`||e instanceof Date){let t=new Date(e);t.setMilliseconds(0),t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw Error(`Cannot get time from CHOICE object`);return e}};e.Time=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.UTCTime})],i.prototype,`utcTime`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime})],i.prototype,`generalTime`,void 0),e.Time=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),rn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Validity=void 0;let n=(K(),t(L)),r=J(),i=nn();var a=class{notBefore=new i.Time(new Date);notAfter=new i.Time(new Date);constructor(e){e&&(this.notBefore=new i.Time(e.notBefore),this.notAfter=new i.Time(e.notAfter))}};e.Validity=a,n.__decorate([(0,r.AsnProp)({type:i.Time})],a.prototype,`notBefore`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Time})],a.prototype,`notAfter`,void 0)})),an=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.Extensions=e.Extension=void 0;let r=(K(),t(L)),i=J();var a=class e{static CRITICAL=!1;extnID=``;critical=e.CRITICAL;extnValue=new i.OctetString;constructor(e={}){Object.assign(this,e)}};e.Extension=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`extnID`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Boolean,defaultValue:a.CRITICAL})],a.prototype,`critical`,void 0),r.__decorate([(0,i.AsnProp)({type:i.OctetString})],a.prototype,`extnValue`,void 0);let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.Extensions=o,e.Extensions=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a})],o)})),on=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Version=void 0;var t;(function(e){e[e.v1=0]=`v1`,e[e.v2=1]=`v2`,e[e.v3=2]=`v3`})(t||(e.Version=t={}))})),sn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TBSCertificate=void 0;let n=(K(),t(L)),r=J(),i=en(),a=wt(),o=tn(),s=rn(),c=an(),l=on();var u=class{version=l.Version.v1;serialNumber=new ArrayBuffer(0);signature=new i.AlgorithmIdentifier;issuer=new a.Name;validity=new s.Validity;subject=new a.Name;subjectPublicKeyInfo=new o.SubjectPublicKeyInfo;issuerUniqueID;subjectUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};e.TBSCertificate=u,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:0,defaultValue:l.Version.v1})],u.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],u.prototype,`serialNumber`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],u.prototype,`signature`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Name})],u.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:s.Validity})],u.prototype,`validity`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Name})],u.prototype,`subject`,void 0),n.__decorate([(0,r.AsnProp)({type:o.SubjectPublicKeyInfo})],u.prototype,`subjectPublicKeyInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,context:1,implicit:!0,optional:!0})],u.prototype,`issuerUniqueID`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,context:2,implicit:!0,optional:!0})],u.prototype,`subjectUniqueID`,void 0),n.__decorate([(0,r.AsnProp)({type:c.Extensions,context:3,optional:!0})],u.prototype,`extensions`,void 0)})),cn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Certificate=void 0;let n=(K(),t(L)),r=J(),i=en(),a=sn();var o=class{tbsCertificate=new a.TBSCertificate;tbsCertificateRaw;signatureAlgorithm=new i.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.Certificate=o,n.__decorate([(0,r.AsnProp)({type:a.TBSCertificate,raw:!0})],o.prototype,`tbsCertificate`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`signatureValue`,void 0)})),ln=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TBSCertList=e.RevokedCertificate=void 0;let n=(K(),t(L)),r=J(),i=en(),a=wt(),o=nn(),s=an();var c=class{userCertificate=new ArrayBuffer(0);revocationDate=new o.Time;crlEntryExtensions;constructor(e={}){Object.assign(this,e)}};e.RevokedCertificate=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],c.prototype,`userCertificate`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Time})],c.prototype,`revocationDate`,void 0),n.__decorate([(0,r.AsnProp)({type:s.Extension,optional:!0,repeated:`sequence`})],c.prototype,`crlEntryExtensions`,void 0);var l=class{version;signature=new i.AlgorithmIdentifier;issuer=new a.Name;thisUpdate=new o.Time;nextUpdate;revokedCertificates;crlExtensions;constructor(e={}){Object.assign(this,e)}};e.TBSCertList=l,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,optional:!0})],l.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],l.prototype,`signature`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Name})],l.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Time})],l.prototype,`thisUpdate`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Time,optional:!0})],l.prototype,`nextUpdate`,void 0),n.__decorate([(0,r.AsnProp)({type:c,repeated:`sequence`,optional:!0})],l.prototype,`revokedCertificates`,void 0),n.__decorate([(0,r.AsnProp)({type:s.Extension,optional:!0,context:0,repeated:`sequence`})],l.prototype,`crlExtensions`,void 0)})),un=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateList=void 0;let n=(K(),t(L)),r=J(),i=en(),a=ln();var o=class{tbsCertList=new a.TBSCertList;tbsCertListRaw;signatureAlgorithm=new i.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertificateList=o,n.__decorate([(0,r.AsnProp)({type:a.TBSCertList,raw:!0})],o.prototype,`tbsCertList`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`signature`,void 0)})),X=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar($t(),e),n.__exportStar(en(),e),n.__exportStar(qt(),e),n.__exportStar(cn(),e),n.__exportStar(un(),e),n.__exportStar(an(),e),n.__exportStar(Tt(),e),n.__exportStar(kt(),e),n.__exportStar(wt(),e),n.__exportStar(Y(),e),n.__exportStar(tn(),e),n.__exportStar(ln(),e),n.__exportStar(sn(),e),n.__exportStar(nn(),e),n.__exportStar(on(),e),n.__exportStar(rn(),e)})),dn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuerAndSerialNumber=void 0;let n=(K(),t(L)),r=J(),i=X();var a=class{issuer=new i.Name;serialNumber=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.IssuerAndSerialNumber=a,n.__decorate([(0,r.AsnProp)({type:i.Name})],a.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`serialNumber`,void 0)})),fn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SignerIdentifier=void 0;let n=(K(),t(L)),r=J(),i=X(),a=dn(),o=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.SignerIdentifier=o,n.__decorate([(0,r.AsnProp)({type:i.SubjectKeyIdentifier,context:0,implicit:!0})],o.prototype,`subjectKeyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:a.IssuerAndSerialNumber})],o.prototype,`issuerAndSerialNumber`,void 0),e.SignerIdentifier=o=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],o)})),pn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyDerivationAlgorithmIdentifier=e.MessageAuthenticationCodeAlgorithm=e.ContentEncryptionAlgorithmIdentifier=e.KeyEncryptionAlgorithmIdentifier=e.SignatureAlgorithmIdentifier=e.DigestAlgorithmIdentifier=e.CMSVersion=void 0;let n=(K(),t(L)),r=X(),i=J();var a;(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`})(a||(e.CMSVersion=a={}));let o=class extends r.AlgorithmIdentifier{};e.DigestAlgorithmIdentifier=o,e.DigestAlgorithmIdentifier=o=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],o);let s=class extends r.AlgorithmIdentifier{};e.SignatureAlgorithmIdentifier=s,e.SignatureAlgorithmIdentifier=s=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],s);let c=class extends r.AlgorithmIdentifier{};e.KeyEncryptionAlgorithmIdentifier=c,e.KeyEncryptionAlgorithmIdentifier=c=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],c);let l=class extends r.AlgorithmIdentifier{};e.ContentEncryptionAlgorithmIdentifier=l,e.ContentEncryptionAlgorithmIdentifier=l=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],l);let u=class extends r.AlgorithmIdentifier{};e.MessageAuthenticationCodeAlgorithm=u,e.MessageAuthenticationCodeAlgorithm=u=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],u);let d=class extends r.AlgorithmIdentifier{};e.KeyDerivationAlgorithmIdentifier=d,e.KeyDerivationAlgorithmIdentifier=d=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],d)})),mn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;let n=(K(),t(L)),r=J();var i=class{attrType=``;attrValues=[];constructor(e={}){Object.assign(this,e)}};e.Attribute=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`attrType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,repeated:`set`})],i.prototype,`attrValues`,void 0)})),hn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SignerInfos=e.SignerInfo=void 0;let r=(K(),t(L)),i=J(),a=fn(),o=pn(),s=mn();var c=class{version=o.CMSVersion.v0;sid=new a.SignerIdentifier;digestAlgorithm=new o.DigestAlgorithmIdentifier;signedAttrs;signedAttrsRaw;signatureAlgorithm=new o.SignatureAlgorithmIdentifier;signature=new i.OctetString;unsignedAttrs;constructor(e={}){Object.assign(this,e)}};e.SignerInfo=c,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],c.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:a.SignerIdentifier})],c.prototype,`sid`,void 0),r.__decorate([(0,i.AsnProp)({type:o.DigestAlgorithmIdentifier})],c.prototype,`digestAlgorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:s.Attribute,repeated:`set`,context:0,implicit:!0,optional:!0,raw:!0})],c.prototype,`signedAttrs`,void 0),r.__decorate([(0,i.AsnProp)({type:o.SignatureAlgorithmIdentifier})],c.prototype,`signatureAlgorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:i.OctetString})],c.prototype,`signature`,void 0),r.__decorate([(0,i.AsnProp)({type:s.Attribute,repeated:`set`,context:1,implicit:!0,optional:!0})],c.prototype,`unsignedAttrs`,void 0);let l=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SignerInfos=l,e.SignerInfos=l=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:c})],l)})),gn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CounterSignature=e.id_counterSignature=void 0;let n=(K(),t(L)),r=J(),i=hn();e.id_counterSignature=`1.2.840.113549.1.9.6`;let a=class extends i.SignerInfo{};e.CounterSignature=a,e.CounterSignature=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a)})),_n=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MessageDigest=e.id_messageDigest=void 0;let t=J();e.id_messageDigest=`1.2.840.113549.1.9.4`,e.MessageDigest=class extends t.OctetString{}})),vn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SigningTime=e.id_signingTime=void 0;let n=(K(),t(L)),r=X(),i=J();e.id_signingTime=`1.2.840.113549.1.9.5`;let a=class extends r.Time{};e.SigningTime=a,e.SigningTime=a=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],a)})),yn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_contentType=void 0;let n=(K(),t(L));n.__exportStar(gn(),e),n.__exportStar(_n(),e),n.__exportStar(vn(),e),e.id_contentType=`1.2.840.113549.1.9.3`})),bn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ACClearAttrs=void 0;let n=(K(),t(L)),r=J(),i=X();var a=class{acIssuer=new i.GeneralName;acSerial=0;attrs=[];constructor(e={}){Object.assign(this,e)}};e.ACClearAttrs=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`acIssuer`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],a.prototype,`acSerial`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Attribute,repeated:`sequence`})],a.prototype,`attrs`,void 0)})),xn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.AttrSpec=void 0;let r=(K(),t(L)),i=J(),a=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.AttrSpec=a,e.AttrSpec=a=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:i.AsnPropTypes.ObjectIdentifier})],a)})),Sn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AAControls=void 0;let n=(K(),t(L)),r=J(),i=xn();var a=class{pathLenConstraint;permittedAttrs;excludedAttrs;permitUnSpecified=!0;constructor(e={}){Object.assign(this,e)}};e.AAControls=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,optional:!0})],a.prototype,`pathLenConstraint`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AttrSpec,implicit:!0,context:0,optional:!0})],a.prototype,`permittedAttrs`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AttrSpec,implicit:!0,context:1,optional:!0})],a.prototype,`excludedAttrs`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,defaultValue:!0})],a.prototype,`permitUnSpecified`,void 0)})),Cn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuerSerial=void 0;let n=(K(),t(L)),r=J(),i=X();var a=class{issuer=new i.GeneralNames;serial=new ArrayBuffer(0);issuerUID=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.IssuerSerial=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralNames})],a.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`serial`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,optional:!0})],a.prototype,`issuerUID`,void 0)})),wn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectDigestInfo=e.DigestedObjectType=void 0;let n=(K(),t(L)),r=J(),i=X();var a;(function(e){e[e.publicKey=0]=`publicKey`,e[e.publicKeyCert=1]=`publicKeyCert`,e[e.otherObjectTypes=2]=`otherObjectTypes`})(a||(e.DigestedObjectType=a={}));var o=class{digestedObjectType=a.publicKey;otherObjectTypeID;digestAlgorithm=new i.AlgorithmIdentifier;objectDigest=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ObjectDigestInfo=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Enumerated})],o.prototype,`digestedObjectType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier,optional:!0})],o.prototype,`otherObjectTypeID`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`digestAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`objectDigest`,void 0)})),Tn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.V2Form=void 0;let n=(K(),t(L)),r=J(),i=X(),a=Cn(),o=wn();var s=class{issuerName;baseCertificateID;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};e.V2Form=s,n.__decorate([(0,r.AsnProp)({type:i.GeneralNames,optional:!0})],s.prototype,`issuerName`,void 0),n.__decorate([(0,r.AsnProp)({type:a.IssuerSerial,context:0,implicit:!0,optional:!0})],s.prototype,`baseCertificateID`,void 0),n.__decorate([(0,r.AsnProp)({type:o.ObjectDigestInfo,context:1,implicit:!0,optional:!0})],s.prototype,`objectDigestInfo`,void 0)})),En=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttCertIssuer=void 0;let n=(K(),t(L)),r=J(),i=X(),a=Tn(),o=class{v1Form;v2Form;constructor(e={}){Object.assign(this,e)}};e.AttCertIssuer=o,n.__decorate([(0,r.AsnProp)({type:i.GeneralName,repeated:`sequence`})],o.prototype,`v1Form`,void 0),n.__decorate([(0,r.AsnProp)({type:a.V2Form,context:0,implicit:!0})],o.prototype,`v2Form`,void 0),e.AttCertIssuer=o=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],o)})),Dn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttCertValidityPeriod=void 0;let n=(K(),t(L)),r=J();var i=class{notBeforeTime=new Date;notAfterTime=new Date;constructor(e={}){Object.assign(this,e)}};e.AttCertValidityPeriod=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime})],i.prototype,`notBeforeTime`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime})],i.prototype,`notAfterTime`,void 0)})),On=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Holder=void 0;let n=(K(),t(L)),r=J(),i=X(),a=Cn(),o=wn();var s=class{baseCertificateID;entityName;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};e.Holder=s,n.__decorate([(0,r.AsnProp)({type:a.IssuerSerial,implicit:!0,context:0,optional:!0})],s.prototype,`baseCertificateID`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralNames,implicit:!0,context:1,optional:!0})],s.prototype,`entityName`,void 0),n.__decorate([(0,r.AsnProp)({type:o.ObjectDigestInfo,implicit:!0,context:2,optional:!0})],s.prototype,`objectDigestInfo`,void 0)})),kn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeCertificateInfo=e.AttCertVersion=void 0;let n=(K(),t(L)),r=J(),i=X(),a=On(),o=En(),s=Dn();var c;(function(e){e[e.v2=1]=`v2`})(c||(e.AttCertVersion=c={}));var l=class{version=c.v2;holder=new a.Holder;issuer=new o.AttCertIssuer;signature=new i.AlgorithmIdentifier;serialNumber=new ArrayBuffer(0);attrCertValidityPeriod=new s.AttCertValidityPeriod;attributes=[];issuerUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};e.AttributeCertificateInfo=l,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],l.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Holder})],l.prototype,`holder`,void 0),n.__decorate([(0,r.AsnProp)({type:o.AttCertIssuer})],l.prototype,`issuer`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],l.prototype,`signature`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],l.prototype,`serialNumber`,void 0),n.__decorate([(0,r.AsnProp)({type:s.AttCertValidityPeriod})],l.prototype,`attrCertValidityPeriod`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Attribute,repeated:`sequence`})],l.prototype,`attributes`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,optional:!0})],l.prototype,`issuerUniqueID`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Extensions,optional:!0})],l.prototype,`extensions`,void 0)})),An=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeCertificate=void 0;let n=(K(),t(L)),r=J(),i=X(),a=kn();var o=class{acinfo=new a.AttributeCertificateInfo;signatureAlgorithm=new i.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.AttributeCertificate=o,n.__decorate([(0,r.AsnProp)({type:a.AttributeCertificateInfo})],o.prototype,`acinfo`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`signatureValue`,void 0)})),jn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ClassList=e.ClassListFlags=void 0;let t=J();var n;(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`})(n||(e.ClassListFlags=n={})),e.ClassList=class extends t.BitString{}})),Mn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SecurityCategory=void 0;let n=(K(),t(L)),r=J();var i=class{type=``;value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SecurityCategory=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier,implicit:!0,context:0})],i.prototype,`type`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,implicit:!0,context:1})],i.prototype,`value`,void 0)})),Nn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Clearance=void 0;let n=(K(),t(L)),r=J(),i=jn(),a=Mn();var o=class{policyId=``;classList=new i.ClassList(i.ClassListFlags.unclassified);securityCategories;constructor(e={}){Object.assign(this,e)}};e.Clearance=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],o.prototype,`policyId`,void 0),n.__decorate([(0,r.AsnProp)({type:i.ClassList,defaultValue:new i.ClassList(i.ClassListFlags.unclassified)})],o.prototype,`classList`,void 0),n.__decorate([(0,r.AsnProp)({type:a.SecurityCategory,repeated:`set`})],o.prototype,`securityCategories`,void 0)})),Pn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IetfAttrSyntax=e.IetfAttrSyntaxValueChoices=void 0;let n=(K(),t(L)),r=J(),i=X();var a=class{cotets;oid;string;constructor(e={}){Object.assign(this,e)}};e.IetfAttrSyntaxValueChoices=a,n.__decorate([(0,r.AsnProp)({type:r.OctetString})],a.prototype,`cotets`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`oid`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Utf8String})],a.prototype,`string`,void 0);var o=class{policyAuthority;values=[];constructor(e={}){Object.assign(this,e)}};e.IetfAttrSyntax=o,n.__decorate([(0,r.AsnProp)({type:i.GeneralNames,implicit:!0,context:0,optional:!0})],o.prototype,`policyAuthority`,void 0),n.__decorate([(0,r.AsnProp)({type:a,repeated:`sequence`})],o.prototype,`values`,void 0)})),Fn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_at_clearance=e.id_at_role=e.id_at=e.id_aca_encAttrs=e.id_aca_group=e.id_aca_chargingIdentity=e.id_aca_accessIdentity=e.id_aca_authenticationInfo=e.id_aca=e.id_ce_targetInformation=e.id_pe_ac_proxying=e.id_pe_aaControls=e.id_pe_ac_auditIdentity=void 0;let t=X();e.id_pe_ac_auditIdentity=`${t.id_pe}.4`,e.id_pe_aaControls=`${t.id_pe}.6`,e.id_pe_ac_proxying=`${t.id_pe}.10`,e.id_ce_targetInformation=`${t.id_ce}.55`,e.id_aca=`${t.id_pkix}.10`,e.id_aca_authenticationInfo=`${e.id_aca}.1`,e.id_aca_accessIdentity=`${e.id_aca}.2`,e.id_aca_chargingIdentity=`${e.id_aca}.3`,e.id_aca_group=`${e.id_aca}.4`,e.id_aca_encAttrs=`${e.id_aca}.6`,e.id_at=`2.5.4`,e.id_at_role=`${e.id_at}.72`,e.id_at_clearance=`2.5.1.5.55`})),In=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.Targets=e.Target=e.TargetCert=void 0;let r=(K(),t(L)),i=J(),a=X(),o=Cn(),s=wn();var c=class{targetCertificate=new o.IssuerSerial;targetName;certDigestInfo;constructor(e={}){Object.assign(this,e)}};e.TargetCert=c,r.__decorate([(0,i.AsnProp)({type:o.IssuerSerial})],c.prototype,`targetCertificate`,void 0),r.__decorate([(0,i.AsnProp)({type:a.GeneralName,optional:!0})],c.prototype,`targetName`,void 0),r.__decorate([(0,i.AsnProp)({type:s.ObjectDigestInfo,optional:!0})],c.prototype,`certDigestInfo`,void 0);let l=class{targetName;targetGroup;targetCert;constructor(e={}){Object.assign(this,e)}};e.Target=l,r.__decorate([(0,i.AsnProp)({type:a.GeneralName,context:0,implicit:!0})],l.prototype,`targetName`,void 0),r.__decorate([(0,i.AsnProp)({type:a.GeneralName,context:1,implicit:!0})],l.prototype,`targetGroup`,void 0),r.__decorate([(0,i.AsnProp)({type:c,context:2,implicit:!0})],l.prototype,`targetCert`,void 0),e.Target=l=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],l);let u=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.Targets=u,e.Targets=u=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:l})],u)})),Ln=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.ProxyInfo=void 0;let r=(K(),t(L)),i=J(),a=In(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.ProxyInfo=o,e.ProxyInfo=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.Targets})],o)})),Rn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RoleSyntax=void 0;let n=(K(),t(L)),r=J(),i=X();var a=class{roleAuthority;roleName;constructor(e={}){Object.assign(this,e)}};e.RoleSyntax=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralNames,implicit:!0,context:0,optional:!0})],a.prototype,`roleAuthority`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName,implicit:!0,context:1})],a.prototype,`roleName`,void 0)})),zn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SvceAuthInfo=void 0;let n=(K(),t(L)),r=J(),i=X();var a=class{service=new i.GeneralName;ident=new i.GeneralName;authInfo;constructor(e={}){Object.assign(this,e)}};e.SvceAuthInfo=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`service`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`ident`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString,optional:!0})],a.prototype,`authInfo`,void 0)})),Bn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(bn(),e),n.__exportStar(Sn(),e),n.__exportStar(En(),e),n.__exportStar(Dn(),e),n.__exportStar(xn(),e),n.__exportStar(An(),e),n.__exportStar(kn(),e),n.__exportStar(jn(),e),n.__exportStar(Nn(),e),n.__exportStar(On(),e),n.__exportStar(Pn(),e),n.__exportStar(Cn(),e),n.__exportStar(wn(),e),n.__exportStar(Fn(),e),n.__exportStar(Ln(),e),n.__exportStar(Rn(),e),n.__exportStar(Mn(),e),n.__exportStar(zn(),e),n.__exportStar(In(),e),n.__exportStar(Tn(),e)})),Vn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateSet=e.CertificateChoices=e.OtherCertificateFormat=void 0;let r=(K(),t(L)),i=J(),a=X(),o=Bn();var s=class{otherCertFormat=``;otherCert=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherCertificateFormat=s,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],s.prototype,`otherCertFormat`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any})],s.prototype,`otherCert`,void 0);let c=class{certificate;v2AttrCert;other;constructor(e={}){Object.assign(this,e)}};e.CertificateChoices=c,r.__decorate([(0,i.AsnProp)({type:a.Certificate})],c.prototype,`certificate`,void 0),r.__decorate([(0,i.AsnProp)({type:o.AttributeCertificate,context:2,implicit:!0})],c.prototype,`v2AttrCert`,void 0),r.__decorate([(0,i.AsnProp)({type:s,context:3,implicit:!0})],c.prototype,`other`,void 0),e.CertificateChoices=c=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],c);let l=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.CertificateSet=l,e.CertificateSet=l=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:c})],l)})),Hn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ContentInfo=void 0;let n=(K(),t(L)),r=J();var i=class{contentType=``;content=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ContentInfo=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`contentType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],i.prototype,`content`,void 0)})),Un=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncapsulatedContentInfo=e.EncapsulatedContent=void 0;let n=(K(),t(L)),r=J(),i=class{single;any;constructor(e={}){Object.assign(this,e)}};e.EncapsulatedContent=i,n.__decorate([(0,r.AsnProp)({type:r.OctetString})],i.prototype,`single`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],i.prototype,`any`,void 0),e.EncapsulatedContent=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i);var a=class{eContentType=``;eContent;constructor(e={}){Object.assign(this,e)}};e.EncapsulatedContentInfo=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`eContentType`,void 0),n.__decorate([(0,r.AsnProp)({type:i,context:0,optional:!0})],a.prototype,`eContent`,void 0)})),Wn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncryptedContentInfo=e.EncryptedContent=void 0;let n=(K(),t(L)),r=J(),i=pn(),a=class{value;constructedValue;constructor(e={}){Object.assign(this,e)}};e.EncryptedContent=a,n.__decorate([(0,r.AsnProp)({type:r.OctetString,context:0,implicit:!0,optional:!0})],a.prototype,`value`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString,converter:r.AsnConstructedOctetStringConverter,context:0,implicit:!0,optional:!0,repeated:`sequence`})],a.prototype,`constructedValue`,void 0),e.EncryptedContent=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],a);var o=class{contentType=``;contentEncryptionAlgorithm=new i.ContentEncryptionAlgorithmIdentifier;encryptedContent;constructor(e={}){Object.assign(this,e)}};e.EncryptedContentInfo=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],o.prototype,`contentType`,void 0),n.__decorate([(0,r.AsnProp)({type:i.ContentEncryptionAlgorithmIdentifier})],o.prototype,`contentEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:a,optional:!0})],o.prototype,`encryptedContent`,void 0)})),Gn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OtherKeyAttribute=void 0;let n=(K(),t(L)),r=J();var i=class{keyAttrId=``;keyAttr;constructor(e={}){Object.assign(this,e)}};e.OtherKeyAttribute=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`keyAttrId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,optional:!0})],i.prototype,`keyAttr`,void 0)})),Kn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.KeyAgreeRecipientInfo=e.OriginatorIdentifierOrKey=e.OriginatorPublicKey=e.RecipientEncryptedKeys=e.RecipientEncryptedKey=e.KeyAgreeRecipientIdentifier=e.RecipientKeyIdentifier=void 0;let r=(K(),t(L)),i=J(),a=X(),o=pn(),s=dn(),c=Gn();var l=class{subjectKeyIdentifier=new a.SubjectKeyIdentifier;date;other;constructor(e={}){Object.assign(this,e)}};e.RecipientKeyIdentifier=l,r.__decorate([(0,i.AsnProp)({type:a.SubjectKeyIdentifier})],l.prototype,`subjectKeyIdentifier`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.GeneralizedTime,optional:!0})],l.prototype,`date`,void 0),r.__decorate([(0,i.AsnProp)({type:c.OtherKeyAttribute,optional:!0})],l.prototype,`other`,void 0);let u=class{rKeyId;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.KeyAgreeRecipientIdentifier=u,r.__decorate([(0,i.AsnProp)({type:l,context:0,implicit:!0,optional:!0})],u.prototype,`rKeyId`,void 0),r.__decorate([(0,i.AsnProp)({type:s.IssuerAndSerialNumber,optional:!0})],u.prototype,`issuerAndSerialNumber`,void 0),e.KeyAgreeRecipientIdentifier=u=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],u);var d=class{rid=new u;encryptedKey=new i.OctetString;constructor(e={}){Object.assign(this,e)}};e.RecipientEncryptedKey=d,r.__decorate([(0,i.AsnProp)({type:u})],d.prototype,`rid`,void 0),r.__decorate([(0,i.AsnProp)({type:i.OctetString})],d.prototype,`encryptedKey`,void 0);let f=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RecipientEncryptedKeys=f,e.RecipientEncryptedKeys=f=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:d})],f);var p=class{algorithm=new a.AlgorithmIdentifier;publicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OriginatorPublicKey=p,r.__decorate([(0,i.AsnProp)({type:a.AlgorithmIdentifier})],p.prototype,`algorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.BitString})],p.prototype,`publicKey`,void 0);let m=class{subjectKeyIdentifier;originatorKey;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.OriginatorIdentifierOrKey=m,r.__decorate([(0,i.AsnProp)({type:a.SubjectKeyIdentifier,context:0,implicit:!0,optional:!0})],m.prototype,`subjectKeyIdentifier`,void 0),r.__decorate([(0,i.AsnProp)({type:p,context:1,implicit:!0,optional:!0})],m.prototype,`originatorKey`,void 0),r.__decorate([(0,i.AsnProp)({type:s.IssuerAndSerialNumber,optional:!0})],m.prototype,`issuerAndSerialNumber`,void 0),e.OriginatorIdentifierOrKey=m=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],m);var h=class{version=o.CMSVersion.v3;originator=new m;ukm;keyEncryptionAlgorithm=new o.KeyEncryptionAlgorithmIdentifier;recipientEncryptedKeys=new f;constructor(e={}){Object.assign(this,e)}};e.KeyAgreeRecipientInfo=h,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],h.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:m,context:0})],h.prototype,`originator`,void 0),r.__decorate([(0,i.AsnProp)({type:i.OctetString,context:1,optional:!0})],h.prototype,`ukm`,void 0),r.__decorate([(0,i.AsnProp)({type:o.KeyEncryptionAlgorithmIdentifier})],h.prototype,`keyEncryptionAlgorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:f})],h.prototype,`recipientEncryptedKeys`,void 0)})),qn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyTransRecipientInfo=e.RecipientIdentifier=void 0;let n=(K(),t(L)),r=J(),i=X(),a=pn(),o=dn(),s=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.RecipientIdentifier=s,n.__decorate([(0,r.AsnProp)({type:i.SubjectKeyIdentifier,context:0,implicit:!0})],s.prototype,`subjectKeyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:o.IssuerAndSerialNumber})],s.prototype,`issuerAndSerialNumber`,void 0),e.RecipientIdentifier=s=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],s);var c=class{version=a.CMSVersion.v0;rid=new s;keyEncryptionAlgorithm=new a.KeyEncryptionAlgorithmIdentifier;encryptedKey=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.KeyTransRecipientInfo=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],c.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:s})],c.prototype,`rid`,void 0),n.__decorate([(0,r.AsnProp)({type:a.KeyEncryptionAlgorithmIdentifier})],c.prototype,`keyEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],c.prototype,`encryptedKey`,void 0)})),Jn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KEKRecipientInfo=e.KEKIdentifier=void 0;let n=(K(),t(L)),r=J(),i=Gn(),a=pn();var o=class{keyIdentifier=new r.OctetString;date;other;constructor(e={}){Object.assign(this,e)}};e.KEKIdentifier=o,n.__decorate([(0,r.AsnProp)({type:r.OctetString})],o.prototype,`keyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime,optional:!0})],o.prototype,`date`,void 0),n.__decorate([(0,r.AsnProp)({type:i.OtherKeyAttribute,optional:!0})],o.prototype,`other`,void 0);var s=class{version=a.CMSVersion.v4;kekid=new o;keyEncryptionAlgorithm=new a.KeyEncryptionAlgorithmIdentifier;encryptedKey=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.KEKRecipientInfo=s,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],s.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:o})],s.prototype,`kekid`,void 0),n.__decorate([(0,r.AsnProp)({type:a.KeyEncryptionAlgorithmIdentifier})],s.prototype,`keyEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],s.prototype,`encryptedKey`,void 0)})),Yn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PasswordRecipientInfo=void 0;let n=(K(),t(L)),r=J(),i=pn();var a=class{version=i.CMSVersion.v0;keyDerivationAlgorithm;keyEncryptionAlgorithm=new i.KeyEncryptionAlgorithmIdentifier;encryptedKey=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.PasswordRecipientInfo=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],a.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.KeyDerivationAlgorithmIdentifier,context:0,optional:!0})],a.prototype,`keyDerivationAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:i.KeyEncryptionAlgorithmIdentifier})],a.prototype,`keyEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],a.prototype,`encryptedKey`,void 0)})),Xn=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RecipientInfo=e.OtherRecipientInfo=void 0;let n=(K(),t(L)),r=J(),i=Kn(),a=qn(),o=Jn(),s=Yn();var c=class{oriType=``;oriValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherRecipientInfo=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],c.prototype,`oriType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],c.prototype,`oriValue`,void 0);let l=class{ktri;kari;kekri;pwri;ori;constructor(e={}){Object.assign(this,e)}};e.RecipientInfo=l,n.__decorate([(0,r.AsnProp)({type:a.KeyTransRecipientInfo,optional:!0})],l.prototype,`ktri`,void 0),n.__decorate([(0,r.AsnProp)({type:i.KeyAgreeRecipientInfo,context:1,implicit:!0,optional:!0})],l.prototype,`kari`,void 0),n.__decorate([(0,r.AsnProp)({type:o.KEKRecipientInfo,context:2,implicit:!0,optional:!0})],l.prototype,`kekri`,void 0),n.__decorate([(0,r.AsnProp)({type:s.PasswordRecipientInfo,context:3,implicit:!0,optional:!0})],l.prototype,`pwri`,void 0),n.__decorate([(0,r.AsnProp)({type:c,context:4,implicit:!0,optional:!0})],l.prototype,`ori`,void 0),e.RecipientInfo=l=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],l)})),Zn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.RecipientInfos=void 0;let r=(K(),t(L)),i=J(),a=Xn(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RecipientInfos=o,e.RecipientInfos=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:a.RecipientInfo})],o)})),Qn=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.RevocationInfoChoices=e.RevocationInfoChoice=e.OtherRevocationInfoFormat=e.id_ri_scvp=e.id_ri_ocsp_response=e.id_ri=void 0;let r=(K(),t(L)),i=J();e.id_ri=`${X().id_pkix}.16`,e.id_ri_ocsp_response=`${e.id_ri}.2`,e.id_ri_scvp=`${e.id_ri}.4`;var a=class{otherRevInfoFormat=``;otherRevInfo=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherRevocationInfoFormat=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`otherRevInfoFormat`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any})],a.prototype,`otherRevInfo`,void 0);let o=class{other=new a;constructor(e={}){Object.assign(this,e)}};e.RevocationInfoChoice=o,r.__decorate([(0,i.AsnProp)({type:a,context:1,implicit:!0})],o.prototype,`other`,void 0),e.RevocationInfoChoice=o=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Choice})],o);let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RevocationInfoChoices=s,e.RevocationInfoChoices=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:o})],s)})),$n=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OriginatorInfo=void 0;let n=(K(),t(L)),r=J(),i=Vn(),a=Qn();var o=class{certs;crls;constructor(e={}){Object.assign(this,e)}};e.OriginatorInfo=o,n.__decorate([(0,r.AsnProp)({type:i.CertificateSet,context:0,implicit:!0,optional:!0})],o.prototype,`certs`,void 0),n.__decorate([(0,r.AsnProp)({type:a.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],o.prototype,`crls`,void 0)})),er=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.EnvelopedData=e.UnprotectedAttributes=void 0;let r=(K(),t(L)),i=J(),a=pn(),o=mn(),s=Zn(),c=$n(),l=Wn(),u=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.UnprotectedAttributes=u,e.UnprotectedAttributes=u=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:o.Attribute})],u);var d=class{version=a.CMSVersion.v0;originatorInfo;recipientInfos=new s.RecipientInfos;encryptedContentInfo=new l.EncryptedContentInfo;unprotectedAttrs;constructor(e={}){Object.assign(this,e)}};e.EnvelopedData=d,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],d.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:c.OriginatorInfo,context:0,implicit:!0,optional:!0})],d.prototype,`originatorInfo`,void 0),r.__decorate([(0,i.AsnProp)({type:s.RecipientInfos})],d.prototype,`recipientInfos`,void 0),r.__decorate([(0,i.AsnProp)({type:l.EncryptedContentInfo})],d.prototype,`encryptedContentInfo`,void 0),r.__decorate([(0,i.AsnProp)({type:u,context:1,implicit:!0,optional:!0})],d.prototype,`unprotectedAttrs`,void 0)})),tr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_authData=e.id_encryptedData=e.id_digestedData=e.id_envelopedData=e.id_signedData=e.id_data=e.id_ct_contentInfo=void 0,e.id_ct_contentInfo=`1.2.840.113549.1.9.16.1.6`,e.id_data=`1.2.840.113549.1.7.1`,e.id_signedData=`1.2.840.113549.1.7.2`,e.id_envelopedData=`1.2.840.113549.1.7.3`,e.id_digestedData=`1.2.840.113549.1.7.5`,e.id_encryptedData=`1.2.840.113549.1.7.6`,e.id_authData=`1.2.840.113549.1.9.16.1.2`})),nr=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SignedData=e.DigestAlgorithmIdentifiers=void 0;let r=(K(),t(L)),i=J(),a=Vn(),o=pn(),s=Un(),c=Qn(),l=hn(),u=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.DigestAlgorithmIdentifiers=u,e.DigestAlgorithmIdentifiers=u=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Set,itemType:o.DigestAlgorithmIdentifier})],u);var d=class{version=o.CMSVersion.v0;digestAlgorithms=new u;encapContentInfo=new s.EncapsulatedContentInfo;certificates;crls;signerInfos=new l.SignerInfos;constructor(e={}){Object.assign(this,e)}};e.SignedData=d,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],d.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:u})],d.prototype,`digestAlgorithms`,void 0),r.__decorate([(0,i.AsnProp)({type:s.EncapsulatedContentInfo})],d.prototype,`encapContentInfo`,void 0),r.__decorate([(0,i.AsnProp)({type:a.CertificateSet,context:0,implicit:!0,optional:!0})],d.prototype,`certificates`,void 0),r.__decorate([(0,i.AsnProp)({type:c.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],d.prototype,`crls`,void 0),r.__decorate([(0,i.AsnProp)({type:l.SignerInfos})],d.prototype,`signerInfos`,void 0)})),rr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(yn(),e),n.__exportStar(mn(),e),n.__exportStar(Vn(),e),n.__exportStar(Hn(),e),n.__exportStar(Un(),e),n.__exportStar(Wn(),e),n.__exportStar(er(),e),n.__exportStar(dn(),e),n.__exportStar(Jn(),e),n.__exportStar(Kn(),e),n.__exportStar(qn(),e),n.__exportStar(tr(),e),n.__exportStar($n(),e),n.__exportStar(Yn(),e),n.__exportStar(Xn(),e),n.__exportStar(Zn(),e),n.__exportStar(Qn(),e),n.__exportStar(nr(),e),n.__exportStar(fn(),e),n.__exportStar(hn(),e),n.__exportStar(pn(),e)})),ir=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_sect571r1=e.id_sect571k1=e.id_secp521r1=e.id_sect409r1=e.id_sect409k1=e.id_secp384r1=e.id_sect283r1=e.id_sect283k1=e.id_secp256r1=e.id_sect233r1=e.id_sect233k1=e.id_secp224r1=e.id_sect163r2=e.id_sect163k1=e.id_secp192r1=e.id_ecdsaWithSHA512=e.id_ecdsaWithSHA384=e.id_ecdsaWithSHA256=e.id_ecdsaWithSHA224=e.id_ecdsaWithSHA1=e.id_ecMQV=e.id_ecDH=e.id_ecPublicKey=void 0,e.id_ecPublicKey=`1.2.840.10045.2.1`,e.id_ecDH=`1.3.132.1.12`,e.id_ecMQV=`1.3.132.1.13`,e.id_ecdsaWithSHA1=`1.2.840.10045.4.1`,e.id_ecdsaWithSHA224=`1.2.840.10045.4.3.1`,e.id_ecdsaWithSHA256=`1.2.840.10045.4.3.2`,e.id_ecdsaWithSHA384=`1.2.840.10045.4.3.3`,e.id_ecdsaWithSHA512=`1.2.840.10045.4.3.4`,e.id_secp192r1=`1.2.840.10045.3.1.1`,e.id_sect163k1=`1.3.132.0.1`,e.id_sect163r2=`1.3.132.0.15`,e.id_secp224r1=`1.3.132.0.33`,e.id_sect233k1=`1.3.132.0.26`,e.id_sect233r1=`1.3.132.0.27`,e.id_secp256r1=`1.2.840.10045.3.1.7`,e.id_sect283k1=`1.3.132.0.16`,e.id_sect283r1=`1.3.132.0.17`,e.id_secp384r1=`1.3.132.0.34`,e.id_sect409k1=`1.3.132.0.36`,e.id_sect409r1=`1.3.132.0.37`,e.id_secp521r1=`1.3.132.0.35`,e.id_sect571k1=`1.3.132.0.38`,e.id_sect571r1=`1.3.132.0.39`})),ar=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ecdsaWithSHA512=e.ecdsaWithSHA384=e.ecdsaWithSHA256=e.ecdsaWithSHA224=e.ecdsaWithSHA1=void 0;let n=(K(),t(L)),r=X(),i=n.__importStar(ir());function a(e){return new r.AlgorithmIdentifier({algorithm:e})}e.ecdsaWithSHA1=a(i.id_ecdsaWithSHA1),e.ecdsaWithSHA224=a(i.id_ecdsaWithSHA224),e.ecdsaWithSHA256=a(i.id_ecdsaWithSHA256),e.ecdsaWithSHA384=a(i.id_ecdsaWithSHA384),e.ecdsaWithSHA512=a(i.id_ecdsaWithSHA512)})),or=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SpecifiedECDomain=e.ECPVer=e.Curve=e.FieldElement=e.ECPoint=e.FieldID=void 0;let n=(K(),t(L)),r=J(),i=class{fieldType;parameters;constructor(e={}){Object.assign(this,e)}};e.FieldID=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`fieldType`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],i.prototype,`parameters`,void 0),e.FieldID=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],i);var a=class extends r.OctetString{};e.ECPoint=a,e.FieldElement=class extends r.OctetString{};let o=class{a;b;seed;constructor(e={}){Object.assign(this,e)}};e.Curve=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.OctetString})],o.prototype,`a`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.OctetString})],o.prototype,`b`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,optional:!0})],o.prototype,`seed`,void 0),e.Curve=o=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],o);var s;(function(e){e[e.ecpVer1=1]=`ecpVer1`})(s||(e.ECPVer=s={}));let c=class{version=s.ecpVer1;fieldID;curve;base;order;cofactor;constructor(e={}){Object.assign(this,e)}};e.SpecifiedECDomain=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],c.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i})],c.prototype,`fieldID`,void 0),n.__decorate([(0,r.AsnProp)({type:o})],c.prototype,`curve`,void 0),n.__decorate([(0,r.AsnProp)({type:a})],c.prototype,`base`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],c.prototype,`order`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,optional:!0})],c.prototype,`cofactor`,void 0),e.SpecifiedECDomain=c=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],c)})),sr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECParameters=void 0;let n=(K(),t(L)),r=J(),i=or(),a=class{namedCurve;implicitCurve;specifiedCurve;constructor(e={}){Object.assign(this,e)}};e.ECParameters=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`namedCurve`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Null})],a.prototype,`implicitCurve`,void 0),n.__decorate([(0,r.AsnProp)({type:i.SpecifiedECDomain})],a.prototype,`specifiedCurve`,void 0),e.ECParameters=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],a)})),cr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECPrivateKey=void 0;let n=(K(),t(L)),r=J(),i=sr();var a=class{version=1;privateKey=new r.OctetString;parameters;publicKey;constructor(e={}){Object.assign(this,e)}};e.ECPrivateKey=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],a.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],a.prototype,`privateKey`,void 0),n.__decorate([(0,r.AsnProp)({type:i.ECParameters,context:0,optional:!0})],a.prototype,`parameters`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString,context:1,optional:!0})],a.prototype,`publicKey`,void 0)})),lr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECDSASigValue=void 0;let n=(K(),t(L)),r=J();var i=class{r=new ArrayBuffer(0);s=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ECDSASigValue=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`r`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`s`,void 0)})),ur=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(ar(),e),n.__exportStar(sr(),e),n.__exportStar(cr(),e),n.__exportStar(lr(),e),n.__exportStar(ir(),e),n.__exportStar(or(),e)})),dr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_mgf1=e.id_md5=e.id_md2=e.id_sha512_256=e.id_sha512_224=e.id_sha512=e.id_sha384=e.id_sha256=e.id_sha224=e.id_sha1=e.id_sha512_256WithRSAEncryption=e.id_sha512_224WithRSAEncryption=e.id_sha512WithRSAEncryption=e.id_sha384WithRSAEncryption=e.id_sha256WithRSAEncryption=e.id_ssha224WithRSAEncryption=e.id_sha224WithRSAEncryption=e.id_sha1WithRSAEncryption=e.id_md5WithRSAEncryption=e.id_md2WithRSAEncryption=e.id_RSASSA_PSS=e.id_pSpecified=e.id_RSAES_OAEP=e.id_rsaEncryption=e.id_pkcs_1=void 0,e.id_pkcs_1=`1.2.840.113549.1.1`,e.id_rsaEncryption=`${e.id_pkcs_1}.1`,e.id_RSAES_OAEP=`${e.id_pkcs_1}.7`,e.id_pSpecified=`${e.id_pkcs_1}.9`,e.id_RSASSA_PSS=`${e.id_pkcs_1}.10`,e.id_md2WithRSAEncryption=`${e.id_pkcs_1}.2`,e.id_md5WithRSAEncryption=`${e.id_pkcs_1}.4`,e.id_sha1WithRSAEncryption=`${e.id_pkcs_1}.5`,e.id_sha224WithRSAEncryption=`${e.id_pkcs_1}.14`,e.id_ssha224WithRSAEncryption=e.id_sha224WithRSAEncryption,e.id_sha256WithRSAEncryption=`${e.id_pkcs_1}.11`,e.id_sha384WithRSAEncryption=`${e.id_pkcs_1}.12`,e.id_sha512WithRSAEncryption=`${e.id_pkcs_1}.13`,e.id_sha512_224WithRSAEncryption=`${e.id_pkcs_1}.15`,e.id_sha512_256WithRSAEncryption=`${e.id_pkcs_1}.16`,e.id_sha1=`1.3.14.3.2.26`,e.id_sha224=`2.16.840.1.101.3.4.2.4`,e.id_sha256=`2.16.840.1.101.3.4.2.1`,e.id_sha384=`2.16.840.1.101.3.4.2.2`,e.id_sha512=`2.16.840.1.101.3.4.2.3`,e.id_sha512_224=`2.16.840.1.101.3.4.2.5`,e.id_sha512_256=`2.16.840.1.101.3.4.2.6`,e.id_md2=`1.2.840.113549.2.2`,e.id_md5=`1.2.840.113549.2.5`,e.id_mgf1=`${e.id_pkcs_1}.8`})),fr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha512_256WithRSAEncryption=e.sha512_224WithRSAEncryption=e.sha512WithRSAEncryption=e.sha384WithRSAEncryption=e.sha256WithRSAEncryption=e.sha224WithRSAEncryption=e.sha1WithRSAEncryption=e.md5WithRSAEncryption=e.md2WithRSAEncryption=e.rsaEncryption=e.pSpecifiedEmpty=e.mgf1SHA1=e.sha512_256=e.sha512_224=e.sha512=e.sha384=e.sha256=e.sha224=e.sha1=e.md4=e.md2=void 0;let n=(K(),t(L)),r=J(),i=X(),a=n.__importStar(dr());function o(e){return new i.AlgorithmIdentifier({algorithm:e,parameters:null})}e.md2=o(a.id_md2),e.md4=o(a.id_md5),e.sha1=o(a.id_sha1),e.sha224=o(a.id_sha224),e.sha256=o(a.id_sha256),e.sha384=o(a.id_sha384),e.sha512=o(a.id_sha512),e.sha512_224=o(a.id_sha512_224),e.sha512_256=o(a.id_sha512_256),e.mgf1SHA1=new i.AlgorithmIdentifier({algorithm:a.id_mgf1,parameters:r.AsnConvert.serialize(e.sha1)}),e.pSpecifiedEmpty=new i.AlgorithmIdentifier({algorithm:a.id_pSpecified,parameters:r.AsnConvert.serialize(r.AsnOctetStringConverter.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))}),e.rsaEncryption=o(a.id_rsaEncryption),e.md2WithRSAEncryption=o(a.id_md2WithRSAEncryption),e.md5WithRSAEncryption=o(a.id_md5WithRSAEncryption),e.sha1WithRSAEncryption=o(a.id_sha1WithRSAEncryption),e.sha224WithRSAEncryption=o(a.id_sha512_224WithRSAEncryption),e.sha256WithRSAEncryption=o(a.id_sha512_256WithRSAEncryption),e.sha384WithRSAEncryption=o(a.id_sha384WithRSAEncryption),e.sha512WithRSAEncryption=o(a.id_sha512WithRSAEncryption),e.sha512_224WithRSAEncryption=o(a.id_sha512_224WithRSAEncryption),e.sha512_256WithRSAEncryption=o(a.id_sha512_256WithRSAEncryption)})),pr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAES_OAEP=e.RsaEsOaepParams=void 0;let n=(K(),t(L)),r=J(),i=X(),a=dr(),o=fr();var s=class{hashAlgorithm=new i.AlgorithmIdentifier(o.sha1);maskGenAlgorithm=new i.AlgorithmIdentifier({algorithm:a.id_mgf1,parameters:r.AsnConvert.serialize(o.sha1)});pSourceAlgorithm=new i.AlgorithmIdentifier(o.pSpecifiedEmpty);constructor(e={}){Object.assign(this,e)}};e.RsaEsOaepParams=s,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:0,defaultValue:o.sha1})],s.prototype,`hashAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:1,defaultValue:o.mgf1SHA1})],s.prototype,`maskGenAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:2,defaultValue:o.pSpecifiedEmpty})],s.prototype,`pSourceAlgorithm`,void 0),e.RSAES_OAEP=new i.AlgorithmIdentifier({algorithm:a.id_RSAES_OAEP,parameters:r.AsnConvert.serialize(new s)})})),mr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSASSA_PSS=e.RsaSaPssParams=void 0;let n=(K(),t(L)),r=J(),i=X(),a=dr(),o=fr();var s=class{hashAlgorithm=new i.AlgorithmIdentifier(o.sha1);maskGenAlgorithm=new i.AlgorithmIdentifier({algorithm:a.id_mgf1,parameters:r.AsnConvert.serialize(o.sha1)});saltLength=20;trailerField=1;constructor(e={}){Object.assign(this,e)}};e.RsaSaPssParams=s,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:0,defaultValue:o.sha1})],s.prototype,`hashAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier,context:1,defaultValue:o.mgf1SHA1})],s.prototype,`maskGenAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:2,defaultValue:20})],s.prototype,`saltLength`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:3,defaultValue:1})],s.prototype,`trailerField`,void 0),e.RSASSA_PSS=new i.AlgorithmIdentifier({algorithm:a.id_RSASSA_PSS,parameters:r.AsnConvert.serialize(new s)})})),hr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DigestInfo=void 0;let n=(K(),t(L)),r=X(),i=J();var a=class{digestAlgorithm=new r.AlgorithmIdentifier;digest=new i.OctetString;constructor(e={}){Object.assign(this,e)}};e.DigestInfo=a,n.__decorate([(0,i.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`digestAlgorithm`,void 0),n.__decorate([(0,i.AsnProp)({type:i.OctetString})],a.prototype,`digest`,void 0)})),gr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(pr(),e),n.__exportStar(mr(),e),n.__exportStar(hr(),e)})),_r=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.OtherPrimeInfos=e.OtherPrimeInfo=void 0;let r=(K(),t(L)),i=J();var a=class{prime=new ArrayBuffer(0);exponent=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherPrimeInfo=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,converter:i.AsnIntegerArrayBufferConverter})],a.prototype,`prime`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,converter:i.AsnIntegerArrayBufferConverter})],a.prototype,`exponent`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,converter:i.AsnIntegerArrayBufferConverter})],a.prototype,`coefficient`,void 0);let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.OtherPrimeInfos=o,e.OtherPrimeInfos=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a})],o)})),vr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAPrivateKey=void 0;let n=(K(),t(L)),r=J(),i=_r();var a=class{version=0;modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);privateExponent=new ArrayBuffer(0);prime1=new ArrayBuffer(0);prime2=new ArrayBuffer(0);exponent1=new ArrayBuffer(0);exponent2=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);otherPrimeInfos;constructor(e={}){Object.assign(this,e)}};e.RSAPrivateKey=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],a.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`modulus`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`publicExponent`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`privateExponent`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`prime1`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`prime2`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`exponent1`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`exponent2`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],a.prototype,`coefficient`,void 0),n.__decorate([(0,r.AsnProp)({type:i.OtherPrimeInfos,optional:!0})],a.prototype,`otherPrimeInfos`,void 0)})),yr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAPublicKey=void 0;let n=(K(),t(L)),r=J();var i=class{modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.RSAPublicKey=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`modulus`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`publicExponent`,void 0)})),br=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(gr(),e),n.__exportStar(fr(),e),n.__exportStar(dr(),e),n.__exportStar(_r(),e),n.__exportStar(vr(),e),n.__exportStar(yr(),e)})),xr=o({__assign:()=>Gr,__asyncDelegator:()=>Lr,__asyncGenerator:()=>Ir,__asyncValues:()=>Rr,__await:()=>Fr,__awaiter:()=>Dr,__classPrivateFieldGet:()=>Hr,__classPrivateFieldSet:()=>Ur,__createBinding:()=>kr,__decorate:()=>wr,__exportStar:()=>Ar,__extends:()=>Sr,__generator:()=>Or,__importDefault:()=>Vr,__importStar:()=>Br,__makeTemplateObject:()=>zr,__metadata:()=>Er,__param:()=>Tr,__read:()=>Mr,__rest:()=>Cr,__spread:()=>Nr,__spreadArrays:()=>Pr,__values:()=>jr});
89
89
  /*! *****************************************************************************
90
90
  Copyright (c) Microsoft Corporation.
91
91
 
@@ -100,9 +100,9 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
100
100
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
101
101
  PERFORMANCE OF THIS SOFTWARE.
102
102
  ***************************************************************************** */
103
- function Qr(e,t){bi(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function $r(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ei(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function ti(e,t){return function(n,r){t(n,r,e)}}function ni(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function ri(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function ii(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function ai(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function oi(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function si(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function ci(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function li(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ci(arguments[t]));return e}function ui(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function di(e){return this instanceof di?(this.v=e,this):new di(e)}function fi(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i={},o(`next`),o(`throw`),o(`return`),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||s(e,t)})})}function s(e,t){try{c(r[e](t))}catch(e){d(a[0][3],e)}}function c(e){e.value instanceof di?Promise.resolve(e.value.v).then(l,u):d(a[0][2],e)}function l(e){s(`next`,e)}function u(e){s(`throw`,e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function pi(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:di(e[r](t)),done:r===`return`}:i?i(t):t}:i}}function mi(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof si==`function`?si(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function hi(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function gi(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function _i(e){return e&&e.__esModule?e:{default:e}}function vi(e,t){if(!t.has(e))throw TypeError(`attempted to get private field on non-instance`);return t.get(e)}function yi(e,t,n){if(!t.has(e))throw TypeError(`attempted to set private field on non-instance`);return t.set(e,n),n}var bi,xi,Si=r((()=>{bi=function(e,t){return bi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},bi(e,t)},xi=function(){return xi=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},xi.apply(this,arguments)}})),Ci=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t;(function(e){e[e.Transient=0]=`Transient`,e[e.Singleton=1]=`Singleton`,e[e.ResolutionScoped=2]=`ResolutionScoped`,e[e.ContainerScoped=3]=`ContainerScoped`})(t||={}),e.default=t})),wi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ci();Object.defineProperty(e,"Lifecycle",{enumerable:!0,get:function(){return t.default}})})),Ti=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defineInjectionTokenMetadata=e.getParamInfo=e.INJECTION_TOKEN_METADATA_KEY=void 0,e.INJECTION_TOKEN_METADATA_KEY=`injectionTokens`;function t(t){let n=Reflect.getMetadata(`design:paramtypes`,t)||[],r=Reflect.getOwnMetadata(e.INJECTION_TOKEN_METADATA_KEY,t)||{};return Object.keys(r).forEach(e=>{n[+e]=r[e]}),n}e.getParamInfo=t;function n(t,n){return function(r,i,a){let o=Reflect.getOwnMetadata(e.INJECTION_TOKEN_METADATA_KEY,r)||{};o[a]=n?{token:t,transform:n.transformToken,transformArgs:n.args||[]}:t,Reflect.defineMetadata(e.INJECTION_TOKEN_METADATA_KEY,o,r)}}e.defineInjectionTokenMetadata=n})),Ei=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isClassProvider=void 0;function t(e){return!!e.useClass}e.isClassProvider=t})),Di=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isFactoryProvider=void 0;function t(e){return!!e.useFactory}e.isFactoryProvider=t})),Oi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.delay=e.DelayedConstructor=void 0;var t=class{constructor(e){this.wrap=e,this.reflectMethods=[`get`,`getPrototypeOf`,`setPrototypeOf`,`getOwnPropertyDescriptor`,`defineProperty`,`has`,`set`,`deleteProperty`,`apply`,`construct`,`ownKeys`]}createProxy(e){let t={},n=!1,r;return new Proxy(t,this.createHandler(()=>(n||=(r=e(this.wrap()),!0),r)))}createHandler(e){let t={};return this.reflectMethods.forEach(n=>{t[n]=(...t)=>{t[0]=e();let r=Reflect[n];return r(...t)}}),t}};e.DelayedConstructor=t;function n(e){if(e===void 0)throw Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new t(e)}e.delay=n})),ki=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isConstructorToken=e.isTransformDescriptor=e.isTokenDescriptor=e.isNormalToken=void 0;let t=Oi();function n(e){return typeof e==`string`||typeof e==`symbol`}e.isNormalToken=n;function r(e){return typeof e==`object`&&`token`in e&&`multiple`in e}e.isTokenDescriptor=r;function i(e){return typeof e==`object`&&`token`in e&&`transform`in e}e.isTransformDescriptor=i;function a(e){return typeof e==`function`||e instanceof t.DelayedConstructor}e.isConstructorToken=a})),Ai=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isTokenProvider=void 0;function t(e){return!!e.useToken}e.isTokenProvider=t})),ji=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isValueProvider=void 0;function t(e){return e.useValue!=null}e.isValueProvider=t})),Mi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ei();Object.defineProperty(e,"isClassProvider",{enumerable:!0,get:function(){return t.isClassProvider}});var n=Di();Object.defineProperty(e,"isFactoryProvider",{enumerable:!0,get:function(){return n.isFactoryProvider}});var r=ki();Object.defineProperty(e,"isNormalToken",{enumerable:!0,get:function(){return r.isNormalToken}});var i=Ai();Object.defineProperty(e,"isTokenProvider",{enumerable:!0,get:function(){return i.isTokenProvider}});var a=ji();Object.defineProperty(e,"isValueProvider",{enumerable:!0,get:function(){return a.isValueProvider}})})),Ni=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isProvider=void 0;let t=Ei(),n=ji(),r=Ai(),i=Di();function a(e){return t.isClassProvider(e)||n.isValueProvider(e)||r.isTokenProvider(e)||i.isFactoryProvider(e)}e.isProvider=a})),Pi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let t=this._registryMap.get(e);return t[t.length-1]||null}set(e,t){this.ensure(e),this._registryMap.get(e).push(t)}setAll(e,t){this._registryMap.set(e,t)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}}})),Fi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Pi();e.default=class extends t.default{}})),Ii=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this.scopedResolutions=new Map}}})),Li=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatErrorCtor=void 0;function t(e,t){return e===null?`at position #${t}`:`"${e.split(`,`)[t].trim()}" at position #${t}`}function n(e,t,n=` `){return[e,...t.message.split(`
103
+ function Sr(e,t){Wr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Cr(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function wr(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Tr(e,t){return function(n,r){t(n,r,e)}}function Er(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Dr(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Or(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function kr(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function Ar(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function jr(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Mr(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Nr(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Mr(arguments[t]));return e}function Pr(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function Fr(e){return this instanceof Fr?(this.v=e,this):new Fr(e)}function Ir(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i={},o(`next`),o(`throw`),o(`return`),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||s(e,t)})})}function s(e,t){try{c(r[e](t))}catch(e){d(a[0][3],e)}}function c(e){e.value instanceof Fr?Promise.resolve(e.value.v).then(l,u):d(a[0][2],e)}function l(e){s(`next`,e)}function u(e){s(`throw`,e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function Lr(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:Fr(e[r](t)),done:r===`return`}:i?i(t):t}:i}}function Rr(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof jr==`function`?jr(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function zr(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Br(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function Vr(e){return e&&e.__esModule?e:{default:e}}function Hr(e,t){if(!t.has(e))throw TypeError(`attempted to get private field on non-instance`);return t.get(e)}function Ur(e,t,n){if(!t.has(e))throw TypeError(`attempted to set private field on non-instance`);return t.set(e,n),n}var Wr,Gr,Kr=r((()=>{Wr=function(e,t){return Wr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},Wr(e,t)},Gr=function(){return Gr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Gr.apply(this,arguments)}})),qr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t;(function(e){e[e.Transient=0]=`Transient`,e[e.Singleton=1]=`Singleton`,e[e.ResolutionScoped=2]=`ResolutionScoped`,e[e.ContainerScoped=3]=`ContainerScoped`})(t||={}),e.default=t})),Jr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=qr();Object.defineProperty(e,"Lifecycle",{enumerable:!0,get:function(){return t.default}})})),Yr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defineInjectionTokenMetadata=e.getParamInfo=e.INJECTION_TOKEN_METADATA_KEY=void 0,e.INJECTION_TOKEN_METADATA_KEY=`injectionTokens`;function t(t){let n=Reflect.getMetadata(`design:paramtypes`,t)||[],r=Reflect.getOwnMetadata(e.INJECTION_TOKEN_METADATA_KEY,t)||{};return Object.keys(r).forEach(e=>{n[+e]=r[e]}),n}e.getParamInfo=t;function n(t,n){return function(r,i,a){let o=Reflect.getOwnMetadata(e.INJECTION_TOKEN_METADATA_KEY,r)||{};o[a]=n?{token:t,transform:n.transformToken,transformArgs:n.args||[]}:t,Reflect.defineMetadata(e.INJECTION_TOKEN_METADATA_KEY,o,r)}}e.defineInjectionTokenMetadata=n})),Xr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isClassProvider=void 0;function t(e){return!!e.useClass}e.isClassProvider=t})),Zr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isFactoryProvider=void 0;function t(e){return!!e.useFactory}e.isFactoryProvider=t})),Qr=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.delay=e.DelayedConstructor=void 0;var t=class{constructor(e){this.wrap=e,this.reflectMethods=[`get`,`getPrototypeOf`,`setPrototypeOf`,`getOwnPropertyDescriptor`,`defineProperty`,`has`,`set`,`deleteProperty`,`apply`,`construct`,`ownKeys`]}createProxy(e){let t={},n=!1,r;return new Proxy(t,this.createHandler(()=>(n||=(r=e(this.wrap()),!0),r)))}createHandler(e){let t={};return this.reflectMethods.forEach(n=>{t[n]=(...t)=>{t[0]=e();let r=Reflect[n];return r(...t)}}),t}};e.DelayedConstructor=t;function n(e){if(e===void 0)throw Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new t(e)}e.delay=n})),$r=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isConstructorToken=e.isTransformDescriptor=e.isTokenDescriptor=e.isNormalToken=void 0;let t=Qr();function n(e){return typeof e==`string`||typeof e==`symbol`}e.isNormalToken=n;function r(e){return typeof e==`object`&&`token`in e&&`multiple`in e}e.isTokenDescriptor=r;function i(e){return typeof e==`object`&&`token`in e&&`transform`in e}e.isTransformDescriptor=i;function a(e){return typeof e==`function`||e instanceof t.DelayedConstructor}e.isConstructorToken=a})),ei=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isTokenProvider=void 0;function t(e){return!!e.useToken}e.isTokenProvider=t})),ti=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isValueProvider=void 0;function t(e){return e.useValue!=null}e.isValueProvider=t})),ni=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Xr();Object.defineProperty(e,"isClassProvider",{enumerable:!0,get:function(){return t.isClassProvider}});var n=Zr();Object.defineProperty(e,"isFactoryProvider",{enumerable:!0,get:function(){return n.isFactoryProvider}});var r=$r();Object.defineProperty(e,"isNormalToken",{enumerable:!0,get:function(){return r.isNormalToken}});var i=ei();Object.defineProperty(e,"isTokenProvider",{enumerable:!0,get:function(){return i.isTokenProvider}});var a=ti();Object.defineProperty(e,"isValueProvider",{enumerable:!0,get:function(){return a.isValueProvider}})})),ri=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isProvider=void 0;let t=Xr(),n=ti(),r=ei(),i=Zr();function a(e){return t.isClassProvider(e)||n.isValueProvider(e)||r.isTokenProvider(e)||i.isFactoryProvider(e)}e.isProvider=a})),ii=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let t=this._registryMap.get(e);return t[t.length-1]||null}set(e,t){this.ensure(e),this._registryMap.get(e).push(t)}setAll(e,t){this._registryMap.set(e,t)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}}})),ai=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ii();e.default=class extends t.default{}})),oi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this.scopedResolutions=new Map}}})),si=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatErrorCtor=void 0;function t(e,t){return e===null?`at position #${t}`:`"${e.split(`,`)[t].trim()}" at position #${t}`}function n(e,t,n=` `){return[e,...t.message.split(`
104
104
  `).map(e=>n+e)].join(`
105
- `)}function r(e,r,i){let[,a=null]=e.toString().match(/constructor\(([\w, ]+)\)/)||[];return n(`Cannot inject the dependency ${t(a,r)} of "${e.name}" constructor. Reason:`,i)}e.formatErrorCtor=r})),Ri=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isDisposable=void 0;function t(e){return!(typeof e.dispose!=`function`||e.dispose.length>0)}e.isDisposable=t})),zi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PostResolutionInterceptors=e.PreResolutionInterceptors=void 0;let t=Pi();var n=class extends t.default{};e.PreResolutionInterceptors=n;var r=class extends t.default{};e.PostResolutionInterceptors=r,e.default=class{constructor(){this.preResolution=new n,this.postResolution=new r}}})),Bi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.instance=e.typeInfo=void 0;let n=(Si(),t(Zr)),r=Mi(),i=Ni(),a=ki(),o=Fi(),s=Ci(),c=Ii(),l=Li(),u=Oi(),d=Ri(),f=zi();e.typeInfo=new Map,e.instance=new class t{constructor(e){this.parent=e,this._registry=new o.default,this.interceptors=new f.default,this.disposed=!1,this.disposables=new Set}register(e,t,n={lifecycle:s.default.Transient}){this.ensureNotDisposed();let a;if(a=i.isProvider(t)?t:{useClass:t},r.isTokenProvider(a)){let t=[e],n=a;for(;n!=null;){let e=n.useToken;if(t.includes(e))throw Error(`Token registration cycle detected! ${[...t,e].join(` -> `)}`);t.push(e);let i=this._registry.get(e);n=i&&r.isTokenProvider(i.provider)?i.provider:null}}if((n.lifecycle===s.default.Singleton||n.lifecycle==s.default.ContainerScoped||n.lifecycle==s.default.ResolutionScoped)&&(r.isValueProvider(a)||r.isFactoryProvider(a)))throw Error(`Cannot use lifecycle "${s.default[n.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:a,options:n}),this}registerType(e,t){return this.ensureNotDisposed(),r.isNormalToken(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})}registerInstance(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})}registerSingleton(e,t){if(this.ensureNotDisposed(),r.isNormalToken(e)){if(r.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:s.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:s.default.Singleton});throw Error(`Cannot register a type name as a singleton without a "to" token`)}let n=e;return t&&!r.isNormalToken(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:s.default.Singleton})}resolve(e,t=new c.default,n=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&r.isNormalToken(e)){if(n)return;throw Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,`Single`),i){let n=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,n,`Single`),n}if(a.isConstructorToken(e)){let n=this.construct(e,t);return this.executePostResolutionInterceptor(e,n,`Single`),n}throw Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let n=[];for(let r of this.interceptors.preResolution.getAll(e))r.options.frequency!=`Once`&&n.push(r),r.callback(e,t);this.interceptors.preResolution.setAll(e,n)}}executePostResolutionInterceptor(e,t,n){if(this.interceptors.postResolution.has(e)){let r=[];for(let i of this.interceptors.postResolution.getAll(e))i.options.frequency!=`Once`&&r.push(i),i.callback(e,t,n);this.interceptors.postResolution.setAll(e,r)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===s.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let n=e.options.lifecycle===s.default.Singleton,i=e.options.lifecycle===s.default.ContainerScoped,a=n||i,o;return o=r.isValueProvider(e.provider)?e.provider.useValue:r.isTokenProvider(e.provider)?a?e.instance||=this.resolve(e.provider.useToken,t):this.resolve(e.provider.useToken,t):r.isClassProvider(e.provider)?a?e.instance||=this.construct(e.provider.useClass,t):this.construct(e.provider.useClass,t):r.isFactoryProvider(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===s.default.ResolutionScoped&&t.scopedResolutions.set(e,o),o}resolveAll(e,t=new c.default,n=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&r.isNormalToken(e)){if(n)return[];throw Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,`All`),i){let n=i.map(e=>this.resolveRegistration(e,t));return this.executePostResolutionInterceptor(e,n,`All`),n}let a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,`All`),a}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(e=>!r.isValueProvider(e.provider)).map(e=>(e.instance=void 0,e)))}createChildContainer(){this.ensureNotDisposed();let e=new t(this);for(let[t,n]of this._registry.entries())n.some(({options:e})=>e.lifecycle===s.default.ContainerScoped)&&e._registry.setAll(t,n.map(e=>e.options.lifecycle===s.default.ContainerScoped?{provider:e.provider,options:e.options}:e));return e}beforeResolution(e,t,n={frequency:`Always`}){this.interceptors.preResolution.set(e,{callback:t,options:n})}afterResolution(e,t,n={frequency:`Always`}){this.interceptors.postResolution.set(e,{callback:t,options:n})}dispose(){return n.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let n=t.dispose();n&&e.push(n)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(t,n){if(t instanceof u.DelayedConstructor)return t.createProxy(e=>this.resolve(e,n));let r=(()=>{let r=e.typeInfo.get(t);if(!r||r.length===0){if(t.length===0)return new t;throw Error(`TypeInfo not known for "${t.name}"`)}return new t(...r.map(this.resolveParams(n,t)))})();return d.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(n,r)=>{try{return a.isTokenDescriptor(n)?a.isTransformDescriptor(n)?n.multiple?this.resolve(n.transform).transform(this.resolveAll(n.token,new c.default,n.isOptional),...n.transformArgs):this.resolve(n.transform).transform(this.resolve(n.token,e,n.isOptional),...n.transformArgs):n.multiple?this.resolveAll(n.token,new c.default,n.isOptional):this.resolve(n.token,e,n.isOptional):a.isTransformDescriptor(n)?this.resolve(n.transform,e).transform(this.resolve(n.token,e),...n.transformArgs):this.resolve(n,e)}catch(e){throw Error(l.formatErrorCtor(t,r,e))}}}ensureNotDisposed(){if(this.disposed)throw Error(`This container has been disposed, you cannot interact with a disposed container`)}},e.default=e.instance})),Vi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ti(),n=Bi(),r=ki(),i=Li();function a(){return function(e){let a=t.getParamInfo(e);return class extends e{constructor(...t){super(...t.concat(a.slice(t.length).map((a,o)=>{try{return r.isTokenDescriptor(a)?r.isTransformDescriptor(a)?a.multiple?n.instance.resolve(a.transform).transform(n.instance.resolveAll(a.token),...a.transformArgs):n.instance.resolve(a.transform).transform(n.instance.resolve(a.token),...a.transformArgs):a.multiple?n.instance.resolveAll(a.token):n.instance.resolve(a.token):r.isTransformDescriptor(a)?n.instance.resolve(a.transform).transform(n.instance.resolve(a.token),...a.transformArgs):n.instance.resolve(a)}catch(n){let r=o+t.length;throw Error(i.formatErrorCtor(e,r,n))}})))}}}}e.default=a})),Hi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ti();function n(e,n){let r={token:e,multiple:!1,isOptional:n&&n.isOptional};return t.defineInjectionTokenMetadata(r)}e.default=n})),Ui=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ti(),n=Bi(),r=Bi();function i(e){return function(i){n.typeInfo.set(i,t.getParamInfo(i)),e&&e.token&&(Array.isArray(e.token)?e.token.forEach(e=>{r.instance.register(e,i)}):r.instance.register(e.token,i))}}e.default=i})),Wi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(Si(),t(Zr)),r=Bi();function i(e=[]){return function(t){return e.forEach(e=>{var{token:t,options:i}=e,a=n.__rest(e,[`token`,`options`]);return r.instance.register(t,a,i)}),t}}e.default=i})),Gi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ui(),n=Bi();function r(){return function(e){t.default()(e),n.instance.registerSingleton(e)}}e.default=r})),Ki=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ti();function n(e,n){let r={token:e,multiple:!0,isOptional:n&&n.isOptional};return t.defineInjectionTokenMetadata(r)}e.default=n})),qi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ti();function n(e,n,...r){let i={token:e,multiple:!0,transform:n,transformArgs:r};return t.defineInjectionTokenMetadata(i)}e.default=n})),Ji=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ti();function n(e,n,...r){return t.defineInjectionTokenMetadata(e,{transformToken:n,args:r})}e.default=n})),Yi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ui(),n=Bi();function r(e,r){return function(i){t.default()(i),n.instance.register(r||i,i,{lifecycle:e})}}e.default=r})),Xi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Vi();Object.defineProperty(e,"autoInjectable",{enumerable:!0,get:function(){return t.default}});var n=Hi();Object.defineProperty(e,"inject",{enumerable:!0,get:function(){return n.default}});var r=Ui();Object.defineProperty(e,"injectable",{enumerable:!0,get:function(){return r.default}});var i=Wi();Object.defineProperty(e,"registry",{enumerable:!0,get:function(){return i.default}});var a=Gi();Object.defineProperty(e,"singleton",{enumerable:!0,get:function(){return a.default}});var o=Ki();Object.defineProperty(e,"injectAll",{enumerable:!0,get:function(){return o.default}});var s=qi();Object.defineProperty(e,"injectAllWithTransform",{enumerable:!0,get:function(){return s.default}});var c=Ji();Object.defineProperty(e,"injectWithTransform",{enumerable:!0,get:function(){return c.default}});var l=Yi();Object.defineProperty(e,"scoped",{enumerable:!0,get:function(){return l.default}})})),Zi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t;return n=>(t??=e(n),t)}e.default=t})),Qi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=new WeakMap;return n=>{let r=t.get(n);return r??(r=e(n),t.set(n,r)),r}}e.default=t})),$i=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t,n,r=!0){let i,a;return o=>{let s=e(o);return(!r||a!==s)&&(i=(a=s)?o.resolve(t):o.resolve(n)),i}}e.default=t})),ea=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Zi();Object.defineProperty(e,"instanceCachingFactory",{enumerable:!0,get:function(){return t.default}});var n=Qi();Object.defineProperty(e,"instancePerContainerCachingFactory",{enumerable:!0,get:function(){return n.default}});var r=$i();Object.defineProperty(e,"predicateAwareClassFactory",{enumerable:!0,get:function(){return r.default}})})),ta=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(Si(),t(Zr));if(typeof Reflect>`u`||!Reflect.getMetadata)throw Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var r=wi();Object.defineProperty(e,"Lifecycle",{enumerable:!0,get:function(){return r.Lifecycle}}),n.__exportStar(Xi(),e),n.__exportStar(ea(),e),n.__exportStar(Mi(),e);var i=Oi();Object.defineProperty(e,"delay",{enumerable:!0,get:function(){return i.delay}});var a=Bi();Object.defineProperty(e,"container",{enumerable:!0,get:function(){return a.instance}})})),na=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.PKCS12AttrSet=e.PKCS12Attribute=void 0;let r=(X(),t(q)),i=Z();var a=class{attrId=``;attrValues=[];constructor(e={}){Object.assign(e)}};e.PKCS12Attribute=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`attrId`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any,repeated:`set`})],a.prototype,`attrValues`,void 0);let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.PKCS12AttrSet=o,e.PKCS12AttrSet=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a})],o)})),ra=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.AuthenticatedSafe=void 0;let r=(X(),t(q)),i=Z(),a=Nr(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.AuthenticatedSafe=o,e.AuthenticatedSafe=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.ContentInfo})],o)})),ia=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_bagtypes=e.id_pbewithSHAAnd40BitRC2_CBC=e.id_pbeWithSHAAnd128BitRC2_CBC=e.id_pbeWithSHAAnd2_KeyTripleDES_CBC=e.id_pbeWithSHAAnd3_KeyTripleDES_CBC=e.id_pbeWithSHAAnd40BitRC4=e.id_pbeWithSHAAnd128BitRC4=e.id_pkcs_12PbeIds=e.id_pkcs_12=e.id_pkcs=e.id_rsadsi=void 0,e.id_rsadsi=`1.2.840.113549`,e.id_pkcs=`${e.id_rsadsi}.1`,e.id_pkcs_12=`${e.id_pkcs}.12`,e.id_pkcs_12PbeIds=`${e.id_pkcs_12}.1`,e.id_pbeWithSHAAnd128BitRC4=`${e.id_pkcs_12PbeIds}.1`,e.id_pbeWithSHAAnd40BitRC4=`${e.id_pkcs_12PbeIds}.2`,e.id_pbeWithSHAAnd3_KeyTripleDES_CBC=`${e.id_pkcs_12PbeIds}.3`,e.id_pbeWithSHAAnd2_KeyTripleDES_CBC=`${e.id_pkcs_12PbeIds}.4`,e.id_pbeWithSHAAnd128BitRC2_CBC=`${e.id_pkcs_12PbeIds}.5`,e.id_pbewithSHAAnd40BitRC2_CBC=`${e.id_pkcs_12PbeIds}.6`,e.id_bagtypes=`${e.id_pkcs_12}.10.1`})),aa=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_pkcs_9=e.id_SafeContents=e.id_SecretBag=e.id_CRLBag=e.id_certBag=e.id_pkcs8ShroudedKeyBag=e.id_keyBag=void 0;let t=ia();e.id_keyBag=`${t.id_bagtypes}.1`,e.id_pkcs8ShroudedKeyBag=`${t.id_bagtypes}.2`,e.id_certBag=`${t.id_bagtypes}.3`,e.id_CRLBag=`${t.id_bagtypes}.4`,e.id_SecretBag=`${t.id_bagtypes}.5`,e.id_SafeContents=`${t.id_bagtypes}.6`,e.id_pkcs_9=`1.2.840.113549.1.9`})),oa=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_sdsiCertificate=e.id_x509Certificate=e.id_certTypes=e.CertBag=void 0;let n=(X(),t(q)),r=Z(),i=aa();var a=class{certId=``;certValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertBag=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`certId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],a.prototype,`certValue`,void 0),e.id_certTypes=`${i.id_pkcs_9}.22`,e.id_x509Certificate=`${e.id_certTypes}.1`,e.id_sdsiCertificate=`${e.id_certTypes}.2`})),sa=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_x509CRL=e.id_crlTypes=e.CRLBag=void 0;let n=(X(),t(q)),r=Z(),i=aa();var a=class{crlId=``;crltValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CRLBag=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`crlId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],a.prototype,`crltValue`,void 0),e.id_crlTypes=`${i.id_pkcs_9}.23`,e.id_x509CRL=`${e.id_crlTypes}.1`})),ca=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncryptedPrivateKeyInfo=e.EncryptedData=void 0;let n=(X(),t(q)),r=Z(),i=$();var a=class extends r.OctetString{};e.EncryptedData=a;var o=class{encryptionAlgorithm=new i.AlgorithmIdentifier;encryptedData=new a;constructor(e={}){Object.assign(this,e)}};e.EncryptedPrivateKeyInfo=o,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`encryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:a})],o.prototype,`encryptedData`,void 0)})),la=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.PrivateKeyInfo=e.Attributes=e.PrivateKey=e.Version=void 0;let r=(X(),t(q)),i=Z(),a=$();var o;(function(e){e[e.v1=0]=`v1`})(o||(e.Version=o={}));var s=class extends i.OctetString{};e.PrivateKey=s;let c=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.Attributes=c,e.Attributes=c=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.Attribute})],c);var l=class{version=o.v1;privateKeyAlgorithm=new a.AlgorithmIdentifier;privateKey=new s;attributes;constructor(e={}){Object.assign(this,e)}};e.PrivateKeyInfo=l,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],l.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:a.AlgorithmIdentifier})],l.prototype,`privateKeyAlgorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:s})],l.prototype,`privateKey`,void 0),r.__decorate([(0,i.AsnProp)({type:c,implicit:!0,context:0,optional:!0})],l.prototype,`attributes`,void 0)})),ua=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(ca(),e),n.__exportStar(la(),e)})),da=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyBag=void 0;let n=(X(),t(q)),r=ua(),i=Z(),a=class extends r.PrivateKeyInfo{};e.KeyBag=a,e.KeyBag=a=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],a)})),fa=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PKCS8ShroudedKeyBag=void 0;let n=(X(),t(q)),r=ua(),i=Z(),a=class extends r.EncryptedPrivateKeyInfo{};e.PKCS8ShroudedKeyBag=a,e.PKCS8ShroudedKeyBag=a=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],a)})),pa=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SecretBag=void 0;let n=(X(),t(q)),r=Z();var i=class{secretTypeId=``;secretValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SecretBag=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`secretTypeId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],i.prototype,`secretValue`,void 0)})),ma=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(oa(),e),n.__exportStar(sa(),e),n.__exportStar(da(),e),n.__exportStar(fa(),e),n.__exportStar(pa(),e),n.__exportStar(aa(),e)})),ha=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MacData=void 0;let n=(X(),t(q)),r=Xr(),i=Z();var a=class{mac=new r.DigestInfo;macSalt=new i.OctetString;iterations=1;constructor(e={}){Object.assign(this,e)}};e.MacData=a,n.__decorate([(0,i.AsnProp)({type:r.DigestInfo})],a.prototype,`mac`,void 0),n.__decorate([(0,i.AsnProp)({type:i.OctetString})],a.prototype,`macSalt`,void 0),n.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,defaultValue:1})],a.prototype,`iterations`,void 0)})),ga=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PFX=void 0;let n=(X(),t(q)),r=Z(),i=Nr(),a=ha();var o=class{version=3;authSafe=new i.ContentInfo;macData=new a.MacData;constructor(e={}){Object.assign(this,e)}};e.PFX=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],o.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.ContentInfo})],o.prototype,`authSafe`,void 0),n.__decorate([(0,r.AsnProp)({type:a.MacData,optional:!0})],o.prototype,`macData`,void 0)})),_a=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeContents=e.SafeBag=void 0;let r=(X(),t(q)),i=Z(),a=na();var o=class{bagId=``;bagValue=new ArrayBuffer(0);bagAttributes;constructor(e={}){Object.assign(this,e)}};e.SafeBag=o,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],o.prototype,`bagId`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any,context:0})],o.prototype,`bagValue`,void 0),r.__decorate([(0,i.AsnProp)({type:a.PKCS12Attribute,repeated:`set`,optional:!0})],o.prototype,`bagAttributes`,void 0);let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SafeContents=s,e.SafeContents=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o})],s)})),va=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(na(),e),n.__exportStar(ra(),e),n.__exportStar(ma(),e),n.__exportStar(ha(),e),n.__exportStar(ia(),e),n.__exportStar(ga(),e),n.__exportStar(_a(),e)})),ya=s((e=>{var n,r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.DateOfBirth=e.UnstructuredAddress=e.UnstructuredName=e.EmailAddress=e.EncryptedPrivateKeyInfo=e.UserPKCS12=e.Pkcs7PDU=e.PKCS9String=e.id_at_pseudonym=e.crlTypes=e.id_certTypes=e.id_smime=e.id_pkcs9_mr_signingTimeMatch=e.id_pkcs9_mr_caseIgnoreMatch=e.id_pkcs9_sx_signingTime=e.id_pkcs9_sx_pkcs9String=e.id_pkcs9_at_countryOfResidence=e.id_pkcs9_at_countryOfCitizenship=e.id_pkcs9_at_gender=e.id_pkcs9_at_placeOfBirth=e.id_pkcs9_at_dateOfBirth=e.id_ietf_at=e.id_pkcs9_at_pkcs7PDU=e.id_pkcs9_at_sequenceNumber=e.id_pkcs9_at_randomNonce=e.id_pkcs9_at_encryptedPrivateKeyInfo=e.id_pkcs9_at_pkcs15Token=e.id_pkcs9_at_userPKCS12=e.id_pkcs9_at_localKeyId=e.id_pkcs9_at_friendlyName=e.id_pkcs9_at_smimeCapabilities=e.id_pkcs9_at_extensionRequest=e.id_pkcs9_at_signingDescription=e.id_pkcs9_at_extendedCertificateAttributes=e.id_pkcs9_at_unstructuredAddress=e.id_pkcs9_at_challengePassword=e.id_pkcs9_at_counterSignature=e.id_pkcs9_at_signingTime=e.id_pkcs9_at_messageDigest=e.id_pkcs9_at_contentType=e.id_pkcs9_at_unstructuredName=e.id_pkcs9_at_emailAddress=e.id_pkcs9_oc_naturalPerson=e.id_pkcs9_oc_pkcsEntity=e.id_pkcs9_mr=e.id_pkcs9_sx=e.id_pkcs9_at=e.id_pkcs9_oc=e.id_pkcs9_mo=e.id_pkcs9=void 0,e.SMIMECapabilities=e.SMIMECapability=e.SigningDescription=e.LocalKeyId=e.FriendlyName=e.ExtendedCertificateAttributes=e.ExtensionRequest=e.ChallengePassword=e.CounterSignature=e.SequenceNumber=e.RandomNonce=e.SigningTime=e.MessageDigest=e.ContentType=e.Pseudonym=e.CountryOfResidence=e.CountryOfCitizenship=e.Gender=e.PlaceOfBirth=void 0;let a=(X(),t(q)),o=Z(),s=a.__importStar(Nr()),c=a.__importStar(va()),l=a.__importStar(ua()),u=a.__importStar($()),d=a.__importStar(gr());e.id_pkcs9=`1.2.840.113549.1.9`,e.id_pkcs9_mo=`${e.id_pkcs9}.0`,e.id_pkcs9_oc=`${e.id_pkcs9}.24`,e.id_pkcs9_at=`${e.id_pkcs9}.25`,e.id_pkcs9_sx=`${e.id_pkcs9}.26`,e.id_pkcs9_mr=`${e.id_pkcs9}.27`,e.id_pkcs9_oc_pkcsEntity=`${e.id_pkcs9_oc}.1`,e.id_pkcs9_oc_naturalPerson=`${e.id_pkcs9_oc}.2`,e.id_pkcs9_at_emailAddress=`${e.id_pkcs9}.1`,e.id_pkcs9_at_unstructuredName=`${e.id_pkcs9}.2`,e.id_pkcs9_at_contentType=`${e.id_pkcs9}.3`,e.id_pkcs9_at_messageDigest=`${e.id_pkcs9}.4`,e.id_pkcs9_at_signingTime=`${e.id_pkcs9}.5`,e.id_pkcs9_at_counterSignature=`${e.id_pkcs9}.6`,e.id_pkcs9_at_challengePassword=`${e.id_pkcs9}.7`,e.id_pkcs9_at_unstructuredAddress=`${e.id_pkcs9}.8`,e.id_pkcs9_at_extendedCertificateAttributes=`${e.id_pkcs9}.9`,e.id_pkcs9_at_signingDescription=`${e.id_pkcs9}.13`,e.id_pkcs9_at_extensionRequest=`${e.id_pkcs9}.14`,e.id_pkcs9_at_smimeCapabilities=`${e.id_pkcs9}.15`,e.id_pkcs9_at_friendlyName=`${e.id_pkcs9}.20`,e.id_pkcs9_at_localKeyId=`${e.id_pkcs9}.21`,e.id_pkcs9_at_userPKCS12=`2.16.840.1.113730.3.1.216`,e.id_pkcs9_at_pkcs15Token=`${e.id_pkcs9_at}.1`,e.id_pkcs9_at_encryptedPrivateKeyInfo=`${e.id_pkcs9_at}.2`,e.id_pkcs9_at_randomNonce=`${e.id_pkcs9_at}.3`,e.id_pkcs9_at_sequenceNumber=`${e.id_pkcs9_at}.4`,e.id_pkcs9_at_pkcs7PDU=`${e.id_pkcs9_at}.5`,e.id_ietf_at=`1.3.6.1.5.5.7.9`,e.id_pkcs9_at_dateOfBirth=`${e.id_ietf_at}.1`,e.id_pkcs9_at_placeOfBirth=`${e.id_ietf_at}.2`,e.id_pkcs9_at_gender=`${e.id_ietf_at}.3`,e.id_pkcs9_at_countryOfCitizenship=`${e.id_ietf_at}.4`,e.id_pkcs9_at_countryOfResidence=`${e.id_ietf_at}.5`,e.id_pkcs9_sx_pkcs9String=`${e.id_pkcs9_sx}.1`,e.id_pkcs9_sx_signingTime=`${e.id_pkcs9_sx}.2`,e.id_pkcs9_mr_caseIgnoreMatch=`${e.id_pkcs9_mr}.1`,e.id_pkcs9_mr_signingTimeMatch=`${e.id_pkcs9_mr}.2`,e.id_smime=`${e.id_pkcs9}.16`,e.id_certTypes=`${e.id_pkcs9}.22`,e.crlTypes=`${e.id_pkcs9}.23`,e.id_at_pseudonym=`${d.id_at}.65`;let f=class extends u.DirectoryString{ia5String;constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};e.PKCS9String=f,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.IA5String})],f.prototype,`ia5String`,void 0),e.PKCS9String=f=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],f);let p=class extends s.ContentInfo{};e.Pkcs7PDU=p,e.Pkcs7PDU=p=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],p);let m=class extends c.PFX{};e.UserPKCS12=m,e.UserPKCS12=m=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],m);let h=class extends l.EncryptedPrivateKeyInfo{};e.EncryptedPrivateKeyInfo=h,e.EncryptedPrivateKeyInfo=h=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],h);let g=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.EmailAddress=g,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.IA5String})],g.prototype,`value`,void 0),e.EmailAddress=g=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],g);let _=class extends f{};e.UnstructuredName=_,e.UnstructuredName=_=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],_);let v=class extends u.DirectoryString{};e.UnstructuredAddress=v,e.UnstructuredAddress=v=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],v);let y=class{value;constructor(e=new Date){this.value=e}};e.DateOfBirth=y,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.GeneralizedTime})],y.prototype,`value`,void 0),e.DateOfBirth=y=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],y);let b=class extends u.DirectoryString{};e.PlaceOfBirth=b,e.PlaceOfBirth=b=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],b);let x=class{value;constructor(e=`M`){this.value=e}toString(){return this.value}};e.Gender=x,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.PrintableString})],x.prototype,`value`,void 0),e.Gender=x=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],x);let S=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.CountryOfCitizenship=S,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.PrintableString})],S.prototype,`value`,void 0),e.CountryOfCitizenship=S=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],S);let C=class extends S{};e.CountryOfResidence=C,e.CountryOfResidence=C=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],C);let w=class extends u.DirectoryString{};e.Pseudonym=w,e.Pseudonym=w=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],w);let T=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.ContentType=T,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.ObjectIdentifier})],T.prototype,`value`,void 0),e.ContentType=T=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],T),e.MessageDigest=class extends o.OctetString{};let E=class extends u.Time{};e.SigningTime=E,e.SigningTime=E=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],E),e.RandomNonce=class extends o.OctetString{};let D=class{value;constructor(e=0){this.value=e}toString(){return this.value.toString()}};e.SequenceNumber=D,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.Integer})],D.prototype,`value`,void 0),e.SequenceNumber=D=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],D);let O=class extends s.SignerInfo{};e.CounterSignature=O,e.CounterSignature=O=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],O);let k=class extends u.DirectoryString{};e.ChallengePassword=k,e.ChallengePassword=k=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],k);let A=n=class extends u.Extensions{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.ExtensionRequest=A,e.ExtensionRequest=A=n=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],A);let j=r=class extends o.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};e.ExtendedCertificateAttributes=j,e.ExtendedCertificateAttributes=j=r=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Set,itemType:s.Attribute})],j);let M=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.FriendlyName=M,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.BmpString})],M.prototype,`value`,void 0),e.FriendlyName=M=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],M),e.LocalKeyId=class extends o.OctetString{},e.SigningDescription=class extends u.DirectoryString{};let N=class extends u.AlgorithmIdentifier{};e.SMIMECapability=N,e.SMIMECapability=N=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],N);let ee=i=class extends o.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,i.prototype)}};e.SMIMECapabilities=ee,e.SMIMECapabilities=ee=i=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence,itemType:N})],ee)})),ba=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.Attributes=void 0;let r=(X(),t(q)),i=Z(),a=$(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.Attributes=o,e.Attributes=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.Attribute})],o)})),xa=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificationRequestInfo=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=ba();var o=class{version=0;subject=new i.Name;subjectPKInfo=new i.SubjectPublicKeyInfo;attributes=new a.Attributes;constructor(e={}){Object.assign(this,e)}};e.CertificationRequestInfo=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],o.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Name})],o.prototype,`subject`,void 0),n.__decorate([(0,r.AsnProp)({type:i.SubjectPublicKeyInfo})],o.prototype,`subjectPKInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Attributes,implicit:!0,context:0,optional:!0})],o.prototype,`attributes`,void 0)})),Sa=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificationRequest=void 0;let n=(X(),t(q)),r=Z(),i=$(),a=xa();var o=class{certificationRequestInfo=new a.CertificationRequestInfo;certificationRequestInfoRaw;signatureAlgorithm=new i.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertificationRequest=o,n.__decorate([(0,r.AsnProp)({type:a.CertificationRequestInfo,raw:!0})],o.prototype,`certificationRequestInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`signature`,void 0)})),Ca=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(X(),t(q));n.__exportStar(ba(),e),n.__exportStar(Sa(),e),n.__exportStar(xa(),e)})),wa=s((e=>{
105
+ `)}function r(e,r,i){let[,a=null]=e.toString().match(/constructor\(([\w, ]+)\)/)||[];return n(`Cannot inject the dependency ${t(a,r)} of "${e.name}" constructor. Reason:`,i)}e.formatErrorCtor=r})),ci=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isDisposable=void 0;function t(e){return!(typeof e.dispose!=`function`||e.dispose.length>0)}e.isDisposable=t})),li=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PostResolutionInterceptors=e.PreResolutionInterceptors=void 0;let t=ii();var n=class extends t.default{};e.PreResolutionInterceptors=n;var r=class extends t.default{};e.PostResolutionInterceptors=r,e.default=class{constructor(){this.preResolution=new n,this.postResolution=new r}}})),ui=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.instance=e.typeInfo=void 0;let n=(Kr(),t(xr)),r=ni(),i=ri(),a=$r(),o=ai(),s=qr(),c=oi(),l=si(),u=Qr(),d=ci(),f=li();e.typeInfo=new Map,e.instance=new class t{constructor(e){this.parent=e,this._registry=new o.default,this.interceptors=new f.default,this.disposed=!1,this.disposables=new Set}register(e,t,n={lifecycle:s.default.Transient}){this.ensureNotDisposed();let a;if(a=i.isProvider(t)?t:{useClass:t},r.isTokenProvider(a)){let t=[e],n=a;for(;n!=null;){let e=n.useToken;if(t.includes(e))throw Error(`Token registration cycle detected! ${[...t,e].join(` -> `)}`);t.push(e);let i=this._registry.get(e);n=i&&r.isTokenProvider(i.provider)?i.provider:null}}if((n.lifecycle===s.default.Singleton||n.lifecycle==s.default.ContainerScoped||n.lifecycle==s.default.ResolutionScoped)&&(r.isValueProvider(a)||r.isFactoryProvider(a)))throw Error(`Cannot use lifecycle "${s.default[n.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:a,options:n}),this}registerType(e,t){return this.ensureNotDisposed(),r.isNormalToken(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})}registerInstance(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})}registerSingleton(e,t){if(this.ensureNotDisposed(),r.isNormalToken(e)){if(r.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:s.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:s.default.Singleton});throw Error(`Cannot register a type name as a singleton without a "to" token`)}let n=e;return t&&!r.isNormalToken(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:s.default.Singleton})}resolve(e,t=new c.default,n=!1){this.ensureNotDisposed();let i=this.getRegistration(e);if(!i&&r.isNormalToken(e)){if(n)return;throw Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,`Single`),i){let n=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,n,`Single`),n}if(a.isConstructorToken(e)){let n=this.construct(e,t);return this.executePostResolutionInterceptor(e,n,`Single`),n}throw Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let n=[];for(let r of this.interceptors.preResolution.getAll(e))r.options.frequency!=`Once`&&n.push(r),r.callback(e,t);this.interceptors.preResolution.setAll(e,n)}}executePostResolutionInterceptor(e,t,n){if(this.interceptors.postResolution.has(e)){let r=[];for(let i of this.interceptors.postResolution.getAll(e))i.options.frequency!=`Once`&&r.push(i),i.callback(e,t,n);this.interceptors.postResolution.setAll(e,r)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===s.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let n=e.options.lifecycle===s.default.Singleton,i=e.options.lifecycle===s.default.ContainerScoped,a=n||i,o;return o=r.isValueProvider(e.provider)?e.provider.useValue:r.isTokenProvider(e.provider)?a?e.instance||=this.resolve(e.provider.useToken,t):this.resolve(e.provider.useToken,t):r.isClassProvider(e.provider)?a?e.instance||=this.construct(e.provider.useClass,t):this.construct(e.provider.useClass,t):r.isFactoryProvider(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===s.default.ResolutionScoped&&t.scopedResolutions.set(e,o),o}resolveAll(e,t=new c.default,n=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&r.isNormalToken(e)){if(n)return[];throw Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,`All`),i){let n=i.map(e=>this.resolveRegistration(e,t));return this.executePostResolutionInterceptor(e,n,`All`),n}let a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,`All`),a}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(e=>!r.isValueProvider(e.provider)).map(e=>(e.instance=void 0,e)))}createChildContainer(){this.ensureNotDisposed();let e=new t(this);for(let[t,n]of this._registry.entries())n.some(({options:e})=>e.lifecycle===s.default.ContainerScoped)&&e._registry.setAll(t,n.map(e=>e.options.lifecycle===s.default.ContainerScoped?{provider:e.provider,options:e.options}:e));return e}beforeResolution(e,t,n={frequency:`Always`}){this.interceptors.preResolution.set(e,{callback:t,options:n})}afterResolution(e,t,n={frequency:`Always`}){this.interceptors.postResolution.set(e,{callback:t,options:n})}dispose(){return n.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let n=t.dispose();n&&e.push(n)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(t,n){if(t instanceof u.DelayedConstructor)return t.createProxy(e=>this.resolve(e,n));let r=(()=>{let r=e.typeInfo.get(t);if(!r||r.length===0){if(t.length===0)return new t;throw Error(`TypeInfo not known for "${t.name}"`)}return new t(...r.map(this.resolveParams(n,t)))})();return d.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(n,r)=>{try{return a.isTokenDescriptor(n)?a.isTransformDescriptor(n)?n.multiple?this.resolve(n.transform).transform(this.resolveAll(n.token,new c.default,n.isOptional),...n.transformArgs):this.resolve(n.transform).transform(this.resolve(n.token,e,n.isOptional),...n.transformArgs):n.multiple?this.resolveAll(n.token,new c.default,n.isOptional):this.resolve(n.token,e,n.isOptional):a.isTransformDescriptor(n)?this.resolve(n.transform,e).transform(this.resolve(n.token,e),...n.transformArgs):this.resolve(n,e)}catch(e){throw Error(l.formatErrorCtor(t,r,e))}}}ensureNotDisposed(){if(this.disposed)throw Error(`This container has been disposed, you cannot interact with a disposed container`)}},e.default=e.instance})),di=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yr(),n=ui(),r=$r(),i=si();function a(){return function(e){let a=t.getParamInfo(e);return class extends e{constructor(...t){super(...t.concat(a.slice(t.length).map((a,o)=>{try{return r.isTokenDescriptor(a)?r.isTransformDescriptor(a)?a.multiple?n.instance.resolve(a.transform).transform(n.instance.resolveAll(a.token),...a.transformArgs):n.instance.resolve(a.transform).transform(n.instance.resolve(a.token),...a.transformArgs):a.multiple?n.instance.resolveAll(a.token):n.instance.resolve(a.token):r.isTransformDescriptor(a)?n.instance.resolve(a.transform).transform(n.instance.resolve(a.token),...a.transformArgs):n.instance.resolve(a)}catch(n){let r=o+t.length;throw Error(i.formatErrorCtor(e,r,n))}})))}}}}e.default=a})),fi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yr();function n(e,n){let r={token:e,multiple:!1,isOptional:n&&n.isOptional};return t.defineInjectionTokenMetadata(r)}e.default=n})),pi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yr(),n=ui(),r=ui();function i(e){return function(i){n.typeInfo.set(i,t.getParamInfo(i)),e&&e.token&&(Array.isArray(e.token)?e.token.forEach(e=>{r.instance.register(e,i)}):r.instance.register(e.token,i))}}e.default=i})),mi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(Kr(),t(xr)),r=ui();function i(e=[]){return function(t){return e.forEach(e=>{var{token:t,options:i}=e,a=n.__rest(e,[`token`,`options`]);return r.instance.register(t,a,i)}),t}}e.default=i})),hi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=pi(),n=ui();function r(){return function(e){t.default()(e),n.instance.registerSingleton(e)}}e.default=r})),gi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yr();function n(e,n){let r={token:e,multiple:!0,isOptional:n&&n.isOptional};return t.defineInjectionTokenMetadata(r)}e.default=n})),_i=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yr();function n(e,n,...r){let i={token:e,multiple:!0,transform:n,transformArgs:r};return t.defineInjectionTokenMetadata(i)}e.default=n})),vi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Yr();function n(e,n,...r){return t.defineInjectionTokenMetadata(e,{transformToken:n,args:r})}e.default=n})),yi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=pi(),n=ui();function r(e,r){return function(i){t.default()(i),n.instance.register(r||i,i,{lifecycle:e})}}e.default=r})),bi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=di();Object.defineProperty(e,"autoInjectable",{enumerable:!0,get:function(){return t.default}});var n=fi();Object.defineProperty(e,"inject",{enumerable:!0,get:function(){return n.default}});var r=pi();Object.defineProperty(e,"injectable",{enumerable:!0,get:function(){return r.default}});var i=mi();Object.defineProperty(e,"registry",{enumerable:!0,get:function(){return i.default}});var a=hi();Object.defineProperty(e,"singleton",{enumerable:!0,get:function(){return a.default}});var o=gi();Object.defineProperty(e,"injectAll",{enumerable:!0,get:function(){return o.default}});var s=_i();Object.defineProperty(e,"injectAllWithTransform",{enumerable:!0,get:function(){return s.default}});var c=vi();Object.defineProperty(e,"injectWithTransform",{enumerable:!0,get:function(){return c.default}});var l=yi();Object.defineProperty(e,"scoped",{enumerable:!0,get:function(){return l.default}})})),xi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t;return n=>(t??=e(n),t)}e.default=t})),Si=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=new WeakMap;return n=>{let r=t.get(n);return r??(r=e(n),t.set(n,r)),r}}e.default=t})),Ci=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t,n,r=!0){let i,a;return o=>{let s=e(o);return(!r||a!==s)&&(i=(a=s)?o.resolve(t):o.resolve(n)),i}}e.default=t})),wi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=xi();Object.defineProperty(e,"instanceCachingFactory",{enumerable:!0,get:function(){return t.default}});var n=Si();Object.defineProperty(e,"instancePerContainerCachingFactory",{enumerable:!0,get:function(){return n.default}});var r=Ci();Object.defineProperty(e,"predicateAwareClassFactory",{enumerable:!0,get:function(){return r.default}})})),Ti=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(Kr(),t(xr));if(typeof Reflect>`u`||!Reflect.getMetadata)throw Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var r=Jr();Object.defineProperty(e,"Lifecycle",{enumerable:!0,get:function(){return r.Lifecycle}}),n.__exportStar(bi(),e),n.__exportStar(wi(),e),n.__exportStar(ni(),e);var i=Qr();Object.defineProperty(e,"delay",{enumerable:!0,get:function(){return i.delay}});var a=ui();Object.defineProperty(e,"container",{enumerable:!0,get:function(){return a.instance}})})),Ei=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.PKCS12AttrSet=e.PKCS12Attribute=void 0;let r=(K(),t(L)),i=J();var a=class{attrId=``;attrValues=[];constructor(e={}){Object.assign(e)}};e.PKCS12Attribute=a,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],a.prototype,`attrId`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any,repeated:`set`})],a.prototype,`attrValues`,void 0);let o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.PKCS12AttrSet=o,e.PKCS12AttrSet=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a})],o)})),Di=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.AuthenticatedSafe=void 0;let r=(K(),t(L)),i=J(),a=rr(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.AuthenticatedSafe=o,e.AuthenticatedSafe=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.ContentInfo})],o)})),Oi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_bagtypes=e.id_pbewithSHAAnd40BitRC2_CBC=e.id_pbeWithSHAAnd128BitRC2_CBC=e.id_pbeWithSHAAnd2_KeyTripleDES_CBC=e.id_pbeWithSHAAnd3_KeyTripleDES_CBC=e.id_pbeWithSHAAnd40BitRC4=e.id_pbeWithSHAAnd128BitRC4=e.id_pkcs_12PbeIds=e.id_pkcs_12=e.id_pkcs=e.id_rsadsi=void 0,e.id_rsadsi=`1.2.840.113549`,e.id_pkcs=`${e.id_rsadsi}.1`,e.id_pkcs_12=`${e.id_pkcs}.12`,e.id_pkcs_12PbeIds=`${e.id_pkcs_12}.1`,e.id_pbeWithSHAAnd128BitRC4=`${e.id_pkcs_12PbeIds}.1`,e.id_pbeWithSHAAnd40BitRC4=`${e.id_pkcs_12PbeIds}.2`,e.id_pbeWithSHAAnd3_KeyTripleDES_CBC=`${e.id_pkcs_12PbeIds}.3`,e.id_pbeWithSHAAnd2_KeyTripleDES_CBC=`${e.id_pkcs_12PbeIds}.4`,e.id_pbeWithSHAAnd128BitRC2_CBC=`${e.id_pkcs_12PbeIds}.5`,e.id_pbewithSHAAnd40BitRC2_CBC=`${e.id_pkcs_12PbeIds}.6`,e.id_bagtypes=`${e.id_pkcs_12}.10.1`})),ki=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_pkcs_9=e.id_SafeContents=e.id_SecretBag=e.id_CRLBag=e.id_certBag=e.id_pkcs8ShroudedKeyBag=e.id_keyBag=void 0;let t=Oi();e.id_keyBag=`${t.id_bagtypes}.1`,e.id_pkcs8ShroudedKeyBag=`${t.id_bagtypes}.2`,e.id_certBag=`${t.id_bagtypes}.3`,e.id_CRLBag=`${t.id_bagtypes}.4`,e.id_SecretBag=`${t.id_bagtypes}.5`,e.id_SafeContents=`${t.id_bagtypes}.6`,e.id_pkcs_9=`1.2.840.113549.1.9`})),Ai=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_sdsiCertificate=e.id_x509Certificate=e.id_certTypes=e.CertBag=void 0;let n=(K(),t(L)),r=J(),i=ki();var a=class{certId=``;certValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertBag=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`certId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],a.prototype,`certValue`,void 0),e.id_certTypes=`${i.id_pkcs_9}.22`,e.id_x509Certificate=`${e.id_certTypes}.1`,e.id_sdsiCertificate=`${e.id_certTypes}.2`})),ji=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_x509CRL=e.id_crlTypes=e.CRLBag=void 0;let n=(K(),t(L)),r=J(),i=ki();var a=class{crlId=``;crltValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CRLBag=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`crlId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],a.prototype,`crltValue`,void 0),e.id_crlTypes=`${i.id_pkcs_9}.23`,e.id_x509CRL=`${e.id_crlTypes}.1`})),Mi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncryptedPrivateKeyInfo=e.EncryptedData=void 0;let n=(K(),t(L)),r=J(),i=X();var a=class extends r.OctetString{};e.EncryptedData=a;var o=class{encryptionAlgorithm=new i.AlgorithmIdentifier;encryptedData=new a;constructor(e={}){Object.assign(this,e)}};e.EncryptedPrivateKeyInfo=o,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`encryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:a})],o.prototype,`encryptedData`,void 0)})),Ni=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.PrivateKeyInfo=e.Attributes=e.PrivateKey=e.Version=void 0;let r=(K(),t(L)),i=J(),a=X();var o;(function(e){e[e.v1=0]=`v1`})(o||(e.Version=o={}));var s=class extends i.OctetString{};e.PrivateKey=s;let c=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.Attributes=c,e.Attributes=c=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.Attribute})],c);var l=class{version=o.v1;privateKeyAlgorithm=new a.AlgorithmIdentifier;privateKey=new s;attributes;constructor(e={}){Object.assign(this,e)}};e.PrivateKeyInfo=l,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer})],l.prototype,`version`,void 0),r.__decorate([(0,i.AsnProp)({type:a.AlgorithmIdentifier})],l.prototype,`privateKeyAlgorithm`,void 0),r.__decorate([(0,i.AsnProp)({type:s})],l.prototype,`privateKey`,void 0),r.__decorate([(0,i.AsnProp)({type:c,implicit:!0,context:0,optional:!0})],l.prototype,`attributes`,void 0)})),Pi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(Mi(),e),n.__exportStar(Ni(),e)})),Fi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyBag=void 0;let n=(K(),t(L)),r=Pi(),i=J(),a=class extends r.PrivateKeyInfo{};e.KeyBag=a,e.KeyBag=a=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],a)})),Ii=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PKCS8ShroudedKeyBag=void 0;let n=(K(),t(L)),r=Pi(),i=J(),a=class extends r.EncryptedPrivateKeyInfo{};e.PKCS8ShroudedKeyBag=a,e.PKCS8ShroudedKeyBag=a=n.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence})],a)})),Li=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SecretBag=void 0;let n=(K(),t(L)),r=J();var i=class{secretTypeId=``;secretValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SecretBag=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`secretTypeId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],i.prototype,`secretValue`,void 0)})),Ri=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(Ai(),e),n.__exportStar(ji(),e),n.__exportStar(Fi(),e),n.__exportStar(Ii(),e),n.__exportStar(Li(),e),n.__exportStar(ki(),e)})),zi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MacData=void 0;let n=(K(),t(L)),r=br(),i=J();var a=class{mac=new r.DigestInfo;macSalt=new i.OctetString;iterations=1;constructor(e={}){Object.assign(this,e)}};e.MacData=a,n.__decorate([(0,i.AsnProp)({type:r.DigestInfo})],a.prototype,`mac`,void 0),n.__decorate([(0,i.AsnProp)({type:i.OctetString})],a.prototype,`macSalt`,void 0),n.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Integer,defaultValue:1})],a.prototype,`iterations`,void 0)})),Bi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PFX=void 0;let n=(K(),t(L)),r=J(),i=rr(),a=zi();var o=class{version=3;authSafe=new i.ContentInfo;macData=new a.MacData;constructor(e={}){Object.assign(this,e)}};e.PFX=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],o.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.ContentInfo})],o.prototype,`authSafe`,void 0),n.__decorate([(0,r.AsnProp)({type:a.MacData,optional:!0})],o.prototype,`macData`,void 0)})),Vi=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeContents=e.SafeBag=void 0;let r=(K(),t(L)),i=J(),a=Ei();var o=class{bagId=``;bagValue=new ArrayBuffer(0);bagAttributes;constructor(e={}){Object.assign(this,e)}};e.SafeBag=o,r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.ObjectIdentifier})],o.prototype,`bagId`,void 0),r.__decorate([(0,i.AsnProp)({type:i.AsnPropTypes.Any,context:0})],o.prototype,`bagValue`,void 0),r.__decorate([(0,i.AsnProp)({type:a.PKCS12Attribute,repeated:`set`,optional:!0})],o.prototype,`bagAttributes`,void 0);let s=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.SafeContents=s,e.SafeContents=s=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:o})],s)})),Hi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(Ei(),e),n.__exportStar(Di(),e),n.__exportStar(Ri(),e),n.__exportStar(zi(),e),n.__exportStar(Oi(),e),n.__exportStar(Bi(),e),n.__exportStar(Vi(),e)})),Ui=s((e=>{var n,r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.DateOfBirth=e.UnstructuredAddress=e.UnstructuredName=e.EmailAddress=e.EncryptedPrivateKeyInfo=e.UserPKCS12=e.Pkcs7PDU=e.PKCS9String=e.id_at_pseudonym=e.crlTypes=e.id_certTypes=e.id_smime=e.id_pkcs9_mr_signingTimeMatch=e.id_pkcs9_mr_caseIgnoreMatch=e.id_pkcs9_sx_signingTime=e.id_pkcs9_sx_pkcs9String=e.id_pkcs9_at_countryOfResidence=e.id_pkcs9_at_countryOfCitizenship=e.id_pkcs9_at_gender=e.id_pkcs9_at_placeOfBirth=e.id_pkcs9_at_dateOfBirth=e.id_ietf_at=e.id_pkcs9_at_pkcs7PDU=e.id_pkcs9_at_sequenceNumber=e.id_pkcs9_at_randomNonce=e.id_pkcs9_at_encryptedPrivateKeyInfo=e.id_pkcs9_at_pkcs15Token=e.id_pkcs9_at_userPKCS12=e.id_pkcs9_at_localKeyId=e.id_pkcs9_at_friendlyName=e.id_pkcs9_at_smimeCapabilities=e.id_pkcs9_at_extensionRequest=e.id_pkcs9_at_signingDescription=e.id_pkcs9_at_extendedCertificateAttributes=e.id_pkcs9_at_unstructuredAddress=e.id_pkcs9_at_challengePassword=e.id_pkcs9_at_counterSignature=e.id_pkcs9_at_signingTime=e.id_pkcs9_at_messageDigest=e.id_pkcs9_at_contentType=e.id_pkcs9_at_unstructuredName=e.id_pkcs9_at_emailAddress=e.id_pkcs9_oc_naturalPerson=e.id_pkcs9_oc_pkcsEntity=e.id_pkcs9_mr=e.id_pkcs9_sx=e.id_pkcs9_at=e.id_pkcs9_oc=e.id_pkcs9_mo=e.id_pkcs9=void 0,e.SMIMECapabilities=e.SMIMECapability=e.SigningDescription=e.LocalKeyId=e.FriendlyName=e.ExtendedCertificateAttributes=e.ExtensionRequest=e.ChallengePassword=e.CounterSignature=e.SequenceNumber=e.RandomNonce=e.SigningTime=e.MessageDigest=e.ContentType=e.Pseudonym=e.CountryOfResidence=e.CountryOfCitizenship=e.Gender=e.PlaceOfBirth=void 0;let a=(K(),t(L)),o=J(),s=a.__importStar(rr()),c=a.__importStar(Hi()),l=a.__importStar(Pi()),u=a.__importStar(X()),d=a.__importStar(Bn());e.id_pkcs9=`1.2.840.113549.1.9`,e.id_pkcs9_mo=`${e.id_pkcs9}.0`,e.id_pkcs9_oc=`${e.id_pkcs9}.24`,e.id_pkcs9_at=`${e.id_pkcs9}.25`,e.id_pkcs9_sx=`${e.id_pkcs9}.26`,e.id_pkcs9_mr=`${e.id_pkcs9}.27`,e.id_pkcs9_oc_pkcsEntity=`${e.id_pkcs9_oc}.1`,e.id_pkcs9_oc_naturalPerson=`${e.id_pkcs9_oc}.2`,e.id_pkcs9_at_emailAddress=`${e.id_pkcs9}.1`,e.id_pkcs9_at_unstructuredName=`${e.id_pkcs9}.2`,e.id_pkcs9_at_contentType=`${e.id_pkcs9}.3`,e.id_pkcs9_at_messageDigest=`${e.id_pkcs9}.4`,e.id_pkcs9_at_signingTime=`${e.id_pkcs9}.5`,e.id_pkcs9_at_counterSignature=`${e.id_pkcs9}.6`,e.id_pkcs9_at_challengePassword=`${e.id_pkcs9}.7`,e.id_pkcs9_at_unstructuredAddress=`${e.id_pkcs9}.8`,e.id_pkcs9_at_extendedCertificateAttributes=`${e.id_pkcs9}.9`,e.id_pkcs9_at_signingDescription=`${e.id_pkcs9}.13`,e.id_pkcs9_at_extensionRequest=`${e.id_pkcs9}.14`,e.id_pkcs9_at_smimeCapabilities=`${e.id_pkcs9}.15`,e.id_pkcs9_at_friendlyName=`${e.id_pkcs9}.20`,e.id_pkcs9_at_localKeyId=`${e.id_pkcs9}.21`,e.id_pkcs9_at_userPKCS12=`2.16.840.1.113730.3.1.216`,e.id_pkcs9_at_pkcs15Token=`${e.id_pkcs9_at}.1`,e.id_pkcs9_at_encryptedPrivateKeyInfo=`${e.id_pkcs9_at}.2`,e.id_pkcs9_at_randomNonce=`${e.id_pkcs9_at}.3`,e.id_pkcs9_at_sequenceNumber=`${e.id_pkcs9_at}.4`,e.id_pkcs9_at_pkcs7PDU=`${e.id_pkcs9_at}.5`,e.id_ietf_at=`1.3.6.1.5.5.7.9`,e.id_pkcs9_at_dateOfBirth=`${e.id_ietf_at}.1`,e.id_pkcs9_at_placeOfBirth=`${e.id_ietf_at}.2`,e.id_pkcs9_at_gender=`${e.id_ietf_at}.3`,e.id_pkcs9_at_countryOfCitizenship=`${e.id_ietf_at}.4`,e.id_pkcs9_at_countryOfResidence=`${e.id_ietf_at}.5`,e.id_pkcs9_sx_pkcs9String=`${e.id_pkcs9_sx}.1`,e.id_pkcs9_sx_signingTime=`${e.id_pkcs9_sx}.2`,e.id_pkcs9_mr_caseIgnoreMatch=`${e.id_pkcs9_mr}.1`,e.id_pkcs9_mr_signingTimeMatch=`${e.id_pkcs9_mr}.2`,e.id_smime=`${e.id_pkcs9}.16`,e.id_certTypes=`${e.id_pkcs9}.22`,e.crlTypes=`${e.id_pkcs9}.23`,e.id_at_pseudonym=`${d.id_at}.65`;let f=class extends u.DirectoryString{ia5String;constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};e.PKCS9String=f,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.IA5String})],f.prototype,`ia5String`,void 0),e.PKCS9String=f=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],f);let p=class extends s.ContentInfo{};e.Pkcs7PDU=p,e.Pkcs7PDU=p=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],p);let m=class extends c.PFX{};e.UserPKCS12=m,e.UserPKCS12=m=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],m);let h=class extends l.EncryptedPrivateKeyInfo{};e.EncryptedPrivateKeyInfo=h,e.EncryptedPrivateKeyInfo=h=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],h);let g=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.EmailAddress=g,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.IA5String})],g.prototype,`value`,void 0),e.EmailAddress=g=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],g);let _=class extends f{};e.UnstructuredName=_,e.UnstructuredName=_=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],_);let v=class extends u.DirectoryString{};e.UnstructuredAddress=v,e.UnstructuredAddress=v=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],v);let y=class{value;constructor(e=new Date){this.value=e}};e.DateOfBirth=y,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.GeneralizedTime})],y.prototype,`value`,void 0),e.DateOfBirth=y=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],y);let b=class extends u.DirectoryString{};e.PlaceOfBirth=b,e.PlaceOfBirth=b=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],b);let x=class{value;constructor(e=`M`){this.value=e}toString(){return this.value}};e.Gender=x,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.PrintableString})],x.prototype,`value`,void 0),e.Gender=x=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],x);let S=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.CountryOfCitizenship=S,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.PrintableString})],S.prototype,`value`,void 0),e.CountryOfCitizenship=S=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],S);let C=class extends S{};e.CountryOfResidence=C,e.CountryOfResidence=C=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],C);let w=class extends u.DirectoryString{};e.Pseudonym=w,e.Pseudonym=w=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],w);let T=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.ContentType=T,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.ObjectIdentifier})],T.prototype,`value`,void 0),e.ContentType=T=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],T),e.MessageDigest=class extends o.OctetString{};let ee=class extends u.Time{};e.SigningTime=ee,e.SigningTime=ee=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],ee),e.RandomNonce=class extends o.OctetString{};let E=class{value;constructor(e=0){this.value=e}toString(){return this.value.toString()}};e.SequenceNumber=E,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.Integer})],E.prototype,`value`,void 0),e.SequenceNumber=E=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],E);let D=class extends s.SignerInfo{};e.CounterSignature=D,e.CounterSignature=D=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],D);let O=class extends u.DirectoryString{};e.ChallengePassword=O,e.ChallengePassword=O=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],O);let k=n=class extends u.Extensions{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.ExtensionRequest=k,e.ExtensionRequest=k=n=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],k);let A=r=class extends o.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};e.ExtendedCertificateAttributes=A,e.ExtendedCertificateAttributes=A=r=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Set,itemType:s.Attribute})],A);let j=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.FriendlyName=j,a.__decorate([(0,o.AsnProp)({type:o.AsnPropTypes.BmpString})],j.prototype,`value`,void 0),e.FriendlyName=j=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Choice})],j),e.LocalKeyId=class extends o.OctetString{},e.SigningDescription=class extends u.DirectoryString{};let M=class extends u.AlgorithmIdentifier{};e.SMIMECapability=M,e.SMIMECapability=M=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence})],M);let te=i=class extends o.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,i.prototype)}};e.SMIMECapabilities=te,e.SMIMECapabilities=te=i=a.__decorate([(0,o.AsnType)({type:o.AsnTypeTypes.Sequence,itemType:M})],te)})),Wi=s((e=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.Attributes=void 0;let r=(K(),t(L)),i=J(),a=X(),o=n=class extends i.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.Attributes=o,e.Attributes=o=n=r.__decorate([(0,i.AsnType)({type:i.AsnTypeTypes.Sequence,itemType:a.Attribute})],o)})),Gi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificationRequestInfo=void 0;let n=(K(),t(L)),r=J(),i=X(),a=Wi();var o=class{version=0;subject=new i.Name;subjectPKInfo=new i.SubjectPublicKeyInfo;attributes=new a.Attributes;constructor(e={}){Object.assign(this,e)}};e.CertificationRequestInfo=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],o.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.Name})],o.prototype,`subject`,void 0),n.__decorate([(0,r.AsnProp)({type:i.SubjectPublicKeyInfo})],o.prototype,`subjectPKInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:a.Attributes,implicit:!0,context:0,optional:!0})],o.prototype,`attributes`,void 0)})),Ki=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificationRequest=void 0;let n=(K(),t(L)),r=J(),i=X(),a=Gi();var o=class{certificationRequestInfo=new a.CertificationRequestInfo;certificationRequestInfoRaw;signatureAlgorithm=new i.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertificationRequest=o,n.__decorate([(0,r.AsnProp)({type:a.CertificationRequestInfo,raw:!0})],o.prototype,`certificationRequestInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],o.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],o.prototype,`signature`,void 0)})),qi=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});let n=(K(),t(L));n.__exportStar(Wi(),e),n.__exportStar(Ki(),e),n.__exportStar(Gi(),e)})),Ji=s((e=>{
106
106
  /*!
107
107
  * MIT License
108
108
  *
@@ -127,15 +127,15 @@ function Qr(e,t){bi(e,t);function n(){this.constructor=e}e.prototype=t===null?Ob
127
127
  * SOFTWARE.
128
128
  *
129
129
  */
130
- Ve();var n=Z(),r=$(),i=Ct(),a=Nr(),o=Br(),s=Xr(),c=(X(),t(q)),l=ta(),u=ya(),d=Ca();function f(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var p=f(r),m=f(a),h=f(o),g=f(s),_=f(u);let v=`crypto.algorithm`;var y=class{getAlgorithms(){return l.container.resolveAll(v)}toAsnAlgorithm(e){({...e});for(let t of this.getAlgorithms()){let n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let t=new r.AlgorithmIdentifier({algorithm:e.name});return`parameters`in e&&(t.parameters=e.parameters),t}throw Error(`Cannot convert WebCrypto algorithm to ASN.1 algorithm`)}toWebAlgorithm(e){for(let t of this.getAlgorithms()){let n=t.toWebAlgorithm(e);if(n)return n}return{name:e.algorithm,parameters:e.parameters}}};let b=`crypto.algorithmProvider`;l.container.registerSingleton(b,y);var x;let S=`1.3.36.3.3.2.8.1.1`,C=`${S}.1`,w=`${S}.2`,T=`${S}.3`,E=`${S}.4`,D=`${S}.5`,O=`${S}.6`,k=`${S}.7`,A=`${S}.8`,j=`${S}.9`,M=`${S}.10`,N=`${S}.11`,ee=`${S}.12`,te=`${S}.13`,ne=`${S}.14`,P=`brainpoolP160r1`,re=`brainpoolP160t1`,ie=`brainpoolP192r1`,F=`brainpoolP192t1`,ae=`brainpoolP224r1`,oe=`brainpoolP224t1`,se=`brainpoolP256r1`,I=`brainpoolP256t1`,L=`brainpoolP320r1`,ce=`brainpoolP320t1`,le=`brainpoolP384r1`,ue=`brainpoolP384t1`,de=`brainpoolP512r1`,fe=`brainpoolP512t1`,R=`ECDSA`;e.EcAlgorithm=x=class{toAsnAlgorithm(e){if(e.name.toLowerCase()===`ecdsa`){if(`hash`in e)switch((typeof e.hash==`string`?e.hash:e.hash.name).toLowerCase()){case`sha-1`:return h.ecdsaWithSHA1;case`sha-256`:return h.ecdsaWithSHA256;case`sha-384`:return h.ecdsaWithSHA384;case`sha-512`:return h.ecdsaWithSHA512}else if(`namedCurve`in e){let t=``;switch(e.namedCurve){case`P-256`:t=h.id_secp256r1;break;case`K-256`:t=x.SECP256K1;break;case`P-384`:t=h.id_secp384r1;break;case`P-521`:t=h.id_secp521r1;break;case P:t=C;break;case re:t=w;break;case ie:t=T;break;case F:t=E;break;case ae:t=D;break;case oe:t=O;break;case se:t=k;break;case I:t=A;break;case L:t=j;break;case ce:t=M;break;case le:t=N;break;case ue:t=ee;break;case de:t=te;break;case fe:t=ne}if(t)return new r.AlgorithmIdentifier({algorithm:h.id_ecPublicKey,parameters:n.AsnConvert.serialize(new h.ECParameters({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case h.id_ecdsaWithSHA1:return{name:R,hash:{name:`SHA-1`}};case h.id_ecdsaWithSHA256:return{name:R,hash:{name:`SHA-256`}};case h.id_ecdsaWithSHA384:return{name:R,hash:{name:`SHA-384`}};case h.id_ecdsaWithSHA512:return{name:R,hash:{name:`SHA-512`}};case h.id_ecPublicKey:if(!e.parameters)throw TypeError(`Cannot get required parameters from EC algorithm`);switch(n.AsnConvert.parse(e.parameters,h.ECParameters).namedCurve){case h.id_secp256r1:return{name:R,namedCurve:`P-256`};case x.SECP256K1:return{name:R,namedCurve:`K-256`};case h.id_secp384r1:return{name:R,namedCurve:`P-384`};case h.id_secp521r1:return{name:R,namedCurve:`P-521`};case C:return{name:R,namedCurve:P};case w:return{name:R,namedCurve:re};case T:return{name:R,namedCurve:ie};case E:return{name:R,namedCurve:F};case D:return{name:R,namedCurve:ae};case O:return{name:R,namedCurve:oe};case k:return{name:R,namedCurve:se};case A:return{name:R,namedCurve:I};case j:return{name:R,namedCurve:L};case M:return{name:R,namedCurve:ce};case N:return{name:R,namedCurve:le};case ee:return{name:R,namedCurve:ue};case te:return{name:R,namedCurve:de};case ne:return{name:R,namedCurve:fe}}}return null}},e.EcAlgorithm.SECP256K1=`1.3.132.0.10`,e.EcAlgorithm=x=c.__decorate([l.injectable()],e.EcAlgorithm),l.container.registerSingleton(v,e.EcAlgorithm);let z=Symbol(`name`),pe=Symbol(`value`);var B=class{constructor(e,t={},n=``){this[z]=e,this[pe]=n;for(let e in t)this[e]=t[e]}};B.NAME=z,B.VALUE=pe;var me=class{static toTextObject(t){let n=new B(`Algorithm Identifier`,{},V.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case h.id_ecPublicKey:{let r=new e.EcAlgorithm().toWebAlgorithm(t);r&&`namedCurve`in r?n[`Named Curve`]=r.namedCurve:n.Parameters=t.parameters;break}default:n.Parameters=t.parameters}return n}},V=class{static toString(e){return this.items[e]||e}};V.items={[g.id_sha1]:`sha1`,[g.id_sha224]:`sha224`,[g.id_sha256]:`sha256`,[g.id_sha384]:`sha384`,[g.id_sha512]:`sha512`,[g.id_rsaEncryption]:`rsaEncryption`,[g.id_sha1WithRSAEncryption]:`sha1WithRSAEncryption`,[g.id_sha224WithRSAEncryption]:`sha224WithRSAEncryption`,[g.id_sha256WithRSAEncryption]:`sha256WithRSAEncryption`,[g.id_sha384WithRSAEncryption]:`sha384WithRSAEncryption`,[g.id_sha512WithRSAEncryption]:`sha512WithRSAEncryption`,[h.id_ecPublicKey]:`ecPublicKey`,[h.id_ecdsaWithSHA1]:`ecdsaWithSHA1`,[h.id_ecdsaWithSHA224]:`ecdsaWithSHA224`,[h.id_ecdsaWithSHA256]:`ecdsaWithSHA256`,[h.id_ecdsaWithSHA384]:`ecdsaWithSHA384`,[h.id_ecdsaWithSHA512]:`ecdsaWithSHA512`,[p.id_kp_serverAuth]:`TLS WWW server authentication`,[p.id_kp_clientAuth]:`TLS WWW client authentication`,[p.id_kp_codeSigning]:`Code Signing`,[p.id_kp_emailProtection]:`E-mail Protection`,[p.id_kp_timeStamping]:`Time Stamping`,[p.id_kp_OCSPSigning]:`OCSP Signing`,[m.id_signedData]:`Signed Data`};var he=class{static serialize(e){return this.serializeObj(e).join(`
131
- `)}static pad(e=0){return``.padStart(2*e,` `)}static serializeObj(e,t=0){let n=[],r=this.pad(t++),a=``,o=e[B.VALUE];o&&(a=` ${o}`),n.push(`${r}${e[B.NAME]}:${a}`),r=this.pad(t);for(let a in e){if(typeof a==`symbol`)continue;let o=e[a],s=a?`${a}: `:``;if(typeof o==`string`||typeof o==`number`||typeof o==`boolean`)n.push(`${r}${s}${o}`);else if(o instanceof Date)n.push(`${r}${s}${o.toUTCString()}`);else if(Array.isArray(o))for(let e of o)e[B.NAME]=a,n.push(...this.serializeObj(e,t));else if(o instanceof B)o[B.NAME]=a,n.push(...this.serializeObj(o,t));else if(i.BufferSourceConverter.isBufferSource(o))a?(n.push(`${r}${s}`),n.push(...this.serializeBufferSource(o,t+1))):n.push(...this.serializeBufferSource(o,t));else if(`toTextObject`in o){let e=o.toTextObject();e[B.NAME]=a,n.push(...this.serializeObj(e,t))}else throw TypeError(`Cannot serialize data in text format. Unsupported type.`)}return n}static serializeBufferSource(e,t=0){let n=this.pad(t),r=i.BufferSourceConverter.toUint8Array(e),a=[];for(let e=0;e<r.length;){let t=[];for(let n=0;n<16&&e<r.length;n++){n===8&&t.push(``);let i=r[e++].toString(16).padStart(2,`0`);t.push(i)}a.push(`${n}${t.join(` `)}`)}return a}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};he.oidSerializer=V,he.algorithmSerializer=me;var ge=class e{constructor(...e){if(e.length===1){let t=e[0];this.rawData=n.AsnConvert.serialize(t),this.onInit(t)}else{let t=n.AsnConvert.parse(e[0],e[1]);this.rawData=i.BufferSourceConverter.toArrayBuffer(e[0]),this.onInit(t)}}equal(t){return t instanceof e&&i.isEqual(t.rawData,this.rawData)}toString(e=`text`){switch(e){case`asn`:return n.AsnConvert.toString(this.rawData);case`text`:return he.serialize(this.toTextObject());case`hex`:return i.Convert.ToHex(this.rawData);case`base64`:return i.Convert.ToBase64(this.rawData);case`base64url`:return i.Convert.ToBase64Url(this.rawData);default:throw TypeError(`Argument 'format' is unsupported value`)}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[``]=this.rawData,e}toTextObjectEmpty(e){return new B(this.getTextName(),{},e)}};ge.NAME=`ASN`;var H=class e extends ge{constructor(...e){let t;t=i.BufferSourceConverter.isBufferSource(e[0])?i.BufferSourceConverter.toArrayBuffer(e[0]):n.AsnConvert.serialize(new r.Extension({extnID:e[0],critical:e[1],extnValue:new n.OctetString(i.BufferSourceConverter.toArrayBuffer(e[2]))})),super(t,r.Extension)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.value,e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty(this.critical?`critical`:void 0);return t[B.NAME]===e.NAME&&(t[B.NAME]=V.toString(this.type)),t}},_e,ve=class e{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[_e]=`CryptoProvider`,typeof self<`u`&&typeof crypto<`u`?this.set(e.DEFAULT,crypto):typeof global<`u`&&global.crypto&&global.crypto.subtle&&this.set(e.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(t=e.DEFAULT){let n=this.items.get(t.toLowerCase());if(!n)throw Error(`Cannot get Crypto by name '${t}'`);return n}set(t,n){if(typeof t==`string`){if(!n)throw TypeError(`Argument 'value' is required`);this.items.set(t.toLowerCase(),n)}else this.items.set(e.DEFAULT,t);return this}};_e=Symbol.toStringTag,ve.DEFAULT=`default`;let U=new ve,ye=/^[0-2](?:\.[1-9][0-9]*)+$/;function be(e){return new RegExp(ye).test(e)}var xe=class{constructor(e={}){this.items={};for(let t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return be(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}};let W=new xe;W.register(`CN`,`2.5.4.3`),W.register(`L`,`2.5.4.7`),W.register(`ST`,`2.5.4.8`),W.register(`O`,`2.5.4.10`),W.register(`OU`,`2.5.4.11`),W.register(`C`,`2.5.4.6`),W.register(`DC`,`0.9.2342.19200300.100.1.25`),W.register(`E`,`1.2.840.113549.1.9.1`),W.register(`G`,`2.5.4.42`),W.register(`I`,`2.5.4.43`),W.register(`SN`,`2.5.4.4`),W.register(`T`,`2.5.4.12`);function Se(e,t){return`\\${i.Convert.ToHex(i.Convert.FromUtf8String(t)).toUpperCase()}`}function Ce(e){return e.replace(/([,+"\\<>;])/g,`\\$1`).replace(/^([ #])/,`\\$1`).replace(/([ ]$)/,`\\$1`).replace(/([\r\n\t])/,Se)}var G=class e{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 xe,this.asn=new r.Name;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e];this.extraNames.register(e,n)}this.asn=typeof e==`string`?this.fromString(e):e instanceof r.Name?e:i.BufferSourceConverter.isBufferSource(e)?n.AsnConvert.parse(e,r.Name):this.fromJSON(e)}getField(e){let t=this.extraNames.findId(e)||W.findId(e),n=[];for(let e of this.asn)for(let r of e)r.type===t&&n.push(r.value.toString());return n}getName(e){return this.extraNames.get(e)||W.get(e)}toString(){return this.asn.map(e=>e.map(e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${i.Convert.ToHex(e.value.anyValue)}`:Ce(e.value.toString())}`).join(`+`)).join(`, `)}toJSON(){let e=[];for(let t of this.asn){let n={};for(let e of t){let t=this.getName(e.type)||e.type;n[t]??(n[t]=[]),n[t].push(e.value.anyValue?`#${i.Convert.ToHex(e.value.anyValue)}`:e.value.toString())}e.push(n)}return e}fromString(e){let t=new r.Name,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,i=null,a=`,`;for(;i=n.exec(`${e},`);){let[,e,n]=i,o=n[n.length-1];(o===`,`||o===`+`)&&(n=n.slice(0,n.length-1),i[3]=o);let s=i[3];e=this.getTypeOid(e);let c=this.createAttribute(e,n);a===`+`?t[t.length-1].push(c):t.push(new r.RelativeDistinguishedName([c])),a=s}return t}fromJSON(e){let t=new r.Name;for(let n of e){let e=new r.RelativeDistinguishedName;for(let t in n){let r=this.getTypeOid(t),i=n[t];for(let t of i){let n=this.createAttribute(r,t);e.push(n)}}t.push(e)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||``),!e)throw Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(t,n){let a=new r.AttributeTypeAndValue({type:t});if(typeof n==`object`)for(let e in n)switch(e){case`ia5String`:a.value.ia5String=n[e];break;case`utf8String`:a.value.utf8String=n[e];break;case`universalString`:a.value.universalString=n[e];break;case`bmpString`:a.value.bmpString=n[e];break;case`printableString`:a.value.printableString=n[e]}else if(n[0]===`#`)a.value.anyValue=i.Convert.FromHex(n.slice(1));else{let r=this.processStringValue(n);t===this.getName(`E`)||t===this.getName(`DC`)?a.value.ia5String=r:e.isPrintableString(r)?a.value.printableString=r:a.value.utf8String=r}return a}processStringValue(e){let t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,`
132
- `).replace(/\\0d/gi,`\r`).replace(/\\0g/gi,` `).replace(/\\(.)/g,`$1`)}toArrayBuffer(){return n.AsnConvert.serialize(this.asn)}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||U.get()):t=e[0]||U.get(),await t.subtle.digest(n,this.toArrayBuffer())}};let we=`Cannot initialize GeneralName from ASN.1 data.`,Te=`${we} Unsupported string format in use.`,Ee=`${we} Value doesn't match to GUID regular expression.`,De=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Oe=`1.3.6.1.4.1.311.25.1`,ke=`1.3.6.1.4.1.311.20.2.3`,Ae=`email`,je=`guid`;var Me=class extends ge{constructor(...e){let t;if(e.length===2)switch(e[0]){case`dn`:{let r=new G(e[1]).toArrayBuffer(),i=n.AsnConvert.parse(r,p.Name);t=new p.GeneralName({directoryName:i});break}case`dns`:t=new p.GeneralName({dNSName:e[1]});break;case Ae:t=new p.GeneralName({rfc822Name:e[1]});break;case je:{let r=new RegExp(De,`i`).exec(e[1]);if(!r)throw Error(`Cannot parse GUID value. Value doesn't match to regular expression`);let a=r.slice(1).map((e,t)=>t<3?i.Convert.ToHex(new Uint8Array(i.Convert.FromHex(e)).reverse()):e).join(``);t=new p.GeneralName({otherName:new p.OtherName({typeId:Oe,value:n.AsnConvert.serialize(new n.OctetString(i.Convert.FromHex(a)))})});break}case`ip`:t=new p.GeneralName({iPAddress:e[1]});break;case`id`:t=new p.GeneralName({registeredID:e[1]});break;case`upn`:t=new p.GeneralName({otherName:new p.OtherName({typeId:ke,value:n.AsnConvert.serialize(n.AsnUtf8StringConverter.toASN(e[1]))})});break;case`url`:t=new p.GeneralName({uniformResourceIdentifier:e[1]});break;default:throw Error(`Cannot create GeneralName. Unsupported type of the name`)}else t=i.BufferSourceConverter.isBufferSource(e[0])?n.AsnConvert.parse(e[0],p.GeneralName):e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=`dns`,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Ae,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=`ip`,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=`url`,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=`id`,this.value=e.registeredID;else if(e.directoryName!=null)this.type=`dn`,this.value=new G(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Oe){this.type=je;let t=n.AsnConvert.parse(e.otherName.value,n.OctetString),r=new RegExp(De,`i`).exec(i.Convert.ToHex(t));if(!r)throw Error(Ee);this.value=r.slice(1).map((e,t)=>t<3?i.Convert.ToHex(new Uint8Array(i.Convert.FromHex(e)).reverse()):e).join(`-`)}else if(e.otherName.typeId===ke)this.type=`upn`,this.value=n.AsnConvert.parse(e.otherName.value,p.DirectoryString).toString();else throw Error(Te);else throw Error(Te)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case`dn`:case`dns`:case je:case`ip`:case`id`:case`upn`:case`url`:e=this.type.toUpperCase();break;case Ae:e=`Email`;break;default:throw Error(`Unsupported GeneralName type`)}let t=this.value;return this.type===`id`&&(t=V.toString(t)),new B(e,void 0,t)}},Ne=class extends ge{constructor(e){let t;if(e instanceof p.GeneralNames)t=e;else if(Array.isArray(e)){let r=[];for(let t of e)if(t instanceof p.GeneralName)r.push(t);else{let e=n.AsnConvert.parse(new Me(t.type,t.value).rawData,p.GeneralName);r.push(e)}t=new p.GeneralNames(r)}else if(i.BufferSourceConverter.isBufferSource(e))t=n.AsnConvert.parse(e,p.GeneralNames);else throw Error(`Cannot initialize GeneralNames. Incorrect incoming arguments`);super(t)}onInit(e){let t=[];for(let n of e){let e=null;try{e=new Me(n)}catch{continue}t.push(e)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let t of this.items){let n=t.toTextObject(),r=e[n[B.NAME]];Array.isArray(r)||(r=[],e[n[B.NAME]]=r),r.push(n)}return e}};Ne.NAME=`GeneralNames`;let Pe=`-{5}`,Fe=`${`${Pe}BEGIN ([^\\n]+(?=${Pe}))${Pe}`}\\n(?:((?:[^:\\n]+: (?:[^\\n]+\\n(?: +[^\\n]+\\n)*))+))?\\n?((?:[a-zA-Z0-9=+/]+\\n)+)${`${Pe}END \\1${Pe}`}`;var K=class{static isPem(e){return typeof e==`string`&&new RegExp(Fe,`g`).test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,``);let t=new RegExp(Fe,`g`),n=[],r=null;for(;r=t.exec(e);){let e=r[3].replace(RegExp(`[\\n]+`,`g`),``),t={type:r[1],headers:[],rawData:i.Convert.FromBase64(e)},a=r[2];if(a){let e=a.split(RegExp(`\\n`,`g`)),n=null;for(let r of e){let[e,i]=r.split(/:(.*)/);if(i===void 0){if(!n)throw Error(`Cannot parse PEM string. Incorrect header value`);n.value+=e.trim()}else n&&t.headers.push(n),n={key:e,value:i.trim()}}n&&t.headers.push(n)}n.push(t)}return n}static decode(e){return this.decodeWithHeaders(e).map(e=>e.rawData)}static decodeFirst(e){let t=this.decode(e);if(!t.length)throw RangeError(`PEM string doesn't contain any objects`);return t[0]}static encode(e,t){if(Array.isArray(e)){let n=[];return t?e.forEach(e=>{if(!i.BufferSourceConverter.isBufferSource(e))throw TypeError(`Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource`);n.push(this.encodeStruct({type:t,rawData:i.BufferSourceConverter.toArrayBuffer(e)}))}):e.forEach(e=>{if(!(`type`in e))throw TypeError(`Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut`);n.push(this.encodeStruct(e))}),n.join(`
130
+ ve();var n=J(),r=X(),i=Je(),a=rr(),o=ur(),s=br(),c=(K(),t(L)),l=Ti(),u=Ui(),d=qi();function f(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var p=f(r),m=f(a),h=f(o),g=f(s),_=f(u);let v=`crypto.algorithm`;var y=class{getAlgorithms(){return l.container.resolveAll(v)}toAsnAlgorithm(e){({...e});for(let t of this.getAlgorithms()){let n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let t=new r.AlgorithmIdentifier({algorithm:e.name});return`parameters`in e&&(t.parameters=e.parameters),t}throw Error(`Cannot convert WebCrypto algorithm to ASN.1 algorithm`)}toWebAlgorithm(e){for(let t of this.getAlgorithms()){let n=t.toWebAlgorithm(e);if(n)return n}return{name:e.algorithm,parameters:e.parameters}}};let b=`crypto.algorithmProvider`;l.container.registerSingleton(b,y);var x;let S=`1.3.36.3.3.2.8.1.1`,C=`${S}.1`,w=`${S}.2`,T=`${S}.3`,ee=`${S}.4`,E=`${S}.5`,D=`${S}.6`,O=`${S}.7`,k=`${S}.8`,A=`${S}.9`,j=`${S}.10`,M=`${S}.11`,te=`${S}.12`,ne=`${S}.13`,re=`${S}.14`,N=`brainpoolP160r1`,ie=`brainpoolP160t1`,ae=`brainpoolP192r1`,P=`brainpoolP192t1`,oe=`brainpoolP224r1`,se=`brainpoolP224t1`,ce=`brainpoolP256r1`,le=`brainpoolP256t1`,ue=`brainpoolP320r1`,de=`brainpoolP320t1`,fe=`brainpoolP384r1`,pe=`brainpoolP384t1`,me=`brainpoolP512r1`,he=`brainpoolP512t1`,F=`ECDSA`;e.EcAlgorithm=x=class{toAsnAlgorithm(e){if(e.name.toLowerCase()===`ecdsa`){if(`hash`in e)switch((typeof e.hash==`string`?e.hash:e.hash.name).toLowerCase()){case`sha-1`:return h.ecdsaWithSHA1;case`sha-256`:return h.ecdsaWithSHA256;case`sha-384`:return h.ecdsaWithSHA384;case`sha-512`:return h.ecdsaWithSHA512}else if(`namedCurve`in e){let t=``;switch(e.namedCurve){case`P-256`:t=h.id_secp256r1;break;case`K-256`:t=x.SECP256K1;break;case`P-384`:t=h.id_secp384r1;break;case`P-521`:t=h.id_secp521r1;break;case N:t=C;break;case ie:t=w;break;case ae:t=T;break;case P:t=ee;break;case oe:t=E;break;case se:t=D;break;case ce:t=O;break;case le:t=k;break;case ue:t=A;break;case de:t=j;break;case fe:t=M;break;case pe:t=te;break;case me:t=ne;break;case he:t=re}if(t)return new r.AlgorithmIdentifier({algorithm:h.id_ecPublicKey,parameters:n.AsnConvert.serialize(new h.ECParameters({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case h.id_ecdsaWithSHA1:return{name:F,hash:{name:`SHA-1`}};case h.id_ecdsaWithSHA256:return{name:F,hash:{name:`SHA-256`}};case h.id_ecdsaWithSHA384:return{name:F,hash:{name:`SHA-384`}};case h.id_ecdsaWithSHA512:return{name:F,hash:{name:`SHA-512`}};case h.id_ecPublicKey:if(!e.parameters)throw TypeError(`Cannot get required parameters from EC algorithm`);switch(n.AsnConvert.parse(e.parameters,h.ECParameters).namedCurve){case h.id_secp256r1:return{name:F,namedCurve:`P-256`};case x.SECP256K1:return{name:F,namedCurve:`K-256`};case h.id_secp384r1:return{name:F,namedCurve:`P-384`};case h.id_secp521r1:return{name:F,namedCurve:`P-521`};case C:return{name:F,namedCurve:N};case w:return{name:F,namedCurve:ie};case T:return{name:F,namedCurve:ae};case ee:return{name:F,namedCurve:P};case E:return{name:F,namedCurve:oe};case D:return{name:F,namedCurve:se};case O:return{name:F,namedCurve:ce};case k:return{name:F,namedCurve:le};case A:return{name:F,namedCurve:ue};case j:return{name:F,namedCurve:de};case M:return{name:F,namedCurve:fe};case te:return{name:F,namedCurve:pe};case ne:return{name:F,namedCurve:me};case re:return{name:F,namedCurve:he}}}return null}},e.EcAlgorithm.SECP256K1=`1.3.132.0.10`,e.EcAlgorithm=x=c.__decorate([l.injectable()],e.EcAlgorithm),l.container.registerSingleton(v,e.EcAlgorithm);let ge=Symbol(`name`),_e=Symbol(`value`);var I=class{constructor(e,t={},n=``){this[ge]=e,this[_e]=n;for(let e in t)this[e]=t[e]}};I.NAME=ge,I.VALUE=_e;var ye=class{static toTextObject(t){let n=new I(`Algorithm Identifier`,{},R.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case h.id_ecPublicKey:{let r=new e.EcAlgorithm().toWebAlgorithm(t);r&&`namedCurve`in r?n[`Named Curve`]=r.namedCurve:n.Parameters=t.parameters;break}default:n.Parameters=t.parameters}return n}},R=class{static toString(e){return this.items[e]||e}};R.items={[g.id_sha1]:`sha1`,[g.id_sha224]:`sha224`,[g.id_sha256]:`sha256`,[g.id_sha384]:`sha384`,[g.id_sha512]:`sha512`,[g.id_rsaEncryption]:`rsaEncryption`,[g.id_sha1WithRSAEncryption]:`sha1WithRSAEncryption`,[g.id_sha224WithRSAEncryption]:`sha224WithRSAEncryption`,[g.id_sha256WithRSAEncryption]:`sha256WithRSAEncryption`,[g.id_sha384WithRSAEncryption]:`sha384WithRSAEncryption`,[g.id_sha512WithRSAEncryption]:`sha512WithRSAEncryption`,[h.id_ecPublicKey]:`ecPublicKey`,[h.id_ecdsaWithSHA1]:`ecdsaWithSHA1`,[h.id_ecdsaWithSHA224]:`ecdsaWithSHA224`,[h.id_ecdsaWithSHA256]:`ecdsaWithSHA256`,[h.id_ecdsaWithSHA384]:`ecdsaWithSHA384`,[h.id_ecdsaWithSHA512]:`ecdsaWithSHA512`,[p.id_kp_serverAuth]:`TLS WWW server authentication`,[p.id_kp_clientAuth]:`TLS WWW client authentication`,[p.id_kp_codeSigning]:`Code Signing`,[p.id_kp_emailProtection]:`E-mail Protection`,[p.id_kp_timeStamping]:`Time Stamping`,[p.id_kp_OCSPSigning]:`OCSP Signing`,[m.id_signedData]:`Signed Data`};var be=class{static serialize(e){return this.serializeObj(e).join(`
131
+ `)}static pad(e=0){return``.padStart(2*e,` `)}static serializeObj(e,t=0){let n=[],r=this.pad(t++),a=``,o=e[I.VALUE];o&&(a=` ${o}`),n.push(`${r}${e[I.NAME]}:${a}`),r=this.pad(t);for(let a in e){if(typeof a==`symbol`)continue;let o=e[a],s=a?`${a}: `:``;if(typeof o==`string`||typeof o==`number`||typeof o==`boolean`)n.push(`${r}${s}${o}`);else if(o instanceof Date)n.push(`${r}${s}${o.toUTCString()}`);else if(Array.isArray(o))for(let e of o)e[I.NAME]=a,n.push(...this.serializeObj(e,t));else if(o instanceof I)o[I.NAME]=a,n.push(...this.serializeObj(o,t));else if(i.BufferSourceConverter.isBufferSource(o))a?(n.push(`${r}${s}`),n.push(...this.serializeBufferSource(o,t+1))):n.push(...this.serializeBufferSource(o,t));else if(`toTextObject`in o){let e=o.toTextObject();e[I.NAME]=a,n.push(...this.serializeObj(e,t))}else throw TypeError(`Cannot serialize data in text format. Unsupported type.`)}return n}static serializeBufferSource(e,t=0){let n=this.pad(t),r=i.BufferSourceConverter.toUint8Array(e),a=[];for(let e=0;e<r.length;){let t=[];for(let n=0;n<16&&e<r.length;n++){n===8&&t.push(``);let i=r[e++].toString(16).padStart(2,`0`);t.push(i)}a.push(`${n}${t.join(` `)}`)}return a}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};be.oidSerializer=R,be.algorithmSerializer=ye;var xe=class e{constructor(...e){if(e.length===1){let t=e[0];this.rawData=n.AsnConvert.serialize(t),this.onInit(t)}else{let t=n.AsnConvert.parse(e[0],e[1]);this.rawData=i.BufferSourceConverter.toArrayBuffer(e[0]),this.onInit(t)}}equal(t){return t instanceof e&&i.isEqual(t.rawData,this.rawData)}toString(e=`text`){switch(e){case`asn`:return n.AsnConvert.toString(this.rawData);case`text`:return be.serialize(this.toTextObject());case`hex`:return i.Convert.ToHex(this.rawData);case`base64`:return i.Convert.ToBase64(this.rawData);case`base64url`:return i.Convert.ToBase64Url(this.rawData);default:throw TypeError(`Argument 'format' is unsupported value`)}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[``]=this.rawData,e}toTextObjectEmpty(e){return new I(this.getTextName(),{},e)}};xe.NAME=`ASN`;var z=class e extends xe{constructor(...e){let t;t=i.BufferSourceConverter.isBufferSource(e[0])?i.BufferSourceConverter.toArrayBuffer(e[0]):n.AsnConvert.serialize(new r.Extension({extnID:e[0],critical:e[1],extnValue:new n.OctetString(i.BufferSourceConverter.toArrayBuffer(e[2]))})),super(t,r.Extension)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.value,e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty(this.critical?`critical`:void 0);return t[I.NAME]===e.NAME&&(t[I.NAME]=R.toString(this.type)),t}},Se,Ce=class e{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Se]=`CryptoProvider`,typeof self<`u`&&typeof crypto<`u`?this.set(e.DEFAULT,crypto):typeof global<`u`&&global.crypto&&global.crypto.subtle&&this.set(e.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(t=e.DEFAULT){let n=this.items.get(t.toLowerCase());if(!n)throw Error(`Cannot get Crypto by name '${t}'`);return n}set(t,n){if(typeof t==`string`){if(!n)throw TypeError(`Argument 'value' is required`);this.items.set(t.toLowerCase(),n)}else this.items.set(e.DEFAULT,t);return this}};Se=Symbol.toStringTag,Ce.DEFAULT=`default`;let B=new Ce,we=/^[0-2](?:\.[1-9][0-9]*)+$/;function Te(e){return new RegExp(we).test(e)}var Ee=class{constructor(e={}){this.items={};for(let t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return Te(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}};let V=new Ee;V.register(`CN`,`2.5.4.3`),V.register(`L`,`2.5.4.7`),V.register(`ST`,`2.5.4.8`),V.register(`O`,`2.5.4.10`),V.register(`OU`,`2.5.4.11`),V.register(`C`,`2.5.4.6`),V.register(`DC`,`0.9.2342.19200300.100.1.25`),V.register(`E`,`1.2.840.113549.1.9.1`),V.register(`G`,`2.5.4.42`),V.register(`I`,`2.5.4.43`),V.register(`SN`,`2.5.4.4`),V.register(`T`,`2.5.4.12`);function De(e,t){return`\\${i.Convert.ToHex(i.Convert.FromUtf8String(t)).toUpperCase()}`}function Oe(e){return e.replace(/([,+"\\<>;])/g,`\\$1`).replace(/^([ #])/,`\\$1`).replace(/([ ]$)/,`\\$1`).replace(/([\r\n\t])/,De)}var H=class e{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 Ee,this.asn=new r.Name;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e];this.extraNames.register(e,n)}this.asn=typeof e==`string`?this.fromString(e):e instanceof r.Name?e:i.BufferSourceConverter.isBufferSource(e)?n.AsnConvert.parse(e,r.Name):this.fromJSON(e)}getField(e){let t=this.extraNames.findId(e)||V.findId(e),n=[];for(let e of this.asn)for(let r of e)r.type===t&&n.push(r.value.toString());return n}getName(e){return this.extraNames.get(e)||V.get(e)}toString(){return this.asn.map(e=>e.map(e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${i.Convert.ToHex(e.value.anyValue)}`:Oe(e.value.toString())}`).join(`+`)).join(`, `)}toJSON(){let e=[];for(let t of this.asn){let n={};for(let e of t){let t=this.getName(e.type)||e.type;n[t]??(n[t]=[]),n[t].push(e.value.anyValue?`#${i.Convert.ToHex(e.value.anyValue)}`:e.value.toString())}e.push(n)}return e}fromString(e){let t=new r.Name,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,i=null,a=`,`;for(;i=n.exec(`${e},`);){let[,e,n]=i,o=n[n.length-1];(o===`,`||o===`+`)&&(n=n.slice(0,n.length-1),i[3]=o);let s=i[3];e=this.getTypeOid(e);let c=this.createAttribute(e,n);a===`+`?t[t.length-1].push(c):t.push(new r.RelativeDistinguishedName([c])),a=s}return t}fromJSON(e){let t=new r.Name;for(let n of e){let e=new r.RelativeDistinguishedName;for(let t in n){let r=this.getTypeOid(t),i=n[t];for(let t of i){let n=this.createAttribute(r,t);e.push(n)}}t.push(e)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||``),!e)throw Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(t,n){let a=new r.AttributeTypeAndValue({type:t});if(typeof n==`object`)for(let e in n)switch(e){case`ia5String`:a.value.ia5String=n[e];break;case`utf8String`:a.value.utf8String=n[e];break;case`universalString`:a.value.universalString=n[e];break;case`bmpString`:a.value.bmpString=n[e];break;case`printableString`:a.value.printableString=n[e]}else if(n[0]===`#`)a.value.anyValue=i.Convert.FromHex(n.slice(1));else{let r=this.processStringValue(n);t===this.getName(`E`)||t===this.getName(`DC`)?a.value.ia5String=r:e.isPrintableString(r)?a.value.printableString=r:a.value.utf8String=r}return a}processStringValue(e){let t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,`
132
+ `).replace(/\\0d/gi,`\r`).replace(/\\0g/gi,` `).replace(/\\(.)/g,`$1`)}toArrayBuffer(){return n.AsnConvert.serialize(this.asn)}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||B.get()):t=e[0]||B.get(),await t.subtle.digest(n,this.toArrayBuffer())}};let ke=`Cannot initialize GeneralName from ASN.1 data.`,Ae=`${ke} Unsupported string format in use.`,je=`${ke} Value doesn't match to GUID regular expression.`,Me=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Ne=`1.3.6.1.4.1.311.25.1`,Pe=`1.3.6.1.4.1.311.20.2.3`,Fe=`email`,Ie=`guid`;var Le=class extends xe{constructor(...e){let t;if(e.length===2)switch(e[0]){case`dn`:{let r=new H(e[1]).toArrayBuffer(),i=n.AsnConvert.parse(r,p.Name);t=new p.GeneralName({directoryName:i});break}case`dns`:t=new p.GeneralName({dNSName:e[1]});break;case Fe:t=new p.GeneralName({rfc822Name:e[1]});break;case Ie:{let r=new RegExp(Me,`i`).exec(e[1]);if(!r)throw Error(`Cannot parse GUID value. Value doesn't match to regular expression`);let a=r.slice(1).map((e,t)=>t<3?i.Convert.ToHex(new Uint8Array(i.Convert.FromHex(e)).reverse()):e).join(``);t=new p.GeneralName({otherName:new p.OtherName({typeId:Ne,value:n.AsnConvert.serialize(new n.OctetString(i.Convert.FromHex(a)))})});break}case`ip`:t=new p.GeneralName({iPAddress:e[1]});break;case`id`:t=new p.GeneralName({registeredID:e[1]});break;case`upn`:t=new p.GeneralName({otherName:new p.OtherName({typeId:Pe,value:n.AsnConvert.serialize(n.AsnUtf8StringConverter.toASN(e[1]))})});break;case`url`:t=new p.GeneralName({uniformResourceIdentifier:e[1]});break;default:throw Error(`Cannot create GeneralName. Unsupported type of the name`)}else t=i.BufferSourceConverter.isBufferSource(e[0])?n.AsnConvert.parse(e[0],p.GeneralName):e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=`dns`,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Fe,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=`ip`,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=`url`,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=`id`,this.value=e.registeredID;else if(e.directoryName!=null)this.type=`dn`,this.value=new H(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Ne){this.type=Ie;let t=n.AsnConvert.parse(e.otherName.value,n.OctetString),r=new RegExp(Me,`i`).exec(i.Convert.ToHex(t));if(!r)throw Error(je);this.value=r.slice(1).map((e,t)=>t<3?i.Convert.ToHex(new Uint8Array(i.Convert.FromHex(e)).reverse()):e).join(`-`)}else if(e.otherName.typeId===Pe)this.type=`upn`,this.value=n.AsnConvert.parse(e.otherName.value,p.DirectoryString).toString();else throw Error(Ae);else throw Error(Ae)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case`dn`:case`dns`:case Ie:case`ip`:case`id`:case`upn`:case`url`:e=this.type.toUpperCase();break;case Fe:e=`Email`;break;default:throw Error(`Unsupported GeneralName type`)}let t=this.value;return this.type===`id`&&(t=R.toString(t)),new I(e,void 0,t)}},Re=class extends xe{constructor(e){let t;if(e instanceof p.GeneralNames)t=e;else if(Array.isArray(e)){let r=[];for(let t of e)if(t instanceof p.GeneralName)r.push(t);else{let e=n.AsnConvert.parse(new Le(t.type,t.value).rawData,p.GeneralName);r.push(e)}t=new p.GeneralNames(r)}else if(i.BufferSourceConverter.isBufferSource(e))t=n.AsnConvert.parse(e,p.GeneralNames);else throw Error(`Cannot initialize GeneralNames. Incorrect incoming arguments`);super(t)}onInit(e){let t=[];for(let n of e){let e=null;try{e=new Le(n)}catch{continue}t.push(e)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let t of this.items){let n=t.toTextObject(),r=e[n[I.NAME]];Array.isArray(r)||(r=[],e[n[I.NAME]]=r),r.push(n)}return e}};Re.NAME=`GeneralNames`;let U=`-{5}`,ze=`${`${U}BEGIN ([^\\n]+(?=${U}))${U}`}\\n(?:((?:[^:\\n]+: (?:[^\\n]+\\n(?: +[^\\n]+\\n)*))+))?\\n?((?:[a-zA-Z0-9=+/]+\\n)+)${`${U}END \\1${U}`}`;var W=class{static isPem(e){return typeof e==`string`&&new RegExp(ze,`g`).test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,``);let t=new RegExp(ze,`g`),n=[],r=null;for(;r=t.exec(e);){let e=r[3].replace(RegExp(`[\\n]+`,`g`),``),t={type:r[1],headers:[],rawData:i.Convert.FromBase64(e)},a=r[2];if(a){let e=a.split(RegExp(`\\n`,`g`)),n=null;for(let r of e){let[e,i]=r.split(/:(.*)/);if(i===void 0){if(!n)throw Error(`Cannot parse PEM string. Incorrect header value`);n.value+=e.trim()}else n&&t.headers.push(n),n={key:e,value:i.trim()}}n&&t.headers.push(n)}n.push(t)}return n}static decode(e){return this.decodeWithHeaders(e).map(e=>e.rawData)}static decodeFirst(e){let t=this.decode(e);if(!t.length)throw RangeError(`PEM string doesn't contain any objects`);return t[0]}static encode(e,t){if(Array.isArray(e)){let n=[];return t?e.forEach(e=>{if(!i.BufferSourceConverter.isBufferSource(e))throw TypeError(`Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource`);n.push(this.encodeStruct({type:t,rawData:i.BufferSourceConverter.toArrayBuffer(e)}))}):e.forEach(e=>{if(!(`type`in e))throw TypeError(`Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut`);n.push(this.encodeStruct(e))}),n.join(`
133
133
  `)}if(!t)throw Error(`Required argument 'tag' is missed`);return this.encodeStruct({type:t,rawData:i.BufferSourceConverter.toArrayBuffer(e)})}static encodeStruct(e){let t=e.type.toLocaleUpperCase(),n=[];if(n.push(`-----BEGIN ${t}-----`),e.headers?.length){for(let t of e.headers)n.push(`${t.key}: ${t.value}`);n.push(``)}let r=i.Convert.ToBase64(e.rawData),a,o=0,s=[];for(;o<r.length&&(r.length-o<64?a=r.substring(o):(a=r.substring(o,o+64),o+=64),a.length!==0)&&(s.push(a),!(a.length<64)););return n.push(...s),n.push(`-----END ${t}-----`),n.join(`
134
- `)}};K.CertificateTag=`CERTIFICATE`,K.CrlTag=`CRL`,K.CertificateRequestTag=`CERTIFICATE REQUEST`,K.PublicKeyTag=`PUBLIC KEY`,K.PrivateKeyTag=`PRIVATE KEY`;var Ie=class e extends ge{static isAsnEncoded(e){return i.BufferSourceConverter.isBufferSource(e)||typeof e==`string`}static toArrayBuffer(e){if(typeof e==`string`){if(K.isPem(e))return K.decode(e)[0];if(i.Convert.isHex(e))return i.Convert.FromHex(e);if(i.Convert.isBase64(e))return i.Convert.FromBase64(e);if(i.Convert.isBase64Url(e))return i.Convert.FromBase64Url(e);throw TypeError(`Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url`)}{let t=i.Convert.ToBinary(e);return K.isPem(t)?K.decode(t)[0]:i.Convert.isHex(t)?i.Convert.FromHex(t):i.Convert.isBase64(t)?i.Convert.FromBase64(t):i.Convert.isBase64Url(t)?i.Convert.FromBase64Url(t):i.BufferSourceConverter.toArrayBuffer(e)}}constructor(...t){e.isAsnEncoded(t[0])?super(e.toArrayBuffer(t[0]),t[1]):super(t[0])}toString(e=`pem`){switch(e){case`pem`:return K.encode(this.rawData,this.tag);default:return super.toString(e)}}},Le=class e extends Ie{static async create(t,n=U.get()){if(t instanceof e)return t;if(ve.isCryptoKey(t)){if(t.type!==`public`)throw TypeError(`Public key is required`);let r=await n.subtle.exportKey(`spki`,t);return new e(r)}if(t.publicKey)return t.publicKey;if(i.BufferSourceConverter.isBufferSource(t))return new e(t);throw TypeError(`Unsupported PublicKeyType`)}constructor(e){Ie.isAsnEncoded(e)?super(e,r.SubjectPublicKeyInfo):super(e),this.tag=K.PublicKeyTag}async export(...e){let t,i=[`verify`],a={hash:`SHA-256`,...this.algorithm};e.length>1?(a=e[0]||a,i=e[1]||i,t=e[2]||U.get()):t=e[0]||U.get();let o=this.rawData,c=n.AsnConvert.parse(this.rawData,r.SubjectPublicKeyInfo);return c.algorithm.algorithm===s.id_RSASSA_PSS&&(o=Re(c,o)),t.subtle.importKey(`spki`,o,a,!0,i)}onInit(e){let t=l.container.resolve(b),r=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case s.id_rsaEncryption:{let t=n.AsnConvert.parse(e.subjectPublicKey,s.RSAPublicKey),a=i.BufferSourceConverter.toUint8Array(t.modulus);r.publicExponent=i.BufferSourceConverter.toUint8Array(t.publicExponent),r.modulusLength=(a[0]?a:a.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||U.get()):t=e[0]||U.get(),await t.subtle.digest(n,this.rawData)}async getKeyIdentifier(...e){let t,i=`SHA-1`;e.length===1?typeof e[0]==`string`?(i=e[0],t=U.get()):t=e[0]:e.length===2?(i=e[0],t=e[1]):t=U.get();let a=n.AsnConvert.parse(this.rawData,r.SubjectPublicKeyInfo);return await t.subtle.digest(i,a.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),t=n.AsnConvert.parse(this.rawData,r.SubjectPublicKeyInfo);switch(e.Algorithm=he.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case o.id_ecPublicKey:e[`EC Point`]=t.subjectPublicKey;break;case s.id_rsaEncryption:default:e[`Raw Data`]=t.subjectPublicKey}return e}};function Re(e,t){return e.algorithm=new r.AlgorithmIdentifier({algorithm:s.id_rsaEncryption,parameters:null}),t=n.AsnConvert.serialize(e),t}var ze=class e extends H{static async create(t,n=!1,r=U.get()){if(`name`in t&&`serialNumber`in t)return new e(t,n);let a=await(await Le.create(t,r)).getKeyIdentifier(r);return new e(i.Convert.ToHex(a),n)}constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]==`string`){let t=new p.AuthorityKeyIdentifier({keyIdentifier:new p.KeyIdentifier(i.Convert.FromHex(e[0]))});super(p.id_ce_authorityKeyIdentifier,e[1],n.AsnConvert.serialize(t))}else{let t=e[0],r=t.name instanceof Ne?n.AsnConvert.parse(t.name.rawData,p.GeneralNames):t.name,a=new p.AuthorityKeyIdentifier({authorityCertIssuer:r,authorityCertSerialNumber:i.Convert.FromHex(t.serialNumber)});super(p.id_ce_authorityKeyIdentifier,e[1],n.AsnConvert.serialize(a))}}onInit(e){super.onInit(e);let t=n.AsnConvert.parse(e.extnValue,p.AuthorityKeyIdentifier);t.keyIdentifier&&(this.keyId=i.Convert.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?i.Convert.ToHex(t.authorityCertSerialNumber):``})}toTextObject(){let e=this.toTextObjectWithoutValue(),t=n.AsnConvert.parse(this.value,p.AuthorityKeyIdentifier);return t.authorityCertIssuer&&(e[`Authority Issuer`]=new Ne(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e[`Authority Serial Number`]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[``]=t.keyIdentifier),e}};ze.NAME=`Authority Key Identifier`;var Be=class extends H{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,r.BasicConstraints);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{let t=new r.BasicConstraints({cA:e[0],pathLenConstraint:e[1]});super(r.id_ce_basicConstraints,e[2],n.AsnConvert.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e[`Path Length`]=this.pathLength),e}};Be.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||={});var He=class extends H{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,p.ExtendedKeyUsage);this.usages=t.map(e=>e)}else{let t=new p.ExtendedKeyUsage(e[0]);super(p.id_ce_extKeyUsage,e[1],n.AsnConvert.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.usages.map(e=>V.toString(e)).join(`, `),e}};He.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||={});var Ue=class extends H{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,r.KeyUsage);this.usages=t.toNumber()}else{let t=new r.KeyUsage(e[0]);super(r.id_ce_keyUsage,e[1],n.AsnConvert.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=n.AsnConvert.parse(this.value,r.KeyUsage).toJSON().join(`, `),e}};Ue.NAME=`Key Usages`;var We=class e extends H{static async create(t,n=!1,r=U.get()){let a=await(await Le.create(t,r)).getKeyIdentifier(r);return new e(i.Convert.ToHex(a),n)}constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,p.SubjectKeyIdentifier);this.keyId=i.Convert.ToHex(t)}else{let t=typeof e[0]==`string`?i.Convert.FromHex(e[0]):e[0],r=new p.SubjectKeyIdentifier(t);super(p.id_ce_subjectKeyIdentifier,e[1],n.AsnConvert.serialize(r)),this.keyId=i.Convert.ToHex(t)}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=n.AsnConvert.parse(this.value,p.SubjectKeyIdentifier),e}};We.NAME=`Subject Key Identifier`;var Ge=class extends H{constructor(...e){i.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(p.id_ce_subjectAltName,e[1],new Ne(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=n.AsnConvert.parse(e.extnValue,p.SubjectAlternativeName);this.names=new Ne(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};Ge.NAME=`Subject Alternative Name`;var J=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new H(e),n=this.items.get(t.type);return n?new n(e):t}};J.items=new Map;var Ke=class extends H{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,p.CertificatePolicies);this.policies=t.map(e=>e.policyIdentifier)}else{let t=e[0],r=e[1]??!1,i=new p.CertificatePolicies(t.map(e=>new p.PolicyInformation({policyIdentifier:e})));super(p.id_ce_certificatePolicies,r,n.AsnConvert.serialize(i)),this.policies=t}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(e=>new B(``,{},V.toString(e))),e}};Ke.NAME=`Certificate Policies`,J.register(p.id_ce_certificatePolicies,Ke);var qe=class extends H{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]==`string`){let t=e[0].map(e=>new p.DistributionPoint({distributionPoint:new p.DistributionPointName({fullName:[new p.GeneralName({uniformResourceIdentifier:e})]})})),r=new p.CRLDistributionPoints(t);super(p.id_ce_cRLDistributionPoints,e[1],n.AsnConvert.serialize(r))}else{let t=new p.CRLDistributionPoints(e[0]);super(p.id_ce_cRLDistributionPoints,e[1],n.AsnConvert.serialize(t))}this.distributionPoints??=[]}onInit(e){super.onInit(e);let t=n.AsnConvert.parse(e.extnValue,p.CRLDistributionPoints);this.distributionPoints=t}toTextObject(){let e=this.toTextObjectWithoutValue();return e[`Distribution Point`]=this.distributionPoints.map(e=>{let t={};return e.distributionPoint&&(t[``]=e.distributionPoint.fullName?.map(e=>new Me(e).toString()).join(`, `)),e.reasons&&(t.Reasons=e.reasons.toString()),e.cRLIssuer&&(t[`CRL Issuer`]=e.cRLIssuer.map(e=>e.toString()).join(`, `)),t}),e}};qe.NAME=`CRL Distribution Points`;var Je=class extends H{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof p.AuthorityInfoAccessSyntax){let t=new p.AuthorityInfoAccessSyntax(e[0]);super(p.id_pe_authorityInfoAccess,e[1],n.AsnConvert.serialize(t))}else{let t=e[0],r=new p.AuthorityInfoAccessSyntax;Xe(r,t,p.id_ad_ocsp,`ocsp`),Xe(r,t,p.id_ad_caIssuers,`caIssuers`),Xe(r,t,p.id_ad_timeStamping,`timeStamping`),Xe(r,t,p.id_ad_caRepository,`caRepository`),super(p.id_pe_authorityInfoAccess,e[1],n.AsnConvert.serialize(r))}this.ocsp??=[],this.caIssuers??=[],this.timeStamping??=[],this.caRepository??=[]}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],n.AsnConvert.parse(e.extnValue,p.AuthorityInfoAccessSyntax).forEach(e=>{switch(e.accessMethod){case p.id_ad_ocsp:this.ocsp.push(new Me(e.accessLocation));break;case p.id_ad_caIssuers:this.caIssuers.push(new Me(e.accessLocation));break;case p.id_ad_timeStamping:this.timeStamping.push(new Me(e.accessLocation));break;case p.id_ad_caRepository:this.caRepository.push(new Me(e.accessLocation))}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&Ye(e,`OCSP`,this.ocsp),this.caIssuers.length&&Ye(e,`CA Issuers`,this.caIssuers),this.timeStamping.length&&Ye(e,`Time Stamping`,this.timeStamping),this.caRepository.length&&Ye(e,`CA Repository`,this.caRepository),e}};Je.NAME=`Authority Info Access`;function Ye(e,t,n){if(n.length===1)e[t]=n[0].toTextObject();else{let r=new B(``);n.forEach((e,t)=>{let n=e.toTextObject(),i=`${n[B.NAME]} ${t+1}`,a=r[i];Array.isArray(a)||(a=[],r[i]=a),a.push(n)}),e[t]=r}}function Xe(e,t,r,i){let a=t[i];a&&(Array.isArray(a)?a:[a]).forEach(t=>{typeof t==`string`&&(t=new Me(`url`,t)),e.push(new p.AccessDescription({accessMethod:r,accessLocation:n.AsnConvert.parse(t.rawData,p.GeneralName)}))})}var Ze=class e extends ge{constructor(...e){let t;if(i.BufferSourceConverter.isBufferSource(e[0]))t=i.BufferSourceConverter.toArrayBuffer(e[0]);else{let a=e[0],o=Array.isArray(e[1])?e[1].map(e=>i.BufferSourceConverter.toArrayBuffer(e)):[];t=n.AsnConvert.serialize(new r.Attribute({type:a,values:o}))}super(t,r.Attribute)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(e=>new B(``,{"":e})),e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty();return t[B.NAME]===e.NAME&&(t[B.NAME]=V.toString(this.type)),t}};Ze.NAME=`Attribute`;var Qe=class extends Ze{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let t=new _.ChallengePassword({printableString:e[0]});super(_.id_pkcs9_at_challengePassword,[n.AsnConvert.serialize(t)])}this.password??=``}onInit(e){if(super.onInit(e),this.values[0]){let e=n.AsnConvert.parse(this.values[0],_.ChallengePassword);this.password=e.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[B.VALUE]=this.password,e}};Qe.NAME=`Challenge Password`;var $e=class extends Ze{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let t=e[0],r=new p.Extensions;for(let e of t)r.push(n.AsnConvert.parse(e.rawData,p.Extension));super(_.id_pkcs9_at_extensionRequest,[n.AsnConvert.serialize(r)])}this.items??=[]}onInit(e){if(super.onInit(e),this.values[0]){let e=n.AsnConvert.parse(this.values[0],p.Extensions);this.items=e.map(e=>J.create(n.AsnConvert.serialize(e)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.items.map(e=>e.toTextObject());for(let n of t)e[n[B.NAME]]=n;return e}};$e.NAME=`Extensions`;var et=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new Ze(e),n=this.items.get(t.type);return n?new n(e):t}};et.items=new Map;let tt=`crypto.signatureFormatter`;var nt=class{toAsnSignature(e,t){return i.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return i.BufferSourceConverter.toArrayBuffer(t)}},rt;e.RsaAlgorithm=rt=class{static createPssParams(e,t){let i=rt.getHashAlgorithm(e);return i?new g.RsaSaPssParams({hashAlgorithm:i,maskGenAlgorithm:new r.AlgorithmIdentifier({algorithm:g.id_mgf1,parameters:n.AsnConvert.serialize(i)}),saltLength:t}):null}static getHashAlgorithm(e){let t=l.container.resolve(b);return typeof e==`string`?t.toAsnAlgorithm({name:e}):typeof e==`object`&&e&&`name`in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`rsassa-pkcs1-v1_5`:if(`hash`in e){let t;if(typeof e.hash==`string`)t=e.hash;else if(e.hash&&typeof e.hash==`object`&&`name`in e.hash&&typeof e.hash.name==`string`)t=e.hash.name.toUpperCase();else throw Error(`Cannot get hash algorithm name`);switch(t.toLowerCase()){case`sha-1`:return new r.AlgorithmIdentifier({algorithm:g.id_sha1WithRSAEncryption,parameters:null});case`sha-256`:return new r.AlgorithmIdentifier({algorithm:g.id_sha256WithRSAEncryption,parameters:null});case`sha-384`:return new r.AlgorithmIdentifier({algorithm:g.id_sha384WithRSAEncryption,parameters:null});case`sha-512`:return new r.AlgorithmIdentifier({algorithm:g.id_sha512WithRSAEncryption,parameters:null})}}else return new r.AlgorithmIdentifier({algorithm:g.id_rsaEncryption,parameters:null});break;case`rsa-pss`:if(`hash`in e){if(!(`saltLength`in e&&typeof e.saltLength==`number`))throw Error(`Cannot get 'saltLength' from 'alg' argument`);let t=rt.createPssParams(e.hash,e.saltLength);if(!t)throw Error(`Cannot create PSS parameters`);return new r.AlgorithmIdentifier({algorithm:g.id_RSASSA_PSS,parameters:n.AsnConvert.serialize(t)})}return new r.AlgorithmIdentifier({algorithm:g.id_RSASSA_PSS,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case g.id_rsaEncryption:return{name:`RSASSA-PKCS1-v1_5`};case g.id_sha1WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-1`}};case g.id_sha256WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-256`}};case g.id_sha384WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-384`}};case g.id_sha512WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-512`}};case g.id_RSASSA_PSS:if(e.parameters){let t=n.AsnConvert.parse(e.parameters,g.RsaSaPssParams);return{name:`RSA-PSS`,hash:l.container.resolve(b).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}return{name:`RSA-PSS`}}return null}},e.RsaAlgorithm=rt=c.__decorate([l.injectable()],e.RsaAlgorithm),l.container.registerSingleton(v,e.RsaAlgorithm),e.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`sha-1`:return new r.AlgorithmIdentifier({algorithm:s.id_sha1});case`sha-256`:return new r.AlgorithmIdentifier({algorithm:s.id_sha256});case`sha-384`:return new r.AlgorithmIdentifier({algorithm:s.id_sha384});case`sha-512`:return new r.AlgorithmIdentifier({algorithm:s.id_sha512})}return null}toWebAlgorithm(e){switch(e.algorithm){case s.id_sha1:return{name:`SHA-1`};case s.id_sha256:return{name:`SHA-256`};case s.id_sha384:return{name:`SHA-384`};case s.id_sha512:return{name:`SHA-512`}}return null}},e.ShaAlgorithm=c.__decorate([l.injectable()],e.ShaAlgorithm),l.container.registerSingleton(v,e.ShaAlgorithm);var Y=class e{addPadding(e,t){let n=i.BufferSourceConverter.toUint8Array(t),r=new Uint8Array(e);return r.set(n,e-n.length),r}removePadding(e,t=!1){let n=i.BufferSourceConverter.toUint8Array(e);for(let e=0;e<n.length;e++)if(n[e]){n=n.slice(e);break}if(t&&n[0]>127){let e=new Uint8Array(n.length+1);return e.set(n,1),e.buffer}return n.buffer}toAsnSignature(t,r){if(t.name===`ECDSA`){let a=t.namedCurve,s=e.namedCurveSize.get(a)||e.defaultNamedCurveSize,c=new o.ECDSASigValue,l=i.BufferSourceConverter.toUint8Array(r);return c.r=this.removePadding(l.slice(0,s),!0),c.s=this.removePadding(l.slice(s,s+s),!0),n.AsnConvert.serialize(c)}return null}toWebSignature(t,r){if(t.name===`ECDSA`){let a=n.AsnConvert.parse(r,o.ECDSASigValue),s=t.namedCurve,c=e.namedCurveSize.get(s)||e.defaultNamedCurveSize,l=this.addPadding(c,this.removePadding(a.r)),u=this.addPadding(c,this.removePadding(a.s));return i.combine(l,u)}return null}};Y.namedCurveSize=new Map,Y.defaultNamedCurveSize=32;let it=`1.3.101.110`,at=`1.3.101.111`,ot=`1.3.101.112`,st=`1.3.101.113`;e.EdAlgorithm=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case`ed25519`:t=ot;break;case`x25519`:t=it;break;case`eddsa`:switch(e.namedCurve.toLowerCase()){case`ed25519`:t=ot;break;case`ed448`:t=st}break;case`ecdh-es`:switch(e.namedCurve.toLowerCase()){case`x25519`:t=it;break;case`x448`:t=at}}return t?new r.AlgorithmIdentifier({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case ot:return{name:`Ed25519`};case st:return{name:`EdDSA`,namedCurve:`Ed448`};case it:return{name:`X25519`};case at:return{name:`ECDH-ES`,namedCurve:`X448`}}return null}},e.EdAlgorithm=c.__decorate([l.injectable()],e.EdAlgorithm),l.container.registerSingleton(v,e.EdAlgorithm);var ct=class extends Ie{constructor(e){Ie.isAsnEncoded(e)?super(e,d.CertificationRequest):super(e),this.tag=K.CertificateRequestTag}onInit(e){this.tbs=n.AsnConvert.serialize(e.certificationRequestInfo),this.publicKey=new Le(e.certificationRequestInfo.subjectPKInfo);let t=l.container.resolve(b);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(e=>et.create(n.AsnConvert.serialize(e)));let r=this.getAttribute(u.id_pkcs9_at_extensionRequest);this.extensions=[],r instanceof $e&&(this.extensions=r.items),this.subjectName=new G(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(let 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(let 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=U.get()){let t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,[`verify`],e),r=l.container.resolveAll(tt).reverse(),i=null;for(let e of r)if(i=e.toWebSignature(t,this.signature),i)break;if(!i)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),t=n.AsnConvert.parse(this.rawData,d.CertificationRequest),i=t.certificationRequestInfo,a=new B(``,{Version:`${r.Version[i.version]} (${i.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let e=new B(``);for(let t of this.attributes){let n=t.toTextObject();e[n[B.NAME]]=n}a.Attributes=e}return e.Data=a,e.Signature=new B(``,{Algorithm:he.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}};ct.NAME=`PKCS#10 Certificate Request`;var lt=class{static async create(e,t=U.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw Error(`Bad field 'keys' in 'params' argument. 'publicKey' is empty`);let i=await t.subtle.exportKey(`spki`,e.keys.publicKey),a=new d.CertificationRequest({certificationRequestInfo:new d.CertificationRequestInfo({subjectPKInfo:n.AsnConvert.parse(i,r.SubjectPublicKeyInfo)})});if(e.name){let t=e.name instanceof G?e.name:new G(e.name);a.certificationRequestInfo.subject=n.AsnConvert.parse(t.toArrayBuffer(),r.Name)}if(e.attributes)for(let t of e.attributes)a.certificationRequestInfo.attributes.push(n.AsnConvert.parse(t.rawData,r.Attribute));if(e.extensions&&e.extensions.length){let t=new r.Attribute({type:u.id_pkcs9_at_extensionRequest}),i=new r.Extensions;for(let t of e.extensions)i.push(n.AsnConvert.parse(t.rawData,r.Extension));t.values.push(n.AsnConvert.serialize(i)),a.certificationRequestInfo.attributes.push(t)}let o={...e.signingAlgorithm,...e.keys.privateKey.algorithm};a.signatureAlgorithm=l.container.resolve(b).toAsnAlgorithm(o);let s=n.AsnConvert.serialize(a.certificationRequestInfo),c=await t.subtle.sign(o,e.keys.privateKey,s),f=l.container.resolveAll(tt).reverse(),p=null;for(let e of f)if(p=e.toAsnSignature(o,c),p)break;if(!p)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return a.signature=p,new ct(n.AsnConvert.serialize(a))}},ut=class extends Ie{constructor(e){Ie.isAsnEncoded(e)?super(e,r.Certificate):super(e),this.tag=K.CertificateTag}onInit(e){let t=e.tbsCertificate;this.tbs=n.AsnConvert.serialize(t),this.serialNumber=i.Convert.ToHex(t.serialNumber),this.subjectName=new G(t.subject),this.subject=new G(t.subject).toString(),this.issuerName=new G(t.issuer),this.issuer=this.issuerName.toString();let r=l.container.resolve(b);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;let a=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!a)throw Error(`Cannot get 'notBefore' value`);this.notBefore=a;let o=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!o)throw Error(`Cannot get 'notAfter' value`);this.notAfter=o,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(e=>J.create(n.AsnConvert.serialize(e)))),this.publicKey=new Le(t.subjectPublicKeyInfo)}getExtension(e){for(let t of this.extensions)if(typeof e==`string`){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e==`string`?t.type===e:t instanceof e)}async verify(e={},t=U.get()){let n,r,a=e.publicKey;try{if(!a)n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,[`verify`],t);else if(`publicKey`in a)n={...a.publicKey.algorithm,...this.signatureAlgorithm},r=await a.publicKey.export(n,[`verify`],t);else if(a instanceof Le)n={...a.algorithm,...this.signatureAlgorithm},r=await a.export(n,[`verify`],t);else if(i.BufferSourceConverter.isBufferSource(a)){let e=new Le(a);n={...e.algorithm,...this.signatureAlgorithm},r=await e.export(n,[`verify`],t)}else n={...a.algorithm,...this.signatureAlgorithm},r=a}catch{return!1}let o=l.container.resolveAll(tt).reverse(),s=null;for(let e of o)if(s=e.toWebSignature(n,this.signature),s)break;if(!s)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);let c=await t.subtle.verify(this.signatureAlgorithm,r,s,this.tbs);if(e.signatureOnly)return c;{let t=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<t&&t<this.notAfter.getTime()}}async getThumbprint(...e){let t,n=`SHA-1`;return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??=U.get(),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=U.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),t=n.AsnConvert.parse(this.rawData,r.Certificate),i=t.tbsCertificate,a=new B(``,{Version:`${r.Version[i.version]} (${i.version})`,"Serial Number":i.serialNumber,"Signature Algorithm":he.serializeAlgorithm(i.signature),Issuer:this.issuer,Validity:new B(``,{"Not Before":i.validity.notBefore.getTime(),"Not After":i.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(i.issuerUniqueID&&(a[`Issuer Unique ID`]=i.issuerUniqueID),i.subjectUniqueID&&(a[`Subject Unique ID`]=i.subjectUniqueID),this.extensions.length){let e=new B(``);for(let t of this.extensions){let n=t.toTextObject();e[n[B.NAME]]=n}a.Extensions=e}return e.Data=a,e.Signature=new B(``,{Algorithm:he.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}};ut.NAME=`Certificate`;var dt=class extends Array{constructor(e){if(super(),Ie.isAsnEncoded(e))this.import(e);else if(e instanceof ut)this.push(e);else if(Array.isArray(e))for(let t of e)this.push(t)}export(e){let t=new m.SignedData;t.version=1,t.encapContentInfo.eContentType=m.id_data,t.encapContentInfo.eContent=new m.EncapsulatedContent({single:new n.OctetString}),t.certificates=new m.CertificateSet(this.map(e=>new m.CertificateChoices({certificate:n.AsnConvert.parse(e.rawData,r.Certificate)})));let i=new m.ContentInfo({contentType:m.id_signedData,content:n.AsnConvert.serialize(t)}),a=n.AsnConvert.serialize(i);return e===`raw`?a:this.toString(e)}import(e){let t=Ie.toArrayBuffer(e),r=n.AsnConvert.parse(t,m.ContentInfo);if(r.contentType!==m.id_signedData)throw TypeError(`Cannot parse CMS package. Incoming data is not a SignedData object.`);let i=n.AsnConvert.parse(r.content,m.SignedData);this.clear();for(let e of i.certificates||[])e.certificate&&this.push(new ut(e.certificate))}clear(){for(;this.pop(););}toString(e=`pem`){let t=this.export(`raw`);switch(e){case`pem`:return K.encode(t,`CMS`);case`pem-chain`:return this.map(e=>e.toString(`pem`)).join(`
135
- `);case`asn`:return n.AsnConvert.toString(t);case`hex`:return i.Convert.ToHex(t);case`base64`:return i.Convert.ToBase64(t);case`base64url`:return i.Convert.ToBase64Url(t);case`text`:return he.serialize(this.toTextObject());default:throw TypeError(`Argument 'format' is unsupported value`)}}toTextObject(){let e=n.AsnConvert.parse(this.export(`raw`),m.ContentInfo),t=n.AsnConvert.parse(e.content,m.SignedData);return new B(`X509Certificates`,{"Content Type":V.toString(e.contentType),Content:new B(``,{Version:`${m.CMSVersion[t.version]} (${t.version})`,Certificates:new B(``,{Certificate:this.map(e=>e.toTextObject())})})})}},ft=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=U.get()){let n=new dt(e),r=e;for(;r=await this.findIssuer(r,t);){let e=await r.getThumbprint(t);for(let r of n){let n=await r.getThumbprint(t);if(i.isEqual(e,n))throw Error(`Cannot build a certificate chain. Circular dependency.`)}n.push(r)}return n}async findIssuer(e,t=U.get()){if(!await e.isSelfSigned(t)){let r=e.getExtension(p.id_ce_authorityKeyIdentifier);for(let a of this.certificates)if(a.subject===e.issuer){if(r){if(r.keyId){let e=a.getExtension(p.id_ce_subjectKeyIdentifier);if(e&&e.keyId!==r.keyId)continue}else if(r.certId){let e=a.getExtension(p.id_ce_subjectAltName);if(e&&!(r.certId.serialNumber===a.serialNumber&&i.isEqual(n.AsnConvert.serialize(r.certId.name),n.AsnConvert.serialize(e))))continue}}try{let n={...a.publicKey.algorithm,...e.signatureAlgorithm},r=await a.publicKey.export(n,[`verify`],t);if(!await e.verify({publicKey:r,signatureOnly:!0},t))continue}catch{continue}return a}}return null}},pt=class{static async createSelfSigned(e,t=U.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw 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=U.get()){let r;r=e.publicKey instanceof Le?e.publicKey.rawData:`publicKey`in e.publicKey?e.publicKey.publicKey.rawData:i.BufferSourceConverter.isBufferSource(e.publicKey)?e.publicKey:await t.subtle.exportKey(`spki`,e.publicKey);let a=e.serialNumber?i.BufferSourceConverter.toUint8Array(i.Convert.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));a[0]>127&&(a[0]&=127),a.length>1&&a[0]===0&&(a[1]|=128);let o=e.notBefore||new Date,s=e.notAfter||new Date(o.getTime()+31536e6),c=new p.Certificate({tbsCertificate:new p.TBSCertificate({version:p.Version.v3,serialNumber:a,validity:new p.Validity({notBefore:o,notAfter:s}),extensions:new p.Extensions(e.extensions?.map(e=>n.AsnConvert.parse(e.rawData,p.Extension))||[]),subjectPublicKeyInfo:n.AsnConvert.parse(r,p.SubjectPublicKeyInfo)})});if(e.subject){let t=e.subject instanceof G?e.subject:new G(e.subject);c.tbsCertificate.subject=n.AsnConvert.parse(t.toArrayBuffer(),p.Name)}if(e.issuer){let t=e.issuer instanceof G?e.issuer:new G(e.issuer);c.tbsCertificate.issuer=n.AsnConvert.parse(t.toArrayBuffer(),p.Name)}let u={hash:`SHA-256`},d=`signingKey`in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},f=l.container.resolve(b);c.tbsCertificate.signature=c.signatureAlgorithm=f.toAsnAlgorithm(d);let m=n.AsnConvert.serialize(c.tbsCertificate),h=`signingKey`in e?await t.subtle.sign(d,e.signingKey,m):e.signature,g=l.container.resolveAll(tt).reverse(),_=null;for(let e of g)if(_=e.toAsnSignature(d,h),_)break;if(!_)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return c.signatureValue=_,new ut(n.AsnConvert.serialize(c))}};e.X509CrlReason=void 0,(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`})(e.X509CrlReason||={});var mt=class extends ge{constructor(...e){let t;t=i.BufferSourceConverter.isBufferSource(e[0])?i.BufferSourceConverter.toArrayBuffer(e[0]):n.AsnConvert.serialize(new r.RevokedCertificate({userCertificate:e[0],revocationDate:new r.Time(e[1]),crlEntryExtensions:e[2]})),super(t,r.RevokedCertificate)}onInit(e){this.serialNumber=i.Convert.ToHex(e.userCertificate),this.revocationDate=e.revocationDate.getTime(),this.extensions=[],e.crlEntryExtensions&&(this.extensions=e.crlEntryExtensions.map(e=>{let t=J.create(n.AsnConvert.serialize(e));switch(t.type){case r.id_ce_cRLReasons:this.reason=n.AsnConvert.parse(t.value,r.CRLReason).reason;break;case r.id_ce_invalidityDate:this.invalidity=n.AsnConvert.parse(t.value,r.InvalidityDate).value}return t}))}},ht=class extends Ie{constructor(e){Ie.isAsnEncoded(e)?super(e,r.CertificateList):super(e),this.tag=K.CrlTag}onInit(e){let t=e.tbsCertList;this.tbs=n.AsnConvert.serialize(t),this.version=t.version;let r=l.container.resolve(b);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.tbsCertListSignatureAlgorithm=t.signature,this.certListSignatureAlgorithm=e.signatureAlgorithm,this.signature=e.signature,this.issuerName=new G(t.issuer),this.issuer=this.issuerName.toString();let i=t.thisUpdate.getTime();if(!i)throw Error(`Cannot get 'thisUpdate' value`);this.thisUpdate=i;let a=t.nextUpdate?.getTime();this.nextUpdate=a,this.entries=t.revokedCertificates?.map(e=>new mt(n.AsnConvert.serialize(e)))||[],this.extensions=[],t.crlExtensions&&(this.extensions=t.crlExtensions.map(e=>J.create(n.AsnConvert.serialize(e))))}getExtension(e){for(let t of this.extensions)if(typeof e==`string`){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e==`string`?t.type===e:t instanceof e)}async verify(e,t=U.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw Error(`algorithm identifier in the sequence tbsCertList and CertificateList mismatch`);let n,r,i=e.publicKey;try{i instanceof ut?(n={...i.publicKey.algorithm,...i.signatureAlgorithm},r=await i.publicKey.export(n,[`verify`])):i instanceof Le?(n={...i.algorithm,...this.signature},r=await i.export(n,[`verify`])):(n={...i.algorithm,...this.signature},r=i)}catch{return!1}let a=l.container.resolveAll(tt).reverse(),o=null;for(let e of a)if(o=e.toWebSignature(n,this.signature),o)break;if(!o)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return await t.subtle.verify(this.signatureAlgorithm,r,o,this.tbs)}async getThumbprint(...e){let t,n=`SHA-1`;return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??=U.get(),await t.subtle.digest(n,this.rawData)}findRevoked(e){let t=typeof e==`string`?e:e.serialNumber;for(let e of this.entries)if(e.serialNumber===t)return e;return null}},gt=class{static async create(e,t=U.get()){let a=e.issuer instanceof G?e.issuer:new G(e.issuer),o=new p.CertificateList({tbsCertList:new p.TBSCertList({version:p.Version.v2,issuer:n.AsnConvert.parse(a.toArrayBuffer(),p.Name),thisUpdate:new r.Time(e.thisUpdate||new Date)})});if(e.nextUpdate&&(o.tbsCertList.nextUpdate=new r.Time(e.nextUpdate)),e.extensions&&e.extensions.length&&(o.tbsCertList.crlExtensions=new p.Extensions(e.extensions.map(e=>n.AsnConvert.parse(e.rawData,p.Extension))||[])),e.entries&&e.entries.length){o.tbsCertList.revokedCertificates=[];for(let t of e.entries){let a=Ie.toArrayBuffer(t.serialNumber);if(o.tbsCertList.revokedCertificates.findIndex(e=>i.isEqual(e.userCertificate,a))>-1)throw Error(`Certificate serial number ${t.serialNumber} already exists in tbsCertList`);let s=new r.RevokedCertificate({userCertificate:a,revocationDate:new r.Time(t.revocationDate||new Date)});if(s.crlEntryExtensions=`extensions`in t&&t.extensions?.length?t.extensions.map(e=>n.AsnConvert.parse(e.rawData,p.Extension)):[],!(t instanceof mt)&&(t.reason&&s.crlEntryExtensions.push(new p.Extension({extnID:p.id_ce_cRLReasons,critical:!1,extnValue:new n.OctetString(n.AsnConvert.serialize(new p.CRLReason(t.reason)))})),t.invalidity&&s.crlEntryExtensions.push(new p.Extension({extnID:p.id_ce_invalidityDate,critical:!1,extnValue:new n.OctetString(n.AsnConvert.serialize(new p.InvalidityDate(t.invalidity)))})),t.issuer)){let t=e.issuer instanceof G?e.issuer:new G(e.issuer);s.crlEntryExtensions.push(new p.Extension({extnID:p.id_ce_certificateIssuer,critical:!1,extnValue:new n.OctetString(n.AsnConvert.serialize(n.AsnConvert.parse(t.toArrayBuffer(),p.Name)))}))}o.tbsCertList.revokedCertificates.push(s)}}let s={...e.signingAlgorithm,...e.signingKey.algorithm},c=l.container.resolve(b);o.tbsCertList.signature=o.signatureAlgorithm=c.toAsnAlgorithm(s);let u=n.AsnConvert.serialize(o.tbsCertList),d=await t.subtle.sign(s,e.signingKey,u),f=l.container.resolveAll(tt).reverse(),m=null;for(let e of f)if(m=e.toAsnSignature(s,d),m)break;if(!m)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return o.signature=m,new ht(n.AsnConvert.serialize(o))}};J.register(p.id_ce_basicConstraints,Be),J.register(p.id_ce_extKeyUsage,He),J.register(p.id_ce_keyUsage,Ue),J.register(p.id_ce_subjectKeyIdentifier,We),J.register(p.id_ce_authorityKeyIdentifier,ze),J.register(p.id_ce_subjectAltName,Ge),J.register(p.id_ce_cRLDistributionPoints,qe),J.register(p.id_pe_authorityInfoAccess,Je),et.register(_.id_pkcs9_at_challengePassword,Qe),et.register(_.id_pkcs9_at_extensionRequest,$e),l.container.registerSingleton(tt,nt),l.container.registerSingleton(tt,Y),Y.namedCurveSize.set(`P-256`,32),Y.namedCurveSize.set(`K-256`,32),Y.namedCurveSize.set(`P-384`,48),Y.namedCurveSize.set(`P-521`,66),e.AlgorithmProvider=y,e.AsnData=ge,e.AsnDefaultSignatureFormatter=nt,e.AsnEcSignatureFormatter=Y,e.Attribute=Ze,e.AttributeFactory=et,e.AuthorityInfoAccessExtension=Je,e.AuthorityKeyIdentifierExtension=ze,e.BasicConstraintsExtension=Be,e.CRLDistributionPointsExtension=qe,e.CertificatePolicyExtension=Ke,e.ChallengePasswordAttribute=Qe,e.CryptoProvider=ve,e.DefaultAlgorithmSerializer=me,e.ExtendedKeyUsageExtension=He,e.Extension=H,e.ExtensionFactory=J,e.ExtensionsAttribute=$e,e.GeneralName=Me,e.GeneralNames=Ne,e.KeyUsagesExtension=Ue,e.Name=G,e.NameIdentifier=xe,e.OidSerializer=V,e.PemConverter=K,e.Pkcs10CertificateRequest=ct,e.Pkcs10CertificateRequestGenerator=lt,e.PublicKey=Le,e.SubjectAlternativeNameExtension=Ge,e.SubjectKeyIdentifierExtension=We,e.TextConverter=he,e.TextObject=B,e.X509Certificate=ut,e.X509CertificateGenerator=pt,e.X509Certificates=dt,e.X509ChainBuilder=ft,e.X509Crl=ht,e.X509CrlEntry=mt,e.X509CrlGenerator=gt,e.cryptoProvider=U,e.diAlgorithm=v,e.diAlgorithmProvider=b,e.diAsnSignatureFormatter=tt,e.idEd25519=ot,e.idEd448=st,e.idX25519=it,e.idX448=at}));Be(),wa();var Ta;(function(e){e.Der=`der`,e.Raw=`raw`})(Ta||={});const Ea=typeof window<`u`&&window.document!==void 0&&typeof crypto<`u`&&crypto.subtle!==void 0,Da=typeof process<`u`&&process.versions!=null&&process.versions.node!=null,Oa=()=>Ea?`browser`:Da?`node`:`purejs`,ka=async(e,t)=>{let n=t??Oa();switch(n){case`browser`:return(await import(`./webcrypto-CRLL4ptE.mjs`)).signWithApiKey(e);case`node`:return(await import(`./nodecrypto-CIGSbdQh.mjs`)).signWithApiKey(e);case`purejs`:return(await import(`./purejs-CZxWHjtN.mjs`)).signWithApiKey(e);default:throw Error(`Unsupported runtime: ${n}`)}};var Aa=class{constructor(e){this.apiPublicKey=e.apiPublicKey,this.apiPrivateKey=e.apiPrivateKey,this.runtimeOverride=e.runtimeOverride}async stamp(e){let t=await ka({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride),n={publicKey:this.apiPublicKey,scheme:`SIGNATURE_SCHEME_TK_API_P256`,signature:t};return{stampHeaderName:`X-Stamp`,stampHeaderValue:c(JSON.stringify(n))}}async sign(e,t){switch(t){case Ta.Raw:{let t=await ka({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride),n=Re(t);return a(n)}case Ta.Der:return ka({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride);default:throw Error(`Unsupported signature format: ${t}`)}}},ja=class extends Error{constructor(e){super(e),this.name=`InvalidKeyError`}};function Ma(){let e=m(`prime256v1`);return e.generateKeys(),Pa(e.getPrivateKey().toString(`hex`).padStart(64,`0`))}const Na=/^[0-9a-f]{64}$/i;function Pa(e){if(!Na.test(e))throw new ja(`P-256 private key must be 64 hex characters`);let t=e.toLowerCase(),n=m(`prime256v1`);try{n.setPrivateKey(Buffer.from(t,`hex`))}catch{throw new ja(`value is not a valid P-256 private key (scalar out of range)`)}return{algorithm:`p256`,privateKeyHex:t,publicKeyHex:n.getPublicKey(`hex`,`compressed`)}}function Fa(e){try{let t=p.convertKey(e,`prime256v1`,`hex`,`hex`,`uncompressed`),n=Buffer.isBuffer(t)?t:Buffer.from(t,`hex`);return n.length===65?n:null}catch{return null}}function Ia(e){let t=Fa(e);if(t===null)throw new ja(`value is not a valid P-256 public key`);return La(t)}function La(e){let t=e.subarray(1,33).toString(`base64url`),n=e.subarray(33,65).toString(`base64url`);return h(`sha256`).update(`{"crv":"P-256","kty":"EC","x":"${t}","y":"${n}"}`,`utf8`).digest(`base64url`)}const Ra=/^https?:\/\/[\x21\x23-\x7e]{1,255}$/,za=/^[\x21\x23-\x3a\x3c-\x7e]{1,128}$/;function Ba(e,t){return`${e.replace(/\/+$/,``)}/agent-keys/${t}`}function Va(e){let t=Ha(e.keypair),n={...t,identityUrl:Ua(e.identityUrl??Ba(e.baseUrl,t.keyId))};return{sign:async e=>{let t=new Uint8Array(await e.clone().arrayBuffer()),r=Wa(n,{method:e.method,url:e.url,body:t},{nonce:_(16).toString(`base64url`),createdAt:new Date}),i=new Headers(e.headers);for(let[e,t]of Object.entries(r))i.set(e,t);return new Request(e,{headers:i})}}}function Ha(e){let t=Fa(e.publicKeyHex);if(t===null)throw Error(`signer keypair has an invalid P-256 public key`);return{signingKey:Ja(t,e.privateKeyHex),keyId:La(t)}}function Ua(e){if(!Ra.test(e))throw Error(`identity URL is outside the signature profile: "${e}"`);return e}function Wa(e,t,n){if(!za.test(n.nonce))throw Error(`nonce is outside the signature profile`);let r=Ga(t.body),i=`"${e.identityUrl}"`,a=`("@method" "@target-uri" "content-digest" "signature-agent");created=${Math.floor(n.createdAt.getTime()/1e3)};keyid="${e.keyId}";nonce="${n.nonce}";alg="ecdsa-p256-sha256"`,o=[`"@method": ${t.method.toUpperCase()}`,`"@target-uri": ${Ka(new URL(t.url))}`,`"content-digest": ${r}`,`"signature-agent": ${i}`,`"@signature-params": ${a}`].join(`
136
- `),s=v(`sha256`,Buffer.from(o,`utf8`),{key:e.signingKey,dsaEncoding:`ieee-p1363`});return{"Content-Digest":r,"Signature-Agent":i,"Signature-Input":`sig=${a}`,Signature:`sig=:${s.toString(`base64`)}:`}}function Ga(e){return`sha-256=:${h(`sha256`).update(e??``).digest(`base64`)}:`}function Ka(e){return`${e.protocol}//${qa(e)}${e.pathname}${e.search}`}function qa(e){let t=e.host.toLowerCase();return e.protocol===`https:`&&e.port===`443`||e.protocol===`http:`&&e.port===`80`?e.hostname.toLowerCase():t}function Ja(e,t){return g({key:{kty:`EC`,crv:`P-256`,d:Buffer.from(t,`hex`).toString(`base64url`),x:e.subarray(1,33).toString(`base64url`),y:e.subarray(33,65).toString(`base64url`)},format:`jwk`})}var Ya=`0.1.0`;const Xa=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Za=Ya;function Qa(e,t){if(!Xa.test(e))throw Error(`${t} must be a valid HTTP token`)}function $a(e,t){let n=!1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r<32||r===127||r>255){n=!0;break}}if(n||/[()\\]/.test(e))throw Error(`${t} must not contain parentheses, backslashes, control characters, or characters outside Latin-1`)}function eo(e){let t=`catena-agent-client/${Za}`;if(!e)return t;Qa(e.name,`appInfo.name`),e.version!==void 0&&Qa(e.version,`appInfo.version`),e.url!==void 0&&$a(e.url,`appInfo.url`);let n=e.version===void 0?e.name:`${e.name}/${e.version}`;return`${e.url===void 0?n:`${n} (${e.url})`} ${t}`}const to=f.object({amount:f.string(),asset_id:f.string()}),no=f.pipe(f.string(),f.isoTimestamp()),ro=f.object({success:f.literal(!0)}),io=f.object({id:f.string(),name:f.string(),status:f.string(),organizationId:f.string()}),ao=f.object({agent:io}),oo=f.object({id:f.string(),ruleType:f.picklist([`per_transaction_amount`,`daily_amount`,`weekly_amount`,`monthly_amount`,`hourly_count`,`daily_count`]),thresholdAmount:f.optional(to),thresholdCount:f.optional(f.number()),action:f.picklist([`block`,`require_approval`]),requiredApprovals:f.number(),accountAggregationScope:f.picklist([`per_account`,`across_accounts`]),actorAggregationScope:f.picklist([`per_agent`,`per_policy`]),displayOrder:f.number()}),so=f.object({id:f.string(),organizationId:f.string(),policyId:f.string(),capability:f.picklist([`query_balance`,`read`,`send`,`transfer`]),accountId:f.string(),rules:f.array(oo),createdAt:no,updatedAt:no}),co=f.object({mode:f.picklist([`open`,`restricted`]),allowedCounterparties:f.optional(f.array(f.string())),createAction:f.optional(f.picklist([`allow`,`block`,`require_approval`])),allowCreate:f.optional(f.boolean())}),lo=f.object({id:f.optional(f.string()),description:f.optional(f.string()),version:f.optional(f.number()),name:f.string(),capabilities:f.array(f.string()),counterpartyRules:f.optional(co),policyCapabilities:f.array(so)}),uo=f.object({policy:lo}),fo=f.object({accounts:f.array(f.object({id:f.string(),name:f.string(),type:f.string(),currency:f.string()}))}),po=f.object({accountId:f.string(),balance:to,balances:f.optional(f.object({total:to,available:to}))}),mo=f.object({id:f.string(),type:f.picklist([`operator-send`,`operator-transfer`,`operator-deposit`,`operator-refund`,`microdeposit`]),action:f.optional(f.string()),status:f.picklist([`pending`,`processing`,`completed`,`failed`,`reversed`]),movementStatus:f.picklist([`initiated`,`provider_pending`,`processing`,`completed`,`failed`,`reversed`,`manual_review`]),direction:f.picklist([`incoming`,`outgoing`]),amount:to,fee:to,currency:f.string(),counterpartyName:f.optional(f.string()),method:f.optional(f.picklist([`ach`,`wire`,`on-chain`])),memo:f.optional(f.string()),description:f.optional(f.string()),txHash:f.optional(f.string()),createdAt:no,completedAt:f.optional(no)}),ho=f.object({accountId:f.string(),transactions:f.array(mo),total:f.number()}),go=f.object({accountId:f.string(),address:f.string(),liquidationAddressId:f.optional(f.string()),source:f.picklist([`wallet`,`liquidation`])}),_o=f.object({id:f.string(),name:f.string(),status:f.optional(f.string()),rails:f.array(f.object({id:f.string(),type:f.string(),walletAddress:f.optional(f.string()),network:f.optional(f.string()),bankName:f.optional(f.string()),accountNumber:f.optional(f.string())}))}),vo=f.object({counterparties:f.array(_o)}),yo=f.picklist([`pending`,`processing`,`completed`,`blocked`,`failed`]),bo=f.object({type:f.literal(`submit_stamp`),signingRequestId:f.string(),signer:f.object({algorithm:f.literal(`p256`),publicKeyHex:f.string()}),preparedBody:f.object({body:f.string(),bodyHash:f.string(),expiresAt:no,prepareToken:f.string()})}),xo=f.object({id:f.string(),type:f.picklist([`send`,`transfer`,`create_counterparty`,`request_counterparty_details`,`x402`]),status:yo,reasons:f.array(f.string()),expiresAt:f.optional(f.nullable(no),null),replayed:f.optional(f.boolean(),!1),data:f.optional(f.nullable(f.record(f.string(),f.unknown())),null),metadata:f.optional(f.object({dataUrl:f.nullable(f.string())})),nextAction:f.optional(bo)});function So(e){let{nextAction:t,...n}=e;return n}const Co=[`ach`,`wire`,`on-chain`],wo=f.picklist(Co),To=f.object({type:f.literal(`send`),accountId:f.string(),counterpartyRailId:f.string(),amount:f.string(),method:wo,memo:f.optional(f.string()),description:f.optional(f.string())}),Eo=f.object({type:f.literal(`transfer`),accountId:f.string(),toAccountId:f.string(),amount:f.string(),memo:f.optional(f.string()),description:f.optional(f.string())}),Do={type:f.literal(`create_counterparty`),name:f.string()},Oo=f.union([f.object({...Do,email:f.optional(f.string()),rail:f.nonOptional(f.unknown())}),f.object({...Do,email:f.string()})]),ko=f.looseObject({scheme:f.string(),network:f.string(),asset:f.string(),amount:f.string(),payTo:f.string(),maxTimeoutSeconds:f.number()}),Ao=f.looseObject({url:f.string(),serviceName:f.fallback(f.optional(f.pipe(f.string(),f.maxLength(255))),void 0)}),jo=f.object({type:f.literal(`x402`),accountId:f.string(),paymentRequirements:ko,resource:f.optional(Ao)}),Mo=f.union([To,Eo,Oo,jo]);function No(e){let t=f.parse(Mo,e);return t.type===`send`||t.type===`transfer`?{...t,amount:{amount:t.amount,asset_id:`USD`}}:t}const Po=f.object({intent:xo});var Fo=class extends Error{status;code;constructor(e,t,n){super(n?`API error ${e} [${n}]: ${t}`:`API error ${e}: ${t}`),this.name=`ApiError`,this.status=e,this.code=n}},Io=class extends Error{timeoutMs;constructor(e){super(`Request timed out after ${e}ms. The server may still have processed a state-changing request; follow that operation's documented recovery procedure before retrying.`),this.name=`TimeoutError`,this.timeoutMs=e}};const Lo=f.object({error:f.nullish(f.string()),message:f.nullish(f.string()),code:f.nullish(f.string())});async function Ro(e){let t=f.safeParse(Lo,await e.json().catch(()=>void 0)),n=t.success?t.output:{};return n.error!=null&&n.message!=null?new Fo(e.status,n.message,n.code??n.error):new Fo(e.status,n.error??n.message??e.statusText,n.code??void 0)}async function zo(e,t){if(!e.ok)throw await Ro(e);return f.parse(t,await e.json())}var Bo=class extends Error{intentId;outcome;constructor(e){let t=e.cause instanceof Error?e.cause.message:String(e.cause);super(e.outcome===`not-submitted`?`Intent ${e.intentId} was created but never submitted; no money moved: ${t}`:`Intent ${e.intentId} submission could not be confirmed: ${t}; poll getIntent("${e.intentId}") to a terminal status and resubmit only after blocked or failed`,{cause:e.cause}),this.name=`IntentSubmitError`,this.intentId=e.intentId,this.outcome=e.outcome}};const Vo=2147483647;var Ho=class{#e;#t;#n;#r;#i;#a;#o;constructor(e){let t=e.timeout===void 0?8e4:e.timeout;if(!Number.isInteger(t)||t<=0||t>Vo)throw TypeError(`timeout must be a positive integer no greater than ${Vo}`);this.#e=e.baseUrl??`https://api.catena.com`,this.#t=eo(e.appInfo),this.#n=e.defaultHeaders??{},this.#r=Pa(e.privateKeyHex),this.#a=(e.fetch??globalThis.fetch).bind(globalThis),this.#o=t,this.#i=Va({keypair:this.#r,baseUrl:this.#e,identityUrl:e.identityUrl})}#s(e){let t=new Headers({"Content-Type":`application/json`});for(let[e,n]of Object.entries(this.#n))t.set(e,n);for(let[n,r]of Object.entries(e??{}))t.set(n,r);return t.set(`User-Agent`,this.#t),t.delete(`Authorization`),t}async#c(e){let t=new URL(`${this.#e}/v1/agent-api${e.path}`);for(let[n,r]of Object.entries(e.query??{}))r!==void 0&&t.searchParams.set(n,r);let n=new Request(t,{method:e.method,headers:this.#s(e.headers),body:e.body===void 0?null:JSON.stringify(e.body)});return this.#i.sign(n)}async#l(e,t){return this.#u(await this.#c(e),t)}async#u(e,t){let n=new AbortController,r=new Request(e,{signal:n.signal}),i;try{let e=new Promise((e,t)=>{i=setTimeout(()=>{let e=new Io(this.#o);t(e),n.abort(e)},this.#o)}),a=this.#a(r).then(e=>zo(e,t));return await Promise.race([a,e])}finally{i!==void 0&&clearTimeout(i)}}async whoami(){return(await this.#l({method:`GET`,path:`/me`},ao)).agent}async submitFeedback(e){await this.#l({method:`POST`,path:`/feedback`,body:{body:e}},ro)}async getPolicy(){return(await this.#l({method:`GET`,path:`/policy`},uo)).policy}async listAccounts(){return this.#l({method:`GET`,path:`/accounts`},fo)}async getAccountBalance(e){return this.#l({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/balance`},po)}async listAccountTransactions(e,t={}){return this.#l({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/transactions`,query:{start:t.start,end:t.end,limit:t.limit?.toString(),offset:t.offset?.toString()}},ho)}async getAccountDepositAddress(e,t){return this.#l({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/deposit-address`,query:{network:t.network,asset:t.asset}},go)}async listCounterparties(e={}){return this.#l({method:`GET`,path:`/counterparties`,query:{address:e.address,network:e.network}},vo)}async submitIntent(e){let t=await this.#d(e),n=t.nextAction;if(!n)return So(t);let r;try{let e=await this.#f(n);r=await this.#c({method:`POST`,path:`/intents/${encodeURIComponent(t.id)}/submit-stamp`,body:{preparedBody:n.preparedBody,stamp:e}})}catch(e){throw new Bo({intentId:t.id,outcome:`not-submitted`,cause:e})}try{return await this.#p(r,t.replayed)}catch(e){throw new Bo({intentId:t.id,outcome:`unknown`,cause:e})}}async#d(e){return this.#l({method:`POST`,path:`/intents`,body:{action:No(e.action)},...e.idempotencyKey!==void 0&&{headers:{"Idempotency-Key":e.idempotencyKey}}},xo)}async#f(e){if(e.signer.publicKeyHex.toLowerCase()!==this.#r.publicKeyHex.toLowerCase())throw Error(`Local signer public key does not match requested signer ${e.signer.publicKeyHex}; linked credential has ${this.#r.publicKeyHex}`);let t=await new Aa({apiPublicKey:this.#r.publicKeyHex,apiPrivateKey:this.#r.privateKeyHex}).stamp(e.preparedBody.body);return{publicKeyHex:this.#r.publicKeyHex,stampHeaderName:t.stampHeaderName,stampHeaderValue:t.stampHeaderValue}}async#p(e,t){let n=So((await this.#u(e,Po)).intent);return t?{...n,replayed:!0}:n}async getIntent(e){return So(await this.#l({method:`GET`,path:`/intents/${encodeURIComponent(e)}`},xo))}async unlinkAgent(){await this.#l({method:`POST`,path:`/unlink`},ro)}async reportSettlement(e){await this.#l({method:`POST`,path:`/intents/${encodeURIComponent(e.intentId)}/settlement-report`,body:{txHash:e.txHash}},ro)}};function Uo(e={}){let t=e.privateKeyHex===void 0?process.env.CATENA_SECRET_KEY:e.privateKeyHex;if(t===void 0)throw new ja(`privateKeyHex is required; pass it explicitly or set CATENA_SECRET_KEY`);return new Ho({...e,privateKeyHex:t})}const Wo=[`registered`,`already_registered`,`not_applicable`,`registration_failed`],Go=f.pipe(f.string(),f.regex(/^0[23][0-9a-f]{64}$/)),Ko=f.pipe(f.string(),f.regex(/^[0-9a-f]{64}$/)),qo=f.object({status:f.picklist(Wo),publicKeyHex:f.optional(Go),reason:f.optional(f.string())}),Jo=f.object({algorithm:f.literal(`p256`),privateKeyHex:Ko,publicKeyHex:Go,registration:qo}),Yo=f.object({version:f.literal(`signer-1`),signer:Jo}),Xo=f.object({version:f.literal(1),refreshToken:f.pipe(f.string(),f.minLength(1)),sessionToken:f.pipe(f.string(),f.minLength(1)),expiresAt:f.pipe(f.string(),f.isoTimestamp())}),Zo=f.object({version:f.literal(2),refreshToken:f.pipe(f.string(),f.minLength(1)),sessionToken:f.pipe(f.string(),f.minLength(1)),expiresAt:f.pipe(f.string(),f.isoTimestamp()),signer:Jo}),Qo=f.object({version:f.literal(3),signer:Jo}),$o=f.variant(`version`,[Xo,Zo,Qo]),es=f.variant(`version`,[Yo,Xo,Zo,Qo]);function ts(e){return f.parse($o,e)}function ns(e){return f.parse(es,e)}function rs(e){let t=f.safeParse(es,e);return t.success?t.output:null}function is(e){return{version:`signer-1`,signer:{algorithm:e.algorithm,privateKeyHex:e.privateKeyHex,publicKeyHex:e.publicKeyHex,registration:{status:`not_applicable`,reason:`pending_claim`}}}}function as(e,t){try{return ns(JSON.parse(e))}catch(e){throw Error(`${t} credential has an unsupported format`,{cause:e})}}function os(e){return ts({version:3,signer:e})}function ss(e){return JSON.stringify(e)}function cs(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ls(e){return(t,n)=>us(e,t,n)}function us(e,t,n){return new Promise((r,i)=>{let a=b(e,[...t],{stdio:[`pipe`,`pipe`,`pipe`]}),o=[],s=[],c=!1,l=!1,u=null,d=null,f=null,p=e=>{c||(c=!0,d!==null&&clearTimeout(d),f!==null&&clearTimeout(f),r(e))},m=e=>{c||(c=!0,d!==null&&clearTimeout(d),f!==null&&clearTimeout(f),i(e))};d=setTimeout(()=>{l=!0,a.kill(`SIGTERM`),f=setTimeout(()=>{a.kill(`SIGKILL`),p({stdout:o.join(``),stderr:s.join(``),status:124})},1e3)},3e4),a.stdout.setEncoding(`utf8`),a.stderr.setEncoding(`utf8`),a.stdout.on(`data`,e=>o.push(e)),a.stderr.on(`data`,e=>s.push(e)),a.on(`error`,t=>{m(Error(`Unable to run ${e}: ${t.message}`))}),a.on(`close`,t=>{if(u!==null&&t===0){m(Error(`Unable to write to ${e} stdin: ${u.message}`));return}p({stdout:o.join(``),stderr:s.join(``),status:l?124:t})}),a.stdin.on(`error`,e=>{u=e});try{a.stdin.end(n)}catch(t){m(t instanceof Error?Error(`Unable to write to ${e} stdin: ${t.message}`):Error(`Unable to write to ${e} stdin`))}})}const ds=`catena-agent`;function fs(e){if(!G.test(e))throw Error(`Invalid credential location for credential storage: "${e}"`);return e}const ps=ls(`/usr/bin/secret-tool`);function ms(e){return e.status===1&&e.stdout===``&&e.stderr.trim()===``}function hs(e,t){if(t.status===0)return;let n=gs(t);throw Error(`Linux Secret Service credential ${e} failed (secret-tool exited ${t.status??`without status`}): ${n}`)}function gs(e){let t=e.stderr.toLowerCase();return e.status===124?`secret service operation timed out`:t.includes(`cannot autolaunch`)||t.includes(`dbus`)||t.includes(`d-bus`)||t.includes(`org.freedesktop.secrets`)?`secret service session is unavailable`:/\blocked\b/.test(t)?`secret service keyring appears to be locked`:t.includes(`authorization`)||t.includes(`denied`)||t.includes(`not authorized`)?`secret service authorization was denied`:`secret service operation failed; ensure the Secret Service session is available and unlocked`}function _s(e){return e instanceof Error?e.message.includes(`ENOENT`)?Error(`Linux Secret Service credential operation failed: /usr/bin/secret-tool was not found. Install libsecret-tools and ensure a Secret Service keyring is available.`,{cause:e}):e:Error(String(e))}var vs=class{runSecretTool;constructor(e={}){if((e.platform??process.platform)!==`linux`)throw Error(`Linux Secret Service credential storage is only supported on Linux`);this.runSecretTool=e.runSecretTool??ps}async save(e,t){let n=ns(t),r=fs(e);if(await this.savePassword(r,ss(n)),!cs(await this.resolveDirectPassword(r),n))throw Error(`Linux Secret Service credential save verification failed`)}async resolve(e){return this.resolveDirectPassword(fs(e))}async delete(e){await this.deletePassword(fs(e))}async savePassword(e,t){hs(`save`,await this.runSecretToolCommand([`store`,`--label`,`${ds} ${e}`,`app`,ds,`account`,e],t))}async resolvePassword(e){let t=await this.runSecretToolCommand([`lookup`,`app`,ds,`account`,e]);return ms(t)?null:(hs(`resolve`,t),t.stdout.replace(/\r?\n$/,``))}async resolveDirectPassword(e){let t=await this.resolvePassword(e);return t===null?null:as(t,`Linux Secret Service`)}async deletePassword(e){let t=await this.runSecretToolCommand([`clear`,`app`,ds,`account`,e]);ms(t)||hs(`delete`,t)}async runSecretToolCommand(e,t){try{return await this.runSecretTool(e,t)}catch(e){throw _s(e)}}};const ys=ls(`/usr/bin/security`),bs=f.object({version:f.literal(1),encoding:f.literal(`base64-json`),chunks:f.pipe(f.number(),f.integer(),f.minValue(1),f.maxValue(64)),sha256:f.pipe(f.string(),f.regex(/^[a-f0-9]{64}$/))});function xs(e){return e.status===44}function Ss(e,t){return`${e}:chunk:${t}`}function Cs(e){let t=JSON.parse(e),n=rs(t);if(n!==null)return{kind:`direct`,payload:n};let r=f.safeParse(bs,t);if(r.success)return{kind:`legacy`,manifest:r.output};throw Error(`macOS Keychain credential has an unsupported format`)}function ws(e,t){if(t.status===0)return;let n=Ts(t);throw Error(`macOS Keychain credential ${e} failed (security exited ${t.status??`without status`})${n===null?``:`: ${n}`}`)}function Ts(e){let t=e.stderr.toLowerCase();return e.status===124?`keychain operation timed out`:t.includes(`stdin isn't a terminal`)?`parent process has no terminal`:t.includes(`user interaction is not allowed`)?`keychain user interaction is not allowed`:t.includes(`authorization`)||t.includes(`denied`)?`keychain authorization was denied`:t.includes(`locked`)?`keychain appears to be locked`:null}function Es(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)throw Error(`macOS Keychain credential values cannot contain control characters`)}return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Ds(e,t){return[`add-generic-password`,`-s`,Es(ds),`-a`,Es(e),`-w`,Es(t),`-U`].join(` `)+`
137
- `}var Os=class{runSecurity;constructor(e={}){if((e.platform??process.platform)!==`darwin`)throw Error(`macOS Keychain credential storage is only supported on macOS`);this.runSecurity=e.runSecurity??ys}async save(e,t){let n=ns(t),r=fs(e),i=await this.resolveLegacyChunkCount(r,64);if(await this.savePassword(r,ss(n)),!cs(await this.resolveDirectPassword(r),n))throw Error(`macOS Keychain credential save verification failed`);await this.deleteChunks(r,i)}async resolve(e){let t=fs(e),n=await this.resolveKeychainItem(t);return n===null?null:n.kind===`direct`?n.payload:this.resolveLegacyPayload(t,n.manifest)}async delete(e){let t=fs(e),n=await this.resolveLegacyChunkCount(t,64);await this.deleteChunks(t,n),await this.deletePassword(t)}async savePassword(e,t){ws(`save`,await this.runSecurity([`-i`],Ds(e,t)))}async resolvePassword(e){let t=await this.runSecurity([`find-generic-password`,`-a`,e,`-s`,ds,`-w`]);return xs(t)?null:(ws(`resolve`,t),t.stdout.replace(/\r?\n$/,``))}async resolveKeychainItem(e){let t=await this.resolvePassword(e);return t===null?null:Cs(t)}async resolveDirectPassword(e){let t=await this.resolveKeychainItem(e);if(t===null)return null;if(t.kind!==`direct`)throw Error(`macOS Keychain credential direct verification failed`);return t.payload}async resolveLegacyPayload(e,t){let n=[];for(let r=0;r<t.chunks;r++){let t=await this.resolvePassword(Ss(e,r));if(t===null)throw Error(`macOS Keychain credential chunk is missing`);n.push(t)}let r=n.join(``);if(h(`sha256`).update(r).digest(`hex`)!==t.sha256)throw Error(`macOS Keychain credential checksum mismatch`);return ns(JSON.parse(Buffer.from(r,`base64`).toString(`utf8`)))}async resolveLegacyChunkCount(e,t){let n=await this.resolvePassword(e);if(n===null)return 0;try{let e=Cs(n);return e.kind===`legacy`?e.manifest.chunks:0}catch{return t}}async deleteChunks(e,t){for(let n=0;n<t;n++)await this.deletePassword(Ss(e,n))}async deletePassword(e){let t=await this.runSecurity([`delete-generic-password`,`-a`,e,`-s`,ds]);xs(t)||ws(`delete`,t)}};function ks(e={}){let t=e.platform??process.platform;if(t===`darwin`)return new Os({platform:t});if(t===`linux`)return new vs({platform:t});throw Error(`Catena credential storage is only supported on macOS and Linux`)}const As=/^127(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/;function js(e){let t=e.replace(/^\[|\]$/g,``);return t===`localhost`||t===`::1`||As.test(t)}function Ms(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`||t.protocol===`http:`&&js(t.hostname)}function Ns(e,t){if(!Ms(e))throw Error(`${t} must be an https:// URL (http:// is allowed only for a loopback host): "${e}"`)}const Ps=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/,Fs=f.object({status:f.optional(f.literal(`linked`),`linked`),bank_url:f.pipe(f.string(),f.minLength(1)),agent_id:f.pipe(f.string(),f.minLength(1)),client_instance_id:f.pipe(f.string(),f.regex(G))}),Is=f.object({status:f.literal(`pending_connection`),bank_url:f.pipe(f.string(),f.minLength(1)),client_instance_id:f.pipe(f.string(),f.regex(G)),created_at:f.pipe(f.string(),f.isoTimestamp())}),Ls=f.variant(`status`,[Fs,Is]);f.object({version:f.literal(1),default_profile:f.optional(f.string()),profiles:f.record(f.string(),Ls),directories:f.optional(f.record(f.string(),f.string()))});const Rs=f.object({version:f.literal(1),default_profile:f.optional(f.string()),profiles:f.record(f.string(),f.unknown()),directories:f.optional(f.record(f.string(),f.unknown()))});function zs(){return te(process.env.HOME??M(),`.catena`)}function Bs(){return te(zs(),`profiles.json`)}function Vs(e){return Ps.test(e)}function Hs(e){if(!Vs(e))throw Error(`invalid profile name "${e}" (expected [a-zA-Z0-9][a-zA-Z0-9._-]{0,63})`)}function Us(e){return typeof e!=`object`||!e||!(`code`in e)?!1:typeof e.code==`string`}function Ws(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`profiles.json is not valid JSON: ${se(e)}`,{cause:e})}if(typeof n==`object`&&n&&`version`in n){let e=n;if(e.version!==1)throw Error(`profiles.json version ${String(e.version)} is not supported (expected 1)`)}let r=f.parse(Rs,n),i={};for(let[e,n]of Object.entries(r.profiles)){if(!Vs(e)){t?.(`profiles: dropping invalid profile name "${e}"`);continue}let r=f.safeParse(Ls,n);if(!r.success){t?.(`profiles: dropping malformed profile "${e}"`);continue}i[e]=r.output}if(r.default_profile!==void 0&&(Hs(r.default_profile),!Object.hasOwn(i,r.default_profile)))throw Error(`profiles.json default_profile "${r.default_profile}" is not linked`);let a={};for(let[e,n]of Object.entries(r.directories??{})){if(!ee(e)){t?.(`profiles: dropping directory binding with relative path "${e}"`);continue}if(typeof n!=`string`||!Vs(n)){t?.(`profiles: dropping malformed directory binding "${e}"`);continue}a[e]=n}return{version:1,...r.default_profile===void 0?{}:{default_profile:r.default_profile},profiles:i,...Object.keys(a).length===0?{}:{directories:a}}}function Gs(e){try{return Ws(E(Bs(),`utf-8`),e)}catch(e){if(e instanceof Error&&Us(e)&&e.code===`ENOENT`)return{version:1,profiles:{}};throw e}}function Ks(){T(zs(),{recursive:!0,mode:448}),S(zs(),448)}function qs(e){Ks();let t=Bs(),n=`${t}.${_(6).toString(`hex`)}.tmp`;j(n,JSON.stringify(e,null,2)+`
138
- `,{encoding:`utf-8`,mode:384}),O(n,t)}function Js(e,t){Hs(e);let n=f.parse(Ls,t);Ns(n.bank_url,`profile "${e}" bank_url`);let r=Gs();qs({...r,profiles:{...r.profiles,[e]:n}})}function Ys(e){return e.status===`linked`}function Xs(e,t){return e.replace(/\/+$/,``)===t.replace(/\/+$/,``)}function Zs(e,t){let n=Object.entries(Gs().profiles).toSorted(([e],[t])=>e.localeCompare(t)).find(([,n])=>Ys(n)&&n.agent_id===e&&Xs(n.bank_url,t));return n===void 0?null:n[0]}function Qs(e,t){let n=Object.fromEntries(Object.entries(e??{}).filter(([,e])=>t(e)));return Object.keys(n).length===0?{}:{directories:n}}function $s(e){Hs(e);let t=Gs(),{[e]:n,...r}=t.profiles;qs({version:1,...t.default_profile===e||t.default_profile===void 0?{}:{default_profile:t.default_profile},profiles:r,...Qs(t.directories,t=>t!==e)})}function ec(e){try{return D(ne(e))}catch{return ne(e)}}function tc(e){return Gs().directories?.[ec(e)]??null}function nc(e,t){Hs(t);let n=Gs();if(!Object.hasOwn(n.profiles,t))throw Error(`Profile "${t}" is not linked. Run catena link --profile ${t} <agent-id>.`);let r=ec(e);return qs({...n,directories:{...n.directories,[r]:t}}),r}function rc(e){let t=Gs(),n=ec(e);if(t.directories===void 0||!Object.hasOwn(t.directories,n))return{directory:n,removed:!1};let{[n]:r,...i}=t.directories,{directories:a,...o}=t;return qs({...o,...Object.keys(i).length===0?{}:{directories:i}}),{directory:n,removed:!0}}function ic(e){return Hs(e),Gs().profiles[e]??null}function ac(){return`client_${_(16).toString(`hex`)}`}function oc(e,t){let n=ic(e);return t.agent_id===void 0?sc(e,t.bank_url,n):cc(e,t.bank_url,t.agent_id,n)}function sc(e,t,n){if(n?.status===`linked`)throw Error(`Profile "${e}" is already linked. Choose a different profile name to start agent connection.`);let r=(n?.status===`pending_connection`&&Xs(n.bank_url,t)?n.client_instance_id:null)??ac();return Js(e,{status:`pending_connection`,bank_url:t,client_instance_id:r,created_at:n?.status===`pending_connection`?n.created_at:new Date().toISOString()}),r}function cc(e,t,n,r){if(r?.status===`linked`){if(r.agent_id!==n)throw Error(`Profile "${e}" is already linked to a different agent (${r.agent_id}). Link ${n} under a different --profile, or run 'catena unlink --profile ${e}' first to repoint it (add --force if that agent's credential is missing or revoked).`);if(!Xs(r.bank_url,t))throw Error(`Profile "${e}" is already linked to this agent on a different bank (${r.bank_url}). Link under a different --profile, or run 'catena unlink --profile ${e}' first (add --force if that credential is missing or revoked).`);return r.client_instance_id}let i=(r?.status===`pending_connection`&&Xs(r.bank_url,t)?r.client_instance_id:null)??ac();return Js(e,{status:`linked`,bank_url:t,agent_id:n,client_instance_id:i}),i}function lc(e){Hs(e);let t=Gs();if(!Object.hasOwn(t.profiles,e))throw Error(`Profile "${e}" is not linked. Run catena link --profile ${e} <agent-id>.`);qs({...t,default_profile:e})}function uc(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[^a-z0-9]+/,``).slice(0,64);return Vs(t)?t:`agent`}function dc(e,t){if(!t(e))return e;for(let n=2;;n++){let r=`${e.slice(0,64-String(n).length-1)}-${n}`;if(!t(r))return r}}function fc(e){Hs(e.reservationName),Hs(e.profileName);let t=f.parse(Ls,e.profile);Ns(t.bank_url,`profile "${e.profileName}" bank_url`);let n=Gs(),{[e.reservationName]:r,...i}=n.profiles;if(!Object.hasOwn(n.profiles,e.reservationName)||r.client_instance_id!==t.client_instance_id)throw Error(`Link reservation "${e.reservationName}" changed during setup (a concurrent link from this directory?). Re-run 'catena link'.`);if(e.profileName!==e.reservationName&&Object.hasOwn(i,e.profileName))throw Error(`Profile "${e.profileName}" already exists; cannot finalize link under that name.`);let a=Object.fromEntries(Object.entries(n.directories??{}).map(([t,n])=>[t,n===e.reservationName?e.profileName:n]));qs({version:1,...n.default_profile===void 0?{}:{default_profile:n.default_profile===e.reservationName?e.profileName:n.default_profile},profiles:{...i,[e.profileName]:t},...Object.keys(a).length===0?{}:{directories:a}})}function pc(e){return e??ks()}async function mc(e,t){let n;try{n=ic(e.profileName)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:se(t)}}if(n===null)return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:`Profile "${e.profileName}" is not linked. Run 'catena link --profile ${e.profileName}' to authenticate.`};try{Ns(n.bank_url,`profile "${e.profileName}" bank_url`)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:se(t)}}if(n.status===`pending_connection`)return{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" is waiting for agent connection approval. Run 'catena link --profile ${e.profileName}' to finish setup.`};let r;try{r=await pc(t).resolve(n.client_instance_id)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential unavailable for ${n.agent_id}: ${se(t)}. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}}return r===null||r.version===`signer-1`?{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential unavailable for ${n.agent_id}. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}:r.version===1?{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential for ${n.agent_id} has no signing key. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}:{ok:!0,profileName:e.profileName,bankUrl:n.bank_url,agentId:n.agent_id,clientInstanceId:n.client_instance_id,signer:r.signer}}const hc={name:`catena-cli`,version:oe},gc=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function _c(e,t){if(!gc.test(e))throw Error(`${t} must be a valid HTTP token`)}function vc(e,t){let n=!1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r<32||r===127||r>255){n=!0;break}}if(n||/[()\\]/.test(e))throw Error(`${t} must not contain parentheses, backslashes, control characters, or characters outside Latin-1`)}function yc(e){_c(e.name,`appInfo.name`),e.version!==void 0&&_c(e.version,`appInfo.version`),e.url!==void 0&&vc(e.url,`appInfo.url`);let t=e.version===void 0?e.name:`${e.name}/${e.version}`;return{"User-Agent":e.url===void 0?t:`${t} (${e.url})`}}const bc=`https://api.catena.com`,xc=`CATENA_PROFILE`;function Sc(e,t,n,r){if(e.directories===void 0)return null;let i;try{i=D(t)}catch{return null}let a=Object.entries(e.directories).map(([e,t])=>[e.replace(/\/+$/,``)||`/`,t]).filter(([e])=>i===e||i.startsWith(e===`/`?`/`:`${e}/`)).toSorted(([e],[t])=>t.length-e.length),o=null;for(let[t,n]of a){if(Object.hasOwn(e.profiles,n))return n;o??=`${t} -> "${n}"`}if(o===null)return null;if(n===`error`)throw Error(`This directory is bound to a profile that no longer exists (${o}). Run 'catena profiles unbind' here, bind it with 'catena profiles bind <name>', or run 'catena link' to re-establish it.`);return r?.(`profiles: ignoring stale directory binding ${o}`),null}function Cc(e,t,n){if(e.flag!==void 0&&e.flag.length>0)return Hs(e.flag),{name:e.flag,source:`flag`};if(e.env!==void 0&&e.env.length>0){if(!Vs(e.env))throw Error(`${xc} is set to an invalid profile name "${e.env}"`);return{name:e.env,source:`env`}}if(e.cwd!==void 0){let r=Sc(t,e.cwd,n,e.log);if(r!==null)return{name:r,source:`directory`}}return t.default_profile===void 0?null:{name:t.default_profile,source:`default`}}function wc(e){return Cc(e,Gs(e.log),`ignore`)}function Tc(e){let t=Gs(e.log),n=Cc(e,t,`error`);if(n!==null)return n;let r=Object.keys(t.profiles),i=Object.entries(t.profiles).filter(([,e])=>Ys(e)).map(([e])=>e);if(i.length===1){let[e]=i;return{name:e,source:`single`}}if(i.length===0){if(r.length===1){let[e]=r;return{name:e,source:`single`}}return r.length>1&&e.log?.(`profiles: ignoring ${r.length} pending profiles (${r.toSorted().join(`, `)}); none is linked`),{name:`default`,source:`fallback`}}throw Error(`Multiple profiles exist and none is selected (${i.toSorted().join(`, `)}). Pass --profile <name>, set ${xc}, run 'catena profiles use <name>', or run 'catena link' from an agent directory to bind it.`)}function Ec(e){return Uo({baseUrl:e.bankUrl,privateKeyHex:e.signer.privateKeyHex,appInfo:hc})}function Dc(){return ks()}async function Oc(e){let t;try{t=Tc({flag:e,env:process.env[xc],cwd:process.cwd(),log:e=>console.error(e)}).name}catch(e){return I(e)}let n=await mc({profileName:t,fallbackBankUrl:bc},void 0);return n.ok||I(n.message),Ec(n)}const kc=new Set([`unknown_key`,`key_revoked`,`client_unlinked`]),Ac=new Set([`signature_auth_disabled`,`missing_auth`]);function jc(e,t){if(!(e instanceof Fo)||e.code===void 0)return e;let n=t===void 0?`catena link`:`catena link --profile ${t}`;return kc.has(e.code)?Error(`This machine's signing key was rejected by the bank (${e.code}). Run '${n}' to re-authenticate.`):e.code===`client_upgrade_required`?Error(`This CLI version (${hc.version}) is no longer supported by the bank. Run 'npm i -g @catena/cli' and retry.`):Ac.has(e.code)?Error(`This bank does not support key-based authentication (${e.code}). Upgrade the bank, or use an older CLI release that authenticates with session tokens.`):e.code===`invalid_signature`&&e.message.includes(`created_out_of_window`)?Error(`The bank rejected this request's timestamp (created_out_of_window). Check this machine's system clock and retry.`):e}function Mc(e,t){console.log(t?.compact?JSON.stringify(e):JSON.stringify(e,null,2))}function Nc(e){return e.profile===void 0||e.profile.length===0?void 0:e.profile}async function Pc(e,t){try{return await t(await Oc(e))}catch(t){return I(jc(t,e))}}function Fc(e,t){return async(n,r)=>{let i=await Pc(e,n);return Mc(i,t),await new Promise(e=>{process.stdout.write(``,()=>e())}),process.exit(r?.exitCode?r.exitCode(i):0)}}function Ic(e){return Fc(Nc(e),{compact:e.json===!0})}const Lc=f.pipe(f.string(),f.regex(/^\d+$/,`must be a non-negative integer`),f.transform(Number),f.maxValue(2**53-1,`must be at most ${2**53-1}`)),Rc=f.pipe(Lc,f.maxValue(200,`must be at most 200`)),zc={profile:Se,json:Ce},Bc=W(zc),Vc=W({account:pe({description:`Account id`,required:!0,schema:we}),...zc}),Hc=W({account:pe({description:`Account id`,required:!0,schema:we}),start:z({description:`Only include transactions at or after this ISO 8601 time`}),end:z({description:`Only include transactions at or before this ISO 8601 time`}),limit:z({description:`Maximum transactions to return (default 50, max 200)`,schema:Rc}),offset:z({description:`Number of transactions to skip for pagination`,schema:Lc}),...zc}),Uc=W({account:pe({description:`Account id`,required:!0,schema:we}),network:ke({description:`Deposit network; defaults to ${De}. Availability depends on the connected environment.`,default:De}),asset:V({description:`Deposit asset (${Ee.join(`|`)})`,choices:Ee,default:`usdc`}),...zc}),Wc=l({meta:{name:`list`,description:`List accounts accessible under the agent's policy`},args:Bc.args,async run({args:e}){await Ic(Bc.parse(e))(e=>e.listAccounts())}}),Gc=l({meta:{name:`balance`,description:`Request an account balance through the policy engine`},args:Vc.args,async run({args:e}){let t=Vc.parse(e);await Ic(t)(e=>e.getAccountBalance(t.account))}}),Kc=l({meta:{name:`transactions`,description:`Read an account's transaction history through the policy engine`},args:Hc.args,async run({args:e}){let t=Hc.parse(e);await Ic(t)(e=>e.listAccountTransactions(t.account,{start:t.start,end:t.end,limit:t.limit,offset:t.offset}))}}),qc=l({meta:{name:`deposit-address`,description:`Read an account deposit address through the policy engine`},args:Uc.args,async run({args:e}){let t=Uc.parse(e);await Ic(t)(e=>e.getAccountDepositAddress(t.account,{network:t.network,asset:t.asset}))}}),Jc=l({meta:{name:`accounts`,description:`Inspect bank accounts`},subCommands:{list:Wc,balance:Gc,transactions:Kc,"deposit-address":qc}}),Yc=f.pipe(f.string(),f.minLength(1,`must not be empty`)),Xc=f.pipe(f.string(),f.trim(),f.email(`must be a valid email address`)),Zc={profile:Se,json:Ce},Qc=W({address:z({description:`Only counterparties with a wallet rail matching this address (0x…)`,schema:Oe}),network:ke({description:`Only counterparties with a wallet rail on this network (e.g. base)`}),...Zc}),$c=z({description:`Counterparty name`,required:!0,schema:Yc}),el=z({description:`Optional contact email`,schema:Xc}),tl=W({name:$c,email:z({description:`Contact email; creating the counterparty sends no email`,required:!0,schema:Xc}),...Zc}),nl=W({name:z({description:`Counterparty name; required without a subcommand`,schema:Yc}),email:z({description:`Contact email; required without a subcommand; creating the counterparty sends no email`,schema:Xc}),...Zc}),rl=W({name:$c,"bank-name":z({description:`Receiving bank name`,required:!0,schema:Yc}),"routing-number":z({description:`9-digit ABA routing number`,required:!0,schema:Yc}),"account-number":z({description:`Receiving bank account number`,required:!0,schema:Yc}),"account-type":V({description:`checking | savings (default checking)`,choices:[`checking`,`savings`]}),"address-street":z({description:`Street address of the receiving bank account holder`,required:!0,schema:Yc}),"address-city":z({description:`City`,required:!0,schema:Yc}),"address-state":z({description:`State (e.g. NY)`,required:!0,schema:Yc}),"address-postal-code":z({description:`Postal code`,required:!0,schema:Yc}),"address-country":z({description:`Default USA`}),email:el,...Zc}),il=W({name:$c,address:z({description:`Wallet address (0x… or ENS name on EVM networks)`,required:!0,schema:Yc}),network:ke({description:`Wallet network; defaults to ${De}. Availability depends on the connected environment.`,default:De}),email:el,...Zc}),al=l({meta:{name:`list`,description:`List counterparties available under the agent's policy`},args:Qc.args,async run({args:e}){let t=Qc.parse(e);await Ic(t)(e=>e.listCounterparties({address:t.address,network:t.network}))}});function ol(e){return e&&e.length>0?e:void 0}function sl(e){let t=ol(e.email);return{type:`create_counterparty`,name:e.name,email:t,rail:{type:`bank`,bankName:e[`bank-name`],routingNumber:e[`routing-number`],accountNumber:e[`account-number`],addressStreet:e[`address-street`],addressCity:e[`address-city`],addressState:e[`address-state`],addressPostalCode:e[`address-postal-code`],...e[`account-type`]?{accountType:e[`account-type`]}:{},...e[`address-country`]?{addressCountry:e[`address-country`]}:{}}}}function cl(e){let t=ol(e.email);return{type:`create_counterparty`,name:e.name,email:t,rail:{type:`wallet`,walletAddress:e.address,network:e.network}}}function ll(e){return{type:`create_counterparty`,name:e.name,email:e.email}}const ul=l({meta:{name:`email`,description:`Create a counterparty with an email and no payment details. Sends no email.`},args:tl.args,async run({args:e}){let t=tl.parse(e);await Ic(t)(e=>e.submitIntent({action:ll(t)}))}}),dl=l({meta:{name:`bank`,description:`Request bank counterparty creation through the policy engine. Prints an intent envelope.`},args:rl.args,async run({args:e}){let t=rl.parse(e),n=sl(t);await Ic(t)(e=>e.submitIntent({action:n}))}}),fl=l({meta:{name:`wallet`,description:`Request wallet counterparty creation through the policy engine. Prints an intent envelope.`},args:il.args,async run({args:e}){let t=il.parse(e);await Ic(t)(e=>e.submitIntent({action:cl(t)}))}}),pl=l({meta:{name:`create`,description:`Request counterparty creation through the policy engine. Without a subcommand, --name and --email create a record without payment details and send no email.`},args:nl.args,default:`email`,subCommands:{email:ul,bank:dl,wallet:fl}}),ml=l({meta:{name:`counterparties`,description:`Inspect and create counterparties`},subCommands:{list:al,create:pl}}),hl=4e3;async function gl(){process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}async function _l(e){return e===void 0?(process.stdin.isTTY&&I(`<message>: pass a quoted message or pipe it on stdin; a message starting with "-" needs -- before it (catena feedback -- "<message>") or stdin`),gl()):e}const vl=W({message:pe({description:`Plain-text feedback (1-4000 chars); omit to pipe on stdin`}),profile:Se,json:Ce}),yl=l({meta:{name:`feedback`,description:`Send free-form feedback about Catena to the Catena team`},args:vl.args,async run({args:e}){(Array.isArray(e._)?e._:[]).length>1&&I(`<message>: pass the message as a single quoted argument`);let t=vl.parse(e),n=(await _l(t.message)).trim();n.length===0&&I(`<message>: must not be empty`),n.length>hl&&I(`<message>: must be at most ${hl} characters (got: ${n.length})`),await Ic(t)(async e=>(await e.submitFeedback(n),{ok:!0}))}});function bl(e){return`# Catena CLI Agent Guide
134
+ `)}};W.CertificateTag=`CERTIFICATE`,W.CrlTag=`CRL`,W.CertificateRequestTag=`CERTIFICATE REQUEST`,W.PublicKeyTag=`PUBLIC KEY`,W.PrivateKeyTag=`PRIVATE KEY`;var G=class e extends xe{static isAsnEncoded(e){return i.BufferSourceConverter.isBufferSource(e)||typeof e==`string`}static toArrayBuffer(e){if(typeof e==`string`){if(W.isPem(e))return W.decode(e)[0];if(i.Convert.isHex(e))return i.Convert.FromHex(e);if(i.Convert.isBase64(e))return i.Convert.FromBase64(e);if(i.Convert.isBase64Url(e))return i.Convert.FromBase64Url(e);throw TypeError(`Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url`)}{let t=i.Convert.ToBinary(e);return W.isPem(t)?W.decode(t)[0]:i.Convert.isHex(t)?i.Convert.FromHex(t):i.Convert.isBase64(t)?i.Convert.FromBase64(t):i.Convert.isBase64Url(t)?i.Convert.FromBase64Url(t):i.BufferSourceConverter.toArrayBuffer(e)}}constructor(...t){e.isAsnEncoded(t[0])?super(e.toArrayBuffer(t[0]),t[1]):super(t[0])}toString(e=`pem`){switch(e){case`pem`:return W.encode(this.rawData,this.tag);default:return super.toString(e)}}},Be=class e extends G{static async create(t,n=B.get()){if(t instanceof e)return t;if(Ce.isCryptoKey(t)){if(t.type!==`public`)throw TypeError(`Public key is required`);let r=await n.subtle.exportKey(`spki`,t);return new e(r)}if(t.publicKey)return t.publicKey;if(i.BufferSourceConverter.isBufferSource(t))return new e(t);throw TypeError(`Unsupported PublicKeyType`)}constructor(e){G.isAsnEncoded(e)?super(e,r.SubjectPublicKeyInfo):super(e),this.tag=W.PublicKeyTag}async export(...e){let t,i=[`verify`],a={hash:`SHA-256`,...this.algorithm};e.length>1?(a=e[0]||a,i=e[1]||i,t=e[2]||B.get()):t=e[0]||B.get();let o=this.rawData,c=n.AsnConvert.parse(this.rawData,r.SubjectPublicKeyInfo);return c.algorithm.algorithm===s.id_RSASSA_PSS&&(o=Ve(c,o)),t.subtle.importKey(`spki`,o,a,!0,i)}onInit(e){let t=l.container.resolve(b),r=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case s.id_rsaEncryption:{let t=n.AsnConvert.parse(e.subjectPublicKey,s.RSAPublicKey),a=i.BufferSourceConverter.toUint8Array(t.modulus);r.publicExponent=i.BufferSourceConverter.toUint8Array(t.publicExponent),r.modulusLength=(a[0]?a:a.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||B.get()):t=e[0]||B.get(),await t.subtle.digest(n,this.rawData)}async getKeyIdentifier(...e){let t,i=`SHA-1`;e.length===1?typeof e[0]==`string`?(i=e[0],t=B.get()):t=e[0]:e.length===2?(i=e[0],t=e[1]):t=B.get();let a=n.AsnConvert.parse(this.rawData,r.SubjectPublicKeyInfo);return await t.subtle.digest(i,a.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),t=n.AsnConvert.parse(this.rawData,r.SubjectPublicKeyInfo);switch(e.Algorithm=be.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case o.id_ecPublicKey:e[`EC Point`]=t.subjectPublicKey;break;case s.id_rsaEncryption:default:e[`Raw Data`]=t.subjectPublicKey}return e}};function Ve(e,t){return e.algorithm=new r.AlgorithmIdentifier({algorithm:s.id_rsaEncryption,parameters:null}),t=n.AsnConvert.serialize(e),t}var He=class e extends z{static async create(t,n=!1,r=B.get()){if(`name`in t&&`serialNumber`in t)return new e(t,n);let a=await(await Be.create(t,r)).getKeyIdentifier(r);return new e(i.Convert.ToHex(a),n)}constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]==`string`){let t=new p.AuthorityKeyIdentifier({keyIdentifier:new p.KeyIdentifier(i.Convert.FromHex(e[0]))});super(p.id_ce_authorityKeyIdentifier,e[1],n.AsnConvert.serialize(t))}else{let t=e[0],r=t.name instanceof Re?n.AsnConvert.parse(t.name.rawData,p.GeneralNames):t.name,a=new p.AuthorityKeyIdentifier({authorityCertIssuer:r,authorityCertSerialNumber:i.Convert.FromHex(t.serialNumber)});super(p.id_ce_authorityKeyIdentifier,e[1],n.AsnConvert.serialize(a))}}onInit(e){super.onInit(e);let t=n.AsnConvert.parse(e.extnValue,p.AuthorityKeyIdentifier);t.keyIdentifier&&(this.keyId=i.Convert.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?i.Convert.ToHex(t.authorityCertSerialNumber):``})}toTextObject(){let e=this.toTextObjectWithoutValue(),t=n.AsnConvert.parse(this.value,p.AuthorityKeyIdentifier);return t.authorityCertIssuer&&(e[`Authority Issuer`]=new Re(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e[`Authority Serial Number`]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[``]=t.keyIdentifier),e}};He.NAME=`Authority Key Identifier`;var Ue=class extends z{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,r.BasicConstraints);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{let t=new r.BasicConstraints({cA:e[0],pathLenConstraint:e[1]});super(r.id_ce_basicConstraints,e[2],n.AsnConvert.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e[`Path Length`]=this.pathLength),e}};Ue.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||={});var We=class extends z{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,p.ExtendedKeyUsage);this.usages=t.map(e=>e)}else{let t=new p.ExtendedKeyUsage(e[0]);super(p.id_ce_extKeyUsage,e[1],n.AsnConvert.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.usages.map(e=>R.toString(e)).join(`, `),e}};We.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||={});var Ge=class extends z{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,r.KeyUsage);this.usages=t.toNumber()}else{let t=new r.KeyUsage(e[0]);super(r.id_ce_keyUsage,e[1],n.AsnConvert.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=n.AsnConvert.parse(this.value,r.KeyUsage).toJSON().join(`, `),e}};Ge.NAME=`Key Usages`;var Ke=class e extends z{static async create(t,n=!1,r=B.get()){let a=await(await Be.create(t,r)).getKeyIdentifier(r);return new e(i.Convert.ToHex(a),n)}constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,p.SubjectKeyIdentifier);this.keyId=i.Convert.ToHex(t)}else{let t=typeof e[0]==`string`?i.Convert.FromHex(e[0]):e[0],r=new p.SubjectKeyIdentifier(t);super(p.id_ce_subjectKeyIdentifier,e[1],n.AsnConvert.serialize(r)),this.keyId=i.Convert.ToHex(t)}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=n.AsnConvert.parse(this.value,p.SubjectKeyIdentifier),e}};Ke.NAME=`Subject Key Identifier`;var qe=class extends z{constructor(...e){i.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(p.id_ce_subjectAltName,e[1],new Re(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=n.AsnConvert.parse(e.extnValue,p.SubjectAlternativeName);this.names=new Re(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};qe.NAME=`Subject Alternative Name`;var Ye=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new z(e),n=this.items.get(t.type);return n?new n(e):t}};Ye.items=new Map;var Xe=class extends z{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=n.AsnConvert.parse(this.value,p.CertificatePolicies);this.policies=t.map(e=>e.policyIdentifier)}else{let t=e[0],r=e[1]??!1,i=new p.CertificatePolicies(t.map(e=>new p.PolicyInformation({policyIdentifier:e})));super(p.id_ce_certificatePolicies,r,n.AsnConvert.serialize(i)),this.policies=t}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(e=>new I(``,{},R.toString(e))),e}};Xe.NAME=`Certificate Policies`,Ye.register(p.id_ce_certificatePolicies,Xe);var Ze=class extends z{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]==`string`){let t=e[0].map(e=>new p.DistributionPoint({distributionPoint:new p.DistributionPointName({fullName:[new p.GeneralName({uniformResourceIdentifier:e})]})})),r=new p.CRLDistributionPoints(t);super(p.id_ce_cRLDistributionPoints,e[1],n.AsnConvert.serialize(r))}else{let t=new p.CRLDistributionPoints(e[0]);super(p.id_ce_cRLDistributionPoints,e[1],n.AsnConvert.serialize(t))}this.distributionPoints??=[]}onInit(e){super.onInit(e);let t=n.AsnConvert.parse(e.extnValue,p.CRLDistributionPoints);this.distributionPoints=t}toTextObject(){let e=this.toTextObjectWithoutValue();return e[`Distribution Point`]=this.distributionPoints.map(e=>{let t={};return e.distributionPoint&&(t[``]=e.distributionPoint.fullName?.map(e=>new Le(e).toString()).join(`, `)),e.reasons&&(t.Reasons=e.reasons.toString()),e.cRLIssuer&&(t[`CRL Issuer`]=e.cRLIssuer.map(e=>e.toString()).join(`, `)),t}),e}};Ze.NAME=`CRL Distribution Points`;var Qe=class extends z{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof p.AuthorityInfoAccessSyntax){let t=new p.AuthorityInfoAccessSyntax(e[0]);super(p.id_pe_authorityInfoAccess,e[1],n.AsnConvert.serialize(t))}else{let t=e[0],r=new p.AuthorityInfoAccessSyntax;et(r,t,p.id_ad_ocsp,`ocsp`),et(r,t,p.id_ad_caIssuers,`caIssuers`),et(r,t,p.id_ad_timeStamping,`timeStamping`),et(r,t,p.id_ad_caRepository,`caRepository`),super(p.id_pe_authorityInfoAccess,e[1],n.AsnConvert.serialize(r))}this.ocsp??=[],this.caIssuers??=[],this.timeStamping??=[],this.caRepository??=[]}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],n.AsnConvert.parse(e.extnValue,p.AuthorityInfoAccessSyntax).forEach(e=>{switch(e.accessMethod){case p.id_ad_ocsp:this.ocsp.push(new Le(e.accessLocation));break;case p.id_ad_caIssuers:this.caIssuers.push(new Le(e.accessLocation));break;case p.id_ad_timeStamping:this.timeStamping.push(new Le(e.accessLocation));break;case p.id_ad_caRepository:this.caRepository.push(new Le(e.accessLocation))}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&$e(e,`OCSP`,this.ocsp),this.caIssuers.length&&$e(e,`CA Issuers`,this.caIssuers),this.timeStamping.length&&$e(e,`Time Stamping`,this.timeStamping),this.caRepository.length&&$e(e,`CA Repository`,this.caRepository),e}};Qe.NAME=`Authority Info Access`;function $e(e,t,n){if(n.length===1)e[t]=n[0].toTextObject();else{let r=new I(``);n.forEach((e,t)=>{let n=e.toTextObject(),i=`${n[I.NAME]} ${t+1}`,a=r[i];Array.isArray(a)||(a=[],r[i]=a),a.push(n)}),e[t]=r}}function et(e,t,r,i){let a=t[i];a&&(Array.isArray(a)?a:[a]).forEach(t=>{typeof t==`string`&&(t=new Le(`url`,t)),e.push(new p.AccessDescription({accessMethod:r,accessLocation:n.AsnConvert.parse(t.rawData,p.GeneralName)}))})}var q=class e extends xe{constructor(...e){let t;if(i.BufferSourceConverter.isBufferSource(e[0]))t=i.BufferSourceConverter.toArrayBuffer(e[0]);else{let a=e[0],o=Array.isArray(e[1])?e[1].map(e=>i.BufferSourceConverter.toArrayBuffer(e)):[];t=n.AsnConvert.serialize(new r.Attribute({type:a,values:o}))}super(t,r.Attribute)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(e=>new I(``,{"":e})),e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty();return t[I.NAME]===e.NAME&&(t[I.NAME]=R.toString(this.type)),t}};q.NAME=`Attribute`;var tt=class extends q{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let t=new _.ChallengePassword({printableString:e[0]});super(_.id_pkcs9_at_challengePassword,[n.AsnConvert.serialize(t)])}this.password??=``}onInit(e){if(super.onInit(e),this.values[0]){let e=n.AsnConvert.parse(this.values[0],_.ChallengePassword);this.password=e.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[I.VALUE]=this.password,e}};tt.NAME=`Challenge Password`;var nt=class extends q{constructor(...e){if(i.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let t=e[0],r=new p.Extensions;for(let e of t)r.push(n.AsnConvert.parse(e.rawData,p.Extension));super(_.id_pkcs9_at_extensionRequest,[n.AsnConvert.serialize(r)])}this.items??=[]}onInit(e){if(super.onInit(e),this.values[0]){let e=n.AsnConvert.parse(this.values[0],p.Extensions);this.items=e.map(e=>Ye.create(n.AsnConvert.serialize(e)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.items.map(e=>e.toTextObject());for(let n of t)e[n[I.NAME]]=n;return e}};nt.NAME=`Extensions`;var rt=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new q(e),n=this.items.get(t.type);return n?new n(e):t}};rt.items=new Map;let it=`crypto.signatureFormatter`;var at=class{toAsnSignature(e,t){return i.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return i.BufferSourceConverter.toArrayBuffer(t)}},ot;e.RsaAlgorithm=ot=class{static createPssParams(e,t){let i=ot.getHashAlgorithm(e);return i?new g.RsaSaPssParams({hashAlgorithm:i,maskGenAlgorithm:new r.AlgorithmIdentifier({algorithm:g.id_mgf1,parameters:n.AsnConvert.serialize(i)}),saltLength:t}):null}static getHashAlgorithm(e){let t=l.container.resolve(b);return typeof e==`string`?t.toAsnAlgorithm({name:e}):typeof e==`object`&&e&&`name`in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`rsassa-pkcs1-v1_5`:if(`hash`in e){let t;if(typeof e.hash==`string`)t=e.hash;else if(e.hash&&typeof e.hash==`object`&&`name`in e.hash&&typeof e.hash.name==`string`)t=e.hash.name.toUpperCase();else throw Error(`Cannot get hash algorithm name`);switch(t.toLowerCase()){case`sha-1`:return new r.AlgorithmIdentifier({algorithm:g.id_sha1WithRSAEncryption,parameters:null});case`sha-256`:return new r.AlgorithmIdentifier({algorithm:g.id_sha256WithRSAEncryption,parameters:null});case`sha-384`:return new r.AlgorithmIdentifier({algorithm:g.id_sha384WithRSAEncryption,parameters:null});case`sha-512`:return new r.AlgorithmIdentifier({algorithm:g.id_sha512WithRSAEncryption,parameters:null})}}else return new r.AlgorithmIdentifier({algorithm:g.id_rsaEncryption,parameters:null});break;case`rsa-pss`:if(`hash`in e){if(!(`saltLength`in e&&typeof e.saltLength==`number`))throw Error(`Cannot get 'saltLength' from 'alg' argument`);let t=ot.createPssParams(e.hash,e.saltLength);if(!t)throw Error(`Cannot create PSS parameters`);return new r.AlgorithmIdentifier({algorithm:g.id_RSASSA_PSS,parameters:n.AsnConvert.serialize(t)})}return new r.AlgorithmIdentifier({algorithm:g.id_RSASSA_PSS,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case g.id_rsaEncryption:return{name:`RSASSA-PKCS1-v1_5`};case g.id_sha1WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-1`}};case g.id_sha256WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-256`}};case g.id_sha384WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-384`}};case g.id_sha512WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-512`}};case g.id_RSASSA_PSS:if(e.parameters){let t=n.AsnConvert.parse(e.parameters,g.RsaSaPssParams);return{name:`RSA-PSS`,hash:l.container.resolve(b).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}return{name:`RSA-PSS`}}return null}},e.RsaAlgorithm=ot=c.__decorate([l.injectable()],e.RsaAlgorithm),l.container.registerSingleton(v,e.RsaAlgorithm),e.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`sha-1`:return new r.AlgorithmIdentifier({algorithm:s.id_sha1});case`sha-256`:return new r.AlgorithmIdentifier({algorithm:s.id_sha256});case`sha-384`:return new r.AlgorithmIdentifier({algorithm:s.id_sha384});case`sha-512`:return new r.AlgorithmIdentifier({algorithm:s.id_sha512})}return null}toWebAlgorithm(e){switch(e.algorithm){case s.id_sha1:return{name:`SHA-1`};case s.id_sha256:return{name:`SHA-256`};case s.id_sha384:return{name:`SHA-384`};case s.id_sha512:return{name:`SHA-512`}}return null}},e.ShaAlgorithm=c.__decorate([l.injectable()],e.ShaAlgorithm),l.container.registerSingleton(v,e.ShaAlgorithm);var st=class e{addPadding(e,t){let n=i.BufferSourceConverter.toUint8Array(t),r=new Uint8Array(e);return r.set(n,e-n.length),r}removePadding(e,t=!1){let n=i.BufferSourceConverter.toUint8Array(e);for(let e=0;e<n.length;e++)if(n[e]){n=n.slice(e);break}if(t&&n[0]>127){let e=new Uint8Array(n.length+1);return e.set(n,1),e.buffer}return n.buffer}toAsnSignature(t,r){if(t.name===`ECDSA`){let a=t.namedCurve,s=e.namedCurveSize.get(a)||e.defaultNamedCurveSize,c=new o.ECDSASigValue,l=i.BufferSourceConverter.toUint8Array(r);return c.r=this.removePadding(l.slice(0,s),!0),c.s=this.removePadding(l.slice(s,s+s),!0),n.AsnConvert.serialize(c)}return null}toWebSignature(t,r){if(t.name===`ECDSA`){let a=n.AsnConvert.parse(r,o.ECDSASigValue),s=t.namedCurve,c=e.namedCurveSize.get(s)||e.defaultNamedCurveSize,l=this.addPadding(c,this.removePadding(a.r)),u=this.addPadding(c,this.removePadding(a.s));return i.combine(l,u)}return null}};st.namedCurveSize=new Map,st.defaultNamedCurveSize=32;let ct=`1.3.101.110`,lt=`1.3.101.111`,ut=`1.3.101.112`,dt=`1.3.101.113`;e.EdAlgorithm=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case`ed25519`:t=ut;break;case`x25519`:t=ct;break;case`eddsa`:switch(e.namedCurve.toLowerCase()){case`ed25519`:t=ut;break;case`ed448`:t=dt}break;case`ecdh-es`:switch(e.namedCurve.toLowerCase()){case`x25519`:t=ct;break;case`x448`:t=lt}}return t?new r.AlgorithmIdentifier({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case ut:return{name:`Ed25519`};case dt:return{name:`EdDSA`,namedCurve:`Ed448`};case ct:return{name:`X25519`};case lt:return{name:`ECDH-ES`,namedCurve:`X448`}}return null}},e.EdAlgorithm=c.__decorate([l.injectable()],e.EdAlgorithm),l.container.registerSingleton(v,e.EdAlgorithm);var ft=class extends G{constructor(e){G.isAsnEncoded(e)?super(e,d.CertificationRequest):super(e),this.tag=W.CertificateRequestTag}onInit(e){this.tbs=n.AsnConvert.serialize(e.certificationRequestInfo),this.publicKey=new Be(e.certificationRequestInfo.subjectPKInfo);let t=l.container.resolve(b);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(e=>rt.create(n.AsnConvert.serialize(e)));let r=this.getAttribute(u.id_pkcs9_at_extensionRequest);this.extensions=[],r instanceof nt&&(this.extensions=r.items),this.subjectName=new H(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(let 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(let 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=B.get()){let t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,[`verify`],e),r=l.container.resolveAll(it).reverse(),i=null;for(let e of r)if(i=e.toWebSignature(t,this.signature),i)break;if(!i)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),t=n.AsnConvert.parse(this.rawData,d.CertificationRequest),i=t.certificationRequestInfo,a=new I(``,{Version:`${r.Version[i.version]} (${i.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let e=new I(``);for(let t of this.attributes){let n=t.toTextObject();e[n[I.NAME]]=n}a.Attributes=e}return e.Data=a,e.Signature=new I(``,{Algorithm:be.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}};ft.NAME=`PKCS#10 Certificate Request`;var pt=class{static async create(e,t=B.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw Error(`Bad field 'keys' in 'params' argument. 'publicKey' is empty`);let i=await t.subtle.exportKey(`spki`,e.keys.publicKey),a=new d.CertificationRequest({certificationRequestInfo:new d.CertificationRequestInfo({subjectPKInfo:n.AsnConvert.parse(i,r.SubjectPublicKeyInfo)})});if(e.name){let t=e.name instanceof H?e.name:new H(e.name);a.certificationRequestInfo.subject=n.AsnConvert.parse(t.toArrayBuffer(),r.Name)}if(e.attributes)for(let t of e.attributes)a.certificationRequestInfo.attributes.push(n.AsnConvert.parse(t.rawData,r.Attribute));if(e.extensions&&e.extensions.length){let t=new r.Attribute({type:u.id_pkcs9_at_extensionRequest}),i=new r.Extensions;for(let t of e.extensions)i.push(n.AsnConvert.parse(t.rawData,r.Extension));t.values.push(n.AsnConvert.serialize(i)),a.certificationRequestInfo.attributes.push(t)}let o={...e.signingAlgorithm,...e.keys.privateKey.algorithm};a.signatureAlgorithm=l.container.resolve(b).toAsnAlgorithm(o);let s=n.AsnConvert.serialize(a.certificationRequestInfo),c=await t.subtle.sign(o,e.keys.privateKey,s),f=l.container.resolveAll(it).reverse(),p=null;for(let e of f)if(p=e.toAsnSignature(o,c),p)break;if(!p)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return a.signature=p,new ft(n.AsnConvert.serialize(a))}},mt=class extends G{constructor(e){G.isAsnEncoded(e)?super(e,r.Certificate):super(e),this.tag=W.CertificateTag}onInit(e){let t=e.tbsCertificate;this.tbs=n.AsnConvert.serialize(t),this.serialNumber=i.Convert.ToHex(t.serialNumber),this.subjectName=new H(t.subject),this.subject=new H(t.subject).toString(),this.issuerName=new H(t.issuer),this.issuer=this.issuerName.toString();let r=l.container.resolve(b);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;let a=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!a)throw Error(`Cannot get 'notBefore' value`);this.notBefore=a;let o=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!o)throw Error(`Cannot get 'notAfter' value`);this.notAfter=o,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(e=>Ye.create(n.AsnConvert.serialize(e)))),this.publicKey=new Be(t.subjectPublicKeyInfo)}getExtension(e){for(let t of this.extensions)if(typeof e==`string`){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e==`string`?t.type===e:t instanceof e)}async verify(e={},t=B.get()){let n,r,a=e.publicKey;try{if(!a)n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,[`verify`],t);else if(`publicKey`in a)n={...a.publicKey.algorithm,...this.signatureAlgorithm},r=await a.publicKey.export(n,[`verify`],t);else if(a instanceof Be)n={...a.algorithm,...this.signatureAlgorithm},r=await a.export(n,[`verify`],t);else if(i.BufferSourceConverter.isBufferSource(a)){let e=new Be(a);n={...e.algorithm,...this.signatureAlgorithm},r=await e.export(n,[`verify`],t)}else n={...a.algorithm,...this.signatureAlgorithm},r=a}catch{return!1}let o=l.container.resolveAll(it).reverse(),s=null;for(let e of o)if(s=e.toWebSignature(n,this.signature),s)break;if(!s)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);let c=await t.subtle.verify(this.signatureAlgorithm,r,s,this.tbs);if(e.signatureOnly)return c;{let t=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<t&&t<this.notAfter.getTime()}}async getThumbprint(...e){let t,n=`SHA-1`;return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??=B.get(),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=B.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),t=n.AsnConvert.parse(this.rawData,r.Certificate),i=t.tbsCertificate,a=new I(``,{Version:`${r.Version[i.version]} (${i.version})`,"Serial Number":i.serialNumber,"Signature Algorithm":be.serializeAlgorithm(i.signature),Issuer:this.issuer,Validity:new I(``,{"Not Before":i.validity.notBefore.getTime(),"Not After":i.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(i.issuerUniqueID&&(a[`Issuer Unique ID`]=i.issuerUniqueID),i.subjectUniqueID&&(a[`Subject Unique ID`]=i.subjectUniqueID),this.extensions.length){let e=new I(``);for(let t of this.extensions){let n=t.toTextObject();e[n[I.NAME]]=n}a.Extensions=e}return e.Data=a,e.Signature=new I(``,{Algorithm:be.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}};mt.NAME=`Certificate`;var ht=class extends Array{constructor(e){if(super(),G.isAsnEncoded(e))this.import(e);else if(e instanceof mt)this.push(e);else if(Array.isArray(e))for(let t of e)this.push(t)}export(e){let t=new m.SignedData;t.version=1,t.encapContentInfo.eContentType=m.id_data,t.encapContentInfo.eContent=new m.EncapsulatedContent({single:new n.OctetString}),t.certificates=new m.CertificateSet(this.map(e=>new m.CertificateChoices({certificate:n.AsnConvert.parse(e.rawData,r.Certificate)})));let i=new m.ContentInfo({contentType:m.id_signedData,content:n.AsnConvert.serialize(t)}),a=n.AsnConvert.serialize(i);return e===`raw`?a:this.toString(e)}import(e){let t=G.toArrayBuffer(e),r=n.AsnConvert.parse(t,m.ContentInfo);if(r.contentType!==m.id_signedData)throw TypeError(`Cannot parse CMS package. Incoming data is not a SignedData object.`);let i=n.AsnConvert.parse(r.content,m.SignedData);this.clear();for(let e of i.certificates||[])e.certificate&&this.push(new mt(e.certificate))}clear(){for(;this.pop(););}toString(e=`pem`){let t=this.export(`raw`);switch(e){case`pem`:return W.encode(t,`CMS`);case`pem-chain`:return this.map(e=>e.toString(`pem`)).join(`
135
+ `);case`asn`:return n.AsnConvert.toString(t);case`hex`:return i.Convert.ToHex(t);case`base64`:return i.Convert.ToBase64(t);case`base64url`:return i.Convert.ToBase64Url(t);case`text`:return be.serialize(this.toTextObject());default:throw TypeError(`Argument 'format' is unsupported value`)}}toTextObject(){let e=n.AsnConvert.parse(this.export(`raw`),m.ContentInfo),t=n.AsnConvert.parse(e.content,m.SignedData);return new I(`X509Certificates`,{"Content Type":R.toString(e.contentType),Content:new I(``,{Version:`${m.CMSVersion[t.version]} (${t.version})`,Certificates:new I(``,{Certificate:this.map(e=>e.toTextObject())})})})}},gt=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=B.get()){let n=new ht(e),r=e;for(;r=await this.findIssuer(r,t);){let e=await r.getThumbprint(t);for(let r of n){let n=await r.getThumbprint(t);if(i.isEqual(e,n))throw Error(`Cannot build a certificate chain. Circular dependency.`)}n.push(r)}return n}async findIssuer(e,t=B.get()){if(!await e.isSelfSigned(t)){let r=e.getExtension(p.id_ce_authorityKeyIdentifier);for(let a of this.certificates)if(a.subject===e.issuer){if(r){if(r.keyId){let e=a.getExtension(p.id_ce_subjectKeyIdentifier);if(e&&e.keyId!==r.keyId)continue}else if(r.certId){let e=a.getExtension(p.id_ce_subjectAltName);if(e&&!(r.certId.serialNumber===a.serialNumber&&i.isEqual(n.AsnConvert.serialize(r.certId.name),n.AsnConvert.serialize(e))))continue}}try{let n={...a.publicKey.algorithm,...e.signatureAlgorithm},r=await a.publicKey.export(n,[`verify`],t);if(!await e.verify({publicKey:r,signatureOnly:!0},t))continue}catch{continue}return a}}return null}},_t=class{static async createSelfSigned(e,t=B.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw 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=B.get()){let r;r=e.publicKey instanceof Be?e.publicKey.rawData:`publicKey`in e.publicKey?e.publicKey.publicKey.rawData:i.BufferSourceConverter.isBufferSource(e.publicKey)?e.publicKey:await t.subtle.exportKey(`spki`,e.publicKey);let a=e.serialNumber?i.BufferSourceConverter.toUint8Array(i.Convert.FromHex(e.serialNumber)):t.getRandomValues(new Uint8Array(16));a[0]>127&&(a[0]&=127),a.length>1&&a[0]===0&&(a[1]|=128);let o=e.notBefore||new Date,s=e.notAfter||new Date(o.getTime()+31536e6),c=new p.Certificate({tbsCertificate:new p.TBSCertificate({version:p.Version.v3,serialNumber:a,validity:new p.Validity({notBefore:o,notAfter:s}),extensions:new p.Extensions(e.extensions?.map(e=>n.AsnConvert.parse(e.rawData,p.Extension))||[]),subjectPublicKeyInfo:n.AsnConvert.parse(r,p.SubjectPublicKeyInfo)})});if(e.subject){let t=e.subject instanceof H?e.subject:new H(e.subject);c.tbsCertificate.subject=n.AsnConvert.parse(t.toArrayBuffer(),p.Name)}if(e.issuer){let t=e.issuer instanceof H?e.issuer:new H(e.issuer);c.tbsCertificate.issuer=n.AsnConvert.parse(t.toArrayBuffer(),p.Name)}let u={hash:`SHA-256`},d=`signingKey`in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},f=l.container.resolve(b);c.tbsCertificate.signature=c.signatureAlgorithm=f.toAsnAlgorithm(d);let m=n.AsnConvert.serialize(c.tbsCertificate),h=`signingKey`in e?await t.subtle.sign(d,e.signingKey,m):e.signature,g=l.container.resolveAll(it).reverse(),_=null;for(let e of g)if(_=e.toAsnSignature(d,h),_)break;if(!_)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return c.signatureValue=_,new mt(n.AsnConvert.serialize(c))}};e.X509CrlReason=void 0,(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`})(e.X509CrlReason||={});var vt=class extends xe{constructor(...e){let t;t=i.BufferSourceConverter.isBufferSource(e[0])?i.BufferSourceConverter.toArrayBuffer(e[0]):n.AsnConvert.serialize(new r.RevokedCertificate({userCertificate:e[0],revocationDate:new r.Time(e[1]),crlEntryExtensions:e[2]})),super(t,r.RevokedCertificate)}onInit(e){this.serialNumber=i.Convert.ToHex(e.userCertificate),this.revocationDate=e.revocationDate.getTime(),this.extensions=[],e.crlEntryExtensions&&(this.extensions=e.crlEntryExtensions.map(e=>{let t=Ye.create(n.AsnConvert.serialize(e));switch(t.type){case r.id_ce_cRLReasons:this.reason=n.AsnConvert.parse(t.value,r.CRLReason).reason;break;case r.id_ce_invalidityDate:this.invalidity=n.AsnConvert.parse(t.value,r.InvalidityDate).value}return t}))}},yt=class extends G{constructor(e){G.isAsnEncoded(e)?super(e,r.CertificateList):super(e),this.tag=W.CrlTag}onInit(e){let t=e.tbsCertList;this.tbs=n.AsnConvert.serialize(t),this.version=t.version;let r=l.container.resolve(b);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.tbsCertListSignatureAlgorithm=t.signature,this.certListSignatureAlgorithm=e.signatureAlgorithm,this.signature=e.signature,this.issuerName=new H(t.issuer),this.issuer=this.issuerName.toString();let i=t.thisUpdate.getTime();if(!i)throw Error(`Cannot get 'thisUpdate' value`);this.thisUpdate=i;let a=t.nextUpdate?.getTime();this.nextUpdate=a,this.entries=t.revokedCertificates?.map(e=>new vt(n.AsnConvert.serialize(e)))||[],this.extensions=[],t.crlExtensions&&(this.extensions=t.crlExtensions.map(e=>Ye.create(n.AsnConvert.serialize(e))))}getExtension(e){for(let t of this.extensions)if(typeof e==`string`){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e==`string`?t.type===e:t instanceof e)}async verify(e,t=B.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw Error(`algorithm identifier in the sequence tbsCertList and CertificateList mismatch`);let n,r,i=e.publicKey;try{i instanceof mt?(n={...i.publicKey.algorithm,...i.signatureAlgorithm},r=await i.publicKey.export(n,[`verify`])):i instanceof Be?(n={...i.algorithm,...this.signature},r=await i.export(n,[`verify`])):(n={...i.algorithm,...this.signature},r=i)}catch{return!1}let a=l.container.resolveAll(it).reverse(),o=null;for(let e of a)if(o=e.toWebSignature(n,this.signature),o)break;if(!o)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return await t.subtle.verify(this.signatureAlgorithm,r,o,this.tbs)}async getThumbprint(...e){let t,n=`SHA-1`;return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??=B.get(),await t.subtle.digest(n,this.rawData)}findRevoked(e){let t=typeof e==`string`?e:e.serialNumber;for(let e of this.entries)if(e.serialNumber===t)return e;return null}},bt=class{static async create(e,t=B.get()){let a=e.issuer instanceof H?e.issuer:new H(e.issuer),o=new p.CertificateList({tbsCertList:new p.TBSCertList({version:p.Version.v2,issuer:n.AsnConvert.parse(a.toArrayBuffer(),p.Name),thisUpdate:new r.Time(e.thisUpdate||new Date)})});if(e.nextUpdate&&(o.tbsCertList.nextUpdate=new r.Time(e.nextUpdate)),e.extensions&&e.extensions.length&&(o.tbsCertList.crlExtensions=new p.Extensions(e.extensions.map(e=>n.AsnConvert.parse(e.rawData,p.Extension))||[])),e.entries&&e.entries.length){o.tbsCertList.revokedCertificates=[];for(let t of e.entries){let a=G.toArrayBuffer(t.serialNumber);if(o.tbsCertList.revokedCertificates.findIndex(e=>i.isEqual(e.userCertificate,a))>-1)throw Error(`Certificate serial number ${t.serialNumber} already exists in tbsCertList`);let s=new r.RevokedCertificate({userCertificate:a,revocationDate:new r.Time(t.revocationDate||new Date)});if(s.crlEntryExtensions=`extensions`in t&&t.extensions?.length?t.extensions.map(e=>n.AsnConvert.parse(e.rawData,p.Extension)):[],!(t instanceof vt)&&(t.reason&&s.crlEntryExtensions.push(new p.Extension({extnID:p.id_ce_cRLReasons,critical:!1,extnValue:new n.OctetString(n.AsnConvert.serialize(new p.CRLReason(t.reason)))})),t.invalidity&&s.crlEntryExtensions.push(new p.Extension({extnID:p.id_ce_invalidityDate,critical:!1,extnValue:new n.OctetString(n.AsnConvert.serialize(new p.InvalidityDate(t.invalidity)))})),t.issuer)){let t=e.issuer instanceof H?e.issuer:new H(e.issuer);s.crlEntryExtensions.push(new p.Extension({extnID:p.id_ce_certificateIssuer,critical:!1,extnValue:new n.OctetString(n.AsnConvert.serialize(n.AsnConvert.parse(t.toArrayBuffer(),p.Name)))}))}o.tbsCertList.revokedCertificates.push(s)}}let s={...e.signingAlgorithm,...e.signingKey.algorithm},c=l.container.resolve(b);o.tbsCertList.signature=o.signatureAlgorithm=c.toAsnAlgorithm(s);let u=n.AsnConvert.serialize(o.tbsCertList),d=await t.subtle.sign(s,e.signingKey,u),f=l.container.resolveAll(it).reverse(),m=null;for(let e of f)if(m=e.toAsnSignature(s,d),m)break;if(!m)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return o.signature=m,new yt(n.AsnConvert.serialize(o))}};Ye.register(p.id_ce_basicConstraints,Ue),Ye.register(p.id_ce_extKeyUsage,We),Ye.register(p.id_ce_keyUsage,Ge),Ye.register(p.id_ce_subjectKeyIdentifier,Ke),Ye.register(p.id_ce_authorityKeyIdentifier,He),Ye.register(p.id_ce_subjectAltName,qe),Ye.register(p.id_ce_cRLDistributionPoints,Ze),Ye.register(p.id_pe_authorityInfoAccess,Qe),rt.register(_.id_pkcs9_at_challengePassword,tt),rt.register(_.id_pkcs9_at_extensionRequest,nt),l.container.registerSingleton(it,at),l.container.registerSingleton(it,st),st.namedCurveSize.set(`P-256`,32),st.namedCurveSize.set(`K-256`,32),st.namedCurveSize.set(`P-384`,48),st.namedCurveSize.set(`P-521`,66),e.AlgorithmProvider=y,e.AsnData=xe,e.AsnDefaultSignatureFormatter=at,e.AsnEcSignatureFormatter=st,e.Attribute=q,e.AttributeFactory=rt,e.AuthorityInfoAccessExtension=Qe,e.AuthorityKeyIdentifierExtension=He,e.BasicConstraintsExtension=Ue,e.CRLDistributionPointsExtension=Ze,e.CertificatePolicyExtension=Xe,e.ChallengePasswordAttribute=tt,e.CryptoProvider=Ce,e.DefaultAlgorithmSerializer=ye,e.ExtendedKeyUsageExtension=We,e.Extension=z,e.ExtensionFactory=Ye,e.ExtensionsAttribute=nt,e.GeneralName=Le,e.GeneralNames=Re,e.KeyUsagesExtension=Ge,e.Name=H,e.NameIdentifier=Ee,e.OidSerializer=R,e.PemConverter=W,e.Pkcs10CertificateRequest=ft,e.Pkcs10CertificateRequestGenerator=pt,e.PublicKey=Be,e.SubjectAlternativeNameExtension=qe,e.SubjectKeyIdentifierExtension=Ke,e.TextConverter=be,e.TextObject=I,e.X509Certificate=mt,e.X509CertificateGenerator=_t,e.X509Certificates=ht,e.X509ChainBuilder=gt,e.X509Crl=yt,e.X509CrlEntry=vt,e.X509CrlGenerator=bt,e.cryptoProvider=B,e.diAlgorithm=v,e.diAlgorithmProvider=b,e.diAsnSignatureFormatter=it,e.idEd25519=ut,e.idEd448=dt,e.idX25519=ct,e.idX448=lt}));I(),Ji();var Yi;(function(e){e.Der=`der`,e.Raw=`raw`})(Yi||={});const Xi=typeof window<`u`&&window.document!==void 0&&typeof crypto<`u`&&crypto.subtle!==void 0,Zi=typeof process<`u`&&process.versions!=null&&process.versions.node!=null,Qi=()=>Xi?`browser`:Zi?`node`:`purejs`,$i=async(e,t)=>{let n=t??Qi();switch(n){case`browser`:return(await import(`./webcrypto-CRLL4ptE.mjs`)).signWithApiKey(e);case`node`:return(await import(`./nodecrypto-CIGSbdQh.mjs`)).signWithApiKey(e);case`purejs`:return(await import(`./purejs-CZxWHjtN.mjs`)).signWithApiKey(e);default:throw Error(`Unsupported runtime: ${n}`)}};var ea=class{constructor(e){this.apiPublicKey=e.apiPublicKey,this.apiPrivateKey=e.apiPrivateKey,this.runtimeOverride=e.runtimeOverride}async stamp(e){let t=await $i({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride),n={publicKey:this.apiPublicKey,scheme:`SIGNATURE_SCHEME_TK_API_P256`,signature:t};return{stampHeaderName:`X-Stamp`,stampHeaderValue:c(JSON.stringify(n))}}async sign(e,t){switch(t){case Yi.Raw:{let t=await $i({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride),n=ge(t);return a(n)}case Yi.Der:return $i({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride);default:throw Error(`Unsupported signature format: ${t}`)}}},ta=class extends Error{constructor(e){super(e),this.name=`InvalidKeyError`}};function na(){let e=m(`prime256v1`);return e.generateKeys(),ia(e.getPrivateKey().toString(`hex`).padStart(64,`0`))}const ra=/^[0-9a-f]{64}$/i;function ia(e){if(!ra.test(e))throw new ta(`P-256 private key must be 64 hex characters`);let t=e.toLowerCase(),n=m(`prime256v1`);try{n.setPrivateKey(Buffer.from(t,`hex`))}catch{throw new ta(`value is not a valid P-256 private key (scalar out of range)`)}return{algorithm:`p256`,privateKeyHex:t,publicKeyHex:n.getPublicKey(`hex`,`compressed`)}}function aa(e){try{let t=p.convertKey(e,`prime256v1`,`hex`,`hex`,`uncompressed`),n=Buffer.isBuffer(t)?t:Buffer.from(t,`hex`);return n.length===65?n:null}catch{return null}}function oa(e){let t=aa(e);if(t===null)throw new ta(`value is not a valid P-256 public key`);return sa(t)}function sa(e){let t=e.subarray(1,33).toString(`base64url`),n=e.subarray(33,65).toString(`base64url`);return h(`sha256`).update(`{"crv":"P-256","kty":"EC","x":"${t}","y":"${n}"}`,`utf8`).digest(`base64url`)}const ca=/^https?:\/\/[\x21\x23-\x7e]{1,255}$/,la=/^[\x21\x23-\x3a\x3c-\x7e]{1,128}$/;function ua(e,t){return`${e.replace(/\/+$/,``)}/agent-keys/${t}`}function da(e){let t=fa(e.keypair),n={...t,identityUrl:pa(e.identityUrl??ua(e.baseUrl,t.keyId))};return{sign:async e=>{let t=new Uint8Array(await e.clone().arrayBuffer()),r=ma(n,{method:e.method,url:e.url,body:t},{nonce:_(16).toString(`base64url`),createdAt:new Date}),i=new Headers(e.headers);for(let[e,t]of Object.entries(r))i.set(e,t);return new Request(e,{headers:i})}}}function fa(e){let t=aa(e.publicKeyHex);if(t===null)throw Error(`signer keypair has an invalid P-256 public key`);return{signingKey:va(t,e.privateKeyHex),keyId:sa(t)}}function pa(e){if(!ca.test(e))throw Error(`identity URL is outside the signature profile: "${e}"`);return e}function ma(e,t,n){if(!la.test(n.nonce))throw Error(`nonce is outside the signature profile`);let r=ha(t.body),i=`"${e.identityUrl}"`,a=`("@method" "@target-uri" "content-digest" "signature-agent");created=${Math.floor(n.createdAt.getTime()/1e3)};keyid="${e.keyId}";nonce="${n.nonce}";alg="ecdsa-p256-sha256"`,o=[`"@method": ${t.method.toUpperCase()}`,`"@target-uri": ${ga(new URL(t.url))}`,`"content-digest": ${r}`,`"signature-agent": ${i}`,`"@signature-params": ${a}`].join(`
136
+ `),s=v(`sha256`,Buffer.from(o,`utf8`),{key:e.signingKey,dsaEncoding:`ieee-p1363`});return{"Content-Digest":r,"Signature-Agent":i,"Signature-Input":`sig=${a}`,Signature:`sig=:${s.toString(`base64`)}:`}}function ha(e){return`sha-256=:${h(`sha256`).update(e??``).digest(`base64`)}:`}function ga(e){return`${e.protocol}//${_a(e)}${e.pathname}${e.search}`}function _a(e){let t=e.host.toLowerCase();return e.protocol===`https:`&&e.port===`443`||e.protocol===`http:`&&e.port===`80`?e.hostname.toLowerCase():t}function va(e,t){return g({key:{kty:`EC`,crv:`P-256`,d:Buffer.from(t,`hex`).toString(`base64url`),x:e.subarray(1,33).toString(`base64url`),y:e.subarray(33,65).toString(`base64url`)},format:`jwk`})}var ya=`0.1.0`;const ba=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,xa=ya;function Sa(e,t){if(!ba.test(e))throw Error(`${t} must be a valid HTTP token`)}function Ca(e,t){let n=!1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r<32||r===127||r>255){n=!0;break}}if(n||/[()\\]/.test(e))throw Error(`${t} must not contain parentheses, backslashes, control characters, or characters outside Latin-1`)}function wa(e){let t=`catena-agent-client/${xa}`;if(!e)return t;Sa(e.name,`appInfo.name`),e.version!==void 0&&Sa(e.version,`appInfo.version`),e.url!==void 0&&Ca(e.url,`appInfo.url`);let n=e.version===void 0?e.name:`${e.name}/${e.version}`;return`${e.url===void 0?n:`${n} (${e.url})`} ${t}`}const Ta=f.pipe(f.string(),f.regex(/\S/,`Response enum values must not be blank`));function Ea(e){return Ta}const Da=f.object({amount:f.string(),asset_id:f.string()}),Oa=f.pipe(f.string(),f.isoTimestamp()),ka=f.object({success:f.literal(!0)}),Aa=f.object({id:f.string(),name:f.string(),status:f.string(),organizationId:f.string()}),ja=f.object({agent:Aa}),Ma=f.object({id:f.string(),ruleType:Ea([`per_transaction_amount`,`daily_amount`,`weekly_amount`,`monthly_amount`,`hourly_count`,`daily_count`]),thresholdAmount:f.optional(Da),thresholdCount:f.optional(f.number()),action:Ea([`block`,`require_approval`]),requiredApprovals:f.number(),accountAggregationScope:Ea([`per_account`,`across_accounts`]),actorAggregationScope:Ea([`per_agent`,`per_policy`]),displayOrder:f.number()}),Na=f.object({id:f.string(),organizationId:f.string(),policyId:f.string(),capability:Ea([`query_balance`,`read`,`send`,`transfer`]),accountId:f.string(),rules:f.array(Ma),createdAt:Oa,updatedAt:Oa}),Pa=[`allow`,`block`,`require_approval`],Fa=[`open`,`restricted`],Ia=Ea(Pa),La=f.object({mode:Ea(Fa),allowedCounterparties:f.optional(f.array(f.string())),createAction:f.optional(Ia),requestPaymentDetailsAction:f.optional(Ia),allowCreate:f.optional(f.boolean())}),Ra=f.object({id:f.optional(f.string()),description:f.optional(f.string()),version:f.optional(f.number()),name:f.string(),capabilities:f.array(f.string()),counterpartyRules:f.optional(La),policyCapabilities:f.array(Na)}),za=f.object({policy:Ra}),Ba=f.object({accounts:f.array(f.object({id:f.string(),name:f.string(),type:f.string(),currency:f.string()}))}),Va=f.object({accountId:f.string(),balance:Da,balances:f.optional(f.object({total:Da,available:Da}))}),Ha=[`operator-send`,`operator-transfer`,`operator-deposit`,`operator-refund`,`microdeposit`],Ua=[`pending`,`processing`,`completed`,`failed`,`reversed`],Wa=[`initiated`,`provider_pending`,`processing`,`completed`,`failed`,`reversed`,`manual_review`],Ga=[`ach`,`wire`,`on-chain`],Ka=f.object({id:f.string(),type:Ea(Ha),action:f.optional(f.string()),status:Ea(Ua),movementStatus:Ea(Wa),direction:f.picklist([`incoming`,`outgoing`]),amount:Da,fee:Da,currency:f.string(),counterpartyName:f.optional(f.string()),method:f.optional(Ea([`ach`,`wire`,`on-chain`])),memo:f.optional(f.string()),description:f.optional(f.string()),txHash:f.optional(f.string()),createdAt:Oa,completedAt:f.optional(Oa)}),qa=f.object({accountId:f.string(),transactions:f.array(Ka),total:f.number()}),Ja=f.object({accountId:f.string(),address:f.string(),liquidationAddressId:f.optional(f.string()),source:Ea([`wallet`,`liquidation`])}),Ya=f.object({id:f.string(),name:f.string(),status:f.optional(f.string()),rails:f.array(f.object({id:f.string(),type:f.string(),walletAddress:f.optional(f.string()),network:f.optional(f.string()),bankName:f.optional(f.string()),accountNumber:f.optional(f.string())}))}),Xa=f.object({counterparties:f.array(Ya)}),Za=f.picklist([`pending`,`processing`,`completed`,`blocked`,`failed`]),Qa=f.object({type:f.literal(`submit_stamp`),signingRequestId:f.string(),signer:f.object({algorithm:f.literal(`p256`),publicKeyHex:f.string()}),preparedBody:f.object({body:f.string(),bodyHash:f.string(),expiresAt:Oa,prepareToken:f.string()})}),$a=f.object({id:f.string(),type:Ea([`send`,`transfer`,`create_counterparty`,`request_counterparty_details`,`x402`]),status:Za,reasons:f.array(f.string()),expiresAt:f.optional(f.nullable(Oa),null),replayed:f.optional(f.boolean(),!1),data:f.optional(f.nullable(f.record(f.string(),f.unknown())),null),metadata:f.optional(f.object({dataUrl:f.nullable(f.string())})),nextAction:f.optional(Qa)});function eo(e){let{nextAction:t,...n}=e;return n}const to=f.picklist(Ga),no=f.object({type:f.literal(`send`),accountId:f.string(),counterpartyRailId:f.string(),amount:f.string(),method:to,memo:f.optional(f.string()),description:f.optional(f.string())}),ro=f.object({type:f.literal(`transfer`),accountId:f.string(),toAccountId:f.string(),amount:f.string(),memo:f.optional(f.string()),description:f.optional(f.string())}),io={type:f.literal(`create_counterparty`),name:f.string()},ao=f.union([f.object({...io,email:f.optional(f.string()),rail:f.nonOptional(f.unknown())}),f.object({...io,email:f.string()})]),oo=f.object({type:f.literal(`request_counterparty_details`),counterpartyId:f.string(),methods:f.pipe(f.object({bank:f.boolean(),wallet:f.boolean()}),f.check(({bank:e,wallet:t})=>e||t,`Select at least one payment method to request`))}),so=f.looseObject({scheme:f.string(),network:f.string(),asset:f.string(),amount:f.string(),payTo:f.string(),maxTimeoutSeconds:f.number()}),co=f.looseObject({url:f.string(),serviceName:f.fallback(f.optional(f.pipe(f.string(),f.maxLength(255))),void 0)}),lo=f.object({type:f.literal(`x402`),accountId:f.string(),paymentRequirements:so,resource:f.optional(co)}),uo=f.union([no,ro,ao,oo,lo]);function fo(e){let t=f.parse(uo,e);return t.type===`send`||t.type===`transfer`?{...t,amount:{amount:t.amount,asset_id:`USD`}}:t}const po=f.object({intent:$a});var mo=class extends Error{status;code;details;constructor(e,t,n,r){super(n?`API error ${e} [${n}]: ${t}`:`API error ${e}: ${t}`),this.name=`ApiError`,this.status=e,this.code=n,this.details=r}},ho=class extends Error{timeoutMs;constructor(e){super(`Request timed out after ${e}ms. The server may still have processed a state-changing request; follow that operation's documented recovery procedure before retrying.`),this.name=`TimeoutError`,this.timeoutMs=e}};const go=f.object({error:f.nullish(f.string()),message:f.nullish(f.string()),code:f.nullish(f.string()),details:f.nullish(f.record(f.string(),f.unknown()))});async function _o(e){let t=f.safeParse(go,await e.json().catch(()=>void 0)),n=t.success?t.output:{};return n.error!=null&&n.message!=null?new mo(e.status,n.message,n.code??n.error,n.details??void 0):new mo(e.status,n.error??n.message??e.statusText,n.code??void 0,n.details??void 0)}async function vo(e,t){if(!e.ok)throw await _o(e);return f.parse(t,await e.json())}var yo=class extends Error{intentId;outcome;constructor(e){let t=e.cause instanceof Error?e.cause.message:String(e.cause);super(e.outcome===`not-submitted`?`Intent ${e.intentId} was created but never submitted; no money moved: ${t}`:`Intent ${e.intentId} submission could not be confirmed: ${t}; poll getIntent("${e.intentId}") to a terminal status and resubmit only after blocked or failed`,{cause:e.cause}),this.name=`IntentSubmitError`,this.intentId=e.intentId,this.outcome=e.outcome}};const bo=2147483647;var xo=class{#e;#t;#n;#r;#i;#a;#o;constructor(e){let t=e.timeout===void 0?8e4:e.timeout;if(!Number.isInteger(t)||t<=0||t>bo)throw TypeError(`timeout must be a positive integer no greater than ${bo}`);this.#e=e.baseUrl??`https://api.catena.com`,this.#t=wa(e.appInfo),this.#n=e.defaultHeaders??{},this.#r=ia(e.privateKeyHex),this.#a=(e.fetch??globalThis.fetch).bind(globalThis),this.#o=t,this.#i=da({keypair:this.#r,baseUrl:this.#e,identityUrl:e.identityUrl})}#s(e){let t=new Headers({"Content-Type":`application/json`});for(let[e,n]of Object.entries(this.#n))t.set(e,n);for(let[n,r]of Object.entries(e??{}))t.set(n,r);return t.set(`User-Agent`,this.#t),t.delete(`Authorization`),t}async#c(e){let t=new URL(`${this.#e}/v1/agent-api${e.path}`);for(let[n,r]of Object.entries(e.query??{}))r!==void 0&&t.searchParams.set(n,r);let n=new Request(t,{method:e.method,headers:this.#s(e.headers),body:e.body===void 0?null:JSON.stringify(e.body)});return this.#i.sign(n)}async#l(e,t){return this.#u(await this.#c(e),t)}async#u(e,t){let n=new AbortController,r=new Request(e,{signal:n.signal}),i;try{let e=new Promise((e,t)=>{i=setTimeout(()=>{let e=new ho(this.#o);t(e),n.abort(e)},this.#o)}),a=this.#a(r).then(e=>vo(e,t));return await Promise.race([a,e])}finally{i!==void 0&&clearTimeout(i)}}async whoami(){return(await this.#l({method:`GET`,path:`/me`},ja)).agent}async submitFeedback(e){await this.#l({method:`POST`,path:`/feedback`,body:{body:e}},ka)}async getPolicy(){return(await this.#l({method:`GET`,path:`/policy`},za)).policy}async listAccounts(){return this.#l({method:`GET`,path:`/accounts`},Ba)}async getAccountBalance(e){return this.#l({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/balance`},Va)}async listAccountTransactions(e,t={}){return this.#l({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/transactions`,query:{start:t.start,end:t.end,limit:t.limit?.toString(),offset:t.offset?.toString()}},qa)}async getAccountDepositAddress(e,t){return this.#l({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/deposit-address`,query:{network:t.network,asset:t.asset}},Ja)}async listCounterparties(e={}){return this.#l({method:`GET`,path:`/counterparties`,query:{address:e.address,network:e.network}},Xa)}async submitIntent(e){let t=await this.#d(e),n=t.nextAction;if(!n)return eo(t);let r;try{let e=await this.#f(n);r=await this.#c({method:`POST`,path:`/intents/${encodeURIComponent(t.id)}/submit-stamp`,body:{preparedBody:n.preparedBody,stamp:e}})}catch(e){throw new yo({intentId:t.id,outcome:`not-submitted`,cause:e})}try{return await this.#p(r,t.replayed)}catch(e){throw new yo({intentId:t.id,outcome:`unknown`,cause:e})}}async#d(e){return this.#l({method:`POST`,path:`/intents`,body:{action:fo(e.action)},...e.idempotencyKey!==void 0&&{headers:{"Idempotency-Key":e.idempotencyKey}}},$a)}async#f(e){if(e.signer.publicKeyHex.toLowerCase()!==this.#r.publicKeyHex.toLowerCase())throw Error(`Local signer public key does not match requested signer ${e.signer.publicKeyHex}; linked credential has ${this.#r.publicKeyHex}`);let t=await new ea({apiPublicKey:this.#r.publicKeyHex,apiPrivateKey:this.#r.privateKeyHex}).stamp(e.preparedBody.body);return{publicKeyHex:this.#r.publicKeyHex,stampHeaderName:t.stampHeaderName,stampHeaderValue:t.stampHeaderValue}}async#p(e,t){let n=eo((await this.#u(e,po)).intent);return t?{...n,replayed:!0}:n}async getIntent(e){return eo(await this.#l({method:`GET`,path:`/intents/${encodeURIComponent(e)}`},$a))}async unlinkAgent(){await this.#l({method:`POST`,path:`/unlink`},ka)}async reportSettlement(e){await this.#l({method:`POST`,path:`/intents/${encodeURIComponent(e.intentId)}/settlement-report`,body:{txHash:e.txHash}},ka)}};function So(e={}){let t=e.privateKeyHex===void 0?process.env.CATENA_SECRET_KEY:e.privateKeyHex;if(t===void 0)throw new ta(`privateKeyHex is required; pass it explicitly or set CATENA_SECRET_KEY`);return new xo({...e,privateKeyHex:t})}function Co(e){let t=e instanceof Error?e.message:String(e);return e instanceof mo&&e.details!==void 0?`${t}\nDetails:\n${JSON.stringify(e.details,null,2)}`:t}function Z(e){console.error(Co(e)),process.exit(1)}const wo=f.string(),To=f.boolean();function Eo(e){return e===void 0}function Do(e){return e.issues?.[0]?.message??`Invalid value`}function Oo(e,t,n,r){return Z(`${e}: ${t}${r?` (got: ${String(n)})`:``}`)}function ko(e,t,n,r){let i=f.safeParse(e,t);return i.success?i.output:Oo(n,Do(i),t,r)}function Ao(e,t){let n=t.schema??wo;return{type:e,description:t.description,negativeDescription:t.negativeDescription,required:t.required,default:t.default,parseValue(e,r){let i=Eo(e)?t.default:e;if(Eo(i)){t.required===!0&&Z(`${r} is required`);return}return ko(n,i,r,t.showValueInError===!0)}}}function Q(e){return Ao(`string`,e)}function jo(e){return Ao(`positional`,e)}function Mo(e){let t=e.schema??wo;return{type:`string`,description:e.description,repeatable:!0,parseValue(n,r){return(Array.isArray(n)?n:[]).map(n=>ko(t,n,r,e.showValueInError===!0))}}}function No(e){return{type:`boolean`,description:e.description,negativeDescription:e.negativeDescription,required:e.required,default:e.default,parseValue(t,n){let r=Eo(t)?e.default:t;if(Eo(r)){e.required===!0&&Z(`${n} is required`);return}return ko(To,r,n,!1)}}}function Po(e){return Fo(`string`,e)}function Fo(e,t){return Ao(e,{description:t.description,required:t.required,default:t.default,schema:f.picklist(t.choices,`must be one of ${t.choices.join(`|`)}`),showValueInError:!0})}function Io(e,t){return t.type===`positional`?`<${e}>`:`--${e}`}function Lo(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z0-9])([A-Z][a-z])/g,`$1 $2`).split(/[ _-]/).filter(e=>e.length>0)}function Ro(e){return Lo(e).join(`-`).toLowerCase()}function zo(e){return Lo(e).map((e,t)=>t===0?e.charAt(0).toLowerCase()+e.slice(1):e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function Bo(e){return[`--${e}`,`--${Ro(e)}`,`--${zo(e)}`]}function Vo(e){let t=e.indexOf(`=`);return t===-1?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}function Ho(e,t,n){let r=e.indexOf(`--`),i=r===-1?e.length:r,a=[...e.slice(0,i).filter(e=>!e.startsWith(`--no-`)),...e.slice(i)],o=new Set(Bo(t)),s=new Set(Object.entries(n).filter(([e,n])=>e!==t&&n.type===`string`).flatMap(([e])=>Bo(e))),c=[];for(let e=0;e<a.length;e++){let t=a[e];if(t===`--`)break;let[n,r]=Vo(t);if(o.has(n)){r===void 0?(c.push(a[e+1]??``),e++):c.push(r);continue}s.has(n)&&r===void 0&&e++}return c}function Uo(e){let t=e.required??(e.type!==`positional`&&void 0);return e.type===`boolean`?{type:e.type,description:e.description,negativeDescription:e.negativeDescription,required:t,default:typeof e.default==`boolean`?e.default:void 0}:{type:e.type,description:e.description,required:t,default:typeof e.default==`string`?e.default:void 0}}function $(e){return{args:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Uo(t)])),label(t){return Io(t,e[t])},parse(t,n){let r=(r,i)=>{if(i.repeatable!==!0)return t[r];if(n===void 0)throw Error(`parse() needs the command's raw argv to collect the repeatable --${r} flag`);return Ho(n,r,e)};return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.parseValue(r(e,t),Io(e,t))]))}}}const Wo=Q({description:`Credential profile name`}),Go=No({description:`Print compact single-line JSON (for piping)`,default:!1}),Ko=/^[a-zA-Z0-9_-]+$/,qo=f.pipe(f.string(`ID must be a string`),f.minLength(1,`ID must not be empty`),f.maxLength(256,`ID is too long (max 256 characters)`),f.regex(Ko,`ID may only contain letters, digits, hyphens, and underscores`)),Jo=[`base`,`base-sepolia`],Yo=[`usdc`],Xo=`base`,Zo=f.pipe(f.string(),f.trim(),f.guard(e=>/^0x[0-9a-fA-F]{40}$/.test(e),`Must be a 0x-prefixed hex wallet address`));function Qo(e){return Po({description:e.description,choices:Jo,...e.default===void 0?{}:{default:e.default}})}const $o=[`registered`,`already_registered`,`not_applicable`,`registration_failed`],es=f.pipe(f.string(),f.regex(/^0[23][0-9a-f]{64}$/)),ts=f.pipe(f.string(),f.regex(/^[0-9a-f]{64}$/)),ns=f.object({status:f.picklist($o),publicKeyHex:f.optional(es),reason:f.optional(f.string())}),rs=f.object({algorithm:f.literal(`p256`),privateKeyHex:ts,publicKeyHex:es,registration:ns}),is=f.object({version:f.literal(`signer-1`),signer:rs}),as=f.object({version:f.literal(1),refreshToken:f.pipe(f.string(),f.minLength(1)),sessionToken:f.pipe(f.string(),f.minLength(1)),expiresAt:f.pipe(f.string(),f.isoTimestamp())}),os=f.object({version:f.literal(2),refreshToken:f.pipe(f.string(),f.minLength(1)),sessionToken:f.pipe(f.string(),f.minLength(1)),expiresAt:f.pipe(f.string(),f.isoTimestamp()),signer:rs}),ss=f.object({version:f.literal(3),signer:rs}),cs=f.variant(`version`,[as,os,ss]),ls=f.variant(`version`,[is,as,os,ss]);function us(e){return f.parse(cs,e)}function ds(e){return f.parse(ls,e)}function fs(e){let t=f.safeParse(ls,e);return t.success?t.output:null}function ps(e){return{version:`signer-1`,signer:{algorithm:e.algorithm,privateKeyHex:e.privateKeyHex,publicKeyHex:e.publicKeyHex,registration:{status:`not_applicable`,reason:`pending_claim`}}}}function ms(e,t){try{return ds(JSON.parse(e))}catch(e){throw Error(`${t} credential has an unsupported format`,{cause:e})}}function hs(e){return us({version:3,signer:e})}function gs(e){return JSON.stringify(e)}function _s(e,t){return JSON.stringify(e)===JSON.stringify(t)}function vs(e){return(t,n)=>ys(e,t,n)}function ys(e,t,n){return new Promise((r,i)=>{let a=b(e,[...t],{stdio:[`pipe`,`pipe`,`pipe`]}),o=[],s=[],c=!1,l=!1,u=null,d=null,f=null,p=e=>{c||(c=!0,d!==null&&clearTimeout(d),f!==null&&clearTimeout(f),r(e))},m=e=>{c||(c=!0,d!==null&&clearTimeout(d),f!==null&&clearTimeout(f),i(e))};d=setTimeout(()=>{l=!0,a.kill(`SIGTERM`),f=setTimeout(()=>{a.kill(`SIGKILL`),p({stdout:o.join(``),stderr:s.join(``),status:124})},1e3)},3e4),a.stdout.setEncoding(`utf8`),a.stderr.setEncoding(`utf8`),a.stdout.on(`data`,e=>o.push(e)),a.stderr.on(`data`,e=>s.push(e)),a.on(`error`,t=>{m(Error(`Unable to run ${e}: ${t.message}`))}),a.on(`close`,t=>{if(u!==null&&t===0){m(Error(`Unable to write to ${e} stdin: ${u.message}`));return}p({stdout:o.join(``),stderr:s.join(``),status:l?124:t})}),a.stdin.on(`error`,e=>{u=e});try{a.stdin.end(n)}catch(t){m(t instanceof Error?Error(`Unable to write to ${e} stdin: ${t.message}`):Error(`Unable to write to ${e} stdin`))}})}const bs=`catena-agent`;function xs(e){if(!Ko.test(e))throw Error(`Invalid credential location for credential storage: "${e}"`);return e}const Ss=vs(`/usr/bin/secret-tool`);function Cs(e){return e.status===1&&e.stdout===``&&e.stderr.trim()===``}function ws(e,t){if(t.status===0)return;let n=Ts(t);throw Error(`Linux Secret Service credential ${e} failed (secret-tool exited ${t.status??`without status`}): ${n}`)}function Ts(e){let t=e.stderr.toLowerCase();return e.status===124?`secret service operation timed out`:t.includes(`cannot autolaunch`)||t.includes(`dbus`)||t.includes(`d-bus`)||t.includes(`org.freedesktop.secrets`)?`secret service session is unavailable`:/\blocked\b/.test(t)?`secret service keyring appears to be locked`:t.includes(`authorization`)||t.includes(`denied`)||t.includes(`not authorized`)?`secret service authorization was denied`:`secret service operation failed; ensure the Secret Service session is available and unlocked`}function Es(e){return e instanceof Error?e.message.includes(`ENOENT`)?Error(`Linux Secret Service credential operation failed: /usr/bin/secret-tool was not found. Install libsecret-tools and ensure a Secret Service keyring is available.`,{cause:e}):e:Error(String(e))}var Ds=class{runSecretTool;constructor(e={}){if((e.platform??process.platform)!==`linux`)throw Error(`Linux Secret Service credential storage is only supported on Linux`);this.runSecretTool=e.runSecretTool??Ss}async save(e,t){let n=ds(t),r=xs(e);if(await this.savePassword(r,gs(n)),!_s(await this.resolveDirectPassword(r),n))throw Error(`Linux Secret Service credential save verification failed`)}async resolve(e){return this.resolveDirectPassword(xs(e))}async delete(e){await this.deletePassword(xs(e))}async savePassword(e,t){ws(`save`,await this.runSecretToolCommand([`store`,`--label`,`${bs} ${e}`,`app`,bs,`account`,e],t))}async resolvePassword(e){let t=await this.runSecretToolCommand([`lookup`,`app`,bs,`account`,e]);return Cs(t)?null:(ws(`resolve`,t),t.stdout.replace(/\r?\n$/,``))}async resolveDirectPassword(e){let t=await this.resolvePassword(e);return t===null?null:ms(t,`Linux Secret Service`)}async deletePassword(e){let t=await this.runSecretToolCommand([`clear`,`app`,bs,`account`,e]);Cs(t)||ws(`delete`,t)}async runSecretToolCommand(e,t){try{return await this.runSecretTool(e,t)}catch(e){throw Es(e)}}};const Os=vs(`/usr/bin/security`),ks=f.object({version:f.literal(1),encoding:f.literal(`base64-json`),chunks:f.pipe(f.number(),f.integer(),f.minValue(1),f.maxValue(64)),sha256:f.pipe(f.string(),f.regex(/^[a-f0-9]{64}$/))});function As(e){return e.status===44}function js(e,t){return`${e}:chunk:${t}`}function Ms(e){let t=JSON.parse(e),n=fs(t);if(n!==null)return{kind:`direct`,payload:n};let r=f.safeParse(ks,t);if(r.success)return{kind:`legacy`,manifest:r.output};throw Error(`macOS Keychain credential has an unsupported format`)}function Ns(e,t){if(t.status===0)return;let n=Ps(t);throw Error(`macOS Keychain credential ${e} failed (security exited ${t.status??`without status`})${n===null?``:`: ${n}`}`)}function Ps(e){let t=e.stderr.toLowerCase();return e.status===124?`keychain operation timed out`:t.includes(`stdin isn't a terminal`)?`parent process has no terminal`:t.includes(`user interaction is not allowed`)?`keychain user interaction is not allowed`:t.includes(`authorization`)||t.includes(`denied`)?`keychain authorization was denied`:t.includes(`locked`)?`keychain appears to be locked`:null}function Fs(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)throw Error(`macOS Keychain credential values cannot contain control characters`)}return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Is(e,t){return[`add-generic-password`,`-s`,Fs(bs),`-a`,Fs(e),`-w`,Fs(t),`-U`].join(` `)+`
137
+ `}var Ls=class{runSecurity;constructor(e={}){if((e.platform??process.platform)!==`darwin`)throw Error(`macOS Keychain credential storage is only supported on macOS`);this.runSecurity=e.runSecurity??Os}async save(e,t){let n=ds(t),r=xs(e),i=await this.resolveLegacyChunkCount(r,64);if(await this.savePassword(r,gs(n)),!_s(await this.resolveDirectPassword(r),n))throw Error(`macOS Keychain credential save verification failed`);await this.deleteChunks(r,i)}async resolve(e){let t=xs(e),n=await this.resolveKeychainItem(t);return n===null?null:n.kind===`direct`?n.payload:this.resolveLegacyPayload(t,n.manifest)}async delete(e){let t=xs(e),n=await this.resolveLegacyChunkCount(t,64);await this.deleteChunks(t,n),await this.deletePassword(t)}async savePassword(e,t){Ns(`save`,await this.runSecurity([`-i`],Is(e,t)))}async resolvePassword(e){let t=await this.runSecurity([`find-generic-password`,`-a`,e,`-s`,bs,`-w`]);return As(t)?null:(Ns(`resolve`,t),t.stdout.replace(/\r?\n$/,``))}async resolveKeychainItem(e){let t=await this.resolvePassword(e);return t===null?null:Ms(t)}async resolveDirectPassword(e){let t=await this.resolveKeychainItem(e);if(t===null)return null;if(t.kind!==`direct`)throw Error(`macOS Keychain credential direct verification failed`);return t.payload}async resolveLegacyPayload(e,t){let n=[];for(let r=0;r<t.chunks;r++){let t=await this.resolvePassword(js(e,r));if(t===null)throw Error(`macOS Keychain credential chunk is missing`);n.push(t)}let r=n.join(``);if(h(`sha256`).update(r).digest(`hex`)!==t.sha256)throw Error(`macOS Keychain credential checksum mismatch`);return ds(JSON.parse(Buffer.from(r,`base64`).toString(`utf8`)))}async resolveLegacyChunkCount(e,t){let n=await this.resolvePassword(e);if(n===null)return 0;try{let e=Ms(n);return e.kind===`legacy`?e.manifest.chunks:0}catch{return t}}async deleteChunks(e,t){for(let n=0;n<t;n++)await this.deletePassword(js(e,n))}async deletePassword(e){let t=await this.runSecurity([`delete-generic-password`,`-a`,e,`-s`,bs]);As(t)||Ns(`delete`,t)}};function Rs(e={}){let t=e.platform??process.platform;if(t===`darwin`)return new Ls({platform:t});if(t===`linux`)return new Ds({platform:t});throw Error(`Catena credential storage is only supported on macOS and Linux`)}const zs=/^127(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/;function Bs(e){let t=e.replace(/^\[|\]$/g,``);return t===`localhost`||t===`::1`||zs.test(t)}function Vs(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`||t.protocol===`http:`&&Bs(t.hostname)}function Hs(e,t){if(!Vs(e))throw Error(`${t} must be an https:// URL (http:// is allowed only for a loopback host): "${e}"`)}const Us=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/,Ws=f.object({status:f.optional(f.literal(`linked`),`linked`),bank_url:f.pipe(f.string(),f.minLength(1)),agent_id:f.pipe(f.string(),f.minLength(1)),client_instance_id:f.pipe(f.string(),f.regex(Ko))}),Gs=f.object({status:f.literal(`pending_connection`),bank_url:f.pipe(f.string(),f.minLength(1)),client_instance_id:f.pipe(f.string(),f.regex(Ko)),created_at:f.pipe(f.string(),f.isoTimestamp())}),Ks=f.variant(`status`,[Ws,Gs]);f.object({version:f.literal(1),default_profile:f.optional(f.string()),profiles:f.record(f.string(),Ks),directories:f.optional(f.record(f.string(),f.string()))});const qs=f.object({version:f.literal(1),default_profile:f.optional(f.string()),profiles:f.record(f.string(),f.unknown()),directories:f.optional(f.record(f.string(),f.unknown()))});function Js(){return ne(process.env.HOME??j(),`.catena`)}function Ys(){return ne(Js(),`profiles.json`)}function Xs(e){return Us.test(e)}function Zs(e){if(!Xs(e))throw Error(`invalid profile name "${e}" (expected [a-zA-Z0-9][a-zA-Z0-9._-]{0,63})`)}function Qs(e){return typeof e!=`object`||!e||!(`code`in e)?!1:typeof e.code==`string`}function $s(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`profiles.json is not valid JSON: ${Co(e)}`,{cause:e})}if(typeof n==`object`&&n&&`version`in n){let e=n;if(e.version!==1)throw Error(`profiles.json version ${String(e.version)} is not supported (expected 1)`)}let r=f.parse(qs,n),i={};for(let[e,n]of Object.entries(r.profiles)){if(!Xs(e)){t?.(`profiles: dropping invalid profile name "${e}"`);continue}let r=f.safeParse(Ks,n);if(!r.success){t?.(`profiles: dropping malformed profile "${e}"`);continue}i[e]=r.output}if(r.default_profile!==void 0&&(Zs(r.default_profile),!Object.hasOwn(i,r.default_profile)))throw Error(`profiles.json default_profile "${r.default_profile}" is not linked`);let a={};for(let[e,n]of Object.entries(r.directories??{})){if(!te(e)){t?.(`profiles: dropping directory binding with relative path "${e}"`);continue}if(typeof n!=`string`||!Xs(n)){t?.(`profiles: dropping malformed directory binding "${e}"`);continue}a[e]=n}return{version:1,...r.default_profile===void 0?{}:{default_profile:r.default_profile},profiles:i,...Object.keys(a).length===0?{}:{directories:a}}}function ec(e){try{return $s(ee(Ys(),`utf-8`),e)}catch(e){if(e instanceof Error&&Qs(e)&&e.code===`ENOENT`)return{version:1,profiles:{}};throw e}}function tc(){T(Js(),{recursive:!0,mode:448}),S(Js(),448)}function nc(e){tc();let t=Ys(),n=`${t}.${_(6).toString(`hex`)}.tmp`;A(n,JSON.stringify(e,null,2)+`
138
+ `,{encoding:`utf-8`,mode:384}),D(n,t)}function rc(e,t){Zs(e);let n=f.parse(Ks,t);Hs(n.bank_url,`profile "${e}" bank_url`);let r=ec();nc({...r,profiles:{...r.profiles,[e]:n}})}function ic(e){return e.status===`linked`}function ac(e,t){return e.replace(/\/+$/,``)===t.replace(/\/+$/,``)}function oc(e,t){let n=Object.entries(ec().profiles).toSorted(([e],[t])=>e.localeCompare(t)).find(([,n])=>ic(n)&&n.agent_id===e&&ac(n.bank_url,t));return n===void 0?null:n[0]}function sc(e,t){let n=Object.fromEntries(Object.entries(e??{}).filter(([,e])=>t(e)));return Object.keys(n).length===0?{}:{directories:n}}function cc(e){Zs(e);let t=ec(),{[e]:n,...r}=t.profiles;nc({version:1,...t.default_profile===e||t.default_profile===void 0?{}:{default_profile:t.default_profile},profiles:r,...sc(t.directories,t=>t!==e)})}function lc(e){try{return E(re(e))}catch{return re(e)}}function uc(e){return ec().directories?.[lc(e)]??null}function dc(e,t){Zs(t);let n=ec();if(!Object.hasOwn(n.profiles,t))throw Error(`Profile "${t}" is not linked. Run catena link --profile ${t} <agent-id>.`);let r=lc(e);return nc({...n,directories:{...n.directories,[r]:t}}),r}function fc(e){let t=ec(),n=lc(e);if(t.directories===void 0||!Object.hasOwn(t.directories,n))return{directory:n,removed:!1};let{[n]:r,...i}=t.directories,{directories:a,...o}=t;return nc({...o,...Object.keys(i).length===0?{}:{directories:i}}),{directory:n,removed:!0}}function pc(e){return Zs(e),ec().profiles[e]??null}function mc(){return`client_${_(16).toString(`hex`)}`}function hc(e,t){let n=pc(e);return t.agent_id===void 0?gc(e,t.bank_url,n):_c(e,t.bank_url,t.agent_id,n)}function gc(e,t,n){if(n?.status===`linked`)throw Error(`Profile "${e}" is already linked. Choose a different profile name to start agent connection.`);let r=(n?.status===`pending_connection`&&ac(n.bank_url,t)?n.client_instance_id:null)??mc();return rc(e,{status:`pending_connection`,bank_url:t,client_instance_id:r,created_at:n?.status===`pending_connection`?n.created_at:new Date().toISOString()}),r}function _c(e,t,n,r){if(r?.status===`linked`){if(r.agent_id!==n)throw Error(`Profile "${e}" is already linked to a different agent (${r.agent_id}). Link ${n} under a different --profile, or run 'catena unlink --profile ${e}' first to repoint it (add --force if that agent's credential is missing or revoked).`);if(!ac(r.bank_url,t))throw Error(`Profile "${e}" is already linked to this agent on a different bank (${r.bank_url}). Link under a different --profile, or run 'catena unlink --profile ${e}' first (add --force if that credential is missing or revoked).`);return r.client_instance_id}let i=(r?.status===`pending_connection`&&ac(r.bank_url,t)?r.client_instance_id:null)??mc();return rc(e,{status:`linked`,bank_url:t,agent_id:n,client_instance_id:i}),i}function vc(e){Zs(e);let t=ec();if(!Object.hasOwn(t.profiles,e))throw Error(`Profile "${e}" is not linked. Run catena link --profile ${e} <agent-id>.`);nc({...t,default_profile:e})}function yc(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[^a-z0-9]+/,``).slice(0,64);return Xs(t)?t:`agent`}function bc(e,t){if(!t(e))return e;for(let n=2;;n++){let r=`${e.slice(0,64-String(n).length-1)}-${n}`;if(!t(r))return r}}function xc(e){Zs(e.reservationName),Zs(e.profileName);let t=f.parse(Ks,e.profile);Hs(t.bank_url,`profile "${e.profileName}" bank_url`);let n=ec(),{[e.reservationName]:r,...i}=n.profiles;if(!Object.hasOwn(n.profiles,e.reservationName)||r.client_instance_id!==t.client_instance_id)throw Error(`Link reservation "${e.reservationName}" changed during setup (a concurrent link from this directory?). Re-run 'catena link'.`);if(e.profileName!==e.reservationName&&Object.hasOwn(i,e.profileName))throw Error(`Profile "${e.profileName}" already exists; cannot finalize link under that name.`);let a=Object.fromEntries(Object.entries(n.directories??{}).map(([t,n])=>[t,n===e.reservationName?e.profileName:n]));nc({version:1,...n.default_profile===void 0?{}:{default_profile:n.default_profile===e.reservationName?e.profileName:n.default_profile},profiles:{...i,[e.profileName]:t},...Object.keys(a).length===0?{}:{directories:a}})}function Sc(e){return e??Rs()}async function Cc(e,t){let n;try{n=pc(e.profileName)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:Co(t)}}if(n===null)return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:`Profile "${e.profileName}" is not linked. Run 'catena link --profile ${e.profileName}' to authenticate.`};try{Hs(n.bank_url,`profile "${e.profileName}" bank_url`)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:Co(t)}}if(n.status===`pending_connection`)return{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" is waiting for agent connection approval. Run 'catena link --profile ${e.profileName}' to finish setup.`};let r;try{r=await Sc(t).resolve(n.client_instance_id)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential unavailable for ${n.agent_id}: ${Co(t)}. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}}return r===null||r.version===`signer-1`?{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential unavailable for ${n.agent_id}. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}:r.version===1?{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential for ${n.agent_id} has no signing key. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}:{ok:!0,profileName:e.profileName,bankUrl:n.bank_url,agentId:n.agent_id,clientInstanceId:n.client_instance_id,signer:r.signer}}const wc={name:`catena-cli`,version:se},Tc=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Ec(e,t){if(!Tc.test(e))throw Error(`${t} must be a valid HTTP token`)}function Dc(e,t){let n=!1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r<32||r===127||r>255){n=!0;break}}if(n||/[()\\]/.test(e))throw Error(`${t} must not contain parentheses, backslashes, control characters, or characters outside Latin-1`)}function Oc(e){Ec(e.name,`appInfo.name`),e.version!==void 0&&Ec(e.version,`appInfo.version`),e.url!==void 0&&Dc(e.url,`appInfo.url`);let t=e.version===void 0?e.name:`${e.name}/${e.version}`;return{"User-Agent":e.url===void 0?t:`${t} (${e.url})`}}const kc=`https://api.catena.com`,Ac=`CATENA_PROFILE`;function jc(e,t,n,r){if(e.directories===void 0)return null;let i;try{i=E(t)}catch{return null}let a=Object.entries(e.directories).map(([e,t])=>[e.replace(/\/+$/,``)||`/`,t]).filter(([e])=>i===e||i.startsWith(e===`/`?`/`:`${e}/`)).toSorted(([e],[t])=>t.length-e.length),o=null;for(let[t,n]of a){if(Object.hasOwn(e.profiles,n))return n;o??=`${t} -> "${n}"`}if(o===null)return null;if(n===`error`)throw Error(`This directory is bound to a profile that no longer exists (${o}). Run 'catena profiles unbind' here, bind it with 'catena profiles bind <name>', or run 'catena link' to re-establish it.`);return r?.(`profiles: ignoring stale directory binding ${o}`),null}function Mc(e,t,n){if(e.flag!==void 0&&e.flag.length>0)return Zs(e.flag),{name:e.flag,source:`flag`};if(e.env!==void 0&&e.env.length>0){if(!Xs(e.env))throw Error(`${Ac} is set to an invalid profile name "${e.env}"`);return{name:e.env,source:`env`}}if(e.cwd!==void 0){let r=jc(t,e.cwd,n,e.log);if(r!==null)return{name:r,source:`directory`}}return t.default_profile===void 0?null:{name:t.default_profile,source:`default`}}function Nc(e){return Mc(e,ec(e.log),`ignore`)}function Pc(e){let t=ec(e.log),n=Mc(e,t,`error`);if(n!==null)return n;let r=Object.keys(t.profiles),i=Object.entries(t.profiles).filter(([,e])=>ic(e)).map(([e])=>e);if(i.length===1){let[e]=i;return{name:e,source:`single`}}if(i.length===0){if(r.length===1){let[e]=r;return{name:e,source:`single`}}return r.length>1&&e.log?.(`profiles: ignoring ${r.length} pending profiles (${r.toSorted().join(`, `)}); none is linked`),{name:`default`,source:`fallback`}}throw Error(`Multiple profiles exist and none is selected (${i.toSorted().join(`, `)}). Pass --profile <name>, set ${Ac}, run 'catena profiles use <name>', or run 'catena link' from an agent directory to bind it.`)}function Fc(e){return So({baseUrl:e.bankUrl,privateKeyHex:e.signer.privateKeyHex,appInfo:wc})}function Ic(){return Rs()}async function Lc(e){let t;try{t=Pc({flag:e,env:process.env[Ac],cwd:process.cwd(),log:e=>console.error(e)}).name}catch(e){return Z(e)}let n=await Cc({profileName:t,fallbackBankUrl:kc},void 0);return n.ok||Z(n.message),Fc(n)}const Rc=new Set([`unknown_key`,`key_revoked`,`client_unlinked`]),zc=new Set([`signature_auth_disabled`,`missing_auth`]);function Bc(e,t){if(!(e instanceof mo)||e.code===void 0)return e;let n=t===void 0?`catena link`:`catena link --profile ${t}`;return Rc.has(e.code)?Error(`This machine's signing key was rejected by the bank (${e.code}). Run '${n}' to re-authenticate.`):e.code===`client_upgrade_required`?Error(`This CLI version (${wc.version}) is no longer supported by the bank. Run 'npm i -g @catena/cli' and retry.`):zc.has(e.code)?Error(`This bank does not support key-based authentication (${e.code}). Upgrade the bank, or use an older CLI release that authenticates with session tokens.`):e.code===`invalid_signature`&&e.message.includes(`created_out_of_window`)?Error(`The bank rejected this request's timestamp (created_out_of_window). Check this machine's system clock and retry.`):e}function Vc(e,t){console.log(t?.compact?JSON.stringify(e):JSON.stringify(e,null,2))}function Hc(e){return e.profile===void 0||e.profile.length===0?void 0:e.profile}async function Uc(e,t){try{return await t(await Lc(e))}catch(t){return Z(Bc(t,e))}}function Wc(e,t){return async(n,r)=>{let i=await Uc(e,n);return Vc(i,t),await new Promise(e=>{process.stdout.write(``,()=>e())}),process.exit(r?.exitCode?r.exitCode(i):0)}}function Gc(e){return Wc(Hc(e),{compact:e.json===!0})}const Kc=f.pipe(f.string(),f.regex(/^\d+$/,`must be a non-negative integer`),f.transform(Number),f.maxValue(2**53-1,`must be at most ${2**53-1}`)),qc=f.pipe(Kc,f.maxValue(200,`must be at most 200`)),Jc={profile:Wo,json:Go},Yc=$(Jc),Xc=$({account:jo({description:`Account id`,required:!0,schema:qo}),...Jc}),Zc=$({account:jo({description:`Account id`,required:!0,schema:qo}),start:Q({description:`Only include transactions at or after this ISO 8601 time`}),end:Q({description:`Only include transactions at or before this ISO 8601 time`}),limit:Q({description:`Maximum transactions to return (default 50, max 200)`,schema:qc}),offset:Q({description:`Number of transactions to skip for pagination`,schema:Kc}),...Jc}),Qc=$({account:jo({description:`Account id`,required:!0,schema:qo}),network:Qo({description:`Deposit network; defaults to ${Xo}. Availability depends on the connected environment.`,default:Xo}),asset:Po({description:`Deposit asset (${Yo.join(`|`)})`,choices:Yo,default:`usdc`}),...Jc}),$c=l({meta:{name:`list`,description:`List accounts accessible under the agent's policy`},args:Yc.args,async run({args:e}){await Gc(Yc.parse(e))(e=>e.listAccounts())}}),el=l({meta:{name:`balance`,description:`Request an account balance through the policy engine`},args:Xc.args,async run({args:e}){let t=Xc.parse(e);await Gc(t)(e=>e.getAccountBalance(t.account))}}),tl=l({meta:{name:`transactions`,description:`Read an account's transaction history through the policy engine`},args:Zc.args,async run({args:e}){let t=Zc.parse(e);await Gc(t)(e=>e.listAccountTransactions(t.account,{start:t.start,end:t.end,limit:t.limit,offset:t.offset}))}}),nl=l({meta:{name:`deposit-address`,description:`Read an account deposit address through the policy engine`},args:Qc.args,async run({args:e}){let t=Qc.parse(e);await Gc(t)(e=>e.getAccountDepositAddress(t.account,{network:t.network,asset:t.asset}))}}),rl=l({meta:{name:`accounts`,description:`Inspect bank accounts`},subCommands:{list:$c,balance:el,transactions:tl,"deposit-address":nl}}),il=f.pipe(f.string(`Idempotency key must be a string`),f.minLength(1,`Idempotency key must not be empty`),f.maxLength(255,`Idempotency key is too long (max 255 characters)`)),al=f.pipe(f.string(),f.minLength(1,`must not be empty`)),ol=f.pipe(f.string(),f.trim(),f.email(`must be a valid email address`)),sl={profile:Wo,json:Go},cl=$({address:Q({description:`Only counterparties with a wallet rail matching this address (0x…)`,schema:Zo}),network:Qo({description:`Only counterparties with a wallet rail on this network (e.g. base)`}),...sl}),ll=Q({description:`Counterparty name`,required:!0,schema:al}),ul=Q({description:`Optional contact email`,schema:ol}),dl=$({name:ll,email:Q({description:`Contact email; creating the counterparty sends no email`,required:!0,schema:ol}),...sl}),fl=$({name:Q({description:`Counterparty name; required without a subcommand`,schema:al}),email:Q({description:`Contact email; required without a subcommand; creating the counterparty sends no email`,schema:ol}),...sl}),pl=$({name:ll,"bank-name":Q({description:`Receiving bank name`,required:!0,schema:al}),"routing-number":Q({description:`9-digit ABA routing number`,required:!0,schema:al}),"account-number":Q({description:`Receiving bank account number`,required:!0,schema:al}),"account-type":Po({description:`checking | savings (default checking)`,choices:[`checking`,`savings`]}),"address-street":Q({description:`Street address of the receiving bank account holder`,required:!0,schema:al}),"address-city":Q({description:`City`,required:!0,schema:al}),"address-state":Q({description:`State (e.g. NY)`,required:!0,schema:al}),"address-postal-code":Q({description:`Postal code`,required:!0,schema:al}),"address-country":Q({description:`Default USA`}),email:ul,...sl}),ml=$({name:ll,address:Q({description:`Wallet address (0x… or ENS name on EVM networks)`,required:!0,schema:al}),network:Qo({description:`Wallet network; defaults to ${Xo}. Availability depends on the connected environment.`,default:Xo}),email:ul,...sl}),hl=$({counterparty:jo({description:`Counterparty id`,required:!0,schema:qo}),bank:No({description:`Request bank account details`,default:!1}),wallet:No({description:`Request wallet details`,default:!1}),"idempotency-key":Q({description:`Optional key to replay this exact submission`,schema:il}),...sl}),gl=l({meta:{name:`list`,description:`List counterparties available under the agent's policy`},args:cl.args,async run({args:e}){let t=cl.parse(e);await Gc(t)(e=>e.listCounterparties({address:t.address,network:t.network}))}});function _l(e){return e&&e.length>0?e:void 0}function vl(e){let t=_l(e.email);return{type:`create_counterparty`,name:e.name,email:t,rail:{type:`bank`,bankName:e[`bank-name`],routingNumber:e[`routing-number`],accountNumber:e[`account-number`],addressStreet:e[`address-street`],addressCity:e[`address-city`],addressState:e[`address-state`],addressPostalCode:e[`address-postal-code`],...e[`account-type`]?{accountType:e[`account-type`]}:{},...e[`address-country`]?{addressCountry:e[`address-country`]}:{}}}}function yl(e){let t=_l(e.email);return{type:`create_counterparty`,name:e.name,email:t,rail:{type:`wallet`,walletAddress:e.address,network:e.network}}}function bl(e){return{type:`create_counterparty`,name:e.name,email:e.email}}const xl=l({meta:{name:`email`,description:`Create a counterparty with an email and no payment details. Sends no email.`},args:dl.args,async run({args:e}){let t=dl.parse(e);await Gc(t)(e=>e.submitIntent({action:bl(t)}))}}),Sl=l({meta:{name:`bank`,description:`Request bank counterparty creation through the policy engine. Prints an intent envelope.`},args:pl.args,async run({args:e}){let t=pl.parse(e),n=vl(t);await Gc(t)(e=>e.submitIntent({action:n}))}}),Cl=l({meta:{name:`wallet`,description:`Request wallet counterparty creation through the policy engine. Prints an intent envelope.`},args:ml.args,async run({args:e}){let t=ml.parse(e);await Gc(t)(e=>e.submitIntent({action:yl(t)}))}}),wl=l({meta:{name:`create`,description:`Request counterparty creation through the policy engine. Without a subcommand, --name and --email create a record without payment details and send no email.`},args:fl.args,default:`email`,subCommands:{email:xl,bank:Sl,wallet:Cl}}),Tl=l({meta:{name:`request-details`,description:`Ask a counterparty to provide bank details, wallet details, or both through the policy engine.`},args:hl.args,async run({args:e}){let t=hl.parse(e);!t.bank&&!t.wallet&&Z(`Select at least one of --bank or --wallet`),await Gc(t)(e=>e.submitIntent({action:{type:`request_counterparty_details`,counterpartyId:t.counterparty,methods:{bank:t.bank,wallet:t.wallet}},...t[`idempotency-key`]?{idempotencyKey:t[`idempotency-key`]}:{}}))}}),El=l({meta:{name:`counterparties`,description:`Inspect, create, and request details from counterparties`},subCommands:{list:gl,create:wl,"request-details":Tl}}),Dl=4e3;async function Ol(){process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}async function kl(e){return e===void 0?(process.stdin.isTTY&&Z(`<message>: pass a quoted message or pipe it on stdin; a message starting with "-" needs -- before it (catena feedback -- "<message>") or stdin`),Ol()):e}const Al=$({message:jo({description:`Plain-text feedback (1-4000 chars); omit to pipe on stdin`}),profile:Wo,json:Go}),jl=l({meta:{name:`feedback`,description:`Send free-form feedback about Catena to the Catena team`},args:Al.args,async run({args:e}){(Array.isArray(e._)?e._:[]).length>1&&Z(`<message>: pass the message as a single quoted argument`);let t=Al.parse(e),n=(await kl(t.message)).trim();n.length===0&&Z(`<message>: must not be empty`),n.length>Dl&&Z(`<message>: must be at most ${Dl} characters (got: ${n.length})`),await Gc(t)(async e=>(await e.submitFeedback(n),{ok:!0}))}});function Ml(e){return`# Catena CLI Agent Guide
139
139
 
140
140
  CLI version: ${e}
141
141
 
@@ -312,6 +312,16 @@ Use the rail-specific help for exact required fields, choices, and defaults:
312
312
  Pass destination details from the user. Do not invent missing routing, account,
313
313
  address, wallet, network, or contact details.
314
314
 
315
+ When an existing counterparty has an email but no usable payment details, ask
316
+ for bank details, wallet details, or both:
317
+
318
+ catena counterparties request-details cp_... --bank
319
+
320
+ Pass at least one of \`--bank\` or \`--wallet\`. The request goes through policy
321
+ and may wait for human approval. It returns before the counterparty responds;
322
+ use \`intents get <id>\` to follow the intent and \`counterparties list\` to see
323
+ details after they are provided.
324
+
315
325
  All forms return an intent envelope. When \`.status\` is \`completed\`, the new
316
326
  counterparty is on \`.data.counterparty\`; a rail-specific creation also returns
317
327
  its \`rails[].id\` for a follow-up send. Creation routed to approval is
@@ -331,6 +341,12 @@ the flag, omit it again. Never choose a fresh key merely because the response
331
341
  was lost. If an error reports an intent id with an unknown submission outcome,
332
342
  do not resubmit it; poll \`catena intents get <id>\`.
333
343
 
344
+ For \`counterparties request-details\`, an omitted idempotency key is not derived
345
+ from the request. A retry is rejected while the invitation is outstanding; the
346
+ error includes its safe state, requested methods, and expiry. After expiry, the
347
+ same command creates a new intent. When exact replay matters, set an explicit
348
+ \`--idempotency-key\` on the first attempt and reuse it on every attempt.
349
+
334
350
  For \`send\` and \`transfer\`, deduplication of a keyless retry lasts about 15
335
351
  minutes after the original settles; past that an identical command is a second
336
352
  payment, so retry promptly or pass an explicit \`--idempotency-key\` to hold one
@@ -498,13 +514,13 @@ you need, tell the Catena team:
498
514
 
499
515
  The message must be 1-4000 characters and is write-only. Longer messages can be
500
516
  piped on stdin instead of passed as an argument.
501
- `}const xl=l({meta:{name:`guide`,description:`Print the Catena CLI agent operating guide`},run(){console.log(bl(oe))}}),Sl=W({id:pe({description:`Intent id (e.g. int_…)`,required:!0,schema:we}),profile:Se,json:Ce}),Cl=l({meta:{name:`get`,description:`Look up the current state of an intent created by this agent`},args:Sl.args,async run({args:e}){let t=Sl.parse(e);await Ic(t)(e=>e.getIntent(t.id))}}),wl=l({meta:{name:`intents`,description:`Inspect intent receipts returned by governed operations`},subCommands:{get:Cl}});function Tl(e=process.env,t=process.platform){return!!(e.SSH_CONNECTION||e.SSH_TTY||t===`linux`&&!e.DISPLAY&&!e.WAYLAND_DISPLAY)}function El(e){let t;try{t=D(ne(e))}catch{return!1}if(t===`/`)return!0;try{let e=D(process.env.HOME??M());return t===e||e.startsWith(`${t}/`)}catch{return!0}}function Dl(e){e&&process.stderr.write(`Failed to open browser: ${e.message}\n`)}function Ol(e){process.platform===`darwin`?y(`open`,[e],Dl):process.platform===`win32`?y(`cmd`,[`/c`,`start`,``,e],Dl):y(`xdg-open`,[e],Dl)}function kl(e){if(typeof e!=`object`||!e)return;let t=e;return typeof t.message==`string`?t.message:typeof t.error==`string`?t.error:void 0}function Al(e){return typeof e!=`object`||!e||!(`access_token`in e)?!1:typeof e.access_token==`string`}function jl(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.agentId==`string`&&typeof t.name==`string`&&typeof t.sessionToken==`string`&&(t.activated===void 0||typeof t.activated==`boolean`)}function Ml(e){if(typeof e!=`object`||!e)return!1;let t=e;return Wo.some(e=>e===t.status)&&(t.publicKeyHex===void 0||typeof t.publicKeyHex==`string`)&&(t.reason===void 0||typeof t.reason==`string`)}async function Nl(e){let{bankUrl:t,authCode:n,verifier:r,redirectUri:i,agentId:a,clientInstanceId:o,clientId:s,clientLabel:c,log:l=()=>{},appInfo:u,existingSigner:d,generateSignerKeypair:f=Ma}=e,p=yc(u);l(`Exchanging authorization code...`);let m=await fetch(`${t}/v1/auth/oauth2/token`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,...p},body:new URLSearchParams({grant_type:`authorization_code`,code:n,code_verifier:r,client_id:s,redirect_uri:i}).toString()});if(!m.ok)return{ok:!1,message:kl(await m.json().catch(()=>({message:`Token exchange failed`})))??m.statusText};let h=await m.json();if(!Al(h))return{ok:!1,message:`Token exchange response missing access_token`};l(`Claiming agent...`);let g=d?{algorithm:d.algorithm,privateKeyHex:d.privateKeyHex,publicKeyHex:d.publicKeyHex}:f(),_=await fetch(`${t}/v1/agent-api/claim`,{method:`POST`,headers:{"Content-Type":`application/json`,...p,Authorization:`Bearer ${h.access_token}`},body:JSON.stringify({agentId:a,clientInstanceId:o,...c===void 0?{}:{clientLabel:c}})});if(!_.ok)return{ok:!1,message:kl(await _.json().catch(()=>({message:`Claim failed`})))??_.statusText};let v=await _.json();return jl(v)?Pl({bankUrl:t,claim:v,clientInstanceId:o,signerKeypair:g,identityHeaders:p,log:l}):{ok:!1,message:`Claim response missing required fields`}}async function Pl(e){let{bankUrl:t,claim:n,clientInstanceId:r,signerKeypair:i,identityHeaders:a}=e;(e.log??(()=>{}))(`Registering signer...`);let o=await Il({bankUrl:t,sessionToken:n.sessionToken,keypair:i,identityHeaders:a});return o.status===`registration_failed`?(n.activated!==!1&&await Ll({bankUrl:t,sessionToken:n.sessionToken,identityHeaders:a}),o.reason===`public_key_conflict`?{ok:!1,message:`This device's signing key conflicts with the one the bank already holds for this agent, or that key is already registered to another agent. Re-running link will not fix this; this agent's signing key cannot be reset automatically, so ask an operator or support to reset it before linking again.`}:{ok:!1,message:`Signer registration failed (${o.reason??`unknown`}). Run link again to retry.`}):{ok:!0,result:{agentId:n.agentId,clientInstanceId:r,agentName:n.name,signer:{...i,registration:o}}}}function Fl(e){return typeof e!=`object`||!e||!(`signer`in e)?!1:Ml(e.signer)}async function Il(e){let t;try{t=await fetch(`${e.bankUrl}/v1/agent-api/signer/register`,{method:`POST`,headers:{"Content-Type":`application/json`,...e.identityHeaders,Authorization:`Bearer ${e.sessionToken}`},body:JSON.stringify({signer:{algorithm:e.keypair.algorithm,publicKeyHex:e.keypair.publicKeyHex}})})}catch{return{status:`registration_failed`,reason:`registration_request_failed`}}if(t.status===409)return{status:`registration_failed`,reason:`public_key_conflict`};if(!t.ok)return{status:`registration_failed`,reason:`provider_registration_failed`};let n=await t.json().catch(()=>null);return Fl(n)?n.signer:{status:`registration_failed`,reason:`registration_response_malformed`}}async function Ll(e){try{await fetch(`${e.bankUrl}/v1/agent-api/unlink`,{method:`POST`,headers:{...e.identityHeaders,Authorization:`Bearer ${e.sessionToken}`}})}catch{}}function Rl(e){return`${e}-signer`}async function zl(e,t){let n=await e.resolve(t);if(n!==null&&`signer`in n)return n.signer;let r=await e.resolve(Rl(t));if(r!==null&&`signer`in r)return r.signer}async function Bl(e,t,n=Ma){let r=await zl(e,t);if(r!==void 0)return r;let i=is(n());return await e.save(Rl(t),i),i.signer}const Vl=[53682,53683,53684,53685,53686,53687];function Hl(e){return new Promise((t,n)=>{let r=0,i=()=>{if(r>=Vl.length){n(Error(`No registered loopback callback ports are available`));return}let a=Vl[r],o=t=>{if(e.off(`error`,o),t.code===`EADDRINUSE`){r++,i();return}n(t)};e.once(`error`,o),e.listen(a,`127.0.0.1`,()=>{e.off(`error`,o),t(a)})};i()})}async function Ul(e){let{bankUrl:t,agentId:n,clientInstanceId:r,clientId:i,clientLabel:a,timeoutMs:o=3e5,log:s=()=>{},appInfo:c,existingSigner:l}=e;Ns(t,`bankUrl`);let u=_(32).toString(`base64url`),d=h(`sha256`).update(u).digest(`base64url`),f=_(16).toString(`hex`),p=e=>{let n=new URL(`${t}/link-complete`);return n.searchParams.set(`linked`,e),n.toString()},m=e=>{let n=new URL(`${t}/link-complete`);return n.searchParams.set(`error`,e),n.toString()};return new Promise((e,h)=>{let g=0,_=!1,v=null,y=t=>{_||(_=!0,v&&clearTimeout(v),S.close(),e(t))},b=e=>{_||(_=!0,v&&clearTimeout(v),S.close(),h(e))},x=e=>{s(`Link failed: ${e}`),y(null)},S=P((e,t)=>{C(e,t).catch(e=>{let n=kl(e)??`Unexpected error`;t.headersSent||(t.writeHead(302,{Location:m(n)}),t.end()),s(`Link failed: ${n}`),y(null)})});async function C(e,o){let d=new URL(e.url??`/`,`http://localhost`);if(d.pathname!==`/callback`){o.writeHead(404),o.end(`Not found`);return}let h=d.searchParams.get(`error`);if(h){let e=d.searchParams.get(`error_description`)??h;o.writeHead(302,{Location:m(e)}),o.end(),x(`OAuth error: ${e}`);return}if(d.searchParams.get(`state`)!==f){o.writeHead(302,{Location:m(`State mismatch during OAuth callback`)}),o.end(),x(`State mismatch during OAuth callback`);return}let _=d.searchParams.get(`code`);if(!_){o.writeHead(302,{Location:m(`Missing authorization code`)}),o.end(),x(`Missing authorization code`);return}let v=`http://127.0.0.1:${g}/callback`,b=await Nl({bankUrl:t,authCode:_,verifier:u,redirectUri:v,agentId:n,clientInstanceId:r,clientId:i,clientLabel:a,log:s,appInfo:c,existingSigner:l});if(!b.ok){o.writeHead(302,{Location:m(b.message)}),o.end(),s(`Link failed: ${b.message}`),y(null);return}o.writeHead(302,{Location:p(b.result.agentId)}),o.end(),y(b.result)}Hl(S).then(e=>{g=e;let n=`http://127.0.0.1:${g}/callback`,r=`${t}/v1/auth/oauth2/authorize?`+new URLSearchParams({response_type:`code`,client_id:i,redirect_uri:n,scope:`openid email profile offline_access`,code_challenge:d,code_challenge_method:`S256`,state:f}).toString();s(`Opening browser for authentication...`),Ol(r),s(`If browser didn't open, visit: ${r}`)}).catch(b),v=setTimeout(()=>{x(`Timed out waiting for authentication`)},o),v.unref()})}function Wl(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.deviceCode==`string`&&typeof t.userCode==`string`&&typeof t.verificationUri==`string`&&typeof t.verificationUriComplete==`string`&&typeof t.expiresIn==`number`&&typeof t.interval==`number`}function Gl(e){if(typeof e!=`object`||!e)return{};let t=e;return{code:typeof t.code==`string`?t.code:void 0,message:typeof t.error==`string`?t.error:void 0}}function Kl(e){return new Promise(t=>{setTimeout(t,e)})}function ql(e){let t={clientInstanceId:e.clientInstanceId,...e.clientLabel===void 0?{}:{clientLabel:e.clientLabel}};return e.scope===`agent:connect`?{scope:`agent:connect`,...t,...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName}}:e.scope===`agent:link`?{scope:`agent:link`,agentId:e.agentId,...t}:{agentId:e.agentId,...t}}async function Jl(e){let{bankUrl:t,clientInstanceId:n,onUserCode:r,log:i=()=>{},appInfo:a,existingSigner:o,generateSignerKeypair:s=Ma,sleep:c=Kl}=e;Ns(t,`bankUrl`);let l=yc(a),u=e=>(i(`Link failed: ${e}`),null),d;try{d=await fetch(`${t}/v1/agent-link/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`,...l},body:JSON.stringify(ql(e))})}catch{return u(`Could not reach the bank to start the device flow`)}if(!d.ok)return u(Gl(await d.json().catch(()=>null)).message??d.statusText);let f=await d.json();if(!Wl(f))return u(`Device authorization response missing required fields`);r({userCode:f.userCode,verificationUri:f.verificationUri,verificationUriComplete:f.verificationUriComplete,expiresInSeconds:f.expiresIn});let p=await Yl({bankUrl:t,grant:f,identityHeaders:l,sleep:c});if(!p.ok)return u(p.message);let m=p.body;if(!jl(m))return u(`Device token response missing required fields`);i(`Approved. Claiming agent...`);let h=await Pl({bankUrl:t,claim:m,clientInstanceId:n,signerKeypair:o?{algorithm:o.algorithm,privateKeyHex:o.privateKeyHex,publicKeyHex:o.publicKeyHex}:s(),identityHeaders:l,log:i});return h.ok?h.result:u(h.message)}async function Yl(e){let{bankUrl:t,grant:n,identityHeaders:r,sleep:i}=e,a=Date.now()+n.expiresIn*1e3,o=Math.max(n.interval,1)*1e3,s=o;for(;Date.now()+o<=a;){await i(o);let e;try{e=await fetch(`${t}/v1/agent-link/device/token`,{method:`POST`,headers:{"Content-Type":`application/json`,...r},body:JSON.stringify({deviceCode:n.deviceCode})})}catch{s=Math.min(s*2,6e4),o=Math.max(o,s);continue}if(s=o,e.ok){let t=await e.json().catch(()=>null);return t===null?{ok:!1,message:`The bank returned an unreadable token response`}:{ok:!0,body:t}}let a=Gl(await e.json().catch(()=>null));if(a.code!==`authorization_pending`){if(a.code===`slow_down`){o+=5e3;continue}return a.code===`expired_token`?{ok:!1,message:`The device code expired before approval. Run link again`}:{ok:!1,message:a.message??`The request was denied`}}}return{ok:!1,message:`Timed out waiting for approval`}}function Xl(e){if(typeof e!=`object`||!e)return!1;let t=e,n=t.signer;return t.credential===`signing_key`&&typeof t.agentId==`string`&&typeof t.name==`string`&&typeof t.keyThumbprint==`string`&&typeof t.activated==`boolean`&&typeof n==`object`&&!!n&&typeof n.status==`string`}async function Zl(e){let{bankUrl:t,clientInstanceId:n,onUserCode:r,log:i=()=>{},appInfo:a,sleep:o=Kl}=e;Ns(t,`bankUrl`);let s=yc(a),c=e=>(i(`Link failed: ${e}`),null),l={clientInstanceId:n,signer:{algorithm:`p256`,publicKeyHex:e.publicKeyHex},...e.clientLabel===void 0?{}:{clientLabel:e.clientLabel}},u=e.agentId===void 0?{scope:`agent:connect:service`,...l,...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName}}:{scope:`agent:link:service`,agentId:e.agentId,...l},d;try{d=await fetch(`${t}/v1/agent-link/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`,...s},body:JSON.stringify(u)})}catch{return c(`Could not reach the bank to start the device flow`)}if(!d.ok){let e=Gl(await d.json().catch(()=>null));return e.code===`validation_failed`?c(`The bank rejected the request, which usually means it does not support --service yet. Nothing was created. Upgrade the bank and retry`):c(e.message??d.statusText)}let f=await d.json();if(!Wl(f))return c(`Device authorization response missing required fields`);r({userCode:f.userCode,verificationUri:f.verificationUri,verificationUriComplete:f.verificationUriComplete,expiresInSeconds:f.expiresIn});let p=await Yl({bankUrl:t,grant:f,identityHeaders:s,sleep:o});return p.ok?jl(p.body)?c(`This bank does not support --service yet: it created a session link for agent ${p.body.agentId}. Unlink it in the console before retrying`):Xl(p.body)?(i(`Approved. Signing key registered.`),{agentId:p.body.agentId,agentName:p.body.name,keyThumbprint:p.body.keyThumbprint,activated:p.body.activated,signerStatus:p.body.signer.status,...p.body.signer.reason===void 0?{}:{signerReason:p.body.signer.reason}}):c(`Device token response missing required fields`):c(p.message)}const Ql=W({"agent-id":pe({description:`Optional agent ID shown in the Catena console; omit to create and link a new agent`,schema:we}),"bank-url":z({description:`Bank API URL (defaults to $CATENA_API_URL or prod)`,default:process.env.CATENA_API_URL??`https://api.catena.com`}),browser:me({description:`Open the browser PKCE flow (default)`,negativeDescription:`Skip the browser and link with a device code you approve from another machine`,default:!0}),name:z({description:`Suggested name for an agent created from this link; only used when agent-id is omitted`}),service:me({description:`Provision a deployed-service signing credential instead of linking this machine: approval registers a P-256 key, no session tokens are minted, and nothing is stored locally. Interactive agent hosts must NOT use this`,default:!1}),"public-key":z({description:`With --service: register this existing compressed P-256 public key (the deployment already holds the private key) instead of generating a keypair`}),profile:Se}),$l=/^0[23][0-9a-f]{64}$/;function eu(e){let t=Math.round(e.expiresInSeconds/60);console.log(`\n To approve this link, visit: ${e.verificationUri}`),console.log(` and enter the code: ${e.userCode}`),console.log(`\n Or open: ${e.verificationUriComplete}`),console.log(`\n Waiting for approval (expires in ${t} minutes)...`)}function tu(e){console.log(`
502
- Keep this generated keypair if the approval completed before the CLI failed:`),console.log(`\n CATENA_AGENT_PUBLIC_KEY=${e.publicKeyHex}`),console.log(` CATENA_AGENT_PRIVATE_KEY=${e.privateKeyHex}`)}function nu(e){switch(e){case`signer_key_conflict`:return` Wallet-send signer: not registered (signer key conflict); unlink the conflicting service link or re-run with the linked agent ID`;case`provider_registration_failed`:return` Wallet-send signer: not registered (provider registration failed); retry after the provider recovers`;case void 0:return` Wallet-send signer: not registered (registration failed); retry after checking the link status`;default:return` Wallet-send signer: not registered (${e}); retry after checking the link status`}}function ru({agentId:e,suggestedAgentName:t,browserRequested:n,isHeadless:r}){return e===void 0?{kind:`device-connect`,deviceTarget:{scope:`agent:connect`,...t===void 0?{}:{suggestedAgentName:t}}}:n?r()?{kind:`device-link`,deviceTarget:{agentId:e},notice:`No browser available — using device code flow.`}:{kind:`pkce-link`,agentId:e}:{kind:`device-link`,deviceTarget:{agentId:e}}}function iu(e){let t=h(`sha256`).update(D(process.cwd())).digest(`hex`).slice(0,16);return`${uc(e??`agent`).slice(0,47)}-${t}`}function au(e){try{let t=process.cwd();if(El(t))return null;let n=tc(t);return{directory:nc(t,e),reboundFrom:n!==null&&n!==e?n:null}}catch{return console.error(`Warning: could not bind the current directory to profile "${e}".`),null}}const ou=l({meta:{name:`link`,description:`Link an existing agent, or create and link a new agent when agent-id is omitted`},args:Ql.args,async run({args:e}){let t=Ql.parse(e),n=t[`bank-url`],r=t[`agent-id`],i=t.name;if(t.service){await su({bankUrl:n,agentId:r,suggestedAgentName:i,publicKeyHex:t[`public-key`]});return}let a,o,s;try{if(Ns(n,`--bank-url`),t[`public-key`]!==void 0)throw Error(`--public-key requires --service`);if(r!==void 0&&i!==void 0)throw Error(`--name can only be used when agent-id is omitted`);let e=wc({flag:Nc(t),cwd:process.cwd(),log:e=>console.error(e)});a=(e!==null&&e.source!=="default"?e.name:null)??(r===void 0?null:Zs(r,n)),o=a??(r===void 0?iu(i):uc(r)),s=oc(o,{bank_url:n,agent_id:r})}catch(e){I(e)}console.log(`
503
- Catena — Agent Setup`),console.log(`─`.repeat(25));let c=ks(),l=await Bl(c,s),u={bankUrl:n,clientInstanceId:s,log:e=>console.log(` ${e}`),appInfo:hc,existingSigner:l},d=ru({agentId:r,suggestedAgentName:i,browserRequested:t.browser,isHeadless:Tl});d.kind===`device-link`&&d.notice!==void 0&&console.log(` ${d.notice}`);let f=d.kind===`pkce-link`?await Ul({...u,agentId:d.agentId,clientId:`catena-cli`,timeoutMs:3e5}):await Jl({...u,...d.deviceTarget,onUserCode:eu});f||I(`
504
- Failed to link agent. Run the command again to try again.`),await c.save(s,os(f.signer));let p=a??dc(uc(f.agentName),e=>e!==o&&ic(e)!==null);try{p===o?Js(p,{bank_url:n,agent_id:f.agentId,client_instance_id:s}):fc({reservationName:o,profileName:p,profile:{bank_url:n,agent_id:f.agentId,client_instance_id:s}})}catch(e){I(e)}console.log(`\n Wrote profile "${p}"`);let m=au(p);m!==null&&console.log(m.reboundFrom===null?` Bound ${m.directory} to profile "${p}"`:` Rebound ${m.directory} from profile "${m.reboundFrom}" to "${p}"`),console.log(` To pin this identity for an agent host, set ${xc}=${p}`),console.log(`\nDone. Agent "${f.agentName}" linked.`),process.exit(0)}});async function su(e){try{if(Ns(e.bankUrl,`--bank-url`),e.agentId!==void 0&&e.suggestedAgentName!==void 0)throw Error(`--name can only be used when agent-id is omitted`);if(e.publicKeyHex!==void 0&&!$l.test(e.publicKeyHex.toLowerCase()))throw Error(`--public-key must be compressed P-256 public key hex (66 chars)`)}catch(e){I(e)}console.log(`
505
- Catena — Deployed Service Setup`),console.log(`─`.repeat(31));let t=e.publicKeyHex===void 0?Ma():null,n=t?.publicKeyHex??e.publicKeyHex?.toLowerCase()??``,r;try{r=Ia(n)}catch(e){e instanceof ja||I(e),I(`Signing key public key is not a valid P-256 point`)}console.log(` Signing key (RFC 7638 thumbprint): ${r}`);let i=`service-${h(`sha256`).update(n).digest(`hex`).slice(0,32)}`,a=!1,o=()=>{t&&a&&tu({publicKeyHex:n,privateKeyHex:t.privateKeyHex})},s;try{s=await Zl({bankUrl:e.bankUrl,clientInstanceId:i,publicKeyHex:n,...e.agentId===void 0?{}:{agentId:e.agentId},...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName},onUserCode:e=>{a=!0,eu(e)},log:e=>console.log(` ${e}`),appInfo:hc})}catch(e){o(),I(e)}s||(o(),I(`
506
- Failed to link the service. Run the command again to try again.`)),s.keyThumbprint!==r&&(o(),I(`The bank registered signing key thumbprint ${s.keyThumbprint}, which does not match the local key (${r}). Do not deploy this credential. Unlink the agent in the console and run link again`)),console.log(`\nDone. Agent "${s.agentName}" linked as a deployed service.`),console.log(` Agent ID: ${s.agentId}`),console.log(` Signing key (RFC 7638 thumbprint): ${s.keyThumbprint}`),s.signerStatus===`registered`||s.signerStatus===`already_registered`?console.log(` Wallet-send signer: registered`):s.signerStatus===`not_applicable`?console.log(` Wallet-send signer: deferred (${s.signerReason??`topology not ready`}); the org must be signing-ready before live sends`):s.signerStatus===`registration_failed`?console.log(nu(s.signerReason)):console.log(` Wallet-send signer: not registered (${s.signerReason??s.signerStatus}); retry after checking the link status`),console.log(`
517
+ `}const Nl=l({meta:{name:`guide`,description:`Print the Catena CLI agent operating guide`},run(){console.log(Ml(se))}}),Pl=$({id:jo({description:`Intent id (e.g. int_…)`,required:!0,schema:qo}),profile:Wo,json:Go}),Fl=l({meta:{name:`get`,description:`Look up the current state of an intent created by this agent`},args:Pl.args,async run({args:e}){let t=Pl.parse(e);await Gc(t)(e=>e.getIntent(t.id))}}),Il=l({meta:{name:`intents`,description:`Inspect intent receipts returned by governed operations`},subCommands:{get:Fl}});function Ll(e=process.env,t=process.platform){return!!(e.SSH_CONNECTION||e.SSH_TTY||t===`linux`&&!e.DISPLAY&&!e.WAYLAND_DISPLAY)}function Rl(e){let t;try{t=E(re(e))}catch{return!1}if(t===`/`)return!0;try{let e=E(process.env.HOME??j());return t===e||e.startsWith(`${t}/`)}catch{return!0}}function zl(e){e&&process.stderr.write(`Failed to open browser: ${e.message}\n`)}function Bl(e){process.platform===`darwin`?y(`open`,[e],zl):process.platform===`win32`?y(`cmd`,[`/c`,`start`,``,e],zl):y(`xdg-open`,[e],zl)}function Vl(e){if(typeof e!=`object`||!e)return;let t=e;return typeof t.message==`string`?t.message:typeof t.error==`string`?t.error:void 0}function Hl(e){return typeof e!=`object`||!e||!(`access_token`in e)?!1:typeof e.access_token==`string`}function Ul(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.agentId==`string`&&typeof t.name==`string`&&typeof t.sessionToken==`string`&&(t.activated===void 0||typeof t.activated==`boolean`)}function Wl(e){if(typeof e!=`object`||!e)return!1;let t=e;return $o.some(e=>e===t.status)&&(t.publicKeyHex===void 0||typeof t.publicKeyHex==`string`)&&(t.reason===void 0||typeof t.reason==`string`)}async function Gl(e){let{bankUrl:t,authCode:n,verifier:r,redirectUri:i,agentId:a,clientInstanceId:o,clientId:s,clientLabel:c,log:l=()=>{},appInfo:u,existingSigner:d,generateSignerKeypair:f=na}=e,p=Oc(u);l(`Exchanging authorization code...`);let m=await fetch(`${t}/v1/auth/oauth2/token`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,...p},body:new URLSearchParams({grant_type:`authorization_code`,code:n,code_verifier:r,client_id:s,redirect_uri:i}).toString()});if(!m.ok)return{ok:!1,message:Vl(await m.json().catch(()=>({message:`Token exchange failed`})))??m.statusText};let h=await m.json();if(!Hl(h))return{ok:!1,message:`Token exchange response missing access_token`};l(`Claiming agent...`);let g=d?{algorithm:d.algorithm,privateKeyHex:d.privateKeyHex,publicKeyHex:d.publicKeyHex}:f(),_=await fetch(`${t}/v1/agent-api/claim`,{method:`POST`,headers:{"Content-Type":`application/json`,...p,Authorization:`Bearer ${h.access_token}`},body:JSON.stringify({agentId:a,clientInstanceId:o,...c===void 0?{}:{clientLabel:c}})});if(!_.ok)return{ok:!1,message:Vl(await _.json().catch(()=>({message:`Claim failed`})))??_.statusText};let v=await _.json();return Ul(v)?Kl({bankUrl:t,claim:v,clientInstanceId:o,signerKeypair:g,identityHeaders:p,log:l}):{ok:!1,message:`Claim response missing required fields`}}async function Kl(e){let{bankUrl:t,claim:n,clientInstanceId:r,signerKeypair:i,identityHeaders:a}=e;(e.log??(()=>{}))(`Registering signer...`);let o=await Jl({bankUrl:t,sessionToken:n.sessionToken,keypair:i,identityHeaders:a});return o.status===`registration_failed`?(n.activated!==!1&&await Yl({bankUrl:t,sessionToken:n.sessionToken,identityHeaders:a}),o.reason===`public_key_conflict`?{ok:!1,message:`This device's signing key conflicts with the one the bank already holds for this agent, or that key is already registered to another agent. Re-running link will not fix this; this agent's signing key cannot be reset automatically, so ask an operator or support to reset it before linking again.`}:{ok:!1,message:`Signer registration failed (${o.reason??`unknown`}). Run link again to retry.`}):{ok:!0,result:{agentId:n.agentId,clientInstanceId:r,agentName:n.name,signer:{...i,registration:o}}}}function ql(e){return typeof e!=`object`||!e||!(`signer`in e)?!1:Wl(e.signer)}async function Jl(e){let t;try{t=await fetch(`${e.bankUrl}/v1/agent-api/signer/register`,{method:`POST`,headers:{"Content-Type":`application/json`,...e.identityHeaders,Authorization:`Bearer ${e.sessionToken}`},body:JSON.stringify({signer:{algorithm:e.keypair.algorithm,publicKeyHex:e.keypair.publicKeyHex}})})}catch{return{status:`registration_failed`,reason:`registration_request_failed`}}if(t.status===409)return{status:`registration_failed`,reason:`public_key_conflict`};if(!t.ok)return{status:`registration_failed`,reason:`provider_registration_failed`};let n=await t.json().catch(()=>null);return ql(n)?n.signer:{status:`registration_failed`,reason:`registration_response_malformed`}}async function Yl(e){try{await fetch(`${e.bankUrl}/v1/agent-api/unlink`,{method:`POST`,headers:{...e.identityHeaders,Authorization:`Bearer ${e.sessionToken}`}})}catch{}}function Xl(e){return`${e}-signer`}async function Zl(e,t){let n=await e.resolve(t);if(n!==null&&`signer`in n)return n.signer;let r=await e.resolve(Xl(t));if(r!==null&&`signer`in r)return r.signer}async function Ql(e,t,n=na){let r=await Zl(e,t);if(r!==void 0)return r;let i=ps(n());return await e.save(Xl(t),i),i.signer}const $l=[53682,53683,53684,53685,53686,53687];function eu(e){return new Promise((t,n)=>{let r=0,i=()=>{if(r>=$l.length){n(Error(`No registered loopback callback ports are available`));return}let a=$l[r],o=t=>{if(e.off(`error`,o),t.code===`EADDRINUSE`){r++,i();return}n(t)};e.once(`error`,o),e.listen(a,`127.0.0.1`,()=>{e.off(`error`,o),t(a)})};i()})}async function tu(e){let{bankUrl:t,agentId:n,clientInstanceId:r,clientId:i,clientLabel:a,timeoutMs:o=3e5,log:s=()=>{},appInfo:c,existingSigner:l}=e;Hs(t,`bankUrl`);let u=_(32).toString(`base64url`),d=h(`sha256`).update(u).digest(`base64url`),f=_(16).toString(`hex`),p=e=>{let n=new URL(`${t}/link-complete`);return n.searchParams.set(`linked`,e),n.toString()},m=e=>{let n=new URL(`${t}/link-complete`);return n.searchParams.set(`error`,e),n.toString()};return new Promise((e,h)=>{let g=0,_=!1,v=null,y=t=>{_||(_=!0,v&&clearTimeout(v),S.close(),e(t))},b=e=>{_||(_=!0,v&&clearTimeout(v),S.close(),h(e))},x=e=>{s(`Link failed: ${e}`),y(null)},S=N((e,t)=>{C(e,t).catch(e=>{let n=Vl(e)??`Unexpected error`;t.headersSent||(t.writeHead(302,{Location:m(n)}),t.end()),s(`Link failed: ${n}`),y(null)})});async function C(e,o){let d=new URL(e.url??`/`,`http://localhost`);if(d.pathname!==`/callback`){o.writeHead(404),o.end(`Not found`);return}let h=d.searchParams.get(`error`);if(h){let e=d.searchParams.get(`error_description`)??h;o.writeHead(302,{Location:m(e)}),o.end(),x(`OAuth error: ${e}`);return}if(d.searchParams.get(`state`)!==f){o.writeHead(302,{Location:m(`State mismatch during OAuth callback`)}),o.end(),x(`State mismatch during OAuth callback`);return}let _=d.searchParams.get(`code`);if(!_){o.writeHead(302,{Location:m(`Missing authorization code`)}),o.end(),x(`Missing authorization code`);return}let v=`http://127.0.0.1:${g}/callback`,b=await Gl({bankUrl:t,authCode:_,verifier:u,redirectUri:v,agentId:n,clientInstanceId:r,clientId:i,clientLabel:a,log:s,appInfo:c,existingSigner:l});if(!b.ok){o.writeHead(302,{Location:m(b.message)}),o.end(),s(`Link failed: ${b.message}`),y(null);return}o.writeHead(302,{Location:p(b.result.agentId)}),o.end(),y(b.result)}eu(S).then(e=>{g=e;let n=`http://127.0.0.1:${g}/callback`,r=`${t}/v1/auth/oauth2/authorize?`+new URLSearchParams({response_type:`code`,client_id:i,redirect_uri:n,scope:`openid email profile offline_access`,code_challenge:d,code_challenge_method:`S256`,state:f}).toString();s(`Opening browser for authentication...`),Bl(r),s(`If browser didn't open, visit: ${r}`)}).catch(b),v=setTimeout(()=>{x(`Timed out waiting for authentication`)},o),v.unref()})}function nu(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.deviceCode==`string`&&typeof t.userCode==`string`&&typeof t.verificationUri==`string`&&typeof t.verificationUriComplete==`string`&&typeof t.expiresIn==`number`&&typeof t.interval==`number`}function ru(e){if(typeof e!=`object`||!e)return{};let t=e;return{code:typeof t.code==`string`?t.code:void 0,message:typeof t.error==`string`?t.error:void 0}}function iu(e){return new Promise(t=>{setTimeout(t,e)})}function au(e){let t={clientInstanceId:e.clientInstanceId,...e.clientLabel===void 0?{}:{clientLabel:e.clientLabel}};return e.scope===`agent:connect`?{scope:`agent:connect`,...t,...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName}}:e.scope===`agent:link`?{scope:`agent:link`,agentId:e.agentId,...t}:{agentId:e.agentId,...t}}async function ou(e){let{bankUrl:t,clientInstanceId:n,onUserCode:r,log:i=()=>{},appInfo:a,existingSigner:o,generateSignerKeypair:s=na,sleep:c=iu}=e;Hs(t,`bankUrl`);let l=Oc(a),u=e=>(i(`Link failed: ${e}`),null),d;try{d=await fetch(`${t}/v1/agent-link/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`,...l},body:JSON.stringify(au(e))})}catch{return u(`Could not reach the bank to start the device flow`)}if(!d.ok)return u(ru(await d.json().catch(()=>null)).message??d.statusText);let f=await d.json();if(!nu(f))return u(`Device authorization response missing required fields`);r({userCode:f.userCode,verificationUri:f.verificationUri,verificationUriComplete:f.verificationUriComplete,expiresInSeconds:f.expiresIn});let p=await su({bankUrl:t,grant:f,identityHeaders:l,sleep:c});if(!p.ok)return u(p.message);let m=p.body;if(!Ul(m))return u(`Device token response missing required fields`);i(`Approved. Claiming agent...`);let h=await Kl({bankUrl:t,claim:m,clientInstanceId:n,signerKeypair:o?{algorithm:o.algorithm,privateKeyHex:o.privateKeyHex,publicKeyHex:o.publicKeyHex}:s(),identityHeaders:l,log:i});return h.ok?h.result:u(h.message)}async function su(e){let{bankUrl:t,grant:n,identityHeaders:r,sleep:i}=e,a=Date.now()+n.expiresIn*1e3,o=Math.max(n.interval,1)*1e3,s=o;for(;Date.now()+o<=a;){await i(o);let e;try{e=await fetch(`${t}/v1/agent-link/device/token`,{method:`POST`,headers:{"Content-Type":`application/json`,...r},body:JSON.stringify({deviceCode:n.deviceCode})})}catch{s=Math.min(s*2,6e4),o=Math.max(o,s);continue}if(s=o,e.ok){let t=await e.json().catch(()=>null);return t===null?{ok:!1,message:`The bank returned an unreadable token response`}:{ok:!0,body:t}}let a=ru(await e.json().catch(()=>null));if(a.code!==`authorization_pending`){if(a.code===`slow_down`){o+=5e3;continue}return a.code===`expired_token`?{ok:!1,message:`The device code expired before approval. Run link again`}:{ok:!1,message:a.message??`The request was denied`}}}return{ok:!1,message:`Timed out waiting for approval`}}function cu(e){if(typeof e!=`object`||!e)return!1;let t=e,n=t.signer;return t.credential===`signing_key`&&typeof t.agentId==`string`&&typeof t.name==`string`&&typeof t.keyThumbprint==`string`&&typeof t.activated==`boolean`&&typeof n==`object`&&!!n&&typeof n.status==`string`}async function lu(e){let{bankUrl:t,clientInstanceId:n,onUserCode:r,log:i=()=>{},appInfo:a,sleep:o=iu}=e;Hs(t,`bankUrl`);let s=Oc(a),c=e=>(i(`Link failed: ${e}`),null),l={clientInstanceId:n,signer:{algorithm:`p256`,publicKeyHex:e.publicKeyHex},...e.clientLabel===void 0?{}:{clientLabel:e.clientLabel}},u=e.agentId===void 0?{scope:`agent:connect:service`,...l,...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName}}:{scope:`agent:link:service`,agentId:e.agentId,...l},d;try{d=await fetch(`${t}/v1/agent-link/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`,...s},body:JSON.stringify(u)})}catch{return c(`Could not reach the bank to start the device flow`)}if(!d.ok){let e=ru(await d.json().catch(()=>null));return e.code===`validation_failed`?c(`The bank rejected the request, which usually means it does not support --service yet. Nothing was created. Upgrade the bank and retry`):c(e.message??d.statusText)}let f=await d.json();if(!nu(f))return c(`Device authorization response missing required fields`);r({userCode:f.userCode,verificationUri:f.verificationUri,verificationUriComplete:f.verificationUriComplete,expiresInSeconds:f.expiresIn});let p=await su({bankUrl:t,grant:f,identityHeaders:s,sleep:o});return p.ok?Ul(p.body)?c(`This bank does not support --service yet: it created a session link for agent ${p.body.agentId}. Unlink it in the console before retrying`):cu(p.body)?(i(`Approved. Signing key registered.`),{agentId:p.body.agentId,agentName:p.body.name,keyThumbprint:p.body.keyThumbprint,activated:p.body.activated,signerStatus:p.body.signer.status,...p.body.signer.reason===void 0?{}:{signerReason:p.body.signer.reason}}):c(`Device token response missing required fields`):c(p.message)}const uu=$({"agent-id":jo({description:`Optional agent ID shown in the Catena console; omit to create and link a new agent`,schema:qo}),"bank-url":Q({description:`Bank API URL (defaults to $CATENA_API_URL or prod)`,default:process.env.CATENA_API_URL??`https://api.catena.com`}),browser:No({description:`Open the browser PKCE flow (default)`,negativeDescription:`Skip the browser and link with a device code you approve from another machine`,default:!0}),name:Q({description:`Suggested name for an agent created from this link; only used when agent-id is omitted`}),service:No({description:`Provision a deployed-service signing credential instead of linking this machine: approval registers a P-256 key, no session tokens are minted, and nothing is stored locally. Interactive agent hosts must NOT use this`,default:!1}),"public-key":Q({description:`With --service: register this existing compressed P-256 public key (the deployment already holds the private key) instead of generating a keypair`}),profile:Wo}),du=/^0[23][0-9a-f]{64}$/;function fu(e){let t=Math.round(e.expiresInSeconds/60);console.log(`\n To approve this link, visit: ${e.verificationUri}`),console.log(` and enter the code: ${e.userCode}`),console.log(`\n Or open: ${e.verificationUriComplete}`),console.log(`\n Waiting for approval (expires in ${t} minutes)...`)}function pu(e){console.log(`
518
+ Keep this generated keypair if the approval completed before the CLI failed:`),console.log(`\n CATENA_AGENT_PUBLIC_KEY=${e.publicKeyHex}`),console.log(` CATENA_AGENT_PRIVATE_KEY=${e.privateKeyHex}`)}function mu(e){switch(e){case`signer_key_conflict`:return` Wallet-send signer: not registered (signer key conflict); unlink the conflicting service link or re-run with the linked agent ID`;case`provider_registration_failed`:return` Wallet-send signer: not registered (provider registration failed); retry after the provider recovers`;case void 0:return` Wallet-send signer: not registered (registration failed); retry after checking the link status`;default:return` Wallet-send signer: not registered (${e}); retry after checking the link status`}}function hu({agentId:e,suggestedAgentName:t,browserRequested:n,isHeadless:r}){return e===void 0?{kind:`device-connect`,deviceTarget:{scope:`agent:connect`,...t===void 0?{}:{suggestedAgentName:t}}}:n?r()?{kind:`device-link`,deviceTarget:{agentId:e},notice:`No browser available — using device code flow.`}:{kind:`pkce-link`,agentId:e}:{kind:`device-link`,deviceTarget:{agentId:e}}}function gu(e){let t=h(`sha256`).update(E(process.cwd())).digest(`hex`).slice(0,16);return`${yc(e??`agent`).slice(0,47)}-${t}`}function _u(e){try{let t=process.cwd();if(Rl(t))return null;let n=uc(t);return{directory:dc(t,e),reboundFrom:n!==null&&n!==e?n:null}}catch{return console.error(`Warning: could not bind the current directory to profile "${e}".`),null}}const vu=l({meta:{name:`link`,description:`Link an existing agent, or create and link a new agent when agent-id is omitted`},args:uu.args,async run({args:e}){let t=uu.parse(e),n=t[`bank-url`],r=t[`agent-id`],i=t.name;if(t.service){await yu({bankUrl:n,agentId:r,suggestedAgentName:i,publicKeyHex:t[`public-key`]});return}let a,o,s;try{if(Hs(n,`--bank-url`),t[`public-key`]!==void 0)throw Error(`--public-key requires --service`);if(r!==void 0&&i!==void 0)throw Error(`--name can only be used when agent-id is omitted`);let e=Nc({flag:Hc(t),cwd:process.cwd(),log:e=>console.error(e)});a=(e!==null&&e.source!=="default"?e.name:null)??(r===void 0?null:oc(r,n)),o=a??(r===void 0?gu(i):yc(r)),s=hc(o,{bank_url:n,agent_id:r})}catch(e){Z(e)}console.log(`
519
+ Catena — Agent Setup`),console.log(`─`.repeat(25));let c=Rs(),l=await Ql(c,s),u={bankUrl:n,clientInstanceId:s,log:e=>console.log(` ${e}`),appInfo:wc,existingSigner:l},d=hu({agentId:r,suggestedAgentName:i,browserRequested:t.browser,isHeadless:Ll});d.kind===`device-link`&&d.notice!==void 0&&console.log(` ${d.notice}`);let f=d.kind===`pkce-link`?await tu({...u,agentId:d.agentId,clientId:`catena-cli`,timeoutMs:3e5}):await ou({...u,...d.deviceTarget,onUserCode:fu});f||Z(`
520
+ Failed to link agent. Run the command again to try again.`),await c.save(s,hs(f.signer));let p=a??bc(yc(f.agentName),e=>e!==o&&pc(e)!==null);try{p===o?rc(p,{bank_url:n,agent_id:f.agentId,client_instance_id:s}):xc({reservationName:o,profileName:p,profile:{bank_url:n,agent_id:f.agentId,client_instance_id:s}})}catch(e){Z(e)}console.log(`\n Wrote profile "${p}"`);let m=_u(p);m!==null&&console.log(m.reboundFrom===null?` Bound ${m.directory} to profile "${p}"`:` Rebound ${m.directory} from profile "${m.reboundFrom}" to "${p}"`),console.log(` To pin this identity for an agent host, set ${Ac}=${p}`),console.log(`\nDone. Agent "${f.agentName}" linked.`),process.exit(0)}});async function yu(e){try{if(Hs(e.bankUrl,`--bank-url`),e.agentId!==void 0&&e.suggestedAgentName!==void 0)throw Error(`--name can only be used when agent-id is omitted`);if(e.publicKeyHex!==void 0&&!du.test(e.publicKeyHex.toLowerCase()))throw Error(`--public-key must be compressed P-256 public key hex (66 chars)`)}catch(e){Z(e)}console.log(`
521
+ Catena — Deployed Service Setup`),console.log(`─`.repeat(31));let t=e.publicKeyHex===void 0?na():null,n=t?.publicKeyHex??e.publicKeyHex?.toLowerCase()??``,r;try{r=oa(n)}catch(e){e instanceof ta||Z(e),Z(`Signing key public key is not a valid P-256 point`)}console.log(` Signing key (RFC 7638 thumbprint): ${r}`);let i=`service-${h(`sha256`).update(n).digest(`hex`).slice(0,32)}`,a=!1,o=()=>{t&&a&&pu({publicKeyHex:n,privateKeyHex:t.privateKeyHex})},s;try{s=await lu({bankUrl:e.bankUrl,clientInstanceId:i,publicKeyHex:n,...e.agentId===void 0?{}:{agentId:e.agentId},...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName},onUserCode:e=>{a=!0,fu(e)},log:e=>console.log(` ${e}`),appInfo:wc})}catch(e){o(),Z(e)}s||(o(),Z(`
522
+ Failed to link the service. Run the command again to try again.`)),s.keyThumbprint!==r&&(o(),Z(`The bank registered signing key thumbprint ${s.keyThumbprint}, which does not match the local key (${r}). Do not deploy this credential. Unlink the agent in the console and run link again`)),console.log(`\nDone. Agent "${s.agentName}" linked as a deployed service.`),console.log(` Agent ID: ${s.agentId}`),console.log(` Signing key (RFC 7638 thumbprint): ${s.keyThumbprint}`),s.signerStatus===`registered`||s.signerStatus===`already_registered`?console.log(` Wallet-send signer: registered`):s.signerStatus===`not_applicable`?console.log(` Wallet-send signer: deferred (${s.signerReason??`topology not ready`}); the org must be signing-ready before live sends`):s.signerStatus===`registration_failed`?console.log(mu(s.signerReason)):console.log(` Wallet-send signer: not registered (${s.signerReason??s.signerStatus}); retry after checking the link status`),console.log(`
507
523
  Set these in the deployment environment:`),console.log(`\n CATENA_API_URL=${e.bankUrl}`),console.log(` CATENA_AGENT_PUBLIC_KEY=${n}`),t&&console.log(` CATENA_AGENT_PRIVATE_KEY=${t.privateKeyHex}`),console.log(` CATENA_AGENT_IDENTITY_URL=<the deployment's public https origin>`),t&&console.log(`
508
- The private key is shown once and is not stored on this machine.`),process.exit(0)}const cu=W({profile:Se,json:Ce}),lu=l({meta:{name:`show`,description:`Show the agent's assigned policy`},args:cu.args,async run({args:e}){await Ic(cu.parse(e))(e=>e.getPolicy())}}),uu=l({meta:{name:`policy`,description:`Inspect the agent's policy`},subCommands:{show:lu}}),du=W({profile:pe({description:`Profile name`,required:!0})});function fu(){try{return Tc({env:process.env[xc],cwd:process.cwd(),log:e=>console.error(e)})}catch(e){return I(e)}}const pu=l({meta:{name:`use`,description:`Set the default credential profile`},args:du.args,async run({args:e}){let t=du.parse(e);try{lc(t.profile),Mc({defaultProfile:t.profile})}catch(e){I(e)}}}),mu=l({meta:{name:`current`,description:`Show the selected credential profile and how it was chosen`},async run(){let e=fu(),t;try{t=ic(e.name)}catch(e){I(e)}t===null&&I(`Profile "${e.name}" is not linked.\nRun 'catena link --profile ${e.name} <agent-id>' to authenticate.`),Mc({profile:e.name,source:e.source,bankUrl:t.bank_url,agentId:Ys(t)?t.agent_id:void 0})}}),hu=l({meta:{name:`list`,description:`List credential profiles and their directory bindings`},async run(){let e;try{e=Gs()}catch(e){I(e)}let t;try{t=Tc({env:process.env[xc],cwd:process.cwd()}).name}catch{t=null}let n=Object.entries(e.directories??{});Mc({defaultProfile:e.default_profile,profiles:Object.entries(e.profiles).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,r])=>({name:e,bankUrl:r.bank_url,agentId:Ys(r)?r.agent_id:void 0,directories:n.filter(([,t])=>t===e).map(([e])=>e).toSorted(),current:e===t}))})}}),gu=W({profile:pe({description:`Profile name to bind`,required:!0}),path:pe({description:`Directory to bind (defaults to the current directory)`})}),_u=l({meta:{name:`bind`,description:`Bind a directory to a profile for automatic selection`},args:gu.args,async run({args:e}){let t=gu.parse(e);try{let e=t.path??process.cwd();if(El(e))throw Error(`Refusing to bind the home directory or an ancestor of it — that would shadow the default profile for every directory beneath it. Bind a specific agent directory instead.`);let n=nc(e,t.profile);Mc({profile:t.profile,directory:n})}catch(e){I(e)}}}),vu=W({path:pe({description:`Directory to unbind (defaults to the current directory)`})}),yu=l({meta:{name:`unbind`,description:`Remove a directory's profile binding`},args:vu.args,async run({args:e}){let t=vu.parse(e);try{Mc(rc(t.path??process.cwd()))}catch(e){I(e)}}}),bu=l({meta:{name:`profiles`,description:`Manage credential profiles`},subCommands:{use:pu,current:mu,list:hu,bind:_u,unbind:yu}}),xu=new Map,Su=/^[A-Z]{3}$/,Cu=/^[A-Z0-9]{2,6}$/;function wu(e,t,n){if(xu.has(e))throw Error(`duplicate asset id ${e}`);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||n<0)throw Error(`decimals and presentmentDecimals must be non-negative integers`);if(n>t)throw Error(`presentment decimals should be less than or equal to decimals`)}function Tu(e,t,n,r){if(!Su.test(e))throw Error(`fiat asset ids must be 3-letter ISO-4217 codes`);wu(e,n,r);let i=e;return xu.set(e,{id:i,symbol:e,name:t,kind:`fiat`,decimals:n,presentmentDecimals:r,denomination:e,valuation:{type:`par`}}),i}function Eu(e,t,n,r,i){if(!Cu.test(e)||Su.test(e))throw Error(`stablecoin tickers must be 2-6 uppercase alphanumerics and not a 3-letter ISO-4217 shape`);let a=xu.get(i.denomination);if(!a||a.kind!==`fiat`)throw Error(`stablecoin denomination must be a registered fiat asset, got ${i.denomination}`);if(n>a.decimals)throw Error(`par stablecoin decimals (${n}) must not exceed its denomination fiat's (${a.decimals})`);wu(e,n,r);let o=e;return xu.set(e,{id:o,symbol:e,name:t,kind:`stablecoin`,decimals:n,presentmentDecimals:r,denomination:a.denomination,valuation:{type:`par`}}),o}Eu(`USDC`,`USD Coin`,6,2,{denomination:Tu(`USD`,`US Dollar`,6,2)})
524
+ The private key is shown once and is not stored on this machine.`),process.exit(0)}const bu=$({profile:Wo,json:Go}),xu=l({meta:{name:`show`,description:`Show the agent's assigned policy`},args:bu.args,async run({args:e}){await Gc(bu.parse(e))(e=>e.getPolicy())}}),Su=l({meta:{name:`policy`,description:`Inspect the agent's policy`},subCommands:{show:xu}}),Cu=$({profile:jo({description:`Profile name`,required:!0})});function wu(){try{return Pc({env:process.env[Ac],cwd:process.cwd(),log:e=>console.error(e)})}catch(e){return Z(e)}}const Tu=l({meta:{name:`use`,description:`Set the default credential profile`},args:Cu.args,async run({args:e}){let t=Cu.parse(e);try{vc(t.profile),Vc({defaultProfile:t.profile})}catch(e){Z(e)}}}),Eu=l({meta:{name:`current`,description:`Show the selected credential profile and how it was chosen`},async run(){let e=wu(),t;try{t=pc(e.name)}catch(e){Z(e)}t===null&&Z(`Profile "${e.name}" is not linked.\nRun 'catena link --profile ${e.name} <agent-id>' to authenticate.`),Vc({profile:e.name,source:e.source,bankUrl:t.bank_url,agentId:ic(t)?t.agent_id:void 0})}}),Du=l({meta:{name:`list`,description:`List credential profiles and their directory bindings`},async run(){let e;try{e=ec()}catch(e){Z(e)}let t;try{t=Pc({env:process.env[Ac],cwd:process.cwd()}).name}catch{t=null}let n=Object.entries(e.directories??{});Vc({defaultProfile:e.default_profile,profiles:Object.entries(e.profiles).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,r])=>({name:e,bankUrl:r.bank_url,agentId:ic(r)?r.agent_id:void 0,directories:n.filter(([,t])=>t===e).map(([e])=>e).toSorted(),current:e===t}))})}}),Ou=$({profile:jo({description:`Profile name to bind`,required:!0}),path:jo({description:`Directory to bind (defaults to the current directory)`})}),ku=l({meta:{name:`bind`,description:`Bind a directory to a profile for automatic selection`},args:Ou.args,async run({args:e}){let t=Ou.parse(e);try{let e=t.path??process.cwd();if(Rl(e))throw Error(`Refusing to bind the home directory or an ancestor of it — that would shadow the default profile for every directory beneath it. Bind a specific agent directory instead.`);let n=dc(e,t.profile);Vc({profile:t.profile,directory:n})}catch(e){Z(e)}}}),Au=$({path:jo({description:`Directory to unbind (defaults to the current directory)`})}),ju=l({meta:{name:`unbind`,description:`Remove a directory's profile binding`},args:Au.args,async run({args:e}){let t=Au.parse(e);try{Vc(fc(t.path??process.cwd()))}catch(e){Z(e)}}}),Mu=l({meta:{name:`profiles`,description:`Manage credential profiles`},subCommands:{use:Tu,current:Eu,list:Du,bind:ku,unbind:ju}}),Nu=new Map,Pu=/^[A-Z]{3}$/,Fu=/^[A-Z0-9]{2,6}$/;function Iu(e,t,n){if(Nu.has(e))throw Error(`duplicate asset id ${e}`);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||n<0)throw Error(`decimals and presentmentDecimals must be non-negative integers`);if(n>t)throw Error(`presentment decimals should be less than or equal to decimals`)}function Lu(e,t,n,r){if(!Pu.test(e))throw Error(`fiat asset ids must be 3-letter ISO-4217 codes`);Iu(e,n,r);let i=e;return Nu.set(e,{id:i,symbol:e,name:t,kind:`fiat`,decimals:n,presentmentDecimals:r,denomination:e,valuation:{type:`par`}}),i}function Ru(e,t,n,r,i){if(!Fu.test(e)||Pu.test(e))throw Error(`stablecoin tickers must be 2-6 uppercase alphanumerics and not a 3-letter ISO-4217 shape`);let a=Nu.get(i.denomination);if(!a||a.kind!==`fiat`)throw Error(`stablecoin denomination must be a registered fiat asset, got ${i.denomination}`);if(n>a.decimals)throw Error(`par stablecoin decimals (${n}) must not exceed its denomination fiat's (${a.decimals})`);Iu(e,n,r);let o=e;return Nu.set(e,{id:o,symbol:e,name:t,kind:`stablecoin`,decimals:n,presentmentDecimals:r,denomination:a.denomination,valuation:{type:`par`}}),o}Ru(`USDC`,`USD Coin`,6,2,{denomination:Lu(`USD`,`US Dollar`,6,2)})
509
525
  /*! decimal.js-light v2.5.1 https://github.com/MikeMcl/decimal.js-light/LICENCE */
510
- ;const Du=e(s(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=r<i?r:i;t<n;++t)if(a.d[t]!==e.d[t])return a.d[t]>e.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return D(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,D(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?O(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):D(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):O(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(D(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,D(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l<u&&(o=m,m=h,h=o,s=l,l=u,u=s),o=[],s=l+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?D(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),D(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=k(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=D(new a(i),e+1,t),r=k(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?k(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=D(new o(a),e+S(a)+1,t),r=k(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return D(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return D(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),A(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),A(u.d,t);return i=!0,e.s<0?new f(d).div(o):D(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=k(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=D(new o(a),e,t),r=S(a),i=k(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),D(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return k(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?D(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?D(t,m):t}function v(e,t,n){if(e!==~~e||e<t||e>n)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=p-r.length,n&&(a+=w(n)),a+=r;o=e[t],r=o+``,n=p-r.length,n&&(a+=w(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}var b=(function(){function e(e,t){var n,r=0,i=e.length;for(e=e.slice();i--;)n=e[i]*t+r,e[i]=n%f|0,r=n/f|0;return r&&e.unshift(r),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]<t[n]),e[n]=r*f+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,E,O,k,A=r.constructor,j=r.s==i.s?1:-1,M=r.d,N=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,O=N.length,T=M.length,g=new A(j),_=g.d=[],u=0;N[u]==(M[u]||0);)++u;if(N[u]>(M[u]||0)&&--l,x=o==null?o=A.precision:s?o+(S(r)-S(i))+1:o,x<0)return new A(0);if(x=x/p+2|0,u=0,O==1)for(d=0,N=N[0],x++;(u<T||d)&&x--;u++)C=d*f+(M[u]||0),_[u]=C/N|0,d=C%N|0;else{for(d=f/(N[0]+1)|0,d>1&&(N=e(N,d),M=e(M,d),O=N.length,T=M.length),w=O,v=M.slice(0,O),y=v.length;y<O;)v[y++]=0;k=N.slice(),k.unshift(0),E=N[0],N[1]>=f/2&&++E;do d=0,c=t(N,v,O,y),c<0?(b=v[0],O!=y&&(b=b*f+(v[1]||0)),d=b/E|0,d>1?(d>=f&&(d=f-1),m=e(N,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,O<h?k:N,h))):(d==0&&(c=d=1),m=N.slice()),h=m.length,h<y&&m.unshift(0),n(v,m,y),c==-1&&(y=v.length,c=t(N,v,O,y),c<1&&(d++,n(v,O<y?k:N,y))),y=v.length):c===0&&(d++,v=[0]),_[u++]=d,c&&v[0]?v[y++]=M[w]||0:(v=[M[w]],y=1);while((w++<T||v[0]!==void 0)&&x--)}return _[0]||_.shift(),g.e=l,D(g,s?o+S(g)+1:o)}})();function x(e,t){var n,r,a,o,c,u,f=0,p=0,m=e.constructor,h=m.precision;if(S(e)>16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=D(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=D(o.times(o),u);return m.precision=h,t==null?(i=!0,D(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return D(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,D(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=D(g.times(g),f),o=3;;){if(c=D(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,D(l,x)):l;l=u,o+=2}}function E(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),r<a){for(r&&e.d.push(+t.slice(0,r)),a-=p;r<a;)e.d.push(+t.slice(r,r+=p));t=t.slice(r),r=p-t.length}else r-=a;for(;r--;)t+=`0`;if(e.d.push(+t),i&&(e.e>h||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function D(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function O(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?D(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a<c,d&&(c=a),a=0;a<c;a++)if(l[a]!=m[a]){d=l[a]<m[a];break}s=0}for(d&&(n=l,l=m,m=n,t.s=-t.s),c=l.length,a=m.length-c;a>0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]<m[a]){for(o=a;o&&l[--o]===0;)l[o]=f-1;--l[o],l[a]+=f}l[a]-=m[a]}for(;l[--c]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(t.d=l,t.e=r,i?D(t,g):t):new h(0)}function k(e,t,n){var r,i=S(e),a=y(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function A(e,t){if(e.length>t)return e.length=t,!0}function j(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return E(t,e.toString())}if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))E(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=j,i.config=i.set=M,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function M(e){if(!e||typeof e!=`object`)throw Error(a+`Object expected`);var t,r,i,s=[`precision`,1,n,`rounding`,0,8,`toExpNeg`,-1/0,0,`toExpPos`,0,1/0];for(t=0;t<s.length;t+=3)if((i=e[r=s[t]])!==void 0)if(c(i)===i&&i>=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i);if((i=e[r=`LN10`])!==void 0)if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i);return this}r=j(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))(),1).default;Du.set({rounding:Du.ROUND_HALF_EVEN}),new Du(1e6),new Du(1e3);const Ou=f.pipe(f.string(`Amount must be a string`),f.nonEmpty(`Amount must not be empty`),f.check(e=>e.trim()===e,`Amount must not have leading or trailing whitespace`),f.check(e=>!e.includes(`e`)&&!e.includes(`E`),`Scientific notation is not supported (e.g. use 1000000 instead of 1e6)`),f.check(e=>!e.startsWith(`+`),`Amount must not have a '+' prefix`),f.check(e=>!e.startsWith(`-`),`Amount must be non-negative`),f.check(e=>{try{return new Du(e).gte(0)}catch{return!1}},`Amount must be a valid decimal (e.g. 100 or 100.50)`)),ku=f.pipe(f.string(`Idempotency key must be a string`),f.minLength(1,`Idempotency key must not be empty`),f.maxLength(255,`Idempotency key is too long (max 255 characters)`)),Au=W({account:z({description:`Source account id`,required:!0,schema:we}),rail:z({description:`Destination counterparty rail id (cprl_...)`,required:!0,schema:we}),amount:z({description:`USD amount as a decimal string (e.g. 125.00)`,required:!0,schema:Ou,showValueInError:!0}),method:V({description:`ach | wire | on-chain; ach and wire require a bank rail, on-chain a wallet rail`,required:!0,choices:Co}),memo:z({description:`Memo on the underlying transfer`}),description:z({description:`Operator-facing description`}),idempotencyKey:z({description:`Optional. Usually omit this. Identical retries are deduplicated for about 15 minutes after the movement settles and return the original intent, even if it failed, so a bare retry never re-sends on its own. Set a unique value when you intentionally want another payment with the same details, or a stable one to keep a single payment deduplicated beyond that window.`,schema:ku}),profile:Se,json:Ce}),ju=l({meta:{name:`send`,description:`Submit a USD send intent to a counterparty rail`},args:Au.args,async run({args:e}){let t=Au.parse(e),n=Ic(t),r={type:`send`,accountId:t.account,counterpartyRailId:t.rail,amount:t.amount,method:t.method,...t.memo?{memo:t.memo}:{},...t.description?{description:t.description}:{}};await n(e=>e.submitIntent({action:r,...t.idempotencyKey?{idempotencyKey:t.idempotencyKey}:{}}))}}),Mu=W({from:z({description:`Source account id`,required:!0,schema:we}),to:z({description:`Destination account id`,required:!0,schema:we}),amount:z({description:`USD amount as a decimal string (e.g. 125.00)`,required:!0,schema:Ou,showValueInError:!0}),memo:z({description:`Memo on the underlying transfer`}),description:z({description:`Operator-facing description`}),idempotencyKey:z({description:`Optional. Usually omit this. Identical retries are deduplicated for about 15 minutes after the movement settles and return the original intent, even if it failed, so a bare retry never re-sends on its own. Set a unique value when you intentionally want another transfer with the same details, or a stable one to keep a single transfer deduplicated beyond that window.`,schema:ku}),profile:Se,json:Ce}),Nu=l({meta:{name:`transfer`,description:`Submit a USD transfer intent between two of this agent's accounts`},args:Mu.args,async run({args:e}){let t=Mu.parse(e),n=Ic(t),r={type:`transfer`,accountId:t.from,toAccountId:t.to,amount:t.amount,...t.memo?{memo:t.memo}:{},...t.description?{description:t.description}:{}};await n(e=>e.submitIntent({action:r,...t.idempotencyKey?{idempotencyKey:t.idempotencyKey}:{}}))}}),Pu=W({profile:Se,force:me({description:`Remove the profile and its local credentials without contacting the server; use when the credential is missing, revoked, or a link was interrupted`,default:!1}),json:Ce}),Fu=l({meta:{name:`unlink`,description:`Disconnect the selected agent profile`},args:Pu.args,async run({args:e}){let t=Pu.parse(e),n=Dc(),r;try{r=Tc({flag:Nc(t),env:process.env[xc],cwd:process.cwd(),log:e=>console.error(e)}).name}catch(e){I(e)}if(t.force){let e;try{if(e=ic(r),e===null)throw Error(`Profile "${r}" not found`);await n.delete(e.client_instance_id),await n.delete(Rl(e.client_instance_id)),$s(r)}catch(e){I(e)}Mc({success:!0,profile:r,...Ys(e)?{agentId:e.agent_id}:{},local:!0},{compact:t.json});return}let i=`To remove only this machine's copy, run 'catena unlink --profile ${r} --force'.`,a=await mc({profileName:r,fallbackBankUrl:bc},n);a.ok||I(`${a.message} ${i}`);let o=Ec(a);try{await o.unlinkAgent(),await n.delete(a.clientInstanceId),await n.delete(Rl(a.clientInstanceId)),$s(r)}catch(e){I(`${se(jc(e,r))} ${i}`)}Mc({success:!0,profile:r,agentId:a.agentId},{compact:t.json})}}),Iu=W({profile:Se,json:Ce}),Lu=l({meta:{name:`whoami`,description:`Show which agent you are currently acting as`},args:Iu.args,async run({args:e}){await Ic(Iu.parse(e))(e=>e.whoami())}});function Ru(e){throw Error(`Unhandled case: ${String(e)}`)}const zu=[`PAYMENT-REQUIRED`,`X-Payment-Required`],Bu=/^0x[0-9a-fA-F]{64}$/,Vu=/^0x[0-9a-fA-F]{40}$/,Hu=f.looseObject({success:f.boolean(),transaction:f.string()}),Uu=f.looseObject({x402Version:f.literal(2),accepts:f.array(ko),resource:f.optional(Ao)}),Wu=`x402_network_mismatch`,Gu=`x402_counterparty_rail_not_found`,Ku=new Set([`x402_requirement_not_payable`,Wu,Gu]),qu={"eip155:8453":`Base`,"eip155:84532":`Base Sepolia`};function Ju(e){let t=Object.hasOwn(qu,e)?qu[e]:void 0;return t?`${t} (${e})`:e}function Yu(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=Uint8Array.from(atob(t),e=>e.charCodeAt(0));return JSON.parse(new TextDecoder().decode(n))}function Xu(e){let t=zu.map(t=>e.headers.get(t)).find(e=>e!==null);if(t)try{let e=f.safeParse(Uu,Yu(t));return e.success?e.output:void 0}catch{return}}async function Zu(e,t,n){try{let r=n.headers.get(`PAYMENT-RESPONSE`);if(!r)return;let i=f.safeParse(Hu,Yu(r));if(!i.success||!i.output.success||!Bu.test(i.output.transaction))return;await e.reportSettlement({intentId:t,txHash:i.output.transaction})}catch{}}var Qu=class extends Error{reasons;constructor(e,t=[],n={}){super(t.length>0&&(n.appendReasonsToMessage??!0)?`${e}: ${t.join(`; `)}`:e),this.name=`X402PaymentError`,this.reasons=t}},$u=class extends Qu{accountId;requiredNetworks;constructor(e,t,n=[]){super(`Account ${e} cannot fund this 402 challenge: it must be paid from a wallet account on ${t.map(Ju).join(` or `)}`,n,{appendReasonsToMessage:!1}),this.name=`X402NetworkMismatchError`,this.accountId=e,this.requiredNetworks=t}},ed=class extends Qu{payTo;network;serviceName;constructor(e,t,n,r=[]){super(`This 402 pays ${e} on ${Ju(t)}, which is not a saved counterparty wallet rail; add it as a counterparty before paying`,r,{appendReasonsToMessage:!1}),this.name=`X402CounterpartyNotFoundError`,this.payTo=e,this.network=t,this.serviceName=n}},td=class extends Qu{intentId;expiresAt;constructor(e,t,n){super(`The payment is awaiting a human approval (intent ${e}); once an operator approves it, retry the request to complete the payment`,t),this.name=`X402ApprovalPendingError`,this.intentId=e,this.expiresAt=n}},nd=class extends Qu{receipt;constructor(e,t){super(`The payment settled (intent ${e.intentId}) but the post-payment continuation failed; retry the request with the PAYMENT-SIGNATURE header from the receipt (or getIntent("${e.intentId}") data.x402.paymentSignature) instead of paying again`),this.name=`X402RetryFailedError`,this.receipt=e,this.cause=t}};async function rd(e,t){try{return await t()}catch(t){throw new nd(e,t)}}var id=class extends Qu{intentId;requirements;constructor(e,t,n){super(`The payment could not be confirmed (intent ${e}); check getIntent("${e}") — completed: reuse its data.x402.paymentSignature as the PAYMENT-SIGNATURE header; processing: poll until terminal; pay again only after blocked or failed`),this.name=`X402SubmitInterruptedError`,this.intentId=e,this.requirements=t,this.cause=n}};async function ad(e,t){let n=t.paymentRequired.accepts.filter(e=>e.scheme===`exact`),r=n.filter(e=>t.maxAtomicAmount===void 0||/^\d+$/.test(e.amount)&&BigInt(e.amount)<=t.maxAtomicAmount).slice(0,5);if(r.length===0)throw new Qu(n.length>0&&t.maxAtomicAmount!==void 0?`Every requirement in the 402 challenge costs more than the caller's maximum amount`:`The 402 challenge offers no exact-scheme requirement Catena can pay`);let i=t.resource??t.paymentRequired.resource,a=[];for(let n of r){let r=await sd(e,{accountId:t.accountId,requirements:n,resource:i}).catch(e=>{if(e instanceof Fo&&e.code!==void 0&&Ku.has(e.code)){a.push({error:e,requirement:n});return}throw e});if(r)return r}let o=a.filter(e=>e.error.code===Gu),s=a.filter(e=>e.error.code===Wu),c=a.filter(e=>e.error.code!==Gu&&e.error.code!==Wu),l=[...new Set([...o,...s,...c].map(e=>e.error.message))],u=o.find(e=>e.error.status===404&&Vu.test(e.requirement.payTo));throw u?new ed(u.requirement.payTo,u.requirement.network,i?.serviceName,l):s.length>0&&o.length===0?new $u(t.accountId,[...new Set(s.map(e=>e.requirement.network))],l):new Qu(`No requirement in the 402 challenge is payable from this account`,l)}const od=f.object({x402:f.object({paymentSignature:f.string()})});async function sd(e,t){let n=await e.submitIntent({action:{type:`x402`,accountId:t.accountId,paymentRequirements:t.requirements,...t.resource!==void 0&&{resource:t.resource}},idempotencyKey:crypto.randomUUID()}).catch(e=>{throw e instanceof Bo&&e.outcome===`unknown`?new id(e.intentId,t.requirements,e):e});if(n.status===`completed`){let e=f.safeParse(od,n.data);if(e.success)return{intentId:n.id,paymentSignature:e.output.x402.paymentSignature,requirements:t.requirements};throw new Qu(`The completed payment did not carry an x402 payment signature`)}switch(n.status){case`pending`:throw new td(n.id,n.reasons,n.expiresAt);case`processing`:throw new Qu(`The payment is still processing (intent ${n.id}); this client cannot resume an in-flight x402 settlement`);case`blocked`:case`failed`:throw new Qu(`Catena declined the payment`,n.reasons)}return Ru(n.status)}function cd(e,t){return t?.body!==void 0&&t.body!==null&&typeof t.body!=`string`&&!(t.body instanceof URLSearchParams)&&!(t.body instanceof Blob)&&!(t.body instanceof ArrayBuffer)&&!ArrayBuffer.isView(t.body)?!1:typeof Request<`u`&&e instanceof Request?e.body===null&&!e.bodyUsed:!0}function ld(e,t){let n=(t.baseFetch??globalThis.fetch).bind(globalThis);return async(r,i)=>{let a=await n(r,i);if(a.status!==402)return a;let o=Xu(a);if(!o)return a;if(!cd(r,i))throw new Qu(`The request body cannot be replayed after payment; buffer the body (string, Blob, or ArrayBuffer) before using the x402 fetch wrapper`);let s=await ad(e,{accountId:t.accountId,paymentRequired:o,...t.maxAtomicAmount!==void 0&&{maxAtomicAmount:t.maxAtomicAmount}});await rd(s,()=>t.onPayment?.(s));let c=new Headers(typeof Request<`u`&&r instanceof Request?r.headers:void 0);new Headers(i?.headers).forEach((e,t)=>{c.set(t,e)}),c.set(`PAYMENT-SIGNATURE`,s.paymentSignature);let l=await rd(s,()=>n(r,{...i,headers:c}));return Zu(e,s.intentId,l),l}}function ud(e,t){try{T(e,{recursive:!0,mode:448}),S(e,448);let n=te(e,t);return T(n,{recursive:!0,mode:448}),S(n,448),n}catch{return}}const dd=4e3;function fd(e){try{return A(e)}catch{return}}function pd(e,t,n){try{x(e,t)}catch{I(n)}}function md(e){let t=ne(e),n=N(t),r=fd(n);(r===void 0||!r.isDirectory())&&I(`--output ${e}: directory ${n} does not exist`);let i=fd(t);return i===void 0?(pd(n,C.W_OK|C.X_OK,`--output ${e}: directory ${n} is not writable`),t):(i.isDirectory()&&I(`--output ${e}: destination is a directory`),i.isFile()||I(`--output ${e}: destination is not a regular file`),pd(t,C.W_OK,`--output ${e}: destination is not writable`),t)}const hd=/^(?:con|prn|aux|nul|com\d|lpt\d)$/i;function gd(e){if(e!==void 0&&G.test(e)&&!hd.test(e))return`${e}.body`;let t=`${Date.now()}-${_(4).toString(`hex`)}.body`;return e===void 0?`unpaid-${t}`:`paid-${t}`}function _d(e,t){let n=ud(zs(),`responses`);if(n===void 0)return;let r=te(n,gd(t));try{return j(r,e,{mode:384}),r}catch{return}}function vd(e){let t=e.subarray(0,dd*4),n=t.toString(`utf8`);return{decoded:n,complete:t.length===e.length&&n.length<=dd&&ie(e)}}function yd({decoded:e,complete:t}){let n=e.slice(0,dd),r=n.charCodeAt(n.length-1);return{body:r>=55296&&r<=56319?n.slice(0,-1):n,...!t&&{bodyTruncated:!0}}}function bd(e,t){if(t.complete)return{body:t.decoded};if(e.length>268435456)return{...yd(t),error:`no writable location for the ${e.length}-byte body and it is too large to inline; only the .body preview survived`};if(ie(e)){let t=e.toString(`utf8`);if(6*t.length+2<=re.MAX_STRING_LENGTH)return{body:t};try{return JSON.stringify(t),{body:t}}catch{}}return{body:e.toString(`base64`),bodyEncoding:`base64`}}function xd(e){return e.error===void 0?e.bodyEncoding===void 0?`the full body is inlined in the result's .body field`:`the full body is inlined base64-encoded in the result's .body field`:e.error}function Sd(e,t,n){let r=_d(e,t);return r===void 0?bd(e,n):{...yd(n),bodyPath:r}}function Cd(e,t,n){let r=vd(e);if(n===void 0)return r.complete?{body:r.decoded}:Sd(e,t,r);try{j(n,e,{mode:384})}catch(i){let a=Sd(e,t,r),o=`--output ${n}: ${se(i)}`;return`bodyPath`in a?{...a,error:`${o}; the full body was saved to ${a.bodyPath}`}:{...a,error:`${o}; ${xd(a)}`}}return{...yd(r),bodyPath:n}}function wd(e){if(e===`@-`)return Td(0,`stdin`);if(e.startsWith(`@`)){let t=e.slice(1);return t===``?I(`--data @<path>: no file path given`):Td(t,`@${t}`)}return e}function Td(e,t){try{return E(e,`utf8`)}catch(e){return I(`--data ${t}: ${se(e)}`)}}function Ed(e){let[t,n=``]=e.split(`.`);return BigInt(`${t}${n.padEnd(6,`0`)}`)}function Dd(e){return{intentId:e.intentId,amountAtomicUsdc:e.requirements.amount,payTo:e.requirements.payTo,network:e.requirements.network}}const Od={"eip155:8453":`base`,"eip155:84532":`base-sepolia`};function kd(e){return Object.hasOwn(Od,e)?Od[e]:void 0}function Ad(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function jd(e){return e===void 0?``:` --profile ${Ad(e)}`}function Md(e){let t=e?.replaceAll(/[\p{C}\s]/gu,` `).replaceAll(/ {2,}/g,` `).trim();return t!==void 0&&t.length>0?t:void 0}function Nd(e,t,n,r){let i=kd(t)??Ad(t);return`catena counterparties create wallet --name ${Ad(n??`<name>`)} --address ${Ad(e)} --network ${i}${jd(r)}`}const Pd=f.pipe(f.string(),f.check(e=>gc.test(e.slice(0,Math.max(e.indexOf(`:`),0))),`must be "Name: Value" with a valid HTTP header name`),f.transform(e=>{let t=e.indexOf(`:`);return{name:e.slice(0,t),value:e.slice(t+1).trimStart()}}),f.check(e=>/^[\t\x20-\x7e\x80-\xff]*$/.test(e.value),`header value contains characters not allowed in an HTTP header`));function Fd(e,t){return e.some(e=>e.name.toLowerCase()===t)}function Id(e,t){Fd(e,`payment-signature`)&&I(`--header cannot set PAYMENT-SIGNATURE; the payment loop attaches it after paying`),Fd(e,`content-type`)&&t!==void 0&&I(`--header "Content-Type: ..." conflicts with --content-type`)}function Ld(e,t,n){let r=[...n!==void 0&&!Fd(e,`content-type`)?[[`content-type`,t??`application/json`]]:[],...e.map(e=>[e.name,e.value])];return r.length>0?new Headers(r):void 0}const Rd=W({url:z({description:`The paywalled URL to fetch (an x402 v2 endpoint)`,required:!0,schema:f.pipe(f.string(),f.url())}),account:z({description:`Source wallet account id the payment draws from`,required:!0,schema:we}),maxAmount:z({description:`Refuse challenges above this USD amount (decimal string, e.g. 0.25). Policy limits still apply server-side.`,schema:f.pipe(f.string(),f.regex(/^\d+(\.\d{1,6})?$/))}),method:V({description:`HTTP method for the request`,choices:[`GET`,`POST`]}),data:z({description:`Request body. Use @path to read a file or @- for stdin. Implies POST and a JSON content type unless overridden.`}),contentType:z({description:`Content-Type header for the request body (default application/json when --data is set)`}),output:z({description:`Write the full response body to this file (must be a regular file; written for any HTTP status — check .status). Without it .body is capped at 4000 characters; longer or non-UTF-8 bodies are saved to a file (path reported in .bodyPath)`}),header:B({description:`Request header as "Name: Value" (repeatable, like curl -H); sent on the initial request and the paid retry`,schema:Pd}),profile:Se,json:Ce}),zd=l({meta:{name:`x402`,description:`Fetch a URL, paying its x402 (HTTP 402) challenge via USDC`},args:Rd.args,async run({args:e,rawArgs:t}){let n=Rd.parse(e,t),r=n.method??(n.data===void 0?`GET`:`POST`);n.data!==void 0&&r!==`POST`&&I(`--data cannot be sent with --method ${r}; a body requires POST`),n.contentType!==void 0&&n.data===void 0&&I(`--content-type has no effect without --data`),Id(n.header,n.contentType);let i=n.output===void 0?void 0:md(n.output),a=n.data===void 0?void 0:wd(n.data),o=Ld(n.header,n.contentType,a);await Ic(n)(async e=>{let t,s=ld(e,{accountId:n.account,...n.maxAmount!==void 0&&{maxAtomicAmount:Ed(n.maxAmount)},onPayment:e=>{t=e}}),c;try{c=await s(n.url,{method:r,...a!==void 0&&{body:a},...o!==void 0&&{headers:o}})}catch(e){if(e instanceof nd)return{status:null,paid:!0,retryFailed:!0,payment:Dd(e.receipt),error:e.message};if(e instanceof $u){let t=e.requiredNetworks.map(e=>kd(e)??e);return{status:null,paid:!1,retryFailed:!1,networkMismatch:{account:e.accountId,requiredNetworks:t,requiredNetworkIds:[...e.requiredNetworks]},error:`${e.message}. Re-run with --account set to a wallet account on ${t.join(` or `)} (your account ids are in \`catena accounts list${jd(n.profile)}\`).`}}if(e instanceof ed){let t=Md(e.serviceName),r=t!==void 0&&t.length<=40?t:void 0,i=Nd(e.payTo,e.network,r,n.profile),a=t===void 0?``:` The endpoint calls itself "${t.length>40?`${t.slice(0,40)}…`:t}" (unverified) — rename it if that is not a service you recognize.`;return{status:null,paid:!1,retryFailed:!1,counterpartyNotFound:{payTo:e.payTo,network:kd(e.network)??e.network,networkId:e.network,createCommand:i,nameIsPlaceholder:r===void 0,...t!==void 0&&{serviceName:t}},error:`${e.message}. Add it, then re-run:\n ${i}\n(counterparty creation may require approval per your policy)${a}`}}if(e instanceof td)return{status:null,paid:!1,retryFailed:!1,approvalPending:{intentId:e.intentId,expiresAt:e.expiresAt,reasons:[...e.reasons]},error:e.message};throw e}let l={status:c.status,paid:t!==void 0,retryFailed:!1,...t!==void 0&&{payment:Dd(t)}},u;try{u=Buffer.from(await c.arrayBuffer())}catch(e){let r=t===void 0?``:`; the payment settled — re-read the PAYMENT-SIGNATURE with \`catena intents get ${t.intentId}${jd(n.profile)}\` to retry manually`;return{...l,error:`failed to read the response body: ${se(e)}${r}`}}return{...l,...Cd(u,t?.intentId,i)}},{exitCode:e=>+(`error`in e)})}}),Bd=f.object({version:f.literal(1),result:f.literal(`latest-version`),latestVersion:f.string(),checkedAt:f.pipe(f.string(),f.isoTimestamp())}),Vd=f.object({version:f.literal(1),result:f.literal(`fetch-failure`),checkedAt:f.pipe(f.string(),f.isoTimestamp())}),Hd=f.variant(`result`,[Bd,Vd]),Ud=f.object({"dist-tags":f.object({latest:f.string()})}),Wd=`cache`;function Gd(){return te(zs(),Wd,`cli-version.json`)}function Kd(e){return new URL(encodeURIComponent(e),`https://registry.npmjs.org/`).href}function qd(e){try{let t=JSON.parse(E(e,`utf8`)),n=f.safeParse(Hd,t);return n.success?n.output:void 0}catch{return}}function Jd(e){let t=qd(e);if(!t)return;let n=Date.parse(t.checkedAt);if(!Number.isFinite(n))return;let r=Date.now()-n,i=t.result===`fetch-failure`?36e5:864e5;if(!(r<0||r>=i))return t}function Yd(e){try{return!w(e)||A(e).isFile()}catch{return!1}}function Xd(e){let t=ud(zs(),Wd);if(t===void 0||!Yd(e))return!1;let n=te(t,`.cli-version-check-${_(6).toString(`hex`)}.tmp`);try{return j(n,``,{encoding:`utf8`,mode:384}),k(n,{force:!0}),!0}catch{try{k(n,{force:!0})}catch{}return!1}}function Zd(e,t){if(ud(zs(),Wd)===void 0)return!1;try{let n=`${e}.${_(6).toString(`hex`)}.tmp`;return j(n,`${JSON.stringify({version:1,...t,checkedAt:new Date().toISOString()},null,2)}\n`,{encoding:`utf8`,mode:384}),O(n,e),!0}catch{return!1}}async function Qd(e){let t=new AbortController,n=setTimeout(()=>t.abort(),750);n.unref();try{let n=await fetch(Kd(e.packageName),{headers:{accept:`application/json`},signal:t.signal});if(!n.ok)return;let r=await n.json(),i=f.safeParse(Ud,r);return i.success?i.output[`dist-tags`].latest:void 0}catch{return}finally{clearTimeout(n)}}function $d(e){let t=F.valid(e.currentVersion),n=F.valid(e.latestVersion);t!==null&&n!==null&&F.gt(n,t)&&console.error(`A newer ${e.packageName} version is available: ${n} (current ${t}).`)}async function ef({packageName:e,currentVersion:t}){let n=Gd(),r=Jd(n);if(r?.result===`latest-version`){$d({packageName:e,currentVersion:t,latestVersion:r.latestVersion});return}if(r?.result===`fetch-failure`||!Xd(n))return;let i=await Qd({packageName:e});if(i===void 0){Zd(n,{result:`fetch-failure`});return}Zd(n,{result:`latest-version`,latestVersion:i}),$d({packageName:e,currentVersion:t,latestVersion:i})}async function tf(e){return typeof e==`function`?await e():await e}async function nf(e){return typeof e==`function`?await e():await e}async function rf(e){return typeof e==`function`?await e():await e}async function af(e,t,n=[]){if(e===t)return n;let r=await rf(e.subCommands??{});return(await Promise.all(Object.entries(r).map(async([e,r])=>af(await tf(r),t,[...n,e])))).find(e=>e!==void 0)}async function of(e,t){if(!e||!t||t.length<2)return e;let n=await nf(e.meta??{});return{...e,meta:{...n,name:t.slice(0,-1).join(` `)}}}function sf(e){return async(t,n)=>{let r=await u(t,await of(n,await af(e,t)));console.log(`${r}\n`)}}function cf({shouldCheckCliVersionFreshness:e}){return l({meta:{name:`catena`,version:oe,description:`Catena CLI`},async setup({rawArgs:t}){!e||t.length===0||await ef({packageName:ae,currentVersion:oe})},subCommands:{link:ou,unlink:Fu,profiles:bu,whoami:Lu,policy:uu,accounts:Jc,intents:wl,send:ju,transfer:Nu,x402:zd,counterparties:ml,feedback:yl,guide:xl}})}const lf=cf({shouldCheckCliVersionFreshness:!0});cf({shouldCheckCliVersionFreshness:!1});function uf(){d(lf,{showUsage:sf(lf)})}uf();export{};
526
+ ;const zu=e(s(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=r<i?r:i;t<n;++t)if(a.d[t]!==e.d[t])return a.d[t]>e.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return E(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,E(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?D(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):E(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):D(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(E(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,E(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l<u&&(o=m,m=h,h=o,s=l,l=u,u=s),o=[],s=l+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?E(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),E(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=O(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=E(new a(i),e+1,t),r=O(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?O(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=E(new o(a),e+S(a)+1,t),r=O(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return E(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return E(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),k(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),k(u.d,t);return i=!0,e.s<0?new f(d).div(o):E(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=O(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=E(new o(a),e,t),r=S(a),i=O(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),E(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return O(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?E(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?E(t,m):t}function v(e,t,n){if(e!==~~e||e<t||e>n)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=p-r.length,n&&(a+=w(n)),a+=r;o=e[t],r=o+``,n=p-r.length,n&&(a+=w(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}var b=(function(){function e(e,t){var n,r=0,i=e.length;for(e=e.slice();i--;)n=e[i]*t+r,e[i]=n%f|0,r=n/f|0;return r&&e.unshift(r),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]<t[n]),e[n]=r*f+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,ee,D,O,k=r.constructor,A=r.s==i.s?1:-1,j=r.d,M=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,D=M.length,T=j.length,g=new k(A),_=g.d=[],u=0;M[u]==(j[u]||0);)++u;if(M[u]>(j[u]||0)&&--l,x=o==null?o=k.precision:s?o+(S(r)-S(i))+1:o,x<0)return new k(0);if(x=x/p+2|0,u=0,D==1)for(d=0,M=M[0],x++;(u<T||d)&&x--;u++)C=d*f+(j[u]||0),_[u]=C/M|0,d=C%M|0;else{for(d=f/(M[0]+1)|0,d>1&&(M=e(M,d),j=e(j,d),D=M.length,T=j.length),w=D,v=j.slice(0,D),y=v.length;y<D;)v[y++]=0;O=M.slice(),O.unshift(0),ee=M[0],M[1]>=f/2&&++ee;do d=0,c=t(M,v,D,y),c<0?(b=v[0],D!=y&&(b=b*f+(v[1]||0)),d=b/ee|0,d>1?(d>=f&&(d=f-1),m=e(M,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,D<h?O:M,h))):(d==0&&(c=d=1),m=M.slice()),h=m.length,h<y&&m.unshift(0),n(v,m,y),c==-1&&(y=v.length,c=t(M,v,D,y),c<1&&(d++,n(v,D<y?O:M,y))),y=v.length):c===0&&(d++,v=[0]),_[u++]=d,c&&v[0]?v[y++]=j[w]||0:(v=[j[w]],y=1);while((w++<T||v[0]!==void 0)&&x--)}return _[0]||_.shift(),g.e=l,E(g,s?o+S(g)+1:o)}})();function x(e,t){var n,r,a,o,c,u,f=0,p=0,m=e.constructor,h=m.precision;if(S(e)>16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=E(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=E(o.times(o),u);return m.precision=h,t==null?(i=!0,E(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return E(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,E(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=E(g.times(g),f),o=3;;){if(c=E(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,E(l,x)):l;l=u,o+=2}}function ee(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),r<a){for(r&&e.d.push(+t.slice(0,r)),a-=p;r<a;)e.d.push(+t.slice(r,r+=p));t=t.slice(r),r=p-t.length}else r-=a;for(;r--;)t+=`0`;if(e.d.push(+t),i&&(e.e>h||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function E(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function D(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?E(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a<c,d&&(c=a),a=0;a<c;a++)if(l[a]!=m[a]){d=l[a]<m[a];break}s=0}for(d&&(n=l,l=m,m=n,t.s=-t.s),c=l.length,a=m.length-c;a>0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]<m[a]){for(o=a;o&&l[--o]===0;)l[o]=f-1;--l[o],l[a]+=f}l[a]-=m[a]}for(;l[--c]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(t.d=l,t.e=r,i?E(t,g):t):new h(0)}function O(e,t,n){var r,i=S(e),a=y(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function k(e,t){if(e.length>t)return e.length=t,!0}function A(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return ee(t,e.toString())}if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))ee(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=A,i.config=i.set=j,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function j(e){if(!e||typeof e!=`object`)throw Error(a+`Object expected`);var t,r,i,s=[`precision`,1,n,`rounding`,0,8,`toExpNeg`,-1/0,0,`toExpPos`,0,1/0];for(t=0;t<s.length;t+=3)if((i=e[r=s[t]])!==void 0)if(c(i)===i&&i>=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i);if((i=e[r=`LN10`])!==void 0)if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i);return this}r=A(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))(),1).default;zu.set({rounding:zu.ROUND_HALF_EVEN}),new zu(1e6),new zu(1e3);const Bu=f.pipe(f.string(`Amount must be a string`),f.nonEmpty(`Amount must not be empty`),f.check(e=>e.trim()===e,`Amount must not have leading or trailing whitespace`),f.check(e=>!e.includes(`e`)&&!e.includes(`E`),`Scientific notation is not supported (e.g. use 1000000 instead of 1e6)`),f.check(e=>!e.startsWith(`+`),`Amount must not have a '+' prefix`),f.check(e=>!e.startsWith(`-`),`Amount must be non-negative`),f.check(e=>{try{return new zu(e).gte(0)}catch{return!1}},`Amount must be a valid decimal (e.g. 100 or 100.50)`)),Vu=$({account:Q({description:`Source account id`,required:!0,schema:qo}),rail:Q({description:`Destination counterparty rail id (cprl_...)`,required:!0,schema:qo}),amount:Q({description:`USD amount as a decimal string (e.g. 125.00)`,required:!0,schema:Bu,showValueInError:!0}),method:Po({description:`ach | wire | on-chain; ach and wire require a bank rail, on-chain a wallet rail`,required:!0,choices:Ga}),memo:Q({description:`Memo on the underlying transfer`}),description:Q({description:`Operator-facing description`}),idempotencyKey:Q({description:`Optional. Usually omit this. Identical retries are deduplicated for about 15 minutes after the movement settles and return the original intent, even if it failed, so a bare retry never re-sends on its own. Set a unique value when you intentionally want another payment with the same details, or a stable one to keep a single payment deduplicated beyond that window.`,schema:il}),profile:Wo,json:Go}),Hu=l({meta:{name:`send`,description:`Submit a USD send intent to a counterparty rail`},args:Vu.args,async run({args:e}){let t=Vu.parse(e),n=Gc(t),r={type:`send`,accountId:t.account,counterpartyRailId:t.rail,amount:t.amount,method:t.method,...t.memo?{memo:t.memo}:{},...t.description?{description:t.description}:{}};await n(e=>e.submitIntent({action:r,...t.idempotencyKey?{idempotencyKey:t.idempotencyKey}:{}}))}}),Uu=$({from:Q({description:`Source account id`,required:!0,schema:qo}),to:Q({description:`Destination account id`,required:!0,schema:qo}),amount:Q({description:`USD amount as a decimal string (e.g. 125.00)`,required:!0,schema:Bu,showValueInError:!0}),memo:Q({description:`Memo on the underlying transfer`}),description:Q({description:`Operator-facing description`}),idempotencyKey:Q({description:`Optional. Usually omit this. Identical retries are deduplicated for about 15 minutes after the movement settles and return the original intent, even if it failed, so a bare retry never re-sends on its own. Set a unique value when you intentionally want another transfer with the same details, or a stable one to keep a single transfer deduplicated beyond that window.`,schema:il}),profile:Wo,json:Go}),Wu=l({meta:{name:`transfer`,description:`Submit a USD transfer intent between two of this agent's accounts`},args:Uu.args,async run({args:e}){let t=Uu.parse(e),n=Gc(t),r={type:`transfer`,accountId:t.from,toAccountId:t.to,amount:t.amount,...t.memo?{memo:t.memo}:{},...t.description?{description:t.description}:{}};await n(e=>e.submitIntent({action:r,...t.idempotencyKey?{idempotencyKey:t.idempotencyKey}:{}}))}}),Gu=$({profile:Wo,force:No({description:`Remove the profile and its local credentials without contacting the server; use when the credential is missing, revoked, or a link was interrupted`,default:!1}),json:Go}),Ku=l({meta:{name:`unlink`,description:`Disconnect the selected agent profile`},args:Gu.args,async run({args:e}){let t=Gu.parse(e),n=Ic(),r;try{r=Pc({flag:Hc(t),env:process.env[Ac],cwd:process.cwd(),log:e=>console.error(e)}).name}catch(e){Z(e)}if(t.force){let e;try{if(e=pc(r),e===null)throw Error(`Profile "${r}" not found`);await n.delete(e.client_instance_id),await n.delete(Xl(e.client_instance_id)),cc(r)}catch(e){Z(e)}Vc({success:!0,profile:r,...ic(e)?{agentId:e.agent_id}:{},local:!0},{compact:t.json});return}let i=`To remove only this machine's copy, run 'catena unlink --profile ${r} --force'.`,a=await Cc({profileName:r,fallbackBankUrl:kc},n);a.ok||Z(`${a.message} ${i}`);let o=Fc(a);try{await o.unlinkAgent(),await n.delete(a.clientInstanceId),await n.delete(Xl(a.clientInstanceId)),cc(r)}catch(e){Z(`${Co(Bc(e,r))} ${i}`)}Vc({success:!0,profile:r,agentId:a.agentId},{compact:t.json})}}),qu=$({profile:Wo,json:Go}),Ju=l({meta:{name:`whoami`,description:`Show which agent you are currently acting as`},args:qu.args,async run({args:e}){await Gc(qu.parse(e))(e=>e.whoami())}});function Yu(e){throw Error(`Unhandled case: ${String(e)}`)}const Xu=[`PAYMENT-REQUIRED`,`X-Payment-Required`],Zu=/^0x[0-9a-fA-F]{64}$/,Qu=/^0x[0-9a-fA-F]{40}$/,$u=f.looseObject({success:f.boolean(),transaction:f.string()}),ed=f.looseObject({x402Version:f.literal(2),accepts:f.array(so),resource:f.optional(co)}),td=`x402_network_mismatch`,nd=`x402_counterparty_rail_not_found`,rd=new Set([`x402_requirement_not_payable`,td,nd]),id={"eip155:8453":`Base`,"eip155:84532":`Base Sepolia`};function ad(e){let t=Object.hasOwn(id,e)?id[e]:void 0;return t?`${t} (${e})`:e}function od(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=Uint8Array.from(atob(t),e=>e.charCodeAt(0));return JSON.parse(new TextDecoder().decode(n))}function sd(e){let t=Xu.map(t=>e.headers.get(t)).find(e=>e!==null);if(t)try{let e=f.safeParse(ed,od(t));return e.success?e.output:void 0}catch{return}}async function cd(e,t,n){try{let r=n.headers.get(`PAYMENT-RESPONSE`);if(!r)return;let i=f.safeParse($u,od(r));if(!i.success||!i.output.success||!Zu.test(i.output.transaction))return;await e.reportSettlement({intentId:t,txHash:i.output.transaction})}catch{}}var ld=class extends Error{reasons;constructor(e,t=[],n={}){super(t.length>0&&(n.appendReasonsToMessage??!0)?`${e}: ${t.join(`; `)}`:e),this.name=`X402PaymentError`,this.reasons=t}},ud=class extends ld{accountId;requiredNetworks;constructor(e,t,n=[]){super(`Account ${e} cannot fund this 402 challenge: it must be paid from a wallet account on ${t.map(ad).join(` or `)}`,n,{appendReasonsToMessage:!1}),this.name=`X402NetworkMismatchError`,this.accountId=e,this.requiredNetworks=t}},dd=class extends ld{payTo;network;serviceName;constructor(e,t,n,r=[]){super(`This 402 pays ${e} on ${ad(t)}, which is not a saved counterparty wallet rail; add it as a counterparty before paying`,r,{appendReasonsToMessage:!1}),this.name=`X402CounterpartyNotFoundError`,this.payTo=e,this.network=t,this.serviceName=n}},fd=class extends ld{intentId;expiresAt;constructor(e,t,n){super(`The payment is awaiting a human approval (intent ${e}); once an operator approves it, retry the request to complete the payment`,t),this.name=`X402ApprovalPendingError`,this.intentId=e,this.expiresAt=n}},pd=class extends ld{receipt;constructor(e,t){super(`The payment settled (intent ${e.intentId}) but the post-payment continuation failed; retry the request with the PAYMENT-SIGNATURE header from the receipt (or getIntent("${e.intentId}") data.x402.paymentSignature) instead of paying again`),this.name=`X402RetryFailedError`,this.receipt=e,this.cause=t}};async function md(e,t){try{return await t()}catch(t){throw new pd(e,t)}}var hd=class extends ld{intentId;requirements;constructor(e,t,n){super(`The payment could not be confirmed (intent ${e}); check getIntent("${e}") — completed: reuse its data.x402.paymentSignature as the PAYMENT-SIGNATURE header; processing: poll until terminal; pay again only after blocked or failed`),this.name=`X402SubmitInterruptedError`,this.intentId=e,this.requirements=t,this.cause=n}};async function gd(e,t){let n=t.paymentRequired.accepts.filter(e=>e.scheme===`exact`),r=n.filter(e=>t.maxAtomicAmount===void 0||/^\d+$/.test(e.amount)&&BigInt(e.amount)<=t.maxAtomicAmount).slice(0,5);if(r.length===0)throw new ld(n.length>0&&t.maxAtomicAmount!==void 0?`Every requirement in the 402 challenge costs more than the caller's maximum amount`:`The 402 challenge offers no exact-scheme requirement Catena can pay`);let i=t.resource??t.paymentRequired.resource,a=[];for(let n of r){let r=await vd(e,{accountId:t.accountId,requirements:n,resource:i}).catch(e=>{if(e instanceof mo&&e.code!==void 0&&rd.has(e.code)){a.push({error:e,requirement:n});return}throw e});if(r)return r}let o=a.filter(e=>e.error.code===nd),s=a.filter(e=>e.error.code===td),c=a.filter(e=>e.error.code!==nd&&e.error.code!==td),l=[...new Set([...o,...s,...c].map(e=>e.error.message))],u=o.find(e=>e.error.status===404&&Qu.test(e.requirement.payTo));throw u?new dd(u.requirement.payTo,u.requirement.network,i?.serviceName,l):s.length>0&&o.length===0?new ud(t.accountId,[...new Set(s.map(e=>e.requirement.network))],l):new ld(`No requirement in the 402 challenge is payable from this account`,l)}const _d=f.object({x402:f.object({paymentSignature:f.string()})});async function vd(e,t){let n=await e.submitIntent({action:{type:`x402`,accountId:t.accountId,paymentRequirements:t.requirements,...t.resource!==void 0&&{resource:t.resource}},idempotencyKey:crypto.randomUUID()}).catch(e=>{throw e instanceof yo&&e.outcome===`unknown`?new hd(e.intentId,t.requirements,e):e});if(n.status===`completed`){let e=f.safeParse(_d,n.data);if(e.success)return{intentId:n.id,paymentSignature:e.output.x402.paymentSignature,requirements:t.requirements};throw new ld(`The completed payment did not carry an x402 payment signature`)}switch(n.status){case`pending`:throw new fd(n.id,n.reasons,n.expiresAt);case`processing`:throw new ld(`The payment is still processing (intent ${n.id}); this client cannot resume an in-flight x402 settlement`);case`blocked`:case`failed`:throw new ld(`Catena declined the payment`,n.reasons)}return Yu(n.status)}function yd(e,t){return t?.body!==void 0&&t.body!==null&&typeof t.body!=`string`&&!(t.body instanceof URLSearchParams)&&!(t.body instanceof Blob)&&!(t.body instanceof ArrayBuffer)&&!ArrayBuffer.isView(t.body)?!1:typeof Request<`u`&&e instanceof Request?e.body===null&&!e.bodyUsed:!0}function bd(e,t){let n=(t.baseFetch??globalThis.fetch).bind(globalThis);return async(r,i)=>{let a=await n(r,i);if(a.status!==402)return a;let o=sd(a);if(!o)return a;if(!yd(r,i))throw new ld(`The request body cannot be replayed after payment; buffer the body (string, Blob, or ArrayBuffer) before using the x402 fetch wrapper`);let s=await gd(e,{accountId:t.accountId,paymentRequired:o,...t.maxAtomicAmount!==void 0&&{maxAtomicAmount:t.maxAtomicAmount}});await md(s,()=>t.onPayment?.(s));let c=new Headers(typeof Request<`u`&&r instanceof Request?r.headers:void 0);new Headers(i?.headers).forEach((e,t)=>{c.set(t,e)}),c.set(`PAYMENT-SIGNATURE`,s.paymentSignature);let l=await md(s,()=>n(r,{...i,headers:c}));return cd(e,s.intentId,l),l}}function xd(e,t){try{T(e,{recursive:!0,mode:448}),S(e,448);let n=ne(e,t);return T(n,{recursive:!0,mode:448}),S(n,448),n}catch{return}}const Sd=4e3;function Cd(e){try{return k(e)}catch{return}}function wd(e,t,n){try{x(e,t)}catch{Z(n)}}function Td(e){let t=re(e),n=M(t),r=Cd(n);(r===void 0||!r.isDirectory())&&Z(`--output ${e}: directory ${n} does not exist`);let i=Cd(t);return i===void 0?(wd(n,C.W_OK|C.X_OK,`--output ${e}: directory ${n} is not writable`),t):(i.isDirectory()&&Z(`--output ${e}: destination is a directory`),i.isFile()||Z(`--output ${e}: destination is not a regular file`),wd(t,C.W_OK,`--output ${e}: destination is not writable`),t)}const Ed=/^(?:con|prn|aux|nul|com\d|lpt\d)$/i;function Dd(e){if(e!==void 0&&Ko.test(e)&&!Ed.test(e))return`${e}.body`;let t=`${Date.now()}-${_(4).toString(`hex`)}.body`;return e===void 0?`unpaid-${t}`:`paid-${t}`}function Od(e,t){let n=xd(Js(),`responses`);if(n===void 0)return;let r=ne(n,Dd(t));try{return A(r,e,{mode:384}),r}catch{return}}function kd(e){let t=e.subarray(0,Sd*4),n=t.toString(`utf8`);return{decoded:n,complete:t.length===e.length&&n.length<=Sd&&ae(e)}}function Ad({decoded:e,complete:t}){let n=e.slice(0,Sd),r=n.charCodeAt(n.length-1);return{body:r>=55296&&r<=56319?n.slice(0,-1):n,...!t&&{bodyTruncated:!0}}}function jd(e,t){if(t.complete)return{body:t.decoded};if(e.length>268435456)return{...Ad(t),error:`no writable location for the ${e.length}-byte body and it is too large to inline; only the .body preview survived`};if(ae(e)){let t=e.toString(`utf8`);if(6*t.length+2<=ie.MAX_STRING_LENGTH)return{body:t};try{return JSON.stringify(t),{body:t}}catch{}}return{body:e.toString(`base64`),bodyEncoding:`base64`}}function Md(e){return e.error===void 0?e.bodyEncoding===void 0?`the full body is inlined in the result's .body field`:`the full body is inlined base64-encoded in the result's .body field`:e.error}function Nd(e,t,n){let r=Od(e,t);return r===void 0?jd(e,n):{...Ad(n),bodyPath:r}}function Pd(e,t,n){let r=kd(e);if(n===void 0)return r.complete?{body:r.decoded}:Nd(e,t,r);try{A(n,e,{mode:384})}catch(i){let a=Nd(e,t,r),o=`--output ${n}: ${Co(i)}`;return`bodyPath`in a?{...a,error:`${o}; the full body was saved to ${a.bodyPath}`}:{...a,error:`${o}; ${Md(a)}`}}return{...Ad(r),bodyPath:n}}function Fd(e){if(e===`@-`)return Id(0,`stdin`);if(e.startsWith(`@`)){let t=e.slice(1);return t===``?Z(`--data @<path>: no file path given`):Id(t,`@${t}`)}return e}function Id(e,t){try{return ee(e,`utf8`)}catch(e){return Z(`--data ${t}: ${Co(e)}`)}}function Ld(e){let[t,n=``]=e.split(`.`);return BigInt(`${t}${n.padEnd(6,`0`)}`)}function Rd(e){return{intentId:e.intentId,amountAtomicUsdc:e.requirements.amount,payTo:e.requirements.payTo,network:e.requirements.network}}const zd={"eip155:8453":`base`,"eip155:84532":`base-sepolia`};function Bd(e){return Object.hasOwn(zd,e)?zd[e]:void 0}function Vd(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Hd(e){return e===void 0?``:` --profile ${Vd(e)}`}function Ud(e){let t=e?.replaceAll(/[\p{C}\s]/gu,` `).replaceAll(/ {2,}/g,` `).trim();return t!==void 0&&t.length>0?t:void 0}function Wd(e,t,n,r){let i=Bd(t)??Vd(t);return`catena counterparties create wallet --name ${Vd(n??`<name>`)} --address ${Vd(e)} --network ${i}${Hd(r)}`}const Gd=f.pipe(f.string(),f.check(e=>Tc.test(e.slice(0,Math.max(e.indexOf(`:`),0))),`must be "Name: Value" with a valid HTTP header name`),f.transform(e=>{let t=e.indexOf(`:`);return{name:e.slice(0,t),value:e.slice(t+1).trimStart()}}),f.check(e=>/^[\t\x20-\x7e\x80-\xff]*$/.test(e.value),`header value contains characters not allowed in an HTTP header`));function Kd(e,t){return e.some(e=>e.name.toLowerCase()===t)}function qd(e,t){Kd(e,`payment-signature`)&&Z(`--header cannot set PAYMENT-SIGNATURE; the payment loop attaches it after paying`),Kd(e,`content-type`)&&t!==void 0&&Z(`--header "Content-Type: ..." conflicts with --content-type`)}function Jd(e,t,n){let r=[...n!==void 0&&!Kd(e,`content-type`)?[[`content-type`,t??`application/json`]]:[],...e.map(e=>[e.name,e.value])];return r.length>0?new Headers(r):void 0}const Yd=$({url:Q({description:`The paywalled URL to fetch (an x402 v2 endpoint)`,required:!0,schema:f.pipe(f.string(),f.url())}),account:Q({description:`Source wallet account id the payment draws from`,required:!0,schema:qo}),maxAmount:Q({description:`Refuse challenges above this USD amount (decimal string, e.g. 0.25). Policy limits still apply server-side.`,schema:f.pipe(f.string(),f.regex(/^\d+(\.\d{1,6})?$/))}),method:Po({description:`HTTP method for the request`,choices:[`GET`,`POST`]}),data:Q({description:`Request body. Use @path to read a file or @- for stdin. Implies POST and a JSON content type unless overridden.`}),contentType:Q({description:`Content-Type header for the request body (default application/json when --data is set)`}),output:Q({description:`Write the full response body to this file (must be a regular file; written for any HTTP status — check .status). Without it .body is capped at 4000 characters; longer or non-UTF-8 bodies are saved to a file (path reported in .bodyPath)`}),header:Mo({description:`Request header as "Name: Value" (repeatable, like curl -H); sent on the initial request and the paid retry`,schema:Gd}),profile:Wo,json:Go}),Xd=l({meta:{name:`x402`,description:`Fetch a URL, paying its x402 (HTTP 402) challenge via USDC`},args:Yd.args,async run({args:e,rawArgs:t}){let n=Yd.parse(e,t),r=n.method??(n.data===void 0?`GET`:`POST`);n.data!==void 0&&r!==`POST`&&Z(`--data cannot be sent with --method ${r}; a body requires POST`),n.contentType!==void 0&&n.data===void 0&&Z(`--content-type has no effect without --data`),qd(n.header,n.contentType);let i=n.output===void 0?void 0:Td(n.output),a=n.data===void 0?void 0:Fd(n.data),o=Jd(n.header,n.contentType,a);await Gc(n)(async e=>{let t,s=bd(e,{accountId:n.account,...n.maxAmount!==void 0&&{maxAtomicAmount:Ld(n.maxAmount)},onPayment:e=>{t=e}}),c;try{c=await s(n.url,{method:r,...a!==void 0&&{body:a},...o!==void 0&&{headers:o}})}catch(e){if(e instanceof pd)return{status:null,paid:!0,retryFailed:!0,payment:Rd(e.receipt),error:e.message};if(e instanceof ud){let t=e.requiredNetworks.map(e=>Bd(e)??e);return{status:null,paid:!1,retryFailed:!1,networkMismatch:{account:e.accountId,requiredNetworks:t,requiredNetworkIds:[...e.requiredNetworks]},error:`${e.message}. Re-run with --account set to a wallet account on ${t.join(` or `)} (your account ids are in \`catena accounts list${Hd(n.profile)}\`).`}}if(e instanceof dd){let t=Ud(e.serviceName),r=t!==void 0&&t.length<=40?t:void 0,i=Wd(e.payTo,e.network,r,n.profile),a=t===void 0?``:` The endpoint calls itself "${t.length>40?`${t.slice(0,40)}…`:t}" (unverified) — rename it if that is not a service you recognize.`;return{status:null,paid:!1,retryFailed:!1,counterpartyNotFound:{payTo:e.payTo,network:Bd(e.network)??e.network,networkId:e.network,createCommand:i,nameIsPlaceholder:r===void 0,...t!==void 0&&{serviceName:t}},error:`${e.message}. Add it, then re-run:\n ${i}\n(counterparty creation may require approval per your policy)${a}`}}if(e instanceof fd)return{status:null,paid:!1,retryFailed:!1,approvalPending:{intentId:e.intentId,expiresAt:e.expiresAt,reasons:[...e.reasons]},error:e.message};throw e}let l={status:c.status,paid:t!==void 0,retryFailed:!1,...t!==void 0&&{payment:Rd(t)}},u;try{u=Buffer.from(await c.arrayBuffer())}catch(e){let r=t===void 0?``:`; the payment settled — re-read the PAYMENT-SIGNATURE with \`catena intents get ${t.intentId}${Hd(n.profile)}\` to retry manually`;return{...l,error:`failed to read the response body: ${Co(e)}${r}`}}return{...l,...Pd(u,t?.intentId,i)}},{exitCode:e=>+(`error`in e)})}}),Zd=f.object({version:f.literal(1),result:f.literal(`latest-version`),latestVersion:f.string(),checkedAt:f.pipe(f.string(),f.isoTimestamp())}),Qd=f.object({version:f.literal(1),result:f.literal(`fetch-failure`),checkedAt:f.pipe(f.string(),f.isoTimestamp())}),$d=f.variant(`result`,[Zd,Qd]),ef=f.object({"dist-tags":f.object({latest:f.string()})}),tf=`cache`;function nf(){return ne(Js(),tf,`cli-version.json`)}function rf(e){return new URL(encodeURIComponent(e),`https://registry.npmjs.org/`).href}function af(e){try{let t=JSON.parse(ee(e,`utf8`)),n=f.safeParse($d,t);return n.success?n.output:void 0}catch{return}}function of(e){let t=af(e);if(!t)return;let n=Date.parse(t.checkedAt);if(!Number.isFinite(n))return;let r=Date.now()-n,i=t.result===`fetch-failure`?36e5:864e5;if(!(r<0||r>=i))return t}function sf(e){try{return!w(e)||k(e).isFile()}catch{return!1}}function cf(e){let t=xd(Js(),tf);if(t===void 0||!sf(e))return!1;let n=ne(t,`.cli-version-check-${_(6).toString(`hex`)}.tmp`);try{return A(n,``,{encoding:`utf8`,mode:384}),O(n,{force:!0}),!0}catch{try{O(n,{force:!0})}catch{}return!1}}function lf(e,t){if(xd(Js(),tf)===void 0)return!1;try{let n=`${e}.${_(6).toString(`hex`)}.tmp`;return A(n,`${JSON.stringify({version:1,...t,checkedAt:new Date().toISOString()},null,2)}\n`,{encoding:`utf8`,mode:384}),D(n,e),!0}catch{return!1}}async function uf(e){let t=new AbortController,n=setTimeout(()=>t.abort(),750);n.unref();try{let n=await fetch(rf(e.packageName),{headers:{accept:`application/json`},signal:t.signal});if(!n.ok)return;let r=await n.json(),i=f.safeParse(ef,r);return i.success?i.output[`dist-tags`].latest:void 0}catch{return}finally{clearTimeout(n)}}function df(e){let t=P.valid(e.currentVersion),n=P.valid(e.latestVersion);t!==null&&n!==null&&P.gt(n,t)&&console.error(`A newer ${e.packageName} version is available: ${n} (current ${t}).`)}async function ff({packageName:e,currentVersion:t}){let n=nf(),r=of(n);if(r?.result===`latest-version`){df({packageName:e,currentVersion:t,latestVersion:r.latestVersion});return}if(r?.result===`fetch-failure`||!cf(n))return;let i=await uf({packageName:e});if(i===void 0){lf(n,{result:`fetch-failure`});return}lf(n,{result:`latest-version`,latestVersion:i}),df({packageName:e,currentVersion:t,latestVersion:i})}async function pf(e){return typeof e==`function`?await e():await e}async function mf(e){return typeof e==`function`?await e():await e}async function hf(e){return typeof e==`function`?await e():await e}async function gf(e,t,n=[]){if(e===t)return n;let r=await hf(e.subCommands??{});return(await Promise.all(Object.entries(r).map(async([e,r])=>gf(await pf(r),t,[...n,e])))).find(e=>e!==void 0)}async function _f(e,t){if(!e||!t||t.length<2)return e;let n=await mf(e.meta??{});return{...e,meta:{...n,name:t.slice(0,-1).join(` `)}}}function vf(e){return async(t,n)=>{let r=await u(t,await _f(n,await gf(e,t)));console.log(`${r}\n`)}}function yf({shouldCheckCliVersionFreshness:e}){return l({meta:{name:`catena`,version:se,description:`Catena CLI`},async setup({rawArgs:t}){!e||t.length===0||await ff({packageName:oe,currentVersion:se})},subCommands:{link:vu,unlink:Ku,profiles:Mu,whoami:Ju,policy:Su,accounts:rl,intents:Il,send:Hu,transfer:Wu,x402:Xd,counterparties:El,feedback:jl,guide:Nl}})}const bf=yf({shouldCheckCliVersionFreshness:!0});yf({shouldCheckCliVersionFreshness:!1});function xf(){d(bf,{showUsage:vf(bf)})}xf();export{};