/* 	@preserve Copyright 2013-2014 Peersm (Na�s)

Modified MIT license for now (which removes the rights to modify, merge, sublicense, and sell):

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, publish, and/or distribute copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

	With adaptations of:

		http://code.google.com/p/stringencoding/
		Copyright Joshua Bell (chromium)
		license Apache 2.0
		Implementing TextEncoder/TextDecoder WHATWG specifications

		https://github.com/digitalbazaar/forge
		Dave Longley
		Copyright (c) 2010-2012 Digital Bazaar, Inc.
		BSD License
		You may use the Forge project under the terms of either the BSD License or the
		GNU General Public License (GPL) Version 2.

		The BSD License is recommended for most projects. It is simple and easy to
		understand and it places almost no restrictions on what you can do with the
		Forge project.

		If the GPL suits your project better you are also free to use Forge under
		that license.

		You don't have to do anything special to choose one license or the other and
		you don't have to notify anyone which license you are using. You are free to
		use this project in commercial projects as long as the copyright header is
		left intact.

		If you are a commercial entity and use this set of libraries in your
		commercial software then reasonable payment to Digital Bazaar, if you can
		afford it, is not required but is expected and would be appreciated. If this
		library saves you time, then it's saving you money. The cost of developing
		the Forge software was on the order of several hundred hours and tens of
		thousands of dollars. We are attempting to strike a balance between helping
		the development community while not being taken advantage of by lucrative
		commercial entities for our efforts.

		Stanford Javascript Crypto Library
		http://bitwiseshiftleft.github.io/sjcl/
		Copyright 2009-2010 Emily Stark, Mike Hamburg, Dan Boneh, Stanford University.

		This is for liability reasons. (Speaking of which, SJCL comes with NO
		WARRANTY WHATSOEVER, express or implied, to the limit of applicable
		law.)

		SJCL is dual-licensed under the GNU GPL version 2.0 or higher, and a
		2-clause BSD license. You may use SJCL under the terms of either of
		these licenses. For your convenience, the GPL versions 2.0 and 3.0
		and the 2-clause BSD license are included here. Additionally, you may
		serve "crunched" copies of sjcl (i.e. those with comments removed,
		and other transformations to reduce code size) without any copyright
		notice.

		RSA and ECC in JavaScript
		http://www-cs-students.stanford.edu/~tjw/jsbn/
		 * Copyright (c) 2003-2005  Tom Wu
		 * All Rights Reserved.
		 *
		 * Permission is hereby granted, free of charge, to any person obtaining
		 * a copy of this software and associated documentation files (the
		 * "Software"), to deal in the Software without restriction, including
		 * without limitation the rights to use, copy, modify, merge, publish,
		 * distribute, sublicense, and/or sell copies of the Software, and to
		 * permit persons to whom the Software is furnished to do so, subject to
		 * the following conditions:
		 *
		 * The above copyright notice and this permission notice shall be
		 * included in all copies or substantial portions of the Software.
		 *
		 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
		 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
		 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
		 *
		 * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
		 * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
		 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
		 * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
		 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
		 *
		 * In addition, the following condition applies:
		 *
		 * All redistributions must retain an intact copy of this copyright notice
		 * and disclaimer.
		 *

		http://webrsa.cvs.sourceforge.net/viewvc/webrsa/Client/RSAES-OAEP.js?content-type=text%2Fplain:
		RSAES-OAEP.js
		Copyright (C) Ellis Pritchard, Guardian Unlimited 2003.
		BSD License.

		https://github.com/mafintosh/torrent-stream
		Copyright (C) 2014 Mathias Buus Madsen <mathiasbuus@gmail.com>
		Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

		The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

		THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

		https://github.com/gpac/mp4box.js
		Copyright (c) 2012. Telecom ParisTech/TSI/MM/GPAC Cyril Concolato
		All rights reserved.
		Redistribution and use in source and binary forms, with or without
		modification, are permitted provided that the following conditions are met:
		* Redistributions of source code must retain the above copyright
		notice, this list of conditions and the following disclaimer.
		* Redistributions in binary form must reproduce the above copyright
		notice, this list of conditions and the following disclaimer in the
		documentation and/or other materials provided with the distribution.
		* Neither the name of the copyright holder nor the
		names of its contributors may be used to endorse or promote products
		derived from this software without specific prior written permission.
		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
		ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
		WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
		DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
		DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
		(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
		LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
		ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
		(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
		SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

	And:

	https://github.com/mishoo/UglifyJS2
	Mihai Bazon
	UglifyJS is released under the BSD license:

	Copyright 2012-2013 (c) Mihai Bazon <mihai.bazon@gmail.com>

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions
	are met:

		* Redistributions of source code must retain the above
		  copyright notice, this list of conditions and the following
		  disclaimer.

		* Redistributions in binary form must reproduce the above
		  copyright notice, this list of conditions and the following
		  disclaimer in the documentation and/or other materials
		  provided with the distribution.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER �AS IS� AND ANY
	EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
	LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
	PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
	PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
	TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
	THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
	SUCH DAMAGE.

*/
!function(){function e(e,t,r){return e>=t&&r>=e}function t(e,t){return Math.floor(e/t)}function r(e){var t=0;this.get=function(){return t>=e.length?al:Number(e[t])},this.offset=function(r){if(t+=r,0>t)throw new Error("Seeking past start of the buffer");if(t>e.length)throw new Error("Seeking past EOF")},this.match=function(r){if(r.length>t+e.length)return!1;var i;for(i=0;i<r.length;i+=1)if(Number(e[t+i])!==r[i])return!1;return!0}}function s(e){var t=0;this.emit=function(){var r,i=al;for(r=0;r<arguments.length;++r)i=Number(arguments[r]),e[t++]=i;return i}}function a(t){function r(t){for(var r=[],i=0,n=t.length;i<t.length;){var s=t.charCodeAt(i);if(e(s,55296,57343))if(e(s,56320,57343))r.push(65533);else if(i===n-1)r.push(65533);else{var a=t.charCodeAt(i+1);if(e(a,56320,57343)){var o=1023&s,c=1023&a;i+=1,r.push(65536+(o<<10)+c)}else r.push(65533)}else r.push(s);i+=1}return r}var i=0,n=r(t);this.offset=function(e){if(i+=e,0>i)throw new Error("Seeking past start of the buffer");if(i>n.length)throw new Error("Seeking past EOF")},this.get=function(){return i>=n.length?ol:n[i]}}function o(){var e="";this.string=function(){return e},this.emit=function(t){65535>=t?e+=String.fromCharCode(t):(t-=65536,e+=String.fromCharCode(55296+(t>>10&1023)),e+=String.fromCharCode(56320+(1023&t)))}}function c(e){this.name="EncodingError",this.message=e,this.code=0}function l(e,t){if(e)throw new c("Decoder error");return t||65533}function h(e){throw new c("The code point "+e+" could not be encoded.")}function u(e){return e=String(e).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(hl,e)?hl[e]:null}function d(e,t){return(t||[])[e]||null}function f(e,t){var r=t.indexOf(e);return-1===r?null:r}function p(e){if(e>39419&&189e3>e||e>1237575)return null;var t,r=0,i=0,n=ul.gb18030;for(t=0;t<n.length;++t){var s=n[t];if(!(s[0]<=e))break;r=s[0],i=s[1]}return i+e-r}function _(e){var t,r=0,i=0,n=ul.gb18030;for(t=0;t<n.length;++t){var s=n[t];if(!(s[1]<=e))break;r=s[1],i=s[0]}return i+e-r}function g(t){var r=t.fatal,i=0,n=0,s=0,a=0;this.decode=function(t){var o=t.get();if(o===al)return 0!==n?l(r):ol;if(t.offset(1),0===n){if(e(o,0,127))return o;if(e(o,194,223))n=1,a=128,i=o-192;else if(e(o,224,239))n=2,a=2048,i=o-224;else{if(!e(o,240,244))return l(r);n=3,a=65536,i=o-240}return i*=Math.pow(64,n),null}if(!e(o,128,191))return i=0,n=0,s=0,a=0,t.offset(-1),l(r);if(s+=1,i+=(o-128)*Math.pow(64,n-s),s!==n)return null;var c=i,h=a;return i=0,n=0,s=0,a=0,e(c,h,1114111)&&!e(c,55296,57343)?c:l(r)}}function m(r){r.fatal;this.encode=function(r,i){var n=i.get();if(n===ol)return al;if(i.offset(1),e(n,55296,57343))return h(n);if(e(n,0,127))return r.emit(n);var s,a;e(n,128,2047)?(s=1,a=192):e(n,2048,65535)?(s=2,a=224):e(n,65536,1114111)&&(s=3,a=240);for(var o=r.emit(t(n,Math.pow(64,s))+a);s>0;){var c=t(n,Math.pow(64,s-1));o=r.emit(128+c%64),s-=1}return o}}function y(t,r){var i=r.fatal;this.decode=function(r){var n=r.get();if(n===al)return ol;if(r.offset(1),e(n,0,127))return n;var s=t[n-128];return null===s?l(i):s}}function v(t,r){r.fatal;this.encode=function(r,i){var n=i.get();if(n===ol)return al;if(i.offset(1),e(n,0,127))return r.emit(n);var s=f(n,t);return null===s&&h(n),r.emit(s+128)}}function b(t,r){var i=r.fatal,n=0,s=0,a=0;this.decode=function(r){var o=r.get();if(o===al&&0===n&&0===s&&0===a)return ol;o!==al||0===n&&0===s&&0===a||(n=0,s=0,a=0,l(i)),r.offset(1);var c;if(0!==a)return c=null,e(o,48,57)&&(c=p(10*(126*(10*(n-129)+(s-48))+(a-129))+o-48)),n=0,s=0,a=0,null===c?(r.offset(-3),l(i)):c;if(0!==s)return e(o,129,254)?(a=o,null):(r.offset(-2),n=0,s=0,l(i));if(0!==n){if(e(o,48,57)&&t)return s=o,null;var h=n,u=null;n=0;var f=127>o?64:65;return(e(o,64,126)||e(o,128,254))&&(u=190*(h-129)+(o-f)),c=null===u?null:d(u,ul.gbk),null===u&&r.offset(-1),null===c?l(i):c}return e(o,0,127)?o:128===o?8364:e(o,129,254)?(n=o,null):l(i)}}function w(r,i){i.fatal;this.encode=function(i,n){var s=n.get();if(s===ol)return al;if(n.offset(1),e(s,0,127))return i.emit(s);var a=f(s,ul.gbk);if(null!==a){var o=t(a,190)+129,c=a%190,l=63>c?64:65;return i.emit(o,c+l)}if(null===a&&!r)return h(s);a=_(s);var u=t(t(t(a,10),126),10);a-=10*u*126*10;var d=t(t(a,10),126);a-=10*d*126;var p=t(a,10),g=a-10*p;return i.emit(u+129,d+48,p+129,g+48)}}function S(t){var r=t.fatal,i=!1,n=0;this.decode=function(t){var s=t.get();if(s===al&&0===n)return ol;if(s===al&&0!==n)return n=0,l(r);if(t.offset(1),126===n)return n=0,123===s?(i=!0,null):125===s?(i=!1,null):126===s?126:10===s?null:(t.offset(-1),l(r));if(0!==n){var a=n;n=0;var o=null;return e(s,33,126)&&(o=d(190*(a-1)+(s+63),ul.gbk)),10===s&&(i=!1),null===o?l(r):o}return 126===s?(n=126,null):i?e(s,32,127)?(n=s,null):(10===s&&(i=!1),l(r)):e(s,0,127)?s:l(r)}}function E(r){var i=(r.fatal,!1);this.encode=function(r,n){var s=n.get();if(s===ol)return al;if(n.offset(1),e(s,0,127)&&i)return n.offset(-1),i=!1,r.emit(126,125);if(126===s)return r.emit(126,126);if(e(s,0,127))return r.emit(s);if(!i)return n.offset(-1),i=!0,r.emit(126,123);var a=f(s,ul.gbk);if(null===a)return h(s);var o=t(a,190)+1,c=a%190-63;return e(o,33,126)&&e(c,33,126)?r.emit(o,c):h(s)}}function C(t){var r=t.fatal,i=0,n=null;this.decode=function(t){if(null!==n){var s=n;return n=null,s}var a=t.get();if(a===al&&0===i)return ol;if(a===al&&0!==i)return i=0,l(r);if(t.offset(1),0!==i){var o=i,c=null;i=0;var h=127>a?64:98;if((e(a,64,126)||e(a,161,254))&&(c=157*(o-129)+(a-h)),1133===c)return n=772,202;if(1135===c)return n=780,202;if(1164===c)return n=772,234;if(1166===c)return n=780,234;var u=null===c?null:d(c,ul.big5);return null===c&&t.offset(-1),null===u?l(r):u}return e(a,0,127)?a:e(a,129,254)?(i=a,null):l(r)}}function A(r){r.fatal;this.encode=function(r,i){var n=i.get();if(n===ol)return al;if(i.offset(1),e(n,0,127))return r.emit(n);var s=f(n,ul.big5);if(null===s)return h(n);var a=t(s,157)+129,o=s%157,c=63>o?64:98;return r.emit(a,o+c)}}function I(t){var r=t.fatal,i=0,n=0;this.decode=function(t){var s=t.get();if(s===al)return 0===i&&0===n?ol:(i=0,n=0,l(r));t.offset(1);var a,o;return 0!==n?(a=n,n=0,o=null,e(a,161,254)&&e(s,161,254)&&(o=d(94*(a-161)+s-161,ul.jis0212)),e(s,161,254)||t.offset(-1),null===o?l(r):o):142===i&&e(s,161,223)?(i=0,65377+s-161):143===i&&e(s,161,254)?(i=0,n=s,null):0!==i?(a=i,i=0,o=null,e(a,161,254)&&e(s,161,254)&&(o=d(94*(a-161)+s-161,ul.jis0208)),e(s,161,254)||t.offset(-1),null===o?l(r):o):e(s,0,127)?s:142===s||143===s||e(s,161,254)?(i=s,null):l(r)}}function T(r){r.fatal;this.encode=function(r,i){var n=i.get();if(n===ol)return al;if(i.offset(1),e(n,0,127))return r.emit(n);if(165===n)return r.emit(92);if(8254===n)return r.emit(126);if(e(n,65377,65439))return r.emit(142,n-65377+161);var s=f(n,ul.jis0208);if(null===s)return h(n);var a=t(s,94)+161,o=s%94+161;return r.emit(a,o)}}function x(t){var r=t.fatal,i={ASCII:0,escape_start:1,escape_middle:2,escape_final:3,lead:4,trail:5,Katakana:6},n=i.ASCII,s=!1,a=0;this.decode=function(t){var o=t.get();switch(o!==al&&t.offset(1),n){default:case i.ASCII:return 27===o?(n=i.escape_start,null):e(o,0,127)?o:o===al?ol:l(r);case i.escape_start:return 36===o||40===o?(a=o,n=i.escape_middle,null):(o!==al&&t.offset(-1),n=i.ASCII,l(r));case i.escape_middle:var c=a;return a=0,36!==c||64!==o&&66!==o?36===c&&40===o?(n=i.escape_final,null):40!==c||66!==o&&74!==o?40===c&&73===o?(n=i.Katakana,null):(t.offset(o===al?-1:-2),n=i.ASCII,l(r)):(n=i.ASCII,null):(s=!1,n=i.lead,null);case i.escape_final:return 68===o?(s=!0,n=i.lead,null):(t.offset(o===al?-2:-3),n=i.ASCII,l(r));case i.lead:return 10===o?(n=i.ASCII,l(r,10)):27===o?(n=i.escape_start,null):o===al?ol:(a=o,n=i.trail,null);case i.trail:if(n=i.lead,o===al)return l(r);var h=null,u=94*(a-33)+o-33;return e(a,33,126)&&e(o,33,126)&&(h=s===!1?d(u,ul.jis0208):d(u,ul.jis0212)),null===h?l(r):h;case i.Katakana:return 27===o?(n=i.escape_start,null):e(o,33,95)?65377+o-33:o===al?ol:l(r)}}}function B(r){var i=(r.fatal,{ASCII:0,lead:1,Katakana:2}),n=i.ASCII;this.encode=function(r,s){var a=s.get();if(a===ol)return al;if(s.offset(1),(e(a,0,127)||165===a||8254===a)&&n!==i.ASCII)return s.offset(-1),n=i.ASCII,r.emit(27,40,66);if(e(a,0,127))return r.emit(a);if(165===a)return r.emit(92);if(8254===a)return r.emit(126);if(e(a,65377,65439)&&n!==i.Katakana)return s.offset(-1),n=i.Katakana,r.emit(27,40,73);if(e(a,65377,65439))return r.emit(a-65377-33);if(n!==i.lead)return s.offset(-1),n=i.lead,r.emit(27,36,66);var o=f(a,ul.jis0208);if(null===o)return h(a);var c=t(o,94)+33,l=o%94+33;return r.emit(c,l)}}function k(t){var r=t.fatal,i=0;this.decode=function(t){var n=t.get();if(n===al&&0===i)return ol;if(n===al&&0!==i)return i=0,l(r);if(t.offset(1),0!==i){var s=i;if(i=0,e(n,64,126)||e(n,128,252)){var a=127>n?64:65,o=160>s?129:193,c=d(188*(s-o)+n-a,ul.jis0208);return null===c?l(r):c}return t.offset(-1),l(r)}return e(n,0,128)?n:e(n,161,223)?65377+n-161:e(n,129,159)||e(n,224,252)?(i=n,null):l(r)}}function R(r){r.fatal;this.encode=function(r,i){var n=i.get();if(n===ol)return al;if(i.offset(1),e(n,0,128))return r.emit(n);if(165===n)return r.emit(92);if(8254===n)return r.emit(126);if(e(n,65377,65439))return r.emit(n-65377+161);var s=f(n,ul.jis0208);if(null===s)return h(n);var a=t(s,188),o=31>a?129:193,c=s%188,l=63>c?64:65;return r.emit(a+o,c+l)}}function U(t){var r=t.fatal,i=0;this.decode=function(t){var n=t.get();if(n===al&&0===i)return ol;if(n===al&&0!==i)return i=0,l(r);if(t.offset(1),0!==i){var s=i,a=null;if(i=0,e(s,129,198)){var o=178*(s-129);e(n,65,90)?a=o+n-65:e(n,97,122)?a=o+26+n-97:e(n,129,254)&&(a=o+26+26+n-129)}e(s,199,253)&&e(n,161,254)&&(a=12460+94*(s-199)+(n-161));var c=null===a?null:d(a,ul["euc-kr"]);return null===a&&t.offset(-1),null===c?l(r):c}return e(n,0,127)?n:e(n,129,253)?(i=n,null):l(r)}}function D(r){r.fatal;this.encode=function(r,i){var n=i.get();if(n===ol)return al;if(i.offset(1),e(n,0,127))return r.emit(n);var s=f(n,ul["euc-kr"]);if(null===s)return h(n);var a,o;if(12460>s){a=t(s,178)+129,o=s%178;var c=26>o?65:52>o?71:77;return r.emit(a,o+c)}return s-=12460,a=t(s,94)+199,o=s%94+161,r.emit(a,o)}}function N(t){var r=t.fatal,i={ASCII:0,escape_start:1,escape_middle:2,escape_end:3,lead:4,trail:5},n=i.ASCII,s=0;this.decode=function(t){var a=t.get();switch(a!==al&&t.offset(1),n){default:case i.ASCII:return 14===a?(n=i.lead,null):15===a?null:27===a?(n=i.escape_start,null):e(a,0,127)?a:a===al?ol:l(r);case i.escape_start:return 36===a?(n=i.escape_middle,null):(a!==al&&t.offset(-1),n=i.ASCII,l(r));case i.escape_middle:return 41===a?(n=i.escape_end,null):(t.offset(a===al?-1:-2),n=i.ASCII,l(r));case i.escape_end:return 67===a?(n=i.ASCII,null):(t.offset(a===al?-2:-3),n=i.ASCII,l(r));case i.lead:return 10===a?(n=i.ASCII,l(r,10)):14===a?null:15===a?(n=i.ASCII,null):a===al?ol:(s=a,n=i.trail,null);case i.trail:if(n=i.lead,a===al)return l(r);var o=null;return e(s,33,70)&&e(a,33,126)?o=d(178*(s-1)+26+26+a-1,ul["euc-kr"]):e(s,71,126)&&e(a,33,126)&&(o=d(12460+94*(s-71)+(a-33),ul["euc-kr"])),null!==o?o:l(r)}}}function L(r){var i=(r.fatal,{ASCII:0,lead:1}),n=!1,s=i.ASCII;this.encode=function(r,a){var o=a.get();if(o===ol)return al;if(n||(n=!0,r.emit(27,36,41,67)),a.offset(1),e(o,0,127)&&s!==i.ASCII)return a.offset(-1),s=i.ASCII,r.emit(15);if(e(o,0,127))return r.emit(o);if(s!==i.lead)return a.offset(-1),s=i.lead,r.emit(14);var c=f(o,ul["euc-kr"]);if(null===c)return h(o);var l,u;return 12460>c?(l=t(c,178)+1,u=c%178-26-26+1,e(l,33,70)&&e(u,33,126)?r.emit(l,u):h(o)):(c-=12460,l=t(c,94)+71,u=c%94+33,e(l,71,126)&&e(u,33,126)?r.emit(l,u):h(o))}}function O(t,r){var i=r.fatal,n=null,s=null;this.decode=function(r){var a=r.get();if(a===al&&null===n&&null===s)return ol;if(a===al&&(null!==n||null!==s))return l(i);if(r.offset(1),null===n)return n=a,null;var o;if(o=t?(n<<8)+a:(a<<8)+n,n=null,null!==s){var c=s;return s=null,e(o,56320,57343)?65536+1024*(c-55296)+(o-56320):(r.offset(-2),l(i))}return e(o,55296,56319)?(s=o,null):e(o,56320,57343)?l(i):o}}function P(r,i){i.fatal;this.encode=function(i,n){function s(e){var t=e>>8,n=255&e;return r?i.emit(t,n):i.emit(n,t)}var a=n.get();if(a===ol)return al;if(n.offset(1),e(a,55296,57343)&&h(a),65535>=a)return s(a);var o=t(a-65536,1024)+55296,c=(a-65536)%1024+56320;return s(o),s(c)}}function F(e,t){return t.match([255,254])&&"utf-16"===e?void t.offset(2):t.match([254,255])&&"utf-16be"==e?void t.offset(2):t.match([239,187,191])&&"utf-8"==e?void t.offset(3):void 0}function q(e,t){if(e=e?String(e):dl,t=Object(t),this._encoding=u(e),null===this._encoding||"utf-8"!==this._encoding.name&&"utf-16"!==this._encoding.name&&"utf-16be"!==this._encoding.name)throw new TypeError("Unknown encoding: "+e);return this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(t.fatal)},Object.defineProperty?Object.defineProperty(this,"encoding",{get:function(){return this._encoding.name}}):this.encoding=this._encoding.name,this}function M(e,t){if(e=e?String(e):dl,t=Object(t),this._encoding=u(e),null===this._encoding)throw new TypeError("Unknown encoding: "+e);return this._streaming=!1,this._decoder=null,this._options={fatal:Boolean(t.fatal)},Object.defineProperty?Object.defineProperty(this,"encoding",{get:function(){return this._encoding.name}}):this.encoding=this._encoding.name,this}function H(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function z(){return new H(null)}function K(e,t,r,i,n,s){for(;--s>=0;){var a=t*this[e++]+r[i]+n;n=Math.floor(a/67108864),r[i++]=67108863&a}return n}function V(e,t,r,i,n,s){for(var a=32767&t,o=t>>15;--s>=0;){var c=32767&this[e],l=this[e++]>>15,h=o*c+l*a;c=a*c+((32767&h)<<15)+r[i]+(1073741823&n),n=(c>>>30)+(h>>>15)+o*l+(n>>>30),r[i++]=1073741823&c}return n}function G(e,t,r,i,n,s){for(var a=16383&t,o=t>>14;--s>=0;){var c=16383&this[e],l=this[e++]>>14,h=o*c+l*a;c=a*c+((16383&h)<<14)+r[i]+n,n=(c>>28)+(h>>14)+o*l,r[i++]=268435455&c}return n}function Y(e){return bl.charAt(e)}function W(e,t){var r=wl[e.charCodeAt(t)];return null==r?-1:r}function Q(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function X(e){this.t=1,this.s=0>e?-1:0,e>0?this[0]=e:-1>e?this[0]=e+DV:this.t=0}function J(e){var t=z();return t.fromInt(e),t}function Z(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var i=e.length,n=!1,s=0;--i>=0;){var a=8==r?255&e[i]:W(e,i);0>a?"-"==e.charAt(i)&&(n=!0):(n=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,s+=r,s>=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&H.ZERO.subTo(this,this)}function $(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}function et(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,i=(1<<t)-1,n=!1,s="",a=this.t,o=this.DB-a*this.DB%t;if(a-->0)for(o<this.DB&&(r=this[a]>>o)>0&&(n=!0,s=Y(r));a>=0;)t>o?(r=(this[a]&(1<<o)-1)<<t-o,r|=this[--a]>>(o+=this.DB-t)):(r=this[a]>>(o-=t)&i,0>=o&&(o+=this.DB,--a)),r>0&&(n=!0),n&&(s+=Y(r));return n?s:"0"}function tt(){var e=z();return H.ZERO.subTo(this,e),e}function rt(){return this.s<0?this.negate():this}function it(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(t=r-e.t,0!=t)return t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}function nt(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function st(){return this.t<=0?0:this.DB*(this.t-1)+nt(this[this.t-1]^this.s&this.DM)}function at(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}function ot(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s}function ct(e,t){var r,i=e%this.DB,n=this.DB-i,s=(1<<n)-1,a=Math.floor(e/this.DB),o=this.s<<i&this.DM;for(r=this.t-1;r>=0;--r)t[r+a+1]=this[r]>>n|o,o=(this[r]&s)<<i;for(r=a-1;r>=0;--r)t[r]=0;t[a]=o,t.t=this.t+a+1,t.s=this.s,t.clamp()}function lt(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)return void(t.t=0);var i=e%this.DB,n=this.DB-i,s=(1<<i)-1;t[0]=this[r]>>i;for(var a=r+1;a<this.t;++a)t[a-r-1]|=(this[a]&s)<<n,t[a-r]=this[a]>>i;i>0&&(t[this.t-r-1]|=(this.s&s)<<n),t.t=this.t-r,t.clamp()}function ht(e,t){for(var r=0,i=0,n=Math.min(e.t,this.t);n>r;)i+=this[r]-e[r],t[r++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i-=e.s;r<this.t;)i+=this[r],t[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<e.t;)i-=e[r],t[r++]=i&this.DM,i>>=this.DB;i-=e.s}t.s=0>i?-1:0,-1>i?t[r++]=this.DV+i:i>0&&(t[r++]=i),t.t=r,t.clamp()}function ut(e,t){var r=this.abs(),i=e.abs(),n=r.t;for(t.t=n+i.t;--n>=0;)t[n]=0;for(n=0;n<i.t;++n)t[n+r.t]=r.am(0,i[n],t,n,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&H.ZERO.subTo(t,t)}function dt(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var i=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,i,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}function ft(e,t,r){var i=e.abs();if(!(i.t<=0)){var n=this.abs();if(n.t<i.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=z());var s=z(),a=this.s,o=e.s,c=this.DB-nt(i[i.t-1]);c>0?(i.lShiftTo(c,s),n.lShiftTo(c,r)):(i.copyTo(s),n.copyTo(r));var l=s.t,h=s[l-1];if(0!=h){var u=h*(1<<this.F1)+(l>1?s[l-2]>>this.F2:0),d=this.FV/u,f=(1<<this.F1)/u,p=1<<this.F2,_=r.t,g=_-l,m=null==t?z():t;for(s.dlShiftTo(g,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),H.ONE.dlShiftTo(l,m),m.subTo(s,s);s.t<l;)s[s.t++]=0;for(;--g>=0;){var y=r[--_]==h?this.DM:Math.floor(r[_]*d+(r[_-1]+p)*f);if((r[_]+=s.am(0,y,r,g,0,l))<y)for(s.dlShiftTo(g,m),r.subTo(m,r);r[_]<--y;)r.subTo(m,r)}null!=t&&(r.drShiftTo(l,t),a!=o&&H.ZERO.subTo(t,t)),r.t=l,r.clamp(),c>0&&r.rShiftTo(c,r),0>a&&H.ZERO.subTo(r,r)}}}function pt(e){var t=z();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(H.ZERO)>0&&e.subTo(t,t),t}function _t(e){this.m=e}function gt(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function mt(e){return e}function yt(e){e.divRemTo(this.m,null,e)}function vt(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function bt(e,t){e.squareTo(t),this.reduce(t)}function wt(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return t=t*(2-(15&e)*t)&15,t=t*(2-(255&e)*t)&255,t=t*(2-((65535&e)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function St(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function Et(e){var t=z();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(H.ZERO)>0&&this.m.subTo(t,t),t}function Ct(e){var t=z();return e.copyTo(t),this.reduce(t),t}function At(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],i=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e[r]+=this.m.am(0,i,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function It(e,t){e.squareTo(t),this.reduce(t)}function Tt(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function xt(){return 0==(this.t>0?1&this[0]:this.s)}function Bt(e,t){if(e>4294967295||1>e)return H.ONE;var r=z(),i=z(),n=t.convert(this),s=nt(e)-1;for(n.copyTo(r);--s>=0;)if(t.sqrTo(r,i),(e&1<<s)>0)t.mulTo(i,n,r);else{var a=r;r=i,i=a}return t.revert(r)}function kt(e,t){var r;return r=256>e||t.isEven()?new _t(t):new St(t),this.exp(e,r)}function Rt(){this.i=0,this.j=0,this.S=new Array}function Ut(e){var t,r,i;for(t=0;256>t;++t)this.S[t]=t;for(r=0,t=0;256>t;++t)r=r+this.S[t]+e[t%e.length]&255,i=this.S[t],this.S[t]=this.S[r],this.S[r]=i;this.i=0,this.j=0}function Dt(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}function Nt(){return new Rt}function Lt(e){El[Cl++]^=255&e,El[Cl++]^=e>>8&255,El[Cl++]^=e>>16&255,El[Cl++]^=e>>24&255,Cl>=Al&&(Cl-=Al)}function Ot(){Lt((new Date).getTime())}function Pt(){if(null==Sl){for(Ot(),Sl=Nt(),Sl.init(El),Cl=0;Cl<El.length;++Cl)El[Cl]=0;Cl=0}return Sl.next()}function Ft(e){var t;for(t=0;t<e.length;++t)e[t]=Pt()}function qt(){}function Mt(e,t){return new H(e,t)}function Ht(e,t){if(t<e.length+11)return alert("Message too long for RSA"),null;for(var r=new Array,i=e.length-1;i>=1&&t>0;){var n=e[i--],s=e[i--];r[--t]=(W(s,0)<<4)+W(n,0)}r[--t]=0;for(var a=new qt,o=new Array;t>2;){for(o[0]=0;0==o[0];)a.nextBytes(o);r[--t]=o[0]}return r[--t]=2,r[--t]=0,new H(r)}function jt(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function zt(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Mt(e,16),this.e=parseInt(t,16)):alert("Invalid RSA public key")}function Kt(e){return e.modPowInt(this.e,this.n)}function Vt(e){var t=Ht(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var i=r.toString(16);return 0==(1&i.length)?i:"0"+i}function Gt(){var e=z();return this.copyTo(e),e}function Yt(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function Wt(){return 0==this.t?this.s:this[0]<<24>>24}function Qt(){return 0==this.t?this.s:this[0]<<16>>16}function Xt(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function Jt(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function Zt(e){if(null==e&&(e=10),0==this.signum()||2>e||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),i=J(r),n=z(),s=z(),a="";for(this.divRemTo(i,n,s);n.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,n.divRemTo(i,n,s);return s.intValue().toString(e)+a}function $t(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),i=Math.pow(t,r),n=!1,s=0,a=0,o=0;o<e.length;++o){var c=W(e,o);0>c?"-"==e.charAt(o)&&0==this.signum()&&(n=!0):(a=t*a+c,++s>=r&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),n&&H.ZERO.subTo(this,this)}function er(e,t,r){if("number"==typeof t)if(2>e)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(H.ONE.shiftLeft(e-1),cr,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(H.ONE.shiftLeft(e-1),this);else{var i=new Array,n=7&e;i.length=(e>>3)+1,t.nextBytes(i),n>0?i[0]&=(1<<n)-1:i[0]=0,this.fromString(i,256)}}function tr(){var e=this.t,t=new Array;t[0]=this.s;var r,i=this.DB-e*this.DB%8,n=0;if(e-->0)for(i<this.DB&&(r=this[e]>>i)!=(this.s&this.DM)>>i&&(t[n++]=r|this.s<<this.DB-i);e>=0;)8>i?(r=(this[e]&(1<<i)-1)<<8-i,r|=this[--e]>>(i+=this.DB-8)):(r=this[e]>>(i-=8)&255,0>=i&&(i+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t}function rr(e){return 0==this.compareTo(e)}function ir(e){return this.compareTo(e)<0?this:e}function nr(e){return this.compareTo(e)>0?this:e}function sr(e,t,r){var i,n,s=Math.min(e.t,this.t);for(i=0;s>i;++i)r[i]=t(this[i],e[i]);if(e.t<this.t){for(n=e.s&this.DM,i=s;i<this.t;++i)r[i]=t(this[i],n);r.t=this.t}else{for(n=this.s&this.DM,i=s;i<e.t;++i)r[i]=t(n,e[i]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}function ar(e,t){return e&t}function or(e){var t=z();return this.bitwiseTo(e,ar,t),t}function cr(e,t){return e|t}function lr(e){var t=z();return this.bitwiseTo(e,cr,t),t}function hr(e,t){return e^t}function ur(e){var t=z();return this.bitwiseTo(e,hr,t),t}function dr(e,t){return e&~t}function fr(e){var t=z();return this.bitwiseTo(e,dr,t),t}function pr(){for(var e=z(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}function _r(e){var t=z();return 0>e?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function gr(e){var t=z();return 0>e?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function mr(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function yr(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+mr(this[e]);return this.s<0?this.t*this.DB:-1}function vr(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function br(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=vr(this[r]^t);return e}function wr(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this[t]&1<<e%this.DB)}function Sr(e,t){var r=H.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}function Er(e){return this.changeBit(e,cr)}function Cr(e){return this.changeBit(e,dr)}function Ar(e){return this.changeBit(e,hr)}function Ir(e,t){for(var r=0,i=0,n=Math.min(e.t,this.t);n>r;)i+=this[r]+e[r],t[r++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i+=e.s;r<this.t;)i+=this[r],t[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<e.t;)i+=e[r],t[r++]=i&this.DM,i>>=this.DB;i+=e.s}t.s=0>i?-1:0,i>0?t[r++]=i:-1>i&&(t[r++]=this.DV+i),t.t=r,t.clamp()}function Tr(e){var t=z();return this.addTo(e,t),t}function xr(e){var t=z();return this.subTo(e,t),t}function Br(e){var t=z();return this.multiplyTo(e,t),t}function kr(){var e=z();return this.squareTo(e),e}function Rr(e){var t=z();return this.divRemTo(e,t,null),t}function Ur(e){var t=z();return this.divRemTo(e,null,t),t}function Dr(e){var t=z(),r=z();return this.divRemTo(e,t,r),new Array(t,r)}function Nr(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function Lr(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}function Or(){}function Pr(e){return e}function Fr(e,t,r){e.multiplyTo(t,r)}function qr(e,t){e.squareTo(t)}function Mr(e){return this.exp(e,new Or)}function Hr(e,t,r){var i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;var n;for(n=r.t-this.t;n>i;++i)r[i+this.t]=this.am(0,e[i],r,i,0,this.t);for(n=Math.min(e.t,t);n>i;++i)this.am(0,e[i],r,i,0,t-i);r.clamp()}function jr(e,t,r){--t;var i=r.t=this.t+e.t-t;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(t-this.t,0);i<e.t;++i)r[this.t+i-t]=this.am(t-i,e[i],r,0,0,this.t+i-t);r.clamp(),r.drShiftTo(1,r)}function zr(e){this.r2=z(),this.q3=z(),H.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function Kr(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=z();return e.copyTo(t),this.reduce(t),t}function Vr(e){return e}function Gr(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function Yr(e,t){e.squareTo(t),this.reduce(t)}function Wr(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function Qr(e,t){var r,i,n=e.bitLength(),s=J(1);if(0>=n)return s;r=18>n?1:48>n?3:144>n?4:768>n?5:6,i=8>n?new _t(t):t.isEven()?new zr(t):new St(t);var a=new Array,o=3,c=r-1,l=(1<<r)-1;if(a[1]=i.convert(this),r>1){var h=z();for(i.sqrTo(a[1],h);l>=o;)a[o]=z(),i.mulTo(h,a[o-2],a[o]),o+=2}var u,d,f=e.t-1,p=!0,_=z();for(n=nt(e[f])-1;f>=0;){for(n>=c?u=e[f]>>n-c&l:(u=(e[f]&(1<<n+1)-1)<<c-n,f>0&&(u|=e[f-1]>>this.DB+n-c)),o=r;0==(1&u);)u>>=1,--o;if((n-=o)<0&&(n+=this.DB,--f),p)a[u].copyTo(s),p=!1;else{for(;o>1;)i.sqrTo(s,_),i.sqrTo(_,s),o-=2;o>0?i.sqrTo(s,_):(d=s,s=_,_=d),i.mulTo(_,a[u],s)}for(;f>=0&&0==(e[f]&1<<n);)i.sqrTo(s,_),d=s,s=_,_=d,--n<0&&(n=this.DB-1,--f)}return i.revert(s)}function Xr(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var i=t;t=r,r=i}var n=t.getLowestSetBit(),s=r.getLowestSetBit();if(0>s)return t;for(s>n&&(s=n),s>0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function Jr(e){if(0>=e)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var i=this.t-1;i>=0;--i)r=(t*r+this[i])%e;return r}function Zr(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return H.ZERO;for(var r=e.clone(),i=this.clone(),n=J(1),s=J(0),a=J(0),o=J(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(e,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),t?(a.isEven()&&o.isEven()||(a.addTo(this,a),o.subTo(e,o)),a.rShiftTo(1,a)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);r.compareTo(i)>=0?(r.subTo(i,r),t&&n.subTo(a,n),s.subTo(o,s)):(i.subTo(r,i),t&&a.subTo(n,a),o.subTo(s,o))}return 0!=i.compareTo(H.ONE)?H.ZERO:o.compareTo(e)>=0?o.subtract(e):o.signum()<0?(o.addTo(e,o),o.signum()<0?o.add(e):o):o}function $r(e){var t,r=this.abs();if(1==r.t&&r[0]<=xl[xl.length-1]){for(t=0;t<xl.length;++t)if(r[0]==xl[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<xl.length;){for(var i=xl[t],n=t+1;n<xl.length&&Bl>i;)i*=xl[n++];for(i=r.modInt(i);n>t;)if(i%xl[t++]==0)return!1}return r.millerRabin(e)}function ei(e){var t=this.subtract(H.ONE),r=t.getLowestSetBit();if(0>=r)return!1;var i=t.shiftRight(r);e=e+1>>1,e>xl.length&&(e=xl.length);for(var n=z(),s=0;e>s;++s){n.fromInt(xl[Math.floor(Math.random()*xl.length)]);var a=n.modPow(i,this);if(0!=a.compareTo(H.ONE)&&0!=a.compareTo(t)){for(var o=1;o++<r&&0!=a.compareTo(t);)if(a=a.modPowInt(2,this),0==a.compareTo(H.ONE))return!1;if(0!=a.compareTo(t))return!1}}return!0}function ti(e,t){var r=Number(e).toString(16);for(t="undefined"==typeof t||null===t?t=2:t;r.length<t;)r="0"+r;return r}var ri=!1;if("undefined"!=typeof require)var ii=require("buffer").Buffer;var ni=!1,si=!1,ai=!1,oi="",ci=!0,li=!1,hi=!1,ui=!1,di=!1,fi=!1,pi=!1,_i=!1,gi=!1,mi=!1,yi=!1,vi=!1,bi=!1,wi=!1,Si=!0,Ei="undefined"!=typeof WebSocket?!1:ai?!1:!0,Ci=ai,Ci=!1,Ai=!1,Ii=Ei||ai?!1:!0,Ti=!1,xi=!1,Bi=!1;if(Ii&&!Ti){process={},process.on=function(){},process.platform={indexOf:function(){}};var ii=function(){};require=function(e){var t=function(){},r={};switch(r.Rsa=t,r.PEM=t,r.Hash=null,r.Guards=[],r.Relays=[],r.Dirs=[],r.Exit=[],e){case"fs":var i={};return i.openSync=t,i.writeSync=t,i.closeSync=t,i.open=function(e,t,r){r()},i.write=t,i.close=t,i.unlinkSync=t,i.readFileSync=t,i.readFile=t,i.stat=t,i.rename=t,i;case"domain":var n={};return n.create=function(){return{on:function(){},run:function(e){e()}}},n;case"child_process":var s={};return s.exec=t,s;case oi+"crypto.js":return r;case oi+"guards.js":return r;case oi+"relays.js":return r;case oi+"dirs.js":return r;case oi+"exit.js":return r;default:return t}}}var ki=require("fs"),Ri=require("child_process"),Ui=function(e,t){t+=" "+(new Date).toDateString()+" "+(new Date).toTimeString();var r=function(e,r){try{if(e||(ki.write(r,t+"\n",function(){}),ki.close(r)),Ii&&"undefined"!=typeof mo){var i=mo("console");i.innerHTML.length>1e6&&(i.innerHTML="");var n=document.createElement("p");n.className="log",n.innerHTML=t,i.appendChild(n)}}catch(s){}};try{ki.open(oi+On+"-"+e,"a",r)}catch(i){}};process.on("uncaughtException",function(e){var t=ki.openSync("/debug.txt","a");ki.writeSync(t,(new Date).toDateString()+" "+(new Date).toTimeString()),ki.writeSync(t,e.stack),ki.closeSync(t)}),process.on("exit",function(){setTimeout(function(){console.log("Process ended")},0),console.log("About to exit "+(new Date).toDateString()+" "+(new Date).toTimeString())});var Di=console.log.bind(console),Ni=function(e){Ui(ai||ci?"debug-prod.txt":Ai?"debug-prod2.txt":"debug.txt",e),ai||Ai||ci||Di(e)},Li=function(e){Ui(ai||ci?"debug-prod.txt":Ai?"debug-prod2.txt":"debug.txt",e),ai||Ai||ci||Di(e)};console.log=function(e){Ui(ai||ci?"debug-prod.txt":Ai?"debug-prod2.txt":"debug.txt",e),(!ai&&!Ai&&!ci||-1!==process.platform.indexOf("win")&&xi||ri)&&Di(e+" "+(new Date).toDateString()+" "+(new Date).toTimeString())};var Oi,Pi,Fi,qi,Mi,Hi,ji;if(!Ii){if(process.argv&&process.argv.length>1){var zi=process.argv.splice(2);
if(5===zi.length)Oi=zi[0],Pi=zi[1],Fi=zi[2],qi=zi[3],Mi=zi[4];else if(1===zi.length){var zi=zi[0].split(":");ai={},ai.ip=zi[0],ai.OR_port=zi[1],ai.OP_port=zi[2],ai.NB=zi[3],ai.NB_HOP=zi[4],ai.renew=1e3*zi[5],zi[6]&&(ai.inflate=!0),Ei=!1}else{if(oi=zi[0]||"",oi.length){if(-1===process.platform.indexOf("win")){var Ki=oi[oi.length-1];"/"!==Ki&&(oi+="/")}}else Di("Invalid directory parameter");if(xi=!0,Oi="",zi.length>1)if("-P"!==zi[1])Hi=zi[1],zi.length>2&&(ji=!0);else{if(xi=!1,Bi=!0,!(zi.length>2))return;if(isNaN(parseInt(zi[2])))return;qi=parseInt(zi[2])}}}var Vi=function(){console.log("update routers "+(new Date).toDateString()+" "+(new Date).toTimeString());var e=function(){console.log("child_process "+(new Date).toDateString()+" "+(new Date).toTimeString())};Ri.exec("/usr/local/bin/node "+oi+"build-relays_and_dirs7.js",{timeout:12e5},e),Oi&&Ri.exec("/usr/local/bin/node "+oi+"publish2.js "+Oi+" "+Pi+":"+Fi+" "+Mi,{timeout:12e5},e)};xi||Bi||setInterval(Vi,36e5)}if(xi)var Gi,Yi,Wi,Qi=function(e){var t={host:"peersm.com",port:80,path:"/peersmclient/proxy.pac",method:"GET"};Gi="";var r=nn.request(t,function(t){t.on("data",function(e){Gi+=e.toString("utf8")}),t.on("end",function(){e()}),t.on("error",function(){console.log("Error proxy.pac")})});r.end()};else var Qi=function(e){var t=new XMLHttpRequest;return t?(t.open("GET",e,!1),t.send(null),t.responseText):void 0};var Xi,Ji,Zi,$i,en,tn=require("tls"),rn=require("net"),nn=require("http"),sn=(require("url"),require("dns")),an=require("crypto"),on=xi?require(oi+"node_modules/torrent-stream"):{},cn=xi?require(oi+"node_modules/torrent-stream/node_modules/bittorrent-dht/index.js"):{},ln=xi?require(oi+"node_modules/torrent-stream/lib/blocklist.js"):{},hn=[],un="0.0.0.0",dn=1e3,Guards=xi||Bi?{}:require(oi+"guards.js").Guards,fn=xi||Bi?{}:require(oi+"relays.js").Relays,pn=xi||Bi?{}:require(oi+"dirs.js").Dirs,Exit=xi||Bi?{}:require(oi+"exit.js").Exit,_n=!1,gn=!0,mn=gn?null:require(oi+"crypto.js").Rsa,yn=gn?null:require(oi+"crypto.js").PEM,vn=gn?null:require(oi+"crypto.js").Hash,bn=498,wn=65535,Sn={},En=[],Cn={},An={},In={},Tn={},xn={},Bn={},kn={},Rn=[],Un={},Dn={},Nn={},Ln={},On=Fi||(ai?Ci?1:ai.OR_port:Ai?1:0),Pn=Pi||(ai?ai.ip:""),Fn="2679B51C906158F3DF4C59AFD73E2B1FDA6535E1",qn=ai?Ci?1:ai.OP_port:Ai?0:0,Mn="010001",Hn=new ii("00000000000000000000000000000000","hex"),jn=32767,zn=qi||(ai?2:0),Kn=5,Vn=5,Gn=ai?ai.NB_HOP:3,Yn=ji?2:3,Wn="-----BEGIN RSA PUBLIC KEY-----",Qn="-----END RSA PUBLIC KEY-----",Xn=5e3,Jn=1e3,Zn=7e3,$n=3,es=0,ts=0,rs=30,is=ai?ai.NB:12,ns=10,ss=ai?ai.NB:si?20:5,as=!1,os=5,cs=5e3,ls=ai?ai.renew:72e5,hs=36e5,us=36e5,ds=[],fs=[],ps=1e3,_s=100,gs=500,ms=50,ys=.8,vs=15e3,bs=16184,ws=ii,Ss="0d0a",Es=".com",Cs=5e3,As=2e3,Is={},Ts="http:",xs="www.f4116a30c08bbdfd01813b96c909.com",Bs=null,ks=null,Rs=36e6,Us=1e4,Ds=3e5,Ns=9e5,Ls=5,Os=ai?!1:!0,Ps=ai?!1:!0,Fs=ai?!1:!0,qs="",Ms=!1,Hs=1024,js=!0,zs=!1,Ks={},Vs="undefined"!=typeof document?document.location.href:"",Gs=!1,Ys=!0,Ws=!1,Qs=ai?!1:!0,Xs=0,Js=1e5,Zs="Retrieving... ",$s=!0,ea=!0,ta="enc",ra=xi||Bi?null:ki.readFileSync(oi+Oi+"/priv-key.pem"),ia=!1,na=65536,sa=2097152,aa=0,oa=0,ca=0,la=100,ha=0,ua=0,da=0,fa=100,pa=0,_a=0,ga=0,ma=100,ya=0,va=0,ba=0,wa=100,Sa=0,Ea=0,Ca=0,Aa=100,Ia=0,Ta=0,xa=0,Ba=1,ka=1e6,Ra=2e6,Ua=1e3,Da=125,Na=5e5,La="0000000000000000000000000000000000000000",Oa=3e5,Pa=32,Fa=20,qa=24,Ma=.1,Ha=20,ja="6d6f6f76",za="sbl-xbl.spamhaus.org",Ka="/spies.txt",Va="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF",Ga={323:"text/h323","3gp":"video/3gpp",a:"application/octet-stream",acx:"application/internet-property-stream",ai:"application/postscript",aif:"audio/x-aiff",aifc:"audio/x-aiff",aiff:"audio/x-aiff",asc:"application/pgp-signature",asf:"video/x-ms-asf",asr:"video/x-ms-asf",asm:"text/x-asm",asx:"video/x-ms-asf",atom:"application/atom+xml",au:"audio/basic",avi:"video/x-msvideo",axs:"application/olescript",bas:"text/plain",bat:"application/x-msdownload",bcpio:"application/x-bcpio",bin:"application/octet-stream",bmp:"image/bmp",bz2:"application/x-bzip2",c:"text/x-c",cab:"application/vnd.ms-cab-compressed",cat:"application/vnd.ms-pkiseccat",cc:"text/x-c",cdf:"application/x-netcdf",cer:"application/x-x509-ca-cert",cgm:"image/cgm",chm:"application/vnd.ms-htmlhelp","class":"application/octet-stream",clp:"application/x-msclip",cmx:"image/x-cmx",cod:"image/cis-cod",com:"application/x-msdownload",conf:"text/plain",cpio:"application/x-cpio",cpp:"text/x-c",cpt:"application/mac-compactpro",crd:"application/x-mscardfile",crl:"application/pkix-crl",crt:"application/x-x509-ca-cert",csh:"application/x-csh",css:"text/css",csv:"text/csv",cxx:"text/x-c",dcr:"application/x-director",deb:"application/x-debian-package",der:"application/x-x509-ca-cert",diff:"text/x-diff",dir:"application/x-director",djv:"image/vnd.djvu",djvu:"image/vnd.djvu",dll:"application/x-msdownload",dmg:"application/octet-stream",dms:"application/octet-stream",doc:"application/msword",dot:"application/msword",dtd:"application/xml-dtd",dv:"video/x-dv",dvi:"application/x-dvi",dxr:"application/x-director",ear:"application/java-archive",eml:"message/rfc822",eps:"application/postscript",etx:"text/x-setext",evy:"application/envoy",exe:"application/x-msdownload",ez:"application/andrew-inset",f:"text/x-fortran",f77:"text/x-fortran",f90:"text/x-fortran",fif:"application/fractals",flr:"x-world/x-vrml",flv:"video/x-flv","for":"text/x-fortran",gem:"application/octet-stream",gemspec:"text/x-script.ruby",gif:"image/gif",gram:"application/srgs",grxml:"application/srgs+xml",gtar:"application/x-gtar",gz:"application/x-gzip",h:"text/x-c",hdf:"application/x-hdf",hh:"text/x-c",hlp:"application/winhlp",hqx:"application/mac-binhex40",hta:"application/hta",htc:"text/x-component",htm:"text/html",html:"text/html",htt:"text/webviewhtml",ice:"x-conference/x-cooltalk",ico:"image/vnd.microsoft.icon",ics:"text/calendar",ief:"image/ief",ifb:"text/calendar",iges:"model/iges",igs:"model/iges",iii:"application/x-iphone",ins:"application/x-internet-signup",isp:"application/x-internet-signup",iso:"application/octet-stream",jar:"application/java-archive",java:"text/x-java-source",jfif:"image/pipeg",jnlp:"application/x-java-jnlp-file",jp2:"image/jp2",jpe:"image/jpeg",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",kar:"audio/midi",latex:"application/x-latex",lha:"application/octet-stream",lsf:"video/x-la-asf",lsx:"video/x-la-asf",lzh:"application/octet-stream",log:"text/plain",m13:"application/x-msmediaview",m14:"application/x-msmediaview",m3u:"audio/x-mpegurl",m4a:"audio/mp4a-latm",m4b:"audio/mp4a-latm",m4p:"audio/mp4a-latm",m4u:"video/vnd.mpegurl",m4v:"video/mp4",mac:"image/x-macpaint",man:"text/troff",mathml:"application/mathml+xml",mbox:"application/mbox",mdb:"application/x-msaccess",mdoc:"text/troff",me:"text/troff",mesh:"model/mesh",mht:"message/rfc822",mhtml:"message/rfc822",mid:"audio/midi",midi:"audio/midi",mif:"application/vnd.mif",mime:"message/rfc822",mml:"application/mathml+xml",mng:"video/x-mng",mny:"application/x-msmoney",mov:"video/quicktime",movie:"video/x-sgi-movie",mp2:"video/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mp4v:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpg:"video/mpeg",mpga:"audio/mpeg",mpp:"application/vnd.ms-project",mpv2:"video/mpeg",ms:"text/troff",msh:"model/mesh",msi:"application/x-msdownload",mvb:"application/x-msmediaview",mxu:"video/vnd.mpegurl",nc:"application/x-netcdf",nws:"message/rfc822",oda:"application/oda",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",ogg:"application/ogg",p:"text/x-pascal",p10:"application/pkcs10",p12:"application/x-pkcs12",p7b:"application/x-pkcs7-certificates",p7c:"application/x-pkcs7-mime",p7m:"application/x-pkcs7-mime",p7r:"application/x-pkcs7-certreqresp",p7s:"application/x-pkcs7-signature",pac:"text/plain",pas:"text/x-pascal",pbm:"image/x-portable-bitmap",pct:"image/pict",pdb:"chemical/x-pdb",pdf:"application/pdf",pem:"application/x-x509-ca-cert",pfx:"application/x-pkcs12",pgm:"image/x-portable-graymap",pgn:"application/x-chess-pgn",pgp:"application/pgp-encrypted",pic:"image/pict",pict:"image/pict",pkg:"application/octet-stream",pko:"application/ynd.ms-pkipko",pl:"text/x-script.perl",pm:"text/x-script.perl-module",pma:"application/x-perfmon",pmc:"application/x-perfmon",pml:"application/x-perfmon",pmr:"application/x-perfmon",pmw:"application/x-perfmon",png:"image/png",pnm:"image/x-portable-anymap",pnt:"image/x-macpaint",pntg:"image/x-macpaint",pot:"application/vnd.ms-powerpoint",ppm:"image/x-portable-pixmap",pps:"application/vnd.ms-powerpoint",ppt:"application/vnd.ms-powerpoint",prf:"application/pics-rules",ps:"application/postscript",psd:"image/vnd.adobe.photoshop",pub:"application/x-mspublisher",py:"text/x-script.python",qt:"video/quicktime",qti:"image/x-quicktime",qtif:"image/x-quicktime",ra:"audio/x-pn-realaudio",rake:"text/x-script.ruby",ram:"audio/x-pn-realaudio",rar:"application/x-rar-compressed",ras:"image/x-cmu-raster",rb:"text/x-script.ruby",rdf:"application/rdf+xml",rgb:"image/x-rgb",rm:"application/vnd.rn-realmedia",rmi:"audio/mid",roff:"text/troff",rpm:"application/x-redhat-package-manager",rss:"application/rss+xml",rtf:"application/rtf",rtx:"text/richtext",ru:"text/x-script.ruby",s:"text/x-asm",scd:"application/x-msschedule",sct:"text/scriptlet",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",sgm:"text/sgml",sgml:"text/sgml",sh:"application/x-sh",shar:"application/x-shar",sig:"application/pgp-signature",silo:"model/mesh",sit:"application/x-stuffit",skd:"application/x-koan",skm:"application/x-koan",skp:"application/x-koan",skt:"application/x-koan",smi:"application/smil",smil:"application/smil",snd:"audio/basic",so:"application/octet-stream",spc:"application/x-pkcs7-certificates",spl:"application/x-futuresplash",src:"application/x-wais-source",sst:"application/vnd.ms-pkicertstore",stl:"application/vnd.ms-pkistl",stm:"text/html",sv4cpio:"application/x-sv4cpio",sv4crc:"application/x-sv4crc",svg:"image/svg+xml",svgz:"image/svg+xml",swf:"application/x-shockwave-flash",t:"text/troff",tar:"application/x-tar",tbz:"application/x-bzip-compressed-tar",tcl:"application/x-tcl",tex:"application/x-tex",texi:"application/x-texinfo",texinfo:"application/x-texinfo",text:"text/plain",tgz:"application/x-compressed",tif:"image/tiff",tiff:"image/tiff",torrent:"application/x-bittorrent",tr:"text/troff",trm:"application/x-msterminal",tsv:"text/tab-seperated-values",txt:"text/plain",uls:"text/iuls",ustar:"application/x-ustar",vcd:"application/x-cdlink",vcf:"text/x-vcard",vcs:"text/x-vcalendar",vrml:"model/vrml",vxml:"application/voicexml+xml",war:"application/java-archive",wav:"audio/x-wav",wbmp:"image/vnd.wap.wbmp",wbxml:"application/vnd.wap.wbxml",wcm:"application/vnd.ms-works",wdb:"application/vnd.ms-works",webm:"video/webm",wks:"application/vnd.ms-works",wma:"audio/x-ms-wma",wmf:"application/x-msmetafile",wml:"text/vnd.wap.wml",wmls:"text/vnd.wap.wmlscript",wmlsc:"application/vnd.wap.wmlscriptc",wmv:"video/x-ms-wmv",wmx:"video/x-ms-wmx",wps:"application/vnd.ms-works",wri:"application/x-mswrite",wrl:"model/vrml",wrz:"x-world/x-vrml",wsdl:"application/wsdl+xml",xaf:"x-world/x-vrml",xbm:"image/x-xbitmap",xht:"application/xhtml+xml",xhtml:"application/xhtml+xml",xla:"application/vnd.ms-excel",xlc:"application/vnd.ms-excel",xlm:"application/vnd.ms-excel",xls:"application/vnd.ms-excel",xlt:"application/vnd.ms-excel",xml:"application/xml",xof:"x-world/x-vrml",xpm:"image/x-xpixmap",xsl:"application/xml",xslt:"application/xslt+xml",xul:"application/vnd.mozilla.xul+xml",xwd:"image/x-xwindowdump",xyz:"chemical/x-xyz",yaml:"text/yaml",yml:"text/yaml",z:"application/x-compress",zip:"application/zip"};if(Ys&&!Ii)var Ya={};if(Ii&&!Ti){var Gi=Qi("proxy.pac");Fs||(Gi="var FindProxyForUrl="+Gi,eval(Gi),Zi=FindProxyForUrl("http://"+xs,xs,!0))}else ai||(Zi={ip:Pn,port:On,wsport:zn,fing:Fn,o_modulus:"8bd0a81286858b11f2856ac2f3efd8a5e538b2f851a4c02cc717c94ea52418c587cc69515e46b5381d17cd2299cb4c59fae38250898eab31c9b8acfcf02110a96f0f03442ecd34f1befb0604e1ffbb981848534da9f3f23795ed7df047730cb9dab711722ad6504b893cebda2de4b41123d667474a166eba3ead7df8267dda15"});if(Fs){Os=!1,Ps=!1;var Wa=Zi;if(Ws=!0,Qs=!1,xi){var Qa=Hi?1e6*Hi:1e5,Xa=1,Ja=498,Za=50,$a={},eo=1e3,to=2e6,ro=5,io=0,no={};Ei=!1;var so={host:"www.monip.org",path:"/",port:80,method:"GET"},ao=function(e){e._torrent_&&(console.log("destroy torrent stream"),e._torrent_stream.destroy(),delete e._torrent_),e.__ini_dht__&&(console.log("destroying dht"),e.__ini_dht__.destroy()),e.__torrent__&&(console.log("destroying engine"),e.__torrent__.destroy())},oo=function(){var e;try{e=ki.readFileSync(Ka).toString("utf8")}catch(t){console.log("could not read spies")}e&&(hn=JSON.parse(e),Xi=ln(hn),console.log("number of spies in blocklist "+hn.length))},co=nn.request(so,function(e){var t="";e.on("data",function(e){t+=e.toString("utf8")}),e.on("end",function(){if(t)try{var e=t.split("<BR>");e.length&&(e=e[1],e=e.split("<br>"),e.length&&(e=e[0].split(":"),e.length>1&&(un=e[1].trim(),console.log("myip "+un))))}catch(r){}oo()}),e.on("error",function(){oo()})});co.on("error",function(){oo()}),co.end(),no.list=function(e,t){ki.readdir(oi,function(r,i){r||i.forEach(function(r){if(-1===r.indexOf("debug.txt")&&-1===r.indexOf("debug-prod.txt")){var i,n,s=r.split("#");if(s.length>1){var a=s[1].split(".");i=s[0]+(a.length>1?"."+a[1]:""),n=s[1].split(".")[0]}if(i)t||ki.stat(oi+r,function(t,s){if(!t){var a={file_name:r,name:i,name_hash:n,hash:"0000000000000000000000000000000000000000",file_length:s.size,current_length:s.size,type:"application/octet-binary"};e(a)}});else{var o=an.createhash("sha1");o.update(new ii(Date.now().toString()+Zl.localAddress.toString()+Zl.localPort.toString(),"utf8")),o=o.digest("hex");var a=r.split(".");if(a.length){var c=a.pop();if(a.length){var i=a.join("."),l=i+"#"+o+"."+c;ki.rename(oi+r,oi+l,function(){ki.stat(oi+l,function(t,r){if(!t){var n={file_name:l,name:i,name_hash:o,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(n)}})})}}}}})})};var lo=function(){ks&&ks.send_db_info(!0)},ho=function(e){e=e.split("ws://")[1].split(":");var t=e[1],r=e[0];console.log("peersm client "+r+" "+t);var i=new rn.Socket;return i.on("connect",function(){i.key_=an.randomBytes(16).toString("base64");var e="GET / HTTP/1.1\r\n";e+="Host: "+i.remoteAddress+":"+i.remotePort+"\r\n",e+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",e+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",e+="Accept-Language: en-us,en;q=0.5\r\n",e+="Accept-Encoding: gzip, deflate\r\n",e+="Connection: keep-alive, Upgrade\r\n",e+="Sec-WebSocket-Version: 13\r\n",e+="Origin: http://peersm.com\r\n",e+="Sec-WebSocket-Key: "+i.key_+"\r\n",e+="Pragma: no-cache\r\n",e+="Cache-Control: no-cache\r\n",e+="Upgrade: websocket\r\n",e+="\r\n",console.log(e),i.write(e)}),i.on("data",function(e){if(i.connected__){var t=Xc(i.stream_ws__?[i.stream_ws__,e].concatBuffers():e);i.stream_ws__=t[1].length?t[1]:null,i.onmessage({data:t[0]})}else{i.on("end",function(){console.log("websocket_node end"),i.onclose()}),i.on("error",function(){console.log("websocket_node error"),i.onclose()});var r=Bc(e.toString("utf8")),n=r["Sec-WebSocket-Accept"]||r["Sec-Websocket-Accept"];if(n){var s=an.createHash("sha1");s.update(i.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var a=s.digest("base64");n===a?(console.log("Client says : Handshake successfull for "+Zl.remoteAddress+" "+Zl.remotePort),i.write=function(e){i._write(Jc(e,2,!0),null,function(){})},i.send=i.write,i.connected__=!0,i.onopen()):i.end()}else i.end()}}),i.close=i.end,i.connect(t,r),i},uo=function(){};uo.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var fo=function(){};fo.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var po=function(e){this.data=[],this.cursor=0,this.size=e};po.prototype.push=function(e){this.data.push(e),this.cursor+=e.length},po.prototype.unshift=function(e){this.data.unshift(e),this.cursor-=e.length},po.prototype.slice=function(e,t){var r,i,n=t-e,s=0,a=[];if(n>0&&this.data.length){for(n=Math.min(n,this.cursor);n>s;){var o=this.data.shift(),c=o.length;a.push(o),s+=c,this.cursor-=c}return r=a.concatBuffers(),i=r.slice(n),r=r.slice(0,n),this.cursor+=i.length,i.length&&this.data.unshift(i),r}return new ii(0)};var _o=function(e){this.fd=e.fd,this.size=e.size,this.type=e.type,this.cursor=0};_o.prototype.slice=function(e,t){if(t){if(t>e){var r=new ii(t-e);return ki.readSync(this.fd,r,0,t-e,e+this.cursor),r}return new ii(0)}return this.size=this.size-e,this.cursor=e,this};var go=function(){var e={};return e.get=function(e){var t={};return ki.readdir(oi,function(r,i){if(r)t.onsuccess({target:{result:null}});else{for(var n,s=!1,a=i.length,o=0;a>o;o++){var c=i[o];if(-1===c.indexOf("debug.txt")){var l,h,u=c.split("#");if(u.length>1){var d=u[1].split(".");d.length>1&&(n=d[1],l=u[0]+(d.length>1?"."+d[1]:"")),h=u[1].split(".")[0]}if(h===e){s=!0,ki.stat(oi+c,function(e,r){!e&&n?ki.open(oi+c,"r",function(e,i){if(e)t.onsuccess({target:{result:null}});else{var s;n&&(s=Ga[n]),s||(s="application/octet-binary"),console.log(l+" "+h+" "+s);var a={fd:i,size:r.size,type:s};t.onsuccess({target:{result:{file_length:r.size,current_length:r.size,type:s,data:a}}})}}):t.onsuccess({target:{result:null}})});break}}}s||t.onsuccess({target:{result:null}})}}),t},e};Yi=function(){Gi="var FindProxyForUrl="+Gi,eval(Gi);var e=FindProxyForUrl("http://"+xs,xs,!0);Zi=e[1][qo(e[1].length)],Wa=ri?{ip:"37.59.47.27",port:0,wsport:0,fing:"E0671CF9CB593F27CD389CD4DD819BF9448EA834",o_modulus:"ca2a670479816ca562f7afc2667db1811f0efa7d595aa27cf532092a052c697b102c03d8b8dddc276050fe9cad15efe72758d9d9b0f581f5cbfd0be92ecd721711797354006625e74e0f733efee3ee779116efe87da3b5f8c1729e2d0a5f2c4de4d5906b6e383c0a0d8dddbc076cf426423f6f2b6fd46fab9f54fb8e42601a2d",name:"Tor Bridge"}:e[2],ia=!0,fn=Guards,Ya.userAgent="node-Tor",eh()},Wi=function(){var e=function(){console.log("update prox --------"),Gi="var FindProxyForUrl="+Gi,eval(Gi),FindProxyForUrl("http://"+xs,xs,!0)};Qi(e)},Qi(Yi),setInterval(lo,1e4),setInterval(Wi,us)}if(Ii){var no,Qa=0,Xa=1,Ja=498,Za=50,$a={},eo=1e3,to=2e6,ro=5,mo=document.getElementById.bind(document),io=0,yo=document.location.href.split("/"),vo=yo[yo.length-1].split("#")[0],bo=function(e){return e.pageY?e.pageY:e.clientY},wo=function(e){return e.pageX?e.pageX:e.clientX},So=function(e,t,r,i){e.__event=e.__event||{},e.__event[t]&&Eo(e,t,e.__event[t][0],e.__event[t][1]),e.__event[t]=[r,i],e.addEventListener?e.addEventListener(t,r,i):e.attachEvent&&e.attachEvent("on"+t,r)},Eo=function(e,t,r,i){e.addEventListener?e.removeEventListener(t,r,i):e.attachEvent&&e.detachEvent("on"+t,r)},Co=[ta,"exe","com","bin","php","php3","php4","php5","phtml","inc","sql","pl","cgi","py","sh","c","cc","cpp","cxx","h","hpp","java","class","jar","html","html","shtml","dhtml","xhtml","xml","js","css","zip","tar","tgz","gz","bz2","tbz","rar","mp3","wav","3ga","midi","mid","rm","ra","ram","pls","m3u","mkw","webm","avi","mp4","m4v","mpg","mpeg","mov","swf","fla","doc","docx","xls","xlsx","rtf","pdf","txt","ppt","pptx","vcard","vcf","obj","max","3ds","3dm","kml","torrent","gpx","dxf","dwg","wsg","vb","pif","gadget","apk","msi","sxc","123","ots","nb","gsheet","xlr","ods","svgz","cdr","svg","ps","eps","orf","pef","rwl","mrw","mef","fff","erf","dcr","bay","3fr","srf","rw2","nef","cr2","arw","dng","dwt","irs","ait","art","aip","aia","ai","indd","prtpset","ppj","plb","prproj","aetx","aet","aes","aepx","aep","aec","ncorx","ncor","em","abr","csh","psb","psd","as","asc","ascs","aif","aiff","flac","iff","m4a","wma","srt","flv","3g2","3gp","asf","wmv","pcast","xlt","xltm","xltx","ans","ascii","log","odt","wpd","accdb","db","dbf","mdb","pdb","asp","aspx","asx","fnt","otf","ttf","dotx","wps2","dll","fon","cmd","srt"],Ao=["tga","gif","jpg","tiff","jpeg","bmp","png"];Co.forEach(function(e){$a[e]="http://www.peersm.com/img/extensions/"+e+".png"});var Io=function(){var e=new XMLHttpRequest;if(e){e.open("POST","bandwidth.html",!0);var t=Date.now(),r=1e5;e.send(new Uint8Array(r)),e.onreadystatechange=function(){if(4==e.readyState){var r=1e5/((Date.now()-t)/1e3);Qa=parseInt((Qa?(Qa+r)/2:r)/Xa),console.log("bandwidth : "+8*Qa/1e3+" Kbps")}}}};setInterval(Io,18e6),Io()}}fn=Guards;var To=function(){ki.rename(oi+(ai||ci?On+"-debug-prod.txt":Ai?On+"-debug-prod2.txt":On+"-debug.txt"),oi+(ai||ci?On+"-debug-prod.txt":Ai?On+"-debug-prod2.txt":On+"-debug.txt")+".old",function(){})};To(),Ii||xi||Bi||console.log(ai?ai.ip+" OP port "+qn+" OR_port "+On+" OP NB_C "+ss+" OP NB_HOP "+Gn+" OP renew "+ls:Oi+" "+Pi+" "+Fi+" "+qi+" "+Mi);var xo=function(e){var t=e.split("magnet:?xt=urn:btih:");return t.length>1?t[1]:void 0},Bo=function(e,t){for(var r=0,i=!1,n=0;!i;)i=parseInt(e.substr(n,1),16)^parseInt(t.substr(n,1),16),i||(r+=4),n++;for(;8>i;)i<<=1,r++;return r},ko=function(){var e={},t=(this.length,[]);return this.forEach(function(t,r){e[t]=r}),Object.keys(e).forEach(function(e){t.push(e)}),e=null,t},Ro=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Accept-Ranges:bytes",e+="Content-Encoding:gzip\r\n",e+="Content-Length:0\r\n",e+="Content-Type:*\r\n",e+="\r\n"},Uo=function(){var e="HTTP/1.1 410 Gone\r\n";return e+="\r\n"},Do=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Vary: Accept-Encoding\r\n",e+="Keep-Alive: timeout=2, max=100\r\n",e+="Connection: Keep-Alive\r\n",e+="Transfer-Encoding: chunked\r\n",e+="Content-Type: text/html\r\n",e+="\r\n1f\r\n//Outside of authorized domains\r\n0\r\n\r\n"},No=function(e){var t="HTTP/1.1 301 Moved Permanently\r\n";return t+="Location: "+e+"\r\n",t+="\r\n"},Lo=function(e){var t={url:e},r=e.split("/"),i=function(e){if(e.length){var r=e[0];t.host=r,e.shift()}t.rest=e.join("/")};return r.length>1&&""===r[1]?(t.protocol=r[0]?r[0]:Ts,r.shift(),r.shift()):t.protocol=Ts,i(r),t},Oo=function(e){var t=[];return t.push(e.protocol?e.protocol:protocol),t.push(""),e.host&&t.push(e.host),e.rest&&t.push(e.rest),t.join("/")},Po=function(e,t){var r=new ii(Wo(t?new ii(e,"utf8"):new ii(e,"hex"),ih),"hex");return r.toString(t?"hex":"utf8")},Fo=function(e){var t=e.slice(0,1),r=e.slice(1,2),i=e.slice(2,2+r.readUInt());return e=e.slice(r.readUInt()+2),{data:e,addr:{type:t,length:r,value:i}}},qo=function(e){return parseInt(Math.random()*e)},Mo=function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds()+(e.getMilliseconds()>500?1:0),0)},Ho=function(e){var t,r,i=[],n=[],s=[],a=e.nb_hop||Kn;if(a>Kn&&(a=Kn),e.nb_try=e.nb_try||1,e.nb_try>Vn)return void console.log("PATH : createPath : Too many attempts");for(r=Guards.length,t=qo(r),t=Guards[t].split("-"),s.push(t[1]),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),a--,r=fn.length,a--;a;)t=qo(r),-1==i.indexOf(t)&&fn[t].split("-")[1]!=n[0].ip&&(i.push(t),a--);var o=function(e){var t=fn[e].split("-"),r={ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]};s.push(t[1]),n.push(r)};for(i.forEach(o),r=Exit.length,t=qo(r);-1!=s.indexOf(Exit[t].split("-")[1]);)t=qo(r);return t=Exit[t].split("-"),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),n},jo=function(e){e&&(e.queue_&&!e.eof_&&(e.eof_=!0,console.log("clearing "+(e.hash_ini?e.hash_ini:"")),e.queue_.push(fin_.bind(e)),1===e.queue_.length&&e.queue_[0]()),_u(e.query_t0))},zo=function(e){for(var t in e)if(!isNaN(t)&&null!=t&&"function"!=typeof t){var r=e[t];if(r){if(r===ks)for(var i in r)if(!isNaN(i)&&null!=i&&"function"!=typeof i){var n=r[i];n&&jo(n)}console.log("clear_requests circuit destroy"),r.circuit_destroy()}}},Ko=function(e,t){var r="GET /"+t+" HTTP/1.1\r\n";return r+="Host: "+e+"\r\n",r+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",r+="Accept: */*\r\n",r+="Accept-Language: en\r\n",r+="Accept-Encoding: gzip, deflate\r\n",r+="Connection: keep-alive\r\n",r+="\r\n",new ii(r,"utf8")},Vo=function(e,t,r){var i="GET /"+t+" HTTP/1.1\r\n";return i+="Host: "+e+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",i+="Range: bytes="+r+"-\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",new ii(i,"utf8")},Go=function(e,t,r){var i=0;if(e.nbc_=e.nbc_?e.nbc_:0,t){if(e.nbc_===jn)return!1}else if(65534===e.nbc_)return!1;for(;e[i]||0===i;)i=t?r?e.cid?++e.cid%jn:jn:e.cid?++e.cid%jn:1:e.cid?++e.cid%65535:1;return e.cid=i,e.nbc_++,i},Yo=function(e){for(var t="",r=0;5>r;r++){var i=an.createhash("sha1");i.update(new ii(e+"0"+r,"hex")),t+=i.digest("hex")}return new ii(t,"hex")},Wo=function(e,t){var r=an.createcipheriv("aes-128-ctr",t,Hn),i=r.update(e,"hex","hex");return i+=r.final("hex")},Qo=function(e,t){var r=t.slice(0,70),i=t.slice(70),n=ac(16),s=[n,r].concatBuffers(),a=new mn;s=a.encrypt(new ii(e.toString("hex"),"binary"),new ii(Mn,"binary"),new ii(s.toString("binary"),"binary"),"RSA_PKCS1_OAEP_PADDING","hex");var o=Wo(i,n);return[new ii(s,"hex"),new ii(o,"hex")].concatBuffers()},Xo=function(e,t,r){var i=new mn,n=new ii(i.decrypt(e,t,"RSA_PKCS1_OAEP_PADDING","hex"),"hex"),s=n.slice(0,16);return[n.slice(16),new ii(Wo(r,s),"hex")].concatBuffers()},Jo=function(e){if(xi){if(this.fc_t.length){var t=this.fc_t.shift();t()}}else if(e.source==window&&e.data==this.messageName&&(e.stopPropagation(),this.fc_t.length)){var t=this.fc_t.shift();t()}},Zo=function(e,t,r,i){if(r)if(r.stop_)ao(r),r=null,console.log("delete sid 2"),delete this[t];else{if(r._torrent_&&xi&&"undefined"==typeof i){var n=Date.now()-r.start_t0;i=Math.ceil(n*Hi*1e6/1e3/Ja/ys),console.log("first blocks nb "+i)}else i="undefined"==typeof i?ro:i;var s=[];if(r.reader.onload=function(n){if(n.target.result){var a=n.target.result instanceof ArrayBuffer?new Uint8Array(n.target.result):n.target.result;if(a.length)for(var o=0;i>o;o++){if(0===r.stream_window_s){r.cursor-=a.length,r._torrent_&&r._torrent_.unshift(a);break}if(r.stream_window_s--,s.push(a.slice(0,Math.min(a.length,bn))),!(a.length>bn))break;a=a.slice(bn)}}var c=Date.now();r.fc_t.push(function(){$o.call(this,e,s,r,t,c)}.bind(this)),xi?setTimeout(Jo.bind(r),0):window.postMessage("flush","*")}.bind(this),0!==i){var a=e.slice(r.cursor,Math.min(e.size,r.cursor+i*bn));r.cursor+="undefined"!=typeof a.length?a.length:a.size,r.reader.readAsArrayBuffer(a)}else r.reader.onload({target:{result:null}})}},$o=function(e,t,r,i,n){t.forEach(function(e){r.sent_+=e.length;var t=new uc(uc.prototype.RELAY_DB_DATA,i,e,this.last_.Df_hash),n=new lc(this.circId,lc.prototype.RELAY,this.last_.stream_encrypt_forward(t));this.send(n)},this);var s,a=Date.now()-n,o=xi?this.socket_.bufferSize:this.socket_.bufferedAmount,c=parseInt((r.cursor-o)/((Date.now()-r.start_t0)/1e3)),l=8*c,h=ka;if(r.cursor<Ja*eo/2)s=eo/4;else if(l>h)s=0;else if(xi)s=Math.ceil(a*c/1e3/Ja/ys);else{var u=to>o?Math.ceil((to-o)/Ja):0;a&&(s=Math.ceil(a*c/1e3/Ja/ys)),s=s?Math.min(u,s):u}s=l>h?0:o>to?0:s>ro?s:ro,mi&&0!==a&&0!==s&&console.log("real bandwidth "+parseInt(8*c/1e3)+" kbps - advertised bandwidth "+parseInt(8*Qa/1e3)+" kbps time "+a+" nbblocs "+s+" buffered amount "+o+" cursor "+r.cursor+" torrent buffered "+(r._torrent_?r._torrent_.cursor:"")),0!==r.stream_window_s||r.pause_[i]?e.size===r.cursor?(console.log("delete sid"),delete this[i],console.log(parseInt(8*r.cd_length/((Date.now()-r.start_t0)/1e3))+" bps")):this.send_db_data(e,i,s,!0):(console.log(parseInt(8*r.cursor/((Date.now()-r.start_t0)/1e3))+" kbps"),console.log("Pausing download CIC "+this.circId+" for stream "+i+" sent "+r.sent_+" remaining length "+(e.size-r.cursor)+" time "+Date.now()+" buffered amount "+o+" fc_t "+r.fc_t.length),r.pause_[i]=e)},ec=function(e){var t=Go(e),r={};return r.sid_=t,r.received_=0,r.sent_=0,r.stream_window=eo,r.stream_window_s=eo,r.send_data=!0,e[t]=r,r.pause_={},t},tc=function(e){if(e){var t=e.split(".");return t=t.length?t[t.length-1]:""}return"exe"},rc=function(e){var t=e.cid_,r=e.sid_;r&&delete t[r],delete e.cid_,delete e.sid_},ic=function(e){Ph(e.bar_),Ph(nu),Ph(Uh)},nc=function(e,t,r){console.log("search in bittorrent");for(var i=Rn;i.length;)if(i[0].socket_)if(i[0].socket_.remoteAddress){if(!i[0].destroyed_)break;console.log("ORDB remove destroyed CIC fac "+i[0].circId),i.shift()}else console.log("ORDB remove fac "+i[0].circId),i[0].circuit_destroy(),i.shift();else console.log("ORDB remove fac "+i[0].circId),i[0].circuit_destroy(),i.shift();if(i.length)try{var n=i[0];i.shift(),i.push(n);var s=ac(16),a={d_length:t,hash_:new ii(r,"hex")};Un[s.toString("hex")]=[this,e,i,a,0],n.send_db_query(a,s)}catch(o){this.send_db_end(0,e)}else this.send_db_end(0,e)},sc=function(e){if("open"===e._stream_.readyState&&!e._source_.updating)if(e.append_buffer.length){e.append_cursor++;var t=e.append_buffer.shift();e.mp4box;try{e._source_.appendBuffer(t)}catch(r){console.log("error updateend ")}}else e.append_cursor=0};ii.prototype.readUInt=function(){switch(this.length){case 1:return this[0];case 2:return this.readUInt16BE(0);case 4:return this.readUInt32BE(0);default:return 0}},ii.prototype.writeUInt=function(e){switch(this.length){case 1:this.writeUInt8(e,0);break;case 2:this.writeUInt16BE(e,0);break;case 4:this.writeUInt32BE(e,0)}return this},ii.prototype.map=function(e){var t=e.length;Gs||Ii?(this.set(e),this.fill(0,t)):(e.copy(this),this.fill(0,t))},Array.prototype.concatBuffers2=function(){var e=[];return this.forEach(function(t){e.push(t.toString("hex"))}),new ii(e.join(""),"hex")},Array.prototype.concatBuffers1=function(){var e=0;this.forEach(function(t){e+=t.length});var t=new ii(e),r=0;return this.forEach(function(e){for(var i=e.length,n=0;i>n;n++)t[r]=e[n],r++}),t},Array.prototype.concatBuffers=function(){if(Gs||Ii){var e=0;this.forEach(function(t){e+=t.length});var t=new ii(e),r=0;return this.forEach(function(e){var i=e.length;t.set(e,r),r+=i}),t}return ii.concat(this)},ii.prototype.parse=function(e){e.WS_OP_&&e.ws_;for(var t=e.stream_tor_;t.length;){var r,i=t.slice(0,2),n=t.slice(2,3),s=i.readUInt();if(e[s]&&e[s].clear_timers(),7==n.readUInt()||n.readUInt()>=128){var a=t.length;if(!(a>=5))break;var o=t.readUInt16BE(3);if(!(a>=o+5))break;r=t.slice(5,o+5),t=t.slice(o+5)}else{if(!(t.length>=512))break;r=t.slice(3,512),t=t.slice(512)}var c=new lc(i.readUInt(),n.readUInt(),r,!0);gc.bind(e)([c])}e.stream_tor_=t;var l=e.queue_;e.WS_OP_&&e.ws_,l.shift(),l.length&&l[0]()},ii.prototype.parseTLS=function(e){for(var t,r=e.stream_tor_;r.length;){var i=r.length;if(!(i>=5))break;var n=r.readUInt16BE(3);if(!(i>=n+5))break;if(t=r.slice(0,n+5),r=r.slice(n+5),22!==t[0]||e.ccs_)20===t[0]&&(e.ccs_=!0),e.process(t);else for(var s=t.readUInt(1,2),a=t.readUInt(3,3),o=t.slice(5,a);o.length;){var i=o.length;if(!(i>=4))break;var c=o.readUInt(1,3);if(!(i>=c+4))break;var l=[new ii(1).writeUInt(22),new ii(2).writeUInt(s),new ii(2).writeUInt(c+4),o.slice(0,c+4)].concatBuffers();e.process(l),o=o.slice(c+4)}}e.stream_tor_=r;var h=e.queue_;h.shift(),h.length&&h[0]()},(Ii||Gs)&&(ii=function(e,t){if(t||"string"!=typeof e||(t="utf8"),e instanceof Array||!isNaN(e)&&!t)return new Uint8Array(e);if("utf8"===t)return new q("utf-8").encode(e);if("hex"===t)try{for(var r=new Uint8Array(e.length/2),i=e.length,n=0;i>n;n+=2)r[n/2]=parseInt(e[n]+e[n+1],16)}catch(s){return new Uint8Array}if("binary"===t)for(var r=new Uint8Array(e.length),i=r.length,n=0;i>n;n++)r[n]=e.charCodeAt(n);return r},ws.isBuffer=function(e){return e instanceof this||e instanceof Uint8Array},Uint8Array.prototype.isBuffer=ws.prototype.isBuffer,Uint8Array.prototype.parse=ws.prototype.parse,Uint8Array.prototype.parseTLS=ws.prototype.parseTLS,ii.isBuffer=function(e){return e instanceof Uint8Array
},Uint8Array.prototype.slice=function(e,t){return t?this.subarray(e,t):this.subarray(e)},Uint8Array.prototype.map=function(e){var t=e.length;this.set(e),this.fill(0,t)},Uint8Array.prototype.readUInt=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16BE(e);case 3:return this.readUInt24BE(e);case 4:return this.readUInt32BE(e);default:return 0}},Uint8Array.prototype.readUIntLE=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16LE(e);case 4:return this.readUInt32LE(e);default:return 0}},Uint8Array.prototype.writeUInt=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16BE(e,t);break;case 3:this.writeUInt24BE(e,t);break;case 4:this.writeUInt32BE(e,t)}return this},Uint8Array.prototype.writeUIntLE=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16LE(e,t);break;case 4:this.writeUInt32LE(e,t)}return this},Uint8Array.prototype.fill=function(e,t){for(var r=this.length,i=t;r>i;i++)this[i]=e},Uint8Array.prototype.readUInt16BE=function(e){return this[e]<<8^this[e+1]},Uint8Array.prototype.readUInt24BE=function(e){return this[e]<<16^this[e+1]<<8^this[e+2]},Uint8Array.prototype.readUInt32BE=function(e){return this[e]<<24^this[e+1]<<16^this[e+2]<<8^this[e+3]},Uint8Array.prototype.readUInt16LE=function(e){return this[e]^this[e+1]<<8},Uint8Array.prototype.readUInt32LE=function(e){return this[e]^this[e+1]<<8^this[e+2]<<16^this[e+3]<<24},Uint8Array.prototype.writeUInt8=function(e,t){this[t]=e},Uint8Array.prototype.writeUInt16BE=function(e,t){this[t]=e>>8&255,this[t+1]=255&e},Uint8Array.prototype.writeUInt24BE=function(e,t){this[t]=e>>16&255,this[t+1]=e>>8&255,this[t+2]=255&e},Uint8Array.prototype.writeUInt32BE=function(e,t){this[t]=e>>24&255,this[t+1]=e>>16&255,this[t+2]=e>>8&255,this[t+3]=255&e},Uint8Array.prototype.writeUInt16LE=function(e,t){this[t]=255&e,this[t+1]=e>>8&255},Uint8Array.prototype.writeUInt32LE=function(e,t){this[t]=255&e,this[t+1]=e>>8&255,this[t+2]=e>>16&255,this[t+3]=e>>24&255},Uint8Array.prototype.toString=function(e){var t=this.length,r=[];if("utf8"===e)return new M("utf-8").decode(this);if("hex"===e)for(var i=0;t>i;i++){var n=this[i].toString(16);r.push(1===n.length?"0"+n:n)}return"binary"===e?String.fromCharCode.apply(null,this):r.join("")},Hn=new ii("00000000000000000000000000000000","hex"));var ac=function(e){return an.randomBytes(e)},oc=function(e){for(var t=e.length,r=[],i=0;t>i;i++)r.push(e[i]);return r.join(".")},cc=function(e){return new ii(e.split("."))},lc=function(e,t,r,i){this.CircID=new ii(2).writeUInt(e),this.Command=new ii(1).writeUInt(t),this.Length=new ii(2).writeUInt(r.length),this.Payload=i?_c.bind(this)(r):r};lc.prototype={PADDING:0,CREATE:1,CREATED:2,RELAY:3,DESTROY:4,CREATE_FAST:5,CREATED_FAST:6,NETINFO:8,RELAY_EARLY:9,VERSIONS:7,CREATE_FAST_WS:120,CREATED_FAST_WS:121,VPADDING:128,CERTS:129,AUTH_CHALLENGE:130,AUTHENTICATE:131,AUTHORIZE:132,RELAY_WS:190,versions_cell_decode:function(e){for(var t=[];e.length;)t.push(e.slice(0,2)),e=e.slice(2);return t},certs_cell_decode:function(e){var t=e.slice(0,1);e=e.slice(1);var r=[];for(r.push(t);e.length;){var i={};i.CertType=e.slice(0,1),i.CLEN=e.slice(1,3);var n=i.CLEN.readUInt();i.Certificate=e.slice(3,3+n),e=e.slice(3+n),r.push(i)}return r},auth_challenge_cell_decode:function(e){var t=[],r={};return r.Challenge=e.slice(0,32),r.N_Methods=e.slice(32,34),r.Methods=e.slice(34,34+r.N_Methods.readUInt()),t.push(r),t},netinfo_cell_decode:function(e){var t=[],r={};r.Timestamp=e.slice(0,4);var i=Fo(e.slice(4));e=i.data,r.other_OR=i.addr,r.nb_addresses=e.slice(0,1),r.this_ORs=[],e=e.slice(1);for(var n=r.nb_addresses.readUInt(),s=0;n>s;s++){var a=Fo(e);r.this_ORs.push(a.addr),e=a.data}return t.push(r),t},create_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),t.push(r),t},create_fast_ws_cell_decode:function(e){var t=[],r={},i=new mn;try{r.key_material=new ii(i.decrypt(ra,e.slice(0,128).toString("hex"),"","hex"),"hex"),t.push(r)}catch(n){console.log("create fast pb decrypting")}return t},created_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),r.derivative_key_data=e.slice(20,40),t.push(r),t},created_fast_ws_cell_decode:function(e){var t=[],r={};return r.key=e.slice(0,40),t.push(r),t},create_cell_decode:function(e){var t=[],r={};return r.M_=e.slice(0,128),r.M2_=e.slice(128,186),t.push(r),t},created_cell_decode:function(e){var t=[],r={};return r.dh_data=e.slice(0,128),r.derivative_key_data=e.slice(128,148),t.push(r),t}};var hc=function(e){e&&(this.OP_=!0,this.server_=e[0],this.path_=e,this.nb_=0,this.conn_=0,this.sent_=0,this.received_=0,this.circuit_window=ps,this.circuit_window_s=ps,this.stream_=[],this.pause_={},this.time_=(new Date).valueOf(),this.resolved_failed=0),this.perf_=0,this.time_average=0};hc.prototype={padding_cell_handle:function(){this.next_&&this.next_.keep_alive()},versions_cell_handle:function(e){var t=this.socket_;if(!this.OR_||this.onion_)e.Payload.forEach(function(e){3==e.readUInt()&&(t.handshake_=3)},this),t.handshake_||this.end("v3 handshake not supported","handshake");else{var e=new lc(this.circId,lc.prototype.VERSIONS,new ii(2).writeUInt(3));if(this.send(e),!t.ws_){var r={};r.CertType=new ii(1).writeUInt(1),r.Certificate=new ii(Ul(oi+Oi+"/pub-key.pem",oi+Oi+"/priv-id-key.pem","der",t.certid_,t.cert_date,t.cert_subject,t.cert_issuer),"hex"),r.CLEN=new ii(2).writeUInt(r.Certificate.length),r=[r.CertType,r.CLEN,r.Certificate].concatBuffers();var i={};i.CertType=new ii(1).writeUInt(2),i.Certificate=new ii(Ul(oi+Oi+"/pub-id-key.pem",oi+Oi+"/priv-id-key.pem","der",parseInt(ac(8).toString("hex"),16),t.cert_date,t.cert_issuer,t.cert_issuer),"hex"),i.CLEN=new ii(2).writeUInt(i.Certificate.length),i=[i.CertType,i.CLEN,i.Certificate].concatBuffers(),e=new lc(this.circId,lc.prototype.CERTS,[new ii(1).writeUInt(2),r,i].concatBuffers()),this.send(e);var n={};n.Challenge=ac(32),n.N_Methods=new ii(2).writeUInt(1),n.Methods=new ii(2).writeUInt(0),e=new lc(this.circId,lc.prototype.AUTH_CHALLENGE,[n.Challenge,n.N_Methods,n.Methods].concatBuffers()),this.send(e)}var s=[],a={};a.Timestamp=new ii(4).writeUInt(parseInt((new Date).valueOf()/1e3)),a.other_OR={type:new ii("04","hex"),length:new ii("04","hex"),value:cc(t.remoteAddress)},a.nb_addresses=new ii("01","hex"),a.this_ORs=[{type:new ii("04","hex"),length:new ii("04","hex"),value:cc(t.address().address)}],s.push(a),e=new lc(this.circId,lc.prototype.NETINFO,s),this.send(e)}},certs_cell_handle:function(){},auth_challenge_cell_handle:function(){},netinfo_cell_handle:function(e){var t={};if(!this.OR_f){var r=this.socket_.remoteAddress;if(e.Length=0,t.Timestamp=new ii(4).writeUInt(parseInt((new Date).valueOf()/1e3)),e.Length+=4,e.Payload[0].this_ORs.forEach(function(i){(oc(i.value)==r||this)&&(t.other_OR=i,e.Length+=i.length,this._OR_ip_verified=!0)},this),this._OR_ip_verified)if(t.nb_addresses=new ii(1).writeUInt(1),e.Length++,t.this_ORs=[e.Payload[0].other_OR],e.Length+=t.this_ORs[0].length,e.Payload=[t],this.send(e),this.socket_.handshake=!0,this.OP_)if(this.setCircId(),!Qs&&!Ws||!Os&&!Fs||Bs&&!ia)this.create();else if(Ii&&Zi&&(!Bs&&$i||!ia)){this.X_=ac(20);var i=new ii(Ql.encrypt(this.X_.toString("hex")),"hex"),n=new lc(this.circId,lc.prototype.CREATE_FAST_WS,i);this.send(n)}else{this.X_=ac(20);var n=new lc(this.circId,lc.prototype.CREATE_FAST,this.X_);this.send(n)}else this.setCircId(),this.create();else this.end("remote IP does not match","handshake")}},create_fast_cell_handle:function(e){console.log("OR receive create fast from "+this.socket_.remoteAddress+" CIC "+this.circId+" sending created_fast"),this.X_=e.Payload[0].key_material,this.Y_=ac(20);var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t),i=new lc(this.circId,lc.prototype.CREATED_FAST,[this.Y_,r].concatBuffers());this.send(i)},create_fast_ws_cell_handle:function(e){if(e.Payload.length){this.X_=e.Payload[0].key_material,this.Y_=ac(20);var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t),i=new lc(this.circId,lc.prototype.CREATED_FAST_WS,new ii(Wo([this.Y_,r].concatBuffers(),this.X_.slice(0,16)),"hex"));this.send(i)}else this.destroy(1)},created_handle:function(){if(this.conn_++,(Qs||Ws)&&(Os||Fs)&&!Bs&&$i&&this.request_.params_.ws===$l&&delete this.next_,this.next_)this.extended_=this.next_,this.extend();else if((Qs||Ws)&&(Os||Fs)){if(console.log("CIRC : CIRCUIT ESTABLISHED FAST - CID "+this.circId+" "+(this.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(this.prev_?this.prev_.server_.ip:"NONE")+" LAST OR : "+this.server_.ip),Bs=this,Os)for(var e in Is)Is[e].associated||Zl.associate(this.first_,e);!as&&Zi&&(Os?xc({params_:{OP:!0,nb_hop:Gn,ws:Zl}}):Zl.db_cid_launched||xc({params_:{OP:!0,nb_hop:Yn,ws:Zl,db:!0}})),this.first_.last_=this}else console.log("CIRC : CAN NOT HAVE ONLY ONE NODE IN THE PATH"),this.end("CAN NOT HAVE ONLY ONE NODE IN THE PATH")},created_fast_cell_handle:function(e){console.log("created fast received CIC "+this.circId),this.Y_=e.Payload[0].key_material;var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t);r.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},created_fast_ws_cell_handle:function(e){var t=new ii(Wo(e.Payload[0].key,this.X_.slice(0,16)),"hex");this.Y_=t.slice(0,20);var r=[this.X_,this.Y_].concatBuffers(),i=this.circuit_keys(r);i.toString("hex")!=t.slice(20,40).toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},create_cell_handle:function(e){var t=e.Payload[0].M_,r=e.Payload[0].M2_;this.X_=Xo(this.socket_.privkey_.toString("utf-8"),t.toString("hex"),r);var i=an.getDiffieHellman("modp2");i.generateKeys(),this.Y_=new ii(i.getPublicKey("hex"),"hex");var n=new ii(i.computeSecret(this.X_,"hex","hex"),"hex"),s=this.circuit_keys(n),a=new lc(this.circId,lc.prototype.CREATED,[this.Y_,s].concatBuffers());this.send(a)},created_cell_handle:function(e){if(this.OP_){console.log("OP created "+this.circId);var t=this.extended_?this.extended_:this;if(t.Y_=e.Payload[0].dh_data,Ii&&!t.DH_.computeSecret){var r=new ii(1).writeUInt(2);An[t.cid_hex]=function(t){var r=this.extended_?this.extended_:this,i=t.toString("hex");r.DH_.computeSecret=function(){return i},delete An[r.cid_hex],this.created_cell_handle(e)}.bind(this);var i=new uc(uc.prototype.RELAY_INFO,0,[r,new ii(t.cid_hex,"hex"),t.Y_].concatBuffers(),Bs.Df_hash),n=new lc(Bs.circId,lc.prototype.RELAY_WS,Bs.stream_encrypt_forward(i));return void Bs.send(n)}var s=new ii(t.DH_.computeSecret(t.Y_,"hex","hex"),"hex"),a=t.circuit_keys(s);if(a.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex"))t.end("KH key does not match","created_extended_key");else if(this.conn_++,t.ok_=!0,t.next_)t.extended_=t.next_,t.extend();else{if(Qs&&Os)for(var o in Is)Is[o].associated||Zl.associate(this.first_,o);Fs&&this.first_.request_.params_.db&&!ks?(ks=this.first_,ks.send_db_info(),ks.process=ks.send_db_query,setInterval(this.send_db_info.bind(ks),Rs),console.log(t?"CIRC : CIRCUIT ESTABLISHED -CID "+t.circId+" "+(t.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(t.prev_?t.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED":"OP created lcirc is undefined")):this.first_.request_.params_.db?(console.log("created handle circuit destroy"),this.first_.circuit_destroy()):(console.log(t?Fs?"CIRC : CIRCUIT ESTABLISHED - CID "+t.circId+" "+(t.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(t.prev_?t.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED":"CIRC : CIRCUIT ESTABLISHED - CID "+t.circId+" "+(t.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(t.prev_?t.prev_.server_.ip:"NONE")+" LAST OR : "+t.server_.ip:"OP created lcirc is undefined"),ts++),ss>ts&&(Ws||Qs?Os||ks?(console.log("create new dl circuit"),xc({params_:{OP:!0,nb_hop:Gn,ws:Zl}})):xc({params_:{OP:!0,nb_hop:Yn,ws:Zl,db:!0}}):xc({params_:{OP:!0,nb_hop:Gn}})),this.first_.last_=t,this.first_.process();var c=En;if(c)for(;c.length;)this.first_.process(c[0]),c.shift()}}else if(this.prev_){console.log("OR process extend - created received from "+this.server_.ip+" sending relay_extended to CIC "+(this.prev_?this.prev_.circId:"undefined"));var l=e.Payload[0],i=new uc(uc.prototype.RELAY_EXTENDED,0,[l.dh_data,l.derivative_key_data].concatBuffers(),this.prev_.Db_hash);this.stream_encrypt_or_b(i.toBuffer(),lc.prototype.RELAY,!0)}else this.next_&&this.next_.destroy()},extend_cell_handle:function(e){if(Wa&&this.socket_.address().port===On&&this.OR_f)console.log("ORDB - Do not extend send destroy"),this.circuit_destroy();else{var t=oc(e.slice(0,4)),r=e.slice(4,6).readUInt(),i=e.slice(6,192),n=e.slice(192,212).toString("hex"),s=new hc;if(s.server_={ip:t,port:r,fing:n},console.log("OR process extend toward "+s.server_.ip+" "+s.server_.port+" "+s.server_.fing),this.next_=s,s.prev_=this,s.onion_=i,s.OR_=!0,s.way_="socket out",s.circId=0,In[t])s.socket_=In[t],s.socket_.stream_tor_=new ii(0),s.setCircId(),s.create(),console.log("OUTGOING OR SOCKET EXTEND : ---------Socket already exists send create ------------ CIC "+s.circId+" for "+s.server_.ip);else{var a="www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".net",o="www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".com",c={key:ki.readFileSync(oi+Oi+"/priv-key.pem"),cert:Ul(oi+Oi+"/pub-key.pem",oi+Oi+"/priv-key.pem","pem",parseInt(ac(8).toString("hex"),16),new Date,a,o),servername:a,rejectUnauthorized:!1};console.log("OUTGOING OR SOCKET EXTEND : ---------OR starts client socket with------------"+c.servername+" "+s.server_.ip+" "+s.server_.port);var l=tn.connect(s.server_.port,s.server_.ip,c,function(){In[s.server_.ip]=this,console.log("OR process extend sending versions"),s.socket_=this,this.OR_=!0,this.way_="socket out",this[s.circId]=s,this.stream_tor_=new ii(0);var e=new lc(s.circId,lc.prototype.VERSIONS,new ii(2).writeUInt(3));s.send(e)});l.on("data",wc),l.circuits_destroy=function(){for(var e in Tn)Object.keys(Tn[e]).forEach(function(t){if(!isNaN(t)&&null!=t&&"function"!=typeof t){var r=Tn[e][t];r&&r.socket_&&r.socket_.remoteAddress&&r.next_&&r.next_.socket_===l&&(console.log("destroy circ in CIC "+r.circId+" "+r.socket_.remoteAddress),r.circuit_destroy())}})},l.on("end",function(){console.log("or_tls_socket end"),delete In[t],l.circuits_destroy()}),l.on("close",function(){console.log("or_tls_socket close"),delete In[t],l.circuits_destroy()}),l.on("error",function(){console.log("or_tls_socket error"),delete In[t],l.circuits_destroy()})}}},handle_destroy:function(e){if(this.OP_){var t=this.first_||this;console.log("OP receive destroy CIC "+t.circId+(t===ks?" ------- DB_CID destroyed --------------- ":"")),t.destroyed_=!0,this.clear_timers(),t.circuit_destroy(!0)}else{console.log("OR "+(this.OR_f?"in":"out")+" received destroy from "+this.socket_.remoteAddress+" on CID "+this.circId);var t=this.prev_||this.next_;t?(console.log("OR "+(this.OR_f?"in":"out")+" send destroy to "+(t.socket_?t.socket_.remoteAddress:"")+" on CID "+t.circId),e=e.toString(),e=1===e.length?"0"+e:e,t.circuit_destroy(),this.circuit_destroy(!0)):this.circuit_destroy()}},relay_cell_handle:function(e,t){var r=e.Payload[0],i=e.Command.readUInt();this.OP_?this.stream_decrypt_backward(r,t):this.prev_?i!==e.RELAY_EARLY&&this.stream_encrypt_or_b(r,i):this.stream_decrypt_or_f(r,i)},relay_send_truncate:function(e){var t=new uc(uc.prototype.RELAY_TRUNCATE,0,new ii(1).writeUInt(e),this.Df_hash),r=new lc(this.circId,lc.prototype.RELAY,this.stream_encrypt_forward(t));this.send(r)},relay_end_handle:function(e,t){var r=this.first_,i=r[e],n=function(){i.download_&&(du('<p style="text-align:center">An unexpected event occured(error '+t+"), please retry</p>"),Ph(i.bar_)),i._write_(new ii(Uo(),"utf8")),i.end()};if(i&&(i.abstract_client_tls&&i.abstract_client_tls.close(),delete i.abstract_client_tls,!i.destroyed))if(-1===[6,12].indexOf(t))Fs||(console.log("END : RETRY error "+t+" CID "+this.first_.circId+" on port "+i.remotePort+" for request "+i.i_id+" nb_try "+i.nb_try),console.log(i.nb_try),i.nb_try<os?(i.nb_try++,r.perf_--,r.resolved_failed++,(r.resolved_failed>ns||0===r.sent_)&&(r.bad_=!0),r.destroy_cid(i),r.request_retry(i,t)):n());else if(i._data_)if(12===parseInt(t))if(console.log("END : CONNRESET RETRY "+t+" CID "+this.first_.circId+" on port "+i.remotePort+" for request "+i.i_id),i.download_)if(i.url_){var s=function(){i.queue_.shift(),du('<p style="text-align:center">Remote server closed the connection (error '+t+"), download could not be completed, resuming...</p>"),setTimeout(function(){mo("alert_box").style.display="none"},1e4);var n=function(t){var i=Lo(t.url_);t.blob_=Ji?new ii(0):new Blob([],{type:t.content_chrome?t.content_chrome:t.content_}),t.params_.stream=Vo(i.host,i.rest,length),t.queue_=[],t.queue_s=[],delete t.eof_,delete r[e],delete t.cid_,delete t.check_hash,delete t.file_id,delete t.start_t0,t.received_=0,xc(t)};Nh(i,!0,n)};i.queue_.push(s),1===i.queue_.length&&i.queue_[0]()}else So(document.body,"mousedown",function(){},!1),du('<p style="text-align:center">Remote server closed the connection (error '+t+"), download could not be completed, please use Resume to resume the download.</p>"),i.eof_||(i.eof_=!0,i.queue_.push(fin_.bind(i)),1===i.queue_.length&&i.queue_[0]());else r.perf_--,r.destroy_cid(i),i.destroy();else i.bufferSize||(Os&&i.abstract_client_tls?i.done_=!0:i.download_?i.eof_||(i.eof_=!0,i.queue_.push(fin_.bind(i)),1===i.queue_.length&&i.queue_[0]()):(r.destroy_cid(i),i.end()));else i.nb_try++,r.perf_--,r.destroy_cid(i),r.request_retry(i,t)},request_retry:function(e,t){console.log("Retry for request "+e.i_id),Os?e.relay_ws_handle(e.ini_data,!0):xc(e,this,"end "+t)},relay_truncated_handle:function(e){console.log("STREAM : Truncated received from "+this.server_.ip+" CIRC "+this.circId+" "+e);var t=this.first_;switch(e){case 8:this.handle_destroy(0);break;case 11:this.handle_destroy(0);break;default:var r=t.last_?t.last_.ok_:null;r||this.next_.change_or("- relay truncated",this.extend)}},relay_truncate_handle:function(e){console.log("truncate "+this.circId);var t=this.next_,r=new lc(t.circId,lc.prototype.DESTROY,new ii("05","hex"));t.send(r);var i=new uc(uc.prototype.RELAY_TRUNCATED,0,new ii(1).writeUInt(e),this.Db_hash);this.stream_encrypt_or_b(i.toBuffer(),lc.prototype.RELAY,!0)},stream_handle:function(e){switch(e.command.readUInt()){case e.RELAY_EXTEND:this.extend_cell_handle(e.data);break;case e.RELAY_TRUNCATE:this.end("Error OR receive truncate :"+e.data.slice(0,1).readUInt(),"truncate");break;case e.RELAY_EXTENDED:this.created_cell_handle(new lc(this.circId,lc.prototype.CREATED,e.data,!0));break;case e.RELAY_TRUNCATED:this.end("Error OP receive truncated :"+e.data.slice(0,1).readUInt(),"truncated");break;case e.RELAY_END:this.end("End :"+e.data.slice(0,1).readUInt(),"relay_end",e.streamId.readUInt());break;case e.RELAY_CONNECTED:this.stream_decode_connected(e),this.stream_handle_connected(e.streamId.readUInt());break;case e.RELAY_DATA:this.stream_handle_data(e);break;case e.RELAY_SENDME:Li("RECEIVING SENDME CIC "+this.circId+" for stream "+e.streamId.readUInt()),this.stream_handle_sendme(e.streamId.readUInt());break;case e.RELAY_ASSOCIATE:this.associate(e.data.slice(0,e.length.readUInt()).toString("utf8"));break;case e.RELAY_INFO:this.info(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_WS:this.relay_ws_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_INFO:this.relay_db_info_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_QUERY:this.relay_db_query_handle(e);break;case e.RELAY_DB_CONNECTED:this.relay_db_connected_handle(e);break;case e.RELAY_DB_END:this.relay_db_end_handle(e);break;case e.RELAY_DB_DATA:this.relay_db_data_handle(e);break;case e.RELAY_DB_SENDME:this.relay_db_sendme_handle(e);break;case e.RELAY_BEGIN_DIR:this.end("End begin_dir :14","begin_dir",e.data.slice(0,1).readUInt())}},stream_decode_connected:function(){},stream_handle_sendme:function(e){var t=this.first_,r=t.stream_;Li("FLUSH BUFFER CIC "+t.circId+" sid "+(e||" whole circuit ")+" buffer length "+r.length);var i=Math.min(e?ms:_s,r.length),n=0;for(e?t[e].stream_window_s+=ms:t.circuit_window_s+=_s;i>n;){var s=e?r[n]:r[0];e?e===s[1]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Qa/Ja))),s[0]=null,n++):(s[0]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Qa/Ja))),n++),r.shift())}},stream_handle_connected:function(e,t){var r=this.first_,i=r[e];if(i)if(Fs&&clearTimeout(i.socket_retry),this.clear_timers(),console.log("STREAM RELAY :--------------RELAY_CONNECTED TO---------------------- "+this.server_.ip+" VIA "+this.first_.server_.ip+" CID "+this.circId+" Stream "+e+" for request "+i.i_id),i.params_.stream){for(var n=i.params_.stream;n.length;){if(i.tls_client_connected||!i.abstract_client_tls,t)var s=new uc(uc.prototype.RELAY_DB_DATA,e,[new ii(t,"hex"),n.slice(0,Math.min(n.length,bn-16))].concatBuffers(),this.Df_hash);else var s=new uc(uc.prototype.RELAY_DATA,e,n.slice(0,Math.min(n.length,bn)),this.Df_hash);var a=new lc(this.circId,lc.prototype.RELAY,this.stream_encrypt_forward(s));if(i.sent_++,r.resolved_failed=0,r.sent_++,r.time_=Date.now(),i.start_t0=r.time_,i.stream_window_s--,r.circuit_window_s--,0===i.stream_window_s||0===r.circuit_window_s?(console.log("Bufferizing CIC "+r.circId+" for request "+i.i_id),r.stream_.push[e]):this.send(a),!(n.length>bn))break;n=n.slice(bn)}i.squeue_&&(i.squeue_.shift(),i.squeue_.length&&i.squeue_[0]())}else Rc(i)},stream_handle_data:function(e,t,r){var i=this.first_;if(i){var n=e.streamId.readUInt(),s=r||i[n];if(s){if(t||s.time_resp||(s.time_resp=Date.now(),i.time_average=(i.time_average+(s.time_resp-s.time_ini))/(i.time_average?2:1)),t){console.log("STREAM RELAY : --------------RECEIVE DECODED TLS DATA FROM---------------------- "+this.server_.ip+" CID "+this.circId+" Stream "+n+" for request "+s.i_id+" length "+e.length.readUInt());{e.data.slice(0,e.length.readUInt())}}else s.tls_client_connected||!s.abstract_client_tls;var a=e.data.slice(0,e.length.readUInt());if(t)s.received_++;else{if(!s._data_||s.wait_header){var o;if(s._data_=!0,s.download_){if(a=s.wait_header?[s.wait_header,a].concatBuffers():a,o=Bc(a.toString("utf8")),"undefined"==typeof o["1a"]||""!==o["1a"])return void(s.wait_header=a);delete s.wait_header;var c=o["0a"].split(" ");if(c=c[1]?c[1]:null){if(Li("STREAM : status code "+c+" for request "+s.i_id),c=c.toString(),-1===["2","3"].indexOf(c[0]))return du('<p style="text-align:center">Wrong URL, please check and try again</p>'),Ph(s.bar_),void i.send_relay_end(s.sid_);if("3"===c[0]){if(o.Location){var l=Lo(o.Location);s.params_.stream=Ko(l.host,l.rest),i.send_relay_end(s.sid_),delete i[s.sid_],delete s.cid_,xc(s)}return}if(s.d_length=s.d_length||0,s.content_=o["Content-Type"]?o["Content-Type"]:"application/octet-binary",o["Content-Length"]&&!s.clength_&&(s.clength_=parseInt(o["Content-Length"])),!s.clength_)for(var h in o)if(-1!==h.toLowerCase().indexOf("content-length")){s.clength_=parseInt(o[h]);break}s.pieces=Math.ceil(s.clength_/Ja),o["Transfer-Encoding"]&&(s.encoding_=o["Transfer-Encoding"]),console.log("Start relay_data"),console.log(s.content_),console.log(s.clength_),console.log(s.encoding_?s.encoding_:"No encoding"),s._stream_&&Hh(s),a=a.toString("hex").split(Ss+Ss),a.shift(),a=new ii(a.join(Ss+Ss),"hex")}}}s._data_=!0,s.received_++,i.received_++,i.circuit_window--,s.stream_window--,s.resp__=s.resp__?s.resp__+a.length:a.length,i.received_%_s===0&&i.circuit_window<ys*ps&&(i.sendme(),i.circuit_window+=_s),s.received_%ms===0&&s.stream_window<ys*gs&&(i.sendme(s),s.stream_window+=ms)}if(1===s.received_,Os){if(a=Lc(a),"undefined"==typeof s.content_){if(a=s.wait_header?[s.wait_header,a].concatBuffers():a,o=Bc(a.toString("utf8")),"undefined"==typeof o["1a"])return console.log("header not complete "+s.i_id),void(s.wait_header=a);if(delete s.wait_header,o.Location){if(s.referer_===Vs)s._host_=o.Location,s.request_&&(s.request_._host_=s._host_),console.log("navigate "+o.Location),i.navigate(s);else{var u=Uc(o.Location,{fake_domain:xs},!0).html;console.log("redirect "+u),i.redirect(s,u)}return}s.content_=o["Content-Type"]?o["Content-Type"]:"",s.encoding_=o["Transfer-Encoding"]?o["Transfer-Encoding"]:null}if(s.content_?-1!==s.content_.indexOf("text/html"):null){if(!s.html_){if(s._host_)return void i.navigate(s);if(s.decoder_=new M("utf-8"),s.t0_=(new Date).valueOf(),!s.header_l){s.html_=new ii(0);var d=a.toString("hex").split(Ss+Ss);if(!(d.length>1))return void(s.header_=a);s.header_=[s.header_?s.header_:new ii(0),new ii(d[0]+Ss+Ss,"hex")].concatBuffers(),s.header_l=s.header_.length}if(s.header_l){if(d.shift(),"chunked"!==s.encoding_){var o=Bc(s.header_.toString("utf8"));o["Content-Length"]&&(s.clength_=parseInt(o["Content-Length"]),s.content_l=!0)}else d=d.join(Ss+Ss).split(Ss),s.header_l=s.header_.length,s.clength_=d.length>1?parseInt(new ii(d[0],"hex").toString("utf8"),16):0,d.shift(),s.pass_="",s.buff_="";a=new ii(d.join(Ss),"hex")}}if("chunked"===s.encoding_){if(s.html_.length+a.length>=s.clength_||s.wait_)var f=Nc(a.toString("hex"),s);ii.isBuffer(s.html_)?s.html_={length:parseInt((f?f:a).length)}:s.html_.length+=f?0:parseInt(a.length)}else s.html_=[s.html_,a].concatBuffers()}}try{}catch(p){}t||i.perf_++,s.nb_try=0;var d=s.html_?s.content_l&&s.clength_===s.html_.length||"chunked"===s.encoding_?!1:!0:!1;if(!d){if("chunked"!==s.encoding_&&(s.socks_s=!1),s.html_){var _=s.content_l?s.html_.toString("utf8"):s.decoder_.decode(f?f:a,{stream:!0});if(!s.content_l){if(s.buff_+=_,s.buff_.length<bs&&!s.end_)return;s.pass_||(_=s.buff_)}var g=Uc(_,s);if(g.pass)return;if(s.pass_){var m=Uc([s.pass_,_].join(""),s);if(m.pass)return;_=m.html,s.pass_=""}else _=g.html;if(s.script_||(_=Dc(_,s),s.script_=!0),!s.header_sent||s.content_l){if(!s.header_l)return;var o=Bc(s.header_.toString("utf8"));o["X-Frame-Options"]&&delete o["X-Frame-Options"],s.content_l&&(o["Content-Length"]=new ii(_,"utf8").length),s.header_=kc(o),s.header_sent=!0,s.content_l?a=new ii([s.header_,_].join(""),"utf8"):t?t(new ii(s.header_,"utf8")):s._write_(new ii(s.header_,"utf8"))}if(s.content_l)s.socks_s=!1,s._init_();else{var d=new ii(_,"utf8").length;s.end_?(_="\r\n"+(d-7).toString(16)+"\r\n"+_,console.log("end html-------"),s._init_(),s.socks_s=!1):(_="\r\n"+d.toString(16)+"\r\n"+_,s.socks_s=!0),a=new ii(_,"utf8"),s.buff_=""}}t?t(a):s._write_(a)}}}},send:function(e){var t=this.first_,r=[e.CircID,e.Command],i=e.Command.readUInt();(7==e.Command.readUInt()||e.Command.readUInt()>=128)&&r.push(e.Length);var n=function(e){if(e.push)e.forEach(function(e){ii.isBuffer(e)?r.push(e):n(e)});else for(var t in e)ii.isBuffer(e[t])?r.push(e[t]):n(e[t])};if(e.Payload.push?e.Payload.forEach(function(e){n(e)}):r.push(e.Payload),r=r.concatBuffers(),7!==e.Command.readUInt()&&e.Command.readUInt()<128){var s=new ii(512);s.map(r),r=s}if(this.OP_&&!t.last_){var a;this.clear_timers();var o;this===t?this.socket_&&this.socket_.handshake_?(a=function(){console.log("CIRC : Create or first extend too long "+this.circId),this.circuit_retry()},o=Xn):(a=function(){this.change_or("Handshake version no answer or bad answer - change OR")},o=Jn):(a=function(){console.log("CIRC : Extend delay expired - change or "+this.server_.ip),this.change_or("- extend too long",this.extend)},o=Zn)}if(Gh&&zh&&(chart1_int||chart2_int)&&parseInt(i)!==lc.prototype.PADDING){var c=Mo(new Date).getTime(),l=r.length;t===ks?chart2_int&&(Gh.dynRow2[c]=Gh.dynRow2[c]?Gh.dynRow2[c]+l:l):chart1_int&&(zh.dynRow2[c]=zh.dynRow2[c]?zh.dynRow2[c]+l:l)}if(this.OP_||this.OR_)try{if(this.OR_&&6===e.Command.readUInt()&&console.log("sending FAST to "+(this.server_?this.server_.ip:"OP")+" CIC "+e.CircID.readUInt()),this.socket_.ws_)if(this.OP_){if(Ii&&!Ti||xi)var s=r;else var s=Jc(r,2,!0);this.socket_.write(s)}else this.socket_.write(Jc(r,2,!1));else this.socket_.write(r)}catch(h){if(console.log("OUTGOING SOCKET "+(this.OP_?"OP ":"OR ")+(this.socket_?this.socket_.ws_?"WS":"TLS":"")+" IP "+(this.server_?this.server_.ip:"")+" socket does not exist any longer"),this.OP_)this.socket_?xi||this.socket_.destroy():(console.log("send1 circuit destroy"),this.circuit_destroy(!0));else if(!this.OR_f){var u=this.socket_;console.log("send2 circuit destroy"),this.circuit_destroy(!0),u&&u.circuits_destroy()}}else u.write(e)},navigate:function(e){var t=Lo(e._host_);t.host="www."+Po(t.host,!0)+Es,xs=t.host,protocol=t.protocol,Zl.associate(Bs,t.host),console.log("send 301 and associate fake_d "+t.host+" location "+Oo(t)),this.redirect(e,Oo(t))},redirect:function(e,t){console.log("redirect send 301 for url "+t),qs?(alert(No(t)),e.__write__(new ii(No(t),"utf8"))):e._write_(new ii(No(t),"utf8")),e.destroy(),this.destroy_cid(e,!0),delete e._host_},send_db_info:function(e){e=e||null;var t=function(e){if(e.file_length===e.current_length&&ks){console.log("send_db_info"),console.log(e.name_hash);var t=new ii(e.name_hash,"hex"),r=new ii(1).writeUInt(t.length),i=new ii(1).writeUInt(0),n=xi?new ii(1).writeUInt(1):new ii(0),s=[r,t,i,n].concatBuffers(),a=new uc(uc.prototype.RELAY_DB_INFO,0,s,ks.last_.Df_hash),o=new lc(ks.circId,lc.prototype.RELAY,ks.last_.stream_encrypt_forward(a));ks.send(o)}};no&&no.list(t,e)},send_db_query:function(e,t){if(e){console.log("send_db_query");var r,i=e.params_?e.params_.hash_:e.hash_,n=e.d_length.toString(16);n=n.length%2?"0"+n:n,n=new ii(n,"hex"),size_l=new ii(1).writeUInt(n.length),console.log("send_db_query hash "+i.toString("hex")+" CIC "+this.circId+" size "+size_l[0]+" size "+n.toString("hex")+" tid "+(t?t.toString("hex"):""));var s=[new ii(1).writeUInt(i.length),i,size_l,n].concatBuffers();if(t)s=[s,t].concatBuffers(),r=0;else{if(r=Go(this),e.cid_=this,!r)return;this[r]=e,e.sid_=r,e.received_=0,e.sent_=0}if(this.OP_){console.log("OP send db_query  CID "+this.circId+" sid "+r);var a=new uc(uc.prototype.RELAY_DB_QUERY,r,s,this.last_.Df_hash),o=new lc(this.circId,lc.prototype.RELAY,this.last_.stream_encrypt_forward(a));e.query_time=Date.now(),this.send(o);var c=function(){this.socket_&&(e._torrentc_||(console.log("serving party not responding"),e.db_try++,this.send_db_end(1,r),delete e.sid_,this.send_db_query(e)))}.bind(this);e.db_try<Ls?(e.query_t0=e.query_t0||[],e.query_t0.push(setTimeout(c,Us))):(this.send_db_end(1,r),delete e.sid_,du('<p style="text-align:center">No answer from the network, changing peer to peer circuits, please wait and retry</p>'),Ph(e.bar_),console.log("db_query no answer circuit destroy"),ks.circuit_destroy(),ks=null)}else{this.prev_=this,this.nb_query=this.nb_query||0,this.nb_query++,console.log("ORDB send db_query  CID "+this.prev_.circId+" sid "+r+" "+this.prev_.socket_.remoteAddress);var a=new uc(uc.prototype.RELAY_DB_QUERY,r,s,this.prev_.Db_hash);this.stream_encrypt_or_b(a.toBuffer(),lc.prototype.RELAY,!0),delete this.prev_}}},send_db_end:function(e,t,r){t=t||0,console.log("send db_end CID "+this.circId+" sid "+t+" reason "+e+" "+("undefined"!=typeof r?r.toString("hex"):""));var i=new ii(1).writeUInt(e);if(i=r?[i,r].concatBuffers():i,this.OP_){var n=new uc(uc.prototype.RELAY_DB_END,t,i,this.last_.Df_hash),s=new lc(this.circId,lc.prototype.RELAY,this.last_.stream_encrypt_forward(n));this.send(s)}else{this.prev_=this;var n=new uc(uc.prototype.RELAY_DB_END,t,i,this.prev_.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),lc.prototype.RELAY,!0),delete this.prev_}},send_db_connected:function(e,t,r,i){e=e.toString(16),e=e.length%2?"0"+e:e,e=new ii(e,"hex"),size_l=new ii(1).writeUInt(e.length),r=new ii(r,"utf8");var n=new ii(2).writeUInt(r.length);console.log("send db_connected "+e.toString("hex")+" CID "+this.circId+" sid "+t+" type "+r.toString("utf8"));var s=[size_l,e,n,r].concatBuffers();if(i&&(s=[i,s].concatBuffers()),this.OP_){var a=new uc(uc.prototype.RELAY_DB_CONNECTED,t,s,this.last_.Df_hash),o=new lc(this.circId,lc.prototype.RELAY,this.last_.stream_encrypt_forward(a));this.send(o)}else{this.prev_=this;
var a=new uc(uc.prototype.RELAY_DB_CONNECTED,t,s,this.prev_.Db_hash);this.stream_encrypt_or_b(a.toBuffer(),lc.prototype.RELAY,!0),delete this.prev_}},send_db_data:function(e,t,r,i){if(this.OP_){var n=this[t];i||(n.fc_t=[],console.log("sending db data "+(this.OP_?"OP ":"ORDB sid ")+t+" BANDWIDTH "+8*Qa+" bps "+(this.OP_?" 512 bytes every "+(1+1e3/(Qa/Ja))+" ms then nbblocks "+Math.ceil(Za*Qa/1e3/Ja)+" every "+Za+"ms window size "+n.stream_window_s+" "+this.circuit_window_s:"")+" cd "+e.size),n.start_t0=Date.now(),n.cd_length=e.size,n.messageName="flush",xi||So(window,"message",Jo.bind(n),!0),n.reader=xi?new fo:new FileReader,n.cursor=0),Zo.call(this,e,t,n,r)}else{this.prev_=this;var s=new uc(uc.prototype.RELAY_DB_DATA,t,e.slice(0,Math.min(e.length,bn)),this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),lc.prototype.RELAY,!0),delete this.prev_}},send_db_sendme:function(e){if(e=e||0,this.OP_){var t=new uc(uc.prototype.RELAY_DB_SENDME,e,new ii(0),this.last_.Df_hash),r=new lc(this.circId,lc.prototype.RELAY,this.last_.stream_encrypt_forward(t));this.send(r)}else{this.prev_=this;var t=new uc(uc.prototype.RELAY_DB_SENDME,e,new ii(0),this.prev_.Db_hash);this.stream_encrypt_or_b(t.toBuffer(),lc.prototype.RELAY,!0),delete this.prev_}},circuit_keys:function(e){var t=Yo(e.toString("hex")),r=t.slice(0,20);return this.Df_=t.slice(20,40),this.Db_=t.slice(40,60),this.Kf_=t.slice(60,76),this.Kb_=t.slice(76,92),this.Kf_cipher=an.createcipheriv("aes-128-ctr",this.Kf_,Hn),this.Kb_cipher=an.createcipheriv("aes-128-ctr",this.Kb_,Hn),this.Df_hash=new vn("sha1"),this.Db_hash=new vn("sha1"),this.Df_hash.update(this.Df_),this.Db_hash.update(this.Db_),r},stream_encrypt_forward:function(e){for(var t=this,r=e.toBuffer();t;)r=new ii(t.Kf_cipher.update(r,"hex","hex"),"hex"),t=t.prev_;return r},stream_decrypt_backward:function(e,t){var r,i=this;if(wi)var n=Date.now();for(var s=e.length;i&&!(i.Kb_&&(e=new ii(i.Kb_cipher.update(e,"hex","hex"),"hex"),r=i.recognized(e)));)i=i.extended_;if(n&&(Sa++,Ea+=s,Ca+=Date.now()-n,Sa%Aa===0&&Ca&&(console.log("CRYPTO perf decrypt backward: "+parseInt(8*Ea/(Ca/1e3))+" bps"),Sa=0,Ea=0,Ca=0)),r&&41===r.command.readUInt(),r)if(t){var a=new uc(uc.prototype.RELAY_END,r.streamId,new ii("0A","hex"),i.Df_hash),o=new lc(i.circId,lc.prototype.RELAY,i.stream_encrypt_forward(a));i.send(o)}else i.stream_handle(r);else this.end("Unrecognized stream","unrecognized"),console.log(e.toString("hex"))},stream_decrypt_or_f:function(e,t,r){if(this.Kf_cipher){if(e=new ii(this.Kf_cipher.update(e,"hex","hex"),"hex"),!r)var i=this.recognized(e);if(i)this.stream_handle(i);else if(Ps&&this.socket_.fake_cid===this);else if(this.next_){var n=new lc(this.next_.circId,t,e);this.next_.send(n)}}},stream_encrypt_or_b:function(e,t,r){var i=this.prev_;if(i&&i.Kb_cipher){if(e=new ii(i.Kb_cipher.update(e,"hex","hex"),"hex"),!r)var n=i.recognized(e);if(n)this.stream_handle(n);else if(i){var s=new lc(i.circId,t,e);i.send(s)}}},recognized:function(e){if(0==e.slice(1,3).readUInt()){var t=e.slice(9,11),r=Math.min(11+t.readUInt(),e.length),i=new uc(e.slice(0,1).readUInt(),e.slice(3,5).readUInt(),e.slice(11,r));i.length=t;var n=e.slice(5,9);if(this.OR_f){this.Df_hash.update(i.toBuffer());var s=new ii(this.Df_hash.digest("hex"),"hex").slice(0,4)}else{this.Db_hash.update(i.toBuffer());var s=new ii(this.Db_hash.digest("hex"),"hex").slice(0,4)}if(s.toString("hex")==n.toString("hex"))return i}},extend:function(){var e=this.extended_,t=cc(e.server_.ip),r=new ii(2).writeUInt(parseInt(e.server_.port)),i=new ii(e.server_.fing,"hex");if(!Ii||an.getDiffieHellman){var n=an.getDiffieHellman("modp2");n.generateKeys(),e.DH_=n,e.X_=new ii(n.getPublicKey("hex"),"hex");var s=function(){var n=Qo(new ii(e.server_.o_modulus,"hex"),e.X_),s=new uc(uc.prototype.RELAY_EXTEND,0,[t,r,n,i].concatBuffers(),this.Df_hash),a=new lc(this.circId,lc.prototype.RELAY_EARLY,this.stream_encrypt_forward(s));this.send(a)};e.server_.o_modulus?s.call(this):e.get_certs(s)}else{var s=function(n){var s=n.slice(0,2).readUInt();e.X_=n.slice(2,2+s),e.DH_={};var a=n.slice(2+s),o=new uc(uc.prototype.RELAY_EXTEND,0,[t,r,a,i].concatBuffers(),this.Df_hash),c=new lc(this.circId,lc.prototype.RELAY_EARLY,this.stream_encrypt_forward(o));delete An[e.cid_hex],this.send(c)}.bind(this);e.create_extend_info(s)}},create:function(){if(this.onion_){var e=new lc(this.circId,lc.prototype.CREATE,this.onion_);this.send(e)}else if(Ii){var t=function(e){var t=e.slice(0,2).readUInt();this.X_=e.slice(2,2+t);var r=e.slice(2+t),i=new lc(this.circId,lc.prototype.CREATE,r);delete An[this.cid_hex],this.send(i)}.bind(this);this.DH_={},this.create_extend_info(t)}else{var r=an.getDiffieHellman("modp2");r.generateKeys(),this.DH_=r,this.X_=new ii(r.getPublicKey("hex"),"hex");var t=function(){var e=Qo(new ii(this.server_.o_modulus,"hex"),this.X_),t=new lc(this.circId,lc.prototype.CREATE,e);this.send(t)};this.server_.o_modulus?t.call(this):this.get_certs(t)}},create_extend_info:function(e){var t=new ii(1).writeUInt(1),r=ac(16),i=r.toString("hex");this.cid_hex=i;var n=new ii(this.server_.o_modulus,"hex");An[i]=e;var s=new uc(uc.prototype.RELAY_INFO,0,[t,r,n].concatBuffers(),Bs.Df_hash),a=new lc(Bs.circId,lc.prototype.RELAY_WS,Bs.stream_encrypt_forward(s));Bs.send(a)},destroy:function(){console.log("CIRC : -------------------------- SEND DESTROY ------------------- "+(this.server_?this.server_.ip:this.socket_.remoteAddress)+(this.OP_?" OP":" OR")+" CID "+this.circId);var e=new lc(this.circId,lc.prototype.DESTROY,new ii("09","hex"));this.send(e)},send_relay_end:function(e,t){var r=this.first_||this;t="undefined"==typeof t?0:t;var i=new uc(uc.prototype.RELAY_END,e,new ii(t),r.last_.Df_hash),n=new lc(r.circId,lc.prototype.RELAY,r.last_.stream_encrypt_forward(i));r.send(n)},send_relay_end_b:function(e,t){var r=new uc(uc.prototype.RELAY_END,e,new ii(1).writeUInt(t),this.Db_hash);this.stream_encrypt_or_b(r.toBuffer(),lc.prototype.RELAY,!0)},associate:function(e){console.log("ASSOCIATE OR RECEIVE "+e),this.socket_.fake_cid=this,xn[e]={circ_:this}},info:function(e){if(this.OP_){var t=e.slice(0,16).toString("hex");An[t]&&An[t](e.slice(16))}else{var r=e.slice(0,1).readUInt(),t=e.slice(1,17);switch(r){case 1:var i=e.slice(17),n=an.getDiffieHellman("modp2");n.generateKeys(),Ln[t.toString("hex")]=n;var s=new ii(n.getPublicKey("hex"),"hex"),a=Qo(i,s);e=new uc(uc.prototype.RELAY_INFO,0,[t,new ii(2).writeUInt(s.length),s,a].concatBuffers(),this.Db_hash).toBuffer(),e=new ii(this.Kb_cipher.update(e,"hex","hex"),"hex");var o=new lc(this.circId,lc.prototype.RELAY_WS,e);this.send(o);break;case 2:var c=t.toString("hex");if(Ln[c]){var l=new ii(Ln[c].computeSecret(e.slice(17),"hex","hex"),"hex");e=new uc(uc.prototype.RELAY_INFO,0,[t,l].concatBuffers(),this.Db_hash).toBuffer(),e=new ii(this.Kb_cipher.update(e,"hex","hex"),"hex");var o=new lc(this.circId,lc.prototype.RELAY_WS,e);delete Ln[c],this.send(o)}}}},relay_ws_handle:function(e,t){if(this.OP_){var r=null,i=e.slice(0,2).readUInt(),s=e.slice(2,2+i).toString("utf8").split(":");if(e=e.slice(2+i),console.log("OP ws receive request "+s[3]+" adresse "+s[0]+" port "+s[1]+" data "+e.length),e.length){var a={},o=Cn[s[3]];o?o.params_&&(r=o.params_.host):(o={nb_try:0,no_exit:[],i_id:s[3]},Cn[s[3]]=o);var c=function(e){for(var t=e,r=new ii(new ii(s[0]+":"+s[1],"utf8").toString("hex"),"hex"),i=r.length.toString(16);4!==i.length;)i="0"+i;if(r=[new ii(i,"hex"),r].concatBuffers(),i=r.length,0===t.length){var n=new uc(uc.prototype.RELAY_WS,0,r,this.Df_hash),a=new lc(this.circId,lc.prototype.RELAY_WS,this.stream_encrypt_forward(n));this.send(a)}else for(;t.length;){var o;o=t.length+i>wn?t.slice(0,wn-i):t,o=[r,o].concatBuffers();var n=new uc(uc.prototype.RELAY_WS,0,o,this.Df_hash),a=new lc(this.circId,lc.prototype.RELAY_WS,this.stream_encrypt_forward(n));if(this.send(a),!(t.length+i>wn))break;t=t.slice(wn-i)}}.bind(Bs);if(!qs||!o.tls_server_connected){var l=function(){if(o.wait_header=o.wait_header?[o.wait_header,e].concatBuffers():e,o.wsqueue_&&o.wsqueue_.length){var t=o.wsqueue_[0];o.wsqueue_.shift(),t()}};if(e.length>=4){var h=e.toString("hex");h.substr(h.length-8)!==Ss+Ss?l():(e=o.wait_header?o.wait_header:e,delete o.wait_header)}else l();o._write_=c,o.destroy=function(){qs?(delete o.abstract_server_tls,o.abstract_client_tls?(delete o.abstract_client_tls,c(new ii(0))):o._write_(new ii(0))):o._write_(new ii(0))}}var u=function(e){var i=s[2],c=Bc(e),l=c.Accept?c.Accept:"";-1!==l.indexOf("text/html")&&delete c["Accept-Encoding"],o.referer_=c.Referer,delete c.Referer,c.Connection="keep-alive";var h=c["0a"].split(" "),u="";if(h.length>1){var d="/"===h[1].substr(0,1)?h[1].substr(1):h[1];u=Po(d)}var f=function(){if("http"===u.substr(0,4)){var l=Lo(u);h[1]="/"+(l.rest?l.rest:""),c["0a"]=h.join(" "),c.Host&&(c.Host=l.host?l.host:""),delete c.Cookie,c["X-Requested-With"]||(o._host_=l.protocol+"//"+c.Host)}else c.Host&&(o.fake_domain=c.Host,c.Host=Is[c.Host].real_domain);c.Accept&&-1!==c.Accept.indexOf("text/html")&&(c["Accept-Encoding"]="identity"),e=kc(c),a.OP=!0,a.nb_hop=Gn,a.one_c=!0,qs&&(i=protocol===Ts&&"443"===i?"80":i),a.host=c.Host+":"+i,r&&a.host!==r&&(delete o.tls_client_connected,delete o.abstract_client_tls,o.cid_&&o.cid_.destroy_cid(o,!0)),a.stream=new ii(e,"utf8"),o.params_=a,o._data_=!1,o._init_=Sc,o._init_(),t&&(o.nb_try=n),o.remoteAddress=s[0],o.remotePort=s[1],o.end=o.destroy};if("https"===u.substr(0,5)||"https:"===protocol){if(!Ms)return console.log("https not supported now "+u),void o._write_(new ii(Ro(),"utf8"));if(f(),o.abstract_client_tls){console.log("Reuse TLS Client for request "+o.i_id);var p=function(){o.abstract_client_tls.prepare(Rl(o.params_.stream.toString("hex")))};o.request_decoded.socks_s?(console.log("Queue "+o.i_id),o.abstract_client_tls.queue_socks.push(p)):p()}else{console.log("Create TLS Client for request "+o.i_id);var _=Lo(u),e=o.params_.stream;o.abstract_client_tls=Nl(o,_.host),o.abstract_client_tls.stream_tor_=new ii(0),o.abstract_client_tls.queue_socks=[];var g={};g._init_=Sc,g._init_(),g._host_=o._host_,g.cid_=o.cid_,g.i_id=o.i_id,g.fake_domain=o.fake_domain,g.socks_s=!0,g.__write__=o.__write__,g.destroy=o.destroy,g.referer_=o.referer_,o.request_decoded=g,g.request_=o,g.received_=0;var m=o.abstract_client_tls,y=function(e){var t=function(e){return function(){this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.stream_tor_.parseTLS(this)}};m.queue_=m.queue_||[],m.queue_.push(t(e).bind(m)),1===m.queue_.length&&m.queue_[0](),m.queue_socks.length&&!g.socks_s&&(g.socks_s=!0,console.log("Unqueue request "+o.i_id),m.queue_socks[0](),m.queue_socks.shift())};o._write_=y,o.write_c=function(e){o.params_.stream=e,xc(o)},o.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),delete o.abstract_client_tls,delete o.tls_client_connected,o.cid_&&o.cid_.destroy_cid(o)},o.abstract_client_tls.error=function(e,t){console.log(" Error TLS client disconnected "+t.message),delete o.abstract_client_tls,delete o.tls_client_connected,o.cid_&&o.cid_.destroy_cid(o)},o.abstract_client_tls.connected=function(t){console.log("TLS client connected to site for request "+o.i_id),o.tls_client_connected=!0,o._data_=!1,console.log("Sending https request for request "+o.i_id+" to site "+e.toString("utf8")),t.prepare(Rl(e.toString("hex")))},o.abstract_client_tls.dataReady=function(e){var t=e.data.data.slice(e.data.read,e.data.length_);e.data.read=e.data.length_;var r={streamId:new ii(2).writeUInt(o.sid_),data:t,length:new ii(2).writeUInt(t.length)};o.cid_&&o.cid_.last_.stream_handle_data(r,o.__write__,g)},o.abstract_client_tls.handshake()}}else f(),xc(o)};if(o.relay_ws_handle=u,qs)o.abstract_server_tls||(o.abstract_server_tls=Nl(o,xs,!0),o.write_s=c,o.abstract_server_tls.closed=function(){console.log(" TLS server disconnected for request "+o.i_id),o.destroy()},o.abstract_server_tls.error=function(e,t){-1===t.message.indexOf("Unknown")&&(console.log("Error TLS server disconnected for request "+o.i_id+" "+t.message),o.destroy())},o.abstract_server_tls.connected=function(){console.log("TLS server connected to socks client for request "+o.i_id),o.tls_server_connected=!0,o._write_=function(e){o.abstract_server_tls?(console.log("tls server send to SOCKS"),o.abstract_server_tls.prepare(Rl(e.toString("hex"))),o.done_&&o.destroy()):console.log("can't send to SOCKS server connection closed for request "+o.i_id)},o.__write__=o._write_,o.abstract_server_tls.dataReady=function(e){console.log(e.data.read);var t=e.data.data.slice(e.data.read,e.data.length_).toString("utf8");-1!==t.indexOf("Host")&&(e.data.read=e.data.length_,console.log("TLS server receive "+t),o.ini_data=t,u(t))}}),o.abstract_server_tls.process(e);else{var d=e.toString("utf8");o.ini_data=d,u(d)}}}if(this.OR_){var i=e.slice(0,2).readUInt(),s=e.slice(2,2+i).toString("utf8");e=e.slice(2+i);var o=Bn[s];if(e.length)return void o.write(e);o.bufferSize||(console.log("OR ws destroy request "+o.i_id),o.end())}},relay_db_info_handle:function(e){console.log("receive relay_db_info CID "+this.circId);var t,r,i,n,s,a;t=e[0],e=e.slice(1),n=e.slice(0,t).toString("hex"),e=e.slice(t),r=e[0],e=e.slice(1),e.length&&(i=e[0]),console.log("db_info "+n+" part "+r+" fac "+(i?"yes":"no")),s=kn[n],s?(s.forEach(function(e){e[0]===this&&(a=!0)},this),a||s.push([this,null,null,0])):kn[n]=[[this,null,null,0]],i&&(console.log(Rn.indexOf(this)),-1===Rn.indexOf(this)&&(console.log("pushing facilitator CID "+this.circId),Rn.push(this)))},relay_db_query_handle:function(e){var t=e.streamId.readUInt();console.log("receive relay_db_query CIC "+this.circId+" sid "+t),e=e.data.slice(0,e.length.readUInt());var r=e[0];e=e.slice(1);var i=e.slice(0,r).toString("hex");e=e.slice(r),r=e[0],e=e.slice(1);var n=parseInt(e.slice(0,r).toString("hex"),16);if(e=e.slice(r),console.log("Receive db_query for "+i+" on CID "+this.circId+" sid "+t+" requesting "+n+" bytes "+e.toString("hex")),this.OP_){var s=e.slice(0,16),a=this.first_;if(i!==La){var o=go(),c=o.get(i);c.onsuccess=function(e){var t=e.target.result;if(t)if(t.file_length===t.current_length&&n<t.file_length){t.data=xi?new _o(t.data):t.data instanceof Blob?t.data:new Blob(t.data);var r,o=t.data.slice(n),c=t.file_length;r=t.type!==t.data.type&&!Ji||Ji&&t.enc?t.type+";"+(t.data.type||t.enc):t.type;var l=ec(a);console.log("Have file "+i+" length "+c+" to be sent "+n+" tid "+s.toString("hex")+" "+(o.size||o.byteLength)+" CID "+a.circId+" sid "+l),a.send_db_connected(c,l,r,s),a.send_db_data(o,l)}else a.send_db_end(0,l,s);else if(xi){var h="magnet:?xt=urn:btih:"+i,u={},d=[];console.log("looking for torrent "+h+" myip "+un);var l=ec(a);a.send_db_connected(0,l,"torrent",s);var f=i.substr(0,Pa/4)+an.randomBytes((160-Pa)/8).toString("hex");console.log("fake infohash "+f),oo();var p=cn({debug:!1,freerider:!1,blocklist:Xi,myip:un});a[l].__ini_dht__=p;{p.nodeId.toString("hex")}p.on("ready",function(){a.send_db_connected(0,l,"dhtready",s),console.log("dht ready - starting lookup for infohash "+f+" "+(new Date).toTimeString()),p.lookup(f)});var _=function(e){var t=e.split(":")[0];Xi.contains(t)||(console.log("new spy "+e,!0),Xi.add(t),hn.push(t))},g=function(e,t){var r=Bo(t.toString("hex"),f),i=e.split(":")[0];if(!Xi.contains(i)&&r>=Fa&&qa>=r){var n=e.split(":")[0];n=n.split("."),n.reverse(),n=n.join(".")+"."+za;var s=function(r){r?u[e]=t:(console.log("--------------- potential spy "+e),_(e))};m(n,s)}},m=function(e,t){sn.resolve(e,function(e){return e&&"ENOTFOUND"===e.code?t(!0):t()})};p.on("peer",_),p.on("node",g),p.on("closest",function(){p.removeListener("peer",_),p.removeListener("node",g),a.send_db_connected(0,l,"start",s),console.log("starting torrent for "+h+" nb of closest nodes: "+p.closest_from_infohash.length);var e=on(h,{blocklist:hn||null,connections:20,path:oi+"node_modules/torrent",verify:!0,debug:!1,freerider:!0,dht:p}),t=function(){var r=[];if(!Array.isArray(u)){var n=[];Object.keys(u).forEach(function(e){n.push({addr:e,id:u[e]})}),u=n,n=[]}if(console.log("Number of closest "+u.length),u.length||(u=p.closest_from_infohash),u){console.log("settorrent dht ready",!0);var s=function(t,i){if(!t&&i.values){var n=i.values.length,s=n>Ha?Ma:0,a=Math.ceil(n*s);i.values.forEach(function(e,t){t>a&&(Xi.contains(e.split(":")[0])?console.log("------------- blocked spy "+e,!0):d.push(e))})}if(r.length)r.shift()();else{var o=[];d=ko.call(d),d.sort(function(){return.5-Math.random()}),console.log("launch torrent nb_peers "+d.length),d.length>=Ha&&d.forEach(function(e){var t=e.split(":")[0];-1===o.indexOf(t)?o.push(t):(console.log("----------- potential spy"),_(e))}),d.forEach(function(t){e.discovery.emit("peer",t)})}};if(u.length>20){var n=[],a=[];u.forEach(function(e){var t=e.addr.split(":")[0];-1===n.indexOf(t)&&(n.push(t),a.push(e))}),u=a,u.sort(function(){return.5-Math.random()}),u=u.slice(0,20)}u.forEach(function(e){{var t=e.addr;t.split(":")[0]}console.log(t,!0),r.push(function(){console.log("sending getpeer to "+t),p._sendGetPeers(t,i,function(e,r){s(e,r,t)})})}),r.length&&r.shift()()}else console.log("settorrent dht not ready, retry later"),setTimeout(t,dn)};e.on("setTorrent",t),a[l].__torrent__=e,e.on("ready",function(){if(e.files.length){console.log("torrent ready");var t={length:0};if(e.files.forEach(function(e){e.length>t.length&&(t=e)}),console.log("sid "+l+" csize "+n+" file length "+t.length),n<t.length){var r,i=tc(t.name);i&&(r=Ga[i]),r||(r="application/octet-binary"),console.log("filename "+t.name+" length "+t.length+" type "+r),t.size=t.length,a.send_db_connected(t.length,l,r,s);var o=a[l];o.fc_t=[],o.cd_length=t.length,o.reader=new uo,o.cursor=n||0,console.log("cursor csize "+n),o._torrent_=new po(t.length-o.cursor),o._stream_||(o.down_limit=Ra),o._torrent_stream=t.createReadStream({start:n,end:t.length}),o._torrent_stream.on("data",function(t){var r=0;e.swarm._queues.forEach(function(e){r+=e.length}),console.log("got for torrent sid "+l+" "+t.length+" bytes of data - offset "+o._torrent_stream._piece+" - nb peers: "+e.swarm.wires.length+" - other peers "+r),o._torrent_.push(t),o.cursor===n&&(o.start_t0=Date.now(),Zo.call(a,o._torrent_,l,o))}),o._torrent_stream.on("end",function(){console.log("torrent stream end ----"),console.log("destroying torrent engine"),ao(o)}),o._torrent_stream.on("close",function(){o.fc_t&&(o.fc_t.length?(console.log("queue not empty - stop sending"),o.stop_=!0):(console.log("queue empty - delete request"),delete a[l])),console.log("destroying torrent engine"),ao(o)});var c=0,h=0,u=function(){c=e.swarm.wires.length,c!==h&&(console.log("--- Peers in swarn:",!0),e.swarm.wires.forEach(function(e){console.log(e.peerAddress,!0)})),h=c};setInterval(u,1e4)}else console.log("bad torrent file"),ao(o),a.send_db_end(0,l)}else console.log("no torrent files"),ao(o),a.send_db_end(0,l)})})}else a.send_db_end(0,l,s)}.bind(this)}else a.send_db_end(0,t,s)}else{console.log("ORDB receive db_query for "+i+" on CID "+this.circId+" sid "+t+" requesting "+n+" bytes ");var l=kn[i];if(l){l.sort(function(e,t){var r=e[3],i=t[3];return r===i?0:i>r?-1:1}).sort(function(e,t){return e[0].socket_?t[0].socket_?0:1:-1});var r=l.length;if(l.forEach(function(e){console.log("f has "+e[0].circId+" valid "+(e[0].socket_?"yes":"no"))}),r){for(;l.length;)if(l[0][0].socket_)if(l[0][0].socket_.remoteAddress){if(!l[0][0].destroyed_)break;console.log("ORDB remove destroyed CIC "+l[0][0].circId),l.shift()}else console.log("ORDB remove "+l[0][0].circId),l[0][0].circuit_destroy(),l.shift();else console.log("ORDB remove "+l[0][0].circId),l[0][0].circuit_destroy(),l.shift();if(l.length){var h=l[0][0];l[0][3]++;var s=ac(16),u={d_length:n,hash_:new ii(i,"hex")};Un[s.toString("hex")]=[this,t,l,u,1],h.send_db_query(u,s)}else nc.call(this,t,n,i)}else nc.call(this,t,n,i)}else Rn.length?nc.call(this,t,n,i):(console.log("ORDB does not know the file"),this.send_db_end(0,t))}},relay_db_connected_handle:function(e){var t=e.streamId.readUInt();if(console.log("receive relay_db_connected CID "+this.circId+" sid "+t),e=e.data.slice(0,e.length.readUInt()),this.OP_){var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),s=this.first_[t];if(console.log("relay_db_connected type "+n),s){if("torrent"===n){if(s.url_)return console.log("direct download"),this.first_.send_db_end(1,t),rc(s),_u(s.query_t0),void xc(s);So(document.body,"mousedown",function(){},!1),console.log("put torrent timer"),s._streaming_||du('<p style="text-align:center">The file is not available in Peersm network, looking for it in Bittorrent network, please wait.</p>'),s._torrentc_=setTimeout(function(){this.first_.send_db_end(1,t),rc(s),ic(s),du('<p style="text-align:center">Could not find the file in bittorrent, stopping download</p>')}.bind(this),Oa)}else mo("alert_box").style.display="none",s._torrentc_&&(console.log("remove torrent timer"),clearTimeout(s._torrentc_));if(-1!==["dhtready","start"].indexOf(n))return void(s._streaming_||du("dhtready"===n?'<p style="text-align:center">The file is not available in Peersm network<br><br>Looking for it in bittorrent network<br><br>Connected to bittorrent, routing table ready<br><br>Starting peers lookup, please wait...</p>':'<p style="text-align:center">Peers found, starting torrent</p>'));s.flowc=s.flowc?s.flowc:Date.now()-s.query_time,console.log("db_query/db_connected "+(Date.now()-s.query_time)+" ms "+s.flowc),_u(s.query_t0),s.clength_=i,s.pieces=Math.ceil(s.clength_/Ja),s.content_=n,s.sid_=t,s.received_=0,s.sent_=0,s.nb_try=0,s.stream_window=eo,s.stream_window_s=eo,s._stream_&&"torrent"!==n&&Hh(s)}}else{var a=e.slice(0,16).toString("hex");e=e.slice(16);var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),o=Un[a];-1===["torrent","dhtready","start"].indexOf(n)&&delete Un[a],console.log("db_connected "+a+" type "+n+" size "+i+" "+typeof o),this.nb_query=0,o&&(this.socket_?o[0].socket_&&(o[0].send_db_connected(i,o[1],n),Dn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t]=o,Nn[o[0].socket_.remotePort+"-"+o[0].socket_.remoteAddress+"-"+o[0].circId+"-"+o[1]]=[this,t],this[t]={},o[0][o[1]]={},console.log("i_or associated with remote port "+this.socket_.remotePort+" remote address "+this.socket_.remoteAddress+" CIC "+this.circId+" Stream "+t),console.log("f_or associated with remote port "+o[0].socket_.remotePort+" remote address "+o[0].socket_.remoteAddress+" CIC "+o[0].circId+" Stream "+o[1])):o[0].send_db_end(0,o[1]))}},relay_db_end_handle:function(e){var t=e.streamId.readUInt();e=e.data.slice(0,e.length.readUInt());var r=e.slice(0,1).readUInt();if(console.log("receive db_end sid "+t+" reason "+r+" CIC "+this.circId),this.OP_){var i=this.first_,n=i[t];if(n)if(n.send_data)n.fc_t?n.fc_t.length?(console.log("queue not empty - stop sending"),n.stop_=!0):(console.log("queue empty - delete request"),delete i[t]):ao(n);else if(_u(n.query_t0),_u(n.sendme_tout),_u(n.waiting_),2===r||n.reason_||3===r){_u(n.sendme_tout),_u(n.waiting_),n.reason_=2;var s=function(){if(n.nb_try<Ls){console.log("Resuming peer download"),n.queue_.shift();var e=function(e){e.params_.db_=!0,delete i[t],delete e.cid_,delete e.eof_,delete e.check_hash,delete e.file_id,delete e.start_t0,e.received_=0,e.reload_=!0,e.queue_=[],e.queue_s=[],e.blob_=Ji?new ii(0):new Blob([],{type:e.content_chrome?e.content_chrome:e.content_}),e.cid_=ks,e.nb_try++,e.db_try=0,xc(e)};n._stream_?(nu&&nu.pause&&nu.pause(),n._parent_&&n._parent_.connected_sources--,e(n)):Nh(n,!0,e)}else n.nb_try===Ls&&(n._stream_?(So(document.body,"mousedown",function(){},!1),du('<p style="text-align:center">The remote peers closed the connections, attempts to resume streaming failed.</p>')):(So(document.body,"mousedown",function(){},!1),du('<p style="text-align:center">The remote peers closed the connections during the download, attempts to resume failed, storing downloaded part, please wait that the file appears in Local Storage.</p><p style="text-align:center">Use resume later to get the complete file.</p>'),kh(n)),delete n.reason_)};n.queue_=n.queue_||[],n.queue_.push(s),1===n.queue_.length&&n.queue_[0]()}else if(n.url_)if(n.reload2_||n.reload_){console.log("resuming direct download");var a=function(e){var r=e.d_length;e.blob_=Ji?new ii(0):new Blob([],{type:e.content_chrome?e.content_chrome:e.content_});var n=Lo(e.url_);e.params_.stream=Vo(n.host,n.rest,r),delete e.params_.db_,delete e.cid_,delete i[t],delete e.file_id,delete e.start_t0,e.received_=0,xc(e)};Nh(n,!0,a)}else this.destroy_cid(n),delete n.params_.db_,delete n.content_,delete n.d_length,delete n.clength_,delete n.blob_,zh&&(Kh.vAxis.maxValue=Js,zh.draw(Vh,Kh)),xc(n);else So(document.body,"mousedown",function(){},!1),du('<p style="text-align:center">The file is currently not available from peers in Peersm and Bittorrent networks and can not be downloaded directly, please check the URL or the Hash Name you are using</p>'),iu=!1,rc(n),ic(n)}else if(this.nb_query=0,e.length>1){console.log("db_end with tid CIC "+this.circId+" db_test length "+(this.db_test?this.db_test.length:"")),this.db_test&&this.db_test.forEach(function(e){clearTimeout(e)});var o=e.slice(1,17).toString("hex"),c=Un[o];if(c){var l=c[2],h=c[4];if(l[h]){c[4]++;var u=l[h][0];u.send_db_query(c[3],new ii(o,"hex")),console.log("try another peer "+u.circId+" tid "+o+" stream length "+e.length)}else Rn.length?nc.call(this,t,c[3].d_length,c[3].hash):(c[0].send_db_end(r,c[1]),delete Un[o])}}else{console.log("forwarding db_end");var d=Nn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t];if(d)try{3!==r&&(delete Dn[d[0].socket_.remotePort+"-"+d[0].socket_.remoteAddress+"-"+d[0].circId+"-"+d[1]],delete Nn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t],delete d[0][d[2]]),d[0].send_db_end(r,d[1])}catch(f){}else{var p=Dn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t];if(p)try{p[0].send_db_end(r,p[1]),delete Nn[p[0].socket_.remotePort+"-"+p[0].socket_.remoteAddress+"-"+p[0].circId+"-"+p[1]],delete Dn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t],delete p[0][p[2]]}catch(f){}}delete this[t]}},relay_db_data_handle:function(e){if(bi)var t=Date.now();var r=e.streamId.readUInt();if(e=e.data.slice(0,e.length.readUInt()),this.OP_){var i=this.first_,n=i[r];if(n){0===n.received_&&(console.log("start_t0 received "+Date.now()),n.start_t0=Date.now(),i.send_db_sendme(r)),n.received_++,i.received_++,n.stream_window--,n._write_(e);var s=n.received_,a=parseInt(e.length*n.received_/((Date.now()-n.start_t0)/1e3)),o=Math.ceil(a*(n.flowc/2/1e3)/e.length);o=Math.ceil(eo-o>0?Math.min(o,eo*(1-ys)):eo*(1-ys));var c,l=function(t){var s=function(e){console.log("sendme timeout received_ "+n.received_+" rec "+e+" stream-blocs "+(eo-o)),n.received_!==e||n._stream_?l(n.received_):(_u(n.sendme_tout),_u(n.waiting_),console.log("resuming peer to peer download received "+n.received_),i.send_db_end(1,r),i.relay_db_end_handle({streamId:new ii(2).writeUInt(r),length:new ii(2).writeUInt(1),data:new ii(1).writeUInt(2)}))};_u(n.sendme_tout),_u(n.waiting_),console.log(8*a+" bps nbBlocs "+o+" stream window "+n.stream_window+" - sending sendme stream received "+i.received_*e.length+" - Buffer Amount: "+Zl.bufferedAmount+" "+Date.now()),i.send_db_sendme(r),n.stream_window+=eo,console.log("sendme timeout "+c+" stream length "+e.length),n.sendme_tout.push(setTimeout(function(){s(t)},c))};n.stream_window===o&&(0===Zl.bufferedAmount||i.received_*e.length<to||n.waiting_?(n.last_sendme=Date.now(),c=a?Math.ceil((eo-o)*e.length/a*1e3)+vs:vs,l(s)):(_u(n.sendme_tout),_u(n.waiting_),n.waiting_.push(setTimeout(function(){console.log("timeout waiting_ buffered "+Zl.bufferedAmount),l(s)},Date.now()-(n.last_sendme||n.start_t0))),console.log(8*a+" bps nbBlocs "+o+" - waiting before sending sendme stream received "+i.received_*e.length+" - Buffer Amount: "+Zl.bufferedAmount+" "+Date.now())))}t&&(ya++,va++,ba+=Date.now()-t,ya%wa===0&&ba&&(console.log("_WRITE_ perf: "+parseInt(e.length*va*8/(ba/1e3))+" bps - Buffered : "+Zl.bufferedAmount),ya=0,va=0,ba=0))}else{var h=Dn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];h&&h[0].send_db_data(e,h[1])}},relay_db_sendme_handle:function(e){var t=e.streamId.readUInt();if(this.OP_){console.log("OP received sendme sid "+t+" resuming - buffered amount "+(xi?this.first_.socket_.bufferSize:this.first_.socket_.bufferedAmount));var r=this.first_,i=r[t];if(i){var n=i.pause_[t];i.stream_window_s+=eo,console.log("stream_window "+i.stream_window_s+" sent "+i.sent_+" fc_t "+i.fc_t.length),n&&(delete i.pause_[t],i._torrent_?Zo.call(r,n,t,i,0):r.send_db_data(n,t,!1,!0))}}else{var s=Nn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t];s&&s[0].send_db_sendme(s[1])}},keep_alive:function(){var e=new lc(this.circId,lc.prototype.PADDING,new ii("00","hex"));this.send(e)},destroy_cid:function(e,t){var r=e.sid_;if(e){if(t){var i=new uc(uc.prototype.RELAY_END,e.sid_,new ii(0),this.last_.Df_hash),n=new lc(this.circId,lc.prototype.RELAY,this.last_.stream_encrypt_forward(i));this.send(n)}delete e.cid_,delete this.first_[r],delete e.sid_,delete this.first_.request_}},setCircId:function(){if(0==this.circId&&delete this.socket_[0],this.OP_){if(this.circId=Go(this.socket_),!this.circId)return!1;this.socket_[this.circId]=this;var e=this,t=this.path_.length-1;this.first_=this,this.t0_=[];for(var r=0;t>r;r++){var i=new hc;i.OP_=!0,i.t0_=[],i.server_=e.path_[r+1],e.next_=i,i.prev_=e,i.path_=e.path_,i.nb_=e.nb_+1,i.socket_=this.socket_,i.circId=this.circId,i.first_=this,e=i}return!0}var n=parseInt(this.server_.fing,16)<parseInt(Fn,16)?!0:!1;this.circId=Go(this.socket_,!0,n?jn:null),this.socket_[this.circId]=this},process:function(e){if(this.last_.first_=this,!e)var e=this.request_;if(e.download_&&!e._stream_&&(So(document.body,"mousedown",function(){},!1),e._data_||e.nb_try?(e._data_=0,du('<p style="text-align:center">Resuming direct download from '+this.last_.server_.ip+"</p>")):du('<p style="text-align:center">File not available from Peers, starting direct download from '+this.last_.server_.ip+"</p>"),setTimeout(function(){mo("alert_box").style.display="none",So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1)},12e3)),e.cid_=this,e.params_.host&&!e.destroyed){var t=new ii(e.params_.host);t=new ii(t.toString("hex")+"00","hex");var r=Go(this);if(r){console.log("STREAM : --------------SEND RELAY_BEGIN---------------------- CID "+this.circId+" on OR "+this.first_.server_.ip+" Stream "+r+" for request "+e.i_id+" on port "+e.remotePort+" host "+t.toString("utf8")),this[r]=e,e.sid_=r,e.received_=0,e.sent_=0,e.stream_window=gs,e.stream_window_s=gs;var i=function(){var t=this;console.log("Timeout Bad circuit "+t.circId),!t.perf_>0&&(t.bad_=!0),t.send_relay_end(r),e.nb_try++,delete e.cid_,delete t[r],xc(e)},n=function(){var n=new uc(uc.prototype.RELAY_BEGIN,r,t,this.last_.Df_hash),s=new lc(this.circId,lc.prototype.RELAY,this.last_.stream_encrypt_forward(n));Fs&&(e.socket_retry=setTimeout(i.bind(this),cs)),this.send(s)};n.call(this)}}},sendme:function(e){e=e||{sid_:0,i_id:-1};var t=new uc(uc.prototype.RELAY_SENDME,e.sid_,new ii(0),this.last_.Df_hash),r=new lc(this.circId,lc.prototype.RELAY,this.last_.stream_encrypt_forward(t));this.send(r)},set_certs:function(e){try{e=e.split(Wn),this.server_.onion_k=Wn+e[1].split(Qn)[0]+Qn,this.server_.sign_k=Wn+e[2].split(Qn)[0]+Qn;var t=new yn;return this.server_.o_modulus=t.modulus(this.server_.onion_k),this.server_.s_modulus=t.modulus(this.server_.sign_k),!0}catch(r){return this.nb_error=this.nb_error?++this.nb_error:1,!1}},get_certs:function(e){if(this.server_&&!this.ok_){var t=pn.length,r=this.server_.fing,i=qo(t),n=pn[i].split(":"),s=n[0],a=n[1],o={host:s,path:"/tor/server/fp/"+r,port:a,headers:{Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"gzip deflate","Accept-Language":"fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3","Cache-Control":"max-age=0",Connection:"keep-alive",Host:s,"User-Agent":"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0"}},c=nn.request(o,function(t){if(c.data_="",200!=t.statusCode){this.clear_t0_();
try{this.get_certs(e)}catch(i){}}t.on("data",function(e){this.clear_t0_(),c.data_+=e.toString("utf8")}.bind(this)),t.on("end",function(){this.server_&&!c.destroy_&&(this.certs_||(this.set_certs(c.data_)?(this.certs_=!0,e.call(this.prev_?this.prev_:this)):this.nb_error>4?this.change_or("CERTS : get_certs wrong cert for "+r,this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e)))}.bind(this))}.bind(this)),l=function(){this.clear_t0_(),this.server_&&(this.nb_error=this.nb_error?++this.nb_error:1,this.nb_error>4?this.change_or("error get_certs",this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e))}.bind(this);c.on("error",l),c.end();var h=function(){this.clear_t0_(),c.removeListener("error",l),l=function(){console.log("CERTS : error fired after abort for "+s)},c.on("error",l),c.destroy_=!0,c.socket.destroy(),this.server_&&this.get_certs(e)}.bind(this);this.t0_.push(setTimeout(h,1e3))}},change_or:function(e,t){if(this.server_){console.log("change_or ----------- CIC "+this.circId);var r,i,n=[];if(this.first_)var s=this.first_.request_;var a="undefined"==typeof s?null:s.params_?s.params_.db:null;if(this.prev_||!Zi||("undefined"==typeof this.server_?1:this.server_!==Zi)){if(this.first_===ks||a)return void(this.first_&&(console.log("change_or circuit destroy"),this.first_.circuit_destroy(),s&&mc(s)));var i=this.prev_?this.next_?fn:Exit:Guards,o=i.length;for(this.clear_timers(),this.clear_t0_(),this.path_?n=this.path_.map(function(e){return e.ip}):n.push(this.server_.ip),r=qo(o);-1!=n.indexOf(i[r].split("-")[1]);)r=qo(o);var c=i[r].split("-");i={ip:c[1],fing:c[0],port:c[2],band:c[3],o_modulus:c[5]?c[5]:c[4]}}else console.log("change_or one OR "+this.circId),i=Zi;for(var l=this;l;)delete l.destroy_,delete l.nb_error,delete l.ok_,l=l.next_;delete this.first_.last_;var h=new hc;Object.keys(this).forEach(function(e){h[e]=this[e]},this),h.server_=i;try{var u=this.server_.ip;this.server_o=this.server_}catch(d){console.log("_server error"),this.clear_timers();for(var f in this)"function"!=typeof this[f]&&console.log(f+" "+this[f]);this.first_.destroy()}delete this.server_,delete h.certs_,this.next_&&(h.next_.prev_=h),this.prev_?(h.prev_.extended_&&(h.prev_.extended_=h),h.prev_.next_=h,-1==e.indexOf("get_certs")&&(h=h.prev_,delete h.certs_)):h.first_=h,h.first_.reconstruct_path(),t&&(this.prev_||this.first_===this)?t.call(h):this.socket_.first_===this?(delete Sn[u],h.socket_&&(this.destroy_=!0,h.socket_.destroy(),delete h.socket_),delete h.extended_,h.circId=0,h.first_=h,h.path_.shift(),h.path_.unshift(h.server_),Tc(h)):this.next_.change_or("PATH : first socket exists, change path",this.create)}},circuit_retry:function(){if(!as&&this.socket_)if(this.ok_||this.socket_.first_!==this){this.destroy(),delete this.ok_,delete this.first_.last_;var e=this.circId;this.circId=Go(this.socket_),delete this.socket_[e],this.socket_[this.circId]=this,this.socket_.nbc_--;for(var t=this;t.extended_;)t.extended_.circId=this.circId,t=t.extended_,delete t.extended_;this===t&&this.socket_.first_!==this?t.create():t.change_or("circuit_retry from first OR circId="+this.circId,this.create.bind(this))}else this.change_or("initial socket closed unexpectedly or unexpected circuit creation error or new circuit creation error")},reconstruct_path:function(){for(var e=this,t=[];e.next_;)t.push(e.server_),e=e.next_;for(;e.prev_;)e.path_=t,e.first_=this,e=e.prev_},circuit_destroy:function(e){if(this.socket_){console.log(this.socket_.remoteAddress?"CIRC : circuit destroy "+(this.OP_?"OP ":"OR "+(this.OR_f?"in ":"out "))+(this.socket_.address()?this.socket_.address().address:"")+" CID "+this.circId+" remote "+this.socket_.remoteAddress:"circuit destroy : socket no remote address CIC "+(this.OP_?"OP ":"OR ")+" "+this.circId);var t;if(this.socket_){var r=this.socket_;this.next_?e||this.destroyed_||(this.destroyed_=!0,r.remoteAddress&&(console.log("circuit_destroy remote address "+r.remoteAddress+" CIC "+this.circId),this.destroy())):this.socket_.address()&&Wa&&parseInt(this.socket_.address().port)===parseInt(On)&&r.OR_f&&(console.log("ORDB - call db_destroy"),this.circuit_db_destroy()),delete r[this.circId],delete this.socket_,Object.keys(r).forEach(function(e){isNaN(e)||null==e||(t=!0)},this),t||this===ks||r.ws_||(console.log("circuit_destroy: destroy socket"),r.destroy())}}console.log("circuit_destroy "+(this.OP_?"OP":"OR")),this.OP_&&(console.log("requests_destroy"),this.requests_destroy()),delete this.next_,delete this.prev_},circuit_db_destroy:function(){this.socket_&&Object.keys(this).forEach(function(e){if(!isNaN(e)&&null!=e){var t=this.socket_?this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+e:this.server_?this.server_.port+"-"+this.server_.ip+"-"+this.circId+"-"+e:"",r=Dn[t]||Nn[t];r&&(console.log("------- "+r[1]),r[0].send_db_end(2,r[1]),delete Nn[t],delete Dn[t],delete this[e],delete r[0][r[1]])}},this)},requests_destroy:function(){for(var e in this)if(!isNaN(e)&&null!=e){var t=this[e];t.abstract_client_tls&&t.abstract_client_tls.close(),delete t.abstract_client_tls,this.destroy_cid(t),ks?this!==ks?t._data_?t.destroy():this.request_retry(t,"requests_destroy"):jo(t):Fs&&jo(t)}if(Os){if(this===Bs){console.log("destroy CIC resend associate ");for(var e in Is)delete Is[e].associated;Bs=null,xc({params_:{OP:!0,nb_hop:Gn,ws:Zl}})}}else ks?this===ks&&(ks=null,xc({params_:{OP:!0,nb_hop:Yn,ws:Zl,db:!0}})):Fs&&xc({params_:{OP:!0,nb_hop:Yn,ws:Zl,db:!0}})},clear_timers:function(){this.OP_&&(this.first_.tc_.forEach(function(e){clearTimeout(e)}),this.first_.tc_=[])},clear_t0_:function(){this.t0_&&(this.t0_.forEach(function(e){clearTimeout(e)}),this.t0_=[])},end:function(e,t,r){if(r)var i=this.first_||this,n=i[r]?i[r]:i.request_;this.OP_,e=e.split(":"),console.log2=function(){};var s=function(){if(e.length>1)switch(parseInt(e[1])){case 0:return console.log2("-- CIC NONE            (No reason given.)"),0;case 1:return console.log2("-- CIC PROTOCOL        (Tor protocol violation.)"),1;case 2:return console.log2("-- CIC INTERNAL        (Internal error.)"),2;case 3:return console.log2("-- CIC REQUESTED       (A client sent a TRUNCATE command.)"),3;case 4:return console.log2("-- CIC HIBERNATING     (Not currently operating; trying to save bandwidth.)"),4;case 5:return console.log2("-- CIC RESOURCELIMIT   (Out of memory, sockets, or circuit IDs.) "+this.circId+" "+(this.OP_?" OP ":" OR ")),5;case 6:return console.log2(" -- CIC CONNECTFAILED   (Unable to reach relay.)"),6;case 7:return console.log2("-- CIC OR_IDENTITY     (Connected to relay, but its OR identity was not as expected.)"),7;case 8:return console.log2("-- CIC OR_CONN_CLOSED  (The OR connection that was carrying this circuit died CID "+this.circId+" "+(this.OP_?" OP ":" OR ")),8;case 9:return console.log2("-- CIC FINISHED        (The circuit has expired for being dirty or old.)"),9;case 10:return console.log2("-- CIC TIMEOUT         (Circuit construction took too long)"),10;case 11:return console.log2("-- CIC DESTROYED       (The circuit was destroyed w/o client TRUNCATE)"),11;case 12:return console.log2("-- CIC NOSUCHSERVICE   (Request for unknown hidden service)"),12}}.bind(this),a=function(){if(e.length>1)switch(parseInt(e[1])){case 1:return console.log2("-- RELAY REASON_MISC           (catch-all for unlisted reasons) request "+(n?n.i_id:"")),1;case 2:return console.log2("-- RELAY REASON_RESOLVEFAILED  (couldn t look up hostname) request "+(n?n.i_id:"")),2;case 3:return console.log2("-- RELAY REASON_CONNECTREFUSED (remote host refused connection) [*] request "+(n?n.i_id:"")),3;case 4:return console.log2("-- RELAY REASON_EXITPOLICY     (OR refuses to connect to host or port) request "+(n?n.i_id:"")),4;case 5:return console.log2("-- RELAY REASON_DESTROY        (Circuit is being destroyed) request "+(n?n.i_id:"")),5;case 6:return console.log2("-- RELAY REASON_DONE           (Anonymized TCP connection was closed) request "+(n?n.i_id:"")),6;case 7:return console.log2("-- RELAY REASON_TIMEOUT        (Connection timed out, or OR timed out while connecting) request "+(n?n.i_id:"")),7;case 8:return console.log2("-- RELAY REASON_NOROUTE        (Routing error while attempting to contact destination) request "+(n?n.i_id:"")),8;case 9:return console.log2("-- RELAY REASON_HIBERNATING    (OR is temporarily hibernating) request "+(n?n.i_id:"")),9;case 10:return console.log2("-- RELAY REASON_INTERNAL       (Internal error at the OR) request "+(n?n.i_id:"")),10;case 11:return console.log2("-- RELAY REASON_RESOURCELIMIT  (OR has no resources to fulfill request) request "+(n?n.i_id:"")),11;case 12:return console.log2("-- RELAY REASON_CONNRESET      (Connection was unexpectedly reset) request "+(n?n.i_id:"")),12;case 13:return console.log2("-- RELAY REASON_TORPROTOCOL    (Sent when closing connection because of Tor protocol violations.) request "+(n?n.i_id:"")),13;case 14:return console.log2("-- RELAY REASON_NOTDIRECTORY   (Client sent RELAY_BEGIN_DIR to a non-directory relay.) request "+(n?n.i_id:"")),14}}.bind(this);if(t)switch(t){case"handshake":this.change_or("handshake failed");break;case"fast_key":this.change_or("wrong fast key");break;case"created_extended_key":this.change_or("wrong create or extend key",this.prev_?this.prev_.extend:null);break;case"truncated":this.relay_truncated_handle(s());break;case"truncate":this.relay_truncate_handle(s());break;case"begin_dir":this.send_relay_end_b(r,a());break;case"destroy":this.handle_destroy(s());break;case"unrecognized":console.log("end unrecognized circuit destroy"),this.circuit_destroy();break;case"relay_end":n&&"undefined"!=typeof n.i_id&&this.relay_end_handle(r,a())}else delete this.socket_[this.circId]}};var uc=function(e,t,r,i){this.command=new ii(1).writeUInt(e),this.recognize=new ii("0000","hex"),this.streamId=new ii(2).writeUInt(t),this.digest=new ii("00000000","hex"),this.length=new ii(2).writeUInt(r.length),this.data=new ii(e===this.RELAY_WS?r.length:bn),this.data.map(r),i&&(i.update(this.toBuffer()),this.digest=new ii(i.digest("hex"),"hex").slice(0,4))};uc.prototype={RELAY_BEGIN:1,RELAY_DATA:2,RELAY_END:3,RELAY_CONNECTED:4,RELAY_SENDME:5,RELAY_EXTEND:6,RELAY_EXTENDED:7,RELAY_TRUNCATE:8,RELAY_TRUNCATED:9,RELAY_DROP:10,RELAY_RESOLVE:11,RELAY_RESOLVED:12,RELAY_BEGIN_DIR:13,RELAY_ASSOCIATE:40,RELAY_WS:41,RELAY_INFO:42,RELAY_DB_INFO:80,RELAY_DB_QUERY:81,RELAY_DB_CONNECTED:82,RELAY_DB_DATA:83,RELAY_DB_END:84,RELAY_DB_SENDME:85,toBuffer:function(){return[this.command,this.recognize,this.streamId,this.digest,this.length,this.data].concatBuffers()}};var dc,fc,pc,_c=function(e){switch(this.Command.readUInt()){case this.VERSIONS:return this.versions_cell_decode(e);case this.CERTS:return this.certs_cell_decode(e);case this.AUTH_CHALLENGE:return this.auth_challenge_cell_decode(e);case this.NETINFO:return this.netinfo_cell_decode(e);case this.CREATED_FAST:return this.created_fast_cell_decode(e);case this.CREATED_FAST_WS:return this.created_fast_ws_cell_decode(e);case this.CREATE_FAST:return this.create_fast_cell_decode(e);case this.CREATE_FAST_WS:return this.create_fast_ws_cell_decode(e);case this.CREATED:return this.created_cell_decode(e);case this.CREATE:return this.create_cell_decode(e);default:return[e]}},gc=function(e,t){if(e)for(var r=e.length,i=0;r>i;i++){var n=e[i],s=n.CircID.readUInt();if(this[s])var a=this[s];else{if(!this.OR_||!this.OR_f)return;if(this[0]){var a=this[0];a.circId=s,this[s]=a,delete this[0]}else{var a=new hc;a.OR_=!0,a.OR_f=!0,a.circId=s,a.socket_=this,a.way_="socket in",this[s]=a}}try{a.clear_timers()}catch(o){}if(6===n.Command.readUInt()&&console.log("handle cell "+n.Command.readUInt()),Gh&&zh&&(chart1_int||chart2_int)&&n.Command.readUInt()!==n.PADDING){var c=Mo(new Date).getTime(),l=0;n.Payload.forEach(function(e){l+=e.length}),a.first_===ks?chart2_int&&(Gh.dynRow[c]=Gh.dynRow[c]?Gh.dynRow[c]+l:l):chart1_int&&(zh.dynRow[c]=zh.dynRow[c]?zh.dynRow[c]+l:l)}if(a.destroyed_)console.log("received cell for destroyed CIC "+a.circId);else switch(n.Command.readUInt()){case n.PADDING:a.padding_cell_handle(n);break;case n.VERSIONS:a.versions_cell_handle(n);break;case n.CERTS:a.certs_cell_handle(n);break;case n.AUTH_CHALLENGE:a.auth_challenge_cell_handle(n);break;case n.NETINFO:a.netinfo_cell_handle(n);break;case n.CREATE_FAST:a.create_fast_cell_handle(n);break;case n.CREATE_FAST_WS:a.create_fast_ws_cell_handle(n);break;case n.CREATED_FAST:a.created_fast_cell_handle(n);break;case n.CREATED_FAST_WS:a.created_fast_ws_cell_handle(n);break;case n.CREATE:a.create_cell_handle(n);break;case n.CREATED:a.created_cell_handle(n);break;case n.RELAY:a.relay_cell_handle(n,t);break;case n.RELAY_WS:a.relay_cell_handle(n,t);break;case n.RELAY_EARLY:a.relay_cell_handle(n,t);break;case n.DESTROY:a.end("Destroy reason:"+n.Payload[0].slice(0,1).readUInt(),"destroy")}}else console.log("end or banish circuit_destroy"),this.circuit_destroy()},mc=function(e){console.log("circuit_start"),Fs&&ts>rs&&(document.location.href=document.location.href);var t=e.params_,r=[];if(t.nb_hop?(t.nb_hop>2||ai)&&(r=Ho(t)):r=Ho(t),Zi&&(r[0]=Zi),(Os||Fs)&&$i&&!Bs){if(t.ws!==$l)return;r[0]=$i}t.db&&(r[Yn-1]=Wa),console.log("PATH :"+r[0].ip+" "+r[1].ip+" "+(r.length>2?r[2].ip:""));var i=Sn[r[0].ip],n=new hc(r);if(n.request_=e,n.first_=n,n.tc_=[],i)if(i.abstract_client_tls&&!i.tls_connected&&i.wsconnected_)console.log("start TLS handshake - circuit start "),i.abstract_client_tls.handshake();else if(console.log("TLS connected - start create_fast"),n.server_=i.server_,n.socket_=i,n.tc_=[],n.setCircId())if(ia){console.log("Sending fast CIC "+n.circId+" "+i.server_.ip+" "+n.destroyed_),t.db&&(Zl.db_cid_launched=!0),n.X_=ac(20);var s=new lc(n.circId,lc.prototype.CREATE_FAST,n.X_);n.send(s)}else n.create();else console.log("PATH : no more circuits available");else console.log("circuit_start init socket"),n.circId=0,t.ws?t.ws.wsconnected_&&(Ac(t.ws,n),Cc.call(t.ws,n)):Tc(n)},yc=function(e){e&&(console.log("CIRCUITS destroy "+(e.remoteAddress?e.remoteAddress:"")),e.OP_&&delete Sn[e.remoteAddress],Object.keys(e).forEach(function(t){if(!isNaN(t)&&null!=t){var r=e[t];console.log("delete cic "+r.circId+" socket "+(r.server_?r.server_.ip:"")),e.OP_?(r.requests_destroy(),delete Sn[r.server_.ip]):r.next_?r.next_.destroy():r.prev_?r.prev_.destroy():r.circuit_db_destroy(),delete r.socket_,delete e[t]}}))},vc=function(e,t){var r=[];for(var i in Sn){var n=[];Object.keys(Sn[i]).forEach(function(t){var r=Sn[i][t];isNaN(t)||null==t||!r.last_||-1!==e.no_exit.indexOf(r)||r.bad_||(!Fs||r!==ks&&r!==Bs)&&n.push(r)}),n.length&&r.push(n)}if(r.length){if(!t){var s,a,o=r[qo(r.length)];if(e.nb_try){o=o.map(function(e){return[e,e.time_average]}),o.sort(function(e,t){return e=e[1],t=t[1],e==t?0:t>e?-1:1});var i=0,c=o.length;if(Fs)i=parseInt(o.length/2);else for(var l=0;c>l;l++)if(0!==o[l][1]){i=l;break}i&&(o=o.slice(i,Math.min(o.length,$n+i))),Li("best circuits "+(o[0]?o[0][0].circId:"")+" "+(o[1]?o[1][0].circId:"")+" "+(o[2]?o[2][0].circId:"")),a=qo(o.length),s=o[a][0]}else a=qo(o.length),s=o[a],s.time_=(new Date).valueOf();return s}if(1===r.length&&1===r[0].length)return!0}else Fs&&console.log("choose circuit no circuit found for request "+e.i_id)},bc=function(e){return function(){if(this.OR_&&this.address().port===On,this.ws_&&(!Ii||Ti||this.OR_)&&!xi){this.WS_OP_;var t=Xc(this.stream_ws_?[this.stream_ws_,e].concatBuffers():e);try{e=t[0]}catch(r){return console.log("wsdecode error or FIN (first bit at 1):"+(e.length?e[0]:"")+" closing WS."),void this.end()}this.ws_&&this.WS_OP_&&t[1].length,this.stream_ws_=t[1].length?t[1]:null}if(this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.WS_OP_&&this.ws_,hi)var i=Date.now();if(this.ws_&&Fs&&!Ii&&!xi){this.pair.encrypted.t0&&(pa++,_a+=this.stream_tor_.length,ga+=Date.now()-this.pair.encrypted.t0,pa%ma===0&&ga&&(console.log("wsdecode perf (pass to encrypted): "+parseInt(8*_a/(ga/1e3))+" bps"),pa=0,_a=0,ga=0)),this.pair.encrypted.write(this.stream_tor_),this.stream_tor_=new ii(0);var n=this.queue_;n.shift(),n.length&&n[0]()}else this.stream_tor_.parse(this);i&&(aa++,oa+=e.length,ca+=Date.now()-i,aa%la===0&&ca&&(this.OR_?this.address()&&Wa&&this.address().port===On&&this.OR_f&&console.log("Parser perf (ORDB):"+parseInt(8*oa/(ca/1e3))+" bps "+this.stream_tor_.length):console.log("Parser perf:"+parseInt(8*oa/(ca/1e3))+" bps "+this.stream_tor_.length),aa=0,oa=0,ca=0))}},wc=function(e){this.queue_=this.queue_||[],this.queue_.push(bc(e).bind(this)),1===this.queue_.length&&this.queue_[0]()},Sc=function(){delete this.end_,delete this.html_,delete this.header_,delete this.header_l,delete this.content_,delete this.content_l,delete this.clength_,delete this.encoding_,delete this.pass_,delete this.t0_,delete this.script_,delete this.header_sent,delete this.decoder_,delete this.f_,delete this.wait_,delete this.buff_,this.nb_try=0,delete this.time_resp},Ec=function(e){var t={};Sc.call(t),t.params_={},t.params_.OP=!0,t.params_.nb_hop=Gn,t.params_.one_c=!0,t.nb_try=0,t.no_exit=[],t.squeue_=[],t.wsqueue_=[],t._date_=Date.now(),t.i_id=io,io++,e=Lo(e),t.params_.host=e.host;var r="GET /"+e.rest+" HTTP/1.1\r\n";return r+="Host: "+e.host+"\r\n",r+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",r+="Accept: */*\r\n",r+="Accept-Language: en\r\n",r+="Accept-Encoding: gzip, deflate\r\n",r+="Connection: keep-alive\r\n",r+="\r\n",t.params_.stream=new ii(r,"utf8"),t.remotePort="60000",t.remoteAddress="1.2.3.4",t.write=function(){},t.end=function(){},t.destroy=function(){},t.close=function(){},t._init_=Sc,t._write_=t.write,t},Cc=function(e){Sn[e.server_.ip]=this,this[e.circId]=e,this.stream_tor_=new ii(0);var t=new lc(e.circId,lc.prototype.VERSIONS,new ii(2).writeUInt(3));e.send(t)},Ac=function(e,t){t.socket_=e,e.first_=t,e.server_=t.server_,e.nbc_=0,ia&&e===Zl&&(e.buff_w=js?new fl.util.ByteBuffer:new ii(0),e.abstract_client_tls=Nl(e,"www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".net"),e.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),clearInterval(en),zo(e),e.destroy(),sl()},e.abstract_client_tls.error=function(t,r){-1===r.message.indexOf("MAC")?(console.log(" Error TLS client disconnected "+r.message),clearInterval(en),zo(e),e.destroy(),sl()):console.log("bad MAC")},e.write=function(t){js?e.buff_w.putBytes(t.toString("binary")):e.buff_w=e.buff_w.length?[e.buff_w,t].concatBuffers():t},e.abstract_client_tls.connected=function(){console.log("TLS client connected"),en=setInterval(el,1e4),e.tls_connected=!0,e.write=function(t){e.abstract_client_tls.prepare(js?t.data?t.getBytes():t.toString("binary"):Rl(t.toString("hex")))},e.write(e.buff_w)},e.write_c=function(t){t.length&&e.send(js?new ii(t,"binary"):t)},e.abstract_client_tls.dataReady=function(t){if(js){if(t.data.length()){var r=new ii(t.data.getBytes(),"binary");e.t0&&(su++,au+=r.length,ou+=Date.now()-e.t0,su%cu===0&&ou&&(console.log("TLS perf (dataReady): "+parseInt(8*au/(ou/1e3))+" bps"),su=0,au=0,ou=0)),wc.call(e,r)}}else{var r=t.data.data.slice(t.data.read,t.data.length_);t.data.read=t.data.length_,console.log(r.length),r.length&&wc.call(e,r)}},e.wsconnected_&&(console.log("start TLS handshake "),delete e.abstract_client_tls.handshaking,e.abstract_client_tls.handshake()))},Ic=function(e){e.OR_=!0,e.OR_f=!0,e.way_="socket in",e.privkey_=ra,e.stream_tor_=new ii(0);var t=new hc;t.remote_=e.remoteAddress,t.OR_=!0,t.OR_f=!0,t.circId=0,t.socket_=e,t.way_="socket in",e[0]=t},Tc=function(e){var t="www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".net",r="www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".com",i={key:ki.readFileSync(oi+Oi+"/priv-key.pem"),cert:Ul(oi+Oi+"/pub-key.pem",oi+Oi+"/priv-key.pem","pem",parseInt(ac(8).toString("hex"),16),new Date,t,r),servername:t,rejectUnauthorized:!1};console.log("OUTGOING SOCKET : ---------start initial socket------------"+i.servername+" "+e.server_.ip+" "+e.server_.port);var n=tn.connect(e.server_.port,e.server_.ip,i,function(){clearTimeout(o),Cc.call(this,e)});n.on("data",wc);var s=function(){n.nbc_>1?yc(Tc):(clearTimeout(o),e.destroy_?yc(Tc):e.last_?yc(Tc):(e.clear_t0_(),delete e.ok_,delete Sn[e.server_.ip],e.circuit_retry()))};n.on("end",s),n.on("close",s),n.on("error",function(){clearTimeout(o),e.destroy_=!0,n.destroy(),e.last_||e.change_or("initial socket error")});var a=function(){e.destroy_=!0,n.destroy(),e.change_or("initial socket failed")};Ac(n,e);var o=setTimeout(a,2e3)},xc=function(e,t){var r=e.params_;if(e.time_ini=Date.now(),r)if(r.OP)if(r.one_c)if(t)if(vc(e,!0)===!0)mc(e);else{var i;if(!Os||e.params_.ws){if(i=vc(e),t)for(var n=5;t===i&&0!==n;)i=vc(e),n--}else for(i=Bs;i===Bs;)i=vc(e);i?i.process(e):mc(e)}else{var i;if(e.cid_&&e.cid_.bad_&&(delete e.tls_client_connected,delete e.abstract_client_tls,e.cid_.destroy_cid(e)),!Os&&!Fs||e.params_.ws||e.params_.db_)i=e.cid_?e.cid_:r.one_c?vc(e):null;else for(i=e.cid_?e.cid_:Bs;i===Bs||i===ks;)i=vc(e);i?(console.log("choose circuit "+i.circId+" for request "+e.i_id),i[e.sid_]?i.last_?i.last_.stream_handle_connected(e.sid_):(i.destroy_cid(e),xc(e)):i.process(e)):(console.log("no circuits"),0===En.length?mc(e):En.push(e))}else mc(e);else{var s="www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".net",a="www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".com",o=new Date,c=parseInt(ac(8).toString("hex"),16),l=Ul(oi+Oi+"/pub-key.pem",oi+Oi+"/priv-key.pem","pem",c,o,s,a),h={key:ki.readFileSync(oi+Oi+"/priv-key.pem"),cert:l,servername:s,requestCert:!0},u=tn.createServer(h,function(e){var t=e.remoteAddress,r=e.remotePort;Ic(e),e.on("data",wc),e.on("error",function(e){console.log("OR socket error"),console.log(e),delete Tn[t+":"+r]}),e.on("end",function(){delete Tn[t+":"+r]}),e.on("close",function(){delete Tn[t+":"+r]}),e.cert_issuer=a,e.cert_subject=s,e.cert_date=o,e.certid_=c,Tn[t+":"+r]=e});u.listen(r.port,function(){console.log("OR : server launched port "+r.port),Fs&&setInterval(nl,Ns)}),u.on("OR : clientError",function(e){console.log(e)}),u.on("error",function(e){console.log(e)}),u.on("end",function(e){console.log(e)})}},Bc=function(e){try{var t={},r=0;return e=e.split("\r\n"),e.forEach(function(e,i){if(e=e.split(":"),e.length>1&&0!=i){var n=e[0];e=e.map(function(e){return e.trim()}),e.shift(),e=e.join(":"),t[n]=e}else t[r+"a"]=e.join(":"),r++}),t}catch(i){console.log("caller"),console.log(Bc.caller.toString().substr(0,50))}},kc=function(e){var t=[],r=0;for(var i in e)isNaN(i.substr(0,1))?t.push(i+": "+e[i]):e[i]?t.push(e[i]):r++;for(var n=0;r>n;n++)t.push("");return t.join("\r\n")},Rc=function(e){e.start_&&(e.write(e.start_),delete e.start_)},Uc=function(e,t,r){var i=/(((\b(https?|ftp|file):\/\/)|\/\/)[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi,n=!1,s=function(i){var s=e.split(i);if(""===s[s.length-1]&&!r)return void(n=!0);var a=e;i=Lo(i);var o=t.fake_domain,c=Is[o],l=c.real_domain_s;if(i.host)if(-1!==i.host.indexOf(l)){var h=i.host.split("."),u=c.real_domain_a;a=i.host===c.real_domain?"http"+qs+"://"+o+"/"+(i.rest?i.rest:""):2===h.length&&"www"===u[0]||2===u.length&&"www"===h[0]?"http"+qs+"://"+o+"/"+(i.rest?i.rest:""):"http"+qs+"://"+o+"/"+Po(Oo(i),!0)}else-1===i.host.indexOf(o)&&(a="http"+qs+"://"+o+"/"+Po(Oo(i),!0));return a},a=e.replace(i,s);return n&&(t.pass_+=e),{html:n?e:a,pass:n}},Dc=function(e){var t="<SCRIPT Language='Javascript'>(function(){ /* insert after doctype - ok all browsers */ var K='';  var noT=['STYLE','BR','HEAD','META','TITLE','NOSCRIPT'];  var noA=['IFRAME','FRAME','EMBED','OBJECT','APPLET'];  var tab=['href','src','innerHTML','outerHTML'];  var attribs=['style','className','align','id','name','width','height'];  var protocol=document.location.protocol;  var url_decode=function(url) { 	var URL={url:url}; 	var res=url.split('/'); 	var dec=function(res) { 		if (res.length) { 			var tmp=res[0]; 				URL.host=tmp; 				res.shift(); 			}; 			URL.rest=res.join('/'); 	}; 	if (res.length>1) { 		if (res[1]==='') { 			URL.protocol=res[0]?res[0]:protocol; 			res.shift(); 			res.shift(); 		}; 	} 	dec(res); 	return URL; };  var url_encode=function(url) { 	var res=[]; 	if (url.protocol) { 		res.push(url.protocol); 		res.push(''); 	}; 	if (url.port) { 		res.push(url.rest); 	}; 	if (url.rest) { 		res.push(url.rest); 	}; 	return res.join('/'); }; 	 var encrypt_decrypt=function(txt,K) { 		var res=[]; 		txt=txt.split(''); 		while (txt.length) { 			res.push(txt.pop()); 		}; 		return res.join(''); };  var url_encrypt=function(url,bool,K) { 	var URL=url_decode(url); 	URL.host=URL.host?encrypt_decrypt(URL.host):null; 	if (bool) { 		URL.rest=URL.rest?encrypt_decrypt(URL.rest):null; 	}; 	return url_encode(URL); /*TODO replace by https */ };  var fake_domain=document.domain;  var real_domain=url_encrypt(fake_domain);  alert(fake_domain+' '+real_domain);  Object.Freeze=function(obj,prop) { 	try { 		Object.defineProperty(obj,prop,{value:obj[prop],configurable:false,writable:false}); 	} catch(ee) { 		/* Safari nok */ 	}; };  var tame=function(obj) { 	try { 		tab.forEach(function(prop) {observe(obj,prop)}); 		var osetAttribute=obj.setAttribute.bind(obj); 		obj.setAttribute=function(prop,val) { 			if (prop&&val) { 				if (((tab.indexOf(prop)!==-1)&&(val.indexOf('http')!==-1))||(['innerHTML','outerHTML'].indexOf(prop)!==-1)) { 					var tmp=url(val,prop); 					if (['innerHTML','outerHTML'].indexOf(prop)===-1) { 						obj['___'+prop+'___']=tmp; 					}; 					osetAttribute(prop,tmp); 				} else { 					if (tab.indexOf(prop)!==-1) { 						obj['___'+prop+'___']=val; 					}; 					osetAttribute(prop,val); 				}; 			}; 		}; 		Object.Freeze(obj,'setAttribute'); 		Object.Freeze(obj,'appendChild'); 		Object.Freeze(obj,'insertBefore'); 		Object.Freeze(obj,'replaceChild'); 	} catch(ee) {}; };  var ocreateElement=document.createElement.bind(document);  document.createElement=function(tag) { 	tag=tag.toLowerCase().trim(); 	switch (tag) { 		case ('iframe' || 'frame' || 'embed' || 'object' || 'applet') : return ocreateElement('canvas'); 		case ('script') : if (document.readyState==='complete') {return ocreateElement('span')}; 		default : var obj=ocreateElement(tag);tame(obj);return obj; 	}; };  var ocreateDocumentFragment=document.createDocumentFragment.bind(document);  document.createDocumentFragment=function() { 	var obj=ocreateDocumentFragment(); 	tame(obj); 	return obj; };  var owrite=document.write.bind(document);  document.write=function(txt) { 	if (txt.toLowerCase().indexOf('script')===-1) { 		owrite(txt); 	}; };  var url=function(val,prop) { /*TODO tame innerHTML outerHTML */ 	if (['innerHTML','outerHTML'].indexOf(prop)!==-1) { 		/* alert(prop+' '+val); */ 		return val; 	}; 	var rurl=''; 	val=url_decode(val); 	if (val.protocol) { 		if (val.host) { 			if (val.host.indexOf(real_domain)!==-1) { 				rurl=url_encrypt(url_encode(val)); 			} else { 				if (val.host.indexOf(fake_domain)===-1) { 					rurl='http://'+fake_domain+'/'+url_encrypt(url_encode(val)); 				} 			}; 		/*alert(rurl);*/ 		} else { 			rurl=url_encrypt(url_encode(val)); 		} 	} else { 		rurl=url_encode(val); 	}; 	return rurl; };  var observe=function(obj,prop) { /* watch js modification of prop */ 	if (['innerHTML','outerHTML'].indexOf(prop)!==-1) { /* if getter/setter */ 		var set_o=function(val) { 			delete this[prop]; 			this[prop]=url(val,prop); 			observe(this,prop); 		}; 	} else { 		var set_o=function(val) { 			delete this[prop]; 			this.setAttribute(prop,val); 			observe(this,prop); 		}; 	}; 	if (['innerHTML','outerHTML'].indexOf(prop)!==-1) { /* if getter/setter */ 		var get_o=function(){ 			delete this[prop]; 			var res=this[prop]; 			observe(this,prop); 			return res; 		}; 	} else { 		var get_o=function(){ 			return this['___'+prop+'___']||''; 		}; 	}; 	try { 		Object.defineProperty(obj,prop,{get:get_o,set:set_o,enumerable:true,configurable:true}); 	} catch (ee) { 		Object.freeze(obj); 	}; /*Safari crashes - unconfigurable property */ 	/* OK FF IE Chrome - NOK Safari */ };  var addEvent=function(o, e, f, p) { 	try {this.delEvent(o,e,f,p);} catch(ee){} 	if (o.addEventListener) { 		o.addEventListener(e, f, p); 	} else if (o.attachEvent) { 		o.attachEvent('on' + e, f); 	} };  var delEvent=function(o, e, f, p) { 	if (o.addEventListener) { 		o.removeEventListener(e, f, p); 	} else if (o.attachEvent) { 		o.detachEvent('on' + e, f); 	} };  var setEvtAllTree=function(obj) { 	obj=obj.nodeName?obj:this.document; 	if (!obj) { 		setTimeout(setEvtAllTree,0); 		return; 	}; 	if ((obj.nodeName=='#document')||(obj.nodeType===1)&&(noT.indexOf(obj.nodeName)===-1)) { 		if (noA.indexOf(obj.nodeName)===-1) { 			if (obj.nodeType!==9) { 				if (obj.href) { 					if (obj.getAttribute('href')) { 						if (obj.getAttribute('href').indexOf('http')!==-1) { 							obj.href=url(obj.href); 						}; 					} else { 						obj.href=url(obj.href); 					}; 				}; 				if (obj.src) { 					if (obj.getAttribute('src')) { 						if (obj.getAttribute('src').indexOf('http')!==-1) { 							obj.src=url(obj.src); 						}; 					} else { 						obj.src=url(obj.src); 					}; 				}; 				tame(obj); 			}; 			var l=obj.childNodes.length; 			for (var i=0;i<l;i++) { 				setEvtAllTree(obj.childNodes[i]); 			}; 		} else { 			var c=document.createElement('canvas'); 			attribs.forEach(function(val) {if (obj[val]) {c[val]=obj[val]}}); 			var ctx = c.getContext('2d'); 			ctx.fillStyle='#FAFAFA'; 			obj.parentNode.replaceChild(c,obj); 			ctx.fillRect(0, 0, c.offsetWidth,c.offsetHeight); 		}; 	}; };  addEvent(window,'load',setEvtAllTree,false); /*addEvent(window,'load',function() {alert('load event')},false);*/  Object.Freeze(document,'createElement'); Object.Freeze(document,'createDocumentFragment'); Object.Freeze(document,'write'); /*alert('loaded');*/  /*setEvtAllTree(window.document);*/ /* hook document.getElementsByTagName('script') */ /* hook window.open */ })();</SCRIPT>";return t="",[t,e].join("")},Nc=function(e,t){var r=e.toString("hex").split(Ss),i=i||[],n=[];return r.forEach(function(e,s){if(t.wait_){var a=parseInt(new ii(e,"hex").toString("utf8"),16);return 0===a&&(t.end_=!0,i.push("0d0a300d0a0d0a")),t.clength_+=a?a:0,void(e.length?s!==r.length-1&&(t.wait_=!1):0===s&&(t.wait_=!1))}var o=t.clength_,c=t.html_.length,l=new ii(e,"hex").length+2;(o>=c+l||c+l-2===o)&&n.push(e),c+l-2===o||s===r.length-1?(n=n.join(Ss),i.push(n),t.html_.length+=l-2,s!==r.length-1&&(t.wait_=!0),n=[]):t.html_.length+=l}),new ii(i.join(""),"hex")},Lc=function(e){if(!(e instanceof Uint8Array)){var t=new ii(e.length);t.map(e),e=t}return e},Oc=function(e){console.log("destroy ws cid"),e.remoteAddress&&e.remotePort?delete Tn[e.remoteAddress+":"+e.remotePort]:il()},Pc=function(e,t){var r=e["Sec-WebSocket-Key"],i=an.createhash("sha1");i.update(r+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var n=i.digest("hex");n=new ii(n,"hex").toString("base64");var s="HTTP/1.1 101 WebSocket Protocol Handshake\r\n";s+="Upgrade: websocket\r\n",s+="Connection: Upgrade\r\n",s+="Sec-WebSocket-Accept:"+n+"\r\n",s+="Access-Control-Allow-Origin:"+e.Origin+"\r\n",s+="\r\n",console.log("INCOMING SOCKET :"+s),t.ws_=!0,Ic(t),t.connected_=!0,t.wsconnected_=!0,t.write(s)},Fc=function(e){this.key_=an.randomBytes(16).toString("base64");var t="GET / HTTP/1.1\r\n";return t+="Host: "+e.ip+(Ws?":"+e.wsport:"")+"\r\n",t+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",t+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",t+="Accept-Language: en-us,en;q=0.5\r\n",t+="Accept-Encoding: gzip, deflate\r\n",t+="Connection: keep-alive, Upgrade\r\n",t+="Sec-WebSocket-Version: 13\r\n",t+="Origin: http://ianonym.com\r\n",t+="Sec-WebSocket-Key: "+this.key_+"\r\n",t+="Pragma: no-cache\r\n",t+="Cache-Control: no-cache\r\n",t+="Upgrade: websocket\r\n",t+="\r\n"},qc=0,Mc=0,Hc=0,jc=100,zc=0,Kc=0,Vc=0,Gc=100,Yc=function(e){di&&(dc=Date.now()),fi&&(fc=Date.now()),console.log("start websocket");var t=xi?new ho("ws://"+e.ip+":"+e.wsport):new WebSocket("ws://"+e.ip+":"+e.wsport);return xi||(t.write=t.send),t.binaryType="arraybuffer",t.setNoDelay=function(){},t.connect=function(){},t.WS_OP_=!0,t.onopen=Qc,t.onmessage=function(e){var r=e.data instanceof ArrayBuffer?new Uint8Array(e.data):e.data;
dc&&(qc++,Mc+=r.length,Hc+=Date.now()-dc,qc%jc===0&&Hc&&(console.log("WS perf (received from WS before processing): "+parseInt(8*Mc/(Hc/1e3))+" bps - Buffered : "+t.bufferedAmount),qc=0,Mc=0,Hc=0)),(di||pi)&&(dc=Date.now()),ia&&t===Zl?(gi&&(t.t0=Date.now()),pc&&dc-pc!==0&&console.log("WS delay between processed and next received: "+(dc-pc)+" data length "+r.length),t.abstract_client_tls.process(js?r.toString("binary"):r),pi&&(pc=Date.now()),fc&&(zc++,Kc+=r.length,Vc+=Date.now()-fc,zc%Gc===0&&Vc&&(console.log("WS perf (received from WS after processed): "+parseInt(8*Kc/(Vc/1e3))+" bps - Buffered : "+t.bufferedAmount),zc=0,Kc=0,Vc=0)),fi&&(fc=Date.now())):wc.call(this,r)},t.onclose=function(){console.log("Websocket closed ws://"+e.ip+":"+e.wsport)},xi||(t.destroy=t.close,t.bufferSize=t.bufferedAmount),t.remoteAddress=e.ip,t.remotePort=qn,t.address=function(){return{port:0,family:"IPv4",address:"127.0.0.1"}},t.setKeepAlive=function(){},t},Wc=function(e){var t=Bc(e.toString("utf8")),r=t["Sec-WebSocket-Accept"];if(r){var i=an.createhash("sha1");i.update(this.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var n=i.digest("hex");n=new ii(n,"hex").toString("base64"),r===n&&(console.log("WS Client says : Handshake successfull"),Qc.call(this))}},Qc=function(){console.log("websocket connected");try{vh.innerHTML="<p>Websocket connected</p>"}catch(e){}this.connected_=!0,this.wsconnected_=!0,this.ws_=!0,Fs&&(this===$l&&$i&&xc({params_:{OP:!0,nb_hop:Gn,ws:this}}),!ia||this!==Zl||!Bs&&$i||(console.log("launch db_cid"),this.db_cid_launched=!0,xc({params_:{OP:!0,nb_hop:Yn,ws:this,db:!0}})),ia||setInterval(el,1e4))},Xc=function(e,t){t=t||[];var r,i=e.length,n=0,s=0,i=e.length,a=new ii(0),o=new ii(0);if(0===e.length)return[a,o];var c=e[0];if(e.length>1){var l=128&e[1],h=127&e[1];if(126===h?(n=e.slice(2,4).readUInt(),l=l&&e.slice(4,8),s=l?8:4):127===h?(n=parseInt(e.slice(2,10).toString("hex"),16),l=l&&e.slice(10,14),s=l?14:10):(n=h,l=l&&e.slice(2,6),s=l?6:2),a=e.slice(s,s+n),r=a.length,l&&a.length===n&&0!=n)for(var u=0;r>u;u++)a[u]=a[u]^l[u%4]}return a.length!==n||0===n?(r=a.length,s=i,o=e):t.push(a),i-s>r?Xc(e.slice(r+s),t):1&c?[t.concatBuffers().toString("utf8"),o.toString("utf8")]:2&c?[t.concatBuffers(),o]:void 0},Jc=function(e,t,r){var i,n,s,a=e.length;r=r?an.randomBytes(4):r;var o=1===t?"81":"82";if(126>a?(n=(r?128|a:a).toString(16),n=1===n.length?"0"+n:n):a>=126&&65535>=a?(o+=r?"FE":"7E",s=2):(o+=r?"FF":"7F",s=8),!n)for(n=a.toString(16),n=n.length%2?"0"+n:n;n.length!==2*s;)n="00"+n;if(o+=n,i=new ii(o,"hex"),r)for(var c=e.length,l=new ii(c),h=0;c>h;h++)l[h]=e[h]^r[h%4];else l=e;return r?[i,r,l].concatBuffers():[i,l].concatBuffers()},Zc=function(e,t){for(var r=e.remoteAddress+":"+e.remotePort+":"+e.port_+":"+e.i_id,i=e.fake_,n=new ii(new ii(r,"utf8").toString("hex"),"hex"),s=n.length.toString(16);4!==s.length;)s="0"+s;for(n=[new ii(s,"hex"),n].concatBuffers(),s=n.toString("hex");t.length;){var a;a=t.length+s>wn?t.slice(0,wn-s):t,a=[n,a].concatBuffers();var o=new uc(uc.prototype.RELAY_WS,0,a,i.Db_hash).toBuffer();o=new ii(i.Kb_cipher.update(o,"hex","hex"),"hex");var c=new lc(i.circId,lc.prototype.RELAY_WS,o);if(i.send(c),!(t.length+s>wn))break;t=t.slice(wn-s)}},$c=function(e){e.i_id=es,e.nb_try=0,e.no_exit=[],e.squeue_=[],e.wsqueue_=[],e._date_=Date.now(),es++,ds.push(e.i_id),console.log("INCOMING SOCKET : ------------------------------------- new incoming socket ----------------------------------------------- request "+e.i_id+" on remote port "+e.remotePort+" for port "+e.address().port);var t=function(t){var r=t.split(":::");if(3!==r.length){var i={},n=Bc(t);if(i.OP=!0,i.nb_hop=Gn,i.one_c=!0,-1!=t.indexOf("WebSocket")){if(console.log("Answer websocket"),Pc(n,e),Fs){var s="www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".net",a="www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".com",o=new Date,c=parseInt(ac(8).toString("hex"),16),l=Ul(oi+Oi+"/pub-key.pem",oi+Oi+"/priv-key.pem","pem",c,o,s,a),h=an.createCredentials({key:ki.readFileSync(oi+Oi+"/priv-key.pem"),cert:l,servername:s}),u=new tn.createSecurePair(h,!0);e.pair=u;var d=u.cleartext;d.tlspair_=!0,d.server=e.server,d.i_id=e.i_id,d.nb_try=e.nb_try,d.no_exit=e.no_exit,d.squeue_=e.squeue_,d.wsqueue_=e.wsqueue_,d._date_=e._date_,d._init_=e._init_,d.OR_=e.OR_,d.OR_f=e.OR_f,d.way_=e.way_,d.privkey_=e.privkey_,d.connected_=e.connected_,d.wsconnected_=e.wsconnected_,d.address=function(){return{port:e.address().port,family:"IPv4",address:e.address().address}},d.__defineGetter__("remoteAddress",function(){return e.remoteAddress}),d.__defineGetter__("remotePort",function(){return e.remotePort}),d.stream_tor_=new ii(0),d.cert_issuer=a,d.cert_subject=s,d.cert_date=o,d.certid_=c,e.write=function(t){e._write(Jc(t,2,!1),null,function(){})},Tn[e.remoteAddress+":"+e.remotePort]=d,u.encrypted.pipe(e),d.on("data",function(e){d.t0&&(ha++,ua+=e.length,da+=Date.now()-d.t0,ha%fa===0&&da&&(console.log("cleartext perf: "+parseInt(8*ua/(da/1e3))+" bps"),ha=0,ua=0,da=0)),wc.call(d,e)}),d.on("end",function(){e.end()}),d.on("error",function(){e.end()})}return!1}return-1!=t.indexOf("HTTP")&&n.Host&&(i.host=n.Host+":80",e.connected_=!0),i.stream=new ii(new ii(t,"utf8").toString("hex"),"hex"),5===i.stream.slice(0,1).readUInt()?(e.socks_=!0,e.connected_=!0,e.write(new ii("0500","hex")),!1):i}e.params_={host:r[0],OP:!0,nb_hop:r[1],stream:new ii(new ii(r[2],"utf8").toString("hex"),"hex"),one_c:r[3]},xc(e)};e.on("data",function(r){e.ws_||console.log("INCOMING SOCKET :------------- RECEIVED FROM INCOMING SOCKET ------------ "+e.i_id+" on port "+e.remotePort+" "+e.remoteAddress+" "+e.address().port);var i;if(e.connected_){if(i={},i.OP=!0,i.nb_hop=Gn,i.one_c=!0,i.host=e.host_?e.host_:!1,e.params_?e.params_.host=i.host:e.params_=i,i.stream=i.host?r:!1,i.stream)if(e.fake_){var n=function(e){return function(){Zc(this,e)}};e.wsqueue_.push(n(r).bind(e))}else{var n=function(t){return function(){if(ai.inflate){t=t.toString("utf8"),t=t.replace("%2Fplayer.html","");var r=Bc(t);r["0a"],r["User-Agent"]&&(r["User-Agent"]="Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"),r.Referer&&"http://www.peersm.com/player.html"===r.Referer&&(r.Referer="http://www.peersm.com/"),t=kc(r),console.log(t),t=new ii(t,"utf8")}this.params_.stream=t,xc(e)}};e.squeue_.push(n(r).bind(e))}if(e.ws_)return e.wsconnected_?(e.pair&&(ui&&(e.pair.cleartext.t0=Date.now()),_i&&(e.pair.encrypted.t0=Date.now())),void wc.call(this,r)):(console.log("server ws not connected"),void Pc(Bc(r.toString("utf8")),e));if(e.socks_&&!i.stream){switch(r.slice(3,4).readUInt()){case 1:e.host_=oc(r.slice(4,8))+":"+r.slice(8).readUInt();break;case 3:var s=r.slice(4,5).readUInt();if(!Ps){e.host_=r.slice(5,5+s).toString("utf8")+":"+r.slice(s+5).readUInt();break}if(!e.ws_){var a=xn[r.slice(5,5+s).toString("utf8")];if(a){var o=e.remoteAddress+":"+e.remotePort;Bn[o]=e,e.fake_=a.circ_,e.port_=r.slice(s+5).readUInt(),e.host_=r.slice(5,5+s).toString("utf8");break}e.host_=r.slice(5,5+s).toString("utf8")+":"+r.slice(s+5).readUInt(),console.log("outside domain "+e.host_+" request "+e.i_id),e.__outside__=!0;break}default:return}if(e.host_===Pn+":"+qn&&(e.ws_=!0,e.setNoDelay(!0)),i.host=e.host_,console.log("INCOMING SOCKET : socks request "+e.i_id+" host "+e.host_+" remote "+e.remoteAddress+":"+e.remotePort),ai&&Ci){var c=["www.lepoint.fr:80","212.95.70.230:80","www.monip.org:80","217.70.182.162:80"];if(e.__connect__=c,443===parseInt(e.host_.split(":")[1]))return void e.write([new ii("050200","hex"),r.slice(3)].concatBuffers())}return e.start_=[new ii("050000","hex"),r.slice(3)].concatBuffers(),void Rc(e)}}else i=t(r.toString("utf8"));if(i&&(Fs&&console.log("Received socks and doing OP, params request "+e.i_id+" "+(i.stream?i.stream.toString("utf8").substr(0,200):"")),i.stream))if(e.fake_){var l=e.wsqueue_[0];e.wsqueue_.shift(),l()}else{if(Ps&&e.__outside__)return void e.write(new ii(Ro(),"utf8"));if(ai&&Ci){var h=Bc(i.stream.toString("utf8"));if(h.Host=h.Host||"",-1===["www.lepoint.fr","www.monip.org"].indexOf(h.Host)||-1===e.__connect__.indexOf(e.host_))return void e.write(new ii(Do(),"utf8"))}e._data_=!1,1===e.squeue_.length&&e.squeue_[0]()}}),e.on("end",function(){console.log("INCOMING SOCKET : End -------------------------end incoming socket------------------------------------- request "+e.i_id+" host "+e.host_),tl(),setTimeout(rl,0),fs.push(e.i_id),e.ws_&&Oc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e.on("close",function(){console.log("INCOMING SOCKET : Close -------------------------end incoming socket------------------------------------- request "+e.i_id),setTimeout(rl,0),fs.push(e.i_id),e.ws_&&Oc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e.on("error",function(){console.log("INCOMING SOCKET : Error -------------------------end incoming socket------------------------------------- request "+e.i_id),setTimeout(rl,0),fs.push(e.i_id),e.ws_&&Oc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e._write_=function(t){if(!e.destroyed)try{e.write(t)}catch(r){}},e._init_=Sc},el=function(){var e=[],t=[],r=0,i=0,n=!1,s=(new Date).valueOf();for(var a in Sn)e.push([a,Sn[a]]);var o=0;e.forEach(function(e){Object.keys(e[1]).forEach(function(n){if(!isNaN(n)&&null!=n){var a=e[1][n],c=a.last_?a.last_:null;if(c)if(Object.keys(a).forEach(function(e){isNaN(e)||null==e||t.push(a[e].i_id+" "+a[e].remotePort)}),is>r&&(s-a.time_<ls||xi)&&(ss>ts||a.time_average<Cs+As||xi)&&a.perf_>=0&&(!a.bad_||a.time_average<Cs&&a.bad_)||a===Bs||a===ks){if(delete a.bad_,a.time_average&&(o+=a.time_average,i++),a.keep_alive(),a!==Bs&&a!==ks&&r++,a===ks&&s-a.time_>hs&&!ji){var l;for(var n in a)if(!isNaN(n)&&null!=n&&"function"!=typeof n){l=!0;break}l?(console.log("download in progres, not changing DB CID ----------"),a.time_=Date.now()):(console.log("monitor UPDATE DB CID ---------"+a.circId),a.circuit_destroy())}if(Fs&&a.last_){var h=a.last_;h.server_&&a!==ks&&h.server_.ip===Pi&&h.server_.port===Fi&&(console.log("destroying ordb last CIC "+a.circId),a.circuit_destroy())}}else if(a.bad_){var l;for(var n in a)if(!isNaN(n)&&null!=n){l=!0;break}l||(console.log("monitor DESTROY "+a.circId),a.circuit_destroy())}else a.bad_=!0}})});var c=[];ds.forEach(function(e){-1===fs.indexOf(e)&&c.push(e)}),ts=r,Cs=i?o/i:Cs,(ni||ai)&&Ni("MONITOR ---- "+r+" circuits on "+ss+" TIME_AVERAGE "+Cs),as=r>=ss&&!n&&(!Fs||ks)?!0:!1,as||Ei||(Ws||Qs?Zl&&(console.log("establish new circuit"),Os||ks?xc({params_:{OP:!0,nb_hop:Gn,ws:Zl}}):(Zl.tls_connected||delete Zl.db_cid_launched,console.log("monitor create db circuit"),xc({params_:{OP:!0,nb_hop:Yn,ws:Zl,db:!0}}))):xc({params_:{OP:!0,nb_hop:Gn}})),Fs&&sl()},tl=function(){var e=[];for(var t in In)e.push([t,In[t]]);console.log("----------------- "+e.length+" sockets out----------------"),e.forEach(function(e){Object.keys(e[1]).forEach(function(t){if(!isNaN(t)&&null!=t){e[1][t]}})}),console.log("-----------------")},rl=function(){var e=[];for(var t in In)e.push([t,In[t]]);e.forEach(function(e){var t;Object.keys(e[1]).forEach(function(r){if(!isNaN(r)&&null!=r&&"function"!=typeof r){var i,n=e[1][r];n&&n.prev_&&n.prev_.socket_&&n.prev_.socket_.remoteAddress&&(i=!0,t=!0),i||n&&(console.log("clearing circuit out n "+r+" CIC "+n.circId),n.circuit_destroy(),delete e[1][r])}}),t||(console.log("delete OR_sock "+e[0]),delete In[e[0]])})},il=function(){for(var e in Tn){var t=Tn[e];t?t.remoteAddress||(console.log("deleting or_sock_in remoteadd "+e),delete Tn[e]):(console.log("deleting or_sock_in "+e),delete Tn[e])}rl()},nl=function(){for(var e in Tn)parseInt(Tn[e].address().port)===parseInt(Fi)&&Object.keys(Tn[e]).forEach(function(t){if(!isNaN(t)&&null!=t)try{var r=Tn[e][t];r.db_test&&r.db_test.forEach(function(e){clearTimeout(e)}),r.db_test=[];var i=function(){r.destroyed_||(console.log("Destroying db_query_no_answer CID "+r.circId+" remote "+(r.socket_?r.socket_.remoteAddress:"null")),r.circuit_destroy(),r.destroyed_=!0)};if(0!==r.circId)if(r.socket_&&!r.destroyed_){var n;for(var s in r)if(!isNaN(s)&&null!=s&&(Dn[r.socket_.remotePort+"-"+r.socket_.remoteAddress+"-"+r.circId+"-"+s]||Nn[r.socket_.remotePort+"-"+r.socket_.remoteAddress+"-"+r.circId+"-"+s])){n=!0;break}if(n)console.log("Download in progress - Not testing CID "+r.circId+" remote "+r.socket_.remoteAddress+" "+Date.now());else{console.log("Testing CID "+r.circId+" remote "+r.socket_.remoteAddress+" "+Date.now());var a=ac(16),o={d_length:0,hash_:new ii("0000000000000000000000000000000000000000","hex")};r.send_db_query(o,a),r.db_test.push(setTimeout(i,Ds))}}else i()}catch(c){}})},sl=function(){if(Xh){var e=(ks?1:0)+(ts>=0?ts:0);mo("direct_text").innerHTML="P2P (Peersm, BitTorrent) and web anonymized circuits : "+e+(e>1?" circuits":" circuit")}};if(Ii||Ys){var al=-1,ol=-1;c.prototype=Error.prototype;var cl=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"utf-8"}],heading:"The Encoding"},{encodings:[{labels:["cp864","ibm864"],name:"ibm864"},{labels:["cp866","ibm866"],name:"ibm866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso_8859-2","l2","latin2"],name:"iso-8859-2"},{labels:["csisolatin3","iso-8859-3","iso_8859-3","iso-ir-109","l3","latin3"],name:"iso-8859-3"},{labels:["csisolatin4","iso-8859-4","iso_8859-4","iso-ir-110","l4","latin4"],name:"iso-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso_8859-5","iso-ir-144"],name:"iso-8859-5"},{labels:["arabic","csisolatinarabic","ecma-114","iso-8859-6","iso_8859-6","iso-ir-127"],name:"iso-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso_8859-7","iso-ir-126"],name:"iso-8859-7"},{labels:["csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-i","iso-ir-138","iso_8859-8","visual"],name:"iso-8859-8"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","l6","latin6"],name:"iso-8859-10"},{labels:["iso-8859-13"],name:"iso-8859-13"},{labels:["iso-8859-14","iso8859-14"],name:"iso-8859-14"},{labels:["iso-8859-15","iso_8859-15"],name:"iso-8859-15"},{labels:["iso-8859-16"],name:"iso-8859-16"},{labels:["koi8-r","koi8_r"],name:"koi8-r"},{labels:["koi8-u"],name:"koi8-u"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["iso-8859-11","tis-620","windows-874"],name:"windows-874"},{labels:["windows-1250","x-cp1250"],name:"windows-1250"},{labels:["windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ascii","ansi_x3.4-1968","csisolatin1","iso-8859-1","iso8859-1","iso_8859-1","l1","latin1","us-ascii","windows-1252"],name:"windows-1252"},{labels:["cp1253","windows-1253"],name:"windows-1253"},{labels:["csisolatin5","iso-8859-9","iso-ir-148","l5","latin5","windows-1254"],name:"windows-1254"},{labels:["cp1255","windows-1255"],name:"windows-1255"},{labels:["cp1256","windows-1256"],name:"windows-1256"},{labels:["windows-1257"],name:"windows-1257"},{labels:["cp1258","windows-1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gbk","gb_2312","gb_2312-80","iso-ir-58","x-gbk"],name:"gbk"},{labels:["gb18030"],name:"gb18030"},{labels:["hz-gb-2312"],name:"hz-gb-2312"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"euc-jp"},{labels:["csiso2022jp","iso-2022-jp"],name:"iso-2022-jp"},{labels:["csshiftjis","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"shift_jis"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"euc-kr"},{labels:["csiso2022kr","iso-2022-kr"],name:"iso-2022-kr"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["utf-16","utf-16le"],name:"utf-16"},{labels:["utf-16be"],name:"utf-16be"}],heading:"Legacy utf-16 encodings"}],ll={},hl={};cl.forEach(function(e){e.encodings.forEach(function(e){ll[e.name]=e,e.labels.forEach(function(t){hl[t]=e})})});var ul={};ll["utf-8"].getEncoder=function(e){return new m(e)},ll["utf-8"].getDecoder=function(e){return new g(e)},function(){["ibm864","ibm866","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-10","iso-8859-13","iso-8859-14","iso-8859-15","iso-8859-16","koi8-r","koi8-u","macintosh","windows-874","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-1258","x-mac-cyrillic"].forEach(function(e){var t=ll[e],r=ul[e];t.getDecoder=function(e){return new y(r,e)},t.getEncoder=function(e){return new v(r,e)}})}(),ll.gbk.getEncoder=function(e){return new w(!1,e)},ll.gbk.getDecoder=function(e){return new b(!1,e)},ll.gb18030.getEncoder=function(e){return new w(!0,e)},ll.gb18030.getDecoder=function(e){return new b(!0,e)},ll["hz-gb-2312"].getEncoder=function(e){return new E(e)},ll["hz-gb-2312"].getDecoder=function(e){return new S(e)},ll.big5.getEncoder=function(e){return new A(e)},ll.big5.getDecoder=function(e){return new C(e)},ll["euc-jp"].getEncoder=function(e){return new T(e)},ll["euc-jp"].getDecoder=function(e){return new I(e)},ll["iso-2022-jp"].getEncoder=function(e){return new B(e)},ll["iso-2022-jp"].getDecoder=function(e){return new x(e)},ll.shift_jis.getEncoder=function(e){return new R(e)},ll.shift_jis.getDecoder=function(e){return new k(e)},ll["euc-kr"].getEncoder=function(e){return new D(e)},ll["euc-kr"].getDecoder=function(e){return new U(e)},ll["iso-2022-kr"].getEncoder=function(e){return new L(e)},ll["iso-2022-kr"].getDecoder=function(e){return new N(e)},ll["utf-16"].getEncoder=function(e){return new P(!1,e)},ll["utf-16"].getDecoder=function(e){return new O(!1,e)},ll["utf-16be"].getEncoder=function(e){return new P(!0,e)},ll["utf-16be"].getDecoder=function(e){return new O(!0,e)};var dl="utf-8";q.prototype={encode:function(e,t){e=e?String(e):"",t=Object(t),this._streaming||(this._encoder=this._encoding.getEncoder(this._options)),this._streaming=Boolean(t.stream);for(var r=[],i=new s(r),n=new a(e);n.get()!==ol;)this._encoder.encode(i,n);if(!this._streaming){var o;do o=this._encoder.encode(i,n);while(o!==al);this._encoder=null}return new Uint8Array(r)}},M.prototype={decode:function(e,t){if(e&&!("buffer"in e&&"byteOffset"in e&&"byteLength"in e))throw new TypeError("Expected ArrayBufferView");e||(e=new Uint8Array(0)),t=Object(t),this._streaming||(this._decoder=this._encoding.getDecoder(this._options)),this._streaming=Boolean(t.stream);var i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new r(i);this._BOMseen||(this._BOMseen=!0,F(this._encoding.name,n));for(var s,a=new o;n.get()!==al;)s=this._decoder.decode(n),null!==s&&s!==ol&&a.emit(s);if(!this._streaming){do s=this._decoder.decode(n),null!==s&&s!==ol&&a.emit(s);while(s!==ol&&n.get()!=al);this._decoder=null}return a.string()}};var fl={};!function(){var e=fl,t=e.util=e.util||{};"undefined"!=typeof process&&process.nextTick?(t.nextTick=process.nextTick,t.setImmediate="function"==typeof setImmediate?setImmediate:t.nextTick):"function"==typeof setImmediate?(t.setImmediate=setImmediate,t.nextTick=function(e){return setImmediate(e)}):(t.setImmediate=function(e){setTimeout(e,0)},t.nextTick=t.setImmediate),t.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.ByteBuffer=function(e){this.data=e||"",this.read=0},t.ByteBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteBuffer.prototype.putByte=function(e){return this.data+=String.fromCharCode(e),this},t.ByteBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),t>>>=1,t>0&&(e+=e);return this.data=r,this},t.ByteBuffer.prototype.putBytes=function(e){return this.data+=e,this},t.ByteBuffer.prototype.putString=function(e){return this.data+=t.encodeUtf8(e),this},t.ByteBuffer.prototype.putInt16=function(e){return this.data+=String.fromCharCode(e>>8&255)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt24=function(e){return this.data+=String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt32=function(e){return this.data+=String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt16Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(e>>8&255),this},t.ByteBuffer.prototype.putInt24Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255),this},t.ByteBuffer.prototype.putInt32Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255),this},t.ByteBuffer.prototype.putInt=function(e,t){do t-=8,this.data+=String.fromCharCode(e>>t&255);while(t>0);return this},t.ByteBuffer.prototype.putSignedInt=function(e,t){return 0>e&&(e+=2<<t-1),this.putInt(e,t)},t.ByteBuffer.prototype.putBuffer=function(e){return this.data+=e.getBytes(),this},t.ByteBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},t.ByteBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},t.ByteBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},t.ByteBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},t.ByteBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},t.ByteBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},t.ByteBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},t.ByteBuffer.prototype.getInt=function(e){var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t},t.ByteBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},t.ByteBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.ByteBuffer.prototype.bytes=function(e){return"undefined"==typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.ByteBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},t.ByteBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},t.ByteBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteBuffer.prototype.copy=function(){var e=t.createBuffer(this.data);return e.read=this.read,e},t.ByteBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},t.ByteBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);16>r&&(e+="0"),e+=r.toString(16)}return e},t.ByteBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())},t.createBuffer=function(e,r){return r=r||"raw",void 0!==e&&"utf8"===r&&(e=t.encodeUtf8(e)),new t.ByteBuffer(e)},t.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),t>>>=1,t>0&&(e+=e);return r},t.xorBytes=function(e,t,r){for(var i="",n="",s="",a=0,o=0;r>0;--r,++a)n=e.charCodeAt(a)^t.charCodeAt(a),o>=10&&(i+=s,s="",o=0),s+=String.fromCharCode(n),++o;return i+=s},t.hexToBytes=function(e){var t="",r=0;for(e.length&!0&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},t.bytesToHex=function(e){return t.createBuffer(e).toHex()},t.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i=[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(e,t){for(var i,n,s,a="",o="",c=0;c<e.length;)i=e.charCodeAt(c++),n=e.charCodeAt(c++),s=e.charCodeAt(c++),a+=r.charAt(i>>2),a+=r.charAt((3&i)<<4|n>>4),isNaN(n)?a+="==":(a+=r.charAt((15&n)<<2|s>>6),a+=isNaN(s)?"=":r.charAt(63&s)),t&&a.length>t&&(o+=a.substr(0,t)+"\r\n",a=a.substr(t));return o+=a},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,s,a="",o=0;o<e.length;)t=i[e.charCodeAt(o++)-43],r=i[e.charCodeAt(o++)-43],n=i[e.charCodeAt(o++)-43],s=i[e.charCodeAt(o++)-43],a+=String.fromCharCode(t<<2|r>>4),64!==n&&(a+=String.fromCharCode((15&r)<<4|n>>2),64!==s&&(a+=String.fromCharCode((3&n)<<6|s)));return a},t.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},t.decodeUtf8=function(e){return decodeURIComponent(escape(e))},t.deflate=function(e,r,i){if(r=t.decode64(e.deflate(t.encode64(r)).rval),i){var n=2,s=r.charCodeAt(1);32&s&&(n=6),r=r.substring(n,r.length-4)}return r},t.inflate=function(e,r){var i=e.inflate(t.encode64(r)).rval;return null===i?null:t.decode64(i)};var n=function(e,r,i){if(!e)throw{message:"WebStorage not available."};var n;if(null===i?n=e.removeItem(r):(i=t.encode64(JSON.stringify(i)),n=e.setItem(r,i)),"undefined"!=typeof n&&n.rval!==!0)throw n.error},s=function(e,r){if(!e)throw{message:"WebStorage not available."};var i=e.getItem(r);if(e.init)if(null===i.rval){if(i.error)throw i.error;i=null}else i=i.rval;return null!==i&&(i=JSON.parse(t.decode64(i))),i},a=function(e,t,r,i){var a=s(e,t);null===a&&(a={}),a[r]=i,n(e,t,a)},o=function(e,t,r){var i=s(e,t);return null!==i&&(i=r in i?i[r]:null),i},c=function(e,t,r){var i=s(e,t);if(null!==i&&r in i){delete i[r];var a=!0;for(var o in i){a=!1;break}a&&(i=null),n(e,t,i)}},l=function(e,t){n(e,t,null)},h=function(e,t,r){var i=null;"undefined"==typeof r&&(r=["web","flash"]);var n,s=!1,a=null;for(var o in r){n=r[o];try{if("flash"===n||"both"===n){if(null===t[0])throw{message:"Flash local storage not available."};i=e.apply(this,t),s="flash"===n}("web"===n||"both"===n)&&(t[0]=localStorage,i=e.apply(this,t),s=!0)}catch(c){a=c}if(s)break}if(!s)throw a;return i};t.setItem=function(e,t,r,i,n){h(a,arguments,n)},t.getItem=function(e,t,r,i){return h(o,arguments,i)},t.removeItem=function(e,t,r,i){h(c,arguments,i)},t.clearItems=function(e,t,r){h(l,arguments,r)},t.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),i=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return i&&(i.fullHost=i.host,i.port?80!==i.port&&"http"===i.scheme?i.fullHost+=":"+i.port:443!==i.port&&"https"===i.scheme&&(i.fullHost+=":"+i.port):"http"===i.scheme?i.port=80:"https"===i.scheme&&(i.port=443),i.full=i.scheme+"://"+i.fullHost),i};var u=null;t.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),i=0;i<r.length;i++){var n,s,a=r[i].indexOf("=");a>0?(n=r[i].substring(0,a),s=r[i].substring(a+1)):(n=r[i],s=null),n in t||(t[n]=[]),n in Object.prototype||null===s||t[n].push(unescape(s))}return t};return"undefined"==typeof e?(null===u&&(u="undefined"==typeof window?{}:r(window.location.search.substring(1))),t=u):t=r(e),t},t.parseFragment=function(e){var r=e,i="",n=e.indexOf("?");n>0&&(r=e.substring(0,n),i=e.substring(n+1));var s=r.split("/");s.length>0&&""===s[0]&&s.shift();var a=""===i?{}:t.getQueryVariables(i);return{pathString:r,queryString:i,path:s,query:a}},t.makeRequest=function(e){var r=t.parseFragment(e),i={path:r.pathString,query:r.queryString,getPath:function(e){return"undefined"==typeof e?r.path:r.path[e]},getQuery:function(e,t){var i;return"undefined"==typeof e?i=r.query:(i=r.query[e],i&&"undefined"!=typeof t&&(i=i[t])),i},getQueryLast:function(e,t){var r,n=i.getQuery(e);return r=n?n[n.length-1]:t}};return i},t.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var i=jQuery.param(t||{});return r=r||"",e+(i.length>0?"?"+i:"")+(r.length>0?"#"+r:"")},t.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var i=0,n=t.length;n>i;){var s=t[i++];if(i==n)e[s]=r;else{var a=s in e;(!a||a&&"object"!=typeof e[s]||a&&null===e[s])&&(e[s]={}),e=e[s]}}},t.getPath=function(e,t,r){for(var i=0,n=t.length,s=!0;s&&n>i&&"object"==typeof e&&null!==e;){var a=t[i++];s=a in e,s&&(e=e[a])}return s?e:r},t.deletePath=function(e,t){if("object"==typeof e&&null!==e)for(var r=0,i=t.length;i>r;){var n=t[r++];if(r==i)delete e[n];else{if(!(n in e)||"object"!=typeof e[n]||null===e[n])break;e=e[n]}}},t.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},t.format=function(e){for(var t,r,i=/%./g,n=0,s=[],a=0;t=i.exec(e);){r=e.substring(a,i.lastIndex-2),r.length>0&&s.push(r),a=i.lastIndex;var o=t[0][1];switch(o){case"s":case"o":s.push(n<arguments.length?arguments[n++ +1]:"<?>");break;case"%":s.push("%");break;default:s.push("<%"+o+"?>")}}return s.push(e.substring(a)),s.join("")},t.formatNumber=function(e,t,r,i){var n=e,s=isNaN(t=Math.abs(t))?2:t,a=void 0===r?",":r,o=void 0===i?".":i,c=0>n?"-":"",l=parseInt(n=Math.abs(+n||0).toFixed(s),10)+"",h=l.length>3?l.length%3:0;return c+(h?l.substr(0,h)+o:"")+l.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+o)+(s?a+Math.abs(n-l).toFixed(s).slice(2):"")},t.formatSize=function(e){return e=e>=1073741824?t.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?t.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?t.formatNumber(e/1024,0)+" KiB":t.formatNumber(e,0)+" bytes"},t.bytesFromIP=function(e){return-1!==e.indexOf(".")?t.bytesFromIPv4(e):-1!==e.indexOf(":")?t.bytesFromIPv6(e):null},t.bytesFromIPv4=function(e){if(e=e.split("."),4!==e.length)return null;for(var r=t.createBuffer(),i=0;i<e.length;++i){var n=parseInt(e[i],10);if(isNaN(n))return null;r.putByte(n)}return r.getBytes()},t.bytesFromIPv6=function(e){var r=0;e=e.split(":").filter(function(e){return 0===e.length&&++r,!0});for(var i=2*(8-e.length+r),n=t.createBuffer(),s=0;8>s;++s)if(e[s]&&0!==e[s].length){var a=t.hexToBytes(e[s]);a.length<2&&n.putByte(0),n.putBytes(a)}else n.fillWithByte(0,i),i=0;return n.getBytes()},t.bytesToIP=function(e){return 4===e.length?t.bytesToIPv4(e):16===e.length?t.bytesToIPv6(e):null},t.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},t.bytesToIPv6=function(e){if(16!==e.length)return null;for(var r=[],i=[],n=0,s=0;s<e.length;s+=2){for(var a=t.bytesToHex(e[s]+e[s+1]);"0"===a[0]&&"0"!==a;)a=a.substr(1);if("0"===a){var o=i[i.length-1],c=r.length;o&&c===o.end+1?(o.end=c,o.end-o.start>i[n].end-i[n].start&&(n=i.length-1)):i.push({start:c,end:c})}r.push(a)}if(i.length>0){var l=i[n];l.end-l.start>0&&(r.splice(l.start,l.end-l.start+1,""),0===l.start&&r.unshift(""),7===l.end&&r.push(""))}return r.join(":")}}(),js||(fl.util.ByteBuffer=function(){},fl.util.createBuffer=function(e,t){var r=new fl.util.ByteBuffer;return e?(r.data=new ii(e,t||"binary"),r.length_=r.data.length):(r.data=new ii(Hs),r.length_=0),r.read=0,r
},fl.util.ByteBuffer.prototype.length=function(){return this.length_-this.read},fl.util.ByteBuffer.prototype.isEmpty=function(){return this.length_-this.read===0},fl.util.ByteBuffer.prototype.putByte=function(e){this.data.length>=this.length_+1?this.data.writeUInt(e,this.length_,1):this.data=this.length_?[this.data.slice(0,this.length_),new Uint8Array([e])].concatBuffers():new Uint8Array([e]),this.length_+=1},fl.util.ByteBuffer.prototype.getByte=function(){return this.data[this.read++]},fl.util.ByteBuffer.prototype.at=function(e){return this.data[this.read+e]},fl.util.ByteBuffer.prototype.last=function(){return this.data[this.length_-1]},fl.util.ByteBuffer.prototype.fillWithByte=function(e,t){if(this.data.length>=this.length_+t)for(var r=this.length_,i=0;t>i;i++)this.data[r+i]=e;else{for(var n=[],i=0;t>i;i++)n.push(e);this.data=this.length_?[this.data.slice(0,this.length_),new Uint8Array(n)].concatBuffers():new Uint8Array(n)}this.length_+=t},fl.util.ByteBuffer.prototype.putBytes=function(e){var t;t="string"==typeof e?new ii(e,"binary"):e;var r=t.length;this.data.length>=this.length_+r?this.data.set(t,this.length_):this.data=this.length_?[this.data.slice(0,this.length_),t].concatBuffers():t,this.length_+=r},fl.util.ByteBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e).toString("binary"),this.read+=e):0===e?t="":(t=this.data.slice(this.read,this.length_).toString("binary"),this.clear()),t},fl.util.ByteBuffer.prototype.putBuffer=function(e){this.data.length>=this.length_+e.length_?e.length_&&this.data.set(e.data.slice(0,e.length_),this.length_):this.data=this.length_?[this.data.slice(0,this.length_),e.data.slice(0,e.length_)].concatBuffers():e.data.slice(0,e.length_),this.length_+=e.length_,e.clear()},fl.util.ByteBuffer.prototype.bytes=function(e){return e?this.data.slice(this.read,this.read+e).toString("binary"):this.data.slice(this.read,this.length_).toString("binary")},fl.util.ByteBuffer.prototype.putInt16=function(e){this.data.length>=this.length_+2?this.data.writeUInt(e,this.length_,2):this.data=this.length_?[this.data.slice(0,this.length_),new ii(2).writeUInt(e)].concatBuffers():new ii(2).writeUInt(e),this.length_+=2},fl.util.ByteBuffer.prototype.putInt24=function(e){this.data.length>=this.length_+3?this.data.writeUInt(e,this.length_,3):this.data=this.length_?[this.data.slice(0,this.length_),new ii(3).writeUInt(e)].concatBuffers():new ii(3).writeUInt(e),this.length_+=3},fl.util.ByteBuffer.prototype.putInt32=function(e){this.data.length>=this.length_+4?this.data.writeUInt(e,this.length_,4):this.data=this.length_?[this.data.slice(0,this.length_),new ii(4).writeUInt(e)].concatBuffers():new ii(4).writeUInt(e),this.length_+=4},fl.util.ByteBuffer.prototype.putInt32Le=function(e){this.data.length>=this.length_+4?this.data.writeUIntLE(e,this.length_,4):this.data=this.length_?[this.data.slice(0,this.length_),new ii(4).writeUIntLE(e)].concatBuffers():new ii(4).writeUIntLE(e),this.length_+=4},fl.util.ByteBuffer.prototype.putInt=function(e,t){t/=8,this.data.length>=this.length_+t?this.data.writeUInt(e,this.length_,t):this.data=this.length_?[this.data.slice(0,this.length_),new ii(t).writeUInt(e)].concatBuffers():new ii(t).writeUInt(e),this.length_+=t},fl.util.ByteBuffer.prototype.getInt16=function(){var e=this.data.readUInt(this.read,2);return this.read+=2,e},fl.util.ByteBuffer.prototype.getInt24=function(){var e=this.data.readUInt(this.read,3);return this.read+=3,e},fl.util.ByteBuffer.prototype.getInt32=function(){var e=this.data.readUInt(this.read,4);return this.read+=4,e},fl.util.ByteBuffer.prototype.getInt32Le=function(){var e=this.data.readUIntLE(this.read,4);return this.read+=4,e},fl.util.ByteBuffer.prototype.getInt=function(e){e/=8;var t=this.data.readUInt(this.read,e);return this.read+=e,t},fl.util.ByteBuffer.prototype.compact=function(){if(this.length()){var e=this.data.slice(this.read,this.length_);this.data=new ii(Math.max(Hs,e.length)),this.data.set(e),this.length_=e.length,this.read=0}else this.clear()},fl.util.ByteBuffer.prototype.clear=function(){this.data=new ii(Hs),this.length_=0,this.read=0},fl.util.ByteBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e),r=this.data.slice(this.read,t);this.data=new ii(Hs),this.data.length>r.length?this.data.set(r):this.data=r,this.length_=r.length,this.read=0},fl.util.ByteBuffer.prototype.toHex=function(){return this.data.slice(0,this.length_).toString("hex")},fl.util.ByteBuffer.prototype.toString=function(){return new ii(this.data.slice(0,this.length_).toString("binary"),"utf8").toString("utf8")}),function(){var e=fl.sha1=fl.sha1||{};fl.md=fl.md||{},fl.md.algorithms=fl.md.algorithms||{},fl.md.sha1=fl.md.algorithms.sha1=e;var t=null,r=!1,i=function(){t=String.fromCharCode(128),t+=fl.util.fillString(String.fromCharCode(0),64),r=!0},n=function(e,t,r){for(var i,n,s,a,o,c,l,h,u=r.length();u>=64;){for(n=e.h0,s=e.h1,a=e.h2,o=e.h3,c=e.h4,h=0;16>h;++h)i=r.getInt32(),t[h]=i,l=o^s&(a^o),i=(n<<5|n>>>27)+l+c+1518500249+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;20>h;++h)i=t[h-3]^t[h-8]^t[h-14]^t[h-16],i=i<<1|i>>>31,t[h]=i,l=o^s&(a^o),i=(n<<5|n>>>27)+l+c+1518500249+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;32>h;++h)i=t[h-3]^t[h-8]^t[h-14]^t[h-16],i=i<<1|i>>>31,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+1859775393+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;40>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+1859775393+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;60>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s&a|o&(s^a),i=(n<<5|n>>>27)+l+c+2400959708+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;80>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+3395469782+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;e.h0+=n,e.h1+=s,e.h2+=a,e.h3+=o,e.h4+=c,u-=64}};e.create=function(){r||i();var e=null,s=fl.util.createBuffer(),a=new Array(80),o={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0};return o.start=function(){return o.messageLength=0,s=fl.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},o},o.start(),o.update=function(t,r){return"utf8"===r&&(t=fl.util.encodeUtf8(t)),o.messageLength+=t.length,s.putBytes(t),n(e,a,s),(s.read>2048||0===s.length())&&s.compact(),o},o.digest=function(){var r=o.messageLength,i=fl.util.createBuffer();i.putBytes(s.bytes()),i.putBytes(t.substr(0,64-(r+8)%64)),i.putInt32(r>>>29&255),i.putInt32(r<<3&4294967295);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};n(c,a,i);var l=fl.util.createBuffer();return l.putInt32(c.h0),l.putInt32(c.h1),l.putInt32(c.h2),l.putInt32(c.h3),l.putInt32(c.h4),l},o.digest2=function(){var r=o.messageLength,i=fl.util.createBuffer(),c=fl.util.createBuffer(s.data.slice(s.read)),l=a.slice(0);i.putBytes(s.bytes()),i.putBytes(t.substr(0,64-(r+8)%64)),i.putInt32(r>>>29&255),i.putInt32(r<<3&4294967295);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};n(h,a,i);var u=fl.util.createBuffer();return u.putInt32(h.h0),u.putInt32(h.h1),u.putInt32(h.h2),u.putInt32(h.h3),u.putInt32(h.h4),s=c,a=l,u},o},e.createhash=function(){var t=e.create(),r=t.update;return t.update=function(e){return r(e.toString("binary"))},t.digest=function(){return t.digest2().toHex()},t}}(),function(){var e=fl;e.hmac={};var t=e.hmac;t.create=function(){var t=null,r=null,i=null,n=null,s={};return s.start=function(s,a){if(null!==s)if(s.constructor==String){if(s=s.toLowerCase(),!(s in e.md.algorithms))throw'Unknown hash algorithm "'+s+'"';r=e.md.algorithms[s].create()}else r=s;if(null===a)a=t;else{if(a.constructor==String)a=e.util.createBuffer(a);else if(a.constructor==Array){var o=a;a=e.util.createBuffer();for(var c=0;c<o.length;++c)a.putByte(o[c])}var l=a.length();l>r.blockLength&&(r.start(),r.update(a.bytes()),a=r.digest()),i=e.util.createBuffer(),n=e.util.createBuffer(),l=a.length();for(var c=0;l>c;++c){var o=a.at(c);i.putByte(54^o),n.putByte(92^o)}if(l<r.blockLength)for(var o=r.blockLength-l,c=0;o>c;++c)i.putByte(54),n.putByte(92);t=a,i=i.bytes(),n=n.bytes()}r.start(),r.update(i)},s.update=function(e){r.update(e)},s.getMac=function(){var e=r.digest().bytes();return r.start(),r.update(n),r.update(e),r.digest()},s.digest=s.getMac,s}}(),function(){var e,t,r,i,n,s=!1,a=4,o=function(){s=!0,r=[0,1,2,4,8,16,32,64,128,27,54];for(var a=new Array(256),o=0;128>o;++o)a[o]=o<<1,a[o+128]=o+128<<1^283;e=new Array(256),t=new Array(256),i=new Array(4),n=new Array(4);for(var o=0;4>o;++o)i[o]=new Array(256),n[o]=new Array(256);for(var c,l,h,u,d,f,p,_=0,g=0,o=0;256>o;++o){u=g^g<<1^g<<2^g<<3^g<<4,u=u>>8^255&u^99,e[_]=u,t[u]=_,d=a[u],c=a[_],l=a[c],h=a[l],f=d<<24^u<<16^u<<8^(u^d),p=(c^l^h)<<24^(_^h)<<16^(_^l^h)<<8^(_^c^h);for(var m=0;4>m;++m)i[m][_]=f,n[m][u]=p,f=f<<24|f>>>8,p=p<<24|p>>>8;0===_?_=g=1:(_=c^a[a[a[c^h]]],g^=a[a[g]])}},c=function(t,i){for(var s,o=t.slice(0),c=1,l=o.length,h=l+6+1,u=a*h,d=l;u>d;++d)s=o[d-1],d%l===0?(s=e[s>>>16&255]<<24^e[s>>>8&255]<<16^e[255&s]<<8^e[s>>>24]^r[c]<<24,c++):l>6&&d%l===4&&(s=e[s>>>24]<<24^e[s>>>16&255]<<16^e[s>>>8&255]<<8^e[255&s]),o[d]=o[d-l]^s;if(i){for(var f,p=n[0],_=n[1],g=n[2],m=n[3],y=o.slice(0),u=o.length,d=0,v=u-a;u>d;d+=a,v-=a)if(0===d||d===u-a)y[d]=o[v],y[d+1]=o[v+3],y[d+2]=o[v+2],y[d+3]=o[v+1];else for(var b=0;a>b;++b)f=o[v+b],y[d+(3&-b)]=p[e[f>>>24]]^_[e[f>>>16&255]]^g[e[f>>>8&255]]^m[e[255&f]];o=y}return o},l=function(r,s,a,o){var c,l,h,u,d,f=r.length/4-1;o?(c=n[0],l=n[1],h=n[2],u=n[3],d=t):(c=i[0],l=i[1],h=i[2],u=i[3],d=e);var p,_,g,m,y,v,b;p=s[0]^r[0],_=s[o?3:1]^r[1],g=s[2]^r[2],m=s[o?1:3]^r[3];for(var w=3,S=1;f>S;++S)y=c[p>>>24]^l[_>>>16&255]^h[g>>>8&255]^u[255&m]^r[++w],v=c[_>>>24]^l[g>>>16&255]^h[m>>>8&255]^u[255&p]^r[++w],b=c[g>>>24]^l[m>>>16&255]^h[p>>>8&255]^u[255&_]^r[++w],m=c[m>>>24]^l[p>>>16&255]^h[_>>>8&255]^u[255&g]^r[++w],p=y,_=v,g=b;a[0]=d[p>>>24]<<24^d[_>>>16&255]<<16^d[g>>>8&255]<<8^d[255&m]^r[++w],a[o?3:1]=d[_>>>24]<<24^d[g>>>16&255]<<16^d[m>>>8&255]<<8^d[255&p]^r[++w],a[2]=d[g>>>24]<<24^d[m>>>16&255]<<16^d[p>>>8&255]<<8^d[255&_]^r[++w],a[o?1:3]=d[m>>>24]<<24^d[p>>>16&255]<<16^d[_>>>8&255]<<8^d[255&g]^r[++w]},h=function(e,t,r,i,n){function h(){if(i)for(var e=0;a>e;++e)b[e]=y.getInt32();else for(var e=0;a>e;++e)b[e]=S[e]^y.getInt32();if(l(T,b,w,i),i){for(var e=0;a>e;++e)v.putInt32(S[e]^w[e]);S=b.slice(0)}else{for(var e=0;a>e;++e)v.putInt32(w[e]);S=w}}function u(){l(T,b,w,!1);for(var e=0;a>e;++e)b[e]=y.getInt32();for(var e=0;a>e;++e){var t=b[e]^w[e];i||(b[e]=t),v.putInt32(t)}}function d(){l(T,b,w,!1);for(var e=0;a>e;++e)b[e]=y.getInt32();for(var e=0;a>e;++e)v.putInt32(b[e]^w[e]),b[e]=w[e]}function f(){l(T,b,w,!1);for(var e=a-1;e>=0;--e){if(4294967295!==b[e]){++b[e];break}b[e]=0}for(var e=0;a>e;++e)v.putInt32(y.getInt32()^w[e])}var p=null;if(s||o(),n=(n||"CBC").toUpperCase(),"string"!=typeof e||16!==e.length&&24!==e.length&&32!==e.length){if(fl.util.isArray(e)&&(16===e.length||24===e.length||32===e.length))for(var _=e,e=fl.util.createBuffer(),g=0;g<_.length;++g)e.putByte(_[g])}else e=fl.util.createBuffer(e);if(!fl.util.isArray(e)){var _=e;e=[];var m=_.length();if(16===m||24===m||32===m){m>>>=2;for(var g=0;m>g;++g)e.push(_.getInt32())}}if(!fl.util.isArray(e)||4!==e.length&&6!==e.length&&8!==e.length)return p;var y,v,b,w,S,E,C,A=-1!==["CFB","OFB","CTR"].indexOf(n),I="CBC"===n,T=c(e,i&&!A),x=a<<2;if(p={output:null},"CBC"===n)C=h;else if("CFB"===n)C=u;else if("OFB"===n)C=d;else{if("CTR"!==n)throw{message:'Unsupported block cipher mode of operation: "'+n+'"'};C=f}return p.update=function(e){for(E||y.putBuffer(e);y.length()>=x||y.length()>0&&E;)C()},p.update2=function(e){for(e&&e.length()&&(y.data=y.data.substr(y.read),y.read=0,y.putBuffer(e));y.length()>=x;)C();p.overflow&&v.getBytes(p.overflow);var t=y.length()%x;if(t){for(var r=fl.util.createBuffer(y.data.slice(y.read)),i=b.slice(0);y.length()>0;)C();y=r,b=i,v.truncate(x-t)}else y.data="",y.read=0;p.overflow=t},p.finish=function(e){var t=!0,r=y.length()%x;if(!i)if(e)t=e(x,y,i);else if(I){var n=y.length()===x?x:x-y.length();y.fillWithByte(n,n)}if(t&&(E=!0,p.update()),i&&(I&&(t=0===r),t))if(e)t=e(x,v,i);else if(I){var s=v.length(),o=v.at(s-1);o>a<<2?t=!1:v.truncate(o)}return!I&&!e&&r>0&&v.truncate(x-r),t},p.start=function(e,t){if(null===e&&(e=S.slice(0)),"string"==typeof e&&16===e.length)e=fl.util.createBuffer(e);else if(fl.util.isArray(e)&&16===e.length)for(var r=e,e=fl.util.createBuffer(),i=0;16>i;++i)e.putByte(r[i]);if(!fl.util.isArray(e)){var r=e;e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32()}if(y=fl.util.createBuffer(),v=t||fl.util.createBuffer(),S=e.slice(0),b=new Array(a),w=new Array(a),E=!1,p.output=v,-1!==["CFB","OFB","CTR"].indexOf(n)){for(var i=0;a>i;++i)b[i]=S[i];S=null}},null!==t&&p.start(t,r),p};fl.aes=fl.aes||{},fl.aes.startEncrypting=function(e,t,r,i){return h(e,t,r,!1,i)},fl.aes.createEncryptionCipher=function(e,t){return h(e,null,null,!1,t)},fl.aes.startDecrypting=function(e,t,r,i){return h(e,t,r,!0,i)},fl.aes.createDecryptionCipher=function(e,t){return h(e,null,null,!0,t)},fl.aes._expandKey=function(e,t){return s||o(),c(e,t)},fl.aes._updateBlock=l,fl.aes.createcipheriv=function(e,t,r){var i=e.split("-")[2],n=fl.util.createBuffer();t=fl.util.createBuffer(t.toString("binary")),r=fl.util.createBuffer(r.toString("binary"));var s=fl.aes.startEncrypting(t,r,n,i),a=s.update2;return s.update=function(e){var t;return e=e?fl.util.createBuffer(e.toString("binary")):fl.util.createBuffer(),a(e),t=n.toHex(),n.data="",n.read=0,t},s}}(),function(){var e=fl;e.asn1={};var t=e.asn1;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(e,t,r,i){return{tagClass:e,type:t,constructed:r,composed:r||i.constructor==Array,value:i}};var r=function(e){var t=e.getByte();if(128==t)return void 0;var r,i=128&t;return r=i?e.getInt((127&t)<<3):t};t.fromDer=function(i){if(i.constructor==String&&(i=e.util.createBuffer(i)),i.length()<2)throw{message:"Too few bytes to parse DER.",bytes:i.length()};var n=i.getByte(),s=192&n,a=31&n,o=r(i);if(i.length()<o)throw{message:"Too few bytes to read ASN.1 value.",detail:i.length()+" < "+o};var c,l=32==(32&n),h=l;if(!h&&s===t.Class.UNIVERSAL&&a===t.Type.BITSTRING&&o>1){var u=i.read,d=i.getByte();if(0===d){n=i.getByte();var f=192&n;if(f===t.Class.UNIVERSAL||f===t.Class.CONTEXT_SPECIFIC)try{var p=r(i);h=p===o-(i.read-u),h&&(++u,--o)}catch(_){}}i.read=u}if(h)if(c=[],void 0===o)for(;;){if(i.bytes(2)===String.fromCharCode(0,0)){i.getBytes(2);break}c.push(t.fromDer(i))}else for(var g=i.length();o>0;)c.push(t.fromDer(i)),o-=g-i.length(),g=i.length();else{if(void 0===o)throw{message:"Non-constructed ASN.1 object of indefinite length."};if(a===t.Type.BMPSTRING){c="";for(var m=0;o>m;m+=2)c+=String.fromCharCode(i.getInt16())}else c=i.getBytes(o)}return t.create(s,a,l,c)},t.toDer=function(r){var i=e.util.createBuffer(),n=r.tagClass|r.type,s=e.util.createBuffer();if(r.composed){r.constructed?n|=32:s.putByte(0);for(var a=0;a<r.value.length;++a)void 0!==r.value[a]&&s.putBuffer(t.toDer(r.value[a]))}else s.putBytes(r.value);if(i.putByte(n),s.length()<=127)i.putByte(127&s.length());else{var o=s.length(),c="";do c+=String.fromCharCode(255&o),o>>>=8;while(o>0);i.putByte(128|c.length);for(var a=c.length-1;a>=0;--a)i.putByte(c.charCodeAt(a))}return i.putBuffer(s),i},t.oidToDer=function(t){var r=t.split("."),i=e.util.createBuffer();i.putByte(40*parseInt(r[0],10)+parseInt(r[1],10));for(var n,s,a,o,c=2;c<r.length;++c){n=!0,s=[],a=parseInt(r[c],10);do o=127&a,a>>>=7,n||(o|=128),s.push(o),n=!1;while(a>0);for(var l=s.length-1;l>=0;--l)i.putByte(s[l])}return i},t.derToOid=function(t){var r;t.constructor==String&&(t=e.util.createBuffer(t));var i=t.getByte();r=Math.floor(i/40)+"."+i%40;for(var n=0;t.length()>0;)i=t.getByte(),n<<=7,128&i?n+=127&i:(r+="."+(n+i),n=0);return r},t.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var i=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var c=e.charAt(10),l=10;"+"!==c&&"-"!==c&&(o=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(r,i,n),t.setUTCHours(s,a,o,0),l&&(c=e.charAt(l),"+"===c||"-"===c)){var h=parseInt(e.substr(l+1,2),10),u=parseInt(e.substr(l+4,2),10),d=60*h+u;d*=6e4,t.setTime("+"===c?+t-d:+t+d)}return t},t.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),i=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),a=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),c=0,l=0,h=!1;"Z"==e.charAt(e.length-1)&&(h=!0);var u=e.length-5,d=e.charAt(u);if("+"===d||"-"===d){var f=parseInt(e.substr(u+1,2),10),p=parseInt(e.substr(u+4,2),10);l=60*f+p,l*=6e4,"+"===d&&(l*=-1),h=!0}return"."==e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),h?(t.setUTCFullYear(r,i,n),t.setUTCHours(s,a,o,c),t.setTime(+t+l)):(t.setFullYear(r,i,n),t.setHours(s,a,o,c)),t},t.dateToUtcTime=function(e){var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var i=0;i<r.length;++i)r[i].length<2&&(t+="0"),t+=r[i];return t+="Z"},t.validate=function(e,r,i,n){var s=!1;if(e.tagClass!==r.tagClass&&"undefined"!=typeof r.tagClass||e.type!==r.type&&"undefined"!=typeof r.type)n&&(e.tagClass!==r.tagClass&&n.push("["+r.name+'] Expected tag class "'+r.tagClass+'", got "'+e.tagClass+'"'),e.type!==r.type&&n.push("["+r.name+'] Expected type "'+r.type+'", got "'+e.type+'"'));else if(e.constructed===r.constructed||"undefined"==typeof r.constructed){if(s=!0,r.value&&r.value.constructor==Array)for(var a=0,o=0;s&&o<r.value.length;++o)s=r.value[o].optional||!1,e.value[a]&&(s=t.validate(e.value[a],r.value[o],i,n),s?++a:r.value[o].optional&&(s=!0)),!s&&n&&n.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+e.value.length+'"');s&&i&&(r.capture&&(i[r.capture]=e.value),r.captureAsn1&&(i[r.captureAsn1]=e))}else n&&n.push("["+r.name+'] Expected constructed "'+r.constructed+'", got "'+e.constructed+'"');return s};var i=/[^\\u0000-\\u00ff]/;t.prettyPrint=function(r,n,s){var a="";n=n||0,s=s||2,n>0&&(a+="\n");for(var o="",c=0;n*s>c;++c)o+=" ";switch(a+=o+"Tag: ",r.tagClass){case t.Class.UNIVERSAL:a+="Universal:";break;case t.Class.APPLICATION:a+="Application:";break;case t.Class.CONTEXT_SPECIFIC:a+="Context-Specific:";break;case t.Class.PRIVATE:a+="Private:"}if(r.tagClass===t.Class.UNIVERSAL)switch(a+=r.type,r.type){case t.Type.NONE:a+=" (None)";break;case t.Type.BOOLEAN:a+=" (Boolean)";break;case t.Type.BITSTRING:a+=" (Bit string)";break;case t.Type.INTEGER:a+=" (Integer)";break;case t.Type.OCTETSTRING:a+=" (Octet string)";break;case t.Type.NULL:a+=" (Null)";break;case t.Type.OID:a+=" (Object Identifier)";break;case t.Type.ODESC:a+=" (Object Descriptor)";break;case t.Type.EXTERNAL:a+=" (External or Instance of)";break;case t.Type.REAL:a+=" (Real)";break;case t.Type.ENUMERATED:a+=" (Enumerated)";break;case t.Type.EMBEDDED:a+=" (Embedded PDV)";break;case t.Type.UTF8:a+=" (UTF8)";break;case t.Type.ROID:a+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:a+=" (Sequence)";break;case t.Type.SET:a+=" (Set)";break;case t.Type.PRINTABLESTRING:a+=" (Printable String)";break;case t.Type.IA5String:a+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:a+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:a+=" (Generalized time)";break;case t.Type.BMPSTRING:a+=" (BMP String)"}else a+=r.type;if(a+="\n",a+=o+"Constructed: "+r.constructed+"\n",r.composed){a+=o+"Sub values: "+r.value.length;for(var c=0;c<r.value.length;++c)a+=t.prettyPrint(r.value[c],n+1,s),c+1<r.value.length&&(a+=",")}else if(a+=o+"Value: ",r.type===t.Type.OID){var l=t.derToOid(r.value);a+=l,e.pki&&e.pki.oids&&l in e.pki.oids&&(a+=" ("+e.pki.oids[l]+")")}else a+=i.test(r.value)?"0x"+e.util.createBuffer(r.value,"utf8").toHex():0===r.value.length?"[null]":r.value;return a}}();var pl,_l=0xdeadbeefcafe,gl=15715070==(16777215&_l);"undefined"==typeof Ya?(H.prototype.am=G,pl=28):gl&&"Microsoft Internet Explorer"==Ya.appName?(H.prototype.am=V,pl=30):gl&&"Netscape"!=Ya.appName?(H.prototype.am=K,pl=26):(H.prototype.am=G,pl=28),H.prototype.DB=pl,H.prototype.DM=(1<<pl)-1,H.prototype.DV=1<<pl;var ml=52;H.prototype.FV=Math.pow(2,ml),H.prototype.F1=ml-pl,H.prototype.F2=2*pl-ml;var yl,vl,bl="0123456789abcdefghijklmnopqrstuvwxyz",wl=new Array;for(yl="0".charCodeAt(0),vl=0;9>=vl;++vl)wl[yl++]=vl;for(yl="a".charCodeAt(0),vl=10;36>vl;++vl)wl[yl++]=vl;for(yl="A".charCodeAt(0),vl=10;36>vl;++vl)wl[yl++]=vl;_t.prototype.convert=gt,_t.prototype.revert=mt,_t.prototype.reduce=yt,_t.prototype.mulTo=vt,_t.prototype.sqrTo=bt,St.prototype.convert=Et,St.prototype.revert=Ct,St.prototype.reduce=At,St.prototype.mulTo=Tt,St.prototype.sqrTo=It,H.prototype.copyTo=Q,H.prototype.fromInt=X,H.prototype.fromString=Z,H.prototype.clamp=$,H.prototype.dlShiftTo=at,H.prototype.drShiftTo=ot,H.prototype.lShiftTo=ct,H.prototype.rShiftTo=lt,H.prototype.subTo=ht,H.prototype.multiplyTo=ut,H.prototype.squareTo=dt,H.prototype.divRemTo=ft,H.prototype.invDigit=wt,H.prototype.isEven=xt,H.prototype.exp=Bt,H.prototype.toString=et,H.prototype.negate=tt,H.prototype.abs=rt,H.prototype.compareTo=it,H.prototype.bitLength=st,H.prototype.mod=pt,H.prototype.modPowInt=kt,H.ZERO=J(0),H.ONE=J(1),Rt.prototype.init=Ut,Rt.prototype.next=Dt;var Sl,El,Cl,Al=256,Ya=Ya||window.navigator;if(null==El){El=new Array,Cl=0;var Il;if("Netscape"==Ya.appName&&Ya.appVersion<"5"&&window.crypto){var Tl=window.crypto.random(32);for(Il=0;Il<Tl.length;++Il)El[Cl++]=255&Tl.charCodeAt(Il)}for(;Al>Cl;)Il=Math.floor(65536*Math.random()),El[Cl++]=Il>>>8,El[Cl++]=255&Il;Cl=0,Ot()}qt.prototype.nextBytes=Ft,jt.prototype.doPublic=Kt,jt.prototype.setPublic=zt,jt.prototype.encrypt=Vt,Or.prototype.convert=Pr,Or.prototype.revert=Pr,Or.prototype.mulTo=Fr,Or.prototype.sqrTo=qr,zr.prototype.convert=Kr,zr.prototype.revert=Vr,zr.prototype.reduce=Gr,zr.prototype.mulTo=Wr,zr.prototype.sqrTo=Yr;var xl=[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,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Bl=(1<<26)/xl[xl.length-1];H.prototype.chunkSize=Xt,H.prototype.toRadix=Zt,H.prototype.fromRadix=$t,H.prototype.fromNumber=er,H.prototype.bitwiseTo=sr,H.prototype.changeBit=Sr,H.prototype.addTo=Ir,H.prototype.dMultiply=Nr,H.prototype.dAddOffset=Lr,H.prototype.multiplyLowerTo=Hr,H.prototype.multiplyUpperTo=jr,H.prototype.modInt=Jr,H.prototype.millerRabin=ei,H.prototype.clone=Gt,H.prototype.intValue=Yt,H.prototype.byteValue=Wt,H.prototype.shortValue=Qt,H.prototype.signum=Jt,H.prototype.toByteArray=tr,H.prototype.equals=rr,H.prototype.min=ir,H.prototype.max=nr,H.prototype.and=or,H.prototype.or=lr,H.prototype.xor=ur,H.prototype.andNot=fr,H.prototype.not=pr,H.prototype.shiftLeft=_r,H.prototype.shiftRight=gr,H.prototype.getLowestSetBit=yr,H.prototype.bitCount=br,H.prototype.testBit=wr,H.prototype.setBit=Er,H.prototype.clearBit=Cr,H.prototype.flipBit=Ar,H.prototype.add=Tr,H.prototype.subtract=xr,H.prototype.multiply=Br,H.prototype.divide=Rr,H.prototype.remainder=Ur,H.prototype.divideAndRemainder=Dr,H.prototype.modPow=Qr,H.prototype.modInverse=Zr,H.prototype.pow=Mr,H.prototype.gcd=Xr,H.prototype.isProbablePrime=$r,H.prototype.square=kr,function(){var e=fl;e.prng={};var t=e.prng;t.create=function(t){function r(){if(i.pools[0].messageLength<32){for(var t,r,n,s=32-i.pools[0].messageLength<<5,a="",o=Math.floor(65535*Math.random());a.length<s;){r=16807*(65535&o),t=16807*(o>>16),r+=(32767&t)<<16,r+=t>>15,r=(2147483647&r)+(r>>31),o=4294967295&r;for(var c=0;3>c;++c)n=o>>>(c<<3),n^=Math.floor(255*Math.random()),a+=String.fromCharCode(255&n)}i.collect(a)}else{var l=e.md.sha1.create();l.update(i.pools[0].digest().getBytes()),i.pools[0].start();for(var h=1,c=1;32>c;++c)h=31==h?2147483648:h<<2,h%i.reseeds===0&&(l.update(i.pools[c].digest().getBytes()),i.pools[c].start());var u=l.digest().getBytes();l.start(),l.update(u);var d=l.digest().getBytes();i.key=i.plugin.formatKey(u),i.seed=i.plugin.formatSeed(d),++i.reseeds,i.generated=0,i.time=+new Date}}for(var i={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0},n=t.md,s=new Array(32),a=0;32>a;++a)s[a]=n.create();return i.pools=s,i.pool=0,i.generate=function(t){null===i.key&&r();for(var n=i.plugin.cipher,s=i.plugin.increment,a=i.plugin.formatKey,o=i.plugin.formatSeed,c=e.util.createBuffer();c.length()<t;){var l=n(i.key,i.seed);if(i.generated+=l.length,c.putBytes(l),i.key=a(n(i.key,s(i.seed))),i.seed=o(n(i.key,i.seed)),i.generated>=1048576){var h=+new Date;h-i.time<100&&r()}}return c.getBytes(t)},i.collect=function(e){for(var t=e.length,n=0;t>n;++n)i.pools[i.pool].update(e.substr(n,1)),i.pool=31===i.pool?0:i.pool+1;if(i.pools[0].messageLength>=32){var s=+new Date;(null===i.time||s-i.time<100)&&r()}},i.collectInt=function(e,t){var r="";do t-=8,r+=String.fromCharCode(e>>t&255);while(t>0);i.collect(r)},i}}(),function(e){var t=fl;t.random={};var r={},i=new Array(4),n=t.util.createBuffer();r.formatKey=function(e){var r=t.util.createBuffer(e);return e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32(),t.aes._expandKey(e,!1)},r.formatSeed=function(e){var r=t.util.createBuffer(e);return e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32(),e},r.cipher=function(e,r){return t.aes._updateBlock(e,r,i,!1),n.putInt32(i[0]),n.putInt32(i[1]),n.putInt32(i[2]),n.putInt32(i[3]),n.getBytes()},r.increment=function(e){return++e[3],e},r.md=t.md.sha1;var s=t.prng.create(r);if(s.collectInt(+new Date,32),"undefined"!=typeof Ya){var a="";for(var o in Ya)try{"string"==typeof Ya[o]&&(a+=Ya[o])}catch(c){}s.collect(a),a=null}e&&(e().mousemove(function(e){s.collectInt(e.clientX,16),s.collectInt(e.clientY,16)}),e().keypress(function(e){s.collectInt(e.charCode,8)})),t.random.getBytes=function(e){return s.generate(e)}}("undefined"!=typeof jQuery?jQuery:null),function(){var e={},t=fl;t.pki=t.pki||{},t.pki.oids=e,e["1.2.840.113549.1.1.1"]="rsaEncryption",e.rsaEncryption="1.2.840.113549.1.1.1",e["1.2.840.113549.1.1.4"]="md5withRSAEncryption",e.md5withRSAEncryption="1.2.840.113549.1.1.4",e["1.2.840.113549.1.1.5"]="sha1withRSAEncryption",e.sha1withRSAEncryption="1.2.840.113549.1.1.5",e["1.2.840.113549.1.1.7"]="RSAES-OAEP",e["RSAES-OAEP"]="1.2.840.113549.1.1.7",e["1.2.840.113549.1.1.8"]="mgf1",e.mgf1="1.2.840.113549.1.1.8",e["1.2.840.113549.1.1.9"]="pSpecified",e.pSpecified="1.2.840.113549.1.1.9",e["1.2.840.113549.1.1.10"]="RSASSA-PSS",e["RSASSA-PSS"]="1.2.840.113549.1.1.10",e["1.2.840.113549.1.1.11"]="sha256WithRSAEncryption",e.sha256WithRSAEncryption="1.2.840.113549.1.1.11",e["1.2.840.113549.1.1.12"]="sha384WithRSAEncryption",e.sha384WithRSAEncryption="1.2.840.113549.1.1.12",e["1.2.840.113549.1.1.13"]="sha512WithRSAEncryption",e.sha512WithRSAEncryption="1.2.840.113549.1.1.13",e["1.3.14.3.2.26"]="sha1",e.sha1="1.3.14.3.2.26",e["2.16.840.1.101.3.4.2.1"]="sha256",e.sha256="2.16.840.1.101.3.4.2.1",e["2.16.840.1.101.3.4.2.2"]="sha384",e.sha384="2.16.840.1.101.3.4.2.2",e["2.16.840.1.101.3.4.2.3"]="sha512",e.sha512="2.16.840.1.101.3.4.2.3",e["1.2.840.113549.2.5"]="md5",e.md5="1.2.840.113549.2.5",e["1.2.840.113549.1.7.1"]="data",e.data="1.2.840.113549.1.7.1",e["1.2.840.113549.1.7.2"]="signedData",e.signedData="1.2.840.113549.1.7.2",e["1.2.840.113549.1.7.3"]="envelopedData",e.envelopedData="1.2.840.113549.1.7.3",e["1.2.840.113549.1.7.4"]="signedAndEnvelopedData",e.signedAndEnvelopedData="1.2.840.113549.1.7.4",e["1.2.840.113549.1.7.5"]="digestedData",e.digestedData="1.2.840.113549.1.7.5",e["1.2.840.113549.1.7.6"]="encryptedData",e.encryptedData="1.2.840.113549.1.7.6",e["1.2.840.113549.1.9.20"]="friendlyName",e.friendlyName="1.2.840.113549.1.9.20",e["1.2.840.113549.1.9.21"]="localKeyId",e.localKeyId="1.2.840.113549.1.9.21",e["1.2.840.113549.1.9.22.1"]="x509Certificate",e.x509Certificate="1.2.840.113549.1.9.22.1",e["1.2.840.113549.1.12.10.1.1"]="keyBag",e.keyBag="1.2.840.113549.1.12.10.1.1",e["1.2.840.113549.1.12.10.1.2"]="pkcs8ShroudedKeyBag",e.pkcs8ShroudedKeyBag="1.2.840.113549.1.12.10.1.2",e["1.2.840.113549.1.12.10.1.3"]="certBag",e.certBag="1.2.840.113549.1.12.10.1.3",e["1.2.840.113549.1.12.10.1.4"]="crlBag",e.crlBag="1.2.840.113549.1.12.10.1.4",e["1.2.840.113549.1.12.10.1.5"]="secretBag",e.secretBag="1.2.840.113549.1.12.10.1.5",e["1.2.840.113549.1.12.10.1.6"]="safeContentsBag",e.safeContentsBag="1.2.840.113549.1.12.10.1.6",e["1.2.840.113549.1.5.13"]="pkcs5PBES2",e.pkcs5PBES2="1.2.840.113549.1.5.13",e["1.2.840.113549.1.5.12"]="pkcs5PBKDF2",e.pkcs5PBKDF2="1.2.840.113549.1.5.12",e["1.2.840.113549.1.12.1.1"]="pbeWithSHAAnd128BitRC4",e.pbeWithSHAAnd128BitRC4="1.2.840.113549.1.12.1.1",e["1.2.840.113549.1.12.1.2"]="pbeWithSHAAnd40BitRC4",e.pbeWithSHAAnd40BitRC4="1.2.840.113549.1.12.1.2",e["1.2.840.113549.1.12.1.3"]="pbeWithSHAAnd3-KeyTripleDES-CBC",e["pbeWithSHAAnd3-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.3",e["1.2.840.113549.1.12.1.4"]="pbeWithSHAAnd2-KeyTripleDES-CBC",e["pbeWithSHAAnd2-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.4",e["1.2.840.113549.1.12.1.5"]="pbeWithSHAAnd128BitRC2-CBC",e["pbeWithSHAAnd128BitRC2-CBC"]="1.2.840.113549.1.12.1.5",e["1.2.840.113549.1.12.1.6"]="pbewithSHAAnd40BitRC2-CBC",e["pbewithSHAAnd40BitRC2-CBC"]="1.2.840.113549.1.12.1.6",e["1.2.840.113549.3.7"]="des-EDE3-CBC",e["des-EDE3-CBC"]="1.2.840.113549.3.7",e["2.16.840.1.101.3.4.1.2"]="aes128-CBC",e["aes128-CBC"]="2.16.840.1.101.3.4.1.2",e["2.16.840.1.101.3.4.1.22"]="aes192-CBC",e["aes192-CBC"]="2.16.840.1.101.3.4.1.22",e["2.16.840.1.101.3.4.1.42"]="aes256-CBC",e["aes256-CBC"]="2.16.840.1.101.3.4.1.42",e["2.5.4.3"]="commonName",e.commonName="2.5.4.3",e["2.5.4.5"]="serialName",e.serialName="2.5.4.5",e["2.5.4.6"]="countryName",e.countryName="2.5.4.6",e["2.5.4.7"]="localityName",e.localityName="2.5.4.7",e["2.5.4.8"]="stateOrProvinceName",e.stateOrProvinceName="2.5.4.8",e["2.5.4.10"]="organizationName",e.organizationName="2.5.4.10",e["2.5.4.11"]="organizationalUnitName",e.organizationalUnitName="2.5.4.11",e["1.2.840.113549.1.9.1"]="emailAddress",e.emailAddress="1.2.840.113549.1.9.1",e["2.5.29.1"]="authorityKeyIdentifier",e["2.5.29.2"]="keyAttributes",e["2.5.29.3"]="certificatePolicies",e["2.5.29.4"]="keyUsageRestriction",e["2.5.29.5"]="policyMapping",e["2.5.29.6"]="subtreesConstraint",e["2.5.29.7"]="subjectAltName",e["2.5.29.8"]="issuerAltName",e["2.5.29.9"]="subjectDirectoryAttributes",e["2.5.29.10"]="basicConstraints",e["2.5.29.11"]="nameConstraints",e["2.5.29.12"]="policyConstraints",e["2.5.29.13"]="basicConstraints",e["2.5.29.14"]="subjectKeyIdentifier",e.subjectKeyIdentifier="2.5.29.14",e["2.5.29.15"]="keyUsage",e.keyUsage="2.5.29.15",e["2.5.29.16"]="privateKeyUsagePeriod",e["2.5.29.17"]="subjectAltName",e.subjectAltName="2.5.29.17",e["2.5.29.18"]="issuerAltName",e.issuerAltName="2.5.29.18",e["2.5.29.19"]="basicConstraints",e.basicConstraints="2.5.29.19",e["2.5.29.20"]="cRLNumber",e["2.5.29.21"]="cRLReason",e["2.5.29.22"]="expirationDate",e["2.5.29.23"]="instructionCode",e["2.5.29.24"]="invalidityDate",e["2.5.29.25"]="cRLDistributionPoints",e["2.5.29.26"]="issuingDistributionPoint",e["2.5.29.27"]="deltaCRLIndicator",e["2.5.29.28"]="issuingDistributionPoint",e["2.5.29.29"]="certificateIssuer",e["2.5.29.30"]="nameConstraints",e["2.5.29.31"]="cRLDistributionPoints",e["2.5.29.32"]="certificatePolicies",e["2.5.29.33"]="policyMappings",e["2.5.29.34"]="policyConstraints",e["2.5.29.35"]="authorityKeyIdentifier",e["2.5.29.36"]="policyConstraints",e["2.5.29.37"]="extKeyUsage",e.extKeyUsage="2.5.29.37",e["2.5.29.46"]="freshestCRL",e["2.5.29.54"]="inhibitAnyPolicy"
}(),function(){var e=fl,t=e.asn1;e.pki=e.pki||{},e.pki.rsa=e.pki.rsa||{};var r=e.pki,i=function(r){var i;if(!(r.algorithm in e.pki.oids))throw{message:"Unknown message digest algorithm.",algorithm:r.algorithm};i=e.pki.oids[r.algorithm];var n=t.oidToDer(i).getBytes(),s=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);a.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,n)),a.value.push(t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,""));var o=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.digest().getBytes());return s.value.push(a),s.value.push(o),t.toDer(s).getBytes()},n=function(e,t,r){var i;if(r)i=e.modPow(t.e,t.n);else{t.dP||(t.dP=t.d.mod(t.p.subtract(H.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(H.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));for(var n=e.mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);n.compareTo(s)<0;)n=n.add(t.p);i=n.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s)}return i};r.rsa.encrypt=function(t,r,i){var s=i,a=e.util.createBuffer(),o=Math.ceil(r.n.bitLength()/8);if(i!==!1&&i!==!0){if(t.length>o-11)throw{message:"Message is too long to encrypt.",length:t.length,max:o-11};a.putByte(0),a.putByte(i);var c,l=o-3-t.length;if(0===i||1===i){s=!1,c=0===i?0:255;for(var h=0;l>h;++h)a.putByte(c)}else{s=!0;for(var h=0;l>h;++h)c=Math.floor(255*Math.random())+1,a.putByte(c)}a.putByte(0)}a.putBytes(t);for(var u=new H(a.toHex(),16),d=n(u,r,s),f=d.toString(16),p=e.util.createBuffer(),_=o-Math.ceil(f.length/2);_>0;)p.putByte(0),--_;return p.putBytes(e.util.hexToBytes(f)),p.getBytes()},r.rsa.decrypt=function(t,r,i,s){var a=(e.util.createBuffer(),Math.ceil(r.n.bitLength()/8));if(t.length!=a)throw{message:"Encrypted message length is invalid.",length:t.length,expected:a};for(var o=new H(e.util.createBuffer(t).toHex(),16),c=n(o,r,i),l=c.toString(16),h=e.util.createBuffer(),u=a-Math.ceil(l.length/2);u>0;)h.putByte(0),--u;if(h.putBytes(e.util.hexToBytes(l)),s!==!1){var d=h.getByte(),f=h.getByte();if(0!==d||i&&0!==f&&1!==f||!i&&2!=f||i&&0===f&&"undefined"==typeof s)throw{message:"Encryption block is invalid."};var p=0;if(0===f){p=a-3-s;for(var _=0;p>_;++_)if(0!==h.getByte())throw{message:"Encryption block is invalid."}}else if(1===f)for(p=0;h.length()>1;){if(255!==h.getByte()){--h.read;break}++p}else if(2===f)for(p=0;h.length()>1;){if(0===h.getByte()){--h.read;break}++p}var g=h.getByte();if(0!==g||p!==a-3-h.length())throw{message:"Encryption block is invalid."}}return h.getBytes()},r.rsa.createKeyPairGenerationState=function(t,r){"string"==typeof t&&(t=parseInt(t,10)),t=t||1024;var i={nextBytes:function(t){for(var r=(+new Date,e.random.getBytes(t.length)),i=0;i<t.length;++i)t[i]=r.charCodeAt(i);+new Date}},n={state:0,itrs:0,maxItrs:100,bits:t,rng:i,e:new H((r||65537).toString(16),16),p:null,q:null,qBits:t>>1,pBits:t-(t>>1),pqState:0,num:null,six:new H(null),addNext:2,keys:null};return n.six.fromInt(6),n},r.rsa.stepKeyPairGenerationState=function(t,r){for(var i,n=+new Date,s=0;null===t.keys&&(0>=r||r>s);){if(0===t.state){var a=null===t.p?t.pBits:t.qBits,o=a-1;if(0===t.pqState)t.itrs=0,t.num=new H(a,t.rng),t.r=null,t.num.isEven()&&t.num.dAddOffset(1,0),t.num.testBit(o)||t.num.bitwiseTo(H.ONE.shiftLeft(o),function(e,t){return e|t},t.num),++t.pqState;else if(1===t.pqState){if(null===t.addNext){var c=t.num.mod(t.six).byteValue();3===c&&(t.num.mod.dAddOffset(2),c=5),t.addNext=1===c?2:4}var l=t.num.isProbablePrime(1);l?++t.pqState:t.itrs<t.maxItrs?(t.num.dAddOffset(t.addNext,0),t.num.bitLength()>a?(t.addNext=null,t.num.subTo(H.ONE.shiftLeft(o),t.num)):t.addNext=4===t.addNext?2:4,++t.itrs):t.pqState=0}else 2===t.pqState?t.pqState=0===t.num.subtract(H.ONE).gcd(t.e).compareTo(H.ONE)?3:0:3===t.pqState&&(t.pqState=0,t.num.isProbablePrime(10)&&(null===t.p?t.p=t.num:t.q=t.num,null!==t.p&&null!==t.q&&++t.state),t.num=null)}else if(1===t.state)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(2===t.state)t.p1=t.p.subtract(H.ONE),t.q1=t.q.subtract(H.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(3===t.state)0===t.phi.gcd(t.e).compareTo(H.ONE)?++t.state:(t.p=null,t.q=null,t.state=0);else if(4===t.state)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(5===t.state){var h=t.e.modInverse(t.phi);t.keys={privateKey:e.pki.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:e.pki.rsa.setPublicKey(t.n,t.e)}}i=+new Date,s+=i-n,n=i}return null!==t.keys},r.rsa.generateKeyPair=function(e,t){var i=r.rsa.createKeyPairGenerationState(e,t);return r.rsa.stepKeyPairGenerationState(i,0),i.keys},r.rsa.setPublicKey=function(e,i){var n={n:e,e:i};return n.encrypt=function(e){return r.rsa.encrypt(e,n,2)},n.verify=function(e,i,s){var a=void 0===s?void 0:!1,o=r.rsa.decrypt(i,n,!0,a);if(void 0===s){var c=t.fromDer(o);return e===c.value[1].value}return s.verify(e,o,n.n.bitLength())},n},r.rsa.setPrivateKey=function(e,t,n,s,a,o,c,l){var h={n:e,e:t,d:n,p:s,q:a,dP:o,dQ:c,qInv:l};return h.decrypt=function(e){return r.rsa.decrypt(e,h,!1)},h.sign=function(e,t){var n=!1;void 0===t&&(t={encode:i},n=1);var s=t.encode(e,h.n.bitLength());return r.rsa.encrypt(s,h,n)},h}}(),function(){function e(e){function t(t){for(var r,i,n=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=t.attributes,a=0;a<s.length;++a){r=s[a];var c=r.value,l=o.Type.PRINTABLESTRING;"valueTagClass"in r&&(l=r.valueTagClass,l===o.Type.UTF8&&(c=e.util.encodeUtf8(c))),i=o.create(o.Class.UNIVERSAL,o.Type.SET,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(r.type).getBytes()),o.create(o.Class.UNIVERSAL,l,!1,c)])]),n.value.push(i)}return n}function r(e){var t=o.create(o.Class.CONTEXT_SPECIFIC,3,!0,[]),r=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);t.value.push(r);for(var i,n,s=0;s<e.length;++s){i=e[s],n=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),r.value.push(n),n.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(i.id).getBytes())),i.critical&&n.value.push(o.create(o.Class.UNIVERSAL,o.Type.BOOLEAN,!1,String.fromCharCode(255)));var a=i.value;"string"!=typeof i.value&&(a=o.toDer(a).getBytes()),n.value.push(o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,a))}return t}function i(e,t){switch(e){case l["RSASSA-PSS"]:var r=[];return void 0!==t.hash.algorithmOid&&r.push(o.create(o.Class.CONTEXT_SPECIFIC,0,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(t.hash.algorithmOid).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")])])),void 0!==t.mgf.algorithmOid&&r.push(o.create(o.Class.CONTEXT_SPECIFIC,1,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(t.mgf.algorithmOid).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(t.mgf.hash.algorithmOid).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")])])])),void 0!==t.saltLength&&r.push(o.create(o.Class.CONTEXT_SPECIFIC,2,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,String.fromCharCode(t.saltLength))])),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,r);default:return o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")}}function n(t){var r=o.create(o.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===t.attributes.length)return r;for(var i=t.attributes,n=0;n<i.length;++n){var s=i[n],a=s.value,c=o.Type.UTF8;"valueTagClass"in s&&(c=s.valueTagClass),c===o.Type.UTF8&&(a=e.util.encodeUtf8(a));var l=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(s.type).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SET,!0,[o.create(o.Class.UNIVERSAL,c,!1,a)])]);r.value.push(l)}return r}function s(e,t,r){for(var i=[a(e+t)],n=16,s=1;r>n;++s,n+=16)i.push(a(i[s-1]+e+t));return i.join("").substr(0,r)}function a(t){return e.md.md5.create().update(t).digest().getBytes()}"undefined"==typeof H&&(H=e.jsbn.BigInteger);var o=e.asn1,c=e.pki=e.pki||{},l=c.oids;c.pbe={};var h={};h.CN=l.commonName,h.commonName="CN",h.C=l.countryName,h.countryName="C",h.L=l.localityName,h.localityName="L",h.ST=l.stateOrProvinceName,h.stateOrProvinceName="ST",h.O=l.organizationName,h.organizationName="O",h.OU=l.organizationalUnitName,h.organizationalUnitName="OU",h.E=l.emailAddress,h.emailAddress="E";var u={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},d={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},f={name:"Certificate",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:o.Class.UNIVERSAL,type:o.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:o.Class.UNIVERSAL,type:o.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:o.Class.UNIVERSAL,type:o.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:o.Class.UNIVERSAL,type:o.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},u,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:o.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:o.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:o.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certSignature"}]},p={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},_={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},g={name:"EncryptedPrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},m={name:"PBES2Algorithms",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,onstructed:!0,capture:"kdfIterationCount"}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},y={name:"pkcs-12PbeParams",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"iterations"}]},v={name:"rsapss",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:o.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:o.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:o.Class.UNIVERSAL,type:o.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:o.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:o.Class.UNIVERSAL,type:o.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},b={name:"CertificationRequestInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},u,{name:"CertificationRequestInfo.attributes",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:o.Class.UNIVERSAL,type:o.Type.SET,constructed:!0}]}]}]},w={name:"CertificationRequest",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[b,{name:"CertificationRequest.signatureAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"csrSignature"}]};c.RDNAttributesAsArray=function(e,t){for(var r,i,n,s=[],a=0;a<e.value.length;++a){r=e.value[a];for(var c=0;c<r.value.length;++c)n={},i=r.value[c],n.type=o.derToOid(i.value[0].value),n.value=i.value[1].value,n.valueTagClass=i.value[1].type,n.type in l&&(n.name=l[n.type],n.name in h&&(n.shortName=h[n.name])),t&&(t.update(n.type),t.update(n.value)),s.push(n)}return s},c.CRIAttributesAsArray=function(e){for(var t=[],r=0;r<e.length;++r)for(var i=e[r],n=o.derToOid(i.value[0].value),s=i.value[1].value,a=0;a<s.length;++a){var c={};c.type=n,c.value=s[a].value,c.valueTagClass=s[a].type,c.type in l&&(c.name=l[c.type],c.name in h&&(c.shortName=h[c.name])),t.push(c)}return t};var S=function(e,t){"string"==typeof t&&(t={shortName:t});for(var r,i=null,n=0;null===i&&n<e.attributes.length;++n)r=e.attributes[n],t.type&&t.type===r.type?i=r:t.name&&t.name===r.name?i=r:t.shortName&&t.shortName===r.shortName&&(i=r);return i},E=function(t){for(var r,i,n,s=[],a=0;a<t.value.length;++a){n=t.value[a];for(var c=0;c<n.value.length;++c){if(i=n.value[c],r={},r.id=o.derToOid(i.value[0].value),r.critical=!1,i.value[1].type===o.Type.BOOLEAN?(r.critical=0!==i.value[1].value.charCodeAt(0),r.value=i.value[2].value):r.value=i.value[1].value,r.id in l)if(r.name=l[r.id],"keyUsage"===r.name){var h=o.fromDer(r.value),u=0,d=0;h.value.length>1&&(u=h.value.charCodeAt(1),d=h.value.length>2?h.value.charCodeAt(2):0),r.digitalSignature=128===(128&u),r.nonRepudiation=64===(64&u),r.keyEncipherment=32===(32&u),r.dataEncipherment=16===(16&u),r.keyAgreement=8===(8&u),r.keyCertSign=4===(4&u),r.cRLSign=2===(2&u),r.encipherOnly=1===(1&u),r.decipherOnly=128===(128&d)}else if("basicConstraints"===r.name){var h=o.fromDer(r.value);if(r.cA=h.value.length>0?0!==h.value[0].value.charCodeAt(0):!1,h.value.length>1){var f=e.util.createBuffer(h.value[1].value);r.pathLenConstraint=f.getInt(f.length()<<3)}}else if("extKeyUsage"===r.name)for(var h=o.fromDer(r.value),p=0;p<h.value.length;++p){var _=o.derToOid(h.value[p].value);_ in l?r[l[_]]=!0:r[_]=!0}else if("subjectAltName"===r.name||"issuerAltName"===r.name){r.altNames=[];for(var g,h=o.fromDer(r.value),m=0;m<h.value.length;++m){g=h.value[m];var y={type:g.type,value:g.value};switch(r.altNames.push(y),g.type){case 1:case 2:case 6:break;case 7:break;case 8:y.oid=o.derToOid(g.value)}}}s.push(r)}}return s};c.pemToDer=function(t){var r=e.pem.decode(t)[0];if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert PEM to DER; PEM is encrypted."};return e.util.createBuffer(r.body)};var C=function(t){var r=t.toString(16);return r[0]>="8"&&(r="00"+r),e.util.hexToBytes(r)},A=function(e,t,r){var i={};if(e!==l["RSASSA-PSS"])return i;r&&(i={hash:{algorithmOid:l.sha1},mgf:{algorithmOid:l.mgf1,hash:{algorithmOid:l.sha1}},saltLength:20});var n={},s=[];if(!o.validate(t,v,n,s))throw{message:"Cannot read RSASSA-PSS parameter block.",errors:s};return void 0!==n.hashOid&&(i.hash=i.hash||{},i.hash.algorithmOid=o.derToOid(n.hashOid)),void 0!==n.maskGenOid&&(i.mgf=i.mgf||{},i.mgf.algorithmOid=o.derToOid(n.maskGenOid),i.mgf.hash=i.mgf.hash||{},i.mgf.hash.algorithmOid=o.derToOid(n.maskGenHashOid)),void 0!==n.saltLength&&(i.saltLength=n.saltLength.charCodeAt(0)),i};c.certificateFromPem=function(t,r,i){var n=e.pem.decode(t)[0];if("CERTIFICATE"!==n.type&&"X509 CERTIFICATE"!==n.type&&"TRUSTED CERTIFICATE"!==n.type)throw{message:'Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type)throw{message:"Could not convert certificate from PEM; PEM is encrypted."};var s=o.fromDer(n.body,i);return c.certificateFromAsn1(s,r)},c.certificateToPem=function(t,r){var i={type:"CERTIFICATE",body:o.toDer(c.certificateToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.publicKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("PUBLIC KEY"!==r.type&&"RSA PUBLIC KEY"!==r.type)throw{message:'Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert public key from PEM; PEM is encrypted."};var i=o.fromDer(r.body);return c.publicKeyFromAsn1(i)},c.publicKeyToPem=function(t,r){var i={type:"PUBLIC KEY",body:o.toDer(c.publicKeyToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.publicKeyToRSAPublicKeyPem=function(t,r){var i={type:"RSA PUBLIC KEY",body:o.toDer(c.publicKeyToRSAPublicKey(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.privateKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("PRIVATE KEY"!==r.type&&"RSA PRIVATE KEY"!==r.type)throw{message:'Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert private key from PEM; PEM is encrypted."};var i=o.fromDer(r.body);return c.privateKeyFromAsn1(i)},c.privateKeyToPem=function(t,r){var i={type:"RSA PRIVATE KEY",body:o.toDer(c.privateKeyToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.certificationRequestFromPem=function(t,r,i){var n=e.pem.decode(t)[0];if("CERTIFICATE REQUEST"!==n.type)throw{message:'Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type)throw{message:"Could not convert certification request from PEM; PEM is encrypted."};var s=o.fromDer(n.body,i);return c.certificationRequestFromAsn1(s,r)},c.certificationRequestToPem=function(t,r){var i={type:"CERTIFICATE REQUEST",body:o.toDer(c.certificationRequestToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.createCertificate=function(){var t={};t.version=2,t.serialNumber="00",t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.validity={},t.validity.notBefore=new Date,t.validity.notAfter=new Date,t.issuer={},t.issuer.getField=function(e){return S(t.issuer,e)},t.issuer.addField=function(e){r([e]),t.issuer.attributes.push(e)},t.issuer.attributes=[],t.issuer.hash=null,t.subject={},t.subject.getField=function(e){return S(t.subject,e)},t.subject.addField=function(e){r([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.extensions=[],t.publicKey=null,t.md=null;var r=function(e){for(var t,r=0;r<e.length;++r){if(t=e[r],"undefined"==typeof t.name&&(t.type&&t.type in c.oids?t.name=c.oids[t.type]:t.shortName&&t.shortName in h&&(t.name=c.oids[h[t.shortName]])),"undefined"==typeof t.type){if(!(t.name&&t.name in c.oids))throw{message:"Attribute type not specified.",attribute:t};t.type=c.oids[t.name]}if("undefined"==typeof t.shortName&&t.name&&t.name in h&&(t.shortName=h[t.name]),"undefined"==typeof t.value)throw{message:"Attribute value not specified.",attribute:t}}};return t.setSubject=function(e,i){r(e),t.subject.attributes=e,delete t.subject.uniqueId,i&&(t.subject.uniqueId=i),t.subject.hash=null},t.setIssuer=function(e,i){r(e),t.issuer.attributes=e,delete t.issuer.uniqueId,i&&(t.issuer.uniqueId=i),t.issuer.hash=null},t.setExtensions=function(r){for(var i,n=0;n<r.length;++n){if(i=r[n],"undefined"==typeof i.name&&i.id&&i.id in c.oids&&(i.name=c.oids[i.id]),"undefined"==typeof i.id){if(!(i.name&&i.name in c.oids))throw{message:"Extension ID not specified.",extension:i};i.id=c.oids[i.name]}if("undefined"==typeof i.value){if("keyUsage"===i.name){var s=0,a=0,h=0;i.digitalSignature&&(a|=128,s=7),i.nonRepudiation&&(a|=64,s=6),i.keyEncipherment&&(a|=32,s=5),i.dataEncipherment&&(a|=16,s=4),i.keyAgreement&&(a|=8,s=3),i.keyCertSign&&(a|=4,s=2),i.cRLSign&&(a|=2,s=1),i.encipherOnly&&(a|=1,s=0),i.decipherOnly&&(h|=128,s=7);var u=String.fromCharCode(s);0!==h?u+=String.fromCharCode(a)+String.fromCharCode(h):0!==a&&(u+=String.fromCharCode(a)),i.value=o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,u)}else if("basicConstraints"===i.name){if(i.value=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),i.cA&&i.value.value.push(o.create(o.Class.UNIVERSAL,o.Type.BOOLEAN,!1,String.fromCharCode(255))),i.pathLenConstraint){var d=i.pathLenConstraint,f=e.util.createBuffer();f.putInt(d,d.toString(2).length),i.value.value.push(o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,f.getBytes()))}}else if("extKeyUsage"===i.name){i.value=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);var p=i.value.value;for(var _ in i)i[_]===!0&&(_ in l?p.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l[_]).getBytes())):-1!==_.indexOf(".")&&p.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(_).getBytes())))}else if("subjectAltName"===i.name||"issuerAltName"===i.name){i.value=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);for(var g,m=0;m<i.altNames.length;++m){g=i.altNames[m];var u=g.value;8===g.type&&(u=o.oidToDer(u)),i.value.value.push(o.create(o.Class.CONTEXT_SPECIFIC,g.type,!1,u))}}if("undefined"==typeof i.value)throw{message:"Extension value not specified.",extension:i}}}t.extensions=r},t.getExtension=function(e){"string"==typeof e&&(e={name:e});for(var r,i=null,n=0;null===i&&n<t.extensions.length;++n)r=t.extensions[n],e.id&&r.id===e.id?i=r:e.name&&r.name===e.name&&(i=r);return i},t.sign=function(r){t.signatureOid=l.sha1withRSAEncryption,t.siginfo.algorithmOid=l.sha1withRSAEncryption,t.md=e.md.sha1.create(),t.tbsCertificate=c.getTBSCertificate(t);var i=o.toDer(t.tbsCertificate);t.md.update(i.getBytes()),t.signature=r.sign(t.md)},t.verify=function(r){var i=!1,n=r.md;if(null===n){if(r.signatureOid in l){var s=l[r.signatureOid];switch(s){case"sha1withRSAEncryption":n=e.md.sha1.create();break;case"md5withRSAEncryption":n=e.md.md5.create();break;case"sha256WithRSAEncryption":n=e.md.sha256.create();break;case"RSASSA-PSS":n=e.md.sha256.create()}}if(null===n)throw{message:"Could not compute certificate digest. Unknown signature OID.",signatureOid:r.signatureOid};var a=r.tbsCertificate||c.getTBSCertificate(r),h=o.toDer(a);n.update(h.getBytes())}if(null!==n){var u=void 0;switch(r.signatureOid){case l.sha1withRSAEncryption:u=void 0;break;case l["RSASSA-PSS"]:var d,f;if(d=l[r.signatureParameters.mgf.hash.algorithmOid],void 0===d||void 0===e.md[d])throw{message:"Unsupported MGF hash function.",oid:r.signatureParameters.mgf.hash.algorithmOid,name:d};if(f=l[r.signatureParameters.mgf.algorithmOid],void 0===f||void 0===e.mgf[f])throw{message:"Unsupported MGF function.",oid:r.signatureParameters.mgf.algorithmOid,name:f};if(f=e.mgf[f].create(e.md[d].create()),d=l[r.signatureParameters.hash.algorithmOid],void 0===d||void 0===e.md[d])throw{message:"Unsupported RSASSA-PSS hash function.",oid:r.signatureParameters.hash.algorithmOid,name:d};u=e.pss.create(e.md[d].create(),f,r.signatureParameters.saltLength)}i=t.publicKey.verify(n.digest().getBytes(),r.signature,u)}return i},t.isIssuer=function(e){var r=!1,i=t.issuer,n=e.subject;if(i.hash&&n.hash)r=i.hash===n.hash;else if(i.attributes.length===n.attributes.length){r=!0;for(var s,a,o=0;r&&o<i.attributes.length;++o)s=i.attributes[o],a=n.attributes[o],(s.type!==a.type||s.value!==a.value)&&(r=!1)}return r},t},c.certificateFromAsn1=function(t,r){var i={},n=[];if(!o.validate(t,f,i,n))throw{message:"Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.",errors:n};if("string"!=typeof i.certSignature){for(var s="\x00",a=0;a<i.certSignature.length;++a)s+=o.toDer(i.certSignature[a]).getBytes();i.certSignature=s}var h=o.derToOid(i.publicKeyOid);if(h!==c.oids.rsaEncryption)throw{message:"Cannot read public key. OID is not RSA."};var u=c.createCertificate();u.version=i.certVersion?i.certVersion.charCodeAt(0):0;var d=e.util.createBuffer(i.certSerialNumber);u.serialNumber=d.toHex(),u.signatureOid=e.asn1.derToOid(i.certSignatureOid),u.signatureParameters=A(u.signatureOid,i.certSignatureParams,!0),u.siginfo.algorithmOid=e.asn1.derToOid(i.certinfoSignatureOid),u.siginfo.parameters=A(u.siginfo.algorithmOid,i.certinfoSignatureParams,!1);var p=e.util.createBuffer(i.certSignature);++p.read,u.signature=p.getBytes();var _=[];if(void 0!==i.certValidity1UTCTime&&_.push(o.utcTimeToDate(i.certValidity1UTCTime)),void 0!==i.certValidity2GeneralizedTime&&_.push(o.generalizedTimeToDate(i.certValidity2GeneralizedTime)),void 0!==i.certValidity3UTCTime&&_.push(o.utcTimeToDate(i.certValidity3UTCTime)),void 0!==i.certValidity4GeneralizedTime&&_.push(o.generalizedTimeToDate(i.certValidity4GeneralizedTime)),_.length>2)throw{message:"Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate."};
if(_.length<2)throw{message:"Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime."};if(u.validity.notBefore=_[0],u.validity.notAfter=_[1],u.tbsCertificate=i.tbsCertificate,r){if(u.md=null,u.signatureOid in l){var h=l[u.signatureOid];switch(h){case"sha1withRSAEncryption":u.md=e.md.sha1.create();break;case"md5withRSAEncryption":u.md=e.md.md5.create();break;case"sha256WithRSAEncryption":u.md=e.md.sha256.create();break;case"RSASSA-PSS":u.md=e.md.sha256.create()}}if(null===u.md)throw{message:"Could not compute certificate digest. Unknown signature OID.",signatureOid:u.signatureOid};var g=o.toDer(u.tbsCertificate);u.md.update(g.getBytes())}var m=e.md.sha1.create();u.issuer.getField=function(e){return S(u.issuer,e)},u.issuer.addField=function(e){_fillMissingFields([e]),u.issuer.attributes.push(e)},u.issuer.attributes=c.RDNAttributesAsArray(i.certIssuer,m),i.certIssuerUniqueId&&(u.issuer.uniqueId=i.certIssuerUniqueId),u.issuer.hash=m.digest().toHex();var y=e.md.sha1.create();return u.subject.getField=function(e){return S(u.subject,e)},u.subject.addField=function(e){_fillMissingFields([e]),u.subject.attributes.push(e)},u.subject.attributes=c.RDNAttributesAsArray(i.certSubject,y),i.certSubjectUniqueId&&(u.subject.uniqueId=i.certSubjectUniqueId),u.subject.hash=y.digest().toHex(),u.extensions=i.certExtensions?E(i.certExtensions):[],u.publicKey=c.publicKeyFromAsn1(i.subjectPublicKeyInfo),u},c.certificationRequestFromAsn1=function(t,r){var i={},n=[];if(!o.validate(t,w,i,n))throw{message:"Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.",errors:n};if("string"!=typeof i.csrSignature){for(var s="\x00",a=0;a<i.csrSignature.length;++a)s+=o.toDer(i.csrSignature[a]).getBytes();i.csrSignature=s}var h=o.derToOid(i.publicKeyOid);if(h!==c.oids.rsaEncryption)throw{message:"Cannot read public key. OID is not RSA."};var u=c.createCertificationRequest();u.version=i.csrVersion?i.csrVersion.charCodeAt(0):0,u.signatureOid=e.asn1.derToOid(i.csrSignatureOid),u.signatureParameters=A(u.signatureOid,i.csrSignatureParams,!0),u.siginfo.algorithmOid=e.asn1.derToOid(i.csrSignatureOid),u.siginfo.parameters=A(u.siginfo.algorithmOid,i.csrSignatureParams,!1);var d=e.util.createBuffer(i.csrSignature);if(++d.read,u.signature=d.getBytes(),u.certificationRequestInfo=i.certificationRequestInfo,r){if(u.md=null,u.signatureOid in l){var h=l[u.signatureOid];switch(h){case"sha1withRSAEncryption":u.md=e.md.sha1.create();break;case"md5withRSAEncryption":u.md=e.md.md5.create();break;case"sha256WithRSAEncryption":u.md=e.md.sha256.create();break;case"RSASSA-PSS":u.md=e.md.sha256.create()}}if(null===u.md)throw{message:"Could not compute certification request digest. Unknown signature OID.",signatureOid:u.signatureOid};var f=o.toDer(u.certificationRequestInfo);u.md.update(f.getBytes())}var p=e.md.sha1.create();return u.subject.getField=function(e){return S(u.subject,e)},u.subject.addField=function(e){_fillMissingFields([e]),u.subject.attributes.push(e)},u.subject.attributes=c.RDNAttributesAsArray(i.certificationRequestInfoSubject,p),u.subject.hash=p.digest().toHex(),u.publicKey=c.publicKeyFromAsn1(i.subjectPublicKeyInfo),u.getAttribute=function(e){return S(u.attributes,e)},u.addAttribute=function(e){_fillMissingFields([e]),u.attributes.push(e)},u.attributes=c.CRIAttributesAsArray(i.certificationRequestInfoAttributes),u},c.createCertificationRequest=function(){var t={};t.version=0,t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.subject={},t.subject.getField=function(e){return S(t.subject,e)},t.subject.addField=function(e){r([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.publicKey=null,t.attributes=[],t.getAttribute=function(e){return S(t.attributes,e)},t.addAttribute=function(e){r([e]),t.attributes.push(e)},t.md=null;var r=function(e){for(var t,r=0;r<e.length;++r){if(t=e[r],"undefined"==typeof t.name&&(t.type&&t.type in c.oids?t.name=c.oids[t.type]:t.shortName&&t.shortName in h&&(t.name=c.oids[h[t.shortName]])),"undefined"==typeof t.type){if(!(t.name&&t.name in c.oids))throw{message:"Attribute type not specified.",attribute:t};t.type=c.oids[t.name]}if("undefined"==typeof t.shortName&&t.name&&t.name in h&&(t.shortName=h[t.name]),"undefined"==typeof t.value)throw{message:"Attribute value not specified.",attribute:t}}};return t.setSubject=function(e){r(e),t.subject.attributes=e,t.subject.hash=null},t.setAttributes=function(e){r(e),t.attributes=e},t.sign=function(r){t.signatureOid=l.sha1withRSAEncryption,t.siginfo.algorithmOid=l.sha1withRSAEncryption,t.md=e.md.sha1.create(),t.certificationRequestInfo=c.getCertificationRequestInfo(t);var i=o.toDer(t.certificationRequestInfo);t.md.update(i.getBytes()),t.signature=r.sign(t.md)},t.verify=function(){var r=!1,i=t.md;if(null===i){if(t.signatureOid in l){var n=l[t.signatureOid];switch(n){case"sha1withRSAEncryption":i=e.md.sha1.create();break;case"md5withRSAEncryption":i=e.md.md5.create();break;case"sha256WithRSAEncryption":i=e.md.sha256.create();break;case"RSASSA-PSS":i=e.md.sha256.create()}}if(null===i)throw{message:"Could not compute certification request digest. Unknown signature OID.",signatureOid:t.signatureOid};var s=t.certificationRequestInfo||c.getCertificationRequestInfo(t),a=o.toDer(s);i.update(a.getBytes())}if(null!==i){var h=void 0;switch(t.signatureOid){case l.sha1withRSAEncryption:h=void 0;break;case l["RSASSA-PSS"]:var u,d;if(u=l[t.signatureParameters.mgf.hash.algorithmOid],void 0===u||void 0===e.md[u])throw{message:"Unsupported MGF hash function.",oid:t.signatureParameters.mgf.hash.algorithmOid,name:u};if(d=l[t.signatureParameters.mgf.algorithmOid],void 0===d||void 0===e.mgf[d])throw{message:"Unsupported MGF function.",oid:t.signatureParameters.mgf.algorithmOid,name:d};if(d=e.mgf[d].create(e.md[u].create()),u=l[t.signatureParameters.hash.algorithmOid],void 0===u||void 0===e.md[u])throw{message:"Unsupported RSASSA-PSS hash function.",oid:t.signatureParameters.hash.algorithmOid,name:u};h=e.pss.create(e.md[u].create(),d,t.signatureParameters.saltLength)}r=t.publicKey.verify(i.digest().getBytes(),t.signature,h)}return r},t},c.getTBSCertificate=function(n){var s=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.CONTEXT_SPECIFIC,0,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,String.fromCharCode(n.version))]),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,e.util.hexToBytes(n.serialNumber)),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(n.siginfo.algorithmOid).getBytes()),i(n.siginfo.algorithmOid,n.siginfo.parameters)]),t(n.issuer),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.UTCTIME,!1,o.dateToUtcTime(n.validity.notBefore)),o.create(o.Class.UNIVERSAL,o.Type.UTCTIME,!1,o.dateToUtcTime(n.validity.notAfter))]),t(n.subject),c.publicKeyToAsn1(n.publicKey)]);return n.issuer.uniqueId&&s.value.push(o.create(o.Class.CONTEXT_SPECIFIC,1,!0,[o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,String.fromCharCode(0)+n.issuer.uniqueId)])),n.subject.uniqueId&&s.value.push(o.create(o.Class.CONTEXT_SPECIFIC,2,!0,[o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,String.fromCharCode(0)+n.subject.uniqueId)])),n.extensions.length>0&&s.value.push(r(n.extensions)),s},c.getCertificationRequestInfo=function(e){var r=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,String.fromCharCode(e.version)),t(e.subject),c.publicKeyToAsn1(e.publicKey),n(e)]);return r},c.distinguishedNameToAsn1=function(e){return t(e)},c.certificateToAsn1=function(e){var t=e.tbsCertificate||c.getTBSCertificate(e);return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[t,o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(e.signatureOid).getBytes()),i(e.signatureOid,e.signatureParameters)]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},c.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||c.getCertificationRequestInfo(e);return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[t,o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(e.signatureOid).getBytes()),i(e.signatureOid,e.signatureParameters)]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},c.createCaStore=function(r){var i={certs:{}};if(i.getIssuer=function(r){var n=null;if(!r.issuer.hash){var s=e.md.sha1.create();r.issuer.attributes=c.RDNAttributesAsArray(t(r.issuer),s),r.issuer.hash=s.digest().toHex()}if(r.issuer.hash in i.certs&&(n=i.certs[r.issuer.hash],e.util.isArray(n)))throw{message:"Resolving multiple issuer matches not implemented yet."};return n},i.addCertificate=function(r){if("string"==typeof r&&(r=e.pki.certificateFromPem(r)),!r.subject.hash){var n=e.md.sha1.create();r.subject.attributes=c.RDNAttributesAsArray(t(r.subject),n),r.subject.hash=n.digest().toHex()}if(r.subject.hash in i.certs){var s=i.certs[r.subject.hash];e.util.isArray(s)||(s=[s]),s.push(r)}else i.certs[r.subject.hash]=r},r)for(var n=0;n<r.length;++n){var s=r[n];i.addCertificate(s)}return i},c.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"},c.verifyCertificateChain=function(t,r,i){r=r.slice(0);var n=r.slice(0),s=new Date,a=!0,o=null,l=0,h=null;do{var u=r.shift();if(s<u.validity.notBefore||s>u.validity.notAfter)o={message:"Certificate is not valid yet or has expired.",error:c.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:s};else{var d=!1;if(r.length>0){h=r[0];try{d=h.verify(u)}catch(f){}}else{var p=t.getIssuer(u);if(null===p)o={message:"Certificate is not trusted.",error:c.certificateError.unknown_ca};else for(e.util.isArray(p)||(p=[p]);!d&&p.length>0;){h=p.shift();try{d=h.verify(u)}catch(f){}}}null!==o||d||(o={message:"Certificate signature is invalid.",error:c.certificateError.bad_certificate})}if(null!==o||u.isIssuer(h)||(o={message:"Certificate issuer is invalid.",error:c.certificateError.bad_certificate}),null===o)for(var _={keyUsage:!0,basicConstraints:!0},g=0;null===o&&g<u.extensions.length;++g){var m=u.extensions[g];!m.critical||m.name in _||(o={message:"Certificate has an unsupported critical extension.",error:c.certificateError.unsupported_certificate})}if(!a||0===r.length&&!h){var y=u.getExtension("basicConstraints"),v=u.getExtension("keyUsage");null!==v&&(v.keyCertSign&&null!==y||(o={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:c.certificateError.bad_certificate})),null!==o||null===y||y.cA||(o={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:c.certificateError.bad_certificate})}var b=null===o?!0:o.error,w=i?i(b,l,n):b;if(w!==!0)throw b===!0&&(o={message:"The application rejected the certificate.",error:c.certificateError.bad_certificate}),(w||0===w)&&("object"!=typeof w||e.util.isArray(w)?"string"==typeof w&&(o.error=w):(w.message&&(o.message=w.message),w.error&&(o.error=w.error))),o;o=null,a=!1,++l}while(r.length>0);return!0},c.publicKeyFromAsn1=function(t){var r={},i=[];if(o.validate(t,u,r,i)){var n=o.derToOid(r.publicKeyOid);if(n!==c.oids.rsaEncryption)throw{message:"Cannot read public key. Unknown OID.",oid:n};t=r.rsaPublicKey}if(i=[],!o.validate(t,d,r,i))throw{message:"Cannot read public key. ASN.1 object does not contain an RSAPublicKey.",errors:i};var s=e.util.createBuffer(r.publicKeyModulus).toHex(),a=e.util.createBuffer(r.publicKeyExponent).toHex();return c.setRsaPublicKey(new H(s,16),new H(a,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.e))])},c.privateKeyFromAsn1=function(t){var r={},i=[];if(o.validate(t,p,r,i)&&(t=o.fromDer(e.util.createBuffer(r.privateKey))),r={},i=[],!o.validate(t,_,r,i))throw{message:"Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.",errors:i};var n,s,a,l,h,u,d,f;return n=e.util.createBuffer(r.privateKeyModulus).toHex(),s=e.util.createBuffer(r.privateKeyPublicExponent).toHex(),a=e.util.createBuffer(r.privateKeyPrivateExponent).toHex(),l=e.util.createBuffer(r.privateKeyPrime1).toHex(),h=e.util.createBuffer(r.privateKeyPrime2).toHex(),u=e.util.createBuffer(r.privateKeyExponent1).toHex(),d=e.util.createBuffer(r.privateKeyExponent2).toHex(),f=e.util.createBuffer(r.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new H(n,16),new H(s,16),new H(a,16),new H(l,16),new H(h,16),new H(u,16),new H(d,16),new H(f,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,String.fromCharCode(0)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,C(e.qInv))])},c.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,"\x00"),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},c.encryptPrivateKeyInfo=function(t,r,i){i=i||{},i.saltSize=i.saltSize||8,i.count=i.count||2048,i.algorithm=i.algorithm||"aes128";var n=e.random.getBytes(i.saltSize),s=i.count,a=e.util.createBuffer();a.putInt16(s);var c,h,u;if(0===i.algorithm.indexOf("aes")){var d;if("aes128"===i.algorithm)c=16,d=l["aes128-CBC"];else if("aes192"===i.algorithm)c=24,d=l["aes192-CBC"];else{if("aes256"!==i.algorithm)throw{message:"Cannot encrypt private key. Unknown encryption algorithm.",algorithm:i.algorithm};c=32,d=l["aes256-CBC"]}var f=e.pkcs5.pbkdf2(r,n,s,c),p=e.random.getBytes(16),_=e.aes.createEncryptionCipher(f);_.start(p),_.update(o.toDer(t)),_.finish(),u=_.output.getBytes(),h=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.pkcs5PBES2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.pkcs5PBKDF2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,n),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,a.getBytes())])]),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(d).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,p)])])])}else{if("3des"!==i.algorithm)throw{message:"Cannot encrypt private key. Unknown encryption algorithm.",algorithm:i.algorithm};c=24;var g=new e.util.ByteBuffer(n),f=e.pkcs12.generateKey(r,g,1,s,c),p=e.pkcs12.generateKey(r,g,2,s,c),_=e.des.createEncryptionCipher(f);_.start(p),_.update(o.toDer(t)),_.finish(),u=_.output.getBytes(),h=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,n),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,a.getBytes())])])}var m=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[h,o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,u)]);return m},c.pbe.getCipherForPBES2=function(t,r,i){var n={},s=[];if(!o.validate(r,m,n,s))throw{message:"Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};if(t=o.derToOid(n.kdfOid),t!==c.oids.pkcs5PBKDF2)throw{message:"Cannot read encrypted private key. Unsupported key derivation function OID.",oid:t,supportedOids:["pkcs5PBKDF2"]};if(t=o.derToOid(n.encOid),t!==c.oids["aes128-CBC"]&&t!==c.oids["aes192-CBC"]&&t!==c.oids["aes256-CBC"])throw{message:"Cannot read encrypted private key. Unsupported encryption scheme OID.",oid:t,supportedOids:["aes128-CBC","aes192-CBC","aes256-CBC"]};var a=n.kdfSalt,l=e.util.createBuffer(n.kdfIterationCount);l=l.getInt(l.length()<<3);var h;t===c.oids["aes128-CBC"]?h=16:t===c.oids["aes192-CBC"]?h=24:t===c.oids["aes256-CBC"]&&(h=32);var u=e.pkcs5.pbkdf2(i,a,l,h),d=n.encIv,f=e.aes.createDecryptionCipher(u);return f.start(d),f},c.pbe.getCipherForPKCS12PBE=function(t,r,i){var n={},s=[];if(!o.validate(r,y,n,s))throw{message:"Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};var a=e.util.createBuffer(n.salt),l=e.util.createBuffer(n.iterations);l=l.getInt(l.length()<<3);var h,u,d;switch(t){case c.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:h=24,u=8,d=e.des.startDecrypting;break;case c.oids["pbewithSHAAnd40BitRC2-CBC"]:h=5,u=8,d=function(t,r){var i=e.rc2.createDecryptionCipher(t,40);return i.start(r,null),i};break;default:throw{message:"Cannot read PKCS #12 PBE data block. Unsupported OID.",oid:t}}var f=e.pkcs12.generateKey(i,a,1,l,h),p=e.pkcs12.generateKey(i,a,2,l,u);return d(f,p)},c.pbe.getCipher=function(e,t,r){switch(e){case c.oids.pkcs5PBES2:return c.pbe.getCipherForPBES2(e,t,r);case c.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case c.oids["pbewithSHAAnd40BitRC2-CBC"]:return c.pbe.getCipherForPKCS12PBE(e,t,r);default:throw{message:"Cannot read encrypted PBE data block. Unsupported OID.",oid:e,supportedOids:["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"]}}},c.decryptPrivateKeyInfo=function(t,r){var i=null,n={},s=[];if(!o.validate(t,g,n,s))throw{message:"Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};var a=o.derToOid(n.encryptionOid),l=c.pbe.getCipher(a,n.encryptionParams,r),h=e.util.createBuffer(n.encryptedData);return l.update(h),l.finish()&&(i=o.fromDer(l.output)),i},c.encryptedPrivateKeyToPem=function(t,r){var i={type:"ENCRYPTED PRIVATE KEY",body:o.toDer(t).getBytes()};return e.pem.encode(i,{maxline:r})},c.encryptedPrivateKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("ENCRYPTED PRIVATE KEY"!==r.type)throw{message:'Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert encrypted private key from PEM; PEM is encrypted."};return o.fromDer(r.body)},c.encryptRsaPrivateKey=function(t,r,i){if(i=i||{},!i.legacy){var n=c.wrapRsaPrivateKey(c.privateKeyToAsn1(t));return n=c.encryptPrivateKeyInfo(n,r,i),c.encryptedPrivateKeyToPem(n)}var a,l,h,u;switch(i.algorithm){case"aes128":a="AES-128-CBC",h=16,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",h=24,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",h=32,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",h=24,l=e.random.getBytes(8),u=e.des.createEncryptionCipher;break;default:throw{message:'Could not encrypt RSA private key; unsupported encryption algorithm "'+i.algorithm+'".',algorithm:i.algorithm}}var d=s(r,l.substr(0,8),h),f=u(d);f.start(l),f.update(o.toDer(c.privateKeyToAsn1(t))),f.finish();var p={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:e.util.bytesToHex(l).toUpperCase()},body:f.output.getBytes()};return e.pem.encode(p)},c.decryptRsaPrivateKey=function(t,r){var i=null,n=e.pem.decode(t)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw{message:'Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type){var a,l;switch(n.dekInfo.algorithm){case"DES-EDE3-CBC":a=24,l=e.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,l=e.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,l=e.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,l=e.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,l=function(t){return e.rc2.createDecryptionCipher(t,40)};break;case"RC2-64-CBC":a=8,l=function(t){return e.rc2.createDecryptionCipher(t,64)};break;case"RC2-128-CBC":a=16,l=function(t){return e.rc2.createDecryptionCipher(t,128)};break;default:throw{message:'Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".',algorithm:n.dekInfo.algorithm}}var h=e.util.hexToBytes(n.dekInfo.parameters),u=s(r,h.substr(0,8),a),d=l(u);if(d.start(h),d.update(e.util.createBuffer(n.body)),!d.finish())return i;i=d.output.getBytes()}else i=n.body;return i="ENCRYPTED PRIVATE KEY"===n.type?c.decryptPrivateKeyInfo(o.fromDer(i),r):o.fromDer(i),null!==i&&(i=c.privateKeyFromAsn1(i)),i},c.setRsaPublicKey=c.rsa.setPublicKey,c.setRsaPrivateKey=c.rsa.setPrivateKey}var t="pki",r=["./aes","./asn1","./des","./jsbn","./md","./mgf","./oids","./pem","./pbkdf2","./pkcs12","./pss","./random","./rc2","./rsa","./util"],i=null;if("function"!=typeof define)return void e(fl);var n=["require","module"].concat(r),s=function(i,n){n.exports=function(n){var s=r.map(function(e){return i(e)}).concat(e);if(n=n||{},n.defined=n.defined||{},n.defined[t])return n[t];n.defined[t]=!0;for(var a=0;a<s.length;++a)s[a](n);return n[t]}};i?i(n,s):"function"==typeof define&&define([].concat(n),function(){s.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){function e(e){function t(e){for(var t=e.name+": ",r=[],i=0;i<e.values.length;++i)r.push(e.values[i].replace(/^(\S+\r\n)/,function(e,t){return" "+t}));t+=r.join(",")+"\r\n";for(var n=0,s=-1,i=0;i<t.length;++i,++n){if(n>65&&-1!==s){var a=t[s];","===a&&(++s,a=" "),t=t.substr(0,s)+"\r\n"+a+t.substr(s+1),n=i-s-1,s=-1,++i}(" "===t[i]||"	"===t[i]||","===t[i])&&(s=i)}return t}function r(e){return e.replace(/^\s+/,"")}var i=e.pem=e.pem||{};i.encode=function(r,i){i=i||{};var n,s="-----BEGIN "+r.type+"-----\r\n";if(r.procType&&(n={name:"Proc-Type",values:[String(r.procType.version),r.procType.type]},s+=t(n)),r.contentDomain&&(n={name:"Content-Domain",values:[r.contentDomain]},s+=t(n)),r.dekInfo&&(n={name:"DEK-Info",values:[r.dekInfo.algorithm]},r.dekInfo.parameters&&n.values.push(r.dekInfo.parameters),s+=t(n)),r.headers)for(var a=0;a<r.headers.length;++a)s+=t(r.headers[a]);return r.procType&&(s+="\r\n"),s+=e.util.encode64(r.body,i.maxline||64)+"\r\n",s+="-----END "+r.type+"-----\r\n"},i.decode=function(t){for(var i,n=[],s=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,a=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,o=/\r?\n/;;){if(i=s.exec(t),!i)break;var c={type:i[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:e.util.decode64(i[3])};if(n.push(c),i[2]){for(var l=i[2].split(o),h=0;i&&h<l.length;){for(var u=l[h].replace(/\s+$/,""),d=h+1;d<l.length;++d){var f=l[d];if(!/\s/.test(f[0]))break;u+=f,h=d}if(i=u.match(a)){for(var p={name:i[1],values:[]},_=i[2].split(","),g=0;g<_.length;++g)p.values.push(r(_[g]));if(c.procType)if(c.contentDomain||"Content-Domain"!==p.name)if(c.dekInfo||"DEK-Info"!==p.name)c.headers.push(p);else{if(0===p.values.length)throw{message:'Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.'};c.dekInfo={algorithm:_[0],parameters:_[1]||null}}else c.contentDomain=_[0]||"";else{if("Proc-Type"!==p.name)throw{message:'Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".'};if(2!==p.values.length)throw{message:'Invalid PEM formatted message. The "Proc-Type" header must have two subfields.'};c.procType={version:_[0],type:_[1]}}}++h}if("ENCRYPTED"===c.procType&&!c.dekInfo)throw{message:'Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".'}}}if(0===n.length)throw{message:"Invalid PEM formatted message."};return n}}var t="pem",r=["./util"],i=null;if("function"!=typeof define)return void e(fl);var n=["require","module"].concat(r),s=function(i,n){n.exports=function(n){var s=r.map(function(e){return i(e)}).concat(e);if(n=n||{},n.defined=n.defined||{},n.defined[t])return n[t];n.defined[t]=!0;for(var a=0;a<s.length;++a)s[a](n);return n[t]}};i?i(n,s):"function"==typeof define&&define([].concat(n),function(){s.apply(null,Array.prototype.slice.call(arguments,0))})}(),function(){var e=fl;e.tls={};var t=function(t,r,i,n){var s=e.util.createBuffer(),a=t.length>>1,o=a+(1&t.length),c=t.substr(0,o),l=t.substr(a,o),h=e.util.createBuffer(),u=e.hmac.create();i=r+i;var d=Math.ceil(n/16),f=Math.ceil(n/20);u.start("MD5",c);var p=e.util.createBuffer();h.putBytes(i);for(var _=0;d>_;++_){{(new Date).valueOf()}u.start(null,null),u.update(h.getBytes()),h.putBuffer(u.digest()),u.start(null,null),u.update(h.bytes()+i),p.putBuffer(u.digest())}u.start("SHA1",l);var g=e.util.createBuffer();h.clear(),h.putBytes(i);for(var _=0;f>_;++_)u.start(null,null),u.update(h.getBytes()),h.putBuffer(u.digest()),u.start(null,null),u.update(h.bytes()+i),g.putBuffer(u.digest());return s.putBytes(e.util.xorBytes(p.getBytes(),g.getBytes(),n)),s},r=function(t,r,i){var n=e.hmac.create();n.start("SHA1",t);var s=e.util.createBuffer();s.putInt32(r[0]),s.putInt32(r[1]),s.putByte(i.type),s.putByte(i.version.major),s.putByte(i.version.minor),s.putInt16(i.length),s.putBytes(i.fragment.bytes());var a=s.getBytes();n.update(a);var o=n.digest().getBytes();return o},i=function(t,r){var i=!1;try{var n=t.deflate(r.fragment.getBytes());r.fragment=e.util.createBuffer(n),r.length=n.length,i=!0}catch(s){}return i},n=function(t,r){var i=!1;try{var n=t.inflate(r.fragment.getBytes());r.fragment=e.util.createBuffer(n),r.length=n.length,i=!0}catch(s){}return i},s=function(e,t){var r=!1,i=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(i),t.updateSequenceNumber();var n=t.cipherState.init?null:t.cipherState.iv;t.cipherState.init=!0;var s=t.cipherState.cipher;return s.start(n),s.update(e.fragment),s.finish(a)&&(e.fragment=s.output,e.length=e.fragment.length(),r=!0),r},a=function(e,t,r){if(!r){var i=t.length()==e?e-1:e-t.length()-1;t.fillWithByte(i,i+1)}return!0},o=function(e,t,r){var i=!0;if(r){for(var n=t.length(),s=t.last(),a=n-1-s;n-1>a;++a)i=i&&t.at(a)==s;i&&t.truncate(s+1)}return i},c=function(t,r){var i=!1,n=r.cipherState.init?null:r.cipherState.iv;r.cipherState.init=!0;var s=r.cipherState.cipher;s.start(n),s.update(t.fragment),i=s.finish(o);for(var a=r.macLength,c="",l=0;a>l;++l)c+=String.fromCharCode(0);var h=s.output.length();h>=a?(t.fragment=s.output.getBytes(h-a),c=s.output.getBytes(a)):t.fragment=s.output.getBytes(),t.fragment=e.util.createBuffer(t.fragment),t.length=t.fragment.length();var u=r.macFunction(r.macKey,r.sequenceNumber,t);return r.updateSequenceNumber(),i=u===c&&i},l=function(t,r){var i=0;switch(r){case 1:i=t.getByte();break;case 2:i=t.getInt16();break;case 3:i=t.getInt24();break;case 4:i=t.getInt32()}return e.util.createBuffer(t.getBytes(i))},h=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},u={};u.Version={major:3,minor:1},u.MaxFragment=15360,u.ConnectionEnd={server:0,client:1},u.PRFAlgorithm={tls_prf_sha256:0},u.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},u.CipherType={stream:0,block:1,aead:2},u.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},u.CompressionMethod={none:0,deflate:1},u.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23},u.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},u.Alert={},u.Alert.Level={warning:1,fatal:2},u.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},u.CipherSuites={TLS_RSA_WITH_AES_128_CBC_SHA:[0,47],TLS_RSA_WITH_AES_256_CBC_SHA:[0,53],TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:[192,10],TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:[192,20],TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA:[0,136],TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA:[0,135],TLS_DHE_RSA_WITH_AES_256_CBC_SHA:[0,57],TLS_DHE_DSS_WITH_AES_256_CBC_SHA:[0,56],TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:[192,15],TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:[192,5],TLS_RSA_WITH_CAMELLIA_256_CBC_SHA:[0,132],TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:[192,7],TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:[192,9],TLS_ECDHE_RSA_WITH_RC4_128_SHA:[192,17],TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:[192,19],TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA:[0,69],TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA:[0,68],TLS_DHE_RSA_WITH_AES_128_CBC_SHA:[0,51],TLS_DHE_DSS_WITH_AES_128_CBC_SHA:[0,50],TLS_ECDH_RSA_WITH_RC4_128_SHA:[192,12],TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:[192,14],TLS_ECDH_ECDSA_WITH_RC4_128_SHA:[192,2],TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:[192,4],TLS_RSA_WITH_SEED_CBC_SHA:[0,150],TLS_RSA_WITH_CAMELLIA_128_CBC_SHA:[0,65],TLS_RSA_WITH_RC4_128_MD5:[0,4],TLS_RSA_WITH_RC4_128_SHA:[0,5],TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:[192,8],TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:[192,18],TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:[0,22],TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:[0,19],TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:[192,13],TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:[192,3],SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA:[254,255],TLS_RSA_WITH_3DES_EDE_CBC_SHA:[0,10]};var d=function(e,t,r){if(r>0){var i=t.fragment,n=e.session.sp.DHE={};n.prime=i.getBytes(i.getInt(16)),n.g=i.getBytes(i.getInt(16)),n.server_public_key=i.getBytes(i.getInt(16)),n.signature=i.getBytes(i.getInt(16))}e.expect=m,e.process()},f=function(t){var r,i=t.session.sp;if(i.DHE){var n=i.DHE,s=new H(ac(128).toString("hex"),16),a=new H(new ii(n.prime,"binary").toString("hex"),16),o=new H(new ii(n.g,"binary").toString("hex"),16),c=new H(new ii(n.server_public_key,"binary").toString("hex"),16),l=new ii(c.modPow(s,a).toString(16),"hex");i.pre_master_secret=l.toString("binary"),r=js?new ii(o.modPow(s,a).toString(16),"hex").toString("binary"):new ii(o.modPow(s,a).toString(16),"hex")}else{r=e.util.createBuffer(),r.putByte(u.Version.major),r.putByte(u.Version.minor),r.putBytes(e.random.getBytes(46)),i.pre_master_secret=r.getBytes();var h=t.session.serverCertificate.publicKey;r=h.encrypt(i.pre_master_secret)}var d=r.length+2,f=e.util.createBuffer();return f.putByte(u.HandshakeType.client_key_exchange),f.putInt24(d),f.putInt16(r.length),f.putBytes(r),f};u.getCipherSuite=function(e){var t=null;for(var r in u.CipherSuites){var i=u.CipherSuites[r];if(i[0]===e.charCodeAt(0)&&i[1]===e.charCodeAt(1)){t=i;break}}return t},u.handleUnexpected=function(e){var t=!e.open&&e.entity===u.ConnectionEnd.client;console.log("unexpected message ----------------"),t=!0,t||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.unexpected_message}})
},u.handleHelloRequest=function(e){!e.handshaking&&e.handshakes>0&&(u.queue(e,u.createAlert({level:u.Alert.Level.warning,description:u.Alert.Description.no_renegotiation})),u.flush(e)),e.process()},u.parseHelloMessage=function(t,r,i){var n=null,s=t.entity==u.ConnectionEnd.client;if(38>i)t.error(t,{message:s?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});else{var a=r.fragment;if(n={version:{major:a.getByte(),minor:a.getByte()},random:e.util.createBuffer(a.getBytes(32)),session_id:l(a,1),extensions:[]},s?(n.cipher_suite=a.getBytes(2),n.compression_method=a.getByte()):(n.cipher_suites=l(a,2),n.compression_methods=l(a,1)),a.length()>0){for(var o=l(a,2);o.length()>0;)n.extensions.push({type:[o.getByte(),o.getByte()],data:l(o,2)});if(!s)for(var c=0;c<n.extensions.length;++c){var h=n.extensions[c];if(0===h.type[0]&&0===h.type[1])for(var d=l(h.data,2);d.length()>0;){var f=d.getByte();if(0!==f)break;t.session.serverNameList.push(l(d,2).getBytes())}}}if(s)t.session.cipherSuite=u.getCipherSuite(n.cipher_suite);else for(var p=e.util.createBuffer(n.cipher_suites.bytes());p.length()>0&&(t.session.cipherSuite=u.getCipherSuite(p.getBytes(2)),null===t.session.cipherSuite););null===t.session.cipherSuite&&t.error(t,{message:"No cipher suites in common.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.handshake_failure},cipherSuite:e.util.bytesToHex(n.cipher_suite)}),t.session.compressionMethod=s?n.compression_method:u.CompressionMethod.none}return n},u.createSecurityParameters=function(e,t){var r;switch(e.session.cipherSuite){case u.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA:r=16;break;case u.CipherSuites.TLS_DHE_RSA_WITH_AES_128_CBC_SHA:r=16;break;case u.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA:r=32;break;case u.CipherSuites.TLS_DHE_RSA_WITH_AES_256_CBC_SHA:r=32}var i=e.entity===u.ConnectionEnd.client,n=t.random.bytes(),s=i?e.session.sp.client_random:n,a=i?n:u.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:u.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:u.BulkCipherAlgorithm.aes,cipher_type:u.CipherType.block,enc_key_length:r,block_length:16,fixed_iv_length:16,record_iv_length:16,mac_algorithm:u.MACAlgorithm.hmac_sha1,mac_length:20,mac_key_length:20,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:s,server_random:a}},u.handleServerHello=function(e,t,r){var i=u.parseHelloMessage(e,t,r);if(!e.fail){var n=i.session_id.bytes();n&&n===e.session.id?(e.expect=v,e.session.resuming=!0,e.session.sp.server_random=i.random.bytes()):(e.expect=_,e.session.resuming=!1,u.createSecurityParameters(e,i)),e.session.id=n,e.process()}},u.handleClientHello=function(t,r,i){var n=u.parseHelloMessage(t,r,i);if(!t.fail){var s=n.session_id.bytes(),a=null;t.sessionCache&&(a=t.sessionCache.getSession(s),null===a&&(s="")),0===s.length&&(s=e.random.getBytes(32)),t.session.id=s,t.session.clientHelloVersion=n.version,t.session.sp=a?a.sp:{},null!==a?(t.expect=T,t.session.resuming=!0,t.session.sp.client_random=n.random.bytes()):(t.expect=t.verifyClient!==!1?C:A,t.session.resuming=!1,u.createSecurityParameters(t,n)),t.open=!0,u.queue(t,u.createRecord({type:u.ContentType.handshake,data:u.createServerHello(t)})),t.session.resuming?(u.queue(t,u.createRecord({type:u.ContentType.change_cipher_spec,data:u.createChangeCipherSpec()})),t.state.pending=u.createConnectionState(t),t.state.current.write=t.state.pending.write,u.queue(t,u.createRecord({type:u.ContentType.handshake,data:u.createFinished(t)}))):(u.queue(t,u.createRecord({type:u.ContentType.handshake,data:u.createCertificate(t)})),t.verifyClient!==!1&&u.queue(t,u.createRecord({type:u.ContentType.handshake,data:u.createCertificateRequest(t)})),u.queue(t,u.createRecord({type:u.ContentType.handshake,data:u.createServerHelloDone(t)}))),u.flush(t),t.process()}},u.handleCertificate=function(t,r,i){if(3>i)t.error(t,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});else{var n,s,a=r.fragment,o={certificate_list:l(a,3)},c=[];try{for(;o.certificate_list.length()>0;)n=l(o.certificate_list,3),s=e.asn1.fromDer(n),n=e.pki.certificateFromAsn1(s,!0),c.push(n)}catch(h){t.error(t,{message:"Could not parse certificate list.",cause:h,send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.bad_certificate}})}if(!t.fail){var d=t.entity===u.ConnectionEnd.client;!d&&t.verifyClient!==!0||0!==c.length?0===c.length?t.expect=d?g:A:(d?t.session.serverCertificate=c[0]:t.session.clientCertificate=c[0],u.verifyCertificateChain(t,c)&&(t.expect=d?g:A)):t.error(t,{message:d?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}}),t.process()}}},u.handleServerKeyExchange=d,u.handleClientKeyExchange=function(t,r,i){if(48>i)t.error(t,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.unsupported_certificate}});else{var n=r.fragment;msg={enc_pre_master_secret:l(n,2).getBytes()};var s=null;if(t.getPrivateKey)try{s=t.getPrivateKey(t,t.session.serverCertificate),s=e.pki.privateKeyFromPem(s)}catch(a){t.error(t,{message:"Could not get private key.",cause:a,send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}})}if(null===s)t.error(t,{message:"No private key set.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}});else try{var o=t.session.sp;o.pre_master_secret=s.decrypt(msg.enc_pre_master_secret);var c=t.session.clientHelloVersion;if(c.major!==o.pre_master_secret.charCodeAt(0)||c.minor!==o.pre_master_secret.charCodeAt(1))throw{message:"TLS version rollback attack detected."}}catch(a){o.pre_master_secret=e.random.getBytes(48)}}t.fail||(t.expect=T,null!==t.session.clientCertificate&&(t.expect=I),t.process())},u.handleCertificateRequest=function(e,t,r){if(3>r)e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});else{var i=t.fragment,n={certificate_types:l(i,1),certificate_authorities:l(i,2)};e.session.certificateRequest=n,e.expect=y,e.process()}},u.handleCertificateVerify=function(t,r,i){if(2>i)t.error(t,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});else{var n=r.fragment;n.read-=4;var s=n.bytes();n.read+=4,msg={signature:l(n,2).getBytes()};var a=e.util.createBuffer();a.putBuffer(t.session.md5.digest()),a.putBuffer(t.session.sha1.digest()),a=a.getBytes();try{var o=t.session.clientCertificate;if(n=e.pki.rsa.decrypt(msg.signature,o.publicKey,!0,a.length),n!==a)throw{message:"CertificateVerify signature does not match."};t.session.md5.update(s),t.session.sha1.update(s)}catch(c){t.error(t,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.handshake_failure}})}t.fail||(t.expect=T,t.process())}},u.handleServerHelloDone=function(e,t,r){if(r>0)e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.record_overflow}});else if(null===e.serverCertificate){var i={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.insufficient_security}},n=e.verify(e,i.alert.description,depth,[]);n===!0?i=null:((n||0===n)&&(n.constructor==Object?(n.message&&(i.message=n.message),n.alert&&(i.alert.description=n.alert)):n.constructor==Number&&(i.alert.description=n)),e.error(e,i))}if(e.fail||null===e.session.certificateRequest||(t=u.createRecord({type:u.ContentType.handshake,data:u.createCertificate(e)}),u.queue(e,t)),!e.fail){t=u.createRecord({type:u.ContentType.handshake,data:u.createClientKeyExchange(e)}),u.queue(e,t),e.expect=S;var s=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&u.queue(e,u.createRecord({type:u.ContentType.handshake,data:u.createCertificateVerify(e,t)})),u.queue(e,u.createRecord({type:u.ContentType.change_cipher_spec,data:u.createChangeCipherSpec()})),e.state.pending=u.createConnectionState(e),e.state.current.write=e.state.pending.write,u.queue(e,u.createRecord({type:u.ContentType.handshake,data:u.createFinished(e)})),e.expect=v,u.flush(e),e.process()};null===e.session.certificateRequest||null===e.session.clientCertificate?s(e,null):u.getClientSignature(e,s)}},u.handleChangeCipherSpec=function(e,t){if(1!=t.fragment.getByte())e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});else{var r=e.entity===u.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=u.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?b:x,e.process()}},u.handleFinished=function(r,i){var n=i.fragment;n.read-=4;var s=n.bytes();n.read+=4;var a=i.fragment.getBytes();n=e.util.createBuffer(),n.putBuffer(r.session.md5.digest()),n.putBuffer(r.session.sha1.digest());var o=r.entity===u.ConnectionEnd.client,c=o?"server finished":"client finished",l=r.session.sp,h=12,d=t;n=d(l.master_secret,c,n.getBytes(),h),n.getBytes()!==a?r.error(r,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.decrypt_error}}):(r.session.md5.update(s),r.session.sha1.update(s),(r.session.resuming&&o||!r.session.resuming&&!o)&&(u.queue(r,u.createRecord({type:u.ContentType.change_cipher_spec,data:u.createChangeCipherSpec()})),r.state.current.write=r.state.pending.write,r.state.pending=null,u.queue(r,u.createRecord({type:u.ContentType.handshake,data:u.createFinished(r)}))),r.expect=o?w:B,r.handshaking=!1,++r.handshakes,r.peerCertificate=o?r.session.serverCertificate:r.session.clientCertificate,r.sessionCache?(r.session={id:r.session.id,sp:r.session.sp},r.session.sp.keys=null):r.session=null,u.flush(r),r.isConnected=!0,r.connected(r),r.process())},u.handleAlert=function(e,t){var r,i=t.fragment,n={level:i.getByte(),description:i.getByte()};switch(n.description){case u.Alert.Description.close_notify:r="Connection closed.";break;case u.Alert.Description.unexpected_message:r="Unexpected message.";break;case u.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case u.Alert.Description.decryption_failed:r="Decryption failed.";break;case u.Alert.Description.record_overflow:r="Record overflow.";break;case u.Alert.Description.decompression_failure:r="Decompression failed.";break;case u.Alert.Description.handshake_failure:r="Handshake failure.";break;case u.Alert.Description.bad_certificate:r="Bad certificate.";break;case u.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case u.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case u.Alert.Description.certificate_expired:r="Certificate expired.";break;case u.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case u.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case u.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case u.Alert.Description.access_denied:r="Access denied.";break;case u.Alert.Description.decode_error:r="Decode error.";break;case u.Alert.Description.decrypt_error:r="Decrypt error.";break;case u.Alert.Description.export_restriction:r="Export restriction.";break;case u.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case u.Alert.Description.insufficient_security:r="Insufficient security.";break;case u.Alert.Description.internal_error:r="Internal error.";break;case u.Alert.Description.user_canceled:r="User canceled.";break;case u.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}n.description===u.Alert.Description.close_notify?e.close():(e.error(e,{message:r,send:!1,origin:e.entity===u.ConnectionEnd.client?"server":"client",alert:n}),e.process())},u.handleHandshake=function(t,r){var i=r.fragment,n=i.getByte(),s=i.getInt24();if(s>i.length())t.fragmented=r,r.fragment=e.util.createBuffer(),i.read-=4,t.process();else{t.fragmented=null,i.read-=4;var a=i.bytes(s+4);i.read+=4,n in K[t.entity][t.expect]?(t.entity!==u.ConnectionEnd.server||t.open||t.fail||(t.handshaking=!0,t.session={serverNameList:[],cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:e.md.md5.create(),sha1:e.md.sha1.create()}),n!==u.HandshakeType.hello_request&&n!==u.HandshakeType.certificate_verify&&n!==u.HandshakeType.finished&&(t.session.md5.update(a),t.session.sha1.update(a)),K[t.entity][t.expect][n](t,r,s)):u.handleUnexpected(t,r)}},u.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()};var p=0,_=1,g=2,m=3,y=4,v=5,b=6,w=7,S=8,E=0,C=1,A=2,I=3,T=4,x=5,B=6,k=u.handleUnexpected,R=u.handleChangeCipherSpec,U=u.handleAlert,D=u.handleHandshake,N=u.handleApplicationData,L=[];L[u.ConnectionEnd.client]=[[k,k,D,k],[k,U,D,k],[k,U,D,k],[k,U,D,k],[k,U,D,k],[R,U,k,k],[k,U,D,k],[k,U,D,N],[k,U,D,k]],L[u.ConnectionEnd.server]=[[k,k,D,k],[k,U,D,k],[k,U,D,k],[k,U,D,k],[R,U,k,k],[k,U,D,k],[k,U,D,N],[k,U,D,k]];var O=u.handleHelloRequest,P=u.handleServerHello,F=u.handleCertificate,q=u.handleServerKeyExchange,M=u.handleCertificateRequest,j=u.handleServerHelloDone,z=u.handleFinished,K=[];K[u.ConnectionEnd.client]=[[k,k,P,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[O,k,k,k,k,k,k,k,k,k,k,F,q,M,j,k,k,k,k,k,k],[O,k,k,k,k,k,k,k,k,k,k,k,q,M,j,k,k,k,k,k,k],[O,k,k,k,k,k,k,k,k,k,k,k,k,M,j,k,k,k,k,k,k],[O,k,k,k,k,k,k,k,k,k,k,k,k,k,j,k,k,k,k,k,k],[O,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[O,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,z],[O,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[O,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k]];var V=u.handleClientHello,G=u.handleClientKeyExchange,Y=u.handleCertificateVerify;K[u.ConnectionEnd.server]=[[k,V,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,F,k,k,k,k,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,G,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,Y,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,z],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k]],u.generateKeys=function(e,r){var i=t,n=r.client_random+r.server_random;e.session.resuming||(r.master_secret=i(r.pre_master_secret,"master secret",n,48).bytes(),r.pre_master_secret=null),n=r.server_random+r.client_random;var s=2*r.mac_key_length+2*r.enc_key_length+2*r.fixed_iv_length,a=i(r.master_secret,"key expansion",n,s);return{client_write_MAC_key:a.getBytes(r.mac_key_length),server_write_MAC_key:a.getBytes(r.mac_key_length),client_write_key:a.getBytes(r.enc_key_length),server_write_key:a.getBytes(r.enc_key_length),client_write_IV:a.getBytes(r.fixed_iv_length),server_write_IV:a.getBytes(r.fixed_iv_length)}},u.createConnectionState=function(t){var a=t.entity===u.ConnectionEnd.client,o=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(){return!0},compressionState:null,compressFunction:function(){return!0},updateSequenceNumber:function(){4294967295==e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},l={read:o(),write:o()};if(l.read.update=function(e,t){return l.read.cipherFunction(t,l.read)?l.read.compressFunction(e,t,l.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.bad_record_mac}}),!e.fail},l.write.update=function(e,t){return l.write.compressFunction(e,t,l.write)?l.write.cipherFunction(t,l.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}}),!e.fail},t.session){var h=t.session.sp;switch(h.keys=u.generateKeys(t,h),l.read.macKey=a?h.keys.server_write_MAC_key:h.keys.client_write_MAC_key,l.write.macKey=a?h.keys.client_write_MAC_key:h.keys.server_write_MAC_key,l.read.macLength=l.write.macLength=h.mac_length,h.mac_algorithm){case u.MACAlgorithm.hmac_sha1:l.read.macFunction=l.write.macFunction=r;break;default:throw{message:"Unsupported MAC algorithm."}}switch(h.bulk_cipher_algorithm){case u.BulkCipherAlgorithm.aes:l.read.cipherState={init:!1,cipher:e.aes.createDecryptionCipher(a?h.keys.server_write_key:h.keys.client_write_key),iv:a?h.keys.server_write_IV:h.keys.client_write_IV},l.write.cipherState={init:!1,cipher:e.aes.createEncryptionCipher(a?h.keys.client_write_key:h.keys.server_write_key),iv:a?h.keys.client_write_IV:h.keys.server_write_IV},l.read.cipherFunction=c,l.write.cipherFunction=s;break;default:throw{message:"Unsupported cipher algorithm."}}switch(h.cipher_type){case u.CipherType.block:break;default:throw{message:"Unsupported cipher type."}}switch(h.compression_algorithm){case u.CompressionMethod.none:break;case u.CompressionMethod.deflate:l.read.compressFunction=n,l.write.compressFunction=i;break;default:throw{message:"Unsupported compression algorithm."}}}return l},u.createRandom=function(){var t=new Date,r=+t+6e4*t.getTimezoneOffset(),i=e.util.createBuffer();return i.putInt32(r),i.putBytes(e.random.getBytes(28)),i},u.createRecord=function(e){var t={type:e.type,version:{major:u.Version.major,minor:u.Version.minor},length:e.data.length(),fragment:e.data};return t},u.createAlert=function(t){var r=e.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),u.createRecord({type:u.ContentType.alert,data:r})},u.createClientHello=function(t){for(var r=e.util.createBuffer(),i=0;i<t.cipherSuites.length;++i){var n=t.cipherSuites[i];r.putByte(n[0]),r.putByte(n[1])}var s=r.length(),a=e.util.createBuffer();a.putByte(u.CompressionMethod.none);var o=a.length(),c=e.util.createBuffer();if(t.virtualHost){var l=e.util.createBuffer();l.putByte(0),l.putByte(0);var d=e.util.createBuffer();d.putByte(0),h(d,2,e.util.createBuffer(t.virtualHost));var f=e.util.createBuffer();h(f,2,d),h(l,2,f),c.putBuffer(l)}var p=c.length();p>0&&(p+=2);var _=t.session.id,g=_.length+1+2+4+28+2+s+1+o+p,m=e.util.createBuffer();return m.putByte(u.HandshakeType.client_hello),m.putInt24(g),m.putByte(u.Version.major),m.putByte(u.Version.minor),m.putBytes(t.session.sp.client_random),h(m,1,e.util.createBuffer(_)),h(m,2,r),h(m,1,a),p>0&&h(m,2,c),m},u.createServerHello=function(t){var r=t.session.id,i=r.length+1+2+4+28+2+1,n=e.util.createBuffer();return n.putByte(u.HandshakeType.server_hello),n.putInt24(i),n.putByte(u.Version.major),n.putByte(u.Version.minor),n.putBytes(t.session.sp.server_random),h(n,1,e.util.createBuffer(r)),n.putByte(t.session.cipherSuite[0]),n.putByte(t.session.cipherSuite[1]),n.putByte(t.session.compressionMethod),n},u.createCertificate=function(t){var r=t.entity===u.ConnectionEnd.client,i=null;t.getCertificate&&(i=t.getCertificate(t,r?t.session.certificateRequest:t.session.serverNameList));var n=e.util.createBuffer();if(null!==i)try{(Array.isArray&&!Array.isArray(i)||i.constructor!==Array)&&(i=[i]);for(var s=null,a=0;a<i.length;++a){var o=e.pki.pemToDer(i);null===s&&(s=e.asn1.fromDer(o.bytes()));var c=e.util.createBuffer();h(c,3,o),n.putBuffer(c)}i=e.pki.certificateFromAsn1(s),r?t.session.clientCertificate=i:t.session.serverCertificate=i}catch(l){t.error(t,{message:"Could not send certificate list.",cause:l,send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.bad_certificate}})}var d=3+n.length(),f=e.util.createBuffer();return f.putByte(u.HandshakeType.certificate),f.putInt24(d),h(f,3,n),f},u.createClientKeyExchange=f,u.createServerKeyExchange=function(){var t=e.util.createBuffer();return t},u.getClientSignature=function(t,r){var i=e.util.createBuffer();i.putBuffer(t.session.md5.digest()),i.putBuffer(t.session.sha1.digest()),i=i.getBytes(),t.getSignature=t.getSignature||function(t,r,i){var n=null;if(t.getPrivateKey)try{n=t.getPrivateKey(t,t.session.clientCertificate),n=e.pki.privateKeyFromPem(n)}catch(s){t.error(t,{message:"Could not get private key.",cause:s,send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}})}null===n?t.error(t,{message:"No private key set.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}}):r=e.pki.rsa.encrypt(r,n,1),i(t,r)},t.getSignature(t,i,r)},u.createCertificateVerify=function(t,r){var i=r.length+2,n=e.util.createBuffer();return n.putByte(u.HandshakeType.certificate_verify),n.putInt24(i),n.putInt16(r.length),n.putBytes(r),n},u.createCertificateRequest=function(t){var r=e.util.createBuffer();r.putByte(1);var i=e.util.createBuffer();for(var n in t.caStore.certs){var s=t.caStore.certs[n],a=e.pki.distinguishedNameToAsn1(s.subject);i.putBuffer(e.asn1.toDer(a))}var o=1+r.length()+2+i.length(),c=e.util.createBuffer();return c.putByte(u.HandshakeType.certificate_request),c.putInt24(o),h(c,1,r),h(c,2,i),c},u.createServerHelloDone=function(){var t=e.util.createBuffer();return t.putByte(u.HandshakeType.server_hello_done),t.putInt24(0),t},u.createChangeCipherSpec=function(){var t=e.util.createBuffer();return t.putByte(1),t},u.createFinished=function(r){var i=e.util.createBuffer();i.putBuffer(r.session.md5.digest()),i.putBuffer(r.session.sha1.digest());var n=r.entity===u.ConnectionEnd.client,s=r.session.sp,a=12,o=t,c=n?"client finished":"server finished";i=o(s.master_secret,c,i.getBytes(),a);var l=e.util.createBuffer();return l.putByte(u.HandshakeType.finished),l.putInt24(i.length()),l.putBuffer(i),l},u.queue=function(t,r){if(r.type===u.ContentType.handshake){var i=r.fragment.bytes();t.session.md5.update(i),t.session.sha1.update(i),i=null}var n;if(r.fragment.length()<=u.MaxFragment)n=[r];else{n=[];for(var s=r.fragment.bytes();s.length>u.MaxFragment;)n.push(u.createRecord({type:r.type,data:e.util.createBuffer(s.slice(0,u.MaxFragment))})),s=s.slice(u.MaxFragment);s.length>0&&n.push(u.createRecord({type:r.type,data:e.util.createBuffer(s)}))}for(var a=0;a<n.length&&!t.fail;++a){var o=n[a],c=t.state.current.write;c.update(t,o)&&t.records.push(o)}},u.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var W=function(t){switch(t){case!0:return!0;case e.pki.certificateError.bad_certificate:return u.Alert.Description.bad_certificate;case e.pki.certificateError.unsupported_certificate:return u.Alert.Description.unsupported_certificate;case e.pki.certificateError.certificate_revoked:return u.Alert.Description.certificate_revoked;case e.pki.certificateError.certificate_expired:return u.Alert.Description.certificate_expired;case e.pki.certificateError.certificate_unknown:return u.Alert.Description.certificate_unknown;case e.pki.certificateError.unknown_ca:return u.Alert.Description.unknown_ca;default:return u.Alert.Description.bad_certificate}},Q=function(t){switch(t){case!0:return!0;case u.Alert.Description.bad_certificate:return e.pki.certificateError.bad_certificate;case u.Alert.Description.unsupported_certificate:return e.pki.certificateError.unsupported_certificate;case u.Alert.Description.certificate_revoked:return e.pki.certificateError.certificate_revoked;case u.Alert.Description.certificate_expired:return e.pki.certificateError.certificate_expired;case u.Alert.Description.certificate_unknown:return e.pki.certificateError.certificate_unknown;case u.Alert.Description.unknown_ca:return e.pki.certificateError.unknown_ca;default:return e.pki.certificateError.bad_certificate}};u.verifyCertificateChain=function(t,r){try{e.pki.verifyCertificateChain(t.caStore,r,function(e,r,i){var n=(W(e),t.verify(t,e,r,i));if(n!==!0){if(n.constructor===Object){var s={message:"The application rejected the certificate.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.bad_certificate}};throw n.message&&(s.message=n.message),n.alert&&(s.alert.description=n.alert),s}n!==e&&(n=Q(n))}return n})}catch(i){i.constructor!==Object&&(i={send:!0,alert:{level:u.Alert.Level.fatal,description:W(i)}}),"send"in i||(i.send=!0),"alert"in i||(i.alert={level:u.Alert.Level.fatal,description:W(i.error)}),t.error(t,i)}return!t.fail},u.createSessionCache=function(t,r){var i=null;if(t&&t.getSession&&t.setSession&&t.order)i=t;else{i={},i.cache=t||{},i.capacity=Math.max(r||100,1),i.order=[];for(var n in t)i.order.length<=r?i.order.push(n):delete t[n];i.getSession=function(t){var r=null,n=null;if(t?n=e.util.bytesToHex(t):i.order.length>0&&(n=i.order[0]),null!==n&&n in i.cache){r=i.cache[n],delete i.cache[n];for(var s in i.order)if(i.order[s]===n){i.order.splice(s,1);break}}return r},i.setSession=function(t,r){if(i.order.length===i.capacity){var n=i.order.shift();delete i.cache[n]}var n=e.util.bytesToHex(t);i.order.push(n),i.cache[n]=r}}return i},u.createConnection=function(t){var r=null;r=t.caStore?Array.isArray&&Array.isArray(t.caStore)||t.caStore.constructor==Array?e.pki.createCaStore(t.caStore):t.caStore:e.pki.createCaStore();var i=t.cipherSuites||null;null===i&&(i=[],i.push(u.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA),i.push(u.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA));var n=t.server?u.ConnectionEnd.server:u.ConnectionEnd.client,s=t.sessionCache?u.createSessionCache(t.sessionCache):null,a={entity:n,sessionId:t.sessionId,caStore:r,sessionCache:s,cipherSuites:i,connected:t.connected,virtualHost:t.virtualHost||null,verifyClient:t.verifyClient||!1,verify:t.verify||function(e,t){return t},getCertificate:t.getCertificate||null,getPrivateKey:t.getPrivateKey||null,getSignature:t.getSignature||null,input:e.util.createBuffer(),tlsData:e.util.createBuffer(),data:e.util.createBuffer(),tlsDataReady:t.tlsDataReady,dataReady:t.dataReady,closed:t.closed,error:function(e,r){r.origin=r.origin||(e.entity===u.ConnectionEnd.client?"client":"server"),r.send&&(u.queue(e,u.createAlert(r.alert)),u.flush(e));var i=r.fatal!==!1;i&&(e.fail=!0),t.error(e,r),i&&e.close(!1)},deflate:t.deflate||null,inflate:t.inflate||null};a.reset=function(e){a.record=null,a.session=null,a.peerCertificate=null,a.state={pending:null,current:null},a.expect=a.entity===u.ConnectionEnd.client?p:E,a.fragmented=null,a.records=[],a.open=!1,a.handshakes=0,a.handshaking=!1,a.isConnected=!1,a.fail=!(e||"undefined"==typeof e),a.input.clear(),a.tlsData.clear(),a.data.clear(),a.state.current=u.createConnectionState(a)},a.reset();var o=function(e,t){var r=t.type-u.ContentType.change_cipher_spec,i=L[e.entity][e.expect];r in i?i[r](e,t):u.handleUnexpected(e,t)},c=function(t){var r=0,i=t.input,n=i.length();return 5>n?r=5-n:t.record={type:i.getByte(),version:{major:i.getByte(),minor:i.getByte()},length:i.getInt16(),fragment:e.util.createBuffer(),ready:!1},r},l=function(e){var t=0,r=e.input,i=r.length();if(i<e.record.length)t=e.record.length-i;else{e.record.fragment.putBytes(r.getBytes(e.record.length)),r.compact();var n=e.state.current.read;n.update(e,e.record)&&(null!==e.fragmented&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:"Invalid fragmented record.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.unexpected_message}})),e.record.ready=!0)}return t};return a.handshake=function(t){if(a.entity!==u.ConnectionEnd.client)a.error(a,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(a.handshaking)a.error(a,{message:"Handshake already in progress.",fatal:!0});else{a.fail&&!a.open&&0===a.handshakes&&(a.fail=!1),a.handshaking=!0,t=t||"";var r=null;t.length>0&&(a.sessionCache&&(r=a.sessionCache.getSession(t)),null===r&&(t="")),0===t.length&&a.sessionCache&&(r=a.sessionCache.getSession(),null!==r&&(t=r.id)),a.session={id:t,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:r?r.sp:{},md5:e.md.md5.create(),sha1:e.md.sha1.create()},a.session.sp.client_random=u.createRandom().getBytes(),a.open=!0,u.queue(a,u.createRecord({type:u.ContentType.handshake,data:u.createClientHello(a)})),u.flush(a)}},a.process=function(e){var t=0;return e&&a.input.putBytes(e),a.fail||(null!==a.record&&a.record.ready&&a.record.fragment.isEmpty()&&(a.record=null),null===a.record&&(t=c(a)),a.fail||null===a.record||a.record.ready||(t=l(a)),!a.fail&&null!==a.record&&a.record.ready&&o(a,a.record)),t},a.prepare=function(t){return u.queue(a,u.createRecord({type:u.ContentType.application_data,data:e.util.createBuffer(t)})),u.flush(a)},a.close=function(e){!a.fail&&a.sessionCache&&a.session&&a.sessionCache.setSession(a.session.id,a.session),a.open&&(a.open=!1,a.input.clear(),(a.isConnected||a.handshaking)&&(a.isConnected=a.handshaking=!1,u.queue(a,u.createAlert({level:u.Alert.Level.warning,description:u.Alert.Description.close_notify})),u.flush(a)),a.closed(a)),a.reset(e)},a},e.tls.prf_tls1=t,e.tls.Alert=u.Alert,e.tls.CipherSuites=u.CipherSuites,e.tls.createSessionCache=u.createSessionCache,e.tls.createConnection=u.createConnection}(),function(){var e={},t=fl;t.md=t.md||{},t.md.algorithms=t.md.algorithms||{},t.md.md5=t.md.algorithms.md5=e;var r=null,i=null,n=null,s=null,a=!1,o=function(){r=String.fromCharCode(128),r+=t.util.fillString(String.fromCharCode(0),64),i=[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],n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=new Array(64);for(var e=0;64>e;++e)s[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));a=!0},c=function(e,t,r){for(var a,o,c,l,h,u,d,f,p=r.length();p>=64;){for(o=e.h0,c=e.h1,l=e.h2,h=e.h3,f=0;16>f;++f)t[f]=r.getInt32Le(),u=h^c&(l^h),a=o+u+s[f]+t[f],d=n[f],o=h,h=l,l=c,c+=a<<d|a>>>32-d;for(;32>f;++f)u=l^h&(c^l),a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<<d|a>>>32-d;for(;48>f;++f)u=c^l^h,a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<<d|a>>>32-d;for(;64>f;++f)u=l^(c|~h),a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<<d|a>>>32-d;e.h0=e.h0+o&4294967295,e.h1=e.h1+c&4294967295,e.h2=e.h2+l&4294967295,e.h3=e.h3+h&4294967295,p-=64}};e.create=function(){a||o();var e=null,i=t.util.createBuffer(),n=new Array(16),s={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0};return s.start=function(){s.messageLength=0,i=t.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878}},s.start(),s.update=function(r,a){"utf8"===a&&(r=t.util.encodeUtf8(r)),s.messageLength+=r.length,i.putBytes(r),c(e,n,i),(i.read>2048||0===i.length())&&i.compact()},s.digest=function(){var a=s.messageLength,o=t.util.createBuffer();o.putBytes(i.bytes()),o.putBytes(r.substr(0,64-(a+8)%64)),o.putInt32Le(a<<3&4294967295),o.putInt32Le(a>>>29&255);var l={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};c(l,n,o);var h=t.util.createBuffer();return h.putInt32Le(l.h0),h.putInt32Le(l.h1),h.putInt32Le(l.h2),h.putInt32Le(l.h3),h},s}}();var kl=function(e){for(var t=e.length,r=[],i=0;t>i;i++){var n=e[i].charCodeAt().toString(16);r.push(n.length>1?n:"0"+n)}return r.join("")},Rl=function(e){for(var t=e.length,r=[],i=0;t>i;i+=2)r.push(String.fromCharCode(parseInt(e[i]+e[i+1],16)));return r.join("")},Ul=function(e,t,r,i,n,s,a,o){var c=fl.pki.publicKeyFromPem(ki.readFileSync(e).toString("utf8")),l=fl.pki.privateKeyFromPem(ki.readFileSync(t).toString("utf8"));
if(!o){var o=fl.pki.createCertificate();o.serialNumber=i;var h=new Date(n.valueOf());h.setHours(h.getHours()-2),o.validity.notBefore=h,o.validity.notAfter=new Date(o.validity.notBefore.valueOf()),o.validity.notAfter.setFullYear(o.validity.notBefore.getFullYear()+1);var u=[{name:"commonName",value:s||"www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".com"}],d=[{name:"commonName",value:a||"www."+ac(Math.floor(20*Math.random()+4)).toString("hex")+".com"}];o.setSubject(u),o.setIssuer(d)}o.publicKey=c,o.sign(l);var f=fl.pki.certificateToPem(o);return"pem"===r?f:"der"===r?js?fl.pki.pemToDer(f).toHex():fl.pki.pemToDer(f).data.toString("hex"):o},Dl=function(e){console.log('Generating 512-bit key-pair and certificate for "'+e+'".');var t=fl.pki.rsa.generateKeyPair(512);console.log("Key-pair created.");var r=fl.pki.createCertificate();r.serialNumber=Date.now().toString(),r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+1);var i=[{name:"commonName",value:e},{name:"countryName",value:"US"},{shortName:"ST",value:"Virginia"},{name:"localityName",value:"Blacksburg"},{name:"organizationName",value:"Internet Widgits Pty Ltd"},{shortName:"OU",value:"Internet Widgits Pty Ltd"}];return r.setSubject(i),r.setIssuer(i),r.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"subjectAltName",altNames:[{type:6,value:"http://www.ianonym.com"}]}]),r.publicKey=t.publicKey,r.sign(t.privateKey),console.log('Certificate created for "'+e+'", signature : <br><br>'+kl(r.signature).toUpperCase()),{cert:fl.pki.certificateToPem(r),privateKey:fl.pki.privateKeyToPem(t.privateKey)}},Nl=function(e,t,r){var i,n=r?"server":"client";return r?Ks[t]?i=Ks[t]:(i=Dl(r?t:"client"),Ks[t]=i):i={cert:{},privateKey:{}},fl.tls.createConnection({server:r?!0:!1,caStore:r?[i.cert]:"",sessionCache:{},cipherSuites:[[0,47],[0,53],[192,10],[192,20],[0,136],[0,135],[0,57],[0,56],[192,15],[192,5],[0,132],[192,7],[192,9],[192,17],[192,19],[0,69],[0,68],[0,51],[0,50],[192,12],[192,14],[192,2],[192,4],[0,150],[0,65],[0,4],[0,5],[192,8],[192,18],[0,22],[0,19],[192,13],[192,3],[254,255],[0,10]],virtualHost:r?"":t,verifyClient:!1,verify:function(e,t,r,i){return!0},connected:function(e){console.log("TLS "+n+" "+t+" connected..."),setTimeout(function(){var t=fl.util.encodeUtf8("Hello "+("server"===n?"client":"server")+" I want 100 â‚¬ ");e.prepare(t)},1)},getCertificate:function(){return i.cert},getPrivateKey:function(){return i.privateKey},tlsDataReady:function(t){if(js){var r=t.tlsData.getBytes();zs?"server"===n?e.write_s(new ii(kl(r),"hex")):e.write_c(new ii(kl(r),"hex")):"server"===n?e.write_s(r):e.write_c(r)}else{var i=t.tlsData.data.slice(0,t.tlsData.length_);i.length&&0!==i[0]&&(t.tlsData.clear(),"server"===n?e.write_s(i):e.write_c(i))}},dataReady:function(e){if(js)console.log(n+" "+t+" received : "+fl.util.decodeUtf8(e.data.getBytes()));else{var r=e.data.data.toString("utf8");console.log(n+" "+t+" received : "+r)}},closed:function(){console.log(n+" "+t+" disconnected.")},error:function(e,r){console.log(n+" "+t+" notification: "+r.message),console.log(-1===r.message.indexOf("Unknown")?"Unexpected error - please retry":"Normal error message, so far, so good."),e.close()}})}}var Ll=function(e,t,r){for(var i="",n="",s="",a=0,o=0;r>0;--r,++a)n=e.charCodeAt(a)^t.charCodeAt(a),o>=10&&(i+=s,s="",o=0),s+=String.fromCharCode(n),++o;return i+=s},Ol=function(e,t,r){for(var i,n="",s=Math.ceil(t/r),a=0;s>a;++a){var o=String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a);i=new vn("sha1"),i.update(new ii(e+o,"binary")),n+=new ii(i.digest("hex"),"hex").toString("binary")}return n.substring(0,t)},Pl=function(e,t,r){var i,n,s="",a=20;r&&(s=r.label,i=r.seed),n=new vn("sha1");var o=e-2*a-2;if(t.length>o)throw{message:"RSAES-OAEP input message length is too long.",length:t.length,maxLength:o};n.update(new ii(s,"binary"));var c=n.digest("hex");c=new ii(c,"hex").toString("binary");for(var l="",h=o-t.length,u=0;h>u;u++)l+="\x00";var d=c+l+""+t;i||(i=ac(a).toString("binary"));var f=Ol(i,e-a-1,a),p=Ll(d,f,d.length),_=Ol(p,a,a),g=Ll(i,_,i.length);return"\x00"+g+p},Fl=function(e,t,r){var i,n="",s=20;if(r&&(n=r.label,i=r.md),t.length!==e)throw{message:"RSAES-OAEP encoded message length is invalid.",length:t.length,expectedLength:e};if(i=new vn("sha1"),2*s+2>e)throw{message:"RSAES-OAEP key is too short for the hash function."};i.update(new ii(n,"binary"));var a=i.digest("hex");a=new ii(a,"hex").toString("binary");for(var o=t.charAt(0),c=t.substring(1,s+1),l=t.substring(1+s),h=Ol(l,s,s),u=fl.util.xorBytes(c,h,c.length),d=Ol(u,e-s-1,s),f=fl.util.xorBytes(l,d,l.length),p=f.substring(0,s),_="\x00"!==o,g=0;s>g;++g)_|=a.charAt(g)!==p.charAt(g);for(var m=1,y=s,v=s;v<f.length;v++){var b=f.charCodeAt(v),w=1&b^1,S=m?65534:0;_|=b&S,m|=w,y+=m}if(_||1!==f.charCodeAt(y))throw{message:"Invalid RSAES-OAEP padding."};return f.substring(y+1)},ql=function(){};ql.prototype.encrypt=function(e,t,r,i){var n={};if(n.n=new H(e.toString("binary"),16),n.e=new H(t.toString("binary"),16),"RSA_PKCS1_OAEP_PADDING"===i){var s=Pl(e.length/2,r.toString("binary")),a=new ii(fl.pki.rsa.encrypt(s,n,!0),"binary").toString("hex");return a}return new ii(fl.pki.rsa.encrypt(r.toString("binary"),n),"binary").toString("hex")},ql.prototype.decrypt=function(e,t,r){if(e=fl.pki.privateKeyFromPem(e),"RSA_PKCS1_OAEP_PADDING"===r){var i=fl.pki.rsa.decrypt(new ii(t,"hex").toString("binary"),e,!1,!1);return i=Fl(e.n.bitLength()/8,i),new ii(i,"binary").toString("hex")}return new ii(fl.pki.rsa.decrypt(buff_mess_bin.toString("binary"),e),"binary").toString("hex")};var Ml=function(e,t,r){this._byteOffset=t||0,e instanceof ArrayBuffer?this.buffer=e:"object"==typeof e?(this.dataView=e,t&&(this._byteOffset+=t)):this.buffer=new ArrayBuffer(e||0),this.position=0,this.endianness=null==r?Ml.LITTLE_ENDIAN:r};Ml.prototype={},Ml.prototype.save=function(e){var t=new Blob([this.buffer]),r=window.webkitURL||window.URL;if(!r||!r.createObjectURL)throw"DataStream.save: Can't create object URL.";var i=r.createObjectURL(t),n=document.createElement("a");n.setAttribute("href",i),n.setAttribute("download",e),n.click(),r.revokeObjectURL(i)},Ml.BIG_ENDIAN=!1,Ml.LITTLE_ENDIAN=!0,Ml.prototype._dynamicSize=!0,Object.defineProperty(Ml.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){e||this._trimAlloc(),this._dynamicSize=e}}),Ml.prototype._byteLength=0,Object.defineProperty(Ml.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}}),Object.defineProperty(Ml.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(e){this._buffer=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(Ml.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(e){this._byteOffset=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}}),Object.defineProperty(Ml.prototype,"dataView",{get:function(){return this._dataView},set:function(e){this._byteOffset=e.byteOffset,this._buffer=e.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+e.byteLength}}),Ml.prototype._realloc=function(e){if(this._dynamicSize){var t=this._byteOffset+this.position+e,r=this._buffer.byteLength;if(r>=t)return void(t>this._byteLength&&(this._byteLength=t));for(1>r&&(r=1);t>r;)r*=2;var i=new ArrayBuffer(r),n=new Uint8Array(this._buffer),s=new Uint8Array(i,0,n.length);s.set(n),this.buffer=i,this._byteLength=t}},Ml.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var e=new ArrayBuffer(this._byteLength),t=new Uint8Array(e),r=new Uint8Array(this._buffer,0,t.length);t.set(r),this.buffer=e}},Ml.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e),r=new Uint8Array(t),i=new Uint8Array(this._buffer,e,r.length);r.set(i),this.buffer=t,this.position-=e},Ml.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t},Ml.prototype.isEof=function(){return this.position>=this._byteLength},Ml.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var r=new Int32Array(this._buffer,this.byteOffset+this.position,e);return Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},Ml.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var r=new Int16Array(this._buffer,this.byteOffset+this.position,e);return Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=2*e,r},Ml.prototype.mapInt8Array=function(e){this._realloc(1*e);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},Ml.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var r=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},Ml.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var r=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=2*e,r},Ml.prototype.mapUint8Array=function(e){this._realloc(1*e);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},Ml.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var r=new Float64Array(this._buffer,this.byteOffset+this.position,e);return Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=8*e,r},Ml.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var r=new Float32Array(this._buffer,this.byteOffset+this.position,e);return Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},Ml.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Int32Array(e);return Ml.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},Ml.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var r=new Int16Array(e);return Ml.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},Ml.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return Ml.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},Ml.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Uint32Array(e);return Ml.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},Ml.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var r=new Uint16Array(e);return Ml.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},Ml.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return Ml.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},Ml.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var r=new Float64Array(e);return Ml.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},Ml.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Float32Array(e);return Ml.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),Ml.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},Ml.prototype.writeInt32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)Ml.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt32Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeInt32(e[r],t)},Ml.prototype.writeInt16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)Ml.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt16Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeInt16(e[r],t)},Ml.prototype.writeInt8Array=function(e){if(this._realloc(1*e.length),e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)Ml.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt8Array(e.length);else for(var t=0;t<e.length;t++)this.writeInt8(e[t])},Ml.prototype.writeUint32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)Ml.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint32Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeUint32(e[r],t)},Ml.prototype.writeUint16Array=function(e,t){if(this._realloc(2*e.length),e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)Ml.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint16Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeUint16(e[r],t)},Ml.prototype.writeUint8Array=function(e){if(this._realloc(1*e.length),e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)Ml.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint8Array(e.length);else for(var t=0;t<e.length;t++)this.writeUint8(e[t])},Ml.prototype.writeFloat64Array=function(e,t){if(this._realloc(8*e.length),e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)Ml.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat64Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeFloat64(e[r],t)},Ml.prototype.writeFloat32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)Ml.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat32Array(e.length,t);else for(var r=0;r<e.length;r++)this.writeFloat32(e[r],t)},Ml.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,null==e?this.endianness:e);return this.position+=4,t},Ml.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,null==e?this.endianness:e);return this.position+=2,t},Ml.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);return this.position+=1,e},Ml.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,null==e?this.endianness:e);return this.position+=4,t},Ml.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,null==e?this.endianness:e);return this.position+=2,t},Ml.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);return this.position+=1,e},Ml.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,null==e?this.endianness:e);return this.position+=4,t},Ml.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,null==e?this.endianness:e);return this.position+=8,t},Ml.prototype.writeInt32=function(e,t){this._realloc(4),this._dataView.setInt32(this.position,e,null==t?this.endianness:t),this.position+=4},Ml.prototype.writeInt16=function(e,t){this._realloc(2),this._dataView.setInt16(this.position,e,null==t?this.endianness:t),this.position+=2},Ml.prototype.writeInt8=function(e){this._realloc(1),this._dataView.setInt8(this.position,e),this.position+=1},Ml.prototype.writeUint32=function(e,t){this._realloc(4),this._dataView.setUint32(this.position,e,null==t?this.endianness:t),this.position+=4},Ml.prototype.writeUint16=function(e,t){this._realloc(2),this._dataView.setUint16(this.position,e,null==t?this.endianness:t),this.position+=2},Ml.prototype.writeUint8=function(e){this._realloc(1),this._dataView.setUint8(this.position,e),this.position+=1},Ml.prototype.writeFloat32=function(e,t){this._realloc(4),this._dataView.setFloat32(this.position,e,null==t?this.endianness:t),this.position+=4},Ml.prototype.writeFloat64=function(e,t){this._realloc(8),this._dataView.setFloat64(this.position,e,null==t?this.endianness:t),this.position+=8},Ml.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0,Ml.memcpy=function(e,t,r,i,n){var s=new Uint8Array(e,t,n),a=new Uint8Array(r,i,n);s.set(a)},Ml.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},Ml.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},Ml.flipArrayEndianness=function(e){for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=0;r<e.byteLength;r+=e.BYTES_PER_ELEMENT)for(var i=r+e.BYTES_PER_ELEMENT-1,n=r;i>n;i--,n++){var s=t[n];t[n]=t[i],t[i]=s}return e},Ml.prototype.failurePosition=0,Ml.prototype.readStruct=function(e){for(var t,r,i={},n=this.position,s=0;s<e.length;s+=2){if(t=e[s+1],r=this.readType(t,i),null==r)return 0===this.failurePosition&&(this.failurePosition=this.position),this.position=n,null;i[e[s]]=r}return i},Ml.prototype.readUCS2String=function(e,t){return String.fromCharCode.apply(null,this.readUint16Array(e,t))},Ml.prototype.writeUCS2String=function(e,t,r){null==r&&(r=e.length);for(var i=0;i<e.length&&r>i;i++)this.writeUint16(e.charCodeAt(i),t);for(;r>i;i++)this.writeUint16(0)},Ml.prototype.readString=function(e,t){return null==t||"ASCII"==t?String.fromCharCode.apply(null,this.mapUint8Array(null==e?this.byteLength-this.position:e)):new M(t).decode(this.mapUint8Array(e))},Ml.prototype.writeString=function(e,t,r){var i=0;if(null==t||"ASCII"==t)if(null!=r){var n=Math.min(e.length,r);for(i=0;n>i;i++)this.writeUint8(e.charCodeAt(i));for(;r>i;i++)this.writeUint8(0)}else for(i=0;i<e.length;i++)this.writeUint8(e.charCodeAt(i));else this.writeUint8Array(new q(t).encode(e.substring(0,r)))},Ml.prototype.readCString=function(e){var t=this.byteLength-this.position,r=new Uint8Array(this._buffer,this._byteOffset+this.position),i=t;null!=e&&(i=Math.min(e,t));for(var n=0;i>n&&0!==r[n];n++);var s=String.fromCharCode.apply(null,this.mapUint8Array(n));return null!=e?this.position+=i-n:n!=t&&(this.position+=1),s},Ml.prototype.writeCString=function(e,t){var r=0;if(null!=t){var i=Math.min(e.length,t);for(r=0;i>r;r++)this.writeUint8(e.charCodeAt(r));for(;t>r;r++)this.writeUint8(0)}else{for(r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));this.writeUint8(0)}},Ml.prototype.readType=function(e,t){if("function"==typeof e)return e(this,t);if(!("object"!=typeof e||e instanceof Array))return e.get(this,t);if(e instanceof Array&&3!=e.length)return this.readStruct(e,t);var r,i,n,s=null,a=null,o="ASCII",c=this.position;switch("string"==typeof e&&/:/.test(e)&&(r=e.split(":"),e=r[0],a=parseInt(r[1])),"string"==typeof e&&/,/.test(e)&&(r=e.split(","),e=r[0],o=parseInt(r[1])),e){case"uint8":s=this.readUint8();break;case"int8":s=this.readInt8();break;case"uint16":s=this.readUint16(this.endianness);break;case"int16":s=this.readInt16(this.endianness);break;case"uint32":s=this.readUint32(this.endianness);break;case"int32":s=this.readInt32(this.endianness);break;case"float32":s=this.readFloat32(this.endianness);break;case"float64":s=this.readFloat64(this.endianness);break;case"uint16be":s=this.readUint16(Ml.BIG_ENDIAN);break;case"int16be":s=this.readInt16(Ml.BIG_ENDIAN);break;case"uint32be":s=this.readUint32(Ml.BIG_ENDIAN);break;case"int32be":s=this.readInt32(Ml.BIG_ENDIAN);break;case"float32be":s=this.readFloat32(Ml.BIG_ENDIAN);break;case"float64be":s=this.readFloat64(Ml.BIG_ENDIAN);break;case"uint16le":s=this.readUint16(Ml.LITTLE_ENDIAN);break;case"int16le":s=this.readInt16(Ml.LITTLE_ENDIAN);break;case"uint32le":s=this.readUint32(Ml.LITTLE_ENDIAN);break;case"int32le":s=this.readInt32(Ml.LITTLE_ENDIAN);break;case"float32le":s=this.readFloat32(Ml.LITTLE_ENDIAN);break;case"float64le":s=this.readFloat64(Ml.LITTLE_ENDIAN);break;case"cstring":s=this.readCString(a);break;case"string":s=this.readString(a,o);break;case"u16string":s=this.readUCS2String(a,this.endianness);break;case"u16stringle":s=this.readUCS2String(a,Ml.LITTLE_ENDIAN);break;case"u16stringbe":s=this.readUCS2String(a,Ml.BIG_ENDIAN);break;default:if(3==e.length){var l=e[1],h=e[2],u=0;if(u="function"==typeof h?h(t,this,e):parseInt("string"==typeof h&&null!=t[h]?t[h]:h),"string"==typeof l){var d=l.replace(/(le|be)$/,""),f=null;switch(/le$/.test(l)?f=Ml.LITTLE_ENDIAN:/be$/.test(l)&&(f=Ml.BIG_ENDIAN),"*"==h&&(u=null),d){case"uint8":s=this.readUint8Array(u);break;case"uint16":s=this.readUint16Array(u,f);break;case"uint32":s=this.readUint32Array(u,f);break;case"int8":s=this.readInt8Array(u);break;case"int16":s=this.readInt16Array(u,f);break;case"int32":s=this.readInt32Array(u,f);break;case"float32":s=this.readFloat32Array(u,f);break;case"float64":s=this.readFloat64Array(u,f);break;case"cstring":case"utf16string":case"string":if(null==u)for(s=[];!this.isEof()&&(n=this.readType(l,t),null!=n);)s.push(n);else for(s=new Array(u),i=0;u>i;i++)s[i]=this.readType(l,t)}}else if("*"==h){s=[];for(this.buffer;;){var p=this.position;try{var _=this.readType(l,t);if(null==_){this.position=p;break}s.push(_)}catch(g){this.position=p;break}}}else for(s=new Array(u),i=0;u>i;i++){if(n=this.readType(l,t),null==n)return null;s[i]=n}break}}return null!=a&&(this.position=c+a),s},Ml.prototype.writeStruct=function(e,t){for(var r=0;r<e.length;r+=2){var i=e[r+1];this.writeType(i,t[e[r]],t)}},Ml.prototype.writeType=function(e,t,r){var i;if("function"==typeof e)return e(this,t);if("object"==typeof e&&!(e instanceof Array))return e.set(this,t,r);var n=null,s="ASCII",a=this.position;switch("string"==typeof e&&/:/.test(e)&&(i=e.split(":"),e=i[0],n=parseInt(i[1])),"string"==typeof e&&/,/.test(e)&&(i=e.split(","),e=i[0],s=parseInt(i[1])),e){case"uint8":this.writeUint8(t);break;case"int8":this.writeInt8(t);break;case"uint16":this.writeUint16(t,this.endianness);break;case"int16":this.writeInt16(t,this.endianness);break;case"uint32":this.writeUint32(t,this.endianness);break;case"int32":this.writeInt32(t,this.endianness);break;case"float32":this.writeFloat32(t,this.endianness);break;case"float64":this.writeFloat64(t,this.endianness);break;case"uint16be":this.writeUint16(t,Ml.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,Ml.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,Ml.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,Ml.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,Ml.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,Ml.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,Ml.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,Ml.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,Ml.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,Ml.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,Ml.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,Ml.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,n);break;case"string":this.writeString(t,s,n);break;case"u16string":this.writeUCS2String(t,this.endianness,n);break;case"u16stringle":this.writeUCS2String(t,Ml.LITTLE_ENDIAN,n);break;case"u16stringbe":this.writeUCS2String(t,Ml.BIG_ENDIAN,n);break;default:if(3==e.length){for(var o=e[1],c=0;c<t.length;c++)this.writeType(o,t[c]);break}this.writeStruct(e,t)}null!=n&&(this.position=a,this._realloc(n),this.position=a+n)};var Hl=Math.pow(2,32);Ml.prototype.readUint64=function(){return this.readUint32()*Hl+this.readUint32()},Ml.prototype.writeUint64=function(e){var t=Math.floor(e/Hl);this.writeUint32(t),this.writeUint32(4294967295&e)},Ml.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()},Ml.prototype.writeUint24=function(e){this.writeUint8((16711680&e)>>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},Ml.prototype.adjustUint32=function(e,t){var r=this.position;this.seek(e),this.writeUint32(t),this.seek(r)};var jl={ERR_NOT_ENOUGH_DATA:0,OK:1,boxCodes:["mdat","avcC","ftyp","payl","vmhd","smhd","hmhd","dref","elst"],fullBoxCodes:["mvhd","tkhd","mdhd","hdlr","smhd","hmhd","nhmd","url ","urn ","ctts","cslg","stco","co64","stsc","stss","stsz","stz2","stts","stsh","mehd","trex","mfhd","tfhd","trun","tfdt","esds","subs"],containerBoxCodes:[["moov",["trak"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl"],["mvex",["trex"]],["moof",["traf"]],["traf",["trun"]],["vttc"],["tref"]],sampleEntryCodes:[{prefix:"Visual",types:["mp4v","avc1","avc2","avc3","avc4","avcp","drac","encv","mjp2","mvc1","mvc2","resv","s263","svc1","vc-1"]},{prefix:"Audio",types:["mp4a","ac-3","alac","dra1","dtsc","dtse",,"dtsh","dtsl","ec-3","enca","g719","g726","m4ae","mlpa","raw ","samr","sawb","sawp","sevc","sqcp","ssmv","twos"]},{prefix:"Hint",types:["fdp ","m2ts","pm2t","prtp","rm2t","rrtp","rsrp","rtp ","sm2t","srtp"]},{prefix:"Metadata",types:["metx","mett","urim"]},{prefix:"Subtitle",types:["stpp","wvtt"]}],trackReferenceTypes:["scal"],initialize:function(){var e,t,r;for(jl.FullBox.prototype=new jl.Box,jl.ContainerBox.prototype=new jl.Box,jl.stsdBox.prototype=new jl.FullBox,jl.SampleEntry.prototype=new jl.FullBox,jl.TrackReferenceTypeBox.prototype=new jl.Box,r=jl.boxCodes.length,e=0;r>e;e++)jl[jl.boxCodes[e]+"Box"]=function(e){return function(t){jl.Box.call(this,jl.boxCodes[e],t)}}(e),jl[jl.boxCodes[e]+"Box"].prototype=new jl.Box;for(r=jl.fullBoxCodes.length,e=0;r>e;e++)jl[jl.fullBoxCodes[e]+"Box"]=function(e){return function(t){jl.FullBox.call(this,jl.fullBoxCodes[e],t)}}(e),jl[jl.fullBoxCodes[e]+"Box"].prototype=new jl.FullBox;for(r=jl.containerBoxCodes.length,e=0;r>e;e++)jl[jl.containerBoxCodes[e][0]+"Box"]=function(e,t){return function(r){if(jl.ContainerBox.call(this,jl.containerBoxCodes[e][0],r),t){this.subBoxNames=t;for(var i=t.length,n=0;i>n;n++)this[t[n]+"s"]=[]}}}(e,jl.containerBoxCodes[e][1]),jl[jl.containerBoxCodes[e][0]+"Box"].prototype=new jl.ContainerBox;for(r=jl.sampleEntryCodes.length,t=0;r>t;t++){var i=jl.sampleEntryCodes[t].prefix,n=jl.sampleEntryCodes[t].types,s=n.length;for(jl[i+"SampleEntry"]=function(e,t){jl.SampleEntry.call(this,e,t)},jl[i+"SampleEntry"].prototype=new jl.SampleEntry,e=0;s>e;e++)jl[n[e]+"Box"]=function(e,t){return function(r){jl[jl.sampleEntryCodes[e].prefix+"SampleEntry"].call(this,jl.sampleEntryCodes[e].types[t],r)}}(t,e),jl[n[e]+"Box"].prototype=new jl[i+"SampleEntry"]}for(r=jl.trackReferenceTypes.length,e=0;r>e;e++)jl[jl.trackReferenceTypes[e]+"Box"]=function(e){return function(t){jl.TrackReferenceTypeBox.call(this,jl.trackReferenceTypes[e],t)}}(e),jl[jl.trackReferenceTypes[e]+"Box"].prototype=new jl.Box},Box:function(e,t){this.type=e,this.size=t},FullBox:function(e,t){jl.Box.call(this,e,t),this.flags=0,this.version=0},ContainerBox:function(e,t){jl.Box.call(this,e,t),this.boxes=[]},SampleEntry:function(e,t){jl.Box.call(this,e,t),this.boxes=[]},TrackReferenceTypeBox:function(e,t){jl.Box.call(this,e,t),this.track_ids=[]},stsdBox:function(e){jl.FullBox.call(this,"stsd",e),this.entries=[]},parseOneBox:function(e,t){var r,i=e.position,n=0;if(e.byteLength-e.position<8)return Vl.d("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:jl.ERR_NOT_ENOUGH_DATA};var s=e.readUint32(),a=e.readString(4);if(Vl.d("BoxParser","Found box of type "+a+" and size "+s+" at position "+i+" in the current buffer ("+(e.buffer.fileStart+i)+" in the file)"),n=8,"uuid"==a&&(uuid=e.readString(16),n+=16),1==s){if(e.byteLength-e.position<8)return e.seek(i),Vl.w("BoxParser",'Not enough data in stream to parse the extended size of the "'+a+'" box'),{code:jl.ERR_NOT_ENOUGH_DATA};s=e.readUint64(),n+=8}else if(0===s)throw"Unlimited box size not supported";return i+s>e.byteLength?(e.seek(i),Vl.w("BoxParser",'Not enough data in stream to parse the entire "'+a+'" box'),{code:jl.ERR_NOT_ENOUGH_DATA,type:a,size:s,hdr_size:n}):(r=jl[a+"Box"]?new jl[a+"Box"](s-n):t?new jl.SampleEntry(a,s-n):new jl.Box(a,s-n),r.hdr_size=n,r.start=i,r.fileStart=i+e.buffer.fileStart,r.parse(e),{code:jl.OK,box:r,size:s})}};jl.initialize(),jl.Box.prototype.parse=function(e){"mdat"!=this.type?this.data=e.readUint8Array(this.size):e.seek(this.start+this.size+this.hdr_size)},jl.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8(),this.flags=e.readUint24(),this.size-=4},jl.ContainerBox.prototype.parse=function(e){var t,r,i;for(i=e.position;e.position<i+this.size;)t=jl.parseOneBox(e),r=t.box,this.boxes.push(r),this.subBoxNames&&-1!=this.subBoxNames.indexOf(r.type)?this[this.subBoxNames+"s"].push(r):this[r.type]=r},jl.SampleEntry.prototype.isVideo=function(){return!1},jl.SampleEntry.prototype.isAudio=function(){return!1},jl.SampleEntry.prototype.isSubtitle=function(){return!1},jl.SampleEntry.prototype.isMetadata=function(){return!1},jl.SampleEntry.prototype.isHint=function(){return!1},jl.SampleEntry.prototype.getCodec=function(){return this.type},jl.SampleEntry.prototype.getWidth=function(){return""},jl.SampleEntry.prototype.getHeight=function(){return""},jl.SampleEntry.prototype.getChannelCount=function(){return""},jl.SampleEntry.prototype.getSampleRate=function(){return""},jl.SampleEntry.prototype.getSampleSize=function(){return""},jl.SampleEntry.prototype.parseHeader=function(e){this.start=e.position,e.readUint8Array(6),this.data_reference_index=e.readUint16()},jl.SampleEntry.prototype.parseFooter=function(e){for(var t,r;e.position<this.start+this.size;)t=jl.parseOneBox(e,!0),r=t.box,this.boxes.push(r),this[r.type]=r},jl.SampleEntry.prototype.parse=function(e){this.parseHeader(e),e.seek(this.start+this.size)},jl.VisualSampleEntry.prototype.parse=function(e){this.parseHeader(e),e.readUint16(),e.readUint16(),e.readUint32Array(3),this.width=e.readUint16(),this.height=e.readUint16(),this.horizresolution=e.readUint32(),this.vertresolution=e.readUint32(),e.readUint32(),this.frame_count=e.readUint16(),this.compressorname=e.readString(32),this.depth=e.readUint16(),e.readUint16(),this.parseFooter(e)},jl.VisualSampleEntry.prototype.isVideo=function(){return!0},jl.VisualSampleEntry.prototype.getWidth=function(){return this.width},jl.VisualSampleEntry.prototype.getHeight=function(){return this.height},jl.AudioSampleEntry.prototype.parse=function(e){this.parseHeader(e),e.readUint32Array(2),this.channel_count=e.readUint16(),this.samplesize=e.readUint16(),e.readUint16(),e.readUint16(),this.samplerate=e.readUint32()/65536,this.parseFooter(e)},jl.AudioSampleEntry.prototype.isAudio=function(){return!0},jl.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count},jl.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate},jl.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize},jl.SubtitleSampleEntry.prototype.isSubtitle=function(){return!0},jl.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint8Array(this.size)},jl.ftypBox.prototype.parse=function(e){this.major_brand=e.readString(4),this.minor_version=e.readUint32(),this.size-=8,this.compatible_brands=[];for(var t=0;this.size>=4;)this.compatible_brands[t]=e.readString(4),this.size-=4,t++},jl.mvhdBox.prototype.parse=function(e){this.flags=0,this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.rate=e.readUint32(),this.volume=e.readUint16()>>8,e.readUint16(),e.readUint32Array(2),this.matrix=e.readUint32Array(9),e.readUint32Array(6),this.next_track_id=e.readUint32()},jl.TKHD_FLAG_ENABLED=1,jl.TKHD_FLAG_IN_MOVIE=2,jl.TKHD_FLAG_IN_PREVIEW=4,jl.tkhdBox.prototype.parse=function(e){this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint32()),e.readUint32Array(2),this.layer=e.readInt16(),this.alternate_group=e.readInt16(),this.volume=e.readInt16()>>8,e.readUint16(),this.matrix=e.readInt32Array(9),this.width=e.readUint32(),this.height=e.readUint32()
},jl.mdhdBox.prototype.parse=function(e){this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.language=e.readUint16();var t=[];t[0]=this.language>>10&31,t[1]=this.language>>5&31,t[2]=31&this.language,this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96),e.readUint16()},jl.hdlrBox.prototype.parse=function(e){this.parseFullHeader(e),0===this.version?(e.readUint32(),this.handler=e.readString(4),e.readUint32Array(3),this.name=e.readCString()):this.data=e.readUint8Array(size)},jl.stsdBox.prototype.parse=function(e){var t,r;for(this.parseFullHeader(e),r=e.readUint32(),i=1;r>=i;i++)t=jl.parseOneBox(e,!0),this.entries.push(t.box)},jl.avcCBox.prototype.parse=function(e){var t,r,i;for(this.configurationVersion=e.readUint8(),this.AVCProfileIndication=e.readUint8(),this.profile_compatibility=e.readUint8(),this.AVCLevelIndication=e.readUint8(),this.lengthSizeMinusOne=3&e.readUint8(),r=31&e.readUint8(),this.size-=6,this.SPS=new Array(r),t=0;r>t;t++)i=e.readUint16(),this.SPS[t]=e.readUint8Array(i),this.size-=2+i;for(r=e.readUint8(),this.size--,this.PPS=new Array(r),t=0;r>t;t++)i=e.readUint16(),this.PPS[t]=e.readUint8Array(i),this.size-=2+i;this.size>0&&(this.ext=e.readUint8Array(this.size))},jl.avc1Box.prototype.getCodec=function(){var e=jl.SampleEntry.prototype.getCodec.call(this);return this.avcC?e+"."+ti(this.avcC.AVCProfileIndication)+ti(this.avcC.profile_compatibility)+ti(this.avcC.AVCLevelIndication):e},jl.mp4aBox.prototype.getCodec=function(){var e=jl.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI(),r=this.esds.esd.getAudioConfig();return e+"."+ti(t)+(r?"."+r:"")}return e},jl.esdsBox.prototype.parse=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size),this.size=0;var t=new zl;this.esd=t.parseOneDescriptor(new Ml(this.data.buffer,0,Ml.BIG_ENDIAN))},jl.cttsBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.sample_counts=[],this.sample_offsets=[],0===this.version)for(r=0;t>r;r++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readUint32());else if(1==this.version)for(r=0;t>r;r++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readInt32());else this.data=e.readUint8Array(this.size-4)},jl.cttsBox.prototype.unpack=function(e){var t,r,i;for(i=0,t=0;t<this.sample_counts.length;t++)for(r=0;r<this.sample_counts[t];r++)e[i].pts=e[i].dts+this.sample_offsets[t],i++},jl.cslgBox.prototype.parse=function(e){this.parseFullHeader(e),0===this.version?(this.compositionToDTSShift=e.readInt32(),this.leastDecodeToDisplayDelta=e.readInt32(),this.greatestDecodeToDisplayDelta=e.readInt32(),this.compositionStartTime=e.readInt32(),this.compositionEndTime=e.readInt32()):this.data=e.readUint8Array(this.size-4)},jl.sttsBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.sample_counts=[],this.sample_deltas=[],0===this.version)for(r=0;t>r;r++)this.sample_counts.push(e.readUint32()),this.sample_deltas.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},jl.sttsBox.prototype.unpack=function(e){var t,r,i;for(i=0,t=0;t<this.sample_counts.length;t++)for(r=0;r<this.sample_counts[t];r++)e[i].dts=0===i?0:e[i-1].dts+this.sample_deltas[t],i++},jl.stssBox.prototype.parse=function(e){var t;this.parseFullHeader(e),t=e.readUint32(),0===this.version?this.sample_numbers=e.readUint32Array(t):this.data=e.readUint8Array(this.size-4)},jl.stshBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],0===this.version)for(r=0;t>r;r++)this.shadowed_sample_numbers.push(e.readUint32()),this.sync_sample_numbers.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},jl.stcoBox.prototype.parse=function(e){var t;this.parseFullHeader(e),t=e.readUint32(),0===this.version?this.chunk_offsets=e.readUint32Array(t):this.data=e.readUint8Array(this.size-4)},jl.stcoBox.prototype.unpack=function(e){var t;for(t=0;t<this.chunk_offsets.length;t++)e[t].offset=this.chunk_offsets[t]},jl.co64Box.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.chunk_offsets=[],0===this.version)for(r=0;t>r;r++)this.chunk_offsets.push(e.readUint64());else this.data=e.readUint8Array(this.size-4)},jl.stscBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],0===this.version)for(r=0;t>r;r++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},jl.stscBox.prototype.unpack=function(e){var t,r,i,n,s;for(n=0,s=0,t=0;t<this.first_chunk.length;t++)for(r=0;r<(t+1<this.first_chunk.length?this.first_chunk[t+1]:1/0);r++)for(s++,i=0;i<this.samples_per_chunk[t];i++){if(!e[n])return;e[n].description_index=this.sample_description_index[t],e[n].chunk_index=s,n++}},jl.stszBox.prototype.parse=function(e){var t,r,i;if(this.parseFullHeader(e),this.sample_sizes=[],0===this.version)if(r=e.readUint32(),i=e.readUint32(),0===r)this.sample_sizes=e.readUint32Array(i);else for(this.sample_sizes=[],t=0;i>t;t++)this.sample_sizes[t]=r;else this.data=e.readUint8Array(this.size)},jl.stszBox.prototype.unpack=function(e){var t;for(t=0;t<this.sample_sizes.length;t++)e[t].size=this.sample_sizes[t]},jl.mehdBox.prototype.parse=function(e){this.parseFullHeader(e),this.fragment_duration=1==this.version?e.readUint64():e.readUint32()},jl.trexBox.prototype.parse=function(e){this.parseFullHeader(e),this.track_id=e.readUint32(),this.default_sample_description_index=e.readUint32(),this.default_sample_duration=e.readUint32(),this.default_sample_size=e.readUint32(),this.default_sample_flags=e.readUint32()},jl.mfhdBox.prototype.parse=function(e){this.parseFullHeader(e),this.sequence_number=e.readUint32()},jl.TFHD_FLAG_BASE_DATA_OFFSET=1,jl.TFHD_FLAG_SAMPLE_DESC=2,jl.TFHD_FLAG_SAMPLE_DUR=8,jl.TFHD_FLAG_SAMPLE_SIZE=16,jl.TFHD_FLAG_SAMPLE_FLAGS=32,jl.TFHD_FLAG_DUR_EMPTY=65536,jl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072,jl.tfhdBox.prototype.parse=function(e){var t=0;this.parseFullHeader(e),this.track_id=e.readUint32(),this.size>t&&this.flags&jl.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size>t&&this.flags&jl.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size>t&&this.flags&jl.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size>t&&this.flags&jl.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size>t&&this.flags&jl.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0},jl.TRUN_FLAGS_DATA_OFFSET=1,jl.TRUN_FLAGS_FIRST_FLAG=4,jl.TRUN_FLAGS_DURATION=256,jl.TRUN_FLAGS_SIZE=512,jl.TRUN_FLAGS_FLAGS=1024,jl.TRUN_FLAGS_CTS_OFFSET=2048,jl.trunBox.prototype.parse=function(e){var t=0;if(this.parseFullHeader(e),this.sample_count=e.readUint32(),t+=4,this.size>t&&this.flags&jl.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size>t&&this.flags&jl.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size>t)for(var r=0;r<this.sample_count;r++)this.flags&jl.TRUN_FLAGS_DURATION&&(this.sample_duration[r]=e.readUint32()),this.flags&jl.TRUN_FLAGS_SIZE&&(this.sample_size[r]=e.readUint32()),this.flags&jl.TRUN_FLAGS_FLAGS&&(this.sample_flags[r]=e.readUint32()),this.flags&jl.TRUN_FLAGS_CTS_OFFSET&&(this.sample_composition_time_offset[r]=0===this.version?e.readUint32():e.readInt32())},jl.tfdtBox.prototype.parse=function(e){this.parseFullHeader(e),this.baseMediaDecodeTime=1==this.version?e.readUint64():e.readUint32()},jl.paylBox.prototype.parse=function(e){this.text=e.readString(this.size)},jl.subsBox.prototype.parse=function(e){var t,r,i,n;for(this.parseFullHeader(e),i=e.readUint32(),this.samples=[],t=0;i>t;t++){var s={};if(this.samples[t]=s,s.sample_delta=e.readUint32(),s.subsamples=[],n=e.readUint16(),n>0)for(r=0;n>r;r++){var a={};s.subsamples.push(a),a.size=1==this.version?e.readUint32():e.readUint16(),a.priority=e.readUint8(),a.discardable=e.readUint8(),a.reserved=e.readUint32()}}},jl.Box.prototype.writeHeader=function(e,t){this.size+=8,this.size>Hl&&(this.size+=8),Vl.d("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.position+(t||"")),this.size>Hl?e.writeUint32(1):(this.sizePosition=e.position,e.writeUint32(this.size)),e.writeString(this.type,null,4),this.size>Hl&&e.writeUint64(this.size)},jl.FullBox.prototype.writeHeader=function(e){this.size+=4,jl.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},jl.Box.prototype.write=function(e){"mdat"===this.type?this.data&&(this.size=this.data.length,this.writeHeader(e),e.writeUint8Array(this.data)):(this.size=this.data.length,this.writeHeader(e),e.writeUint8Array(this.data))},jl.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t<this.boxes.length;t++)this.boxes[t]&&(this.boxes[t].write(e),this.size+=this.boxes[t].size);Vl.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},jl.TrackReferenceTypeBox.prototype.write=function(e){this.size=4*this.track_ids.length,this.writeHeader(e),e.writeUint32Array(this.track_ids)},jl.ftypBox.prototype.write=function(e){this.size=8+4*this.compatible_brands.length,this.writeHeader(e),e.writeString(this.major_brand,null,4),e.writeUint32(this.minor_version);for(var t=0;t<this.compatible_brands.length;t++)e.writeString(this.compatible_brands[t],null,4)},jl.mvhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=96,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.timescale),e.writeUint32(this.duration),e.writeUint32(this.rate),e.writeUint16(this.volume<<8),e.writeUint16(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32Array(this.matrix),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(this.next_track_id)},jl.tkhdBox.prototype.write=function(e){this.version=0,this.size=80,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.track_id),e.writeUint32(0),e.writeUint32(this.duration),e.writeUint32(0),e.writeUint32(0),e.writeInt16(this.layer),e.writeInt16(this.alternate_group),e.writeInt16(this.volume<<8),e.writeUint16(0),e.writeInt32Array(this.matrix),e.writeUint32(this.width),e.writeUint32(this.height)},jl.mdhdBox.prototype.write=function(e){this.size=20,this.flags=0,this.version=0,this.writeHeader(e),e.writeUint32(this.creation_time),e.writeUint32(this.modification_time),e.writeUint32(this.timescale),e.writeUint32(this.duration),e.writeUint16(this.language),e.writeUint16(0)},jl.hdlrBox.prototype.write=function(e){this.size=20+this.name.length+1,this.version=0,this.flags=0,this.writeHeader(e),e.writeUint32(0),e.writeString(this.handler,null,4),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeCString(this.name)},jl.stsdBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=0,this.writeHeader(e),e.writeUint32(this.entries.length),this.size+=4,t=0;t<this.entries.length;t++)this.entries[t].write(e),this.size+=this.entries[t].size;Vl.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},jl.SampleEntry.prototype.writeHeader=function(e){this.size=8,jl.Box.prototype.writeHeader.call(this,e),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint8(0),e.writeUint16(this.data_reference_index)},jl.SampleEntry.prototype.writeFooter=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e),this.size+=this.boxes[t].size;Vl.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),e.adjustUint32(this.sizePosition,this.size)},jl.SampleEntry.prototype.write=function(e){this.writeHeader(e),this.writeFooter(e)},jl.VisualSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=70,e.writeUint16(0),e.writeUint16(0),e.writeUint32(0),e.writeUint32(0),e.writeUint32(0),e.writeUint16(this.width),e.writeUint16(this.height),e.writeUint32(this.horizresolution),e.writeUint32(this.vertresolution),e.writeUint32(0),e.writeUint16(this.frame_count),e.writeString(this.compressorname,null,32),e.writeUint16(this.depth),e.writeInt16(-1),this.writeFooter(e)},jl.AudioSampleEntry.prototype.write=function(e){this.writeHeader(e),this.size+=20,e.writeUint32(0),e.writeUint32(0),e.writeUint16(this.channel_count),e.writeUint16(this.samplesize),e.writeUint16(0),e.writeUint16(0),e.writeUint32(this.samplerate<<16),this.writeFooter(e)},jl.avcCBox.prototype.write=function(e){var t;for(this.size=7,t=0;t<this.SPS.length;t++)this.size+=2+this.SPS[t].length;for(t=0;t<this.PPS.length;t++)this.size+=2+this.PPS[t].length;for(this.ext&&(this.size+=this.ext.length),this.writeHeader(e),e.writeUint8(this.configurationVersion),e.writeUint8(this.AVCProfileIndication),e.writeUint8(this.profile_compatibility),e.writeUint8(this.AVCLevelIndication),e.writeUint8(this.lengthSizeMinusOne+252),e.writeUint8(this.SPS.length+224),t=0;t<this.SPS.length;t++)e.writeUint16(this.SPS[t].length),e.writeUint8Array(this.SPS[t]);for(e.writeUint8(this.PPS.length),t=0;t<this.PPS.length;t++)e.writeUint16(this.PPS[t].length),e.writeUint8Array(this.PPS[t]);this.ext&&e.writeUint8Array(this.ext)},jl.cttsBox.prototype.write=function(e){var t;for(this.version=1,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(e),e.writeUint32(this.sample_counts.length),t=0;t<this.sample_counts.length;t++)e.writeUint32(this.sample_counts[t]),e.writeInt32(this.sample_offsets[t])},jl.cslgBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20,this.writeHeader(e),e.writeInt32(this.compositionToDTSShift),e.writeInt32(this.leastDecodeToDisplayDelta),e.writeInt32(this.greatestDecodeToDisplayDelta),e.writeInt32(this.compositionStartTime),e.writeInt32(this.compositionEndTime)},jl.sttsBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(e),e.writeUint32(this.sample_counts.length),t=0;t<this.sample_counts.length;t++)e.writeUint32(this.sample_counts[t]),e.writeUint32(this.sample_deltas[t])},jl.stssBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+4*this.sample_numbers.length,this.writeHeader(e),e.writeUint32(this.sample_numbers.length),e.writeUint32Array(this.sample_numbers)},jl.stshBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.shadowed_sample_numbers.length,this.writeHeader(e),e.writeUint32(this.shadowed_sample_numbers.length),t=0;t<this.shadowed_sample_numbers.length;t++)e.writeUint32(this.shadowed_sample_numbers[t]),e.writeUint32(this.sync_sample_numbers[t])},jl.stcoBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4+4*this.chunk_offsets.length,this.writeHeader(e),e.writeUint32(this.chunk_offsets.length),e.writeUint32Array(this.chunk_offsets)},jl.co64Box.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+8*this.chunk_offsets.length,this.writeHeader(e),e.writeUint32(this.chunk_offsets.length),t=0;t<this.chunk_offsets.length;t++)e.writeUint64(this.chunk_offsets[t])},jl.stscBox.prototype.write=function(e){var t;for(this.version=0,this.flags=0,this.size=4+12*this.first_chunk.length,this.writeHeader(e),e.writeUint32(this.first_chunk.length),t=0;t<this.first_chunk.length;t++)e.writeUint32(this.first_chunk[t]),e.writeUint32(this.samples_per_chunk[t]),e.writeUint32(this.sample_description_index[t])},jl.stszBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=8+12*this.sample_sizes.length,this.writeHeader(e),e.writeUint32(0),e.writeUint32(this.sample_sizes.length),e.writeUint32Array(this.sample_sizes)},jl.mehdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.fragment_duration)},jl.trexBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=20,this.writeHeader(e),e.writeUint32(this.track_id),e.writeUint32(this.default_sample_description_index),e.writeUint32(this.default_sample_duration),e.writeUint32(this.default_sample_size),e.writeUint32(this.default_sample_flags)},jl.mfhdBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),e.writeUint32(this.sequence_number)},jl.tfhdBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&jl.TFHD_FLAG_BASE_OFFSET&&(this.size+=8),this.flags&jl.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&jl.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&jl.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&jl.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(e),e.writeUint32(this.track_id),this.flags&jl.TFHD_FLAG_BASE_OFFSET&&e.writeUint64(this.base_data_offset),this.flags&jl.TFHD_FLAG_SAMPLE_DESC&&e.writeUint32(this.default_sample_description_index),this.flags&jl.TFHD_FLAG_SAMPLE_DUR&&e.writeUint32(this.default_sample_duration),this.flags&jl.TFHD_FLAG_SAMPLE_SIZE&&e.writeUint32(this.default_sample_size),this.flags&jl.TFHD_FLAG_SAMPLE_FLAGS&&e.writeUint32(this.default_sample_flags)},jl.trunBox.prototype.write=function(e){this.version=0,this.size=4,this.flags&jl.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&jl.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&jl.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&jl.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&jl.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&jl.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(e),e.writeUint32(this.sample_count),this.flags&jl.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=e.position,e.writeInt32(this.data_offset)),this.flags&jl.TRUN_FLAGS_FIRST_FLAG&&e.writeUint32(this.first_sample_flags);for(var t=0;t<this.sample_count;t++)this.flags&jl.TRUN_FLAGS_DURATION&&e.writeUint32(this.sample_duration[t]),this.flags&jl.TRUN_FLAGS_SIZE&&e.writeUint32(this.sample_size[t]),this.flags&jl.TRUN_FLAGS_FLAGS&&e.writeUint32(this.sample_flags[t]),this.flags&jl.TRUN_FLAGS_CTS_OFFSET&&(0===this.version?e.writeUint32(this.sample_composition_time_offset[t]):e.writeInt32(this.sample_composition_time_offset[t]))},jl.tfdtBox.prototype.write=function(e){this.version=0,this.flags=0,this.size=4,this.writeHeader(e),1==this.version?e.writeUint64(this.baseMediaDecodeTime):e.writeUint32(this.baseMediaDecodeTime)};var zl=function(){var e=3,t=4,r=5,i=6,n=[];n[e]="ES_Descriptor",n[t]="DecoderConfigDescriptor",n[r]="DecoderSpecificInfo",n[i]="SLConfigDescriptor";var s=this,a={};return this.parseOneDescriptor=function(e){var t,r,i,s=0,o=0;for(t=e.readUint8(),s++,i=e.readUint8(),s++;128&i;)o=(127&i)<<7,i=e.readUint8(),s++;return o+=127&i,Vl.d("MPEG4DescriptorParser","Found "+(n[t]|"Descriptor "+t)+", size "+o+" at position "+e.position),r=n[t]?new a[n[t]](o):new a.Descriptor(o),r.parse(e),r},a.Descriptor=function(e,t){this.tag=e,this.size=t,this.descs=[]},a.Descriptor.prototype.parse=function(e){this.data=e.readUint8Array(this.size)},a.Descriptor.prototype.findDescriptor=function(e){for(var t=0;t<this.descs.length;t++)if(this.descs[t].tag==e)return this.descs[t];return null},a.Descriptor.prototype.parseRemainingDescriptors=function(e){for(var t=e.position;e.position<t+this.size;){var r=s.parseOneDescriptor(e);this.descs.push(r)}},a.ES_Descriptor=function(t){a.Descriptor.call(this,e,t)},a.ES_Descriptor.prototype=new a.Descriptor,a.ES_Descriptor.prototype.parse=function(e){if(this.ES_ID=e.readUint16(),this.flags=e.readUint8(),this.size-=3,128&this.flags?(this.dependsOn_ES_ID=e.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,64&this.flags){var t=e.readUint8();this.URL=e.readString(t),this.size-=t+1}else this.URL=null;32&this.flags?(this.OCR_ES_ID=e.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(e)},a.ES_Descriptor.prototype.getOTI=function(){var e=this.findDescriptor(t);return e?e.oti:0},a.ES_Descriptor.prototype.getAudioConfig=function(){var e=this.findDescriptor(t);if(!e)return null;var i=e.findDescriptor(r);return i&&i.data?(248&i.data[0])>>3:null},a.DecoderConfigDescriptor=function(e){a.Descriptor.call(this,t,e)},a.DecoderConfigDescriptor.prototype=new a.Descriptor,a.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},a.DecoderSpecificInfo=function(e){a.Descriptor.call(this,r,e)},a.DecoderSpecificInfo.prototype=new a.Descriptor,a.SLConfigDescriptor=function(e){a.Descriptor.call(this,i,e)},a.SLConfigDescriptor.prototype=new a.Descriptor,this},Kl=function(e){this.stream=e,this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=!1,this.lastMoofIndex=0,this.lastPosition=0,this.parsingMdat=!1,this.moovStartFound=!1,this.samplesDataSize=0,this.nextParsePosition=0};Kl.prototype.repositionAtMdatEnd=function(e,t){var r;for(r=this.stream.bufferIndex;r<this.stream.nextBuffers.length;r++){var i=this.stream.nextBuffers[r];if(e.fileStart+t>=i.fileStart){if(e.fileStart+t<=i.fileStart+i.byteLength)return this.parsingMdat=!1,this.stream.buffer=i,this.stream.bufferIndex=r,this.stream.position=e.fileStart+t-i.fileStart,Vl.d("ISOFile","Found 'mdat' end in buffer #"+this.stream.bufferIndex+" at position "+this.lastPosition),!0;e.buffers.push(i)}}return!1},Kl.prototype.findEndContiguousBuf=function(){var e,t,r;if(this.nextSeekPosition)for(e=0;e<this.stream.nextBuffers.length&&(r=this.stream.nextBuffers[e],r.fileStart<=this.nextSeekPosition);e++)t=this.stream.nextBuffers[e],this.stream.bufferIndex=e;else t=this.stream.nextBuffers[this.stream.bufferIndex];if(this.stream.nextBuffers.length>this.stream.bufferIndex)for(e=this.stream.bufferIndex+1;e<this.stream.nextBuffers.length&&(r=this.stream.nextBuffers[e],r.fileStart===t.fileStart+t.byteLength);e++)t=r,this.stream.bufferIndex=e;return t.fileStart+t.byteLength>=this.nextSeekPosition&&delete this.nextSeekPosition,t.fileStart+t.byteLength},Kl.prototype.parse=function(){var e,t,r;for(Vl.d("ISOFile","Starting parsing with buffer #"+this.stream.bufferIndex+" from position "+this.lastPosition+" ("+(this.stream.buffer.fileStart+this.lastPosition)+" in the file)"),this.stream.seek(this.lastPosition);;){if(this.parsingMdat){if(r=this.mdats[this.mdats.length-1],e=this.repositionAtMdatEnd(r,r.size+r.hdr_size))continue;return void(this.nextParsePosition=this.findEndContiguousBuf())}if(this.lastPosition=this.stream.position,t=jl.parseOneBox(this.stream),t.code==jl.ERR_NOT_ENOUGH_DATA){if("mdat"===t.type){if(this.parsingMdat=!0,r=new jl[t.type+"Box"](t.size-t.hdr_size),this.mdats.push(r),r.fileStart=this.stream.buffer.fileStart+this.stream.position,r.hdr_size=t.hdr_size,r.buffers=[],r.buffers[0]=this.stream.buffer,this.stream.buffer.usedBytes+=t.hdr_size,e=this.repositionAtMdatEnd(r,r.size+r.hdr_size))continue;return void(this.nextParsePosition=this.moovStartFound?this.findEndContiguousBuf():r.fileStart+r.size+r.hdr_size)}if("moov"===t.type&&(this.moovStartFound=!0),this.stream.bufferIndex<this.stream.nextBuffers.length-1){var i=this.stream.nextBuffers[this.stream.bufferIndex+1];if(i.fileStart===this.stream.buffer.fileStart+this.stream.buffer.byteLength){var n=this.stream.buffer.byteLength,s=this.stream.buffer.usedBytes,a=this.stream.buffer.fileStart;this.stream.nextBuffers[this.stream.bufferIndex]=ArrayBuffer.concat(this.stream.buffer,i),this.stream.buffer=this.stream.nextBuffers[this.stream.bufferIndex],this.stream.nextBuffers.splice(this.stream.bufferIndex+1,1),this.stream.buffer.usedBytes=s,this.stream.buffer.fileStart=a,this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength,Vl.d("ISOFile","Concatenating buffer for box parsing (length: "+n+"->"+this.stream.buffer.byteLength+")");continue}return void(this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength)}return void(this.nextParsePosition=t.type?this.moovStartFound?this.stream.buffer.fileStart+this.stream.buffer.byteLength:this.stream.buffer.fileStart+this.stream.position+t.size:this.stream.buffer.fileStart+this.stream.buffer.byteLength)}switch(r=t.box,this.boxes.push(r),r.type){case"mdat":this.mdats.push(r),r.fileStart=this.stream.buffer.fileStart+r.start,r.buffers=[this.stream.buffer],this.stream.buffer.usedBytes+=r.hdr_size;break;case"moof":this.moofs.push(r),this.stream.buffer.usedBytes+=t.size;break;case"moov":this.moovStartFound=!0,0===this.mdats.length&&(this.isProgressive=!0),this[r.type]=r,this.stream.buffer.usedBytes+=t.size;break;default:this[r.type]=r,this.stream.buffer.usedBytes+=t.size}}},Kl.prototype.write=function(e){for(var t=0;t<this.boxes.length;t++)this.boxes[t].write(e)},Kl.prototype.writeInitializationSegment=function(e){var t;if(Vl.d("ISOFile","Generating initialization segment"),this.ftyp.write(e),this.moov.mvex){var r;for(this.initial_duration=this.moov.mvex.fragment_duration,t=0;t<this.moov.boxes.length;t++){var i=this.moov.boxes[t];i==this.moov.mvex&&(r=t)}r>-1&&this.moov.boxes.splice(r,1)}var n=new jl.mvexBox;this.moov.boxes.push(n);var s=new jl.mehdBox;for(n.boxes.push(s),s.fragment_duration=this.initial_duration,t=0;t<this.moov.traks.length;t++){var a=new jl.trexBox;n.boxes.push(a),a.track_id=this.moov.traks[t].tkhd.track_id,a.default_sample_description_index=1,a.default_sample_duration=this.moov.traks[t].samples.length>0?this.moov.traks[t].samples[0].duration:0,a.default_sample_size=0,a.default_sample_flags=65536}this.moov.write(e)},Kl.prototype.resetTables=function(){var e,t,r,i,n,s,a,o;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;e<this.moov.traks.length;e++){t=this.moov.traks[e],t.tkhd.duration=0,t.mdia.mdhd.duration=0,r=t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64,r.chunk_offsets=[],i=t.mdia.minf.stbl.stsc,i.first_chunk=[],i.samples_per_chunk=[],i.sample_description_index=[],n=t.mdia.minf.stbl.stsz,n.sample_sizes=[],s=t.mdia.minf.stbl.stts,s.sample_counts=[],s.sample_deltas=[],a=t.mdia.minf.stbl.ctts,a&&(a.sample_counts=[],a.sample_offsets=[]),o=t.mdia.minf.stbl.stss;var c=t.mdia.minf.stbl.boxes.indexOf(o);-1!=c&&(t.mdia.minf.stbl.boxes[c]=null)}},Kl.prototype.buildSampleLists=function(){var e,t,r,i,n,s,a,o,c,l,h,u,d,f,p,_,g,m,y,v,b;for(e=0;e<this.moov.traks.length;e++){for(r=this.moov.traks[e],r.samples=[],i=r.mdia.minf.stbl.stco||r.mdia.minf.stbl.co64,n=r.mdia.minf.stbl.stsc,s=r.mdia.minf.stbl.stsz,a=r.mdia.minf.stbl.stts,o=r.mdia.minf.stbl.ctts,c=r.mdia.minf.stbl.stss,l=r.mdia.minf.stbl.stsd,h=r.mdia.minf.stbl.subs,d=-1,u=-1,f=-1,p=0,_=0,g=-1,m=-1,y=-1,v=-1,b=0,subs_entry_index=0,last_subs_sample_index=0,t=0;t<s.sample_sizes.length;t++){var w={};w.track_id=r.tkhd.track_id,w.timescale=r.mdia.mdhd.timescale,r.samples[t]=w,w.size=s.sample_sizes[t],_>t?(w.chunk_index=d,w.chunk_run_index=u):(p=0,d++,w.chunk_index=d,f>d?w.chunk_run_index=u:u<n.first_chunk.length-2?(u++,f=n.first_chunk[u+1]-1):f=1/0,_+=n.samples_per_chunk[u],w.chunk_run_index=u),w.description=l.entries[n.sample_description_index[w.chunk_run_index]-1],w.offset=i.chunk_offsets[w.chunk_index]+p,p+=w.size,t>=g&&(m++,0>g&&(g=0),g+=a.sample_counts[m]),t>0?(w.dts=r.samples[t-1].dts+a.sample_deltas[m],r.samples[t-1].duration=w.dts-r.samples[t-1].dts):w.dts=0,o?(t>=y&&(v++,0>y&&(y=0),y+=o.sample_counts[v]),w.cts=r.samples[t].dts+o.sample_offsets[v]):w.cts=w.dts,c?t==c.sample_numbers[b]-1?(w.is_rap=!0,b++):w.is_rap=!1:w.is_rap=!0,h&&h.samples[subs_entry_index].sample_delta+last_subs_sample_index==t&&(w.subsamples=h.samples[subs_entry_index].subsamples,last_subs_sample_index+=h.samples[subs_entry_index].sample_delta)}t>0&&(r.samples[t-1].duration=r.mdia.mdhd.duration-r.samples[t-1].dts)}},Kl.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t<this.moov.mvex.trexs.length;t++){var r=this.moov.mvex.trexs[t];if(r.track_id==e)return r}return null},Kl.prototype.updateSampleLists=function(){for(var e,t,r,i,n,s,a,o,c,l,h,u,d,f;this.lastMoofIndex<this.moofs.length;)if(c=this.moofs[this.lastMoofIndex],this.lastMoofIndex++,"moof"==c.type)for(l=c,e=0;e<l.trafs.length;e++){for(h=l.trafs[e],u=this.getTrackById(h.tfhd.track_id),d=this.getTrexById(h.tfhd.track_id),i=h.tfhd.flags&jl.TFHD_FLAG_SAMPLE_DESC?h.tfhd.default_sample_description_index:d.default_sample_description_index,n=h.tfhd.flags&jl.TFHD_FLAG_SAMPLE_DUR?h.tfhd.default_sample_duration:d.default_sample_duration,s=h.tfhd.flags&jl.TFHD_FLAG_SAMPLE_SIZE?h.tfhd.default_sample_size:d.default_sample_size,a=h.tfhd.flags&jl.TFHD_FLAG_SAMPLE_FLAGS?h.tfhd.default_sample_flags:d.default_sample_flags,t=0;t<h.truns.length;t++){var p=h.truns[t];for(r=0;r<p.sample_count;r++){f={},h.first_sample_index=u.samples.length,u.samples.push(f),f.track_id=u.tkhd.track_id,f.timescale=u.mdia.mdhd.timescale,f.description=u.mdia.minf.stbl.stsd.entries[i-1],f.size=s,p.flags&jl.TRUN_FLAGS_SIZE&&(f.size=p.sample_size[r]),f.duration=n,p.flags&jl.TRUN_FLAGS_DURATION&&(f.duration=p.sample_duration[r]),u.first_traf_merged||r>0?f.dts=u.samples[u.samples.length-2].dts+u.samples[u.samples.length-2].duration:(f.dts=h.tfdt?h.tfdt.baseMediaDecodeTime:0,u.first_traf_merged=!0),f.cts=f.dts,p.flags&jl.TRUN_FLAGS_CTS_OFFSET&&(f.cts=f.dts+p.sample_composition_time_offset[r]),sample_flags=a,p.flags&jl.TRUN_FLAGS_FLAGS?sample_flags=p.sample_flags[r]:0===r&&p.flags&jl.TRUN_FLAGS_FIRST_FLAG&&(sample_flags=p.first_sample_flags),f.is_rap=sample_flags>>16&1?!1:!0;var _=h.tfhd.flags&jl.TFHD_FLAG_BASE_DATA_OFFSET?!0:!1,g=h.tfhd.flags&jl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF?!0:!1,m=p.flags&jl.TRUN_FLAGS_DATA_OFFSET?!0:!1,y=0;y=_?h.tfhd.base_data_offset:g?l.fileStart:0===t?l.fileStart:o,f.offset=0===t&&0===r?m?y+p.data_offset:y:o,o=f.offset+f.size}}if(h.subs){var v=h.first_sample_index;for(t=0;t<h.subs.samples.length;t++)v+=h.subs.samples[t].sample_delta,f=u.samples[v-1],f.subsamples=h.subs.samples[t].subsamples}}},Kl.prototype.getCodecs=function(){var e,t="";for(e=0;e<this.moov.traks.length;e++){var r=this.moov.traks[e];e>0&&(t+=","),t+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return t},Kl.prototype.getTrackById=function(e){for(var t=0;t<this.moov.traks.length;t++){var r=this.moov.traks[t];if(r.tkhd.track_id==e)return r}return null},Kl.prototype.getSample=function(e,t){var r,i,n,s,a=e.samples[t];if(a.data){if(a.alreadyRead==a.size)return a}else a.data=new Uint8Array(a.size),a.alreadyRead=0,this.samplesDataSize+=a.size,Vl.d("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+a.size+" (total: "+this.samplesDataSize+")");for(n=0;n<this.mdats.length;n++){for(r=this.mdats[n],s=0;s<r.buffers.length;s++)if(i=r.buffers[s],a.offset+a.alreadyRead>=i.fileStart&&a.offset+a.alreadyRead<i.fileStart+i.byteLength){var o=i.byteLength-(a.offset+a.alreadyRead-i.fileStart);if(a.size-a.alreadyRead<=o)return Vl.d("ISOFile","Getting sample #"+t+" data (alreadyRead: "+a.alreadyRead+" offset: "+(a.offset+a.alreadyRead-i.fileStart)+" size: "+(a.size-a.alreadyRead)+")"),Ml.memcpy(a.data.buffer,a.alreadyRead,i,a.offset+a.alreadyRead-i.fileStart,a.size-a.alreadyRead),i.usedBytes+=a.size-a.alreadyRead,a.alreadyRead=a.size,i.usedBytes==i.byteLength&&(r.buffers.splice(s,1),Vl.d("ISOFile","Removing buffer for mdat ("+r.buffers.length+" buffers left)"),s--),a;
Vl.d("ISOFile","Getting sample data (alreadyRead: "+a.alreadyRead+" offset: "+(a.offset+a.alreadyRead-i.fileStart)+" size: "+o+")"),Ml.memcpy(a.data.buffer,a.alreadyRead,i,a.offset+a.alreadyRead-i.fileStart,o),i.usedBytes+=o,i.usedBytes==i.byteLength&&(r.buffers.splice(s,1),Vl.d("ISOFile","Removing buffer for mdat ("+r.buffers.length+" buffers left)"),s--),a.alreadyRead+=o}0===r.buffers.length&&this.mdats.length>1&&(this.mdats.splice(n,1),n--)}return null},Kl.prototype.releaseSample=function(e,t){var r=e.samples[t];return r.data=null,this.samplesDataSize-=r.size,r.size};var Vl=function(){var e=new Date,t=4,r=3,i=2,n=1,s="undefined"!=typeof document&&-1!==document.location.href.indexOf("mp4box")?n:t,a={setLogLevel:function(e){s=e==this.d?n:e==this.i?i:e==this.w?r:e==this.e?t:t},d:function(t,r){n>=s&&console.debug("["+Vl.getDurationString(new Date-e,1e3)+"]","["+t+"]",r)},i:function(t,r){i>=s&&console.info("["+Vl.getDurationString(new Date-e,1e3)+"]","["+t+"]",r)},w:function(t,i){r>=s&&console.warn("["+Vl.getDurationString(new Date-e,1e3)+"]","["+t+"]",i)},e:function(r,i){t>=s&&console.error("["+Vl.getDurationString(new Date-e,1e3)+"]","["+r+"]",i)}};return a}();Vl.getDurationString=function(e,t){function r(e,t){for(var r=""+e,i=r.split(".");i[0].length<t;)i[0]="0"+i[0];return i.join(".")}var i=t||1,n=e/i,s=Math.floor(n/3600);n-=3600*s;var a=Math.floor(n/60);n-=60*a;var o=1e3*n;return n=Math.floor(n),o-=1e3*n,o=Math.floor(o),""+s+":"+r(a,2)+":"+r(n,2)+"."+r(o,3)},Vl.printRanges=function(e){var t=e.length;if(t>0){for(var r="",i=0;t>i;i++)i>0&&(r+=","),r+="["+Vl.getDurationString(e.start(i))+","+Vl.getDurationString(e.end(i))+"]";return r}return"(empty)"};var Gl=function(){this.inputStream=null,this.nextBuffers=[],this.inputIsoFile=null,this.onMoovStart=null,this.moovStartSent=!1,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.sampleListBuilt=!1,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationStarted=!1,this.nextMoofNumber=0};Gl.prototype.setSegmentOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n),n.id=e,n.user=t,n.trak=i,i.nextSample=0,n.segmentStream=null,n.nb_samples=1e3,n.rapAlignement=!0,r&&(r.nbSamples&&(n.nb_samples=r.nbSamples),r.rapAlignement&&(n.rapAlignement=r.rapAlignement))}},Gl.prototype.unsetSegmentOptions=function(e){for(var t=-1,r=0;r<this.fragmentedTracks.length;r++){var i=this.fragmentedTracks[r];i.id==e&&(t=r)}t>-1&&this.fragmentedTracks.splice(t,1)},Gl.prototype.setExtractionOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.extractedTracks.push(n),n.id=e,n.user=t,n.trak=i,i.nextSample=0,n.nb_samples=1e3,n.samples=[],r&&r.nbSamples&&(n.nb_samples=r.nbSamples)}},Gl.prototype.unsetExtractionOptions=function(e){for(var t=-1,r=0;r<this.extractedTracks.length;r++){var i=this.extractedTracks[r];i.id==e&&(t=r)}t>-1&&this.extractedTracks.splice(t,1)},Gl.prototype.createSingleSampleMoof=function(e){var t=new jl.moofBox,r=new jl.mfhdBox;r.sequence_number=this.nextMoofNumber,this.nextMoofNumber++,t.boxes.push(r);var i=new jl.trafBox;t.boxes.push(i);var n=new jl.tfhdBox;i.boxes.push(n),n.track_id=e.track_id,n.flags=jl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF;var s=new jl.tfdtBox;i.boxes.push(s),s.baseMediaDecodeTime=e.dts;var a=new jl.trunBox;return i.boxes.push(a),t.trun=a,a.flags=jl.TRUN_FLAGS_DATA_OFFSET|jl.TRUN_FLAGS_DURATION|jl.TRUN_FLAGS_SIZE|jl.TRUN_FLAGS_FLAGS|jl.TRUN_FLAGS_CTS_OFFSET,a.data_offset=0,a.first_sample_flags=0,a.sample_count=1,a.sample_duration=[],a.sample_duration[0]=e.duration,a.sample_size=[],a.sample_size[0]=e.size,a.sample_flags=[],a.sample_flags[0]=0,a.sample_composition_time_offset=[],a.sample_composition_time_offset[0]=e.cts-e.dts,t},Gl.prototype.createFragment=function(e,t,r,i){var n=this.inputIsoFile.getTrackById(t),s=this.inputIsoFile.getSample(n,r);if(null==s)return null;var a=i||new Ml;a.endianness=Ml.BIG_ENDIAN;var o=this.createSingleSampleMoof(s);o.write(a),o.trun.data_offset=o.size+8,Vl.d("BoxWriter","Adjusting data_offset with new value "+o.trun.data_offset),a.adjustUint32(o.trun.data_offset_position,o.trun.data_offset);var c=new jl.mdatBox;return c.data=s.data,c.write(a),a},ArrayBuffer.concat=function(e,t){Vl.d("ArrayBuffer","Trying to create a new buffer of size: "+(e.byteLength+t.byteLength));var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r.buffer},Gl.prototype.insertBuffer=function(e){for(var t,r=!0,i=0;i<this.nextBuffers.length;i++){var n=this.nextBuffers[i];if(e.fileStart<=n.fileStart){if(e.fileStart===n.fileStart){if(e.byteLength>n.byteLength){this.nextBuffers.splice(i,1),i--;continue}Vl.w("MP4Box","Buffer already appended, ignoring")}else e.fileStart+e.byteLength<=n.fileStart?(Vl.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" length:"+e.byteLength+")"),this.nextBuffers.splice(i,0,e),0===i&&null!=this.inputStream&&(this.inputStream.buffer=e)):(t=new Uint8Array(n.fileStart-e.fileStart),t.set(new Uint8Array(e,0,n.fileStart-e.fileStart)),t.fileStart=e.fileStart,e=t,e.usedBytes=0,Vl.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" length:"+e.byteLength+")"),this.nextBuffers.splice(i,0,e),0===i&&null!=this.inputStream&&(this.inputStream.buffer=e));r=!1;break}if(e.fileStart<n.fileStart+n.byteLength){var s=n.fileStart+n.byteLength-e.fileStart,a=e.byteLength-s;t=new Uint8Array(a),t.set(new Uint8Array(e,s,a)),t.buffer.fileStart=e.fileStart+s,e=t.buffer,e.usedBytes=0}}r&&(Vl.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" length:"+e.byteLength+")"),this.nextBuffers.push(e),0===i&&null!=this.inputStream&&(this.inputStream.buffer=e))},Gl.prototype.open=function(){if(!this.inputStream){if(!(this.nextBuffers.length>0))return Vl.w("MP4Box","No buffer to start parsing from"),!1;var e=this.nextBuffers[0];if(0!==e.fileStart)return Vl.w("MP4Box","The first buffer should have a fileStart of 0"),!1;this.inputStream=new Ml(e,0,Ml.BIG_ENDIAN),this.inputStream.nextBuffers=this.nextBuffers,this.inputStream.bufferIndex=0}if(this.inputIsoFile||(this.inputIsoFile=new Kl(this.inputStream)),this.inputIsoFile.parse(),this.inputIsoFile.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.inputIsoFile.moov){if(this.sampleListBuilt||(this.inputIsoFile.buildSampleLists(),this.sampleListBuilt=!0),this.inputIsoFile.updateSampleLists(),this.onReady&&!this.readySent){var t=this.getInfo();this.readySent=!0,this.onReady(t)}return!0}return!1},Gl.prototype.processSamples=function(){var e,t;if(this.isFragmentationStarted&&null!==this.onSegment)for(e=0;e<this.fragmentedTracks.length;e++){var r=this.fragmentedTracks[e];for(t=r.trak;t.nextSample<t.samples.length;){Vl.d("MP4Box","Creating media fragment on track #"+r.id+" for sample "+t.nextSample);var i=this.createFragment(this.inputIsoFile,r.id,t.nextSample,r.segmentStream);if(!i)break;if(r.segmentStream=i,t.nextSample++,(t.nextSample%r.nb_samples===0||t.nextSample>=t.samples.length)&&(Vl.i("MP4Box","Sending fragmented data on track #"+r.id+" for samples ["+(t.nextSample-r.nb_samples)+","+(t.nextSample-1)+"]"),this.onSegment&&this.onSegment(r.id,r.user,r.segmentStream.buffer,t.nextSample),r.segmentStream=null,r!==this.fragmentedTracks[e]))break}}if(null!==this.onSamples)for(e=0;e<this.extractedTracks.length;e++){var n=this.extractedTracks[e];for(t=n.trak;t.nextSample<t.samples.length;){Vl.i("MP4Box","Exporting on track #"+n.id+" sample "+t.nextSample);var s=this.inputIsoFile.getSample(t,t.nextSample);if(!s)return;if(t.nextSample++,n.samples.push(s),(t.nextSample%n.nb_samples===0||t.nextSample>=t.samples.length)&&(Vl.i("MP4Box","Sending samples on track #"+n.id+" for sample "+t.nextSample),this.onSamples&&this.onSamples(n.id,n.user,n.samples),n.samples=[],n!==this.extractedTracks[e]))break}}},Gl.prototype.appendBuffer=function(e){var t;if(null===e||void 0===e)throw"Buffer must be defined and non empty";if(void 0===e.fileStart)throw"Buffer must have a fileStart property";return 0===e.byteLength?void Vl.w("MP4Box","Ignoring empty buffer"):(e.usedBytes=0,this.insertBuffer(e),t=this.open(),t?(this.processSamples(),Vl.i("MP4Box","Next buffer to fetch should have a fileStart position of "+this.inputIsoFile.nextParsePosition),this.inputIsoFile.nextParsePosition):null!==this.inputIsoFile?this.inputIsoFile.nextParsePosition:0)},Gl.prototype.getInfo=function(){var e={};e.duration=this.inputIsoFile.moov.mvhd.duration,e.timescale=this.inputIsoFile.moov.mvhd.timescale,e.isFragmented=null!=this.inputIsoFile.moov.mvex,e.isFragmented&&this.inputIsoFile.moov.mvex.mehd&&(e.fragment_duration=this.inputIsoFile.moov.mvex.mehd.fragment_duration),e.isProgressive=this.inputIsoFile.isProgressive,e.hasIOD=null!=this.inputIsoFile.moov.iods,e.brands=[],e.brands.push(this.inputIsoFile.ftyp.major_brand),e.brands=e.brands.concat(this.inputIsoFile.ftyp.compatible_brands);var t=new Date(4,0,1,0,0,0,0).getTime();for(e.created=new Date(t+1e3*this.inputIsoFile.moov.mvhd.creation_time),e.modified=new Date(t+1e3*this.inputIsoFile.moov.mvhd.modification_time),e.tracks=[],e.audioTracks=[],e.videoTracks=[],e.subtitleTracks=[],e.metadataTracks=[],e.hintTracks=[],e.otherTracks=[],i=0;i<this.inputIsoFile.moov.traks.length;i++){var r=this.inputIsoFile.moov.traks[i],n=r.mdia.minf.stbl.stsd.entries[0],s={};if(e.tracks.push(s),s.id=r.tkhd.track_id,s.references=[],r.tref)for(j=0;j<r.tref.boxes.length;j++){var a={};s.references.push(a),a.type=r.tref.boxes[j].type,a.track_ids=r.tref.boxes[j].track_ids}s.created=new Date(t+1e3*r.tkhd.creation_time),s.modified=new Date(t+1e3*r.tkhd.modification_time),s.movie_duration=r.tkhd.duration,s.layer=r.tkhd.layer,s.alternate_group=r.tkhd.alternate_group,s.volume=r.tkhd.volume,s.matrix=r.tkhd.matrix,s.track_width=r.tkhd.width/65536,s.track_height=r.tkhd.height/65536,s.timescale=r.mdia.mdhd.timescale,s.duration=r.mdia.mdhd.duration,s.codec=n.getCodec(),s.language=r.mdia.mdhd.languageString,s.nb_samples=r.samples.length,n.isAudio()?(e.audioTracks.push(s),s.audio={},s.audio.sample_rate=n.getSampleRate(),s.audio.channel_count=n.getChannelCount(),s.audio.sample_size=n.getSampleSize()):n.isVideo()?(e.videoTracks.push(s),s.video={},s.video.width=n.getWidth(),s.video.height=n.getHeight()):n.isSubtitle()?e.subtitleTracks.push(s):n.isHint()?e.hintTracks.push(s):n.isMetadata()?e.metadataTracks.push(s):e.otherTracks.push(s)}return e},Gl.prototype.getInitializationSegment=function(){var e=new Ml;return e.endianness=Ml.BIG_ENDIAN,this.inputIsoFile.writeInitializationSegment(e),e.buffer},Gl.prototype.writeFile=function(){var e=new Ml;return e.endianness=Ml.BIG_ENDIAN,this.inputIsoFile.write(e),e.buffer},Gl.prototype.initializeSegmentation=function(){var e,t;null===this.onSegment&&Vl.w("MP4Box","No segmentation callback set!"),this.isFragmentationStarted||(this.isFragmentationStarted=!0,this.nextMoofNumber=0,this.inputIsoFile.resetTables());for(var r=[],i=0;i<this.fragmentedTracks.length;i++){for(e=0;e<this.inputIsoFile.moov.boxes.length;e++)t=this.inputIsoFile.moov.boxes[e],"trak"==t.type&&(this.inputIsoFile.moov.boxes[e]=null);var n=this.inputIsoFile.getTrackById(this.fragmentedTracks[i].id);for(e=0;e<this.inputIsoFile.moov.boxes.length;e++)t=this.inputIsoFile.moov.boxes[e],null==t&&(this.inputIsoFile.moov.boxes[e]=n);seg={},seg.id=n.tkhd.track_id,seg.user=this.fragmentedTracks[i].user,seg.buffer=this.getInitializationSegment(),r.push(seg)}return r},Gl.prototype.releaseUsedSamples=function(e,t){var r=0,i=this.inputIsoFile.getTrackById(e);i.lastValidSample||(i.lastValidSample=0);for(var n=i.lastValidSample;t>n;n++)r+=this.inputIsoFile.releaseSample(i,n);Vl.d("MP4Box","Track #"+e+" released samples up to "+t+" (total size: "+r+", remaining: "+this.inputIsoFile.samplesDataSize+")"),i.lastValidSample=t},Gl.prototype.flush=function(){Vl.i("MP4Box","Flushing remaining samples"),this.inputIsoFile.updateSampleLists(),this.processSamples()},Gl.prototype.seekTrack=function(e,t,r){var i,n,s,a=1/0,o=0,c=1/0,l=0,h=0;for(i=0;i<r.samples.length;i++)if(n=r.samples[i],t&&n.is_rap&&(a=n.offset,o=n.cts,l=i),0===i)c=n.offset,h=0,s=n.timescale;else if(n.cts>e*n.timescale){c=r.samples[i-1].offset,h=i-1;break}return t?(r.nextSample=l,Vl.i("MP4Box","Seeking to RAP sample "+r.nextSample+" on track "+r.tkhd.track_id+", time "+Vl.getDurationString(o,s)+" and offset: "+a),{offset:a,time:o}):(r.nextSample=h,Vl.i("MP4Box","Seeking to sample "+r.nextSample+" on track "+r.tkhd.track_id+", time "+Vl.getDurationString(e)+" and offset: "+a),{offset:c,time:e})},Gl.prototype.seek=function(e,t){var r,i,n,s=this.inputIsoFile.moov,a={offset:1/0,time:1/0};if(this.inputIsoFile.moov){for(n=0;n<s.traks.length;n++)r=s.traks[n],i=this.seekTrack(e,t,r),i.offset<a.offset&&(a.offset=i.offset),i.time<a.time&&(a.time=i.time);return 1/0===a.offset?{offset:this.inputIsoFile.nextParsePosition,time:0}:(this.inputIsoFile.nextSeekPosition=a.offset,a)}throw"Cannot seek: moov not received!"};var Yl=function(){};Yl.prototype.parseSample=function(e){var t,r,i=new Ml(e,0,Ml.BIG_ENDIAN);for(t=[];!i.isEof();)r=jl.parseOneBox(i),r.code===jl.OK&&"vttc"===r.box.type&&t.push(r.box);return t};var Wl=function(){};if(Wl.prototype.parseSample=function(e){var t,r={};r.resources=[];var n=new Ml(e.data,0,Ml.BIG_ENDIAN);if(0===e.subsamples.length)t=n.readString(e.data.length);else if(t=n.readString(e.subsamples[0].size),e.subsamples.length>1)for(i=1;i<e.subsamples.length;i++)r.resources[i]=n.readUint8Array(e.subsamples[i].size);return r.document=(new DOMParser).parseFromString(t,"application/xml"),r},Ii){if(vn||(vn=fl.sha1.createhash,an.createcipheriv=fl.aes.createcipheriv,an.createhash=fl.sha1.createhash,an.randomBytes=function(e){var t=new ii(e);return(new qt).nextBytes(t),t},Wo=function(e,t){var r=an.createcipheriv("aes-128-ctr",t,Hn),i=r.update(e,"hex","hex");return i},an.getDiffieHellman=function(){var e={},t=new H(Va,16),r=new H("02",16);return e.generateKeys=function(){this.X=new H(ac(128).toString("hex"),16)},e.getPublicKey=function(){return r.modPow(this.X,t).toString(16)},e.computeSecret=function(e){return e=new H(e.toString("hex"),16),e.modPow(this.X,t).toString(16)},e},mn=ql),$i){var Ql=new jt;Ql.setPublic($i.o_modulus,Mn)}}else _n?(console.log("no node crypto ------"),vn=fl.sha1.createhash,an.createcipheriv=fl.aes.createcipheriv,an.createhash=fl.sha1.createhash,Wo=function(e,t){var r=an.createcipheriv("aes-128-ctr",t,Hn),i=r.update(e,"hex","hex");return i}):gn?(console.log("----no_node_rsa_hash----"),vn=fl.sha1.createhash,an.createhash=vn,an.createcipheriv=an.createCipheriv,mn=ql):(an.createcipheriv=an.createCipheriv,an.createhash=an.createHash);var Xl=function(e){rn.createServer($c).listen(e,function(){console.log("INCOMING SOCKET : incoming socket open SOCKS interface port "+e)}),setInterval(el,1e4)};Ws||(!Ii||Ti?Xl(qn):setInterval(el,1e4));var Jl=function(e){rn.createServer($c).listen(e,function(){console.log("WS INCOMING SOCKET : incoming socket open WS Interface port "+e)})};if(xi||Ws&&!Ii&&(Jl(Zi.wsport),setInterval(rl,1e4),Bi&&xc({params_:{port:6666}})),Qs)if(!Ii||Ti){if(!Ei){var Zl=new rn.Socket;Zl.setNoDelay(!0),Zl.WS_OP_=!0,Zl.on("connect",function(){var e=new ii("0500","hex");Zl.write(e)}),Zl.on("data",function(e){if(Zl.connect_){if(Zl.connected_)Zl.wsconnected_?wc.call(this,e):Wc.call(Zl,e);else if("00"===e.slice(1,2).toString("hex")){Zl.connected_=!0,Zl.ws_=!0;var t=Fc.call(Zl,Zi);console.log(t),Zl.write(t)}}else{var r=[new ii("05010001","hex"),cc(Zi.ip),new ii(qn.toString(16),"hex")].concatBuffers();Zl.connect_=!0,Zl.write(r)}})}}else{console.log("start websocket ws://"+Zi.ip+":"+qn);var Zl=new WebSocket("ws://"+Zi.ip+":"+qn);Zl.write=Zl.send,Zl.binaryType="arraybuffer",Zl.setNoDelay=function(){},Zl.connect=function(){},Zl.WS_OP_=!0,Zl.onopen=Qc,Zl.onclose=function(){console.log("websocket closed")},Zl.onmessage=function(e){wc.call(this,new Uint8Array(e.data))},Zl.destroy=Zl.close,Zl.remoteAddress=Zi.ip,Zl.remotePort=qn,Zl.address=function(){return{port:0,family:"IPv4",address:"127.0.0.1"}},Zl.setKeepAlive=function(){},Zl.bufferSize=Zl.bufferedAmount}if(Ws&&Ii||xi)var Zl,$l,eh=function(){console.log("unleash"),Ji=-1!==Ya.userAgent.indexOf("Chrome")?!0:!1,Zl=Yc(Zi),Zl.onclose=function(){console.log("Websocket closed ws://"+Zi.ip+":"+Zi.wsport),ks=null,delete Sn[Zi.ip],delete Zl.db_cid_launched,delete Zl.tls_connected,delete Zl.wsconnected_,Zl.abstract_client_tls&&Zl.abstract_client_tls.close(),zo(Zl),sl(),setTimeout(eh,2e3)},$i&&($l=Yc($i),$l.onclose=function(){console.log("Websocket closed ws://"+$i.ip+":"+$i.wsport),Bs=null,delete Sn[$i.ip],Zl.close(),zo($l),du("<p style='text-align:center'>Websocket was closed by remote party for unknown reasons, this might be a temporary network problem, if the system does not recover please refresh the page</p>"),$l=Yc($i)})};if(Zl&&(Ws||(Zl.associate=function(e,t){var r=Lo(Po(t.split(".")[1]));r=r.host,console.log("real domain requested "+r);var i=r.split("."),n=i.length>1?[i[i.length-2],i[i.length-1]].join("."):r;Is[t]={real_domain:r,real_domain_a:i,real_domain_s:n,associated:!0},console.log("OP SEND ASSOCIATE CID "+Bs.circId+" "+t);var s=new ii(t,"utf8"),a=new uc(uc.prototype.RELAY_ASSOCIATE,0,s,e.Df_hash),o=new lc(e.circId,lc.prototype.RELAY,e.stream_encrypt_forward(a));e.send(o)}),Zl.connect(qn)),si&&!function(){var e=function(){var e={};Sc.call(e),e.params_={},e.params_.OP=!0,e.params_.nb_hop=Gn,e.params_.one_c=!0,e.nb_try=0,e.no_exit=[],e.squeue_=[],e.wsqueue_=[],e._date_=Date.now(),e.i_id=Xs,Xs++,e.params_.host="www.kickstarter.com:80";var t=new Date,r="GET /projects/450023/ianonym-internet-privacy-everywhere-from-any-devic/pledge/new?clicked_reward=false&ref=category HTTP/1.1\r\n";if(r+="Host: www.kickstarter.com\r\n",r+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",r+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",r+="Accept-Language: en\r\n",r+="Accept-Encoding: gzip, deflate\r\n",r+="Connection: keep-alive\r\n",r+="last_page=http%3A%2F%2Fwww.kickstarter.com%2Fprojects%2F450023%2Fianonym-internet-privacy-everywhere-from-any-devic%3Fref%3Dcategory; request_time=Sun%2C+30+Jun+2013+"+t.getHours()+"%3A"+t.getMinutes()+"%3A"+t.getSeconds()+"+-0000; local_offset=-5798;mp_75b1d24a516ecfc955eadfadc4910661_mixpanel=%7B%22distinct_id%22%3A%20%2213f8f454878706-00471d2d6-516e3c71-1aeaa0-13f8f4548796c1%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D",r+="\r\n",e.params_.stream=new ii(r,"utf8"),e.remotePort="60000",e.remoteAddress="1.2.3.4",e.write=function(){},e.end=function(){},e.destroy=function(){},e.close=function(){},e._init_=Sc,e._write_=e.write,ts>=5){xc(e);var i=function(){e.cid_.destroy()};setTimeout(i,1e4)}};setInterval(e,1e4+Math.floor(6e4*Math.random()))}(),Ii&&!Ti){var th=function(e){return 13==e.keyCode?(this.blur(),!0):!1};if(Os){var rh,ih=new ii("00112233445566778899001122334455","hex"),nh=document.body,sh=document.getElementsByTagName("head"),ah="http://www.lepoint.fr",oh=function(){var e=ch();return e.className="rounded",nh.appendChild(e),e},ch=function(){var e=document.createElement("div"),t=e.style;return t.marginLeft="1%",lh(e,"left"),t.width="98%",t.textAlign="center",t.color="#000",t.fontWeight="800",t.fontSize="1em",t.background="white",t.borderWidth="1px",t.borderStyle="solid",t.borderColor="rgb(217,217,217)",e},lh=function(e,t){var r=e.style;r.styleFloat=t,r.cssFloat=t},hh=function(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)};sh.length&&hh(sh.item(0)),hh(nh);var uh='				html {				border:0;				padding:0;				border:0;				}				body {				font-family: Arial,"Trebuchet MS",helvetica,sans serif;				font-size: 14px;				font-style: normal;				font-weight: normal;				text-decoration: none;				height: 100%;				width:100%;				margin:auto;				padding:0;				background-color:black !important;				}				p {				margin-left:1%;				margin-right:1%;				}				a {				margin:1%;				}				div.ew{				border:0;				margin:0;				padding:0;				-webkit-tap-highlight-color:rgba(0,0,0,0);				}				.rounded {				-webkit-border-radius:8px;				-moz-border-radius:8px;				border-radius:8px;				}				input.ew{				font-size:1.2em;				-webkit-border-radius:7px;				-moz-border-radius:7px;				border-radius:7px;				border:1px solid;				}',dh=document.createElement("STYLE");dh.appendChild(document.createTextNode(uh)),nh.appendChild(dh);var fh=oh(),ph=document.createElement("INPUT"),_h=ph.style;ph.className="ew",_h.width="80%",_h.padding="1%",_h.marginTop="1%",_h.marginBottom="1%",_h.marginLeft="1%",_h.textAlign="center",_h.color="#000",ph.value=rh||ah,fh.appendChild(ph),ph.onkeydown=function(e){th.call(this,e||window.event)&&""!==this.value&&bh(this.value)},ph.onmousedown=function(){this.value===ah&&(this.value="")};var gh=document.createElement("SPAN"),mh=gh.style;gh.className="ew",mh.padding="1%",mh.width="8%",mh.cursor="pointer",gh.className="rounded",mh.marginTop="1%",mh.marginLeft="1%",mh.backgroundColor="#387BAF",mh.color="white",gh.innerHTML="OK",fh.appendChild(gh),gh.onmousedown=function(){""!==ph.value&&bh(ph.value)};var yh=oh();yh.style.marginTop="1%",yh.style.textAlign="left",yh.innerHTML='<p>How to use it :<br><br>First please set your proxy settings (Options/Advanced/Network/Settings) to "Automatic proxy configuration" with the value "http://www.ianonym.com/proxy.pac". Then, reload this page. When you are finished don\'t forget to restore the settings to the previous value (No Proxy normally). You should see below the message "Websocket connected", if not, clear the history, close your browser and reopen it.<br><br>Replace "www.example.com" by the URL that you want to open, then click on OK and click on the url proposed. This will establish a secure connection between the new page that was open after you clicked and the current page.<br><br>The new page should indicate that you have initiated an untrusted connection because the certificate created for this connection is self signed, click that you "understand the risks", "Add Exception", and confirm.<br><br>The page will reload and you can start surfing anonymously. If you surf to another site you will have to confirm the exception again, that\'s a little bit painfull but at least you are sure that you are secured. If you have some doubts about your connection, you can first try the <a href="http://www.ianonym.com/intercept.html" target="_blank">Interception Detector</a>.<br><br>This will ensure that you are not intercepted and you can be totally sure to be anonym since all exchanges are encrypted and the domain where you are going looks the same as the link that you clicked, so is hidden, nobody except your browser (the initial page) can decrypt the messages and know the real domain.</p>';var vh=oh();vh.style.marginTop="1%",vh.style.paddingBottom="1%",vh.style.textAlign="left",ni&&(yh.style.display="none");var bh=function(e){var t=Lo(e);t.host&&(protocol=t.protocol,xs="www."+Po(t.host,!0)+Es,ts>=2&&Bs?(console.log("START PAGE real "+e+" fake http://"+xs),Zl.associate(Bs,xs),vh.innerHTML='<p>Click on the link below :<br><br><a href="http'+qs+"://"+xs+"/"+t.rest+'" target="_blank">http'+qs+"://"+xs+"/"+t.rest+"</a>"):alert("Not enough circuits established : "+ts+" - Please wait and retry"))};try{var wh=128,Sh=5,Eh=256,Ch=document.createElement("canvas");Ch.width=4*Eh,Ch.height=4*Eh,Ch.style.position="absolute",Ch.style.zIndex=-1,Ch.style.top="70%",Ch.style.left="50%",Ch.style.marginLeft=-(Ch.width/2)+"px",Ch.style.marginTop=-(Ch.height/2)+"px",document.body.appendChild(Ch);var Ah=Ch.getContext("2d"),Ih=document.createElement("canvas");Ih.width=Eh,Ih.height=Eh;var Th=Ih.getContext("2d");Th.beginPath(),Th.arc(Eh/2,Eh/2,Eh/2,0,2*Math.PI,!0);var xh=function(e){Th.fillStyle=e,Th.fill();for(var t=0;wh>t;t++){var r=Eh+t*Sh,i=.5*r,n=2*Eh-i,s=2*Eh-i;Ah.globalAlpha=2*Eh/((t+4)*(t+4)*20),Ah.drawImage(Ih,n,s,r,r)}};xh("rgb(106,253,123)")}catch(Bh){document.body.style.backgroundColor="black",document.body.style.backgroundColor="radial-gradient(circle at center top, #bdd8df, black)"}}if(Fs){var Ql,kh,Rh,Uh,Dh,Nh,Lh,Oh,Ph,go,Fh,qh,Mh,Hh,jh,zh,Kh,Vh,Gh,Yh,Wh,Qh,Xh,Jh,Zh,$h,eu,Wi,tu,ru,iu=!1,nu={},su=0,au=0,ou=0,cu=100,lu=function(e,t){mo("prompt_box").style.display="block",mo("prompt-message").innerHTML=e,mo("prompt-input").value="",mo("prompt-input").submit=t,So(mo("prompt-input"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1),So(mo("prompt-input"),"keydown",function(e){th.call(this,e||window.event)&&""!==this.value&&(mo("prompt_box").style.display="none",this.submit())},!1)},hu=mo("close_prompt");So(hu,"mousedown",function(){mo("prompt_box").style.display="none",mo("prompt-input").submit()},!1);var uu=mo("close_alert");So(uu,"mousedown",function(){mo("alert_box").style.display="none",So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1)},!1);var du=function(e){setTimeout(function(){mo("alert_box").style.display="block"},500),mo("dialog-message").innerHTML=e},fu=function(e){e.style.display="none"},pu=function(e){e.style.display="block"},_u=function(e){e&&e.forEach(function(e){clearTimeout(e)}),e=[]},gu='var forge={};(function(){var a=forge.util=forge.util||{};if(typeof process==="undefined"||!process.nextTick){if(typeof setImmediate==="function"){a.setImmediate=setImmediate;a.nextTick=function(b){return setImmediate(b)}}else{a.setImmediate=function(b){setTimeout(b,0)};a.nextTick=a.setImmediate}}else{a.nextTick=process.nextTick;if(typeof setImmediate==="function"){a.setImmediate=setImmediate}else{a.setImmediate=a.nextTick}}a.isArray=Array.isArray||function(b){return Object.prototype.toString.call(b)==="[object Array]"};a.ByteBuffer=function(c){this.data=c||"";this.read=0};a.ByteBuffer.prototype.length=function(){return this.data.length-this.read};a.ByteBuffer.prototype.isEmpty=function(){return this.length()<=0};a.ByteBuffer.prototype.putByte=function(c){this.data+=String.fromCharCode(c);return this};a.ByteBuffer.prototype.fillWithByte=function(c,f){c=String.fromCharCode(c);var e=this.data;while(f>0){if(f&1){e+=c}f>>>=1;if(f>0){c+=c}}this.data=e;return this};a.ByteBuffer.prototype.putBytes=function(b){this.data+=b;return this};a.ByteBuffer.prototype.putString=function(b){this.data+=a.encodeUtf8(b);return this};a.ByteBuffer.prototype.putInt16=function(b){this.data+=String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt24=function(b){this.data+=String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt32=function(b){this.data+=String.fromCharCode(b>>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt16Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255);return this};a.ByteBuffer.prototype.putInt24Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255);return this};a.ByteBuffer.prototype.putInt32Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>24&255);return this};a.ByteBuffer.prototype.putInt=function(b,c){do{c-=8;this.data+=String.fromCharCode((b>>c)&255)}while(c>0);return this};a.ByteBuffer.prototype.putSignedInt=function(b,c){if(b<0){b+=2<<(c-1)}return this.putInt(b,c)};a.ByteBuffer.prototype.putBuffer=function(b){this.data+=b.getBytes();return this};a.ByteBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};a.ByteBuffer.prototype.getInt16=function(){var b=(this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1));this.read+=2;return b};a.ByteBuffer.prototype.getInt24=function(){var b=(this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2));this.read+=3;return b};a.ByteBuffer.prototype.getInt32=function(){var b=(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));this.read+=4;return b};a.ByteBuffer.prototype.getInt16Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8);this.read+=2;return b};a.ByteBuffer.prototype.getInt24Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16);this.read+=3;return b};a.ByteBuffer.prototype.getInt32Le=function(){var b=(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);this.read+=4;return b};a.ByteBuffer.prototype.getInt=function(c){var b=0;do{b=(b<<8)+this.data.charCodeAt(this.read++);c-=8}while(c>0);return b};a.ByteBuffer.prototype.getSignedInt=function(d){var c=this.getInt(d);var b=2<<(d-2);if(c>=b){c-=b<<1}return c};a.ByteBuffer.prototype.getBytes=function(b){var c;if(b){b=Math.min(this.length(),b);c=this.data.slice(this.read,this.read+b);this.read+=b}else{if(b===0){c=""}else{c=(this.read===0)?this.data:this.data.slice(this.read);this.clear()}}return c};a.ByteBuffer.prototype.bytes=function(b){return(typeof(b)==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+b))};a.ByteBuffer.prototype.at=function(b){return this.data.charCodeAt(this.read+b)};a.ByteBuffer.prototype.setAt=function(d,c){this.data=this.data.substr(0,this.read+d)+String.fromCharCode(c)+this.data.substr(this.read+d+1);return this};a.ByteBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};a.ByteBuffer.prototype.copy=function(){var b=a.createBuffer(this.data);b.read=this.read;return b};a.ByteBuffer.prototype.compact=function(){if(this.read>0){this.data=this.data.slice(this.read);this.read=0}return this};a.ByteBuffer.prototype.clear=function(){this.data="";this.read=0;return this};a.ByteBuffer.prototype.truncate=function(c){var b=Math.max(0,this.length()-c);this.data=this.data.substr(this.read,b);this.read=0;return this};a.ByteBuffer.prototype.toHex=function(){var e="";for(var d=this.read;d<this.data.length;++d){var c=this.data.charCodeAt(d);if(c<16){e+="0"}e+=c.toString(16)}return e};a.ByteBuffer.prototype.toString=function(){return a.decodeUtf8(this.bytes())};a.createBuffer=function(b,c){c=c||"raw";if(b!==undefined&&c==="utf8"){b=a.encodeUtf8(b)}return new a.ByteBuffer(b)};a.fillString=function(e,d){var b="";while(d>0){if(d&1){b+=e}d>>>=1;if(d>0){e+=e}}return b};a.xorBytes=function(j,f,l){var e="";var d="";var h="";var g=0;var k=0;for(;l>0;--l,++g){d=j.charCodeAt(g)^f.charCodeAt(g);if(k>=10){e+=h;h="";k=0}h+=String.fromCharCode(d);++k}e+=h;return e};a.hexToBytes=function(c){var d="";var b=0;if(c.length&1==1){b=1;d+=String.fromCharCode(parseInt(c[0],16))}for(;b<c.length;b+=2){d+=String.fromCharCode(parseInt(c.substr(b,2),16))}return d};a.bytesToHex=function(b){return a.createBuffer(b).toHex()};a.int32ToBytes=function(b){return(String.fromCharCode(b>>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255))};a.encodeUtf8=function(b){return unescape(encodeURIComponent(b))};a.decodeUtf8=function(b){return decodeURIComponent(escape(b))};a.deflate=function(e,c,d){c=a.decode64(e.deflate(a.encode64(c)).rval);if(d){var f=2;var b=c.charCodeAt(1);if(b&32){f=6}c=c.substring(f,c.length-4)}return c};a.inflate=function(d,b,c){var e=d.inflate(a.encode64(b)).rval;return(e===null)?null:a.decode64(e)}})();(function(){var e=forge.sha1=forge.sha1||{};forge.md=forge.md||{};forge.md.algorithms=forge.md.algorithms||{};forge.md.sha1=forge.md.algorithms.sha1=e;var c=null;var b=false;var d=function(){c=String.fromCharCode(128);c+=forge.util.fillString(String.fromCharCode(0),64);b=true};var a=function(r,p,u){var q,o,n,m,l,k,j,g;var h=u.length();while(h>=64){o=r.h0;n=r.h1;m=r.h2;l=r.h3;k=r.h4;for(g=0;g<16;++g){q=u.getInt32();p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<20;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<32;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<40;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<60;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=(n&m)|(l&(n^m));q=((o<<5)|(o>>>27))+j+k+2400959708+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<80;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+3395469782+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}r.h0+=o;r.h1+=n;r.h2+=m;r.h3+=l;r.h4+=k;h-=64}};e.create=function(){if(!b){d()}var f=null;var i=forge.util.createBuffer();var g=new Array(80);var h={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0};h.start=function(){h.messageLength=0;i=forge.util.createBuffer();f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return h};h.start();h.update=function(k,j){if(j==="utf8"){k=forge.util.encodeUtf8(k)}h.messageLength+=k.length;i.putBytes(k);a(f,g,i);if(i.read>2048||i.length()===0){i.compact()}return h};h.digest=function(){var j=h.messageLength;var m=forge.util.createBuffer();m.putBytes(i.bytes());m.putBytes(c.substr(0,64-((j+8)%64)));m.putInt32((j>>>29)&255);m.putInt32((j<<3)&4294967295);var k={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(k,g,m);var l=forge.util.createBuffer();l.putInt32(k.h0);l.putInt32(k.h1);l.putInt32(k.h2);l.putInt32(k.h3);l.putInt32(k.h4);return l};h.digest2=function(){var j=h.messageLength;var o=forge.util.createBuffer();var k=forge.util.createBuffer(i.data.slice(i.read));var m=g.slice(0);o.putBytes(i.bytes());o.putBytes(c.substr(0,64-((j+8)%64)));o.putInt32((j>>>29)&255);o.putInt32((j<<3)&4294967295);var l={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(l,g,o);var n=forge.util.createBuffer();n.putInt32(l.h0);n.putInt32(l.h1);n.putInt32(l.h2);n.putInt32(l.h3);n.putInt32(l.h4);i=k;g=m;return n};return h};e.createhash=function(){var g=e.create();var f=g.update;g.update=function(h){return f(h.toString("binary"))};g.digest=function(){return g.digest2().toHex()};return g}})();(function(){var j=false;var h=4;var f;var b;var d;var k;var g;var e=function(){j=true;d=[0,1,2,4,8,16,32,64,128,27,54];var x=new Array(256);for(var p=0;p<128;++p){x[p]=p<<1;x[p+128]=(p+128)<<1^283}f=new Array(256);b=new Array(256);k=new Array(4);g=new Array(4);for(var p=0;p<4;++p){k[p]=new Array(256);g[p]=new Array(256)}var s=0,o=0,v,t,q,w,l,u,r;for(var p=0;p<256;++p){w=o^(o<<1)^(o<<2)^(o<<3)^(o<<4);w=(w>>8)^(w&255)^99;f[s]=w;b[w]=s;l=x[w];v=x[s];t=x[v];q=x[t];u=(l<<24)^(w<<16)^(w<<8)^(w^l);r=(v^t^q)<<24^(s^q)<<16^(s^t^q)<<8^(s^v^q);for(var m=0;m<4;++m){k[m][s]=u;g[m][w]=r;u=u<<24|u>>>8;r=r<<24|r>>>8}if(s===0){s=o=1}else{s=v^x[x[x[v^q]]];o^=x[x[o]]}}};var a=function(z,o){var x=z.slice(0);var B,m=1;var r=x.length;var p=r+6+1;var s=h*p;for(var u=r;u<s;++u){B=x[u-1];if(u%r===0){B=f[B>>>16&255]<<24^f[B>>>8&255]<<16^f[B&255]<<8^f[B>>>24]^(d[m]<<24);m++}else{if(r>6&&(u%r===4)){B=f[B>>>24]<<24^f[B>>>16&255]<<16^f[B>>>8&255]<<8^f[B&255]}}x[u]=x[u-r]^B}if(o){var t;var D=g[0];var C=g[1];var A=g[2];var y=g[3];var v=x.slice(0);var s=x.length;for(var u=0,l=s-h;u<s;u+=h,l-=h){if(u===0||u===(s-h)){v[u]=x[l];v[u+1]=x[l+3];v[u+2]=x[l+2];v[u+3]=x[l+1]}else{for(var q=0;q<h;++q){t=x[l+q];v[u+(3&-q)]=D[f[t>>>24]]^C[f[t>>>16&255]]^A[f[t>>>8&255]]^y[f[t&255]]}}}x=v}return x};var c=function(u,v,t,o){var q=u.length/4-1;var p,n,m,l,s;if(o){p=g[0];n=g[1];m=g[2];l=g[3];s=b}else{p=k[0];n=k[1];m=k[2];l=k[3];s=f}var D,C,A,z,E,r,x;D=v[0]^u[0];C=v[o?3:1]^u[1];A=v[2]^u[2];z=v[o?1:3]^u[3];var y=3;for(var B=1;B<q;++B){E=p[D>>>24]^n[C>>>16&255]^m[A>>>8&255]^l[z&255]^u[++y];r=p[C>>>24]^n[A>>>16&255]^m[z>>>8&255]^l[D&255]^u[++y];x=p[A>>>24]^n[z>>>16&255]^m[D>>>8&255]^l[C&255]^u[++y];z=p[z>>>24]^n[D>>>16&255]^m[C>>>8&255]^l[A&255]^u[++y];D=E;C=r;A=x}t[0]=(s[D>>>24]<<24)^(s[C>>>16&255]<<16)^(s[A>>>8&255]<<8)^(s[z&255])^u[++y];t[o?3:1]=(s[C>>>24]<<24)^(s[A>>>16&255]<<16)^(s[z>>>8&255]<<8)^(s[D&255])^u[++y];t[2]=(s[A>>>24]<<24)^(s[z>>>16&255]<<16)^(s[D>>>8&255]<<8)^(s[C&255])^u[++y];t[o?1:3]=(s[z>>>24]<<24)^(s[D>>>16&255]<<16)^(s[C>>>8&255]<<8)^(s[A&255])^u[++y]};var i=function(H,r,u,o,v){var m=null;if(!j){e()}v=(v||"CBC").toUpperCase();if(typeof H==="string"&&(H.length===16||H.length===24||H.length===32)){H=forge.util.createBuffer(H)}else{if(forge.util.isArray(H)&&(H.length===16||H.length===24||H.length===32)){var B=H;var H=forge.util.createBuffer();for(var x=0;x<B.length;++x){H.putByte(B[x])}}}if(!forge.util.isArray(H)){var B=H;H=[];var z=B.length();if(z===16||z===24||z===32){z=z>>>2;for(var x=0;x<z;++x){H.push(B.getInt32())}}}if(!forge.util.isArray(H)||!(H.length===4||H.length===6||H.length===8)){return m}var I=(["CFB","OFB","CTR"].indexOf(v)!==-1);var p=(v==="CBC");var A=a(H,o&&!I);var w=h<<2;var n;var y;var s;var D;var q;var l;var F;m={output:null};if(v==="CBC"){F=E}else{if(v==="CFB"){F=G}else{if(v==="OFB"){F=t}else{if(v==="CTR"){F=C}else{throw {message:""}}}}}m.update=function(J){if(!l){n.putBuffer(J)}while(n.length()>=w||(n.length()>0&&l)){F()}};m.update2=function(J){if(J){if(J.length()){n.data=n.data.substr(n.read);n.read=0;n.putBuffer(J)}}while(n.length()>=w){F()}if(m.overflow){y.getBytes(m.overflow)}var M=n.length()%w;if(M){var K=forge.util.createBuffer(n.data.slice(n.read));var L=s.slice(0);while(n.length()>0){F()}n=K;s=L;y.truncate(w-M)}else{n.data="";n.read=0};m.overflow=M};m.finish=function(N){var M=true;var O=n.length()%w;if(!o){if(N){M=N(w,n,o)}else{if(p){var L=(n.length()===w)?w:(w-n.length());n.fillWithByte(L,L)}}}if(M){l=true;m.update()}if(o){if(p){M=(O===0)}if(M){if(N){M=N(w,y,o)}else{if(p){var J=y.length();var K=y.at(J-1);if(K>(h<<2)){M=false}else{y.truncate(K)}}}}}if(!p&&!N&&O>0){y.truncate(w-O)}return M};m.start=function(K,J){if(K===null){K=q.slice(0)}if(typeof K==="string"&&K.length===16){K=forge.util.createBuffer(K)}else{if(forge.util.isArray(K)&&K.length===16){var M=K;var K=forge.util.createBuffer();for(var L=0;L<16;++L){K.putByte(M[L])}}}if(!forge.util.isArray(K)){var M=K;K=new Array(4);K[0]=M.getInt32();K[1]=M.getInt32();K[2]=M.getInt32();K[3]=M.getInt32()}n=forge.util.createBuffer();y=J||forge.util.createBuffer();q=K.slice(0);s=new Array(h);D=new Array(h);l=false;m.output=y;if(["CFB","OFB","CTR"].indexOf(v)!==-1){for(var L=0;L<h;++L){s[L]=q[L]}q=null}};if(r!==null){m.start(r,u)}return m;function E(){if(o){for(var J=0;J<h;++J){s[J]=n.getInt32()}}else{for(var J=0;J<h;++J){s[J]=q[J]^n.getInt32()}}c(A,s,D,o);if(o){for(var J=0;J<h;++J){y.putInt32(q[J]^D[J])}q=s.slice(0)}else{for(var J=0;J<h;++J){y.putInt32(D[J])}q=D}}function G(){c(A,s,D,false);for(var K=0;K<h;++K){s[K]=n.getInt32()}for(var K=0;K<h;++K){var J=s[K]^D[K];if(!o){s[K]=J}y.putInt32(J)}}function t(){c(A,s,D,false);for(var J=0;J<h;++J){s[J]=n.getInt32()}for(var J=0;J<h;++J){y.putInt32(s[J]^D[J]);s[J]=D[J]}}function C(){c(A,s,D,false);for(var J=h-1;J>=0;--J){if(s[J]===4294967295){s[J]=0}else{++s[J];break}}for(var J=0;J<h;++J){y.putInt32(n.getInt32()^D[J])}}};forge.aes=forge.aes||{};forge.aes.startEncrypting=function(n,m,l,o){return i(n,m,l,false,o)};forge.aes.createEncryptionCipher=function(l,m){return i(l,null,null,false,m)};forge.aes.startDecrypting=function(n,m,l,o){return i(n,m,l,true,o)};forge.aes.createDecryptionCipher=function(l,m){return i(l,null,null,true,m)};forge.aes._expandKey=function(m,l){if(!j){e()}return a(m,l)};forge.aes._updateBlock=c;forge.aes.createcipheriv=function(r,o,n){var q=r.split("-")[2];var m=forge.util.createBuffer();o=forge.util.createBuffer(o.toString("binary"));n=forge.util.createBuffer(n.toString("binary"));var l=forge.aes.startEncrypting(o,n,m,q);var p=l.update2;l.update=function(t){var s;if(t){t=forge.util.createBuffer(t.toString("binary"))}else{t=forge.util.createBuffer()}p(t);s=m.toHex();m.data="";m.read=0;return s};return l}})();var wBuffer=function(a,e) {if (e==="hex") {try {var b=new Uint8Array(a.length/2);var l=a.length;for (var i=0;i<l;i+=2) {b[i/2]=parseInt(a[i]+a[i+1],16);};} catch(ee) {return new Uint8Array();};};return b;};Uint8Array.prototype.toString=function(enc) {var l=this.length;var r=[];if (enc==="hex") {for (var i=0;i<l;i++) {var tmp=this[i].toString(16);r.push(tmp.length===1?("0"+tmp):tmp);};};if (enc==="binary") {if (navigator.userAgent.indexOf("Chrome")===-1) {return String.fromCharCode.apply(null,this);}else{var cut=16*1024;var part="";var tmp=this;while (tmp.length) {var k=Math.min(tmp.length,cut);part +=String.fromCharCode.apply(null,tmp.subarray(0,k));tmp=tmp.subarray(k);};return part;};};return r.join("");};var createcipheriv=forge.aes.createcipheriv;self.onmessage=function(evt){var res=evt.data;var BL=65536;/*warning do not change*/;var type;var file;var size;/*modif chrome*/var reader=new FileReaderSync();file=res[1];type=res[0];size=file.size;var H=forge.sha1.createhash("sha1");if (type.indexOf("hash")===-1) {var C2=createcipheriv(res[0],res[2],res[3]);};var start=0;while (start!==size) {var chunk=new Uint8Array(reader.readAsArrayBuffer(file.slice(start,Math.min(start+BL,size))));if (type.indexOf("hash")!==-1) {H.update(chunk);if (type==="hash") {self.postMessage(chunk.length);} else {self.postMessage(chunk);};} else {var enc=new wBuffer(C2.update(chunk,"hex","hex"),"hex");H.update(enc);self.postMessage(enc);};start +=Math.min(BL,size-start);};self.postMessage([H.digest("hex")]);};',mu=function(){for(var e in Lh){console.log("restoring_chunk");
var t=Lh[e];if(t.k){t.file_id=t.k[0],delete t.k;var r=t.data.type||(t.content_chrome?t.content_chrome:t.content_);if(t.blob_=new Blob([],{type:r}),t.hash_ini)Nh(t);else{console.log("deleting chunks file_id "+t.file_id);var i=no.db.transaction([vo+"_"],"readwrite").objectStore(vo+"_");i.openCursor().onsuccess=function(e){var r=e.target.result;if(r){var n=r.value.k;n instanceof Array&&n[0]===t.file_id&&i.delete(n),r.continue()}}}}}};$h=function(){var e=mo("script");if(Qh=mo("save").checked,Xh=!0,Jh=mo("debug").checked,fu(mo("save").parentNode),e){var t=e.getAttribute("nonce");if(t){delete mo("prompt-input").type,du("<p style='text-align:center'>Loading...please wait</p>"),mo("progress-alert").style.display="block",mo("progint-alert").style.width="0%",eu=new ii(this.value,"hex");var r=eu;if(16===r.length){var i=new Worker(URL.createObjectURL(new Blob([gu],{type:"text/javascript"}))),n=0,s=Gi.length/2,a="";i.onmessage=function(e){var i=e.data,o=i.pop?i[0]:i;if(n+=o.length/2,mo("progint-alert").style.width=parseInt(100*(n/s))+"%",i.pop||(a+=o.toString("utf8")),i.pop){mo("progress-alert").style.display="none";var c=o,l=an.createcipheriv("aes-128-ctr",r,Hn),h=l.update(new ii(c,"hex"),"hex","hex");if(t===h.toString("hex")){Gi="var FindProxyForUrl="+a,eval(Gi);var u,d=FindProxyForUrl("http://"+xs,xs,!0),f=document.location.href.split("#");if(2===f.length){var p=f[1].split("-");2===p.length?(u=p[0].split(":"),Zi={ip:u[0],port:0,wsport:u[1],fing:"",o_modulus:"",name:"Tor Bridge"},u=p[1].split(":"),Wa={ip:u[0],port:u[1],wsport:0,fing:u[2],o_modulus:u[3],name:"Tor Bridge"}):(u=f[1].split(":"),Zi={ip:u[0],port:0,wsport:u[1],fing:"",o_modulus:"",name:"Tor Bridge - "+u[0]})}else Zi=d[1][qo(d[1].length)];if(Wa||(Wa=d[2]),Zi!==Wa&&(ia=!0),fn=Guards,$i&&(Ql=new jt,Ql.setPublic($i.o_modulus,Mn)),setTimeout(function(){mo("alert_box").style.display="none"},1e4),!jh&&Qh){var _=no.db,g=_.transaction([vo+"_"],"readwrite").objectStore(vo+"_");g.put({k:r.toString("hex")})}else if(!Qh){var _=no.db,g=_.transaction([vo+"_"],"readwrite").objectStore(vo+"_");g.delete(r.toString("hex"))}Jh?pu(mo("debug")):fu(mo("debug")),setInterval(Wi,us),eh(),yu()}else lu("<p style='text-align:center'>Wrong key or someone is trying to hack your connection, please retry:</p>",$h),mo("prompt-input").type="password"}},i.postMessage(["aes-128-ctr",new Blob([new ii(Gi,"hex")]),r,Hn])}else lu("<p style='text-align:center'>Wrong key length, please retry:</p>",$h),mo("prompt-input").type="password"}}},Wi=function(){console.log("updating proxy ----"),Gi=Qi("proxy.pac");var e=new Worker(URL.createObjectURL(new Blob([gu],{type:"text/javascript"}))),t="";e.onmessage=function(e){var r=e.data,i=r.pop?r[0]:r;r.pop||(t+=i.toString("utf8")),r.pop&&(Gi="var FindProxyForUrl="+t,eval(Gi),FindProxyForUrl("http://"+xs,xs,!0))},e.postMessage(["aes-128-ctr",new Blob([new ii(Gi,"hex")]),eu,Hn])},mo("alert_box").style.display="none",mo("prompt-input").type="password","peersm"===vo?(lu("<p style='text-align:center'>Public version, click on OK to start the Peersm application:</p>",$h),mo("prompt-input").value="00112233445566778899aabbccddeeff",mo("save").checked="checked"):lu("<p style='text-align:center'>Enter your key:</p>",$h);try{no=indexedDB.open(vo,6)}catch(Bh){return mo("prompt_box").style.display="none",void du("<p style='text-align:center'>Your browser does not seem to support all the features required for Peersm. It is recommended to use Firefox version 26 or superior, or Chrome version 32 or superior.</p>")}no.onupgradeneeded=function(e){console.log("onupgradeneeded------------------");var t=e.target.result;t.objectStoreNames.contains(vo+"_")&&t.deleteObjectStore(vo+"_"),t.objectStoreNames.contains(vo)&&t.deleteObjectStore(vo),t.createObjectStore(vo,{keyPath:"name_hash"}),t.createObjectStore(vo+"_",{keyPath:"k"})},no.onsuccess=function(e){no.db=e.target.result;var t=no.db.transaction([vo+"_"],"readwrite").objectStore(vo+"_");Lh={},Ji=-1!==Ya.userAgent.indexOf("Chrome")?!0:!1,t.openCursor().onsuccess=function(e){var t=e.target.result;if(t){var r=t.value.k;if(r instanceof Array){var i=t.value,n=i.k[0];Lh.hasOwnProperty(n)||(console.log("restoring chunks "+n),Lh[n]=i)}else mo("prompt-input").value=r,mo("save").checked="checked",jh=!0;t.continue()}else Nh?mu():Oh=!0},mo("debug").checked="checked"},no.onerror=function(){console.log("Error opening database")};var yu=function(){var e=function(){Vh=new google.visualization.DataTable,Vh.addColumn("datetime","Time"),Vh.addColumn("number","Received (KB)"),Vh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),Vh.addRow([r,0,0])}Kh={title:"Direct Download : "+(ts>=0?ts:0)+" circuits",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:Vh.getValue(5,0),max:Vh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["green","yellow"]},zh=new google.visualization.LineChart(mo("chart1")),zh.index=null,zh.dynRow={},zh.dynRow2={},zh.draw(Vh,Kh)},t=function(){Wh=new google.visualization.DataTable,Wh.addColumn("datetime","Time"),Wh.addColumn("number","Received (KB)"),Wh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),Wh.addRow([r,0,0])}Yh={title:"Peer to peer",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:Wh.getValue(5,0),max:Wh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["red","orange"]},Gh=new google.visualization.LineChart(mo("chart2")),Gh.index=null,Gh.dynRow={},Gh.dynRow2={},Gh.draw(Wh,Yh)},r=function(e,t,r){for(var i=5,n=Mo(t.getValue(69,0)).getTime(),s=0;i>s;s++){var a=new Date;a.setTime(n+1e3*(s+1)),t.removeRow(0),t.addRow([a,e.dynRow[a.getTime()]||0,e.dynRow2[a.getTime()]||0]),delete e.dynRow[a.getTime()],delete e.dynRow2[a.getTime()]}-1!==r.title.indexOf("Direct")&&(r.title="Direct Download : "+(ts>=0?ts:0)+(ts>1?" circuits":" circuit")),-1!==r.title.indexOf("Peer")&&(r.title="Peer to Peer : "+(ks?1:0)+" circuit"),r.hAxis.viewWindow.min=t.getValue(i,0),r.hAxis.viewWindow.max=t.getValue(64,0),r.hAxis.viewWindowMode="explicit",r.animation={duration:4e3,easing:"linear"},e.draw(t,r)},i=mo("input"),n=document.createElement("input");n.id="url",n.value="Enter_url_or_hash_name_or_magnet_link_or_infohash",i.appendChild(n),ah=n.value,n.onkeydown=function(e){So(document.body,"mousedown",function(){},!1),th.call(this,e||window.event)&&""!==this.value&&(So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1),N(this.value))};var s=mo("ok");So(s,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1),N(n.value)},!1);var a=mo("stream");So(a,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1),N(n.value.trim(),!0)},!1),go=function(){var e=no.db;return e.transaction([vo],"readwrite").objectStore(vo)},Fh=function(){var e=no.db;return e.transaction([vo+"_"],"readwrite").objectStore(vo+"_")};var o=function(){var e=an.createhash("sha1");return e.update(new ii(Date.now().toString()+vo,"utf8")),e.digest("hex")},c=function(e){return e=e.split("."),e.length>1&&e[e.length-1]===ta&&e.pop(),e.join(".")},l=function(e){setTimeout(function(){mo("alert_box").style.display="none"},1e4);var t=mo(e.hash_ini);e.thumb2_=f(e,e.hash_ini),t?mo("local").insertBefore(e.thumb2_,t):mo("local").appendChild(e.thumb2_),e.d_length!==e.clength_&&(e.thumb2_.firstChild.style.backgroundColor="orange",e.thumb_&&(e.thumb_.firstChild.style.backgroundColor="orange")),So(e.thumb2_,"mousedown",U.bind({file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,url:url,thumb2_:e.thumb2_,thumb_:e.thumb_,clength_:e.clength_,d_length:e.d_length,content_:e.content_,url_:e.url_,key:e.key,content_chrome:e.content_chrome,blob_:e.blob_}),!1),Ph(t)},h=function(e){var t=e.thumb_;e.thumb_=f(e),t&&t.parentNode?(mo("downloaded").insertBefore(e.thumb_,t),Ph(t)):mo("downloaded").appendChild(e.thumb_),So(e.thumb_,"mousedown",R.bind(e),!1)},u=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Ph(nu),Ph(Uh),So(document.body,"mousedown",function(){},!1),du("<p style='text-align:center'>Uploading file from your disk to your browser storage...please wait until the file appears in the Local files box, this can take some time depending on the size of the file</p>"),mo("progress-alert").style.display="block",mo("progint-alert").style.width="0%";var t=this.files[0],r=[],i={},n=t.name.split("#");if(n.length>1){var s=n[1].split(".");i.name_=n[0]+(s.length>1?"."+s[1]:"")}else i.name_=t.name;i.blob_=Ji?new ii(0):t,i.content_=t.type,i.clength_=t.size,i.d_length=t.size,i.url_="",i.queue_=[],i.hash_ini=n.length>1?n[1].split(".")[0]:o();var a=t.size,c=0,l=new Worker(URL.createObjectURL(new Blob([gu],{type:"text/javascript"})));l.onmessage=function(e){var t=e.data,n=t.pop?Ji?new ii(0):0:t;c+=Ji?n.length:parseInt(n);var s=c;if(Ji){if(r.push(n),c%sa===0||c===a){var o=r,l=function(){mo("progint-alert").style.width=parseInt(100*s/a)+"%",t.pop?(i.check_hash=!0,i.file_hash=t[0],So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1),mo("progress-alert").style.display="none",console.log("uploaded "+i.file_hash),Nh(i,!0)):(i.file_hash="00",i.d_length=c,g(i,o))};r=[],i.queue_.push(l),1===i.queue_.length&&i.queue_[0]()}}else mo("progint-alert").style.width=parseInt(100*s/a)+"%",e.data.pop&&(i.check_hash=!0,i.file_hash=e.data[0],mo("progress-alert").style.display="none",console.log("uploaded "+i.file_hash),Nh(i,!0))},l.postMessage([Ji?"hashc":"hash",t])},d=mo("file_upload");So(d,"change",u,!1),qh=function(e,t){var r=t.d_length||0,i=t.clength_||0,n=0;i&&(n=parseInt(r/i*100));var s=document.createElement("div");s.className="progress";var a=document.createElement("p");a.className="bar",a.innerHTML=Zs+n+"%";var o=document.createElement("div");o.className="progcont";var c=document.createElement("div");return c.className="progint",c.style.width=n+"%",o.appendChild(c),s.appendChild(a),s.appendChild(o),e.appendChild(s),s.progtxt=a,s.progbar=c,So(s,"mousedown",Mh.bind(t),!1),s};var f=function(e,t){var r=e.name_||e.name,i=e.blob_||e.data||new Blob([]),n=tc(r),s=i.type||e.content_chrome||e.content_||e.type,a=$a[n]?$a[n]:-1!==Ao.indexOf(n)&&-1!==s.indexOf("image")?URL.createObjectURL(i):$a.exe,o=document.createElement("div");o.className="thumbwrap",t&&(o.id=t);var c=document.createElement("div");c.className="thumb";var l=document.createElement("img");l.className="thumbimg",l.src=a;var h=document.createElement("div");h.align="center";var u=document.createElement("span");return u.className="thumbspan",u.innerHTML=r,c.appendChild(l),o.appendChild(c),h.appendChild(u),o.appendChild(h),o},p=function(e,t){console.log("compute hash"),e.file_hash=0,So(document.body,"mousedown",function(){},!1),du("<p style='text-align:center'>Calculating hash for a resumed file, please wait...</p>"),mo("progress-alert").style.display="block",mo("progint-alert").style.width="0%";var r=e.blob_,i=new Worker(URL.createObjectURL(new Blob([gu],{type:"text/javascript"}))),n=r.size,s=0;i.onmessage=function(r){var i=r.data.pop?0:parseInt(r.data);if(s+=i,mo("progint-alert").style.width=parseInt(100*s/n)+"%",r.data.pop){mo("progress-alert").style.display="none",setTimeout(function(){mo("alert_box").style.display="none"},1e4),e.file_hash=r.data[0];var a=function(){h(e),l(e),_(e,t)};e.queue_.push(a),So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1),1===e.queue_.length&&e.queue_[0]()}},i.postMessage(["hash",r])};Nh=function(e,t,r){console.log("store_DB "),So(document.body,"mousedown",function(){},!1),e.nb_try===Ls||e.reason_||du("<p style='text-align:center'>Storing file, please wait that the file appears in Local Files (for large files this can take some time)</p>"),no.store=function(){var i,n=Ji?[]:null,s=0,a=Fh();e.file_id=e.file_id||0;var o=a.get([e.file_id,s]),c=e.blob_ instanceof Uint8Array?e.content_chrome?e.content_chrome:e.content_:e.blob_.type,u=new Blob([],{type:c});if(li)var i=Date.now();o.onsuccess=function(o){var d=o.target.result;if(d){var f=d.data;f instanceof Array?(f.unshift(u),u=new Blob(f,{type:c})):u=new Blob([u,f],{type:c}),Ji&&(f instanceof Array?(f.shift(),n=n.concat(f)):n.push(f)),a.delete([e.file_id,s]),s++,m=a.get([e.file_id,s]),m.onsuccess=this.onsuccess}else{console.log("Saving chunks size "+u.size+(i?" time to read all chunks "+(Date.now()-i):"")),Ji&&(e.blob_ instanceof Array?n=n.concat(e.blob_):n.push(e.blob_)),e.blob_=new Blob([u,e.blob_],{type:c});var g=go(),m=g.get(e.hash_ini);console.log("store_DB open");var y=Date.now();m.onsuccess=function(i){console.log("store_DB success "+(Date.now()-y));var s=i.target.result;if(s?(Ph(mo(s.name_hash)),Ji?(f=s.data.concat(n),e.blob_=new Blob(f,{type:e.content_chrome?e.content_chrome:e.content_})):(f=new Blob([s.data,e.blob_],{type:c}),e.blob_=f)):f=Ji?n:e.blob_,!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+ta)}e.file_hash=e.file_hash||0,e.d_length=e.blob_.size,t||h(e),r||l(e),e.check_hash||e.clength_!==e.d_length?_(e,f,r):p(e,f),console.log("Chunks saved "+(Date.now()-y)),mo("alert_box").style.display="none",So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1)}}}},no.store()};var _=function(e,t,r){e.file_hash=e.file_hash||0;var i=go();i.put(Ji?{hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t,enc:e.content_chrome||""}:{hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t}),r?r(e):(e.d_length===e.clength_&&ks&&ks.send_db_info(),rc(e))},g=function(e,t){if(yi)var r=Date.now();var i=no.db,n=i.transaction([vo+"_"],"readwrite"),s=n.objectStore(vo+"_");if(!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+ta)}e.file_id?e.chunk_nb++:(e.file_id=Date.now(),e.chunk_nb=0),s.put({k:[e.file_id,e.chunk_nb],file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,content_:e.content_,clength_:e.clength_,d_length:e.d_length,url_:e.url_,key:e.key?e.key:"",data:t}),r&&console.log("db_perf "+(Date.now()-r));var o=e.queue_;o.shift(),o.length&&o[0]()};ru=function(e){console.log("duration: "+e);var t=e.split("PT"),r=t[1].split("H"),i=parseFloat(r[1].split("M")[1].split("S")[0]);return t=t[1].split("H")[0],r=r[1].split("M")[0],3600*t+60*r+i};var m=function(){try{log("addsourcebuffer "+this._stream_.readyState),this._source_=this._stream_.addSourceBuffer(this.mime_codec)}catch(e){console.log("wait open addsourcebuffer failed")}},y=function(e,t){if(e.received_===t)mo("alert_box").style.display="none",e._source_.addEventListener("updateend",function(){sc(e)}),sc(e);else if(e.received_>t&&(0===e.append_cursor&&(e.wait_chunk=!0),e.wait_chunk)){var r=Math.min(Math.ceil((e.clength_-e.d_length)/Ja),Ua/4);e.append_cursor++,e.append_cursor>=r&&(delete e.wait_chunk,sc(e))}},v=function(e,t){if(t._stream_&&!t._streaming_){if(t.d_length+=e.length,t._json_+=e.toString("utf8"),t.d_length>=t.clength_){console.log("json "+t._json_);try{var r=JSON.parse(t._json_)}catch(i){return console.log("wrong json file, retrying"),t=L(t.hash_ini,null,!0),void xc(t)}for(var n in r)if("Duration"!==n){var s=L(r[n].Representation.BaseURL,null,!0);if(t.nb_sources.push(s),s._streaming_=!0,s.mime_codec=r[n].Representation.mimeType+'; codecs="'+r[n].Representation.codecs+'"',s._stream_=t._stream_,s._parent_=t,s._bandwidth_=r[n].Representation.bandwidth,s._width_=r[n].Representation.width,s._height_=r[n].Representation.height,"open"===t._stream_.readyState)try{s._source_=t._stream_.addSourceBuffer(s.mime_codec)}catch(i){console.log("addsourcebuffer failed"),t._wait_open.push(m.bind(s))}else t._wait_open.push(m.bind(s));xc(s)}else(tu=function(){var e=r[n];"open"===t._stream_.readyState?t._stream_.duration=ru(e):(console.log("media stream not ready yet - retry later"),setTimeout(tu,500))})();console.log("Queue fin json "+t.d_length+" "+t.clength_+" "+(parseInt(8*Ja*t.received_/((Date.now()-t.start_t0)/1e3))+" bps ")),_u(t.sendme_tout),_u(t.waiting_),t.eof_=!0,fin_.call(t)}}else if(t._streaming_){if(t.d_length+=e.length,t.append_buffer.push(e),t._source_)y(t,Math.min(Ua,t.pieces));else if(t.mp4box){var a=t.append_buffer.length;if((a>=Da||t.d_length>=t.clength_)&&(!t._moov_||t._moov_===ja)){t._moov_&&(t.mp4box.inputIsoFile||(t.mp4box.inputIsoFile=new Kl),t._parent_.mp4box.inputIsoFile?t.mp4box.inputIsoFile.ftyp=t._parent_.mp4box.inputIsoFile.ftyp:setTimeout(function(){v(new ii(0),t)},1e3));for(var o=t.append_buffer.concatBuffers(),c=0;a>c;c++)t.append_buffer.shift();t._moov_&&console.log("appending moov mp4box length "+o.length),o.buffer.fileStart=t.mp4box._fileStart_||0,t.mp4box._fileStart_+=o.length,t.mp4box.appendBuffer(o.buffer)}if(t._moov_&&t._moov_!==ja&&(t._moov_===!0?t._moov_=e.toString("hex"):t._moov_+=e.toString("hex"),-1!==t._moov_.indexOf(ja))){console.log("moov found");var l=t._moov_.split(ja),h=l[0],u=l[1];h=h.substr(h.length-8,h.length),console.log("moov size "+h+" rest "+u.length),t._moov_=ja,t.append_buffer=[],t.append_buffer.push(new ii(h+ja+u,"hex"))}}t.d_length>=t.clength_&&(console.log("Queue fin streaming "+t.d_length+" "+t.clength_+" "+(parseInt(8*Ja*t.received_/((Date.now()-t.start_t0)/1e3))+" bps ")),console.log("queue length "+t.append_buffer.length+" cursor "+t.append_cursor+" received "+t.received_),_u(t.sendme_tout),_u(t.waiting_),t.eof_=!0,t.mp4box&&t.mp4box.flush(),fin_.call(t))}else if(t.eof_)console.log("EOF");else{var d=function(e){return function(){if(t.d_length+=e.length,!t.blob_){t.content_=t.content_||"application/octet-binary";var r=t.content_.split(";");if(r.length>1&&(t.content_=r[0],t.content_chrome=r[1]||"application/octet-binary"),t.blob_=Ji?new ii(0):new Blob([],{type:t.content_chrome?t.content_chrome:t.content_}),!t.reload2_&&!t.reload_){t.check_hash=new vn("sha1");var i=go();i.delete(t.hash_ini)}t.clength_||Ph(t.bar_)}if(t.blob_=Ji?t.blob_.length?[t.blob_,e].concatBuffers():e:new Blob([t.blob_,e],{type:t.content_chrome?t.content_chrome:t.content_}),t.check_hash&&t.check_hash.update(e),t.clength_){var n=t.blob_.size||t.blob_.length||t.blob_.byteLength;if(n>=na&&t.d_length<t.clength_){t.queue_=t.queue_||[];var s=function(e){return function(){g(t,e)}};t.queue_.push(s(t.blob_)),t.blob_=Ji?new ii(0):new Blob([],{type:t.content_chrome?t.content_chrome:t.content_}),1===t.queue_.length&&t.queue_[0]()}else t.d_length>=t.clength_&&(console.log("Queue fin "+t.d_length+" "+t.clength_+" "+(parseInt(8*Ja*t.received_/((Date.now()-t.start_t0)/1e3))+" bps ")+(t.blob_.size||t.blob_.length||t.blob_.byteLength)),_u(t.sendme_tout),_u(t.waiting_),t.eof_=!0,t.queue_.push(fin_.bind(t)),1===t.queue_.length&&t.queue_[0]());if(t.clength_||t.d_length>=t.clength_){var a=parseInt(t.d_length/t.clength_*100);t.bar_.progtxt.innerHTML=Zs+parseInt(t.d_length/1e3)+" kB",t.bar_.progbar.style.width=a+"%"}t.queue_s.shift(),t.queue_s.length&&t.queue_s[0]()}}};t.queue_s=t.queue_s||[],t.queue_s.push(d(e)),1===t.queue_s.length&&t.queue_s[0]()}};Ph=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},fin_=function(){console.log("execute fin"),this.eof_=!0,this.queue_=[],this.queue_s=[],this.cid_&&(this.cid_===ks?(console.log("sending db_end CIC "+this.cid_.circId+" sid "+this.sid_),this.cid_.send_db_end(1,this.sid_)):this.d_length<this.clength_&&this.cid_.send_relay_end(this.sid_),this.cid_.destroy_cid(this)),this._stream_?(clearTimeout(this._torrentc_),iu=!1):kh(this)},Mh=function(){D("menu"),this.eof||(this.nb_try=Ls+1,_u(this.query_t0),_u(this.sendme_tout),_u(this.waiting_),clearTimeout(this.mp4box_t0),this.pieces=0,this.cid_&&(this.cid_===ks?this.cid_.send_db_end(1,this.sid_):this.d_length<this.clength_&&this.cid_.send_relay_end(this.sid_),this.cid_.destroy_cid(this)),this.eof_=!0,this.queue_=this.queue_||[],this._stream_?(console.log("stop streaming"),fin_.call(this)):(this.queue_.push(fin_.bind(this)),setTimeout(function(){du("<p style='text-align:center'>Stopping download, please wait that pending data are processed, use resume to restart</p>")},500)),1===this.queue_.length&&this.queue_[0]())};var b=function(e,t){du('<p style="text-align:center"> Error: '+t+" - This media can not be streamed, please use Download</p>"),Ph(Uh),Ph(nu),Mh.call(e)};Hh=function(e){var t=e.content_;if(console.log("init_media "+t),-1===t.indexOf("json")&&(-1===t.indexOf("video")&&-1===t.indexOf("audio")&&-1===t.indexOf("binary")||e._streaming_))-1===t.indexOf("video")&&-1===t.indexOf("audio")&&-1===t.indexOf("binary")||!e._parent_?(du('<p style="text-align:center">Error: not an audio/video file - This media can not be streamed, please use Download</p>'),document.body.removeChild(Uh),Mh.call(e)):e._moov_||(e._parent_.connected_sources++,e._parent_.connected_sources===e._parent_.nb_sources.length&&(console.log("play media already fragmented"),du('<p style="text-align:center">Connected... the video is going to start, please wait</p>'),nu.play()));else{Ph(nu),nu=document.createElement("video"),nu.className="mediasrc",nu.controls=!0,e._stream_=new Rh,nu.src=URL.createObjectURL(e._stream_),nu._stream_=e._stream_,Uh.appendChild(nu),So(Dh,"mousedown",function(){Ph(Uh),Ph(nu),e.nb_sources.forEach(function(e){Mh.call(e)}),Mh.call(e)},!0),-1===t.indexOf("json")&&(e._streaming_=!0);var r=function(){if(-1===t.indexOf("json"))-1!==t.indexOf("webm")?(e.nb_sources=[],e._streaming_=!0,e._source_=e._stream_.addSourceBuffer('video/webm; codecs="vp8,vorbis"'),console.log("play media"),du('<p style="text-align:center">Connected... the video is going to start, please wait</p>'),nu.play()):e.mime_codec||(e.nb_sources=[],e._streaming_=!0,e.mp4box=new Gl,du('<p style="text-align:center">Connected... Analyzing if this video can be streamed, please wait</p>'),e.mp4box._fileStart_=0,e.mp4box.onMoovStart=function(){console.log("moov start"),du('<p style="text-align:center">The video is going to start, please wait</p>')},e.mp4box.onReady=function(t){if(clearTimeout(e.mp4box_t0),e._moov_&&(Mh.call(e._moov_),delete request_moov.mp4box),console.log("play media mp4box ready"),nu.play(),t.tracks){for(;t.tracks.length;){var r=t.tracks.shift();if(r){var i='video/mp4; codecs=" '+r.codec+'"';console.log("mp4box mime: "+i),console.log(JSON.stringify(r));var n=!1;if(Rh.isTypeSupported(i)){n=!0;var s={append_buffer:[]};if(s._stream_=e._stream_,s._source_=e._stream_.addSourceBuffer(i),s._source_.request=s,s.pieces=e.pieces,s.mp4box=!0,s.track=r.id,s.received_=0,s.append_cursor=0,s.clength_=e.clength_,s.d_length_=0,Si)var a=Date.now();e.mp4box.onSegment=function(e,t,r){r=new Uint8Array(r),t.received_++,a&&(Ia++,Ta+=r.length,xa+=Date.now()-a,Ia%Ba===0&&xa&&(console.log("MP4BOX perf track "+t.track+":"+parseInt(8*Ta/(xa/1e3))+" bps - received from mp4box"+Ta+" Bytes since "+parseInt(xa/1e3)+" s"),Ia=0)),t.append_buffer.push(r),t._init_?(1===t.received_&&(mo("alert_box").style.display="none",t._source_.addEventListener("updateend",function(){sc(t)})),sc(t)):t.wait_init=!0};var o;if(r.video){var c=parseInt(e.clength_/r.nb_samples);o=Math.ceil(Na/c)}else o=1e3;console.log("nbsamples for track "+r.id+" "+o),e.mp4box.setSegmentOptions(r.id,s,{nbSamples:o})}if(!n)return console.log(r.codec+" codec not supported"),void b(e,r.codec+" codec not supported")}}var l=e.mp4box.initializeSegmentation();console.log("init length "+l.length);for(var h=function(e){var t=e.target.request;t._source_.removeEventListener("updateend",h),t._init_=!0,t.wait_init&&(console.log("wait_init"),t._source_.addEventListener("updateend",function(){sc(t)}),sc(t))};l.length;){var u=l.shift(),d=u.user;console.log("init segment track "+u.user.track+" "+u.buffer.byteLength),d.append_buffer.push(new Uint8Array(u.buffer)),d._source_.addEventListener("updateend",h),sc(d)}}},e.mp4box.onError=function(){console.log("mp4box error"),b(e,"mp4box error"),delete e.mp4box});else for(;e._wait_open.length;)e._wait_open.shift()()};So(e._stream_,"webkitsourceopen",r,!1),So(e._stream_,"sourceopen",r,!1),e._stream_.addEventListener("sourceclose",function(){console.log("SOURCE CLOSED"),e.nb_sources.forEach(function(e){Mh.call(e)}),Mh.call(e)},!1),nu.addEventListener("seeking",function(){}),nu.addEventListener("pause",function(){}),nu.addEventListener("play",function(){}),nu.addEventListener("error",function(){du('<p style="text-align:center">Error: Media Source error - This media can not be streamed or something unexpected happened</p>'),e.nb_sources.forEach(function(e){Mh.call(e)}),Mh.call(e);try{e._stream_.endOfStream()}catch(t){}})}};var w=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,D("menu"),Ph(this.thumb_)},S=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,D("menu2");var t=this,r=function(){if(this.value){var e=go(),r=e.get(t.hash_ini);r.onsuccess=function(r){r.target.result&&(r.target.result.name=this.value,t.name_=this.value,e.put(r.target.result),t.thumb_&&h(t),l(t))}.bind(this)}};lu("<p style='text-align:center'>Enter new name:</p>",r)},E=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,D("menu2");var t=go();t.delete(this.hash_ini),Ph(this.thumb2_),Ph(this.thumb_)},C=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t=this;t.nb_try++,t.db_try=0,t.params_.db_=!0,t.reload_=!0,t.sid_&&(delete t.cid_[t.sid_],delete t.sid_),delete t.cid_,delete t.eof_,delete t.check_hash,delete t.last_saved,delete t.file_id,delete t.start_t0,_u(t.query_t0),t.name_=this.name_||"",t.queue_=[],t.queue_s=[],t.blob_=Ji?new ii(0):new Blob([],{type:t.content_chrome?t.content_chrome:t.content_}),t.cid_=ks,D("menu"),Ph(t.thumb_),t.bar_=qh(mo("downloaded"),t),xc(t)},A=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t=L(this.url_,this.hash_ini);t.clength_=this.clength_,t.d_length=this.d_length,t.content_=this.content_,t.reload2_=!0,t.thumb2_=this.thumb2_,delete t.eof_,delete t.last_saved,delete t.file_id,delete t.start_t0,t.queue_=[],t.queue_s=[],t.name_=this.name_||"",_u(t.query_t0),t.nb_try++,t.db_try=0,t.blob_=Ji?new ii(0):new Blob([],{type:t.content_chrome?t.content_chrome:t.content_}),t.cid_=ks,D("menu2"),Ph(this.thumb_),t.bar_=qh(mo("downloaded"),t),xc(t)},I=function(){var e=this.key;D("menu2"),So(document.body,"mousedown",function(){},!1),e?setTimeout(function(){du("<p style='text-align:center'>"+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file</p>")},800):du("<p style='text-align:center'>"+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file</p>"),mo("progress-alert").style.display="block",mo("progint-alert").style.width="0%";var t=e?new ii(e,"hex"):ac(16),r=this.blob_,i=r.size,n={file_hash:"00",hash_ini:o(),name_:e?c(this.name_):this.name_+"."+ta,clength_:i,d_length:0,content_:this.content_,url_:this.url_,key:e?"":t.toString("hex"),content_chrome:e?null:Ji?"application/binary":null,blob_:Ji?new ii(0):new Blob([],{type:e?this.content_:"application/octet-binary"}),queue_:[]},s=0;if(e){var a=go(),l=a.get(this.hash_ini);l.onsuccess=function(t){if(t.target.result){var r=t.target.result;r.key=e,this.key=e,So(this.thumb2_,"mousedown",U.bind({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,content_chrome:this.content_chrome,blob_:this.blob_}),!1),a.put(r)}}.bind(this)}var h=new Worker(URL.createObjectURL(new Blob([gu]))),u=[];if(vi)var d=Date.now();h.onmessage=function(t){var r=t.data,n=r instanceof Array?r[0]:r;r instanceof Array||(s+=n.length);var a=s;if(d&&(console.log("worker perf "+(Date.now()-d)),d=Date.now()),u.push(n),s%sa===0||s===i){var o=u,c=function(){mo("progint-alert").style.width=parseInt(100*(a/i))+"%",r instanceof Array?(this.check_hash=!0,this.file_hash=n,So(document.body,"mousedown",function(){setTimeout(Zh,1e3)},!1),mo("progress-alert").style.display="none",Nh(this,!0)):(this.file_hash="00",this.d_length=a,g(this,Ji?o:new Blob(o,{type:e?this.content_:"application/octet-binary"})))}.bind(this);u=[],this.queue_.push(c),1===this.queue_.length&&this.queue_[0]()}}.bind(n),h.postMessage(["aes-128-ctr",r,t,Hn])},T=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,I.call({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_})},x=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t={file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,content_:this.content_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_};if(this.blob_.type!==this.content_||"enc"===tc(this.name_))if(this.key)I.call(t);else{var r=function(){var e=this.value;32===e.length?(t.key=e,I.call(t)):setTimeout(function(){du("<p style='text-align:center'>Please enter a valid key</p>")},800)};lu("<p style='text-align:center'>Enter key:</p>",r)}else du("<p style='text-align:center'>This is not an encrypted file</p>")},B=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,du("<li>Hash Name: "+this.hash_ini+"</li><li>File hash: "+this.file_hash+"</li><li>File Type: "+this.content_+"</li><li>File size: "+this.clength_+" bytes</li><li>Current size: "+this.d_length+" bytes</li><li>Key: "+((this.content_chrome?1:this.content_!==this.blob_.type||"enc"===tc(this.name_))?this.key?this.key:"Get the encryption key from peer":"Not encrypted")+"</li>")},k=function(e,t){var r=mo(e);r&&(r.event_&&Eo(r,"mousedown",r.event_,!1),r.event_=t.bind(this),So(r,"mousedown",r.event_,!1))},R=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t=mo("menu2");t.style.display="none",t=mo("menu"),t.style.top=bo(e)+"px",t.style.left=wo(e)+"px",t.style.display="block",mo("open").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),k.call(this,"delete",w),k.call(this,"reload",C),this.clength_===this.d_length?fu(mo("reload")):pu(mo("reload"))},U=function(e){if(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,ks&&ts>=1){var t=mo("menu");t.style.display="none",t=mo("menu2"),t.style.top=bo(e)+"px",t.style.left=wo(e)+"px",t.style.display="block",mo("open2").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),k.call(this,"delete2",E),k.call(this,"rename2",S),k.call(this,"property2",B),this.d_length===this.clength_?fu(mo("reload2")):(pu(mo("reload2")),k.call(this,"reload2",A));var r=this.blob_.type||(this.content_chrome?this.content_chrome:this.content_);this.key||r!==this.content_||"enc"===tc(this.name_)?(fu(mo("encrypt2")),pu(mo("decrypt2")),k.call(this,"decrypt2",x)):(pu(mo("encrypt2")),k.call(this,"encrypt2",T),fu(mo("decrypt2")))}else du('<p style="text-align:center">Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit</p>')},D=function(e){var t=mo(e);t.style.display="none"};Zh=function(){var e=mo("menu");e.style.display="none",e=mo("menu2"),e.style.display="none",mo("alert_box").style.display="none",mo("prompt_box").style.display="none"},kh=function(e){e.blob_?(e.check_hash&&(e.file_hash=e.check_hash.digest("hex")),console.log("Blob loaded "+e.d_length+" "+(e.file_hash||"")),Nh(e),Ph(e.bar_)):Ph(e.bar_)},So(document.body,"mousedown",function(){setTimeout(Zh,1e3)
},!1),So(mo("dialog-message"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1);var N=function(e,t){if(!t||t&&(nu.parentNode?!1:!iu))if(ks&&ts>1){console.log("Start loading url");var r=L(e,null,t);40!==r.hash_ini.length||isNaN(Number("0x"+r.hash_ini))?du('<p style="text-align:center">Please enter a valid reference (hash_name, magnet link, infohash or url)</p>'):(r.d_length=0,Ph(r.thumb_),Ph(mo(r.hash_ini)),t?(iu=!0,O(r)):(r.bar_=qh(mo("downloaded"),r),Ph(nu),Ph(Uh),iu=!1),(r.bar_||r._stream_&&Rh)&&xc(r))}else du('<p style="text-align:center">Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit</p>')},L=function(e,t,r){if(!t){var i=xo(e);if(i)t=i,e="";else if(-1!==e.indexOf("http")||-1!==e.indexOf("https")){var n=an.createhash("sha1");n.update(new ii(e,"utf8")),t=n.digest("hex")}else t=e,e=""}var s=Ec(e);s.params_.hash_=new ii(t,"hex"),s.hash_ini=t,s.url_=e,e=Lo(e),s.params_.stream=Ko(e.host,e.rest),s.params_.host=e.host+":"+("https"===e.protcol?"443":"80"),s.params_.db_=!0,s.cid_=ks,s.download_=[],s.d_length=0,s.nb_try=0;var a=e.rest.split("/");return s.name_=a.length?a[a.length-1]:"",s._write_=function(e){v(e,this)},s.queue_=[],s.db_try=0,s.sendme_tout=[],s.waiting_=[],s.queue_s=[],s._stream_=r||!1,r&&(s.stream_buffer=[],s.append_buffer=[],s.append_cursor=0,s.append_wait=new ii(0),s.nb_sources=[],s.connected_sources=0,s.debug_chunk=[],s.append_to=[],s._wait_open=[],s._json_=""),s},O=function(e){Rh=window.MediaSource||window.webkitMediaSource||window.WebKitMediaSource||window.webkitMediaSource||window.MozMediaSource||!1,Rh?(Uh=document.createElement("div"),Uh.className="media",document.body.appendChild(Uh),Dh=document.createElement("div"),Dh.className="boxclose",Uh.appendChild(Dh),So(Dh,"mousedown",function(){Ph(Uh),Ph(nu),Mh.call(e)},!0)):du('<p style="text-align:center">Media Source is not available in your browser, so streaming is not possible, please update it or try with Chrome browser.</p>')},P=function(){e(),t(),chart1_int=setInterval(function(){r(zh,Vh,Kh)},5e3),chart2_int=setInterval(function(){r(Gh,Wh,Yh)},5e3),So(mo("chart1"),"mousedown",function(){$s?clearInterval(chart1_int):chart1_int=setInterval(function(){r(zh,Vh,Kh)},5e3),$s=!$s},!1),So(mo("chart2"),"mousedown",function(){ea?clearInterval(chart2_int):chart2_int=setInterval(function(){r(Gh,Wh,Yh)},5e3),ea=!ea},!1)},F=function(){no.list=function(e){var t=no.db.transaction([vo],"readwrite").objectStore(vo);t.openCursor().onsuccess=function(t){var r=t.target.result;if(r){var i=r.value;e(i),r.continue()}else Oh&&mu()}},no.list(q)},q=function(e){Ji&&(e.data=new Blob(e.data,{type:e.enc?e.enc:e.type}));var t=f(e,e.name_hash);mo("local").appendChild(t),So(t,"mousedown",U.bind({file_hash:e.hash,hash_ini:e.name_hash,name_:e.name,thumb2_:t,clength_:e.file_length,d_length:e.current_length,content_:e.type,url_:e.file_url,key:e.key,content_chrome:e.enc||"",blob_:e.data}),!1),e.file_length!==e.current_length&&(t.firstChild.style.backgroundColor="orange")};if(Xh){var M=(ks?1:0)+(ts>=0?ts:0);mo("direct_text").innerHTML="Direct, P2P and bittorrent anonymized circuits : "+M+(M>1?" circuits":" circuit"),pu(mo("direct_text")),pu(mo("peer_text"))}else{var H=document.createElement("script");H.src="http://www.peersm.com/gchart.js",H.onload=P,document.body.appendChild(H)}mo("prompt-input").removeAttribute("type"),F()}}}}();