function SgLib_PBKDF2(n,t,i,r){var u=forge.util.hexToBytes(t);return new Promise(function(t,f){try{var e=forge.pkcs5.pbkdf2(n,u,i,r/8,"sha1"),o=forge.util.bytesToHex(e);t(o)}catch(s){f(s)}})}function str2ab(n){for(var i=new ArrayBuffer(n.length),u=new Uint8Array(i),t=0,r=n.length;t<r;t++)u[t]=n.charCodeAt(t);return i}function StringToBinary(n){var r,u,f,e,t,i;for(t=n.length,r=[],e=!1,f=i=0;0<=t?i<t:i>t;f=0<=t?++i:--i)if(u=String.prototype.charCodeAt.call(n,f),u>255){e=!0;r=null;break}else r.push(u);return e===!0?unescape(encodeURIComponent(n)):String.fromCharCode.apply(null,Array.prototype.slice.apply(r))}function StringToUint8Array(n){var u,t,e,f,r,i;for(u=StringToBinary(n),t=u.length,e=new ArrayBuffer(t),f=new Uint8Array(e),r=i=0;0<=t?i<t:i>t;r=0<=t?++i:--i)f[r]=String.prototype.charCodeAt.call(u,r);return f}function uint8ArrayToHexStr(n){for(var r="",t,i=0;i<n.byteLength;i++)t=n[i].toString(16),t.length<2&&(t="0"+t),r+=t;return r}function arrayBufferToHexString(n){for(var r=new Uint8Array(n),u="",t,i=0;i<r.byteLength;i++)t=r[i].toString(16),t.length<2&&(t="0"+t),u+=t;return u}function arrayBufferToString(n,t,i){for(var o=new Uint8Array(n),f=o.length,u="",e,r=0;r<f;r+=65535)e=65535,r+65535>f&&(e=f-r),u+=String.fromCharCode.apply(null,o.subarray(r,r+e));return u?t&&t(u):i&&i("buffer was invalid"),u}function binStringToHex(n){for(var i,r="",t=0,u=n.length;t<u;++t)i=n.charCodeAt(t),r=r+(i>>4).toString(16)+(i&15).toString(16);return r}function rawStringToBuffer(n){for(var i=n.length,r=new Array(i),t=0;t<i;++t)r[t]=n.charCodeAt(t)&255;return new Uint8Array(r).buffer}function decipher3DES(n,t,i){return CryptoJS.TripleDES.decrypt({ciphertext:n},t,{iv:i,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7})}function cipher3DES(n,t,i){var r=CryptoJS.TripleDES.encrypt(CryptoJS.enc.Hex.parse(n),CryptoJS.enc.Hex.parse(t),{iv:CryptoJS.enc.Hex.parse(i),mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return r.ciphertext}function makeOddParity(n,t){for(var i=0,r=0,f=0,u=0,i=0;i<t;i++){for(f=0,r=0;r<8;r++)u=1,u=u<<r,(n[i]&u)!=0&&f++;f%2==0&&(n[i]=n[i]^1)}return forge.util.binary.hex.encode(n)}function SDSgLib_openPKCS8PrivateKey(n,t){return new Promise(function(i,r){var u,h,v,e,f,o;window.msCrypto?u=window.msCrypto:window.crypto?u=window.crypto:r(Error("Web Cryptography API not supported. [No Crypto Namespace]"));u.webkitSubtle?h=u.webkitSubtle:u.subtle?h=u.subtle:r(Error("Web Cryptography API not supported. [No Crypto.Subtle Namespace]"));v="SHA-1";e=org.pkijs.fromBER(rawStringToBuffer(n));e.offset===-1&&r(Error(SDSGL_ERR_01));f=new org.pkijs.simpl.pkcs8.ENCRYPTED_PRIVATEKEY_INFO_WP52({schema:e.result});o=f.encryptionAlgorithm.parameters.encryptionScheme.algorithm_id;o!=SD_TripleDES&&r(Error(SDSGL_ERR_02+o));var c=f.encryptionAlgorithm.parameters.EncAlgWPBKDF2params.keyDevParams.iterationCount,l=binStringToHex(arrayBufferToString(f.encryptionAlgorithm.parameters.EncAlgWPBKDF2params.keyDevParams.salt.value_block.value_hex)),a=CryptoJS.enc.Hex.parse(binStringToHex(arrayBufferToString(f.encryptedData.value_block.value_hex,!1,!0))),s=forge.util.createBuffer(t);SgLib_PBKDF2(s,l,c,192).then(function(n){n=makeOddParity(forge.util.binary.hex.decode(n),24);var o=CryptoJS.enc.Hex.parse(n),e=CryptoJS.enc.Hex.parse(binStringToHex(arrayBufferToString(f.encryptionAlgorithm.parameters.encryptionScheme.algorithm_params.value_block.value_hex,!1,!0))),h=decipher3DES(a,o,e),u=h.toString(CryptoJS.enc.Latin1);u.length<=0&&r(Error(SDSGL_ERR_03));u[0]!="0"?(console.log("Unable to decrypt ciphered private key "+new Date),s=forge.util.createBuffer(forge.util.encodeUtf8(t)),SgLib_PBKDF2(s,l,c,192).then(function(n){n=makeOddParity(forge.util.binary.hex.decode(n),24);var u=CryptoJS.enc.Hex.parse(n),f=decipher3DES(a,u,e),t=f.toString(CryptoJS.enc.Latin1);t.length<=0&&(console.log("Deciphered binary private key length is zero "+new Date),r(Error(SDSGL_ERR_03)));t[0]!="0"?r(Error(SDSGL_ERR_03)):i(t)})):i(u)})})}function SDSgLib_cipherPKCS8Key(n,t){return new Promise(function(i,r){var u,o,s=2048,f,e,h;window.msCrypto?u=window.msCrypto:window.crypto?u=window.crypto:r(Error("Web Cryptography API not supported. [No Crypto Namespace]"));u.webkitSubtle?o=u.webkitSubtle:u.subtle?o=u.subtle:r(Error("Web Cryptography API not supported. [No Crypto.Subtle Namespace]"));f=new Uint8Array(8);u.getRandomValues(f);e=new Uint8Array(8);u.getRandomValues(e);h=uint8ArrayToHexStr(f);SgLib_PBKDF2(t,h,s,192).then(function(t){t=makeOddParity(forge.util.binary.hex.decode(t),24);var u=uint8ArrayToHexStr(e),o=cipher3DES(arrayBufferToHexString(n),t,u),h={cipherText:o,salt:f,iv:e,iterations:s};create_PKCS8_enc(h,SD_PBES2,SD_PBKDF2,SD_TripleDES).then(function(n){i(n)},function(n){r(Error("Error while encoding ciphered key: "+n.message))})})})}function empty(n){if(typeof n=="undefined"||n===null)return!0}function str2ab(n){for(var i=new ArrayBuffer(n.length),u=new Uint8Array(i),t=0,r=n.length;t<r;t++)u[t]=n.charCodeAt(t);return i}function arrayBufferToString(n,t,i){for(var o=new Uint8Array(n),f=o.length,u="",e,r=0;r<f;r+=65535)e=65535,r+65535>f&&(e=f-r),u+=String.fromCharCode.apply(null,o.subarray(r,r+e));return u?t&&t(u):i&&i("buffer was invalid"),u}function SDSgLib_encodePKCS7Detached(n,t,i){return SDSgLib_encodePKCS7(n,t,i,null)}function SDSgLib_encodePKCS7WithContent(n,t,i,r){return SDSgLib_encodePKCS7(n,t,i,r)}function SDSgLib_encodePKCS7(n,t,i,r){var u="";if(i==SD_SHA1_NAME)u=SD_SHA1_DOID;else if(i==SD_SHA256_NAME)u=SD_SHA256_DOID;else if(i==SD_SHA384_NAME)u=SD_SHA384_DOID;else if(i==SD_SHA512_NAME)u=SD_SHA512_DOID;else return new Promise(function(n,t){t(SD_UNKNOWN_ALGORITHM)});return!(t instanceof ArrayBuffer)||t==null||t.length==0?new Promise(function(n,t){t(SD_ERROR_EMPTY_SIGNATURE)}):!(typeof n=="string")||n==null||n.length==0?new Promise(function(n,t){t(SD_ERROR_EMPTY_CERTIFICATE)}):new Promise(function(i){var o=org.pkijs.fromBER(str2ab(n)),f=new org.pkijs.simpl.CERT({schema:o.result}),e=Promise.resolve();e=e.then(function(){var n=new org.pkijs.simpl.cms.EncapsulatedContentInfo({eContentType:DATA_CONTENT_TYPE});return r!=null&&(n.eContent=new org.pkijs.asn1.OCTETSTRING({value_hex:r})),new org.pkijs.simpl.CMS_SIGNED_DATA({version:1,digestAlgorithms:[new org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:u,algorithm_params:new org.pkijs.asn1.NULL})],encapContentInfo:n,signerInfos:[new org.pkijs.simpl.CMS_SIGNER_INFO({version:1,sid:new org.pkijs.simpl.cms.IssuerAndSerialNumber({issuer:f.issuer,serialNumber:f.serialNumber}),digestAlgorithm:new org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:u,algorithm_params:new org.pkijs.asn1.NULL}),signatureAlgorithm:new org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:SD_RSAENCRYPTION}),signature:new org.pkijs.asn1.OCTETSTRING({value_hex:t})})],certificates:[f]})});e.then(function(n){var t=n.toSchema(!0),r=new org.pkijs.simpl.CMS_CONTENT_INFO({contentType:CMS_SIGNED_DATA,content:t}),t=r.toSchema(!0),u=t.toBER(!1);i(u)},function(n){alert(SD_ERROR_ENCODING_PKCS7+n)})})}function isWCAPISupported(){var n,t;if(window.msCrypto)n=window.msCrypto;else if(window.crypto)n=window.crypto;else return alert("Your current browser does not support the Web Cryptography API! This page will not work. [No Crypto Namespace]"),!1;if(n.webkitSubtle)t=n.webkitSubtle;else if(n.subtle)t=n.subtle;else return alert("Your current browser does not support the Web Cryptography API! This page will not work. [No Crypto.Subtle Namespace]"),!1;return!0}function convertStringToArrayBufferView(n){for(var i=new Uint8Array(n.length),t=0;t<n.length;t++)i[t]=n.charCodeAt(t);return i}function convertArrayBufferViewtoString(n){for(var i="",t=0;t<n.byteLength;t++)i+=String.fromCharCode(n[t]);return i}function formatPEM(n){for(var u=n.length,t="",i=0,r=0;i<u;i++,r++)r>63&&(t=t+"\r\n",r=0),t=t+n[i];return t}function base64toBlob(n,t){var i,r,e;t=t||"";var u=1024,o=atob(n),s=o.length,h=Math.ceil(s/u),c=new Array(h);for(i=0;i<h;++i){var f=i*u,l=Math.min(f+u,s),a=new Array(l-f);for(r=f,e=0;r<l;++e,++r)a[e]=o[r].charCodeAt(0);c[i]=new Uint8Array(a)}return new Blob(c,{type:t})}function isNPAPIPluginsSupported(){var n=!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t=typeof InstallTrigger!="undefined",i=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,r=!!window.chrome&&!n;return/*@cc_on!@*/!1||!!document.documentMode}function signContent(n,t,i,r){return new Promise(function(u,f){var e,o;window.msCrypto?e=window.msCrypto:window.crypto?e=window.crypto:f(Error("Web Cryptography API not supported. [No Crypto Namespace]"));e.webkitSubtle?o=e.webkitSubtle:e.subtle?o=e.subtle:f(Error("Web Cryptography API not supported. [No Crypto.Subtle Namespace]"));SDSgLib_openPKCS8PrivateKey(n,t).then(function(n){n[0]!="0"&&f(Error(SDSGL_ERR_03));o.importKey("pkcs8",rawStringToBuffer(n),{name:"RSASSA-PKCS1-v1_5",hash:{name:i}},!1,["sign"]).then(function(n){o.sign({name:"RSASSA-PKCS1-v1_5",hash:{name:i}},n,convertStringToArrayBufferView(r)).then(function(n){for(var i="",r=new Uint8Array(n),f,t=0;t<r.length;t++)i=i+String.fromCharCode(r[t]);f=window.btoa(i);u(f)},function(n){f(Error("Error during signing data: "+n.message))})},function(n){f(Error("Error during importing pkcs8: "+n.message))})},function(n){f(Error("Error during getting pkcs8: "+n.message))})})}function signHash(n,t,i,r){return new Promise(function(u,f){var e,o;window.msCrypto?e=window.msCrypto:window.crypto?e=window.crypto:f(Error("Web Cryptography API not supported. [No Crypto Namespace]"));e.webkitSubtle?o=e.webkitSubtle:e.subtle?o=e.subtle:f(Error("Web Cryptography API not supported. [No Crypto.Subtle Namespace]"));SDSgLib_openPKCS8PrivateKey(n,t).then(function(n){var t,e;n[0]!="0"&&f(Error(SDSGL_ERR_03));t=formatPEM(window.btoa(n));e=Module.ccall("jsglibSignFromHashV2","string",["string","number","string","number","number"],[t,t.length,r,r.length,i]);e||f(Error("Error during signing hash"));u(e)},function(n){f(Error("Error during getting pkcs8: "+n.message))})})}function multiSignHash(n,t,i,r){var f=r[0],u=r[2];return new Promise(function(r,e){var o,s;window.msCrypto?o=window.msCrypto:window.crypto?o=window.crypto:e(Error("Web Cryptography API not supported. [No Crypto Namespace]"));o.webkitSubtle?s=o.webkitSubtle:o.subtle?s=o.subtle:e(Error("Web Cryptography API not supported. [No Crypto.Subtle Namespace]"));SDSgLib_openPKCS8PrivateKey(n,t).then(function(n){var t,o;n[0]!="0"&&e(Error(SDSGL_ERR_03));t=formatPEM(window.btoa(n));o=Module.ccall("jsglibSignFromHashV2","string",["string","number","string","number","number"],[t,t.length,u,u.length,i]);o||e(Error("Error during signing hash"));r(o+"|"+f)},function(n){e(Error("Error during getting pkcs8: "+n.message))})})}function pkcs7FromHash(n,t,i,r,u){return new Promise(function(f,e){var o,s;window.msCrypto?o=window.msCrypto:window.crypto?o=window.crypto:e(Error("Web Cryptography API not supported. [No Crypto Namespace]"));o.webkitSubtle?s=o.webkitSubtle:o.subtle?s=o.subtle:e(Error("Web Cryptography API not supported. [No Crypto.Subtle Namespace]"));SDSgLib_openPKCS8PrivateKey(t,n).then(function(n){var s,o,t;n[0]!="0"&&e(Error(SDSGL_ERR_03));s=formatPEM(window.btoa(n));o=Module.ccall("jsglibSignFromHashV2","string",["string","number","string","number","number"],[s,s.length,u,u.length,r]);o||e(Error("Error during getting pkcs1"));o.substring(0,7)=="[Error]"&&e(Error(o));switch(r){case 2:t="SHA-1";break;case 3:t="SHA-256";break;case 4:t="SHA-384";break;case 5:t="SHA-512";break;default:t="SHA-256"}SDSgLib_encodePKCS7Detached(i,str2ab(window.atob(o)),t).then(function(n){f(n)},function(n){e(Error("Error during getting pkcs7: "+n.message))})},function(n){e(Error("Error during getting pkcs8: "+n.message))})})}function pkcs7FromContent(n,t,i,r,u,f){return new Promise(function(e,o){var s,h;window.msCrypto?s=window.msCrypto:window.crypto?s=window.crypto:o(Error("Web Cryptography API not supported. [No Crypto Namespace]"));s.webkitSubtle?h=s.webkitSubtle:s.subtle?h=s.subtle:o(Error("Web Cryptography API not supported. [No Crypto.Subtle Namespace]"));SDSgLib_openPKCS8PrivateKey(t,n).then(function(n){n[0]!="0"&&o(Error(SDSGL_ERR_03));h.importKey("pkcs8",rawStringToBuffer(n),{name:"RSASSA-PKCS1-v1_5",hash:{name:r}},!1,["sign"]).then(function(n){h.sign({name:"RSASSA-PKCS1-v1_5",hash:{name:r}},n,convertStringToArrayBufferView(u)).then(function(n){SDSgLib_encodePKCS7(i,n,r,f?null:str2ab(u)).then(function(n){e(n)},function(n){var t={};t.reason="some reason!";t.message=n;o(t)})},function(n){o(Error("Error during signing data: "+n.message))})},function(n){o(Error("Error during importing pkcs8: "+n.message))})},function(n){o(Error("Error during getting pkcs8: "+n.message))})})}function privateDecrypt(n,t,i){return new Promise(function(r,u){var f,e;window.msCrypto?f=window.msCrypto:window.crypto?f=window.crypto:u(Error("Web Cryptography API not supported. [No Crypto Namespace]"));f.webkitSubtle?e=f.webkitSubtle:f.subtle?e=f.subtle:u(Error("Web Cryptography API not supported. [No Crypto.Subtle Namespace]"));SDSgLib_openPKCS8PrivateKey(n,t).then(function(n){var t,f;n[0]!="0"&&u(Error(SDSGL_ERR_03));t=formatPEM(window.btoa(n));f=Module.ccall("jsglibPrivateDecryptV2","string",["string","number","string","number"],[t,t.length,i,i.length]);f||u(Error("Error during decrypting data"));r(f)},function(n){u(Error("Error during getting pkcs8: "+n.message))})})}function globalEval(n){eval.call(null,n)}function assert(n,t){n||abort("Assertion failed: "+t)}function getCFunc(n){var t=Module["_"+n];if(!t)try{t=["_"+n]}catch(i){}return assert(t,"Cannot call unknown function "+n+" (perhaps LLVM optimizations or closure removed it?)"),t}function setValue(n,t,i){i=i||"i8";i.charAt(i.length-1)==="*"&&(i="i32");switch(i){case"i1":HEAP8[n>>0]=t;break;case"i8":HEAP8[n>>0]=t;break;case"i16":HEAP16[n>>1]=t;break;case"i32":HEAP32[n>>2]=t;break;case"i64":tempI64=[t>>>0,(tempDouble=t,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)];HEAP32[n>>2]=tempI64[0];HEAP32[n+4>>2]=tempI64[1];break;case"float":HEAPF32[n>>2]=t;break;case"double":HEAPF64[n>>3]=t;break;default:abort("invalid type for setValue: "+i)}}function getValue(n,t){t=t||"i8";t.charAt(t.length-1)==="*"&&(t="i32");switch(t){case"i1":return HEAP8[n>>0];case"i8":return HEAP8[n>>0];case"i16":return HEAP16[n>>1];case"i32":return HEAP32[n>>2];case"i64":return HEAP32[n>>2];case"float":return HEAPF32[n>>2];case"double":return HEAPF64[n>>3];default:abort("invalid type for setValue: "+t)}return null}function allocate(n,t,i,r){var l,o,h,u,r,c,e,f,a,v,s;if(typeof n=="number"?(l=!0,o=n):(l=!1,o=n.length),h=typeof t=="string"?t:null,u=i==ALLOC_NONE?r:[_malloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][i===undefined?ALLOC_STATIC:i](Math.max(o,h?1:t.length)),l){for(r=u,assert((u&3)==0),c=u+(o&-4);r<c;r+=4)HEAP32[r>>2]=0;for(c=u+o;r<c;)HEAP8[r++>>0]=0;return u}if(h==="i8")return n.subarray||n.slice?HEAPU8.set(n,u):HEAPU8.set(new Uint8Array(n),u),u;for(e=0;e<o;){if(s=n[e],typeof s=="function"&&(s=Runtime.getFunctionIndex(s)),f=h||t[e],f===0){e++;continue}f=="i64"&&(f="i32");setValue(u+e,s,f);v!==f&&(a=Runtime.getNativeTypeSize(f),v=f);e+=a}return u}function getMemory(n){return staticSealed?typeof _sbrk!="undefined"&&!_sbrk.called||!runtimeInitialized?Runtime.dynamicAlloc(n):_malloc(n):Runtime.staticAlloc(n)}function Pointer_stringify(n,t){var f,e,i,r,u,o;if(t===0||!n)return"";for(f=0,i=0;;){if(e=HEAPU8[n+i>>0],f|=e,e==0&&!t)break;if(i++,t&&i==t)break}if(t||(t=i),r="",f<128){for(u=1024;t>0;)o=String.fromCharCode.apply(String,HEAPU8.subarray(n,n+Math.min(t,u))),r=r?r+o:o,n+=u,t-=u;return r}return Module.UTF8ToString(n)}function AsciiToString(n){for(var i="",t;;){if(t=HEAP8[n++>>0],!t)return i;i+=String.fromCharCode(t)}}function stringToAscii(n,t){return writeAsciiToMemory(n,t,!1)}function UTF8ArrayToString(n,t){for(var i,r,u,e,o,h,f="",s;;){if(i=n[t++],!i)return f;if(!(i&128)){f+=String.fromCharCode(i);continue}if(r=n[t++]&63,(i&224)==192){f+=String.fromCharCode((i&31)<<6|r);continue}u=n[t++]&63;(i&240)==224?i=(i&15)<<12|r<<6|u:(e=n[t++]&63,(i&248)==240?i=(i&7)<<18|r<<12|u<<6|e:(o=n[t++]&63,(i&252)==248?i=(i&3)<<24|r<<18|u<<12|e<<6|o:(h=n[t++]&63,i=(i&1)<<30|r<<24|u<<18|e<<12|o<<6|h)));i<65536?f+=String.fromCharCode(i):(s=i-65536,f+=String.fromCharCode(55296|s>>10,56320|s&1023))}}function UTF8ToString(n){return UTF8ArrayToString(HEAPU8,n)}function stringToUTF8Array(n,t,i,r){var o,f,e,u;if(!(r>0))return 0;for(o=i,f=i+r-1,e=0;e<n.length;++e)if(u=n.charCodeAt(e),u>=55296&&u<=57343&&(u=65536+((u&1023)<<10)|n.charCodeAt(++e)&1023),u<=127){if(i>=f)break;t[i++]=u}else if(u<=2047){if(i+1>=f)break;t[i++]=192|u>>6;t[i++]=128|u&63}else if(u<=65535){if(i+2>=f)break;t[i++]=224|u>>12;t[i++]=128|u>>6&63;t[i++]=128|u&63}else if(u<=2097151){if(i+3>=f)break;t[i++]=240|u>>18;t[i++]=128|u>>12&63;t[i++]=128|u>>6&63;t[i++]=128|u&63}else if(u<=67108863){if(i+4>=f)break;t[i++]=248|u>>24;t[i++]=128|u>>18&63;t[i++]=128|u>>12&63;t[i++]=128|u>>6&63;t[i++]=128|u&63}else{if(i+5>=f)break;t[i++]=252|u>>30;t[i++]=128|u>>24&63;t[i++]=128|u>>18&63;t[i++]=128|u>>12&63;t[i++]=128|u>>6&63;t[i++]=128|u&63}return t[i]=0,i-o}function stringToUTF8(n,t,i){return stringToUTF8Array(n,HEAPU8,t,i)}function lengthBytesUTF8(n){for(var r=0,t,i=0;i<n.length;++i)t=n.charCodeAt(i),t>=55296&&t<=57343&&(t=65536+((t&1023)<<10)|n.charCodeAt(++i)&1023),t<=127?++r:r+=t<=2047?2:t<=65535?3:t<=2097151?4:t<=67108863?5:6;return r}function UTF16ToString(n){for(var i=0,r="",t;;){if(t=HEAP16[n+i*2>>1],t==0)return r;++i;r+=String.fromCharCode(t)}}function stringToUTF16(n,t,i){var u,f,r,e;if(i===undefined&&(i=2147483647),i<2)return 0;for(i-=2,u=t,f=i<n.length*2?i/2:n.length,r=0;r<f;++r)e=n.charCodeAt(r),HEAP16[t>>1]=e,t+=2;return HEAP16[t>>1]=0,t-u}function lengthBytesUTF16(n){return n.length*2}function UTF32ToString(n){for(var u=0,i="",t,r;;){if(t=HEAP32[n+u*4>>2],t==0)return i;++u;t>=65536?(r=t-65536,i+=String.fromCharCode(55296|r>>10,56320|r&1023)):i+=String.fromCharCode(t)}}function stringToUTF32(n,t,i){var f,e,u,r,o;if(i===undefined&&(i=2147483647),i<4)return 0;for(f=t,e=f+i-4,u=0;u<n.length;++u)if(r=n.charCodeAt(u),r>=55296&&r<=57343&&(o=n.charCodeAt(++u),r=65536+((r&1023)<<10)|o&1023),HEAP32[t>>2]=r,t+=4,t+4>e)break;return HEAP32[t>>2]=0,t-f}function lengthBytesUTF32(n){for(var r=0,i,t=0;t<n.length;++t)i=n.charCodeAt(t),i>=55296&&i<=57343&&++t,r+=4;return r}function demangle(n){function l(){var i,f,o,r,u,e;for(t++,n[t]==="K"&&t++,i=[];n[t]!=="E";){if(n[t]==="S"){t++;f=n.indexOf("_",t);o=n.substring(t,f)||0;i.push(h[o]||"?");t=f+1;continue}if(n[t]==="C"){i.push(i[i.length-1]);t+=2;continue}if(r=parseInt(n.substr(t)),u=r.toString().length,!r||!u){t--;break}e=n.substr(t+u,r);i.push(e);h.push(e);t+=u+r}return t++,i}function i(r,u,f){function k(){return"("+o.join(", ")+")"}var h,o,a,y,p,w,v,b,e;if(u=u||Infinity,h="",o=[],n[t]==="N"){if(a=l().join("::"),u--,u===0)return r?[a]:a}else(n[t]==="K"||c&&n[t]==="L")&&t++,e=parseInt(n.substr(t)),e&&(y=e.toString().length,a=n.substr(t+y,e),t+=y+e);c=!1;n[t]==="I"?(t++,p=i(!0),w=i(!0,1,!0),h+=w[0]+" "+a+"<"+p.join(", ")+">"):h=a;n:while(t<n.length&&u-->0)if(v=n[t++],v in s)o.push(s[v]);else switch(v){case"P":o.push(i(!0,1,!0)[0]+"*");break;case"R":o.push(i(!0,1,!0)[0]+"&");break;case"L":t++;b=n.indexOf("E",t);e=b-t;o.push(n.substr(t,e));t+=e+2;break;case"A":if(e=parseInt(n.substr(t)),t+=e.toString().length,n[t]!=="_")throw"?";t++;o.push(i(!0,1,!0)[0]+" ["+e+"]");break;case"E":break n;default:h+="?"+v;break n}return f||o.length!==1||o[0]!=="void"||(o=[]),r?(h&&o.push(h+"?"),o):h+k()}var o=!!Module.___cxa_demangle,r,u,f,e;if(o)try{if(r=_malloc(n.length),writeStringToMemory(n.substr(1),r),u=_malloc(4),f=Module.___cxa_demangle(r,0,0,u),getValue(u,"i32")===0&&f)return Pointer_stringify(f)}catch(a){}finally{r&&_free(r);u&&_free(u);f&&_free(f)}var t=3,s={v:"void",b:"bool",c:"char",s:"short",i:"int",l:"long",f:"float",d:"double",w:"wchar_t",a:"signed char",h:"unsigned char",t:"unsigned short",j:"unsigned int",m:"unsigned long",x:"long long",y:"unsigned long long",z:"..."},h=[],c=!0;e=n;try{if(n=="Object._main"||n=="_main")return"main()";if((typeof n=="number"&&(n=Pointer_stringify(n)),n[0]!=="_")||n[1]!=="_"||n[2]!=="Z")return n;switch(n[3]){case"n":return"operator new()";case"d":return"operator delete()"}e=i()}catch(a){e+="?"}return e.indexOf("?")>=0&&!o&&Runtime.warnOnce("warning: a problem occurred in builtin C++ name demangling; build with  -s DEMANGLE_SUPPORT=1  to link in libcxxabi demangling"),e}function demangleAll(n){return n.replace(/__Z[\w\d_]+/g,function(n){var t=demangle(n);return n===t?n:n+" ["+t+"]"})}function jsStackTrace(){var n=new Error;if(!n.stack){try{throw new Error(0);}catch(t){n=t}if(!n.stack)return"(no stack trace available)"}return n.stack.toString()}function stackTrace(){return demangleAll(jsStackTrace())}function alignMemoryPage(n){return n%4096>0&&(n+=4096-n%4096),n}function enlargeMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.")}function callRuntimeCallbacks(n){for(var t,i;n.length>0;){if(t=n.shift(),typeof t=="function"){t();continue}i=t.func;typeof i=="number"?t.arg===undefined?Runtime.dynCall("v",i):Runtime.dynCall("vi",i,[t.arg]):i(t.arg===undefined?null:t.arg)}}function preRun(){if(Module.preRun)for(typeof Module.preRun=="function"&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){runtimeInitialized||(runtimeInitialized=!0,callRuntimeCallbacks(__ATINIT__))}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=!0}function postRun(){if(Module.postRun)for(typeof Module.postRun=="function"&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(n){__ATPRERUN__.unshift(n)}function addOnInit(n){__ATINIT__.unshift(n)}function addOnPreMain(n){__ATMAIN__.unshift(n)}function addOnExit(n){__ATEXIT__.unshift(n)}function addOnPostRun(n){__ATPOSTRUN__.unshift(n)}function intArrayFromString(n,t,i){var u=i>0?i:lengthBytesUTF8(n)+1,r=new Array(u),f=stringToUTF8Array(n,r,0,r.length);return t&&(r.length=f),r}function intArrayToString(n){for(var r=[],i,t=0;t<n.length;t++)i=n[t],i>255&&(i&=255),r.push(String.fromCharCode(i));return r.join("")}function writeStringToMemory(n,t,i){for(var u=intArrayFromString(n,i),r=0,f;r<u.length;)f=u[r],HEAP8[t+r>>0]=f,r=r+1}function writeArrayToMemory(n,t){for(var i=0;i<n.length;i++)HEAP8[t++>>0]=n[i]}function writeAsciiToMemory(n,t,i){for(var r=0;r<n.length;++r)HEAP8[t++>>0]=n.charCodeAt(r);i||(HEAP8[t>>0]=0)}function unSign(n,t){return n>=0?n:t<=32?2*Math.abs(1<<t-1)+n:Math.pow(2,t)+n}function reSign(n,t){if(n<=0)return n;var i=t<=32?Math.abs(1<<t-1):Math.pow(2,t-1);return n>=i&&(t<=32||n>i)&&(n=-2*i+n),n}function getUniqueRunDependency(n){return n}function addRunDependency(){runDependencies++;Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies)}function removeRunDependency(){if(runDependencies--,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies),runDependencies==0&&(runDependencyWatcher!==null&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var n=dependenciesFulfilled;dependenciesFulfilled=null;n()}}function copyTempFloat(n){HEAP8[tempDoublePtr]=HEAP8[n];HEAP8[tempDoublePtr+1]=HEAP8[n+1];HEAP8[tempDoublePtr+2]=HEAP8[n+2];HEAP8[tempDoublePtr+3]=HEAP8[n+3]}function copyTempDouble(n){HEAP8[tempDoublePtr]=HEAP8[n];HEAP8[tempDoublePtr+1]=HEAP8[n+1];HEAP8[tempDoublePtr+2]=HEAP8[n+2];HEAP8[tempDoublePtr+3]=HEAP8[n+3];HEAP8[tempDoublePtr+4]=HEAP8[n+4];HEAP8[tempDoublePtr+5]=HEAP8[n+5];HEAP8[tempDoublePtr+6]=HEAP8[n+6];HEAP8[tempDoublePtr+7]=HEAP8[n+7]}function ___setErrNo(n){return Module.___errno_location&&(HEAP32[Module.___errno_location()>>2]=n),n}function _sysconf(n){switch(n){case 30:return PAGE_SIZE;case 85:return totalMemory/PAGE_SIZE;case 132:case 133:case 12:case 137:case 138:case 15:case 235:case 16:case 17:case 18:case 19:case 20:case 149:case 13:case 10:case 236:case 153:case 9:case 21:case 22:case 159:case 154:case 14:case 77:case 78:case 139:case 80:case 81:case 82:case 68:case 67:case 164:case 11:case 29:case 47:case 48:case 95:case 52:case 51:case 46:return 200809;case 79:return 0;case 27:case 246:case 127:case 128:case 23:case 24:case 160:case 161:case 181:case 182:case 242:case 183:case 184:case 243:case 244:case 245:case 165:case 178:case 179:case 49:case 50:case 168:case 169:case 175:case 170:case 171:case 172:case 97:case 76:case 32:case 173:case 35:return-1;case 176:case 177:case 7:case 155:case 8:case 157:case 125:case 126:case 92:case 93:case 129:case 130:case 131:case 94:case 91:return 1;case 74:case 60:case 69:case 70:case 4:return 1024;case 31:case 42:case 72:return 32;case 87:case 26:case 33:return 2147483647;case 34:case 1:return 47839;case 38:case 36:return 99;case 43:case 37:return 2048;case 0:return 2097152;case 3:return 65536;case 28:return 32768;case 44:return 32767;case 75:return 16384;case 39:return 1e3;case 89:return 700;case 71:return 256;case 40:return 255;case 2:return 100;case 180:return 64;case 25:return 20;case 5:return 16;case 6:return 6;case 73:return 4;case 84:return typeof navigator=="object"?navigator.hardwareConcurrency||1:1}return ___setErrNo(ERRNO_CODES.EINVAL),-1}function _pthread_cleanup_push(n,t){__ATEXIT__.push(function(){Runtime.dynCall("vi",n,[t])});_pthread_cleanup_push.level=__ATEXIT__.length}function _pthread_cleanup_pop(){assert(_pthread_cleanup_push.level==__ATEXIT__.length,"cannot pop if something else added meanwhile!");__ATEXIT__.pop();_pthread_cleanup_push.level=__ATEXIT__.length}function _abort(){Module.abort()}function ___lock(){}function ___unlock(){}function ___syscall6(n,t){SYSCALLS.varargs=t;try{var r=SYSCALLS.getStreamFromFD();return FS.close(r),0}catch(i){return typeof FS!="undefined"&&i instanceof FS.ErrnoError||abort(i),-i.errno}}function _sbrk(n){var t=_sbrk,i,r;return(t.called||(DYNAMICTOP=alignMemoryPage(DYNAMICTOP),t.called=!0,assert(Runtime.dynamicAlloc),t.alloc=Runtime.dynamicAlloc,Runtime.dynamicAlloc=function(){abort("cannot dynamically allocate, sbrk now has control")}),i=DYNAMICTOP,n!=0&&(r=t.alloc(n),!r))?-1>>>0:i}function _emscripten_memcpy_big(n,t,i){return HEAPU8.set(HEAPU8.subarray(t,t+i),n),n}function _emscripten_set_main_loop_timing(n,t){return(Browser.mainLoop.timingMode=n,Browser.mainLoop.timingValue=t,!Browser.mainLoop.func)?1:(n==0?(Browser.mainLoop.scheduler=function(){setTimeout(Browser.mainLoop.runner,t)},Browser.mainLoop.method="timeout"):n==1&&(Browser.mainLoop.scheduler=function(){Browser.requestAnimationFrame(Browser.mainLoop.runner)},Browser.mainLoop.method="rAF"),0)}function _emscripten_set_main_loop(n,t,i,r,u){Module.noExitRuntime=!0;assert(!Browser.mainLoop.func,"emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters.");Browser.mainLoop.func=n;Browser.mainLoop.arg=r;var f=Browser.mainLoop.currentlyRunningMainloop;if(Browser.mainLoop.runner=function(){var e,t,i,u;if(!ABORT){if(Browser.mainLoop.queue.length>0){e=Date.now();t=Browser.mainLoop.queue.shift();t.func(t.arg);Browser.mainLoop.remainingBlockers&&(i=Browser.mainLoop.remainingBlockers,u=i%1==0?i-1:Math.floor(i),t.counted?Browser.mainLoop.remainingBlockers=u:(u=u+.5,Browser.mainLoop.remainingBlockers=(8*i+u)/9));console.log('main loop blocker "'+t.name+'" took '+(Date.now()-e)+" ms");Browser.mainLoop.updateStatus();setTimeout(Browser.mainLoop.runner,0);return}if(!(f<Browser.mainLoop.currentlyRunningMainloop)){if(Browser.mainLoop.currentFrameNumber=Browser.mainLoop.currentFrameNumber+1|0,Browser.mainLoop.timingMode==1&&Browser.mainLoop.timingValue>1&&Browser.mainLoop.currentFrameNumber%Browser.mainLoop.timingValue!=0){Browser.mainLoop.scheduler();return}(Browser.mainLoop.method==="timeout"&&Module.ctx&&(Module.printErr("Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!"),Browser.mainLoop.method=""),Browser.mainLoop.runIter(function(){typeof r!="undefined"?Runtime.dynCall("vi",n,[r]):Runtime.dynCall("v",n)}),f<Browser.mainLoop.currentlyRunningMainloop)||(typeof SDL=="object"&&SDL.audio&&SDL.audio.queueNewAudioData&&SDL.audio.queueNewAudioData(),Browser.mainLoop.scheduler())}}},u||(t&&t>0?_emscripten_set_main_loop_timing(0,1e3/t):_emscripten_set_main_loop_timing(1,1),Browser.mainLoop.scheduler()),i)throw"SimulateInfiniteLoop";}function _time(n){var t=Date.now()/1e3|0;return n&&(HEAP32[n>>2]=t),t}function _pthread_self(){return 0}function ___syscall140(n,t){SYSCALLS.varargs=t;try{var i=SYSCALLS.getStreamFromFD(),e=SYSCALLS.get(),o=SYSCALLS.get(),s=SYSCALLS.get(),u=SYSCALLS.get(),f=o;return assert(e===0),FS.llseek(i,f,u),HEAP32[s>>2]=i.position,i.getdents&&f===0&&u===0&&(i.getdents=null),0}catch(r){return typeof FS!="undefined"&&r instanceof FS.ErrnoError||abort(r),-r.errno}}function ___syscall146(n,t){SYSCALLS.varargs=t;try{var r=SYSCALLS.getStreamFromFD(),u=SYSCALLS.get(),f=SYSCALLS.get();return SYSCALLS.doWritev(r,u,f)}catch(i){return typeof FS!="undefined"&&i instanceof FS.ErrnoError||abort(i),-i.errno}}function ___syscall54(n,t){var i,u,r;SYSCALLS.varargs=t;try{i=SYSCALLS.getStreamFromFD();u=SYSCALLS.get();switch(u){case 21505:return i.tty?0:-ERRNO_CODES.ENOTTY;case 21506:return i.tty?0:-ERRNO_CODES.ENOTTY;case 21519:return i.tty?(r=SYSCALLS.get(),HEAP32[r>>2]=0,0):-ERRNO_CODES.ENOTTY;case 21520:return i.tty?-ERRNO_CODES.EINVAL:-ERRNO_CODES.ENOTTY;case 21531:return r=SYSCALLS.get(),FS.ioctl(i,u,r);default:abort("bad ioctl syscall "+u)}}catch(f){return typeof FS!="undefined"&&f instanceof FS.ErrnoError||abort(f),-f.errno}}function invoke_iiii(n,t,i,r){try{return Module.dynCall_iiii(n,t,i,r)}catch(u){if(typeof u!="number"&&u!=="longjmp")throw u;asm.setThrew(1,0)}}function invoke_viiiii(n,t,i,r,u,f){try{Module.dynCall_viiiii(n,t,i,r,u,f)}catch(e){if(typeof e!="number"&&e!=="longjmp")throw e;asm.setThrew(1,0)}}function invoke_vi(n,t){try{Module.dynCall_vi(n,t)}catch(i){if(typeof i!="number"&&i!=="longjmp")throw i;asm.setThrew(1,0)}}function invoke_ii(n,t){try{return Module.dynCall_ii(n,t)}catch(i){if(typeof i!="number"&&i!=="longjmp")throw i;asm.setThrew(1,0)}}function invoke_viiiiii(n,t,i,r,u,f,e){try{Module.dynCall_viiiiii(n,t,i,r,u,f,e)}catch(o){if(typeof o!="number"&&o!=="longjmp")throw o;asm.setThrew(1,0)}}function invoke_viiii(n,t,i,r,u){try{Module.dynCall_viiii(n,t,i,r,u)}catch(f){if(typeof f!="number"&&f!=="longjmp")throw f;asm.setThrew(1,0)}}function ExitStatus(n){this.name="ExitStatus";this.message="Program terminated with exit("+n+")";this.status=n}function run(n){function t(){Module.calledRun||(Module.calledRun=!0,ABORT)||(ensureInitRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),Module._main&&shouldRunNow&&Module.callMain(n),postRun())}(n=n||Module.arguments,preloadStartTime===null&&(preloadStartTime=Date.now()),runDependencies>0)||(preRun(),runDependencies>0)||Module.calledRun||(Module.setStatus?(Module.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Module.setStatus("")},1);t()},1)):t())}function exit(n,t){if(!t||!Module.noExitRuntime){if(!Module.noExitRuntime&&(ABORT=!0,EXITSTATUS=n,STACKTOP=initialStackTop,exitRuntime(),Module.onExit))Module.onExit(n);if(ENVIRONMENT_IS_NODE){process.stdout.once("drain",function(){process.exit(n)});console.log(" ");setTimeout(function(){process.exit(n)},500)}else ENVIRONMENT_IS_SHELL&&typeof quit=="function"&&quit(n);throw new ExitStatus(n);}}function abort(n){n!==undefined?(Module.print(n),Module.printErr(n),n=JSON.stringify(n)):n="";ABORT=!0;EXITSTATUS=1;var t="abort("+n+") at "+stackTrace()+"\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";abortDecorators&&abortDecorators.forEach(function(i){t=i(t,n)});throw t;}var CryptoJS,Module,moduleOverrides,nodeFS,nodePath,TRY_USE_DUMP,key,Runtime,globalScope,cwrap,ccall,PAGE_SIZE,buffer,memoryInitializer,ASM_CONSTS,tempDoublePtr,ERRNO_CODES,Browser,fs,NODEJS_PATH,initialStackTop,preloadStartTime,calledMain,abortDecorators,shouldRunNow;(function(n){if(typeof n.org=="undefined")n.org={};else if(typeof n.org!="object")throw new Error("Name org already exists and it's not an object");if(typeof n.org.pkijs=="undefined")n.org.pkijs={};else if(typeof n.org.pkijs!="object")throw new Error("Name org.pkijs already exists and it's not an object but "+typeof n.org.pkijs);n.org.pkijs.emptyObject=function(){this.toJSON=function(){return{}};this.toSchema=function(){return{}}};n.org.pkijs.getNames=function(n){var t={};return n instanceof Object&&(t=n.names||{}),t};n.org.pkijs.inheriteObjectFields=function(n){for(i in n.prototype)typeof n.prototype[i]!="function"&&(this[i]=n.prototype[i])};n.org.pkijs.getUTCDate=function(n){var t=n;return new Date(t.getTime()+t.getTimezoneOffset()*6e4)};n.org.pkijs.padNumber=function(n,t){for(var r=n.toString(10),u=t-r.length,f=new Array(u),e,i=0;i<u;i++)f[i]="0";return e=f.join(""),e.concat(r)};n.org.pkijs.getValue=function(n,t,i){return t in n?n[t]:i};n.org.pkijs.isEqual_view=function(n,t){if(n.length!==t.length)return!1;for(var i=0;i<n.length;i++)if(n[i]!=t[i])return!1;return!0};n.org.pkijs.isEqual_buffer=function(t,i){if(t.byteLength!=i.byteLength)return!1;var r=new Uint8Array(t),u=new Uint8Array(i);return n.org.pkijs.isEqual_view(r,u)};n.org.pkijs.concat_buffers=function(n,t){for(var e=new Uint8Array(n),o=new Uint8Array(t),u=new ArrayBuffer(n.byteLength+t.byteLength),f=new Uint8Array(u),r,i=0;i<n.byteLength;i++)f[i]=e[i];for(r=0;r<t.byteLength;r++)f[n.byteLength+r]=o[r];return u};n.org.pkijs.copyBuffer=function(n){for(var i=new ArrayBuffer(n.byteLength),u=new Uint8Array(i),r=new Uint8Array(n),t=0;t<r.length;t++)u[t]=r[t];return i};n.org.pkijs.getCrypto=function(){var t;return"crypto"in n&&("webkitSubtle"in n.crypto&&(t=n.crypto.webkitSubtle),"subtle"in n.crypto&&(t=n.crypto.subtle)),t};n.org.pkijs.stringPrep=function(n){var t=n.replace(/^\s+|\s+$/g,"");return t=t.replace(/\s+/g," "),t.toLowerCase()};n.org.pkijs.bufferToHexCodes=function(n,t,i){for(var u="",e=new Uint8Array(n,t,i),f,r=0;r<e.length;r++)f=e[r].toString(16).toUpperCase(),u=u+(f.length===1?"0":"")+f;return u};n.org.pkijs.bufferFromHexCodes=function(n){var f=n.length,e=new ArrayBuffer(f>>1),o=new Uint8Array(e),t={},u,r,i;for(t["0"]=0,t["1"]=1,t["2"]=2,t["3"]=3,t["4"]=4,t["5"]=5,t["6"]=6,t["7"]=7,t["8"]=8,t["9"]=9,t.A=10,t.a=10,t.B=11,t.b=11,t.C=12,t.c=12,t.D=13,t.d=13,t.E=14,t.e=14,t.F=15,t.f=15,u=0,r=0,i=0;i<f;i++)i%2?(r|=t[n.charAt(i)],o[u]=r,u++):r=t[n.charAt(i)]<<4;return e};n.org.pkijs.getRandomValues=function(t){if("crypto"in n)return n.crypto.getRandomValues(t);throw new Error("No support for Web Cryptography API");};n.org.pkijs.getAlgorithmParameters=function(t,i){var r={algorithm:{},usages:[]};switch(t.toUpperCase()){case"RSASSA-PKCS1-V1_5":switch(i.toLowerCase()){case"generatekey":r={algorithm:{name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},usages:["sign","verify"]};break;case"verify":case"sign":case"importkey":r={algorithm:{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},usages:["verify"]};break;case"exportkey":default:return{algorithm:{name:"RSASSA-PKCS1-v1_5"},usages:[]}}break;case"RSA-PSS":switch(i.toLowerCase()){case"sign":case"verify":r={algorithm:{name:"RSA-PSS",hash:{name:"SHA-1"},saltLength:20},usages:["sign","verify"]};break;case"generatekey":r={algorithm:{name:"RSA-PSS",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-1"}},usages:["sign","verify"]};break;case"importkey":r={algorithm:{name:"RSA-PSS",hash:{name:"SHA-1"}},usages:["verify"]};break;case"exportkey":default:return{algorithm:{name:"RSA-PSS"},usages:[]}}break;case"RSA-OAEP":switch(i.toLowerCase()){case"encrypt":case"decrypt":r={algorithm:{name:"RSA-OAEP"},usages:["encrypt","decrypt"]};break;case"generatekey":r={algorithm:{name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"importkey":r={algorithm:{name:"RSA-OAEP",hash:{name:"SHA-256"}},usages:["encrypt"]};break;case"exportkey":default:return{algorithm:{name:"RSA-OAEP"},usages:[]}}break;case"ECDSA":switch(i.toLowerCase()){case"generatekey":r={algorithm:{name:"ECDSA",namedCurve:"P-256"},usages:["sign","verify"]};break;case"importkey":r={algorithm:{name:"ECDSA",namedCurve:"P-256"},usages:["verify"]};break;case"verify":case"sign":r={algorithm:{name:"ECDSA",hash:{name:"SHA-256"}},usages:["sign"]};break;default:return{algorithm:{name:"ECDSA"},usages:[]}}break;case"ECDH":switch(i.toLowerCase()){case"exportkey":case"importkey":case"generatekey":r={algorithm:{name:"ECDH",namedCurve:"P-256"},usages:["deriveKey","deriveBits"]};break;case"derivekey":case"derivebits":r={algorithm:{name:"ECDH",namedCurve:"P-256",public:[]},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"ECDH"},usages:[]}}break;case"AES-CTR":switch(i.toLowerCase()){case"importkey":case"exportkey":case"generatekey":r={algorithm:{name:"AES-CTR",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":r={algorithm:{name:"AES-CTR",counter:new Uint8Array(16),length:10},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};default:return{algorithm:{name:"AES-CTR"},usages:[]}}break;case"AES-CBC":switch(i.toLowerCase()){case"importkey":case"exportkey":case"generatekey":r={algorithm:{name:"AES-CBC",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":r={algorithm:{name:"AES-CBC",iv:n.org.pkijs.getRandomValues(new Uint8Array(16))},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};default:return{algorithm:{name:"AES-CBC"},usages:[]}}break;case"AES-GCM":switch(i.toLowerCase()){case"importkey":case"exportkey":case"generatekey":r={algorithm:{name:"AES-GCM",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":r={algorithm:{name:"AES-GCM",iv:n.org.pkijs.getRandomValues(new Uint8Array(16))},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};default:return{algorithm:{name:"AES-GCM"},usages:[]}}break;case"AES-KW":switch(i.toLowerCase()){case"importkey":case"exportkey":case"generatekey":case"wrapkey":case"unwrapkey":r={algorithm:{name:"AES-KW",length:256},usages:["wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-KW"},usages:[]}}break;case"HMAC":switch(i.toLowerCase()){case"sign":case"verify":r={algorithm:{name:"HMAC"},usages:["sign","verify"]};break;case"importkey":case"exportkey":case"generatekey":r={algorithm:{name:"HMAC",length:10,hash:{name:"SHA-256"}},usages:["sign","verify"]};break;default:return{algorithm:{name:"HMAC"},usages:[]}}break;case"HKDF":switch(i.toLowerCase()){case"derivekey":r={algorithm:{name:"HKDF",hash:"SHA-256",salt:new Uint8Array,info:new Uint8Array},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"HKDF"},usages:[]}}break;case"PBKDF2":switch(i.toLowerCase()){case"derivekey":r={algorithm:{name:"PBKDF2",hash:{name:"SHA-256"},salt:new Uint8Array,iterations:1e3},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"PBKDF2"},usages:[]}}}return r};n.org.pkijs.getOIDByAlgorithm=function(n){var t="";switch(n.name.toUpperCase()){case"RSASSA-PKCS1-V1_5":switch(n.hash.name.toUpperCase()){case"SHA-1":t="1.2.840.113549.1.1.5";break;case"SHA-256":t="1.2.840.113549.1.1.11";break;case"SHA-384":t="1.2.840.113549.1.1.12";break;case"SHA-512":t="1.2.840.113549.1.1.13"}break;case"RSA-PSS":t="1.2.840.113549.1.1.10";break;case"RSA-OAEP":t="1.2.840.113549.1.1.7";break;case"ECDSA":switch(n.hash.name.toUpperCase()){case"SHA-1":t="1.2.840.10045.4.1";break;case"SHA-256":t="1.2.840.10045.4.3.2";break;case"SHA-384":t="1.2.840.10045.4.3.3";break;case"SHA-512":t="1.2.840.10045.4.3.4"}break;case"ECDH":switch(n.kdf.toUpperCase()){case"SHA-1":t="1.3.133.16.840.63.0.2";break;case"SHA-256":t="1.3.132.1.11.1";break;case"SHA-384":t="1.3.132.1.11.2";break;case"SHA-512":t="1.3.132.1.11.3"}break;case"AES-CBC":switch(n.length){case 128:t="2.16.840.1.101.3.4.1.2";break;case 192:t="2.16.840.1.101.3.4.1.22";break;case 256:t="2.16.840.1.101.3.4.1.42"}break;case"AES-GCM":switch(n.length){case 128:t="2.16.840.1.101.3.4.1.6";break;case 192:t="2.16.840.1.101.3.4.1.26";break;case 256:t="2.16.840.1.101.3.4.1.46"}break;case"AES-CFB":switch(n.length){case 128:t="2.16.840.1.101.3.4.1.4";break;case 192:t="2.16.840.1.101.3.4.1.24";break;case 256:t="2.16.840.1.101.3.4.1.44"}break;case"AES-KW":switch(n.length){case 128:t="2.16.840.1.101.3.4.1.5";break;case 192:t="2.16.840.1.101.3.4.1.25";break;case 256:t="2.16.840.1.101.3.4.1.45"}break;case"HMAC":switch(n.hash.name.toUpperCase()){case"SHA-1":t="1.2.840.113549.2.7";break;case"SHA-256":t="1.2.840.113549.2.9";break;case"SHA-384":t="1.2.840.113549.2.10";break;case"SHA-512":t="1.2.840.113549.2.11"}break;case"DH":t="1.2.840.113549.1.9.16.3.5";break;case"SHA-1":t="1.3.14.3.2.26";break;case"SHA-256":t="2.16.840.1.101.3.4.2.1";break;case"SHA-384":t="2.16.840.1.101.3.4.2.2";break;case"SHA-512":t="2.16.840.1.101.3.4.2.3";break;case"PBKDF2":t="1.2.840.113549.1.5.12";break;case"P-256":t="1.2.840.10045.3.1.7";break;case"P-384":t="1.3.132.0.34";break;case"P-521":t="1.3.132.0.35"}return t};n.org.pkijs.getAlgorithmByOID=function(n){var t={};switch(n){case"1.2.840.113549.1.1.5":t={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};break;case"1.2.840.113549.1.1.11":t={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};break;case"1.2.840.113549.1.1.12":t={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};break;case"1.2.840.113549.1.1.13":t={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};break;case"1.2.840.113549.1.1.10":t={name:"RSA-PSS"};break;case"1.2.840.113549.1.1.7":t={name:"RSA-OAEP"};break;case"1.2.840.10045.4.1":t={name:"ECDSA",hash:{name:"SHA-1"}};break;case"1.2.840.10045.4.3.2":t={name:"ECDSA",hash:{name:"SHA-256"}};break;case"1.2.840.10045.4.3.3":t={name:"ECDSA",hash:{name:"SHA-384"}};break;case"1.2.840.10045.4.3.4":t={name:"ECDSA",hash:{name:"SHA-512"}};break;case"1.3.133.16.840.63.0.2":t={name:"ECDH",kdf:"SHA-1"};break;case"1.3.132.1.11.1":t={name:"ECDH",kdf:"SHA-256"};break;case"1.3.132.1.11.2":t={name:"ECDH",kdf:"SHA-384"};break;case"1.3.132.1.11.3":t={name:"ECDH",kdf:"SHA-512"};break;case"2.16.840.1.101.3.4.1.2":t={name:"AES-CBC",length:128};break;case"2.16.840.1.101.3.4.1.22":t={name:"AES-CBC",length:192};break;case"2.16.840.1.101.3.4.1.42":t={name:"AES-CBC",length:256};break;case"2.16.840.1.101.3.4.1.6":t={name:"AES-GCM",length:128};break;case"2.16.840.1.101.3.4.1.26":t={name:"AES-GCM",length:192};break;case"2.16.840.1.101.3.4.1.46":t={name:"AES-GCM",length:256};break;case"2.16.840.1.101.3.4.1.4":t={name:"AES-CFB",length:128};break;case"2.16.840.1.101.3.4.1.24":t={name:"AES-CFB",length:192};break;case"2.16.840.1.101.3.4.1.44":t={name:"AES-CFB",length:256};break;case"2.16.840.1.101.3.4.1.5":t={name:"AES-KW",length:128};break;case"2.16.840.1.101.3.4.1.25":t={name:"AES-KW",length:192};break;case"2.16.840.1.101.3.4.1.45":t={name:"AES-KW",length:256};break;case"1.2.840.113549.2.7":t={name:"HMAC",hash:{name:"SHA-1"}};break;case"1.2.840.113549.2.9":t={name:"HMAC",hash:{name:"SHA-256"}};break;case"1.2.840.113549.2.10":t={name:"HMAC",hash:{name:"SHA-384"}};break;case"1.2.840.113549.2.11":t={name:"HMAC",hash:{name:"SHA-512"}};break;case"1.2.840.113549.1.9.16.3.5":t={name:"DH"};break;case"1.3.14.3.2.26":t={name:"SHA-1"};break;case"2.16.840.1.101.3.4.2.1":t={name:"SHA-256"};break;case"2.16.840.1.101.3.4.2.2":t={name:"SHA-384"};break;case"2.16.840.1.101.3.4.2.3":t={name:"SHA-512"};break;case"1.2.840.113549.1.5.12":t={name:"PBKDF2"};break;case"1.2.840.10045.3.1.7":t={name:"P-256"};break;case"1.3.132.0.34":t={name:"P-384"};break;case"1.3.132.0.35":t={name:"P-521"}}return t};n.org.pkijs.getHashAlgorithm=function(t){var i="",r,u;switch(t.algorithm_id){case"1.2.840.10045.4.1":case"1.2.840.113549.1.1.5":i="SHA-1";break;case"1.2.840.10045.4.3.2":case"1.2.840.113549.1.1.11":i="SHA-256";break;case"1.2.840.10045.4.3.3":case"1.2.840.113549.1.1.12":i="SHA-384";break;case"1.2.840.10045.4.3.4":case"1.2.840.113549.1.1.13":i="SHA-512";break;case"1.2.840.113549.1.1.10":try{if(r=new n.org.pkijs.simpl.x509.RSASSA_PSS_params({schema:t.algorithm_params}),"hashAlgorithm"in r){if(u=n.org.pkijs.getAlgorithmByOID(r.hashAlgorithm.algorithm_id),"name"in u==!1)return"";i=u.name}else i="SHA-1"}catch(f){}}return i};n.org.pkijs.createCMSECDSASignature=function(t){var i,l,a,w;if(t.byteLength%2!=0)return new ArrayBuffer(0);for(var r=0,u=t.byteLength/2,v=new Uint8Array(t),y=new ArrayBuffer(u),f=new Uint8Array(y),e,o,p=new ArrayBuffer(u),s=new Uint8Array(p),h,c;r<u;r++)f[r]=v[r];if(f[0]&128)for(e=new ArrayBuffer(u+1),o=new Uint8Array(e),o[0]=0,i=0;i<u;i++)o[i+1]=f[i];else e=y,o=f;for(;r<t.byteLength;r++)s[r-u]=v[r];if(s[0]&128)for(h=new ArrayBuffer(u+1),c=new Uint8Array(h),c[0]=0,i=0;i<u;i++)c[i+1]=s[i];else h=p,c=s;return l=new n.org.pkijs.asn1.INTEGER,l.value_block.is_hex_only=!0,l.value_block.value_hex=n.org.pkijs.copyBuffer(e),a=new n.org.pkijs.asn1.INTEGER,a.value_block.is_hex_only=!0,a.value_block.value_hex=n.org.pkijs.copyBuffer(h),w=new n.org.pkijs.asn1.SEQUENCE({value:[l,a]}),w.toBER(!1)};n.org.pkijs.createECDSASignatureFromCMS=function(n){var i=0,r=0,e=0,u=n.value_block.value[0].value_block.value_hex.byteLength,o=n.value_block.value[1].value_block.value_hex.byteLength,s=new Uint8Array(n.value_block.value[0].value_block.value_hex),f,h,c,t;for(s[0]===0&&s[1]&128?(i=u-1,r=1):i=u,f=new Uint8Array(n.value_block.value[1].value_block.value_hex),f[0]===0&&f[1]&128?(i+=o-1,e=1):i+=o,h=new ArrayBuffer(i),c=new Uint8Array(h),t=r;t<u;t++)c[t-r]=s[t];for(t=e;t<o;t++)c[t-e+u-r]=f[t];return h};n.org.pkijs.getEncryptionAlgorithm=function(n){var t="";switch(n.name.toUpperCase()){case"AES-CBC":switch(n.length){case 128:t="2.16.840.1.101.3.4.1.2";break;case 192:t="2.16.840.1.101.3.4.1.22";break;case 256:t="2.16.840.1.101.3.4.1.42"}break;case"AES-GCM":switch(n.length){case 128:t="2.16.840.1.101.3.4.1.6";break;case 192:t="2.16.840.1.101.3.4.1.26";break;case 256:t="2.16.840.1.101.3.4.1.46"}}return t};n.org.pkijs.getAlgorithmByEncryptionOID=function(n){var t="";switch(n){case"2.16.840.1.101.3.4.1.2":case"2.16.840.1.101.3.4.1.22":case"2.16.840.1.101.3.4.1.42":t="AES-CBC";break;case"2.16.840.1.101.3.4.1.6":case"2.16.840.1.101.3.4.1.26":case"2.16.840.1.101.3.4.1.46":t="AES-GCM"}return t}})(typeof exports!="undefined"?exports:window),function(n){function f(n,t){for(var r=0,i=n.length-1;i>=0;i--)r+=n[n.length-1-i]*Math.pow(2,t*i);return r}function u(n,t,i){var f,o,r,e,s,u,h;for(i=i||-1,f=0,o=Math.pow(2,t),r=1;r<8;r++){if(n<o){if(i<0)e=new ArrayBuffer(r),f=r;else{if(i<r)return new ArrayBuffer(0);e=new ArrayBuffer(i);f=i}for(s=new Uint8Array(e),u=r-1;u>=0;u--)h=Math.pow(2,u*t),s[f-u-1]=Math.floor(n/h),n-=s[f-u-1]*h;return e}o*=Math.pow(2,t)}}function o(n){for(var o=n<0?n*-1:n,s=128,t,r,h,c,e,f=1;f<8;f++){if(o<=s){if(n<0){var l=s-o,t=u(l,8,f),r=new Uint8Array(t);return r[0]|=128,t}if(t=u(o,8,f),r=new Uint8Array(t),r[0]&128){for(h=i(t),c=new Uint8Array(h),t=new ArrayBuffer(t.byteLength+1),r=new Uint8Array(t),e=0;e<h.byteLength;e++)r[e+1]=c[e];r[0]=0}return t}s*=Math.pow(2,8)}return new ArrayBuffer(0)}function s(){var n=new Uint8Array(this.value_hex),e,o,s,i,r,t,h;for(this.value_hex.byteLength>=2&&(e=n[0]==255&&n[1]&128,o=n[0]==0&&(n[1]&128)==0,(e||o)&&this.warnings.push("Needlessly long format")),s=new ArrayBuffer(this.value_hex.byteLength),i=new Uint8Array(s),r=0;r<this.value_hex.byteLength;r++)i[r]=0;i[0]=n[0]&128;var c=f(i,8),l=new ArrayBuffer(this.value_hex.byteLength),u=new Uint8Array(l);for(t=0;t<this.value_hex.byteLength;t++)u[t]=n[t];return u[0]&=127,h=f(u,8),h-c}function i(n){var t;if(r(n,0,n.byteLength)===!1)return new ArrayBuffer(0);var u=new Uint8Array(n),i=new ArrayBuffer(n.byteLength),f=new Uint8Array(i);for(t=0;t<n.byteLength;t++)f[t]=u[t];return i}function h(n,t,i){var u;if(r(n,t,i)===!1)return new ArrayBuffer(0);var e=new Uint8Array(n,t,i),f=new ArrayBuffer(i),o=new Uint8Array(f);for(u=0;u<i;u++)o[u]=e[u];return f}function e(n,t){for(var e=new Uint8Array(n),o=new Uint8Array(t),u=new ArrayBuffer(n.byteLength+t.byteLength),f=new Uint8Array(u),r,i=0;i<n.byteLength;i++)f[i]=e[i];for(r=0;r<t.byteLength;r++)f[n.byteLength+r]=o[r];return u}function r(n,t,i){return n instanceof ArrayBuffer==!1?(this.error='Wrong parameter: input_buffer must be "ArrayBuffer"',!1):n.byteLength===0?(this.error="Wrong parameter: input_buffer has zero length",!1):t<0?(this.error="Wrong parameter: input_offset less than zero",!1):i<0?(this.error="Wrong parameter: input_length less than zero",!1):n.byteLength-t-i<0?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0}function l(n,t,i){var u,e,f,o;if(r(n,t,i)===!1)return"";for(u="",e=new Uint8Array(n,t,i),f=0;f<e.length;f++)o=e[f].toString(16).toUpperCase(),u=u+(o.length===1?" 0":" ")+o;return u}function c(t,u,f){function v(n,t){if(n instanceof t)return n;var r=new t;return r.id_block=n.id_block,r.len_block=n.len_block,r.warnings=n.warnings,r.value_before_decode=i(n.value_before_decode),r}var a=u,e=new n.org.pkijs.asn1.ASN1_block,l,s,o,c;if(r(t,u,f)===!1)return e.error="Wrong input parameters",{offset:-1,result:e};if(l=new Uint8Array(t,u,f),l.length==0)return this.error="Zero buffer length",{offset:-1,result:e};if(s=e.id_block.fromBER(t,u,f),e.warnings.concat(e.id_block.warnings),s==-1)return e.error=e.id_block.error,{offset:-1,result:e};if(u=s,f-=e.id_block.block_length,s=e.len_block.fromBER(t,u,f),e.warnings.concat(e.len_block.warnings),s==-1)return e.error=e.len_block.error,{offset:-1,result:e};if(u=s,f-=e.len_block.block_length,e.id_block.is_constructed==!1&&e.len_block.is_indefinite_form==!0)return e.error=new String("Indefinite length form used for primitive encoding form"),{offset:-1,result:e};o=n.org.pkijs.asn1.ASN1_block;switch(e.id_block.tag_class){case 1:if(e.id_block.tag_number>=37&&e.id_block.is_hex_only==!1)return e.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:e};switch(e.id_block.tag_number){case 0:if(e.id_block.is_constructed==!0&&e.len_block.length>0)return e.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:e};o=n.org.pkijs.asn1.EOC;break;case 1:o=n.org.pkijs.asn1.BOOLEAN;break;case 2:o=n.org.pkijs.asn1.INTEGER;break;case 3:o=n.org.pkijs.asn1.BITSTRING;break;case 4:o=n.org.pkijs.asn1.OCTETSTRING;break;case 5:o=n.org.pkijs.asn1.NULL;break;case 6:o=n.org.pkijs.asn1.OID;break;case 10:o=n.org.pkijs.asn1.ENUMERATED;break;case 12:o=n.org.pkijs.asn1.UTF8STRING;break;case 14:o=n.org.pkijs.asn1.TIME;break;case 15:return e.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:e};case 16:o=n.org.pkijs.asn1.SEQUENCE;break;case 17:o=n.org.pkijs.asn1.SET;break;case 18:o=n.org.pkijs.asn1.NUMERICSTRING;break;case 19:o=n.org.pkijs.asn1.PRINTABLESTRING;break;case 20:o=n.org.pkijs.asn1.TELETEXSTRING;break;case 21:o=n.org.pkijs.asn1.VIDEOTEXSTRING;break;case 22:o=n.org.pkijs.asn1.IA5STRING;break;case 23:o=n.org.pkijs.asn1.UTCTIME;break;case 24:o=n.org.pkijs.asn1.GENERALIZEDTIME;break;case 25:o=n.org.pkijs.asn1.GRAPHICSTRING;break;case 26:o=n.org.pkijs.asn1.VISIBLESTRING;break;case 27:o=n.org.pkijs.asn1.GENERALSTRING;break;case 28:o=n.org.pkijs.asn1.UNIVERSALSTRING;break;case 29:o=n.org.pkijs.asn1.CHARACTERSTRING;break;case 30:o=n.org.pkijs.asn1.BMPSTRING;break;case 31:o=n.org.pkijs.asn1.DATE;break;case 33:o=n.org.pkijs.asn1.DATETIME;break;default:c=e.id_block.is_constructed==!0?new n.org.pkijs.asn1.ASN1_CONSTRUCTED:new n.org.pkijs.asn1.ASN1_PRIMITIVE;c.id_block=e.id_block;c.len_block=e.len_block;c.warnings=e.warnings;e=c;s=e.fromBER(t,u,f)}break;case 2:case 3:case 4:default:o=e.id_block.is_constructed==!0?n.org.pkijs.asn1.ASN1_CONSTRUCTED:n.org.pkijs.asn1.ASN1_PRIMITIVE}return e=v(e,o),s=e.fromBER(t,u,e.len_block.is_indefinite_form==!0?f:e.len_block.length),e.value_before_decode=h(t,a,e.block_length),{offset:s,result:e}}if(typeof n.org=="undefined")n.org={};else if(typeof n.org!="object")throw new Error("Name org already exists and it's not an object");if(typeof n.org.pkijs=="undefined")n.org.pkijs={};else if(typeof n.org.pkijs!="object")throw new Error("Name org.pkijs already exists and it's not an object but "+typeof n.org.pkijs);if(typeof n.org.pkijs.asn1=="undefined")n.org.pkijs.asn1={};else if(typeof n.org.pkijs.asn1!="object")throw new Error("Name org.pkijs.asn1 already exists and it's not an object but "+typeof n.org.pkijs.asn1);var t={};t.base_block=function(){arguments[0]instanceof Object?(this.block_length=n.org.pkijs.getValue(arguments[0],"block_length",0),this.error=n.org.pkijs.getValue(arguments[0],"error",new String),this.warnings=n.org.pkijs.getValue(arguments[0],"warnings",[]),this.value_before_decode="value_before_decode"in arguments[0]?i(arguments[0].value_before_decode):new ArrayBuffer(0)):(this.block_length=0,this.error=new String,this.warnings=[],this.value_before_decode=new ArrayBuffer(0))};t.base_block.prototype.block_name=function(){return"base_block"};t.base_block.prototype.toJSON=function(){return{block_name:t.base_block.prototype.block_name.call(this),block_length:this.block_length,error:this.error,warnings:this.warnings,value_before_decode:n.org.pkijs.bufferToHexCodes(this.value_before_decode,0,this.value_before_decode.byteLength)}};t.hex_block=function(){t.base_block.call(this,arguments[0]);arguments[0]instanceof Object?(this.is_hex_only=n.org.pkijs.getValue(arguments[0],"is_hex_only",!1),this.value_hex="value_hex"in arguments[0]?i(arguments[0].value_hex):new ArrayBuffer(0)):(this.is_hex_only=!1,this.value_hex=new ArrayBuffer(0))};t.hex_block.prototype=new t.base_block;t.hex_block.constructor=t.hex_block;t.hex_block.prototype.block_name=function(){return"hex_block"};t.hex_block.prototype.fromBER=function(n,t,i){var f,e,u;if(r.call(this,n,t,i)===!1)return-1;if(f=new Uint8Array(n,t,i),f.length==0)return this.warnings.push("Zero buffer length"),t;for(this.value_hex=new ArrayBuffer(i),e=new Uint8Array(this.value_hex),u=0;u<f.length;u++)e[u]=f[u];return this.block_length=i,t+i};t.hex_block.prototype.toBER=function(n){var i,u,r,t;if(typeof n=="undefined"&&(n=!1),this.is_hex_only!==!0)return this.error='Flag "is_hex_only" is not set, abort',new ArrayBuffer(0);if(i=new ArrayBuffer(this.value_hex.byteLength),n===!0)return i;for(u=new Uint8Array(i),r=new Uint8Array(this.value_hex),t=0;t<r.length;t++)u[t]=r[t];return i};t.hex_block.prototype.toJSON=function(){var i=t.base_block.prototype.toJSON.call(this);return i.block_name=t.hex_block.prototype.block_name.call(this),i.is_hex_only=this.is_hex_only,i.value_hex=n.org.pkijs.bufferToHexCodes(this.value_hex,0,this.value_hex.byteLength),i};t.identification_block=function(){t.hex_block.call(this,arguments[0]);this.tag_class=-1;this.tag_number=-1;this.is_constructed=!1;arguments[0]instanceof Object&&"id_block"in arguments[0]&&(this.is_hex_only=n.org.pkijs.getValue(arguments[0].id_block,"is_hex_only",!1),this.value_hex=n.org.pkijs.getValue(arguments[0].id_block,"value_hex",new ArrayBuffer(0)),this.tag_class=n.org.pkijs.getValue(arguments[0].id_block,"tag_class",-1),this.tag_number=n.org.pkijs.getValue(arguments[0].id_block,"tag_number",-1),this.is_constructed=n.org.pkijs.getValue(arguments[0].id_block,"is_constructed",!1))};t.identification_block.prototype=new t.hex_block;t.identification_block.constructor=t.identification_block;t.identification_block.prototype.block_name=function(){return"identification_block"};t.identification_block.prototype.toBER=function(n){var r,s,f,t,e,i;typeof n=="undefined"&&(n=!1);r=0;switch(this.tag_class){case 1:r|=0;break;case 2:r|=64;break;case 3:r|=128;break;case 4:r|=192;break;default:return this.error="Unknown tag class",new ArrayBuffer(0)}if(this.is_constructed&&(r|=32),this.tag_number<31&&!this.is_hex_only)return f=new ArrayBuffer(1),t=new Uint8Array(f),n||(s=this.tag_number,s&=31,r|=s,t[0]=r),f;if(this.is_hex_only===!1){var h=u(this.tag_number,7),c=new Uint8Array(h),o=h.byteLength,f=new ArrayBuffer(o+1),t=new Uint8Array(f);if(t[0]=r|31,!n){for(i=0;i<o-1;i++)t[i+1]=c[i]|128;t[o]=c[o-1]}return f}if(f=new ArrayBuffer(this.value_hex.byteLength+1),t=new Uint8Array(f),t[0]=r|31,n===!1){for(e=new Uint8Array(this.value_hex),i=0;i<e.length-1;i++)t[i+1]=e[i]|128;t[this.value_hex.byteLength]=e[e.length-1]}return f};t.identification_block.prototype.fromBER=function(n,t,i){var s,v,a,u,c,o,l,h,e;if(r.call(this,n,t,i)===!1)return-1;if(s=new Uint8Array(n,t,i),s.length==0)return this.error="Zero buffer length",-1;v=s[0]&192;switch(v){case 0:this.tag_class=1;break;case 64:this.tag_class=2;break;case 128:this.tag_class=3;break;case 192:this.tag_class=4;break;default:return this.error="Unknown tag class",-1}if(this.is_constructed=(s[0]&32)==32?!0:!1,this.is_hex_only=!1,a=s[0]&31,a!=31)this.tag_number=a,this.block_length=1;else{for(u=1,this.value_hex=new ArrayBuffer(255),c=255,o=new Uint8Array(this.value_hex);s[u]&128;){if(o[u-1]=s[u]&127,u++,u>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(u==c){for(c+=255,l=new ArrayBuffer(c),h=new Uint8Array(l),e=0;e<o.length;e++)h[e]=o[e];this.value_hex=new ArrayBuffer(c);o=new Uint8Array(this.value_hex)}}for(this.block_length=u+1,o[u-1]=s[u]&127,l=new ArrayBuffer(u),h=new Uint8Array(l),e=0;e<u;e++)h[e]=o[e];this.value_hex=new ArrayBuffer(u);o=new Uint8Array(this.value_hex);o.set(h);this.block_length<=9?this.tag_number=f(o,7):(this.is_hex_only=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tag_class==1&&this.is_constructed)switch(this.tag_number){case 1:case 2:case 5:case 6:case 9:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.block_length};t.identification_block.prototype.toJSON=function(){var n=t.hex_block.prototype.toJSON.call(this);return n.block_name=t.identification_block.prototype.block_name.call(this),n.tag_class=this.tag_class,n.tag_number=this.tag_number,n.is_constructed=this.is_constructed,n};t.length_block=function(){t.base_block.call(this,arguments[0]);this.is_indefinite_form=!1;this.long_form_used=!1;this.length=0;arguments[0]instanceof Object&&"len_block"in arguments[0]&&(this.is_indefinite_form=n.org.pkijs.getValue(arguments[0].len_block,"is_indefinite_form",!1),this.long_form_used=n.org.pkijs.getValue(arguments[0].len_block,"long_form_used",!1),this.length=n.org.pkijs.getValue(arguments[0].len_block,"length",0))};t.length_block.prototype=new t.base_block;t.length_block.constructor=t.length_block;t.length_block.prototype.block_name=function(){return"length_block"};t.length_block.prototype.fromBER=function(n,t,i){var u,e,s,o;if(r.call(this,n,t,i)===!1)return-1;if(u=new Uint8Array(n,t,i),u.length==0)return this.error="Zero buffer length",-1;if(u[0]==255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.is_indefinite_form=u[0]==128?!0:!1,this.is_indefinite_form==!0)return this.block_length=1,t+this.block_length;if(this.long_form_used=u[0]&128?!0:!1,this.long_form_used==!1)return this.length=u[0],this.block_length=1,t+this.block_length;if(e=u[0]&127,e>8)return this.error="Too big integer",-1;if(e+1>u.length)return this.error="End of input reached before message was fully decoded",-1;for(s=new Uint8Array(e),o=0;o<e;o++)s[o]=u[o+1];return s[e-1]==0&&this.warnings.push("Needlessly long encoded length"),this.length=f(s,8),this.long_form_used&&this.length<=127&&this.warnings.push("Unneccesary usage of long length form"),this.block_length=e+1,t+this.block_length};t.length_block.prototype.toBER=function(n){var r,e,f,t,i;if(typeof n=="undefined"&&(n=!1),this.length>127&&(this.long_form_used=!0),this.is_indefinite_form)return t=new ArrayBuffer(1),n===!1&&(i=new Uint8Array(t),i[0]=128),t;if(this.long_form_used===!0){if(r=u(this.length,8),r.byteLength>127)return this.error="Too big length",new ArrayBuffer(0);if(t=new ArrayBuffer(r.byteLength+1),n===!0)return t;for(e=new Uint8Array(r),i=new Uint8Array(t),i[0]=r.byteLength|128,f=0;f<r.byteLength;f++)i[f+1]=e[f];return t}return t=new ArrayBuffer(1),n===!1&&(i=new Uint8Array(t),i[0]=this.length),t};t.length_block.prototype.toJSON=function(){var n=t.base_block.prototype.toJSON.call(this);return n.block_name=t.length_block.prototype.block_name.call(this),n.is_indefinite_form=this.is_indefinite_form,n.long_form_used=this.long_form_used,n.length=this.length,n};t.value_block=function(){t.base_block.call(this,arguments[0])};t.value_block.prototype=new t.base_block;t.value_block.constructor=t.value_block;t.value_block.prototype.block_name=function(){return"value_block"};t.value_block.prototype.toJSON=function(){var n=t.base_block.prototype.toJSON.call(this);return n.block_name=t.value_block.prototype.block_name.call(this),n};n.org.pkijs.asn1.ASN1_block=function(){t.base_block.call(this,arguments[0]);arguments[0]instanceof Object&&(this.name=n.org.pkijs.getValue(arguments[0],"name",""),this.optional=n.org.pkijs.getValue(arguments[0],"optional",!1),"primitive_schema"in arguments[0]&&(this.primitive_schema=arguments[0].primitive_schema));this.id_block=new t.identification_block(arguments[0]);this.len_block=new t.length_block(arguments[0]);this.value_block=new t.value_block(arguments[0])};n.org.pkijs.asn1.ASN1_block.prototype=new t.base_block;n.org.pkijs.asn1.ASN1_block.constructor=n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.ASN1_block.prototype.block_name=function(){return"ASN1_block"};n.org.pkijs.asn1.ASN1_block.prototype.fromBER=function(n,t,i){var r=this.value_block.fromBER(n,t,this.len_block.is_indefinite_form==!0?i:this.len_block.length);return r==-1?(this.error=this.value_block.error,r):(this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),this.value_block.error.length==0&&(this.block_length+=this.value_block.block_length),r)};n.org.pkijs.asn1.ASN1_block.prototype.toBER=function(n){var t,u,f,o,s,i,r;return typeof n=="undefined"&&(n=!1),u=this.id_block.toBER(n),f=this.value_block.toBER(!0),this.len_block.length=f.byteLength,o=this.len_block.toBER(n),t=e(u,o),s=n===!1?this.value_block.toBER(n):new ArrayBuffer(this.len_block.length),t=e(t,s),this.len_block.is_indefinite_form===!0&&(i=new ArrayBuffer(2),n===!1&&(r=new Uint8Array(i),r[0]=0,r[1]=0),t=e(t,i)),t};n.org.pkijs.asn1.ASN1_block.prototype.toJSON=function(){var i=t.base_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.ASN1_block.prototype.block_name.call(this),i.id_block=this.id_block.toJSON(),i.len_block=this.len_block.toJSON(),i.value_block=this.value_block.toJSON(),"name"in this&&(i.name=this.name),"optional"in this&&(i.optional=this.optional),"primitive_schema"in this&&(i.primitive_schema=this.primitive_schema.toJSON()),i};t.ASN1_PRIMITIVE_value_block=function(){t.value_block.call(this,arguments[0]);arguments[0]instanceof Object?(this.value_hex="value_hex"in arguments[0]?i(arguments[0].value_hex):new ArrayBuffer(0),this.is_hex_only=n.org.pkijs.getValue(arguments[0],"is_hex_only",!0)):(this.value_hex=new ArrayBuffer(0),this.is_hex_only=!0)};t.ASN1_PRIMITIVE_value_block.prototype=new t.value_block;t.ASN1_PRIMITIVE_value_block.constructor=t.ASN1_PRIMITIVE_value_block;t.ASN1_PRIMITIVE_value_block.prototype.fromBER=function(n,t,i){var u,e,f;if(r.call(this,n,t,i)===!1)return-1;if(u=new Uint8Array(n,t,i),u.length==0)return this.warnings.push("Zero buffer length"),t;for(this.value_hex=new ArrayBuffer(u.length),e=new Uint8Array(this.value_hex),f=0;f<u.length;f++)e[f]=u[f];return this.block_length=i,t+i};t.ASN1_PRIMITIVE_value_block.prototype.toBER=function(){return i(this.value_hex)};t.ASN1_PRIMITIVE_value_block.prototype.block_name=function(){return"ASN1_PRIMITIVE_value_block"};t.ASN1_PRIMITIVE_value_block.prototype.toJSON=function(){var i=t.value_block.prototype.toJSON.call(this);return i.block_name=t.ASN1_PRIMITIVE_value_block.prototype.block_name.call(this),i.value_hex=n.org.pkijs.bufferToHexCodes(this.value_hex,0,this.value_hex.byteLength),i.is_hex_only=this.is_hex_only,i};n.org.pkijs.asn1.ASN1_PRIMITIVE=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.id_block.is_constructed=!1;this.value_block=new t.ASN1_PRIMITIVE_value_block(arguments[0])};n.org.pkijs.asn1.ASN1_PRIMITIVE.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.ASN1_PRIMITIVE.constructor=n.org.pkijs.asn1.ASN1_PRIMITIVE;n.org.pkijs.asn1.ASN1_PRIMITIVE.prototype.block_name=function(){return"PRIMITIVE"};n.org.pkijs.asn1.ASN1_PRIMITIVE.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.ASN1_PRIMITIVE.prototype.block_name.call(this),t};t.ASN1_CONSTRUCTED_value_block=function(){t.value_block.call(this,arguments[0]);arguments[0]instanceof Object?(this.value=n.org.pkijs.getValue(arguments[0],"value",[]),this.is_indefinite_form=n.org.pkijs.getValue(arguments[0],"is_indefinite_form",!1)):(this.value=[],this.is_indefinite_form=!1)};t.ASN1_CONSTRUCTED_value_block.prototype=new t.value_block;t.ASN1_CONSTRUCTED_value_block.constructor=t.ASN1_CONSTRUCTED_value_block;t.ASN1_CONSTRUCTED_value_block.prototype.fromBER=function(t,i,u){function a(n,t){return n==!0?1:t}var s=i,l=u,o,e,f;if(r.call(this,t,i,u)===!1)return-1;if(o=new Uint8Array(t,i,u),o.length==0)return this.warnings.push("Zero buffer length"),i;for(e=i;a(this.is_indefinite_form,u)>0;){if(f=c(t,e,u),f.offset==-1)return this.error=f.result.error,this.warnings.concat(f.result.warnings),-1;if(e=f.offset,this.block_length+=f.result.block_length,u-=f.result.block_length,this.value.push(f.result),this.is_indefinite_form==!0&&f.result.block_name()==n.org.pkijs.asn1.EOC.prototype.block_name())break}return this.is_indefinite_form==!0&&(this.value[this.value.length-1].block_name()==n.org.pkijs.asn1.EOC.prototype.block_name()?this.value.pop():this.warnings.push("No EOC block encoded")),this.value_before_decode=h(t,s,l),e};t.ASN1_CONSTRUCTED_value_block.prototype.toBER=function(n){var t,i,r;for(typeof n=="undefined"&&(n=!1),t=new ArrayBuffer(0),i=0;i<this.value.length;i++)r=this.value[i].toBER(n),t=e(t,r);return t};t.ASN1_CONSTRUCTED_value_block.prototype.block_name=function(){return"ASN1_CONSTRUCTED_value_block"};t.ASN1_CONSTRUCTED_value_block.prototype.toJSON=function(){var n=t.value_block.prototype.toJSON.call(this),i;for(n.block_name=t.ASN1_CONSTRUCTED_value_block.prototype.block_name.call(this),n.is_indefinite_form=this.is_indefinite_form,n.value=[],i=0;i<this.value.length;i++)n.value.push(this.value[i].toJSON());return n};n.org.pkijs.asn1.ASN1_CONSTRUCTED=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.id_block.is_constructed=!0;this.value_block=new t.ASN1_CONSTRUCTED_value_block(arguments[0])};n.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.ASN1_CONSTRUCTED.constructor=n.org.pkijs.asn1.ASN1_CONSTRUCTED;n.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.block_name=function(){return"CONSTRUCTED"};n.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.fromBER=function(n,t,i){this.value_block.is_indefinite_form=this.len_block.is_indefinite_form;var r=this.value_block.fromBER(n,t,this.len_block.is_indefinite_form==!0?i:this.len_block.length);return r==-1?(this.error=this.value_block.error,r):(this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),this.value_block.error.length==0&&(this.block_length+=this.value_block.block_length),r)};n.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.block_name.call(this),t};t.EOC_value_block=function(){t.value_block.call(this,arguments[0])};t.EOC_value_block.prototype=new t.value_block;t.EOC_value_block.constructor=t.EOC_value_block;t.EOC_value_block.prototype.fromBER=function(n,t){return t};t.EOC_value_block.prototype.toBER=function(){return new ArrayBuffer(0)};t.EOC_value_block.prototype.block_name=function(){return"EOC_value_block"};t.EOC_value_block.prototype.toJSON=function(){var n=t.value_block.prototype.toJSON.call(this);return n.block_name=t.EOC_value_block.prototype.block_name.call(this),n};n.org.pkijs.asn1.EOC=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.EOC_value_block;this.id_block.tag_class=1;this.id_block.tag_number=0};n.org.pkijs.asn1.EOC.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.EOC.constructor=t.EOC_value_block;n.org.pkijs.asn1.EOC.prototype.block_name=function(){return"END_OF_CONTENT"};n.org.pkijs.asn1.EOC.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.EOC.prototype.block_name.call(this),t};t.BOOLEAN_value_block=function(){if(t.value_block.call(this,arguments[0]),arguments[0]instanceof Object){if(this.value=n.org.pkijs.getValue(arguments[0],"value",!1),this.is_hex_only=n.org.pkijs.getValue(arguments[0],"is_hex_only",!1),"value_hex"in arguments[0])this.value_hex=i(arguments[0].value_hex);else if(this.value_hex=new ArrayBuffer(1),this.value===!0){var r=new Uint8Array(this.value_hex);r[0]=255}}else this.value=!1,this.is_hex_only=!1,this.value_hex=new ArrayBuffer(1)};t.BOOLEAN_value_block.prototype=new t.value_block;t.BOOLEAN_value_block.constructor=t.BOOLEAN_value_block;t.BOOLEAN_value_block.prototype.fromBER=function(n,t,i){var u,e,f;if(r.call(this,n,t,i)===!1)return-1;for(u=new Uint8Array(n,t,i),i>1&&this.warnings.push("BOOLEAN value encoded in more then 1 octet"),this.value=u[0]==0?!1:!0,this.is_hex_only=!0,this.value_hex=new ArrayBuffer(u.length),e=new Uint8Array(this.value_hex),f=0;f<u.length;f++)e[f]=u[f];return this.block_length=i,t+i};t.BOOLEAN_value_block.prototype.toBER=function(n){return typeof n=="undefined"&&(n=!1),this.value_hex};t.BOOLEAN_value_block.prototype.block_name=function(){return"BOOLEAN_value_block"};t.BOOLEAN_value_block.prototype.toJSON=function(){var i=t.value_block.prototype.toJSON.call(this);return i.block_name=t.BOOLEAN_value_block.prototype.block_name.call(this),i.value=this.value,i.is_hex_only=this.is_hex_only,i.value_hex=n.org.pkijs.bufferToHexCodes(this.value_hex,0,this.value_hex.byteLength),i};n.org.pkijs.asn1.BOOLEAN=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.BOOLEAN_value_block(arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=1};n.org.pkijs.asn1.BOOLEAN.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.BOOLEAN.constructor=t.BOOLEAN_value_block;n.org.pkijs.asn1.BOOLEAN.prototype.block_name=function(){return"BOOLEAN"};n.org.pkijs.asn1.BOOLEAN.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.BOOLEAN.prototype.block_name.call(this),t};n.org.pkijs.asn1.SEQUENCE=function(){n.org.pkijs.asn1.ASN1_CONSTRUCTED.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=16};n.org.pkijs.asn1.SEQUENCE.prototype=new n.org.pkijs.asn1.ASN1_CONSTRUCTED;n.org.pkijs.asn1.SEQUENCE.constructor=n.org.pkijs.asn1.SEQUENCE;n.org.pkijs.asn1.SEQUENCE.prototype.block_name=function(){return"SEQUENCE"};n.org.pkijs.asn1.SEQUENCE.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.SEQUENCE.prototype.block_name.call(this),t};n.org.pkijs.asn1.SET=function(){n.org.pkijs.asn1.ASN1_CONSTRUCTED.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=17};n.org.pkijs.asn1.SET.prototype=new n.org.pkijs.asn1.ASN1_CONSTRUCTED;n.org.pkijs.asn1.SET.constructor=n.org.pkijs.asn1.SET;n.org.pkijs.asn1.SET.prototype.block_name=function(){return"SET"};n.org.pkijs.asn1.SET.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_CONSTRUCTED.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.SET.prototype.block_name.call(this),t};n.org.pkijs.asn1.NULL=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=5};n.org.pkijs.asn1.NULL.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.NULL.constructor=n.org.pkijs.asn1.NULL;n.org.pkijs.asn1.NULL.prototype.block_name=function(){return"NULL"};n.org.pkijs.asn1.NULL.prototype.fromBER=function(n,t,i){return this.len_block.length>0&&this.warnings.push("Non-zero length of value block for NULL type"),this.id_block.error.length===0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length===0&&(this.block_length+=this.len_block.block_length),this.block_length+=i,t+i};n.org.pkijs.asn1.NULL.prototype.toBER=function(n){var t,i;return(typeof n=="undefined"&&(n=!1),t=new ArrayBuffer(2),n===!0)?t:(i=new Uint8Array(t),i[0]=5,i[1]=0,t)};n.org.pkijs.asn1.NULL.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.NULL.prototype.block_name.call(this),t};t.OCTETSTRING_value_block=function(){t.ASN1_CONSTRUCTED_value_block.call(this,arguments[0]);arguments[0]instanceof Object?(this.is_constructed=n.org.pkijs.getValue(arguments[0],"is_constructed",!1),this.is_hex_only=n.org.pkijs.getValue(arguments[0],"is_hex_only",!1),this.value_hex="value_hex"in arguments[0]?i(arguments[0].value_hex):new ArrayBuffer(0)):(this.is_constructed=!1,this.is_hex_only=!1,this.value_hex=new ArrayBuffer(0))};t.OCTETSTRING_value_block.prototype=new t.ASN1_CONSTRUCTED_value_block;t.OCTETSTRING_value_block.constructor=t.OCTETSTRING_value_block;t.OCTETSTRING_value_block.prototype.fromBER=function(i,r,u){var f=0,e,o;if(this.is_constructed==!0){if(this.is_hex_only=!1,f=t.ASN1_CONSTRUCTED_value_block.prototype.fromBER.call(this,i,r,u),f==-1)return f;for(e=0;e<this.value.length;e++){if(o=this.value[e].block_name(),o==n.org.pkijs.asn1.EOC.prototype.block_name())if(this.is_indefinite_form==!0)break;else return this.error="EOC is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1;if(o!=n.org.pkijs.asn1.OCTETSTRING.prototype.block_name())return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.is_hex_only=!0,f=t.hex_block.prototype.fromBER.call(this,i,r,u),this.block_length=u;return f};t.OCTETSTRING_value_block.prototype.toBER=function(n){if(typeof n=="undefined"&&(n=!1),this.is_constructed===!0)return t.ASN1_CONSTRUCTED_value_block.prototype.toBER.call(this,n);var r=new ArrayBuffer(this.value_hex.byteLength);return n===!0?r:this.value_hex.byteLength==0?r:i(this.value_hex)};t.OCTETSTRING_value_block.prototype.block_name=function(){return"OCTETSTRING_value_block"};t.OCTETSTRING_value_block.prototype.toJSON=function(){var i=t.ASN1_CONSTRUCTED_value_block.prototype.toJSON.call(this);return i.block_name=t.OCTETSTRING_value_block.prototype.block_name.call(this),i.is_constructed=this.is_constructed,i.is_hex_only=this.is_hex_only,i.value_hex=n.org.pkijs.bufferToHexCodes(this.value_hex,0,this.value_hex.byteLength),i};n.org.pkijs.asn1.OCTETSTRING=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.OCTETSTRING_value_block(arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=4};n.org.pkijs.asn1.OCTETSTRING.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.OCTETSTRING.constructor=n.org.pkijs.asn1.OCTETSTRING;n.org.pkijs.asn1.OCTETSTRING.prototype.fromBER=function(t,i,r){return(this.value_block.is_constructed=this.id_block.is_constructed,this.value_block.is_indefinite_form=this.len_block.is_indefinite_form,r==0)?(this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),i):n.org.pkijs.asn1.ASN1_block.prototype.fromBER.call(this,t,i,r)};n.org.pkijs.asn1.OCTETSTRING.prototype.block_name=function(){return"OCTETSTRING"};n.org.pkijs.asn1.OCTETSTRING.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.OCTETSTRING.prototype.block_name.call(this),t};t.BITSTRING_value_block=function(){t.ASN1_CONSTRUCTED_value_block.call(this,arguments[0]);arguments[0]instanceof Object?(this.unused_bits=n.org.pkijs.getValue(arguments[0],"unused_bits",0),this.is_constructed=n.org.pkijs.getValue(arguments[0],"is_constructed",!1),this.is_hex_only=n.org.pkijs.getValue(arguments[0],"is_hex_only",!1),this.value_hex="value_hex"in arguments[0]?i(arguments[0].value_hex):new ArrayBuffer(0),this.block_length=this.value_hex.byteLength):(this.unused_bits=0,this.is_constructed=!1,this.is_hex_only=!1,this.value_hex=new ArrayBuffer(0))};t.BITSTRING_value_block.prototype=new t.ASN1_CONSTRUCTED_value_block;t.BITSTRING_value_block.constructor=t.BITSTRING_value_block;t.BITSTRING_value_block.prototype.fromBER=function(i,u,f){var o,h,s,c,e;if(f==0)return u;if(o=-1,this.is_constructed==!0){if(o=t.ASN1_CONSTRUCTED_value_block.prototype.fromBER.call(this,i,u,f),o==-1)return o;for(e=0;e<this.value.length;e++){if(h=this.value[e].block_name(),h==n.org.pkijs.asn1.EOC.prototype.block_name())if(this.is_indefinite_form==!0)break;else return this.error="EOC is unexpected, BIT STRING may consists of BIT STRINGs only",-1;if(h!=n.org.pkijs.asn1.BITSTRING.prototype.block_name())return this.error="BIT STRING may consists of BIT STRINGs only",-1;if(this.unused_bits>0&&this.value[e].unused_bits>0)return this.error='Usign of "unused bits" inside constructive BIT STRING allowed for least one only',-1;if(this.unused_bits=this.value[e].unused_bits,this.unused_bits>7)return this.error="Unused bits for BITSTRING must be in range 0-7",-1}return o}if(r.call(this,i,u,f)===!1)return-1;if(s=new Uint8Array(i,u,f),this.unused_bits=s[0],this.unused_bits>7)return this.error="Unused bits for BITSTRING must be in range 0-7",-1;for(this.value_hex=new ArrayBuffer(s.length-1),c=new Uint8Array(this.value_hex),e=0;e<f-1;e++)c[e]=s[e+1];return this.block_length=s.length,u+f};t.BITSTRING_value_block.prototype.toBER=function(n){var i;if(typeof n=="undefined"&&(n=!1),this.is_constructed===!0)return t.ASN1_CONSTRUCTED_value_block.prototype.toBER.call(this,n);if(n===!0)return new ArrayBuffer(this.value_hex.byteLength+1);if(this.value_hex.byteLength==0)return new ArrayBuffer(0);var f=new Uint8Array(this.value_hex),r=new ArrayBuffer(this.value_hex.byteLength+1),u=new Uint8Array(r);for(u[0]=this.unused_bits,i=0;i<this.value_hex.byteLength;i++)u[i+1]=f[i];return r};t.BITSTRING_value_block.prototype.block_name=function(){return"BITSTRING_value_block"};t.BITSTRING_value_block.prototype.toJSON=function(){var i=t.ASN1_CONSTRUCTED_value_block.prototype.toJSON.call(this);return i.block_name=t.BITSTRING_value_block.prototype.block_name.call(this),i.unused_bits=this.unused_bits,i.is_constructed=this.is_constructed,i.is_hex_only=this.is_hex_only,i.value_hex=n.org.pkijs.bufferToHexCodes(this.value_hex,0,this.value_hex.byteLength),i};n.org.pkijs.asn1.BITSTRING=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.BITSTRING_value_block(arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=3};n.org.pkijs.asn1.BITSTRING.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.BITSTRING.constructor=n.org.pkijs.asn1.BITSTRING;n.org.pkijs.asn1.BITSTRING.prototype.block_name=function(){return"BITSTRING"};n.org.pkijs.asn1.BITSTRING.prototype.fromBER=function(t,i,r){return r==0?i:(this.value_block.is_constructed=this.id_block.is_constructed,this.value_block.is_indefinite_form=this.len_block.is_indefinite_form,n.org.pkijs.asn1.ASN1_block.prototype.fromBER.call(this,t,i,r))};n.org.pkijs.asn1.BITSTRING.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.BITSTRING.prototype.block_name.call(this),t};t.INTEGER_value_block=function(){t.value_block.call(this,arguments[0]);arguments[0]instanceof Object?(this.value_dec=n.org.pkijs.getValue(arguments[0],"value",0),this.is_hex_only=n.org.pkijs.getValue(arguments[0],"is_hex_only",!1),"value_hex"in arguments[0]?(this.value_hex=i(arguments[0].value_hex),this.value_hex.byteLength>=4?this.is_hex_only=!0:this.value_dec=s.call(this)):this.value_hex=o(this.value_dec)):(this.value_dec=0,this.is_hex_only=!1,this.value_hex=new ArrayBuffer(0))};t.INTEGER_value_block.prototype=new t.value_block;t.INTEGER_value_block.constructor=t.INTEGER_value_block;t.INTEGER_value_block.prototype.fromBER=function(n,i,r){var u=t.hex_block.prototype.fromBER.call(this,n,i,r);return u==-1?u:(this.value_hex.byteLength>4?(this.warnings.push("Too big INTEGER for decoding, hex only"),this.is_hex_only=!0):this.value_dec=s.call(this),this.block_length=r,i+r)};t.INTEGER_value_block.prototype.toBER=function(n){if(typeof n=="undefined"&&(n=!1),this.is_hex_only===!1){var t=o(this.value_dec);return t.byteLength==0?(this.error="Error during encoding INTEGER value",new ArrayBuffer(0)):i(t)}return i(this.value_hex)};t.INTEGER_value_block.prototype.block_name=function(){return"INTEGER_value_block"};t.INTEGER_value_block.prototype.toJSON=function(){var i=t.value_block.prototype.toJSON.call(this);return i.block_name=t.INTEGER_value_block.prototype.block_name.call(this),i.value_dec=this.value_dec,i.is_hex_only=this.is_hex_only,i.value_hex=n.org.pkijs.bufferToHexCodes(this.value_hex,0,this.value_hex.byteLength),i};n.org.pkijs.asn1.INTEGER=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.INTEGER_value_block(arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=2};n.org.pkijs.asn1.INTEGER.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.INTEGER.constructor=n.org.pkijs.asn1.INTEGER;n.org.pkijs.asn1.INTEGER.prototype.block_name=function(){return"INTEGER"};n.org.pkijs.asn1.INTEGER.prototype.isEqual=function(){return arguments[0]instanceof n.org.pkijs.asn1.INTEGER?this.value_block.is_hex_only&&arguments[0].value_block.is_hex_only?n.org.pkijs.isEqual_buffer(this.value_block.value_hex,arguments[0].value_block.value_hex):this.value_block.is_hex_only===arguments[0].value_block.is_hex_only?this.value_block.value_dec==arguments[0].value_block.value_dec:!1:arguments[0]instanceof ArrayBuffer?n.org.pkijs.isEqual_buffer(this.value_block.value_hex,arguments[0].value_block.value_hex):!1};n.org.pkijs.asn1.INTEGER.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.INTEGER.prototype.block_name.call(this),t};n.org.pkijs.asn1.ENUMERATED=function(){n.org.pkijs.asn1.INTEGER.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=10};n.org.pkijs.asn1.ENUMERATED.prototype=new n.org.pkijs.asn1.INTEGER;n.org.pkijs.asn1.ENUMERATED.constructor=n.org.pkijs.asn1.ENUMERATED;n.org.pkijs.asn1.ENUMERATED.prototype.block_name=function(){return"ENUMERATED"};n.org.pkijs.asn1.ENUMERATED.prototype.toJSON=function(){var t=n.org.pkijs.asn1.INTEGER.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.ENUMERATED.prototype.block_name.call(this),t};t.SID_value_block=function(){t.hex_block.call(this,arguments[0]);arguments[0]instanceof Object?(this.value_dec=n.org.pkijs.getValue(arguments[0],"value_dec",-1),this.is_first_sid=n.org.pkijs.getValue(arguments[0],"is_first_sid",!1)):(this.value_dec=-1,this.is_first_sid=!1)};t.SID_value_block.prototype=new t.hex_block;t.SID_value_block.constructor=t.SID_value_block;t.SID_value_block.prototype.block_name=function(){return"sid_block"};t.SID_value_block.prototype.fromBER=function(n,t,u){var s,o,h,c,e;if(u==0)return t;if(r.call(this,n,t,u)===!1)return-1;for(s=new Uint8Array(n,t,u),this.value_hex=new ArrayBuffer(u),o=new Uint8Array(this.value_hex),e=0;e<u;e++)if(o[e]=s[e]&127,this.block_length++,(s[e]&128)==0)break;for(h=new ArrayBuffer(this.block_length),c=new Uint8Array(h),e=0;e<this.block_length;e++)c[e]=o[e];return(this.value_hex=i(h),o=new Uint8Array(this.value_hex),(s[this.block_length-1]&128)!=0)?(this.error="End of input reached before message was fully decoded",-1):(o[0]==0&&this.warnings.push("Needlessly long format of SID encoding"),this.block_length<=8?this.value_dec=f(o,7):(this.is_hex_only=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.block_length)};t.SID_value_block.prototype.toBER=function(n){var i,f,e,r,t;if(typeof n=="undefined"&&(n=!1),this.is_hex_only){if(n===!0)return new ArrayBuffer(this.value_hex.byteLength);var o=new Uint8Array(this.value_hex),f=new ArrayBuffer(this.block_length),r=new Uint8Array(f);for(t=0;t<this.block_length-1;t++)r[t]=o[t]|128;r[this.block_length-1]=o[this.block_length-1]}if(i=u(this.value_dec,7),i.byteLength===0)return this.error="Error during encoding SID value",new ArrayBuffer(0);if(f=new ArrayBuffer(i.byteLength),n===!1){for(e=new Uint8Array(i),r=new Uint8Array(f),t=0;t<i.byteLength-1;t++)r[t]=e[t]|128;r[i.byteLength-1]=e[i.byteLength-1]}return f};t.SID_value_block.prototype.toString=function(){var n="",t;return this.is_hex_only===!0?n=l(this.value_hex):this.is_first_sid?(t=this.value_dec,this.value_dec<=39?n="0.":this.value_dec<=79?(n="1.",t-=40):(n="2.",t-=80),n=n+t.toString()):n=this.value_dec.toString(),n};t.SID_value_block.prototype.toJSON=function(){var n=t.hex_block.prototype.toJSON.call(this);return n.block_name=t.SID_value_block.prototype.block_name.call(this),n.value_dec=this.value_dec,n.is_first_sid=this.is_first_sid,n};t.OID_value_block=function(){t.value_block.call(this,arguments[0]);this.value=[];arguments[0]instanceof Object&&this.fromString(n.org.pkijs.getValue(arguments[0],"value",""))};t.OID_value_block.prototype=new t.value_block;t.OID_value_block.constructor=t.OID_value_block;t.OID_value_block.prototype.fromBER=function(n,i,r){for(var f=i,u;r>0;){if(u=new t.SID_value_block,f=u.fromBER(n,f,r),f==-1)return this.block_length=0,this.error=u.error,f;this.value.length==0&&(u.is_first_sid=!0);this.block_length+=u.block_length;r-=u.block_length;this.value.push(u)}return f};t.OID_value_block.prototype.toBER=function(n){var i,t,r;for(typeof n=="undefined"&&(n=!1),i=new ArrayBuffer(0),t=0;t<this.value.length;t++){if(r=this.value[t].toBER(n),r.byteLength===0)return this.error=this.value[t].error,new ArrayBuffer(0);i=e(i,r)}return i};t.OID_value_block.prototype.fromString=function(n){var f,s,i;this.value=[];var r=0,u=0,e="",o=!1;do if(u=n.indexOf(".",r),e=u===-1?n.substr(r):n.substr(r,u-r),r=u+1,o){i=this.value[0];f=0;switch(i.value_dec){case 0:break;case 1:f=40;break;case 2:f=80;break;default:return this.value=[],!1}if(s=parseInt(e,10),Number.isNaN(s))return!0;i.value_dec=s+f;o=!1}else{if(i=new t.SID_value_block,i.value_dec=parseInt(e,10),Number.isNaN(i.value_dec))return!0;this.value.length===0&&(i.is_first_sid=!0,o=!0);this.value.push(i)}while(u!==-1);return!0};t.OID_value_block.prototype.toString=function(){for(var n="",r=!1,i,t=0;t<this.value.length;t++)r=this.value[t].is_hex_only,i=this.value[t].toString(),t!==0&&(n=n+"."),r?(i="{"+i+"}",n=this.value[t].is_first_sid?"2.{"+i+" - 80}":n+i):n=n+i;return n};t.OID_value_block.prototype.block_name=function(){return"OID_value_block"};t.OID_value_block.prototype.toJSON=function(){var n=t.value_block.prototype.toJSON.call(this),i;for(n.block_name=t.OID_value_block.prototype.block_name.call(this),n.value=t.OID_value_block.prototype.toString.call(this),n.sid_array=[],i=0;i<this.value.length;i++)n.sid_array.push(this.value[i].toJSON());return n};n.org.pkijs.asn1.OID=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.OID_value_block(arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=6};n.org.pkijs.asn1.OID.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.OID.constructor=n.org.pkijs.asn1.OID;n.org.pkijs.asn1.OID.prototype.block_name=function(){return"OID"};n.org.pkijs.asn1.OID.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.OID.prototype.block_name.call(this),t};t.UTF8STRING_value_block=function(){t.hex_block.call(this,arguments[0]);this.is_hex_only=!0;this.value=""};t.UTF8STRING_value_block.prototype=new t.hex_block;t.UTF8STRING_value_block.constructor=t.UTF8STRING_value_block;t.UTF8STRING_value_block.prototype.block_name=function(){return"UTF8STRING_value_block"};t.UTF8STRING_value_block.prototype.toJSON=function(){var n=t.hex_block.prototype.toJSON.call(this);return n.block_name=t.UTF8STRING_value_block.prototype.block_name.call(this),n.value=this.value,n};n.org.pkijs.asn1.UTF8STRING=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.UTF8STRING_value_block;arguments[0]instanceof Object&&"value"in arguments[0]&&n.org.pkijs.asn1.UTF8STRING.prototype.fromString.call(this,arguments[0].value);this.id_block.tag_class=1;this.id_block.tag_number=12};n.org.pkijs.asn1.UTF8STRING.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.UTF8STRING.constructor=n.org.pkijs.asn1.UTF8STRING;n.org.pkijs.asn1.UTF8STRING.prototype.block_name=function(){return"UTF8STRING"};n.org.pkijs.asn1.UTF8STRING.prototype.fromBER=function(t,i,r){var u=this.value_block.fromBER(t,i,this.len_block.is_indefinite_form==!0?r:this.len_block.length);return u==-1?(this.error=this.value_block.error,u):(n.org.pkijs.asn1.UTF8STRING.prototype.fromBuffer.call(this,this.value_block.value_hex),this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),this.value_block.error.length==0&&(this.block_length+=this.value_block.block_length),u)};n.org.pkijs.asn1.UTF8STRING.prototype.fromBuffer=function(n){this.value_block.value=String.fromCharCode.apply(null,new Uint8Array(n));try{this.value_block.value=decodeURIComponent(escape(this.value_block.value))}catch(t){this.warnings.push('Error during "decodeURIComponent": '+t+", using raw string")}};n.org.pkijs.asn1.UTF8STRING.prototype.fromString=function(n){var i=unescape(encodeURIComponent(n)),r=i.length,u,t;for(this.value_block.value_hex=new ArrayBuffer(r),u=new Uint8Array(this.value_block.value_hex),t=0;t<r;t++)u[t]=i.charCodeAt(t);this.value_block.value=n};n.org.pkijs.asn1.UTF8STRING.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.UTF8STRING.prototype.block_name.call(this),t};t.BMPSTRING_value_block=function(){t.hex_block.call(this,arguments[0]);this.is_hex_only=!0;this.value=""};t.BMPSTRING_value_block.prototype=new t.hex_block;t.BMPSTRING_value_block.constructor=t.BMPSTRING_value_block;t.BMPSTRING_value_block.prototype.block_name=function(){return"BMPSTRING_value_block"};t.BMPSTRING_value_block.prototype.toJSON=function(){var n=t.hex_block.prototype.toJSON.call(this);return n.block_name=t.BMPSTRING_value_block.prototype.block_name.call(this),n.value=this.value,n};n.org.pkijs.asn1.BMPSTRING=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.BMPSTRING_value_block;arguments[0]instanceof Object&&"value"in arguments[0]&&n.org.pkijs.asn1.BMPSTRING.prototype.fromString.call(this,arguments[0].value);this.id_block.tag_class=1;this.id_block.tag_number=30};n.org.pkijs.asn1.BMPSTRING.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.BMPSTRING.constructor=n.org.pkijs.asn1.BMPSTRING;n.org.pkijs.asn1.BMPSTRING.prototype.block_name=function(){return"BMPSTRING"};n.org.pkijs.asn1.BMPSTRING.prototype.fromBER=function(t,i,r){var u=this.value_block.fromBER(t,i,this.len_block.is_indefinite_form==!0?r:this.len_block.length);return u==-1?(this.error=this.value_block.error,u):(n.org.pkijs.asn1.BMPSTRING.prototype.fromBuffer.call(this,this.value_block.value_hex),this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),this.value_block.error.length==0&&(this.block_length+=this.value_block.block_length),u)};n.org.pkijs.asn1.BMPSTRING.prototype.fromBuffer=function(t){for(var u=n.org.pkijs.copyBuffer(t),r=new Uint8Array(u),f,i=0;i<r.length;i=i+2)f=r[i],r[i]=r[i+1],r[i+1]=f;this.value_block.value=String.fromCharCode.apply(null,new Uint16Array(u))};n.org.pkijs.asn1.BMPSTRING.prototype.fromString=function(n){var f=n.length,e,t,o,i,s,r;for(this.value_block.value_hex=new ArrayBuffer(f*2),e=new Uint8Array(this.value_block.value_hex),t=0;t<f;t++)if(o=u(n.charCodeAt(t),8),i=new Uint8Array(o),!(i.length>2))for(s=2-i.length,r=i.length-1;r>=0;r--)e[t*2+r+s]=i[r];this.value_block.value=n};n.org.pkijs.asn1.BMPSTRING.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.BMPSTRING.prototype.block_name.call(this),t};t.UNIVERSALSTRING_value_block=function(){t.hex_block.call(this,arguments[0]);this.is_hex_only=!0;this.value=""};t.UNIVERSALSTRING_value_block.prototype=new t.hex_block;t.UNIVERSALSTRING_value_block.constructor=t.UNIVERSALSTRING_value_block;t.UNIVERSALSTRING_value_block.prototype.block_name=function(){return"UNIVERSALSTRING_value_block"};t.UNIVERSALSTRING_value_block.prototype.toJSON=function(){var n=t.hex_block.prototype.toJSON.call(this);return n.block_name=t.UNIVERSALSTRING_value_block.prototype.block_name.call(this),n.value=this.value,n};n.org.pkijs.asn1.UNIVERSALSTRING=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.UNIVERSALSTRING_value_block;arguments[0]instanceof Object&&"value"in arguments[0]&&n.org.pkijs.asn1.UNIVERSALSTRING.prototype.fromString.call(this,arguments[0].value);this.id_block.tag_class=1;this.id_block.tag_number=28};n.org.pkijs.asn1.UNIVERSALSTRING.prototype=new n.org.pkijs.asn1.ASN1_block;n.org.pkijs.asn1.UNIVERSALSTRING.constructor=n.org.pkijs.asn1.UNIVERSALSTRING;n.org.pkijs.asn1.UNIVERSALSTRING.prototype.block_name=function(){return"UNIVERSALSTRING"};n.org.pkijs.asn1.UNIVERSALSTRING.prototype.fromBER=function(t,i,r){var u=this.value_block.fromBER(t,i,this.len_block.is_indefinite_form==!0?r:this.len_block.length);return u==-1?(this.error=this.value_block.error,u):(n.org.pkijs.asn1.UNIVERSALSTRING.prototype.fromBuffer.call(this,this.value_block.value_hex),this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),this.value_block.error.length==0&&(this.block_length+=this.value_block.block_length),u)};n.org.pkijs.asn1.UNIVERSALSTRING.prototype.fromBuffer=function(t){for(var u=n.org.pkijs.copyBuffer(t),r=new Uint8Array(u),i=0;i<r.length;i=i+4)r[i]=r[i+3],r[i+1]=r[i+2],r[i+2]=0,r[i+3]=0;this.value_block.value=String.fromCharCode.apply(null,new Uint32Array(u))};n.org.pkijs.asn1.UNIVERSALSTRING.prototype.fromString=function(n){var f=n.length,e,t,o,i,s,r;for(this.value_block.value_hex=new ArrayBuffer(f*4),e=new Uint8Array(this.value_block.value_hex),t=0;t<f;t++)if(o=u(n.charCodeAt(t),8),i=new Uint8Array(o),!(i.length>4))for(s=4-i.length,r=i.length-1;r>=0;r--)e[t*4+r+s]=i[r];this.value_block.value=n};n.org.pkijs.asn1.UNIVERSALSTRING.prototype.toJSON=function(){var t=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.UNIVERSALSTRING.prototype.block_name.call(this),t};t.SIMPLESTRING_value_block=function(){t.hex_block.call(this,arguments[0]);this.value="";this.is_hex_only=!0};t.SIMPLESTRING_value_block.prototype=new t.hex_block;t.SIMPLESTRING_value_block.constructor=t.SIMPLESTRING_value_block;t.SIMPLESTRING_value_block.prototype.block_name=function(){return"SIMPLESTRING_value_block"};t.SIMPLESTRING_value_block.prototype.toJSON=function(){var n=t.hex_block.prototype.toJSON.call(this);return n.block_name=t.SIMPLESTRING_value_block.prototype.block_name.call(this),n.value=this.value,n};t.SIMPLESTRING_block=function(){n.org.pkijs.asn1.ASN1_block.call(this,arguments[0]);this.value_block=new t.SIMPLESTRING_value_block;arguments[0]instanceof Object&&"value"in arguments[0]&&t.SIMPLESTRING_block.prototype.fromString.call(this,arguments[0].value)};t.SIMPLESTRING_block.prototype=new n.org.pkijs.asn1.ASN1_block;t.SIMPLESTRING_block.constructor=t.SIMPLESTRING_block;t.SIMPLESTRING_block.prototype.block_name=function(){return"SIMPLESTRING"};t.SIMPLESTRING_block.prototype.fromBER=function(n,i,r){var u=this.value_block.fromBER(n,i,this.len_block.is_indefinite_form==!0?r:this.len_block.length);return u==-1?(this.error=this.value_block.error,u):(t.SIMPLESTRING_block.prototype.fromBuffer.call(this,this.value_block.value_hex),this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),this.value_block.error.length==0&&(this.block_length+=this.value_block.block_length),u)};t.SIMPLESTRING_block.prototype.fromBuffer=function(n){this.value_block.value=String.fromCharCode.apply(null,new Uint8Array(n))};t.SIMPLESTRING_block.prototype.fromString=function(n){var i=n.length,r,t;for(this.value_block.value_hex=new ArrayBuffer(i),r=new Uint8Array(this.value_block.value_hex),t=0;t<i;t++)r[t]=n.charCodeAt(t);this.value_block.value=n};t.SIMPLESTRING_block.prototype.toJSON=function(){var i=n.org.pkijs.asn1.ASN1_block.prototype.toJSON.call(this);return i.block_name=t.SIMPLESTRING_block.prototype.block_name.call(this),i.block_name=t.value_block.prototype.block_name.call(this),i};n.org.pkijs.asn1.NUMERICSTRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=18};n.org.pkijs.asn1.NUMERICSTRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.NUMERICSTRING.constructor=n.org.pkijs.asn1.NUMERICSTRING;n.org.pkijs.asn1.NUMERICSTRING.prototype.block_name=function(){return"NUMERICSTRING"};n.org.pkijs.asn1.NUMERICSTRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.NUMERICSTRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.PRINTABLESTRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=19};n.org.pkijs.asn1.PRINTABLESTRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.PRINTABLESTRING.constructor=n.org.pkijs.asn1.PRINTABLESTRING;n.org.pkijs.asn1.PRINTABLESTRING.prototype.block_name=function(){return"PRINTABLESTRING"};n.org.pkijs.asn1.PRINTABLESTRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.PRINTABLESTRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.TELETEXSTRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=20};n.org.pkijs.asn1.TELETEXSTRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.TELETEXSTRING.constructor=n.org.pkijs.asn1.TELETEXSTRING;n.org.pkijs.asn1.TELETEXSTRING.prototype.block_name=function(){return"TELETEXSTRING"};n.org.pkijs.asn1.TELETEXSTRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.TELETEXSTRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.VIDEOTEXSTRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=21};n.org.pkijs.asn1.VIDEOTEXSTRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.VIDEOTEXSTRING.constructor=n.org.pkijs.asn1.VIDEOTEXSTRING;n.org.pkijs.asn1.VIDEOTEXSTRING.prototype.block_name=function(){return"VIDEOTEXSTRING"};n.org.pkijs.asn1.VIDEOTEXSTRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.VIDEOTEXSTRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.IA5STRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=22};n.org.pkijs.asn1.IA5STRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.IA5STRING.constructor=n.org.pkijs.asn1.IA5STRING;n.org.pkijs.asn1.IA5STRING.prototype.block_name=function(){return"IA5STRING"};n.org.pkijs.asn1.IA5STRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.IA5STRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.GRAPHICSTRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=25};n.org.pkijs.asn1.GRAPHICSTRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.GRAPHICSTRING.constructor=n.org.pkijs.asn1.GRAPHICSTRING;n.org.pkijs.asn1.GRAPHICSTRING.prototype.block_name=function(){return"GRAPHICSTRING"};n.org.pkijs.asn1.GRAPHICSTRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.GRAPHICSTRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.VISIBLESTRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=26};n.org.pkijs.asn1.VISIBLESTRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.VISIBLESTRING.constructor=n.org.pkijs.asn1.VISIBLESTRING;n.org.pkijs.asn1.VISIBLESTRING.prototype.block_name=function(){return"VISIBLESTRING"};n.org.pkijs.asn1.VISIBLESTRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.VISIBLESTRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.GENERALSTRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=27};n.org.pkijs.asn1.GENERALSTRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.GENERALSTRING.constructor=n.org.pkijs.asn1.GENERALSTRING;n.org.pkijs.asn1.GENERALSTRING.prototype.block_name=function(){return"GENERALSTRING"};n.org.pkijs.asn1.GENERALSTRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.GENERALSTRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.CHARACTERSTRING=function(){t.SIMPLESTRING_block.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=29};n.org.pkijs.asn1.CHARACTERSTRING.prototype=new t.SIMPLESTRING_block;n.org.pkijs.asn1.CHARACTERSTRING.constructor=n.org.pkijs.asn1.CHARACTERSTRING;n.org.pkijs.asn1.CHARACTERSTRING.prototype.block_name=function(){return"CHARACTERSTRING"};n.org.pkijs.asn1.CHARACTERSTRING.prototype.toJSON=function(){var i=t.SIMPLESTRING_block.prototype.toJSON.call(this);return i.block_name=n.org.pkijs.asn1.CHARACTERSTRING.prototype.block_name.call(this),i};n.org.pkijs.asn1.UTCTIME=function(){var i,t;if(n.org.pkijs.asn1.VISIBLESTRING.call(this,arguments[0]),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,arguments[0]instanceof Object&&"value"in arguments[0])for(n.org.pkijs.asn1.UTCTIME.prototype.fromString.call(this,arguments[0].value),this.value_block.value_hex=new ArrayBuffer(arguments[0].value.length),i=new Uint8Array(this.value_block.value_hex),t=0;t<str.length;t++)i[t]=arguments[0].value.charCodeAt(t);arguments[0]instanceof Object&&"value_date"in arguments[0]&&(n.org.pkijs.asn1.UTCTIME.prototype.fromDate.call(this,arguments[0].value_date),this.value_block.value_hex=n.org.pkijs.asn1.UTCTIME.prototype.toBuffer.call(this));this.id_block.tag_class=1;this.id_block.tag_number=23};n.org.pkijs.asn1.UTCTIME.prototype=new n.org.pkijs.asn1.VISIBLESTRING;n.org.pkijs.asn1.UTCTIME.constructor=n.org.pkijs.asn1.UTCTIME;n.org.pkijs.asn1.UTCTIME.prototype.fromBER=function(t,i,r){var u=this.value_block.fromBER(t,i,this.len_block.is_indefinite_form==!0?r:this.len_block.length);return u==-1?(this.error=this.value_block.error,u):(n.org.pkijs.asn1.UTCTIME.prototype.fromBuffer.call(this,this.value_block.value_hex),this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),this.value_block.error.length==0&&(this.block_length+=this.value_block.block_length),u)};n.org.pkijs.asn1.UTCTIME.prototype.fromBuffer=function(t){n.org.pkijs.asn1.UTCTIME.prototype.fromString.call(this,String.fromCharCode.apply(null,new Uint8Array(t)))};n.org.pkijs.asn1.UTCTIME.prototype.toBuffer=function(){for(var i=n.org.pkijs.asn1.UTCTIME.prototype.toString.call(this),r=new ArrayBuffer(i.length),u=new Uint8Array(r),t=0;t<i.length;t++)u[t]=i.charCodeAt(t);return r};n.org.pkijs.asn1.UTCTIME.prototype.fromDate=function(n){this.year=n.getFullYear();this.month=n.getMonth()+1;this.day=n.getDate();this.hour=n.getHours();this.minute=n.getMinutes();this.second=n.getSeconds()};n.org.pkijs.asn1.UTCTIME.prototype.toDate=function(){return new Date(this.year,this.month-1,this.day,this.hour,this.minute,this.second)};n.org.pkijs.asn1.UTCTIME.prototype.fromString=function(n){var t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(n),i;if(t===null){this.error="Wrong input string for convertion";return}i=parseInt(t[1],10);this.year=i>=50?1900+i:2e3+i;this.month=parseInt(t[2],10);this.day=parseInt(t[3],10);this.hour=parseInt(t[4],10);this.minute=parseInt(t[5],10);this.second=parseInt(t[6],10)};n.org.pkijs.asn1.UTCTIME.prototype.toString=function(){var t=new Array(7);return t[0]=n.org.pkijs.padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=n.org.pkijs.padNumber(this.month,2),t[2]=n.org.pkijs.padNumber(this.day,2),t[3]=n.org.pkijs.padNumber(this.hour,2),t[4]=n.org.pkijs.padNumber(this.minute,2),t[5]=n.org.pkijs.padNumber(this.second,2),t[6]="Z",t.join("")};n.org.pkijs.asn1.UTCTIME.prototype.block_name=function(){return"UTCTIME"};n.org.pkijs.asn1.UTCTIME.prototype.toJSON=function(){var t=n.org.pkijs.asn1.VISIBLESTRING.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.UTCTIME.prototype.block_name.call(this),t.year=this.year,t.month=this.month,t.day=this.day,t.hour=this.hour,t.minute=this.minute,t.second=this.second,t};n.org.pkijs.asn1.GENERALIZEDTIME=function(){var i,t;if(n.org.pkijs.asn1.VISIBLESTRING.call(this,arguments[0]),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,arguments[0]instanceof Object&&"value"in arguments[0])for(n.org.pkijs.asn1.GENERALIZEDTIME.prototype.fromString.call(this,arguments[0].value),this.value_block.value_hex=new ArrayBuffer(arguments[0].value.length),i=new Uint8Array(this.value_block.value_hex),t=0;t<str.length;t++)i[t]=arguments[0].value.charCodeAt(t);arguments[0]instanceof Object&&"value_date"in arguments[0]&&(n.org.pkijs.asn1.GENERALIZEDTIME.prototype.fromDate.call(this,arguments[0].value_date),this.value_block.value_hex=n.org.pkijs.asn1.GENERALIZEDTIME.prototype.toBuffer.call(this));this.id_block.tag_class=1;this.id_block.tag_number=24};n.org.pkijs.asn1.GENERALIZEDTIME.prototype=new n.org.pkijs.asn1.VISIBLESTRING;n.org.pkijs.asn1.GENERALIZEDTIME.constructor=n.org.pkijs.asn1.GENERALIZEDTIME;n.org.pkijs.asn1.GENERALIZEDTIME.prototype.fromBER=function(t,i,r){var u=this.value_block.fromBER(t,i,this.len_block.is_indefinite_form==!0?r:this.len_block.length);return u==-1?(this.error=this.value_block.error,u):(n.org.pkijs.asn1.GENERALIZEDTIME.prototype.fromBuffer.call(this,this.value_block.value_hex),this.id_block.error.length==0&&(this.block_length+=this.id_block.block_length),this.len_block.error.length==0&&(this.block_length+=this.len_block.block_length),this.value_block.error.length==0&&(this.block_length+=this.value_block.block_length),u)};n.org.pkijs.asn1.GENERALIZEDTIME.prototype.fromBuffer=function(t){n.org.pkijs.asn1.GENERALIZEDTIME.prototype.fromString.call(this,String.fromCharCode.apply(null,new Uint8Array(t)))};n.org.pkijs.asn1.GENERALIZEDTIME.prototype.toBuffer=function(){for(var i=n.org.pkijs.asn1.GENERALIZEDTIME.prototype.toString.call(this),r=new ArrayBuffer(i.length),u=new Uint8Array(r),t=0;t<i.length;t++)u[t]=i.charCodeAt(t);return r};n.org.pkijs.asn1.GENERALIZEDTIME.prototype.fromDate=function(n){this.year=n.getFullYear();this.month=n.getMonth()+1;this.day=n.getDate();this.hour=n.getHours();this.minute=n.getMinutes();this.second=n.getSeconds()};n.org.pkijs.asn1.GENERALIZEDTIME.prototype.toDate=function(){return new Date(this.year,this.month-1,this.day,this.hour,this.minute,this.second)};n.org.pkijs.asn1.GENERALIZEDTIME.prototype.fromString=function(n){var t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(n);if(t===null){this.error="Wrong input string for convertion";return}this.year=parseInt(t[1],10);this.month=parseInt(t[2],10);this.day=parseInt(t[3],10);this.hour=parseInt(t[4],10);this.minute=parseInt(t[5],10);this.second=parseInt(t[6],10)};n.org.pkijs.asn1.GENERALIZEDTIME.prototype.toString=function(){var t=new Array(7);return t[0]=n.org.pkijs.padNumber(this.year,4),t[1]=n.org.pkijs.padNumber(this.month,2),t[2]=n.org.pkijs.padNumber(this.day,2),t[3]=n.org.pkijs.padNumber(this.hour,2),t[4]=n.org.pkijs.padNumber(this.minute,2),t[5]=n.org.pkijs.padNumber(this.second,2),t[6]="Z",t.join("")};n.org.pkijs.asn1.GENERALIZEDTIME.prototype.block_name=function(){return"GENERALIZEDTIME"};n.org.pkijs.asn1.GENERALIZEDTIME.prototype.toJSON=function(){var t=n.org.pkijs.asn1.VISIBLESTRING.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.GENERALIZEDTIME.prototype.block_name.call(this),t.year=this.year,t.month=this.month,t.day=this.day,t.hour=this.hour,t.minute=this.minute,t.second=this.second,t};n.org.pkijs.asn1.DATE=function(){n.org.pkijs.asn1.UTF8STRING.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=31};n.org.pkijs.asn1.DATE.prototype=new n.org.pkijs.asn1.UTF8STRING;n.org.pkijs.asn1.DATE.constructor=n.org.pkijs.asn1.DATE;n.org.pkijs.asn1.DATE.prototype.block_name=function(){return"DATE"};n.org.pkijs.asn1.DATE.prototype.toJSON=function(){var t=n.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.DATE.prototype.block_name.call(this),t};n.org.pkijs.asn1.TIMEOFDAY=function(){n.org.pkijs.asn1.UTF8STRING.call(this,arguments[0])};n.org.pkijs.asn1.TIMEOFDAY.prototype=new n.org.pkijs.asn1.UTF8STRING;n.org.pkijs.asn1.TIMEOFDAY.constructor=n.org.pkijs.asn1.TIMEOFDAY;n.org.pkijs.asn1.TIMEOFDAY.prototype.block_name=function(){return"TIMEOFDAY"};n.org.pkijs.asn1.DATE.prototype.toJSON=function(){var t=n.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.TIMEOFDAY.prototype.block_name.call(this),t};n.org.pkijs.asn1.DATETIME=function(){n.org.pkijs.asn1.UTF8STRING.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=33};n.org.pkijs.asn1.DATETIME.prototype=new n.org.pkijs.asn1.UTF8STRING;n.org.pkijs.asn1.DATETIME.constructor=n.org.pkijs.asn1.DATETIME;n.org.pkijs.asn1.DATETIME.prototype.block_name=function(){return"DATETIME"};n.org.pkijs.asn1.DATETIME.prototype.toJSON=function(){var t=n.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.DATETIME.prototype.block_name.call(this),t};n.org.pkijs.asn1.DURATION=function(){n.org.pkijs.asn1.UTF8STRING.call(this,arguments[0])};n.org.pkijs.asn1.DURATION.prototype=new n.org.pkijs.asn1.UTF8STRING;n.org.pkijs.asn1.DURATION.constructor=n.org.pkijs.asn1.DURATION;n.org.pkijs.asn1.DURATION.prototype.block_name=function(){return"DURATION"};n.org.pkijs.asn1.DURATION.prototype.toJSON=function(){var t=n.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.DURATION.prototype.block_name.call(this),t};n.org.pkijs.asn1.TIME=function(){n.org.pkijs.asn1.UTF8STRING.call(this,arguments[0]);this.id_block.tag_class=1;this.id_block.tag_number=14};n.org.pkijs.asn1.TIME.prototype=new n.org.pkijs.asn1.UTF8STRING;n.org.pkijs.asn1.TIME.constructor=n.org.pkijs.asn1.TIME;n.org.pkijs.asn1.TIME.prototype.block_name=function(){return"TIME"};n.org.pkijs.asn1.TIME.prototype.toJSON=function(){var t=n.org.pkijs.asn1.UTF8STRING.prototype.toJSON.call(this);return t.block_name=n.org.pkijs.asn1.TIME.prototype.block_name.call(this),t};n.org.pkijs.asn1.CHOICE=function(){arguments[0]instanceof Object&&(this.value=n.org.pkijs.getValue(arguments[0],"value",[]),this.optional=n.org.pkijs.getValue(arguments[0],"optional",!1))};n.org.pkijs.asn1.ANY=function(){arguments[0]instanceof Object&&(this.name=n.org.pkijs.getValue(arguments[0],"name",""),this.optional=n.org.pkijs.getValue(arguments[0],"optional",!1))};n.org.pkijs.asn1.REPEATED=function(){arguments[0]instanceof Object&&(this.name=n.org.pkijs.getValue(arguments[0],"name",""),this.optional=n.org.pkijs.getValue(arguments[0],"optional",!1),this.value=n.org.pkijs.getValue(arguments[0],"value",new n.org.pkijs.asn1.ANY),this.local=n.org.pkijs.getValue(arguments[0],"local",!1))};n.org.pkijs.fromBER=function(t){if(t.byteLength==0){var i=new n.org.pkijs.asn1.ASN1_block;return i.error="Input buffer has zero length",i}return c(t,0,t.byteLength)};n.org.pkijs.compareSchema=function(t,i,r){var w,s,e,h,b,c,p,v,u,o,y,f;if(r instanceof n.org.pkijs.asn1.CHOICE){for(w=!1,s=0;s<r.value.length;s++)if(e=n.org.pkijs.compareSchema(t,i,r.value[s]),e.verified===!0)return{verified:!0,result:t};if(w===!1)return f={verified:!1,result:{error:"Wrong values for CHOICE type"}},r.hasOwnProperty("name")&&(f.name=r.name),f}if(r instanceof n.org.pkijs.asn1.ANY)return r.hasOwnProperty("name")&&(t[r.name]=i),{verified:!0,result:t};if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong root object"}};if(i instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(r instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("id_block"in r==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("fromBER"in r.id_block==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("toBER"in r.id_block==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(h=r.id_block.toBER(!1),h.byteLength===0)return{verified:!1,result:{error:"Error encoding id_block for ASN.1 schema"}};if(b=r.id_block.fromBER(h,0,h.byteLength),b===-1)return{verified:!1,result:{error:"Error decoding id_block for ASN.1 schema"}};if(r.id_block.hasOwnProperty("tag_class")===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.id_block.tag_class!==i.id_block.tag_class)return{verified:!1,result:t};if(r.id_block.hasOwnProperty("tag_number")===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.id_block.tag_number!==i.id_block.tag_number)return{verified:!1,result:t};if(r.id_block.hasOwnProperty("is_constructed")===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.id_block.is_constructed!==i.id_block.is_constructed)return{verified:!1,result:t};if("is_hex_only"in r.id_block==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.id_block.is_hex_only!==i.id_block.is_hex_only)return{verified:!1,result:t};if(r.id_block.is_hex_only===!0){if("value_hex"in r.id_block==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(c=new Uint8Array(r.id_block.value_hex),p=new Uint8Array(i.id_block.value_hex),c.length!==p.length)return{verified:!1,result:t};for(u=0;u<c.length;u++)if(c[u]!==p[1])return{verified:!1,result:t}}if(r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),r.name!==""&&(t[r.name]=i)),r.id_block.is_constructed===!0){var l=0,e={verified:!1},a=r.value_block.value.length;if(a>0&&r.value_block.value[0]instanceof n.org.pkijs.asn1.REPEATED&&(a=i.value_block.value.length),a===0)return{verified:!0,result:t};if(i.value_block.value.length===0&&r.value_block.value.length!==0){for(v=!0,u=0;u<r.value_block.value.length;u++)v=v&&(r.value_block.value[u].optional||!1);return v===!0?{verified:!0,result:t}:(r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),r.name!==""&&delete t[r.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(u=0;u<a;u++)if(u-l>=i.value_block.value.length){if(r.value_block.value[u].optional===!1)return f={verified:!1,result:t},t.error="Inconsistent length between ASN.1 data and schema",r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),r.name!==""&&(delete t[r.name],f.name=r.name)),f}else if(r.value_block.value[0]instanceof n.org.pkijs.asn1.REPEATED){if(e=n.org.pkijs.compareSchema(t,i.value_block.value[u],r.value_block.value[0].value),e.verified===!1)if(r.value_block.value[0].optional===!0)l++;else return r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),r.name!==""&&delete t[r.name]),e;"name"in r.value_block.value[0]&&r.value_block.value[0].name.length>0&&(o={},o="local"in r.value_block.value[0]&&r.value_block.value[0].local===!0?i:t,typeof o[r.value_block.value[0].name]=="undefined"&&(o[r.value_block.value[0].name]=[]),o[r.value_block.value[0].name].push(i.value_block.value[u]))}else if(e=n.org.pkijs.compareSchema(t,i.value_block.value[u-l],r.value_block.value[u]),e.verified===!1)if(r.value_block.value[u].optional===!0)l++;else return r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),r.name!==""&&delete t[r.name]),e;return e.verified===!1?(f={verified:!1,result:t},r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),r.name!==""&&(delete t[r.name],f.name=r.name)),f):{verified:!0,result:t}}return"primitive_schema"in r&&"value_hex"in i.value_block?(y=n.org.pkijs.fromBER(i.value_block.value_hex),y.offset===-1)?(f={verified:!1,result:y.result},r.hasOwnProperty("name")&&(r.name=r.name.replace(/^\s+|\s+$/g,""),r.name!==""&&(delete t[r.name],f.name=r.name)),f):n.org.pkijs.compareSchema(t,y.result,r.primitive_schema):{verified:!0,result:t}};n.org.pkijs.verifySchema=function(t,i){if(i instanceof Object==!1)return{varified:!1,result:{error:"Wrong ASN.1 schema type"}};var r=n.org.pkijs.fromBER(t);return r.offset===-1?{verified:!1,result:r.result}:n.org.pkijs.compareSchema(r.result,r.result,i)};n.org.pkijs.fromJSON=function(){}}(typeof exports!="undefined"?exports:window),function(n){if(typeof n.org=="undefined")n.org={};else if(typeof n.org!="object")throw new Error("Name org already exists and it's not an object");if(typeof n.org.pkijs=="undefined")n.org.pkijs={};else if(typeof n.org.pkijs!="object")throw new Error("Name org.pkijs already exists and it's not an object but "+typeof n.org.pkijs);if(typeof n.org.pkijs.schema=="undefined")n.org.pkijs.schema={};else if(typeof n.org.pkijs.schema!="object")throw new Error("Name org.pkijs.schema already exists and it's not an object but "+typeof n.org.pkijs.schema);if(typeof n.org.pkijs.schema.x509=="undefined")n.org.pkijs.schema.x509={};else if(typeof n.org.pkijs.schema.x509!="object")throw new Error("Name org.pkijs.schema.x509 already exists and it's not an object but "+typeof n.org.pkijs.schema.x509);var t={};n.org.pkijs.schema.TIME=function(t,i){var r=n.org.pkijs.getNames(arguments[0]),u=i||!1;return new n.org.pkijs.asn1.CHOICE({optional:u,value:[new n.org.pkijs.asn1.UTCTIME({name:r.utcTimeName||""}),new n.org.pkijs.asn1.GENERALIZEDTIME({name:r.generalTimeName||""})]})};t.tbsCertificate=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"tbsCertificate",value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.INTEGER({name:t.tbsCertificate_version||"tbsCertificate.version"})]}),new n.org.pkijs.asn1.INTEGER({name:t.tbsCertificate_serialNumber||"tbsCertificate.serialNumber"}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.signature||{names:{block_name:"tbsCertificate.signature"}}),n.org.pkijs.schema.RDN(t.issuer||{names:{block_name:"tbsCertificate.issuer"}}),new n.org.pkijs.asn1.SEQUENCE({name:t.tbsCertificate_validity||"tbsCertificate.validity",value:[n.org.pkijs.schema.TIME(t.not_before||{names:{utcTimeName:"tbsCertificate.notBefore",generalTimeName:"tbsCertificate.notBefore"}}),n.org.pkijs.schema.TIME(t.not_after||{names:{utcTimeName:"tbsCertificate.notAfter",generalTimeName:"tbsCertificate.notAfter"}})]}),n.org.pkijs.schema.RDN(t.subject||{names:{block_name:"tbsCertificate.subject"}}),n.org.pkijs.schema.PUBLIC_KEY_INFO(t.subjectPublicKeyInfo||{names:{block_name:"tbsCertificate.subjectPublicKeyInfo"}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.tbsCertificate_issuerUniqueID||"tbsCertificate.issuerUniqueID",optional:!0,id_block:{tag_class:3,tag_number:1}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.tbsCertificate_subjectUniqueID||"tbsCertificate.subjectUniqueID",optional:!0,id_block:{tag_class:3,tag_number:2}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:3},value:[n.org.pkijs.schema.EXTENSIONS(t.extensions||{names:{block_name:"tbsCertificate.extensions"}})]})]})};n.org.pkijs.schema.CERT=function(){var i=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:i.block_name||"",value:[t.tbsCertificate(i.tbsCertificate),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(i.signatureAlgorithm||{names:{block_name:"signatureAlgorithm"}}),new n.org.pkijs.asn1.BITSTRING({name:i.signatureValue||"signatureValue"})]})};t.tbsCertList=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"tbsCertList",value:[new n.org.pkijs.asn1.INTEGER({optional:!0,name:t.tbsCertList_version||"tbsCertList.version",value:2}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.signature||{names:{block_name:"tbsCertList.signature"}}),n.org.pkijs.schema.RDN(t.issuer||{names:{block_name:"tbsCertList.issuer"}}),n.org.pkijs.schema.TIME(t.tbsCertList_thisUpdate||{names:{utcTimeName:"tbsCertList.thisUpdate",generalTimeName:"tbsCertList.thisUpdate"}}),n.org.pkijs.schema.TIME(t.tbsCertList_thisUpdate||{names:{utcTimeName:"tbsCertList.nextUpdate",generalTimeName:"tbsCertList.nextUpdate"}},!0),new n.org.pkijs.asn1.SEQUENCE({optional:!0,value:[new n.org.pkijs.asn1.REPEATED({name:t.tbsCertList_revokedCertificates||"tbsCertList.revokedCertificates",value:new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.INTEGER,n.org.pkijs.schema.TIME(),n.org.pkijs.schema.EXTENSIONS({},!0)]})})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[n.org.pkijs.schema.EXTENSIONS(t.crlExtensions||{names:{block_name:"tbsCertList.extensions"}})]})]})};n.org.pkijs.schema.CRL=function(){var i=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:i.block_name||"CertificateList",value:[t.tbsCertList(arguments[0]),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(i.signatureAlgorithm||{names:{block_name:"signatureAlgorithm"}}),new n.org.pkijs.asn1.BITSTRING({name:i.signatureValue||"signatureValue"})]})};t.CertificationRequestInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.CertificationRequestInfo||"CertificationRequestInfo",value:[new n.org.pkijs.asn1.INTEGER({name:t.CertificationRequestInfo_version||"CertificationRequestInfo.version"}),new n.org.pkijs.schema.RDN(t.subject||{names:{block_name:"CertificationRequestInfo.subject"}}),new n.org.pkijs.schema.PUBLIC_KEY_INFO({names:{block_name:"CertificationRequestInfo.subjectPublicKeyInfo"}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.REPEATED({optional:!0,name:t.CertificationRequestInfo_attributes||"CertificationRequestInfo.attributes",value:n.org.pkijs.schema.ATTRIBUTE(t.attributes||{})})]})]})};n.org.pkijs.schema.PKCS10=function(){var i=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({value:[t.CertificationRequestInfo(i.certificationRequestInfo||{}),new n.org.pkijs.asn1.SEQUENCE({name:i.signatureAlgorithm||"signatureAlgorithm",value:[new n.org.pkijs.asn1.OID,new n.org.pkijs.asn1.ANY({optional:!0})]}),new n.org.pkijs.asn1.BITSTRING({name:i.signatureValue||"signatureValue"})]})};n.org.pkijs.schema.PKCS8=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.INTEGER({name:t.version||""}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.privateKeyAlgorithm||""),new n.org.pkijs.asn1.OCTETSTRING({name:t.privateKey||""}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.REPEATED({name:t.attributes||"",value:n.org.pkijs.schema.ATTRIBUTE()})]})]})};t.BuiltInStandardAttributes=function(t){typeof t=="undefined"&&(t=!1);var i=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({optional:t,value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:2,tag_number:1},name:i.country_name||"",value:[new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.NUMERICSTRING,new n.org.pkijs.asn1.PRINTABLESTRING]})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:2,tag_number:2},name:i.administration_domain_name||"",value:[new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.NUMERICSTRING,new n.org.pkijs.asn1.PRINTABLESTRING]})]}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:0},name:i.network_address||"",is_hex_only:!0}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:1},name:i.terminal_identifier||"",is_hex_only:!0}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:2},name:i.private_domain_name||"",value:[new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.NUMERICSTRING,new n.org.pkijs.asn1.PRINTABLESTRING]})]}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:3},name:i.organization_name||"",is_hex_only:!0}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,name:i.numeric_user_identifier||"",id_block:{tag_class:3,tag_number:4},is_hex_only:!0}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,name:i.personal_name||"",id_block:{tag_class:3,tag_number:5},value:[new n.org.pkijs.asn1.ASN1_PRIMITIVE({id_block:{tag_class:3,tag_number:0},is_hex_only:!0}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:1},is_hex_only:!0}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:2},is_hex_only:!0}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:3},is_hex_only:!0})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,name:i.organizational_unit_names||"",id_block:{tag_class:3,tag_number:6},value:[new n.org.pkijs.asn1.REPEATED({value:new n.org.pkijs.asn1.PRINTABLESTRING})]})]})};t.BuiltInDomainDefinedAttributes=function(t){return typeof t=="undefined"&&(t=!1),new n.org.pkijs.asn1.SEQUENCE({optional:t,value:[new n.org.pkijs.asn1.PRINTABLESTRING,new n.org.pkijs.asn1.PRINTABLESTRING]})};t.ExtensionAttributes=function(t){return typeof t=="undefined"&&(t=!1),new n.org.pkijs.asn1.SET({optional:t,value:[new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:0},is_hex_only:!0}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.ANY]})]})};n.org.pkijs.schema.GENERAL_NAME=function(){var i=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},name:i.block_name||"",value:[new n.org.pkijs.asn1.OID,new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.ANY]})]}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:i.block_name||"",id_block:{tag_class:3,tag_number:1}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:i.block_name||"",id_block:{tag_class:3,tag_number:2}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:3},name:i.block_name||"",value:[t.BuiltInStandardAttributes(!1),t.BuiltInDomainDefinedAttributes(!0),t.ExtensionAttributes(!0)]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:4},name:i.block_name||"",value:[n.org.pkijs.schema.RDN(i.directoryName||{})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:5},name:i.block_name||"",value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.TELETEXSTRING,new n.org.pkijs.asn1.PRINTABLESTRING,new n.org.pkijs.asn1.UNIVERSALSTRING,new n.org.pkijs.asn1.UTF8STRING,new n.org.pkijs.asn1.BMPSTRING]})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.TELETEXSTRING,new n.org.pkijs.asn1.PRINTABLESTRING,new n.org.pkijs.asn1.UNIVERSALSTRING,new n.org.pkijs.asn1.UTF8STRING,new n.org.pkijs.asn1.BMPSTRING]})]})]}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:i.block_name||"",id_block:{tag_class:3,tag_number:6}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:i.block_name||"",id_block:{tag_class:3,tag_number:7}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:i.block_name||"",id_block:{tag_class:3,tag_number:8}})]})};n.org.pkijs.schema.ALGORITHM_IDENTIFIER=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",optional:t.optional||!1,value:[new n.org.pkijs.asn1.OID({name:t.algorithmIdentifier||""}),new n.org.pkijs.asn1.ANY({name:t.algorithmParams||"",optional:!0})]})};n.org.pkijs.schema.x509.RSAPublicKey=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.INTEGER({name:t.modulus||""}),new n.org.pkijs.asn1.INTEGER({name:t.publicExponent||""})]})};n.org.pkijs.schema.x509.OtherPrimeInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.INTEGER({name:t.prime||""}),new n.org.pkijs.asn1.INTEGER({name:t.exponent||""}),new n.org.pkijs.asn1.INTEGER({name:t.coefficient||""})]})};n.org.pkijs.schema.x509.RSAPrivateKey=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.INTEGER({name:t.version||""}),new n.org.pkijs.asn1.INTEGER({name:t.modulus||""}),new n.org.pkijs.asn1.INTEGER({name:t.publicExponent||""}),new n.org.pkijs.asn1.INTEGER({name:t.privateExponent||""}),new n.org.pkijs.asn1.INTEGER({name:t.prime1||""}),new n.org.pkijs.asn1.INTEGER({name:t.prime2||""}),new n.org.pkijs.asn1.INTEGER({name:t.exponent1||""}),new n.org.pkijs.asn1.INTEGER({name:t.exponent2||""}),new n.org.pkijs.asn1.INTEGER({name:t.coefficient||""}),new n.org.pkijs.asn1.SEQUENCE({optional:!0,value:[new n.org.pkijs.asn1.REPEATED({name:t.otherPrimeInfos||"",value:n.org.pkijs.schema.x509.OtherPrimeInfo(t.otherPrimeInfo||{})})]})]})};n.org.pkijs.schema.x509.RSASSA_PSS_params=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},optional:!0,value:[n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.hashAlgorithm||{})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:1},optional:!0,value:[n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.maskGenAlgorithm||{})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:2},optional:!0,value:[new n.org.pkijs.asn1.INTEGER({name:t.saltLength||""})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:3},optional:!0,value:[new n.org.pkijs.asn1.INTEGER({name:t.trailerField||""})]}),]})};n.org.pkijs.schema.PUBLIC_KEY_INFO=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.algorithm||{}),new n.org.pkijs.asn1.BITSTRING({name:t.subjectPublicKey||""})]})};n.org.pkijs.schema.ATTRIBUTE=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.type||""}),new n.org.pkijs.asn1.SET({name:t.set_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.values||"",value:new n.org.pkijs.asn1.ANY})]})]})};n.org.pkijs.schema.ATTR_TYPE_AND_VALUE=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.type||""}),new n.org.pkijs.asn1.ANY({name:t.value||""})]})};n.org.pkijs.schema.RDN=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.repeated_sequence||"",value:new n.org.pkijs.asn1.SET({value:[new n.org.pkijs.asn1.REPEATED({name:t.repeated_set||"",value:n.org.pkijs.schema.ATTR_TYPE_AND_VALUE(t.attr_type_and_value||{})})]})})]})};n.org.pkijs.schema.EXTENSION=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.extnID||""}),new n.org.pkijs.asn1.BOOLEAN({name:t.critical||"",optional:!0}),new n.org.pkijs.asn1.OCTETSTRING({name:t.extnValue||""})]})};n.org.pkijs.schema.EXTENSIONS=function(t,i){var r=n.org.pkijs.getNames(arguments[0]),u=i||!1;return new n.org.pkijs.asn1.SEQUENCE({optional:u,name:r.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:r.extensions||"",value:n.org.pkijs.schema.EXTENSION(r.extension||{})})]})};n.org.pkijs.schema.x509.AuthorityKeyIdentifier=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.keyIdentifier||"",optional:!0,id_block:{tag_class:3,tag_number:0}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.REPEATED({name:t.authorityCertIssuer||"",value:n.org.pkijs.schema.GENERAL_NAME()})]}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.authorityCertSerialNumber||"",optional:!0,id_block:{tag_class:3,tag_number:2}})]})};n.org.pkijs.schema.x509.PrivateKeyUsagePeriod=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.notBefore||"",optional:!0,id_block:{tag_class:3,tag_number:0}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.notAfter||"",optional:!0,id_block:{tag_class:3,tag_number:1}})]})};n.org.pkijs.schema.x509.AltName=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.altNames||"",value:n.org.pkijs.schema.GENERAL_NAME()})]})};n.org.pkijs.schema.x509.SubjectDirectoryAttributes=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.attributes||"",value:n.org.pkijs.schema.ATTRIBUTE()})]})};n.org.pkijs.schema.x509.GeneralSubtree=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[n.org.pkijs.schema.GENERAL_NAME(t.base||""),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.INTEGER({name:t.minimum||""})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.INTEGER({name:t.maximum||""})]})]})};n.org.pkijs.schema.x509.NameConstraints=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.REPEATED({name:t.permittedSubtrees||"",value:n.org.pkijs.schema.x509.GeneralSubtree()})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.REPEATED({name:t.excludedSubtrees||"",value:n.org.pkijs.schema.x509.GeneralSubtree()})]})]})};n.org.pkijs.schema.x509.BasicConstraints=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.BOOLEAN({optional:!0,name:t.cA||""}),new n.org.pkijs.asn1.INTEGER({optional:!0,name:t.pathLenConstraint||""})]})};n.org.pkijs.schema.x509.PolicyQualifierInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.policyQualifierId||""}),new n.org.pkijs.asn1.ANY({name:t.qualifier||""})]})};n.org.pkijs.schema.x509.PolicyInformation=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.policyIdentifier||""}),new n.org.pkijs.asn1.SEQUENCE({optional:!0,value:[new n.org.pkijs.asn1.REPEATED({name:t.policyQualifiers||"",value:n.org.pkijs.schema.x509.PolicyQualifierInfo()})]})]})};n.org.pkijs.schema.x509.CertificatePolicies=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.certificatePolicies||"",value:n.org.pkijs.schema.x509.PolicyInformation()})]})};n.org.pkijs.schema.x509.PolicyMapping=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.issuerDomainPolicy||""}),new n.org.pkijs.asn1.OID({name:t.subjectDomainPolicy||""})]})};n.org.pkijs.schema.x509.PolicyMappings=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.mappings||"",value:n.org.pkijs.schema.x509.PolicyMapping()})]})};n.org.pkijs.schema.x509.PolicyConstraints=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.requireExplicitPolicy||"",optional:!0,id_block:{tag_class:3,tag_number:0}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.inhibitPolicyMapping||"",optional:!0,id_block:{tag_class:3,tag_number:1}})]})};n.org.pkijs.schema.x509.ExtKeyUsage=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.keyPurposes||"",value:new n.org.pkijs.asn1.OID})]})};n.org.pkijs.schema.x509.DistributionPoint=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.distributionPoint||"",optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.REPEATED({name:t.distributionPoint_names||"",value:n.org.pkijs.schema.GENERAL_NAME()})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.distributionPoint||"",optional:!0,id_block:{tag_class:3,tag_number:1},value:n.org.pkijs.schema.RDN().value_block.value})]})]}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.reasons||"",optional:!0,id_block:{tag_class:3,tag_number:1}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.cRLIssuer||"",optional:!0,id_block:{tag_class:3,tag_number:2},value:[new n.org.pkijs.asn1.REPEATED({name:t.cRLIssuer_names||"",value:n.org.pkijs.schema.GENERAL_NAME()})]})]})};n.org.pkijs.schema.x509.CRLDistributionPoints=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.distributionPoints||"",value:n.org.pkijs.schema.x509.DistributionPoint()})]})};n.org.pkijs.schema.x509.AccessDescription=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.accessMethod||""}),n.org.pkijs.schema.GENERAL_NAME(t.accessLocation||"")]})};n.org.pkijs.schema.x509.InfoAccess=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.accessDescriptions||"",value:n.org.pkijs.schema.x509.AccessDescription()})]})};n.org.pkijs.schema.x509.IssuingDistributionPoint=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.distributionPoint||"",id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.REPEATED({name:t.distributionPoint_names||"",value:n.org.pkijs.schema.GENERAL_NAME()})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.distributionPoint||"",id_block:{tag_class:3,tag_number:1},value:n.org.pkijs.schema.RDN().value_block.value})]})]}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.onlyContainsUserCerts||"",optional:!0,id_block:{tag_class:3,tag_number:1}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.onlyContainsCACerts||"",optional:!0,id_block:{tag_class:3,tag_number:2}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.onlySomeReasons||"",optional:!0,id_block:{tag_class:3,tag_number:3}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.indirectCRL||"",optional:!0,id_block:{tag_class:3,tag_number:4}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.onlyContainsAttributeCerts||"",optional:!0,id_block:{tag_class:3,tag_number:5}})]})}}(typeof exports!="undefined"?exports:window),function(n){if(typeof n.org=="undefined")n.org={};else if(typeof n.org!="object")throw new Error("Name org already exists and it's not an object");if(typeof n.org.pkijs=="undefined")n.org.pkijs={};else if(typeof n.org.pkijs!="object")throw new Error("Name org.pkijs already exists and it's not an object but "+typeof n.org.pkijs);if(typeof n.org.pkijs.simpl=="undefined")n.org.pkijs.simpl={};else if(typeof n.org.pkijs.simpl!="object")throw new Error("Name org.pkijs.simpl already exists and it's not an object but "+typeof n.org.pkijs.simpl);if(typeof n.org.pkijs.simpl.x509=="undefined")n.org.pkijs.simpl.x509={};else if(typeof n.org.pkijs.simpl.x509!="object")throw new Error("Name org.pkijs.simpl.x509 already exists and it's not an object but "+typeof n.org.pkijs.simpl.x509);n.org.pkijs.simpl.TIME=function(){this.type=0;this.value=new Date(0,0,0);arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.TIME.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.type=arguments[0].type||0,this.value=arguments[0].value||new Date(0,0,0))};n.org.pkijs.simpl.TIME.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.TIME({names:{utcTimeName:"utcTimeName",generalTimeName:"generalTimeName"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for TIME");"utcTimeName"in i.result&&(this.type=0,this.value=i.result.utcTimeName.toDate());"generalTimeName"in i.result&&(this.type=1,this.value=i.result.generalTimeName.toDate())};n.org.pkijs.simpl.TIME.prototype.toSchema=function(){var t={};return this.type===0&&(t=new n.org.pkijs.asn1.UTCTIME({value_date:this.value})),this.type===1&&(t=new n.org.pkijs.asn1.GENERALIZEDTIME({value_date:this.value})),t};n.org.pkijs.simpl.TIME.prototype.toJSON=function(){return{type:this.type,value:this.value}};n.org.pkijs.simpl.GENERAL_NAME=function(){this.NameType=9;this.Name={};arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.GENERAL_NAME.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.NameType=arguments[0].NameType||9,this.Name=arguments[0].Name||{})};n.org.pkijs.simpl.GENERAL_NAME.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.GENERAL_NAME({names:{block_name:"block_name",otherName:"otherName",rfc822Name:"rfc822Name",dNSName:"dNSName",x400Address:"x400Address",directoryName:{names:{block_name:"directoryName"}},ediPartyName:"ediPartyName",uniformResourceIdentifier:"uniformResourceIdentifier",iPAddress:"iPAddress",registeredID:"registeredID"}})),r,u;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for GENERAL_NAME");this.NameType=i.result.block_name.id_block.tag_number;switch(this.NameType){case 0:this.Name=i.result.block_name;break;case 1:case 2:case 6:r=i.result.block_name;r.id_block.tag_class=1;r.id_block.tag_number=22;u=r.toBER(!1);this.Name=n.org.pkijs.fromBER(u).result.value_block.value;break;case 3:this.Name=i.result.block_name;break;case 4:this.Name=new n.org.pkijs.simpl.RDN({schema:i.result.directoryName});break;case 5:this.Name=i.result.ediPartyName;break;case 7:this.Name=new n.org.pkijs.asn1.OCTETSTRING({value_hex:i.result.block_name.value_block.value_hex});break;case 8:r=i.result.block_name;r.id_block.tag_class=1;r.id_block.tag_number=6;u=r.toBER(!1);this.Name=n.org.pkijs.fromBER(u).result.value_block.toString()}};n.org.pkijs.simpl.GENERAL_NAME.prototype.toSchema=function(){var t;switch(this.NameType){case 0:case 3:case 5:return new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:this.NameType},value:[this.Name]});case 1:case 2:case 6:return t=new n.org.pkijs.asn1.IA5STRING({value:this.Name}),t.id_block.tag_class=3,t.id_block.tag_number=this.NameType,t;case 4:return new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:4},value:[this.Name.toSchema()]});case 7:return t=this.Name,t.id_block.tag_class=3,t.id_block.tag_number=this.NameType,t;case 8:return t=new n.org.pkijs.asn1.OID({value:this.Name}),t.id_block.tag_class=3,t.id_block.tag_number=this.NameType,t;default:return n.org.pkijs.schema.GENERAL_NAME()}};n.org.pkijs.simpl.GENERAL_NAME.prototype.toJSON=function(){var n={NameType:this.NameType};return n.Name=typeof this.Name=="string"?this.Name:this.Name.toJSON(),n};n.org.pkijs.simpl.GENERAL_NAMES=function(){this.names=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.GENERAL_NAMES.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.names=arguments[0].names||[])};n.org.pkijs.simpl.GENERAL_NAMES.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.REPEATED({name:"names",value:n.org.pkijs.schema.GENERAL_NAME()})]})),r,i;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for GENERAL_NAMES");for(r=u.result.names,i=0;i<r.length;i++)this.names.push(new n.org.pkijs.simpl.GENERAL_NAME({schema:r[i]}))};n.org.pkijs.simpl.GENERAL_NAMES.prototype.toSchema=function(){for(var i=[],t=0;t<this.names.length;t++)i.push(this.names[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.GENERAL_NAMES.prototype.toJSON=function(){for(var t=[],n=0;n<this.names.length;n++)t.push(this.names[n].toJSON());return{names:t}};n.org.pkijs.simpl.ALGORITHM_IDENTIFIER=function(){this.algorithm_id="";arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.ALGORITHM_IDENTIFIER.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.algorithm_id=arguments[0].algorithm_id||"","algorithm_params"in arguments[0]&&(this.algorithm_params=arguments[0].algorithm_params))};n.org.pkijs.simpl.ALGORITHM_IDENTIFIER.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.ALGORITHM_IDENTIFIER({names:{algorithmIdentifier:"algorithm",algorithmParams:"params"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for ALGORITHM_IDENTIFIER");this.algorithm_id=i.result.algorithm.value_block.toString();"params"in i.result&&(this.algorithm_params=i.result.params)};n.org.pkijs.simpl.ALGORITHM_IDENTIFIER.prototype.toSchema=function(){var t=[];return t.push(new n.org.pkijs.asn1.OID({value:this.algorithm_id})),"algorithm_params"in this&&t.push(this.algorithm_params),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.ALGORITHM_IDENTIFIER.prototype.getCommonName=function(){};n.org.pkijs.simpl.ALGORITHM_IDENTIFIER.prototype.toJSON=function(){var n={algorithm_id:this.algorithm_id};return"algorithm_params"in this&&(n.algorithm_params=this.algorithm_params.toJSON()),n};n.org.pkijs.simpl.x509.RSAPublicKey=function(){this.modulus=new n.org.pkijs.asn1.INTEGER;this.publicExponent=new n.org.pkijs.asn1.INTEGER;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.RSAPublicKey.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.modulus=arguments[0].modulus||new n.org.pkijs.asn1.INTEGER,this.publicExponent=arguments[0].publicExponent||new n.org.pkijs.asn1.INTEGER)};n.org.pkijs.simpl.x509.RSAPublicKey.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.RSAPublicKey({names:{modulus:"modulus",publicExponent:"publicExponent"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for RSAPublicKey");this.modulus=i.result.modulus;this.publicExponent=i.result.publicExponent};n.org.pkijs.simpl.x509.RSAPublicKey.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.modulus,this.publicExponent]})};n.org.pkijs.simpl.x509.RSAPublicKey.prototype.toJSON=function(){return{modulus:this.modulus.toJSON(),publicExponent:this.publicExponent.toJSON()}};n.org.pkijs.simpl.x509.OtherPrimeInfo=function(){this.prime=new n.org.pkijs.asn1.INTEGER;this.exponent=new n.org.pkijs.asn1.INTEGER;this.coefficient=new n.org.pkijs.asn1.INTEGER;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.OtherPrimeInfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.prime=arguments[0].prime||new n.org.pkijs.asn1.INTEGER,this.exponent=arguments[0].exponent||new n.org.pkijs.asn1.INTEGER,this.coefficient=arguments[0].coefficient||new n.org.pkijs.asn1.INTEGER)};n.org.pkijs.simpl.x509.OtherPrimeInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.OtherPrimeInfo({names:{prime:"prime",exponent:"exponent",coefficient:"coefficient"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for OtherPrimeInfo");this.prime=i.result.prime;this.exponent=i.result.exponent;this.coefficient=i.result.coefficient};n.org.pkijs.simpl.x509.OtherPrimeInfo.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.prime,this.exponent,this.coefficient]})};n.org.pkijs.simpl.x509.OtherPrimeInfo.prototype.toJSON=function(){return{prime:this.prime.toJSON(),exponent:this.exponent.toJSON(),coefficient:this.coefficient.toJSON()}};n.org.pkijs.simpl.x509.RSAPrivateKey=function(){this.version=0;this.modulus=new n.org.pkijs.asn1.INTEGER;this.publicExponent=new n.org.pkijs.asn1.INTEGER;this.privateExponent=new n.org.pkijs.asn1.INTEGER;this.prime1=new n.org.pkijs.asn1.INTEGER;this.prime2=new n.org.pkijs.asn1.INTEGER;this.exponent1=new n.org.pkijs.asn1.INTEGER;this.exponent2=new n.org.pkijs.asn1.INTEGER;this.coefficient=new n.org.pkijs.asn1.INTEGER;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.RSAPrivateKey.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version=arguments[0].version||0,this.modulus=arguments[0].modulus||new n.org.pkijs.asn1.INTEGER,this.publicExponent=arguments[0].publicExponent||new n.org.pkijs.asn1.INTEGER,this.privateExponent=arguments[0].privateExponent||new n.org.pkijs.asn1.INTEGER,this.prime1=arguments[0].prime1||new n.org.pkijs.asn1.INTEGER,this.prime2=arguments[0].prime2||new n.org.pkijs.asn1.INTEGER,this.exponent1=arguments[0].exponent1||new n.org.pkijs.asn1.INTEGER,this.exponent2=arguments[0].exponent2||new n.org.pkijs.asn1.INTEGER,this.coefficient=arguments[0].coefficient||new n.org.pkijs.asn1.INTEGER,"otherPrimeInfos"in arguments[0]&&(this.otherPrimeInfos=arguments[0].otherPrimeInfos||[]))};n.org.pkijs.simpl.x509.RSAPrivateKey.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.RSAPrivateKey({names:{version:"version",modulus:"modulus",publicExponent:"publicExponent",privateExponent:"privateExponent",prime1:"prime1",prime2:"prime2",exponent1:"exponent1",exponent2:"exponent2",coefficient:"coefficient",otherPrimeInfos:"otherPrimeInfos"}})),u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for RSAPrivateKey");if(this.version=i.result.version.value_block.value_dec,this.modulus=i.result.modulus,this.publicExponent=i.result.publicExponent,this.privateExponent=i.result.privateExponent,this.prime1=i.result.prime1,this.prime2=i.result.prime2,this.exponent1=i.result.exponent1,this.exponent2=i.result.exponent2,this.coefficient=i.result.coefficient,"otherPrimeInfos"in i.result)for(u=i.result.otherPrimeInfos,r=0;r<u.length;r++)this.otherPrimeInfos.push(new n.org.pkijs.simpl.x509.OtherPrimeInfo({schema:u[r]}))};n.org.pkijs.simpl.x509.RSAPrivateKey.prototype.toSchema=function(){var t=[],r,i;if(t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),t.push(this.modulus),t.push(this.publicExponent),t.push(this.privateExponent),t.push(this.prime1),t.push(this.prime2),t.push(this.exponent1),t.push(this.exponent2),t.push(this.coefficient),"otherPrimeInfos"in this){for(r=[],i=0;i<this.otherPrimeInfos.length;i++)r.push(this.otherPrimeInfos[i].toSchema());t.push(new n.org.pkijs.asn1.SEQUENCE({value:r}))}return new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.x509.RSAPrivateKey.prototype.toJSON=function(){var t={version:this.version,modulus:this.modulus.toJSON(),publicExponent:this.publicExponent.toJSON(),privateExponent:this.privateExponent.toJSON(),prime1:this.prime1.toJSON(),prime2:this.prime2.toJSON(),exponent1:this.exponent1.toJSON(),exponent2:this.exponent2.toJSON(),coefficient:this.coefficient.toJSON()},n;if("otherPrimeInfos"in this)for(t.otherPrimeInfos=[],n=0;n<this.otherPrimeInfos.length;n++)t.otherPrimeInfos.push(this.otherPrimeInfos[n].toJSON());return t};n.org.pkijs.simpl.x509.RSASSA_PSS_params=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.RSASSA_PSS_params.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&("hashAlgorithm"in arguments[0]&&(this.hashAlgorithm=arguments[0].hashAlgorithm),"maskGenAlgorithm"in arguments[0]&&(this.maskGenAlgorithm=arguments[0].maskGenAlgorithm),"saltLength"in arguments[0]&&(this.saltLength=arguments[0].saltLength),"trailerField"in arguments[0]&&(this.trailerField=arguments[0].trailerField))};n.org.pkijs.simpl.x509.RSASSA_PSS_params.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.RSASSA_PSS_params({names:{hashAlgorithm:{names:{block_name:"hashAlgorithm"}},maskGenAlgorithm:{names:{block_name:"maskGenAlgorithm"}},saltLength:"saltLength",trailerField:"trailerField"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for RSASSA_PSS_params");"hashAlgorithm"in i.result&&(this.hashAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.hashAlgorithm}));"maskGenAlgorithm"in i.result&&(this.maskGenAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.maskGenAlgorithm}));"saltLength"in i.result&&(this.saltLength=i.result.saltLength.value_block.value_dec);"trailerField"in i.result&&(this.trailerField=i.result.trailerField.value_block.value_dec)};n.org.pkijs.simpl.x509.RSASSA_PSS_params.prototype.toSchema=function(){var t=[];return"hashAlgorithm"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[this.hashAlgorithm.toSchema()]})),"maskGenAlgorithm"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:1},value:[this.maskGenAlgorithm.toSchema()]})),"saltLength"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:2},value:[new n.org.pkijs.asn1.INTEGER({value:this.saltLength})]})),"trailerField"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:3},value:[new n.org.pkijs.asn1.INTEGER({value:this.trailerField})]})),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.x509.RSASSA_PSS_params.prototype.toJSON=function(){var n={};return"hashAlgorithm"in this&&(n.hashAlgorithm=this.hashAlgorithm.toJSON()),"maskGenAlgorithm"in this&&(n.maskGenAlgorithm=this.maskGenAlgorithm.toJSON()),"saltLength"in this&&(n.saltLength=this.saltLength.toJSON()),"trailerField"in this&&(n.trailerField=this.trailerField.toJSON()),n};n.org.pkijs.simpl.PUBLIC_KEY_INFO=function(){this.algorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.subjectPublicKey=new n.org.pkijs.asn1.BITSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.PUBLIC_KEY_INFO.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.algorithm=arguments[0].algorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.subjectPublicKey=arguments[0].subjectPublicKey||new n.org.pkijs.asn1.BITSTRING)};n.org.pkijs.simpl.PUBLIC_KEY_INFO.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.PUBLIC_KEY_INFO({names:{algorithm:{names:{block_name:"algorithm"}},subjectPublicKey:"subjectPublicKey"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PUBLIC_KEY_INFO");this.algorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.algorithm});this.subjectPublicKey=i.result.subjectPublicKey};n.org.pkijs.simpl.PUBLIC_KEY_INFO.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.algorithm.toSchema(),this.subjectPublicKey]})};n.org.pkijs.simpl.PUBLIC_KEY_INFO.prototype.importKey=function(t){var i=Promise.resolve(),u=this,r;return typeof t=="undefined"?new Promise(function(n,t){t("Need to provide publicKey input parameter")}):(r=n.org.pkijs.getCrypto(),typeof r=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):(i=i.then(function(){return r.exportKey("spki",t)}),i.then(function(t){var i=n.org.pkijs.fromBER(t);try{n.org.pkijs.simpl.PUBLIC_KEY_INFO.prototype.fromSchema.call(u,i.result)}catch(r){return new Promise(function(n,t){t("Error during initializing object from schema")})}},function(n){return new Promise(function(t,i){i("Error during exporting public key: "+n)})}))};n.org.pkijs.simpl.PUBLIC_KEY_INFO.prototype.toJSON=function(){return{algorithm:this.algorithm.toJSON(),subjectPublicKey:this.subjectPublicKey.toJSON()}};n.org.pkijs.simpl.ATTR_TYPE_AND_VALUE=function(){this.type="";this.value={};arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.ATTR_TYPE_AND_VALUE.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.type=arguments[0].type||"",this.value=arguments[0].value||{})};n.org.pkijs.simpl.ATTR_TYPE_AND_VALUE.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.ATTR_TYPE_AND_VALUE({names:{type:"type",value:"typeValue"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for ATTR_TYPE_AND_VALUE");this.type=i.result.type.value_block.toString();this.value=i.result.typeValue};n.org.pkijs.simpl.ATTR_TYPE_AND_VALUE.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.type}),this.value]})};n.org.pkijs.simpl.ATTR_TYPE_AND_VALUE.prototype.isEqual=function(){if(arguments[0]instanceof n.org.pkijs.simpl.ATTR_TYPE_AND_VALUE){if(this.type!==arguments[0].type)return!1;if(this.value instanceof n.org.pkijs.asn1.UTF8STRING&&arguments[0].value instanceof n.org.pkijs.asn1.UTF8STRING||this.value instanceof n.org.pkijs.asn1.BMPSTRING&&arguments[0].value instanceof n.org.pkijs.asn1.BMPSTRING||this.value instanceof n.org.pkijs.asn1.UNIVERSALSTRING&&arguments[0].value instanceof n.org.pkijs.asn1.UNIVERSALSTRING||this.value instanceof n.org.pkijs.asn1.NUMERICSTRING&&arguments[0].value instanceof n.org.pkijs.asn1.NUMERICSTRING||this.value instanceof n.org.pkijs.asn1.PRINTABLESTRING&&arguments[0].value instanceof n.org.pkijs.asn1.PRINTABLESTRING||this.value instanceof n.org.pkijs.asn1.TELETEXSTRING&&arguments[0].value instanceof n.org.pkijs.asn1.TELETEXSTRING||this.value instanceof n.org.pkijs.asn1.VIDEOTEXSTRING&&arguments[0].value instanceof n.org.pkijs.asn1.VIDEOTEXSTRING||this.value instanceof n.org.pkijs.asn1.IA5STRING&&arguments[0].value instanceof n.org.pkijs.asn1.IA5STRING||this.value instanceof n.org.pkijs.asn1.GRAPHICSTRING&&arguments[0].value instanceof n.org.pkijs.asn1.GRAPHICSTRING||this.value instanceof n.org.pkijs.asn1.VISIBLESTRING&&arguments[0].value instanceof n.org.pkijs.asn1.VISIBLESTRING||this.value instanceof n.org.pkijs.asn1.GENERALSTRING&&arguments[0].value instanceof n.org.pkijs.asn1.GENERALSTRING||this.value instanceof n.org.pkijs.asn1.CHARACTERSTRING&&arguments[0].value instanceof n.org.pkijs.asn1.CHARACTERSTRING){var t=n.org.pkijs.stringPrep(this.value.value_block.value),i=n.org.pkijs.stringPrep(arguments[0].value.value_block.value);if(t.localeCompare(i)!==0)return!1}else if(n.org.pkijs.isEqual_buffer(this.value.value_before_decode,arguments[0].value.value_before_decode)===!1)return!1;return!0}return!1};n.org.pkijs.simpl.ATTR_TYPE_AND_VALUE.prototype.toJSON=function(){var n={type:this.type};return n.value=Object.keys(this.value).length!==0?this.value.toJSON():this.value,n};n.org.pkijs.simpl.RDN=function(){this.types_and_values=[];this.value_before_decode=new ArrayBuffer(0);arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.RDN.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.types_and_values=arguments[0].types_and_values||[],this.value_before_decode=arguments[0].value_before_decode||new ArrayBuffer(0))};n.org.pkijs.simpl.RDN.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.RDN({names:{block_name:"RDN",repeated_set:"types_and_values"}})),u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for RDN");if("types_and_values"in i.result)for(u=i.result.types_and_values,r=0;r<u.length;r++)this.types_and_values.push(new n.org.pkijs.simpl.ATTR_TYPE_AND_VALUE({schema:u[r]}));this.value_before_decode=i.result.RDN.value_before_decode};n.org.pkijs.simpl.RDN.prototype.toSchema=function(){var i,t,r;if(this.value_before_decode.byteLength===0){for(i=[],t=0;t<this.types_and_values.length;t++)i.push(this.types_and_values[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.SET({value:i})]})}return r=n.org.pkijs.fromBER(this.value_before_decode),r.result};n.org.pkijs.simpl.RDN.prototype.isEqual=function(){if(arguments[0]instanceof n.org.pkijs.simpl.RDN){if(this.types_and_values.length!=arguments[0].types_and_values.length)return!1;for(var t=0;t<this.types_and_values.length;t++)if(this.types_and_values[t].isEqual(arguments[0].types_and_values[t])===!1)return!1;return!0}return arguments[0]instanceof ArrayBuffer?n.org.pkijs.isEqual_buffer(this.value_before_decode,arguments[0]):!1};n.org.pkijs.simpl.RDN.prototype.toJSON=function(){for(var t={types_and_values:[]},n=0;n<this.types_and_values.length;n++)t.types_and_values.push(this.types_and_values[n].toJSON());return t};n.org.pkijs.simpl.x509.AuthorityKeyIdentifier=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.AuthorityKeyIdentifier.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&("keyIdentifier"in arguments[0]&&(this.keyIdentifier=arguments[0].keyIdentifier),"authorityCertIssuer"in arguments[0]&&(this.authorityCertIssuer=arguments[0].authorityCertIssuer),"authorityCertSerialNumber"in arguments[0]&&(this.authorityCertSerialNumber=arguments[0].authorityCertSerialNumber))};n.org.pkijs.simpl.x509.AuthorityKeyIdentifier.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.AuthorityKeyIdentifier({names:{keyIdentifier:"keyIdentifier",authorityCertIssuer:"authorityCertIssuer",authorityCertSerialNumber:"authorityCertSerialNumber"}})),u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for AuthorityKeyIdentifier");if("keyIdentifier"in i.result&&(i.result.keyIdentifier.id_block.tag_class=1,i.result.keyIdentifier.id_block.tag_number=4,this.keyIdentifier=i.result.keyIdentifier),"authorityCertIssuer"in i.result)for(this.authorityCertIssuer=[],u=i.result.authorityCertIssuer,r=0;r<u.length;r++)this.authorityCertIssuer.push(new n.org.pkijs.simpl.GENERAL_NAME({schema:u[r]}));"authorityCertSerialNumber"in i.result&&(i.result.authorityCertSerialNumber.id_block.tag_class=1,i.result.authorityCertSerialNumber.id_block.tag_number=2,this.authorityCertSerialNumber=i.result.authorityCertSerialNumber)};n.org.pkijs.simpl.x509.AuthorityKeyIdentifier.prototype.toSchema=function(){var i=[],u,r,t;if("keyIdentifier"in this&&(t=this.keyIdentifier,t.id_block.tag_class=3,t.id_block.tag_number=0,i.push(t)),"authorityCertIssuer"in this){for(u=[],r=0;r<this.authorityCertIssuer.length;r++)u.push(this.authorityCertIssuer[r].toSchema());i.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.SEQUENCE({value:u})]}))}return"authorityCertSerialNumber"in this&&(t=this.authorityCertSerialNumber,t.id_block.tag_class=3,t.id_block.tag_number=2,i.push(t)),new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.AuthorityKeyIdentifier.prototype.toJSON=function(){var n={},t;if("keyIdentifier"in this&&(n.keyIdentifier=this.keyIdentifier.toJSON()),"authorityCertIssuer"in this)for(n.authorityCertIssuer=[],t=0;t<this.authorityCertIssuer.length;t++)n.authorityCertIssuer.push(this.authorityCertIssuer[t].toJSON());return"authorityCertSerialNumber"in this&&(n.authorityCertSerialNumber=this.authorityCertSerialNumber.toJSON()),n};n.org.pkijs.simpl.x509.PrivateKeyUsagePeriod=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.PrivateKeyUsagePeriod.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&("notBefore"in arguments[0]&&(this.notBefore=arguments[0].notBefore),"notAfter"in arguments[0]&&(this.notAfter=arguments[0].notAfter))};n.org.pkijs.simpl.x509.PrivateKeyUsagePeriod.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.PrivateKeyUsagePeriod({names:{notBefore:"notBefore",notAfter:"notAfter"}})),r,u;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PrivateKeyUsagePeriod");"notBefore"in i.result&&(r=new n.org.pkijs.asn1.GENERALIZEDTIME,r.fromBuffer(i.result.notBefore.value_block.value_hex),this.notBefore=r.toDate());"notAfter"in i.result&&(u=new n.org.pkijs.asn1.GENERALIZEDTIME({value_hex:i.result.notAfter.value_block.value_hex}),u.fromBuffer(i.result.notAfter.value_block.value_hex),this.notAfter=u.toDate())};n.org.pkijs.simpl.x509.PrivateKeyUsagePeriod.prototype.toSchema=function(){var t=[];return"notBefore"in this&&t.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({id_block:{tag_class:3,tag_number:0},value_hex:new n.org.pkijs.asn1.GENERALIZEDTIME({value_date:this.notBefore}).value_block.value_hex})),"notAfter"in this&&t.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({id_block:{tag_class:3,tag_number:1},value_hex:new n.org.pkijs.asn1.GENERALIZEDTIME({value_date:this.notAfter}).value_block.value_hex})),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.x509.PrivateKeyUsagePeriod.prototype.toJSON=function(){var n={};return"notBefore"in this&&(n.notBefore=this.notBefore),"notAfter"in this&&(n.notAfter=this.notAfter),n};n.org.pkijs.simpl.x509.AltName=function(){this.altNames=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.AltName.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.altNames=arguments[0].altNames||[])};n.org.pkijs.simpl.x509.AltName.prototype.fromSchema=function(t){var r=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.AltName({names:{altNames:"altNames"}})),u,i;if(r.verified===!1)throw new Error("Object's schema was not verified against input data for AltName");if("altNames"in r.result)for(u=r.result.altNames,i=0;i<u.length;i++)this.altNames.push(new n.org.pkijs.simpl.GENERAL_NAME({schema:u[i]}))};n.org.pkijs.simpl.x509.AltName.prototype.toSchema=function(){for(var i=[],t=0;t<this.altNames.length;t++)i.push(this.altNames[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.AltName.prototype.toJSON=function(){for(var t={altNames:[]},n=0;n<this.altNames.length;n++)t.altNames.push(this.altNames[n].toJSON());return t};n.org.pkijs.simpl.x509.SubjectDirectoryAttributes=function(){this.attributes=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.SubjectDirectoryAttributes.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.attributes=arguments[0].attributes||[])};n.org.pkijs.simpl.x509.SubjectDirectoryAttributes.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.SubjectDirectoryAttributes({names:{attributes:"attributes"}})),r,i;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for SubjectDirectoryAttributes");for(r=u.result.attributes,i=0;i<r.length;i++)this.attributes.push(new n.org.pkijs.simpl.ATTRIBUTE({schema:r[i]}))};n.org.pkijs.simpl.x509.SubjectDirectoryAttributes.prototype.toSchema=function(){for(var i=[],t=0;t<this.attributes.length;t++)i.push(this.attributes[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.SubjectDirectoryAttributes.prototype.toJSON=function(){for(var t={attributes:[]},n=0;n<this.attributes.length;n++)t.attributes.push(this.attributes[n].toJSON());return t};n.org.pkijs.simpl.x509.PolicyMapping=function(){this.issuerDomainPolicy="";this.subjectDomainPolicy="";arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.PolicyMapping.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.issuerDomainPolicy=arguments[0].issuerDomainPolicy||"",this.subjectDomainPolicy=arguments[0].subjectDomainPolicy||"")};n.org.pkijs.simpl.x509.PolicyMapping.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.PolicyMapping({names:{issuerDomainPolicy:"issuerDomainPolicy",subjectDomainPolicy:"subjectDomainPolicy"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PolicyMapping");this.issuerDomainPolicy=i.result.issuerDomainPolicy.value_block.toString();this.subjectDomainPolicy=i.result.subjectDomainPolicy.value_block.toString()};n.org.pkijs.simpl.x509.PolicyMapping.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.issuerDomainPolicy}),new n.org.pkijs.asn1.OID({value:this.subjectDomainPolicy})]})};n.org.pkijs.simpl.x509.PolicyMapping.prototype.toJSON=function(){return{issuerDomainPolicy:this.issuerDomainPolicy,subjectDomainPolicy:this.subjectDomainPolicy}};n.org.pkijs.simpl.x509.PolicyMappings=function(){this.mappings=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.PolicyMappings.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.mappings=arguments[0].mappings||[])};n.org.pkijs.simpl.x509.PolicyMappings.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.PolicyMappings({names:{mappings:"mappings"}})),r,i;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for PolicyMappings");for(r=u.result.mappings,i=0;i<r.length;i++)this.mappings.push(new n.org.pkijs.simpl.x509.PolicyMapping({schema:r[i]}))};n.org.pkijs.simpl.x509.PolicyMappings.prototype.toSchema=function(){for(var i=[],t=0;t<this.mappings.length;t++)i.push(this.mappings.toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.PolicyMappings.prototype.toJSON=function(){for(var t={mappings:[]},n=0;n<this.mappings.length;n++)t.mappings.push(this.mappings[n].toJSON());return t};n.org.pkijs.simpl.x509.GeneralSubtree=function(){this.base=new n.org.pkijs.simpl.GENERAL_NAME;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.GeneralSubtree.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.base=arguments[0].base||new n.org.pkijs.simpl.GENERAL_NAME,"minimum"in arguments[0]&&(this.minimum=arguments[0].minimum),"maximum"in arguments[0]&&(this.maximum=arguments[0].maximum))};n.org.pkijs.simpl.x509.GeneralSubtree.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.GeneralSubtree({names:{base:{names:{block_name:"base"}},minimum:"minimum",maximum:"maximum"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for ");this.base=new n.org.pkijs.simpl.GENERAL_NAME({schema:i.result.base});"minimum"in i.result&&(this.minimum=i.result.minimum.value_block.is_hex_only?i.result.minimum:i.result.minimum.value_block.value_dec);"maximum"in i.result&&(this.maximum=i.result.maximum.value_block.is_hex_only?i.result.maximum:i.result.maximum.value_block.value_dec)};n.org.pkijs.simpl.x509.GeneralSubtree.prototype.toSchema=function(){var t=[],i,r;return t.push(this.base.toSchema()),"minimum"in this&&(i=0,i=this.minimum instanceof n.org.pkijs.asn1.INTEGER?this.minimum:new n.org.pkijs.asn1.INTEGER({value:this.minimum}),t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[i]}))),"maximum"in this&&(r=0,r=this.maximum instanceof n.org.pkijs.asn1.INTEGER?this.maximum:new n.org.pkijs.asn1.INTEGER({value:this.maximum}),t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[r]}))),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.x509.GeneralSubtree.prototype.toJSON=function(){var n={base:this.base.toJSON()};return"minimum"in this&&(n.minimum=typeof this.minimum=="number"?this.minimum:this.minimum.toJSON()),"maximum"in this&&(n.maximum=typeof this.maximum=="number"?this.maximum:this.maximum.toJSON()),n};n.org.pkijs.simpl.x509.NameConstraints=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.NameConstraints.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&("permittedSubtrees"in arguments[0]&&(this.permittedSubtrees=arguments[0].permittedSubtrees),"excludedSubtrees"in arguments[0]&&(this.excludedSubtrees=arguments[0].excludedSubtrees))};n.org.pkijs.simpl.x509.NameConstraints.prototype.fromSchema=function(t){var r=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.NameConstraints({names:{permittedSubtrees:"permittedSubtrees",excludedSubtrees:"excludedSubtrees"}})),u,f,i;if(r.verified===!1)throw new Error("Object's schema was not verified against input data for NameConstraints");if("permittedSubtrees"in r.result)for(this.permittedSubtrees=[],u=r.result.permittedSubtrees,i=0;i<u.length;i++)this.permittedSubtrees.push(new n.org.pkijs.simpl.x509.GeneralSubtree({schema:u[i]}));if("excludedSubtrees"in r.result)for(this.excludedSubtrees=[],f=r.result.excludedSubtrees,i=0;i<f.length;i++)this.excludedSubtrees.push(new n.org.pkijs.simpl.x509.GeneralSubtree({schema:f[i]}))};n.org.pkijs.simpl.x509.NameConstraints.prototype.toSchema=function(){var i=[],r,u,t;if("permittedSubtrees"in this){for(r=[],t=0;t<this.permittedSubtrees.length;t++)r.push(this.permittedSubtrees[t].toSchema());i.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.SEQUENCE({value:r})]}))}if("excludedSubtrees"in this){for(u=[],t=0;t<this.excludedSubtrees.length;t++)u.push(this.excludedSubtrees[t].toSchema());i.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.SEQUENCE({value:u})]}))}return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.NameConstraints.prototype.toJSON=function(){var t={},n;if("permittedSubtrees"in this)for(t.permittedSubtrees=[],n=0;n<this.permittedSubtrees.length;n++)t.permittedSubtrees.push(this.permittedSubtrees[n].toJSON());if("excludedSubtrees"in this)for(t.excludedSubtrees=[],n=0;n<this.excludedSubtrees.length;n++)t.excludedSubtrees.push(this.excludedSubtrees[n].toJSON());return t};n.org.pkijs.simpl.x509.BasicConstraints=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.BasicConstraints.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&("cA"in arguments[0]&&(this.cA=arguments[0].cA),"pathLenConstraint"in arguments[0]&&(this.pathLenConstraint=arguments[0].pathLenConstraint))};n.org.pkijs.simpl.x509.BasicConstraints.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.BasicConstraints({names:{cA:"cA",pathLenConstraint:"pathLenConstraint"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for BasicConstraints");"cA"in i.result&&(this.cA=i.result.cA.value_block.value);"pathLenConstraint"in i.result&&(this.pathLenConstraint=i.result.pathLenConstraint.value_block.value_dec)};n.org.pkijs.simpl.x509.BasicConstraints.prototype.toSchema=function(){var t=[];return"cA"in this&&t.push(new n.org.pkijs.asn1.BOOLEAN({value:this.cA})),"pathLenConstraint"in this&&t.push(new n.org.pkijs.asn1.INTEGER({value:this.pathLenConstraint})),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.x509.BasicConstraints.prototype.toJSON=function(){var n={};return"cA"in this&&(n.cA=this.cA),"pathLenConstraint"in this&&(n.pathLenConstraint=this.pathLenConstraint),n};n.org.pkijs.simpl.x509.PolicyQualifierInfo=function(){this.policyQualifierId="";this.qualifier=new n.org.pkijs.asn1.ANY;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.PolicyQualifierInfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.policyQualifierId=arguments[0].policyQualifierId||"",this.qualifier=arguments[0].qualifier||new n.org.pkijs.asn1.ANY)};n.org.pkijs.simpl.x509.PolicyQualifierInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.PolicyQualifierInfo({names:{policyQualifierId:"policyQualifierId",qualifier:"qualifier"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PolicyQualifierInfo");this.policyQualifierId=i.result.policyQualifierId.value_block.toString();this.qualifier=i.result.qualifier};n.org.pkijs.simpl.x509.PolicyQualifierInfo.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.policyQualifierId}),this.qualifier]})};n.org.pkijs.simpl.x509.PolicyQualifierInfo.prototype.toJSON=function(){return{policyQualifierId:this.policyQualifierId,qualifier:this.qualifier.toJSON()}};n.org.pkijs.simpl.x509.PolicyInformation=function(){this.policyIdentifier="";arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.PolicyInformation.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.policyIdentifier=arguments[0].policyIdentifier||"","policyQualifiers"in arguments[0]&&(this.policyQualifiers=arguments[0].policyQualifiers))};n.org.pkijs.simpl.x509.PolicyInformation.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.PolicyInformation({names:{policyIdentifier:"policyIdentifier",policyQualifiers:"policyQualifiers"}})),u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PolicyInformation");if(this.policyIdentifier=i.result.policyIdentifier.value_block.toString(),"policyQualifiers"in i.result)for(this.policyQualifiers=[],u=i.result.policyQualifiers,r=0;r<u.length;r++)this.policyQualifiers.push(new n.org.pkijs.simpl.x509.PolicyQualifierInfo({schema:u[r]}))};n.org.pkijs.simpl.x509.PolicyInformation.prototype.toSchema=function(){var i=[],r,t;if(i.push(new n.org.pkijs.asn1.OID({value:this.policyIdentifier})),"policyQualifiers"in this){for(r=[],t=0;t<this.policyQualifiers.length;t++)r.push(this.policyQualifiers[t].toSchema());i.push(new n.org.pkijs.asn1.SEQUENCE({value:r}))}return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.PolicyInformation.prototype.toJSON=function(){var t={policyIdentifier:this.policyIdentifier},n;if("policyQualifiers"in this)for(t.policyQualifiers=[],n=0;n<this.policyQualifiers.length;n++)t.policyQualifiers.push(this.policyQualifiers[n].toJSON());return t};n.org.pkijs.simpl.x509.CertificatePolicies=function(){this.certificatePolicies=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.CertificatePolicies.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.certificatePolicies=arguments[0].certificatePolicies||[])};n.org.pkijs.simpl.x509.CertificatePolicies.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.CertificatePolicies({names:{certificatePolicies:"certificatePolicies"}})),r,i;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for CertificatePolicies");for(r=u.result.certificatePolicies,i=0;i<r.length;i++)this.certificatePolicies.push(new n.org.pkijs.simpl.x509.PolicyInformation({schema:r[i]}))};n.org.pkijs.simpl.x509.CertificatePolicies.prototype.toSchema=function(){for(var i=[],t=0;t<this.certificatePolicies.length;t++)i.push(this.certificatePolicies[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.CertificatePolicies.prototype.toJSON=function(){for(var t={certificatePolicies:[]},n=0;n<this.certificatePolicies.length;n++)t.certificatePolicies.push(this.certificatePolicies[n].toJSON());return t};n.org.pkijs.simpl.x509.PolicyConstraints=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.PolicyConstraints.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.requireExplicitPolicy=arguments[0].requireExplicitPolicy||0,this.inhibitPolicyMapping=arguments[0].inhibitPolicyMapping||0)};n.org.pkijs.simpl.x509.PolicyConstraints.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.PolicyConstraints({names:{requireExplicitPolicy:"requireExplicitPolicy",inhibitPolicyMapping:"inhibitPolicyMapping"}})),r,f,e,u,o,s;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PolicyConstraints");"requireExplicitPolicy"in i.result&&(r=i.result.requireExplicitPolicy,r.id_block.tag_class=1,r.id_block.tag_number=2,f=r.toBER(!1),e=n.org.pkijs.fromBER(f),this.requireExplicitPolicy=e.result.value_block.value_dec);"inhibitPolicyMapping"in i.result&&(u=i.result.inhibitPolicyMapping,u.id_block.tag_class=1,u.id_block.tag_number=2,o=u.toBER(!1),s=n.org.pkijs.fromBER(o),this.inhibitPolicyMapping=s.result.value_block.value_dec)};n.org.pkijs.simpl.x509.PolicyConstraints.prototype.toSchema=function(){var i=[],t,r;return"requireExplicitPolicy"in this&&(t=new n.org.pkijs.asn1.INTEGER({value:this.requireExplicitPolicy}),t.id_block.tag_class=3,t.id_block.tag_number=0,i.push(t)),"inhibitPolicyMapping"in this&&(r=new n.org.pkijs.asn1.INTEGER({value:this.inhibitPolicyMapping}),t.id_block.tag_class=3,t.id_block.tag_number=1,i.push(r)),new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.PolicyConstraints.prototype.toJSON=function(){var n={};return"requireExplicitPolicy"in this&&(n.requireExplicitPolicy=this.requireExplicitPolicy),"inhibitPolicyMapping"in this&&(n.inhibitPolicyMapping=this.inhibitPolicyMapping),n};n.org.pkijs.simpl.x509.ExtKeyUsage=function(){this.keyPurposes=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.ExtKeyUsage.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.keyPurposes=arguments[0].keyPurposes||[])};n.org.pkijs.simpl.x509.ExtKeyUsage.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.ExtKeyUsage({names:{keyPurposes:"keyPurposes"}})),r,i;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for ExtKeyUsage");for(r=u.result.keyPurposes,i=0;i<r.length;i++)this.keyPurposes.push(r[i].value_block.toString())};n.org.pkijs.simpl.x509.ExtKeyUsage.prototype.toSchema=function(){for(var i=[],t=0;t<this.keyPurposes.length;t++)i.push(new n.org.pkijs.asn1.OID({value:this.keyPurposes[t]}));return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.ExtKeyUsage.prototype.toJSON=function(){for(var t={keyPurposes:[]},n=0;n<this.keyPurposes.length;n++)t.keyPurposes.push(this.keyPurposes[n]);return t};n.org.pkijs.simpl.x509.DistributionPoint=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.DistributionPoint.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&("distributionPoint"in arguments[0]&&(this.distributionPoint=arguments[0].distributionPoint),"reasons"in arguments[0]&&(this.reasons=arguments[0].reasons),"cRLIssuer"in arguments[0]&&(this.cRLIssuer=arguments[0].cRLIssuer))};n.org.pkijs.simpl.x509.DistributionPoint.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.DistributionPoint({names:{distributionPoint:"distributionPoint",distributionPoint_names:"distributionPoint_names",reasons:"reasons",cRLIssuer:"cRLIssuer",cRLIssuer_names:"cRLIssuer_names"}})),u,f,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for DistributionPoint");if("distributionPoint"in i.result){if(i.result.distributionPoint.id_block.tag_number==0)for(this.distributionPoint=[],u=i.result.distributionPoint_names,r=0;r<u.length;r++)this.distributionPoint.push(new n.org.pkijs.simpl.GENERAL_NAME({schema:u[r]}));i.result.distributionPoint.id_block.tag_number==1&&(i.result.distributionPoint.id_block.tag_class=1,i.result.distributionPoint.id_block.tag_number=16,this.distributionPoint=new n.org.pkijs.simpl.RDN({schema:i.result.distributionPoint}))}if("reasons"in i.result&&(this.reasons=new n.org.pkijs.asn1.BITSTRING({value_hex:i.result.reasons.value_block.value_hex})),"cRLIssuer"in i.result)for(this.cRLIssuer=[],f=i.result.cRLIssuer_names,r=0;r<f;r++)this.cRLIssuer.push(new n.org.pkijs.simpl.GENERAL_NAME({schema:f[r]}))};n.org.pkijs.simpl.x509.DistributionPoint.prototype.toSchema=function(){var i=[],r,u,f,t;if("distributionPoint"in this){if(this.distributionPoint instanceof Array){for(u=[],t=0;t<this.distributionPoint.length;t++)u.push(this.distributionPoint[t].toSchema());r=new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:u})}else r=new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:1},value:[this.distributionPoint.toSchema()]});i.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[r]}))}if("reasons"in this&&i.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({id_block:{tag_class:3,tag_number:1},value_hex:this.reasons.value_block.value_hex})),"cRLIssuer"in this){for(f=new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:names.cRLIssuer||"",optional:!0,id_block:{tag_class:3,tag_number:2}}),t=0;t<this.cRLIssuer.length;t++)f.value_block.value.push(this.cRLIssuer[t].toSchema());i.push(f)}return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.DistributionPoint.prototype.toJSON=function(){var t={},n;if("distributionPoint"in this)if(this.distributionPoint instanceof Array)for(t.distributionPoint=[],n=0;n<this.distributionPoint.length;n++)t.distributionPoint.push(this.distributionPoint[n].toJSON());else t.distributionPoint=this.distributionPoint.toJSON();if("reasons"in this&&(t.reasons=this.reasons.toJSON()),"cRLIssuer"in this)for(t.cRLIssuer=[],n=0;n<this.cRLIssuer.length;n++)t.cRLIssuer.push(this.cRLIssuer[n].toJSON());return t};n.org.pkijs.simpl.x509.CRLDistributionPoints=function(){this.distributionPoints=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.CRLDistributionPoints.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.distributionPoints=arguments[0].distributionPoints||[])};n.org.pkijs.simpl.x509.CRLDistributionPoints.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.CRLDistributionPoints({names:{distributionPoints:"distributionPoints"}})),r,i;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for CRLDistributionPoints");for(r=u.result.distributionPoints,i=0;i<r.length;i++)this.distributionPoints.push(new n.org.pkijs.simpl.x509.DistributionPoint({schema:r[i]}))};n.org.pkijs.simpl.x509.CRLDistributionPoints.prototype.toSchema=function(){for(var i=[],t=0;t<this.distributionPoints.length;t++)i.push(this.distributionPoints[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.CRLDistributionPoints.prototype.toJSON=function(){for(var t={distributionPoints:[]},n=0;n<this.distributionPoints.length;n++)t.distributionPoints.push(this.distributionPoints[n].toJSON());return t};n.org.pkijs.simpl.x509.AccessDescription=function(){this.accessMethod="";this.accessLocation=new n.org.pkijs.simpl.GENERAL_NAME;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.AccessDescription.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.accessMethod=arguments[0].accessMethod||"",this.accessLocation=arguments[0].accessLocation||new n.org.pkijs.simpl.GENERAL_NAME)};n.org.pkijs.simpl.x509.AccessDescription.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.AccessDescription({names:{accessMethod:"accessMethod",accessLocation:{names:{block_name:"accessLocation"}}}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for AccessDescription");this.accessMethod=i.result.accessMethod.value_block.toString();this.accessLocation=new n.org.pkijs.simpl.GENERAL_NAME({schema:i.result.accessLocation})};n.org.pkijs.simpl.x509.AccessDescription.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.accessMethod}),this.accessLocation.toSchema()]})};n.org.pkijs.simpl.x509.AccessDescription.prototype.toJSON=function(){return{accessMethod:this.accessMethod,accessLocation:this.accessLocation.toJSON()}};n.org.pkijs.simpl.x509.InfoAccess=function(){this.accessDescriptions=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.InfoAccess.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.accessDescriptions=arguments[0].accessDescriptions||[])};n.org.pkijs.simpl.x509.InfoAccess.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.InfoAccess({names:{accessDescriptions:"accessDescriptions"}})),r,i;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for InfoAccess");for(r=u.result.accessDescriptions,i=0;i<r.length;i++)this.accessDescriptions.push(new n.org.pkijs.simpl.x509.AccessDescription({schema:r[i]}))};n.org.pkijs.simpl.x509.InfoAccess.prototype.toSchema=function(){for(var i=[],t=0;t<this.accessDescriptions.length;t++)i.push(this.accessDescriptions[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.x509.InfoAccess.prototype.toJSON=function(){for(var t={accessDescriptions:[]},n=0;n<this.accessDescriptions.length;n++)t.accessDescriptions.push(this.accessDescriptions[n].toJSON());return t};n.org.pkijs.simpl.x509.IssuingDistributionPoint=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.IssuingDistributionPoint.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&("distributionPoint"in arguments[0]&&(this.distributionPoint=arguments[0].distributionPoint),"onlyContainsUserCerts"in arguments[0]&&(this.onlyContainsUserCerts=arguments[0].onlyContainsUserCerts),"onlyContainsCACerts"in arguments[0]&&(this.onlyContainsCACerts=arguments[0].onlyContainsCACerts),"onlySomeReasons"in arguments[0]&&(this.onlySomeReasons=arguments[0].onlySomeReasons),"indirectCRL"in arguments[0]&&(this.indirectCRL=arguments[0].indirectCRL),"onlyContainsAttributeCerts"in arguments[0]&&(this.onlyContainsAttributeCerts=arguments[0].onlyContainsAttributeCerts))};n.org.pkijs.simpl.x509.IssuingDistributionPoint.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.IssuingDistributionPoint({names:{distributionPoint:"distributionPoint",onlyContainsUserCerts:"onlyContainsUserCerts",onlyContainsCACerts:"onlyContainsCACerts",onlySomeReasons:"onlySomeReasons",indirectCRL:"indirectCRL",onlyContainsAttributeCerts:"onlyContainsAttributeCerts"}})),f,u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for IssuingDistributionPoint");if("distributionPoint"in i.result){if(i.result.distributionPoint.id_block.tag_number==0)for(this.distributionPoint=[],f=i.result.distributionPoint_names,u=0;u<f.length;u++)this.distributionPoint.push(new n.org.pkijs.simpl.GENERAL_NAME({schema:f[u]}));i.result.distributionPoint.id_block.tag_number==1&&(i.result.distributionPoint.id_block.tag_class=1,i.result.distributionPoint.id_block.tag_number=16,this.distributionPoint=new n.org.pkijs.simpl.RDN({schema:i.result.distributionPoint}))}"onlyContainsUserCerts"in i.result&&(r=new Uint8Array(i.result.onlyContainsUserCerts.value_block.value_hex),this.onlyContainsUserCerts=r[0]===0?!1:!0);"onlyContainsCACerts"in i.result&&(r=new Uint8Array(i.result.onlyContainsCACerts.value_block.value_hex),this.onlyContainsCACerts=r[0]===0?!1:!0);"onlySomeReasons"in i.result&&(r=new Uint8Array(i.result.onlySomeReasons.value_block.value_hex),this.onlySomeReasons=r[0]);"indirectCRL"in i.result&&(r=new Uint8Array(i.result.indirectCRL.value_block.value_hex),this.indirectCRL=r[0]===0?!1:!0);"onlyContainsAttributeCerts"in i.result&&(r=new Uint8Array(i.result.onlyContainsAttributeCerts.value_block.value_hex),this.onlyContainsAttributeCerts=r[0]===0?!1:!0)};n.org.pkijs.simpl.x509.IssuingDistributionPoint.prototype.toSchema=function(){var r=[],u,f,t,i;if("distributionPoint"in this){if(this.distributionPoint instanceof Array)for(u=new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0}}),f=0;f<this.distributionPoint.length;f++)u.value_block.value.push(this.distributionPoint[f].toSchema());else u=this.distributionPoint.toSchema(),u.id_block.tag_class=3,u.id_block.tag_number=1;r.push(u)}return"onlyContainsUserCerts"in this&&(t=new ArrayBuffer(1),i=new Uint8Array(t),i[0]=this.onlyContainsUserCerts===!1?0:255,r.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:names.onlyContainsUserCerts||"",optional:!0,id_block:{tag_class:3,tag_number:1},value_hex:t}))),"onlyContainsCACerts"in this&&(t=new ArrayBuffer(1),i=new Uint8Array(t),i[0]=this.onlyContainsCACerts===!1?0:255,r.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:names.onlyContainsUserCerts||"",optional:!0,id_block:{tag_class:3,tag_number:2},value_hex:t}))),"onlySomeReasons"in this&&(t=new ArrayBuffer(1),i=new Uint8Array(t),i[0]=this.onlySomeReasons,r.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:names.onlyContainsUserCerts||"",optional:!0,id_block:{tag_class:3,tag_number:3},value_hex:t}))),"indirectCRL"in this&&(t=new ArrayBuffer(1),i=new Uint8Array(t),i[0]=this.indirectCRL===!1?0:255,r.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:names.onlyContainsUserCerts||"",optional:!0,id_block:{tag_class:3,tag_number:4},value_hex:t}))),"onlyContainsAttributeCerts"in this&&(t=new ArrayBuffer(1),i=new Uint8Array(t),i[0]=this.onlyContainsAttributeCerts===!1?0:255,r.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:names.onlyContainsUserCerts||"",optional:!0,id_block:{tag_class:3,tag_number:5},value_hex:t}))),new n.org.pkijs.asn1.SEQUENCE({value:r})};n.org.pkijs.simpl.x509.IssuingDistributionPoint.prototype.toJSON=function(){var n={},t;if("distributionPoint"in this)if(this.distributionPoint instanceof Array)for(n.distributionPoint=[],t=0;t<this.distributionPoint.length;t++)n.distributionPoint.push(this.distributionPoint[t].toJSON());else n.distributionPoint=this.distributionPoint.toJSON();return"onlyContainsUserCerts"in this&&(n.onlyContainsUserCerts=this.onlyContainsUserCerts),"onlyContainsCACerts"in this&&(n.onlyContainsCACerts=this.onlyContainsCACerts),"onlySomeReasons"in this&&(n.onlySomeReasons=this.onlySomeReasons.toJSON()),"indirectCRL"in this&&(n.indirectCRL=this.indirectCRL),"onlyContainsAttributeCerts"in this&&(n.onlyContainsAttributeCerts=this.onlyContainsAttributeCerts),n};n.org.pkijs.simpl.EXTENSION=function(){this.extnID="";this.critical=!1;this.extnValue=new n.org.pkijs.asn1.OCTETSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.EXTENSION.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.extnID=arguments[0].extnID||"",this.critical=arguments[0].critical||!1,this.extnValue="extnValue"in arguments[0]?new n.org.pkijs.asn1.OCTETSTRING({value_hex:arguments[0].extnValue}):new n.org.pkijs.asn1.OCTETSTRING,"parsedValue"in arguments[0]&&(this.parsedValue=arguments[0].parsedValue))};n.org.pkijs.simpl.EXTENSION.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.EXTENSION({names:{extnID:"extnID",critical:"critical",extnValue:"extnValue"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for EXTENSION");if(this.extnID=i.result.extnID.value_block.toString(),"critical"in i.result&&(this.critical=i.result.critical.value_block.value),this.extnValue=i.result.extnValue,i=n.org.pkijs.fromBER(this.extnValue.value_block.value_hex),i.offset!==-1)switch(this.extnID){case"2.5.29.9":this.parsedValue=new n.org.pkijs.simpl.x509.SubjectDirectoryAttributes({schema:i.result});break;case"2.5.29.14":this.parsedValue=i.result;break;case"2.5.29.15":this.parsedValue=i.result;break;case"2.5.29.16":this.parsedValue=new n.org.pkijs.simpl.x509.PrivateKeyUsagePeriod({schema:i.result});break;case"2.5.29.17":case"2.5.29.18":this.parsedValue=new n.org.pkijs.simpl.x509.AltName({schema:i.result});break;case"2.5.29.19":this.parsedValue=new n.org.pkijs.simpl.x509.BasicConstraints({schema:i.result});break;case"2.5.29.20":case"2.5.29.27":this.parsedValue=i.result;break;case"2.5.29.21":this.parsedValue=i.result;break;case"2.5.29.24":this.parsedValue=i.result;break;case"2.5.29.28":this.parsedValue=new n.org.pkijs.simpl.x509.IssuingDistributionPoint({schema:i.result});break;case"2.5.29.29":this.parsedValue=new n.org.pkijs.simpl.GENERAL_NAMES({schema:i.result});break;case"2.5.29.30":this.parsedValue=new n.org.pkijs.simpl.x509.NameConstraints({schema:i.result});break;case"2.5.29.31":case"2.5.29.46":this.parsedValue=new n.org.pkijs.simpl.x509.CRLDistributionPoints({schema:i.result});break;case"2.5.29.32":this.parsedValue=new n.org.pkijs.simpl.x509.CertificatePolicies({schema:i.result});break;case"2.5.29.33":this.parsedValue=new n.org.pkijs.simpl.x509.PolicyMappings({schema:i.result});break;case"2.5.29.35":this.parsedValue=new n.org.pkijs.simpl.x509.AuthorityKeyIdentifier({schema:i.result});break;case"2.5.29.36":this.parsedValue=new n.org.pkijs.simpl.x509.PolicyConstraints({schema:i.result});break;case"2.5.29.37":this.parsedValue=new n.org.pkijs.simpl.x509.ExtKeyUsage({schema:i.result});break;case"2.5.29.54":this.parsedValue=i.result;break;case"1.3.6.1.5.5.7.1.1":case"1.3.6.1.5.5.7.1.11":this.parsedValue=new n.org.pkijs.simpl.x509.InfoAccess({schema:i.result})}};n.org.pkijs.simpl.EXTENSION.prototype.toSchema=function(){var t=[];return t.push(new n.org.pkijs.asn1.OID({value:this.extnID})),this.critical&&t.push(new n.org.pkijs.asn1.BOOLEAN({value:this.critical})),t.push(this.extnValue),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.EXTENSION.prototype.toJSON=function(){var n={extnID:this.extnID,critical:this.critical,extnValue:this.extnValue.toJSON()};return"parsedValue"in this&&(n.parsedValue=this.parsedValue.toJSON()),n};n.org.pkijs.simpl.EXTENSIONS=function(){this.extensions_array=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.EXTENSIONS.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.extensions_array=arguments[0].extensions_array||[])};n.org.pkijs.simpl.EXTENSIONS.prototype.fromSchema=function(t){var r=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.EXTENSIONS({names:{extensions:"extensions"}})),i;if(r.verified===!1)throw new Error("Object's schema was not verified against input data for EXTENSIONS");for(i=0;i<r.result.extensions.length;i++)this.extensions_array.push(new n.org.pkijs.simpl.EXTENSION({schema:r.result.extensions[i]}))};n.org.pkijs.simpl.EXTENSIONS.prototype.toSchema=function(){for(var i=[],t=0;t<this.extensions_array.length;t++)i.push(this.extensions_array[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.EXTENSIONS.prototype.toJSON=function(){for(var t={extensions_array:[]},n=0;n<this.extensions_array.length;n++)t.extensions_array.push(this.extensions_array[n].toJSON());return t};n.org.pkijs.simpl.CERT=function(){this.tbs=new ArrayBuffer(0);this.serialNumber=new n.org.pkijs.asn1.INTEGER;this.signature=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.issuer=new n.org.pkijs.simpl.RDN;this.notBefore=new n.org.pkijs.simpl.TIME;this.notAfter=new n.org.pkijs.simpl.TIME;this.subject=new n.org.pkijs.simpl.RDN;this.subjectPublicKeyInfo=new n.org.pkijs.simpl.PUBLIC_KEY_INFO;this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.signatureValue=new n.org.pkijs.asn1.BITSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CERT.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.tbs=arguments[0].tbs||new ArrayBuffer(0),"version"in arguments[0]&&(this.version=arguments[0].version),this.serialNumber=arguments[0].serialNumber||new n.org.pkijs.asn1.INTEGER,this.signature=arguments[0].signature||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.issuer=arguments[0].issuer||new n.org.pkijs.simpl.RDN,this.notBefore=arguments[0].not_before||new n.org.pkijs.simpl.TIME,this.notAfter=arguments[0].not_after||new n.org.pkijs.simpl.TIME,this.subject=arguments[0].subject||new n.org.pkijs.simpl.RDN,this.subjectPublicKeyInfo=arguments[0].subjectPublicKeyInfo||new n.org.pkijs.simpl.PUBLIC_KEY_INFO,"issuerUniqueID"in arguments[0]&&(this.issuerUniqueID=arguments[0].issuerUniqueID),"subjectUniqueID"in arguments[0]&&(this.subjectUniqueID=arguments[0].subjectUniqueID),"extensions"in arguments[0]&&(this.extensions=arguments[0].extensions),this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.signatureValue=new n.org.pkijs.asn1.BITSTRING)};n.org.pkijs.simpl.CERT.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CERT({names:{tbsCertificate:{names:{extensions:{names:{extensions:"tbsCertificate.extensions"}}}}}})),u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for CERT");if(this.tbs=i.result.tbsCertificate.value_before_decode,"tbsCertificate.version"in i.result&&(this.version=i.result["tbsCertificate.version"].value_block.value_dec),this.serialNumber=i.result["tbsCertificate.serialNumber"],this.signature=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result["tbsCertificate.signature"]}),this.issuer=new n.org.pkijs.simpl.RDN({schema:i.result["tbsCertificate.issuer"]}),this.notBefore=new n.org.pkijs.simpl.TIME({schema:i.result["tbsCertificate.notBefore"]}),this.notAfter=new n.org.pkijs.simpl.TIME({schema:i.result["tbsCertificate.notAfter"]}),this.subject=new n.org.pkijs.simpl.RDN({schema:i.result["tbsCertificate.subject"]}),this.subjectPublicKeyInfo=new n.org.pkijs.simpl.PUBLIC_KEY_INFO({schema:i.result["tbsCertificate.subjectPublicKeyInfo"]}),"tbsCertificate.issuerUniqueID"in i.result&&(this.issuerUniqueID=i.result["tbsCertificate.issuerUniqueID"].value_block.value_hex),"tbsCertificate.subjectUniqueID"in i.result&&(this.issuerUniqueID=i.result["tbsCertificate.subjectUniqueID"].value_block.value_hex),"tbsCertificate.extensions"in i.result)for(this.extensions=[],u=i.result["tbsCertificate.extensions"],r=0;r<u.length;r++)this.extensions.push(new n.org.pkijs.simpl.EXTENSION({schema:u[r]}));this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.signatureAlgorithm});this.signatureValue=i.result.signatureValue};n.org.pkijs.simpl.CERT.prototype.encodeTBS=function(){var t=[],r,i;if("version"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.INTEGER({value:this.version})]})),t.push(this.serialNumber),t.push(this.signature.toSchema()),t.push(this.issuer.toSchema()),t.push(new n.org.pkijs.asn1.SEQUENCE({value:[this.notBefore.toSchema(),this.notAfter.toSchema()]})),t.push(this.subject.toSchema()),t.push(this.subjectPublicKeyInfo.toSchema()),"issuerUniqueID"in this&&t.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:1},value_hex:this.issuerUniqueID})),"subjectUniqueID"in this&&t.push(new n.org.pkijs.asn1.ASN1_PRIMITIVE({optional:!0,id_block:{tag_class:3,tag_number:2},value_hex:this.subjectUniqueID})),"subjectUniqueID"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:3},value:[this.extensions.toSchema()]})),"extensions"in this){for(r=[],i=0;i<this.extensions.length;i++)r.push(this.extensions[i].toSchema());t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:3},value:[new n.org.pkijs.asn1.SEQUENCE({value:r})]}))}return new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.CERT.prototype.toSchema=function(t){var i,r;if(typeof t=="undefined"&&(t=!1),i={},t===!1){if(this.tbs.length===0)return n.org.pkijs.schema.CERT().value[0];r=n.org.pkijs.fromBER(this.tbs);i=r.result}else i=n.org.pkijs.simpl.CERT.prototype.encodeTBS.call(this);return new n.org.pkijs.asn1.SEQUENCE({value:[i,this.signatureAlgorithm.toSchema(),this.signatureValue]})};n.org.pkijs.simpl.CERT.prototype.verify=function(){var f=Promise.resolve(),t={},e=this.signatureValue,o=this.tbs,i=this,r,u;if(this.issuer.isEqual(this.subject))t=this.subjectPublicKeyInfo;else if(arguments[0]instanceof Object&&"issuerCertificate"in arguments[0]&&(t=arguments[0].issuerCertificate.subjectPublicKeyInfo),t instanceof n.org.pkijs.simpl.PUBLIC_KEY_INFO==!1)return new Promise(function(n,t){t("Please provide issuer certificate as a parameter")});return(r=n.org.pkijs.getCrypto(),typeof r=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):(u=n.org.pkijs.getHashAlgorithm(this.signatureAlgorithm),u==="")?new Promise(function(n,t){t("Unsupported signature algorithm: "+i.signatureAlgorithm.algorithm_id)}):(f=f.then(function(){var e=n.org.pkijs.getAlgorithmByOID(i.signatureAlgorithm.algorithm_id),o,f;if("name"in e==!1)return new Promise(function(n,t){t("Unsupported public key algorithm: "+i.signatureAlgorithm.algorithm_id)});o=e.name;f=n.org.pkijs.getAlgorithmParameters(o,"importkey");"hash"in f.algorithm&&(f.algorithm.hash.name=u);var s=t.toSchema(),h=s.toBER(!1),c=new Uint8Array(h);return r.importKey("spki",c,f.algorithm,!0,f.usages)}),f.then(function(t){var s=n.org.pkijs.getAlgorithmParameters(t.algorithm.name,"verify"),h,a,f,c,l;if("hash"in s.algorithm&&(s.algorithm.hash.name=u),h=e.value_block.value_hex,t.algorithm.name==="ECDSA"&&(a=n.org.pkijs.fromBER(h),h=n.org.pkijs.createECDSASignatureFromCMS(a.result)),t.algorithm.name==="RSA-PSS"){try{f=new n.org.pkijs.simpl.x509.RSASSA_PSS_params({schema:i.signatureAlgorithm.algorithm_params})}catch(v){return new Promise(function(n,t){t(v)})}if(s.algorithm.saltLength="saltLength"in f?f.saltLength:20,c="SHA-1","hashAlgorithm"in f){if(l=n.org.pkijs.getAlgorithmByOID(f.hashAlgorithm.algorithm_id),"name"in l==!1)return new Promise(function(n,t){t("Unrecognized hash algorithm: "+f.hashAlgorithm.algorithm_id)});c=l.name}s.algorithm.hash.name=c}return r.verify(s.algorithm,t,new Uint8Array(h),new Uint8Array(o))}))};n.org.pkijs.simpl.CERT.prototype.sign=function(t,i){var u=this,s,r,f,e,h,o;if(typeof t=="undefined")return new Promise(function(n,t){t("Need to provide a private key for signing")});if(typeof i=="undefined")i="SHA-1";else if(s=n.org.pkijs.getOIDByAlgorithm({name:i}),s==="")return new Promise(function(n,t){t("Unsupported hash algorithm: "+i)});r=n.org.pkijs.getAlgorithmParameters(t.algorithm.name,"sign");r.algorithm.hash.name=i;switch(t.algorithm.name.toUpperCase()){case"RSASSA-PKCS1-V1_5":case"ECDSA":u.signature.algorithm_id=n.org.pkijs.getOIDByAlgorithm(r.algorithm);u.signatureAlgorithm.algorithm_id=u.signature.algorithm_id;break;case"RSA-PSS":switch(i.toUpperCase()){case"SHA-256":r.algorithm.saltLength=32;break;case"SHA-384":r.algorithm.saltLength=48;break;case"SHA-512":r.algorithm.saltLength=64}if(f={},i.toUpperCase()!=="SHA-1"){if(e=n.org.pkijs.getOIDByAlgorithm({name:i}),e==="")return new Promise(function(n,t){t("Unsupported hash algorithm: "+i)});f.hashAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:e,algorithm_params:new n.org.pkijs.asn1.NULL});f.maskGenAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.8",algorithm_params:f.hashAlgorithm.toSchema()})}r.algorithm.saltLength!==20&&(f.saltLength=r.algorithm.saltLength);h=new n.org.pkijs.simpl.x509.RSASSA_PSS_params(f);u.signature=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.10",algorithm_params:h.toSchema()});u.signatureAlgorithm=u.signature;break;default:return new Promise(function(n,i){i("Unsupported signature algorithm: "+t.algorithm.name)})}return(u.tbs=n.org.pkijs.simpl.CERT.prototype.encodeTBS.call(this).toBER(!1),o=n.org.pkijs.getCrypto(),typeof o=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):o.sign(r.algorithm,t,new Uint8Array(u.tbs)).then(function(t){r.algorithm.name==="ECDSA"&&(t=n.org.pkijs.createCMSECDSASignature(t));u.signatureValue=new n.org.pkijs.asn1.BITSTRING({value_hex:t})},function(n){return new Promise(function(t,i){i("Signing error: "+n)})})};n.org.pkijs.simpl.CERT.prototype.getPublicKey=function(){var t,u=n.org.pkijs.getCrypto(),i,r,f;if(typeof u=="undefined")return new Promise(function(n,t){t("Unable to create WebCrypto object")});if(arguments[0]instanceof Object)if("algorithm"in arguments[0])t=arguments[0].algorithm;else return new Promise(function(n,t){t('Absent mandatory parameter "algorithm"')});else{if(i=n.org.pkijs.getHashAlgorithm(this.signatureAlgorithm),i==="")return new Promise(function(n,t){t("Unsupported signature algorithm: "+this.signatureAlgorithm.algorithm_id)});if(r=n.org.pkijs.getAlgorithmByOID(this.signatureAlgorithm.algorithm_id),"name"in r==!1)return new Promise(function(n,t){t("Unsupported public key algorithm: "+this.signatureAlgorithm.algorithm_id)});f=r.name;t=n.org.pkijs.getAlgorithmParameters(f,"importkey");"hash"in t.algorithm&&(t.algorithm.hash.name=i)}var e=this.subjectPublicKeyInfo.toSchema(),o=e.toBER(!1),s=new Uint8Array(o);return u.importKey("spki",s,t.algorithm,!0,t.usages)};n.org.pkijs.simpl.CERT.prototype.getKeyHash=function(){var t=n.org.pkijs.getCrypto();return typeof t=="undefined"?new Promise(function(n,t){t("Unable to create WebCrypto object")}):t.digest({name:"sha-1"},new Uint8Array(this.subjectPublicKeyInfo.subjectPublicKey.value_block.value_hex))};n.org.pkijs.simpl.CERT.prototype.toJSON=function(){var t={tbs:n.org.pkijs.bufferToHexCodes(this.tbs,0,this.tbs.byteLength),serialNumber:this.serialNumber.toJSON(),signature:this.signature.toJSON(),issuer:this.issuer.toJSON(),notBefore:this.notBefore.toJSON(),notAfter:this.notAfter.toJSON(),subject:this.subject.toJSON(),subjectPublicKeyInfo:this.subjectPublicKeyInfo.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()},i;if("version"in this&&(t.version=this.version),"issuerUniqueID"in this&&(t.issuerUniqueID=n.org.pkijs.bufferToHexCodes(this.issuerUniqueID,0,this.issuerUniqueID.byteLength)),"subjectUniqueID"in this&&(t.subjectUniqueID=n.org.pkijs.bufferToHexCodes(this.subjectUniqueID,0,this.subjectUniqueID.byteLength)),"extensions"in this)for(t.extensions=[],i=0;i<this.extensions.length;i++)t.extensions.push(this.extensions[i].toJSON());return t};n.org.pkijs.simpl.REV_CERT=function(){this.userCertificate=new n.org.pkijs.asn1.INTEGER;this.revocationDate=new n.org.pkijs.simpl.TIME;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.REV_CERT.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.userCertificate=arguments[0].userCertificate||new n.org.pkijs.asn1.INTEGER,this.revocationDate=arguments[0].revocationDate||new n.org.pkijs.simpl.TIME,"crlEntryExtensions"in arguments[0]&&(this.crlEntryExtensions=arguments[0].crlEntryExtensions))};n.org.pkijs.simpl.REV_CERT.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.INTEGER({name:"userCertificate"}),n.org.pkijs.schema.TIME({names:{utcTimeName:"revocationDate",generalTimeName:"revocationDate"}}),n.org.pkijs.schema.EXTENSIONS({names:{block_name:"crlEntryExtensions"}},!0)]})),u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for REV_CERT");if(this.userCertificate=i.result.userCertificate,this.revocationDate=new n.org.pkijs.simpl.TIME({schema:i.result.revocationDate}),"crlEntryExtensions"in i.result)for(this.crlEntryExtensions=[],u=i.result.crlEntryExtensions.value_block.value,r=0;r<u.length;r++)this.crlEntryExtensions.push(new n.org.pkijs.simpl.EXTENSION({schema:u[r]}))};n.org.pkijs.simpl.REV_CERT.prototype.toSchema=function(){var t=[],r,i;if(t.push(this.userCertificate),t.push(this.revocationDate.toSchema()),"crlEntryExtensions"in this){for(r=[],i=0;i<this.crlEntryExtensions.length;i++)r.push(this.crlEntryExtensions[i].toSchema());t.push(new n.org.pkijs.asn1.SEQUENCE({value:r}))}return new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.REV_CERT.prototype.toJSON=function(){var t={userCertificate:this.userCertificate.toJSON(),revocationDate:this.revocationDate.toJSON},n;if("crlEntryExtensions"in this)for(t.crlEntryExtensions=[],n=0;n<this.crlEntryExtensions.length;n++)t.crlEntryExtensions.push(this.crlEntryExtensions[n].toJSON());return t};n.org.pkijs.simpl.CRL=function(){this.tbs=new ArrayBuffer(0);this.signature=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.issuer=new n.org.pkijs.simpl.RDN;this.thisUpdate=new n.org.pkijs.simpl.TIME;this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.signatureValue=new n.org.pkijs.asn1.BITSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CRL.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.tbs=arguments[0].tbs||new ArrayBuffer(0),"version"in arguments[0]&&(this.version=arguments[0].version),this.signature=arguments[0].signature||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.issuer=arguments[0].issuer||new n.org.pkijs.simpl.RDN,this.thisUpdate=arguments[0].thisUpdate||new n.org.pkijs.simpl.TIME,"nextUpdate"in arguments[0]&&(this.nextUpdate=arguments[0].nextUpdate),"revokedCertificates"in arguments[0]&&(this.revokedCertificates=arguments[0].revokedCertificates),"crlExtensions"in arguments[0]&&(this.crlExtensions=arguments[0].crlExtensions),this.signatureAlgorithm=arguments[0].signatureAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.signatureValue=arguments[0].signatureValue||new n.org.pkijs.asn1.BITSTRING)};n.org.pkijs.simpl.CRL.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CRL()),u,f,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for CRL");if(this.tbs=i.result.tbsCertList.value_before_decode,"tbsCertList.version"in i.result&&(this.version=i.result["tbsCertList.version"].value_block.value_dec),this.signature=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result["tbsCertList.signature"]}),this.issuer=new n.org.pkijs.simpl.RDN({schema:i.result["tbsCertList.issuer"]}),this.thisUpdate=new n.org.pkijs.simpl.TIME({schema:i.result["tbsCertList.thisUpdate"]}),"tbsCertList.nextUpdate"in i.result&&(this.nextUpdate=new n.org.pkijs.simpl.TIME({schema:i.result["tbsCertList.nextUpdate"]})),"tbsCertList.revokedCertificates"in i.result)for(this.revokedCertificates=[],u=i.result["tbsCertList.revokedCertificates"],r=0;r<u.length;r++)this.revokedCertificates.push(new n.org.pkijs.simpl.REV_CERT({schema:u[r]}));if("tbsCertList.extensions"in i.result)for(this.crlExtensions=[],f=i.result["tbsCertList.extensions"].value_block.value,r=0;r<f.length;r++)this.crlExtensions.push(new n.org.pkijs.simpl.EXTENSION({schema:f[r]}));this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.signatureAlgorithm});this.signatureValue=i.result.signatureValue};n.org.pkijs.simpl.CRL.prototype.encodeTBS=function(){var t=[],u,i,f,r;if("version"in this&&t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),t.push(this.signature.toSchema()),t.push(this.issuer.toSchema()),t.push(this.thisUpdate.toSchema()),"nextUpdate"in this&&t.push(this.nextUpdate.toSchema()),"revokedCertificates"in this){for(u=[],i=0;i<this.revokedCertificates.length;i++)u.push(this.revokedCertificates[i].toSchema());t.push(new n.org.pkijs.asn1.SEQUENCE({value:u}))}if("crlExtensions"in this){for(f=[],r=0;r<this.crlExtensions.length;r++)f.push(this.crlExtensions[r].toSchema());t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.SEQUENCE({value:f})]}))}return new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.CRL.prototype.toSchema=function(t){typeof t=="undefined"&&(t=!1);var i;if(t===!1){if(this.tbs.length===0)return n.org.pkijs.schema.CRL();i=n.org.pkijs.fromBER(this.tbs).result}else i=n.org.pkijs.simpl.CRL.prototype.encodeTBS.call(this);return new n.org.pkijs.asn1.SEQUENCE({value:[i,this.signatureAlgorithm.toSchema(),this.signatureValue]})};n.org.pkijs.simpl.CRL.prototype.verify=function(){var f=Promise.resolve(),e=this.signatureValue,o=this.tbs,t=-1,i=this,r,u;return(arguments[0]instanceof Object&&("issuerCertificate"in arguments[0]&&(t=arguments[0].issuerCertificate.subjectPublicKeyInfo),"publicKeyInfo"in arguments[0]&&(t=arguments[0].publicKeyInfo)),t instanceof n.org.pkijs.simpl.PUBLIC_KEY_INFO==!1)?new Promise(function(n,t){t("Issuer's certificate must be provided as an input parameter")}):(r=n.org.pkijs.getCrypto(),typeof r=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):(u=n.org.pkijs.getHashAlgorithm(this.signatureAlgorithm),u==="")?new Promise(function(n,t){t("Unsupported signature algorithm: "+i.signatureAlgorithm.algorithm_id)}):(f=f.then(function(){var o=n.org.pkijs.getAlgorithmByOID(i.signature.algorithm_id),e,f;if(0)return new Promise(function(n,t){t("Unsupported public key algorithm: "+i.signature.algorithm_id)});e=o.name;f=n.org.pkijs.getAlgorithmParameters(e,"importkey");"hash"in f.algorithm&&(f.algorithm.hash.name=u);var s=t.toSchema(),h=s.toBER(!1),c=new Uint8Array(h);return r.importKey("spki",c,f.algorithm,!0,f.usages)}),f.then(function(t){var s=n.org.pkijs.getAlgorithmParameters(t.algorithm.name,"verify"),h,a,f,c,l;if("hash"in s.algorithm&&(s.algorithm.hash.name=u),h=e.value_block.value_hex,t.algorithm.name==="ECDSA"&&(a=n.org.pkijs.fromBER(h),h=n.org.pkijs.createECDSASignatureFromCMS(a.result)),t.algorithm.name==="RSA-PSS"){try{f=new n.org.pkijs.simpl.x509.RSASSA_PSS_params({schema:i.signatureAlgorithm.algorithm_params})}catch(v){return new Promise(function(n,t){t(v)})}if(s.algorithm.saltLength="saltLength"in f?f.saltLength:20,c="SHA-1","hashAlgorithm"in f){if(l=n.org.pkijs.getAlgorithmByOID(f.hashAlgorithm.algorithm_id),"name"in l==!1)return new Promise(function(n,t){t("Unrecognized hash algorithm: "+f.hashAlgorithm.algorithm_id)});c=l.name}s.algorithm.hash.name=c}return r.verify(s.algorithm,t,new Uint8Array(h),new Uint8Array(o))}))};n.org.pkijs.simpl.CRL.prototype.sign=function(t,i){var u=this,s,r,f,e,h,o;if(typeof t=="undefined")return new Promise(function(n,t){t("Need to provide a private key for signing")});if(typeof i=="undefined")i="SHA-1";else if(s=n.org.pkijs.getOIDByAlgorithm({name:i}),s==="")return new Promise(function(n,t){t("Unsupported hash algorithm: "+i)});r=n.org.pkijs.getAlgorithmParameters(t.algorithm.name,"sign");r.algorithm.hash.name=i;switch(t.algorithm.name.toUpperCase()){case"RSASSA-PKCS1-V1_5":case"ECDSA":u.signature.algorithm_id=n.org.pkijs.getOIDByAlgorithm(r.algorithm);u.signatureAlgorithm.algorithm_id=u.signature.algorithm_id;break;case"RSA-PSS":switch(i.toUpperCase()){case"SHA-256":r.algorithm.saltLength=32;break;case"SHA-384":r.algorithm.saltLength=48;break;case"SHA-512":r.algorithm.saltLength=64}if(f={},i.toUpperCase()!=="SHA-1"){if(e=n.org.pkijs.getOIDByAlgorithm({name:i}),e==="")return new Promise(function(n,t){t("Unsupported hash algorithm: "+i)});f.hashAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:e,algorithm_params:new n.org.pkijs.asn1.NULL});f.maskGenAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.8",algorithm_params:f.hashAlgorithm.toSchema()})}r.algorithm.saltLength!==20&&(f.saltLength=r.algorithm.saltLength);h=new n.org.pkijs.simpl.x509.RSASSA_PSS_params(f);u.signature=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.10",algorithm_params:h.toSchema()});u.signatureAlgorithm=u.signature;break;default:return new Promise(function(n,i){i("Unsupported signature algorithm: "+t.algorithm.name)})}return(u.tbs=n.org.pkijs.simpl.CRL.prototype.encodeTBS.call(this).toBER(!1),o=n.org.pkijs.getCrypto(),typeof o=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):o.sign(r.algorithm,t,new Uint8Array(u.tbs)).then(function(t){r.algorithm.name==="ECDSA"&&(t=n.org.pkijs.createCMSECDSASignature(t));u.signatureValue=new n.org.pkijs.asn1.BITSTRING({value_hex:t})},function(n){return new Promise(function(t,i){i("Signing error: "+n)})})};n.org.pkijs.simpl.CRL.prototype.isCertificateRevoked=function(){var t={},i;if((arguments[0]instanceof Object&&"certificate"in arguments[0]&&(t=arguments[0].certificate),t instanceof n.org.pkijs.simpl.CERT==!1)||this.issuer.isEqual(t.issuer)===!1||"revokedCertificates"in this==!1)return!1;for(i=0;i<this.revokedCertificates.length;i++)if(this.revokedCertificates[i].userCertificate.isEqual(t.serialNumber))return!0;return!1};n.org.pkijs.simpl.CRL.prototype.toJSON=function(){var i={tbs:n.org.pkijs.bufferToHexCodes(this.tbs,0,this.tbs.byteLength),signature:this.signature.toJSON(),issuer:this.issuer.toJSON(),thisUpdate:this.thisUpdate.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()},t;if("version"in this&&(i.version=this.version),"nextUpdate"in this&&(i.nextUpdate=this.nextUpdate.toJSON()),"revokedCertificates"in this)for(i.revokedCertificates=[],t=0;t<this.revokedCertificates.length;t++)i.revokedCertificates.push(this.revokedCertificates[t].toJSON());if("crlExtensions"in this)for(i.crlExtensions=[],t=0;t<this.crlExtensions.length;t++)i.crlExtensions.push(this.crlExtensions[t].toJSON());return i};n.org.pkijs.simpl.ATTRIBUTE=function(){this.type="";this.values=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.ATTRIBUTE.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.type=arguments[0].type||"",this.values=arguments[0].values||[])};n.org.pkijs.simpl.ATTRIBUTE.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.ATTRIBUTE({names:{type:"type",values:"values"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for ATTRIBUTE");this.type=i.result.type.value_block.toString();this.values=i.result.values};n.org.pkijs.simpl.ATTRIBUTE.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.type}),new n.org.pkijs.asn1.SET({value:this.values})]})};n.org.pkijs.simpl.ATTRIBUTE.prototype.toJSON=function(){for(var t={type:this.type,values:[]},n=0;n<this.values.length;n++)t.values.push(this.values[n].toJSON());return t};n.org.pkijs.simpl.PKCS10=function(){this.tbs=new ArrayBuffer(0);this.version=0;this.subject=new n.org.pkijs.simpl.RDN;this.subjectPublicKeyInfo=new n.org.pkijs.simpl.PUBLIC_KEY_INFO;this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.signatureValue=new n.org.pkijs.asn1.BITSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.PKCS10.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.tbs=arguments[0].tbs||new ArrayBuffer(0),this.version=arguments[0].version||0,this.subject=arguments[0].subject||new n.org.pkijs.simpl.RDN,this.subjectPublicKeyInfo=arguments[0].subjectPublicKeyInfo||new n.org.pkijs.simpl.PUBLIC_KEY_INFO,"attributes"in arguments[0]&&(this.attributes=arguments[0].attributes),this.signatureAlgorithm=arguments[0].signatureAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.signatureValue=arguments[0].signatureValue||new n.org.pkijs.asn1.BITSTRING)};n.org.pkijs.simpl.PKCS10.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.PKCS10()),u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PKCS10");if(this.tbs=i.result.CertificationRequestInfo.value_before_decode,this.version=i.result["CertificationRequestInfo.version"].value_block.value_dec,this.subject=new n.org.pkijs.simpl.RDN({schema:i.result["CertificationRequestInfo.subject"]}),this.subjectPublicKeyInfo=new n.org.pkijs.simpl.PUBLIC_KEY_INFO({schema:i.result["CertificationRequestInfo.subjectPublicKeyInfo"]}),"CertificationRequestInfo.attributes"in i.result)for(this.attributes=[],u=i.result["CertificationRequestInfo.attributes"],r=0;r<u.length;r++)this.attributes.push(new n.org.pkijs.simpl.ATTRIBUTE({schema:u[r]}));this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.signatureAlgorithm});this.signatureValue=i.result.signatureValue};n.org.pkijs.simpl.PKCS10.prototype.encodeTBS=function(){var t=[],r,i;if(t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),t.push(this.subject.toSchema()),t.push(this.subjectPublicKeyInfo.toSchema()),"attributes"in this){for(r=[],i=0;i<this.attributes.length;i++)r.push(this.attributes[i].toSchema());t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:r}))}return new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.PKCS10.prototype.toSchema=function(t){typeof t=="undefined"&&(t=!1);var i;if(t===!1){if(this.tbs.length===0)return n.org.pkijs.schema.PKCS10();i=n.org.pkijs.fromBER(this.tbs).result}else i=n.org.pkijs.simpl.PKCS10.prototype.encodeTBS.call(this);return new n.org.pkijs.asn1.SEQUENCE({value:[i,this.signatureAlgorithm.toSchema(),this.signatureValue]})};n.org.pkijs.simpl.PKCS10.prototype.verify=function(){var t=this,i="",r=Promise.resolve(),f=this.subjectPublicKeyInfo,e=this.signatureValue,o=this.tbs,u=n.org.pkijs.getCrypto();return typeof u=="undefined"?new Promise(function(n,t){t("Unable to create WebCrypto object")}):(i=n.org.pkijs.getHashAlgorithm(this.signatureAlgorithm),i==="")?new Promise(function(n,i){i("Unsupported signature algorithm: "+t.signatureAlgorithm.algorithm_id)}):(r=r.then(function(){var e=n.org.pkijs.getAlgorithmByOID(t.signatureAlgorithm.algorithm_id),o,r;if("name"in e==!1)return new Promise(function(n,i){i("Unsupported public key algorithm: "+t.signatureAlgorithm.algorithm_id)});o=e.name;r=n.org.pkijs.getAlgorithmParameters(o,"importkey");"hash"in r.algorithm&&(r.algorithm.hash.name=i);var s=f.toSchema(),h=s.toBER(!1),c=new Uint8Array(h);return u.importKey("spki",c,r.algorithm,!0,r.usages)}),r.then(function(r){var s=n.org.pkijs.getAlgorithmParameters(r.algorithm.name,"verify"),h,a,f,c,l;if("hash"in s.algorithm&&(s.algorithm.hash.name=i),h=e.value_block.value_hex,r.algorithm.name==="ECDSA"&&(a=n.org.pkijs.fromBER(h),h=n.org.pkijs.createECDSASignatureFromCMS(a.result)),r.algorithm.name==="RSA-PSS"){try{f=new n.org.pkijs.simpl.x509.RSASSA_PSS_params({schema:t.signatureAlgorithm.algorithm_params})}catch(v){return new Promise(function(n,t){t(v)})}if(s.algorithm.saltLength="saltLength"in f?f.saltLength:20,c="SHA-1","hashAlgorithm"in f){if(l=n.org.pkijs.getAlgorithmByOID(f.hashAlgorithm.algorithm_id),"name"in l==!1)return new Promise(function(n,t){t("Unrecognized hash algorithm: "+f.hashAlgorithm.algorithm_id)});c=l.name}s.algorithm.hash.name=c}return u.verify(s.algorithm,r,new Uint8Array(h),new Uint8Array(o))}))};n.org.pkijs.simpl.PKCS10.prototype.sign=function(t,i){var f=this,s,r,u,e,h,o;if(typeof t=="undefined")return new Promise(function(n,t){t("Need to provide a private key for signing")});if(typeof i=="undefined")i="SHA-1";else if(s=n.org.pkijs.getOIDByAlgorithm({name:i}),s==="")return new Promise(function(n,t){t("Unsupported hash algorithm: "+i)});r=n.org.pkijs.getAlgorithmParameters(t.algorithm.name,"sign");r.algorithm.hash.name=i;switch(t.algorithm.name.toUpperCase()){case"RSASSA-PKCS1-V1_5":case"ECDSA":f.signatureAlgorithm.algorithm_id=n.org.pkijs.getOIDByAlgorithm(r.algorithm);break;case"RSA-PSS":switch(i.toUpperCase()){case"SHA-256":r.algorithm.saltLength=32;break;case"SHA-384":r.algorithm.saltLength=48;break;case"SHA-512":r.algorithm.saltLength=64}if(u={},i.toUpperCase()!=="SHA-1"){if(e=n.org.pkijs.getOIDByAlgorithm({name:i}),e==="")return new Promise(function(n,t){t("Unsupported hash algorithm: "+i)});u.hashAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:e,algorithm_params:new n.org.pkijs.asn1.NULL});u.maskGenAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.8",algorithm_params:u.hashAlgorithm.toSchema()})}r.algorithm.saltLength!==20&&(u.saltLength=r.algorithm.saltLength);h=new n.org.pkijs.simpl.x509.RSASSA_PSS_params(u);f.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.10",algorithm_params:h.toSchema()});break;default:return new Promise(function(n,i){i("Unsupported signature algorithm: "+t.algorithm.name)})}return(f.tbs=n.org.pkijs.simpl.PKCS10.prototype.encodeTBS.call(this).toBER(!1),o=n.org.pkijs.getCrypto(),typeof o=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):o.sign(r.algorithm,t,new Uint8Array(f.tbs)).then(function(t){r.algorithm.name==="ECDSA"&&(t=n.org.pkijs.createCMSECDSASignature(t));f.signatureValue=new n.org.pkijs.asn1.BITSTRING({value_hex:t})},function(n){return new Promise(function(t,i){i("Signing error: "+n)})})};n.org.pkijs.simpl.PKCS10.prototype.toJSON=function(){var i={tbs:n.org.pkijs.bufferToHexCodes(this.tbs,0,this.tbs.byteLength),version:this.version,subject:this.subject.toJSON(),subjectPublicKeyInfo:this.subjectPublicKeyInfo.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()},t;if("attributes"in this)for(i.attributes=[],t=0;t<this.attributes.length;t++)i.attributes.push(this.attributes[t].toJSON());return i};n.org.pkijs.simpl.PKCS8=function(){this.version=0;this.privateKeyAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.privateKey=new n.org.pkijs.asn1.OCTETSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.PKCS8.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version=arguments[0].version||0,this.privateKeyAlgorithm=arguments[0].privateKeyAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.privateKey=arguments[0].privateKey||new n.org.pkijs.asn1.OCTETSTRING,"attributes"in arguments[0]&&(this.attributes=arguments[0].attributes))};n.org.pkijs.simpl.PKCS8.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.PKCS8({names:{version:"version",privateKeyAlgorithm:{names:{block_name:"privateKeyAlgorithm"}},privateKey:"privateKey",attributes:"attributes"}})),u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PKCS8");if(this.version=i.result.version.value_block.value_dec,this.privateKeyAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.privateKeyAlgorithm}),this.privateKey=i.result.privateKey,"attributes"in i.result)for(this.attributes=[],u=i.result.attributes,r=0;r<u.length;r++)this.attributes.push(new n.org.pkijs.simpl.ATTRIBUTE({schema:u[r]}))};n.org.pkijs.simpl.PKCS8.prototype.toSchema=function(){var t=[],r,i;if(t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),t.push(this.privateKeyAlgorithm.toSchema()),t.push(this.privateKey),"attributes"in this){for(r=[],i=0;i<this.attributes.length;i++)r.push(this.attributes[i].toSchema());t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:r}))}return new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.PKCS8.prototype.toJSON=function(){var t={version:this.version,privateKeyAlgorithm:this.privateKeyAlgorithm.toJSON(),privateKey:this.privateKey.toJSON()},n;if("attributes"in this)for(t.attributes=[],n=0;n<this.attributes.length;n++)t.attributes.push(this.attributes[n].toJSON());return t};n.org.pkijs.simpl.CERT_CHAIN=function(){this.trusted_certs=[];this.certs=[];this.crls=[];arguments[0]instanceof Object&&(this.trusted_certs=arguments[0].trusted_certs||[],this.certs=arguments[0].certs||[],this.crls=arguments[0].crls||[])};n.org.pkijs.simpl.CERT_CHAIN.prototype.sort=function(){function p(n,t){function u(n){return i.crls[n].verify({issuerCertificate:t}).then(function(t){return t===!0?new Promise(function(t){t(i.crls[n])}):(n++,n<i.crls.length?u(n):new Promise(function(n,t){t({result:!1,result_code:9,result_message:"Unable to find CRL for issuer's certificate"})}))},function(){return new Promise(function(n,t){t({result:!1,result_code:10,result_message:"Unable to find CRL for issuer's certificate"})})})}var r=Promise.resolve();return(r=r.then(function(){if(n.notBefore.value>v||n.notAfter.value<v)return new Promise(function(n,t){t({result:!1,result_code:8,result_message:"Certificate validity period is out of checking date"})})}),i.crls.length===0)?r.then(function(){return new Promise(function(n){n()})}):(r=r.then(function(){return u(0)}),r.then(function(t){return t.isCertificateRevoked({certificate:n})===!0?new Promise(function(n,t){t({result:!1,result_code:11,result_message:"Subject certificate was revoked"})}):new Promise(function(n){n()})},function(){return new Promise(function(n){n()})}))}function l(){return a(u,0).then(function(t){var e,r;if(f.push(n[t]),u=n[t],n.splice(t,1),u.issuer.isEqual(u.subject)===!0){for(e=i.trusted_certs.length===0?!0:!1,r=0;r<i.trusted_certs.length;r++)if(u.issuer.isEqual(i.trusted_certs[r].issuer)===!0&&u.subject.isEqual(i.trusted_certs[r].subject)===!0&&u.serialNumber.isEqual(i.trusted_certs[r].serialNumber)===!0){e=!0;break}return e===!1?new Promise(function(n,t){t({result:!1,result_code:22,result_message:'Self-signed root certificate not in "trusted certificates" array'})}):u.verify().then(function(n){return n===!0?p(u,u).then(function(){return new Promise(function(n){n(f)})},function(n){return new Promise(function(t,i){i({result:!1,result_code:12,result_message:n})})}):new Promise(function(n,t){t({result:!1,result_code:13,result_message:"Unable to build certificate chain - signature of root certificate is invalid"})})},function(n){return new Promise(function(t,i){i({result:!1,result_code:14,result_message:n})})})}return n.length>0?l():i.trusted_certs.length!==0?(n=i.trusted_certs.splice(0),l()):new Promise(function(n,t){t({result:!1,result_code:23,result_message:"Root certificate not found"})})},function(n){return new Promise(function(t,i){i(n)})})}function a(t,i){return n[i].subject.isEqual(t.issuer)===!0?t.verify({issuerCertificate:n[i]}).then(function(r){return r===!0?p(t,n[i]).then(function(){return new Promise(function(n){n(i)})},function(n){return new Promise(function(t,i){i({result:!1,result_code:16,result_message:n})})}):i<n.length-1?a(t,i+1):new Promise(function(n,t){t({result:!1,result_code:17,result_message:"Unable to build certificate chain - incomplete certificate chain or signature of some certificate is invalid"})})},function(){return new Promise(function(n,t){t({result:!1,result_code:18,result_message:"Unable to build certificate chain - error during certificate signature verification"})})}):i<n.length-1?a(t,i+1):new Promise(function(n,t){t({result:!1,result_code:19,result_message:"Unable to build certificate chain - incomplete certificate chain"})})}var f=[],n=this.certs.slice(0),v=new Date,i=this,o,t,e,r,c,u;if(n.length===0)return new Promise(function(n,t){t({result:!1,result_code:2,result_message:"Certificate's array can not be empty"})});for(o=-1,t=0;t<n.length;t++){if(e=!1,"extensions"in n[t]){var s=!1,h=!1,y=!1;for(r=0;r<n[t].extensions.length;r++){if(n[t].extensions[r].critical===!0&&"parsedValue"in n[t].extensions[r]==!1)return new Promise(function(i,u){u({result:!1,result_code:6,result_message:"Unable to parse critical certificate extension: "+n[t].extensions[r].extnID})});n[t].extensions[r].extnID==="2.5.29.15"&&(h=!0,c=new Uint8Array(n[t].extensions[r].parsedValue.value_block.value_hex),(c[0]&4)==4&&(s=!0),(c[0]&2)==2&&(y=!0));n[t].extensions[r].extnID==="2.5.29.19"&&"cA"in n[t].extensions[r].parsedValue&&n[t].extensions[r].parsedValue.cA===!0&&(e=!0)}if(s===!0&&e===!1)return new Promise(function(n,t){t({result:!1,result_code:3,result_message:'Unable to build certificate chain - using "keyCertSign" flag set without BasicConstaints'})});if(h===!0&&e===!0&&s===!1)return new Promise(function(n,t){t({result:!1,result_code:4,result_message:'Unable to build certificate chain - "keyCertSign" flag was not set'})});if(e===!0&&h===!0&&y===!1)return new Promise(function(n,t){t({result:!1,result_code:5,result_message:'Unable to build certificate chain - intermediate certificate must have "cRLSign" key usage flag'})})}if(e===!1){if(f.length!==0)return new Promise(function(n,t){t({result:!1,result_code:7,result_message:"Unable to build certificate chain - more than one possible end-user certificate"})});f.push(n[t]);o=t}}if(n.splice(o,1),f.length===0)return new Promise(function(n,t){t({result:!1,result_code:1,result_message:"Can't find end-user certificate"})});if(n.length===0){if(f[0].issuer.isEqual(f[0].subject)===!0)return new Promise(function(n){n(f)});if(this.trusted_certs.length===0)return new Promise(function(n,t){t({result:!1,result_code:70,result_message:"Can't find root certificate"})});n=i.trusted_certs.splice(0)}return u=f[0],l()};n.org.pkijs.simpl.CERT_CHAIN.prototype.verify=function(){if(this.certs.length===0)return new Promise(function(n,t){t("Empty certificate array")});var a=Promise.resolve(),t=this,s=[];s.push("2.5.29.32.0");var p=!1,w=!1,b=!1,k=[],d=[],g=[],nt=new Date;arguments[0]instanceof Object&&("initial_policy_set"in arguments[0]&&(s=arguments[0].initial_policy_set),"initial_explicit_policy"in arguments[0]&&(p=arguments[0].initial_explicit_policy),"initial_policy_mapping_inhibit"in arguments[0]&&(w=arguments[0].initial_policy_mapping_inhibit),"initial_inhibit_policy"in arguments[0]&&(b=arguments[0].initial_inhibit_policy),"initial_permitted_subtrees_set"in arguments[0]&&(k=arguments[0].initial_permitted_subtrees_set),"initial_excluded_subtrees_set"in arguments[0]&&(d=arguments[0].initial_excluded_subtrees_set),"initial_required_name_forms"in arguments[0]&&(g=arguments[0].initial_required_name_forms));var h=p,v=w,c=b,i=new Array(3);i[0]=!1;i[1]=!1;i[2]=!1;var f=0,e=0,o=0,u=k,r=d,l=g,y=1;return a=n.org.pkijs.simpl.CERT_CHAIN.prototype.sort.call(this).then(function(n){t.certs=n}),a=a.then(function(){var a=[],l,et,rt,u,w,b,ut,k,ot,d,g,p,ft,nt,tt,st,it,n,r;for(a.push("2.5.29.32.0"),l=[],et=new Array(t.certs.length-1),rt=0;rt<t.certs.length-1;rt++)et[rt]=!0;for(l.push(et),u=new Array(t.certs.length-1),w=new Array(t.certs.length-1),n=t.certs.length-2;n>=0;n--,y++)if("extensions"in t.certs[n]){for(r=0;r<t.certs[n].extensions.length;r++){if(t.certs[n].extensions[r].extnID==="2.5.29.32")for(w[n]=t.certs[n].extensions[r].parsedValue,b=0;b<t.certs[n].extensions[r].parsedValue.certificatePolicies.length;b++){for(ut=-1,k=0;k<a.length;k++)if(t.certs[n].extensions[r].parsedValue.certificatePolicies[b].policyIdentifier===a[k]){ut=k;break}ut===-1?(a.push(t.certs[n].extensions[r].parsedValue.certificatePolicies[b].policyIdentifier),ot=new Array(t.certs.length-1),ot[n]=!0,l.push(ot)):l[ut][n]=!0}t.certs[n].extensions[r].extnID==="2.5.29.33"&&(u[n]=t.certs[n].extensions[r].parsedValue);t.certs[n].extensions[r].extnID==="2.5.29.36"&&h==!1&&(t.certs[n].extensions[r].parsedValue.requireExplicitPolicy===0?h=!0:i[0]===!1?(i[0]=!0,f=t.certs[n].extensions[r].parsedValue.requireExplicitPolicy):f=f>t.certs[n].extensions[r].parsedValue.requireExplicitPolicy?t.certs[n].extensions[r].parsedValue.requireExplicitPolicy:f,t.certs[n].extensions[r].parsedValue.inhibitPolicyMapping===0?v=!0:i[1]===!1?(i[1]=!0,e=t.certs[n].extensions[r].parsedValue.requireExplicitPolicy):e=e>t.certs[n].extensions[r].parsedValue.requireExplicitPolicy?t.certs[n].extensions[r].parsedValue.requireExplicitPolicy:e);t.certs[n].extensions[r].extnID==="2.5.29.54"&&c===!1&&(t.certs[n].extensions[r].parsedValue.value_block.value_dec===0?c=!0:i[2]===!1?(i[2]=!0,o=t.certs[n].extensions[r].parsedValue.value_block.value_dec):o=o>t.certs[n].extensions[r].parsedValue.value_block.value_dec?t.certs[n].extensions[r].parsedValue.value_block.value_dec:o)}if(c===!0&&delete l[0][n],typeof w[n]!="undefined"&&typeof u[n]!="undefined"&&v===!1)for(d=0;d<w[n].certificatePolicies.length;d++){for(g="",p=0;p<u[n].mappings.length;p++){if(u[n].mappings[p].subjectDomainPolicy===w[n].certificatePolicies[d].policyIdentifier){g=u[n].mappings[p].issuerDomainPolicy;break}if(u[n].mappings[p].issuerDomainPolicy===w[n].certificatePolicies[d].policyIdentifier){g=u[n].mappings[p].subjectDomainPolicy;break}}if(g!==""){for(ft=-1,nt=0;nt<a.length;nt++)if(a[nt]===g){ft=nt;break}ft!==-1&&(l[ft][n]=!0)}}h===!1&&i[0]===!0&&(f--,f===0&&(h=!0,i[0]=!1));v===!1&&i[1]===!0&&(e--,e===0&&(v=!0,i[1]=!1));c===!1&&i[2]===!0&&(o--,o===0&&(c=!0,i[2]=!1))}for(tt=[],n=0;n<l.length;n++){for(st=!0,r=0;r<t.certs.length-1;r++)if(typeof l[n][r]=="undefined"){st=!1;break}st===!0&&tt.push(a[n])}for(it=[],n=0;n<tt.length;n++)for(r=0;r<s.length;r++)if(s[r]===tt[n]){it.push(s[r]);break}return{result:it.length>0?!0:!1,result_code:0,result_message:it.length>0?"":'Zero "user_constr_policies" array, no intersections with "auth_constr_policies"',auth_constr_policies:tt,user_constr_policies:it,explicit_policy_indicator:h,policy_mappings:u}}),a.then(function(i){function b(t,i){var s=n.org.pkijs.stringPrep(t),h=n.org.pkijs.stringPrep(i),o=s.split("."),f=h.split("."),e=o.length,u=f.length,r;if(e===0||u===0||e<u)return!1;for(r=0;r<e;r++)if(o[r].length===0)return!1;for(r=0;r<u;r++)if(f[r].length===0){if(r===0){if(u===1)return!1;continue}return!1}for(r=0;r<u;r++)if(f[u-1-r].length!==0&&o[e-1-r].localeCompare(f[u-1-r])!==0)return!1;return!0}function k(t,i){var e=n.org.pkijs.stringPrep(t),o=n.org.pkijs.stringPrep(i),u=e.split("@"),r=o.split("@"),s,h,f;return u.length===0||r.length===0||u.length<r.length?!1:r.length===1?(s=b(u[1],r[0]),s?(h=u[1].split("."),f=r[0].split("."),f[0].length===0)?!0:h.length!==f.length?!1:!0:!1):e.localeCompare(o)===0?!0:!1}function nt(t,i){var f=n.org.pkijs.stringPrep(t),e=n.org.pkijs.stringPrep(i),u=f.split("/"),l=e.split("/"),r,s,h,c,o;if(l.length>1)return!1;if(u.length>1)for(r=0;r<u.length;r++)if(u[r].length>0&&u[r].charAt(u[r].length-1)!==":"){s=u[r].split(":");f=s[0];break}return h=b(f,e),h?(c=f.split("."),o=e.split("."),o[0].length===0)?!0:c.length!==o.length?!1:!0:!1}function tt(n,t){var u=new Uint8Array(n.value_block.value_hex),r=new Uint8Array(t.value_block.value_hex),i;if(u.length===4&&r.length===8){for(i=0;i<4;i++)if((u[i]^r[i])&r[i+4])return!1;return!0}if(u.length===16&&r.length===32){for(i=0;i<16;i++)if((u[i]^r[i])&r[i+16])return!1;return!0}return!1}function it(n,t){var e,r,u,f,i;if(n.types_and_values.length===0||t.types_and_values.length===0)return!0;if(n.types_and_values.length<t.types_and_values.length)return!1;for(e=!0,r=0,u=0;u<t.types_and_values.length;u++){for(f=!1,i=r;i<n.types_and_values.length;i++)if(f=n.types_and_values[i].isEqual(t.types_and_values[u]),n.types_and_values[i].type===t.types_and_values[u].type&&(e=e&&f),f===!0)if(r===0||r===i){r=i+1;break}else return!1;if(f===!1)return!1}return r===0?!1:e}var s,p,a,w,c,v,h,e,f;if(i.result===!1)return i;for(y=1,s=t.certs.length-2;s>=0;s--,y++){var o=[],d=[],g=[];if("extensions"in t.certs[s])for(e=0;e<t.certs[s].extensions.length;e++)t.certs[s].extensions[e].extnID==="2.5.29.30"&&("permittedSubtrees"in t.certs[s].extensions[e].parsedValue&&(d=d.concat(t.certs[s].extensions[e].parsedValue.permittedSubtrees)),"excludedSubtrees"in t.certs[s].extensions[e].parsedValue&&(g=g.concat(t.certs[s].extensions[e].parsedValue.excludedSubtrees))),t.certs[s].extensions[e].extnID==="2.5.29.17"&&(o=o.concat(t.certs[s].extensions[e].parsedValue.altNames)),t.certs[s].extensions[e].extnID==="1.2.840.113549.1.9.1"&&email_addresses.push(t.certs[s].extensions[e].parsedValue.value);for(p=l.length>0?!1:!0,e=0;e<l.length;e++)switch(l[e].base.NameType){case 4:if(l[e].base.Name.types_and_values.length!==t.certs[s].subject.types_and_values.length)continue;for(p=!0,f=0;f<t.certs[s].subject.types_and_values.length;f++)if(t.certs[s].subject.types_and_values[f].type!==l[e].base.Name.types_and_values[f].type){p=!1;break}if(p===!0)break}if(p===!1)return i.result=!1,i.result_code=21,i.result_message="No neccessary name form found",new Promise(function(n,t){t(i)});for(a=[],a[0]=[],a[1]=[],a[2]=[],a[3]=[],a[4]=[],e=0;e<u.length;e++)switch(u[e].base.NameType){case 1:a[0].push(u[e]);break;case 2:a[1].push(u[e]);break;case 4:a[2].push(u[e]);break;case 6:a[3].push(u[e]);break;case 7:a[4].push(u[e])}for(w=0;w<5;w++){for(c=!1,v=a[w],e=0;e<v.length;e++){switch(w){case 0:if(o.length>=0)for(f=0;f<o.length;f++)o[f].NameType===1&&(c=c||k(o[f].Name,v[e].base.Name));else for(f=0;f<t.certs[s].subject.types_and_values.length;f++)(t.certs[s].subject.types_and_values[f].type==="1.2.840.113549.1.9.1"||t.certs[s].subject.types_and_values[f].type==="0.9.2342.19200300.100.1.3")&&(c=c||k(t.certs[s].subject.types_and_values[f].value.value_block.value,v[e].base.Name));break;case 1:if(o.length>0)for(f=0;f<o.length;f++)o[f].NameType===2&&(c=c||b(o[f].Name,v[e].base.Name));break;case 2:c=it(t.certs[s].subject,v[e].base.Name);break;case 3:if(o.length>0)for(f=0;f<o.length;f++)o[f].NameType===6&&(c=c||nt(o[f].Name,v[e].base.Name));break;case 4:if(o.length>0)for(f=0;f<o.length;f++)o[f].NameType===7&&(c=c||tt(o[f].Name,v[e].base.Name))}if(c)break}if(c===!1&&v.length>0)return i.result=!1,i.result_code=41,i.result_message='Failed to meet "permitted sub-trees" name constraint',new Promise(function(n,t){t(i)})}for(h=!1,e=0;e<r.length;e++){switch(r[e].base.NameType){case 1:if(o.length>=0)for(f=0;f<o.length;f++)o[f].NameType===1&&(h=h||k(o[f].Name,r[e].base.Name));else for(f=0;f<t.subject.types_and_values.length;f++)(t.subject.types_and_values[f].type==="1.2.840.113549.1.9.1"||t.subject.types_and_values[f].type==="0.9.2342.19200300.100.1.3")&&(h=h||k(t.subject.types_and_values[f].value.value_block.value,r[e].base.Name));break;case 2:if(o.length>0)for(f=0;f<o.length;f++)o[f].NameType===2&&(h=h||b(o[f].Name,r[e].base.Name));break;case 4:h=h||it(t.certs[s].subject,r[e].base.Name);break;case 6:if(o.length>0)for(f=0;f<o.length;f++)o[f].NameType===6&&(h=h||nt(o[f].Name,r[e].base.Name));break;case 7:if(o.length>0)for(f=0;f<o.length;f++)o[f].NameType===7&&(h=h||tt(o[f].Name,r[e].base.Name))}if(h)break}if(h===!0)return i.result=!1,i.result_code=42,i.result_message='Failed to meet "excluded sub-trees" name constraint',new Promise(function(n,t){t(i)});u=u.concat(d);r=r.concat(g)}return i})}}(typeof exports!="undefined"?exports:window),function(n){if(typeof n.org=="undefined")n.org={};else if(typeof n.org!="object")throw new Error("Name org already exists and it's not an object");if(typeof n.org.pkijs=="undefined")n.org.pkijs={};else if(typeof n.org.pkijs!="object")throw new Error("Name org.pkijs already exists and it's not an object but "+typeof n.org.pkijs);if(typeof n.org.pkijs.schema=="undefined")n.org.pkijs.schema={};else if(typeof n.org.pkijs.schema!="object")throw new Error("Name org.pkijs.schema already exists and it's not an object but "+typeof n.org.pkijs.schema);if(typeof n.org.pkijs.schema.cms=="undefined")n.org.pkijs.schema.cms={};else if(typeof n.org.pkijs.schema.cms!="object")throw new Error("Name org.pkijs.schema.cms already exists and it's not an object but "+typeof n.org.pkijs.schema.cms);if(typeof n.org.pkijs.schema.x509=="undefined")n.org.pkijs.schema.x509={};else if(typeof n.org.pkijs.schema.x509!="object")throw new Error("Name org.pkijs.schema.x509 already exists and it's not an object but "+typeof n.org.pkijs.schema.x509);n.org.pkijs.schema.CMS_CONTENT_INFO=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"ContentInfo",value:[new n.org.pkijs.asn1.OID({name:t.contentType||"contentType"}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.ANY({name:t.content||"content"})]})]})};n.org.pkijs.schema.cms.OtherCertificateFormat=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.otherCertFormat||"otherCertFormat"}),new n.org.pkijs.asn1.ANY({name:t.otherCert||"otherCert"})]})};n.org.pkijs.schema.CMS_CERTIFICATE_SET=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SET({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.certificates||"",value:new n.org.pkijs.asn1.CHOICE({value:[n.org.pkijs.schema.CERT(),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:3},value:[new n.org.pkijs.asn1.OID,new n.org.pkijs.asn1.ANY]})]})})]})};n.org.pkijs.schema.cms.OtherRevocationInfoFormat=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.otherRevInfoFormat||"otherRevInfoFormat"}),new n.org.pkijs.asn1.ANY({name:t.otherRevInfo||"otherRevInfo"})]})};n.org.pkijs.schema.CSM_REVOCATION_INFO_CHOICES=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SET({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.crls||"",value:new n.org.pkijs.asn1.CHOICE({value:[n.org.pkijs.schema.CRL(),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.OID,new n.org.pkijs.asn1.ANY]})]})})]})};n.org.pkijs.schema.cms.IssuerAndSerialNumber=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[n.org.pkijs.schema.RDN(t.issuer||{}),new n.org.pkijs.asn1.INTEGER({name:t.serialNumber||""})]})};n.org.pkijs.schema.cms.Attribute=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.attrType||""}),new n.org.pkijs.asn1.SET({value:[new n.org.pkijs.asn1.REPEATED({name:t.attrValues||"",value:new n.org.pkijs.asn1.ANY})]})]})};n.org.pkijs.schema.x509.RSAES_OAEP_params=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},optional:!0,value:[n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.hashAlgorithm||{})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:1},optional:!0,value:[n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.maskGenAlgorithm||{})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:2},optional:!0,value:[n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.pSourceAlgorithm||{})]})]})};n.org.pkijs.schema.cms.SignedUnsignedAttributes=function(t,i){var r=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:r.block_name||"",optional:!0,id_block:{tag_class:3,tag_number:i},value:[new n.org.pkijs.asn1.REPEATED({name:r.attributes||"",value:n.org.pkijs.schema.cms.Attribute()})]})};n.org.pkijs.schema.CMS_SIGNER_INFO=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:"SignerInfo",value:[new n.org.pkijs.asn1.INTEGER({name:t.version||"SignerInfo.version"}),new n.org.pkijs.asn1.CHOICE({value:[n.org.pkijs.schema.cms.IssuerAndSerialNumber(t.sid||{names:{block_name:"SignerInfo.sid"}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,name:t.sid||"SignerInfo.sid",id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.OCTETSTRING]})]}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.digestAlgorithm||{names:{block_name:"SignerInfo.digestAlgorithm"}}),n.org.pkijs.schema.cms.SignedUnsignedAttributes(t.signedAttrs||{names:{block_name:"SignerInfo.signedAttrs"}},0),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.signatureAlgorithm||{names:{block_name:"SignerInfo.signatureAlgorithm"}}),new n.org.pkijs.asn1.OCTETSTRING({name:t.signature||"SignerInfo.signature"}),n.org.pkijs.schema.cms.SignedUnsignedAttributes(t.unsignedAttrs||{names:{block_name:"SignerInfo.unsignedAttrs"}},1)]})};n.org.pkijs.schema.cms.EncapsulatedContentInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.eContentType||""}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.ANY({name:t.eContent||""})]})]})};n.org.pkijs.schema.CMS_SIGNED_DATA=function(t,i){var t=n.org.pkijs.getNames(arguments[0]);return typeof i=="undefined"&&(i=!1),new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"SignedData",value:[new n.org.pkijs.asn1.INTEGER({name:t.version||"SignedData.version"}),new n.org.pkijs.asn1.SET({value:[new n.org.pkijs.asn1.REPEATED({name:t.digestAlgorithms||"SignedData.digestAlgorithms",value:n.org.pkijs.schema.ALGORITHM_IDENTIFIER()})]}),n.org.pkijs.schema.cms.EncapsulatedContentInfo(t.encapContentInfo||{names:{block_name:"SignedData.encapContentInfo"}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:n.org.pkijs.schema.CMS_CERTIFICATE_SET(t.certificates||{names:{certificates:"SignedData.certificates"}}).value_block.value}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:n.org.pkijs.schema.CSM_REVOCATION_INFO_CHOICES(t.crls||{names:{crls:"SignedData.crls"}}).value_block.value}),new n.org.pkijs.asn1.SET({value:[new n.org.pkijs.asn1.REPEATED({name:t.signerInfos||"SignedData.signerInfos",value:n.org.pkijs.schema.CMS_SIGNER_INFO()})]})]})};n.org.pkijs.schema.cms.ECC_CMS_SharedInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.keyInfo||{}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.entityUInfo||"",id_block:{tag_class:3,tag_number:0},optional:!0,value:[new n.org.pkijs.asn1.OCTETSTRING]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.suppPubInfo||"",id_block:{tag_class:3,tag_number:2},value:[new n.org.pkijs.asn1.OCTETSTRING]})]})};n.org.pkijs.schema.cms.PBKDF2_params=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.OCTETSTRING({name:t.salt_primitive||""}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.salt_constructed||{})]}),new n.org.pkijs.asn1.INTEGER({name:t.iterationCount||""}),new n.org.pkijs.asn1.INTEGER({name:t.keyLength||"",optional:!0}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.prf||{names:{optional:!0}})]})};n.org.pkijs.schema.cms.RecipientIdentifier=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.CHOICE({value:[n.org.pkijs.schema.cms.IssuerAndSerialNumber({names:{block_name:t.block_name||""}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.block_name||"",id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.OCTETSTRING]})]})};n.org.pkijs.schema.cms.KeyTransRecipientInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.INTEGER({name:t.version||""}),n.org.pkijs.schema.cms.RecipientIdentifier(t.rid||{}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.keyEncryptionAlgorithm||{}),new n.org.pkijs.asn1.OCTETSTRING({name:t.encryptedKey||""})]})};n.org.pkijs.schema.cms.OriginatorPublicKey=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.algorithm||{}),new n.org.pkijs.asn1.BITSTRING({name:t.publicKey||""})]})};n.org.pkijs.schema.cms.OriginatorIdentifierOrKey=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.CHOICE({value:[n.org.pkijs.schema.cms.IssuerAndSerialNumber({names:{block_name:t.block_name||""}}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({id_block:{tag_class:3,tag_number:0},name:t.block_name||""}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:1},name:t.block_name||"",value:n.org.pkijs.schema.cms.OriginatorPublicKey().value_block.value})]})};n.org.pkijs.schema.cms.OtherKeyAttribute=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({optional:t.optional||!0,name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.keyAttrId||""}),new n.org.pkijs.asn1.ANY({optional:!0,name:t.keyAttr||""})]})};n.org.pkijs.schema.cms.RecipientKeyIdentifier=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OCTETSTRING({name:t.subjectKeyIdentifier||""}),new n.org.pkijs.asn1.GENERALIZEDTIME({optional:!0,name:t.date||""}),n.org.pkijs.schema.cms.OtherKeyAttribute(t.other||{})]})};n.org.pkijs.schema.cms.KeyAgreeRecipientIdentifier=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.CHOICE({value:[n.org.pkijs.schema.cms.IssuerAndSerialNumber(t.issuerAndSerialNumber||{names:{block_name:t.block_name||""}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.block_name||"",id_block:{tag_class:3,tag_number:0},value:n.org.pkijs.schema.cms.RecipientKeyIdentifier(t.rKeyId||{names:{block_name:t.block_name||""}}).value_block.value})]})};n.org.pkijs.schema.cms.RecipientEncryptedKey=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[n.org.pkijs.schema.cms.KeyAgreeRecipientIdentifier(t.rid||{}),new n.org.pkijs.asn1.OCTETSTRING({name:t.encryptedKey||""})]})};n.org.pkijs.schema.cms.RecipientEncryptedKeys=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.REPEATED({name:t.RecipientEncryptedKeys||"",value:n.org.pkijs.schema.cms.RecipientEncryptedKey()})]})};n.org.pkijs.schema.cms.KeyAgreeRecipientInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.INTEGER({name:t.version||""}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[n.org.pkijs.schema.cms.OriginatorIdentifierOrKey(t.originator||{})]}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.OCTETSTRING({name:t.ukm||""})]}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.keyEncryptionAlgorithm||{}),n.org.pkijs.schema.cms.RecipientEncryptedKeys(t.recipientEncryptedKeys||{})]})};n.org.pkijs.schema.cms.KEKIdentifier=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OCTETSTRING({name:t.keyIdentifier||""}),new n.org.pkijs.asn1.GENERALIZEDTIME({optional:!0,name:t.date||""}),n.org.pkijs.schema.cms.OtherKeyAttribute(t.other||{})]})};n.org.pkijs.schema.cms.KEKRecipientInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.INTEGER({name:t.version||""}),n.org.pkijs.schema.cms.KEKIdentifier(t.kekid||{}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.keyEncryptionAlgorithm||{}),new n.org.pkijs.asn1.OCTETSTRING({name:t.encryptedKey||""})]})};n.org.pkijs.schema.cms.PasswordRecipientinfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.INTEGER({name:t.version||""}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.keyDerivationAlgorithm||"",optional:!0,id_block:{tag_class:3,tag_number:0},value:n.org.pkijs.schema.ALGORITHM_IDENTIFIER().value_block.value}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.keyEncryptionAlgorithm||{}),new n.org.pkijs.asn1.OCTETSTRING({name:t.encryptedKey||""})]})};n.org.pkijs.schema.cms.OtherRecipientInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.oriType||""}),new n.org.pkijs.asn1.ANY({name:t.oriValue||""})]})};n.org.pkijs.schema.CMS_RECIPIENT_INFO=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.CHOICE({value:[n.org.pkijs.schema.cms.KeyTransRecipientInfo({names:{block_name:t.block_name||""}}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.block_name||"",id_block:{tag_class:3,tag_number:1},value:n.org.pkijs.schema.cms.KeyAgreeRecipientInfo().value_block.value}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.block_name||"",id_block:{tag_class:3,tag_number:2},value:n.org.pkijs.schema.cms.KEKRecipientInfo().value_block.value}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.block_name||"",id_block:{tag_class:3,tag_number:3},value:n.org.pkijs.schema.cms.PasswordRecipientinfo().value_block.value}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.block_name||"",id_block:{tag_class:3,tag_number:4},value:n.org.pkijs.schema.cms.OtherRecipientInfo().value_block.value})]})};n.org.pkijs.schema.cms.OriginatorInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.certs||"",optional:!0,id_block:{tag_class:3,tag_number:0},value:n.org.pkijs.schema.CMS_CERTIFICATE_SET().value_block.value}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.crls||"",optional:!0,id_block:{tag_class:3,tag_number:1},value:n.org.pkijs.schema.CSM_REVOCATION_INFO_CHOICES().value_block.value})]})};n.org.pkijs.schema.cms.EncryptedContentInfo=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.contentType||""}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.contentEncryptionAlgorithm||{}),new n.org.pkijs.asn1.CHOICE({value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.encryptedContent||"",id_block:{tag_class:3,tag_number:0},value:[new n.org.pkijs.asn1.REPEATED({value:new n.org.pkijs.asn1.OCTETSTRING})]}),new n.org.pkijs.asn1.ASN1_PRIMITIVE({name:t.encryptedContent||"",id_block:{tag_class:3,tag_number:0}})]})]})};n.org.pkijs.schema.CMS_ENVELOPED_DATA=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.INTEGER({name:t.version||""}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({name:t.originatorInfo||"",optional:!0,id_block:{tag_class:3,tag_number:0},value:n.org.pkijs.schema.cms.OriginatorInfo().value_block.value}),new n.org.pkijs.asn1.SET({value:[new n.org.pkijs.asn1.REPEATED({name:t.recipientInfos||"",value:n.org.pkijs.schema.CMS_RECIPIENT_INFO()})]}),n.org.pkijs.schema.cms.EncryptedContentInfo(t.encryptedContentInfo||{}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[new n.org.pkijs.asn1.REPEATED({name:t.unprotectedAttrs||"",value:n.org.pkijs.schema.ATTRIBUTE()})]})]})}}(typeof exports!="undefined"?exports:window),function(n){if(typeof n.org=="undefined")n.org={};else if(typeof n.org!="object")throw new Error("Name org already exists and it's not an object");if(typeof n.org.pkijs=="undefined")n.org.pkijs={};else if(typeof n.org.pkijs!="object")throw new Error("Name org.pkijs already exists and it's not an object but "+typeof n.org.pkijs);if(typeof n.org.pkijs.simpl=="undefined")n.org.pkijs.simpl={};else if(typeof n.org.pkijs.simpl!="object")throw new Error("Name org.pkijs.simpl already exists and it's not an object but "+typeof n.org.pkijs.simpl);if(typeof n.org.pkijs.simpl.cms=="undefined")n.org.pkijs.simpl.cms={};else if(typeof n.org.pkijs.simpl.cms!="object")throw new Error("Name org.pkijs.simpl.cms already exists and it's not an object but "+typeof n.org.pkijs.simpl.cms);if(typeof n.org.pkijs.simpl.x509=="undefined")n.org.pkijs.simpl.x509={};else if(typeof n.org.pkijs.simpl.x509!="object")throw new Error("Name org.pkijs.simpl.x509 already exists and it's not an object but "+typeof n.org.pkijs.simpl.x509);n.org.pkijs.simpl.cms.kdfWithCounter=function(t,i,r,u){var o,e,f,s;switch(t.toUpperCase()){case"SHA-1":case"SHA-256":case"SHA-384":case"SHA-512":break;default:return new Promise(function(n,i){i("Unknown hash function: "+t)})}return i instanceof ArrayBuffer==!1?new Promise(function(n,t){t('Please set "Zbuffer" as "ArrayBuffer"')}):i.byteLength===0?new Promise(function(n,t){t('"Zbuffer" has zero length, error')}):u instanceof ArrayBuffer==!1?new Promise(function(n,t){t('Please set "SharedInfo" as "ArrayBuffer"')}):r>255?new Promise(function(n,t){t('Please set "Counter" variable to value less or equal to 255')}):(o=new ArrayBuffer(4),e=new Uint8Array(o),e[0]=0,e[1]=0,e[2]=0,e[3]=r,f=new ArrayBuffer(0),s=n.org.pkijs.getCrypto(),typeof s=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):(f=n.org.pkijs.concat_buffers(f,i),f=n.org.pkijs.concat_buffers(f,o),f=n.org.pkijs.concat_buffers(f,u),s.digest({name:t},f).then(function(n){return{counter:r,result:n}}))};n.org.pkijs.simpl.cms.kdf=function(t,i,r,u){var f=0,e=1,h=[],o,s;switch(t.toUpperCase()){case"SHA-1":f=160;break;case"SHA-256":f=256;break;case"SHA-384":f=384;break;case"SHA-512":f=512;break;default:return new Promise(function(n,i){i("Unknown hash function: "+t)})}if(i instanceof ArrayBuffer==!1)return new Promise(function(n,t){t('Please set "Zbuffer" as "ArrayBuffer"')});if(i.byteLength===0)return new Promise(function(n,t){t('"Zbuffer" has zero length, error')});if(u instanceof ArrayBuffer==!1)return new Promise(function(n,t){t('Please set "SharedInfo" as "ArrayBuffer"')});for(o=r/f,Math.floor(o)>0&&(e=Math.floor(o),o-e>0&&e++),s=1;s<=e;s++)h.push(n.org.pkijs.simpl.cms.kdfWithCounter(t,i,s,u));return Promise.all(h).then(function(n){for(var i=new ArrayBuffer(0),f=1,u=!0,t;u;){for(u=!1,t=0;t<n.length;t++)if(n[t].counter===f){i=org.pkijs.concat_buffers(i,n[t].result);u=!0;break}f++}if(r>>=3,i.byteLength>r){var e=new ArrayBuffer(r),o=new Uint8Array(e),s=new Uint8Array(i);for(t=0;t<r;t++)o[t]=s[t];return e}return i},function(n){return new Promise(function(t,i){i(n)})})};n.org.pkijs.simpl.CMS_CONTENT_INFO=function(){this.contentType="";this.content=new n.org.pkijs.asn1.ANY;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CMS_CONTENT_INFO.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.contentType=arguments[0].contentType||"",this.content=arguments[0].content||new n.org.pkijs.asn1.ANY)};n.org.pkijs.simpl.CMS_CONTENT_INFO.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CMS_CONTENT_INFO());if(i.verified===!1)throw new Error("Object's schema was not verified against input data for CMS_CONTENT_INFO");this.contentType=i.result.contentType.value_block.toString();this.content=i.result.content};n.org.pkijs.simpl.CMS_CONTENT_INFO.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.contentType}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[this.content]})]})};n.org.pkijs.simpl.CMS_CONTENT_INFO.prototype.toJSON=function(){var t={contentType:this.contentType};return this.content instanceof n.org.pkijs.asn1.ANY||(t.content=this.content.toJSON()),t};n.org.pkijs.simpl.cms.OtherCertificateFormat=function(){this.otherCertFormat="";this.otherCert=new n.org.pkijs.asn1.ANY;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.OtherCertificateFormat.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.otherCertFormat=arguments[0].contentType||"",this.otherCert=arguments[0].content||new n.org.pkijs.asn1.ANY)};n.org.pkijs.simpl.cms.OtherCertificateFormat.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.OtherCertificateFormat());if(i.verified===!1)throw new Error("Object's schema was not verified against input data for OtherCertificateFormat");this.otherCertFormat=i.result.otherCertFormat.value_block.toString();this.otherCert=i.result.otherCert};n.org.pkijs.simpl.cms.OtherCertificateFormat.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.otherCertFormat}),this.otherCert]})};n.org.pkijs.simpl.cms.OtherCertificateFormat.prototype.toJSON=function(){var t={otherCertFormat:this.otherCertFormat};return this.otherCert instanceof n.org.pkijs.asn1.ANY||(t.otherCert=this.otherCert.toJSON()),t};n.org.pkijs.simpl.cms.OtherRevocationInfoFormat=function(){this.otherRevInfoFormat="";this.otherRevInfo=new n.org.pkijs.asn1.ANY;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.OtherRevocationInfoFormat.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.otherRevInfoFormat=arguments[0].otherRevInfoFormat||"",this.otherRevInfo=arguments[0].otherRevInfo||new n.org.pkijs.asn1.ANY)};n.org.pkijs.simpl.cms.OtherRevocationInfoFormat.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.OtherRevocationInfoFormat());if(i.verified===!1)throw new Error("Object's schema was not verified against input data for OtherRevocationInfoFormat");this.otherRevInfoFormat=i.result.otherRevInfoFormat.value_block.toString();this.otherRevInfo=i.result.otherRevInfo};n.org.pkijs.simpl.cms.OtherRevocationInfoFormat.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.otherRevInfoFormat}),this.otherRevInfo]})};n.org.pkijs.simpl.cms.OtherRevocationInfoFormat.prototype.toJSON=function(){var t={otherRevInfoFormat:this.otherRevInfoFormat};return this.otherRevInfo instanceof n.org.pkijs.asn1.ANY||(t.otherRevInfo=this.otherRevInfo.toJSON()),t};n.org.pkijs.simpl.CMS_CERTIFICATE_SET=function(){this.certificates=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CMS_CERTIFICATE_SET.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.certificates=arguments[0].certificates||[])};n.org.pkijs.simpl.CMS_CERTIFICATE_SET.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CMS_CERTIFICATE_SET()),i,r;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for CMS_CERTIFICATE_SET");for(i=u.result.certificates,r=0;r<i;r++)i.id_block.tag_class===1?this.certificates.push(new n.org.pkijs.simpl.CERT({schema:i[r]})):this.certificates.push(i[r])};n.org.pkijs.simpl.CMS_CERTIFICATE_SET.prototype.toSchema=function(){for(var i=[],t=0;t<this.certificates.length;t++)this.certificates[t]instanceof n.org.pkijs.simpl.CERT?i.push(this.certificates[t].toSchema()):i.push(this.certificates[t]);return new n.org.pkijs.asn1.SET({value:i})};n.org.pkijs.simpl.CMS_CERTIFICATE_SET.prototype.toJSON=function(){var t={},n;for(t.certificates=[],n=0;n<this.certificates.length;n++)t.certificates.push(this.certificates[n].toJSON());return t};n.org.pkijs.simpl.CSM_REVOCATION_INFO_CHOICES=function(){this.crls=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CSM_REVOCATION_INFO_CHOICES.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.crls=arguments[0].crls||[])};n.org.pkijs.simpl.CSM_REVOCATION_INFO_CHOICES.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CSM_REVOCATION_INFO_CHOICES()),i,r;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for CSM_REVOCATION_INFO_CHOICES");for(i=u.result.crls,r=0;r<i;r++)i.id_block.tag_class===1?this.crls.push(new n.org.pkijs.simpl.CRL({schema:i[r]})):this.crls.push(i[r])};n.org.pkijs.simpl.CSM_REVOCATION_INFO_CHOICES.prototype.toSchema=function(){for(var i=[],t=0;t<this.crls.length;t++)this.crls[t]instanceof n.org.pkijs.simpl.CRL?i.push(this.crls[t].toSchema()):i.push(this.crls[t]);return new n.org.pkijs.asn1.SET({value:i})};n.org.pkijs.simpl.CSM_REVOCATION_INFO_CHOICES.prototype.toJSON=function(){var t={},n;for(t.crls=[],n=0;n<this.crls.length;n++)t.crls.push(this.crls[n].toJSON());return t};n.org.pkijs.simpl.cms.IssuerAndSerialNumber=function(){this.issuer=new n.org.pkijs.simpl.RDN;this.serialNumber=new n.org.pkijs.asn1.INTEGER;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.IssuerAndSerialNumber.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.issuer=arguments[0].issuer||new n.org.pkijs.simpl.RDN,this.serialNumber=arguments[0].serialNumber||new n.org.pkijs.asn1.INTEGER)};n.org.pkijs.simpl.cms.IssuerAndSerialNumber.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.IssuerAndSerialNumber({names:{issuer:{names:{block_name:"issuer"}},serialNumber:"serialNumber"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for IssuerAndSerialNumber");this.issuer=new n.org.pkijs.simpl.RDN({schema:i.result.issuer});this.serialNumber=i.result.serialNumber};n.org.pkijs.simpl.cms.IssuerAndSerialNumber.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.issuer.toSchema(),this.serialNumber]})};n.org.pkijs.simpl.cms.IssuerAndSerialNumber.prototype.toJSON=function(){return{issuer:this.issuer.toJSON(),serialNumber:this.serialNumber.toJSON()}};n.org.pkijs.simpl.cms.Attribute=function(){this.attrType="";this.attrValues=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.Attribute.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.attrType=arguments[0].attrType||"",this.attrValues=arguments[0].attrValues||[])};n.org.pkijs.simpl.cms.Attribute.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.Attribute({names:{attrType:"attrType",attrValues:"attrValues"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for Attribute");this.attrType=i.result.attrType.value_block.toString();this.attrValues=i.result.attrValues;switch(this.attrType){case"0.4.0.1733.2.5":this.parsedValue=new n.org.pkijs.simpl.cades.ATSHashIndex({schema:this.attrValues[0]});break;case"0.4.0.1733.2.4":this.parsedValue=new n.org.pkijs.simpl.cades.archive_time_stamp_v3({schema:this.attrValues[0]});break;case"1.2.840.113549.1.9.16.2.14":this.parsedValue=new n.org.pkijs.simpl.cades.signature_time_stamp({schema:this.attrValues[0]});break;case"1.2.840.113549.1.9.16.2.21":this.parsedValue=new n.org.pkijs.simpl.cades.complete_certificate_references({schema:this.attrValues[0]});break;case"1.2.840.113549.1.9.16.2.22":this.parsedValue=new n.org.pkijs.simpl.cades.complete_revocation_references({schema:this.attrValues[0]});break;case"1.2.840.113549.1.9.16.2.25":this.parsedValue=new n.org.pkijs.simpl.cades.CAdES_C_Timestamp({schema:this.attrValues[0]});break;case"1.2.840.113549.1.9.16.2.23":this.parsedValue=new n.org.pkijs.simpl.cades.certificate_values({schema:this.attrValues[0]});break;case"1.2.840.113549.1.9.16.2.24":this.parsedValue=new n.org.pkijs.simpl.cades.revocation_values({schema:this.attrValues[0]})}};n.org.pkijs.simpl.cms.Attribute.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.attrType}),new n.org.pkijs.asn1.SET({value:this.attrValues})]})};n.org.pkijs.simpl.cms.Attribute.prototype.toJSON=function(){var t={attrType:this.attrType},n;for(t.attrValues=[],n=0;n<this.attrValues.length;n++)t.attrValues.push(this.attrValues[n].toJSON());return t};n.org.pkijs.simpl.x509.RSAES_OAEP_params=function(){arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.x509.RSAES_OAEP_params.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&("hashAlgorithm"in arguments[0]&&(this.hashAlgorithm=arguments[0].hashAlgorithm),"maskGenAlgorithm"in arguments[0]&&(this.maskGenAlgorithm=arguments[0].maskGenAlgorithm),"pSourceAlgorithm"in arguments[0]&&(this.pSourceAlgorithm=arguments[0].pSourceAlgorithm))};n.org.pkijs.simpl.x509.RSAES_OAEP_params.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.x509.RSAES_OAEP_params({names:{hashAlgorithm:{names:{block_name:"hashAlgorithm"}},maskGenAlgorithm:{names:{block_name:"maskGenAlgorithm"}},pSourceAlgorithm:{names:{block_name:"pSourceAlgorithm"}}}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for RSAES_OAEP_params");"hashAlgorithm"in i.result&&(this.hashAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.hashAlgorithm}));"maskGenAlgorithm"in i.result&&(this.maskGenAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.maskGenAlgorithm}));"pSourceAlgorithm"in i.result&&(this.pSourceAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.pSourceAlgorithm}))};n.org.pkijs.simpl.x509.RSAES_OAEP_params.prototype.toSchema=function(){var t=[];return"hashAlgorithm"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[this.hashAlgorithm.toSchema()]})),"maskGenAlgorithm"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:1},value:[this.maskGenAlgorithm.toSchema()]})),"pSourceAlgorithm"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:2},value:[this.pSourceAlgorithm.toSchema()]})),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.x509.RSAES_OAEP_params.prototype.toJSON=function(){var n={};return"hashAlgorithm"in this&&(n.hashAlgorithm=this.hashAlgorithm.toJSON()),"maskGenAlgorithm"in this&&(n.maskGenAlgorithm=this.maskGenAlgorithm.toJSON()),"pSourceAlgorithm"in this&&(n.pSourceAlgorithm=this.pSourceAlgorithm.toJSON()),n};n.org.pkijs.simpl.cms.PBKDF2_params=function(){this.salt=new n.org.pkijs.emptyObject;this.iterationCount=0;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.PBKDF2_params.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.salt=arguments[0].salt||new n.org.pkijs.emptyObject,this.iterationCount=arguments[0].iterationCount||0,"keyLength"in arguments[0]&&(this.keyLength=arguments[0].keyLength),"prf"in arguments[0]&&(this.prf=arguments[0].prf))};n.org.pkijs.simpl.cms.PBKDF2_params.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.PBKDF2_params({names:{salt_primitive:"salt",salt_constructed:{names:{block_name:"salt"}},iterationCount:"iterationCount",keyLength:"keyLength",prf:{names:{block_name:"prf",optional:!0}}}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PBKDF2_params");this.salt=i.result.salt;this.iterationCount=i.result.iterationCount.value_block.value_dec;"keyLength"in i.result&&(this.keyLength=i.result.keyLength.value_block.value_dec);"prf"in i.result&&(this.prf=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.prf}))};n.org.pkijs.simpl.cms.PBKDF2_params.prototype.toSchema=function(){var t=[];return t.push(this.salt),t.push(new n.org.pkijs.asn1.INTEGER({value:this.iterationCount})),"keyLength"in this&&t.push(new n.org.pkijs.asn1.INTEGER({value:this.keyLength})),"prf"in this&&t.push(this.prf.toSchema()),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.PBKDF2_params.prototype.toJSON=function(){var n={salt:this.salt.toJSON(),iterationCount:this.iterationCount};return"keyLength"in this&&(n.keyLength=this.keyLength),"prf"in this&&(n.prf=this.prf.toJSON()),n};n.org.pkijs.simpl.cms.SignedUnsignedAttributes=function(){this.type=0;this.attributes=[];this.encoded_value=new ArrayBuffer(0);arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.SignedUnsignedAttributes.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.type=arguments[0].type||0,this.attributes=arguments[0].attributes||[])};n.org.pkijs.simpl.cms.SignedUnsignedAttributes.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.SignedUnsignedAttributes({names:{attributes:"attributes"}},this.type)),f,u,r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for SignedUnsignedAttributes");if(this.type=i.result.id_block.tag_number,this.encoded_value=i.result.value_before_decode,f=new Uint8Array(this.encoded_value),f[0]=49,"attributes"in i.result==!1)if(this.type===0)throw new Error("Wrong structure of SignedUnsignedAttributes");else return;for(u=i.result.attributes,r=0;r<u.length;r++)this.attributes.push(new n.org.pkijs.simpl.cms.Attribute({schema:u[r]}))};n.org.pkijs.simpl.cms.SignedUnsignedAttributes.prototype.toSchema=function(){for(var i=[],t=0;t<this.attributes.length;t++)i.push(this.attributes[t].toSchema());return new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:this.type},value:i})};n.org.pkijs.simpl.cms.SignedUnsignedAttributes.prototype.toJSON=function(){var t={type:this.type},n;for(t.attributes=[],n=0;n<this.attributes.length;n++)t.attributes.push(this.attributes[n].toJSON());return t};n.org.pkijs.simpl.CMS_SIGNER_INFO=function(){this.version=0;this.sid=new n.org.pkijs.asn1.ANY;this.digestAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.signature=new n.org.pkijs.asn1.OCTETSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CMS_SIGNER_INFO.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version=arguments[0].version||0,this.sid=arguments[0].sid||new n.org.pkijs.asn1.ANY,this.digestAlgorithm=arguments[0].digestAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,"signedAttrs"in arguments[0]&&(this.signedAttrs=arguments[0].signedAttrs),this.signatureAlgorithm=arguments[0].signatureAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.signature=arguments[0].signature||new n.org.pkijs.asn1.OCTETSTRING,"unsignedAttrs"in arguments[0]&&(this.unsignedAttrs=arguments[0].unsignedAttrs))};n.org.pkijs.simpl.CMS_SIGNER_INFO.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CMS_SIGNER_INFO()),r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for CMS_SIGNER_INFO");this.version=i.result["SignerInfo.version"].value_block.value_dec;r=i.result["SignerInfo.sid"];this.sid=r.id_block.tag_class===1?new n.org.pkijs.simpl.cms.IssuerAndSerialNumber({schema:r}):r;this.digestAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result["SignerInfo.digestAlgorithm"]});"SignerInfo.signedAttrs"in i.result&&(this.signedAttrs=new n.org.pkijs.simpl.cms.SignedUnsignedAttributes({schema:i.result["SignerInfo.signedAttrs"]}));this.signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result["SignerInfo.signatureAlgorithm"]});this.signature=i.result["SignerInfo.signature"];"SignerInfo.unsignedAttrs"in i.result&&(this.unsignedAttrs=new n.org.pkijs.simpl.cms.SignedUnsignedAttributes,this.unsignedAttrs.type=1,this.unsignedAttrs.fromSchema(i.result["SignerInfo.unsignedAttrs"]))};n.org.pkijs.simpl.CMS_SIGNER_INFO.prototype.toSchema=function(){var t=[];return t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),this.sid instanceof n.org.pkijs.simpl.cms.IssuerAndSerialNumber?t.push(this.sid.toSchema()):t.push(this.sid),t.push(this.digestAlgorithm.toSchema()),"signedAttrs"in this&&t.push(this.signedAttrs.toSchema()),t.push(this.signatureAlgorithm.toSchema()),t.push(this.signature),"unsignedAttrs"in this&&t.push(this.unsignedAttrs.toSchema()),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.CMS_SIGNER_INFO.prototype.toJSON=function(){var t={version:this.version};return this.sid instanceof n.org.pkijs.asn1.ANY||(t.sid=this.sid.toJSON()),t.digestAlgorithm=this.digestAlgorithm.toJSON(),"signedAttrs"in this&&(t.signedAttrs=this.signedAttrs.toJSON()),t.signatureAlgorithm=this.signatureAlgorithm.toJSON(),t.signature=this.signature.toJSON(),"unsignedAttrs"in this&&(t.unsignedAttrs=this.unsignedAttrs.toJSON()),t};n.org.pkijs.simpl.cms.EncapsulatedContentInfo=function(){var t;if(this.eContentType="",arguments[0]instanceof Object&&"schema"in arguments[0])n.org.pkijs.simpl.cms.EncapsulatedContentInfo.prototype.fromSchema.call(this,arguments[0].schema);else if(arguments[0]instanceof Object&&(this.eContentType=arguments[0].eContentType||"","eContent"in arguments[0]&&(this.eContent=arguments[0].eContent,this.eContent.id_block.tag_class===1&&this.eContent.id_block.tag_number===4&&this.eContent.id_block.is_constructed===!1))){for(var u=new n.org.pkijs.asn1.OCTETSTRING({id_block:{is_constructed:!0},is_constructed:!0}),i=0,f=this.eContent.value_block.value_hex.byteLength;f>0;){var r=new Uint8Array(this.eContent.value_block.value_hex,i,i+65536>this.eContent.value_block.value_hex.byteLength?this.eContent.value_block.value_hex.byteLength-i:65536),e=new ArrayBuffer(r.length),o=new Uint8Array(e);for(t=0;t<o.length;t++)o[t]=r[t];u.value_block.value.push(new n.org.pkijs.asn1.OCTETSTRING({value_hex:e}));f-=r.length;i+=r.length}this.eContent=u}};n.org.pkijs.simpl.cms.EncapsulatedContentInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.EncapsulatedContentInfo({names:{eContentType:"eContentType",eContent:"eContent"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for EncapsulatedContentInfo");this.eContentType=i.result.eContentType.value_block.toString();"eContent"in i.result&&(this.eContent=i.result.eContent)};n.org.pkijs.simpl.cms.EncapsulatedContentInfo.prototype.toSchema=function(){var t=[];return t.push(new n.org.pkijs.asn1.OID({value:this.eContentType})),"eContent"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:[this.eContent]})),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.EncapsulatedContentInfo.prototype.toJSON=function(){var n={eContentType:this.eContentType};return"eContent"in this&&(n.eContent=this.eContent.toJSON()),n};n.org.pkijs.simpl.CMS_SIGNED_DATA=function(){this.version=0;this.digestAlgorithms=[];this.encapContentInfo=new n.org.pkijs.simpl.cms.EncapsulatedContentInfo;this.signerInfos=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CMS_SIGNED_DATA.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version=arguments[0].version||0,this.digestAlgorithms=arguments[0].digestAlgorithms||[],this.encapContentInfo=arguments[0].encapContentInfo||new n.org.pkijs.simpl.cms.EncapsulatedContentInfo,"certificates"in arguments[0]&&(this.certificates=arguments[0].certificates),"crls"in arguments[0]&&(this.crls=arguments[0].crls),this.signerInfos=arguments[0].signerInfos||[])};n.org.pkijs.simpl.CMS_SIGNED_DATA.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CMS_SIGNED_DATA()),h,o,f,r,e,u,c,s;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for CMS_SIGNED_DATA");for(this.version=i.result["SignedData.version"].value_block.value_dec,h=i.result["SignedData.digestAlgorithms"],o=0;o<h.length;o++)this.digestAlgorithms.push(new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:h[o]}));if(this.encapContentInfo=new n.org.pkijs.simpl.cms.EncapsulatedContentInfo({schema:i.result["SignedData.encapContentInfo"]}),"SignedData.certificates"in i.result)for(this.certificates=[],f=i.result["SignedData.certificates"],r=0;r<f.length;r++)f[r].id_block.tag_class===1?this.certificates.push(new n.org.pkijs.simpl.CERT({schema:f[r]})):(f[r].id_block.tag_class=1,f[r].id_block.tag_number=16,this.certificates.push(new n.org.pkijs.simpl.cms.OtherCertificateFormat({schema:f[r]})));if("SignedData.crls"in i.result)for(this.crls=[],e=i.result["SignedData.crls"],u=0;u<e.length;u++)e[u].id_block.tag_class===1?this.crls.push(new n.org.pkijs.simpl.CRL({schema:e[u]})):(e[u].id_block.tag_class=1,e[u].id_block.tag_number=16,this.crls.push(new n.org.pkijs.simpl.cms.OtherRevocationInfoFormat({schema:e[u]})));for(c=i.result["SignedData.signerInfos"],s=0;s<c.length;s++)this.signerInfos.push(new n.org.pkijs.simpl.CMS_SIGNER_INFO({schema:c[s]}))};n.org.pkijs.simpl.CMS_SIGNED_DATA.prototype.toSchema=function(t){var i,l,f,e,r,o,s,u,h,a,c;for(typeof t=="undefined"&&(t=!1),i=[],i.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),l=[],f=0;f<this.digestAlgorithms.length;f++)l.push(this.digestAlgorithms[f].toSchema(t));if(i.push(new n.org.pkijs.asn1.SET({value:l})),i.push(this.encapContentInfo.toSchema()),"certificates"in this){for(e=[],r=0;r<this.certificates.length;r++)this.certificates[r]instanceof n.org.pkijs.simpl.cms.OtherCertificateFormat?(o=this.certificates[r].toSchema(t),o.id_block.tag_class=3,o.id_block.tag_number=3,e.push(o)):e.push(this.certificates[r].toSchema(t));i.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:e}))}if("crls"in this){for(s=[],u=0;u<this.crls.length;u++)this.crls[u]instanceof n.org.pkijs.simpl.cms.OtherRevocationInfoFormat?(h=this.crls[u].toSchema(t),h.id_block.tag_class=3,h.id_block.tag_number=1,s.push(h)):s.push(this.crls[u].toSchema(t));i.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:s}))}for(a=[],c=0;c<this.signerInfos.length;c++)a.push(this.signerInfos[c].toSchema(t));return i.push(new n.org.pkijs.asn1.SET({value:a})),new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.CMS_SIGNED_DATA.prototype.verify=function(){function y(n){var i,t;if(n.issuer.isEqual(o.issuer)===!0&&n.serialNumber.isEqual(o.serialNumber)===!0)return null;for(i=!1,t=0;t<n.extensions.length;t++)n.extensions[t].extnID==="2.5.29.19"&&"cA"in n.extensions[t].parsedValue&&n.extensions[t].parsedValue.cA===!0&&(i=!0);return i?n:null}var t=Promise.resolve(),r=this.certificates,u=this.signerInfos,f=this.encapContentInfo,e=new ArrayBuffer(0),c="",i=-1,o={},v=[],l=this,s=n.org.pkijs.getCrypto(),a,h;if(typeof s=="undefined")return new Promise(function(n,t){t("Unable to create WebCrypto object")});if(arguments[0]instanceof Object&&("signer"in arguments[0]&&(i=arguments[0].signer),"data"in arguments[0]&&(e=arguments[0].data),"trusted_certs"in arguments[0]&&(v=arguments[0].trusted_certs)),i===-1)return new Promise(function(n,t){t("Unable to get signer index from input parameters")});if("certificates"in this==!1)return new Promise(function(n,t){t("No certificates attached to this signed data")});for(t=this.signerInfos[i].sid instanceof n.org.pkijs.simpl.cms.IssuerAndSerialNumber?t.then(function(){for(var n=0;r.length;n++)if(r[n].issuer.isEqual(u[i].sid.issuer)&&r[n].serialNumber.isEqual(u[i].sid.serialNumber))return o=r[n],new Promise(function(n){n()});return new Promise(function(n,t){t("Unable to find signer certificate")})}):t.then(function(){for(var f=[],t=0;t<r.length;t++)f.push(s.digest({name:"sha-1"},new Uint8Array(r[t].subjectPublicKeyInfo.subjectPublicKey.value_block.value_hex)));return Promise.all(f).then(function(t){for(var f=0;f<r.length;f++)if(n.org.pkijs.isEqual_buffer(t[f],u[i].sid.value_block.value_hex))return o=r[f],new Promise(function(n){n()});return new Promise(function(n,t){t("Unable to find signer certificate")})},function(){return new Promise(function(n,t){t("Unable to find signer certificate")})})}),a=[],h=0;h<this.certificates.length;h++)a.push(y(this.certificates[h]));return t=t.then(function(){return Promise.all(a).then(function(t){var r=[],i,u;for(r.push(o),i=0;i<t.length;i++)t[i]!==null&&r.push(t[i]);return u=new n.org.pkijs.simpl.CERT_CHAIN({certs:r,trusted_certs:v}),"crls"in l&&(u.crls=l.crls),u.verify().then(function(n){return n.result===!0?new Promise(function(n){n()}):new Promise(function(n,t){t("Validation of signer's certificate failed")})},function(n){return new Promise(function(t,i){i("Validation of signer's certificate failed with error: "+(n instanceof Object?n.result_message:n))})})},function(n){return new Promise(function(t,i){i("Error during checking certificates for CA flag: "+n)})})}),t=t.then(function(){var t=n.org.pkijs.getAlgorithmByOID(u[i].digestAlgorithm.algorithm_id);return"name"in t==!1?new Promise(function(n,t){t("Unsupported signature algorithm: "+l.signerInfos[i].digestAlgorithm.algorithm_id)}):(c=t.name,new Promise(function(n){n()}))}),t=t.then(function(){if("signedAttrs"in u[i])e=u[i].signedAttrs.encoded_value;else if("eContent"in f)if(f.eContent.id_block.tag_class===1&&f.eContent.id_block.tag_number===4)if(f.eContent.id_block.is_constructed===!1)e=f.eContent.value_block.value_hex;else for(var t=0;t<f.eContent.value_block.value.length;t++)e=n.org.pkijs.concat_buffers(e,f.eContent.value_block.value[t].value_block.value_hex);else e=f.eContent.value_block.value_hex;else if(e.byteLength===0)return new Promise(function(n,t){t("Missed detached data input array")})}),t=t.then(function(){var i=n.org.pkijs.getAlgorithmByOID(o.signatureAlgorithm.algorithm_id),r,t;if("name"in i==!1)return new Promise(function(n,t){t("Unsupported public key algorithm: "+o.signatureAlgorithm.algorithm_id)});r=i.name;t=n.org.pkijs.getAlgorithmParameters(r,"importkey");"hash"in t.algorithm&&(t.algorithm.hash.name=c);var u=o.subjectPublicKeyInfo.toSchema(),f=u.toBER(!1),e=new Uint8Array(f);return s.importKey("spki",e,t.algorithm,!0,t.usages)}),t.then(function(t){var f=n.org.pkijs.getAlgorithmParameters(t.algorithm.name,"verify"),o,a,r,h,l;if("hash"in f.algorithm&&(f.algorithm.hash.name=c),o=u[i].signature.value_block.value_hex,t.algorithm.name==="ECDSA"&&(a=n.org.pkijs.fromBER(o),o=n.org.pkijs.createECDSASignatureFromCMS(a.result)),t.algorithm.name==="RSA-PSS"){try{r=new n.org.pkijs.simpl.x509.RSASSA_PSS_params({schema:u[i].signatureAlgorithm.algorithm_params})}catch(v){return new Promise(function(n,t){t(v)})}if(f.algorithm.saltLength="saltLength"in r?r.saltLength:20,h="SHA-1","hashAlgorithm"in r){if(l=n.org.pkijs.getAlgorithmByOID(r.hashAlgorithm.algorithm_id),"name"in l==!1)return new Promise(function(n,t){t("Unrecognized hash algorithm: "+r.hashAlgorithm.algorithm_id)});h=l.name}f.algorithm.hash.name=h}return s.verify(f.algorithm,t,new Uint8Array(o),new Uint8Array(e))},function(n){return new Promise(function(t,i){i(n)})})};n.org.pkijs.simpl.CMS_SIGNED_DATA.prototype.sign=function(t,i,r,u){var f=this,o,c,e,h,a,v,s,l;if(u=u||new ArrayBuffer(0),o="",typeof t=="undefined")return new Promise(function(n,t){t("Need to provide a private key for signing")});if(typeof r=="undefined"&&(r="SHA-1"),o=n.org.pkijs.getOIDByAlgorithm({name:r}),o==="")return new Promise(function(n,t){t("Unsupported hash algorithm: "+r)});for(c=!1,s=0;s<f.digestAlgorithms.length;s++)if(f.digestAlgorithms[s].algorithm_id===o){c=!0;break}c===!1&&f.digestAlgorithms.push(new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:o,algorithm_params:new n.org.pkijs.asn1.NULL}));f.signerInfos[i].digestAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:o,algorithm_params:new n.org.pkijs.asn1.NULL});e=n.org.pkijs.getAlgorithmParameters(t.algorithm.name,"sign");e.algorithm.hash.name=r;switch(t.algorithm.name.toUpperCase()){case"RSASSA-PKCS1-V1_5":case"ECDSA":f.signerInfos[i].signatureAlgorithm.algorithm_id=n.org.pkijs.getOIDByAlgorithm(e.algorithm);break;case"RSA-PSS":switch(r.toUpperCase()){case"SHA-256":e.algorithm.saltLength=32;break;case"SHA-384":e.algorithm.saltLength=48;break;case"SHA-512":e.algorithm.saltLength=64}if(h={},r.toUpperCase()!=="SHA-1"){if(o=n.org.pkijs.getOIDByAlgorithm({name:r}),o==="")return new Promise(function(n,t){t("Unsupported hash algorithm: "+r)});h.hashAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:o,algorithm_params:new n.org.pkijs.asn1.NULL});h.maskGenAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.8",algorithm_params:h.hashAlgorithm.toSchema()})}e.algorithm.saltLength!==20&&(h.saltLength=e.algorithm.saltLength);a=new n.org.pkijs.simpl.x509.RSASSA_PSS_params(h);f.signerInfos[i].signatureAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.10",algorithm_params:a.toSchema()});break;default:return new Promise(function(n,i){i("Unsupported signature algorithm: "+t.algorithm.name)})}if("signedAttrs"in f.signerInfos[i])f.signerInfos[i].signedAttrs.encoded_value.byteLength!==0?u=f.signerInfos[i].signedAttrs.encoded_value:(u=f.signerInfos[i].signedAttrs.toSchema(!0).toBER(!1),v=new Uint8Array(u),v[0]=49);else if("eContent"in f.encapContentInfo)if(f.encapContentInfo.eContent.id_block.tag_class===1&&f.encapContentInfo.eContent.id_block.tag_number===4)if(f.encapContentInfo.eContent.id_block.is_constructed===!1)u=f.encapContentInfo.eContent.value_block.value_hex;else for(s=0;s<f.encapContentInfo.eContent.value_block.value.length;s++)u=n.org.pkijs.concat_buffers(u,f.encapContentInfo.eContent.value_block.value[s].value_block.value_hex);else u=f.encapContentInfo.eContent.value_block.value_hex;else if(u.byteLength===0)return new Promise(function(n,t){t("Missed detached data input array")});return(l=n.org.pkijs.getCrypto(),typeof l=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):l.sign(e.algorithm,t,new Uint8Array(u)).then(function(t){return e.algorithm.name==="ECDSA"&&(t=n.org.pkijs.createCMSECDSASignature(t)),f.signerInfos[i].signature=new n.org.pkijs.asn1.OCTETSTRING({value_hex:t}),new Promise(function(n){n(t)})},function(n){return new Promise(function(t,i){i("Signing error: "+n)})})};n.org.pkijs.simpl.CMS_SIGNED_DATA.prototype.toJSON=function(){var t={version:this.version},n;for(t.digestAlgorithms=[],n=0;n<this.digestAlgorithms.length;n++)t.digestAlgorithms.push(this.digestAlgorithms[n].toJSON());if(t.encapContentInfo=this.encapContentInfo.toJSON(),"certificates"in this)for(t.certificates=[],n=0;n<this.certificates.length;n++)t.certificates.push(this.certificates[n].toJSON());if("crls"in this)for(t.crls=[],n=0;n<this.crls.length;n++)t.crls.push(this.crls[n].toJSON());for(t.signerInfos=[],n=0;n<this.signerInfos.length;n++)t.signerInfos.push(this.signerInfos[n].toJSON());return t};n.org.pkijs.simpl.cms.ECC_CMS_SharedInfo=function(){this.keyInfo=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.suppPubInfo=new n.org.pkijs.asn1.OCTETSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.ECC_CMS_SharedInfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.keyInfo=arguments[0].keyInfo||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,"entityUInfo"in arguments[0]&&(this.entityUInfo=arguments[0].entityUInfo),this.suppPubInfo=arguments[0].suppPubInfo||new n.org.pkijs.asn1.OCTETSTRING)};n.org.pkijs.simpl.cms.ECC_CMS_SharedInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.ECC_CMS_SharedInfo({names:{keyInfo:{names:{block_name:"keyInfo"}},entityUInfo:"entityUInfo",suppPubInfo:"suppPubInfo"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for ECC_CMS_SharedInfo");this.keyInfo=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.keyInfo});"entityUInfo"in i.result&&(this.entityUInfo=i.result.entityUInfo.value_block.value[0]);this.suppPubInfo=i.result.suppPubInfo.value_block.value[0]};n.org.pkijs.simpl.cms.ECC_CMS_SharedInfo.prototype.toSchema=function(){var t=[];return t.push(this.keyInfo.toSchema()),"entityUInfo"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[this.entityUInfo]})),t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:2},value:[this.suppPubInfo]})),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.ECC_CMS_SharedInfo.prototype.toJSON=function(){var n={keyInfo:this.keyInfo.toJSON()};return"entityUInfo"in this&&(n.entityUInfo=this.entityUInfo.toJSON()),n.suppPubInfo=this.suppPubInfo.toJSON(),n};n.org.pkijs.simpl.cms.RecipientIdentifier=function(){this.variant=-1;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.RecipientIdentifier.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.variant=arguments[0].variant||-1,"value"in arguments[0]&&(this.value=arguments[0].value))};n.org.pkijs.simpl.cms.RecipientIdentifier.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.RecipientIdentifier({names:{block_name:"block_name"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for RecipientIdentifier");i.result.block_name.id_block.tag_class===1?(this.variant=1,this.value=new n.org.pkijs.simpl.cms.IssuerAndSerialNumber({schema:i.result.block_name})):(this.variant=2,this.value=i.result.block_name.value_block.value[0])};n.org.pkijs.simpl.cms.RecipientIdentifier.prototype.toSchema=function(){switch(this.variant){case 1:return this.value.toSchema();case 2:return new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[this.value]});default:return new n.org.pkijs.asn1.ANY}return new n.org.pkijs.asn1.ANY};n.org.pkijs.simpl.cms.RecipientIdentifier.prototype.toJSON=function(){var n={variant:this.variant};return(this.variant==1||this.variant===2)&&(n.value=this.value.toJSON()),n};n.org.pkijs.simpl.cms.KeyTransRecipientInfo=function(){this.version=-1;this.rid=new n.org.pkijs.emptyObject;this.keyEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.encryptedKey=new n.org.pkijs.asn1.OCTETSTRING;this.recipientCertificate=new n.org.pkijs.simpl.CERT;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.KeyTransRecipientInfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version=arguments[0].version||-1,this.rid=arguments[0].rid||new n.org.pkijs.emptyObject,this.keyEncryptionAlgorithm=arguments[0].keyEncryptionAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.encryptedKey=arguments[0].encryptedKey||new n.org.pkijs.asn1.OCTETSTRING,this.recipientCertificate=arguments[0].recipientCertificate||new n.org.pkijs.simpl.CERT)};n.org.pkijs.simpl.cms.KeyTransRecipientInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.KeyTransRecipientInfo({names:{version:"version",rid:{names:{block_name:"rid"}},keyEncryptionAlgorithm:{names:{block_name:"keyEncryptionAlgorithm"}},encryptedKey:"encryptedKey"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for KeyTransRecipientInfo");this.version=i.result.version.value_block.value_dec;this.rid=i.result.rid.id_block.tag_class===3?i.result.rid.value_block.value[0]:new n.org.pkijs.simpl.cms.IssuerAndSerialNumber({schema:i.result.rid});this.keyEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.keyEncryptionAlgorithm});this.encryptedKey=i.result.encryptedKey};n.org.pkijs.simpl.cms.KeyTransRecipientInfo.prototype.toSchema=function(){var t=[];return t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),this.rid instanceof n.org.pkijs.simpl.cms.IssuerAndSerialNumber?t.push(this.rid.toSchema()):t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[this.rid]})),t.push(this.keyEncryptionAlgorithm.toSchema()),t.push(this.encryptedKey),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.KeyTransRecipientInfo.prototype.toJSON=function(){return{version:this.version,rid:this.rid.toJSON(),keyEncryptionAlgorithm:this.keyEncryptionAlgorithm.toJSON(),encryptedKey:this.encryptedKey.toJSON()}};n.org.pkijs.simpl.cms.OriginatorPublicKey=function(){this.algorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.publicKey=new n.org.pkijs.asn1.BITSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.OriginatorPublicKey.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.algorithm=arguments[0].algorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.publicKey=arguments[0].publicKey||new n.org.pkijs.asn1.BITSTRING)};n.org.pkijs.simpl.cms.OriginatorPublicKey.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.OriginatorPublicKey({names:{algorithm:{names:{block_name:"algorithm"}},publicKey:"publicKey"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for OriginatorPublicKey");this.algorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.algorithm});this.publicKey=i.result.publicKey};n.org.pkijs.simpl.cms.OriginatorPublicKey.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.algorithm.toSchema(),this.publicKey]})};n.org.pkijs.simpl.cms.OriginatorPublicKey.prototype.toJSON=function(){return{algorithm:this.algorithm.toJSON(),publicKey:this.publicKey.toJSON()}};n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey=function(){this.variant=-1;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.variant=arguments[0].variant||-1,"value"in arguments[0]&&(this.value=arguments[0].value))};n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.OriginatorIdentifierOrKey({names:{block_name:"block_name"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for OriginatorIdentifierOrKey");i.result.block_name.id_block.tag_class===1?(this.variant=1,this.value=new n.org.pkijs.simpl.cms.IssuerAndSerialNumber({schema:i.result.block_name})):i.result.block_name.id_block.tag_number===0?(i.result.block_name.id_block.tag_class=1,i.result.block_name.id_block.tag_number=4,this.variant=2,this.value=i.result.block_name):(i.result.block_name.id_block.tag_class=1,i.result.block_name.id_block.tag_number=16,this.variant=3,this.value=new n.org.pkijs.simpl.cms.OriginatorPublicKey({schema:i.result.block_name}))};n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey.prototype.toSchema=function(){switch(this.variant){case 1:return this.value.toSchema();case 2:return this.value.id_block.tag_class=3,this.value.id_block.tag_number=0,this.value;case 3:var t=this.value.toSchema();return t.id_block.tag_class=3,t.id_block.tag_number=1,t;default:return new n.org.pkijs.asn1.ANY}return new n.org.pkijs.asn1.ANY};n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey.prototype.toJSON=function(){var n={variant:this.variant};return(this.variant==1||this.variant===2||this.variant===3)&&(n.value=this.value.toJSON()),n};n.org.pkijs.simpl.cms.OtherKeyAttribute=function(){this.keyAttrId="";arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.OtherKeyAttribute.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.keyAttrId=arguments[0].keyAttrId||new n.org.pkijs.asn1.OID,"keyAttr"in arguments[0]&&(this.keyAttr=arguments[0].keyAttr))};n.org.pkijs.simpl.cms.OtherKeyAttribute.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.OtherKeyAttribute({names:{keyAttrId:"keyAttrId",keyAttr:"keyAttr"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for OtherKeyAttribute");this.keyAttrId=i.result.keyAttrId.value_block.toString();"keyAttr"in i.result&&(this.keyAttr=i.result.keyAttr)};n.org.pkijs.simpl.cms.OtherKeyAttribute.prototype.toSchema=function(){var t=[];return t.push(new n.org.pkijs.asn1.OID({value:this.keyAttrId})),"keyAttr"in this&&t.push(this.keyAttr.toSchema()),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.OtherKeyAttribute.prototype.toJSON=function(){var n={keyAttrId:this.keyAttrId};return"keyAttr"in this&&(n.keyAttr=this.keyAttr.toJSON()),n};n.org.pkijs.simpl.cms.RecipientKeyIdentifier=function(){this.subjectKeyIdentifier=new n.org.pkijs.asn1.OCTETSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.RecipientKeyIdentifier.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.subjectKeyIdentifier=arguments[0].subjectKeyIdentifier||new n.org.pkijs.asn1.OCTETSTRING,"date"in arguments[0]&&(this.date=arguments[0].date),"other"in arguments[0]&&(this.other=arguments[0].other))};n.org.pkijs.simpl.cms.RecipientKeyIdentifier.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.RecipientKeyIdentifier({names:{subjectKeyIdentifier:"subjectKeyIdentifier",date:"date",other:{names:{block_name:"other"}}}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for RecipientKeyIdentifier");this.subjectKeyIdentifier=i.result.subjectKeyIdentifier;"date"in i.result&&(this.date=i.result.date);"other"in i.result&&(this.other=new n.org.pkijs.simpl.cms.OtherKeyAttribute({schema:i.result.other}))};n.org.pkijs.simpl.cms.RecipientKeyIdentifier.prototype.toSchema=function(){var t=[];return t.push(this.subjectKeyIdentifier),"date"in this&&t.push(this.date),"other"in this&&t.push(this.other.toSchema()),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.RecipientKeyIdentifier.prototype.toJSON=function(){var n={subjectKeyIdentifier:this.subjectKeyIdentifier.toJSON()};return"date"in this&&(n.date=this.date),"other"in this&&(n.other=this.other.toJSON()),n};n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier=function(){this.variant=-1;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.variant=arguments[0].variant||-1,"value"in arguments[0]&&(this.value=arguments[0].value))};n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.KeyAgreeRecipientIdentifier({names:{block_name:"block_name"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for KeyAgreeRecipientIdentifier");i.result.block_name.id_block.tag_class===1?(this.variant=1,this.value=new n.org.pkijs.simpl.cms.IssuerAndSerialNumber({schema:i.result.block_name})):(this.variant=2,i.result.block_name.id_block.tag_class=1,i.result.block_name.id_block.tag_number=16,this.value=new n.org.pkijs.simpl.cms.RecipientKeyIdentifier({schema:i.result.block_name}))};n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier.prototype.toSchema=function(){switch(this.variant){case 1:return this.value.toSchema();case 2:return new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:this.value.toSchema().value_block.value});default:return new n.org.pkijs.asn1.ANY}return new n.org.pkijs.asn1.ANY};n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier.prototype.toJSON=function(){var n={variant:this.variant};return(this.variant==1||this.variant===2)&&(n.value=this.value.toJSON()),n};n.org.pkijs.simpl.cms.RecipientEncryptedKey=function(){this.rid=new n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier;this.encryptedKey=new n.org.pkijs.asn1.OCTETSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.RecipientEncryptedKey.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.rid=arguments[0].rid||new n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier,this.encryptedKey=arguments[0].encryptedKey||new n.org.pkijs.asn1.OCTETSTRING)};n.org.pkijs.simpl.cms.RecipientEncryptedKey.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.RecipientEncryptedKey({names:{rid:{names:{block_name:"rid"}},encryptedKey:"encryptedKey"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for RecipientEncryptedKey");this.rid=new n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier({schema:i.result.rid});this.encryptedKey=i.result.encryptedKey};n.org.pkijs.simpl.cms.RecipientEncryptedKey.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.rid.toSchema(),this.encryptedKey]})};n.org.pkijs.simpl.cms.RecipientEncryptedKey.prototype.toJSON=function(){return{rid:this.rid.toJSON(),encryptedKey:this.encryptedKey.toJSON()}};n.org.pkijs.simpl.cms.RecipientEncryptedKeys=function(){this.encryptedKeys=[];arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.RecipientEncryptedKeys.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.encryptedKeys=arguments[0].encryptedKeys||[])};n.org.pkijs.simpl.cms.RecipientEncryptedKeys.prototype.fromSchema=function(t){var u=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.RecipientEncryptedKeys({names:{RecipientEncryptedKeys:"RecipientEncryptedKeys"}})),r,i;if(u.verified===!1)throw new Error("Object's schema was not verified against input data for RecipientEncryptedKeys");for(r=u.result.RecipientEncryptedKeys,i=0;i<r.length;i++)this.encryptedKeys.push(new n.org.pkijs.simpl.cms.RecipientEncryptedKey({schema:r[i]}))};n.org.pkijs.simpl.cms.RecipientEncryptedKeys.prototype.toSchema=function(){for(var i=[],t=0;t<this.encryptedKeys.length;t++)i.push(this.encryptedKeys[t].toSchema());return new n.org.pkijs.asn1.SEQUENCE({value:i})};n.org.pkijs.simpl.cms.RecipientEncryptedKeys.prototype.toJSON=function(){var t={},n;for(t.encryptedKeys=[],n=0;n<this.encryptedKeys.length;n++)t.encryptedKeys.push(this.encryptedKeys[n].toJSON());return t};n.org.pkijs.simpl.cms.KeyAgreeRecipientInfo=function(){this.version=0;this.originator=new n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey;this.keyEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.recipientEncryptedKeys=new n.org.pkijs.simpl.cms.RecipientEncryptedKeys;this.recipientCertificate=new n.org.pkijs.simpl.CERT;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.KeyAgreeRecipientInfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version=arguments[0].version||0,this.originator=arguments[0].originator||new n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey,"ukm"in arguments[0]&&(this.ukm=arguments[0].ukm),this.keyEncryptionAlgorithm=arguments[0].keyEncryptionAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.recipientEncryptedKeys=arguments[0].recipientEncryptedKeys||new n.org.pkijs.simpl.cms.RecipientEncryptedKeys,this.recipientCertificate=arguments[0].recipientCertificate||new n.org.pkijs.simpl.CERT)};n.org.pkijs.simpl.cms.KeyAgreeRecipientInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.KeyAgreeRecipientInfo({names:{version:"version",originator:{names:{block_name:"originator"}},ukm:"ukm",keyEncryptionAlgorithm:{names:{block_name:"keyEncryptionAlgorithm"}},recipientEncryptedKeys:{names:{block_name:"recipientEncryptedKeys"}}}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for KeyAgreeRecipientInfo");this.version=i.result.version.value_block.value_dec;this.originator=new n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey({schema:i.result.originator});"ukm"in i.result&&(this.ukm=i.result.ukm);this.keyEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.keyEncryptionAlgorithm});this.recipientEncryptedKeys=new n.org.pkijs.simpl.cms.RecipientEncryptedKeys({schema:i.result.recipientEncryptedKeys})};n.org.pkijs.simpl.cms.KeyAgreeRecipientInfo.prototype.toSchema=function(){var t=[];return t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:[this.originator.toSchema()]})),"ukm"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:[this.ukm]})),t.push(this.keyEncryptionAlgorithm.toSchema()),t.push(this.recipientEncryptedKeys.toSchema()),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.KeyAgreeRecipientInfo.prototype.toJSON=function(){return{version:this.version,originator:this.originator.toJSON(),ukm:this.ukm.toJSON(),keyEncryptionAlgorithm:this.keyEncryptionAlgorithm.toJSON(),recipientEncryptedKeys:this.recipientEncryptedKeys.toJSON()}};n.org.pkijs.simpl.cms.KEKIdentifier=function(){this.keyIdentifier=new n.org.pkijs.asn1.OCTETSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.KEKIdentifier.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.keyIdentifier=arguments[0].keyIdentifier||new n.org.pkijs.asn1.OCTETSTRING,"date"in arguments[0]&&(this.date=arguments[0].date),"other"in arguments[0]&&(this.other=arguments[0].other))};n.org.pkijs.simpl.cms.KEKIdentifier.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.KEKIdentifier({names:{keyIdentifier:"keyIdentifier",date:"date",other:{names:{block_name:"other"}}}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for KEKIdentifier");this.keyIdentifier=i.result.keyIdentifier;"date"in i.result&&(this.date=i.result.date);"other"in i.result&&(this.other=new n.org.pkijs.simpl.cms.OtherKeyAttribute({schema:i.result.other}))};n.org.pkijs.simpl.cms.KEKIdentifier.prototype.toSchema=function(){var t=[];return t.push(this.keyIdentifier),"date"in this&&t.push(this.date),"other"in this&&t.push(this.other.toSchema()),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.KEKIdentifier.prototype.toJSON=function(){var n={keyIdentifier:this.keyIdentifier.toJSON()};return"date"in this&&(n.date=this.date),"other"in this&&(n.other=this.other.toJSON()),n};n.org.pkijs.simpl.cms.KEKRecipientInfo=function(){this.version=0;this.kekid=new n.org.pkijs.simpl.cms.KEKIdentifier;this.keyEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.encryptedKey=new n.org.pkijs.asn1.OCTETSTRING;this.preDefinedKEK=new ArrayBuffer(0);arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.KEKRecipientInfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version=arguments[0].version||0,this.kekid=arguments[0].kekid||new n.org.pkijs.simpl.cms.KEKIdentifier,this.keyEncryptionAlgorithm=arguments[0].keyEncryptionAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.encryptedKey=arguments[0].encryptedKey||new n.org.pkijs.asn1.OCTETSTRING,this.preDefinedKEK=arguments[0].preDefinedKEK||new ArrayBuffer(0))};n.org.pkijs.simpl.cms.KEKRecipientInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.KEKRecipientInfo({names:{version:"version",kekid:{names:{block_name:"kekid"}},keyEncryptionAlgorithm:{names:{block_name:"keyEncryptionAlgorithm"}},encryptedKey:"encryptedKey"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for KEKRecipientInfo");this.version=i.result.version.value_block.value_dec;this.kekid=new n.org.pkijs.simpl.cms.KEKIdentifier({schema:i.result.kekid});this.keyEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.keyEncryptionAlgorithm});this.encryptedKey=i.result.encryptedKey};n.org.pkijs.simpl.cms.KEKRecipientInfo.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.INTEGER({value:this.version}),this.kekid.toSchema(),this.keyEncryptionAlgorithm.toSchema(),this.encryptedKey]})};n.org.pkijs.simpl.cms.KEKRecipientInfo.prototype.toJSON=function(){return{version:this.version,kekid:this.originator.toJSON(),keyEncryptionAlgorithm:this.keyEncryptionAlgorithm.toJSON(),encryptedKey:this.encryptedKey.toJSON()}};n.org.pkijs.simpl.cms.PasswordRecipientinfo=function(){this.version=-1;this.keyEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;this.encryptedKey=new n.org.pkijs.asn1.OCTETSTRING;this.password=new ArrayBuffer(0);arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.PasswordRecipientinfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version="version"in arguments[0]?arguments[0].version:-1,"keyDerivationAlgorithm"in arguments[0]&&(this.keyDerivationAlgorithm=arguments[0].keyDerivationAlgorithm),this.keyEncryptionAlgorithm=arguments[0].keyEncryptionAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,this.encryptedKey=arguments[0].encryptedKey||new n.org.pkijs.asn1.OCTETSTRING,this.password=arguments[0].password||new ArrayBuffer(0))};n.org.pkijs.simpl.cms.PasswordRecipientinfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.PasswordRecipientinfo({names:{version:"version",keyDerivationAlgorithm:"keyDerivationAlgorithm",keyEncryptionAlgorithm:{names:{block_name:"keyEncryptionAlgorithm"}},encryptedKey:"encryptedKey"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PasswordRecipientinfo");this.version=i.result.version.value_block.value_dec;"keyDerivationAlgorithm"in i.result&&(i.result.keyDerivationAlgorithm.id_block.tag_class=1,i.result.keyDerivationAlgorithm.id_block.tag_number=16,this.keyDerivationAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.keyDerivationAlgorithm}));this.keyEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.keyEncryptionAlgorithm});this.encryptedKey=i.result.encryptedKey};n.org.pkijs.simpl.cms.PasswordRecipientinfo.prototype.toSchema=function(){var t=[];return t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),"keyDerivationAlgorithm"in this&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({id_block:{tag_class:3,tag_number:0},value:this.keyDerivationAlgorithm.toSchema().value_block.value})),t.push(this.keyEncryptionAlgorithm.toSchema()),t.push(this.encryptedKey),new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.cms.PasswordRecipientinfo.prototype.toJSON=function(){return{version:this.version,keyDerivationAlgorithm:this.keyDerivationAlgorithm.toJSON(),keyEncryptionAlgorithm:this.keyEncryptionAlgorithm.toJSON(),encryptedKey:this.encryptedKey.toJSON()}};n.org.pkijs.simpl.cms.OtherRecipientInfo=function(){this.oriType="";this.oriValue=new n.org.pkijs.asn1.ANY;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.OtherRecipientInfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.oriType=arguments[0].oriType||"",this.oriValue=arguments[0].oriValue||new n.org.pkijs.asn1.ANY)};n.org.pkijs.simpl.cms.OtherRecipientInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.OtherRecipientInfo({names:{oriType:"oriType",oriValue:"oriValue"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for OtherRecipientInfo");this.oriType=i.result.oriType.value_block.toString();this.oriValue=i.result.oriValue};n.org.pkijs.simpl.cms.OtherRecipientInfo.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.OID({value:this.oriType}),this.oriValue]})};n.org.pkijs.simpl.cms.OtherRecipientInfo.prototype.toJSON=function(){var t={oriType:this.oriType};return this.oriValue instanceof n.org.pkijs.asn1.ANY||(t.oriValue=this.oriValue.toJSON()),t};n.org.pkijs.simpl.CMS_RECIPIENT_INFO=function(){this.variant=-1;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CMS_RECIPIENT_INFO.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.variant=arguments[0].variant||-1,"value"in arguments[0]&&(this.value=arguments[0].value))};n.org.pkijs.simpl.CMS_RECIPIENT_INFO.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CMS_RECIPIENT_INFO({names:{block_name:"block_name"}})),r;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for CMS_RECIPIENT_INFO");if(i.result.block_name.id_block.tag_class===1)this.variant=1,this.value=new n.org.pkijs.simpl.cms.KeyTransRecipientInfo({schema:i.result.block_name});else{r=i.result.block_name.id_block.tag_number;i.result.block_name.id_block.tag_class=1;i.result.block_name.id_block.tag_number=16;switch(r){case 1:this.variant=2;this.value=new n.org.pkijs.simpl.cms.KeyAgreeRecipientInfo({schema:i.result.block_name});break;case 2:this.variant=3;this.value=new n.org.pkijs.simpl.cms.KEKRecipientInfo({schema:i.result.block_name});break;case 3:this.variant=4;this.value=new n.org.pkijs.simpl.cms.PasswordRecipientinfo({schema:i.result.block_name});break;case 4:this.variant=5;this.value=new n.org.pkijs.simpl.cms.OtherRecipientInfo({schema:i.result.block_name})}}};n.org.pkijs.simpl.CMS_RECIPIENT_INFO.prototype.toSchema=function(){var t=this.value.toSchema();switch(this.variant){case 1:return t;case 2:case 3:case 4:return t.id_block.tag_class=3,t.id_block.tag_number=this.variant-1,t;default:return new n.org.pkijs.asn1.ANY}return new n.org.pkijs.asn1.ANY};n.org.pkijs.simpl.CMS_RECIPIENT_INFO.prototype.toJSON=function(){var n={variant:this.variant};return(this.variant==1||this.variant===2)&&(n.value=this.value.toJSON()),n};n.org.pkijs.simpl.cms.OriginatorInfo=function(){this.certs=new n.org.pkijs.simpl.CMS_CERTIFICATE_SET;this.crls=new n.org.pkijs.simpl.CSM_REVOCATION_INFO_CHOICES;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.cms.OriginatorInfo.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.certs=arguments[0].certs||new n.org.pkijs.simpl.CMS_CERTIFICATE_SET,this.crls=arguments[0].crls||new n.org.pkijs.simpl.CSM_REVOCATION_INFO_CHOICES)};n.org.pkijs.simpl.cms.OriginatorInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.OriginatorInfo({names:{certs:"certs",crls:"crls"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for OriginatorInfo");i.result.certs.id_block.tag_class=1;i.result.certs.id_block.tag_number=17;this.certs=new n.org.pkijs.simpl.CMS_CERTIFICATE_SET({schema:i.result.certs});i.result.crls.id_block.tag_class=1;i.result.crls.id_block.tag_number=17;this.crls=new n.org.pkijs.simpl.CSM_REVOCATION_INFO_CHOICES({schema:i.result.crls})};n.org.pkijs.simpl.cms.OriginatorInfo.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:this.certs.toSchema().value_block.value}),new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:this.crls.toSchema().value_block.value})]})};n.org.pkijs.simpl.cms.OriginatorInfo.prototype.toJSON=function(){return{certs:this.certs.toJSON(),crls:this.crls.toJSON()}};n.org.pkijs.simpl.cms.EncryptedContentInfo=function(){var t;if(this.contentType="",this.contentEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,arguments[0]instanceof Object&&"schema"in arguments[0])n.org.pkijs.simpl.cms.EncryptedContentInfo.prototype.fromSchema.call(this,arguments[0].schema);else if(arguments[0]instanceof Object&&(this.contentType=arguments[0].contentType||"",this.contentEncryptionAlgorithm=arguments[0].contentEncryptionAlgorithm||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER,"encryptedContent"in arguments[0]&&(this.encryptedContent=arguments[0].encryptedContent,this.encryptedContent.id_block.tag_class===1&&this.encryptedContent.id_block.tag_number===4&&this.encryptedContent.id_block.is_constructed===!1))){for(var u=new n.org.pkijs.asn1.OCTETSTRING({id_block:{is_constructed:!0},is_constructed:!0}),i=0,f=this.encryptedContent.value_block.value_hex.byteLength;f>0;){var r=new Uint8Array(this.encryptedContent.value_block.value_hex,i,i+1024>this.encryptedContent.value_block.value_hex.byteLength?this.encryptedContent.value_block.value_hex.byteLength-i:1024),e=new ArrayBuffer(r.length),o=new Uint8Array(e);for(t=0;t<o.length;t++)o[t]=r[t];u.value_block.value.push(new n.org.pkijs.asn1.OCTETSTRING({value_hex:e}));f-=r.length;i+=r.length}this.encryptedContent=u}};n.org.pkijs.simpl.cms.EncryptedContentInfo.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.cms.EncryptedContentInfo({names:{contentType:"contentType",contentEncryptionAlgorithm:{names:{block_name:"contentEncryptionAlgorithm"}},encryptedContent:"encryptedContent"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for EncryptedContentInfo");this.contentType=i.result.contentType.value_block.toString();this.contentEncryptionAlgorithm=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.contentEncryptionAlgorithm});"encryptedContent"in i.result&&(this.encryptedContent=i.result.encryptedContent,this.encryptedContent.id_block.tag_class=1,this.encryptedContent.id_block.tag_number=4)};n.org.pkijs.simpl.cms.EncryptedContentInfo.prototype.toSchema=function(){var r={is_indefinite_form:!1},i=[],t;return i.push(new n.org.pkijs.asn1.OID({value:this.contentType})),i.push(this.contentEncryptionAlgorithm.toSchema()),"encryptedContent"in this&&(r.is_indefinite_form=this.encryptedContent.id_block.is_constructed,t=this.encryptedContent,t.id_block.tag_class=3,t.id_block.tag_number=0,t.len_block.is_indefinite_form=this.encryptedContent.id_block.is_constructed,i.push(t)),new n.org.pkijs.asn1.SEQUENCE({len_block:r,value:i})};n.org.pkijs.simpl.cms.EncryptedContentInfo.prototype.toJSON=function(){var n={contentType:this.contentType,contentEncryptionAlgorithm:this.contentEncryptionAlgorithm.toJSON()};return"encryptedContent"in this&&(n.encryptedContent=this.encryptedContent.toJSON()),n};n.org.pkijs.simpl.CMS_ENVELOPED_DATA=function(){this.version=0;this.recipientInfos=[];this.encryptedContentInfo=new n.org.pkijs.simpl.cms.EncryptedContentInfo;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.CMS_ENVELOPED_DATA.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.version=arguments[0].version||0,"originatorInfo"in arguments[0]&&(this.originatorInfo=arguments[0].originatorInfo),this.recipientInfos=arguments[0].recipientInfos||[],this.encryptedContentInfo=arguments[0].encryptedContentInfo||new n.org.pkijs.simpl.cms.EncryptedContentInfo,"unprotectedAttrs"in arguments[0]&&(this.unprotectedAttrs=arguments[0].unprotectedAttrs))};n.org.pkijs.simpl.CMS_ENVELOPED_DATA.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.CMS_ENVELOPED_DATA({names:{version:"version",originatorInfo:"originatorInfo",recipientInfos:"recipientInfos",encryptedContentInfo:{names:{block_name:"encryptedContentInfo"}},unprotectedAttrs:"unprotectedAttrs"}})),f,r,e,u;if(i.verified===!1)throw new Error("Object's schema was not verified against input data for CMS_ENVELOPED_DATA");for(this.version=i.result.version.value_block.value_dec,("originatorInfo"in i.result)&&(i.result.originatorInfo.id_block.tag_class=1,i.result.originatorInfo.id_block.tag_number=16,this.originatorInfo=new n.org.pkijs.simpl.cms.OriginatorInfo({schema:i.result.originatorInfo})),f=i.result.recipientInfos,r=0;r<f.length;r++)this.recipientInfos.push(new n.org.pkijs.simpl.CMS_RECIPIENT_INFO({schema:f[r]}));if(this.encryptedContentInfo=new n.org.pkijs.simpl.cms.EncryptedContentInfo({schema:i.result.encryptedContentInfo}),"unprotectedAttrs"in i.result)for(this.unprotectedAttrs=[],e=i.result.unprotectedAttrs,u=0;u<e.length;u++)this.unprotectedAttrs.push(new n.org.pkijs.simpl.ATTRIBUTE({schema:e[u]}))};n.org.pkijs.simpl.CMS_ENVELOPED_DATA.prototype.toSchema=function(){var t=[],u,i,f,r;for(t.push(new n.org.pkijs.asn1.INTEGER({value:this.version})),("originatorInfo"in this)&&t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:0},value:this.originatorInfo.toSchema().value_block.value})),u=[],i=0;i<this.recipientInfos.length;i++)u.push(this.recipientInfos[i].toSchema());if(t.push(new n.org.pkijs.asn1.SET({value:u})),t.push(this.encryptedContentInfo.toSchema()),"unprotectedAttrs"in this){for(f=[],r=0;r<this.unprotectedAttrs.length;r++)f.push(this.unprotectedAttrs[r].toSchema());t.push(new n.org.pkijs.asn1.ASN1_CONSTRUCTED({optional:!0,id_block:{tag_class:3,tag_number:1},value:f}))}return new n.org.pkijs.asn1.SEQUENCE({value:t})};n.org.pkijs.simpl.CMS_ENVELOPED_DATA.prototype.toJSON=function(){var t={version:this.version},n;for(("originatorInfo"in this)&&(t.originatorInfo=this.originatorInfo.toJSON()),t.recipientInfos=[],n=0;n<this.recipientInfos.length;n++)t.recipientInfos.push(this.recipientInfos[n].toJSON());if(t.encryptedContentInfo=this.encryptedContentInfo.toJSON(),"unprotectedAttrs"in this)for(t.unprotectedAttrs=[],n=0;n<this.unprotectedAttrs.length;n++)t.unprotectedAttrs.push(this.unprotectedAttrs[n].toJSON());return t};n.org.pkijs.simpl.CMS_ENVELOPED_DATA.prototype.addRecipientByCertificate=function(t,i,r){var l=0,u=i||{},e,o,v,s,y,h,c,p,f;if(t.subjectPublicKeyInfo.algorithm.algorithm_id.indexOf("1.2.840.113549")!==-1)l=1,r=1;else if(t.subjectPublicKeyInfo.algorithm.algorithm_id.indexOf("1.2.840.10045")!==-1)l=2,r=2;else throw new Error("Unknown type of certificate's public key: "+t.subjectPublicKeyInfo.algorithm.algorithm_id);"oaepHashAlgorithm"in u==!1&&(u.oaepHashAlgorithm="SHA-512");"kdfAlgorithm"in u==!1&&(u.kdfAlgorithm="SHA-512");"kekEncryptionLength"in u==!1&&(u.kekEncryptionLength=256);switch(r){case 1:if(e=n.org.pkijs.getOIDByAlgorithm({name:"RSA-OAEP"}),e==="")throw new Error("Can not find OID for OAEP");if(o=n.org.pkijs.getOIDByAlgorithm({name:u.oaepHashAlgorithm}),o==="")throw new Error("Unknown OAEP hash algorithm: "+u.oaepHashAlgorithm);var a=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:o,algorithm_params:new n.org.pkijs.asn1.NULL}),w=new n.org.pkijs.simpl.x509.RSAES_OAEP_params({hashAlgorithm:a,maskGenAlgorithm:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:"1.2.840.113549.1.1.8",algorithm_params:a.toSchema()})}),f=new n.org.pkijs.simpl.cms.KeyTransRecipientInfo({version:0,rid:new n.org.pkijs.simpl.cms.IssuerAndSerialNumber({issuer:t.issuer,serialNumber:t.serialNumber}),keyEncryptionAlgorithm:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:e,algorithm_params:w.toSchema()}),recipientCertificate:t});this.recipientInfos.push(new n.org.pkijs.simpl.CMS_RECIPIENT_INFO({variant:1,value:f}));break;case 2:if(v=new n.org.pkijs.simpl.cms.RecipientEncryptedKey({rid:new n.org.pkijs.simpl.cms.KeyAgreeRecipientIdentifier({variant:1,value:new n.org.pkijs.simpl.cms.IssuerAndSerialNumber({issuer:t.issuer,serialNumber:t.serialNumber})})}),s=n.org.pkijs.getOIDByAlgorithm({name:"AES-KW",length:u.kekEncryptionLength}),s==="")throw new Error("Unknown length for key encryption algorithm: "+u.kekEncryptionLength);if(y=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:s,algorithm_params:new n.org.pkijs.asn1.NULL}),h=n.org.pkijs.getOIDByAlgorithm({name:"ECDH",kdf:u.kdfAlgorithm}),h==="")throw new Error("Unknown KDF algorithm: "+u.kdfAlgorithm);c=new ArrayBuffer(64);p=new Uint8Array(c);n.org.pkijs.getRandomValues(p);f=new n.org.pkijs.simpl.cms.KeyAgreeRecipientInfo({version:3,ukm:new n.org.pkijs.asn1.OCTETSTRING({value_hex:c}),keyEncryptionAlgorithm:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:h,algorithm_params:y.toSchema()}),recipientEncryptedKeys:new n.org.pkijs.simpl.cms.RecipientEncryptedKeys({encryptedKeys:[v]}),recipientCertificate:t});this.recipientInfos.push(new n.org.pkijs.simpl.CMS_RECIPIENT_INFO({variant:2,value:f}));break;default:throw new Error('Unknown "variant" value: '+r);}return!0};n.org.pkijs.simpl.CMS_ENVELOPED_DATA.prototype.addRecipientByPreDefinedData=function(t,i,r){var u=i||{},o,l,s,h,a,c,v,f,e;if(t instanceof ArrayBuffer==!1)throw new Error('Please pass "preDefinedData" in ArrayBuffer type');if(t.byteLength===0)throw new Error("Pre-defined data could have zero length");"keyIdentifier"in u==!1&&(o=new ArrayBuffer(16),l=new Uint8Array(o),n.org.pkijs.getRandomValues(l),u.keyIdentifier=o);"hmacHashAlgorithm"in u==!1&&(u.hmacHashAlgorithm="SHA-512");"iterationCount"in u==!1&&(u.iterationCount=2048);"keyEncryptionAlgorithm"in u==!1&&(u.keyEncryptionAlgorithm={name:"AES-KW",length:256});"keyEncryptionAlgorithmParams"in u==!1&&(u.keyEncryptionAlgorithmParams=new n.org.pkijs.asn1.NULL);switch(r){case 1:if(f=n.org.pkijs.getOIDByAlgorithm(u.keyEncryptionAlgorithm),f==="")throw new Error('Incorrect value for "keyEncryptionAlgorithm"');e=new n.org.pkijs.simpl.cms.KEKRecipientInfo({version:4,kekid:new n.org.pkijs.simpl.cms.KEKIdentifier({keyIdentifier:new n.org.pkijs.asn1.OCTETSTRING({value_hex:u.keyIdentifier})}),keyEncryptionAlgorithm:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:f,algorithm_params:u.keyEncryptionAlgorithmParams}),preDefinedKEK:t});this.recipientInfos.push(new n.org.pkijs.simpl.CMS_RECIPIENT_INFO({variant:3,value:e}));break;case 2:if(s=n.org.pkijs.getOIDByAlgorithm({name:"PBKDF2"}),s==="")throw new Error("Can not find OID for PBKDF2");if(h=new ArrayBuffer(64),a=new Uint8Array(h),n.org.pkijs.getRandomValues(a),c=n.org.pkijs.getOIDByAlgorithm({name:"HMAC",hash:{name:u.hmacHashAlgorithm}}),c==="")throw new Error('Incorrect value for "hmacHashAlgorithm": '+u.hmacHashAlgorithm);if(v=new n.org.pkijs.simpl.cms.PBKDF2_params({salt:new n.org.pkijs.asn1.OCTETSTRING({value_hex:h}),iterationCount:u.iterationCount,prf:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:c,algorithm_params:new n.org.pkijs.asn1.NULL})}),f=n.org.pkijs.getOIDByAlgorithm(u.keyEncryptionAlgorithm),f==="")throw new Error('Incorrect value for "keyEncryptionAlgorithm"');e=new n.org.pkijs.simpl.cms.PasswordRecipientinfo({version:0,keyDerivationAlgorithm:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:s,algorithm_params:v.toSchema()}),keyEncryptionAlgorithm:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:f,algorithm_params:u.keyEncryptionAlgorithmParams}),password:t});this.recipientInfos.push(new n.org.pkijs.simpl.CMS_RECIPIENT_INFO({variant:4,value:e}));break;default:throw new Error('Unknown value for "variant": '+r);}};n.org.pkijs.simpl.CMS_ENVELOPED_DATA.prototype.encrypt=function(t,i){function y(t){var i=Promise.resolve(),s,h,f,o,c;return i=i.then(function(){var i=r.recipientInfos[t].value.recipientCertificate.subjectPublicKeyInfo.algorithm.algorithm_params,u;if(i instanceof n.org.pkijs.asn1.OID==!1)return new Promise(function(n,i){i('Incorrect "recipientCertificate" for index '+t)});u=i.value_block.toString();switch(u){case"1.2.840.10045.3.1.7":f="P-256";o=256;break;case"1.3.132.0.34":f="P-384";o=384;break;case"1.3.132.0.35":f="P-521";o=528;break;default:return new Promise(function(n,i){i("Incorrect curve OID for index "+t)})}return f},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return u.generateKey({name:"ECDH",namedCurve:n},!0,["deriveBits"])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return s=n.publicKey,h=n.privateKey,u.exportKey("spki",s)},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return c=n,r.recipientInfos[t].value.recipientCertificate.getPublicKey({algorithm:{algorithm:{name:"ECDH",namedCurve:f},usages:[]}})},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return u.deriveBits({name:"ECDH",public:n},h,o)},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(i){var f=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:r.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_params}),e=n.org.pkijs.getAlgorithmByOID(f.algorithm_id),u;if("name"in e==!1)return new Promise(function(n,t){t("Incorrect OID for key encryption algorithm: "+f.algorithm_id)});var o=e.length,s=new ArrayBuffer(4),c=new Uint8Array(s);for(u=3;u>=0;u--)c[u]=o,o>>=8;var l=new n.org.pkijs.simpl.cms.ECC_CMS_SharedInfo({keyInfo:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:f.algorithm_id,algorithm_params:new n.org.pkijs.asn1.NULL}),entityUInfo:r.recipientInfos[t].value.ukm,suppPubInfo:new n.org.pkijs.asn1.OCTETSTRING({value_hex:s})}),a=l.toSchema().toBER(!1),h=n.org.pkijs.getAlgorithmByOID(r.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id);return"name"in h==!1?new Promise(function(n,i){i("Incorrect OID for key encryption algorithm: "+r.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id)}):n.org.pkijs.simpl.cms.kdf(h.kdf,i,e.length,a)},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return u.importKey("raw",n,{name:"AES-KW"},!0,["wrapKey"])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return u.wrapKey("raw",e,n,{name:"AES-KW"})},function(n){return new Promise(function(t,i){i(n)})}),i.then(function(i){var f=org.pkijs.fromBER(c),u=new n.org.pkijs.simpl.cms.OriginatorIdentifierOrKey;u.variant=3;u.value=new n.org.pkijs.simpl.cms.OriginatorPublicKey({schema:f.result});"algorithm_params"in u.value.algorithm&&delete u.value.algorithm.algorithm_params;r.recipientInfos[t].value.originator=u;r.recipientInfos[t].value.recipientEncryptedKeys.encryptedKeys[0].encryptedKey=new n.org.pkijs.asn1.OCTETSTRING({value_hex:i})},function(n){return new Promise(function(t,i){i(n)})})}function p(t){var i=Promise.resolve();return i=i.then(function(){var f=r.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_params,i=new n.org.pkijs.simpl.x509.RSAES_OAEP_params({schema:f}),u=n.org.pkijs.getAlgorithmByOID(i.hashAlgorithm.algorithm_id);return"name"in u==!1?new Promise(function(n,t){t("Incorrect OID for hash algorithm: "+i.hashAlgorithm.algorithm_id)}):r.recipientInfos[t].value.recipientCertificate.getPublicKey({algorithm:{algorithm:{name:"RSA-OAEP",hash:{name:u.name}},usages:["encrypt","wrapKey"]}})},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return u.encrypt({name:"RSA-OAEP"},n,c)},function(n){return new Promise(function(t,i){i(n)})}),i.then(function(i){r.recipientInfos[t].value.encryptedKey=new n.org.pkijs.asn1.OCTETSTRING({value_hex:i})},function(n){return new Promise(function(t,i){i(n)})})}function w(t){var i=Promise.resolve(),f;return i=i.then(function(){return(f=n.org.pkijs.getAlgorithmByOID(r.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id),"name"in f==!1)?new Promise(function(n,i){i('Incorrect OID for "keyEncryptionAlgorithm": '+r.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id)}):u.importKey("raw",new Uint8Array(r.recipientInfos[t].value.preDefinedKEK),f,!0,["wrapKey"])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return u.wrapKey("raw",e,n,f)},function(n){return new Promise(function(t,i){i(n)})}),i.then(function(i){r.recipientInfos[t].value.encryptedKey=new n.org.pkijs.asn1.OCTETSTRING({value_hex:i})},function(n){return new Promise(function(t,i){i(n)})})}function b(t){var i=Promise.resolve(),f,o;return i=i.then(function(){if("keyDerivationAlgorithm"in r.recipientInfos[t].value==!1)return new Promise(function(n,t){t('Please append encoded "keyDerivationAlgorithm"')});if("algorithm_params"in r.recipientInfos[t].value.keyDerivationAlgorithm==!1)return new Promise(function(n,t){t('Incorrectly encoded "keyDerivationAlgorithm"')});try{f=new n.org.pkijs.simpl.cms.PBKDF2_params({schema:r.recipientInfos[t].value.keyDerivationAlgorithm.algorithm_params})}catch(i){return new Promise(function(n,t){t('Incorrectly encoded "keyDerivationAlgorithm"')})}},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(){var n=new Uint8Array(r.recipientInfos[t].value.password);return u.importKey("raw",n,"PBKDF2",!0,["deriveKey"])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(i){var e,s,h,c;if(o=n.org.pkijs.getAlgorithmByOID(r.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id),"name"in o==!1)return new Promise(function(n,i){i('Incorrect OID for "keyEncryptionAlgorithm": '+r.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id)});if(e="SHA-1","prf"in f){if(s=n.org.pkijs.getAlgorithmByOID(f.prf.algorithm_id),"name"in s==!1)return new Promise(function(n,t){t("Incorrect OID for HMAC hash algorithm")});e=s.hash.name}return h=new Uint8Array(f.salt.value_block.value_hex),c=f.iterationCount,u.deriveKey({name:"PBKDF2",hash:{name:e},salt:h,iterations:c},i,o,!0,["wrapKey"])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return u.wrapKey("raw",e,n,o)},function(n){return new Promise(function(t,i){i(n)})}),i.then(function(i){r.recipientInfos[t].value.encryptedKey=new n.org.pkijs.asn1.OCTETSTRING({value_hex:i})},function(n){return new Promise(function(t,i){i(n)})})}var r=this,f=Promise.resolve(),o=new ArrayBuffer(16),s=new Uint8Array(o),u;n.org.pkijs.getRandomValues(s);var v=new Uint8Array(i),e,h,c,l=[],a=n.org.pkijs.getOIDByAlgorithm(t);return a===""?new Promise(function(n,t){t('Wrong "contentEncryptionAlgorithm" value')}):(u=n.org.pkijs.getCrypto(),typeof u=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):(f=f.then(function(){return u.generateKey(t,!0,["encrypt"])}),f=f.then(function(n){return e=n,u.encrypt({name:t.name,iv:s},e,v)},function(n){return new Promise(function(t,i){i(n)})}),f=f.then(function(n){return h=n,u.exportKey("raw",e)},function(n){return new Promise(function(t,i){i(n)})}).then(function(n){return c=n,!0},function(n){return new Promise(function(t,i){i(n)})}),f=f.then(function(){r.version=2;r.encryptedContentInfo=new n.org.pkijs.simpl.cms.EncryptedContentInfo({contentType:"1.2.840.113549.1.7.1",contentEncryptionAlgorithm:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:a,algorithm_params:new n.org.pkijs.asn1.OCTETSTRING({value_hex:o})}),encryptedContent:new n.org.pkijs.asn1.OCTETSTRING({value_hex:h})})},function(n){return new Promise(function(t,i){i(n)})}),f=f.then(function(){for(var t,n=0;n<r.recipientInfos.length;n++){t=Promise.resolve();switch(r.recipientInfos[n].variant){case 1:t=p(n);break;case 2:t=y(n);break;case 3:t=w(n);break;case 4:t=b(n);break;default:return new Promise(function(t,i){i("Uknown recipient type in array with index "+n)})}l.push(t)}},function(n){return new Promise(function(t,i){i(n)})}),f.then(function(){return Promise.all(l)},function(n){return new Promise(function(t,i){i(n)})}))};n.org.pkijs.simpl.CMS_ENVELOPED_DATA.prototype.decrypt=function(t,r){function s(t){var i=Promise.resolve(),r,o,s,h;return i=i.then(function(){if("recipientCertificate"in e==!1)return new Promise(function(n,t){t('Parameter "recipientCertificate" is mandatory for "KeyAgreeRecipientInfo"')});if("recipientPrivateKey"in e==!1)return new Promise(function(n,t){t('Parameter "recipientPrivateKey" is mandatory for "KeyAgreeRecipientInfo"')});var i=e.recipientCertificate.subjectPublicKeyInfo.algorithm.algorithm_params;if(i instanceof n.org.pkijs.asn1.OID==!1)return new Promise(function(n,i){i('Incorrect "recipientCertificate" for index '+t)});s=i.value_block.toString();switch(s){case"1.2.840.10045.3.1.7":r="P-256";o=256;break;case"1.3.132.0.34":r="P-384";o=384;break;case"1.3.132.0.35":r="P-521";o=528;break;default:return new Promise(function(n,i){i("Incorrect curve OID for index "+t)})}return f.importKey("pkcs8",e.recipientPrivateKey,{name:"ECDH",namedCurve:r},!0,["deriveBits"])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(i){h=i;"algorithm_params"in u.recipientInfos[t].value.originator.value.algorithm==!1&&(u.recipientInfos[t].value.originator.value.algorithm.algorithm_params=new n.org.pkijs.asn1.OID({value:s}));var e=u.recipientInfos[t].value.originator.value.toSchema().toBER(!1);return f.importKey("spki",e,{name:"ECDH",namedCurve:r},!0,[])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return f.deriveBits({name:"ECDH",public:n},h,o)},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(i){var f=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:u.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_params}),e=n.org.pkijs.getAlgorithmByOID(f.algorithm_id),r;if("name"in e==!1)return new Promise(function(n,t){t("Incorrect OID for key encryption algorithm: "+f.algorithm_id)});var o=e.length,s=new ArrayBuffer(4),c=new Uint8Array(s);for(r=3;r>=0;r--)c[r]=o,o>>=8;var l=new n.org.pkijs.simpl.cms.ECC_CMS_SharedInfo({keyInfo:new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({algorithm_id:f.algorithm_id,algorithm_params:new n.org.pkijs.asn1.NULL}),entityUInfo:u.recipientInfos[t].value.ukm,suppPubInfo:new n.org.pkijs.asn1.OCTETSTRING({value_hex:s})}),a=l.toSchema().toBER(!1),h=n.org.pkijs.getAlgorithmByOID(u.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id);return"name"in h==!1?new Promise(function(n,i){i("Incorrect OID for key encryption algorithm: "+u.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id)}):n.org.pkijs.simpl.cms.kdf(h.kdf,i,e.length,a)},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return f.importKey("raw",n,{name:"AES-KW"},!0,["unwrapKey"])},function(n){return new Promise(function(t,i){i(n)})}),i.then(function(i){var r=n.org.pkijs.getAlgorithmByOID(u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id);return"name"in r==!1?new Promise(function(n,t){t('Incorrect "contentEncryptionAlgorithm": '+u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id)}):f.unwrapKey("raw",u.recipientInfos[t].value.recipientEncryptedKeys.encryptedKeys[0].encryptedKey.value_block.value_hex,i,{name:"AES-KW"},r,!0,["decrypt"])},function(n){return new Promise(function(t,i){i(n)})})}function h(t){var i=Promise.resolve();return i=i.then(function(){if("recipientPrivateKey"in e==!1)return new Promise(function(n,t){t('Parameter "recipientPrivateKey" is mandatory for "KeyTransRecipientInfo"')});var o=u.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_params,i=new n.org.pkijs.simpl.x509.RSAES_OAEP_params({schema:o}),r=n.org.pkijs.getAlgorithmByOID(i.hashAlgorithm.algorithm_id);return"name"in r==!1?new Promise(function(n,t){t("Incorrect OID for hash algorithm: "+i.hashAlgorithm.algorithm_id)}):f.importKey("pkcs8",e.recipientPrivateKey,{name:"RSA-OAEP",hash:{name:r.name}},!0,["decrypt"])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(n){return f.decrypt({name:"RSA-OAEP"},n,u.recipientInfos[t].value.encryptedKey.value_block.value_hex)},function(n){return new Promise(function(t,i){i(n)})}),i.then(function(t){var i=n.org.pkijs.getAlgorithmByOID(u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id);return"name"in i==!1?new Promise(function(n,t){t('Incorrect "contentEncryptionAlgorithm": '+u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id)}):f.importKey("raw",t,i,!0,["decrypt"])},function(n){return new Promise(function(t,i){i(n)})})}function c(t){var r=Promise.resolve(),i;return r=r.then(function(){return"preDefinedData"in e==!1?new Promise(function(n,t){t('Parameter "preDefinedData" is mandatory for "KEKRecipientInfo"')}):(i=n.org.pkijs.getAlgorithmByOID(u.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id),"name"in i==!1)?new Promise(function(n,i){i('Incorrect OID for "keyEncryptionAlgorithm": '+u.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id)}):f.importKey("raw",e.preDefinedData,i,!0,["unwrapKey"])},function(n){return new Promise(function(t,i){i(n)})}),r.then(function(r){var e=n.org.pkijs.getAlgorithmByOID(u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id);return"name"in e==!1?new Promise(function(n,t){t('Incorrect "contentEncryptionAlgorithm": '+u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id)}):f.unwrapKey("raw",u.recipientInfos[t].value.encryptedKey.value_block.value_hex,r,i,e,!0,["decrypt"])},function(n){return new Promise(function(t,i){i(n)})})}function l(t){var i=Promise.resolve(),r,o;return i=i.then(function(){if("preDefinedData"in e==!1)return new Promise(function(n,t){t('Parameter "preDefinedData" is mandatory for "KEKRecipientInfo"')});if("keyDerivationAlgorithm"in u.recipientInfos[t].value==!1)return new Promise(function(n,t){t('Please append encoded "keyDerivationAlgorithm"')});if("algorithm_params"in u.recipientInfos[t].value.keyDerivationAlgorithm==!1)return new Promise(function(n,t){t('Incorrectly encoded "keyDerivationAlgorithm"')});try{r=new n.org.pkijs.simpl.cms.PBKDF2_params({schema:u.recipientInfos[t].value.keyDerivationAlgorithm.algorithm_params})}catch(i){return new Promise(function(n,t){t('Incorrectly encoded "keyDerivationAlgorithm"')})}return f.importKey("raw",e.preDefinedData,"PBKDF2",!0,["deriveKey"])},function(n){return new Promise(function(t,i){i(n)})}),i=i.then(function(i){var e,s,h,c;if(o=n.org.pkijs.getAlgorithmByOID(u.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id),"name"in o==!1)return new Promise(function(n,i){i('Incorrect OID for "keyEncryptionAlgorithm": '+u.recipientInfos[t].value.keyEncryptionAlgorithm.algorithm_id)});if(e="SHA-1","prf"in r){if(s=n.org.pkijs.getAlgorithmByOID(r.prf.algorithm_id),"name"in s==!1)return new Promise(function(n,t){t("Incorrect OID for HMAC hash algorithm")});e=s.hash.name}return h=new Uint8Array(r.salt.value_block.value_hex),c=r.iterationCount,f.deriveKey({name:"PBKDF2",hash:{name:e},salt:h,iterations:c},i,o,!0,["unwrapKey"])},function(n){return new Promise(function(t,i){i(n)})}),i.then(function(i){var r=n.org.pkijs.getAlgorithmByOID(u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id);return"name"in r==!1?new Promise(function(n,t){t('Incorrect "contentEncryptionAlgorithm": '+u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id)}):f.unwrapKey("raw",u.recipientInfos[t].value.encryptedKey.value_block.value_hex,i,o,r,!0,["decrypt"])},function(n){return new Promise(function(t,i){i(n)})})}var u=this,o=Promise.resolve(),e=r||{},f;return t+1>this.recipientInfos.length?new Promise(function(n,t){t('Maximum value for "index" is: '+(this.recipientInfos.length-1))}):(f=n.org.pkijs.getCrypto(),typeof f=="undefined")?new Promise(function(n,t){t("Unable to create WebCrypto object")}):(o=o.then(function(){var n=Promise.resolve();switch(u.recipientInfos[t].variant){case 1:n=h(t);break;case 2:n=s(t);break;case 3:n=c(t);break;case 4:n=l(t);break;default:return new Promise(function(n,t){t("Uknown recipient type in array with index "+i)})}return n},function(n){return new Promise(function(t,i){i(n)})}),o.then(function(t){var e=n.org.pkijs.getAlgorithmByOID(u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id),r;if("name"in e==!1)return new Promise(function(n,t){t('Incorrect "contentEncryptionAlgorithm": '+u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_id)});var o=u.encryptedContentInfo.contentEncryptionAlgorithm.algorithm_params.value_block.value_hex,s=new Uint8Array(o),i=new ArrayBuffer(0);if(u.encryptedContentInfo.encryptedContent.id_block.is_constructed===!1)i=u.encryptedContentInfo.encryptedContent.value_block.value_hex;else for(r=0;r<u.encryptedContentInfo.encryptedContent.value_block.value.length;r++)i=n.org.pkijs.concat_buffers(i,u.encryptedContentInfo.encryptedContent.value_block.value[r].value_block.value_hex);return f.decrypt({name:e.name,iv:s},t,i)},function(n){return new Promise(function(t,i){i(n)})}))}}(typeof exports!="undefined"?exports:window);CryptoJS=CryptoJS||function(n,t){var u={},f=u.lib={},o=function(){},i=f.Base={extend:function(n){o.prototype=this;var t=new o;return n&&t.mixIn(n),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var t in n)n.hasOwnProperty(t)&&(this[t]=n[t]);n.hasOwnProperty("toString")&&(this.toString=n.toString)},clone:function(){return this.init.prototype.extend(this)}},r=f.WordArray=i.extend({init:function(n,i){n=this.words=n||[];this.sigBytes=i!=t?i:4*n.length},toString:function(n){return(n||l).stringify(this)},concat:function(n){var i=this.words,r=n.words,u=this.sigBytes,t;if(n=n.sigBytes,this.clamp(),u%4)for(t=0;t<n;t++)i[u+t>>>2]|=(r[t>>>2]>>>24-8*(t%4)&255)<<24-8*((u+t)%4);else if(65535<r.length)for(t=0;t<n;t+=4)i[u+t>>>2]=r[t>>>2];else i.push.apply(i,r);return this.sigBytes+=n,this},clamp:function(){var i=this.words,t=this.sigBytes;i[t>>>2]&=4294967295<<32-8*(t%4);i.length=n.ceil(t/4)},clone:function(){var n=i.clone.call(this);return n.words=this.words.slice(0),n},random:function(t){for(var i=[],u=0;u<t;u+=4)i.push(4294967296*n.random()|0);return new r.init(i,t)}}),e=u.enc={},l=e.Hex={stringify:function(n){var u=n.words,i,t,r;for(n=n.sigBytes,i=[],t=0;t<n;t++)r=u[t>>>2]>>>24-8*(t%4)&255,i.push((r>>>4).toString(16)),i.push((r&15).toString(16));return i.join("")},parse:function(n){for(var i=n.length,u=[],t=0;t<i;t+=2)u[t>>>3]|=parseInt(n.substr(t,2),16)<<24-4*(t%8);return new r.init(u,i/2)}},s=e.Latin1={stringify:function(n){var r=n.words,i,t;for(n=n.sigBytes,i=[],t=0;t<n;t++)i.push(String.fromCharCode(r[t>>>2]>>>24-8*(t%4)&255));return i.join("")},parse:function(n){for(var i=n.length,u=[],t=0;t<i;t++)u[t>>>2]|=(n.charCodeAt(t)&255)<<24-8*(t%4);return new r.init(u,i)}},a=e.Utf8={stringify:function(n){try{return decodeURIComponent(escape(s.stringify(n)))}catch(t){throw Error("Malformed UTF-8 data");}},parse:function(n){return s.parse(unescape(encodeURIComponent(n)))}},h=f.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(n){"string"==typeof n&&(n=a.parse(n));this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(t){var e=this._data,s=e.words,u=e.sigBytes,o=this.blockSize,f=u/(4*o),f=t?n.ceil(f):n.max((f|0)-this._minBufferSize,0),i;if(t=f*o,u=n.min(4*t,u),t){for(i=0;i<t;i+=o)this._doProcessBlock(s,i);i=s.splice(0,t);e.sigBytes-=u}return new r.init(i,u)},clone:function(){var n=i.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0}),c;return f.Hasher=h.extend({cfg:i.extend(),init:function(n){this.cfg=this.cfg.extend(n);this.reset()},reset:function(){h.reset.call(this);this._doReset()},update:function(n){return this._append(n),this._process(),this},finalize:function(n){return n&&this._append(n),this._doFinalize()},blockSize:16,_createHelper:function(n){return function(t,i){return new n.init(i).finalize(t)}},_createHmacHelper:function(n){return function(t,i){return new c.HMAC.init(n,i).finalize(t)}}}),c=u.algo={},u}(Math),function(){var n=CryptoJS,t=n.lib.WordArray;n.enc.Base64={stringify:function(n){var i=n.words,u=n.sigBytes,f=this._map,t,e,r;for(n.clamp(),n=[],t=0;t<u;t+=3)for(e=(i[t>>>2]>>>24-8*(t%4)&255)<<16|(i[t+1>>>2]>>>24-8*((t+1)%4)&255)<<8|i[t+2>>>2]>>>24-8*((t+2)%4)&255,r=0;4>r&&t+.75*r<u;r++)n.push(f.charAt(e>>>6*(3-r)&63));if(i=f.charAt(64))for(;n.length%4;)n.push(i);return n.join("")},parse:function(n){var e=n.length,f=this._map,i=f.charAt(64),o,s;i&&(i=n.indexOf(i),-1!=i&&(e=i));for(var i=[],u=0,r=0;r<e;r++)r%4&&(o=f.indexOf(n.charAt(r-1))<<2*(r%4),s=f.indexOf(n.charAt(r))>>>6-2*(r%4),i[u>>>2]|=(o|s)<<24-8*(u%4),u++);return t.create(i,u)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(n){function i(n,t,i,r,u,f,e){return n=n+(t&i|~t&r)+u+e,(n<<f|n>>>32-f)+t}function r(n,t,i,r,u,f,e){return n=n+(t&r|i&~r)+u+e,(n<<f|n>>>32-f)+t}function u(n,t,i,r,u,f,e){return n=n+(t^i^r)+u+e,(n<<f|n>>>32-f)+t}function f(n,t,i,r,u,f,e){return n=n+(i^(t|~r))+u+e,(n<<f|n>>>32-f)+t}for(var o=CryptoJS,e=o.lib,c=e.WordArray,s=e.Hasher,e=o.algo,t=[],h=0;64>h;h++)t[h]=4294967296*n.abs(n.sin(h+1))|0;e=e.MD5=s.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(n,e){for(var v,a,l=0;16>l;l++)v=e+l,a=n[v],n[v]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;var l=this._hash.words,v=n[e+0],a=n[e+1],y=n[e+2],p=n[e+3],w=n[e+4],b=n[e+5],k=n[e+6],d=n[e+7],g=n[e+8],nt=n[e+9],tt=n[e+10],it=n[e+11],rt=n[e+12],ut=n[e+13],ft=n[e+14],et=n[e+15],o=l[0],s=l[1],h=l[2],c=l[3],o=i(o,s,h,c,v,7,t[0]),c=i(c,o,s,h,a,12,t[1]),h=i(h,c,o,s,y,17,t[2]),s=i(s,h,c,o,p,22,t[3]),o=i(o,s,h,c,w,7,t[4]),c=i(c,o,s,h,b,12,t[5]),h=i(h,c,o,s,k,17,t[6]),s=i(s,h,c,o,d,22,t[7]),o=i(o,s,h,c,g,7,t[8]),c=i(c,o,s,h,nt,12,t[9]),h=i(h,c,o,s,tt,17,t[10]),s=i(s,h,c,o,it,22,t[11]),o=i(o,s,h,c,rt,7,t[12]),c=i(c,o,s,h,ut,12,t[13]),h=i(h,c,o,s,ft,17,t[14]),s=i(s,h,c,o,et,22,t[15]),o=r(o,s,h,c,a,5,t[16]),c=r(c,o,s,h,k,9,t[17]),h=r(h,c,o,s,it,14,t[18]),s=r(s,h,c,o,v,20,t[19]),o=r(o,s,h,c,b,5,t[20]),c=r(c,o,s,h,tt,9,t[21]),h=r(h,c,o,s,et,14,t[22]),s=r(s,h,c,o,w,20,t[23]),o=r(o,s,h,c,nt,5,t[24]),c=r(c,o,s,h,ft,9,t[25]),h=r(h,c,o,s,p,14,t[26]),s=r(s,h,c,o,g,20,t[27]),o=r(o,s,h,c,ut,5,t[28]),c=r(c,o,s,h,y,9,t[29]),h=r(h,c,o,s,d,14,t[30]),s=r(s,h,c,o,rt,20,t[31]),o=u(o,s,h,c,b,4,t[32]),c=u(c,o,s,h,g,11,t[33]),h=u(h,c,o,s,it,16,t[34]),s=u(s,h,c,o,ft,23,t[35]),o=u(o,s,h,c,a,4,t[36]),c=u(c,o,s,h,w,11,t[37]),h=u(h,c,o,s,d,16,t[38]),s=u(s,h,c,o,tt,23,t[39]),o=u(o,s,h,c,ut,4,t[40]),c=u(c,o,s,h,v,11,t[41]),h=u(h,c,o,s,p,16,t[42]),s=u(s,h,c,o,k,23,t[43]),o=u(o,s,h,c,nt,4,t[44]),c=u(c,o,s,h,rt,11,t[45]),h=u(h,c,o,s,et,16,t[46]),s=u(s,h,c,o,y,23,t[47]),o=f(o,s,h,c,v,6,t[48]),c=f(c,o,s,h,d,10,t[49]),h=f(h,c,o,s,ft,15,t[50]),s=f(s,h,c,o,b,21,t[51]),o=f(o,s,h,c,rt,6,t[52]),c=f(c,o,s,h,p,10,t[53]),h=f(h,c,o,s,tt,15,t[54]),s=f(s,h,c,o,a,21,t[55]),o=f(o,s,h,c,g,6,t[56]),c=f(c,o,s,h,et,10,t[57]),h=f(h,c,o,s,k,15,t[58]),s=f(s,h,c,o,ut,21,t[59]),o=f(o,s,h,c,w,6,t[60]),c=f(c,o,s,h,it,10,t[61]),h=f(h,c,o,s,y,15,t[62]),s=f(s,h,c,o,nt,21,t[63]);l[0]=l[0]+o|0;l[1]=l[1]+s|0;l[2]=l[2]+h|0;l[3]=l[3]+c|0},_doFinalize:function(){var u=this._data,r=u.words,t=8*this._nDataBytes,i=8*u.sigBytes,f;for(r[i>>>5]|=128<<24-i%32,f=n.floor(t/4294967296),r[(i+64>>>9<<4)+15]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360,r[(i+64>>>9<<4)+14]=(t<<8|t>>>24)&16711935|(t<<24|t>>>8)&4278255360,u.sigBytes=4*(r.length+1),this._process(),u=this._hash,r=u.words,t=0;4>t;t++)i=r[t],r[t]=(i<<8|i>>>24)&16711935|(i<<24|i>>>8)&4278255360;return u},clone:function(){var n=s.clone.call(this);return n._hash=this._hash.clone(),n}});o.MD5=s._createHelper(e);o.HmacMD5=s._createHmacHelper(e)}(Math),function(){var t=CryptoJS,n=t.lib,i=n.Base,r=n.WordArray,n=t.algo,u=n.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:n.MD5,iterations:1}),init:function(n){this.cfg=this.cfg.extend(n)},compute:function(n,t){for(var i,o,u=this.cfg,f=u.hasher.create(),e=r.create(),h=e.words,s=u.keySize,u=u.iterations;h.length<s;){for(i&&f.update(i),i=f.update(n).finalize(t),f.reset(),o=1;o<u;o++)i=f.finalize(i),f.reset();e.concat(i)}return e.sigBytes=4*s,e}});t.EvpKDF=function(n,t,i){return u.create(i).compute(n,t)}}();CryptoJS.lib.Cipher||function(n){var i=CryptoJS,t=i.lib,f=t.Base,e=t.WordArray,c=t.BufferedBlockAlgorithm,l=i.enc.Base64,y=i.algo.EvpKDF,s=t.Cipher=c.extend({cfg:f.extend(),createEncryptor:function(n,t){return this.create(this._ENC_XFORM_MODE,n,t)},createDecryptor:function(n,t){return this.create(this._DEC_XFORM_MODE,n,t)},init:function(n,t,i){this.cfg=this.cfg.extend(i);this._xformMode=n;this._key=t;this.reset()},reset:function(){c.reset.call(this);this._doReset()},process:function(n){return this._append(n),this._process()},finalize:function(n){return n&&this._append(n),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(n){return{encrypt:function(t,i,r){return("string"==typeof i?v:u).encrypt(n,t,i,r)},decrypt:function(t,i,r){return("string"==typeof i?v:u).decrypt(n,t,i,r)}}}});t.StreamCipher=s.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var o=i.mode={},a=function(t,i,r){var f=this._iv,u;for(f?this._iv=n:f=this._prevBlock,u=0;u<r;u++)t[i+u]^=f[u]},r=(t.BlockCipherMode=f.extend({createEncryptor:function(n,t){return this.Encryptor.create(n,t)},createDecryptor:function(n,t){return this.Decryptor.create(n,t)},init:function(n,t){this._cipher=n;this._iv=t}})).extend();r.Encryptor=r.extend({processBlock:function(n,t){var i=this._cipher,r=i.blockSize;a.call(this,n,t,r);i.encryptBlock(n,t);this._prevBlock=n.slice(t,t+r)}});r.Decryptor=r.extend({processBlock:function(n,t){var i=this._cipher,r=i.blockSize,u=n.slice(t,t+r);i.decryptBlock(n,t);a.call(this,n,t,r);this._prevBlock=u}});o=o.CBC=r;r=(i.pad={}).Pkcs7={pad:function(n,t){for(var i=4*t,i=i-n.sigBytes%i,f=i<<24|i<<16|i<<8|i,r=[],u=0;u<i;u+=4)r.push(f);i=e.create(r,i);n.concat(i)},unpad:function(n){n.sigBytes-=n.words[n.sigBytes-1>>>2]&255}};t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:o,padding:r}),reset:function(){var t;s.reset.call(this);var n=this.cfg,i=n.iv,n=n.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1);this._mode=t.call(n,this,i&&i.words)},_doProcessBlock:function(n,t){this._mode.processBlock(n,t)},_doFinalize:function(){var t=this.cfg.padding,n;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),n=this._process(!0)):(n=this._process(!0),t.unpad(n)),n},blockSize:4});var h=t.CipherParams=f.extend({init:function(n){this.mixIn(n)},toString:function(n){return(n||this.formatter).stringify(this)}}),o=(i.format={}).OpenSSL={stringify:function(n){var t=n.ciphertext;return n=n.salt,(n?e.create([1398893684,1701076831]).concat(n).concat(t):t).toString(l)},parse:function(n){var t,i;return n=l.parse(n),t=n.words,1398893684==t[0]&&1701076831==t[1]&&(i=e.create(t.slice(2,4)),t.splice(0,4),n.sigBytes-=16),h.create({ciphertext:n,salt:i})}},u=t.SerializableCipher=f.extend({cfg:f.extend({format:o}),encrypt:function(n,t,i,r){r=this.cfg.extend(r);var u=n.createEncryptor(i,r);return t=u.finalize(t),u=u.cfg,h.create({ciphertext:t,key:i,iv:u.iv,algorithm:n,mode:u.mode,padding:u.padding,blockSize:n.blockSize,formatter:r.format})},decrypt:function(n,t,i,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n.createDecryptor(i,r).finalize(t.ciphertext)},_parse:function(n,t){return"string"==typeof n?t.parse(n,this):n}}),i=(i.kdf={}).OpenSSL={execute:function(n,t,i,r){return r||(r=e.random(8)),n=y.create({keySize:t+i}).compute(n,r),i=e.create(n.words.slice(t),4*i),n.sigBytes=4*t,h.create({key:n,iv:i,salt:r})}},v=t.PasswordBasedCipher=u.extend({cfg:u.cfg.extend({kdf:i}),encrypt:function(n,t,i,r){return r=this.cfg.extend(r),i=r.kdf.execute(i,n.keySize,n.ivSize),r.iv=i.iv,n=u.encrypt.call(this,n,t,i.key,r),n.mixIn(i),n},decrypt:function(n,t,i,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),i=r.kdf.execute(i,n.keySize,n.ivSize,t.salt),r.iv=i.iv,u.decrypt.call(this,n,t,i.key,r)}})}(),function(){function t(n,t){var i=(this._lBlock>>>n^this._rBlock)&t;this._rBlock^=i;this._lBlock^=i<<n}function i(n,t){var i=(this._rBlock>>>n^this._lBlock)&t;this._lBlock^=i;this._rBlock^=i<<n}var r=CryptoJS,n=r.lib,e=n.WordArray,n=n.BlockCipher,u=r.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{"0":8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{"0":1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{"0":260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{"0":2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{"0":128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{"0":268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{"0":1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{"0":134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],l=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],f=u.DES=n.extend({_doReset:function(){for(var i,u=this._key.words,r=[],n=0;56>n;n++)i=s[n]-1,r[n]=u[i>>>5]>>>31-i%32&1;for(u=this._subKeys=[],i=0;16>i;i++){for(var t=u[i]=[],f=h[i],n=0;24>n;n++)t[n/6|0]|=r[(o[n]-1+f)%28]<<31-n%6,t[4+(n/6|0)]|=r[28+(o[n+24]-1+f)%28]<<31-n%6;for(t[0]=t[0]<<1|t[0]>>>31,n=1;7>n;n++)t[n]>>>=4*(n-1)+3;t[7]=t[7]<<5|t[7]>>>27}for(r=this._invSubKeys=[],n=0;16>n;n++)r[n]=u[15-n]},encryptBlock:function(n,t){this._doCryptBlock(n,t,this._subKeys)},decryptBlock:function(n,t){this._doCryptBlock(n,t,this._invSubKeys)},_doCryptBlock:function(n,r,u){var e;for(this._lBlock=n[r],this._rBlock=n[r+1],t.call(this,4,252645135),t.call(this,16,65535),i.call(this,2,858993459),i.call(this,8,16711935),t.call(this,1,1431655765),e=0;16>e;e++){for(var h=u[e],a=this._lBlock,o=this._rBlock,s=0,f=0;8>f;f++)s|=c[f][((o^h[f])&l[f])>>>0];this._lBlock=o;this._rBlock=a^s}u=this._lBlock;this._lBlock=this._rBlock;this._rBlock=u;t.call(this,1,1431655765);i.call(this,8,16711935);i.call(this,2,858993459);t.call(this,16,65535);t.call(this,4,252645135);n[r]=this._lBlock;n[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=n._createHelper(f);u=u.TripleDES=n.extend({_doReset:function(){var n=this._key.words;this._des1=f.createEncryptor(e.create(n.slice(0,2)));this._des2=f.createEncryptor(e.create(n.slice(2,4)));this._des3=f.createEncryptor(e.create(n.slice(4,6)))},encryptBlock:function(n,t){this._des1.encryptBlock(n,t);this._des2.decryptBlock(n,t);this._des3.encryptBlock(n,t)},decryptBlock:function(n,t){this._des3.decryptBlock(n,t);this._des2.encryptBlock(n,t);this._des1.decryptBlock(n,t)},keySize:6,ivSize:2,blockSize:2});r.TripleDES=n._createHelper(u)}(),function(){if("function"==typeof ArrayBuffer){var n=CryptoJS.lib.WordArray,t=n.init;n.init=function(n){if(n instanceof ArrayBuffer&&(n=new DataView(n)),(n instanceof Int8Array||n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int16Array||n instanceof Uint16Array||n instanceof Int32Array||n instanceof Uint32Array||n instanceof Float32Array||n instanceof Float64Array)&&(n=new DataView(n.buffer)),n instanceof DataView){for(var r=n.byteLength,u=[],i=0;i<r;i++)u[i>>>2]|=n.getUint8(i)<<24-8*(i%4);t.call(this,u,r)}else t.apply(this,arguments)};n.init.prototype=n}}(),function(n){for(var r,a,s,i,f=CryptoJS,t=f.lib,v=t.WordArray,e=t.Hasher,t=f.algo,h=[],c=[],l=function(n){return 4294967296*(n-(n|0))|0},o=2,u=0;64>u;){n:{for(r=o,a=n.sqrt(r),s=2;s<=a;s++)if(!(r%s)){r=!1;break n}r=!0}r&&(8>u&&(h[u]=l(n.pow(o,.5))),c[u]=l(n.pow(o,1/3)),u++);o++}i=[];t=t.SHA256=e.extend({_doReset:function(){this._hash=new v.init(h.slice(0))},_doProcessBlock:function(n,t){for(var o,s,r=this._hash.words,f=r[0],h=r[1],l=r[2],y=r[3],e=r[4],a=r[5],v=r[6],p=r[7],u=0;64>u;u++)16>u?i[u]=n[t+u]|0:(o=i[u-15],s=i[u-2],i[u]=((o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3)+i[u-7]+((s<<15|s>>>17)^(s<<13|s>>>19)^s>>>10)+i[u-16]),o=p+((e<<26|e>>>6)^(e<<21|e>>>11)^(e<<7|e>>>25))+(e&a^~e&v)+c[u]+i[u],s=((f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22))+(f&h^f&l^h&l),p=v,v=a,a=e,e=y+o|0,y=l,l=h,h=f,f=o+s|0;r[0]=r[0]+f|0;r[1]=r[1]+h|0;r[2]=r[2]+l|0;r[3]=r[3]+y|0;r[4]=r[4]+e|0;r[5]=r[5]+a|0;r[6]=r[6]+v|0;r[7]=r[7]+p|0},_doFinalize:function(){var r=this._data,t=r.words,u=8*this._nDataBytes,i=8*r.sigBytes;return t[i>>>5]|=128<<24-i%32,t[(i+64>>>9<<4)+14]=n.floor(u/4294967296),t[(i+64>>>9<<4)+15]=u,r.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var n=e.clone.call(this);return n._hash=this._hash.clone(),n}});f.SHA256=e._createHelper(t);f.HmacSHA256=e._createHmacHelper(t)}(Math),function(n){if(typeof n.org=="undefined")n.org={};else if(typeof n.org!="object")throw new Error("Name org already exists and it's not an object");if(typeof n.org.pkijs=="undefined")n.org.pkijs={};else if(typeof n.org.pkijs!="object")throw new Error("Name org.pkijs already exists and it's not an object but "+typeof n.org.pkijs);if(typeof n.org.pkijs.schema=="undefined")n.org.pkijs.schema={};else if(typeof n.org.pkijs.schema!="object")throw new Error("Name org.pkijs.schema already exists and it's not an object but "+typeof n.org.pkijs.schema);if(typeof n.org.pkijs.schema.pkcs8=="undefined")n.org.pkijs.schema.pkcs8={};else if(typeof n.org.pkijs.schema.pkcs8!="object")throw new Error("Name org.pkijs.schema.pkcs8 already exists and it's not an object but "+typeof n.org.pkijs.schema.pkcs8);n.org.pkijs.schema.pkcs8.ENCRYPTED_PRIVATEKEY_INFO_WP52=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"encryptedPrivateKeyInfo",value:[n.org.pkijs.schema.pkcs8.ENCRYPTIONALGORITHM(t.algorithm||{names:{block_name:t.encryptionAlgorithm||"encryptionAlgorithm"}}),new n.org.pkijs.asn1.OCTETSTRING({name:t.encryptedData||"encryptedData"})]})};n.org.pkijs.schema.pkcs8.ENCRYPTIONALGORITHM=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.encryptionAlgorithm||"algorithm"}),n.org.pkijs.schema.pkcs8.PARAMETERS(t.encryptionAlgorithm||{names:{block_name:t.parameters||""}})]})};n.org.pkijs.schema.pkcs8.PARAMETERS=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[n.org.pkijs.schema.pkcs8.ENCALG_WithPBKDF2_params(t.parameters||{names:{block_name:t.EncAlgWPBKDF2params||""}}),n.org.pkijs.schema.ALGORITHM_IDENTIFIER(t.parameters||{names:{block_name:"encryptionScheme"}})]})};n.org.pkijs.schema.pkcs8.ENCALG_WithPBKDF2_params=function(){var t=n.org.pkijs.getNames(arguments[0]);return new n.org.pkijs.asn1.SEQUENCE({name:t.block_name||"",value:[new n.org.pkijs.asn1.OID({name:t.EncAlgWPBKDF2params||"keyDerivationFunc"}),n.org.pkijs.schema.cms.PBKDF2_params(t.parameters||{names:{block_name:t.keyDevParams||""}})]})}}(typeof exports!="undefined"?exports:window),function(n){if(typeof n.org=="undefined")n.org={};else if(typeof n.org!="object")throw new Error("Name org already exists and it's not an object");if(typeof n.org.pkijs=="undefined")n.org.pkijs={};else if(typeof n.org.pkijs!="object")throw new Error("Name org.pkijs already exists and it's not an object but "+typeof n.org.pkijs);if(typeof n.org.pkijs.simpl=="undefined")n.org.pkijs.simpl={};else if(typeof n.org.pkijs.simpl!="object")throw new Error("Name org.pkijs.simpl already exists and it's not an object but "+typeof n.org.pkijs.simpl);if(typeof n.org.pkijs.simpl.pkcs8=="undefined")n.org.pkijs.simpl.pkcs8={};else if(typeof n.org.pkijs.simpl.pkcs8!="object")throw new Error("Name org.pkijs.simpl.pkcs8 already exists and it's not an object but "+typeof n.org.pkijs.simpl.pkcs8);n.org.pkijs.simpl.pkcs8.ENCRYPTED_PRIVATEKEY_INFO_WP52=function(){this.encryptionAlgorithm=new n.org.pkijs.simpl.pkcs8.ENCRYPTIONALGORITHM;this.encryptedData=new n.org.pkijs.asn1.OCTETSTRING;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.pkcs8.ENCRYPTED_PRIVATEKEY_INFO_WP52.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.encryptionAlgorithm=arguments[0].encryptionAlgorithm||new n.org.pkijs.simpl.pkcs8.ENCRYPTIONALGORITHM,this.encryptedData=arguments[0].encryptedData||new n.org.pkijs.asn1.OCTETSTRING)};n.org.pkijs.simpl.pkcs8.ENCRYPTED_PRIVATEKEY_INFO_WP52.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.pkcs8.ENCRYPTED_PRIVATEKEY_INFO_WP52({names:{encryptionAlgorithm:"encryptionAlgorithm",encryptedData:"encryptedData"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for ENCRYPTED_PRIVATEKEY_INFO_WP52");this.encryptionAlgorithm=new n.org.pkijs.simpl.pkcs8.ENCRYPTIONALGORITHM({schema:i.result.encryptionAlgorithm});this.encryptedData=i.result.encryptedData};n.org.pkijs.simpl.pkcs8.ENCRYPTED_PRIVATEKEY_INFO_WP52.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.encryptionAlgorithm.toSchema(),this.encryptedData]})};n.org.pkijs.simpl.pkcs8.ENCRYPTED_PRIVATEKEY_INFO_WP52.prototype.toJSON=function(){return{encryptionAlgorithm:this.encryptionAlgorithm.toJSON(),encryptedData:this.encryptedData.toJSON()}};n.org.pkijs.simpl.pkcs8.ENCRYPTIONALGORITHM=function(){this.algorithm=new n.org.pkijs.asn1.OID;this.parameters=new n.org.pkijs.simpl.pkcs8.PARAMETERS;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.pkcs8.ENCRYPTIONALGORITHM.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.algorithm=arguments[0].algorithm||new n.org.pkijs.asn1.OID,this.parameters=arguments[0].parameters||n.org.pkijs.simpl.pkcs8.PARAMETERS())};n.org.pkijs.simpl.pkcs8.ENCRYPTIONALGORITHM.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.pkcs8.ENCRYPTIONALGORITHM({names:{algorithm:"algorithm",parameters:"parameters"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for ENCRYPTIONALGORITHM");this.algorithm=i.result.algorithm;this.parameters=new n.org.pkijs.simpl.pkcs8.PARAMETERS({schema:i.result.parameters})};n.org.pkijs.simpl.pkcs8.ENCRYPTIONALGORITHM.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.algorithm.toSchema(),this.parameters.toSchema()]})};n.org.pkijs.simpl.pkcs8.ENCRYPTIONALGORITHM.prototype.toJSON=function(){return{algorithm:this.algorithm.toJSON(),parameters:this.parameters.toJSON()}};n.org.pkijs.simpl.pkcs8.PARAMETERS=function(){this.EncAlgWPBKDF2params=new n.org.pkijs.simpl.pkcs8.ENCALG_WithPBKDF2_params;this.encryptionScheme=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.pkcs8.PARAMETERS.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.EncAlgWPBKDF2params=arguments[0].EncAlgWPBKDF2params||new n.org.pkijs.simpl.pkcs8.ENCALG_WithPBKDF2_params,this.encryptionScheme=arguments[0].encryptionScheme||new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER)};n.org.pkijs.simpl.pkcs8.PARAMETERS.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.pkcs8.PARAMETERS({names:{EncAlgWPBKDF2params:"EncAlgWPBKDF2params",encryptionScheme:"encryptionScheme"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for PARAMETERS");this.EncAlgWPBKDF2params=new n.org.pkijs.simpl.pkcs8.ENCALG_WithPBKDF2_params({schema:i.result.EncAlgWPBKDF2params});this.encryptionScheme=new n.org.pkijs.simpl.ALGORITHM_IDENTIFIER({schema:i.result.encryptionScheme})};n.org.pkijs.simpl.pkcs8.PARAMETERS.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.EncAlgWPBKDF2params.toSchema(),this.encryptionScheme.toSchema()]})};n.org.pkijs.simpl.pkcs8.PARAMETERS.prototype.toJSON=function(){return{EncAlgWPBKDF2params:this.EncAlgWPBKDF2params.toJSON(),encryptionScheme:this.encryptionScheme.toJSON()}};n.org.pkijs.simpl.pkcs8.ENCALG_WithPBKDF2_params=function(){this.keyDerivationFunc=new n.org.pkijs.asn1.OID;this.keyDevParams=new n.org.pkijs.simpl.cms.PBKDF2_params;arguments[0]instanceof Object&&"schema"in arguments[0]?n.org.pkijs.simpl.pkcs8.ENCALG_WithPBKDF2_params.prototype.fromSchema.call(this,arguments[0].schema):arguments[0]instanceof Object&&(this.keyDerivationFunc=arguments[0].keyDerivationFunc||new n.org.pkijs.asn1.OID,this.keyDevParams=arguments[0].keyDevParams||new n.org.pkijs.simpl.cms.PBKDF2_params)};n.org.pkijs.simpl.pkcs8.ENCALG_WithPBKDF2_params.prototype.fromSchema=function(t){var i=n.org.pkijs.compareSchema(t,t,n.org.pkijs.schema.pkcs8.ENCALG_WithPBKDF2_params({names:{keyDerivationFunc:"keyDerivationFunc",keyDevParams:"keyDevParams"}}));if(i.verified===!1)throw new Error("Object's schema was not verified against input data for ENCALG_WithPBKDF2_params");this.keyDerivationFunc=i.result.keyDerivationFunc;this.keyDevParams=new n.org.pkijs.simpl.cms.PBKDF2_params({schema:i.result.keyDevParams})};n.org.pkijs.simpl.pkcs8.ENCALG_WithPBKDF2_params.prototype.toSchema=function(){return new n.org.pkijs.asn1.SEQUENCE({value:[this.keyDerivationFunc.toSchema(),this.keyDevParams.toSchema()]})};n.org.pkijs.simpl.pkcs8.ENCALG_WithPBKDF2_params.prototype.toJSON=function(){return{keyDerivationFunc:this.keyDerivationFunc.toJSON(),keyDevParams:this.keyDevParams.toJSON()}}}(typeof exports!="undefined"?exports:window),function(n,t){typeof define=="function"&&define.amd?define([],t):n.forge=t()}(this,function(){var i,t,n;return function(r){function e(n,t){return nt.call(n,t)}function c(n,t){var o,s,u,e,h,y,c,w,i,l,p,r=t&&t.split("/"),a=f.map,v=a&&a["*"]||{};if(n&&n.charAt(0)===".")if(t){for(r=r.slice(0,r.length-1),n=n.split("/"),h=n.length-1,f.nodeIdCompat&&b.test(n[h])&&(n[h]=n[h].replace(b,"")),n=r.concat(n),i=0;i<n.length;i+=1)if(p=n[i],p===".")n.splice(i,1),i-=1;else if(p===".."){if(i===1&&(n[2]===".."||n[0]===".."))break;i>0&&(n.splice(i-1,2),i-=2)}n=n.join("/")}else n.indexOf("./")===0&&(n=n.substring(2));if((r||v)&&a){for(o=n.split("/"),i=o.length;i>0;i-=1){if(s=o.slice(0,i).join("/"),r)for(l=r.length;l>0;l-=1)if(u=a[r.slice(0,l).join("/")],u&&(u=u[s],u)){e=u;y=i;break}if(e)break;!c&&v&&v[s]&&(c=v[s],w=i)}!e&&c&&(e=c,y=w);e&&(o.splice(0,y,e),n=o.join("/"))}return n}function p(n,t){return function(){return o.apply(r,tt.call(arguments,0).concat([n,t]))}}function k(n){return function(t){return c(t,n)}}function d(n){return function(t){u[n]=t}}function l(n){if(e(h,n)){var t=h[n];delete h[n];y[n]=!0;a.apply(r,t)}if(!e(u,n)&&!e(y,n))throw new Error("No "+n);return u[n]}function w(n){var i,t=n?n.indexOf("!"):-1;return t>-1&&(i=n.substring(0,t),n=n.substring(t+1,n.length)),[i,n]}function g(n){return function(){return f&&f.config&&f.config[n]||{}}}var a,o,v,s,u={},h={},f={},y={},nt=Object.prototype.hasOwnProperty,tt=[].slice,b=/\.js$/;v=function(n,t){var r,u=w(n),i=u[0];return n=u[1],i&&(i=c(i,t),r=l(i)),i?n=r&&r.normalize?r.normalize(n,k(t)):c(n,t):(n=c(n,t),u=w(n),i=u[0],n=u[1],i&&(r=l(i))),{f:i?i+"!"+n:n,n:n,pr:i,p:r}};s={require:function(n){return p(n)},exports:function(n){var t=u[n];return typeof t!="undefined"?t:u[n]={}},module:function(n){return{id:n,uri:"",exports:u[n],config:g(n)}}};a=function(n,t,i,f){var w,o,k,b,c,a=[],g=typeof i,nt;if(f=f||n,g==="undefined"||g==="function"){for(t=!t.length&&i.length?["require","exports","module"]:t,c=0;c<t.length;c+=1)if(b=v(t[c],f),o=b.f,o==="require")a[c]=s.require(n);else if(o==="exports")a[c]=s.exports(n),nt=!0;else if(o==="module")w=a[c]=s.module(n);else if(e(u,o)||e(h,o)||e(y,o))a[c]=l(o);else{if(!b.p)throw new Error(n+" missing "+o);b.p.load(b.n,p(f,!0),d(o),{});a[c]=u[o]}k=i?i.apply(u[n],a):undefined;n&&(w&&w.exports!==r&&w.exports!==u[n]?u[n]=w.exports:k===r&&nt||(u[n]=k))}else n&&(u[n]=i)};i=t=o=function(n,t,i,u,e){if(typeof n=="string")return s[n]?s[n](t):l(v(n,t).f);if(!n.splice){if(f=n,f.deps&&o(f.deps,f.callback),!t)return;t.splice?(n=t,t=i,i=null):n=r}return t=t||function(){},typeof i=="function"&&(i=u,u=e),u?a(r,n,t,i):setTimeout(function(){a(r,n,t,i)},4),o};o.config=function(n){return o(n)};i._defined=u;n=function(n,t,i){t.splice||(i=t,t=[]);e(u,n)||e(h,n)||(h[n]=[n,t,i])};n.amd={jQuery:!0}}(),n("node_modules/almond/almond",function(){}),function(){function u(n){function e(n){var i,r;if(this.data="",this.read=0,typeof n=="string")this.data=n;else if(t.isArrayBuffer(n)||t.isArrayBufferView(n)){i=new Uint8Array(n);try{this.data=String.fromCharCode.apply(null,i)}catch(u){for(r=0;r<i.length;++r)this.putByte(i[r])}}else(n instanceof e||typeof n=="object"&&typeof n.data=="string"&&typeof n.read=="number")&&(this.data=n.data,this.read=n.read);this._constructedStringLength=0}function c(n,i){i=i||{};this.read=i.readOffset||0;this.growSize=i.growSize||1024;var r=t.isArrayBuffer(n),u=t.isArrayBufferView(n);if(r||u){this.data=r?new DataView(n):new DataView(n.buffer,n.byteOffset,n.byteLength);this.write="writeOffset"in i?i.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0));this.write=0;n!==null&&n!==undefined&&this.putBytes(n);"writeOffset"in i&&(this.write=i.writeOffset)}var t=n.util=n.util||{},h,i,r,u;(function(){var i,n,e;if(typeof process!="undefined"&&process.nextTick){t.nextTick=process.nextTick;t.setImmediate=typeof setImmediate=="function"?setImmediate:t.nextTick;return}if(typeof setImmediate=="function"){t.setImmediate=setImmediate;t.nextTick=function(n){return setImmediate(n)};return}if(t.setImmediate=function(n){setTimeout(n,0)},typeof window!="undefined"&&typeof window.postMessage=="function"){i="forge.setImmediate";n=[];t.setImmediate=function(t){n.push(t);n.length===1&&window.postMessage(i,"*")};function o(t){if(t.source===window&&t.data===i){t.stopPropagation();var r=n.slice();n.length=0;r.forEach(function(n){n()})}}window.addEventListener("message",o,!0)}if(typeof MutationObserver!="undefined"){var r=Date.now(),u=!0,f=document.createElement("div"),n=[];new MutationObserver(function(){var t=n.slice();n.length=0;t.forEach(function(n){n()})}).observe(f,{attributes:!0});e=t.setImmediate;t.setImmediate=function(t){Date.now()-r>15?(r=Date.now(),e(t)):(n.push(t),n.length===1&&f.setAttribute("a",u=!u))}}t.nextTick=t.setImmediate})();t.isArray=Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"};t.isArrayBuffer=function(n){return typeof ArrayBuffer!="undefined"&&n instanceof ArrayBuffer};t.isArrayBufferView=function(n){return n&&t.isArrayBuffer(n.buffer)&&n.byteLength!==undefined};t.ByteBuffer=e;t.ByteStringBuffer=e;h=4096;t.ByteStringBuffer.prototype._optimizeConstructedString=function(n){this._constructedStringLength+=n;this._constructedStringLength>h&&(this.data.substr(0,1),this._constructedStringLength=0)};t.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};t.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};t.ByteStringBuffer.prototype.putByte=function(n){return this.putBytes(String.fromCharCode(n))};t.ByteStringBuffer.prototype.fillWithByte=function(n,t){n=String.fromCharCode(n);for(var i=this.data;t>0;)t&1&&(i+=n),t>>>=1,t>0&&(n+=n);return this.data=i,this._optimizeConstructedString(t),this};t.ByteStringBuffer.prototype.putBytes=function(n){return this.data+=n,this._optimizeConstructedString(n.length),this};t.ByteStringBuffer.prototype.putString=function(n){return this.putBytes(t.encodeUtf8(n))};t.ByteStringBuffer.prototype.putInt16=function(n){return this.putBytes(String.fromCharCode(n>>8&255)+String.fromCharCode(n&255))};t.ByteStringBuffer.prototype.putInt24=function(n){return this.putBytes(String.fromCharCode(n>>16&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n&255))};t.ByteStringBuffer.prototype.putInt32=function(n){return this.putBytes(String.fromCharCode(n>>24&255)+String.fromCharCode(n>>16&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n&255))};t.ByteStringBuffer.prototype.putInt16Le=function(n){return this.putBytes(String.fromCharCode(n&255)+String.fromCharCode(n>>8&255))};t.ByteStringBuffer.prototype.putInt24Le=function(n){return this.putBytes(String.fromCharCode(n&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n>>16&255))};t.ByteStringBuffer.prototype.putInt32Le=function(n){return this.putBytes(String.fromCharCode(n&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n>>16&255)+String.fromCharCode(n>>24&255))};t.ByteStringBuffer.prototype.putInt=function(n,t){var i="";do t-=8,i+=String.fromCharCode(n>>t&255);while(t>0);return this.putBytes(i)};t.ByteStringBuffer.prototype.putSignedInt=function(n,t){return n<0&&(n+=2<<t-1),this.putInt(n,t)};t.ByteStringBuffer.prototype.putBuffer=function(n){return this.putBytes(n.getBytes())};t.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};t.ByteStringBuffer.prototype.getInt16=function(){var n=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,n};t.ByteStringBuffer.prototype.getInt24=function(){var n=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,n};t.ByteStringBuffer.prototype.getInt32=function(){var n=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,n};t.ByteStringBuffer.prototype.getInt16Le=function(){var n=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,n};t.ByteStringBuffer.prototype.getInt24Le=function(){var n=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,n};t.ByteStringBuffer.prototype.getInt32Le=function(){var n=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,n};t.ByteStringBuffer.prototype.getInt=function(n){var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),n-=8;while(n>0);return t};t.ByteStringBuffer.prototype.getSignedInt=function(n){var t=this.getInt(n),i=2<<n-2;return t>=i&&(t-=i<<1),t};t.ByteStringBuffer.prototype.getBytes=function(n){var t;return n?(n=Math.min(this.length(),n),t=this.data.slice(this.read,this.read+n),this.read+=n):n===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};t.ByteStringBuffer.prototype.bytes=function(n){return typeof n=="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+n)};t.ByteStringBuffer.prototype.at=function(n){return this.data.charCodeAt(this.read+n)};t.ByteStringBuffer.prototype.setAt=function(n,t){return this.data=this.data.substr(0,this.read+n)+String.fromCharCode(t)+this.data.substr(this.read+n+1),this};t.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};t.ByteStringBuffer.prototype.copy=function(){var n=t.createBuffer(this.data);return n.read=this.read,n};t.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};t.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};t.ByteStringBuffer.prototype.truncate=function(n){var t=Math.max(0,this.length()-n);return this.data=this.data.substr(this.read,t),this.read=0,this};t.ByteStringBuffer.prototype.toHex=function(){for(var t="",i,n=this.read;n<this.data.length;++n)i=this.data.charCodeAt(n),i<16&&(t+="0"),t+=i.toString(16);return t};t.ByteStringBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())};t.DataBuffer=c;t.DataBuffer.prototype.length=function(){return this.write-this.read};t.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};t.DataBuffer.prototype.accommodate=function(n,t){if(this.length()>=n)return this;t=Math.max(t||this.growSize,n);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),i=new Uint8Array(this.length()+t);return i.set(r),this.data=new DataView(i.buffer),this};t.DataBuffer.prototype.putByte=function(n){return this.accommodate(1),this.data.setUint8(this.write++,n),this};t.DataBuffer.prototype.fillWithByte=function(n,t){this.accommodate(t);for(var i=0;i<t;++i)this.data.setUint8(n);return this};t.DataBuffer.prototype.putBytes=function(n,i){var e,r,u,f;if(t.isArrayBufferView(n))return r=new Uint8Array(n.buffer,n.byteOffset,n.byteLength),e=r.byteLength-r.byteOffset,this.accommodate(e),u=new Uint8Array(this.data.buffer,this.write),u.set(r),this.write+=e,this;if(t.isArrayBuffer(n))return r=new Uint8Array(n),this.accommodate(r.byteLength),u=new Uint8Array(this.data.buffer),u.set(r,this.write),this.write+=r.byteLength,this;if(n instanceof t.DataBuffer||typeof n=="object"&&typeof n.read=="number"&&typeof n.write=="number"&&t.isArrayBufferView(n.data))return r=new Uint8Array(n.data.byteLength,n.read,n.length()),this.accommodate(r.byteLength),u=new Uint8Array(n.data.byteLength,this.write),u.set(r),this.write+=r.byteLength,this;if(n instanceof t.ByteStringBuffer&&(n=n.data,i="binary"),i=i||"binary",typeof n=="string"){if(i==="hex")return this.accommodate(Math.ceil(n.length/2)),f=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(n,f,this.write),this;if(i==="base64")return this.accommodate(Math.ceil(n.length/4)*3),f=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(n,f,this.write),this;if(i==="utf8"&&(n=t.encodeUtf8(n),i="binary"),i==="binary"||i==="raw")return this.accommodate(n.length),f=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(f),this;if(i==="utf16")return this.accommodate(n.length*2),f=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(f),this;throw new Error("Invalid encoding: "+i);}throw Error("Invalid parameter: "+n);};t.DataBuffer.prototype.putBuffer=function(n){return this.putBytes(n),n.clear(),this};t.DataBuffer.prototype.putString=function(n){return this.putBytes(n,"utf16")};t.DataBuffer.prototype.putInt16=function(n){return this.accommodate(2),this.data.setInt16(this.write,n),this.write+=2,this};t.DataBuffer.prototype.putInt24=function(n){return this.accommodate(3),this.data.setInt16(this.write,n>>8&65535),this.data.setInt8(this.write,n>>16&255),this.write+=3,this};t.DataBuffer.prototype.putInt32=function(n){return this.accommodate(4),this.data.setInt32(this.write,n),this.write+=4,this};t.DataBuffer.prototype.putInt16Le=function(n){return this.accommodate(2),this.data.setInt16(this.write,n,!0),this.write+=2,this};t.DataBuffer.prototype.putInt24Le=function(n){return this.accommodate(3),this.data.setInt8(this.write,n>>16&255),this.data.setInt16(this.write,n>>8&65535,!0),this.write+=3,this};t.DataBuffer.prototype.putInt32Le=function(n){return this.accommodate(4),this.data.setInt32(this.write,n,!0),this.write+=4,this};t.DataBuffer.prototype.putInt=function(n,t){this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,n>>t&255);while(t>0);return this};t.DataBuffer.prototype.putSignedInt=function(n,t){return this.accommodate(t/8),n<0&&(n+=2<<t-1),this.putInt(n,t)};t.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};t.DataBuffer.prototype.getInt16=function(){var n=this.data.getInt16(this.read);return this.read+=2,n};t.DataBuffer.prototype.getInt24=function(){var n=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,n};t.DataBuffer.prototype.getInt32=function(){var n=this.data.getInt32(this.read);return this.read+=4,n};t.DataBuffer.prototype.getInt16Le=function(){var n=this.data.getInt16(this.read,!0);return this.read+=2,n};t.DataBuffer.prototype.getInt24Le=function(){var n=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,n};t.DataBuffer.prototype.getInt32Le=function(){var n=this.data.getInt32(this.read,!0);return this.read+=4,n};t.DataBuffer.prototype.getInt=function(n){var t=0;do t=(t<<8)+this.data.getInt8(this.read++),n-=8;while(n>0);return t};t.DataBuffer.prototype.getSignedInt=function(n){var t=this.getInt(n),i=2<<n-2;return t>=i&&(t-=i<<1),t};t.DataBuffer.prototype.getBytes=function(n){var t;return n?(n=Math.min(this.length(),n),t=this.data.slice(this.read,this.read+n),this.read+=n):n===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};t.DataBuffer.prototype.bytes=function(n){return typeof n=="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+n)};t.DataBuffer.prototype.at=function(n){return this.data.getUint8(this.read+n)};t.DataBuffer.prototype.setAt=function(n,t){return this.data.setUint8(n,t),this};t.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};t.DataBuffer.prototype.copy=function(){return new t.DataBuffer(this)};t.DataBuffer.prototype.compact=function(){if(this.read>0){var n=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(n.byteLength);t.set(n);this.data=new DataView(t);this.write-=this.read;this.read=0}return this};t.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};t.DataBuffer.prototype.truncate=function(n){return this.write=Math.max(0,this.length()-n),this.read=Math.min(this.read,this.write),this};t.DataBuffer.prototype.toHex=function(){for(var t="",i,n=this.read;n<this.data.byteLength;++n)i=this.data.getUint8(n),i<16&&(t+="0"),t+=i.toString(16);return t};t.DataBuffer.prototype.toString=function(n){var i=new Uint8Array(this.data,this.read,this.length());if(n=n||"utf8",n==="binary"||n==="raw")return t.binary.raw.encode(i);if(n==="hex")return t.binary.hex.encode(i);if(n==="base64")return t.binary.base64.encode(i);if(n==="utf8")return t.text.utf8.decode(i);if(n==="utf16")return t.text.utf16.decode(i);throw new Error("Invalid encoding: "+n);};t.createBuffer=function(n,i){return i=i||"raw",n!==undefined&&i==="utf8"&&(n=t.encodeUtf8(n)),new t.ByteBuffer(n)};t.fillString=function(n,t){for(var i="";t>0;)t&1&&(i+=n),t>>>=1,t>0&&(n+=n);return i};t.xorBytes=function(n,t,i){for(var u="",o="",r="",f=0,e=0;i>0;--i,++f)o=n.charCodeAt(f)^t.charCodeAt(f),e>=10&&(u+=r,r="",e=0),r+=String.fromCharCode(o),++e;return u+=r,u};t.hexToBytes=function(n){var i="",t=0;for(n.length&!0&&(t=1,i+=String.fromCharCode(parseInt(n[0],16)));t<n.length;t+=2)i+=String.fromCharCode(parseInt(n.substr(t,2),16));return i};t.bytesToHex=function(n){return t.createBuffer(n).toHex()};t.int32ToBytes=function(n){return String.fromCharCode(n>>24&255)+String.fromCharCode(n>>16&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n&255)};i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r=[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];t.encode64=function(n,t){for(var r="",o="",s,u,f,e=0;e<n.length;)s=n.charCodeAt(e++),u=n.charCodeAt(e++),f=n.charCodeAt(e++),r+=i.charAt(s>>2),r+=i.charAt((s&3)<<4|u>>4),isNaN(u)?r+="==":(r+=i.charAt((u&15)<<2|f>>6),r+=isNaN(f)?"=":i.charAt(f&63)),t&&r.length>t&&(o+=r.substr(0,t)+"\r\n",r=r.substr(t));return o+=r,o};t.decode64=function(n){n=n.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var i="",o,f,u,e,t=0;t<n.length;)o=r[n.charCodeAt(t++)-43],f=r[n.charCodeAt(t++)-43],u=r[n.charCodeAt(t++)-43],e=r[n.charCodeAt(t++)-43],i+=String.fromCharCode(o<<2|f>>4),u!==64&&(i+=String.fromCharCode((f&15)<<4|u>>2),e!==64&&(i+=String.fromCharCode((u&3)<<6|e)));return i};t.encodeUtf8=function(n){return unescape(encodeURIComponent(n))};t.decodeUtf8=function(n){return decodeURIComponent(escape(n))};t.binary={raw:{},hex:{},base64:{}};t.binary.raw.encode=function(n){return String.fromCharCode.apply(null,n)};t.binary.raw.decode=function(n,t,i){var r=t,f,u;for(r||(r=new Uint8Array(n.length)),i=i||0,f=i,u=0;u<n.length;++u)r[f++]=n.charCodeAt(u);return t?f-i:r};t.binary.hex.encode=t.bytesToHex;t.binary.hex.decode=function(n,t,i){var r=t,u,f;for(r||(r=new Uint8Array(Math.ceil(n.length/2))),i=i||0,u=0,f=i,n.length&1&&(u=1,r[f++]=parseInt(n[0],16));u<n.length;u+=2)r[f++]=parseInt(n.substr(u,2),16);return t?f-i:r};t.binary.base64.encode=function(n,t){for(var r="",o="",s,u,f,e=0;e<n.byteLength;)s=n[e++],u=n[e++],f=n[e++],r+=i.charAt(s>>2),r+=i.charAt((s&3)<<4|u>>4),isNaN(u)?r+="==":(r+=i.charAt((u&15)<<2|f>>6),r+=isNaN(f)?"=":i.charAt(f&63)),t&&r.length>t&&(o+=r.substr(0,t)+"\r\n",r=r.substr(t));return o+=r,o};t.binary.base64.decode=function(n,t,i){var u=t,c,s,o,h,f,e;for(u||(u=new Uint8Array(Math.ceil(n.length/4)*3)),n=n.replace(/[^A-Za-z0-9\+\/\=]/g,""),i=i||0,f=0,e=i;f<n.length;)c=r[n.charCodeAt(f++)-43],s=r[n.charCodeAt(f++)-43],o=r[n.charCodeAt(f++)-43],h=r[n.charCodeAt(f++)-43],u[e++]=c<<2|s>>4,o!==64&&(u[e++]=(s&15)<<4|o>>2,h!==64&&(u[e++]=(o&3)<<6|h));return t?e-i:u.subarray(0,e)};t.text={utf8:{},utf16:{}};t.text.utf8.encode=function(n,i,r){var u,e,f;for(n=t.encodeUtf8(n),u=i,u||(u=new Uint8Array(n.length)),r=r||0,e=r,f=0;f<n.length;++f)u[e++]=n.charCodeAt(f);return i?e-r:u};t.text.utf8.decode=function(n){return t.decodeUtf8(String.fromCharCode.apply(null,n))};t.text.utf16.encode=function(n,t,i){var r=t,e,f,o,u;for(r||(r=new Uint8Array(n.length*2)),e=new Uint16Array(r.buffer),i=i||0,f=i,o=i,u=0;u<n.length;++u)e[o++]=n.charCodeAt(u),f+=2;return t?f-i:r};t.text.utf16.decode=function(n){return String.fromCharCode.apply(null,new Uint16Array(n.buffer))};t.deflate=function(n,i,r){if(i=t.decode64(n.deflate(t.encode64(i)).rval),r){var u=2,f=i.charCodeAt(1);f&32&&(u=6);i=i.substring(u,i.length-4)}return i};t.inflate=function(n,i){var r=n.inflate(t.encode64(i)).rval;return r===null?null:t.decode64(r)};var o=function(n,i,r){var u,f;if(!n)throw new Error("WebStorage not available.");if(r===null?u=n.removeItem(i):(r=t.encode64(JSON.stringify(r)),u=n.setItem(i,r)),typeof u!="undefined"&&u.rval!==!0){f=new Error(u.error.message);throw f.id=u.error.id,f.name=u.error.name,f;}},s=function(n,i){var r,u;if(!n)throw new Error("WebStorage not available.");if(r=n.getItem(i),n.init)if(r.rval===null){if(r.error){u=new Error(r.error.message);throw u.id=r.error.id,u.name=r.error.name,u;}r=null}else r=r.rval;return r!==null&&(r=JSON.parse(t.decode64(r))),r},l=function(n,t,i,r){var u=s(n,t);u===null&&(u={});u[i]=r;o(n,t,u)},a=function(n,t,i){var r=s(n,t);return r!==null&&(r=i in r?r[i]:null),r},v=function(n,t,i){var r=s(n,t),u,f;if(r!==null&&i in r){delete r[i];u=!0;for(f in r){u=!1;break}u&&(r=null);o(n,t,r)}},y=function(n,t){o(n,t,null)},f=function(n,t,i){var f=null,r,u,e,o;typeof i=="undefined"&&(i=["web","flash"]);u=!1;e=null;for(o in i){r=i[o];try{if(r==="flash"||r==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");f=n.apply(this,t);u=r==="flash"}(r==="web"||r==="both")&&(t[0]=localStorage,f=n.apply(this,t),u=!0)}catch(s){e=s}if(u)break}if(!u)throw e;return f};t.setItem=function(n,t,i,r,u){f(l,arguments,u)};t.getItem=function(n,t,i,r){return f(a,arguments,r)};t.removeItem=function(n,t,i,r){f(v,arguments,r)};t.clearItems=function(n,t,i){f(y,arguments,i)};t.parseUrl=function(n){var r=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g,i,t;return r.lastIndex=0,i=r.exec(n),t=i===null?null:{full:n,scheme:i[1],host:i[2],port:i[3],path:i[4]},t&&(t.fullHost=t.host,t.port?t.port!==80&&t.scheme==="http"?t.fullHost+=":"+t.port:t.port!==443&&t.scheme==="https"&&(t.fullHost+=":"+t.port):t.scheme==="http"?t.port=80:t.scheme==="https"&&(t.port=443),t.full=t.scheme+"://"+t.fullHost),t};u=null;t.getQueryVariables=function(n){var i=function(n){for(var u={},r=n.split("&"),f,i,e,t=0;t<r.length;t++)f=r[t].indexOf("="),f>0?(i=r[t].substring(0,f),e=r[t].substring(f+1)):(i=r[t],e=null),i in u||(u[i]=[]),!(i in Object.prototype)&&e!==null&&u[i].push(unescape(e));return u},t;return typeof n=="undefined"?(u===null&&(u=typeof window!="undefined"&&window.location&&window.location.search?i(window.location.search.substring(1)):{}),t=u):t=i(n),t};t.parseFragment=function(n){var u=n,r="",f=n.indexOf("?"),i,e;return f>0&&(u=n.substring(0,f),r=n.substring(f+1)),i=u.split("/"),i.length>0&&i[0]===""&&i.shift(),e=r===""?{}:t.getQueryVariables(r),{pathString:u,queryString:r,path:i,query:e}};t.makeRequest=function(n){var i=t.parseFragment(n),r={path:i.pathString,query:i.queryString,getPath:function(n){return typeof n=="undefined"?i.path:i.path[n]},getQuery:function(n,t){var r;return typeof n=="undefined"?r=i.query:(r=i.query[n],r&&typeof t!="undefined"&&(r=r[t])),r},getQueryLast:function(n,t){var u,i=r.getQuery(n);return u=i?i[i.length-1]:t,u}};return r};t.makeLink=function(n,t,i){n=jQuery.isArray(n)?n.join("/"):n;var r=jQuery.param(t||{});return i=i||"",n+(r.length>0?"?"+r:"")+(i.length>0?"#"+i:"")};t.setPath=function(n,t,i){var u,e,r,f;if(typeof n=="object"&&n!==null)for(u=0,e=t.length;u<e;)r=t[u++],u==e?n[r]=i:(f=r in n,(!f||f&&typeof n[r]!="object"||f&&n[r]===null)&&(n[r]={}),n=n[r])};t.getPath=function(n,t,i){for(var f=0,e=t.length,r=!0,u;r&&f<e&&typeof n=="object"&&n!==null;)u=t[f++],r=u in n,r&&(n=n[u]);return r?n:i};t.deletePath=function(n,t){var r,u,i;if(typeof n=="object"&&n!==null)for(r=0,u=t.length;r<u;)if(i=t[r++],r==u)delete n[i];else{if(!(i in n&&typeof n[i]=="object"&&n[i]!==null))break;n=n[i]}};t.isEmpty=function(n){for(var t in n)if(n.hasOwnProperty(t))return!1;return!0};t.format=function(n){for(var i=/%./g,e,r,o=0,t=[],u=0,f;e=i.exec(n);){r=n.substring(u,i.lastIndex-2);r.length>0&&t.push(r);u=i.lastIndex;f=e[0][1];switch(f){case"s":case"o":o<arguments.length?t.push(arguments[o+++1]):t.push("<?>");break;case"%":t.push("%");break;default:t.push("<%"+f+"?>")}}return t.push(n.substring(u)),t.join("")};t.formatNumber=function(n,t,i,r){var f=n,e=isNaN(t=Math.abs(t))?2:t,h=i===undefined?",":i,s=r===undefined?".":r,c=f<0?"-":"",u=parseInt(f=Math.abs(+f||0).toFixed(e),10)+"",o=u.length>3?u.length%3:0;return c+(o?u.substr(0,o)+s:"")+u.substr(o).replace(/(\d{3})(?=\d)/g,"$1"+s)+(e?h+Math.abs(f-u).toFixed(e).slice(2):"")};t.formatSize=function(n){return n=n>=1073741824?t.formatNumber(n/1073741824,2,".","")+" GiB":n>=1048576?t.formatNumber(n/1048576,2,".","")+" MiB":n>=1024?t.formatNumber(n/1024,0)+" KiB":t.formatNumber(n,0)+" bytes",n};t.bytesFromIP=function(n){return n.indexOf(".")!==-1?t.bytesFromIPv4(n):n.indexOf(":")!==-1?t.bytesFromIPv6(n):null};t.bytesFromIPv4=function(n){var r,i,u;if(n=n.split("."),n.length!==4)return null;for(r=t.createBuffer(),i=0;i<n.length;++i){if(u=parseInt(n[i],10),isNaN(u))return null;r.putByte(u)}return r.getBytes()};t.bytesFromIPv6=function(n){var e=0,u,r,i,f;for(n=n.split(":").filter(function(n){return n.length===0&&++e,!0}),u=(8-n.length+e)*2,r=t.createBuffer(),i=0;i<8;++i){if(!n[i]||n[i].length===0){r.fillWithByte(0,u);u=0;continue}f=t.hexToBytes(n[i]);f.length<2&&r.putByte(0);r.putBytes(f)}return r.getBytes()};t.bytesToIP=function(n){return n.length===4?t.bytesToIPv4(n):n.length===16?t.bytesToIPv6(n):null};t.bytesToIPv4=function(n){var i,t;if(n.length!==4)return null;for(i=[],t=0;t<n.length;++t)i.push(n.charCodeAt(t));return i.join(".")};t.bytesToIPv6=function(n){var o,u,e,s,r;if(n.length!==16)return null;var f=[],i=[],h=0;for(o=0;o<n.length;o+=2){for(u=t.bytesToHex(n[o]+n[o+1]);u[0]==="0"&&u!=="0";)u=u.substr(1);u==="0"&&(e=i[i.length-1],s=f.length,!e||s!==e.end+1?i.push({start:s,end:s}):(e.end=s,e.end-e.start>i[h].end-i[h].start&&(h=i.length-1)));f.push(u)}return i.length>0&&(r=i[h],r.end-r.start>0&&(f.splice(r.start,r.end-r.start+1,""),r.start===0&&f.unshift(""),r.end===7&&f.push(""))),f.join(":")};t.estimateCores=function(n,i){function r(n,o,s){if(o===0){var h=Math.floor(n.reduce(function(n,t){return n+t},0)/n.length);return t.cores=Math.max(1,h),URL.revokeObjectURL(u),i(null,t.cores)}f(s,function(t,i){n.push(e(s,i));r(n,o-1,s)})}function f(n,t){for(var r=[],f=[],e,i=0;i<n;++i)e=new Worker(u),e.addEventListener("message",function(i){if(f.push(i.data),f.length===n){for(var u=0;u<n;++u)r[u].terminate();t(null,f)}}),r.push(e);for(i=0;i<n;++i)r[i].postMessage(i)}function e(n,t){for(var e=[],u,o,r,f,i=0;i<n;++i)for(u=t[i],o=e[i]=[],r=0;r<n;++r)i!==r&&(f=t[r],(u.st>f.st&&u.st<f.et||f.st>u.st&&f.st<u.et)&&o.push(r));return e.reduce(function(n,t){return Math.max(n,t.length)},0)}if(typeof n=="function"&&(i=n,n={}),n=n||{},"cores"in t&&!n.update)return i(null,t.cores);if(typeof navigator!="undefined"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return t.cores=navigator.hardwareConcurrency,i(null,t.cores);if(typeof Worker=="undefined")return t.cores=1,i(null,t.cores);if(typeof Blob=="undefined")return t.cores=2,i(null,t.cores);var u=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(){for(var n=Date.now(),t=n+4;Date.now()<t;);self.postMessage({st:n,et:t})})}.toString(),")()"],{type:"application/javascript"}));r([],5,16)}}var i="util",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/util",["require","module"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){n.cipher=n.cipher||{};n.cipher.algorithms=n.cipher.algorithms||{};n.cipher.createCipher=function(t,i){var r=t;if(typeof r=="string"&&(r=n.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new n.cipher.BlockCipher({algorithm:r,key:i,decrypt:!1})};n.cipher.createDecipher=function(t,i){var r=t;if(typeof r=="string"&&(r=n.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new n.cipher.BlockCipher({algorithm:r,key:i,decrypt:!0})};n.cipher.registerAlgorithm=function(t,i){t=t.toUpperCase();n.cipher.algorithms[t]=i};n.cipher.getAlgorithm=function(t){return t=t.toUpperCase(),t in n.cipher.algorithms?n.cipher.algorithms[t]:null};var t=n.cipher.BlockCipher=function(n){this.algorithm=n.algorithm;this.mode=this.algorithm.mode;this.blockSize=this.mode.blockSize;this._finish=!1;this._input=null;this.output=null;this._op=n.decrypt?this.mode.decrypt:this.mode.encrypt;this._decrypt=n.decrypt;this.algorithm.initialize(n)};t.prototype.start=function(t){var i,r;t=t||{};i={};for(r in t)i[r]=t[r];i.decrypt=this._decrypt;this._finish=!1;this._input=n.util.createBuffer();this.output=t.output||n.util.createBuffer();this.mode.start(i)};t.prototype.update=function(n){for(n&&this._input.putBuffer(n);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};t.prototype.finish=function(n){n&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(t){return n(this.blockSize,t,!1)},this.mode.unpad=function(t){return n(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)?!1:(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t)?!1:this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)?!1:!0)}}var i="cipher",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/cipher",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function i(t){var r,i;if(typeof t=="string"&&(t=n.util.createBuffer(t)),n.util.isArray(t)&&t.length>4)for(r=t,t=n.util.createBuffer(),i=0;i<r.length;++i)t.putByte(r[i]);return n.util.isArray(t)||(t=[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]),t}function r(n){n[n.length-1]=n[n.length-1]+1&4294967295}function u(n){return[n/4294967296|0,n&4294967295]}n.cipher=n.cipher||{};var t=n.cipher.modes=n.cipher.modes||{};t.ecb=function(n){n=n||{};this.name="ECB";this.cipher=n.cipher;this.blockSize=n.blockSize||16;this._ints=this.blockSize/4;this._inBlock=new Array(this._ints);this._outBlock=new Array(this._ints)};t.ecb.prototype.start=function(){};t.ecb.prototype.encrypt=function(n,t,i){var r;if(n.length()<this.blockSize&&!(i&&n.length()>0))return!0;for(r=0;r<this._ints;++r)this._inBlock[r]=n.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])};t.ecb.prototype.decrypt=function(n,t,i){var r;if(n.length()<this.blockSize&&!(i&&n.length()>0))return!0;for(r=0;r<this._ints;++r)this._inBlock[r]=n.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])};t.ecb.prototype.pad=function(n){var t=n.length()===this.blockSize?this.blockSize:this.blockSize-n.length();return n.fillWithByte(t,t),!0};t.ecb.prototype.unpad=function(n,t){if(t.overflow>0)return!1;var r=n.length(),i=n.at(r-1);return i>this.blockSize<<2?!1:(n.truncate(i),!0)};t.cbc=function(n){n=n||{};this.name="CBC";this.cipher=n.cipher;this.blockSize=n.blockSize||16;this._ints=this.blockSize/4;this._inBlock=new Array(this._ints);this._outBlock=new Array(this._ints)};t.cbc.prototype.start=function(n){if(n.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in n))throw new Error("Invalid IV parameter.");this._iv=i(n.iv);this._prev=this._iv.slice(0)}};t.cbc.prototype.encrypt=function(n,t,i){var r;if(n.length()<this.blockSize&&!(i&&n.length()>0))return!0;for(r=0;r<this._ints;++r)this._inBlock[r]=this._prev[r]^n.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),r=0;r<this._ints;++r)t.putInt32(this._outBlock[r]);this._prev=this._outBlock};t.cbc.prototype.decrypt=function(n,t,i){var r;if(n.length()<this.blockSize&&!(i&&n.length()>0))return!0;for(r=0;r<this._ints;++r)this._inBlock[r]=n.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),r=0;r<this._ints;++r)t.putInt32(this._prev[r]^this._outBlock[r]);this._prev=this._inBlock.slice(0)};t.cbc.prototype.pad=function(n){var t=n.length()===this.blockSize?this.blockSize:this.blockSize-n.length();return n.fillWithByte(t,t),!0};t.cbc.prototype.unpad=function(n,t){if(t.overflow>0)return!1;var r=n.length(),i=n.at(r-1);return i>this.blockSize<<2?!1:(n.truncate(i),!0)};t.cfb=function(t){t=t||{};this.name="CFB";this.cipher=t.cipher;this.blockSize=t.blockSize||16;this._ints=this.blockSize/4;this._inBlock=null;this._outBlock=new Array(this._ints);this._partialBlock=new Array(this._ints);this._partialOutput=n.util.createBuffer();this._partialBytes=0};t.cfb.prototype.start=function(n){if(!("iv"in n))throw new Error("Invalid IV parameter.");this._iv=i(n.iv);this._inBlock=this._iv.slice(0);this._partialBytes=0};t.cfb.prototype.encrypt=function(n,t,i){var f=n.length(),u,r;if(f===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&f>=this.blockSize){for(r=0;r<this._ints;++r)this._inBlock[r]=n.getInt32()^this._outBlock[r],t.putInt32(this._inBlock[r]);return}for(u=(this.blockSize-f)%this.blockSize,u>0&&(u=this.blockSize-u),this._partialOutput.clear(),r=0;r<this._ints;++r)this._partialBlock[r]=n.getInt32()^this._outBlock[r],this._partialOutput.putInt32(this._partialBlock[r]);if(u>0)n.read-=this.blockSize;else for(r=0;r<this._ints;++r)this._inBlock[r]=this._partialBlock[r];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),u>0&&!i)return t.putBytes(this._partialOutput.getBytes(u-this._partialBytes)),this._partialBytes=u,!0;t.putBytes(this._partialOutput.getBytes(f-this._partialBytes));this._partialBytes=0};t.cfb.prototype.decrypt=function(n,t,i){var f=n.length(),u,r;if(f===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&f>=this.blockSize){for(r=0;r<this._ints;++r)this._inBlock[r]=n.getInt32(),t.putInt32(this._inBlock[r]^this._outBlock[r]);return}for(u=(this.blockSize-f)%this.blockSize,u>0&&(u=this.blockSize-u),this._partialOutput.clear(),r=0;r<this._ints;++r)this._partialBlock[r]=n.getInt32(),this._partialOutput.putInt32(this._partialBlock[r]^this._outBlock[r]);if(u>0)n.read-=this.blockSize;else for(r=0;r<this._ints;++r)this._inBlock[r]=this._partialBlock[r];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),u>0&&!i)return t.putBytes(this._partialOutput.getBytes(u-this._partialBytes)),this._partialBytes=u,!0;t.putBytes(this._partialOutput.getBytes(f-this._partialBytes));this._partialBytes=0};t.ofb=function(t){t=t||{};this.name="OFB";this.cipher=t.cipher;this.blockSize=t.blockSize||16;this._ints=this.blockSize/4;this._inBlock=null;this._outBlock=new Array(this._ints);this._partialOutput=n.util.createBuffer();this._partialBytes=0};t.ofb.prototype.start=function(n){if(!("iv"in n))throw new Error("Invalid IV parameter.");this._iv=i(n.iv);this._inBlock=this._iv.slice(0);this._partialBytes=0};t.ofb.prototype.encrypt=function(n,t,i){var f=n.length(),u,r;if(n.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&f>=this.blockSize){for(r=0;r<this._ints;++r)t.putInt32(n.getInt32()^this._outBlock[r]),this._inBlock[r]=this._outBlock[r];return}for(u=(this.blockSize-f)%this.blockSize,u>0&&(u=this.blockSize-u),this._partialOutput.clear(),r=0;r<this._ints;++r)this._partialOutput.putInt32(n.getInt32()^this._outBlock[r]);if(u>0)n.read-=this.blockSize;else for(r=0;r<this._ints;++r)this._inBlock[r]=this._outBlock[r];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),u>0&&!i)return t.putBytes(this._partialOutput.getBytes(u-this._partialBytes)),this._partialBytes=u,!0;t.putBytes(this._partialOutput.getBytes(f-this._partialBytes));this._partialBytes=0};t.ofb.prototype.decrypt=t.ofb.prototype.encrypt;t.ctr=function(t){t=t||{};this.name="CTR";this.cipher=t.cipher;this.blockSize=t.blockSize||16;this._ints=this.blockSize/4;this._inBlock=null;this._outBlock=new Array(this._ints);this._partialOutput=n.util.createBuffer();this._partialBytes=0};t.ctr.prototype.start=function(n){if(!("iv"in n))throw new Error("Invalid IV parameter.");this._iv=i(n.iv);this._inBlock=this._iv.slice(0);this._partialBytes=0};t.ctr.prototype.encrypt=function(n,t,i){var e=n.length(),f,u;if(e===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&e>=this.blockSize)for(u=0;u<this._ints;++u)t.putInt32(n.getInt32()^this._outBlock[u]);else{for(f=(this.blockSize-e)%this.blockSize,f>0&&(f=this.blockSize-f),this._partialOutput.clear(),u=0;u<this._ints;++u)this._partialOutput.putInt32(n.getInt32()^this._outBlock[u]);if(f>0&&(n.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!i)return t.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;t.putBytes(this._partialOutput.getBytes(e-this._partialBytes));this._partialBytes=0}r(this._inBlock)};t.ctr.prototype.decrypt=t.ctr.prototype.encrypt;t.gcm=function(t){t=t||{};this.name="GCM";this.cipher=t.cipher;this.blockSize=t.blockSize||16;this._ints=this.blockSize/4;this._inBlock=new Array(this._ints);this._outBlock=new Array(this._ints);this._partialOutput=n.util.createBuffer();this._partialBytes=0;this._R=3774873600};t.gcm.prototype.start=function(t){var f,i,e,o;if(!("iv"in t))throw new Error("Invalid IV parameter.");if(f=n.util.createBuffer(t.iv),this._cipherLength=0,i="additionalData"in t?n.util.createBuffer(t.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in t?t.tagLength:128,this._tag=null,t.decrypt&&(this._tag=n.util.createBuffer(t.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");if(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),e=f.length(),e===12)this._j0=[f.getInt32(),f.getInt32(),f.getInt32(),1];else{for(this._j0=[0,0,0,0];f.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[f.getInt32(),f.getInt32(),f.getInt32(),f.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(u(e*8)))}for(this._inBlock=this._j0.slice(0),r(this._inBlock),this._partialBytes=0,i=n.util.createBuffer(i),this._aDataLength=u(i.length()*8),o=i.length()%this.blockSize,o&&i.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];i.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[i.getInt32(),i.getInt32(),i.getInt32(),i.getInt32()])};t.gcm.prototype.encrypt=function(n,t,i){var e=n.length(),f,o,u;if(e===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&e>=this.blockSize){for(u=0;u<this._ints;++u)t.putInt32(this._outBlock[u]^=n.getInt32());this._cipherLength+=this.blockSize}else{for(f=(this.blockSize-e)%this.blockSize,f>0&&(f=this.blockSize-f),this._partialOutput.clear(),u=0;u<this._ints;++u)this._partialOutput.putInt32(n.getInt32()^this._outBlock[u]);if(f===0||i){for(i?(o=e%this.blockSize,this._cipherLength+=o,this._partialOutput.truncate(this.blockSize-o)):this._cipherLength+=this.blockSize,u=0;u<this._ints;++u)this._outBlock[u]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!i)return n.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;t.putBytes(this._partialOutput.getBytes(e-this._partialBytes));this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock);r(this._inBlock)};t.gcm.prototype.decrypt=function(n,t,i){var f=n.length(),u;if(f<this.blockSize&&!(i&&f>0))return!0;for(this.cipher.encrypt(this._inBlock,this._outBlock),r(this._inBlock),this._hashBlock[0]=n.getInt32(),this._hashBlock[1]=n.getInt32(),this._hashBlock[2]=n.getInt32(),this._hashBlock[3]=n.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock),u=0;u<this._ints;++u)t.putInt32(this._outBlock[u]^this._hashBlock[u]);this._cipherLength+=f<this.blockSize?f%this.blockSize:this.blockSize};t.gcm.prototype.afterFinish=function(t,i){var e=!0,o,f,r;for(i.decrypt&&i.overflow&&t.truncate(this.blockSize-i.overflow),this.tag=n.util.createBuffer(),o=this._aDataLength.concat(u(this._cipherLength*8)),this._s=this.ghash(this._hashSubkey,this._s,o),f=[],this.cipher.encrypt(this._j0,f),r=0;r<this._ints;++r)this.tag.putInt32(this._s[r]^f[r]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),i.decrypt&&this.tag.bytes()!==this._tag&&(e=!1),e};t.gcm.prototype.multiply=function(n,t){for(var r=[0,0,0,0],i=t.slice(0),f,u=0;u<128;++u)f=n[u/32|0]&1<<31-u%32,f&&(r[0]^=i[0],r[1]^=i[1],r[2]^=i[2],r[3]^=i[3]),this.pow(i,i);return r};t.gcm.prototype.pow=function(n,t){for(var r=n[3]&1,i=3;i>0;--i)t[i]=n[i]>>>1|(n[i-1]&1)<<31;t[0]=n[0]>>>1;r&&(t[0]^=this._R)};t.gcm.prototype.tableMultiply=function(n){for(var i=[0,0,0,0],t=0;t<32;++t){var u=t/8|0,f=n[u]>>>(7-t%8)*4&15,r=this._m[t][f];i[0]^=r[0];i[1]^=r[1];i[2]^=r[2];i[3]^=r[3]}return i};t.gcm.prototype.ghash=function(n,t,i){return t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3],this.tableMultiply(t)};t.gcm.prototype.generateHashTable=function(n,t){for(var u=8/t,r=4*u,f=16*u,e=new Array(f),i=0;i<f;++i){var o=[0,0,0,0],s=i/r|0,h=(r-1-i%r)*t;o[s]=1<<t-1<<h;e[i]=this.generateSubHashTable(this.multiply(o,n),t)}return e};t.gcm.prototype.generateSubHashTable=function(n,t){var h=1<<t,u=h>>>1,r=new Array(h),i,f,e,o,s;for(r[u]=n.slice(0),i=u>>>1;i>0;)this.pow(r[2*i],r[i]=[]),i>>=1;for(i=2;i<u;){for(f=1;f<i;++f)e=r[i],o=r[f],r[i+f]=[e[0]^o[0],e[1]^o[1],e[2]^o[2],e[3]^o[3]];i*=2}for(r[0]=[0,0,0,0],i=u+1;i<h;++i)s=r[i^u],r[i]=[n[0]^s[0],n[1]^s[1],n[2]^s[2],n[3]^s[3]];return r}}var i="cipherModes",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/cipherModes",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function u(t,i){var r=function(){return new n.aes.Algorithm(t,i)};n.cipher.registerAlgorithm(t,r)}function c(){var u,f,o,c,w,l,e,b,v,y,n,p;for(s=!0,a=[0,1,2,4,8,16,32,64,128,27,54],u=new Array(256),n=0;n<128;++n)u[n]=n<<1,u[n+128]=n+128<<1^283;for(t=new Array(256),h=new Array(256),r=new Array(4),i=new Array(4),n=0;n<4;++n)r[n]=new Array(256),i[n]=new Array(256);for(f=0,o=0,n=0;n<256;++n){for(e=o^o<<1^o<<2^o<<3^o<<4,e=e>>8^e&255^99,t[f]=e,h[e]=f,b=u[e],c=u[f],w=u[c],l=u[w],v=b<<24^e<<16^e<<8^e^b,y=(c^w^l)<<24^(f^l)<<16^(f^w^l)<<8^f^c^l,p=0;p<4;++p)r[p][f]=v,i[p][e]=y,v=v<<24|v>>>8,y=y<<24|y>>>8;f===0?f=o=1:(f=c^u[u[u[c^l]]],o^=u[u[o]])}}function l(n,r){for(var e=n.slice(0),o,p=1,h=e.length,w=h+6+1,l=f*w,s,y,u=h;u<l;++u)o=e[u-1],u%h==0?(o=t[o>>>16&255]<<24^t[o>>>8&255]<<16^t[o&255]<<8^t[o>>>24]^a[p]<<24,p++):h>6&&u%h==4&&(o=t[o>>>24]<<24^t[o>>>16&255]<<16^t[o>>>8&255]<<8^t[o&255]),e[u]=e[u-h]^o;if(r){var v,b=i[0],k=i[1],d=i[2],g=i[3],c=e.slice(0);for(l=e.length,u=0,s=l-f;u<l;u+=f,s-=f)if(u===0||u===l-f)c[u]=e[s],c[u+1]=e[s+3],c[u+2]=e[s+2],c[u+3]=e[s+1];else for(y=0;y<f;++y)v=e[s+y],c[u+(3&-y)]=b[t[v>>>24]]^k[t[v>>>16&255]]^d[t[v>>>8&255]]^g[t[v&255]];e=c}return e}function o(n,u,f,e){var tt=n.length/4-1,y,p,w,b,o,s,c,l,a,d,g,nt,v,k;for(e?(y=i[0],p=i[1],w=i[2],b=i[3],o=h):(y=r[0],p=r[1],w=r[2],b=r[3],o=t),s=u[0]^n[0],c=u[e?3:1]^n[1],l=u[2]^n[2],a=u[e?1:3]^n[3],v=3,k=1;k<tt;++k)d=y[s>>>24]^p[c>>>16&255]^w[l>>>8&255]^b[a&255]^n[++v],g=y[c>>>24]^p[l>>>16&255]^w[a>>>8&255]^b[s&255]^n[++v],nt=y[l>>>24]^p[a>>>16&255]^w[s>>>8&255]^b[c&255]^n[++v],a=y[a>>>24]^p[s>>>16&255]^w[c>>>8&255]^b[l&255]^n[++v],s=d,c=g,l=nt;f[0]=o[s>>>24]<<24^o[c>>>16&255]<<16^o[l>>>8&255]<<8^o[a&255]^n[++v];f[e?3:1]=o[c>>>24]<<24^o[l>>>16&255]<<16^o[a>>>8&255]<<8^o[s&255]^n[++v];f[2]=o[l>>>24]<<24^o[a>>>16&255]<<16^o[s>>>8&255]<<8^o[c&255]^n[++v];f[e?1:3]=o[a>>>24]<<24^o[s>>>16&255]<<16^o[c>>>8&255]<<8^o[l&255]^n[++v]}function e(t){var u,r,i,f;return t=t||{},u=(t.mode||"CBC").toUpperCase(),r="AES-"+u,i=t.decrypt?n.cipher.createDecipher(r,t.key):n.cipher.createCipher(r,t.key),f=i.start,i.start=function(t,r){var u=null;r instanceof n.util.ByteBuffer&&(u=r,r={});r=r||{};r.output=u;r.iv=t;f.call(i,r)},i}n.aes=n.aes||{};n.aes.startEncrypting=function(n,t,i,r){var u=e({key:n,output:i,decrypt:!1,mode:r});return u.start(t),u};n.aes.createEncryptionCipher=function(n,t){return e({key:n,output:null,decrypt:!1,mode:t})};n.aes.startDecrypting=function(n,t,i,r){var u=e({key:n,output:i,decrypt:!0,mode:r});return u.start(t),u};n.aes.createDecryptionCipher=function(n,t){return e({key:n,output:null,decrypt:!0,mode:t})};n.aes.Algorithm=function(n,t){s||c();var i=this;i.name=n;i.mode=new t({blockSize:16,cipher:{encrypt:function(n,t){return o(i._w,n,t,!1)},decrypt:function(n,t){return o(i._w,n,t,!0)}}});i._init=!1};n.aes.Algorithm.prototype.initialize=function(t){var i,u,f,r,e,o;if(!this._init){if(i=t.key,typeof i!="string"||i.length!==16&&i.length!==24&&i.length!==32){if(n.util.isArray(i)&&(i.length===16||i.length===24||i.length===32))for(u=i,i=n.util.createBuffer(),r=0;r<u.length;++r)i.putByte(u[r])}else i=n.util.createBuffer(i);if(!n.util.isArray(i)&&(u=i,i=[],f=u.length(),f===16||f===24||f===32))for(f>>>=2,r=0;r<f;++r)i.push(u.getInt32());if(!n.util.isArray(i)||i.length!==4&&i.length!==6&&i.length!==8)throw new Error("Invalid key parameter.");e=this.mode.name;o=["CFB","OFB","CTR","GCM"].indexOf(e)!==-1;this._w=l(i,t.decrypt&&!o);this._init=!0}};n.aes._expandKey=function(n,t){return s||c(),l(n,t)};n.aes._updateBlock=o;u("AES-ECB",n.cipher.modes.ecb);u("AES-CBC",n.cipher.modes.cbc);u("AES-CFB",n.cipher.modes.cfb);u("AES-OFB",n.cipher.modes.ofb);u("AES-CTR",n.cipher.modes.ctr);u("AES-GCM",n.cipher.modes.gcm);var s=!1,f=4,t,h,a,r,i}var i="aes",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/aes",["require","module","./cipher","./cipherModes","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){n.pki=n.pki||{};var t=n.pki.oids=n.oids=n.oids||{};t["1.2.840.113549.1.1.1"]="rsaEncryption";t.rsaEncryption="1.2.840.113549.1.1.1";t["1.2.840.113549.1.1.4"]="md5WithRSAEncryption";t.md5WithRSAEncryption="1.2.840.113549.1.1.4";t["1.2.840.113549.1.1.5"]="sha1WithRSAEncryption";t.sha1WithRSAEncryption="1.2.840.113549.1.1.5";t["1.2.840.113549.1.1.7"]="RSAES-OAEP";t["RSAES-OAEP"]="1.2.840.113549.1.1.7";t["1.2.840.113549.1.1.8"]="mgf1";t.mgf1="1.2.840.113549.1.1.8";t["1.2.840.113549.1.1.9"]="pSpecified";t.pSpecified="1.2.840.113549.1.1.9";t["1.2.840.113549.1.1.10"]="RSASSA-PSS";t["RSASSA-PSS"]="1.2.840.113549.1.1.10";t["1.2.840.113549.1.1.11"]="sha256WithRSAEncryption";t.sha256WithRSAEncryption="1.2.840.113549.1.1.11";t["1.2.840.113549.1.1.12"]="sha384WithRSAEncryption";t.sha384WithRSAEncryption="1.2.840.113549.1.1.12";t["1.2.840.113549.1.1.13"]="sha512WithRSAEncryption";t.sha512WithRSAEncryption="1.2.840.113549.1.1.13";t["1.3.14.3.2.7"]="desCBC";t.desCBC="1.3.14.3.2.7";t["1.3.14.3.2.26"]="sha1";t.sha1="1.3.14.3.2.26";t["2.16.840.1.101.3.4.2.1"]="sha256";t.sha256="2.16.840.1.101.3.4.2.1";t["2.16.840.1.101.3.4.2.2"]="sha384";t.sha384="2.16.840.1.101.3.4.2.2";t["2.16.840.1.101.3.4.2.3"]="sha512";t.sha512="2.16.840.1.101.3.4.2.3";t["1.2.840.113549.2.5"]="md5";t.md5="1.2.840.113549.2.5";t["1.2.840.113549.1.7.1"]="data";t.data="1.2.840.113549.1.7.1";t["1.2.840.113549.1.7.2"]="signedData";t.signedData="1.2.840.113549.1.7.2";t["1.2.840.113549.1.7.3"]="envelopedData";t.envelopedData="1.2.840.113549.1.7.3";t["1.2.840.113549.1.7.4"]="signedAndEnvelopedData";t.signedAndEnvelopedData="1.2.840.113549.1.7.4";t["1.2.840.113549.1.7.5"]="digestedData";t.digestedData="1.2.840.113549.1.7.5";t["1.2.840.113549.1.7.6"]="encryptedData";t.encryptedData="1.2.840.113549.1.7.6";t["1.2.840.113549.1.9.1"]="emailAddress";t.emailAddress="1.2.840.113549.1.9.1";t["1.2.840.113549.1.9.2"]="unstructuredName";t.unstructuredName="1.2.840.113549.1.9.2";t["1.2.840.113549.1.9.3"]="contentType";t.contentType="1.2.840.113549.1.9.3";t["1.2.840.113549.1.9.4"]="messageDigest";t.messageDigest="1.2.840.113549.1.9.4";t["1.2.840.113549.1.9.5"]="signingTime";t.signingTime="1.2.840.113549.1.9.5";t["1.2.840.113549.1.9.6"]="counterSignature";t.counterSignature="1.2.840.113549.1.9.6";t["1.2.840.113549.1.9.7"]="challengePassword";t.challengePassword="1.2.840.113549.1.9.7";t["1.2.840.113549.1.9.8"]="unstructuredAddress";t.unstructuredAddress="1.2.840.113549.1.9.8";t["1.2.840.113549.1.9.14"]="extensionRequest";t.extensionRequest="1.2.840.113549.1.9.14";t["1.2.840.113549.1.9.20"]="friendlyName";t.friendlyName="1.2.840.113549.1.9.20";t["1.2.840.113549.1.9.21"]="localKeyId";t.localKeyId="1.2.840.113549.1.9.21";t["1.2.840.113549.1.9.22.1"]="x509Certificate";t.x509Certificate="1.2.840.113549.1.9.22.1";t["1.2.840.113549.1.12.10.1.1"]="keyBag";t.keyBag="1.2.840.113549.1.12.10.1.1";t["1.2.840.113549.1.12.10.1.2"]="pkcs8ShroudedKeyBag";t.pkcs8ShroudedKeyBag="1.2.840.113549.1.12.10.1.2";t["1.2.840.113549.1.12.10.1.3"]="certBag";t.certBag="1.2.840.113549.1.12.10.1.3";t["1.2.840.113549.1.12.10.1.4"]="crlBag";t.crlBag="1.2.840.113549.1.12.10.1.4";t["1.2.840.113549.1.12.10.1.5"]="secretBag";t.secretBag="1.2.840.113549.1.12.10.1.5";t["1.2.840.113549.1.12.10.1.6"]="safeContentsBag";t.safeContentsBag="1.2.840.113549.1.12.10.1.6";t["1.2.840.113549.1.5.13"]="pkcs5PBES2";t.pkcs5PBES2="1.2.840.113549.1.5.13";t["1.2.840.113549.1.5.12"]="pkcs5PBKDF2";t.pkcs5PBKDF2="1.2.840.113549.1.5.12";t["1.2.840.113549.1.12.1.1"]="pbeWithSHAAnd128BitRC4";t.pbeWithSHAAnd128BitRC4="1.2.840.113549.1.12.1.1";t["1.2.840.113549.1.12.1.2"]="pbeWithSHAAnd40BitRC4";t.pbeWithSHAAnd40BitRC4="1.2.840.113549.1.12.1.2";t["1.2.840.113549.1.12.1.3"]="pbeWithSHAAnd3-KeyTripleDES-CBC";t["pbeWithSHAAnd3-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.3";t["1.2.840.113549.1.12.1.4"]="pbeWithSHAAnd2-KeyTripleDES-CBC";t["pbeWithSHAAnd2-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.4";t["1.2.840.113549.1.12.1.5"]="pbeWithSHAAnd128BitRC2-CBC";t["pbeWithSHAAnd128BitRC2-CBC"]="1.2.840.113549.1.12.1.5";t["1.2.840.113549.1.12.1.6"]="pbewithSHAAnd40BitRC2-CBC";t["pbewithSHAAnd40BitRC2-CBC"]="1.2.840.113549.1.12.1.6";t["1.2.840.113549.3.7"]="des-EDE3-CBC";t["des-EDE3-CBC"]="1.2.840.113549.3.7";t["2.16.840.1.101.3.4.1.2"]="aes128-CBC";t["aes128-CBC"]="2.16.840.1.101.3.4.1.2";t["2.16.840.1.101.3.4.1.22"]="aes192-CBC";t["aes192-CBC"]="2.16.840.1.101.3.4.1.22";t["2.16.840.1.101.3.4.1.42"]="aes256-CBC";t["aes256-CBC"]="2.16.840.1.101.3.4.1.42";t["2.5.4.3"]="commonName";t.commonName="2.5.4.3";t["2.5.4.5"]="serialName";t.serialName="2.5.4.5";t["2.5.4.6"]="countryName";t.countryName="2.5.4.6";t["2.5.4.7"]="localityName";t.localityName="2.5.4.7";t["2.5.4.8"]="stateOrProvinceName";t.stateOrProvinceName="2.5.4.8";t["2.5.4.10"]="organizationName";t.organizationName="2.5.4.10";t["2.5.4.11"]="organizationalUnitName";t.organizationalUnitName="2.5.4.11";t["2.16.840.1.113730.1.1"]="nsCertType";t.nsCertType="2.16.840.1.113730.1.1";t["2.5.29.1"]="authorityKeyIdentifier";t["2.5.29.2"]="keyAttributes";t["2.5.29.3"]="certificatePolicies";t["2.5.29.4"]="keyUsageRestriction";t["2.5.29.5"]="policyMapping";t["2.5.29.6"]="subtreesConstraint";t["2.5.29.7"]="subjectAltName";t["2.5.29.8"]="issuerAltName";t["2.5.29.9"]="subjectDirectoryAttributes";t["2.5.29.10"]="basicConstraints";t["2.5.29.11"]="nameConstraints";t["2.5.29.12"]="policyConstraints";t["2.5.29.13"]="basicConstraints";t["2.5.29.14"]="subjectKeyIdentifier";t.subjectKeyIdentifier="2.5.29.14";t["2.5.29.15"]="keyUsage";t.keyUsage="2.5.29.15";t["2.5.29.16"]="privateKeyUsagePeriod";t["2.5.29.17"]="subjectAltName";t.subjectAltName="2.5.29.17";t["2.5.29.18"]="issuerAltName";t.issuerAltName="2.5.29.18";t["2.5.29.19"]="basicConstraints";t.basicConstraints="2.5.29.19";t["2.5.29.20"]="cRLNumber";t["2.5.29.21"]="cRLReason";t["2.5.29.22"]="expirationDate";t["2.5.29.23"]="instructionCode";t["2.5.29.24"]="invalidityDate";t["2.5.29.25"]="cRLDistributionPoints";t["2.5.29.26"]="issuingDistributionPoint";t["2.5.29.27"]="deltaCRLIndicator";t["2.5.29.28"]="issuingDistributionPoint";t["2.5.29.29"]="certificateIssuer";t["2.5.29.30"]="nameConstraints";t["2.5.29.31"]="cRLDistributionPoints";t["2.5.29.32"]="certificatePolicies";t["2.5.29.33"]="policyMappings";t["2.5.29.34"]="policyConstraints";t["2.5.29.35"]="authorityKeyIdentifier";t["2.5.29.36"]="policyConstraints";t["2.5.29.37"]="extKeyUsage";t.extKeyUsage="2.5.29.37";t["2.5.29.46"]="freshestCRL";t["2.5.29.54"]="inhibitAnyPolicy";t["1.3.6.1.5.5.7.3.1"]="serverAuth";t.serverAuth="1.3.6.1.5.5.7.3.1";t["1.3.6.1.5.5.7.3.2"]="clientAuth";t.clientAuth="1.3.6.1.5.5.7.3.2";t["1.3.6.1.5.5.7.3.3"]="codeSigning";t.codeSigning="1.3.6.1.5.5.7.3.3";t["1.3.6.1.5.5.7.3.4"]="emailProtection";t.emailProtection="1.3.6.1.5.5.7.3.4";t["1.3.6.1.5.5.7.3.8"]="timeStamping";t.timeStamping="1.3.6.1.5.5.7.3.8"}var i="oids",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/oids",["require","module"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var t=n.asn1=n.asn1||{},i,r;t.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};t.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};t.create=function(t,i,r,u){var e,f;if(n.util.isArray(u)){for(e=[],f=0;f<u.length;++f)u[f]!==undefined&&e.push(u[f]);u=e}return{tagClass:t,type:i,constructed:r,composed:r||n.util.isArray(u),value:u}};i=t.getBerValueLength=function(n){var t=n.getByte(),i,r;return t===128?undefined:(r=t&128,i=r?n.getInt((t&127)<<3):t,i)};t.fromDer=function(r,u){var e,o,a,h,c,b,v,k,y,p;if(u===undefined&&(u=!0),typeof r=="string"&&(r=n.util.createBuffer(r)),r.length()<2){e=new Error("Too few bytes to parse DER.");throw e.bytes=r.length(),e;}var s=r.getByte(),w=s&192,l=s&31,f=i(r);if(r.length()<f){if(u){e=new Error("Too few bytes to read ASN.1 value.");throw e.detail=r.length()+" < "+f,e;}f=r.length()}if(a=(s&32)==32,h=a,!h&&w===t.Class.UNIVERSAL&&l===t.Type.BITSTRING&&f>1){if(c=r.read,b=r.getByte(),b===0&&(s=r.getByte(),v=s&192,v===t.Class.UNIVERSAL||v===t.Class.CONTEXT_SPECIFIC))try{k=i(r);h=k===f-(r.read-c);h&&(++c,--f)}catch(d){}r.read=c}if(h)if(o=[],f===undefined)for(;;){if(r.bytes(2)===String.fromCharCode(0,0)){r.getBytes(2);break}o.push(t.fromDer(r,u))}else for(y=r.length();f>0;)o.push(t.fromDer(r,u)),f-=y-r.length(),y=r.length();else{if(f===undefined){if(u)throw new Error("Non-constructed ASN.1 object of indefinite length.");f=r.length()}if(l===t.Type.BMPSTRING)for(o="",p=0;p<f;p+=2)o+=String.fromCharCode(r.getInt16());else o=r.getBytes(f)}return t.create(w,l,a,o)};t.toDer=function(i){var f=n.util.createBuffer(),s=i.tagClass|i.type,u=n.util.createBuffer(),o,e,r;if(i.composed)for(i.constructed?s|=32:u.putByte(0),r=0;r<i.value.length;++r)i.value[r]!==undefined&&u.putBuffer(t.toDer(i.value[r]));else if(i.type===t.Type.BMPSTRING)for(r=0;r<i.value.length;++r)u.putInt16(i.value.charCodeAt(r));else u.putBytes(i.value);if(f.putByte(s),u.length()<=127)f.putByte(u.length()&127);else{o=u.length();e="";do e+=String.fromCharCode(o&255),o>>>=8;while(o>0);for(f.putByte(e.length|128),r=e.length-1;r>=0;--r)f.putByte(e.charCodeAt(r))}return f.putBuffer(u),f};t.oidToDer=function(t){var i=t.split("."),o=n.util.createBuffer(),s,r,u,h,f,e;for(o.putByte(40*parseInt(i[0],10)+parseInt(i[1],10)),f=2;f<i.length;++f){s=!0;r=[];u=parseInt(i[f],10);do h=u&127,u>>>=7,s||(h|=128),r.push(h),s=!1;while(u>0);for(e=r.length-1;e>=0;--e)o.putByte(r[e])}return o};t.derToOid=function(t){var u,i,r;for(typeof t=="string"&&(t=n.util.createBuffer(t)),i=t.getByte(),u=Math.floor(i/40)+"."+i%40,r=0;t.length()>0;)i=t.getByte(),r<<=7,i&128?r+=i&127:(u+="."+(r+i),r=0);return u};t.utcTimeToDate=function(n){var t=new Date,u=parseInt(n.substr(0,2),10),i,r;u=u>=50?1900+u:2e3+u;var o=parseInt(n.substr(2,2),10)-1,s=parseInt(n.substr(4,2),10),h=parseInt(n.substr(6,2),10),c=parseInt(n.substr(8,2),10),e=0;if(n.length>11&&(i=n.charAt(10),r=10,i!=="+"&&i!=="-"&&(e=parseInt(n.substr(10,2),10),r+=2)),t.setUTCFullYear(u,o,s),t.setUTCHours(h,c,e,0),r&&(i=n.charAt(r),i==="+"||i==="-")){var l=parseInt(n.substr(r+1,2),10),a=parseInt(n.substr(r+4,2),10),f=l*60+a;f*=6e4;i==="+"?t.setTime(+t-f):t.setTime(+t+f)}return t};t.generalizedTimeToDate=function(n){var t=new Date,o=parseInt(n.substr(0,4),10),s=parseInt(n.substr(4,2),10)-1,h=parseInt(n.substr(6,2),10),c=parseInt(n.substr(8,2),10),l=parseInt(n.substr(10,2),10),a=parseInt(n.substr(12,2),10),f=0,i=0,e=!1,r,u,v,y;return n.charAt(n.length-1)==="Z"&&(e=!0),r=n.length-5,u=n.charAt(r),(u==="+"||u==="-")&&(v=parseInt(n.substr(r+1,2),10),y=parseInt(n.substr(r+4,2),10),i=v*60+y,i*=6e4,u==="+"&&(i*=-1),e=!0),n.charAt(14)==="."&&(f=parseFloat(n.substr(14),10)*1e3),e?(t.setUTCFullYear(o,s,h),t.setUTCHours(c,l,a,f),t.setTime(+t+i)):(t.setFullYear(o,s,h),t.setHours(c,l,a,f)),t};t.dateToUtcTime=function(n){var i,t,r;if(typeof n=="string")return n;for(i="",t=[],t.push((""+n.getUTCFullYear()).substr(2)),t.push(""+(n.getUTCMonth()+1)),t.push(""+n.getUTCDate()),t.push(""+n.getUTCHours()),t.push(""+n.getUTCMinutes()),t.push(""+n.getUTCSeconds()),r=0;r<t.length;++r)t[r].length<2&&(i+="0"),i+=t[r];return i+="Z",i};t.dateToGeneralizedTime=function(n){var i,t,r;if(typeof n=="string")return n;for(i="",t=[],t.push(""+n.getUTCFullYear()),t.push(""+(n.getUTCMonth()+1)),t.push(""+n.getUTCDate()),t.push(""+n.getUTCHours()),t.push(""+n.getUTCMinutes()),t.push(""+n.getUTCSeconds()),r=0;r<t.length;++r)t[r].length<2&&(i+="0"),i+=t[r];return i+="Z",i};t.integerToDer=function(t){var i=n.util.createBuffer(),r;if(t>=-128&&t<128)return i.putSignedInt(t,8);if(t>=-32768&&t<32768)return i.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return i.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return i.putSignedInt(t,32);r=new Error("Integer too large; max is 32-bits.");throw r.integer=t,r;};t.derToInteger=function(t){typeof t=="string"&&(t=n.util.createBuffer(t));var i=t.length()*8;if(i>32)throw new Error("Integer too large; max is 32-bits.");return t.getSignedInt(i)};t.validate=function(i,r,u,f){var e=!1,s,o;if(i.tagClass!==r.tagClass&&typeof r.tagClass!="undefined"||i.type!==r.type&&typeof r.type!="undefined")f&&(i.tagClass!==r.tagClass&&f.push("["+r.name+'] Expected tag class "'+r.tagClass+'", got "'+i.tagClass+'"'),i.type!==r.type&&f.push("["+r.name+'] Expected type "'+r.type+'", got "'+i.type+'"'));else if(i.constructed===r.constructed||typeof r.constructed=="undefined"){if(e=!0,r.value&&n.util.isArray(r.value))for(s=0,o=0;e&&o<r.value.length;++o)e=r.value[o].optional||!1,i.value[s]&&(e=t.validate(i.value[s],r.value[o],u,f),e?++s:r.value[o].optional&&(e=!0)),!e&&f&&f.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+i.value.length+'"');e&&u&&(r.capture&&(u[r.capture]=i.value),r.captureAsn1&&(u[r.captureAsn1]=i))}else f&&f.push("["+r.name+'] Expected constructed "'+r.constructed+'", got "'+i.constructed+'"');return e};r=/[^\\u0000-\\u00ff]/;t.prettyPrint=function(i,u,f){var e="",s,l,h,o,c;for(u=u||0,f=f||2,u>0&&(e+="\n"),s="",o=0;o<u*f;++o)s+=" ";e+=s+"Tag: ";switch(i.tagClass){case t.Class.UNIVERSAL:e+="Universal:";break;case t.Class.APPLICATION:e+="Application:";break;case t.Class.CONTEXT_SPECIFIC:e+="Context-Specific:";break;case t.Class.PRIVATE:e+="Private:"}if(i.tagClass===t.Class.UNIVERSAL){e+=i.type;switch(i.type){case t.Type.NONE:e+=" (None)";break;case t.Type.BOOLEAN:e+=" (Boolean)";break;case t.Type.BITSTRING:e+=" (Bit string)";break;case t.Type.INTEGER:e+=" (Integer)";break;case t.Type.OCTETSTRING:e+=" (Octet string)";break;case t.Type.NULL:e+=" (Null)";break;case t.Type.OID:e+=" (Object Identifier)";break;case t.Type.ODESC:e+=" (Object Descriptor)";break;case t.Type.EXTERNAL:e+=" (External or Instance of)";break;case t.Type.REAL:e+=" (Real)";break;case t.Type.ENUMERATED:e+=" (Enumerated)";break;case t.Type.EMBEDDED:e+=" (Embedded PDV)";break;case t.Type.UTF8:e+=" (UTF8)";break;case t.Type.ROID:e+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:e+=" (Sequence)";break;case t.Type.SET:e+=" (Set)";break;case t.Type.PRINTABLESTRING:e+=" (Printable String)";break;case t.Type.IA5String:e+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:e+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:e+=" (Generalized time)";break;case t.Type.BMPSTRING:e+=" (BMP String)"}}else e+=i.type;if(e+="\n",e+=s+"Constructed: "+i.constructed+"\n",i.composed){for(l=0,h="",o=0;o<i.value.length;++o)i.value[o]!==undefined&&(l+=1,h+=t.prettyPrint(i.value[o],u+1,f),o+1<i.value.length&&(h+=","));e+=s+"Sub values: "+l+h}else if(e+=s+"Value: ",i.type===t.Type.OID&&(c=t.derToOid(i.value),e+=c,n.pki&&n.pki.oids&&c in n.pki.oids&&(e+=" ("+n.pki.oids[c]+") ")),i.type===t.Type.INTEGER)try{e+=t.derToInteger(i.value)}catch(a){e+="0x"+n.util.bytesToHex(i.value)}else i.type===t.Type.OCTETSTRING?(r.test(i.value)||(e+="("+i.value+") "),e+="0x"+n.util.bytesToHex(i.value)):e+=i.type===t.Type.UTF8?n.util.decodeUtf8(i.value):i.type===t.Type.PRINTABLESTRING||i.type===t.Type.IA5String?i.value:r.test(i.value)?"0x"+n.util.bytesToHex(i.value):i.value.length===0?"[null]":i.value;return e}}var i="asn1",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/asn1",["require","module","./util","./oids"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function s(){u=String.fromCharCode(128);u+=n.util.fillString(String.fromCharCode(0),64);r=[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];i=[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];t=new Array(64);for(var f=0;f<64;++f)t[f]=Math.floor(Math.abs(Math.sin(f+1))*4294967296);o=!0}function f(n,u,f){for(var c,a,h,o,s,v,l,e,y=f.length();y>=64;){for(a=n.h0,h=n.h1,o=n.h2,s=n.h3,e=0;e<16;++e)u[e]=f.getInt32Le(),v=s^h&(o^s),c=a+v+t[e]+u[e],l=i[e],a=s,s=o,o=h,h+=c<<l|c>>>32-l;for(;e<32;++e)v=o^s&(h^o),c=a+v+t[e]+u[r[e]],l=i[e],a=s,s=o,o=h,h+=c<<l|c>>>32-l;for(;e<48;++e)v=h^o^s,c=a+v+t[e]+u[r[e]],l=i[e],a=s,s=o,o=h,h+=c<<l|c>>>32-l;for(;e<64;++e)v=o^(h|~s),c=a+v+t[e]+u[r[e]],l=i[e],a=s,s=o,o=h,h+=c<<l|c>>>32-l;n.h0=n.h0+a|0;n.h1=n.h1+h|0;n.h2=n.h2+o|0;n.h3=n.h3+s|0;y-=64}}var e=n.md5=n.md5||{};n.md=n.md||{};n.md.algorithms=n.md.algorithms||{};n.md.md5=n.md.algorithms.md5=e;e.create=function(){o||s();var r=null,i=n.util.createBuffer(),e=new Array(16),t={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return t.start=function(){var f,u;for(t.messageLength=0,t.fullMessageLength=t.messageLength64=[],f=t.messageLengthSize/4,u=0;u<f;++u)t.fullMessageLength.push(0);return i=n.util.createBuffer(),r={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},t},t.start(),t.update=function(u,o){var s,h;for(o==="utf8"&&(u=n.util.encodeUtf8(u)),s=u.length,t.messageLength+=s,s=[s/4294967296>>>0,s>>>0],h=t.fullMessageLength.length-1;h>=0;--h)t.fullMessageLength[h]+=s[1],s[1]=s[0]+(t.fullMessageLength[h]/4294967296>>>0),t.fullMessageLength[h]=t.fullMessageLength[h]>>>0,s[0]=s[1]/4294967296>>>0;return i.putBytes(u),f(r,e,i),(i.read>2048||i.length()===0)&&i.compact(),t},t.digest=function(){var h=n.util.createBuffer(),v,y,l,a,c,o,s;for(h.putBytes(i.bytes()),v=t.fullMessageLength[t.fullMessageLength.length-1]+t.messageLengthSize,y=v&t.blockLength-1,h.putBytes(u.substr(0,t.blockLength-y)),a=0,c=t.fullMessageLength.length-1;c>=0;--c)l=t.fullMessageLength[c]*8+a,a=l/4294967296>>>0,h.putInt32Le(l>>>0);return o={h0:r.h0,h1:r.h1,h2:r.h2,h3:r.h3},f(o,e,h),s=n.util.createBuffer(),s.putInt32Le(o.h0),s.putInt32Le(o.h1),s.putInt32Le(o.h2),s.putInt32Le(o.h3),s},t};var u=null,r=null,i=null,t=null,o=!1}var i="md5",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/md5",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function f(){t=String.fromCharCode(128);t+=n.util.fillString(String.fromCharCode(0),64);i=!0}function r(n,t,i){for(var r,e,f,s,o,h,c,u,l=i.length();l>=64;){for(e=n.h0,f=n.h1,s=n.h2,o=n.h3,h=n.h4,u=0;u<16;++u)r=i.getInt32(),t[u]=r,c=o^f&(s^o),r=(e<<5|e>>>27)+c+h+1518500249+r,h=o,o=s,s=f<<30|f>>>2,f=e,e=r;for(;u<20;++u)r=t[u-3]^t[u-8]^t[u-14]^t[u-16],r=r<<1|r>>>31,t[u]=r,c=o^f&(s^o),r=(e<<5|e>>>27)+c+h+1518500249+r,h=o,o=s,s=f<<30|f>>>2,f=e,e=r;for(;u<32;++u)r=t[u-3]^t[u-8]^t[u-14]^t[u-16],r=r<<1|r>>>31,t[u]=r,c=f^s^o,r=(e<<5|e>>>27)+c+h+1859775393+r,h=o,o=s,s=f<<30|f>>>2,f=e,e=r;for(;u<40;++u)r=t[u-6]^t[u-16]^t[u-28]^t[u-32],r=r<<2|r>>>30,t[u]=r,c=f^s^o,r=(e<<5|e>>>27)+c+h+1859775393+r,h=o,o=s,s=f<<30|f>>>2,f=e,e=r;for(;u<60;++u)r=t[u-6]^t[u-16]^t[u-28]^t[u-32],r=r<<2|r>>>30,t[u]=r,c=f&s|o&(f^s),r=(e<<5|e>>>27)+c+h+2400959708+r,h=o,o=s,s=f<<30|f>>>2,f=e,e=r;for(;u<80;++u)r=t[u-6]^t[u-16]^t[u-28]^t[u-32],r=r<<2|r>>>30,t[u]=r,c=f^s^o,r=(e<<5|e>>>27)+c+h+3395469782+r,h=o,o=s,s=f<<30|f>>>2,f=e,e=r;n.h0=n.h0+e|0;n.h1=n.h1+f|0;n.h2=n.h2+s|0;n.h3=n.h3+o|0;n.h4=n.h4+h|0;l-=64}}var u=n.sha1=n.sha1||{},t,i;n.md=n.md||{};n.md.algorithms=n.md.algorithms||{};n.md.sha1=n.md.algorithms.sha1=u;u.create=function(){i||f();var e=null,o=n.util.createBuffer(),s=new Array(80),u={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return u.start=function(){var i,t;for(u.messageLength=0,u.fullMessageLength=u.messageLength64=[],i=u.messageLengthSize/4,t=0;t<i;++t)u.fullMessageLength.push(0);return o=n.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},u},u.start(),u.update=function(t,i){var f,h;for(i==="utf8"&&(t=n.util.encodeUtf8(t)),f=t.length,u.messageLength+=f,f=[f/4294967296>>>0,f>>>0],h=u.fullMessageLength.length-1;h>=0;--h)u.fullMessageLength[h]+=f[1],f[1]=f[0]+(u.fullMessageLength[h]/4294967296>>>0),u.fullMessageLength[h]=u.fullMessageLength[h]>>>0,f[0]=f[1]/4294967296>>>0;return o.putBytes(t),r(e,s,o),(o.read>2048||o.length()===0)&&o.compact(),u},u.digest=function(){var h=n.util.createBuffer(),v,y,w,a,p,c,l,i,f;for(h.putBytes(o.bytes()),v=u.fullMessageLength[u.fullMessageLength.length-1]+u.messageLengthSize,y=v&u.blockLength-1,h.putBytes(t.substr(0,u.blockLength-y)),w=n.util.createBuffer(),c=u.fullMessageLength[0]*8,l=0;l<u.fullMessageLength.length;++l)a=u.fullMessageLength[l+1]*8,p=a/4294967296>>>0,c+=p,h.putInt32(c>>>0),c=a;return i={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4},r(i,s,h),f=n.util.createBuffer(),f.putInt32(i.h0),f.putInt32(i.h1),f.putInt32(i.h2),f.putInt32(i.h3),f.putInt32(i.h4),f},u};t=null;i=!1}var i="sha1",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/sha1",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function e(){t=String.fromCharCode(128);t+=n.util.fillString(String.fromCharCode(0),64);f=[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];u=!0}function i(n,t,i){for(var e,s,p,w,b,k,r,u,h,l,v,o,a,c,y,d=i.length();d>=64;){for(r=0;r<16;++r)t[r]=i.getInt32();for(;r<64;++r)e=t[r-2],e=(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10,s=t[r-15],s=(s>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,t[r]=e+t[r-7]+s+t[r-16]|0;for(u=n.h0,h=n.h1,l=n.h2,v=n.h3,o=n.h4,a=n.h5,c=n.h6,y=n.h7,r=0;r<64;++r)w=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),b=c^o&(a^c),p=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),k=u&h|l&(u^h),e=y+w+b+f[r]+t[r],s=p+k,y=c,c=a,a=o,o=v+e|0,v=l,l=h,h=u,u=e+s|0;n.h0=n.h0+u|0;n.h1=n.h1+h|0;n.h2=n.h2+l|0;n.h3=n.h3+v|0;n.h4=n.h4+o|0;n.h5=n.h5+a|0;n.h6=n.h6+c|0;n.h7=n.h7+y|0;d-=64}}var r=n.sha256=n.sha256||{};n.md=n.md||{};n.md.algorithms=n.md.algorithms||{};n.md.sha256=n.md.algorithms.sha256=r;r.create=function(){u||e();var f=null,o=n.util.createBuffer(),s=new Array(64),r={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){var i,t;for(r.messageLength=0,r.fullMessageLength=r.messageLength64=[],i=r.messageLengthSize/4,t=0;t<i;++t)r.fullMessageLength.push(0);return o=n.util.createBuffer(),f={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},r},r.start(),r.update=function(t,u){var e,h;for(u==="utf8"&&(t=n.util.encodeUtf8(t)),e=t.length,r.messageLength+=e,e=[e/4294967296>>>0,e>>>0],h=r.fullMessageLength.length-1;h>=0;--h)r.fullMessageLength[h]+=e[1],e[1]=e[0]+(r.fullMessageLength[h]/4294967296>>>0),r.fullMessageLength[h]=r.fullMessageLength[h]>>>0,e[0]=e[1]/4294967296>>>0;return o.putBytes(t),i(f,s,o),(o.read>2048||o.length()===0)&&o.compact(),r},r.digest=function(){var h=n.util.createBuffer(),v,y,w,a,p,c,l,u,e;for(h.putBytes(o.bytes()),v=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,y=v&r.blockLength-1,h.putBytes(t.substr(0,r.blockLength-y)),w=n.util.createBuffer(),c=r.fullMessageLength[0]*8,l=0;l<r.fullMessageLength.length;++l)a=r.fullMessageLength[l+1]*8,p=a/4294967296>>>0,c+=p,h.putInt32(c>>>0),c=a;return u={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4,h5:f.h5,h6:f.h6,h7:f.h7},i(u,s,h),e=n.util.createBuffer(),e.putInt32(u.h0),e.putInt32(u.h1),e.putInt32(u.h2),e.putInt32(u.h3),e.putInt32(u.h4),e.putInt32(u.h5),e.putInt32(u.h6),e.putInt32(u.h7),e},r};var t=null,u=!1,f=null}var i="sha256",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/sha256",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function s(){u=String.fromCharCode(128);u+=n.util.fillString(String.fromCharCode(0),128);f=[[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]];t={};t["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]];t["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]];t["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]];t["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]];o=!0}function e(n,t,i){for(var p,w,nt,tt,ct,lt,at,vt,yt,pt,wt,bt,o,s,l,a,b,k,it,rt,h,c,d,g,v,y,ut,ft,u,e,r,et,ot,st,ht,kt=i.length();kt>=128;){for(u=0;u<16;++u)t[u][0]=i.getInt32()>>>0,t[u][1]=i.getInt32()>>>0;for(;u<80;++u)et=t[u-2],e=et[0],r=et[1],p=((e>>>19|r<<13)^(r>>>29|e<<3)^e>>>6)>>>0,w=((e<<13|r>>>19)^(r<<3|e>>>29)^(e<<26|r>>>6))>>>0,st=t[u-15],e=st[0],r=st[1],nt=((e>>>1|r<<31)^(e>>>8|r<<24)^e>>>7)>>>0,tt=((e<<31|r>>>1)^(e<<24|r>>>8)^(e<<25|r>>>7))>>>0,ot=t[u-7],ht=t[u-16],r=w+ot[1]+tt+ht[1],t[u][0]=p+ot[0]+nt+ht[0]+(r/4294967296>>>0)>>>0,t[u][1]=r>>>0;for(o=n[0][0],s=n[0][1],l=n[1][0],a=n[1][1],b=n[2][0],k=n[2][1],it=n[3][0],rt=n[3][1],h=n[4][0],c=n[4][1],d=n[5][0],g=n[5][1],v=n[6][0],y=n[6][1],ut=n[7][0],ft=n[7][1],u=0;u<80;++u)at=((h>>>14|c<<18)^(h>>>18|c<<14)^(c>>>9|h<<23))>>>0,vt=((h<<18|c>>>14)^(h<<14|c>>>18)^(c<<23|h>>>9))>>>0,yt=(v^h&(d^v))>>>0,pt=(y^c&(g^y))>>>0,ct=((o>>>28|s<<4)^(s>>>2|o<<30)^(s>>>7|o<<25))>>>0,lt=((o<<4|s>>>28)^(s<<30|o>>>2)^(s<<25|o>>>7))>>>0,wt=(o&l|b&(o^l))>>>0,bt=(s&a|k&(s^a))>>>0,r=ft+vt+pt+f[u][1]+t[u][1],p=ut+at+yt+f[u][0]+t[u][0]+(r/4294967296>>>0)>>>0,w=r>>>0,r=lt+bt,nt=ct+wt+(r/4294967296>>>0)>>>0,tt=r>>>0,ut=v,ft=y,v=d,y=g,d=h,g=c,r=rt+w,h=it+p+(r/4294967296>>>0)>>>0,c=r>>>0,it=b,rt=k,b=l,k=a,l=o,a=s,r=w+tt,o=p+nt+(r/4294967296>>>0)>>>0,s=r>>>0;r=n[0][1]+s;n[0][0]=n[0][0]+o+(r/4294967296>>>0)>>>0;n[0][1]=r>>>0;r=n[1][1]+a;n[1][0]=n[1][0]+l+(r/4294967296>>>0)>>>0;n[1][1]=r>>>0;r=n[2][1]+k;n[2][0]=n[2][0]+b+(r/4294967296>>>0)>>>0;n[2][1]=r>>>0;r=n[3][1]+rt;n[3][0]=n[3][0]+it+(r/4294967296>>>0)>>>0;n[3][1]=r>>>0;r=n[4][1]+c;n[4][0]=n[4][0]+h+(r/4294967296>>>0)>>>0;n[4][1]=r>>>0;r=n[5][1]+g;n[5][0]=n[5][0]+d+(r/4294967296>>>0)>>>0;n[5][1]=r>>>0;r=n[6][1]+y;n[6][0]=n[6][0]+v+(r/4294967296>>>0)>>>0;n[6][1]=r>>>0;r=n[7][1]+ft;n[7][0]=n[7][0]+ut+(r/4294967296>>>0)>>>0;n[7][1]=r>>>0;kt-=128}}var i=n.sha512=n.sha512||{},r;n.md=n.md||{};n.md.algorithms=n.md.algorithms||{};n.md.sha512=n.md.algorithms.sha512=i;r=n.sha384=n.sha512.sha384=n.sha512.sha384||{};r.create=function(){return i.create("SHA-384")};n.md.sha384=n.md.algorithms.sha384=r;n.sha512.sha256=n.sha512.sha256||{create:function(){return i.create("SHA-512/256")}};n.md["sha512/256"]=n.md.algorithms["sha512/256"]=n.sha512.sha256;n.sha512.sha224=n.sha512.sha224||{create:function(){return i.create("SHA-512/224")}};n.md["sha512/224"]=n.md.algorithms["sha512/224"]=n.sha512.sha224;i.create=function(i){var c,r;if(o||s(),typeof i=="undefined"&&(i="SHA-512"),i in t){var l=t[i],h=null,f=n.util.createBuffer(),a=new Array(80);for(c=0;c<80;++c)a[c]=new Array(2);return r={algorithm:i.replace("-","").toLowerCase(),blockLength:128,digestLength:64,messageLength:0,fullMessageLength:null,messageLengthSize:16},r.start=function(){var i,t;for(r.messageLength=0,r.fullMessageLength=r.messageLength128=[],i=r.messageLengthSize/4,t=0;t<i;++t)r.fullMessageLength.push(0);for(f=n.util.createBuffer(),h=new Array(l.length),t=0;t<l.length;++t)h[t]=l[t].slice(0);return r},r.start(),r.update=function(t,i){var u,o;for(i==="utf8"&&(t=n.util.encodeUtf8(t)),u=t.length,r.messageLength+=u,u=[u/4294967296>>>0,u>>>0],o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=u[1],u[1]=u[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,u[0]=u[1]/4294967296>>>0;return f.putBytes(t),e(h,a,f),(f.read>2048||f.length()===0)&&f.compact(),r},r.digest=function(){var s=n.util.createBuffer(),p,w,k,v,b,c,o,l,y,t;for(s.putBytes(f.bytes()),p=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,w=p&r.blockLength-1,s.putBytes(u.substr(0,r.blockLength-w)),k=n.util.createBuffer(),c=r.fullMessageLength[0]*8,t=0;t<r.fullMessageLength.length;++t)v=r.fullMessageLength[t+1]*8,b=v/4294967296>>>0,c+=b,s.putInt32(c>>>0),c=v;for(o=new Array(h.length),t=0;t<h.length;++t)o[t]=h[t].slice(0);for(e(o,a,s),l=n.util.createBuffer(),y=i==="SHA-512"?o.length:i==="SHA-384"?o.length-2:o.length-4,t=0;t<y;++t)l.putInt32(o[t][0]),(t!==y-1||i!=="SHA-512/224")&&l.putInt32(o[t][1]);return l},r}throw new Error("Invalid SHA-512 algorithm: "+i);};var u=null,o=!1,f=null,t=null}var i="sha512",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/sha512",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){n.md=n.md||{};n.md.algorithms={md5:n.md5,sha1:n.sha1,sha256:n.sha256};n.md.md5=n.md5;n.md.sha1=n.sha1;n.md.sha256=n.sha256}var i="md",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/md",["require","module","./md5","./sha1","./sha256","./sha512"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var t=n.hmac=n.hmac||{};t.create=function(){var f=null,t=null,i=null,r=null,u={};return u.start=function(u,e){var h,s,o;if(u!==null)if(typeof u=="string"){if(u=u.toLowerCase(),!(u in n.md.algorithms))throw new Error('Unknown hash algorithm "'+u+'"');t=n.md.algorithms[u].create()}else t=u;if(e===null)e=f;else{if(typeof e=="string")e=n.util.createBuffer(e);else if(n.util.isArray(e))for(s=e,e=n.util.createBuffer(),o=0;o<s.length;++o)e.putByte(s[o]);for(h=e.length(),h>t.blockLength&&(t.start(),t.update(e.bytes()),e=t.digest()),i=n.util.createBuffer(),r=n.util.createBuffer(),h=e.length(),o=0;o<h;++o)s=e.at(o),i.putByte(54^s),r.putByte(92^s);if(h<t.blockLength)for(s=t.blockLength-h,o=0;o<s;++o)i.putByte(54),r.putByte(92);f=e;i=i.bytes();r=r.bytes()}t.start();t.update(i)},u.update=function(n){t.update(n)},u.getMac=function(){var n=t.digest().bytes();return t.start(),t.update(r),t.update(n),t.digest()},u.digest=u.getMac,u}}var i="hmac",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/hmac",["require","module","./md","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function t(n){for(var i=n.name+": ",e=[],o=function(n,t){return" "+t},u,r,f,t=0;t<n.values.length;++t)e.push(n.values[t].replace(/^(\S+\r\n)/,o));for(i+=e.join(",")+"\r\n",u=0,r=-1,t=0;t<i.length;++t,++u)u>65&&r!==-1?(f=i[r],f===","?(++r,i=i.substr(0,r)+"\r\n "+i.substr(r)):i=i.substr(0,r)+"\r\n"+f+i.substr(r+1),u=t-r-1,r=-1,++t):(i[t]===" "||i[t]==="\t"||i[t]===",")&&(r=t);return i}function r(n){return n.replace(/^\s+/,"")}var i=n.pem=n.pem||{};i.encode=function(i,r){var u,f,e;if(r=r||{},u="-----BEGIN "+i.type+"-----\r\n",i.procType&&(f={name:"Proc-Type",values:[String(i.procType.version),i.procType.type]},u+=t(f)),i.contentDomain&&(f={name:"Content-Domain",values:[i.contentDomain]},u+=t(f)),i.dekInfo&&(f={name:"DEK-Info",values:[i.dekInfo.algorithm]},i.dekInfo.parameters&&f.values.push(i.dekInfo.parameters),u+=t(f)),i.headers)for(e=0;e<i.headers.length;++e)u+=t(i.headers[e]);return i.procType&&(u+="\r\n"),u+=n.util.encode64(i.body,r.maxline||64)+"\r\n",u+="-----END "+i.type+"-----\r\n",u};i.decode=function(t){for(var l=[],y=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,i,u,s,o,a,h,v,f,e,c;;){if(i=y.exec(t),!i)break;if(u={type:i[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:n.util.decode64(i[3])},l.push(u),i[2]){for(s=i[2].split(/\r?\n/),o=0;i&&o<s.length;){for(a=s[o].replace(/\s+$/,""),h=o+1;h<s.length;++h){if(v=s[h],!/\s/.test(v[0]))break;a+=v;o=h}if(i=a.match(/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/),i){for(f={name:i[1],values:[]},e=i[2].split(","),c=0;c<e.length;++c)f.values.push(r(e[c]));if(u.procType)if(u.contentDomain||f.name!=="Content-Domain")if(u.dekInfo||f.name!=="DEK-Info")u.headers.push(f);else{if(f.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');u.dekInfo={algorithm:e[0],parameters:e[1]||null}}else u.contentDomain=e[0]||"";else{if(f.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(f.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');u.procType={version:e[0],type:e[1]}}}++o}if(u.procType==="ENCRYPTED"&&!u.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".');}}if(l.length===0)throw new Error("Invalid PEM formatted message.");return l}}var i="pem",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pem",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function t(t,i){var r=function(){return new n.des.Algorithm(t,i)};n.cipher.registerAlgorithm(t,r)}function u(n){for(var l=[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],v=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],y=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],p=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],w=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],b=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],k=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],d=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],g=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],nt=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],tt=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],it=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],rt=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],ut=n.length()>8?3:1,f=[],h=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],c=0,r,i,t,u,o,s,e=0;e<ut;e++)for(i=n.getInt32(),t=n.getInt32(),r=(i>>>4^t)&252645135,t^=r,i^=r<<4,r=(t>>>-16^i)&65535,i^=r,t^=r<<-16,r=(i>>>2^t)&858993459,t^=r,i^=r<<2,r=(t>>>-16^i)&65535,i^=r,t^=r<<-16,r=(i>>>1^t)&1431655765,t^=r,i^=r<<1,r=(t>>>8^i)&16711935,i^=r,t^=r<<8,r=(i>>>1^t)&1431655765,t^=r,i^=r<<1,r=i<<8|t>>>20&240,i=t<<24|t<<8&16711680|t>>>8&65280|t>>>24&240,t=r,u=0;u<h.length;++u)h[u]?(i=i<<2|i>>>26,t=t<<2|t>>>26):(i=i<<1|i>>>27,t=t<<1|t>>>27),i&=-15,t&=-15,o=l[i>>>28]|a[i>>>24&15]|v[i>>>20&15]|y[i>>>16&15]|p[i>>>12&15]|w[i>>>8&15]|b[i>>>4&15],s=k[t>>>28]|d[t>>>24&15]|g[t>>>20&15]|nt[t>>>16&15]|tt[t>>>12&15]|it[t>>>8&15]|rt[t>>>4&15],r=(s>>>16^o)&65535,f[c++]=o^r,f[c++]=s^r<<16;return f}function r(n,t,i,r){var g=n.length===32?3:9,d,v,y,u,p,nt,tt,w,b,k;for(d=g===3?r?[30,-2,-2]:[0,32,2]:r?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2],y=t[0],u=t[1],v=(y>>>4^u)&252645135,u^=v,y^=v<<4,v=(y>>>16^u)&65535,u^=v,y^=v<<16,v=(u>>>2^y)&858993459,y^=v,u^=v<<2,v=(u>>>8^y)&16711935,y^=v,u^=v<<8,v=(y>>>1^u)&1431655765,u^=v,y^=v<<1,y=y<<1|y>>>31,u=u<<1|u>>>31,p=0;p<g;p+=3){for(nt=d[p+1],tt=d[p+2],w=d[p];w!=nt;w+=tt)b=u^n[w],k=(u>>>4|u<<28)^n[w+1],v=y,y=u,u=v^(e[b>>>24&63]|s[b>>>16&63]|c[b>>>8&63]|a[b&63]|f[k>>>24&63]|o[k>>>16&63]|h[k>>>8&63]|l[k&63]);v=y;y=u;u=v}y=y>>>1|y<<31;u=u>>>1|u<<31;v=(y>>>1^u)&1431655765;u^=v;y^=v<<1;v=(u>>>8^y)&16711935;y^=v;u^=v<<8;v=(u>>>2^y)&858993459;y^=v;u^=v<<2;v=(y>>>16^u)&65535;u^=v;y^=v<<16;v=(y>>>4^u)&252645135;u^=v;y^=v<<4;i[0]=y;i[1]=u}function i(t){var u,r,i,f;return t=t||{},u=(t.mode||"CBC").toUpperCase(),r="DES-"+u,i=t.decrypt?n.cipher.createDecipher(r,t.key):n.cipher.createCipher(r,t.key),f=i.start,i.start=function(t,r){var u=null;r instanceof n.util.ByteBuffer&&(u=r,r={});r=r||{};r.output=u;r.iv=t;f.call(i,r)},i}n.des=n.des||{};n.des.startEncrypting=function(n,t,r,u){var f=i({key:n,output:r,decrypt:!1,mode:u||(t===null?"ECB":"CBC")});return f.start(t),f};n.des.createEncryptionCipher=function(n,t){return i({key:n,output:null,decrypt:!1,mode:t})};n.des.startDecrypting=function(n,t,r,u){var f=i({key:n,output:r,decrypt:!0,mode:u||(t===null?"ECB":"CBC")});return f.start(t),f};n.des.createDecryptionCipher=function(n,t){return i({key:n,output:null,decrypt:!0,mode:t})};n.des.Algorithm=function(n,t){var i=this;i.name=n;i.mode=new t({blockSize:8,cipher:{encrypt:function(n,t){return r(i._keys,n,t,!1)},decrypt:function(n,t){return r(i._keys,n,t,!0)}}});i._init=!1};n.des.Algorithm.prototype.initialize=function(t){if(!this._init){var i=n.util.createBuffer(t.key);if(this.name.indexOf("3DES")===0&&i.length()!==24)throw new Error("Invalid Triple-DES key size: "+i.length()*8);this._keys=u(i);this._init=!0}};t("DES-ECB",n.cipher.modes.ecb);t("DES-CBC",n.cipher.modes.cbc);t("DES-CFB",n.cipher.modes.cfb);t("DES-OFB",n.cipher.modes.ofb);t("DES-CTR",n.cipher.modes.ctr);t("3DES-ECB",n.cipher.modes.ecb);t("3DES-CBC",n.cipher.modes.cbc);t("3DES-CFB",n.cipher.modes.cfb);t("3DES-OFB",n.cipher.modes.ofb);t("3DES-CTR",n.cipher.modes.ctr);var f=[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],e=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],o=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],s=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],h=[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],c=[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],l=[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],a=[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]}var i="des",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/des",["require","module","./cipher","./cipherModes","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var u=n.pkcs5=n.pkcs5||{},r=typeof process!="undefined"&&process.versions&&process.versions.node,i;r&&!n.disableNativeCode&&(i=t("crypto"));n.pbkdf2=u.pbkdf2=function(t,u,f,e,o,s){function d(){if(c>w)return s(null,b);h.start(null,null);h.update(u);h.update(n.util.int32ToBytes(c));l=y=h.digest().getBytes();p=2;g()}function g(){if(p<=f)return h.start(null,null),h.update(y),v=h.digest().getBytes(),l=n.util.xorBytes(l,v,a),y=v,++p,n.util.setImmediate(g);b+=c<w?l:l.substr(0,nt);++c;d()}var a,k,b,l,v,y,c,p;if(typeof o=="function"&&(s=o,o=null),r&&!n.disableNativeCode&&i.pbkdf2&&(o===null||typeof o!="object")&&(i.pbkdf2Sync.length>4||!o||o==="sha1"))return typeof o!="string"&&(o="sha1"),u=new Buffer(u,"binary"),s?i.pbkdf2Sync.length===4?i.pbkdf2(t,u,f,e,function(n,t){if(n)return s(n);s(null,t.toString("binary"))}):i.pbkdf2(t,u,f,e,o,function(n,t){if(n)return s(n);s(null,t.toString("binary"))}):i.pbkdf2Sync.length===4?i.pbkdf2Sync(t,u,f,e).toString("binary"):i.pbkdf2Sync(t,u,f,e,o).toString("binary");if((typeof o=="undefined"||o===null)&&(o=n.md.sha1.create()),typeof o=="string"){if(!(o in n.md.algorithms))throw new Error("Unknown hash algorithm: "+o);o=n.md[o].create()}if(a=o.digestLength,e>4294967295*a){if(k=new Error("Derived key is too long."),s)return s(k);throw k;}var w=Math.ceil(e/a),nt=e-(w-1)*a,h=n.hmac.create();if(h.start(o,t),b="",!s){for(c=1;c<=w;++c){for(h.start(null,null),h.update(u),h.update(n.util.int32ToBytes(c)),l=y=h.digest().getBytes(),p=2;p<=f;++p)h.start(null,null),h.update(y),v=h.digest().getBytes(),l=n.util.xorBytes(l,v,a),y=v;b+=c<w?l:l.substr(0,nt)}return b}c=1;d()}}var i="pbkdf2",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pbkdf2",["require","module","./hmac","./md","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var u=typeof process!="undefined"&&process.versions&&process.versions.node,i=null,r;n.disableNativeCode||!u||process.versions["node-webkit"]||(i=t("crypto"));r=n.prng=n.prng||{};r.create=function(t){function s(n){if(r.pools[0].messageLength>=32)return u(),n();var t=32-r.pools[0].messageLength<<5;r.seedFile(t,function(t,i){if(t)return n(t);r.collect(i);u();n()})}function h(){if(r.pools[0].messageLength>=32)return u();var n=32-r.pools[0].messageLength<<5;r.collect(r.seedFileSync(n));u()}function u(){var n=r.plugin.md.create(),t,i,u,f;for(n.update(r.pools[0].digest().getBytes()),r.pools[0].start(),t=1,i=1;i<32;++i)t=t===31?2147483648:t<<2,t%r.reseeds==0&&(n.update(r.pools[i].digest().getBytes()),r.pools[i].start());u=n.digest().getBytes();n.start();n.update(u);f=n.digest().getBytes();r.key=r.plugin.formatKey(u);r.seed=r.plugin.formatSeed(f);r.reseeds=r.reseeds===4294967295?0:r.reseeds+1;r.generated=0}function e(t){var s=null,e,r,l,o,h,u,c,f,i;if(typeof window!="undefined"&&(e=window.crypto||window.msCrypto,e&&e.getRandomValues&&(s=function(n){return e.getRandomValues(n)})),r=n.util.createBuffer(),s)while(r.length()<t){l=Math.max(1,Math.min(t-r.length(),65536)/4);o=new Uint32Array(Math.floor(l));try{for(s(o),i=0;i<o.length;++i)r.putInt32(o[i])}catch(a){if(!(typeof QuotaExceededError!="undefined"&&a instanceof QuotaExceededError))throw a;}}if(r.length()<t)for(f=Math.floor(Math.random()*65536);r.length()<t;)for(u=16807*(f&65535),h=16807*(f>>16),u+=(h&32767)<<16,u+=h>>15,u=(u&2147483647)+(u>>31),f=u&4294967295,i=0;i<3;++i)c=f>>>(i<<3),c^=Math.floor(Math.random()*256),r.putByte(String.fromCharCode(c&255));return r.getBytes(t)}for(var r={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0},c=t.md,o=new Array(32),f=0;f<32;++f)o[f]=c.create();return r.pools=o,r.pool=0,r.generate=function(t,i){function u(l){if(l)return i(l);if(e.length()>=t)return i(null,e.getBytes(t));if(r.generated>1048575&&(r.key=null),r.key===null)return n.util.nextTick(function(){s(u)});var a=f(r.key,r.seed);r.generated+=a.length;e.putBytes(a);r.key=h(f(r.key,o(r.seed)));r.seed=c(f(r.key,r.seed));n.util.setImmediate(u)}if(!i)return r.generateSync(t);var f=r.plugin.cipher,o=r.plugin.increment,h=r.plugin.formatKey,c=r.plugin.formatSeed,e=n.util.createBuffer();r.key=null;u()},r.generateSync=function(t){var u=r.plugin.cipher,e=r.plugin.increment,o=r.plugin.formatKey,s=r.plugin.formatSeed,i,f;for(r.key=null,i=n.util.createBuffer();i.length()<t;)r.generated>1048575&&(r.key=null),r.key===null&&h(),f=u(r.key,r.seed),r.generated+=f.length,i.putBytes(f),r.key=o(u(r.key,e(r.seed))),r.seed=s(u(r.key,r.seed));return i.getBytes(t)},i?(r.seedFile=function(n,t){i.randomBytes(n,function(n,i){if(n)return t(n);t(null,i.toString())})},r.seedFileSync=function(n){return i.randomBytes(n).toString()}):(r.seedFile=function(n,t){try{t(null,e(n))}catch(i){t(i)}},r.seedFileSync=e),r.collect=function(n){for(var i=n.length,t=0;t<i;++t)r.pools[r.pool].update(n.substr(t,1)),r.pool=r.pool===31?0:r.pool+1},r.collectInt=function(n,t){for(var u="",i=0;i<t;i+=8)u+=String.fromCharCode(n>>i&255);r.collect(u)},r.registerWorker=function(n){if(n===self)r.seedFile=function(n,t){function i(n){var r=n.data;r.forge&&r.forge.prng&&(self.removeEventListener("message",i),t(r.forge.prng.err,r.forge.prng.bytes))}self.addEventListener("message",i);self.postMessage({forge:{prng:{needed:n}}})};else{var t=function(t){var i=t.data;i.forge&&i.forge.prng&&r.seedFile(i.forge.prng.needed,function(t,i){n.postMessage({forge:{prng:{err:t,bytes:i}}})})};n.addEventListener("message",t)}},r}}var i="prng",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/prng",["require","module","./md","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){n.random&&n.random.getBytes||function(t){function h(){var t=n.prng.create(r);return t.getBytes=function(n,i){return t.generate(n,i)},t.getBytesSync=function(n){return t.generate(n)},t}var r={},f=new Array(4),e=n.util.createBuffer(),o,s,u;r.formatKey=function(t){var i=n.util.createBuffer(t);return t=new Array(4),t[0]=i.getInt32(),t[1]=i.getInt32(),t[2]=i.getInt32(),t[3]=i.getInt32(),n.aes._expandKey(t,!1)};r.formatSeed=function(t){var i=n.util.createBuffer(t);return t=new Array(4),t[0]=i.getInt32(),t[1]=i.getInt32(),t[2]=i.getInt32(),t[3]=i.getInt32(),t};r.cipher=function(t,i){return n.aes._updateBlock(t,i,f,!1),e.putInt32(f[0]),e.putInt32(f[1]),e.putInt32(f[2]),e.putInt32(f[3]),e.getBytes()};r.increment=function(n){return++n[3],n};r.md=n.md.sha256;var i=h(),l=typeof process!="undefined"&&process.versions&&process.versions.node,c=null;if(typeof window!="undefined"&&(o=window.crypto||window.msCrypto,o&&o.getRandomValues&&(c=function(n){return o.getRandomValues(n)})),n.disableNativeCode||!l&&!c){if(typeof window=="undefined"||window.document===undefined,i.collectInt(+new Date,32),typeof navigator!="undefined"){s="";for(u in navigator)try{typeof navigator[u]=="string"&&(s+=navigator[u])}catch(a){}i.collect(s);s=null}t&&(t().mousemove(function(n){i.collectInt(n.clientX,16);i.collectInt(n.clientY,16)}),t().keypress(function(n){i.collectInt(n.charCode,8)}))}if(n.random)for(u in i)n.random[u]=i[u];else n.random=i;n.random.createInstance=h}(typeof jQuery!="undefined"?jQuery:null)}var i="random",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/random",["require","module","./aes","./md","./prng","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var t=[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],r=[1,2,3,5],u=function(n,t){return n<<t&65535|(n&65535)>>16-t},f=function(n,t){return(n&65535)>>t|n<<16-t&65535},i;n.rc2=n.rc2||{};n.rc2.expandKey=function(i,r){typeof i=="string"&&(i=n.util.createBuffer(i));r=r||128;for(var f=i,o=i.length(),s=r,e=Math.ceil(s/8),h=255>>(s&7),u=o;u<128;u++)f.putByte(t[f.at(u-1)+f.at(u-o)&255]);for(f.setAt(128-e,t[f.at(128-e)&h]),u=127-e;u>=0;u--)f.setAt(u,t[f.at(u+1)^f.at(u+e)]);return f};i=function(t,i,e){var w=!1,s=null,h=null,c=null,l,p,o,a,v=[],b,y;for(t=n.rc2.expandKey(t,i),o=0;o<64;o++)v.push(t.getInt16Le());return e?(l=function(n){for(o=0;o<4;o++)n[o]+=v[a]+(n[(o+3)%4]&n[(o+2)%4])+(~n[(o+3)%4]&n[(o+1)%4]),n[o]=u(n[o],r[o]),a++},p=function(n){for(o=0;o<4;o++)n[o]+=v[n[(o+3)%4]&63]}):(l=function(n){for(o=3;o>=0;o--)n[o]=f(n[o],r[o]),n[o]-=v[a]+(n[(o+3)%4]&n[(o+2)%4])+(~n[(o+3)%4]&n[(o+1)%4]),a--},p=function(n){for(o=3;o>=0;o--)n[o]-=v[n[(o+3)%4]&63]}),b=function(n){var t=[],r,i,u;for(o=0;o<4;o++)r=s.getInt16Le(),c!==null&&(e?r^=c.getInt16Le():c.putInt16Le(r)),t.push(r&65535);for(a=e?0:63,i=0;i<n.length;i++)for(u=0;u<n[i][0];u++)n[i][1](t);for(o=0;o<4;o++)c!==null&&(e?c.putInt16Le(t[o]):t[o]^=c.getInt16Le()),h.putInt16Le(t[o])},y=null,y={start:function(t,i){t&&typeof t=="string"&&(t=n.util.createBuffer(t));w=!1;s=n.util.createBuffer();h=i||new n.util.createBuffer;c=t;y.output=h},update:function(n){for(w||s.putBuffer(n);s.length()>=8;)b([[5,l],[1,p],[6,l],[1,p],[5,l]])},finish:function(n){var t=!0,i,r,u;return e&&(n?t=n(8,s,!e):(i=s.length()===8?8:8-s.length(),s.fillWithByte(i,i))),t&&(w=!0,y.update()),e||(t=s.length()===0,t&&(n?t=n(8,h,!e):(r=h.length(),u=h.at(r-1),u>r?t=!1:h.truncate(u)))),t}},y};n.rc2.startEncrypting=function(t,i,r){var u=n.rc2.createEncryptionCipher(t,128);return u.start(i,r),u};n.rc2.createEncryptionCipher=function(n,t){return i(n,t,!0)};n.rc2.startDecrypting=function(t,i,r){var u=n.rc2.createDecryptionCipher(t,128);return u.start(i,r),u};n.rc2.createDecryptionCipher=function(n,t){return i(n,t,!1)}}var i="rc2",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/rc2",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function t(n,t,i){this.data=[];n!=null&&("number"==typeof n?this.fromNumber(n,t,i):t==null&&"string"!=typeof n?this.fromString(n,256):this.fromString(n,t))}function i(){return new t(null)}function ut(n,t,i,r,u,f){while(--f>=0){var e=t*this.data[n++]+i.data[r]+u;u=Math.floor(e/67108864);i.data[r++]=e&67108863}return u}function ft(n,t,i,r,u,f){for(var o=t&32767,s=t>>15;--f>=0;){var e=this.data[n]&32767,h=this.data[n++]>>15,c=s*e+h*o;e=o*e+((c&32767)<<15)+i.data[r]+(u&1073741823);u=(e>>>30)+(c>>>15)+s*h+(u>>>30);i.data[r++]=e&1073741823}return u}function w(n,t,i,r,u,f){for(var o=t&16383,s=t>>14;--f>=0;){var e=this.data[n]&16383,h=this.data[n++]>>14,c=s*e+h*o;e=o*e+((c&16383)<<14)+i.data[r]+u;u=(e>>28)+(c>>14)+s*h;i.data[r++]=e&268435455}return u}function b(n){return it.charAt(n)}function k(n,t){var i=a[n.charCodeAt(t)];return i==null?-1:i}function et(n){for(var t=this.t-1;t>=0;--t)n.data[t]=this.data[t];n.t=this.t;n.s=this.s}function ot(n){this.t=1;this.s=n<0?-1:0;n>0?this.data[0]=n:n<-1?this.data[0]=n+this.DV:this.t=0}function e(n){var t=i();return t.fromInt(n),t}function st(n,i){var u,f;if(i==16)u=4;else if(i==8)u=3;else if(i==256)u=8;else if(i==2)u=1;else if(i==32)u=5;else{if(i!=4){this.fromRadix(n,i);return}u=2}this.t=0;this.s=0;for(var e=n.length,o=!1,r=0;--e>=0;){if(f=u==8?n[e]&255:k(n,e),f<0){n.charAt(e)=="-"&&(o=!0);continue}o=!1;r==0?this.data[this.t++]=f:r+u>this.DB?(this.data[this.t-1]|=(f&(1<<this.DB-r)-1)<<r,this.data[this.t++]=f>>this.DB-r):this.data[this.t-1]|=f<<r;r+=u;r>=this.DB&&(r-=this.DB)}u==8&&(n[0]&128)!=0&&(this.s=-1,r>0&&(this.data[this.t-1]|=(1<<this.DB-r)-1<<r));this.clamp();o&&t.ZERO.subTo(this,this)}function ht(){for(var n=this.s&this.DM;this.t>0&&this.data[this.t-1]==n;)--this.t}function ct(n){var t;if(this.s<0)return"-"+this.negate().toString(n);if(n==16)t=4;else if(n==8)t=3;else if(n==2)t=1;else if(n==32)t=5;else{if(n!=4)return this.toRadix(n);t=2}var o=(1<<t)-1,u,f=!1,e="",r=this.t,i=this.DB-r*this.DB%t;if(r-->0)for(i<this.DB&&(u=this.data[r]>>i)>0&&(f=!0,e=b(u));r>=0;)i<t?(u=(this.data[r]&(1<<i)-1)<<t-i,u|=this.data[--r]>>(i+=this.DB-t)):(u=this.data[r]>>(i-=t)&o,i<=0&&(i+=this.DB,--r)),u>0&&(f=!0),f&&(e+=b(u));return f?e:"0"}function lt(){var n=i();return t.ZERO.subTo(this,n),n}function at(){return this.s<0?this.negate():this}function vt(n){var t=this.s-n.s,i;if(t!=0)return t;if(i=this.t,t=i-n.t,t!=0)return this.s<0?-t:t;while(--i>=0)if((t=this.data[i]-n.data[i])!=0)return t;return 0}function v(n){var i=1,t;return(t=n>>>16)!=0&&(n=t,i+=16),(t=n>>8)!=0&&(n=t,i+=8),(t=n>>4)!=0&&(n=t,i+=4),(t=n>>2)!=0&&(n=t,i+=2),(t=n>>1)!=0&&(n=t,i+=1),i}function yt(){return this.t<=0?0:this.DB*(this.t-1)+v(this.data[this.t-1]^this.s&this.DM)}function pt(n,t){for(var i=this.t-1;i>=0;--i)t.data[i+n]=this.data[i];for(i=n-1;i>=0;--i)t.data[i]=0;t.t=this.t+n;t.s=this.s}function wt(n,t){for(var i=n;i<this.t;++i)t.data[i-n]=this.data[i];t.t=Math.max(this.t-n,0);t.s=this.s}function bt(n,t){for(var u=n%this.DB,e=this.DB-u,o=(1<<e)-1,r=Math.floor(n/this.DB),f=this.s<<u&this.DM,i=this.t-1;i>=0;--i)t.data[i+r+1]=this.data[i]>>e|f,f=(this.data[i]&o)<<u;for(i=r-1;i>=0;--i)t.data[i]=0;t.data[r]=f;t.t=this.t+r+1;t.s=this.s;t.clamp()}function kt(n,t){var i,r;if(t.s=this.s,i=Math.floor(n/this.DB),i>=this.t){t.t=0;return}var u=n%this.DB,f=this.DB-u,e=(1<<u)-1;for(t.data[0]=this.data[i]>>u,r=i+1;r<this.t;++r)t.data[r-i-1]|=(this.data[r]&e)<<f,t.data[r-i]=this.data[r]>>u;u>0&&(t.data[this.t-i-1]|=(this.s&e)<<f);t.t=this.t-i;t.clamp()}function dt(n,t){for(var r=0,i=0,u=Math.min(n.t,this.t);r<u;)i+=this.data[r]-n.data[r],t.data[r++]=i&this.DM,i>>=this.DB;if(n.t<this.t){for(i-=n.s;r<this.t;)i+=this.data[r],t.data[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<n.t;)i-=n.data[r],t.data[r++]=i&this.DM,i>>=this.DB;i-=n.s}t.s=i<0?-1:0;i<-1?t.data[r++]=this.DV+i:i>0&&(t.data[r++]=i);t.t=r;t.clamp()}function gt(n,i){var u=this.abs(),f=n.abs(),r=u.t;for(i.t=r+f.t;--r>=0;)i.data[r]=0;for(r=0;r<f.t;++r)i.data[r+u.t]=u.am(0,f.data[r],i,r,0,u.t);i.s=0;i.clamp();this.s!=n.s&&t.ZERO.subTo(i,i)}function ni(n){for(var i=this.abs(),t=n.t=2*i.t,r;--t>=0;)n.data[t]=0;for(t=0;t<i.t-1;++t)r=i.am(t,i.data[t],n,2*t,0,1),(n.data[t+i.t]+=i.am(t+1,2*i.data[t],n,2*t+1,r,i.t-t-1))>=i.DV&&(n.data[t+i.t]-=i.DV,n.data[t+i.t+1]=1);n.t>0&&(n.data[n.t-1]+=i.am(t,i.data[t],n,2*t,0,1));n.s=0;n.clamp()}function ti(n,r,u){var s=n.abs(),l,e,a,p;if(!(s.t<=0)){if(l=this.abs(),l.t<s.t){r!=null&&r.fromInt(0);u!=null&&this.copyTo(u);return}u==null&&(u=i());var f=i(),w=this.s,k=n.s,c=this.DB-v(s.data[s.t-1]);if(c>0?(s.lShiftTo(c,f),l.lShiftTo(c,u)):(s.copyTo(f),l.copyTo(u)),e=f.t,a=f.data[e-1],a!=0){var b=a*(1<<this.F1)+(e>1?f.data[e-2]>>this.F2:0),d=this.FV/b,g=(1<<this.F1)/b,nt=1<<this.F2,h=u.t,y=h-e,o=r==null?i():r;for(f.dlShiftTo(y,o),u.compareTo(o)>=0&&(u.data[u.t++]=1,u.subTo(o,u)),t.ONE.dlShiftTo(e,o),o.subTo(f,f);f.t<e;)f.data[f.t++]=0;while(--y>=0)if(p=u.data[--h]==a?this.DM:Math.floor(u.data[h]*d+(u.data[h-1]+nt)*g),(u.data[h]+=f.am(0,p,u,y,0,e))<p)for(f.dlShiftTo(y,o),u.subTo(o,u);u.data[h]<--p;)u.subTo(o,u);r!=null&&(u.drShiftTo(e,r),w!=k&&t.ZERO.subTo(r,r));u.t=e;u.clamp();c>0&&u.rShiftTo(c,u);w<0&&t.ZERO.subTo(u,u)}}}function ii(n){var r=i();return this.abs().divRemTo(n,null,r),this.s<0&&r.compareTo(t.ZERO)>0&&n.subTo(r,r),r}function o(n){this.m=n}function ri(n){return n.s<0||n.compareTo(this.m)>=0?n.mod(this.m):n}function ui(n){return n}function fi(n){n.divRemTo(this.m,null,n)}function ei(n,t,i){n.multiplyTo(t,i);this.reduce(i)}function oi(n,t){n.squareTo(t);this.reduce(t)}function si(){var t,n;return this.t<1?0:(t=this.data[0],(t&1)==0)?0:(n=t&3,n=n*(2-(t&15)*n)&15,n=n*(2-(t&255)*n)&255,n=n*(2-((t&65535)*n&65535))&65535,n=n*(2-t*n%this.DV)%this.DV,n>0?this.DV-n:-n)}function s(n){this.m=n;this.mp=n.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<n.DB-15)-1;this.mt2=2*n.t}function hi(n){var r=i();return n.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),n.s<0&&r.compareTo(t.ZERO)>0&&this.m.subTo(r,r),r}function ci(n){var t=i();return n.copyTo(t),this.reduce(t),t}function li(n){for(var i,t,r;n.t<=this.mt2;)n.data[n.t++]=0;for(i=0;i<this.m.t;++i)for(t=n.data[i]&32767,r=t*this.mpl+((t*this.mph+(n.data[i]>>15)*this.mpl&this.um)<<15)&n.DM,t=i+this.m.t,n.data[t]+=this.m.am(0,r,n,i,0,this.m.t);n.data[t]>=n.DV;)n.data[t]-=n.DV,n.data[++t]++;n.clamp();n.drShiftTo(this.m.t,n);n.compareTo(this.m)>=0&&n.subTo(this.m,n)}function ai(n,t){n.squareTo(t);this.reduce(t)}function vi(n,t,i){n.multiplyTo(t,i);this.reduce(i)}function yi(){return(this.t>0?this.data[0]&1:this.s)==0}function pi(n,r){var s;if(n>4294967295||n<1)return t.ONE;var u=i(),f=i(),e=r.convert(this),o=v(n)-1;for(e.copyTo(u);--o>=0;)r.sqrTo(u,f),(n&1<<o)>0?r.mulTo(f,e,u):(s=u,u=f,f=s);return r.revert(u)}function wi(n,t){var i;return i=n<256||t.isEven()?new o(t):new s(t),this.exp(n,i)}function bi(){var n=i();return this.copyTo(n),n}function ki(){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 di(){return this.t==0?this.s:this.data[0]<<24>>24}function gi(){return this.t==0?this.s:this.data[0]<<16>>16}function nr(n){return Math.floor(Math.LN2*this.DB/Math.log(n))}function tr(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function ir(n){if(n==null&&(n=10),this.signum()==0||n<2||n>36)return"0";var s=this.chunkSize(n),f=Math.pow(n,s),o=e(f),t=i(),r=i(),u="";for(this.divRemTo(o,t,r);t.signum()>0;)u=(f+r.intValue()).toString(n).substr(1)+u,t.divRemTo(o,t,r);return r.intValue().toString(n)+u}function rr(n,i){var u,e;this.fromInt(0);i==null&&(i=10);var o=this.chunkSize(i),h=Math.pow(i,o),s=!1,f=0,r=0;for(u=0;u<n.length;++u){if(e=k(n,u),e<0){n.charAt(u)=="-"&&this.signum()==0&&(s=!0);continue}r=i*r+e;++f>=o&&(this.dMultiply(h),this.dAddOffset(r,0),f=0,r=0)}f>0&&(this.dMultiply(Math.pow(i,f)),this.dAddOffset(r,0));s&&t.ZERO.subTo(this,this)}function ur(n,i,r){if("number"==typeof i)if(n<2)this.fromInt(1);else for(this.fromNumber(n,r),this.testBit(n-1)||this.bitwiseTo(t.ONE.shiftLeft(n-1),p,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>n&&this.subTo(t.ONE.shiftLeft(n-1),this);else{var u=[],f=n&7;u.length=(n>>3)+1;i.nextBytes(u);f>0?u[0]&=(1<<f)-1:u[0]=0;this.fromString(u,256)}}function fr(){var i=this.t,u=[],n,t,r;if(u[0]=this.s,n=this.DB-i*this.DB%8,r=0,i-->0)for(n<this.DB&&(t=this.data[i]>>n)!=(this.s&this.DM)>>n&&(u[r++]=t|this.s<<this.DB-n);i>=0;)n<8?(t=(this.data[i]&(1<<n)-1)<<8-n,t|=this.data[--i]>>(n+=this.DB-8)):(t=this.data[i]>>(n-=8)&255,n<=0&&(n+=this.DB,--i)),(t&128)!=0&&(t|=-256),r==0&&(this.s&128)!=(t&128)&&++r,(r>0||t!=this.s)&&(u[r++]=t);return u}function er(n){return this.compareTo(n)==0}function or(n){return this.compareTo(n)<0?this:n}function sr(n){return this.compareTo(n)>0?this:n}function hr(n,t,i){for(var u,f=Math.min(n.t,this.t),r=0;r<f;++r)i.data[r]=t(this.data[r],n.data[r]);if(n.t<this.t){for(u=n.s&this.DM,r=f;r<this.t;++r)i.data[r]=t(this.data[r],u);i.t=this.t}else{for(u=this.s&this.DM,r=f;r<n.t;++r)i.data[r]=t(u,n.data[r]);i.t=n.t}i.s=t(this.s,n.s);i.clamp()}function cr(n,t){return n&t}function lr(n){var t=i();return this.bitwiseTo(n,cr,t),t}function p(n,t){return n|t}function ar(n){var t=i();return this.bitwiseTo(n,p,t),t}function d(n,t){return n^t}function vr(n){var t=i();return this.bitwiseTo(n,d,t),t}function g(n,t){return n&~t}function yr(n){var t=i();return this.bitwiseTo(n,g,t),t}function pr(){for(var t=i(),n=0;n<this.t;++n)t.data[n]=this.DM&~this.data[n];return t.t=this.t,t.s=~this.s,t}function wr(n){var t=i();return n<0?this.rShiftTo(-n,t):this.lShiftTo(n,t),t}function br(n){var t=i();return n<0?this.lShiftTo(-n,t):this.rShiftTo(n,t),t}function kr(n){if(n==0)return-1;var t=0;return(n&65535)==0&&(n>>=16,t+=16),(n&255)==0&&(n>>=8,t+=8),(n&15)==0&&(n>>=4,t+=4),(n&3)==0&&(n>>=2,t+=2),(n&1)==0&&++t,t}function dr(){for(var n=0;n<this.t;++n)if(this.data[n]!=0)return n*this.DB+kr(this.data[n]);return this.s<0?this.t*this.DB:-1}function gr(n){for(var t=0;n!=0;)n&=n-1,++t;return t}function nu(){for(var t=0,i=this.s&this.DM,n=0;n<this.t;++n)t+=gr(this.data[n]^i);return t}function tu(n){var t=Math.floor(n/this.DB);return t>=this.t?this.s!=0:(this.data[t]&1<<n%this.DB)!=0}function iu(n,i){var r=t.ONE.shiftLeft(n);return this.bitwiseTo(r,i,r),r}function ru(n){return this.changeBit(n,p)}function uu(n){return this.changeBit(n,g)}function fu(n){return this.changeBit(n,d)}function eu(n,t){for(var r=0,i=0,u=Math.min(n.t,this.t);r<u;)i+=this.data[r]+n.data[r],t.data[r++]=i&this.DM,i>>=this.DB;if(n.t<this.t){for(i+=n.s;r<this.t;)i+=this.data[r],t.data[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<n.t;)i+=n.data[r],t.data[r++]=i&this.DM,i>>=this.DB;i+=n.s}t.s=i<0?-1:0;i>0?t.data[r++]=i:i<-1&&(t.data[r++]=this.DV+i);t.t=r;t.clamp()}function ou(n){var t=i();return this.addTo(n,t),t}function su(n){var t=i();return this.subTo(n,t),t}function hu(n){var t=i();return this.multiplyTo(n,t),t}function cu(n){var t=i();return this.divRemTo(n,t,null),t}function lu(n){var t=i();return this.divRemTo(n,null,t),t}function au(n){var t=i(),r=i();return this.divRemTo(n,t,r),[t,r]}function vu(n){this.data[this.t]=this.am(0,n-1,this,0,0,this.t);++this.t;this.clamp()}function yu(n,t){if(n!=0){while(this.t<=t)this.data[this.t++]=0;for(this.data[t]+=n;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function l(){}function nt(n){return n}function pu(n,t,i){n.multiplyTo(t,i)}function wu(n,t){n.squareTo(t)}function bu(n){return this.exp(n,new l)}function ku(n,t,i){var r=Math.min(this.t+n.t,t),u;for(i.s=0,i.t=r;r>0;)i.data[--r]=0;for(u=i.t-this.t;r<u;++r)i.data[r+this.t]=this.am(0,n.data[r],i,r,0,this.t);for(u=Math.min(n.t,t);r<u;++r)this.am(0,n.data[r],i,r,0,t-r);i.clamp()}function du(n,t,i){--t;var r=i.t=this.t+n.t-t;for(i.s=0;--r>=0;)i.data[r]=0;for(r=Math.max(t-this.t,0);r<n.t;++r)i.data[this.t+r-t]=this.am(t-r,n.data[r],i,0,0,this.t+r-t);i.clamp();i.drShiftTo(1,i)}function h(n){this.r2=i();this.q3=i();t.ONE.dlShiftTo(2*n.t,this.r2);this.mu=this.r2.divide(n);this.m=n}function gu(n){if(n.s<0||n.t>2*this.m.t)return n.mod(this.m);if(n.compareTo(this.m)<0)return n;var t=i();return n.copyTo(t),this.reduce(t),t}function nf(n){return n}function tf(n){for(n.drShiftTo(this.m.t-1,this.r2),n.t>this.m.t+1&&(n.t=this.m.t+1,n.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);n.compareTo(this.r2)<0;)n.dAddOffset(1,this.m.t+1);for(n.subTo(this.r2,n);n.compareTo(this.m)>=0;)n.subTo(this.m,n)}function rf(n,t){n.squareTo(t);this.reduce(t)}function uf(n,t,i){n.multiplyTo(t,i);this.reduce(i)}function ff(n,t){var r=n.bitLength(),w,u=e(1),c,d;if(r<=0)return u;w=r<18?1:r<48?3:r<144?4:r<768?5:6;c=r<8?new o(t):t.isEven()?new h(t):new s(t);var y=[],f=3,b=w-1,g=(1<<w)-1;if(y[1]=c.convert(this),w>1)for(d=i(),c.sqrTo(y[1],d);f<=g;)y[f]=i(),c.mulTo(d,y[f-2],y[f]),f+=2;var l=n.t-1,p,nt=!0,a=i(),k;for(r=v(n.data[l])-1;l>=0;){for(r>=b?p=n.data[l]>>r-b&g:(p=(n.data[l]&(1<<r+1)-1)<<b-r,l>0&&(p|=n.data[l-1]>>this.DB+r-b)),f=w;(p&1)==0;)p>>=1,--f;if((r-=f)<0&&(r+=this.DB,--l),nt)y[p].copyTo(u),nt=!1;else{while(f>1)c.sqrTo(u,a),c.sqrTo(a,u),f-=2;f>0?c.sqrTo(u,a):(k=u,u=a,a=k);c.mulTo(a,y[p],u)}while(l>=0&&(n.data[l]&1<<r)==0)c.sqrTo(u,a),k=u,u=a,a=k,--r<0&&(r=this.DB-1,--l)}return c.revert(u)}function ef(n){var i=this.s<0?this.negate():this.clone(),t=n.s<0?n.negate():n.clone(),f,u,r;if(i.compareTo(t)<0&&(f=i,i=t,t=f),u=i.getLowestSetBit(),r=t.getLowestSetBit(),r<0)return i;for(u<r&&(r=u),r>0&&(i.rShiftTo(r,i),t.rShiftTo(r,t));i.signum()>0;)(u=i.getLowestSetBit())>0&&i.rShiftTo(u,i),(u=t.getLowestSetBit())>0&&t.rShiftTo(u,t),i.compareTo(t)>=0?(i.subTo(t,i),i.rShiftTo(1,i)):(t.subTo(i,t),t.rShiftTo(1,t));return r>0&&t.lShiftTo(r,t),t}function of(n){var r,t,i;if(n<=0)return 0;if(r=this.DV%n,t=this.s<0?n-1:0,this.t>0)if(r==0)t=this.data[0]%n;else for(i=this.t-1;i>=0;--i)t=(r*t+this.data[i])%n;return t}function sf(n){var h=n.isEven();if(this.isEven()&&h||n.signum()==0)return t.ZERO;for(var u=n.clone(),f=this.clone(),o=e(1),r=e(0),s=e(0),i=e(1);u.signum()!=0;){while(u.isEven())u.rShiftTo(1,u),h?(o.isEven()&&r.isEven()||(o.addTo(this,o),r.subTo(n,r)),o.rShiftTo(1,o)):r.isEven()||r.subTo(n,r),r.rShiftTo(1,r);while(f.isEven())f.rShiftTo(1,f),h?(s.isEven()&&i.isEven()||(s.addTo(this,s),i.subTo(n,i)),s.rShiftTo(1,s)):i.isEven()||i.subTo(n,i),i.rShiftTo(1,i);u.compareTo(f)>=0?(u.subTo(f,u),h&&o.subTo(s,o),r.subTo(i,r)):(f.subTo(u,f),h&&s.subTo(o,s),i.subTo(r,i))}return f.compareTo(t.ONE)!=0?t.ZERO:i.compareTo(n)>=0?i.subtract(n):i.signum()<0?(i.addTo(n,i),i.signum()<0?i.add(n):i):i}function hf(n){var t,i=this.abs(),r,f;if(i.t==1&&i.data[0]<=u[u.length-1]){for(t=0;t<u.length;++t)if(i.data[0]==u[t])return!0;return!1}if(i.isEven())return!1;for(t=1;t<u.length;){for(r=u[t],f=t+1;f<u.length&&r<rt;)r*=u[f++];for(r=i.modInt(r);t<f;)if(r%u[t++]==0)return!1}return i.millerRabin(n)}function cf(n){var r=this.subtract(t.ONE),f=r.getLowestSetBit(),o,s,u,e,i,h;if(f<=0)return!1;for(o=r.shiftRight(f),s=lf(),e=0;e<n;++e){do u=new t(this.bitLength(),s);while(u.compareTo(t.ONE)<=0||u.compareTo(r)>=0);if(i=u.modPow(o,this),i.compareTo(t.ONE)!=0&&i.compareTo(r)!=0){for(h=1;h++<f&&i.compareTo(r)!=0;)if(i=i.modPowInt(2,this),i.compareTo(t.ONE)==0)return!1;if(i.compareTo(r)!=0)return!1}}return!0}function lf(){return{nextBytes:function(n){for(var t=0;t<n.length;++t)n[t]=Math.floor(Math.random()*256)}}}var f,tt=(0xdeadbeefcafe&16777215)==15715070,y,it,a,c,r,u,rt;for(typeof navigator=="undefined"?(t.prototype.am=w,f=28):tt&&navigator.appName=="Microsoft Internet Explorer"?(t.prototype.am=ft,f=30):tt&&navigator.appName!="Netscape"?(t.prototype.am=ut,f=26):(t.prototype.am=w,f=28),t.prototype.DB=f,t.prototype.DM=(1<<f)-1,t.prototype.DV=1<<f,y=52,t.prototype.FV=Math.pow(2,y),t.prototype.F1=y-f,t.prototype.F2=2*f-y,it="0123456789abcdefghijklmnopqrstuvwxyz",a=[],c="0".charCodeAt(0),r=0;r<=9;++r)a[c++]=r;for(c="a".charCodeAt(0),r=10;r<36;++r)a[c++]=r;for(c="A".charCodeAt(0),r=10;r<36;++r)a[c++]=r;o.prototype.convert=ri;o.prototype.revert=ui;o.prototype.reduce=fi;o.prototype.mulTo=ei;o.prototype.sqrTo=oi;s.prototype.convert=hi;s.prototype.revert=ci;s.prototype.reduce=li;s.prototype.mulTo=vi;s.prototype.sqrTo=ai;t.prototype.copyTo=et;t.prototype.fromInt=ot;t.prototype.fromString=st;t.prototype.clamp=ht;t.prototype.dlShiftTo=pt;t.prototype.drShiftTo=wt;t.prototype.lShiftTo=bt;t.prototype.rShiftTo=kt;t.prototype.subTo=dt;t.prototype.multiplyTo=gt;t.prototype.squareTo=ni;t.prototype.divRemTo=ti;t.prototype.invDigit=si;t.prototype.isEven=yi;t.prototype.exp=pi;t.prototype.toString=ct;t.prototype.negate=lt;t.prototype.abs=at;t.prototype.compareTo=vt;t.prototype.bitLength=yt;t.prototype.mod=ii;t.prototype.modPowInt=wi;t.ZERO=e(0);t.ONE=e(1);l.prototype.convert=nt;l.prototype.revert=nt;l.prototype.mulTo=pu;l.prototype.sqrTo=wu;h.prototype.convert=gu;h.prototype.revert=nf;h.prototype.reduce=tf;h.prototype.mulTo=uf;h.prototype.sqrTo=rf;u=[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];rt=67108864/u[u.length-1];t.prototype.chunkSize=nr;t.prototype.toRadix=ir;t.prototype.fromRadix=rr;t.prototype.fromNumber=ur;t.prototype.bitwiseTo=hr;t.prototype.changeBit=iu;t.prototype.addTo=eu;t.prototype.dMultiply=vu;t.prototype.dAddOffset=yu;t.prototype.multiplyLowerTo=ku;t.prototype.multiplyUpperTo=du;t.prototype.modInt=of;t.prototype.millerRabin=cf;t.prototype.clone=bi;t.prototype.intValue=ki;t.prototype.byteValue=di;t.prototype.shortValue=gi;t.prototype.signum=tr;t.prototype.toByteArray=fr;t.prototype.equals=er;t.prototype.min=or;t.prototype.max=sr;t.prototype.and=lr;t.prototype.or=ar;t.prototype.xor=vr;t.prototype.andNot=yr;t.prototype.not=pr;t.prototype.shiftLeft=wr;t.prototype.shiftRight=br;t.prototype.getLowestSetBit=dr;t.prototype.bitCount=nu;t.prototype.testBit=tu;t.prototype.setBit=ru;t.prototype.clearBit=uu;t.prototype.flipBit=fu;t.prototype.add=ou;t.prototype.subtract=su;t.prototype.multiply=hu;t.prototype.divide=cu;t.prototype.remainder=lu;t.prototype.divideAndRemainder=au;t.prototype.modPow=ff;t.prototype.modInverse=sf;t.prototype.pow=bu;t.prototype.gcd=ef;t.prototype.isProbablePrime=hf;n.jsbn=n.jsbn||{};n.jsbn.BigInteger=t}var i="jsbn",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/jsbn",["require","module"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function t(t,i,r){var f,e,u,o;for(r||(r=n.md.sha1.create()),f="",e=Math.ceil(i/r.digestLength),u=0;u<e;++u)o=String.fromCharCode(u>>24&255,u>>16&255,u>>8&255,u&255),r.start(),r.update(t+o),f+=r.digest().getBytes();return f.substring(0,i)}var i=n.pkcs1=n.pkcs1||{};i.encode_rsa_oaep=function(i,r,u){var s,e,f,h,l,c,a,v,o;if(typeof u=="string"?(s=u,e=arguments[3]||undefined,f=arguments[4]||undefined):u&&(s=u.label||undefined,e=u.seed||undefined,f=u.md||undefined,u.mgf1&&u.mgf1.md&&(h=u.mgf1.md)),f?f.start():f=n.md.sha1.create(),h||(h=f),l=Math.ceil(i.n.bitLength()/8),c=l-2*f.digestLength-2,r.length>c){o=new Error("RSAES-OAEP input message length is too long.");throw o.length=r.length,o.maxLength=c,o;}s||(s="");f.update(s,"raw");var w=f.digest(),y="",b=c-r.length;for(a=0;a<b;a++)y+="\0";if(v=w.getBytes()+y+"\x01"+r,e){if(e.length!==f.digestLength){o=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw o.seedLength=e.length,o.digestLength=f.digestLength,o;}}else e=n.random.getBytes(f.digestLength);var k=t(e,l-f.digestLength-1,h),p=n.util.xorBytes(v,k,v.length),d=t(p,f.digestLength,h),g=n.util.xorBytes(e,d,e.length);return"\0"+g+p};i.decode_rsa_oaep=function(i,r,u){var o,f,s,h,e,l,a,v,y;if(typeof u=="string"?(o=u,f=arguments[3]||undefined):u&&(o=u.label||undefined,f=u.md||undefined,u.mgf1&&u.mgf1.md&&(s=u.mgf1.md)),h=Math.ceil(i.n.bitLength()/8),r.length!==h){e=new Error("RSAES-OAEP encoded message length is invalid.");throw e.length=r.length,e.expectedLength=h,e;}if(f===undefined?f=n.md.sha1.create():f.start(),s||(s=f),h<2*f.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");o||(o="");f.update(o,"raw");var k=f.digest().getBytes(),d=r.charAt(0),w=r.substring(1,f.digestLength+1),p=r.substring(1+f.digestLength),g=t(p,f.digestLength,s),nt=n.util.xorBytes(w,g,w.length),tt=t(nt,h-f.digestLength-1,s),c=n.util.xorBytes(p,tt,p.length),it=c.substring(0,f.digestLength),e=d!=="\0";for(l=0;l<f.digestLength;++l)e|=k.charAt(l)!==it.charAt(l);for(a=1,v=f.digestLength,y=f.digestLength;y<c.length;y++){var b=c.charCodeAt(y),rt=b&1^1,ut=a?65534:0;e|=b&ut;a&=rt;v+=a}if(e||c.charCodeAt(v)!==1)throw new Error("Invalid RSAES-OAEP padding.");return c.substring(v+1)}}var i="pkcs1",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pkcs1",["require","module","./util","./random","./sha1"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function e(n,t,i,u){return"workers"in i?o(n,t,i,u):r(n,t,i,u)}function r(i,u,f,e){var o=t(i,u),v=0,l=s(o.bitLength()),h,a;"millerRabinTests"in f&&(l=f.millerRabinTests);h=10;"maxBlockTime"in f&&(h=f.maxBlockTime);a=+new Date;do{if(o.bitLength()>i&&(o=t(i,u)),o.isProbablePrime(l))return e(null,o);o.dAddOffset(c[v++%8],0)}while(h<0||+new Date-a<h);n.util.setImmediate(function(){r(i,u,f,e)})}function o(u,f,e,o){function c(){function y(n){var v,s,y;if(!e){if(--c,v=n.data,v.found){for(s=0;s<r.length;++s)r[s].terminate();return e=!0,o(null,new i(v.prime,16))}h.bitLength()>u&&(h=t(u,f));y=h.toString(16);n.target.postMessage({hex:y,workLoad:l});h.dAddOffset(a,0)}}var r,c,n,e;for(s=Math.max(1,s),r=[],n=0;n<s;++n)r[n]=new Worker(v);for(c=s,n=0;n<s;++n)r[n].addEventListener("message",y);e=!1}if(typeof Worker=="undefined")return r(u,f,e,o);var h=t(u,f),s=e.workers,l=e.workLoad||100,a=l*30/8,v=e.workerScript||"forge/prime.worker.js";if(s===-1)return n.util.estimateCores(function(n,t){n&&(t=2);s=t-1;c()});c()}function t(n,t){var r=new i(n,t),e=n-1;return r.testBit(e)||r.bitwiseTo(i.ONE.shiftLeft(e),f,r),r.dAddOffset(31-r.mod(u).byteValue(),0),r}function s(n){return n<=100?27:n<=150?18:n<=200?15:n<=250?12:n<=300?9:n<=350?8:n<=400?7:n<=500?6:n<=600?5:n<=800?4:n<=1250?3:2}var f;if(!n.prime){var h=n.prime=n.prime||{},i=n.jsbn.BigInteger,c=[6,4,2,4,2,4,6,2],u=new i(null);u.fromInt(30);f=function(n,t){return n|t};h.generateProbablePrime=function(t,i,r){var u,f,o;if(typeof i=="function"&&(r=i,i={}),i=i||{},u=i.algorithm||"PRIMEINC",typeof u=="string"&&(u={name:u}),u.options=u.options||{},f=i.prng||n.random,o={nextBytes:function(n){for(var i=f.getBytesSync(n.length),t=0;t<n.length;++t)n[t]=i.charCodeAt(t)}},u.name==="PRIMEINC")return e(t,o,u.options,r);throw new Error("Invalid prime generation algorithm: "+u.name);}}}var i="prime",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/prime",["require","module","./util","./jsbn","./random"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function e(t,i,r){var f=n.util.createBuffer(),h=Math.ceil(i.n.bitLength()/8),s,e,o,c,l,u;if(t.length>h-11){s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=t.length,s.max=h-11,s;}if(f.putByte(0),f.putByte(r),e=h-3-t.length,r===0||r===1)for(o=r===0?0:255,u=0;u<e;++u)f.putByte(o);else while(e>0){for(c=0,l=n.random.getBytes(e),u=0;u<e;++u)o=l.charCodeAt(u),o===0?++c:f.putByte(o);e=c}return f.putByte(0),f.putBytes(t),f}function f(t,i,r,u){var h=Math.ceil(i.n.bitLength()/8),f=n.util.createBuffer(t),l=f.getByte(),o=f.getByte(),e,s,c;if(l!==0||r&&o!==0&&o!==1||!r&&o!=2||r&&o===0&&typeof u=="undefined")throw new Error("Encryption block is invalid.");if(e=0,o===0){for(e=h-3-u,s=0;s<e;++s)if(f.getByte()!==0)throw new Error("Encryption block is invalid.");}else if(o===1)for(e=0;f.length()>1;){if(f.getByte()!==255){--f.read;break}++e}else if(o===2)for(e=0;f.length()>1;){if(f.getByte()===0){--f.read;break}++e}if(c=f.getByte(),c!==0||e!==h-3-f.length())throw new Error("Encryption block is invalid.");return f.getBytes()}function s(t,u,f){function s(){e(t.pBits,function(n,i){if(n)return f(n);if(t.p=i,t.q!==null)return o(n,t.q);e(t.qBits,o)})}function e(t,i){n.prime.generateProbablePrime(t,h,i)}function o(n,u){var c,h;if(n)return f(n);if(t.q=u,t.p.compareTo(t.q)<0&&(c=t.p,t.p=t.q,t.q=c),t.p.subtract(r.ONE).gcd(t.e).compareTo(r.ONE)!==0){t.p=null;s();return}if(t.q.subtract(r.ONE).gcd(t.e).compareTo(r.ONE)!==0){t.q=null;e(t.qBits,o);return}if(t.p1=t.p.subtract(r.ONE),t.q1=t.q.subtract(r.ONE),t.phi=t.p1.multiply(t.q1),t.phi.gcd(t.e).compareTo(r.ONE)!==0){t.p=t.q=null;s();return}if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits){t.q=null;e(t.qBits,o);return}h=t.e.modInverse(t.phi);t.keys={privateKey:i.rsa.setPrivateKey(t.n,t.e,h,t.p,t.q,h.mod(t.p1),h.mod(t.q1),t.q.modInverse(t.p)),publicKey:i.rsa.setPublicKey(t.n,t.e)};f(null,t.keys)}typeof u=="function"&&(f=u,u={});u=u||{};var h={algorithm:{name:u.algorithm||"PRIMEINC",options:{workers:u.workers||2,workLoad:u.workLoad||100,workerScript:u.workerScript}}};"prng"in u&&(h.prng=u.prng);s()}function u(t){var i=t.toString(16);return i[0]>="8"&&(i="00"+i),n.util.hexToBytes(i)}function h(n){return n<=100?27:n<=150?18:n<=200?15:n<=250?12:n<=300?9:n<=350?8:n<=400?7:n<=500?6:n<=600?5:n<=800?4:n<=1250?3:2}var r,t;typeof r=="undefined"&&(r=n.jsbn.BigInteger);t=n.asn1;n.pki=n.pki||{};n.pki.rsa=n.rsa=n.rsa||{};var i=n.pki,c=[6,4,2,4,2,4,6,2],l={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"}]},a={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"}]},v={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"}]},y=n.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"}]}]},p=function(n){var e,o,f;if(n.algorithm in i.oids){e=i.oids[n.algorithm];var s=t.oidToDer(e).getBytes(),r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);return u.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,s)),u.value.push(t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")),o=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n.digest().getBytes()),r.value.push(u),r.value.push(o),t.toDer(r).getBytes()}f=new Error("Unknown message digest algorithm.");throw f.algorithm=n.algorithm,f;},o=function(t,i,u){var f,e,o,s;if(u)return t.modPow(i.e,i.n);if(!i.p||!i.q)return t.modPow(i.d,i.n);i.dP||(i.dP=i.d.mod(i.p.subtract(r.ONE)));i.dQ||(i.dQ=i.d.mod(i.q.subtract(r.ONE)));i.qInv||(i.qInv=i.q.modInverse(i.p));do f=new r(n.util.bytesToHex(n.random.getBytes(i.n.bitLength()/8)),16);while(f.compareTo(i.n)>=0||!f.gcd(i.n).equals(r.ONE));for(t=t.multiply(f.modPow(i.e,i.n)).mod(i.n),e=t.mod(i.p).modPow(i.dP,i.p),o=t.mod(i.q).modPow(i.dQ,i.q);e.compareTo(o)<0;)e=e.add(i.p);return s=e.subtract(o).multiply(i.qInv).mod(i.p).multiply(i.q).add(o),s=s.multiply(f.modInverse(i.n)).mod(i.n),s};i.rsa.encrypt=function(t,i,u){var h=u,f,a=Math.ceil(i.n.bitLength()/8);u!==!1&&u!==!0?(h=u===2,f=e(t,i,u)):(f=n.util.createBuffer(),f.putBytes(t));for(var v=new r(f.toHex(),16),y=o(v,i,h),c=y.toString(16),s=n.util.createBuffer(),l=a-Math.ceil(c.length/2);l>0;)s.putByte(0),--l;return s.putBytes(n.util.hexToBytes(c)),s.getBytes()};i.rsa.decrypt=function(t,i,u,e){var c=Math.ceil(i.n.bitLength()/8),s,l;if(t.length!==c){s=new Error("Encrypted message length is invalid.");throw s.length=t.length,s.expected=c,s;}if(l=new r(n.util.createBuffer(t).toHex(),16),l.compareTo(i.n)>=0)throw new Error("Encrypted message is invalid.");for(var y=o(l,i,u),a=y.toString(16),h=n.util.createBuffer(),v=c-Math.ceil(a.length/2);v>0;)h.putByte(0),--v;return h.putBytes(n.util.hexToBytes(a)),e!==!1?f(h.getBytes(),i,u):h.getBytes()};i.rsa.createKeyPairGenerationState=function(t,i,u){typeof t=="string"&&(t=parseInt(t,10));t=t||2048;u=u||{};var o=u.prng||n.random,s={nextBytes:function(n){for(var i=o.getBytesSync(n.length),t=0;t<n.length;++t)n[t]=i.charCodeAt(t)}},e=u.algorithm||"PRIMEINC",f;if(e!=="PRIMEINC")throw new Error("Invalid key generation algorithm: "+e);return f={algorithm:e,state:0,bits:t,rng:s,eInt:i||65537,e:new r(null),p:null,q:null,qBits:t>>1,pBits:t-(t>>1),pqState:0,num:null,keys:null},f.e.fromInt(f.eInt),f};i.rsa.stepKeyPairGenerationState=function(n,t){var e,u,s,f;"algorithm"in n||(n.algorithm="PRIMEINC");e=new r(null);e.fromInt(30);for(var l=0,y=function(n,t){return n|t},a=+new Date,o,v=0;n.keys===null&&(t<=0||v<t);)n.state===0?(u=n.p===null?n.pBits:n.qBits,s=u-1,n.pqState===0?(n.num=new r(u,n.rng),n.num.testBit(s)||n.num.bitwiseTo(r.ONE.shiftLeft(s),y,n.num),n.num.dAddOffset(31-n.num.mod(e).byteValue(),0),l=0,++n.pqState):n.pqState===1?n.num.bitLength()>u?n.pqState=0:n.num.isProbablePrime(h(n.num.bitLength()))?++n.pqState:n.num.dAddOffset(c[l++%8],0):n.pqState===2?n.pqState=n.num.subtract(r.ONE).gcd(n.e).compareTo(r.ONE)===0?3:0:n.pqState===3&&(n.pqState=0,n.p===null?n.p=n.num:n.q=n.num,n.p!==null&&n.q!==null&&++n.state,n.num=null)):n.state===1?(n.p.compareTo(n.q)<0&&(n.num=n.p,n.p=n.q,n.q=n.num),++n.state):n.state===2?(n.p1=n.p.subtract(r.ONE),n.q1=n.q.subtract(r.ONE),n.phi=n.p1.multiply(n.q1),++n.state):n.state===3?n.phi.gcd(n.e).compareTo(r.ONE)===0?++n.state:(n.p=null,n.q=null,n.state=0):n.state===4?(n.n=n.p.multiply(n.q),n.n.bitLength()===n.bits?++n.state:(n.q=null,n.state=0)):n.state===5&&(f=n.e.modInverse(n.phi),n.keys={privateKey:i.rsa.setPrivateKey(n.n,n.e,f,n.p,n.q,f.mod(n.p1),f.mod(n.q1),n.q.modInverse(n.p)),publicKey:i.rsa.setPublicKey(n.n,n.e)}),o=+new Date,v+=o-a,a=o;return n.keys!==null};i.rsa.generateKeyPair=function(n,t,r,u){arguments.length===1?typeof n=="object"?(r=n,n=undefined):typeof n=="function"&&(u=n,n=undefined):arguments.length===2?typeof n=="number"?typeof t=="function"?(u=t,t=undefined):typeof t!="number"&&(r=t,t=undefined):(r=n,u=t,n=undefined,t=undefined):arguments.length===3&&(typeof t=="number"?typeof r=="function"&&(u=r,r=undefined):(u=r,r=t,t=undefined));r=r||{};n===undefined&&(n=r.bits||2048);t===undefined&&(t=r.e||65537);var f=i.rsa.createKeyPairGenerationState(n,t,r);if(!u)return i.rsa.stepKeyPairGenerationState(f,0),f.keys;s(f,r,u)};i.setRsaPublicKey=i.rsa.setPublicKey=function(r,u){var o={n:r,e:u};return o.encrypt=function(t,r,u){if(typeof r=="string"?r=r.toUpperCase():r===undefined&&(r="RSAES-PKCS1-V1_5"),r==="RSAES-PKCS1-V1_5")r={encode:function(n,t){return e(n,t,2).getBytes()}};else if(r==="RSA-OAEP"||r==="RSAES-OAEP")r={encode:function(t,i){return n.pkcs1.encode_rsa_oaep(i,t,u)}};else if(["RAW","NONE","NULL",null].indexOf(r)!==-1)r={encode:function(n){return n}};else if(typeof r=="string")throw new Error('Unsupported encryption scheme: "'+r+'".');var f=r.encode(t,o,!0);return i.rsa.encrypt(f,o,!0)},o.verify=function(n,r,u){typeof u=="string"?u=u.toUpperCase():u===undefined&&(u="RSASSA-PKCS1-V1_5");u==="RSASSA-PKCS1-V1_5"?u={verify:function(n,i){i=f(i,o,!0);var r=t.fromDer(i);return n===r.value[1].value}}:(u==="NONE"||u==="NULL"||u===null)&&(u={verify:function(n,t){return t=f(t,o,!0),n===t}});var e=i.rsa.decrypt(r,o,!0,!1);return u.verify(n,e,o.n.bitLength())},o};i.setRsaPrivateKey=i.rsa.setPrivateKey=function(t,r,u,e,o,s,h,c){var l={n:t,e:r,d:u,p:e,q:o,dP:s,dQ:h,qInv:c};return l.decrypt=function(t,r,u){typeof r=="string"?r=r.toUpperCase():r===undefined&&(r="RSAES-PKCS1-V1_5");var e=i.rsa.decrypt(t,l,!1,!1);if(r==="RSAES-PKCS1-V1_5")r={decode:f};else if(r==="RSA-OAEP"||r==="RSAES-OAEP")r={decode:function(t,i){return n.pkcs1.decode_rsa_oaep(i,t,u)}};else{if(["RAW","NONE","NULL",null].indexOf(r)===-1)throw new Error('Unsupported encryption scheme: "'+r+'".');r={decode:function(n){return n}}}return r.decode(e,l,!1)},l.sign=function(n,t){var r=!1,u;return typeof t=="string"&&(t=t.toUpperCase()),t===undefined||t==="RSASSA-PKCS1-V1_5"?(t={encode:p},r=1):(t==="NONE"||t==="NULL"||t===null)&&(t={encode:function(){return n}},r=1),u=t.encode(n,l.n.bitLength()),i.rsa.encrypt(u,l,r)},l};i.wrapRsaPrivateKey=function(n){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(i.oids.rsaEncryption).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(n).getBytes())])};i.privateKeyFromAsn1=function(u){var f={},e=[],o,s,h,c,v,y,p,w,b;if(t.validate(u,l,f,e)&&(u=t.fromDer(n.util.createBuffer(f.privateKey))),f={},e=[],!t.validate(u,a,f,e)){o=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw o.errors=e,o;}return s=n.util.createBuffer(f.privateKeyModulus).toHex(),h=n.util.createBuffer(f.privateKeyPublicExponent).toHex(),c=n.util.createBuffer(f.privateKeyPrivateExponent).toHex(),v=n.util.createBuffer(f.privateKeyPrime1).toHex(),y=n.util.createBuffer(f.privateKeyPrime2).toHex(),p=n.util.createBuffer(f.privateKeyExponent1).toHex(),w=n.util.createBuffer(f.privateKeyExponent2).toHex(),b=n.util.createBuffer(f.privateKeyCoefficient).toHex(),i.setRsaPrivateKey(new r(s,16),new r(h,16),new r(c,16),new r(v,16),new r(y,16),new r(p,16),new r(w,16),new r(b,16))};i.privateKeyToAsn1=i.privateKeyToRSAPrivateKey=function(n){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,u(n.n)),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.e)),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.d)),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.p)),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.q)),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.dP)),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.dQ)),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.qInv))])};i.publicKeyFromAsn1=function(u){var e={},o=[],s,f,h,c;if(t.validate(u,y,e,o)){if(s=t.derToOid(e.publicKeyOid),s!==i.oids.rsaEncryption){f=new Error("Cannot read public key. Unknown OID.");throw f.oid=s,f;}u=e.rsaPublicKey}if(o=[],!t.validate(u,v,e,o)){f=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw f.errors=o,f;}return h=n.util.createBuffer(e.publicKeyModulus).toHex(),c=n.util.createBuffer(e.publicKeyExponent).toHex(),i.setRsaPublicKey(new r(h,16),new r(c,16))};i.publicKeyToAsn1=i.publicKeyToSubjectPublicKeyInfo=function(n){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(i.oids.rsaEncryption).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,[i.publicKeyToRSAPublicKey(n)])])};i.publicKeyToRSAPublicKey=function(n){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.n)),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,u(n.e))])}}var i="rsa",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/rsa",["require","module","./asn1","./jsbn","./oids","./pkcs1","./prime","./random","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function u(n,t){return n.start().update(t).digest().getBytes()}var f,t,i;typeof f=="undefined"&&(f=n.jsbn.BigInteger);t=n.asn1;i=n.pki=n.pki||{};i.pbe=n.pbe=n.pbe||{};var r=i.oids,e={name:"EncryptedPrivateKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",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:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},o={name:"PBES2Algorithms",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,onstructed:!0,capture:"kdfIterationCount"}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},s={name:"pkcs-12PbeParams",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"iterations"}]};i.encryptPrivateKeyInfo=function(u,f,e){var c,l,a,h;e=e||{};e.saltSize=e.saltSize||8;e.count=e.count||2048;e.algorithm=e.algorithm||"aes128";var v=n.random.getBytesSync(e.saltSize),y=e.count,d=t.integerToDer(y),s,w,b;if(e.algorithm.indexOf("aes")===0||e.algorithm==="des"){switch(e.algorithm){case"aes128":s=16;c=16;l=r["aes128-CBC"];a=n.aes.createEncryptionCipher;break;case"aes192":s=24;c=16;l=r["aes192-CBC"];a=n.aes.createEncryptionCipher;break;case"aes256":s=32;c=16;l=r["aes256-CBC"];a=n.aes.createEncryptionCipher;break;case"des":s=8;c=8;l=r.desCBC;a=n.des.createEncryptionCipher;break;default:h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=e.algorithm,h;}var k=n.pkcs5.pbkdf2(f,v,y,s),p=n.random.getBytesSync(c),o=a(k);o.start(p);o.update(t.toDer(u));o.finish();b=o.output.getBytes();w=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.pkcs5PBES2).getBytes()),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(r.pkcs5PBKDF2).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,v),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,d.getBytes())])]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(l).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,p)])])])}else{if(e.algorithm!=="3des"){h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=e.algorithm,h;}s=24;var g=new n.util.ByteBuffer(v),k=i.pbe.generatePkcs12Key(f,g,1,y,s),p=i.pbe.generatePkcs12Key(f,g,2,y,s),o=n.des.createEncryptionCipher(k);o.start(p);o.update(t.toDer(u));o.finish();b=o.output.getBytes();w=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,v),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,d.getBytes())])])}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[w,t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,b)])};i.decryptPrivateKeyInfo=function(r,u){var h=null,f={},c=[],o;if(!t.validate(r,e,f,c)){o=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=c,o;}var l=t.derToOid(f.encryptionOid),s=i.pbe.getCipher(l,f.encryptionParams,u),a=n.util.createBuffer(f.encryptedData);return s.update(a),s.finish()&&(h=t.fromDer(s.output)),h};i.encryptedPrivateKeyToPem=function(i,r){var u={type:"ENCRYPTED PRIVATE KEY",body:t.toDer(i).getBytes()};return n.pem.encode(u,{maxline:r})};i.encryptedPrivateKeyFromPem=function(i){var r=n.pem.decode(i)[0],u;if(r.type!=="ENCRYPTED PRIVATE KEY"){u=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw u.headerType=r.type,u;}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return t.fromDer(r.body)};i.encryptRsaPrivateKey=function(r,u,f){var l,o,e,s,h,a,v,c,y;if(f=f||{},!f.legacy)return l=i.wrapRsaPrivateKey(i.privateKeyToAsn1(r)),l=i.encryptPrivateKeyInfo(l,u,f),i.encryptedPrivateKeyToPem(l);switch(f.algorithm){case"aes128":o="AES-128-CBC";s=16;e=n.random.getBytesSync(16);h=n.aes.createEncryptionCipher;break;case"aes192":o="AES-192-CBC";s=24;e=n.random.getBytesSync(16);h=n.aes.createEncryptionCipher;break;case"aes256":o="AES-256-CBC";s=32;e=n.random.getBytesSync(16);h=n.aes.createEncryptionCipher;break;case"3des":o="DES-EDE3-CBC";s=24;e=n.random.getBytesSync(8);h=n.des.createEncryptionCipher;break;case"des":o="DES-CBC";s=8;e=n.random.getBytesSync(8);h=n.des.createEncryptionCipher;break;default:a=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+f.algorithm+'".');throw a.algorithm=f.algorithm,a;}return v=n.pbe.opensslDeriveBytes(u,e.substr(0,8),s),c=h(v),c.start(e),c.update(t.toDer(i.privateKeyToAsn1(r))),c.finish(),y={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:o,parameters:n.util.bytesToHex(e).toUpperCase()},body:c.output.getBytes()},n.pem.encode(y)};i.decryptRsaPrivateKey=function(r,u){var e=null,f=n.pem.decode(r)[0],o,s,h;if(f.type!=="ENCRYPTED PRIVATE KEY"&&f.type!=="PRIVATE KEY"&&f.type!=="RSA PRIVATE KEY"){h=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw h.headerType=h,h;}if(f.procType&&f.procType.type==="ENCRYPTED"){switch(f.dekInfo.algorithm){case"DES-CBC":o=8;s=n.des.createDecryptionCipher;break;case"DES-EDE3-CBC":o=24;s=n.des.createDecryptionCipher;break;case"AES-128-CBC":o=16;s=n.aes.createDecryptionCipher;break;case"AES-192-CBC":o=24;s=n.aes.createDecryptionCipher;break;case"AES-256-CBC":o=32;s=n.aes.createDecryptionCipher;break;case"RC2-40-CBC":o=5;s=function(t){return n.rc2.createDecryptionCipher(t,40)};break;case"RC2-64-CBC":o=8;s=function(t){return n.rc2.createDecryptionCipher(t,64)};break;case"RC2-128-CBC":o=16;s=function(t){return n.rc2.createDecryptionCipher(t,128)};break;default:h=new Error('Could not decrypt private key; unsupported encryption algorithm "'+f.dekInfo.algorithm+'".');throw h.algorithm=f.dekInfo.algorithm,h;}var l=n.util.hexToBytes(f.dekInfo.parameters),a=n.pbe.opensslDeriveBytes(u,l.substr(0,8),o),c=s(a);if(c.start(l),c.update(n.util.createBuffer(f.body)),!c.finish())return e;e=c.output.getBytes()}else e=f.body;return e=f.type==="ENCRYPTED PRIVATE KEY"?i.decryptPrivateKeyInfo(t.fromDer(e),u):t.fromDer(e),e!==null&&(e=i.privateKeyFromAsn1(e)),e};i.pbe.generatePkcs12Key=function(t,i,r,u,f,e){var w,o,ft,d,et,g,c,ot,nt,h,tt,v,st,it,y,p;(typeof e=="undefined"||e===null)&&(e=n.md.sha1.create());var rt=e.digestLength,s=e.blockLength,l=new n.util.ByteBuffer,a=new n.util.ByteBuffer;if(t!==null&&t!==undefined){for(o=0;o<t.length;o++)a.putInt16(t.charCodeAt(o));a.putInt16(0)}var b=a.length(),k=i.length(),ut=new n.util.ByteBuffer;for(ut.fillWithByte(r,s),ft=s*Math.ceil(k/s),d=new n.util.ByteBuffer,o=0;o<ft;o++)d.putByte(i.at(o%k));for(et=s*Math.ceil(b/s),g=new n.util.ByteBuffer,o=0;o<et;o++)g.putByte(a.at(o%b));for(c=d,c.putBuffer(g),ot=Math.ceil(f/rt),nt=1;nt<=ot;nt++){for(h=new n.util.ByteBuffer,h.putBytes(ut.bytes()),h.putBytes(c.bytes()),tt=0;tt<u;tt++)e.start(),e.update(h.getBytes()),h=e.digest();for(v=new n.util.ByteBuffer,o=0;o<s;o++)v.putByte(h.at(o%rt));for(st=Math.ceil(k/s)+Math.ceil(b/s),it=new n.util.ByteBuffer,w=0;w<st;w++){for(y=new n.util.ByteBuffer(c.getBytes(s)),p=511,o=v.length()-1;o>=0;o--)p>>=8,p+=v.at(o)+y.at(o),y.setAt(o,p&255);it.putBuffer(y)}c=it;l.putBuffer(h)}return l.truncate(l.length()-f),l};i.pbe.getCipher=function(n,t,r){switch(n){case i.oids.pkcs5PBES2:return i.pbe.getCipherForPBES2(n,t,r);case i.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case i.oids["pbewithSHAAnd40BitRC2-CBC"]:return i.pbe.getCipherForPKCS12PBE(n,t,r);default:var u=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw u.oid=n,u.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],u;}};i.pbe.getCipherForPBES2=function(r,u,f){var s={},a=[],e,v,l,h,c;if(!t.validate(u,o,s,a)){e=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw e.errors=a,e;}if(r=t.derToOid(s.kdfOid),r!==i.oids.pkcs5PBKDF2){e=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw e.oid=r,e.supportedOids=["pkcs5PBKDF2"],e;}if(r=t.derToOid(s.encOid),r!==i.oids["aes128-CBC"]&&r!==i.oids["aes192-CBC"]&&r!==i.oids["aes256-CBC"]&&r!==i.oids["des-EDE3-CBC"]&&r!==i.oids.desCBC){e=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw e.oid=r,e.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],e;}v=s.kdfSalt;l=n.util.createBuffer(s.kdfIterationCount);l=l.getInt(l.length()<<3);switch(i.oids[r]){case"aes128-CBC":h=16;c=n.aes.createDecryptionCipher;break;case"aes192-CBC":h=24;c=n.aes.createDecryptionCipher;break;case"aes256-CBC":h=32;c=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":h=24;c=n.des.createDecryptionCipher;break;case"desCBC":h=8;c=n.des.createDecryptionCipher}var p=n.pkcs5.pbkdf2(f,v,l,h),w=s.encIv,y=c(p);return y.start(w),y};i.pbe.getCipherForPKCS12PBE=function(r,u,f){var h={},y=[],c,o,l,a,v,e,p,w;if(!t.validate(u,s,h,y)){e=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw e.errors=y,e;}c=n.util.createBuffer(h.salt);o=n.util.createBuffer(h.iterations);o=o.getInt(o.length()<<3);switch(r){case i.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:l=24;a=8;v=n.des.startDecrypting;break;case i.oids["pbewithSHAAnd40BitRC2-CBC"]:l=5;a=8;v=function(t,i){var r=n.rc2.createDecryptionCipher(t,40);return r.start(i,null),r};break;default:e=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw e.oid=r,e;}return p=i.pbe.generatePkcs12Key(f,c,1,o,l),w=i.pbe.generatePkcs12Key(f,c,2,o,a),v(p,w)};i.pbe.opensslDeriveBytes=function(t,i,r,f){var e,o,s;for((typeof f=="undefined"||f===null)&&(f=n.md.md5.create()),i===null&&(i=""),e=[u(f,t+i)],o=16,s=1;o<r;++s,o+=16)e.push(u(f,e[s-1]+t+i));return e.join("").substr(0,r)}}var i="pbe",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pbe",["require","module","./aes","./asn1","./des","./md","./oids","./pem","./pbkdf2","./random","./rc2","./rsa","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var t=n.asn1,i=n.pkcs7asn1=n.pkcs7asn1||{},r,u,f;n.pkcs7=n.pkcs7||{};n.pkcs7.asn1=i;r={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};i.contentInfoValidator=r;u={name:"EncryptedContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};i.envelopedDataValidator={name:"EnvelopedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(u)};i.encryptedDataValidator={name:"EncryptedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"}].concat(u)};f={name:"SignerInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};i.signedDataValidator={name:"SignedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},r,{name:"SignedData.Certificates",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,capture:"signerInfos",optional:!0,value:[f]}]};i.recipientInfoValidator={name:"RecipientInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}}var i="pkcs7asn1",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pkcs7asn1",["require","module","./asn1","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){n.mgf=n.mgf||{};var t=n.mgf.mgf1=n.mgf1=n.mgf1||{};t.create=function(t){return{generate:function(i,r){for(var u=new n.util.ByteBuffer,o=Math.ceil(r/t.digestLength),e,f=0;f<o;f++)e=new n.util.ByteBuffer,e.putInt32(f),t.start(),t.update(i+e.getBytes()),u.putBuffer(t.digest());return u.truncate(u.length()-r),u.getBytes()}}}}var i="mgf1",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/mgf1",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){n.mgf=n.mgf||{};n.mgf.mgf1=n.mgf1}var i="mgf",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/mgf",["require","module","./mgf1"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var t=n.pss=n.pss||{};t.create=function(t){var r,s,e;arguments.length===3&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var u=t.md,o=t.mgf,f=u.digestLength,i=t.salt||null;if(typeof i=="string"&&(i=n.util.createBuffer(i)),"saltLength"in t)r=t.saltLength;else{if(i===null)throw new Error("Salt length not specified or specific salt not given.");r=i.length()}if(i!==null&&i.length()!==r)throw new Error("Given salt length does not match length of given salt.");return s=t.prng||n.random,e={},e.encode=function(t,e){var h,w=e-1,v=Math.ceil(w/8),d=t.digest().getBytes(),y,c,p,l,k;if(v<f+r+2)throw new Error("Message is too long to encrypt.");y=i===null?s.getBytesSync(r):i.bytes();c=new n.util.ByteBuffer;c.fillWithByte(0,8);c.putBytes(d);c.putBytes(y);u.start();u.update(c.getBytes());p=u.digest().getBytes();l=new n.util.ByteBuffer;l.fillWithByte(0,v-r-f-2);l.putByte(1);l.putBytes(y);var g=l.getBytes(),b=v-f-1,nt=o.generate(p,b),a="";for(h=0;h<b;h++)a+=String.fromCharCode(g.charCodeAt(h)^nt.charCodeAt(h));return k=65280>>8*v-w&255,a=String.fromCharCode(a.charCodeAt(0)&~k)+a.substr(1),a+p+String.fromCharCode(188)},e.verify=function(t,i,e){var s,y=e-1,c=Math.ceil(y/8),k,h,v,d,l,g;if(i=i.substr(-c),c<f+r+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(i.charCodeAt(c-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var a=c-f-1,p=i.substr(0,a),w=i.substr(a,f),b=65280>>8*c-y&255;if((p.charCodeAt(0)&b)!=0)throw new Error("Bits beyond keysize not zero as expected.");for(k=o.generate(w,a),h="",s=0;s<a;s++)h+=String.fromCharCode(p.charCodeAt(s)^k.charCodeAt(s));for(h=String.fromCharCode(h.charCodeAt(0)&~b)+h.substr(1),v=c-f-r-2,s=0;s<v;s++)if(h.charCodeAt(s)!==0)throw new Error("Leftmost octets not zero as expected");if(h.charCodeAt(v)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");return d=h.substr(-r),l=new n.util.ByteBuffer,l.fillWithByte(0,8),l.putBytes(t),l.putBytes(d),u.start(),u.update(l.getBytes()),g=u.digest().getBytes(),w===g},e}}var i="pss",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pss",["require","module","./random","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function e(n,t){var r,i,u;for(typeof t=="string"&&(t={shortName:t}),r=null,u=0;r===null&&u<n.attributes.length;++u)i=n.attributes[u],t.type&&t.type===i.type?r=i:t.name&&t.name===i.name?r=i:t.shortName&&t.shortName===i.shortName&&(r=i);return r}function o(i){for(var o=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),r,s,h=i.attributes,f,e,u=0;u<h.length;++u)r=h[u],f=r.value,e=t.Type.PRINTABLESTRING,"valueTagClass"in r&&(e=r.valueTagClass,e===t.Type.UTF8&&(f=n.util.encodeUtf8(f))),s=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.type).getBytes()),t.create(t.Class.UNIVERSAL,e,!1,f)])]),o.value.push(s);return o}function f(n){for(var f,s,e,o=0;o<n.length;++o){if(f=n[o],typeof f.name=="undefined"&&(f.type&&f.type in i.oids?f.name=i.oids[f.type]:f.shortName&&f.shortName in u&&(f.name=i.oids[u[f.shortName]])),typeof f.type=="undefined"){if(!(f.name&&f.name in i.oids)){e=new Error("Attribute type not specified.");throw e.attribute=f,e;}f.type=i.oids[f.name]}if(typeof f.shortName=="undefined"&&f.name&&f.name in u&&(f.shortName=u[f.name]),f.type===r.extensionRequest&&(f.valueConstructed=!0,f.valueTagClass=t.Type.SEQUENCE,!f.value&&f.extensions))for(f.value=[],s=0;s<f.extensions.length;++s)f.value.push(i.certificateExtensionToAsn1(c(f.extensions[s])));if(typeof f.value=="undefined"){e=new Error("Attribute value not specified.");throw e.attribute=f,e;}}}function c(u,f){var y,l,o,e,c,a,s,p,h;if(f=f||{},typeof u.name=="undefined"&&u.id&&u.id in i.oids&&(u.name=i.oids[u.id]),typeof u.id=="undefined"){if(!(u.name&&u.name in i.oids)){h=new Error("Extension ID not specified.");throw h.extension=u,h;}u.id=i.oids[u.name]}if(typeof u.value!="undefined")return u;if(u.name==="keyUsage"){var o=0,e=0,v=0;u.digitalSignature&&(e|=128,o=7);u.nonRepudiation&&(e|=64,o=6);u.keyEncipherment&&(e|=32,o=5);u.dataEncipherment&&(e|=16,o=4);u.keyAgreement&&(e|=8,o=3);u.keyCertSign&&(e|=4,o=2);u.cRLSign&&(e|=2,o=1);u.encipherOnly&&(e|=1,o=0);u.decipherOnly&&(v|=128,o=7);s=String.fromCharCode(o);v!==0?s+=String.fromCharCode(e)+String.fromCharCode(v):e!==0&&(s+=String.fromCharCode(e));u.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,s)}else if(u.name==="basicConstraints")u.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),u.cA&&u.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in u&&u.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(u.pathLenConstraint).getBytes()));else if(u.name==="extKeyUsage"){u.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);y=u.value.value;for(l in u)u[l]===!0&&(l in r?y.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r[l]).getBytes())):l.indexOf(".")!==-1&&y.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(l).getBytes())))}else if(u.name==="nsCertType")o=0,e=0,u.client&&(e|=128,o=7),u.server&&(e|=64,o=6),u.email&&(e|=32,o=5),u.objsign&&(e|=16,o=4),u.reserved&&(e|=8,o=3),u.sslCA&&(e|=4,o=2),u.emailCA&&(e|=2,o=1),u.objCA&&(e|=1,o=0),s=String.fromCharCode(o),e!==0&&(s+=String.fromCharCode(e)),u.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,s);else if(u.name==="subjectAltName"||u.name==="issuerAltName")for(u.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),a=0;a<u.altNames.length;++a){if(c=u.altNames[a],s=c.value,c.type===7&&c.ip){if(s=n.util.bytesFromIP(c.ip),s===null){h=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw h.extension=u,h;}}else c.type===8&&(s=c.oid?t.oidToDer(t.oidToDer(c.oid)):t.oidToDer(s));u.value.value.push(t.create(t.Class.CONTEXT_SPECIFIC,c.type,!1,s))}else u.name==="subjectKeyIdentifier"&&f.cert&&(p=f.cert.generateSubjectKeyIdentifier(),u.subjectKeyIdentifier=p.toHex(),u.value=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,p.getBytes()));if(typeof u.value=="undefined"){h=new Error("Extension value not specified.");throw h.extension=u,h;}return u}function h(n,i){switch(n){case r["RSASSA-PSS"]:var u=[];return i.hash.algorithmOid!==undefined&&u.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])),i.mgf.algorithmOid!==undefined&&u.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.mgf.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.mgf.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])])),i.saltLength!==undefined&&u.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(i.saltLength).getBytes())])),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,u);default:return t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")}}function a(i){var f=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]),e,u,h,c;if(i.attributes.length===0)return f;for(e=i.attributes,u=0;u<e.length;++u){var r=e[u],o=r.value,s=t.Type.UTF8;"valueTagClass"in r&&(s=r.valueTagClass);s===t.Type.UTF8&&(o=n.util.encodeUtf8(o));h=!1;"valueConstructed"in r&&(h=r.valueConstructed);c=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,s,h,o)])]);f.value.push(c)}return f}var t=n.asn1,i=n.pki=n.pki||{},r=i.oids,u={},s;u.CN=r.commonName;u.commonName="CN";u.C=r.countryName;u.countryName="C";u.L=r.localityName;u.localityName="L";u.ST=r.stateOrProvinceName;u.stateOrProvinceName="ST";u.O=r.organizationName;u.organizationName="O";u.OU=r.organizationalUnitName;u.organizationalUnitName="OU";u.E=r.emailAddress;u.emailAddress="E";var l=n.pki.rsa.publicKeyValidator,v={name:"Certificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},l,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,capture:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,capture:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,capture:"certSignature"}]},y={name:"rsapss",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},p={name:"CertificationRequestInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},l,{name:"CertificationRequestInfo.attributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0}]}]}]},w={name:"CertificationRequest",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[p,{name:"CertificationRequest.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,capture:"csrSignature"}]};i.RDNAttributesAsArray=function(n,i){for(var c=[],h,e,f,s,o=0;o<n.value.length;++o)for(h=n.value[o],s=0;s<h.value.length;++s)f={},e=h.value[s],f.type=t.derToOid(e.value[0].value),f.value=e.value[1].value,f.valueTagClass=e.value[1].type,f.type in r&&(f.name=r[f.type],f.name in u&&(f.shortName=u[f.name])),i&&(i.update(f.type),i.update(f.value)),c.push(f);return c};i.CRIAttributesAsArray=function(n){for(var c=[],e,f,s,o=0;o<n.length;++o){var l=n[o],a=t.derToOid(l.value[0].value),h=l.value[1].value;for(e=0;e<h.length;++e){if(f={},f.type=a,f.value=h[e].value,f.valueTagClass=h[e].type,f.type in r&&(f.name=r[f.type],f.name in u&&(f.shortName=u[f.name])),f.type===r.extensionRequest)for(f.extensions=[],s=0;s<f.value.length;++s)f.extensions.push(i.certificateExtensionFromAsn1(f.value[s]));c.push(f)}}return c};s=function(n,i,u){var f={},e,o,s;if(n!==r["RSASSA-PSS"])return f;if(u&&(f={hash:{algorithmOid:r.sha1},mgf:{algorithmOid:r.mgf1,hash:{algorithmOid:r.sha1}},saltLength:20}),e={},o=[],!t.validate(i,y,e,o)){s=new Error("Cannot read RSASSA-PSS parameter block.");throw s.errors=o,s;}return e.hashOid!==undefined&&(f.hash=f.hash||{},f.hash.algorithmOid=t.derToOid(e.hashOid)),e.maskGenOid!==undefined&&(f.mgf=f.mgf||{},f.mgf.algorithmOid=t.derToOid(e.maskGenOid),f.mgf.hash=f.mgf.hash||{},f.mgf.hash.algorithmOid=t.derToOid(e.maskGenHashOid)),e.saltLength!==undefined&&(f.saltLength=e.saltLength.charCodeAt(0)),f};i.certificateFromPem=function(r,u,f){var e=n.pem.decode(r)[0],o,s;if(e.type!=="CERTIFICATE"&&e.type!=="X509 CERTIFICATE"&&e.type!=="TRUSTED CERTIFICATE"){o=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw o.headerType=e.type,o;}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");return s=t.fromDer(e.body,f),i.certificateFromAsn1(s,u)};i.certificateToPem=function(r,u){var f={type:"CERTIFICATE",body:t.toDer(i.certificateToAsn1(r)).getBytes()};return n.pem.encode(f,{maxline:u})};i.publicKeyFromPem=function(r){var u=n.pem.decode(r)[0],f,e;if(u.type!=="PUBLIC KEY"&&u.type!=="RSA PUBLIC KEY"){f=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw f.headerType=u.type,f;}if(u.procType&&u.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");return e=t.fromDer(u.body),i.publicKeyFromAsn1(e)};i.publicKeyToPem=function(r,u){var f={type:"PUBLIC KEY",body:t.toDer(i.publicKeyToAsn1(r)).getBytes()};return n.pem.encode(f,{maxline:u})};i.publicKeyToRSAPublicKeyPem=function(r,u){var f={type:"RSA PUBLIC KEY",body:t.toDer(i.publicKeyToRSAPublicKey(r)).getBytes()};return n.pem.encode(f,{maxline:u})};i.getPublicKeyFingerprint=function(r,u){var f,h,o,e,s;u=u||{};f=u.md||n.md.sha1.create();h=u.type||"RSAPublicKey";switch(h){case"RSAPublicKey":o=t.toDer(i.publicKeyToRSAPublicKey(r)).getBytes();break;case"SubjectPublicKeyInfo":o=t.toDer(i.publicKeyToAsn1(r)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+u.type+'".');}if(f.start(),f.update(o),e=f.digest(),u.encoding==="hex")return s=e.toHex(),u.delimiter?s.match(/.{2}/g).join(u.delimiter):s;if(u.encoding==="binary")return e.getBytes();if(u.encoding)throw new Error('Unknown encoding "'+u.encoding+'".');return e};i.certificationRequestFromPem=function(r,u,f){var e=n.pem.decode(r)[0],o,s;if(e.type!=="CERTIFICATE REQUEST"){o=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw o.headerType=e.type,o;}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");return s=t.fromDer(e.body,f),i.certificationRequestFromAsn1(s,u)};i.certificationRequestToPem=function(r,u){var f={type:"CERTIFICATE REQUEST",body:t.toDer(i.certificationRequestToAsn1(r)).getBytes()};return n.pem.encode(f,{maxline:u})};i.createCertificate=function(){var u={};return u.version=2,u.serialNumber="00",u.signatureOid=null,u.signature=null,u.siginfo={},u.siginfo.algorithmOid=null,u.validity={},u.validity.notBefore=new Date,u.validity.notAfter=new Date,u.issuer={},u.issuer.getField=function(n){return e(u.issuer,n)},u.issuer.addField=function(n){f([n]);u.issuer.attributes.push(n)},u.issuer.attributes=[],u.issuer.hash=null,u.subject={},u.subject.getField=function(n){return e(u.subject,n)},u.subject.addField=function(n){f([n]);u.subject.attributes.push(n)},u.subject.attributes=[],u.subject.hash=null,u.extensions=[],u.publicKey=null,u.md=null,u.setSubject=function(n,t){f(n);u.subject.attributes=n;delete u.subject.uniqueId;t&&(u.subject.uniqueId=t);u.subject.hash=null},u.setIssuer=function(n,t){f(n);u.issuer.attributes=n;delete u.issuer.uniqueId;t&&(u.issuer.uniqueId=t);u.issuer.hash=null},u.setExtensions=function(n){for(var t=0;t<n.length;++t)c(n[t],{cert:u});u.extensions=n},u.getExtension=function(n){var t,i,r;for(typeof n=="string"&&(n={name:n}),t=null,r=0;t===null&&r<u.extensions.length;++r)i=u.extensions[r],n.id&&i.id===n.id?t=i:n.name&&i.name===n.name&&(t=i);return t},u.sign=function(f,e){var o,s,h;if(u.md=e||n.md.sha1.create(),o=r[u.md.algorithm+"WithRSAEncryption"],!o){s=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw s.algorithm=u.md.algorithm,s;}u.signatureOid=u.siginfo.algorithmOid=o;u.tbsCertificate=i.getTBSCertificate(u);h=t.toDer(u.tbsCertificate);u.md.update(h.getBytes());u.signature=f.sign(u.md)},u.verify=function(f){var l=!1,o,a,v,y,c,s,h,e;if(!u.issued(f)){var p=f.issuer,w=u.subject,e=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 e.expectedIssuer=p.attributes,e.actualIssuer=w.attributes,e;}if(o=f.md,o===null){if(f.signatureOid in r){a=r[f.signatureOid];switch(a){case"sha1WithRSAEncryption":o=n.md.sha1.create();break;case"md5WithRSAEncryption":o=n.md.md5.create();break;case"sha256WithRSAEncryption":o=n.md.sha256.create();break;case"sha512WithRSAEncryption":o=n.md.sha512.create();break;case"RSASSA-PSS":o=n.md.sha256.create()}}if(o===null){e=new Error("Could not compute certificate digest. Unknown signature OID.");throw e.signatureOid=f.signatureOid,e;}v=f.tbsCertificate||i.getTBSCertificate(f);y=t.toDer(v);o.update(y.getBytes())}if(o!==null){switch(f.signatureOid){case r.sha1WithRSAEncryption:c=undefined;break;case r["RSASSA-PSS"]:if(s=r[f.signatureParameters.mgf.hash.algorithmOid],s===undefined||n.md[s]===undefined){e=new Error("Unsupported MGF hash function.");throw e.oid=f.signatureParameters.mgf.hash.algorithmOid,e.name=s,e;}if(h=r[f.signatureParameters.mgf.algorithmOid],h===undefined||n.mgf[h]===undefined){e=new Error("Unsupported MGF function.");throw e.oid=f.signatureParameters.mgf.algorithmOid,e.name=h,e;}if(h=n.mgf[h].create(n.md[s].create()),s=r[f.signatureParameters.hash.algorithmOid],s===undefined||n.md[s]===undefined)throw{message:"Unsupported RSASSA-PSS hash function.",oid:f.signatureParameters.hash.algorithmOid,name:s};c=n.pss.create(n.md[s].create(),h,f.signatureParameters.saltLength)}l=u.publicKey.verify(o.digest().getBytes(),f.signature,c)}return l},u.isIssuer=function(n){var t=!1,i=u.issuer,f=n.subject,e,o,r;if(i.hash&&f.hash)t=i.hash===f.hash;else if(i.attributes.length===f.attributes.length)for(t=!0,r=0;t&&r<i.attributes.length;++r)e=i.attributes[r],o=f.attributes[r],(e.type!==o.type||e.value!==o.value)&&(t=!1);return t},u.issued=function(n){return n.isIssuer(u)},u.generateSubjectKeyIdentifier=function(){return i.getPublicKeyFingerprint(u.publicKey,{type:"RSAPublicKey"})},u.verifySubjectKeyIdentifier=function(){for(var e=r.subjectKeyIdentifier,i,f,t=0;t<u.extensions.length;++t)if(i=u.extensions[t],i.id===e)return f=u.generateSubjectKeyIdentifier().getBytes(),n.util.hexToBytes(i.subjectKeyIdentifier)===f;return!1},u};i.certificateFromAsn1=function(u,o){var c={},g=[],w,p,h,nt,b,l,y,a,tt,k,d;if(!t.validate(u,v,c,g)){a=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw a.errors=g,a;}if(typeof c.certSignature!="string"){for(w="\0",p=0;p<c.certSignature.length;++p)w+=t.toDer(c.certSignature[p]).getBytes();c.certSignature=w}if(y=t.derToOid(c.publicKeyOid),y!==i.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");if(h=i.createCertificate(),h.version=c.certVersion?c.certVersion.charCodeAt(0):0,nt=n.util.createBuffer(c.certSerialNumber),h.serialNumber=nt.toHex(),h.signatureOid=n.asn1.derToOid(c.certSignatureOid),h.signatureParameters=s(h.signatureOid,c.certSignatureParams,!0),h.siginfo.algorithmOid=n.asn1.derToOid(c.certinfoSignatureOid),h.siginfo.parameters=s(h.siginfo.algorithmOid,c.certinfoSignatureParams,!1),b=n.util.createBuffer(c.certSignature),++b.read,h.signature=b.getBytes(),l=[],c.certValidity1UTCTime!==undefined&&l.push(t.utcTimeToDate(c.certValidity1UTCTime)),c.certValidity2GeneralizedTime!==undefined&&l.push(t.generalizedTimeToDate(c.certValidity2GeneralizedTime)),c.certValidity3UTCTime!==undefined&&l.push(t.utcTimeToDate(c.certValidity3UTCTime)),c.certValidity4GeneralizedTime!==undefined&&l.push(t.generalizedTimeToDate(c.certValidity4GeneralizedTime)),l.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(l.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(h.validity.notBefore=l[0],h.validity.notAfter=l[1],h.tbsCertificate=c.tbsCertificate,o){if(h.md=null,h.signatureOid in r){y=r[h.signatureOid];switch(y){case"sha1WithRSAEncryption":h.md=n.md.sha1.create();break;case"md5WithRSAEncryption":h.md=n.md.md5.create();break;case"sha256WithRSAEncryption":h.md=n.md.sha256.create();break;case"sha512WithRSAEncryption":h.md=n.md.sha512.create();break;case"RSASSA-PSS":h.md=n.md.sha256.create()}}if(h.md===null){a=new Error("Could not compute certificate digest. Unknown signature OID.");throw a.signatureOid=h.signatureOid,a;}tt=t.toDer(h.tbsCertificate);h.md.update(tt.getBytes())}return k=n.md.sha1.create(),h.issuer.getField=function(n){return e(h.issuer,n)},h.issuer.addField=function(n){f([n]);h.issuer.attributes.push(n)},h.issuer.attributes=i.RDNAttributesAsArray(c.certIssuer,k),c.certIssuerUniqueId&&(h.issuer.uniqueId=c.certIssuerUniqueId),h.issuer.hash=k.digest().toHex(),d=n.md.sha1.create(),h.subject.getField=function(n){return e(h.subject,n)},h.subject.addField=function(n){f([n]);h.subject.attributes.push(n)},h.subject.attributes=i.RDNAttributesAsArray(c.certSubject,d),c.certSubjectUniqueId&&(h.subject.uniqueId=c.certSubjectUniqueId),h.subject.hash=d.digest().toHex(),h.extensions=c.certExtensions?i.certificateExtensionsFromAsn1(c.certExtensions):[],h.publicKey=i.publicKeyFromAsn1(c.subjectPublicKeyInfo),h};i.certificateExtensionsFromAsn1=function(n){for(var f=[],u,r,t=0;t<n.value.length;++t)for(u=n.value[t],r=0;r<u.value.length;++r)f.push(i.certificateExtensionFromAsn1(u.value[r]));return f};i.certificateExtensionFromAsn1=function(i){var u={},s,h,c,e,o,l,a,f;if(u.id=t.derToOid(i.value[0].value),u.critical=!1,i.value[1].type===t.Type.BOOLEAN?(u.critical=i.value[1].value.charCodeAt(0)!==0,u.value=i.value[2].value):u.value=i.value[1].value,u.id in r)if(u.name=r[u.id],u.name==="keyUsage"){var f=t.fromDer(u.value),e=0,v=0;f.value.length>1&&(e=f.value.charCodeAt(1),v=f.value.length>2?f.value.charCodeAt(2):0);u.digitalSignature=(e&128)==128;u.nonRepudiation=(e&64)==64;u.keyEncipherment=(e&32)==32;u.dataEncipherment=(e&16)==16;u.keyAgreement=(e&8)==8;u.keyCertSign=(e&4)==4;u.cRLSign=(e&2)==2;u.encipherOnly=(e&1)==1;u.decipherOnly=(v&128)==128}else if(u.name==="basicConstraints")f=t.fromDer(u.value),u.cA=f.value.length>0&&f.value[0].type===t.Type.BOOLEAN?f.value[0].value.charCodeAt(0)!==0:!1,s=null,f.value.length>0&&f.value[0].type===t.Type.INTEGER?s=f.value[0].value:f.value.length>1&&(s=f.value[1].value),s!==null&&(u.pathLenConstraint=t.derToInteger(s));else if(u.name==="extKeyUsage")for(f=t.fromDer(u.value),h=0;h<f.value.length;++h)c=t.derToOid(f.value[h].value),c in r?u[r[c]]=!0:u[c]=!0;else if(u.name==="nsCertType")f=t.fromDer(u.value),e=0,f.value.length>1&&(e=f.value.charCodeAt(1)),u.client=(e&128)==128,u.server=(e&64)==64,u.email=(e&32)==32,u.objsign=(e&16)==16,u.reserved=(e&8)==8,u.sslCA=(e&4)==4,u.emailCA=(e&2)==2,u.objCA=(e&1)==1;else if(u.name==="subjectAltName"||u.name==="issuerAltName")for(u.altNames=[],f=t.fromDer(u.value),l=0;l<f.value.length;++l){o=f.value[l];a={type:o.type,value:o.value};u.altNames.push(a);switch(o.type){case 7:a.ip=n.util.bytesToIP(o.value);break;case 8:a.oid=t.derToOid(o.value)}}else u.name==="subjectKeyIdentifier"&&(f=t.fromDer(u.value),u.subjectKeyIdentifier=n.util.bytesToHex(f.value));return u};i.certificationRequestFromAsn1=function(u,o){var c={},k=[],y,v,h,p,a,l,d,b;if(!t.validate(u,w,c,k)){l=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw l.errors=k,l;}if(typeof c.csrSignature!="string"){for(y="\0",v=0;v<c.csrSignature.length;++v)y+=t.toDer(c.csrSignature[v]).getBytes();c.csrSignature=y}if(a=t.derToOid(c.publicKeyOid),a!==i.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");if(h=i.createCertificationRequest(),h.version=c.csrVersion?c.csrVersion.charCodeAt(0):0,h.signatureOid=n.asn1.derToOid(c.csrSignatureOid),h.signatureParameters=s(h.signatureOid,c.csrSignatureParams,!0),h.siginfo.algorithmOid=n.asn1.derToOid(c.csrSignatureOid),h.siginfo.parameters=s(h.siginfo.algorithmOid,c.csrSignatureParams,!1),p=n.util.createBuffer(c.csrSignature),++p.read,h.signature=p.getBytes(),h.certificationRequestInfo=c.certificationRequestInfo,o){if(h.md=null,h.signatureOid in r){a=r[h.signatureOid];switch(a){case"sha1WithRSAEncryption":h.md=n.md.sha1.create();break;case"md5WithRSAEncryption":h.md=n.md.md5.create();break;case"sha256WithRSAEncryption":h.md=n.md.sha256.create();break;case"sha512WithRSAEncryption":h.md=n.md.sha512.create();break;case"RSASSA-PSS":h.md=n.md.sha256.create()}}if(h.md===null){l=new Error("Could not compute certification request digest. Unknown signature OID.");throw l.signatureOid=h.signatureOid,l;}d=t.toDer(h.certificationRequestInfo);h.md.update(d.getBytes())}return b=n.md.sha1.create(),h.subject.getField=function(n){return e(h.subject,n)},h.subject.addField=function(n){f([n]);h.subject.attributes.push(n)},h.subject.attributes=i.RDNAttributesAsArray(c.certificationRequestInfoSubject,b),h.subject.hash=b.digest().toHex(),h.publicKey=i.publicKeyFromAsn1(c.subjectPublicKeyInfo),h.getAttribute=function(n){return e(h,n)},h.addAttribute=function(n){f([n]);h.attributes.push(n)},h.attributes=i.CRIAttributesAsArray(c.certificationRequestInfoAttributes||[]),h};i.createCertificationRequest=function(){var u={};return u.version=0,u.signatureOid=null,u.signature=null,u.siginfo={},u.siginfo.algorithmOid=null,u.subject={},u.subject.getField=function(n){return e(u.subject,n)},u.subject.addField=function(n){f([n]);u.subject.attributes.push(n)},u.subject.attributes=[],u.subject.hash=null,u.publicKey=null,u.attributes=[],u.getAttribute=function(n){return e(u,n)},u.addAttribute=function(n){f([n]);u.attributes.push(n)},u.md=null,u.setSubject=function(n){f(n);u.subject.attributes=n;u.subject.hash=null},u.setAttributes=function(n){f(n);u.attributes=n},u.sign=function(f,e){var o,s,h;if(u.md=e||n.md.sha1.create(),o=r[u.md.algorithm+"WithRSAEncryption"],!o){s=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw s.algorithm=u.md.algorithm,s;}u.signatureOid=u.siginfo.algorithmOid=o;u.certificationRequestInfo=i.getCertificationRequestInfo(u);h=t.toDer(u.certificationRequestInfo);u.md.update(h.getBytes());u.signature=f.sign(u.md)},u.verify=function(){var h=!1,e=u.md,c,l,a,v,o,s,f;if(e===null){if(u.signatureOid in r){c=r[u.signatureOid];switch(c){case"sha1WithRSAEncryption":e=n.md.sha1.create();break;case"md5WithRSAEncryption":e=n.md.md5.create();break;case"sha256WithRSAEncryption":e=n.md.sha256.create();break;case"sha512WithRSAEncryption":e=n.md.sha512.create();break;case"RSASSA-PSS":e=n.md.sha256.create()}}if(e===null){f=new Error("Could not compute certification request digest. Unknown signature OID.");throw f.signatureOid=u.signatureOid,f;}l=u.certificationRequestInfo||i.getCertificationRequestInfo(u);a=t.toDer(l);e.update(a.getBytes())}if(e!==null){switch(u.signatureOid){case r["RSASSA-PSS"]:if(o=r[u.signatureParameters.mgf.hash.algorithmOid],o===undefined||n.md[o]===undefined){f=new Error("Unsupported MGF hash function.");throw f.oid=u.signatureParameters.mgf.hash.algorithmOid,f.name=o,f;}if(s=r[u.signatureParameters.mgf.algorithmOid],s===undefined||n.mgf[s]===undefined){f=new Error("Unsupported MGF function.");throw f.oid=u.signatureParameters.mgf.algorithmOid,f.name=s,f;}if(s=n.mgf[s].create(n.md[o].create()),o=r[u.signatureParameters.hash.algorithmOid],o===undefined||n.md[o]===undefined){f=new Error("Unsupported RSASSA-PSS hash function.");throw f.oid=u.signatureParameters.hash.algorithmOid,f.name=o,f;}v=n.pss.create(n.md[o].create(),s,u.signatureParameters.saltLength)}h=u.publicKey.verify(e.digest().getBytes(),u.signature,v)}return h},u};i.getTBSCertificate=function(r){var u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.version).getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,n.util.hexToBytes(r.serialNumber)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.siginfo.algorithmOid).getBytes()),h(r.siginfo.algorithmOid,r.siginfo.parameters)]),o(r.issuer),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(r.validity.notBefore)),t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(r.validity.notAfter))]),o(r.subject),i.publicKeyToAsn1(r.publicKey)]);return r.issuer.uniqueId&&u.value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+r.issuer.uniqueId)])),r.subject.uniqueId&&u.value.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+r.subject.uniqueId)])),r.extensions.length>0&&u.value.push(i.certificateExtensionsToAsn1(r.extensions)),u};i.getCertificationRequestInfo=function(n){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(n.version).getBytes()),o(n.subject),i.publicKeyToAsn1(n.publicKey),a(n)])};i.distinguishedNameToAsn1=function(n){return o(n)};i.certificateToAsn1=function(n){var r=n.tbsCertificate||i.getTBSCertificate(n);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[r,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.signatureOid).getBytes()),h(n.signatureOid,n.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+n.signature)])};i.certificateExtensionsToAsn1=function(n){var u=t.create(t.Class.CONTEXT_SPECIFIC,3,!0,[]),f=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),r;for(u.value.push(f),r=0;r<n.length;++r)f.value.push(i.certificateExtensionToAsn1(n[r]));return u};i.certificateExtensionToAsn1=function(n){var i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),r;return i.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.id).getBytes())),n.critical&&i.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255))),r=n.value,typeof n.value!="string"&&(r=t.toDer(r).getBytes()),i.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r)),i};i.certificationRequestToAsn1=function(n){var r=n.certificationRequestInfo||i.getCertificationRequestInfo(n);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[r,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.signatureOid).getBytes()),h(n.signatureOid,n.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+n.signature)])};i.createCaStore=function(r){function e(t){if(!t.hash){var r=n.md.sha1.create();t.attributes=i.RDNAttributesAsArray(o(t),r);t.hash=r.digest().toHex()}return u.certs[t.hash]||null}var u={certs:{}},f,s;if(u.getIssuer=function(n){return e(n.issuer)},u.addCertificate=function(t){var f,r;typeof t=="string"&&(t=n.pki.certificateFromPem(t));t.subject.hash||(f=n.md.sha1.create(),t.subject.attributes=i.RDNAttributesAsArray(o(t.subject),f),t.subject.hash=f.digest().toHex());t.subject.hash in u.certs?(r=u.certs[t.subject.hash],n.util.isArray(r)||(r=[r]),r.push(t)):u.certs[t.subject.hash]=t},u.hasCertificate=function(r){var u=e(r.subject),o,f,s;if(!u)return!1;for(n.util.isArray(u)||(u=[u]),o=t.toDer(i.certificateToAsn1(r)).getBytes(),f=0;f<u.length;++f)if(s=t.toDer(i.certificateToAsn1(u[f])).getBytes(),o===s)return!0;return!1},r)for(f=0;f<r.length;++f)s=r[f],u.addCertificate(s);return u};i.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};i.verifyCertificateChain=function(t,r,u){var h,l,g,a,k,c,v,nt,y,o;r=r.slice(0);var tt=r.slice(0),p=new Date,d=!0,f=null,w=0;do{var e=r.shift(),s=null,b=!1;if((p<e.validity.notBefore||p>e.validity.notAfter)&&(f={message:"Certificate is not valid yet or has expired.",error:i.certificateError.certificate_expired,notBefore:e.validity.notBefore,notAfter:e.validity.notAfter,now:p}),f===null){if(s=r[0]||t.getIssuer(e),s===null&&e.isIssuer(e)&&(b=!0,s=e),s){for(h=s,n.util.isArray(h)||(h=[h]),l=!1;!l&&h.length>0;){s=h.shift();try{l=s.verify(e)}catch(it){}}l||(f={message:"Certificate signature is invalid.",error:i.certificateError.bad_certificate})}f!==null||s&&!b||t.hasCertificate(e)||(f={message:"Certificate is not trusted.",error:i.certificateError.unknown_ca})}if(f===null&&s&&!e.isIssuer(s)&&(f={message:"Certificate issuer is invalid.",error:i.certificateError.bad_certificate}),f===null)for(g={keyUsage:!0,basicConstraints:!0},a=0;f===null&&a<e.extensions.length;++a)k=e.extensions[a],!k.critical||k.name in g||(f={message:"Certificate has an unsupported critical extension.",error:i.certificateError.unsupported_certificate});if(f!==null||d&&(r.length!==0||s&&!b)||(c=e.getExtension("basicConstraints"),v=e.getExtension("keyUsage"),v===null||v.keyCertSign&&c!==null||(f={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:i.certificateError.bad_certificate}),f!==null||c===null||c.cA||(f={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:i.certificateError.bad_certificate}),f===null&&v!==null&&"pathLenConstraint"in c&&(nt=w-1,nt>c.pathLenConstraint&&(f={message:"Certificate basicConstraints pathLenConstraint violated.",error:i.certificateError.bad_certificate}))),y=f===null?!0:f.error,o=u?u(y,w,tt):y,o!==!0){y===!0&&(f={message:"The application rejected the certificate.",error:i.certificateError.bad_certificate});(o||o===0)&&(typeof o=="object"&&!n.util.isArray(o)?(o.message&&(f.message=o.message),o.error&&(f.error=o.error)):typeof o=="string"&&(f.error=o));throw f;}f=null;d=!1;++w}while(r.length>0);return!0}}var i="x509",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t.pki}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/x509",["require","module","./aes","./asn1","./des","./md","./mgf","./oids","./pem","./pss","./rsa","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function r(n,t,i,r){for(var o=[],e,u,f=0;f<n.length;f++)for(e=0;e<n[f].safeBags.length;e++)if(u=n[f].safeBags[e],r===undefined||u.type===r){if(t===null){o.push(u);continue}u.attributes[t]!==undefined&&u.attributes[t].indexOf(i)>=0&&o.push(u)}return o}function f(t){var r,i;if(t.composed||t.constructed){for(r=n.util.createBuffer(),i=0;i<t.value.length;++i)r.putBytes(t.value[i].value);t.composed=t.constructed=!1;t.value=r.getBytes()}return t}function o(n,r,u,o){var l,c;if(r=t.fromDer(r,u),r.tagClass!==t.Class.UNIVERSAL||r.type!==t.Type.SEQUENCE||r.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(l=0;l<r.value.length;l++){var b=r.value[l],a={},w=[];if(!t.validate(b,e,a,w)){c=new Error("Cannot read ContentInfo.");throw c.errors=w,c;}var y={encrypted:!1},p=null,v=a.content.value[0];switch(t.derToOid(a.contentType)){case i.oids.data:if(v.tagClass!==t.Class.UNIVERSAL||v.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");p=f(v).value;break;case i.oids.encryptedData:p=s(v,o);y.encrypted=!0;break;default:c=new Error("Unsupported PKCS#12 contentType.");throw c.contentType=t.derToOid(a.contentType),c;}y.safeBags=h(p,u,o);n.safeContents.push(y)}}function s(r,u){var o={},c=[],s,e;if(!t.validate(r,n.pkcs7.asn1.encryptedDataValidator,o,c)){e=new Error("Cannot read EncryptedContentInfo.");throw e.errors=c,e;}if(s=t.derToOid(o.contentType),s!==i.oids.data){e=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw e.oid=s,e;}s=t.derToOid(o.encAlgorithm);var h=i.pbe.getCipher(s,o.encParameter,u),l=f(o.encryptedContentAsn1),a=n.util.createBuffer(l.value);if(h.update(a),!h.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return h.output.getBytes()}function h(n,r,u){var p,h,e,v,w,s,f;if(!r&&n.length===0)return[];if(n=t.fromDer(n,r),n.tagClass!==t.Class.UNIVERSAL||n.type!==t.Type.SEQUENCE||n.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(p=[],h=0;h<n.value.length;h++){var b=n.value[h],o={},l=[];if(!t.validate(b,a,o,l)){f=new Error("Cannot read SafeBag.");throw f.errors=l,f;}e={type:t.derToOid(o.bagId),attributes:c(o.bagAttributes)};p.push(e);s=o.bagValue.value[0];switch(e.type){case i.oids.pkcs8ShroudedKeyBag:if(s=i.decryptPrivateKeyInfo(s,u),s===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case i.oids.keyBag:try{e.key=i.privateKeyFromAsn1(s)}catch(k){e.key=null;e.asn1=s}continue;case i.oids.certBag:v=y;w=function(){var n,u;if(t.derToOid(o.certId)!==i.oids.x509Certificate){n=new Error("Unsupported certificate type, only X.509 supported.");throw n.oid=t.derToOid(o.certId),n;}u=t.fromDer(o.cert,r);try{e.cert=i.certificateFromAsn1(u,!0)}catch(f){e.cert=null;e.asn1=u}};break;default:f=new Error("Unsupported PKCS#12 SafeBag type.");throw f.oid=e.type,f;}if(v!==undefined&&!t.validate(s,v,o,l)){f=new Error("Cannot read PKCS#12 "+v.name);throw f.errors=l,f;}w()}return p}function c(n){var o={},u,r,s,h,f,e;if(n!==undefined)for(u=0;u<n.length;++u){if(r={},s=[],!t.validate(n[u],v,r,s)){h=new Error("Cannot read PKCS#12 BagAttribute.");throw h.errors=s,h;}if(f=t.derToOid(r.oid),i.oids[f]!==undefined)for(o[i.oids[f]]=[],e=0;e<r.values.length;++e)o[i.oids[f]].push(r.values[e].value)}return o}var t=n.asn1,i=n.pki,u=n.pkcs12=n.pkcs12||{},e={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},l={name:"PFX",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},e,{name:"PFX.macData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},a={name:"SafeBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},v={name:"Attribute",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,capture:"values"}]},y={name:"CertBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:t.Class.UNIVERSAL,type:t.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};u.pkcs12FromAsn1=function(e,s,h){var c,k,v,a,p,g;if(typeof s=="string"?(h=s,s=!0):s===undefined&&(s=!0),c={},k=[],!t.validate(e,l,c,k)){a=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw a.errors=a,a;}if(v={version:c.version.charCodeAt(0),safeContents:[],getBags:function(t){var u={},i;return"localKeyId"in t?i=t.localKeyId:"localKeyIdHex"in t&&(i=n.util.hexToBytes(t.localKeyIdHex)),i===undefined&&!("friendlyName"in t)&&"bagType"in t&&(u[t.bagType]=r(v.safeContents,null,null,t.bagType)),i!==undefined&&(u.localKeyId=r(v.safeContents,"localKeyId",i,t.bagType)),"friendlyName"in t&&(u.friendlyName=r(v.safeContents,"friendlyName",t.friendlyName,t.bagType)),u},getBagsByFriendlyName:function(n,t){return r(v.safeContents,"friendlyName",n,t)},getBagsByLocalKeyId:function(n,t){return r(v.safeContents,"localKeyId",n,t)}},c.version.charCodeAt(0)!==3){a=new Error("PKCS#12 PFX of version other than 3 not supported.");throw a.version=c.version.charCodeAt(0),a;}if(t.derToOid(c.contentType)!==i.oids.data){a=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw a.oid=t.derToOid(c.contentType),a;}if(p=c.content.value[0],p.tagClass!==t.Class.UNIVERSAL||p.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(p=f(p),c.mac){var y=null,w=0,d=t.derToOid(c.macAlgorithm);switch(d){case i.oids.sha1:y=n.md.sha1.create();w=20;break;case i.oids.sha256:y=n.md.sha256.create();w=32;break;case i.oids.sha384:y=n.md.sha384.create();w=48;break;case i.oids.sha512:y=n.md.sha512.create();w=64;break;case i.oids.md5:y=n.md.md5.create();w=16}if(y===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+d);var nt=new n.util.ByteBuffer(c.macSalt),tt="macIterations"in c?parseInt(n.util.bytesToHex(c.macIterations),16):1,it=u.generateKey(h,nt,3,tt,w,y),b=n.hmac.create();if(b.start(y,it),b.update(p.value),g=b.getMac(),g.getBytes()!==c.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?");}return o(v,p.value,s,h),v};u.toPkcs12Asn1=function(r,f,e,o){var s,v,h,c,l,y,p,w,a,nt,tt,b,k,it,rt,d,ut,ot;for(o=o||{},o.saltSize=o.saltSize||8,o.count=o.count||2048,o.algorithm=o.algorithm||o.encAlgorithm||"aes128",("useMac"in o)||(o.useMac=!0),("localKeyId"in o)||(o.localKeyId=null),("generateLocalKeyId"in o)||(o.generateLocalKeyId=!0),s=o.localKeyId,s!==null?s=n.util.hexToBytes(s):o.generateLocalKeyId&&(f?(h=n.util.isArray(f)?f[0]:f,typeof h=="string"&&(h=i.certificateFromPem(h)),c=n.md.sha1.create(),c.update(t.toDer(i.certificateToAsn1(h)).getBytes()),s=c.digest().getBytes()):s=n.random.getBytes(20)),l=[],s!==null&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.localKeyId).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,s)])])),("friendlyName"in o)&&l.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.friendlyName).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.BMPSTRING,!1,o.friendlyName)])])),l.length>0&&(v=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,l)),y=[],p=[],f!==null&&(p=n.util.isArray(f)?f:[f]),w=[],a=0;a<p.length;++a){f=p[a];typeof f=="string"&&(f=i.certificateFromPem(f));var st=a===0?v:undefined,ht=i.certificateToAsn1(f),ct=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.certBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.x509Certificate).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(ht).getBytes())])])]),st]);w.push(ct)}if(w.length>0&&(nt=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,w),tt=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(nt).getBytes())])]),y.push(tt)),b=null,r!==null&&(k=i.wrapRsaPrivateKey(i.privateKeyToAsn1(r)),b=e===null?t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.keyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[k]),v]):t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.pkcs8ShroudedKeyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[i.encryptPrivateKeyInfo(k,e,o)]),v]),it=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[b]),rt=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(it).getBytes())])]),y.push(rt)),d=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,y),o.useMac){var c=n.md.sha1.create(),ft=new n.util.ByteBuffer(n.random.getBytes(o.saltSize)),et=o.count,r=u.generateKey(e,ft,3,et,20),g=n.hmac.create();g.start(c,r);g.update(t.toDer(d).getBytes());ot=g.getMac();ut=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.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.sha1).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,ot.getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,ft.getBytes()),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(et).getBytes())])}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(3).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(d).getBytes())])]),ut])};u.generateKey=n.pbe.generatePkcs12Key}var i="pkcs12",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pkcs12",["require","module","./asn1","./hmac","./oids","./pkcs7asn1","./pbe","./random","./rsa","./sha1","./util","./x509"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var i=n.asn1,t=n.pki=n.pki||{};t.pemToDer=function(t){var i=n.pem.decode(t)[0];if(i.procType&&i.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return n.util.createBuffer(i.body)};t.privateKeyFromPem=function(r){var u=n.pem.decode(r)[0],f,e;if(u.type!=="PRIVATE KEY"&&u.type!=="RSA PRIVATE KEY"){f=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw f.headerType=u.type,f;}if(u.procType&&u.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");return e=i.fromDer(u.body),t.privateKeyFromAsn1(e)};t.privateKeyToPem=function(r,u){var f={type:"RSA PRIVATE KEY",body:i.toDer(t.privateKeyToAsn1(r)).getBytes()};return n.pem.encode(f,{maxline:u})};t.privateKeyInfoToPem=function(t,r){var u={type:"PRIVATE KEY",body:i.toDer(t).getBytes()};return n.pem.encode(u,{maxline:r})}}var i="pki",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pki",["require","module","./asn1","./oids","./pbe","./pem","./pbkdf2","./pkcs12","./pss","./rsa","./util","./x509"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var h=function(t,i,r,u){var c=n.util.createBuffer(),l=t.length>>1,a=l+(t.length&1),p=t.substr(0,a),w=t.substr(l,a),e=n.util.createBuffer(),f=n.hmac.create(),v,y,s,h,o;for(r=i+r,v=Math.ceil(u/16),y=Math.ceil(u/20),f.start("MD5",p),s=n.util.createBuffer(),e.putBytes(r),o=0;o<v;++o)f.start(null,null),f.update(e.getBytes()),e.putBuffer(f.digest()),f.start(null,null),f.update(e.bytes()+r),s.putBuffer(f.digest());for(f.start("SHA1",w),h=n.util.createBuffer(),e.clear(),e.putBytes(r),o=0;o<y;++o)f.start(null,null),f.update(e.getBytes()),e.putBuffer(f.digest()),f.start(null,null),f.update(e.bytes()+r),h.putBuffer(f.digest());return c.putBytes(n.util.xorBytes(s.getBytes(),h.getBytes(),u)),c},ri=function(){},ft=function(t,i,r){var f=n.hmac.create(),u;return f.start("SHA1",t),u=n.util.createBuffer(),u.putInt32(i[0]),u.putInt32(i[1]),u.putByte(r.type),u.putByte(r.version.major),u.putByte(r.version.minor),u.putInt16(r.length),u.putBytes(r.fragment.bytes()),f.update(u.getBytes()),f.digest().getBytes()},et=function(t,i){var u=!1,r;try{r=t.deflate(i.fragment.getBytes());i.fragment=n.util.createBuffer(r);i.length=r.length;u=!0}catch(f){}return u},ot=function(t,i){var u=!1,r;try{r=t.inflate(i.fragment.getBytes());i.fragment=n.util.createBuffer(r);i.length=r.length;u=!0}catch(f){}return u},e=function(t,i){var r=0;switch(i){case 1:r=t.getByte();break;case 2:r=t.getInt16();break;case 3:r=t.getInt24();break;case 4:r=t.getInt32()}return n.util.createBuffer(t.getBytes(r))},o=function(n,t,i){n.putInt(i.length(),t<<3);n.putBuffer(i)},i={},a,ut,v;i.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}};i.SupportedVersions=[i.Versions.TLS_1_1,i.Versions.TLS_1_0];i.Version=i.SupportedVersions[0];i.MaxFragment=15360;i.ConnectionEnd={server:0,client:1};i.PRFAlgorithm={tls_prf_sha256:0};i.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2};i.CipherType={stream:0,block:1,aead:2};i.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4};i.CompressionMethod={none:0,deflate:1};i.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24};i.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};i.Alert={};i.Alert.Level={warning:1,fatal:2};i.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};i.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};i.CipherSuites={};i.getCipherSuite=function(n){var r=null,u,t;for(u in i.CipherSuites)if(t=i.CipherSuites[u],t.id[0]===n.charCodeAt(0)&&t.id[1]===n.charCodeAt(1)){r=t;break}return r};i.handleUnexpected=function(n){var t=!n.open&&n.entity===i.ConnectionEnd.client;t||n.error(n,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.unexpected_message}})};i.handleHelloRequest=function(n){!n.handshaking&&n.handshakes>0&&(i.queue(n,i.createAlert(n,{level:i.Alert.Level.warning,description:i.Alert.Description.no_renegotiation})),i.flush(n));n.process()};i.parseHelloMessage=function(t,r,u){var f=null,s=t.entity===i.ConnectionEnd.client,o,c,h,l,a,v,p,y;if(u<38)t.error(t,{message:s?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});else{if(o=r.fragment,c=o.length(),f={version:{major:o.getByte(),minor:o.getByte()},random:n.util.createBuffer(o.getBytes(32)),session_id:e(o,1),extensions:[]},s?(f.cipher_suite=o.getBytes(2),f.compression_method=o.getByte()):(f.cipher_suites=e(o,2),f.compression_methods=e(o,1)),c=u-(c-o.length()),c>0){for(h=e(o,2);h.length()>0;)f.extensions.push({type:[h.getByte(),h.getByte()],data:e(h,2)});if(!s)for(l=0;l<f.extensions.length;++l)if(a=f.extensions[l],a.type[0]===0&&a.type[1]===0)for(v=e(a.data,2);v.length()>0;){if(p=v.getByte(),p!==0)break;t.session.extensions.server_name.serverNameList.push(e(v,2).getBytes())}}if(t.session.version&&(f.version.major!==t.session.version.major||f.version.minor!==t.session.version.minor))return t.error(t,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.protocol_version}});if(s)t.session.cipherSuite=i.getCipherSuite(f.cipher_suite);else for(y=n.util.createBuffer(f.cipher_suites.bytes());y.length()>0;)if(t.session.cipherSuite=i.getCipherSuite(y.getBytes(2)),t.session.cipherSuite!==null)break;if(t.session.cipherSuite===null)return t.error(t,{message:"No cipher suites in common.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.handshake_failure},cipherSuite:n.util.bytesToHex(f.cipher_suite)});t.session.compressionMethod=s?f.compression_method:i.CompressionMethod.none}return f};i.createSecurityParameters=function(n,t){var r=n.entity===i.ConnectionEnd.client,u=t.random.bytes(),f=r?n.session.sp.client_random:u,e=r?u:i.createRandom().getBytes();n.session.sp={entity:n.entity,prf_algorithm:i.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:n.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:f,server_random:e}};i.handleServerHello=function(n,t,r){var u=i.parseHelloMessage(n,t,r),f;if(!n.fail){if(!(u.version.minor<=n.version.minor))return n.error(n,{message:"Incompatible TLS version.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.protocol_version}});n.version.minor=u.version.minor;n.session.version=n.version;f=u.session_id.bytes();f.length>0&&f===n.session.id?(n.expect=d,n.session.resuming=!0,n.session.sp.server_random=u.random.bytes()):(n.expect=ht,n.session.resuming=!1,i.createSecurityParameters(n,u));n.session.id=f;n.process()}};i.handleClientHello=function(t,r,u){var e=i.parseHelloMessage(t,r,u),o,f,s,h;if(!t.fail){if(o=e.session_id.bytes(),f=null,t.sessionCache&&(f=t.sessionCache.getSession(o),f===null?o="":(f.version.major!==e.version.major||f.version.minor>e.version.minor)&&(f=null,o="")),o.length===0&&(o=n.random.getBytes(32)),t.session.id=o,t.session.clientHelloVersion=e.version,t.session.sp={},f)t.version=t.session.version=f.version,t.session.sp=f.sp;else{for(h=1;h<i.SupportedVersions.length;++h)if(s=i.SupportedVersions[h],s.minor<=e.version.minor)break;t.version={major:s.major,minor:s.minor};t.session.version=t.version}f!==null?(t.expect=p,t.session.resuming=!0,t.session.sp.client_random=e.random.bytes()):(t.expect=t.verifyClient!==!1?wt:y,t.session.resuming=!1,i.createSecurityParameters(t,e));t.open=!0;i.queue(t,i.createRecord(t,{type:i.ContentType.handshake,data:i.createServerHello(t)}));t.session.resuming?(i.queue(t,i.createRecord(t,{type:i.ContentType.change_cipher_spec,data:i.createChangeCipherSpec()})),t.state.pending=i.createConnectionState(t),t.state.current.write=t.state.pending.write,i.queue(t,i.createRecord(t,{type:i.ContentType.handshake,data:i.createFinished(t)}))):(i.queue(t,i.createRecord(t,{type:i.ContentType.handshake,data:i.createCertificate(t)})),t.fail||(i.queue(t,i.createRecord(t,{type:i.ContentType.handshake,data:i.createServerKeyExchange(t)})),t.verifyClient!==!1&&i.queue(t,i.createRecord(t,{type:i.ContentType.handshake,data:i.createCertificateRequest(t)})),i.queue(t,i.createRecord(t,{type:i.ContentType.handshake,data:i.createServerHelloDone(t)}))));i.flush(t);t.process()}};i.handleCertificate=function(t,r,u){var o;if(u<3)return t.error(t,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});var l=r.fragment,h={certificate_list:e(l,3)},s,c,f=[];try{while(h.certificate_list.length()>0)s=e(h.certificate_list,3),c=n.asn1.fromDer(s),s=n.pki.certificateFromAsn1(c,!0),f.push(s)}catch(a){return t.error(t,{message:"Could not parse certificate list.",cause:a,send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.bad_certificate}})}o=t.entity===i.ConnectionEnd.client;!o&&t.verifyClient!==!0||f.length!==0?f.length===0?t.expect=o?k:y:(o?t.session.serverCertificate=f[0]:t.session.clientCertificate=f[0],i.verifyCertificateChain(t,f)&&(t.expect=o?k:y)):t.error(t,{message:o?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});t.process()};i.handleServerKeyExchange=function(n,t,r){if(r>0)return n.error(n,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.unsupported_certificate}});n.expect=ct;n.process()};i.handleClientKeyExchange=function(t,r,u){var o,s;if(u<48)return t.error(t,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.unsupported_certificate}});var h=r.fragment,c={enc_pre_master_secret:e(h,2).getBytes()},f=null;if(t.getPrivateKey)try{f=t.getPrivateKey(t,t.session.serverCertificate);f=n.pki.privateKeyFromPem(f)}catch(l){t.error(t,{message:"Could not get private key.",cause:l,send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}})}if(f===null)return t.error(t,{message:"No private key set.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}});try{if(o=t.session.sp,o.pre_master_secret=f.decrypt(c.enc_pre_master_secret),s=t.session.clientHelloVersion,s.major!==o.pre_master_secret.charCodeAt(0)||s.minor!==o.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.");}catch(l){o.pre_master_secret=n.random.getBytes(48)}t.expect=p;t.session.clientCertificate!==null&&(t.expect=bt);t.process()};i.handleCertificateRequest=function(n,t,r){if(r<3)return n.error(n,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});var u=t.fragment,f={certificate_types:e(u,1),certificate_authorities:e(u,2)};n.session.certificateRequest=f;n.expect=lt;n.process()};i.handleCertificateVerify=function(t,r,u){var o,s,h,f,c;if(u<2)return t.error(t,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});o=r.fragment;o.read-=4;s=o.bytes();o.read+=4;h={signature:e(o,2).getBytes()};f=n.util.createBuffer();f.putBuffer(t.session.md5.digest());f.putBuffer(t.session.sha1.digest());f=f.getBytes();try{if(c=t.session.clientCertificate,!c.publicKey.verify(f,h.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");t.session.md5.update(s);t.session.sha1.update(s)}catch(l){return t.error(t,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.handshake_failure}})}t.expect=p;t.process()};i.handleServerHelloDone=function(t,r,u){var o;if(u>0)return t.error(t,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.record_overflow}});if(t.serverCertificate===null){var e={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.insufficient_security}},f=t.verify(t,e.alert.description,0,[]);if(f!==!0)return(f||f===0)&&(typeof f=="object"&&!n.util.isArray(f)?(f.message&&(e.message=f.message),f.alert&&(e.alert.description=f.alert)):typeof f=="number"&&(e.alert.description=f)),t.error(t,e)}if(t.session.certificateRequest!==null&&(r=i.createRecord(t,{type:i.ContentType.handshake,data:i.createCertificate(t)}),i.queue(t,r)),r=i.createRecord(t,{type:i.ContentType.handshake,data:i.createClientKeyExchange(t)}),i.queue(t,r),t.expect=yt,o=function(n,t){n.session.certificateRequest!==null&&n.session.clientCertificate!==null&&i.queue(n,i.createRecord(n,{type:i.ContentType.handshake,data:i.createCertificateVerify(n,t)}));i.queue(n,i.createRecord(n,{type:i.ContentType.change_cipher_spec,data:i.createChangeCipherSpec()}));n.state.pending=i.createConnectionState(n);n.state.current.write=n.state.pending.write;i.queue(n,i.createRecord(n,{type:i.ContentType.handshake,data:i.createFinished(n)}));n.expect=d;i.flush(n);n.process()},t.session.certificateRequest===null||t.session.clientCertificate===null)return o(t,null);i.getClientSignature(t,o)};i.handleChangeCipherSpec=function(n,t){if(t.fragment.getByte()!==1)return n.error(n,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.illegal_parameter}});var r=n.entity===i.ConnectionEnd.client;(n.session.resuming&&r||!n.session.resuming&&!r)&&(n.state.pending=i.createConnectionState(n));n.state.current.read=n.state.pending.read;(!n.session.resuming&&r||n.session.resuming&&!r)&&(n.state.pending=null);n.expect=r?at:kt;n.process()};i.handleFinished=function(t,r){var u=r.fragment,e,o;u.read-=4;e=u.bytes();u.read+=4;o=r.fragment.getBytes();u=n.util.createBuffer();u.putBuffer(t.session.md5.digest());u.putBuffer(t.session.sha1.digest());var f=t.entity===i.ConnectionEnd.client,s=f?"server finished":"client finished",c=t.session.sp,l=h;if(u=l(c.master_secret,s,u.getBytes(),12),u.getBytes()!==o)return t.error(t,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.decrypt_error}});t.session.md5.update(e);t.session.sha1.update(e);(t.session.resuming&&f||!t.session.resuming&&!f)&&(i.queue(t,i.createRecord(t,{type:i.ContentType.change_cipher_spec,data:i.createChangeCipherSpec()})),t.state.current.write=t.state.pending.write,t.state.pending=null,i.queue(t,i.createRecord(t,{type:i.ContentType.handshake,data:i.createFinished(t)})));t.expect=f?vt:dt;t.handshaking=!1;++t.handshakes;t.peerCertificate=f?t.session.serverCertificate:t.session.clientCertificate;i.flush(t);t.isConnected=!0;t.connected(t);t.process()};i.handleAlert=function(n,t){var f=t.fragment,u={level:f.getByte(),description:f.getByte()},r;switch(u.description){case i.Alert.Description.close_notify:r="Connection closed.";break;case i.Alert.Description.unexpected_message:r="Unexpected message.";break;case i.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case i.Alert.Description.decryption_failed:r="Decryption failed.";break;case i.Alert.Description.record_overflow:r="Record overflow.";break;case i.Alert.Description.decompression_failure:r="Decompression failed.";break;case i.Alert.Description.handshake_failure:r="Handshake failure.";break;case i.Alert.Description.bad_certificate:r="Bad certificate.";break;case i.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case i.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case i.Alert.Description.certificate_expired:r="Certificate expired.";break;case i.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case i.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case i.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case i.Alert.Description.access_denied:r="Access denied.";break;case i.Alert.Description.decode_error:r="Decode error.";break;case i.Alert.Description.decrypt_error:r="Decrypt error.";break;case i.Alert.Description.export_restriction:r="Export restriction.";break;case i.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case i.Alert.Description.insufficient_security:r="Insufficient security.";break;case i.Alert.Description.internal_error:r="Internal error.";break;case i.Alert.Description.user_canceled:r="User canceled.";break;case i.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(u.description===i.Alert.Description.close_notify)return n.close();n.error(n,{message:r,send:!1,origin:n.entity===i.ConnectionEnd.client?"server":"client",alert:u});n.process()};i.handleHandshake=function(t,r){var u=r.fragment,f=u.getByte(),e=u.getInt24(),o;if(e>u.length())return t.fragmented=r,r.fragment=n.util.createBuffer(),u.read-=4,t.process();t.fragmented=null;u.read-=4;o=u.bytes(e+4);u.read+=4;f in l[t.entity][t.expect]?(t.entity===i.ConnectionEnd.server&&!t.open&&!t.fail&&(t.handshaking=!0,t.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:n.md.md5.create(),sha1:n.md.sha1.create()}),f!==i.HandshakeType.hello_request&&f!==i.HandshakeType.certificate_verify&&f!==i.HandshakeType.finished&&(t.session.md5.update(o),t.session.sha1.update(o)),l[t.entity][t.expect][f](t,r,e)):i.handleUnexpected(t,r)};i.handleApplicationData=function(n,t){n.data.putBuffer(t.fragment);n.dataReady(n);n.process()};i.handleHeartbeat=function(t,r){var f=r.fragment,e=f.getByte(),o=f.getInt16(),u=f.getBytes(o);if(e===i.HeartbeatMessageType.heartbeat_request){if(t.handshaking||o>u.length)return t.process();i.queue(t,i.createRecord(t,{type:i.ContentType.heartbeat,data:i.createHeartbeat(i.HeartbeatMessageType.heartbeat_response,u)}));i.flush(t)}else if(e===i.HeartbeatMessageType.heartbeat_response){if(u!==t.expectedHeartbeatPayload)return t.process();t.heartbeatReceived&&t.heartbeatReceived(t,n.util.createBuffer(u))}t.process()};var st=0,ht=1,k=2,ct=3,lt=4,d=5,at=6,vt=7,yt=8,pt=0,wt=1,y=2,bt=3,p=4,kt=5,dt=6,t=i.handleUnexpected,g=i.handleChangeCipherSpec,r=i.handleAlert,f=i.handleHandshake,nt=i.handleApplicationData,u=i.handleHeartbeat,w=[];w[i.ConnectionEnd.client]=[[t,r,f,t,u],[t,r,f,t,u],[t,r,f,t,u],[t,r,f,t,u],[t,r,f,t,u],[g,r,t,t,u],[t,r,f,t,u],[t,r,f,nt,u],[t,r,f,t,u]];w[i.ConnectionEnd.server]=[[t,r,f,t,u],[t,r,f,t,u],[t,r,f,t,u],[t,r,f,t,u],[g,r,t,t,u],[t,r,f,t,u],[t,r,f,nt,u],[t,r,f,t,u]];var s=i.handleHelloRequest,gt=i.handleServerHello,tt=i.handleCertificate,it=i.handleServerKeyExchange,b=i.handleCertificateRequest,c=i.handleServerHelloDone,rt=i.handleFinished,l=[];l[i.ConnectionEnd.client]=[[t,t,gt,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t],[s,t,t,t,t,t,t,t,t,t,t,tt,it,b,c,t,t,t,t,t,t],[s,t,t,t,t,t,t,t,t,t,t,t,it,b,c,t,t,t,t,t,t],[s,t,t,t,t,t,t,t,t,t,t,t,t,b,c,t,t,t,t,t,t],[s,t,t,t,t,t,t,t,t,t,t,t,t,t,c,t,t,t,t,t,t],[s,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t],[s,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,rt],[s,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t],[s,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t]];var ni=i.handleClientHello,ti=i.handleClientKeyExchange,ii=i.handleCertificateVerify;l[i.ConnectionEnd.server]=[[t,ni,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t],[t,t,t,t,t,t,t,t,t,t,t,tt,t,t,t,t,t,t,t,t,t],[t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,ti,t,t,t,t],[t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,ii,t,t,t,t,t],[t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t],[t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,rt],[t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t],[t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t]];i.generateKeys=function(n,t){var s=h,f=t.client_random+t.server_random,e,o,r,u;return n.session.resuming||(t.master_secret=s(t.pre_master_secret,"master secret",f,48).bytes(),t.pre_master_secret=null),f=t.server_random+t.client_random,e=2*t.mac_key_length+2*t.enc_key_length,o=n.version.major===i.Versions.TLS_1_0.major&&n.version.minor===i.Versions.TLS_1_0.minor,o&&(e+=2*t.fixed_iv_length),r=s(t.master_secret,"key expansion",f,e),u={client_write_MAC_key:r.getBytes(t.mac_key_length),server_write_MAC_key:r.getBytes(t.mac_key_length),client_write_key:r.getBytes(t.enc_key_length),server_write_key:r.getBytes(t.enc_key_length)},o&&(u.client_write_IV=r.getBytes(t.fixed_iv_length),u.server_write_IV=r.getBytes(t.fixed_iv_length)),u};i.createConnectionState=function(n){var u=n.entity===i.ConnectionEnd.client,f=function(){var n={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(){return!0},compressionState:null,compressFunction:function(){return!0},updateSequenceNumber:function(){n.sequenceNumber[1]===4294967295?(n.sequenceNumber[1]=0,++n.sequenceNumber[0]):++n.sequenceNumber[1]}};return n},t={read:f(),write:f()},r;if(t.read.update=function(n,r){return t.read.cipherFunction(r,t.read)?t.read.compressFunction(n,r,t.read)||n.error(n,{message:"Could not decompress record.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.decompression_failure}}):n.error(n,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.bad_record_mac}}),!n.fail},t.write.update=function(n,r){return t.write.compressFunction(n,r,t.write)?t.write.cipherFunction(r,t.write)||n.error(n,{message:"Could not encrypt record.",send:!1,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}}):n.error(n,{message:"Could not compress record.",send:!1,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}}),!n.fail},n.session){r=n.session.sp;n.session.cipherSuite.initSecurityParameters(r);r.keys=i.generateKeys(n,r);t.read.macKey=u?r.keys.server_write_MAC_key:r.keys.client_write_MAC_key;t.write.macKey=u?r.keys.client_write_MAC_key:r.keys.server_write_MAC_key;n.session.cipherSuite.initConnectionState(t,n,r);switch(r.compression_algorithm){case i.CompressionMethod.none:break;case i.CompressionMethod.deflate:t.read.compressFunction=ot;t.write.compressFunction=et;break;default:throw new Error("Unsupported compression algorithm.");}}return t};i.createRandom=function(){var i=new Date,r=+i+i.getTimezoneOffset()*6e4,t=n.util.createBuffer();return t.putInt32(r),t.putBytes(n.random.getBytes(28)),t};i.createRecord=function(n,t){if(!t.data)return null;return{type:t.type,version:{major:n.version.major,minor:n.version.minor},length:t.data.length(),fragment:t.data}};i.createAlert=function(t,r){var u=n.util.createBuffer();return u.putByte(r.level),u.putByte(r.description),i.createRecord(t,{type:i.ContentType.alert,data:u})};i.createClientHello=function(t){var u,s,a,y,h,p,c,f,l,v,e;for(t.session.clientHelloVersion={major:t.version.major,minor:t.version.minor},u=n.util.createBuffer(),s=0;s<t.cipherSuites.length;++s)a=t.cipherSuites[s],u.putByte(a.id[0]),u.putByte(a.id[1]);y=u.length();h=n.util.createBuffer();h.putByte(i.CompressionMethod.none);p=h.length();c=n.util.createBuffer();t.virtualHost&&(f=n.util.createBuffer(),f.putByte(0),f.putByte(0),l=n.util.createBuffer(),l.putByte(0),o(l,2,n.util.createBuffer(t.virtualHost)),v=n.util.createBuffer(),o(v,2,l),o(f,2,v),c.putBuffer(f));e=c.length();e>0&&(e+=2);var w=t.session.id,b=w.length+1+2+4+28+2+y+1+p+e,r=n.util.createBuffer();return r.putByte(i.HandshakeType.client_hello),r.putInt24(b),r.putByte(t.version.major),r.putByte(t.version.minor),r.putBytes(t.session.sp.client_random),o(r,1,n.util.createBuffer(w)),o(r,2,u),o(r,1,h),e>0&&o(r,2,c),r};i.createServerHello=function(t){var u=t.session.id,f=u.length+1+2+4+28+2+1,r=n.util.createBuffer();return r.putByte(i.HandshakeType.server_hello),r.putInt24(f),r.putByte(t.version.major),r.putByte(t.version.minor),r.putBytes(t.session.sp.server_random),o(r,1,n.util.createBuffer(u)),r.putByte(t.session.cipherSuite.id[0]),r.putByte(t.session.cipherSuite.id[1]),r.putByte(t.session.compressionMethod),r};i.createCertificate=function(t){var v=t.entity===i.ConnectionEnd.client,r=null,y,e,s,h,u,c,l,a,p,f;if(t.getCertificate&&(y=v?t.session.certificateRequest:t.session.extensions.server_name.serverNameList,r=t.getCertificate(t,y)),e=n.util.createBuffer(),r!==null)try{for(n.util.isArray(r)||(r=[r]),s=null,h=0;h<r.length;++h){if(u=n.pem.decode(r[h])[0],u.type!=="CERTIFICATE"&&u.type!=="X509 CERTIFICATE"&&u.type!=="TRUSTED CERTIFICATE"){c=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw c.headerType=u.type,c;}if(u.procType&&u.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");l=n.util.createBuffer(u.body);s===null&&(s=n.asn1.fromDer(l.bytes(),!1));a=n.util.createBuffer();o(a,3,l);e.putBuffer(a)}r=n.pki.certificateFromAsn1(s);v?t.session.clientCertificate=r:t.session.serverCertificate=r}catch(w){return t.error(t,{message:"Could not send certificate list.",cause:w,send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.bad_certificate}})}return p=3+e.length(),f=n.util.createBuffer(),f.putByte(i.HandshakeType.certificate),f.putInt24(p),o(f,3,e),f};i.createClientKeyExchange=function(t){var r=n.util.createBuffer(),f,e,o,u;return r.putByte(t.session.clientHelloVersion.major),r.putByte(t.session.clientHelloVersion.minor),r.putBytes(n.random.getBytes(46)),f=t.session.sp,f.pre_master_secret=r.getBytes(),e=t.session.serverCertificate.publicKey,r=e.encrypt(f.pre_master_secret),o=r.length+2,u=n.util.createBuffer(),u.putByte(i.HandshakeType.client_key_exchange),u.putInt24(o),u.putInt16(r.length),u.putBytes(r),u};i.createServerKeyExchange=function(){var r=0,t=n.util.createBuffer();return r>0&&(t.putByte(i.HandshakeType.server_key_exchange),t.putInt24(r)),t};i.getClientSignature=function(t,r){var u=n.util.createBuffer();u.putBuffer(t.session.md5.digest());u.putBuffer(t.session.sha1.digest());u=u.getBytes();t.getSignature=t.getSignature||function(t,r,u){var f=null;if(t.getPrivateKey)try{f=t.getPrivateKey(t,t.session.clientCertificate);f=n.pki.privateKeyFromPem(f)}catch(e){t.error(t,{message:"Could not get private key.",cause:e,send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}})}f===null?t.error(t,{message:"No private key set.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.internal_error}}):r=f.sign(r,null);u(t,r)};t.getSignature(t,u,r)};i.createCertificateVerify=function(t,r){var f=r.length+2,u=n.util.createBuffer();return u.putByte(i.HandshakeType.certificate_verify),u.putInt24(f),u.putInt16(r.length),u.putBytes(r),u};i.createCertificateRequest=function(t){var f=n.util.createBuffer(),u,e,s,h,c,r;f.putByte(1);u=n.util.createBuffer();for(e in t.caStore.certs)s=t.caStore.certs[e],h=n.pki.distinguishedNameToAsn1(s.subject),u.putBuffer(n.asn1.toDer(h));return c=1+f.length()+2+u.length(),r=n.util.createBuffer(),r.putByte(i.HandshakeType.certificate_request),r.putInt24(c),o(r,1,f),o(r,2,u),r};i.createServerHelloDone=function(){var t=n.util.createBuffer();return t.putByte(i.HandshakeType.server_hello_done),t.putInt24(0),t};i.createChangeCipherSpec=function(){var t=n.util.createBuffer();return t.putByte(1),t};i.createFinished=function(t){var r=n.util.createBuffer(),u;r.putBuffer(t.session.md5.digest());r.putBuffer(t.session.sha1.digest());var f=t.entity===i.ConnectionEnd.client,e=t.session.sp,o=h,s=f?"client finished":"server finished";return r=o(e.master_secret,s,r.getBytes(),12),u=n.util.createBuffer(),u.putByte(i.HandshakeType.finished),u.putInt24(r.length()),u.putBuffer(r),u};i.createHeartbeat=function(t,i,r){var u,f,e;return typeof r=="undefined"&&(r=i.length),u=n.util.createBuffer(),u.putByte(t),u.putInt16(r),u.putBytes(i),f=u.length(),e=Math.max(16,f-r-3),u.putBytes(n.random.getBytes(e)),u};i.queue=function(t,r){var e,f,u,o,s,h;if(r){if(r.type===i.ContentType.handshake&&(e=r.fragment.bytes(),t.session.md5.update(e),t.session.sha1.update(e),e=null),r.fragment.length()<=i.MaxFragment)f=[r];else{for(f=[],u=r.fragment.bytes();u.length>i.MaxFragment;)f.push(i.createRecord(t,{type:r.type,data:n.util.createBuffer(u.slice(0,i.MaxFragment))})),u=u.slice(i.MaxFragment);u.length>0&&f.push(i.createRecord(t,{type:r.type,data:n.util.createBuffer(u)}))}for(o=0;o<f.length&&!t.fail;++o)s=f[o],h=t.state.current.write,h.update(t,s)&&t.records.push(s)}};i.flush=function(n){for(var i,t=0;t<n.records.length;++t)i=n.records[t],n.tlsData.putByte(i.type),n.tlsData.putByte(i.version.major),n.tlsData.putByte(i.version.minor),n.tlsData.putInt16(i.fragment.length()),n.tlsData.putBuffer(n.records[t].fragment);return n.records=[],n.tlsDataReady(n)};a=function(t){switch(t){case!0:return!0;case n.pki.certificateError.bad_certificate:return i.Alert.Description.bad_certificate;case n.pki.certificateError.unsupported_certificate:return i.Alert.Description.unsupported_certificate;case n.pki.certificateError.certificate_revoked:return i.Alert.Description.certificate_revoked;case n.pki.certificateError.certificate_expired:return i.Alert.Description.certificate_expired;case n.pki.certificateError.certificate_unknown:return i.Alert.Description.certificate_unknown;case n.pki.certificateError.unknown_ca:return i.Alert.Description.unknown_ca;default:return i.Alert.Description.bad_certificate}};ut=function(t){switch(t){case!0:return!0;case i.Alert.Description.bad_certificate:return n.pki.certificateError.bad_certificate;case i.Alert.Description.unsupported_certificate:return n.pki.certificateError.unsupported_certificate;case i.Alert.Description.certificate_revoked:return n.pki.certificateError.certificate_revoked;case i.Alert.Description.certificate_expired:return n.pki.certificateError.certificate_expired;case i.Alert.Description.certificate_unknown:return n.pki.certificateError.certificate_unknown;case i.Alert.Description.unknown_ca:return n.pki.certificateError.unknown_ca;default:return n.pki.certificateError.bad_certificate}};i.verifyCertificateChain=function(t,r){try{n.pki.verifyCertificateChain(t.caStore,r,function(r,u,f){var s=a(r),e=t.verify(t,r,u,f),o;if(e!==!0){if(typeof e=="object"&&!n.util.isArray(e)){o=new Error("The application rejected the certificate.");throw o.send=!0,o.alert={level:i.Alert.Level.fatal,description:i.Alert.Description.bad_certificate},e.message&&(o.message=e.message),e.alert&&(o.alert.description=e.alert),o;}e!==r&&(e=ut(e))}return e})}catch(f){var u=f;(typeof u!="object"||n.util.isArray(u))&&(u={send:!0,alert:{level:i.Alert.Level.fatal,description:a(f)}});"send"in u||(u.send=!0);"alert"in u||(u.alert={level:i.Alert.Level.fatal,description:a(u.error)});t.error(t,u)}return!t.fail};i.createSessionCache=function(t,i){var r=null,u;if(t&&t.getSession&&t.setSession&&t.order)r=t;else{r={};r.cache=t||{};r.capacity=Math.max(i||100,1);r.order=[];for(u in t)r.order.length<=i?r.order.push(u):delete t[u];r.getSession=function(t){var f=null,i=null,u;if(t?i=n.util.bytesToHex(t):r.order.length>0&&(i=r.order[0]),i!==null&&i in r.cache){f=r.cache[i];delete r.cache[i];for(u in r.order)if(r.order[u]===i){r.order.splice(u,1);break}}return f};r.setSession=function(t,i){var u;r.order.length===r.capacity&&(u=r.order.shift(),delete r.cache[u]);u=n.util.bytesToHex(t);r.order.push(u);r.cache[u]=i}}return r};i.createConnection=function(t){var f=null,u,e;if(f=t.caStore?n.util.isArray(t.caStore)?n.pki.createCaStore(t.caStore):t.caStore:n.pki.createCaStore(),u=t.cipherSuites||null,u===null){u=[];for(e in i.CipherSuites)u.push(i.CipherSuites[e])}var o=t.server||!1?i.ConnectionEnd.server:i.ConnectionEnd.client,s=t.sessionCache?i.createSessionCache(t.sessionCache):null,r={version:{major:i.Version.major,minor:i.Version.minor},entity:o,sessionId:t.sessionId,caStore:f,sessionCache:s,cipherSuites:u,connected:t.connected,virtualHost:t.virtualHost||null,verifyClient:t.verifyClient||!1,verify:t.verify||function(n,t){return t},getCertificate:t.getCertificate||null,getPrivateKey:t.getPrivateKey||null,getSignature:t.getSignature||null,input:n.util.createBuffer(),tlsData:n.util.createBuffer(),data:n.util.createBuffer(),tlsDataReady:t.tlsDataReady,dataReady:t.dataReady,heartbeatReceived:t.heartbeatReceived,closed:t.closed,error:function(n,r){r.origin=r.origin||(n.entity===i.ConnectionEnd.client?"client":"server");r.send&&(i.queue(n,i.createAlert(n,r.alert)),i.flush(n));var u=r.fatal!==!1;u&&(n.fail=!0);t.error(n,r);u&&n.close(!1)},deflate:t.deflate||null,inflate:t.inflate||null};r.reset=function(n){r.version={major:i.Version.major,minor:i.Version.minor};r.record=null;r.session=null;r.peerCertificate=null;r.state={pending:null,current:null};r.expect=r.entity===i.ConnectionEnd.client?st:pt;r.fragmented=null;r.records=[];r.open=!1;r.handshakes=0;r.handshaking=!1;r.isConnected=!1;r.fail=!n&&typeof n!="undefined";r.input.clear();r.tlsData.clear();r.data.clear();r.state.current=i.createConnectionState(r)};r.reset();var h=function(n,t){var r=t.type-i.ContentType.change_cipher_spec,u=w[n.entity][n.expect];r in u?u[r](n,t):i.handleUnexpected(n,t)},c=function(t){var f=0,r=t.input,e=r.length(),u;return e<5?f=5-e:(t.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:n.util.createBuffer(),ready:!1},u=t.record.version.major===t.version.major,u&&t.session&&t.session.version&&(u=t.record.version.minor===t.version.minor),u||t.error(t,{message:"Incompatible TLS version.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.protocol_version}})),f},l=function(n){var r=0,t=n.input,u=t.length(),f;return u<n.record.length?r=n.record.length-u:(n.record.fragment.putBytes(t.getBytes(n.record.length)),t.compact(),f=n.state.current.read,f.update(n,n.record)&&(n.fragmented!==null&&(n.fragmented.type===n.record.type?(n.fragmented.fragment.putBuffer(n.record.fragment),n.record=n.fragmented):n.error(n,{message:"Invalid fragmented record.",send:!0,alert:{level:i.Alert.Level.fatal,description:i.Alert.Description.unexpected_message}})),n.record.ready=!0)),r};return r.handshake=function(t){if(r.entity!==i.ConnectionEnd.client)r.error(r,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(r.handshaking)r.error(r,{message:"Handshake already in progress.",fatal:!1});else{r.fail&&!r.open&&r.handshakes===0&&(r.fail=!1);r.handshaking=!0;t=t||"";var u=null;t.length>0&&(r.sessionCache&&(u=r.sessionCache.getSession(t)),u===null&&(t=""));t.length===0&&r.sessionCache&&(u=r.sessionCache.getSession(),u!==null&&(t=u.id));r.session={id:t,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:n.md.md5.create(),sha1:n.md.sha1.create()};u&&(r.version=u.version,r.session.sp=u.sp);r.session.sp.client_random=i.createRandom().getBytes();r.open=!0;i.queue(r,i.createRecord(r,{type:i.ContentType.handshake,data:i.createClientHello(r)}));i.flush(r)}},r.process=function(n){var t=0;return n&&r.input.putBytes(n),r.fail||(r.record!==null&&r.record.ready&&r.record.fragment.isEmpty()&&(r.record=null),r.record===null&&(t=c(r)),!r.fail&&r.record!==null&&!r.record.ready&&(t=l(r)),!r.fail&&r.record!==null&&r.record.ready&&h(r,r.record)),t},r.prepare=function(t){return i.queue(r,i.createRecord(r,{type:i.ContentType.application_data,data:n.util.createBuffer(t)})),i.flush(r)},r.prepareHeartbeatRequest=function(t,u){return t instanceof n.util.ByteBuffer&&(t=t.bytes()),typeof u=="undefined"&&(u=t.length),r.expectedHeartbeatPayload=t,i.queue(r,i.createRecord(r,{type:i.ContentType.heartbeat,data:i.createHeartbeat(i.HeartbeatMessageType.heartbeat_request,t,u)})),i.flush(r)},r.close=function(n){if(!r.fail&&r.sessionCache&&r.session){var t={id:r.session.id,version:r.session.version,sp:r.session.sp};t.sp.keys=null;r.sessionCache.setSession(t.id,t)}r.open&&(r.open=!1,r.input.clear(),(r.isConnected||r.handshaking)&&(r.isConnected=r.handshaking=!1,i.queue(r,i.createAlert(r,{level:i.Alert.Level.warning,description:i.Alert.Description.close_notify})),i.flush(r)),r.closed(r));r.reset(n)},r};n.tls=n.tls||{};for(v in i)typeof i[v]!="function"&&(n.tls[v]=i[v]);n.tls.prf_tls1=h;n.tls.hmac_sha1=ft;n.tls.createSessionCache=i.createSessionCache;n.tls.createConnection=i.createConnection}var i="tls",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/tls",["require","module","./asn1","./hmac","./md","./pem","./pki","./random","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function i(i,r,f){var e=r.entity===n.tls.ConnectionEnd.client;i.read.cipherState={init:!1,cipher:n.cipher.createDecipher("AES-CBC",e?f.keys.server_write_key:f.keys.client_write_key),iv:e?f.keys.server_write_IV:f.keys.client_write_IV};i.write.cipherState={init:!1,cipher:n.cipher.createCipher("AES-CBC",e?f.keys.client_write_key:f.keys.server_write_key),iv:e?f.keys.client_write_IV:f.keys.server_write_IV};i.read.cipherFunction=o;i.write.cipherFunction=u;i.read.macLength=i.write.macLength=f.mac_length;i.read.macFunction=i.write.macFunction=t.hmac_sha1}function u(i,r){var o=!1,s=r.macFunction(r.macKey,r.sequenceNumber,i),e,u;return i.fragment.putBytes(s),r.updateSequenceNumber(),e=i.version.minor===t.Versions.TLS_1_0.minor?r.cipherState.init?null:r.cipherState.iv:n.random.getBytesSync(16),r.cipherState.init=!0,u=r.cipherState.cipher,u.start({iv:e}),i.version.minor>=t.Versions.TLS_1_1.minor&&u.output.putBytes(e),u.update(i.fragment),u.finish(f)&&(i.fragment=u.output,i.length=i.fragment.length(),o=!0),o}function f(n,t,i){if(!i){var r=n-t.length()%n;t.fillWithByte(r-1,r)}return!0}function e(n,t,i){var r=!0,e,u,f;if(i){for(e=t.length(),u=t.last(),f=e-1-u;f<e-1;++f)r=r&&t.at(f)==u;r&&t.truncate(u+1)}return r}function o(i,u){var o=!1,c,f,v;++r;c=i.version.minor===t.Versions.TLS_1_0.minor?u.cipherState.init?null:u.cipherState.iv:i.fragment.getBytes(16);u.cipherState.init=!0;f=u.cipherState.cipher;f.start({iv:c});f.update(i.fragment);o=f.finish(e);var h=u.macLength,l=n.random.getBytesSync(h),a=f.output.length();return a>=h?(i.fragment=f.output.getBytes(a-h),l=f.output.getBytes(h)):i.fragment=f.output.getBytes(),i.fragment=n.util.createBuffer(i.fragment),i.length=i.fragment.length(),v=u.macFunction(u.macKey,u.sequenceNumber,i),u.updateSequenceNumber(),o=s(u.macKey,l,v)&&o,o}function s(t,i,r){var u=n.hmac.create();return u.start("SHA1",t),u.update(i),i=u.digest().getBytes(),u.start(null,null),u.update(r),r=u.digest().getBytes(),i===r}var t=n.tls,r;t.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(n){n.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes;n.cipher_type=t.CipherType.block;n.enc_key_length=16;n.block_length=16;n.fixed_iv_length=16;n.record_iv_length=16;n.mac_algorithm=t.MACAlgorithm.hmac_sha1;n.mac_length=20;n.mac_key_length=20},initConnectionState:i};t.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(n){n.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes;n.cipher_type=t.CipherType.block;n.enc_key_length=32;n.block_length=16;n.fixed_iv_length=16;n.record_iv_length=16;n.mac_algorithm=t.MACAlgorithm.hmac_sha1;n.mac_length=20;n.mac_key_length=20},initConnectionState:i};r=0}var i="aesCipherSuites",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/aesCipherSuites",["require","module","./aes","./tls"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){n.debug=n.debug||{};n.debug.storage={};n.debug.get=function(t,i){var r;return typeof t=="undefined"?r=n.debug.storage:t in n.debug.storage&&(r=typeof i=="undefined"?n.debug.storage[t]:n.debug.storage[t][i]),r};n.debug.set=function(t,i,r){t in n.debug.storage||(n.debug.storage[t]={});n.debug.storage[t][i]=r};n.debug.clear=function(t,i){typeof t=="undefined"?n.debug.storage={}:t in n.debug.storage&&(typeof i=="undefined"?delete n.debug.storage[t]:delete n.debug.storage[t][i])}}var i="debug",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/debug",["require","module"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function t(t,i,r,u){t.generate=function(t,f){for(var e=new n.util.ByteBuffer,c=Math.ceil(f/u)+r,s=new n.util.ByteBuffer,h,o=r;o<c;++o)s.putInt32(o),i.start(),i.update(t+s.getBytes()),h=i.digest(),e.putBytes(h.getBytes(u));return e.truncate(e.length()-f),e.getBytes()}}n.kem=n.kem||{};var i=n.jsbn.BigInteger;n.kem.rsa={};n.kem.rsa.create=function(t,r){r=r||{};var f=r.prng||n.random,u={};return u.encrypt=function(r,u){var s=Math.ceil(r.n.bitLength()/8),e,o,h,c;do e=new i(n.util.bytesToHex(f.getBytesSync(s)),16).mod(r.n);while(e.equals(i.ZERO));return e=n.util.hexToBytes(e.toString(16)),o=s-e.length,o>0&&(e=n.util.fillString(String.fromCharCode(0),o)+e),h=r.encrypt(e,"NONE"),c=t.generate(e,u),{encapsulation:h,key:c}},u.decrypt=function(n,i,r){var u=n.decrypt(i,"NONE");return t.generate(u,r)},u};n.kem.kdf1=function(n,i){t(this,n,0,i||n.digestLength)};n.kem.kdf2=function(n,i){t(this,n,1,i||n.digestLength)}}var i="kem",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/kem",["require","module","./util","./random","./jsbn"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var s,h,t,r,c,u,f,l;n.log=n.log||{};n.log.levels=["none","error","warning","info","debug","verbose","max"];var e={},o=[],i=null;for(n.log.LEVEL_LOCKED=2,n.log.NO_LEVEL_CHECK=4,n.log.INTERPOLATE=8,t=0;t<n.log.levels.length;++t)s=n.log.levels[t],e[s]={index:t,name:s.toUpperCase()};for(n.log.logMessage=function(t){for(var f=e[t.level].index,i,u,r=0;r<o.length;++r)i=o[r],i.flags&n.log.NO_LEVEL_CHECK?i.f(t):(u=e[i.level].index,f<=u&&i.f(i,t))},n.log.prepareStandard=function(n){"standard"in n||(n.standard=e[n.level].name+" ["+n.category+"] "+n.message)},n.log.prepareFull=function(t){if(!("full"in t)){var i=[t.message];i=i.concat([]||t.arguments);t.full=n.util.format.apply(this,i)}},n.log.prepareStandardFull=function(t){"standardFull"in t||(n.log.prepareStandard(t),t.standardFull=t.standard)},h=["error","warning","info","debug","verbose"],t=0;t<h.length;++t)(function(t){n.log[t]=function(i,r){var u=Array.prototype.slice.call(arguments).slice(2),f={timestamp:new Date,level:t,category:i,message:r,arguments:u};n.log.logMessage(f)}})(h[t]);n.log.makeLogger=function(t){var i={flags:0,f:t};return n.log.setLevel(i,"none"),i};n.log.setLevel=function(t,i){var u=!1,r,f;if(t&&!(t.flags&n.log.LEVEL_LOCKED))for(r=0;r<n.log.levels.length;++r)if(f=n.log.levels[r],i==f){t.level=i;u=!0;break}return u};n.log.lock=function(t,i){typeof i=="undefined"||i?t.flags|=n.log.LEVEL_LOCKED:t.flags&=~n.log.LEVEL_LOCKED};n.log.addLogger=function(n){o.push(n)};typeof console!="undefined"&&"log"in console?(console.error&&console.warn&&console.info&&console.debug?(c={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},u=function(t,i){n.log.prepareStandard(i);var u=c[i.level],r=[i.standard];r=r.concat(i.arguments.slice());u.apply(console,r)},r=n.log.makeLogger(u)):(u=function(t,i){n.log.prepareStandardFull(i);console.log(i.standardFull)},r=n.log.makeLogger(u)),n.log.setLevel(r,"debug"),n.log.addLogger(r),i=r):console={log:function(){}};i!==null&&(f=n.util.getQueryVariables(),"console.level"in f&&n.log.setLevel(i,f["console.level"].slice(-1)[0]),"console.lock"in f&&(l=f["console.lock"].slice(-1)[0],l=="true"&&n.log.lock(i)));n.log.consoleLogger=i}var i="log",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/log",["require","module","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function e(r){var u={},e=[],f;if(!t.validate(r,i.asn1.recipientInfoValidator,u,e)){f=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw f.errors=e,f;}return{version:u.version.charCodeAt(0),issuer:n.pki.RDNAttributesAsArray(u.issuer),serialNumber:n.util.createBuffer(u.serial).toHex(),encryptedContent:{algorithm:t.derToOid(u.encAlgorithm),parameter:u.encParameter.value,content:u.encKey}}}function o(i){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(i.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n.pki.distinguishedNameToAsn1({attributes:i.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,n.util.hexToBytes(i.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.encryptedContent.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,i.encryptedContent.content)])}function s(n){for(var i=[],t=0;t<n.length;++t)i.push(e(n[t]));return i}function h(n){for(var i=[],t=0;t<n.length;++t)i.push(o(n[t]));return i}function c(i){var u=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(i.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n.pki.distinguishedNameToAsn1({attributes:i.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,n.util.hexToBytes(i.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.digestAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])]),e,f,o;if(i.authenticatedAttributesAsn1&&u.value.push(i.authenticatedAttributesAsn1),u.value.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.signatureAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])),u.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,i.signature)),i.unauthenticatedAttributes.length>0){for(e=t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[]),f=0;f<i.unauthenticatedAttributes.length;++f)o=i.unauthenticatedAttributes[f],e.values.push(r(o));u.value.push(e)}return u}function l(n){for(var i=[],t=0;t<n.length;++t)i.push(c(n[t]));return i}function r(i){var u,f;if(i.type===n.pki.oids.contentType)u=t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.value).getBytes());else if(i.type===n.pki.oids.messageDigest)u=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,i.value.bytes());else if(i.type===n.pki.oids.signingTime){var e=new Date("Jan 1, 1950 00:00:00Z"),o=new Date("Jan 1, 2050 00:00:00Z"),r=i.value;typeof r=="string"&&(f=Date.parse(r),r=isNaN(f)?r.length===13?t.utcTimeToDate(r):t.generalizedTimeToDate(r):new Date(f));u=r>=e&&r<o?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(r)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(r))}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[u])])}function a(i){return[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.pki.oids.data).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,i.parameter.getBytes())]),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,i.content.getBytes())])]}function u(i,r,u){var f={},s,h,o,e;if(!t.validate(r,u,f,[])){s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s;}if(h=t.derToOid(f.contentType),h!==n.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(f.encryptedContent){if(o="",n.util.isArray(f.encryptedContent))for(e=0;e<f.encryptedContent.length;++e){if(f.encryptedContent[e].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=f.encryptedContent[e].value}else o=f.encryptedContent;i.encryptedContent={algorithm:t.derToOid(f.encAlgorithm),parameter:n.util.createBuffer(f.encParameter.value),content:n.util.createBuffer(o)}}if(f.content){if(o="",n.util.isArray(f.content))for(e=0;e<f.content.length;++e){if(f.content[e].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=f.content[e].value}else o=f.content;i.content=n.util.createBuffer(o)}return i.version=f.version.charCodeAt(0),i.rawCapture=f,f}function f(t){if(t.encryptedContent.key===undefined)throw new Error("Symmetric key not available.");if(t.content===undefined){var i;switch(t.encryptedContent.algorithm){case n.pki.oids["aes128-CBC"]:case n.pki.oids["aes192-CBC"]:case n.pki.oids["aes256-CBC"]:i=n.aes.createDecryptionCipher(t.encryptedContent.key);break;case n.pki.oids.desCBC:case n.pki.oids["des-EDE3-CBC"]:i=n.des.createDecryptionCipher(t.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+t.encryptedContent.algorithm);}if(i.start(t.encryptedContent.parameter),i.update(t.encryptedContent.content),!i.finish())throw new Error("Symmetric decryption failed.");t.content=i.output}}var t=n.asn1,i=n.pkcs7=n.pkcs7||{};i.messageFromPem=function(r){var u=n.pem.decode(r)[0],f,e;if(u.type!=="PKCS7"){f=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw f.headerType=u.type,f;}if(u.procType&&u.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");return e=t.fromDer(u.body),i.messageFromAsn1(e)};i.messageToPem=function(i,r){var u={type:"PKCS7",body:t.toDer(i.toAsn1()).getBytes()};return n.pem.encode(u,{maxline:r})};i.messageFromAsn1=function(r){var f={},s=[],e,o,u;if(!t.validate(r,i.asn1.contentInfoValidator,f,s)){e=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw e.errors=s,e;}o=t.derToOid(f.contentType);switch(o){case n.pki.oids.envelopedData:u=i.createEnvelopedData();break;case n.pki.oids.encryptedData:u=i.createEncryptedData();break;case n.pki.oids.signedData:u=i.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+o+" is not (yet) supported.");}return u.fromAsn1(f.content.value[0]),u};i.createSignedData=function(){function e(){for(var r={},e,i,u=0;u<f.signers.length;++u)e=f.signers[u],i=e.digestAlgorithm,i in r||(r[i]=n.md[n.pki.oids[i]].create()),e.md=e.authenticatedAttributes.length===0?r[i]:n.md[n.pki.oids[i]].create();f.digestAlgorithmIdentifiers=[];for(i in r)f.digestAlgorithmIdentifiers.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]));return r}function o(i){var v,s,e,y,p,h,u,a,c,o;if(f.contentInfo.value.length<2)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");v=t.derToOid(f.contentInfo.value[0].value);s=f.contentInfo.value[1];s=s.value[0];e=t.toDer(s);e.getByte();t.getBerValueLength(e);e=e.getBytes();for(y in i)i[y].start().update(e);for(p=new Date,h=0;h<f.signers.length;++h){if(u=f.signers[h],u.authenticatedAttributes.length===0){if(v!==n.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.");}else{for(u.authenticatedAttributesAsn1=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]),a=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[]),c=0;c<u.authenticatedAttributes.length;++c)o=u.authenticatedAttributes[c],o.type===n.pki.oids.messageDigest?o.value=i[u.digestAlgorithm].digest():o.type===n.pki.oids.signingTime&&(o.value||(o.value=p)),a.value.push(r(o)),u.authenticatedAttributesAsn1.value.push(r(o));e=t.toDer(a).getBytes();u.md.start().update(e)}u.signature=u.key.sign(u.md,"RSASSA-PKCS1-V1_5")}f.signerInfos=l(f.signers)}var f=null;return f={type:n.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){var e,r;for(u(f,t,i.asn1.signedDataValidator),f.certificates=[],f.crls=[],f.digestAlgorithmIdentifiers=[],f.contentInfo=null,f.signerInfos=[],e=f.rawCapture.certificates.value,r=0;r<e.length;++r)f.certificates.push(n.pki.certificateFromAsn1(e[r]))},toAsn1:function(){var r,u,e,i;for(f.contentInfo||f.sign(),r=[],u=0;u<f.certificates.length;++u)r.push(n.pki.certificateToAsn1(f.certificates[u]));return e=[],i=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(f.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,f.digestAlgorithmIdentifiers),f.contentInfo])]),r.length>0&&i.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,r)),e.length>0&&i.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,e)),i.value[0].value.push(t.create(t.Class.UNIVERSAL,t.Type.SET,!0,f.signerInfos)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(f.type).getBytes()),i])},addSigner:function(t){var l=t.issuer,a=t.serialNumber,i,r,s,u,e,o,h,c;if(t.certificate&&(i=t.certificate,typeof i=="string"&&(i=n.pki.certificateFromPem(i)),l=i.issuer.attributes,a=i.serialNumber),r=t.key,!r)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof r=="string"&&(r=n.pki.privateKeyFromPem(r));s=t.digestAlgorithm||n.pki.oids.sha1;switch(s){case n.pki.oids.sha1:case n.pki.oids.sha256:case n.pki.oids.sha384:case n.pki.oids.sha512:case n.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+s);}if(u=t.authenticatedAttributes||[],u.length>0){for(e=!1,o=!1,h=0;h<u.length;++h){if(c=u[h],!e&&c.type===n.pki.oids.contentType){if(e=!0,o)break;continue}if(!o&&c.type===n.pki.oids.messageDigest){if(o=!0,e)break;continue}}if(!e||!o)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.");}f.signers.push({key:r,version:1,issuer:l,serialNumber:a,digestAlgorithm:s,signatureAlgorithm:n.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:u,unauthenticatedAttributes:[]})},sign:function(){var i,r;((typeof f.content!="object"||f.contentInfo===null)&&(f.contentInfo=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.pki.oids.data).getBytes())]),"content"in f&&(f.content instanceof n.util.ByteBuffer?i=f.content.bytes():typeof f.content=="string"&&(i=n.util.encodeUtf8(f.content)),f.contentInfo.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,i)])))),f.signers.length!==0)&&(r=e(),o(r))},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.");},addCertificate:function(t){typeof t=="string"&&(t=n.pki.certificateFromPem(t));f.certificates.push(t)},addCertificateRevokationList:function(){throw new Error("PKCS#7 CRL support not yet implemented.");}},f};i.createEncryptedData=function(){var t=null;return t={type:n.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:n.pki.oids["aes256-CBC"]},fromAsn1:function(n){u(t,n,i.asn1.encryptedDataValidator)},decrypt:function(n){n!==undefined&&(t.encryptedContent.key=n);f(t)}},t};i.createEnvelopedData=function(){var r=null;return r={type:n.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:n.pki.oids["aes256-CBC"]},fromAsn1:function(n){var t=u(r,n,i.asn1.envelopedDataValidator);r.recipients=s(t.recipientInfos.value)},toAsn1:function(){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.type).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,h(r.recipients)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,a(r.encryptedContent))])])])},findRecipient:function(n){for(var i=n.issuer.attributes,f,e,o,t,u=0;u<r.recipients.length;++u)if((f=r.recipients[u],e=f.issuer,f.serialNumber===n.serialNumber)&&e.length===i.length){for(o=!0,t=0;t<i.length;++t)if(e[t].type!==i[t].type||e[t].value!==i[t].value){o=!1;break}if(o)return f}return null},decrypt:function(t,i){if(r.encryptedContent.key===undefined&&t!==undefined&&i!==undefined)switch(t.encryptedContent.algorithm){case n.pki.oids.rsaEncryption:case n.pki.oids.desCBC:var u=i.decrypt(t.encryptedContent.content);r.encryptedContent.key=n.util.createBuffer(u);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm);}f(r)},addRecipient:function(t){r.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:n.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,i){var u,e,o,s,h,f;if(r.encryptedContent.content===undefined){i=i||r.encryptedContent.algorithm;t=t||r.encryptedContent.key;switch(i){case n.pki.oids["aes128-CBC"]:u=16;e=16;o=n.aes.createEncryptionCipher;break;case n.pki.oids["aes192-CBC"]:u=24;e=16;o=n.aes.createEncryptionCipher;break;case n.pki.oids["aes256-CBC"]:u=32;e=16;o=n.aes.createEncryptionCipher;break;case n.pki.oids["des-EDE3-CBC"]:u=24;e=8;o=n.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+i);}if(t===undefined)t=n.util.createBuffer(n.random.getBytes(u));else if(t.length()!=u)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+u+".");if(r.encryptedContent.algorithm=i,r.encryptedContent.key=t,r.encryptedContent.parameter=n.util.createBuffer(n.random.getBytes(e)),s=o(t),s.start(r.encryptedContent.parameter.copy()),s.update(r.content),!s.finish())throw new Error("Symmetric encryption failed.");r.encryptedContent.content=s.output}for(h=0;h<r.recipients.length;++h)if(f=r.recipients[h],f.encryptedContent.content===undefined)switch(f.encryptedContent.algorithm){case n.pki.oids.rsaEncryption:f.encryptedContent.content=f.encryptedContent.key.encrypt(r.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+f.encryptedContent.algorithm);}}},r}}var i="pkcs7",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/pkcs7",["require","module","./aes","./asn1","./des","./oids","./pem","./pkcs7asn1","./random","./util","./x509"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){function t(t,i){var r=i.toString(16),u;r[0]>="8"&&(r="00"+r);u=n.util.hexToBytes(r);t.putInt32(u.length);t.putBytes(u)}function i(n,t){n.putInt32(t.length);n.putString(t)}function r(){for(var i=n.md.sha1.create(),r=arguments.length,t=0;t<r;++t)i.update(arguments[t]);return i.digest()}var u=n.ssh=n.ssh||{};u.privateKeyToPutty=function(u,f,e){var c,d,a,o,v,y,p,w,l,g,tt,s,b;e=e||"";f=f||"";var k="ssh-rsa",nt=f===""?"none":"aes256-cbc",h="PuTTY-User-Key-File-2: "+k+"\r\n";return h+="Encryption: "+nt+"\r\n",h+="Comment: "+e+"\r\n",c=n.util.createBuffer(),i(c,k),t(c,u.e),t(c,u.n),d=n.util.encode64(c.bytes(),64),a=Math.floor(d.length/66)+1,h+="Public-Lines: "+a+"\r\n",h+=d,o=n.util.createBuffer(),t(o,u.d),t(o,u.p),t(o,u.q),t(o,u.qInv),f?(y=o.length()+16-1,y-=y%16,p=r(o.bytes()),p.truncate(p.length()-y+o.length()),o.putBuffer(p),w=n.util.createBuffer(),w.putBuffer(r("\0\0\0\0",f)),w.putBuffer(r("\0\0\0",f)),l=n.aes.createEncryptionCipher(w.truncate(8),"CBC"),l.start(n.util.createBuffer().fillWithByte(0,16)),l.update(o.copy()),l.finish(),g=l.output,g.truncate(16),v=n.util.encode64(g.bytes(),64)):v=n.util.encode64(o.bytes(),64),a=Math.floor(v.length/66)+1,h+="\r\nPrivate-Lines: "+a+"\r\n",h+=v,tt=r("putty-private-key-file-mac-key",f),s=n.util.createBuffer(),i(s,k),i(s,nt),i(s,e),s.putInt32(c.length()),s.putBuffer(c),s.putInt32(o.length()),s.putBuffer(o),b=n.hmac.create(),b.start("sha1",tt),b.update(s.bytes()),h+="\r\nPrivate-MAC: "+b.digest().toHex()+"\r\n",h};u.publicKeyToOpenSSH=function(r,u){var e="ssh-rsa",f;return u=u||"",f=n.util.createBuffer(),i(f,e),t(f,r.e),t(f,r.n),e+" "+n.util.encode64(f.bytes())+" "+u};u.privateKeyToOpenSSH=function(t,i){return i?n.pki.encryptRsaPrivateKey(t,i,{legacy:!0,algorithm:"aes128"}):n.pki.privateKeyToPem(t)};u.getPublicKeyFingerprint=function(r,u){var e,s;u=u||{};var o=u.md||n.md.md5.create(),f=n.util.createBuffer();if(i(f,"ssh-rsa"),t(f,r.e),t(f,r.n),o.start(),o.update(f.getBytes()),e=o.digest(),u.encoding==="hex")return s=e.toHex(),u.delimiter?s.match(/.{2}/g).join(u.delimiter):s;if(u.encoding==="binary")return e.getBytes();if(u.encoding)throw new Error('Unknown encoding "'+u.encoding+'".');return e}}var i="ssh",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/ssh",["require","module","./aes","./hmac","./md5","./sha1","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function u(n){var h="forge.task",k=0,nt={},rt=0,f,s;n.debug.set(h,"tasks",nt);f={};n.debug.set(h,"queues",f);var it="?",ut=30,ft=20,c="ready",u="running",o="blocked",e="sleeping",i="done",r="error",v="stop",l="start",p="block",d="unblock",w="sleep",g="wakeup",y="cancel",b="fail",t={};t[c]={};t[c][v]=c;t[c][l]=u;t[c][y]=i;t[c][b]=r;t[u]={};t[u][v]=c;t[u][l]=u;t[u][p]=o;t[u][d]=u;t[u][w]=e;t[u][g]=u;t[u][y]=i;t[u][b]=r;t[o]={};t[o][v]=o;t[o][l]=o;t[o][p]=o;t[o][d]=o;t[o][w]=o;t[o][g]=o;t[o][y]=i;t[o][b]=r;t[e]={};t[e][v]=e;t[e][l]=e;t[e][p]=e;t[e][d]=e;t[e][w]=e;t[e][g]=e;t[e][y]=i;t[e][b]=r;t[i]={};t[i][v]=i;t[i][l]=i;t[i][p]=i;t[i][d]=i;t[i][w]=i;t[i][g]=i;t[i][y]=i;t[i][b]=r;t[r]={};t[r][v]=r;t[r][l]=r;t[r][p]=r;t[r][d]=r;t[r][w]=r;t[r][g]=r;t[r][y]=r;t[r][b]=r;s=function(t){this.id=-1;this.name=t.name||it;this.parent=t.parent||null;this.run=t.run;this.subtasks=[];this.error=!1;this.state=c;this.blocks=0;this.timeoutId=null;this.swapTime=null;this.userData=null;this.id=rt++;nt[this.id]=this;k>=1&&n.log.verbose(h,"[%s][%s] init",this.id,this.name,this)};s.prototype.debug=function(t){t=t||"";n.log.debug(h,t,"[%s][%s] task:",this.id,this.name,this,"subtasks:",this.subtasks.length,"queue:",f)};s.prototype.next=function(n,t){typeof n=="function"&&(t=n,n=this.name);var i=new s({run:t,name:n,parent:this});return i.state=u,i.type=this.type,i.successCallback=this.successCallback||null,i.failureCallback=this.failureCallback||null,this.subtasks.push(i),this};s.prototype.parallel=function(t,i){return n.util.isArray(t)&&(i=t,t=this.name),this.next(t,function(r){var f=r,e,u,o,s;for(f.block(i.length),e=function(t,r){n.task.start({type:t,run:function(n){i[r](n)},success:function(){f.unblock()},failure:function(){f.unblock()}})},u=0;u<i.length;u++)o=t+"__parallel-"+r.id+"-"+u,s=u,e(o,s)})};s.prototype.stop=function(){this.state=t[this.state][v]};s.prototype.start=function(){this.error=!1;this.state=t[this.state][l];this.state===u&&(this.start=new Date,this.run(this),a(this,0))};s.prototype.block=function(n){n=typeof n=="undefined"?1:n;this.blocks+=n;this.blocks>0&&(this.state=t[this.state][p])};s.prototype.unblock=function(n){return n=typeof n=="undefined"?1:n,this.blocks-=n,this.blocks===0&&this.state!==i&&(this.state=u,a(this,0)),this.blocks};s.prototype.sleep=function(n){n=typeof n=="undefined"?0:n;this.state=t[this.state][w];var i=this;this.timeoutId=setTimeout(function(){i.timeoutId=null;i.state=u;a(i,0)},n)};s.prototype.wait=function(n){n.wait(this)};s.prototype.wakeup=function(){this.state===e&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=u,a(this,0))};s.prototype.cancel=function(){this.state=t[this.state][y];this.permitsNeeded=0;this.timeoutId!==null&&(cancelTimeout(this.timeoutId),this.timeoutId=null);this.subtasks=[]};s.prototype.fail=function(n){if(this.error=!0,tt(this,!0),n)n.error=this.error,n.swapTime=this.swapTime,n.userData=this.userData,a(n,0);else{if(this.parent!==null){for(var t=this.parent;t.parent!==null;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;tt(t,!0)}this.failureCallback&&this.failureCallback(this)}};var et=function(n){n.error=!1;n.state=t[n.state][l];setTimeout(function(){n.state===u&&(n.swapTime=+new Date,n.run(n),a(n,0))},0)},a=function(n,t){var i=t>ut||+new Date-n.swapTime>ft,r=function(t){if(t++,n.state===u)if(i&&(n.swapTime=+new Date),n.subtasks.length>0){var r=n.subtasks.shift();r.error=n.error;r.swapTime=n.swapTime;r.userData=n.userData;r.run(r);r.error||a(r,t)}else tt(n),n.error||n.parent!==null&&(n.parent.error=n.error,n.parent.swapTime=n.swapTime,n.parent.userData=n.userData,a(n.parent,t))};i?setTimeout(r,0):r(t)},tt=function(t,r){t.state=i;delete nt[t.id];k>=1&&n.log.verbose(h,"[%s][%s] finish",t.id,t.name,t);t.parent===null&&(t.type in f?f[t.type].length===0?n.log.error(h,"[%s][%s] task queue empty [%s]",t.id,t.name,t.type):f[t.type][0]!==t?n.log.error(h,"[%s][%s] task not first in queue [%s]",t.id,t.name,t.type):(f[t.type].shift(),f[t.type].length===0?(k>=1&&n.log.verbose(h,"[%s][%s] delete queue [%s]",t.id,t.name,t.type),delete f[t.type]):(k>=1&&n.log.verbose(h,"[%s][%s] queue start next [%s] remain:%s",t.id,t.name,t.type,f[t.type].length),f[t.type][0].start())):n.log.error(h,"[%s][%s] task queue missing [%s]",t.id,t.name,t.type),r||(t.error&&t.failureCallback?t.failureCallback(t):!t.error&&t.successCallback&&t.successCallback(t)))};n.task=n.task||{};n.task.start=function(t){var i=new s({run:t.run,name:t.name||it});i.type=t.type;i.successCallback=t.success||null;i.failureCallback=t.failure||null;i.type in f?f[t.type].push(i):(k>=1&&n.log.verbose(h,"[%s][%s] create queue [%s]",i.id,i.name,i.type),f[i.type]=[i],et(i))};n.task.cancel=function(n){n in f&&(f[n]=[f[n][0]])};n.task.createCondition=function(){var n={tasks:{}};return n.wait=function(t){t.id in n.tasks||(t.block(),n.tasks[t.id]=t)},n.notify=function(){var t=n.tasks,i;n.tasks={};for(i in t)t[i].unblock()},n}}var i="task",f,e,o,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports)return typeof forge=="undefined"&&(forge={}),u(forge);f=!0;n=function(n,i){i(t,module)}}o=function(n,t){t.exports=function(t){var f=e.map(function(t){return n(t)}).concat(u),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<f.length;++r)f[r](t);return t[i]}};r=n;n=function(t,i){return e=typeof t=="string"?i.slice(2):t.slice(2),f?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/task",["require","module","./debug","./log","./util"],function(){o.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){var i="forge",u,f,e,r;if(typeof n!="function"){if(typeof module!="object"||!module.exports){typeof forge=="undefined"&&(forge={disableNativeCode:!1});return}u=!0;n=function(n,i){i(t,module)}}e=function(n,t){t.exports=function(t){var u=f.map(function(t){return n(t)}),r;if(t=t||{},t.defined=t.defined||{},t.defined[i])return t[i];for(t.defined[i]=!0,r=0;r<u.length;++r)u[r](t);return t};t.exports.disableNativeCode=!1;t.exports(t.exports)};r=n;n=function(t,i){return f=typeof t=="string"?i.slice(2):t.slice(2),u?(delete n,r.apply(null,Array.prototype.slice.call(arguments,0))):(n=r,n.apply(null,Array.prototype.slice.call(arguments,0)))};n("js/forge",["require","module","./aes","./aesCipherSuites","./asn1","./cipher","./cipherModes","./debug","./des","./hmac","./kem","./log","./md","./mgf1","./pbkdf2","./pem","./pkcs7","./pkcs1","./pkcs12","./pki","./prime","./prng","./pss","./random","./rc2","./ssh","./task","./tls","./util"],function(){e.apply(null,Array.prototype.slice.call(arguments,0))})}(),t("js/forge")});var SD_TripleDES="1.2.840.113549.3.7",SDSGL_ERR_01="Error while decoding pkcs#8 encrypted private key stream",SDSGL_ERR_02="Invalid or unsupported algorithm: ",SDSGL_ERR_03="Error while decrypting private key",SDSGL_ERR_04="Error while deriving symmetric key",ADJUSTED_3DES_KEY_LENGTH=48;var SD_SHA1_NAME="SHA-1",SD_SHA256_NAME="SHA-256",SD_SHA384_NAME="SHA-384",SD_SHA512_NAME="SHA-512",CMS_SIGNED_DATA="1.2.840.113549.1.7.2",DATA_CONTENT_TYPE="1.2.840.113549.1.7.1",SD_RSAENCRYPTION="1.2.840.113549.1.1.1",SD_SHA1_DOID="1.3.14.3.2.26",SD_SHA256_DOID="2.16.840.1.101.3.4.2.1",SD_SHA384_DOID="2.16.840.1.101.3.4.2.2",SD_SHA512_DOID="2.16.840.1.101.3.4.2.3",SD_UNKNOWN_ALGORITHM="An unknown hash Algorithm was supplied",SD_ERROR_ENCODING_PKCS7="Error during encoding of PKCS#7 Signed Data: ",SD_ERROR_EMPTY_SIGNATURE="An empty or invalid value was received for signature",SD_ERROR_EMPTY_CERTIFICATE="An empty or invalid value was received for certificate";Module||(Module=(typeof Module!="undefined"?Module:null)||{});moduleOverrides={};for(key in Module)Module.hasOwnProperty(key)&&(moduleOverrides[key]=Module[key]);var ENVIRONMENT_IS_WEB=typeof window=="object",ENVIRONMENT_IS_WORKER=typeof importScripts=="function",ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof require=="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER,ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){Module.print||(Module.print=function(n){process.stdout.write(n+"\n")});Module.printErr||(Module.printErr=function(n){process.stderr.write(n+"\n")});nodeFS=require("fs");nodePath=require("path");Module.read=function(n,t){n=nodePath.normalize(n);var i=nodeFS.readFileSync(n);return i||n==nodePath.resolve(n)||(n=path.join(__dirname,"..","src",n),i=nodeFS.readFileSync(n)),i&&!t&&(i=i.toString()),i};Module.readBinary=function(n){return Module.read(n,!0)};Module.load=function(n){globalEval(read(n))};Module.thisProgram||(Module.thisProgram=process.argv.length>1?process.argv[1].replace(/\\/g,"/"):"unknown-program");Module.arguments=process.argv.slice(2);typeof module!="undefined"&&(module.exports=Module);process.on("uncaughtException",function(n){if(!(n instanceof ExitStatus))throw n;});Module.inspect=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL)Module.print||(Module.print=print),typeof printErr!="undefined"&&(Module.printErr=printErr),Module.read=typeof read!="undefined"?read:function(){throw"no read() available (jsc?)";},Module.readBinary=function(n){if(typeof readbuffer=="function")return new Uint8Array(readbuffer(n));var t=read(n,"binary");return assert(typeof t=="object"),t},typeof scriptArgs!="undefined"?Module.arguments=scriptArgs:typeof arguments!="undefined"&&(Module.arguments=arguments);else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)Module.read=function(n){var t=new XMLHttpRequest;return t.open("GET",n,!1),t.send(null),t.responseText},typeof arguments!="undefined"&&(Module.arguments=arguments),typeof console!="undefined"?(Module.print||(Module.print=function(n){console.log(n)}),Module.printErr||(Module.printErr=function(n){console.log(n)})):(TRY_USE_DUMP=!1,Module.print||(Module.print=TRY_USE_DUMP&&typeof dump!="undefined"?function(n){dump(n)}:function(){})),ENVIRONMENT_IS_WORKER&&(Module.load=importScripts),typeof Module.setWindowTitle=="undefined"&&(Module.setWindowTitle=function(n){document.title=n});else throw"Unknown runtime environment. Where are we?";!Module.load&&Module.read&&(Module.load=function(n){globalEval(Module.read(n))});Module.print||(Module.print=function(){});Module.printErr||(Module.printErr=Module.print);Module.arguments||(Module.arguments=[]);Module.thisProgram||(Module.thisProgram="./this.program");Module.print=Module.print;Module.printErr=Module.printErr;Module.preRun=[];Module.postRun=[];for(key in moduleOverrides)moduleOverrides.hasOwnProperty(key)&&(Module[key]=moduleOverrides[key]);Runtime={setTempRet0:function(n){tempRet0=n},getTempRet0:function(){return tempRet0},stackSave:function(){return STACKTOP},stackRestore:function(n){STACKTOP=n},getNativeTypeSize:function(n){switch(n){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:if(n[n.length-1]==="*")return Runtime.QUANTUM_SIZE;if(n[0]==="i"){var t=parseInt(n.substr(1));return assert(t%8==0),t/8}return 0}},getNativeFieldSize:function(n){return Math.max(Runtime.getNativeTypeSize(n),Runtime.QUANTUM_SIZE)},STACK_ALIGN:16,prepVararg:function(n,t){return t==="double"||t==="i64"?n&7&&(assert((n&7)==4),n+=4):assert((n&3)==0),n},getAlignSize:function(n,t,i){return!i&&(n=="i64"||n=="double")?8:n?Math.min(t||(n?Runtime.getNativeFieldSize(n):0),Runtime.QUANTUM_SIZE):Math.min(t,8)},dynCall:function(n,t,i){return i&&i.length?(i.splice||(i=Array.prototype.slice.call(i)),i.splice(0,0,t),Module["dynCall_"+n].apply(null,i)):Module["dynCall_"+n].call(null,t)},functionPointers:[],addFunction:function(n){for(var t=0;t<Runtime.functionPointers.length;t++)if(!Runtime.functionPointers[t])return Runtime.functionPointers[t]=n,2*(1+t);throw"Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.";},removeFunction:function(n){Runtime.functionPointers[(n-2)/2]=null},warnOnce:function(n){Runtime.warnOnce.shown||(Runtime.warnOnce.shown={});Runtime.warnOnce.shown[n]||(Runtime.warnOnce.shown[n]=1,Module.printErr(n))},funcWrappers:{},getFuncWrapper:function(n,t){assert(t);Runtime.funcWrappers[t]||(Runtime.funcWrappers[t]={});var i=Runtime.funcWrappers[t];return i[n]||(i[n]=function(){return Runtime.dynCall(t,n,arguments)}),i[n]},getCompilerSetting:function(){throw"You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work";},stackAlloc:function(n){var t=STACKTOP;return STACKTOP=STACKTOP+n|0,STACKTOP=STACKTOP+15&-16,t},staticAlloc:function(n){var t=STATICTOP;return STATICTOP=STATICTOP+n|0,STATICTOP=STATICTOP+15&-16,t},dynamicAlloc:function(n){var t=DYNAMICTOP,i;return(DYNAMICTOP=DYNAMICTOP+n|0,DYNAMICTOP=DYNAMICTOP+15&-16,DYNAMICTOP>=TOTAL_MEMORY&&(i=enlargeMemory(),!i))?(DYNAMICTOP=t,0):t},alignMemory:function(n,t){return n=Math.ceil(n/(t?t:16))*(t?t:16)},makeBigInt:function(n,t,i){return i?+(n>>>0)+ +(t>>>0)*4294967296:+(n>>>0)+ +(t|0)*4294967296},GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module.Runtime=Runtime;var __THREW__=0,ABORT=!1,EXITSTATUS=0,undef=0,tempValue,tempInt,tempBigInt,tempInt2,tempBigInt2,tempPair,tempBigIntI,tempBigIntR,tempBigIntS,tempBigIntP,tempBigIntD,tempDouble,tempFloat,tempI64,tempI64b,tempRet0,tempRet1,tempRet2,tempRet3,tempRet4,tempRet5,tempRet6,tempRet7,tempRet8,tempRet9;globalScope=this,function(){function r(n){var t=n.toString().match(u).slice(1);return{arguments:t[0],body:t[1],returnValue:t[2]}}var n={stackSave:function(){Runtime.stackSave()},stackRestore:function(){Runtime.stackRestore()},arrayToC:function(n){var t=Runtime.stackAlloc(n.length);return writeArrayToMemory(n,t),t},stringToC:function(n){var t=0;return n!==null&&n!==undefined&&n!==0&&(t=Runtime.stackAlloc((n.length<<2)+1),writeStringToMemory(n,t)),t}},f={string:n.stringToC,array:n.arrayToC},u,t,i;ccall=function(n,t,i,r,u){var l=getCFunc(n),h=[],o=0,e,c,s;if(r)for(e=0;e<r.length;e++)c=f[i[e]],c?(o===0&&(o=Runtime.stackSave()),h[e]=c(r[e])):h[e]=r[e];if(s=l.apply(null,h),t==="string"&&(s=Pointer_stringify(s)),o!==0){if(u&&u.async){EmterpreterAsync.asyncFinalizers.push(function(){Runtime.stackRestore(o)});return}Runtime.stackRestore(o)}return s};u=/^function\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;t={};for(i in n)n.hasOwnProperty(i)&&(t[i]=r(n[i]));cwrap=function(n,i,u){var e,c,l,o,y,p;u=u||[];var a=getCFunc(n),s=u.every(function(n){return n==="number"}),v=i!=="string";if(v&&s)return a;var h=u.map(function(n,t){return"$"+t}),f="(function("+h.join(",")+") {",w=u.length;if(!s)for(f+="var stack = "+t.stackSave.body+";",e=0;e<w;e++)(c=h[e],l=u[e],l!=="number")&&(o=t[l+"ToC"],f+="var "+o.arguments+" = "+c+";",f+=o.body+";",f+=c+"="+o.returnValue+";");return y=r(function(){return a}).returnValue,f+="var ret = "+y+"("+h.join(",")+");",v||(p=r(function(){return Pointer_stringify}).returnValue,f+="ret = "+p+"(ret);"),s||(f+=t.stackRestore.body.replace("()","(stack)")+";"),f+="return ret})",new Function(f)()}}();Module.ccall=ccall;Module.cwrap=cwrap;Module.setValue=setValue;Module.getValue=getValue;var ALLOC_NORMAL=0,ALLOC_STACK=1,ALLOC_STATIC=2,ALLOC_DYNAMIC=3,ALLOC_NONE=4;Module.ALLOC_NORMAL=ALLOC_NORMAL;Module.ALLOC_STACK=ALLOC_STACK;Module.ALLOC_STATIC=ALLOC_STATIC;Module.ALLOC_DYNAMIC=ALLOC_DYNAMIC;Module.ALLOC_NONE=ALLOC_NONE;Module.allocate=allocate;Module.getMemory=getMemory;Module.Pointer_stringify=Pointer_stringify;Module.AsciiToString=AsciiToString;Module.stringToAscii=stringToAscii;Module.UTF8ArrayToString=UTF8ArrayToString;Module.UTF8ToString=UTF8ToString;Module.stringToUTF8Array=stringToUTF8Array;Module.stringToUTF8=stringToUTF8;Module.lengthBytesUTF8=lengthBytesUTF8;Module.UTF16ToString=UTF16ToString;Module.stringToUTF16=stringToUTF16;Module.lengthBytesUTF16=lengthBytesUTF16;Module.UTF32ToString=UTF32ToString;Module.stringToUTF32=stringToUTF32;Module.lengthBytesUTF32=lengthBytesUTF32;Module.stackTrace=stackTrace;PAGE_SIZE=4096;for(var HEAP,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64,STATIC_BASE=0,STATICTOP=0,staticSealed=!1,STACK_BASE=0,STACKTOP=0,STACK_MAX=0,DYNAMIC_BASE=0,DYNAMICTOP=0,TOTAL_STACK=Module.TOTAL_STACK||5242880,TOTAL_MEMORY=Module.TOTAL_MEMORY||16777216,totalMemory=65536;totalMemory<TOTAL_MEMORY||totalMemory<2*TOTAL_STACK;)totalMemory<16777216?totalMemory*=2:totalMemory+=16777216;totalMemory!==TOTAL_MEMORY&&(Module.printErr("increasing TOTAL_MEMORY to "+totalMemory+" to be compliant with the asm.js spec (and given that TOTAL_STACK="+TOTAL_STACK+")"),TOTAL_MEMORY=totalMemory);assert(typeof Int32Array!="undefined"&&typeof Float64Array!="undefined"&&!!new Int32Array(1).subarray&&!!new Int32Array(1).set,"JS engine does not provide full typed array support");buffer=new ArrayBuffer(TOTAL_MEMORY);HEAP8=new Int8Array(buffer);HEAP16=new Int16Array(buffer);HEAP32=new Int32Array(buffer);HEAPU8=new Uint8Array(buffer);HEAPU16=new Uint16Array(buffer);HEAPU32=new Uint32Array(buffer);HEAPF32=new Float32Array(buffer);HEAPF64=new Float64Array(buffer);HEAP32[0]=255;assert(HEAPU8[0]===255&&HEAPU8[3]===0,"Typed arrays 2 must be run on a little-endian system");Module.HEAP=HEAP;Module.buffer=buffer;Module.HEAP8=HEAP8;Module.HEAP16=HEAP16;Module.HEAP32=HEAP32;Module.HEAPU8=HEAPU8;Module.HEAPU16=HEAPU16;Module.HEAPU32=HEAPU32;Module.HEAPF32=HEAPF32;Module.HEAPF64=HEAPF64;var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATEXIT__=[],__ATPOSTRUN__=[],runtimeInitialized=!1,runtimeExited=!1;Module.addOnPreRun=addOnPreRun;Module.addOnInit=addOnInit;Module.addOnPreMain=addOnPreMain;Module.addOnExit=addOnExit;Module.addOnPostRun=addOnPostRun;Module.intArrayFromString=intArrayFromString;Module.intArrayToString=intArrayToString;Module.writeStringToMemory=writeStringToMemory;Module.writeArrayToMemory=writeArrayToMemory;Module.writeAsciiToMemory=writeAsciiToMemory;Math.imul&&Math.imul(4294967295,5)===-5||(Math.imul=function(n,t){var u=n>>>16,i=n&65535,f=t>>>16,r=t&65535;return i*r+(u*r+i*f<<16)|0});Math.imul=Math.imul;Math.clz32||(Math.clz32=function(n){n=n>>>0;for(var t=0;t<32;t++)if(n&1<<31-t)return t;return 32});Math.clz32=Math.clz32;var Math_abs=Math.abs,Math_cos=Math.cos,Math_sin=Math.sin,Math_tan=Math.tan,Math_acos=Math.acos,Math_asin=Math.asin,Math_atan=Math.atan,Math_atan2=Math.atan2,Math_exp=Math.exp,Math_log=Math.log,Math_sqrt=Math.sqrt,Math_ceil=Math.ceil,Math_floor=Math.floor,Math_pow=Math.pow,Math_imul=Math.imul,Math_fround=Math.fround,Math_min=Math.min,Math_clz32=Math.clz32,runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;Module.addRunDependency=addRunDependency;Module.removeRunDependency=removeRunDependency;Module.preloadedImages={};Module.preloadedAudios={};memoryInitializer=null;ASM_CONSTS=[];STATIC_BASE=8;STATICTOP=STATIC_BASE+5072;__ATINIT__.push();allocate([104,0,0,0,11,15,0,0,144,0,0,0,24,15,0,0,8,0,0,0,0,0,0,0,144,0,0,0,57,15,0,0,16,0,0,0,0,0,0,0,144,0,0,0,127,15,0,0,16,0,0,0,0,0,0,0,144,0,0,0,91,15,0,0,48,0,0,0,0,0,0,0,144,0,0,0,161,15,0,0,32,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,80,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,212,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,206,15,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47,0,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,62,64,64,64,63,52,53,54,55,56,57,58,59,60,61,64,64,64,0,64,64,64,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,64,64,64,64,64,64,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,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,96,134,72,1,101,3,4,42,134,72,134,247,13,2,43,14,3,2,26,42,134,72,134,247,13,1,12,1,48,33,48,9,6,5,43,14,3,2,26,5,0,4,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,0,48,13,6,9,96,134,72,1,101,3,4,2,0,5,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,112,114,105,118,97,116,101,32,107,101,121,32,118,97,108,117,101,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,112,114,105,118,97,116,101,32,107,101,121,32,108,101,110,103,116,104,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,104,97,115,104,32,118,97,108,117,101,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,104,97,115,104,32,97,108,103,111,114,105,116,104,109,0,91,69,114,114,111,114,93,32,72,97,115,104,32,97,108,103,111,114,105,116,104,109,32,109,105,115,109,97,116,99,104,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,104,97,115,104,32,108,101,110,103,116,104,0,91,69,114,114,111,114,93,32,68,101,99,111,100,105,110,103,32,112,114,105,118,97,116,101,32,107,101,121,0,91,69,114,114,111,114,93,32,85,115,105,110,103,32,112,114,105,118,97,116,101,32,107,101,121,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,112,114,105,118,97,116,101,32,107,101,121,32,102,111,114,109,97,116,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,104,97,115,104,32,102,111,114,109,97,116,0,91,69,114,114,111,114,93,32,67,111,110,118,101,114,116,105,110,103,32,115,105,103,110,97,116,117,114,101,32,116,111,32,98,97,115,101,54,52,32,102,111,114,109,97,116,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,115,105,103,110,97,116,117,114,101,32,118,97,108,117,101,0,91,69,114,114,111,114,93,32,73,110,99,111,114,114,101,99,116,32,115,105,103,110,97,116,117,114,101,32,102,111,114,109,97,116,0,91,69,114,114,111,114,93,32,67,111,110,118,101,114,116,105,110,103,32,99,111,110,116,101,110,116,32,116,111,32,98,97,115,101,54,52,32,102,111,114,109,97,116,0,91,69,114,114,111,114,93,32,85,110,107,110,111,119,110,32,69,114,114,111,114,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE);tempDoublePtr=Runtime.alignMemory(allocate(12,"i8",ALLOC_STATIC),8);assert(tempDoublePtr%8==0);ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};Module._memset=_memset;var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can   access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"},PATH={splitPath:function(n){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(n).slice(1)},normalizeArray:function(n,t){for(var r=0,u,i=n.length-1;i>=0;i--)u=n[i],u==="."?n.splice(i,1):u===".."?(n.splice(i,1),r++):r&&(n.splice(i,1),r--);if(t)for(;r--;r)n.unshift("..");return n},normalize:function(n){var t=n.charAt(0)==="/",i=n.substr(-1)==="/";return n=PATH.normalizeArray(n.split("/").filter(function(n){return!!n}),!t).join("/"),n||t||(n="."),n&&i&&(n+="/"),(t?"/":"")+n},dirname:function(n){var i=PATH.splitPath(n),r=i[0],t=i[1];return!r&&!t?".":(t&&(t=t.substr(0,t.length-1)),r+t)},basename:function(n){if(n==="/")return"/";var t=n.lastIndexOf("/");return t===-1?n:n.substr(t+1)},extname:function(n){return PATH.splitPath(n)[3]},join:function(){var n=Array.prototype.slice.call(arguments,0);return PATH.normalize(n.join("/"))},join2:function(n,t){return PATH.normalize(n+"/"+t)},resolve:function(){for(var n="",r=!1,i,t=arguments.length-1;t>=-1&&!r;t--){if(i=t>=0?arguments[t]:FS.cwd(),typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");else if(!i)return"";n=i+"/"+n;r=i.charAt(0)==="/"}return n=PATH.normalizeArray(n.split("/").filter(function(n){return!!n}),!r).join("/"),(r?"/":"")+n||"."},relative:function(n,t){function o(n){for(var t=0,i;t<n.length;t++)if(n[t]!=="")break;for(i=n.length-1;i>=0;i--)if(n[i]!=="")break;return t>i?[]:n.slice(t,i-t+1)}var r,i;n=PATH.resolve(n).substr(1);t=PATH.resolve(t).substr(1);var u=o(n.split("/")),f=o(t.split("/")),s=Math.min(u.length,f.length),e=s;for(i=0;i<s;i++)if(u[i]!==f[i]){e=i;break}for(r=[],i=e;i<u.length;i++)r.push("..");return r=r.concat(f.slice(e)),r.join("/")}},TTY={ttys:[],init:function(){},shutdown:function(){},register:function(n,t){TTY.ttys[n]={input:[],output:[],ops:t};FS.registerDevice(n,TTY.stream_ops)},stream_ops:{open:function(n){var t=TTY.ttys[n.node.rdev];if(!t)throw new FS.ErrnoError(ERRNO_CODES.ENODEV);n.tty=t;n.seekable=!1},close:function(n){n.tty.ops.flush(n.tty)},flush:function(n){n.tty.ops.flush(n.tty)},read:function(n,t,i,r){var u,e,f;if(!n.tty||!n.tty.ops.get_char)throw new FS.ErrnoError(ERRNO_CODES.ENXIO);for(u=0,e=0;e<r;e++){try{f=n.tty.ops.get_char(n.tty)}catch(o){throw new FS.ErrnoError(ERRNO_CODES.EIO);}if(f===undefined&&u===0)throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);if(f===null||f===undefined)break;u++;t[i+e]=f}return u&&(n.node.timestamp=Date.now()),u},write:function(n,t,i,r){if(!n.tty||!n.tty.ops.put_char)throw new FS.ErrnoError(ERRNO_CODES.ENXIO);for(var u=0;u<r;u++)try{n.tty.ops.put_char(n.tty,t[i+u])}catch(f){throw new FS.ErrnoError(ERRNO_CODES.EIO);}return r&&(n.node.timestamp=Date.now()),u}},default_tty_ops:{get_char:function(n){var t;if(!n.input.length){if(t=null,ENVIRONMENT_IS_NODE){var u=256,f=new Buffer(u),i=0,r=process.stdin.fd,e=!1;try{r=fs.openSync("/dev/stdin","r");e=!0}catch(o){}i=fs.readSync(r,f,0,u,null);e&&fs.closeSync(r);t=i>0?f.slice(0,i).toString("utf-8"):null}else typeof window!="undefined"&&typeof window.prompt=="function"?(t=window.prompt("Input: "),t!==null&&(t+="\n")):typeof readline=="function"&&(t=readline(),t!==null&&(t+="\n"));if(!t)return null;n.input=intArrayFromString(t,!0)}return n.input.shift()},put_char:function(n,t){t===null||t===10?(Module.print(UTF8ArrayToString(n.output,0)),n.output=[]):t!=0&&n.output.push(t)},flush:function(n){n.output&&n.output.length>0&&(Module.print(UTF8ArrayToString(n.output,0)),n.output=[])}},default_tty1_ops:{put_char:function(n,t){t===null||t===10?(Module.printErr(UTF8ArrayToString(n.output,0)),n.output=[]):t!=0&&n.output.push(t)},flush:function(n){n.output&&n.output.length>0&&(Module.printErr(UTF8ArrayToString(n.output,0)),n.output=[])}}},MEMFS={ops_table:null,mount:function(){return MEMFS.createNode(null,"/",16895,0)},createNode:function(n,t,i,r){if(FS.isBlkdev(i)||FS.isFIFO(i))throw new FS.ErrnoError(ERRNO_CODES.EPERM);MEMFS.ops_table||(MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}});var u=FS.createNode(n,t,i,r);return FS.isDir(u.mode)?(u.node_ops=MEMFS.ops_table.dir.node,u.stream_ops=MEMFS.ops_table.dir.stream,u.contents={}):FS.isFile(u.mode)?(u.node_ops=MEMFS.ops_table.file.node,u.stream_ops=MEMFS.ops_table.file.stream,u.usedBytes=0,u.contents=null):FS.isLink(u.mode)?(u.node_ops=MEMFS.ops_table.link.node,u.stream_ops=MEMFS.ops_table.link.stream):FS.isChrdev(u.mode)&&(u.node_ops=MEMFS.ops_table.chrdev.node,u.stream_ops=MEMFS.ops_table.chrdev.stream),u.timestamp=Date.now(),n&&(n.contents[t]=u),u},getFileDataAsRegularArray:function(n){var i,t;if(n.contents&&n.contents.subarray){for(i=[],t=0;t<n.usedBytes;++t)i.push(n.contents[t]);return i}return n.contents},getFileDataAsTypedArray:function(n){return n.contents?n.contents.subarray?n.contents.subarray(0,n.usedBytes):new Uint8Array(n.contents):new Uint8Array},expandFileStorage:function(n,t){var i,r,u;if(n.contents&&n.contents.subarray&&t>n.contents.length&&(n.contents=MEMFS.getFileDataAsRegularArray(n),n.usedBytes=n.contents.length),!n.contents||n.contents.subarray){if(i=n.contents?n.contents.buffer.byteLength:0,i>=t)return;r=1048576;t=Math.max(t,i*(i<r?2:1.125)|0);i!=0&&(t=Math.max(t,256));u=n.contents;n.contents=new Uint8Array(t);n.usedBytes>0&&n.contents.set(u.subarray(0,n.usedBytes),0);return}for(!n.contents&&t>0&&(n.contents=[]);n.contents.length<t;)n.contents.push(0)},resizeFileStorage:function(n,t){if(n.usedBytes!=t){if(t==0){n.contents=null;n.usedBytes=0;return}if(!n.contents||n.contents.subarray){var i=n.contents;n.contents=new Uint8Array(new ArrayBuffer(t));i&&n.contents.set(i.subarray(0,Math.min(t,n.usedBytes)));n.usedBytes=t;return}if(n.contents||(n.contents=[]),n.contents.length>t)n.contents.length=t;else while(n.contents.length<t)n.contents.push(0);n.usedBytes=t}},node_ops:{getattr:function(n){var t={};return t.dev=FS.isChrdev(n.mode)?n.id:1,t.ino=n.id,t.mode=n.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=n.rdev,t.size=FS.isDir(n.mode)?4096:FS.isFile(n.mode)?n.usedBytes:FS.isLink(n.mode)?n.link.length:0,t.atime=new Date(n.timestamp),t.mtime=new Date(n.timestamp),t.ctime=new Date(n.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr:function(n,t){t.mode!==undefined&&(n.mode=t.mode);t.timestamp!==undefined&&(n.timestamp=t.timestamp);t.size!==undefined&&MEMFS.resizeFileStorage(n,t.size)},lookup:function(){throw FS.genericErrors[ERRNO_CODES.ENOENT];},mknod:function(n,t,i,r){return MEMFS.createNode(n,t,i,r)},rename:function(n,t,i){var r,u;if(FS.isDir(n.mode)){try{r=FS.lookupNode(t,i)}catch(f){}if(r)for(u in r.contents)throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);}delete n.parent.contents[n.name];n.name=i;t.contents[i]=n;n.parent=t},unlink:function(n,t){delete n.contents[t]},rmdir:function(n,t){var i=FS.lookupNode(n,t),r;for(r in i.contents)throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);delete n.contents[t]},readdir:function(n){var i=[".",".."],t;for(t in n.contents)n.contents.hasOwnProperty(t)&&i.push(t);return i},symlink:function(n,t,i){var r=MEMFS.createNode(n,t,41471,0);return r.link=i,r},readlink:function(n){if(!FS.isLink(n.mode))throw new FS.ErrnoError(ERRNO_CODES.EINVAL);return n.link}},stream_ops:{read:function(n,t,i,r,u){var o=n.node.contents,f,e;if(u>=n.node.usedBytes)return 0;if(f=Math.min(n.node.usedBytes-u,r),assert(f>=0),f>8&&o.subarray)t.set(o.subarray(u,u+f),i);else for(e=0;e<f;e++)t[i+e]=o[u+e];return f},write:function(n,t,i,r,u,f){var e,o;if(!r)return 0;if(e=n.node,e.timestamp=Date.now(),t.subarray&&(!e.contents||e.contents.subarray)){if(f)return e.contents=t.subarray(i,i+r),e.usedBytes=r,r;if(e.usedBytes===0&&u===0)return e.contents=new Uint8Array(t.subarray(i,i+r)),e.usedBytes=r,r;if(u+r<=e.usedBytes)return e.contents.set(t.subarray(i,i+r),u),r}if(MEMFS.expandFileStorage(e,u+r),e.contents.subarray&&t.subarray)e.contents.set(t.subarray(i,i+r),u);else for(o=0;o<r;o++)e.contents[u+o]=t[i+o];return e.usedBytes=Math.max(e.usedBytes,u+r),r},llseek:function(n,t,i){var r=t;if(i===1?r+=n.position:i===2&&FS.isFile(n.node.mode)&&(r+=n.node.usedBytes),r<0)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);return r},allocate:function(n,t,i){MEMFS.expandFileStorage(n.node,t+i);n.node.usedBytes=Math.max(n.node.usedBytes,t+i)},mmap:function(n,t,i,r,u,f,e){if(!FS.isFile(n.node.mode))throw new FS.ErrnoError(ERRNO_CODES.ENODEV);var s,h,o=n.node.contents;if(e&2||o.buffer!==t&&o.buffer!==t.buffer){if((u>0||u+r<n.node.usedBytes)&&(o=o.subarray?o.subarray(u,u+r):Array.prototype.slice.call(o,u,u+r)),h=!0,s=_malloc(r),!s)throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);t.set(o,s)}else h=!1,s=o.byteOffset;return{ptr:s,allocated:h}},msync:function(n,t,i,r,u){if(!FS.isFile(n.node.mode))throw new FS.ErrnoError(ERRNO_CODES.ENODEV);if(u&2)return 0;var f=MEMFS.stream_ops.write(n,t,0,r,i,!1);return 0}}},IDBFS={dbs:{},indexedDB:function(){if(typeof indexedDB!="undefined")return indexedDB;var n=null;return typeof window=="object"&&(n=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),assert(n,"IDBFS used, but indexedDB not supported"),n},DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function(){return MEMFS.mount.apply(null,arguments)},syncfs:function(n,t,i){IDBFS.getLocalSet(n,function(r,u){if(r)return i(r);IDBFS.getRemoteSet(n,function(n,r){if(n)return i(n);var f=t?r:u,e=t?u:r;IDBFS.reconcile(f,e,i)})})},getDB:function(n,t){var i=IDBFS.dbs[n],r;if(i)return t(null,i);try{r=IDBFS.indexedDB().open(n,IDBFS.DB_VERSION)}catch(u){return t(u)}r.onupgradeneeded=function(n){var i=n.target.result,r=n.target.transaction,t;t=i.objectStoreNames.contains(IDBFS.DB_STORE_NAME)?r.objectStore(IDBFS.DB_STORE_NAME):i.createObjectStore(IDBFS.DB_STORE_NAME);t.indexNames.contains("timestamp")||t.createIndex("timestamp","timestamp",{unique:!1})};r.onsuccess=function(){i=r.result;IDBFS.dbs[n]=i;t(null,i)};r.onerror=function(n){t(this.error);n.preventDefault()}},getLocalSet:function(n,t){function e(n){return n!=="."&&n!==".."}function o(n){return function(t){return PATH.join2(n,t)}}for(var f={},r=FS.readdir(n.mountpoint).filter(e).map(o(n.mountpoint)),i,u;r.length;){i=r.pop();try{u=FS.stat(i)}catch(s){return t(s)}FS.isDir(u.mode)&&r.push.apply(r,FS.readdir(i).filter(e).map(o(i)));f[i]={timestamp:u.mtime}}return t(null,{type:"local",entries:f})},getRemoteSet:function(n,t){var i={};IDBFS.getDB(n.mountpoint,function(n,r){var u,f,e;if(n)return t(n);u=r.transaction([IDBFS.DB_STORE_NAME],"readonly");u.onerror=function(n){t(this.error);n.preventDefault()};f=u.objectStore(IDBFS.DB_STORE_NAME);e=f.index("timestamp");e.openKeyCursor().onsuccess=function(n){var u=n.target.result;if(!u)return t(null,{type:"remote",db:r,entries:i});i[u.primaryKey]={timestamp:u.key};u.continue()}})},loadLocalEntry:function(n,t){var i,r,u;try{u=FS.lookupPath(n);r=u.node;i=FS.stat(n)}catch(f){return t(f)}return FS.isDir(i.mode)?t(null,{timestamp:i.mtime,mode:i.mode}):FS.isFile(i.mode)?(r.contents=MEMFS.getFileDataAsTypedArray(r),t(null,{timestamp:i.mtime,mode:i.mode,contents:r.contents})):t(new Error("node type not supported"))},storeLocalEntry:function(n,t,i){try{if(FS.isDir(t.mode))FS.mkdir(n,t.mode);else if(FS.isFile(t.mode))FS.writeFile(n,t.contents,{encoding:"binary",canOwn:!0});else return i(new Error("node type not supported"));FS.chmod(n,t.mode);FS.utime(n,t.timestamp,t.timestamp)}catch(r){return i(r)}i(null)},removeLocalEntry:function(n,t){try{var u=FS.lookupPath(n),i=FS.stat(n);FS.isDir(i.mode)?FS.rmdir(n):FS.isFile(i.mode)&&FS.unlink(n)}catch(r){return t(r)}t(null)},loadRemoteEntry:function(n,t,i){var r=n.get(t);r.onsuccess=function(n){i(null,n.target.result)};r.onerror=function(n){i(this.error);n.preventDefault()}},storeRemoteEntry:function(n,t,i,r){var u=n.put(i,t);u.onsuccess=function(){r(null)};u.onerror=function(n){r(this.error);n.preventDefault()}},removeRemoteEntry:function(n,t,i){var r=n.delete(t);r.onsuccess=function(){i(null)};r.onerror=function(n){i(this.error);n.preventDefault()}},reconcile:function(n,t,i){function r(n){return n?r.errored?void 0:(r.errored=!0,i(n)):++h>=u?i(null):void 0}var u=0,o=[],f;if(Object.keys(n.entries).forEach(function(i){var f=n.entries[i],r=t.entries[i];(!r||f.timestamp>r.timestamp)&&(o.push(i),u++)}),f=[],Object.keys(t.entries).forEach(function(i){var e=t.entries[i],r=n.entries[i];r||(f.push(i),u++)}),!u)return i(null);var h=0,c=n.type==="remote"?n.db:t.db,s=c.transaction([IDBFS.DB_STORE_NAME],"readwrite"),e=s.objectStore(IDBFS.DB_STORE_NAME);s.onerror=function(n){r(this.error);n.preventDefault()};o.sort().forEach(function(n){t.type==="local"?IDBFS.loadRemoteEntry(e,n,function(t,i){if(t)return r(t);IDBFS.storeLocalEntry(n,i,r)}):IDBFS.loadLocalEntry(n,function(t,i){if(t)return r(t);IDBFS.storeRemoteEntry(e,n,i,r)})});f.sort().reverse().forEach(function(n){t.type==="local"?IDBFS.removeLocalEntry(n,r):IDBFS.removeRemoteEntry(e,n,r)})}},NODEFS={isWindows:!1,staticInit:function(){NODEFS.isWindows=!!process.platform.match(/^win/)},mount:function(n){return assert(ENVIRONMENT_IS_NODE),NODEFS.createNode(null,"/",NODEFS.getMode(n.opts.root),0)},createNode:function(n,t,i){if(!FS.isDir(i)&&!FS.isFile(i)&&!FS.isLink(i))throw new FS.ErrnoError(ERRNO_CODES.EINVAL);var r=FS.createNode(n,t,i);return r.node_ops=NODEFS.node_ops,r.stream_ops=NODEFS.stream_ops,r},getMode:function(n){var t;try{t=fs.lstatSync(n);NODEFS.isWindows&&(t.mode=t.mode|(t.mode&146)>>1)}catch(i){if(!i.code)throw i;throw new FS.ErrnoError(ERRNO_CODES[i.code]);}return t.mode},realPath:function(n){for(var t=[];n.parent!==n;)t.push(n.name),n=n.parent;return t.push(n.mount.opts.root),t.reverse(),PATH.join.apply(null,t)},flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function(n){return n in NODEFS.flagsToPermissionStringMap?NODEFS.flagsToPermissionStringMap[n]:n},node_ops:{getattr:function(n){var r=NODEFS.realPath(n),t;try{t=fs.lstatSync(r)}catch(i){if(!i.code)throw i;throw new FS.ErrnoError(ERRNO_CODES[i.code]);}return NODEFS.isWindows&&!t.blksize&&(t.blksize=4096),NODEFS.isWindows&&!t.blocks&&(t.blocks=(t.size+t.blksize-1)/t.blksize|0),{dev:t.dev,ino:t.ino,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,blksize:t.blksize,blocks:t.blocks}},setattr:function(n,t){var i=NODEFS.realPath(n),r;try{t.mode!==undefined&&(fs.chmodSync(i,t.mode),n.mode=t.mode);t.timestamp!==undefined&&(r=new Date(t.timestamp),fs.utimesSync(i,r,r));t.size!==undefined&&fs.truncateSync(i,t.size)}catch(u){if(!u.code)throw u;throw new FS.ErrnoError(ERRNO_CODES[u.code]);}},lookup:function(n,t){var i=PATH.join2(NODEFS.realPath(n),t),r=NODEFS.getMode(i);return NODEFS.createNode(n,t,r)},mknod:function(n,t,i,r){var u=NODEFS.createNode(n,t,i,r),e=NODEFS.realPath(u);try{FS.isDir(u.mode)?fs.mkdirSync(e,u.mode):fs.writeFileSync(e,"",{mode:u.mode})}catch(f){if(!f.code)throw f;throw new FS.ErrnoError(ERRNO_CODES[f.code]);}return u},rename:function(n,t,i){var u=NODEFS.realPath(n),f=PATH.join2(NODEFS.realPath(t),i);try{fs.renameSync(u,f)}catch(r){if(!r.code)throw r;throw new FS.ErrnoError(ERRNO_CODES[r.code]);}},unlink:function(n,t){var r=PATH.join2(NODEFS.realPath(n),t);try{fs.unlinkSync(r)}catch(i){if(!i.code)throw i;throw new FS.ErrnoError(ERRNO_CODES[i.code]);}},rmdir:function(n,t){var r=PATH.join2(NODEFS.realPath(n),t);try{fs.rmdirSync(r)}catch(i){if(!i.code)throw i;throw new FS.ErrnoError(ERRNO_CODES[i.code]);}},readdir:function(n){var i=NODEFS.realPath(n);try{return fs.readdirSync(i)}catch(t){if(!t.code)throw t;throw new FS.ErrnoError(ERRNO_CODES[t.code]);}},symlink:function(n,t,i){var u=PATH.join2(NODEFS.realPath(n),t);try{fs.symlinkSync(i,u)}catch(r){if(!r.code)throw r;throw new FS.ErrnoError(ERRNO_CODES[r.code]);}},readlink:function(n){var t=NODEFS.realPath(n);try{return t=fs.readlinkSync(t),NODEJS_PATH.relative(NODEJS_PATH.resolve(n.mount.opts.root),t)}catch(i){if(!i.code)throw i;throw new FS.ErrnoError(ERRNO_CODES[i.code]);}}},stream_ops:{open:function(n){var i=NODEFS.realPath(n.node);try{FS.isFile(n.node.mode)&&(n.nfd=fs.openSync(i,NODEFS.flagsToPermissionString(n.flags)))}catch(t){if(!t.code)throw t;throw new FS.ErrnoError(ERRNO_CODES[t.code]);}},close:function(n){try{FS.isFile(n.node.mode)&&n.nfd&&fs.closeSync(n.nfd)}catch(t){if(!t.code)throw t;throw new FS.ErrnoError(ERRNO_CODES[t.code]);}},read:function(n,t,i,r,u){var o,e,f;if(r===0)return 0;o=new Buffer(r);try{e=fs.readSync(n.nfd,o,0,r,u)}catch(s){throw new FS.ErrnoError(ERRNO_CODES[s.code]);}if(e>0)for(f=0;f<e;f++)t[i+f]=o[f];return e},write:function(n,t,i,r,u){var e=new Buffer(t.subarray(i,i+r)),f;try{f=fs.writeSync(n.nfd,e,0,r,u)}catch(o){throw new FS.ErrnoError(ERRNO_CODES[o.code]);}return f},llseek:function(n,t,i){var r=t,u;if(i===1)r+=n.position;else if(i===2&&FS.isFile(n.node.mode))try{u=fs.fstatSync(n.nfd);r+=u.size}catch(f){throw new FS.ErrnoError(ERRNO_CODES[f.code]);}if(r<0)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);return r}}},WORKERFS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:function(n){assert(ENVIRONMENT_IS_WORKER);WORKERFS.reader||(WORKERFS.reader=new FileReaderSync);var t=WORKERFS.createNode(null,"/",WORKERFS.DIR_MODE,0);return Array.prototype.forEach.call(n.opts.files||[],function(n){WORKERFS.createNode(t,n.name,WORKERFS.FILE_MODE,0,n,n.lastModifiedDate)}),(n.opts.blobs||[]).forEach(function(n){WORKERFS.createNode(t,n.name,WORKERFS.FILE_MODE,0,n.data)}),t},createNode:function(n,t,i,r,u,f){var e=FS.createNode(n,t,i);return e.mode=i,e.node_ops=WORKERFS.node_ops,e.stream_ops=WORKERFS.stream_ops,e.timestamp=(f||new Date).getTime(),n?(e.size=u.size,e.contents=u,n.contents[t]=e):(e.size=4096,e.contents={}),e},node_ops:{getattr:function(n){return{dev:1,ino:undefined,mode:n.mode,nlink:1,uid:0,gid:0,rdev:undefined,size:n.size,atime:new Date(n.timestamp),mtime:new Date(n.timestamp),ctime:new Date(n.timestamp),blksize:4096,blocks:Math.ceil(n.size/4096)}},setattr:function(n,t){t.mode!==undefined&&(n.mode=t.mode);t.timestamp!==undefined&&(n.timestamp=t.timestamp)},lookup:function(){throw new FS.ErrnoError(ERRNO_CODES.ENOENT);},mknod:function(){throw new FS.ErrnoError(ERRNO_CODES.EPERM);},rename:function(){throw new FS.ErrnoError(ERRNO_CODES.EPERM);},unlink:function(){throw new FS.ErrnoError(ERRNO_CODES.EPERM);},rmdir:function(){throw new FS.ErrnoError(ERRNO_CODES.EPERM);},readdir:function(){throw new FS.ErrnoError(ERRNO_CODES.EPERM);},symlink:function(){throw new FS.ErrnoError(ERRNO_CODES.EPERM);},readlink:function(){throw new FS.ErrnoError(ERRNO_CODES.EPERM);}},stream_ops:{read:function(n,t,i,r,u){if(u>=n.node.size)return 0;var f=n.node.contents.slice(u,u+r),e=WORKERFS.reader.readAsArrayBuffer(f);return t.set(new Uint8Array(e),i),f.size},write:function(){throw new FS.ErrnoError(ERRNO_CODES.EIO);},llseek:function(n,t,i){var r=t;if(i===1?r+=n.position:i===2&&FS.isFile(n.node.mode)&&(r+=n.node.size),r<0)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);return r}}},_stdin=allocate(1,"i32*",ALLOC_STATIC),_stdout=allocate(1,"i32*",ALLOC_STATIC),_stderr=allocate(1,"i32*",ALLOC_STATIC),FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},handleFSError:function(n){if(!(n instanceof FS.ErrnoError))throw n+" : "+stackTrace();return ___setErrNo(n.errno)},lookupPath:function(n,t){var s,e,u,f,h,c,l;if(n=PATH.resolve(FS.cwd(),n),t=t||{},!n)return{path:"",node:null};s={follow_mount:!0,recurse_count:0};for(e in s)t[e]===undefined&&(t[e]=s[e]);if(t.recurse_count>8)throw new FS.ErrnoError(ERRNO_CODES.ELOOP);var o=PATH.normalizeArray(n.split("/").filter(function(n){return!!n}),!1),i=FS.root,r="/";for(u=0;u<o.length;u++){if(f=u===o.length-1,f&&t.parent)break;if(i=FS.lookupNode(i,o[u]),r=PATH.join2(r,o[u]),FS.isMountpoint(i)&&(!f||f&&t.follow_mount)&&(i=i.mounted.root),!f||t.follow)for(h=0;FS.isLink(i.mode);)if(c=FS.readlink(r),r=PATH.resolve(PATH.dirname(r),c),l=FS.lookupPath(r,{recurse_count:t.recurse_count}),i=l.node,h++>40)throw new FS.ErrnoError(ERRNO_CODES.ELOOP);}return{path:r,node:i}},getPath:function(n){for(var t,i;;){if(FS.isRoot(n))return(i=n.mount.mountpoint,!t)?i:i[i.length-1]!=="/"?i+"/"+t:i+t;t=t?n.name+"/"+t:n.name;n=n.parent}},hashName:function(n,t){for(var i=0,r=0;r<t.length;r++)i=(i<<5)-i+t.charCodeAt(r)|0;return(n+i>>>0)%FS.nameTable.length},hashAddNode:function(n){var t=FS.hashName(n.parent.id,n.name);n.name_next=FS.nameTable[t];FS.nameTable[t]=n},hashRemoveNode:function(n){var i=FS.hashName(n.parent.id,n.name),t;if(FS.nameTable[i]===n)FS.nameTable[i]=n.name_next;else for(t=FS.nameTable[i];t;){if(t.name_next===n){t.name_next=n.name_next;break}t=t.name_next}},lookupNode:function(n,t){var r=FS.mayLookup(n),u,i,f;if(r)throw new FS.ErrnoError(r,n);for(u=FS.hashName(n.id,t),i=FS.nameTable[u];i;i=i.name_next)if(f=i.name,i.parent.id===n.id&&f===t)return i;return FS.lookup(n,t)},createNode:function(n,t,i,r){var u,f,e;return FS.FSNode||(FS.FSNode=function(n,t,i,r){n||(n=this);this.parent=n;this.mount=n.mount;this.mounted=null;this.id=FS.nextInode++;this.name=t;this.mode=i;this.node_ops={};this.stream_ops={};this.rdev=r},FS.FSNode.prototype={},u=365,f=146,Object.defineProperties(FS.FSNode.prototype,{read:{get:function(){return(this.mode&u)===u},set:function(n){n?this.mode|=u:this.mode&=~u}},write:{get:function(){return(this.mode&f)===f},set:function(n){n?this.mode|=f:this.mode&=~f}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}})),e=new FS.FSNode(n,t,i,r),FS.hashAddNode(e),e},destroyNode:function(n){FS.hashRemoveNode(n)},isRoot:function(n){return n===n.parent},isMountpoint:function(n){return!!n.mounted},isFile:function(n){return(n&61440)==32768},isDir:function(n){return(n&61440)==16384},isLink:function(n){return(n&61440)==40960},isChrdev:function(n){return(n&61440)==8192},isBlkdev:function(n){return(n&61440)==24576},isFIFO:function(n){return(n&61440)==4096},isSocket:function(n){return(n&49152)==49152},flagModes:{r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(n){var t=FS.flagModes[n];if(typeof t=="undefined")throw new Error("Unknown file open mode: "+n);return t},flagsToPermissionString:function(n){var t=["r","w","rw"][n&3];return n&512&&(t+="w"),t},nodePermissions:function(n,t){if(FS.ignorePermissions)return 0;if(t.indexOf("r")===-1||n.mode&292)if(t.indexOf("w")===-1||n.mode&146){if(t.indexOf("x")!==-1&&!(n.mode&73))return ERRNO_CODES.EACCES}else return ERRNO_CODES.EACCES;else return ERRNO_CODES.EACCES;return 0},mayLookup:function(n){var t=FS.nodePermissions(n,"x");return t?t:n.node_ops.lookup?0:ERRNO_CODES.EACCES},mayCreate:function(n,t){try{var i=FS.lookupNode(n,t);return ERRNO_CODES.EEXIST}catch(r){}return FS.nodePermissions(n,"wx")},mayDelete:function(n,t,i){var r,u;try{r=FS.lookupNode(n,t)}catch(f){return f.errno}if(u=FS.nodePermissions(n,"wx"),u)return u;if(i){if(!FS.isDir(r.mode))return ERRNO_CODES.ENOTDIR;if(FS.isRoot(r)||FS.getPath(r)===FS.cwd())return ERRNO_CODES.EBUSY}else if(FS.isDir(r.mode))return ERRNO_CODES.EISDIR;return 0},mayOpen:function(n,t){return n?FS.isLink(n.mode)?ERRNO_CODES.ELOOP:FS.isDir(n.mode)&&((t&2097155)!=0||t&512)?ERRNO_CODES.EISDIR:FS.nodePermissions(n,FS.flagsToPermissionString(t)):ERRNO_CODES.ENOENT},MAX_OPEN_FDS:4096,nextfd:function(n,t){n=n||0;t=t||FS.MAX_OPEN_FDS;for(var i=n;i<=t;i++)if(!FS.streams[i])return i;throw new FS.ErrnoError(ERRNO_CODES.EMFILE);},getStream:function(n){return FS.streams[n]},createStream:function(n,t,i){var r,u,f;FS.FSStream||(FS.FSStream=function(){},FS.FSStream.prototype={},Object.defineProperties(FS.FSStream.prototype,{object:{get:function(){return this.node},set:function(n){this.node=n}},isRead:{get:function(){return(this.flags&2097155)!=1}},isWrite:{get:function(){return(this.flags&2097155)!=0}},isAppend:{get:function(){return this.flags&1024}}}));r=new FS.FSStream;for(u in n)r[u]=n[u];return n=r,f=FS.nextfd(t,i),n.fd=f,FS.streams[f]=n,n},closeStream:function(n){FS.streams[n]=null},chrdev_stream_ops:{open:function(n){var t=FS.getDevice(n.node.rdev);n.stream_ops=t.stream_ops;n.stream_ops.open&&n.stream_ops.open(n)},llseek:function(){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);}},major:function(n){return n>>8},minor:function(n){return n&255},makedev:function(n,t){return n<<8|t},registerDevice:function(n,t){FS.devices[n]={stream_ops:t}},getDevice:function(n){return FS.devices[n]},getMounts:function(n){for(var r=[],t=[n],i;t.length;)i=t.pop(),r.push(i),t.push.apply(t,i.mounts);return r},syncfs:function(n,t){function i(n){if(n)return i.errored?void 0:(i.errored=!0,t(n));++u>=r.length&&t(null)}typeof n=="function"&&(t=n,n=!1);var r=FS.getMounts(FS.root.mount),u=0;r.forEach(function(t){if(!t.type.syncfs)return i(null);t.type.syncfs(t,n,i)})},mount:function(n,t,i){var e=i==="/",s=!i,r,o,u,f;if(e&&FS.root)throw new FS.ErrnoError(ERRNO_CODES.EBUSY);else if(!e&&!s){if(o=FS.lookupPath(i,{follow_mount:!1}),i=o.path,r=o.node,FS.isMountpoint(r))throw new FS.ErrnoError(ERRNO_CODES.EBUSY);if(!FS.isDir(r.mode))throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);}return u={type:n,opts:t,mountpoint:i,mounts:[]},f=n.mount(u),f.mount=u,u.root=f,e?FS.root=f:r&&(r.mounted=u,r.mount&&r.mount.mounts.push(u)),f},unmount:function(n){var r=FS.lookupPath(n,{follow_mount:!1}),i;if(!FS.isMountpoint(r.node))throw new FS.ErrnoError(ERRNO_CODES.EINVAL);var t=r.node,u=t.mounted,f=FS.getMounts(u);Object.keys(FS.nameTable).forEach(function(n){for(var t=FS.nameTable[n],i;t;)i=t.name_next,f.indexOf(t.mount)!==-1&&FS.destroyNode(t),t=i});t.mounted=null;i=t.mount.mounts.indexOf(u);assert(i!==-1);t.mount.mounts.splice(i,1)},lookup:function(n,t){return n.node_ops.lookup(n,t)},mknod:function(n,t,i){var e=FS.lookupPath(n,{parent:!0}),u=e.node,r=PATH.basename(n),f;if(!r||r==="."||r==="..")throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if(f=FS.mayCreate(u,r),f)throw new FS.ErrnoError(f);if(!u.node_ops.mknod)throw new FS.ErrnoError(ERRNO_CODES.EPERM);return u.node_ops.mknod(u,r,t,i)},create:function(n,t){return t=t!==undefined?t:438,t&=4095,t|=32768,FS.mknod(n,t,0)},mkdir:function(n,t){return t=t!==undefined?t:511,t&=1023,t|=16384,FS.mknod(n,t,0)},mkdev:function(n,t,i){return typeof i=="undefined"&&(i=t,t=438),t|=8192,FS.mknod(n,t,i)},symlink:function(n,t){var f,i,r,u;if(!PATH.resolve(n))throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(f=FS.lookupPath(t,{parent:!0}),i=f.node,!i)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(r=PATH.basename(t),u=FS.mayCreate(i,r),u)throw new FS.ErrnoError(u);if(!i.node_ops.symlink)throw new FS.ErrnoError(ERRNO_CODES.EPERM);return i.node_ops.symlink(i,r,n)},rename:function(n,t){var v=PATH.dirname(n),y=PATH.dirname(t),a=PATH.basename(n),o=PATH.basename(t),s,i,u,f,h,e,l,r;try{s=FS.lookupPath(n,{parent:!0});i=s.node;s=FS.lookupPath(t,{parent:!0});u=s.node}catch(c){throw new FS.ErrnoError(ERRNO_CODES.EBUSY);}if(!i||!u)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(i.mount!==u.mount)throw new FS.ErrnoError(ERRNO_CODES.EXDEV);if(f=FS.lookupNode(i,a),h=PATH.relative(n,y),h.charAt(0)!==".")throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if(h=PATH.relative(t,v),h.charAt(0)!==".")throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);try{e=FS.lookupNode(u,o)}catch(c){}if(f!==e){if(l=FS.isDir(f.mode),r=FS.mayDelete(i,a,l),r)throw new FS.ErrnoError(r);if(r=e?FS.mayDelete(u,o,l):FS.mayCreate(u,o),r)throw new FS.ErrnoError(r);if(!i.node_ops.rename)throw new FS.ErrnoError(ERRNO_CODES.EPERM);if(FS.isMountpoint(f)||e&&FS.isMountpoint(e))throw new FS.ErrnoError(ERRNO_CODES.EBUSY);if(u!==i&&(r=FS.nodePermissions(i,"w"),r))throw new FS.ErrnoError(r);try{FS.trackingDelegate.willMovePath&&FS.trackingDelegate.willMovePath(n,t)}catch(c){console.log("FS.trackingDelegate['willMovePath']('"+n+"', '"+t+"') threw an exception: "+c.message)}FS.hashRemoveNode(f);try{i.node_ops.rename(f,u,o)}catch(c){throw c;}finally{FS.hashAddNode(f)}try{if(FS.trackingDelegate.onMovePath)FS.trackingDelegate.onMovePath(n,t)}catch(c){console.log("FS.trackingDelegate['onMovePath']('"+n+"', '"+t+"') threw an exception: "+c.message)}}},rmdir:function(n){var e=FS.lookupPath(n,{parent:!0}),t=e.node,i=PATH.basename(n),r=FS.lookupNode(t,i),u=FS.mayDelete(t,i,!0);if(u)throw new FS.ErrnoError(u);if(!t.node_ops.rmdir)throw new FS.ErrnoError(ERRNO_CODES.EPERM);if(FS.isMountpoint(r))throw new FS.ErrnoError(ERRNO_CODES.EBUSY);try{FS.trackingDelegate.willDeletePath&&FS.trackingDelegate.willDeletePath(n)}catch(f){console.log("FS.trackingDelegate['willDeletePath']('"+n+"') threw an exception: "+f.message)}t.node_ops.rmdir(t,i);FS.destroyNode(r);try{if(FS.trackingDelegate.onDeletePath)FS.trackingDelegate.onDeletePath(n)}catch(f){console.log("FS.trackingDelegate['onDeletePath']('"+n+"') threw an exception: "+f.message)}},readdir:function(n){var i=FS.lookupPath(n,{follow:!0}),t=i.node;if(!t.node_ops.readdir)throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);return t.node_ops.readdir(t)},unlink:function(n){var e=FS.lookupPath(n,{parent:!0}),t=e.node,r=PATH.basename(n),u=FS.lookupNode(t,r),i=FS.mayDelete(t,r,!1);if(i){i===ERRNO_CODES.EISDIR&&(i=ERRNO_CODES.EPERM);throw new FS.ErrnoError(i);}if(!t.node_ops.unlink)throw new FS.ErrnoError(ERRNO_CODES.EPERM);if(FS.isMountpoint(u))throw new FS.ErrnoError(ERRNO_CODES.EBUSY);try{FS.trackingDelegate.willDeletePath&&FS.trackingDelegate.willDeletePath(n)}catch(f){console.log("FS.trackingDelegate['willDeletePath']('"+n+"') threw an exception: "+f.message)}t.node_ops.unlink(t,r);FS.destroyNode(u);try{if(FS.trackingDelegate.onDeletePath)FS.trackingDelegate.onDeletePath(n)}catch(f){console.log("FS.trackingDelegate['onDeletePath']('"+n+"') threw an exception: "+f.message)}},readlink:function(n){var i=FS.lookupPath(n),t=i.node;if(!t)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(!t.node_ops.readlink)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);return PATH.resolve(FS.getPath(t.parent),t.node_ops.readlink(t))},stat:function(n,t){var r=FS.lookupPath(n,{follow:!t}),i=r.node;if(!i)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(!i.node_ops.getattr)throw new FS.ErrnoError(ERRNO_CODES.EPERM);return i.node_ops.getattr(i)},lstat:function(n){return FS.stat(n,!0)},chmod:function(n,t,i){var r,u;if(typeof n=="string"?(u=FS.lookupPath(n,{follow:!i}),r=u.node):r=n,!r.node_ops.setattr)throw new FS.ErrnoError(ERRNO_CODES.EPERM);r.node_ops.setattr(r,{mode:t&4095|r.mode&-4096,timestamp:Date.now()})},lchmod:function(n,t){FS.chmod(n,t,!0)},fchmod:function(n,t){var i=FS.getStream(n);if(!i)throw new FS.ErrnoError(ERRNO_CODES.EBADF);FS.chmod(i.node,t)},chown:function(n,t,i,r){var u,f;if(typeof n=="string"?(f=FS.lookupPath(n,{follow:!r}),u=f.node):u=n,!u.node_ops.setattr)throw new FS.ErrnoError(ERRNO_CODES.EPERM);u.node_ops.setattr(u,{timestamp:Date.now()})},lchown:function(n,t,i){FS.chown(n,t,i,!0)},fchown:function(n,t,i){var r=FS.getStream(n);if(!r)throw new FS.ErrnoError(ERRNO_CODES.EBADF);FS.chown(r.node,t,i)},truncate:function(n,t){var i,u,r;if(t<0)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if(typeof n=="string"?(u=FS.lookupPath(n,{follow:!0}),i=u.node):i=n,!i.node_ops.setattr)throw new FS.ErrnoError(ERRNO_CODES.EPERM);if(FS.isDir(i.mode))throw new FS.ErrnoError(ERRNO_CODES.EISDIR);if(!FS.isFile(i.mode))throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if(r=FS.nodePermissions(i,"w"),r)throw new FS.ErrnoError(r);i.node_ops.setattr(i,{size:t,timestamp:Date.now()})},ftruncate:function(n,t){var i=FS.getStream(n);if(!i)throw new FS.ErrnoError(ERRNO_CODES.EBADF);if((i.flags&2097155)==0)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);FS.truncate(i.node,t)},utime:function(n,t,i){var u=FS.lookupPath(n,{follow:!0}),r=u.node;r.node_ops.setattr(r,{timestamp:Math.max(t,i)})},open:function(n,t,i,r,u){var f,c,s,h,e,o;if(n==="")throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(t=typeof t=="string"?FS.modeStringToFlags(t):t,i=typeof i=="undefined"?438:i,i=t&64?i&4095|32768:0,typeof n=="object")f=n;else{n=PATH.normalize(n);try{c=FS.lookupPath(n,{follow:!(t&131072)});f=c.node}catch(l){}}if(s=!1,t&64)if(f){if(t&128)throw new FS.ErrnoError(ERRNO_CODES.EEXIST);}else f=FS.mknod(n,i,0),s=!0;if(!f)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(FS.isChrdev(f.mode)&&(t&=-513),t&65536&&!FS.isDir(f.mode))throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);if(!s&&(h=FS.mayOpen(f,t),h))throw new FS.ErrnoError(h);t&512&&FS.truncate(f,0);t&=-641;e=FS.createStream({node:f,path:FS.getPath(f),flags:t,seekable:!0,position:0,stream_ops:f.stream_ops,ungotten:[],error:!1},r,u);e.stream_ops.open&&e.stream_ops.open(e);!Module.logReadFiles||t&1||(FS.readFiles||(FS.readFiles={}),n in FS.readFiles||(FS.readFiles[n]=1,Module.printErr("read file: "+n)));try{if(FS.trackingDelegate.onOpenFile){o=0;(t&2097155)!=1&&(o|=FS.tracking.openFlags.READ);(t&2097155)!=0&&(o|=FS.tracking.openFlags.WRITE);FS.trackingDelegate.onOpenFile(n,o)}}catch(l){console.log("FS.trackingDelegate['onOpenFile']('"+n+"', flags) threw an exception: "+l.message)}return e},close:function(n){n.getdents&&(n.getdents=null);try{n.stream_ops.close&&n.stream_ops.close(n)}catch(t){throw t;}finally{FS.closeStream(n.fd)}},llseek:function(n,t,i){if(!n.seekable||!n.stream_ops.llseek)throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);return n.position=n.stream_ops.llseek(n,t,i),n.ungotten=[],n.position},read:function(n,t,i,r,u){var f,e;if(r<0||u<0)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if((n.flags&2097155)==1)throw new FS.ErrnoError(ERRNO_CODES.EBADF);if(FS.isDir(n.node.mode))throw new FS.ErrnoError(ERRNO_CODES.EISDIR);if(!n.stream_ops.read)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if(f=!0,typeof u=="undefined")u=n.position,f=!1;else if(!n.seekable)throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);return e=n.stream_ops.read(n,t,i,r,u),f||(n.position+=e),e},write:function(n,t,i,r,u,f){var e,o;if(r<0||u<0)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if((n.flags&2097155)==0)throw new FS.ErrnoError(ERRNO_CODES.EBADF);if(FS.isDir(n.node.mode))throw new FS.ErrnoError(ERRNO_CODES.EISDIR);if(!n.stream_ops.write)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if(n.flags&1024&&FS.llseek(n,0,2),e=!0,typeof u=="undefined")u=n.position,e=!1;else if(!n.seekable)throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);o=n.stream_ops.write(n,t,i,r,u,f);e||(n.position+=o);try{if(n.path&&FS.trackingDelegate.onWriteToFile)FS.trackingDelegate.onWriteToFile(n.path)}catch(s){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+s.message)}return o},allocate:function(n,t,i){if(t<0||i<=0)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if((n.flags&2097155)==0)throw new FS.ErrnoError(ERRNO_CODES.EBADF);if(!FS.isFile(n.node.mode)&&!FS.isDir(node.mode))throw new FS.ErrnoError(ERRNO_CODES.ENODEV);if(!n.stream_ops.allocate)throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);n.stream_ops.allocate(n,t,i)},mmap:function(n,t,i,r,u,f,e){if((n.flags&2097155)==1)throw new FS.ErrnoError(ERRNO_CODES.EACCES);if(!n.stream_ops.mmap)throw new FS.ErrnoError(ERRNO_CODES.ENODEV);return n.stream_ops.mmap(n,t,i,r,u,f,e)},msync:function(n,t,i,r,u){return!n||!n.stream_ops.msync?0:n.stream_ops.msync(n,t,i,r,u)},munmap:function(){return 0},ioctl:function(n,t,i){if(!n.stream_ops.ioctl)throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);return n.stream_ops.ioctl(n,t,i)},readFile:function(n,t){if(t=t||{},t.flags=t.flags||"r",t.encoding=t.encoding||"binary",t.encoding!=="utf8"&&t.encoding!=="binary")throw new Error('Invalid encoding type "'+t.encoding+'"');var i,u=FS.open(n,t.flags),e=FS.stat(n),f=e.size,r=new Uint8Array(f);return FS.read(u,r,0,f,0),t.encoding==="utf8"?i=UTF8ArrayToString(r,0):t.encoding==="binary"&&(i=r),FS.close(u),i},writeFile:function(n,t,i){var r,u,f;if(i=i||{},i.flags=i.flags||"w",i.encoding=i.encoding||"utf8",i.encoding!=="utf8"&&i.encoding!=="binary")throw new Error('Invalid encoding type "'+i.encoding+'"');r=FS.open(n,i.flags,i.mode);i.encoding==="utf8"?(u=new Uint8Array(lengthBytesUTF8(t)+1),f=stringToUTF8Array(t,u,0,u.length),FS.write(r,u,0,f,0,i.canOwn)):i.encoding==="binary"&&FS.write(r,t,0,t.length,0,i.canOwn);FS.close(r)},cwd:function(){return FS.currentPath},chdir:function(n){var t=FS.lookupPath(n,{follow:!0}),i;if(!FS.isDir(t.node.mode))throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);if(i=FS.nodePermissions(t.node,"x"),i)throw new FS.ErrnoError(i);FS.currentPath=t.path},createDefaultDirectories:function(){FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")},createDefaultDevices:function(){var n,t;FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:function(){return 0},write:function(n,t,i,r){return r}});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));typeof crypto!="undefined"?(t=new Uint8Array(1),n=function(){return crypto.getRandomValues(t),t[0]}):n=ENVIRONMENT_IS_NODE?function(){return require("crypto").randomBytes(1)[0]}:function(){return Math.random()*256|0};FS.createDevice("/dev","random",n);FS.createDevice("/dev","urandom",n);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){FS.mkdir("/proc");FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd");FS.mount({mount:function(){var n=FS.createNode("/proc/self","fd",16384|0777,73);return n.node_ops={lookup:function(n,t){var u=+t,r=FS.getStream(u),i;if(!r)throw new FS.ErrnoError(ERRNO_CODES.EBADF);return i={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return r.path}}},i.parent=i,i}},n}},{},"/proc/self/fd")},createStandardStreams:function(){var n,t,i;Module.stdin?FS.createDevice("/dev","stdin",Module.stdin):FS.symlink("/dev/tty","/dev/stdin");Module.stdout?FS.createDevice("/dev","stdout",null,Module.stdout):FS.symlink("/dev/tty","/dev/stdout");Module.stderr?FS.createDevice("/dev","stderr",null,Module.stderr):FS.symlink("/dev/tty1","/dev/stderr");n=FS.open("/dev/stdin","r");assert(n.fd===0,"invalid handle for stdin ("+n.fd+")");t=FS.open("/dev/stdout","w");assert(t.fd===1,"invalid handle for stdout ("+t.fd+")");i=FS.open("/dev/stderr","w");assert(i.fd===2,"invalid handle for stderr ("+i.fd+")")},ensureErrnoError:function(){FS.ErrnoError||(FS.ErrnoError=function(n,t){this.node=t;this.setErrno=function(n){this.errno=n;for(var t in ERRNO_CODES)if(ERRNO_CODES[t]===n){this.code=t;break}};this.setErrno(n);this.message=ERRNO_MESSAGES[n]},FS.ErrnoError.prototype=new Error,FS.ErrnoError.prototype.constructor=FS.ErrnoError,[ERRNO_CODES.ENOENT].forEach(function(n){FS.genericErrors[n]=new FS.ErrnoError(n);FS.genericErrors[n].stack="<generic error, no stack>"}))},staticInit:function(){FS.ensureErrnoError();FS.nameTable=new Array(4096);FS.mount(MEMFS,{},"/");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories()},init:function(n,t,i){assert(!FS.init.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)");FS.init.initialized=!0;FS.ensureErrnoError();Module.stdin=n||Module.stdin;Module.stdout=t||Module.stdout;Module.stderr=i||Module.stderr;FS.createStandardStreams()},quit:function(){var t,n,i;for(FS.init.initialized=!1,t=Module._fflush,t&&t(0),n=0;n<FS.streams.length;n++)(i=FS.streams[n],i)&&FS.close(i)},getMode:function(n,t){var i=0;return n&&(i|=365),t&&(i|=146),i},joinPath:function(n,t){var i=PATH.join.apply(null,n);return t&&i[0]=="/"&&(i=i.substr(1)),i},absolutePath:function(n,t){return PATH.resolve(t,n)},standardizePath:function(n){return PATH.normalize(n)},findObject:function(n,t){var i=FS.analyzePath(n,t);return i.exists?i.object:(___setErrNo(i.error),null)},analyzePath:function(n,t){var i,r;try{r=FS.lookupPath(n,{follow:!t});n=r.path}catch(u){}i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{r=FS.lookupPath(n,{parent:!0});i.parentExists=!0;i.parentPath=r.path;i.parentObject=r.node;i.name=PATH.basename(n);r=FS.lookupPath(n,{follow:!t});i.exists=!0;i.path=r.path;i.object=r.node;i.name=r.node.name;i.isRoot=r.path==="/"}catch(u){i.error=u.errno}return i},createFolder:function(n,t,i,r){var u=PATH.join2(typeof n=="string"?n:FS.getPath(n),t),f=FS.getMode(i,r);return FS.mkdir(u,f)},createPath:function(n,t){var r,u,i;for(n=typeof n=="string"?n:FS.getPath(n),r=t.split("/").reverse();r.length;)if(u=r.pop(),u){i=PATH.join2(n,u);try{FS.mkdir(i)}catch(f){}n=i}return i},createFile:function(n,t,i,r,u){var f=PATH.join2(typeof n=="string"?n:FS.getPath(n),t),e=FS.getMode(r,u);return FS.create(f,e)},createDataFile:function(n,t,i,r,u,f){var a=t?PATH.join2(typeof n=="string"?n:FS.getPath(n),t):n,s=FS.getMode(r,u),o=FS.create(a,s),h,e,l,c;if(i){if(typeof i=="string"){for(h=new Array(i.length),e=0,l=i.length;e<l;++e)h[e]=i.charCodeAt(e);i=h}FS.chmod(o,s|146);c=FS.open(o,"w");FS.write(c,i,0,i.length,0,f);FS.close(c);FS.chmod(o,s)}return o},createDevice:function(n,t,i,r){var f=PATH.join2(typeof n=="string"?n:FS.getPath(n),t),e=FS.getMode(!!i,!!r),u;return FS.createDevice.major||(FS.createDevice.major=64),u=FS.makedev(FS.createDevice.major++,0),FS.registerDevice(u,{open:function(n){n.seekable=!1},close:function(){r&&r.buffer&&r.buffer.length&&r(10)},read:function(n,t,r,u){for(var e=0,f,o=0;o<u;o++){try{f=i()}catch(s){throw new FS.ErrnoError(ERRNO_CODES.EIO);}if(f===undefined&&e===0)throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);if(f===null||f===undefined)break;e++;t[r+o]=f}return e&&(n.node.timestamp=Date.now()),e},write:function(n,t,i,u){for(var f=0;f<u;f++)try{r(t[i+f])}catch(e){throw new FS.ErrnoError(ERRNO_CODES.EIO);}return u&&(n.node.timestamp=Date.now()),f}}),FS.mkdev(f,e,u)},createLink:function(n,t,i){var r=PATH.join2(typeof n=="string"?n:FS.getPath(n),t);return FS.symlink(i,r)},forceLoadFile:function(n){if(n.isDevice||n.isFolder||n.link||n.contents)return!0;var t=!0;if(typeof XMLHttpRequest!="undefined")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else if(Module.read)try{n.contents=intArrayFromString(Module.read(n.url),!0);n.usedBytes=n.contents.length}catch(i){t=!1}else throw new Error("Cannot load without read() or XMLHttpRequest.");return t||___setErrNo(ERRNO_CODES.EIO),t},createLazyFile:function(n,t,i,r,u){function o(){this.lengthKnown=!1;this.chunks=[]}var s,e,f,h,c;if(o.prototype.get=function(n){if(n>this.length-1||n<0)return undefined;var t=n%this.chunkSize,i=n/this.chunkSize|0;return this.getter(i)[t]},o.prototype.setDataGetter=function(n){this.getter=n},o.prototype.cacheLength=function(){var n=new XMLHttpRequest,e,r;if(n.open("HEAD",i,!1),n.send(null),!(n.status>=200&&n.status<300||n.status===304))throw new Error("Couldn't load "+i+". Status: "+n.status);var t=Number(n.getResponseHeader("Content-length")),f,o=(f=n.getResponseHeader("Accept-Ranges"))&&f==="bytes",u=1048576;o||(u=t);e=function(n,r){if(n>r)throw new Error("invalid range ("+n+", "+r+") or no bytes requested!");if(r>t-1)throw new Error("only "+t+" bytes available! programmer error!");var f=new XMLHttpRequest;if(f.open("GET",i,!1),t!==u&&f.setRequestHeader("Range","bytes="+n+"-"+r),typeof Uint8Array!="undefined"&&(f.responseType="arraybuffer"),f.overrideMimeType&&f.overrideMimeType("text/plain; charset=x-user-defined"),f.send(null),!(f.status>=200&&f.status<300||f.status===304))throw new Error("Couldn't load "+i+". Status: "+f.status);return f.response!==undefined?new Uint8Array(f.response||[]):intArrayFromString(f.responseText||"",!0)};r=this;r.setDataGetter(function(n){var f=n*u,i=(n+1)*u-1;if(i=Math.min(i,t-1),typeof r.chunks[n]=="undefined"&&(r.chunks[n]=e(f,i)),typeof r.chunks[n]=="undefined")throw new Error("doXHR failed!");return r.chunks[n]});this._length=t;this._chunkSize=u;this.lengthKnown=!0},typeof XMLHttpRequest!="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";s=new o;Object.defineProperty(s,"length",{get:function(){return this.lengthKnown||this.cacheLength(),this._length}});Object.defineProperty(s,"chunkSize",{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}});e={isDevice:!1,contents:s}}else e={isDevice:!1,url:i};return f=FS.createFile(n,t,e,r,u),e.contents?f.contents=e.contents:e.url&&(f.contents=null,f.url=e.url),Object.defineProperty(f,"usedBytes",{get:function(){return this.contents.length}}),h={},c=Object.keys(f.stream_ops),c.forEach(function(n){var t=f.stream_ops[n];h[n]=function(){if(!FS.forceLoadFile(f))throw new FS.ErrnoError(ERRNO_CODES.EIO);return t.apply(null,arguments)}}),h.read=function(n,t,i,r,u){var o,s,e;if(!FS.forceLoadFile(f))throw new FS.ErrnoError(ERRNO_CODES.EIO);if(o=n.node.contents,u>=o.length)return 0;if(s=Math.min(o.length-u,r),assert(s>=0),o.slice)for(e=0;e<s;e++)t[i+e]=o[u+e];else for(e=0;e<s;e++)t[i+e]=o.get(u+e);return s},f.stream_ops=h,f},createPreloadedFile:function(n,t,i,r,u,f,e,o,s,h){function a(i){function v(i){h&&h();o||FS.createDataFile(n,t,i,r,u,s);f&&f();removeRunDependency(l)}var a=!1;Module.preloadPlugins.forEach(function(n){a||n.canHandle(c)&&(n.handle(i,c,v,function(){e&&e();removeRunDependency(l)}),a=!0)});a||v(i)}Browser.init();var c=t?PATH.resolve(PATH.join2(n,t)):n,l=getUniqueRunDependency("cp "+c);addRunDependency(l);typeof i=="string"?Browser.asyncLoad(i,function(n){a(n)},e):a(i)},indexedDB:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},DB_NAME:function(){return"EM_FS_"+window.location.pathname},DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function(n,t,i){var u,r;t=t||function(){};i=i||function(){};u=FS.indexedDB();try{r=u.open(FS.DB_NAME(),FS.DB_VERSION)}catch(f){return i(f)}r.onupgradeneeded=function(){console.log("creating db");var n=r.result;n.createObjectStore(FS.DB_STORE_NAME)};r.onsuccess=function(){function s(){u==0?t():i()}var h=r.result,e=h.transaction([FS.DB_STORE_NAME],"readwrite"),c=e.objectStore(FS.DB_STORE_NAME),f=0,u=0,o=n.length;n.forEach(function(n){var t=c.put(FS.analyzePath(n).object.contents,n);t.onsuccess=function(){f++;f+u==o&&s()};t.onerror=function(){u++;f+u==o&&s()}});e.onerror=i};r.onerror=i},loadFilesFromDB:function(n,t,i){var u,r;t=t||function(){};i=i||function(){};u=FS.indexedDB();try{r=u.open(FS.DB_NAME(),FS.DB_VERSION)}catch(f){return i(f)}r.onupgradeneeded=i;r.onsuccess=function(){function s(){u==0?t():i()}var h=r.result,f;try{f=h.transaction([FS.DB_STORE_NAME],"readonly")}catch(c){i(c);return}var l=f.objectStore(FS.DB_STORE_NAME),e=0,u=0,o=n.length;n.forEach(function(n){var t=l.get(n);t.onsuccess=function(){FS.analyzePath(n).exists&&FS.unlink(n);FS.createDataFile(PATH.dirname(n),PATH.basename(n),t.result,!0,!0,!0);e++;e+u==o&&s()};t.onerror=function(){u++;e+u==o&&s()}});f.onerror=i};r.onerror=i}},SYSCALLS={DEFAULT_POLLMASK:5,mappings:{},umask:511,calculateAt:function(n,t){var i,r;if(t[0]!=="/"){if(n===-100)i=FS.cwd();else{if(r=FS.getStream(n),!r)throw new FS.ErrnoError(ERRNO_CODES.EBADF);i=r.path}t=PATH.join2(i,t)}return t},doStat:function(n,t,i){try{var r=n(t)}catch(u){if(u&&u.node&&PATH.normalize(t)!==PATH.normalize(FS.getPath(u.node)))return-ERRNO_CODES.ENOTDIR;throw u;}return HEAP32[i>>2]=r.dev,HEAP32[i+4>>2]=0,HEAP32[i+8>>2]=r.ino,HEAP32[i+12>>2]=r.mode,HEAP32[i+16>>2]=r.nlink,HEAP32[i+20>>2]=r.uid,HEAP32[i+24>>2]=r.gid,HEAP32[i+28>>2]=r.rdev,HEAP32[i+32>>2]=0,HEAP32[i+36>>2]=r.size,HEAP32[i+40>>2]=4096,HEAP32[i+44>>2]=r.blocks,HEAP32[i+48>>2]=r.atime.getTime()/1e3|0,HEAP32[i+52>>2]=0,HEAP32[i+56>>2]=r.mtime.getTime()/1e3|0,HEAP32[i+60>>2]=0,HEAP32[i+64>>2]=r.ctime.getTime()/1e3|0,HEAP32[i+68>>2]=0,HEAP32[i+72>>2]=r.ino,0},doMsync:function(n,t,i,r){var u=new Uint8Array(HEAPU8.buffer,n,i);FS.msync(t,u,0,i,r)},doMkdir:function(n,t){return n=PATH.normalize(n),n[n.length-1]==="/"&&(n=n.substr(0,n.length-1)),FS.mkdir(n,t,0),0},doMknod:function(n,t,i){switch(t&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-ERRNO_CODES.EINVAL}return FS.mknod(n,t,i),0},doReadlink:function(n,t,i){if(i<=0)return-ERRNO_CODES.EINVAL;var r=FS.readlink(n);return r=r.slice(0,Math.max(0,i)),writeStringToMemory(r,t,!0),r.length},doAccess:function(n,t){var r,u,i;return t&-8?-ERRNO_CODES.EINVAL:(u=FS.lookupPath(n,{follow:!0}),r=u.node,i="",t&4&&(i+="r"),t&2&&(i+="w"),t&1&&(i+="x"),i&&FS.nodePermissions(r,i))?-ERRNO_CODES.EACCES:0},doDup:function(n,t,i){var r=FS.getStream(i);return r&&FS.close(r),FS.open(n,t,0,i,i).fd},doReadv:function(n,t,i,r){for(var e=0,u=0;u<i;u++){var s=HEAP32[t+u*8>>2],o=HEAP32[t+(u*8+4)>>2],f=FS.read(n,HEAP8,s,o,r);if(f<0)return-1;if(e+=f,f<o)break}return e},doWritev:function(n,t,i,r){for(var f=0,u=0;u<i;u++){var o=HEAP32[t+u*8>>2],s=HEAP32[t+(u*8+4)>>2],e=FS.write(n,HEAP8,o,s,r);if(e<0)return-1;f+=e}return f},varargs:0,get:function(){SYSCALLS.varargs+=4;return HEAP32[SYSCALLS.varargs-4>>2]},getStr:function(){return Pointer_stringify(SYSCALLS.get())},getStreamFromFD:function(){var n=FS.getStream(SYSCALLS.get());if(!n)throw new FS.ErrnoError(ERRNO_CODES.EBADF);return n},getSocketFromFD:function(){var n=SOCKFS.getSocket(SYSCALLS.get());if(!n)throw new FS.ErrnoError(ERRNO_CODES.EBADF);return n},getSocketAddress:function(n){var i=SYSCALLS.get(),r=SYSCALLS.get(),t;if(n&&i===0)return null;if(t=__read_sockaddr(i,r),t.errno)throw new FS.ErrnoError(t.errno);return t.addr=DNS.lookup_addr(t.addr)||t.addr,t},get64:function(){var n=SYSCALLS.get(),t=SYSCALLS.get();return n>=0?assert(t===0):assert(t===-1),n},getZero:function(){assert(SYSCALLS.get()===0)}};Module._memcpy=_memcpy;Browser={mainLoop:{scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],pause:function(){Browser.mainLoop.scheduler=null;Browser.mainLoop.currentlyRunningMainloop++},resume:function(){Browser.mainLoop.currentlyRunningMainloop++;var n=Browser.mainLoop.timingMode,t=Browser.mainLoop.timingValue,i=Browser.mainLoop.func;Browser.mainLoop.func=null;_emscripten_set_main_loop(i,0,!1,Browser.mainLoop.arg,!0);_emscripten_set_main_loop_timing(n,t);Browser.mainLoop.scheduler()},updateStatus:function(){if(Module.setStatus){var i=Module.statusMessage||"Please wait...",n=Browser.mainLoop.remainingBlockers,t=Browser.mainLoop.expectedBlockers;n?n<t?Module.setStatus(i+" ("+(t-n)+"/"+t+")"):Module.setStatus(i):Module.setStatus("")}},runIter:function(n){if(!ABORT){if(Module.preMainLoop){var i=Module.preMainLoop();if(i===!1)return}try{n()}catch(t){if(t instanceof ExitStatus)return;t&&typeof t=="object"&&t.stack&&Module.printErr("exception thrown: "+[t,t.stack]);throw t;}Module.postMainLoop&&Module.postMainLoop()}}},isFullScreen:!1,pointerLock:!1,moduleContextCreatedCallbacks:[],workers:[],init:function(){function r(){Browser.pointerLock=document.pointerLockElement===n||document.mozPointerLockElement===n||document.webkitPointerLockElement===n||document.msPointerLockElement===n}var t,i,n;if(Module.preloadPlugins||(Module.preloadPlugins=[]),!Browser.initted){Browser.initted=!0;try{new Blob;Browser.hasBlobConstructor=!0}catch(u){Browser.hasBlobConstructor=!1;console.log("warning: no blob constructor, cannot create blobs with mimetypes")}Browser.BlobBuilder=typeof MozBlobBuilder!="undefined"?MozBlobBuilder:typeof WebKitBlobBuilder!="undefined"?WebKitBlobBuilder:Browser.hasBlobConstructor?null:console.log("warning: no BlobBuilder");Browser.URLObject=typeof window!="undefined"?window.URL?window.URL:window.webkitURL:undefined;Module.noImageDecoding||typeof Browser.URLObject!="undefined"||(console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),Module.noImageDecoding=!0);t={};t.canHandle=function(n){return!Module.noImageDecoding&&/\.(jpg|jpeg|png|bmp)$/i.test(n)};t.handle=function(n,t,i,r){var f=null,o,e,u;if(Browser.hasBlobConstructor)try{f=new Blob([n],{type:Browser.getMimetype(t)});f.size!==n.length&&(f=new Blob([new Uint8Array(n).buffer],{type:Browser.getMimetype(t)}))}catch(s){Runtime.warnOnce("Blob constructor present but fails: "+s+"; falling back to blob builder")}f||(o=new Browser.BlobBuilder,o.append(new Uint8Array(n).buffer),f=o.getBlob());e=Browser.URLObject.createObjectURL(f);u=new Image;u.onload=function(){var r,f;assert(u.complete,"Image "+t+" could not be decoded");r=document.createElement("canvas");r.width=u.width;r.height=u.height;f=r.getContext("2d");f.drawImage(u,0,0);Module.preloadedImages[t]=r;Browser.URLObject.revokeObjectURL(e);i&&i(n)};u.onerror=function(){console.log("Image "+e+" could not be decoded");r&&r()};u.src=e};Module.preloadPlugins.push(t);i={};i.canHandle=function(n){return!Module.noAudioDecoding&&n.substr(-4)in{".ogg":1,".wav":1,".mp3":1}};i.handle=function(n,t,i,r){function e(r){f||(f=!0,Module.preloadedAudios[t]=r,i&&i(n))}function o(){f||(f=!0,Module.preloadedAudios[t]=new Audio,r&&r())}var f=!1,s,h,u;if(Browser.hasBlobConstructor){try{s=new Blob([n],{type:Browser.getMimetype(t)})}catch(c){return o()}h=Browser.URLObject.createObjectURL(s);u=new Audio;u.addEventListener("canplaythrough",function(){e(u)},!1);u.onerror=function(){function i(n){for(var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e="=",t="",r=0,i=0,o,u=0;u<n.length;u++)for(r=r<<8|n[u],i+=8;i>=6;)o=r>>i-6&63,i-=6,t+=f[o];return i==2?(t+=f[(r&3)<<4],t+=e+e):i==4&&(t+=f[(r&15)<<2],t+=e),t}f||(console.log("warning: browser could not fully decode audio "+t+", trying slower base64 approach"),u.src="data:audio/x-"+t.substr(-3)+";base64,"+i(n),e(u))};u.src=h;Browser.safeSetTimeout(function(){e(u)},1e4)}else return o()};Module.preloadPlugins.push(i);n=Module.canvas;n&&(n.requestPointerLock=n.requestPointerLock||n.mozRequestPointerLock||n.webkitRequestPointerLock||n.msRequestPointerLock||function(){},n.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},n.exitPointerLock=n.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",r,!1),document.addEventListener("mozpointerlockchange",r,!1),document.addEventListener("webkitpointerlockchange",r,!1),document.addEventListener("mspointerlockchange",r,!1),Module.elementPointerLock&&n.addEventListener("click",function(t){!Browser.pointerLock&&n.requestPointerLock&&(n.requestPointerLock(),t.preventDefault())},!1))}},createContext:function(n,t,i,r){var u,f,e,o;if(t&&Module.ctx&&n==Module.canvas)return Module.ctx;if(t){if(e={antialias:!1,alpha:!1},r)for(o in r)e[o]=r[o];f=GL.createContext(n,e);f&&(u=GL.getContext(f).GLctx);n.style.backgroundColor="black"}else u=n.getContext("2d");return u?(i&&(t||assert(typeof GLctx=="undefined","cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),Module.ctx=u,t&&GL.makeContextCurrent(f),Module.useWebGL=t,Browser.moduleContextCreatedCallbacks.forEach(function(n){n()}),Browser.init()),u):null},destroyContext:function(){},fullScreenHandlersInstalled:!1,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function(n,t,i){function f(){Browser.isFullScreen=!1;var n=r.parentNode;if((document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===n?(r.cancelFullScreen=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msExitFullscreen||document.exitFullscreen||function(){},r.cancelFullScreen=r.cancelFullScreen.bind(document),Browser.lockPointer&&r.requestPointerLock(),Browser.isFullScreen=!0,Browser.resizeCanvas&&Browser.setFullScreenCanvasSize()):(n.parentNode.insertBefore(r,n),n.parentNode.removeChild(n),Browser.resizeCanvas&&Browser.setWindowedCanvasSize()),Module.onFullScreen)Module.onFullScreen(Browser.isFullScreen);Browser.updateCanvasDimensions(r)}var r,u;Browser.lockPointer=n;Browser.resizeCanvas=t;Browser.vrDevice=i;typeof Browser.lockPointer=="undefined"&&(Browser.lockPointer=!0);typeof Browser.resizeCanvas=="undefined"&&(Browser.resizeCanvas=!1);typeof Browser.vrDevice=="undefined"&&(Browser.vrDevice=null);r=Module.canvas;Browser.fullScreenHandlersInstalled||(Browser.fullScreenHandlersInstalled=!0,document.addEventListener("fullscreenchange",f,!1),document.addEventListener("mozfullscreenchange",f,!1),document.addEventListener("webkitfullscreenchange",f,!1),document.addEventListener("MSFullscreenChange",f,!1));u=document.createElement("div");r.parentNode.insertBefore(u,r);u.appendChild(r);u.requestFullScreen=u.requestFullScreen||u.mozRequestFullScreen||u.msRequestFullscreen||(u.webkitRequestFullScreen?function(){u.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null);i?u.requestFullScreen({vrDisplay:i}):u.requestFullScreen()},nextRAF:0,fakeRequestAnimationFrame:function(n){var t=Date.now(),i;if(Browser.nextRAF===0)Browser.nextRAF=t+1e3/60;else while(t+2>=Browser.nextRAF)Browser.nextRAF+=1e3/60;i=Math.max(Browser.nextRAF-t,0);setTimeout(n,i)},requestAnimationFrame:function(n){typeof window=="undefined"?Browser.fakeRequestAnimationFrame(n):(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||Browser.fakeRequestAnimationFrame),window.requestAnimationFrame(n))},safeCallback:function(n){return function(){if(!ABORT)return n.apply(null,arguments)}},allowAsyncCallbacks:!0,queuedAsyncCallbacks:[],pauseAsyncCallbacks:function(){Browser.allowAsyncCallbacks=!1},resumeAsyncCallbacks:function(){if(Browser.allowAsyncCallbacks=!0,Browser.queuedAsyncCallbacks.length>0){var n=Browser.queuedAsyncCallbacks;Browser.queuedAsyncCallbacks=[];n.forEach(function(n){n()})}},safeRequestAnimationFrame:function(n){return Browser.requestAnimationFrame(function(){ABORT||(Browser.allowAsyncCallbacks?n():Browser.queuedAsyncCallbacks.push(n))})},safeSetTimeout:function(n,t){return Module.noExitRuntime=!0,setTimeout(function(){ABORT||(Browser.allowAsyncCallbacks?n():Browser.queuedAsyncCallbacks.push(n))},t)},safeSetInterval:function(n,t){return Module.noExitRuntime=!0,setInterval(function(){ABORT||Browser.allowAsyncCallbacks&&n()},t)},getMimetype:function(n){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[n.substr(n.lastIndexOf(".")+1)]},getUserMedia:function(n){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia);window.getUserMedia(n)},getMovementX:function(n){return n.movementX||n.mozMovementX||n.webkitMovementX||0},getMovementY:function(n){return n.movementY||n.mozMovementY||n.webkitMovementY||0},getMouseWheelDelta:function(n){var t=0;switch(n.type){case"DOMMouseScroll":t=n.detail;break;case"mousewheel":t=n.wheelDelta;break;case"wheel":t=n.deltaY;break;default:throw"unrecognized mouse wheel event: "+n.type;}return t},mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent:function(n){var t,e,o,r,s,u,f;if(Browser.pointerLock)n.type!="mousemove"&&"mozMovementX"in n?Browser.mouseMovementX=Browser.mouseMovementY=0:(Browser.mouseMovementX=Browser.getMovementX(n),Browser.mouseMovementY=Browser.getMovementY(n)),typeof SDL!="undefined"?(Browser.mouseX=SDL.mouseX+Browser.mouseMovementX,Browser.mouseY=SDL.mouseY+Browser.mouseMovementY):(Browser.mouseX+=Browser.mouseMovementX,Browser.mouseY+=Browser.mouseMovementY);else{var i=Module.canvas.getBoundingClientRect(),h=Module.canvas.width,c=Module.canvas.height,l=typeof window.scrollX!="undefined"?window.scrollX:window.pageXOffset,a=typeof window.scrollY!="undefined"?window.scrollY:window.pageYOffset;if(n.type==="touchstart"||n.type==="touchend"||n.type==="touchmove"){if(t=n.touch,t===undefined)return;e=t.pageX-(l+i.left);o=t.pageY-(a+i.top);e=e*(h/i.width);o=o*(c/i.height);r={x:e,y:o};n.type==="touchstart"?(Browser.lastTouches[t.identifier]=r,Browser.touches[t.identifier]=r):(n.type==="touchend"||n.type==="touchmove")&&(s=Browser.touches[t.identifier],s||(s=r),Browser.lastTouches[t.identifier]=s,Browser.touches[t.identifier]=r);return}u=n.pageX-(l+i.left);f=n.pageY-(a+i.top);u=u*(h/i.width);f=f*(c/i.height);Browser.mouseMovementX=u-Browser.mouseX;Browser.mouseMovementY=f-Browser.mouseY;Browser.mouseX=u;Browser.mouseY=f}},xhrLoad:function(n,t,i){var r=new XMLHttpRequest;r.open("GET",n,!0);r.responseType="arraybuffer";r.onload=function(){r.status==200||r.status==0&&r.response?t(r.response):i()};r.onerror=i;r.send(null)},asyncLoad:function(n,t,i,r){Browser.xhrLoad(n,function(i){assert(i,'Loading data file "'+n+'" failed (no arrayBuffer).');t(new Uint8Array(i));r||removeRunDependency("al "+n)},function(){if(i)i();else throw'Loading data file "'+n+'" failed.';});r||addRunDependency("al "+n)},resizeListeners:[],updateResizeListeners:function(){var n=Module.canvas;Browser.resizeListeners.forEach(function(t){t(n.width,n.height)})},setCanvasSize:function(n,t,i){var r=Module.canvas;Browser.updateCanvasDimensions(r,n,t);i||Browser.updateResizeListeners()},windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function(){if(typeof SDL!="undefined"){var n=HEAPU32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2];n=n|8388608;HEAP32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2]=n}Browser.updateResizeListeners()},setWindowedCanvasSize:function(){if(typeof SDL!="undefined"){var n=HEAPU32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2];n=n&-8388609;HEAP32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2]=n}Browser.updateResizeListeners()},updateCanvasDimensions:function(n,t,i){var r,u,f;t&&i?(n.widthNative=t,n.heightNative=i):(t=n.widthNative,i=n.heightNative);r=t;u=i;Module.forcedAspectRatio&&Module.forcedAspectRatio>0&&(r/u<Module.forcedAspectRatio?r=Math.round(u*Module.forcedAspectRatio):u=Math.round(r/Module.forcedAspectRatio));(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement||document.msFullScreenElement||document.msFullscreenElement||document.webkitCurrentFullScreenElement)===n.parentNode&&typeof screen!="undefined"&&(f=Math.min(screen.width/r,screen.height/u),r=Math.round(r*f),u=Math.round(u*f));Browser.resizeCanvas?(n.width!=r&&(n.width=r),n.height!=u&&(n.height=u),typeof n.style!="undefined"&&(n.style.removeProperty("width"),n.style.removeProperty("height"))):(n.width!=t&&(n.width=t),n.height!=i&&(n.height=i),typeof n.style!="undefined"&&(r!=t||u!=i?(n.style.setProperty("width",r+"px","important"),n.style.setProperty("height",u+"px","important")):(n.style.removeProperty("width"),n.style.removeProperty("height"))))},wgetRequests:{},nextWgetRequestHandle:0,getNextWgetRequestHandle:function(){var n=Browser.nextWgetRequestHandle;return Browser.nextWgetRequestHandle++,n}};FS.staticInit();__ATINIT__.unshift(function(){Module.noFSInit||FS.init.initialized||FS.init()});__ATMAIN__.push(function(){FS.ignorePermissions=!1});__ATEXIT__.push(function(){FS.quit()});Module.FS_createFolder=FS.createFolder;Module.FS_createPath=FS.createPath;Module.FS_createDataFile=FS.createDataFile;Module.FS_createPreloadedFile=FS.createPreloadedFile;Module.FS_createLazyFile=FS.createLazyFile;Module.FS_createLink=FS.createLink;Module.FS_createDevice=FS.createDevice;Module.FS_unlink=FS.unlink;__ATINIT__.unshift(function(){TTY.init()});__ATEXIT__.push(function(){TTY.shutdown()});ENVIRONMENT_IS_NODE&&(fs=require("fs"),NODEJS_PATH=require("path"),NODEFS.staticInit());Module.requestFullScreen=function(n,t,i){Browser.requestFullScreen(n,t,i)};Module.requestAnimationFrame=function(n){Browser.requestAnimationFrame(n)};Module.setCanvasSize=function(n,t,i){Browser.setCanvasSize(n,t,i)};Module.pauseMainLoop=function(){Browser.mainLoop.pause()};Module.resumeMainLoop=function(){Browser.mainLoop.resume()};Module.getUserMedia=function(){Browser.getUserMedia()};Module.createContext=function(n,t,i,r){return Browser.createContext(n,t,i,r)};STACK_BASE=STACKTOP=Runtime.alignMemory(STATICTOP);staticSealed=!0;STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=DYNAMICTOP=Runtime.alignMemory(STACK_MAX);assert(DYNAMIC_BASE<TOTAL_MEMORY,"TOTAL_MEMORY not big enough for stack");Module.asmGlobalArg={Math:Math,Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,NaN:NaN,Infinity:Infinity};Module.asmLibraryArg={abort:abort,assert:assert,invoke_iiii:invoke_iiii,invoke_viiiii:invoke_viiiii,invoke_vi:invoke_vi,invoke_ii:invoke_ii,invoke_viiiiii:invoke_viiiiii,invoke_viiii:invoke_viiii,_pthread_cleanup_pop:_pthread_cleanup_pop,_pthread_self:_pthread_self,_sysconf:_sysconf,___lock:___lock,___syscall6:___syscall6,___setErrNo:___setErrNo,_abort:_abort,_sbrk:_sbrk,_time:_time,_pthread_cleanup_push:_pthread_cleanup_push,_emscripten_memcpy_big:_emscripten_memcpy_big,___syscall54:___syscall54,___unlock:___unlock,___syscall140:___syscall140,_emscripten_set_main_loop_timing:_emscripten_set_main_loop_timing,_emscripten_set_main_loop:_emscripten_set_main_loop,___syscall146:___syscall146,STACKTOP:STACKTOP,STACK_MAX:STACK_MAX,tempDoublePtr:tempDoublePtr,ABORT:ABORT};var asm=function(n,t,i){"use asm";function kr(n){n=n|0;var t=0;return t=u,u=u+n|0,u=u+15&-16,t|0}function dr(){return u|0}function gr(n){n=n|0;u=n}function nu(n,t){n=n|0;t=t|0;u=n;fr=t}function tu(n,t){n=n|0;t=t|0;(dt|0)==0&&(dt=n,er=t)}function iu(n){n=n|0;gt=n}function ru(){return gt|0}function uu(n,t,i,r,e){n=n|0;t=t|0;i=i|0;r=r|0;e=e|0;var o=0,c=0,l=0,a=0,v=0,y=0,p=0,w=0,b=0,k=0,d=0,g=0,nt=0,tt=0,it=0,rt=0,s=0,ut=0,ft=0,et=0,ot=0,st=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ii=0,ri=0,ui=0,h=0,fi=0;if(fi=u,c=f[n>>0]|0,l=(c&255)>>>2,tt=l&255,lt=r+tt|0,ni=f[lt>>0]|0,f[i>>0]=ni,ti=f[n>>0]|0,ii=ti&255,ri=ii<<4,ui=ri&48,h=n+1|0,a=f[h>>0]|0,v=a&255,y=v>>>4,p=ui|y,w=r+p|0,b=f[w>>0]|0,k=i+1|0,f[k>>0]=b,d=(t&255)>1,!d){dt=i+2|0;f[dt>>0]=e;gt=i+3|0;f[gt>>0]=e;return}g=f[h>>0]|0;nt=g&255;it=nt<<2;rt=it&60;s=n+2|0;ut=f[s>>0]|0;ft=ut&255;et=ft>>>6;ot=rt|et;st=r+ot|0;ht=f[st>>0]|0;ct=i+2|0;f[ct>>0]=ht;at=(t&255)>2;at?(vt=f[s>>0]|0,yt=vt&255,pt=yt&63,wt=r+pt|0,bt=f[wt>>0]|0,o=bt):o=e;kt=i+3|0;f[kt>>0]=o;return}function fu(n,t,i,r,e){n=n|0;t=t|0;i=i|0;r=r|0;e=e|0;var h=0,v=0,y=0,p=0,w=0,b=0,k=0,d=0,g=0,nt=0,tt=0,it=0,rt=0,ut=0,ft=0,et=0,ot=0,st=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ii=0,ri=0,ui=0,c=0,fi=0,ei=0,oi=0,si=0,hi=0,ci=0,li=0,ai=0,vi=0,yi=0,pi=0,wi=0,bi=0,ki=0,l=0,di=0,o=0,a=0,s=0;if(s=u,u=u+16|0,o=s,v=t<<24>>24==0,v){u=s;return}if(y=f[n>>0]|0,f[o>>0]=y,ut=(t&255)<2,ut?(ct=o+1|0,f[ct>>0]=0,a=11):(lt=n+1|0,at=f[lt>>0]|0,vt=o+1|0,f[vt>>0]=at,yt=(t&255)<3,yt?a=11:(wt=n+2|0,bt=f[wt>>0]|0,kt=o+2|0,f[kt>>0]=bt)),(a|0)==11&&(dt=o+2|0,f[dt>>0]=0),gt=f[o>>0]|0,ni=(gt&255)>>>2,ti=ni&255,ii=r+ti|0,ri=f[ii>>0]|0,f[i>>0]=ri,ui=f[o>>0]|0,fi=ui&255,ei=fi<<4,oi=ei&48,c=o+1|0,si=f[c>>0]|0,hi=si&255,ci=hi>>>4,li=oi|ci,ai=r+li|0,vi=f[ai>>0]|0,yi=i+1|0,f[yi>>0]=vi,wi=(t&255)>1,!wi){st=i+2|0;f[st>>0]=e;ht=i+3|0;f[ht>>0]=e;u=s;return}pt=f[c>>0]|0;pi=pt&255;bi=pi<<2;ki=bi&60;l=o+2|0;di=f[l>>0]|0;p=di&255;w=p>>>6;b=ki|w;k=r+b|0;d=f[k>>0]|0;g=i+2|0;f[g>>0]=d;nt=(t&255)>2;nt?(tt=f[l>>0]|0,it=tt&255,rt=it&63,ft=r+rt|0,et=f[ft>>0]|0,h=et):h=e;ot=i+3|0;f[ot>>0]=h;u=s;return}function eu(n,t,i,r,e){n=n|0;t=t|0;i=i|0;r=r|0;e=e|0;var l=0,a=0,v=0,y=0,p=0,w=0,b=0,k=0,d=0,g=0,nt=0,tt=0,it=0,rt=0,ut=0,ft=0,et=0,ot=0,h=0,st=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,c=0,kt=0,dt=0,gt=0,ni=0,ti=0,ii=0,ri=0,ui=0,fi=0,ei=0,oi=0,si=0,hi=0,ci=0,li=0,ai=0,vi=0,yi=0,pi=0,wi=0,bi=0,ki=0,di=0,gi=0,nr=0,tr=0,ir=0,rr=0,ur=0,fr=0,er=0,or=0,sr=0,hr=0,cr=0,o=0,s=0;if(s=u,u=u+16|0,o=s,l=f[n>>0]|0,a=l&255,it=r+a|0,at=f[it>>0]|0,f[o>>0]=at,ti=n+1|0,ai=f[ti>>0]|0,ir=ai&255,sr=r+ir|0,hr=f[sr>>0]|0,cr=o+1|0,f[cr>>0]=hr,v=n+2|0,y=f[v>>0]|0,p=y&255,w=r+p|0,b=f[w>>0]|0,k=o+2|0,f[k>>0]=b,d=n+3|0,g=f[d>>0]|0,nt=g&255,tt=r+nt|0,rt=f[tt>>0]|0,ut=o+3|0,f[ut>>0]=rt,ft=f[o>>0]|0,et=ft&255,ot=et<<2,h=o+1|0,st=f[h>>0]|0,ht=st&255,ct=ht>>>4,lt=ct&3,vt=lt|ot,yt=vt&255,f[t>>0]=yt,f[i>>0]=3,pt=n+2|0,wt=f[pt>>0]|0,bt=wt<<24>>24,c=e&255,kt=(bt|0)==(c|0),kt?f[i>>0]=2:(dt=f[h>>0]|0,gt=dt&255,ni=gt<<4,ii=o+2|0,ri=f[ii>>0]|0,ui=ri&255,fi=ui>>>2,ei=fi&15,oi=ei|ni,si=oi&255,hi=t+1|0,f[hi>>0]=si),ci=n+3|0,li=f[ci>>0]|0,vi=li<<24>>24,yi=(vi|0)==(c|0),yi){pi=f[i>>0]|0;wi=pi+-1<<24>>24;f[i>>0]=wi;u=s;return}bi=o+2|0;ki=f[bi>>0]|0;di=ki&255;gi=di<<6;nr=o+3|0;tr=f[nr>>0]|0;rr=tr&255;ur=rr&63;fr=ur|gi;er=fr&255;or=t+2|0;f[or>>0]=er;u=s;return}function ou(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var a=0,e=0,v=0,y=0,p=0,w=0,b=0,k=0,d=0,c=0,g=0,nt=0,tt=0,s=0,it=0,rt=0,l=0,ut=0,ft=0,et=0,o=0,ot=0,st=0,ht=0,ct=0,lt=0;return(lt=u,y=i&3,p=(y|0)==0,!p)?(e=0,o=0,r[f>>2]=o,e|0):(d=t<<24>>24==0,c=(i|0)!=0,et=d|c,!et)?(e=0,o=0,r[f>>2]=o,e|0):(g=(n>>>0)/3&-1,nt=(n>>>0)%3&-1,ut=(nt|0)!=0,tt=ut&1,a=tt+g|0,s=a<<2,ht=t<<24>>24==2,ot=ht&1,ct=t<<24>>24==1,st=ct?2:ot,c?(it=(s>>>0)/(i>>>0)&-1,rt=(s>>>0)%(i>>>0)&-1,ft=(rt|0)!=0,w=ft&1,v=w+it|0,l=v):l=0,b=h(l,st)|0,k=b+s|0,e=1,o=k,r[f>>2]=o,e|0)}function su(n,t,i){n=n|0;t=t|0;i=i|0;var ut=0,a=0,ft=0,et=0,ot=0,tt=0,st=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0,h=0,dt=0,gt=0,ni=0,ti=0,ii=0,ri=0,ui=0,fi=0,ei=0,it=0,oi=0,si=0,hi=0,c=0,ci=0,li=0,l=0,v=0,y=0,p=0,o=0,ai=0,vi=0,e=0,w=0,rt=0,s=0,b=0,k=0,d=0,yi=0,pi=0,wi=0,bi=0,ki=0,di=0,g=0,nt=0,gi=0;for(gi=u,l=0,o=0,s=0,nt=0;;){if(tt=nt+1|0,st=n+nt|0,h=f[st>>0]|0,it=h&255,oi=901+it|0,si=f[oi>>0]|0,hi=si<<24>>24!=64,c=h<<24>>24==45,bi=c|hi,bi){ci=o&255;n:do switch(ci|0){case 0:switch(it|0){case 45:li=o+1<<24>>24;e=li;break n;case 61:ht=s+1|0;ct=ht&3;lt=(ct|0)==0;ut=lt?5:4;e=ut;break n;default:e=o;break n}break;case 1:at=c&1;vt=at^1;ai=vt+o<<24>>24;e=ai;break;case 2:yt=c&1;ot=yt+o<<24>>24;e=ot;break;case 3:vi=c?o:0;e=vi;break;case 4:yi=h<<24>>24==61;pt=o+1<<24>>24;ft=yi?pt:6;e=ft;break;case 5:wt=o+1<<24>>24;e=wt;break;default:e=o}while(0);switch(e<<24>>24){case 5:case 4:case 0:bt=h<<24>>24==61;kt=bt&1;et=kt+l<<24>>24;dt=s+1|0;v=et;b=dt;break;default:v=l;b=s}if(gt=(e&255)>4,gt){p=v;rt=e;d=b;break}else y=v,w=e,k=b}else y=l,w=o,k=s;if(ni=tt>>>0<t>>>0,ni)l=y,o=w,s=k,nt=tt;else{p=y;rt=w;d=k;break}}return(ti=d&3,pi=(p&255)>2,wi=(ti|0)!=0,ki=wi|pi,ii=rt<<24>>24==6,di=ii|ki,di)?(a=0,g=0,r[i>>2]=g,a|0):(ri=p&255,ui=d>>>2,fi=ui*3|0,ei=fi-ri|0,a=1,g=ei,r[i>>2]=g,a|0)}function hu(n,t,i,r,e){n=n|0;t=t|0;i=i|0;r=r|0;e=e|0;var b=0,o=0,k=0,v=0,l=0,s=0,h=0,rt=0,a=0,ut=0,ft=0,et=0,ot=0,st=0,c=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,d=0,g=0,pt=0,y=0,wt=0,bt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ii=0,ri=0,p=0,ui=0,fi=0,ei=0,nt=0,oi=0,si=0,tt=0,it=0,w=0,hi=0;if((hi=u,ut=e&3,ft=(ut|0)==0,!ft)||(d=r&255,ii=r<<24>>24==0,ri=(e|0)!=0,oi=ii|ri,!oi))return o=0,o|0;if(p=r<<24>>24!=0,ui=e>>>2,b=p?ui:1,fi=(t>>>0)/3&-1,ei=t>>>0>2,ei){for(nt=(t>>>0)/3&-1,et=nt>>>0>1,tt=et?nt:1,ot=tt*3|0,v=n,s=i,w=0;;){uu(v,3,s,836,61);st=v+3|0;c=s+4|0;n:do if(p)if(ht=w+1|0,ct=(ht>>>0)%(b>>>0)&-1,lt=(ct|0)==0,lt)switch(d|0){case 1:f[c>>0]=13;at=s+5|0;f[at>>0]=10;vt=s+6|0;h=vt;break n;case 2:f[c>>0]=10;yt=s+5|0;h=yt;break n;default:h=c;break n}else h=c;else h=c;while(0);if(g=w+1|0,pt=g>>>0<fi>>>0,pt)v=st,s=h,w=g;else{rt=h;break}}si=n+ot|0;k=si;l=rt;it=tt}else k=n,l=i,it=0;if((y=(t>>>0)%3&-1,wt=(y|0)==0,wt?a=l:(bt=y&255,fu(k,bt,l,836,61),kt=l+4|0,a=kt),!p)||(dt=(it>>>0)%(b>>>0)&-1,gt=dt|y,ni=(gt|0)==0,ni))return o=1,o|0;switch(d|0){case 1:return f[a>>0]=13,ti=a+1|0,f[ti>>0]=10,o=1,o|0;case 2:return f[a>>0]=10,o=1,o|0;default:return o=1,o|0}return 0}function cu(n,t,i){n=n|0;t=t|0;i=i|0;var yt=0,pt=0,o=0,p=0,tt=0,wt=0,it=0,bt=0,rt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ii=0,ri=0,ui=0,fi=0,ei=0,oi=0,s=0,ut=0,ft=0,si=0,hi=0,ci=0,li=0,ai=0,vi=0,yi=0,pi=0,et=0,wi=0,bi=0,ki=0,di=0,gi=0,nr=0,l=0,tr=0,ir=0,ot=0,h=0,w=0,st=0,a=0,v=0,b=0,ht=0,e=0,rr=0,ur=0,r=0,k=0,ct=0,lt=0,c=0,y=0,d=0,at=0,fr=0,er=0,or=0,sr=0,hr=0,cr=0,g=0,vt=0,nt=0;for(nt=u,u=u+16|0,ot=nt+4|0,lt=nt,o=i,h=0,a=0,e=0,c=0,g=0;;){if(rt=g+1|0,kt=n+g|0,s=f[kt>>0]|0,et=s&255,di=901+et|0,gi=f[di>>0]|0,nr=gi<<24>>24!=64,l=s<<24>>24==45,sr=l|nr,sr){tr=e&255;n:do switch(tr|0){case 0:switch(et|0){case 45:ir=e+1<<24>>24;r=ir;break n;case 61:dt=c+1|0;gt=dt&3;ni=(gt|0)==0;yt=ni?5:4;r=yt;break n;default:r=e;break n}break;case 1:ti=l&1;ii=ti^1;rr=ii+e<<24>>24;r=rr;break;case 2:ri=l&1;bt=ri+e<<24>>24;r=bt;break;case 3:ur=l?e:0;r=ur;break;case 4:fr=s<<24>>24==61;ui=e+1<<24>>24;wt=fr?ui:6;r=wt;break;case 5:fi=e+1<<24>>24;r=fi;break;default:r=e}while(0);switch(r<<24>>24){case 5:case 4:case 0:ei=s<<24>>24==61;oi=ei&1;it=oi+a<<24>>24;ut=c+1|0;ft=h+1<<24>>24;si=h&255;hi=ot+si|0;f[hi>>0]=s;ci=ft<<24>>24==4;ci?(eu(ot,o,lt,901,61),li=f[lt>>0]|0,ai=li&255,vi=o+ai|0,p=vi,w=0,v=it,y=ut):(p=o,w=ft,v=it,y=ut);break;default:p=o;w=h;v=a;y=c}if(yi=(r&255)>4,yi){ht=v;ct=r;at=y;vt=17;break}else tt=p,st=w,b=v,k=r,d=y}else tt=o,st=h,b=a,k=e,d=c;if(pi=rt>>>0<t>>>0,pi)o=tt,h=st,a=b,e=k,c=d,g=rt;else{ht=b;ct=k;at=d;vt=17;break}}return(vt|0)==17?(wi=at&3,er=(ht&255)>2,or=(wi|0)!=0,hr=er|or,bi=ct<<24>>24==6,cr=bi|hr,ki=cr&1,pt=ki^1,u=nt,pt|0):0}function lu(n,t,i){n=n|0;t=t|0;i=i|0;var f=0,e=0,o=0;o=u;r[n>>2]=t;f=n+4|0;r[f>>2]=i;e=n+8|0;r[e>>2]=0;return}function au(n,t){n=n|0;t=t|0;var f=0,e=0,h=0,c=0,l=0,a=0,v=0,y=0,o=0,i=0,p=0,s=0,w=0,b=0,k=0,d=0,g=0;return(g=u,h=t+4|0,c=r[h>>2]|0,o=n+8|0,i=r[o>>2]|0,p=n+4|0,s=r[p>>2]|0,w=s>>>0>i>>>0,!w)?(e=0,e|0):(b=i+c|0,k=b>>>0<s>>>0,d=s-i|0,f=k?c:d,l=r[n>>2]|0,a=l+i|0,r[t>>2]=a,r[h>>2]=f,v=r[o>>2]|0,y=v+f|0,r[o>>2]=y,e=f,e|0)}function ft(n,t){n=n|0;t=t|0;var i=0,e=0,o=0,s=0,h=0,c=0,l=0,a=0,v=0,y=0,p=0,w=0;return(w=u,e=n+8|0,o=r[e>>2]|0,s=n+4|0,h=r[s>>2]|0,c=o>>>0<h>>>0,!c)?(i=0,i|0):(l=r[n>>2]|0,a=l+o|0,v=f[a>>0]|0,f[t>>0]=v,y=r[e>>2]|0,p=y+1|0,r[e>>2]=p,i=1,i|0)}function ti(n,t,i){n=n|0;t=t|0;i=i|0;var o=0,d=0,g=0,nt=0,tt=0,it=0,rt=0,ut=0,et=0,ot=0,st=0,ht=0,h=0,ct=0,w=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,b=0,kt=0,dt=0,gt=0,ni=0,c=0,ti=0,ii=0,ri=0,ui=0,fi=0,k=0,l=0,a=0,e=0,v=0,ei=0,y=0,oi=0,p=0,s=0;if((s=u,u=u+16|0,e=s,nt=ft(n,e)|0,tt=(nt|0)==1,!tt)||(lt=f[e>>0]|0,ni=lt&255,c=ni&31,r[t>>2]=c,ti=(c|0)==31,ti)||(ii=f[e>>0]|0,ri=ii<<24>>24<0,ri&&(ui=c|128,r[t>>2]=ui),fi=f[e>>0]|0,it=fi&-96,rt=it<<24>>24==-96,rt&&(ut=r[t>>2]|0,et=ut|160,r[t>>2]=et),ot=ft(n,e)|0,st=(ot|0)==1,!st))return o=0,u=s,o|0;ht=f[e>>0]|0;h=ht&255;g=h&128;ct=(g|0)==0;do if(ct)l=h,y=2;else if(w=h&127,at=(w|0)==0,at)l=0,y=2;else{for(k=0,a=w,v=0;;){if(vt=ft(n,e)|0,yt=(vt|0)==1,!yt){o=0;p=14;break}if(pt=k<<8,wt=f[e>>0]|0,bt=wt&255,b=bt|pt,kt=a+-1|0,dt=v+1|0,gt=(a|0)>1,gt)k=b,a=kt,v=dt;else{d=b;ei=v;p=12;break}}if((p|0)==12){oi=ei+3|0;l=d;y=oi;break}else if((p|0)==14)return u=s,o|0}while(0);return r[i>>2]=l,o=y,u=s,o|0}function tt(n,t,i){n=n|0;t=t|0;i=i|0;var y=0,e=0,s=0,p=0,w=0,b=0,k=0,d=0,g=0,nt=0,c=0,tt=0,it=0,rt=0,l=0,a=0,ut=0,et=0,ot=0,st=0,ht=0,h=0,v=0,ct=0,o=0;return(o=u,u=u+16|0,h=o,v=o+4|0,s=ti(n,t,h)|0,p=(s|0)==0,p)?(e=0,u=o,e|0):(rt=r[h>>2]|0,l=i+4|0,r[l>>2]=rt,a=r[t>>2]|0,ut=(a|0)==3,!ut)?(d=vu(a)|0,g=(d|0)==0,g?(e=s,u=o,e|0):(nt=au(n,i)|0,c=r[h>>2]|0,tt=(nt|0)==(c|0),it=c+s|0,y=tt?it:0,u=o,y|0)):(et=ft(n,v)|0,ot=(et|0)!=0,st=f[v>>0]|0,ht=st<<24>>24==0,ct=ot&ht,!ct)?(e=0,u=o,e|0):(w=r[h>>2]|0,b=w+-1|0,r[l>>2]=b,k=s+1|0,e=k,u=o,e|0)}function vu(n){n=n|0;var t=0,i=0,r=0,f=0;return f=u,i=n&-2,r=(i|0)!=16,t=r&1,t|0}function a(n,t){n=n|0;t=t|0;var s=0,i=0,e=0,h=0,c=0,l=0,o=0,f=0;return(f=u,u=u+16|0,o=f,e=tt(n,o,t)|0,h=(e|0)==0,h)?(i=0,u=f,i|0):(c=r[o>>2]|0,l=(c|0)==2,s=l?e:0,i=s,u=f,i|0)}function yu(n,t,i){n=n|0;t=t|0;i=i|0;var f=0,s=0,y=0,h=0,p=0,w=0,b=0,k=0,d=0,g=0,nt=0,c=0,it=0,l=0,rt=0,v=0,ut=0,ft=0,et=0,o=0,ot=0,st=0,e=0;return e=u,u=u+32|0,ft=e+16|0,ot=e+8|0,o=e+4|0,et=e,s=tt(n,o,ft)|0,y=(s|0)!=0,g=r[o>>2]|0,nt=(g|0)==16,st=y&nt,st?(c=a(n,ot)|0,it=(c|0)==0,it?f=0:(l=pu(n,t)|0,rt=(l|0)==0,rt?f=0:(v=ti(n,o,et)|0,ut=(v|0)==0,ut?f=0:(h=wu(n,i)|0,p=(h|0)==0,p?f=0:(w=c+s|0,b=w+l|0,k=b+v|0,d=k+h|0,f=d))))):f=0,u=e,f|0}function pu(n,t){n=n|0;t=t|0;var y=0,i=0,h=0,p=0,c=0,w=0,b=0,l=0,k=0,d=0,a=0,g=0,nt=0,it=0,rt=0,ut=0,ft=0,v=0,et=0,s=0,ot=0,st=0,ht=0,o=0,e=0,ct=0,lt=0,at=0,f=0;return(f=u,u=u+16|0,o=f+8|0,e=f,h=tt(n,e,o)|0,p=(h|0)!=0,rt=r[e>>2]|0,ft=(rt|0)==16,ct=p&ft,!ct)?(i=0,u=f,i|0):(v=o+4|0,et=r[v>>2]|0,s=tt(n,e,o)|0,ot=(s|0)!=0,st=r[e>>2]|0,ht=(st|0)==6,lt=ot&ht,!lt)?(i=0,u=f,i|0):(c=s+h|0,w=r[o>>2]|0,b=r[v>>2]|0,l=bu(w,b)|0,r[t>>2]=l,k=(l|0)<0,k)?(i=0,u=f,i|0):(d=(et|0)==(s|0),d?(i=c,u=f,i|0):(a=tt(n,e,o)|0,g=(a|0)!=0,nt=r[e>>2]|0,it=(nt|0)==5,at=g&it,ut=a+c|0,y=at?ut:0,u=f,y|0))}function wu(n,t){n=n|0;t=t|0;var rt=0,o=0,ut=0,ft=0,et=0,ot=0,st=0,ht=0,ct=0,lt=0,at=0,h=0,vt=0,yt=0,pt=0,wt=0,c=0,bt=0,kt=0,dt=0,gt=0,ni=0,l=0,ti=0,ii=0,ri=0,ui=0,fi=0,ei=0,v=0,oi=0,si=0,hi=0,ci=0,li=0,p=0,w=0,ai=0,vi=0,yi=0,pi=0,wi=0,b=0,bi=0,ki=0,di=0,gi=0,nr=0,tr=0,k=0,ir=0,rr=0,ur=0,fr=0,er=0,d=0,or=0,nt=0,sr=0,hr=0,cr=0,lr=0,ar=0,vr=0,yr=0,i=0,it=0,pr=0,e=0;return(e=u,u=u+16|0,i=e+8|0,it=e,s(t|0,0,2818)|0,o=tt(n,it,i)|0,ut=(o|0)!=0,yt=r[it>>2]|0,ii=(yt|0)==16,pr=ut&ii,!pr)?(u=e,0):(p=a(n,i)|0,gi=(p|0)==0,gi)?(u=e,0):(nt=a(n,i)|0,ar=(nt|0)==0,ar)?(u=e,0):(vr=p+o|0,yr=vr+nt|0,ft=t+2|0,et=y(i,ft,512)|0,ot=(et|0)==0,!ot)?(u=e,0):(st=r[i>>2]|0,ht=f[st>>0]|0,ct=ht<<24>>24==0,lt=i+4|0,at=r[lt>>2]|0,h=at<<3,ct?(vt=h+65528|0,pt=vt&65535,g[t>>1]=pt):(wt=h&65535,g[t>>1]=wt),c=a(n,i)|0,bt=(c|0)==0,bt)?(u=e,0):(kt=yr+c|0,dt=t+514|0,gt=y(i,dt,512)|0,ni=(gt|0)==0,!ni)?(u=e,0):(l=a(n,i)|0,ti=(l|0)==0,ti)?(u=e,0):(ri=kt+l|0,ui=t+1026|0,fi=y(i,ui,512)|0,ei=(fi|0)==0,!ei)?(u=e,0):(v=a(n,i)|0,oi=(v|0)==0,oi)?(u=e,0):(si=ri+v|0,hi=t+1538|0,ci=y(i,hi,256)|0,li=(ci|0)==0,!li)?(u=e,0):(w=a(n,i)|0,ai=(w|0)==0,ai)?(u=e,0):(vi=si+w|0,yi=t+1794|0,pi=y(i,yi,256)|0,wi=(pi|0)==0,!wi)?(u=e,0):(b=a(n,i)|0,bi=(b|0)==0,bi)?(u=e,0):(ki=vi+b|0,di=t+2050|0,nr=y(i,di,256)|0,tr=(nr|0)==0,!tr)?(u=e,0):(k=a(n,i)|0,ir=(k|0)==0,ir)?(u=e,0):(rr=ki+k|0,ur=t+2306|0,fr=y(i,ur,256)|0,er=(fr|0)==0,!er)?(u=e,0):(d=a(n,i)|0,or=(d|0)==0,or?(u=e,0):(sr=t+2562|0,hr=y(i,sr,256)|0,cr=(hr|0)==0,lr=rr+d|0,rt=cr?lr:0,u=e,rt|0))}function y(n,t,i){n=n|0;t=t|0;i=i|0;var e=0,c=0,l=0,a=0,v=0,o=0,y=0,p=0,w=0,s=0,b=0,k=0,h=0,g=0,nt=0,tt=0,it=0;return(it=u,v=n+4|0,o=r[v>>2]|0,w=o>>>0>i>>>0,!w)?(c=i-o|0,y=t+c|0,p=r[n>>2]|0,d(y|0,p|0,o|0)|0,e=0,e|0):(s=r[n>>2]|0,b=f[s>>0]|0,k=b<<24>>24==0,!k)?(e=1,e|0):(h=o+-1|0,g=h>>>0>i>>>0,g)?(e=1,e|0):(l=i+1|0,a=l-o|0,nt=t+a|0,tt=s+1|0,d(nt|0,tt|0,h|0)|0,e=0,e|0)}function bu(n,t){n=n|0;t=t|0;var v=0,i=0,y=0,p=0,s=0,w=0,b=0,d=0,g=0,nt=0,tt=0,h=0,it=0,rt=0,ut=0,ft=0,et=0,ot=0,st=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ii=0,c=0,ri=0,ui=0,fi=0,ei=0,oi=0,si=0,l=0,hi=0,ci=0,li=0,ai=0,vi=0,yi=0,pi=0,wi=0,bi=0,ki=0,di=0,gi=0,nr=0,tr=0,ir=0,o=0,rr=0,ur=0,fr=0,er=0,or=0,sr=0,hr=0,cr=0,lr=0,ar=0,e=0,a=0;a=u;u=u+16|0;o=a;s=o;w=s;r[w>>2]=-2042067414;et=s+4|0;bt=et;r[bt>>2]=16846327;n:do switch(t|0){case 9:if(ei=k(o,n,8)|0,wi=(ei|0)==0,wi){gi=n+8|0;nr=f[gi>>0]|0;tr=nr&255;switch(tr|0){case 1:i=100;break n;case 2:i=101;break n;case 3:i=102;break n;case 4:i=103;break n;case 5:i=111;break n;case 11:i=121;break n;case 12:i=122;break n;case 13:i=123;break n;case 14:i=120;break n;default:i=-1;break n}}if(ir=k(o,n,7)|0,b=(ir|0)==0,b){d=n+7|0;g=f[d>>0]|0;nt=g&255;switch(nt|0){case 5:tt=n+8|0;h=f[tt>>0]|0;hr=h<<24>>24==3;fr=hr?105:-1;cr=h<<24>>24==1;or=cr?104:fr;i=or;break n;case 6:it=n+8|0;rt=f[it>>0]|0;ut=rt<<24>>24==1;v=ut?105:-1;i=v;break n;case 7:ft=n+8|0;ot=f[ft>>0]|0;st=ot<<24>>24==1;y=st?106:-1;i=y;break n;case 15:ht=n+8|0;ct=f[ht>>0]|0;lt=ct<<24>>24==1;p=lt?107:-1;i=p;break n;default:i=-1;break n}}if(at=k(1157,n,7)|0,vt=(at|0)==0,vt)if(yt=n+7|0,pt=f[yt>>0]|0,ur=pt<<24>>24==2,ur){wt=n+8|0;kt=f[wt>>0]|0;dt=kt&255;switch(dt|0){case 1:i=8;break n;case 2:i=9;break n;case 3:i=10;break n;case 4:i=7;break n;default:i=-1;break n}}else i=-1;else e=41;break;case 8:if(gt=k(1164,n,7)|0,ni=(gt|0)==0,ni){ti=n+7|0;ii=f[ti>>0]|0;c=ii&255;switch(c|0){case 5:case 4:case 2:i=c;break n}i=-1;break n}ri=k(1164,n,6)|0;ui=(ri|0)==0;ui?(fi=n+6|0,oi=f[fi>>0]|0,rr=oi<<24>>24==3,rr?(si=n+7|0,l=f[si>>0]|0,ar=l<<24>>24==7,sr=ar?112:-1,lr=l<<24>>24==4,er=lr?107:sr,i=er):i=-1):e=41;break;case 5:if(hi=k(1171,n,4)|0,ci=(hi|0)==0,ci){li=n+4|0;ai=f[li>>0]|0;vi=ai&255;switch(vi|0){case 7:i=106;break n;case 26:i=6;break n;case 29:i=111;break n;default:i=-1;break n}}else e=41;break;case 10:if(yi=k(1176,n,9)|0,pi=(yi|0)==0,pi){bi=n+9|0;ki=f[bi>>0]|0;di=ki&255;switch(di|0){case 3:i=110;break n;case 5:i=109;break n;case 6:i=108;break n;default:e=41;break n}}else e=41;break;default:e=41}while(0);return(e|0)==41&&(i=-1),u=a,i|0}function ii(n,t,i){n=n|0;t=t|0;i=i|0;var f=0,o=0,h=0,c=0,e=0,r=0;return(r=u,u=u+6672|0,e=r+4|0,c=r,s(i|0,0,2818)|0,lu(e,n,t),o=yu(e,c,i)|0,h=(o|0)==0,!h)?(f=0,u=r,f|0):(s(i|0,0,2818)|0,f=-7,u=r,f|0)}function et(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var e=0,c=0,l=0,a=0,v=0,y=0,p=0,h=0,w=0,b=0,k=0,d=0,g=0,nt=0;return(nt=u,c=su(n,t,f)|0,l=(c|0)==1,!l)?(e=0,e|0):(y=r[f>>2]|0,p=y+1|0,h=vt(p)|0,r[i>>2]=h,w=(h|0)==0,w)?(e=0,e|0):(b=r[f>>2]|0,k=b+1|0,s(h|0,0,k|0)|0,d=r[i>>2]|0,g=cu(n,t,d)|0,a=(g|0)==1,a)?(e=1,e|0):(v=r[i>>2]|0,o(v),e=0,e|0)}function ri(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var e=0,c=0,l=0,a=0,v=0,y=0,p=0,h=0,w=0,b=0,k=0,d=0,g=0,nt=0;return(nt=u,c=ou(t,0,64,f)|0,l=(c|0)==1,!l)?(e=0,e|0):(y=r[f>>2]|0,p=y+1|0,h=vt(p)|0,r[i>>2]=h,w=(h|0)==0,w)?(e=0,e|0):(b=r[f>>2]|0,k=b+1|0,s(h|0,0,k|0)|0,d=r[i>>2]|0,g=hu(n,t,d,0,64)|0,a=(g|0)==1,a)?(e=1,e|0):(v=r[i>>2]|0,o(v),e=0,e|0)}function ku(n,t,i,e,h,c){n=n|0;t=t|0;i=i|0;e=e|0;h=h|0;c=c|0;var l=0,vt=0,yt=0,pt=0,g=0,wt=0,bt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ui=0,fi=0,ei=0,oi=0,si=0,hi=0,ci=0,li=0,ai=0,vi=0,yi=0,pi=0,wi=0,bi=0,ki=0,di=0,gi=0,tr=0,ir=0,rr=0,ur=0,fr=0,er=0,or=0,sr=0,hr=0,cr=0,lr=0,ar=0,vr=0,yr=0,pr=0,wr=0,br=0,kr=0,dr=0,gr=0,nu=0,tu=0,iu=0,ru=0,uu=0,fu=0,eu=0,ou=0,su=0,hu=0,cu=0,lu=0,au=0,vu=0,yu=0,pu=0,wu=0,bu=0,nt=0,ft=0,w=0,b=0,y=0,ot=0,st=0,ht=0,ct=0,ku=0,lt=0,at=0,tt=0,v=0,it=0,du=0,p=0,rt=0,a=0,k=0,ut=0;a=u;u=u+3488|0;tt=a+3443|0;v=a+3360|0;it=a+28|0;y=a+24|0;ot=a+20|0;w=a+16|0;b=a+12|0;st=a+2848|0;ht=a+8|0;nt=a+4|0;ft=a;p=tt;k=1185;ut=p+35|0;do f[p>>0]=f[k>>0]|0,p=p+1|0,k=k+1|0;while((p|0)<(ut|0));p=v;k=1220;ut=p+83|0;do f[p>>0]=f[k>>0]|0,p=p+1|0,k=k+1|0;while((p|0)<(ut|0));if(yt=(n|0)==0,yt)return l=-1,u=a,l|0;if(pt=(t|0)==0,pt)return l=-2,u=a,l|0;if(ei=et(n,t,y,ot)|0,bi=(ei|0)==0,bi)return l=-9,u=a,l|0;if(sr=(i|0)==0,sr)return dr=r[y>>2]|0,o(dr),l=-3,u=a,l|0;if(vt=h+-2|0,du=vt>>>0<4,!du)return hu=r[y>>2]|0,o(hu),l=-4,u=a,l|0;if(pu=et(i,e,w,b)|0,wu=(pu|0)==0,wu)return bu=r[y>>2]|0,o(bu),l=-10,u=a,l|0;g=r[b>>2]|0;n:do switch(g|0){case 20:if(wt=(h|0)==2,wt){pr=tt+15|0;wr=r[w>>2]|0;br=r[b>>2]|0;d(pr|0,wr|0,br|0)|0;ct=tt;at=35;break n}return bt=r[w>>2]|0,o(bt),kt=r[y>>2]|0,o(kt),l=-5,u=a,l|0;case 32:if(dt=(h|0)==3,dt){ti=g+17|0;ui=ti&255;fi=v+1|0;f[fi>>0]=ui;oi=v+14|0;f[oi>>0]=1;si=r[b>>2]|0;hi=si&255;ci=v+18|0;f[ci>>0]=hi;rt=24;break n}return gt=r[w>>2]|0,o(gt),ni=r[y>>2]|0,o(ni),l=-5,u=a,l|0;case 48:if(li=(h|0)==4,li){yi=g+17|0;pi=yi&255;wi=v+1|0;f[wi>>0]=pi;ki=v+14|0;f[ki>>0]=2;di=r[b>>2]|0;gi=di&255;tr=v+18|0;f[tr>>0]=gi;rt=24;break n}return ai=r[w>>2]|0,o(ai),vi=r[y>>2]|0,o(vi),l=-5,u=a,l|0;case 64:if(ir=(h|0)==5,ir){fr=g+17|0;er=fr&255;or=v+1|0;f[or>>0]=er;hr=v+14|0;f[hr>>0]=3;cr=r[b>>2]|0;lr=cr&255;ar=v+18|0;f[ar>>0]=lr;rt=24;break n}return rr=r[w>>2]|0,o(rr),ur=r[y>>2]|0,o(ur),l=-5,u=a,l|0;default:return vr=r[w>>2]|0,o(vr),yr=r[y>>2]|0,o(yr),l=-6,u=a,l|0}while(0);return((rt|0)==24&&(lt=r[b>>2]|0,ku=lt+19|0,kr=v+19|0,gr=r[w>>2]|0,d(kr|0,gr|0,lt|0)|0,ct=v,at=ku),nu=r[y>>2]|0,tu=r[ot>>2]|0,iu=ii(nu,tu,it)|0,ru=(iu|0)==0,uu=r[w>>2]|0,o(uu),fu=r[y>>2]|0,o(fu),!ru)?(l=-7,u=a,l|0):(eu=hf(st,ht,ct,at,it)|0,ou=(eu|0)==0,s(it|0,0,2818)|0,!ou)?(l=-8,u=a,l|0):(su=r[ht>>2]|0,cu=ri(st,su,nt,ft)|0,lu=(cu|0)==0,lu)?(l=-11,u=a,l|0):(au=r[nt>>2]|0,nr(c,au)|0,vu=r[nt>>2]|0,o(vu),yu=r[ft>>2]|0,l=yu,u=a,l|0)}function du(n,t,i,f,e){n=n|0;t=t|0;i=i|0;f=f|0;e=e|0;var c=0,nt=0,tt=0,it=0,rt=0,ut=0,ft=0,ot=0,st=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ui=0,fi=0,p=0,ei=0,v=0,w=0,b=0,k=0,l=0,d=0,a=0,g=0,y=0,h=0;return(h=u,u=u+3360|0,l=h+24|0,d=h+20|0,a=h+16|0,g=h+12|0,y=h+28|0,b=h+2848|0,k=h+8|0,v=h+4|0,w=h,nt=(n|0)==0,nt)?(c=-1,u=h,c|0):(tt=(t|0)==0,tt)?(c=-2,u=h,c|0):(vt=et(n,t,l,d)|0,gt=(vt|0)==0,gt)?(c=-9,u=h,c|0):(ni=(i|0)==0,ni)?(ti=r[l>>2]|0,o(ti),c=-12,u=h,c|0):(ui=et(i,f,a,g)|0,fi=(ui|0)==0,p=r[l>>2]|0,fi)?(o(p),c=-13,u=h,c|0):(ei=r[d>>2]|0,it=ii(p,ei,y)|0,rt=(it|0)==0,!rt)?(ut=r[a>>2]|0,o(ut),ft=r[l>>2]|0,o(ft),c=-7,u=h,c|0):(ot=r[l>>2]|0,o(ot),st=r[a>>2]|0,ht=r[g>>2]|0,ct=cf(b,k,st,ht,y)|0,lt=(ct|0)==0,at=r[a>>2]|0,o(at),s(y|0,0,2818)|0,!lt)?(c=-8,u=h,c|0):(yt=r[k>>2]|0,pt=ri(b,yt,v,w)|0,wt=(pt|0)==0,wt)?(c=-14,u=h,c|0):(bt=r[v>>2]|0,nr(e,bt)|0,kt=r[v>>2]|0,o(kt),dt=r[w>>2]|0,c=dt,u=h,c|0)}function ui(n,t){n=n|0;t=t|0;var i=0,o=0,r=0,e=0;o=u;do switch(n|0){case-1:i=t;r=1303;e=i+36|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-2:i=t;r=1339;e=i+37|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-3:i=t;r=1376;e=i+29|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-4:i=t;r=1405;e=i+33|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-5:i=t;r=1438;e=i+32|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-6:i=t;r=1470;e=i+30|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-7:i=t;r=1500;e=i+29|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-8:i=t;r=1529;e=i+26|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-9:i=t;r=1555;e=i+37|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-10:i=t;r=1592;e=i+30|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-11:i=t;r=1622;e=i+46|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-12:i=t;r=1668;e=i+34|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-13:i=t;r=1702;e=i+35|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;case-14:i=t;r=1737;e=i+44|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return;default:i=t;r=1781;e=i+22|0;do f[i>>0]=f[r>>0]|0,i=i+1|0,r=r+1|0;while((i|0)<(e|0));return}while(0)}function gu(n,t,i,r,f){n=n|0;t=t|0;i=i|0;r=r|0;f=f|0;var e=0,o=0,s=0;return(s=u,e=ku(n,t,i,r,f,1803)|0,o=(e|0)<1,!o)?1803:(ui(e,1803),1803)}function nf(n,t,i,r){n=n|0;t=t|0;i=i|0;r=r|0;var f=0,e=0,o=0;return(o=u,f=du(n,t,i,r,2827)|0,e=(f|0)<1,!e)?2827:(ui(f,2827),2827)}function tf(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var p=0,o=0,s=0,c=0,w=0,b=0,l=0,k=0,d=0,g=0,nt=0,tt=0,a=0,v=0,it=0,rt=0,y=0,ut=0,e=0,ft=0,et=0,ot=0;ot=u;o=n&65535;s=n>>>16;a=t&65535;v=t>>>16;it=h(a,o)|0;r[f>>2]=it;rt=h(v,s)|0;r[i>>2]=rt;y=h(v,o)|0;ut=h(a,s)|0;e=y+ut|0;ft=e>>>0<y>>>0;p=ft?65536:0;c=e<<16;w=e>>>16;b=r[f>>2]|0;l=b+c|0;r[f>>2]=l;k=l>>>0<c>>>0;d=k&1;et=d|p;g=r[i>>2]|0;nt=g+w|0;tt=nt+et|0;r[i>>2]=tt;return}function fi(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var tt=0,it=0,rt=0,ut=0,a=0,ft=0,et=0,ot=0,st=0,y=0,p=0,w=0,ht=0,s=0,ct=0,lt=0,at=0,vt=0,b=0,yt=0,k=0,d=0,g=0,h=0,pt=0,nt=0,c=0,wt=0,e=0,o=0;if(o=u,u=u+16|0,nt=o+4|0,c=o,it=f+1|0,l(n,it),rt=(t|0)==0,rt){u=o;return}if(s=v(i,f)|0,lt=(s|0)==0,lt)g=0;else for(h=0,e=0;;)if(at=i+(e<<2)|0,vt=r[at>>2]|0,tf(t,vt,nt,c),b=n+(e<<2)|0,yt=r[b>>2]|0,k=yt+h|0,d=k>>>0<h>>>0,tt=d&1,ut=r[c>>2]|0,a=k+ut|0,r[b>>2]=a,ft=r[c>>2]|0,et=a>>>0<ft>>>0,ot=d?2:1,pt=et?ot:tt,st=r[nt>>2]|0,y=pt+st|0,p=e+1|0,wt=(p|0)==(s|0),wt){g=y;break}else h=y,e=p;w=n+(s<<2)|0;ht=r[w>>2]|0;ct=ht+g|0;r[w>>2]=ct;u=o;return}function ei(n,t){n=n|0;t=t|0;var e=0,v=0,o=0,i=0,y=0,p=0,w=0,b=0,k=0,s=0,c=0,l=0,d=0,a=0,f=0,g=0;for(g=u,c=-2,l=1,a=2,f=1;;)if(o=c<<1,i=l<<1,y=h(f,t)|0,p=o^-1,w=y&p,b=i>>>0<w>>>0,k=b?i:0,e=k+f|0,s=a+1|0,d=(s|0)==33,d){v=e;break}else c=o,l=i,a=s,f=e;r[n>>2]=v;return}function rt(n,t,i,f,e,o){n=n|0;t=t|0;i=i|0;f=f|0;e=e|0;o=o|0;var ft=0,et=0,st=0,ht=0,ct=0,y=0,lt=0,vt=0,yt=0,pt=0,d=0,g=0,w=0,wt=0,bt=0,kt=0,nt=0,dt=0,gt=0,ni=0,ti=0,ii=0,b=0,ri=0,tt=0,ui=0,ei=0,oi=0,si=0,s=0,c=0,v=0,rt=0,hi=0,k=0,ci=0,ut=0,a=0;if(a=u,u=u+2080|0,v=a+1040|0,ut=a+520|0,rt=a,et=o<<1,st=et|1,l(v,st),wt=(o|0)==0,wt)g=0,s=v;else{for(b=o+1|0,c=v,k=0;;)if(ri=t+(k<<2)|0,tt=r[ri>>2]|0,ui=r[i>>2]|0,ei=h(ui,tt)|0,oi=r[c>>2]|0,si=ei+oi|0,ht=h(si,e)|0,fi(rt,tt,i,o),fi(ut,ht,f,o),ct=at(c,c,rt,b)|0,y=c+(b<<2)|0,r[y>>2]=ct,lt=at(c,c,ut,b)|0,vt=r[y>>2]|0,yt=vt+lt|0,r[y>>2]=yt,pt=c+4|0,d=k+1|0,hi=(d|0)==(o|0),hi)break;else c=pt,k=d;ci=v+(o<<2)|0;g=o;s=ci}if(ft=g+o|0,w=v+(ft<<2)|0,bt=r[w>>2]|0,kt=(bt|0)==0,kt){if(ti=ot(s,f,o)|0,ii=(ti|0)>-1,!ii){p(n,s,o);u=a;return}it(s,s,f,o)|0;p(n,s,o);u=a;return}if(nt=it(s,s,f,o)|0,dt=(nt|0)==0,dt){p(n,s,o);u=a;return}gt=r[w>>2]|0;ni=gt-nt|0;r[w>>2]=ni;p(n,s,o);u=a;return}function oi(n,t,i,f,e,o){n=n|0;t=t|0;i=i|0;f=f|0;e=e|0;o=o|0;var ot=0,st=0,ht=0,a=0,ct=0,lt=0,at=0,vt=0,yt=0,d=0,g=0,pt=0,wt=0,bt=0,kt=0,nt=0,dt=0,gt=0,y=0,ni=0,ti=0,ii=0,tt=0,it=0,ft=0,s=0,w=0,b=0,k=0,c=0,et=0,h=0;if(h=u,u=u+3632|0,s=h+3112|0,tt=h+2592|0,ft=h+1552|0,it=h+1032|0,c=h+516|0,et=h,ht=o<<5,a=o+1|0,si(tt,ht,a),kt=o<<6,nt=a<<1,si(ft,kt,nt),ut(it,ft,nt,f,o),rt(et,t,it,f,e,o),ut(s,tt,a,f,o),dt=of(i,o)|0,gt=v(i,o)|0,y=dt+-1|0,ni=(y|0)>-1,!ni){l(c,o);r[c>>2]=1;rt(s,s,c,f,e,o);p(n,s,o);u=h;return}for(ti=y&31,ii=1<<ti,ct=gt+-1|0,w=ii,b=y,k=ct;;)if(rt(s,s,s,f,e,o),lt=i+(k<<2)|0,at=r[lt>>2]|0,vt=at&w,yt=(vt|0)==0,yt||rt(s,s,et,f,e,o),d=w>>>1,g=(d|0)==0,ot=g?-2147483648:d,pt=g<<31>>31,st=pt+k|0,wt=b+-1|0,bt=(b|0)>0,bt)w=ot,b=wt,k=st;else break;l(c,o);r[c>>2]=1;rt(s,s,c,f,e,o);p(n,s,o);u=h;return}function b(n,t,i,e){n=n|0;t=t|0;i=i|0;e=e|0;var nt=0,y=0,tt=0,it=0,rt=0,ut=0,ft=0,et=0,p=0,ot=0,w=0,st=0,ht=0,ct=0,lt=0,b=0,at=0,a=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0,dt=0,gt=0,ni=0,ti=0,k=0,ii=0,o=0,c=0,d=0,h=0,l=0,ri=0,g=0,v=0,ui=0,fi=0;fi=u;y=e+-1|0;tt=(t|0)!=0;ct=(y|0)>-1;kt=tt&ct;n:do if(kt){for(c=0,h=y;;){if(dt=(h|0)>-1,!dt){d=c;break}for(ti=-2-h|0,k=ti+1|0,ii=k>>>0>4294967292,ui=ii?k:-4,l=h,g=0,v=0;;)if(rt=i+l|0,ut=f[rt>>0]|0,ft=ut&255,et=ft<<v,p=et|g,ot=l+-1|0,w=v+8|0,st=(l|0)>0,ht=w>>>0<32,lt=ht&st,lt)l=ot,g=p,v=w;else{nt=p;break}if(b=h+ui|0,at=n+(c<<2)|0,r[at>>2]=nt,a=c+1|0,vt=a>>>0<t>>>0,yt=(b|0)>-1,pt=vt&yt,pt)c=a,h=b;else{o=a;break n}}gt=n+(d<<2)|0;r[gt>>2]=0;ni=d+1|0;o=ni}else o=0;while(0);if(it=o>>>0<t>>>0,it){ri=n+(o<<2)|0;wt=t-o|0;bt=wt<<2;s(ri|0,0,bt|0)|0;return}}function rf(n,t,i,e){n=n|0;t=t|0;i=i|0;e=e|0;var c=0,k=0,d=0,g=0,nt=0,tt=0,it=0,p=0,rt=0,ut=0,ft=0,l=0,et=0,w=0,ot=0,st=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0,b=0,a=0,v=0,o=0,s=0,h=0,y=0,dt=0,gt=0;gt=u;c=t+-1|0;k=(e|0)!=0;et=(c|0)>-1;vt=k&et;n:do{if(vt){for(a=0,o=c;;){if(pt=i+(a<<2)|0,wt=r[pt>>2]|0,bt=(o|0)>-1,!bt)break;for(kt=-2-o|0,b=kt+1|0,d=b>>>0>4294967292,dt=d?b:-4,s=o,y=0;;)if(g=wt>>>y,nt=g&255,tt=n+s|0,f[tt>>0]=nt,it=s+-1|0,p=y+8|0,rt=(s|0)>0,ut=p>>>0<32,ft=ut&rt,ft)s=it,y=p;else break;if(l=o+dt|0,w=a+1|0,ot=w>>>0<e>>>0,st=(l|0)>-1,ht=ot&st,ht)a=w,o=l;else{v=l;break n}}return}v=c}while(0);if(yt=(v|0)>-1,yt)h=v;else return;for(;;)if(ct=n+h|0,f[ct>>0]=0,lt=h+-1|0,at=(h|0)>0,at)h=lt;else break;return}function l(n,t){n=n|0;t=t|0;var i=0,r=0,f=0;if(f=u,i=(t|0)==0,!i){r=t<<2;s(n|0,0,r|0)|0;return}}function si(n,t,i){n=n|0;t=t|0;i=i|0;var f=0,e=0,o=0,s=0,h=0,c=0,a=0;if(a=u,l(n,i),f=i<<5,e=f>>>0>t>>>0,e){o=t&31;s=1<<o;h=t>>>5;c=n+(h<<2)|0;r[c>>2]=s;return}}function it(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var k=0,v=0,e=0,o=0,s=0,d=0,g=0,nt=0,tt=0,y=0,it=0,p=0,rt=0,ut=0,h=0,ft=0,w=0,et=0,ot=0,c=0,l=0,a=0,b=0,st=0;if(st=u,g=(f|0)==0,g)return a=0,a|0;for(v=f,e=i,o=t,s=n,c=0;;)if(nt=r[o>>2]|0,p=nt-c|0,rt=o+4|0,ut=(p|0)==-1,h=r[e>>2]|0,ut?(ft=h^-1,l=c,b=ft):(w=p-h|0,et=h^-1,ot=w>>>0>et>>>0,k=ot&1,l=k,b=w),d=e+4|0,tt=s+4|0,r[s>>2]=b,y=v+-1|0,it=(y|0)==0,it){a=l;break}else v=y,e=d,o=rt,s=tt,c=l;return a|0}function hi(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var st=0,c=0,b=0,ht=0,ct=0,k=0,lt=0,d=0,g=0,at=0,nt=0,vt=0,yt=0,a=0,pt=0,wt=0,tt=0,it=0,bt=0,rt=0,kt=0,dt=0,ut=0,gt=0,ni=0,ft=0,ti=0,ii=0,ri=0,ui=0,fi=0,y=0,ei=0,et=0,ot=0,w=0,oi=0,si=0,e=0,h=0,o=0,s=0;if(s=u,u=u+1040|0,o=s+8|0,ot=s+4|0,w=s,c=f<<1,l(o,c),b=v(t,f)|0,a=v(i,f)|0,gt=(b|0)==0,gt){p(n,o,c);u=s;return}for(ni=(a|0)==0,e=0;;){if(ft=t+(e<<2)|0,ti=r[ft>>2]|0,ii=(ti|0)==0,fi=ii|ni,fi)et=0;else for(y=0,h=0;;)if(ri=r[ft>>2]|0,ui=i+(h<<2)|0,ht=r[ui>>2]|0,li(ri,ht,ot,w),ct=h+e|0,k=o+(ct<<2)|0,lt=r[k>>2]|0,d=lt+y|0,g=d>>>0<y>>>0,st=g&1,at=r[w>>2]|0,nt=d+at|0,r[k>>2]=nt,vt=r[w>>2]|0,yt=nt>>>0<vt>>>0,pt=g?2:1,ei=yt?pt:st,wt=r[ot>>2]|0,tt=ei+wt|0,it=h+1|0,oi=(it|0)==(a|0),oi){et=tt;break}else y=tt,h=it;if(bt=e+a|0,rt=o+(bt<<2)|0,kt=r[rt>>2]|0,dt=kt+et|0,r[rt>>2]=dt,ut=e+1|0,si=(ut|0)==(b|0),si)break;else e=ut}p(n,o,c);u=s;return}function v(n,t){n=n|0;t=t|0;var i=0,e=0,f=0,s=0,h=0,c=0,l=0,a=0,o=0,v=0,y=0,p=0;if(p=u,s=(t|0)==0,s)return f=0,f|0;for(h=t+-1|0,i=h;;){if(c=n+(i<<2)|0,l=r[c>>2]|0,a=(l|0)==0,!a){e=i;break}if(o=i+-1|0,v=(i|0)==0,v){e=o;break}else i=o}return y=e+1|0,f=y,f|0}function p(n,t,i){n=n|0;t=t|0;i=i|0;var o=0,f=0,e=0,h=0,c=0,l=0,a=0,s=0,v=0,y=0;if(y=u,h=(i|0)==0,!h){for(o=i,f=t,e=n;;)if(c=f+4|0,l=r[f>>2]|0,a=e+4|0,r[e>>2]=l,s=o+-1|0,v=(s|0)==0,v)break;else o=s,f=c,e=a;return}}function ci(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var h=0,e=0,o=0,c=0,y=0,p=0,l=0,w=0,b=0,k=0,d=0,a=0,g=0,nt=0,tt=0,it=0,v=0,s=0,rt=0,ut=0;if(ut=u,y=i>>>0<32,p=(f|0)!=0,rt=y&p,!rt)return s=0,s|0;for(b=32-i|0,k=(i|0)==0,e=n,o=t,c=f,v=0;;)if(d=o+4|0,a=r[o>>2]|0,g=a<<i,nt=g|v,tt=e+4|0,r[e>>2]=nt,it=a>>>b,h=k?0:it,l=c+-1|0,w=(l|0)==0,w){s=h;break}else e=tt,o=d,c=l,v=h;return s|0}function uf(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var s=0,h=0,a=0,v=0,y=0,p=0,w=0,b=0,e=0,k=0,c=0,d=0,g=0,nt=0,l=0,o=0,tt=0,it=0;if(it=u,a=i>>>0<32,v=(f|0)!=0,tt=a&v,!tt)return o=0,o|0;for(w=32-i|0,b=(i|0)==0,h=f,l=0;;)if(e=h+-1|0,k=t+(e<<2)|0,c=r[k>>2]|0,d=c>>>i,g=d|l,nt=n+(e<<2)|0,r[nt>>2]=g,y=c<<w,s=b?0:y,p=(e|0)==0,p){o=s;break}else h=e,l=s;return o|0}function ff(n,t,i,f,e,o){n=n|0;t=t|0;i=i|0;f=f|0;e=e|0;o=o|0;var nr=0,tr=0,ir=0,wt=0,s=0,rr=0,tt=0,bt=0,ur=0,fr=0,y=0,a=0,kt=0,dt=0,gt=0,er=0,ni=0,or=0,sr=0,hr=0,cr=0,d=0,lr=0,ar=0,vr=0,yr=0,pr=0,wr=0,br=0,rt=0,kr=0,dr=0,ti=0,ii=0,gr=0,ri=0,ui=0,nu=0,tu=0,iu=0,ru=0,uu=0,fu=0,eu=0,ou=0,su=0,hu=0,fi=0,cu=0,lu=0,au=0,vu=0,yu=0,pu=0,wu=0,bu=0,ku=0,du=0,ei=0,oi=0,ut=0,si=0,hi=0,gu=0,nf=0,tf=0,li=0,ft=0,rf=0,ff=0,ef=0,of=0,hf=0,vi=0,cf=0,lf=0,et=0,af=0,vf=0,yi=0,yf=0,pf=0,wf=0,bf=0,kf=0,df=0,gf=0,w=0,ne=0,st=0,te=0,ie=0,re=0,ue=0,fe=0,ee=0,oe=0,se=0,he=0,ce=0,le=0,ae=0,ve=0,ye=0,ht=0,ct=0,pe=0,pi=0,lt=0,wi=0,bi=0,at=0,vt=0,we=0,c=0,b=0,p=0,be=0,ke=0,de=0,yt=0,g=0,ki=0,di=0,k=0,pt=0,ge=0,gi=0,nt=0;if(nt=u,u=u+1552|0,c=nt+516|0,b=nt,s=v(e,o)|0,rr=(s|0)==0,rr){u=nt;return}if(ni=s+-1|0,wr=e+(ni<<2)|0,tu=r[wr>>2]|0,lu=ai(tu)|0,ut=32-lu|0,l(c,s),of=ci(c,i,ut,f)|0,wf=c+(f<<2)|0,r[wf>>2]=of,ci(b,e,ut,s)|0,ue=b+(ni<<2)|0,tt=r[ue>>2]|0,l(n,f),bt=f-s|0,ur=(bt|0)>-1,ur)for(fr=(tt|0)==-1,y=tt+1|0,a=y>>>16,kt=(a|0)==65535,dt=y&65535,gt=y<<16,er=gt^-1,or=y<<16,sr=-2-tt|0,hr=a+1|0,cr=a+1|0,p=bt;;){if(d=p+s|0,fr)lr=c+(d<<2)|0,ar=r[lr>>2]|0,at=ar;else{for(vr=d+-1|0,yr=c+(vr<<2)|0,pr=r[yr>>2]|0,br=c+(d<<2)|0,rt=r[br>>2]|0,kt?(kr=rt>>>16,ht=kr):(dr=(rt>>>0)/(cr>>>0)&-1,ht=dr),ye=ht&65535,ti=ht&65535,ii=h(ti,dt)|0,gr=h(ti,a)|0,ri=ii<<16,ui=pr-ri|0,nu=ri^-1,iu=ui>>>0>nu>>>0,ru=iu<<31>>31,uu=ii>>>16,nr=rt-gr|0,fu=nr-uu|0,eu=fu+ru|0,ct=ye,g=ui,k=eu;;){if(ou=k>>>0>a>>>0,!ou&&(su=(k|0)!=(a|0),hu=g>>>0<or>>>0,be=hu|su,be)){pe=ct;ki=g;pt=k;break}fi=g-gt|0;cu=fi>>>0>er>>>0;au=cu<<31>>31;tr=k-a|0;vu=tr+au|0;yu=ct+1<<16>>16;ct=yu;g=fi;k=vu}if(kt?(pu=pt&65535,lt=pu):(wu=pt<<16,bu=ki>>>16,ku=wu|bu,du=(ku>>>0)/(hr>>>0)&-1,lt=du),pi=lt&65535,ei=lt&65535,oi=h(ei,dt)|0,si=h(ei,a)|0,hi=ki-oi|0,gu=oi^-1,nf=hi>>>0>gu>>>0,tf=nf<<31>>31,li=si<<16,ft=hi-li|0,rf=li^-1,ff=ft>>>0>rf>>>0,ef=ff<<31>>31,hf=si>>>16,ir=pt-hf|0,ge=ir+tf|0,vi=ge+ef|0,cf=(vi|0)==0,lf=ft>>>0<y>>>0,de=lf&cf,de)wi=pi;else for(bi=pi,di=ft,gi=vi;;)if(et=di-y|0,af=et>>>0>sr>>>0,vf=af<<31>>31,wt=vf+gi|0,yi=bi+1<<16>>16,yf=(wt|0)==0,pf=et>>>0<y>>>0,ke=pf&yf,ke){wi=yi;break}else bi=yi,di=et,gi=wt;bf=pe&65535;kf=bf<<16;df=wi&65535;gf=df|kf;at=gf}for(w=c+(p<<2)|0,ne=sf(w,w,at,b,s)|0,st=c+(d<<2)|0,te=r[st>>2]|0,ie=te-ne|0,vt=at,yt=ie;;){if(r[st>>2]=yt,re=(yt|0)==0,re&&(fe=ot(w,b,s)|0,ee=(fe|0)>-1,!ee)){we=vt;break}oe=vt+1|0;se=it(w,w,b,s)|0;he=r[st>>2]|0;ce=he-se|0;vt=oe;yt=ce}if(le=n+(p<<2)|0,r[le>>2]=we,ae=p+-1|0,ve=(p|0)>0,ve)p=ae;else break}l(t,o);uf(t,c,ut,s)|0;u=nt;return}function ot(n,t,i){n=n|0;t=t|0;i=i|0;var o=0,f=0,c=0,e=0,l=0,s=0,a=0,h=0,v=0,y=0,p=0,w=0;w=u;c=(i|0)==0;n:do if(c)f=0;else for(o=i;;){if(e=o+-1|0,l=n+(e<<2)|0,s=r[l>>2]|0,a=t+(e<<2)|0,h=r[a>>2]|0,v=s>>>0>h>>>0,v){f=1;break n}if(y=s>>>0<h>>>0,y){f=-1;break n}if(p=(e|0)==0,p){f=0;break}else o=e}while(0);return f|0}function ut(n,t,i,r,f){n=n|0;t=t|0;i=i|0;r=r|0;f=f|0;var o=0,e=0;e=u;u=u+1040|0;o=e;ff(o,n,t,i,r,f);u=e;return}function ef(n,t,i,r,f){n=n|0;t=t|0;i=i|0;r=r|0;f=f|0;var s=0,e=0,o=0;o=u;u=u+1040|0;e=o;hi(e,t,i,f);s=f<<1;ut(n,e,s,r,f);u=o;return}function at(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var k=0,a=0,o=0,s=0,h=0,d=0,g=0,nt=0,tt=0,it=0,v=0,y=0,c=0,p=0,rt=0,ut=0,w=0,e=0,b=0,l=0,ft=0,et=0;if(et=u,g=(f|0)==0,g)return l=0,l|0;for(a=f,o=i,s=t,h=n,e=0;;)if(nt=s+4|0,it=r[s>>2]|0,v=it+e|0,y=v>>>0<e>>>0,c=r[o>>2]|0,p=v+c|0,rt=p>>>0<c>>>0,k=rt&1,b=y?e:k,ft=y?c:p,d=o+4|0,ut=h+4|0,r[h>>2]=ft,w=a+-1|0,tt=(w|0)==0,tt){l=b;break}else a=w,o=d,s=nt,h=ut,e=b;return l|0}function of(n,t){n=n|0;t=t|0;var i=0,f=0,o=0,e=0,s=0,h=0,c=0,l=0,a=0,y=0;return(y=u,f=v(n,t)|0,o=(f|0)==0,o)?(i=0,i|0):(e=f+-1|0,s=e<<5,h=n+(e<<2)|0,c=r[h>>2]|0,l=ai(c)|0,a=l+s|0,i=a,i|0)}function li(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var p=0,o=0,s=0,c=0,w=0,b=0,l=0,k=0,d=0,g=0,nt=0,tt=0,a=0,v=0,it=0,rt=0,y=0,ut=0,e=0,ft=0,et=0,ot=0;ot=u;o=n>>>16;s=t>>>16;a=n&65535;v=t&65535;it=h(v,a)|0;r[f>>2]=it;rt=h(s,o)|0;r[i>>2]=rt;y=h(s,a)|0;ut=h(v,o)|0;e=y+ut|0;ft=e>>>0<y>>>0;p=ft?65536:0;c=e<<16;w=e>>>16;b=r[f>>2]|0;l=b+c|0;r[f>>2]=l;k=l>>>0<c>>>0;d=k&1;et=d|p;g=r[i>>2]|0;nt=g+w|0;tt=nt+et|0;r[i>>2]=tt;return}function ai(n){n=n|0;var r=0,o=0,t=0,f=0,s=0,h=0,i=0,e=0,c=0,l=0;if(l=u,o=(n|0)==0,o)return i=0,i|0;for(r=n,e=0;;)if(t=e+1|0,f=r>>>1,s=t>>>0>31,h=(f|0)==0,c=h|s,c){i=t;break}else r=f,e=t;return i|0}function sf(n,t,i,f,e){n=n|0;t=t|0;i=i|0;f=f|0;e=e|0;var k=0,d=0,g=0,nt=0,a=0,tt=0,it=0,rt=0,ut=0,ft=0,v=0,y=0,et=0,ot=0,st=0,ht=0,p=0,ct=0,lt=0,w=0,h=0,at=0,c=0,vt=0,o=0,yt=0,b=0,l=0,s=0;if(s=u,u=u+16|0,b=s+4|0,l=s,d=(i|0)==0,g=(e|0)==0,yt=d|g,yt)return c=0,u=s,c|0;for(h=0,o=0;;)if(et=f+(o<<2)|0,ot=r[et>>2]|0,li(i,ot,b,l),st=t+(o<<2)|0,ht=r[st>>2]|0,p=ht-h|0,ct=n+(o<<2)|0,lt=h^-1,w=p>>>0>lt>>>0,k=w&1,nt=r[l>>2]|0,a=p-nt|0,r[ct>>2]=a,tt=r[l>>2]|0,it=tt^-1,rt=a>>>0>it>>>0,ut=w?2:1,at=rt?ut:k,ft=r[b>>2]|0,v=at+ft|0,y=o+1|0,vt=(y|0)==(e|0),vt){c=v;break}else h=v,o=y;return u=s,c|0}function hf(n,t,i,r,e){n=n|0;t=t|0;i=i|0;r=r|0;e=e|0;var h=0,c=0,y=0,p=0,w=0,b=0,k=0,nt=0,tt=0,it=0,rt=0,ut=0,ft=0,et=0,ot=0,st=0,ht=0,ct=0,l=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,a=0,o=0,bt=0,v=0;return(v=u,u=u+512|0,o=v,c=g[e>>1]|0,y=c&65535,et=y+7|0,l=et>>>3,lt=r+11|0,at=lt>>>0>l>>>0,at)?(h=1030,u=v,h|0):(f[o>>0]=0,vt=o+1|0,f[vt>>0]=1,yt=r^-1,pt=l+yt|0,wt=pt>>>0>2,wt?(bt=o+2|0,p=c&65535,w=p+7|0,b=w>>>3,k=b+-3|0,nt=k-r|0,s(bt|0,-1,nt|0)|0,tt=c&65535,it=tt+7|0,rt=it>>>3,ut=rt+-1|0,ft=ut-r|0,a=ft):a=2,ot=a+1|0,st=o+a|0,f[st>>0]=0,ht=o+ot|0,d(ht|0,i|0,r|0)|0,ct=vi(n,t,o,l,e)|0,s(o|0,0,512)|0,h=ct,u=v,h|0)}function vi(n,t,i,f,e){n=n|0;t=t|0;i=i|0;f=f|0;e=e|0;var tt=0,pt=0,wt=0,bt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ii=0,lt=0,ri=0,ui=0,fi=0,vt=0,si=0,ci=0,li=0,ai=0,vi=0,yi=0,yt=0,c=0,nt=0,pi=0,p=0,rt=0,ft=0,et=0,st=0,w=0,k=0,y=0,ht=0,a=0,d=0,ct=0,h=0,o=0;return(o=u,u=u+6208|0,p=o+5680|0,rt=o+5164|0,ft=o+4648|0,et=o+4132|0,st=o+3616|0,k=o+3100|0,y=o+2584|0,ht=o+2068|0,a=o+1552|0,d=o+1036|0,ct=o+520|0,h=o+4|0,w=o,b(p,129,i,f),pt=e+1538|0,b(a,129,pt,256),wt=e+1794|0,b(d,129,wt,256),fi=e+2050|0,b(et,129,fi,256),ai=e+2306|0,b(st,129,ai,256),vi=e+2|0,b(ht,129,vi,512),yi=e+2562|0,b(ct,129,yi,256),yt=v(p,129)|0,c=v(a,129)|0,nt=v(ht,129)|0,pi=ot(p,ht,nt)|0,bt=(pi|0)>-1,bt)?(tt=1025,u=o,tt|0):(kt=g[e>>1]|0,dt=kt&65535,gt=dt+7|0,ni=gt>>>3,r[t>>2]=ni,ut(rt,p,yt,a,c),ut(ft,p,yt,d,c),l(k,nt),ti=r[a>>2]|0,ei(w,ti),ii=r[w>>2]|0,lt=0-ii|0,r[w>>2]=lt,oi(k,rt,et,a,lt,c),l(y,nt),ri=r[d>>2]|0,ei(w,ri),ui=r[w>>2]|0,vt=0-ui|0,r[w>>2]=vt,oi(y,ft,st,d,vt,c),si=ot(k,y,c)|0,ci=(si|0)>-1,ci?it(h,k,y,c)|0:(it(h,y,k,c)|0,it(h,a,h,c)|0),ef(h,h,ct,a,c),hi(h,h,d,c),at(h,h,y,nt)|0,li=r[t>>2]|0,rf(n,li,h,nt),s(p|0,0,516)|0,s(rt|0,0,516)|0,s(ft|0,0,516)|0,s(et|0,0,516)|0,s(st|0,0,516)|0,s(k|0,0,516)|0,s(y|0,0,516)|0,s(a|0,0,516)|0,s(d|0,0,516)|0,s(ct|0,0,516)|0,s(h|0,0,516)|0,tt=0,u=o,tt|0)}function cf(n,t,i,e,o){n=n|0;t=t|0;i=i|0;e=e|0;o=o|0;var h=0,it=0,rt=0,ut=0,ft=0,et=0,ot=0,k=0,st=0,ht=0,ct=0,lt=0,v=0,at=0,vt=0,y=0,yt=0,p=0,pt=0,wt=0,bt=0,c=0,kt=0,nt=0,dt=0,gt=0,ni=0,ti=0,w=0,a=0,l=0,tt=0,b=0;if(b=u,u=u+528|0,l=b+8|0,tt=b,it=g[o>>1]|0,rt=it&65535,at=rt+7|0,c=at>>>3,kt=c>>>0<e>>>0,kt)h=1030;else if(nt=vi(l,tt,i,e,o)|0,dt=(nt|0)==0,dt)if(gt=r[tt>>2]|0,ni=(gt|0)==(c|0),ni)if(ti=f[l>>0]|0,ut=ti<<24>>24==0,ut)if(ft=l+1|0,et=f[ft>>0]|0,ot=et<<24>>24==2,ot){k=c+-1|0;st=k>>>0>2;n:do if(st)for(a=2;;){if(ht=l+a|0,ct=f[ht>>0]|0,lt=ct<<24>>24==0,lt){w=a;break n}if(v=a+1|0,vt=v>>>0<k>>>0,vt)a=v;else{w=v;break}}else w=2;while(0);y=w+1|0;yt=c>>>0>y>>>0;yt?(p=c-y|0,r[t>>2]=p,pt=p+11|0,wt=pt>>>0>c>>>0,wt?h=1025:(bt=l+y|0,d(n|0,bt|0,p|0)|0,s(l|0,0,512)|0,h=0)):h=1025}else h=1025;else h=1025;else h=1030;else h=nt;return u=b,h|0}function yi(n){n=n|0;var t=0;t=u;o(n);return}function lf(n){n=n|0;var t=u;return}function af(n){n=n|0;var t=u;return}function vf(n){n=n|0;var t=u;return}function yf(n){n=n|0;var t=0;t=u;yi(n);return}function pf(n){n=n|0;var t=0;t=u;yi(n);return}function wf(n,t,i){n=n|0;t=t|0;i=i|0;var h=0,o=0,l=0,a=0,v=0,y=0,p=0,w=0,b=0,k=0,s=0,d=0,g=0,nt=0,tt=0,it=0,rt=0,ut=0,f=0,e=0,c=0,ft=0;if(c=u,u=u+64|0,f=c,l=(n|0)==(t|0),l)o=1;else if(a=(t|0)==0,a)o=0;else if(s=wi(t,16,32,0)|0,d=(s|0)==0,d)o=0;else{e=f;ft=e+56|0;do r[e>>2]=0,e=e+4|0;while((e|0)<(ft|0));r[f>>2]=s;g=f+8|0;r[g>>2]=n;nt=f+12|0;r[nt>>2]=-1;tt=f+48|0;r[tt>>2]=1;it=r[s>>2]|0;rt=it+28|0;ut=r[rt>>2]|0;v=r[i>>2]|0;kt[ut&3](s,f,v,1);y=f+24|0;p=r[y>>2]|0;w=(p|0)==1;w?(b=f+16|0,k=r[b>>2]|0,r[i>>2]=k,h=1):h=0;o=h}return u=c,o|0}function pi(n,t,i,e){n=n|0;t=t|0;i=i|0;e=e|0;var o=0,s=0,l=0,a=0,v=0,y=0,p=0,w=0,b=0,k=0,h=0,d=0,g=0,c=0,nt=0;nt=u;o=t+16|0;s=r[o>>2]|0;p=(s|0)==0;do if(p)r[o>>2]=i,w=t+24|0,r[w>>2]=e,b=t+36|0,r[b>>2]=1;else{if(k=(s|0)==(i|0),!k){c=t+36|0;l=r[c>>2]|0;a=l+1|0;r[c>>2]=a;v=t+24|0;r[v>>2]=2;y=t+54|0;f[y>>0]=1;break}h=t+24|0;d=r[h>>2]|0;g=(d|0)==2;g&&(r[h>>2]=e)}while(0);return}function bf(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var e=0,o=0,s=0,h=0;h=u;e=t+8|0;o=r[e>>2]|0;s=(n|0)==(o|0);s&&pi(0,t,i,f);return}function kf(n,t,i,f){n=n|0;t=t|0;i=i|0;f=f|0;var o=0,s=0,h=0,c=0,e=0,l=0,a=0,v=0,y=0;y=u;o=t+8|0;s=r[o>>2]|0;h=(n|0)==(s|0);h?pi(0,t,i,f):(c=n+8|0,e=r[c>>2]|0,l=r[e>>2]|0,a=l+28|0,v=r[a>>2]|0,kt[v&3](e,t,i,f));return}function wi(n,t,i,e){n=n|0;t=t|0;i=i|0;e=e|0;var d=0,nt=0,v=0,tt=0,c=0,it=0,y=0,p=0,w=0,b=0,rt=0,ut=0,ft=0,et=0,ot=0,st=0,ht=0,ct=0,at=0,vt=0,yt=0,pt=0,wt=0,kt=0,dt=0,gt=0,ni=0,ti=0,ii=0,ri=0,ui=0,fi=0,ei=0,oi=0,si=0,hi=0,l=0,ci=0,li=0,ai=0,vi=0,yi=0,a=0,pi=0,wi=0,bi=0,s=0,o=0,ki=0,di=0,gi=0,nr=0,h=0,k=0,tr=0;k=u;u=u+64|0;o=k;v=r[n>>2]|0;tt=v+-8|0;ot=r[tt>>2]|0;gt=ot;l=n+gt|0;yi=v+-4|0;a=r[yi>>2]|0;r[o>>2]=i;pi=o+4|0;r[pi>>2]=n;wi=o+8|0;r[wi>>2]=t;bi=o+12|0;r[bi>>2]=e;c=o+16|0;it=o+20|0;y=o+24|0;p=o+28|0;w=o+32|0;b=o+40|0;rt=(a|0)==(i|0);h=c;tr=h+36|0;do r[h>>2]=0,h=h+4|0;while((h|0)<(tr|0));g[c+36>>1]=0;f[c+38>>0]=0;n:do if(rt)ut=o+48|0,r[ut>>2]=1,ft=r[i>>2]|0,et=ft+20|0,st=r[et>>2]|0,lt[st&3](i,o,l,l,1,0),ht=r[y>>2]|0,ct=(ht|0)==1,d=ct?l:0,s=d;else{at=o+36|0;vt=r[a>>2]|0;yt=vt+24|0;pt=r[yt>>2]|0;bt[pt&3](a,o,l,1,0);wt=r[at>>2]|0;switch(wt|0){case 0:kt=r[b>>2]|0;dt=(kt|0)==1;ni=r[p>>2]|0;ti=(ni|0)==1;ki=dt&ti;ii=r[w>>2]|0;ri=(ii|0)==1;di=ki&ri;ui=r[it>>2]|0;nt=di?ui:0;s=nt;break n;case 1:break;default:s=0;break n}if(fi=r[y>>2]|0,ei=(fi|0)==1,!ei&&(oi=r[b>>2]|0,si=(oi|0)==0,hi=r[p>>2]|0,ci=(hi|0)==1,gi=si&ci,li=r[w>>2]|0,ai=(li|0)==1,nr=gi&ai,!nr)){s=0;break}vi=r[c>>2]|0;s=vi}while(0);return u=k,s|0}function bi(n,t,i,e,o){n=n|0;t=t|0;i=i|0;e=e|0;o=o|0;var y=0,p=0,w=0,b=0,k=0,d=0,g=0,nt=0,s=0,h=0,tt=0,it=0,rt=0,ut=0,ft=0,et=0,c=0,ot=0,l=0,st=0,ht=0,ct=0,lt=0,at=0,a=0,v=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0;kt=u;y=t+53|0;f[y>>0]=1;p=t+4|0;rt=r[p>>2]|0;lt=(rt|0)==(e|0);do if(lt){if(at=t+52|0,f[at>>0]=1,a=t+16|0,v=r[a>>2]|0,vt=(v|0)==0,vt){if(r[a>>2]=i,yt=t+24|0,r[yt>>2]=o,pt=t+36|0,r[pt>>2]=1,w=t+48|0,b=r[w>>2]|0,k=(b|0)==1,d=(o|0)==1,wt=k&d,!wt)break;g=t+54|0;f[g>>0]=1;break}if(nt=(v|0)==(i|0),!nt){l=t+36|0;st=r[l>>2]|0;ht=st+1|0;r[l>>2]=ht;ct=t+54|0;f[ct>>0]=1;break}s=t+24|0;h=r[s>>2]|0;tt=(h|0)==2;tt?(r[s>>2]=o,c=o):c=h;it=t+48|0;ut=r[it>>2]|0;ft=(ut|0)==1;et=(c|0)==1;bt=ft&et;bt&&(ot=t+54|0,f[ot>>0]=1)}while(0);return}function df(n,t,i,e,o){n=n|0;t=t|0;i=i|0;e=e|0;o=o|0;var k=0,d=0,g=0,nt=0,tt=0,it=0,l=0,rt=0,ut=0,ft=0,et=0,ot=0,st=0,h=0,ht=0,ct=0,a=0,v=0,at=0,y=0,vt=0,yt=0,pt=0,wt=0,kt=0,dt=0,gt=0,p=0,ni=0,ti=0,ii=0,ri=0,ui=0,fi=0,ei=0,oi=0,si=0,hi=0,ci=0,w=0,li=0,ai=0,vi=0,yi=0,b=0,pi=0,wi=0,bi=0,c=0,ki=0,s=0,di=0;di=u;k=t+8|0;d=r[k>>2]|0;st=(n|0)==(d|0);n:do if(st)wt=t+4|0,ei=r[wt>>2]|0,yi=(ei|0)==(i|0),yi&&(b=t+28|0,pi=r[b>>2]|0,wi=(pi|0)==1,wi||(r[b>>2]=e));else{if(bi=r[t>>2]|0,g=(n|0)==(bi|0),!g){ci=n+8|0;w=r[ci>>2]|0;li=r[w>>2]|0;ai=li+24|0;vi=r[ai>>2]|0;bt[vi&3](w,t,i,e,o);break}if(nt=t+16|0,tt=r[nt>>2]|0,it=(tt|0)==(i|0),!it&&(l=t+20|0,rt=r[l>>2]|0,ut=(rt|0)==(i|0),!ut)){if(ot=t+32|0,r[ot>>2]=e,h=t+44|0,ht=r[h>>2]|0,ct=(ht|0)==4,ct)break;a=t+52|0;f[a>>0]=0;v=t+53|0;f[v>>0]=0;at=n+8|0;y=r[at>>2]|0;vt=r[y>>2]|0;yt=vt+20|0;pt=r[yt>>2]|0;lt[pt&3](y,t,i,i,1,o);kt=f[v>>0]|0;dt=kt<<24>>24==0;dt?(c=0,s=13):(gt=f[a>>0]|0,ki=gt<<24>>24==0,ki&&(c=1,s=13));do if((s|0)==13){if(r[l>>2]=i,p=t+40|0,ni=r[p>>2]|0,ti=ni+1|0,r[p>>2]=ti,ii=t+36|0,ri=r[ii>>2]|0,ui=(ri|0)==1,ui)if(fi=t+24|0,oi=r[fi>>2]|0,si=(oi|0)==2,si){if(hi=t+54|0,f[hi>>0]=1,c)break}else s=16;else s=16;if((s|0)==16&&c)break;r[h>>2]=4;break n}while(0);r[h>>2]=3;break}ft=(e|0)==1;ft&&(et=t+32|0,r[et>>2]=1)}while(0);return}function gf(n,t,i,e,o){n=n|0;t=t|0;i=i|0;e=e|0;o=o|0;var l=0,a=0,v=0,y=0,p=0,w=0,s=0,b=0,k=0,d=0,g=0,nt=0,tt=0,h=0,it=0,rt=0,ut=0,ft=0,et=0,ot=0,st=0,ht=0,ct=0,lt=0,at=0,vt=0,yt=0,c=0,pt=0,wt=0,bt=0,kt=0;kt=u;l=t+8|0;a=r[l>>2]|0;tt=(n|0)==(a|0);do if(tt)lt=t+4|0,vt=r[lt>>2]|0,yt=(vt|0)==(i|0),yt&&(c=t+28|0,pt=r[c>>2]|0,wt=(pt|0)==1,wt||(r[c>>2]=e));else if(bt=r[t>>2]|0,v=(n|0)==(bt|0),v){if(y=t+16|0,p=r[y>>2]|0,w=(p|0)==(i|0),!w&&(s=t+20|0,b=r[s>>2]|0,k=(b|0)==(i|0),!k)){nt=t+32|0;r[nt>>2]=e;r[s>>2]=i;h=t+40|0;it=r[h>>2]|0;rt=it+1|0;r[h>>2]=rt;ut=t+36|0;ft=r[ut>>2]|0;et=(ft|0)==1;et&&(ot=t+24|0,st=r[ot>>2]|0,ht=(st|0)==2,ht&&(ct=t+54|0,f[ct>>0]=1));at=t+44|0;r[at>>2]=4;break}d=(e|0)==1;d&&(g=t+32|0,r[g>>2]=1)}while(0);return}function ne(n,t,i,f,e,o){n=n|0;t=t|0;i=i|0;f=f|0;e=e|0;o=o|0;var h=0,c=0,l=0,a=0,s=0,v=0,y=0,p=0,w=0;w=u;h=t+8|0;c=r[h>>2]|0;l=(n|0)==(c|0);l?bi(0,t,i,f,e):(a=n+8|0,s=r[a>>2]|0,v=r[s>>2]|0,y=v+20|0,p=r[y>>2]|0,lt[p&3](s,t,i,f,e,o));return}function te(n,t,i,f,e,o){n=n|0;t=t|0;i=i|0;f=f|0;e=e|0;o=o|0;var s=0,h=0,c=0,l=0;l=u;s=t+8|0;h=r[s>>2]|0;c=(n|0)==(h|0);c&&bi(0,t,i,f,e);return}function ie(n,t,i){n=n|0;t=t|0;i=i|0;var s=0,h=0,c=0,l=0,e=0,a=0,v=0,f=0,o=0;return o=u,u=u+16|0,f=o,s=r[i>>2]|0,r[f>>2]=s,h=r[n>>2]|0,c=h+16|0,l=r[c>>2]|0,e=ct[l&7](n,t,f)|0,a=e&1,e&&(v=r[f>>2]|0,r[i>>2]=v),u=o,a|0}function re(n){n=n|0;var i=0,r=0,f=0,t=0,e=0,o=0;return o=u,i=(n|0)==0,i?t=0:(r=wi(n,16,64,0)|0,e=(r|0)!=0,t=e),f=t&1,f|0}function vt(n){n=n|0;var vu=0,os=0,ss=0,hs=0,cs=0,ls=0,yg=0,pg=0,wg=0,bg=0,kg=0,dg=0,as=0,gg=0,nn=0,tn=0,rn=0,un=0,vs=0,ys=0,ps=0,ws=0,bs=0,ks=0,fn=0,en=0,on=0,sn=0,hn=0,cn=0,ln=0,an=0,yu=0,vn=0,yn=0,pn=0,wn=0,bn=0,kn=0,a=0,dn=0,gn=0,ntt=0,ttt=0,itt=0,rtt=0,utt=0,ftt=0,ett=0,ott=0,stt=0,htt=0,ctt=0,ltt=0,att=0,vtt=0,ytt=0,ptt=0,wtt=0,btt=0,ktt=0,dtt=0,gtt=0,nit=0,tit=0,iit=0,rit=0,uit=0,fit=0,eit=0,oit=0,sit=0,hit=0,cit=0,lit=0,ait=0,vit=0,yit=0,pit=0,wit=0,bit=0,kit=0,dit=0,git=0,nrt=0,trt=0,irt=0,rrt=0,pu=0,urt=0,frt=0,ert=0,ort=0,srt=0,hrt=0,crt=0,lrt=0,art=0,vrt=0,yrt=0,prt=0,ds=0,wrt=0,brt=0,krt=0,drt=0,grt=0,nut=0,tut=0,iut=0,rut=0,uut=0,fut=0,eut=0,out=0,sut=0,hut=0,gs=0,cut=0,lut=0,aut=0,vut=0,yut=0,put=0,wut=0,but=0,kut=0,dut=0,nh=0,gut=0,nft=0,tft=0,th=0,ift=0,rft=0,uft=0,fft=0,eft=0,wu=0,oft=0,sft=0,hft=0,ih=0,rh=0,cft=0,lft=0,aft=0,vft=0,yft=0,pft=0,wft=0,bu=0,bft=0,kft=0,dft=0,gft=0,net=0,tet=0,iet=0,ret=0,uet=0,fet=0,eet=0,oet=0,pi=0,set=0,het=0,cet=0,aet=0,uh=0,vet=0,yet=0,pet=0,wet=0,bet=0,ket=0,det=0,fh=0,ku=0,eh=0,get=0,not=0,tot=0,iot=0,rot=0,uot=0,fot=0,oh=0,eot=0,sh=0,wi=0,oot=0,sot=0,hot=0,du=0,cot=0,lot=0,aot=0,vot=0,yot=0,pot=0,wot=0,bot=0,hh=0,kot=0,ch=0,lh=0,dot=0,ah=0,got=0,vh=0,nst=0,yh=0,gu=0,tst=0,ph=0,ist=0,wh=0,rst=0,bh=0,ust=0,kh=0,fst=0,est=0,dh=0,ost=0,sst=0,nf=0,hst=0,cst=0,lst=0,ast=0,vst=0,gh=0,yst=0,nc=0,pst=0,tc=0,wst=0,bst=0,bi=0,kst=0,dst=0,ic=0,rc=0,tf=0,uc=0,gst=0,fc=0,nht=0,tht=0,ui=0,iht=0,ki=0,rht=0,uht=0,rf=0,di=0,fht=0,ec=0,eht=0,oht=0,oc=0,sht=0,hht=0,sc=0,hc=0,cht=0,cc=0,lc=0,ac=0,lht=0,vc=0,yc=0,aht=0,pc=0,wc=0,vht=0,yht=0,gi=0,pht=0,wht=0,bc=0,kc=0,bht=0,kht=0,dht=0,ght=0,nct=0,tct=0,ict=0,rct=0,uct=0,dc=0,fct=0,ect=0,oct=0,sct=0,gc=0,hct=0,cct=0,lct=0,act=0,vct=0,nr=0,yct=0,pct=0,wct=0,bct=0,kct=0,tr=0,dct=0,gct=0,nlt=0,tlt=0,ilt=0,rlt=0,ult=0,nl=0,flt=0,elt=0,tl=0,olt=0,slt=0,hlt=0,clt=0,llt=0,alt=0,vlt=0,ylt=0,il=0,plt=0,ir=0,rl=0,uf=0,wlt=0,ul=0,fl=0,el=0,blt=0,klt=0,dlt=0,ol=0,sl=0,glt=0,nat=0,tat=0,iat=0,rat=0,uat=0,fat=0,eat=0,hl=0,s=0,cl=0,oat=0,ll=0,al=0,ff=0,sat=0,hat=0,cat=0,lat=0,vl=0,yl=0,aat=0,vat=0,pl=0,yat=0,pat=0,wl=0,wat=0,bat=0,bl=0,kat=0,dat=0,gat=0,nvt=0,kl=0,tvt=0,ivt=0,rvt=0,uvt=0,fvt=0,evt=0,ovt=0,dl=0,svt=0,hvt=0,cvt=0,gl=0,lvt=0,avt=0,vvt=0,yvt=0,pvt=0,na=0,ef=0,wvt=0,bvt=0,kvt=0,dvt=0,of=0,gvt=0,nyt=0,sf=0,tyt=0,iyt=0,ryt=0,uyt=0,fyt=0,eyt=0,oyt=0,syt=0,ta=0,hyt=0,cyt=0,hf=0,lyt=0,ayt=0,vyt=0,ia=0,yyt=0,ra=0,ua=0,fa=0,pyt=0,ea=0,wyt=0,oa=0,byt=0,sa=0,kyt=0,ha=0,dyt=0,gyt=0,ca=0,npt=0,la=0,tpt=0,aa=0,ipt=0,rpt=0,upt=0,fpt=0,ept=0,opt=0,spt=0,hpt=0,cpt=0,lpt=0,va=0,ya=0,apt=0,pa=0,vpt=0,ypt=0,wa=0,ba=0,ppt=0,wpt=0,bpt=0,kpt=0,dpt=0,cf=0,gpt=0,nt=0,nwt=0,twt=0,iwt=0,fi=0,rwt=0,rr=0,uwt=0,fwt=0,lf=0,ewt=0,ka=0,owt=0,swt=0,hwt=0,da=0,cwt=0,lwt=0,ga=0,nv=0,awt=0,tv=0,iv=0,vwt=0,ywt=0,rv=0,uv=0,pwt=0,fv=0,ev=0,wwt=0,bwt=0,kwt=0,dwt=0,ov=0,sv=0,hv=0,gwt=0,nbt=0,tbt=0,ibt=0,rbt=0,ubt=0,fbt=0,ebt=0,cv=0,obt=0,sbt=0,hbt=0,cbt=0,lbt=0,lv=0,abt=0,vbt=0,ybt=0,ur=0,pbt=0,v=0,wbt=0,bbt=0,kbt=0,dbt=0,gbt=0,fr=0,nkt=0,tkt=0,ikt=0,rkt=0,ukt=0,av=0,fkt=0,vv=0,ekt=0,okt=0,yv=0,skt=0,hkt=0,ckt=0,lkt=0,akt=0,vkt=0,ykt=0,pkt=0,pv=0,wkt=0,af=0,wv=0,bv=0,kv=0,bkt=0,kkt=0,dkt=0,gkt=0,dv=0,gv=0,ndt=0,tdt=0,idt=0,rdt=0,udt=0,vf=0,fdt=0,ny=0,edt=0,odt=0,sdt=0,ty=0,iy=0,hdt=0,cdt=0,ry=0,ldt=0,uy=0,adt=0,vdt=0,ydt=0,fy=0,pdt=0,wdt=0,bdt=0,kdt=0,ey=0,ddt=0,gdt=0,oy=0,ngt=0,tgt=0,igt=0,yf=0,rgt=0,ugt=0,fgt=0,sy=0,hy=0,egt=0,cy=0,ogt=0,sgt=0,hgt=0,cgt=0,lgt=0,pf=0,agt=0,vgt=0,ygt=0,pgt=0,wgt=0,bgt=0,kgt=0,dgt=0,ggt=0,nnt=0,tnt=0,int=0,er=0,rnt=0,unt=0,ly=0,fnt=0,ent=0,ay=0,ont=0,snt=0,hnt=0,cnt=0,lnt=0,ant=0,vy=0,or=0,vnt=0,wf=0,yy=0,ynt=0,pnt=0,wnt=0,bnt=0,knt=0,dnt=0,gnt=0,ei=0,py=0,nti=0,sr=0,et=0,tti=0,iti=0,rti=0,uti=0,fti=0,eti=0,oti=0,sti=0,hti=0,cti=0,wy=0,lti=0,ati=0,vti=0,by=0,yti=0,ky=0,hr=0,dy=0,pti=0,wti=0,bti=0,kti=0,dti=0,gti=0,nii=0,tii=0,iii=0,gy=0,rii=0,np=0,tp=0,ip=0,wt=0,uii=0,rp=0,fii=0,up=0,fp=0,eii=0,ep=0,oii=0,sii=0,hii=0,cii=0,bf=0,lii=0,op=0,aii=0,sp=0,vii=0,yii=0,pii=0,wii=0,bii=0,hp=0,kii=0,cr=0,dii=0,kf=0,cp=0,lp=0,ap=0,gii=0,nri=0,tri=0,iri=0,rri=0,uri=0,fri=0,vp=0,yp=0,eri=0,ori=0,sri=0,pp=0,hri=0,cri=0,lri=0,wp=0,bp=0,ari=0,vri=0,lr=0,kp=0,yri=0,ar=0,pri=0,wri=0,bri=0,dp=0,kri=0,dri=0,gri=0,nui=0,df=0,tui=0,iui=0,gp=0,rui=0,uui=0,fui=0,gf=0,eui=0,oui=0,sui=0,hui=0,nw=0,cui=0,lui=0,aui=0,vui=0,vr=0,ne=0,yui=0,pui=0,wui=0,bui=0,kui=0,dui=0,tw=0,gui=0,iw=0,nfi=0,te=0,tfi=0,ifi=0,i=0,rfi=0,ufi=0,rw=0,ffi=0,efi=0,ofi=0,ie=0,uw=0,sfi=0,hfi=0,fw=0,cfi=0,re=0,lfi=0,ew=0,afi=0,vfi=0,yfi=0,pfi=0,ue=0,wfi=0,ow=0,bfi=0,sw=0,kfi=0,dfi=0,gfi=0,hw=0,cw=0,lw=0,nei=0,tei=0,iei=0,aw=0,vw=0,rei=0,uei=0,fei=0,eei=0,oei=0,sei=0,hei=0,cei=0,lei=0,yw=0,pw=0,aei=0,ww=0,vei=0,yei=0,pei=0,wei=0,fe=0,bei=0,bw=0,kei=0,bt=0,dei=0,gei=0,noi=0,kw=0,toi=0,ioi=0,roi=0,uoi=0,foi=0,dw=0,gw=0,eoi=0,ooi=0,soi=0,hoi=0,coi=0,nb=0,loi=0,aoi=0,voi=0,tb=0,yr=0,pr=0,yoi=0,poi=0,woi=0,boi=0,wr=0,koi=0,doi=0,ib=0,goi=0,nsi=0,tsi=0,isi=0,rsi=0,tt=0,it=0,usi=0,fsi=0,esi=0,d=0,br=0,osi=0,ssi=0,hsi=0,csi=0,lsi=0,rb=0,asi=0,vsi=0,ysi=0,psi=0,wsi=0,kr=0,bsi=0,ksi=0,dsi=0,gsi=0,nhi=0,dr=0,thi=0,ihi=0,ub=0,fb=0,rhi=0,uhi=0,fhi=0,kt=0,ehi=0,dt=0,ohi=0,eb=0,shi=0,hhi=0,oi=0,chi=0,lhi=0,ahi=0,vhi=0,yhi=0,phi=0,whi=0,bhi=0,khi=0,dhi=0,ghi=0,ob=0,nci=0,tci=0,ici=0,rci=0,uci=0,si=0,fci=0,gr=0,eci=0,oci=0,ee=0,sb=0,sci=0,hb=0,hci=0,cci=0,cb=0,lci=0,aci=0,lb=0,ab=0,vci=0,yci=0,vb=0,yb=0,pci=0,pb=0,wb=0,wci=0,bb=0,kb=0,bci=0,kci=0,dci=0,gci=0,nli=0,db=0,gb=0,tli=0,ili=0,rli=0,uli=0,fli=0,eli=0,oli=0,nk=0,sli=0,hli=0,tk=0,cli=0,lli=0,ali=0,vli=0,ik=0,yli=0,pli=0,oe=0,wli=0,nu=0,bli=0,kli=0,dli=0,gli=0,nai=0,tu=0,tai=0,iai=0,rai=0,uai=0,fai=0,eai=0,oai=0,sai=0,rk=0,hai=0,cai=0,lai=0,aai=0,vai=0,yai=0,uk=0,pai=0,he=0,fk=0,ek=0,ok=0,wai=0,bai=0,kai=0,dai=0,sk=0,hk=0,gai=0,nvi=0,tvi=0,ivi=0,rvi=0,ce=0,uvi=0,fvi=0,evi=0,ovi=0,svi=0,ck=0,lk=0,hvi=0,cvi=0,ak=0,lvi=0,vk=0,avi=0,vvi=0,yvi=0,yk=0,pvi=0,wvi=0,bvi=0,kvi=0,pk=0,dvi=0,gvi=0,nyi=0,tyi=0,iyi=0,ryi=0,le=0,uyi=0,fyi=0,eyi=0,wk=0,bk=0,oyi=0,syi=0,hyi=0,cyi=0,lyi=0,ayi=0,vyi=0,ae=0,yyi=0,pyi=0,wyi=0,byi=0,kyi=0,ve=0,dyi=0,gyi=0,npi=0,tpi=0,ipi=0,rpi=0,iu=0,upi=0,fpi=0,epi=0,opi=0,ru=0,spi=0,kk=0,hpi=0,cpi=0,lpi=0,api=0,vpi=0,ypi=0,dk=0,ye=0,gk=0,nd=0,ppi=0,wpi=0,bpi=0,kpi=0,dpi=0,gpi=0,nwi=0,pe=0,twi=0,we=0,iwi=0,td=0,id=0,rwi=0,uwi=0,fwi=0,ewi=0,rd=0,owi=0,swi=0,ud=0,hwi=0,cwi=0,lwi=0,fd=0,ed=0,awi=0,ot=0,hi=0,vwi=0,ywi=0,od=0,sd=0,pwi=0,wwi=0,bwi=0,kwi=0,be=0,dwi=0,hd=0,gwi=0,nbi=0,cd=0,tbi=0,ibi=0,ke=0,ld=0,rbi=0,ubi=0,ad=0,de=0,fbi=0,ebi=0,obi=0,sbi=0,hbi=0,cbi=0,ut=0,lbi=0,abi=0,vbi=0,ybi=0,vd=0,pbi=0,wbi=0,ge=0,yd=0,pd=0,wd=0,bbi=0,kbi=0,dbi=0,bd=0,kd=0,gbi=0,nki=0,tki=0,iki=0,rki=0,uki=0,no=0,fki=0,eki=0,oki=0,ski=0,dd=0,gd=0,ng=0,hki=0,cki=0,tg=0,lki=0,ig=0,aki=0,vki=0,rg=0,yki=0,to=0,io=0,ro=0,uo=0,fo=0,st=0,ht=0,ct=0,eo=0,oo=0,so=0,gt=0,ni=0,pki=0,wki=0,ti=0,bki=0,p=0,b=0,k=0,uu=0,fu=0,ug=0,fg=0,eu=0,eg=0,ou=0,su=0,hu=0,ho=0,kki=0,co=0,dki=0,lo=0,gki=0,cu=0,ndi=0,tdi=0,idi=0,rdi=0,ao=0,ii=0,rt=0,h=0,udi=0,fdi=0,edi=0,og=0,odi=0,sdi=0,hdi=0,cdi=0,ldi=0,adi=0,vdi=0,ydi=0,pdi=0,wdi=0,bdi=0,g=0,lu=0,ri=0,vo=0,yo=0,po=0,y=0,ci=0,sg=0,hg=0,wo=0,li=0,ai=0,vi=0,kdi=0,yi=0,cg=0,lg=0,lt=0,ft=0,bo=0,ko=0,at=0,go=0,ns=0,ts=0,vt=0,t=0,is=0,pt=0,ag=0,c=0,rs=0,l=0,vg=0,us=0,fs=0,f=0,es=0,au=0,o=0,ddi=0;ddi=u;but=n>>>0<245;do if(but){if(kut=n>>>0<11,lct=n+11|0,oyt=lct&-8,v=kut?16:oyt,or=v>>>3,df=r[56]|0,yr=df>>>or,oli=yr&3,opi=(oli|0)==0,!opi){dut=yr&1;bot=dut^1;gu=bot+or|0;dh=gu<<1;nc=264+(dh<<2)|0;ott=dh+2|0;uc=264+(ott<<2)|0;di=r[uc>>2]|0;cc=di+8|0;gi=r[cc>>2]|0;ict=(nc|0)==(gi|0);do if(ict)act=1<<gu,nlt=act^-1,hlt=df&nlt,r[56]=hlt;else{if(wlt=r[60]|0,tat=gi>>>0<wlt>>>0,!tat&&(al=gi+12|0,yat=r[al>>2]|0,tvt=(yat|0)==(di|0),tvt)){r[al>>2]=nc;r[uc>>2]=gi;break}e()}while(0);gl=gu<<3;dvt=gl|3;syt=di+4|0;r[syt>>2]=dvt;att=gl|4;ua=di+att|0;gyt=r[ua>>2]|0;opt=gyt|1;r[ua>>2]=opt;rt=cc;break}if(wa=r[58]|0,twt=v>>>0>wa>>>0,twt){if(swt=(yr|0)==0,!swt){ywt=yr<<or;sv=2<<or;obt=0-sv|0;wbt=sv|obt;av=ywt&wbt;vkt=0-av|0;dkt=av&vkt;ny=dkt+-1|0;adt=ny>>>12;oy=adt&16;cy=ny>>>oy;wgt=cy>>>5;ly=wgt&8;vnt=ly|oy;py=cy>>>ly;sti=py>>>2;dy=sti&4;rii=vnt|dy;ep=py>>>dy;yii=ep>>>1;ap=yii&2;ori=rii|ap;kp=ep>>>ap;tui=kp>>>1;nw=tui&1;kui=ori|nw;ufi=kp>>>nw;re=kui+ufi|0;sw=re<<1;vw=264+(sw<<2)|0;grt=sw+2|0;pw=264+(grt<<2)|0;bt=r[pw>>2]|0;gw=bt+8|0;pr=r[gw>>2]|0;tsi=(vw|0)==(pr|0);do if(tsi)ssi=1<<re,bsi=ssi^-1,uhi=df&bsi,r[56]=uhi,ve=wa;else{if(lhi=r[60]|0,nci=pr>>>0<lhi>>>0,!nci&&(sb=pr+12|0,yci=r[sb>>2]|0,dci=(yci|0)==(bt|0),dci)){r[sb>>2]=vw;r[pw>>2]=pr;gg=r[58]|0;ve=gg;break}e()}while(0);nk=re<<3;oe=nk-v|0;rai=v|3;vai=bt+4|0;r[vai>>2]=rai;dai=bt+v|0;evi=oe|1;sut=v|4;vvi=bt+sut|0;r[vvi>>2]=evi;tyi=bt+nk|0;r[tyi>>2]=oe;hyi=(ve|0)==0;hyi||(ru=r[61]|0,gk=ve>>>3,we=gk<<1,ud=264+(we<<2)|0,od=r[56]|0,cd=1<<gk,obi=od&cd,wbi=(obi|0)==0,wbi?(nki=od|cd,r[56]=nki,fn=we+2|0,en=264+(fn<<2)|0,ks=en,ro=ud):(aut=we+2|0,gd=264+(aut<<2)|0,nh=r[gd>>2]|0,oft=r[60]|0,wft=nh>>>0<oft>>>0,wft?e():(ks=gd,ro=nh)),r[ks>>2]=ru,fet=ro+12|0,r[fet>>2]=ru,pet=ru+8|0,r[pet>>2]=ro,iot=ru+12|0,r[iot>>2]=ud);r[58]=oe;r[61]=dai;rt=gw;break}if(du=r[57]|0,yot=(du|0)==0,yot)h=v,o=154;else{for(pot=0-du|0,wot=du&pot,hh=wot+-1|0,kot=hh>>>12,ch=kot&16,lh=hh>>>ch,dot=lh>>>5,ah=dot&8,got=ah|ch,vh=lh>>>ah,nst=vh>>>2,yh=nst&4,tst=got|yh,ph=vh>>>yh,ist=ph>>>1,wh=ist&2,rst=tst|wh,bh=ph>>>wh,ust=bh>>>1,kh=ust&1,fst=rst|kh,est=bh>>>kh,ost=fst+est|0,sst=528+(ost<<2)|0,nf=r[sst>>2]|0,hst=nf+4|0,cst=r[hst>>2]|0,lst=cst&-8,ast=lst-v|0,lu=ast,ko=nf,rs=nf;;){if(vst=ko+16|0,gh=r[vst>>2]|0,yst=(gh|0)==0,yst)if(pst=ko+20|0,tc=r[pst>>2]|0,wst=(tc|0)==0,wst){ri=lu;l=rs;break}else bi=tc;else bi=gh;bst=bi+4|0;kst=r[bst>>2]|0;dst=kst&-8;ic=dst-v|0;rc=ic>>>0<lu>>>0;an=rc?ic:lu;wut=rc?bi:rs;lu=an;ko=bi;rs=wut}if(tf=r[60]|0,gst=l>>>0<tf>>>0,!gst&&(fc=l+v|0,nht=l>>>0<fc>>>0,nht)){tht=l+24|0;ui=r[tht>>2]|0;iht=l+12|0;ki=r[iht>>2]|0;rht=(ki|0)==(l|0);do if(rht){if(sc=l+20|0,hc=r[sc>>2]|0,cht=(hc|0)==0,cht)if(lc=l+16|0,ac=r[lc>>2]|0,lht=(ac|0)==0,lht){p=0;break}else gt=ac,uu=lc;else gt=hc,uu=sc;for(;;){if(vc=gt+20|0,yc=r[vc>>2]|0,aht=(yc|0)==0,!aht){gt=yc;uu=vc;continue}if(pc=gt+16|0,wc=r[pc>>2]|0,vht=(wc|0)==0,vht){wki=gt;fg=uu;break}else gt=wc,uu=pc}if(yht=fg>>>0<tf>>>0,yht)e();else{r[fg>>2]=0;p=wki;break}}else{if(uht=l+8|0,rf=r[uht>>2]|0,fht=rf>>>0<tf>>>0,!fht&&(ec=rf+12|0,eht=r[ec>>2]|0,oht=(eht|0)==(l|0),oht&&(oc=ki+8|0,sht=r[oc>>2]|0,hht=(sht|0)==(l|0),hht))){r[ec>>2]=ki;r[oc>>2]=rf;p=ki;break}e()}while(0);pht=(ui|0)==0;do if(!pht){if(wht=l+28|0,bc=r[wht>>2]|0,kc=528+(bc<<2)|0,bht=r[kc>>2]|0,kht=(l|0)==(bht|0),kht){if(r[kc>>2]=p,ndi=(p|0)==0,ndi){dht=1<<bc;ght=dht^-1;nct=r[57]|0;tct=nct&ght;r[57]=tct;break}}else if(rct=r[60]|0,uct=ui>>>0<rct>>>0,uct&&e(),dc=ui+16|0,fct=r[dc>>2]|0,ect=(fct|0)==(l|0),ect?r[dc>>2]=p:(oct=ui+20|0,r[oct>>2]=p),sct=(p|0)==0,sct)break;gc=r[60]|0;hct=p>>>0<gc>>>0;hct&&e();cct=p+24|0;r[cct>>2]=ui;vct=l+16|0;nr=r[vct>>2]|0;yct=(nr|0)==0;do if(!yct)if(pct=nr>>>0<gc>>>0,pct)e();else{wct=p+16|0;r[wct>>2]=nr;bct=nr+24|0;r[bct>>2]=p;break}while(0);if(kct=l+20|0,tr=r[kct>>2]|0,dct=(tr|0)==0,!dct)if(gct=r[60]|0,tlt=tr>>>0<gct>>>0,tlt)e();else{ilt=p+20|0;r[ilt>>2]=tr;rlt=tr+24|0;r[rlt>>2]=p;break}}while(0);ult=ri>>>0<16;ult?(nl=ri+v|0,flt=nl|3,elt=l+4|0,r[elt>>2]=flt,nut=nl+4|0,tl=l+nut|0,olt=r[tl>>2]|0,slt=olt|1,r[tl>>2]=slt):(clt=v|3,llt=l+4|0,r[llt>>2]=clt,alt=ri|1,ntt=v|4,vlt=l+ntt|0,r[vlt>>2]=alt,itt=ri+v|0,ylt=l+itt|0,r[ylt>>2]=ri,il=r[58]|0,plt=(il|0)==0,plt||(ir=r[61]|0,rl=il>>>3,uf=rl<<1,ul=264+(uf<<2)|0,fl=r[56]|0,el=1<<rl,blt=fl&el,klt=(blt|0)==0,klt?(dlt=fl|el,r[56]=dlt,nn=uf+2|0,ln=264+(nn<<2)|0,ws=ln,io=ul):(vrt=uf+2|0,ol=264+(vrt<<2)|0,sl=r[ol>>2]|0,glt=r[60]|0,nat=sl>>>0<glt>>>0,nat?e():(ws=ol,io=sl)),r[ws>>2]=ir,iat=io+12|0,r[iat>>2]=ir,rat=ir+8|0,r[rat>>2]=io,uat=ir+12|0,r[uat>>2]=ul),r[58]=ri,r[61]=fc);fat=l+8|0;rt=fat;break}e()}}else h=v,o=154}else if(eat=n>>>0>4294967231,eat)h=-1,o=154;else if(hl=n+11|0,s=hl&-8,cl=r[57]|0,oat=(cl|0)==0,oat)h=s,o=154;else{ll=0-s|0;ff=hl>>>8;sat=(ff|0)==0;sat?ii=0:(hat=s>>>0>16777215,hat?ii=31:(cat=ff+1048320|0,lat=cat>>>16,vl=lat&8,yl=ff<<vl,aat=yl+520192|0,vat=aat>>>16,pl=vat&4,pat=pl|vl,wl=yl<<pl,wat=wl+245760|0,bat=wat>>>16,bl=bat&2,kat=pat|bl,dat=14-kat|0,gat=wl<<bl,nvt=gat>>>15,kl=dat+nvt|0,ivt=kl<<1,rvt=kl+7|0,uvt=s>>>rvt,fvt=uvt&1,evt=fvt|ivt,ii=evt));ovt=528+(ii<<2)|0;dl=r[ovt>>2]|0;svt=(dl|0)==0;n:do if(svt)po=ll,go=0,fs=0,o=86;else for(hvt=(ii|0)==31,cvt=ii>>>1,lvt=25-cvt|0,avt=hvt?0:lvt,vvt=s<<avt,vo=ll,sg=0,wo=vvt,at=dl,vg=0;;){if(yvt=at+4|0,pvt=r[yvt>>2]|0,na=pvt&-8,ef=na-s|0,wvt=ef>>>0<vo>>>0,wvt)if(bvt=(na|0)==(s|0),bvt){ci=ef;vt=at;au=at;o=90;break n}else yo=ef,us=at;else yo=vo,us=vg;if(kvt=at+20|0,of=r[kvt>>2]|0,gvt=wo>>>31,nyt=(at+16|0)+(gvt<<2)|0,sf=r[nyt>>2]|0,tyt=(of|0)==0,iyt=(of|0)==(sf|0),cdi=tyt|iyt,hg=cdi?sg:of,ryt=(sf|0)==0,uyt=wo<<1,ryt){po=yo;go=hg;fs=us;o=86;break}else vo=yo,sg=hg,wo=uyt,at=sf,vg=us}while(0);if((o|0)==86){if(fyt=(go|0)==0,eyt=(fs|0)==0,odi=fyt&eyt,odi){if(ta=2<<ii,hyt=0-ta|0,cyt=ta|hyt,hf=cl&cyt,lyt=(hf|0)==0,lyt){h=s;o=154;break}ayt=0-hf|0;vyt=hf&ayt;ia=vyt+-1|0;yyt=ia>>>12;ra=yyt&16;fa=ia>>>ra;pyt=fa>>>5;ea=pyt&8;wyt=ea|ra;oa=fa>>>ea;byt=oa>>>2;sa=byt&4;kyt=wyt|sa;ha=oa>>>sa;dyt=ha>>>1;ca=dyt&2;npt=kyt|ca;la=ha>>>ca;tpt=la>>>1;aa=tpt&1;ipt=npt|aa;rpt=la>>>aa;upt=ipt+rpt|0;fpt=528+(upt<<2)|0;ept=r[fpt>>2]|0;ns=ept;es=0}else ns=go,es=fs;spt=(ns|0)==0;spt?(y=po,f=es):(ci=po,vt=ns,au=es,o=90)}if((o|0)==90)for(;;){if(o=0,hpt=vt+4|0,cpt=r[hpt>>2]|0,lpt=cpt&-8,va=lpt-s|0,ya=va>>>0<ci>>>0,yu=ya?va:ci,ts=ya?vt:au,apt=vt+16|0,pa=r[apt>>2]|0,vpt=(pa|0)==0,!vpt){ci=yu;vt=pa;au=ts;o=90;continue}if(ypt=vt+20|0,ba=r[ypt>>2]|0,ppt=(ba|0)==0,ppt){y=yu;f=ts;break}else ci=yu,vt=ba,au=ts,o=90}if(wpt=(f|0)==0,wpt)h=s,o=154;else if(bpt=r[58]|0,kpt=bpt-s|0,dpt=y>>>0<kpt>>>0,dpt){if(cf=r[60]|0,gpt=f>>>0<cf>>>0,!gpt&&(nt=f+s|0,nwt=f>>>0<nt>>>0,nwt)){iwt=f+24|0;fi=r[iwt>>2]|0;rwt=f+12|0;rr=r[rwt>>2]|0;uwt=(rr|0)==(f|0);do if(uwt){if(ga=f+20|0,nv=r[ga>>2]|0,awt=(nv|0)==0,awt)if(tv=f+16|0,iv=r[tv>>2]|0,vwt=(iv|0)==0,vwt){k=0;break}else ti=iv,eu=tv;else ti=nv,eu=ga;for(;;){if(rv=ti+20|0,uv=r[rv>>2]|0,pwt=(uv|0)==0,!pwt){ti=uv;eu=rv;continue}if(fv=ti+16|0,ev=r[fv>>2]|0,wwt=(ev|0)==0,wwt){bki=ti;eg=eu;break}else ti=ev,eu=fv}if(bwt=eg>>>0<cf>>>0,bwt)e();else{r[eg>>2]=0;k=bki;break}}else{if(fwt=f+8|0,lf=r[fwt>>2]|0,ewt=lf>>>0<cf>>>0,!ewt&&(ka=lf+12|0,owt=r[ka>>2]|0,hwt=(owt|0)==(f|0),hwt&&(da=rr+8|0,cwt=r[da>>2]|0,lwt=(cwt|0)==(f|0),lwt))){r[ka>>2]=rr;r[da>>2]=lf;k=rr;break}e()}while(0);kwt=(fi|0)==0;do if(!kwt){if(dwt=f+28|0,ov=r[dwt>>2]|0,hv=528+(ov<<2)|0,gwt=r[hv>>2]|0,nbt=(f|0)==(gwt|0),nbt){if(r[hv>>2]=k,idi=(k|0)==0,idi){tbt=1<<ov;ibt=tbt^-1;rbt=r[57]|0;ubt=rbt&ibt;r[57]=ubt;break}}else if(fbt=r[60]|0,ebt=fi>>>0<fbt>>>0,ebt&&e(),cv=fi+16|0,sbt=r[cv>>2]|0,hbt=(sbt|0)==(f|0),hbt?r[cv>>2]=k:(cbt=fi+20|0,r[cbt>>2]=k),lbt=(k|0)==0,lbt)break;lv=r[60]|0;abt=k>>>0<lv>>>0;abt&&e();vbt=k+24|0;r[vbt>>2]=fi;ybt=f+16|0;ur=r[ybt>>2]|0;pbt=(ur|0)==0;do if(!pbt)if(bbt=ur>>>0<lv>>>0,bbt)e();else{kbt=k+16|0;r[kbt>>2]=ur;dbt=ur+24|0;r[dbt>>2]=k;break}while(0);if(gbt=f+20|0,fr=r[gbt>>2]|0,nkt=(fr|0)==0,!nkt)if(tkt=r[60]|0,ikt=fr>>>0<tkt>>>0,ikt)e();else{rkt=k+20|0;r[rkt>>2]=fr;ukt=fr+24|0;r[ukt>>2]=k;break}}while(0);fkt=y>>>0<16;n:do if(fkt)vv=y+s|0,ekt=vv|3,okt=f+4|0,r[okt>>2]=ekt,bit=vv+4|0,yv=f+bit|0,skt=r[yv>>2]|0,hkt=skt|1,r[yv>>2]=hkt;else{if(ckt=s|3,lkt=f+4|0,r[lkt>>2]=ckt,akt=y|1,dn=s|4,ykt=f+dn|0,r[ykt>>2]=akt,ett=y+s|0,pkt=f+ett|0,r[pkt>>2]=y,pv=y>>>3,wkt=y>>>0<256,wkt){af=pv<<1;wv=264+(af<<2)|0;bv=r[56]|0;kv=1<<pv;bkt=bv&kv;kkt=(bkt|0)==0;kkt?(gkt=bv|kv,r[56]=gkt,un=af+2|0,sn=264+(un<<2)|0,ps=sn,fo=wv):(pit=af+2|0,dv=264+(pit<<2)|0,gv=r[dv>>2]|0,ndt=r[60]|0,tdt=gv>>>0<ndt>>>0,tdt?e():(ps=dv,fo=gv));r[ps>>2]=nt;idt=fo+12|0;r[idt>>2]=nt;lit=s+8|0;rdt=f+lit|0;r[rdt>>2]=fo;vit=s+12|0;udt=f+vit|0;r[udt>>2]=wv;break}if(vf=y>>>8,fdt=(vf|0)==0,fdt?ht=0:(edt=y>>>0>16777215,edt?ht=31:(odt=vf+1048320|0,sdt=odt>>>16,ty=sdt&8,iy=vf<<ty,hdt=iy+520192|0,cdt=hdt>>>16,ry=cdt&4,ldt=ry|ty,uy=iy<<ry,vdt=uy+245760|0,ydt=vdt>>>16,fy=ydt&2,pdt=ldt|fy,wdt=14-pdt|0,bdt=uy<<fy,kdt=bdt>>>15,ey=wdt+kdt|0,ddt=ey<<1,gdt=ey+7|0,ngt=y>>>gdt,tgt=ngt&1,igt=tgt|ddt,ht=igt)),yf=528+(ht<<2)|0,git=s+28|0,rgt=f+git|0,r[rgt>>2]=ht,yrt=s+16|0,ugt=f+yrt|0,iut=s+20|0,fgt=f+iut|0,r[fgt>>2]=0,r[ugt>>2]=0,sy=r[57]|0,hy=1<<ht,egt=sy&hy,ogt=(egt|0)==0,ogt){sgt=sy|hy;r[57]=sgt;r[yf>>2]=nt;eut=s+24|0;hgt=f+eut|0;r[hgt>>2]=yf;hut=s+12|0;cgt=f+hut|0;r[cgt>>2]=nt;cut=s+8|0;lgt=f+cut|0;r[lgt>>2]=nt;break}pf=r[yf>>2]|0;agt=pf+4|0;vgt=r[agt>>2]|0;ygt=vgt&-8;pgt=(ygt|0)==(y|0);t:do if(pgt)ou=pf;else{for(bgt=(ht|0)==31,kgt=ht>>>1,dgt=25-kgt|0,ggt=bgt?0:dgt,nnt=y<<ggt,eo=nnt,ho=pf;;){if(ent=eo>>>31,ay=(ho+16|0)+(ent<<2)|0,er=r[ay>>2]|0,ont=(er|0)==0,ont){as=ay;kki=ho;break}if(tnt=eo<<1,int=er+4|0,rnt=r[int>>2]|0,unt=rnt&-8,fnt=(unt|0)==(y|0),fnt){ou=er;break t}else eo=tnt,ho=er}if(snt=r[60]|0,hnt=as>>>0<snt>>>0,hnt)e();else{r[as>>2]=nt;ctt=s+24|0;cnt=f+ctt|0;r[cnt>>2]=kki;nit=s+12|0;lnt=f+nit|0;r[lnt>>2]=nt;sit=s+8|0;ant=f+sit|0;r[ant>>2]=nt;break n}}while(0);if(vy=ou+8|0,wf=r[vy>>2]|0,yy=r[60]|0,ynt=wf>>>0>=yy>>>0,udi=ou>>>0>=yy>>>0,pnt=ynt&udi,pnt){wnt=wf+12|0;r[wnt>>2]=nt;r[vy>>2]=nt;lut=s+8|0;bnt=f+lut|0;r[bnt>>2]=wf;vut=s+12|0;knt=f+vut|0;r[knt>>2]=ou;stt=s+24|0;dnt=f+stt|0;r[dnt>>2]=0;break}else e()}while(0);gnt=f+8|0;rt=gnt;break}e()}else h=s,o=154}while(0);n:do if((o|0)==154){if(ei=r[58]|0,nti=ei>>>0<h>>>0,!nti){sr=ei-h|0;et=r[61]|0;tti=sr>>>0>15;tti?(iti=et+h|0,r[61]=iti,r[58]=sr,rti=sr|1,dit=h+4|0,uti=et+dit|0,r[uti>>2]=rti,fti=et+ei|0,r[fti>>2]=sr,eti=h|3,oti=et+4|0,r[oti>>2]=eti):(r[58]=0,r[61]=0,hti=ei|3,cti=et+4|0,r[cti>>2]=hti,ttt=ei+4|0,wy=et+ttt|0,lti=r[wy>>2]|0,ati=lti|1,r[wy>>2]=ati);vti=et+8|0;rt=vti;break}if(by=r[59]|0,yti=by>>>0>h>>>0,yti){ky=by-h|0;r[59]=ky;hr=r[62]|0;pti=hr+h|0;r[62]=pti;wti=ky|1;vn=h+4|0;bti=hr+vn|0;r[bti>>2]=wti;kti=h|3;dti=hr+4|0;r[dti>>2]=kti;gti=hr+8|0;rt=gti;break}if(nii=r[174]|0,tii=(nii|0)==0,tii&&se(),iii=h+48|0,gy=r[176]|0,np=h+47|0,tp=gy+np|0,ip=0-gy|0,wt=tp&ip,uii=wt>>>0>h>>>0,uii){if(rp=r[166]|0,fii=(rp|0)==0,!fii&&(up=r[164]|0,fp=up+wt|0,eii=fp>>>0<=up>>>0,oii=fp>>>0>rp>>>0,hdi=eii|oii,hdi)){rt=0;break}sii=r[167]|0;hii=sii&4;cii=(hii|0)==0;t:do if(cii){bf=r[62]|0;lii=(bf|0)==0;i:do if(lii)o=172;else{for(li=672;;){if(op=r[li>>2]|0,aii=op>>>0>bf>>>0,!aii&&(sp=li+4|0,vii=r[sp>>2]|0,pii=op+vii|0,wii=pii>>>0>bf>>>0,wii)){kg=li;dg=sp;break}if(bii=li+8|0,hp=r[bii>>2]|0,kii=(hp|0)==0,kii){o=172;break i}else li=hp}if(ari=r[59]|0,vri=tp-ari|0,lr=vri&ip,yri=lr>>>0<2147483647,yri)if(ar=w(lr|0)|0,pri=r[kg>>2]|0,wri=r[dg>>2]|0,bri=pri+wri|0,dp=(ar|0)==(bri|0),vu=dp?lr:0,dp)if(kri=(ar|0)==-1,kri)pt=vu;else{t=ar;c=vu;o=192;break t}else cu=ar,ft=lr,is=vu,o=182;else pt=0}while(0);do if((o|0)==172)if(cr=w(0)|0,dii=(cr|0)==-1,dii)pt=0;else if(kf=cr,cp=r[175]|0,lp=cp+-1|0,gii=lp&kf,nri=(gii|0)==0,nri?lt=wt:(tri=lp+kf|0,iri=0-cp|0,rri=tri&iri,uri=wt-kf|0,fri=uri+rri|0,lt=fri),vp=r[164]|0,yp=vp+lt|0,eri=lt>>>0>h>>>0,sri=lt>>>0<2147483647,sdi=eri&sri,sdi){if(pp=r[166]|0,hri=(pp|0)==0,!hri&&(cri=yp>>>0<=vp>>>0,lri=yp>>>0>pp>>>0,ldi=cri|lri,ldi)){pt=0;break}if(wp=w(lt|0)|0,bp=(wp|0)==(cr|0),lg=bp?lt:0,bp){t=cr;c=lg;o=192;break t}else cu=wp,ft=lt,is=lg,o=182}else pt=0;while(0);i:do if((o|0)==182){dri=0-ft|0;gri=(cu|0)!=-1;nui=ft>>>0<2147483647;vdi=nui&gri;iui=iii>>>0>ft>>>0;pdi=iui&vdi;do if(pdi)if(gp=r[176]|0,rui=np-ft|0,uui=rui+gp|0,fui=0-gp|0,gf=uui&fui,eui=gf>>>0<2147483647,eui)if(oui=w(gf|0)|0,sui=(oui|0)==-1,sui){w(dri|0)|0;pt=is;break i}else{hui=gf+ft|0;bo=hui;break}else bo=ft;else bo=ft;while(0);if(cui=(cu|0)==-1,cui)pt=is;else{t=cu;c=bo;o=192;break t}}while(0);lui=r[167]|0;aui=lui|4;r[167]=aui;ag=pt;o=189}else ag=0,o=189;while(0);if((o|0)==189&&(vui=wt>>>0<2147483647,vui&&(vr=w(wt|0)|0,ne=w(0)|0,yui=(vr|0)!=-1,pui=(ne|0)!=-1,adi=yui&pui,wui=vr>>>0<ne>>>0,wdi=wui&adi,wdi&&(bui=ne,dui=vr,tw=bui-dui|0,gui=h+40|0,iw=tw>>>0>gui>>>0,put=iw?tw:ag,iw&&(t=vr,c=put,o=192)))),(o|0)==192){nfi=r[164]|0;te=nfi+c|0;r[164]=te;tfi=r[165]|0;ifi=te>>>0>tfi>>>0;ifi&&(r[165]=te);i=r[62]|0;rfi=(i|0)==0;t:do if(rfi){for(rw=r[60]|0,ffi=(rw|0)==0,efi=t>>>0<rw>>>0,bdi=ffi|efi,bdi&&(r[60]=t),r[168]=t,r[169]=c,r[171]=0,ofi=r[174]|0,r[65]=ofi,r[64]=-1,ao=0;;)if(ie=ao<<1,uw=264+(ie<<2)|0,wn=ie+3|0,sfi=264+(wn<<2)|0,r[sfi>>2]=uw,utt=ie+2|0,hfi=264+(utt<<2)|0,r[hfi>>2]=uw,fw=ao+1|0,rdi=(fw|0)==32,rdi)break;else ao=fw;cfi=c+-40|0;lfi=t+8|0;ew=lfi;afi=ew&7;vfi=(afi|0)==0;yfi=0-ew|0;pfi=yfi&7;ue=vfi?0:pfi;wfi=t+ue|0;ow=cfi-ue|0;r[62]=wfi;r[59]=ow;bfi=ow|1;bn=ue+4|0;kfi=t+bn|0;r[kfi>>2]=bfi;irt=c+-36|0;dfi=t+irt|0;r[dfi>>2]=40;gfi=r[178]|0;r[63]=gfi}else{for(vi=672;;){if(hw=r[vi>>2]|0,cw=vi+4|0,lw=r[cw>>2]|0,nei=hw+lw|0,tei=(t|0)==(nei|0),tei){pg=hw;wg=cw;bg=lw;kdi=vi;o=202;break}if(iei=vi+8|0,aw=r[iei>>2]|0,rei=(aw|0)==0,rei)break;else vi=aw}if((o|0)==202&&(uei=kdi+12|0,fei=r[uei>>2]|0,eei=fei&8,oei=(eei|0)==0,oei&&(sei=i>>>0>=pg>>>0,hei=i>>>0<t>>>0,ydi=hei&sei,ydi))){cei=bg+c|0;r[wg>>2]=cei;lei=r[59]|0;yw=lei+c|0;aei=i+8|0;ww=aei;vei=ww&7;yei=(vei|0)==0;pei=0-ww|0;wei=pei&7;fe=yei?0:wei;bei=i+fe|0;bw=yw-fe|0;r[62]=bei;r[59]=bw;kei=bw|1;kn=fe+4|0;dei=i+kn|0;r[dei>>2]=kei;rrt=yw+4|0;gei=i+rrt|0;r[gei>>2]=40;noi=r[178]|0;r[63]=noi;break}for(kw=r[60]|0,toi=t>>>0<kw>>>0,toi?(r[60]=t,oi=t):oi=kw,ioi=t+c|0,yi=672;;){if(roi=r[yi>>2]|0,uoi=(roi|0)==(ioi|0),uoi){yg=yi;cg=yi;o=210;break}if(foi=yi+8|0,dw=r[foi>>2]|0,eoi=(dw|0)==0,eoi){ai=672;break}else yi=dw}if((o|0)==210)if(ooi=cg+12|0,soi=r[ooi>>2]|0,hoi=soi&8,coi=(hoi|0)==0,coi){r[yg>>2]=t;nb=cg+4|0;loi=r[nb>>2]|0;aoi=loi+c|0;r[nb>>2]=aoi;voi=t+8|0;tb=voi;yoi=tb&7;poi=(yoi|0)==0;woi=0-tb|0;boi=woi&7;wr=poi?0:boi;koi=t+wr|0;vtt=c+8|0;doi=t+vtt|0;ib=doi;goi=ib&7;nsi=(goi|0)==0;isi=0-ib|0;rsi=isi&7;tt=nsi?0:rsi;ytt=tt+c|0;it=t+ytt|0;usi=it;fsi=koi;esi=usi-fsi|0;a=wr+h|0;d=t+a|0;br=esi-h|0;osi=h|3;ftt=wr+4|0;hsi=t+ftt|0;r[hsi>>2]=osi;csi=(it|0)==(i|0);i:do if(csi)lsi=r[59]|0,rb=lsi+br|0,r[59]=rb,r[62]=d,asi=rb|1,fut=a+4|0,vsi=t+fut|0,r[vsi>>2]=asi;else{if(ysi=r[61]|0,psi=(it|0)==(ysi|0),psi){wsi=r[58]|0;kr=wsi+br|0;r[58]=kr;r[61]=d;ksi=kr|1;rut=a+4|0;dsi=t+rut|0;r[dsi>>2]=ksi;uut=kr+a|0;gsi=t+uut|0;r[gsi>>2]=kr;break}if(pu=c+4|0,ptt=pu+tt|0,nhi=t+ptt|0,dr=r[nhi>>2]|0,thi=dr&3,ihi=(thi|0)==1,ihi){ub=dr&-8;fb=dr>>>3;rhi=dr>>>0<256;r:do if(rhi){krt=tt|8;eit=krt+c|0;fhi=t+eit|0;kt=r[fhi>>2]|0;drt=c+12|0;oit=drt+tt|0;ehi=t+oit|0;dt=r[ehi>>2]|0;ohi=fb<<1;eb=264+(ohi<<2)|0;shi=(kt|0)==(eb|0);do if(!shi){if(hhi=kt>>>0<oi>>>0,!hhi&&(chi=kt+12|0,ahi=r[chi>>2]|0,vhi=(ahi|0)==(it|0),vhi))break;e()}while(0);if(yhi=(dt|0)==(kt|0),yhi){phi=1<<fb;whi=phi^-1;bhi=r[56]|0;khi=bhi&whi;r[56]=khi;break}dhi=(dt|0)==(eb|0);do if(dhi)cn=dt+8|0,bs=cn;else{if(ghi=dt>>>0<oi>>>0,!ghi&&(ob=dt+8|0,tci=r[ob>>2]|0,ici=(tci|0)==(it|0),ici)){bs=ob;break}e()}while(0);rci=kt+12|0;r[rci>>2]=dt;r[bs>>2]=kt}else{wrt=tt|24;wtt=wrt+c|0;uci=t+wtt|0;si=r[uci>>2]|0;out=c+12|0;btt=out+tt|0;fci=t+btt|0;gr=r[fci>>2]|0;eci=(gr|0)==(it|0);u:do if(eci){if(gs=tt|16,uit=pu+gs|0,lb=t+uit|0,ab=r[lb>>2]|0,vci=(ab|0)==0,vci)if(fit=gs+c|0,vb=t+fit|0,yb=r[vb>>2]|0,pci=(yb|0)==0,pci){b=0;break}else ni=yb,fu=vb;else ni=ab,fu=lb;for(;;){if(pb=ni+20|0,wb=r[pb>>2]|0,wci=(wb|0)==0,!wci){ni=wb;fu=pb;continue}if(bb=ni+16|0,kb=r[bb>>2]|0,bci=(kb|0)==0,bci){pki=ni;ug=fu;break}else ni=kb,fu=bb}if(kci=ug>>>0<oi>>>0,kci)e();else{r[ug>>2]=0;b=pki;break}}else{brt=tt|8;ktt=brt+c|0;oci=t+ktt|0;ee=r[oci>>2]|0;sci=ee>>>0<oi>>>0;do if(!sci){if(hb=ee+12|0,hci=r[hb>>2]|0,cci=(hci|0)==(it|0),!cci)break;if(cb=gr+8|0,lci=r[cb>>2]|0,aci=(lci|0)==(it|0),!aci)break;r[hb>>2]=gr;r[cb>>2]=ee;b=gr;break u}while(0);e()}while(0);if(gci=(si|0)==0,gci)break;prt=c+28|0;dtt=prt+tt|0;nli=t+dtt|0;db=r[nli>>2]|0;gb=528+(db<<2)|0;tli=r[gb>>2]|0;ili=(it|0)==(tli|0);do if(ili){if(r[gb>>2]=b,tdi=(b|0)==0,!tdi)break;rli=1<<db;uli=rli^-1;fli=r[57]|0;eli=fli&uli;r[57]=eli;break r}else if(sli=r[60]|0,hli=si>>>0<sli>>>0,hli&&e(),tk=si+16|0,cli=r[tk>>2]|0,lli=(cli|0)==(it|0),lli?r[tk>>2]=b:(ali=si+20|0,r[ali>>2]=b),vli=(b|0)==0,vli)break r;while(0);ik=r[60]|0;yli=b>>>0<ik>>>0;yli&&e();pli=b+24|0;r[pli>>2]=si;ds=tt|16;gtt=ds+c|0;wli=t+gtt|0;nu=r[wli>>2]|0;bli=(nu|0)==0;do if(!bli)if(kli=nu>>>0<ik>>>0,kli)e();else{dli=b+16|0;r[dli>>2]=nu;gli=nu+24|0;r[gli>>2]=b;break}while(0);if(iit=pu+ds|0,nai=t+iit|0,tu=r[nai>>2]|0,tai=(tu|0)==0,tai)break;if(iai=r[60]|0,uai=tu>>>0<iai>>>0,uai)e();else{fai=b+20|0;r[fai>>2]=tu;eai=tu+24|0;r[eai>>2]=b;break}}while(0);yut=ub|tt;rit=yut+c|0;oai=t+rit|0;sai=ub+br|0;og=oai;g=sai}else og=it,g=br;if(rk=og+4|0,hai=r[rk>>2]|0,cai=hai&-2,r[rk>>2]=cai,lai=g|1,htt=a+4|0,aai=t+htt|0,r[aai>>2]=lai,ltt=g+a|0,yai=t+ltt|0,r[yai>>2]=g,uk=g>>>3,pai=g>>>0<256,pai){he=uk<<1;fk=264+(he<<2)|0;ek=r[56]|0;ok=1<<uk;wai=ek&ok;bai=(wai|0)==0;do if(bai)kai=ek|ok,r[56]=kai,rn=he+2|0,hn=264+(rn<<2)|0,ys=hn,uo=fk;else{if(art=he+2|0,sk=264+(art<<2)|0,hk=r[sk>>2]|0,gai=r[60]|0,nvi=hk>>>0<gai>>>0,!nvi){ys=sk;uo=hk;break}e()}while(0);r[ys>>2]=d;tvi=uo+12|0;r[tvi>>2]=d;crt=a+8|0;ivi=t+crt|0;r[ivi>>2]=uo;lrt=a+12|0;rvi=t+lrt|0;r[rvi>>2]=fk;break}ce=g>>>8;uvi=(ce|0)==0;do if(uvi)ct=0;else{if(fvi=g>>>0>16777215,fvi){ct=31;break}ovi=ce+1048320|0;svi=ovi>>>16;ck=svi&8;lk=ce<<ck;hvi=lk+520192|0;cvi=hvi>>>16;ak=cvi&4;lvi=ak|ck;vk=lk<<ak;avi=vk+245760|0;yvi=avi>>>16;yk=yvi&2;pvi=lvi|yk;wvi=14-pvi|0;bvi=vk<<yk;kvi=bvi>>>15;pk=wvi+kvi|0;dvi=pk<<1;gvi=pk+7|0;nyi=g>>>gvi;iyi=nyi&1;ryi=iyi|dvi;ct=ryi}while(0);if(le=528+(ct<<2)|0,tit=a+28|0,uyi=t+tit|0,r[uyi>>2]=ct,hit=a+16|0,fyi=t+hit|0,cit=a+20|0,eyi=t+cit|0,r[eyi>>2]=0,r[fyi>>2]=0,wk=r[57]|0,bk=1<<ct,oyi=wk&bk,syi=(oyi|0)==0,syi){cyi=wk|bk;r[57]=cyi;r[le>>2]=d;ait=a+24|0;lyi=t+ait|0;r[lyi>>2]=le;yit=a+12|0;ayi=t+yit|0;r[ayi>>2]=d;wit=a+8|0;vyi=t+wit|0;r[vyi>>2]=d;break}ae=r[le>>2]|0;yyi=ae+4|0;pyi=r[yyi>>2]|0;wyi=pyi&-8;byi=(wyi|0)==(g|0);r:do if(byi)hu=ae;else{for(kyi=(ct|0)==31,dyi=ct>>>1,gyi=25-dyi|0,npi=kyi?0:gyi,tpi=g<<npi,so=tpi,co=ae;;){if(spi=so>>>31,kk=(co+16|0)+(spi<<2)|0,iu=r[kk>>2]|0,hpi=(iu|0)==0,hpi){os=kk;dki=co;break}if(ipi=so<<1,rpi=iu+4|0,upi=r[rpi>>2]|0,fpi=upi&-8,epi=(fpi|0)==(g|0),epi){hu=iu;break r}else so=ipi,co=iu}if(cpi=r[60]|0,lpi=os>>>0<cpi>>>0,lpi)e();else{r[os>>2]=d;ort=a+24|0;api=t+ort|0;r[api>>2]=dki;srt=a+12|0;vpi=t+srt|0;r[vpi>>2]=d;hrt=a+8|0;ypi=t+hrt|0;r[ypi>>2]=d;break i}}while(0);if(dk=hu+8|0,ye=r[dk>>2]|0,nd=r[60]|0,ppi=ye>>>0>=nd>>>0,edi=hu>>>0>=nd>>>0,wpi=ppi&edi,wpi){bpi=ye+12|0;r[bpi>>2]=d;r[dk>>2]=d;urt=a+8|0;kpi=t+urt|0;r[kpi>>2]=ye;frt=a+12|0;dpi=t+frt|0;r[dpi>>2]=hu;ert=a+24|0;gpi=t+ert|0;r[gpi>>2]=0;break}else e()}while(0);kit=wr|8;nwi=t+kit|0;rt=nwi;break n}else ai=672;for(;;){if(pe=r[ai>>2]|0,twi=pe>>>0>i>>>0,!twi&&(iwi=ai+4|0,td=r[iwi>>2]|0,id=pe+td|0,rwi=id>>>0>i>>>0,rwi)){hs=pe;cs=td;ls=id;break}uwi=ai+8|0;fwi=r[uwi>>2]|0;ai=fwi}if(yn=cs+-47|0,rtt=cs+-39|0,ewi=hs+rtt|0,rd=ewi,owi=rd&7,swi=(owi|0)==0,hwi=0-rd|0,cwi=hwi&7,lwi=swi?0:cwi,nrt=yn+lwi|0,fd=hs+nrt|0,ed=i+16|0,awi=fd>>>0<ed>>>0,ot=awi?i:fd,hi=ot+8|0,vwi=c+-40|0,ywi=t+8|0,sd=ywi,pwi=sd&7,wwi=(pwi|0)==0,bwi=0-sd|0,kwi=bwi&7,be=wwi?0:kwi,dwi=t+be|0,hd=vwi-be|0,r[62]=dwi,r[59]=hd,gwi=hd|1,pn=be+4|0,nbi=t+pn|0,r[nbi>>2]=gwi,trt=c+-36|0,tbi=t+trt|0,r[tbi>>2]=40,ibi=r[178]|0,r[63]=ibi,ke=ot+4|0,r[ke>>2]=27,r[hi>>2]=r[168]|0,r[hi+4>>2]=r[169]|0,r[hi+8>>2]=r[170]|0,r[hi+12>>2]=r[171]|0,r[168]=t,r[169]=c,r[171]=0,r[170]=hi,ld=ot+28|0,r[ld>>2]=7,rbi=ot+32|0,ubi=rbi>>>0<ls>>>0,ubi)for(de=ld;;)if(ad=de+4|0,r[ad>>2]=7,fbi=de+8|0,ebi=fbi>>>0<ls>>>0,ebi)de=ad;else break;if(sbi=(ot|0)==(i|0),!sbi){if(hbi=ot,cbi=i,ut=hbi-cbi|0,lbi=r[ke>>2]|0,abi=lbi&-2,r[ke>>2]=abi,vbi=ut|1,ybi=i+4|0,r[ybi>>2]=vbi,r[ot>>2]=ut,vd=ut>>>3,pbi=ut>>>0<256,pbi){ge=vd<<1;yd=264+(ge<<2)|0;pd=r[56]|0;wd=1<<vd;bbi=pd&wd;kbi=(bbi|0)==0;kbi?(dbi=pd|wd,r[56]=dbi,tn=ge+2|0,on=264+(tn<<2)|0,vs=on,to=yd):(tut=ge+2|0,bd=264+(tut<<2)|0,kd=r[bd>>2]|0,gbi=r[60]|0,tki=kd>>>0<gbi>>>0,tki?e():(vs=bd,to=kd));r[vs>>2]=i;iki=to+12|0;r[iki>>2]=i;rki=i+8|0;r[rki>>2]=to;uki=i+12|0;r[uki>>2]=yd;break}if(no=ut>>>8,fki=(no|0)==0,fki?st=0:(eki=ut>>>0>16777215,eki?st=31:(oki=no+1048320|0,ski=oki>>>16,dd=ski&8,ng=no<<dd,hki=ng+520192|0,cki=hki>>>16,tg=cki&4,lki=tg|dd,ig=ng<<tg,aki=ig+245760|0,vki=aki>>>16,rg=vki&2,yki=lki|rg,gut=14-yki|0,nft=ig<<rg,tft=nft>>>15,th=gut+tft|0,ift=th<<1,rft=th+7|0,uft=ut>>>rft,fft=uft&1,eft=fft|ift,st=eft)),wu=528+(st<<2)|0,sft=i+28|0,r[sft>>2]=st,hft=i+20|0,r[hft>>2]=0,r[ed>>2]=0,ih=r[57]|0,rh=1<<st,cft=ih&rh,lft=(cft|0)==0,lft){aft=ih|rh;r[57]=aft;r[wu>>2]=i;vft=i+24|0;r[vft>>2]=wu;yft=i+12|0;r[yft>>2]=i;pft=i+8|0;r[pft>>2]=i;break}bu=r[wu>>2]|0;bft=bu+4|0;kft=r[bft>>2]|0;dft=kft&-8;gft=(dft|0)==(ut|0);i:do if(gft)su=bu;else{for(net=(st|0)==31,tet=st>>>1,iet=25-tet|0,ret=net?0:iet,uet=ut<<ret,oo=uet,lo=bu;;){if(aet=oo>>>31,uh=(lo+16|0)+(aet<<2)|0,pi=r[uh>>2]|0,vet=(pi|0)==0,vet){ss=uh;gki=lo;break}if(eet=oo<<1,oet=pi+4|0,set=r[oet>>2]|0,het=set&-8,cet=(het|0)==(ut|0),cet){su=pi;break i}else oo=eet,lo=pi}if(yet=r[60]|0,wet=ss>>>0<yet>>>0,wet)e();else{r[ss>>2]=i;bet=i+24|0;r[bet>>2]=gki;ket=i+12|0;r[ket>>2]=i;det=i+8|0;r[det>>2]=i;break t}}while(0);if(fh=su+8|0,ku=r[fh>>2]|0,eh=r[60]|0,get=ku>>>0>=eh>>>0,fdi=su>>>0>=eh>>>0,not=get&fdi,not){tot=ku+12|0;r[tot>>2]=i;r[fh>>2]=i;rot=i+8|0;r[rot>>2]=ku;uot=i+12|0;r[uot>>2]=su;fot=i+24|0;r[fot>>2]=0;break}else e()}}while(0);if(oh=r[59]|0,eot=oh>>>0>h>>>0,eot){sh=oh-h|0;r[59]=sh;wi=r[62]|0;oot=wi+h|0;r[62]=oot;sot=sh|1;gn=h+4|0;hot=wi+gn|0;r[hot>>2]=sot;cot=h|3;lot=wi+4|0;r[lot>>2]=cot;aot=wi+8|0;rt=aot;break}}vot=yt()|0;r[vot>>2]=12;rt=0}else rt=0}while(0);return rt|0}function o(n){n=n|0;var si=0,lf=0,hi=0,ci=0,li=0,af=0,vf=0,yf=0,pf=0,wf=0,bf=0,kf=0,df=0,gf=0,ne=0,c=0,te=0,ie=0,re=0,ue=0,fe=0,ee=0,oe=0,se=0,he=0,ce=0,le=0,ae=0,ve=0,ye=0,pe=0,we=0,be=0,bt=0,ke=0,de=0,ge=0,no=0,ai=0,vi=0,to=0,io=0,ro=0,uo=0,fo=0,eo=0,oo=0,yi=0,p=0,so=0,ho=0,co=0,lo=0,ao=0,vo=0,yo=0,ft=0,pi=0,po=0,wo=0,bo=0,ko=0,go=0,ns=0,ts=0,et=0,is=0,rs=0,us=0,fs=0,es=0,it=0,wi=0,os=0,ss=0,w=0,hs=0,b=0,i=0,cs=0,bi=0,ls=0,as=0,vs=0,ys=0,ps=0,ws=0,bs=0,ks=0,l=0,ds=0,gs=0,nh=0,th=0,ih=0,rh=0,ki=0,uh=0,fh=0,eh=0,oh=0,sh=0,rt=0,hh=0,ot=0,ch=0,lh=0,kt=0,ah=0,vh=0,di=0,yh=0,ph=0,wh=0,gi=0,bh=0,kh=0,nr=0,tr=0,dh=0,ir=0,rr=0,gh=0,nc=0,ur=0,fr=0,tc=0,er=0,or=0,ic=0,rc=0,uc=0,fc=0,sr=0,ec=0,hr=0,cr=0,oc=0,sc=0,hc=0,cc=0,lc=0,ac=0,vc=0,k=0,yc=0,pc=0,lr=0,wc=0,bc=0,kc=0,dc=0,ar=0,gc=0,nl=0,tl=0,il=0,st=0,rl=0,ul=0,fl=0,el=0,ol=0,ht=0,sl=0,hl=0,cl=0,d=0,ll=0,al=0,vl=0,yl=0,pl=0,wl=0,bl=0,kl=0,dl=0,gl=0,na=0,ta=0,vr=0,ia=0,dt=0,yr=0,pr=0,wr=0,ra=0,ua=0,fa=0,g=0,br=0,kr=0,ea=0,oa=0,sa=0,ha=0,ca=0,gt=0,la=0,aa=0,va=0,ya=0,pa=0,dr=0,gr=0,wa=0,ba=0,nu=0,ka=0,tu=0,da=0,iu=0,ga=0,ru=0,nv=0,tv=0,iv=0,rv=0,uu=0,uv=0,fv=0,ev=0,ov=0,sv=0,hv=0,ni=0,cv=0,lv=0,av=0,fu=0,eu=0,vv=0,yv=0,pv=0,wv=0,bv=0,kv=0,dv=0,ti=0,gv=0,ny=0,ty=0,iy=0,ry=0,uy=0,fy=0,ey=0,oy=0,sy=0,hy=0,cy=0,ct=0,ly=0,ay=0,vy=0,yy=0,py=0,wy=0,ou=0,by=0,ky=0,dy=0,gy=0,np=0,tp=0,su=0,ii=0,ip=0,hu=0,rp=0,up=0,fp=0,ep=0,op=0,sp=0,hp=0,cu=0,cp=0,lp=0,ap=0,vp=0,yp=0,pp=0,wp=0,bp=0,kp=0,dp=0,lu=0,gp=0,nw=0,tw=0,iw=0,rw=0,ut=0,uw=0,lt=0,fw=0,ew=0,ri=0,ui=0,ow=0,au=0,sw=0,hw=0,vu=0,cw=0,lw=0,yu=0,pu=0,aw=0,wu=0,bu=0,ku=0,vw=0,du=0,gu=0,yw=0,nf=0,tf=0,pw=0,ww=0,bw=0,kw=0,dw=0,rf=0,uf=0,gw=0,nb=0,tb=0,ib=0,rb=0,ub=0,f=0,fb=0,eb=0,ff=0,ob=0,sb=0,hb=0,cb=0,ef=0,lb=0,ab=0,a=0,vb=0,at=0,yb=0,pb=0,wb=0,bb=0,kb=0,vt=0,db=0,gb=0,fi=0,y=0,ei=0,nt=0,nk=0,s=0,tt=0,tk=0,h=0,yt=0,of=0,pt=0,sf=0,wt=0,oi=0,ik=0,rk=0,uk=0,fk=0,t=0,o=0,v=0,hf=0,cf=0,ek=0;ek=u;be=(n|0)==0;n:do if(!be){bt=n+-8|0;k=r[60]|0;yy=bt>>>0<k>>>0;t:do if(!yy&&(gp=n+-4|0,ui=r[gp>>2]|0,wu=ui&3,bw=(wu|0)==1,!bw)){f=ui&-8;pf=f+-8|0;a=n+pf|0;ke=ui&1;eo=(ke|0)==0;do if(eo){if(ft=r[bt>>2]|0,rs=(wu|0)==0,rs)break n;if(c=-8-ft|0,i=n+c|0,l=ft+f|0,oh=i>>>0<k>>>0,oh)break t;if(yh=r[61]|0,gh=(i|0)==(yh|0),gh){if(ce=f+-4|0,ai=n+ce|0,vi=r[ai>>2]|0,to=vi&3,io=(to|0)==3,!io){t=i;o=l;break}r[58]=l;ro=vi&-2;r[ai>>2]=ro;uo=l|1;te=c+4|0;fo=n+te|0;r[fo>>2]=uo;r[a>>2]=l;break n}if(sr=ft>>>3,yc=ft>>>0<256,yc){le=c+8|0;il=n+le|0;d=r[il>>2]|0;ae=c+12|0;na=n+ae|0;g=r[na>>2]|0;va=sr<<1;iu=264+(va<<2)|0;ov=(d|0)==(iu|0);do if(!ov){if(pv=d>>>0<k>>>0,!pv&&(uy=d+12|0,py=r[uy>>2]|0,ip=(py|0)==(i|0),ip))break;e()}while(0);if(lp=(g|0)==(d|0),lp){yp=1<<sr;pp=yp^-1;wp=r[56]|0;bp=wp&pp;r[56]=bp;t=i;o=l;break}kp=(g|0)==(iu|0);do if(kp)yf=g+8|0,ci=yf;else{if(dp=g>>>0<k>>>0,!dp&&(lu=g+8|0,nw=r[lu>>2]|0,tw=(nw|0)==(i|0),tw)){ci=lu;break}e()}while(0);iw=d+12|0;r[iw>>2]=g;r[ci>>2]=d;t=i;o=l;break}ie=c+24|0;rw=n+ie|0;ut=r[rw>>2]|0;re=c+12|0;uw=n+re|0;lt=r[uw>>2]|0;fw=(lt|0)==(i|0);do if(fw){if(fe=c+20|0,yu=n+fe|0,pu=r[yu>>2]|0,aw=(pu|0)==0,aw)if(ue=c+16|0,bu=n+ue|0,ku=r[bu>>2]|0,vw=(ku|0)==0,vw){s=0;break}else nt=ku,yt=bu;else nt=pu,yt=yu;for(;;){if(du=nt+20|0,gu=r[du>>2]|0,yw=(gu|0)==0,!yw){nt=gu;yt=du;continue}if(nf=nt+16|0,tf=r[nf>>2]|0,pw=(tf|0)==0,pw){nk=nt;of=yt;break}else nt=tf,yt=nf}if(ww=of>>>0<k>>>0,ww)e();else{r[of>>2]=0;s=nk;break}}else{if(he=c+8|0,ew=n+he|0,ri=r[ew>>2]|0,ow=ri>>>0<k>>>0,!ow&&(au=ri+12|0,sw=r[au>>2]|0,hw=(sw|0)==(i|0),hw&&(vu=lt+8|0,cw=r[vu>>2]|0,lw=(cw|0)==(i|0),lw))){r[au>>2]=lt;r[vu>>2]=ri;s=lt;break}e()}while(0);if(kw=(ut|0)==0,kw)t=i,o=l;else{if(ee=c+28|0,dw=n+ee|0,rf=r[dw>>2]|0,uf=528+(rf<<2)|0,gw=r[uf>>2]|0,nb=(i|0)==(gw|0),nb){if(r[uf>>2]=s,rk=(s|0)==0,rk){tb=1<<rf;ib=tb^-1;rb=r[57]|0;ub=rb&ib;r[57]=ub;t=i;o=l;break}}else if(fb=r[60]|0,eb=ut>>>0<fb>>>0,eb&&e(),ff=ut+16|0,ob=r[ff>>2]|0,sb=(ob|0)==(i|0),sb?r[ff>>2]=s:(hb=ut+20|0,r[hb>>2]=s),cb=(s|0)==0,cb){t=i;o=l;break}ef=r[60]|0;lb=s>>>0<ef>>>0;lb&&e();ab=s+24|0;r[ab>>2]=ut;oe=c+16|0;vb=n+oe|0;at=r[vb>>2]|0;yb=(at|0)==0;do if(!yb)if(pb=at>>>0<ef>>>0,pb)e();else{wb=s+16|0;r[wb>>2]=at;bb=at+24|0;r[bb>>2]=s;break}while(0);if(se=c+20|0,kb=n+se|0,vt=r[kb>>2]|0,db=(vt|0)==0,db)t=i,o=l;else if(gb=r[60]|0,de=vt>>>0<gb>>>0,de)e();else{ge=s+20|0;r[ge>>2]=vt;no=vt+24|0;r[no>>2]=s;t=i;o=l;break}}}else t=bt,o=f;while(0);if(oo=t>>>0<a>>>0,oo&&(ne=f+-4|0,yi=n+ne|0,p=r[yi>>2]|0,so=p&1,ho=(so|0)==0,!ho)){if(co=p&2,lo=(co|0)==0,lo){if(ao=r[62]|0,vo=(a|0)==(ao|0),vo){if(yo=r[59]|0,pi=yo+o|0,r[59]=pi,r[62]=t,po=pi|1,wo=t+4|0,r[wo>>2]=po,bo=r[61]|0,ko=(t|0)==(bo|0),!ko)break n;r[61]=0;r[58]=0;break n}if(go=r[61]|0,ns=(a|0)==(go|0),ns){ts=r[58]|0;et=ts+o|0;r[58]=et;r[61]=t;is=et|1;us=t+4|0;r[us>>2]=is;fs=t+et|0;r[fs>>2]=et;break n}es=p&-8;it=es+o|0;wi=p>>>3;os=p>>>0<256;do if(os){ss=n+f|0;w=r[ss>>2]|0;gf=f|4;hs=n+gf|0;b=r[hs>>2]|0;cs=wi<<1;bi=264+(cs<<2)|0;ls=(w|0)==(bi|0);do if(!ls){if(as=r[60]|0,vs=w>>>0<as>>>0,!vs&&(ys=w+12|0,ps=r[ys>>2]|0,ws=(ps|0)==(a|0),ws))break;e()}while(0);if(bs=(b|0)==(w|0),bs){ks=1<<wi;ds=ks^-1;gs=r[56]|0;nh=gs&ds;r[56]=nh;break}th=(b|0)==(bi|0);do if(th)vf=b+8|0,hi=vf;else{if(ih=r[60]|0,rh=b>>>0<ih>>>0,!rh&&(ki=b+8|0,uh=r[ki>>2]|0,fh=(uh|0)==(a|0),fh)){hi=ki;break}e()}while(0);eh=w+12|0;r[eh>>2]=b;r[hi>>2]=w}else{ve=f+16|0;sh=n+ve|0;rt=r[sh>>2]|0;ye=f|4;hh=n+ye|0;ot=r[hh>>2]|0;ch=(ot|0)==(a|0);do if(ch){if(we=f+12|0,nr=n+we|0,tr=r[nr>>2]|0,dh=(tr|0)==0,dh)if(pe=f+8|0,ir=n+pe|0,rr=r[ir>>2]|0,nc=(rr|0)==0,nc){h=0;break}else tt=rr,pt=ir;else tt=tr,pt=nr;for(;;){if(ur=tt+20|0,fr=r[ur>>2]|0,tc=(fr|0)==0,!tc){tt=fr;pt=ur;continue}if(er=tt+16|0,or=r[er>>2]|0,ic=(or|0)==0,ic){tk=tt;sf=pt;break}else tt=or,pt=er}if(rc=r[60]|0,uc=sf>>>0<rc>>>0,uc)e();else{r[sf>>2]=0;h=tk;break}}else{if(lh=n+f|0,kt=r[lh>>2]|0,ah=r[60]|0,vh=kt>>>0<ah>>>0,!vh&&(di=kt+12|0,ph=r[di>>2]|0,wh=(ph|0)==(a|0),wh&&(gi=ot+8|0,bh=r[gi>>2]|0,kh=(bh|0)==(a|0),kh))){r[di>>2]=ot;r[gi>>2]=kt;h=ot;break}e()}while(0);if(fc=(rt|0)==0,!fc){if(bf=f+20|0,ec=n+bf|0,hr=r[ec>>2]|0,cr=528+(hr<<2)|0,oc=r[cr>>2]|0,sc=(a|0)==(oc|0),sc){if(r[cr>>2]=h,uk=(h|0)==0,uk){hc=1<<hr;cc=hc^-1;lc=r[57]|0;ac=lc&cc;r[57]=ac;break}}else if(vc=r[60]|0,pc=rt>>>0<vc>>>0,pc&&e(),lr=rt+16|0,wc=r[lr>>2]|0,bc=(wc|0)==(a|0),bc?r[lr>>2]=h:(kc=rt+20|0,r[kc>>2]=h),dc=(h|0)==0,dc)break;ar=r[60]|0;gc=h>>>0<ar>>>0;gc&&e();nl=h+24|0;r[nl>>2]=rt;kf=f+8|0;tl=n+kf|0;st=r[tl>>2]|0;rl=(st|0)==0;do if(!rl)if(ul=st>>>0<ar>>>0,ul)e();else{fl=h+16|0;r[fl>>2]=st;el=st+24|0;r[el>>2]=h;break}while(0);if(df=f+12|0,ol=n+df|0,ht=r[ol>>2]|0,sl=(ht|0)==0,!sl)if(hl=r[60]|0,cl=ht>>>0<hl>>>0,cl)e();else{ll=h+20|0;r[ll>>2]=ht;al=ht+24|0;r[al>>2]=h;break}}}while(0);if(vl=it|1,yl=t+4|0,r[yl>>2]=vl,pl=t+it|0,r[pl>>2]=it,wl=r[61]|0,bl=(t|0)==(wl|0),bl){r[58]=it;break n}else v=it}else kl=p&-2,r[yi>>2]=kl,dl=o|1,gl=t+4|0,r[gl>>2]=dl,ta=t+o|0,r[ta>>2]=o,v=o;if(vr=v>>>3,ia=v>>>0<256,ia){dt=vr<<1;yr=264+(dt<<2)|0;pr=r[56]|0;wr=1<<vr;ra=pr&wr;ua=(ra|0)==0;ua?(fa=pr|wr,r[56]=fa,lf=dt+2|0,af=264+(lf<<2)|0,li=af,fi=yr):(wf=dt+2|0,br=264+(wf<<2)|0,kr=r[br>>2]|0,ea=r[60]|0,oa=kr>>>0<ea>>>0,oa?e():(li=br,fi=kr));r[li>>2]=t;sa=fi+12|0;r[sa>>2]=t;ha=t+8|0;r[ha>>2]=fi;ca=t+12|0;r[ca>>2]=yr;break n}gt=v>>>8;la=(gt|0)==0;la?y=0:(aa=v>>>0>16777215,aa?y=31:(ya=gt+1048320|0,pa=ya>>>16,dr=pa&8,gr=gt<<dr,wa=gr+520192|0,ba=wa>>>16,nu=ba&4,ka=nu|dr,tu=gr<<nu,da=tu+245760|0,ga=da>>>16,ru=ga&2,nv=ka|ru,tv=14-nv|0,iv=tu<<ru,rv=iv>>>15,uu=tv+rv|0,uv=uu<<1,fv=uu+7|0,ev=v>>>fv,sv=ev&1,hv=sv|uv,y=hv));ni=528+(y<<2)|0;cv=t+28|0;r[cv>>2]=y;lv=t+16|0;av=t+20|0;r[av>>2]=0;r[lv>>2]=0;fu=r[57]|0;eu=1<<y;vv=fu&eu;yv=(vv|0)==0;i:do if(yv)wv=fu|eu,r[57]=wv,r[ni>>2]=t,bv=t+24|0,r[bv>>2]=ni,kv=t+12|0,r[kv>>2]=t,dv=t+8|0,r[dv>>2]=t;else{ti=r[ni>>2]|0;gv=ti+4|0;ny=r[gv>>2]|0;ty=ny&-8;iy=(ty|0)==(v|0);r:do if(iy)wt=ti;else{for(ry=(y|0)==31,fy=y>>>1,ey=25-fy|0,oy=ry?0:ey,sy=v<<oy,ei=sy,oi=ti;;){if(wy=ei>>>31,ou=(oi+16|0)+(wy<<2)|0,ct=r[ou>>2]|0,by=(ct|0)==0,by){si=ou;ik=oi;break}if(hy=ei<<1,cy=ct+4|0,ly=r[cy>>2]|0,ay=ly&-8,vy=(ay|0)==(v|0),vy){wt=ct;break r}else ei=hy,oi=ct}if(ky=r[60]|0,dy=si>>>0<ky>>>0,dy)e();else{r[si>>2]=t;gy=t+24|0;r[gy>>2]=ik;np=t+12|0;r[np>>2]=t;tp=t+8|0;r[tp>>2]=t;break i}}while(0);if(su=wt+8|0,ii=r[su>>2]|0,hu=r[60]|0,rp=ii>>>0>=hu>>>0,fk=wt>>>0>=hu>>>0,up=rp&fk,up){fp=ii+12|0;r[fp>>2]=t;r[su>>2]=t;ep=t+8|0;r[ep>>2]=ii;op=t+12|0;r[op>>2]=wt;sp=t+24|0;r[sp>>2]=0;break}else e()}while(0);if(hp=r[64]|0,cu=hp+-1|0,r[64]=cu,cp=(cu|0)==0,cp)cf=680;else break n;for(;;)if(hf=r[cf>>2]|0,ap=(hf|0)==0,vp=hf+8|0,ap)break;else cf=vp;r[64]=-1;break n}}while(0);e()}while(0);return}function yt(){var n=0,t=0,i=0,f=0,e=0,o=0,s=0;return s=u,t=r[44]|0,i=(t|0)==0,i?n=720:(f=sr()|0,e=f+60|0,o=r[e>>2]|0,n=o),n|0}function st(n){n=n|0;var t=0,i=0,f=0,e=0,o=0;return o=u,i=n>>>0>4294963200,i?(f=0-n|0,e=yt()|0,r[e>>2]=f,t=-1):t=n,t|0}function ki(n){n=n|0;var t=0;return t=u,0}function pt(n){n=n|0;var t=u;return}function ue(n){n=n|0;var f=0,e=0,o=0,s=0,t=0,i=0;return i=u,u=u+16|0,t=i,f=n+60|0,e=r[f>>2]|0,r[t>>2]=e,o=lr(6,t|0)|0,s=st(o)|0,u=i,s|0}function fe(n,t,i){n=n|0;t=t|0;i=i|0;var h=0,c=0,l=0,a=0,v=0,y=0,s=0,e=0,f=0,p=0,w=0,b=0,k=0,o=0;return o=u,u=u+32|0,f=o,e=o+20|0,c=n+60|0,l=r[c>>2]|0,r[f>>2]=l,p=f+4|0,r[p>>2]=0,w=f+8|0,r[w>>2]=t,b=f+12|0,r[b>>2]=e,k=f+16|0,r[k>>2]=i,a=br(140,f|0)|0,v=st(a)|0,y=(v|0)<0,y?(r[e>>2]=-1,s=-1):(h=r[e>>2]|0,s=h),u=o,s|0}function di(n,t,i){n=n|0;t=t|0;i=i|0;var b=0,ht=0,ct=0,s=0,tt=0,it=0,rt=0,lt=0,at=0,vt=0,yt=0,pt=0,wt=0,bt=0,kt=0,dt=0,gt=0,ut=0,ti=0,ii=0,ri=0,ui=0,ft=0,fi=0,ei=0,oi=0,l=0,si=0,hi=0,ci=0,li=0,ai=0,vi=0,yi=0,a=0,pi=0,et=0,wi=0,bi=0,ki=0,di=0,gi=0,nr=0,tr=0,ir=0,rr=0,ur=0,fr=0,er=0,k=0,ot=0,sr=0,hr=0,cr=0,f=0,v=0,e=0,lr=0,h=0,o=0,ar=0,d=0,c=0,g=0,y=0,p=0,yr=0,pr=0,wr=0,br=0,nt=0,w=0;for(w=u,u=u+48|0,p=w+16|0,y=w,c=w+32|0,s=n+28|0,tt=r[s>>2]|0,r[c>>2]=tt,dt=c+4|0,l=n+20|0,wi=r[l>>2]|0,er=wi,ot=er-tt|0,r[dt>>2]=ot,sr=c+8|0,r[sr>>2]=t,hr=c+12|0,r[hr>>2]=i,cr=ot+i|0,it=n+60|0,rt=n+44|0,e=c,o=2,g=cr;;){if(lt=r[44]|0,at=(lt|0)==0,at?(wt=r[it>>2]|0,r[p>>2]=wt,wr=p+4|0,r[wr>>2]=e,br=p+8|0,r[br>>2]=o,bt=ni(146,p|0)|0,kt=st(bt)|0,f=kt):(vr(6,n|0),vt=r[it>>2]|0,r[y>>2]=vt,yr=y+4|0,r[yr>>2]=e,pr=y+8|0,r[pr>>2]=o,yt=ni(146,y|0)|0,pt=st(yt)|0,or(0),f=pt),gt=(g|0)==(f|0),gt){nt=6;break}if(fi=(f|0)<0,fi){lr=e;ar=o;nt=8;break}vi=g-f|0;yi=e+4|0;a=r[yi>>2]|0;pi=f>>>0>a>>>0;pi?(et=r[rt>>2]|0,r[s>>2]=et,r[l>>2]=et,bi=f-a|0,ki=e+8|0,di=o+-1|0,ht=e+12|0,ct=r[ht>>2]|0,k=ct,v=bi,h=ki,d=di):(gi=(o|0)==2,gi?(nr=r[s>>2]|0,tr=nr+f|0,r[s>>2]=tr,k=a,v=f,h=e,d=2):(k=a,v=f,h=e,d=o));ir=r[h>>2]|0;rr=ir+v|0;r[h>>2]=rr;ur=h+4|0;fr=k-v|0;r[ur>>2]=fr;e=h;o=d;g=vi}return(nt|0)==6?(ut=r[rt>>2]|0,ti=n+48|0,ii=r[ti>>2]|0,ri=ut+ii|0,ui=n+16|0,r[ui>>2]=ri,ft=ut,r[s>>2]=ft,r[l>>2]=ft,b=i):(nt|0)==8&&(ei=n+16|0,r[ei>>2]=0,r[s>>2]=0,r[l>>2]=0,oi=r[n>>2]|0,si=oi|32,r[n>>2]=si,hi=(ar|0)==2,hi?b=0:(ci=lr+4|0,li=r[ci>>2]|0,ai=i-li|0,b=ai)),u=w,b|0}function ee(n,t,i){n=n|0;t=t|0;i=i|0;var s=0,h=0,c=0,l=0,a=0,v=0,y=0,p=0,w=0,b=0,k=0,e=0,d=0,g=0,o=0;return o=u,u=u+80|0,e=o,k=o+12|0,s=n+36|0,r[s>>2]=4,h=r[n>>2]|0,c=h&64,l=(c|0)==0,l&&(a=n+60|0,v=r[a>>2]|0,r[e>>2]=v,d=e+4|0,r[d>>2]=21505,g=e+8|0,r[g>>2]=k,y=pr(54,e|0)|0,p=(y|0)==0,p||(w=n+75|0,f[w>>0]=-1)),b=di(n,t,i)|0,u=o,b|0}function gi(n){n=n|0;var i=0,s=0,h=0,t=0,v=0,y=0,p=0,w=0,b=0,k=0,d=0,g=0,nt=0,tt=0,it=0,rt=0,ut=0,ft=0,et=0,ot=0,st=0,c=0,ht=0,ct=0,f=0,lt=0,at=0,vt=0,l=0,yt=0,bt=0,kt=0,dt=0,a=0,e=0,o=0,gt=0;gt=u;v=(n|0)==0;do if(v){if(yt=r[55]|0,bt=(yt|0)==0,bt?f=0:(kt=r[55]|0,p=gi(kt)|0,f=p),cr(204),h=r[50]|0,w=(h|0)==0,w)a=f;else for(t=h,e=f;;)if(b=t+76|0,k=r[b>>2]|0,d=(k|0)>-1,d?(g=ki(t)|0,c=g):c=0,nt=t+20|0,tt=r[nt>>2]|0,it=t+28|0,rt=r[it>>2]|0,ft=tt>>>0>rt>>>0,ft?(et=wt(t)|0,ot=et|e,o=ot):o=e,st=(c|0)==0,st||pt(t),ht=t+56|0,s=r[ht>>2]|0,ct=(s|0)==0,ct){a=o;break}else t=s,e=o;wr(204);i=a}else{if(y=n+76|0,ut=r[y>>2]|0,lt=(ut|0)>-1,!lt){at=wt(n)|0;i=at;break}vt=ki(n)|0;dt=(vt|0)==0;l=wt(n)|0;dt?i=l:(pt(n),i=l)}while(0);return i|0}function k(n,t,i){n=n|0;t=t|0;i=i|0;var s=0,a=0,v=0,y=0,h=0,p=0,r=0,c=0,w=0,l=0,b=0,k=0,d=0,g=0,nt=0,e=0,o=0,tt=0;tt=u;y=(i|0)==0;n:do if(y)r=0;else{for(s=i,e=n,o=t;;){if(h=f[e>>0]|0,c=f[o>>0]|0,w=h<<24>>24==c<<24>>24,!w){a=h;v=c;break}if(l=s+-1|0,b=e+1|0,k=o+1|0,d=(l|0)==0,d){r=0;break n}else s=l,e=b,o=k}g=a&255;nt=v&255;p=g-nt|0;r=p}while(0);return r|0}function oe(n,t){n=n|0;t=t|0;var i=0,s=0,e=0,h=0,c=0,l=0,o=0,k=0,d=0,g=0,lt=0,nt=0,at=0,vt=0,yt=0,a=0,pt=0,wt=0,bt=0,kt=0,dt=0,gt=0,v=0,tt=0,it=0,y=0,ni=0,ti=0,ii=0,ri=0,ui=0,rt=0,fi=0,ei=0,ut=0,p=0,ft=0,oi=0,si=0,hi=0,ci=0,et=0,li=0,w=0,ot=0,b=0,st=0,ht=0,ct=0,ai=0;ai=u;g=t;lt=n;gt=g^lt;fi=gt&3;si=(fi|0)==0;n:do if(si){if(hi=g&3,ci=(hi|0)==0,ci)i=t,s=n;else for(e=n,h=t;;){if(et=f[h>>0]|0,f[e>>0]=et,li=et<<24>>24==0,li){c=e;break n}if(w=h+1|0,nt=e+1|0,at=w,vt=at&3,yt=(vt|0)==0,yt){i=w;s=nt;break}else e=nt,h=w}if(a=r[i>>2]|0,pt=a+-16843009|0,wt=a&-2139062144,bt=wt^-2139062144,kt=bt&pt,dt=(kt|0)==0,dt)for(it=a,b=s,ht=i;;)if(v=ht+4|0,tt=b+4|0,r[b>>2]=it,y=r[v>>2]|0,ni=y+-16843009|0,ti=y&-2139062144,ii=ti^-2139062144,ri=ii&ni,ui=(ri|0)==0,ui)it=y,b=tt,ht=v;else{ot=tt;st=v;break}else ot=s,st=i;l=st;o=ot;ct=8}else l=t,o=n,ct=8;while(0);if((ct|0)==8)if(rt=f[l>>0]|0,f[o>>0]=rt,ei=rt<<24>>24==0,ei)c=o;else for(k=o,d=l;;)if(ut=d+1|0,p=k+1|0,ft=f[ut>>0]|0,f[p>>0]=ft,oi=ft<<24>>24==0,oi){c=p;break}else k=p,d=ut;return c|0}function nr(n,t){n=n|0;t=t|0;var i=0;return i=u,oe(n,t)|0,n|0}function se(){var t=0,i=0,n=0,f=0,o=0,s=0,h=0,c=0,l=0,a=0;a=u;t=r[174]|0;i=(t|0)==0;do if(i)if(n=hr(30)|0,f=n+-1|0,o=f&n,s=(o|0)==0,s){r[176]=n;r[175]=n;r[177]=-1;r[178]=-1;r[179]=0;r[167]=0;h=ar(0)|0;c=h&-16;l=c^1431655768;r[174]=l;break}else e();while(0);return}function he(n){n=n|0;var t=0,i=0,f=0,e=0;e=u;t=n+68|0;i=r[t>>2]|0;f=(i|0)==0;f&&pt(n);return}function wt(n){n=n|0;var i=0,t=0,l=0,f=0,e=0,o=0,a=0,v=0,y=0,p=0,w=0,b=0,k=0,s=0,d=0,g=0,nt=0,tt=0,it=0,rt=0,h=0,c=0,ut=0;return ut=u,t=n+20|0,l=r[t>>2]|0,s=n+28|0,d=r[s>>2]|0,g=l>>>0>d>>>0,g?(nt=n+36|0,tt=r[nt>>2]|0,ct[tt&7](n,0,0)|0,it=r[t>>2]|0,rt=(it|0)==0,rt?i=-1:c=3):c=3,(c|0)==3&&(h=n+4|0,f=r[h>>2]|0,e=n+8|0,o=r[e>>2]|0,a=f>>>0<o>>>0,a&&(v=n+40|0,y=r[v>>2]|0,p=f,w=o,b=p-w|0,ct[y&7](n,b,1)|0),k=n+16|0,r[k>>2]=0,r[s>>2]=0,r[t>>2]=0,r[e>>2]=0,r[h>>2]=0,i=0),i|0}function ce(){}function s(n,t,i){n=n|0;t=t|0;i=i|0;var e=0,o=0,s=0,u=0;if(e=n+i|0,(i|0)>=20){if(t=t&255,u=n&3,o=t|t<<8|t<<16|t<<24,s=e&-4,u)for(u=n+4-u|0;(n|0)<(u|0);)f[n>>0]=t,n=n+1|0;while((n|0)<(s|0))r[n>>2]=o,n=n+4|0}while((n|0)<(e|0))f[n>>0]=t,n=n+1|0;return n-i|0}function d(n,t,i){n=n|0;t=t|0;i=i|0;var u=0;if((i|0)>=4096)return yr(n|0,t|0,i|0)|0;if(u=n|0,(n&3)==(t&3)){while(n&3){if((i|0)==0)return u|0;f[n>>0]=f[t>>0]|0;n=n+1|0;t=t+1|0;i=i-1|0}while((i|0)>=4)r[n>>2]=r[t>>2]|0,n=n+4|0,t=t+4|0,i=i-4|0}while((i|0)>0)f[n>>0]=f[t>>0]|0,n=n+1|0,t=t+1|0,i=i-1|0;return u|0}function le(n,t,i,r){return n=n|0,t=t|0,i=i|0,r=r|0,ct[n&7](t|0,i|0,r|0)|0}function ae(n,t,i,r,u,f){n=n|0;t=t|0;i=i|0;r=r|0;u=u|0;f=f|0;bt[n&3](t|0,i|0,r|0,u|0,f|0)}function ve(n,t){n=n|0;t=t|0;ke[n&7](t|0)}function ye(n,t){return n=n|0,t=t|0,de[n&1](t|0)|0}function pe(n,t,i,r,u,f,e){n=n|0;t=t|0;i=i|0;r=r|0;u=u|0;f=f|0;e=e|0;lt[n&3](t|0,i|0,r|0,u|0,f|0,e|0)}function we(n,t,i,r,u){n=n|0;t=t|0;i=i|0;r=r|0;u=u|0;kt[n&3](t|0,i|0,r|0,u|0)}function ht(n,t,i){return n=n|0,t=t|0,i=i|0,nt(0),0}function tr(n,t,i,r,u){n=n|0;t=t|0;i=i|0;r=r|0;u=u|0;nt(1)}function ir(n){n=n|0;nt(2)}function be(n){return n=n|0,nt(3),0}function rr(n,t,i,r,u,f){n=n|0;t=t|0;i=i|0;r=r|0;u=u|0;f=f|0;nt(4)}function ur(n,t,i,r){n=n|0;t=t|0;i=i|0;r=r|0;nt(5)}var f=new n.Int8Array(i),g=new n.Int16Array(i),r=new n.Int32Array(i),ge=new n.Uint8Array(i),no=new n.Uint16Array(i),to=new n.Uint32Array(i),io=new n.Float32Array(i),ro=new n.Float64Array(i),u=t.STACKTOP|0,fr=t.STACK_MAX|0,c=t.tempDoublePtr|0,uo=t.ABORT|0,dt=0,er=0,fo=n.NaN,eo=n.Infinity,gt=0,oo=n.Math.floor,so=n.Math.abs,ho=n.Math.sqrt,co=n.Math.pow,lo=n.Math.cos,ao=n.Math.sin,vo=n.Math.tan,yo=n.Math.acos,po=n.Math.asin,wo=n.Math.atan,bo=n.Math.atan2,ko=n.Math.exp,go=n.Math.log,ns=n.Math.ceil,h=n.Math.imul,ts=n.Math.min,is=n.Math.clz32,nt=t.abort,rs=t.assert,us=t.invoke_iiii,fs=t.invoke_viiiii,es=t.invoke_vi,os=t.invoke_ii,ss=t.invoke_viiiiii,hs=t.invoke_viiii,or=t._pthread_cleanup_pop,sr=t._pthread_self,hr=t._sysconf,cr=t.___lock,lr=t.___syscall6,cs=t.___setErrNo,e=t._abort,w=t._sbrk,ar=t._time,vr=t._pthread_cleanup_push,yr=t._emscripten_memcpy_big,pr=t.___syscall54,wr=t.___unlock,br=t.___syscall140,ls=t._emscripten_set_main_loop_timing,as=t._emscripten_set_main_loop,ni=t.___syscall146,ct=[ht,wf,ee,fe,di,ht,ht,ht],bt=[tr,gf,df,tr],ke=[ir,lf,yf,af,vf,pf,he,ir],de=[be,ue],lt=[rr,te,ne,rr],kt=[ur,bf,kf,ur];return{_jsglibPrivateDecryptV2:nf,___cxa_can_catch:ie,_free:o,___cxa_is_pointer_type:re,_jsglibSignFromHashV2:gu,_memset:s,_malloc:vt,_memcpy:d,_fflush:gi,___errno_location:yt,runPostSets:ce,stackAlloc:kr,stackSave:dr,stackRestore:gr,establishStackSpace:nu,setThrew:tu,setTempRet0:iu,getTempRet0:ru,dynCall_iiii:le,dynCall_viiiii:ae,dynCall_vi:ve,dynCall_ii:ye,dynCall_viiiiii:pe,dynCall_viiii:we}}(Module.asmGlobalArg,Module.asmLibraryArg,buffer),_jsglibPrivateDecryptV2=Module._jsglibPrivateDecryptV2=asm._jsglibPrivateDecryptV2,___cxa_can_catch=Module.___cxa_can_catch=asm.___cxa_can_catch,_free=Module._free=asm._free,runPostSets=Module.runPostSets=asm.runPostSets,___cxa_is_pointer_type=Module.___cxa_is_pointer_type=asm.___cxa_is_pointer_type,_jsglibSignFromHashV2=Module._jsglibSignFromHashV2=asm._jsglibSignFromHashV2,_memset=Module._memset=asm._memset,_malloc=Module._malloc=asm._malloc,_memcpy=Module._memcpy=asm._memcpy,_fflush=Module._fflush=asm._fflush,___errno_location=Module.___errno_location=asm.___errno_location,dynCall_iiii=Module.dynCall_iiii=asm.dynCall_iiii,dynCall_viiiii=Module.dynCall_viiiii=asm.dynCall_viiiii,dynCall_vi=Module.dynCall_vi=asm.dynCall_vi,dynCall_ii=Module.dynCall_ii=asm.dynCall_ii,dynCall_viiiiii=Module.dynCall_viiiiii=asm.dynCall_viiiiii,dynCall_viiii=Module.dynCall_viiii=asm.dynCall_viiii;if(Runtime.stackAlloc=asm.stackAlloc,Runtime.stackSave=asm.stackSave,Runtime.stackRestore=asm.stackRestore,Runtime.establishStackSpace=asm.establishStackSpace,Runtime.setTempRet0=asm.setTempRet0,Runtime.getTempRet0=asm.getTempRet0,ExitStatus.prototype=new Error,ExitStatus.prototype.constructor=ExitStatus,preloadStartTime=null,calledMain=!1,dependenciesFulfilled=function runCaller(){Module.calledRun||run();Module.calledRun||(dependenciesFulfilled=runCaller)},Module.callMain=Module.callMain=function(n){function f(){for(var n=0;n<3;n++)i.push(0)}var u,i,r,e;for(assert(runDependencies==0,"cannot call main when async dependencies remain! (listen on __ATMAIN__)"),assert(__ATPRERUN__.length==0,"cannot call main when preRun functions remain to be called"),n=n||[],ensureInitRuntime(),u=n.length+1,i=[allocate(intArrayFromString(Module.thisProgram),"i8",ALLOC_NORMAL)],f(),r=0;r<u-1;r=r+1)i.push(allocate(intArrayFromString(n[r]),"i8",ALLOC_NORMAL)),f();i.push(0);i=allocate(i,"i32",ALLOC_NORMAL);initialStackTop=Runtime.stackSave();try{e=Module._main(u,i,0);exit(e,!0)}catch(t){if(t instanceof ExitStatus)return;if(t=="SimulateInfiniteLoop"){Module.noExitRuntime=!0;Runtime.stackRestore(initialStackTop);return}t&&typeof t=="object"&&t.stack&&Module.printErr("exception thrown: "+[t,t.stack]);throw t;}finally{calledMain=!0}},Module.run=Module.run=run,Module.exit=Module.exit=exit,abortDecorators=[],Module.abort=Module.abort=abort,Module.preInit)for(typeof Module.preInit=="function"&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();shouldRunNow=!0;Module.noInitialRun&&(shouldRunNow=!1);run()