@stacksjs/rpx 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +0,0 @@
1
- import{H as ce}from"./chunk-en36kajt.js";import{I as cr,J as le,K as zt,O as Or}from"./chunk-2y0c08hn.js";import{P as ca,Q as aa}from"./chunk-e794mmrn.js";var li=aa((Bn,Ar)=>{var $t=process||{},ci=$t.argv||[],Zt=$t.env||{},na=!(!!Zt.NO_COLOR||ci.includes("--no-color"))&&(!!Zt.FORCE_COLOR||ci.includes("--color")||$t.platform==="win32"||($t.stdout||{}).isTTY&&Zt.TERM!=="dumb"||!!Zt.CI),sa=(N,_,t=N)=>(e)=>{let a=""+e,d=a.indexOf(_,N.length);return~d?N+oa(a,_,t,d)+_:N+a+_},oa=(N,_,t,e)=>{let a="",d=0;do a+=N.substring(d,e)+t,d=e+_.length,e=N.indexOf(_,d);while(~e);return a+N.substring(d)},ui=(N=na)=>{let _=N?sa:()=>String;return{isColorSupported:N,reset:_("\x1B[0m","\x1B[0m"),bold:_("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:_("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:_("\x1B[3m","\x1B[23m"),underline:_("\x1B[4m","\x1B[24m"),inverse:_("\x1B[7m","\x1B[27m"),hidden:_("\x1B[8m","\x1B[28m"),strikethrough:_("\x1B[9m","\x1B[29m"),black:_("\x1B[30m","\x1B[39m"),red:_("\x1B[31m","\x1B[39m"),green:_("\x1B[32m","\x1B[39m"),yellow:_("\x1B[33m","\x1B[39m"),blue:_("\x1B[34m","\x1B[39m"),magenta:_("\x1B[35m","\x1B[39m"),cyan:_("\x1B[36m","\x1B[39m"),white:_("\x1B[37m","\x1B[39m"),gray:_("\x1B[90m","\x1B[39m"),bgBlack:_("\x1B[40m","\x1B[49m"),bgRed:_("\x1B[41m","\x1B[49m"),bgGreen:_("\x1B[42m","\x1B[49m"),bgYellow:_("\x1B[43m","\x1B[49m"),bgBlue:_("\x1B[44m","\x1B[49m"),bgMagenta:_("\x1B[45m","\x1B[49m"),bgCyan:_("\x1B[46m","\x1B[49m"),bgWhite:_("\x1B[47m","\x1B[49m"),blackBright:_("\x1B[90m","\x1B[39m"),redBright:_("\x1B[91m","\x1B[39m"),greenBright:_("\x1B[92m","\x1B[39m"),yellowBright:_("\x1B[93m","\x1B[39m"),blueBright:_("\x1B[94m","\x1B[39m"),magentaBright:_("\x1B[95m","\x1B[39m"),cyanBright:_("\x1B[96m","\x1B[39m"),whiteBright:_("\x1B[97m","\x1B[39m"),bgBlackBright:_("\x1B[100m","\x1B[49m"),bgRedBright:_("\x1B[101m","\x1B[49m"),bgGreenBright:_("\x1B[102m","\x1B[49m"),bgYellowBright:_("\x1B[103m","\x1B[49m"),bgBlueBright:_("\x1B[104m","\x1B[49m"),bgMagentaBright:_("\x1B[105m","\x1B[49m"),bgCyanBright:_("\x1B[106m","\x1B[49m"),bgWhiteBright:_("\x1B[107m","\x1B[49m")}};Ar.exports=ui();Ar.exports.createColors=ui});var Nr="0.9.0";import{homedir as rr}from"node:os";import{join as ir}from"node:path";import{resolve as Li}from"path";import Di from"process";function tr(N,_){if(Array.isArray(_)&&!Array.isArray(N))return _;if(Array.isArray(_)&&Array.isArray(N))return _.map((e,a)=>{let d=N[a];if(Nt(e)&&Nt(d))return tr(d,e);return e});if(!Nt(_)||!Nt(N))return _;let t={...N};for(let e in _)if(Object.prototype.hasOwnProperty.call(_,e)){let a=_[e],d=t[e];if(a===null||a===void 0)t[e]=a;else if(Nt(a)&&Nt(d))t[e]=tr(d,a);else t[e]=a}return t}function Nt(N){return Boolean(N&&typeof N==="object"&&!Array.isArray(N))}async function wr({name:N,cwd:_,defaultConfig:t}){let e=Li(_||Di.cwd(),`${N}.config`);try{let a=await import(e),d=a.default||a;return tr(t,d)}catch(a){return t}}var Ui={from:"localhost:5173",to:"stacks.localhost",cleanUrls:!1,https:{basePath:"",caCertPath:ir(rr(),".stacks","ssl","stacks.localhost.ca.crt"),certPath:ir(rr(),".stacks","ssl","stacks.localhost.crt"),keyPath:ir(rr(),".stacks","ssl","stacks.localhost.crt.key")},cleanup:{certs:!1,hosts:!1},vitePluginUsage:!1,verbose:!0},Ut=await wr({name:"reverse-proxy",defaultConfig:Ui});import*as kr from"node:fs/promises";function $(N,_,t){if(t)console.debug(`[rpx:${N}] ${_}`)}function Ta(N){if(Pt(N))return N.proxies.map((_)=>{let t=_.to||"stacks.localhost";return t.startsWith("http")?new URL(t).hostname:t});if(Qt(N)){let _=N.to||"stacks.localhost";return[_.startsWith("http")?new URL(_).hostname:_]}return["stacks.localhost"]}function Rr(N){return typeof N==="object"&&N!==null&&"certificate"in N&&"privateKey"in N&&typeof N.certificate==="string"&&typeof N.privateKey==="string"}function Ht(N){if(!N)return"stacks.localhost";if(Pt(N)&&N.proxies.length>0)return N.proxies[0].to||"stacks.localhost";if(Qt(N))return N.to||"stacks.localhost";return"stacks.localhost"}function Vt(N){return"proxies"in N&&Array.isArray(N.proxies)}function Pt(N){return"proxies"in N&&Array.isArray(N.proxies)}function Qt(N){return"to"in N&&typeof N.to==="string"}async function _r(N,_){try{await kr.unlink(N),$("certificates",`Successfully deleted: ${N}`,_)}catch(t){if(t.code!=="ENOENT")$("certificates",`Warning: Could not delete ${N}: ${t}`,_)}}import{exec as Vi}from"node:child_process";import St from"node:fs";import Lr from"node:os";import ar from"node:path";import xt from"node:process";import{promisify as Pi}from"node:util";var xi=Pi(Vi),mt=xt.platform==="win32"?ar.join(xt.env.windir||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts";async function Dr(N){if(xt.platform==="win32")throw new Error("Administrator privileges required on Windows");try{await xi(`sudo ${N}`)}catch(_){throw new Error(`Failed to execute sudo command: ${_.message}`)}}async function Ur(N,_){$("hosts",`Adding hosts: ${N.join(", ")}`,_),$("hosts",`Using hosts file at: ${mt}`,_);try{let t=await St.promises.readFile(mt,"utf-8"),e=N.filter((g)=>{let v=`127.0.0.1 ${g}`,u=`::1 ${g}`;return!t.includes(v)&&!t.includes(u)});if(e.length===0){$("hosts","All hosts already exist in hosts file",_),ce.info("All hosts are already in the hosts file");return}let a=e.map((g)=>`
2
- # Added by rpx
3
- 127.0.0.1 ${g}
4
- ::1 ${g}`).join(`
5
- `),d=ar.join(Lr.tmpdir(),"hosts.tmp");await St.promises.writeFile(d,t+a,"utf8");try{await Dr(`cp "${d}" "${mt}"`),ce.success(`Added new hosts: ${e.join(", ")}`)}catch(g){if(ce.error("Failed to modify hosts file automatically"),ce.warn("Please add these entries to your hosts file manually:"),a.split(`
6
- `).forEach((v)=>ce.warn(v)),xt.platform==="win32")ce.warn(`
7
- On Windows:`),ce.warn("1. Run notepad as administrator"),ce.warn("2. Open C:\\Windows\\System32\\drivers\\etc\\hosts");else ce.warn(`
8
- On Unix systems:`),ce.warn(`sudo nano ${mt}`);throw new Error("Failed to modify hosts file: manual intervention required")}finally{St.unlinkSync(d)}}catch(t){let e=t;throw ce.error(`Failed to manage hosts file: ${e.message}`),e}}async function Vr(N,_){$("hosts",`Removing hosts: ${N.join(", ")}`,_);try{let e=(await St.promises.readFile(mt,"utf-8")).split(`
9
- `),a=e.filter((v,u)=>{if(v.trim()==="# Added by rpx")return e.splice(u+1,2),!1;return!0});while(a[a.length-1]?.trim()==="")a.pop();let d=`${a.join(`
10
- `)}
11
- `,g=ar.join(Lr.tmpdir(),"hosts.tmp");await St.promises.writeFile(g,d,"utf8");try{await Dr(`cp "${g}" "${mt}"`),ce.success("Hosts removed successfully")}catch(v){if(ce.error("Failed to modify hosts file automatically"),ce.warn("Please remove these entries from your hosts file manually:"),N.forEach((u)=>{ce.warn("# Added by rpx"),ce.warn(`127.0.0.1 ${u}`),ce.warn(`::1 ${u}`)}),xt.platform==="win32")ce.warn(`
12
- On Windows:`),ce.warn("1. Run notepad as administrator"),ce.warn("2. Open C:\\Windows\\System32\\drivers\\etc\\hosts");else ce.warn(`
13
- On Unix systems:`),ce.warn(`sudo nano ${mt}`);throw new Error("Failed to modify hosts file: manual intervention required")}finally{St.unlinkSync(g)}}catch(t){let e=t;throw ce.error(`Failed to remove hosts: ${e.message}`),e}}async function Pr(N,_){$("hosts",`Checking hosts: ${N}`,_);let t=await St.promises.readFile(mt,"utf-8");return N.map((e)=>{let a=`127.0.0.1 ${e}`,d=`::1 ${e}`;return t.includes(a)||t.includes(d)})}import Ft from"node:fs/promises";import{homedir as ia}from"node:os";import{join as At}from"node:path";import nr from"node:os";import sr from"node:path";import{resolve as Yi}from"path";import Xi from"process";import{exec as Zi}from"node:child_process";import xr from"node:fs";import $i from"node:path";import Ji from"node:process";import{promisify as ea}from"node:util";import dt from"node:fs";import Kr from"node:os";import kt from"node:path";var pe=le((N,_)=>{_.exports={options:{usePureJavaScript:!1}}}),Ki=le((N,_)=>{var t={};_.exports=t;var e={};t.encode=function(d,g,v){if(typeof g!=="string")throw new TypeError('"alphabet" must be a string.');if(v!==void 0&&typeof v!=="number")throw new TypeError('"maxline" must be a number.');var u="";if(!(d instanceof Uint8Array))u=a(d,g);else{var r=0,m=g.length,f=g.charAt(0),I=[0];for(r=0;r<d.length;++r){for(var U=0,S=d[r];U<I.length;++U)S+=I[U]<<8,I[U]=S%m,S=S/m|0;while(S>0)I.push(S%m),S=S/m|0}for(r=0;d[r]===0&&r<d.length-1;++r)u+=f;for(r=I.length-1;r>=0;--r)u+=g[I[r]]}if(v){var c=new RegExp(".{1,"+v+"}","g");u=u.match(c).join(`\r
14
- `)}return u},t.decode=function(d,g){if(typeof d!=="string")throw new TypeError('"input" must be a string.');if(typeof g!=="string")throw new TypeError('"alphabet" must be a string.');var v=e[g];if(!v){v=e[g]=[];for(var u=0;u<g.length;++u)v[g.charCodeAt(u)]=u}d=d.replace(/\s/g,"");var r=g.length,m=g.charAt(0),f=[0];for(var u=0;u<d.length;u++){var I=v[d.charCodeAt(u)];if(I===void 0)return;for(var U=0,S=I;U<f.length;++U)S+=f[U]*r,f[U]=S&255,S>>=8;while(S>0)f.push(S&255),S>>=8}for(var c=0;d[c]===m&&c<d.length-1;++c)f.push(0);if(typeof Buffer!=="undefined")return Buffer.from(f.reverse());return new Uint8Array(f.reverse())};function a(d,g){var v=0,u=g.length,r=g.charAt(0),m=[0];for(v=0;v<d.length();++v){for(var f=0,I=d.at(v);f<m.length;++f)I+=m[f]<<8,m[f]=I%u,I=I/u|0;while(I>0)m.push(I%u),I=I/u|0}var U="";for(v=0;d.at(v)===0&&v<d.length()-1;++v)U+=r;for(v=m.length-1;v>=0;--v)U+=g[m[v]];return U}}),Ce=le((N,_)=>{var t=pe(),e=Ki(),a=_.exports=t.util=t.util||{};(function(){if(typeof process!=="undefined"&&process.nextTick){if(a.nextTick=process.nextTick,typeof setImmediate==="function")a.setImmediate=setImmediate;else a.setImmediate=a.nextTick;return}if(typeof setImmediate==="function"){a.setImmediate=function(){return setImmediate.apply(void 0,arguments)},a.nextTick=function(i){return setImmediate(i)};return}if(a.setImmediate=function(i){setTimeout(i,0)},typeof window!=="undefined"&&typeof window.postMessage==="function"){let i=function(B){if(B.source===window&&B.data===p){B.stopPropagation();var V=y.slice();y.length=0,V.forEach(function(O){O()})}};var s=i,p="forge.setImmediate",y=[];a.setImmediate=function(B){if(y.push(B),y.length===1)window.postMessage(p,"*")},window.addEventListener("message",i,!0)}if(typeof MutationObserver!=="undefined"){var b=Date.now(),L=!0,h=document.createElement("div"),y=[];new MutationObserver(function(){var B=y.slice();y.length=0,B.forEach(function(V){V()})}).observe(h,{attributes:!0});var n=a.setImmediate;a.setImmediate=function(B){if(Date.now()-b>15)b=Date.now(),n(B);else if(y.push(B),y.length===1)h.setAttribute("a",L=!L)}}a.nextTick=a.setImmediate})(),a.isNodejs=typeof process!=="undefined"&&process.versions&&process.versions.node,a.globalScope=function(){if(a.isNodejs)return global;return typeof self==="undefined"?window:self}(),a.isArray=Array.isArray||function(s){return Object.prototype.toString.call(s)==="[object Array]"},a.isArrayBuffer=function(s){return typeof ArrayBuffer!=="undefined"&&s instanceof ArrayBuffer},a.isArrayBufferView=function(s){return s&&a.isArrayBuffer(s.buffer)&&s.byteLength!==void 0};function d(s){if(!(s===8||s===16||s===24||s===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+s)}a.ByteBuffer=g;function g(s){if(this.data="",this.read=0,typeof s==="string")this.data=s;else if(a.isArrayBuffer(s)||a.isArrayBufferView(s))if(typeof Buffer!=="undefined"&&s instanceof Buffer)this.data=s.toString("binary");else{var p=new Uint8Array(s);try{this.data=String.fromCharCode.apply(null,p)}catch(b){for(var y=0;y<p.length;++y)this.putByte(p[y])}}else if(s instanceof g||typeof s==="object"&&typeof s.data==="string"&&typeof s.read==="number")this.data=s.data,this.read=s.read;this._constructedStringLength=0}a.ByteStringBuffer=g;var v=4096;a.ByteStringBuffer.prototype._optimizeConstructedString=function(s){if(this._constructedStringLength+=s,this._constructedStringLength>v)this.data.substr(0,1),this._constructedStringLength=0},a.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},a.ByteStringBuffer.prototype.putByte=function(s){return this.putBytes(String.fromCharCode(s))},a.ByteStringBuffer.prototype.fillWithByte=function(s,p){s=String.fromCharCode(s);var y=this.data;while(p>0){if(p&1)y+=s;if(p>>>=1,p>0)s+=s}return this.data=y,this._optimizeConstructedString(p),this},a.ByteStringBuffer.prototype.putBytes=function(s){return this.data+=s,this._optimizeConstructedString(s.length),this},a.ByteStringBuffer.prototype.putString=function(s){return this.putBytes(a.encodeUtf8(s))},a.ByteStringBuffer.prototype.putInt16=function(s){return this.putBytes(String.fromCharCode(s>>8&255)+String.fromCharCode(s&255))},a.ByteStringBuffer.prototype.putInt24=function(s){return this.putBytes(String.fromCharCode(s>>16&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s&255))},a.ByteStringBuffer.prototype.putInt32=function(s){return this.putBytes(String.fromCharCode(s>>24&255)+String.fromCharCode(s>>16&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s&255))},a.ByteStringBuffer.prototype.putInt16Le=function(s){return this.putBytes(String.fromCharCode(s&255)+String.fromCharCode(s>>8&255))},a.ByteStringBuffer.prototype.putInt24Le=function(s){return this.putBytes(String.fromCharCode(s&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s>>16&255))},a.ByteStringBuffer.prototype.putInt32Le=function(s){return this.putBytes(String.fromCharCode(s&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s>>16&255)+String.fromCharCode(s>>24&255))},a.ByteStringBuffer.prototype.putInt=function(s,p){d(p);var y="";do p-=8,y+=String.fromCharCode(s>>p&255);while(p>0);return this.putBytes(y)},a.ByteStringBuffer.prototype.putSignedInt=function(s,p){if(s<0)s+=2<<p-1;return this.putInt(s,p)},a.ByteStringBuffer.prototype.putBuffer=function(s){return this.putBytes(s.getBytes())},a.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},a.ByteStringBuffer.prototype.getInt16=function(){var s=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,s},a.ByteStringBuffer.prototype.getInt24=function(){var s=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,s},a.ByteStringBuffer.prototype.getInt32=function(){var s=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,s},a.ByteStringBuffer.prototype.getInt16Le=function(){var s=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,s},a.ByteStringBuffer.prototype.getInt24Le=function(){var s=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,s},a.ByteStringBuffer.prototype.getInt32Le=function(){var s=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,s},a.ByteStringBuffer.prototype.getInt=function(s){d(s);var p=0;do p=(p<<8)+this.data.charCodeAt(this.read++),s-=8;while(s>0);return p},a.ByteStringBuffer.prototype.getSignedInt=function(s){var p=this.getInt(s),y=2<<s-2;if(p>=y)p-=y<<1;return p},a.ByteStringBuffer.prototype.getBytes=function(s){var p;if(s)s=Math.min(this.length(),s),p=this.data.slice(this.read,this.read+s),this.read+=s;else if(s===0)p="";else p=this.read===0?this.data:this.data.slice(this.read),this.clear();return p},a.ByteStringBuffer.prototype.bytes=function(s){return typeof s==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+s)},a.ByteStringBuffer.prototype.at=function(s){return this.data.charCodeAt(this.read+s)},a.ByteStringBuffer.prototype.setAt=function(s,p){return this.data=this.data.substr(0,this.read+s)+String.fromCharCode(p)+this.data.substr(this.read+s+1),this},a.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},a.ByteStringBuffer.prototype.copy=function(){var s=a.createBuffer(this.data);return s.read=this.read,s},a.ByteStringBuffer.prototype.compact=function(){if(this.read>0)this.data=this.data.slice(this.read),this.read=0;return this},a.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},a.ByteStringBuffer.prototype.truncate=function(s){var p=Math.max(0,this.length()-s);return this.data=this.data.substr(this.read,p),this.read=0,this},a.ByteStringBuffer.prototype.toHex=function(){var s="";for(var p=this.read;p<this.data.length;++p){var y=this.data.charCodeAt(p);if(y<16)s+="0";s+=y.toString(16)}return s},a.ByteStringBuffer.prototype.toString=function(){return a.decodeUtf8(this.bytes())};function u(s,p){p=p||{},this.read=p.readOffset||0,this.growSize=p.growSize||1024;var y=a.isArrayBuffer(s),b=a.isArrayBufferView(s);if(y||b){if(y)this.data=new DataView(s);else this.data=new DataView(s.buffer,s.byteOffset,s.byteLength);this.write="writeOffset"in p?p.writeOffset:this.data.byteLength;return}if(this.data=new DataView(new ArrayBuffer(0)),this.write=0,s!==null&&s!==void 0)this.putBytes(s);if("writeOffset"in p)this.write=p.writeOffset}a.DataBuffer=u,a.DataBuffer.prototype.length=function(){return this.write-this.read},a.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},a.DataBuffer.prototype.accommodate=function(s,p){if(this.length()>=s)return this;p=Math.max(p||this.growSize,s);var y=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),b=new Uint8Array(this.length()+p);return b.set(y),this.data=new DataView(b.buffer),this},a.DataBuffer.prototype.putByte=function(s){return this.accommodate(1),this.data.setUint8(this.write++,s),this},a.DataBuffer.prototype.fillWithByte=function(s,p){this.accommodate(p);for(var y=0;y<p;++y)this.data.setUint8(s);return this},a.DataBuffer.prototype.putBytes=function(s,p){if(a.isArrayBufferView(s)){var y=new Uint8Array(s.buffer,s.byteOffset,s.byteLength),b=y.byteLength-y.byteOffset;this.accommodate(b);var L=new Uint8Array(this.data.buffer,this.write);return L.set(y),this.write+=b,this}if(a.isArrayBuffer(s)){var y=new Uint8Array(s);this.accommodate(y.byteLength);var L=new Uint8Array(this.data.buffer);return L.set(y,this.write),this.write+=y.byteLength,this}if(s instanceof a.DataBuffer||typeof s==="object"&&typeof s.read==="number"&&typeof s.write==="number"&&a.isArrayBufferView(s.data)){var y=new Uint8Array(s.data.byteLength,s.read,s.length());this.accommodate(y.byteLength);var L=new Uint8Array(s.data.byteLength,this.write);return L.set(y),this.write+=y.byteLength,this}if(s instanceof a.ByteStringBuffer)s=s.data,p="binary";if(p=p||"binary",typeof s==="string"){var h;if(p==="hex")return this.accommodate(Math.ceil(s.length/2)),h=new Uint8Array(this.data.buffer,this.write),this.write+=a.binary.hex.decode(s,h,this.write),this;if(p==="base64")return this.accommodate(Math.ceil(s.length/4)*3),h=new Uint8Array(this.data.buffer,this.write),this.write+=a.binary.base64.decode(s,h,this.write),this;if(p==="utf8")s=a.encodeUtf8(s),p="binary";if(p==="binary"||p==="raw")return this.accommodate(s.length),h=new Uint8Array(this.data.buffer,this.write),this.write+=a.binary.raw.decode(h),this;if(p==="utf16")return this.accommodate(s.length*2),h=new Uint16Array(this.data.buffer,this.write),this.write+=a.text.utf16.encode(h),this;throw new Error("Invalid encoding: "+p)}throw Error("Invalid parameter: "+s)},a.DataBuffer.prototype.putBuffer=function(s){return this.putBytes(s),s.clear(),this},a.DataBuffer.prototype.putString=function(s){return this.putBytes(s,"utf16")},a.DataBuffer.prototype.putInt16=function(s){return this.accommodate(2),this.data.setInt16(this.write,s),this.write+=2,this},a.DataBuffer.prototype.putInt24=function(s){return this.accommodate(3),this.data.setInt16(this.write,s>>8&65535),this.data.setInt8(this.write,s>>16&255),this.write+=3,this},a.DataBuffer.prototype.putInt32=function(s){return this.accommodate(4),this.data.setInt32(this.write,s),this.write+=4,this},a.DataBuffer.prototype.putInt16Le=function(s){return this.accommodate(2),this.data.setInt16(this.write,s,!0),this.write+=2,this},a.DataBuffer.prototype.putInt24Le=function(s){return this.accommodate(3),this.data.setInt8(this.write,s>>16&255),this.data.setInt16(this.write,s>>8&65535,!0),this.write+=3,this},a.DataBuffer.prototype.putInt32Le=function(s){return this.accommodate(4),this.data.setInt32(this.write,s,!0),this.write+=4,this},a.DataBuffer.prototype.putInt=function(s,p){d(p),this.accommodate(p/8);do p-=8,this.data.setInt8(this.write++,s>>p&255);while(p>0);return this},a.DataBuffer.prototype.putSignedInt=function(s,p){if(d(p),this.accommodate(p/8),s<0)s+=2<<p-1;return this.putInt(s,p)},a.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},a.DataBuffer.prototype.getInt16=function(){var s=this.data.getInt16(this.read);return this.read+=2,s},a.DataBuffer.prototype.getInt24=function(){var s=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,s},a.DataBuffer.prototype.getInt32=function(){var s=this.data.getInt32(this.read);return this.read+=4,s},a.DataBuffer.prototype.getInt16Le=function(){var s=this.data.getInt16(this.read,!0);return this.read+=2,s},a.DataBuffer.prototype.getInt24Le=function(){var s=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,s},a.DataBuffer.prototype.getInt32Le=function(){var s=this.data.getInt32(this.read,!0);return this.read+=4,s},a.DataBuffer.prototype.getInt=function(s){d(s);var p=0;do p=(p<<8)+this.data.getInt8(this.read++),s-=8;while(s>0);return p},a.DataBuffer.prototype.getSignedInt=function(s){var p=this.getInt(s),y=2<<s-2;if(p>=y)p-=y<<1;return p},a.DataBuffer.prototype.getBytes=function(s){var p;if(s)s=Math.min(this.length(),s),p=this.data.slice(this.read,this.read+s),this.read+=s;else if(s===0)p="";else p=this.read===0?this.data:this.data.slice(this.read),this.clear();return p},a.DataBuffer.prototype.bytes=function(s){return typeof s==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+s)},a.DataBuffer.prototype.at=function(s){return this.data.getUint8(this.read+s)},a.DataBuffer.prototype.setAt=function(s,p){return this.data.setUint8(s,p),this},a.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},a.DataBuffer.prototype.copy=function(){return new a.DataBuffer(this)},a.DataBuffer.prototype.compact=function(){if(this.read>0){var s=new Uint8Array(this.data.buffer,this.read),p=new Uint8Array(s.byteLength);p.set(s),this.data=new DataView(p),this.write-=this.read,this.read=0}return this},a.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},a.DataBuffer.prototype.truncate=function(s){return this.write=Math.max(0,this.length()-s),this.read=Math.min(this.read,this.write),this},a.DataBuffer.prototype.toHex=function(){var s="";for(var p=this.read;p<this.data.byteLength;++p){var y=this.data.getUint8(p);if(y<16)s+="0";s+=y.toString(16)}return s},a.DataBuffer.prototype.toString=function(s){var p=new Uint8Array(this.data,this.read,this.length());if(s=s||"utf8",s==="binary"||s==="raw")return a.binary.raw.encode(p);if(s==="hex")return a.binary.hex.encode(p);if(s==="base64")return a.binary.base64.encode(p);if(s==="utf8")return a.text.utf8.decode(p);if(s==="utf16")return a.text.utf16.decode(p);throw new Error("Invalid encoding: "+s)},a.createBuffer=function(s,p){if(p=p||"raw",s!==void 0&&p==="utf8")s=a.encodeUtf8(s);return new a.ByteBuffer(s)},a.fillString=function(s,p){var y="";while(p>0){if(p&1)y+=s;if(p>>>=1,p>0)s+=s}return y},a.xorBytes=function(s,p,y){var b="",L="",h="",n=0,i=0;for(;y>0;--y,++n){if(L=s.charCodeAt(n)^p.charCodeAt(n),i>=10)b+=h,h="",i=0;h+=String.fromCharCode(L),++i}return b+=h,b},a.hexToBytes=function(s){var p="",y=0;if(s.length&!0)y=1,p+=String.fromCharCode(parseInt(s[0],16));for(;y<s.length;y+=2)p+=String.fromCharCode(parseInt(s.substr(y,2),16));return p},a.bytesToHex=function(s){return a.createBuffer(s).toHex()},a.int32ToBytes=function(s){return String.fromCharCode(s>>24&255)+String.fromCharCode(s>>16&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s&255)};var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=[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],f="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";a.encode64=function(s,p){var y="",b="",L,h,n,i=0;while(i<s.length){if(L=s.charCodeAt(i++),h=s.charCodeAt(i++),n=s.charCodeAt(i++),y+=r.charAt(L>>2),y+=r.charAt((L&3)<<4|h>>4),isNaN(h))y+="==";else y+=r.charAt((h&15)<<2|n>>6),y+=isNaN(n)?"=":r.charAt(n&63);if(p&&y.length>p)b+=y.substr(0,p)+`\r
15
- `,y=y.substr(p)}return b+=y,b},a.decode64=function(s){s=s.replace(/[^A-Za-z0-9\+\/\=]/g,"");var p="",y,b,L,h,n=0;while(n<s.length)if(y=m[s.charCodeAt(n++)-43],b=m[s.charCodeAt(n++)-43],L=m[s.charCodeAt(n++)-43],h=m[s.charCodeAt(n++)-43],p+=String.fromCharCode(y<<2|b>>4),L!==64){if(p+=String.fromCharCode((b&15)<<4|L>>2),h!==64)p+=String.fromCharCode((L&3)<<6|h)}return p},a.encodeUtf8=function(s){return unescape(encodeURIComponent(s))},a.decodeUtf8=function(s){return decodeURIComponent(escape(s))},a.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:e.encode,decode:e.decode}},a.binary.raw.encode=function(s){return String.fromCharCode.apply(null,s)},a.binary.raw.decode=function(s,p,y){var b=p;if(!b)b=new Uint8Array(s.length);y=y||0;var L=y;for(var h=0;h<s.length;++h)b[L++]=s.charCodeAt(h);return p?L-y:b},a.binary.hex.encode=a.bytesToHex,a.binary.hex.decode=function(s,p,y){var b=p;if(!b)b=new Uint8Array(Math.ceil(s.length/2));y=y||0;var L=0,h=y;if(s.length&1)L=1,b[h++]=parseInt(s[0],16);for(;L<s.length;L+=2)b[h++]=parseInt(s.substr(L,2),16);return p?h-y:b},a.binary.base64.encode=function(s,p){var y="",b="",L,h,n,i=0;while(i<s.byteLength){if(L=s[i++],h=s[i++],n=s[i++],y+=r.charAt(L>>2),y+=r.charAt((L&3)<<4|h>>4),isNaN(h))y+="==";else y+=r.charAt((h&15)<<2|n>>6),y+=isNaN(n)?"=":r.charAt(n&63);if(p&&y.length>p)b+=y.substr(0,p)+`\r
16
- `,y=y.substr(p)}return b+=y,b},a.binary.base64.decode=function(s,p,y){var b=p;if(!b)b=new Uint8Array(Math.ceil(s.length/4)*3);s=s.replace(/[^A-Za-z0-9\+\/\=]/g,""),y=y||0;var L,h,n,i,B=0,V=y;while(B<s.length)if(L=m[s.charCodeAt(B++)-43],h=m[s.charCodeAt(B++)-43],n=m[s.charCodeAt(B++)-43],i=m[s.charCodeAt(B++)-43],b[V++]=L<<2|h>>4,n!==64){if(b[V++]=(h&15)<<4|n>>2,i!==64)b[V++]=(n&3)<<6|i}return p?V-y:b.subarray(0,V)},a.binary.base58.encode=function(s,p){return a.binary.baseN.encode(s,f,p)},a.binary.base58.decode=function(s,p){return a.binary.baseN.decode(s,f,p)},a.text={utf8:{},utf16:{}},a.text.utf8.encode=function(s,p,y){s=a.encodeUtf8(s);var b=p;if(!b)b=new Uint8Array(s.length);y=y||0;var L=y;for(var h=0;h<s.length;++h)b[L++]=s.charCodeAt(h);return p?L-y:b},a.text.utf8.decode=function(s){return a.decodeUtf8(String.fromCharCode.apply(null,s))},a.text.utf16.encode=function(s,p,y){var b=p;if(!b)b=new Uint8Array(s.length*2);var L=new Uint16Array(b.buffer);y=y||0;var h=y,n=y;for(var i=0;i<s.length;++i)L[n++]=s.charCodeAt(i),h+=2;return p?h-y:b},a.text.utf16.decode=function(s){return String.fromCharCode.apply(null,new Uint16Array(s.buffer))},a.deflate=function(s,p,y){if(p=a.decode64(s.deflate(a.encode64(p)).rval),y){var b=2,L=p.charCodeAt(1);if(L&32)b=6;p=p.substring(b,p.length-4)}return p},a.inflate=function(s,p,y){var b=s.inflate(a.encode64(p)).rval;return b===null?null:a.decode64(b)};var I=function(s,p,y){if(!s)throw new Error("WebStorage not available.");var b;if(y===null)b=s.removeItem(p);else y=a.encode64(JSON.stringify(y)),b=s.setItem(p,y);if(typeof b!=="undefined"&&b.rval!==!0){var L=new Error(b.error.message);throw L.id=b.error.id,L.name=b.error.name,L}},U=function(s,p){if(!s)throw new Error("WebStorage not available.");var y=s.getItem(p);if(s.init)if(y.rval===null){if(y.error){var b=new Error(y.error.message);throw b.id=y.error.id,b.name=y.error.name,b}y=null}else y=y.rval;if(y!==null)y=JSON.parse(a.decode64(y));return y},S=function(s,p,y,b){var L=U(s,p);if(L===null)L={};L[y]=b,I(s,p,L)},c=function(s,p,y){var b=U(s,p);if(b!==null)b=y in b?b[y]:null;return b},C=function(s,p,y){var b=U(s,p);if(b!==null&&y in b){delete b[y];var L=!0;for(var h in b){L=!1;break}if(L)b=null;I(s,p,b)}},T=function(s,p){I(s,p,null)},E=function(s,p,y){var b=null;if(typeof y==="undefined")y=["web","flash"];var L,h=!1,n=null;for(var i in y){L=y[i];try{if(L==="flash"||L==="both"){if(p[0]===null)throw new Error("Flash local storage not available.");b=s.apply(this,p),h=L==="flash"}if(L==="web"||L==="both")p[0]=localStorage,b=s.apply(this,p),h=!0}catch(B){n=B}if(h)break}if(!h)throw n;return b};a.setItem=function(s,p,y,b,L){E(S,arguments,L)},a.getItem=function(s,p,y,b){return E(c,arguments,b)},a.removeItem=function(s,p,y,b){E(C,arguments,b)},a.clearItems=function(s,p,y){E(T,arguments,y)},a.isEmpty=function(s){for(var p in s)if(s.hasOwnProperty(p))return!1;return!0},a.format=function(s){var p=/%./g,y,b,L=0,h=[],n=0;while(y=p.exec(s)){if(b=s.substring(n,p.lastIndex-2),b.length>0)h.push(b);n=p.lastIndex;var i=y[0][1];switch(i){case"s":case"o":if(L<arguments.length)h.push(arguments[L+++1]);else h.push("<?>");break;case"%":h.push("%");break;default:h.push("<%"+i+"?>")}}return h.push(s.substring(n)),h.join("")},a.formatNumber=function(s,p,y,b){var L=s,h=isNaN(p=Math.abs(p))?2:p,n=y===void 0?",":y,i=b===void 0?".":b,B=L<0?"-":"",V=parseInt(L=Math.abs(+L||0).toFixed(h),10)+"",O=V.length>3?V.length%3:0;return B+(O?V.substr(0,O)+i:"")+V.substr(O).replace(/(\d{3})(?=\d)/g,"$1"+i)+(h?n+Math.abs(L-V).toFixed(h).slice(2):"")},a.formatSize=function(s){if(s>=1073741824)s=a.formatNumber(s/1073741824,2,".","")+" GiB";else if(s>=1048576)s=a.formatNumber(s/1048576,2,".","")+" MiB";else if(s>=1024)s=a.formatNumber(s/1024,0)+" KiB";else s=a.formatNumber(s,0)+" bytes";return s},a.bytesFromIP=function(s){if(s.indexOf(".")!==-1)return a.bytesFromIPv4(s);if(s.indexOf(":")!==-1)return a.bytesFromIPv6(s);return null},a.bytesFromIPv4=function(s){if(s=s.split("."),s.length!==4)return null;var p=a.createBuffer();for(var y=0;y<s.length;++y){var b=parseInt(s[y],10);if(isNaN(b))return null;p.putByte(b)}return p.getBytes()},a.bytesFromIPv6=function(s){var p=0;s=s.split(":").filter(function(n){if(n.length===0)++p;return!0});var y=(8-s.length+p)*2,b=a.createBuffer();for(var L=0;L<8;++L){if(!s[L]||s[L].length===0){b.fillWithByte(0,y),y=0;continue}var h=a.hexToBytes(s[L]);if(h.length<2)b.putByte(0);b.putBytes(h)}return b.getBytes()},a.bytesToIP=function(s){if(s.length===4)return a.bytesToIPv4(s);if(s.length===16)return a.bytesToIPv6(s);return null},a.bytesToIPv4=function(s){if(s.length!==4)return null;var p=[];for(var y=0;y<s.length;++y)p.push(s.charCodeAt(y));return p.join(".")},a.bytesToIPv6=function(s){if(s.length!==16)return null;var p=[],y=[],b=0;for(var L=0;L<s.length;L+=2){var h=a.bytesToHex(s[L]+s[L+1]);while(h[0]==="0"&&h!=="0")h=h.substr(1);if(h==="0"){var n=y[y.length-1],i=p.length;if(!n||i!==n.end+1)y.push({start:i,end:i});else if(n.end=i,n.end-n.start>y[b].end-y[b].start)b=y.length-1}p.push(h)}if(y.length>0){var B=y[b];if(B.end-B.start>0){if(p.splice(B.start,B.end-B.start+1,""),B.start===0)p.unshift("");if(B.end===7)p.push("")}}return p.join(":")},a.estimateCores=function(s,p){if(typeof s==="function")p=s,s={};if(s=s||{},"cores"in a&&!s.update)return p(null,a.cores);if(typeof navigator!=="undefined"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return a.cores=navigator.hardwareConcurrency,p(null,a.cores);if(typeof Worker==="undefined")return a.cores=1,p(null,a.cores);if(typeof Blob==="undefined")return a.cores=2,p(null,a.cores);var y=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(n){var i=Date.now(),B=i+4;while(Date.now()<B);self.postMessage({st:i,et:B})})}.toString(),")()"],{type:"application/javascript"}));b([],5,16);function b(n,i,B){if(i===0){var V=Math.floor(n.reduce(function(O,P){return O+P},0)/n.length);return a.cores=Math.max(1,V),URL.revokeObjectURL(y),p(null,a.cores)}L(B,function(O,P){n.push(h(B,P)),b(n,i-1,B)})}function L(n,i){var B=[],V=[];for(var O=0;O<n;++O){var P=new Worker(y);P.addEventListener("message",function(M){if(V.push(M.data),V.length===n){for(var G=0;G<n;++G)B[G].terminate();i(null,V)}}),B.push(P)}for(var O=0;O<n;++O)B[O].postMessage(O)}function h(n,i){var B=[];for(var V=0;V<n;++V){var O=i[V],P=B[V]=[];for(var M=0;M<n;++M){if(V===M)continue;var G=i[M];if(O.st>G.st&&O.st<G.et||G.st>O.st&&G.st<O.et)P.push(M)}}return B.reduce(function(q,H){return Math.max(q,H.length)},0)}}}),ur=le((N,_)=>{var t=pe();Ce(),_.exports=t.cipher=t.cipher||{},t.cipher.algorithms=t.cipher.algorithms||{},t.cipher.createCipher=function(a,d){var g=a;if(typeof g==="string"){if(g=t.cipher.getAlgorithm(g),g)g=g()}if(!g)throw new Error("Unsupported algorithm: "+a);return new t.cipher.BlockCipher({algorithm:g,key:d,decrypt:!1})},t.cipher.createDecipher=function(a,d){var g=a;if(typeof g==="string"){if(g=t.cipher.getAlgorithm(g),g)g=g()}if(!g)throw new Error("Unsupported algorithm: "+a);return new t.cipher.BlockCipher({algorithm:g,key:d,decrypt:!0})},t.cipher.registerAlgorithm=function(a,d){a=a.toUpperCase(),t.cipher.algorithms[a]=d},t.cipher.getAlgorithm=function(a){if(a=a.toUpperCase(),a in t.cipher.algorithms)return t.cipher.algorithms[a];return null};var e=t.cipher.BlockCipher=function(a){this.algorithm=a.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=a.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=a.decrypt,this.algorithm.initialize(a)};e.prototype.start=function(a){a=a||{};var d={};for(var g in a)d[g]=a[g];d.decrypt=this._decrypt,this._finish=!1,this._input=t.util.createBuffer(),this.output=a.output||t.util.createBuffer(),this.mode.start(d)},e.prototype.update=function(a){if(a)this._input.putBuffer(a);while(!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish);this._input.compact()},e.prototype.finish=function(a){if(a&&(this.mode.name==="ECB"||this.mode.name==="CBC"))this.mode.pad=function(g){return a(this.blockSize,g,!1)},this.mode.unpad=function(g){return a(this.blockSize,g,!0)};var d={};if(d.decrypt=this._decrypt,d.overflow=this._input.length()%this.blockSize,!this._decrypt&&this.mode.pad){if(!this.mode.pad(this._input,d))return!1}if(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad){if(!this.mode.unpad(this.output,d))return!1}if(this.mode.afterFinish){if(!this.mode.afterFinish(this.output,d))return!1}return!0}}),Mr=le((N,_)=>{var t=pe();Ce(),t.cipher=t.cipher||{};var e=_.exports=t.cipher.modes=t.cipher.modes||{};e.ecb=function(v){v=v||{},this.name="ECB",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.ecb.prototype.start=function(v){},e.ecb.prototype.encrypt=function(v,u,r){if(v.length()<this.blockSize&&!(r&&v.length()>0))return!0;for(var m=0;m<this._ints;++m)this._inBlock[m]=v.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var m=0;m<this._ints;++m)u.putInt32(this._outBlock[m])},e.ecb.prototype.decrypt=function(v,u,r){if(v.length()<this.blockSize&&!(r&&v.length()>0))return!0;for(var m=0;m<this._ints;++m)this._inBlock[m]=v.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var m=0;m<this._ints;++m)u.putInt32(this._outBlock[m])},e.ecb.prototype.pad=function(v,u){var r=v.length()===this.blockSize?this.blockSize:this.blockSize-v.length();return v.fillWithByte(r,r),!0},e.ecb.prototype.unpad=function(v,u){if(u.overflow>0)return!1;var r=v.length(),m=v.at(r-1);if(m>this.blockSize<<2)return!1;return v.truncate(m),!0},e.cbc=function(v){v=v||{},this.name="CBC",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.cbc.prototype.start=function(v){if(v.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if(!("iv"in v))throw new Error("Invalid IV parameter.");else this._iv=a(v.iv,this.blockSize),this._prev=this._iv.slice(0)},e.cbc.prototype.encrypt=function(v,u,r){if(v.length()<this.blockSize&&!(r&&v.length()>0))return!0;for(var m=0;m<this._ints;++m)this._inBlock[m]=this._prev[m]^v.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var m=0;m<this._ints;++m)u.putInt32(this._outBlock[m]);this._prev=this._outBlock},e.cbc.prototype.decrypt=function(v,u,r){if(v.length()<this.blockSize&&!(r&&v.length()>0))return!0;for(var m=0;m<this._ints;++m)this._inBlock[m]=v.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var m=0;m<this._ints;++m)u.putInt32(this._prev[m]^this._outBlock[m]);this._prev=this._inBlock.slice(0)},e.cbc.prototype.pad=function(v,u){var r=v.length()===this.blockSize?this.blockSize:this.blockSize-v.length();return v.fillWithByte(r,r),!0},e.cbc.prototype.unpad=function(v,u){if(u.overflow>0)return!1;var r=v.length(),m=v.at(r-1);if(m>this.blockSize<<2)return!1;return v.truncate(m),!0},e.cfb=function(v){v=v||{},this.name="CFB",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.cfb.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=a(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.cfb.prototype.encrypt=function(v,u,r){var m=v.length();if(m===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&m>=this.blockSize){for(var f=0;f<this._ints;++f)this._inBlock[f]=v.getInt32()^this._outBlock[f],u.putInt32(this._inBlock[f]);return}var I=(this.blockSize-m)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialBlock[f]=v.getInt32()^this._outBlock[f],this._partialOutput.putInt32(this._partialBlock[f]);if(I>0)v.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._partialBlock[f];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(m-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(v,u,r){var m=v.length();if(m===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&m>=this.blockSize){for(var f=0;f<this._ints;++f)this._inBlock[f]=v.getInt32(),u.putInt32(this._inBlock[f]^this._outBlock[f]);return}var I=(this.blockSize-m)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialBlock[f]=v.getInt32(),this._partialOutput.putInt32(this._partialBlock[f]^this._outBlock[f]);if(I>0)v.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._partialBlock[f];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(m-this._partialBytes)),this._partialBytes=0},e.ofb=function(v){v=v||{},this.name="OFB",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.ofb.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=a(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ofb.prototype.encrypt=function(v,u,r){var m=v.length();if(v.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&m>=this.blockSize){for(var f=0;f<this._ints;++f)u.putInt32(v.getInt32()^this._outBlock[f]),this._inBlock[f]=this._outBlock[f];return}var I=(this.blockSize-m)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(v.getInt32()^this._outBlock[f]);if(I>0)v.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._outBlock[f];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(m-this._partialBytes)),this._partialBytes=0},e.ofb.prototype.decrypt=e.ofb.prototype.encrypt,e.ctr=function(v){v=v||{},this.name="CTR",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.ctr.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=a(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ctr.prototype.encrypt=function(v,u,r){var m=v.length();if(m===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&m>=this.blockSize)for(var f=0;f<this._ints;++f)u.putInt32(v.getInt32()^this._outBlock[f]);else{var I=(this.blockSize-m)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(v.getInt32()^this._outBlock[f]);if(I>0)v.read-=this.blockSize;if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(m-this._partialBytes)),this._partialBytes=0}d(this._inBlock)},e.ctr.prototype.decrypt=e.ctr.prototype.encrypt,e.gcm=function(v){v=v||{},this.name="GCM",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0,this._R=3774873600},e.gcm.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");var u=t.util.createBuffer(v.iv);this._cipherLength=0;var r;if("additionalData"in v)r=t.util.createBuffer(v.additionalData);else r=t.util.createBuffer();if("tagLength"in v)this._tagLength=v.tagLength;else this._tagLength=128;if(this._tag=null,v.decrypt){if(this._tag=t.util.createBuffer(v.tag).getBytes(),this._tag.length!==this._tagLength/8)throw new Error("Authentication tag does not match tag length.")}this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var m=u.length();if(m===12)this._j0=[u.getInt32(),u.getInt32(),u.getInt32(),1];else{this._j0=[0,0,0,0];while(u.length()>0)this._j0=this.ghash(this._hashSubkey,this._j0,[u.getInt32(),u.getInt32(),u.getInt32(),u.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(g(m*8)))}this._inBlock=this._j0.slice(0),d(this._inBlock),this._partialBytes=0,r=t.util.createBuffer(r),this._aDataLength=g(r.length()*8);var f=r.length()%this.blockSize;if(f)r.fillWithByte(0,this.blockSize-f);this._s=[0,0,0,0];while(r.length()>0)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])},e.gcm.prototype.encrypt=function(v,u,r){var m=v.length();if(m===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&m>=this.blockSize){for(var f=0;f<this._ints;++f)u.putInt32(this._outBlock[f]^=v.getInt32());this._cipherLength+=this.blockSize}else{var I=(this.blockSize-m)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(v.getInt32()^this._outBlock[f]);if(I<=0||r){if(r){var U=m%this.blockSize;this._cipherLength+=U,this._partialOutput.truncate(this.blockSize-U)}else this._cipherLength+=this.blockSize;for(var f=0;f<this._ints;++f)this._outBlock[f]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return v.read-=this.blockSize,u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(m-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),d(this._inBlock)},e.gcm.prototype.decrypt=function(v,u,r){var m=v.length();if(m<this.blockSize&&!(r&&m>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),d(this._inBlock),this._hashBlock[0]=v.getInt32(),this._hashBlock[1]=v.getInt32(),this._hashBlock[2]=v.getInt32(),this._hashBlock[3]=v.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var f=0;f<this._ints;++f)u.putInt32(this._outBlock[f]^this._hashBlock[f]);if(m<this.blockSize)this._cipherLength+=m%this.blockSize;else this._cipherLength+=this.blockSize},e.gcm.prototype.afterFinish=function(v,u){var r=!0;if(u.decrypt&&u.overflow)v.truncate(this.blockSize-u.overflow);this.tag=t.util.createBuffer();var m=this._aDataLength.concat(g(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,m);var f=[];this.cipher.encrypt(this._j0,f);for(var I=0;I<this._ints;++I)this.tag.putInt32(this._s[I]^f[I]);if(this.tag.truncate(this.tag.length()%(this._tagLength/8)),u.decrypt&&this.tag.bytes()!==this._tag)r=!1;return r},e.gcm.prototype.multiply=function(v,u){var r=[0,0,0,0],m=u.slice(0);for(var f=0;f<128;++f){var I=v[f/32|0]&1<<31-f%32;if(I)r[0]^=m[0],r[1]^=m[1],r[2]^=m[2],r[3]^=m[3];this.pow(m,m)}return r},e.gcm.prototype.pow=function(v,u){var r=v[3]&1;for(var m=3;m>0;--m)u[m]=v[m]>>>1|(v[m-1]&1)<<31;if(u[0]=v[0]>>>1,r)u[0]^=this._R},e.gcm.prototype.tableMultiply=function(v){var u=[0,0,0,0];for(var r=0;r<32;++r){var m=r/8|0,f=v[m]>>>(7-r%8)*4&15,I=this._m[r][f];u[0]^=I[0],u[1]^=I[1],u[2]^=I[2],u[3]^=I[3]}return u},e.gcm.prototype.ghash=function(v,u,r){return u[0]^=r[0],u[1]^=r[1],u[2]^=r[2],u[3]^=r[3],this.tableMultiply(u)},e.gcm.prototype.generateHashTable=function(v,u){var r=8/u,m=4*r,f=16*r,I=new Array(f);for(var U=0;U<f;++U){var S=[0,0,0,0],c=U/m|0,C=(m-1-U%m)*u;S[c]=1<<u-1<<C,I[U]=this.generateSubHashTable(this.multiply(S,v),u)}return I},e.gcm.prototype.generateSubHashTable=function(v,u){var r=1<<u,m=r>>>1,f=new Array(r);f[m]=v.slice(0);var I=m>>>1;while(I>0)this.pow(f[2*I],f[I]=[]),I>>=1;I=2;while(I<m){for(var U=1;U<I;++U){var S=f[I],c=f[U];f[I+U]=[S[0]^c[0],S[1]^c[1],S[2]^c[2],S[3]^c[3]]}I*=2}f[0]=[0,0,0,0];for(I=m+1;I<r;++I){var C=f[I^m];f[I]=[v[0]^C[0],v[1]^C[1],v[2]^C[2],v[3]^C[3]]}return f};function a(v,u){if(typeof v==="string")v=t.util.createBuffer(v);if(t.util.isArray(v)&&v.length>4){var r=v;v=t.util.createBuffer();for(var m=0;m<r.length;++m)v.putByte(r[m])}if(v.length()<u)throw new Error("Invalid IV length; got "+v.length()+" bytes and expected "+u+" bytes.");if(!t.util.isArray(v)){var f=[],I=u/4;for(var m=0;m<I;++m)f.push(v.getInt32());v=f}return v}function d(v){v[v.length-1]=v[v.length-1]+1&4294967295}function g(v){return[v/4294967296|0,v&4294967295]}}),Tt=le((N,_)=>{var t=pe();ur(),Mr(),Ce(),_.exports=t.aes=t.aes||{},t.aes.startEncrypting=function(c,C,T,E){var s=S({key:c,output:T,decrypt:!1,mode:E});return s.start(C),s},t.aes.createEncryptionCipher=function(c,C){return S({key:c,output:null,decrypt:!1,mode:C})},t.aes.startDecrypting=function(c,C,T,E){var s=S({key:c,output:T,decrypt:!0,mode:E});return s.start(C),s},t.aes.createDecryptionCipher=function(c,C){return S({key:c,output:null,decrypt:!0,mode:C})},t.aes.Algorithm=function(c,C){if(!a)f();var T=this;T.name=c,T.mode=new C({blockSize:16,cipher:{encrypt:function(E,s){return U(T._w,E,s,!1)},decrypt:function(E,s){return U(T._w,E,s,!0)}}}),T._init=!1},t.aes.Algorithm.prototype.initialize=function(c){if(this._init)return;var C=c.key,T;if(typeof C==="string"&&(C.length===16||C.length===24||C.length===32))C=t.util.createBuffer(C);else if(t.util.isArray(C)&&(C.length===16||C.length===24||C.length===32)){T=C,C=t.util.createBuffer();for(var E=0;E<T.length;++E)C.putByte(T[E])}if(!t.util.isArray(C)){T=C,C=[];var s=T.length();if(s===16||s===24||s===32){s=s>>>2;for(var E=0;E<s;++E)C.push(T.getInt32())}}if(!t.util.isArray(C)||!(C.length===4||C.length===6||C.length===8))throw new Error("Invalid key parameter.");var p=this.mode.name,y=["CFB","OFB","CTR","GCM"].indexOf(p)!==-1;this._w=I(C,c.decrypt&&!y),this._init=!0},t.aes._expandKey=function(c,C){if(!a)f();return I(c,C)},t.aes._updateBlock=U,e("AES-ECB",t.cipher.modes.ecb),e("AES-CBC",t.cipher.modes.cbc),e("AES-CFB",t.cipher.modes.cfb),e("AES-OFB",t.cipher.modes.ofb),e("AES-CTR",t.cipher.modes.ctr),e("AES-GCM",t.cipher.modes.gcm);function e(c,C){var T=function(){return new t.aes.Algorithm(c,C)};t.cipher.registerAlgorithm(c,T)}var a=!1,d=4,g,v,u,r,m;function f(){a=!0,u=[0,1,2,4,8,16,32,64,128,27,54];var c=new Array(256);for(var C=0;C<128;++C)c[C]=C<<1,c[C+128]=C+128<<1^283;g=new Array(256),v=new Array(256),r=new Array(4),m=new Array(4);for(var C=0;C<4;++C)r[C]=new Array(256),m[C]=new Array(256);var T=0,E=0,s,p,y,b,L,h,n;for(var C=0;C<256;++C){b=E^E<<1^E<<2^E<<3^E<<4,b=b>>8^b&255^99,g[T]=b,v[b]=T,L=c[b],s=c[T],p=c[s],y=c[p],h=L<<24^b<<16^b<<8^(b^L),n=(s^p^y)<<24^(T^y)<<16^(T^p^y)<<8^(T^s^y);for(var i=0;i<4;++i)r[i][T]=h,m[i][b]=n,h=h<<24|h>>>8,n=n<<24|n>>>8;if(T===0)T=E=1;else T=s^c[c[c[s^y]]],E^=c[c[E]]}}function I(c,C){var T=c.slice(0),E,s=1,p=T.length,y=p+6+1,b=d*y;for(var L=p;L<b;++L){if(E=T[L-1],L%p===0)E=g[E>>>16&255]<<24^g[E>>>8&255]<<16^g[E&255]<<8^g[E>>>24]^u[s]<<24,s++;else if(p>6&&L%p===4)E=g[E>>>24]<<24^g[E>>>16&255]<<16^g[E>>>8&255]<<8^g[E&255];T[L]=T[L-p]^E}if(C){var h,n=m[0],i=m[1],B=m[2],V=m[3],O=T.slice(0);b=T.length;for(var L=0,P=b-d;L<b;L+=d,P-=d)if(L===0||L===b-d)O[L]=T[P],O[L+1]=T[P+3],O[L+2]=T[P+2],O[L+3]=T[P+1];else for(var M=0;M<d;++M)h=T[P+M],O[L+(3&-M)]=n[g[h>>>24]]^i[g[h>>>16&255]]^B[g[h>>>8&255]]^V[g[h&255]];T=O}return T}function U(c,C,T,E){var s=c.length/4-1,p,y,b,L,h;if(E)p=m[0],y=m[1],b=m[2],L=m[3],h=v;else p=r[0],y=r[1],b=r[2],L=r[3],h=g;var n,i,B,V,O,P,M;n=C[0]^c[0],i=C[E?3:1]^c[1],B=C[2]^c[2],V=C[E?1:3]^c[3];var G=3;for(var q=1;q<s;++q)O=p[n>>>24]^y[i>>>16&255]^b[B>>>8&255]^L[V&255]^c[++G],P=p[i>>>24]^y[B>>>16&255]^b[V>>>8&255]^L[n&255]^c[++G],M=p[B>>>24]^y[V>>>16&255]^b[n>>>8&255]^L[i&255]^c[++G],V=p[V>>>24]^y[n>>>16&255]^b[i>>>8&255]^L[B&255]^c[++G],n=O,i=P,B=M;T[0]=h[n>>>24]<<24^h[i>>>16&255]<<16^h[B>>>8&255]<<8^h[V&255]^c[++G],T[E?3:1]=h[i>>>24]<<24^h[B>>>16&255]<<16^h[V>>>8&255]<<8^h[n&255]^c[++G],T[2]=h[B>>>24]<<24^h[V>>>16&255]<<16^h[n>>>8&255]<<8^h[i&255]^c[++G],T[E?1:3]=h[V>>>24]<<24^h[n>>>16&255]<<16^h[i>>>8&255]<<8^h[B&255]^c[++G]}function S(c){c=c||{};var C=(c.mode||"CBC").toUpperCase(),T="AES-"+C,E;if(c.decrypt)E=t.cipher.createDecipher(T,c.key);else E=t.cipher.createCipher(T,c.key);var s=E.start;return E.start=function(p,y){var b=null;if(y instanceof t.util.ByteBuffer)b=y,y={};y=y||{},y.output=b,y.iv=p,s.call(E,y)},E}}),It=le((N,_)=>{var t=pe();t.pki=t.pki||{};var e=_.exports=t.pki.oids=t.oids=t.oids||{};function a(g,v){e[g]=v,e[v]=g}function d(g,v){e[g]=v}a("1.2.840.113549.1.1.1","rsaEncryption"),a("1.2.840.113549.1.1.4","md5WithRSAEncryption"),a("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),a("1.2.840.113549.1.1.7","RSAES-OAEP"),a("1.2.840.113549.1.1.8","mgf1"),a("1.2.840.113549.1.1.9","pSpecified"),a("1.2.840.113549.1.1.10","RSASSA-PSS"),a("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),a("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),a("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),a("1.3.101.112","EdDSA25519"),a("1.2.840.10040.4.3","dsa-with-sha1"),a("1.3.14.3.2.7","desCBC"),a("1.3.14.3.2.26","sha1"),a("1.3.14.3.2.29","sha1WithRSASignature"),a("2.16.840.1.101.3.4.2.1","sha256"),a("2.16.840.1.101.3.4.2.2","sha384"),a("2.16.840.1.101.3.4.2.3","sha512"),a("2.16.840.1.101.3.4.2.4","sha224"),a("2.16.840.1.101.3.4.2.5","sha512-224"),a("2.16.840.1.101.3.4.2.6","sha512-256"),a("1.2.840.113549.2.2","md2"),a("1.2.840.113549.2.5","md5"),a("1.2.840.113549.1.7.1","data"),a("1.2.840.113549.1.7.2","signedData"),a("1.2.840.113549.1.7.3","envelopedData"),a("1.2.840.113549.1.7.4","signedAndEnvelopedData"),a("1.2.840.113549.1.7.5","digestedData"),a("1.2.840.113549.1.7.6","encryptedData"),a("1.2.840.113549.1.9.1","emailAddress"),a("1.2.840.113549.1.9.2","unstructuredName"),a("1.2.840.113549.1.9.3","contentType"),a("1.2.840.113549.1.9.4","messageDigest"),a("1.2.840.113549.1.9.5","signingTime"),a("1.2.840.113549.1.9.6","counterSignature"),a("1.2.840.113549.1.9.7","challengePassword"),a("1.2.840.113549.1.9.8","unstructuredAddress"),a("1.2.840.113549.1.9.14","extensionRequest"),a("1.2.840.113549.1.9.20","friendlyName"),a("1.2.840.113549.1.9.21","localKeyId"),a("1.2.840.113549.1.9.22.1","x509Certificate"),a("1.2.840.113549.1.12.10.1.1","keyBag"),a("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),a("1.2.840.113549.1.12.10.1.3","certBag"),a("1.2.840.113549.1.12.10.1.4","crlBag"),a("1.2.840.113549.1.12.10.1.5","secretBag"),a("1.2.840.113549.1.12.10.1.6","safeContentsBag"),a("1.2.840.113549.1.5.13","pkcs5PBES2"),a("1.2.840.113549.1.5.12","pkcs5PBKDF2"),a("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),a("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),a("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),a("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),a("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),a("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),a("1.2.840.113549.2.7","hmacWithSHA1"),a("1.2.840.113549.2.8","hmacWithSHA224"),a("1.2.840.113549.2.9","hmacWithSHA256"),a("1.2.840.113549.2.10","hmacWithSHA384"),a("1.2.840.113549.2.11","hmacWithSHA512"),a("1.2.840.113549.3.7","des-EDE3-CBC"),a("2.16.840.1.101.3.4.1.2","aes128-CBC"),a("2.16.840.1.101.3.4.1.22","aes192-CBC"),a("2.16.840.1.101.3.4.1.42","aes256-CBC"),a("2.5.4.3","commonName"),a("2.5.4.4","surname"),a("2.5.4.5","serialNumber"),a("2.5.4.6","countryName"),a("2.5.4.7","localityName"),a("2.5.4.8","stateOrProvinceName"),a("2.5.4.9","streetAddress"),a("2.5.4.10","organizationName"),a("2.5.4.11","organizationalUnitName"),a("2.5.4.12","title"),a("2.5.4.13","description"),a("2.5.4.15","businessCategory"),a("2.5.4.17","postalCode"),a("2.5.4.42","givenName"),a("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),a("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),a("2.16.840.1.113730.1.1","nsCertType"),a("2.16.840.1.113730.1.13","nsComment"),d("2.5.29.1","authorityKeyIdentifier"),d("2.5.29.2","keyAttributes"),d("2.5.29.3","certificatePolicies"),d("2.5.29.4","keyUsageRestriction"),d("2.5.29.5","policyMapping"),d("2.5.29.6","subtreesConstraint"),d("2.5.29.7","subjectAltName"),d("2.5.29.8","issuerAltName"),d("2.5.29.9","subjectDirectoryAttributes"),d("2.5.29.10","basicConstraints"),d("2.5.29.11","nameConstraints"),d("2.5.29.12","policyConstraints"),d("2.5.29.13","basicConstraints"),a("2.5.29.14","subjectKeyIdentifier"),a("2.5.29.15","keyUsage"),d("2.5.29.16","privateKeyUsagePeriod"),a("2.5.29.17","subjectAltName"),a("2.5.29.18","issuerAltName"),a("2.5.29.19","basicConstraints"),d("2.5.29.20","cRLNumber"),d("2.5.29.21","cRLReason"),d("2.5.29.22","expirationDate"),d("2.5.29.23","instructionCode"),d("2.5.29.24","invalidityDate"),d("2.5.29.25","cRLDistributionPoints"),d("2.5.29.26","issuingDistributionPoint"),d("2.5.29.27","deltaCRLIndicator"),d("2.5.29.28","issuingDistributionPoint"),d("2.5.29.29","certificateIssuer"),d("2.5.29.30","nameConstraints"),a("2.5.29.31","cRLDistributionPoints"),a("2.5.29.32","certificatePolicies"),d("2.5.29.33","policyMappings"),d("2.5.29.34","policyConstraints"),a("2.5.29.35","authorityKeyIdentifier"),d("2.5.29.36","policyConstraints"),a("2.5.29.37","extKeyUsage"),d("2.5.29.46","freshestCRL"),d("2.5.29.54","inhibitAnyPolicy"),a("1.3.6.1.4.1.11129.2.4.2","timestampList"),a("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),a("1.3.6.1.5.5.7.3.1","serverAuth"),a("1.3.6.1.5.5.7.3.2","clientAuth"),a("1.3.6.1.5.5.7.3.3","codeSigning"),a("1.3.6.1.5.5.7.3.4","emailProtection"),a("1.3.6.1.5.5.7.3.8","timeStamping")}),lt=le((N,_)=>{var t=pe();Ce(),It();var e=_.exports=t.asn1=t.asn1||{};e.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},e.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},e.create=function(u,r,m,f,I){if(t.util.isArray(f)){var U=[];for(var S=0;S<f.length;++S)if(f[S]!==void 0)U.push(f[S]);f=U}var c={tagClass:u,type:r,constructed:m,composed:m||t.util.isArray(f),value:f};if(I&&"bitStringContents"in I)c.bitStringContents=I.bitStringContents,c.original=e.copy(c);return c},e.copy=function(u,r){var m;if(t.util.isArray(u)){m=[];for(var f=0;f<u.length;++f)m.push(e.copy(u[f],r));return m}if(typeof u==="string")return u;if(m={tagClass:u.tagClass,type:u.type,constructed:u.constructed,composed:u.composed,value:e.copy(u.value,r)},r&&!r.excludeBitStringContents)m.bitStringContents=u.bitStringContents;return m},e.equals=function(u,r,m){if(t.util.isArray(u)){if(!t.util.isArray(r))return!1;if(u.length!==r.length)return!1;for(var f=0;f<u.length;++f)if(!e.equals(u[f],r[f]))return!1;return!0}if(typeof u!==typeof r)return!1;if(typeof u==="string")return u===r;var I=u.tagClass===r.tagClass&&u.type===r.type&&u.constructed===r.constructed&&u.composed===r.composed&&e.equals(u.value,r.value);if(m&&m.includeBitStringContents)I=I&&u.bitStringContents===r.bitStringContents;return I},e.getBerValueLength=function(u){var r=u.getByte();if(r===128)return;var m,f=r&128;if(!f)m=r;else m=u.getInt((r&127)<<3);return m};function a(u,r,m){if(m>r){var f=new Error("Too few bytes to parse DER.");throw f.available=u.length(),f.remaining=r,f.requested=m,f}}var d=function(u,r){var m=u.getByte();if(r--,m===128)return;var f,I=m&128;if(!I)f=m;else{var U=m&127;a(u,r,U),f=u.getInt(U<<3)}if(f<0)throw new Error("Negative length: "+f);return f};e.fromDer=function(u,r){if(r===void 0)r={strict:!0,parseAllBytes:!0,decodeBitStrings:!0};if(typeof r==="boolean")r={strict:r,parseAllBytes:!0,decodeBitStrings:!0};if(!("strict"in r))r.strict=!0;if(!("parseAllBytes"in r))r.parseAllBytes=!0;if(!("decodeBitStrings"in r))r.decodeBitStrings=!0;if(typeof u==="string")u=t.util.createBuffer(u);var m=u.length(),f=g(u,u.length(),0,r);if(r.parseAllBytes&&u.length()!==0){var I=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw I.byteCount=m,I.remaining=u.length(),I}return f};function g(u,r,m,f){var I;a(u,r,2);var U=u.getByte();r--;var S=U&192,c=U&31;I=u.length();var C=d(u,r);if(r-=I-u.length(),C!==void 0&&C>r){if(f.strict){var T=new Error("Too few bytes to read ASN.1 value.");throw T.available=u.length(),T.remaining=r,T.requested=C,T}C=r}var E,s,p=(U&32)===32;if(p)if(E=[],C===void 0)for(;;){if(a(u,r,2),u.bytes(2)===String.fromCharCode(0,0)){u.getBytes(2),r-=2;break}I=u.length(),E.push(g(u,r,m+1,f)),r-=I-u.length()}else while(C>0)I=u.length(),E.push(g(u,C,m+1,f)),r-=I-u.length(),C-=I-u.length();if(E===void 0&&S===e.Class.UNIVERSAL&&c===e.Type.BITSTRING)s=u.bytes(C);if(E===void 0&&f.decodeBitStrings&&S===e.Class.UNIVERSAL&&c===e.Type.BITSTRING&&C>1){var y=u.read,b=r,L=0;if(c===e.Type.BITSTRING)a(u,r,1),L=u.getByte(),r--;if(L===0)try{I=u.length();var h={strict:!0,decodeBitStrings:!0},n=g(u,r,m+1,h),i=I-u.length();if(r-=i,c==e.Type.BITSTRING)i++;var B=n.tagClass;if(i===C&&(B===e.Class.UNIVERSAL||B===e.Class.CONTEXT_SPECIFIC))E=[n]}catch(O){}if(E===void 0)u.read=y,r=b}if(E===void 0){if(C===void 0){if(f.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");C=r}if(c===e.Type.BMPSTRING){E="";for(;C>0;C-=2)a(u,r,2),E+=String.fromCharCode(u.getInt16()),r-=2}else E=u.getBytes(C),r-=C}var V=s===void 0?null:{bitStringContents:s};return e.create(S,c,p,E,V)}e.toDer=function(u){var r=t.util.createBuffer(),m=u.tagClass|u.type,f=t.util.createBuffer(),I=!1;if("bitStringContents"in u){if(I=!0,u.original)I=e.equals(u,u.original)}if(I)f.putBytes(u.bitStringContents);else if(u.composed){if(u.constructed)m|=32;else f.putByte(0);for(var U=0;U<u.value.length;++U)if(u.value[U]!==void 0)f.putBuffer(e.toDer(u.value[U]))}else if(u.type===e.Type.BMPSTRING)for(var U=0;U<u.value.length;++U)f.putInt16(u.value.charCodeAt(U));else if(u.type===e.Type.INTEGER&&u.value.length>1&&(u.value.charCodeAt(0)===0&&(u.value.charCodeAt(1)&128)===0||u.value.charCodeAt(0)===255&&(u.value.charCodeAt(1)&128)===128))f.putBytes(u.value.substr(1));else f.putBytes(u.value);if(r.putByte(m),f.length()<=127)r.putByte(f.length()&127);else{var S=f.length(),c="";do c+=String.fromCharCode(S&255),S=S>>>8;while(S>0);r.putByte(c.length|128);for(var U=c.length-1;U>=0;--U)r.putByte(c.charCodeAt(U))}return r.putBuffer(f),r},e.oidToDer=function(u){var r=u.split("."),m=t.util.createBuffer();m.putByte(40*parseInt(r[0],10)+parseInt(r[1],10));var f,I,U,S;for(var c=2;c<r.length;++c){f=!0,I=[],U=parseInt(r[c],10);do{if(S=U&127,U=U>>>7,!f)S|=128;I.push(S),f=!1}while(U>0);for(var C=I.length-1;C>=0;--C)m.putByte(I[C])}return m},e.derToOid=function(u){var r;if(typeof u==="string")u=t.util.createBuffer(u);var m=u.getByte();r=Math.floor(m/40)+"."+m%40;var f=0;while(u.length()>0)if(m=u.getByte(),f=f<<7,m&128)f+=m&127;else r+="."+(f+m),f=0;return r},e.utcTimeToDate=function(u){var r=new Date,m=parseInt(u.substr(0,2),10);m=m>=50?1900+m:2000+m;var f=parseInt(u.substr(2,2),10)-1,I=parseInt(u.substr(4,2),10),U=parseInt(u.substr(6,2),10),S=parseInt(u.substr(8,2),10),c=0;if(u.length>11){var C=u.charAt(10),T=10;if(C!=="+"&&C!=="-")c=parseInt(u.substr(10,2),10),T+=2}if(r.setUTCFullYear(m,f,I),r.setUTCHours(U,S,c,0),T){if(C=u.charAt(T),C==="+"||C==="-"){var E=parseInt(u.substr(T+1,2),10),s=parseInt(u.substr(T+4,2),10),p=E*60+s;if(p*=60000,C==="+")r.setTime(+r-p);else r.setTime(+r+p)}}return r},e.generalizedTimeToDate=function(u){var r=new Date,m=parseInt(u.substr(0,4),10),f=parseInt(u.substr(4,2),10)-1,I=parseInt(u.substr(6,2),10),U=parseInt(u.substr(8,2),10),S=parseInt(u.substr(10,2),10),c=parseInt(u.substr(12,2),10),C=0,T=0,E=!1;if(u.charAt(u.length-1)==="Z")E=!0;var s=u.length-5,p=u.charAt(s);if(p==="+"||p==="-"){var y=parseInt(u.substr(s+1,2),10),b=parseInt(u.substr(s+4,2),10);if(T=y*60+b,T*=60000,p==="+")T*=-1;E=!0}if(u.charAt(14)===".")C=parseFloat(u.substr(14),10)*1000;if(E)r.setUTCFullYear(m,f,I),r.setUTCHours(U,S,c,C),r.setTime(+r+T);else r.setFullYear(m,f,I),r.setHours(U,S,c,C);return r},e.dateToUtcTime=function(u){if(typeof u==="string")return u;var r="",m=[];m.push((""+u.getUTCFullYear()).substr(2)),m.push(""+(u.getUTCMonth()+1)),m.push(""+u.getUTCDate()),m.push(""+u.getUTCHours()),m.push(""+u.getUTCMinutes()),m.push(""+u.getUTCSeconds());for(var f=0;f<m.length;++f){if(m[f].length<2)r+="0";r+=m[f]}return r+="Z",r},e.dateToGeneralizedTime=function(u){if(typeof u==="string")return u;var r="",m=[];m.push(""+u.getUTCFullYear()),m.push(""+(u.getUTCMonth()+1)),m.push(""+u.getUTCDate()),m.push(""+u.getUTCHours()),m.push(""+u.getUTCMinutes()),m.push(""+u.getUTCSeconds());for(var f=0;f<m.length;++f){if(m[f].length<2)r+="0";r+=m[f]}return r+="Z",r},e.integerToDer=function(u){var r=t.util.createBuffer();if(u>=-128&&u<128)return r.putSignedInt(u,8);if(u>=-32768&&u<32768)return r.putSignedInt(u,16);if(u>=-8388608&&u<8388608)return r.putSignedInt(u,24);if(u>=-2147483648&&u<2147483648)return r.putSignedInt(u,32);var m=new Error("Integer too large; max is 32-bits.");throw m.integer=u,m},e.derToInteger=function(u){if(typeof u==="string")u=t.util.createBuffer(u);var r=u.length()*8;if(r>32)throw new Error("Integer too large; max is 32-bits.");return u.getSignedInt(r)},e.validate=function(u,r,m,f){var I=!1;if((u.tagClass===r.tagClass||typeof r.tagClass==="undefined")&&(u.type===r.type||typeof r.type==="undefined")){if(u.constructed===r.constructed||typeof r.constructed==="undefined"){if(I=!0,r.value&&t.util.isArray(r.value)){var U=0;for(var S=0;I&&S<r.value.length;++S){if(I=r.value[S].optional||!1,u.value[U]){if(I=e.validate(u.value[U],r.value[S],m,f),I)++U;else if(r.value[S].optional)I=!0}if(!I&&f)f.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+u.value.length+'"')}}if(I&&m){if(r.capture)m[r.capture]=u.value;if(r.captureAsn1)m[r.captureAsn1]=u;if(r.captureBitStringContents&&"bitStringContents"in u)m[r.captureBitStringContents]=u.bitStringContents;if(r.captureBitStringValue&&"bitStringContents"in u){var c;if(u.bitStringContents.length<2)m[r.captureBitStringValue]="";else{var C=u.bitStringContents.charCodeAt(0);if(C!==0)throw new Error("captureBitStringValue only supported for zero unused bits");m[r.captureBitStringValue]=u.bitStringContents.slice(1)}}}}else if(f)f.push("["+r.name+'] Expected constructed "'+r.constructed+'", got "'+u.constructed+'"')}else if(f){if(u.tagClass!==r.tagClass)f.push("["+r.name+'] Expected tag class "'+r.tagClass+'", got "'+u.tagClass+'"');if(u.type!==r.type)f.push("["+r.name+'] Expected type "'+r.type+'", got "'+u.type+'"')}return I};var v=/[^\\u0000-\\u00ff]/;e.prettyPrint=function(u,r,m){var f="";if(r=r||0,m=m||2,r>0)f+=`
17
- `;var I="";for(var U=0;U<r*m;++U)I+=" ";switch(f+=I+"Tag: ",u.tagClass){case e.Class.UNIVERSAL:f+="Universal:";break;case e.Class.APPLICATION:f+="Application:";break;case e.Class.CONTEXT_SPECIFIC:f+="Context-Specific:";break;case e.Class.PRIVATE:f+="Private:";break}if(u.tagClass===e.Class.UNIVERSAL)switch(f+=u.type,u.type){case e.Type.NONE:f+=" (None)";break;case e.Type.BOOLEAN:f+=" (Boolean)";break;case e.Type.INTEGER:f+=" (Integer)";break;case e.Type.BITSTRING:f+=" (Bit string)";break;case e.Type.OCTETSTRING:f+=" (Octet string)";break;case e.Type.NULL:f+=" (Null)";break;case e.Type.OID:f+=" (Object Identifier)";break;case e.Type.ODESC:f+=" (Object Descriptor)";break;case e.Type.EXTERNAL:f+=" (External or Instance of)";break;case e.Type.REAL:f+=" (Real)";break;case e.Type.ENUMERATED:f+=" (Enumerated)";break;case e.Type.EMBEDDED:f+=" (Embedded PDV)";break;case e.Type.UTF8:f+=" (UTF8)";break;case e.Type.ROID:f+=" (Relative Object Identifier)";break;case e.Type.SEQUENCE:f+=" (Sequence)";break;case e.Type.SET:f+=" (Set)";break;case e.Type.PRINTABLESTRING:f+=" (Printable String)";break;case e.Type.IA5String:f+=" (IA5String (ASCII))";break;case e.Type.UTCTIME:f+=" (UTC time)";break;case e.Type.GENERALIZEDTIME:f+=" (Generalized time)";break;case e.Type.BMPSTRING:f+=" (BMP String)";break}else f+=u.type;if(f+=`
18
- `,f+=I+"Constructed: "+u.constructed+`
19
- `,u.composed){var S=0,c="";for(var U=0;U<u.value.length;++U)if(u.value[U]!==void 0){if(S+=1,c+=e.prettyPrint(u.value[U],r+1,m),U+1<u.value.length)c+=","}f+=I+"Sub values: "+S+c}else{if(f+=I+"Value: ",u.type===e.Type.OID){var C=e.derToOid(u.value);if(f+=C,t.pki&&t.pki.oids){if(C in t.pki.oids)f+=" ("+t.pki.oids[C]+") "}}if(u.type===e.Type.INTEGER)try{f+=e.derToInteger(u.value)}catch(E){f+="0x"+t.util.bytesToHex(u.value)}else if(u.type===e.Type.BITSTRING){if(u.value.length>1)f+="0x"+t.util.bytesToHex(u.value.slice(1));else f+="(none)";if(u.value.length>0){var T=u.value.charCodeAt(0);if(T==1)f+=" (1 unused bit shown)";else if(T>1)f+=" ("+T+" unused bits shown)"}}else if(u.type===e.Type.OCTETSTRING){if(!v.test(u.value))f+="("+u.value+") ";f+="0x"+t.util.bytesToHex(u.value)}else if(u.type===e.Type.UTF8)try{f+=t.util.decodeUtf8(u.value)}catch(E){if(E.message==="URI malformed")f+="0x"+t.util.bytesToHex(u.value)+" (malformed UTF8)";else throw E}else if(u.type===e.Type.PRINTABLESTRING||u.type===e.Type.IA5String)f+=u.value;else if(v.test(u.value))f+="0x"+t.util.bytesToHex(u.value);else if(u.value.length===0)f+="[null]";else f+=u.value}return f}}),yt=le((N,_)=>{var t=pe();_.exports=t.md=t.md||{},t.md.algorithms=t.md.algorithms||{}}),Ot=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.hmac=t.hmac||{};e.create=function(){var a=null,d=null,g=null,v=null,u={};return u.start=function(r,m){if(r!==null)if(typeof r==="string")if(r=r.toLowerCase(),r in t.md.algorithms)d=t.md.algorithms[r].create();else throw new Error('Unknown hash algorithm "'+r+'"');else d=r;if(m===null)m=a;else{if(typeof m==="string")m=t.util.createBuffer(m);else if(t.util.isArray(m)){var f=m;m=t.util.createBuffer();for(var I=0;I<f.length;++I)m.putByte(f[I])}var U=m.length();if(U>d.blockLength)d.start(),d.update(m.bytes()),m=d.digest();g=t.util.createBuffer(),v=t.util.createBuffer(),U=m.length();for(var I=0;I<U;++I){var f=m.at(I);g.putByte(54^f),v.putByte(92^f)}if(U<d.blockLength){var f=d.blockLength-U;for(var I=0;I<f;++I)g.putByte(54),v.putByte(92)}a=m,g=g.bytes(),v=v.bytes()}d.start(),d.update(g)},u.update=function(r){d.update(r)},u.getMac=function(){var r=d.digest().bytes();return d.start(),d.update(v),d.update(r),d.digest()},u.digest=u.getMac,u}}),lr=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.md5=t.md5||{};t.md.md5=t.md.algorithms.md5=e,e.create=function(){if(!u)r();var f=null,I=t.util.createBuffer(),U=new Array(16),S={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return S.start=function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];var c=S.messageLengthSize/4;for(var C=0;C<c;++C)S.fullMessageLength.push(0);return I=t.util.createBuffer(),f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},S},S.start(),S.update=function(c,C){if(C==="utf8")c=t.util.encodeUtf8(c);var T=c.length;S.messageLength+=T,T=[T/4294967296>>>0,T>>>0];for(var E=S.fullMessageLength.length-1;E>=0;--E)S.fullMessageLength[E]+=T[1],T[1]=T[0]+(S.fullMessageLength[E]/4294967296>>>0),S.fullMessageLength[E]=S.fullMessageLength[E]>>>0,T[0]=T[1]/4294967296>>>0;if(I.putBytes(c),m(f,U,I),I.read>2048||I.length()===0)I.compact();return S},S.digest=function(){var c=t.util.createBuffer();c.putBytes(I.bytes());var C=S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize,T=C&S.blockLength-1;c.putBytes(a.substr(0,S.blockLength-T));var E,s=0;for(var p=S.fullMessageLength.length-1;p>=0;--p)E=S.fullMessageLength[p]*8+s,s=E/4294967296>>>0,c.putInt32Le(E>>>0);var y={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3};m(y,U,c);var b=t.util.createBuffer();return b.putInt32Le(y.h0),b.putInt32Le(y.h1),b.putInt32Le(y.h2),b.putInt32Le(y.h3),b},S};var a=null,d=null,g=null,v=null,u=!1;function r(){a=String.fromCharCode(128),a+=t.util.fillString(String.fromCharCode(0),64),d=[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],g=[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],v=new Array(64);for(var f=0;f<64;++f)v[f]=Math.floor(Math.abs(Math.sin(f+1))*4294967296);u=!0}function m(f,I,U){var S,c,C,T,E,s,p,y,b=U.length();while(b>=64){c=f.h0,C=f.h1,T=f.h2,E=f.h3;for(y=0;y<16;++y)I[y]=U.getInt32Le(),s=E^C&(T^E),S=c+s+v[y]+I[y],p=g[y],c=E,E=T,T=C,C+=S<<p|S>>>32-p;for(;y<32;++y)s=T^E&(C^T),S=c+s+v[y]+I[d[y]],p=g[y],c=E,E=T,T=C,C+=S<<p|S>>>32-p;for(;y<48;++y)s=C^T^E,S=c+s+v[y]+I[d[y]],p=g[y],c=E,E=T,T=C,C+=S<<p|S>>>32-p;for(;y<64;++y)s=T^(C|~E),S=c+s+v[y]+I[d[y]],p=g[y],c=E,E=T,T=C,C+=S<<p|S>>>32-p;f.h0=f.h0+c|0,f.h1=f.h1+C|0,f.h2=f.h2+T|0,f.h3=f.h3+E|0,b-=64}}}),Rt=le((N,_)=>{var t=pe();Ce();var e=_.exports=t.pem=t.pem||{};e.encode=function(g,v){v=v||{};var u="-----BEGIN "+g.type+`-----\r
20
- `,r;if(g.procType)r={name:"Proc-Type",values:[String(g.procType.version),g.procType.type]},u+=a(r);if(g.contentDomain)r={name:"Content-Domain",values:[g.contentDomain]},u+=a(r);if(g.dekInfo){if(r={name:"DEK-Info",values:[g.dekInfo.algorithm]},g.dekInfo.parameters)r.values.push(g.dekInfo.parameters);u+=a(r)}if(g.headers)for(var m=0;m<g.headers.length;++m)u+=a(g.headers[m]);if(g.procType)u+=`\r
21
- `;return u+=t.util.encode64(g.body,v.maxline||64)+`\r
22
- `,u+="-----END "+g.type+`-----\r
23
- `,u},e.decode=function(g){var v=[],u=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,r=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,m=/\r?\n/,f;while(!0){if(f=u.exec(g),!f)break;var I=f[1];if(I==="NEW CERTIFICATE REQUEST")I="CERTIFICATE REQUEST";var U={type:I,procType:null,contentDomain:null,dekInfo:null,headers:[],body:t.util.decode64(f[3])};if(v.push(U),!f[2])continue;var S=f[2].split(m),c=0;while(f&&c<S.length){var C=S[c].replace(/\s+$/,"");for(var T=c+1;T<S.length;++T){var E=S[T];if(!/\s/.test(E[0]))break;C+=E,c=T}if(f=C.match(r),f){var s={name:f[1],values:[]},p=f[2].split(",");for(var y=0;y<p.length;++y)s.values.push(d(p[y]));if(!U.procType){if(s.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');else if(s.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');U.procType={version:p[0],type:p[1]}}else if(!U.contentDomain&&s.name==="Content-Domain")U.contentDomain=p[0]||"";else if(!U.dekInfo&&s.name==="DEK-Info"){if(s.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');U.dekInfo={algorithm:p[0],parameters:p[1]||null}}else U.headers.push(s)}++c}if(U.procType==="ENCRYPTED"&&!U.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}if(v.length===0)throw new Error("Invalid PEM formatted message.");return v};function a(g){var v=g.name+": ",u=[],r=function(S,c){return" "+c};for(var m=0;m<g.values.length;++m)u.push(g.values[m].replace(/^(\S+\r\n)/,r));v+=u.join(",")+`\r
24
- `;var f=0,I=-1;for(var m=0;m<v.length;++m,++f)if(f>65&&I!==-1){var U=v[I];if(U===",")++I,v=v.substr(0,I)+`\r
25
- `+v.substr(I);else v=v.substr(0,I)+`\r
26
- `+U+v.substr(I+1);f=m-I-1,I=-1,++m}else if(v[m]===" "||v[m]==="\t"||v[m]===",")I=m;return v}function d(g){return g.replace(/^\s+/,"")}}),Yt=le((N,_)=>{var t=pe();ur(),Mr(),Ce(),_.exports=t.des=t.des||{},t.des.startEncrypting=function(c,C,T,E){var s=S({key:c,output:T,decrypt:!1,mode:E||(C===null?"ECB":"CBC")});return s.start(C),s},t.des.createEncryptionCipher=function(c,C){return S({key:c,output:null,decrypt:!1,mode:C})},t.des.startDecrypting=function(c,C,T,E){var s=S({key:c,output:T,decrypt:!0,mode:E||(C===null?"ECB":"CBC")});return s.start(C),s},t.des.createDecryptionCipher=function(c,C){return S({key:c,output:null,decrypt:!0,mode:C})},t.des.Algorithm=function(c,C){var T=this;T.name=c,T.mode=new C({blockSize:8,cipher:{encrypt:function(E,s){return U(T._keys,E,s,!1)},decrypt:function(E,s){return U(T._keys,E,s,!0)}}}),T._init=!1},t.des.Algorithm.prototype.initialize=function(c){if(this._init)return;var C=t.util.createBuffer(c.key);if(this.name.indexOf("3DES")===0){if(C.length()!==24)throw new Error("Invalid Triple-DES key size: "+C.length()*8)}this._keys=I(C),this._init=!0},e("DES-ECB",t.cipher.modes.ecb),e("DES-CBC",t.cipher.modes.cbc),e("DES-CFB",t.cipher.modes.cfb),e("DES-OFB",t.cipher.modes.ofb),e("DES-CTR",t.cipher.modes.ctr),e("3DES-ECB",t.cipher.modes.ecb),e("3DES-CBC",t.cipher.modes.cbc),e("3DES-CFB",t.cipher.modes.cfb),e("3DES-OFB",t.cipher.modes.ofb),e("3DES-CTR",t.cipher.modes.ctr);function e(c,C){var T=function(){return new t.des.Algorithm(c,C)};t.cipher.registerAlgorithm(c,T)}var a=[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],d=[-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],g=[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],v=[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],u=[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],r=[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],m=[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 I(c){var C=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],T=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],E=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],s=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],p=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],y=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],b=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],L=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],h=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],n=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],i=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],B=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],V=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],O=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],P=c.length()>8?3:1,M=[],G=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],q=0,H;for(var X=0;X<P;X++){var J=c.getInt32(),te=c.getInt32();H=(J>>>4^te)&252645135,te^=H,J^=H<<4,H=(te>>>-16^J)&65535,J^=H,te^=H<<-16,H=(J>>>2^te)&858993459,te^=H,J^=H<<2,H=(te>>>-16^J)&65535,J^=H,te^=H<<-16,H=(J>>>1^te)&1431655765,te^=H,J^=H<<1,H=(te>>>8^J)&16711935,J^=H,te^=H<<8,H=(J>>>1^te)&1431655765,te^=H,J^=H<<1,H=J<<8|te>>>20&240,J=te<<24|te<<8&16711680|te>>>8&65280|te>>>24&240,te=H;for(var se=0;se<G.length;++se){if(G[se])J=J<<2|J>>>26,te=te<<2|te>>>26;else J=J<<1|J>>>27,te=te<<1|te>>>27;J&=-15,te&=-15;var fe=C[J>>>28]|T[J>>>24&15]|E[J>>>20&15]|s[J>>>16&15]|p[J>>>12&15]|y[J>>>8&15]|b[J>>>4&15],ve=L[te>>>28]|h[te>>>24&15]|n[te>>>20&15]|i[te>>>16&15]|B[te>>>12&15]|V[te>>>8&15]|O[te>>>4&15];H=(ve>>>16^fe)&65535,M[q++]=fe^H,M[q++]=ve^H<<16}}return M}function U(c,C,T,E){var s=c.length===32?3:9,p;if(s===3)p=E?[30,-2,-2]:[0,32,2];else p=E?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y,b=C[0],L=C[1];y=(b>>>4^L)&252645135,L^=y,b^=y<<4,y=(b>>>16^L)&65535,L^=y,b^=y<<16,y=(L>>>2^b)&858993459,b^=y,L^=y<<2,y=(L>>>8^b)&16711935,b^=y,L^=y<<8,y=(b>>>1^L)&1431655765,L^=y,b^=y<<1,b=b<<1|b>>>31,L=L<<1|L>>>31;for(var h=0;h<s;h+=3){var n=p[h+1],i=p[h+2];for(var B=p[h];B!=n;B+=i){var V=L^c[B],O=(L>>>4|L<<28)^c[B+1];y=b,b=L,L=y^(d[V>>>24&63]|v[V>>>16&63]|r[V>>>8&63]|f[V&63]|a[O>>>24&63]|g[O>>>16&63]|u[O>>>8&63]|m[O&63])}y=b,b=L,L=y}b=b>>>1|b<<31,L=L>>>1|L<<31,y=(b>>>1^L)&1431655765,L^=y,b^=y<<1,y=(L>>>8^b)&16711935,b^=y,L^=y<<8,y=(L>>>2^b)&858993459,b^=y,L^=y<<2,y=(b>>>16^L)&65535,L^=y,b^=y<<16,y=(b>>>4^L)&252645135,L^=y,b^=y<<4,T[0]=b,T[1]=L}function S(c){c=c||{};var C=(c.mode||"CBC").toUpperCase(),T="DES-"+C,E;if(c.decrypt)E=t.cipher.createDecipher(T,c.key);else E=t.cipher.createCipher(T,c.key);var s=E.start;return E.start=function(p,y){var b=null;if(y instanceof t.util.ByteBuffer)b=y,y={};y=y||{},y.output=b,y.iv=p,s.call(E,y)},E}}),fr=le((N,_)=>{var t=pe();Ot(),yt(),Ce();var e=t.pkcs5=t.pkcs5||{},a;if(t.util.isNodejs&&!t.options.usePureJavaScript)a=zt("crypto");_.exports=t.pbkdf2=e.pbkdf2=function(d,g,v,u,r,m){if(typeof r==="function")m=r,r=null;if(t.util.isNodejs&&!t.options.usePureJavaScript&&a.pbkdf2&&(r===null||typeof r!=="object")&&(a.pbkdf2Sync.length>4||(!r||r==="sha1"))){if(typeof r!=="string")r="sha1";if(d=Buffer.from(d,"binary"),g=Buffer.from(g,"binary"),!m){if(a.pbkdf2Sync.length===4)return a.pbkdf2Sync(d,g,v,u).toString("binary");return a.pbkdf2Sync(d,g,v,u,r).toString("binary")}if(a.pbkdf2Sync.length===4)return a.pbkdf2(d,g,v,u,function(h,n){if(h)return m(h);m(null,n.toString("binary"))});return a.pbkdf2(d,g,v,u,r,function(h,n){if(h)return m(h);m(null,n.toString("binary"))})}if(typeof r==="undefined"||r===null)r="sha1";if(typeof r==="string"){if(!(r in t.md.algorithms))throw new Error("Unknown hash algorithm: "+r);r=t.md[r].create()}var f=r.digestLength;if(u>4294967295*f){var I=new Error("Derived key is too long.");if(m)return m(I);throw I}var U=Math.ceil(u/f),S=u-(U-1)*f,c=t.hmac.create();c.start(r,d);var C="",T,E,s;if(!m){for(var p=1;p<=U;++p){c.start(null,null),c.update(g),c.update(t.util.int32ToBytes(p)),T=s=c.digest().getBytes();for(var y=2;y<=v;++y)c.start(null,null),c.update(s),E=c.digest().getBytes(),T=t.util.xorBytes(T,E,f),s=E;C+=p<U?T:T.substr(0,S)}return C}var p=1,y;function b(){if(p>U)return m(null,C);c.start(null,null),c.update(g),c.update(t.util.int32ToBytes(p)),T=s=c.digest().getBytes(),y=2,L()}function L(){if(y<=v)return c.start(null,null),c.update(s),E=c.digest().getBytes(),T=t.util.xorBytes(T,E,f),s=E,++y,t.util.setImmediate(L);C+=p<U?T:T.substr(0,S),++p,b()}b()}}),Fr=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.sha256=t.sha256||{};t.md.sha256=t.md.algorithms.sha256=e,e.create=function(){if(!d)v();var r=null,m=t.util.createBuffer(),f=new Array(64),I={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return I.start=function(){I.messageLength=0,I.fullMessageLength=I.messageLength64=[];var U=I.messageLengthSize/4;for(var S=0;S<U;++S)I.fullMessageLength.push(0);return m=t.util.createBuffer(),r={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},I},I.start(),I.update=function(U,S){if(S==="utf8")U=t.util.encodeUtf8(U);var c=U.length;I.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var C=I.fullMessageLength.length-1;C>=0;--C)I.fullMessageLength[C]+=c[1],c[1]=c[0]+(I.fullMessageLength[C]/4294967296>>>0),I.fullMessageLength[C]=I.fullMessageLength[C]>>>0,c[0]=c[1]/4294967296>>>0;if(m.putBytes(U),u(r,f,m),m.read>2048||m.length()===0)m.compact();return I},I.digest=function(){var U=t.util.createBuffer();U.putBytes(m.bytes());var S=I.fullMessageLength[I.fullMessageLength.length-1]+I.messageLengthSize,c=S&I.blockLength-1;U.putBytes(a.substr(0,I.blockLength-c));var C,T,E=I.fullMessageLength[0]*8;for(var s=0;s<I.fullMessageLength.length-1;++s)C=I.fullMessageLength[s+1]*8,T=C/4294967296>>>0,E+=T,U.putInt32(E>>>0),E=C>>>0;U.putInt32(E);var p={h0:r.h0,h1:r.h1,h2:r.h2,h3:r.h3,h4:r.h4,h5:r.h5,h6:r.h6,h7:r.h7};u(p,f,U);var y=t.util.createBuffer();return y.putInt32(p.h0),y.putInt32(p.h1),y.putInt32(p.h2),y.putInt32(p.h3),y.putInt32(p.h4),y.putInt32(p.h5),y.putInt32(p.h6),y.putInt32(p.h7),y},I};var a=null,d=!1,g=null;function v(){a=String.fromCharCode(128),a+=t.util.fillString(String.fromCharCode(0),64),g=[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],d=!0}function u(r,m,f){var I,U,S,c,C,T,E,s,p,y,b,L,h,n,i,B=f.length();while(B>=64){for(E=0;E<16;++E)m[E]=f.getInt32();for(;E<64;++E)I=m[E-2],I=(I>>>17|I<<15)^(I>>>19|I<<13)^I>>>10,U=m[E-15],U=(U>>>7|U<<25)^(U>>>18|U<<14)^U>>>3,m[E]=I+m[E-7]+U+m[E-16]|0;s=r.h0,p=r.h1,y=r.h2,b=r.h3,L=r.h4,h=r.h5,n=r.h6,i=r.h7;for(E=0;E<64;++E)c=(L>>>6|L<<26)^(L>>>11|L<<21)^(L>>>25|L<<7),C=n^L&(h^n),S=(s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10),T=s&p|y&(s^p),I=i+c+C+g[E]+m[E],U=S+T,i=n,n=h,h=L,L=b+I>>>0,b=y,y=p,p=s,s=I+U>>>0;r.h0=r.h0+s|0,r.h1=r.h1+p|0,r.h2=r.h2+y|0,r.h3=r.h3+b|0,r.h4=r.h4+L|0,r.h5=r.h5+h|0,r.h6=r.h6+n|0,r.h7=r.h7+i|0,B-=64}}}),jr=le((N,_)=>{var t=pe();Ce();var e=null;if(t.util.isNodejs&&!t.options.usePureJavaScript&&!process.versions["node-webkit"])e=zt("crypto");var a=_.exports=t.prng=t.prng||{};a.create=function(d){var g={plugin:d,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},v=d.md,u=new Array(32);for(var r=0;r<32;++r)u[r]=v.create();g.pools=u,g.pool=0,g.generate=function(S,c){if(!c)return g.generateSync(S);var C=g.plugin.cipher,T=g.plugin.increment,E=g.plugin.formatKey,s=g.plugin.formatSeed,p=t.util.createBuffer();g.key=null,y();function y(b){if(b)return c(b);if(p.length()>=S)return c(null,p.getBytes(S));if(g.generated>1048575)g.key=null;if(g.key===null)return t.util.nextTick(function(){m(y)});var L=C(g.key,g.seed);g.generated+=L.length,p.putBytes(L),g.key=E(C(g.key,T(g.seed))),g.seed=s(C(g.key,g.seed)),t.util.setImmediate(y)}},g.generateSync=function(S){var c=g.plugin.cipher,C=g.plugin.increment,T=g.plugin.formatKey,E=g.plugin.formatSeed;g.key=null;var s=t.util.createBuffer();while(s.length()<S){if(g.generated>1048575)g.key=null;if(g.key===null)f();var p=c(g.key,g.seed);g.generated+=p.length,s.putBytes(p),g.key=T(c(g.key,C(g.seed))),g.seed=E(c(g.key,g.seed))}return s.getBytes(S)};function m(S){if(g.pools[0].messageLength>=32)return I(),S();var c=32-g.pools[0].messageLength<<5;g.seedFile(c,function(C,T){if(C)return S(C);g.collect(T),I(),S()})}function f(){if(g.pools[0].messageLength>=32)return I();var S=32-g.pools[0].messageLength<<5;g.collect(g.seedFileSync(S)),I()}function I(){g.reseeds=g.reseeds===4294967295?0:g.reseeds+1;var S=g.plugin.md.create();S.update(g.keyBytes);var c=1;for(var C=0;C<32;++C){if(g.reseeds%c===0)S.update(g.pools[C].digest().getBytes()),g.pools[C].start();c=c<<1}g.keyBytes=S.digest().getBytes(),S.start(),S.update(g.keyBytes);var T=S.digest().getBytes();g.key=g.plugin.formatKey(g.keyBytes),g.seed=g.plugin.formatSeed(T),g.generated=0}function U(S){var c=null,C=t.util.globalScope,T=C.crypto||C.msCrypto;if(T&&T.getRandomValues)c=function(i){return T.getRandomValues(i)};var E=t.util.createBuffer();if(c)while(E.length()<S){var s=Math.max(1,Math.min(S-E.length(),65536)/4),p=new Uint32Array(Math.floor(s));try{c(p);for(var y=0;y<p.length;++y)E.putInt32(p[y])}catch(i){if(!(typeof QuotaExceededError!=="undefined"&&i instanceof QuotaExceededError))throw i}}if(E.length()<S){var b,L,h,n=Math.floor(Math.random()*65536);while(E.length()<S){L=16807*(n&65535),b=16807*(n>>16),L+=(b&32767)<<16,L+=b>>15,L=(L&2147483647)+(L>>31),n=L&4294967295;for(var y=0;y<3;++y)h=n>>>(y<<3),h^=Math.floor(Math.random()*256),E.putByte(h&255)}}return E.getBytes(S)}if(e)g.seedFile=function(S,c){e.randomBytes(S,function(C,T){if(C)return c(C);c(null,T.toString())})},g.seedFileSync=function(S){return e.randomBytes(S).toString()};else g.seedFile=function(S,c){try{c(null,U(S))}catch(C){c(C)}},g.seedFileSync=U;return g.collect=function(S){var c=S.length;for(var C=0;C<c;++C)g.pools[g.pool].update(S.substr(C,1)),g.pool=g.pool===31?0:g.pool+1},g.collectInt=function(S,c){var C="";for(var T=0;T<c;T+=8)C+=String.fromCharCode(S>>T&255);g.collect(C)},g.registerWorker=function(S){if(S===self)g.seedFile=function(C,T){function E(s){var p=s.data;if(p.forge&&p.forge.prng)self.removeEventListener("message",E),T(p.forge.prng.err,p.forge.prng.bytes)}self.addEventListener("message",E),self.postMessage({forge:{prng:{needed:C}}})};else{var c=function(C){var T=C.data;if(T.forge&&T.forge.prng)g.seedFile(T.forge.prng.needed,function(E,s){S.postMessage({forge:{prng:{err:E,bytes:s}}})})};S.addEventListener("message",c)}},g}}),ct=le((N,_)=>{var t=pe();Tt(),Fr(),jr(),Ce(),function(){if(t.random&&t.random.getBytes){_.exports=t.random;return}(function(e){var a={},d=new Array(4),g=t.util.createBuffer();a.formatKey=function(S){var c=t.util.createBuffer(S);return S=new Array(4),S[0]=c.getInt32(),S[1]=c.getInt32(),S[2]=c.getInt32(),S[3]=c.getInt32(),t.aes._expandKey(S,!1)},a.formatSeed=function(S){var c=t.util.createBuffer(S);return S=new Array(4),S[0]=c.getInt32(),S[1]=c.getInt32(),S[2]=c.getInt32(),S[3]=c.getInt32(),S},a.cipher=function(S,c){return t.aes._updateBlock(S,c,d,!1),g.putInt32(d[0]),g.putInt32(d[1]),g.putInt32(d[2]),g.putInt32(d[3]),g.getBytes()},a.increment=function(S){return++S[3],S},a.md=t.md.sha256;function v(){var S=t.prng.create(a);return S.getBytes=function(c,C){return S.generate(c,C)},S.getBytesSync=function(c){return S.generate(c)},S}var u=v(),r=null,m=t.util.globalScope,f=m.crypto||m.msCrypto;if(f&&f.getRandomValues)r=function(S){return f.getRandomValues(S)};if(t.options.usePureJavaScript||!t.util.isNodejs&&!r){if(typeof window==="undefined"||window.document===void 0);if(u.collectInt(+new Date,32),typeof navigator!=="undefined"){var I="";for(var U in navigator)try{if(typeof navigator[U]=="string")I+=navigator[U]}catch(S){}u.collect(I),I=null}if(e)e().mousemove(function(S){u.collectInt(S.clientX,16),u.collectInt(S.clientY,16)}),e().keypress(function(S){u.collectInt(S.charCode,8)})}if(!t.random)t.random=u;else for(var U in u)t.random[U]=u[U];t.random.createInstance=v,_.exports=t.random})(typeof jQuery!=="undefined"?jQuery:null)}()}),Gr=le((N,_)=>{var t=pe();Ce();var e=[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],a=[1,2,3,5],d=function(u,r){return u<<r&65535|(u&65535)>>16-r},g=function(u,r){return(u&65535)>>r|u<<16-r&65535};_.exports=t.rc2=t.rc2||{},t.rc2.expandKey=function(u,r){if(typeof u==="string")u=t.util.createBuffer(u);r=r||128;var m=u,f=u.length(),I=r,U=Math.ceil(I/8),S=255>>(I&7),c;for(c=f;c<128;c++)m.putByte(e[m.at(c-1)+m.at(c-f)&255]);m.setAt(128-U,e[m.at(128-U)&S]);for(c=127-U;c>=0;c--)m.setAt(c,e[m.at(c+1)^m.at(c+U)]);return m};var v=function(u,r,m){var f=!1,I=null,U=null,S=null,c,C,T,E,s=[];u=t.rc2.expandKey(u,r);for(T=0;T<64;T++)s.push(u.getInt16Le());if(m)c=function(b){for(T=0;T<4;T++)b[T]+=s[E]+(b[(T+3)%4]&b[(T+2)%4])+(~b[(T+3)%4]&b[(T+1)%4]),b[T]=d(b[T],a[T]),E++},C=function(b){for(T=0;T<4;T++)b[T]+=s[b[(T+3)%4]&63]};else c=function(b){for(T=3;T>=0;T--)b[T]=g(b[T],a[T]),b[T]-=s[E]+(b[(T+3)%4]&b[(T+2)%4])+(~b[(T+3)%4]&b[(T+1)%4]),E--},C=function(b){for(T=3;T>=0;T--)b[T]-=s[b[(T+3)%4]&63]};var p=function(b){var L=[];for(T=0;T<4;T++){var h=I.getInt16Le();if(S!==null)if(m)h^=S.getInt16Le();else S.putInt16Le(h);L.push(h&65535)}E=m?0:63;for(var n=0;n<b.length;n++)for(var i=0;i<b[n][0];i++)b[n][1](L);for(T=0;T<4;T++){if(S!==null)if(m)S.putInt16Le(L[T]);else L[T]^=S.getInt16Le();U.putInt16Le(L[T])}},y=null;return y={start:function(b,L){if(b){if(typeof b==="string")b=t.util.createBuffer(b)}f=!1,I=t.util.createBuffer(),U=L||new t.util.createBuffer,S=b,y.output=U},update:function(b){if(!f)I.putBuffer(b);while(I.length()>=8)p([[5,c],[1,C],[6,c],[1,C],[5,c]])},finish:function(b){var L=!0;if(m)if(b)L=b(8,I,!m);else{var h=I.length()===8?8:8-I.length();I.fillWithByte(h,h)}if(L)f=!0,y.update();if(!m){if(L=I.length()===0,L)if(b)L=b(8,U,!m);else{var n=U.length(),i=U.at(n-1);if(i>n)L=!1;else U.truncate(i)}}return L}},y};t.rc2.startEncrypting=function(u,r,m){var f=t.rc2.createEncryptionCipher(u,128);return f.start(r,m),f},t.rc2.createEncryptionCipher=function(u,r){return v(u,r,!0)},t.rc2.startDecrypting=function(u,r,m){var f=t.rc2.createDecryptionCipher(u,128);return f.start(r,m),f},t.rc2.createDecryptionCipher=function(u,r){return v(u,r,!1)}}),Xt=le((N,_)=>{var t=pe();_.exports=t.jsbn=t.jsbn||{};var e,a=244837814094590,d=(a&16777215)==15715070;function g(A,k,x){if(this.data=[],A!=null)if(typeof A=="number")this.fromNumber(A,k,x);else if(k==null&&typeof A!="string")this.fromString(A,256);else this.fromString(A,k)}t.jsbn.BigInteger=g;function v(){return new g(null)}function u(A,k,x,j,z,W){while(--W>=0){var ne=k*this.data[A++]+x.data[j]+z;z=Math.floor(ne/67108864),x.data[j++]=ne&67108863}return z}function r(A,k,x,j,z,W){var ne=k&32767,re=k>>15;while(--W>=0){var Ee=this.data[A]&32767,Ye=this.data[A++]>>15,rt=re*Ee+Ye*ne;Ee=ne*Ee+((rt&32767)<<15)+x.data[j]+(z&1073741823),z=(Ee>>>30)+(rt>>>15)+re*Ye+(z>>>30),x.data[j++]=Ee&1073741823}return z}function m(A,k,x,j,z,W){var ne=k&16383,re=k>>14;while(--W>=0){var Ee=this.data[A]&16383,Ye=this.data[A++]>>14,rt=re*Ee+Ye*ne;Ee=ne*Ee+((rt&16383)<<14)+x.data[j]+z,z=(Ee>>28)+(rt>>14)+re*Ye,x.data[j++]=Ee&268435455}return z}if(typeof navigator==="undefined")g.prototype.am=m,e=28;else if(d&&navigator.appName=="Microsoft Internet Explorer")g.prototype.am=r,e=30;else if(d&&navigator.appName!="Netscape")g.prototype.am=u,e=26;else g.prototype.am=m,e=28;g.prototype.DB=e,g.prototype.DM=(1<<e)-1,g.prototype.DV=1<<e;var f=52;g.prototype.FV=Math.pow(2,f),g.prototype.F1=f-e,g.prototype.F2=2*e-f;var I="0123456789abcdefghijklmnopqrstuvwxyz",U=new Array,S,c;S=48;for(c=0;c<=9;++c)U[S++]=c;S=97;for(c=10;c<36;++c)U[S++]=c;S=65;for(c=10;c<36;++c)U[S++]=c;function C(A){return I.charAt(A)}function T(A,k){var x=U[A.charCodeAt(k)];return x==null?-1:x}function E(A){for(var k=this.t-1;k>=0;--k)A.data[k]=this.data[k];A.t=this.t,A.s=this.s}function s(A){if(this.t=1,this.s=A<0?-1:0,A>0)this.data[0]=A;else if(A<-1)this.data[0]=A+this.DV;else this.t=0}function p(A){var k=v();return k.fromInt(A),k}function y(A,k){var x;if(k==16)x=4;else if(k==8)x=3;else if(k==256)x=8;else if(k==2)x=1;else if(k==32)x=5;else if(k==4)x=2;else{this.fromRadix(A,k);return}this.t=0,this.s=0;var j=A.length,z=!1,W=0;while(--j>=0){var ne=x==8?A[j]&255:T(A,j);if(ne<0){if(A.charAt(j)=="-")z=!0;continue}if(z=!1,W==0)this.data[this.t++]=ne;else if(W+x>this.DB)this.data[this.t-1]|=(ne&(1<<this.DB-W)-1)<<W,this.data[this.t++]=ne>>this.DB-W;else this.data[this.t-1]|=ne<<W;if(W+=x,W>=this.DB)W-=this.DB}if(x==8&&(A[0]&128)!=0){if(this.s=-1,W>0)this.data[this.t-1]|=(1<<this.DB-W)-1<<W}if(this.clamp(),z)g.ZERO.subTo(this,this)}function b(){var A=this.s&this.DM;while(this.t>0&&this.data[this.t-1]==A)--this.t}function L(A){if(this.s<0)return"-"+this.negate().toString(A);var k;if(A==16)k=4;else if(A==8)k=3;else if(A==2)k=1;else if(A==32)k=5;else if(A==4)k=2;else return this.toRadix(A);var x=(1<<k)-1,j,z=!1,W="",ne=this.t,re=this.DB-ne*this.DB%k;if(ne-- >0){if(re<this.DB&&(j=this.data[ne]>>re)>0)z=!0,W=C(j);while(ne>=0){if(re<k)j=(this.data[ne]&(1<<re)-1)<<k-re,j|=this.data[--ne]>>(re+=this.DB-k);else if(j=this.data[ne]>>(re-=k)&x,re<=0)re+=this.DB,--ne;if(j>0)z=!0;if(z)W+=C(j)}}return z?W:"0"}function h(){var A=v();return g.ZERO.subTo(this,A),A}function n(){return this.s<0?this.negate():this}function i(A){var k=this.s-A.s;if(k!=0)return k;var x=this.t;if(k=x-A.t,k!=0)return this.s<0?-k:k;while(--x>=0)if((k=this.data[x]-A.data[x])!=0)return k;return 0}function B(A){var k=1,x;if((x=A>>>16)!=0)A=x,k+=16;if((x=A>>8)!=0)A=x,k+=8;if((x=A>>4)!=0)A=x,k+=4;if((x=A>>2)!=0)A=x,k+=2;if((x=A>>1)!=0)A=x,k+=1;return k}function V(){if(this.t<=0)return 0;return this.DB*(this.t-1)+B(this.data[this.t-1]^this.s&this.DM)}function O(A,k){var x;for(x=this.t-1;x>=0;--x)k.data[x+A]=this.data[x];for(x=A-1;x>=0;--x)k.data[x]=0;k.t=this.t+A,k.s=this.s}function P(A,k){for(var x=A;x<this.t;++x)k.data[x-A]=this.data[x];k.t=Math.max(this.t-A,0),k.s=this.s}function M(A,k){var x=A%this.DB,j=this.DB-x,z=(1<<j)-1,W=Math.floor(A/this.DB),ne=this.s<<x&this.DM,re;for(re=this.t-1;re>=0;--re)k.data[re+W+1]=this.data[re]>>j|ne,ne=(this.data[re]&z)<<x;for(re=W-1;re>=0;--re)k.data[re]=0;k.data[W]=ne,k.t=this.t+W+1,k.s=this.s,k.clamp()}function G(A,k){k.s=this.s;var x=Math.floor(A/this.DB);if(x>=this.t){k.t=0;return}var j=A%this.DB,z=this.DB-j,W=(1<<j)-1;k.data[0]=this.data[x]>>j;for(var ne=x+1;ne<this.t;++ne)k.data[ne-x-1]|=(this.data[ne]&W)<<z,k.data[ne-x]=this.data[ne]>>j;if(j>0)k.data[this.t-x-1]|=(this.s&W)<<z;k.t=this.t-x,k.clamp()}function q(A,k){var x=0,j=0,z=Math.min(A.t,this.t);while(x<z)j+=this.data[x]-A.data[x],k.data[x++]=j&this.DM,j>>=this.DB;if(A.t<this.t){j-=A.s;while(x<this.t)j+=this.data[x],k.data[x++]=j&this.DM,j>>=this.DB;j+=this.s}else{j+=this.s;while(x<A.t)j-=A.data[x],k.data[x++]=j&this.DM,j>>=this.DB;j-=A.s}if(k.s=j<0?-1:0,j<-1)k.data[x++]=this.DV+j;else if(j>0)k.data[x++]=j;k.t=x,k.clamp()}function H(A,k){var x=this.abs(),j=A.abs(),z=x.t;k.t=z+j.t;while(--z>=0)k.data[z]=0;for(z=0;z<j.t;++z)k.data[z+x.t]=x.am(0,j.data[z],k,z,0,x.t);if(k.s=0,k.clamp(),this.s!=A.s)g.ZERO.subTo(k,k)}function X(A){var k=this.abs(),x=A.t=2*k.t;while(--x>=0)A.data[x]=0;for(x=0;x<k.t-1;++x){var j=k.am(x,k.data[x],A,2*x,0,1);if((A.data[x+k.t]+=k.am(x+1,2*k.data[x],A,2*x+1,j,k.t-x-1))>=k.DV)A.data[x+k.t]-=k.DV,A.data[x+k.t+1]=1}if(A.t>0)A.data[A.t-1]+=k.am(x,k.data[x],A,2*x,0,1);A.s=0,A.clamp()}function J(A,k,x){var j=A.abs();if(j.t<=0)return;var z=this.abs();if(z.t<j.t){if(k!=null)k.fromInt(0);if(x!=null)this.copyTo(x);return}if(x==null)x=v();var W=v(),ne=this.s,re=A.s,Ee=this.DB-B(j.data[j.t-1]);if(Ee>0)j.lShiftTo(Ee,W),z.lShiftTo(Ee,x);else j.copyTo(W),z.copyTo(x);var Ye=W.t,rt=W.data[Ye-1];if(rt==0)return;var tt=rt*(1<<this.F1)+(Ye>1?W.data[Ye-2]>>this.F2:0),pt=this.FV/tt,Gt=(1<<this.F1)/tt,st=1<<this.F2,ot=x.t,qt=ot-Ye,vt=k==null?v():k;if(W.dlShiftTo(qt,vt),x.compareTo(vt)>=0)x.data[x.t++]=1,x.subTo(vt,x);g.ONE.dlShiftTo(Ye,vt),vt.subTo(W,W);while(W.t<Ye)W.data[W.t++]=0;while(--qt>=0){var er=x.data[--ot]==rt?this.DM:Math.floor(x.data[ot]*pt+(x.data[ot-1]+st)*Gt);if((x.data[ot]+=W.am(0,er,x,qt,0,Ye))<er){W.dlShiftTo(qt,vt),x.subTo(vt,x);while(x.data[ot]<--er)x.subTo(vt,x)}}if(k!=null){if(x.drShiftTo(Ye,k),ne!=re)g.ZERO.subTo(k,k)}if(x.t=Ye,x.clamp(),Ee>0)x.rShiftTo(Ee,x);if(ne<0)g.ZERO.subTo(x,x)}function te(A){var k=v();if(this.abs().divRemTo(A,null,k),this.s<0&&k.compareTo(g.ZERO)>0)A.subTo(k,k);return k}function se(A){this.m=A}function fe(A){if(A.s<0||A.compareTo(this.m)>=0)return A.mod(this.m);else return A}function ve(A){return A}function Ie(A){A.divRemTo(this.m,null,A)}function Z(A,k,x){A.multiplyTo(k,x),this.reduce(x)}function me(A,k){A.squareTo(k),this.reduce(k)}se.prototype.convert=fe,se.prototype.revert=ve,se.prototype.reduce=Ie,se.prototype.mulTo=Z,se.prototype.sqrTo=me;function ee(){if(this.t<1)return 0;var A=this.data[0];if((A&1)==0)return 0;var k=A&3;return k=k*(2-(A&15)*k)&15,k=k*(2-(A&255)*k)&255,k=k*(2-((A&65535)*k&65535))&65535,k=k*(2-A*k%this.DV)%this.DV,k>0?this.DV-k:-k}function Ae(A){this.m=A,this.mp=A.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<A.DB-15)-1,this.mt2=2*A.t}function de(A){var k=v();if(A.abs().dlShiftTo(this.m.t,k),k.divRemTo(this.m,null,k),A.s<0&&k.compareTo(g.ZERO)>0)this.m.subTo(k,k);return k}function l(A){var k=v();return A.copyTo(k),this.reduce(k),k}function D(A){while(A.t<=this.mt2)A.data[A.t++]=0;for(var k=0;k<this.m.t;++k){var x=A.data[k]&32767,j=x*this.mpl+((x*this.mph+(A.data[k]>>15)*this.mpl&this.um)<<15)&A.DM;x=k+this.m.t,A.data[x]+=this.m.am(0,j,A,k,0,this.m.t);while(A.data[x]>=A.DV)A.data[x]-=A.DV,A.data[++x]++}if(A.clamp(),A.drShiftTo(this.m.t,A),A.compareTo(this.m)>=0)A.subTo(this.m,A)}function R(A,k){A.squareTo(k),this.reduce(k)}function o(A,k,x){A.multiplyTo(k,x),this.reduce(x)}Ae.prototype.convert=de,Ae.prototype.revert=l,Ae.prototype.reduce=D,Ae.prototype.mulTo=o,Ae.prototype.sqrTo=R;function w(){return(this.t>0?this.data[0]&1:this.s)==0}function F(A,k){if(A>4294967295||A<1)return g.ONE;var x=v(),j=v(),z=k.convert(this),W=B(A)-1;z.copyTo(x);while(--W>=0)if(k.sqrTo(x,j),(A&1<<W)>0)k.mulTo(j,z,x);else{var ne=x;x=j,j=ne}return k.revert(x)}function K(A,k){var x;if(A<256||k.isEven())x=new se(k);else x=new Ae(k);return this.exp(A,x)}g.prototype.copyTo=E,g.prototype.fromInt=s,g.prototype.fromString=y,g.prototype.clamp=b,g.prototype.dlShiftTo=O,g.prototype.drShiftTo=P,g.prototype.lShiftTo=M,g.prototype.rShiftTo=G,g.prototype.subTo=q,g.prototype.multiplyTo=H,g.prototype.squareTo=X,g.prototype.divRemTo=J,g.prototype.invDigit=ee,g.prototype.isEven=w,g.prototype.exp=F,g.prototype.toString=L,g.prototype.negate=h,g.prototype.abs=n,g.prototype.compareTo=i,g.prototype.bitLength=V,g.prototype.mod=te,g.prototype.modPowInt=K,g.ZERO=p(0),g.ONE=p(1);function Y(){var A=v();return this.copyTo(A),A}function ie(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;else 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 oe(){return this.t==0?this.s:this.data[0]<<24>>24}function Q(){return this.t==0?this.s:this.data[0]<<16>>16}function ae(A){return Math.floor(Math.LN2*this.DB/Math.log(A))}function ue(){if(this.s<0)return-1;else if(this.t<=0||this.t==1&&this.data[0]<=0)return 0;else return 1}function ge(A){if(A==null)A=10;if(this.signum()==0||A<2||A>36)return"0";var k=this.chunkSize(A),x=Math.pow(A,k),j=p(x),z=v(),W=v(),ne="";this.divRemTo(j,z,W);while(z.signum()>0)ne=(x+W.intValue()).toString(A).substr(1)+ne,z.divRemTo(j,z,W);return W.intValue().toString(A)+ne}function he(A,k){if(this.fromInt(0),k==null)k=10;var x=this.chunkSize(k),j=Math.pow(k,x),z=!1,W=0,ne=0;for(var re=0;re<A.length;++re){var Ee=T(A,re);if(Ee<0){if(A.charAt(re)=="-"&&this.signum()==0)z=!0;continue}if(ne=k*ne+Ee,++W>=x)this.dMultiply(j),this.dAddOffset(ne,0),W=0,ne=0}if(W>0)this.dMultiply(Math.pow(k,W)),this.dAddOffset(ne,0);if(z)g.ZERO.subTo(this,this)}function be(A,k,x){if(typeof k=="number")if(A<2)this.fromInt(1);else{if(this.fromNumber(A,x),!this.testBit(A-1))this.bitwiseTo(g.ONE.shiftLeft(A-1),De,this);if(this.isEven())this.dAddOffset(1,0);while(!this.isProbablePrime(k))if(this.dAddOffset(2,0),this.bitLength()>A)this.subTo(g.ONE.shiftLeft(A-1),this)}else{var j=new Array,z=A&7;if(j.length=(A>>3)+1,k.nextBytes(j),z>0)j[0]&=(1<<z)-1;else j[0]=0;this.fromString(j,256)}}function ke(){var A=this.t,k=new Array;k[0]=this.s;var x=this.DB-A*this.DB%8,j,z=0;if(A-- >0){if(x<this.DB&&(j=this.data[A]>>x)!=(this.s&this.DM)>>x)k[z++]=j|this.s<<this.DB-x;while(A>=0){if(x<8)j=(this.data[A]&(1<<x)-1)<<8-x,j|=this.data[--A]>>(x+=this.DB-8);else if(j=this.data[A]>>(x-=8)&255,x<=0)x+=this.DB,--A;if((j&128)!=0)j|=-256;if(z==0&&(this.s&128)!=(j&128))++z;if(z>0||j!=this.s)k[z++]=j}}return k}function we(A){return this.compareTo(A)==0}function Be(A){return this.compareTo(A)<0?this:A}function Se(A){return this.compareTo(A)>0?this:A}function Te(A,k,x){var j,z,W=Math.min(A.t,this.t);for(j=0;j<W;++j)x.data[j]=k(this.data[j],A.data[j]);if(A.t<this.t){z=A.s&this.DM;for(j=W;j<this.t;++j)x.data[j]=k(this.data[j],z);x.t=this.t}else{z=this.s&this.DM;for(j=W;j<A.t;++j)x.data[j]=k(z,A.data[j]);x.t=A.t}x.s=k(this.s,A.s),x.clamp()}function Le(A,k){return A&k}function We(A){var k=v();return this.bitwiseTo(A,Le,k),k}function De(A,k){return A|k}function Ze(A){var k=v();return this.bitwiseTo(A,De,k),k}function $e(A,k){return A^k}function Je(A){var k=v();return this.bitwiseTo(A,$e,k),k}function et(A,k){return A&~k}function at(A){var k=v();return this.bitwiseTo(A,et,k),k}function ut(){var A=v();for(var k=0;k<this.t;++k)A.data[k]=this.DM&~this.data[k];return A.t=this.t,A.s=~this.s,A}function ht(A){var k=v();if(A<0)this.rShiftTo(-A,k);else this.lShiftTo(A,k);return k}function gt(A){var k=v();if(A<0)this.lShiftTo(-A,k);else this.rShiftTo(A,k);return k}function Et(A){if(A==0)return-1;var k=0;if((A&65535)==0)A>>=16,k+=16;if((A&255)==0)A>>=8,k+=8;if((A&15)==0)A>>=4,k+=4;if((A&3)==0)A>>=2,k+=2;if((A&1)==0)++k;return k}function bt(){for(var A=0;A<this.t;++A)if(this.data[A]!=0)return A*this.DB+Et(this.data[A]);if(this.s<0)return this.t*this.DB;return-1}function Dt(A){var k=0;while(A!=0)A&=A-1,++k;return k}function jt(){var A=0,k=this.s&this.DM;for(var x=0;x<this.t;++x)A+=Dt(this.data[x]^k);return A}function Ue(A){var k=Math.floor(A/this.DB);if(k>=this.t)return this.s!=0;return(this.data[k]&1<<A%this.DB)!=0}function Ve(A,k){var x=g.ONE.shiftLeft(A);return this.bitwiseTo(x,k,x),x}function Pe(A){return this.changeBit(A,De)}function xe(A){return this.changeBit(A,et)}function Ke(A){return this.changeBit(A,$e)}function Oe(A,k){var x=0,j=0,z=Math.min(A.t,this.t);while(x<z)j+=this.data[x]+A.data[x],k.data[x++]=j&this.DM,j>>=this.DB;if(A.t<this.t){j+=A.s;while(x<this.t)j+=this.data[x],k.data[x++]=j&this.DM,j>>=this.DB;j+=this.s}else{j+=this.s;while(x<A.t)j+=A.data[x],k.data[x++]=j&this.DM,j>>=this.DB;j+=A.s}if(k.s=j<0?-1:0,j>0)k.data[x++]=j;else if(j<-1)k.data[x++]=this.DV+j;k.t=x,k.clamp()}function Me(A){var k=v();return this.addTo(A,k),k}function Fe(A){var k=v();return this.subTo(A,k),k}function je(A){var k=v();return this.multiplyTo(A,k),k}function Ge(A){var k=v();return this.divRemTo(A,k,null),k}function qe(A){var k=v();return this.divRemTo(A,null,k),k}function He(A){var k=v(),x=v();return this.divRemTo(A,k,x),new Array(k,x)}function Qe(A){this.data[this.t]=this.am(0,A-1,this,0,0,this.t),++this.t,this.clamp()}function ze(A,k){if(A==0)return;while(this.t<=k)this.data[this.t++]=0;this.data[k]+=A;while(this.data[k]>=this.DV){if(this.data[k]-=this.DV,++k>=this.t)this.data[this.t++]=0;++this.data[k]}}function Ne(){}function Re(A){return A}function pi(A,k,x){A.multiplyTo(k,x)}function di(A,k){A.squareTo(k)}Ne.prototype.convert=Re,Ne.prototype.revert=Re,Ne.prototype.mulTo=pi,Ne.prototype.sqrTo=di;function yi(A){return this.exp(A,new Ne)}function gi(A,k,x){var j=Math.min(this.t+A.t,k);x.s=0,x.t=j;while(j>0)x.data[--j]=0;var z;for(z=x.t-this.t;j<z;++j)x.data[j+this.t]=this.am(0,A.data[j],x,j,0,this.t);for(z=Math.min(A.t,k);j<z;++j)this.am(0,A.data[j],x,j,0,k-j);x.clamp()}function vi(A,k,x){--k;var j=x.t=this.t+A.t-k;x.s=0;while(--j>=0)x.data[j]=0;for(j=Math.max(k-this.t,0);j<A.t;++j)x.data[this.t+j-k]=this.am(k-j,A.data[j],x,0,0,this.t+j-k);x.clamp(),x.drShiftTo(1,x)}function Bt(A){this.r2=v(),this.q3=v(),g.ONE.dlShiftTo(2*A.t,this.r2),this.mu=this.r2.divide(A),this.m=A}function mi(A){if(A.s<0||A.t>2*this.m.t)return A.mod(this.m);else if(A.compareTo(this.m)<0)return A;else{var k=v();return A.copyTo(k),this.reduce(k),k}}function Ci(A){return A}function Ei(A){if(A.drShiftTo(this.m.t-1,this.r2),A.t>this.m.t+1)A.t=this.m.t+1,A.clamp();this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(A.compareTo(this.r2)<0)A.dAddOffset(1,this.m.t+1);A.subTo(this.r2,A);while(A.compareTo(this.m)>=0)A.subTo(this.m,A)}function Si(A,k){A.squareTo(k),this.reduce(k)}function Ti(A,k,x){A.multiplyTo(k,x),this.reduce(x)}Bt.prototype.convert=mi,Bt.prototype.revert=Ci,Bt.prototype.reduce=Ei,Bt.prototype.mulTo=Ti,Bt.prototype.sqrTo=Si;function Ii(A,k){var x=A.bitLength(),j,z=p(1),W;if(x<=0)return z;else if(x<18)j=1;else if(x<48)j=3;else if(x<144)j=4;else if(x<768)j=5;else j=6;if(x<8)W=new se(k);else if(k.isEven())W=new Bt(k);else W=new Ae(k);var ne=new Array,re=3,Ee=j-1,Ye=(1<<j)-1;if(ne[1]=W.convert(this),j>1){var rt=v();W.sqrTo(ne[1],rt);while(re<=Ye)ne[re]=v(),W.mulTo(rt,ne[re-2],ne[re]),re+=2}var tt=A.t-1,pt,Gt=!0,st=v(),ot;x=B(A.data[tt])-1;while(tt>=0){if(x>=Ee)pt=A.data[tt]>>x-Ee&Ye;else if(pt=(A.data[tt]&(1<<x+1)-1)<<Ee-x,tt>0)pt|=A.data[tt-1]>>this.DB+x-Ee;re=j;while((pt&1)==0)pt>>=1,--re;if((x-=re)<0)x+=this.DB,--tt;if(Gt)ne[pt].copyTo(z),Gt=!1;else{while(re>1)W.sqrTo(z,st),W.sqrTo(st,z),re-=2;if(re>0)W.sqrTo(z,st);else ot=z,z=st,st=ot;W.mulTo(st,ne[pt],z)}while(tt>=0&&(A.data[tt]&1<<x)==0)if(W.sqrTo(z,st),ot=z,z=st,st=ot,--x<0)x=this.DB-1,--tt}return W.revert(z)}function Ai(A){var k=this.s<0?this.negate():this.clone(),x=A.s<0?A.negate():A.clone();if(k.compareTo(x)<0){var j=k;k=x,x=j}var z=k.getLowestSetBit(),W=x.getLowestSetBit();if(W<0)return k;if(z<W)W=z;if(W>0)k.rShiftTo(W,k),x.rShiftTo(W,x);while(k.signum()>0){if((z=k.getLowestSetBit())>0)k.rShiftTo(z,k);if((z=x.getLowestSetBit())>0)x.rShiftTo(z,x);if(k.compareTo(x)>=0)k.subTo(x,k),k.rShiftTo(1,k);else x.subTo(k,x),x.rShiftTo(1,x)}if(W>0)x.lShiftTo(W,x);return x}function bi(A){if(A<=0)return 0;var k=this.DV%A,x=this.s<0?A-1:0;if(this.t>0)if(k==0)x=this.data[0]%A;else for(var j=this.t-1;j>=0;--j)x=(k*x+this.data[j])%A;return x}function Bi(A){var k=A.isEven();if(this.isEven()&&k||A.signum()==0)return g.ZERO;var x=A.clone(),j=this.clone(),z=p(1),W=p(0),ne=p(0),re=p(1);while(x.signum()!=0){while(x.isEven()){if(x.rShiftTo(1,x),k){if(!z.isEven()||!W.isEven())z.addTo(this,z),W.subTo(A,W);z.rShiftTo(1,z)}else if(!W.isEven())W.subTo(A,W);W.rShiftTo(1,W)}while(j.isEven()){if(j.rShiftTo(1,j),k){if(!ne.isEven()||!re.isEven())ne.addTo(this,ne),re.subTo(A,re);ne.rShiftTo(1,ne)}else if(!re.isEven())re.subTo(A,re);re.rShiftTo(1,re)}if(x.compareTo(j)>=0){if(x.subTo(j,x),k)z.subTo(ne,z);W.subTo(re,W)}else{if(j.subTo(x,j),k)ne.subTo(z,ne);re.subTo(W,re)}}if(j.compareTo(g.ONE)!=0)return g.ZERO;if(re.compareTo(A)>=0)return re.subtract(A);if(re.signum()<0)re.addTo(A,re);else return re;if(re.signum()<0)return re.add(A);else return re}var nt=[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],Ni=67108864/nt[nt.length-1];function wi(A){var k,x=this.abs();if(x.t==1&&x.data[0]<=nt[nt.length-1]){for(k=0;k<nt.length;++k)if(x.data[0]==nt[k])return!0;return!1}if(x.isEven())return!1;k=1;while(k<nt.length){var j=nt[k],z=k+1;while(z<nt.length&&j<Ni)j*=nt[z++];j=x.modInt(j);while(k<z)if(j%nt[k++]==0)return!1}return x.millerRabin(A)}function ki(A){var k=this.subtract(g.ONE),x=k.getLowestSetBit();if(x<=0)return!1;var j=k.shiftRight(x),z=Ri(),W;for(var ne=0;ne<A;++ne){do W=new g(this.bitLength(),z);while(W.compareTo(g.ONE)<=0||W.compareTo(k)>=0);var re=W.modPow(j,this);if(re.compareTo(g.ONE)!=0&&re.compareTo(k)!=0){var Ee=1;while(Ee++<x&&re.compareTo(k)!=0)if(re=re.modPowInt(2,this),re.compareTo(g.ONE)==0)return!1;if(re.compareTo(k)!=0)return!1}}return!0}function Ri(){return{nextBytes:function(A){for(var k=0;k<A.length;++k)A[k]=Math.floor(Math.random()*256)}}}g.prototype.chunkSize=ae,g.prototype.toRadix=ge,g.prototype.fromRadix=he,g.prototype.fromNumber=be,g.prototype.bitwiseTo=Te,g.prototype.changeBit=Ve,g.prototype.addTo=Oe,g.prototype.dMultiply=Qe,g.prototype.dAddOffset=ze,g.prototype.multiplyLowerTo=gi,g.prototype.multiplyUpperTo=vi,g.prototype.modInt=bi,g.prototype.millerRabin=ki,g.prototype.clone=Y,g.prototype.intValue=ie,g.prototype.byteValue=oe,g.prototype.shortValue=Q,g.prototype.signum=ue,g.prototype.toByteArray=ke,g.prototype.equals=we,g.prototype.min=Be,g.prototype.max=Se,g.prototype.and=We,g.prototype.or=Ze,g.prototype.xor=Je,g.prototype.andNot=at,g.prototype.not=ut,g.prototype.shiftLeft=ht,g.prototype.shiftRight=gt,g.prototype.getLowestSetBit=bt,g.prototype.bitCount=jt,g.prototype.testBit=Ue,g.prototype.setBit=Pe,g.prototype.clearBit=xe,g.prototype.flipBit=Ke,g.prototype.add=Me,g.prototype.subtract=Fe,g.prototype.multiply=je,g.prototype.divide=Ge,g.prototype.remainder=qe,g.prototype.divideAndRemainder=He,g.prototype.modPow=Ii,g.prototype.modInverse=Bi,g.prototype.pow=yi,g.prototype.gcd=Ai,g.prototype.isProbablePrime=wi}),Mt=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.sha1=t.sha1||{};t.md.sha1=t.md.algorithms.sha1=e,e.create=function(){if(!d)g();var u=null,r=t.util.createBuffer(),m=new Array(80),f={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return f.start=function(){f.messageLength=0,f.fullMessageLength=f.messageLength64=[];var I=f.messageLengthSize/4;for(var U=0;U<I;++U)f.fullMessageLength.push(0);return r=t.util.createBuffer(),u={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},f},f.start(),f.update=function(I,U){if(U==="utf8")I=t.util.encodeUtf8(I);var S=I.length;f.messageLength+=S,S=[S/4294967296>>>0,S>>>0];for(var c=f.fullMessageLength.length-1;c>=0;--c)f.fullMessageLength[c]+=S[1],S[1]=S[0]+(f.fullMessageLength[c]/4294967296>>>0),f.fullMessageLength[c]=f.fullMessageLength[c]>>>0,S[0]=S[1]/4294967296>>>0;if(r.putBytes(I),v(u,m,r),r.read>2048||r.length()===0)r.compact();return f},f.digest=function(){var I=t.util.createBuffer();I.putBytes(r.bytes());var U=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize,S=U&f.blockLength-1;I.putBytes(a.substr(0,f.blockLength-S));var c,C,T=f.fullMessageLength[0]*8;for(var E=0;E<f.fullMessageLength.length-1;++E)c=f.fullMessageLength[E+1]*8,C=c/4294967296>>>0,T+=C,I.putInt32(T>>>0),T=c>>>0;I.putInt32(T);var s={h0:u.h0,h1:u.h1,h2:u.h2,h3:u.h3,h4:u.h4};v(s,m,I);var p=t.util.createBuffer();return p.putInt32(s.h0),p.putInt32(s.h1),p.putInt32(s.h2),p.putInt32(s.h3),p.putInt32(s.h4),p},f};var a=null,d=!1;function g(){a=String.fromCharCode(128),a+=t.util.fillString(String.fromCharCode(0),64),d=!0}function v(u,r,m){var f,I,U,S,c,C,T,E,s=m.length();while(s>=64){I=u.h0,U=u.h1,S=u.h2,c=u.h3,C=u.h4;for(E=0;E<16;++E)f=m.getInt32(),r[E]=f,T=c^U&(S^c),f=(I<<5|I>>>27)+T+C+1518500249+f,C=c,c=S,S=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<20;++E)f=r[E-3]^r[E-8]^r[E-14]^r[E-16],f=f<<1|f>>>31,r[E]=f,T=c^U&(S^c),f=(I<<5|I>>>27)+T+C+1518500249+f,C=c,c=S,S=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<32;++E)f=r[E-3]^r[E-8]^r[E-14]^r[E-16],f=f<<1|f>>>31,r[E]=f,T=U^S^c,f=(I<<5|I>>>27)+T+C+1859775393+f,C=c,c=S,S=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<40;++E)f=r[E-6]^r[E-16]^r[E-28]^r[E-32],f=f<<2|f>>>30,r[E]=f,T=U^S^c,f=(I<<5|I>>>27)+T+C+1859775393+f,C=c,c=S,S=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<60;++E)f=r[E-6]^r[E-16]^r[E-28]^r[E-32],f=f<<2|f>>>30,r[E]=f,T=U&S|c&(U^S),f=(I<<5|I>>>27)+T+C+2400959708+f,C=c,c=S,S=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<80;++E)f=r[E-6]^r[E-16]^r[E-28]^r[E-32],f=f<<2|f>>>30,r[E]=f,T=U^S^c,f=(I<<5|I>>>27)+T+C+3395469782+f,C=c,c=S,S=(U<<30|U>>>2)>>>0,U=I,I=f;u.h0=u.h0+I|0,u.h1=u.h1+U|0,u.h2=u.h2+S|0,u.h3=u.h3+c|0,u.h4=u.h4+C|0,s-=64}}}),qr=le((N,_)=>{var t=pe();Ce(),ct(),Mt();var e=_.exports=t.pkcs1=t.pkcs1||{};e.encode_rsa_oaep=function(d,g,v){var u,r,m,f;if(typeof v==="string")u=v,r=arguments[3]||void 0,m=arguments[4]||void 0;else if(v){if(u=v.label||void 0,r=v.seed||void 0,m=v.md||void 0,v.mgf1&&v.mgf1.md)f=v.mgf1.md}if(!m)m=t.md.sha1.create();else m.start();if(!f)f=m;var I=Math.ceil(d.n.bitLength()/8),U=I-2*m.digestLength-2;if(g.length>U){var S=new Error("RSAES-OAEP input message length is too long.");throw S.length=g.length,S.maxLength=U,S}if(!u)u="";m.update(u,"raw");var c=m.digest(),C="",T=U-g.length;for(var E=0;E<T;E++)C+="\x00";var s=c.getBytes()+C+"\x01"+g;if(!r)r=t.random.getBytes(m.digestLength);else if(r.length!==m.digestLength){var S=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw S.seedLength=r.length,S.digestLength=m.digestLength,S}var p=a(r,I-m.digestLength-1,f),y=t.util.xorBytes(s,p,s.length),b=a(y,m.digestLength,f),L=t.util.xorBytes(r,b,r.length);return"\x00"+L+y},e.decode_rsa_oaep=function(d,g,v){var u,r,m;if(typeof v==="string")u=v,r=arguments[3]||void 0;else if(v){if(u=v.label||void 0,r=v.md||void 0,v.mgf1&&v.mgf1.md)m=v.mgf1.md}var f=Math.ceil(d.n.bitLength()/8);if(g.length!==f){var y=new Error("RSAES-OAEP encoded message length is invalid.");throw y.length=g.length,y.expectedLength=f,y}if(r===void 0)r=t.md.sha1.create();else r.start();if(!m)m=r;if(f<2*r.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");if(!u)u="";r.update(u,"raw");var I=r.digest().getBytes(),U=g.charAt(0),S=g.substring(1,r.digestLength+1),c=g.substring(1+r.digestLength),C=a(c,r.digestLength,m),T=t.util.xorBytes(S,C,S.length),E=a(T,f-r.digestLength-1,m),s=t.util.xorBytes(c,E,c.length),p=s.substring(0,r.digestLength),y=U!=="\x00";for(var b=0;b<r.digestLength;++b)y|=I.charAt(b)!==p.charAt(b);var L=1,h=r.digestLength;for(var n=r.digestLength;n<s.length;n++){var i=s.charCodeAt(n),B=i&1^1,V=L?65534:0;y|=i&V,L=L&B,h+=L}if(y||s.charCodeAt(h)!==1)throw new Error("Invalid RSAES-OAEP padding.");return s.substring(h+1)};function a(d,g,v){if(!v)v=t.md.sha1.create();var u="",r=Math.ceil(g/v.digestLength);for(var m=0;m<r;++m){var f=String.fromCharCode(m>>24&255,m>>16&255,m>>8&255,m&255);v.start(),v.update(d+f),u+=v.digest().getBytes()}return u.substring(0,g)}}),Hr=le((N,_)=>{var t=pe();Ce(),Xt(),ct(),function(){if(t.prime){_.exports=t.prime;return}var e=_.exports=t.prime=t.prime||{},a=t.jsbn.BigInteger,d=[6,4,2,4,2,4,6,2],g=new a(null);g.fromInt(30);var v=function(S,c){return S|c};e.generateProbablePrime=function(S,c,C){if(typeof c==="function")C=c,c={};c=c||{};var T=c.algorithm||"PRIMEINC";if(typeof T==="string")T={name:T};T.options=T.options||{};var E=c.prng||t.random,s={nextBytes:function(p){var y=E.getBytesSync(p.length);for(var b=0;b<p.length;++b)p[b]=y.charCodeAt(b)}};if(T.name==="PRIMEINC")return u(S,s,T.options,C);throw new Error("Invalid prime generation algorithm: "+T.name)};function u(S,c,C,T){if("workers"in C)return f(S,c,C,T);return r(S,c,C,T)}function r(S,c,C,T){var E=I(S,c),s=0,p=U(E.bitLength());if("millerRabinTests"in C)p=C.millerRabinTests;var y=10;if("maxBlockTime"in C)y=C.maxBlockTime;m(E,S,c,s,p,y,T)}function m(S,c,C,T,E,s,p){var y=+new Date;do{if(S.bitLength()>c)S=I(c,C);if(S.isProbablePrime(E))return p(null,S);S.dAddOffset(d[T++%8],0)}while(s<0||+new Date-y<s);t.util.setImmediate(function(){m(S,c,C,T,E,s,p)})}function f(S,c,C,T){if(typeof Worker==="undefined")return r(S,c,C,T);var E=I(S,c),s=C.workers,p=C.workLoad||100,y=p*30/8,b=C.workerScript||"forge/prime.worker.js";if(s===-1)return t.util.estimateCores(function(h,n){if(h)n=2;s=n-1,L()});L();function L(){s=Math.max(1,s);var h=[];for(var n=0;n<s;++n)h[n]=new Worker(b);var i=s;for(var n=0;n<s;++n)h[n].addEventListener("message",V);var B=!1;function V(O){if(B)return;--i;var P=O.data;if(P.found){for(var M=0;M<h.length;++M)h[M].terminate();return B=!0,T(null,new a(P.prime,16))}if(E.bitLength()>S)E=I(S,c);var G=E.toString(16);O.target.postMessage({hex:G,workLoad:p}),E.dAddOffset(y,0)}}}function I(S,c){var C=new a(S,c),T=S-1;if(!C.testBit(T))C.bitwiseTo(a.ONE.shiftLeft(T),v,C);return C.dAddOffset(31-C.mod(g).byteValue(),0),C}function U(S){if(S<=100)return 27;if(S<=150)return 18;if(S<=200)return 15;if(S<=250)return 12;if(S<=300)return 9;if(S<=350)return 8;if(S<=400)return 7;if(S<=500)return 6;if(S<=600)return 5;if(S<=800)return 4;if(S<=1250)return 3;return 2}}()}),Wt=le((N,_)=>{var t=pe();if(lt(),Xt(),It(),qr(),Hr(),ct(),Ce(),typeof e==="undefined")e=t.jsbn.BigInteger;var e,a=t.util.isNodejs?zt("crypto"):null,d=t.asn1,g=t.util;t.pki=t.pki||{},_.exports=t.pki.rsa=t.rsa=t.rsa||{};var v=t.pki,u=[6,4,2,4,2,4,6,2],r={name:"PrivateKeyInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},m={name:"RSAPrivateKey",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},f={name:"RSAPublicKey",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},I=t.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},U={name:"DigestInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:d.Class.UNIVERSAL,type:d.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:d.Class.UNIVERSAL,type:d.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},S=function(n){var i;if(n.algorithm in v.oids)i=v.oids[n.algorithm];else{var B=new Error("Unknown message digest algorithm.");throw B.algorithm=n.algorithm,B}var V=d.oidToDer(i).getBytes(),O=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),P=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);P.value.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,V)),P.value.push(d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,""));var M=d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,n.digest().getBytes());return O.value.push(P),O.value.push(M),d.toDer(O).getBytes()},c=function(n,i,B){if(B)return n.modPow(i.e,i.n);if(!i.p||!i.q)return n.modPow(i.d,i.n);if(!i.dP)i.dP=i.d.mod(i.p.subtract(e.ONE));if(!i.dQ)i.dQ=i.d.mod(i.q.subtract(e.ONE));if(!i.qInv)i.qInv=i.q.modInverse(i.p);var V;do V=new e(t.util.bytesToHex(t.random.getBytes(i.n.bitLength()/8)),16);while(V.compareTo(i.n)>=0||!V.gcd(i.n).equals(e.ONE));n=n.multiply(V.modPow(i.e,i.n)).mod(i.n);var O=n.mod(i.p).modPow(i.dP,i.p),P=n.mod(i.q).modPow(i.dQ,i.q);while(O.compareTo(P)<0)O=O.add(i.p);var M=O.subtract(P).multiply(i.qInv).mod(i.p).multiply(i.q).add(P);return M=M.multiply(V.modInverse(i.n)).mod(i.n),M};v.rsa.encrypt=function(n,i,B){var V=B,O,P=Math.ceil(i.n.bitLength()/8);if(B!==!1&&B!==!0)V=B===2,O=C(n,i,B);else O=t.util.createBuffer(),O.putBytes(n);var M=new e(O.toHex(),16),G=c(M,i,V),q=G.toString(16),H=t.util.createBuffer(),X=P-Math.ceil(q.length/2);while(X>0)H.putByte(0),--X;return H.putBytes(t.util.hexToBytes(q)),H.getBytes()},v.rsa.decrypt=function(n,i,B,V){var O=Math.ceil(i.n.bitLength()/8);if(n.length!==O){var P=new Error("Encrypted message length is invalid.");throw P.length=n.length,P.expected=O,P}var M=new e(t.util.createBuffer(n).toHex(),16);if(M.compareTo(i.n)>=0)throw new Error("Encrypted message is invalid.");var G=c(M,i,B),q=G.toString(16),H=t.util.createBuffer(),X=O-Math.ceil(q.length/2);while(X>0)H.putByte(0),--X;if(H.putBytes(t.util.hexToBytes(q)),V!==!1)return T(H.getBytes(),i,B);return H.getBytes()},v.rsa.createKeyPairGenerationState=function(n,i,B){if(typeof n==="string")n=parseInt(n,10);n=n||2048,B=B||{};var V=B.prng||t.random,O={nextBytes:function(G){var q=V.getBytesSync(G.length);for(var H=0;H<G.length;++H)G[H]=q.charCodeAt(H)}},P=B.algorithm||"PRIMEINC",M;if(P==="PRIMEINC")M={algorithm:P,state:0,bits:n,rng:O,eInt:i||65537,e:new e(null),p:null,q:null,qBits:n>>1,pBits:n-(n>>1),pqState:0,num:null,keys:null},M.e.fromInt(M.eInt);else throw new Error("Invalid key generation algorithm: "+P);return M},v.rsa.stepKeyPairGenerationState=function(n,i){if(!("algorithm"in n))n.algorithm="PRIMEINC";var B=new e(null);B.fromInt(30);var V=0,O=function(J,te){return J|te},P=+new Date,M,G=0;while(n.keys===null&&(i<=0||G<i)){if(n.state===0){var q=n.p===null?n.pBits:n.qBits,H=q-1;if(n.pqState===0){if(n.num=new e(q,n.rng),!n.num.testBit(H))n.num.bitwiseTo(e.ONE.shiftLeft(H),O,n.num);n.num.dAddOffset(31-n.num.mod(B).byteValue(),0),V=0,++n.pqState}else if(n.pqState===1)if(n.num.bitLength()>q)n.pqState=0;else if(n.num.isProbablePrime(p(n.num.bitLength())))++n.pqState;else n.num.dAddOffset(u[V++%8],0);else if(n.pqState===2)n.pqState=n.num.subtract(e.ONE).gcd(n.e).compareTo(e.ONE)===0?3:0;else if(n.pqState===3){if(n.pqState=0,n.p===null)n.p=n.num;else n.q=n.num;if(n.p!==null&&n.q!==null)++n.state;n.num=null}}else if(n.state===1){if(n.p.compareTo(n.q)<0)n.num=n.p,n.p=n.q,n.q=n.num;++n.state}else if(n.state===2)n.p1=n.p.subtract(e.ONE),n.q1=n.q.subtract(e.ONE),n.phi=n.p1.multiply(n.q1),++n.state;else if(n.state===3)if(n.phi.gcd(n.e).compareTo(e.ONE)===0)++n.state;else n.p=null,n.q=null,n.state=0;else if(n.state===4)if(n.n=n.p.multiply(n.q),n.n.bitLength()===n.bits)++n.state;else n.q=null,n.state=0;else if(n.state===5){var X=n.e.modInverse(n.phi);n.keys={privateKey:v.rsa.setPrivateKey(n.n,n.e,X,n.p,n.q,X.mod(n.p1),X.mod(n.q1),n.q.modInverse(n.p)),publicKey:v.rsa.setPublicKey(n.n,n.e)}}M=+new Date,G+=M-P,P=M}return n.keys!==null},v.rsa.generateKeyPair=function(n,i,B,V){if(arguments.length===1){if(typeof n==="object")B=n,n=void 0;else if(typeof n==="function")V=n,n=void 0}else if(arguments.length===2)if(typeof n==="number"){if(typeof i==="function")V=i,i=void 0;else if(typeof i!=="number")B=i,i=void 0}else B=n,V=i,n=void 0,i=void 0;else if(arguments.length===3)if(typeof i==="number"){if(typeof B==="function")V=B,B=void 0}else V=B,B=i,i=void 0;if(B=B||{},n===void 0)n=B.bits||2048;if(i===void 0)i=B.e||65537;if(!t.options.usePureJavaScript&&!B.prng&&n>=256&&n<=16384&&(i===65537||i===3)){if(V){if(y("generateKeyPair"))return a.generateKeyPair("rsa",{modulusLength:n,publicExponent:i,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(G,q,H){if(G)return V(G);V(null,{privateKey:v.privateKeyFromPem(H),publicKey:v.publicKeyFromPem(q)})});if(b("generateKey")&&b("exportKey"))return g.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:n,publicExponent:h(i),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(G){return g.globalScope.crypto.subtle.exportKey("pkcs8",G.privateKey)}).then(void 0,function(G){V(G)}).then(function(G){if(G){var q=v.privateKeyFromAsn1(d.fromDer(t.util.createBuffer(G)));V(null,{privateKey:q,publicKey:v.setRsaPublicKey(q.n,q.e)})}});if(L("generateKey")&&L("exportKey")){var O=g.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:n,publicExponent:h(i),hash:{name:"SHA-256"}},!0,["sign","verify"]);O.oncomplete=function(G){var q=G.target.result,H=g.globalScope.msCrypto.subtle.exportKey("pkcs8",q.privateKey);H.oncomplete=function(X){var J=X.target.result,te=v.privateKeyFromAsn1(d.fromDer(t.util.createBuffer(J)));V(null,{privateKey:te,publicKey:v.setRsaPublicKey(te.n,te.e)})},H.onerror=function(X){V(X)}},O.onerror=function(G){V(G)};return}}else if(y("generateKeyPairSync")){var P=a.generateKeyPairSync("rsa",{modulusLength:n,publicExponent:i,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:v.privateKeyFromPem(P.privateKey),publicKey:v.publicKeyFromPem(P.publicKey)}}}var M=v.rsa.createKeyPairGenerationState(n,i,B);if(!V)return v.rsa.stepKeyPairGenerationState(M,0),M.keys;E(M,B,V)},v.setRsaPublicKey=v.rsa.setPublicKey=function(n,i){var B={n,e:i};return B.encrypt=function(V,O,P){if(typeof O==="string")O=O.toUpperCase();else if(O===void 0)O="RSAES-PKCS1-V1_5";if(O==="RSAES-PKCS1-V1_5")O={encode:function(G,q,H){return C(G,q,2).getBytes()}};else if(O==="RSA-OAEP"||O==="RSAES-OAEP")O={encode:function(G,q){return t.pkcs1.encode_rsa_oaep(q,G,P)}};else if(["RAW","NONE","NULL",null].indexOf(O)!==-1)O={encode:function(G){return G}};else if(typeof O==="string")throw new Error('Unsupported encryption scheme: "'+O+'".');var M=O.encode(V,B,!0);return v.rsa.encrypt(M,B,!0)},B.verify=function(V,O,P,M){if(typeof P==="string")P=P.toUpperCase();else if(P===void 0)P="RSASSA-PKCS1-V1_5";if(M===void 0)M={_parseAllDigestBytes:!0};if(!("_parseAllDigestBytes"in M))M._parseAllDigestBytes=!0;if(P==="RSASSA-PKCS1-V1_5")P={verify:function(q,H){H=T(H,B,!0);var X=d.fromDer(H,{parseAllBytes:M._parseAllDigestBytes}),J={},te=[];if(!d.validate(X,U,J,te)){var se=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw se.errors=te,se}var fe=d.derToOid(J.algorithmIdentifier);if(!(fe===t.oids.md2||fe===t.oids.md5||fe===t.oids.sha1||fe===t.oids.sha224||fe===t.oids.sha256||fe===t.oids.sha384||fe===t.oids.sha512||fe===t.oids["sha512-224"]||fe===t.oids["sha512-256"])){var se=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw se.oid=fe,se}if(fe===t.oids.md2||fe===t.oids.md5){if(!("parameters"in J))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.")}return q===J.digest}};else if(P==="NONE"||P==="NULL"||P===null)P={verify:function(q,H){return H=T(H,B,!0),q===H}};var G=v.rsa.decrypt(O,B,!0,!1);return P.verify(V,G,B.n.bitLength())},B},v.setRsaPrivateKey=v.rsa.setPrivateKey=function(n,i,B,V,O,P,M,G){var q={n,e:i,d:B,p:V,q:O,dP:P,dQ:M,qInv:G};return q.decrypt=function(H,X,J){if(typeof X==="string")X=X.toUpperCase();else if(X===void 0)X="RSAES-PKCS1-V1_5";var te=v.rsa.decrypt(H,q,!1,!1);if(X==="RSAES-PKCS1-V1_5")X={decode:T};else if(X==="RSA-OAEP"||X==="RSAES-OAEP")X={decode:function(se,fe){return t.pkcs1.decode_rsa_oaep(fe,se,J)}};else if(["RAW","NONE","NULL",null].indexOf(X)!==-1)X={decode:function(se){return se}};else throw new Error('Unsupported encryption scheme: "'+X+'".');return X.decode(te,q,!1)},q.sign=function(H,X){var J=!1;if(typeof X==="string")X=X.toUpperCase();if(X===void 0||X==="RSASSA-PKCS1-V1_5")X={encode:S},J=1;else if(X==="NONE"||X==="NULL"||X===null)X={encode:function(){return H}},J=1;var te=X.encode(H,q.n.bitLength());return v.rsa.encrypt(te,q,J)},q},v.wrapRsaPrivateKey=function(n){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(0).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(v.oids.rsaEncryption).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")]),d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,d.toDer(n).getBytes())])},v.privateKeyFromAsn1=function(n){var i={},B=[];if(d.validate(n,r,i,B))n=d.fromDer(t.util.createBuffer(i.privateKey));if(i={},B=[],!d.validate(n,m,i,B)){var V=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw V.errors=B,V}var O,P,M,G,q,H,X,J;return O=t.util.createBuffer(i.privateKeyModulus).toHex(),P=t.util.createBuffer(i.privateKeyPublicExponent).toHex(),M=t.util.createBuffer(i.privateKeyPrivateExponent).toHex(),G=t.util.createBuffer(i.privateKeyPrime1).toHex(),q=t.util.createBuffer(i.privateKeyPrime2).toHex(),H=t.util.createBuffer(i.privateKeyExponent1).toHex(),X=t.util.createBuffer(i.privateKeyExponent2).toHex(),J=t.util.createBuffer(i.privateKeyCoefficient).toHex(),v.setRsaPrivateKey(new e(O,16),new e(P,16),new e(M,16),new e(G,16),new e(q,16),new e(H,16),new e(X,16),new e(J,16))},v.privateKeyToAsn1=v.privateKeyToRSAPrivateKey=function(n){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(0).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.n)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.e)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.d)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.p)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.q)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.dP)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.dQ)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.qInv))])},v.publicKeyFromAsn1=function(n){var i={},B=[];if(d.validate(n,I,i,B)){var V=d.derToOid(i.publicKeyOid);if(V!==v.oids.rsaEncryption){var O=new Error("Cannot read public key. Unknown OID.");throw O.oid=V,O}n=i.rsaPublicKey}if(B=[],!d.validate(n,f,i,B)){var O=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw O.errors=B,O}var P=t.util.createBuffer(i.publicKeyModulus).toHex(),M=t.util.createBuffer(i.publicKeyExponent).toHex();return v.setRsaPublicKey(new e(P,16),new e(M,16))},v.publicKeyToAsn1=v.publicKeyToSubjectPublicKeyInfo=function(n){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(v.oids.rsaEncryption).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,[v.publicKeyToRSAPublicKey(n)])])},v.publicKeyToRSAPublicKey=function(n){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.n)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,s(n.e))])};function C(n,i,B){var V=t.util.createBuffer(),O=Math.ceil(i.n.bitLength()/8);if(n.length>O-11){var P=new Error("Message is too long for PKCS#1 v1.5 padding.");throw P.length=n.length,P.max=O-11,P}V.putByte(0),V.putByte(B);var M=O-3-n.length,G;if(B===0||B===1){G=B===0?0:255;for(var q=0;q<M;++q)V.putByte(G)}else while(M>0){var H=0,X=t.random.getBytes(M);for(var q=0;q<M;++q)if(G=X.charCodeAt(q),G===0)++H;else V.putByte(G);M=H}return V.putByte(0),V.putBytes(n),V}function T(n,i,B,V){var O=Math.ceil(i.n.bitLength()/8),P=t.util.createBuffer(n),M=P.getByte(),G=P.getByte();if(M!==0||B&&G!==0&&G!==1||!B&&G!=2||B&&G===0&&typeof V==="undefined")throw new Error("Encryption block is invalid.");var q=0;if(G===0){q=O-3-V;for(var H=0;H<q;++H)if(P.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(G===1){q=0;while(P.length()>1){if(P.getByte()!==255){--P.read;break}++q}}else if(G===2){q=0;while(P.length()>1){if(P.getByte()===0){--P.read;break}++q}}var X=P.getByte();if(X!==0||q!==O-3-P.length())throw new Error("Encryption block is invalid.");return P.getBytes()}function E(n,i,B){if(typeof i==="function")B=i,i={};i=i||{};var V={algorithm:{name:i.algorithm||"PRIMEINC",options:{workers:i.workers||2,workLoad:i.workLoad||100,workerScript:i.workerScript}}};if("prng"in i)V.prng=i.prng;O();function O(){P(n.pBits,function(G,q){if(G)return B(G);if(n.p=q,n.q!==null)return M(G,n.q);P(n.qBits,M)})}function P(G,q){t.prime.generateProbablePrime(G,V,q)}function M(G,q){if(G)return B(G);if(n.q=q,n.p.compareTo(n.q)<0){var H=n.p;n.p=n.q,n.q=H}if(n.p.subtract(e.ONE).gcd(n.e).compareTo(e.ONE)!==0){n.p=null,O();return}if(n.q.subtract(e.ONE).gcd(n.e).compareTo(e.ONE)!==0){n.q=null,P(n.qBits,M);return}if(n.p1=n.p.subtract(e.ONE),n.q1=n.q.subtract(e.ONE),n.phi=n.p1.multiply(n.q1),n.phi.gcd(n.e).compareTo(e.ONE)!==0){n.p=n.q=null,O();return}if(n.n=n.p.multiply(n.q),n.n.bitLength()!==n.bits){n.q=null,P(n.qBits,M);return}var X=n.e.modInverse(n.phi);n.keys={privateKey:v.rsa.setPrivateKey(n.n,n.e,X,n.p,n.q,X.mod(n.p1),X.mod(n.q1),n.q.modInverse(n.p)),publicKey:v.rsa.setPublicKey(n.n,n.e)},B(null,n.keys)}}function s(n){var i=n.toString(16);if(i[0]>="8")i="00"+i;var B=t.util.hexToBytes(i);if(B.length>1&&(B.charCodeAt(0)===0&&(B.charCodeAt(1)&128)===0||B.charCodeAt(0)===255&&(B.charCodeAt(1)&128)===128))return B.substr(1);return B}function p(n){if(n<=100)return 27;if(n<=150)return 18;if(n<=200)return 15;if(n<=250)return 12;if(n<=300)return 9;if(n<=350)return 8;if(n<=400)return 7;if(n<=500)return 6;if(n<=600)return 5;if(n<=800)return 4;if(n<=1250)return 3;return 2}function y(n){return t.util.isNodejs&&typeof a[n]==="function"}function b(n){return typeof g.globalScope!=="undefined"&&typeof g.globalScope.crypto==="object"&&typeof g.globalScope.crypto.subtle==="object"&&typeof g.globalScope.crypto.subtle[n]==="function"}function L(n){return typeof g.globalScope!=="undefined"&&typeof g.globalScope.msCrypto==="object"&&typeof g.globalScope.msCrypto.subtle==="object"&&typeof g.globalScope.msCrypto.subtle[n]==="function"}function h(n){var i=t.util.hexToBytes(n.toString(16)),B=new Uint8Array(i.length);for(var V=0;V<i.length;++V)B[V]=i.charCodeAt(V);return B}}),Qr=le((N,_)=>{var t=pe();if(Tt(),lt(),Yt(),yt(),It(),fr(),Rt(),ct(),Gr(),Wt(),Ce(),typeof e==="undefined")e=t.jsbn.BigInteger;var e,a=t.asn1,d=t.pki=t.pki||{};_.exports=d.pbe=t.pbe=t.pbe||{};var g=d.oids,v={name:"EncryptedPrivateKeyInfo",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",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:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},u={name:"PBES2Algorithms",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},r={name:"pkcs-12PbeParams",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"iterations"}]};d.encryptPrivateKeyInfo=function(S,c,C){C=C||{},C.saltSize=C.saltSize||8,C.count=C.count||2048,C.algorithm=C.algorithm||"aes128",C.prfAlgorithm=C.prfAlgorithm||"sha1";var T=t.random.getBytesSync(C.saltSize),E=C.count,s=a.integerToDer(E),p,y,b;if(C.algorithm.indexOf("aes")===0||C.algorithm==="des"){var L,h,n;switch(C.algorithm){case"aes128":p=16,L=16,h=g["aes128-CBC"],n=t.aes.createEncryptionCipher;break;case"aes192":p=24,L=16,h=g["aes192-CBC"],n=t.aes.createEncryptionCipher;break;case"aes256":p=32,L=16,h=g["aes256-CBC"],n=t.aes.createEncryptionCipher;break;case"des":p=8,L=8,h=g.desCBC,n=t.des.createEncryptionCipher;break;default:var i=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw i.algorithm=C.algorithm,i}var B="hmacWith"+C.prfAlgorithm.toUpperCase(),V=I(B),O=t.pkcs5.pbkdf2(c,T,E,p,V),P=t.random.getBytesSync(L),M=n(O);M.start(P),M.update(a.toDer(S)),M.finish(),b=M.output.getBytes();var G=U(T,s,p,B);y=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(g.pkcs5PBES2).getBytes()),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(g.pkcs5PBKDF2).getBytes()),G]),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(h).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,P)])])])}else if(C.algorithm==="3des"){p=24;var q=new t.util.ByteBuffer(T),O=d.pbe.generatePkcs12Key(c,q,1,E,p),P=d.pbe.generatePkcs12Key(c,q,2,E,p),M=t.des.createEncryptionCipher(O);M.start(P),M.update(a.toDer(S)),M.finish(),b=M.output.getBytes(),y=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(g["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,T),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,s.getBytes())])])}else{var i=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw i.algorithm=C.algorithm,i}var H=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[y,a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,b)]);return H},d.decryptPrivateKeyInfo=function(S,c){var C=null,T={},E=[];if(!a.validate(S,v,T,E)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=E,s}var p=a.derToOid(T.encryptionOid),y=d.pbe.getCipher(p,T.encryptionParams,c),b=t.util.createBuffer(T.encryptedData);if(y.update(b),y.finish())C=a.fromDer(y.output);return C},d.encryptedPrivateKeyToPem=function(S,c){var C={type:"ENCRYPTED PRIVATE KEY",body:a.toDer(S).getBytes()};return t.pem.encode(C,{maxline:c})},d.encryptedPrivateKeyFromPem=function(S){var c=t.pem.decode(S)[0];if(c.type!=="ENCRYPTED PRIVATE KEY"){var C=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw C.headerType=c.type,C}if(c.procType&&c.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return a.fromDer(c.body)},d.encryptRsaPrivateKey=function(S,c,C){if(C=C||{},!C.legacy){var T=d.wrapRsaPrivateKey(d.privateKeyToAsn1(S));return T=d.encryptPrivateKeyInfo(T,c,C),d.encryptedPrivateKeyToPem(T)}var E,s,p,y;switch(C.algorithm){case"aes128":E="AES-128-CBC",p=16,s=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"aes192":E="AES-192-CBC",p=24,s=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"aes256":E="AES-256-CBC",p=32,s=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"3des":E="DES-EDE3-CBC",p=24,s=t.random.getBytesSync(8),y=t.des.createEncryptionCipher;break;case"des":E="DES-CBC",p=8,s=t.random.getBytesSync(8),y=t.des.createEncryptionCipher;break;default:var b=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+C.algorithm+'".');throw b.algorithm=C.algorithm,b}var L=t.pbe.opensslDeriveBytes(c,s.substr(0,8),p),h=y(L);h.start(s),h.update(a.toDer(d.privateKeyToAsn1(S))),h.finish();var n={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:E,parameters:t.util.bytesToHex(s).toUpperCase()},body:h.output.getBytes()};return t.pem.encode(n)},d.decryptRsaPrivateKey=function(S,c){var C=null,T=t.pem.decode(S)[0];if(T.type!=="ENCRYPTED PRIVATE KEY"&&T.type!=="PRIVATE KEY"&&T.type!=="RSA PRIVATE KEY"){var E=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw E.headerType=E,E}if(T.procType&&T.procType.type==="ENCRYPTED"){var s,p;switch(T.dekInfo.algorithm){case"DES-CBC":s=8,p=t.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,p=t.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,p=t.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,p=t.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,p=t.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,p=function(n){return t.rc2.createDecryptionCipher(n,40)};break;case"RC2-64-CBC":s=8,p=function(n){return t.rc2.createDecryptionCipher(n,64)};break;case"RC2-128-CBC":s=16,p=function(n){return t.rc2.createDecryptionCipher(n,128)};break;default:var E=new Error('Could not decrypt private key; unsupported encryption algorithm "'+T.dekInfo.algorithm+'".');throw E.algorithm=T.dekInfo.algorithm,E}var y=t.util.hexToBytes(T.dekInfo.parameters),b=t.pbe.opensslDeriveBytes(c,y.substr(0,8),s),L=p(b);if(L.start(y),L.update(t.util.createBuffer(T.body)),L.finish())C=L.output.getBytes();else return C}else C=T.body;if(T.type==="ENCRYPTED PRIVATE KEY")C=d.decryptPrivateKeyInfo(a.fromDer(C),c);else C=a.fromDer(C);if(C!==null)C=d.privateKeyFromAsn1(C);return C},d.pbe.generatePkcs12Key=function(S,c,C,T,E,s){var p,y;if(typeof s==="undefined"||s===null){if(!("sha1"in t.md))throw new Error('"sha1" hash algorithm unavailable.');s=t.md.sha1.create()}var{digestLength:b,blockLength:L}=s,h=new t.util.ByteBuffer,n=new t.util.ByteBuffer;if(S!==null&&S!==void 0){for(y=0;y<S.length;y++)n.putInt16(S.charCodeAt(y));n.putInt16(0)}var i=n.length(),B=c.length(),V=new t.util.ByteBuffer;V.fillWithByte(C,L);var O=L*Math.ceil(B/L),P=new t.util.ByteBuffer;for(y=0;y<O;y++)P.putByte(c.at(y%B));var M=L*Math.ceil(i/L),G=new t.util.ByteBuffer;for(y=0;y<M;y++)G.putByte(n.at(y%i));var q=P;q.putBuffer(G);var H=Math.ceil(E/b);for(var X=1;X<=H;X++){var J=new t.util.ByteBuffer;J.putBytes(V.bytes()),J.putBytes(q.bytes());for(var te=0;te<T;te++)s.start(),s.update(J.getBytes()),J=s.digest();var se=new t.util.ByteBuffer;for(y=0;y<L;y++)se.putByte(J.at(y%b));var fe=Math.ceil(B/L)+Math.ceil(i/L),ve=new t.util.ByteBuffer;for(p=0;p<fe;p++){var Ie=new t.util.ByteBuffer(q.getBytes(L)),Z=511;for(y=se.length()-1;y>=0;y--)Z=Z>>8,Z+=se.at(y)+Ie.at(y),Ie.setAt(y,Z&255);ve.putBuffer(Ie)}q=ve,h.putBuffer(J)}return h.truncate(h.length()-E),h},d.pbe.getCipher=function(S,c,C){switch(S){case d.oids.pkcs5PBES2:return d.pbe.getCipherForPBES2(S,c,C);case d.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case d.oids["pbewithSHAAnd40BitRC2-CBC"]:return d.pbe.getCipherForPKCS12PBE(S,c,C);default:var T=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw T.oid=S,T.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],T}},d.pbe.getCipherForPBES2=function(S,c,C){var T={},E=[];if(!a.validate(c,u,T,E)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=E,s}if(S=a.derToOid(T.kdfOid),S!==d.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=S,s.supportedOids=["pkcs5PBKDF2"],s}if(S=a.derToOid(T.encOid),S!==d.oids["aes128-CBC"]&&S!==d.oids["aes192-CBC"]&&S!==d.oids["aes256-CBC"]&&S!==d.oids["des-EDE3-CBC"]&&S!==d.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=S,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var p=T.kdfSalt,y=t.util.createBuffer(T.kdfIterationCount);y=y.getInt(y.length()<<3);var b,L;switch(d.oids[S]){case"aes128-CBC":b=16,L=t.aes.createDecryptionCipher;break;case"aes192-CBC":b=24,L=t.aes.createDecryptionCipher;break;case"aes256-CBC":b=32,L=t.aes.createDecryptionCipher;break;case"des-EDE3-CBC":b=24,L=t.des.createDecryptionCipher;break;case"desCBC":b=8,L=t.des.createDecryptionCipher;break}var h=f(T.prfOid),n=t.pkcs5.pbkdf2(C,p,y,b,h),i=T.encIv,B=L(n);return B.start(i),B},d.pbe.getCipherForPKCS12PBE=function(S,c,C){var T={},E=[];if(!a.validate(c,r,T,E)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=E,s}var p=t.util.createBuffer(T.salt),y=t.util.createBuffer(T.iterations);y=y.getInt(y.length()<<3);var b,L,h;switch(S){case d.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:b=24,L=8,h=t.des.startDecrypting;break;case d.oids["pbewithSHAAnd40BitRC2-CBC"]:b=5,L=8,h=function(O,P){var M=t.rc2.createDecryptionCipher(O,40);return M.start(P,null),M};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=S,s}var n=f(T.prfOid),i=d.pbe.generatePkcs12Key(C,p,1,y,b,n);n.start();var B=d.pbe.generatePkcs12Key(C,p,2,y,L,n);return h(i,B)},d.pbe.opensslDeriveBytes=function(S,c,C,T){if(typeof T==="undefined"||T===null){if(!("md5"in t.md))throw new Error('"md5" hash algorithm unavailable.');T=t.md.md5.create()}if(c===null)c="";var E=[m(T,S+c)];for(var s=16,p=1;s<C;++p,s+=16)E.push(m(T,E[p-1]+S+c));return E.join("").substr(0,C)};function m(S,c){return S.start().update(c).digest().getBytes()}function f(S){var c;if(!S)c="hmacWithSHA1";else if(c=d.oids[a.derToOid(S)],!c){var C=new Error("Unsupported PRF OID.");throw C.oid=S,C.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],C}return I(c)}function I(S){var c=t.md;switch(S){case"hmacWithSHA224":c=t.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":S=S.substr(8).toLowerCase();break;default:var C=new Error("Unsupported PRF algorithm.");throw C.algorithm=S,C.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],C}if(!c||!(S in c))throw new Error("Unknown hash algorithm: "+S);return c[S].create()}function U(S,c,C,T){var E=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,S),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,c.getBytes())]);if(T!=="hmacWithSHA1")E.value.push(a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,t.util.hexToBytes(C.toString(16))),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(d.oids[T]).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,"")]));return E}}),zr=le((N,_)=>{var t=pe();lt(),Ce();var e=t.asn1,a=_.exports=t.pkcs7asn1=t.pkcs7asn1||{};t.pkcs7=t.pkcs7||{},t.pkcs7.asn1=a;var d={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};a.contentInfoValidator=d;var g={name:"EncryptedContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};a.envelopedDataValidator={name:"EnvelopedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(g)},a.encryptedDataValidator={name:"EncryptedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"}].concat(g)};var v={name:"SignerInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};a.signedDataValidator={name:"SignedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},d,{name:"SignedData.Certificates",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,capture:"signerInfos",optional:!0,value:[v]}]},a.recipientInfoValidator={name:"RecipientInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}}),Yr=le((N,_)=>{var t=pe();Ce(),t.mgf=t.mgf||{};var e=_.exports=t.mgf.mgf1=t.mgf1=t.mgf1||{};e.create=function(a){var d={generate:function(g,v){var u=new t.util.ByteBuffer,r=Math.ceil(v/a.digestLength);for(var m=0;m<r;m++){var f=new t.util.ByteBuffer;f.putInt32(m),a.start(),a.update(g+f.getBytes()),u.putBuffer(a.digest())}return u.truncate(u.length()-v),u.getBytes()}};return d}}),Oi=le((N,_)=>{var t=pe();Yr(),_.exports=t.mgf=t.mgf||{},t.mgf.mgf1=t.mgf1}),hr=le((N,_)=>{var t=pe();ct(),Ce();var e=_.exports=t.pss=t.pss||{};e.create=function(a){if(arguments.length===3)a={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]};var{md:d,mgf:g}=a,v=d.digestLength,u=a.salt||null;if(typeof u==="string")u=t.util.createBuffer(u);var r;if("saltLength"in a)r=a.saltLength;else if(u!==null)r=u.length();else throw new Error("Salt length not specified or specific salt not given.");if(u!==null&&u.length()!==r)throw new Error("Given salt length does not match length of given salt.");var m=a.prng||t.random,f={};return f.encode=function(I,U){var S,c=U-1,C=Math.ceil(c/8),T=I.digest().getBytes();if(C<v+r+2)throw new Error("Message is too long to encrypt.");var E;if(u===null)E=m.getBytesSync(r);else E=u.bytes();var s=new t.util.ByteBuffer;s.fillWithByte(0,8),s.putBytes(T),s.putBytes(E),d.start(),d.update(s.getBytes());var p=d.digest().getBytes(),y=new t.util.ByteBuffer;y.fillWithByte(0,C-r-v-2),y.putByte(1),y.putBytes(E);var b=y.getBytes(),L=C-v-1,h=g.generate(p,L),n="";for(S=0;S<L;S++)n+=String.fromCharCode(b.charCodeAt(S)^h.charCodeAt(S));var i=65280>>8*C-c&255;return n=String.fromCharCode(n.charCodeAt(0)&~i)+n.substr(1),n+p+String.fromCharCode(188)},f.verify=function(I,U,S){var c,C=S-1,T=Math.ceil(C/8);if(U=U.substr(-T),T<v+r+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(U.charCodeAt(T-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var E=T-v-1,s=U.substr(0,E),p=U.substr(E,v),y=65280>>8*T-C&255;if((s.charCodeAt(0)&y)!==0)throw new Error("Bits beyond keysize not zero as expected.");var b=g.generate(p,E),L="";for(c=0;c<E;c++)L+=String.fromCharCode(s.charCodeAt(c)^b.charCodeAt(c));L=String.fromCharCode(L.charCodeAt(0)&~y)+L.substr(1);var h=T-v-r-2;for(c=0;c<h;c++)if(L.charCodeAt(c)!==0)throw new Error("Leftmost octets not zero as expected");if(L.charCodeAt(h)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var n=L.substr(-r),i=new t.util.ByteBuffer;i.fillWithByte(0,8),i.putBytes(I),i.putBytes(n),d.start(),d.update(i.getBytes());var B=d.digest().getBytes();return p===B},f}}),pr=le((N,_)=>{var t=pe();Tt(),lt(),Yt(),yt(),Oi(),It(),Rt(),hr(),Wt(),Ce();var e=t.asn1,a=_.exports=t.pki=t.pki||{},d=a.oids,g={};g.CN=d.commonName,g.commonName="CN",g.C=d.countryName,g.countryName="C",g.L=d.localityName,g.localityName="L",g.ST=d.stateOrProvinceName,g.stateOrProvinceName="ST",g.O=d.organizationName,g.organizationName="O",g.OU=d.organizationalUnitName,g.organizationalUnitName="OU",g.E=d.emailAddress,g.emailAddress="E";var v=t.pki.rsa.publicKeyValidator,u={name:"Certificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},v,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},r={name:"rsapss",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},m={name:"CertificationRequestInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},v,{name:"CertificationRequestInfo.attributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0}]}]}]},f={name:"CertificationRequest",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[m,{name:"CertificationRequest.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};a.RDNAttributesAsArray=function(h,n){var i=[],B,V,O;for(var P=0;P<h.value.length;++P){B=h.value[P];for(var M=0;M<B.value.length;++M){if(O={},V=B.value[M],O.type=e.derToOid(V.value[0].value),O.value=V.value[1].value,O.valueTagClass=V.value[1].type,O.type in d){if(O.name=d[O.type],O.name in g)O.shortName=g[O.name]}if(n)n.update(O.type),n.update(O.value);i.push(O)}}return i},a.CRIAttributesAsArray=function(h){var n=[];for(var i=0;i<h.length;++i){var B=h[i],V=e.derToOid(B.value[0].value),O=B.value[1].value;for(var P=0;P<O.length;++P){var M={};if(M.type=V,M.value=O[P].value,M.valueTagClass=O[P].type,M.type in d){if(M.name=d[M.type],M.name in g)M.shortName=g[M.name]}if(M.type===d.extensionRequest){M.extensions=[];for(var G=0;G<M.value.length;++G)M.extensions.push(a.certificateExtensionFromAsn1(M.value[G]))}n.push(M)}}return n};function I(h,n){if(typeof n==="string")n={shortName:n};var i=null,B;for(var V=0;i===null&&V<h.attributes.length;++V)if(B=h.attributes[V],n.type&&n.type===B.type)i=B;else if(n.name&&n.name===B.name)i=B;else if(n.shortName&&n.shortName===B.shortName)i=B;return i}var U=function(h,n,i){var B={};if(h!==d["RSASSA-PSS"])return B;if(i)B={hash:{algorithmOid:d.sha1},mgf:{algorithmOid:d.mgf1,hash:{algorithmOid:d.sha1}},saltLength:20};var V={},O=[];if(!e.validate(n,r,V,O)){var P=new Error("Cannot read RSASSA-PSS parameter block.");throw P.errors=O,P}if(V.hashOid!==void 0)B.hash=B.hash||{},B.hash.algorithmOid=e.derToOid(V.hashOid);if(V.maskGenOid!==void 0)B.mgf=B.mgf||{},B.mgf.algorithmOid=e.derToOid(V.maskGenOid),B.mgf.hash=B.mgf.hash||{},B.mgf.hash.algorithmOid=e.derToOid(V.maskGenHashOid);if(V.saltLength!==void 0)B.saltLength=V.saltLength.charCodeAt(0);return B},S=function(h){switch(d[h.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return t.md.sha1.create();case"md5WithRSAEncryption":return t.md.md5.create();case"sha256WithRSAEncryption":return t.md.sha256.create();case"sha384WithRSAEncryption":return t.md.sha384.create();case"sha512WithRSAEncryption":return t.md.sha512.create();case"RSASSA-PSS":return t.md.sha256.create();default:var n=new Error("Could not compute "+h.type+" digest. Unknown signature OID.");throw n.signatureOid=h.signatureOid,n}},c=function(h){var n=h.certificate,i;switch(n.signatureOid){case d.sha1WithRSAEncryption:case d.sha1WithRSASignature:break;case d["RSASSA-PSS"]:var B,V;if(B=d[n.signatureParameters.mgf.hash.algorithmOid],B===void 0||t.md[B]===void 0){var O=new Error("Unsupported MGF hash function.");throw O.oid=n.signatureParameters.mgf.hash.algorithmOid,O.name=B,O}if(V=d[n.signatureParameters.mgf.algorithmOid],V===void 0||t.mgf[V]===void 0){var O=new Error("Unsupported MGF function.");throw O.oid=n.signatureParameters.mgf.algorithmOid,O.name=V,O}if(V=t.mgf[V].create(t.md[B].create()),B=d[n.signatureParameters.hash.algorithmOid],B===void 0||t.md[B]===void 0){var O=new Error("Unsupported RSASSA-PSS hash function.");throw O.oid=n.signatureParameters.hash.algorithmOid,O.name=B,O}i=t.pss.create(t.md[B].create(),V,n.signatureParameters.saltLength);break}return n.publicKey.verify(h.md.digest().getBytes(),h.signature,i)};a.certificateFromPem=function(h,n,i){var B=t.pem.decode(h)[0];if(B.type!=="CERTIFICATE"&&B.type!=="X509 CERTIFICATE"&&B.type!=="TRUSTED CERTIFICATE"){var V=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw V.headerType=B.type,V}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var O=e.fromDer(B.body,i);return a.certificateFromAsn1(O,n)},a.certificateToPem=function(h,n){var i={type:"CERTIFICATE",body:e.toDer(a.certificateToAsn1(h)).getBytes()};return t.pem.encode(i,{maxline:n})},a.publicKeyFromPem=function(h){var n=t.pem.decode(h)[0];if(n.type!=="PUBLIC KEY"&&n.type!=="RSA PUBLIC KEY"){var i=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var B=e.fromDer(n.body);return a.publicKeyFromAsn1(B)},a.publicKeyToPem=function(h,n){var i={type:"PUBLIC KEY",body:e.toDer(a.publicKeyToAsn1(h)).getBytes()};return t.pem.encode(i,{maxline:n})},a.publicKeyToRSAPublicKeyPem=function(h,n){var i={type:"RSA PUBLIC KEY",body:e.toDer(a.publicKeyToRSAPublicKey(h)).getBytes()};return t.pem.encode(i,{maxline:n})},a.getPublicKeyFingerprint=function(h,n){n=n||{};var i=n.md||t.md.sha1.create(),B=n.type||"RSAPublicKey",V;switch(B){case"RSAPublicKey":V=e.toDer(a.publicKeyToRSAPublicKey(h)).getBytes();break;case"SubjectPublicKeyInfo":V=e.toDer(a.publicKeyToAsn1(h)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+n.type+'".')}i.start(),i.update(V);var O=i.digest();if(n.encoding==="hex"){var P=O.toHex();if(n.delimiter)return P.match(/.{2}/g).join(n.delimiter);return P}else if(n.encoding==="binary")return O.getBytes();else if(n.encoding)throw new Error('Unknown encoding "'+n.encoding+'".');return O},a.certificationRequestFromPem=function(h,n,i){var B=t.pem.decode(h)[0];if(B.type!=="CERTIFICATE REQUEST"){var V=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw V.headerType=B.type,V}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var O=e.fromDer(B.body,i);return a.certificationRequestFromAsn1(O,n)},a.certificationRequestToPem=function(h,n){var i={type:"CERTIFICATE REQUEST",body:e.toDer(a.certificationRequestToAsn1(h)).getBytes()};return t.pem.encode(i,{maxline:n})},a.createCertificate=function(){var h={};return h.version=2,h.serialNumber="00",h.signatureOid=null,h.signature=null,h.siginfo={},h.siginfo.algorithmOid=null,h.validity={},h.validity.notBefore=new Date,h.validity.notAfter=new Date,h.issuer={},h.issuer.getField=function(n){return I(h.issuer,n)},h.issuer.addField=function(n){T([n]),h.issuer.attributes.push(n)},h.issuer.attributes=[],h.issuer.hash=null,h.subject={},h.subject.getField=function(n){return I(h.subject,n)},h.subject.addField=function(n){T([n]),h.subject.attributes.push(n)},h.subject.attributes=[],h.subject.hash=null,h.extensions=[],h.publicKey=null,h.md=null,h.setSubject=function(n,i){if(T(n),h.subject.attributes=n,delete h.subject.uniqueId,i)h.subject.uniqueId=i;h.subject.hash=null},h.setIssuer=function(n,i){if(T(n),h.issuer.attributes=n,delete h.issuer.uniqueId,i)h.issuer.uniqueId=i;h.issuer.hash=null},h.setExtensions=function(n){for(var i=0;i<n.length;++i)E(n[i],{cert:h});h.extensions=n},h.getExtension=function(n){if(typeof n==="string")n={name:n};var i=null,B;for(var V=0;i===null&&V<h.extensions.length;++V)if(B=h.extensions[V],n.id&&B.id===n.id)i=B;else if(n.name&&B.name===n.name)i=B;return i},h.sign=function(n,i){h.md=i||t.md.sha1.create();var B=d[h.md.algorithm+"WithRSAEncryption"];if(!B){var V=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw V.algorithm=h.md.algorithm,V}h.signatureOid=h.siginfo.algorithmOid=B,h.tbsCertificate=a.getTBSCertificate(h);var O=e.toDer(h.tbsCertificate);h.md.update(O.getBytes()),h.signature=n.sign(h.md)},h.verify=function(n){var i=!1;if(!h.issued(n)){var B=n.issuer,V=h.subject,O=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw O.expectedIssuer=V.attributes,O.actualIssuer=B.attributes,O}var P=n.md;if(P===null){P=S({signatureOid:n.signatureOid,type:"certificate"});var M=n.tbsCertificate||a.getTBSCertificate(n),G=e.toDer(M);P.update(G.getBytes())}if(P!==null)i=c({certificate:h,md:P,signature:n.signature});return i},h.isIssuer=function(n){var i=!1,B=h.issuer,V=n.subject;if(B.hash&&V.hash)i=B.hash===V.hash;else if(B.attributes.length===V.attributes.length){i=!0;var O,P;for(var M=0;i&&M<B.attributes.length;++M)if(O=B.attributes[M],P=V.attributes[M],O.type!==P.type||O.value!==P.value)i=!1}return i},h.issued=function(n){return n.isIssuer(h)},h.generateSubjectKeyIdentifier=function(){return a.getPublicKeyFingerprint(h.publicKey,{type:"RSAPublicKey"})},h.verifySubjectKeyIdentifier=function(){var n=d.subjectKeyIdentifier;for(var i=0;i<h.extensions.length;++i){var B=h.extensions[i];if(B.id===n){var V=h.generateSubjectKeyIdentifier().getBytes();return t.util.hexToBytes(B.subjectKeyIdentifier)===V}}return!1},h},a.certificateFromAsn1=function(h,n){var i={},B=[];if(!e.validate(h,u,i,B)){var V=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw V.errors=B,V}var O=e.derToOid(i.publicKeyOid);if(O!==a.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var P=a.createCertificate();P.version=i.certVersion?i.certVersion.charCodeAt(0):0;var M=t.util.createBuffer(i.certSerialNumber);P.serialNumber=M.toHex(),P.signatureOid=t.asn1.derToOid(i.certSignatureOid),P.signatureParameters=U(P.signatureOid,i.certSignatureParams,!0),P.siginfo.algorithmOid=t.asn1.derToOid(i.certinfoSignatureOid),P.siginfo.parameters=U(P.siginfo.algorithmOid,i.certinfoSignatureParams,!1),P.signature=i.certSignature;var G=[];if(i.certValidity1UTCTime!==void 0)G.push(e.utcTimeToDate(i.certValidity1UTCTime));if(i.certValidity2GeneralizedTime!==void 0)G.push(e.generalizedTimeToDate(i.certValidity2GeneralizedTime));if(i.certValidity3UTCTime!==void 0)G.push(e.utcTimeToDate(i.certValidity3UTCTime));if(i.certValidity4GeneralizedTime!==void 0)G.push(e.generalizedTimeToDate(i.certValidity4GeneralizedTime));if(G.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(G.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(P.validity.notBefore=G[0],P.validity.notAfter=G[1],P.tbsCertificate=i.tbsCertificate,n){P.md=S({signatureOid:P.signatureOid,type:"certificate"});var q=e.toDer(P.tbsCertificate);P.md.update(q.getBytes())}var H=t.md.sha1.create(),X=e.toDer(i.certIssuer);if(H.update(X.getBytes()),P.issuer.getField=function(se){return I(P.issuer,se)},P.issuer.addField=function(se){T([se]),P.issuer.attributes.push(se)},P.issuer.attributes=a.RDNAttributesAsArray(i.certIssuer),i.certIssuerUniqueId)P.issuer.uniqueId=i.certIssuerUniqueId;P.issuer.hash=H.digest().toHex();var J=t.md.sha1.create(),te=e.toDer(i.certSubject);if(J.update(te.getBytes()),P.subject.getField=function(se){return I(P.subject,se)},P.subject.addField=function(se){T([se]),P.subject.attributes.push(se)},P.subject.attributes=a.RDNAttributesAsArray(i.certSubject),i.certSubjectUniqueId)P.subject.uniqueId=i.certSubjectUniqueId;if(P.subject.hash=J.digest().toHex(),i.certExtensions)P.extensions=a.certificateExtensionsFromAsn1(i.certExtensions);else P.extensions=[];return P.publicKey=a.publicKeyFromAsn1(i.subjectPublicKeyInfo),P},a.certificateExtensionsFromAsn1=function(h){var n=[];for(var i=0;i<h.value.length;++i){var B=h.value[i];for(var V=0;V<B.value.length;++V)n.push(a.certificateExtensionFromAsn1(B.value[V]))}return n},a.certificateExtensionFromAsn1=function(h){var n={};if(n.id=e.derToOid(h.value[0].value),n.critical=!1,h.value[1].type===e.Type.BOOLEAN)n.critical=h.value[1].value.charCodeAt(0)!==0,n.value=h.value[2].value;else n.value=h.value[1].value;if(n.id in d){if(n.name=d[n.id],n.name==="keyUsage"){var i=e.fromDer(n.value),B=0,V=0;if(i.value.length>1)B=i.value.charCodeAt(1),V=i.value.length>2?i.value.charCodeAt(2):0;n.digitalSignature=(B&128)===128,n.nonRepudiation=(B&64)===64,n.keyEncipherment=(B&32)===32,n.dataEncipherment=(B&16)===16,n.keyAgreement=(B&8)===8,n.keyCertSign=(B&4)===4,n.cRLSign=(B&2)===2,n.encipherOnly=(B&1)===1,n.decipherOnly=(V&128)===128}else if(n.name==="basicConstraints"){var i=e.fromDer(n.value);if(i.value.length>0&&i.value[0].type===e.Type.BOOLEAN)n.cA=i.value[0].value.charCodeAt(0)!==0;else n.cA=!1;var O=null;if(i.value.length>0&&i.value[0].type===e.Type.INTEGER)O=i.value[0].value;else if(i.value.length>1)O=i.value[1].value;if(O!==null)n.pathLenConstraint=e.derToInteger(O)}else if(n.name==="extKeyUsage"){var i=e.fromDer(n.value);for(var P=0;P<i.value.length;++P){var M=e.derToOid(i.value[P].value);if(M in d)n[d[M]]=!0;else n[M]=!0}}else if(n.name==="nsCertType"){var i=e.fromDer(n.value),B=0;if(i.value.length>1)B=i.value.charCodeAt(1);n.client=(B&128)===128,n.server=(B&64)===64,n.email=(B&32)===32,n.objsign=(B&16)===16,n.reserved=(B&8)===8,n.sslCA=(B&4)===4,n.emailCA=(B&2)===2,n.objCA=(B&1)===1}else if(n.name==="subjectAltName"||n.name==="issuerAltName"){n.altNames=[];var G,i=e.fromDer(n.value);for(var q=0;q<i.value.length;++q){G=i.value[q];var H={type:G.type,value:G.value};switch(n.altNames.push(H),G.type){case 1:case 2:case 6:break;case 7:H.ip=t.util.bytesToIP(G.value);break;case 8:H.oid=e.derToOid(G.value);break;default:}}}else if(n.name==="subjectKeyIdentifier"){var i=e.fromDer(n.value);n.subjectKeyIdentifier=t.util.bytesToHex(i.value)}}return n},a.certificationRequestFromAsn1=function(h,n){var i={},B=[];if(!e.validate(h,f,i,B)){var V=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw V.errors=B,V}var O=e.derToOid(i.publicKeyOid);if(O!==a.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var P=a.createCertificationRequest();if(P.version=i.csrVersion?i.csrVersion.charCodeAt(0):0,P.signatureOid=t.asn1.derToOid(i.csrSignatureOid),P.signatureParameters=U(P.signatureOid,i.csrSignatureParams,!0),P.siginfo.algorithmOid=t.asn1.derToOid(i.csrSignatureOid),P.siginfo.parameters=U(P.siginfo.algorithmOid,i.csrSignatureParams,!1),P.signature=i.csrSignature,P.certificationRequestInfo=i.certificationRequestInfo,n){P.md=S({signatureOid:P.signatureOid,type:"certification request"});var M=e.toDer(P.certificationRequestInfo);P.md.update(M.getBytes())}var G=t.md.sha1.create();return P.subject.getField=function(q){return I(P.subject,q)},P.subject.addField=function(q){T([q]),P.subject.attributes.push(q)},P.subject.attributes=a.RDNAttributesAsArray(i.certificationRequestInfoSubject,G),P.subject.hash=G.digest().toHex(),P.publicKey=a.publicKeyFromAsn1(i.subjectPublicKeyInfo),P.getAttribute=function(q){return I(P,q)},P.addAttribute=function(q){T([q]),P.attributes.push(q)},P.attributes=a.CRIAttributesAsArray(i.certificationRequestInfoAttributes||[]),P},a.createCertificationRequest=function(){var h={};return h.version=0,h.signatureOid=null,h.signature=null,h.siginfo={},h.siginfo.algorithmOid=null,h.subject={},h.subject.getField=function(n){return I(h.subject,n)},h.subject.addField=function(n){T([n]),h.subject.attributes.push(n)},h.subject.attributes=[],h.subject.hash=null,h.publicKey=null,h.attributes=[],h.getAttribute=function(n){return I(h,n)},h.addAttribute=function(n){T([n]),h.attributes.push(n)},h.md=null,h.setSubject=function(n){T(n),h.subject.attributes=n,h.subject.hash=null},h.setAttributes=function(n){T(n),h.attributes=n},h.sign=function(n,i){h.md=i||t.md.sha1.create();var B=d[h.md.algorithm+"WithRSAEncryption"];if(!B){var V=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw V.algorithm=h.md.algorithm,V}h.signatureOid=h.siginfo.algorithmOid=B,h.certificationRequestInfo=a.getCertificationRequestInfo(h);var O=e.toDer(h.certificationRequestInfo);h.md.update(O.getBytes()),h.signature=n.sign(h.md)},h.verify=function(){var n=!1,i=h.md;if(i===null){i=S({signatureOid:h.signatureOid,type:"certification request"});var B=h.certificationRequestInfo||a.getCertificationRequestInfo(h),V=e.toDer(B);i.update(V.getBytes())}if(i!==null)n=c({certificate:h,md:i,signature:h.signature});return n},h};function C(h){var n=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),i,B,V=h.attributes;for(var O=0;O<V.length;++O){i=V[O];var P=i.value,M=e.Type.PRINTABLESTRING;if("valueTagClass"in i){if(M=i.valueTagClass,M===e.Type.UTF8)P=t.util.encodeUtf8(P)}B=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(i.type).getBytes()),e.create(e.Class.UNIVERSAL,M,!1,P)])]),n.value.push(B)}return n}function T(h){var n;for(var i=0;i<h.length;++i){if(n=h[i],typeof n.name==="undefined"){if(n.type&&n.type in a.oids)n.name=a.oids[n.type];else if(n.shortName&&n.shortName in g)n.name=a.oids[g[n.shortName]]}if(typeof n.type==="undefined")if(n.name&&n.name in a.oids)n.type=a.oids[n.name];else{var B=new Error("Attribute type not specified.");throw B.attribute=n,B}if(typeof n.shortName==="undefined"){if(n.name&&n.name in g)n.shortName=g[n.name]}if(n.type===d.extensionRequest){if(n.valueConstructed=!0,n.valueTagClass=e.Type.SEQUENCE,!n.value&&n.extensions){n.value=[];for(var V=0;V<n.extensions.length;++V)n.value.push(a.certificateExtensionToAsn1(E(n.extensions[V])))}}if(typeof n.value==="undefined"){var B=new Error("Attribute value not specified.");throw B.attribute=n,B}}}function E(h,n){if(n=n||{},typeof h.name==="undefined"){if(h.id&&h.id in a.oids)h.name=a.oids[h.id]}if(typeof h.id==="undefined")if(h.name&&h.name in a.oids)h.id=a.oids[h.name];else{var i=new Error("Extension ID not specified.");throw i.extension=h,i}if(typeof h.value!=="undefined")return h;if(h.name==="keyUsage"){var B=0,V=0,O=0;if(h.digitalSignature)V|=128,B=7;if(h.nonRepudiation)V|=64,B=6;if(h.keyEncipherment)V|=32,B=5;if(h.dataEncipherment)V|=16,B=4;if(h.keyAgreement)V|=8,B=3;if(h.keyCertSign)V|=4,B=2;if(h.cRLSign)V|=2,B=1;if(h.encipherOnly)V|=1,B=0;if(h.decipherOnly)O|=128,B=7;var P=String.fromCharCode(B);if(O!==0)P+=String.fromCharCode(V)+String.fromCharCode(O);else if(V!==0)P+=String.fromCharCode(V);h.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,P)}else if(h.name==="basicConstraints"){if(h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),h.cA)h.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,String.fromCharCode(255)));if("pathLenConstraint"in h)h.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.pathLenConstraint).getBytes()))}else if(h.name==="extKeyUsage"){h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var M=h.value.value;for(var G in h){if(h[G]!==!0)continue;if(G in d)M.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d[G]).getBytes()));else if(G.indexOf(".")!==-1)M.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(G).getBytes()))}}else if(h.name==="nsCertType"){var B=0,V=0;if(h.client)V|=128,B=7;if(h.server)V|=64,B=6;if(h.email)V|=32,B=5;if(h.objsign)V|=16,B=4;if(h.reserved)V|=8,B=3;if(h.sslCA)V|=4,B=2;if(h.emailCA)V|=2,B=1;if(h.objCA)V|=1,B=0;var P=String.fromCharCode(B);if(V!==0)P+=String.fromCharCode(V);h.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,P)}else if(h.name==="subjectAltName"||h.name==="issuerAltName"){h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var q;for(var H=0;H<h.altNames.length;++H){q=h.altNames[H];var P=q.value;if(q.type===7&&q.ip){if(P=t.util.bytesFromIP(q.ip),P===null){var i=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw i.extension=h,i}}else if(q.type===8)if(q.oid)P=e.oidToDer(e.oidToDer(q.oid));else P=e.oidToDer(P);h.value.value.push(e.create(e.Class.CONTEXT_SPECIFIC,q.type,!1,P))}}else if(h.name==="nsComment"&&n.cert){if(!/^[\x00-\x7F]*$/.test(h.comment)||h.comment.length<1||h.comment.length>128)throw new Error('Invalid "nsComment" content.');h.value=e.create(e.Class.UNIVERSAL,e.Type.IA5STRING,!1,h.comment)}else if(h.name==="subjectKeyIdentifier"&&n.cert){var X=n.cert.generateSubjectKeyIdentifier();h.subjectKeyIdentifier=X.toHex(),h.value=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,X.getBytes())}else if(h.name==="authorityKeyIdentifier"&&n.cert){h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var M=h.value.value;if(h.keyIdentifier){var J=h.keyIdentifier===!0?n.cert.generateSubjectKeyIdentifier().getBytes():h.keyIdentifier;M.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!1,J))}if(h.authorityCertIssuer){var te=[e.create(e.Class.CONTEXT_SPECIFIC,4,!0,[C(h.authorityCertIssuer===!0?n.cert.issuer:h.authorityCertIssuer)])];M.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,te))}if(h.serialNumber){var se=t.util.hexToBytes(h.serialNumber===!0?n.cert.serialNumber:h.serialNumber);M.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!1,se))}}else if(h.name==="cRLDistributionPoints"){h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var M=h.value.value,fe=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),ve=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]),q;for(var H=0;H<h.altNames.length;++H){q=h.altNames[H];var P=q.value;if(q.type===7&&q.ip){if(P=t.util.bytesFromIP(q.ip),P===null){var i=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw i.extension=h,i}}else if(q.type===8)if(q.oid)P=e.oidToDer(e.oidToDer(q.oid));else P=e.oidToDer(P);ve.value.push(e.create(e.Class.CONTEXT_SPECIFIC,q.type,!1,P))}fe.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[ve])),M.push(fe)}if(typeof h.value==="undefined"){var i=new Error("Extension value not specified.");throw i.extension=h,i}return h}function s(h,n){switch(h){case d["RSASSA-PSS"]:var i=[];if(n.hash.algorithmOid!==void 0)i.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(n.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])]));if(n.mgf.algorithmOid!==void 0)i.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(n.mgf.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(n.mgf.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])]));if(n.saltLength!==void 0)i.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(n.saltLength).getBytes())]));return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,i);default:return e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")}}function p(h){var n=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);if(h.attributes.length===0)return n;var i=h.attributes;for(var B=0;B<i.length;++B){var V=i[B],O=V.value,P=e.Type.UTF8;if("valueTagClass"in V)P=V.valueTagClass;if(P===e.Type.UTF8)O=t.util.encodeUtf8(O);var M=!1;if("valueConstructed"in V)M=V.valueConstructed;var G=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(V.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,P,M,O)])]);n.value.push(G)}return n}var y=new Date("1950-01-01T00:00:00Z"),b=new Date("2050-01-01T00:00:00Z");function L(h){if(h>=y&&h<b)return e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(h));else return e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(h))}a.getTBSCertificate=function(h){var n=L(h.validity.notBefore),i=L(h.validity.notAfter),B=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.version).getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(h.serialNumber)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.siginfo.algorithmOid).getBytes()),s(h.siginfo.algorithmOid,h.siginfo.parameters)]),C(h.issuer),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[n,i]),C(h.subject),a.publicKeyToAsn1(h.publicKey)]);if(h.issuer.uniqueId)B.value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,String.fromCharCode(0)+h.issuer.uniqueId)]));if(h.subject.uniqueId)B.value.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,String.fromCharCode(0)+h.subject.uniqueId)]));if(h.extensions.length>0)B.value.push(a.certificateExtensionsToAsn1(h.extensions));return B},a.getCertificationRequestInfo=function(h){var n=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.version).getBytes()),C(h.subject),a.publicKeyToAsn1(h.publicKey),p(h)]);return n},a.distinguishedNameToAsn1=function(h){return C(h)},a.certificateToAsn1=function(h){var n=h.tbsCertificate||a.getTBSCertificate(h);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[n,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.signatureOid).getBytes()),s(h.signatureOid,h.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,String.fromCharCode(0)+h.signature)])},a.certificateExtensionsToAsn1=function(h){var n=e.create(e.Class.CONTEXT_SPECIFIC,3,!0,[]),i=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);n.value.push(i);for(var B=0;B<h.length;++B)i.value.push(a.certificateExtensionToAsn1(h[B]));return n},a.certificateExtensionToAsn1=function(h){var n=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);if(n.value.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.id).getBytes())),h.critical)n.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,String.fromCharCode(255)));var i=h.value;if(typeof h.value!=="string")i=e.toDer(i).getBytes();return n.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,i)),n},a.certificationRequestToAsn1=function(h){var n=h.certificationRequestInfo||a.getCertificationRequestInfo(h);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[n,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.signatureOid).getBytes()),s(h.signatureOid,h.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,String.fromCharCode(0)+h.signature)])},a.createCaStore=function(h){var n={certs:{}};n.getIssuer=function(P){var M=i(P.issuer);return M},n.addCertificate=function(P){if(typeof P==="string")P=t.pki.certificateFromPem(P);if(B(P.subject),!n.hasCertificate(P))if(P.subject.hash in n.certs){var M=n.certs[P.subject.hash];if(!t.util.isArray(M))M=[M];M.push(P),n.certs[P.subject.hash]=M}else n.certs[P.subject.hash]=P},n.hasCertificate=function(P){if(typeof P==="string")P=t.pki.certificateFromPem(P);var M=i(P.subject);if(!M)return!1;if(!t.util.isArray(M))M=[M];var G=e.toDer(a.certificateToAsn1(P)).getBytes();for(var q=0;q<M.length;++q){var H=e.toDer(a.certificateToAsn1(M[q])).getBytes();if(G===H)return!0}return!1},n.listAllCertificates=function(){var P=[];for(var M in n.certs)if(n.certs.hasOwnProperty(M)){var G=n.certs[M];if(!t.util.isArray(G))P.push(G);else for(var q=0;q<G.length;++q)P.push(G[q])}return P},n.removeCertificate=function(P){var M;if(typeof P==="string")P=t.pki.certificateFromPem(P);if(B(P.subject),!n.hasCertificate(P))return null;var G=i(P.subject);if(!t.util.isArray(G))return M=n.certs[P.subject.hash],delete n.certs[P.subject.hash],M;var q=e.toDer(a.certificateToAsn1(P)).getBytes();for(var H=0;H<G.length;++H){var X=e.toDer(a.certificateToAsn1(G[H])).getBytes();if(q===X)M=G[H],G.splice(H,1)}if(G.length===0)delete n.certs[P.subject.hash];return M};function i(P){return B(P),n.certs[P.hash]||null}function B(P){if(!P.hash){var M=t.md.sha1.create();P.attributes=a.RDNAttributesAsArray(C(P),M),P.hash=M.digest().toHex()}}if(h)for(var V=0;V<h.length;++V){var O=h[V];n.addCertificate(O)}return n},a.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"},a.verifyCertificateChain=function(h,n,i){if(typeof i==="function")i={verify:i};i=i||{},n=n.slice(0);var B=n.slice(0),V=i.validityCheckDate;if(typeof V==="undefined")V=new Date;var O=!0,P=null,M=0;do{var G=n.shift(),q=null,H=!1;if(V){if(V<G.validity.notBefore||V>G.validity.notAfter)P={message:"Certificate is not valid yet or has expired.",error:a.certificateError.certificate_expired,notBefore:G.validity.notBefore,notAfter:G.validity.notAfter,now:V}}if(P===null){if(q=n[0]||h.getIssuer(G),q===null){if(G.isIssuer(G))H=!0,q=G}if(q){var X=q;if(!t.util.isArray(X))X=[X];var J=!1;while(!J&&X.length>0){q=X.shift();try{J=q.verify(G)}catch(Ae){}}if(!J)P={message:"Certificate signature is invalid.",error:a.certificateError.bad_certificate}}if(P===null&&(!q||H)&&!h.hasCertificate(G))P={message:"Certificate is not trusted.",error:a.certificateError.unknown_ca}}if(P===null&&q&&!G.isIssuer(q))P={message:"Certificate issuer is invalid.",error:a.certificateError.bad_certificate};if(P===null){var te={keyUsage:!0,basicConstraints:!0};for(var se=0;P===null&&se<G.extensions.length;++se){var fe=G.extensions[se];if(fe.critical&&!(fe.name in te))P={message:"Certificate has an unsupported critical extension.",error:a.certificateError.unsupported_certificate}}}if(P===null&&(!O||n.length===0&&(!q||H))){var ve=G.getExtension("basicConstraints"),Ie=G.getExtension("keyUsage");if(Ie!==null){if(!Ie.keyCertSign||ve===null)P={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:a.certificateError.bad_certificate}}if(P===null&&ve!==null&&!ve.cA)P={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:a.certificateError.bad_certificate};if(P===null&&Ie!==null&&"pathLenConstraint"in ve){var Z=M-1;if(Z>ve.pathLenConstraint)P={message:"Certificate basicConstraints pathLenConstraint violated.",error:a.certificateError.bad_certificate}}}var me=P===null?!0:P.error,ee=i.verify?i.verify(me,M,B):me;if(ee===!0)P=null;else{if(me===!0)P={message:"The application rejected the certificate.",error:a.certificateError.bad_certificate};if(ee||ee===0){if(typeof ee==="object"&&!t.util.isArray(ee)){if(ee.message)P.message=ee.message;if(ee.error)P.error=ee.error}else if(typeof ee==="string")P.error=ee}throw P}O=!1,++M}while(n.length>0);return!0}}),Xr=le((N,_)=>{var t=pe();lt(),Ot(),It(),zr(),Qr(),ct(),Wt(),Mt(),Ce(),pr();var{asn1:e,pki:a}=t,d=_.exports=t.pkcs12=t.pkcs12||{},g={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},v={name:"PFX",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},g,{name:"PFX.macData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:e.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},u={name:"SafeBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},r={name:"Attribute",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,capture:"values"}]},m={name:"CertBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:e.Class.UNIVERSAL,type:e.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function f(T,E,s,p){var y=[];for(var b=0;b<T.length;b++)for(var L=0;L<T[b].safeBags.length;L++){var h=T[b].safeBags[L];if(p!==void 0&&h.type!==p)continue;if(E===null){y.push(h);continue}if(h.attributes[E]!==void 0&&h.attributes[E].indexOf(s)>=0)y.push(h)}return y}d.pkcs12FromAsn1=function(T,E,s){if(typeof E==="string")s=E,E=!0;else if(E===void 0)E=!0;var p={},y=[];if(!e.validate(T,v,p,y)){var b=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw b.errors=b,b}var L={version:p.version.charCodeAt(0),safeContents:[],getBags:function(q){var H={},X;if("localKeyId"in q)X=q.localKeyId;else if("localKeyIdHex"in q)X=t.util.hexToBytes(q.localKeyIdHex);if(X===void 0&&!("friendlyName"in q)&&"bagType"in q)H[q.bagType]=f(L.safeContents,null,null,q.bagType);if(X!==void 0)H.localKeyId=f(L.safeContents,"localKeyId",X,q.bagType);if("friendlyName"in q)H.friendlyName=f(L.safeContents,"friendlyName",q.friendlyName,q.bagType);return H},getBagsByFriendlyName:function(q,H){return f(L.safeContents,"friendlyName",q,H)},getBagsByLocalKeyId:function(q,H){return f(L.safeContents,"localKeyId",q,H)}};if(p.version.charCodeAt(0)!==3){var b=new Error("PKCS#12 PFX of version other than 3 not supported.");throw b.version=p.version.charCodeAt(0),b}if(e.derToOid(p.contentType)!==a.oids.data){var b=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw b.oid=e.derToOid(p.contentType),b}var h=p.content.value[0];if(h.tagClass!==e.Class.UNIVERSAL||h.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(h=I(h),p.mac){var n=null,i=0,B=e.derToOid(p.macAlgorithm);switch(B){case a.oids.sha1:n=t.md.sha1.create(),i=20;break;case a.oids.sha256:n=t.md.sha256.create(),i=32;break;case a.oids.sha384:n=t.md.sha384.create(),i=48;break;case a.oids.sha512:n=t.md.sha512.create(),i=64;break;case a.oids.md5:n=t.md.md5.create(),i=16;break}if(n===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+B);var V=new t.util.ByteBuffer(p.macSalt),O="macIterations"in p?parseInt(t.util.bytesToHex(p.macIterations),16):1,P=d.generateKey(s,V,3,O,i,n),M=t.hmac.create();M.start(n,P),M.update(h.value);var G=M.getMac();if(G.getBytes()!==p.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return U(L,h.value,E,s),L};function I(T){if(T.composed||T.constructed){var E=t.util.createBuffer();for(var s=0;s<T.value.length;++s)E.putBytes(T.value[s].value);T.composed=T.constructed=!1,T.value=E.getBytes()}return T}function U(T,E,s,p){if(E=e.fromDer(E,s),E.tagClass!==e.Class.UNIVERSAL||E.type!==e.Type.SEQUENCE||E.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var y=0;y<E.value.length;y++){var b=E.value[y],L={},h=[];if(!e.validate(b,g,L,h)){var n=new Error("Cannot read ContentInfo.");throw n.errors=h,n}var i={encrypted:!1},B=null,V=L.content.value[0];switch(e.derToOid(L.contentType)){case a.oids.data:if(V.tagClass!==e.Class.UNIVERSAL||V.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");B=I(V).value;break;case a.oids.encryptedData:B=S(V,p),i.encrypted=!0;break;default:var n=new Error("Unsupported PKCS#12 contentType.");throw n.contentType=e.derToOid(L.contentType),n}i.safeBags=c(B,s,p),T.safeContents.push(i)}}function S(T,E){var s={},p=[];if(!e.validate(T,t.pkcs7.asn1.encryptedDataValidator,s,p)){var y=new Error("Cannot read EncryptedContentInfo.");throw y.errors=p,y}var b=e.derToOid(s.contentType);if(b!==a.oids.data){var y=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw y.oid=b,y}b=e.derToOid(s.encAlgorithm);var L=a.pbe.getCipher(b,s.encParameter,E),h=I(s.encryptedContentAsn1),n=t.util.createBuffer(h.value);if(L.update(n),!L.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return L.output.getBytes()}function c(T,E,s){if(!E&&T.length===0)return[];if(T=e.fromDer(T,E),T.tagClass!==e.Class.UNIVERSAL||T.type!==e.Type.SEQUENCE||T.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");var p=[];for(var y=0;y<T.value.length;y++){var b=T.value[y],L={},h=[];if(!e.validate(b,u,L,h)){var n=new Error("Cannot read SafeBag.");throw n.errors=h,n}var i={type:e.derToOid(L.bagId),attributes:C(L.bagAttributes)};p.push(i);var B,V,O=L.bagValue.value[0];switch(i.type){case a.oids.pkcs8ShroudedKeyBag:if(O=a.decryptPrivateKeyInfo(O,s),O===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case a.oids.keyBag:try{i.key=a.privateKeyFromAsn1(O)}catch(M){i.key=null,i.asn1=O}continue;case a.oids.certBag:B=m,V=function(){if(e.derToOid(L.certId)!==a.oids.x509Certificate){var M=new Error("Unsupported certificate type, only X.509 supported.");throw M.oid=e.derToOid(L.certId),M}var G=e.fromDer(L.cert,E);try{i.cert=a.certificateFromAsn1(G,!0)}catch(q){i.cert=null,i.asn1=G}};break;default:var n=new Error("Unsupported PKCS#12 SafeBag type.");throw n.oid=i.type,n}if(B!==void 0&&!e.validate(O,B,L,h)){var n=new Error("Cannot read PKCS#12 "+B.name);throw n.errors=h,n}V()}return p}function C(T){var E={};if(T!==void 0)for(var s=0;s<T.length;++s){var p={},y=[];if(!e.validate(T[s],r,p,y)){var b=new Error("Cannot read PKCS#12 BagAttribute.");throw b.errors=y,b}var L=e.derToOid(p.oid);if(a.oids[L]===void 0)continue;E[a.oids[L]]=[];for(var h=0;h<p.values.length;++h)E[a.oids[L]].push(p.values[h].value)}return E}d.toPkcs12Asn1=function(T,E,s,p){if(p=p||{},p.saltSize=p.saltSize||8,p.count=p.count||2048,p.algorithm=p.algorithm||p.encAlgorithm||"aes128",!("useMac"in p))p.useMac=!0;if(!("localKeyId"in p))p.localKeyId=null;if(!("generateLocalKeyId"in p))p.generateLocalKeyId=!0;var y=p.localKeyId,b;if(y!==null)y=t.util.hexToBytes(y);else if(p.generateLocalKeyId)if(E){var L=t.util.isArray(E)?E[0]:E;if(typeof L==="string")L=a.certificateFromPem(L);var h=t.md.sha1.create();h.update(e.toDer(a.certificateToAsn1(L)).getBytes()),y=h.digest().getBytes()}else y=t.random.getBytes(20);var n=[];if(y!==null)n.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.localKeyId).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,y)])]));if("friendlyName"in p)n.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.friendlyName).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.BMPSTRING,!1,p.friendlyName)])]));if(n.length>0)b=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,n);var i=[],B=[];if(E!==null)if(t.util.isArray(E))B=E;else B=[E];var V=[];for(var O=0;O<B.length;++O){if(E=B[O],typeof E==="string")E=a.certificateFromPem(E);var P=O===0?b:void 0,M=a.certificateToAsn1(E),G=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.certBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.x509Certificate).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(M).getBytes())])])]),P]);V.push(G)}if(V.length>0){var q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,V),H=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(q).getBytes())])]);i.push(H)}var X=null;if(T!==null){var J=a.wrapRsaPrivateKey(a.privateKeyToAsn1(T));if(s===null)X=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.keyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[J]),b]);else X=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.pkcs8ShroudedKeyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[a.encryptPrivateKeyInfo(J,s,p)]),b]);var te=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[X]),se=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(te).getBytes())])]);i.push(se)}var fe=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,i),ve;if(p.useMac){var h=t.md.sha1.create(),Ie=new t.util.ByteBuffer(t.random.getBytes(p.saltSize)),Z=p.count,T=d.generateKey(s,Ie,3,Z,20),me=t.hmac.create();me.start(h,T),me.update(e.toDer(fe).getBytes());var ee=me.getMac();ve=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.sha1).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,ee.getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,Ie.getBytes()),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(Z).getBytes())])}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(3).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(fe).getBytes())])]),ve])},d.generateKey=t.pbe.generatePkcs12Key}),Wr=le((N,_)=>{var t=pe();lt(),It(),Qr(),Rt(),fr(),Xr(),hr(),Wt(),Ce(),pr();var e=t.asn1,a=_.exports=t.pki=t.pki||{};a.pemToDer=function(d){var g=t.pem.decode(d)[0];if(g.procType&&g.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return t.util.createBuffer(g.body)},a.privateKeyFromPem=function(d){var g=t.pem.decode(d)[0];if(g.type!=="PRIVATE KEY"&&g.type!=="RSA PRIVATE KEY"){var v=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw v.headerType=g.type,v}if(g.procType&&g.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var u=e.fromDer(g.body);return a.privateKeyFromAsn1(u)},a.privateKeyToPem=function(d,g){var v={type:"RSA PRIVATE KEY",body:e.toDer(a.privateKeyToAsn1(d)).getBytes()};return t.pem.encode(v,{maxline:g})},a.privateKeyInfoToPem=function(d,g){var v={type:"PRIVATE KEY",body:e.toDer(d).getBytes()};return t.pem.encode(v,{maxline:g})}}),Zr=le((N,_)=>{var t=pe();lt(),Ot(),lr(),Rt(),Wr(),ct(),Mt(),Ce();var e=function(l,D,R,o){var w=t.util.createBuffer(),F=l.length>>1,K=F+(l.length&1),Y=l.substr(0,K),ie=l.substr(F,K),oe=t.util.createBuffer(),Q=t.hmac.create();R=D+R;var ae=Math.ceil(o/16),ue=Math.ceil(o/20);Q.start("MD5",Y);var ge=t.util.createBuffer();oe.putBytes(R);for(var he=0;he<ae;++he)Q.start(null,null),Q.update(oe.getBytes()),oe.putBuffer(Q.digest()),Q.start(null,null),Q.update(oe.bytes()+R),ge.putBuffer(Q.digest());Q.start("SHA1",ie);var be=t.util.createBuffer();oe.clear(),oe.putBytes(R);for(var he=0;he<ue;++he)Q.start(null,null),Q.update(oe.getBytes()),oe.putBuffer(Q.digest()),Q.start(null,null),Q.update(oe.bytes()+R),be.putBuffer(Q.digest());return w.putBytes(t.util.xorBytes(ge.getBytes(),be.getBytes(),o)),w},a=function(l,D,R){var o=t.hmac.create();o.start("SHA1",l);var w=t.util.createBuffer();return w.putInt32(D[0]),w.putInt32(D[1]),w.putByte(R.type),w.putByte(R.version.major),w.putByte(R.version.minor),w.putInt16(R.length),w.putBytes(R.fragment.bytes()),o.update(w.getBytes()),o.digest().getBytes()},d=function(l,D,R){var o=!1;try{var w=l.deflate(D.fragment.getBytes());D.fragment=t.util.createBuffer(w),D.length=w.length,o=!0}catch(F){}return o},g=function(l,D,R){var o=!1;try{var w=l.inflate(D.fragment.getBytes());D.fragment=t.util.createBuffer(w),D.length=w.length,o=!0}catch(F){}return o},v=function(l,D){var R=0;switch(D){case 1:R=l.getByte();break;case 2:R=l.getInt16();break;case 3:R=l.getInt24();break;case 4:R=l.getInt32();break}return t.util.createBuffer(l.getBytes(R))},u=function(l,D,R){l.putInt(R.length(),D<<3),l.putBuffer(R)},r={};r.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},r.SupportedVersions=[r.Versions.TLS_1_1,r.Versions.TLS_1_0],r.Version=r.SupportedVersions[0],r.MaxFragment=15360,r.ConnectionEnd={server:0,client:1},r.PRFAlgorithm={tls_prf_sha256:0},r.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},r.CipherType={stream:0,block:1,aead:2},r.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},r.CompressionMethod={none:0,deflate:1},r.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},r.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},r.Alert={},r.Alert.Level={warning:1,fatal:2},r.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},r.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},r.CipherSuites={},r.getCipherSuite=function(l){var D=null;for(var R in r.CipherSuites){var o=r.CipherSuites[R];if(o.id[0]===l.charCodeAt(0)&&o.id[1]===l.charCodeAt(1)){D=o;break}}return D},r.handleUnexpected=function(l,D){var R=!l.open&&l.entity===r.ConnectionEnd.client;if(!R)l.error(l,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.unexpected_message}})},r.handleHelloRequest=function(l,D,R){if(!l.handshaking&&l.handshakes>0)r.queue(l,r.createAlert(l,{level:r.Alert.Level.warning,description:r.Alert.Description.no_renegotiation})),r.flush(l);l.process()},r.parseHelloMessage=function(l,D,R){var o=null,w=l.entity===r.ConnectionEnd.client;if(R<38)l.error(l,{message:w?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});else{var F=D.fragment,K=F.length();if(o={version:{major:F.getByte(),minor:F.getByte()},random:t.util.createBuffer(F.getBytes(32)),session_id:v(F,1),extensions:[]},w)o.cipher_suite=F.getBytes(2),o.compression_method=F.getByte();else o.cipher_suites=v(F,2),o.compression_methods=v(F,1);if(K=R-(K-F.length()),K>0){var Y=v(F,2);while(Y.length()>0)o.extensions.push({type:[Y.getByte(),Y.getByte()],data:v(Y,2)});if(!w)for(var ie=0;ie<o.extensions.length;++ie){var oe=o.extensions[ie];if(oe.type[0]===0&&oe.type[1]===0){var Q=v(oe.data,2);while(Q.length()>0){var ae=Q.getByte();if(ae!==0)break;l.session.extensions.server_name.serverNameList.push(v(Q,2).getBytes())}}}}if(l.session.version){if(o.version.major!==l.session.version.major||o.version.minor!==l.session.version.minor)return l.error(l,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.protocol_version}})}if(w)l.session.cipherSuite=r.getCipherSuite(o.cipher_suite);else{var ue=t.util.createBuffer(o.cipher_suites.bytes());while(ue.length()>0)if(l.session.cipherSuite=r.getCipherSuite(ue.getBytes(2)),l.session.cipherSuite!==null)break}if(l.session.cipherSuite===null)return l.error(l,{message:"No cipher suites in common.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.handshake_failure},cipherSuite:t.util.bytesToHex(o.cipher_suite)});if(w)l.session.compressionMethod=o.compression_method;else l.session.compressionMethod=r.CompressionMethod.none}return o},r.createSecurityParameters=function(l,D){var R=l.entity===r.ConnectionEnd.client,o=D.random.bytes(),w=R?l.session.sp.client_random:o,F=R?o:r.createRandom().getBytes();l.session.sp={entity:l.entity,prf_algorithm:r.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:l.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:w,server_random:F}},r.handleServerHello=function(l,D,R){var o=r.parseHelloMessage(l,D,R);if(l.fail)return;if(o.version.minor<=l.version.minor)l.version.minor=o.version.minor;else return l.error(l,{message:"Incompatible TLS version.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.protocol_version}});l.session.version=l.version;var w=o.session_id.bytes();if(w.length>0&&w===l.session.id)l.expect=c,l.session.resuming=!0,l.session.sp.server_random=o.random.bytes();else l.expect=f,l.session.resuming=!1,r.createSecurityParameters(l,o);l.session.id=w,l.process()},r.handleClientHello=function(l,D,R){var o=r.parseHelloMessage(l,D,R);if(l.fail)return;var w=o.session_id.bytes(),F=null;if(l.sessionCache){if(F=l.sessionCache.getSession(w),F===null)w="";else if(F.version.major!==o.version.major||F.version.minor>o.version.minor)F=null,w=""}if(w.length===0)w=t.random.getBytes(32);if(l.session.id=w,l.session.clientHelloVersion=o.version,l.session.sp={},F)l.version=l.session.version=F.version,l.session.sp=F.sp;else{var K;for(var Y=1;Y<r.SupportedVersions.length;++Y)if(K=r.SupportedVersions[Y],K.minor<=o.version.minor)break;l.version={major:K.major,minor:K.minor},l.session.version=l.version}if(F!==null)l.expect=L,l.session.resuming=!0,l.session.sp.client_random=o.random.bytes();else l.expect=l.verifyClient!==!1?p:y,l.session.resuming=!1,r.createSecurityParameters(l,o);if(l.open=!0,r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createServerHello(l)})),l.session.resuming)r.queue(l,r.createRecord(l,{type:r.ContentType.change_cipher_spec,data:r.createChangeCipherSpec()})),l.state.pending=r.createConnectionState(l),l.state.current.write=l.state.pending.write,r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createFinished(l)}));else if(r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createCertificate(l)})),!l.fail){if(r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createServerKeyExchange(l)})),l.verifyClient!==!1)r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createCertificateRequest(l)}));r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createServerHelloDone(l)}))}r.flush(l),l.process()},r.handleCertificate=function(l,D,R){if(R<3)return l.error(l,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});var o=D.fragment,w={certificate_list:v(o,3)},F,K,Y=[];try{while(w.certificate_list.length()>0)F=v(w.certificate_list,3),K=t.asn1.fromDer(F),F=t.pki.certificateFromAsn1(K,!0),Y.push(F)}catch(oe){return l.error(l,{message:"Could not parse certificate list.",cause:oe,send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.bad_certificate}})}var ie=l.entity===r.ConnectionEnd.client;if((ie||l.verifyClient===!0)&&Y.length===0)l.error(l,{message:ie?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});else if(Y.length===0)l.expect=ie?I:y;else{if(ie)l.session.serverCertificate=Y[0];else l.session.clientCertificate=Y[0];if(r.verifyCertificateChain(l,Y))l.expect=ie?I:y}l.process()},r.handleServerKeyExchange=function(l,D,R){if(R>0)return l.error(l,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.unsupported_certificate}});l.expect=U,l.process()},r.handleClientKeyExchange=function(l,D,R){if(R<48)return l.error(l,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.unsupported_certificate}});var o=D.fragment,w={enc_pre_master_secret:v(o,2).getBytes()},F=null;if(l.getPrivateKey)try{F=l.getPrivateKey(l,l.session.serverCertificate),F=t.pki.privateKeyFromPem(F)}catch(ie){l.error(l,{message:"Could not get private key.",cause:ie,send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}})}if(F===null)return l.error(l,{message:"No private key set.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}});try{var K=l.session.sp;K.pre_master_secret=F.decrypt(w.enc_pre_master_secret);var Y=l.session.clientHelloVersion;if(Y.major!==K.pre_master_secret.charCodeAt(0)||Y.minor!==K.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(ie){K.pre_master_secret=t.random.getBytes(48)}if(l.expect=L,l.session.clientCertificate!==null)l.expect=b;l.process()},r.handleCertificateRequest=function(l,D,R){if(R<3)return l.error(l,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});var o=D.fragment,w={certificate_types:v(o,1),certificate_authorities:v(o,2)};l.session.certificateRequest=w,l.expect=S,l.process()},r.handleCertificateVerify=function(l,D,R){if(R<2)return l.error(l,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});var o=D.fragment;o.read-=4;var w=o.bytes();o.read+=4;var F={signature:v(o,2).getBytes()},K=t.util.createBuffer();K.putBuffer(l.session.md5.digest()),K.putBuffer(l.session.sha1.digest()),K=K.getBytes();try{var Y=l.session.clientCertificate;if(!Y.publicKey.verify(K,F.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");l.session.md5.update(w),l.session.sha1.update(w)}catch(ie){return l.error(l,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.handshake_failure}})}l.expect=L,l.process()},r.handleServerHelloDone=function(l,D,R){if(R>0)return l.error(l,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.record_overflow}});if(l.serverCertificate===null){var o={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.insufficient_security}},w=0,F=l.verify(l,o.alert.description,w,[]);if(F!==!0){if(F||F===0){if(typeof F==="object"&&!t.util.isArray(F)){if(F.message)o.message=F.message;if(F.alert)o.alert.description=F.alert}else if(typeof F==="number")o.alert.description=F}return l.error(l,o)}}if(l.session.certificateRequest!==null)D=r.createRecord(l,{type:r.ContentType.handshake,data:r.createCertificate(l)}),r.queue(l,D);D=r.createRecord(l,{type:r.ContentType.handshake,data:r.createClientKeyExchange(l)}),r.queue(l,D),l.expect=E;var K=function(Y,ie){if(Y.session.certificateRequest!==null&&Y.session.clientCertificate!==null)r.queue(Y,r.createRecord(Y,{type:r.ContentType.handshake,data:r.createCertificateVerify(Y,ie)}));r.queue(Y,r.createRecord(Y,{type:r.ContentType.change_cipher_spec,data:r.createChangeCipherSpec()})),Y.state.pending=r.createConnectionState(Y),Y.state.current.write=Y.state.pending.write,r.queue(Y,r.createRecord(Y,{type:r.ContentType.handshake,data:r.createFinished(Y)})),Y.expect=c,r.flush(Y),Y.process()};if(l.session.certificateRequest===null||l.session.clientCertificate===null)return K(l,null);r.getClientSignature(l,K)},r.handleChangeCipherSpec=function(l,D){if(D.fragment.getByte()!==1)return l.error(l,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});var R=l.entity===r.ConnectionEnd.client;if(l.session.resuming&&R||!l.session.resuming&&!R)l.state.pending=r.createConnectionState(l);if(l.state.current.read=l.state.pending.read,!l.session.resuming&&R||l.session.resuming&&!R)l.state.pending=null;l.expect=R?C:h,l.process()},r.handleFinished=function(l,D,R){var o=D.fragment;o.read-=4;var w=o.bytes();o.read+=4;var F=D.fragment.getBytes();o=t.util.createBuffer(),o.putBuffer(l.session.md5.digest()),o.putBuffer(l.session.sha1.digest());var K=l.entity===r.ConnectionEnd.client,Y=K?"server finished":"client finished",ie=l.session.sp,oe=12,Q=e;if(o=Q(ie.master_secret,Y,o.getBytes(),oe),o.getBytes()!==F)return l.error(l,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.decrypt_error}});if(l.session.md5.update(w),l.session.sha1.update(w),l.session.resuming&&K||!l.session.resuming&&!K)r.queue(l,r.createRecord(l,{type:r.ContentType.change_cipher_spec,data:r.createChangeCipherSpec()})),l.state.current.write=l.state.pending.write,l.state.pending=null,r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createFinished(l)}));l.expect=K?T:n,l.handshaking=!1,++l.handshakes,l.peerCertificate=K?l.session.serverCertificate:l.session.clientCertificate,r.flush(l),l.isConnected=!0,l.connected(l),l.process()},r.handleAlert=function(l,D){var R=D.fragment,o={level:R.getByte(),description:R.getByte()},w;switch(o.description){case r.Alert.Description.close_notify:w="Connection closed.";break;case r.Alert.Description.unexpected_message:w="Unexpected message.";break;case r.Alert.Description.bad_record_mac:w="Bad record MAC.";break;case r.Alert.Description.decryption_failed:w="Decryption failed.";break;case r.Alert.Description.record_overflow:w="Record overflow.";break;case r.Alert.Description.decompression_failure:w="Decompression failed.";break;case r.Alert.Description.handshake_failure:w="Handshake failure.";break;case r.Alert.Description.bad_certificate:w="Bad certificate.";break;case r.Alert.Description.unsupported_certificate:w="Unsupported certificate.";break;case r.Alert.Description.certificate_revoked:w="Certificate revoked.";break;case r.Alert.Description.certificate_expired:w="Certificate expired.";break;case r.Alert.Description.certificate_unknown:w="Certificate unknown.";break;case r.Alert.Description.illegal_parameter:w="Illegal parameter.";break;case r.Alert.Description.unknown_ca:w="Unknown certificate authority.";break;case r.Alert.Description.access_denied:w="Access denied.";break;case r.Alert.Description.decode_error:w="Decode error.";break;case r.Alert.Description.decrypt_error:w="Decrypt error.";break;case r.Alert.Description.export_restriction:w="Export restriction.";break;case r.Alert.Description.protocol_version:w="Unsupported protocol version.";break;case r.Alert.Description.insufficient_security:w="Insufficient security.";break;case r.Alert.Description.internal_error:w="Internal error.";break;case r.Alert.Description.user_canceled:w="User canceled.";break;case r.Alert.Description.no_renegotiation:w="Renegotiation not supported.";break;default:w="Unknown error.";break}if(o.description===r.Alert.Description.close_notify)return l.close();l.error(l,{message:w,send:!1,origin:l.entity===r.ConnectionEnd.client?"server":"client",alert:o}),l.process()},r.handleHandshake=function(l,D){var R=D.fragment,o=R.getByte(),w=R.getInt24();if(w>R.length())return l.fragmented=D,D.fragment=t.util.createBuffer(),R.read-=4,l.process();l.fragmented=null,R.read-=4;var F=R.bytes(w+4);if(R.read+=4,o in ve[l.entity][l.expect]){if(l.entity===r.ConnectionEnd.server&&!l.open&&!l.fail)l.handshaking=!0,l.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:t.md.md5.create(),sha1:t.md.sha1.create()};if(o!==r.HandshakeType.hello_request&&o!==r.HandshakeType.certificate_verify&&o!==r.HandshakeType.finished)l.session.md5.update(F),l.session.sha1.update(F);ve[l.entity][l.expect][o](l,D,w)}else r.handleUnexpected(l,D)},r.handleApplicationData=function(l,D){l.data.putBuffer(D.fragment),l.dataReady(l),l.process()},r.handleHeartbeat=function(l,D){var R=D.fragment,o=R.getByte(),w=R.getInt16(),F=R.getBytes(w);if(o===r.HeartbeatMessageType.heartbeat_request){if(l.handshaking||w>F.length)return l.process();r.queue(l,r.createRecord(l,{type:r.ContentType.heartbeat,data:r.createHeartbeat(r.HeartbeatMessageType.heartbeat_response,F)})),r.flush(l)}else if(o===r.HeartbeatMessageType.heartbeat_response){if(F!==l.expectedHeartbeatPayload)return l.process();if(l.heartbeatReceived)l.heartbeatReceived(l,t.util.createBuffer(F))}l.process()};var m=0,f=1,I=2,U=3,S=4,c=5,C=6,T=7,E=8,s=0,p=1,y=2,b=3,L=4,h=5,n=6,i=r.handleUnexpected,B=r.handleChangeCipherSpec,V=r.handleAlert,O=r.handleHandshake,P=r.handleApplicationData,M=r.handleHeartbeat,G=[];G[r.ConnectionEnd.client]=[[i,V,O,i,M],[i,V,O,i,M],[i,V,O,i,M],[i,V,O,i,M],[i,V,O,i,M],[B,V,i,i,M],[i,V,O,i,M],[i,V,O,P,M],[i,V,O,i,M]],G[r.ConnectionEnd.server]=[[i,V,O,i,M],[i,V,O,i,M],[i,V,O,i,M],[i,V,O,i,M],[B,V,i,i,M],[i,V,O,i,M],[i,V,O,P,M],[i,V,O,i,M]];var{handleHelloRequest:q,handleServerHello:H,handleCertificate:X,handleServerKeyExchange:J,handleCertificateRequest:te,handleServerHelloDone:se,handleFinished:fe}=r,ve=[];ve[r.ConnectionEnd.client]=[[i,i,H,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,X,J,te,se,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,J,te,se,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,te,se,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,se,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,fe],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i]];var{handleClientHello:Ie,handleClientKeyExchange:Z,handleCertificateVerify:me}=r;ve[r.ConnectionEnd.server]=[[i,Ie,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,X,i,i,i,i,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,Z,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,me,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,fe],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i]],r.generateKeys=function(l,D){var R=e,o=D.client_random+D.server_random;if(!l.session.resuming)D.master_secret=R(D.pre_master_secret,"master secret",o,48).bytes(),D.pre_master_secret=null;o=D.server_random+D.client_random;var w=2*D.mac_key_length+2*D.enc_key_length,F=l.version.major===r.Versions.TLS_1_0.major&&l.version.minor===r.Versions.TLS_1_0.minor;if(F)w+=2*D.fixed_iv_length;var K=R(D.master_secret,"key expansion",o,w),Y={client_write_MAC_key:K.getBytes(D.mac_key_length),server_write_MAC_key:K.getBytes(D.mac_key_length),client_write_key:K.getBytes(D.enc_key_length),server_write_key:K.getBytes(D.enc_key_length)};if(F)Y.client_write_IV=K.getBytes(D.fixed_iv_length),Y.server_write_IV=K.getBytes(D.fixed_iv_length);return Y},r.createConnectionState=function(l){var D=l.entity===r.ConnectionEnd.client,R=function(){var F={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(K){return!0},compressionState:null,compressFunction:function(K){return!0},updateSequenceNumber:function(){if(F.sequenceNumber[1]===4294967295)F.sequenceNumber[1]=0,++F.sequenceNumber[0];else++F.sequenceNumber[1]}};return F},o={read:R(),write:R()};if(o.read.update=function(F,K){if(!o.read.cipherFunction(K,o.read))F.error(F,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.bad_record_mac}});else if(!o.read.compressFunction(F,K,o.read))F.error(F,{message:"Could not decompress record.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.decompression_failure}});return!F.fail},o.write.update=function(F,K){if(!o.write.compressFunction(F,K,o.write))F.error(F,{message:"Could not compress record.",send:!1,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}});else if(!o.write.cipherFunction(K,o.write))F.error(F,{message:"Could not encrypt record.",send:!1,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}});return!F.fail},l.session){var w=l.session.sp;switch(l.session.cipherSuite.initSecurityParameters(w),w.keys=r.generateKeys(l,w),o.read.macKey=D?w.keys.server_write_MAC_key:w.keys.client_write_MAC_key,o.write.macKey=D?w.keys.client_write_MAC_key:w.keys.server_write_MAC_key,l.session.cipherSuite.initConnectionState(o,l,w),w.compression_algorithm){case r.CompressionMethod.none:break;case r.CompressionMethod.deflate:o.read.compressFunction=g,o.write.compressFunction=d;break;default:throw new Error("Unsupported compression algorithm.")}}return o},r.createRandom=function(){var l=new Date,D=+l+l.getTimezoneOffset()*60000,R=t.util.createBuffer();return R.putInt32(D),R.putBytes(t.random.getBytes(28)),R},r.createRecord=function(l,D){if(!D.data)return null;var R={type:D.type,version:{major:l.version.major,minor:l.version.minor},length:D.data.length(),fragment:D.data};return R},r.createAlert=function(l,D){var R=t.util.createBuffer();return R.putByte(D.level),R.putByte(D.description),r.createRecord(l,{type:r.ContentType.alert,data:R})},r.createClientHello=function(l){l.session.clientHelloVersion={major:l.version.major,minor:l.version.minor};var D=t.util.createBuffer();for(var R=0;R<l.cipherSuites.length;++R){var o=l.cipherSuites[R];D.putByte(o.id[0]),D.putByte(o.id[1])}var w=D.length(),F=t.util.createBuffer();F.putByte(r.CompressionMethod.none);var K=F.length(),Y=t.util.createBuffer();if(l.virtualHost){var ie=t.util.createBuffer();ie.putByte(0),ie.putByte(0);var oe=t.util.createBuffer();oe.putByte(0),u(oe,2,t.util.createBuffer(l.virtualHost));var Q=t.util.createBuffer();u(Q,2,oe),u(ie,2,Q),Y.putBuffer(ie)}var ae=Y.length();if(ae>0)ae+=2;var ue=l.session.id,ge=ue.length+1+2+4+28+2+w+1+K+ae,he=t.util.createBuffer();if(he.putByte(r.HandshakeType.client_hello),he.putInt24(ge),he.putByte(l.version.major),he.putByte(l.version.minor),he.putBytes(l.session.sp.client_random),u(he,1,t.util.createBuffer(ue)),u(he,2,D),u(he,1,F),ae>0)u(he,2,Y);return he},r.createServerHello=function(l){var D=l.session.id,R=D.length+1+2+4+28+2+1,o=t.util.createBuffer();return o.putByte(r.HandshakeType.server_hello),o.putInt24(R),o.putByte(l.version.major),o.putByte(l.version.minor),o.putBytes(l.session.sp.server_random),u(o,1,t.util.createBuffer(D)),o.putByte(l.session.cipherSuite.id[0]),o.putByte(l.session.cipherSuite.id[1]),o.putByte(l.session.compressionMethod),o},r.createCertificate=function(l){var D=l.entity===r.ConnectionEnd.client,R=null;if(l.getCertificate){var o;if(D)o=l.session.certificateRequest;else o=l.session.extensions.server_name.serverNameList;R=l.getCertificate(l,o)}var w=t.util.createBuffer();if(R!==null)try{if(!t.util.isArray(R))R=[R];var F=null;for(var K=0;K<R.length;++K){var Y=t.pem.decode(R[K])[0];if(Y.type!=="CERTIFICATE"&&Y.type!=="X509 CERTIFICATE"&&Y.type!=="TRUSTED CERTIFICATE"){var ie=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw ie.headerType=Y.type,ie}if(Y.procType&&Y.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var oe=t.util.createBuffer(Y.body);if(F===null)F=t.asn1.fromDer(oe.bytes(),!1);var Q=t.util.createBuffer();u(Q,3,oe),w.putBuffer(Q)}if(R=t.pki.certificateFromAsn1(F),D)l.session.clientCertificate=R;else l.session.serverCertificate=R}catch(ge){return l.error(l,{message:"Could not send certificate list.",cause:ge,send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.bad_certificate}})}var ae=3+w.length(),ue=t.util.createBuffer();return ue.putByte(r.HandshakeType.certificate),ue.putInt24(ae),u(ue,3,w),ue},r.createClientKeyExchange=function(l){var D=t.util.createBuffer();D.putByte(l.session.clientHelloVersion.major),D.putByte(l.session.clientHelloVersion.minor),D.putBytes(t.random.getBytes(46));var R=l.session.sp;R.pre_master_secret=D.getBytes();var o=l.session.serverCertificate.publicKey;D=o.encrypt(R.pre_master_secret);var w=D.length+2,F=t.util.createBuffer();return F.putByte(r.HandshakeType.client_key_exchange),F.putInt24(w),F.putInt16(D.length),F.putBytes(D),F},r.createServerKeyExchange=function(l){var D=0,R=t.util.createBuffer();if(D>0)R.putByte(r.HandshakeType.server_key_exchange),R.putInt24(D);return R},r.getClientSignature=function(l,D){var R=t.util.createBuffer();R.putBuffer(l.session.md5.digest()),R.putBuffer(l.session.sha1.digest()),R=R.getBytes(),l.getSignature=l.getSignature||function(o,w,F){var K=null;if(o.getPrivateKey)try{K=o.getPrivateKey(o,o.session.clientCertificate),K=t.pki.privateKeyFromPem(K)}catch(Y){o.error(o,{message:"Could not get private key.",cause:Y,send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}})}if(K===null)o.error(o,{message:"No private key set.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}});else w=K.sign(w,null);F(o,w)},l.getSignature(l,R,D)},r.createCertificateVerify=function(l,D){var R=D.length+2,o=t.util.createBuffer();return o.putByte(r.HandshakeType.certificate_verify),o.putInt24(R),o.putInt16(D.length),o.putBytes(D),o},r.createCertificateRequest=function(l){var D=t.util.createBuffer();D.putByte(1);var R=t.util.createBuffer();for(var o in l.caStore.certs){var w=l.caStore.certs[o],F=t.pki.distinguishedNameToAsn1(w.subject),K=t.asn1.toDer(F);R.putInt16(K.length()),R.putBuffer(K)}var Y=1+D.length()+2+R.length(),ie=t.util.createBuffer();return ie.putByte(r.HandshakeType.certificate_request),ie.putInt24(Y),u(ie,1,D),u(ie,2,R),ie},r.createServerHelloDone=function(l){var D=t.util.createBuffer();return D.putByte(r.HandshakeType.server_hello_done),D.putInt24(0),D},r.createChangeCipherSpec=function(){var l=t.util.createBuffer();return l.putByte(1),l},r.createFinished=function(l){var D=t.util.createBuffer();D.putBuffer(l.session.md5.digest()),D.putBuffer(l.session.sha1.digest());var R=l.entity===r.ConnectionEnd.client,o=l.session.sp,w=12,F=e,K=R?"client finished":"server finished";D=F(o.master_secret,K,D.getBytes(),w);var Y=t.util.createBuffer();return Y.putByte(r.HandshakeType.finished),Y.putInt24(D.length()),Y.putBuffer(D),Y},r.createHeartbeat=function(l,D,R){if(typeof R==="undefined")R=D.length;var o=t.util.createBuffer();o.putByte(l),o.putInt16(R),o.putBytes(D);var w=o.length(),F=Math.max(16,w-R-3);return o.putBytes(t.random.getBytes(F)),o},r.queue=function(l,D){if(!D)return;if(D.fragment.length()===0){if(D.type===r.ContentType.handshake||D.type===r.ContentType.alert||D.type===r.ContentType.change_cipher_spec)return}if(D.type===r.ContentType.handshake){var R=D.fragment.bytes();l.session.md5.update(R),l.session.sha1.update(R),R=null}var o;if(D.fragment.length()<=r.MaxFragment)o=[D];else{o=[];var w=D.fragment.bytes();while(w.length>r.MaxFragment)o.push(r.createRecord(l,{type:D.type,data:t.util.createBuffer(w.slice(0,r.MaxFragment))})),w=w.slice(r.MaxFragment);if(w.length>0)o.push(r.createRecord(l,{type:D.type,data:t.util.createBuffer(w)}))}for(var F=0;F<o.length&&!l.fail;++F){var K=o[F],Y=l.state.current.write;if(Y.update(l,K))l.records.push(K)}},r.flush=function(l){for(var D=0;D<l.records.length;++D){var R=l.records[D];l.tlsData.putByte(R.type),l.tlsData.putByte(R.version.major),l.tlsData.putByte(R.version.minor),l.tlsData.putInt16(R.fragment.length()),l.tlsData.putBuffer(l.records[D].fragment)}return l.records=[],l.tlsDataReady(l)};var ee=function(l){switch(l){case!0:return!0;case t.pki.certificateError.bad_certificate:return r.Alert.Description.bad_certificate;case t.pki.certificateError.unsupported_certificate:return r.Alert.Description.unsupported_certificate;case t.pki.certificateError.certificate_revoked:return r.Alert.Description.certificate_revoked;case t.pki.certificateError.certificate_expired:return r.Alert.Description.certificate_expired;case t.pki.certificateError.certificate_unknown:return r.Alert.Description.certificate_unknown;case t.pki.certificateError.unknown_ca:return r.Alert.Description.unknown_ca;default:return r.Alert.Description.bad_certificate}},Ae=function(l){switch(l){case!0:return!0;case r.Alert.Description.bad_certificate:return t.pki.certificateError.bad_certificate;case r.Alert.Description.unsupported_certificate:return t.pki.certificateError.unsupported_certificate;case r.Alert.Description.certificate_revoked:return t.pki.certificateError.certificate_revoked;case r.Alert.Description.certificate_expired:return t.pki.certificateError.certificate_expired;case r.Alert.Description.certificate_unknown:return t.pki.certificateError.certificate_unknown;case r.Alert.Description.unknown_ca:return t.pki.certificateError.unknown_ca;default:return t.pki.certificateError.bad_certificate}};r.verifyCertificateChain=function(l,D){try{var R={};for(var o in l.verifyOptions)R[o]=l.verifyOptions[o];R.verify=function(F,K,Y){var ie=ee(F),oe=l.verify(l,F,K,Y);if(oe!==!0){if(typeof oe==="object"&&!t.util.isArray(oe)){var Q=new Error("The application rejected the certificate.");if(Q.send=!0,Q.alert={level:r.Alert.Level.fatal,description:r.Alert.Description.bad_certificate},oe.message)Q.message=oe.message;if(oe.alert)Q.alert.description=oe.alert;throw Q}if(oe!==F)oe=Ae(oe)}return oe},t.pki.verifyCertificateChain(l.caStore,D,R)}catch(F){var w=F;if(typeof w!=="object"||t.util.isArray(w))w={send:!0,alert:{level:r.Alert.Level.fatal,description:ee(F)}};if(!("send"in w))w.send=!0;if(!("alert"in w))w.alert={level:r.Alert.Level.fatal,description:ee(w.error)};l.error(l,w)}return!l.fail},r.createSessionCache=function(l,D){var R=null;if(l&&l.getSession&&l.setSession&&l.order)R=l;else{R={},R.cache=l||{},R.capacity=Math.max(D||100,1),R.order=[];for(var o in l)if(R.order.length<=D)R.order.push(o);else delete l[o];R.getSession=function(w){var F=null,K=null;if(w)K=t.util.bytesToHex(w);else if(R.order.length>0)K=R.order[0];if(K!==null&&K in R.cache){F=R.cache[K],delete R.cache[K];for(var Y in R.order)if(R.order[Y]===K){R.order.splice(Y,1);break}}return F},R.setSession=function(w,F){if(R.order.length===R.capacity){var K=R.order.shift();delete R.cache[K]}var K=t.util.bytesToHex(w);R.order.push(K),R.cache[K]=F}}return R},r.createConnection=function(l){var D=null;if(l.caStore)if(t.util.isArray(l.caStore))D=t.pki.createCaStore(l.caStore);else D=l.caStore;else D=t.pki.createCaStore();var R=l.cipherSuites||null;if(R===null){R=[];for(var o in r.CipherSuites)R.push(r.CipherSuites[o])}var w=l.server?r.ConnectionEnd.server:r.ConnectionEnd.client,F=l.sessionCache?r.createSessionCache(l.sessionCache):null,K={version:{major:r.Version.major,minor:r.Version.minor},entity:w,sessionId:l.sessionId,caStore:D,sessionCache:F,cipherSuites:R,connected:l.connected,virtualHost:l.virtualHost||null,verifyClient:l.verifyClient||!1,verify:l.verify||function(Q,ae,ue,ge){return ae},verifyOptions:l.verifyOptions||{},getCertificate:l.getCertificate||null,getPrivateKey:l.getPrivateKey||null,getSignature:l.getSignature||null,input:t.util.createBuffer(),tlsData:t.util.createBuffer(),data:t.util.createBuffer(),tlsDataReady:l.tlsDataReady,dataReady:l.dataReady,heartbeatReceived:l.heartbeatReceived,closed:l.closed,error:function(Q,ae){if(ae.origin=ae.origin||(Q.entity===r.ConnectionEnd.client?"client":"server"),ae.send)r.queue(Q,r.createAlert(Q,ae.alert)),r.flush(Q);var ue=ae.fatal!==!1;if(ue)Q.fail=!0;if(l.error(Q,ae),ue)Q.close(!1)},deflate:l.deflate||null,inflate:l.inflate||null};K.reset=function(Q){K.version={major:r.Version.major,minor:r.Version.minor},K.record=null,K.session=null,K.peerCertificate=null,K.state={pending:null,current:null},K.expect=K.entity===r.ConnectionEnd.client?m:s,K.fragmented=null,K.records=[],K.open=!1,K.handshakes=0,K.handshaking=!1,K.isConnected=!1,K.fail=!(Q||typeof Q==="undefined"),K.input.clear(),K.tlsData.clear(),K.data.clear(),K.state.current=r.createConnectionState(K)},K.reset();var Y=function(Q,ae){var ue=ae.type-r.ContentType.change_cipher_spec,ge=G[Q.entity][Q.expect];if(ue in ge)ge[ue](Q,ae);else r.handleUnexpected(Q,ae)},ie=function(Q){var ae=0,ue=Q.input,ge=ue.length();if(ge<5)ae=5-ge;else{Q.record={type:ue.getByte(),version:{major:ue.getByte(),minor:ue.getByte()},length:ue.getInt16(),fragment:t.util.createBuffer(),ready:!1};var he=Q.record.version.major===Q.version.major;if(he&&Q.session&&Q.session.version)he=Q.record.version.minor===Q.version.minor;if(!he)Q.error(Q,{message:"Incompatible TLS version.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.protocol_version}})}return ae},oe=function(Q){var ae=0,ue=Q.input,ge=ue.length();if(ge<Q.record.length)ae=Q.record.length-ge;else{Q.record.fragment.putBytes(ue.getBytes(Q.record.length)),ue.compact();var he=Q.state.current.read;if(he.update(Q,Q.record)){if(Q.fragmented!==null)if(Q.fragmented.type===Q.record.type)Q.fragmented.fragment.putBuffer(Q.record.fragment),Q.record=Q.fragmented;else Q.error(Q,{message:"Invalid fragmented record.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.unexpected_message}});Q.record.ready=!0}}return ae};return K.handshake=function(Q){if(K.entity!==r.ConnectionEnd.client)K.error(K,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(K.handshaking)K.error(K,{message:"Handshake already in progress.",fatal:!1});else{if(K.fail&&!K.open&&K.handshakes===0)K.fail=!1;K.handshaking=!0,Q=Q||"";var ae=null;if(Q.length>0){if(K.sessionCache)ae=K.sessionCache.getSession(Q);if(ae===null)Q=""}if(Q.length===0&&K.sessionCache){if(ae=K.sessionCache.getSession(),ae!==null)Q=ae.id}if(K.session={id:Q,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:t.md.md5.create(),sha1:t.md.sha1.create()},ae)K.version=ae.version,K.session.sp=ae.sp;K.session.sp.client_random=r.createRandom().getBytes(),K.open=!0,r.queue(K,r.createRecord(K,{type:r.ContentType.handshake,data:r.createClientHello(K)})),r.flush(K)}},K.process=function(Q){var ae=0;if(Q)K.input.putBytes(Q);if(!K.fail){if(K.record!==null&&K.record.ready&&K.record.fragment.isEmpty())K.record=null;if(K.record===null)ae=ie(K);if(!K.fail&&K.record!==null&&!K.record.ready)ae=oe(K);if(!K.fail&&K.record!==null&&K.record.ready)Y(K,K.record)}return ae},K.prepare=function(Q){return r.queue(K,r.createRecord(K,{type:r.ContentType.application_data,data:t.util.createBuffer(Q)})),r.flush(K)},K.prepareHeartbeatRequest=function(Q,ae){if(Q instanceof t.util.ByteBuffer)Q=Q.bytes();if(typeof ae==="undefined")ae=Q.length;return K.expectedHeartbeatPayload=Q,r.queue(K,r.createRecord(K,{type:r.ContentType.heartbeat,data:r.createHeartbeat(r.HeartbeatMessageType.heartbeat_request,Q,ae)})),r.flush(K)},K.close=function(Q){if(!K.fail&&K.sessionCache&&K.session){var ae={id:K.session.id,version:K.session.version,sp:K.session.sp};ae.sp.keys=null,K.sessionCache.setSession(ae.id,ae)}if(K.open){if(K.open=!1,K.input.clear(),K.isConnected||K.handshaking)K.isConnected=K.handshaking=!1,r.queue(K,r.createAlert(K,{level:r.Alert.Level.warning,description:r.Alert.Description.close_notify})),r.flush(K);K.closed(K)}K.reset(Q)},K},_.exports=t.tls=t.tls||{};for(de in r)if(typeof r[de]!=="function")t.tls[de]=r[de];var de;t.tls.prf_tls1=e,t.tls.hmac_sha1=a,t.tls.createSessionCache=r.createSessionCache,t.tls.createConnection=r.createConnection}),Mi=le((N,_)=>{var t=pe();Tt(),Zr();var e=_.exports=t.tls;e.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(m){m.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,m.cipher_type=e.CipherType.block,m.enc_key_length=16,m.block_length=16,m.fixed_iv_length=16,m.record_iv_length=16,m.mac_algorithm=e.MACAlgorithm.hmac_sha1,m.mac_length=20,m.mac_key_length=20},initConnectionState:a},e.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(m){m.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,m.cipher_type=e.CipherType.block,m.enc_key_length=32,m.block_length=16,m.fixed_iv_length=16,m.record_iv_length=16,m.mac_algorithm=e.MACAlgorithm.hmac_sha1,m.mac_length=20,m.mac_key_length=20},initConnectionState:a};function a(m,f,I){var U=f.entity===t.tls.ConnectionEnd.client;m.read.cipherState={init:!1,cipher:t.cipher.createDecipher("AES-CBC",U?I.keys.server_write_key:I.keys.client_write_key),iv:U?I.keys.server_write_IV:I.keys.client_write_IV},m.write.cipherState={init:!1,cipher:t.cipher.createCipher("AES-CBC",U?I.keys.client_write_key:I.keys.server_write_key),iv:U?I.keys.client_write_IV:I.keys.server_write_IV},m.read.cipherFunction=u,m.write.cipherFunction=d,m.read.macLength=m.write.macLength=I.mac_length,m.read.macFunction=m.write.macFunction=e.hmac_sha1}function d(m,f){var I=!1,U=f.macFunction(f.macKey,f.sequenceNumber,m);m.fragment.putBytes(U),f.updateSequenceNumber();var S;if(m.version.minor===e.Versions.TLS_1_0.minor)S=f.cipherState.init?null:f.cipherState.iv;else S=t.random.getBytesSync(16);f.cipherState.init=!0;var c=f.cipherState.cipher;if(c.start({iv:S}),m.version.minor>=e.Versions.TLS_1_1.minor)c.output.putBytes(S);if(c.update(m.fragment),c.finish(g))m.fragment=c.output,m.length=m.fragment.length(),I=!0;return I}function g(m,f,I){if(!I){var U=m-f.length()%m;f.fillWithByte(U-1,U)}return!0}function v(m,f,I){var U=!0;if(I){var S=f.length(),c=f.last();for(var C=S-1-c;C<S-1;++C)U=U&&f.at(C)==c;if(U)f.truncate(c+1)}return U}function u(m,f){var I=!1,U;if(m.version.minor===e.Versions.TLS_1_0.minor)U=f.cipherState.init?null:f.cipherState.iv;else U=m.fragment.getBytes(16);f.cipherState.init=!0;var S=f.cipherState.cipher;S.start({iv:U}),S.update(m.fragment),I=S.finish(v);var c=f.macLength,C=t.random.getBytesSync(c),T=S.output.length();if(T>=c)m.fragment=S.output.getBytes(T-c),C=S.output.getBytes(c);else m.fragment=S.output.getBytes();m.fragment=t.util.createBuffer(m.fragment),m.length=m.fragment.length();var E=f.macFunction(f.macKey,f.sequenceNumber,m);return f.updateSequenceNumber(),I=r(f.macKey,C,E)&&I,I}function r(m,f,I){var U=t.hmac.create();return U.start("SHA1",m),U.update(f),f=U.digest().getBytes(),U.start(null,null),U.update(I),I=U.digest().getBytes(),f===I}}),$r=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.sha512=t.sha512||{};t.md.sha512=t.md.algorithms.sha512=e;var a=t.sha384=t.sha512.sha384=t.sha512.sha384||{};a.create=function(){return e.create("SHA-384")},t.md.sha384=t.md.algorithms.sha384=a,t.sha512.sha256=t.sha512.sha256||{create:function(){return e.create("SHA-512/256")}},t.md["sha512/256"]=t.md.algorithms["sha512/256"]=t.sha512.sha256,t.sha512.sha224=t.sha512.sha224||{create:function(){return e.create("SHA-512/224")}},t.md["sha512/224"]=t.md.algorithms["sha512/224"]=t.sha512.sha224,e.create=function(f){if(!g)r();if(typeof f==="undefined")f="SHA-512";if(!(f in u))throw new Error("Invalid SHA-512 algorithm: "+f);var I=u[f],U=null,S=t.util.createBuffer(),c=new Array(80);for(var C=0;C<80;++C)c[C]=new Array(2);var T=64;switch(f){case"SHA-384":T=48;break;case"SHA-512/256":T=32;break;case"SHA-512/224":T=28;break}var E={algorithm:f.replace("-","").toLowerCase(),blockLength:128,digestLength:T,messageLength:0,fullMessageLength:null,messageLengthSize:16};return E.start=function(){E.messageLength=0,E.fullMessageLength=E.messageLength128=[];var s=E.messageLengthSize/4;for(var p=0;p<s;++p)E.fullMessageLength.push(0);S=t.util.createBuffer(),U=new Array(I.length);for(var p=0;p<I.length;++p)U[p]=I[p].slice(0);return E},E.start(),E.update=function(s,p){if(p==="utf8")s=t.util.encodeUtf8(s);var y=s.length;E.messageLength+=y,y=[y/4294967296>>>0,y>>>0];for(var b=E.fullMessageLength.length-1;b>=0;--b)E.fullMessageLength[b]+=y[1],y[1]=y[0]+(E.fullMessageLength[b]/4294967296>>>0),E.fullMessageLength[b]=E.fullMessageLength[b]>>>0,y[0]=y[1]/4294967296>>>0;if(S.putBytes(s),m(U,c,S),S.read>2048||S.length()===0)S.compact();return E},E.digest=function(){var s=t.util.createBuffer();s.putBytes(S.bytes());var p=E.fullMessageLength[E.fullMessageLength.length-1]+E.messageLengthSize,y=p&E.blockLength-1;s.putBytes(d.substr(0,E.blockLength-y));var b,L,h=E.fullMessageLength[0]*8;for(var n=0;n<E.fullMessageLength.length-1;++n)b=E.fullMessageLength[n+1]*8,L=b/4294967296>>>0,h+=L,s.putInt32(h>>>0),h=b>>>0;s.putInt32(h);var i=new Array(U.length);for(var n=0;n<U.length;++n)i[n]=U[n].slice(0);m(i,c,s);var B=t.util.createBuffer(),V;if(f==="SHA-512")V=i.length;else if(f==="SHA-384")V=i.length-2;else V=i.length-4;for(var n=0;n<V;++n)if(B.putInt32(i[n][0]),n!==V-1||f!=="SHA-512/224")B.putInt32(i[n][1]);return B},E};var d=null,g=!1,v=null,u=null;function r(){d=String.fromCharCode(128),d+=t.util.fillString(String.fromCharCode(0),128),v=[[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]],u={},u["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],g=!0}function m(f,I,U){var S,c,C,T,E,s,p,y,b,L,h,n,i,B,V,O,P,M,G,q,H,X,J,te,se,fe,ve,Ie,Z,me,ee,Ae,de,l,D,R=U.length();while(R>=128){for(Z=0;Z<16;++Z)I[Z][0]=U.getInt32()>>>0,I[Z][1]=U.getInt32()>>>0;for(;Z<80;++Z)Ae=I[Z-2],me=Ae[0],ee=Ae[1],S=((me>>>19|ee<<13)^(ee>>>29|me<<3)^me>>>6)>>>0,c=((me<<13|ee>>>19)^(ee<<3|me>>>29)^(me<<26|ee>>>6))>>>0,l=I[Z-15],me=l[0],ee=l[1],C=((me>>>1|ee<<31)^(me>>>8|ee<<24)^me>>>7)>>>0,T=((me<<31|ee>>>1)^(me<<24|ee>>>8)^(me<<25|ee>>>7))>>>0,de=I[Z-7],D=I[Z-16],ee=c+de[1]+T+D[1],I[Z][0]=S+de[0]+C+D[0]+(ee/4294967296>>>0)>>>0,I[Z][1]=ee>>>0;i=f[0][0],B=f[0][1],V=f[1][0],O=f[1][1],P=f[2][0],M=f[2][1],G=f[3][0],q=f[3][1],H=f[4][0],X=f[4][1],J=f[5][0],te=f[5][1],se=f[6][0],fe=f[6][1],ve=f[7][0],Ie=f[7][1];for(Z=0;Z<80;++Z)p=((H>>>14|X<<18)^(H>>>18|X<<14)^(X>>>9|H<<23))>>>0,y=((H<<18|X>>>14)^(H<<14|X>>>18)^(X<<23|H>>>9))>>>0,b=(se^H&(J^se))>>>0,L=(fe^X&(te^fe))>>>0,E=((i>>>28|B<<4)^(B>>>2|i<<30)^(B>>>7|i<<25))>>>0,s=((i<<4|B>>>28)^(B<<30|i>>>2)^(B<<25|i>>>7))>>>0,h=(i&V|P&(i^V))>>>0,n=(B&O|M&(B^O))>>>0,ee=Ie+y+L+v[Z][1]+I[Z][1],S=ve+p+b+v[Z][0]+I[Z][0]+(ee/4294967296>>>0)>>>0,c=ee>>>0,ee=s+n,C=E+h+(ee/4294967296>>>0)>>>0,T=ee>>>0,ve=se,Ie=fe,se=J,fe=te,J=H,te=X,ee=q+c,H=G+S+(ee/4294967296>>>0)>>>0,X=ee>>>0,G=P,q=M,P=V,M=O,V=i,O=B,ee=c+T,i=S+C+(ee/4294967296>>>0)>>>0,B=ee>>>0;ee=f[0][1]+B,f[0][0]=f[0][0]+i+(ee/4294967296>>>0)>>>0,f[0][1]=ee>>>0,ee=f[1][1]+O,f[1][0]=f[1][0]+V+(ee/4294967296>>>0)>>>0,f[1][1]=ee>>>0,ee=f[2][1]+M,f[2][0]=f[2][0]+P+(ee/4294967296>>>0)>>>0,f[2][1]=ee>>>0,ee=f[3][1]+q,f[3][0]=f[3][0]+G+(ee/4294967296>>>0)>>>0,f[3][1]=ee>>>0,ee=f[4][1]+X,f[4][0]=f[4][0]+H+(ee/4294967296>>>0)>>>0,f[4][1]=ee>>>0,ee=f[5][1]+te,f[5][0]=f[5][0]+J+(ee/4294967296>>>0)>>>0,f[5][1]=ee>>>0,ee=f[6][1]+fe,f[6][0]=f[6][0]+se+(ee/4294967296>>>0)>>>0,f[6][1]=ee>>>0,ee=f[7][1]+Ie,f[7][0]=f[7][0]+ve+(ee/4294967296>>>0)>>>0,f[7][1]=ee>>>0,R-=128}}}),Fi=le((N)=>{var _=pe();lt();var t=_.asn1;N.privateKeyValidator={name:"PrivateKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},N.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}}),ji=le((N,_)=>{var t=pe();Xt(),ct(),$r(),Ce();var e=Fi(),a=e.publicKeyValidator,d=e.privateKeyValidator;if(typeof g==="undefined")g=t.jsbn.BigInteger;var g,v=t.util.ByteBuffer,u=typeof Buffer==="undefined"?Uint8Array:Buffer;t.pki=t.pki||{},_.exports=t.pki.ed25519=t.ed25519=t.ed25519||{};var r=t.ed25519;r.constants={},r.constants.PUBLIC_KEY_BYTE_LENGTH=32,r.constants.PRIVATE_KEY_BYTE_LENGTH=64,r.constants.SEED_BYTE_LENGTH=32,r.constants.SIGN_BYTE_LENGTH=64,r.constants.HASH_BYTE_LENGTH=64,r.generateKeyPair=function(l){l=l||{};var D=l.seed;if(D===void 0)D=t.random.getBytesSync(r.constants.SEED_BYTE_LENGTH);else if(typeof D==="string"){if(D.length!==r.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+r.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(D instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');D=m({message:D,encoding:"binary"});var R=new u(r.constants.PUBLIC_KEY_BYTE_LENGTH),o=new u(r.constants.PRIVATE_KEY_BYTE_LENGTH);for(var w=0;w<32;++w)o[w]=D[w];return p(R,o),{publicKey:R,privateKey:o}},r.privateKeyFromAsn1=function(l){var D={},R=[],o=t.asn1.validate(l,d,D,R);if(!o){var w=new Error("Invalid Key.");throw w.errors=R,w}var F=t.asn1.derToOid(D.privateKeyOid),K=t.oids.EdDSA25519;if(F!==K)throw new Error('Invalid OID "'+F+'"; OID must be "'+K+'".');var Y=D.privateKey,ie=m({message:t.asn1.fromDer(Y).value,encoding:"binary"});return{privateKeyBytes:ie}},r.publicKeyFromAsn1=function(l){var D={},R=[],o=t.asn1.validate(l,a,D,R);if(!o){var w=new Error("Invalid Key.");throw w.errors=R,w}var F=t.asn1.derToOid(D.publicKeyOid),K=t.oids.EdDSA25519;if(F!==K)throw new Error('Invalid OID "'+F+'"; OID must be "'+K+'".');var Y=D.ed25519PublicKey;if(Y.length!==r.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return m({message:Y,encoding:"binary"})},r.publicKeyFromPrivateKey=function(l){l=l||{};var D=m({message:l.privateKey,encoding:"binary"});if(D.length!==r.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+r.constants.PRIVATE_KEY_BYTE_LENGTH);var R=new u(r.constants.PUBLIC_KEY_BYTE_LENGTH);for(var o=0;o<R.length;++o)R[o]=D[32+o];return R},r.sign=function(l){l=l||{};var D=m(l),R=m({message:l.privateKey,encoding:"binary"});if(R.length===r.constants.SEED_BYTE_LENGTH){var o=r.generateKeyPair({seed:R});R=o.privateKey}else if(R.length!==r.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+r.constants.SEED_BYTE_LENGTH+" or "+r.constants.PRIVATE_KEY_BYTE_LENGTH);var w=new u(r.constants.SIGN_BYTE_LENGTH+D.length);y(w,D,D.length,R);var F=new u(r.constants.SIGN_BYTE_LENGTH);for(var K=0;K<F.length;++K)F[K]=w[K];return F},r.verify=function(l){l=l||{};var D=m(l);if(l.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var R=m({message:l.signature,encoding:"binary"});if(R.length!==r.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+r.constants.SIGN_BYTE_LENGTH);var o=m({message:l.publicKey,encoding:"binary"});if(o.length!==r.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+r.constants.PUBLIC_KEY_BYTE_LENGTH);var w=new u(r.constants.SIGN_BYTE_LENGTH+D.length),F=new u(r.constants.SIGN_BYTE_LENGTH+D.length),K;for(K=0;K<r.constants.SIGN_BYTE_LENGTH;++K)w[K]=R[K];for(K=0;K<D.length;++K)w[K+r.constants.SIGN_BYTE_LENGTH]=D[K];return b(F,w,w.length,o)>=0};function m(l){var D=l.message;if(D instanceof Uint8Array||D instanceof u)return D;var R=l.encoding;if(D===void 0)if(l.md)D=l.md.digest().getBytes(),R="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof D==="string"&&!R)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof D==="string"){if(typeof Buffer!=="undefined")return Buffer.from(D,R);D=new v(D,R)}else if(!(D instanceof v))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');var o=new u(D.length());for(var w=0;w<o.length;++w)o[w]=D.at(w);return o}var f=Z(),I=Z([1]),U=Z([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),S=Z([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),c=Z([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),C=Z([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),T=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]),E=Z([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function s(l,D){var R=t.md.sha512.create(),o=new v(l);R.update(o.getBytes(D),"binary");var w=R.digest().getBytes();if(typeof Buffer!=="undefined")return Buffer.from(w,"binary");var F=new u(r.constants.HASH_BYTE_LENGTH);for(var K=0;K<64;++K)F[K]=w.charCodeAt(K);return F}function p(l,D){var R=[Z(),Z(),Z(),Z()],o,w=s(D,32);w[0]&=248,w[31]&=127,w[31]|=64,te(R,w),B(l,R);for(o=0;o<32;++o)D[o+32]=l[o];return 0}function y(l,D,R,o){var w,F,K=new Float64Array(64),Y=[Z(),Z(),Z(),Z()],ie=s(o,32);ie[0]&=248,ie[31]&=127,ie[31]|=64;var oe=R+64;for(w=0;w<R;++w)l[64+w]=D[w];for(w=0;w<32;++w)l[32+w]=ie[32+w];var Q=s(l.subarray(32),R+32);h(Q),te(Y,Q),B(l,Y);for(w=32;w<64;++w)l[w]=o[w];var ae=s(l,R+64);h(ae);for(w=32;w<64;++w)K[w]=0;for(w=0;w<32;++w)K[w]=Q[w];for(w=0;w<32;++w)for(F=0;F<32;F++)K[w+F]+=ae[w]*ie[F];return L(l.subarray(32),K),oe}function b(l,D,R,o){var w,F,K=new u(32),Y=[Z(),Z(),Z(),Z()],ie=[Z(),Z(),Z(),Z()];if(F=-1,R<64)return-1;if(O(ie,o))return-1;for(w=0;w<R;++w)l[w]=D[w];for(w=0;w<32;++w)l[w+32]=o[w];var oe=s(l,R);if(h(oe),J(Y,ie,oe),te(ie,D.subarray(32)),n(Y,ie),B(K,Y),R-=64,q(D,0,K,0)){for(w=0;w<R;++w)l[w]=0;return-1}for(w=0;w<R;++w)l[w]=D[w+64];return F=R,F}function L(l,D){var R,o,w,F;for(o=63;o>=32;--o){R=0;for(w=o-32,F=o-12;w<F;++w)D[w]+=R-16*D[o]*T[w-(o-32)],R=D[w]+128>>8,D[w]-=R*256;D[w]+=R,D[o]=0}R=0;for(w=0;w<32;++w)D[w]+=R-(D[31]>>4)*T[w],R=D[w]>>8,D[w]&=255;for(w=0;w<32;++w)D[w]-=R*T[w];for(o=0;o<32;++o)D[o+1]+=D[o]>>8,l[o]=D[o]&255}function h(l){var D=new Float64Array(64);for(var R=0;R<64;++R)D[R]=l[R],l[R]=0;L(l,D)}function n(l,D){var R=Z(),o=Z(),w=Z(),F=Z(),K=Z(),Y=Z(),ie=Z(),oe=Z(),Q=Z();ee(R,l[1],l[0]),ee(Q,D[1],D[0]),de(R,R,Q),me(o,l[0],l[1]),me(Q,D[0],D[1]),de(o,o,Q),de(w,l[3],D[3]),de(w,w,S),de(F,l[2],D[2]),me(F,F,F),ee(K,o,R),ee(Y,F,w),me(ie,F,w),me(oe,o,R),de(l[0],K,Y),de(l[1],oe,ie),de(l[2],ie,Y),de(l[3],K,oe)}function i(l,D,R){for(var o=0;o<4;++o)Ie(l[o],D[o],R)}function B(l,D){var R=Z(),o=Z(),w=Z();fe(w,D[2]),de(R,D[0],w),de(o,D[1],w),V(l,o),l[31]^=X(R)<<7}function V(l,D){var R,o,w,F=Z(),K=Z();for(R=0;R<16;++R)K[R]=D[R];ve(K),ve(K),ve(K);for(o=0;o<2;++o){F[0]=K[0]-65517;for(R=1;R<15;++R)F[R]=K[R]-65535-(F[R-1]>>16&1),F[R-1]&=65535;F[15]=K[15]-32767-(F[14]>>16&1),w=F[15]>>16&1,F[14]&=65535,Ie(K,F,1-w)}for(R=0;R<16;R++)l[2*R]=K[R]&255,l[2*R+1]=K[R]>>8}function O(l,D){var R=Z(),o=Z(),w=Z(),F=Z(),K=Z(),Y=Z(),ie=Z();if(se(l[2],I),P(l[1],D),Ae(w,l[1]),de(F,w,U),ee(w,w,l[2]),me(F,l[2],F),Ae(K,F),Ae(Y,K),de(ie,Y,K),de(R,ie,w),de(R,R,F),M(R,R),de(R,R,w),de(R,R,F),de(R,R,F),de(l[0],R,F),Ae(o,l[0]),de(o,o,F),G(o,w))de(l[0],l[0],E);if(Ae(o,l[0]),de(o,o,F),G(o,w))return-1;if(X(l[0])===D[31]>>7)ee(l[0],f,l[0]);return de(l[3],l[0],l[1]),0}function P(l,D){var R;for(R=0;R<16;++R)l[R]=D[2*R]+(D[2*R+1]<<8);l[15]&=32767}function M(l,D){var R=Z(),o;for(o=0;o<16;++o)R[o]=D[o];for(o=250;o>=0;--o)if(Ae(R,R),o!==1)de(R,R,D);for(o=0;o<16;++o)l[o]=R[o]}function G(l,D){var R=new u(32),o=new u(32);return V(R,l),V(o,D),q(R,0,o,0)}function q(l,D,R,o){return H(l,D,R,o,32)}function H(l,D,R,o,w){var F,K=0;for(F=0;F<w;++F)K|=l[D+F]^R[o+F];return(1&K-1>>>8)-1}function X(l){var D=new u(32);return V(D,l),D[0]&1}function J(l,D,R){var o,w;se(l[0],f),se(l[1],I),se(l[2],I),se(l[3],f);for(w=255;w>=0;--w)o=R[w/8|0]>>(w&7)&1,i(l,D,o),n(D,l),n(l,l),i(l,D,o)}function te(l,D){var R=[Z(),Z(),Z(),Z()];se(R[0],c),se(R[1],C),se(R[2],I),de(R[3],c,C),J(l,R,D)}function se(l,D){var R;for(R=0;R<16;R++)l[R]=D[R]|0}function fe(l,D){var R=Z(),o;for(o=0;o<16;++o)R[o]=D[o];for(o=253;o>=0;--o)if(Ae(R,R),o!==2&&o!==4)de(R,R,D);for(o=0;o<16;++o)l[o]=R[o]}function ve(l){var D,R,o=1;for(D=0;D<16;++D)R=l[D]+o+65535,o=Math.floor(R/65536),l[D]=R-o*65536;l[0]+=o-1+37*(o-1)}function Ie(l,D,R){var o,w=~(R-1);for(var F=0;F<16;++F)o=w&(l[F]^D[F]),l[F]^=o,D[F]^=o}function Z(l){var D,R=new Float64Array(16);if(l)for(D=0;D<l.length;++D)R[D]=l[D];return R}function me(l,D,R){for(var o=0;o<16;++o)l[o]=D[o]+R[o]}function ee(l,D,R){for(var o=0;o<16;++o)l[o]=D[o]-R[o]}function Ae(l,D){de(l,D,D)}function de(l,D,R){var o,w,F=0,K=0,Y=0,ie=0,oe=0,Q=0,ae=0,ue=0,ge=0,he=0,be=0,ke=0,we=0,Be=0,Se=0,Te=0,Le=0,We=0,De=0,Ze=0,$e=0,Je=0,et=0,at=0,ut=0,ht=0,gt=0,Et=0,bt=0,Dt=0,jt=0,Ue=R[0],Ve=R[1],Pe=R[2],xe=R[3],Ke=R[4],Oe=R[5],Me=R[6],Fe=R[7],je=R[8],Ge=R[9],qe=R[10],He=R[11],Qe=R[12],ze=R[13],Ne=R[14],Re=R[15];o=D[0],F+=o*Ue,K+=o*Ve,Y+=o*Pe,ie+=o*xe,oe+=o*Ke,Q+=o*Oe,ae+=o*Me,ue+=o*Fe,ge+=o*je,he+=o*Ge,be+=o*qe,ke+=o*He,we+=o*Qe,Be+=o*ze,Se+=o*Ne,Te+=o*Re,o=D[1],K+=o*Ue,Y+=o*Ve,ie+=o*Pe,oe+=o*xe,Q+=o*Ke,ae+=o*Oe,ue+=o*Me,ge+=o*Fe,he+=o*je,be+=o*Ge,ke+=o*qe,we+=o*He,Be+=o*Qe,Se+=o*ze,Te+=o*Ne,Le+=o*Re,o=D[2],Y+=o*Ue,ie+=o*Ve,oe+=o*Pe,Q+=o*xe,ae+=o*Ke,ue+=o*Oe,ge+=o*Me,he+=o*Fe,be+=o*je,ke+=o*Ge,we+=o*qe,Be+=o*He,Se+=o*Qe,Te+=o*ze,Le+=o*Ne,We+=o*Re,o=D[3],ie+=o*Ue,oe+=o*Ve,Q+=o*Pe,ae+=o*xe,ue+=o*Ke,ge+=o*Oe,he+=o*Me,be+=o*Fe,ke+=o*je,we+=o*Ge,Be+=o*qe,Se+=o*He,Te+=o*Qe,Le+=o*ze,We+=o*Ne,De+=o*Re,o=D[4],oe+=o*Ue,Q+=o*Ve,ae+=o*Pe,ue+=o*xe,ge+=o*Ke,he+=o*Oe,be+=o*Me,ke+=o*Fe,we+=o*je,Be+=o*Ge,Se+=o*qe,Te+=o*He,Le+=o*Qe,We+=o*ze,De+=o*Ne,Ze+=o*Re,o=D[5],Q+=o*Ue,ae+=o*Ve,ue+=o*Pe,ge+=o*xe,he+=o*Ke,be+=o*Oe,ke+=o*Me,we+=o*Fe,Be+=o*je,Se+=o*Ge,Te+=o*qe,Le+=o*He,We+=o*Qe,De+=o*ze,Ze+=o*Ne,$e+=o*Re,o=D[6],ae+=o*Ue,ue+=o*Ve,ge+=o*Pe,he+=o*xe,be+=o*Ke,ke+=o*Oe,we+=o*Me,Be+=o*Fe,Se+=o*je,Te+=o*Ge,Le+=o*qe,We+=o*He,De+=o*Qe,Ze+=o*ze,$e+=o*Ne,Je+=o*Re,o=D[7],ue+=o*Ue,ge+=o*Ve,he+=o*Pe,be+=o*xe,ke+=o*Ke,we+=o*Oe,Be+=o*Me,Se+=o*Fe,Te+=o*je,Le+=o*Ge,We+=o*qe,De+=o*He,Ze+=o*Qe,$e+=o*ze,Je+=o*Ne,et+=o*Re,o=D[8],ge+=o*Ue,he+=o*Ve,be+=o*Pe,ke+=o*xe,we+=o*Ke,Be+=o*Oe,Se+=o*Me,Te+=o*Fe,Le+=o*je,We+=o*Ge,De+=o*qe,Ze+=o*He,$e+=o*Qe,Je+=o*ze,et+=o*Ne,at+=o*Re,o=D[9],he+=o*Ue,be+=o*Ve,ke+=o*Pe,we+=o*xe,Be+=o*Ke,Se+=o*Oe,Te+=o*Me,Le+=o*Fe,We+=o*je,De+=o*Ge,Ze+=o*qe,$e+=o*He,Je+=o*Qe,et+=o*ze,at+=o*Ne,ut+=o*Re,o=D[10],be+=o*Ue,ke+=o*Ve,we+=o*Pe,Be+=o*xe,Se+=o*Ke,Te+=o*Oe,Le+=o*Me,We+=o*Fe,De+=o*je,Ze+=o*Ge,$e+=o*qe,Je+=o*He,et+=o*Qe,at+=o*ze,ut+=o*Ne,ht+=o*Re,o=D[11],ke+=o*Ue,we+=o*Ve,Be+=o*Pe,Se+=o*xe,Te+=o*Ke,Le+=o*Oe,We+=o*Me,De+=o*Fe,Ze+=o*je,$e+=o*Ge,Je+=o*qe,et+=o*He,at+=o*Qe,ut+=o*ze,ht+=o*Ne,gt+=o*Re,o=D[12],we+=o*Ue,Be+=o*Ve,Se+=o*Pe,Te+=o*xe,Le+=o*Ke,We+=o*Oe,De+=o*Me,Ze+=o*Fe,$e+=o*je,Je+=o*Ge,et+=o*qe,at+=o*He,ut+=o*Qe,ht+=o*ze,gt+=o*Ne,Et+=o*Re,o=D[13],Be+=o*Ue,Se+=o*Ve,Te+=o*Pe,Le+=o*xe,We+=o*Ke,De+=o*Oe,Ze+=o*Me,$e+=o*Fe,Je+=o*je,et+=o*Ge,at+=o*qe,ut+=o*He,ht+=o*Qe,gt+=o*ze,Et+=o*Ne,bt+=o*Re,o=D[14],Se+=o*Ue,Te+=o*Ve,Le+=o*Pe,We+=o*xe,De+=o*Ke,Ze+=o*Oe,$e+=o*Me,Je+=o*Fe,et+=o*je,at+=o*Ge,ut+=o*qe,ht+=o*He,gt+=o*Qe,Et+=o*ze,bt+=o*Ne,Dt+=o*Re,o=D[15],Te+=o*Ue,Le+=o*Ve,We+=o*Pe,De+=o*xe,Ze+=o*Ke,$e+=o*Oe,Je+=o*Me,et+=o*Fe,at+=o*je,ut+=o*Ge,ht+=o*qe,gt+=o*He,Et+=o*Qe,bt+=o*ze,Dt+=o*Ne,jt+=o*Re,F+=38*Le,K+=38*We,Y+=38*De,ie+=38*Ze,oe+=38*$e,Q+=38*Je,ae+=38*et,ue+=38*at,ge+=38*ut,he+=38*ht,be+=38*gt,ke+=38*Et,we+=38*bt,Be+=38*Dt,Se+=38*jt,w=1,o=F+w+65535,w=Math.floor(o/65536),F=o-w*65536,o=K+w+65535,w=Math.floor(o/65536),K=o-w*65536,o=Y+w+65535,w=Math.floor(o/65536),Y=o-w*65536,o=ie+w+65535,w=Math.floor(o/65536),ie=o-w*65536,o=oe+w+65535,w=Math.floor(o/65536),oe=o-w*65536,o=Q+w+65535,w=Math.floor(o/65536),Q=o-w*65536,o=ae+w+65535,w=Math.floor(o/65536),ae=o-w*65536,o=ue+w+65535,w=Math.floor(o/65536),ue=o-w*65536,o=ge+w+65535,w=Math.floor(o/65536),ge=o-w*65536,o=he+w+65535,w=Math.floor(o/65536),he=o-w*65536,o=be+w+65535,w=Math.floor(o/65536),be=o-w*65536,o=ke+w+65535,w=Math.floor(o/65536),ke=o-w*65536,o=we+w+65535,w=Math.floor(o/65536),we=o-w*65536,o=Be+w+65535,w=Math.floor(o/65536),Be=o-w*65536,o=Se+w+65535,w=Math.floor(o/65536),Se=o-w*65536,o=Te+w+65535,w=Math.floor(o/65536),Te=o-w*65536,F+=w-1+37*(w-1),w=1,o=F+w+65535,w=Math.floor(o/65536),F=o-w*65536,o=K+w+65535,w=Math.floor(o/65536),K=o-w*65536,o=Y+w+65535,w=Math.floor(o/65536),Y=o-w*65536,o=ie+w+65535,w=Math.floor(o/65536),ie=o-w*65536,o=oe+w+65535,w=Math.floor(o/65536),oe=o-w*65536,o=Q+w+65535,w=Math.floor(o/65536),Q=o-w*65536,o=ae+w+65535,w=Math.floor(o/65536),ae=o-w*65536,o=ue+w+65535,w=Math.floor(o/65536),ue=o-w*65536,o=ge+w+65535,w=Math.floor(o/65536),ge=o-w*65536,o=he+w+65535,w=Math.floor(o/65536),he=o-w*65536,o=be+w+65535,w=Math.floor(o/65536),be=o-w*65536,o=ke+w+65535,w=Math.floor(o/65536),ke=o-w*65536,o=we+w+65535,w=Math.floor(o/65536),we=o-w*65536,o=Be+w+65535,w=Math.floor(o/65536),Be=o-w*65536,o=Se+w+65535,w=Math.floor(o/65536),Se=o-w*65536,o=Te+w+65535,w=Math.floor(o/65536),Te=o-w*65536,F+=w-1+37*(w-1),l[0]=F,l[1]=K,l[2]=Y,l[3]=ie,l[4]=oe,l[5]=Q,l[6]=ae,l[7]=ue,l[8]=ge,l[9]=he,l[10]=be,l[11]=ke,l[12]=we,l[13]=Be,l[14]=Se,l[15]=Te}}),Gi=le((N,_)=>{var t=pe();Ce(),ct(),Xt(),_.exports=t.kem=t.kem||{};var e=t.jsbn.BigInteger;t.kem.rsa={},t.kem.rsa.create=function(d,g){g=g||{};var v=g.prng||t.random,u={};return u.encrypt=function(r,m){var f=Math.ceil(r.n.bitLength()/8),I;do I=new e(t.util.bytesToHex(v.getBytesSync(f)),16).mod(r.n);while(I.compareTo(e.ONE)<=0);I=t.util.hexToBytes(I.toString(16));var U=f-I.length;if(U>0)I=t.util.fillString(String.fromCharCode(0),U)+I;var S=r.encrypt(I,"NONE"),c=d.generate(I,m);return{encapsulation:S,key:c}},u.decrypt=function(r,m,f){var I=r.decrypt(m,"NONE");return d.generate(I,f)},u},t.kem.kdf1=function(d,g){a(this,d,0,g||d.digestLength)},t.kem.kdf2=function(d,g){a(this,d,1,g||d.digestLength)};function a(d,g,v,u){d.generate=function(r,m){var f=new t.util.ByteBuffer,I=Math.ceil(m/u)+v,U=new t.util.ByteBuffer;for(var S=v;S<I;++S){U.putInt32(S),g.start(),g.update(r+U.getBytes());var c=g.digest();f.putBytes(c.getBytes(u))}return f.truncate(f.length()-m),f.getBytes()}}}),qi=le((N,_)=>{var t=pe();Ce(),_.exports=t.log=t.log||{},t.log.levels=["none","error","warning","info","debug","verbose","max"];var e={},a=[],d=null;t.log.LEVEL_LOCKED=2,t.log.NO_LEVEL_CHECK=4,t.log.INTERPOLATE=8;for(u=0;u<t.log.levels.length;++u)g=t.log.levels[u],e[g]={index:u,name:g.toUpperCase()};var g,u;t.log.logMessage=function(S){var c=e[S.level].index;for(var C=0;C<a.length;++C){var T=a[C];if(T.flags&t.log.NO_LEVEL_CHECK)T.f(S);else{var E=e[T.level].index;if(c<=E)T.f(T,S)}}},t.log.prepareStandard=function(S){if(!("standard"in S))S.standard=e[S.level].name+" ["+S.category+"] "+S.message},t.log.prepareFull=function(S){if(!("full"in S)){var c=[S.message];c=c.concat([]),S.full=t.util.format.apply(this,c)}},t.log.prepareStandardFull=function(S){if(!("standardFull"in S))t.log.prepareStandard(S),S.standardFull=S.standard},v=["error","warning","info","debug","verbose"];for(u=0;u<v.length;++u)(function(S){t.log[S]=function(c,C){var T=Array.prototype.slice.call(arguments).slice(2),E={timestamp:new Date,level:S,category:c,message:C,arguments:T};t.log.logMessage(E)}})(v[u]);var v,u;if(t.log.makeLogger=function(S){var c={flags:0,f:S};return t.log.setLevel(c,"none"),c},t.log.setLevel=function(S,c){var C=!1;if(S&&!(S.flags&t.log.LEVEL_LOCKED))for(var T=0;T<t.log.levels.length;++T){var E=t.log.levels[T];if(c==E){S.level=c,C=!0;break}}return C},t.log.lock=function(S,c){if(typeof c==="undefined"||c)S.flags|=t.log.LEVEL_LOCKED;else S.flags&=~t.log.LEVEL_LOCKED},t.log.addLogger=function(S){a.push(S)},typeof console!=="undefined"&&"log"in console){if(console.error&&console.warn&&console.info&&console.debug)m={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},f=function(S,c){t.log.prepareStandard(c);var C=m[c.level],T=[c.standard];T=T.concat(c.arguments.slice()),C.apply(console,T)},r=t.log.makeLogger(f);else f=function(S,c){t.log.prepareStandardFull(c),console.log(c.standardFull)},r=t.log.makeLogger(f);t.log.setLevel(r,"debug"),t.log.addLogger(r),d=r}else console={log:function(){}};var r,m,f;if(d!==null&&typeof window!=="undefined"&&window.location){if(I=new URL(window.location.href).searchParams,I.has("console.level"))t.log.setLevel(d,I.get("console.level").slice(-1)[0]);if(I.has("console.lock")){if(U=I.get("console.lock").slice(-1)[0],U=="true")t.log.lock(d)}}var I,U;t.log.consoleLogger=d}),Hi=le((N,_)=>{_.exports=yt(),lr(),Mt(),Fr(),$r()}),Qi=le((N,_)=>{var t=pe();Tt(),lt(),Yt(),It(),Rt(),zr(),ct(),Ce(),pr();var e=t.asn1,a=_.exports=t.pkcs7=t.pkcs7||{};a.messageFromPem=function(c){var C=t.pem.decode(c)[0];if(C.type!=="PKCS7"){var T=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw T.headerType=C.type,T}if(C.procType&&C.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var E=e.fromDer(C.body);return a.messageFromAsn1(E)},a.messageToPem=function(c,C){var T={type:"PKCS7",body:e.toDer(c.toAsn1()).getBytes()};return t.pem.encode(T,{maxline:C})},a.messageFromAsn1=function(c){var C={},T=[];if(!e.validate(c,a.asn1.contentInfoValidator,C,T)){var E=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw E.errors=T,E}var s=e.derToOid(C.contentType),p;switch(s){case t.pki.oids.envelopedData:p=a.createEnvelopedData();break;case t.pki.oids.encryptedData:p=a.createEncryptedData();break;case t.pki.oids.signedData:p=a.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+s+" is not (yet) supported.")}return p.fromAsn1(C.content.value[0]),p},a.createSignedData=function(){var c=null;return c={type:t.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(E){if(U(c,E,a.asn1.signedDataValidator),c.certificates=[],c.crls=[],c.digestAlgorithmIdentifiers=[],c.contentInfo=null,c.signerInfos=[],c.rawCapture.certificates){var s=c.rawCapture.certificates.value;for(var p=0;p<s.length;++p)c.certificates.push(t.pki.certificateFromAsn1(s[p]))}},toAsn1:function(){if(!c.contentInfo)c.sign();var E=[];for(var s=0;s<c.certificates.length;++s)E.push(t.pki.certificateToAsn1(c.certificates[s]));var p=[],y=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,c.digestAlgorithmIdentifiers),c.contentInfo])]);if(E.length>0)y.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,E));if(p.length>0)y.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,p));return y.value[0].value.push(e.create(e.Class.UNIVERSAL,e.Type.SET,!0,c.signerInfos)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),y])},addSigner:function(E){var{issuer:s,serialNumber:p}=E;if(E.certificate){var y=E.certificate;if(typeof y==="string")y=t.pki.certificateFromPem(y);s=y.issuer.attributes,p=y.serialNumber}var b=E.key;if(!b)throw new Error("Could not add PKCS#7 signer; no private key specified.");if(typeof b==="string")b=t.pki.privateKeyFromPem(b);var L=E.digestAlgorithm||t.pki.oids.sha1;switch(L){case t.pki.oids.sha1:case t.pki.oids.sha256:case t.pki.oids.sha384:case t.pki.oids.sha512:case t.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+L)}var h=E.authenticatedAttributes||[];if(h.length>0){var n=!1,i=!1;for(var B=0;B<h.length;++B){var V=h[B];if(!n&&V.type===t.pki.oids.contentType){if(n=!0,i)break;continue}if(!i&&V.type===t.pki.oids.messageDigest){if(i=!0,n)break;continue}}if(!n||!i)throw new 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.")}c.signers.push({key:b,version:1,issuer:s,serialNumber:p,digestAlgorithm:L,signatureAlgorithm:t.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:h,unauthenticatedAttributes:[]})},sign:function(E){if(E=E||{},typeof c.content!=="object"||c.contentInfo===null){if(c.contentInfo=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.pki.oids.data).getBytes())]),"content"in c){var s;if(c.content instanceof t.util.ByteBuffer)s=c.content.bytes();else if(typeof c.content==="string")s=t.util.encodeUtf8(c.content);if(E.detached)c.detachedContent=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,s);else c.contentInfo.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,s)]))}}if(c.signers.length===0)return;var p=C();T(p)},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(E){if(typeof E==="string")E=t.pki.certificateFromPem(E);c.certificates.push(E)},addCertificateRevokationList:function(E){throw new Error("PKCS#7 CRL support not yet implemented.")}},c;function C(){var E={};for(var s=0;s<c.signers.length;++s){var p=c.signers[s],y=p.digestAlgorithm;if(!(y in E))E[y]=t.md[t.pki.oids[y]].create();if(p.authenticatedAttributes.length===0)p.md=E[y];else p.md=t.md[t.pki.oids[y]].create()}c.digestAlgorithmIdentifiers=[];for(var y in E)c.digestAlgorithmIdentifiers.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(y).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]));return E}function T(E){var s;if(c.detachedContent)s=c.detachedContent;else s=c.contentInfo.value[1],s=s.value[0];if(!s)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var p=e.derToOid(c.contentInfo.value[0].value),y=e.toDer(s);y.getByte(),e.getBerValueLength(y),y=y.getBytes();for(var b in E)E[b].start().update(y);var L=new Date;for(var h=0;h<c.signers.length;++h){var n=c.signers[h];if(n.authenticatedAttributes.length===0){if(p!==t.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{n.authenticatedAttributesAsn1=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);var i=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[]);for(var B=0;B<n.authenticatedAttributes.length;++B){var V=n.authenticatedAttributes[B];if(V.type===t.pki.oids.messageDigest)V.value=E[n.digestAlgorithm].digest();else if(V.type===t.pki.oids.signingTime){if(!V.value)V.value=L}i.value.push(f(V)),n.authenticatedAttributesAsn1.value.push(f(V))}y=e.toDer(i).getBytes(),n.md.start().update(y)}n.signature=n.key.sign(n.md,"RSASSA-PKCS1-V1_5")}c.signerInfos=m(c.signers)}},a.createEncryptedData=function(){var c=null;return c={type:t.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(C){U(c,C,a.asn1.encryptedDataValidator)},decrypt:function(C){if(C!==void 0)c.encryptedContent.key=C;S(c)}},c},a.createEnvelopedData=function(){var c=null;return c={type:t.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(C){var T=U(c,C,a.asn1.envelopedDataValidator);c.recipients=v(T.recipientInfos.value)},toAsn1:function(){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,u(c.recipients)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,I(c.encryptedContent))])])])},findRecipient:function(C){var T=C.issuer.attributes;for(var E=0;E<c.recipients.length;++E){var s=c.recipients[E],p=s.issuer;if(s.serialNumber!==C.serialNumber)continue;if(p.length!==T.length)continue;var y=!0;for(var b=0;b<T.length;++b)if(p[b].type!==T[b].type||p[b].value!==T[b].value){y=!1;break}if(y)return s}return null},decrypt:function(C,T){if(c.encryptedContent.key===void 0&&C!==void 0&&T!==void 0)switch(C.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:case t.pki.oids.desCBC:var E=T.decrypt(C.encryptedContent.content);c.encryptedContent.key=t.util.createBuffer(E);break;default:throw new Error("Unsupported asymmetric cipher, OID "+C.encryptedContent.algorithm)}S(c)},addRecipient:function(C){c.recipients.push({version:0,issuer:C.issuer.attributes,serialNumber:C.serialNumber,encryptedContent:{algorithm:t.pki.oids.rsaEncryption,key:C.publicKey}})},encrypt:function(C,T){if(c.encryptedContent.content===void 0){T=T||c.encryptedContent.algorithm,C=C||c.encryptedContent.key;var E,s,p;switch(T){case t.pki.oids["aes128-CBC"]:E=16,s=16,p=t.aes.createEncryptionCipher;break;case t.pki.oids["aes192-CBC"]:E=24,s=16,p=t.aes.createEncryptionCipher;break;case t.pki.oids["aes256-CBC"]:E=32,s=16,p=t.aes.createEncryptionCipher;break;case t.pki.oids["des-EDE3-CBC"]:E=24,s=8,p=t.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+T)}if(C===void 0)C=t.util.createBuffer(t.random.getBytes(E));else if(C.length()!=E)throw new Error("Symmetric key has wrong length; got "+C.length()+" bytes, expected "+E+".");c.encryptedContent.algorithm=T,c.encryptedContent.key=C,c.encryptedContent.parameter=t.util.createBuffer(t.random.getBytes(s));var y=p(C);if(y.start(c.encryptedContent.parameter.copy()),y.update(c.content),!y.finish())throw new Error("Symmetric encryption failed.");c.encryptedContent.content=y.output}for(var b=0;b<c.recipients.length;++b){var L=c.recipients[b];if(L.encryptedContent.content!==void 0)continue;switch(L.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:L.encryptedContent.content=L.encryptedContent.key.encrypt(c.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+L.encryptedContent.algorithm)}}}},c};function d(c){var C={},T=[];if(!e.validate(c,a.asn1.recipientInfoValidator,C,T)){var E=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw E.errors=T,E}return{version:C.version.charCodeAt(0),issuer:t.pki.RDNAttributesAsArray(C.issuer),serialNumber:t.util.createBuffer(C.serial).toHex(),encryptedContent:{algorithm:e.derToOid(C.encAlgorithm),parameter:C.encParameter?C.encParameter.value:void 0,content:C.encKey}}}function g(c){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:c.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(c.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.encryptedContent.algorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.encryptedContent.content)])}function v(c){var C=[];for(var T=0;T<c.length;++T)C.push(d(c[T]));return C}function u(c){var C=[];for(var T=0;T<c.length;++T)C.push(g(c[T]));return C}function r(c){var C=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:c.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(c.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.digestAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])]);if(c.authenticatedAttributesAsn1)C.value.push(c.authenticatedAttributesAsn1);if(C.value.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.signatureAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])),C.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.signature)),c.unauthenticatedAttributes.length>0){var T=e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[]);for(var E=0;E<c.unauthenticatedAttributes.length;++E){var s=c.unauthenticatedAttributes[E];T.values.push(f(s))}C.value.push(T)}return C}function m(c){var C=[];for(var T=0;T<c.length;++T)C.push(r(c[T]));return C}function f(c){var C;if(c.type===t.pki.oids.contentType)C=e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.value).getBytes());else if(c.type===t.pki.oids.messageDigest)C=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.value.bytes());else if(c.type===t.pki.oids.signingTime){var T=new Date("1950-01-01T00:00:00Z"),E=new Date("2050-01-01T00:00:00Z"),s=c.value;if(typeof s==="string"){var p=Date.parse(s);if(!isNaN(p))s=new Date(p);else if(s.length===13)s=e.utcTimeToDate(s);else s=e.generalizedTimeToDate(s)}if(s>=T&&s<E)C=e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(s));else C=e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(s))}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[C])])}function I(c){return[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.pki.oids.data).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.algorithm).getBytes()),!c.parameter?void 0:e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.parameter.getBytes())]),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.content.getBytes())])]}function U(c,C,T){var E={},s=[];if(!e.validate(C,T,E,s)){var p=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw p.errors=p,p}var y=e.derToOid(E.contentType);if(y!==t.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(E.encryptedContent){var b="";if(t.util.isArray(E.encryptedContent))for(var L=0;L<E.encryptedContent.length;++L){if(E.encryptedContent[L].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");b+=E.encryptedContent[L].value}else b=E.encryptedContent;c.encryptedContent={algorithm:e.derToOid(E.encAlgorithm),parameter:t.util.createBuffer(E.encParameter.value),content:t.util.createBuffer(b)}}if(E.content){var b="";if(t.util.isArray(E.content))for(var L=0;L<E.content.length;++L){if(E.content[L].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");b+=E.content[L].value}else b=E.content;c.content=t.util.createBuffer(b)}return c.version=E.version.charCodeAt(0),c.rawCapture=E,E}function S(c){if(c.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(c.content===void 0){var C;switch(c.encryptedContent.algorithm){case t.pki.oids["aes128-CBC"]:case t.pki.oids["aes192-CBC"]:case t.pki.oids["aes256-CBC"]:C=t.aes.createDecryptionCipher(c.encryptedContent.key);break;case t.pki.oids.desCBC:case t.pki.oids["des-EDE3-CBC"]:C=t.des.createDecryptionCipher(c.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+c.encryptedContent.algorithm)}if(C.start(c.encryptedContent.parameter),C.update(c.encryptedContent.content),!C.finish())throw new Error("Symmetric decryption failed.");c.content=C.output}}}),zi=le((N,_)=>{var t=pe();Tt(),Ot(),lr(),Mt(),Ce();var e=_.exports=t.ssh=t.ssh||{};e.privateKeyToPutty=function(v,u,r){r=r||"",u=u||"";var m="ssh-rsa",f=u===""?"none":"aes256-cbc",I="PuTTY-User-Key-File-2: "+m+`\r
27
- `;I+="Encryption: "+f+`\r
28
- `,I+="Comment: "+r+`\r
29
- `;var U=t.util.createBuffer();d(U,m),a(U,v.e),a(U,v.n);var S=t.util.encode64(U.bytes(),64),c=Math.floor(S.length/66)+1;I+="Public-Lines: "+c+`\r
30
- `,I+=S;var C=t.util.createBuffer();a(C,v.d),a(C,v.p),a(C,v.q),a(C,v.qInv);var T;if(!u)T=t.util.encode64(C.bytes(),64);else{var E=C.length()+16-1;E-=E%16;var s=g(C.bytes());s.truncate(s.length()-E+C.length()),C.putBuffer(s);var p=t.util.createBuffer();p.putBuffer(g("\x00\x00\x00\x00",u)),p.putBuffer(g("\x00\x00\x00\x01",u));var y=t.aes.createEncryptionCipher(p.truncate(8),"CBC");y.start(t.util.createBuffer().fillWithByte(0,16)),y.update(C.copy()),y.finish();var b=y.output;b.truncate(16),T=t.util.encode64(b.bytes(),64)}c=Math.floor(T.length/66)+1,I+=`\r
31
- Private-Lines: `+c+`\r
32
- `,I+=T;var L=g("putty-private-key-file-mac-key",u),h=t.util.createBuffer();d(h,m),d(h,f),d(h,r),h.putInt32(U.length()),h.putBuffer(U),h.putInt32(C.length()),h.putBuffer(C);var n=t.hmac.create();return n.start("sha1",L),n.update(h.bytes()),I+=`\r
33
- Private-MAC: `+n.digest().toHex()+`\r
34
- `,I},e.publicKeyToOpenSSH=function(v,u){var r="ssh-rsa";u=u||"";var m=t.util.createBuffer();return d(m,r),a(m,v.e),a(m,v.n),r+" "+t.util.encode64(m.bytes())+" "+u},e.privateKeyToOpenSSH=function(v,u){if(!u)return t.pki.privateKeyToPem(v);return t.pki.encryptRsaPrivateKey(v,u,{legacy:!0,algorithm:"aes128"})},e.getPublicKeyFingerprint=function(v,u){u=u||{};var r=u.md||t.md.md5.create(),m="ssh-rsa",f=t.util.createBuffer();d(f,m),a(f,v.e),a(f,v.n),r.start(),r.update(f.getBytes());var I=r.digest();if(u.encoding==="hex"){var U=I.toHex();if(u.delimiter)return U.match(/.{2}/g).join(u.delimiter);return U}else if(u.encoding==="binary")return I.getBytes();else if(u.encoding)throw new Error('Unknown encoding "'+u.encoding+'".');return I};function a(v,u){var r=u.toString(16);if(r[0]>="8")r="00"+r;var m=t.util.hexToBytes(r);v.putInt32(m.length),v.putBytes(m)}function d(v,u){v.putInt32(u.length),v.putString(u)}function g(){var v=t.md.sha1.create(),u=arguments.length;for(var r=0;r<u;++r)v.update(arguments[r]);return v.digest()}}),Jr=le((N,_)=>{_.exports=pe(),Tt(),Mi(),lt(),ur(),Yt(),ji(),Ot(),Gi(),qi(),Hi(),Yr(),fr(),Rt(),qr(),Xr(),Qi(),Wr(),Hr(),jr(),hr(),ct(),Gr(),zi(),Zr(),Ce()});function or(N,_){if(Array.isArray(_)&&!Array.isArray(N))return _;if(Array.isArray(_)&&Array.isArray(N))return _.map((e,a)=>{let d=N[a];if(wt(e)&&wt(d))return or(d,e);return e});if(!wt(_)||!wt(N))return _;let t={...N};for(let e in _)if(Object.prototype.hasOwnProperty.call(_,e)){let a=_[e],d=t[e];if(a===null||a===void 0)t[e]=a;else if(wt(a)&&wt(d))t[e]=or(d,a);else t[e]=a}return t}function wt(N){return Boolean(N&&typeof N==="object"&&!Array.isArray(N))}async function Wi({name:N,cwd:_,defaultConfig:t}){let e=Yi(_||Xi.cwd(),`${N}.config`);try{let a=await import(e),d=a.default||a;return or(t,d)}catch(a){return t}}var ei={altNameIPs:["127.0.0.1"],altNameURIs:["localhost"],organizationName:"Local Development",countryName:"US",stateName:"California",localityName:"Playa Vista",commonName:"stacks.localhost",validityDays:825,hostCertCN:"stacks.localhost",domain:"stacks.localhost",rootCA:{certificate:"",privateKey:""},basePath:"",caCertPath:sr.join(nr.homedir(),".stacks","ssl","stacks.localhost.ca.crt"),certPath:sr.join(nr.homedir(),".stacks","ssl","stacks.localhost.crt"),keyPath:sr.join(nr.homedir(),".stacks","ssl","stacks.localhost.crt.key"),verbose:!1},_e=await Wi({name:"tls",defaultConfig:ei}),za=cr(Jr(),1);function ti(N){let _=Number.parseInt(N[0],16);if(_<8)return N;return _-=8,_.toString()+N.substring(1)}function ri(N,_){let t=[];function e(a){try{let d=xr.readdirSync(a);for(let g of d){let v=$i.join(a,g);if(xr.lstatSync(v).isDirectory())e(v);else if(g===_)t.push(a)}}catch(d){console.warn(`Error reading directory ${a}: ${d}`)}}return e(N),t}function ye(N,_,t){if(t||_e.verbose)console.debug(`[tlsx:${N}] ${_}`)}var ta=ea(Zi);async function Kt(N,_={}){try{let{stdout:t,stderr:e}=await ta(N,{cwd:_.cwd||Ji.cwd(),timeout:_.timeout||30000});return{stdout:t.trim(),stderr:e.trim()}}catch(t){let e=new Error(`Failed to execute command: ${N}
35
- Error: ${t.message}`);throw e.stack=t.stack,e}}var Xe=cr(Jr(),1);function dr(N){ye("cert","Generating random serial number",N);let _=ti(Xe.default.util.bytesToHex(Xe.default.random.getBytesSync(20)));return ye("cert",`Generated serial number: ${_}`,N),_}function yr(N){let _=N.notBeforeDays??2,t=N.validityDays??(N.validityYears?N.validityYears*365:180);ye("cert","Calculating certificate validity dates",N.verbose);let e=new Date(Date.now()-86400*_*1000),a=new Date(e.getTime()+t*24*60*60*1000);return e.setUTCHours(0,0,0,0),a.setUTCHours(23,59,59,999),ye("cert",`Validity period: ${e.toISOString()} to ${a.toISOString()}`,N.verbose),{notBefore:e,notAfter:a}}function ra(N){let _=[];if(_.push({name:"basicConstraints",cA:N.isCA??!1,critical:!0,...N.basicConstraints||{}}),N.keyUsage)_.push({name:"keyUsage",critical:!0,...N.keyUsage});if(N.extKeyUsage)_.push({name:"extKeyUsage",...N.extKeyUsage});if(N.subjectAltNames&&N.subjectAltNames.length>0)_.push({name:"subjectAltName",altNames:N.subjectAltNames});return _}async function gr(N={}){ye("ca","Creating new Root CA Certificate",N.verbose);let _=N.keySize||2048;ye("ca",`Generating ${_}-bit RSA key pair`,N.verbose);let{privateKey:t,publicKey:e}=Xe.pki.rsa.generateKeyPair(_),a=[{shortName:"C",value:N.countryName||_e.countryName},{shortName:"ST",value:N.stateName||_e.stateName},{shortName:"L",value:N.localityName||_e.localityName},{shortName:"O",value:N.organization||"Local Development CA"},{shortName:"OU",value:N.organizationalUnit||"Certificate Authority"},{shortName:"CN",value:N.commonName||"Local Development Root CA"},...N.extraAttributes||[]],{notBefore:d,notAfter:g}=yr({validityYears:N.validityYears||100,verbose:N.verbose}),v=Xe.pki.createCertificate();return v.publicKey=e,v.serialNumber=dr(N.verbose),v.validity.notBefore=d,v.validity.notAfter=g,v.setSubject(a),v.setIssuer(a),v.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",keyCertSign:!0,cRLSign:!0,critical:!0},{name:"subjectKeyIdentifier"}]),v.sign(t,Xe.default.md.sha256.create()),{certificate:Xe.pki.certificateToPem(v),privateKey:Xe.pki.privateKeyToPem(t),notBefore:d,notAfter:g}}async function vr(N){if(ye("cert","Generating new certificate",N.verbose),ye("cert",`Options: ${JSON.stringify(N)}`,N.verbose),!N.rootCA?.certificate||!N.rootCA?.privateKey)throw new Error("Root CA certificate and private key are required");let _=Xe.pki.certificateFromPem(N.rootCA.certificate),t=Xe.pki.privateKeyFromPem(N.rootCA.privateKey);ye("cert","Generating 2048-bit RSA key pair for host certificate",N.verbose);let e=2048,{privateKey:a,publicKey:d}=Xe.pki.rsa.generateKeyPair(e),g=N.certificateAttributes||[{shortName:"C",value:N.countryName||_e.countryName},{shortName:"ST",value:N.stateName||_e.stateName},{shortName:"L",value:N.localityName||_e.localityName},{shortName:"O",value:N.organizationName||_e.organizationName},{shortName:"CN",value:N.commonName||_e.commonName}],{notBefore:v,notAfter:u}=yr({validityDays:N.validityDays,verbose:N.verbose}),r=Xe.pki.createCertificate();return r.publicKey=d,r.serialNumber=dr(N.verbose),r.validity.notBefore=v,r.validity.notAfter=u,r.setSubject(g),r.setIssuer(_.subject.attributes),r.setExtensions(ra(N)),r.sign(t,Xe.default.md.sha256.create()),{certificate:Xe.pki.certificateToPem(r),privateKey:Xe.pki.privateKeyToPem(a),notBefore:v,notAfter:u}}async function mr(N,_,t){ye("trust",`Adding certificate to system trust store with options: ${JSON.stringify(t)}`,t?.verbose),ye("trust","Storing certificate and private key",t?.verbose);let e=ii(N,t);ye("trust","Storing CA certificate",t?.verbose);let a=ai(_,t),d=Kr.platform();ye("trust",`Detected platform: ${d}`,t?.verbose);let g="TC, C, C";if(d==="darwin")ye("trust","Adding certificate to macOS keychain",t?.verbose),await Kt(`sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${a}`);else if(d==="win32")ye("trust","Adding certificate to Windows certificate store",t?.verbose),await Kt(`certutil -f -v -addstore -enterprise Root ${a}`);else if(d==="linux"){ye("trust","Adding certificate to Linux certificate store",t?.verbose);let v=Kr.homedir(),u="cert9.db";ye("trust",`Searching for certificate databases in ${v}`,t?.verbose);let r=ri(v,u);for(let m of r){ye("trust",`Processing certificate database in ${m}`,t?.verbose);try{ye("trust",`Attempting to delete existing cert for ${_e.commonName}`,t?.verbose),await Kt(`certutil -d sql:${m} -D -n ${_e.commonName}`)}catch(f){ye("trust",`Warning: Error deleting existing cert: ${f}`,t?.verbose),console.warn(`Error deleting existing cert: ${f}`)}ye("trust",`Adding new certificate to ${m}`,t?.verbose),await Kt(`certutil -d sql:${m} -A -t ${g} -n ${_e.commonName} -i ${a}`),Or.info(`Cert added to ${m}`)}}else throw ye("trust",`Error: Unsupported platform ${d}`,t?.verbose),new Error(`Unsupported platform: ${d}`);return ye("trust","Certificate successfully added to system trust store",t?.verbose),e}function ii(N,_){ye("storage",`Storing certificate and private key with options: ${JSON.stringify(_)}`,_?.verbose);let t=kt.join(_?.basePath||_e.basePath,_?.certPath||_e.certPath),e=kt.join(_?.basePath||_e.basePath,_?.keyPath||_e.keyPath);ye("storage",`Certificate path: ${t}`,_?.verbose),ye("storage",`Private key path: ${e}`,_?.verbose);let a=kt.dirname(t);if(!dt.existsSync(a))ye("storage",`Creating certificate directory: ${a}`,_?.verbose),dt.mkdirSync(a,{recursive:!0});ye("storage","Writing certificate file",_?.verbose),dt.writeFileSync(t,N.certificate);let d=kt.dirname(e);if(!dt.existsSync(d))ye("storage",`Creating private key directory: ${d}`,_?.verbose),dt.mkdirSync(d,{recursive:!0});return ye("storage","Writing private key file",_?.verbose),dt.writeFileSync(e,N.privateKey),ye("storage","Certificate and private key stored successfully",_?.verbose),t}function ai(N,_){ye("storage","Storing CA certificate",_?.verbose);let t=kt.join(_?.basePath||_e.basePath,_?.caCertPath||_e.caCertPath);ye("storage",`CA certificate path: ${t}`,_?.verbose);let e=kt.dirname(t);if(!dt.existsSync(e))ye("storage",`Creating CA certificate directory: ${e}`,_?.verbose),dt.mkdirSync(e,{recursive:!0});return ye("storage","Writing CA certificate file",_?.verbose),dt.writeFileSync(t,N),ye("storage","CA certificate stored successfully",_?.verbose),t}var hn=Xe.tls,pn=Xe.pki,dn=Xe.default;var Cr=null;function In(N,_){let t=Vt(N)?N.proxies[0].to||"stacks.localhost":N.to||"stacks.localhost";if(typeof N.https==="object"&&typeof _.https==="object"){if(N.https.caCertPath&&N.https.certPath&&N.https.keyPath){let a=Ct({...N,to:t,https:_.https}),d=N.https.altNameIPs?.filter((v)=>v!==void 0)||a.altNameIPs,g=N.https.altNameURIs?.filter((v)=>v!==void 0)||a.altNameURIs;return{...a,caCertPath:N.https.caCertPath||a.caCertPath,certPath:N.https.certPath||a.certPath,keyPath:N.https.keyPath||a.keyPath,basePath:N.https.basePath||a.basePath,commonName:N.https.commonName||a.commonName,organizationName:N.https.organizationName||a.organizationName,countryName:N.https.countryName||a.countryName,stateName:N.https.stateName||a.stateName,localityName:N.https.localityName||a.localityName,validityDays:N.https.validityDays||a.validityDays,altNameIPs:d,altNameURIs:g,verbose:N.verbose||a.verbose}}}return Ct({...N,to:t})}function ni(N){let _=new Set;_.add(N);let t=N.split(".");if(t.length>=2)_.add(`*.${t.slice(1).join(".")}`);return Array.from(_)}function Er(N){let _=Ht(N),t="";if(typeof N?.https==="object")return t=N.https.basePath||"",{caCertPath:N.https.caCertPath||At(t,`${_}.ca.crt`),certPath:N.https.certPath||At(t,`${_}.crt`),keyPath:N.https.keyPath||At(t,`${_}.key`)};let e=t||At(ia(),".stacks","ssl"),a=_.replace(/\*/g,"wildcard");return{caCertPath:At(e,`${a}.ca.crt`),certPath:At(e,`${a}.crt`),keyPath:At(e,`${a}.key`)}}function si(N){let _=new Set;if(Pt(N))N.proxies.forEach((t)=>{let e=t.to||"stacks.localhost";ni(e).forEach((a)=>_.add(a))});else if(Qt(N)){let t=N.to||"stacks.localhost";ni(t).forEach((e)=>_.add(e))}else _.add("stacks.localhost");return _.add("localhost"),_.add("*.localhost"),_}async function Sr(N){$("ssl","Loading SSL configuration",N.verbose);let _={...Ut,...N};if(N.https=Ct(_),!N.https?.keyPath&&!N.https?.certPath)return $("ssl","No SSL configuration provided",N.verbose),null;if(N.https?.keyPath&&!N.https?.certPath||!N.https?.keyPath&&N.https?.certPath){let t=!N.https?.keyPath?"keyPath":"certPath";throw $("ssl",`Invalid SSL configuration - missing ${t}`,N.verbose),new Error(`SSL Configuration requires both keyPath and certPath. Missing: ${t}`)}try{if(!N.https?.keyPath||!N.https?.certPath)return null;try{$("ssl","Reading SSL certificate files",N.verbose);let t=await Ft.readFile(N.https?.keyPath,"utf8"),e=await Ft.readFile(N.https?.certPath,"utf8");return $("ssl","SSL configuration loaded successfully",N.verbose),{key:t,cert:e}}catch(t){return $("ssl",`Failed to read certificates: ${t}`,N.verbose),null}}catch(t){throw $("ssl",`SSL configuration error: ${t}`,N.verbose),t}}async function Tr(N){if(Cr){$("ssl","Using cached SSL configuration",N.verbose);return}let _=Pt(N)?N.proxies.map((g)=>g.to):[N.to];$("ssl",`Generating certificate for domains: ${_.join(", ")}`,N.verbose);let t=Ct(N,N.verbose);ce.info("Generating Root CA certificate...");let e=await gr(t),a=Ct(N,N.verbose);ce.info(`Generating host certificate for: ${_.join(", ")}`);let d=await vr({...a,rootCA:{certificate:e.certificate,privateKey:e.privateKey}});await mr(d,e.certificate,a),Cr={key:d.privateKey,cert:d.certificate,ca:e.certificate},ce.success(`Certificate generated successfully for ${_.length} domain${_.length>1?"s":""}`),$("ssl",`Certificate includes domains: ${_.join(", ")}`,N.verbose)}function An(){return Cr}async function Ir(N){let _=Ht(N),t=Er(N);try{$("ssl",`Checking certificates for ${_} at paths:`,N?.verbose),$("ssl",`CA: ${t.caCertPath}`,N?.verbose),$("ssl",`Cert: ${t.certPath}`,N?.verbose),$("ssl",`Key: ${t.keyPath}`,N?.verbose);let e=await Ft.readFile(t.keyPath,"utf8"),a=await Ft.readFile(t.certPath,"utf8"),d;if(t.caCertPath)try{d=await Ft.readFile(t.caCertPath,"utf8")}catch(g){$("ssl",`Failed to read CA cert: ${g}`,N?.verbose)}return{key:e,cert:a,ca:d}}catch(e){return $("ssl",`Failed to read certificates: ${e}`,N?.verbose),null}}function Ct(N,_){let t=Ht(N);$("ssl",`Primary domain: ${t}`,_);let e=Er(N);if(typeof N.https==="object"){let a={domain:t,hostCertCN:t,basePath:N.https.basePath||"",caCertPath:N.https.caCertPath||e.caCertPath,certPath:N.https.certPath||e.certPath,keyPath:N.https.keyPath||e.keyPath,altNameIPs:["127.0.0.1","::1"],altNameURIs:[],commonName:N.https.commonName||t,organizationName:N.https.organizationName||"Local Development",countryName:N.https.countryName||"US",stateName:N.https.stateName||"California",localityName:N.https.localityName||"Playa Vista",validityDays:N.https.validityDays||825,verbose:_||!1,subjectAltNames:Array.from(si(N)).map((d)=>({type:2,value:d}))};if(Rr(N.https.rootCA))a.rootCA=N.https.rootCA;return a}return{domain:t,hostCertCN:t,basePath:"",...e,altNameIPs:["127.0.0.1","::1"],altNameURIs:[],commonName:t,organizationName:"Local Development",countryName:"US",stateName:"California",localityName:"Playa Vista",validityDays:825,verbose:_||!1,subjectAltNames:Array.from(si(N)).map((a)=>({type:2,value:a}))}}async function oi(N,_){let t=Er({to:N,verbose:_}),e=[t.caCertPath,t.certPath,t.keyPath];$("certificates","Attempting to clean up relating certificates",_),await Promise.all(e.map((a)=>_r(a,_)))}import*as _t from"node:http";import*as fi from"node:https";import*as Jt from"node:net";import ft from"node:process";var it=ca(li(),1);var Br=new Set;async function Lt(N){$("cleanup","Starting cleanup process",N?.verbose),console.log(`
36
- `),ce.info("Shutting down proxy servers...");let _=[],t=Array.from(Br).map((e)=>new Promise((a)=>{e.close(()=>{$("cleanup","Server closed successfully",N?.verbose),a()})}));if(_.push(...t),N?.hosts&&N.domains?.length){$("cleanup","Cleaning up hosts file entries",N?.verbose);let e=N.domains.filter((a)=>!a.includes("localhost"));if(e.length>0)ce.info("Cleaning up hosts file entries..."),_.push(Vr(e,N?.verbose).then(()=>{$("cleanup",`Removed hosts entries for ${e.join(", ")}`,N?.verbose)}).catch((a)=>{$("cleanup",`Failed to remove hosts entries: ${a}`,N?.verbose),ce.warn(`Failed to clean up hosts file entries for ${e.join(", ")}:`,a)}))}if(N?.certs&&N.domains?.length){$("cleanup","Cleaning up SSL certificates",N?.verbose),ce.info("Cleaning up SSL certificates...");let e=N.domains.map(async(a)=>{try{await oi(a,N?.verbose),$("cleanup",`Removed certificates for ${a}`,N?.verbose)}catch(d){console.log("checkError",d),$("cleanup",`Failed to remove certificates for ${a}: ${d}`,N?.verbose),ce.warn(`Failed to clean up certificates for ${a}:`,d)}});_.push(...e)}try{await Promise.all(_),$("cleanup","All cleanup tasks completed successfully",N?.verbose),ce.success("All cleanup tasks completed successfully"),ft.exit(0)}catch(e){$("cleanup",`Error during cleanup: ${e}`,N?.verbose),ce.error("Error during cleanup:",e),ft.exit(1)}}ft.on("SIGINT",Lt);ft.on("SIGTERM",Lt);ft.on("uncaughtException",(N)=>{$("process",`Uncaught exception: ${N}`,!0),ce.error("Uncaught exception:",N),Lt()});function br(N,_,t){return $("port",`Checking if port ${N} is in use on ${_}`,t),new Promise((e)=>{let a=Jt.createServer();a.once("error",(d)=>{if(d.code==="EADDRINUSE")$("port",`Port ${N} is in use`,t),e(!0)}),a.once("listening",()=>{$("port",`Port ${N} is available`,t),a.close(),e(!1)}),a.listen(N,_)})}async function ua(N,_,t){$("port",`Finding available port starting from ${N}`,t);let e=N;while(await br(e,_,t))$("port",`Port ${e} is in use, trying ${e+1}`,t),e++;return $("port",`Found available port: ${e}`,t),e}async function la(N,_,t){return $("connection",`Testing connection to ${N}:${_}`,t),new Promise((e,a)=>{let d=Jt.connect({host:N,port:_,timeout:5000});d.once("connect",()=>{$("connection",`Successfully connected to ${N}:${_}`,t),d.end(),e()}),d.once("timeout",()=>{$("connection",`Connection to ${N}:${_} timed out`,t),d.destroy(),a(new Error(`Connection to ${N}:${_} timed out`))}),d.once("error",(g)=>{$("connection",`Failed to connect to ${N}:${_}: ${g}`,t),d.destroy(),a(new Error(`Failed to connect to ${N}:${_}: ${g.message}`))})})}async function hi(N){$("server",`Starting server with options: ${JSON.stringify(N)}`,N.verbose);let _=new URL((N.from?.startsWith("http")?N.from:`http://${N.from}`)||"localhost:5173"),t=new URL((N.to?.startsWith("http")?N.to:`http://${N.to}`)||"stacks.localhost"),e=Number.parseInt(_.port)||(_.protocol.includes("https:")?443:80),a=[t.hostname];if(!t.hostname.includes("localhost")&&!t.hostname.includes("127.0.0.1")){$("hosts",`Checking if hosts file entry exists for: ${t.hostname}`,N?.verbose);try{if(!(await Pr(a,N.verbose))[0]){ce.info(`Adding ${t.hostname} to hosts file...`),ce.info("This may require sudo/administrator privileges");try{await Ur(a,N.verbose)}catch(v){if(ce.error("Failed to add hosts entry:",v.message),ce.warn("You can manually add this entry to your hosts file:"),ce.warn(`127.0.0.1 ${t.hostname}`),ce.warn(`::1 ${t.hostname}`),ft.platform==="win32")ce.warn("On Windows:"),ce.warn("1. Run notepad as administrator"),ce.warn("2. Open C:\\Windows\\System32\\drivers\\etc\\hosts");else ce.warn("On Unix systems:"),ce.warn("sudo nano /etc/hosts")}}else $("hosts",`Host entry already exists for ${t.hostname}`,N.verbose)}catch(g){ce.error("Failed to check hosts file:",g.message)}}try{await la(_.hostname,e,N.verbose)}catch(g){$("server",`Connection test failed: ${g}`,N.verbose),ce.error(g.message),ft.exit(1)}let d=N._cachedSSLConfig||null;if(N.https)try{if(N.https===!0)N.https=Ct({...N,to:t.hostname});try{$("ssl",`Attempting to load SSL configuration for ${t.hostname}`,N.verbose),d=await Sr({...N,to:t.hostname,https:N.https})}catch(g){$("ssl",`Failed to load certificates, will generate new ones: ${g}`,N.verbose)}if(!d){if($("ssl",`Generating new certificates for ${t.hostname}`,N.verbose),await Tr({...N,from:_.toString(),to:t.hostname,https:N.https}),d=await Sr({...N,to:t.hostname,https:N.https}),!d)throw new Error(`Failed to load SSL configuration after generating certificates for ${t.hostname}`)}}catch(g){throw $("server",`SSL setup failed: ${g}`,N.verbose),g}$("server",`Setting up reverse proxy with SSL config for ${t.hostname}`,N.verbose),await ha({...N,from:N.from||"localhost:5173",to:t.hostname,fromPort:e,sourceUrl:{hostname:_.hostname,host:_.host},ssl:d})}async function fa(N,_,t,e,a,d,g,v,u,r){$("proxy",`Creating proxy server ${N} -> ${_} with cleanUrls: ${r}`,u);let m=(U,S)=>{$("request",`Incoming request: ${U.method} ${U.url}`,u);let c=U.url||"/";if(r){if(!c.match(/\.[a-z0-9]+$/i))if(c.endsWith("/"))c=`${c}index.html`;else c=`${c}.html`}let C={hostname:d.hostname,port:t,path:c,method:U.method,headers:{...U.headers,host:d.host}};$("request",`Proxy request options: ${JSON.stringify(C)}`,u);let T=_t.request(C,(E)=>{if($("response",`Proxy response received with status ${E.statusCode}`,u),r&&E.statusCode===404){let p=[];if(c.endsWith(".html"))p.push(c.slice(0,-5));else if(!c.match(/\.[a-z0-9]+$/i))p.push(`${c}.html`);if(!c.endsWith("/"))p.push(`${c}/index.html`);if(p.length>0){$("cleanUrls",`Trying alternative paths: ${p.join(", ")}`,u);let y=(b)=>{if(b.length===0){S.writeHead(E.statusCode||404,E.headers),E.pipe(S);return}let L=b[0],h={...C,path:L},n=_t.request(h,(i)=>{if(i.statusCode===200)$("cleanUrls",`Found matching path: ${L}`,u),S.writeHead(i.statusCode,i.headers),i.pipe(S);else y(b.slice(1))});n.on("error",()=>y(b.slice(1))),n.end()};y(p);return}}let s={...E.headers,"Strict-Transport-Security":"max-age=31536000; includeSubDomains; preload","X-Content-Type-Options":"nosniff"};S.writeHead(E.statusCode||500,s),E.pipe(S)});T.on("error",(E)=>{$("request",`Proxy request failed: ${E}`,u),ce.error("Proxy request failed:",E),S.writeHead(502),S.end(`Proxy Error: ${E.message}`)}),U.pipe(T)},f=g?{key:g.key,cert:g.cert,ca:g.ca,minVersion:"TLSv1.2",maxVersion:"TLSv1.3",requestCert:!1,rejectUnauthorized:!1,ciphers:["TLS_AES_128_GCM_SHA256","TLS_AES_256_GCM_SHA384","TLS_CHACHA20_POLY1305_SHA256","ECDHE-ECDSA-AES128-GCM-SHA256","ECDHE-RSA-AES128-GCM-SHA256","ECDHE-ECDSA-AES256-GCM-SHA384","ECDHE-RSA-AES256-GCM-SHA384"].join(":"),allowHTTP1:!0,ALPNProtocols:["h2","http/1.1"]}:void 0;$("server",`Creating server with SSL config: ${!!g}`,u);let I=g&&f?fi.createServer(f,m):_t.createServer(m);if(g)I.on("secureConnection",(U)=>{$("tls",`TLS Connection established: ${JSON.stringify({protocol:U.getProtocol?.(),cipher:U.getCipher?.(),authorized:U.authorized,authError:U.authorizationError})}`,u)});return Br.add(I),new Promise((U,S)=>{I.listen(e,a,()=>{if($("server",`Server listening on port ${e}`,u),!v){if(console.log(""),console.log(` ${it.green(it.bold("reverse-proxy"))} ${it.green(`v${Nr}`)}`),console.log(""),console.log(` ${it.green("➜")} ${it.dim(N)} ${it.dim("➜")} ${g?"https":"http"}://${_}`),e!==(g?443:80))console.log(` ${it.green("➜")} Listening on port ${e}`);if(g)console.log(` ${it.green("➜")} SSL enabled with:`),console.log(" - TLS 1.2/1.3"),console.log(" - Modern cipher suite"),console.log(" - HTTP/2 enabled"),console.log(" - HSTS enabled");if(r)console.log(` ${it.green("➜")} Clean URLs enabled`)}U()}),I.on("error",(c)=>{$("server",`Server error: ${c}`,u),S(c)})})}async function ha(N){$("setup",`Setting up reverse proxy: ${JSON.stringify(N)}`,N.verbose);let{from:_,to:t,fromPort:e,sourceUrl:a,ssl:d,verbose:g,cleanup:v,vitePluginUsage:u,portManager:r}=N,m=80,f=443,I="0.0.0.0";try{if(d&&!r?.usedPorts.has(m))if(!await br(m,I,g))$("setup","Starting HTTP redirect server",g),pa(g),r?.usedPorts.add(m);else $("setup","Port 80 is in use, skipping HTTP redirect",g),ce.warn("Port 80 is in use, HTTP to HTTPS redirect will not be available");let U=d?f:m,S;if(r)S=await r.getNextAvailablePort(U);else S=await br(U,I,g)?await ua(d?8443:8080,I,g):U;if(S!==U)ce.warn(`Port ${U} is in use. Using port ${S} instead.`),ce.info(`You can use 'sudo lsof -i :${U}' (Unix) or 'netstat -ano | findstr :${U}' (Windows) to check what's using the port.`);await fa(_,t,e,S,I,a,d,u,g)}catch(U){$("setup",`Setup failed: ${U}`,g),ce.error(`Failed to setup reverse proxy: ${U.message}`),Lt({domains:[t],hosts:typeof v==="boolean"?v:v?.hosts,certs:typeof v==="boolean"?v:v?.certs,verbose:g})}}function pa(N){$("redirect","Starting HTTP redirect server",N);let _=_t.createServer((t,e)=>{let a=t.headers.host||"";$("redirect",`Redirecting request from ${a}${t.url} to HTTPS`,N),e.writeHead(301,{Location:`https://${a}${t.url}`}),e.end()}).listen(80);Br.add(_),$("redirect","HTTP redirect server started",N)}function Un(N){let _={...Ut,...N};$("proxy",`Starting proxy with options: ${JSON.stringify(_)}`,_?.verbose);let t={from:_.from,to:_.to,cleanUrls:_.cleanUrls,https:Ct(_),cleanup:_.cleanup,vitePluginUsage:_.vitePluginUsage,verbose:_.verbose};console.log("serverOptions",t),hi(t).catch((e)=>{$("proxy",`Failed to start proxy: ${e}`,_.verbose),ce.error(`Failed to start proxy: ${e.message}`),Lt({domains:[_.to],hosts:typeof _.cleanup==="boolean"?_.cleanup:_.cleanup?.hosts,certs:typeof _.cleanup==="boolean"?_.cleanup:_.cleanup?.certs,verbose:_.verbose})})}async function Vn(N){$("proxies","Starting proxy setup",N?.verbose);let _={...Ut,...N},t=Vt(_)?_.proxies[0].to||"stacks.localhost":_.to||"stacks.localhost";if(_.https){let v=await Ir(_);if(v)$("ssl",`Using existing certificates for ${t}`,_.verbose),_._cachedSSLConfig=v;else{$("ssl",`No valid certificates found for ${t}, generating new ones`,_.verbose),await Tr(_);let u=await Ir(_);if(!u)throw new Error(`Failed to load SSL certificates after generation for ${t}. Please check file permissions and paths.`);_._cachedSSLConfig=u}}let e=Vt(_)?_.proxies.map((v)=>({...v,https:_.https,cleanup:_.cleanup,cleanUrls:_.cleanUrls,vitePluginUsage:_.vitePluginUsage,verbose:_.verbose,_cachedSSLConfig:_._cachedSSLConfig})):[{from:_.from||"localhost:5173",to:_.to||"stacks.localhost",cleanUrls:_.cleanUrls||!1,https:_.https,cleanup:_.cleanup,vitePluginUsage:_.vitePluginUsage,verbose:_.verbose,_cachedSSLConfig:_._cachedSSLConfig}],a=e.map((v)=>v.to||"stacks.localhost"),d=_._cachedSSLConfig,g=()=>Lt({domains:a,hosts:typeof _.cleanup==="boolean"?_.cleanup:_.cleanup?.hosts,certs:typeof _.cleanup==="boolean"?_.cleanup:_.cleanup?.certs,verbose:_.verbose||!1});ft.on("SIGINT",g),ft.on("SIGTERM",g),ft.on("uncaughtException",(v)=>{$("process",`Uncaught exception: ${v}`,!0),console.error("Uncaught exception:",v),g()});for(let v of e)try{let u=v.to||"stacks.localhost";$("proxy",`Starting proxy for ${u} with SSL config: ${!!d}`,v.verbose),await hi({from:v.from||"localhost:5173",to:u,cleanUrls:v.cleanUrls||!1,https:v.https||!1,cleanup:v.cleanup||!1,vitePluginUsage:v.vitePluginUsage||!1,verbose:v.verbose||!1,_cachedSSLConfig:d})}catch(u){$("proxies",`Failed to start proxy for ${v.to}: ${u}`,v.verbose),console.error(`Failed to start proxy for ${v.to}:`,u),g()}}
37
- export{Nr as a,Ut as b,$ as c,Ta as d,Rr as e,Ht as f,Vt as g,Pt as h,Qt as i,_r as j,mt as k,Ur as l,Vr as m,Pr as n,In as o,ni as p,Er as q,si as r,Sr as s,Tr as t,An as u,Ir as v,Ct as w,oi as x,Lt as y,hi as z,ha as A,pa as B,Un as C,Vn as D};