@bizzsv/bizz-payment 1.2.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,445 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));function l(){if(typeof window>`u`)return`*`;if(window.location.origin&&window.location.origin!==`null`)return window.location.origin;if(document.referrer)try{return new URL(document.referrer).origin}catch{return`*`}return`*`}var u=l(),d=o(((e,t)=>{t.exports={options:{usePureJavaScript:!1}}})),f=o(((e,t)=>{var n={};t.exports=n;var r={};n.encode=function(e,t,n){if(typeof t!=`string`)throw TypeError(`"alphabet" must be a string.`);if(n!==void 0&&typeof n!=`number`)throw TypeError(`"maxline" must be a number.`);var r=``;if(!(e instanceof Uint8Array))r=i(e,t);else{var a=0,o=t.length,s=t.charAt(0),c=[0];for(a=0;a<e.length;++a){for(var l=0,u=e[a];l<c.length;++l)u+=c[l]<<8,c[l]=u%o,u=u/o|0;for(;u>0;)c.push(u%o),u=u/o|0}for(a=0;e[a]===0&&a<e.length-1;++a)r+=s;for(a=c.length-1;a>=0;--a)r+=t[c[a]]}if(n){var d=RegExp(`.{1,`+n+`}`,`g`);r=r.match(d).join(`\r
2
+ `)}return r},n.decode=function(e,t){if(typeof e!=`string`)throw TypeError(`"input" must be a string.`);if(typeof t!=`string`)throw TypeError(`"alphabet" must be a string.`);var n=r[t];if(!n){n=r[t]=[];for(var i=0;i<t.length;++i)n[t.charCodeAt(i)]=i}e=e.replace(/\s/g,``);for(var a=t.length,o=t.charAt(0),s=[0],i=0;i<e.length;i++){var c=n[e.charCodeAt(i)];if(c===void 0)return;for(var l=0,u=c;l<s.length;++l)u+=s[l]*a,s[l]=u&255,u>>=8;for(;u>0;)s.push(u&255),u>>=8}for(var d=0;e[d]===o&&d<e.length-1;++d)s.push(0);return typeof Buffer<`u`?Buffer.from(s.reverse()):new Uint8Array(s.reverse())};function i(e,t){var n=0,r=t.length,i=t.charAt(0),a=[0];for(n=0;n<e.length();++n){for(var o=0,s=e.at(n);o<a.length;++o)s+=a[o]<<8,a[o]=s%r,s=s/r|0;for(;s>0;)a.push(s%r),s=s/r|0}var c=``;for(n=0;e.at(n)===0&&n<e.length()-1;++n)c+=i;for(n=a.length-1;n>=0;--n)c+=t[a[n]];return c}})),p=o(((e,t)=>{var n=d(),r=f(),i=t.exports=n.util=n.util||{};(function(){if(typeof process<`u`&&process.nextTick&&!process.browser){i.nextTick=process.nextTick,typeof setImmediate==`function`?i.setImmediate=setImmediate:i.setImmediate=i.nextTick;return}if(typeof setImmediate==`function`){i.setImmediate=function(){return setImmediate.apply(void 0,arguments)},i.nextTick=function(e){return setImmediate(e)};return}if(i.setImmediate=function(e){setTimeout(e,0)},typeof window<`u`&&typeof window.postMessage==`function`){var e=`forge.setImmediate`,t=[];i.setImmediate=function(n){t.push(n),t.length===1&&window.postMessage(e,`*`)};function n(n){if(n.source===window&&n.data===e){n.stopPropagation();var r=t.slice();t.length=0,r.forEach(function(e){e()})}}window.addEventListener(`message`,n,!0)}if(typeof MutationObserver<`u`){var n=Date.now(),r=!0,a=document.createElement(`div`),t=[];new MutationObserver(function(){var e=t.slice();t.length=0,e.forEach(function(e){e()})}).observe(a,{attributes:!0});var o=i.setImmediate;i.setImmediate=function(e){Date.now()-n>15?(n=Date.now(),o(e)):(t.push(e),t.length===1&&a.setAttribute(`a`,r=!r))}}i.nextTick=i.setImmediate})(),i.isNodejs=typeof process<`u`&&process.versions&&process.versions.node,i.globalScope=(function(){return i.isNodejs?global:typeof self>`u`?window:self})(),i.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)===`[object Array]`},i.isArrayBuffer=function(e){return typeof ArrayBuffer<`u`&&e instanceof ArrayBuffer},i.isArrayBufferView=function(e){return e&&i.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function a(e){if(!(e===8||e===16||e===24||e===32))throw Error(`Only 8, 16, 24, or 32 bits supported: `+e)}i.ByteBuffer=o;function o(e){if(this.data=``,this.read=0,typeof e==`string`)this.data=e;else if(i.isArrayBuffer(e)||i.isArrayBufferView(e))if(typeof Buffer<`u`&&e instanceof Buffer)this.data=e.toString(`binary`);else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var n=0;n<t.length;++n)this.putByte(t[n])}}else (e instanceof o||typeof e==`object`&&typeof e.data==`string`&&typeof e.read==`number`)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}i.ByteStringBuffer=o;var s=4096;i.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>s&&(this.data.substr(0,1),this._constructedStringLength=0)},i.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},i.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},i.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},i.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var n=this.data;t>0;)t&1&&(n+=e),t>>>=1,t>0&&(e+=e);return this.data=n,this._optimizeConstructedString(t),this},i.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},i.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(i.encodeUtf8(e))},i.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},i.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},i.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},i.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))},i.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},i.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},i.ByteStringBuffer.prototype.putInt=function(e,t){a(t);var n=``;do t-=8,n+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(n)},i.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},i.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},i.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},i.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},i.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},i.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},i.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},i.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},i.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},i.ByteStringBuffer.prototype.getInt=function(e){a(e);var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t},i.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),n=2<<e-2;return t>=n&&(t-=n<<1),t},i.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t=``:(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t},i.ByteStringBuffer.prototype.bytes=function(e){return e===void 0?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},i.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},i.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},i.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},i.ByteStringBuffer.prototype.copy=function(){var e=i.createBuffer(this.data);return e.read=this.read,e},i.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},i.ByteStringBuffer.prototype.clear=function(){return this.data=``,this.read=0,this},i.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},i.ByteStringBuffer.prototype.toHex=function(){for(var e=``,t=this.read;t<this.data.length;++t){var n=this.data.charCodeAt(t);n<16&&(e+=`0`),e+=n.toString(16)}return e},i.ByteStringBuffer.prototype.toString=function(){return i.decodeUtf8(this.bytes())};function c(e,t){t||={},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var n=i.isArrayBuffer(e),r=i.isArrayBufferView(e);if(n||r){n?this.data=new DataView(e):this.data=new DataView(e.buffer,e.byteOffset,e.byteLength),this.write=`writeOffset`in t?t.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,e!=null&&this.putBytes(e),`writeOffset`in t&&(this.write=t.writeOffset)}i.DataBuffer=c,i.DataBuffer.prototype.length=function(){return this.write-this.read},i.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},i.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var n=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),r=new Uint8Array(this.length()+t);return r.set(n),this.data=new DataView(r.buffer),this},i.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},i.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var n=0;n<t;++n)this.data.setUint8(e);return this},i.DataBuffer.prototype.putBytes=function(e,t){if(i.isArrayBufferView(e)){var n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=n.byteLength-n.byteOffset;this.accommodate(r);var a=new Uint8Array(this.data.buffer,this.write);return a.set(n),this.write+=r,this}if(i.isArrayBuffer(e)){var n=new Uint8Array(e);this.accommodate(n.byteLength);var a=new Uint8Array(this.data.buffer);return a.set(n,this.write),this.write+=n.byteLength,this}if(e instanceof i.DataBuffer||typeof e==`object`&&typeof e.read==`number`&&typeof e.write==`number`&&i.isArrayBufferView(e.data)){var n=new Uint8Array(e.data.byteLength,e.read,e.length());this.accommodate(n.byteLength);var a=new Uint8Array(e.data.byteLength,this.write);return a.set(n),this.write+=n.byteLength,this}if(e instanceof i.ByteStringBuffer&&(e=e.data,t=`binary`),t||=`binary`,typeof e==`string`){var o;if(t===`hex`)return this.accommodate(Math.ceil(e.length/2)),o=new Uint8Array(this.data.buffer,this.write),this.write+=i.binary.hex.decode(e,o,this.write),this;if(t===`base64`)return this.accommodate(Math.ceil(e.length/4)*3),o=new Uint8Array(this.data.buffer,this.write),this.write+=i.binary.base64.decode(e,o,this.write),this;if(t===`utf8`&&(e=i.encodeUtf8(e),t=`binary`),t===`binary`||t===`raw`)return this.accommodate(e.length),o=new Uint8Array(this.data.buffer,this.write),this.write+=i.binary.raw.decode(o),this;if(t===`utf16`)return this.accommodate(e.length*2),o=new Uint16Array(this.data.buffer,this.write),this.write+=i.text.utf16.encode(o),this;throw Error(`Invalid encoding: `+t)}throw Error(`Invalid parameter: `+e)},i.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},i.DataBuffer.prototype.putString=function(e){return this.putBytes(e,`utf16`)},i.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},i.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},i.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},i.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},i.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},i.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},i.DataBuffer.prototype.putInt=function(e,t){a(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this},i.DataBuffer.prototype.putSignedInt=function(e,t){return a(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},i.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},i.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},i.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},i.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},i.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},i.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},i.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},i.DataBuffer.prototype.getInt=function(e){a(e);var t=0;do t=(t<<8)+this.data.getInt8(this.read++),e-=8;while(e>0);return t},i.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),n=2<<e-2;return t>=n&&(t-=n<<1),t},i.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t=``:(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t},i.DataBuffer.prototype.bytes=function(e){return e===void 0?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},i.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},i.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},i.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},i.DataBuffer.prototype.copy=function(){return new i.DataBuffer(this)},i.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},i.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},i.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},i.DataBuffer.prototype.toHex=function(){for(var e=``,t=this.read;t<this.data.byteLength;++t){var n=this.data.getUint8(t);n<16&&(e+=`0`),e+=n.toString(16)}return e},i.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if(e||=`utf8`,e===`binary`||e===`raw`)return i.binary.raw.encode(t);if(e===`hex`)return i.binary.hex.encode(t);if(e===`base64`)return i.binary.base64.encode(t);if(e===`utf8`)return i.text.utf8.decode(t);if(e===`utf16`)return i.text.utf16.decode(t);throw Error(`Invalid encoding: `+e)},i.createBuffer=function(e,t){return t||=`raw`,e!==void 0&&t===`utf8`&&(e=i.encodeUtf8(e)),new i.ByteBuffer(e)},i.fillString=function(e,t){for(var n=``;t>0;)t&1&&(n+=e),t>>>=1,t>0&&(e+=e);return n},i.xorBytes=function(e,t,n){for(var r=``,i=``,a=``,o=0,s=0;n>0;--n,++o)i=e.charCodeAt(o)^t.charCodeAt(o),s>=10&&(r+=a,a=``,s=0),a+=String.fromCharCode(i),++s;return r+=a,r},i.hexToBytes=function(e){var t=``,n=0;for(e.length&!0&&(n=1,t+=String.fromCharCode(parseInt(e[0],16)));n<e.length;n+=2)t+=String.fromCharCode(parseInt(e.substr(n,2),16));return t},i.bytesToHex=function(e){return i.createBuffer(e).toHex()},i.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var l=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,u=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],p=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`;i.encode64=function(e,t){for(var n=``,r=``,i,a,o,s=0;s<e.length;)i=e.charCodeAt(s++),a=e.charCodeAt(s++),o=e.charCodeAt(s++),n+=l.charAt(i>>2),n+=l.charAt((i&3)<<4|a>>4),isNaN(a)?n+=`==`:(n+=l.charAt((a&15)<<2|o>>6),n+=isNaN(o)?`=`:l.charAt(o&63)),t&&n.length>t&&(r+=n.substr(0,t)+`\r
3
+ `,n=n.substr(t));return r+=n,r},i.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,``);for(var t=``,n,r,i,a,o=0;o<e.length;)n=u[e.charCodeAt(o++)-43],r=u[e.charCodeAt(o++)-43],i=u[e.charCodeAt(o++)-43],a=u[e.charCodeAt(o++)-43],t+=String.fromCharCode(n<<2|r>>4),i!==64&&(t+=String.fromCharCode((r&15)<<4|i>>2),a!==64&&(t+=String.fromCharCode((i&3)<<6|a)));return t},i.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},i.decodeUtf8=function(e){return decodeURIComponent(escape(e))},i.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:r.encode,decode:r.decode}},i.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},i.binary.raw.decode=function(e,t,n){var r=t;r||=new Uint8Array(e.length),n||=0;for(var i=n,a=0;a<e.length;++a)r[i++]=e.charCodeAt(a);return t?i-n:r},i.binary.hex.encode=i.bytesToHex,i.binary.hex.decode=function(e,t,n){var r=t;r||=new Uint8Array(Math.ceil(e.length/2)),n||=0;var i=0,a=n;for(e.length&1&&(i=1,r[a++]=parseInt(e[0],16));i<e.length;i+=2)r[a++]=parseInt(e.substr(i,2),16);return t?a-n:r},i.binary.base64.encode=function(e,t){for(var n=``,r=``,i,a,o,s=0;s<e.byteLength;)i=e[s++],a=e[s++],o=e[s++],n+=l.charAt(i>>2),n+=l.charAt((i&3)<<4|a>>4),isNaN(a)?n+=`==`:(n+=l.charAt((a&15)<<2|o>>6),n+=isNaN(o)?`=`:l.charAt(o&63)),t&&n.length>t&&(r+=n.substr(0,t)+`\r
4
+ `,n=n.substr(t));return r+=n,r},i.binary.base64.decode=function(e,t,n){var r=t;r||=new Uint8Array(Math.ceil(e.length/4)*3),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,``),n||=0;for(var i,a,o,s,c=0,l=n;c<e.length;)i=u[e.charCodeAt(c++)-43],a=u[e.charCodeAt(c++)-43],o=u[e.charCodeAt(c++)-43],s=u[e.charCodeAt(c++)-43],r[l++]=i<<2|a>>4,o!==64&&(r[l++]=(a&15)<<4|o>>2,s!==64&&(r[l++]=(o&3)<<6|s));return t?l-n:r.subarray(0,l)},i.binary.base58.encode=function(e,t){return i.binary.baseN.encode(e,p,t)},i.binary.base58.decode=function(e,t){return i.binary.baseN.decode(e,p,t)},i.text={utf8:{},utf16:{}},i.text.utf8.encode=function(e,t,n){e=i.encodeUtf8(e);var r=t;r||=new Uint8Array(e.length),n||=0;for(var a=n,o=0;o<e.length;++o)r[a++]=e.charCodeAt(o);return t?a-n:r},i.text.utf8.decode=function(e){return i.decodeUtf8(String.fromCharCode.apply(null,e))},i.text.utf16.encode=function(e,t,n){var r=t;r||=new Uint8Array(e.length*2);var i=new Uint16Array(r.buffer);n||=0;for(var a=n,o=n,s=0;s<e.length;++s)i[o++]=e.charCodeAt(s),a+=2;return t?a-n:r},i.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},i.deflate=function(e,t,n){if(t=i.decode64(e.deflate(i.encode64(t)).rval),n){var r=2;t.charCodeAt(1)&32&&(r=6),t=t.substring(r,t.length-4)}return t},i.inflate=function(e,t,n){var r=e.inflate(i.encode64(t)).rval;return r===null?null:i.decode64(r)};var m=function(e,t,n){if(!e)throw Error(`WebStorage not available.`);var r;if(n===null?r=e.removeItem(t):(n=i.encode64(JSON.stringify(n)),r=e.setItem(t,n)),r!==void 0&&r.rval!==!0){var a=Error(r.error.message);throw a.id=r.error.id,a.name=r.error.name,a}},h=function(e,t){if(!e)throw Error(`WebStorage not available.`);var n=e.getItem(t);if(e.init)if(n.rval===null){if(n.error){var r=Error(n.error.message);throw r.id=n.error.id,r.name=n.error.name,r}n=null}else n=n.rval;return n!==null&&(n=JSON.parse(i.decode64(n))),n},g=function(e,t,n,r){var i=h(e,t);i===null&&(i={}),i[n]=r,m(e,t,i)},_=function(e,t,n){var r=h(e,t);return r!==null&&(r=n in r?r[n]:null),r},v=function(e,t,n){var r=h(e,t);if(r!==null&&n in r){delete r[n];var i=!0;for(var a in r){i=!1;break}i&&(r=null),m(e,t,r)}},y=function(e,t){m(e,t,null)},b=function(e,t,n){var r=null;n===void 0&&(n=[`web`,`flash`]);var i,a=!1,o=null;for(var s in n){i=n[s];try{if(i===`flash`||i===`both`){if(t[0]===null)throw Error(`Flash local storage not available.`);r=e.apply(this,t),a=i===`flash`}(i===`web`||i===`both`)&&(t[0]=localStorage,r=e.apply(this,t),a=!0)}catch(e){o=e}if(a)break}if(!a)throw o;return r};i.setItem=function(e,t,n,r,i){b(g,arguments,i)},i.getItem=function(e,t,n,r){return b(_,arguments,r)},i.removeItem=function(e,t,n,r){b(v,arguments,r)},i.clearItems=function(e,t,n){b(y,arguments,n)},i.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},i.format=function(e){for(var t=/%./g,n,r,i=0,a=[],o=0;n=t.exec(e);){r=e.substring(o,t.lastIndex-2),r.length>0&&a.push(r),o=t.lastIndex;var s=n[0][1];switch(s){case`s`:case`o`:i<arguments.length?a.push(arguments[i+++1]):a.push(`<?>`);break;case`%`:a.push(`%`);break;default:a.push(`<%`+s+`?>`)}}return a.push(e.substring(o)),a.join(``)},i.formatNumber=function(e,t,n,r){var i=e,a=isNaN(t=Math.abs(t))?2:t,o=n===void 0?`,`:n,s=r===void 0?`.`:r,c=i<0?`-`:``,l=parseInt(i=Math.abs(+i||0).toFixed(a),10)+``,u=l.length>3?l.length%3:0;return c+(u?l.substr(0,u)+s:``)+l.substr(u).replace(/(\d{3})(?=\d)/g,`$1`+s)+(a?o+Math.abs(i-l).toFixed(a).slice(2):``)},i.formatSize=function(e){return e=e>=1073741824?i.formatNumber(e/1073741824,2,`.`,``)+` GiB`:e>=1048576?i.formatNumber(e/1048576,2,`.`,``)+` MiB`:e>=1024?i.formatNumber(e/1024,0)+` KiB`:i.formatNumber(e,0)+` bytes`,e},i.bytesFromIP=function(e){return e.indexOf(`.`)===-1?e.indexOf(`:`)===-1?null:i.bytesFromIPv6(e):i.bytesFromIPv4(e)},i.bytesFromIPv4=function(e){if(e=e.split(`.`),e.length!==4)return null;for(var t=i.createBuffer(),n=0;n<e.length;++n){var r=parseInt(e[n],10);if(isNaN(r))return null;t.putByte(r)}return t.getBytes()},i.bytesFromIPv6=function(e){var t=0;e=e.split(`:`).filter(function(e){return e.length===0&&++t,!0});for(var n=(8-e.length+t)*2,r=i.createBuffer(),a=0;a<8;++a){if(!e[a]||e[a].length===0){r.fillWithByte(0,n),n=0;continue}var o=i.hexToBytes(e[a]);o.length<2&&r.putByte(0),r.putBytes(o)}return r.getBytes()},i.bytesToIP=function(e){return e.length===4?i.bytesToIPv4(e):e.length===16?i.bytesToIPv6(e):null},i.bytesToIPv4=function(e){if(e.length!==4)return null;for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t.join(`.`)},i.bytesToIPv6=function(e){if(e.length!==16)return null;for(var t=[],n=[],r=0,a=0;a<e.length;a+=2){for(var o=i.bytesToHex(e[a]+e[a+1]);o[0]===`0`&&o!==`0`;)o=o.substr(1);if(o===`0`){var s=n[n.length-1],c=t.length;!s||c!==s.end+1?n.push({start:c,end:c}):(s.end=c,s.end-s.start>n[r].end-n[r].start&&(r=n.length-1))}t.push(o)}if(n.length>0){var l=n[r];l.end-l.start>0&&(t.splice(l.start,l.end-l.start+1,``),l.start===0&&t.unshift(``),l.end===7&&t.push(``))}return t.join(`:`)},i.estimateCores=function(e,t){if(typeof e==`function`&&(t=e,e={}),e||={},`cores`in i&&!e.update)return t(null,i.cores);if(typeof navigator<`u`&&`hardwareConcurrency`in navigator&&navigator.hardwareConcurrency>0)return i.cores=navigator.hardwareConcurrency,t(null,i.cores);if(typeof Worker>`u`)return i.cores=1,t(null,i.cores);if(typeof Blob>`u`)return i.cores=2,t(null,i.cores);var n=URL.createObjectURL(new Blob([`(`,function(){self.addEventListener(`message`,function(e){for(var t=Date.now(),n=t+4;Date.now()<n;);self.postMessage({st:t,et:n})})}.toString(),`)()`],{type:`application/javascript`}));r([],5,16);function r(e,s,c){if(s===0){var l=Math.floor(e.reduce(function(e,t){return e+t},0)/e.length);return i.cores=Math.max(1,l),URL.revokeObjectURL(n),t(null,i.cores)}a(c,function(t,n){e.push(o(c,n)),r(e,s-1,c)})}function a(e,t){for(var r=[],i=[],a=0;a<e;++a){var o=new Worker(n);o.addEventListener(`message`,function(n){if(i.push(n.data),i.length===e){for(var a=0;a<e;++a)r[a].terminate();t(null,i)}}),r.push(o)}for(var a=0;a<e;++a)r[a].postMessage(a)}function o(e,t){for(var n=[],r=0;r<e;++r)for(var i=t[r],a=n[r]=[],o=0;o<e;++o)if(r!==o){var s=t[o];(i.st>s.st&&i.st<s.et||s.st>i.st&&s.st<i.et)&&a.push(o)}return n.reduce(function(e,t){return Math.max(e,t.length)},0)}}})),m=o(((e,t)=>{var n=d();p(),t.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(e,t){var r=e;if(typeof r==`string`&&(r=n.cipher.getAlgorithm(r),r&&=r()),!r)throw Error(`Unsupported algorithm: `+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},n.cipher.createDecipher=function(e,t){var r=e;if(typeof r==`string`&&(r=n.cipher.getAlgorithm(r),r&&=r()),!r)throw Error(`Unsupported algorithm: `+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},n.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),n.cipher.algorithms[e]=t},n.cipher.getAlgorithm=function(e){return e=e.toUpperCase(),e in n.cipher.algorithms?n.cipher.algorithms[e]:null};var r=n.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};r.prototype.start=function(e){e||={};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=e.output||n.util.createBuffer(),this.mode.start(t)},r.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},r.prototype.finish=function(e){e&&(this.mode.name===`ECB`||this.mode.name===`CBC`)&&(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t))}})),h=o(((e,t)=>{var n=d();p(),n.cipher=n.cipher||{};var r=t.exports=n.cipher.modes=n.cipher.modes||{};r.ecb=function(e){e||={},this.name=`ECB`,this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)},r.ecb.prototype.start=function(e){},r.ecb.prototype.encrypt=function(e,t,n){if(e.length()<this.blockSize&&!(n&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])},r.ecb.prototype.decrypt=function(e,t,n){if(e.length()<this.blockSize&&!(n&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])},r.ecb.prototype.pad=function(e,t){var n=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(n,n),!0},r.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var n=e.length(),r=e.at(n-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},r.cbc=function(e){e||={},this.name=`CBC`,this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)},r.cbc.prototype.start=function(e){if(e.iv===null){if(!this._prev)throw Error(`Invalid IV parameter.`);this._iv=this._prev.slice(0)}else if(`iv`in e)this._iv=i(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw Error(`Invalid IV parameter.`)},r.cbc.prototype.encrypt=function(e,t,n){if(e.length()<this.blockSize&&!(n&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=this._prev[r]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r]);this._prev=this._outBlock},r.cbc.prototype.decrypt=function(e,t,n){if(e.length()<this.blockSize&&!(n&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._prev[r]^this._outBlock[r]);this._prev=this._inBlock.slice(0)},r.cbc.prototype.pad=function(e,t){var n=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(n,n),!0},r.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var n=e.length(),r=e.at(n-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},r.cfb=function(e){e||={},this.name=`CFB`,this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialBlock=Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},r.cfb.prototype.start=function(e){if(!(`iv`in e))throw Error(`Invalid IV parameter.`);this._iv=i(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},r.cfb.prototype.encrypt=function(e,t,n){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32()^this._outBlock[i],t.putInt32(this._inBlock[i]);return}var a=(this.blockSize-r)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(a>0)e.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!n)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},r.cfb.prototype.decrypt=function(e,t,n){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32(),t.putInt32(this._inBlock[i]^this._outBlock[i]);return}var a=(this.blockSize-r)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!n)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},r.ofb=function(e){e||={},this.name=`OFB`,this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},r.ofb.prototype.start=function(e){if(!(`iv`in e))throw Error(`Invalid IV parameter.`);this._iv=i(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},r.ofb.prototype.encrypt=function(e,t,n){var r=e.length();if(e.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];return}var a=(this.blockSize-r)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!n)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},r.ofb.prototype.decrypt=r.ofb.prototype.encrypt,r.ctr=function(e){e||={},this.name=`CTR`,this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},r.ctr.prototype.start=function(e){if(!(`iv`in e))throw Error(`Invalid IV parameter.`);this._iv=i(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},r.ctr.prototype.encrypt=function(e,t,n){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]);else{var o=(this.blockSize-r)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!n)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}a(this._inBlock)},r.ctr.prototype.decrypt=r.ctr.prototype.encrypt,r.gcm=function(e){e||={},this.name=`GCM`,this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},r.gcm.prototype.start=function(e){if(!(`iv`in e))throw Error(`Invalid IV parameter.`);var t=n.util.createBuffer(e.iv);this._cipherLength=0;var r=`additionalData`in e?n.util.createBuffer(e.additionalData):n.util.createBuffer();if(`tagLength`in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw Error(`Authentication tag does not match tag length.`);this._hashBlock=Array(this._ints),this.tag=null,this._hashSubkey=Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=t.length();if(i===12)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(o(i*8)))}this._inBlock=this._j0.slice(0),a(this._inBlock),this._partialBytes=0,r=n.util.createBuffer(r),this._aDataLength=o(r.length()*8);var s=r.length()%this.blockSize;for(s&&r.fillWithByte(0,this.blockSize-s),this._s=[0,0,0,0];r.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])},r.gcm.prototype.encrypt=function(e,t,n){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^=e.getInt32());this._cipherLength+=this.blockSize}else{var o=(this.blockSize-r)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(o<=0||n){if(n){var s=r%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(var i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!n)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),a(this._inBlock)},r.gcm.prototype.decrypt=function(e,t,n){var r=e.length();if(r<this.blockSize&&!(n&&r>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),a(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^this._hashBlock[i]);r<this.blockSize?this._cipherLength+=r%this.blockSize:this._cipherLength+=this.blockSize},r.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=n.util.createBuffer();var i=this._aDataLength.concat(o(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,i);var a=[];this.cipher.encrypt(this._j0,a);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^a[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},r.gcm.prototype.multiply=function(e,t){for(var n=[0,0,0,0],r=t.slice(0),i=0;i<128;++i)e[i/32|0]&1<<31-i%32&&(n[0]^=r[0],n[1]^=r[1],n[2]^=r[2],n[3]^=r[3]),this.pow(r,r);return n},r.gcm.prototype.pow=function(e,t){for(var n=e[3]&1,r=3;r>0;--r)t[r]=e[r]>>>1|(e[r-1]&1)<<31;t[0]=e[0]>>>1,n&&(t[0]^=this._R)},r.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],n=0;n<32;++n){var r=e[n/8|0]>>>(7-n%8)*4&15,i=this._m[n][r];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},r.gcm.prototype.ghash=function(e,t,n){return t[0]^=n[0],t[1]^=n[1],t[2]^=n[2],t[3]^=n[3],this.tableMultiply(t)},r.gcm.prototype.generateHashTable=function(e,t){for(var n=8/t,r=4*n,i=16*n,a=Array(i),o=0;o<i;++o){var s=[0,0,0,0],c=o/r|0,l=(r-1-o%r)*t;s[c]=1<<t-1<<l,a[o]=this.generateSubHashTable(this.multiply(s,e),t)}return a},r.gcm.prototype.generateSubHashTable=function(e,t){var n=1<<t,r=n>>>1,i=Array(n);i[r]=e.slice(0);for(var a=r>>>1;a>0;)this.pow(i[2*a],i[a]=[]),a>>=1;for(a=2;a<r;){for(var o=1;o<a;++o){var s=i[a],c=i[o];i[a+o]=[s[0]^c[0],s[1]^c[1],s[2]^c[2],s[3]^c[3]]}a*=2}for(i[0]=[0,0,0,0],a=r+1;a<n;++a){var l=i[a^r];i[a]=[e[0]^l[0],e[1]^l[1],e[2]^l[2],e[3]^l[3]]}return i};function i(e,t){if(typeof e==`string`&&(e=n.util.createBuffer(e)),n.util.isArray(e)&&e.length>4){var r=e;e=n.util.createBuffer();for(var i=0;i<r.length;++i)e.putByte(r[i])}if(e.length()<t)throw Error(`Invalid IV length; got `+e.length()+` bytes and expected `+t+` bytes.`);if(!n.util.isArray(e)){for(var a=[],o=t/4,i=0;i<o;++i)a.push(e.getInt32());e=a}return e}function a(e){e[e.length-1]=e[e.length-1]+1&4294967295}function o(e){return[e/4294967296|0,e&4294967295]}})),g=o(((e,t)=>{var n=d();m(),h(),p(),t.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,n,r){var i=v({key:e,output:n,decrypt:!1,mode:r});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return v({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,n,r){var i=v({key:e,output:n,decrypt:!0,mode:r});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return v({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){i||f();var n=this;n.name=e,n.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return _(n._w,e,t,!1)},decrypt:function(e,t){return _(n._w,e,t,!0)}}}),n._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t=e.key,r;if(typeof t==`string`&&(t.length===16||t.length===24||t.length===32))t=n.util.createBuffer(t);else if(n.util.isArray(t)&&(t.length===16||t.length===24||t.length===32)){r=t,t=n.util.createBuffer();for(var i=0;i<r.length;++i)t.putByte(r[i])}if(!n.util.isArray(t)){r=t,t=[];var a=r.length();if(a===16||a===24||a===32){a>>>=2;for(var i=0;i<a;++i)t.push(r.getInt32())}}if(!n.util.isArray(t)||!(t.length===4||t.length===6||t.length===8))throw Error(`Invalid key parameter.`);var o=this.mode.name,s=[`CFB`,`OFB`,`CTR`,`GCM`].indexOf(o)!==-1;this._w=g(t,e.decrypt&&!s),this._init=!0}},n.aes._expandKey=function(e,t){return i||f(),g(e,t)},n.aes._updateBlock=_,r(`AES-ECB`,n.cipher.modes.ecb),r(`AES-CBC`,n.cipher.modes.cbc),r(`AES-CFB`,n.cipher.modes.cfb),r(`AES-OFB`,n.cipher.modes.ofb),r(`AES-CTR`,n.cipher.modes.ctr),r(`AES-GCM`,n.cipher.modes.gcm);function r(e,t){n.cipher.registerAlgorithm(e,function(){return new n.aes.Algorithm(e,t)})}var i=!1,a=4,o,s,c,l,u;function f(){i=!0,c=[0,1,2,4,8,16,32,64,128,27,54];for(var e=Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;o=Array(256),s=Array(256),l=[,,,,],u=[,,,,];for(var t=0;t<4;++t)l[t]=Array(256),u[t]=Array(256);for(var n=0,r=0,a,d,f,p,m,h,g,t=0;t<256;++t){p=r^r<<1^r<<2^r<<3^r<<4,p=p>>8^p&255^99,o[n]=p,s[p]=n,m=e[p],a=e[n],d=e[a],f=e[d],h=m<<24^p<<16^p<<8^p^m,g=(a^d^f)<<24^(n^f)<<16^(n^d^f)<<8^n^a^f;for(var _=0;_<4;++_)l[_][n]=h,u[_][p]=g,h=h<<24|h>>>8,g=g<<24|g>>>8;n===0?n=r=1:(n=a^e[e[e[a^f]]],r^=e[e[r]])}}function g(e,t){for(var n=e.slice(0),r,i=1,s=n.length,l=a*(s+6+1),d=s;d<l;++d)r=n[d-1],d%s===0?(r=o[r>>>16&255]<<24^o[r>>>8&255]<<16^o[r&255]<<8^o[r>>>24]^c[i]<<24,i++):s>6&&d%s===4&&(r=o[r>>>24]<<24^o[r>>>16&255]<<16^o[r>>>8&255]<<8^o[r&255]),n[d]=n[d-s]^r;if(t){var f,p=u[0],m=u[1],h=u[2],g=u[3],_=n.slice(0);l=n.length;for(var d=0,v=l-a;d<l;d+=a,v-=a)if(d===0||d===l-a)_[d]=n[v],_[d+1]=n[v+3],_[d+2]=n[v+2],_[d+3]=n[v+1];else for(var y=0;y<a;++y)f=n[v+y],_[d+(3&-y)]=p[o[f>>>24]]^m[o[f>>>16&255]]^h[o[f>>>8&255]]^g[o[f&255]];n=_}return n}function _(e,t,n,r){var i=e.length/4-1,a,c,d,f,p;r?(a=u[0],c=u[1],d=u[2],f=u[3],p=s):(a=l[0],c=l[1],d=l[2],f=l[3],p=o);for(var m=t[0]^e[0],h=t[r?3:1]^e[1],g=t[2]^e[2],_=t[r?1:3]^e[3],v,y,b,x=3,S=1;S<i;++S)v=a[m>>>24]^c[h>>>16&255]^d[g>>>8&255]^f[_&255]^e[++x],y=a[h>>>24]^c[g>>>16&255]^d[_>>>8&255]^f[m&255]^e[++x],b=a[g>>>24]^c[_>>>16&255]^d[m>>>8&255]^f[h&255]^e[++x],_=a[_>>>24]^c[m>>>16&255]^d[h>>>8&255]^f[g&255]^e[++x],m=v,h=y,g=b;n[0]=p[m>>>24]<<24^p[h>>>16&255]<<16^p[g>>>8&255]<<8^p[_&255]^e[++x],n[r?3:1]=p[h>>>24]<<24^p[g>>>16&255]<<16^p[_>>>8&255]<<8^p[m&255]^e[++x],n[2]=p[g>>>24]<<24^p[_>>>16&255]<<16^p[m>>>8&255]<<8^p[h&255]^e[++x],n[r?1:3]=p[_>>>24]<<24^p[m>>>16&255]<<16^p[h>>>8&255]<<8^p[g&255]^e[++x]}function v(e){e||={};var t=`AES-`+(e.mode||`CBC`).toUpperCase(),r=e.decrypt?n.cipher.createDecipher(t,e.key):n.cipher.createCipher(t,e.key),i=r.start;return r.start=function(e,t){var a=null;t instanceof n.util.ByteBuffer&&(a=t,t={}),t||={},t.output=a,t.iv=e,i.call(r,t)},r}})),_=o(((e,t)=>{var n=d();n.pki=n.pki||{};var r=t.exports=n.pki.oids=n.oids=n.oids||{};function i(e,t){r[e]=t,r[t]=e}function a(e,t){r[e]=t}i(`1.2.840.113549.1.1.1`,`rsaEncryption`),i(`1.2.840.113549.1.1.4`,`md5WithRSAEncryption`),i(`1.2.840.113549.1.1.5`,`sha1WithRSAEncryption`),i(`1.2.840.113549.1.1.7`,`RSAES-OAEP`),i(`1.2.840.113549.1.1.8`,`mgf1`),i(`1.2.840.113549.1.1.9`,`pSpecified`),i(`1.2.840.113549.1.1.10`,`RSASSA-PSS`),i(`1.2.840.113549.1.1.11`,`sha256WithRSAEncryption`),i(`1.2.840.113549.1.1.12`,`sha384WithRSAEncryption`),i(`1.2.840.113549.1.1.13`,`sha512WithRSAEncryption`),i(`1.3.101.112`,`EdDSA25519`),i(`1.2.840.10040.4.3`,`dsa-with-sha1`),i(`1.3.14.3.2.7`,`desCBC`),i(`1.3.14.3.2.26`,`sha1`),i(`1.3.14.3.2.29`,`sha1WithRSASignature`),i(`2.16.840.1.101.3.4.2.1`,`sha256`),i(`2.16.840.1.101.3.4.2.2`,`sha384`),i(`2.16.840.1.101.3.4.2.3`,`sha512`),i(`2.16.840.1.101.3.4.2.4`,`sha224`),i(`2.16.840.1.101.3.4.2.5`,`sha512-224`),i(`2.16.840.1.101.3.4.2.6`,`sha512-256`),i(`1.2.840.113549.2.2`,`md2`),i(`1.2.840.113549.2.5`,`md5`),i(`1.2.840.113549.1.7.1`,`data`),i(`1.2.840.113549.1.7.2`,`signedData`),i(`1.2.840.113549.1.7.3`,`envelopedData`),i(`1.2.840.113549.1.7.4`,`signedAndEnvelopedData`),i(`1.2.840.113549.1.7.5`,`digestedData`),i(`1.2.840.113549.1.7.6`,`encryptedData`),i(`1.2.840.113549.1.9.1`,`emailAddress`),i(`1.2.840.113549.1.9.2`,`unstructuredName`),i(`1.2.840.113549.1.9.3`,`contentType`),i(`1.2.840.113549.1.9.4`,`messageDigest`),i(`1.2.840.113549.1.9.5`,`signingTime`),i(`1.2.840.113549.1.9.6`,`counterSignature`),i(`1.2.840.113549.1.9.7`,`challengePassword`),i(`1.2.840.113549.1.9.8`,`unstructuredAddress`),i(`1.2.840.113549.1.9.14`,`extensionRequest`),i(`1.2.840.113549.1.9.20`,`friendlyName`),i(`1.2.840.113549.1.9.21`,`localKeyId`),i(`1.2.840.113549.1.9.22.1`,`x509Certificate`),i(`1.2.840.113549.1.12.10.1.1`,`keyBag`),i(`1.2.840.113549.1.12.10.1.2`,`pkcs8ShroudedKeyBag`),i(`1.2.840.113549.1.12.10.1.3`,`certBag`),i(`1.2.840.113549.1.12.10.1.4`,`crlBag`),i(`1.2.840.113549.1.12.10.1.5`,`secretBag`),i(`1.2.840.113549.1.12.10.1.6`,`safeContentsBag`),i(`1.2.840.113549.1.5.13`,`pkcs5PBES2`),i(`1.2.840.113549.1.5.12`,`pkcs5PBKDF2`),i(`1.2.840.113549.1.12.1.1`,`pbeWithSHAAnd128BitRC4`),i(`1.2.840.113549.1.12.1.2`,`pbeWithSHAAnd40BitRC4`),i(`1.2.840.113549.1.12.1.3`,`pbeWithSHAAnd3-KeyTripleDES-CBC`),i(`1.2.840.113549.1.12.1.4`,`pbeWithSHAAnd2-KeyTripleDES-CBC`),i(`1.2.840.113549.1.12.1.5`,`pbeWithSHAAnd128BitRC2-CBC`),i(`1.2.840.113549.1.12.1.6`,`pbewithSHAAnd40BitRC2-CBC`),i(`1.2.840.113549.2.7`,`hmacWithSHA1`),i(`1.2.840.113549.2.8`,`hmacWithSHA224`),i(`1.2.840.113549.2.9`,`hmacWithSHA256`),i(`1.2.840.113549.2.10`,`hmacWithSHA384`),i(`1.2.840.113549.2.11`,`hmacWithSHA512`),i(`1.2.840.113549.3.7`,`des-EDE3-CBC`),i(`2.16.840.1.101.3.4.1.2`,`aes128-CBC`),i(`2.16.840.1.101.3.4.1.22`,`aes192-CBC`),i(`2.16.840.1.101.3.4.1.42`,`aes256-CBC`),i(`2.5.4.3`,`commonName`),i(`2.5.4.4`,`surname`),i(`2.5.4.5`,`serialNumber`),i(`2.5.4.6`,`countryName`),i(`2.5.4.7`,`localityName`),i(`2.5.4.8`,`stateOrProvinceName`),i(`2.5.4.9`,`streetAddress`),i(`2.5.4.10`,`organizationName`),i(`2.5.4.11`,`organizationalUnitName`),i(`2.5.4.12`,`title`),i(`2.5.4.13`,`description`),i(`2.5.4.15`,`businessCategory`),i(`2.5.4.17`,`postalCode`),i(`2.5.4.42`,`givenName`),i(`1.3.6.1.4.1.311.60.2.1.2`,`jurisdictionOfIncorporationStateOrProvinceName`),i(`1.3.6.1.4.1.311.60.2.1.3`,`jurisdictionOfIncorporationCountryName`),i(`2.16.840.1.113730.1.1`,`nsCertType`),i(`2.16.840.1.113730.1.13`,`nsComment`),a(`2.5.29.1`,`authorityKeyIdentifier`),a(`2.5.29.2`,`keyAttributes`),a(`2.5.29.3`,`certificatePolicies`),a(`2.5.29.4`,`keyUsageRestriction`),a(`2.5.29.5`,`policyMapping`),a(`2.5.29.6`,`subtreesConstraint`),a(`2.5.29.7`,`subjectAltName`),a(`2.5.29.8`,`issuerAltName`),a(`2.5.29.9`,`subjectDirectoryAttributes`),a(`2.5.29.10`,`basicConstraints`),a(`2.5.29.11`,`nameConstraints`),a(`2.5.29.12`,`policyConstraints`),a(`2.5.29.13`,`basicConstraints`),i(`2.5.29.14`,`subjectKeyIdentifier`),i(`2.5.29.15`,`keyUsage`),a(`2.5.29.16`,`privateKeyUsagePeriod`),i(`2.5.29.17`,`subjectAltName`),i(`2.5.29.18`,`issuerAltName`),i(`2.5.29.19`,`basicConstraints`),a(`2.5.29.20`,`cRLNumber`),a(`2.5.29.21`,`cRLReason`),a(`2.5.29.22`,`expirationDate`),a(`2.5.29.23`,`instructionCode`),a(`2.5.29.24`,`invalidityDate`),a(`2.5.29.25`,`cRLDistributionPoints`),a(`2.5.29.26`,`issuingDistributionPoint`),a(`2.5.29.27`,`deltaCRLIndicator`),a(`2.5.29.28`,`issuingDistributionPoint`),a(`2.5.29.29`,`certificateIssuer`),a(`2.5.29.30`,`nameConstraints`),i(`2.5.29.31`,`cRLDistributionPoints`),i(`2.5.29.32`,`certificatePolicies`),a(`2.5.29.33`,`policyMappings`),a(`2.5.29.34`,`policyConstraints`),i(`2.5.29.35`,`authorityKeyIdentifier`),a(`2.5.29.36`,`policyConstraints`),i(`2.5.29.37`,`extKeyUsage`),a(`2.5.29.46`,`freshestCRL`),a(`2.5.29.54`,`inhibitAnyPolicy`),i(`1.3.6.1.4.1.11129.2.4.2`,`timestampList`),i(`1.3.6.1.5.5.7.1.1`,`authorityInfoAccess`),i(`1.3.6.1.5.5.7.3.1`,`serverAuth`),i(`1.3.6.1.5.5.7.3.2`,`clientAuth`),i(`1.3.6.1.5.5.7.3.3`,`codeSigning`),i(`1.3.6.1.5.5.7.3.4`,`emailProtection`),i(`1.3.6.1.5.5.7.3.8`,`timeStamping`)})),v=o(((e,t)=>{var n=d();p(),_();var r=t.exports=n.asn1=n.asn1||{};r.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},r.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},r.maxDepth=256,r.create=function(e,t,i,a,o){if(n.util.isArray(a)){for(var s=[],c=0;c<a.length;++c)a[c]!==void 0&&s.push(a[c]);a=s}var l={tagClass:e,type:t,constructed:i,composed:i||n.util.isArray(a),value:a};return o&&`bitStringContents`in o&&(l.bitStringContents=o.bitStringContents,l.original=r.copy(l)),l},r.copy=function(e,t){var i;if(n.util.isArray(e)){i=[];for(var a=0;a<e.length;++a)i.push(r.copy(e[a],t));return i}return typeof e==`string`?e:(i={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:r.copy(e.value,t)},t&&!t.excludeBitStringContents&&(i.bitStringContents=e.bitStringContents),i)},r.equals=function(e,t,i){if(n.util.isArray(e)){if(!n.util.isArray(t)||e.length!==t.length)return!1;for(var a=0;a<e.length;++a)if(!r.equals(e[a],t[a]))return!1;return!0}if(typeof e!=typeof t)return!1;if(typeof e==`string`)return e===t;var o=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&r.equals(e.value,t.value);return i&&i.includeBitStringContents&&(o&&=e.bitStringContents===t.bitStringContents),o},r.getBerValueLength=function(e){var t=e.getByte();if(t!==128)return t&128?e.getInt((t&127)<<3):t};function i(e,t,n){if(n>t){var r=Error(`Too few bytes to parse DER.`);throw r.available=e.length(),r.remaining=t,r.requested=n,r}}var a=function(e,t){var n=e.getByte();if(t--,n!==128){var r;if(!(n&128))r=n;else{var a=n&127;i(e,t,a),r=e.getInt(a<<3)}if(r<0)throw Error(`Negative length: `+r);return r}};r.fromDer=function(e,t){t===void 0&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof t==`boolean`&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),`strict`in t||(t.strict=!0),`parseAllBytes`in t||(t.parseAllBytes=!0),`decodeBitStrings`in t||(t.decodeBitStrings=!0),`maxDepth`in t||(t.maxDepth=r.maxDepth),typeof e==`string`&&(e=n.util.createBuffer(e));var i=e.length(),a=o(e,e.length(),0,t);if(t.parseAllBytes&&e.length()!==0){var s=Error(`Unparsed DER bytes remain after ASN.1 parsing.`);throw s.byteCount=i,s.remaining=e.length(),s}return a};function o(e,t,n,s){if(n>=s.maxDepth)throw Error(`ASN.1 parsing error: Max depth exceeded.`);var c;i(e,t,2);var l=e.getByte();t--;var u=l&192,d=l&31;c=e.length();var f=a(e,t);if(t-=c-e.length(),f!==void 0&&f>t){if(s.strict){var p=Error(`Too few bytes to read ASN.1 value.`);throw p.available=e.length(),p.remaining=t,p.requested=f,p}f=t}var m,h,g=(l&32)==32;if(g)if(m=[],f===void 0)for(;;){if(i(e,t,2),e.bytes(2)===`\0\0`){e.getBytes(2),t-=2;break}c=e.length(),m.push(o(e,t,n+1,s)),t-=c-e.length()}else for(;f>0;)c=e.length(),m.push(o(e,f,n+1,s)),t-=c-e.length(),f-=c-e.length();if(m===void 0&&u===r.Class.UNIVERSAL&&d===r.Type.BITSTRING&&(h=e.bytes(f)),m===void 0&&s.decodeBitStrings&&u===r.Class.UNIVERSAL&&d===r.Type.BITSTRING&&f>1){var _=e.read,v=t,y=0;if(d===r.Type.BITSTRING&&(i(e,t,1),y=e.getByte(),t--),y===0)try{c=e.length();var b=o(e,t,n+1,{strict:!0,decodeBitStrings:!0}),x=c-e.length();t-=x,d==r.Type.BITSTRING&&x++;var S=b.tagClass;x===f&&(S===r.Class.UNIVERSAL||S===r.Class.CONTEXT_SPECIFIC)&&(m=[b])}catch{}m===void 0&&(e.read=_,t=v)}if(m===void 0){if(f===void 0){if(s.strict)throw Error(`Non-constructed ASN.1 object of indefinite length.`);f=t}if(d===r.Type.BMPSTRING)for(m=``;f>0;f-=2)i(e,t,2),m+=String.fromCharCode(e.getInt16()),t-=2;else m=e.getBytes(f),t-=f}var C=h===void 0?null:{bitStringContents:h};return r.create(u,d,g,m,C)}r.toDer=function(e){var t=n.util.createBuffer(),i=e.tagClass|e.type,a=n.util.createBuffer(),o=!1;if(`bitStringContents`in e&&(o=!0,e.original&&(o=r.equals(e,e.original))),o)a.putBytes(e.bitStringContents);else if(e.composed){e.constructed?i|=32:a.putByte(0);for(var s=0;s<e.value.length;++s)e.value[s]!==void 0&&a.putBuffer(r.toDer(e.value[s]))}else if(e.type===r.Type.BMPSTRING)for(var s=0;s<e.value.length;++s)a.putInt16(e.value.charCodeAt(s));else e.type===r.Type.INTEGER&&e.value.length>1&&(e.value.charCodeAt(0)===0&&!(e.value.charCodeAt(1)&128)||e.value.charCodeAt(0)===255&&(e.value.charCodeAt(1)&128)==128)?a.putBytes(e.value.substr(1)):a.putBytes(e.value);if(t.putByte(i),a.length()<=127)t.putByte(a.length()&127);else{var c=a.length(),l=``;do l+=String.fromCharCode(c&255),c>>>=8;while(c>0);t.putByte(l.length|128);for(var s=l.length-1;s>=0;--s)t.putByte(l.charCodeAt(s))}return t.putBuffer(a),t},r.oidToDer=function(e){var t=e.split(`.`),r=n.util.createBuffer();r.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var i,a,o,s,c=2;c<t.length;++c){if(i=!0,a=[],o=parseInt(t[c],10),o>4294967295)throw Error(`OID value too large; max is 32-bits.`);do s=o&127,o>>>=7,i||(s|=128),a.push(s),i=!1;while(o>0);for(var l=a.length-1;l>=0;--l)r.putByte(a[l])}return r},r.derToOid=function(e){var t;typeof e==`string`&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+`.`+r%40;for(var i=0;e.length()>0;){if(i>70368744177663)throw Error(`OID value too large; max is 53-bits.`);r=e.getByte(),i*=128,r&128?i+=r&127:(t+=`.`+(i+r),i=0)}return t},r.utcTimeToDate=function(e){var t=new Date,n=parseInt(e.substr(0,2),10);n=n>=50?1900+n:2e3+n;var r=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),a=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=0;if(e.length>11){var c=e.charAt(10),l=10;c!==`+`&&c!==`-`&&(s=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(n,r,i),t.setUTCHours(a,o,s,0),l&&(c=e.charAt(l),c===`+`||c===`-`)){var u=parseInt(e.substr(l+1,2),10),d=parseInt(e.substr(l+4,2),10),f=u*60+d;f*=6e4,c===`+`?t.setTime(+t-f):t.setTime(+t+f)}return t},r.generalizedTimeToDate=function(e){var t=new Date,n=parseInt(e.substr(0,4),10),r=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),s=parseInt(e.substr(12,2),10),c=0,l=0,u=!1;e.charAt(e.length-1)===`Z`&&(u=!0);var d=e.length-5,f=e.charAt(d);if(f===`+`||f===`-`){var p=parseInt(e.substr(d+1,2),10),m=parseInt(e.substr(d+4,2),10);l=p*60+m,l*=6e4,f===`+`&&(l*=-1),u=!0}return e.charAt(14)===`.`&&(c=parseFloat(e.substr(14),10)*1e3),u?(t.setUTCFullYear(n,r,i),t.setUTCHours(a,o,s,c),t.setTime(+t+l)):(t.setFullYear(n,r,i),t.setHours(a,o,s,c)),t},r.dateToUtcTime=function(e){if(typeof e==`string`)return e;var t=``,n=[];n.push((``+e.getUTCFullYear()).substr(2)),n.push(``+(e.getUTCMonth()+1)),n.push(``+e.getUTCDate()),n.push(``+e.getUTCHours()),n.push(``+e.getUTCMinutes()),n.push(``+e.getUTCSeconds());for(var r=0;r<n.length;++r)n[r].length<2&&(t+=`0`),t+=n[r];return t+=`Z`,t},r.dateToGeneralizedTime=function(e){if(typeof e==`string`)return e;var t=``,n=[];n.push(``+e.getUTCFullYear()),n.push(``+(e.getUTCMonth()+1)),n.push(``+e.getUTCDate()),n.push(``+e.getUTCHours()),n.push(``+e.getUTCMinutes()),n.push(``+e.getUTCSeconds());for(var r=0;r<n.length;++r)n[r].length<2&&(t+=`0`),t+=n[r];return t+=`Z`,t},r.integerToDer=function(e){var t=n.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=Error(`Integer too large; max is 32-bits.`);throw r.integer=e,r},r.derToInteger=function(e){typeof e==`string`&&(e=n.util.createBuffer(e));var t=e.length()*8;if(t>32)throw Error(`Integer too large; max is 32-bits.`);return e.getSignedInt(t)},r.validate=function(e,t,i,a){var o=!1;if((e.tagClass===t.tagClass||t.tagClass===void 0)&&(e.type===t.type||t.type===void 0))if(e.constructed===t.constructed||t.constructed===void 0){if(o=!0,t.value&&n.util.isArray(t.value))for(var s=0,c=0;o&&c<t.value.length;++c){var l=t.value[c];o=!!l.optional;var u=e.value[s];if(!u){l.optional||(o=!1,a&&a.push(`[`+t.name+`] Missing required element. Expected tag class "`+l.tagClass+`", type "`+l.type+`"`));continue}if(l.tagClass!==void 0&&l.type!==void 0&&(u.tagClass!==l.tagClass||u.type!==l.type))if(l.optional){o=!0;continue}else{o=!1,a&&a.push(`[`+t.name+`] Tag mismatch. Expected (`+l.tagClass+`,`+l.type+`), got (`+u.tagClass+`,`+u.type+`)`);break}if(r.validate(u,l,i,a))++s,o=!0;else if(l.optional)o=!0;else{o=!1;break}}if(o&&i&&(t.capture&&(i[t.capture]=e.value),t.captureAsn1&&(i[t.captureAsn1]=e),t.captureBitStringContents&&`bitStringContents`in e&&(i[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&`bitStringContents`in e))if(e.bitStringContents.length<2)i[t.captureBitStringValue]=``;else{if(e.bitStringContents.charCodeAt(0)!==0)throw Error(`captureBitStringValue only supported for zero unused bits`);i[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else a&&a.push(`[`+t.name+`] Expected constructed "`+t.constructed+`", got "`+e.constructed+`"`);else a&&(e.tagClass!==t.tagClass&&a.push(`[`+t.name+`] Expected tag class "`+t.tagClass+`", got "`+e.tagClass+`"`),e.type!==t.type&&a.push(`[`+t.name+`] Expected type "`+t.type+`", got "`+e.type+`"`));return o};var s=/[^\\u0000-\\u00ff]/;r.prettyPrint=function(e,t,i){var a=``;t||=0,i||=2,t>0&&(a+=`
5
+ `);for(var o=``,c=0;c<t*i;++c)o+=` `;switch(a+=o+`Tag: `,e.tagClass){case r.Class.UNIVERSAL:a+=`Universal:`;break;case r.Class.APPLICATION:a+=`Application:`;break;case r.Class.CONTEXT_SPECIFIC:a+=`Context-Specific:`;break;case r.Class.PRIVATE:a+=`Private:`;break}if(e.tagClass===r.Class.UNIVERSAL)switch(a+=e.type,e.type){case r.Type.NONE:a+=` (None)`;break;case r.Type.BOOLEAN:a+=` (Boolean)`;break;case r.Type.INTEGER:a+=` (Integer)`;break;case r.Type.BITSTRING:a+=` (Bit string)`;break;case r.Type.OCTETSTRING:a+=` (Octet string)`;break;case r.Type.NULL:a+=` (Null)`;break;case r.Type.OID:a+=` (Object Identifier)`;break;case r.Type.ODESC:a+=` (Object Descriptor)`;break;case r.Type.EXTERNAL:a+=` (External or Instance of)`;break;case r.Type.REAL:a+=` (Real)`;break;case r.Type.ENUMERATED:a+=` (Enumerated)`;break;case r.Type.EMBEDDED:a+=` (Embedded PDV)`;break;case r.Type.UTF8:a+=` (UTF8)`;break;case r.Type.ROID:a+=` (Relative Object Identifier)`;break;case r.Type.SEQUENCE:a+=` (Sequence)`;break;case r.Type.SET:a+=` (Set)`;break;case r.Type.PRINTABLESTRING:a+=` (Printable String)`;break;case r.Type.IA5String:a+=` (IA5String (ASCII))`;break;case r.Type.UTCTIME:a+=` (UTC time)`;break;case r.Type.GENERALIZEDTIME:a+=` (Generalized time)`;break;case r.Type.BMPSTRING:a+=` (BMP String)`;break}else a+=e.type;if(a+=`
6
+ `,a+=o+`Constructed: `+e.constructed+`
7
+ `,e.composed){for(var l=0,u=``,c=0;c<e.value.length;++c)e.value[c]!==void 0&&(l+=1,u+=r.prettyPrint(e.value[c],t+1,i),c+1<e.value.length&&(u+=`,`));a+=o+`Sub values: `+l+u}else{if(a+=o+`Value: `,e.type===r.Type.OID){var d=r.derToOid(e.value);a+=d,n.pki&&n.pki.oids&&d in n.pki.oids&&(a+=` (`+n.pki.oids[d]+`) `)}if(e.type===r.Type.INTEGER)try{a+=r.derToInteger(e.value)}catch{a+=`0x`+n.util.bytesToHex(e.value)}else if(e.type===r.Type.BITSTRING){if(e.value.length>1?a+=`0x`+n.util.bytesToHex(e.value.slice(1)):a+=`(none)`,e.value.length>0){var f=e.value.charCodeAt(0);f==1?a+=` (1 unused bit shown)`:f>1&&(a+=` (`+f+` unused bits shown)`)}}else if(e.type===r.Type.OCTETSTRING)s.test(e.value)||(a+=`(`+e.value+`) `),a+=`0x`+n.util.bytesToHex(e.value);else if(e.type===r.Type.UTF8)try{a+=n.util.decodeUtf8(e.value)}catch(t){if(t.message===`URI malformed`)a+=`0x`+n.util.bytesToHex(e.value)+` (malformed UTF8)`;else throw t}else e.type===r.Type.PRINTABLESTRING||e.type===r.Type.IA5String?a+=e.value:s.test(e.value)?a+=`0x`+n.util.bytesToHex(e.value):e.value.length===0?a+=`[null]`:a+=e.value}return a}})),y=o(((e,t)=>{var n=d();t.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}})),b=o(((e,t)=>{var n=d();y(),p();var r=t.exports=n.hmac=n.hmac||{};r.create=function(){var e=null,t=null,r=null,i=null,a={};return a.start=function(a,o){if(a!==null)if(typeof a==`string`)if(a=a.toLowerCase(),a in n.md.algorithms)t=n.md.algorithms[a].create();else throw Error(`Unknown hash algorithm "`+a+`"`);else t=a;if(o===null)o=e;else{if(typeof o==`string`)o=n.util.createBuffer(o);else if(n.util.isArray(o)){var s=o;o=n.util.createBuffer();for(var c=0;c<s.length;++c)o.putByte(s[c])}var l=o.length();l>t.blockLength&&(t.start(),t.update(o.bytes()),o=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),l=o.length();for(var c=0;c<l;++c){var s=o.at(c);r.putByte(54^s),i.putByte(92^s)}if(l<t.blockLength)for(var s=t.blockLength-l,c=0;c<s;++c)r.putByte(54),i.putByte(92);e=o,r=r.bytes(),i=i.bytes()}t.start(),t.update(r)},a.update=function(e){t.update(e)},a.getMac=function(){var e=t.digest().bytes();return t.start(),t.update(i),t.update(e),t.digest()},a.digest=a.getMac,a}})),x=o(((e,t)=>{var n=d();y(),p();var r=t.exports=n.md5=n.md5||{};n.md.md5=n.md.algorithms.md5=r,r.create=function(){c||l();var e=null,t=n.util.createBuffer(),r=Array(16),a={algorithm:`md5`,blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return a.start=function(){a.messageLength=0,a.fullMessageLength=a.messageLength64=[];for(var r=a.messageLengthSize/4,i=0;i<r;++i)a.fullMessageLength.push(0);return t=n.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},a},a.start(),a.update=function(i,o){o===`utf8`&&(i=n.util.encodeUtf8(i));var s=i.length;a.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var c=a.fullMessageLength.length-1;c>=0;--c)a.fullMessageLength[c]+=s[1],s[1]=s[0]+(a.fullMessageLength[c]/4294967296>>>0),a.fullMessageLength[c]=a.fullMessageLength[c]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(i),u(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),a},a.digest=function(){var o=n.util.createBuffer();o.putBytes(t.bytes());var s=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize&a.blockLength-1;o.putBytes(i.substr(0,a.blockLength-s));for(var c,l=0,d=a.fullMessageLength.length-1;d>=0;--d)c=a.fullMessageLength[d]*8+l,l=c/4294967296>>>0,o.putInt32Le(c>>>0);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};u(f,r,o);var p=n.util.createBuffer();return p.putInt32Le(f.h0),p.putInt32Le(f.h1),p.putInt32Le(f.h2),p.putInt32Le(f.h3),p},a};var i=null,a=null,o=null,s=null,c=!1;function l(){i=`€`,i+=n.util.fillString(`\0`,64),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],o=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=Array(64);for(var e=0;e<64;++e)s[e]=Math.floor(Math.abs(Math.sin(e+1))*4294967296);c=!0}function u(e,t,n){for(var r,i,c,l,u,d,f,p,m=n.length();m>=64;){for(i=e.h0,c=e.h1,l=e.h2,u=e.h3,p=0;p<16;++p)t[p]=n.getInt32Le(),d=u^c&(l^u),r=i+d+s[p]+t[p],f=o[p],i=u,u=l,l=c,c+=r<<f|r>>>32-f;for(;p<32;++p)d=l^u&(c^l),r=i+d+s[p]+t[a[p]],f=o[p],i=u,u=l,l=c,c+=r<<f|r>>>32-f;for(;p<48;++p)d=c^l^u,r=i+d+s[p]+t[a[p]],f=o[p],i=u,u=l,l=c,c+=r<<f|r>>>32-f;for(;p<64;++p)d=l^(c|~u),r=i+d+s[p]+t[a[p]],f=o[p],i=u,u=l,l=c,c+=r<<f|r>>>32-f;e.h0=e.h0+i|0,e.h1=e.h1+c|0,e.h2=e.h2+l|0,e.h3=e.h3+u|0,m-=64}}})),S=o(((e,t)=>{var n=d();p();var r=t.exports=n.pem=n.pem||{};r.encode=function(e,t){t||={};var r=`-----BEGIN `+e.type+`-----\r
8
+ `,a;if(e.procType&&(a={name:`Proc-Type`,values:[String(e.procType.version),e.procType.type]},r+=i(a)),e.contentDomain&&(a={name:`Content-Domain`,values:[e.contentDomain]},r+=i(a)),e.dekInfo&&(a={name:`DEK-Info`,values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&a.values.push(e.dekInfo.parameters),r+=i(a)),e.headers)for(var o=0;o<e.headers.length;++o)r+=i(e.headers[o]);return e.procType&&(r+=`\r
9
+ `),r+=n.util.encode64(e.body,t.maxline||64)+`\r
10
+ `,r+=`-----END `+e.type+`-----\r
11
+ `,r},r.decode=function(e){for(var t=[],r=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,i=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,o=/\r?\n/,s;s=r.exec(e),s;){var c=s[1];c===`NEW CERTIFICATE REQUEST`&&(c=`CERTIFICATE REQUEST`);var l={type:c,procType:null,contentDomain:null,dekInfo:null,headers:[],body:n.util.decode64(s[3])};if(t.push(l),s[2]){for(var u=s[2].split(o),d=0;s&&d<u.length;){for(var f=u[d].replace(/\s+$/,``),p=d+1;p<u.length;++p){var m=u[p];if(!/\s/.test(m[0]))break;f+=m,d=p}if(s=f.match(i),s){for(var h={name:s[1],values:[]},g=s[2].split(`,`),_=0;_<g.length;++_)h.values.push(a(g[_]));if(!l.procType){if(h.name!==`Proc-Type`)throw Error(`Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".`);if(h.values.length!==2)throw Error(`Invalid PEM formatted message. The "Proc-Type" header must have two subfields.`);l.procType={version:g[0],type:g[1]}}else if(!l.contentDomain&&h.name===`Content-Domain`)l.contentDomain=g[0]||``;else if(!l.dekInfo&&h.name===`DEK-Info`){if(h.values.length===0)throw Error(`Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.`);l.dekInfo={algorithm:g[0],parameters:g[1]||null}}else l.headers.push(h)}++d}if(l.procType===`ENCRYPTED`&&!l.dekInfo)throw Error(`Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".`)}}if(t.length===0)throw Error(`Invalid PEM formatted message.`);return t};function i(e){for(var t=e.name+`: `,n=[],r=function(e,t){return` `+t},i=0;i<e.values.length;++i)n.push(e.values[i].replace(/^(\S+\r\n)/,r));t+=n.join(`,`)+`\r
12
+ `;for(var a=0,o=-1,i=0;i<t.length;++i,++a)if(a>65&&o!==-1){var s=t[o];s===`,`?(++o,t=t.substr(0,o)+`\r
13
+ `+t.substr(o)):t=t.substr(0,o)+`\r
14
+ `+s+t.substr(o+1),a=i-o-1,o=-1,++i}else (t[i]===` `||t[i]===` `||t[i]===`,`)&&(o=i);return t}function a(e){return e.replace(/^\s+/,``)}})),C=o(((e,t)=>{var n=d();m(),h(),p(),t.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,n,r){var i=v({key:e,output:n,decrypt:!1,mode:r||(t===null?`ECB`:`CBC`)});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return v({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,n,r){var i=v({key:e,output:n,decrypt:!0,mode:r||(t===null?`ECB`:`CBC`)});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return v({key:e,output:null,decrypt:!0,mode:t})},n.des.Algorithm=function(e,t){var n=this;n.name=e,n.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return _(n._keys,e,t,!1)},decrypt:function(e,t){return _(n._keys,e,t,!0)}}}),n._init=!1},n.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=n.util.createBuffer(e.key);if(this.name.indexOf(`3DES`)===0&&t.length()!==24)throw Error(`Invalid Triple-DES key size: `+t.length()*8);this._keys=g(t),this._init=!0}},r(`DES-ECB`,n.cipher.modes.ecb),r(`DES-CBC`,n.cipher.modes.cbc),r(`DES-CFB`,n.cipher.modes.cfb),r(`DES-OFB`,n.cipher.modes.ofb),r(`DES-CTR`,n.cipher.modes.ctr),r(`3DES-ECB`,n.cipher.modes.ecb),r(`3DES-CBC`,n.cipher.modes.cbc),r(`3DES-CFB`,n.cipher.modes.cfb),r(`3DES-OFB`,n.cipher.modes.ofb),r(`3DES-CTR`,n.cipher.modes.ctr);function r(e,t){n.cipher.registerAlgorithm(e,function(){return new n.des.Algorithm(e,t)})}var i=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],a=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],o=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],s=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],c=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],u=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],f=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function g(e){for(var t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],r=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],a=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],s=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],u=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],f=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],m=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],h=e.length()>8?3:1,g=[],_=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,y,b=0;b<h;b++){var x=e.getInt32(),S=e.getInt32();y=(x>>>4^S)&252645135,S^=y,x^=y<<4,y=(S>>>-16^x)&65535,x^=y,S^=y<<-16,y=(x>>>2^S)&858993459,S^=y,x^=y<<2,y=(S>>>-16^x)&65535,x^=y,S^=y<<-16,y=(x>>>1^S)&1431655765,S^=y,x^=y<<1,y=(S>>>8^x)&16711935,x^=y,S^=y<<8,y=(x>>>1^S)&1431655765,S^=y,x^=y<<1,y=x<<8|S>>>20&240,x=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=y;for(var C=0;C<_.length;++C){_[C]?(x=x<<2|x>>>26,S=S<<2|S>>>26):(x=x<<1|x>>>27,S=S<<1|S>>>27),x&=-15,S&=-15;var w=t[x>>>28]|n[x>>>24&15]|r[x>>>20&15]|i[x>>>16&15]|a[x>>>12&15]|o[x>>>8&15]|s[x>>>4&15],T=c[S>>>28]|l[S>>>24&15]|u[S>>>20&15]|d[S>>>16&15]|f[S>>>12&15]|p[S>>>8&15]|m[S>>>4&15];y=(T>>>16^w)&65535,g[v++]=w^y,g[v++]=T^y<<16}}return g}function _(e,t,n,r){var d=e.length===32?3:9,p=d===3?r?[30,-2,-2]:[0,32,2]:r?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2],m,h=t[0],g=t[1];m=(h>>>4^g)&252645135,g^=m,h^=m<<4,m=(h>>>16^g)&65535,g^=m,h^=m<<16,m=(g>>>2^h)&858993459,h^=m,g^=m<<2,m=(g>>>8^h)&16711935,h^=m,g^=m<<8,m=(h>>>1^g)&1431655765,g^=m,h^=m<<1,h=h<<1|h>>>31,g=g<<1|g>>>31;for(var _=0;_<d;_+=3){for(var v=p[_+1],y=p[_+2],b=p[_];b!=v;b+=y){var x=g^e[b],S=(g>>>4|g<<28)^e[b+1];m=h,h=g,g=m^(a[x>>>24&63]|s[x>>>16&63]|l[x>>>8&63]|f[x&63]|i[S>>>24&63]|o[S>>>16&63]|c[S>>>8&63]|u[S&63])}m=h,h=g,g=m}h=h>>>1|h<<31,g=g>>>1|g<<31,m=(h>>>1^g)&1431655765,g^=m,h^=m<<1,m=(g>>>8^h)&16711935,h^=m,g^=m<<8,m=(g>>>2^h)&858993459,h^=m,g^=m<<2,m=(h>>>16^g)&65535,g^=m,h^=m<<16,m=(h>>>4^g)&252645135,g^=m,h^=m<<4,n[0]=h,n[1]=g}function v(e){e||={};var t=`DES-`+(e.mode||`CBC`).toUpperCase(),r=e.decrypt?n.cipher.createDecipher(t,e.key):n.cipher.createCipher(t,e.key),i=r.start;return r.start=function(e,t){var a=null;t instanceof n.util.ByteBuffer&&(a=t,t={}),t||={},t.output=a,t.iv=e,i.call(r,t)},r}})),w=o(((e,t)=>{t.exports={}})),T=o(((e,t)=>{var n=d();b(),y(),p();var r=n.pkcs5=n.pkcs5||{},i;n.util.isNodejs&&!n.options.usePureJavaScript&&(i=w()),t.exports=n.pbkdf2=r.pbkdf2=function(e,t,r,a,o,s){if(typeof o==`function`&&(s=o,o=null),n.util.isNodejs&&!n.options.usePureJavaScript&&i.pbkdf2&&(typeof o!=`object`||!o)&&(i.pbkdf2Sync.length>4||!o||o===`sha1`))return typeof o!=`string`&&(o=`sha1`),e=Buffer.from(e,`binary`),t=Buffer.from(t,`binary`),s?i.pbkdf2Sync.length===4?i.pbkdf2(e,t,r,a,function(e,t){if(e)return s(e);s(null,t.toString(`binary`))}):i.pbkdf2(e,t,r,a,o,function(e,t){if(e)return s(e);s(null,t.toString(`binary`))}):i.pbkdf2Sync.length===4?i.pbkdf2Sync(e,t,r,a).toString(`binary`):i.pbkdf2Sync(e,t,r,a,o).toString(`binary`);if(o??=`sha1`,typeof o==`string`){if(!(o in n.md.algorithms))throw Error(`Unknown hash algorithm: `+o);o=n.md[o].create()}var c=o.digestLength;if(a>4294967295*c){var l=Error(`Derived key is too long.`);if(s)return s(l);throw l}var u=Math.ceil(a/c),d=a-(u-1)*c,f=n.hmac.create();f.start(o,e);var p=``,m,h,g;if(!s){for(var _=1;_<=u;++_){f.start(null,null),f.update(t),f.update(n.util.int32ToBytes(_)),m=g=f.digest().getBytes();for(var v=2;v<=r;++v)f.start(null,null),f.update(g),h=f.digest().getBytes(),m=n.util.xorBytes(m,h,c),g=h;p+=_<u?m:m.substr(0,d)}return p}var _=1,v;function y(){if(_>u)return s(null,p);f.start(null,null),f.update(t),f.update(n.util.int32ToBytes(_)),m=g=f.digest().getBytes(),v=2,b()}function b(){if(v<=r)return f.start(null,null),f.update(g),h=f.digest().getBytes(),m=n.util.xorBytes(m,h,c),g=h,++v,n.util.setImmediate(b);p+=_<u?m:m.substr(0,d),++_,y()}y()}})),E=o(((e,t)=>{var n=d();y(),p();var r=t.exports=n.sha256=n.sha256||{};n.md.sha256=n.md.algorithms.sha256=r,r.create=function(){a||s();var e=null,t=n.util.createBuffer(),r=Array(64),o={algorithm:`sha256`,blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return o.start=function(){o.messageLength=0,o.fullMessageLength=o.messageLength64=[];for(var r=o.messageLengthSize/4,i=0;i<r;++i)o.fullMessageLength.push(0);return t=n.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},o},o.start(),o.update=function(i,a){a===`utf8`&&(i=n.util.encodeUtf8(i));var s=i.length;o.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var l=o.fullMessageLength.length-1;l>=0;--l)o.fullMessageLength[l]+=s[1],s[1]=s[0]+(o.fullMessageLength[l]/4294967296>>>0),o.fullMessageLength[l]=o.fullMessageLength[l]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(i),c(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),o},o.digest=function(){var a=n.util.createBuffer();a.putBytes(t.bytes());var s=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;a.putBytes(i.substr(0,o.blockLength-s));for(var l,u,d=o.fullMessageLength[0]*8,f=0;f<o.fullMessageLength.length-1;++f)l=o.fullMessageLength[f+1]*8,u=l/4294967296>>>0,d+=u,a.putInt32(d>>>0),d=l>>>0;a.putInt32(d);var p={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(p,r,a);var m=n.util.createBuffer();return m.putInt32(p.h0),m.putInt32(p.h1),m.putInt32(p.h2),m.putInt32(p.h3),m.putInt32(p.h4),m.putInt32(p.h5),m.putInt32(p.h6),m.putInt32(p.h7),m},o};var i=null,a=!1,o=null;function s(){i=`€`,i+=n.util.fillString(`\0`,64),o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],a=!0}function c(e,t,n){for(var r,i,a,s,c,l,u,d,f,p,m,h,g,_,v,y=n.length();y>=64;){for(u=0;u<16;++u)t[u]=n.getInt32();for(;u<64;++u)r=t[u-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,i=t[u-15],i=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[u]=r+t[u-7]+i+t[u-16]|0;for(d=e.h0,f=e.h1,p=e.h2,m=e.h3,h=e.h4,g=e.h5,_=e.h6,v=e.h7,u=0;u<64;++u)s=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),c=_^h&(g^_),a=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),l=d&f|p&(d^f),r=v+s+c+o[u]+t[u],i=a+l,v=_,_=g,g=h,h=m+r>>>0,m=p,p=f,f=d,d=r+i>>>0;e.h0=e.h0+d|0,e.h1=e.h1+f|0,e.h2=e.h2+p|0,e.h3=e.h3+m|0,e.h4=e.h4+h|0,e.h5=e.h5+g|0,e.h6=e.h6+_|0,e.h7=e.h7+v|0,y-=64}}})),D=o(((e,t)=>{var n=d();p();var r=null;n.util.isNodejs&&!n.options.usePureJavaScript&&!process.versions[`node-webkit`]&&(r=w());var i=t.exports=n.prng=n.prng||{};i.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:``},i=e.md,a=Array(32),o=0;o<32;++o)a[o]=i.create();t.pools=a,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var i=t.plugin.cipher,a=t.plugin.increment,o=t.plugin.formatKey,c=t.plugin.formatSeed,l=n.util.createBuffer();t.key=null,u();function u(d){if(d)return r(d);if(l.length()>=e)return r(null,l.getBytes(e));if(t.generated>1048575&&(t.key=null),t.key===null)return n.util.nextTick(function(){s(u)});var f=i(t.key,t.seed);t.generated+=f.length,l.putBytes(f),t.key=o(i(t.key,a(t.seed))),t.seed=c(i(t.key,t.seed)),n.util.setImmediate(u)}},t.generateSync=function(e){var r=t.plugin.cipher,i=t.plugin.increment,a=t.plugin.formatKey,o=t.plugin.formatSeed;t.key=null;for(var s=n.util.createBuffer();s.length()<e;){t.generated>1048575&&(t.key=null),t.key===null&&c();var l=r(t.key,t.seed);t.generated+=l.length,s.putBytes(l),t.key=a(r(t.key,i(t.seed))),t.seed=o(r(t.key,t.seed))}return s.getBytes(e)};function s(e){if(t.pools[0].messageLength>=32)return l(),e();var n=32-t.pools[0].messageLength<<5;t.seedFile(n,function(n,r){if(n)return e(n);t.collect(r),l(),e()})}function c(){if(t.pools[0].messageLength>=32)return l();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),l()}function l(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var n=1,r=0;r<32;++r)t.reseeds%n===0&&(e.update(t.pools[r].digest().getBytes()),t.pools[r].start()),n<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function u(e){var t=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(t=function(e){return i.getRandomValues(e)});var a=n.util.createBuffer();if(t)for(;a.length()<e;){var o=Math.max(1,Math.min(e-a.length(),65536)/4),s=new Uint32Array(Math.floor(o));try{t(s);for(var c=0;c<s.length;++c)a.putInt32(s[c])}catch(e){if(!(typeof QuotaExceededError<`u`&&e instanceof QuotaExceededError))throw e}}if(a.length()<e)for(var l,u,d,f=Math.floor(Math.random()*65536);a.length()<e;){u=16807*(f&65535),l=16807*(f>>16),u+=(l&32767)<<16,u+=l>>15,u=(u&2147483647)+(u>>31),f=u&4294967295;for(var c=0;c<3;++c)d=f>>>(c<<3),d^=Math.floor(Math.random()*256),a.putByte(d&255)}return a.getBytes(e)}return r?(t.seedFile=function(e,t){r.randomBytes(e,function(e,n){if(e)return t(e);t(null,n.toString())})},t.seedFileSync=function(e){return r.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(e){t(e)}},t.seedFileSync=u),t.collect=function(e){for(var n=e.length,r=0;r<n;++r)t.pools[t.pool].update(e.substr(r,1)),t.pool=t.pool===31?0:t.pool+1},t.collectInt=function(e,n){for(var r=``,i=0;i<n;i+=8)r+=String.fromCharCode(e>>i&255);t.collect(r)},t.registerWorker=function(e){e===self?t.seedFile=function(e,t){function n(e){var r=e.data;r.forge&&r.forge.prng&&(self.removeEventListener(`message`,n),t(r.forge.prng.err,r.forge.prng.bytes))}self.addEventListener(`message`,n),self.postMessage({forge:{prng:{needed:e}}})}:e.addEventListener(`message`,function(n){var r=n.data;r.forge&&r.forge.prng&&t.seedFile(r.forge.prng.needed,function(t,n){e.postMessage({forge:{prng:{err:t,bytes:n}}})})})},t}})),O=o(((e,t)=>{var n=d();g(),E(),D(),p(),(function(){if(n.random&&n.random.getBytes){t.exports=n.random;return}(function(e){var r={},i=[,,,,],a=n.util.createBuffer();r.formatKey=function(e){var t=n.util.createBuffer(e);return e=[,,,,],e[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return e=[,,,,],e[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),a.putInt32(i[0]),a.putInt32(i[1]),a.putInt32(i[2]),a.putInt32(i[3]),a.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;function o(){var e=n.prng.create(r);return e.getBytes=function(t,n){return e.generate(t,n)},e.getBytesSync=function(t){return e.generate(t)},e}var s=o(),c=null,l=n.util.globalScope,u=l.crypto||l.msCrypto;if(u&&u.getRandomValues&&(c=function(e){return u.getRandomValues(e)}),n.options.usePureJavaScript||!n.util.isNodejs&&!c){if(typeof window>`u`||window.document,s.collectInt(+new Date,32),typeof navigator<`u`){var d=``;for(var f in navigator)try{typeof navigator[f]==`string`&&(d+=navigator[f])}catch{}s.collect(d),d=null}e&&(e().mousemove(function(e){s.collectInt(e.clientX,16),s.collectInt(e.clientY,16)}),e().keypress(function(e){s.collectInt(e.charCode,8)}))}if(!n.random)n.random=s;else for(var f in s)n.random[f]=s[f];n.random.createInstance=o,t.exports=n.random})(typeof jQuery<`u`?jQuery:null)})()})),k=o(((e,t)=>{var n=d();p();var r=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],i=[1,2,3,5],a=function(e,t){return e<<t&65535|(e&65535)>>16-t},o=function(e,t){return(e&65535)>>t|e<<16-t&65535};t.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){typeof e==`string`&&(e=n.util.createBuffer(e)),t||=128;var i=e,a=e.length(),o=t,s=Math.ceil(o/8),c=255>>(o&7),l;for(l=a;l<128;l++)i.putByte(r[i.at(l-1)+i.at(l-a)&255]);for(i.setAt(128-s,r[i.at(128-s)&c]),l=127-s;l>=0;l--)i.setAt(l,r[i.at(l+1)^i.at(l+s)]);return i};var s=function(e,t,r){var s=!1,c=null,l=null,u=null,d,f,p,m,h=[];for(e=n.rc2.expandKey(e,t),p=0;p<64;p++)h.push(e.getInt16Le());r?(d=function(e){for(p=0;p<4;p++)e[p]+=h[m]+(e[(p+3)%4]&e[(p+2)%4])+(~e[(p+3)%4]&e[(p+1)%4]),e[p]=a(e[p],i[p]),m++},f=function(e){for(p=0;p<4;p++)e[p]+=h[e[(p+3)%4]&63]}):(d=function(e){for(p=3;p>=0;p--)e[p]=o(e[p],i[p]),e[p]-=h[m]+(e[(p+3)%4]&e[(p+2)%4])+(~e[(p+3)%4]&e[(p+1)%4]),m--},f=function(e){for(p=3;p>=0;p--)e[p]-=h[e[(p+3)%4]&63]});var g=function(e){var t=[];for(p=0;p<4;p++){var n=c.getInt16Le();u!==null&&(r?n^=u.getInt16Le():u.putInt16Le(n)),t.push(n&65535)}m=r?0:63;for(var i=0;i<e.length;i++)for(var a=0;a<e[i][0];a++)e[i][1](t);for(p=0;p<4;p++)u!==null&&(r?u.putInt16Le(t[p]):t[p]^=u.getInt16Le()),l.putInt16Le(t[p])},_=null;return _={start:function(e,t){e&&typeof e==`string`&&(e=n.util.createBuffer(e)),s=!1,c=n.util.createBuffer(),l=t||new n.util.createBuffer,u=e,_.output=l},update:function(e){for(s||c.putBuffer(e);c.length()>=8;)g([[5,d],[1,f],[6,d],[1,f],[5,d]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,c,!r);else{var n=c.length()===8?8:8-c.length();c.fillWithByte(n,n)}if(t&&(s=!0,_.update()),!r&&(t=c.length()===0,t))if(e)t=e(8,l,!r);else{var i=l.length(),a=l.at(i-1);a>i?t=!1:l.truncate(a)}return t}},_};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return s(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return s(e,t,!1)}})),A=o(((e,t)=>{var n=d();t.exports=n.jsbn=n.jsbn||{};var r,i=!0;function a(e,t,n){this.data=[],e!=null&&(typeof e==`number`?this.fromNumber(e,t,n):t==null&&typeof e!=`string`?this.fromString(e,256):this.fromString(e,t))}n.jsbn.BigInteger=a;function o(){return new a(null)}function s(e,t,n,r,i,a){for(;--a>=0;){var o=t*this.data[e++]+n.data[r]+i;i=Math.floor(o/67108864),n.data[r++]=o&67108863}return i}function c(e,t,n,r,i,a){for(var o=t&32767,s=t>>15;--a>=0;){var c=this.data[e]&32767,l=this.data[e++]>>15,u=s*c+l*o;c=o*c+((u&32767)<<15)+n.data[r]+(i&1073741823),i=(c>>>30)+(u>>>15)+s*l+(i>>>30),n.data[r++]=c&1073741823}return i}function l(e,t,n,r,i,a){for(var o=t&16383,s=t>>14;--a>=0;){var c=this.data[e]&16383,l=this.data[e++]>>14,u=s*c+l*o;c=o*c+((u&16383)<<14)+n.data[r]+i,i=(c>>28)+(u>>14)+s*l,n.data[r++]=c&268435455}return i}typeof navigator>`u`?(a.prototype.am=l,r=28):i&&navigator.appName==`Microsoft Internet Explorer`?(a.prototype.am=c,r=30):i&&navigator.appName!=`Netscape`?(a.prototype.am=s,r=26):(a.prototype.am=l,r=28),a.prototype.DB=r,a.prototype.DM=(1<<r)-1,a.prototype.DV=1<<r;var u=52;a.prototype.FV=2**u,a.prototype.F1=u-r,a.prototype.F2=2*r-u;var f=`0123456789abcdefghijklmnopqrstuvwxyz`,p=[],m=48,h;for(h=0;h<=9;++h)p[m++]=h;for(m=97,h=10;h<36;++h)p[m++]=h;for(m=65,h=10;h<36;++h)p[m++]=h;function g(e){return f.charAt(e)}function _(e,t){return p[e.charCodeAt(t)]??-1}function v(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function y(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function b(e){var t=o();return t.fromInt(e),t}function x(e,t){var n;if(t==16)n=4;else if(t==8)n=3;else if(t==256)n=8;else if(t==2)n=1;else if(t==32)n=5;else if(t==4)n=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var r=e.length,i=!1,o=0;--r>=0;){var s=n==8?e[r]&255:_(e,r);if(s<0){e.charAt(r)==`-`&&(i=!0);continue}i=!1,o==0?this.data[this.t++]=s:o+n>this.DB?(this.data[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this.data[this.t++]=s>>this.DB-o):this.data[this.t-1]|=s<<o,o+=n,o>=this.DB&&(o-=this.DB)}n==8&&e[0]&128&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&a.ZERO.subTo(this,this)}function S(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t}function C(e){if(this.s<0)return`-`+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var n=(1<<t)-1,r,i=!1,a=``,o=this.t,s=this.DB-o*this.DB%t;if(o-- >0)for(s<this.DB&&(r=this.data[o]>>s)>0&&(i=!0,a=g(r));o>=0;)s<t?(r=(this.data[o]&(1<<s)-1)<<t-s,r|=this.data[--o]>>(s+=this.DB-t)):(r=this.data[o]>>(s-=t)&n,s<=0&&(s+=this.DB,--o)),r>0&&(i=!0),i&&(a+=g(r));return i?a:`0`}function w(){var e=o();return a.ZERO.subTo(this,e),e}function T(){return this.s<0?this.negate():this}function E(e){var t=this.s-e.s;if(t!=0)return t;var n=this.t;if(t=n-e.t,t!=0)return this.s<0?-t:t;for(;--n>=0;)if((t=this.data[n]-e.data[n])!=0)return t;return 0}function D(e){var t=1,n;return(n=e>>>16)!=0&&(e=n,t+=16),(n=e>>8)!=0&&(e=n,t+=8),(n=e>>4)!=0&&(e=n,t+=4),(n=e>>2)!=0&&(e=n,t+=2),(n=e>>1)!=0&&(e=n,t+=1),t}function O(){return this.t<=0?0:this.DB*(this.t-1)+D(this.data[this.t-1]^this.s&this.DM)}function k(e,t){var n;for(n=this.t-1;n>=0;--n)t.data[n+e]=this.data[n];for(n=e-1;n>=0;--n)t.data[n]=0;t.t=this.t+e,t.s=this.s}function A(e,t){for(var n=e;n<this.t;++n)t.data[n-e]=this.data[n];t.t=Math.max(this.t-e,0),t.s=this.s}function j(e,t){var n=e%this.DB,r=this.DB-n,i=(1<<r)-1,a=Math.floor(e/this.DB),o=this.s<<n&this.DM,s;for(s=this.t-1;s>=0;--s)t.data[s+a+1]=this.data[s]>>r|o,o=(this.data[s]&i)<<n;for(s=a-1;s>=0;--s)t.data[s]=0;t.data[a]=o,t.t=this.t+a+1,t.s=this.s,t.clamp()}function M(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t){t.t=0;return}var r=e%this.DB,i=this.DB-r,a=(1<<r)-1;t.data[0]=this.data[n]>>r;for(var o=n+1;o<this.t;++o)t.data[o-n-1]|=(this.data[o]&a)<<i,t.data[o-n]=this.data[o]>>r;r>0&&(t.data[this.t-n-1]|=(this.s&a)<<i),t.t=this.t-n,t.clamp()}function N(e,t){for(var n=0,r=0,i=Math.min(e.t,this.t);n<i;)r+=this.data[n]-e.data[n],t.data[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;n<this.t;)r+=this.data[n],t.data[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r-=e.data[n],t.data[n++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t.data[n++]=this.DV+r:r>0&&(t.data[n++]=r),t.t=n,t.clamp()}function P(e,t){var n=this.abs(),r=e.abs(),i=n.t;for(t.t=i+r.t;--i>=0;)t.data[i]=0;for(i=0;i<r.t;++i)t.data[i+n.t]=n.am(0,r.data[i],t,i,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&a.ZERO.subTo(t,t)}function ee(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e.data[n]=0;for(n=0;n<t.t-1;++n){var r=t.am(n,t.data[n],e,2*n,0,1);(e.data[n+t.t]+=t.am(n+1,2*t.data[n],e,2*n+1,r,t.t-n-1))>=t.DV&&(e.data[n+t.t]-=t.DV,e.data[n+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(n,t.data[n],e,2*n,0,1)),e.s=0,e.clamp()}function F(e,t,n){var r=e.abs();if(!(r.t<=0)){var i=this.abs();if(i.t<r.t){t?.fromInt(0),n!=null&&this.copyTo(n);return}n??=o();var s=o(),c=this.s,l=e.s,u=this.DB-D(r.data[r.t-1]);u>0?(r.lShiftTo(u,s),i.lShiftTo(u,n)):(r.copyTo(s),i.copyTo(n));var d=s.t,f=s.data[d-1];if(f!=0){var p=f*(1<<this.F1)+(d>1?s.data[d-2]>>this.F2:0),m=this.FV/p,h=(1<<this.F1)/p,g=1<<this.F2,_=n.t,v=_-d,y=t??o();for(s.dlShiftTo(v,y),n.compareTo(y)>=0&&(n.data[n.t++]=1,n.subTo(y,n)),a.ONE.dlShiftTo(d,y),y.subTo(s,s);s.t<d;)s.data[s.t++]=0;for(;--v>=0;){var b=n.data[--_]==f?this.DM:Math.floor(n.data[_]*m+(n.data[_-1]+g)*h);if((n.data[_]+=s.am(0,b,n,v,0,d))<b)for(s.dlShiftTo(v,y),n.subTo(y,n);n.data[_]<--b;)n.subTo(y,n)}t!=null&&(n.drShiftTo(d,t),c!=l&&a.ZERO.subTo(t,t)),n.t=d,n.clamp(),u>0&&n.rShiftTo(u,n),c<0&&a.ZERO.subTo(n,n)}}}function I(e){var t=o();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(a.ZERO)>0&&e.subTo(t,t),t}function L(e){this.m=e}function R(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function z(e){return e}function B(e){e.divRemTo(this.m,null,e)}function V(e,t,n){e.multiplyTo(t,n),this.reduce(n)}function H(e,t){e.squareTo(t),this.reduce(t)}L.prototype.convert=R,L.prototype.revert=z,L.prototype.reduce=B,L.prototype.mulTo=V,L.prototype.sqrTo=H;function U(){if(this.t<1)return 0;var e=this.data[0];if(!(e&1))return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function W(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function G(e){var t=o();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(a.ZERO)>0&&this.m.subTo(t,t),t}function K(e){var t=o();return e.copyTo(t),this.reduce(t),t}function q(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=e.data[t]&32767,r=n*this.mpl+((n*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(n=t+this.m.t,e.data[n]+=this.m.am(0,r,e,t,0,this.m.t);e.data[n]>=e.DV;)e.data[n]-=e.DV,e.data[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function J(e,t){e.squareTo(t),this.reduce(t)}function Y(e,t,n){e.multiplyTo(t,n),this.reduce(n)}W.prototype.convert=G,W.prototype.revert=K,W.prototype.reduce=q,W.prototype.mulTo=Y,W.prototype.sqrTo=J;function X(){return(this.t>0?this.data[0]&1:this.s)==0}function Z(e,t){if(e>4294967295||e<1)return a.ONE;var n=o(),r=o(),i=t.convert(this),s=D(e)-1;for(i.copyTo(n);--s>=0;)if(t.sqrTo(n,r),(e&1<<s)>0)t.mulTo(r,i,n);else{var c=n;n=r,r=c}return t.revert(n)}function te(e,t){var n=e<256||t.isEven()?new L(t):new W(t);return this.exp(e,n)}a.prototype.copyTo=v,a.prototype.fromInt=y,a.prototype.fromString=x,a.prototype.clamp=S,a.prototype.dlShiftTo=k,a.prototype.drShiftTo=A,a.prototype.lShiftTo=j,a.prototype.rShiftTo=M,a.prototype.subTo=N,a.prototype.multiplyTo=P,a.prototype.squareTo=ee,a.prototype.divRemTo=F,a.prototype.invDigit=U,a.prototype.isEven=X,a.prototype.exp=Z,a.prototype.toString=C,a.prototype.negate=w,a.prototype.abs=T,a.prototype.compareTo=E,a.prototype.bitLength=O,a.prototype.mod=I,a.prototype.modPowInt=te,a.ZERO=b(0),a.ONE=b(1);function ne(){var e=o();return this.copyTo(e),e}function re(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else if(this.t==1)return this.data[0];else if(this.t==0)return 0;return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function ie(){return this.t==0?this.s:this.data[0]<<24>>24}function ae(){return this.t==0?this.s:this.data[0]<<16>>16}function oe(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function se(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function ce(e){if(e??=10,this.signum()==0||e<2||e>36)return`0`;var t=this.chunkSize(e),n=e**+t,r=b(n),i=o(),a=o(),s=``;for(this.divRemTo(r,i,a);i.signum()>0;)s=(n+a.intValue()).toString(e).substr(1)+s,i.divRemTo(r,i,a);return a.intValue().toString(e)+s}function le(e,t){this.fromInt(0),t??=10;for(var n=this.chunkSize(t),r=t**+n,i=!1,o=0,s=0,c=0;c<e.length;++c){var l=_(e,c);if(l<0){e.charAt(c)==`-`&&this.signum()==0&&(i=!0);continue}s=t*s+l,++o>=n&&(this.dMultiply(r),this.dAddOffset(s,0),o=0,s=0)}o>0&&(this.dMultiply(t**+o),this.dAddOffset(s,0)),i&&a.ZERO.subTo(this,this)}function ue(e,t,n){if(typeof t==`number`)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(a.ONE.shiftLeft(e-1),ve,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(a.ONE.shiftLeft(e-1),this);else{var r=[],i=e&7;r.length=(e>>3)+1,t.nextBytes(r),i>0?r[0]&=(1<<i)-1:r[0]=0,this.fromString(r,256)}}function de(){var e=this.t,t=[];t[0]=this.s;var n=this.DB-e*this.DB%8,r,i=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),r&128&&(r|=-256),i==0&&(this.s&128)!=(r&128)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t}function fe(e){return this.compareTo(e)==0}function pe(e){return this.compareTo(e)<0?this:e}function me(e){return this.compareTo(e)>0?this:e}function he(e,t,n){var r,i,a=Math.min(e.t,this.t);for(r=0;r<a;++r)n.data[r]=t(this.data[r],e.data[r]);if(e.t<this.t){for(i=e.s&this.DM,r=a;r<this.t;++r)n.data[r]=t(this.data[r],i);n.t=this.t}else{for(i=this.s&this.DM,r=a;r<e.t;++r)n.data[r]=t(i,e.data[r]);n.t=e.t}n.s=t(this.s,e.s),n.clamp()}function ge(e,t){return e&t}function _e(e){var t=o();return this.bitwiseTo(e,ge,t),t}function ve(e,t){return e|t}function ye(e){var t=o();return this.bitwiseTo(e,ve,t),t}function be(e,t){return e^t}function xe(e){var t=o();return this.bitwiseTo(e,be,t),t}function Se(e,t){return e&~t}function Ce(e){var t=o();return this.bitwiseTo(e,Se,t),t}function we(){for(var e=o(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e}function Te(e){var t=o();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function Q(e){var t=o();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function Ee(e){if(e==0)return-1;var t=0;return e&65535||(e>>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function $(){for(var e=0;e<this.t;++e)if(this.data[e]!=0)return e*this.DB+Ee(this.data[e]);return this.s<0?this.t*this.DB:-1}function De(e){for(var t=0;e!=0;)e&=e-1,++t;return t}function Oe(){for(var e=0,t=this.s&this.DM,n=0;n<this.t;++n)e+=De(this.data[n]^t);return e}function ke(e){var t=Math.floor(e/this.DB);return t>=this.t?this.s!=0:(this.data[t]&1<<e%this.DB)!=0}function Ae(e,t){var n=a.ONE.shiftLeft(e);return this.bitwiseTo(n,t,n),n}function je(e){return this.changeBit(e,ve)}function Me(e){return this.changeBit(e,Se)}function Ne(e){return this.changeBit(e,be)}function Pe(e,t){for(var n=0,r=0,i=Math.min(e.t,this.t);n<i;)r+=this.data[n]+e.data[n],t.data[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;n<this.t;)r+=this.data[n],t.data[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r+=e.data[n],t.data[n++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t.data[n++]=r:r<-1&&(t.data[n++]=this.DV+r),t.t=n,t.clamp()}function Fe(e){var t=o();return this.addTo(e,t),t}function Ie(e){var t=o();return this.subTo(e,t),t}function Le(e){var t=o();return this.multiplyTo(e,t),t}function Re(e){var t=o();return this.divRemTo(e,t,null),t}function ze(e){var t=o();return this.divRemTo(e,null,t),t}function Be(e){var t=o(),n=o();return this.divRemTo(e,t,n),[t,n]}function Ve(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function He(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function Ue(){}function We(e){return e}function Ge(e,t,n){e.multiplyTo(t,n)}function Ke(e,t){e.squareTo(t)}Ue.prototype.convert=We,Ue.prototype.revert=We,Ue.prototype.mulTo=Ge,Ue.prototype.sqrTo=Ke;function qe(e){return this.exp(e,new Ue)}function Je(e,t,n){var r=Math.min(this.t+e.t,t);for(n.s=0,n.t=r;r>0;)n.data[--r]=0;var i;for(i=n.t-this.t;r<i;++r)n.data[r+this.t]=this.am(0,e.data[r],n,r,0,this.t);for(i=Math.min(e.t,t);r<i;++r)this.am(0,e.data[r],n,r,0,t-r);n.clamp()}function Ye(e,t,n){--t;var r=n.t=this.t+e.t-t;for(n.s=0;--r>=0;)n.data[r]=0;for(r=Math.max(t-this.t,0);r<e.t;++r)n.data[this.t+r-t]=this.am(t-r,e.data[r],n,0,0,this.t+r-t);n.clamp(),n.drShiftTo(1,n)}function Xe(e){this.r2=o(),this.q3=o(),a.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function Ze(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=o();return e.copyTo(t),this.reduce(t),t}function Qe(e){return e}function $e(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function et(e,t){e.squareTo(t),this.reduce(t)}function tt(e,t,n){e.multiplyTo(t,n),this.reduce(n)}Xe.prototype.convert=Ze,Xe.prototype.revert=Qe,Xe.prototype.reduce=$e,Xe.prototype.mulTo=tt,Xe.prototype.sqrTo=et;function nt(e,t){var n=e.bitLength(),r,i=b(1),a;if(n<=0)return i;r=n<18?1:n<48?3:n<144?4:n<768?5:6,a=n<8?new L(t):t.isEven()?new Xe(t):new W(t);var s=[],c=3,l=r-1,u=(1<<r)-1;if(s[1]=a.convert(this),r>1){var d=o();for(a.sqrTo(s[1],d);c<=u;)s[c]=o(),a.mulTo(d,s[c-2],s[c]),c+=2}var f=e.t-1,p,m=!0,h=o(),g;for(n=D(e.data[f])-1;f>=0;){for(n>=l?p=e.data[f]>>n-l&u:(p=(e.data[f]&(1<<n+1)-1)<<l-n,f>0&&(p|=e.data[f-1]>>this.DB+n-l)),c=r;!(p&1);)p>>=1,--c;if((n-=c)<0&&(n+=this.DB,--f),m)s[p].copyTo(i),m=!1;else{for(;c>1;)a.sqrTo(i,h),a.sqrTo(h,i),c-=2;c>0?a.sqrTo(i,h):(g=i,i=h,h=g),a.mulTo(h,s[p],i)}for(;f>=0&&!(e.data[f]&1<<n);)a.sqrTo(i,h),g=i,i=h,h=g,--n<0&&(n=this.DB-1,--f)}return a.revert(i)}function rt(e){var t=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(t.compareTo(n)<0){var r=t;t=n,n=r}var i=t.getLowestSetBit(),a=n.getLowestSetBit();if(a<0)return t;for(i<a&&(a=i),a>0&&(t.rShiftTo(a,t),n.rShiftTo(a,n));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),t.compareTo(n)>=0?(t.subTo(n,t),t.rShiftTo(1,t)):(n.subTo(t,n),n.rShiftTo(1,n));return a>0&&n.lShiftTo(a,n),n}function it(e){if(e<=0)return 0;var t=this.DV%e,n=this.s<0?e-1:0;if(this.t>0)if(t==0)n=this.data[0]%e;else for(var r=this.t-1;r>=0;--r)n=(t*n+this.data[r])%e;return n}function at(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return a.ZERO;for(var n=e.clone(),r=this.clone(),i=b(1),o=b(0),s=b(0),c=b(1);n.signum()!=0;){for(;n.isEven();)n.rShiftTo(1,n),t?((!i.isEven()||!o.isEven())&&(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;r.isEven();)r.rShiftTo(1,r),t?((!s.isEven()||!c.isEven())&&(s.addTo(this,s),c.subTo(e,c)),s.rShiftTo(1,s)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);n.compareTo(r)>=0?(n.subTo(r,n),t&&i.subTo(s,i),o.subTo(c,o)):(r.subTo(n,r),t&&s.subTo(i,s),c.subTo(o,c))}if(r.compareTo(a.ONE)!=0)return a.ZERO;if(c.compareTo(e)>=0)return c.subtract(e);if(c.signum()<0)c.addTo(e,c);else return c;return c.signum()<0?c.add(e):c}var ot=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],st=(1<<26)/ot[ot.length-1];function ct(e){var t,n=this.abs();if(n.t==1&&n.data[0]<=ot[ot.length-1]){for(t=0;t<ot.length;++t)if(n.data[0]==ot[t])return!0;return!1}if(n.isEven())return!1;for(t=1;t<ot.length;){for(var r=ot[t],i=t+1;i<ot.length&&r<st;)r*=ot[i++];for(r=n.modInt(r);t<i;)if(r%ot[t++]==0)return!1}return n.millerRabin(e)}function lt(e){var t=this.subtract(a.ONE),n=t.getLowestSetBit();if(n<=0)return!1;for(var r=t.shiftRight(n),i=ut(),o,s=0;s<e;++s){do o=new a(this.bitLength(),i);while(o.compareTo(a.ONE)<=0||o.compareTo(t)>=0);var c=o.modPow(r,this);if(c.compareTo(a.ONE)!=0&&c.compareTo(t)!=0){for(var l=1;l++<n&&c.compareTo(t)!=0;)if(c=c.modPowInt(2,this),c.compareTo(a.ONE)==0)return!1;if(c.compareTo(t)!=0)return!1}}return!0}function ut(){return{nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(Math.random()*256)}}}a.prototype.chunkSize=oe,a.prototype.toRadix=ce,a.prototype.fromRadix=le,a.prototype.fromNumber=ue,a.prototype.bitwiseTo=he,a.prototype.changeBit=Ae,a.prototype.addTo=Pe,a.prototype.dMultiply=Ve,a.prototype.dAddOffset=He,a.prototype.multiplyLowerTo=Je,a.prototype.multiplyUpperTo=Ye,a.prototype.modInt=it,a.prototype.millerRabin=lt,a.prototype.clone=ne,a.prototype.intValue=re,a.prototype.byteValue=ie,a.prototype.shortValue=ae,a.prototype.signum=se,a.prototype.toByteArray=de,a.prototype.equals=fe,a.prototype.min=pe,a.prototype.max=me,a.prototype.and=_e,a.prototype.or=ye,a.prototype.xor=xe,a.prototype.andNot=Ce,a.prototype.not=we,a.prototype.shiftLeft=Te,a.prototype.shiftRight=Q,a.prototype.getLowestSetBit=$,a.prototype.bitCount=Oe,a.prototype.testBit=ke,a.prototype.setBit=je,a.prototype.clearBit=Me,a.prototype.flipBit=Ne,a.prototype.add=Fe,a.prototype.subtract=Ie,a.prototype.multiply=Le,a.prototype.divide=Re,a.prototype.remainder=ze,a.prototype.divideAndRemainder=Be,a.prototype.modPow=nt,a.prototype.modInverse=at,a.prototype.pow=qe,a.prototype.gcd=rt,a.prototype.isProbablePrime=ct})),j=o(((e,t)=>{var n=d();y(),p();var r=t.exports=n.sha1=n.sha1||{};n.md.sha1=n.md.algorithms.sha1=r,r.create=function(){a||o();var e=null,t=n.util.createBuffer(),r=Array(80),c={algorithm:`sha1`,blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return c.start=function(){c.messageLength=0,c.fullMessageLength=c.messageLength64=[];for(var r=c.messageLengthSize/4,i=0;i<r;++i)c.fullMessageLength.push(0);return t=n.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},c},c.start(),c.update=function(i,a){a===`utf8`&&(i=n.util.encodeUtf8(i));var o=i.length;c.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var l=c.fullMessageLength.length-1;l>=0;--l)c.fullMessageLength[l]+=o[1],o[1]=o[0]+(c.fullMessageLength[l]/4294967296>>>0),c.fullMessageLength[l]=c.fullMessageLength[l]>>>0,o[0]=o[1]/4294967296>>>0;return t.putBytes(i),s(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),c},c.digest=function(){var a=n.util.createBuffer();a.putBytes(t.bytes());var o=c.fullMessageLength[c.fullMessageLength.length-1]+c.messageLengthSize&c.blockLength-1;a.putBytes(i.substr(0,c.blockLength-o));for(var l,u,d=c.fullMessageLength[0]*8,f=0;f<c.fullMessageLength.length-1;++f)l=c.fullMessageLength[f+1]*8,u=l/4294967296>>>0,d+=u,a.putInt32(d>>>0),d=l>>>0;a.putInt32(d);var p={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};s(p,r,a);var m=n.util.createBuffer();return m.putInt32(p.h0),m.putInt32(p.h1),m.putInt32(p.h2),m.putInt32(p.h3),m.putInt32(p.h4),m},c};var i=null,a=!1;function o(){i=`€`,i+=n.util.fillString(`\0`,64),a=!0}function s(e,t,n){for(var r,i,a,o,s,c,l,u,d=n.length();d>=64;){for(i=e.h0,a=e.h1,o=e.h2,s=e.h3,c=e.h4,u=0;u<16;++u)r=n.getInt32(),t[u]=r,l=s^a&(o^s),r=(i<<5|i>>>27)+l+c+1518500249+r,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=r;for(;u<20;++u)r=t[u-3]^t[u-8]^t[u-14]^t[u-16],r=r<<1|r>>>31,t[u]=r,l=s^a&(o^s),r=(i<<5|i>>>27)+l+c+1518500249+r,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=r;for(;u<32;++u)r=t[u-3]^t[u-8]^t[u-14]^t[u-16],r=r<<1|r>>>31,t[u]=r,l=a^o^s,r=(i<<5|i>>>27)+l+c+1859775393+r,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=r;for(;u<40;++u)r=t[u-6]^t[u-16]^t[u-28]^t[u-32],r=r<<2|r>>>30,t[u]=r,l=a^o^s,r=(i<<5|i>>>27)+l+c+1859775393+r,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=r;for(;u<60;++u)r=t[u-6]^t[u-16]^t[u-28]^t[u-32],r=r<<2|r>>>30,t[u]=r,l=a&o|s&(a^o),r=(i<<5|i>>>27)+l+c+2400959708+r,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=r;for(;u<80;++u)r=t[u-6]^t[u-16]^t[u-28]^t[u-32],r=r<<2|r>>>30,t[u]=r,l=a^o^s,r=(i<<5|i>>>27)+l+c+3395469782+r,c=s,s=o,o=(a<<30|a>>>2)>>>0,a=i,i=r;e.h0=e.h0+i|0,e.h1=e.h1+a|0,e.h2=e.h2+o|0,e.h3=e.h3+s|0,e.h4=e.h4+c|0,d-=64}}})),M=o(((e,t)=>{var n=d();p(),O(),j();var r=t.exports=n.pkcs1=n.pkcs1||{};r.encode_rsa_oaep=function(e,t,r){var a,o,s,c;typeof r==`string`?(a=r,o=arguments[3]||void 0,s=arguments[4]||void 0):r&&(a=r.label||void 0,o=r.seed||void 0,s=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),s?s.start():s=n.md.sha1.create(),c||=s;var l=Math.ceil(e.n.bitLength()/8),u=l-2*s.digestLength-2;if(t.length>u){var d=Error(`RSAES-OAEP input message length is too long.`);throw d.length=t.length,d.maxLength=u,d}a||=``,s.update(a,`raw`);for(var f=s.digest(),p=``,m=u-t.length,h=0;h<m;h++)p+=`\0`;var g=f.getBytes()+p+``+t;if(!o)o=n.random.getBytes(s.digestLength);else if(o.length!==s.digestLength){var d=Error(`Invalid RSAES-OAEP seed. The seed length must match the digest length.`);throw d.seedLength=o.length,d.digestLength=s.digestLength,d}var _=i(o,l-s.digestLength-1,c),v=n.util.xorBytes(g,_,g.length),y=i(v,s.digestLength,c);return`\0`+n.util.xorBytes(o,y,o.length)+v},r.decode_rsa_oaep=function(e,t,r){var a,o,s;typeof r==`string`?(a=r,o=arguments[3]||void 0):r&&(a=r.label||void 0,o=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md));var c=Math.ceil(e.n.bitLength()/8);if(t.length!==c){var l=Error(`RSAES-OAEP encoded message length is invalid.`);throw l.length=t.length,l.expectedLength=c,l}if(o===void 0?o=n.md.sha1.create():o.start(),s||=o,c<2*o.digestLength+2)throw Error(`RSAES-OAEP key is too short for the hash function.`);a||=``,o.update(a,`raw`);for(var u=o.digest().getBytes(),d=t.charAt(0),f=t.substring(1,o.digestLength+1),p=t.substring(1+o.digestLength),m=i(p,o.digestLength,s),h=i(n.util.xorBytes(f,m,f.length),c-o.digestLength-1,s),g=n.util.xorBytes(p,h,p.length),_=g.substring(0,o.digestLength),l=d!==`\0`,v=0;v<o.digestLength;++v)l|=u.charAt(v)!==_.charAt(v);for(var y=1,b=o.digestLength,x=o.digestLength;x<g.length;x++){var S=g.charCodeAt(x),C=S&1^1;l|=S&(y?65534:0),y&=C,b+=y}if(l||g.charCodeAt(b)!==1)throw Error(`Invalid RSAES-OAEP padding.`);return g.substring(b+1)};function i(e,t,r){r||=n.md.sha1.create();for(var i=``,a=Math.ceil(t/r.digestLength),o=0;o<a;++o){var s=String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,o&255);r.start(),r.update(e+s),i+=r.digest().getBytes()}return i.substring(0,t)}})),N=o(((e,t)=>{var n=d();p(),A(),O(),(function(){if(n.prime){t.exports=n.prime;return}var e=t.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],a=new r(null);a.fromInt(30);var o=function(e,t){return e|t};e.generateProbablePrime=function(e,t,r){typeof t==`function`&&(r=t,t={}),t||={};var i=t.algorithm||`PRIMEINC`;typeof i==`string`&&(i={name:i}),i.options=i.options||{};var a=t.prng||n.random,o={nextBytes:function(e){for(var t=a.getBytesSync(e.length),n=0;n<e.length;++n)e[n]=t.charCodeAt(n)}};if(i.name===`PRIMEINC`)return s(e,o,i.options,r);throw Error(`Invalid prime generation algorithm: `+i.name)};function s(e,t,n,r){return`workers`in n?u(e,t,n,r):c(e,t,n,r)}function c(e,t,n,r){var i=d(e,t),a=0,o=f(i.bitLength());`millerRabinTests`in n&&(o=n.millerRabinTests);var s=10;`maxBlockTime`in n&&(s=n.maxBlockTime),l(i,e,t,a,o,s,r)}function l(e,t,r,a,o,s,c){var u=+new Date;do{if(e.bitLength()>t&&(e=d(t,r)),e.isProbablePrime(o))return c(null,e);e.dAddOffset(i[a++%8],0)}while(s<0||+new Date-u<s);n.util.setImmediate(function(){l(e,t,r,a,o,s,c)})}function u(e,t,i,a){if(typeof Worker>`u`)return c(e,t,i,a);var o=d(e,t),s=i.workers,l=i.workLoad||100,u=l*30/8,f=i.workerScript||`forge/prime.worker.js`;if(s===-1)return n.util.estimateCores(function(e,t){e&&(t=2),s=t-1,p()});p();function p(){s=Math.max(1,s);for(var n=[],i=0;i<s;++i)n[i]=new Worker(f);for(var c=s,i=0;i<s;++i)n[i].addEventListener(`message`,m);var p=!1;function m(i){if(!p){--c;var s=i.data;if(s.found){for(var f=0;f<n.length;++f)n[f].terminate();return p=!0,a(null,new r(s.prime,16))}o.bitLength()>e&&(o=d(e,t));var m=o.toString(16);i.target.postMessage({hex:m,workLoad:l}),o.dAddOffset(u,0)}}}}function d(e,t){var n=new r(e,t),i=e-1;return n.testBit(i)||n.bitwiseTo(r.ONE.shiftLeft(i),o,n),n.dAddOffset(31-n.mod(a).byteValue(),0),n}function f(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}})()})),P=o(((e,t)=>{var n=d();if(v(),A(),_(),M(),N(),O(),p(),r===void 0)var r=n.jsbn.BigInteger;var i=n.util.isNodejs?w():null,a=n.asn1,o=n.util;n.pki=n.pki||{},t.exports=n.pki.rsa=n.rsa=n.rsa||{};var s=n.pki,c=[6,4,2,4,2,4,6,2],l={name:`PrivateKeyInfo`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:`PrivateKeyInfo.version`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyVersion`},{name:`PrivateKeyInfo.privateKeyAlgorithm`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:`AlgorithmIdentifier.algorithm`,tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:`privateKeyOid`}]},{name:`PrivateKeyInfo`,tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:`privateKey`}]},u={name:`RSAPrivateKey`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:`RSAPrivateKey.version`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyVersion`},{name:`RSAPrivateKey.modulus`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyModulus`},{name:`RSAPrivateKey.publicExponent`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyPublicExponent`},{name:`RSAPrivateKey.privateExponent`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyPrivateExponent`},{name:`RSAPrivateKey.prime1`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyPrime1`},{name:`RSAPrivateKey.prime2`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyPrime2`},{name:`RSAPrivateKey.exponent1`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyExponent1`},{name:`RSAPrivateKey.exponent2`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyExponent2`},{name:`RSAPrivateKey.coefficient`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`privateKeyCoefficient`}]},f={name:`RSAPublicKey`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:`RSAPublicKey.modulus`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`publicKeyModulus`},{name:`RSAPublicKey.exponent`,tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:`publicKeyExponent`}]},m=n.pki.rsa.publicKeyValidator={name:`SubjectPublicKeyInfo`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,captureAsn1:`subjectPublicKeyInfo`,value:[{name:`SubjectPublicKeyInfo.AlgorithmIdentifier`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:`AlgorithmIdentifier.algorithm`,tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:`publicKeyOid`}]},{name:`SubjectPublicKeyInfo.subjectPublicKey`,tagClass:a.Class.UNIVERSAL,type:a.Type.BITSTRING,constructed:!1,value:[{name:`SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:`rsaPublicKey`}]}]},h={name:`DigestInfo`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:`DigestInfo.DigestAlgorithm`,tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:`DigestInfo.DigestAlgorithm.algorithmIdentifier`,tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:`algorithmIdentifier`},{name:`DigestInfo.DigestAlgorithm.parameters`,tagClass:a.Class.UNIVERSAL,type:a.Type.NULL,capture:`parameters`,optional:!0,constructed:!1}]},{name:`DigestInfo.digest`,tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:`digest`}]},g=function(e){var t;if(e.algorithm in s.oids)t=s.oids[e.algorithm];else{var n=Error(`Unknown message digest algorithm.`);throw n.algorithm=e.algorithm,n}var r=a.oidToDer(t).getBytes(),i=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[]),o=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[]);o.value.push(a.create(a.Class.UNIVERSAL,a.Type.OID,!1,r)),o.value.push(a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,``));var c=a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(o),i.value.push(c),a.toDer(i).getBytes()},y=function(e,t,i){if(i)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||=t.d.mod(t.p.subtract(r.ONE)),t.dQ||=t.d.mod(t.q.subtract(r.ONE)),t.qInv||=t.q.modInverse(t.p);var a;do a=new r(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16);while(a.compareTo(t.n)>=0||!a.gcd(t.n).equals(r.ONE));e=e.multiply(a.modPow(t.e,t.n)).mod(t.n);for(var o=e.mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);o.compareTo(s)<0;)o=o.add(t.p);var c=o.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s);return c=c.multiply(a.modInverse(t.n)).mod(t.n),c};s.rsa.encrypt=function(e,t,i){var a=i,o,s=Math.ceil(t.n.bitLength()/8);i!==!1&&i!==!0?(a=i===2,o=b(e,t,i)):(o=n.util.createBuffer(),o.putBytes(e));for(var c=y(new r(o.toHex(),16),t,a).toString(16),l=n.util.createBuffer(),u=s-Math.ceil(c.length/2);u>0;)l.putByte(0),--u;return l.putBytes(n.util.hexToBytes(c)),l.getBytes()},s.rsa.decrypt=function(e,t,i,a){var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var s=Error(`Encrypted message length is invalid.`);throw s.length=e.length,s.expected=o,s}var c=new r(n.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw Error(`Encrypted message is invalid.`);for(var l=y(c,t,i).toString(16),u=n.util.createBuffer(),d=o-Math.ceil(l.length/2);d>0;)u.putByte(0),--d;return u.putBytes(n.util.hexToBytes(l)),a===!1?u.getBytes():x(u.getBytes(),t,i)},s.rsa.createKeyPairGenerationState=function(e,t,i){typeof e==`string`&&(e=parseInt(e,10)),e||=2048,i||={};var a=i.prng||n.random,o={nextBytes:function(e){for(var t=a.getBytesSync(e.length),n=0;n<e.length;++n)e[n]=t.charCodeAt(n)}},s=i.algorithm||`PRIMEINC`,c;if(s===`PRIMEINC`)c={algorithm:s,state:0,bits:e,rng:o,eInt:t||65537,e:new r(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},c.e.fromInt(c.eInt);else throw Error(`Invalid key generation algorithm: `+s);return c},s.rsa.stepKeyPairGenerationState=function(e,t){`algorithm`in e||(e.algorithm=`PRIMEINC`);var n=new r(null);n.fromInt(30);for(var i=0,a=function(e,t){return e|t},o=+new Date,l,u=0;e.keys===null&&(t<=0||u<t);){if(e.state===0){var d=e.p===null?e.pBits:e.qBits,f=d-1;e.pqState===0?(e.num=new r(d,e.rng),e.num.testBit(f)||e.num.bitwiseTo(r.ONE.shiftLeft(f),a,e.num),e.num.dAddOffset(31-e.num.mod(n).byteValue(),0),i=0,++e.pqState):e.pqState===1?e.num.bitLength()>d?e.pqState=0:e.num.isProbablePrime(T(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(c[i++%8],0):e.pqState===2?e.pqState=e.num.subtract(r.ONE).gcd(e.e).compareTo(r.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(r.ONE),e.q1=e.q.subtract(r.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(r.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var p=e.e.modInverse(e.phi);e.keys={privateKey:s.rsa.setPrivateKey(e.n,e.e,p,e.p,e.q,p.mod(e.p1),p.mod(e.q1),e.q.modInverse(e.p)),publicKey:s.rsa.setPublicKey(e.n,e.e)}}l=+new Date,u+=l-o,o=l}return e.keys!==null},s.rsa.generateKeyPair=function(e,t,r,c){if(arguments.length===1?typeof e==`object`?(r=e,e=void 0):typeof e==`function`&&(c=e,e=void 0):arguments.length===2?typeof e==`number`?typeof t==`function`?(c=t,t=void 0):typeof t!=`number`&&(r=t,t=void 0):(r=e,c=t,e=void 0,t=void 0):arguments.length===3&&(typeof t==`number`?typeof r==`function`&&(c=r,r=void 0):(c=r,r=t,t=void 0)),r||={},e===void 0&&(e=r.bits||2048),t===void 0&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(c){if(E(`generateKeyPair`))return i.generateKeyPair(`rsa`,{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:`spki`,format:`pem`},privateKeyEncoding:{type:`pkcs8`,format:`pem`}},function(e,t,n){if(e)return c(e);c(null,{privateKey:s.privateKeyFromPem(n),publicKey:s.publicKeyFromPem(t)})});if(D(`generateKey`)&&D(`exportKey`))return o.globalScope.crypto.subtle.generateKey({name:`RSASSA-PKCS1-v1_5`,modulusLength:e,publicExponent:j(t),hash:{name:`SHA-256`}},!0,[`sign`,`verify`]).then(function(e){return o.globalScope.crypto.subtle.exportKey(`pkcs8`,e.privateKey)}).then(void 0,function(e){c(e)}).then(function(e){if(e){var t=s.privateKeyFromAsn1(a.fromDer(n.util.createBuffer(e)));c(null,{privateKey:t,publicKey:s.setRsaPublicKey(t.n,t.e)})}});if(k(`generateKey`)&&k(`exportKey`)){var l=o.globalScope.msCrypto.subtle.generateKey({name:`RSASSA-PKCS1-v1_5`,modulusLength:e,publicExponent:j(t),hash:{name:`SHA-256`}},!0,[`sign`,`verify`]);l.oncomplete=function(e){var t=e.target.result,r=o.globalScope.msCrypto.subtle.exportKey(`pkcs8`,t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=s.privateKeyFromAsn1(a.fromDer(n.util.createBuffer(t)));c(null,{privateKey:r,publicKey:s.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){c(e)}},l.onerror=function(e){c(e)};return}}else if(E(`generateKeyPairSync`)){var u=i.generateKeyPairSync(`rsa`,{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:`spki`,format:`pem`},privateKeyEncoding:{type:`pkcs8`,format:`pem`}});return{privateKey:s.privateKeyFromPem(u.privateKey),publicKey:s.publicKeyFromPem(u.publicKey)}}}var d=s.rsa.createKeyPairGenerationState(e,t,r);if(!c)return s.rsa.stepKeyPairGenerationState(d,0),d.keys;S(d,r,c)},s.setRsaPublicKey=s.rsa.setPublicKey=function(e,t){var r={n:e,e:t};return r.encrypt=function(e,t,i){if(typeof t==`string`?t=t.toUpperCase():t===void 0&&(t=`RSAES-PKCS1-V1_5`),t===`RSAES-PKCS1-V1_5`)t={encode:function(e,t,n){return b(e,t,2).getBytes()}};else if(t===`RSA-OAEP`||t===`RSAES-OAEP`)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if([`RAW`,`NONE`,`NULL`,null].indexOf(t)!==-1)t={encode:function(e){return e}};else if(typeof t==`string`)throw Error(`Unsupported encryption scheme: "`+t+`".`);var a=t.encode(e,r,!0);return s.rsa.encrypt(a,r,!0)},r.verify=function(e,t,i,o){typeof i==`string`?i=i.toUpperCase():i===void 0&&(i=`RSASSA-PKCS1-V1_5`),o===void 0&&(o={_parseAllDigestBytes:!0}),`_parseAllDigestBytes`in o||(o._parseAllDigestBytes=!0),i===`RSASSA-PKCS1-V1_5`?i={verify:function(e,t){t=x(t,r,!0);var i=a.fromDer(t,{parseAllBytes:o._parseAllDigestBytes}),s={},c=[];if(!a.validate(i,h,s,c)){var l=Error(`ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.`);throw l.errors=c,l}var u=a.derToOid(s.algorithmIdentifier);if(!(u===n.oids.md2||u===n.oids.md5||u===n.oids.sha1||u===n.oids.sha224||u===n.oids.sha256||u===n.oids.sha384||u===n.oids.sha512||u===n.oids[`sha512-224`]||u===n.oids[`sha512-256`])){var l=Error(`Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.`);throw l.oid=u,l}if((u===n.oids.md2||u===n.oids.md5)&&!(`parameters`in s))throw Error(`ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.`);return e===s.digest}}:(i===`NONE`||i===`NULL`||i===null)&&(i={verify:function(e,t){return t=x(t,r,!0),e===t}});var c=s.rsa.decrypt(t,r,!0,!1);return i.verify(e,c,r.n.bitLength())},r},s.setRsaPrivateKey=s.rsa.setPrivateKey=function(e,t,r,i,a,o,c,l){var u={n:e,e:t,d:r,p:i,q:a,dP:o,dQ:c,qInv:l};return u.decrypt=function(e,t,r){typeof t==`string`?t=t.toUpperCase():t===void 0&&(t=`RSAES-PKCS1-V1_5`);var i=s.rsa.decrypt(e,u,!1,!1);if(t===`RSAES-PKCS1-V1_5`)t={decode:x};else if(t===`RSA-OAEP`||t===`RSAES-OAEP`)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else if([`RAW`,`NONE`,`NULL`,null].indexOf(t)!==-1)t={decode:function(e){return e}};else throw Error(`Unsupported encryption scheme: "`+t+`".`);return t.decode(i,u,!1)},u.sign=function(e,t){var n=!1;typeof t==`string`&&(t=t.toUpperCase()),t===void 0||t===`RSASSA-PKCS1-V1_5`?(t={encode:g},n=1):(t===`NONE`||t===`NULL`||t===null)&&(t={encode:function(){return e}},n=1);var r=t.encode(e,u.n.bitLength());return s.rsa.encrypt(r,u,n)},u},s.wrapRsaPrivateKey=function(e){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,a.integerToDer(0).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(s.oids.rsaEncryption).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,``)]),a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,a.toDer(e).getBytes())])},s.privateKeyFromAsn1=function(e){var t={},i=[];if(a.validate(e,l,t,i)&&(e=a.fromDer(n.util.createBuffer(t.privateKey))),t={},i=[],!a.validate(e,u,t,i)){var o=Error(`Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.`);throw o.errors=i,o}var c=n.util.createBuffer(t.privateKeyModulus).toHex(),d=n.util.createBuffer(t.privateKeyPublicExponent).toHex(),f=n.util.createBuffer(t.privateKeyPrivateExponent).toHex(),p=n.util.createBuffer(t.privateKeyPrime1).toHex(),m=n.util.createBuffer(t.privateKeyPrime2).toHex(),h=n.util.createBuffer(t.privateKeyExponent1).toHex(),g=n.util.createBuffer(t.privateKeyExponent2).toHex(),_=n.util.createBuffer(t.privateKeyCoefficient).toHex();return s.setRsaPrivateKey(new r(c,16),new r(d,16),new r(f,16),new r(p,16),new r(m,16),new r(h,16),new r(g,16),new r(_,16))},s.privateKeyToAsn1=s.privateKeyToRSAPrivateKey=function(e){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,a.integerToDer(0).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.n)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.e)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.d)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.p)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.q)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.dP)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.dQ)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.qInv))])},s.publicKeyFromAsn1=function(e){var t={},i=[];if(a.validate(e,m,t,i)){var o=a.derToOid(t.publicKeyOid);if(o!==s.oids.rsaEncryption){var c=Error(`Cannot read public key. Unknown OID.`);throw c.oid=o,c}e=t.rsaPublicKey}if(i=[],!a.validate(e,f,t,i)){var c=Error(`Cannot read public key. ASN.1 object does not contain an RSAPublicKey.`);throw c.errors=i,c}var l=n.util.createBuffer(t.publicKeyModulus).toHex(),u=n.util.createBuffer(t.publicKeyExponent).toHex();return s.setRsaPublicKey(new r(l,16),new r(u,16))},s.publicKeyToAsn1=s.publicKeyToSubjectPublicKeyInfo=function(e){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(s.oids.rsaEncryption).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,``)]),a.create(a.Class.UNIVERSAL,a.Type.BITSTRING,!1,[s.publicKeyToRSAPublicKey(e)])])},s.publicKeyToRSAPublicKey=function(e){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.n)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,C(e.e))])};function b(e,t,r){var i=n.util.createBuffer(),a=Math.ceil(t.n.bitLength()/8);if(e.length>a-11){var o=Error(`Message is too long for PKCS#1 v1.5 padding.`);throw o.length=e.length,o.max=a-11,o}i.putByte(0),i.putByte(r);var s=a-3-e.length,c;if(r===0||r===1){c=r===0?0:255;for(var l=0;l<s;++l)i.putByte(c)}else for(;s>0;){for(var u=0,d=n.random.getBytes(s),l=0;l<s;++l)c=d.charCodeAt(l),c===0?++u:i.putByte(c);s=u}return i.putByte(0),i.putBytes(e),i}function x(e,t,r,i){var a=Math.ceil(t.n.bitLength()/8),o=n.util.createBuffer(e),s=o.getByte(),c=o.getByte();if(s!==0||r&&c!==0&&c!==1||!r&&c!=2||r&&c===0&&i===void 0)throw Error(`Encryption block is invalid.`);var l=0;if(c===0){l=a-3-i;for(var u=0;u<l;++u)if(o.getByte()!==0)throw Error(`Encryption block is invalid.`)}else if(c===1)for(l=0;o.length()>1;){if(o.getByte()!==255){--o.read;break}++l}else if(c===2)for(l=0;o.length()>1;){if(o.getByte()===0){--o.read;break}++l}if(o.getByte()!==0||l!==a-3-o.length())throw Error(`Encryption block is invalid.`);return o.getBytes()}function S(e,t,i){typeof t==`function`&&(i=t,t={}),t||={};var a={algorithm:{name:t.algorithm||`PRIMEINC`,options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};`prng`in t&&(a.prng=t.prng),o();function o(){c(e.pBits,function(t,n){if(t)return i(t);if(e.p=n,e.q!==null)return l(t,e.q);c(e.qBits,l)})}function c(e,t){n.prime.generateProbablePrime(e,a,t)}function l(t,n){if(t)return i(t);if(e.q=n,e.p.compareTo(e.q)<0){var a=e.p;e.p=e.q,e.q=a}if(e.p.subtract(r.ONE).gcd(e.e).compareTo(r.ONE)!==0){e.p=null,o();return}if(e.q.subtract(r.ONE).gcd(e.e).compareTo(r.ONE)!==0){e.q=null,c(e.qBits,l);return}if(e.p1=e.p.subtract(r.ONE),e.q1=e.q.subtract(r.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(r.ONE)!==0){e.p=e.q=null,o();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,c(e.qBits,l);return}var u=e.e.modInverse(e.phi);e.keys={privateKey:s.rsa.setPrivateKey(e.n,e.e,u,e.p,e.q,u.mod(e.p1),u.mod(e.q1),e.q.modInverse(e.p)),publicKey:s.rsa.setPublicKey(e.n,e.e)},i(null,e.keys)}}function C(e){var t=e.toString(16);t[0]>=`8`&&(t=`00`+t);var r=n.util.hexToBytes(t);return r.length>1&&(r.charCodeAt(0)===0&&!(r.charCodeAt(1)&128)||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)==128)?r.substr(1):r}function T(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function E(e){return n.util.isNodejs&&typeof i[e]==`function`}function D(e){return o.globalScope!==void 0&&typeof o.globalScope.crypto==`object`&&typeof o.globalScope.crypto.subtle==`object`&&typeof o.globalScope.crypto.subtle[e]==`function`}function k(e){return o.globalScope!==void 0&&typeof o.globalScope.msCrypto==`object`&&typeof o.globalScope.msCrypto.subtle==`object`&&typeof o.globalScope.msCrypto.subtle[e]==`function`}function j(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i<t.length;++i)r[i]=t.charCodeAt(i);return r}})),ee=o(((e,t)=>{var n=d();if(g(),v(),C(),y(),_(),T(),S(),O(),k(),P(),p(),r===void 0)var r=n.jsbn.BigInteger;var i=n.asn1,a=n.pki=n.pki||{};t.exports=a.pbe=n.pbe=n.pbe||{};var o=a.oids,s={name:`EncryptedPrivateKeyInfo`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:`EncryptedPrivateKeyInfo.encryptionAlgorithm`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:`AlgorithmIdentifier.algorithm`,tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:`encryptionOid`},{name:`AlgorithmIdentifier.parameters`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:`encryptionParams`}]},{name:`EncryptedPrivateKeyInfo.encryptedData`,tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:`encryptedData`}]},c={name:`PBES2Algorithms`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:`PBES2Algorithms.keyDerivationFunc`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:`PBES2Algorithms.keyDerivationFunc.oid`,tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:`kdfOid`},{name:`PBES2Algorithms.params`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:`PBES2Algorithms.params.salt`,tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:`kdfSalt`},{name:`PBES2Algorithms.params.iterationCount`,tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:`kdfIterationCount`},{name:`PBES2Algorithms.params.keyLength`,tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,optional:!0,capture:`keyLength`},{name:`PBES2Algorithms.params.prf`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:`PBES2Algorithms.params.prf.algorithm`,tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:`prfOid`}]}]}]},{name:`PBES2Algorithms.encryptionScheme`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:`PBES2Algorithms.encryptionScheme.oid`,tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:`encOid`},{name:`PBES2Algorithms.encryptionScheme.iv`,tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:`encIv`}]}]},l={name:`pkcs-12PbeParams`,tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:`pkcs-12PbeParams.salt`,tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:`salt`},{name:`pkcs-12PbeParams.iterations`,tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:`iterations`}]};a.encryptPrivateKeyInfo=function(e,t,r){r||={},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||`aes128`,r.prfAlgorithm=r.prfAlgorithm||`sha1`;var s=n.random.getBytesSync(r.saltSize),c=r.count,l=i.integerToDer(c),u,d,f;if(r.algorithm.indexOf(`aes`)===0||r.algorithm===`des`){var p,g,_;switch(r.algorithm){case`aes128`:u=16,p=16,g=o[`aes128-CBC`],_=n.aes.createEncryptionCipher;break;case`aes192`:u=24,p=16,g=o[`aes192-CBC`],_=n.aes.createEncryptionCipher;break;case`aes256`:u=32,p=16,g=o[`aes256-CBC`],_=n.aes.createEncryptionCipher;break;case`des`:u=8,p=8,g=o.desCBC,_=n.des.createEncryptionCipher;break;default:var v=Error(`Cannot encrypt private key. Unknown encryption algorithm.`);throw v.algorithm=r.algorithm,v}var y=`hmacWith`+r.prfAlgorithm.toUpperCase(),b=m(y),x=n.pkcs5.pbkdf2(t,s,c,u,b),S=n.random.getBytesSync(p),C=_(x);C.start(S),C.update(i.toDer(e)),C.finish(),f=C.output.getBytes();var w=h(s,l,u,y);d=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o.pkcs5PBES2).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o.pkcs5PBKDF2).getBytes()),w]),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(g).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,S)])])])}else if(r.algorithm===`3des`){u=24;var T=new n.util.ByteBuffer(s),x=a.pbe.generatePkcs12Key(t,T,1,c,u),S=a.pbe.generatePkcs12Key(t,T,2,c,u),C=n.des.createEncryptionCipher(x);C.start(S),C.update(i.toDer(e)),C.finish(),f=C.output.getBytes(),d=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(o[`pbeWithSHAAnd3-KeyTripleDES-CBC`]).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,s),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,l.getBytes())])])}else{var v=Error(`Cannot encrypt private key. Unknown encryption algorithm.`);throw v.algorithm=r.algorithm,v}return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[d,i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,f)])},a.decryptPrivateKeyInfo=function(e,t){var r=null,o={},c=[];if(!i.validate(e,s,o,c)){var l=Error(`Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.`);throw l.errors=c,l}var u=i.derToOid(o.encryptionOid),d=a.pbe.getCipher(u,o.encryptionParams,t),f=n.util.createBuffer(o.encryptedData);return d.update(f),d.finish()&&(r=i.fromDer(d.output)),r},a.encryptedPrivateKeyToPem=function(e,t){var r={type:`ENCRYPTED PRIVATE KEY`,body:i.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})},a.encryptedPrivateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if(t.type!==`ENCRYPTED PRIVATE KEY`){var r=Error(`Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".`);throw r.headerType=t.type,r}if(t.procType&&t.procType.type===`ENCRYPTED`)throw Error(`Could not convert encrypted private key from PEM; PEM is encrypted.`);return i.fromDer(t.body)},a.encryptRsaPrivateKey=function(e,t,r){if(r||={},!r.legacy){var o=a.wrapRsaPrivateKey(a.privateKeyToAsn1(e));return o=a.encryptPrivateKeyInfo(o,t,r),a.encryptedPrivateKeyToPem(o)}var s,c,l,u;switch(r.algorithm){case`aes128`:s=`AES-128-CBC`,l=16,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case`aes192`:s=`AES-192-CBC`,l=24,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case`aes256`:s=`AES-256-CBC`,l=32,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case`3des`:s=`DES-EDE3-CBC`,l=24,c=n.random.getBytesSync(8),u=n.des.createEncryptionCipher;break;case`des`:s=`DES-CBC`,l=8,c=n.random.getBytesSync(8),u=n.des.createEncryptionCipher;break;default:var d=Error(`Could not encrypt RSA private key; unsupported encryption algorithm "`+r.algorithm+`".`);throw d.algorithm=r.algorithm,d}var f=n.pbe.opensslDeriveBytes(t,c.substr(0,8),l),p=u(f);p.start(c),p.update(i.toDer(a.privateKeyToAsn1(e))),p.finish();var m={type:`RSA PRIVATE KEY`,procType:{version:`4`,type:`ENCRYPTED`},dekInfo:{algorithm:s,parameters:n.util.bytesToHex(c).toUpperCase()},body:p.output.getBytes()};return n.pem.encode(m)},a.decryptRsaPrivateKey=function(e,t){var r=null,o=n.pem.decode(e)[0];if(o.type!==`ENCRYPTED PRIVATE KEY`&&o.type!==`PRIVATE KEY`&&o.type!==`RSA PRIVATE KEY`){var s=Error(`Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".`);throw s.headerType=s,s}if(o.procType&&o.procType.type===`ENCRYPTED`){var c,l;switch(o.dekInfo.algorithm){case`DES-CBC`:c=8,l=n.des.createDecryptionCipher;break;case`DES-EDE3-CBC`:c=24,l=n.des.createDecryptionCipher;break;case`AES-128-CBC`:c=16,l=n.aes.createDecryptionCipher;break;case`AES-192-CBC`:c=24,l=n.aes.createDecryptionCipher;break;case`AES-256-CBC`:c=32,l=n.aes.createDecryptionCipher;break;case`RC2-40-CBC`:c=5,l=function(e){return n.rc2.createDecryptionCipher(e,40)};break;case`RC2-64-CBC`:c=8,l=function(e){return n.rc2.createDecryptionCipher(e,64)};break;case`RC2-128-CBC`:c=16,l=function(e){return n.rc2.createDecryptionCipher(e,128)};break;default:var s=Error(`Could not decrypt private key; unsupported encryption algorithm "`+o.dekInfo.algorithm+`".`);throw s.algorithm=o.dekInfo.algorithm,s}var u=n.util.hexToBytes(o.dekInfo.parameters),d=n.pbe.opensslDeriveBytes(t,u.substr(0,8),c),f=l(d);if(f.start(u),f.update(n.util.createBuffer(o.body)),f.finish())r=f.output.getBytes();else return r}else r=o.body;return r=o.type===`ENCRYPTED PRIVATE KEY`?a.decryptPrivateKeyInfo(i.fromDer(r),t):i.fromDer(r),r!==null&&(r=a.privateKeyFromAsn1(r)),r},a.pbe.generatePkcs12Key=function(e,t,r,i,a,o){var s,c;if(o==null){if(!(`sha1`in n.md))throw Error(`"sha1" hash algorithm unavailable.`);o=n.md.sha1.create()}var l=o.digestLength,u=o.blockLength,d=new n.util.ByteBuffer,f=new n.util.ByteBuffer;if(e!=null){for(c=0;c<e.length;c++)f.putInt16(e.charCodeAt(c));f.putInt16(0)}var p=f.length(),m=t.length(),h=new n.util.ByteBuffer;h.fillWithByte(r,u);var g=u*Math.ceil(m/u),_=new n.util.ByteBuffer;for(c=0;c<g;c++)_.putByte(t.at(c%m));var v=u*Math.ceil(p/u),y=new n.util.ByteBuffer;for(c=0;c<v;c++)y.putByte(f.at(c%p));var b=_;b.putBuffer(y);for(var x=Math.ceil(a/l),S=1;S<=x;S++){var C=new n.util.ByteBuffer;C.putBytes(h.bytes()),C.putBytes(b.bytes());for(var w=0;w<i;w++)o.start(),o.update(C.getBytes()),C=o.digest();var T=new n.util.ByteBuffer;for(c=0;c<u;c++)T.putByte(C.at(c%l));var E=Math.ceil(m/u)+Math.ceil(p/u),D=new n.util.ByteBuffer;for(s=0;s<E;s++){var O=new n.util.ByteBuffer(b.getBytes(u)),k=511;for(c=T.length()-1;c>=0;c--)k>>=8,k+=T.at(c)+O.at(c),O.setAt(c,k&255);D.putBuffer(O)}b=D,d.putBuffer(C)}return d.truncate(d.length()-a),d},a.pbe.getCipher=function(e,t,n){switch(e){case a.oids.pkcs5PBES2:return a.pbe.getCipherForPBES2(e,t,n);case a.oids[`pbeWithSHAAnd3-KeyTripleDES-CBC`]:case a.oids[`pbewithSHAAnd40BitRC2-CBC`]:return a.pbe.getCipherForPKCS12PBE(e,t,n);default:var r=Error(`Cannot read encrypted PBE data block. Unsupported OID.`);throw r.oid=e,r.supportedOids=[`pkcs5PBES2`,`pbeWithSHAAnd3-KeyTripleDES-CBC`,`pbewithSHAAnd40BitRC2-CBC`],r}},a.pbe.getCipherForPBES2=function(e,t,r){var o={},s=[];if(!i.validate(t,c,o,s)){var l=Error(`Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.`);throw l.errors=s,l}if(e=i.derToOid(o.kdfOid),e!==a.oids.pkcs5PBKDF2){var l=Error(`Cannot read encrypted private key. Unsupported key derivation function OID.`);throw l.oid=e,l.supportedOids=[`pkcs5PBKDF2`],l}if(e=i.derToOid(o.encOid),e!==a.oids[`aes128-CBC`]&&e!==a.oids[`aes192-CBC`]&&e!==a.oids[`aes256-CBC`]&&e!==a.oids[`des-EDE3-CBC`]&&e!==a.oids.desCBC){var l=Error(`Cannot read encrypted private key. Unsupported encryption scheme OID.`);throw l.oid=e,l.supportedOids=[`aes128-CBC`,`aes192-CBC`,`aes256-CBC`,`des-EDE3-CBC`,`desCBC`],l}var u=o.kdfSalt,d=n.util.createBuffer(o.kdfIterationCount);d=d.getInt(d.length()<<3);var p,m;switch(a.oids[e]){case`aes128-CBC`:p=16,m=n.aes.createDecryptionCipher;break;case`aes192-CBC`:p=24,m=n.aes.createDecryptionCipher;break;case`aes256-CBC`:p=32,m=n.aes.createDecryptionCipher;break;case`des-EDE3-CBC`:p=24,m=n.des.createDecryptionCipher;break;case`desCBC`:p=8,m=n.des.createDecryptionCipher;break}var h=f(o.prfOid),g=n.pkcs5.pbkdf2(r,u,d,p,h),_=o.encIv,v=m(g);return v.start(_),v},a.pbe.getCipherForPKCS12PBE=function(e,t,r){var o={},s=[];if(!i.validate(t,l,o,s)){var c=Error(`Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.`);throw c.errors=s,c}var u=n.util.createBuffer(o.salt),d=n.util.createBuffer(o.iterations);d=d.getInt(d.length()<<3);var p,m,h;switch(e){case a.oids[`pbeWithSHAAnd3-KeyTripleDES-CBC`]:p=24,m=8,h=n.des.startDecrypting;break;case a.oids[`pbewithSHAAnd40BitRC2-CBC`]:p=5,m=8,h=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var c=Error(`Cannot read PKCS #12 PBE data block. Unsupported OID.`);throw c.oid=e,c}var g=f(o.prfOid),_=a.pbe.generatePkcs12Key(r,u,1,d,p,g);g.start();var v=a.pbe.generatePkcs12Key(r,u,2,d,m,g);return h(_,v)},a.pbe.opensslDeriveBytes=function(e,t,r,i){if(i==null){if(!(`md5`in n.md))throw Error(`"md5" hash algorithm unavailable.`);i=n.md.md5.create()}t===null&&(t=``);for(var a=[u(i,e+t)],o=16,s=1;o<r;++s,o+=16)a.push(u(i,a[s-1]+e+t));return a.join(``).substr(0,r)};function u(e,t){return e.start().update(t).digest().getBytes()}function f(e){var t;if(!e)t=`hmacWithSHA1`;else if(t=a.oids[i.derToOid(e)],!t){var n=Error(`Unsupported PRF OID.`);throw n.oid=e,n.supported=[`hmacWithSHA1`,`hmacWithSHA224`,`hmacWithSHA256`,`hmacWithSHA384`,`hmacWithSHA512`],n}return m(t)}function m(e){var t=n.md;switch(e){case`hmacWithSHA224`:t=n.md.sha512;case`hmacWithSHA1`:case`hmacWithSHA256`:case`hmacWithSHA384`:case`hmacWithSHA512`:e=e.substr(8).toLowerCase();break;default:var r=Error(`Unsupported PRF algorithm.`);throw r.algorithm=e,r.supported=[`hmacWithSHA1`,`hmacWithSHA224`,`hmacWithSHA256`,`hmacWithSHA384`,`hmacWithSHA512`],r}if(!t||!(e in t))throw Error(`Unknown hash algorithm: `+e);return t[e].create()}function h(e,t,r,o){var s=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,e),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,t.getBytes())]);return o!==`hmacWithSHA1`&&s.value.push(i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,n.util.hexToBytes(r.toString(16))),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(a.oids[o]).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,``)])),s}})),F=o(((e,t)=>{var n=d();v(),p();var r=n.asn1,i=t.exports=n.pkcs7asn1=n.pkcs7asn1||{};n.pkcs7=n.pkcs7||{},n.pkcs7.asn1=i;var a={name:`ContentInfo`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`ContentInfo.ContentType`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`contentType`},{name:`ContentInfo.content`,tagClass:r.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:`content`}]};i.contentInfoValidator=a;var o={name:`EncryptedContentInfo`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`EncryptedContentInfo.contentType`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`contentType`},{name:`EncryptedContentInfo.contentEncryptionAlgorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`EncryptedContentInfo.contentEncryptionAlgorithm.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`encAlgorithm`},{name:`EncryptedContentInfo.contentEncryptionAlgorithm.parameter`,tagClass:r.Class.UNIVERSAL,captureAsn1:`encParameter`}]},{name:`EncryptedContentInfo.encryptedContent`,tagClass:r.Class.CONTEXT_SPECIFIC,type:0,capture:`encryptedContent`,captureAsn1:`encryptedContentAsn1`}]};i.envelopedDataValidator={name:`EnvelopedData`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`EnvelopedData.Version`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`version`},{name:`EnvelopedData.RecipientInfos`,tagClass:r.Class.UNIVERSAL,type:r.Type.SET,constructed:!0,captureAsn1:`recipientInfos`}].concat(o)},i.encryptedDataValidator={name:`EncryptedData`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`EncryptedData.Version`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`version`}].concat(o)};var s={name:`SignerInfo`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`SignerInfo.version`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1},{name:`SignerInfo.issuerAndSerialNumber`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`SignerInfo.issuerAndSerialNumber.issuer`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:`issuer`},{name:`SignerInfo.issuerAndSerialNumber.serialNumber`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`serial`}]},{name:`SignerInfo.digestAlgorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`SignerInfo.digestAlgorithm.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`digestAlgorithm`},{name:`SignerInfo.digestAlgorithm.parameter`,tagClass:r.Class.UNIVERSAL,constructed:!1,captureAsn1:`digestParameter`,optional:!0}]},{name:`SignerInfo.authenticatedAttributes`,tagClass:r.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:`authenticatedAttributes`},{name:`SignerInfo.digestEncryptionAlgorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,capture:`signatureAlgorithm`},{name:`SignerInfo.encryptedDigest`,tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:`signature`},{name:`SignerInfo.unauthenticatedAttributes`,tagClass:r.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:`unauthenticatedAttributes`}]};i.signedDataValidator={name:`SignedData`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`SignedData.Version`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`version`},{name:`SignedData.DigestAlgorithms`,tagClass:r.Class.UNIVERSAL,type:r.Type.SET,constructed:!0,captureAsn1:`digestAlgorithms`},a,{name:`SignedData.Certificates`,tagClass:r.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:`certificates`},{name:`SignedData.CertificateRevocationLists`,tagClass:r.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:`crls`},{name:`SignedData.SignerInfos`,tagClass:r.Class.UNIVERSAL,type:r.Type.SET,capture:`signerInfos`,optional:!0,value:[s]}]},i.recipientInfoValidator={name:`RecipientInfo`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`RecipientInfo.version`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`version`},{name:`RecipientInfo.issuerAndSerial`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`RecipientInfo.issuerAndSerial.issuer`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:`issuer`},{name:`RecipientInfo.issuerAndSerial.serialNumber`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`serial`}]},{name:`RecipientInfo.keyEncryptionAlgorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`RecipientInfo.keyEncryptionAlgorithm.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`encAlgorithm`},{name:`RecipientInfo.keyEncryptionAlgorithm.parameter`,tagClass:r.Class.UNIVERSAL,constructed:!1,captureAsn1:`encParameter`,optional:!0}]},{name:`RecipientInfo.encryptedKey`,tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:`encKey`}]}})),I=o(((e,t)=>{var n=d();p(),n.mgf=n.mgf||{};var r=t.exports=n.mgf.mgf1=n.mgf1=n.mgf1||{};r.create=function(e){return{generate:function(t,r){for(var i=new n.util.ByteBuffer,a=Math.ceil(r/e.digestLength),o=0;o<a;o++){var s=new n.util.ByteBuffer;s.putInt32(o),e.start(),e.update(t+s.getBytes()),i.putBuffer(e.digest())}return i.truncate(i.length()-r),i.getBytes()}}}})),L=o(((e,t)=>{var n=d();I(),t.exports=n.mgf=n.mgf||{},n.mgf.mgf1=n.mgf1})),R=o(((e,t)=>{var n=d();O(),p();var r=t.exports=n.pss=n.pss||{};r.create=function(e){arguments.length===3&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t=e.md,r=e.mgf,i=t.digestLength,a=e.salt||null;typeof a==`string`&&(a=n.util.createBuffer(a));var o;if(`saltLength`in e)o=e.saltLength;else if(a!==null)o=a.length();else throw Error(`Salt length not specified or specific salt not given.`);if(a!==null&&a.length()!==o)throw Error(`Given salt length does not match length of given salt.`);var s=e.prng||n.random,c={};return c.encode=function(e,c){var l,u=c-1,d=Math.ceil(u/8),f=e.digest().getBytes();if(d<i+o+2)throw Error(`Message is too long to encrypt.`);var p=a===null?s.getBytesSync(o):a.bytes(),m=new n.util.ByteBuffer;m.fillWithByte(0,8),m.putBytes(f),m.putBytes(p),t.start(),t.update(m.getBytes());var h=t.digest().getBytes(),g=new n.util.ByteBuffer;g.fillWithByte(0,d-o-i-2),g.putByte(1),g.putBytes(p);var _=g.getBytes(),v=d-i-1,y=r.generate(h,v),b=``;for(l=0;l<v;l++)b+=String.fromCharCode(_.charCodeAt(l)^y.charCodeAt(l));var x=65280>>8*d-u&255;return b=String.fromCharCode(b.charCodeAt(0)&~x)+b.substr(1),b+h+`¼`},c.verify=function(e,a,s){var c,l=s-1,u=Math.ceil(l/8);if(a=a.substr(-u),u<i+o+2)throw Error(`Inconsistent parameters to PSS signature verification.`);if(a.charCodeAt(u-1)!==188)throw Error(`Encoded message does not end in 0xBC.`);var d=u-i-1,f=a.substr(0,d),p=a.substr(d,i),m=65280>>8*u-l&255;if((f.charCodeAt(0)&m)!==0)throw Error(`Bits beyond keysize not zero as expected.`);var h=r.generate(p,d),g=``;for(c=0;c<d;c++)g+=String.fromCharCode(f.charCodeAt(c)^h.charCodeAt(c));g=String.fromCharCode(g.charCodeAt(0)&~m)+g.substr(1);var _=u-i-o-2;for(c=0;c<_;c++)if(g.charCodeAt(c)!==0)throw Error(`Leftmost octets not zero as expected`);if(g.charCodeAt(_)!==1)throw Error(`Inconsistent PSS signature, 0x01 marker not found`);var v=g.substr(-o),y=new n.util.ByteBuffer;return y.fillWithByte(0,8),y.putBytes(e),y.putBytes(v),t.start(),t.update(y.getBytes()),p===t.digest().getBytes()},c}})),z=o(((e,t)=>{var n=d();g(),v(),C(),y(),L(),_(),S(),R(),P(),p();var r=n.asn1,i=t.exports=n.pki=n.pki||{},a=i.oids,o={};o.CN=a.commonName,o.commonName=`CN`,o.C=a.countryName,o.countryName=`C`,o.L=a.localityName,o.localityName=`L`,o.ST=a.stateOrProvinceName,o.stateOrProvinceName=`ST`,o.O=a.organizationName,o.organizationName=`O`,o.OU=a.organizationalUnitName,o.organizationalUnitName=`OU`,o.E=a.emailAddress,o.emailAddress=`E`;var s=n.pki.rsa.publicKeyValidator,c={name:`Certificate`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`Certificate.TBSCertificate`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:`tbsCertificate`,value:[{name:`Certificate.TBSCertificate.version`,tagClass:r.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:`Certificate.TBSCertificate.version.integer`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`certVersion`}]},{name:`Certificate.TBSCertificate.serialNumber`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`certSerialNumber`},{name:`Certificate.TBSCertificate.signature`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`Certificate.TBSCertificate.signature.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`certinfoSignatureOid`},{name:`Certificate.TBSCertificate.signature.parameters`,tagClass:r.Class.UNIVERSAL,optional:!0,captureAsn1:`certinfoSignatureParams`}]},{name:`Certificate.TBSCertificate.issuer`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:`certIssuer`},{name:`Certificate.TBSCertificate.validity`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`Certificate.TBSCertificate.validity.notBefore (utc)`,tagClass:r.Class.UNIVERSAL,type:r.Type.UTCTIME,constructed:!1,optional:!0,capture:`certValidity1UTCTime`},{name:`Certificate.TBSCertificate.validity.notBefore (generalized)`,tagClass:r.Class.UNIVERSAL,type:r.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:`certValidity2GeneralizedTime`},{name:`Certificate.TBSCertificate.validity.notAfter (utc)`,tagClass:r.Class.UNIVERSAL,type:r.Type.UTCTIME,constructed:!1,optional:!0,capture:`certValidity3UTCTime`},{name:`Certificate.TBSCertificate.validity.notAfter (generalized)`,tagClass:r.Class.UNIVERSAL,type:r.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:`certValidity4GeneralizedTime`}]},{name:`Certificate.TBSCertificate.subject`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:`certSubject`},s,{name:`Certificate.TBSCertificate.issuerUniqueID`,tagClass:r.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:`Certificate.TBSCertificate.issuerUniqueID.id`,tagClass:r.Class.UNIVERSAL,type:r.Type.BITSTRING,constructed:!1,captureBitStringValue:`certIssuerUniqueId`}]},{name:`Certificate.TBSCertificate.subjectUniqueID`,tagClass:r.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:`Certificate.TBSCertificate.subjectUniqueID.id`,tagClass:r.Class.UNIVERSAL,type:r.Type.BITSTRING,constructed:!1,captureBitStringValue:`certSubjectUniqueId`}]},{name:`Certificate.TBSCertificate.extensions`,tagClass:r.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:`certExtensions`,optional:!0}]},{name:`Certificate.signatureAlgorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`Certificate.signatureAlgorithm.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`certSignatureOid`},{name:`Certificate.TBSCertificate.signature.parameters`,tagClass:r.Class.UNIVERSAL,optional:!0,captureAsn1:`certSignatureParams`}]},{name:`Certificate.signatureValue`,tagClass:r.Class.UNIVERSAL,type:r.Type.BITSTRING,constructed:!1,captureBitStringValue:`certSignature`}]},l={name:`rsapss`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`rsapss.hashAlgorithm`,tagClass:r.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:`rsapss.hashAlgorithm.AlgorithmIdentifier`,tagClass:r.Class.UNIVERSAL,type:r.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:`rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`hashOid`}]}]},{name:`rsapss.maskGenAlgorithm`,tagClass:r.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:`rsapss.maskGenAlgorithm.AlgorithmIdentifier`,tagClass:r.Class.UNIVERSAL,type:r.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:`rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`maskGenOid`},{name:`rsapss.maskGenAlgorithm.AlgorithmIdentifier.params`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`maskGenHashOid`}]}]}]},{name:`rsapss.saltLength`,tagClass:r.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:`rsapss.saltLength.saltLength`,tagClass:r.Class.UNIVERSAL,type:r.Class.INTEGER,constructed:!1,capture:`saltLength`}]},{name:`rsapss.trailerField`,tagClass:r.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:`rsapss.trailer.trailer`,tagClass:r.Class.UNIVERSAL,type:r.Class.INTEGER,constructed:!1,capture:`trailer`}]}]},u={name:`CertificationRequestInfo`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:`certificationRequestInfo`,value:[{name:`CertificationRequestInfo.integer`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`certificationRequestInfoVersion`},{name:`CertificationRequestInfo.subject`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:`certificationRequestInfoSubject`},s,{name:`CertificationRequestInfo.attributes`,tagClass:r.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:`certificationRequestInfoAttributes`,value:[{name:`CertificationRequestInfo.attributes`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`CertificationRequestInfo.attributes.type`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1},{name:`CertificationRequestInfo.attributes.value`,tagClass:r.Class.UNIVERSAL,type:r.Type.SET,constructed:!0}]}]}]},f={name:`CertificationRequest`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:`csr`,value:[u,{name:`CertificationRequest.signatureAlgorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`CertificationRequest.signatureAlgorithm.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`csrSignatureOid`},{name:`CertificationRequest.signatureAlgorithm.parameters`,tagClass:r.Class.UNIVERSAL,optional:!0,captureAsn1:`csrSignatureParams`}]},{name:`CertificationRequest.signature`,tagClass:r.Class.UNIVERSAL,type:r.Type.BITSTRING,constructed:!1,captureBitStringValue:`csrSignature`}]};i.RDNAttributesAsArray=function(e,t){for(var n=[],i,s,c,l=0;l<e.value.length;++l){i=e.value[l];for(var u=0;u<i.value.length;++u)c={},s=i.value[u],c.type=r.derToOid(s.value[0].value),c.value=s.value[1].value,c.valueTagClass=s.value[1].type,c.type in a&&(c.name=a[c.type],c.name in o&&(c.shortName=o[c.name])),t&&(t.update(c.type),t.update(c.value)),n.push(c)}return n},i.CRIAttributesAsArray=function(e){for(var t=[],n=0;n<e.length;++n)for(var s=e[n],c=r.derToOid(s.value[0].value),l=s.value[1].value,u=0;u<l.length;++u){var d={};if(d.type=c,d.value=l[u].value,d.valueTagClass=l[u].type,d.type in a&&(d.name=a[d.type],d.name in o&&(d.shortName=o[d.name])),d.type===a.extensionRequest){d.extensions=[];for(var f=0;f<d.value.length;++f)d.extensions.push(i.certificateExtensionFromAsn1(d.value[f]))}t.push(d)}return t};function m(e,t){typeof t==`string`&&(t={shortName:t});for(var n=null,r,i=0;n===null&&i<e.attributes.length;++i)r=e.attributes[i],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(n=r);return n}var h=function(e,t,n){var i={};if(e!==a[`RSASSA-PSS`])return i;n&&(i={hash:{algorithmOid:a.sha1},mgf:{algorithmOid:a.mgf1,hash:{algorithmOid:a.sha1}},saltLength:20});var o={},s=[];if(!r.validate(t,l,o,s)){var c=Error(`Cannot read RSASSA-PSS parameter block.`);throw c.errors=s,c}return o.hashOid!==void 0&&(i.hash=i.hash||{},i.hash.algorithmOid=r.derToOid(o.hashOid)),o.maskGenOid!==void 0&&(i.mgf=i.mgf||{},i.mgf.algorithmOid=r.derToOid(o.maskGenOid),i.mgf.hash=i.mgf.hash||{},i.mgf.hash.algorithmOid=r.derToOid(o.maskGenHashOid)),o.saltLength!==void 0&&(i.saltLength=o.saltLength.charCodeAt(0)),i},b=function(e){switch(a[e.signatureOid]){case`sha1WithRSAEncryption`:case`sha1WithRSASignature`:return n.md.sha1.create();case`md5WithRSAEncryption`:return n.md.md5.create();case`sha256WithRSAEncryption`:return n.md.sha256.create();case`sha384WithRSAEncryption`:return n.md.sha384.create();case`sha512WithRSAEncryption`:return n.md.sha512.create();case`RSASSA-PSS`:return n.md.sha256.create();default:var t=Error(`Could not compute `+e.type+` digest. Unknown signature OID.`);throw t.signatureOid=e.signatureOid,t}},x=function(e){var t=e.certificate,r;switch(t.signatureOid){case a.sha1WithRSAEncryption:case a.sha1WithRSASignature:break;case a[`RSASSA-PSS`]:var i=a[t.signatureParameters.mgf.hash.algorithmOid],o;if(i===void 0||n.md[i]===void 0){var s=Error(`Unsupported MGF hash function.`);throw s.oid=t.signatureParameters.mgf.hash.algorithmOid,s.name=i,s}if(o=a[t.signatureParameters.mgf.algorithmOid],o===void 0||n.mgf[o]===void 0){var s=Error(`Unsupported MGF function.`);throw s.oid=t.signatureParameters.mgf.algorithmOid,s.name=o,s}if(o=n.mgf[o].create(n.md[i].create()),i=a[t.signatureParameters.hash.algorithmOid],i===void 0||n.md[i]===void 0){var s=Error(`Unsupported RSASSA-PSS hash function.`);throw s.oid=t.signatureParameters.hash.algorithmOid,s.name=i,s}r=n.pss.create(n.md[i].create(),o,t.signatureParameters.saltLength);break}return t.publicKey.verify(e.md.digest().getBytes(),e.signature,r)};i.certificateFromPem=function(e,t,a){var o=n.pem.decode(e)[0];if(o.type!==`CERTIFICATE`&&o.type!==`X509 CERTIFICATE`&&o.type!==`TRUSTED CERTIFICATE`){var s=Error(`Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".`);throw s.headerType=o.type,s}if(o.procType&&o.procType.type===`ENCRYPTED`)throw Error(`Could not convert certificate from PEM; PEM is encrypted.`);var c=r.fromDer(o.body,a);return i.certificateFromAsn1(c,t)},i.certificateToPem=function(e,t){var a={type:`CERTIFICATE`,body:r.toDer(i.certificateToAsn1(e)).getBytes()};return n.pem.encode(a,{maxline:t})},i.publicKeyFromPem=function(e){var t=n.pem.decode(e)[0];if(t.type!==`PUBLIC KEY`&&t.type!==`RSA PUBLIC KEY`){var a=Error(`Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".`);throw a.headerType=t.type,a}if(t.procType&&t.procType.type===`ENCRYPTED`)throw Error(`Could not convert public key from PEM; PEM is encrypted.`);var o=r.fromDer(t.body);return i.publicKeyFromAsn1(o)},i.publicKeyToPem=function(e,t){var a={type:`PUBLIC KEY`,body:r.toDer(i.publicKeyToAsn1(e)).getBytes()};return n.pem.encode(a,{maxline:t})},i.publicKeyToRSAPublicKeyPem=function(e,t){var a={type:`RSA PUBLIC KEY`,body:r.toDer(i.publicKeyToRSAPublicKey(e)).getBytes()};return n.pem.encode(a,{maxline:t})},i.getPublicKeyFingerprint=function(e,t){t||={};var a=t.md||n.md.sha1.create(),o=t.type||`RSAPublicKey`,s;switch(o){case`RSAPublicKey`:s=r.toDer(i.publicKeyToRSAPublicKey(e)).getBytes();break;case`SubjectPublicKeyInfo`:s=r.toDer(i.publicKeyToAsn1(e)).getBytes();break;default:throw Error(`Unknown fingerprint type "`+t.type+`".`)}a.start(),a.update(s);var c=a.digest();if(t.encoding===`hex`){var l=c.toHex();return t.delimiter?l.match(/.{2}/g).join(t.delimiter):l}else if(t.encoding===`binary`)return c.getBytes();else if(t.encoding)throw Error(`Unknown encoding "`+t.encoding+`".`);return c},i.certificationRequestFromPem=function(e,t,a){var o=n.pem.decode(e)[0];if(o.type!==`CERTIFICATE REQUEST`){var s=Error(`Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".`);throw s.headerType=o.type,s}if(o.procType&&o.procType.type===`ENCRYPTED`)throw Error(`Could not convert certification request from PEM; PEM is encrypted.`);var c=r.fromDer(o.body,a);return i.certificationRequestFromAsn1(c,t)},i.certificationRequestToPem=function(e,t){var a={type:`CERTIFICATE REQUEST`,body:r.toDer(i.certificationRequestToAsn1(e)).getBytes()};return n.pem.encode(a,{maxline:t})},i.createCertificate=function(){var e={};return e.version=2,e.serialNumber=`00`,e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return m(e.issuer,t)},e.issuer.addField=function(t){T([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return m(e.subject,t)},e.subject.addField=function(t){T([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,n){T(t),e.subject.attributes=t,delete e.subject.uniqueId,n&&(e.subject.uniqueId=n),e.subject.hash=null},e.setIssuer=function(t,n){T(t),e.issuer.attributes=t,delete e.issuer.uniqueId,n&&(e.issuer.uniqueId=n),e.issuer.hash=null},e.setExtensions=function(t){for(var n=0;n<t.length;++n)E(t[n],{cert:e});e.extensions=t},e.getExtension=function(t){typeof t==`string`&&(t={name:t});for(var n=null,r,i=0;n===null&&i<e.extensions.length;++i)r=e.extensions[i],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(n=r);return n},e.sign=function(t,o){e.md=o||n.md.sha1.create();var s=a[e.md.algorithm+`WithRSAEncryption`];if(!s){var c=Error(`Could not compute certificate digest. Unknown message digest algorithm OID.`);throw c.algorithm=e.md.algorithm,c}e.signatureOid=e.siginfo.algorithmOid=s,e.tbsCertificate=i.getTBSCertificate(e);var l=r.toDer(e.tbsCertificate);e.md.update(l.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var n=!1;if(!e.issued(t)){var a=t.issuer,o=e.subject,s=Error(`The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.`);throw s.expectedIssuer=o.attributes,s.actualIssuer=a.attributes,s}var c=t.md;if(c===null){c=b({signatureOid:t.signatureOid,type:`certificate`});var l=t.tbsCertificate||i.getTBSCertificate(t),u=r.toDer(l);c.update(u.getBytes())}return c!==null&&(n=x({certificate:e,md:c,signature:t.signature})),n},e.isIssuer=function(t){var n=!1,r=e.issuer,i=t.subject;if(r.hash&&i.hash)n=r.hash===i.hash;else if(r.attributes.length===i.attributes.length){n=!0;for(var a,o,s=0;n&&s<r.attributes.length;++s)a=r.attributes[s],o=i.attributes[s],(a.type!==o.type||a.value!==o.value)&&(n=!1)}return n},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return i.getPublicKeyFingerprint(e.publicKey,{type:`RSAPublicKey`})},e.verifySubjectKeyIdentifier=function(){for(var t=a.subjectKeyIdentifier,r=0;r<e.extensions.length;++r){var i=e.extensions[r];if(i.id===t){var o=e.generateSubjectKeyIdentifier().getBytes();return n.util.hexToBytes(i.subjectKeyIdentifier)===o}}return!1},e},i.certificateFromAsn1=function(e,t){var a={},o=[];if(!r.validate(e,c,a,o)){var s=Error(`Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.`);throw s.errors=o,s}if(r.derToOid(a.publicKeyOid)!==i.oids.rsaEncryption)throw Error(`Cannot read public key. OID is not RSA.`);var l=i.createCertificate();l.version=a.certVersion?a.certVersion.charCodeAt(0):0,l.serialNumber=n.util.createBuffer(a.certSerialNumber).toHex(),l.signatureOid=n.asn1.derToOid(a.certSignatureOid),l.signatureParameters=h(l.signatureOid,a.certSignatureParams,!0),l.siginfo.algorithmOid=n.asn1.derToOid(a.certinfoSignatureOid),l.siginfo.parameters=h(l.siginfo.algorithmOid,a.certinfoSignatureParams,!1),l.signature=a.certSignature;var u=[];if(a.certValidity1UTCTime!==void 0&&u.push(r.utcTimeToDate(a.certValidity1UTCTime)),a.certValidity2GeneralizedTime!==void 0&&u.push(r.generalizedTimeToDate(a.certValidity2GeneralizedTime)),a.certValidity3UTCTime!==void 0&&u.push(r.utcTimeToDate(a.certValidity3UTCTime)),a.certValidity4GeneralizedTime!==void 0&&u.push(r.generalizedTimeToDate(a.certValidity4GeneralizedTime)),u.length>2)throw Error(`Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.`);if(u.length<2)throw Error(`Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.`);if(l.validity.notBefore=u[0],l.validity.notAfter=u[1],l.tbsCertificate=a.tbsCertificate,t){l.md=b({signatureOid:l.signatureOid,type:`certificate`});var d=r.toDer(l.tbsCertificate);l.md.update(d.getBytes())}var f=n.md.sha1.create(),p=r.toDer(a.certIssuer);f.update(p.getBytes()),l.issuer.getField=function(e){return m(l.issuer,e)},l.issuer.addField=function(e){T([e]),l.issuer.attributes.push(e)},l.issuer.attributes=i.RDNAttributesAsArray(a.certIssuer),a.certIssuerUniqueId&&(l.issuer.uniqueId=a.certIssuerUniqueId),l.issuer.hash=f.digest().toHex();var g=n.md.sha1.create(),_=r.toDer(a.certSubject);return g.update(_.getBytes()),l.subject.getField=function(e){return m(l.subject,e)},l.subject.addField=function(e){T([e]),l.subject.attributes.push(e)},l.subject.attributes=i.RDNAttributesAsArray(a.certSubject),a.certSubjectUniqueId&&(l.subject.uniqueId=a.certSubjectUniqueId),l.subject.hash=g.digest().toHex(),a.certExtensions?l.extensions=i.certificateExtensionsFromAsn1(a.certExtensions):l.extensions=[],l.publicKey=i.publicKeyFromAsn1(a.subjectPublicKeyInfo),l},i.certificateExtensionsFromAsn1=function(e){for(var t=[],n=0;n<e.value.length;++n)for(var r=e.value[n],a=0;a<r.value.length;++a)t.push(i.certificateExtensionFromAsn1(r.value[a]));return t},i.certificateExtensionFromAsn1=function(e){var t={};if(t.id=r.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===r.Type.BOOLEAN?(t.critical=e.value[1].value.charCodeAt(0)!==0,t.value=e.value[2].value):t.value=e.value[1].value,t.id in a){if(t.name=a[t.id],t.name===`keyUsage`){var i=r.fromDer(t.value),o=0,s=0;i.value.length>1&&(o=i.value.charCodeAt(1),s=i.value.length>2?i.value.charCodeAt(2):0),t.digitalSignature=(o&128)==128,t.nonRepudiation=(o&64)==64,t.keyEncipherment=(o&32)==32,t.dataEncipherment=(o&16)==16,t.keyAgreement=(o&8)==8,t.keyCertSign=(o&4)==4,t.cRLSign=(o&2)==2,t.encipherOnly=(o&1)==1,t.decipherOnly=(s&128)==128}else if(t.name===`basicConstraints`){var i=r.fromDer(t.value);i.value.length>0&&i.value[0].type===r.Type.BOOLEAN?t.cA=i.value[0].value.charCodeAt(0)!==0:t.cA=!1;var c=null;i.value.length>0&&i.value[0].type===r.Type.INTEGER?c=i.value[0].value:i.value.length>1&&(c=i.value[1].value),c!==null&&(t.pathLenConstraint=r.derToInteger(c))}else if(t.name===`extKeyUsage`)for(var i=r.fromDer(t.value),l=0;l<i.value.length;++l){var u=r.derToOid(i.value[l].value);u in a?t[a[u]]=!0:t[u]=!0}else if(t.name===`nsCertType`){var i=r.fromDer(t.value),o=0;i.value.length>1&&(o=i.value.charCodeAt(1)),t.client=(o&128)==128,t.server=(o&64)==64,t.email=(o&32)==32,t.objsign=(o&16)==16,t.reserved=(o&8)==8,t.sslCA=(o&4)==4,t.emailCA=(o&2)==2,t.objCA=(o&1)==1}else if(t.name===`subjectAltName`||t.name===`issuerAltName`){t.altNames=[];for(var d,i=r.fromDer(t.value),f=0;f<i.value.length;++f){d=i.value[f];var p={type:d.type,value:d.value};switch(t.altNames.push(p),d.type){case 1:case 2:case 6:break;case 7:p.ip=n.util.bytesToIP(d.value);break;case 8:p.oid=r.derToOid(d.value);break;default:}}}else if(t.name===`subjectKeyIdentifier`){var i=r.fromDer(t.value);t.subjectKeyIdentifier=n.util.bytesToHex(i.value)}}return t},i.certificationRequestFromAsn1=function(e,t){var a={},o=[];if(!r.validate(e,f,a,o)){var s=Error(`Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.`);throw s.errors=o,s}if(r.derToOid(a.publicKeyOid)!==i.oids.rsaEncryption)throw Error(`Cannot read public key. OID is not RSA.`);var c=i.createCertificationRequest();if(c.version=a.csrVersion?a.csrVersion.charCodeAt(0):0,c.signatureOid=n.asn1.derToOid(a.csrSignatureOid),c.signatureParameters=h(c.signatureOid,a.csrSignatureParams,!0),c.siginfo.algorithmOid=n.asn1.derToOid(a.csrSignatureOid),c.siginfo.parameters=h(c.siginfo.algorithmOid,a.csrSignatureParams,!1),c.signature=a.csrSignature,c.certificationRequestInfo=a.certificationRequestInfo,t){c.md=b({signatureOid:c.signatureOid,type:`certification request`});var l=r.toDer(c.certificationRequestInfo);c.md.update(l.getBytes())}var u=n.md.sha1.create();return c.subject.getField=function(e){return m(c.subject,e)},c.subject.addField=function(e){T([e]),c.subject.attributes.push(e)},c.subject.attributes=i.RDNAttributesAsArray(a.certificationRequestInfoSubject,u),c.subject.hash=u.digest().toHex(),c.publicKey=i.publicKeyFromAsn1(a.subjectPublicKeyInfo),c.getAttribute=function(e){return m(c,e)},c.addAttribute=function(e){T([e]),c.attributes.push(e)},c.attributes=i.CRIAttributesAsArray(a.certificationRequestInfoAttributes||[]),c},i.createCertificationRequest=function(){var e={};return e.version=0,e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return m(e.subject,t)},e.subject.addField=function(t){T([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return m(e,t)},e.addAttribute=function(t){T([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){T(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){T(t),e.attributes=t},e.sign=function(t,o){e.md=o||n.md.sha1.create();var s=a[e.md.algorithm+`WithRSAEncryption`];if(!s){var c=Error(`Could not compute certification request digest. Unknown message digest algorithm OID.`);throw c.algorithm=e.md.algorithm,c}e.signatureOid=e.siginfo.algorithmOid=s,e.certificationRequestInfo=i.getCertificationRequestInfo(e);var l=r.toDer(e.certificationRequestInfo);e.md.update(l.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,n=e.md;if(n===null){n=b({signatureOid:e.signatureOid,type:`certification request`});var a=e.certificationRequestInfo||i.getCertificationRequestInfo(e),o=r.toDer(a);n.update(o.getBytes())}return n!==null&&(t=x({certificate:e,md:n,signature:e.signature})),t},e};function w(e){for(var t=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]),i,a,o=e.attributes,s=0;s<o.length;++s){i=o[s];var c=i.value,l=r.Type.PRINTABLESTRING;`valueTagClass`in i&&(l=i.valueTagClass,l===r.Type.UTF8&&(c=n.util.encodeUtf8(c))),a=r.create(r.Class.UNIVERSAL,r.Type.SET,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.type).getBytes()),r.create(r.Class.UNIVERSAL,l,!1,c)])]),t.value.push(a)}return t}function T(e){for(var t,n=0;n<e.length;++n){if(t=e[n],t.name===void 0&&(t.type&&t.type in i.oids?t.name=i.oids[t.type]:t.shortName&&t.shortName in o&&(t.name=i.oids[o[t.shortName]])),t.type===void 0)if(t.name&&t.name in i.oids)t.type=i.oids[t.name];else{var s=Error(`Attribute type not specified.`);throw s.attribute=t,s}if(t.shortName===void 0&&t.name&&t.name in o&&(t.shortName=o[t.name]),t.type===a.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=r.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var c=0;c<t.extensions.length;++c)t.value.push(i.certificateExtensionToAsn1(E(t.extensions[c])))}if(t.value===void 0){var s=Error(`Attribute value not specified.`);throw s.attribute=t,s}}}function E(e,t){if(t||={},e.name===void 0&&e.id&&e.id in i.oids&&(e.name=i.oids[e.id]),e.id===void 0)if(e.name&&e.name in i.oids)e.id=i.oids[e.name];else{var o=Error(`Extension ID not specified.`);throw o.extension=e,o}if(e.value!==void 0)return e;if(e.name===`keyUsage`){var s=0,c=0,l=0;e.digitalSignature&&(c|=128,s=7),e.nonRepudiation&&(c|=64,s=6),e.keyEncipherment&&(c|=32,s=5),e.dataEncipherment&&(c|=16,s=4),e.keyAgreement&&(c|=8,s=3),e.keyCertSign&&(c|=4,s=2),e.cRLSign&&(c|=2,s=1),e.encipherOnly&&(c|=1,s=0),e.decipherOnly&&(l|=128,s=7);var u=String.fromCharCode(s);l===0?c!==0&&(u+=String.fromCharCode(c)):u+=String.fromCharCode(c)+String.fromCharCode(l),e.value=r.create(r.Class.UNIVERSAL,r.Type.BITSTRING,!1,u)}else if(e.name===`basicConstraints`)e.value=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(r.create(r.Class.UNIVERSAL,r.Type.BOOLEAN,!1,`ÿ`)),`pathLenConstraint`in e&&e.value.value.push(r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(e.pathLenConstraint).getBytes()));else if(e.name===`extKeyUsage`){e.value=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);var d=e.value.value;for(var f in e)e[f]===!0&&(f in a?d.push(r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(a[f]).getBytes())):f.indexOf(`.`)!==-1&&d.push(r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(f).getBytes())))}else if(e.name===`nsCertType`){var s=0,c=0;e.client&&(c|=128,s=7),e.server&&(c|=64,s=6),e.email&&(c|=32,s=5),e.objsign&&(c|=16,s=4),e.reserved&&(c|=8,s=3),e.sslCA&&(c|=4,s=2),e.emailCA&&(c|=2,s=1),e.objCA&&(c|=1,s=0);var u=String.fromCharCode(s);c!==0&&(u+=String.fromCharCode(c)),e.value=r.create(r.Class.UNIVERSAL,r.Type.BITSTRING,!1,u)}else if(e.name===`subjectAltName`||e.name===`issuerAltName`){e.value=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);for(var p,m=0;m<e.altNames.length;++m){p=e.altNames[m];var u=p.value;if(p.type===7&&p.ip){if(u=n.util.bytesFromIP(p.ip),u===null){var o=Error(`Extension "ip" value is not a valid IPv4 or IPv6 address.`);throw o.extension=e,o}}else p.type===8&&(u=p.oid?r.oidToDer(r.oidToDer(p.oid)):r.oidToDer(u));e.value.value.push(r.create(r.Class.CONTEXT_SPECIFIC,p.type,!1,u))}}else if(e.name===`nsComment`&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw Error(`Invalid "nsComment" content.`);e.value=r.create(r.Class.UNIVERSAL,r.Type.IA5STRING,!1,e.comment)}else if(e.name===`subjectKeyIdentifier`&&t.cert){var h=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=h.toHex(),e.value=r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,h.getBytes())}else if(e.name===`authorityKeyIdentifier`&&t.cert){e.value=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);var d=e.value.value;if(e.keyIdentifier){var g=e.keyIdentifier===!0?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;d.push(r.create(r.Class.CONTEXT_SPECIFIC,0,!1,g))}if(e.authorityCertIssuer){var _=[r.create(r.Class.CONTEXT_SPECIFIC,4,!0,[w(e.authorityCertIssuer===!0?t.cert.issuer:e.authorityCertIssuer)])];d.push(r.create(r.Class.CONTEXT_SPECIFIC,1,!0,_))}if(e.serialNumber){var v=n.util.hexToBytes(e.serialNumber===!0?t.cert.serialNumber:e.serialNumber);d.push(r.create(r.Class.CONTEXT_SPECIFIC,2,!1,v))}}else if(e.name===`cRLDistributionPoints`){e.value=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);for(var d=e.value.value,y=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]),b=r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[]),p,m=0;m<e.altNames.length;++m){p=e.altNames[m];var u=p.value;if(p.type===7&&p.ip){if(u=n.util.bytesFromIP(p.ip),u===null){var o=Error(`Extension "ip" value is not a valid IPv4 or IPv6 address.`);throw o.extension=e,o}}else p.type===8&&(u=p.oid?r.oidToDer(r.oidToDer(p.oid)):r.oidToDer(u));b.value.push(r.create(r.Class.CONTEXT_SPECIFIC,p.type,!1,u))}y.value.push(r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[b])),d.push(y)}if(e.value===void 0){var o=Error(`Extension value not specified.`);throw o.extension=e,o}return e}function D(e,t){switch(e){case a[`RSASSA-PSS`]:var n=[];return t.hash.algorithmOid!==void 0&&n.push(r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(t.hash.algorithmOid).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,``)])])),t.mgf.algorithmOid!==void 0&&n.push(r.create(r.Class.CONTEXT_SPECIFIC,1,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(t.mgf.algorithmOid).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(t.mgf.hash.algorithmOid).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,``)])])])),t.saltLength!==void 0&&n.push(r.create(r.Class.CONTEXT_SPECIFIC,2,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(t.saltLength).getBytes())])),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,n);default:return r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,``)}}function O(e){var t=r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[]);if(e.attributes.length===0)return t;for(var i=e.attributes,a=0;a<i.length;++a){var o=i[a],s=o.value,c=r.Type.UTF8;`valueTagClass`in o&&(c=o.valueTagClass),c===r.Type.UTF8&&(s=n.util.encodeUtf8(s));var l=!1;`valueConstructed`in o&&(l=o.valueConstructed);var u=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(o.type).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SET,!0,[r.create(r.Class.UNIVERSAL,c,l,s)])]);t.value.push(u)}return t}var k=new Date(`1950-01-01T00:00:00Z`),A=new Date(`2050-01-01T00:00:00Z`);function j(e){return e>=k&&e<A?r.create(r.Class.UNIVERSAL,r.Type.UTCTIME,!1,r.dateToUtcTime(e)):r.create(r.Class.UNIVERSAL,r.Type.GENERALIZEDTIME,!1,r.dateToGeneralizedTime(e))}i.getTBSCertificate=function(e){var t=j(e.validity.notBefore),a=j(e.validity.notAfter),o=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(e.version).getBytes())]),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,n.util.hexToBytes(e.serialNumber)),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.siginfo.algorithmOid).getBytes()),D(e.siginfo.algorithmOid,e.siginfo.parameters)]),w(e.issuer),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[t,a]),w(e.subject),i.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&o.value.push(r.create(r.Class.CONTEXT_SPECIFIC,1,!0,[r.create(r.Class.UNIVERSAL,r.Type.BITSTRING,!1,`\0`+e.issuer.uniqueId)])),e.subject.uniqueId&&o.value.push(r.create(r.Class.CONTEXT_SPECIFIC,2,!0,[r.create(r.Class.UNIVERSAL,r.Type.BITSTRING,!1,`\0`+e.subject.uniqueId)])),e.extensions.length>0&&o.value.push(i.certificateExtensionsToAsn1(e.extensions)),o},i.getCertificationRequestInfo=function(e){return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(e.version).getBytes()),w(e.subject),i.publicKeyToAsn1(e.publicKey),O(e)])},i.distinguishedNameToAsn1=function(e){return w(e)},i.certificateToAsn1=function(e){var t=e.tbsCertificate||i.getTBSCertificate(e);return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[t,r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.signatureOid).getBytes()),D(e.signatureOid,e.signatureParameters)]),r.create(r.Class.UNIVERSAL,r.Type.BITSTRING,!1,`\0`+e.signature)])},i.certificateExtensionsToAsn1=function(e){var t=r.create(r.Class.CONTEXT_SPECIFIC,3,!0,[]),n=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);t.value.push(n);for(var a=0;a<e.length;++a)n.value.push(i.certificateExtensionToAsn1(e[a]));return t},i.certificateExtensionToAsn1=function(e){var t=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);t.value.push(r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.id).getBytes())),e.critical&&t.value.push(r.create(r.Class.UNIVERSAL,r.Type.BOOLEAN,!1,`ÿ`));var n=e.value;return typeof e.value!=`string`&&(n=r.toDer(n).getBytes()),t.value.push(r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,n)),t},i.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||i.getCertificationRequestInfo(e);return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[t,r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.signatureOid).getBytes()),D(e.signatureOid,e.signatureParameters)]),r.create(r.Class.UNIVERSAL,r.Type.BITSTRING,!1,`\0`+e.signature)])},i.createCaStore=function(e){var t={certs:{}};t.getIssuer=function(e){return a(e.issuer)},t.addCertificate=function(e){if(typeof e==`string`&&(e=n.pki.certificateFromPem(e)),o(e.subject),!t.hasCertificate(e))if(e.subject.hash in t.certs){var r=t.certs[e.subject.hash];n.util.isArray(r)||(r=[r]),r.push(e),t.certs[e.subject.hash]=r}else t.certs[e.subject.hash]=e},t.hasCertificate=function(e){typeof e==`string`&&(e=n.pki.certificateFromPem(e));var t=a(e.subject);if(!t)return!1;n.util.isArray(t)||(t=[t]);for(var o=r.toDer(i.certificateToAsn1(e)).getBytes(),s=0;s<t.length;++s)if(o===r.toDer(i.certificateToAsn1(t[s])).getBytes())return!0;return!1},t.listAllCertificates=function(){var e=[];for(var r in t.certs)if(t.certs.hasOwnProperty(r)){var i=t.certs[r];if(!n.util.isArray(i))e.push(i);else for(var a=0;a<i.length;++a)e.push(i[a])}return e},t.removeCertificate=function(e){var s;if(typeof e==`string`&&(e=n.pki.certificateFromPem(e)),o(e.subject),!t.hasCertificate(e))return null;var c=a(e.subject);if(!n.util.isArray(c))return s=t.certs[e.subject.hash],delete t.certs[e.subject.hash],s;for(var l=r.toDer(i.certificateToAsn1(e)).getBytes(),u=0;u<c.length;++u)l===r.toDer(i.certificateToAsn1(c[u])).getBytes()&&(s=c[u],c.splice(u,1));return c.length===0&&delete t.certs[e.subject.hash],s};function a(e){return o(e),t.certs[e.hash]||null}function o(e){if(!e.hash){var t=n.md.sha1.create();e.attributes=i.RDNAttributesAsArray(w(e),t),e.hash=t.digest().toHex()}}if(e)for(var s=0;s<e.length;++s){var c=e[s];t.addCertificate(c)}return t},i.certificateError={bad_certificate:`forge.pki.BadCertificate`,unsupported_certificate:`forge.pki.UnsupportedCertificate`,certificate_revoked:`forge.pki.CertificateRevoked`,certificate_expired:`forge.pki.CertificateExpired`,certificate_unknown:`forge.pki.CertificateUnknown`,unknown_ca:`forge.pki.UnknownCertificateAuthority`},i.verifyCertificateChain=function(e,t,r){typeof r==`function`&&(r={verify:r}),r||={},t=t.slice(0);var a=t.slice(0),o=r.validityCheckDate;o===void 0&&(o=new Date);var s=!0,c=null,l=0;do{var u=t.shift(),d=null,f=!1;if(o&&(o<u.validity.notBefore||o>u.validity.notAfter)&&(c={message:`Certificate is not valid yet or has expired.`,error:i.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:o}),c===null){if(d=t[0]||e.getIssuer(u),d===null&&u.isIssuer(u)&&(f=!0,d=u),d){var p=d;n.util.isArray(p)||(p=[p]);for(var m=!1;!m&&p.length>0;){d=p.shift();try{m=d.verify(u)}catch{}}m||(c={message:`Certificate signature is invalid.`,error:i.certificateError.bad_certificate})}c===null&&(!d||f)&&!e.hasCertificate(u)&&(c={message:`Certificate is not trusted.`,error:i.certificateError.unknown_ca})}if(c===null&&d&&!u.isIssuer(d)&&(c={message:`Certificate issuer is invalid.`,error:i.certificateError.bad_certificate}),c===null)for(var h={keyUsage:!0,basicConstraints:!0},g=0;c===null&&g<u.extensions.length;++g){var _=u.extensions[g];_.critical&&!(_.name in h)&&(c={message:`Certificate has an unsupported critical extension.`,error:i.certificateError.unsupported_certificate})}if(c===null&&(!s||t.length===0&&(!d||f))){var v=u.getExtension(`basicConstraints`),y=u.getExtension(`keyUsage`);y!==null&&(!y.keyCertSign||v===null)&&(c={message:`Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.`,error:i.certificateError.bad_certificate}),c===null&&v!==null&&!v.cA&&(c={message:`Certificate basicConstraints indicates the certificate is not a CA.`,error:i.certificateError.bad_certificate}),c===null&&y!==null&&`pathLenConstraint`in v&&l-1>v.pathLenConstraint&&(c={message:`Certificate basicConstraints pathLenConstraint violated.`,error:i.certificateError.bad_certificate})}var b=c===null?!0:c.error,x=r.verify?r.verify(b,l,a):b;if(x===!0)c=null;else throw b===!0&&(c={message:`The application rejected the certificate.`,error:i.certificateError.bad_certificate}),(x||x===0)&&(typeof x==`object`&&!n.util.isArray(x)?(x.message&&(c.message=x.message),x.error&&(c.error=x.error)):typeof x==`string`&&(c.error=x)),c;s=!1,++l}while(t.length>0);return!0}})),B=o(((e,t)=>{var n=d();v(),b(),_(),F(),ee(),O(),P(),j(),p(),z();var r=n.asn1,i=n.pki,a=t.exports=n.pkcs12=n.pkcs12||{},o={name:`ContentInfo`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`ContentInfo.contentType`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`contentType`},{name:`ContentInfo.content`,tagClass:r.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:`content`}]},s={name:`PFX`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`PFX.version`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:`version`},o,{name:`PFX.macData`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:`mac`,value:[{name:`PFX.macData.mac`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`PFX.macData.mac.digestAlgorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`PFX.macData.mac.digestAlgorithm.algorithm`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`macAlgorithm`},{name:`PFX.macData.mac.digestAlgorithm.parameters`,optional:!0,tagClass:r.Class.UNIVERSAL,captureAsn1:`macAlgorithmParameters`}]},{name:`PFX.macData.mac.digest`,tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:`macDigest`}]},{name:`PFX.macData.macSalt`,tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:`macSalt`},{name:`PFX.macData.iterations`,tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,optional:!0,capture:`macIterations`}]}]},c={name:`SafeBag`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`SafeBag.bagId`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`bagId`},{name:`SafeBag.bagValue`,tagClass:r.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:`bagValue`},{name:`SafeBag.bagAttributes`,tagClass:r.Class.UNIVERSAL,type:r.Type.SET,constructed:!0,optional:!0,capture:`bagAttributes`}]},l={name:`Attribute`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`Attribute.attrId`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`oid`},{name:`Attribute.attrValues`,tagClass:r.Class.UNIVERSAL,type:r.Type.SET,constructed:!0,capture:`values`}]},u={name:`CertBag`,tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:`CertBag.certId`,tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:`certId`},{name:`CertBag.certValue`,tagClass:r.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:`CertBag.certValue[0]`,tagClass:r.Class.UNIVERSAL,type:r.Class.OCTETSTRING,constructed:!1,capture:`cert`}]}]};function f(e,t,n,r){for(var i=[],a=0;a<e.length;a++)for(var o=0;o<e[a].safeBags.length;o++){var s=e[a].safeBags[o];if(!(r!==void 0&&s.type!==r)){if(t===null){i.push(s);continue}s.attributes[t]!==void 0&&s.attributes[t].indexOf(n)>=0&&i.push(s)}}return i}a.pkcs12FromAsn1=function(e,t,o){typeof t==`string`?(o=t,t=!0):t===void 0&&(t=!0);var c={};if(!r.validate(e,s,c,[])){var l=Error(`Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.`);throw l.errors=l,l}var u={version:c.version.charCodeAt(0),safeContents:[],getBags:function(e){var t={},r;return`localKeyId`in e?r=e.localKeyId:`localKeyIdHex`in e&&(r=n.util.hexToBytes(e.localKeyIdHex)),r===void 0&&!(`friendlyName`in e)&&`bagType`in e&&(t[e.bagType]=f(u.safeContents,null,null,e.bagType)),r!==void 0&&(t.localKeyId=f(u.safeContents,`localKeyId`,r,e.bagType)),`friendlyName`in e&&(t.friendlyName=f(u.safeContents,`friendlyName`,e.friendlyName,e.bagType)),t},getBagsByFriendlyName:function(e,t){return f(u.safeContents,`friendlyName`,e,t)},getBagsByLocalKeyId:function(e,t){return f(u.safeContents,`localKeyId`,e,t)}};if(c.version.charCodeAt(0)!==3){var l=Error(`PKCS#12 PFX of version other than 3 not supported.`);throw l.version=c.version.charCodeAt(0),l}if(r.derToOid(c.contentType)!==i.oids.data){var l=Error(`Only PKCS#12 PFX in password integrity mode supported.`);throw l.oid=r.derToOid(c.contentType),l}var d=c.content.value[0];if(d.tagClass!==r.Class.UNIVERSAL||d.type!==r.Type.OCTETSTRING)throw Error(`PKCS#12 authSafe content data is not an OCTET STRING.`);if(d=m(d),c.mac){var p=null,g=0,_=r.derToOid(c.macAlgorithm);switch(_){case i.oids.sha1:p=n.md.sha1.create(),g=20;break;case i.oids.sha256:p=n.md.sha256.create(),g=32;break;case i.oids.sha384:p=n.md.sha384.create(),g=48;break;case i.oids.sha512:p=n.md.sha512.create(),g=64;break;case i.oids.md5:p=n.md.md5.create(),g=16;break}if(p===null)throw Error(`PKCS#12 uses unsupported MAC algorithm: `+_);var v=new n.util.ByteBuffer(c.macSalt),y=`macIterations`in c?parseInt(n.util.bytesToHex(c.macIterations),16):1,b=a.generateKey(o,v,3,y,g,p),x=n.hmac.create();if(x.start(p,b),x.update(d.value),x.getMac().getBytes()!==c.macDigest)throw Error(`PKCS#12 MAC could not be verified. Invalid password?`)}else if(Array.isArray(e.value)&&e.value.length>2)throw Error(`Invalid PKCS#12. macData field present but MAC was not validated.`);return h(u,d.value,t,o),u};function m(e){if(e.composed||e.constructed){for(var t=n.util.createBuffer(),r=0;r<e.value.length;++r)t.putBytes(e.value[r].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function h(e,t,n,a){if(t=r.fromDer(t,n),t.tagClass!==r.Class.UNIVERSAL||t.type!==r.Type.SEQUENCE||t.constructed!==!0)throw Error(`PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo`);for(var s=0;s<t.value.length;s++){var c=t.value[s],l={},u=[];if(!r.validate(c,o,l,u)){var d=Error(`Cannot read ContentInfo.`);throw d.errors=u,d}var f={encrypted:!1},p=null,h=l.content.value[0];switch(r.derToOid(l.contentType)){case i.oids.data:if(h.tagClass!==r.Class.UNIVERSAL||h.type!==r.Type.OCTETSTRING)throw Error(`PKCS#12 SafeContents Data is not an OCTET STRING.`);p=m(h).value;break;case i.oids.encryptedData:p=g(h,a),f.encrypted=!0;break;default:var d=Error(`Unsupported PKCS#12 contentType.`);throw d.contentType=r.derToOid(l.contentType),d}f.safeBags=y(p,n,a),e.safeContents.push(f)}}function g(e,t){var a={},o=[];if(!r.validate(e,n.pkcs7.asn1.encryptedDataValidator,a,o)){var s=Error(`Cannot read EncryptedContentInfo.`);throw s.errors=o,s}var c=r.derToOid(a.contentType);if(c!==i.oids.data){var s=Error(`PKCS#12 EncryptedContentInfo ContentType is not Data.`);throw s.oid=c,s}c=r.derToOid(a.encAlgorithm);var l=i.pbe.getCipher(c,a.encParameter,t),u=m(a.encryptedContentAsn1),d=n.util.createBuffer(u.value);if(l.update(d),!l.finish())throw Error(`Failed to decrypt PKCS#12 SafeContents.`);return l.output.getBytes()}function y(e,t,n){if(!t&&e.length===0)return[];if(e=r.fromDer(e,t),e.tagClass!==r.Class.UNIVERSAL||e.type!==r.Type.SEQUENCE||e.constructed!==!0)throw Error(`PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.`);for(var a=[],o=0;o<e.value.length;o++){var s=e.value[o],l={},d=[];if(!r.validate(s,c,l,d)){var f=Error(`Cannot read SafeBag.`);throw f.errors=d,f}var p={type:r.derToOid(l.bagId),attributes:x(l.bagAttributes)};a.push(p);var m,h,g=l.bagValue.value[0];switch(p.type){case i.oids.pkcs8ShroudedKeyBag:if(g=i.decryptPrivateKeyInfo(g,n),g===null)throw Error(`Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?`);case i.oids.keyBag:try{p.key=i.privateKeyFromAsn1(g)}catch{p.key=null,p.asn1=g}continue;case i.oids.certBag:m=u,h=function(){if(r.derToOid(l.certId)!==i.oids.x509Certificate){var e=Error(`Unsupported certificate type, only X.509 supported.`);throw e.oid=r.derToOid(l.certId),e}var n=r.fromDer(l.cert,t);try{p.cert=i.certificateFromAsn1(n,!0)}catch{p.cert=null,p.asn1=n}};break;default:var f=Error(`Unsupported PKCS#12 SafeBag type.`);throw f.oid=p.type,f}if(m!==void 0&&!r.validate(g,m,l,d)){var f=Error(`Cannot read PKCS#12 `+m.name);throw f.errors=d,f}h()}return a}function x(e){var t={};if(e!==void 0)for(var n=0;n<e.length;++n){var a={},o=[];if(!r.validate(e[n],l,a,o)){var s=Error(`Cannot read PKCS#12 BagAttribute.`);throw s.errors=o,s}var c=r.derToOid(a.oid);if(i.oids[c]!==void 0){t[i.oids[c]]=[];for(var u=0;u<a.values.length;++u)t[i.oids[c]].push(a.values[u].value)}}return t}a.toPkcs12Asn1=function(e,t,o,s){s||={},s.saltSize=s.saltSize||8,s.count=s.count||2048,s.algorithm=s.algorithm||s.encAlgorithm||`aes128`,`useMac`in s||(s.useMac=!0),`localKeyId`in s||(s.localKeyId=null),`generateLocalKeyId`in s||(s.generateLocalKeyId=!0);var c=s.localKeyId,l;if(c!==null)c=n.util.hexToBytes(c);else if(s.generateLocalKeyId)if(t){var u=n.util.isArray(t)?t[0]:t;typeof u==`string`&&(u=i.certificateFromPem(u));var d=n.md.sha1.create();d.update(r.toDer(i.certificateToAsn1(u)).getBytes()),c=d.digest().getBytes()}else c=n.random.getBytes(20);var f=[];c!==null&&f.push(r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.localKeyId).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SET,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,c)])])),`friendlyName`in s&&f.push(r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.friendlyName).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SET,!0,[r.create(r.Class.UNIVERSAL,r.Type.BMPSTRING,!1,s.friendlyName)])])),f.length>0&&(l=r.create(r.Class.UNIVERSAL,r.Type.SET,!0,f));var p=[],m=[];t!==null&&(m=n.util.isArray(t)?t:[t]);for(var h=[],g=0;g<m.length;++g){t=m[g],typeof t==`string`&&(t=i.certificateFromPem(t));var _=g===0?l:void 0,v=i.certificateToAsn1(t),y=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.certBag).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.x509Certificate).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,r.toDer(v).getBytes())])])]),_]);h.push(y)}if(h.length>0){var b=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,h),x=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.data).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,r.toDer(b).getBytes())])]);p.push(x)}var S=null;if(e!==null){var C=i.wrapRsaPrivateKey(i.privateKeyToAsn1(e));S=o===null?r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.keyBag).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[C]),l]):r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.pkcs8ShroudedKeyBag).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[i.encryptPrivateKeyInfo(C,o,s)]),l]);var w=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[S]),T=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.data).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,r.toDer(w).getBytes())])]);p.push(T)}var E=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,p),D;if(s.useMac){var d=n.md.sha1.create(),O=new n.util.ByteBuffer(n.random.getBytes(s.saltSize)),k=s.count,e=a.generateKey(o,O,3,k,20),A=n.hmac.create();A.start(d,e),A.update(r.toDer(E).getBytes());var j=A.getMac();D=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.sha1).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,``)]),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,j.getBytes())]),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,O.getBytes()),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(k).getBytes())])}return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(3).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.oids.data).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,r.toDer(E).getBytes())])]),D])},a.generateKey=n.pbe.generatePkcs12Key})),V=o(((e,t)=>{var n=d();v(),_(),ee(),S(),T(),B(),R(),P(),p(),z();var r=n.asn1,i=t.exports=n.pki=n.pki||{};i.pemToDer=function(e){var t=n.pem.decode(e)[0];if(t.procType&&t.procType.type===`ENCRYPTED`)throw Error(`Could not convert PEM to DER; PEM is encrypted.`);return n.util.createBuffer(t.body)},i.privateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if(t.type!==`PRIVATE KEY`&&t.type!==`RSA PRIVATE KEY`){var a=Error(`Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".`);throw a.headerType=t.type,a}if(t.procType&&t.procType.type===`ENCRYPTED`)throw Error(`Could not convert private key from PEM; PEM is encrypted.`);var o=r.fromDer(t.body);return i.privateKeyFromAsn1(o)},i.privateKeyToPem=function(e,t){var a={type:`RSA PRIVATE KEY`,body:r.toDer(i.privateKeyToAsn1(e)).getBytes()};return n.pem.encode(a,{maxline:t})},i.privateKeyInfoToPem=function(e,t){var i={type:`PRIVATE KEY`,body:r.toDer(e).getBytes()};return n.pem.encode(i,{maxline:t})}})),H=o(((e,t)=>{var n=d();v(),b(),x(),S(),V(),O(),j(),p();var r=function(e,t,r,i){var a=n.util.createBuffer(),o=e.length>>1,s=o+(e.length&1),c=e.substr(0,s),l=e.substr(o,s),u=n.util.createBuffer(),d=n.hmac.create();r=t+r;var f=Math.ceil(i/16),p=Math.ceil(i/20);d.start(`MD5`,c);var m=n.util.createBuffer();u.putBytes(r);for(var h=0;h<f;++h)d.start(null,null),d.update(u.getBytes()),u.putBuffer(d.digest()),d.start(null,null),d.update(u.bytes()+r),m.putBuffer(d.digest());d.start(`SHA1`,l);var g=n.util.createBuffer();u.clear(),u.putBytes(r);for(var h=0;h<p;++h)d.start(null,null),d.update(u.getBytes()),u.putBuffer(d.digest()),d.start(null,null),d.update(u.bytes()+r),g.putBuffer(d.digest());return a.putBytes(n.util.xorBytes(m.getBytes(),g.getBytes(),i)),a},i=function(e,t,r){var i=n.hmac.create();i.start(`SHA1`,e);var a=n.util.createBuffer();return a.putInt32(t[0]),a.putInt32(t[1]),a.putByte(r.type),a.putByte(r.version.major),a.putByte(r.version.minor),a.putInt16(r.length),a.putBytes(r.fragment.bytes()),i.update(a.getBytes()),i.digest().getBytes()},a=function(e,t,r){var i=!1;try{var a=e.deflate(t.fragment.getBytes());t.fragment=n.util.createBuffer(a),t.length=a.length,i=!0}catch{}return i},o=function(e,t,r){var i=!1;try{var a=e.inflate(t.fragment.getBytes());t.fragment=n.util.createBuffer(a),t.length=a.length,i=!0}catch{}return i},s=function(e,t){var r=0;switch(t){case 1:r=e.getByte();break;case 2:r=e.getInt16();break;case 3:r=e.getInt24();break;case 4:r=e.getInt32();break}return n.util.createBuffer(e.getBytes(r))},c=function(e,t,n){e.putInt(n.length(),t<<3),e.putBuffer(n)},l={};l.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},l.SupportedVersions=[l.Versions.TLS_1_1,l.Versions.TLS_1_0],l.Version=l.SupportedVersions[0],l.MaxFragment=15360,l.ConnectionEnd={server:0,client:1},l.PRFAlgorithm={tls_prf_sha256:0},l.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},l.CipherType={stream:0,block:1,aead:2},l.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},l.CompressionMethod={none:0,deflate:1},l.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},l.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},l.Alert={},l.Alert.Level={warning:1,fatal:2},l.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},l.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},l.CipherSuites={},l.getCipherSuite=function(e){var t=null;for(var n in l.CipherSuites){var r=l.CipherSuites[n];if(r.id[0]===e.charCodeAt(0)&&r.id[1]===e.charCodeAt(1)){t=r;break}}return t},l.handleUnexpected=function(e,t){!e.open&&e.entity===l.ConnectionEnd.client||e.error(e,{message:`Unexpected message. Received TLS record out of order.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.unexpected_message}})},l.handleHelloRequest=function(e,t,n){!e.handshaking&&e.handshakes>0&&(l.queue(e,l.createAlert(e,{level:l.Alert.Level.warning,description:l.Alert.Description.no_renegotiation})),l.flush(e)),e.process()},l.parseHelloMessage=function(e,t,r){var i=null,a=e.entity===l.ConnectionEnd.client;if(r<38)e.error(e,{message:a?`Invalid ServerHello message. Message too short.`:`Invalid ClientHello message. Message too short.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.illegal_parameter}});else{var o=t.fragment,c=o.length();if(i={version:{major:o.getByte(),minor:o.getByte()},random:n.util.createBuffer(o.getBytes(32)),session_id:s(o,1),extensions:[]},a?(i.cipher_suite=o.getBytes(2),i.compression_method=o.getByte()):(i.cipher_suites=s(o,2),i.compression_methods=s(o,1)),c=r-(c-o.length()),c>0){for(var u=s(o,2);u.length()>0;)i.extensions.push({type:[u.getByte(),u.getByte()],data:s(u,2)});if(!a)for(var d=0;d<i.extensions.length;++d){var f=i.extensions[d];if(f.type[0]===0&&f.type[1]===0)for(var p=s(f.data,2);p.length()>0&&p.getByte()===0;)e.session.extensions.server_name.serverNameList.push(s(p,2).getBytes())}}if(e.session.version&&(i.version.major!==e.session.version.major||i.version.minor!==e.session.version.minor))return e.error(e,{message:`TLS version change is disallowed during renegotiation.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.protocol_version}});if(a)e.session.cipherSuite=l.getCipherSuite(i.cipher_suite);else for(var m=n.util.createBuffer(i.cipher_suites.bytes());m.length()>0&&(e.session.cipherSuite=l.getCipherSuite(m.getBytes(2)),e.session.cipherSuite===null););if(e.session.cipherSuite===null)return e.error(e,{message:`No cipher suites in common.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.handshake_failure},cipherSuite:n.util.bytesToHex(i.cipher_suite)});a?e.session.compressionMethod=i.compression_method:e.session.compressionMethod=l.CompressionMethod.none}return i},l.createSecurityParameters=function(e,t){var n=e.entity===l.ConnectionEnd.client,r=t.random.bytes(),i=n?e.session.sp.client_random:r,a=n?r:l.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:l.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:i,server_random:a}},l.handleServerHello=function(e,t,n){var r=l.parseHelloMessage(e,t,n);if(!e.fail){if(r.version.minor<=e.version.minor)e.version.minor=r.version.minor;else return e.error(e,{message:`Incompatible TLS version.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.protocol_version}});e.session.version=e.version;var i=r.session_id.bytes();i.length>0&&i===e.session.id?(e.expect=_,e.session.resuming=!0,e.session.sp.server_random=r.random.bytes()):(e.expect=f,e.session.resuming=!1,l.createSecurityParameters(e,r)),e.session.id=i,e.process()}},l.handleClientHello=function(e,t,r){var i=l.parseHelloMessage(e,t,r);if(!e.fail){var a=i.session_id.bytes(),o=null;if(e.sessionCache&&(o=e.sessionCache.getSession(a),o===null?a=``:(o.version.major!==i.version.major||o.version.minor>i.version.minor)&&(o=null,a=``)),a.length===0&&(a=n.random.getBytes(32)),e.session.id=a,e.session.clientHelloVersion=i.version,e.session.sp={},o)e.version=e.session.version=o.version,e.session.sp=o.sp;else{for(var s,c=1;c<l.SupportedVersions.length&&(s=l.SupportedVersions[c],!(s.minor<=i.version.minor));++c);e.version={major:s.major,minor:s.minor},e.session.version=e.version}o===null?(e.expect=e.verifyClient===!1?D:E,e.session.resuming=!1,l.createSecurityParameters(e,i)):(e.expect=A,e.session.resuming=!0,e.session.sp.client_random=i.random.bytes()),e.open=!0,l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createServerHello(e)})),e.session.resuming?(l.queue(e,l.createRecord(e,{type:l.ContentType.change_cipher_spec,data:l.createChangeCipherSpec()})),e.state.pending=l.createConnectionState(e),e.state.current.write=e.state.pending.write,l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createFinished(e)}))):(l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createCertificate(e)})),e.fail||(l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createServerKeyExchange(e)})),e.verifyClient!==!1&&l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createCertificateRequest(e)})),l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createServerHelloDone(e)})))),l.flush(e),e.process()}},l.handleCertificate=function(e,t,r){if(r<3)return e.error(e,{message:`Invalid Certificate message. Message too short.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.illegal_parameter}});var i=t.fragment,a={certificate_list:s(i,3)},o,c,u=[];try{for(;a.certificate_list.length()>0;)o=s(a.certificate_list,3),c=n.asn1.fromDer(o),o=n.pki.certificateFromAsn1(c,!0),u.push(o)}catch(t){return e.error(e,{message:`Could not parse certificate list.`,cause:t,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.bad_certificate}})}var d=e.entity===l.ConnectionEnd.client;(d||e.verifyClient===!0)&&u.length===0?e.error(e,{message:d?`No server certificate provided.`:`No client certificate provided.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.illegal_parameter}}):u.length===0?e.expect=d?m:D:(d?e.session.serverCertificate=u[0]:e.session.clientCertificate=u[0],l.verifyCertificateChain(e,u)&&(e.expect=d?m:D)),e.process()},l.handleServerKeyExchange=function(e,t,n){if(n>0)return e.error(e,{message:`Invalid key parameters. Only RSA is supported.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.unsupported_certificate}});e.expect=h,e.process()},l.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:`Invalid key parameters. Only RSA is supported.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.unsupported_certificate}});var i=t.fragment,a={enc_pre_master_secret:s(i,2).getBytes()},o=null;if(e.getPrivateKey)try{o=e.getPrivateKey(e,e.session.serverCertificate),o=n.pki.privateKeyFromPem(o)}catch(t){e.error(e,{message:`Could not get private key.`,cause:t,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.internal_error}})}if(o===null)return e.error(e,{message:`No private key set.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.internal_error}});try{var c=e.session.sp;c.pre_master_secret=o.decrypt(a.enc_pre_master_secret);var u=e.session.clientHelloVersion;if(u.major!==c.pre_master_secret.charCodeAt(0)||u.minor!==c.pre_master_secret.charCodeAt(1))throw Error(`TLS version rollback attack detected.`)}catch{c.pre_master_secret=n.random.getBytes(48)}e.expect=A,e.session.clientCertificate!==null&&(e.expect=k),e.process()},l.handleCertificateRequest=function(e,t,n){if(n<3)return e.error(e,{message:`Invalid CertificateRequest. Message too short.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.illegal_parameter}});var r=t.fragment,i={certificate_types:s(r,1),certificate_authorities:s(r,2)};e.session.certificateRequest=i,e.expect=g,e.process()},l.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:`Invalid CertificateVerify. Message too short.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.illegal_parameter}});var i=t.fragment;i.read-=4;var a=i.bytes();i.read+=4;var o={signature:s(i,2).getBytes()},c=n.util.createBuffer();c.putBuffer(e.session.md5.digest()),c.putBuffer(e.session.sha1.digest()),c=c.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(c,o.signature,`NONE`))throw Error(`CertificateVerify signature does not match.`);e.session.md5.update(a),e.session.sha1.update(a)}catch{return e.error(e,{message:`Bad signature in CertificateVerify.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.handshake_failure}})}e.expect=A,e.process()},l.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:`Invalid ServerHelloDone message. Invalid length.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.record_overflow}});if(e.serverCertificate===null){var i={message:`No server certificate provided. Not enough security.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.insufficient_security}},a=e.verify(e,i.alert.description,0,[]);if(a!==!0)return(a||a===0)&&(typeof a==`object`&&!n.util.isArray(a)?(a.message&&(i.message=a.message),a.alert&&(i.alert.description=a.alert)):typeof a==`number`&&(i.alert.description=a)),e.error(e,i)}e.session.certificateRequest!==null&&(t=l.createRecord(e,{type:l.ContentType.handshake,data:l.createCertificate(e)}),l.queue(e,t)),t=l.createRecord(e,{type:l.ContentType.handshake,data:l.createClientKeyExchange(e)}),l.queue(e,t),e.expect=w;var o=function(e,t){e.session.certificateRequest!==null&&e.session.clientCertificate!==null&&l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createCertificateVerify(e,t)})),l.queue(e,l.createRecord(e,{type:l.ContentType.change_cipher_spec,data:l.createChangeCipherSpec()})),e.state.pending=l.createConnectionState(e),e.state.current.write=e.state.pending.write,l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createFinished(e)})),e.expect=_,l.flush(e),e.process()};if(e.session.certificateRequest===null||e.session.clientCertificate===null)return o(e,null);l.getClientSignature(e,o)},l.handleChangeCipherSpec=function(e,t){if(t.fragment.getByte()!==1)return e.error(e,{message:`Invalid ChangeCipherSpec message received.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.illegal_parameter}});var n=e.entity===l.ConnectionEnd.client;(e.session.resuming&&n||!e.session.resuming&&!n)&&(e.state.pending=l.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&n||e.session.resuming&&!n)&&(e.state.pending=null),e.expect=n?y:M,e.process()},l.handleFinished=function(e,t,i){var a=t.fragment;a.read-=4;var o=a.bytes();a.read+=4;var s=t.fragment.getBytes();a=n.util.createBuffer(),a.putBuffer(e.session.md5.digest()),a.putBuffer(e.session.sha1.digest());var c=e.entity===l.ConnectionEnd.client,u=c?`server finished`:`client finished`,d=e.session.sp;if(a=r(d.master_secret,u,a.getBytes(),12),a.getBytes()!==s)return e.error(e,{message:`Invalid verify_data in Finished message.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.decrypt_error}});e.session.md5.update(o),e.session.sha1.update(o),(e.session.resuming&&c||!e.session.resuming&&!c)&&(l.queue(e,l.createRecord(e,{type:l.ContentType.change_cipher_spec,data:l.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,l.queue(e,l.createRecord(e,{type:l.ContentType.handshake,data:l.createFinished(e)}))),e.expect=c?C:N,e.handshaking=!1,++e.handshakes,e.peerCertificate=c?e.session.serverCertificate:e.session.clientCertificate,l.flush(e),e.isConnected=!0,e.connected(e),e.process()},l.handleAlert=function(e,t){var n=t.fragment,r={level:n.getByte(),description:n.getByte()},i;switch(r.description){case l.Alert.Description.close_notify:i=`Connection closed.`;break;case l.Alert.Description.unexpected_message:i=`Unexpected message.`;break;case l.Alert.Description.bad_record_mac:i=`Bad record MAC.`;break;case l.Alert.Description.decryption_failed:i=`Decryption failed.`;break;case l.Alert.Description.record_overflow:i=`Record overflow.`;break;case l.Alert.Description.decompression_failure:i=`Decompression failed.`;break;case l.Alert.Description.handshake_failure:i=`Handshake failure.`;break;case l.Alert.Description.bad_certificate:i=`Bad certificate.`;break;case l.Alert.Description.unsupported_certificate:i=`Unsupported certificate.`;break;case l.Alert.Description.certificate_revoked:i=`Certificate revoked.`;break;case l.Alert.Description.certificate_expired:i=`Certificate expired.`;break;case l.Alert.Description.certificate_unknown:i=`Certificate unknown.`;break;case l.Alert.Description.illegal_parameter:i=`Illegal parameter.`;break;case l.Alert.Description.unknown_ca:i=`Unknown certificate authority.`;break;case l.Alert.Description.access_denied:i=`Access denied.`;break;case l.Alert.Description.decode_error:i=`Decode error.`;break;case l.Alert.Description.decrypt_error:i=`Decrypt error.`;break;case l.Alert.Description.export_restriction:i=`Export restriction.`;break;case l.Alert.Description.protocol_version:i=`Unsupported protocol version.`;break;case l.Alert.Description.insufficient_security:i=`Insufficient security.`;break;case l.Alert.Description.internal_error:i=`Internal error.`;break;case l.Alert.Description.user_canceled:i=`User canceled.`;break;case l.Alert.Description.no_renegotiation:i=`Renegotiation not supported.`;break;default:i=`Unknown error.`;break}if(r.description===l.Alert.Description.close_notify)return e.close();e.error(e,{message:i,send:!1,origin:e.entity===l.ConnectionEnd.client?`server`:`client`,alert:r}),e.process()},l.handleHandshake=function(e,t){var r=t.fragment,i=r.getByte(),a=r.getInt24();if(a>r.length())return e.fragmented=t,t.fragment=n.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var o=r.bytes(a+4);r.read+=4,i in J[e.entity][e.expect]?(e.entity===l.ConnectionEnd.server&&!e.open&&!e.fail&&(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:n.md.md5.create(),sha1:n.md.sha1.create()}),i!==l.HandshakeType.hello_request&&i!==l.HandshakeType.certificate_verify&&i!==l.HandshakeType.finished&&(e.session.md5.update(o),e.session.sha1.update(o)),J[e.entity][e.expect][i](e,t,a)):l.handleUnexpected(e,t)},l.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},l.handleHeartbeat=function(e,t){var r=t.fragment,i=r.getByte(),a=r.getInt16(),o=r.getBytes(a);if(i===l.HeartbeatMessageType.heartbeat_request){if(e.handshaking||a>o.length)return e.process();l.queue(e,l.createRecord(e,{type:l.ContentType.heartbeat,data:l.createHeartbeat(l.HeartbeatMessageType.heartbeat_response,o)})),l.flush(e)}else if(i===l.HeartbeatMessageType.heartbeat_response){if(o!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,n.util.createBuffer(o))}e.process()};var u=0,f=1,m=2,h=3,g=4,_=5,y=6,C=7,w=8,T=0,E=1,D=2,k=3,A=4,M=5,N=6,P=l.handleUnexpected,ee=l.handleChangeCipherSpec,F=l.handleAlert,I=l.handleHandshake,L=l.handleApplicationData,R=l.handleHeartbeat,z=[];z[l.ConnectionEnd.client]=[[P,F,I,P,R],[P,F,I,P,R],[P,F,I,P,R],[P,F,I,P,R],[P,F,I,P,R],[ee,F,P,P,R],[P,F,I,P,R],[P,F,I,L,R],[P,F,I,P,R]],z[l.ConnectionEnd.server]=[[P,F,I,P,R],[P,F,I,P,R],[P,F,I,P,R],[P,F,I,P,R],[ee,F,P,P,R],[P,F,I,P,R],[P,F,I,L,R],[P,F,I,P,R]];var B=l.handleHelloRequest,H=l.handleServerHello,U=l.handleCertificate,W=l.handleServerKeyExchange,G=l.handleCertificateRequest,K=l.handleServerHelloDone,q=l.handleFinished,J=[];J[l.ConnectionEnd.client]=[[P,P,H,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P],[B,P,P,P,P,P,P,P,P,P,P,U,W,G,K,P,P,P,P,P,P],[B,P,P,P,P,P,P,P,P,P,P,P,W,G,K,P,P,P,P,P,P],[B,P,P,P,P,P,P,P,P,P,P,P,P,G,K,P,P,P,P,P,P],[B,P,P,P,P,P,P,P,P,P,P,P,P,P,K,P,P,P,P,P,P],[B,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P],[B,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,q],[B,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P],[B,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P]];var Y=l.handleClientHello,X=l.handleClientKeyExchange,Z=l.handleCertificateVerify;J[l.ConnectionEnd.server]=[[P,Y,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P],[P,P,P,P,P,P,P,P,P,P,P,U,P,P,P,P,P,P,P,P,P],[P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,X,P,P,P,P],[P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,Z,P,P,P,P,P],[P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P],[P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,q],[P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P],[P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P,P]],l.generateKeys=function(e,t){var n=r,i=t.client_random+t.server_random;e.session.resuming||(t.master_secret=n(t.pre_master_secret,`master secret`,i,48).bytes(),t.pre_master_secret=null),i=t.server_random+t.client_random;var a=2*t.mac_key_length+2*t.enc_key_length,o=e.version.major===l.Versions.TLS_1_0.major&&e.version.minor===l.Versions.TLS_1_0.minor;o&&(a+=2*t.fixed_iv_length);var s=n(t.master_secret,`key expansion`,i,a),c={client_write_MAC_key:s.getBytes(t.mac_key_length),server_write_MAC_key:s.getBytes(t.mac_key_length),client_write_key:s.getBytes(t.enc_key_length),server_write_key:s.getBytes(t.enc_key_length)};return o&&(c.client_write_IV=s.getBytes(t.fixed_iv_length),c.server_write_IV=s.getBytes(t.fixed_iv_length)),c},l.createConnectionState=function(e){var t=e.entity===l.ConnectionEnd.client,n=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){e.sequenceNumber[1]===4294967295?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},r={read:n(),write:n()};if(r.read.update=function(e,t){return r.read.cipherFunction(t,r.read)?r.read.compressFunction(e,t,r.read)||e.error(e,{message:`Could not decompress record.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.decompression_failure}}):e.error(e,{message:`Could not decrypt record or bad MAC.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.bad_record_mac}}),!e.fail},r.write.update=function(e,t){return r.write.compressFunction(e,t,r.write)?r.write.cipherFunction(t,r.write)||e.error(e,{message:`Could not encrypt record.`,send:!1,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.internal_error}}):e.error(e,{message:`Could not compress record.`,send:!1,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.internal_error}}),!e.fail},e.session){var i=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(i),i.keys=l.generateKeys(e,i),r.read.macKey=t?i.keys.server_write_MAC_key:i.keys.client_write_MAC_key,r.write.macKey=t?i.keys.client_write_MAC_key:i.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(r,e,i),i.compression_algorithm){case l.CompressionMethod.none:break;case l.CompressionMethod.deflate:r.read.compressFunction=o,r.write.compressFunction=a;break;default:throw Error(`Unsupported compression algorithm.`)}}return r},l.createRandom=function(){var e=new Date,t=+e+e.getTimezoneOffset()*6e4,r=n.util.createBuffer();return r.putInt32(t),r.putBytes(n.random.getBytes(28)),r},l.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},l.createAlert=function(e,t){var r=n.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),l.createRecord(e,{type:l.ContentType.alert,data:r})},l.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=n.util.createBuffer(),r=0;r<e.cipherSuites.length;++r){var i=e.cipherSuites[r];t.putByte(i.id[0]),t.putByte(i.id[1])}var a=t.length(),o=n.util.createBuffer();o.putByte(l.CompressionMethod.none);var s=o.length(),u=n.util.createBuffer();if(e.virtualHost){var d=n.util.createBuffer();d.putByte(0),d.putByte(0);var f=n.util.createBuffer();f.putByte(0),c(f,2,n.util.createBuffer(e.virtualHost));var p=n.util.createBuffer();c(p,2,f),c(d,2,p),u.putBuffer(d)}var m=u.length();m>0&&(m+=2);var h=e.session.id,g=h.length+1+2+4+28+2+a+1+s+m,_=n.util.createBuffer();return _.putByte(l.HandshakeType.client_hello),_.putInt24(g),_.putByte(e.version.major),_.putByte(e.version.minor),_.putBytes(e.session.sp.client_random),c(_,1,n.util.createBuffer(h)),c(_,2,t),c(_,1,o),m>0&&c(_,2,u),_},l.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,i=n.util.createBuffer();return i.putByte(l.HandshakeType.server_hello),i.putInt24(r),i.putByte(e.version.major),i.putByte(e.version.minor),i.putBytes(e.session.sp.server_random),c(i,1,n.util.createBuffer(t)),i.putByte(e.session.cipherSuite.id[0]),i.putByte(e.session.cipherSuite.id[1]),i.putByte(e.session.compressionMethod),i},l.createCertificate=function(e){var t=e.entity===l.ConnectionEnd.client,r=null;if(e.getCertificate){var i=t?e.session.certificateRequest:e.session.extensions.server_name.serverNameList;r=e.getCertificate(e,i)}var a=n.util.createBuffer();if(r!==null)try{n.util.isArray(r)||(r=[r]);for(var o=null,s=0;s<r.length;++s){var u=n.pem.decode(r[s])[0];if(u.type!==`CERTIFICATE`&&u.type!==`X509 CERTIFICATE`&&u.type!==`TRUSTED CERTIFICATE`){var d=Error(`Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".`);throw d.headerType=u.type,d}if(u.procType&&u.procType.type===`ENCRYPTED`)throw Error(`Could not convert certificate from PEM; PEM is encrypted.`);var f=n.util.createBuffer(u.body);o===null&&(o=n.asn1.fromDer(f.bytes(),!1));var p=n.util.createBuffer();c(p,3,f),a.putBuffer(p)}r=n.pki.certificateFromAsn1(o),t?e.session.clientCertificate=r:e.session.serverCertificate=r}catch(t){return e.error(e,{message:`Could not send certificate list.`,cause:t,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.bad_certificate}})}var m=3+a.length(),h=n.util.createBuffer();return h.putByte(l.HandshakeType.certificate),h.putInt24(m),c(h,3,a),h},l.createClientKeyExchange=function(e){var t=n.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(n.random.getBytes(46));var r=e.session.sp;r.pre_master_secret=t.getBytes(),t=e.session.serverCertificate.publicKey.encrypt(r.pre_master_secret);var i=t.length+2,a=n.util.createBuffer();return a.putByte(l.HandshakeType.client_key_exchange),a.putInt24(i),a.putInt16(t.length),a.putBytes(t),a},l.createServerKeyExchange=function(e){var t=0,r=n.util.createBuffer();return t>0&&(r.putByte(l.HandshakeType.server_key_exchange),r.putInt24(t)),r},l.getClientSignature=function(e,t){var r=n.util.createBuffer();r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest()),r=r.getBytes(),e.getSignature=e.getSignature||function(e,t,r){var i=null;if(e.getPrivateKey)try{i=e.getPrivateKey(e,e.session.clientCertificate),i=n.pki.privateKeyFromPem(i)}catch(t){e.error(e,{message:`Could not get private key.`,cause:t,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.internal_error}})}i===null?e.error(e,{message:`No private key set.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.internal_error}}):t=i.sign(t,null),r(e,t)},e.getSignature(e,r,t)},l.createCertificateVerify=function(e,t){var r=t.length+2,i=n.util.createBuffer();return i.putByte(l.HandshakeType.certificate_verify),i.putInt24(r),i.putInt16(t.length),i.putBytes(t),i},l.createCertificateRequest=function(e){var t=n.util.createBuffer();t.putByte(1);var r=n.util.createBuffer();for(var i in e.caStore.certs){var a=e.caStore.certs[i],o=n.pki.distinguishedNameToAsn1(a.subject),s=n.asn1.toDer(o);r.putInt16(s.length()),r.putBuffer(s)}var u=1+t.length()+2+r.length(),d=n.util.createBuffer();return d.putByte(l.HandshakeType.certificate_request),d.putInt24(u),c(d,1,t),c(d,2,r),d},l.createServerHelloDone=function(e){var t=n.util.createBuffer();return t.putByte(l.HandshakeType.server_hello_done),t.putInt24(0),t},l.createChangeCipherSpec=function(){var e=n.util.createBuffer();return e.putByte(1),e},l.createFinished=function(e){var t=n.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var i=e.entity===l.ConnectionEnd.client,a=e.session.sp,o=12,s=r,c=i?`client finished`:`server finished`;t=s(a.master_secret,c,t.getBytes(),o);var u=n.util.createBuffer();return u.putByte(l.HandshakeType.finished),u.putInt24(t.length()),u.putBuffer(t),u},l.createHeartbeat=function(e,t,r){r===void 0&&(r=t.length);var i=n.util.createBuffer();i.putByte(e),i.putInt16(r),i.putBytes(t);var a=i.length(),o=Math.max(16,a-r-3);return i.putBytes(n.random.getBytes(o)),i},l.queue=function(e,t){if(t&&!(t.fragment.length()===0&&(t.type===l.ContentType.handshake||t.type===l.ContentType.alert||t.type===l.ContentType.change_cipher_spec))){if(t.type===l.ContentType.handshake){var r=t.fragment.bytes();e.session.md5.update(r),e.session.sha1.update(r),r=null}var i;if(t.fragment.length()<=l.MaxFragment)i=[t];else{i=[];for(var a=t.fragment.bytes();a.length>l.MaxFragment;)i.push(l.createRecord(e,{type:t.type,data:n.util.createBuffer(a.slice(0,l.MaxFragment))})),a=a.slice(l.MaxFragment);a.length>0&&i.push(l.createRecord(e,{type:t.type,data:n.util.createBuffer(a)}))}for(var o=0;o<i.length&&!e.fail;++o){var s=i[o];e.state.current.write.update(e,s)&&e.records.push(s)}}},l.flush=function(e){for(var t=0;t<e.records.length;++t){var n=e.records[t];e.tlsData.putByte(n.type),e.tlsData.putByte(n.version.major),e.tlsData.putByte(n.version.minor),e.tlsData.putInt16(n.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var te=function(e){switch(e){case!0:return!0;case n.pki.certificateError.bad_certificate:return l.Alert.Description.bad_certificate;case n.pki.certificateError.unsupported_certificate:return l.Alert.Description.unsupported_certificate;case n.pki.certificateError.certificate_revoked:return l.Alert.Description.certificate_revoked;case n.pki.certificateError.certificate_expired:return l.Alert.Description.certificate_expired;case n.pki.certificateError.certificate_unknown:return l.Alert.Description.certificate_unknown;case n.pki.certificateError.unknown_ca:return l.Alert.Description.unknown_ca;default:return l.Alert.Description.bad_certificate}},ne=function(e){switch(e){case!0:return!0;case l.Alert.Description.bad_certificate:return n.pki.certificateError.bad_certificate;case l.Alert.Description.unsupported_certificate:return n.pki.certificateError.unsupported_certificate;case l.Alert.Description.certificate_revoked:return n.pki.certificateError.certificate_revoked;case l.Alert.Description.certificate_expired:return n.pki.certificateError.certificate_expired;case l.Alert.Description.certificate_unknown:return n.pki.certificateError.certificate_unknown;case l.Alert.Description.unknown_ca:return n.pki.certificateError.unknown_ca;default:return n.pki.certificateError.bad_certificate}};for(var re in l.verifyCertificateChain=function(e,t){try{var r={};for(var i in e.verifyOptions)r[i]=e.verifyOptions[i];r.verify=function(t,r,i){te(t);var a=e.verify(e,t,r,i);if(a!==!0){if(typeof a==`object`&&!n.util.isArray(a)){var o=Error(`The application rejected the certificate.`);throw o.send=!0,o.alert={level:l.Alert.Level.fatal,description:l.Alert.Description.bad_certificate},a.message&&(o.message=a.message),a.alert&&(o.alert.description=a.alert),o}a!==t&&(a=ne(a))}return a},n.pki.verifyCertificateChain(e.caStore,t,r)}catch(t){var a=t;(typeof a!=`object`||n.util.isArray(a))&&(a={send:!0,alert:{level:l.Alert.Level.fatal,description:te(t)}}),`send`in a||(a.send=!0),`alert`in a||(a.alert={level:l.Alert.Level.fatal,description:te(a.error)}),e.error(e,a)}return!e.fail},l.createSessionCache=function(e,t){var r=null;if(e&&e.getSession&&e.setSession&&e.order)r=e;else{for(var i in r={},r.cache=e||{},r.capacity=Math.max(t||100,1),r.order=[],e)r.order.length<=t?r.order.push(i):delete e[i];r.getSession=function(e){var t=null,i=null;if(e?i=n.util.bytesToHex(e):r.order.length>0&&(i=r.order[0]),i!==null&&i in r.cache){for(var a in t=r.cache[i],delete r.cache[i],r.order)if(r.order[a]===i){r.order.splice(a,1);break}}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var i=r.order.shift();delete r.cache[i]}var i=n.util.bytesToHex(e);r.order.push(i),r.cache[i]=t}}return r},l.createConnection=function(e){var t=null;t=e.caStore?n.util.isArray(e.caStore)?n.pki.createCaStore(e.caStore):e.caStore:n.pki.createCaStore();var r=e.cipherSuites||null;if(r===null)for(var i in r=[],l.CipherSuites)r.push(l.CipherSuites[i]);var a=e.server?l.ConnectionEnd.server:l.ConnectionEnd.client,o=e.sessionCache?l.createSessionCache(e.sessionCache):null,s={version:{major:l.Version.major,minor:l.Version.minor},entity:a,sessionId:e.sessionId,caStore:t,sessionCache:o,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,n,r){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:n.util.createBuffer(),tlsData:n.util.createBuffer(),data:n.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,n){n.origin=n.origin||(t.entity===l.ConnectionEnd.client?`client`:`server`),n.send&&(l.queue(t,l.createAlert(t,n.alert)),l.flush(t));var r=n.fatal!==!1;r&&(t.fail=!0),e.error(t,n),r&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null};s.reset=function(e){s.version={major:l.Version.major,minor:l.Version.minor},s.record=null,s.session=null,s.peerCertificate=null,s.state={pending:null,current:null},s.expect=s.entity===l.ConnectionEnd.client?u:T,s.fragmented=null,s.records=[],s.open=!1,s.handshakes=0,s.handshaking=!1,s.isConnected=!1,s.fail=!(e||e===void 0),s.input.clear(),s.tlsData.clear(),s.data.clear(),s.state.current=l.createConnectionState(s)},s.reset();var c=function(e,t){var n=t.type-l.ContentType.change_cipher_spec,r=z[e.entity][e.expect];n in r?r[n](e,t):l.handleUnexpected(e,t)},d=function(e){var t=0,r=e.input,i=r.length();if(i<5)t=5-i;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:n.util.createBuffer(),ready:!1};var a=e.record.version.major===e.version.major;a&&e.session&&e.session.version&&(a=e.record.version.minor===e.version.minor),a||e.error(e,{message:`Incompatible TLS version.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.protocol_version}})}return t},f=function(e){var t=0,n=e.input,r=n.length();return r<e.record.length?t=e.record.length-r:(e.record.fragment.putBytes(n.getBytes(e.record.length)),n.compact(),e.state.current.read.update(e,e.record)&&(e.fragmented!==null&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:`Invalid fragmented record.`,send:!0,alert:{level:l.Alert.Level.fatal,description:l.Alert.Description.unexpected_message}})),e.record.ready=!0)),t};return s.handshake=function(e){if(s.entity!==l.ConnectionEnd.client)s.error(s,{message:`Cannot initiate handshake as a server.`,fatal:!1});else if(s.handshaking)s.error(s,{message:`Handshake already in progress.`,fatal:!1});else{s.fail&&!s.open&&s.handshakes===0&&(s.fail=!1),s.handshaking=!0,e||=``;var t=null;e.length>0&&(s.sessionCache&&(t=s.sessionCache.getSession(e)),t===null&&(e=``)),e.length===0&&s.sessionCache&&(t=s.sessionCache.getSession(),t!==null&&(e=t.id)),s.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:n.md.md5.create(),sha1:n.md.sha1.create()},t&&(s.version=t.version,s.session.sp=t.sp),s.session.sp.client_random=l.createRandom().getBytes(),s.open=!0,l.queue(s,l.createRecord(s,{type:l.ContentType.handshake,data:l.createClientHello(s)})),l.flush(s)}},s.process=function(e){var t=0;return e&&s.input.putBytes(e),s.fail||(s.record!==null&&s.record.ready&&s.record.fragment.isEmpty()&&(s.record=null),s.record===null&&(t=d(s)),!s.fail&&s.record!==null&&!s.record.ready&&(t=f(s)),!s.fail&&s.record!==null&&s.record.ready&&c(s,s.record)),t},s.prepare=function(e){return l.queue(s,l.createRecord(s,{type:l.ContentType.application_data,data:n.util.createBuffer(e)})),l.flush(s)},s.prepareHeartbeatRequest=function(e,t){return e instanceof n.util.ByteBuffer&&(e=e.bytes()),t===void 0&&(t=e.length),s.expectedHeartbeatPayload=e,l.queue(s,l.createRecord(s,{type:l.ContentType.heartbeat,data:l.createHeartbeat(l.HeartbeatMessageType.heartbeat_request,e,t)})),l.flush(s)},s.close=function(e){if(!s.fail&&s.sessionCache&&s.session){var t={id:s.session.id,version:s.session.version,sp:s.session.sp};t.sp.keys=null,s.sessionCache.setSession(t.id,t)}s.open&&(s.open=!1,s.input.clear(),(s.isConnected||s.handshaking)&&(s.isConnected=s.handshaking=!1,l.queue(s,l.createAlert(s,{level:l.Alert.Level.warning,description:l.Alert.Description.close_notify})),l.flush(s)),s.closed(s)),s.reset(e)},s},t.exports=n.tls=n.tls||{},l)typeof l[re]!=`function`&&(n.tls[re]=l[re]);n.tls.prf_tls1=r,n.tls.hmac_sha1=i,n.tls.createSessionCache=l.createSessionCache,n.tls.createConnection=l.createConnection})),U=o(((e,t)=>{var n=d();g(),H();var r=t.exports=n.tls;r.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:`TLS_RSA_WITH_AES_128_CBC_SHA`,initSecurityParameters:function(e){e.bulk_cipher_algorithm=r.BulkCipherAlgorithm.aes,e.cipher_type=r.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=r.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:i},r.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:`TLS_RSA_WITH_AES_256_CBC_SHA`,initSecurityParameters:function(e){e.bulk_cipher_algorithm=r.BulkCipherAlgorithm.aes,e.cipher_type=r.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=r.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:i};function i(e,t,i){var o=t.entity===n.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:n.cipher.createDecipher(`AES-CBC`,o?i.keys.server_write_key:i.keys.client_write_key),iv:o?i.keys.server_write_IV:i.keys.client_write_IV},e.write.cipherState={init:!1,cipher:n.cipher.createCipher(`AES-CBC`,o?i.keys.client_write_key:i.keys.server_write_key),iv:o?i.keys.client_write_IV:i.keys.server_write_IV},e.read.cipherFunction=c,e.write.cipherFunction=a,e.read.macLength=e.write.macLength=i.mac_length,e.read.macFunction=e.write.macFunction=r.hmac_sha1}function a(e,t){var i=!1,a=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(a),t.updateSequenceNumber();var s=e.version.minor===r.Versions.TLS_1_0.minor?t.cipherState.init?null:t.cipherState.iv:n.random.getBytesSync(16);t.cipherState.init=!0;var c=t.cipherState.cipher;return c.start({iv:s}),e.version.minor>=r.Versions.TLS_1_1.minor&&c.output.putBytes(s),c.update(e.fragment),c.finish(o)&&(e.fragment=c.output,e.length=e.fragment.length(),i=!0),i}function o(e,t,n){if(!n){var r=e-t.length()%e;t.fillWithByte(r-1,r)}return!0}function s(e,t,n){var r=!0;if(n){for(var i=t.length(),a=t.last(),o=i-1-a;o<i-1;++o)r&&=t.at(o)==a;r&&t.truncate(a+1)}return r}function c(e,t){var i=!1,a=e.version.minor===r.Versions.TLS_1_0.minor?t.cipherState.init?null:t.cipherState.iv:e.fragment.getBytes(16);t.cipherState.init=!0;var o=t.cipherState.cipher;o.start({iv:a}),o.update(e.fragment),i=o.finish(s);var c=t.macLength,u=n.random.getBytesSync(c),d=o.output.length();d>=c?(e.fragment=o.output.getBytes(d-c),u=o.output.getBytes(c)):e.fragment=o.output.getBytes(),e.fragment=n.util.createBuffer(e.fragment),e.length=e.fragment.length();var f=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),i=l(t.macKey,u,f)&&i,i}function l(e,t,r){var i=n.hmac.create();return i.start(`SHA1`,e),i.update(t),t=i.digest().getBytes(),i.start(null,null),i.update(r),r=i.digest().getBytes(),t===r}})),W=o(((e,t)=>{var n=d();y(),p();var r=t.exports=n.sha512=n.sha512||{};n.md.sha512=n.md.algorithms.sha512=r;var i=n.sha384=n.sha512.sha384=n.sha512.sha384||{};i.create=function(){return r.create(`SHA-384`)},n.md.sha384=n.md.algorithms.sha384=i,n.sha512.sha256=n.sha512.sha256||{create:function(){return r.create(`SHA-512/256`)}},n.md[`sha512/256`]=n.md.algorithms[`sha512/256`]=n.sha512.sha256,n.sha512.sha224=n.sha512.sha224||{create:function(){return r.create(`SHA-512/224`)}},n.md[`sha512/224`]=n.md.algorithms[`sha512/224`]=n.sha512.sha224,r.create=function(e){if(o||l(),e===void 0&&(e=`SHA-512`),!(e in c))throw Error(`Invalid SHA-512 algorithm: `+e);for(var t=c[e],r=null,i=n.util.createBuffer(),s=Array(80),d=0;d<80;++d)s[d]=[,,];var f=64;switch(e){case`SHA-384`:f=48;break;case`SHA-512/256`:f=32;break;case`SHA-512/224`:f=28;break}var p={algorithm:e.replace(`-`,``).toLowerCase(),blockLength:128,digestLength:f,messageLength:0,fullMessageLength:null,messageLengthSize:16};return p.start=function(){p.messageLength=0,p.fullMessageLength=p.messageLength128=[];for(var e=p.messageLengthSize/4,a=0;a<e;++a)p.fullMessageLength.push(0);i=n.util.createBuffer(),r=Array(t.length);for(var a=0;a<t.length;++a)r[a]=t[a].slice(0);return p},p.start(),p.update=function(e,t){t===`utf8`&&(e=n.util.encodeUtf8(e));var a=e.length;p.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var o=p.fullMessageLength.length-1;o>=0;--o)p.fullMessageLength[o]+=a[1],a[1]=a[0]+(p.fullMessageLength[o]/4294967296>>>0),p.fullMessageLength[o]=p.fullMessageLength[o]>>>0,a[0]=a[1]/4294967296>>>0;return i.putBytes(e),u(r,s,i),(i.read>2048||i.length()===0)&&i.compact(),p},p.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var o=p.fullMessageLength[p.fullMessageLength.length-1]+p.messageLengthSize&p.blockLength-1;t.putBytes(a.substr(0,p.blockLength-o));for(var c,l,d=p.fullMessageLength[0]*8,f=0;f<p.fullMessageLength.length-1;++f)c=p.fullMessageLength[f+1]*8,l=c/4294967296>>>0,d+=l,t.putInt32(d>>>0),d=c>>>0;t.putInt32(d);for(var m=Array(r.length),f=0;f<r.length;++f)m[f]=r[f].slice(0);u(m,s,t);for(var h=n.util.createBuffer(),g=e===`SHA-512`?m.length:e===`SHA-384`?m.length-2:m.length-4,f=0;f<g;++f)h.putInt32(m[f][0]),(f!==g-1||e!==`SHA-512/224`)&&h.putInt32(m[f][1]);return h},p};var a=null,o=!1,s=null,c=null;function l(){a=`€`,a+=n.util.fillString(`\0`,128),s=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],c={},c[`SHA-512`]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c[`SHA-384`]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c[`SHA-512/256`]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c[`SHA-512/224`]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],o=!0}function u(e,t,n){for(var r,i,a,o,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,P,ee,F,I,L,R=n.length();R>=128;){for(M=0;M<16;++M)t[M][0]=n.getInt32()>>>0,t[M][1]=n.getInt32()>>>0;for(;M<80;++M)ee=t[M-2],N=ee[0],P=ee[1],r=((N>>>19|P<<13)^(P>>>29|N<<3)^N>>>6)>>>0,i=((N<<13|P>>>19)^(P<<3|N>>>29)^(N<<26|P>>>6))>>>0,I=t[M-15],N=I[0],P=I[1],a=((N>>>1|P<<31)^(N>>>8|P<<24)^N>>>7)>>>0,o=((N<<31|P>>>1)^(N<<24|P>>>8)^(N<<25|P>>>7))>>>0,F=t[M-7],L=t[M-16],P=i+F[1]+o+L[1],t[M][0]=r+F[0]+a+L[0]+(P/4294967296>>>0)>>>0,t[M][1]=P>>>0;for(g=e[0][0],_=e[0][1],v=e[1][0],y=e[1][1],b=e[2][0],x=e[2][1],S=e[3][0],C=e[3][1],w=e[4][0],T=e[4][1],E=e[5][0],D=e[5][1],O=e[6][0],k=e[6][1],A=e[7][0],j=e[7][1],M=0;M<80;++M)u=((w>>>14|T<<18)^(w>>>18|T<<14)^(T>>>9|w<<23))>>>0,d=((w<<18|T>>>14)^(w<<14|T>>>18)^(T<<23|w>>>9))>>>0,f=(O^w&(E^O))>>>0,p=(k^T&(D^k))>>>0,c=((g>>>28|_<<4)^(_>>>2|g<<30)^(_>>>7|g<<25))>>>0,l=((g<<4|_>>>28)^(_<<30|g>>>2)^(_<<25|g>>>7))>>>0,m=(g&v|b&(g^v))>>>0,h=(_&y|x&(_^y))>>>0,P=j+d+p+s[M][1]+t[M][1],r=A+u+f+s[M][0]+t[M][0]+(P/4294967296>>>0)>>>0,i=P>>>0,P=l+h,a=c+m+(P/4294967296>>>0)>>>0,o=P>>>0,A=O,j=k,O=E,k=D,E=w,D=T,P=C+i,w=S+r+(P/4294967296>>>0)>>>0,T=P>>>0,S=b,C=x,b=v,x=y,v=g,y=_,P=i+o,g=r+a+(P/4294967296>>>0)>>>0,_=P>>>0;P=e[0][1]+_,e[0][0]=e[0][0]+g+(P/4294967296>>>0)>>>0,e[0][1]=P>>>0,P=e[1][1]+y,e[1][0]=e[1][0]+v+(P/4294967296>>>0)>>>0,e[1][1]=P>>>0,P=e[2][1]+x,e[2][0]=e[2][0]+b+(P/4294967296>>>0)>>>0,e[2][1]=P>>>0,P=e[3][1]+C,e[3][0]=e[3][0]+S+(P/4294967296>>>0)>>>0,e[3][1]=P>>>0,P=e[4][1]+T,e[4][0]=e[4][0]+w+(P/4294967296>>>0)>>>0,e[4][1]=P>>>0,P=e[5][1]+D,e[5][0]=e[5][0]+E+(P/4294967296>>>0)>>>0,e[5][1]=P>>>0,P=e[6][1]+k,e[6][0]=e[6][0]+O+(P/4294967296>>>0)>>>0,e[6][1]=P>>>0,P=e[7][1]+j,e[7][0]=e[7][0]+A+(P/4294967296>>>0)>>>0,e[7][1]=P>>>0,R-=128}}})),G=o((e=>{var t=d();v();var n=t.asn1;e.privateKeyValidator={name:`PrivateKeyInfo`,tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:`PrivateKeyInfo.version`,tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:`privateKeyVersion`},{name:`PrivateKeyInfo.privateKeyAlgorithm`,tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:`AlgorithmIdentifier.algorithm`,tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:`privateKeyOid`}]},{name:`PrivateKeyInfo`,tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:`privateKey`}]},e.publicKeyValidator={name:`SubjectPublicKeyInfo`,tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:`subjectPublicKeyInfo`,value:[{name:`SubjectPublicKeyInfo.AlgorithmIdentifier`,tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:`AlgorithmIdentifier.algorithm`,tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:`publicKeyOid`}]},{tagClass:n.Class.UNIVERSAL,type:n.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:`ed25519PublicKey`}]}})),K=o(((e,t)=>{var n=d();A(),O(),W(),p();var r=G(),i=r.publicKeyValidator,a=r.privateKeyValidator;if(o===void 0)var o=n.jsbn.BigInteger;var s=n.util.ByteBuffer,c=typeof Buffer>`u`?Uint8Array:Buffer;n.pki=n.pki||{},t.exports=n.pki.ed25519=n.ed25519=n.ed25519||{};var l=n.ed25519;l.constants={},l.constants.PUBLIC_KEY_BYTE_LENGTH=32,l.constants.PRIVATE_KEY_BYTE_LENGTH=64,l.constants.SEED_BYTE_LENGTH=32,l.constants.SIGN_BYTE_LENGTH=64,l.constants.HASH_BYTE_LENGTH=64,l.generateKeyPair=function(e){e||={};var t=e.seed;if(t===void 0)t=n.random.getBytesSync(l.constants.SEED_BYTE_LENGTH);else if(typeof t==`string`){if(t.length!==l.constants.SEED_BYTE_LENGTH)throw TypeError(`"seed" must be `+l.constants.SEED_BYTE_LENGTH+` bytes in length.`)}else if(!(t instanceof Uint8Array))throw TypeError(`"seed" must be a node.js Buffer, Uint8Array, or a binary string.`);t=u({message:t,encoding:`binary`});for(var r=new c(l.constants.PUBLIC_KEY_BYTE_LENGTH),i=new c(l.constants.PRIVATE_KEY_BYTE_LENGTH),a=0;a<32;++a)i[a]=t[a];return S(r,i),{publicKey:r,privateKey:i}},l.privateKeyFromAsn1=function(e){var t={},r=[];if(!n.asn1.validate(e,a,t,r)){var i=Error(`Invalid Key.`);throw i.errors=r,i}var o=n.asn1.derToOid(t.privateKeyOid),s=n.oids.EdDSA25519;if(o!==s)throw Error(`Invalid OID "`+o+`"; OID must be "`+s+`".`);var c=t.privateKey;return{privateKeyBytes:u({message:n.asn1.fromDer(c).value,encoding:`binary`})}},l.publicKeyFromAsn1=function(e){var t={},r=[];if(!n.asn1.validate(e,i,t,r)){var a=Error(`Invalid Key.`);throw a.errors=r,a}var o=n.asn1.derToOid(t.publicKeyOid),s=n.oids.EdDSA25519;if(o!==s)throw Error(`Invalid OID "`+o+`"; OID must be "`+s+`".`);var c=t.ed25519PublicKey;if(c.length!==l.constants.PUBLIC_KEY_BYTE_LENGTH)throw Error(`Key length is invalid.`);return u({message:c,encoding:`binary`})},l.publicKeyFromPrivateKey=function(e){e||={};var t=u({message:e.privateKey,encoding:`binary`});if(t.length!==l.constants.PRIVATE_KEY_BYTE_LENGTH)throw TypeError(`"options.privateKey" must have a byte length of `+l.constants.PRIVATE_KEY_BYTE_LENGTH);for(var n=new c(l.constants.PUBLIC_KEY_BYTE_LENGTH),r=0;r<n.length;++r)n[r]=t[32+r];return n},l.sign=function(e){e||={};var t=u(e),n=u({message:e.privateKey,encoding:`binary`});if(n.length===l.constants.SEED_BYTE_LENGTH)n=l.generateKeyPair({seed:n}).privateKey;else if(n.length!==l.constants.PRIVATE_KEY_BYTE_LENGTH)throw TypeError(`"options.privateKey" must have a byte length of `+l.constants.SEED_BYTE_LENGTH+` or `+l.constants.PRIVATE_KEY_BYTE_LENGTH);var r=new c(l.constants.SIGN_BYTE_LENGTH+t.length);C(r,t,t.length,n);for(var i=new c(l.constants.SIGN_BYTE_LENGTH),a=0;a<i.length;++a)i[a]=r[a];return i},l.verify=function(e){e||={};var t=u(e);if(e.signature===void 0)throw TypeError(`"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.`);var n=u({message:e.signature,encoding:`binary`});if(n.length!==l.constants.SIGN_BYTE_LENGTH)throw TypeError(`"options.signature" must have a byte length of `+l.constants.SIGN_BYTE_LENGTH);var r=u({message:e.publicKey,encoding:`binary`});if(r.length!==l.constants.PUBLIC_KEY_BYTE_LENGTH)throw TypeError(`"options.publicKey" must have a byte length of `+l.constants.PUBLIC_KEY_BYTE_LENGTH);var i=new c(l.constants.SIGN_BYTE_LENGTH+t.length),a=new c(l.constants.SIGN_BYTE_LENGTH+t.length),o;for(o=0;o<l.constants.SIGN_BYTE_LENGTH;++o)i[o]=n[o];for(o=0;o<t.length;++o)i[o+l.constants.SIGN_BYTE_LENGTH]=t[o];return w(a,i,i.length,r)>=0};function u(e){var t=e.message;if(t instanceof Uint8Array||t instanceof c)return t;var n=e.encoding;if(t===void 0)if(e.md)t=e.md.digest().getBytes(),n=`binary`;else throw TypeError(`"options.message" or "options.md" not specified.`);if(typeof t==`string`&&!n)throw TypeError(`"options.encoding" must be "binary" or "utf8".`);if(typeof t==`string`){if(typeof Buffer<`u`)return Buffer.from(t,n);t=new s(t,n)}else if(!(t instanceof s))throw TypeError(`"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.`);for(var r=new c(t.length()),i=0;i<r.length;++i)r[i]=t.at(i);return r}var f=q(),m=q([1]),h=q([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),g=q([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),_=q([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),v=q([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),y=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),b=q([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function x(e,t){var r=n.md.sha512.create(),i=new s(e);r.update(i.getBytes(t),`binary`);var a=r.digest().getBytes();if(typeof Buffer<`u`)return Buffer.from(a,`binary`);for(var o=new c(l.constants.HASH_BYTE_LENGTH),u=0;u<64;++u)o[u]=a.charCodeAt(u);return o}function S(e,t){var n=[q(),q(),q(),q()],r,i=x(t,32);for(i[0]&=248,i[31]&=127,i[31]|=64,B(n,i),j(e,n),r=0;r<32;++r)t[r+32]=e[r];return 0}function C(e,t,n,r){var i,a,o=new Float64Array(64),s=[q(),q(),q(),q()],c=x(r,32);c[0]&=248,c[31]&=127,c[31]|=64;var l=n+64;for(i=0;i<n;++i)e[64+i]=t[i];for(i=0;i<32;++i)e[32+i]=c[32+i];var u=x(e.subarray(32),n+32);for(E(u),B(s,u),j(e,s),i=32;i<64;++i)e[i]=r[i];var d=x(e,n+64);for(E(d),i=32;i<64;++i)o[i]=0;for(i=0;i<32;++i)o[i]=u[i];for(i=0;i<32;++i)for(a=0;a<32;a++)o[i+a]+=d[i]*c[a];return T(e.subarray(32),o),l}function w(e,t,n,r){var i,a,o=new c(32),s=[q(),q(),q(),q()],l=[q(),q(),q(),q()];if(a=-1,n<64||N(l,r))return-1;for(i=0;i<n;++i)e[i]=t[i];for(i=0;i<32;++i)e[i+32]=r[i];var u=x(e,n);if(E(u),z(s,l,u),B(l,t.subarray(32)),D(s,l),j(o,s),n-=64,I(t,0,o,0)){for(i=0;i<n;++i)e[i]=0;return-1}for(i=0;i<n;++i)e[i]=t[i+64];return a=n,a}function T(e,t){var n,r,i,a;for(r=63;r>=32;--r){for(n=0,i=r-32,a=r-12;i<a;++i)t[i]+=n-16*t[r]*y[i-(r-32)],n=t[i]+128>>8,t[i]-=n*256;t[i]+=n,t[r]=0}for(n=0,i=0;i<32;++i)t[i]+=n-(t[31]>>4)*y[i],n=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=n*y[i];for(r=0;r<32;++r)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function E(e){for(var t=new Float64Array(64),n=0;n<64;++n)t[n]=e[n],e[n]=0;T(e,t)}function D(e,t){var n=q(),r=q(),i=q(),a=q(),o=q(),s=q(),c=q(),l=q(),u=q();Y(n,e[1],e[0]),Y(u,t[1],t[0]),Z(n,n,u),J(r,e[0],e[1]),J(u,t[0],t[1]),Z(r,r,u),Z(i,e[3],t[3]),Z(i,i,g),Z(a,e[2],t[2]),J(a,a,a),Y(o,r,n),Y(s,a,i),J(c,a,i),J(l,r,n),Z(e[0],o,s),Z(e[1],l,c),Z(e[2],c,s),Z(e[3],o,l)}function k(e,t,n){for(var r=0;r<4;++r)K(e[r],t[r],n)}function j(e,t){var n=q(),r=q(),i=q();H(i,t[2]),Z(n,t[0],i),Z(r,t[1],i),M(e,r),e[31]^=R(n)<<7}function M(e,t){var n,r,i,a=q(),o=q();for(n=0;n<16;++n)o[n]=t[n];for(U(o),U(o),U(o),r=0;r<2;++r){for(a[0]=o[0]-65517,n=1;n<15;++n)a[n]=o[n]-65535-(a[n-1]>>16&1),a[n-1]&=65535;a[15]=o[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,K(o,a,1-i)}for(n=0;n<16;n++)e[2*n]=o[n]&255,e[2*n+1]=o[n]>>8}function N(e,t){var n=q(),r=q(),i=q(),a=q(),o=q(),s=q(),c=q();return V(e[2],m),P(e[1],t),X(i,e[1]),Z(a,i,h),Y(i,i,e[2]),J(a,e[2],a),X(o,a),X(s,o),Z(c,s,o),Z(n,c,i),Z(n,n,a),ee(n,n),Z(n,n,i),Z(n,n,a),Z(n,n,a),Z(e[0],n,a),X(r,e[0]),Z(r,r,a),F(r,i)&&Z(e[0],e[0],b),X(r,e[0]),Z(r,r,a),F(r,i)?-1:(R(e[0])===t[31]>>7&&Y(e[0],f,e[0]),Z(e[3],e[0],e[1]),0)}function P(e,t){var n;for(n=0;n<16;++n)e[n]=t[2*n]+(t[2*n+1]<<8);e[15]&=32767}function ee(e,t){var n=q(),r;for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)X(n,n),r!==1&&Z(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}function F(e,t){var n=new c(32),r=new c(32);return M(n,e),M(r,t),I(n,0,r,0)}function I(e,t,n,r){return L(e,t,n,r,32)}function L(e,t,n,r,i){var a,o=0;for(a=0;a<i;++a)o|=e[t+a]^n[r+a];return(1&o-1>>>8)-1}function R(e){var t=new c(32);return M(t,e),t[0]&1}function z(e,t,n){var r,i;for(V(e[0],f),V(e[1],m),V(e[2],m),V(e[3],f),i=255;i>=0;--i)r=n[i/8|0]>>(i&7)&1,k(e,t,r),D(t,e),D(e,e),k(e,t,r)}function B(e,t){var n=[q(),q(),q(),q()];V(n[0],_),V(n[1],v),V(n[2],m),Z(n[3],_,v),z(e,n,t)}function V(e,t){var n;for(n=0;n<16;n++)e[n]=t[n]|0}function H(e,t){var n=q(),r;for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)X(n,n),r!==2&&r!==4&&Z(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}function U(e){var t,n,r=1;for(t=0;t<16;++t)n=e[t]+r+65535,r=Math.floor(n/65536),e[t]=n-r*65536;e[0]+=r-1+37*(r-1)}function K(e,t,n){for(var r,i=~(n-1),a=0;a<16;++a)r=i&(e[a]^t[a]),e[a]^=r,t[a]^=r}function q(e){var t,n=new Float64Array(16);if(e)for(t=0;t<e.length;++t)n[t]=e[t];return n}function J(e,t,n){for(var r=0;r<16;++r)e[r]=t[r]+n[r]}function Y(e,t,n){for(var r=0;r<16;++r)e[r]=t[r]-n[r]}function X(e,t){Z(e,t,t)}function Z(e,t,n){var r,i,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0,O=0,k=0,A=0,j=0,M=0,N=0,P=0,ee=0,F=n[0],I=n[1],L=n[2],R=n[3],z=n[4],B=n[5],V=n[6],H=n[7],U=n[8],W=n[9],G=n[10],K=n[11],q=n[12],J=n[13],Y=n[14],X=n[15];r=t[0],a+=r*F,o+=r*I,s+=r*L,c+=r*R,l+=r*z,u+=r*B,d+=r*V,f+=r*H,p+=r*U,m+=r*W,h+=r*G,g+=r*K,_+=r*q,v+=r*J,y+=r*Y,b+=r*X,r=t[1],o+=r*F,s+=r*I,c+=r*L,l+=r*R,u+=r*z,d+=r*B,f+=r*V,p+=r*H,m+=r*U,h+=r*W,g+=r*G,_+=r*K,v+=r*q,y+=r*J,b+=r*Y,x+=r*X,r=t[2],s+=r*F,c+=r*I,l+=r*L,u+=r*R,d+=r*z,f+=r*B,p+=r*V,m+=r*H,h+=r*U,g+=r*W,_+=r*G,v+=r*K,y+=r*q,b+=r*J,x+=r*Y,S+=r*X,r=t[3],c+=r*F,l+=r*I,u+=r*L,d+=r*R,f+=r*z,p+=r*B,m+=r*V,h+=r*H,g+=r*U,_+=r*W,v+=r*G,y+=r*K,b+=r*q,x+=r*J,S+=r*Y,C+=r*X,r=t[4],l+=r*F,u+=r*I,d+=r*L,f+=r*R,p+=r*z,m+=r*B,h+=r*V,g+=r*H,_+=r*U,v+=r*W,y+=r*G,b+=r*K,x+=r*q,S+=r*J,C+=r*Y,w+=r*X,r=t[5],u+=r*F,d+=r*I,f+=r*L,p+=r*R,m+=r*z,h+=r*B,g+=r*V,_+=r*H,v+=r*U,y+=r*W,b+=r*G,x+=r*K,S+=r*q,C+=r*J,w+=r*Y,T+=r*X,r=t[6],d+=r*F,f+=r*I,p+=r*L,m+=r*R,h+=r*z,g+=r*B,_+=r*V,v+=r*H,y+=r*U,b+=r*W,x+=r*G,S+=r*K,C+=r*q,w+=r*J,T+=r*Y,E+=r*X,r=t[7],f+=r*F,p+=r*I,m+=r*L,h+=r*R,g+=r*z,_+=r*B,v+=r*V,y+=r*H,b+=r*U,x+=r*W,S+=r*G,C+=r*K,w+=r*q,T+=r*J,E+=r*Y,D+=r*X,r=t[8],p+=r*F,m+=r*I,h+=r*L,g+=r*R,_+=r*z,v+=r*B,y+=r*V,b+=r*H,x+=r*U,S+=r*W,C+=r*G,w+=r*K,T+=r*q,E+=r*J,D+=r*Y,O+=r*X,r=t[9],m+=r*F,h+=r*I,g+=r*L,_+=r*R,v+=r*z,y+=r*B,b+=r*V,x+=r*H,S+=r*U,C+=r*W,w+=r*G,T+=r*K,E+=r*q,D+=r*J,O+=r*Y,k+=r*X,r=t[10],h+=r*F,g+=r*I,_+=r*L,v+=r*R,y+=r*z,b+=r*B,x+=r*V,S+=r*H,C+=r*U,w+=r*W,T+=r*G,E+=r*K,D+=r*q,O+=r*J,k+=r*Y,A+=r*X,r=t[11],g+=r*F,_+=r*I,v+=r*L,y+=r*R,b+=r*z,x+=r*B,S+=r*V,C+=r*H,w+=r*U,T+=r*W,E+=r*G,D+=r*K,O+=r*q,k+=r*J,A+=r*Y,j+=r*X,r=t[12],_+=r*F,v+=r*I,y+=r*L,b+=r*R,x+=r*z,S+=r*B,C+=r*V,w+=r*H,T+=r*U,E+=r*W,D+=r*G,O+=r*K,k+=r*q,A+=r*J,j+=r*Y,M+=r*X,r=t[13],v+=r*F,y+=r*I,b+=r*L,x+=r*R,S+=r*z,C+=r*B,w+=r*V,T+=r*H,E+=r*U,D+=r*W,O+=r*G,k+=r*K,A+=r*q,j+=r*J,M+=r*Y,N+=r*X,r=t[14],y+=r*F,b+=r*I,x+=r*L,S+=r*R,C+=r*z,w+=r*B,T+=r*V,E+=r*H,D+=r*U,O+=r*W,k+=r*G,A+=r*K,j+=r*q,M+=r*J,N+=r*Y,P+=r*X,r=t[15],b+=r*F,x+=r*I,S+=r*L,C+=r*R,w+=r*z,T+=r*B,E+=r*V,D+=r*H,O+=r*U,k+=r*W,A+=r*G,j+=r*K,M+=r*q,N+=r*J,P+=r*Y,ee+=r*X,a+=38*x,o+=38*S,s+=38*C,c+=38*w,l+=38*T,u+=38*E,d+=38*D,f+=38*O,p+=38*k,m+=38*A,h+=38*j,g+=38*M,_+=38*N,v+=38*P,y+=38*ee,i=1,r=a+i+65535,i=Math.floor(r/65536),a=r-i*65536,r=o+i+65535,i=Math.floor(r/65536),o=r-i*65536,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=d+i+65535,i=Math.floor(r/65536),d=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=m+i+65535,i=Math.floor(r/65536),m=r-i*65536,r=h+i+65535,i=Math.floor(r/65536),h=r-i*65536,r=g+i+65535,i=Math.floor(r/65536),g=r-i*65536,r=_+i+65535,i=Math.floor(r/65536),_=r-i*65536,r=v+i+65535,i=Math.floor(r/65536),v=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=b+i+65535,i=Math.floor(r/65536),b=r-i*65536,a+=i-1+37*(i-1),i=1,r=a+i+65535,i=Math.floor(r/65536),a=r-i*65536,r=o+i+65535,i=Math.floor(r/65536),o=r-i*65536,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=c+i+65535,i=Math.floor(r/65536),c=r-i*65536,r=l+i+65535,i=Math.floor(r/65536),l=r-i*65536,r=u+i+65535,i=Math.floor(r/65536),u=r-i*65536,r=d+i+65535,i=Math.floor(r/65536),d=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=p+i+65535,i=Math.floor(r/65536),p=r-i*65536,r=m+i+65535,i=Math.floor(r/65536),m=r-i*65536,r=h+i+65535,i=Math.floor(r/65536),h=r-i*65536,r=g+i+65535,i=Math.floor(r/65536),g=r-i*65536,r=_+i+65535,i=Math.floor(r/65536),_=r-i*65536,r=v+i+65535,i=Math.floor(r/65536),v=r-i*65536,r=y+i+65535,i=Math.floor(r/65536),y=r-i*65536,r=b+i+65535,i=Math.floor(r/65536),b=r-i*65536,a+=i-1+37*(i-1),e[0]=a,e[1]=o,e[2]=s,e[3]=c,e[4]=l,e[5]=u,e[6]=d,e[7]=f,e[8]=p,e[9]=m,e[10]=h,e[11]=g,e[12]=_,e[13]=v,e[14]=y,e[15]=b}})),q=o(((e,t)=>{var n=d();p(),O(),A(),t.exports=n.kem=n.kem||{};var r=n.jsbn.BigInteger;n.kem.rsa={},n.kem.rsa.create=function(e,t){t||={};var i=t.prng||n.random,a={};return a.encrypt=function(t,a){var o=Math.ceil(t.n.bitLength()/8),s;do s=new r(n.util.bytesToHex(i.getBytesSync(o)),16).mod(t.n);while(s.compareTo(r.ONE)<=0);s=n.util.hexToBytes(s.toString(16));var c=o-s.length;return c>0&&(s=n.util.fillString(`\0`,c)+s),{encapsulation:t.encrypt(s,`NONE`),key:e.generate(s,a)}},a.decrypt=function(t,n,r){var i=t.decrypt(n,`NONE`);return e.generate(i,r)},a},n.kem.kdf1=function(e,t){i(this,e,0,t||e.digestLength)},n.kem.kdf2=function(e,t){i(this,e,1,t||e.digestLength)};function i(e,t,r,i){e.generate=function(e,a){for(var o=new n.util.ByteBuffer,s=Math.ceil(a/i)+r,c=new n.util.ByteBuffer,l=r;l<s;++l){c.putInt32(l),t.start(),t.update(e+c.getBytes());var u=t.digest();o.putBytes(u.getBytes(i))}return o.truncate(o.length()-a),o.getBytes()}}})),J=o(((e,t)=>{var n=d();p(),t.exports=n.log=n.log||{},n.log.levels=[`none`,`error`,`warning`,`info`,`debug`,`verbose`,`max`];var r={},i=[],a=null;n.log.LEVEL_LOCKED=2,n.log.NO_LEVEL_CHECK=4,n.log.INTERPOLATE=8;for(var o=0;o<n.log.levels.length;++o){var s=n.log.levels[o];r[s]={index:o,name:s.toUpperCase()}}n.log.logMessage=function(e){for(var t=r[e.level].index,a=0;a<i.length;++a){var o=i[a];o.flags&n.log.NO_LEVEL_CHECK?o.f(e):t<=r[o.level].index&&o.f(o,e)}},n.log.prepareStandard=function(e){`standard`in e||(e.standard=r[e.level].name+` [`+e.category+`] `+e.message)},n.log.prepareFull=function(e){if(!(`full`in e)){var t=[e.message];t=t.concat([]),e.full=n.util.format.apply(this,t)}},n.log.prepareStandardFull=function(e){`standardFull`in e||(n.log.prepareStandard(e),e.standardFull=e.standard)};for(var c=[`error`,`warning`,`info`,`debug`,`verbose`],o=0;o<c.length;++o)(function(e){n.log[e]=function(t,r){var i=Array.prototype.slice.call(arguments).slice(2),a={timestamp:new Date,level:e,category:t,message:r,arguments:i};n.log.logMessage(a)}})(c[o]);if(n.log.makeLogger=function(e){var t={flags:0,f:e};return n.log.setLevel(t,`none`),t},n.log.setLevel=function(e,t){var r=!1;if(e&&!(e.flags&n.log.LEVEL_LOCKED)){for(var i=0;i<n.log.levels.length;++i)if(t==n.log.levels[i]){e.level=t,r=!0;break}}return r},n.log.lock=function(e,t){t===void 0||t?e.flags|=n.log.LEVEL_LOCKED:e.flags&=~n.log.LEVEL_LOCKED},n.log.addLogger=function(e){i.push(e)},typeof console<`u`&&`log`in console){var l;if(console.error&&console.warn&&console.info&&console.debug){var u={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},f=function(e,t){n.log.prepareStandard(t);var r=u[t.level],i=[t.standard];i=i.concat(t.arguments.slice()),r.apply(console,i)};l=n.log.makeLogger(f)}else{var f=function(e,t){n.log.prepareStandardFull(t),console.log(t.standardFull)};l=n.log.makeLogger(f)}n.log.setLevel(l,`debug`),n.log.addLogger(l),a=l}else console={log:function(){}};if(a!==null&&typeof window<`u`&&window.location){var m=new URL(window.location.href).searchParams;m.has(`console.level`)&&n.log.setLevel(a,m.get(`console.level`).slice(-1)[0]),m.has(`console.lock`)&&m.get(`console.lock`).slice(-1)[0]==`true`&&n.log.lock(a)}n.log.consoleLogger=a})),Y=o(((e,t)=>{t.exports=y(),x(),j(),E(),W()})),X=o(((e,t)=>{var n=d();g(),v(),C(),_(),S(),F(),O(),p(),z();var r=n.asn1,i=t.exports=n.pkcs7=n.pkcs7||{};i.messageFromPem=function(e){var t=n.pem.decode(e)[0];if(t.type!==`PKCS7`){var a=Error(`Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".`);throw a.headerType=t.type,a}if(t.procType&&t.procType.type===`ENCRYPTED`)throw Error(`Could not convert PKCS#7 message from PEM; PEM is encrypted.`);var o=r.fromDer(t.body);return i.messageFromAsn1(o)},i.messageToPem=function(e,t){var i={type:`PKCS7`,body:r.toDer(e.toAsn1()).getBytes()};return n.pem.encode(i,{maxline:t})},i.messageFromAsn1=function(e){var t={},a=[];if(!r.validate(e,i.asn1.contentInfoValidator,t,a)){var o=Error(`Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.`);throw o.errors=a,o}var s=r.derToOid(t.contentType),c;switch(s){case n.pki.oids.envelopedData:c=i.createEnvelopedData();break;case n.pki.oids.encryptedData:c=i.createEncryptedData();break;case n.pki.oids.signedData:c=i.createSignedData();break;default:throw Error(`Cannot read PKCS#7 message. ContentType with OID `+s+` is not (yet) supported.`)}return c.fromAsn1(t.content.value[0]),c},i.createSignedData=function(){var e=null;return e={type:n.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){if(h(e,t,i.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var r=e.rawCapture.certificates.value,a=0;a<r.length;++a)e.certificates.push(n.pki.certificateFromAsn1(r[a]))},toAsn1:function(){e.contentInfo||e.sign();for(var t=[],i=0;i<e.certificates.length;++i)t.push(n.pki.certificateToAsn1(e.certificates[i]));var a=[],o=r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(e.version).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return t.length>0&&o.value[0].value.push(r.create(r.Class.CONTEXT_SPECIFIC,0,!0,t)),a.length>0&&o.value[0].value.push(r.create(r.Class.CONTEXT_SPECIFIC,1,!0,a)),o.value[0].value.push(r.create(r.Class.UNIVERSAL,r.Type.SET,!0,e.signerInfos)),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.type).getBytes()),o])},addSigner:function(t){var r=t.issuer,i=t.serialNumber;if(t.certificate){var a=t.certificate;typeof a==`string`&&(a=n.pki.certificateFromPem(a)),r=a.issuer.attributes,i=a.serialNumber}var o=t.key;if(!o)throw Error(`Could not add PKCS#7 signer; no private key specified.`);typeof o==`string`&&(o=n.pki.privateKeyFromPem(o));var s=t.digestAlgorithm||n.pki.oids.sha1;switch(s){case n.pki.oids.sha1:case n.pki.oids.sha256:case n.pki.oids.sha384:case n.pki.oids.sha512:case n.pki.oids.md5:break;default:throw Error(`Could not add PKCS#7 signer; unknown message digest algorithm: `+s)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var l=!1,u=!1,d=0;d<c.length;++d){var f=c[d];if(!l&&f.type===n.pki.oids.contentType){if(l=!0,u)break;continue}if(!u&&f.type===n.pki.oids.messageDigest){if(u=!0,l)break;continue}}if(!l||!u)throw Error(`Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.`)}e.signers.push({key:o,version:1,issuer:r,serialNumber:i,digestAlgorithm:s,signatureAlgorithm:n.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:c,unauthenticatedAttributes:[]})},sign:function(i){if(i||={},(typeof e.content!=`object`||e.contentInfo===null)&&(e.contentInfo=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(n.pki.oids.data).getBytes())]),`content`in e)){var o;e.content instanceof n.util.ByteBuffer?o=e.content.bytes():typeof e.content==`string`&&(o=n.util.encodeUtf8(e.content)),i.detached?e.detachedContent=r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,o):e.contentInfo.value.push(r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,o)]))}e.signers.length!==0&&a(t())},verify:function(){throw Error(`PKCS#7 signature verification not yet implemented.`)},addCertificate:function(t){typeof t==`string`&&(t=n.pki.certificateFromPem(t)),e.certificates.push(t)},addCertificateRevokationList:function(e){throw Error(`PKCS#7 CRL support not yet implemented.`)}},e;function t(){for(var t={},i=0;i<e.signers.length;++i){var a=e.signers[i],o=a.digestAlgorithm;o in t||(t[o]=n.md[n.pki.oids[o]].create()),a.authenticatedAttributes.length===0?a.md=t[o]:a.md=n.md[n.pki.oids[o]].create()}for(var o in e.digestAlgorithmIdentifiers=[],t)e.digestAlgorithmIdentifiers.push(r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(o).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,``)]));return t}function a(t){var i;if(e.detachedContent?i=e.detachedContent:(i=e.contentInfo.value[1],i=i.value[0]),!i)throw Error(`Could not sign PKCS#7 message; there is no content to sign.`);var a=r.derToOid(e.contentInfo.value[0].value),o=r.toDer(i);for(var s in o.getByte(),r.getBerValueLength(o),o=o.getBytes(),t)t[s].start().update(o);for(var c=new Date,l=0;l<e.signers.length;++l){var d=e.signers[l];if(d.authenticatedAttributes.length===0){if(a!==n.pki.oids.data)throw Error(`Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.`)}else{d.authenticatedAttributesAsn1=r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var p=r.create(r.Class.UNIVERSAL,r.Type.SET,!0,[]),m=0;m<d.authenticatedAttributes.length;++m){var h=d.authenticatedAttributes[m];h.type===n.pki.oids.messageDigest?h.value=t[d.digestAlgorithm].digest():h.type===n.pki.oids.signingTime&&(h.value||=c),p.value.push(f(h)),d.authenticatedAttributesAsn1.value.push(f(h))}o=r.toDer(p).getBytes(),d.md.start().update(o)}d.signature=d.key.sign(d.md,`RSASSA-PKCS1-V1_5`)}e.signerInfos=u(e.signers)}},i.createEncryptedData=function(){var e=null;return e={type:n.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:n.pki.oids[`aes256-CBC`]},fromAsn1:function(t){h(e,t,i.asn1.encryptedDataValidator)},decrypt:function(t){t!==void 0&&(e.encryptedContent.key=t),y(e)}},e},i.createEnvelopedData=function(){var e=null;return e={type:n.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:n.pki.oids[`aes256-CBC`]},fromAsn1:function(t){var n=h(e,t,i.asn1.envelopedDataValidator);e.recipients=s(n.recipientInfos.value)},toAsn1:function(){return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.type).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(e.version).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SET,!0,c(e.recipients)),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,m(e.encryptedContent))])])])},findRecipient:function(t){for(var n=t.issuer.attributes,r=0;r<e.recipients.length;++r){var i=e.recipients[r],a=i.issuer;if(i.serialNumber===t.serialNumber&&a.length===n.length){for(var o=!0,s=0;s<n.length;++s)if(a[s].type!==n[s].type||a[s].value!==n[s].value){o=!1;break}if(o)return i}}return null},decrypt:function(t,r){if(e.encryptedContent.key===void 0&&t!==void 0&&r!==void 0)switch(t.encryptedContent.algorithm){case n.pki.oids.rsaEncryption:case n.pki.oids.desCBC:var i=r.decrypt(t.encryptedContent.content);e.encryptedContent.key=n.util.createBuffer(i);break;default:throw Error(`Unsupported asymmetric cipher, OID `+t.encryptedContent.algorithm)}y(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:n.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(e.encryptedContent.content===void 0){r||=e.encryptedContent.algorithm,t||=e.encryptedContent.key;var i,a,o;switch(r){case n.pki.oids[`aes128-CBC`]:i=16,a=16,o=n.aes.createEncryptionCipher;break;case n.pki.oids[`aes192-CBC`]:i=24,a=16,o=n.aes.createEncryptionCipher;break;case n.pki.oids[`aes256-CBC`]:i=32,a=16,o=n.aes.createEncryptionCipher;break;case n.pki.oids[`des-EDE3-CBC`]:i=24,a=8,o=n.des.createEncryptionCipher;break;default:throw Error(`Unsupported symmetric cipher, OID `+r)}if(t===void 0)t=n.util.createBuffer(n.random.getBytes(i));else if(t.length()!=i)throw Error(`Symmetric key has wrong length; got `+t.length()+` bytes, expected `+i+`.`);e.encryptedContent.algorithm=r,e.encryptedContent.key=t,e.encryptedContent.parameter=n.util.createBuffer(n.random.getBytes(a));var s=o(t);if(s.start(e.encryptedContent.parameter.copy()),s.update(e.content),!s.finish())throw Error(`Symmetric encryption failed.`);e.encryptedContent.content=s.output}for(var c=0;c<e.recipients.length;++c){var l=e.recipients[c];if(l.encryptedContent.content===void 0)switch(l.encryptedContent.algorithm){case n.pki.oids.rsaEncryption:l.encryptedContent.content=l.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw Error(`Unsupported asymmetric cipher, OID `+l.encryptedContent.algorithm)}}}},e};function a(e){var t={},a=[];if(!r.validate(e,i.asn1.recipientInfoValidator,t,a)){var o=Error(`Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.`);throw o.errors=a,o}return{version:t.version.charCodeAt(0),issuer:n.pki.RDNAttributesAsArray(t.issuer),serialNumber:n.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:r.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function o(e){return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(e.version).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[n.pki.distinguishedNameToAsn1({attributes:e.issuer}),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,n.util.hexToBytes(e.serialNumber))]),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.encryptedContent.algorithm).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,``)]),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function s(e){for(var t=[],n=0;n<e.length;++n)t.push(a(e[n]));return t}function c(e){for(var t=[],n=0;n<e.length;++n)t.push(o(e[n]));return t}function l(e){var t=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(e.version).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[n.pki.distinguishedNameToAsn1({attributes:e.issuer}),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,n.util.hexToBytes(e.serialNumber))]),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.digestAlgorithm).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,``)])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.signatureAlgorithm).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,``)])),t.value.push(r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var i=r.create(r.Class.CONTEXT_SPECIFIC,1,!0,[]),a=0;a<e.unauthenticatedAttributes.length;++a){var o=e.unauthenticatedAttributes[a];i.values.push(f(o))}t.value.push(i)}return t}function u(e){for(var t=[],n=0;n<e.length;++n)t.push(l(e[n]));return t}function f(e){var t;if(e.type===n.pki.oids.contentType)t=r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.value).getBytes());else if(e.type===n.pki.oids.messageDigest)t=r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===n.pki.oids.signingTime){var i=new Date(`1950-01-01T00:00:00Z`),a=new Date(`2050-01-01T00:00:00Z`),o=e.value;if(typeof o==`string`){var s=Date.parse(o);o=isNaN(s)?o.length===13?r.utcTimeToDate(o):r.generalizedTimeToDate(o):new Date(s)}t=o>=i&&o<a?r.create(r.Class.UNIVERSAL,r.Type.UTCTIME,!1,r.dateToUtcTime(o)):r.create(r.Class.UNIVERSAL,r.Type.GENERALIZEDTIME,!1,r.dateToGeneralizedTime(o))}return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.type).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SET,!0,[t])])}function m(e){return[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(n.pki.oids.data).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.algorithm).getBytes()),e.parameter?r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,e.parameter.getBytes()):void 0]),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,e.content.getBytes())])]}function h(e,t,i){var a={};if(!r.validate(t,i,a,[])){var o=Error(`Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.`);throw o.errors=o,o}if(r.derToOid(a.contentType)!==n.pki.oids.data)throw Error(`Unsupported PKCS#7 message. Only wrapped ContentType Data supported.`);if(a.encryptedContent){var s=``;if(n.util.isArray(a.encryptedContent))for(var c=0;c<a.encryptedContent.length;++c){if(a.encryptedContent[c].type!==r.Type.OCTETSTRING)throw Error(`Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.`);s+=a.encryptedContent[c].value}else s=a.encryptedContent;e.encryptedContent={algorithm:r.derToOid(a.encAlgorithm),parameter:n.util.createBuffer(a.encParameter.value),content:n.util.createBuffer(s)}}if(a.content){var s=``;if(n.util.isArray(a.content))for(var c=0;c<a.content.length;++c){if(a.content[c].type!==r.Type.OCTETSTRING)throw Error(`Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.`);s+=a.content[c].value}else s=a.content;e.content=n.util.createBuffer(s)}return e.version=a.version.charCodeAt(0),e.rawCapture=a,a}function y(e){if(e.encryptedContent.key===void 0)throw Error(`Symmetric key not available.`);if(e.content===void 0){var t;switch(e.encryptedContent.algorithm){case n.pki.oids[`aes128-CBC`]:case n.pki.oids[`aes192-CBC`]:case n.pki.oids[`aes256-CBC`]:t=n.aes.createDecryptionCipher(e.encryptedContent.key);break;case n.pki.oids.desCBC:case n.pki.oids[`des-EDE3-CBC`]:t=n.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw Error(`Unsupported symmetric cipher, OID `+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw Error(`Symmetric decryption failed.`);e.content=t.output}}})),Z=o(((e,t)=>{var n=d();g(),b(),x(),j(),p();var r=t.exports=n.ssh=n.ssh||{};r.privateKeyToPutty=function(e,t,r){r||=``,t||=``;var s=`ssh-rsa`,c=t===``?`none`:`aes256-cbc`,l=`PuTTY-User-Key-File-2: `+s+`\r
15
+ `;l+=`Encryption: `+c+`\r
16
+ `,l+=`Comment: `+r+`\r
17
+ `;var u=n.util.createBuffer();a(u,s),i(u,e.e),i(u,e.n);var d=n.util.encode64(u.bytes(),64),f=Math.floor(d.length/66)+1;l+=`Public-Lines: `+f+`\r
18
+ `,l+=d;var p=n.util.createBuffer();i(p,e.d),i(p,e.p),i(p,e.q),i(p,e.qInv);var m;if(!t)m=n.util.encode64(p.bytes(),64);else{var h=p.length()+16-1;h-=h%16;var g=o(p.bytes());g.truncate(g.length()-h+p.length()),p.putBuffer(g);var _=n.util.createBuffer();_.putBuffer(o(`\0\0\0\0`,t)),_.putBuffer(o(`\0\0\0`,t));var v=n.aes.createEncryptionCipher(_.truncate(8),`CBC`);v.start(n.util.createBuffer().fillWithByte(0,16)),v.update(p.copy()),v.finish();var y=v.output;y.truncate(16),m=n.util.encode64(y.bytes(),64)}f=Math.floor(m.length/66)+1,l+=`\r
19
+ Private-Lines: `+f+`\r
20
+ `,l+=m;var b=o(`putty-private-key-file-mac-key`,t),x=n.util.createBuffer();a(x,s),a(x,c),a(x,r),x.putInt32(u.length()),x.putBuffer(u),x.putInt32(p.length()),x.putBuffer(p);var S=n.hmac.create();return S.start(`sha1`,b),S.update(x.bytes()),l+=`\r
21
+ Private-MAC: `+S.digest().toHex()+`\r
22
+ `,l},r.publicKeyToOpenSSH=function(e,t){var r=`ssh-rsa`;t||=``;var o=n.util.createBuffer();return a(o,r),i(o,e.e),i(o,e.n),r+` `+n.util.encode64(o.bytes())+` `+t},r.privateKeyToOpenSSH=function(e,t){return t?n.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:`aes128`}):n.pki.privateKeyToPem(e)},r.getPublicKeyFingerprint=function(e,t){t||={};var r=t.md||n.md.md5.create(),o=`ssh-rsa`,s=n.util.createBuffer();a(s,o),i(s,e.e),i(s,e.n),r.start(),r.update(s.getBytes());var c=r.digest();if(t.encoding===`hex`){var l=c.toHex();return t.delimiter?l.match(/.{2}/g).join(t.delimiter):l}else if(t.encoding===`binary`)return c.getBytes();else if(t.encoding)throw Error(`Unknown encoding "`+t.encoding+`".`);return c};function i(e,t){var r=t.toString(16);r[0]>=`8`&&(r=`00`+r);var i=n.util.hexToBytes(r);e.putInt32(i.length),e.putBytes(i)}function a(e,t){e.putInt32(t.length),e.putString(t)}function o(){for(var e=n.md.sha1.create(),t=arguments.length,r=0;r<t;++r)e.update(arguments[r]);return e.digest()}})),te=c(o(((e,t)=>{t.exports=d(),g(),U(),v(),m(),C(),K(),b(),q(),J(),Y(),I(),T(),S(),M(),B(),X(),V(),N(),D(),R(),O(),k(),Z(),H(),p()}))(),1),{entries:ne,setPrototypeOf:re,isFrozen:ie,getPrototypeOf:ae,getOwnPropertyDescriptor:oe}=Object,{freeze:se,seal:ce,create:le}=Object,{apply:ue,construct:de}=typeof Reflect<`u`&&Reflect;se||=function(e){return e},ce||=function(e){return e},ue||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},de||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var fe=Q(Array.prototype.forEach),pe=Q(Array.prototype.lastIndexOf),me=Q(Array.prototype.pop),he=Q(Array.prototype.push),ge=Q(Array.prototype.splice),_e=Q(String.prototype.toLowerCase),ve=Q(String.prototype.toString),ye=Q(String.prototype.match),be=Q(String.prototype.replace),xe=Q(String.prototype.indexOf),Se=Q(String.prototype.trim),Ce=Q(Object.prototype.hasOwnProperty),we=Q(RegExp.prototype.test),Te=Ee(TypeError);function Q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return ue(e,t,r)}}function Ee(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return de(e,n)}}function $(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_e;re&&re(e,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ie(t)||(t[r]=e),i=e)}e[i]=!0}return e}function De(e){for(let t=0;t<e.length;t++)Ce(e,t)||(e[t]=null);return e}function Oe(e){let t=le(null);for(let[n,r]of ne(e))Ce(e,n)&&(Array.isArray(r)?t[n]=De(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=Oe(r):t[n]=r);return t}function ke(e,t){for(;e!==null;){let n=oe(e,t);if(n){if(n.get)return Q(n.get);if(typeof n.value==`function`)return Q(n.value)}e=ae(e)}function n(){return null}return n}var Ae=se(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),je=se(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Me=se([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Ne=se([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Pe=se(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Fe=se([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Ie=se([`#text`]),Le=se(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns.slot`.split(`.`)),Re=se(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),ze=se(`accent.accentunder.align.bevelled.close.columnsalign.columnlines.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lspace.lquote.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Be=se([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ve=ce(/\{\{[\w\W]*|[\w\W]*\}\}/gm),He=ce(/<%[\w\W]*|[\w\W]*%>/gm),Ue=ce(/\$\{[\w\W]*/gm),We=ce(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ge=ce(/^aria-[\-\w]+$/),Ke=ce(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qe=ce(/^(?:\w+script|data):/i),Je=ce(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ye=ce(/^html$/i),Xe=ce(/^[a-z][.\w]*(-[.\w]+)+$/i),Ze=Object.freeze({__proto__:null,ARIA_ATTR:Ge,ATTR_WHITESPACE:Je,CUSTOM_ELEMENT:Xe,DATA_ATTR:We,DOCTYPE_NAME:Ye,ERB_EXPR:He,IS_ALLOWED_URI:Ke,IS_SCRIPT_OR_DATA:qe,MUSTACHE_EXPR:Ve,TMPLIT_EXPR:Ue}),Qe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},$e=function(){return typeof window>`u`?null:window},et=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},tt=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function nt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:$e(),t=e=>nt(e);if(t.version=`3.3.3`,t.removed=[],!e||!e.document||e.document.nodeType!==Qe.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=ke(m,`cloneNode`),g=ke(m,`remove`),_=ke(m,`nextSibling`),v=ke(m,`childNodes`),y=ke(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,x=``,{implementation:S,createNodeIterator:C,createDocumentFragment:w,getElementsByTagName:T}=n,{importNode:E}=r,D=tt();t.isSupported=typeof ne==`function`&&typeof y==`function`&&S&&S.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:O,ERB_EXPR:k,TMPLIT_EXPR:A,DATA_ATTR:j,ARIA_ATTR:M,IS_SCRIPT_OR_DATA:N,ATTR_WHITESPACE:P,CUSTOM_ELEMENT:ee}=Ze,{IS_ALLOWED_URI:F}=Ze,I=null,L=$({},[...Ae,...je,...Me,...Pe,...Ie]),R=null,z=$({},[...Le,...Re,...ze,...Be]),B=Object.seal(le(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,H=null,U=Object.seal(le(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),W=!0,G=!0,K=!1,q=!0,J=!1,Y=!0,X=!1,Z=!1,te=!1,re=!1,ie=!1,ae=!1,oe=!0,ce=!1,ue=!0,de=!1,Q={},Ee=null,De=$({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),Ve=null,He=$({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ue=null,We=$({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ge=`http://www.w3.org/1998/Math/MathML`,qe=`http://www.w3.org/2000/svg`,Je=`http://www.w3.org/1999/xhtml`,Xe=Je,rt=!1,it=null,at=$({},[Ge,qe,Je],ve),ot=$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),st=$({},[`annotation-xml`]),ct=$({},[`title`,`style`,`font`,`a`,`script`]),lt=null,ut=[`application/xhtml+xml`,`text/html`],dt=null,ft=null,pt=n.createElement(`form`),mt=function(e){return e instanceof RegExp||e instanceof Function},ht=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(ft&&ft===e)){if((!e||typeof e!=`object`)&&(e={}),e=Oe(e),lt=ut.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,dt=lt===`application/xhtml+xml`?ve:_e,I=Ce(e,`ALLOWED_TAGS`)?$({},e.ALLOWED_TAGS,dt):L,R=Ce(e,`ALLOWED_ATTR`)?$({},e.ALLOWED_ATTR,dt):z,it=Ce(e,`ALLOWED_NAMESPACES`)?$({},e.ALLOWED_NAMESPACES,ve):at,Ue=Ce(e,`ADD_URI_SAFE_ATTR`)?$(Oe(We),e.ADD_URI_SAFE_ATTR,dt):We,Ve=Ce(e,`ADD_DATA_URI_TAGS`)?$(Oe(He),e.ADD_DATA_URI_TAGS,dt):He,Ee=Ce(e,`FORBID_CONTENTS`)?$({},e.FORBID_CONTENTS,dt):De,V=Ce(e,`FORBID_TAGS`)?$({},e.FORBID_TAGS,dt):Oe({}),H=Ce(e,`FORBID_ATTR`)?$({},e.FORBID_ATTR,dt):Oe({}),Q=Ce(e,`USE_PROFILES`)?e.USE_PROFILES:!1,W=e.ALLOW_ARIA_ATTR!==!1,G=e.ALLOW_DATA_ATTR!==!1,K=e.ALLOW_UNKNOWN_PROTOCOLS||!1,q=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,J=e.SAFE_FOR_TEMPLATES||!1,Y=e.SAFE_FOR_XML!==!1,X=e.WHOLE_DOCUMENT||!1,re=e.RETURN_DOM||!1,ie=e.RETURN_DOM_FRAGMENT||!1,ae=e.RETURN_TRUSTED_TYPE||!1,te=e.FORCE_BODY||!1,oe=e.SANITIZE_DOM!==!1,ce=e.SANITIZE_NAMED_PROPS||!1,ue=e.KEEP_CONTENT!==!1,de=e.IN_PLACE||!1,F=e.ALLOWED_URI_REGEXP||Ke,Xe=e.NAMESPACE||Je,ot=e.MATHML_TEXT_INTEGRATION_POINTS||ot,st=e.HTML_INTEGRATION_POINTS||st,B=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&mt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&mt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(B.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),J&&(G=!1),ie&&(re=!0),Q&&(I=$({},Ie),R=le(null),Q.html===!0&&($(I,Ae),$(R,Le)),Q.svg===!0&&($(I,je),$(R,Re),$(R,Be)),Q.svgFilters===!0&&($(I,Me),$(R,Re),$(R,Be)),Q.mathMl===!0&&($(I,Pe),$(R,ze),$(R,Be))),Ce(e,`ADD_TAGS`)||(U.tagCheck=null),Ce(e,`ADD_ATTR`)||(U.attributeCheck=null),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?U.tagCheck=e.ADD_TAGS:(I===L&&(I=Oe(I)),$(I,e.ADD_TAGS,dt))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?U.attributeCheck=e.ADD_ATTR:(R===z&&(R=Oe(R)),$(R,e.ADD_ATTR,dt))),e.ADD_URI_SAFE_ATTR&&$(Ue,e.ADD_URI_SAFE_ATTR,dt),e.FORBID_CONTENTS&&(Ee===De&&(Ee=Oe(Ee)),$(Ee,e.FORBID_CONTENTS,dt)),e.ADD_FORBID_CONTENTS&&(Ee===De&&(Ee=Oe(Ee)),$(Ee,e.ADD_FORBID_CONTENTS,dt)),ue&&(I[`#text`]=!0),X&&$(I,[`html`,`head`,`body`]),I.table&&($(I,[`tbody`]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Te(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Te(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);b=e.TRUSTED_TYPES_POLICY,x=b.createHTML(``)}else b===void 0&&(b=et(p,i)),b!==null&&typeof x==`string`&&(x=b.createHTML(``));se&&se(e),ft=e}},gt=$({},[...je,...Me,...Ne]),_t=$({},[...Pe,...Fe]),vt=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:Xe,tagName:`template`});let n=_e(e.tagName),r=_e(t.tagName);return it[e.namespaceURI]?e.namespaceURI===qe?t.namespaceURI===Je?n===`svg`:t.namespaceURI===Ge?n===`svg`&&(r===`annotation-xml`||ot[r]):!!gt[n]:e.namespaceURI===Ge?t.namespaceURI===Je?n===`math`:t.namespaceURI===qe?n===`math`&&st[r]:!!_t[n]:e.namespaceURI===Je?t.namespaceURI===qe&&!st[r]||t.namespaceURI===Ge&&!ot[r]?!1:!_t[n]&&(ct[n]||!gt[n]):!!(lt===`application/xhtml+xml`&&it[e.namespaceURI]):!1},yt=function(e){he(t.removed,{element:e});try{y(e).removeChild(e)}catch{g(e)}},bt=function(e,n){try{he(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{he(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(re||ie)try{yt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},xt=function(e){let t=null,r=null;if(te)e=`<remove></remove>`+e;else{let t=ye(e,/^[\r\n\t ]+/);r=t&&t[0]}lt===`application/xhtml+xml`&&Xe===Je&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?b.createHTML(e):e;if(Xe===Je)try{t=new f().parseFromString(i,lt)}catch{}if(!t||!t.documentElement){t=S.createDocument(Xe,`template`,null);try{t.documentElement.innerHTML=rt?x:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Xe===Je?T.call(t,X?`html`:`body`)[0]:X?t.documentElement:a},St=function(e){return C.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ct=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},wt=function(e){return typeof s==`function`&&e instanceof s};function Tt(e,n,r){fe(e,e=>{e.call(t,n,r,ft)})}let Et=function(e){let n=null;if(Tt(D.beforeSanitizeElements,e,null),Ct(e))return yt(e),!0;let r=dt(e.nodeName);if(Tt(D.uponSanitizeElement,e,{tagName:r,allowedTags:I}),Y&&e.hasChildNodes()&&!wt(e.firstElementChild)&&we(/<[/\w!]/g,e.innerHTML)&&we(/<[/\w!]/g,e.textContent)||e.nodeType===Qe.progressingInstruction||Y&&e.nodeType===Qe.comment&&we(/<[/\w]/g,e.data))return yt(e),!0;if(!(U.tagCheck instanceof Function&&U.tagCheck(r))&&(!I[r]||V[r])){if(!V[r]&&Ot(r)&&(B.tagNameCheck instanceof RegExp&&we(B.tagNameCheck,r)||B.tagNameCheck instanceof Function&&B.tagNameCheck(r)))return!1;if(ue&&!Ee[r]){let t=y(e)||e.parentNode,n=v(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,_(e))}}}return yt(e),!0}return e instanceof c&&!vt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&we(/<\/no(script|embed|frames)/i,e.innerHTML)?(yt(e),!0):(J&&e.nodeType===Qe.text&&(n=e.textContent,fe([O,k,A],e=>{n=be(n,e,` `)}),e.textContent!==n&&(he(t.removed,{element:e.cloneNode()}),e.textContent=n)),Tt(D.afterSanitizeElements,e,null),!1)},Dt=function(e,t,r){if(H[t]||oe&&(t===`id`||t===`name`)&&(r in n||r in pt))return!1;if(!(G&&!H[t]&&we(j,t))&&!(W&&we(M,t))&&!(U.attributeCheck instanceof Function&&U.attributeCheck(t,e))){if(!R[t]||H[t]){if(!(Ot(e)&&(B.tagNameCheck instanceof RegExp&&we(B.tagNameCheck,e)||B.tagNameCheck instanceof Function&&B.tagNameCheck(e))&&(B.attributeNameCheck instanceof RegExp&&we(B.attributeNameCheck,t)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(t,e))||t===`is`&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&we(B.tagNameCheck,r)||B.tagNameCheck instanceof Function&&B.tagNameCheck(r))))return!1}else if(!Ue[t]&&!we(F,be(r,P,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&xe(r,`data:`)===0&&Ve[e])&&!(K&&!we(N,be(r,P,``)))&&r)return!1}return!0},Ot=function(e){return e!==`annotation-xml`&&ye(e,ee)},kt=function(e){Tt(D.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||Ct(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=dt(a),l=s,u=a===`value`?l:Se(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,Tt(D.uponSanitizeAttribute,e,r),u=r.attrValue,ce&&(c===`id`||c===`name`)&&(bt(a,e),u=`user-content-`+u),Y&&we(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){bt(a,e);continue}if(c===`attributename`&&ye(u,`href`)){bt(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){bt(a,e);continue}if(!q&&we(/\/>/i,u)){bt(a,e);continue}J&&fe([O,k,A],e=>{u=be(u,e,` `)});let d=dt(e.nodeName);if(!Dt(d,c,u)){bt(a,e);continue}if(b&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=b.createHTML(u);break;case`TrustedScriptURL`:u=b.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),Ct(e)?yt(e):me(t.removed)}catch{bt(a,e)}}Tt(D.afterSanitizeAttributes,e,null)},At=function e(t){let n=null,r=St(t);for(Tt(D.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)Tt(D.uponSanitizeShadowNode,n,null),Et(n),kt(n),n.content instanceof a&&e(n.content);Tt(D.afterSanitizeShadowDOM,t,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(rt=!e,rt&&(e=`<!-->`),typeof e!=`string`&&!wt(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw Te(`dirty is not a string, aborting`)}else throw Te(`toString is not a function`);if(!t.isSupported)return e;if(Z||ht(n),t.removed=[],typeof e==`string`&&(de=!1),de){if(e.nodeName){let t=dt(e.nodeName);if(!I[t]||V[t])throw Te(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=xt(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===Qe.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!re&&!J&&!X&&e.indexOf(`<`)===-1)return b&&ae?b.createHTML(e):e;if(i=xt(e),!i)return re?null:ae?x:``}i&&te&&yt(i.firstChild);let u=St(de?e:i);for(;c=u.nextNode();)Et(c),kt(c),c.content instanceof a&&At(c.content);if(de)return e;if(re){if(ie)for(l=w.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(R.shadowroot||R.shadowrootmode)&&(l=E.call(r,l,!0)),l}let d=X?i.outerHTML:i.innerHTML;return X&&I[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&we(Ye,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
23
+ `+d),J&&fe([O,k,A],e=>{d=be(d,e,` `)}),b&&ae?b.createHTML(d):d},t.setConfig=function(){ht(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Z=!0},t.clearConfig=function(){ft=null,Z=!1},t.isValidAttribute=function(e,t,n){return ft||ht({}),Dt(dt(e),dt(t),n)},t.addHook=function(e,t){typeof t==`function`&&he(D[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=pe(D[e],t);return n===-1?void 0:ge(D[e],n,1)[0]}return me(D[e])},t.removeHooks=function(e){D[e]=[]},t.removeAllHooks=function(){D=tt()},t}var rt=nt(),it=class e{static instance;baseUrl=``;bearerToken=null;constructor(){}static getInstance(){return e.instance||=new e,e.instance}setBearerToken(e){this.bearerToken=e}async get(e,t={},n=`api/v1`){return fetch(`${this.baseUrl}/${n}/${e}`,{...t,method:`GET`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${this.bearerToken}`,...t.headers}})}async post(e,t,n={},r=`api/v1`){return fetch(`${this.baseUrl}/${r}/${e}`,{body:rt.sanitize(JSON.stringify(t)),method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${this.bearerToken}`,...n.headers},...n})}},at=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``),ot=async e=>{let t=new TextEncoder().encode(e);return at(await crypto.subtle.digest(`SHA-256`,t))},st=void 0,ct=void 0,lt=class e{static instance;authenticateAuthorize=`oauth/application/authorize`;authenticateToken=`oauth/application/token`;request=it.getInstance();pkceReady;authToken=null;constructor(){this.pkceReady=this.generatePkce()}static getInstance(){return e.instance||=new e,e.instance}getAuthToken(){return this.authToken}async generatePkce(){let e=te.util.bytesToHex(te.random.getBytesSync(32));return{verifier:e,challenge:await ot(e)}}async authorize(e){let t={client_id:st,redirect_uri:ct,response_type:`code`,code_challenge:e,code_challenge_method:`S256`};return(await this.request.post(this.authenticateAuthorize,t)).json()}async token(e,t){let n={client_id:st,code:e,code_verifier:t,redirect_uri:ct,grant_type:`authorization_code`};return(await this.request.post(this.authenticateToken,n)).json()}async authenticateAndAuthorize(){let{verifier:e,challenge:t}=await this.pkceReady;try{let n=await this.authorize(t);this.authToken=await this.token(n.redirect_uri.code,e)}catch(e){throw console.error(`Error authenticating or authorizing:`,e),e}}},ut=class e{request=it.getInstance();static instance;urlConfig=`external/online_payments/orders/configuration`;config=null;constructor(e,t){this.urlConfig=this.setURLcode(e,t)}static getInstance(t,n){return!e.instance&&t&&(e.instance=new e(t,n)),e.instance}getConfig(){return this.config}setURLcode=(e,t)=>t?`${this.urlConfig}?code=${t}&scope=order_template`:`${this.urlConfig}?code=${e}&scope=branch`;async configRequest(){let e=await this.request.get(this.urlConfig),t=await e.json();return e.ok&&(this.config=t),t}},dt=class e{request=it.getInstance();static instance;countries=[];countriesLoadError=null;urlCountries=`resources/countries`;constructor(){}static getInstance(){return e.instance||=new e,e.instance}getCountries(){return this.countries}setCountries(e){this.countries=e}getCountriesLoadError(){return this.countriesLoadError}async fetchCountries(){let e=await this.request.get(this.urlCountries),t=await e.json();return e.ok?(this.countriesLoadError=null,this.setCountries(t.data),t):(this.countriesLoadError=`No se pudo cargar la lista de países.`,t)}},ft={400:`Error al cargar orden de pago: solicitud inválida`,401:`Error al cargar orden de pago: autenticación requerida`,403:`Error al cargar orden de pago: autorización denegada`,404:`Error al cargar orden de pago: recurso no encontrado`,500:`Error al cargar orden de pago: falla interna del servicio`,502:`Error al cargar orden de pago: respuesta inválida del servicio upstream`,503:`Error al cargar orden de pago: servicio no disponible`};function pt(e,t){return ft[e]||`Error al obtener información de sucursal: ${t}`}var mt=class e{static instance;initPromise=null;auth=lt.getInstance();request=it.getInstance();branchConfig;countryContent=dt.getInstance();authToken=null;config=null;constructor(){}static getInstance(){return e.instance||=new e,e.instance}async initialize(e,t){return this.initPromise||=this.boot(e,t),this.initPromise}async boot(e,t){await this.auth.authenticateAndAuthorize(),this.authToken=this.auth.getAuthToken(),this.request.setBearerToken(this.authToken?.access_token??``),this.branchConfig=ut.getInstance(e,t);let n=await this.branchConfig.configRequest();if(`error`in n)throw Error(pt(n.status,e));this.config=this.branchConfig.getConfig(),await this.countryContent.fetchCountries()}getAuthToken(){if(!this.authToken)throw Error(`PaymentOrchestrator not initialized. Call initialize() first.`);return this.authToken}getConfig(){if(!this.config)throw Error(`PaymentOrchestrator not initialized. Call initialize() first.`);return this.config}},ht=class e{request=it.getInstance();static instance;cardinalToken=null;urlCardinalToken=`external/online_payments/orders/token`;orchestrator=mt.getInstance();constructor(){}static getInstance(){return e.instance||=new e,e.instance}getCardinalToken(){return this.cardinalToken}setCardinalToken(e){this.cardinalToken=e}generateCardinalTokenPayload(e){return{branch_id:this.orchestrator.getConfig().data.branch_id,subtotal_cents:parseInt(e.amount.replace(`.`,``).replace(`,`,``)),subtotal_currency:`USD`,tip_cents:0,tip_currency:`USD`,description:e.description}}async fetchCardinalToken(e){let t=await this.request.post(this.urlCardinalToken,{data:e}),n=await t.json();return t.ok,n}},gt=class e{static instance;states=[];statesLoadError=null;constructor(){}static getInstance(){return e.instance||=new e,e.instance}getStates(){return this.states}setStates(e){this.states=e}getStatesLoadError(){return this.statesLoadError}async fetchStates(e){let t=await it.getInstance().get(`resources/countries/${e}/states`),n=await t.json();return t.ok?(this.statesLoadError=null,this.setStates(n.data),n):(this.statesLoadError=`No se pudo cargar la lista de estados.`,this.setStates([]),n)}},_t=e=>{let t=e[0];return Number(t)===4?`visa`:Number(t)===2||Number(t)===5?`mastercard`:Number(t)===6?`union_pay`:`not_valid`},vt=e=>{let[t,n]=e.split(`/`);return{month:t,year:n}},yt=e=>e.replace(/\s/g,``),bt=class e{static instance;songbirdUrl=``;loaded=!1;initialized=!1;constructor(){}static getInstance(){return e.instance||=new e,e.instance}loadSongbird(){return this.loaded?Promise.resolve():new Promise((e,t)=>{let n=document.createElement(`script`);n.src=this.songbirdUrl,n.onload=()=>{this.loaded=!0,e()},n.onerror=()=>t(Error(`Failed to load Songbird script`)),document.head.appendChild(n)})}getBrowserData(){return{browser_java_enabled:!1,browser_language:navigator.language,browser_color_depth:screen.colorDepth,browser_screen_height:screen.height,browser_screen_width:screen.width,browser_time_zone:Intl.DateTimeFormat().resolvedOptions().timeZone||`America/El_Salvador`,user_agent:navigator.userAgent,device_channel:`Browser`,browser_javascript_enabled:!0}}async setupCardinal(e){return await this.loadSongbird(),this.cleanup(),new Promise((t,n)=>{try{Cardinal.configure({timeout:6e3,maxRequestRetries:3,logging:{level:`on`}}),Cardinal.on(`payments.setupComplete`,n=>{Cardinal.off(`payments.setupComplete`),this.submitCollectionForm(e),t(n.sessionId)}),Cardinal.setup(`init`,{jwt:e}),this.initialized=!0}catch(e){n(e)}})}cleanup(){let e=document.querySelector(`iframe[name="cardinalIframe"]`);e&&e.remove();let t=document.getElementById(`collectionForm`);t&&t.remove()}submitCollectionForm(e){this.cleanup();let t=document.createElement(`iframe`);t.name=`cardinalIframe`,t.height=`10`,t.width=`10`,t.style.cssText=`visibility:hidden;position:absolute;top:-1000px;left:-1000px;`,document.body.appendChild(t);let n=document.createElement(`form`);n.id=`collectionForm`,n.name=`devicedata`,n.method=`POST`,n.action=`https://centinelapistag.cardinalcommerce.com/V2/Cruise/Collect`,n.target=`cardinalIframe`;let r=document.createElement(`input`);r.type=`hidden`,r.name=`JWT`,r.value=e,n.appendChild(r),document.body.appendChild(n),n.submit()}onCardinalValidated(){return new Promise(e=>{Cardinal.on(`payments.validated`,t=>{Cardinal.off(`payments.validated`),e(t)})})}continueCardinal(e,t,n){Cardinal.continue(`cca`,{AcsUrl:e.acs_url,Payload:e.payload},{OrderDetails:{TransactionId:e.transaction_id,OrderNumber:e.order_number_client,Amount:t,CurrencyCode:e.currency_code,OrderDescription:n,OrderChannel:e.transaction_mode}})}},xt=class e{static instance;request=it.getInstance();cardinalService=bt.getInstance();registerPaymentResponse=null;constructor(){}static getInstance(){return e.instance||=new e,e.instance}async registerPayment(e,t){let n={data:{...t,...this.cardinalService.getBrowserData()}},r=await this.request.post(`external/online_payments/orders/${e}/register_payment`,n,{},`api/v2`),i=await r.json();return r.ok&&(this.registerPaymentResponse=i.data),i}async validatePayment(e,t){let n=await this.request.post(`external/online_payments/orders/${e}/validate_payment`,{data:t},{},`api/v2`),r=await n.json();return n.ok,r}async confirmPayment(e,t){let n=await this.request.post(`external/online_payments/orders/${e}/confirm_payment`,{data:t},{},`api/v2`),r=await n.json();return n.ok,r}buildValidatePayloadFromCardinal(e){let t=this.registerPaymentResponse;return{validated:e.Validated,action_code:e.ActionCode,error_number:e.ErrorNumber,error_description:e.ErrorDescription,payment_type:e.Payment.Type,processor_transaction_id:e.Payment.ProcessorTransactionId,cavv:e.Payment.ExtendedData.CAVV,currency_code:e.Payment.ExtendedData.CurrencyCode,eci_flag:e.Payment.ExtendedData.ECIFlag,three_ds_version:e.Payment.ExtendedData.ThreeDSVersion,pares_status:e.Payment.ExtendedData.PAResStatus,signature_verification:e.Payment.ExtendedData.SignatureVerification,cavv_algorithm:t?.cavv_algorithm||void 0,enrolled:t?.enrolled||void 0,ds_transaction_id:t?.ds_transaction_id||void 0}}},St=class{request=it.getInstance();urlEncrypt=`resources/encryption/public_key`;token=null;async getTokenFromServer(){let e=await this.request.get(this.urlEncrypt,{},`api/v2`);if(!e.ok)throw Error(`Failed to get encryption token`);this.token=(await e.json()).data}getToken(){return this.token}encryptData(e){if(!this.token)throw Error(`Encryption token not found`);let t=JSON.stringify({...e,nonce:crypto.randomUUID(),timestamp:Math.floor(Date.now()/1e3)}),n=te.default.random.getBytesSync(32),r=te.default.random.getBytesSync(12),i=te.default.cipher.createCipher(`AES-GCM`,n);i.start({iv:r,additionalData:``,tagLength:128}),i.update(te.default.util.createBuffer(t,`utf8`)),i.finish();let a=te.default.pki.publicKeyFromPem(this.token.public_key).encrypt(n,`RSA-OAEP`);return{encrypted_data:te.default.util.encode64(i.output.getBytes()),encrypted_key:te.default.util.encode64(a),iv:te.default.util.encode64(r),tag:te.default.util.encode64(i.mode.tag.getBytes())}}},Ct=class e{static instance;cardinalToken=ht.getInstance();cardinalService=bt.getInstance();cardinalPayment=xt.getInstance();countryContent=dt.getInstance();stateContent=gt.getInstance();orchestrator=mt.getInstance();constructor(){}static getInstance(){return e.instance||=new e,e.instance}async process(e,t,n){let r=this.cardinalToken.generateCardinalTokenPayload(e);t&&(r.subtotal_cents=t);let i=await this.cardinalToken.fetchCardinalToken(r);if(`error`in i){n.sendAlert(`Error`,i.error||`Error al procesar el pago`);return}let{id:a,token:o}=i.data,s=await this.cardinalService.setupCardinal(o),c=this.countryContent.getCountries().find(t=>t.id===e.country),l=this.stateContent.getStates().find(t=>t.id===e.region),u=vt(e.cardExpiry),d=new St;try{await d.getTokenFromServer()}catch(e){throw Error(`Failed to get encryption token: `+e)}let f=d.encryptData({card_number:yt(e.cardNumber),card_expiration_month:u.month,card_expiration_year:`20${u.year}`,cvv:e.cardCvc,expiration_date:`${u.year}${u.month}`,cardholder_name:e.cardHolder}),p={reference:s,billing_address:e.address,billing_city:e.city,billing_country_code:String(c?.number||``),billing_first_name:e.firstName,billing_last_name:e.lastName,billing_postal_code:e.postalCode,billing_state_code:l?.short_code||``,billing_country_name:c?.name||``,email:e.email,phone_number:e.phone.replace(/\s/g,``),...f},m=await this.cardinalPayment.registerPayment(a,p);if(`error`in m){n.sendAlert(`Error`,m.error||`Error al procesar el pago`);return}let h=m.data;if(h.status!==`success`){n.sendAlert(`Error al pagar`,`Tu compra no pudo ser procesada.
24
+ Por favor revisa tu información e inténtalo de nuevo`);return}if(h.required_authentication&&h.acs_url!==``){this.cardinalService.continueCardinal(h,String(r.subtotal_cents),e.description);let t=await this.cardinalService.onCardinalValidated();if(t.ActionCode!==`SUCCESS`){n.sendAlert(`Error al pagar`,`Tu compra no pudo ser procesada.
25
+ Por favor revisa tu información e inténtalo de nuevo`);return}let i=this.cardinalPayment.buildValidatePayloadFromCardinal(t),o=await this.cardinalPayment.validatePayment(a,{...i,...f});if(`error`in o){n.sendAlert(`Error`,o.error||`Error al procesar el pago`);return}if(o.data.status!==`success`){n.sendAlert(`Error al pagar`,`Tu compra no pudo ser procesada.
26
+ Por favor revisa tu información e inténtalo de nuevo`);return}}else{let e=await this.cardinalPayment.validatePayment(a,{...f});if(`error`in e){n.sendAlert(`Error`,e.error||`Error al procesar el pago`);return}if(e.data.status!==`success`){n.sendAlert(`Error al pagar`,`Tu compra no pudo ser procesada.
27
+ Por favor revisa tu información e inténtalo de nuevo`);return}}let g=this.buildConfirmPayload(),_=await this.cardinalPayment.confirmPayment(a,{...g,...f});if(`error`in _){n.sendAlert(`Error`,_.error||`Error al procesar el pago`);return}_.data.status===`success`?(n.sendSuccess({data:{id:a,status:_.data.status,amount_cents:parseInt(e.amount.replace(`.`,``).replace(`,`,``)),amount_currency:`USD`,response_code:_.data.response_code,authorization_number:_.data.authorization_code,reference_number:_.data.reference_code,billing_document_number:e.billingDocumentNumber,description:e.description,date:this.getCurrentDate(),time:this.getCurrentTime(),commerce_name:this.orchestrator.getConfig().data.name,branch_name:this.orchestrator.getConfig().data.branch_name,card_network:``,card_last_digits:e.cardNumber.slice(-4),invoice_serie:null}}),n.resetForm()):n.sendAlert(`Error al pagar`,`Tu compra no pudo ser procesada.
28
+ Por favor revisa tu información e inténtalo de nuevo`)}buildConfirmPayload(){let e=new Date,t=String(e.getFullYear()).slice(2),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getHours()).padStart(2,`0`),i=String(e.getMinutes()).padStart(2,`0`),a=String(e.getSeconds()).padStart(2,`0`);return{invoice_number:String(Math.floor(Math.random()*90001)+1e4),terminal_id:``,retailer_id:``,transaction_date:`${t}${n}`,transaction_time:`${r}${i}${a}`}}getCurrentDate(){let e=new Date,t=String(e.getMonth()+1).padStart(2,`0`),n=String(e.getDate()).padStart(2,`0`);return`${e.getFullYear()}-${t}-${n}`}getCurrentTime(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}`}};function wt(){let e=document.createElement(`div`);return e.setAttribute(`data-bizz-loading`,``),e.innerHTML=`
29
+ <style>
30
+ [data-bizz-loading] {
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: center;
34
+ padding: 48px 16px;
35
+ }
36
+ .bizz-spinner {
37
+ width: 32px;
38
+ height: 32px;
39
+ border: 3px solid #e9ecef;
40
+ border-top-color: #ff5257;
41
+ border-radius: 50%;
42
+ animation: bizz-spin 0.6s linear infinite;
43
+ }
44
+ @keyframes bizz-spin {
45
+ to { transform: rotate(360deg); }
46
+ }
47
+ </style>
48
+ <div class="bizz-spinner"></div>
49
+ `,e}var Tt={minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!0};new Intl.NumberFormat(`en-US`,Tt);function Et(e,t=`USD`,n=`currency`){return new Intl.NumberFormat(`en-US`,{style:n,currency:t,...Tt}).format(e)}function Dt(e){return parseInt(e.replace(/,/g,``).replace(`.`,``),0)}var Ot=class e{static instance;orchestrator=mt.getInstance();urlValidateAmount=`external/online_payments/orders/validate`;lastAmountValidate=0;constructor(){}static getInstance(){return e.instance||=new e,e.instance}setLastAmountValidate(e){this.lastAmountValidate=e}getLastAmountValidate(){return this.lastAmountValidate}async validateAmount(e,t=!1){let n=typeof e==`string`?Dt(e):e;if(!t&&n===this.getLastAmountValidate())return;this.setLastAmountValidate(n);let r=await it.getInstance().post(this.urlValidateAmount,{data:{branch_id:this.orchestrator.getConfig().data.branch_id,amount_cents:n}}),i=await r.json();return r.ok,i}},kt=class e{request=it.getInstance();urlPaymentIntent=`external/online_payments/payment_intents`;orchestrator=mt.getInstance();static instance;constructor(){}static getInstance(){return e.instance||=new e,e.instance}async generatePaymentIntentPayload(e){let t=this.orchestrator.getConfig(),n=new St;try{await n.getTokenFromServer()}catch(e){throw Error(`Failed to get encryption token: `+e)}let r={card_number:yt(e.cardNumber),card_security_code:e.cardCvc,cardholder_name:e.cardHolder,card_expiration_month:vt(e.cardExpiry).month,card_expiration_year:vt(e.cardExpiry).year},i=null;try{i=n.encryptData(r)}catch(e){throw Error(`Failed to encrypt data: `+e)}return{branch_id:t.data.branch_id,card_network:_t(e.cardNumber),operation:`direct`,iv:i.iv,tag:i.tag,encrypted_data:i.encrypted_data,cardholder_name:e.cardHolder,card_last_digits:e.cardNumber.slice(-4),subtotal_currency:`USD`,billing_name:e.cardHolder,encrypted_key:i.encrypted_key,subtotal_cents:parseInt(e.amount.replace(`.`,``).replace(`,`,``)),billing_email:e.email,description:e.description,billing_document_number:e.billingDocumentNumber}}async createPaymentIntent(e){let t=this.orchestrator.getAuthToken(),n=await this.request.post(this.urlPaymentIntent,{data:e},{headers:{Authorization:`Bearer ${t.access_token}`,"Content-Type":`application/json`}},`api/v2`),r=await n.json();return n.ok,r}},At=[{label:`Documento Único de Identidad (DUI)`,value:`dui`},{label:`Pasaporte`,value:`passport`},{label:`Tarjeta de extranjero`,value:`resident_card`}],jt=[{label:`Selecciona aquí`,value:``}],Mt=[{label:`Selecciona aquí`,value:``}],Nt={amount:{label:`Monto a pagar`,icon:`currency-dollar`,placeholder:`0.00`,divider:!0},documentType:{label:`Tipo de documento`,icon:`document`,placeholder:`Tipo de documento`,type:`select`,default:`dui`,options:At},billingDocumentNumber:{label:`Número de documento`,icon:`document`,placeholder:`1234567890`,type:`text`,mask:`########-#`},email:{label:`Correo electrónico`,icon:`email`,placeholder:`example@example.com`,type:`email`,divider:!0},cardNumber:{label:`Número de tarjeta`,icon:`credit-card`,placeholder:`4111 1111 1111 1111`,mask:`#### #### #### ####`},cardExpiry:{label:`Fecha de expiración`,icon:`calendar`,placeholder:`MM/YY`,mask:`##/##`},cardCvc:{label:`CVV`,icon:`shield-lock`,placeholder:`123`,mask:`###`},cardHolder:{label:`Nombre en tarjeta`,icon:`user`,placeholder:`John Doe`},description:{label:`Descripción`,icon:`description`,placeholder:`Description`}},Pt={amount:{label:`Monto a pagar`,icon:`currency-dollar`,placeholder:`0.00`,divider:!0},documentType:{label:`Tipo de documento`,icon:`document`,placeholder:`Selecciona tipo de documento`,type:`select`,default:`dui`,options:At},billingDocumentNumber:{label:`Número de documento`,icon:`document`,placeholder:`Escribe acá`,type:`text`,mask:`########-#`},firstName:{label:`Nombre`,icon:`user`,placeholder:`Ingresar nombre`},lastName:{label:`Apellido`,icon:`user`,placeholder:`Ingresar apellido`},email:{label:`Correo electrónico`,icon:`email`,placeholder:`Escribe acá`,type:`email`},phone:{label:`Teléfono`,icon:`phone`,placeholder:`Ingresar teléfono`,divider:!0},cardNumber:{label:`Número de tarjeta`,icon:`credit-card`,placeholder:`Escribe acá`,mask:`#### #### #### ####`},cardHolder:{label:`Nombre en tarjeta`,icon:`user`,placeholder:`Escribe acá`},cardExpiry:{label:`Fecha de vencimiento`,icon:`calendar`,placeholder:`Escribe acá`,mask:`##/##`},cardCvc:{label:`CVV`,icon:`shield-lock`,placeholder:`Escribe acá`,mask:`###`,divider:!0},country:{label:`País`,icon:`map-pin`,placeholder:`Selecciona aquí`,type:`select`,options:jt},region:{label:`Región`,icon:`map-pin`,placeholder:`Selecciona aquí`,type:`select`,options:Mt},city:{label:`Ciudad`,icon:`map-pin`,placeholder:`Escribe aquí`},address:{label:`Dirección`,icon:`map-pin`,placeholder:`Escribe aquí`},postalCode:{label:`Código postal`,icon:`document`,placeholder:`Escribe aquí`,divider:!0},description:{label:`Descripción`,icon:`description`,placeholder:`Escribe acá`}};function Ft(e){let t=e?.label??`Pagar`;return`<button type="submit" data-label="${t}" data-loading-label="${e?.loadingLabel??`Procesando...`}">${t}</button>`}function It(e){let{header:t}=e,n=!0,r=!0,i=!0,a=!0,o=!0;return typeof t==`boolean`&&!t?``:(typeof t==`object`&&(`logo`in t&&typeof t.logo==`boolean`&&(n=t.logo),`totalAmount`in t&&typeof t.totalAmount==`boolean`&&(r=t.totalAmount),`description`in t&&typeof t.description==`boolean`&&(i=t.description),`requestMessage`in t&&typeof t.requestMessage==`boolean`&&(a=t.requestMessage),`date`in t&&typeof t.date==`boolean`&&(o=t.date)),`
50
+ <header class="form-header">
51
+ ${n?`<img src="${e.logo}" alt="${e.name} Logo" class="commerce-logo">`:``}
52
+ ${r?`<div class="commerce-total-amount-container">
53
+ ${e.icon??``}
54
+ <span class="total-amount-value">${e.totalAmount}</span>
55
+ </div>`:``}
56
+ ${i&&e.description?`<h1 class="commerce-description">${e.description}</h1>`:``}
57
+ ${a?`<p class="commerce-required">“${e.name} está solicitando que hagás un pago en línea”</p>`:``}
58
+ ${o?`<date class="commerce-date"> ${new Date().toLocaleDateString(`es-SV`,{day:`numeric`,month:`long`,year:`numeric`})} </date>`:``}
59
+ </header>
60
+ <span class="divider-header"></span>
61
+ `)}function Lt(e){let t=e.find(e=>e.name===`amount`);return{amountHtml:t?`
62
+ <div class="field">
63
+ <label for="amount">${t.label}</label>
64
+ <div class="input-wrapper">
65
+ ${t.iconSvg??``}
66
+ <input type="text" id="amount" name="amount" placeholder="${t.placeholder}" ${t.amountValue?` value="${t.amountValue}"`:``} ${t.disabled?` disabled`:``} ${t.mask?` data-maska="${t.mask}"`:``} />
67
+ </div>
68
+ <span class="field-error" id="error-amount"></span>
69
+ ${t.divider?`<span class="divider" />`:``}
70
+ </div>
71
+ `:``,fieldsHtml:e.filter(e=>e.name!==`amount`).map(e=>{let t=e.mask?` data-maska="${e.mask}"`:``,n=e.type===`select`?`
72
+ <select id="${e.name}" name="${e.name}"${e.disabled?` disabled`:``}>
73
+ ${e.options?.map(t=>`<option value="${t.value}"${t.value===e.default?` selected`:``}>${t.label}</option>`).join(``)??``}
74
+ </select>
75
+ `:``,r=e.type===`select`?``:`
76
+ <input type="${e.type}" id="${e.name}" name="${e.name}" placeholder="${e.placeholder}"${t}${e.disabled?` disabled`:``}
77
+ ${e.default===void 0?``:` value="${e.default}"`} />
78
+ `;return`
79
+ <div class="field">
80
+ <label for="${e.name}">${e.label}</label>
81
+ <div class="input-wrapper">
82
+ ${e.iconSvg??``}
83
+ ${n}
84
+ ${r}
85
+ </div>
86
+ <span class="field-error" id="error-${e.name}"></span>
87
+ ${e.divider?`<span class="divider" />`:``}
88
+ </div>
89
+ `}).join(``)}}var Rt=`<!DOCTYPE html>
90
+ <html lang="en">
91
+ <head>
92
+ <meta charset="UTF-8">
93
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
94
+ <style>
95
+ * {
96
+ margin: 0;
97
+ padding: 0;
98
+ box-sizing: border-box;
99
+ scrollbar-width: none;
100
+ -ms-overflow-style: none;
101
+ }
102
+ *::-webkit-scrollbar,
103
+ html::-webkit-scrollbar,
104
+ body::-webkit-scrollbar {
105
+ width: 0;
106
+ height: 0;
107
+ }
108
+ /* Hide scrollbars visually; scrolling still works (wheel, touch, keyboard) */
109
+ body {
110
+ font-family: Poppins, sans-serif;
111
+ padding: 16px;
112
+ }
113
+ form#payment-form {
114
+ display: flex;
115
+ flex-direction: column;
116
+ gap: 16px;
117
+ }
118
+ section.payment-form-container {
119
+ padding: 32px;
120
+ border-radius: 12px;
121
+ border: 1px solid #D3D9DE;
122
+ }
123
+ .field {
124
+ display: flex;
125
+ flex-direction: column;
126
+ gap: 6px;
127
+ margin-bottom: 1rem;
128
+ }
129
+ label {
130
+ font-family: Poppins, sans-serif;
131
+ font-weight: 400;
132
+ line-height: 1.5rem;
133
+ font-size: 1rem;
134
+ color: #69737D;
135
+ }
136
+ .input-wrapper {
137
+ display: flex;
138
+ align-items: center;
139
+ gap: 8px;
140
+ background-color: #F6F7F9;
141
+ border-radius: 12px;
142
+ padding: 12px 15px;
143
+ border: 1px solid transparent;
144
+ transition: border-color 0.2s;
145
+ }
146
+
147
+ .input-wrapper svg {
148
+ width: 18px;
149
+ height: 18px;
150
+ color: #9ca3af;
151
+ flex-shrink: 0;
152
+ }
153
+ .input-wrapper input, select {
154
+ width: 100%;
155
+ border: none;
156
+ background: transparent;
157
+ font-family: Poppins, sans-serif;
158
+ font-size: 14px;
159
+ color: #1f2937;
160
+ outline: none;
161
+ }
162
+ .input-wrapper input::placeholder {
163
+ color: #9ca3af;
164
+ }
165
+ .input-wrapper input[disabled] {
166
+ background-color: #f6f7f9;
167
+ color: #69737D;
168
+ cursor: not-allowed;
169
+ }
170
+ .field-error {
171
+ font-size: 14px;
172
+ padding-top: 4px;
173
+ color: #DB3339;
174
+ font-weight: 400;
175
+ }
176
+ .field-error.visible {
177
+ display: block;
178
+ }
179
+ button {
180
+ background-color: #ff5257;
181
+ color: #fff;
182
+ font-family: Poppins, sans-serif;
183
+ font-size: 1rem;
184
+ font-weight: 700;
185
+ gap: .5rem;
186
+ isolation: isolate;
187
+ line-height: 1.5rem;
188
+ padding: .5rem 1rem;
189
+ transition-duration: .2s;
190
+ transition-property: all;
191
+ transition-timing-function: cubic-bezier(.4, 0, .2, 1);
192
+ border: none;
193
+ border-radius: 6px;
194
+ cursor: pointer;
195
+ }
196
+ button:disabled {
197
+ cursor: not-allowed;
198
+ background-color: #e9ecef;
199
+ color: #adb5bd
200
+ }
201
+ button:disabled:hover {
202
+ background-color: #d7d9db;
203
+ color: #a4a7ab;
204
+ }
205
+ button:hover {
206
+ background-color: #e6484d;
207
+ }
208
+ .divider {
209
+ margin-top: 0.5rem;
210
+ background-color: #e9ecef;
211
+ width: 100%;
212
+ height: 1px;
213
+ }
214
+ .form-alert {
215
+ display: none;
216
+ text-align: center;
217
+ padding: 12px 16px;
218
+ }
219
+ .form-alert.visible {
220
+ display: block;
221
+ }
222
+ .form-alert:not(.form-alert--receipt) h3 {
223
+ font-family: Poppins, sans-serif;
224
+ font-size: 1rem;
225
+ font-weight: 700;
226
+ color: #1f2937;
227
+ margin-bottom: 4px;
228
+ }
229
+ .form-alert:not(.form-alert--receipt) p {
230
+ font-family: Poppins, sans-serif;
231
+ font-size: 0.875rem;
232
+ font-weight: 400;
233
+ color: #86919c;
234
+ }
235
+ .form-alert--receipt {
236
+ padding: 20px 12px 24px;
237
+ }
238
+ .payment-success {
239
+ max-width: 320px;
240
+ margin: 0 auto;
241
+ text-align: center;
242
+ }
243
+ .payment-success__amount {
244
+ font-family: Poppins, sans-serif;
245
+ font-size: 2rem;
246
+ font-weight: 700;
247
+ color: #000000;
248
+ letter-spacing: -0.02em;
249
+ margin: 0 0 10px;
250
+ line-height: 1.15;
251
+ }
252
+ .payment-success__datetime {
253
+ font-family: Poppins, sans-serif;
254
+ font-size: 0.8125rem;
255
+ font-weight: 400;
256
+ color: #6c757d;
257
+ margin: 0 0 24px;
258
+ line-height: 1.4;
259
+ }
260
+ .payment-success__blocks {
261
+ display: flex;
262
+ flex-direction: column;
263
+ gap: 18px;
264
+ margin-bottom: 28px;
265
+ text-align: center;
266
+ }
267
+ .payment-success__block {
268
+ display: flex;
269
+ flex-direction: column;
270
+ gap: 4px;
271
+ align-items: center;
272
+ }
273
+ .payment-success__label {
274
+ font-family: Poppins, sans-serif;
275
+ font-size: 0.75rem;
276
+ font-weight: 400;
277
+ color: #6c757d;
278
+ line-height: 1.3;
279
+ }
280
+ .payment-success__value {
281
+ font-family: Poppins, sans-serif;
282
+ font-size: 1.0625rem;
283
+ font-weight: 700;
284
+ color: #000000;
285
+ line-height: 1.3;
286
+ }
287
+ .payment-success__footer {
288
+ padding-top: 4px;
289
+ }
290
+ .payment-success__done {
291
+ font-family: Poppins, sans-serif;
292
+ font-size: 1.5rem;
293
+ font-weight: 700;
294
+ color: #000000;
295
+ margin: 0 0 10px;
296
+ line-height: 1.2;
297
+ }
298
+
299
+ .bizz-logo {
300
+ width: 92px;
301
+ height: 32px;
302
+ display: block;
303
+ margin: 0 auto 32px;
304
+ }
305
+
306
+ .form-header {
307
+ display: flex;
308
+ justify-content: center;
309
+ align-items: center;
310
+ margin-bottom: 32px;
311
+ flex-direction: column;
312
+ font-family: Poppins, sans-serif;
313
+ font-weight: 400;
314
+ line-height: 1.5rem;
315
+ }
316
+ .commerce-total-amount-container {
317
+ color: #1E2125;
318
+ margin-top: 32px;
319
+ }
320
+ .commerce-total-amount-container .total-amount-value {
321
+ font-size: 3rem;
322
+ font-weight: 600;
323
+ line-height: 4rem;
324
+ }
325
+ .form-header .commerce-description {
326
+ color: #1E2125;
327
+ font-size: 1rem;
328
+ }
329
+ .form-header .commerce-total-amount {
330
+ color: #1E2125;
331
+ font-size: 1rem;
332
+ margin-top: 32px;
333
+ }
334
+ .form-header .commerce-required {
335
+ color: #121417;
336
+ font-size: 1rem;
337
+ margin-top: 32px;
338
+ }
339
+ .commerce-date {
340
+ margin-top: 8px;
341
+ font-size: 1rem;
342
+ color: #69737D;
343
+ }
344
+ .commerce-logo {
345
+ border-radius: 60px;
346
+ border: 3px solid #F6F7F9;
347
+ width: 60px;
348
+ height: 60px;
349
+ }
350
+ .divider-header {
351
+ margin: 32px 0px;
352
+ background-color: #e9ecef;
353
+ width: 100%;
354
+ height: 1px;
355
+ display: block;
356
+ }
357
+ </style>
358
+ </head>
359
+ <body>
360
+ <!--BIZZ_LOGO-->
361
+ <section class="payment-form-container">
362
+ <!--HEADER-->
363
+ <form id="payment-form">
364
+ <div id="payment-form-static-fields">
365
+ <!--AMOUNT_FIELD-->
366
+ </div>
367
+ <div id="payment-form-dynamic-fields">
368
+ <!--FIELDS-->
369
+ </div>
370
+ <div class="form-alert" id="form-alert"></div>
371
+ <!--SUBMIT_BUTTON-->
372
+ </form>
373
+ </section>
374
+ <!--SCRIPT-->
375
+ </body>
376
+ </html>
377
+ `,zt='(function(){var{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:r,getOwnPropertyDescriptor:i}=Object,{freeze:a,seal:o,create:s}=Object,{apply:c,construct:l}=typeof Reflect<`u`&&Reflect;a||=function(e){return e},o||=function(e){return e},c||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},l||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var u=b(Array.prototype.forEach),d=b(Array.prototype.lastIndexOf),ee=b(Array.prototype.pop),f=b(Array.prototype.push),p=b(Array.prototype.splice),m=b(String.prototype.toLowerCase),h=b(String.prototype.toString),g=b(String.prototype.match),te=b(String.prototype.replace),ne=b(String.prototype.indexOf),re=b(String.prototype.trim),_=b(Object.prototype.hasOwnProperty),v=b(RegExp.prototype.test),y=ie(TypeError);function b(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return c(e,t,r)}}function ie(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return l(e,n)}}function x(e,r){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:m;t&&t(e,null);let a=r.length;for(;a--;){let t=r[a];if(typeof t==`string`){let e=i(t);e!==t&&(n(r)||(r[a]=e),t=e)}e[t]=!0}return e}function S(e){for(let t=0;t<e.length;t++)_(e,t)||(e[t]=null);return e}function C(t){let n=s(null);for(let[r,i]of e(t))_(t,r)&&(Array.isArray(i)?n[r]=S(i):i&&typeof i==`object`&&i.constructor===Object?n[r]=C(i):n[r]=i);return n}function ae(e,t){for(;e!==null;){let n=i(e,t);if(n){if(n.get)return b(n.get);if(typeof n.value==`function`)return b(n.value)}e=r(e)}function n(){return null}return n}var oe=a(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),se=a(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),ce=a([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),le=a([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),ue=a(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),de=a([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),fe=a([`#text`]),pe=a(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns.slot`.split(`.`)),me=a(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),he=a(`accent.accentunder.align.bevelled.close.columnsalign.columnlines.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lspace.lquote.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),ge=a([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),_e=o(/\\{\\{[\\w\\W]*|[\\w\\W]*\\}\\}/gm),ve=o(/<%[\\w\\W]*|[\\w\\W]*%>/gm),ye=o(/\\$\\{[\\w\\W]*/gm),be=o(/^data-[\\-\\w.\\u00B7-\\uFFFF]+$/),w=o(/^aria-[\\-\\w]+$/),xe=o(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i),Se=o(/^(?:\\w+script|data):/i),Ce=o(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g),we=o(/^html$/i),Te=o(/^[a-z][.\\w]*(-[.\\w]+)+$/i),Ee=Object.freeze({__proto__:null,ARIA_ATTR:w,ATTR_WHITESPACE:Ce,CUSTOM_ELEMENT:Te,DATA_ATTR:be,DOCTYPE_NAME:we,ERB_EXPR:ve,IS_ALLOWED_URI:xe,IS_SCRIPT_OR_DATA:Se,MUSTACHE_EXPR:_e,TMPLIT_EXPR:ye}),De={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Oe=function(){return typeof window>`u`?null:window},ke=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Ae=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function je(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Oe(),n=e=>je(e);if(n.version=`3.3.3`,n.removed=[],!t||!t.document||t.document.nodeType!==De.document||!t.Element)return n.isSupported=!1,n;let{document:r}=t,i=r,o=i.currentScript,{DocumentFragment:c,HTMLTemplateElement:l,Node:b,Element:ie,NodeFilter:S,NamedNodeMap:_e=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:ve,DOMParser:ye,trustedTypes:be}=t,w=ie.prototype,Se=ae(w,`cloneNode`),Ce=ae(w,`remove`),Te=ae(w,`nextSibling`),Me=ae(w,`childNodes`),T=ae(w,`parentNode`);if(typeof l==`function`){let e=r.createElement(`template`);e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let E,D=``,{implementation:O,createNodeIterator:Ne,createDocumentFragment:Pe,getElementsByTagName:Fe}=r,{importNode:Ie}=i,k=Ae();n.isSupported=typeof e==`function`&&typeof T==`function`&&O&&O.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:Le,ERB_EXPR:A,TMPLIT_EXPR:Re,DATA_ATTR:ze,ARIA_ATTR:Be,IS_SCRIPT_OR_DATA:Ve,ATTR_WHITESPACE:j,CUSTOM_ELEMENT:He}=Ee,{IS_ALLOWED_URI:Ue}=Ee,M=null,We=x({},[...oe,...se,...ce,...ue,...fe]),N=null,Ge=x({},[...pe,...me,...he,...ge]),P=Object.seal(s(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),F=null,I=null,L=Object.seal(s(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ke=!0,qe=!0,Je=!1,Ye=!0,R=!1,Xe=!0,z=!1,Ze=!1,B=!1,V=!1,H=!1,U=!1,W=!0,Qe=!1,$e=!0,et=!1,G={},K=null,tt=x({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),nt=null,rt=x({},[`audio`,`video`,`img`,`source`,`image`,`track`]),it=null,at=x({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),ot=`http://www.w3.org/1998/Math/MathML`,st=`http://www.w3.org/2000/svg`,q=`http://www.w3.org/1999/xhtml`,J=q,ct=!1,lt=null,ut=x({},[ot,st,q],h),dt=x({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),ft=x({},[`annotation-xml`]),pt=x({},[`title`,`style`,`font`,`a`,`script`]),mt=null,ht=[`application/xhtml+xml`,`text/html`],Y=null,X=null,gt=r.createElement(`form`),_t=function(e){return e instanceof RegExp||e instanceof Function},vt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(X&&X===e)){if((!e||typeof e!=`object`)&&(e={}),e=C(e),mt=ht.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Y=mt===`application/xhtml+xml`?h:m,M=_(e,`ALLOWED_TAGS`)?x({},e.ALLOWED_TAGS,Y):We,N=_(e,`ALLOWED_ATTR`)?x({},e.ALLOWED_ATTR,Y):Ge,lt=_(e,`ALLOWED_NAMESPACES`)?x({},e.ALLOWED_NAMESPACES,h):ut,it=_(e,`ADD_URI_SAFE_ATTR`)?x(C(at),e.ADD_URI_SAFE_ATTR,Y):at,nt=_(e,`ADD_DATA_URI_TAGS`)?x(C(rt),e.ADD_DATA_URI_TAGS,Y):rt,K=_(e,`FORBID_CONTENTS`)?x({},e.FORBID_CONTENTS,Y):tt,F=_(e,`FORBID_TAGS`)?x({},e.FORBID_TAGS,Y):C({}),I=_(e,`FORBID_ATTR`)?x({},e.FORBID_ATTR,Y):C({}),G=_(e,`USE_PROFILES`)?e.USE_PROFILES:!1,Ke=e.ALLOW_ARIA_ATTR!==!1,qe=e.ALLOW_DATA_ATTR!==!1,Je=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ye=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,R=e.SAFE_FOR_TEMPLATES||!1,Xe=e.SAFE_FOR_XML!==!1,z=e.WHOLE_DOCUMENT||!1,V=e.RETURN_DOM||!1,H=e.RETURN_DOM_FRAGMENT||!1,U=e.RETURN_TRUSTED_TYPE||!1,B=e.FORCE_BODY||!1,W=e.SANITIZE_DOM!==!1,Qe=e.SANITIZE_NAMED_PROPS||!1,$e=e.KEEP_CONTENT!==!1,et=e.IN_PLACE||!1,Ue=e.ALLOWED_URI_REGEXP||xe,J=e.NAMESPACE||q,dt=e.MATHML_TEXT_INTEGRATION_POINTS||dt,ft=e.HTML_INTEGRATION_POINTS||ft,P=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&_t(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(P.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&_t(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(P.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(P.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),R&&(qe=!1),H&&(V=!0),G&&(M=x({},fe),N=s(null),G.html===!0&&(x(M,oe),x(N,pe)),G.svg===!0&&(x(M,se),x(N,me),x(N,ge)),G.svgFilters===!0&&(x(M,ce),x(N,me),x(N,ge)),G.mathMl===!0&&(x(M,ue),x(N,he),x(N,ge))),_(e,`ADD_TAGS`)||(L.tagCheck=null),_(e,`ADD_ATTR`)||(L.attributeCheck=null),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?L.tagCheck=e.ADD_TAGS:(M===We&&(M=C(M)),x(M,e.ADD_TAGS,Y))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?L.attributeCheck=e.ADD_ATTR:(N===Ge&&(N=C(N)),x(N,e.ADD_ATTR,Y))),e.ADD_URI_SAFE_ATTR&&x(it,e.ADD_URI_SAFE_ATTR,Y),e.FORBID_CONTENTS&&(K===tt&&(K=C(K)),x(K,e.FORBID_CONTENTS,Y)),e.ADD_FORBID_CONTENTS&&(K===tt&&(K=C(K)),x(K,e.ADD_FORBID_CONTENTS,Y)),$e&&(M[`#text`]=!0),z&&x(M,[`html`,`head`,`body`]),M.table&&(x(M,[`tbody`]),delete F.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw y(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw y(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);E=e.TRUSTED_TYPES_POLICY,D=E.createHTML(``)}else E===void 0&&(E=ke(be,o)),E!==null&&typeof D==`string`&&(D=E.createHTML(``));a&&a(e),X=e}},yt=x({},[...se,...ce,...le]),bt=x({},[...ue,...de]),xt=function(e){let t=T(e);(!t||!t.tagName)&&(t={namespaceURI:J,tagName:`template`});let n=m(e.tagName),r=m(t.tagName);return lt[e.namespaceURI]?e.namespaceURI===st?t.namespaceURI===q?n===`svg`:t.namespaceURI===ot?n===`svg`&&(r===`annotation-xml`||dt[r]):!!yt[n]:e.namespaceURI===ot?t.namespaceURI===q?n===`math`:t.namespaceURI===st?n===`math`&&ft[r]:!!bt[n]:e.namespaceURI===q?t.namespaceURI===st&&!ft[r]||t.namespaceURI===ot&&!dt[r]?!1:!bt[n]&&(pt[n]||!yt[n]):!!(mt===`application/xhtml+xml`&&lt[e.namespaceURI]):!1},Z=function(e){f(n.removed,{element:e});try{T(e).removeChild(e)}catch{Ce(e)}},Q=function(e,t){try{f(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch{f(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),e===`is`)if(V||H)try{Z(t)}catch{}else try{t.setAttribute(e,``)}catch{}},St=function(e){let t=null,n=null;if(B)e=`<remove></remove>`+e;else{let t=g(e,/^[\\r\\n\\t ]+/);n=t&&t[0]}mt===`application/xhtml+xml`&&J===q&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=E?E.createHTML(e):e;if(J===q)try{t=new ye().parseFromString(i,mt)}catch{}if(!t||!t.documentElement){t=O.createDocument(J,`template`,null);try{t.documentElement.innerHTML=ct?D:i}catch{}}let a=t.body||t.documentElement;return e&&n&&a.insertBefore(r.createTextNode(n),a.childNodes[0]||null),J===q?Fe.call(t,z?`html`:`body`)[0]:z?t.documentElement:a},Ct=function(e){return Ne.call(e.ownerDocument||e,e,S.SHOW_ELEMENT|S.SHOW_COMMENT|S.SHOW_TEXT|S.SHOW_PROCESSING_INSTRUCTION|S.SHOW_CDATA_SECTION,null)},wt=function(e){return e instanceof ve&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof _e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},Tt=function(e){return typeof b==`function`&&e instanceof b};function $(e,t,r){u(e,e=>{e.call(n,t,r,X)})}let Et=function(e){let t=null;if($(k.beforeSanitizeElements,e,null),wt(e))return Z(e),!0;let r=Y(e.nodeName);if($(k.uponSanitizeElement,e,{tagName:r,allowedTags:M}),Xe&&e.hasChildNodes()&&!Tt(e.firstElementChild)&&v(/<[/\\w!]/g,e.innerHTML)&&v(/<[/\\w!]/g,e.textContent)||e.nodeType===De.progressingInstruction||Xe&&e.nodeType===De.comment&&v(/<[/\\w]/g,e.data))return Z(e),!0;if(!(L.tagCheck instanceof Function&&L.tagCheck(r))&&(!M[r]||F[r])){if(!F[r]&&Ot(r)&&(P.tagNameCheck instanceof RegExp&&v(P.tagNameCheck,r)||P.tagNameCheck instanceof Function&&P.tagNameCheck(r)))return!1;if($e&&!K[r]){let t=T(e)||e.parentNode,n=Me(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Se(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,Te(e))}}}return Z(e),!0}return e instanceof ie&&!xt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&v(/<\\/no(script|embed|frames)/i,e.innerHTML)?(Z(e),!0):(R&&e.nodeType===De.text&&(t=e.textContent,u([Le,A,Re],e=>{t=te(t,e,` `)}),e.textContent!==t&&(f(n.removed,{element:e.cloneNode()}),e.textContent=t)),$(k.afterSanitizeElements,e,null),!1)},Dt=function(e,t,n){if(I[t]||W&&(t===`id`||t===`name`)&&(n in r||n in gt))return!1;if(!(qe&&!I[t]&&v(ze,t))&&!(Ke&&v(Be,t))&&!(L.attributeCheck instanceof Function&&L.attributeCheck(t,e))){if(!N[t]||I[t]){if(!(Ot(e)&&(P.tagNameCheck instanceof RegExp&&v(P.tagNameCheck,e)||P.tagNameCheck instanceof Function&&P.tagNameCheck(e))&&(P.attributeNameCheck instanceof RegExp&&v(P.attributeNameCheck,t)||P.attributeNameCheck instanceof Function&&P.attributeNameCheck(t,e))||t===`is`&&P.allowCustomizedBuiltInElements&&(P.tagNameCheck instanceof RegExp&&v(P.tagNameCheck,n)||P.tagNameCheck instanceof Function&&P.tagNameCheck(n))))return!1}else if(!it[t]&&!v(Ue,te(n,j,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ne(n,`data:`)===0&&nt[e])&&!(Je&&!v(Ve,te(n,j,``)))&&n)return!1}return!0},Ot=function(e){return e!==`annotation-xml`&&g(e,He)},kt=function(e){$(k.beforeSanitizeAttributes,e,null);let{attributes:t}=e;if(!t||wt(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:N,forceKeepAttr:void 0},i=t.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=t[i],c=Y(a),l=s,d=a===`value`?l:re(l);if(r.attrName=c,r.attrValue=d,r.keepAttr=!0,r.forceKeepAttr=void 0,$(k.uponSanitizeAttribute,e,r),d=r.attrValue,Qe&&(c===`id`||c===`name`)&&(Q(a,e),d=`user-content-`+d),Xe&&v(/((--!?|])>)|<\\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){Q(a,e);continue}if(c===`attributename`&&g(d,`href`)){Q(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){Q(a,e);continue}if(!Ye&&v(/\\/>/i,d)){Q(a,e);continue}R&&u([Le,A,Re],e=>{d=te(d,e,` `)});let f=Y(e.nodeName);if(!Dt(f,c,d)){Q(a,e);continue}if(E&&typeof be==`object`&&typeof be.getAttributeType==`function`&&!o)switch(be.getAttributeType(f,c)){case`TrustedHTML`:d=E.createHTML(d);break;case`TrustedScriptURL`:d=E.createScriptURL(d);break}if(d!==l)try{o?e.setAttributeNS(o,a,d):e.setAttribute(a,d),wt(e)?Z(e):ee(n.removed)}catch{Q(a,e)}}$(k.afterSanitizeAttributes,e,null)},At=function e(t){let n=null,r=Ct(t);for($(k.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)$(k.uponSanitizeShadowNode,n,null),Et(n),kt(n),n.content instanceof c&&e(n.content);$(k.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=null,a=null,o=null,s=null;if(ct=!e,ct&&(e=`<!-->`),typeof e!=`string`&&!Tt(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw y(`dirty is not a string, aborting`)}else throw y(`toString is not a function`);if(!n.isSupported)return e;if(Ze||vt(t),n.removed=[],typeof e==`string`&&(et=!1),et){if(e.nodeName){let t=Y(e.nodeName);if(!M[t]||F[t])throw y(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof b)r=St(`<!---->`),a=r.ownerDocument.importNode(e,!0),a.nodeType===De.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?r=a:r.appendChild(a);else{if(!V&&!R&&!z&&e.indexOf(`<`)===-1)return E&&U?E.createHTML(e):e;if(r=St(e),!r)return V?null:U?D:``}r&&B&&Z(r.firstChild);let l=Ct(et?e:r);for(;o=l.nextNode();)Et(o),kt(o),o.content instanceof c&&At(o.content);if(et)return e;if(V){if(H)for(s=Pe.call(r.ownerDocument);r.firstChild;)s.appendChild(r.firstChild);else s=r;return(N.shadowroot||N.shadowrootmode)&&(s=Ie.call(i,s,!0)),s}let d=z?r.outerHTML:r.innerHTML;return z&&M[`!doctype`]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&v(we,r.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+r.ownerDocument.doctype.name+`>\n`+d),R&&u([Le,A,Re],e=>{d=te(d,e,` `)}),E&&U?E.createHTML(d):d},n.setConfig=function(){vt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Ze=!0},n.clearConfig=function(){X=null,Ze=!1},n.isValidAttribute=function(e,t,n){return X||vt({}),Dt(Y(e),Y(t),n)},n.addHook=function(e,t){typeof t==`function`&&f(k[e],t)},n.removeHook=function(e,t){if(t!==void 0){let n=d(k[e],t);return n===-1?void 0:p(k[e],n,1)[0]}return ee(k[e])},n.removeHooks=function(e){k[e]=[]},n.removeAllHooks=function(){k=Ae()},n}var Me=je(),T=class e{static instance;baseUrl=``;bearerToken=null;constructor(){}static getInstance(){return e.instance||=new e,e.instance}setBearerToken(e){this.bearerToken=e}async get(e,t={},n=`api/v1`){return fetch(`${this.baseUrl}/${n}/${e}`,{...t,method:`GET`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${this.bearerToken}`,...t.headers}})}async post(e,t,n={},r=`api/v1`){return fetch(`${this.baseUrl}/${r}/${e}`,{body:Me.sanitize(JSON.stringify(t)),method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${this.bearerToken}`,...n.headers},...n})}},E=Object.defineProperty,D=(e,t,n)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t,n)=>D(e,typeof t==`symbol`?t:t+``,n),Ne={"#":{pattern:/[0-9]/},"@":{pattern:/[a-zA-Z]/},"*":{pattern:/[a-zA-Z0-9]/}},Pe=(e,t,n)=>e.replaceAll(t,``).replace(n,`.`).replace(`..`,`.`).replace(/[^.\\d]/g,``),Fe=(e,t,n)=>new Intl.NumberFormat(n.number?.locale??`en`,{minimumFractionDigits:e,maximumFractionDigits:t,roundingMode:`trunc`}),Ie=(e,t=!0,n)=>{let r=n.number?.unsigned!==!0&&e.startsWith(`-`)?`-`:``,i=n.number?.fraction??0,a=Fe(0,i,n),o=a.formatToParts(1000.12),s=o.find(e=>e.type===`group`)?.value??` `,c=o.find(e=>e.type===`decimal`)?.value??`.`,l=Pe(e,s,c);if(Number.isNaN(parseFloat(l)))return r;let u=l.split(`.`);u[1]!=null&&u[1].length>=1&&(a=Fe(u[1].length<=i?u[1].length:i,i,n));let d=a.format(parseFloat(l));return t?i>0&&l.endsWith(`.`)&&!l.slice(0,-1).includes(`.`)&&(d+=c):d=Pe(d,s,c),r+d},k=e=>JSON.parse(e.replaceAll(`\'`,`"`)),Le=(e,t={})=>{let n={...t};e.dataset.maska!=null&&e.dataset.maska!==``&&(n.mask=Re(e.dataset.maska)),e.dataset.maskaEager!=null&&(n.eager=A(e.dataset.maskaEager)),e.dataset.maskaReversed!=null&&(n.reversed=A(e.dataset.maskaReversed)),e.dataset.maskaTokensReplace!=null&&(n.tokensReplace=A(e.dataset.maskaTokensReplace)),e.dataset.maskaTokens!=null&&(n.tokens=ze(e.dataset.maskaTokens));let r={};return e.dataset.maskaNumberLocale!=null&&(r.locale=e.dataset.maskaNumberLocale),e.dataset.maskaNumberFraction!=null&&(r.fraction=parseInt(e.dataset.maskaNumberFraction)),e.dataset.maskaNumberUnsigned!=null&&(r.unsigned=A(e.dataset.maskaNumberUnsigned)),(e.dataset.maskaNumber!=null||Object.values(r).length>0)&&(n.number=r),n},A=e=>e===``?!0:!!JSON.parse(e),Re=e=>e.startsWith(`[`)&&e.endsWith(`]`)?k(e):e,ze=e=>{if(e.startsWith(`{`)&&e.endsWith(`}`))return k(e);let t={};return e.split(`|`).forEach(e=>{let n=e.split(`:`);t[n[0]]={pattern:Be()?new RegExp(n[1],`u`):new RegExp(n[1]),optional:n[2]===`optional`,multiple:n[2]===`multiple`,repeated:n[2]===`repeated`}}),t},Be=()=>{try{return!0}catch{return!1}},Ve=class{constructor(e={}){O(this,`opts`,{}),O(this,`memo`,new Map);let t={...e};if(t.tokens!=null){t.tokens=t.tokensReplace?{...t.tokens}:{...Ne,...t.tokens};for(let e of Object.values(t.tokens))typeof e.pattern==`string`&&(e.pattern=Be()?new RegExp(e.pattern,`u`):new RegExp(e.pattern))}else t.tokens=Ne;Array.isArray(t.mask)&&(t.mask.length>1?t.mask=[...t.mask].sort((e,t)=>e.length-t.length):t.mask=t.mask[0]??``),t.mask===``&&(t.mask=null),this.opts=t}masked(e){return this.process(String(e),this.findMask(String(e)))}unmasked(e){return this.process(String(e),this.findMask(String(e)),!1)}isEager(){return this.opts.eager===!0}isReversed(){return this.opts.reversed===!0}completed(e){let t=this.findMask(String(e));if(this.opts.mask==null||t==null)return!1;let n=this.process(String(e),t).length;return typeof this.opts.mask==`string`?n>=this.opts.mask.length:n>=t.length}findMask(e){let t=this.opts.mask;if(t==null)return null;if(typeof t==`string`)return t;if(typeof t==`function`)return t(e);let n=this.process(e,t.slice(-1).pop()??``,!1);return t.find(t=>this.process(e,t,!1).length>=n.length)??``}escapeMask(e){let t=[],n=[];return e.split(``).forEach((r,i)=>{r===`!`&&e[i-1]!==`!`?n.push(i-n.length):t.push(r)}),{mask:t.join(``),escaped:n}}process(e,t,n=!0){if(this.opts.number!=null)return Ie(e,n,this.opts);if(t==null)return e;let r=`v=${e},mr=${t},m=${n?1:0}`;if(this.memo.has(r))return this.memo.get(r);let{mask:i,escaped:a}=this.escapeMask(t),o=[],s=this.opts.tokens==null?{}:this.opts.tokens,c=this.isReversed()?-1:1,l=this.isReversed()?`unshift`:`push`,u=this.isReversed()?0:i.length-1,d=this.isReversed()?()=>m>-1&&h>-1:()=>m<i.length&&h<e.length,ee=e=>!this.isReversed()&&e<=u||this.isReversed()&&e>=u,f,p=-1,m=this.isReversed()?i.length-1:0,h=this.isReversed()?e.length-1:0,g=!1;for(;d();){let t=i.charAt(m),r=s[t],d=r?.transform==null?e.charAt(h):r.transform(e.charAt(h));if(!a.includes(m)&&r!=null?(d.match(r.pattern)==null?r.multiple?g&&=(m+=c,h-=c,!1):d===f?f=void 0:r.optional&&(m+=c,h-=c):(o[l](d),r.repeated?(p===-1?p=m:m===u&&m!==p&&(m=p-c),u===p&&(m-=c)):r.multiple&&(g=!0,m-=c),m+=c),h+=c):(n&&!this.isEager()&&o[l](t),d===t&&!this.isEager()?h+=c:f=t,this.isEager()||(m+=c)),this.isEager())for(;ee(m)&&(s[i.charAt(m)]==null||a.includes(m));){if(n){if(o[l](i.charAt(m)),e.charAt(h)===i.charAt(m)){m+=c,h+=c;continue}}else i.charAt(m)===e.charAt(h)&&(h+=c);m+=c}}return this.memo.set(r,o.join(``)),this.memo.get(r)}},j=class{constructor(e,t={}){O(this,`items`,new Map),O(this,`eventAbortController`),O(this,`onInput`,e=>{if(e instanceof CustomEvent&&e.type===`input`&&!e.isTrusted&&!e.bubbles)return;let t=e.target,n=this.items.get(t);if(n===void 0)return;let r=`inputType`in e&&e.inputType.startsWith(`delete`),i=n.isEager(),a=r&&i&&n.unmasked(t.value)===``?``:t.value;this.fixCursor(t,r,()=>this.setValue(t,a))}),this.options=t,this.eventAbortController=new AbortController,this.init(this.getInputs(e))}update(e={}){this.options={...e},this.init(Array.from(this.items.keys()))}updateValue(e){e.value!==``&&e.value!==this.processInput(e)?.masked&&this.setValue(e,e.value)}destroy(){this.eventAbortController.abort(),this.items.clear()}init(e){let t=this.getOptions(this.options);for(let n of e){if(!this.items.has(n)){let{signal:e}=this.eventAbortController;n.addEventListener(`input`,this.onInput,{capture:!0,signal:e})}let e=new Ve(Le(n,t));this.items.set(n,e),queueMicrotask(()=>this.updateValue(n)),n.selectionStart===null&&e.isEager()&&console.warn("Maska: input of `%s` type is not supported",n.type)}}getInputs(e){return typeof e==`string`?Array.from(document.querySelectorAll(e)):`length`in e?Array.from(e):[e]}getOptions(e){let{onMaska:t,preProcess:n,postProcess:r,...i}=e;return i}fixCursor(e,t,n){let r=e.selectionStart,i=e.value;if(n(),r===null||r===i.length&&!t)return;let a=e.value,o=i.slice(0,r),s=a.slice(0,r),c=this.processInput(e,o)?.unmasked,l=this.processInput(e,s)?.unmasked;if(c===void 0||l===void 0)return;let u=r;o!==s&&(u+=t?a.length-i.length:c.length-l.length),e.setSelectionRange(u,u)}setValue(e,t){let n=this.processInput(e,t);n!==void 0&&(e.value=n.masked,this.options.onMaska!=null&&(Array.isArray(this.options.onMaska)?this.options.onMaska.forEach(e=>e(n)):this.options.onMaska(n)),e.dispatchEvent(new CustomEvent(`maska`,{detail:n})),e.dispatchEvent(new CustomEvent(`input`,{detail:n.masked})))}processInput(e,t){let n=this.items.get(e);if(n===void 0)return;let r=t??e.value;this.options.preProcess!=null&&(r=this.options.preProcess(r));let i=n.masked(r);return this.options.postProcess!=null&&(i=this.options.postProcess(i)),{masked:i,unmasked:n.unmasked(r),completed:n.completed(r)}}},He={minimumFractionDigits:2,maximumFractionDigits:2,useGrouping:!0},Ue=new Intl.NumberFormat(`en-US`,He);function M(e,t=`USD`,n=`currency`){return new Intl.NumberFormat(`en-US`,{style:n,currency:t,...He}).format(e)}function We(e){if(!e?.trim())return`—`;let t=e.trim();return t.startsWith(`#`)?t:`#${t}`}var N=(e,t)=>e.querySelector(`input[name="${t}"], select[name="${t}"]`),Ge=(e,t)=>{let n=e.querySelector(`button[type="submit"]`);if(n){n.disabled=t;let e=n.dataset.label??`Pagar`,r=n.dataset.loadingLabel??`Procesando...`;n.textContent=t?r:e}},P=e=>{e.reset();let t=e.querySelector(`select[name="documentType"]`);t&&(t.value=`dui`,t.dispatchEvent(new Event(`change`,{bubbles:!0})))},F=(e,t,n)=>{let r=e.querySelector(`.form-alert`);r&&(r.innerHTML=`<h3>`+t+`</h3><p>`+n+`</p>`,r.classList.remove(`form-alert--receipt`),r.classList.add(`visible`))},I=(e,t)=>{let n=document.querySelector(`.form-header`);if(n){let e=n.querySelector(`.commerce-logo`);e&&(n.innerHTML=``,n.appendChild(e))}let r=document.querySelector(`.divider-header`);r&&(r.style.display=`none`);let i=t.data,a=M(i.amount_cents/100,i.amount_currency),o=`${i.date}, ${i.time}`,s=We(i.reference_number),c=We(i.authorization_number);e.innerHTML=`<div class="payment-success"><p class="payment-success__amount">`+a+`</p><p class="payment-success__datetime">`+o+`</p><div class="payment-success__blocks"><div class="payment-success__block"><span class="payment-success__label">Número de referencia</span><span class="payment-success__value">`+s+`</span></div><div class="payment-success__block"><span class="payment-success__label">Número de autorización</span><span class="payment-success__value">`+c+`</span></div></div><div class="payment-success__footer"><h3 class="payment-success__done">¡Gracias por tu compra!</h3></div></div>`},L=(e,t,n)=>{let r=N(e,t);if(!r)return;let i=r.closest(`.input-wrapper`),a=i?.parentElement?.querySelector(`.field-error`);n?(i&&i.classList.add(`has-error`),a&&(a.textContent=n,a.classList.add(`visible`),Ke(a))):(i&&i.classList.remove(`has-error`),a&&(a.textContent=``,a.classList.remove(`visible`)))},Ke=e=>{e.scrollIntoView({behavior:`smooth`,block:`center`})},qe=e=>{let t=e.find(e=>e.name===`amount`);t&&(t.addEventListener(`input`,function(){let e=t.value.replace(/\\D/g,``);if(e){let n=parseInt(e,10)/100;t.value=Ue.format(n)}else t.value=``}),t.addEventListener(`blur`,()=>{parent.postMessage({type:`payment-form:validate-amount`,amount:t.value},`*`)}))},Je=class e{static instance;states=[];statesLoadError=null;constructor(){}static getInstance(){return e.instance||=new e,e.instance}getStates(){return this.states}setStates(e){this.states=e}getStatesLoadError(){return this.statesLoadError}async fetchStates(e){let t=await T.getInstance().get(`resources/countries/${e}/states`),n=await t.json();return t.ok?(this.statesLoadError=null,this.setStates(n.data),n):(this.statesLoadError=`No se pudo cargar la lista de estados.`,this.setStates([]),n)}},Ye=e=>{let t=e.find(e=>e.name===`documentType`),n=e.find(e=>e.name===`billingDocumentNumber`);if(!t||!n)return;let r=new j(n);t.addEventListener(`change`,function(e){r?.destroy(),e.target.value===`dui`?(n.setAttribute(`inputmode`,`numeric`),n.setAttribute(`data-maska`,`########-#`),r=new j(n)):(n.removeAttribute(`inputmode`),n.removeAttribute(`data-maska`),n.value=``,r=null)})},R=e=>{e.forEach(function(e){e instanceof HTMLInputElement&&(e.addEventListener(`blur`,function(){let t=e.dataset.maskaValue||e.value;parent.postMessage({type:`payment-form:validate`,field:e.name,value:t},`*`)}),e.addEventListener(`input`,function(){let t=e.closest(`.input-wrapper`),n=t?.parentElement?.querySelector(`.field-error`);t&&t.classList.remove(`has-error`),n&&(n.textContent=``,n.classList.remove(`visible`))})),e instanceof HTMLSelectElement&&e.addEventListener(`change`,function(){parent.postMessage({type:`payment-form:validate`,field:e.name,value:e.value},`*`)})})},Xe=(e,t)=>{e.addEventListener(`submit`,function(e){e.preventDefault();let n={};t.forEach(function(e){n[e.name]=e.dataset.maskaValue||e.value}),parent.postMessage({type:`payment-form:submit`,value:n},`*`)})};function z(e=document.body){let t=new ResizeObserver(()=>{let{width:t,height:n}=e.getBoundingClientRect();parent.postMessage({type:`payment-form:sizing`,width:t,height:n},`*`)});return t.observe(e),t}var Ze=T.getInstance();new j(`input[data-maska]:not([name="billingDocumentNumber"])`);var B=document.getElementById(`payment-form`),V=B.querySelectorAll(`input, select`),H=Array.from(V.values());qe(H),Ye(H);var U=H.find(e=>e.name===`country`),W=H.find(e=>e.name===`region`);if(U instanceof HTMLSelectElement){let e=Je.getInstance();U.addEventListener(`change`,async function(){if(U.value===``)return;if(L(B,`region`,``),W instanceof HTMLSelectElement){W.innerHTML=``;let e=document.createElement(`option`);e.value=``,e.textContent=`Cargando...`,W.appendChild(e),W.disabled=!0}let t=await e.fetchStates(U.value);if(W instanceof HTMLSelectElement&&(W.disabled=!1,W.innerHTML=``),`error`in t){let t=e.getStatesLoadError();t&&L(B,`region`,t);return}if(e.setStates(t.data),parent.postMessage({type:`payment-form:states-loaded`,states:t.data},`*`),W instanceof HTMLSelectElement){let e=document.createElement(`option`);e.value=``,e.textContent=`Selecciona aquí`,W.appendChild(e),t.data.forEach(e=>{let t=document.createElement(`option`);t.value=e.id,t.textContent=e.name,W.appendChild(t)})}})}R(H),z(),window.addEventListener(`message`,function(e){if(!(!e.data||!e.data.type))switch(e.data.type){case`payment-form:set-submit-loading`:Ge(B,e.data.disabled);break;case`payment-form:reset`:P(B);break;case`payment-form:alert`:F(B,e.data.title,e.data.message);break;case`payment-form:validation-result`:L(B,e.data.field,e.data.error);break;case`payment-form:success`:I(B,e.data.paymentIntent);break;case`payment-form:set-token`:Ze.setBearerToken(e.data.token);break;default:break}}),Xe(B,H)})();',Bt=`data:image/svg+xml,%3csvg%20width='99'%20height='32'%20viewBox='0%200%2099%2032'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M27.3848%200C29.8942%206.60543e-06%2031.9284%202.03883%2031.9284%204.55384V27.4462C31.9284%2029.9611%2029.8942%2032%2027.3848%2032H4.54376C2.03439%2032%203.69132e-05%2029.9611%200%2027.4462V4.55384C0%202.03882%202.03437%200%204.54376%200H27.3848ZM12.0067%205.0348C11.1292%205.03257%2010.3064%205.37037%209.68349%205.98797C9.0639%206.60335%208.70775%207.46498%208.70775%208.35337V15.4962C8.70775%2016.0154%209.12754%2016.4372%209.64666%2016.4372C10.1647%2016.4372%2010.5856%2016.0165%2010.5856%2015.4962V8.331C10.5856%207.95282%2010.7328%207.59689%2011.0008%207.32948C11.2676%207.06208%2011.6215%206.91564%2011.9978%206.91564H12.0023C12.7781%206.91791%2013.4099%207.56007%2013.4099%208.34774V13.5762C13.4099%2014.5508%2014.1982%2015.3407%2015.1705%2015.3407H18.1221C18.9695%2015.3407%2019.7934%2015.6518%2020.4119%2016.2325C21.0851%2016.8647%2021.4568%2017.7273%2021.4568%2018.647V21.6646C21.4568%2022.5473%2021.1141%2023.3776%2020.4901%2024.003C19.8672%2024.6274%2019.0387%2024.972%2018.1568%2024.972H14.0229C13.1689%2024.972%2012.3315%2024.67%2011.7063%2024.0871C11.0287%2023.4538%2010.6547%2022.5889%2010.6547%2021.6658V20.9799C10.6547%2020.7315%2010.7529%2020.4931%2010.9282%2020.3163L12.5169%2018.7242C12.6922%2018.5485%2012.93%2018.45%2013.1778%2018.45H15.6618C16.0067%2018.4501%2016.3449%2018.5688%2016.6005%2018.8004C16.8941%2019.0655%2017.056%2019.4314%2017.0549%2019.823C17.0527%2020.576%2016.4331%2021.188%2015.6729%2021.188H13.3161C12.7982%2021.188%2012.3774%2021.6087%2012.3774%2022.1289C12.3774%2022.6481%2012.797%2023.0699%2013.3161%2023.0699H15.6896C16.759%2023.0699%2017.755%2022.5518%2018.3813%2021.6355C18.6346%2021.2651%2018.8066%2020.841%2018.8825%2020.398C19.0666%2019.3273%2018.7339%2018.2823%2017.9949%2017.5338C17.3898%2016.9207%2016.5413%2016.5692%2015.6683%2016.5692H13.2045C12.9232%2016.5692%2012.643%2016.605%2012.3729%2016.6867C11.9196%2016.8243%2011.5189%2017.0638%2011.1884%2017.395L9.62652%2018.9614C9.4334%2019.1549%209.26156%2019.372%209.12983%2019.6115C8.89539%2020.0389%208.77596%2020.5021%208.77596%2020.981V21.6669C8.77597%2022.3673%208.91323%2023.0464%209.18337%2023.6864C9.44348%2024.304%209.81749%2024.859%2010.292%2025.3356C10.7664%2025.8112%2011.3202%2026.186%2011.9364%2026.4467C12.575%2026.7174%2013.2526%2026.855%2013.9514%2026.855H18.1546C18.8534%2026.855%2019.5311%2026.7174%2020.1696%2026.4467C20.7859%2026.1849%2021.3396%2025.8112%2021.8141%2025.3356C22.2885%2024.8601%2022.6626%2024.3052%2022.9227%2023.6876C23.1928%2023.0476%2023.3301%2022.3684%2023.3301%2021.668V18.6503C23.3301%2017.9499%2023.1928%2017.2708%2022.9227%2016.6309L22.9259%2016.6274C22.6647%2016.0098%2022.2918%2015.4549%2021.8174%2014.9794C21.3418%2014.5028%2020.7891%2014.1291%2020.1729%2013.8684C19.5343%2013.5976%2018.8567%2013.4598%2018.1579%2013.4598H15.2865V8.331C15.2865%207.46722%2014.9562%206.65034%2014.3545%206.03272C13.7416%205.40167%2012.8852%205.03816%2012.0067%205.0348Z'%20fill='%23121417'/%3e%3cpath%20d='M53.3405%2027.9622C52.2765%2027.9622%2051.291%2027.7244%2050.3858%2027.2507C49.4807%2026.7769%2048.7229%2026.121%2048.1143%2025.2809V25.8218C48.1143%2026.7616%2047.3527%2027.5249%2046.415%2027.5249C45.4773%2027.5249%2044.7157%2026.7616%2044.7157%2025.8218V5.70262C44.7157%204.76283%2045.4773%203.99949%2046.415%203.99949C47.3527%203.99949%2048.1143%204.76283%2048.1143%205.70262V15.6663C48.6789%2014.855%2049.408%2014.2202%2050.3055%2013.7656C51.201%2013.3092%2052.1904%2013.0809%2053.2735%2013.0809C54.6112%2013.0809%2055.8072%2013.4051%2056.8635%2014.0514C57.918%2014.6997%2058.7485%2015.5819%2059.3532%2016.6982C59.9579%2017.8144%2060.2603%2019.0898%2060.2603%2020.5206C60.2603%2021.9514%2059.9503%2023.2422%2059.3321%2024.3642C58.714%2025.4862%2057.8835%2026.3665%2056.8406%2027.0033C55.7995%2027.6419%2054.6322%2027.9603%2053.3405%2027.9603V27.9622ZM52.3722%2025.0489C53.218%2025.0489%2053.9663%2024.8552%2054.6169%2024.4677C55.2676%2024.0803%2055.7766%2023.5471%2056.1459%2022.8682C56.5133%2022.1892%2056.699%2021.4125%2056.699%2020.536C56.699%2019.6595%2056.5095%2018.8789%2056.1325%2018.1903C55.7555%2017.5018%2055.2427%2016.9648%2054.5978%2016.5754C53.951%2016.188%2053.2104%2015.9943%2052.3741%2015.9943C51.5378%2015.9943%2050.7877%2016.188%2050.1294%2016.5754C49.4692%2016.9628%2048.9525%2017.5018%2048.5813%2018.1903C48.2081%2018.8789%2048.0225%2019.6614%2048.0225%2020.536C48.0225%2021.4105%2048.2062%2022.1892%2048.5755%2022.8682C48.9449%2023.5471%2049.4577%2024.0803%2050.1179%2024.4677C50.7781%2024.8552%2051.5302%2025.0489%2052.376%2025.0489H52.3722Z'%20fill='%23121417'/%3e%3cpath%20d='M64.816%2010.647C64.4429%2010.647%2064.1003%2010.553%2063.7865%2010.367C63.4726%2010.1809%2063.2219%209.92969%2063.0363%209.61515C62.8488%209.30061%2062.7569%208.95154%2062.7569%208.56795C62.7569%208.18437%2062.8507%207.85256%2063.0363%207.54186C63.2219%207.23115%2063.4726%206.98374%2063.7865%206.79578C64.1003%206.60974%2064.4429%206.51576%2064.816%206.51576C65.1892%206.51576%2065.5413%206.60974%2065.8456%206.79578C66.1498%206.98374%2066.3967%207.23115%2066.5823%207.54186C66.7679%207.85256%2066.8617%208.19396%2066.8617%208.56795C66.8617%208.94195%2066.7679%209.30061%2066.5823%209.61515C66.3948%209.92969%2066.1498%2010.1809%2065.8456%2010.367C65.5413%2010.5549%2065.1968%2010.647%2064.816%2010.647ZM63.109%2025.8217V15.2213C63.109%2014.2815%2063.8707%2013.5182%2064.8084%2013.5182C65.746%2013.5182%2066.5077%2014.2815%2066.5077%2015.2213V25.8217C66.5077%2026.7615%2065.746%2027.5249%2064.8084%2027.5249C63.8707%2027.5249%2063.109%2026.7615%2063.109%2025.8217Z'%20fill='%23121417'/%3e%3cpath%20d='M70.9719%2025.4033L78.0104%2016.1569H71.7795C71.0523%2016.1569%2070.4629%2015.5662%2070.4629%2014.8374C70.4629%2014.1086%2071.0523%2013.5178%2071.7795%2013.5178H81.1736C82.2644%2013.5178%2082.8825%2014.7702%2082.2204%2015.6391L75.1724%2024.8835H82.1113C82.8385%2024.8835%2083.4279%2025.4743%2083.4279%2026.2031C83.4279%2026.9319%2082.8385%2027.5226%2082.1113%2027.5226H72.0187C70.9279%2027.5226%2070.3098%2026.2702%2070.9719%2025.4014V25.4033Z'%20fill='%23121417'/%3e%3cpath%20d='M86.544%2025.4033L93.5824%2016.1569H87.3516C86.6244%2016.1569%2086.035%2015.5662%2086.035%2014.8374C86.035%2014.1086%2086.6244%2013.5178%2087.3516%2013.5178H96.7457C97.8365%2013.5178%2098.4546%2014.7702%2097.7925%2015.6391L90.7445%2024.8835H97.6834C98.4106%2024.8835%2099%2025.4743%2099%2026.2031C99%2026.9319%2098.4106%2027.5226%2097.6834%2027.5226H87.5908C86.5%2027.5226%2085.8819%2026.2702%2086.544%2025.4014V25.4033Z'%20fill='%23121417'/%3e%3c/svg%3e`;function Vt(e){let t=`<img src="${Bt}" alt="Bizz Logo" class="bizz-logo">`;return Rt.replace(`<!--BIZZ_LOGO-->`,t).replace(`<!--HEADER-->`,e.headerHtml).replace(`<!--AMOUNT_FIELD-->`,e.amountHtml).replace(`<!--FIELDS-->`,e.fieldsHtml).replace(`<!--SUBMIT_BUTTON-->`,e.submitButtonHtml).replace(`<!--SCRIPT-->`,`<script>${zt}<\/script>`)}function Ht(e){let t=document.createElement(`iframe`);return t.style.border=`none`,t.style.display=`block`,t.style.overflow=`hidden`,t.srcdoc=e,t.style.width=`100%`,t.style.height=`100%`,t}var Ut=`<svg
378
+ xmlns="http://www.w3.org/2000/svg"
379
+ width="24"
380
+ height="24"
381
+ viewBox="0 0 24 24"
382
+ fill="none"
383
+ stroke="currentColor"
384
+ stroke-width="2"
385
+ stroke-linecap="round"
386
+ stroke-linejoin="round"
387
+ class="icon icon-tabler icons-tabler-outline icon-tabler-currency-dollar"
388
+ >
389
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
390
+ <path d="M16.7 8a3 3 0 0 0 -2.7 -2h-4a3 3 0 0 0 0 6h4a3 3 0 0 1 0 6h-4a3 3 0 0 1 -2.7 -2" />
391
+ <path d="M12 3v3m0 12v3" />
392
+ </svg>`,Wt=`<svg
393
+ xmlns="http://www.w3.org/2000/svg"
394
+ width="24"
395
+ height="24"
396
+ viewBox="0 0 24 24"
397
+ fill="none"
398
+ stroke="currentColor"
399
+ stroke-width="2"
400
+ stroke-linecap="round"
401
+ stroke-linejoin="round"
402
+ class="icon icon-tabler icons-tabler-outline icon-tabler-credit-card"
403
+ >
404
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
405
+ <path d="M3 8a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3l0 -8" />
406
+ <path d="M3 10l18 0" />
407
+ <path d="M7 15l.01 0" />
408
+ <path d="M11 15l2 0" />
409
+ </svg>`,Gt=`<svg
410
+ xmlns="http://www.w3.org/2000/svg"
411
+ width="24"
412
+ height="24"
413
+ viewBox="0 0 24 24"
414
+ fill="none"
415
+ stroke="currentColor"
416
+ stroke-width="2"
417
+ stroke-linecap="round"
418
+ stroke-linejoin="round"
419
+ class="icon icon-tabler icons-tabler-outline icon-tabler-calendar"
420
+ >
421
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
422
+ <path d="M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12" />
423
+ <path d="M16 3v4" />
424
+ <path d="M8 3v4" />
425
+ <path d="M4 11h16" />
426
+ <path d="M11 15h1" />
427
+ <path d="M12 15v3" />
428
+ </svg>`,Kt=`<svg
429
+ xmlns="http://www.w3.org/2000/svg"
430
+ width="24"
431
+ height="24"
432
+ viewBox="0 0 24 24"
433
+ fill="none"
434
+ stroke="currentColor"
435
+ stroke-width="2"
436
+ stroke-linecap="round"
437
+ stroke-linejoin="round"
438
+ class="icon icon-tabler icons-tabler-outline icon-tabler-shield-lock"
439
+ >
440
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
441
+ <path d="M12 3a12 12 0 0 0 8.5 3a12 12 0 0 1 -8.5 15a12 12 0 0 1 -8.5 -15a12 12 0 0 0 8.5 -3" />
442
+ <path d="M11 11a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" />
443
+ <path d="M12 12l0 2.5" />
444
+ </svg>`,qt=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-mail"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10" /><path d="M3 7l9 6l9 -6" /></svg>`,Jt=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-user"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0" /><path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" /></svg>`,Yt=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-message-circle"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1" /></svg>`,Xt=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-id"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3 7a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v10a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3l0 -10" /><path d="M7 10a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M15 8l2 0" /><path d="M15 12l2 0" /><path d="M7 16l10 0" /></svg>`,Zt=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-device-mobile"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 5a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2v-14" /><path d="M11 4h2" /><path d="M12 17v.01" /></svg>`,Qt=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-map-pin"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 11a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" /><path d="M17.657 16.657l-4.243 4.243a2 2 0 0 1 -2.827 0l-4.244 -4.243a8 8 0 1 1 11.314 0" /></svg>`,$t={"currency-dollar":Ut,"credit-card":Wt,calendar:Gt,"shield-lock":Kt,email:qt,user:Jt,description:Yt,document:Xt,phone:Zt,"map-pin":Qt};function en(e){let t=$t[e];if(!t)throw Error(`Icon "${e}" not found`);return t}var tn=class e{static instance;currentDate=new Date;currentYear=this.currentDate.getFullYear();currentMonth=this.currentDate.getMonth()+1;static getInstance(){return e.instance||=new e,e.instance}validateField(e,t){return this.inputRequired(t)||({amount:e=>this.amountInput(e),cardNumber:e=>this.cardNumberInput(e),cardExpiry:e=>this.cardExpiryInput(e),cardCvc:e=>this.cardCvcInput(e),email:e=>this.emailInput(e)}[e]?.(t)??``)}inputRequired(e){return e.trim()===``?`Este campo es requerido`:``}amountInput(e){return Number(e)<=0?`El monto debe ser mayor a 0`:``}cardNumberInput(e){let t=e.replace(/\s/g,``);return/^[0-9]{16}$/.test(t)?_t(t)===`not_valid`?`Por favor ingrese una tarjeta visa, mastercard o union_pay`:``:`Por favor, ingrese un número de tarjeta válido`}cardExpiryInput(e){let[t,n]=e.split(`/`),r=Number(this.currentYear.toString().slice(-2));return Number(n)<r?`El año de expiración no puede ser anterior al año actual`:Number(t)<1||Number(t)>12?`El mes de expiración debe estar entre 01 y 12`:Number(n)===r&&Number(t)<this.currentMonth?`La tarjeta está expirada`:``}emailInput(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?``:`Por favor, ingrese un email válido`}cardCvcInput(e){return/^[0-9]{3,4}$/.test(e)?``:`Por favor, ingrese un código de seguridad válido`}},nn=(e,t,n,r)=>Object.keys(t).map(i=>{let a=t[i],o=e.get(i);return{name:i,label:o?.label??a.label,placeholder:o?.placeholder??a.placeholder??a.label,iconSvg:en(a.icon),mask:a.mask,divider:a.divider,type:a.type??`text`,options:a.type===`select`?a.options:void 0,default:a.default,amountValue:n?Et(n/100,`USD`,`decimal`):void 0,disabled:i===`amount`?r:!1}}),rn=[{code:`51`,title:`¡Fondos insuficientes!`,message:`Intenta con otra tarjeta o confirma que tengas saldo disponible.`},{code:`04`,title:`¡Tarjeta bloqueada!`,message:`Contacta a tu banco o prueba con otra tarjeta.`},{code:`96`,title:`¡Sistema no disponible!`,message:`Vuelve a intentar en unos minutos.`},{code:`54`,title:`¡Tarjeta expirada!`,message:`Revisa la fecha de vencimiento o usa otra tarjeta.`},{code:`06`,title:`¡CVV no válido!`,message:`Verifica el código de seguridad e inténtalo de nuevo.`},{code:`99`,title:`¡Transacción inválida!`,message:`Revisa tus datos e inténtalo de nuevo.`}],an=e=>rn.find(t=>t.code===e)||{title:`¡Error al pagar!`,message:`Tu compra no pudo ser procesada!
445
+ Por favor revisa tu información e inténtalo de nuevo`,code:0},on={subtotal_cents:`amount`,billing_document_number:`billingDocumentNumber`,billing_email:`email`,card_network:`cardNumber`,cardholder_name:`cardHolder`,billing_name:`cardHolder`,country:`country`,description:`description`},sn=new Set([`iv`,`tag`,`encrypted_data`,`encrypted_key`]),cn=class{origin;constructor(e){this.origin=e}sendServerValidationErrors(e,t){if(typeof t==`string`||!e)return!1;let n=this.buildValidationResults(t);for(let t of n)e.postMessage({type:`payment-form:validation-result`,field:t.field,error:t.error},this.origin);return n.length>0}hasEncryptionPayloadErrors(e){return typeof e==`string`?!1:Object.keys(e).some(e=>sn.has(e))}resolveServerErrorMessage(e){return typeof e==`string`?e:`Por favor, revisa los campos`}buildValidationResults(e){let t=[];for(let[n,r]of Object.entries(e)){let e=on[n],i=Array.isArray(r)?r.find(e=>typeof e==`string`):void 0;!e||!i||t.push({field:e,error:i})}return t}},ln=class{config;iframe=null;messageHandler=null;successListeners=new Set;failureListeners=new Set;readyListeners=new Set;sizingListeners=new Set;validation=tn.getInstance();origin=u;serverErrorHandler;orchestrator=mt.getInstance();paymentIntent=kt.getInstance();countryContent=dt.getInstance();processPayment=Ct.getInstance();stateContent=gt.getInstance();amountEvaluation=Ot.getInstance();currentAmount;currentValues={};constructor(e){this.config=e,this.currentAmount=e.totalAmount,this.serverErrorHandler=new cn(this.origin)}on(e,t){e===`success`?this.successListeners.add(t):e===`failure`?this.failureListeners.add(t):e===`ready`?this.readyListeners.add(t):e===`sizing`&&this.sizingListeners.add(t)}async setup(){let e=document.querySelector(this.config.iframeTarget);if(!e)throw Error(`Element not found: ${this.config.iframeTarget}`);let t=wt();e.appendChild(t);try{await this.orchestrator.initialize(this.config.branchCode,this.config.paymentRequestCode)}catch(n){t.remove();let r=document.createElement(`div`);r.style.cssText=`font-family:Poppins,sans-serif;text-align:center;padding:32px;color:#DB3339;font-size:14px;`,r.textContent=n instanceof Error?n.message:`Pago no procesado`,e.appendChild(r);return}if(t.remove(),this.applyFixedAmountFromOrderTemplate(),this.renderForm(),this.messageHandler=async e=>{if(e.source!==this.iframe?.contentWindow)return;let t=e.data;if(t?.type){if(t.type===`payment-form:states-loaded`&&this.stateContent.setStates(t.states),t.type===`payment-form:sizing`&&(this.iframe&&(this.iframe.style.height=`${t.height}px`),this.sendSizingEmitter(t.width,t.height)),t.type===`payment-form:validate-amount`){this.currentAmount=Dt(t.amount),this.setSubmitLoading(!0);let e=await this.amountEvaluation.validateAmount(t.amount);if(this.setSubmitLoading(!1),e&&`data`in e){let t=this.orchestrator.getConfig();t.data.secure_mode!==e.data.secure_mode&&(t.data.secure_mode=e.data.secure_mode,this.renderForm())}}if(t.type===`payment-form:validate`){this.currentValues[t.field]=t.value;let e=this.validation.validateField(t.field,t.value);this.iframe?.contentWindow?.postMessage({type:`payment-form:validation-result`,field:t.field,error:e},this.origin)}if(t.type===`payment-form:submit`){t.value.amount&&(this.currentAmount=Dt(t.value.amount));let e=!1,n=Object.keys(t.value);for(let r of n){let n=this.validation.validateField(r,t.value[r]??``);n&&(e=!0,this.iframe?.contentWindow?.postMessage({type:`payment-form:validation-result`,field:r,error:n},this.origin))}if(!e){if(this.setSubmitLoading(!0),this.orchestrator.getConfig().data.secure_mode){try{await this.processPayment.process(t.value,this.config.totalAmount,{sendAlert:(e,t)=>this.sendAlert(e,t),sendSuccess:e=>this.sendSuccess(e),resetForm:()=>this.resetForm()})}catch{let e=`No pudimos obtener información de encriptación`;this.sendAlert(`¡Error al encriptar tus datos!`,e),this.sendFailureEmitter(0,e)}finally{this.setSubmitLoading(!1)}return}let e=await this.paymentIntent.generatePaymentIntentPayload(t.value).catch(e=>{this.setSubmitLoading(!1),this.sendAlert(`¡Error al cifrar tus datos!`,`Por favor, intenta nuevamente, o contacta al comercio.`)});if(!e)return;this.config.totalAmount&&(e.subtotal_cents=this.config.totalAmount);let n=await this.paymentIntent.createPaymentIntent(e);if(this.setSubmitLoading(!1),`error`in n&&`code`in n){if(n.status===422&&this.serverErrorHandler.hasEncryptionPayloadErrors(n.error)){let e=`Error al encriptar tus datos.`;this.sendAlert(`¡Error al encriptar tus datos!`,e),this.sendFailureEmitter(n.status,e);return}if(n.status===422&&this.serverErrorHandler.sendServerValidationErrors(this.iframe?.contentWindow,n.error)){this.sendFailureEmitter(n.status,`Por favor, revisa los campos`);return}n.code===`inactive_company_commerce`?this.sendAlert(`¡Comercio inactivo!`,`Tu compra no pudo ser procesada! El comercio no está disponible por el momento`):n.code===`payment_limit_exceeded`?this.sendAlert(`¡Límite de pago excedido!`,`Por favor, contacta al comercio.`):n.status===422?this.sendAlert(`¡Revisa la información!`,`Por favor, revisa los campos`):this.sendAlert(`¡Error al procesar el pago!`,`Por favor, intenta nuevamente, o contacta al comercio.`),this.sendFailureEmitter(n.status,this.serverErrorHandler.resolveServerErrorMessage(n.error));return}if(n.data.status!==`success`){let e=an(n.data.response_code??``);this.sendAlert(e.title,e.message),this.sendFailureEmitter(0,e.message);return}if(n.data.status===`success`){this.sendSuccess(n),this.resetForm();return}}}}},window.addEventListener(`message`,this.messageHandler),this.config.totalAmount&&Number(this.config.totalAmount)>0)try{this.setSubmitLoading(!0);let e=await this.amountEvaluation.validateAmount(this.config.totalAmount.toString());if(this.setSubmitLoading(!1),e&&`data`in e){let t=this.orchestrator.getConfig();t.data.secure_mode!==e.data.secure_mode&&(t.data.secure_mode=e.data.secure_mode,this.renderForm())}}catch{this.setSubmitLoading(!1),this.sendAlert(`¡Error al validar el monto!`,`Asegúrate de que el monto a pagar sea válido`)}}applyFixedAmountFromOrderTemplate(){if(!this.config.paymentRequestCode)return;let{data:e}=this.orchestrator.getConfig();if(e.order_template_id==null||typeof e.amount_cents!=`number`||e.amount_cents<=0)return;let t=Et(e.amount_cents/100,`USD`,`decimal`);this.config.description=e.description,this.config.totalAmount=Dt(t),this.currentAmount=Dt(t)}renderForm(){let e=document.querySelector(this.config.iframeTarget);if(!e)return;this.iframe&&this.iframe.remove();let t=new Map((this.config.i18n?.fields??[]).map(e=>[e.name,e])),n=this.orchestrator.getConfig().data.secure_mode?Pt:Nt,r=n.country;r&&`options`in r&&(r.options=[...r.options,...this.countryContent.getCountries().map(e=>({label:e.name,value:e.id}))]);let i=!!this.config.totalAmount,a=nn(t,n,this.currentAmount,i);a.forEach(e=>{this.currentValues[e.name]!==void 0&&e.name!==`amount`&&(e.default=this.currentValues[e.name])});let o=this.config.totalAmount?Et(this.config.totalAmount/100,`USD`,`decimal`):``,{amountHtml:s,fieldsHtml:c}=Lt(a);this.iframe=Ht(Vt({headerHtml:It({logo:this.orchestrator.getConfig().data.logo_url,name:this.orchestrator.getConfig().data.name,description:this.config.description,header:this.config.header,totalAmount:o,...o?{icon:en(`currency-dollar`)}:{}}),amountHtml:s,fieldsHtml:c,submitButtonHtml:Ft(this.config.i18n?.submitButton)})),e.appendChild(this.iframe),this.iframe.addEventListener(`load`,()=>{this.setToken(this.orchestrator.getAuthToken().access_token);let e=this.countryContent.getCountriesLoadError();e&&this.serverErrorHandler.sendServerValidationErrors(this.iframe?.contentWindow,{country:[e]}),this.sendReadyEmitter()})}resetForm(){this.iframe?.contentWindow?.postMessage({type:`payment-form:reset`},this.origin)}setSubmitLoading(e){this.iframe?.contentWindow?.postMessage({type:`payment-form:set-submit-loading`,disabled:e},this.origin)}setToken(e){this.iframe?.contentWindow?.postMessage({type:`payment-form:set-token`,token:e},this.origin)}sendAlert(e,t){this.iframe?.contentWindow?.postMessage({type:`payment-form:alert`,title:e,message:t},this.origin)}sendFailureEmitter(e,t){for(let n of this.failureListeners)n({status:e,message:t})}sendReadyEmitter(){for(let e of this.readyListeners)e()}sendSizingEmitter(e,t){for(let n of this.sizingListeners)n({width:e,height:t})}sendSuccess(e){this.config.totalAmount&&(e.data.amount_cents=this.config.totalAmount),this.iframe?.contentWindow?.postMessage({type:`payment-form:success`,paymentIntent:e},this.origin);let{id:t,status:n,amount_cents:r,response_code:i,authorization_number:a,reference_number:o}=e.data,s={id:t,status:n,amount_cents:r,response_code:i,authorization_number:a,reference_number:o};for(let e of this.successListeners)e(s)}destroy(){this.messageHandler&&=(window.removeEventListener(`message`,this.messageHandler),null),this.successListeners.clear(),this.failureListeners.clear(),this.readyListeners.clear(),this.sizingListeners.clear(),this.iframe&&=(this.iframe.remove(),null)}};exports.BizzPaymentForm=ln;