Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Semi-Unofficial port of vPGP2 to Firefox. ALPHA VERSION
// ==UserScript==
// @name libakasakacore vPGP bundle
// @namespace libakasakacore
// @description by popular demand, ported to FFox by Genjitsu Gadget Lab team
// @include *://vk.com/*
// @version 1
// @grant GM_addStyle
// ==/UserScript==
function addJS_Node (text, s_URL, funcToRun, runOnLoad) {
var D = document;
var scriptNode = D.createElement ('script');
if (runOnLoad) {
scriptNode.addEventListener ("load", runOnLoad, false);
}
scriptNode.type = "text/javascript";
if (text) scriptNode.textContent = text;
if (s_URL) scriptNode.src = s_URL;
if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()';
var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
targ.appendChild (scriptNode);
}
var uri="data:text/javascript;base64,Ly8gPT1Vc2VyU2NyaXB0PT0NCi8vIEBuYW1lICAgICAgICBsaWJha2FzYWthY29yZSBidW5kbGUNCi8vIEBuYW1lc3BhY2UgICBsaWJha2FzYWthY29yZQ0KLy8gQGRlc2NyaXB0aW9uIGJ5IHBvcHVsYXIgZGVtYW5kLCBieSBHZW5qaXRzdSBHYWRnZXQgTGFiIHRlYW0NCi8vIEBpbmNsdWRlICAgICB2ay5jb20NCi8vIEB2ZXJzaW9uICAgICAxDQovLyBAZ3JhbnQgICAgICAgbm9uZQ0KLy8gPT0vVXNlclNjcmlwdD09DQoNCnZhciBsaWJha2FzYWthZ3VpID0gbmV3IE9iamVjdDsNCmxpYmFrYXNha2FndWkuZGVmRm9vdGVyID0gJzxmb250IHN0eWxlPSJjb2xvcjojYWFhIiBvbmNsaWNrPSJsaWJha2FzYWthZ3VpLmFib3V0KCkiPkVsIFBzeSBDb25ncm9vPC9mb250Pic7DQpsaWJha2FzYWthZ3VpLmFib3V0ID0gZnVuY3Rpb24oKSB7DQoJLyog0e7n5ODl7CDs5fHx4OTm4e7q8SAqLyANCgl2YXIgbXlib3ggPSB3aW5kb3cuTWVzc2FnZUJveCh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UudG9TdHJpbmcoKSk7DQoJCQkJCQkJfQ0KCQkJCQkJCX0NCgkJCQkJCX0NCgkJCSAgICAgICAgICAgIHJvd19pZCA9IGFkZF9yb3cuaWQ7DQoJCQkgICAgICAgICAgICBhZGRfcm93LmlkID0gJyc7DQoJCQkgICAgICAgICAgICBpZiAoZ2Uocm93X2lkKSkgew0KCQkJICAgICAgICAgICAgICByZShhZGRfcm93KTsNCgkJCSAgICAgICAgICAgICAgY29udGludWU7DQoJCQkgICAgICAgICAgICB9DQoJCQkgICAgICAgICAgICBhZGRfcm93LmlkID0gcm93X2lkOw0KCQkJICAgICAgICAgICAgaWYgKG1vcmUgPCAwKSB7DQoJCQkgICAgICAgICAgICAgIGN1cl9yb3dzLmFwcGVuZENoaWxkKGFkZF9yb3cpOw0KCQkJICAgICAgICAgICAgfSBlbHNlIHsNCgkJCSAgICAgICAgICAgICAgY3VyX3Jvd3MuaW5zZXJ0QmVmb3JlKGFkZF9yb3csIGJlZm9yZV9yb3cpOw0KCQkJICAgICAgICAgICAgfQ0KCQkJICAgICAgICAgIH0NCgkJCSAgICAgICAgICByZShuZXdfdCk7DQoJCQkgICAgICAgICAgSU0udXBkYXRlUGVlcihwZWVyX2lkLCBtc2dzLCBhbGxfc2hvd24sIChtb3JlIDwgMCkgPyAtMSA6IDApOw0KCQkJICAgICAgICAgIGRlbGV0ZSBjdXIudGFic1twZWVyX2lkXS5sb2FkaW5nSGlzdG9yeTsNCgkJCSAgICAgICAgICBjbGVhclRpbWVvdXQobG9hZGluZ1RpbWVvdXQpOw0KCQkJICAgICAgICAgIGlmIChjdXIuZm9jdXNlZCA9PSBwZWVyX2lkKSB7DQoJCQkgICAgICAgICAgICBJTS5yZWFkTGFzdE1zZ3MoKTsNCgkJCSAgICAgICAgICB9DQoJCQkgICAgICAgICAgaWYgKGN1ci5wZWVyID09IHBlZXJfaWQpIElNLmFwcGx5UGVlcigpOw0KCQkJICAgICAgICAgIElNLnVwZGF0ZVNjcm9sbChtb3JlI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CkgeyByLnQgPSAwOyByZXR1cm47IH0NCiAgdmFyIGJzID0gbiV0aGlzLkRCOw0KICB2YXIgY2JzID0gdGhpcy5EQi1iczsNCiAgdmFyIGJtID0gKDE8PGJzKS0xOw0KICByWzBdID0gdGhpc1tkc10+PmJzOw0KICBmb3IodmFyIGkgPSBkcysxOyBpIDwgdGhpcy50OyArK2kpIHsNCiAgICByW2ktZHMtMV0gfD0gKHRoaXNbaV0mYm0pPDxjYnM7DQogICAgcltpLWRzXSA9IHRoaXNbaV0+PmJzOw0KICB9DQogIGlmKGJzID4gMCkgclt0aGlzLnQtZHMtMV0gfD0gKHRoaXMucyZibSk8PGNiczsNCiAgci50ID0gdGhpcy50LWRzOw0KICByLmNsYW1wKCk7DQp9DQoNCi8vIChwcm90ZWN0ZWQpIHIgPSB0aGlzIC0gYQ0KZnVuY3Rpb24gYm5wU3ViVG8oYSxyKSB7DQogIHZhciBpID0gMCwgYyA9IDAsIG0gPSBNYXRoLm1pbihhLnQsdGhpcy50KTsNCiAgd2hpbGUoaSA8IG0pIHsNCiAgICBjICs9IHRoaXNbaV0tYVtpXTsNCiAgICByW2krK10gPSBjJnRoaXMuRE07DQogICAgYyA+Pj0gdGhpcy5EQjsNCiAgfQ0KICBpZihhLnQgPCB0aGlzLnQpIHsNCiAgICBjIC09IGEuczsNCiAgICB3aGlsZShpIDwgdGhpcy50KSB7DQogICAgICBjICs9IHRoaXNbaV07DQogICAgICByW2krK10gPSBjJnRoaXMuRE07DQogICAgICBjID4+PSB0aGlzLkRCOw0KICAgIH0NCiAgICBjICs9IHRoaXMuczsNCiAgfQ0KICBlbHNlIHsNCiAgICBjICs9IHRoaXMuczsNCiAgICB3aGlsZShpIDwgYS50KSB7DQogICAgICBjIC09IGFbaV07DQogICAgICByW2krK10gPSBjJnRoaXMuRE07DQogICAgICBjID4+PSB0aGlzLkRCOw0KICAgIH0NCiAgICBjIC09IGEuczsNCiAgfQ0KICByLnMgPSAoYzwwKT8tMTowOw0KICBpZihj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WFrOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZm9yKDs7KSB7DQogICAgICAgICAgICAgICAga2V5LnEgPSBuZXcgQmlnSW50ZWdlcihxcywxLHJuZyk7DQogICAgICAgICAgICAgICAgaWYoa2V5LnEuc3VidHJhY3QoQmlnSW50ZWdlci5PTkUpLmdjZChrZXkuZWUpLmNvbXBhcmVUbyhCaWdJbnRlZ2VyLk9ORSkgPT0gMCAmJiBrZXkucS5pc1Byb2JhYmxlUHJpbWUoMTApKSBicmVhazsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGlmKGtleS5wLmNvbXBhcmVUbyhrZXkucSkgPD0gMCkgew0KICAgICAgICAgICAgICAgIHZhciB0ID0ga2V5LnA7DQogICAgICAgICAgICAgICAga2V5LnAgPSBrZXkucTsNCiAgICAgICAgICAgICAgICBrZXkucSA9IHQ7DQogICAgICAgICAgICB9DQogICAgICAgICAgICB2YXIgcDEgPSBrZXkucC5zdWJ0cmFjdChCaWdJbnRlZ2VyLk9ORSk7DQogICAgICAgICAgICB2YXIgcTEgPSBrZXkucS5zdWJ0cmFjdChCaWdJbnRlZ2VyLk9ORSk7DQogICAgICAgICAgICB2YXIgcGhpID0gcDEubXVsdGlwbHkocTEpOw0KICAgICAgICAgICAgaWYocGhpLmdjZChrZXkuZWUpLmNvbXBhcmVUbyhCaWdJbnRlZ2VyLk9ORSkgPT0gMCkgew0KICAgICAgICAgICAgICAgIGtleS5uID0ga2V5LnAubXVsdGlwbHkoa2V5LnEpOw0KICAgICAgICAgICAgICAgIGtleS5kID0ga2V5LmVlLm1vZEludmVyc2UocGhpKTsNCiAgICAgICAgICAgICAgICBrZXkuZG1wMSA9IGtleS5kLm1vZChwMSk7DQogICAgICAgICAgICAgICAga2V5LmRtcTEgPSBrZXkuZC5tb2QocTEpOw0KICAgICAgICAgICAgICAgIGtleS51ID0ga2V5LnAubW9kSW52ZXJzZShrZXkucSk7DQogICAgICAgICAgICAgICAgYnJlYWs7DQogICAgIC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HM9MTI7DQogICBrYz02Ow0KICB9DQogIGVsc2UgaWYoa2V5bGVuPT0zMikNCiAgew0KICAgcm91bmRzPTE0Ow0KICAga2M9ODsNCiAgfQ0KICBlbHNlDQogIHsNCgl1dGlsLnByaW50X2Vycm9yKCdhZXMuanM6IEludmFsaWQga2V5LWxlbmd0aCBmb3IgQUVTIGtleTonK2tleWxlbik7DQogICByZXR1cm47DQogIH0NCg0KICBmb3IoaT0wOyBpPG1heHJrKzE7IGkrKykga2V5U2NoZWRbaV09bmV3IEFycmF5KDQpOw0KDQogIGZvcihpPTAsaj0wOyBqPGtleWxlbjsgaisrLGkrPTQpDQogICAga1tqXSA9IGtleS5jaGFyQ29kZUF0KGkpIHwgKGtleS5jaGFyQ29kZUF0KGkrMSk8PDgpDQogICAgICAgICAgICAgICAgICAgICB8IChrZXkuY2hhckNvZGVBdChpKzIpPDwxNikgfCAoa2V5LmNoYXJDb2RlQXQoaSszKTw8MjQpOw0KDQogIGZvcihqPWtjLTE7IGo+PTA7IGotLSkgdGtbal0gPSBrW2pdOw0KDQogIHI9MDsNCiAgdD0wOw0KICBmb3Ioaj0wOyAoajxrYykmJihyPHJvdW5kcysxKTsgKQ0KICB7DQogICAgZm9yKDsgKGo8a2MpJiYodDw0KTsgaisrLHQrKykNCiAgICB7DQogICAgICBrZXlTY2hlZFtyXVt0XT10a1tqXTsNCiAgICB9DQogICAgaWYodD09NCkNCiAgICB7DQogICAgICByKys7DQogICAgICB0PTA7DQogICAgfQ0KICB9DQoNCiAgd2hpbGUocjxyb3VuZHMrMSkNCiAgew0KICAgIHZhciB0ZW1wID0gdGtba2MtMV07DQoNCiAgICB0a1swXSBePSBTW0IxKHRlbXApXSB8IChTW0IyKHRlbXApXTw8OCkgfCAoU1tCMyh0ZW1wKV08PDE2KSB8IChTW0IwKHRlbXApXTw8MjQpOw0KICAgIHRrWzBdIF49IFJjb25bcmNvbnBvaW50ZXIrK107DQoNCiAgICBpZihrYyAhPSA4KQ0KICAgIHsNCi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DAwNDEsIDB4MDA2MSwgMHgwMDgxLCAweDAwYzEsDQogICAgICAgIDB4MDEwMSwgMHgwMTgxLCAweDAyMDEsIDB4MDMwMSwgMHgwNDAxLCAweDA2MDEsIDB4MDgwMSwgMHgwYzAxLA0KICAgICAgICAweDEwMDEsIDB4MTgwMSwgMHgyMDAxLCAweDMwMDEsIDB4NDAwMSwgMHg2MDAxDQogICAgXSwNCg0KICAgIGNwZGV4dCA9IFsNCiAgICAgICAgMCwgIDAsICAwLCAgMCwgIDEsICAxLCAgMiwgIDIsDQogICAgICAgIDMsICAzLCAgNCwgIDQsICA1LCAgNSwgIDYsICA2LA0KICAgICAgICA3LCAgNywgIDgsICA4LCAgOSwgIDksIDEwLCAxMCwNCiAgICAgICAgMTEsIDExLCAxMiwgMTIsIDEzLCAxMw0KICAgIF0sDQogICAgDQogICAgYm9yZGVyID0gWzE2LCAxNywgMTgsIDAsIDgsIDcsIDksIDYsIDEwLCA1LCAxMSwgNCwgMTIsIDMsIDEzLCAyLCAxNCwgMSwgMTVdLA0KICAgIA0KICAgIGJBID0gYmFycmF5LA0KDQogICAgYnl0ZXBvcz0wLA0KICAgIGJpdHBvcz0wLA0KICAgIGJiID0gMSwNCiAgICBiaXRzPTAsDQogICAgDQogICAgTkFNRU1BWCA9IDI1NiwNCiAgICANCiAgICBuYW1lQnVmID0gW10sDQogICAgDQogICAgZmlsZW91dDsNCiAgICANCiAgICBmdW5jdGlvbiByZWFkQnl0ZSgpew0KICAgICAgICBiaXRzKz04Ow0KICAgICAgICBpZiAoYnl0ZXBvczxiQS5sZW5ndGgpew0KICAgICAgICAgICAgLy9pZiAoZGVidWcpDQogICAgICAgICAgICAvLyAgICBkb2N1bWVudC53cml0ZShieXRlcG9zKyI6ICIrYkFbYnl0ZXBvc10rIjxicj4iKTsNCiAgICAgICAgICAgIHJldHVybiBiQVtieXRlcG9zKytdOw0KICAgICAgICB9IGVsc2UNCiAgICAgICAgICAgIHJldHVybiAtMTsNCiAgICB9Ow0KDQogICAgZnVuY3Rpb24gYnl0ZUFsaWduKCl7DQogICAgICAgIGJiID0gMTsNCiAgICB9Ow0KICAgIA0KICAgIGZ1bmN0aW9uIHJlYWRCaXQoKXsNCiAgICAgICAgdmFyIGNhcnJ5Ow0KICAgICAgICBiaXRzKys7DQogICAgICAgIGNhcnJ5ID0gKGJiICYgMSk7DQogICAgICAgIGJiID4+PSAxOw0KICAgICAgICBpZiAoYmI9PTApew0KICAgICAgICAgICAgYmIgPSByZWFkQnl0ZSgpOw0KICAgICAgICAgICAgY2FycnkgPSAoYmIgJiAxKTsNCiAgICAgICAgICAgIGJiID0gKGJiPj4xKSB8IDB4ODA7DQogICAgICAgIH0NCiAgICAgICAgcmV0dXJuIGNhcnJ5Ow0KICAgIH07DQoNCiAgICBmdW5jdGlvbiByZWFkQml0cyhhKSB7DQogICAgICAgIHZhciByZXMgPSAwLA0KICAgICAgICAgICAgaSA9IGE7DQogICAgDQogICAgICAgIHdoaWxlKGktLSkgew0KICAgICAgICAgICAgcmVzID0gKHJlczw8MSkgfCByZWFkQml0KCk7DQogICAgICAgIH0NCiAgICAgICAgaWYoYSkgew0KICAgICAgICAgICAgcmVzID0gYml0UmV2ZXJzZVtyZXNdPj4oOC1hKTsNCiAgICAgICAgfQ0KICAgICAgICByZXR1cm4gcmVzOw0KICAgIH07DQogICAgICAgIA0KICAgIGZ1bmN0aW9uIGZsdXNoQnVmZmVyKCl7DQogICAgICAgIC8vZG9jdW1lbnQud3JpdGUoJ0ZMVVNIQlVGRkVSOicrYnVmMzJrKTsNCiAgICAgICAgYklkeCA9IDA7DQogICAgfTsNCiAgICBmdW5jdGlvbiBhZGRCdWZmZXIoYSl7DQogICAgICAgIFNJWkUrKzsNCiAgICAgICAgLy9DUkM9dXBkY3JjKGEsY3JjKTsNCiAgICAgICAgYnVmMzJrW2JJZHgrK10gPSBhOw0KICAgICAgICBvdXRwdXRBcnIucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGEpKTsNCiAgICAgICAgLy9vdXRwdXQrPVN0cmluZy5mcm9tQ2hhckNvZGUoYSk7DQogICAgICAgIGlmKGJJZHg9PTB4ODAwMCl7DQogICAgICAgICAgICAvL2RvY3VtZW50LndyaXRlKCdBRERCVUZGRVI6JytidWYzMmspOw0KICAgICAgICAgICAgYklkeD0wOw0KICAgICAgICB9DQogICAgfTsNCiAgICANCiAgICBmdW5jdGlvbiBIdWZOb2RlKCkgew0KICAgICAgICB0aGlzLmIwPTA7DQogICAgICAgIHRoaXMuYjE9MDsNCiAgICAgICAgdGhpcy5qdW1wID0gbnVsbDsNCiAgICAgICAgdGhpcy5qdW1wcG9zID0gLTE7DQogICAgfTsNCg0KICAgIHZhciBMSVRFUkFMUyA9IDI4ODsNCiAgICANCiAgICB2YXIgbGl0ZXJhbFRyZWUgPSBuZXcgQXJyYXkoTElURVJBTFMpOw0KICAgIHZhciBkaXN0YW5jZVRyZWUgPSBuZXcgQXJyYXkoMzIpOw0KICAgIHZhciB0cmVlcG9zPTA7DQogICAgdmFyIFBsYWNlcyA9IG51bGw7DQogICAgdmFyIFBsYWNlczIgPSBudWxsOw0KICAgIA0KICAgIHZhciBpbXBEaXN0YW5jZVRyZWUgPSBuZXcgQXJyYXkoNjQpOw0KICAgIHZhciBpbXBMZW5ndGhUcmVlID0gbmV3IEFycmF5KDY0KTsNCiAgICANCiAgICB2YXIgbGVuID0gMDsNCiAgICB2YXIgZnBvcyA9IG5ldyBBcnJheSgxNyk7DQogICAgZnBvc1swXT0wOw0KICAgIHZhciBmbGVuczsNCiAgICB2YXIgZm1heDsNCiAgICANCiAgICBmdW5jdGlvbiBJc1BhdCgpIHsNCiAgICAgICAgd2hpbGUgKDEpIHsNCiAgICAgICAgICAgIGlmIChmcG9zW2xlbl0gPj0gZm1heCkNCiAgICAgICAgICAgICAgICByZXR1cm4gLTE7DQogICAgICAgICAgICBpZiAoZmxlbnNbZnBvc1tsZW5dXSA9PSBsZW4pDQogICAgICAgICAgICAgICAgcmV0dXJuIGZwb3NbbGVuXSsrOw0KICAgICAgICAgICAgZnBvc1tsZW5dKys7DQogICAgICAgIH0NCiAgICB9Ow0KDQogICAgZnVuY3Rpb24gUmVjKCkgew0KICAgICAgICB2YXIgY3VycGxhY2UgPSBQbGFjZXNbdHJlZXBvc107DQogICAgICAgIHZhciB0bXA7DQogICAgICAgIGlmIChkZWJ1ZykNCiAgICAJCWRvY3VtZW50LndyaXRlKCI8YnI+bGVuOiIrbGVuKyIgdHJlZXBvczoiK3RyZWVwb3MpOw0KICAgICAgICBpZihsZW49PTE3KSB7IC8vd2FyIDE3DQogICAgICAgICAgICByZXR1cm4gLTE7DQogICAgICAgIH0NCiAgICAgICAgdHJlZXBvcysrOw0KICAgICAgICBsZW4rKzsNCiAgICAJDQogICAgICAgIHRtcCA9IElzUGF0KCk7DQogICAgICAgIGlmIChkZWJ1ZykNCiAgICAgICAgCWRvY3VtZW50LndyaXRlKCI8YnI+SXNQYXQgIit0bXApOw0KICAgICAgICBpZih0bXAgPj0gMCkgew0KICAgICAgICAgICAgY3VycGxhY2UuYjAgPSB0bXA7ICAgIC8qIGxlYWYgY2VsbCBmb3IgMC1iaXQgKi8NCiAgICAgICAgICAgIGlmIChkZWJ1ZykNCiAgICAgICAgICAgIAlkb2N1bWVudC53cml0ZSgiPGJyPmIwICIrY3VycGxhY2UuYjApOw0KICAgICAgICB9IGVsc2Ugew0KICAgICAgICAvKiBOb3QgYSBMZWFmIGNlbGwgKi8NCiAgICAgICAgY3VycGxhY2UuYjAgPSAweDgwMDA7DQogICAgICAgIGlmIChkZWJ1ZykNCiAgICAgICAgCWRvY3VtZW50LndyaXRlKCI8YnI+YjAgIitjdXJwbGFjZS5iMCk7DQogICAgICAgIGlmKFJlYygpKQ0KICAgICAgICAgICAgcmV0dXJuIC0xOw0KICAgICAgICB9DQogICAgICAgIHRtcCA9IElzUGF0KCk7DQogICAgICAgIGlmKHRtcCA+PSAwKSB7DQogICAgICAgICAgICBjdXJwbGFjZS5iMSA9IHRtcDs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QogICAgICAgIFBsYWNlcyA9IGN1cnJlbnRUcmVlOw0KICAgICAgICB0cmVlcG9zPTA7DQogICAgICAgIGZsZW5zID0gbGVuZ3RoczsNCiAgICAgICAgZm1heCAgPSBudW12YWw7DQogICAgICAgIGZvciAoaT0wO2k8MTc7aSsrKQ0KICAgICAgICAgICAgZnBvc1tpXSA9IDA7DQogICAgICAgIGxlbiA9IDA7DQogICAgICAgIGlmKFJlYygpKSB7DQogICAgICAgICAgICAvL2ZwcmludGYoc3RkZXJyLCAiaW52YWxpZCBodWZmbWFuIHRyZWVcbiIpOw0KICAgICAgICAgICAgaWYgKGRlYnVnKQ0KICAgICAgICAgICAgCWFsZXJ0KCJpbnZhbGlkIGh1ZmZtYW4gdHJlZVxuIik7DQogICAgICAgICAgICByZXR1cm4gLTE7DQogICAgICAgIH0NCiAgICAgICAgaWYgKGRlYnVnKXsNCiAgICAgICAgCWRvY3VtZW50LndyaXRlKCc8YnI+VHJlZTogJytQbGFjZXMubGVuZ3RoKTsNCiAgICAgICAgCWZvciAodmFyIGE9MDthPDMyO2ErKyl7DQogICAgICAgICAgICAJZG9jdW1lbnQud3JpdGUoIlBsYWNlc1siK2ErIl0uYjA9IitQbGFjZXNbYV0uYjArIjxicj4iKTsNCiAgICAgICAgICAgIAlkb2N1bWVudC53cml0ZSgiUGxhY2VzWyIrYSsiXS5iMT0iK1BsYWNlc1thXS5iMSsiPGJyPiIpOw0KICAgICAgICAJfQ0KICAgICAgICB9DQogICAgDQogICAgICAgIC8qaWYoc2hvdykgew0KICAgICAgICAgICAgdmFyIHRtcDsNCiAgICAgICAgICAgIGZvcih0bXA9Y3VycmVudFRyZWU7dG1wPFBsYWNlczt0bXArKykgew0KICAgICAgICAgICAgICAgIGZwcmludGYoc3Rkb3V0LCAiMHglMDN4ICAweCUwM3ggKDB4JTA0eCkiLHRtcC1jdXJyZW50VHJlZSwgdG1wLT5qdW1wP3RtcC0+anVtcC1jdXJyZW50VHJlZTowLCh0bXAtPmp1bXA/dG1wLT5qdW1wLWN1cnJlbnRUcmVlOjApKjYrMHhjZjApOw0KICAgICAgICAgICAgICAgIGlmKCEodG1wLmIwICYgMHg4MDAwKSkgew0KICAgICAgICAgICAgICAgICAgICAvL2ZwcmludGYoc3Rkb3V0LCAiICAweCUwM3ggKCVjKSIsIHRtcC0+YjAsKHRtcC0+YjA8MjU2ICYmIGlzcHJpbnQodG1wLT5iMCkpP3RtcC0+YjA6JxoaGicpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZighKHRtcC5iMSAmIDB4ODAwMCkpIHsNCiAgICAgICAgICAgICAgICAgICAgaWYoKHRtcC5iMCAmIDB4ODAwMCkpDQogICAgICAgICAgICAgICAgICAgICAgICBmcHJpbnRmKHN0ZG91dCwgIiAgICAgICAgICAgIik7DQogICAgICAgICAgICAgICAgICAgIGZwcmludGYoc3Rkb3V0LCAiICAweCUwM3ggKCVjKSIsIHRtcC0+YjEsKHRtcC0+YjE8MjU2ICYmIGlzcHJpbnQodG1wLT5iMSkpP3RtcC0+YjE6JxoaGicpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBmcHJpbnRmKHN0ZG91dCwgIlxuIik7DQogICAgICAgICAgICB9DQogICAgICAgIH0qLw0KICAgICAgICByZXR1cm4gMDsNCiAgICB9Ow0KICAgIA0KICAgIGZ1bmN0aW9uIERlY29kZVZhbHVlKGN1cnJlbnRUcmVlKSB7DQogICAgICAgIHZhciBsZW4sIGksDQogICAgICAgICAgICB4dHJlZXBvcz0wLA0KICAgICAgICAgICAgWCA9IGN1cnJlbnRUcmVlW3h0cmVlcG9zXSwNCiAgICAgICAgICAgIGI7DQoNCiAgICAgICAgLyogZGVjb2RlIG9uZSBzeW1ib2wgb2YgdGhlIGRhdGEgKi8NCiAgICAgICAgd2hpbGUoMSkgew0KICAgICAgICAgICAgYj1yZWFkQml0KCk7DQogICAgICAgICAgICBpZiAoZGVidWcpDQogICAgICAgICAgICAJZG9jdW1lbnQud3JpdGUoImI9IitiKTsNCiAgICAgICAgICAgIGlmKGIpIHsNCiAgICAgICAgICAgICAgICBpZighKFguYjEgJiAweDgwMDApKXsNCiAgICAgICAgICAgICAgICAJaWYgKGRlYnVnKQ0KICAgICAgICAgICAgICAgICAgICAJZG9jdW1lbnQud3JpdGUoInJldDEiKTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFguYjE7ICAgIC8qIElmIGxlYWYgbm9kZSwgcmV0dXJuIGRhdGEgKi8NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgWCA9IFguanVtcDsNCiAgICAgICAgICAgICAgICBsZW4gPSBjdXJyZW50VHJlZS5sZW5ndGg7DQogICAgICAgICAgICAgICAgZm9yIChpPTA7aTxsZW47aSsrKXsNCiAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRUcmVlW2ldPT09WCl7DQogICAgICAgICAgICAgICAgICAgICAgICB4dHJlZXBvcz1pOw0KICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgLy94dHJlZXBvcysrOw0KICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICBpZighKFguYjAgJiAweDgwMDApKXsNCiAgICAgICAgICAgICAgICAJaWYgKGRlYnVnKQ0KICAgICAgICAgICAgICAgICAgICAJZG9jdW1lbnQud3JpdGUoInJldDIiKTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFguYjA7ICAgIC8qIElmIGxlYWYgbm9kZSwgcmV0dXJuIGRhdGEgKi8NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgLy9YKys7IC8vPz8/Pz8/Pz8/Pz8/Pz8/Pz8/DQogICAgICAgICAgICAgICAgeHRyZWVwb3MrKzsNCiAgICAgICAgICAgICAgICBYID0gY3VycmVudFRyZWVbeHRyZWVwb3NdOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgICAgIGlmIChkZWJ1ZykNCiAgICAgICAgCWRvY3VtZW50LndyaXRlKCJyZXQzIik7DQogICAgICAgIHJldHVybiAtMTsNCiAgICB9Ow0KICAgIA0KICAgIGZ1bmN0aW9uIERlZmxhdGVMb29wKCkgew0KICAgIHZhciBsYXN0LCBjLCB0eXBlLCBpLCBsZW47DQoNCiAgICBkbyB7DQogICAgICAgIC8qaWYoKGxhc3QgPSByZWFkQml0KCkpKXsNCiAgICAgICAgICAgIGZwcmludGYoZXJyZnAsICJMYXN0IEJsb2NrOiAiKTsNCiAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgIGZwcmludGYoZXJyZnAsICJOb3QgTGFzdCBCbG9jazogIik7DQogICAgICAgIH0qLw0KICAgICAgICBsYXN0ID0gcmVhZEJpdCgpOw0KICAgICAgICB0eXBlID0gcmVhZEJpdHMoMik7DQogICAgICAgIHN3aXRjaCh0eXBlKSB7DQogICAgICAgICAgICBjYXNlIDA6DQogICAgICAgICAgICAJaWYgKGRlYnVnKQ0KICAgICAgICAgICAgICAgIAlhbGVydCgiU3RvcmVkXG4iKTsNCiAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgIGNhc2UgMToNCiAgICAgICAgICAgIAlpZiAoZGVidWcpDQogICAgICAgICAgICAgICAgCWFsZXJ0KCJGaXhlZCBIdWZmbWFuIGNvZGVzXG4iKTsNCiAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgIGNhc2UgMjoNCiAgICAgICAgICAgIAlpZiAoZGVidWcpDQogICAgICAgICAgICAgICAgCWFsZXJ0KCJEeW5hbWljIEh1ZmZtYW4gY29kZXNcbiIpOw0KICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgY2FzZSAzOg0KICAgICAgICAgICAgCWlmIChkZWJ1ZykNCiAgICAgICAgICAgICAgICAJYWxlcnQoIlJlc2VydmVkIGJsb2NrIHR5cGUhIVxuIik7DQogICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICBkZWZhdWx0Og0KICAgICAgICAgICAgCWlmIChkZWJ1ZykNCiAgICAgICAgICAgICAgICAJYWxlcnQoIlVuZXhwZWN0ZWQgdmFsdWUgJWQhXG4iLCB0eXBlKTsNCiAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgfQ0KDQogICAgICAgIGlmKHR5cGU9PTApIHsNCiAgICAgICAgICAgIHZhciBibG9ja0xlbiwgY1N1bTsNCg0KICAgICAgICAgICAgLy8gU3RvcmVkIA0KICAgICAgICAgICAgYnl0ZUFsaWduKCk7DQogICAgICAgICAgICBibG9ja0xlbiA9IHJlYWRCeXRlKCk7DQogICAgICAgICAgICBibG9ja0xlbiB8PSAocmVhZEJ5dGUoKTw8OCk7DQoNCiAgICAgICAgICAgIGNTdW0gPSByZWFkQnl0ZSgpOw0KICAgICAgICAgICAgY1N1bSB8PSAocmVhZEJ5dGUoKTw8OCk7DQoNCiAgICAgICAgICAgIGlmKCgoYmxvY2tMZW4gXiB+Y1N1bSkgJiAweGZmZmYpKSB7DQogICAgICAgICAgICAgICAgZG9jdW1lbnQud3JpdGUoIkJsb2NrTGVuIGNoZWNrc3VtIG1pc21hdGNoXG4iKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIHdoaWxlKGJsb2NrTGVuLS0pIHsNCiAgICAgICAgICAgICAgICBjID0gcmVhZEJ5dGUoKTsNCiAgICAgICAgICAgICAgICBhZGRCdWZmZXIoYyk7DQogICAgICAgICAgICB9DQogICAgICAgIH0gZWxzZSBpZih0eXBlPT0xKSB7DQogICAgICAgICAgICB2YXIgajsNCg0KICAgICAgICAgICAgLyogRml4ZWQgSHVmZm1hbiB0YWJsZXMgLS0gZml4ZWQgZGVjb2RlIHJvdXRpbmUgKi8NCiAgICAgICAgICAgIHdoaWxlKDEpIHsNCiAgICAgICAgICAgIC8qDQogICAgICAgICAgICAgICAgMjU2ICAgIDAwMDAwMDAgICAgICAgIDANCiAgICAgICAgICAgICAgICA6ICAgOiAgICAgOg0KICAgICAgICAgICAgICAgIDI3OSAgICAwMDEwMTExICAgICAgICAyMw0KICAgICAgICAgICAgICAgIDAgICAwMDExMDAwMCAgICA0OA0KICAgICAgICAgICAgICAgIDogICAgOiAgICAgIDoNCiAgICAgICAgICAgICAgICAxNDMgICAgMTAxMTExMTEgICAgMTkxDQogICAgICAgICAgICAgICAgMjgwIDExMDAwMDAwICAgIDE5Mg0KICAgICAgICAgICAgICAgIDogICAgOiAgICAgIDoNCiAgICAgICAgICAgICAgICAyODcgMTEwMDAxMTEgICAgMTk5DQogICAgICAgICAgICAgICAgMTQ0ICAgIDExMDAxMDAwMCAgICA0MDANCiAgICAgICAgICAgICAgICA6ICAgIDogICAgICAgOg0KICAgICAgICAgICAgICAgIDI1NSAgICAxMTExMTExMTEgICAgNTExDQogICAgDQogICAgICAgICAgICAgICAgTm90ZSB0aGUgYml0IG9yZGVyIQ0KICAgICAgICAgICAgICAgICovDQoNCiAgICAgICAgICAgIGogPSAoYml0UmV2ZXJzZVtyZWFkQml0cyg3KV0+PjEpOw0KICAgICAgICAgICAgaWYoaiA+IDIzKSB7DQogICAgICAgICAgICAgICAgaiA9IChqPDwxKSB8IHJlYWRCaXQoKTsgICAgLyogNDguLjI1NSAqLw0KDQogICAgICAgICAgICAgICAgaWYoaiA+IDE5OSkgeyAgICAvKiAyMDAuLjI1NSAqLw0KICAgICAgICAgICAgICAgICAgICBqIC09IDEyODsgICAgLyogIDcyLi4xMjcgKi8NCiAgICAgICAgICAgICAgICAgICAgaiA9IChqPDwxKSB8IHJlYWRCaXQoKTsgICAgICAgIC8qIDE0NC4uMjU1IDw8ICovDQogICAgICAgICAgICAgICAgfSBlbHNlIHsgICAgICAgIC8qICA0OC4uMTk5ICovDQogICAgICAgICAgICAgICAgICAgIGogLT0gNDg7ICAgIC8qICAgMC4uMTUxICovDQogICAgICAgICAgICAgICAgICAgIGlmKGogPiAxNDMpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGogPSBqKzEzNjsgICAgLyogMjgwLi4yODcgPDwgKi8NCiAgICAgICAgICAgICAgICAgICAgICAgIC8qICAgMC4uMTQzIDw8ICovDQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICB9IGVsc2UgeyAgICAvKiAgIDAuLjIzICovDQogICAgICAgICAgICAgICAgaiArPSAyNTY7ICAgIC8qIDI1Ni4uMjc5IDw8ICovDQogICAgICAgICAgICB9DQogICAgICAgICAgICBpZihqIDwgMjU2KSB7DQogICAgICAgICAgICAgICAgYWRkQnVmZmVyKGopOw0KICAgICAgICAgICAgICAgIC8vZG9jdW1lbnQud3JpdGUoIm91dDoiK1N0cmluZy5mcm9tQ2hhckNvZGUoaikpOw0KICAgICAgICAgICAgICAgIC8qZnByaW50ZihlcnJmcCwgIkAlZCAlMDJ4XG4iLCBTSVpFLCBqKTsqLw0KICAgICAgICAgICAgfSBlbHNlIGlmKGogPT0gMjU2KSB7DQogICAgICAgICAgICAgICAgLyogRU9GICovDQogICAgICAgICAgICAgICAgYnJlYWs7DQogICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgIHZhciBsZW4sIGRpc3Q7DQoNCiAgICAgICAgICAgICAgICBqIC09IDI1NiArIDE7ICAgIC8qIGJ5dGVzICsgRU9GICovDQogICAgICAgICAgICAgICAgbGVuID0gcmVhZEJpdHMoY3BsZXh0W2pdKSArIGNwbGVuc1tqXTsNCg0KICAgICAgICAgICAgICAgIGogPSBiaXRSZXZlcnNlW3JlYWRCaXRzKDUpXT4+MzsNCiAgICAgICAgICAgICAgICBpZihjcGRleHRbal0gPiA4KSB7DQogICAgICAgICAgICAgICAgICAgIGRpc3QgPSByZWFkQml0cyg4KTsNCiAgICAgICAgICAgICAgICAgICAgZGlzdCB8PSAocmVhZEJpdHMoY3BkZXh0W2pdLTgpPDw4KTsNCiAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICBkaXN0ID0gcmVhZEJpdHMoY3BkZXh0W2pdKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgZGlzdCArPSBjcGRpc3Rbal07DQoNCiAgICAgICAgICAgICAgICAvKmZwcmludGYoZXJyZnAsICJAJWQgKGwlMDJ4LGQlMDR4KVxuIiwgU0laRSwgbGVuLCBkaXN0KTsqLw0KICAgICAgICAgICAgICAgIGZvcihqPTA7ajxsZW47aisrKSB7DQogICAgICAgICAgICAgICAgICAgIHZhciBjID0gYnVmMzJrWyhiSWR4IC0gZGlzdCkgJiAweDdmZmZdOw0KICAgICAgICAgICAgICAgICAgICBhZGRCdWZmZXIoYyk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfSAvLyB3aGlsZQ0KICAgICAgICB9IGVsc2UgaWYodHlwZT09Mikgew0KICAgICAgICAgICAgdmFyIGosIG4sIGxpdGVyYWxDb2RlcywgZGlzdENvZGVzLCBsZW5Db2RlczsNCiAgICAgICAgICAgIHZhciBsbCA9IG5ldyBBcnJheSgyODgrMzIpOyAgICAvLyAic3RhdGljIiBqdXN0IHRvIHByZXNlcnZlIHN0YWNrDQogICAgDQogICAgICAgICAgICAvLyBEeW5hbWljIEh1ZmZtYW4gdGFibGVzIA0KICAgIA0KICAgICAgICAgICAgbGl0ZXJhbENvZGVzID0gMjU3ICsgcmVhZEJpdHMoNSk7DQogICAgICAgICAgICBkaXN0Q29kZXMgPSAxICsgcmVhZEJpdHMoNSk7DQogICAgICAgICAgICBsZW5Db2RlcyA9IDQgKyByZWFkQml0cyg0KTsNCiAgICAgICAgICAgIC8vZG9jdW1lbnQud3JpdGUoIjxicj5wYXJhbTogIitsaXRlcmFsQ29kZXMrIiAiK2Rpc3RDb2RlcysiICIrbGVuQ29kZXMrIjxicj4iKTsNCiAgICAgICAgICAgIGZvcihqPTA7IGo8MTk7IGorKykgew0KICAgICAgICAgICAgICAgIGxsW2pdID0gMDsNCiAgICAgICAgICAgIH0NCiAgICANCiAgICAgICAgICAgIC8vIEdldCB0aGUgZGVjb2RlIHRyZWUgY29kZSBsZW5ndGhzDQogICAgDQogICAgICAgICAgICAvL2RvY3VtZW50LndyaXRlKCI8YnI+Iik7DQogICAgICAgICAgICBmb3Ioaj0wOyBqPGxlbkNvZGVzOyBqKyspIHsNCiAgICAgICAgICAgICAgICBsbFtib3JkZXJbal1dID0gcmVhZEJpdHMoMyk7DQogICAgICAgICAgICAgICAgLy9kb2N1bWVudC53cml0ZShsbFtib3JkZXJbal1dKyIgIik7DQogICAgICAgICAgICB9DQogICAgICAgICAgICAvL2ZwcmludGYoZXJyZnAsICJcbiIpOw0KICAgICAgICAgICAgLy9kb2N1bWVudC53cml0ZSgnPGJyPmxsOicrbGwpOw0KICAgICAgICAgICAgbGVuID0gZGlzdGFuY2VUcmVlLmxlbmd0aDsNCiAgICAgICAgICAgIGZvciAoaT0wOyBpPGxlbjsgaSsrKQ0KICAgICAgICAgICAgICAgIGRpc3RhbmNlVHJlZVtpXT1uZXcgSHVmTm9kZSgpOw0KICAgICAgICAgICAgaWYoQ3JlYXRlVHJlZShkaXN0YW5jZVRyZWUsIDE5LCBsbCwgMCkpIHsNCiAgICAgICAgICAgICAgICBmbHVzaEJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIHJldHVybiAxOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgaWYgKGRlYnVnKXsNCiAgICAgICAgICAgIAlkb2N1bWVudC53cml0ZSgiPGJyPmRpc3RhbmNlVHJlZSIpOw0KICAgICAgICAgICAgCWZvcih2YXIgYT0wO2E8ZGlzdGFuY2VUcmVlLmxlbmd0aDthKyspew0KICAgICAgICAgICAgICAgIAlkb2N1bWVudC53cml0ZSgiPGJyPiIrZGlzdGFuY2VUcmVlW2FdLmIwKyIgIitkaXN0YW5jZVRyZWVbYV0uYjErIiAiK2Rpc3RhbmNlVHJlZVthXS5qdW1wKyIgIitkaXN0YW5jZVRyZWVbYV0uanVtcHBvcyk7DQogICAgICAgICAgICAgICAgCS8qaWYgKGRpc3RhbmNlVHJlZVthXS5qdW1wcG9zIT0tMSkNCiAgICAgICAgICAgICAgICAgICAgCWRvY3VtZW50LndyaXRlKCIgIitkaXN0YW5jZVRyZWVbYV0uanVtcC5iMCsiICIrZGlzdGFuY2VUcmVlW2FdLmp1bXAuYjEpOw0KICAgICAgICAgICAgICAgIAkqLw0KICAgICAgICAgICAgCX0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIC8vZG9jdW1lbnQud3JpdGUoJzxCUj50cmVlIGNyZWF0ZWQnKTsNCiAgICANCiAgICAgICAgICAgIC8vcmVhZCBpbiBsaXRlcmFsIGFuZCBkaXN0YW5jZSBjb2RlIGxlbmd0aHMNCiAgICAgICAgICAgIG4gPSBsaXRlcmFsQ29kZXMgKyBkaXN0Q29kZXM7DQogICAgICAgICAgICBpID0gMDsNCiAgICAgICAgICAgIHZhciB6PS0xOw0KICAgICAgICAgICAgaWYgKGRlYnVnKQ0KICAgICAgICAgICAgCWRvY3VtZW50LndyaXRlKCI8YnI+bj0iK24rIiBiaXRzOiAiK2JpdHMrIjxicj4iKTsNCiAgICAgICAgICAgIHdoaWxlKGkgPCBuKSB7DQogICAgICAgICAgICAgICAgeisrOw0KICAgICAgICAgICAgICAgIGogPSBEZWNvZGVWYWx1ZShkaXN0YW5jZVRyZWUpOw0KICAgICAgICAgICAgICAgIGlmIChkZWJ1ZykNCiAgICAgICAgICAgICAgICAJZG9jdW1lbnQud3JpdGUoIjxicj4iK3orIiBpOiIraSsiIGRlY29kZTogIitqKyIgICAgYml0cyAiK2JpdHMrIjxicj4iKTsNCiAgICAgICAgICAgICAgICBpZihqPDE2KSB7ICAgIC8vIGxlbmd0aCBvZiBjb2RlIGluIGJpdHMgKDAuLjE1KQ0KICAgICAgICAgICAgICAgICAgICAgICBsbFtpKytdID0gajsNCiAgICAgICAgICAgICAgICB9IGVsc2UgaWYoaj09MTYpIHsgICAgLy8gcmVwZWF0IGxhc3QgbGVuZ3RoIDMgdG8gNiB0aW1lcyANCiAgICAgICAgICAgICAgICAgICAgICAgdmFyIGw7DQogICAgICAgICAgICAgICAgICAgIGogPSAzICsgcmVhZEJpdHMoMik7DQogICAgICAgICAgICAgICAgICAgIGlmKGkraiA+IG4pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGZsdXNoQnVmZmVyKCk7DQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBsID0gaSA/IGxsW2ktMV0gOiAwOw0KICAgICAgICAgICAgICAgICAgICB3aGlsZShqLS0pIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGxsW2krK10gPSBsOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgaWYoaj09MTcpIHsgICAgICAgIC8vIDMgdG8gMTAgemVybyBsZW5ndGggY29kZXMNCiAgICAgICAgICAgICAgICAgICAgICAgIGogPSAzICsgcmVhZEJpdHMoMyk7DQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7ICAgICAgICAvLyBqID09IDE4OiAxMSB0byAxMzggemVybyBsZW5ndGggY29kZXMgDQogICAgICAgICAgICAgICAgICAgICAgICBqID0gMTEgKyByZWFkQml0cyg3KTsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBpZihpK2ogPiBuKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBmbHVzaEJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIDE7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgd2hpbGUoai0tKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBsbFtpKytdID0gMDsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIC8qZm9yKGo9MDsgajxsaXRlcmFsQ29kZXMrZGlzdENvZGVzOyBqKyspIHsNCiAgICAgICAgICAgICAgICAvL2ZwcmludGYoZXJyZnAsICIlZCAiLCBsbFtqXSk7DQogICAgICAgICAgICAgICAgaWYgKChqJjcpPT03KQ0KICAgICAgICAgICAgICAgICAgICBmcHJpbnRmKGVycmZwLCAiXG4iKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGZwcmludGYoZXJyZnAsICJcbiIpOyovDQogICAgICAgICAgICAvLyBDYW4gb3ZlcndyaXRlIHRyZWUgZGVjb2RlIHRyZWUgYXMgaXQgaXMgbm90IHVzZWQgYW55bW9yZQ0KICAgICAgICAgICAgbGVuID0gbGl0ZXJhbFRyZWUubGVuZ3RoOw0KICAgICAgICAgICAgZm9yIChpPTA7IGk8bGVuOyBpKyspDQogICAgICAgICAgICAgICAgbGl0ZXJhbFRyZWVbaV09bmV3IEh1Zk5vZGUoKTsNCiAgICAgICAgICAgIGlmKENyZWF0ZVRyZWUobGl0ZXJhbFRyZWUsIGxpdGVyYWxDb2RlcywgbGwsIDApKSB7DQogICAgICAgICAgICAgICAgZmx1c2hCdWZmZXIoKTsNCiAgICAgICAgICAgICAgICByZXR1cm4gMTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGxlbiA9IGxpdGVyYWxUcmVlLmxlbmd0aDsNCiAgICAgICAgICAgIGZvciAoaT0wOyBpPGxlbjsgaSsrKQ0KICAgICAgICAgICAgICAgIGRpc3RhbmNlVHJlZVtpXT1uZXcgSHVmTm9kZSgpOw0KICAgICAgICAgICAgdmFyIGxsMiA9IG5ldyBBcnJheSgpOw0KICAgICAgICAgICAgZm9yIChpPWxpdGVyYWxDb2RlczsgaSA8bGwubGVuZ3RoOyBpKyspew0KICAgICAgICAgICAgICAgIGxsMltpLWxpdGVyYWxDb2Rlc109bGxbaV07DQogICAgICAgICAgICB9ICAgIA0KICAgICAgICAgICAgaWYoQ3JlYXRlVHJlZShkaXN0YW5jZVRyZWUsIGRpc3RDb2RlcywgbGwyLCAwKSkgew0KICAgICAgICAgICAgICAgIGZsdXNoQnVmZmVyKCk7DQogICAgICAgICAgICAgICAgcmV0dXJuIDE7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBpZiAoZGVidWcpDQogICAgICAgICAgIAkJZG9jdW1lbnQud3JpdGUoIjxicj5saXRlcmFsVHJlZSIpOw0KICAgICAgICAgICAgb3V0ZXI6DQogICAgICAgICAgICB3aGlsZSgxKSB7DQogICAgICAgICAgICAgICAgaiA9IERlY29kZVZhbHVlKGxpdGVyYWxUcmVlKTsNCiAgICAgICAgICAgICAgICBpZihqID49IDI1NikgeyAgICAgICAgLy8gSW4gQzY0OiBpZiBjYXJyeSBzZXQNCiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbiwgZGlzdDsNCiAgICAgICAgICAgICAgICAgICAgaiAtPSAyNTY7DQogICAgICAgICAgICAgICAgICAgIGlmKGogPT0gMCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgLy8gRU9GDQogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICBqLS07DQogICAgICAgICAgICAgICAgICAgIGxlbiA9IHJlYWRCaXRzKGNwbGV4dFtqXSkgKyBjcGxlbnNbal07DQogICAgDQogICAgICAgICAgICAgICAgICAgIGogPSBEZWNvZGVWYWx1ZShkaXN0YW5jZVRyZWUpOw0KICAgICAgICAgICAgICAgICAgICBpZihjcGRleHRbal0gPiA4KSB7DQogICAgICAgICAgICAgICAgICAgICAgICBkaXN0ID0gcmVhZEJpdHMoOCk7DQogICAgICAgICAgICAgICAgICAgICAgICBkaXN0IHw9IChyZWFkQml0cyhjcGRleHRbal0tOCk8PDgpOw0KICAgICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgICAgICAgZGlzdCA9IHJlYWRCaXRzKGNwZGV4dFtqXSk7DQogICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgZGlzdCArPSBjcGRpc3Rbal07DQogICAgICAgICAgICAgICAgICAgIHdoaWxlKGxlbi0tKSB7DQogICAgICAgICAgICAgICAgICAgICAgICBpZihiSWR4IC0gZGlzdCA8IDApIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhayBvdXRlcjsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjID0gYnVmMzJrWyhiSWR4IC0gZGlzdCkgJiAweDdmZmZdOw0KICAgICAgICAgICAgICAgICAgICAgICAgYWRkQnVmZmVyKGMpOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAgICAgICAgICAgICAgICAgYWRkQnVmZmVyKGopOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgfQ0KICAgIH0gd2hpbGUoIWxhc3QpOw0KICAgIGZsdXNoQnVmZmVyKCk7DQoNCiAgICBieXRlQWxpZ24oKTsNCiAgICByZXR1cm4gMDsNCn07DQoNCkpYRy5VdGlsLlVuemlwLnByb3RvdHlwZS51bnppcEZpbGUgPSBmdW5jdGlvbihuYW1lKSB7DQogICAgdmFyIGk7DQoJdGhpcy51bnppcCgpOw0KCS8vYWxlcnQodW56aXBwZWRbMF1bMV0pOw0KCWZvciAoaT0wO2k8dW56aXBwZWQubGVuZ3RoO2krKyl7DQoJCWlmKHVuemlwcGVkW2ldWzFdPT1uYW1lKSB7DQoJCQlyZXR1cm4gdW56aXBwZWRbaV1bMF07DQoJCX0NCgl9DQoJDQogIH07DQoNCkpYRy5VdGlsLlVuemlwLnByb3RvdHlwZS5kZWZsYXRlID0gZnVuY3Rpb24oKSB7DQogICAgb3V0cHV0QXJyID0gW107DQogICAgdmFyIHRtcCA9IFtdOw0KICAgIG1vZGVaSVAgPSBmYWxzZT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LTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5Ky89IiwNCg0KICAgIC8vIHB1YmxpYyBtZXRob2QgZm9yIGVuY29kaW5nDQogICAgZW5jb2RlIDogZnVuY3Rpb24gKGlucHV0KSB7DQogICAgICAgIHZhciBvdXRwdXQgPSBbXSwNCiAgICAgICAgICAgIGNocjEsIGNocjIsIGNocjMsIGVuYzEsIGVuYzIsIGVuYzMsIGVuYzQsDQogICAgICAgICAgICBpID0gMDsNCg0KICAgICAgICBpbnB1dCA9IEpYRy5VdGlsLkJhc2U2NC5fdXRmOF9lbmNvZGUoaW5wdXQpOw0KDQogICAgICAgIHdoaWxlIChpIDwgaW5wdXQubGVuZ3RoKSB7DQoNCiAgICAgICAgICAgIGNocjEgPSBpbnB1dC5jaGFyQ29kZUF0KGkrKyk7DQogICAgICAgICAgICBjaHIyID0gaW5wdXQuY2hhckNvZGVBdChpKyspOw0KICAgICAgICAgICAgY2hyMyA9IGlucHV0LmNoYXJDb2RlQXQoaSsrKTsNCg0KICAgICAgICAgICAgZW5jMSA9IGNocjEgPj4gMjsNCiAgICAgICAgICAgIGVuYzIgPSAoKGNocjEgJiAzKSA8PCA0KSB8IChjaHIyID4+IDQpOw0KICAgICAgICAgICAgZW5jMyA9ICgoY2hyMiAmIDE1KSA8PCAyKSB8IChjaHIzID4+IDYpOw0KICAgICAgICAgICAgZW5jNCA9IGNocjMgJiA2MzsNCg0KICAgICAgICAgICAgaWYgKGlzTmFOKGNocjIpKSB7DQogICAgICAgICAgICAgICAgZW5jMyA9IGVuYzQgPSA2NDsNCiAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNOYU4oY2hyMykpIHsNCiAgICAgICAgICAgICAgICBlbmM0ID0gNjQ7DQogICAgICAgICAgICB9DQoNCiAgICAgICAgICAgIG91dHB1dC5wdXNoKFt0aGlzLl9rZXlTdHIuY2hhckF0KGVuYzEpLA0KICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2tleVN0ci5jaGFyQXQoZW5jMiksDQogICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fa2V5U3RyLmNoYXJBdChlbmMzKSwNCiAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9rZXlTdHIuY2hhckF0KGVuYzQpXS5qb2luKCcnKSk7DQogICAgICAgIH0NCg0KICAgICAgICByZXR1cm4gb3V0cHV0LmpvaW4oJycpOw0KICAgIH0sDQoNCiAgICAvLyBwdWJsaWMgbWV0aG9kIGZvciBkZWNvZGluZw0KICAgIGRlY29kZSA6IGZ1bmN0aW9uIChpbnB1dCwgdXRmOCkgew0KICAgICAgICB2YXIgb3V0cHV0ID0gW10sDQogICAgICAgICAgICBjaHIxLCBjaHIyLCBjaHIzLA0KICAgICAgICAgICAgZW5jMSwgZW5jMiwgZW5jMywgZW5jNCwNCiAgICAgICAgICAgIGkgPSAwOw0KDQogICAgICAgIGlucHV0ID0gaW5wdXQucmVwbGFjZSgvW15BLVphLXowLTlcK1wvXD1dL2csICIiKTsNCg0KICAgICAgICB3aGlsZSAoaSA8IGlucHV0Lmxlbmd0aCkgew0KDQogICAgICAgICAgICBlbmMxID0gdGhpcy5fa2V5U3RyLmluZGV4T2YoaW5wdXQuY2hhckF0KGkrKykpOw0KICAgICAgICAgICAgZW5jMiA9IHRoaXMuX2tleVN0ci5pbmRleE9mKGlucHV0LmNoYXJBdChpKyspKTsNCiAgICAgICAgICAgIGVuYzMgPSB0aGlzLl9rZXlTdHIuaW5kZXhPZihpbnB1dC5jaGFyQXQoaSsrKSk7DQogICAgICAgICAgICBlbmM0ID0gdGhpcy5fa2V5U3RyLmluZGV4T2YoaW5wdXQuY2hhckF0KGkrKykpOw0KDQogICAgICAgICAgICBjaHIxID0gKGVuYzEgPDwgMikgfCAoZW5jMiA+PiA0KTsNCiAgICAgICAgICAgIGNocjIgPSAoKGVuYzIgJiAxNSkgPDwgNCkgfCAoZW5jMyA+PiAyKTsNCiAgICAg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AgICB9DQogICAgICAgICAgICBlbHNlIGlmKChjID4gMTI3KSAmJiAoYyA8IDIwNDgpKSB7DQogICAgICAgICAgICAgICAgdXRmdGV4dCArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKChjID4+IDYpIHwgMTkyKTsNCiAgICAgICAgICAgICAgICB1dGZ0ZXh0ICs9IFN0cmluZy5mcm9tQ2hhckNvZGUoKGMgJiA2MykgfCAxMjgpOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgdXRmdGV4dCArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKChjID4+IDEyKSB8IDIyNCk7DQogICAgICAgICAgICAgICAgdXRmdGV4dCArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKCgoYyA+PiA2KSAmIDYzKSB8IDEyOCk7DQogICAgICAgICAgICAgICAgdXRmdGV4dCArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKChjICYgNjMpIHwgMTI4KTsNCiAgICAgICAgICAgIH0NCg0KICAgICAgICB9DQoNCiAgICAgICAgcmV0dXJuIHV0ZnRleHQ7DQogICAgfSwNCg0KICAgIC8vIHByaXZhdGUgbWV0aG9kIGZvciBVVEYtOCBkZWNvZGluZw0KICAgIF91dGY4X2RlY29kZSA6IGZ1bmN0aW9uICh1dGZ0ZXh0KSB7DQogICAgICAgIHZhciBzdHJpbmcgPSBbXSwNCiAgICAgICAgICAgIGkgPSAwLA0KICAgICAgICAgICAgYyA9IDAsIGMyID0gMCwgYzMgPSAwOw0KDQogICAgICAgIHdoaWxlICggaSA8IHV0ZnRleHQubGVuZ3RoICkgew0KICAgICAgICAgICAgYyA9IHV0ZnRleHQuY2hhckNvZGVBdChpKTsNCiAgICAgICAgICAgIGlmIChjIDwgMTI4KSB7DQogICAgICAgICAgICAgICAgc3RyaW5nLnB1c2goU3RyaW5nLmZyb21DaGFyQ29kZShjKSk7DQogICAgICAgICAgICAgICAgaSsrOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSBpZigoYyA+IDE5MSkgJiYgKGMgPCAyMjQpKSB7DQogICAgICAgICAgICAgICAgYzIgPSB1dGZ0ZXh0LmNoYXJDb2RlQXQoaSsxKTsNCiAgICAgICAgICAgICAgICBzdHJpbmcucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKCgoYyAmIDMxKSA8PCA2KSB8IChjMiAmIDYzKSkpOw0KICAgICAgICAgICAgICAgIGkgKz0gMjsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGVsc2Ugew0KICAgICAgICAgICAgICAgIGMyID0gdXRmdGV4dC5jaGFyQ29kZUF0KGkrMSk7DQogICAgICAgICAgICAgICAgYzMgPSB1dGZ0ZXh0LmNoYXJDb2RlQXQoaSsyKTsNCiAgICAgICAgICAgICAgICBzdHJpbmcucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKCgoYyAmIDE1KSA8PCAxMikgfCAoKGMyICYgNjMpIDw8IDYpIHwgKGMzICYgNjMpKSk7DQogICAgICAgICAgICAgICAgaSArPSAzOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgICAgIHJldHVybiBzdHJpbmcuam9pbignJyk7DQogICAgfSwNCiAgICANCiAgICBfZGVzdHJpcDogZnVuY3Rpb24gKHN0cmlwcGVkLCB3cmFwKXsNCiAgICAgICAgdmFyIGxpbmVzID0gW10sIGxpbmVubywgaSwNCiAgICAgICAgICAgIGRlc3RyaXBwZWQgPSBbXTsNCiAgICAgICAgDQogICAgICAgIGlmICh3cmFwPT1udWxsKSANCiAgICAgICAgICAgIHdyYXAgPSA3NjsNCiAgICAgICAgICAgIA0KICAgICAgICBzdHJpcHBlZC5yZXBsYWNlKC8gL2csICIiKTsNCiAgICAgICAgbGluZW5vID0gc3RyaXBwZWQubGVuZ3RoIC8gd3JhcDsNCiAgICAgICAgZm9yIChpID0gMDsgaSA8IGxpbmVubzsgaSsrKQ0KICAgICAgICAgICAgbGluZXNbaV09c3RyaXBwZWQuc3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xnb3JpdGhtKydcbicrDQoJICAgICAgICAgICJPbmUtb2N0ZXQgaGFzaCBhbGdvcml0aG0uICAgICAgICAgIDoiK3RoaXMuaGFzaEFsZ29yaXRobSsnXG4nKw0KCSAgICAgICAgICAiVHdvLW9jdGV0IGZpZWxkIGhvbGRpbmcgbGVmdFxuIiArDQoJICAgICAgICAgICIgMTYgYml0cyBvZiBzaWduZWQgaGFzaCB2YWx1ZS4gICAgIDoiK3RoaXMuc2lnbmVkSGFzaFZhbHVlKydcbic7DQoJCX0gZWxzZSB7DQogICAgICAgICAgdmFyIHJlc3VsdCA9ICc1LjIuIFNpZ25hdHVyZSBQYWNrZXQgKFRhZyAyKVxuJysNCiAgICAgICAgICAiUGFja2V0IExlbmd0aDogICAgICAgICAgICAgICAgICAgICA6Iit0aGlzLnBhY2tldExlbmd0aCsnXG4nKw0KICAgICAgICAgICJQYWNrZXQgdmVyc2lvbjogICAgICAgICAgICAgICAgICAgIDoiK3RoaXMudmVyc2lvbisnXG4nKw0KICAgICAgICAgICJPbmUtb2N0ZXQgc2lnbmF0dXJlIHR5cGUgICAgICAgICAgIDoiK3RoaXMuc2lnbmF0dXJlVHlwZSsnXG4nKw0KICAgICAgICAgICJPbmUtb2N0ZXQgcHVibGljLWtleSBhbGdvcml0aG0uICAgIDoiK3RoaXMucHVibGljS2V5QWxnb3JpdGhtKydcbicrDQogICAgICAgICAgIk9uZS1vY3RldCBoYXNoIGFsZ29yaXRobS4gICAgICAgICAgOiIrdGhpcy5oYXNoQWxnb3JpdGhtKydcbicrDQogICAgICAgICAgIlR3by1vY3RldCBmaWVsZCBob2xkaW5nIGxlZnRcbiIgKw0KICAgICAgICAgICIgMTYgYml0cyBvZiBzaWduZWQgaGFzaCB2YWx1ZS4gICAgIDoiK3RoaXMuc2lnbmVkSGFzaFZhbHVlKydcbicrDQogICAgICAgICAgIlNpZ25hdHVyZSBDcmVhdGlvbiBUaW1lICAgICAgICAgICAgOiIrdGhpcy5jcmVhdGlvblRpbWUrJ1xuJysNCiAgICAgICAgICAiU2lnbmF0dXJlIEV4cGlyYXRpb24gVGltZSAgICAgICAgICA6Iit0aGlzLnNpZ25hdHVyZUV4cGlyYXRpb25UaW1lKydcbicrDQogICAgICAgICAgIlNpZ25hdHVyZSBOZXZlciBFeHBpcmVzICAgICAgICAgICAgOiIrdGhpcy5zaWduYXR1cmVOZXZlckV4cGlyZXMrJ1xuJysNCiAgICAgICAgICAiRXhwb3J0YWJsZSBDZXJ0aWZpY2F0aW9uICAgICAgICAgICA6Iit0aGlzLmV4cG9ydGFibGUrJ1xuJysNCiAgICAgICAgICAiVHJ1c3QgU2lnbmF0dXJlIGxldmVsOiAgICAgICAgICAgICA6Iit0aGlzLnRydXN0TGV2ZWwrJyBhbW91bnQnK3RoaXMudHJ1c3RBbW91bnQrJ1xuJysNCiAgICAgICAgICAiUmVndWxhciBFeHByZXNzaW9uICAgICAgICAgICAgICAgICA6Iit0aGlzLnJlZ3VsYXJfZXhwcmVzc2lvbisnXG4nKw0KICAgICAgICAgICJSZXZvY2FibGUgICAgICAgICAgICAgICAgICAgICAgICAgIDoiK3RoaXMucmV2b2NhYmxlKydcbicrDQogICAgICAgICAgIktleSBFeHBpcmF0aW9uIFRpbWUgICAgICAgICAgICAgICAgOiIrdGhpcy5rZXlFeHBpcmF0aW9uVGltZSsiICIrdGhpcy5rZXlOZXZlckV4cGlyZXMrJ1xuJysNCiAgICAgICAgICAiUHJlZmVycmVkIFN5bW1ldHJpYyBBbGdvcml0aG1zICAgICA6Iit0aGlzLnByZWZlcnJlZFN5bW1ldHJpY0FsZ29yaXRobXMrJ1xuJysNCiAgICAgICAgICAiUmV2b2NhdGlvbiBLZXkiKydcbicrDQogICAgICAgICAgIiAgICggMSBvY3RldCBvZiBjbGFzcywgICAgICAgICAgICAgOiIrdGhpcy5yZXZvY2F0aW9uS2V5Q2xhc3MgKydcbicrDQogICAgICAgICAgIiAgICAgMSBvY3RldCBvZiBwdWJsaWMta2V5IElELCAgICAgOiIgK3RoaXMucmV2b2NhdGlvbktleUFsZ29yaXRobSsnXG4nKw0KICAgICAgICAgICIgICAgMjAgb2N0ZXRzIG9mIGZpbmdlcnByaW50KSAgICAgIDoiK3RoaXMucmV2b2NhdGlvbktleUZpbmdlcnByaW50KydcbicrDQogICAgICAgICAgIklzc3VlciAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiIrdXRpbC5oZXhzdHJkdW1wKHRoaXMuaXNzdWVyS2V5SWQpKydcbicrDQogICAgICAgICAgIlByZWZlcnJlZCBIYXNoIEFsZ29yaXRobXMgICAgICAgICAgOiIrdGhpcy5wcmVmZXJyZWRIYXNoQWxnb3JpdGhtcysnXG4nKw0KICAgICAgICAgICJQcmVmZXJyZWQgQ29tcHJlc3Npb24gQWxnLiAgICAgICAgIDoiK3RoaXMucHJlZmVycmVkQ29tcHJlc3Npb25BbGdvcml0aG1zKydcbicrDQogICAgICAgICAgIktleSBTZXJ2ZXIgUHJlZmVyZW5jZXMgICAgICAgICAgICAgOiIrdGhpcy5rZXlTZXJ2ZXJQcmVmZXJlbmNlcysnXG4nKw0KICAgICAgICAgICJQcmVmZXJyZWQgS2V5IFNlcnZlciAgICAgICAgICAgICAgIDoiK3RoaXMucHJlZmVycmVkS2V5U2VydmVyKydcbicrDQogICAgICAgICAgIlByaW1hcnkgVXNlciBJRCAgICAgICAgICAgICAgICAgICAgOiIrdGhpcy5pc1ByaW1hcnlVc2VySUQrJ1xuJysNCiAgICAgICAgICAiUG9saWN5IFVSSSAgICAgICAgICAgICAgICAgICAgICAgICA6Iit0aGlzLnBvbGljeVVSSSsnXG4nKw0KICAgICAgICAgICJLZXkgRmxhZ3MgICAgICAgICAgICAgICAgICAgICAgICAgIDoiK3RoaXMua2V5RmxhZ3MrJ1xuJysNCiAgICAgICAgICAiU2lnbmVyJ3MgVXNlciBJRCAgICAgICAgICAgICAgICAgICA6Iit0aGlzLnNpZ25lcnNVc2VySWQrJ1xuJysNCiAgICAgICAgICAiTm90YXRpb24gICAg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2xhc3M9ImJ1dHRvbl9ibHVlIGltX3NlbmRfY29udCBmbF9sIj48YnV0dG9uIGlkPSJwZ3Bfb24iIG9uY2xpY2s9InZQR1AudHVybk9uKCcrY3VyLnBlZXIrJykiPkVuYWJsZSBQR1A8L2J1dHRvbj48L2Rpdj4nKTsNCgl9DQp9DQoNCnZQR1Auc2hvd1NldHRpbmdzID0gZnVuY3Rpb24oKSB7DQoJaWYodHlwZW9mIHZQR1Auc2V0dGluZ3MgPT0gInVuZGVmaW5lZCIgfHwgdlBHUC5zZXR0aW5ncyA9PSBudWxsKSB2UEdQLnNldHRpbmdzID0gIG5ldyBPYmplY3QoKTsNCglpZih2UEdQLnNldHRpbmdzLnNldHVwRG9uZSkgc2hvd0RvbmVCb3goJ1lvdSBoYWQgYWxyZWFkeSBjb21wbGV0ZWQgdGhlIHNldHVwIHdpemFyZC4nKTsNCgllbHNlIHsNCgkJdlBHUC5zYXZlU2V0dGluZygnZmlyc3RSdW4nLCBmYWxzZSk7DQoJCXZQR1AuZW5naW5lQXJyaXZhbCgpOw0KCQl9DQp9DQoNCnZQR1AucmVnaXN0ZXIoKTsNCg0K";
addJS_Node(null,uri,null,null);
console.log("GGL Team. El. Psy. Congroo.")

could you update it, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment