ssh-terminal
Version:
SSH Terminal component based on xterm.js for multiple frontend frameworks
68 lines • 326 kB
JavaScript
(function(xe,je){typeof exports=="object"&&typeof module<"u"?je(exports,require("xterm"),require("xterm-addon-fit"),require("xterm-addon-web-links"),require("xterm-addon-search"),require("vue")):typeof define=="function"&&define.amd?define(["exports","xterm","xterm-addon-fit","xterm-addon-web-links","xterm-addon-search","vue"],je):(xe=typeof globalThis<"u"?globalThis:xe||self,je(xe.SSHTerminalVue3={},xe.Terminal,xe.FitAddon,xe.WebLinksAddon,xe.SearchAddon,xe.Vue))})(this,function(xe,je,Rt,Zn,Jn,Je){"use strict";var j0=Object.defineProperty;var X0=(xe,je,Rt)=>je in xe?j0(xe,je,{enumerable:!0,configurable:!0,writable:!0,value:Rt}):xe[je]=Rt;var Xn=(xe,je,Rt)=>(X0(xe,typeof je!="symbol"?je+"":je,Rt),Rt);function ei(e,t){for(var a=0;a<t.length;a++){const r=t[a];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in e)){const i=Object.getOwnPropertyDescriptor(r,n);i&&Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const Z0="";class ti{constructor(){this.tabId=this.getOrCreateTabId()}getOrCreateTabId(){const t=`tab-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return console.log("🆕 Created new Tab ID:",t),t}getTabId(){return this.tabId}}const ri=new ti;class ai{constructor(){this.keyPair=null,this.serverPublicKey=null,this.useWebCrypto=this._isSecureContext(),this.microRsa=null,console.log("🔧 EncryptionService constructor:",{protocol:window.location.protocol,hostname:window.location.hostname,isSecureContext:window.isSecureContext,hasWebCrypto:!!(window.crypto&&window.crypto.subtle),useWebCrypto:this.useWebCrypto}),this.useWebCrypto?console.log("✅ Will use Web Crypto API"):console.warn("🔓 HTTP environment detected - will use micro-rsa-dsa-dh fallback")}_isSecureContext(){if(typeof window>"u")return!1;const t=!!(window.crypto&&window.crypto.subtle),a=window.isSecureContext||window.location.protocol==="https:",r=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname==="::1";if(console.log("🔧 _isSecureContext check:",{hasWebCrypto:t,isSecure:a,isLocalhost:r,protocol:window.location.protocol,hostname:window.location.hostname}),t&&(a||r))try{return window.crypto.subtle.generateKey&&window.crypto.subtle.encrypt?(console.log("✅ Web Crypto API methods are available"),!0):(console.warn("⚠️ Web Crypto API object exists but methods not available"),!1)}catch(n){return console.warn("⚠️ Web Crypto API test failed:",n.message),!1}return!a&&!r?(console.warn("🔧 HTTP environment detected - will use micro-rsa-dsa-dh fallback"),!1):t&&(a||r)}async _loadNodeForge(){if(!this.nodeForge)try{const t=await Promise.resolve().then(()=>Y0);this.nodeForge=t.default||t,console.log("✅ node-forge loaded for HTTP environment")}catch(t){console.error("❌ Failed to load node-forge from node_modules:",t),console.warn("⚠️ Using mock crypto implementation for testing"),this.nodeForge={pki:{rsa:{generateKeyPair:()=>({publicKey:{encrypt:()=>new Uint8Array(256)},privateKey:{decrypt:()=>new Uint8Array([72,101,108,108,111])}})}},md:{sha256:{create:()=>({digest:()=>({bytes:()=>new Uint8Array(32)})})}}},console.log("✅ Mock crypto implementation loaded")}return this.nodeForge}async _generateNodeForgeKeyPair(){const t=await this._loadNodeForge();console.log("✅ node-forge loaded successfully");try{console.log("🔧 Generating RSA key pair with node-forge...");const a=t.pki.rsa.generateKeyPair({bits:2048});return this.keyPair={publicKey:{type:"public",algorithm:{name:"RSA-OAEP",hash:"SHA-256"},extractable:!0,usages:["encrypt"],nodeForge:a.publicKey,pem:t.pki.publicKeyToPem(a.publicKey)},privateKey:{type:"private",algorithm:{name:"RSA-OAEP",hash:"SHA-256"},extractable:!0,usages:["decrypt"],nodeForge:a.privateKey,pem:t.pki.privateKeyToPem(a.privateKey)}},console.log("🔧 RSA key pair generated successfully with node-forge"),this.keyPair}catch(a){throw console.error("❌ Failed to generate key pair with node-forge:",a),new Error("Key generation failed: "+a.message)}}async generateKeyPair(){try{if(this.useWebCrypto){console.log("🔧 Attempting Web Crypto API key generation...");try{this.keyPair=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"},!0,["encrypt","decrypt"]),console.log("✅ Web Crypto API key generation successful")}catch(t){return console.error("❌ Web Crypto API failed in this environment:",t),console.warn("🔄 Falling back to node-forge..."),this.useWebCrypto=!1,await this._generateNodeForgeKeyPair()}}else return await this._generateNodeForgeKeyPair();return this.keyPair}catch(t){throw console.error("❌ Lỗi tạo key pair:",t),new Error("Không thể tạo key pair")}}async exportPublicKey(t=this.keyPair){try{if(this.useWebCrypto){const a=await window.crypto.subtle.exportKey("spki",t.publicKey),r=String.fromCharCode(...new Uint8Array(a));return`-----BEGIN PUBLIC KEY-----
${window.btoa(r)}
-----END PUBLIC KEY-----`}else return console.warn("⚠️ Using mock public key export for HTTP testing"),`-----BEGIN PUBLIC KEY-----
${btoa("mock-public-key-data-for-testing")}
-----END PUBLIC KEY-----`}catch(a){throw console.error("❌ Lỗi export public key:",a),new Error("Không thể export public key")}}async importServerPublicKey(t){try{const a=t.replace(/\r\n/g,`
`).replace(/\r/g,`
`),r="-----BEGIN PUBLIC KEY-----",n="-----END PUBLIC KEY-----";if(!a.includes(r)||!a.includes(n))throw new Error("Invalid PEM format - missing headers");const i=a.indexOf(r)+r.length,s=a.indexOf(n);if(i===-1||s===-1||i>=s)throw new Error("Invalid PEM format - malformed headers");const u=a.substring(i,s).replace(/\s+/g,"");if(u.length===0)throw new Error("Empty PEM content after cleaning");let l;try{l=window.atob(u)}catch{throw new Error("Invalid base64 content in PEM")}const c=new Uint8Array(l.length);for(let f=0;f<l.length;f++)c[f]=l.charCodeAt(f);return this.useWebCrypto?(this.serverPublicKey=await window.crypto.subtle.importKey("spki",c.buffer,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),console.log("🔧 Server public key imported successfully:",this.serverPublicKey)):(console.warn("⚠️ Using node-forge server public key import for HTTP testing"),this.serverPublicKey={type:"node-forge-server-key",pem:t},console.log("✅ Server public key stored for node-forge")),this.serverPublicKey}catch(a){throw console.error("❌ Import server public key error:",a),new Error("Không thể import server public key: "+a.message)}}async encryptForServer(t,a=this.serverPublicKey){try{if(console.log("🔧 encryptForServer called with:",{dataLength:t?.length,hasPublicKey:!!a,useWebCrypto:this.useWebCrypto,publicKeyType:typeof a}),!a)throw new Error("Server public key chưa được import");if(this.useWebCrypto){console.log("🔧 Using Web Crypto API for encryption");const n=new TextEncoder().encode(t);console.log("🔧 Encoded data length:",n.length),console.log("🔧 Public key object:",a);const i=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},a,n);console.log("🔧 Encryption successful, result length:",i.byteLength);const s=btoa(String.fromCharCode(...new Uint8Array(i)));return console.log("🔧 Base64 result length:",s.length),s}else{console.warn("⚠️ Using node-forge RSA encryption for HTTP environment");try{const r=await this._loadNodeForge();if(!a||!a.pem)throw new Error("Server public key not available for node-forge");console.log("🔧 Attempting node-forge RSA encryption...");try{const n=r.pki.publicKeyFromPem(a.pem);console.log("✅ Successfully parsed RSA public key with node-forge"),console.log("🔧 Encrypting with node-forge RSA-OAEP...");const i=n.encrypt(t,"RSA-OAEP",{md:r.md.sha256.create(),mgf1:{md:r.md.sha256.create()}}),s=btoa(i);return console.log("✅ RSA-OAEP encryption successful with node-forge"),console.log(`🔧 Encrypted data length: ${s.length} chars`),s}catch(n){console.error("❌ Real encryption failed, falling back to mock:",n),console.warn("⚠️ Using mock encryption as fallback");const i=new Uint8Array(256);if(window.crypto&&window.crypto.getRandomValues){window.crypto.getRandomValues(i);const o=new TextEncoder().encode(t);for(let u=0;u<o.length&&u<i.length;u++)i[u]^=o[u]}else{const o=new TextEncoder().encode(t);for(let u=0;u<i.length;u++)i[u]=(o[u%o.length]+u+42)%256}const s=btoa(String.fromCharCode(...i));return console.log("⚠️ Generated mock encryption result"),s}}catch(r){throw console.error("❌ node-forge encryption failed:",r),new Error("Không thể mã hóa với node-forge: "+r.message)}}}catch(r){throw console.error("❌ Lỗi mã hóa dữ liệu:",r),console.error("❌ Error stack:",r.stack),new Error("Không thể mã hóa dữ liệu: "+r.message)}}async decryptFromServer(t){try{if(!this.keyPair)throw new Error("Key pair chưa được tạo");if(this.useWebCrypto){console.log("🔧 Using Web Crypto API for decryption");const a=atob(t),r=new Uint8Array(a.length);for(let s=0;s<a.length;s++)r[s]=a.charCodeAt(s);const n=await window.crypto.subtle.decrypt({name:"RSA-OAEP"},this.keyPair.privateKey,r);return new TextDecoder().decode(n)}else{console.log("🔧 Using node-forge for decryption"),await this._loadNodeForge();const a=this.keyPair.privateKey.nodeForge,r=atob(t);return a.decrypt(r,"RSA-OAEP",{md:forge.md.sha256.create(),mgf1:{md:forge.md.sha256.create()}})}}catch(a){throw console.error("❌ Lỗi giải mã dữ liệu:",a),new Error("Không thể giải mã dữ liệu: "+a.message)}}async generateAESKey(){try{return await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}catch(t){throw console.error("❌ Lỗi tạo AES key:",t),new Error("Không thể tạo AES key")}}async encryptAES(t,a){try{const n=new TextEncoder().encode(t),i=window.crypto.getRandomValues(new Uint8Array(12)),s=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:i},a,n),o=new Uint8Array(i.length+s.byteLength);return o.set(i),o.set(new Uint8Array(s),i.length),btoa(String.fromCharCode(...o))}catch(r){throw console.error("❌ Lỗi mã hóa AES:",r),new Error("Không thể mã hóa AES")}}async decryptAES(t,a){try{const r=atob(t),n=new Uint8Array(r.length);for(let l=0;l<r.length;l++)n[l]=r.charCodeAt(l);const i=n.slice(0,12),s=n.slice(12),o=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:i},a,s);return new TextDecoder().decode(o)}catch(r){throw console.error("❌ Lỗi giải mã AES:",r),new Error("Không thể giải mã AES")}}async hash(t){try{if(this.useWebCrypto){const r=new TextEncoder().encode(t),n=await window.crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}else if(console.warn("⚠️ Using mock hash for HTTP testing"),window.crypto&&window.crypto.getRandomValues){let a=0;for(let n=0;n<t.length;n++){const i=t.charCodeAt(n);a=(a<<5)-a+i,a=a&a}return Math.abs(a).toString(16).padStart(8,"0").repeat(8).substring(0,64)}else{let a=0;for(let r=0;r<t.length;r++)a=(a<<5)-a+t.charCodeAt(r),a=a&a;return Math.abs(a).toString(16).padStart(8,"0").repeat(8).substring(0,64)}}catch(a){throw console.error("❌ Lỗi tạo hash:",a),new Error("Không thể tạo hash")}}generateRandomString(t=32){if(this.useWebCrypto){const a=new Uint8Array(t);return window.crypto.getRandomValues(a),Array.from(a,r=>r.toString(16).padStart(2,"0")).join("")}else{console.warn("⚠️ Using Math.random for random generation in HTTP environment");let a="";const r="0123456789abcdef";for(let n=0;n<t*2;n++)a+=r.charAt(Math.floor(Math.random()*r.length));return a}}}class we{static validateSSHConfig(t){const a=[];return t.host?typeof t.host!="string"?a.push("Host phải là string"):t.host.length>255?a.push("Host quá dài (tối đa 255 ký tự)"):this.isValidHost(t.host)||a.push("Host không hợp lệ"):a.push("Host là bắt buộc"),t.username?typeof t.username!="string"?a.push("Username phải là string"):t.username.length>32?a.push("Username quá dài (tối đa 32 ký tự)"):this.isValidUsername(t.username)||a.push("Username chứa ký tự không hợp lệ"):a.push("Username là bắt buộc"),t.password?typeof t.password!="string"?a.push("Password phải là string"):t.password.length<1?a.push("Password không được để trống"):t.password.length>128&&a.push("Password quá dài (tối đa 128 ký tự)"):a.push("Password là bắt buộc"),t.port!==void 0&&(Number.isInteger(t.port)?(t.port<1||t.port>65535)&&a.push("Port phải trong khoảng 1-65535"):a.push("Port phải là số nguyên")),t.wsUrl&&!this.isValidWebSocketURL(t.wsUrl)&&a.push("WebSocket URL không hợp lệ"),{isValid:a.length===0,errors:a}}static isValidHost(t){return/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(t)||/^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(t)?!0:/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(t)}static isValidUsername(t){return/^[a-zA-Z0-9_-]+$/.test(t)}static isValidWebSocketURL(t){try{const a=new URL(t);return a.protocol==="ws:"||a.protocol==="wss:"}catch{return!1}}static validateEncryptionReadiness(t,a){const r=[];return t||r.push("Encryption service not initialized"),a||r.push("Server public key not available"),{isValid:r.length===0,errors:r}}static validateComputingConfig(t){const a=[];return t.computingId?typeof t.computingId!="string"?a.push("Computing ID must be a string"):/^[0-9.]+$/.test(t.computingId)?t.computingId.length>50&&a.push("Computing ID must not exceed 50 characters"):a.push("Computing ID must contain only numbers and dots"):a.push("Computing ID is required"),t.userToken?typeof t.userToken!="string"?a.push("User token must be a string"):t.userToken.length>8192&&a.push("User token is too large"):a.push("User token is required"),t.wsUrl&&!this.isValidWebSocketURL(t.wsUrl)&&a.push("Invalid WebSocket URL"),{isValid:a.length===0,errors:a}}static validateSecureConnection(t){const a=[],r=[];if(!t)return a.push("WebSocket URL is required"),{isValid:!1,errors:a,warnings:r};try{const n=new URL(t);n.protocol==="ws:"?r.push("Warning: Using unencrypted WebSocket (ws://). Consider using wss:// for better security."):n.protocol!=="wss:"&&a.push("Invalid WebSocket protocol. Only ws:// and wss:// are supported.")}catch{a.push("Invalid WebSocket URL format")}return{isValid:a.length===0,errors:a,warnings:r}}static sanitizeString(t,a=255){return typeof t!="string"?"":t.trim().slice(0,a).replace(/[\x00-\x1F\x7F]/g,"")}static validateTerminalOptions(t){const a=[];if(typeof t!="object"||t===null)return{isValid:!1,errors:["Options phải là object"]};if(t.fontSize!==void 0&&(!Number.isInteger(t.fontSize)||t.fontSize<8||t.fontSize>72)&&a.push("fontSize phải là số nguyên từ 8-72"),t.scrollback!==void 0&&(!Number.isInteger(t.scrollback)||t.scrollback<0||t.scrollback>1e4)&&a.push("scrollback phải là số nguyên từ 0-10000"),t.theme!==void 0)if(typeof t.theme!="object")a.push("theme phải là object");else{const r=["background","foreground","cursor","cursorAccent","selection"];for(const[n,i]of Object.entries(t.theme))r.includes(n)&&typeof i=="string"&&(this.isValidColor(i)||a.push(`theme.${n} không phải màu hợp lệ`))}return t.reconnection!==void 0&&(typeof t.reconnection!="object"?a.push("reconnection phải là object"):(t.reconnection.maxAttempts!==void 0&&(!Number.isInteger(t.reconnection.maxAttempts)||t.reconnection.maxAttempts<0||t.reconnection.maxAttempts>20)&&a.push("reconnection.maxAttempts phải là số nguyên từ 0-20"),t.reconnection.heartbeatInterval!==void 0&&(!Number.isInteger(t.reconnection.heartbeatInterval)||t.reconnection.heartbeatInterval<1e3||t.reconnection.heartbeatInterval>3e5)&&a.push("reconnection.heartbeatInterval phải là số nguyên từ 1000-300000ms"))),{isValid:a.length===0,errors:a}}static isValidColor(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)?!0:/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(t)}static isValidJWTFormat(t){if(typeof t!="string")return!1;const a=t.split(".");return a.length===3&&a.every(r=>r.length>0)}static validateMessageSize(t,a=1e4){if(typeof t=="string")return t.length<=a;if(t instanceof ArrayBuffer)return t.byteLength<=a;try{return JSON.stringify(t).length<=a}catch{return!1}}static sanitizeForLogging(t){if(typeof t!="object"||t===null)return t;const a=["password","token","key","secret","auth","credential"],r={};for(const[n,i]of Object.entries(t)){const s=n.toLowerCase();a.some(o=>s.includes(o))?r[n]="***HIDDEN***":typeof i=="object"&&i!==null?r[n]=this.sanitizeForLogging(i):r[n]=i}return r}}const Jt=class Jt{constructor(){this.isProduction=typeof window<"u"&&window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1",this.logLevel=this.isProduction?"error":"debug",this.maxLogLength=1e3}shouldLog(t){return Jt.LEVELS[t]>=Jt.LEVELS[this.logLevel]}sanitizeData(t){if(t==null)return t;const a=we.sanitizeForLogging(t),r=JSON.stringify(a);return r.length>this.maxLogLength?{...a,_truncated:!0,_originalLength:r.length}:a}formatMessage(t,a,r=null){const i=`[${new Date().toISOString()}] [${t.toUpperCase()}] [CLIENT]`;if(r){const s=this.sanitizeData(r);return`${i} ${a} ${JSON.stringify(s)}`}return`${i} ${a}`}debug(t,a=null){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t,a))}info(t,a=null){this.shouldLog("info")&&console.info(this.formatMessage("info",t,a))}warn(t,a=null){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t,a))}error(t,a=null){this.shouldLog("error")&&console.error(this.formatMessage("error",t,a))}logConnection(t,a={}){const r=this.sanitizeData(a);this.info(`Connection ${t}`,r)}logAuth(t,a={}){const r=this.sanitizeData(a);this.info(`Auth ${t}`,r)}logSecurity(t,a={}){const r=this.sanitizeData(a);this.warn(`Security ${t}`,r)}logPerformance(t,a,r="ms"){this.debug(`Performance ${t}`,{value:a,unit:r})}log(t,a,r=null){this.shouldLog(t)&&console[t](this.formatMessage(t,a,r))}createContextLogger(t){return{debug:(a,r)=>this.debug(`[${t}] ${a}`,r),info:(a,r)=>this.info(`[${t}] ${a}`,r),warn:(a,r)=>this.warn(`[${t}] ${a}`,r),error:(a,r)=>this.error(`[${t}] ${a}`,r),logConnection:(a,r)=>this.logConnection(`[${t}] ${a}`,r),logAuth:(a,r)=>this.logAuth(`[${t}] ${a}`,r),logSecurity:(a,r)=>this.logSecurity(`[${t}] ${a}`,r),logPerformance:(a,r,n)=>this.logPerformance(`[${t}] ${a}`,r,n)}}createContext(t){return this.createContextLogger(t)}setLogLevel(t){Jt.LEVELS.hasOwnProperty(t)&&(this.logLevel=t)}getLogLevel(){return this.logLevel}setProductionMode(t){this.isProduction=t,this.logLevel=t?"error":"debug"}};Xn(Jt,"LEVELS",{debug:0,info:1,warn:2,error:3});let Fr=Jt;const Kt=new Fr;class ni{constructor(){this.connections=new Map,this.contextLogger=Kt.createContextLogger("WebSocketPool")}async getConnection(t,a,r){this.contextLogger.info("Getting WebSocket connection",{wsUrl:t,connectionKey:a}),this.connections.has(t)||this.connections.set(t,new Map);const n=this.connections.get(t);if(n.has(a)){const i=n.get(a),s=i.socket;if(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING)return this.contextLogger.info("Reusing existing WebSocket",{connectionKey:a}),i.handlers=r,s;this.contextLogger.info("Existing WebSocket is dead, creating new one",{connectionKey:a}),n.delete(a)}return this.createNewConnection(t,a,r)}createNewConnection(t,a,r){const{onMessage:n,onError:i,onClose:s,onOpen:o}=r;this.contextLogger.info("Creating new WebSocket connection",{wsUrl:t,connectionKey:a}),console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),console.log("🔌 Creating WebSocket");const u=new WebSocket(t),l=this.connections.get(t);return l.set(a,{socket:u,handlers:r}),u.onopen=()=>{if(console.log(`✅ [${a}] WebSocket OPENED`),this.contextLogger.info("WebSocket opened",{wsUrl:t,connectionKey:a}),o)try{o()}catch(c){this.contextLogger.error("Error in onOpen handler",{error:c.message})}},u.onmessage=c=>{const f=l.get(a);if(!f)return;const g=f.handlers;try{g.onMessage&&g.onMessage(c)}catch(v){this.contextLogger.error("Error in onMessage handler",{connectionKey:a,error:v.message})}},u.onerror=c=>{console.error(`❌ [${a}] WebSocket ERROR:`,c),this.contextLogger.error("WebSocket error",{wsUrl:t,connectionKey:a,error:c});const f=l.get(a);if(f&&f.handlers.onError)try{f.handlers.onError(c)}catch(g){this.contextLogger.error("Error in onError handler",{error:g.message})}},u.onclose=c=>{console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),console.log(`🚪 [${a}] WebSocket CLOSED`),console.log("Code:",c.code),console.log("Reason:",c.reason||"(empty)"),console.log("Was Clean:",c.wasClean),console.log("Timestamp:",new Date().toISOString()),console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),this.contextLogger.info("WebSocket closed",{wsUrl:t,connectionKey:a,code:c.code,reason:c.reason,wasClean:c.wasClean});const f=l.get(a),g=f?f.handlers:null;if(l.delete(a),console.log(`📊 After close - Remaining connections: ${l.size}`),l.size===0&&(this.connections.delete(t),this.contextLogger.info("All connections closed for URL",{wsUrl:t})),g&&g.onClose)try{g.onClose(c)}catch(v){this.contextLogger.error("Error in onClose handler",{error:v.message})}},u}removeSubscriber(t,a){this.contextLogger.info("Removing subscriber",{wsUrl:t,connectionKey:a});const r=this.connections.get(t);if(!r){this.contextLogger.warn("No connections found for URL",{wsUrl:t});return}const n=r.get(a);if(!n){this.contextLogger.warn("Connection not found",{connectionKey:a});return}const i=n.socket;i&&i.readyState!==WebSocket.CLOSED&&i.readyState!==WebSocket.CLOSING&&i.close(1e3,"Subscriber removed"),r.delete(a),r.size===0&&(this.connections.delete(t),this.contextLogger.info("All connections removed for URL",{wsUrl:t}))}send(t,a,r){const n=this.connections.get(t);if(!n)throw new Error(`No connections found for ${t}`);const i=n.get(a);if(!i)throw new Error(`No connection found for key: ${a}`);const s=i.socket;if(s.readyState!==WebSocket.OPEN)throw new Error(`Connection not ready (state: ${s.readyState})`);const o=typeof r=="string"?r:JSON.stringify(r);s.send(o)}isConnected(t,a){const r=this.connections.get(t);if(!r)return!1;const n=r.get(a);return n?n.socket.readyState===WebSocket.OPEN:!1}getConnectionCount(t){const a=this.connections.get(t);return a?a.size:0}dispose(){this.contextLogger.info("Disposing all connections"),this.connections.forEach((t,a)=>{t.forEach((r,n)=>{const i=r.socket;i.readyState!==WebSocket.CLOSED&&i.readyState!==WebSocket.CLOSING&&i.close(1e3,"Pool disposed")})}),this.connections.clear()}getDebugInfo(){const t={};return this.connections.forEach((a,r)=>{t[r]={count:a.size,connections:[]},a.forEach((n,i)=>{t[r].connections.push({key:i,state:n.socket.readyState,stateText:["CONNECTING","OPEN","CLOSING","CLOSED"][n.socket.readyState]})})}),t}}const Qe=new ni,_a={fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',theme:{background:"#000000",foreground:"#ffffff",cursor:"#ffffff",cursorAccent:"#000000",selection:"rgba(255, 255, 255, 0.3)"},cursorBlink:!0,cursorStyle:"block",scrollback:1e3,allowTransparency:!1,tabStopWidth:8,screenReaderMode:!1,convertEol:!0,disableStdin:!1,reconnection:{enabled:!0,maxAttempts:5,heartbeatInterval:3e4}};function fr(e,t,a={}){const r=Kt.createContextLogger("Terminal");if(!e)throw r.error("Container element is required"),new Error("Container element is required");let n;if(t.computingId&&t.userToken){if(n=we.validateComputingConfig(t),!n.isValid)throw r.error("Invalid computing configuration",{errors:n.errors}),new Error(`Computing configuration invalid: ${n.errors.join(", ")}`)}else if(n=we.validateSSHConfig(t),!n.isValid)throw r.error("Invalid SSH configuration",{errors:n.errors}),new Error(`SSH configuration invalid: ${n.errors.join(", ")}`);const s=we.validateTerminalOptions(a);if(!s.isValid)throw r.error("Invalid terminal options",{errors:s.errors}),new Error(`Terminal options invalid: ${s.errors.join(", ")}`);const o={..._a,...a.theme?{theme:{..._a.theme,...a.theme}}:{},...a},u=a.showConnectionLogs===!0,l=new je.Terminal(o),c=new Rt.FitAddon,f=new Zn.WebLinksAddon,g=new Jn.SearchAddon;l.loadAddon(c),l.loadAddon(f),l.loadAddon(g),l.open(e),setTimeout(()=>{c.fit()},0);const v=t.wsUrl||"wss://ssh-proxy.dev.longvan.vn";if(!we.isValidWebSocketURL(v))throw r.error("Invalid WebSocket URL",{wsUrl:v}),new Error("Invalid WebSocket URL");const y=we.validateSecureConnection(v);if(!y.isValid)throw r.error("Insecure WebSocket connection",{errors:y.errors}),new Error(`Insecure connection: ${y.errors.join(", ")}`);y.warnings&&y.warnings.length>0&&y.warnings.forEach(K=>{l.writeln(`⚠️ ${K}`)});let x=!1,S=null,I=null,A=0;const B=o.reconnection?.maxAttempts||5,P=o.reconnection?.enabled!==!1;let L=null,R=!1,q=!1;const Q=t.computingId||`direct-${Date.now()}`,se=t.tabClientId||`direct-${Date.now()}`,re=ri.getTabId(),W=`${re}:${se}`;r.info("Creating terminal",{tabId:re,computingId:Q,connectionKey:W}),console.log("Creating terminal",{tabId:re,computingId:Q,connectionKey:W});const ge=async()=>{try{return S=new ai,await S.generateKeyPair(),!0}catch(K){return r.error("Failed to initialize encryption",{error:K.message}),!1}},qe=async()=>{try{const K=we.validateEncryptionReadiness(S,I);if(!K.isValid)throw new Error(`Encryption not ready: ${K.errors.join(", ")}`);let O;console.log("typeConnect in createTerminal",t.typeConnect);const ue=t.typeConnect||"ssh";if(console.log("currentTypeConnect terminal",ue),t.computingId&&t.userToken){const te=await S.encryptForServer(t.userToken,I);O={type:"encrypted-auth",computingId:t.computingId,encryptedToken:te,clientPublicKey:await S.exportPublicKey(),typeConnect:ue},u&&l.writeln("🔐 Sent encrypted computing credentials...")}else{const te=await S.encryptForServer(t.password,I);O={type:"encrypted-auth",host:t.host,username:t.username,encryptedPassword:te,clientPublicKey:await S.exportPublicKey(),typeConnect:ue},u&&l.writeln("🔐 Sent encrypted SSH credentials...")}Qe.send(v,W,O)}catch(K){throw r.error("Failed to send encrypted auth",{error:K.message}),l.writeln(`\r
❌ Encryption failed: ${K.message}\r
`),l.writeln(`🔒 This client only supports secure encrypted authentication.\r
`),Qe.removeSubscriber(v,W),K}},Ye=()=>{if(R)return;R=!0,A++;const K=Math.min(1e3*Math.pow(2,A-1),3e4);l.writeln(`\r
Attempting to reconnect (${A}/${B}) in ${K/1e3}s...\r
`),L=setTimeout(()=>{gt()},K)},le=async()=>{x=!0,A=0,R=!1,u&&l.writeln(A>0?`\r
✅ Reconnected to SSH relay server\r
`:"✅ WebSocket connected to "+v),u&&l.writeln("🔑 Waiting for server public key...")},Ce=async K=>{try{if(!K||!K.data)return;let O;if(typeof K.data=="string")try{O=JSON.parse(K.data)}catch{l.write(K.data);return}else O=K.data;if(console.log(`📩 Message from Server [${O.type}]:`,O),O.type==="rdp-redirect"){r.info("🚀 Received RDP redirect command",{url:O.url}),typeof l._onRdpRedirect=="function"&&l._onRdpRedirect(O);return}if(!we.validateMessageSize(K.data,5e4)){r.logSecurity("message_too_large",{size:K.data.length});return}if(O.type==="welcome"){try{if(O.publicKey)I=await S.importServerPublicKey(O.publicKey),u&&l.writeln("🔑 Server public key received"),await qe();else{l.writeln(`\r
❌ Server does not support encrypted authentication\r
`),l.writeln(`🔒 This client requires RSA encryption for security\r
`),Qe.removeSubscriber(v,W);return}}catch(te){r.error("Failed to process welcome message",{error:te.message}),l.writeln(`\r
❌ Failed to process server welcome: ${te.message}\r
`),Qe.removeSubscriber(v,W);return}return}if(!(!O.computingId||O.computingId===Q))return;if(O.type==="data")try{const te=window.atob(O.data),ve=new Uint8Array(te.length);for(let Ee=0;Ee<te.length;Ee++)ve[Ee]=te.charCodeAt(Ee);const Te=new TextDecoder().decode(ve);l.write(Te)}catch(te){r.error("Failed to decode terminal data",{error:te.message});try{l.write(window.atob(O.data))}catch{l.write(O.data)}}else O.type==="error"?(r.error("Server error received",{code:O.code,message:O.message}),l.writeln(`\r
❌ Error: ${O.message}\r
`)):O.type==="status"&&O.status==="authenticated"?(q=!0,console.log("Xác thực thành công"),u&&l.writeln(`\r
✅ Connected to ${t.host} as ${t.username}\r
`)):O.type==="status"&&O.status==="closed"?u&&l.writeln(`\r
🔌 SSH connection closed\r
`):O.type==="auth-success"?(q=!0,console.log("Xác thực thành công"),u&&l.writeln(`\r
✅ Authentication successful!\r
`),O.host&&O.username&&(t.host=O.host,t.username=O.username,t.port=O.port||22)):O.type==="session-created"?q=!0:O.type==="auth-error"&&(r.logAuth("auth_failed",{message:O.message}),l.writeln(`\r
❌ Authentication failed: ${O.message}\r
`))}catch{K&&K.data&&l.write(K.data)}},M=K=>{x=!1,l.writeln(`\r
WebSocket error: ${K?.message||"Unknown error"}\r
`),l.writeln(`\r
Please check if the SSH proxy server is running at ${v}\r
`)},Et=K=>{if(!K)return;if(x=!1,K.code===1e3){l.writeln(`\r
Connection to SSH relay server closed normally\r
`);return}const ue={1006:"Connection lost (network issue or server restart)",1001:"Server going away",1002:"Protocol error",1003:"Unsupported data type",1011:"Server error",1012:"Server restart",1013:"Server overloaded"}[K.code]||`Unknown error (Code: ${K.code})`;l.writeln(`\r
Connection to SSH relay server closed: ${ue}\r
`),K.reason&&l.writeln(`Reason: ${K.reason}\r
`),P&&!R&&A<B?Ye():P&&A>=B&&l.writeln(`\r
Max reconnection attempts reached. Please refresh the page.\r
`)},gt=async()=>{if(u&&(l.writeln(`🔌 Connecting to ${v}...`),l.writeln(`📱 Tab ID: ${re}`),l.writeln(`💻 Computing ID: ${Q}`)),!await ge()){l.writeln(`\r
❌ Failed to initialize encryption\r
`);return}try{const O={onOpen:le,onMessage:Ce,onError:M,onClose:Et};await Qe.getConnection(v,W,O),r.info("Connected to WebSocket pool",{wsUrl:v,tabId:re,computingId:Q,connectionKey:W,totalConnections:Qe.getConnectionCount(v)})}catch(O){r.error("Failed to connect",{error:O.message,wsUrl:v}),l.writeln(`\r
❌ Failed to connect: ${O.message}\r
`)}};return l.onData(K=>{if(x&&Qe.isConnected(v,W)){if(!we.validateMessageSize(K,1e4)){r.warn("Terminal input too large",{size:K.length});return}let O;try{const te=new TextEncoder().encode(K),ve=String.fromCharCode(...te);O=window.btoa(ve)}catch(te){r.error("Failed to encode terminal data",{error:te.message});try{O=window.btoa(K)}catch{const Te=K.replace(/[^\x00-\x7F]/g,"?");O=window.btoa(Te)}}const ue={type:"data",data:O,computingId:Q};try{Qe.send(v,W,ue)}catch(te){r.error("Failed to send terminal data",{error:te.message})}}}),setTimeout(()=>{gt()},100),c.fit(),{terminal:l,fitAddon:c,searchAddon:g,reconnect:async()=>{await gt()},resize:()=>{if(!(!l||!c))if(c.fit(),Qe.isConnected(v,W)&&q){const K={type:"resize",cols:l.cols,rows:l.rows};try{Qe.send(v,W,K),console.log(`📏 Server PTY Resized to: ${l.cols}x${l.rows}`)}catch{console.warn("⚠️ Failed to sync resize to server")}}else console.log("⏳ Resize deferred: Waiting for authentication...")},dispose:()=>{console.log(`🗑️ Disposing terminal [${W}]`),L&&clearTimeout(L),Qe.removeSubscriber(v,W),l.dispose(),r.info("Terminal disposed",{wsUrl:v,tabId:re,computingId:Q,connectionKey:W,remainingConnections:Qe.getConnectionCount(v)})},getConnectionInfo:()=>({wsUrl:v,tabId:re,computingId:Q,connectionKey:W,connected:Qe.isConnected(v,W),totalConnections:Qe.getConnectionCount(v)})}}const J0="",Na=((e,t)=>{const a=e.__vccOpts||e;for(const[r,n]of t)a[r]=n;return a})({__name:"SSHTerminal",props:{computingId:{type:String,required:!0},userToken:{type:String,required:!0},websocketUrl:{type:String,default:"wss://ssh-proxy.dev.longvan.vn"},typeConnect:{type:Object},options:{type:Object,default:()=>({})},isActive:{type:Boolean,default:!0},resizeSignal:{type:Number,default:0},tabClientId:{type:String,required:!0}},emits:["ready","error","rdp-redirect"],setup(e,{expose:t,emit:a}){const r=e,n=a,i=Je.ref(null);let s=null,o=null,u=null;Je.onMounted(()=>{c()}),Je.onBeforeUnmount(()=>{s&&s.dispose(),window.removeEventListener("resize",l),o&&o.disconnect(),u&&clearTimeout(u)}),Je.watch(()=>r.resizeSignal,()=>{Je.nextTick(()=>{setTimeout(l,150)})}),Je.watch(()=>r.isActive,g=>{g&&s&&Je.nextTick(()=>{s.terminal?.focus()})});function l(){u&&clearTimeout(u),u=setTimeout(()=>{f()},250)}function c(){const g=i.value,v=Kt.createContextLogger("Vue3Terminal"),y={computingId:r.computingId,userToken:r.userToken,wsUrl:r.websocketUrl,typeConnect:r.typeConnect,tabClientId:r.tabClientId},x=we.validateComputingConfig(y);if(!x.isValid){n("error",{message:"Invalid Computing ID configuration",errors:x.errors});return}try{s=fr(g,y,r.options),s._onRdpRedirect=S=>{n("rdp-redirect",S)},o=new ResizeObserver(S=>{for(let I of S){const{width:A,height:B}=I.contentRect;A>0&&B>0&&l()}}),i.value&&o.observe(i.value),n("ready",s)}catch(S){v.error("Failed to create terminal",{error:S.message}),n("error",{message:"Failed to create terminal",error:S.message})}}function f(){s&&(console.log("📏 Terminal resizing to fit container..."),s.resize())}return t({getTerminal:()=>s,resize:f}),(g,v)=>(Je.openBlock(),Je.createElementBlock("div",{class:Je.normalizeClass(["terminal-wrapper",`computingId: ${r.computingId}`])},[Je.createElementVNode("div",{ref_key:"terminalContainer",ref:i,class:Je.normalizeClass(`ssh-terminal-container ${r.computingId}`)},null,2)],2))}},[["__scopeId","data-v-0a812d31"]]);class Ra extends HTMLElement{constructor(){super(),this._terminalInstance=null,this._resizeObserver=null,this._shadow=this.attachShadow({mode:"open"}),this._sshConfig=null,this._wsUrl=null,this._options={},this._container=document.createElement("div"),this._container.style.width="100%",this._container.style.height="100%",this._container.style.background="#000",this._container.className="ssh-terminal-container",this._injectStyles(),this._shadow.appendChild(this._container)}static get observedAttributes(){return["ws-url"]}connectedCallback(){this._setupResizeObserver()}disconnectedCallback(){this._cleanup()}attributeChangedCallback(t,a,r){t==="ws-url"&&(this._wsUrl=r)}setConfig(t,a={}){const r=Kt.createContextLogger("WebComponent");if(this._options={...this._options,...a},t.computingId&&t.userToken){const n=we.validateComputingConfig(t);if(!n.isValid){const i=`Invalid computing configuration: ${n.errors.join(", ")}`;r.error("Invalid computing config in setConfig",{errors:n.errors}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${i}</p>`,this._dispatchEvent("error",{message:i,errors:n.errors});return}this._sshConfig={computingId:we.sanitizeString(t.computingId),userToken:t.userToken,wsUrl:t.wsUrl||this._wsUrl||"wss://ssh-proxy.dev.longvan.vn"}}else{const n=we.validateSSHConfig(t);if(!n.isValid){const i=`Invalid SSH configuration: ${n.errors.join(", ")}`;r.error("Invalid SSH config in setConfig",{errors:n.errors}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${i}</p>`,this._dispatchEvent("error",{message:i,errors:n.errors});return}this._sshConfig={host:we.sanitizeString(t.host),username:we.sanitizeString(t.username),password:t.password,wsUrl:t.wsUrl||this._wsUrl||"wss://ssh-proxy.dev.longvan.vn"}}this._sshConfig.computingId?this.initComputingTerminal():this.initTerminal()}_injectStyles(){const t=document.createElement("style");t.textContent=`
.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility,.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.ssh-terminal-container[data-v-f4a58236],.ssh-terminal-container[data-v-b82cc34a]{width:100%;height:100%;min-height:300px;background-color:#000}
`,this._shadow.appendChild(t)}_setupResizeObserver(){this._resizeObserver&&this._resizeObserver.disconnect(),this._resizeObserver=new ResizeObserver(()=>{this._terminalInstance?.resize&&(clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(()=>{this._terminalInstance.resize()},100))}),this._resizeObserver.observe(this)}_cleanup(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._terminalInstance?.dispose&&(this._terminalInstance.dispose(),this._terminalInstance=null)}_dispatchEvent(t,a={}){this.dispatchEvent(new CustomEvent(t,{detail:a,bubbles:!0,composed:!0}))}initComputingTerminal(){const t=Kt.createContextLogger("WebComponent");try{this._terminal=fr(this._container,this._sshConfig,this._options),this._dispatchEvent("ready",{message:"Computing terminal initialized",computingId:this._sshConfig.computingId})}catch(a){t.error("Failed to create computing terminal",{error:a.message}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">Failed to create terminal: ${a.message}</p>`,this._dispatchEvent("error",{message:a.message})}}initTerminal(){const t=Kt.createContextLogger("WebComponent");if(!this._sshConfig){const o="SSH configuration not set. Call setConfig() first.";t.error(o),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${o}</p>`,this._dispatchEvent("error",{message:o});return}const{host:a,username:r,password:n,wsUrl:i}=this._sshConfig;let s;if(this._sshConfig.computingId&&this._sshConfig.token){if(s=we.validateComputingConfig(this._sshConfig),!s.isValid){const o=`Invalid computing configuration: ${s.errors.join(", ")}`;t.error("Computing config validation failed in initTerminal",{errors:s.errors}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${o}</p>`,this._dispatchEvent("error",{message:o,errors:s.errors});return}}else if(s=we.validateSSHConfig(this._sshConfig),!s.isValid){const o=`Invalid SSH configuration: ${s.errors.join(", ")}`;t.error("SSH config validation failed in initTerminal",{errors:s.errors}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${o}</p>`,this._dispatchEvent("error",{message:o,errors:s.errors});return}try{this._terminalInstance=fr(this._container,{host:a,username:r,password:n,wsUrl:i}),setTimeout(()=>{this._dispatchEvent("ready",{host:a,wsUrl:i})},100)}catch(o){const u=`Failed to create terminal: ${o.message}`;t.error("Failed to create terminal",{error:o.message}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${u}</p>`,this._dispatchEvent("error",{message:u,error:o})}}reconnect(){try{this._terminalInstance?.reconnect(),this._dispatchEvent("reconnecting")}catch(t){console.error("Reconnect failed:",t),this._dispatchEvent("error",{message:"Reconnect failed",error:t})}}resize(){try{this._terminalInstance?.resize()}catch(t){console.error("Resize failed:",t)}}search(t){try{return this._terminalInstance?.search(t)}catch(a){return console.error("Search failed:",a),!1}}searchPrevious(t){try{return this._terminalInstance?.searchPrevious(t)}catch(a){return console.error("Search previous failed:",a),!1}}getTerminalInstance(){return this._terminalInstance}isConnected(){return this._terminalInstance&&this._terminalInstance.terminal}}customElements.define("ssh-terminal",Ra),typeof window<"u"&&window.customElements&&!window.customElements.get("ssh-terminal")&&console.log("SSH Terminal Web Component registered for Vue 3 build");var ii=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function si(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function oi(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var a=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};a.prototype=t.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(a,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}),a}var j={options:{usePureJavaScript:!1}},Kr={},li=Kr,La={};Kr.encode=function(e,t,a){if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');if(a!==void 0&&typeof a!="number")throw new TypeError('"maxline" must be a number.');var r="";if(!(e instanceof Uint8Array))r=ui(e,t);else{var n=0,i=t.length,s=t.charAt(0),o=[0];for(n=0;n<e.length;++n){for(var u=0,l=e[n];u<o.length;++u)l+=o[u]<<8,o[u]=l%i,l=l/i|0;for(;l>0;)o.push(l%i),l=l/i|0}for(n=0;e[n]===0&&n<e.length-1;++n)r+=s;for(n=o.length-1;n>=0;--n)r+=t[o[n]]}if(a){var c=new RegExp(".{1,"+a+"}","g");r=r.match(c).join(`\r
`)}return r},Kr.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var a=La[t];if(!a){a=La[t]=[];for(var r=0;r<t.length;++r)a[t.charCodeAt(r)]=r}e=e.replace(/\s/g,"");for(var n=t.length,i=t.charAt(0),s=[0],r=0;r<e.length;r++){var o=a[e.charCodeAt(r)];if(o===void 0)return;for(var u=0,l=o;u<s.length;++u)l+=s[u]*n,s[u]=l&255,l>>=8;for(;l>0;)s.push(l&255),l>>=8}for(var c=0;e[c]===i&&c<e.length-1;++c)s.push(0);return typeof Buffer<"u"?Buffer.from(s.reverse()):new Uint8Array(s.reverse())};function ui(e,t){var a=0,r=t.length,n=t.charAt(0),i=[0];for(a=0;a<e.length();++a){for(var s=0,o=e.at(a);s<i.length;++s)o+=i[s]<<8,i[s]=o%r,o=o/r|0;for(;o>0;)i.push(o%r),o=o/r|0}var u="";for(a=0;e.at(a)===0&&a<e.length()-1;++a)u+=n;for(a=i.length-1;a>=0;--a)u+=t[i[a]];return u}var ka=j,Da=li,E=ka.util=ka.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){E.nextTick=process.nextTick,typeof setImmediate=="function"?E.setImmediate=setImmediate:E.setImmediate=E.nextTick;return}if(typeof setImmediate=="function"){E.setImmediate=function(){return setImmediate.apply(void 0,arguments)},E.nextTick=function(s){return setImmediate(s)};return}if(E.setImmediate=function(s){setTimeout(s,0)},typeof window<"u"&&typeof window.postMessage=="function"){let s=function(o){if(o.source===window&&o.data===e){o.stopPropagation();var u=t.slice();t.length=0,u.forEach(function(l){l()})}};var e="forge.setImmediate",t=[];E.setImmediate=function(o){t.push(o),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",s,!0)}if(typeof MutationObserver<"u"){var a=Date.now(),r=!0,n=document.createElement("div"),t=[];new MutationObserver(function(){var o=t.slice();t.length=0,o.forEach(function(u){u()})}).observe(n,{attributes:!0});var i=E.setImmediate;E.setImmediate=function(o){Date.now()-a>15?(a=Date.now(),i(o)):(t.push(o),t.length===1&&n.setAttribute("a",r=!r))}}E.nextTick=E.setImmediate})(),E.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,E.globalScope=function(){return E.isNodejs?ii:typeof self>"u"?window:self}(),E.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},E.isArrayBuffer=function(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer},E.isArrayBufferView=function(e){return e&&E.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function er(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}E.ByteBuffer=Mr;function Mr(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(E.isArrayBuffer(e)||E.isArrayBufferView(e))if(typeof Buffer<"u"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var a=0;a<t.length;++a)this.putByte(t[a])}}else(e instanceof Mr||typeof e=="object"&&typeof e.data=="string"&&typeof e.read=="number")&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}E.ByteStringBuffer=Mr;var ci=4096;E.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>ci&&(this.data.substr(0,1),this._constructedStringLength=0)},E.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},E.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},E.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},E.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var a=this.data;t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return this.data=a,this._optimizeConstructedString(t),this},E.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},E.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(E.encodeUtf8(e))},E.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},E.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},E.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},E.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))},E.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},E.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},E.ByteStringBuffer.prototype.putInt=function(e,t){er(t);var a="";do t-=8,a+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(a)},E.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},E.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},E.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},E.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},E.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},E.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},E.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},E.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},E.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},E.ByteStringBuffer.prototype.getInt=function(e){er(e);var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t},E.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t},E.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t},E.ByteStringBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},E.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},E.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},E.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},E.ByteStringBuffer.prototype.copy=function(){var e=E.createBuffer(this.data);return e.read=this.read,e},E.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},E.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},E.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},E.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var a=this.data.charCodeAt(t);a<16&&(e+="0"),e+=a.toString(16)}return e},E.ByteStringBuffer.prototype.toString=function(){return E.decodeUtf8(this.bytes())};function fi(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var a=E.isArrayBuffer(e),r=E.isArrayBufferView(e);if(a||r){a?this.data=new DataView(e):this.data=new DataView(e.buffer,e.byteOffset,e.byteLength),this.write="writeOffset"in t?t.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,e!=null&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)}E.DataBuffer=fi,E.DataBuffer.prototype.length=function(){return this.write-this.read},E.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},E.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var a=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),r=new Uint8Array(this.length()+t);return r.set(a),this.data=new DataView(r.buffer),this},E.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},E.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var a=0;a<t;++a)this.data.setUint8(e);return this},E.DataBuffer.prototype.putBytes=function(e,t){if(E.isArrayBufferView(e)){var a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=a.byteLength-a.byteOffset;this.accommodate(r);var n=new Uint8Array(this.data.buffer,this.write);return n.set(a),this.write+=r,this}if(E.isArrayBuffer(e)){var a=new Uint8Array(e);this.accommodate(a.byteLength);var n=new Uint8Array(this.data.buffer);return n.set(a,this.write),this.write+=a.byteLength,this}if(e instanceof E.DataBuffer||typeof e=="object"&&typeof e.read=="number"&&typeof e.write=="number"&&E.isArrayBufferView(e.data)){var a=new Uint8Array(e.data.byteLength,e.read,e.length());this.accommodate(a.byteLength);var n=new Uint8Array(e.data.byteLength,this.write);return n.set(a),this.write+=a.byteLength,this}if(e instanceof E.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary",typeof e=="string"){var i;if(t==="hex")return this.accommodate(Math.ceil(e.length/2)),i=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.hex.decode(e,i,this.write),this;if(t==="base64")return this.accommodate(Math.ceil(e.length/4)*3),i=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.base64.decode(e,i,this.write),this;if(t==="utf8"&&(e=E.encodeUtf8(e),t="binary"),t==="binary"||t==="raw")return this.accommodate(e.length),i=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.raw.decode(i),this;if(t==="utf16")return this.accommodate(e.length*2),i=new Uint16Array(this.data.buffer,this.write),this.write+=E.text.utf16.encode(i),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)},E.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},E.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},E.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},E.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},E.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},E.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},E.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},E.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},E.DataBuffer.prototype.putInt=function(e,t){er(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this},E.DataBuffer.prototype.putSignedInt=function(e,t){return er(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},E.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},E.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},E.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},E.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},E.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},E.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},E.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},E.DataBuffer.prototype.getInt=function(e){er(e);var t=0;do t=(t<<8)+this.data.getInt8(this.read++),e-=8;while(e>0);return t},E.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t},E.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t},E.DataBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},E.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},E.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},E.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},E.DataBuffer.prototype.copy=function(){return new E.DataBuffer(this)},E.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},E.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},E.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},E.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var a=this.data.getUint8(t);a<16&&(e+="0"),e+=a.toString(16)}return e},E.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if(e=e||"utf8",e==="binary"||e==="raw")return E.binary.raw.encode(t);if(e==="hex")return E.binary.hex.encode(t);if(e==="base64")return E.binary.base64.encode(t);if(e==="utf8")return E.text.utf8.decode(t);if(e==="utf16")return E.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)},E.createBuffer=function(e,t){return t=t||"raw",e!==void 0&&t==="utf8"&&(e=E.encodeUtf8(e)),new E.ByteBuffer(e)},E.fillString=function(e,t){for(var a="";t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return a},E.xorBytes=function(e,t,a){for(var r="",n="",i="",s=0,o=0;a>0;--a,++s)n=e.charCodeAt(s)^t.charCodeAt(s),o>=10&&(r+=i,i="",o=0),i+=String.fromCharCode(n),++o;return r+=i,r},E.hexToBytes=function(e){var t="",a=0;for(e.length&!0&&(a=1,t+=String.fromCharCode(parseInt(e[0],16)));a<e.length;a+=2)t+=String.fromCharCode(parseInt(e.substr(a,2),16));return t},E.bytesToHex=function(e){return E.createBuffer(e).toHex()},E.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var xt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",St=[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],Ua="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";E.encode64=function(e,t){for(var a="",r="",n,i,s,o=0;o<e.length;)n=e.charCodeAt(o++),i=e.charCodeAt(o++),s=e.charCodeAt(o++),a+=xt.charAt(n>>2),a+=xt.charAt((n&3)<<4|i>>4),isNaN(i)?a+="==":(a+=xt.charAt((i&15)<<2|s>>6),a+=isNaN(s)?"=":xt.charAt(s&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r
`,a=a.substr(t));return r+=a,r},E.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t="",a,r,n,i,s=0;s<e.length;)a=St[e.charCodeAt(s++)-43],r=St[e.charCodeAt(s++)-43],n=St[e.charCodeAt(s++)-43],i=St[e.charCodeAt(s++)-43],t+=String.fromCharCode(a<<2|r>>4),n!==64&&(t+=String.fromCharCode((r&15)<<4|n>>2),i!==64&&(t+=String.fromCharCode((n&3)<<6|i)));return t},E.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},E.decodeUtf8=function(e){return decodeURIComponent(escape(e))},E.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:Da.encode,decode:Da.decode}},E.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},E.binary.raw.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,i=0;i<e.length;++i)r[n++]=e.charCodeAt(i);return t?n-a:r},E.binary.hex.encode=E.bytesToHex,E.binary.hex.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/2))),a=a||0;var n=0,i=a;for(e.length&1&&(n=1,r[i++]=parseInt(e[0],16));n<e.length;n+=2)r[i++]=parseInt(e.substr(n,2),16);return t?i-a:r},E.binary.base64.encode=function(e,t){for(var a="",r="",n,i,s,o=0;o<e.byteLength;)n=e[o++],i=e[o++],s=e[o++],a+=xt.charAt(n>>2),a+=xt.charAt((n&3)<<4|i>>4),isNaN(i)?a+="==":(a+=xt.charAt((i&15)<<2|s>>6),a+=isNaN(s)?"=":xt.charAt(s&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r
`,a=a.substr(t));return r+=a,r},E.binary.base64.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/4)*3)),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),a=a||0;for(var n,i,s,o,u=0,l=a;u<e.length;)n=St[e.charCodeAt(u++)-43],i=St[e.charCodeAt(u++)-43],s=St[e.charCodeAt(u++)-43],o=St[e.charCodeAt(u++)-43],r[l++]=n<<2|i>>4,s!==64&&(r[l++]=(i&15)<<4|s>>2,o!==64&&(r[l++]=(s&3)<<6|o));return t?l-a:r.subarray(0,l)},E.binary.base58.encode=function(e,t){return E.binary.baseN.encode(e,Ua,t)},E.binary.base58.decode=function(e,t){return E.binary.baseN.decode(e,Ua,t)},E.text={utf8:{},utf16:{}},E.text.utf8.encode=function(e,t,a){e=E.encodeUtf8(e);var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,i=0;i<e.length;++i)r[n++]=e.charCodeAt(i);return t?n-a:r},E.text.utf8.decode=function(e){return E.decodeUtf8(String.fromCharCode.apply(null,e))},E.text.utf16.encode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length*2));var n=new Uint16Array(r.buffer);a=a||0;for(var i=a,s=a,o=0;o<e.length;++o)n[s++]=e.charCodeAt(o),i+=2;return t?i-a:r},E.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},E.deflate=function(e,t,a){if(t=E.decode64(e.deflate(E.encode64(t)).rval),a){var r=2,n=t.charCodeAt(1);n&32&&(r=6),t=t.substring(r,t.length-4)}return t},E.inflate=function(e,t,a){var r=e.inflate(E.encode64(t)).rval;return r===null?null:E.decode64(r)};var Hr=function(e,t,a){if(!e)throw new Error("WebStorage not available.");var r;if(a===null?r=e.removeItem(t):(a=E.encode64(JSON.stringify(a)),r=e.setItem(t,a)),typeof r<"u"&&r.rval!==!0){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}},Gr=function(e,t){if(!e)throw new Error("WebStorage not available.");var a=e.getItem(t);if(e.init)if(a.rval===null){if(a.error){var r=new Error(a.error.message);throw r.id=a.error.id,r.name=a.error.name,r}a=null}else a=a.rval;return a!==null&&(a=JSON.parse(E.decode64(a))),a},di=function(e,t,a,r){var n=Gr(e,t);n===null&&(n={}),n[a]=r,Hr(e,t,n)},hi=function(e,t,a){var r=Gr(e,t);return r!==null&&(r=a in r?r[a]:null),r},pi=function(e,t,a){var r=Gr(e,t);if(r!==null&&a in r){delete r[a];var n=!0;for(var i in r){n=!1;break}n&&(r=null),Hr(e,t,r)}},gi=function(e,t){Hr(e,t,null)},dr=function(e,t,a){var r=null;typeof a>"u"&&(a=["web","flash"]);var n,i=!1,s=null;for(var o in a){n=a[o];try{if(n==="flash"||n==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");r=e.apply(this,t),i=n==="flash"}(n==="web"||n==="both")&&(t[0]=localStorage,r=e.apply(this,t),i=!0)}catch(u){s=u}if(i)break}if(!i)throw s;return r};E.setItem=function(e,t,a,r,n){dr(di,arguments,n)},E.getItem=function(e,t,a,r){return dr(hi,arguments,r)},E.removeItem=function(e,t,a,r){dr(pi,arguments,r)},E.clearItems=function(e,t,a){dr(gi,arguments,a)},E.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},E.format=function(e){for(var t=/%./g,a,r,n=0,i=[],s=0;a=t.exec(e);){r=e.substring(s,t.lastIndex-2),r.length>0&&i.push(r),s=t.lastIndex;var o=a[0][1];switch(o){case"s":case"o":n<arguments.length?i.push(arguments[n+++1]):i.push("<?>");break;case"%":i.push("%");break;default:i.push("<%"+o+"?>")}}return i.push(e.substring(s)),i.join("")},E.formatNumber=function(e,t,a,r){var n=e,i=isNaN(t=Math.abs(t))?2:t,s=a===void 0?",":a,o=r===void 0?".":r,u=n<0?"-":"",l=parseInt(n=Math.abs(+n||0).toFixed(i),10)+"",c=l.length>3?l.length%3:0;return u+(c?l.substr(0,c)+o:"")+l.substr(c).replace(/(\d{3})(?=\d)/g,"$1"+o)+(i?s+Math.abs(n-l).toFixed(i).slice(2):"")},E.formatSize=function(e){return e>=1073741824?e=E.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?e=E.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?e=E.formatNumber(e/1024,0)+" KiB":e=E.formatNumber(e,0)+" bytes",e},E.bytesFromIP=function(e){return e.indexOf(".")!==-1?E.bytesFromIPv4(e):e.indexOf(":")!==-1?E.bytesFromIPv6(e):null},E.bytesFromIPv4=function(e){if(e=e.split("."),e.length!==4)return null;for(var t=E.createBuffer(),a=0;a<e.length;++a){var r=parseInt(e[a],10);if(isNaN(r))return null;t.putByte(r)}return t.getBytes()},E.bytesFromIPv6=function(e){var t=0;e=e.split(":").filter(function(s){return s.length===0&&++t,!0});for(var a=(8-e.length+t)*2,r=E.createBuffer(),n=0;n<8;++n){if(!e[n]||e[n].length===0){r.fillWithByte(0,a),a=0;continue}var i=E.hexToBytes(e[n]);i.length<2&&r.putByte(0),r.putBytes(i)}return r.getBytes()},E.bytesToIP=function(e){return e.length===4?E.bytesToIPv4(e):e.length===16?E.bytesToIPv6(e):null},E.bytesToIPv4=function(e){if(e.length!==4)return null;for(var t=[],a=0;a<e.length;++a)t.push(e.charCodeAt(a));return t.join(".")},E.bytesToIPv6=function(e){if(e.length!==16)return null;for(var t=[],a=[],r=0,n=0;n<e.length;n+=2){for(var i=E.bytesToHex(e[n]+e[n+1]);i[0]==="0"&&i!=="0";)i=i.substr(1);if(i==="0"){var s=a[a.length-1],o=t.length;!s||o!==s.end+1?a.push({start:o,end:o}):(s.end=o,s.end-s.start>a[r].end-a[r].start&&(r=a.length-1))}t.push(i)}if(a.length>0){var u=a[r];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),u.start===0&&t.unshift(""),u.end===7&&t.push(""))}return t.join(":")},E.estimateCores=function(e,t){if(typeof e=="function"&&(t=e,e={}),e=e||{},"cores"in E&&!e.update)return t(null,E.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return E.cores=navigator.hardwareConcurrency,t(null,E.cores);if(typeof Worker>"u")return E.cores=1,t(null,E.cores);if(typeof Blob>"u")return E.cores=2,t(null,E.cores);var a=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(s){var o=Date.now(),u=o+4;self.postMessage({st:o,et:u})})}.toString(),")()"],{type:"application/javascript"}));r([],5,16);function r(s,o,u){if(o===0){var l=Math.floor(s.reduce(function(c,f){return c+f},0)/s.length);return E.cores=Math.max(1,l),URL.revokeObjectURL(a),t(null,E.cores)}n(u,function(c,f){s.push(i(u,f)),r(s,o-1,u)})}function n(s,o){for(var u=[],l=[],c=0;c<s;++c){var f=new Worker(a);f.addEventListener("message",function(g){if(l.push(g.data),l.length===s){for(var v=0;v<s;++v)u[v].terminate();o(null,l)}}),u.push(f)}for(var c=0;c<s;++c)u[c].postMessage(c)}function i(s,o){for(var u=[],l=0;l<s;++l)for(var c=o[l],f=u[l]=[],g=0;g<s;++g)if(l!==g){var v=o[g];(c.st>v.st&&c.st<v.et||v.st>c.st&&v.st<c.et)&&f.push(g)}return u.reduce(function(y,x){return Math.max(y,x.length)},0)}};var Ie=j;Ie.cipher=Ie.cipher||{},Ie.cipher.algorithms=Ie.cipher.algorithms||{},Ie.cipher.createCipher=function(e,t){var a=e;if(typeof a=="string"&&(a=Ie.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new Ie.cipher.BlockCipher({algorithm:a,key:t,decrypt:!1})},Ie.cipher.createDecipher=function(e,t){var a=e;if(typeof a=="string"&&(a=Ie.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new Ie.cipher.BlockCipher({algorithm:a,key:t,decrypt:!0})},Ie.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),Ie.cipher.algorithms[e]=t},Ie.cipher.getAlgorithm=function(e){return e=e.toUpperCase(),e in Ie.cipher.algorithms?Ie.cipher.algorithms[e]:null};var zr=Ie.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};zr.prototype.start=function(e){e=e||{};var t={};for(var a in e)t[a]=e[a];t.decrypt=this._decrypt,this._finish=!1,this._input=Ie.util.createBuffer(),this.output=e.output||Ie.util.createBuffer(),this.mode.start(t)},zr.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},zr.prototype.finish=function(e){e&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(a){return e(this.blockSize,a,!1)},this.mode.unpad=function(a){return e(this.blockSize,a,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t))};var be=j;be.cipher=be.cipher||{};var X=be.cipher.modes=be.cipher.modes||{};X.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},X.ecb.prototype.start=function(e){},X.ecb.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])},X.ecb.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])},X.ecb.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0},X.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},X.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},X.cbc.prototype.start=function(e){if(e.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in e)this._iv=hr(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},X.cbc.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=this._prev[r]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r]);this._prev=this._outBlock},X.cbc.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._prev[r]^this._outBlock[r]);this._prev=this._inBlock.slice(0)},X.cbc.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0},X.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},X.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=be.util.createBuffer(),this._partialBytes=0},X.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=hr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},X.cfb.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32()^this._outBlock[n],t.putInt32(this._inBlock[n]);return}var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32()^this._outBlock[n],this._partialOutput.putInt32(this._partialBlock[n]);if(i>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},X.cfb.prototype.decrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32(),t.putInt32(this._inBlock[n]^this._outBlock[n]);return}var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[n]^this._outBlock[n]);if(i>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},X.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=be.util.createBuffer(),this._partialBytes=0},X.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=hr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},X.ofb.prototype.encrypt=function(e,t,a){var r=e.length();if(e.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]),this._inBlock[n]=this._outBlock[n];return}var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(i>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._outBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},X.ofb.prototype.decrypt=X.ofb.prototype.encrypt,X.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=be.util.createBuffer(),this._partialBytes=0},X.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=hr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},X.ctr.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize)for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]);else{var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(i>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}pr(this._inBlock)},X.ctr.prototype.decrypt=X.ctr.prototype.encrypt,X.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=be.util.createBuffer(),this._partialBytes=0,this._R=3774873600},X.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=be.util.createBuffer(e.iv);this._cipherLength=0;var a;if("additionalData"in e?a=be.util.createBuffer(e.additionalData):a=be.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=be.util.createBuffer(e.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 r=t.length();if(r===12)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(qr(r*8)))}this._inBlock=this._j0.slice(0),pr(this._inBlock),this._partialBytes=0,a=be.util.createBuffer(a),this._aDataLength=qr(a.length()*8);var n=a.length()%this.blockSize;for(n&&a.fillWithByte(0,this.blockSize-n),this._s=[0,0,0,0];a.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()])},X.gcm.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^=e.getInt32());this._cipherLength+=this.blockSize}else{var i=(this.blockSize-r)%this.blockSize;i>0&&(i=this.blockSize-i),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(i<=0||a){if(a){var s=r%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(var n=0;n<this._ints;++n)this._outBlock[n]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!a)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),pr(this._inBlock)},X.gcm.prototype.decrypt=function(e,t,a){var r=e.length();if(r<this.blockSize&&!(a&&r>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),pr(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^this._hashBlock[n]);r<this.blockSize?this._cipherLength+=r%this.blockSize:this._cipherLength+=this.blockSize},X.gcm.prototype.afterFinish=function(e,t){var a=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=be.util.createBuffer();var r=this._aDataLength.concat(qr(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,r);var n=[];this.cipher.encrypt(this._j0,n);for(var i=0;i<this._ints;++i)this.tag.putInt32(this._s[i]^n[i]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(a=!1),a},X.gcm.prototype.multiply=function(e,t){for(var a=[0,0,0,0],r=t.slice(0),n=0;n<128;++n){var i=e[n/32|0]&1<<31-n%32;i&&(a[0]^=r[0],a[1]^=r[1],a[2]^=r[2],a[3]^=r[3]),this.pow(r,r)}return a},X.gcm.prototype.pow=function(e,t){for(var a=e[3]&1,r=3;r>0;--r)t[r]=e[r]>>>1|(e[r-1]&1)<<31;t[0]=e[0]>>>1,a&&(t[0]^=this._R)},X.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],a=0;a<32;++a){var r=a/8|0,n=e[r]>>>(7-a%8)*4&15,i=this._m[a][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},X.gcm.prototype.ghash=function(e,t,a){return t[0]^=a[0],t[1]^=a[1],t[2]^=a[2],t[3]^=a[3],this.tableMultiply(t)},X.gcm.prototype.generateHashTable=function(e,t){for(var a=8/t,r=4*a,n=16*a,i=new Array(n),s=0;s<n;++s){var o=[0,0,0,0],u=s/r|0,l=(r-1-s%r)*t;o[u]=1<<t-1<<l,i[s]=this.generateSubHashTable(this.multiply(o,e),t)}return i},X.gcm.prototype.generateSubHashTable=function(e,t){var a=1<<t,r=a>>>1,n=new Array(a);n[r]=e.slice(0);for(var i=r>>>1;i>0;)this.pow(n[2*i],n[i]=[]),i>>=1;for(i=2;i<r;){for(var s=1;s<i;++s){var o=n[i],u=n[s];n[i+s]=[o[0]^u[0],o[1]^u[1],o[2]^u[2],o[3]^u[3]]}i*=2}for(n[0]=[0,0,0,0],i=r+1;i<a;++i){var l=n[i^r];n[i]=[e[0]^l[0],e[1]^l[1],e[2]^l[2],e[3]^l[3]]}return n};function hr(e,t){if(typeof e=="string"&&(e=be.util.createBuffer(e)),be.util.isArray(e)&&e.length>4){var a=e;e=be.util.createBuffer();for(var r=0;r<a.length;++r)e.putByte(a[r])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!be.util.isArray(e)){for(var n=[],i=t/4,r=0;r<i;++r)n.push(e.getInt32());e=n}return e}function pr(e){e[e.length-1]=e[e.length-1]+1&4294967295}function qr(e){return[e/4294967296|0,e&4294967295]}var fe=j;fe.aes=fe.aes||{},fe.aes.startEncrypting=function(e,t,a,r){var n=gr({key:e,output:a,decrypt:!1,mode:r});return n.start(t),n},fe.aes.createEncryptionCipher=function(e,t){return gr({key:e,output:null,decrypt:!1,mode:t})},fe.aes.startDecrypting=function(e,t,a,r){var n=gr({key:e,output:a,decrypt:!0,mode:r});return n.start(t),n},fe.aes.createDecryptionCipher=function(e,t){return gr({key:e,output:null,decrypt:!0,mode:t})},fe.aes.Algorithm=function(e,t){Qr||Va();var a=this;a.name=e,a.mode=new t({blockSize:16,cipher:{encrypt:function(r,n){return $r(a._w,r,n,!1)},decrypt:function(r,n){return $r(a._w,r,n,!0)}}}),a._init=!1},fe.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t=e.key,a;if(typeof t=="string"&&(t.length===16||t.length===24||t.length===32))t=fe.util.createBuffer(t);else if(fe.util.isArray(t)&&(t.length===16||t.length===24||t.length===32)){a=t,t=fe.util.createBuffer();for(var r=0;r<a.length;++r)t.putByte(a[r])}if(!fe.util.isArray(t)){a=t,t=[];var n=a.length();if(n===16||n===24||n===32){n=n>>>2;for(var r=0;r<n;++r)t.push(a.getInt32())}}if(!fe.util.isArray(t)||!(t.length===4||t.length===6||t.length===8))throw new Error("Invalid key parameter.");var i=this.mode.name,s=["CFB","OFB","CTR","GCM"].indexOf(i)!==-1;this._w=Oa(t,e.decrypt&&!s),this._init=!0}},fe.aes._expandKey=function(e,t){return Qr||Va(),Oa(e,t)},fe.aes._updateBlock=$r,Mt("AES-ECB",fe.cipher.modes.ecb),Mt("AES-CBC",fe.cipher.modes.cbc),Mt("AES-CFB",fe.cipher.modes.cfb),Mt("AES-OFB",fe.cipher.modes.ofb),Mt("AES-CTR",fe.cipher.modes.ctr),Mt("AES-GCM",fe.cipher.modes.gcm);function Mt(e,t){var a=function(){return new fe.aes.Algorithm(e,t)};fe.cipher.registerAlgorithm(e,a)}var Qr=!1,Ht=4,Me,Wr,Pa,Lt,it;function Va(){Qr=!0,Pa=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;Me=new Array(256),Wr=new Array(256),Lt=new Array(4),it=new Array(4);for(var t=0;t<4;++t)Lt[t]=new Array(256),it[t]=new Array(256);for(var a=0,r=0,n,i,s,o,u,l,c,t=0;t<256;++t){o=r^r<<1^r<<2^r<<3^r<<4,o=o>>8^o&255^99,Me[a]=o,Wr[o]=a,u=e[o],n=e[a],i=e[n],s=e[i],l=u<<24^o<<16^o<<8^(o^u),c=(n^i^s)<<24^(a^s)<<16^(a^i^s)<<8^(a^n^s);for(var f=0;f<4;++f)Lt[f][a]=l,it[f][o]=c,l=l<<24|l>>>8,c=c<<24|c>>>8;a===0?a=r=1:(a=n^e[e[e[n^s]]],r^=e[e[r]])}}function Oa(e,t){for(var a=e.slice(0),r,n=1,i=a.length,s=i+6+1,o=Ht*s,u=i;u<o;++u)r=a[u-1],u%i===0?(r=Me[r>>>16&255]<<24^Me[r>>>8&255]<<16^Me[r&255]<<8^Me[r>>>24]^Pa[n]<<24,n++):i>6&&u%i===4&&(r=Me[r>>>24]<<24^Me[r>>>16&255]<<16^Me[r>>>8&255]<<8^Me[r&255]),a[u]=a[u-i]^r;if(t){var l,c=it[0],f=it[1],g=it[2],v=it[3],y=a.slice(0);o=a.length;for(var u=0,x=o-Ht;u<o;u+=Ht,x-=Ht)if(u===0||u===o-Ht)y[u]=a[x],y[u+1]=a[x+3],y[u+2]=a[x+2],y[u+3]=a[x+1];else for(var S=0;S<Ht;++S)l=a[x+S],y[u+(3&-S)]=c[Me[l>>>24]]^f[Me[l>>>16&255]]^g[Me[l>>>8&255]]^v[Me[l&255]];a=y}return a}function $r(e,t,a,r){var n=e.length/4-1,i,s,o,u,l;r?(i=it[0],s=it[1],o=it[2],u=it[3],l=Wr):(i=Lt[0],s=Lt[1],o=Lt[2],u=Lt[3],l=Me);var c,f,g,v,y,x,S;c=t[0]^e[0],f=t[r?3:1]^e[1],g=t[2]^e[2],v=t[r?1:3]^e[3];for(var I=3,A=1;A<n;++A)y=i[c>>>24]^s[f>>>16&255]^o[g>>>8&255]^u[v&255]^e[++I],x=i[f>>>24]^s[g>>>16&255]^o[v>>>8&255]^u[c&255]^e[++I],S=i[g>>>24]^s[v>>>16&255]^o[c>>>8&255]^u[f&255]^e[++I],v=i[v>>>24]^s[c>>>16&255]^o[f>>>8&255]^u[g&255]^e[++I],c=y,f=x,g=S;a[0]=l[c>>>24]<<24^l[f>>>16&255]<<16^l[g>>>8&255]<<8^l[v&255]^e[++I],a[r?3:1]=l[f>>>24]<<24^l[g>>>16&255]<<16^l[v>>>8&255]<<8^l[c&255]^e[++I],a[2]=l[g>>>24]<<24^l[v>>>16&255]<<16^l[c>>>8&255]<<8^l[f&255]^e[++I],a[r?1:3]=l[v>>>24]<<24^l[c>>>16&255]<<16^l[f>>>8&255]<<8^l[g&255]^e[++I]}function gr(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="AES-"+t,r;e.decrypt?r=fe.cipher.createDecipher(a,e.key):r=fe.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(i,s){var o=null;s instanceof fe.util.ByteBuffer&&(o=s,s={}),s=s||{},s.output=o,s.iv=i,n.call(r,s)},r}var tr=j;tr.pki=tr.pki||{};var Yr=tr.pki.oids=tr.oids=tr.oids||{};function N(e,t){Yr[e]=t,Yr[t]=e}function oe(e,t){Yr[e]=t}N("1.2.840.113549.1.1.1","rsaEncryption"),N("1.2.840.113549.1.1.4","md5WithRSAEncryption"),N("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),N("1.2.840.113549.1.1.7","RSAES-OAEP"),N("1.2.840.113549.1.1.8","mgf1"),N("1.2.840.113549.1.1.9","pSpecified"),N("1.2.840.113549.1.1.10","RSASSA-PSS"),N("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),N("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),N("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),N("1.3.101.112","EdDSA25519"),N("1.2.840.10040.4.3","dsa-with-sha1"),N("1.3.14.3.2.7","desCBC"),N("1.3.14.3.2.26","sha1"),N("1.3.14.3.2.29","sha1WithRSASignature"),N("2.16.840.1.101.3.4.2.1","sha256"),N("2.16.840.1.101.3.4.2.2","sha384"),N("2.16.840.1.101.3.4.2.3","sha512"),N("2.16.840.1.101.3.4.2.4","sha224"),N("2.16.840.1.101.3.4.2.5","sha512-224"),N("2.16.840.1.101.3.4.2.6","sha512-256"),N("1.2.840.113549.2.2","md2"),N("1.2.840.113549.2.5","md5"),N("1.2.840.113549.1.7.1","data"),N("1.2.840.113549.1.7.2","signedData"),N("1.2.840.113549.1.7.3","envelopedData"),N("1.2.840.113549.1.7.4","signedAndEnvelopedData"),N("1.2.840.113549.1.7.5","digestedData"),N("1.2.840.113549.1.7.6","encryptedData"),N("1.2.840.113549.1.9.1","emailAddress"),N("1.2.840.113549.1.9.2","unstructuredName"),N("1.2.840.113549.1.9.3","contentType"),N("1.2.840.113549.1.9.4","messageDigest"),N("1.2.840.113549.1.9.5","signingTime"),N("1.2.840.113549.1.9.6","counterSignature"),N("1.2.840.113549.1.9.7","challengePassword"),N("1.2.840.113549.1.9.8","unstructuredAddress"),N("1.2.840.113549.1.9.14","extensionRequest"),N("1.2.840.113549.1.9.20","friendlyName"),N("1.2.840.113549.1.9.21","localKeyId"),N("1.2.840.113549.1.9.22.1","x509Certificate"),N("1.2.840.113549.1.12.10.1.1","keyBag"),N("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),N("1.2.840.113549.1.12.10.1.3","certBag"),N("1.2.840.113549.1.12.10.1.4","crlBag"),N("1.2.840.113549.1.12.10.1.5","secretBag"),N("1.2.840.113549.1.12.10.1.6","safeContentsBag"),N("1.2.840.113549.1.5.13","pkcs5PBES2"),N("1.2.840.113549.1.5.12","pkcs5PBKDF2"),N("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),N("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),N("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),N("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),N("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),N("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),N("1.2.840.113549.2.7","hmacWithSHA1"),N("1.2.840.113549.2.8","hmacWithSHA224"),N("1.2.840.113549.2.9","hmacWithSHA256"),N("1.2.840.113549.2.10","hmacWithSHA384"),N("1.2.840.113549.2.11","hmacWithSHA512"),N("1.2.840.113549.3.7","des-EDE3-CBC"),N("2.16.840.1.101.3.4.1.2","aes128-CBC"),N("2.16.840.1.101.3.4.1.22","aes192-CBC"),N("2.16.840.1.101.3.4.1.42","aes256-CBC"),N("2.5.4.3","commonName"),N("2.5.4.4","surname"),N("2.5.4.5","serialNumber"),N("2.5.4.6","countryName"),N("2.5.4.7","localityName"),N("2.5.4.8","stateOrProvinceName"),N("2.5.4.9","streetAddress"),N("2.5.4.10","organizationName"),N("2.5.4.11","organizationalUnitName"),N("2.5.4.12","title"),N("2.5.4.13","description"),N("2.5.4.15","businessCategory"),N("2.5.4.17","postalCode"),N("2.5.4.42","givenName"),N("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),N("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),N("2.16.840.1.113730.1.1","nsCertType"),N("2.16.840.1.113730.1.13","nsComment"),oe("2.5.29.1","authorityKeyIdentifier"),oe("2.5.29.2","keyAttributes"),oe("2.5.29.3","certificatePolicies"),oe("2.5.29.4","keyUsageRestriction"),oe("2.5.29.5","policyMapping"),oe("2.5.29.6","subtreesConstraint"),oe("2.5.29.7","subjectAltName"),oe("2.5.29.8","issuerAltName"),oe("2.5.29.9","subjectDirectoryAttributes"),oe("2.5.29.10","basicConstraints"),oe("2.5.29.11","nameConstraints"),oe("2.5.29.12","policyConstraints"),oe("2.5.29.13","basicConstraints"),N("2.5.29.14","subjectKeyIdentifier"),N("2.5.29.15","keyUsage"),oe("2.5.29.16","privateKeyUsagePeriod"),N("2.5.29.17","subjectAltName"),N("2.5.29.18","issuerAltName"),N("2.5.29.19","basicConstraints"),oe("2.5.29.20","cRLNumber"),oe("2.5.29.21","cRLReason"),oe("2.5.29.22","expirationDate"),oe("2.5.29.23","instructionCode"),oe("2.5.29.24","invalidityDate"),oe("2.5.29.25","cRLDistributionPoints"),oe("2.5.29.26","issuingDistributionPoint"),oe("2.5.29.27","deltaCRLIndicator"),oe("2.5.29.28","issuingDistributionPoint"),oe("2.5.29.29","certificateIssuer"),oe("2.5.29.30","nameConstraints"),N("2.5.29.31","cRLDistributionPoints"),N("2.5.29.32","certificatePolicies"),oe("2.5.29.33","policyMappings"),oe("2.5.29.34","policyConstraints"),N("2.5.29.35","authorityKeyIdentifier"),oe("2.5.29.36","policyConstraints"),N("2.5.29.37","extKeyUsage"),oe("2.5.29.46","freshestCRL"),oe("2.5.29.54","inhibitAnyPolicy"),N("1.3.6.1.4.1.11129.2.4.2","timestampList"),N("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),N("1.3.6.1.5.5.7.3.1","serverAuth"),N("1.3.6.1.5.5.7.3.2","clientAuth"),N("1.3.6.1.5.5.7.3.3","codeSigning"),N("1.3.6.1.5.5.7.3.4","emailProtection"),N("1.3.6.1.5.5.7.3.8","timeStamping");var he=j,U=he.asn1=he.asn1||{};U.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},U.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},U.maxDepth=256,U.create=function(e,t,a,r,n){if(he.util.isArray(r)){for(var i=[],s=0;s<r.length;++s)r[s]!==void 0&&i.push(r[s]);r=i}var o={tagClass:e,type:t,constructed:a,composed:a||he.util.isArray(r),value:r};return n&&"bitStringContents"in n&&(o.bitStringContents=n.bitStringContents,o.original=U.copy(o)),o},U.copy=function(e,t){var a;if(he.util.isArray(e)){a=[];for(var r=0;r<e.length;++r)a.push(U.copy(e[r],t));return a}return typeof e=="string"?e:(a={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:U.copy(e.value,t)},t&&!t.excludeBitStringContents&&(a.bitStringContents=e.bitStringContents),a)},U.equals=function(e,t,a){if(he.util.isArray(e)){if(!he.util.isArray(t)||e.length!==t.length)return!1;for(var r=0;r<e.length;++r)if(!U.equals(e[r],t[r]))return!1;return!0}if(typeof e!=typeof t)return!1;if(typeof e=="string")return e===t;var n=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&U.equals(e.value,t.value);return a&&a.includeBitStringContents&&(n=n&&e.bitStringContents===t.bitStringContents),n},U.getBerValueLength=function(e){var t=e.getByte();if(t!==128){var a,r=t&128;return r?a=e.getInt((t&127)<<3):a=t,a}};function rr(e,t,a){if(a>t){var r=new Error("Too few bytes to parse DER.");throw r.available=e.length(),r.remaining=t,r.requested=a,r}}var yi=function(e,t){var a=e.getByte();if(t--,a!==128){var r,n=a&128;if(!n)r=a;else{var i=a&127;rr(e,t,i),r=e.getInt(i<<3)}if(r<0)throw new Error("Negative length: "+r);return r}};U.fromDer=function(e,t){t===void 0&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof t=="boolean"&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"maxDepth"in t||(t.maxDepth=U.maxDepth),typeof e=="string"&&(e=he.util.createBuffer(e));var a=e.length(),r=yr(e,e.length(),0,t);if(t.parseAllBytes&&e.length()!==0){var n=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw n.byteCount=a,n.remaining=e.length(),n}return r};function yr(e,t,a,r){if(a>=r.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var n;rr(e,t,2);var i=e.getByte();t--;var s=i&192,o=i&31;n=e.length();var u=yi(e,t);if(t-=n-e.length(),u!==void 0&&u>t){if(r.strict){var l=new Error("Too few bytes to read ASN.1 value.");throw l.available=e.length(),l.remaining=t,l.requested=u,l}u=t}var c,f,g=(i&32)===32;if(g)if(c=[],u===void 0)for(;;){if(rr(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}n=e.length(),c.push(yr(e,t,a+1,r)),t-=n-e.length()}else for(;u>0;)n=e.length(),c.push(yr(e,u,a+1,r)),t-=n-e.length(),u-=n-e.length();if(c===void 0&&s===U.Class.UNIVERSAL&&o===U.Type.BITSTRING&&(f=e.bytes(u)),c===void 0&&r.decodeBitStrings&&s===U.Class.UNIVERSAL&&o===U.Type.BITSTRING&&u>1){var v=e.read,y=t,x=0;if(o===U.Type.BITSTRING&&(rr(e,t,1),x=e.getByte(),t--),x===0)try{n=e.length();var S={strict:!0,decodeBitStrings:!0},I=yr(e,t,a+1,S),A=n-e.length();t-=A,o==U.Type.BITSTRING&&A++;var B=I.tagClass;A===u&&(B===U.Class.UNIVERSAL||B===U.Class.CONTEXT_SPECIFIC)&&(c=[I])}catch{}c===void 0&&(e.read=v,t=y)}if(c===void 0){if(u===void 0){if(r.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");u=t}if(o===U.Type.BMPSTRING)for(c="";u>0;u-=2)rr(e,t,2),c+=String.fromCharCode(e.getInt16()),t-=2;else c=e.getBytes(u),t-=u}var P=f===void 0?null:{bitStringContents:f};return U.create(s,o,g,c,P)}U.toDer=function(e){var t=he.util.createBuffer(),a=e.tagClass|e.type,r=he.util.createBuffer(),n=!1;if("bitStringContents"in e&&(n=!0,e.original&&(n=U.equals(e,e.original))),n)r.putBytes(e.bitStringContents);else if(e.composed){e.constructed?a|=32:r.putByte(0);for(var i=0;i<e.value.length;++i)e.value[i]!==void 0&&r.putBuffer(U.toDer(e.value[i]))}else if(e.type===U.Type.BMPSTRING)for(var i=0;i<e.value.length;++i)r.putInt16(e.value.charCodeAt(i));else e.type===U.Type.INTEGER&&e.value.length>1&&(e.value.charCodeAt(0)===0&&!(e.value.charCodeAt(1)&128)||e.value.charCodeAt(0)===255&&(e.value.charCodeAt(1)&128)===128)?r.putBytes(e.value.substr(1)):r.putBytes(e.value);if(t.putByte(a),r.length()<=127)t.putByte(r.length()&127);else{var s=r.length(),o="";do o+=String.fromCharCode(s&255),s=s>>>8;while(s>0);t.putByte(o.length|128);for(var i=o.length-1;i>=0;--i)t.putByte(o.charCodeAt(i))}return t.putBuffer(r),t},U.oidToDer=function(e){var t=e.split("."),a=he.util.createBuffer();a.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var r,n,i,s,o=2;o<t.length;++o){if(r=!0,n=[],i=parseInt(t[o],10),i>4294967295)throw new Error("OID value too large; max is 32-bits.");do s=i&127,i=i>>>7,r||(s|=128),n.push(s),r=!1;while(i>0);for(var u=n.length-1;u>=0;--u)a.putByte(n[u])}return a},U.derToOid=function(e){var t;typeof e=="string"&&(e=he.util.createBuffer(e));var a=e.getByte();t=Math.floor(a/40)+"."+a%40;for(var r=0;e.length()>0;){if(r>70368744177663)throw new Error("OID value too large; max is 53-bits.");a=e.getByte(),r=r*128,a&128?r+=a&127:(t+="."+(r+a),r=0)}return t},U.utcTimeToDate=function(e){var t=new Date,a=parseInt(e.substr(0,2),10);a=a>=50?1900+a:2e3+a;var r=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),i=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var u=e.charAt(10),l=10;u!=="+"&&u!=="-"&&(o=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(a,r,n),t.setUTCHours(i,s,o,0),l&&(u=e.charAt(l),u==="+"||u==="-")){var c=parseInt(e.substr(l+1,2),10),f=parseInt(e.substr(l+4,2),10),g=c*60+f;g*=6e4,u==="+"?t.setTime(+t-g):t.setTime(+t+g)}return t},U.generalizedTimeToDate=function(e){var t=new Date,a=parseInt(e.substr(0,4),10),r=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),u=0,l=0,c=!1;e.charAt(e.length-1)==="Z"&&(c=!0);var f=e.length-5,g=e.charAt(f);if(g==="+"||g==="-"){var v=parseInt(e.substr(f+1,2),10),y=parseInt(e.substr(f+4,2),10);l=v*60+y,l*=6e4,g==="+"&&(l*=-1),c=!0}return e.charAt(14)==="."&&(u=parseFloat(e.substr(14),10)*1e3),c?(t.setUTCFullYear(a,r,n),t.setUTCHours(i,s,o,u),t.setTime(+t+l)):(t.setFullYear(a,r,n),t.setHours(i,s,o,u)),t},U.dateToUtcTime=function(e){if(typeof e=="string")return e;var t="",a=[];a.push((""+e.getUTCFullYear()).substr(2)),a.push(""+(e.getUTCMonth()+1)),a.push(""+e.getUTCDate()),a.push(""+e.getUTCHours()),a.push(""+e.getUTCMinutes()),a.push(""+e.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(t+="0"),t+=a[r];return t+="Z",t},U.dateToGeneralizedTime=function(e){if(typeof e=="string")return e;var t="",a=[];a.push(""+e.getUTCFullYear()),a.push(""+(e.getUTCMonth()+1)),a.push(""+e.getUTCDate()),a.push(""+e.getUTCHours()),a.push(""+e.getUTCMinutes()),a.push(""+e.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(t+="0"),t+=a[r];return t+="Z",t},U.integerToDer=function(e){var t=he.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var a=new Error("Integer too large; max is 32-bits.");throw a.integer=e,a},U.derToInteger=function(e){typeof e=="string"&&(e=he.util.createBuffer(e));var t=e.length()*8;if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},U.validate=function(e,t,a,r){var n=!1;if((e.tagClass===t.tagClass||typeof t.tagClass>"u")&&(e.type===t.type||typeof t.type>"u"))if(e.constructed===t.constructed||typeof t.constructed>"u"){if(n=!0,t.value&&he.util.isArray(t.value))for(var i=0,s=0;n&&s<t.value.length;++s){var o=t.value[s];n=!!o.optional;var u=e.value[i];if(!u){o.optional||(n=!1,r&&r.push("["+t.name+'] Missing required element. Expected tag class "'+o.tagClass+'", type "'+o.type+'"'));continue}var l=typeof o.tagClass<"u"&&typeof o.type<"u";if(l&&(u.tagClass!==o.tagClass||u.type!==o.type))if(o.optional){n=!0;continue}else{n=!1,r&&r.push("["+t.name+"] Tag mismatch. Expected ("+o.tagClass+","+o.type+"), got ("+u.tagClass+","+u.type+")");break}var c=U.validate(u,o,a,r);if(c)++i,n=!0;else if(o.optional)n=!0;else{n=!1;break}}if(n&&a&&(t.capture&&(a[t.capture]=e.value),t.captureAsn1&&(a[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(a[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)a[t.captureBitStringValue]="";else{var f=e.bitStringContents.charCodeAt(0);if(f!==0)throw new Error("captureBitStringValue only supported for zero unused bits");a[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else r&&r.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');else r&&(e.tagClass!==t.tagClass&&r.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&r.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));return n};var Fa=/[^\\u0000-\\u00ff]/;U.prettyPrint=function(e,t,a){var r="";t=t||0,a=a||2,t>0&&(r+=`
`);for(var n="",i=0;i<t*a;++i)n+=" ";switch(r+=n+"Tag: ",e.tagClass){case U.Class.UNIVERSAL:r+="Universal:";break;case U.Class.APPLICATION:r+="Application:";break;case U.Class.CONTEXT_SPECIFIC:r+="Context-Specific:";break;case U.Class.PRIVATE:r+="Private:";break}if(e.tagClass===U.Class.UNIVERSAL)switch(r+=e.type,e.type){case U.Type.NONE:r+=" (None)";break;case U.Type.BOOLEAN:r+=" (Boolean)";break;case U.Type.INTEGER:r+=" (Integer)";break;case U.Type.BITSTRING:r+=" (Bit string)";break;case U.Type.OCTETSTRING:r+=" (Octet string)";break;case U.Type.NULL:r+=" (Null)";break;case U.Type.OID:r+=" (Object Identifier)";break;case U.Type.ODESC:r+=" (Object Descriptor)";break;case U.Type.EXTERNAL:r+=" (External or Instance of)";break;case U.Type.REAL:r+=" (Real)";break;case U.Type.ENUMERATED:r+=" (Enumerated)";break;case U.Type.EMBEDDED:r+=" (Embedded PDV)";break;case U.Type.UTF8:r+=" (UTF8)";break;case U.Type.ROID:r+=" (Relative Object Identifier)";break;case U.Type.SEQUENCE:r+=" (Sequence)";break;case U.Type.SET:r+=" (Set)";break;case U.Type.PRINTABLESTRING:r+=" (Printable String)";break;case U.Type.IA5String:r+=" (IA5String (ASCII))";break;case U.Type.UTCTIME:r+=" (UTC time)";break;case U.Type.GENERALIZEDTIME:r+=" (Generalized time)";break;case U.Type.BMPSTRING:r+=" (BMP String)";break}else r+=e.type;if(r+=`
`,r+=n+"Constructed: "+e.constructed+`
`,e.composed){for(var s=0,o="",i=0;i<e.value.length;++i)e.value[i]!==void 0&&(s+=1,o+=U.prettyPrint(e.value[i],t+1,a),i+1<e.value.length&&(o+=","));r+=n+"Sub values: "+s+o}else{if(r+=n+"Value: ",e.type===U.Type.OID){var u=U.derToOid(e.value);r+=u,he.pki&&he.pki.oids&&u in he.pki.oids&&(r+=" ("+he.pki.oids[u]+") ")}if(e.type===U.Type.INTEGER)try{r+=U.derToInteger(e.value)}catch{r+="0x"+he.util.bytesToHex(e.value)}else if(e.type===U.Type.BITSTRING){if(e.value.length>1?r+="0x"+he.util.bytesToHex(e.value.slice(1)):r+="(none)",e.value.length>0){var l=e.value.charCodeAt(0);l==1?r+=" (1 unused bit shown)":l>1&&(r+=" ("+l+" unused bits shown)")}}else if(e.type===U.Type.OCTETSTRING)Fa.test(e.value)||(r+="("+e.value+") "),r+="0x"+he.util.bytesToHex(e.value);else if(e.type===U.Type.UTF8)try{r+=he.util.decodeUtf8(e.value)}catch(c){if(c.message==="URI malformed")r+="0x"+he.util.bytesToHex(e.value)+" (malformed UTF8)";else throw c}else e.type===U.Type.PRINTABLESTRING||e.type===U.Type.IA5String?r+=e.value:Fa.test(e.value)?r+="0x"+he.util.bytesToHex(e.value):e.value.length===0?r+="[null]":r+=e.value}return r};var vr=j;vr.md=vr.md||{},vr.md.algorithms=vr.md.algorithms||{};var yt=j,vi=yt.hmac=yt.hmac||{};vi.create=function(){var e=null,t=null,a=null,r=null,n={};return n.start=function(i,s){if(i!==null)if(typeof i=="string")if(i=i.toLowerCase(),i in yt.md.algorithms)t=yt.md.algorithms[i].create();else throw new Error('Unknown hash algorithm "'+i+'"');else t=i;if(s===null)s=e;else{if(typeof s=="string")s=yt.util.createBuffer(s);else if(yt.util.isArray(s)){var o=s;s=yt.util.createBuffer();for(var u=0;u<o.length;++u)s.putByte(o[u])}var l=s.length();l>t.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),a=yt.util.createBuffer(),r=yt.util.createBuffer(),l=s.length();for(var u=0;u<l;++u){var o=s.at(u);a.putByte(54^o),r.putByte(92^o)}if(l<t.blockLength)for(var o=t.blockLength-l,u=0;u<o;++u)a.putByte(54),r.putByte(92);e=s,a=a.bytes(),r=r.bytes()}t.start(),t.update(a)},n.update=function(i){t.update(i)},n.getMac=function(){var i=t.digest().bytes();return t.start(),t.update(r),t.update(i),t.digest()},n.digest=n.getMac,n};var ot=j,Ka=ot.md5=ot.md5||{};ot.md.md5=ot.md.algorithms.md5=Ka,Ka.create=function(){Ma||mi();var e=null,t=ot.util.createBuffer(),a=new Array(16),r={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,i=0;i<n;++i)r.fullMessageLength.push(0);return t=ot.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},r},r.start(),r.update=function(n,i){i==="utf8"&&(n=ot.util.encodeUtf8(n));var s=n.length;r.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=s[1],s[1]=s[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(n),Ha(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=ot.util.createBuffer();n.putBytes(t.bytes());var i=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,s=i&r.blockLength-1;n.putBytes(jr.substr(0,r.blockLength-s));for(var o,u=0,l=r.fullMessageLength.length-1;l>=0;--l)o=r.fullMessageLength[l]*8+u,u=o/4294967296>>>0,n.putInt32Le(o>>>0);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};Ha(c,a,n);var f=ot.util.createBuffer();return f.putInt32Le(c.h0),f.putInt32Le(c.h1),f.putInt32Le(c.h2),f.putInt32Le(c.h3),f},r};var jr=null,mr=null,ar=null,Gt=null,Ma=!1;function mi(){jr=String.fromCharCode(128),jr+=ot.util.fillString(String.fromCharCode(0),64),mr=[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],ar=[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],Gt=new Array(64);for(var e=0;e<64;++e)Gt[e]=Math.floor(Math.abs(Math.sin(e+1))*4294967296);Ma=!0}function Ha(e,t,a){for(var r,n,i,s,o,u,l,c,f=a.length();f>=64;){for(n=e.h0,i=e.h1,s=e.h2,o=e.h3,c=0;c<16;++c)t[c]=a.getInt32Le(),u=o^i&(s^o),r=n+u+Gt[c]+t[c],l=ar[c],n=o,o=s,s=i,i+=r<<l|r>>>32-l;for(;c<32;++c)u=s^o&(i^s),r=n+u+Gt[c]+t[mr[c]],l=ar[c],n=o,o=s,s=i,i+=r<<l|r>>>32-l;for(;c<48;++c)u=i^s^o,r=n+u+Gt[c]+t[mr[c]],l=ar[c],n=o,o=s,s=i,i+=r<<l|r>>>32-l;for(;c<64;++c)u=s^(i|~o),r=n+u+Gt[c]+t[mr[c]],l=ar[c],n=o,o=s,s=i,i+=r<<l|r>>>32-l;e.h0=e.h0+n|0,e.h1=e.h1+i|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,f-=64}}var Cr=j,Ga=Cr.pem=Cr.pem||{};Ga.encode=function(e,t){t=t||{};var a="-----BEGIN "+e.type+`-----\r
`,r;if(e.procType&&(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]},a+=Er(r)),e.contentDomain&&(r={name:"Content-Domain",values:[e.contentDomain]},a+=Er(r)),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),a+=Er(r)),e.headers)for(var n=0;n<e.headers.length;++n)a+=Er(e.headers[n]);return e.procType&&(a+=`\r
`),a+=Cr.util.encode64(e.body,t.maxline||64)+`\r
`,a+="-----END "+e.type+`-----\r
`,a},Ga.decode=function(e){for(var t=[],a=/\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^:]+)/,n=/\r?\n/,i;i=a.exec(e),!!i;){var s=i[1];s==="NEW CERTIFICATE REQUEST"&&(s="CERTIFICATE REQUEST");var o={type:s,procType:null,contentDomain:null,dekInfo:null,headers:[],body:Cr.util.decode64(i[3])};if(t.push(o),!!i[2]){for(var u=i[2].split(n),l=0;i&&l<u.length;){for(var c=u[l].replace(/\s+$/,""),f=l+1;f<u.length;++f){var g=u[f];if(!/\s/.test(g[0]))break;c+=g,l=f}if(i=c.match(r),i){for(var v={name:i[1],values:[]},y=i[2].split(","),x=0;x<y.length;++x)v.values.push(Ci(y[x]));if(o.procType)if(!o.contentDomain&&v.name==="Content-Domain")o.contentDomain=y[0]||"";else if(!o.dekInfo&&v.name==="DEK-Info"){if(v.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');o.dekInfo={algorithm:y[0],parameters:y[1]||null}}else o.headers.push(v);else{if(v.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(v.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');o.procType={version:y[0],type:y[1]}}}++l}if(o.procType==="ENCRYPTED"&&!o.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(t.length===0)throw new Error("Invalid PEM formatted message.");return t};function Er(e){for(var t=e.name+": ",a=[],r=function(u,l){return" "+l},n=0;n<e.values.length;++n)a.push(e.values[n].replace(/^(\S+\r\n)/,r));t+=a.join(",")+`\r
`;for(var i=0,s=-1,n=0;n<t.length;++n,++i)if(i>65&&s!==-1){var o=t[s];o===","?(++s,t=t.substr(0,s)+`\r
`+t.substr(s)):t=t.substr(0,s)+`\r
`+o+t.substr(s+1),i=n-s-1,s=-1,++n}else(t[n]===" "||t[n]===" "||t[n]===",")&&(s=n);return t}function Ci(e){return e.replace(/^\s+/,"")}var ye=j;ye.des=ye.des||{},ye.des.startEncrypting=function(e,t,a,r){var n=xr({key:e,output:a,decrypt:!1,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n},ye.des.createEncryptionCipher=function(e,t){return xr({key:e,output:null,decrypt:!1,mode:t})},ye.des.startDecrypting=function(e,t,a,r){var n=xr({key:e,output:a,decrypt:!0,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n},ye.des.createDecryptionCipher=function(e,t){return xr({key:e,output:null,decrypt:!0,mode:t})},ye.des.Algorithm=function(e,t){var a=this;a.name=e,a.mode=new t({blockSize:8,cipher:{encrypt:function(r,n){return za(a._keys,r,n,!1)},decrypt:function(r,n){return za(a._keys,r,n,!0)}}}),a._init=!1},ye.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=ye.util.createBuffer(e.key);if(this.name.indexOf("3DES")===0&&t.length()!==24)throw new Error("Invalid Triple-DES key size: "+t.length()*8);this._keys=wi(t),this._init=!0}},lt("DES-ECB",ye.cipher.modes.ecb),lt("DES-CBC",ye.cipher.modes.cbc),lt("DES-CFB",ye.cipher.modes.cfb),lt("DES-OFB",ye.cipher.modes.ofb),lt("DES-CTR",ye.cipher.modes.ctr),lt("3DES-ECB",ye.cipher.modes.ecb),lt("3DES-CBC",ye.cipher.modes.cbc),lt("3DES-CFB",ye.cipher.modes.cfb),lt("3DES-OFB",ye.cipher.modes.ofb),lt("3DES-CTR",ye.cipher.modes.ctr);function lt(e,t){var a=function(){return new ye.des.Algorithm(e,t)};ye.cipher.registerAlgorithm(e,a)}var Ei=[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],xi=[-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],Si=[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],Ti=[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],Ii=[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],bi=[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],Ai=[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],Bi=[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 wi(e){for(var t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],a=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],r=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],n=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],i=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],o=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],c=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],g=[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],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],x=e.length()>8?3:1,S=[],I=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],A=0,B,P=0;P<x;P++){var L=e.getInt32(),R=e.getInt32();B=(L>>>4^R)&252645135,R^=B,L^=B<<4,B=(R>>>-16^L)&65535,L^=B,R^=B<<-16,B=(L>>>2^R)&858993459,R^=B,L^=B<<2,B=(R>>>-16^L)&65535,L^=B,R^=B<<-16,B=(L>>>1^R)&1431655765,R^=B,L^=B<<1,B=(R>>>8^L)&16711935,L^=B,R^=B<<8,B=(L>>>1^R)&1431655765,R^=B,L^=B<<1,B=L<<8|R>>>20&240,L=R<<24|R<<8&16711680|R>>>8&65280|R>>>24&240,R=B;for(var q=0;q<I.length;++q){I[q]?(L=L<<2|L>>>26,R=R<<2|R>>>26):(L=L<<1|L>>>27,R=R<<1|R>>>27),L&=-15,R&=-15;var Q=t[L>>>28]|a[L>>>24&15]|r[L>>>20&15]|n[L>>>16&15]|i[L>>>12&15]|s[L>>>8&15]|o[L>>>4&15],se=u[R>>>28]|l[R>>>24&15]|c[R>>>20&15]|f[R>>>16&15]|g[R>>>12&15]|v[R>>>8&15]|y[R>>>4&15];B=(se>>>16^Q)&65535,S[A++]=Q^B,S[A++]=se^B<<16}}return S}function za(e,t,a,r){var n=e.length===32?3:9,i;n===3?i=r?[30,-2,-2]:[0,32,2]:i=r?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var s,o=t[0],u=t[1];s=(o>>>4^u)&252645135,u^=s,o^=s<<4,s=(o>>>16^u)&65535,u^=s,o^=s<<16,s=(u>>>2^o)&858993459,o^=s,u^=s<<2,s=(u>>>8^o)&16711935,o^=s,u^=s<<8,s=(o>>>1^u)&1431655765,u^=s,o^=s<<1,o=o<<1|o>>>31,u=u<<1|u>>>31;for(var l=0;l<n;l+=3){for(var c=i[l+1],f=i[l+2],g=i[l];g!=c;g+=f){var v=u^e[g],y=(u>>>4|u<<28)^e[g+1];s=o,o=u,u=s^(xi[v>>>24&63]|Ti[v>>>16&63]|bi[v>>>8&63]|Bi[v&63]|Ei[y>>>24&63]|Si[y>>>16&63]|Ii[y>>>8&63]|Ai[y&63])}s=o,o=u,u=s}o=o>>>1|o<<31,u=u>>>1|u<<31,s=(o>>>1^u)&1431655765,u^=s,o^=s<<1,s=(u>>>8^o)&16711935,o^=s,u^=s<<8,s=(u>>>2^o)&858993459,o^=s,u^=s<<2,s=(o>>>16^u)&65535,u^=s,o^=s<<16,s=(o>>>4^u)&252645135,u^=s,o^=s<<4,a[0]=o,a[1]=u}function xr(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="DES-"+t,r;e.decrypt?r=ye.cipher.createDecipher(a,e.key):r=ye.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(i,s){var o=null;s instanceof ye.util.ByteBuffer&&(o=s,s={}),s=s||{},s.output=o,s.iv=i,n.call(r,s)},r}const Xr=oi(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var He=j,_i=He.pkcs5=He.pkcs5||{},vt;He.util.isNodejs&&!He.options.usePureJavaScript&&(vt=Xr),He.pbkdf2=_i.pbkdf2=function(e,t,a,r,n,i){if(typeof n=="function"&&(i=n,n=null),He.util.isNodejs&&!He.options.usePureJavaScript&&vt.pbkdf2&&(n===null||typeof n!="object")&&(vt.pbkdf2Sync.length>4||!n||n==="sha1"))return typeof n!="string"&&(n="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),i?vt.pbkdf2Sync.length===4?vt.pbkdf2(e,t,a,r,function(B,P){if(B)return i(B);i(null,P.toString("binary"))}):vt.pbkdf2(e,t,a,r,n,function(B,P){if(B)return i(B);i(null,P.toString("binary"))}):vt.pbkdf2Sync.length===4?vt.pbkdf2Sync(e,t,a,r).toString("binary"):vt.pbkdf2Sync(e,t,a,r,n).toString("binary");if((typeof n>"u"||n===null)&&(n="sha1"),typeof n=="string"){if(!(n in He.md.algorithms))throw new Error("Unknown hash algorithm: "+n);n=He.md[n].create()}var s=n.digestLength;if(r>4294967295*s){var o=new Error("Derived key is too long.");if(i)return i(o);throw o}var u=Math.ceil(r/s),l=r-(u-1)*s,c=He.hmac.create();c.start(n,e);var f="",g,v,y;if(!i){for(var x=1;x<=u;++x){c.start(null,null),c.update(t),c.update(He.util.int32ToBytes(x)),g=y=c.digest().getBytes();for(var S=2;S<=a;++S)c.start(null,null),c.update(y),v=c.digest().getBytes(),g=He.util.xorBytes(g,v,s),y=v;f+=x<u?g:g.substr(0,l)}return f}var x=1,S;function I(){if(x>u)return i(null,f);c.start(null,null),c.update(t),c.update(He.util.int32ToBytes(x)),g=y=c.digest().getBytes(),S=2,A()}function A(){if(S<=a)return c.start(null,null),c.update(y),v=c.digest().getBytes(),g=He.util.xorBytes(g,v,s),y=v,++S,He.util.setImmediate(A);f+=x<u?g:g.substr(0,l),++x,I()}I()};var ut=j,qa=ut.sha256=ut.sha256||{};ut.md.sha256=ut.md.algorithms.sha256=qa,qa.create=function(){Qa||Ni();var e=null,t=ut.util.createBuffer(),a=new Array(64),r={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,i=0;i<n;++i)r.fullMessageLength.push(0);return t=ut.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},r},r.start(),r.update=function(n,i){i==="utf8"&&(n=ut.util.encodeUtf8(n));var s=n.length;r.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=s[1],s[1]=s[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(n),$a(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=ut.util.createBuffer();n.putBytes(t.bytes());var i=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,s=i&r.blockLength-1;n.putBytes(Zr.substr(0,r.blockLength-s));for(var o,u,l=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)o=r.fullMessageLength[c+1]*8,u=o/4294967296>>>0,l+=u,n.putInt32(l>>>0),l=o>>>0;n.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};$a(f,a,n);var g=ut.util.createBuffer();return g.putInt32(f.h0),g.putInt32(f.h1),g.putInt32(f.h2),g.putInt32(f.h3),g.putInt32(f.h4),g.putInt32(f.h5),g.putInt32(f.h6),g.putInt32(f.h7),g},r};var Zr=null,Qa=!1,Wa=null;function Ni(){Zr=String.fromCharCode(128),Zr+=ut.util.fillString(String.fromCharCode(0),64),Wa=[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],Qa=!0}function $a(e,t,a){for(var r,n,i,s,o,u,l,c,f,g,v,y,x,S,I,A=a.length();A>=64;){for(l=0;l<16;++l)t[l]=a.getInt32();for(;l<64;++l)r=t[l-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,n=t[l-15],n=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[l]=r+t[l-7]+n+t[l-16]|0;for(c=e.h0,f=e.h1,g=e.h2,v=e.h3,y=e.h4,x=e.h5,S=e.h6,I=e.h7,l=0;l<64;++l)s=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),o=S^y&(x^S),i=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),u=c&f|g&(c^f),r=I+s+o+Wa[l]+t[l],n=i+u,I=S,S=x,x=y,y=v+r>>>0,v=g,g=f,f=c,c=r+n>>>0;e.h0=e.h0+c|0,e.h1=e.h1+f|0,e.h2=e.h2+g|0,e.h3=e.h3+v|0,e.h4=e.h4+y|0,e.h5=e.h5+x|0,e.h6=e.h6+S|0,e.h7=e.h7+I|0,A-=64}}var ct=j,Sr=null;ct.util.isNodejs&&!ct.options.usePureJavaScript&&!process.versions["node-webkit"]&&(Sr=Xr);var Ri=ct.prng=ct.prng||{};Ri.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},a=e.md,r=new Array(32),n=0;n<32;++n)r[n]=a.create();t.pools=r,t.pool=0,t.generate=function(l,c){if(!c)return t.generateSync(l);var f=t.plugin.cipher,g=t.plugin.increment,v=t.plugin.formatKey,y=t.plugin.formatSeed,x=ct.util.createBuffer();t.key=null,S();function S(I){if(I)return c(I);if(x.length()>=l)return c(null,x.getBytes(l));if(t.generated>1048575&&(t.key=null),t.key===null)return ct.util.nextTick(function(){i(S)});var A=f(t.key,t.seed);t.generated+=A.length,x.putBytes(A),t.key=v(f(t.key,g(t.seed))),t.seed=y(f(t.key,t.seed)),ct.util.setImmediate(S)}},t.generateSync=function(l){var c=t.plugin.cipher,f=t.plugin.increment,g=t.plugin.formatKey,v=t.plugin.formatSeed;t.key=null;for(var y=ct.util.createBuffer();y.length()<l;){t.generated>1048575&&(t.key=null),t.key===null&&s();var x=c(t.key,t.seed);t.generated+=x.length,y.putBytes(x),t.key=g(c(t.key,f(t.seed))),t.seed=v(c(t.key,t.seed))}return y.getBytes(l)};function i(l){if(t.pools[0].messageLength>=32)return o(),l();var c=32-t.pools[0].messageLength<<5;t.seedFile(c,function(f,g){if(f)return l(f);t.collect(g),o(),l()})}function s(){if(t.pools[0].messageLength>=32)return o();var l=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(l)),o()}function o(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var l=t.plugin.md.create();l.update(t.keyBytes);for(var c=1,f=0;f<32;++f)t.reseeds%c===0&&(l.update(t.pools[f].digest().getBytes()),t.pools[f].start()),c=c<<1;t.keyBytes=l.digest().getBytes(),l.start(),l.update(t.keyBytes);var g=l.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(g),t.generated=0}function u(l){var c=null,f=ct.util.globalScope,g=f.crypto||f.msCrypto;g&&g.getRandomValues&&(c=function(L){return g.getRandomValues(L)});var v=ct.util.createBuffer();if(c)for(;v.length()<l;){var y=Math.max(1,Math.min(l-v.length(),65536)/4),x=new Uint32Array(Math.floor(y));try{c(x);for(var S=0;S<x.length;++S)v.putInt32(x[S])}catch(L){if(!(typeof QuotaExceededError<"u"&&L instanceof QuotaExceededError))throw L}}if(v.length()<l)for(var I,A,B,P=Math.floor(Math.random()*65536);v.length()<l;){A=16807*(P&65535),I=16807*(P>>16),A+=(I&32767)<<16,A+=I>>15,A=(A&2147483647)+(A>>31),P=A&4294967295;for(var S=0;S<3;++S)B=P>>>(S<<3),B^=Math.floor(Math.random()*256),v.putByte(B&255)}return v.getBytes(l)}return Sr?(t.seedFile=function(l,c){Sr.randomBytes(l,function(f,g){if(f)return c(f);c(null,g.toString())})},t.seedFileSync=function(l){return Sr.randomBytes(l).toString()}):(t.seedFile=function(l,c){try{c(null,u(l))}catch(f){c(f)}},t.seedFileSync=u),t.collect=function(l){for(var c=l.length,f=0;f<c;++f)t.pools[t.pool].update(l.substr(f,1)),t.pool=t.pool===31?0:t.pool+1},t.collectInt=function(l,c){for(var f="",g=0;g<c;g+=8)f+=String.fromCharCode(l>>g&255);t.collect(f)},t.registerWorker=function(l){if(l===self)t.seedFile=function(f,g){function v(y){var x=y.data;x.forge&&x.forge.prng&&(self.removeEventListener("message",v),g(x.forge.prng.err,x.forge.prng.bytes))}self.addEventListener("message",v),self.postMessage({forge:{prng:{needed:f}}})};else{var c=function(f){var g=f.data;g.forge&&g.forge.prng&&t.seedFile(g.forge.prng.needed,function(v,y){l.postMessage({forge:{prng:{err:v,bytes:y}}})})};l.addEventListener("message",c)}},t};var Ae=j;(function(){if(Ae.random&&Ae.random.getBytes){Ae.random;return}(function(e){var t={},a=new Array(4),r=Ae.util.createBuffer();t.formatKey=function(f){var g=Ae.util.createBuffer(f);return f=new Array(4),f[0]=g.getInt32(),f[1]=g.getInt32(),f[2]=g.getInt32(),f[3]=g.getInt32(),Ae.aes._expandKey(f,!1)},t.formatSeed=function(f){var g=Ae.util.createBuffer(f);return f=new Array(4),f[0]=g.getInt32(),f[1]=g.getInt32(),f[2]=g.getInt32(),f[3]=g.getInt32(),f},t.cipher=function(f,g){return Ae.aes._updateBlock(f,g,a,!1),r.putInt32(a[0]),r.putInt32(a[1]),r.putInt32(a[2]),r.putInt32(a[3]),r.getBytes()},t.increment=function(f){return++f[3],f},t.md=Ae.md.sha256;function n(){var f=Ae.prng.create(t);return f.getBytes=function(g,v){return f.generate(g,v)},f.getBytesSync=function(g){return f.generate(g)},f}var i=n(),s=null,o=Ae.util.globalScope,u=o.crypto||o.msCrypto;if(u&&u.getRandomValues&&(s=function(f){return u.getRandomValues(f)}),Ae.options.usePureJavaScript||!Ae.util.isNodejs&&!s){if(i.collectInt(+new Date,32),typeof navigator<"u"){var l="";for(var c in navigator)try{typeof navigator[c]=="string"&&(l+=navigator[c])}catch{}i.collect(l),l=null}e&&(e().mousemove(function(f){i.collectInt(f.clientX,16),i.collectInt(f.clientY,16)}),e().keypress(function(f){i.collectInt(f.charCode,8)}))}if(!Ae.random)Ae.random=i;else for(var c in i)Ae.random[c]=i[c];Ae.random.createInstance=n,Ae.random})(typeof jQuery<"u"?jQuery:null)})();var We=j,Jr=[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],Ya=[1,2,3,5],Li=function(e,t){return e<<t&65535|(e&65535)>>16-t},ki=function(e,t){return(e&65535)>>t|e<<16-t&65535};We.rc2=We.rc2||{},We.rc2.expandKey=function(e,t){typeof e=="string"&&(e=We.util.createBuffer(e)),t=t||128;var a=e,r=e.length(),n=t,i=Math.ceil(n/8),s=255>>(n&7),o;for(o=r;o<128;o++)a.putByte(Jr[a.at(o-1)+a.at(o-r)&255]);for(a.setAt(128-i,Jr[a.at(128-i)&s]),o=127-i;o>=0;o--)a.setAt(o,Jr[a.at(o+1)^a.at(o+i)]);return a};var ja=function(e,t,a){var r=!1,n=null,i=null,s=null,o,u,l,c,f=[];for(e=We.rc2.expandKey(e,t),l=0;l<64;l++)f.push(e.getInt16Le());a?(o=function(y){for(l=0;l<4;l++)y[l]+=f[c]+(y[(l+3)%4]&y[(l+2)%4])+(~y[(l+3)%4]&y[(l+1)%4]),y[l]=Li(y[l],Ya[l]),c++},u=function(y){for(l=0;l<4;l++)y[l]+=f[y[(l+3)%4]&63]}):(o=function(y){for(l=3;l>=0;l--)y[l]=ki(y[l],Ya[l]),y[l]-=f[c]+(y[(l+3)%4]&y[(l+2)%4])+(~y[(l+3)%4]&y[(l+1)%4]),c--},u=function(y){for(l=3;l>=0;l--)y[l]-=f[y[(l+3)%4]&63]});var g=function(y){var x=[];for(l=0;l<4;l++){var S=n.getInt16Le();s!==null&&(a?S^=s.getInt16Le():s.putInt16Le(S)),x.push(S&65535)}c=a?0:63;for(var I=0;I<y.length;I++)for(var A=0;A<y[I][0];A++)y[I][1](x);for(l=0;l<4;l++)s!==null&&(a?s.putInt16Le(x[l]):x[l]^=s.getInt16Le()),i.putInt16Le(x[l])},v=null;return v={start:function(y,x){y&&typeof y=="string"&&(y=We.util.createBuffer(y)),r=!1,n=We.util.createBuffer(),i=x||new We.util.createBuffer,s=y,v.output=i},update:function(y){for(r||n.putBuffer(y);n.length()>=8;)g([[5,o],[1,u],[6,o],[1,u],[5,o]])},finish:function(y){var x=!0;if(a)if(y)x=y(8,n,!a);else{var S=n.length()===8?8:8-n.length();n.fillWithByte(S,S)}if(x&&(r=!0,v.update()),!a&&(x=n.length()===0,x))if(y)x=y(8,i,!a);else{var I=i.length(),A=i.at(I-1);A>I?x=!1:i.truncate(A)}return x}},v};We.rc2.startEncrypting=function(e,t,a){var r=We.rc2.createEncryptionCipher(e,128);return r.start(t,a),r},We.rc2.createEncryptionCipher=function(e,t){return ja(e,t,!0)},We.rc2.startDecrypting=function(e,t,a){var r=We.rc2.createDecryptionCipher(e,128);return r.start(t,a),r},We.rc2.createDecryptionCipher=function(e,t){return ja(e,t,!1)};var ea=j;ea.jsbn=ea.jsbn||{};var mt;function w(e,t,a){this.data=[],e!=null&&(typeof e=="number"?this.fromNumber(e,t,a):t==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,t))}ea.jsbn.BigInteger=w;function ne(){return new w(null)}function Di(e,t,a,r,n,i){for(;--i>=0;){var s=t*this.data[e++]+a.data[r]+n;n=Math.floor(s/67108864),a.data[r++]=s&67108863}return n}function Ui(e,t,a,r,n,i){for(var s=t&32767,o=t>>15;--i>=0;){var u=this.data[e]&32767,l=this.data[e++]>>15,c=o*u+l*s;u=s*u+((c&32767)<<15)+a.data[r]+(n&1073741823),n=(u>>>30)+(c>>>15)+o*l+(n>>>30),a.data[r++]=u&1073741823}return n}function Xa(e,t,a,r,n,i){for(var s=t&16383,o=t>>14;--i>=0;){var u=this.data[e]&16383,l=this.data[e++]>>14,c=o*u+l*s;u=s*u+((c&16383)<<14)+a.data[r]+n,n=(u>>28)+(c>>14)+o*l,a.data[r++]=u&268435455}return n}typeof navigator>"u"?(w.prototype.am=Xa,mt=28):navigator.appName=="Microsoft Internet Explorer"?(w.prototype.am=Ui,mt=30):navigator.appName!="Netscape"?(w.prototype.am=Di,mt=26):(w.prototype.am=Xa,mt=28),w.prototype.DB=mt,w.prototype.DM=(1<<mt)-1,w.prototype.DV=1<<mt;var ta=52;w.prototype.FV=Math.pow(2,ta),w.prototype.F1=ta-mt,w.prototype.F2=2*mt-ta;var Pi="0123456789abcdefghijklmnopqrstuvwxyz",Tr=new Array,zt,et;for(zt="0".charCodeAt(0),et=0;et<=9;++et)Tr[zt++]=et;for(zt="a".charCodeAt(0),et=10;et<36;++et)Tr[zt++]=et;for(zt="A".charCodeAt(0),et=10;et<36;++et)Tr[zt++]=et;function Za(e){return Pi.charAt(e)}function Ja(e,t){var a=Tr[e.charCodeAt(t)];return a??-1}function Vi(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function Oi(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function Tt(e){var t=ne();return t.fromInt(e),t}function Fi(e,t){var a;if(t==16)a=4;else if(t==8)a=3;else if(t==256)a=8;else if(t==2)a=1;else if(t==32)a=5;else if(t==4)a=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var r=e.length,n=!1,i=0;--r>=0;){var s=a==8?e[r]&255:Ja(e,r);if(s<0){e.charAt(r)=="-"&&(n=!0);continue}n=!1,i==0?this.data[this.t++]=s:i+a>this.DB?(this.data[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this.data[this.t++]=s>>this.DB-i):this.data[this.t-1]|=s<<i,i+=a,i>=this.DB&&(i-=this.DB)}a==8&&e[0]&128&&(this.s=-1,i>0&&(this.data[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),n&&w.ZERO.subTo(this,this)}function Ki(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t}function Mi(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var a=(1<<t)-1,r,n=!1,i="",s=this.t,o=this.DB-s*this.DB%t;if(s-- >0)for(o<this.DB&&(r=this.data[s]>>o)>0&&(n=!0,i=Za(r));s>=0;)o<t?(r=(this.data[s]&(1<<o)-1)<<t-o,r|=this.data[--s]>>(o+=this.DB-t)):(r=this.data[s]>>(o-=t)&a,o<=0&&(o+=this.DB,--s)),r>0&&(n=!0),n&&(i+=Za(r));return n?i:"0"}function Hi(){var e=ne();return w.ZERO.subTo(this,e),e}function Gi(){return this.s<0?this.negate():this}function zi(e){var t=this.s-e.s;if(t!=0)return t;var a=this.t;if(t=a-e.t,t!=0)return this.s<0?-t:t;for(;--a>=0;)if((t=this.data[a]-e.data[a])!=0)return t;return 0}function Ir(e){var t=1,a;return(a=e>>>16)!=0&&(e=a,t+=16),(a=e>>8)!=0&&(e=a,t+=8),(a=e>>4)!=0&&(e=a,t+=4),(a=e>>2)!=0&&(e=a,t+=2),(a=e>>1)!=0&&(e=a,t+=1),t}function qi(){return this.t<=0?0:this.DB*(this.t-1)+Ir(this.data[this.t-1]^this.s&this.DM)}function Qi(e,t){var a;for(a=this.t-1;a>=0;--a)t.data[a+e]=this.data[a];for(a=e-1;a>=0;--a)t.data[a]=0;t.t=this.t+e,t.s=this.s}function Wi(e,t){for(var a=e;a<this.t;++a)t.data[a-e]=this.data[a];t.t=Math.max(this.t-e,0),t.s=this.s}function $i(e,t){var a=e%this.DB,r=this.DB-a,n=(1<<r)-1,i=Math.floor(e/this.DB),s=this.s<<a&this.DM,o;for(o=this.t-1;o>=0;--o)t.data[o+i+1]=this.data[o]>>r|s,s=(this.data[o]&n)<<a;for(o=i-1;o>=0;--o)t.data[o]=0;t.data[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}function Yi(e,t){t.s=this.s;var a=Math.floor(e/this.DB);if(a>=this.t){t.t=0;return}var r=e%this.DB,n=this.DB-r,i=(1<<r)-1;t.data[0]=this.data[a]>>r;for(var s=a+1;s<this.t;++s)t.data[s-a-1]|=(this.data[s]&i)<<n,t.data[s-a]=this.data[s]>>r;r>0&&(t.data[this.t-a-1]|=(this.s&i)<<n),t.t=this.t-a,t.clamp()}function ji(e,t){for(var a=0,r=0,n=Math.min(e.t,this.t);a<n;)r+=this.data[a]-e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;a<this.t;)r+=this.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;a<e.t;)r-=e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t.data[a++]=this.DV+r:r>0&&(t.data[a++]=r),t.t=a,t.clamp()}function Xi(e,t){var a=this.abs(),r=e.abs(),n=a.t;for(t.t=n+r.t;--n>=0;)t.data[n]=0;for(n=0;n<r.t;++n)t.data[n+a.t]=a.am(0,r.data[n],t,n,0,a.t);t.s=0,t.clamp(),this.s!=e.s&&w.ZERO.subTo(t,t)}function Zi(e){for(var t=this.abs(),a=e.t=2*t.t;--a>=0;)e.data[a]=0;for(a=0;a<t.t-1;++a){var r=t.am(a,t.data[a],e,2*a,0,1);(e.data[a+t.t]+=t.am(a+1,2*t.data[a],e,2*a+1,r,t.t-a-1))>=t.DV&&(e.data[a+t.t]-=t.DV,e.data[a+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(a,t.data[a],e,2*a,0,1)),e.s=0,e.clamp()}function Ji(e,t,a){var r=e.abs();if(!(r.t<=0)){var n=this.abs();if(n.t<r.t){t?.fromInt(0),a!=null&&this.copyTo(a);return}a==null&&(a=ne());var i=ne(),s=this.s,o=e.s,u=this.DB-Ir(r.data[r.t-1]);u>0?(r.lShiftTo(u,i),n.lShiftTo(u,a)):(r.copyTo(i),n.copyTo(a));var l=i.t,c=i.data[l-1];if(c!=0){var f=c*(1<<this.F1)+(l>1?i.data[l-2]>>this.F2:0),g=this.FV/f,v=(1<<this.F1)/f,y=1<<this.F2,x=a.t,S=x-l,I=t??ne();for(i.dlShiftTo(S,I),a.compareTo(I)>=0&&(a.data[a.t++]=1,a.subTo(I,a)),w.ONE.dlShiftTo(l,I),I.subTo(i,i);i.t<l;)i.data[i.t++]=0;for(;--S>=0;){var A=a.data[--x]==c?this.DM:Math.floor(a.data[x]*g+(a.data[x-1]+y)*v);if((a.data[x]+=i.am(0,A,a,S,0,l))<A)for(i.dlShiftTo(S,I),a.subTo(I,a);a.data[x]<--A;)a.subTo(I,a)}t!=null&&(a.drShiftTo(l,t),s!=o&&w.ZERO.subTo(t,t)),a.t=l,a.clamp(),u>0&&a.rShiftTo(u,a),s<0&&w.ZERO.subTo(a,a)}}}function es(e){var t=ne();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(w.ZERO)>0&&e.subTo(t,t),t}function kt(e){this.m=e}function ts(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function rs(e){return e}function as(e){e.divRemTo(this.m,null,e)}function ns(e,t,a){e.multiplyTo(t,a),this.reduce(a)}function is(e,t){e.squareTo(t),this.reduce(t)}kt.prototype.convert=ts,kt.prototype.revert=rs,kt.prototype.reduce=as,kt.prototype.mulTo=ns,kt.prototype.sqrTo=is;function ss(){if(this.t<1)return 0;var e=this.data[0];if(!(e&1))return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Dt(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function os(e){var t=ne();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(w.ZERO)>0&&this.m.subTo(t,t),t}function ls(e){var t=ne();return e.copyTo(t),this.reduce(t),t}function us(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var a=e.data[t]&32767,r=a*this.mpl+((a*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(a=t+this.m.t,e.data[a]+=this.m.am(0,r,e,t,0,this.m.t);e.data[a]>=e.DV;)e.data[a]-=e.DV,e.data[++a]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function cs(e,t){e.squareTo(t),this.reduce(t)}function fs(e,t,a){e.multiplyTo(t,a),this.reduce(a)}Dt.prototype.convert=os,Dt.prototype.revert=ls,Dt.prototype.reduce=us,Dt.prototype.mulTo=fs,Dt.prototype.sqrTo=cs;function ds(){return(this.t>0?this.data[0]&1:this.s)==0}function hs(e,t){if(e>4294967295||e<1)return w.ONE;var a=ne(),r=ne(),n=t.convert(this),i=Ir(e)-1;for(n.copyTo(a);--i>=0;)if(t.sqrTo(a,r),(e&1<<i)>0)t.mulTo(r,n,a);else{var s=a;a=r,r=s}return t.revert(a)}function ps(e,t){var a;return e<256||t.isEven()?a=new kt(t):a=new Dt(t),this.exp(e,a)}w.prototype.copyTo=Vi,w.prototype.fromInt=Oi,w.prototype.fromString=Fi,w.prototype.clamp=Ki,w.prototype.dlShiftTo=Qi,w.prototype.drShiftTo=Wi,w.prototype.lShiftTo=$i,w.prototype.rShiftTo=Yi,w.prototype.subTo=ji,w.prototype.multiplyTo=Xi,w.prototype.squareTo=Zi,w.prototype.divRemTo=Ji,w.prototype.invDigit=ss,w.prototype.isEven=ds,w.prototype.exp=hs,w.prototype.toString=Mi,w.prototype.negate=Hi,w.prototype.abs=Gi,w.prototype.compareTo=zi,w.prototype.bitLength=qi,w.prototype.mod=es,w.prototype.modPowInt=ps,w.ZERO=Tt(0),w.ONE=Tt(1);function gs(){var e=ne();return this.copyTo(e),e}function ys(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function vs(){return this.t==0?this.s:this.data[0]<<24>>24}function ms(){return this.t==0?this.s:this.data[0]<<16>>16}function Cs(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function Es(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function xs(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),a=Math.pow(e,t),r=Tt(a),n=ne(),i=ne(),s="";for(this.divRemTo(r,n,i);n.signum()>0;)s=(a+i.intValue()).toString(e).substr(1)+s,n.divRemTo(r,n,i);return i.intValue().toString(e)+s}function Ss(e,t){this.fromInt(0),t==null&&(t=10);for(var a=this.chunkSize(t),r=Math.pow(t,a),n=!1,i=0,s=0,o=0;o<e.length;++o){var u=Ja(e,o);if(u<0){e.charAt(o)=="-"&&this.signum()==0&&(n=!0);continue}s=t*s+u,++i>=a&&(this.dMultiply(r),this.dAddOffset(s,0),i=0,s=0)}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(s,0)),n&&w.ZERO.subTo(this,this)}function Ts(e,t,a){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,a),this.testBit(e-1)||this.bitwiseTo(w.ONE.shiftLeft(e-1),ra,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(w.ONE.shiftLeft(e-1),this);else{var r=new Array,n=e&7;r.length=(e>>3)+1,t.nextBytes(r),n>0?r[0]&=(1<<n)-1:r[0]=0,this.fromString(r,256)}}function Is(){var e=this.t,t=new Array;t[0]=this.s;var a=this.DB-e*this.DB%8,r,n=0;if(e-- >0)for(a<this.DB&&(r=this.data[e]>>a)!=(this.s&this.DM)>>a&&(t[n++]=r|this.s<<this.DB-a);e>=0;)a<8?(r=(this.data[e]&(1<<a)-1)<<8-a,r|=this.data[--e]>>(a+=this.DB-8)):(r=this.data[e]>>(a-=8)&255,a<=0&&(a+=this.DB,--e)),r&128&&(r|=-256),n==0&&(this.s&128)!=(r&128)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t}function bs(e){return this.compareTo(e)==0}function As(e){return this.compareTo(e)<0?this:e}function Bs(e){return this.compareTo(e)>0?this:e}function ws(e,t,a){var r,n,i=Math.min(e.t,this.t);for(r=0;r<i;++r)a.data[r]=t(this.data[r],e.data[r]);if(e.t<this.t){for(n=e.s&this.DM,r=i;r<this.t;++r)a.data[r]=t(this.data[r],n);a.t=this.t}else{for(n=this.s&this.DM,r=i;r<e.t;++r)a.data[r]=t(n,e.data[r]);a.t=e.t}a.s=t(this.s,e.s),a.clamp()}function _s(e,t){return e&t}function Ns(e){var t=ne();return this.bitwiseTo(e,_s,t),t}function ra(e,t){return e|t}function Rs(e){var t=ne();return this.bitwiseTo(e,ra,t),t}function en(e,t){return e^t}function Ls(e){var t=ne();return this.bitwiseTo(e,en,t),t}function tn(e,t){return e&~t}function ks(e){var t=ne();return this.bitwiseTo(e,tn,t),t}function Ds(){for(var e=ne(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e}function Us(e){var t=ne();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function Ps(e){var t=ne();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function Vs(e){if(e==0)return-1;var t=0;return e&65535||(e>>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function Os(){for(var e=0;e<this.t;++e)if(this.data[e]!=0)return e*this.DB+Vs(this.data[e]);return this.s<0?this.t*this.DB:-1}function Fs(e){for(var t=0;e!=0;)e&=e-1,++t;return t}function Ks(){for(var e=0,t=this.s&this.DM,a=0;a<this.t;++a)e+=Fs(this.data[a]^t);return e}function Ms(e){var t=Math.floor(e/this.DB);return t>=this.t?this.s!=0:(this.data[t]&1<<e%this.DB)!=0}function Hs(e,t){var a=w.ONE.shiftLeft(e);return this.bitwiseTo(a,t,a),a}function Gs(e){return this.changeBit(e,ra)}function zs(e){return this.changeBit(e,tn)}function qs(e){return this.changeBit(e,en)}function Qs(e,t){for(var a=0,r=0,n=Math.min(e.t,this.t);a<n;)r+=this.data[a]+e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;a<this.t;)r+=this.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;a<e.t;)r+=e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t.data[a++]=r:r<-1&&(t.data[a++]=this.DV+r),t.t=a,t.clamp()}function Ws(e){var t=ne();return this.addTo(e,t),t}function $s(e){var t=ne();return this.subTo(e,t),t}function Ys(e){var t=ne();return this.multiplyTo(e,t),t}function js(e){var t=ne();return this.divRemTo(e,t,null),t}function Xs(e){var t=ne();return this.divRemTo(e,null,t),t}function Zs(e){var t=ne(),a=ne();return this.divRemTo(e,t,a),new Array(t,a)}function Js(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function eo(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function nr(){}function rn(e){return e}function to(e,t,a){e.multiplyTo(t,a)}function ro(e,t){e.squareTo(t)}nr.prototype.convert=rn,nr.prototype.revert=rn,nr.prototype.mulTo=to,nr.prototype.sqrTo=ro;function ao(e){return this.exp(e,new nr)}function no(e,t,a){var r=Math.min(this.t+e.t,t);for(a.s=0,a.t=r;r>0;)a.data[--r]=0;var n;for(n=a.t-this.t;r<n;++r)a.data[r+this.t]=this.am(0,e.data[r],a,r,0,this.t);for(n=Math.min(e.t,t);r<n;++r)this.am(0,e.data[r],a,r,0,t-r);a.clamp()}function io(e,t,a){--t;var r=a.t=this.t+e.t-t;for(a.s=0;--r>=0;)a.data[r]=0;for(r=Math.max(t-this.t,0);r<e.t;++r)a.data[this.t+r-t]=this.am(t-r,e.data[r],a,0,0,this.t+r-t);a.clamp(),a.drShiftTo(1,a)}function qt(e){this.r2=ne(),this.q3=ne(),w.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function so(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=ne();return e.copyTo(t),this.reduce(t),t}function oo(e){return e}function lo(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function uo(e,t){e.squareTo(t),this.reduce(t)}function co(e,t,a){e.multiplyTo(t,a),this.reduce(a)}qt.prototype.convert=so,qt.prototype.revert=oo,qt.prototype.reduce=lo,qt.prototype.mulTo=co,qt.prototype.sqrTo=uo;function fo(e,t){var a=e.bitLength(),r,n=Tt(1),i;if(a<=0)return n;a<18?r=1:a<48?r=3:a<144?r=4:a<768?r=5:r=6,a<8?i=new kt(t):t.isEven()?i=new qt(t):i=new Dt(t);var s=new Array,o=3,u=r-1,l=(1<<r)-1;if(s[1]=i.convert(this),r>1){var c=ne();for(i.sqrTo(s[1],c);o<=l;)s[o]=ne(),i.mulTo(c,s[o-2],s[o]),o+=2}var f=e.t-1,g,v=!0,y=ne(),x;for(a=Ir(e.data[f])-1;f>=0;){for(a>=u?g=e.data[f]>>a-u&l:(g=(e.data[f]&(1<<a+1)-1)<<u-a,f>0&&(g|=e.data[f-1]>>this.DB+a-u)),o=r;!(g&1);)g>>=1,--o;if((a-=o)<0&&(a+=this.DB,--f),v)s[g].copyTo(n),v=!1;else{for(;o>1;)i.sqrTo(n,y),i.sqrTo(y,n),o-=2;o>0?i.sqrTo(n,y):(x=n,n=y,y=x),i.mulTo(y,s[g],n)}for(;f>=0&&!(e.data[f]&1<<a);)i.sqrTo(n,y),x=n,n=y,y=x,--a<0&&(a=this.DB-1,--f)}return i.revert(n)}function ho(e){var t=this.s<0?this.negate():this.clone(),a=e.s<0?e.negate():e.clone();if(t.compareTo(a)<0){var r=t;t=a,a=r}var n=t.getLowestSetBit(),i=a.getLowestSetBit();if(i<0)return t;for(n<i&&(i=n),i>0&&(t.rShiftTo(i,t),a.rShiftTo(i,a));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=a.getLowestSetBit())>0&&a.rShiftTo(n,a),t.compareTo(a)>=0?(t.subTo(a,t),t.rShiftTo(1,t)):(a.subTo(t,a),a.rShiftTo(1,a));return i>0&&a.lShiftTo(i,a),a}function po(e){if(e<=0)return 0;var t=this.DV%e,a=this.s<0?e-1:0;if(this.t>0)if(t==0)a=this.data[0]%e;else for(var r=this.t-1;r>=0;--r)a=(t*a+this.data[r])%e;return a}function go(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return w.ZERO;for(var a=e.clone(),r=this.clone(),n=Tt(1),i=Tt(0),s=Tt(0),o=Tt(1);a.signum()!=0;){for(;a.isEven();)a.rShiftTo(1,a),t?((!n.isEven()||!i.isEven())&&(n.addTo(this,n),i.subTo(e,i)),n.rShiftTo(1,n)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;r.isEven();)r.rShiftTo(1,r),t?((!s.isEven()||!o.isEven())&&(s.addTo(this,s),o.subTo(e,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);a.compareTo(r)>=0?(a.subTo(r,a),t&&n.subTo(s,n),i.subTo(o,i)):(r.subTo(a,r),t&&s.subTo(n,s),o.subTo(i,o))}if(r.compareTo(w.ONE)!=0)return w.ZERO;if(o.compareTo(e)>=0)return o.subtract(e);if(o.signum()<0)o.addTo(e,o);else return o;return o.signum()<0?o.add(e):o}var st=[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],yo=(1<<26)/st[st.length-1];function vo(e){var t,a=this.abs();if(a.t==1&&a.data[0]<=st[st.length-1]){for(t=0;t<st.length;++t)if(a.data[0]==st[t])return!0;return!1}if(a.isEven())return!1;for(t=1;t<st.length;){for(var r=st[t],n=t+1;n<st.length&&r<yo;)r*=st[n++];for(r=a.modInt(r);t<n;)if(r%st[t++]==0)return!1}return a.millerRabin(e)}function mo(e){var t=this.subtract(w.ONE),a=t.getLowestSetBit();if(a<=0)return!1;for(var r=t.shiftRight(a),n=Co(),i,s=0;s<e;++s){do i=new w(this.bitLength(),n);while(i.compareTo(w.ONE)<=0||i.compareTo(t)>=0);var o=i.modPow(r,this);if(o.compareTo(w.ONE)!=0&&o.compareTo(t)!=0){for(var u=1;u++<a&&o.compareTo(t)!=0;)if(o=o.modPowInt(2,this),o.compareTo(w.ONE)==0)return!1;if(o.compareTo(t)!=0)return!1}}return!0}function Co(){return{nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(Math.random()*256)}}}w.prototype.chunkSize=Cs,w.prototype.toRadix=xs,w.prototype.fromRadix=Ss,w.prototype.fromNumber=Ts,w.prototype.bitwiseTo=ws,w.prototype.changeBit=Hs,w.prototype.addTo=Qs,w.prototype.dMultiply=Js,w.prototype.dAddOffset=eo,w.prototype.multiplyLowerTo=no,w.prototype.multiplyUpperTo=io,w.prototype.modInt=po,w.prototype.millerRabin=mo,w.prototype.clone=gs,w.prototype.intValue=ys,w.prototype.byteValue=vs,w.prototype.shortValue=ms,w.prototype.signum=Es,w.prototype.toByteArray=Is,w.prototype.equals=bs,w.prototype.min=As,w.prototype.max=Bs,w.prototype.and=Ns,w.prototype.or=Rs,w.prototype.xor=Ls,w.prototype.andNot=ks,w.prototype.not=Ds,w.prototype.shiftLeft=Us,w.prototype.shiftRight=Ps,w.prototype.getLowestSetBit=Os,w.prototype.bitCount=Ks,w.prototype.testBit=Ms,w.prototype.setBit=Gs,w.prototype.clearBit=zs,w.prototype.flipBit=qs,w.prototype.add=Ws,w.prototype.subtract=$s,w.prototype.multiply=Ys,w.prototype.divide=js,w.prototype.remainder=Xs,w.prototype.divideAndRemainder=Zs,w.prototype.modPow=fo,w.prototype.modInverse=go,w.prototype.pow=ao,w.prototype.gcd=ho,w.prototype.isProbablePrime=vo;var ft=j,an=ft.sha1=ft.sha1||{};ft.md.sha1=ft.md.algorithms.sha1=an,an.create=function(){nn||Eo();var e=null,t=ft.util.createBuffer(),a=new Array(80),r={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,i=0;i<n;++i)r.fullMessageLength.push(0);return t=ft.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},r},r.start(),r.update=function(n,i){i==="utf8"&&(n=ft.util.encodeUtf8(n));var s=n.length;r.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=s[1],s[1]=s[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(n),sn(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=ft.util.createBuffer();n.putBytes(t.bytes());var i=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,s=i&r.blockLength-1;n.putBytes(aa.substr(0,r.blockLength-s));for(var o,u,l=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)o=r.fullMessageLength[c+1]*8,u=o/4294967296>>>0,l+=u,n.putInt32(l>>>0),l=o>>>0;n.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};sn(f,a,n);var g=ft.util.createBuffer();return g.putInt32(f.h0),g.putInt32(f.h1),g.putInt32(f.h2),g.putInt32(f.h3),g.putInt32(f.h4),g},r};var aa=null,nn=!1;function Eo(){aa=String.fromCharCode(128),aa+=ft.util.fillString(String.fromCharCode(0),64),nn=!0}function sn(e,t,a){for(var r,n,i,s,o,u,l,c,f=a.length();f>=64;){for(n=e.h0,i=e.h1,s=e.h2,o=e.h3,u=e.h4,c=0;c<16;++c)r=a.getInt32(),t[c]=r,l=o^i&(s^o),r=(n<<5|n>>>27)+l+u+1518500249+r,u=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=r;for(;c<20;++c)r=t[c-3]^t[c-8]^t[c-14]^t[c-16],r=r<<1|r>>>31,t[c]=r,l=o^i&(s^o),r=(n<<5|n>>>27)+l+u+1518500249+r,u=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=r;for(;c<32;++c)r=t[c-3]^t[c-8]^t[c-14]^t[c-16],r=r<<1|r>>>31,t[c]=r,l=i^s^o,r=(n<<5|n>>>27)+l+u+1859775393+r,u=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=r;for(;c<40;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=i^s^o,r=(n<<5|n>>>27)+l+u+1859775393+r,u=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=r;for(;c<60;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=i&s|o&(i^s),r=(n<<5|n>>>27)+l+u+2400959708+r,u=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=r;for(;c<80;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=i^s^o,r=(n<<5|n>>>27)+l+u+3395469782+r,u=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=r;e.h0=e.h0+n|0,e.h1=e.h1+i|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,e.h4=e.h4+u|0,f-=64}}var dt=j,on=dt.pkcs1=dt.pkcs1||{};on.encode_rsa_oaep=function(e,t,a){var r,n,i,s;typeof a=="string"?(r=a,n=arguments[3]||void 0,i=arguments[4]||void 0):a&&(r=a.label||void 0,n=a.seed||void 0,i=a.md||void 0,a.mgf1&&a.mgf1.md&&(s=a.mgf1.md)),i?i.start():i=dt.md.sha1.create(),s||(s=i);var o=Math.ceil(e.n.bitLength()/8),u=o-2*i.digestLength-2;if(t.length>u){var l=new Error("RSAES-OAEP input message length is too long.");throw l.length=t.length,l.maxLength=u,l}r||(r=""),i.update(r,"raw");for(var c=i.digest(),f="",g=u-t.length,v=0;v<g;v++)f+="\0";var y=c.getBytes()+f+""+t;if(!n)n=dt.random.getBytes(i.digestLength);else if(n.length!==i.digestLength){var l=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw l.seedLength=n.length,l.digestLength=i.digestLength,l}var x=br(n,o-i.digestLength-1,s),S=dt.util.xorBytes(y,x,y.length),I=br(S,i.digestLength,s),A=dt.util.xorBytes(n,I,n.length);return"\0"+A+S},on.decode_rsa_oaep=function(e,t,a){var r,n,i;typeof a=="string"?(r=a,n=arguments[3]||void 0):a&&(r=a.label||void 0,n=a.md||void 0,a.mgf1&&a.mgf1.md&&(i=a.mgf1.md));var s=Math.ceil(e.n.bitLength()/8);if(t.length!==s){var S=new Error("RSAES-OAEP encoded message length is invalid.");throw S.length=t.length,S.expectedLength=s,S}if(n===void 0?n=dt.md.sha1.create():n.start(),i||(i=n),s<2*n.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");r||(r=""),n.update(r,"raw");for(var o=n.digest().getBytes(),u=t.charAt(0),l=t.substring(1,n.digestLength+1),c=t.substring(1+n.digestLength),f=br(c,n.digestLength,i),g=dt.util.xorBytes(l,f,l.length),v=br(g,s-n.digestLength-1,i),y=dt.util.xorBytes(c,v,c.length),x=y.substring(0,n.digestLength),S=u!=="\0",I=0;I<n.digestLength;++I)S|=o.charAt(I)!==x.charAt(I);for(var A=1,B=n.digestLength,P=n.digestLength;P<y.length;P++){var L=y.charCodeAt(P),R=L&1^1,q=A?65534:0;S|=L&q,A=A&R,B+=A}if(S||y.charCodeAt(B)!==1)throw new Error("Invalid RSAES-OAEP padding.");return y.substring(B+1)};function br(e,t,a){a||(a=dt.md.sha1.create());for(var r="",n=Math.ceil(t/a.digestLength),i=0;i<n;++i){var s=String.fromCharCode(i>>24&255,i>>16&255,i>>8&255,i&255);a.start(),a.update(e+s),r+=a.digest().getBytes()}return r.substring(0,t)}var It=j;(function(){if(It.prime){It.prime;return}var e=It.prime=It.prime||{},t=It.jsbn.BigInteger,a=[6,4,2,4,2,4,6,2],r=new t(null);r.fromInt(30);var n=function(f,g){return f|g};e.generateProbablePrime=function(f,g,v){typeof g=="function"&&(v=g,g={}),g=g||{};var y=g.algorithm||"PRIMEINC";typeof y=="string"&&(y={name:y}),y.options=y.options||{};var x=g.prng||It.random,S={nextBytes:function(I){for(var A=x.getBytesSync(I.length),B=0;B<I.length;++B)I[B]=A.charCodeAt(B)}};if(y.name==="PRIMEINC")return i(f,S,y.options,v);throw new Error("Invalid prime generation algorithm: "+y.name)};function i(f,g,v,y){return"workers"in v?u(f,g,v,y):s(f,g,v,y)}function s(f,g,v,y){var x=l(f,g),S=0,I=c(x.bitLength());"millerRabinTests"in v&&(I=v.millerRabinTests);var A=10;"maxBlockTime"in v&&(A=v.maxBlockTime),o(x,f,g,S,I,A,y)}function o(f,g,v,y,x,S,I){var A=+new Date;do{if(f.bitLength()>g&&(f=l(g,v)),f.isProbablePrime(x))return I(null,f);f.dAddOffset(a[y++%8],0)}while(S<0||+new Date-A<S);It.util.setImmediate(function(){o(f,g,v,y,x,S,I)})}function u(f,g,v,y){if(typeof Worker>"u")return s(f,g,v,y);var x=l(f,g),S=v.workers,I=v.workLoad||100,A=I*30/8,B=v.workerScript||"forge/prime.worker.js";if(S===-1)return It.util.estimateCores(function(L,R){L&&(R=2),S=R-1,P()});P();function P(){S=Math.max(1,S);for(var L=[],R=0;R<S;++R)L[R]=new Worker(B);for(var R=0;R<S;++R)L[R].addEventListener("message",Q);var q=!1;function Q(se){if(!q){var re=se.data;if(re.found){for(var W=0;W<L.length;++W)L[W].terminate();return q=!0,y(null,new t(re.prime,16))}x.bitLength()>f&&(x=l(f,g));var ge=x.toString(16);se.target.postMessage({hex:ge,workLoad:I}),x.dAddOffset(A,0)}}}}function l(f,g){var v=new t(f,g),y=f-1;return v.testBit(y)||v.bitwiseTo(t.ONE.shiftLeft(y),n,v),v.dAddOffset(31-v.mod(r).byteValue(),0),v}function c(f){return f<=100?27:f<=150?18:f<=200?15:f<=250?12:f<=300?9:f<=350?8:f<=400?7:f<=500?6:f<=600?5:f<=800?4:f<=1250?3:2}})();var H=j;if(typeof ie>"u")var ie=H.jsbn.BigInteger;var na=H.util.isNodejs?Xr:null,T=H.asn1,tt=H.util;H.pki=H.pki||{},H.pki.rsa=H.rsa=H.rsa||{};var $=H.pki,xo=[6,4,2,4,2,4,6,2],So={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"}]},To={name:"RSAPrivateKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},Io={name:"RSAPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},bo=H.pki.rsa.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"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},Ao={name:"DigestInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:T.Class.UNIVERSAL,type:T.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:T.Class.UNIVERSAL,type:T.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},Bo=function(e){var t;if(e.algorithm in $.oids)t=$.oids[e.algorithm];else{var a=new Error("Unknown message digest algorithm.");throw a.algorithm=e.algorithm,a}var r=T.oidToDer(t).getBytes(),n=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),i=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);i.value.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,r)),i.value.push(T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,""));var s=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,e.digest().getBytes());return n.value.push(i),n.value.push(s),T.toDer(n).getBytes()},ln=function(e,t,a){if(a)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||(t.dP=t.d.mod(t.p.subtract(ie.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(ie.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var r;do r=new ie(H.util.bytesToHex(H.random.getBytes(t.n.bitLength()/8)),16);while(r.compareTo(t.n)>=0||!r.gcd(t.n).equals(ie.ONE));e=e.multiply(r.modPow(t.e,t.n)).mod(t.n);for(var n=e.mod(t.p).modPow(t.dP,t.p),i=e.mod(t.q).modPow(t.dQ,t.q);n.compareTo(i)<0;)n=n.add(t.p);var s=n.subtract(i).multiply(t.qInv).mod(t.p).multiply(t.q).add(i);return s=s.multiply(r.modInverse(t.n)).mod(t.n),s};$.rsa.encrypt=function(e,t,a){var r=a,n,i=Math.ceil(t.n.bitLength()/8);a!==!1&&a!==!0?(r=a===2,n=un(e,t,a)):(n=H.util.createBuffer(),n.putBytes(e));for(var s=new ie(n.toHex(),16),o=ln(s,t,r),u=o.toString(16),l=H.util.createBuffer(),c=i-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(H.util.hexToBytes(u)),l.getBytes()},$.rsa.decrypt=function(e,t,a,r){var n=Math.ceil(t.n.bitLength()/8);if(e.length!==n){var i=new Error("Encrypted message length is invalid.");throw i.length=e.length,i.expected=n,i}var s=new ie(H.util.createBuffer(e).toHex(),16);if(s.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var o=ln(s,t,a),u=o.toString(16),l=H.util.createBuffer(),c=n-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(H.util.hexToBytes(u)),r!==!1?Ar(l.getBytes(),t,a):l.getBytes()},$.rsa.createKeyPairGenerationState=function(e,t,a){typeof e=="string"&&(e=parseInt(e,10)),e=e||2048,a=a||{};var r=a.prng||H.random,n={nextBytes:function(o){for(var u=r.getBytesSync(o.length),l=0;l<o.length;++l)o[l]=u.charCodeAt(l)}},i=a.algorithm||"PRIMEINC",s;if(i==="PRIMEINC")s={algorithm:i,state:0,bits:e,rng:n,eInt:t||65537,e:new ie(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},s.e.fromInt(s.eInt);else throw new Error("Invalid key generation algorithm: "+i);return s},$.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var a=new ie(null);a.fromInt(30);for(var r=0,n=function(f,g){return f|g},i=+new Date,s,o=0;e.keys===null&&(t<=0||o<t);){if(e.state===0){var u=e.p===null?e.pBits:e.qBits,l=u-1;e.pqState===0?(e.num=new ie(u,e.rng),e.num.testBit(l)||e.num.bitwiseTo(ie.ONE.shiftLeft(l),n,e.num),e.num.dAddOffset(31-e.num.mod(a).byteValue(),0),r=0,++e.pqState):e.pqState===1?e.num.bitLength()>u?e.pqState=0:e.num.isProbablePrime(_o(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(xo[r++%8],0):e.pqState===2?e.pqState=e.num.subtract(ie.ONE).gcd(e.e).compareTo(ie.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(ie.ONE),e.q1=e.q.subtract(ie.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(ie.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var c=e.e.modInverse(e.phi);e.keys={privateKey:$.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:$.rsa.setPublicKey(e.n,e.e)}}s=+new Date,o+=s-i,i=s}return e.keys!==null},$.rsa.generateKeyPair=function(e,t,a,r){if(arguments.length===1?typeof e=="object"?(a=e,e=void 0):typeof e=="function"&&(r=e,e=void 0):arguments.length===2?typeof e=="number"?typeof t=="function"?(r=t,t=void 0):typeof t!="number"&&(a=t,t=void 0):(a=e,r=t,e=void 0,t=void 0):arguments.length===3&&(typeof t=="number"?typeof a=="function"&&(r=a,a=void 0):(r=a,a=t,t=void 0)),a=a||{},e===void 0&&(e=a.bits||2048),t===void 0&&(t=a.e||65537),!H.options.usePureJavaScript&&!a.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(r){if(cn("generateKeyPair"))return na.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(o,u,l){if(o)return r(o);r(null,{privateKey:$.privateKeyFromPem(l),publicKey:$.publicKeyFromPem(u)})});if(fn("generateKey")&&fn("exportKey"))return tt.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:hn(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(o){return tt.globalScope.crypto.subtle.exportKey("pkcs8",o.privateKey)}).then(void 0,function(o){r(o)}).then(function(o){if(o){var u=$.privateKeyFromAsn1(T.fromDer(H.util.createBuffer(o)));r(null,{privateKey:u,publicKey:$.setRsaPublicKey(u.n,u.e)})}});if(dn("generateKey")&&dn("exportKey")){var n=tt.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:hn(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);n.oncomplete=function(o){var u=o.target.result,l=tt.globalScope.msCrypto.subtle.exportKey("pkcs8",u.privateKey);l.oncomplete=function(c){var f=c.target.result,g=$.privateKeyFromAsn1(T.fromDer(H.util.createBuffer(f)));r(null,{privateKey:g,publicKey:$.setRsaPublicKey(g.n,g.e)})},l.onerror=function(c){r(c)}},n.onerror=function(o){r(o)};return}}else if(cn("generateKeyPairSync")){var i=na.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:$.privateKeyFromPem(i.privateKey),publicKey:$.publicKeyFromPem(i.publicKey)}}}var s=$.rsa.createKeyPairGenerationState(e,t,a);if(!r)return $.rsa.stepKeyPairGenerationState(s,0),s.keys;wo(s,a,r)},$.setRsaPublicKey=$.rsa.setPublicKey=function(e,t){var a={n:e,e:t};return a.encrypt=function(r,n,i){if(typeof n=="string"?n=n.toUpperCase():n===void 0&&(n="RSAES-PKCS1-V1_5"),n==="RSAES-PKCS1-V1_5")n={encode:function(o,u,l){return un(o,u,2).getBytes()}};else if(n==="RSA-OAEP"||n==="RSAES-OAEP")n={encode:function(o,u){return H.pkcs1.encode_rsa_oaep(u,o,i)}};else if(["RAW","NONE","NULL",null].indexOf(n)!==-1)n={encode:function(o){return o}};else if(typeof n=="string")throw new Error('Unsupported encryption scheme: "'+n+'".');var s=n.encode(r,a,!0);return $.rsa.encrypt(s,a,!0)},a.verify=function(r,n,i,s){typeof i=="string"?i=i.toUpperCase():i===void 0&&(i="RSASSA-PKCS1-V1_5"),s===void 0&&(s={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in s||(s._parseAllDigestBytes=!0),i==="RSASSA-PKCS1-V1_5"?i={verify:function(u,l){l=Ar(l,a,!0);var c=T.fromDer(l,{parseAllBytes:s._parseAllDigestBytes}),f={},g=[];if(!T.validate(c,Ao,f,g)){var v=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw v.errors=g,v}var y=T.derToOid(f.algorithmIdentifier);if(!(y===H.oids.md2||y===H.oids.md5||y===H.oids.sha1||y===H.oids.sha224||y===H.oids.sha256||y===H.oids.sha384||y===H.oids.sha512||y===H.oids["sha512-224"]||y===H.oids["sha512-256"])){var v=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw v.oid=y,v}if((y===H.oids.md2||y===H.oids.md5)&&!("parameters"in f))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.");return u===f.digest}}:(i==="NONE"||i==="NULL"||i===null)&&(i={verify:function(u,l){return l=Ar(l,a,!0),u===l}});var o=$.rsa.decrypt(n,a,!0,!1);return i.verify(r,o,a.n.bitLength())},a},$.setRsaPrivateKey=$.rsa.setPrivateKey=function(e,t,a,r,n,i,s,o){var u={n:e,e:t,d:a,p:r,q:n,dP:i,dQ:s,qInv:o};return u.decrypt=function(l,c,f){typeof c=="string"?c=c.toUpperCase():c===void 0&&(c="RSAES-PKCS1-V1_5");var g=$.rsa.decrypt(l,u,!1,!1);if(c==="RSAES-PKCS1-V1_5")c={decode:Ar};else if(c==="RSA-OAEP"||c==="RSAES-OAEP")c={decode:function(v,y){return H.pkcs1.decode_rsa_oaep(y,v,f)}};else if(["RAW","NONE","NULL",null].indexOf(c)!==-1)c={decode:function(v){return v}};else throw new Error('Unsupported encryption scheme: "'+c+'".');return c.decode(g,u,!1)},u.sign=function(l,c){var f=!1;typeof c=="string"&&(c=c.toUpperCase()),c===void 0||c==="RSASSA-PKCS1-V1_5"?(c={encode:Bo},f=1):(c==="NONE"||c==="NULL"||c===null)&&(c={encode:function(){return l}},f=1);var g=c.encode(l,u.n.bitLength());return $.rsa.encrypt(g,u,f)},u},$.wrapRsaPrivateKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(0).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer($.oids.rsaEncryption).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]),T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,T.toDer(e).getBytes())])},$.privateKeyFromAsn1=function(e){var t={},a=[];if(T.validate(e,So,t,a)&&(e=T.fromDer(H.util.createBuffer(t.privateKey))),t={},a=[],!T.validate(e,To,t,a)){var r=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw r.errors=a,r}var n,i,s,o,u,l,c,f;return n=H.util.createBuffer(t.privateKeyModulus).toHex(),i=H.util.createBuffer(t.privateKeyPublicExponent).toHex(),s=H.util.createBuffer(t.privateKeyPrivateExponent).toHex(),o=H.util.createBuffer(t.privateKeyPrime1).toHex(),u=H.util.createBuffer(t.privateKeyPrime2).toHex(),l=H.util.createBuffer(t.privateKeyExponent1).toHex(),c=H.util.createBuffer(t.privateKeyExponent2).toHex(),f=H.util.createBuffer(t.privateKeyCoefficient).toHex(),$.setRsaPrivateKey(new ie(n,16),new ie(i,16),new ie(s,16),new ie(o,16),new ie(u,16),new ie(l,16),new ie(c,16),new ie(f,16))},$.privateKeyToAsn1=$.privateKeyToRSAPrivateKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(0).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.n)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.e)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.d)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.p)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.q)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.dP)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.dQ)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.qInv))])},$.publicKeyFromAsn1=function(e){var t={},a=[];if(T.validate(e,bo,t,a)){var r=T.derToOid(t.publicKeyOid);if(r!==$.oids.rsaEncryption){var n=new Error("Cannot read public key. Unknown OID.");throw n.oid=r,n}e=t.rsaPublicKey}if(a=[],!T.validate(e,Io,t,a)){var n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw n.errors=a,n}var i=H.util.createBuffer(t.publicKeyModulus).toHex(),s=H.util.createBuffer(t.publicKeyExponent).toHex();return $.setRsaPublicKey(new ie(i,16),new ie(s,16))},$.publicKeyToAsn1=$.publicKeyToSubjectPublicKeyInfo=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer($.oids.rsaEncryption).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]),T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,[$.publicKeyToRSAPublicKey(e)])])},$.publicKeyToRSAPublicKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.n)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ht(e.e))])};function un(e,t,a){var r=H.util.createBuffer(),n=Math.ceil(t.n.bitLength()/8);if(e.length>n-11){var i=new Error("Message is too long for PKCS#1 v1.5 padding.");throw i.length=e.length,i.max=n-11,i}r.putByte(0),r.putByte(a);var s=n-3-e.length,o;if(a===0||a===1){o=a===0?0:255;for(var u=0;u<s;++u)r.putByte(o)}else for(;s>0;){for(var l=0,c=H.random.getBytes(s),u=0;u<s;++u)o=c.charCodeAt(u),o===0?++l:r.putByte(o);s=l}return r.putByte(0),r.putBytes(e),r}function Ar(e,t,a,r){var n=Math.ceil(t.n.bitLength()/8),i=H.util.createBuffer(e),s=i.getByte(),o=i.getByte();if(s!==0||a&&o!==0&&o!==1||!a&&o!=2||a&&o===0&&typeof r>"u")throw new Error("Encryption block is invalid.");var u=0;if(o===0){u=n-3-r;for(var l=0;l<u;++l)if(i.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(o===1)for(u=0;i.length()>1;){if(i.getByte()!==255){--i.read;break}++u}else if(o===2)for(u=0;i.length()>1;){if(i.getByte()===0){--i.read;break}++u}var c=i.getByte();if(c!==0||u!==n-3-i.length())throw new Error("Encryption block is invalid.");return i.getBytes()}function wo(e,t,a){typeof t=="function"&&(a=t,t={}),t=t||{};var r={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(r.prng=t.prng),n();function n(){i(e.pBits,function(o,u){if(o)return a(o);if(e.p=u,e.q!==null)return s(o,e.q);i(e.qBits,s)})}function i(o,u){H.prime.generateProbablePrime(o,r,u)}function s(o,u){if(o)return a(o);if(e.q=u,e.p.compareTo(e.q)<0){var l=e.p;e.p=e.q,e.q=l}if(e.p.subtract(ie.ONE).gcd(e.e).compareTo(ie.ONE)!==0){e.p=null,n();return}if(e.q.subtract(ie.ONE).gcd(e.e).compareTo(ie.ONE)!==0){e.q=null,i(e.qBits,s);return}if(e.p1=e.p.subtract(ie.ONE),e.q1=e.q.subtract(ie.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(ie.ONE)!==0){e.p=e.q=null,n();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,i(e.qBits,s);return}var c=e.e.modInverse(e.phi);e.keys={privateKey:$.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:$.rsa.setPublicKey(e.n,e.e)},a(null,e.keys)}}function ht(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var a=H.util.hexToBytes(t);return a.length>1&&(a.charCodeAt(0)===0&&!(a.charCodeAt(1)&128)||a.charCodeAt(0)===255&&(a.charCodeAt(1)&128)===128)?a.substr(1):a}function _o(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function cn(e){return H.util.isNodejs&&typeof na[e]=="function"}function fn(e){return typeof tt.globalScope<"u"&&typeof tt.globalScope.crypto=="object"&&typeof tt.globalScope.crypto.subtle=="object"&&typeof tt.globalScope.crypto.subtle[e]=="function"}function dn(e){return typeof tt.globalScope<"u"&&typeof tt.globalScope.msCrypto=="object"&&typeof tt.globalScope.msCrypto.subtle=="object"&&typeof tt.globalScope.msCrypto.subtle[e]=="function"}function hn(e){for(var t=H.util.hexToBytes(e.toString(16)),a=new Uint8Array(t.length),r=0;r<t.length;++r)a[r]=t.charCodeAt(r);return a}var F=j;if(typeof No>"u")var No=F.jsbn.BigInteger;var b=F.asn1,Y=F.pki=F.pki||{};Y.pbe=F.pbe=F.pbe||{};var Ut=Y.oids,Ro={name:"EncryptedPrivateKeyInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:b.Class.UNIVERSAL,type:b.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},Lo={name:"PBES2Algorithms",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:b.Class.UNIVERSAL,type:b.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:b.Class.UNIVERSAL,type:b.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},ko={name:"pkcs-12PbeParams",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:b.Class.UNIVERSAL,type:b.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"iterations"}]};Y.encryptPrivateKeyInfo=function(e,t,a){a=a||{},a.saltSize=a.saltSize||8,a.count=a.count||2048,a.algorithm=a.algorithm||"aes128",a.prfAlgorithm=a.prfAlgorithm||"sha1";var r=F.random.getBytesSync(a.saltSize),n=a.count,i=b.integerToDer(n),s,o,u;if(a.algorithm.indexOf("aes")===0||a.algorithm==="des"){var l,c,f;switch(a.algorithm){case"aes128":s=16,l=16,c=Ut["aes128-CBC"],f=F.aes.createEncryptionCipher;break;case"aes192":s=24,l=16,c=Ut["aes192-CBC"],f=F.aes.createEncryptionCipher;break;case"aes256":s=32,l=16,c=Ut["aes256-CBC"],f=F.aes.createEncryptionCipher;break;case"des":s=8,l=8,c=Ut.desCBC,f=F.des.createEncryptionCipher;break;default:var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=a.algorithm,g}var v="hmacWith"+a.prfAlgorithm.toUpperCase(),y=yn(v),x=F.pkcs5.pbkdf2(t,r,n,s,y),S=F.random.getBytesSync(l),I=f(x);I.start(S),I.update(b.toDer(e)),I.finish(),u=I.output.getBytes();var A=Do(r,i,s,v);o=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(Ut.pkcs5PBES2).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(Ut.pkcs5PBKDF2).getBytes()),A]),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(c).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.OCTETSTRING,!1,S)])])])}else if(a.algorithm==="3des"){s=24;var B=new F.util.ByteBuffer(r),x=Y.pbe.generatePkcs12Key(t,B,1,n,s),S=Y.pbe.generatePkcs12Key(t,B,2,n,s),I=F.des.createEncryptionCipher(x);I.start(S),I.update(b.toDer(e)),I.finish(),u=I.output.getBytes(),o=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(Ut["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OCTETSTRING,!1,r),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,i.getBytes())])])}else{var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=a.algorithm,g}var P=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[o,b.create(b.Class.UNIVERSAL,b.Type.OCTETSTRING,!1,u)]);return P},Y.decryptPrivateKeyInfo=function(e,t){var a=null,r={},n=[];if(!b.validate(e,Ro,r,n)){var i=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw i.errors=n,i}var s=b.derToOid(r.encryptionOid),o=Y.pbe.getCipher(s,r.encryptionParams,t),u=F.util.createBuffer(r.encryptedData);return o.update(u),o.finish()&&(a=b.fromDer(o.output)),a},Y.encryptedPrivateKeyToPem=function(e,t){var a={type:"ENCRYPTED PRIVATE KEY",body:b.toDer(e).getBytes()};return F.pem.encode(a,{maxline:t})},Y.encryptedPrivateKeyFromPem=function(e){var t=F.pem.decode(e)[0];if(t.type!=="ENCRYPTED PRIVATE KEY"){var a=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return b.fromDer(t.body)},Y.encryptRsaPrivateKey=function(e,t,a){if(a=a||{},!a.legacy){var r=Y.wrapRsaPrivateKey(Y.privateKeyToAsn1(e));return r=Y.encryptPrivateKeyInfo(r,t,a),Y.encryptedPrivateKeyToPem(r)}var n,i,s,o;switch(a.algorithm){case"aes128":n="AES-128-CBC",s=16,i=F.random.getBytesSync(16),o=F.aes.createEncryptionCipher;break;case"aes192":n="AES-192-CBC",s=24,i=F.random.getBytesSync(16),o=F.aes.createEncryptionCipher;break;case"aes256":n="AES-256-CBC",s=32,i=F.random.getBytesSync(16),o=F.aes.createEncryptionCipher;break;case"3des":n="DES-EDE3-CBC",s=24,i=F.random.getBytesSync(8),o=F.des.createEncryptionCipher;break;case"des":n="DES-CBC",s=8,i=F.random.getBytesSync(8),o=F.des.createEncryptionCipher;break;default:var u=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+a.algorithm+'".');throw u.algorithm=a.algorithm,u}var l=F.pbe.opensslDeriveBytes(t,i.substr(0,8),s),c=o(l);c.start(i),c.update(b.toDer(Y.privateKeyToAsn1(e))),c.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:n,parameters:F.util.bytesToHex(i).toUpperCase()},body:c.output.getBytes()};return F.pem.encode(f)},Y.decryptRsaPrivateKey=function(e,t){var a=null,r=F.pem.decode(e)[0];if(r.type!=="ENCRYPTED PRIVATE KEY"&&r.type!=="PRIVATE KEY"&&r.type!=="RSA PRIVATE KEY"){var n=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw n.headerType=n,n}if(r.procType&&r.procType.type==="ENCRYPTED"){var i,s;switch(r.dekInfo.algorithm){case"DES-CBC":i=8,s=F.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,s=F.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,s=F.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,s=F.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,s=F.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,s=function(f){return F.rc2.createDecryptionCipher(f,40)};break;case"RC2-64-CBC":i=8,s=function(f){return F.rc2.createDecryptionCipher(f,64)};break;case"RC2-128-CBC":i=16,s=function(f){return F.rc2.createDecryptionCipher(f,128)};break;default:var n=new Error('Could not decrypt private key; unsupported encryption algorithm "'+r.dekInfo.algorithm+'".');throw n.algorithm=r.dekInfo.algorithm,n}var o=F.util.hexToBytes(r.dekInfo.parameters),u=F.pbe.opensslDeriveBytes(t,o.substr(0,8),i),l=s(u);if(l.start(o),l.update(F.util.createBuffer(r.body)),l.finish())a=l.output.getBytes();else return a}else a=r.body;return r.type==="ENCRYPTED PRIVATE KEY"?a=Y.decryptPrivateKeyInfo(b.fromDer(a),t):a=b.fromDer(a),a!==null&&(a=Y.privateKeyFromAsn1(a)),a},Y.pbe.generatePkcs12Key=function(e,t,a,r,n,i){var s,o;if(typeof i>"u"||i===null){if(!("sha1"in F.md))throw new Error('"sha1" hash algorithm unavailable.');i=F.md.sha1.create()}var u=i.digestLength,l=i.blockLength,c=new F.util.ByteBuffer,f=new F.util.ByteBuffer;if(e!=null){for(o=0;o<e.length;o++)f.putInt16(e.charCodeAt(o));f.putInt16(0)}var g=f.length(),v=t.length(),y=new F.util.ByteBuffer;y.fillWithByte(a,l);var x=l*Math.ceil(v/l),S=new F.util.ByteBuffer;for(o=0;o<x;o++)S.putByte(t.at(o%v));var I=l*Math.ceil(g/l),A=new F.util.ByteBuffer;for(o=0;o<I;o++)A.putByte(f.at(o%g));var B=S;B.putBuffer(A);for(var P=Math.ceil(n/u),L=1;L<=P;L++){var R=new F.util.ByteBuffer;R.putBytes(y.bytes()),R.putBytes(B.bytes());for(var q=0;q<r;q++)i.start(),i.update(R.getBytes()),R=i.digest();var Q=new F.util.ByteBuffer;for(o=0;o<l;o++)Q.putByte(R.at(o%u));var se=Math.ceil(v/l)+Math.ceil(g/l),re=new F.util.ByteBuffer;for(s=0;s<se;s++){var W=new F.util.ByteBuffer(B.getBytes(l)),ge=511;for(o=Q.length()-1;o>=0;o--)ge=ge>>8,ge+=Q.at(o)+W.at(o),W.setAt(o,ge&255);re.putBuffer(W)}B=re,c.putBuffer(R)}return c.truncate(c.length()-n),c},Y.pbe.getCipher=function(e,t,a){switch(e){case Y.oids.pkcs5PBES2:return Y.pbe.getCipherForPBES2(e,t,a);case Y.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case Y.oids["pbewithSHAAnd40BitRC2-CBC"]:return Y.pbe.getCipherForPKCS12PBE(e,t,a);default:var r=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw r.oid=e,r.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],r}},Y.pbe.getCipherForPBES2=function(e,t,a){var r={},n=[];if(!b.validate(t,Lo,r,n)){var i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw i.errors=n,i}if(e=b.derToOid(r.kdfOid),e!==Y.oids.pkcs5PBKDF2){var i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw i.oid=e,i.supportedOids=["pkcs5PBKDF2"],i}if(e=b.derToOid(r.encOid),e!==Y.oids["aes128-CBC"]&&e!==Y.oids["aes192-CBC"]&&e!==Y.oids["aes256-CBC"]&&e!==Y.oids["des-EDE3-CBC"]&&e!==Y.oids.desCBC){var i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw i.oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i}var s=r.kdfSalt,o=F.util.createBuffer(r.kdfIterationCount);o=o.getInt(o.length()<<3);var u,l;switch(Y.oids[e]){case"aes128-CBC":u=16,l=F.aes.createDecryptionCipher;break;case"aes192-CBC":u=24,l=F.aes.createDecryptionCipher;break;case"aes256-CBC":u=32,l=F.aes.createDecryptionCipher;break;case"des-EDE3-CBC":u=24,l=F.des.createDecryptionCipher;break;case"desCBC":u=8,l=F.des.createDecryptionCipher;break}var c=gn(r.prfOid),f=F.pkcs5.pbkdf2(a,s,o,u,c),g=r.encIv,v=l(f);return v.start(g),v},Y.pbe.getCipherForPKCS12PBE=function(e,t,a){var r={},n=[];if(!b.validate(t,ko,r,n)){var i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw i.errors=n,i}var s=F.util.createBuffer(r.salt),o=F.util.createBuffer(r.iterations);o=o.getInt(o.length()<<3);var u,l,c;switch(e){case Y.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,l=8,c=F.des.startDecrypting;break;case Y.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,l=8,c=function(x,S){var I=F.rc2.createDecryptionCipher(x,40);return I.start(S,null),I};break;default:var i=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw i.oid=e,i}var f=gn(r.prfOid),g=Y.pbe.generatePkcs12Key(a,s,1,o,u,f);f.start();var v=Y.pbe.generatePkcs12Key(a,s,2,o,l,f);return c(g,v)},Y.pbe.opensslDeriveBytes=function(e,t,a,r){if(typeof r>"u"||r===null){if(!("md5"in F.md))throw new Error('"md5" hash algorithm unavailable.');r=F.md.md5.create()}t===null&&(t="");for(var n=[pn(r,e+t)],i=16,s=1;i<a;++s,i+=16)n.push(pn(r,n[s-1]+e+t));return n.join("").substr(0,a)};function pn(e,t){return e.start().update(t).digest().getBytes()}function gn(e){var t;if(!e)t="hmacWithSHA1";else if(t=Y.oids[b.derToOid(e)],!t){var a=new Error("Unsupported PRF OID.");throw a.oid=e,a.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],a}return yn(t)}function yn(e){var t=F.md;switch(e){case"hmacWithSHA224":t=F.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var a=new Error("Unsupported PRF algorithm.");throw a.algorithm=e,a.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],a}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}function Do(e,t,a,r){var n=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OCTETSTRING,!1,e),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,t.getBytes())]);return r!=="hmacWithSHA1"&&n.value.push(b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,F.util.hexToBytes(a.toString(16))),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(Y.oids[r]).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.NULL,!1,"")])),n}var Qt=j,V=Qt.asn1,Wt=Qt.pkcs7asn1=Qt.pkcs7asn1||{};Qt.pkcs7=Qt.pkcs7||{},Qt.pkcs7.asn1=Wt;var vn={name:"ContentInfo",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:V.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};Wt.contentInfoValidator=vn;var mn={name:"EncryptedContentInfo",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:V.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:V.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};Wt.envelopedDataValidator={name:"EnvelopedData",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:V.Class.UNIVERSAL,type:V.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(mn)},Wt.encryptedDataValidator={name:"EncryptedData",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"version"}].concat(mn)};var Uo={name:"SignerInfo",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:V.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:V.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:V.Class.UNIVERSAL,type:V.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:V.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};Wt.signedDataValidator={name:"SignedData",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:V.Class.UNIVERSAL,type:V.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},vn,{name:"SignedData.Certificates",tagClass:V.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:V.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:V.Class.UNIVERSAL,type:V.Type.SET,capture:"signerInfos",optional:!0,value:[Uo]}]},Wt.recipientInfoValidator={name:"RecipientInfo",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:V.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:V.Class.UNIVERSAL,type:V.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]};var Pt=j;Pt.mgf=Pt.mgf||{};var Po=Pt.mgf.mgf1=Pt.mgf1=Pt.mgf1||{};Po.create=function(e){var t={generate:function(a,r){for(var n=new Pt.util.ByteBuffer,i=Math.ceil(r/e.digestLength),s=0;s<i;s++){var o=new Pt.util.ByteBuffer;o.putInt32(s),e.start(),e.update(a+o.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}};return t};var Br=j;Br.mgf=Br.mgf||{},Br.mgf.mgf1=Br.mgf1;var Vt=j,Vo=Vt.pss=Vt.pss||{};Vo.create=function(e){arguments.length===3&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t=e.md,a=e.mgf,r=t.digestLength,n=e.salt||null;typeof n=="string"&&(n=Vt.util.createBuffer(n));var i;if("saltLength"in e)i=e.saltLength;else if(n!==null)i=n.length();else throw new Error("Salt length not specified or specific salt not given.");if(n!==null&&n.length()!==i)throw new Error("Given salt length does not match length of given salt.");var s=e.prng||Vt.random,o={};return o.encode=function(u,l){var c,f=l-1,g=Math.ceil(f/8),v=u.digest().getBytes();if(g<r+i+2)throw new Error("Message is too long to encrypt.");var y;n===null?y=s.getBytesSync(i):y=n.bytes();var x=new Vt.util.ByteBuffer;x.fillWithByte(0,8),x.putBytes(v),x.putBytes(y),t.start(),t.update(x.getBytes());var S=t.digest().getBytes(),I=new Vt.util.ByteBuffer;I.fillWithByte(0,g-i-r-2),I.putByte(1),I.putBytes(y);var A=I.getBytes(),B=g-r-1,P=a.generate(S,B),L="";for(c=0;c<B;c++)L+=String.fromCharCode(A.charCodeAt(c)^P.charCodeAt(c));var R=65280>>8*g-f&255;return L=String.fromCharCode(L.charCodeAt(0)&~R)+L.substr(1),L+S+String.fromCharCode(188)},o.verify=function(u,l,c){var f,g=c-1,v=Math.ceil(g/8);if(l=l.substr(-v),v<r+i+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(l.charCodeAt(v-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var y=v-r-1,x=l.substr(0,y),S=l.substr(y,r),I=65280>>8*v-g&255;if(x.charCodeAt(0)&I)throw new Error("Bits beyond keysize not zero as expected.");var A=a.generate(S,y),B="";for(f=0;f<y;f++)B+=String.fromCharCode(x.charCodeAt(f)^A.charCodeAt(f));B=String.fromCharCode(B.charCodeAt(0)&~I)+B.substr(1);var P=v-r-i-2;for(f=0;f<P;f++)if(B.charCodeAt(f)!==0)throw new Error("Leftmost octets not zero as expected");if(B.charCodeAt(P)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var L=B.substr(-i),R=new Vt.util.ByteBuffer;R.fillWithByte(0,8),R.putBytes(u),R.putBytes(L),t.start(),t.update(R.getBytes());var q=t.digest().getBytes();return S===q},o};var G=j,d=G.asn1,k=G.pki=G.pki||{},ae=k.oids,me={};me.CN=ae.commonName,me.commonName="CN",me.C=ae.countryName,me.countryName="C",me.L=ae.localityName,me.localityName="L",me.ST=ae.stateOrProvinceName,me.stateOrProvinceName="ST",me.O=ae.organizationName,me.organizationName="O",me.OU=ae.organizationalUnitName,me.organizationalUnitName="OU",me.E=ae.emailAddress,me.emailAddress="E";var Cn=G.pki.rsa.publicKeyValidator,Oo={name:"Certificate",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:d.Class.UNIVERSAL,type:d.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:d.Class.UNIVERSAL,type:d.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:d.Class.UNIVERSAL,type:d.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:d.Class.UNIVERSAL,type:d.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},Cn,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:d.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:d.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:d.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},Fo={name:"rsapss",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:d.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:d.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:d.Class.UNIVERSAL,type:d.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:d.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:d.Class.UNIVERSAL,type:d.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},Ko={name:"CertificationRequestInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},Cn,{name:"CertificationRequestInfo.attributes",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:d.Class.UNIVERSAL,type:d.Type.SET,constructed:!0}]}]}]},Mo={name:"CertificationRequest",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[Ko,{name:"CertificationRequest.signatureAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};k.RDNAttributesAsArray=function(e,t){for(var a=[],r,n,i,s=0;s<e.value.length;++s){r=e.value[s];for(var o=0;o<r.value.length;++o)i={},n=r.value[o],i.type=d.derToOid(n.value[0].value),i.value=n.value[1].value,i.valueTagClass=n.value[1].type,i.type in ae&&(i.name=ae[i.type],i.name in me&&(i.shortName=me[i.name])),t&&(t.update(i.type),t.update(i.value)),a.push(i)}return a},k.CRIAttributesAsArray=function(e){for(var t=[],a=0;a<e.length;++a)for(var r=e[a],n=d.derToOid(r.value[0].value),i=r.value[1].value,s=0;s<i.length;++s){var o={};if(o.type=n,o.value=i[s].value,o.valueTagClass=i[s].type,o.type in ae&&(o.name=ae[o.type],o.name in me&&(o.shortName=me[o.name])),o.type===ae.extensionRequest){o.extensions=[];for(var u=0;u<o.value.length;++u)o.extensions.push(k.certificateExtensionFromAsn1(o.value[u]))}t.push(o)}return t};function bt(e,t){typeof t=="string"&&(t={shortName:t});for(var a=null,r,n=0;a===null&&n<e.attributes.length;++n)r=e.attributes[n],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(a=r);return a}var wr=function(e,t,a){var r={};if(e!==ae["RSASSA-PSS"])return r;a&&(r={hash:{algorithmOid:ae.sha1},mgf:{algorithmOid:ae.mgf1,hash:{algorithmOid:ae.sha1}},saltLength:20});var n={},i=[];if(!d.validate(t,Fo,n,i)){var s=new Error("Cannot read RSASSA-PSS parameter block.");throw s.errors=i,s}return n.hashOid!==void 0&&(r.hash=r.hash||{},r.hash.algorithmOid=d.derToOid(n.hashOid)),n.maskGenOid!==void 0&&(r.mgf=r.mgf||{},r.mgf.algorithmOid=d.derToOid(n.maskGenOid),r.mgf.hash=r.mgf.hash||{},r.mgf.hash.algorithmOid=d.derToOid(n.maskGenHashOid)),n.saltLength!==void 0&&(r.saltLength=n.saltLength.charCodeAt(0)),r},_r=function(e){switch(ae[e.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return G.md.sha1.create();case"md5WithRSAEncryption":return G.md.md5.create();case"sha256WithRSAEncryption":return G.md.sha256.create();case"sha384WithRSAEncryption":return G.md.sha384.create();case"sha512WithRSAEncryption":return G.md.sha512.create();case"RSASSA-PSS":return G.md.sha256.create();default:var t=new Error("Could not compute "+e.type+" digest. Unknown signature OID.");throw t.signatureOid=e.signatureOid,t}},En=function(e){var t=e.certificate,a;switch(t.signatureOid){case ae.sha1WithRSAEncryption:case ae.sha1WithRSASignature:break;case ae["RSASSA-PSS"]:var r,n;if(r=ae[t.signatureParameters.mgf.hash.algorithmOid],r===void 0||G.md[r]===void 0){var i=new Error("Unsupported MGF hash function.");throw i.oid=t.signatureParameters.mgf.hash.algorithmOid,i.name=r,i}if(n=ae[t.signatureParameters.mgf.algorithmOid],n===void 0||G.mgf[n]===void 0){var i=new Error("Unsupported MGF function.");throw i.oid=t.signatureParameters.mgf.algorithmOid,i.name=n,i}if(n=G.mgf[n].create(G.md[r].create()),r=ae[t.signatureParameters.hash.algorithmOid],r===void 0||G.md[r]===void 0){var i=new Error("Unsupported RSASSA-PSS hash function.");throw i.oid=t.signatureParameters.hash.algorithmOid,i.name=r,i}a=G.pss.create(G.md[r].create(),n,t.signatureParameters.saltLength);break}return t.publicKey.verify(e.md.digest().getBytes(),e.signature,a)};k.certificateFromPem=function(e,t,a){var r=G.pem.decode(e)[0];if(r.type!=="CERTIFICATE"&&r.type!=="X509 CERTIFICATE"&&r.type!=="TRUSTED CERTIFICATE"){var n=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var i=d.fromDer(r.body,a);return k.certificateFromAsn1(i,t)},k.certificateToPem=function(e,t){var a={type:"CERTIFICATE",body:d.toDer(k.certificateToAsn1(e)).getBytes()};return G.pem.encode(a,{maxline:t})},k.publicKeyFromPem=function(e){var t=G.pem.decode(e)[0];if(t.type!=="PUBLIC KEY"&&t.type!=="RSA PUBLIC KEY"){var a=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var r=d.fromDer(t.body);return k.publicKeyFromAsn1(r)},k.publicKeyToPem=function(e,t){var a={type:"PUBLIC KEY",body:d.toDer(k.publicKeyToAsn1(e)).getBytes()};return G.pem.encode(a,{maxline:t})},k.publicKeyToRSAPublicKeyPem=function(e,t){var a={type:"RSA PUBLIC KEY",body:d.toDer(k.publicKeyToRSAPublicKey(e)).getBytes()};return G.pem.encode(a,{maxline:t})},k.getPublicKeyFingerprint=function(e,t){t=t||{};var a=t.md||G.md.sha1.create(),r=t.type||"RSAPublicKey",n;switch(r){case"RSAPublicKey":n=d.toDer(k.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":n=d.toDer(k.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+t.type+'".')}a.start(),a.update(n);var i=a.digest();if(t.encoding==="hex"){var s=i.toHex();return t.delimiter?s.match(/.{2}/g).join(t.delimiter):s}else{if(t.encoding==="binary")return i.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return i},k.certificationRequestFromPem=function(e,t,a){var r=G.pem.decode(e)[0];if(r.type!=="CERTIFICATE REQUEST"){var n=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var i=d.fromDer(r.body,a);return k.certificationRequestFromAsn1(i,t)},k.certificationRequestToPem=function(e,t){var a={type:"CERTIFICATE REQUEST",body:d.toDer(k.certificationRequestToAsn1(e)).getBytes()};return G.pem.encode(a,{maxline:t})},k.createCertificate=function(){var e={};return e.version=2,e.serialNumber="00",e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return bt(e.issuer,t)},e.issuer.addField=function(t){rt([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return bt(e.subject,t)},e.subject.addField=function(t){rt([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,a){rt(t),e.subject.attributes=t,delete e.subject.uniqueId,a&&(e.subject.uniqueId=a),e.subject.hash=null},e.setIssuer=function(t,a){rt(t),e.issuer.attributes=t,delete e.issuer.uniqueId,a&&(e.issuer.uniqueId=a),e.issuer.hash=null},e.setExtensions=function(t){for(var a=0;a<t.length;++a)xn(t[a],{cert:e});e.extensions=t},e.getExtension=function(t){typeof t=="string"&&(t={name:t});for(var a=null,r,n=0;a===null&&n<e.extensions.length;++n)r=e.extensions[n],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(a=r);return a},e.sign=function(t,a){e.md=a||G.md.sha1.create();var r=ae[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.tbsCertificate=k.getTBSCertificate(e);var i=d.toDer(e.tbsCertificate);e.md.update(i.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var a=!1;if(!e.issued(t)){var r=t.issuer,n=e.subject,i=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 i.expectedIssuer=n.attributes,i.actualIssuer=r.attributes,i}var s=t.md;if(s===null){s=_r({signatureOid:t.signatureOid,type:"certificate"});var o=t.tbsCertificate||k.getTBSCertificate(t),u=d.toDer(o);s.update(u.getBytes())}return s!==null&&(a=En({certificate:e,md:s,signature:t.signature})),a},e.isIssuer=function(t){var a=!1,r=e.issuer,n=t.subject;if(r.hash&&n.hash)a=r.hash===n.hash;else if(r.attributes.length===n.attributes.length){a=!0;for(var i,s,o=0;a&&o<r.attributes.length;++o)i=r.attributes[o],s=n.attributes[o],(i.type!==s.type||i.value!==s.value)&&(a=!1)}return a},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return k.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=ae.subjectKeyIdentifier,a=0;a<e.extensions.length;++a){var r=e.extensions[a];if(r.id===t){var n=e.generateSubjectKeyIdentifier().getBytes();return G.util.hexToBytes(r.subjectKeyIdentifier)===n}}return!1},e},k.certificateFromAsn1=function(e,t){var a={},r=[];if(!d.validate(e,Oo,a,r)){var n=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw n.errors=r,n}var i=d.derToOid(a.publicKeyOid);if(i!==k.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var s=k.createCertificate();s.version=a.certVersion?a.certVersion.charCodeAt(0):0;var o=G.util.createBuffer(a.certSerialNumber);s.serialNumber=o.toHex(),s.signatureOid=G.asn1.derToOid(a.certSignatureOid),s.signatureParameters=wr(s.signatureOid,a.certSignatureParams,!0),s.siginfo.algorithmOid=G.asn1.derToOid(a.certinfoSignatureOid),s.siginfo.parameters=wr(s.siginfo.algorithmOid,a.certinfoSignatureParams,!1),s.signature=a.certSignature;var u=[];if(a.certValidity1UTCTime!==void 0&&u.push(d.utcTimeToDate(a.certValidity1UTCTime)),a.certValidity2GeneralizedTime!==void 0&&u.push(d.generalizedTimeToDate(a.certValidity2GeneralizedTime)),a.certValidity3UTCTime!==void 0&&u.push(d.utcTimeToDate(a.certValidity3UTCTime)),a.certValidity4GeneralizedTime!==void 0&&u.push(d.generalizedTimeToDate(a.certValidity4GeneralizedTime)),u.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(u.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(s.validity.notBefore=u[0],s.validity.notAfter=u[1],s.tbsCertificate=a.tbsCertificate,t){s.md=_r({signatureOid:s.signatureOid,type:"certificate"});var l=d.toDer(s.tbsCertificate);s.md.update(l.getBytes())}var c=G.md.sha1.create(),f=d.toDer(a.certIssuer);c.update(f.getBytes()),s.issuer.getField=function(y){return bt(s.issuer,y)},s.issuer.addField=function(y){rt([y]),s.issuer.attributes.push(y)},s.issuer.attributes=k.RDNAttributesAsArray(a.certIssuer),a.certIssuerUniqueId&&(s.issuer.uniqueId=a.certIssuerUniqueId),s.issuer.hash=c.digest().toHex();var g=G.md.sha1.create(),v=d.toDer(a.certSubject);return g.update(v.getBytes()),s.subject.getField=function(y){return bt(s.subject,y)},s.subject.addField=function(y){rt([y]),s.subject.attributes.push(y)},s.subject.attributes=k.RDNAttributesAsArray(a.certSubject),a.certSubjectUniqueId&&(s.subject.uniqueId=a.certSubjectUniqueId),s.subject.hash=g.digest().toHex(),a.certExtensions?s.extensions=k.certificateExtensionsFromAsn1(a.certExtensions):s.extensions=[],s.publicKey=k.publicKeyFromAsn1(a.subjectPublicKeyInfo),s},k.certificateExtensionsFromAsn1=function(e){for(var t=[],a=0;a<e.value.length;++a)for(var r=e.value[a],n=0;n<r.value.length;++n)t.push(k.certificateExtensionFromAsn1(r.value[n]));return t},k.certificateExtensionFromAsn1=function(e){var t={};if(t.id=d.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===d.Type.BOOLEAN?(t.critical=e.value[1].value.charCodeAt(0)!==0,t.value=e.value[2].value):t.value=e.value[1].value,t.id in ae){if(t.name=ae[t.id],t.name==="keyUsage"){var a=d.fromDer(t.value),r=0,n=0;a.value.length>1&&(r=a.value.charCodeAt(1),n=a.value.length>2?a.value.charCodeAt(2):0),t.digitalSignature=(r&128)===128,t.nonRepudiation=(r&64)===64,t.keyEncipherment=(r&32)===32,t.dataEncipherment=(r&16)===16,t.keyAgreement=(r&8)===8,t.keyCertSign=(r&4)===4,t.cRLSign=(r&2)===2,t.encipherOnly=(r&1)===1,t.decipherOnly=(n&128)===128}else if(t.name==="basicConstraints"){var a=d.fromDer(t.value);a.value.length>0&&a.value[0].type===d.Type.BOOLEAN?t.cA=a.value[0].value.charCodeAt(0)!==0:t.cA=!1;var i=null;a.value.length>0&&a.value[0].type===d.Type.INTEGER?i=a.value[0].value:a.value.length>1&&(i=a.value[1].value),i!==null&&(t.pathLenConstraint=d.derToInteger(i))}else if(t.name==="extKeyUsage")for(var a=d.fromDer(t.value),s=0;s<a.value.length;++s){var o=d.derToOid(a.value[s].value);o in ae?t[ae[o]]=!0:t[o]=!0}else if(t.name==="nsCertType"){var a=d.fromDer(t.value),r=0;a.value.length>1&&(r=a.value.charCodeAt(1)),t.client=(r&128)===128,t.server=(r&64)===64,t.email=(r&32)===32,t.objsign=(r&16)===16,t.reserved=(r&8)===8,t.sslCA=(r&4)===4,t.emailCA=(r&2)===2,t.objCA=(r&1)===1}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.altNames=[];for(var u,a=d.fromDer(t.value),l=0;l<a.value.length;++l){u=a.value[l];var c={type:u.type,value:u.value};switch(t.altNames.push(c),u.type){case 1:case 2:case 6:break;case 7:c.ip=G.util.bytesToIP(u.value);break;case 8:c.oid=d.derToOid(u.value);break}}}else if(t.name==="subjectKeyIdentifier"){var a=d.fromDer(t.value);t.subjectKeyIdentifier=G.util.bytesToHex(a.value)}}return t},k.certificationRequestFromAsn1=function(e,t){var a={},r=[];if(!d.validate(e,Mo,a,r)){var n=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw n.errors=r,n}var i=d.derToOid(a.publicKeyOid);if(i!==k.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var s=k.createCertificationRequest();if(s.version=a.csrVersion?a.csrVersion.charCodeAt(0):0,s.signatureOid=G.asn1.derToOid(a.csrSignatureOid),s.signatureParameters=wr(s.signatureOid,a.csrSignatureParams,!0),s.siginfo.algorithmOid=G.asn1.derToOid(a.csrSignatureOid),s.siginfo.parameters=wr(s.siginfo.algorithmOid,a.csrSignatureParams,!1),s.signature=a.csrSignature,s.certificationRequestInfo=a.certificationRequestInfo,t){s.md=_r({signatureOid:s.signatureOid,type:"certification request"});var o=d.toDer(s.certificationRequestInfo);s.md.update(o.getBytes())}var u=G.md.sha1.create();return s.subject.getField=function(l){return bt(s.subject,l)},s.subject.addField=function(l){rt([l]),s.subject.attributes.push(l)},s.subject.attributes=k.RDNAttributesAsArray(a.certificationRequestInfoSubject,u),s.subject.hash=u.digest().toHex(),s.publicKey=k.publicKeyFromAsn1(a.subjectPublicKeyInfo),s.getAttribute=function(l){return bt(s,l)},s.addAttribute=function(l){rt([l]),s.attributes.push(l)},s.attributes=k.CRIAttributesAsArray(a.certificationRequestInfoAttributes||[]),s},k.createCertificationRequest=function(){var e={};return e.version=0,e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return bt(e.subject,t)},e.subject.addField=function(t){rt([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return bt(e,t)},e.addAttribute=function(t){rt([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){rt(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){rt(t),e.attributes=t},e.sign=function(t,a){e.md=a||G.md.sha1.create();var r=ae[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.certificationRequestInfo=k.getCertificationRequestInfo(e);var i=d.toDer(e.certificationRequestInfo);e.md.update(i.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,a=e.md;if(a===null){a=_r({signatureOid:e.signatureOid,type:"certification request"});var r=e.certificationRequestInfo||k.getCertificationRequestInfo(e),n=d.toDer(r);a.update(n.getBytes())}return a!==null&&(t=En({certificate:e,md:a,signature:e.signature})),t},e};function $t(e){for(var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),a,r,n=e.attributes,i=0;i<n.length;++i){a=n[i];var s=a.value,o=d.Type.PRINTABLESTRING;"valueTagClass"in a&&(o=a.valueTagClass,o===d.Type.UTF8&&(s=G.util.encodeUtf8(s))),r=d.create(d.Class.UNIVERSAL,d.Type.SET,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(a.type).getBytes()),d.create(d.Class.UNIVERSAL,o,!1,s)])]),t.value.push(r)}return t}function rt(e){for(var t,a=0;a<e.length;++a){if(t=e[a],typeof t.name>"u"&&(t.type&&t.type in k.oids?t.name=k.oids[t.type]:t.shortName&&t.shortName in me&&(t.name=k.oids[me[t.shortName]])),typeof t.type>"u")if(t.name&&t.name in k.oids)t.type=k.oids[t.name];else{var r=new Error("Attribute type not specified.");throw r.attribute=t,r}if(typeof t.shortName>"u"&&t.name&&t.name in me&&(t.shortName=me[t.name]),t.type===ae.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=d.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var n=0;n<t.extensions.length;++n)t.value.push(k.certificateExtensionToAsn1(xn(t.extensions[n])))}if(typeof t.value>"u"){var r=new Error("Attribute value not specified.");throw r.attribute=t,r}}}function xn(e,t){if(t=t||{},typeof e.name>"u"&&e.id&&e.id in k.oids&&(e.name=k.oids[e.id]),typeof e.id>"u")if(e.name&&e.name in k.oids)e.id=k.oids[e.name];else{var a=new Error("Extension ID not specified.");throw a.extension=e,a}if(typeof e.value<"u")return e;if(e.name==="keyUsage"){var r=0,n=0,i=0;e.digitalSignature&&(n|=128,r=7),e.nonRepudiation&&(n|=64,r=6),e.keyEncipherment&&(n|=32,r=5),e.dataEncipherment&&(n|=16,r=4),e.keyAgreement&&(n|=8,r=3),e.keyCertSign&&(n|=4,r=2),e.cRLSign&&(n|=2,r=1),e.encipherOnly&&(n|=1,r=0),e.decipherOnly&&(i|=128,r=7);var s=String.fromCharCode(r);i!==0?s+=String.fromCharCode(n)+String.fromCharCode(i):n!==0&&(s+=String.fromCharCode(n)),e.value=d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,s)}else if(e.name==="basicConstraints")e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(d.create(d.Class.UNIVERSAL,d.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.pathLenConstraint).getBytes()));else if(e.name==="extKeyUsage"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);var o=e.value.value;for(var u in e)e[u]===!0&&(u in ae?o.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(ae[u]).getBytes())):u.indexOf(".")!==-1&&o.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(u).getBytes())))}else if(e.name==="nsCertType"){var r=0,n=0;e.client&&(n|=128,r=7),e.server&&(n|=64,r=6),e.email&&(n|=32,r=5),e.objsign&&(n|=16,r=4),e.reserved&&(n|=8,r=3),e.sslCA&&(n|=4,r=2),e.emailCA&&(n|=2,r=1),e.objCA&&(n|=1,r=0);var s=String.fromCharCode(r);n!==0&&(s+=String.fromCharCode(n)),e.value=d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,s)}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);for(var l,c=0;c<e.altNames.length;++c){l=e.altNames[c];var s=l.value;if(l.type===7&&l.ip){if(s=G.util.bytesFromIP(l.ip),s===null){var a=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw a.extension=e,a}}else l.type===8&&(l.oid?s=d.oidToDer(d.oidToDer(l.oid)):s=d.oidToDer(s));e.value.value.push(d.create(d.Class.CONTEXT_SPECIFIC,l.type,!1,s))}}else if(e.name==="nsComment"&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=d.create(d.Class.UNIVERSAL,d.Type.IA5STRING,!1,e.comment)}else if(e.name==="subjectKeyIdentifier"&&t.cert){var f=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=f.toHex(),e.value=d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,f.getBytes())}else if(e.name==="authorityKeyIdentifier"&&t.cert){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);var o=e.value.value;if(e.keyIdentifier){var g=e.keyIdentifier===!0?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;o.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!1,g))}if(e.authorityCertIssuer){var v=[d.create(d.Class.CONTEXT_SPECIFIC,4,!0,[$t(e.authorityCertIssuer===!0?t.cert.issuer:e.authorityCertIssuer)])];o.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,v))}if(e.serialNumber){var y=G.util.hexToBytes(e.serialNumber===!0?t.cert.serialNumber:e.serialNumber);o.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if(e.name==="cRLDistributionPoints"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);for(var o=e.value.value,x=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),S=d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[]),l,c=0;c<e.altNames.length;++c){l=e.altNames[c];var s=l.value;if(l.type===7&&l.ip){if(s=G.util.bytesFromIP(l.ip),s===null){var a=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw a.extension=e,a}}else l.type===8&&(l.oid?s=d.oidToDer(d.oidToDer(l.oid)):s=d.oidToDer(s));S.value.push(d.create(d.Class.CONTEXT_SPECIFIC,l.type,!1,s))}x.value.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[S])),o.push(x)}if(typeof e.value>"u"){var a=new Error("Extension value not specified.");throw a.extension=e,a}return e}function ia(e,t){switch(e){case ae["RSASSA-PSS"]:var a=[];return t.hash.algorithmOid!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.hash.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")])])),t.mgf.algorithmOid!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.mgf.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.mgf.hash.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")])])])),t.saltLength!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(t.saltLength).getBytes())])),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,a);default:return d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")}}function Ho(e){var t=d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[]);if(e.attributes.length===0)return t;for(var a=e.attributes,r=0;r<a.length;++r){var n=a[r],i=n.value,s=d.Type.UTF8;"valueTagClass"in n&&(s=n.valueTagClass),s===d.Type.UTF8&&(i=G.util.encodeUtf8(i));var o=!1;"valueConstructed"in n&&(o=n.valueConstructed);var u=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(n.type).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SET,!0,[d.create(d.Class.UNIVERSAL,s,o,i)])]);t.value.push(u)}return t}var Go=new Date("1950-01-01T00:00:00Z"),zo=new Date("2050-01-01T00:00:00Z");function Sn(e){return e>=Go&&e<zo?d.create(d.Class.UNIVERSAL,d.Type.UTCTIME,!1,d.dateToUtcTime(e)):d.create(d.Class.UNIVERSAL,d.Type.GENERALIZEDTIME,!1,d.dateToGeneralizedTime(e))}k.getTBSCertificate=function(e){var t=Sn(e.validity.notBefore),a=Sn(e.validity.notAfter),r=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.version).getBytes())]),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,G.util.hexToBytes(e.serialNumber)),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.siginfo.algorithmOid).getBytes()),ia(e.siginfo.algorithmOid,e.siginfo.parameters)]),$t(e.issuer),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,a]),$t(e.subject),k.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&r.value.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,[d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&r.value.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!0,[d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&r.value.push(k.certificateExtensionsToAsn1(e.extensions)),r},k.getCertificationRequestInfo=function(e){var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.version).getBytes()),$t(e.subject),k.publicKeyToAsn1(e.publicKey),Ho(e)]);return t},k.distinguishedNameToAsn1=function(e){return $t(e)},k.certificateToAsn1=function(e){var t=e.tbsCertificate||k.getTBSCertificate(e);return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.signatureOid).getBytes()),ia(e.signatureOid,e.signatureParameters)]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},k.certificateExtensionsToAsn1=function(e){var t=d.create(d.Class.CONTEXT_SPECIFIC,3,!0,[]),a=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);t.value.push(a);for(var r=0;r<e.length;++r)a.value.push(k.certificateExtensionToAsn1(e[r]));return t},k.certificateExtensionToAsn1=function(e){var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);t.value.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.id).getBytes())),e.critical&&t.value.push(d.create(d.Class.UNIVERSAL,d.Type.BOOLEAN,!1,String.fromCharCode(255)));var a=e.value;return typeof e.value!="string"&&(a=d.toDer(a).getBytes()),t.value.push(d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,a)),t},k.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||k.getCertificationRequestInfo(e);return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.signatureOid).getBytes()),ia(e.signatureOid,e.signatureParameters)]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},k.createCaStore=function(e){var t={certs:{}};t.getIssuer=function(s){var o=a(s.issuer);return o},t.addCertificate=function(s){if(typeof s=="string"&&(s=G.pki.certificateFromPem(s)),r(s.subject),!t.hasCertificate(s))if(s.subject.hash in t.certs){var o=t.certs[s.subject.hash];G.util.isArray(o)||(o=[o]),o.push(s),t.certs[s.subject.hash]=o}else t.certs[s.subject.hash]=s},t.hasCertificate=function(s){typeof s=="string"&&(s=G.pki.certificateFromPem(s));var o=a(s.subject);if(!o)return!1;G.util.isArray(o)||(o=[o]);for(var u=d.toDer(k.certificateToAsn1(s)).getBytes(),l=0;l<o.length;++l){var c=d.toDer(k.certificateToAsn1(o[l])).getBytes();if(u===c)return!0}return!1},t.listAllCertificates=function(){var s=[];for(var o in t.certs)if(t.certs.hasOwnProperty(o)){var u=t.certs[o];if(!G.util.isArray(u))s.push(u);else for(var l=0;l<u.length;++l)s.push(u[l])}return s},t.removeCertificate=function(s){var o;if(typeof s=="string"&&(s=G.pki.certificateFromPem(s)),r(s.subject),!t.hasCertificate(s))return null;var u=a(s.subject);if(!G.util.isArray(u))return o=t.certs[s.subject.hash],delete t.certs[s.subject.hash],o;for(var l=d.toDer(k.certificateToAsn1(s)).getBytes(),c=0;c<u.length;++c){var f=d.toDer(k.certificateToAsn1(u[c])).getBytes();l===f&&(o=u[c],u.splice(c,1))}return u.length===0&&delete t.certs[s.subject.hash],o};function a(s){return r(s),t.certs[s.hash]||null}function r(s){if(!s.hash){var o=G.md.sha1.create();s.attributes=k.RDNAttributesAsArray($t(s),o),s.hash=o.digest().toHex()}}if(e)for(var n=0;n<e.length;++n){var i=e[n];t.addCertificate(i)}return t},k.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"},k.verifyCertificateChain=function(e,t,a){typeof a=="function"&&(a={verify:a}),a=a||{},t=t.slice(0);var r=t.slice(0),n=a.validityCheckDate;typeof n>"u"&&(n=new Date);var i=!0,s=null,o=0;do{var u=t.shift(),l=null,c=!1;if(n&&(n<u.validity.notBefore||n>u.validity.notAfter)&&(s={message:"Certificate is not valid yet or has expired.",error:k.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:n}),s===null){if(l=t[0]||e.getIssuer(u),l===null&&u.isIssuer(u)&&(c=!0,l=u),l){var f=l;G.util.isArray(f)||(f=[f]);for(var g=!1;!g&&f.length>0;){l=f.shift();try{g=l.verify(u)}catch{}}g||(s={message:"Certificate signature is invalid.",error:k.certificateError.bad_certificate})}s===null&&(!l||c)&&!e.hasCertificate(u)&&(s={message:"Certificate is not trusted.",error:k.certificateError.unknown_ca})}if(s===null&&l&&!u.isIssuer(l)&&(s={message:"Certificate issuer is invalid.",error:k.certificateError.bad_certificate}),s===null)for(var v={keyUsage:!0,basicConstraints:!0},y=0;s===null&&y<u.extensions.length;++y){var x=u.extensions[y];x.critical&&!(x.name in v)&&(s={message:"Certificate has an unsupported critical extension.",error:k.certificateError.unsupported_certificate})}if(s===null&&(!i||t.length===0&&(!l||c))){var S=u.getExtension("basicConstraints"),I=u.getExtension("keyUsage");if(I!==null&&(!I.keyCertSign||S===null)&&(s={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:k.certificateError.bad_certificate}),s===null&&S!==null&&!S.cA&&(s={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:k.certificateError.bad_certificate}),s===null&&I!==null&&"pathLenConstraint"in S){var A=o-1;A>S.pathLenConstraint&&(s={message:"Certificate basicConstraints pathLenConstraint violated.",error:k.certificateError.bad_certificate})}}var B=s===null?!0:s.error,P=a.verify?a.verify(B,o,r):B;if(P===!0)s=null;else throw B===!0&&(s={message:"The application rejected the certificate.",error:k.certificateError.bad_certificate}),(P||P===0)&&(typeof P=="object"&&!G.util.isArray(P)?(P.message&&(s.message=P.message),P.error&&(s.error=P.error)):typeof P=="string"&&(s.error=P)),s;i=!1,++o}while(t.length>0);return!0};var de=j,m=de.asn1,Z=de.pki,ir=de.pkcs12=de.pkcs12||{},Tn={name:"ContentInfo",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},qo={name:"PFX",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"version"},Tn,{name:"PFX.macData",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:m.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:m.Class.UNIVERSAL,type:m.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:m.Class.UNIVERSAL,type:m.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},Qo={name:"SafeBag",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:m.Class.UNIVERSAL,type:m.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},Wo={name:"Attribute",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:m.Class.UNIVERSAL,type:m.Type.SET,constructed:!0,capture:"values"}]},$o={name:"CertBag",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:m.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:m.Class.UNIVERSAL,type:m.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function sr(e,t,a,r){for(var n=[],i=0;i<e.length;i++)for(var s=0;s<e[i].safeBags.length;s++){var o=e[i].safeBags[s];if(!(r!==void 0&&o.type!==r)){if(t===null){n.push(o);continue}o.attributes[t]!==void 0&&o.attributes[t].indexOf(a)>=0&&n.push(o)}}return n}ir.pkcs12FromAsn1=function(e,t,a){typeof t=="string"?(a=t,t=!0):t===void 0&&(t=!0);var r={},n=[];if(!m.validate(e,qo,r,n)){var i=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw i.errors=i,i}var s={version:r.version.charCodeAt(0),safeContents:[],getBags:function(S){var I={},A;return"localKeyId"in S?A=S.localKeyId:"localKeyIdHex"in S&&(A=de.util.hexToBytes(S.localKeyIdHex)),A===void 0&&!("friendlyName"in S)&&"bagType"in S&&(I[S.bagType]=sr(s.safeContents,null,null,S.bagType)),A!==void 0&&(I.localKeyId=sr(s.safeContents,"localKeyId",A,S.bagType)),"friendlyName"in S&&(I.friendlyName=sr(s.safeContents,"friendlyName",S.friendlyName,S.bagType)),I},getBagsByFriendlyName:function(S,I){return sr(s.safeContents,"friendlyName",S,I)},getBagsByLocalKeyId:function(S,I){return sr(s.safeContents,"localKeyId",S,I)}};if(r.version.charCodeAt(0)!==3){var i=new Error("PKCS#12 PFX of version other than 3 not supported.");throw i.version=r.version.charCodeAt(0),i}if(m.derToOid(r.contentType)!==Z.oids.data){var i=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw i.oid=m.derToOid(r.contentType),i}var o=r.content.value[0];if(o.tagClass!==m.Class.UNIVERSAL||o.type!==m.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(o=sa(o),r.mac){var u=null,l=0,c=m.derToOid(r.macAlgorithm);switch(c){case Z.oids.sha1:u=de.md.sha1.create(),l=20;break;case Z.oids.sha256:u=de.md.sha256.create(),l=32;break;case Z.oids.sha384:u=de.md.sha384.create(),l=48;break;case Z.oids.sha512:u=de.md.sha512.create(),l=64;break;case Z.oids.md5:u=de.md.md5.create(),l=16;break}if(u===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+c);var f=new de.util.ByteBuffer(r.macSalt),g="macIterations"in r?parseInt(de.util.bytesToHex(r.macIterations),16):1,v=ir.generateKey(a,f,3,g,l,u),y=de.hmac.create();y.start(u,v),y.update(o.value);var x=y.getMac();if(x.getBytes()!==r.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray(e.value)&&e.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return Yo(s,o.value,t,a),s};function sa(e){if(e.composed||e.constructed){for(var t=de.util.createBuffer(),a=0;a<e.value.length;++a)t.putBytes(e.value[a].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function Yo(e,t,a,r){if(t=m.fromDer(t,a),t.tagClass!==m.Class.UNIVERSAL||t.type!==m.Type.SEQUENCE||t.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var n=0;n<t.value.length;n++){var i=t.value[n],s={},o=[];if(!m.validate(i,Tn,s,o)){var u=new Error("Cannot read ContentInfo.");throw u.errors=o,u}var l={encrypted:!1},c=null,f=s.content.value[0];switch(m.derToOid(s.contentType)){case Z.oids.data:if(f.tagClass!==m.Class.UNIVERSAL||f.type!==m.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");c=sa(f).value;break;case Z.oids.encryptedData:c=jo(f,r),l.encrypted=!0;break;default:var u=new Error("Unsupported PKCS#12 contentType.");throw u.contentType=m.derToOid(s.contentType),u}l.safeBags=Xo(c,a,r),e.safeContents.push(l)}}function jo(e,t){var a={},r=[];if(!m.validate(e,de.pkcs7.asn1.encryptedDataValidator,a,r)){var n=new Error("Cannot read EncryptedContentInfo.");throw n.errors=r,n}var i=m.derToOid(a.contentType);if(i!==Z.oids.data){var n=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw n.oid=i,n}i=m.derToOid(a.encAlgorithm);var s=Z.pbe.getCipher(i,a.encParameter,t),o=sa(a.encryptedContentAsn1),u=de.util.createBuffer(o.value);if(s.update(u),!s.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return s.output.getBytes()}function Xo(e,t,a){if(!t&&e.length===0)return[];if(e=m.fromDer(e,t),e.tagClass!==m.Class.UNIVERSAL||e.type!==m.Type.SEQUENCE||e.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var r=[],n=0;n<e.value.length;n++){var i=e.value[n],s={},o=[];if(!m.validate(i,Qo,s,o)){var u=new Error("Cannot read SafeBag.");throw u.errors=o,u}var l={type:m.derToOid(s.bagId),attributes:Zo(s.bagAttributes)};r.push(l);var c,f,g=s.bagValue.value[0];switch(l.type){case Z.oids.pkcs8ShroudedKeyBag:if(g=Z.decryptPrivateKeyInfo(g,a),g===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case Z.oids.keyBag:try{l.key=Z.privateKeyFromAsn1(g)}catch{l.key=null,l.asn1=g}continue;case Z.oids.certBag:c=$o,f=function(){if(m.derToOid(s.certId)!==Z.oids.x509Certificate){var y=new Error("Unsupported certificate type, only X.509 supported.");throw y.oid=m.derToOid(s.certId),y}var x=m.fromDer(s.cert,t);try{l.cert=Z.certificateFromAsn1(x,!0)}catch{l.cert=null,l.asn1=x}};break;default:var u=new Error("Unsupported PKCS#12 SafeBag type.");throw u.oid=l.type,u}if(c!==void 0&&!m.validate(g,c,s,o)){var u=new Error("Cannot read PKCS#12 "+c.name);throw u.errors=o,u}f()}return r}function Zo(e){var t={};if(e!==void 0)for(var a=0;a<e.length;++a){var r={},n=[];if(!m.validate(e[a],Wo,r,n)){var i=new Error("Cannot read PKCS#12 BagAttribute.");throw i.errors=n,i}var s=m.derToOid(r.oid);if(Z.oids[s]!==void 0){t[Z.oids[s]]=[];for(var o=0;o<r.values.length;++o)t[Z.oids[s]].push(r.values[o].value)}}return t}ir.toPkcs12Asn1=function(e,t,a,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||r.encAlgorithm||"aes128","useMac"in r||(r.useMac=!0),"localKeyId"in r||(r.localKeyId=null),"generateLocalKeyId"in r||(r.generateLocalKeyId=!0);var n=r.localKeyId,i;if(n!==null)n=de.util.hexToBytes(n);else if(r.generateLocalKeyId)if(t){var s=de.util.isArray(t)?t[0]:t;typeof s=="string"&&(s=Z.certificateFromPem(s));var o=de.md.sha1.create();o.update(m.toDer(Z.certificateToAsn1(s)).getBytes()),n=o.digest().getBytes()}else n=de.random.getBytes(20);var u=[];n!==null&&u.push(m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.localKeyId).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,n)])])),"friendlyName"in r&&u.push(m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.friendlyName).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,m.Type.BMPSTRING,!1,r.friendlyName)])])),u.length>0&&(i=m.create(m.Class.UNIVERSAL,m.Type.SET,!0,u));var l=[],c=[];t!==null&&(de.util.isArray(t)?c=t:c=[t]);for(var f=[],g=0;g<c.length;++g){t=c[g],typeof t=="string"&&(t=Z.certificateFromPem(t));var v=g===0?i:void 0,y=Z.certificateToAsn1(t),x=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.certBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.x509Certificate).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(y).getBytes())])])]),v]);f.push(x)}if(f.length>0){var S=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,f),I=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(S).getBytes())])]);l.push(I)}var A=null;if(e!==null){var B=Z.wrapRsaPrivateKey(Z.privateKeyToAsn1(e));a===null?A=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.keyBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[B]),i]):A=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.pkcs8ShroudedKeyBag).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[Z.encryptPrivateKeyInfo(B,a,r)]),i]);var P=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[A]),L=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(P).getBytes())])]);l.push(L)}var R=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,l),q;if(r.useMac){var o=de.md.sha1.create(),Q=new de.util.ByteBuffer(de.random.getBytes(r.saltSize)),se=r.count,e=ir.generateKey(a,Q,3,se,20),re=de.hmac.create();re.start(o,e),re.update(m.toDer(R).getBytes());var W=re.getMac();q=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.sha1).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")]),m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,W.getBytes())]),m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,Q.getBytes()),m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(se).getBytes())])}return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(3).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(Z.oids.data).getBytes()),m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,m.toDer(R).getBytes())])]),q])},ir.generateKey=de.pbe.generatePkcs12Key;var At=j,oa=At.asn1,Yt=At.pki=At.pki||{};Yt.pemToDer=function(e){var t=At.pem.decode(e)[0];if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return At.util.createBuffer(t.body)},Yt.privateKeyFromPem=function(e){var t=At.pem.decode(e)[0];if(t.type!=="PRIVATE KEY"&&t.type!=="RSA PRIVATE KEY"){var a=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var r=oa.fromDer(t.body);return Yt.privateKeyFromAsn1(r)},Yt.privateKeyToPem=function(e,t){var a={type:"RSA PRIVATE KEY",body:oa.toDer(Yt.privateKeyToAsn1(e)).getBytes()};return At.pem.encode(a,{maxline:t})},Yt.privateKeyInfoToPem=function(e,t){var a={type:"PRIVATE KEY",body:oa.toDer(e).getBytes()};return At.pem.encode(a,{maxline:t})};var _=j,Nr=function(e,t,a,r){var n=_.util.createBuffer(),i=e.length>>1,s=i+(e.length&1),o=e.substr(0,s),u=e.substr(i,s),l=_.util.createBuffer(),c=_.hmac.create();a=t+a;var f=Math.ceil(r/16),g=Math.ceil(r/20);c.start("MD5",o);var v=_.util.createBuffer();l.putBytes(a);for(var y=0;y<f;++y)c.start(null,null),c.update(l.getBytes()),l.putBuffer(c.digest()),c.start(null,null),c.update(l.bytes()+a),v.putBuffer(c.digest());c.start("SHA1",u);var x=_.util.createBuffer();l.clear(),l.putBytes(a);for(var y=0;y<g;++y)c.start(null,null),c.update(l.getBytes()),l.putBuffer(c.digest()),c.start(null,null),c.update(l.bytes()+a),x.putBuffer(c.digest());return n.putBytes(_.util.xorBytes(v.getBytes(),x.getBytes(),r)),n},Jo=function(e,t,a){var r=_.hmac.create();r.start("SHA1",e);var n=_.util.createBuffer();return n.putInt32(t[0]),n.putInt32(t[1]),n.putByte(a.type),n.putByte(a.version.major),n.putByte(a.version.minor),n.putInt16(a.length),n.putBytes(a.fragment.bytes()),r.update(n.getBytes()),r.digest().getBytes()},e0=function(e,t,a){var r=!1;try{var n=e.deflate(t.fragment.getBytes());t.fragment=_.util.createBuffer(n),t.length=n.length,r=!0}catch{}return r},t0=function(e,t,a){var r=!1;try{var n=e.inflate(t.fragment.getBytes());t.fragment=_.util.createBuffer(n),t.length=n.length,r=!0}catch{}return r},Xe=function(e,t){var a=0;switch(t){case 1:a=e.getByte();break;case 2:a=e.getInt16();break;case 3:a=e.getInt24();break;case 4:a=e.getInt32();break}return _.util.createBuffer(e.getBytes(a))},at=function(e,t,a){e.putInt(a.length(),t<<3),e.putBuffer(a)},p={};p.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},p.SupportedVersions=[p.Versions.TLS_1_1,p.Versions.TLS_1_0],p.Version=p.SupportedVersions[0],p.MaxFragment=16384-1024,p.ConnectionEnd={server:0,client:1},p.PRFAlgorithm={tls_prf_sha256:0},p.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},p.CipherType={stream:0,block:1,aead:2},p.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},p.CompressionMethod={none:0,deflate:1},p.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},p.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},p.Alert={},p.Alert.Level={warning:1,fatal:2},p.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},p.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},p.CipherSuites={},p.getCipherSuite=function(e){var t=null;for(var a in p.CipherSuites){var r=p.CipherSuites[a];if(r.id[0]===e.charCodeAt(0)&&r.id[1]===e.charCodeAt(1)){t=r;break}}return t},p.handleUnexpected=function(e,t){var a=!e.open&&e.entity===p.ConnectionEnd.client;a||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unexpected_message}})},p.handleHelloRequest=function(e,t,a){!e.handshaking&&e.handshakes>0&&(p.queue(e,p.createAlert(e,{level:p.Alert.Level.warning,description:p.Alert.Description.no_renegotiation})),p.flush(e)),e.process()},p.parseHelloMessage=function(e,t,a){var r=null,n=e.entity===p.ConnectionEnd.client;if(a<38)e.error(e,{message:n?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});else{var i=t.fragment,s=i.length();if(r={version:{major:i.getByte(),minor:i.getByte()},random:_.util.createBuffer(i.getBytes(32)),session_id:Xe(i,1),extensions:[]},n?(r.cipher_suite=i.getBytes(2),r.compression_method=i.getByte()):(r.cipher_suites=Xe(i,2),r.compression_methods=Xe(i,1)),s=a-(s-i.length()),s>0){for(var o=Xe(i,2);o.length()>0;)r.extensions.push({type:[o.getByte(),o.getByte()],data:Xe(o,2)});if(!n)for(var u=0;u<r.extensions.length;++u){var l=r.extensions[u];if(l.type[0]===0&&l.type[1]===0)for(var c=Xe(l.data,2);c.length()>0;){var f=c.getByte();if(f!==0)break;e.session.extensions.server_name.serverNameList.push(Xe(c,2).getBytes())}}}if(e.session.version&&(r.version.major!==e.session.version.major||r.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}});if(n)e.session.cipherSuite=p.getCipherSuite(r.cipher_suite);else for(var g=_.util.createBuffer(r.cipher_suites.bytes());g.length()>0&&(e.session.cipherSuite=p.getCipherSuite(g.getBytes(2)),e.session.cipherSuite===null););if(e.session.cipherSuite===null)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.handshake_failure},cipherSuite:_.util.bytesToHex(r.cipher_suite)});n?e.session.compressionMethod=r.compression_method:e.session.compressionMethod=p.CompressionMethod.none}return r},p.createSecurityParameters=function(e,t){var a=e.entity===p.ConnectionEnd.client,r=t.random.bytes(),n=a?e.session.sp.client_random:r,i=a?r:p.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:p.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:i}},p.handleServerHello=function(e,t,a){var r=p.parseHelloMessage(e,t,a);if(!e.fail){if(r.version.minor<=e.version.minor)e.version.minor=r.version.minor;else return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}});e.session.version=e.version;var n=r.session_id.bytes();n.length>0&&n===e.session.id?(e.expect=bn,e.session.resuming=!0,e.session.sp.server_random=r.random.bytes()):(e.expect=a0,e.session.resuming=!1,p.createSecurityParameters(e,r)),e.session.id=n,e.process()}},p.handleClientHello=function(e,t,a){var r=p.parseHelloMessage(e,t,a);if(!e.fail){var n=r.session_id.bytes(),i=null;if(e.sessionCache&&(i=e.sessionCache.getSession(n),i===null?n="":(i.version.major!==r.version.major||i.version.minor>r.version.minor)&&(i=null,n="")),n.length===0&&(n=_.random.getBytes(32)),e.session.id=n,e.session.clientHelloVersion=r.version,e.session.sp={},i)e.version=e.session.version=i.version,e.session.sp=i.sp;else{for(var s,o=1;o<p.SupportedVersions.length&&(s=p.SupportedVersions[o],!(s.minor<=r.version.minor));++o);e.version={major:s.major,minor:s.minor},e.session.version=e.version}i!==null?(e.expect=ua,e.session.resuming=!0,e.session.sp.client_random=r.random.bytes()):(e.expect=e.verifyClient!==!1?c0:la,e.session.resuming=!1,p.createSecurityParameters(e,r)),e.open=!0,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerHello(e)})),e.session.resuming?(p.queue(e,p.createRecord(e,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),e.state.pending=p.createConnectionState(e),e.state.current.write=e.state.pending.write,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createFinished(e)}))):(p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificate(e)})),e.fail||(p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerKeyExchange(e)})),e.verifyClient!==!1&&p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificateRequest(e)})),p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerHelloDone(e)})))),p.flush(e),e.process()}},p.handleCertificate=function(e,t,a){if(a<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_list:Xe(r,3)},i,s,o=[];try{for(;n.certificate_list.length()>0;)i=Xe(n.certificate_list,3),s=_.asn1.fromDer(i),i=_.pki.certificateFromAsn1(s,!0),o.push(i)}catch(l){return e.error(e,{message:"Could not parse certificate list.",cause:l,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var u=e.entity===p.ConnectionEnd.client;(u||e.verifyClient===!0)&&o.length===0?e.error(e,{message:u?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}}):o.length===0?e.expect=u?In:la:(u?e.session.serverCertificate=o[0]:e.session.clientCertificate=o[0],p.verifyCertificateChain(e,o)&&(e.expect=u?In:la)),e.process()},p.handleServerKeyExchange=function(e,t,a){if(a>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unsupported_certificate}});e.expect=n0,e.process()},p.handleClientKeyExchange=function(e,t,a){if(a<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unsupported_certificate}});var r=t.fragment,n={enc_pre_master_secret:Xe(r,2).getBytes()},i=null;if(e.getPrivateKey)try{i=e.getPrivateKey(e,e.session.serverCertificate),i=_.pki.privateKeyFromPem(i)}catch(u){e.error(e,{message:"Could not get private key.",cause:u,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}})}if(i===null)return e.error(e,{message:"No private key set.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}});try{var s=e.session.sp;s.pre_master_secret=i.decrypt(n.enc_pre_master_secret);var o=e.session.clientHelloVersion;if(o.major!==s.pre_master_secret.charCodeAt(0)||o.minor!==s.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{s.pre_master_secret=_.random.getBytes(48)}e.expect=ua,e.session.clientCertificate!==null&&(e.expect=f0),e.process()},p.handleCertificateRequest=function(e,t,a){if(a<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_types:Xe(r,1),certificate_authorities:Xe(r,2)};e.session.certificateRequest=n,e.expect=i0,e.process()},p.handleCertificateVerify=function(e,t,a){if(a<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var i={signature:Xe(r,2).getBytes()},s=_.util.createBuffer();s.putBuffer(e.session.md5.digest()),s.putBuffer(e.session.sha1.digest()),s=s.getBytes();try{var o=e.session.clientCertificate;if(!o.publicKey.verify(s,i.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(n),e.session.sha1.update(n)}catch{return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.handshake_failure}})}e.expect=ua,e.process()},p.handleServerHelloDone=function(e,t,a){if(a>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.record_overflow}});if(e.serverCertificate===null){var r={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.insufficient_security}},n=0,i=e.verify(e,r.alert.description,n,[]);if(i!==!0)return(i||i===0)&&(typeof i=="object"&&!_.util.isArray(i)?(i.message&&(r.message=i.message),i.alert&&(r.alert.description=i.alert)):typeof i=="number"&&(r.alert.description=i)),e.error(e,r)}e.session.certificateRequest!==null&&(t=p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificate(e)}),p.queue(e,t)),t=p.createRecord(e,{type:p.ContentType.handshake,data:p.createClientKeyExchange(e)}),p.queue(e,t),e.expect=l0;var s=function(o,u){o.session.certificateRequest!==null&&o.session.clientCertificate!==null&&p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createCertificateVerify(o,u)})),p.queue(o,p.createRecord(o,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),o.state.pending=p.createConnectionState(o),o.state.current.write=o.state.pending.write,p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createFinished(o)})),o.expect=bn,p.flush(o),o.process()};if(e.session.certificateRequest===null||e.session.clientCertificate===null)return s(e,null);p.getClientSignature(e,s)},p.handleChangeCipherSpec=function(e,t){if(t.fragment.getByte()!==1)return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var a=e.entity===p.ConnectionEnd.client;(e.session.resuming&&a||!e.session.resuming&&!a)&&(e.state.pending=p.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&a||e.session.resuming&&!a)&&(e.state.pending=null),e.expect=a?s0:d0,e.process()},p.handleFinished=function(e,t,a){var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var i=t.fragment.getBytes();r=_.util.createBuffer(),r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest());var s=e.entity===p.ConnectionEnd.client,o=s?"server finished":"client finished",u=e.session.sp,l=12,c=Nr;if(r=c(u.master_secret,o,r.getBytes(),l),r.getBytes()!==i)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.decrypt_error}});e.session.md5.update(n),e.session.sha1.update(n),(e.session.resuming&&s||!e.session.resuming&&!s)&&(p.queue(e,p.createRecord(e,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createFinished(e)}))),e.expect=s?o0:h0,e.handshaking=!1,++e.handshakes,e.peerCertificate=s?e.session.serverCertificate:e.session.clientCertificate,p.flush(e),e.isConnected=!0,e.connected(e),e.process()},p.handleAlert=function(e,t){var a=t.fragment,r={level:a.getByte(),description:a.getByte()},n;switch(r.description){case p.Alert.Description.close_notify:n="Connection closed.";break;case p.Alert.Description.unexpected_message:n="Unexpected message.";break;case p.Alert.Description.bad_record_mac:n="Bad record MAC.";break;case p.Alert.Description.decryption_failed:n="Decryption failed.";break;case p.Alert.Description.record_overflow:n="Record overflow.";break;case p.Alert.Description.decompression_failure:n="Decompression failed.";break;case p.Alert.Description.handshake_failure:n="Handshake failure.";break;case p.Alert.Description.bad_certificate:n="Bad certificate.";break;case p.Alert.Description.unsupported_certificate:n="Unsupported certificate.";break;case p.Alert.Description.certificate_revoked:n="Certificate revoked.";break;case p.Alert.Description.certificate_expired:n="Certificate expired.";break;case p.Alert.Description.certificate_unknown:n="Certificate unknown.";break;case p.Alert.Description.illegal_parameter:n="Illegal parameter.";break;case p.Alert.Description.unknown_ca:n="Unknown certificate authority.";break;case p.Alert.Description.access_denied:n="Access denied.";break;case p.Alert.Description.decode_error:n="Decode error.";break;case p.Alert.Description.decrypt_error:n="Decrypt error.";break;case p.Alert.Description.export_restriction:n="Export restriction.";break;case p.Alert.Description.protocol_version:n="Unsupported protocol version.";break;case p.Alert.Description.insufficient_security:n="Insufficient security.";break;case p.Alert.Description.internal_error:n="Internal error.";break;case p.Alert.Description.user_canceled:n="User canceled.";break;case p.Alert.Description.no_renegotiation:n="Renegotiation not supported.";break;default:n="Unknown error.";break}if(r.description===p.Alert.Description.close_notify)return e.close();e.error(e,{message:n,send:!1,origin:e.entity===p.ConnectionEnd.client?"server":"client",alert:r}),e.process()},p.handleHandshake=function(e,t){var a=t.fragment,r=a.getByte(),n=a.getInt24();if(n>a.length())return e.fragmented=t,t.fragment=_.util.createBuffer(),a.read-=4,e.process();e.fragmented=null,a.read-=4;var i=a.bytes(n+4);a.read+=4,r in Lr[e.entity][e.expect]?(e.entity===p.ConnectionEnd.server&&!e.open&&!e.fail&&(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:_.md.md5.create(),sha1:_.md.sha1.create()}),r!==p.HandshakeType.hello_request&&r!==p.HandshakeType.certificate_verify&&r!==p.HandshakeType.finished&&(e.session.md5.update(i),e.session.sha1.update(i)),Lr[e.entity][e.expect][r](e,t,n)):p.handleUnexpected(e,t)},p.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},p.handleHeartbeat=function(e,t){var a=t.fragment,r=a.getByte(),n=a.getInt16(),i=a.getBytes(n);if(r===p.HeartbeatMessageType.heartbeat_request){if(e.handshaking||n>i.length)return e.process();p.queue(e,p.createRecord(e,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_response,i)})),p.flush(e)}else if(r===p.HeartbeatMessageType.heartbeat_response){if(i!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,_.util.createBuffer(i))}e.process()};var r0=0,a0=1,In=2,n0=3,i0=4,bn=5,s0=6,o0=7,l0=8,u0=0,c0=1,la=2,f0=3,ua=4,d0=5,h0=6,h=p.handleUnexpected,An=p.handleChangeCipherSpec,_e=p.handleAlert,Ge=p.handleHandshake,Bn=p.handleApplicationData,Ne=p.handleHeartbeat,ca=[];ca[p.ConnectionEnd.client]=[[h,_e,Ge,h,Ne],[h,_e,Ge,h,Ne],[h,_e,Ge,h,Ne],[h,_e,Ge,h,Ne],[h,_e,Ge,h,Ne],[An,_e,h,h,Ne],[h,_e,Ge,h,Ne],[h,_e,Ge,Bn,Ne],[h,_e,Ge,h,Ne]],ca[p.ConnectionEnd.server]=[[h,_e,Ge,h,Ne],[h,_e,Ge,h,Ne],[h,_e,Ge,h,Ne],[h,_e,Ge,h,Ne],[An,_e,h,h,Ne],[h,_e,Ge,h,Ne],[h,_e,Ge,Bn,Ne],[h,_e,Ge,h,Ne]];var Bt=p.handleHelloRequest,p0=p.handleServerHello,wn=p.handleCertificate,_n=p.handleServerKeyExchange,fa=p.handleCertificateRequest,Rr=p.handleServerHelloDone,Nn=p.handleFinished,Lr=[];Lr[p.ConnectionEnd.client]=[[h,h,p0,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Bt,h,h,h,h,h,h,h,h,h,h,wn,_n,fa,Rr,h,h,h,h,h,h],[Bt,h,h,h,h,h,h,h,h,h,h,h,_n,fa,Rr,h,h,h,h,h,h],[Bt,h,h,h,h,h,h,h,h,h,h,h,h,fa,Rr,h,h,h,h,h,h],[Bt,h,h,h,h,h,h,h,h,h,h,h,h,h,Rr,h,h,h,h,h,h],[Bt,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Bt,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,Nn],[Bt,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[Bt,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h]];var g0=p.handleClientHello,y0=p.handleClientKeyExchange,v0=p.handleCertificateVerify;Lr[p.ConnectionEnd.server]=[[h,g0,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,wn,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,y0,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,v0,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,Nn],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h]],p.generateKeys=function(e,t){var a=Nr,r=t.client_random+t.server_random;e.session.resuming||(t.master_secret=a(t.pre_master_secret,"master secret",r,48).bytes(),t.pre_master_secret=null),r=t.server_random+t.client_random;var n=2*t.mac_key_length+2*t.enc_key_length,i=e.version.major===p.Versions.TLS_1_0.major&&e.version.minor===p.Versions.TLS_1_0.minor;i&&(n+=2*t.fixed_iv_length);var s=a(t.master_secret,"key expansion",r,n),o={client_write_MAC_key:s.getBytes(t.mac_key_length),server_write_MAC_key:s.getBytes(t.mac_key_length),client_write_key:s.getBytes(t.enc_key_length),server_write_key:s.getBytes(t.enc_key_length)};return i&&(o.client_write_IV=s.getBytes(t.fixed_iv_length),o.server_write_IV=s.getBytes(t.fixed_iv_length)),o},p.createConnectionState=function(e){var t=e.entity===p.ConnectionEnd.client,a=function(){var i={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(s){return!0},compressionState:null,compressFunction:function(s){return!0},updateSequenceNumber:function(){i.sequenceNumber[1]===4294967295?(i.sequenceNumber[1]=0,++i.sequenceNumber[0]):++i.sequenceNumber[1]}};return i},r={read:a(),write:a()};if(r.read.update=function(i,s){return r.read.cipherFunction(s,r.read)?r.read.compressFunction(i,s,r.read)||i.error(i,{message:"Could not decompress record.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.decompression_failure}}):i.error(i,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_record_mac}}),!i.fail},r.write.update=function(i,s){return r.write.compressFunction(i,s,r.write)?r.write.cipherFunction(s,r.write)||i.error(i,{message:"Could not encrypt record.",send:!1,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}):i.error(i,{message:"Could not compress record.",send:!1,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}),!i.fail},e.session){var n=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(n),n.keys=p.generateKeys(e,n),r.read.macKey=t?n.keys.server_write_MAC_key:n.keys.client_write_MAC_key,r.write.macKey=t?n.keys.client_write_MAC_key:n.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(r,e,n),n.compression_algorithm){case p.CompressionMethod.none:break;case p.CompressionMethod.deflate:r.read.compressFunction=t0,r.write.compressFunction=e0;break;default:throw new Error("Unsupported compression algorithm.")}}return r},p.createRandom=function(){var e=new Date,t=+e+e.getTimezoneOffset()*6e4,a=_.util.createBuffer();return a.putInt32(t),a.putBytes(_.random.getBytes(28)),a},p.createRecord=function(e,t){if(!t.data)return null;var a={type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data};return a},p.createAlert=function(e,t){var a=_.util.createBuffer();return a.putByte(t.level),a.putByte(t.description),p.createRecord(e,{type:p.ContentType.alert,data:a})},p.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=_.util.createBuffer(),a=0;a<e.cipherSuites.length;++a){var r=e.cipherSuites[a];t.putByte(r.id[0]),t.putByte(r.id[1])}var n=t.length(),i=_.util.createBuffer();i.putByte(p.CompressionMethod.none);var s=i.length(),o=_.util.createBuffer();if(e.virtualHost){var u=_.util.createBuffer();u.putByte(0),u.putByte(0);var l=_.util.createBuffer();l.putByte(0),at(l,2,_.util.createBuffer(e.virtualHost));var c=_.util.createBuffer();at(c,2,l),at(u,2,c),o.putBuffer(u)}var f=o.length();f>0&&(f+=2);var g=e.session.id,v=g.length+1+2+4+28+2+n+1+s+f,y=_.util.createBuffer();return y.putByte(p.HandshakeType.client_hello),y.putInt24(v),y.putByte(e.version.major),y.putByte(e.version.minor),y.putBytes(e.session.sp.client_random),at(y,1,_.util.createBuffer(g)),at(y,2,t),at(y,1,i),f>0&&at(y,2,o),y},p.createServerHello=function(e){var t=e.session.id,a=t.length+1+2+4+28+2+1,r=_.util.createBuffer();return r.putByte(p.HandshakeType.server_hello),r.putInt24(a),r.putByte(e.version.major),r.putByte(e.version.minor),r.putBytes(e.session.sp.server_random),at(r,1,_.util.createBuffer(t)),r.putByte(e.session.cipherSuite.id[0]),r.putByte(e.session.cipherSuite.id[1]),r.putByte(e.session.compressionMethod),r},p.createCertificate=function(e){var t=e.entity===p.ConnectionEnd.client,a=null;if(e.getCertificate){var r;t?r=e.session.certificateRequest:r=e.session.extensions.server_name.serverNameList,a=e.getCertificate(e,r)}var n=_.util.createBuffer();if(a!==null)try{_.util.isArray(a)||(a=[a]);for(var i=null,s=0;s<a.length;++s){var o=_.pem.decode(a[s])[0];if(o.type!=="CERTIFICATE"&&o.type!=="X509 CERTIFICATE"&&o.type!=="TRUSTED CERTIFICATE"){var u=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw u.headerType=o.type,u}if(o.procType&&o.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var l=_.util.createBuffer(o.body);i===null&&(i=_.asn1.fromDer(l.bytes(),!1));var c=_.util.createBuffer();at(c,3,l),n.putBuffer(c)}a=_.pki.certificateFromAsn1(i),t?e.session.clientCertificate=a:e.session.serverCertificate=a}catch(v){return e.error(e,{message:"Could not send certificate list.",cause:v,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var f=3+n.length(),g=_.util.createBuffer();return g.putByte(p.HandshakeType.certificate),g.putInt24(f),at(g,3,n),g},p.createClientKeyExchange=function(e){var t=_.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(_.random.getBytes(46));var a=e.session.sp;a.pre_master_secret=t.getBytes();var r=e.session.serverCertificate.publicKey;t=r.encrypt(a.pre_master_secret);var n=t.length+2,i=_.util.createBuffer();return i.putByte(p.HandshakeType.client_key_exchange),i.putInt24(n),i.putInt16(t.length),i.putBytes(t),i},p.createServerKeyExchange=function(e){var t=_.util.createBuffer();return t},p.getClientSignature=function(e,t){var a=_.util.createBuffer();a.putBuffer(e.session.md5.digest()),a.putBuffer(e.session.sha1.digest()),a=a.getBytes(),e.getSignature=e.getSignature||function(r,n,i){var s=null;if(r.getPrivateKey)try{s=r.getPrivateKey(r,r.session.clientCertificate),s=_.pki.privateKeyFromPem(s)}catch(o){r.error(r,{message:"Could not get private key.",cause:o,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}})}s===null?r.error(r,{message:"No private key set.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}):n=s.sign(n,null),i(r,n)},e.getSignature(e,a,t)},p.createCertificateVerify=function(e,t){var a=t.length+2,r=_.util.createBuffer();return r.putByte(p.HandshakeType.certificate_verify),r.putInt24(a),r.putInt16(t.length),r.putBytes(t),r},p.createCertificateRequest=function(e){var t=_.util.createBuffer();t.putByte(1);var a=_.util.createBuffer();for(var r in e.caStore.certs){var n=e.caStore.certs[r],i=_.pki.distinguishedNameToAsn1(n.subject),s=_.asn1.toDer(i);a.putInt16(s.length()),a.putBuffer(s)}var o=1+t.length()+2+a.length(),u=_.util.createBuffer();return u.putByte(p.HandshakeType.certificate_request),u.putInt24(o),at(u,1,t),at(u,2,a),u},p.createServerHelloDone=function(e){var t=_.util.createBuffer();return t.putByte(p.HandshakeType.server_hello_done),t.putInt24(0),t},p.createChangeCipherSpec=function(){var e=_.util.createBuffer();return e.putByte(1),e},p.createFinished=function(e){var t=_.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var a=e.entity===p.ConnectionEnd.client,r=e.session.sp,n=12,i=Nr,s=a?"client finished":"server finished";t=i(r.master_secret,s,t.getBytes(),n);var o=_.util.createBuffer();return o.putByte(p.HandshakeType.finished),o.putInt24(t.length()),o.putBuffer(t),o},p.createHeartbeat=function(e,t,a){typeof a>"u"&&(a=t.length);var r=_.util.createBuffer();r.putByte(e),r.putInt16(a),r.putBytes(t);var n=r.length(),i=Math.max(16,n-a-3);return r.putBytes(_.random.getBytes(i)),r},p.queue=function(e,t){if(t&&!(t.fragment.length()===0&&(t.type===p.ContentType.handshake||t.type===p.ContentType.alert||t.type===p.ContentType.change_cipher_spec))){if(t.type===p.ContentType.handshake){var a=t.fragment.bytes();e.session.md5.update(a),e.session.sha1.update(a),a=null}var r;if(t.fragment.length()<=p.MaxFragment)r=[t];else{r=[];for(var n=t.fragment.bytes();n.length>p.MaxFragment;)r.push(p.createRecord(e,{type:t.type,data:_.util.createBuffer(n.slice(0,p.MaxFragment))})),n=n.slice(p.MaxFragment);n.length>0&&r.push(p.createRecord(e,{type:t.type,data:_.util.createBuffer(n)}))}for(var i=0;i<r.length&&!e.fail;++i){var s=r[i],o=e.state.current.write;o.update(e,s)&&e.records.push(s)}}},p.flush=function(e){for(var t=0;t<e.records.length;++t){var a=e.records[t];e.tlsData.putByte(a.type),e.tlsData.putByte(a.version.major),e.tlsData.putByte(a.version.minor),e.tlsData.putInt16(a.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var da=function(e){switch(e){case!0:return!0;case _.pki.certificateError.bad_certificate:return p.Alert.Description.bad_certificate;case _.pki.certificateError.unsupported_certificate:return p.Alert.Description.unsupported_certificate;case _.pki.certificateError.certificate_revoked:return p.Alert.Description.certificate_revoked;case _.pki.certificateError.certificate_expired:return p.Alert.Description.certificate_expired;case _.pki.certificateError.certificate_unknown:return p.Alert.Description.certificate_unknown;case _.pki.certificateError.unknown_ca:return p.Alert.Description.unknown_ca;default:return p.Alert.Description.bad_certificate}},m0=function(e){switch(e){case!0:return!0;case p.Alert.Description.bad_certificate:return _.pki.certificateError.bad_certificate;case p.Alert.Description.unsupported_certificate:return _.pki.certificateError.unsupported_certificate;case p.Alert.Description.certificate_revoked:return _.pki.certificateError.certificate_revoked;case p.Alert.Description.certificate_expired:return _.pki.certificateError.certificate_expired;case p.Alert.Description.certificate_unknown:return _.pki.certificateError.certificate_unknown;case p.Alert.Description.unknown_ca:return _.pki.certificateError.unknown_ca;default:return _.pki.certificateError.bad_certificate}};p.verifyCertificateChain=function(e,t){try{var a={};for(var r in e.verifyOptions)a[r]=e.verifyOptions[r];a.verify=function(i,s,o){var u=da(i),l=e.verify(e,i,s,o);if(l!==!0){if(typeof l=="object"&&!_.util.isArray(l)){var c=new Error("The application rejected the certificate.");throw c.send=!0,c.alert={level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate},l.message&&(c.message=l.message),l.alert&&(c.alert.description=l.alert),c}l!==i&&(l=m0(l))}return l},_.pki.verifyCertificateChain(e.caStore,t,a)}catch(i){var n=i;(typeof n!="object"||_.util.isArray(n))&&(n={send:!0,alert:{level:p.Alert.Level.fatal,description:da(i)}}),"send"in n||(n.send=!0),"alert"in n||(n.alert={level:p.Alert.Level.fatal,description:da(n.error)}),e.error(e,n)}return!e.fail},p.createSessionCache=function(e,t){var a=null;if(e&&e.getSession&&e.setSession&&e.order)a=e;else{a={},a.cache=e||{},a.capacity=Math.max(t||100,1),a.order=[];for(var r in e)a.order.length<=t?a.order.push(r):delete e[r];a.getSession=function(n){var i=null,s=null;if(n?s=_.util.bytesToHex(n):a.order.length>0&&(s=a.order[0]),s!==null&&s in a.cache){i=a.cache[s],delete a.cache[s];for(var o in a.order)if(a.order[o]===s){a.order.splice(o,1);break}}return i},a.setSession=function(n,i){if(a.order.length===a.capacity){var s=a.order.shift();delete a.cache[s]}var s=_.util.bytesToHex(n);a.order.push(s),a.cache[s]=i}}return a},p.createConnection=function(e){var t=null;e.caStore?_.util.isArray(e.caStore)?t=_.pki.createCaStore(e.caStore):t=e.caStore:t=_.pki.createCaStore();var a=e.cipherSuites||null;if(a===null){a=[];for(var r in p.CipherSuites)a.push(p.CipherSuites[r])}var n=e.server?p.ConnectionEnd.server:p.ConnectionEnd.client,i=e.sessionCache?p.createSessionCache(e.sessionCache):null,s={version:{major:p.Version.major,minor:p.Version.minor},entity:n,sessionId:e.sessionId,caStore:t,sessionCache:i,cipherSuites:a,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(c,f,g,v){return f},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:_.util.createBuffer(),tlsData:_.util.createBuffer(),data:_.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(c,f){f.origin=f.origin||(c.entity===p.ConnectionEnd.client?"client":"server"),f.send&&(p.queue(c,p.createAlert(c,f.alert)),p.flush(c));var g=f.fatal!==!1;g&&(c.fail=!0),e.error(c,f),g&&c.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null};s.reset=function(c){s.version={major:p.Version.major,minor:p.Version.minor},s.record=null,s.session=null,s.peerCertificate=null,s.state={pending:null,current:null},s.expect=s.entity===p.ConnectionEnd.client?r0:u0,s.fragmented=null,s.records=[],s.open=!1,s.handshakes=0,s.handshaking=!1,s.isConnected=!1,s.fail=!(c||typeof c>"u"),s.input.clear(),s.tlsData.clear(),s.data.clear(),s.state.current=p.createConnectionState(s)},s.reset();var o=function(c,f){var g=f.type-p.ContentType.change_cipher_spec,v=ca[c.entity][c.expect];g in v?v[g](c,f):p.handleUnexpected(c,f)},u=function(c){var f=0,g=c.input,v=g.length();if(v<5)f=5-v;else{c.record={type:g.getByte(),version:{major:g.getByte(),minor:g.getByte()},length:g.getInt16(),fragment:_.util.createBuffer(),ready:!1};var y=c.record.version.major===c.version.major;y&&c.session&&c.session.version&&(y=c.record.version.minor===c.version.minor),y||c.error(c,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}})}return f},l=function(c){var f=0,g=c.input,v=g.length();if(v<c.record.length)f=c.record.length-v;else{c.record.fragment.putBytes(g.getBytes(c.record.length)),g.compact();var y=c.state.current.read;y.update(c,c.record)&&(c.fragmented!==null&&(c.fragmented.type===c.record.type?(c.fragmented.fragment.putBuffer(c.record.fragment),c.record=c.fragmented):c.error(c,{message:"Invalid fragmented record.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unexpected_message}})),c.record.ready=!0)}return f};return s.handshake=function(c){if(s.entity!==p.ConnectionEnd.client)s.error(s,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(s.handshaking)s.error(s,{message:"Handshake already in progress.",fatal:!1});else{s.fail&&!s.open&&s.handshakes===0&&(s.fail=!1),s.handshaking=!0,c=c||"";var f=null;c.length>0&&(s.sessionCache&&(f=s.sessionCache.getSession(c)),f===null&&(c="")),c.length===0&&s.sessionCache&&(f=s.sessionCache.getSession(),f!==null&&(c=f.id)),s.session={id:c,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:_.md.md5.create(),sha1:_.md.sha1.create()},f&&(s.version=f.version,s.session.sp=f.sp),s.session.sp.client_random=p.createRandom().getBytes(),s.open=!0,p.queue(s,p.createRecord(s,{type:p.ContentType.handshake,data:p.createClientHello(s)})),p.flush(s)}},s.process=function(c){var f=0;return c&&s.input.putBytes(c),s.fail||(s.record!==null&&s.record.ready&&s.record.fragment.isEmpty()&&(s.record=null),s.record===null&&(f=u(s)),!s.fail&&s.record!==null&&!s.record.ready&&(f=l(s)),!s.fail&&s.record!==null&&s.record.ready&&o(s,s.record)),f},s.prepare=function(c){return p.queue(s,p.createRecord(s,{type:p.ContentType.application_data,data:_.util.createBuffer(c)})),p.flush(s)},s.prepareHeartbeatRequest=function(c,f){return c instanceof _.util.ByteBuffer&&(c=c.bytes()),typeof f>"u"&&(f=c.length),s.expectedHeartbeatPayload=c,p.queue(s,p.createRecord(s,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_request,c,f)})),p.flush(s)},s.close=function(c){if(!s.fail&&s.sessionCache&&s.session){var f={id:s.session.id,version:s.session.version,sp:s.session.sp};f.sp.keys=null,s.sessionCache.setSession(f.id,f)}s.open&&(s.open=!1,s.input.clear(),(s.isConnected||s.handshaking)&&(s.isConnected=s.handshaking=!1,p.queue(s,p.createAlert(s,{level:p.Alert.Level.warning,description:p.Alert.Description.close_notify})),p.flush(s)),s.closed(s)),s.reset(c)},s},_.tls=_.tls||{};for(var ha in p)typeof p[ha]!="function"&&(_.tls[ha]=p[ha]);_.tls.prf_tls1=Nr,_.tls.hmac_sha1=Jo,_.tls.createSessionCache=p.createSessionCache,_.tls.createConnection=p.createConnection;var wt=j,nt=wt.tls;nt.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=nt.BulkCipherAlgorithm.aes,e.cipher_type=nt.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=nt.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:Rn},nt.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=nt.BulkCipherAlgorithm.aes,e.cipher_type=nt.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=nt.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:Rn};function Rn(e,t,a){var r=t.entity===wt.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:wt.cipher.createDecipher("AES-CBC",r?a.keys.server_write_key:a.keys.client_write_key),iv:r?a.keys.server_write_IV:a.keys.client_write_IV},e.write.cipherState={init:!1,cipher:wt.cipher.createCipher("AES-CBC",r?a.keys.client_write_key:a.keys.server_write_key),iv:r?a.keys.client_write_IV:a.keys.server_write_IV},e.read.cipherFunction=S0,e.write.cipherFunction=C0,e.read.macLength=e.write.macLength=a.mac_length,e.read.macFunction=e.write.macFunction=nt.hmac_sha1}function C0(e,t){var a=!1,r=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(r),t.updateSequenceNumber();var n;e.version.minor===nt.Versions.TLS_1_0.minor?n=t.cipherState.init?null:t.cipherState.iv:n=wt.random.getBytesSync(16),t.cipherState.init=!0;var i=t.cipherState.cipher;return i.start({iv:n}),e.version.minor>=nt.Versions.TLS_1_1.minor&&i.output.putBytes(n),i.update(e.fragment),i.finish(E0)&&(e.fragment=i.output,e.length=e.fragment.length(),a=!0),a}function E0(e,t,a){if(!a){var r=e-t.length()%e;t.fillWithByte(r-1,r)}return!0}function x0(e,t,a){var r=!0;if(a){for(var n=t.length(),i=t.last(),s=n-1-i;s<n-1;++s)r=r&&t.at(s)==i;r&&t.truncate(i+1)}return r}function S0(e,t){var a=!1,r;e.version.minor===nt.Versions.TLS_1_0.minor?r=t.cipherState.init?null:t.cipherState.iv:r=e.fragment.getBytes(16),t.cipherState.init=!0;var n=t.cipherState.cipher;n.start({iv:r}),n.update(e.fragment),a=n.finish(x0);var i=t.macLength,s=wt.random.getBytesSync(i),o=n.output.length();o>=i?(e.fragment=n.output.getBytes(o-i),s=n.output.getBytes(i)):e.fragment=n.output.getBytes(),e.fragment=wt.util.createBuffer(e.fragment),e.length=e.fragment.length();var u=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),a=T0(t.macKey,s,u)&&a,a}function T0(e,t,a){var r=wt.hmac.create();return r.start("SHA1",e),r.update(t),t=r.digest().getBytes(),r.start(null,null),r.update(a),a=r.digest().getBytes(),t===a}var pe=j,or=pe.sha512=pe.sha512||{};pe.md.sha512=pe.md.algorithms.sha512=or;var Ln=pe.sha384=pe.sha512.sha384=pe.sha512.sha384||{};Ln.create=function(){return or.create("SHA-384")},pe.md.sha384=pe.md.algorithms.sha384=Ln,pe.sha512.sha256=pe.sha512.sha256||{create:function(){return or.create("SHA-512/256")}},pe.md["sha512/256"]=pe.md.algorithms["sha512/256"]=pe.sha512.sha256,pe.sha512.sha224=pe.sha512.sha224||{create:function(){return or.create("SHA-512/224")}},pe.md["sha512/224"]=pe.md.algorithms["sha512/224"]=pe.sha512.sha224,or.create=function(e){if(kn||I0(),typeof e>"u"&&(e="SHA-512"),!(e in Ot))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=Ot[e],a=null,r=pe.util.createBuffer(),n=new Array(80),i=0;i<80;++i)n[i]=new Array(2);var s=64;switch(e){case"SHA-384":s=48;break;case"SHA-512/256":s=32;break;case"SHA-512/224":s=28;break}var o={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:s,messageLength:0,fullMessageLength:null,messageLengthSize:16};return o.start=function(){o.messageLength=0,o.fullMessageLength=o.messageLength128=[];for(var u=o.messageLengthSize/4,l=0;l<u;++l)o.fullMessageLength.push(0);r=pe.util.createBuffer(),a=new Array(t.length);for(var l=0;l<t.length;++l)a[l]=t[l].slice(0);return o},o.start(),o.update=function(u,l){l==="utf8"&&(u=pe.util.encodeUtf8(u));var c=u.length;o.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var f=o.fullMessageLength.length-1;f>=0;--f)o.fullMessageLength[f]+=c[1],c[1]=c[0]+(o.fullMessageLength[f]/4294967296>>>0),o.fullMessageLength[f]=o.fullMessageLength[f]>>>0,c[0]=c[1]/4294967296>>>0;return r.putBytes(u),Dn(a,n,r),(r.read>2048||r.length()===0)&&r.compact(),o},o.digest=function(){var u=pe.util.createBuffer();u.putBytes(r.bytes());var l=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize,c=l&o.blockLength-1;u.putBytes(pa.substr(0,o.blockLength-c));for(var f,g,v=o.fullMessageLength[0]*8,y=0;y<o.fullMessageLength.length-1;++y)f=o.fullMessageLength[y+1]*8,g=f/4294967296>>>0,v+=g,u.putInt32(v>>>0),v=f>>>0;u.putInt32(v);for(var x=new Array(a.length),y=0;y<a.length;++y)x[y]=a[y].slice(0);Dn(x,n,u);var S=pe.util.createBuffer(),I;e==="SHA-512"?I=x.length:e==="SHA-384"?I=x.length-2:I=x.length-4;for(var y=0;y<I;++y)S.putInt32(x[y][0]),(y!==I-1||e!=="SHA-512/224")&&S.putInt32(x[y][1]);return S},o};var pa=null,kn=!1,ga=null,Ot=null;function I0(){pa=String.fromCharCode(128),pa+=pe.util.fillString(String.fromCharCode(0),128),ga=[[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]],Ot={},Ot["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],Ot["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],Ot["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],Ot["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],kn=!0}function Dn(e,t,a){for(var r,n,i,s,o,u,l,c,f,g,v,y,x,S,I,A,B,P,L,R,q,Q,se,re,W,ge,qe,Ye,le,Ce,M,Et,gt,K,O,ue=a.length();ue>=128;){for(le=0;le<16;++le)t[le][0]=a.getInt32()>>>0,t[le][1]=a.getInt32()>>>0;for(;le<80;++le)Et=t[le-2],Ce=Et[0],M=Et[1],r=((Ce>>>19|M<<13)^(M>>>29|Ce<<3)^Ce>>>6)>>>0,n=((Ce<<13|M>>>19)^(M<<3|Ce>>>29)^(Ce<<26|M>>>6))>>>0,K=t[le-15],Ce=K[0],M=K[1],i=((Ce>>>1|M<<31)^(Ce>>>8|M<<24)^Ce>>>7)>>>0,s=((Ce<<31|M>>>1)^(Ce<<24|M>>>8)^(Ce<<25|M>>>7))>>>0,gt=t[le-7],O=t[le-16],M=n+gt[1]+s+O[1],t[le][0]=r+gt[0]+i+O[0]+(M/4294967296>>>0)>>>0,t[le][1]=M>>>0;for(x=e[0][0],S=e[0][1],I=e[1][0],A=e[1][1],B=e[2][0],P=e[2][1],L=e[3][0],R=e[3][1],q=e[4][0],Q=e[4][1],se=e[5][0],re=e[5][1],W=e[6][0],ge=e[6][1],qe=e[7][0],Ye=e[7][1],le=0;le<80;++le)l=((q>>>14|Q<<18)^(q>>>18|Q<<14)^(Q>>>9|q<<23))>>>0,c=((q<<18|Q>>>14)^(q<<14|Q>>>18)^(Q<<23|q>>>9))>>>0,f=(W^q&(se^W))>>>0,g=(ge^Q&(re^ge))>>>0,o=((x>>>28|S<<4)^(S>>>2|x<<30)^(S>>>7|x<<25))>>>0,u=((x<<4|S>>>28)^(S<<30|x>>>2)^(S<<25|x>>>7))>>>0,v=(x&I|B&(x^I))>>>0,y=(S&A|P&(S^A))>>>0,M=Ye+c+g+ga[le][1]+t[le][1],r=qe+l+f+ga[le][0]+t[le][0]+(M/4294967296>>>0)>>>0,n=M>>>0,M=u+y,i=o+v+(M/4294967296>>>0)>>>0,s=M>>>0,qe=W,Ye=ge,W=se,ge=re,se=q,re=Q,M=R+n,q=L+r+(M/4294967296>>>0)>>>0,Q=M>>>0,L=B,R=P,B=I,P=A,I=x,A=S,M=n+s,x=r+i+(M/4294967296>>>0)>>>0,S=M>>>0;M=e[0][1]+S,e[0][0]=e[0][0]+x+(M/4294967296>>>0)>>>0,e[0][1]=M>>>0,M=e[1][1]+A,e[1][0]=e[1][0]+I+(M/4294967296>>>0)>>>0,e[1][1]=M>>>0,M=e[2][1]+P,e[2][0]=e[2][0]+B+(M/4294967296>>>0)>>>0,e[2][1]=M>>>0,M=e[3][1]+R,e[3][0]=e[3][0]+L+(M/4294967296>>>0)>>>0,e[3][1]=M>>>0,M=e[4][1]+Q,e[4][0]=e[4][0]+q+(M/4294967296>>>0)>>>0,e[4][1]=M>>>0,M=e[5][1]+re,e[5][0]=e[5][0]+se+(M/4294967296>>>0)>>>0,e[5][1]=M>>>0,M=e[6][1]+ge,e[6][0]=e[6][0]+W+(M/4294967296>>>0)>>>0,e[6][1]=M>>>0,M=e[7][1]+Ye,e[7][0]=e[7][0]+qe+(M/4294967296>>>0)>>>0,e[7][1]=M>>>0,ue-=128}}var ya={},b0=j,Be=b0.asn1;ya.privateKeyValidator={name:"PrivateKeyInfo",tagClass:Be.Class.UNIVERSAL,type:Be.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Be.Class.UNIVERSAL,type:Be.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Be.Class.UNIVERSAL,type:Be.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Be.Class.UNIVERSAL,type:Be.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Be.Class.UNIVERSAL,type:Be.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},ya.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Be.Class.UNIVERSAL,type:Be.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Be.Class.UNIVERSAL,type:Be.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Be.Class.UNIVERSAL,type:Be.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:Be.Class.UNIVERSAL,type:Be.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]};var Re=j,Un=ya,A0=Un.publicKeyValidator,B0=Un.privateKeyValidator;if(typeof w0>"u")var w0=Re.jsbn.BigInteger;var va=Re.util.ByteBuffer,$e=typeof Buffer>"u"?Uint8Array:Buffer;Re.pki=Re.pki||{},Re.pki.ed25519=Re.ed25519=Re.ed25519||{};var J=Re.ed25519;J.constants={},J.constants.PUBLIC_KEY_BYTE_LENGTH=32,J.constants.PRIVATE_KEY_BYTE_LENGTH=64,J.constants.SEED_BYTE_LENGTH=32,J.constants.SIGN_BYTE_LENGTH=64,J.constants.HASH_BYTE_LENGTH=64,J.generateKeyPair=function(e){e=e||{};var t=e.seed;if(t===void 0)t=Re.random.getBytesSync(J.constants.SEED_BYTE_LENGTH);else if(typeof t=="string"){if(t.length!==J.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+J.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=Ct({message:t,encoding:"binary"});for(var a=new $e(J.constants.PUBLIC_KEY_BYTE_LENGTH),r=new $e(J.constants.PRIVATE_KEY_BYTE_LENGTH),n=0;n<32;++n)r[n]=t[n];return L0(a,r),{publicKey:a,privateKey:r}},J.privateKeyFromAsn1=function(e){var t={},a=[],r=Re.asn1.validate(e,B0,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var i=Re.asn1.derToOid(t.privateKeyOid),s=Re.oids.EdDSA25519;if(i!==s)throw new Error('Invalid OID "'+i+'"; OID must be "'+s+'".');var o=t.privateKey,u=Ct({message:Re.asn1.fromDer(o).value,encoding:"binary"});return{privateKeyBytes:u}},J.publicKeyFromAsn1=function(e){var t={},a=[],r=Re.asn1.validate(e,A0,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var i=Re.asn1.derToOid(t.publicKeyOid),s=Re.oids.EdDSA25519;if(i!==s)throw new Error('Invalid OID "'+i+'"; OID must be "'+s+'".');var o=t.ed25519PublicKey;if(o.length!==J.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return Ct({message:o,encoding:"binary"})},J.publicKeyFromPrivateKey=function(e){e=e||{};var t=Ct({message:e.privateKey,encoding:"binary"});if(t.length!==J.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+J.constants.PRIVATE_KEY_BYTE_LENGTH);for(var a=new $e(J.constants.PUBLIC_KEY_BYTE_LENGTH),r=0;r<a.length;++r)a[r]=t[32+r];return a},J.sign=function(e){e=e||{};var t=Ct(e),a=Ct({message:e.privateKey,encoding:"binary"});if(a.length===J.constants.SEED_BYTE_LENGTH){var r=J.generateKeyPair({seed:a});a=r.privateKey}else if(a.length!==J.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+J.constants.SEED_BYTE_LENGTH+" or "+J.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new $e(J.constants.SIGN_BYTE_LENGTH+t.length);k0(n,t,t.length,a);for(var i=new $e(J.constants.SIGN_BYTE_LENGTH),s=0;s<i.length;++s)i[s]=n[s];return i},J.verify=function(e){e=e||{};var t=Ct(e);if(e.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var a=Ct({message:e.signature,encoding:"binary"});if(a.length!==J.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+J.constants.SIGN_BYTE_LENGTH);var r=Ct({message:e.publicKey,encoding:"binary"});if(r.length!==J.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+J.constants.PUBLIC_KEY_BYTE_LENGTH);var n=new $e(J.constants.SIGN_BYTE_LENGTH+t.length),i=new $e(J.constants.SIGN_BYTE_LENGTH+t.length),s;for(s=0;s<J.constants.SIGN_BYTE_LENGTH;++s)n[s]=a[s];for(s=0;s<t.length;++s)n[s+J.constants.SIGN_BYTE_LENGTH]=t[s];return D0(i,n,n.length,r)>=0};function Ct(e){var t=e.message;if(t instanceof Uint8Array||t instanceof $e)return t;var a=e.encoding;if(t===void 0)if(e.md)t=e.md.digest().getBytes(),a="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof t=="string"&&!a)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof t=="string"){if(typeof Buffer<"u")return Buffer.from(t,a);t=new va(t,a)}else if(!(t instanceof va))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.');for(var r=new $e(t.length()),n=0;n<r.length;++n)r[n]=t.at(n);return r}var ma=z(),kr=z([1]),_0=z([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),N0=z([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Pn=z([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Vn=z([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Ca=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]),R0=z([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function lr(e,t){var a=Re.md.sha512.create(),r=new va(e);a.update(r.getBytes(t),"binary");var n=a.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(n,"binary");for(var i=new $e(J.constants.HASH_BYTE_LENGTH),s=0;s<64;++s)i[s]=n.charCodeAt(s);return i}function L0(e,t){var a=[z(),z(),z(),z()],r,n=lr(t,32);for(n[0]&=248,n[31]&=127,n[31]|=64,Ta(a,n),Sa(e,a),r=0;r<32;++r)t[r+32]=e[r];return 0}function k0(e,t,a,r){var n,i,s=new Float64Array(64),o=[z(),z(),z(),z()],u=lr(r,32);u[0]&=248,u[31]&=127,u[31]|=64;var l=a+64;for(n=0;n<a;++n)e[64+n]=t[n];for(n=0;n<32;++n)e[32+n]=u[32+n];var c=lr(e.subarray(32),a+32);for(Ea(c),Ta(o,c),Sa(e,o),n=32;n<64;++n)e[n]=r[n];var f=lr(e,a+64);for(Ea(f),n=32;n<64;++n)s[n]=0;for(n=0;n<32;++n)s[n]=c[n];for(n=0;n<32;++n)for(i=0;i<32;i++)s[n+i]+=f[n]*u[i];return On(e.subarray(32),s),l}function D0(e,t,a,r){var n,i,s=new $e(32),o=[z(),z(),z(),z()],u=[z(),z(),z(),z()];if(i=-1,a<64||U0(u,r))return-1;for(n=0;n<a;++n)e[n]=t[n];for(n=0;n<32;++n)e[n+32]=r[n];var l=lr(e,a);if(Ea(l),Gn(o,u,l),Ta(u,t.subarray(32)),xa(o,u),Sa(s,o),a-=64,Mn(t,0,s,0)){for(n=0;n<a;++n)e[n]=0;return-1}for(n=0;n<a;++n)e[n]=t[n+64];return i=a,i}function On(e,t){var a,r,n,i;for(r=63;r>=32;--r){for(a=0,n=r-32,i=r-12;n<i;++n)t[n]+=a-16*t[r]*Ca[n-(r-32)],a=t[n]+128>>8,t[n]-=a*256;t[n]+=a,t[r]=0}for(a=0,n=0;n<32;++n)t[n]+=a-(t[31]>>4)*Ca[n],a=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=a*Ca[n];for(r=0;r<32;++r)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function Ea(e){for(var t=new Float64Array(64),a=0;a<64;++a)t[a]=e[a],e[a]=0;On(e,t)}function xa(e,t){var a=z(),r=z(),n=z(),i=z(),s=z(),o=z(),u=z(),l=z(),c=z();Xt(a,e[1],e[0]),Xt(c,t[1],t[0]),ce(a,a,c),jt(r,e[0],e[1]),jt(c,t[0],t[1]),ce(r,r,c),ce(n,e[3],t[3]),ce(n,n,N0),ce(i,e[2],t[2]),jt(i,i,i),Xt(s,r,a),Xt(o,i,n),jt(u,i,n),jt(l,r,a),ce(e[0],s,o),ce(e[1],l,u),ce(e[2],u,o),ce(e[3],s,l)}function Fn(e,t,a){for(var r=0;r<4;++r)zn(e[r],t[r],a)}function Sa(e,t){var a=z(),r=z(),n=z();F0(n,t[2]),ce(a,t[0],n),ce(r,t[1],n),Dr(e,r),e[31]^=Hn(a)<<7}function Dr(e,t){var a,r,n,i=z(),s=z();for(a=0;a<16;++a)s[a]=t[a];for(Ia(s),Ia(s),Ia(s),r=0;r<2;++r){for(i[0]=s[0]-65517,a=1;a<15;++a)i[a]=s[a]-65535-(i[a-1]>>16&1),i[a-1]&=65535;i[15]=s[15]-32767-(i[14]>>16&1),n=i[15]>>16&1,i[14]&=65535,zn(s,i,1-n)}for(a=0;a<16;a++)e[2*a]=s[a]&255,e[2*a+1]=s[a]>>8}function U0(e,t){var a=z(),r=z(),n=z(),i=z(),s=z(),o=z(),u=z();return _t(e[2],kr),P0(e[1],t),Ft(n,e[1]),ce(i,n,_0),Xt(n,n,e[2]),jt(i,e[2],i),Ft(s,i),Ft(o,s),ce(u,o,s),ce(a,u,n),ce(a,a,i),V0(a,a),ce(a,a,n),ce(a,a,i),ce(a,a,i),ce(e[0],a,i),Ft(r,e[0]),ce(r,r,i),Kn(r,n)&&ce(e[0],e[0],R0),Ft(r,e[0]),ce(r,r,i),Kn(r,n)?-1:(Hn(e[0])===t[31]>>7&&Xt(e[0],ma,e[0]),ce(e[3],e[0],e[1]),0)}function P0(e,t){var a;for(a=0;a<16;++a)e[a]=t[2*a]+(t[2*a+1]<<8);e[15]&=32767}function V0(e,t){var a=z(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=250;r>=0;--r)Ft(a,a),r!==1&&ce(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function Kn(e,t){var a=new $e(32),r=new $e(32);return Dr(a,e),Dr(r,t),Mn(a,0,r,0)}function Mn(e,t,a,r){return O0(e,t,a,r,32)}function O0(e,t,a,r,n){var i,s=0;for(i=0;i<n;++i)s|=e[t+i]^a[r+i];return(1&s-1>>>8)-1}function Hn(e){var t=new $e(32);return Dr(t,e),t[0]&1}function Gn(e,t,a){var r,n;for(_t(e[0],ma),_t(e[1],kr),_t(e[2],kr),_t(e[3],ma),n=255;n>=0;--n)r=a[n/8|0]>>(n&7)&1,Fn(e,t,r),xa(t,e),xa(e,e),Fn(e,t,r)}function Ta(e,t){var a=[z(),z(),z(),z()];_t(a[0],Pn),_t(a[1],Vn),_t(a[2],kr),ce(a[3],Pn,Vn),Gn(e,a,t)}function _t(e,t){var a;for(a=0;a<16;a++)e[a]=t[a]|0}function F0(e,t){var a=z(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=253;r>=0;--r)Ft(a,a),r!==2&&r!==4&&ce(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function Ia(e){var t,a,r=1;for(t=0;t<16;++t)a=e[t]+r+65535,r=Math.floor(a/65536),e[t]=a-r*65536;e[0]+=r-1+37*(r-1)}function zn(e,t,a){for(var r,n=~(a-1),i=0;i<16;++i)r=n&(e[i]^t[i]),e[i]^=r,t[i]^=r}function z(e){var t,a=new Float64Array(16);if(e)for(t=0;t<e.length;++t)a[t]=e[t];return a}function jt(e,t,a){for(var r=0;r<16;++r)e[r]=t[r]+a[r]}function Xt(e,t,a){for(var r=0;r<16;++r)e[r]=t[r]-a[r]}function Ft(e,t){ce(e,t,t)}function ce(e,t,a){var r,n,i=0,s=0,o=0,u=0,l=0,c=0,f=0,g=0,v=0,y=0,x=0,S=0,I=0,A=0,B=0,P=0,L=0,R=0,q=0,Q=0,se=0,re=0,W=0,ge=0,qe=0,Ye=0,le=0,Ce=0,M=0,Et=0,gt=0,K=a[0],O=a[1],ue=a[2],te=a[3],ve=a[4],Te=a[5],Ee=a[6],Le=a[7],ke=a[8],De=a[9],Ue=a[10],Pe=a[11],Ve=a[12],Oe=a[13],Fe=a[14],Ke=a[15];r=t[0],i+=r*K,s+=r*O,o+=r*ue,u+=r*te,l+=r*ve,c+=r*Te,f+=r*Ee,g+=r*Le,v+=r*ke,y+=r*De,x+=r*Ue,S+=r*Pe,I+=r*Ve,A+=r*Oe,B+=r*Fe,P+=r*Ke,r=t[1],s+=r*K,o+=r*O,u+=r*ue,l+=r*te,c+=r*ve,f+=r*Te,g+=r*Ee,v+=r*Le,y+=r*ke,x+=r*De,S+=r*Ue,I+=r*Pe,A+=r*Ve,B+=r*Oe,P+=r*Fe,L+=r*Ke,r=t[2],o+=r*K,u+=r*O,l+=r*ue,c+=r*te,f+=r*ve,g+=r*Te,v+=r*Ee,y+=r*Le,x+=r*ke,S+=r*De,I+=r*Ue,A+=r*Pe,B+=r*Ve,P+=r*Oe,L+=r*Fe,R+=r*Ke,r=t[3],u+=r*K,l+=r*O,c+=r*ue,f+=r*te,g+=r*ve,v+=r*Te,y+=r*Ee,x+=r*Le,S+=r*ke,I+=r*De,A+=r*Ue,B+=r*Pe,P+=r*Ve,L+=r*Oe,R+=r*Fe,q+=r*Ke,r=t[4],l+=r*K,c+=r*O,f+=r*ue,g+=r*te,v+=r*ve,y+=r*Te,x+=r*Ee,S+=r*Le,I+=r*ke,A+=r*De,B+=r*Ue,P+=r*Pe,L+=r*Ve,R+=r*Oe,q+=r*Fe,Q+=r*Ke,r=t[5],c+=r*K,f+=r*O,g+=r*ue,v+=r*te,y+=r*ve,x+=r*Te,S+=r*Ee,I+=r*Le,A+=r*ke,B+=r*De,P+=r*Ue,L+=r*Pe,R+=r*Ve,q+=r*Oe,Q+=r*Fe,se+=r*Ke,r=t[6],f+=r*K,g+=r*O,v+=r*ue,y+=r*te,x+=r*ve,S+=r*Te,I+=r*Ee,A+=r*Le,B+=r*ke,P+=r*De,L+=r*Ue,R+=r*Pe,q+=r*Ve,Q+=r*Oe,se+=r*Fe,re+=r*Ke,r=t[7],g+=r*K,v+=r*O,y+=r*ue,x+=r*te,S+=r*ve,I+=r*Te,A+=r*Ee,B+=r*Le,P+=r*ke,L+=r*De,R+=r*Ue,q+=r*Pe,Q+=r*Ve,se+=r*Oe,re+=r*Fe,W+=r*Ke,r=t[8],v+=r*K,y+=r*O,x+=r*ue,S+=r*te,I+=r*ve,A+=r*Te,B+=r*Ee,P+=r*Le,L+=r*ke,R+=r*De,q+=r*Ue,Q+=r*Pe,se+=r*Ve,re+=r*Oe,W+=r*Fe,ge+=r*Ke,r=t[9],y+=r*K,x+=r*O,S+=r*ue,I+=r*te,A+=r*ve,B+=r*Te,P+=r*Ee,L+=r*Le,R+=r*ke,q+=r*De,Q+=r*Ue,se+=r*Pe,re+=r*Ve,W+=r*Oe,ge+=r*Fe,qe+=r*Ke,r=t[10],x+=r*K,S+=r*O,I+=r*ue,A+=r*te,B+=r*ve,P+=r*Te,L+=r*Ee,R+=r*Le,q+=r*ke,Q+=r*De,se+=r*Ue,re+=r*Pe,W+=r*Ve,ge+=r*Oe,qe+=r*Fe,Ye+=r*Ke,r=t[11],S+=r*K,I+=r*O,A+=r*ue,B+=r*te,P+=r*ve,L+=r*Te,R+=r*Ee,q+=r*Le,Q+=r*ke,se+=r*De,re+=r*Ue,W+=r*Pe,ge+=r*Ve,qe+=r*Oe,Ye+=r*Fe,le+=r*Ke,r=t[12],I+=r*K,A+=r*O,B+=r*ue,P+=r*te,L+=r*ve,R+=r*Te,q+=r*Ee,Q+=r*Le,se+=r*ke,re+=r*De,W+=r*Ue,ge+=r*Pe,qe+=r*Ve,Ye+=r*Oe,le+=r*Fe,Ce+=r*Ke,r=t[13],A+=r*K,B+=r*O,P+=r*ue,L+=r*te,R+=r*ve,q+=r*Te,Q+=r*Ee,se+=r*Le,re+=r*ke,W+=r*De,ge+=r*Ue,qe+=r*Pe,Ye+=r*Ve,le+=r*Oe,Ce+=r*Fe,M+=r*Ke,r=t[14],B+=r*K,P+=r*O,L+=r*ue,R+=r*te,q+=r*ve,Q+=r*Te,se+=r*Ee,re+=r*Le,W+=r*ke,ge+=r*De,qe+=r*Ue,Ye+=r*Pe,le+=r*Ve,Ce+=r*Oe,M+=r*Fe,Et+=r*Ke,r=t[15],P+=r*K,L+=r*O,R+=r*ue,q+=r*te,Q+=r*ve,se+=r*Te,re+=r*Ee,W+=r*Le,ge+=r*ke,qe+=r*De,Ye+=r*Ue,le+=r*Pe,Ce+=r*Ve,M+=r*Oe,Et+=r*Fe,gt+=r*Ke,i+=38*L,s+=38*R,o+=38*q,u+=38*Q,l+=38*se,c+=38*re,f+=38*W,g+=38*ge,v+=38*qe,y+=38*Ye,x+=38*le,S+=38*Ce,I+=38*M,A+=38*Et,B+=38*gt,n=1,r=i+n+65535,n=Math.floor(r/65536),i=r-n*65536,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=v+n+65535,n=Math.floor(r/65536),v=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=x+n+65535,n=Math.floor(r/65536),x=r-n*65536,r=S+n+65535,n=Math.floor(r/65536),S=r-n*65536,r=I+n+65535,n=Math.floor(r/65536),I=r-n*65536,r=A+n+65535,n=Math.floor(r/65536),A=r-n*65536,r=B+n+65535,n=Math.floor(r/65536),B=r-n*65536,r=P+n+65535,n=Math.floor(r/65536),P=r-n*65536,i+=n-1+37*(n-1),n=1,r=i+n+65535,n=Math.floor(r/65536),i=r-n*65536,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=v+n+65535,n=Math.floor(r/65536),v=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=x+n+65535,n=Math.floor(r/65536),x=r-n*65536,r=S+n+65535,n=Math.floor(r/65536),S=r-n*65536,r=I+n+65535,n=Math.floor(r/65536),I=r-n*65536,r=A+n+65535,n=Math.floor(r/65536),A=r-n*65536,r=B+n+65535,n=Math.floor(r/65536),B=r-n*65536,r=P+n+65535,n=Math.floor(r/65536),P=r-n*65536,i+=n-1+37*(n-1),e[0]=i,e[1]=s,e[2]=o,e[3]=u,e[4]=l,e[5]=c,e[6]=f,e[7]=g,e[8]=v,e[9]=y,e[10]=x,e[11]=S,e[12]=I,e[13]=A,e[14]=B,e[15]=P}var Ze=j;Ze.kem=Ze.kem||{};var qn=Ze.jsbn.BigInteger;Ze.kem.rsa={},Ze.kem.rsa.create=function(e,t){t=t||{};var a=t.prng||Ze.random,r={};return r.encrypt=function(n,i){var s=Math.ceil(n.n.bitLength()/8),o;do o=new qn(Ze.util.bytesToHex(a.getBytesSync(s)),16).mod(n.n);while(o.compareTo(qn.ONE)<=0);o=Ze.util.hexToBytes(o.toString(16));var u=s-o.length;u>0&&(o=Ze.util.fillString(String.fromCharCode(0),u)+o);var l=n.encrypt(o,"NONE"),c=e.generate(o,i);return{encapsulation:l,key:c}},r.decrypt=function(n,i,s){var o=n.decrypt(i,"NONE");return e.generate(o,s)},r},Ze.kem.kdf1=function(e,t){Qn(this,e,0,t||e.digestLength)},Ze.kem.kdf2=function(e,t){Qn(this,e,1,t||e.digestLength)};function Qn(e,t,a,r){e.generate=function(n,i){for(var s=new Ze.util.ByteBuffer,o=Math.ceil(i/r)+a,u=new Ze.util.ByteBuffer,l=a;l<o;++l){u.putInt32(l),t.start(),t.update(n+u.getBytes());var c=t.digest();s.putBytes(c.getBytes(r))}return s.truncate(s.length()-i),s.getBytes()}}var ee=j;ee.log=ee.log||{},ee.log.levels=["none","error","warning","info","debug","verbose","max"];var Ur={},ba=[],ur=null;ee.log.LEVEL_LOCKED=2,ee.log.NO_LEVEL_CHECK=4,ee.log.INTERPOLATE=8;for(var Nt=0;Nt<ee.log.levels.length;++Nt){var Wn=ee.log.levels[Nt];Ur[Wn]={index:Nt,name:Wn.toUpperCase()}}ee.log.logMessage=function(e){for(var t=Ur[e.level].index,a=0;a<ba.length;++a){var r=ba[a];if(r.flags&ee.log.NO_LEVEL_CHECK)r.f(e);else{var n=Ur[r.level].index;t<=n&&r.f(r,e)}}},ee.log.prepareStandard=function(e){"standard"in e||(e.standard=Ur[e.level].name+" ["+e.category+"] "+e.message)},ee.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]),e.full=ee.util.format.apply(this,t)}},ee.log.prepareStandardFull=function(e){"standardFull"in e||(ee.log.prepareStandard(e),e.standardFull=e.standard)};for(var $n=["error","warning","info","debug","verbose"],Nt=0;Nt<$n.length;++Nt)(function(t){ee.log[t]=function(a,r){var n=Array.prototype.slice.call(arguments).slice(2),i={timestamp:new Date,level:t,category:a,message:r,arguments:n};ee.log.logMessage(i)}})($n[Nt]);if(ee.log.makeLogger=function(e){var t={flags:0,f:e};return ee.log.setLevel(t,"none"),t},ee.log.setLevel=function(e,t){var a=!1;if(e&&!(e.flags&ee.log.LEVEL_LOCKED))for(var r=0;r<ee.log.levels.length;++r){var n=ee.log.levels[r];if(t==n){e.level=t,a=!0;break}}return a},ee.log.lock=function(e,t){typeof t>"u"||t?e.flags|=ee.log.LEVEL_LOCKED:e.flags&=~ee.log.LEVEL_LOCKED},ee.log.addLogger=function(e){ba.push(e)},typeof console<"u"&&"log"in console){var cr;if(console.error&&console.warn&&console.info&&console.debug){var K0={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},Aa=function(e,t){ee.log.prepareStandard(t);var a=K0[t.level],r=[t.standard];r=r.concat(t.arguments.slice()),a.apply(console,r)};cr=ee.log.makeLogger(Aa)}else{var Aa=function(t,a){ee.log.prepareStandardFull(a),console.log(a.standardFull)};cr=ee.log.makeLogger(Aa)}ee.log.setLevel(cr,"debug"),ee.log.addLogger(cr),ur=cr}else console={log:function(){}};if(ur!==null&&typeof window<"u"&&window.location){var Pr=new URL(window.location.href).searchParams;if(Pr.has("console.level")&&ee.log.setLevel(ur,Pr.get("console.level").slice(-1)[0]),Pr.has("console.lock")){var M0=Pr.get("console.lock").slice(-1)[0];M0=="true"&&ee.log.lock(ur)}}ee.log.consoleLogger=ur;var D=j,C=D.asn1,ze=D.pkcs7=D.pkcs7||{};ze.messageFromPem=function(e){var t=D.pem.decode(e)[0];if(t.type!=="PKCS7"){var a=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var r=C.fromDer(t.body);return ze.messageFromAsn1(r)},ze.messageToPem=function(e,t){var a={type:"PKCS7",body:C.toDer(e.toAsn1()).getBytes()};return D.pem.encode(a,{maxline:t})},ze.messageFromAsn1=function(e){var t={},a=[];if(!C.validate(e,ze.asn1.contentInfoValidator,t,a)){var r=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw r.errors=a,r}var n=C.derToOid(t.contentType),i;switch(n){case D.pki.oids.envelopedData:i=ze.createEnvelopedData();break;case D.pki.oids.encryptedData:i=ze.createEncryptedData();break;case D.pki.oids.signedData:i=ze.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+n+" is not (yet) supported.")}return i.fromAsn1(t.content.value[0]),i},ze.createSignedData=function(){var e=null;return e={type:D.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(r){if(wa(e,r,ze.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,i=0;i<n.length;++i)e.certificates.push(D.pki.certificateFromAsn1(n[i]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(D.pki.certificateToAsn1(e.certificates[n]));var i=[],s=C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&s.value[0].value.push(C.create(C.Class.CONTEXT_SPECIFIC,0,!0,r)),i.length>0&&s.value[0].value.push(C.create(C.Class.CONTEXT_SPECIFIC,1,!0,i)),s.value[0].value.push(C.create(C.Class.UNIVERSAL,C.Type.SET,!0,e.signerInfos)),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),s])},addSigner:function(r){var n=r.issuer,i=r.serialNumber;if(r.certificate){var s=r.certificate;typeof s=="string"&&(s=D.pki.certificateFromPem(s)),n=s.issuer.attributes,i=s.serialNumber}var o=r.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof o=="string"&&(o=D.pki.privateKeyFromPem(o));var u=r.digestAlgorithm||D.pki.oids.sha1;switch(u){case D.pki.oids.sha1:case D.pki.oids.sha256:case D.pki.oids.sha384:case D.pki.oids.sha512:case D.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+u)}var l=r.authenticatedAttributes||[];if(l.length>0){for(var c=!1,f=!1,g=0;g<l.length;++g){var v=l[g];if(!c&&v.type===D.pki.oids.contentType){if(c=!0,f)break;continue}if(!f&&v.type===D.pki.oids.messageDigest){if(f=!0,c)break;continue}}if(!c||!f)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.")}e.signers.push({key:o,version:1,issuer:n,serialNumber:i,digestAlgorithm:u,signatureAlgorithm:D.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:l,unauthenticatedAttributes:[]})},sign:function(r){if(r=r||{},(typeof e.content!="object"||e.contentInfo===null)&&(e.contentInfo=C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(D.pki.oids.data).getBytes())]),"content"in e)){var n;e.content instanceof D.util.ByteBuffer?n=e.content.bytes():typeof e.content=="string"&&(n=D.util.encodeUtf8(e.content)),r.detached?e.detachedContent=C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,n)]))}if(e.signers.length!==0){var i=t();a(i)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(r){typeof r=="string"&&(r=D.pki.certificateFromPem(r)),e.certificates.push(r)},addCertificateRevokationList:function(r){throw new Error("PKCS#7 CRL support not yet implemented.")}},e;function t(){for(var r={},n=0;n<e.signers.length;++n){var i=e.signers[n],s=i.digestAlgorithm;s in r||(r[s]=D.md[D.pki.oids[s]].create()),i.authenticatedAttributes.length===0?i.md=r[s]:i.md=D.md[D.pki.oids[s]].create()}e.digestAlgorithmIdentifiers=[];for(var s in r)e.digestAlgorithmIdentifiers.push(C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(s).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")]));return r}function a(r){var n;if(e.detachedContent?n=e.detachedContent:(n=e.contentInfo.value[1],n=n.value[0]),!n)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var i=C.derToOid(e.contentInfo.value[0].value),s=C.toDer(n);s.getByte(),C.getBerValueLength(s),s=s.getBytes();for(var o in r)r[o].start().update(s);for(var u=new Date,l=0;l<e.signers.length;++l){var c=e.signers[l];if(c.authenticatedAttributes.length===0){if(i!==D.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{c.authenticatedAttributesAsn1=C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=C.create(C.Class.UNIVERSAL,C.Type.SET,!0,[]),g=0;g<c.authenticatedAttributes.length;++g){var v=c.authenticatedAttributes[g];v.type===D.pki.oids.messageDigest?v.value=r[c.digestAlgorithm].digest():v.type===D.pki.oids.signingTime&&(v.value||(v.value=u)),f.value.push(Ba(v)),c.authenticatedAttributesAsn1.value.push(Ba(v))}s=C.toDer(f).getBytes(),c.md.start().update(s)}c.signature=c.key.sign(c.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=W0(e.signers)}},ze.createEncryptedData=function(){var e=null;return e={type:D.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:D.pki.oids["aes256-CBC"]},fromAsn1:function(t){wa(e,t,ze.asn1.encryptedDataValidator)},decrypt:function(t){t!==void 0&&(e.encryptedContent.key=t),Yn(e)}},e},ze.createEnvelopedData=function(){var e=null;return e={type:D.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:D.pki.oids["aes256-CBC"]},fromAsn1:function(t){var a=wa(e,t,ze.asn1.envelopedDataValidator);e.recipients=z0(a.recipientInfos.value)},toAsn1:function(){return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,q0(e.recipients)),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,$0(e.encryptedContent))])])])},findRecipient:function(t){for(var a=t.issuer.attributes,r=0;r<e.recipients.length;++r){var n=e.recipients[r],i=n.issuer;if(n.serialNumber===t.serialNumber&&i.length===a.length){for(var s=!0,o=0;o<a.length;++o)if(i[o].type!==a[o].type||i[o].value!==a[o].value){s=!1;break}if(s)return n}}return null},decrypt:function(t,a){if(e.encryptedContent.key===void 0&&t!==void 0&&a!==void 0)switch(t.encryptedContent.algorithm){case D.pki.oids.rsaEncryption:case D.pki.oids.desCBC:var r=a.decrypt(t.encryptedContent.content);e.encryptedContent.key=D.util.createBuffer(r);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}Yn(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:D.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,a){if(e.encryptedContent.content===void 0){a=a||e.encryptedContent.algorithm,t=t||e.encryptedContent.key;var r,n,i;switch(a){case D.pki.oids["aes128-CBC"]:r=16,n=16,i=D.aes.createEncryptionCipher;break;case D.pki.oids["aes192-CBC"]:r=24,n=16,i=D.aes.createEncryptionCipher;break;case D.pki.oids["aes256-CBC"]:r=32,n=16,i=D.aes.createEncryptionCipher;break;case D.pki.oids["des-EDE3-CBC"]:r=24,n=8,i=D.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+a)}if(t===void 0)t=D.util.createBuffer(D.random.getBytes(r));else if(t.length()!=r)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+r+".");e.encryptedContent.algorithm=a,e.encryptedContent.key=t,e.encryptedContent.parameter=D.util.createBuffer(D.random.getBytes(n));var s=i(t);if(s.start(e.encryptedContent.parameter.copy()),s.update(e.content),!s.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=s.output}for(var o=0;o<e.recipients.length;++o){var u=e.recipients[o];if(u.encryptedContent.content===void 0)switch(u.encryptedContent.algorithm){case D.pki.oids.rsaEncryption:u.encryptedContent.content=u.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+u.encryptedContent.algorithm)}}}},e};function H0(e){var t={},a=[];if(!C.validate(e,ze.asn1.recipientInfoValidator,t,a)){var r=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw r.errors=a,r}return{version:t.version.charCodeAt(0),issuer:D.pki.RDNAttributesAsArray(t.issuer),serialNumber:D.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:C.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function G0(e){return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[D.pki.distinguishedNameToAsn1({attributes:e.issuer}),C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,D.util.hexToBytes(e.serialNumber))]),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.encryptedContent.algorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")]),C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function z0(e){for(var t=[],a=0;a<e.length;++a)t.push(H0(e[a]));return t}function q0(e){for(var t=[],a=0;a<e.length;++a)t.push(G0(e[a]));return t}function Q0(e){var t=C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[D.pki.distinguishedNameToAsn1({attributes:e.issuer}),C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,D.util.hexToBytes(e.serialNumber))]),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.digestAlgorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.signatureAlgorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")])),t.value.push(C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var a=C.create(C.Class.CONTEXT_SPECIFIC,1,!0,[]),r=0;r<e.unauthenticatedAttributes.length;++r){var n=e.unauthenticatedAttributes[r];a.values.push(Ba(n))}t.value.push(a)}return t}function W0(e){for(var t=[],a=0;a<e.length;++a)t.push(Q0(e[a]));return t}function Ba(e){var t;if(e.type===D.pki.oids.contentType)t=C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.value).getBytes());else if(e.type===D.pki.oids.messageDigest)t=C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===D.pki.oids.signingTime){var a=new Date("1950-01-01T00:00:00Z"),r=new Date("2050-01-01T00:00:00Z"),n=e.value;if(typeof n=="string"){var i=Date.parse(n);isNaN(i)?n.length===13?n=C.utcTimeToDate(n):n=C.generalizedTimeToDate(n):n=new Date(i)}n>=a&&n<r?t=C.create(C.Class.UNIVERSAL,C.Type.UTCTIME,!1,C.dateToUtcTime(n)):t=C.create(C.Class.UNIVERSAL,C.Type.GENERALIZEDTIME,!1,C.dateToGeneralizedTime(n))}return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,[t])])}function $0(e){return[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(D.pki.oids.data).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.algorithm).getBytes()),e.parameter?C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.parameter.getBytes()):void 0]),C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.content.getBytes())])]}function wa(e,t,a){var r={},n=[];if(!C.validate(t,a,r,n)){var i=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw i.errors=i,i}var s=C.derToOid(r.contentType);if(s!==D.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(r.encryptedContent){var o="";if(D.util.isArray(r.encryptedContent))for(var u=0;u<r.encryptedContent.length;++u){if(r.encryptedContent[u].type!==C.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=r.encryptedContent[u].value}else o=r.encryptedContent;e.encryptedContent={algorithm:C.derToOid(r.encAlgorithm),parameter:D.util.createBuffer(r.encParameter.value),content:D.util.createBuffer(o)}}if(r.content){var o="";if(D.util.isArray(r.content))for(var u=0;u<r.content.length;++u){if(r.content[u].type!==C.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=r.content[u].value}else o=r.content;e.content=D.util.createBuffer(o)}return e.version=r.version.charCodeAt(0),e.rawCapture=r,r}function Yn(e){if(e.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(e.content===void 0){var t;switch(e.encryptedContent.algorithm){case D.pki.oids["aes128-CBC"]:case D.pki.oids["aes192-CBC"]:case D.pki.oids["aes256-CBC"]:t=D.aes.createDecryptionCipher(e.encryptedContent.key);break;case D.pki.oids.desCBC:case D.pki.oids["des-EDE3-CBC"]:t=D.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}var Se=j,Vr=Se.ssh=Se.ssh||{};Vr.privateKeyToPutty=function(e,t,a){a=a||"",t=t||"";var r="ssh-rsa",n=t===""?"none":"aes256-cbc",i="PuTTY-User-Key-File-2: "+r+`\r
`;i+="Encryption: "+n+`\r
`,i+="Comment: "+a+`\r
`;var s=Se.util.createBuffer();Zt(s,r),pt(s,e.e),pt(s,e.n);var o=Se.util.encode64(s.bytes(),64),u=Math.floor(o.length/66)+1;i+="Public-Lines: "+u+`\r
`,i+=o;var l=Se.util.createBuffer();pt(l,e.d),pt(l,e.p),pt(l,e.q),pt(l,e.qInv);var c;if(!t)c=Se.util.encode64(l.bytes(),64);else{var f=l.length()+16-1;f-=f%16;var g=Or(l.bytes());g.truncate(g.length()-f+l.length()),l.putBuffer(g);var v=Se.util.createBuffer();v.putBuffer(Or("\0\0\0\0",t)),v.putBuffer(Or("\0\0\0",t));var y=Se.aes.createEncryptionCipher(v.truncate(8),"CBC");y.start(Se.util.createBuffer().fillWithByte(0,16)),y.update(l.copy()),y.finish();var x=y.output;x.truncate(16),c=Se.util.encode64(x.bytes(),64)}u=Math.floor(c.length/66)+1,i+=`\r
Private-Lines: `+u+`\r
`,i+=c;var S=Or("putty-private-key-file-mac-key",t),I=Se.util.createBuffer();Zt(I,r),Zt(I,n),Zt(I,a),I.putInt32(s.length()),I.putBuffer(s),I.putInt32(l.length()),I.putBuffer(l);var A=Se.hmac.create();return A.start("sha1",S),A.update(I.bytes()),i+=`\r
Private-MAC: `+A.digest().toHex()+`\r
`,i},Vr.publicKeyToOpenSSH=function(e,t){var a="ssh-rsa";t=t||"";var r=Se.util.createBuffer();return Zt(r,a),pt(r,e.e),pt(r,e.n),a+" "+Se.util.encode64(r.bytes())+" "+t},Vr.privateKeyToOpenSSH=function(e,t){return t?Se.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):Se.pki.privateKeyToPem(e)},Vr.getPublicKeyFingerprint=function(e,t){t=t||{};var a=t.md||Se.md.md5.create(),r="ssh-rsa",n=Se.util.createBuffer();Zt(n,r),pt(n,e.e),pt(n,e.n),a.start(),a.update(n.getBytes());var i=a.digest();if(t.encoding==="hex"){var s=i.toHex();return t.delimiter?s.match(/.{2}/g).join(t.delimiter):s}else{if(t.encoding==="binary")return i.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return i};function pt(e,t){var a=t.toString(16);a[0]>="8"&&(a="00"+a);var r=Se.util.hexToBytes(a);e.putInt32(r.length),e.putBytes(r)}function Zt(e,t){e.putInt32(t.length),e.putString(t)}function Or(){for(var e=Se.md.sha1.create(),t=arguments.length,a=0;a<t;++a)e.update(arguments[a]);return e.digest()}var jn=j;const Y0=ei({__proto__:null,default:si(jn)},[jn]);xe.SSHTerminal=Na,xe.SSHTerminalElement=Ra,xe.Vue3SSHTerminal=Na,xe.createTerminal=fr,Object.defineProperty(xe,Symbol.toStringTag,{value:"Module"})});