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ic3VjY2VzcyIpIHsKICAgICAgICAgIGVycm9yX2NvdW50KysKICAgICAgICAgIDtjb25zb2xlLmxvZygiZXJyb3IgcnVubmluZyBvcmFjbGUgY3N2IikKICAgICAgICAgIDtjb25zb2xlLmVycm9yKGpzb25fcmVzcG9uc2UpCiAgICAgICAgICBmYWlsX21lc3NhZ2UocCwiRXJyb3IuIikKICAgICAgICAgIHAgPSBhZGRfbWVzc2FnZShkYXRhPy5tZXNzYWdlICsgIlxuKioqIFNjcmlwdCBoYWx0ZWQuICoqKiIsICJyZWQiKQogICAgICAgICAgcC5zdHlsZS5wYWRkaW5nQm90dG9tID0gIjFyZW0iCiAgICAgICAgICBlcnJvcnMrKwogICAgICAgICAgcmV0dXJuICJlcnJvciIKICAgICAgICB9CiAgICAKICAKICAgICAgfWVsc2V7CiAgICAgICAgY29uc3QganNvbiA9IGF3YWl0IHJ1bl9vcmFjbGVfc2NyaXB0KHsgCiAgICAgICAgICBzcWw6IG9yYWNsZV9zY3JpcHQsIAogICAgICAgICAgdXNlcm5hbWU6IHVzZXJuYW1lLCAKICAgICAgICAgIHBhc3N3b3JkOiBwYXNzd29yZCwgCiAgICAgICAgICB1cmw6b3JhY2xlX3VybC5zcGxpdCgiL29yZHMvIilbMF0gKyAiL29yZHMvIiArIHVzZXJuYW1lLnRvTG93ZXJDYXNlKCkgKyAiL18vc3FsIgogICAgICAgIH0pCiAgICAgICAgZm9yIChjb25zdCBzdG10IG9mIGpzb24uaXRlbXMpIHsKICAgICAgICAgIGlmIChzdG10LmVycm9yQ29kZSkgewogICAgICAgICAgICBlcnJvcl9jb3VudCsrCiAgICAgICAgICAgIGNvbnNvbGUuZXJyb3Ioc3RtdCkKICAgICAgICAgICAgZmFpbF9tZXNzYWdlKHAsIkVycm9yLiIpCiAgICAgICAgICAgIHAgPSBhZGRfbWVzc2FnZShkYXRhPy5tZXNzYWdlICsgIlxuKioqIFNjcmlwdCBoYWx0ZWQuICoqKiIsICJyZWQiKQogICAgICAgICAgICB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zcz0ncGxhbic+JHtwYXJhbXMucGxhbi50YWJsZXN9PC9zcGFuPmApCiAgICAgICAgICB9CiAgICAgICAgICBpZihwYXJhbXMucGxhbi5yb3dzKXsKICAgICAgICAgICAgcm93X29wdGlvbnMucHVzaChgPGJyPjxzcGFuIGNsYXNzPSdwbGFuJz4ke3BhcmFtcy5wbGFuLnJvd3N9PC9zcGFuPmApCiAgICAgICAgICB9CiAgICAgICAgICBpZihwYXJhbXMucGxhbi5vcmRlcil7CiAgICAgICAgICAgIG9yZGVyX29wdGlvbnMucHVzaChgPGJyPjxzcGFuIGNsYXNzPSdwbGFuJz4ke3BhcmFtcy5wbGFuLm9yZGVyfTwvc3Bhbj5gKQogICAgICAgICAgfQogICAgICAgIH0KICAKICAgICAgICBwbGFuX2xpc3QucHVzaChgPG9sPjxsaT5XaGljaCBjb2x1bW5zIHNob3VsZCBiZSBzaG93bj8mbmJzcDske2NvbHVtbl9vcHRpb25zLmpvaW4oIiIpfTwvbGk+YCkKICAgICAgICBwbGFuX2xpc3QucHVzaChgPGxpPldoYXQgdGFibGVzIGhvbGQgdGhlIGRhdGE/Jm5ic3A7JHt0YWJsZV9vcHRpb25zLmpvaW4oIiIpfTwvbGk+YCkKICAgICAgICBwbGFuX2xpc3QucHVzaChgPGxpPldoaWNoIHJvd3Mgc2hvdWxkIGJlIGluY2x1ZGVkPyZuYnNwOyR7cm93X29wdGlvbnMuam9pbigiIil9PC9saT5gKQogICAgICAgIHBsYW5fbGlzdC5wdXNoKGA8bGk+V2hhdCBvcmRlciBzaG91bGQgcm93cyBiZSBpbj8mbmJzcDske29yZGVyX29wdGlvbnMuam9pbigiIil9PC9saT48L29sPmApCiAgICAKICAgICAgICBjb25zdCBwbGFuX3RleHQgPSBbXQogICAgCiAgICAgICAgcGxhbl90ZXh0LnB1c2goYDxkaXYgY2xhc3M9InNpZGViYXIgd2lkZSI+YCkKICAgICAgICBwbGFuX3RleHQucHVzaChgPGRpdiBjbGFzcz0ic2lkZWJhciB0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ICAgc2hvdzogdHJ1ZQogICAgICB9KQogIAogICAgfQogIAogIAogIH0KICAKICAKICBhc3luYyBmdW5jdGlvbiBnZXRfZWRpdG9yKGJ1dHRvbl9wcmVzc2VkKSB7CiAgICAvLyBsb2FkcyBhbiBlZGl0b3IgZnJvbSBhIHVybAogICAgICBjb25zdCB1cmwgPSBhd2FpdCB1aV9pbnB1dF9ib3goCiAgICAgICAgICAiRW50ZXIgdGhlIFVSTCBvZiB0aGUgcXVlcnkgc2V0IHlvdSB3YW50IHRvIGxvYWQuIiwKICAgICAgICAgICJMb2FkIFF1ZXJ5IFNldCIsCiAgICAgICAgICAiIiwKICAgICAgICAgICJodHRwczovLy4uLiIsCiAgICAgICAgICBbIk9LIl0gICAgICAgCiAgICAgICkKICAgICAgaWYodXJsICYmIHVybC5sZW5ndGg+OCl7CiAgICAgICAgdHJ5ewogICAgICAgIHJlc3BvbnNlID0gYXdhaXQgZmV0Y2godXJsKQogICAgICAgIEJvb2tTdG9yYWdlLnF1ZXJ5RWRpdG9yKGF3YWl0IHJlc3BvbnNlLmpzb24oKSkKICAgICAgICB3aW5kb3cubG9jYXRpb24ucmVsb2FkKCkKICAgICAgICB9Y2F0Y2goZSl7CiAgICAgICAgICA7bG9nKCJyZXNwb25zZSIpCiAgICAgICAgICBtZXNzYWdlKHsKICAgICAgICAgICAgbWVzc2FnZTogIlVuYWJsZSB0byBpbXBvcnQgdGhlIGZpbGUuICBJdCBkb2VzIG5vdCBhcHBlYXIgdG8gYmUgaW4gdGhlIGNvcnJlY3QgZm9ybWF0LiIsCiAgICAgICAgICAgIHRpdGxlOiAiQmFkIEZpbGUgRm9ybWF0IiwKICAgICAgICAgICAgc2Vjb25kczogOCwKICAgICAgICAgICAga2luZDoiZXJyb3IiLAogICAgICAgICAgICBzaG93OiB0cnVlCiAgICAgICAgICB9KQogICAgICAgIH0KICAgICAgfQogIH0KICAKICAKICBhc3luYyBmdW5jdGlvbiBsb2FkX3R1dG9yaWFsKHNlbGVjdF9vYmopIHsKICAgIGlmKHNlbGVjdF9vYmoudmFsdWU8MCl7CiAgICAvLyBsb2FkcyBhbiBlZGl0b3IgZnJvbSBhIHVybAogICAgICBjb25zdCB1cmwgPSBhd2FpdCB1aV9pbnB1dF9ib3goCiAgICAgICAgICAnRW50ZXIgdGhlIFVSTCBvZiB0aGUgdHV0b3JpYWwgb3IgdGhlIHR1dG9yaWFsIHNldCB5b3Ugd2FudCB0byBsb2FkIG9yIDxzcGFuIG9uY2xpY2s9InRhZyhgaW5wdXQtYm94LWlucHV0YCkudmFsdWU9YHR1dG9yaWFsc2AiIGNsYXNzPSJzcGFuLWxpbmsiPiBnZXQgdGhlIGNvZGUgZm9yIHRoZSBkZWZhdWx0IHR1dG9yaWFscy48L3NwYW4+JywKICAgICAgICAgICJMb2FkIFR1dG9yaWFscyIsCiAgICAgICAgICAiIiwKICAgICAgICAgICJodHRwczovLy4uLiIsCiAgICAgICAgICBbIk9LIl0gICAgICAgCiAgICAgICkKICAKICAgICAgaWYodXJsICYmIHVybC5sZW5ndGg+NSl7CiAgICAgICAgdHJ5ewogICAgICAgICAgbGV0IHR1dG9yaWFsc19kYXRhCiAgICAgICAgICAKICAgICAgICAgIGlmKHVybC50b0xvd2VyQ2FzZSgpLnN0YXJ0c1dpdGgoImh0dHAiKSl7CiAgICAgICAgICAgIGxldCByZXNwb25zZSA9IGF3YWl0IGZldGNoKHVybCkKICAgICAgICAgICAgdHV0b3JpYWxzX2RhdGEgPSBhd2FpdCByZXNwb25zZS5qc29uKCkKICAgICAgICAgIH1lbHNlewogICAgICAgICAgICB0dXRvcmlhbHNfZGF0YSA9IGF3YWl0IGdldF9wb3N0X2pzb24oZ2V0X3VybCh1cmwpKQogICAgICAgICAgfQogIAogICAgICAgICAgbG9nKCJ0dXRvcmlhbHNfZGF0YSIsdHV0b3JpYWxzX2RhdGEpCiAgICAgICAgICAvL2RlYnVnZ2VyCiAgICAgICAgICAvLyBjaGVja2luZyBmb3IgZm9ybWF0IG9mIHR1dG9yaWFsIHNldCAgICAgIAogICAgICAgICAgbG9nKCJ0dXRvcmlhbHNfZGF0YS50dXRvcmlhbHMiLHR1dG9yaWFsc19kYXRhLnR1dG9yaWFscykKICAgICAgICAgIGxvZygidHV0b3JpYWxzX2RhdGEuY3VycmVudFR1dG9yaWFsIix0dXRvcmlhbHNfZGF0YS5jdXJyZW50VHV0b3JpYWwpCiAgICAgICAgICBpZih0dXRvcmlhbHNfZGF0YS50dXRvcmlhbHMhPT11bmRlZmluZWQgJiYgdHV0b3JpYWxzX2RhdGEuY3VycmVudFR1dG9yaWFsIT09dW5kZWZpbmVkKXsKICAgICAgICAgIAogICAgICAgICAgICAvLyBsb29rcyBsaWtlIGEgdHV0b3JpYWwgc2V0CiAgICAgICAgICB9ZWxzZSBpZih0dXRvcmlhbHNfZGF0YS50aXRsZSE9PXVuZGVmaW5lZCAmJiB0dXRvcmlhbHNfZGF0YS50ZXh0IT09dW5kZWZpbmVkICYmIHR1dG9yaWFsc19kYXRhLnBhZ2VzIT09dW5kZWZpbmVkKXsKICAgICAgICAgICAgLy8gbG9va3MgbGlrZSBhIGRpbmdsZSB0dXRvcmlhbCwgdXNlIGl0IHRvIGJ1aWxkIGEgc2V0CiAgICAgICAgICAKICAgICAgICAgICAgdHV0b3JpYWxzX2RhdGE9ewogICAgICAgICAgICAgICJjdXJyZW50VHV0b3JpYWwiOjAsICAKICAgICAgICAgICAgICAgICJ0dXRvcmlhbHMiOlsKICAgICAgICAgICAgICAgIHsgInRpdGxlIjp0dXRvcmlhbHNfZGF0YS50aXRsZSwKICAgICAgICAgICAgICAgICAgInRleHQiOnR1dG9yaWFsc19kYXRhLnRleHQsCiAgICAgICAgICAgICAgICAgICJ1cmwiOnVybAogICAgICAgICAgICB9XX0KICAgICAgICAgIH1lbHNlewogICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0ZpbGUgZm9ybWF0IG5vdCByZWNvZ25pemVkLicpOwogICAgICAgICAgfQogIAogIAogICAgICAgICA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jZSgiWiIsICIiKTsKICAgICAgICAgICAgICAgIGJyZWFrCiAgICAgICAgICAgICAgY2FzZSAiTlVNQkVSIjoKICAgICAgICAgICAgICAgIGlmIChjb2wuc2NhbGUgPiAwKSB7CiAgICAgICAgICAgICAgICAgIHZhbCA9IHJvd1tjb2wuanNvbkNvbHVtbk5hbWVdLnRvRml4ZWQoY29sLnNjYWxlKQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY3NzX2NsYXNzID0gJyBjbGFzcz0ibnVtZXJpYyInCiAgICAgICAgICAgICAgICBicmVhawogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdHIucHVzaChgPHRkJHtjc3NfY2xhc3N9PiR7dmFsfTwvdGQ+YCkKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRyLnB1c2goYDx0ZCBjbGFzcz0ibnVsbCI+PC90ZD5gKQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0ci5wdXNoKGA8L3RyPmApCiAgICAgICAgdGFibGUucHVzaCh0ci5qb2luKGBgKSkKICAgICAgfQogICAgICAvL2xvZygiZGF0YSB0YWJsZSBuYW1lIixjb250cm9scy5lZGl0LmRhdGFzZXQudGFibGVuYW1lKQogICAgICB0YWJsZS5wdXNoKGA8L3RyPjwvdGJvZHk+PC90YWJsZT48ZGl2IGNsYXNzPSJ0b29sLWZvb3RlciI+PHNwYW4gdGl0bGU9IkV4cGFuZCIgb25jbGljaz0iZXhwYW5kX3Jlc3VsdCh0aGlzKSIgY2xhc3M9Im1hdGVyaWFsLXN5bWJvbHMtb3V0bGluZWQgYnV0dG9uIj5leHBhbmQ8L3NwYW4+PHNwYW4gdGl0bGU9IkRvd25sb2FkIENTViIgb25jbGljaz0idGFibGVUb0NTVih0aGlzKSIgY2xhc3M9Im1hdGVyaWFsLXN5bWJvbHMtb3V0bGluZWQgYnV0dG9uIj5kb3dubG9hZDwvc3Bhbj48L2Rpdj5gKQogICA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AogICAgICAgIC8vIHNob3cgdGhhdCB3ZSBhcmUgY3VycmVudGx5IHJ1bm5pbmcgYSBxdWVyeQogICAgICAgIGNvbnRyb2xzLmJ1dHRvbi5pbm5lckhUTUwgPSBgaG91cmdsYXNzX2VtcHR5YAogICAgICAgIGNvbnRyb2xzLmJ1dHRvbi5jbGFzc0xpc3QuYWRkKGBibGlua2ApCiAgICAgICAgY29udHJvbHMucXVlcnlfcmVzdWx0LmlubmVySFRNTCA9ICIiCiAgCiAgCiAgICAgICAgZm9yIChjb25zdCB0b29sIG9mIE9iamVjdC52YWx1ZXMoY29udHJvbHMudG9vbHMpKSB7CiAgICAgICAgICB0b29sLnN0eWxlLmRpc3BsYXkgPSAibm9uZSIKICAgICAgICB9CiAgCiAgICAgICAgcGFyYW1zID0gewogICAgICAgICAgZW5naW5lOiBnZXRfYm9va19kYl90eXBlKCksCiAgICAgICAgICBxdWVyeTogY29udHJvbHMuZWRpdC52YWx1ZSwKICAgICAgICAgIGNvbm5lY3Rpb246IGNvbnRyb2xzLmVkaXQuZGF0YXNldC5jb25uZWN0aW9uLAogICAgICAgICAgc2NoZW1hOiBjb250cm9scy5lZGl0LmRhdGFzZXQuc2NoZW1hLAogICAgICAgICAgb3duZXI6IGNvbnRyb2xzLmVkaXQuZGF0YXNldC5vd25lciwKICAgICAgICAgIHRhYmxlbmFtZTogY29udHJvbHMuZWRpdC5kYXRhc2V0LnRhYmxlbmFtZSwKICAgICAgICAgIHRpbWVzdGFtcDogZWxlbWVudC5pZAogICAgICAgIH0KICAKICAKICAgICAgICAvLyBvdmVycmlkZXMgaWYgd29ya2luZyBmcm9tIHF1ZXJ5IGVkaXRvcgogICAgICAgIGlmKGNvbnRyb2xzLnNldHRpbmdzKXsKICAgICAgICAgIC8vbG9nKCJjb250cm9scyIsIGNvbnRyb2xzKQogICAgICAgICAgcGFyYW1zLmVuZ2luZT1jb250cm9scy5zZXR0aW5ncy5xdWVyeVNlbGVjdG9yKCJzZWxlY3RbbmFtZT0nZW5naW5lJ10iKS52YWx1ZQogICAgICAgIH0KICAgICAgICAgIAogIAogIAogIAogICAgICAgIC8vIH0KICAKICAgICAgICAvL2xvZygicXVlcnkgZXhlY3V0aW9uIHBhcmFtcyIsIHBhcmFtcykKICAKICAgICAgICAvL2xvZyBxdWVyeSBpZiBjb25maWd1cmVkCiAgICAgICAgaWYgKGdldF9mcm9tX2Jvb2tfc3RvcmFnZSgic3VibWlzc2lvbkluZm8iKSkgewogICAgICAgICAgLy9idWlsZCB0aGUgb2JlamN0IHRvIHN1Ym1pdAogICAgICAgICAgbGV0IHNvdXJjZT1wYXJhbXMuZmlsZW5hbWUgfHwgd2luZG93LmxvY2F0aW9uLmhyZWYKICAgICAgICAgIGlmKHNvdXJjZT09PSd1bmRlZmluZWQnKXtzb3VyY2UgPSB3aW5kb3cubG9jYXRpb24uaHJlZn0KICAgICAgICAgIHBheWxvYWQgPSB7CiAgICAgICAgICAgIHN1Ym1pc3Npb25UeXBlOiAibG9nUXVlcnkiLAogICAgICAgICAgICBzdHVkZW50SWQ6IGdldF9mcm9tX2Jvb2tfc3RvcmFnZSgic3VibWlzc2lvbkluZm8iKS5pZCwKICAgICAgICAgICAgZmlyc3ROYW1lOiBnZXRfZnJvbV9ib29rX3N0b3JhZ2UoInN1Ym1pc3Npb25JbmZvIikuZm4sCiAgICAgICAgICAgIGxhc3ROYW1lOiBnZXRfZnJvbV9ib29rX3N0b3JhZ2UoInN1Ym1pc3Npb25JbmZvIikubG4sCiAgICAgICAgICAgIGVtYWlsOiAibm8gZW1haWwiLAogICAgICAgICAgICBwYWdlOiB3aW5kb3cubG9jYXRpb24uaHJlZiwKICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsCiAgICAgICAgICAgIHF1ZXJ5OiBwYXJhbXMucXVlcnkKICAgICAgICAgIH0KICAKICAKICAKICAgICAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgc3VibWl0X2JhY2tlbmRfcGFja2FnZShwYXlsb2FkLCBmYWxzZSkKICAKICAKICAgICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXMgPT09ICJmYWlsdXJlIikgewogICAgICAgICAgICBtZXNzYWdlKHsKICAgICAgICAgICAgICBtZXNzYWdlOiByZXNwb25zZS5tZXNzYWdlLAogICAgICAgICAgICAgIHRpdGxlOiAiTG9nIEVycm9yIiwKICAgICAgICAgICAgICBraW5kOiAiZXJyb3IiLAogICAgICAgICAgICAgIHNlY29uZHM6IDgsCiAgICAgICAgICAgIH0pCiAgICAgICAgICAgIHJldHVybgogICAgICAgICAgfQogIAogICAgICAgIH0KICAKICAKICAgICAgfSBlbHNlIHsKICAgICAgICB0aHJvdyAnY2Fubm90IHJ1biBxdWVyeSB3aXRob3V0IGFuIEhUTUwgRWxlbWVudCBvciBvdmVycmlkZSBwYXJhbXMnCiAgICAgIH0KICAKICAgICAgbGV0IHJlc3BvbnNlCiAgCiAgICAgIC8vbG9nKCItLS0+IHBhcmFtcy5lbmdpbmUiLCBwYXJhbXMsIGNvbnRyb2xzKQogICAgICBzd2l0Y2ggKHBhcmFtcy5lbmdpbmUpIHsKICAgICAgICBjYXNlICJvcmFjbGUiOiAvLz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAgICAgICAgIGlmKEJvb2tTdG9yYWdlLmxvZ2luVHlwZSgpIT09InBhaWQiICYmIEJvb2tTdG9yYWdlLmxvZ2luVHlwZSgpIT09ImdhcyIpewogICAgICAgICAgICAvL1RyeWluZyB0byBleGVjdXRlIGFuIG9yYWNsZSBxdWVyeSB3aXRoIG5vIGJhY2tlbmQsIHByb2JhYmx5IGZyb20gcXVlcnkgZWRpdG9yCiAgICAgICAgICAgIAogICAgICAgICAgICBtZXNzYWdlKHsKICAgICAgICAgICAgICBtZXNzYWdlOiAiVG8gZXhlY3V0ZSBhIHF1ZXJ5IHVzaW5nIE9yYWNsZSwgeW91ciBhdXRoZW50aWNhdGlvbiBtZXRob2Qgb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zaW5nIiwKICAgICAgICAgICAgICBraW5kOiAiZXJyb3IiLAogICAgICAgICAgICAgIHNlY29uZHM6IDgsCiAgICAgICAgICAgIHNob3c6IHRydWUKICAgICAgICAgICAgfSkKICAKICAgICAgICAgICAgdGhyb3cgZQogICAgICAgICAgfQogICAgICAgICAgcmVzcG9uc2UgPSBhd2FpdCBydW5fZGJfcXVlcnkocGFyYW1zKQogIAogIAogIAogICAgICAgICAgYnJlYWsKICAgICAgICBjYXNlICJzcWxpdGUiOiAvLz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAgICAgICBpZihjb250cm9scy5zZXR0aW5ncyl7CiAgICAgICAgICAvLyBydW5uaW5nIGZyb20gZWRpdG9yCiAgICAgICAgICBwYXJhbXMuc2NoZW1hPWNvbnRyb2xzLnNldHRpbmdzLnF1ZXJ5U2VsZWN0b3IoImlucHV0W25hbWU9J2RhdGFiYXNlTmFtZSddIikudmFsdWUKICAgICAgICB9ICAKICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgcnVuX2RiX3F1ZXJ5KHBhcmFtcykKICAKICAKICAgICAgICAgIGJyZWFrCiAgICAgICAgZGVmYXVsdDogLy9Cb29rID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KICAgICAgICAgIC8vbG9nKCItLS0+IGV4ZWN1dGluZyBib29rIHF1ZXJ5IikKICAgICAgICAgIC8vIGJvb2sgIAogICAgICAgICAgcmVzcG9uc2UgPSBhd2FpdCBKU09OLnBhcnNlKGF3YWl0IGdldF9wb3N0X2NvbnRlbnQoZ2V0X3VybChjb250cm9scy5lZGl0LmRhdGFzZXQudGFibGVuYW1lLCAiLWRhdGEiKSkpCiAgCiAgCiAgICAgIH0gLy89PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT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25zdCBpbWFnZSA9IGVsZW0uZ2V0RWxlbWVudHNCeVRhZ05hbWUoImltZyIpWzBdCiAgICAgIGxldCByZWN0ID0gZ2V0Q29vcmRzKGltYWdlKQogICAgICAvLyAvL2xvZygicmVjdCIsIHJlY3QpCiAgICAKICAgICAgY29uc3QgZG9jX2NlbnRlciA9IGRvY3VtZW50LmJvZHkuY2xpZW50V2lkdGgvMgogIAogICAgICBsZXQgbGVmdAogICAgICBsZXQgbGVmdDIKICAgICAgbGV0IHRvcAogICAgICBsZXQgY2xhc3NuYW1lPSJyaWdodCIKICAgICAgIAogICAgICBpZihhcmVhLmRhdGFzZXQua2luZD09PSJ0YWJsZSIpewogICAgICAgIGxlZnQgPSByZWN0LmxlZnQgKyBwYXJzZUludChjb29yZHNbMl0pCiAgICAgICAgbGVmdDIgPSByZWN0LmxlZnQgKyBwYXJzZUludChjb29yZHNbMF0pCiAgICAgICAgdG9wID0gcmVjdC50b3ArcGFyc2VJbnQoY29vcmRzWzFdKS01IAogICAgICAgIGlmKE1hdGguYWJzKGRvY19jZW50ZXItbGVmdCkgPiBNYXRoLmFicyhkb2NfY2VudGVyLWxlZnQyKSl7CiAgICAgICAgICAgLy8gcGxhY2UgY2FsbG91dCB0byByaWdodAogICAgICAgICAgIGxlZnQ9bGVmdDIgLSAyMTYKICAgICAgICAgICBjbGFzc25hbWU9ImxlZnQiCiAgICAgICAgfWVsc2V7CiAgICAgICAgICAvLyBwbGFjZSBjYWxsb3V0IHRvIGxlZnQKICAgICAgICAgIGxlZnQ9bGVmdCttYXJnaW4KICAgICAgICB9ICAKICAgICAgfWVsc2V7CiAgICAgICAgLy9yZWxhdGlvbnNoaXAKICAgICAgICAvL2xvZygiZXZlbnQucGFnZVgiLGV2ZW50LnBhZ2VYKQogICAgICAgIC8vbGVmdD1yZWN0LmxlZnQrZXZlbnQub2Zmc2V0WCArMAogICAgICAgIGxlZnQ9ZXZlbnQucGFnZVgrMjUKICAgICAgICB0b3A9TWF0aC5yb3VuZ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IGZyYWdtZW50LnNwbGl0KCIuIilbMF0sIGZyYWdtZW50LnNwbGl0KCIuIilbMV0pCiAgICAgIGlmIChtc2cpIHsKICAgICAgICBtZXNzYWdlKHsKICAgICAgICAgIG1lc3NhZ2U6IG1zZywKICAgICAgICAgIHRpdGxlOiAiUHJvYmxlbSBCdWlsZGluZyBTUUwiLAogICAgICAgICAgc2Vjb25kczogNCwKICAgICAgICAgIGtpbmQ6ICJlcnJvciIsCiAgICAgICAgICBzaG93OiB0cnVlCiAgICAgICAgfSkKICAgICAgcmV0dXJuCiAgICAgIH0KICAKICAgIH0gZWxzZSB7CiAgICAgIC8vIGF0b20gaXMgYSBsaW5rCiAgICAgIC8vIGZpbmQgdGhlIHRhbGJlcyBpbiB0aGUgbGluawogICAgICBsZXQgdGVtcCA9IGZyYWdtZW50LnJlcGxhY2UoIiBKT0lOICIsICIgIikuc3BsaXQoIiAiKQogICAgICBsZXQgbWF0Y2hfY291bnQgPSAwCiAgICAgIGxldCB0YWJsZV90b19hZGQKICAgICAgY29uc3QgdGFibGUxID0gdGVtcFswXQogICAgICBjb25zdCB0YWJsZTIgPSB0ZW1wWzFdCiAgCiAgICAgIGlmIChESUFHUkFNU1tpZF0ucXVlcnkudGFibGVzLmxlbmd0aCA9PT0gMCkgewogICAgICAgIC8vIHF1ZXJ5IGlzIGVtcHR5LCBjb25maWd1cmUgZnJvbSBzY3JhdGNoCiAgICAgICAgbXNnID0gYWRkX2ZpZWxkKGlkLCB0YWJsZTEsICIqIikKICAgICAgICBpZiAobXNnKSB7CiAgICAgICAgICBtZXNzYWdlKHsKICAgICAgICAgICAgbWVzc2FnZTogbXNnLAogICAgICAgICAgICB0aXRsZTogIlByb2JsZW0gQnVpbGRpbmcgU1FMIiwKICAgICAgICAgICAgc2Vjb25kczogNCwKICAgICAgICAgICAga2luZDogImVycm9yIiwKICAgICAgICAgICAgc2hvdzogdHJ1ZQogICAgICAgICAgfSkKICAgICAgICAgIHJldHVybgogICAgICAgIH0KICAgICAgICAvLyBub3cgZ2V0IHJlYWR5IHRvIGFkZCB0aGUgam9pbiBjbGF1c2UKICAgICAgICBsZXQgZnJhZyA9IGZyYWdtZW50LnNwbGl0KCIgT04gIilbMV0KICAgICAgICAvL2xvZygiZnJhZyIsZnJhZykKICAgICAgICAvLyBwdXNoIHRoZSByZXN0IGludG8gdGhlIG5leHQgZW50cnkKICAgICAgICBESUFHUkFNU1tpZF0ucXVlcnkuZnJvbS5wdXNoKCIgIEpPSU4gICIgKyB0YWJsZTIgKyAiXG4gICAgT04gICIgKyBmcmFnKQogICAgICAgIERJQUdSQU1TW2lkXS5xdWVyeS50YWJsZXMucHVzaCh0YWJsZTIpCiAgCiAgICAgIH0gZWxzZSB7CiAgICAgICAgLy90aGVyZSBpcyBhbHJlYWR5IGEgdGFibGUgaW4gdGhlIHF1ZXJ5LiAgbmVlZCB0byBjaGVjayB0byBzZWUgaWYgYXRvbSBqb2luIG1ha2VzIHNlbnNlCiAgICAgICAgZm9yIChjb25zdCB0bmFtZSBvZiBESUFHUkFNU1tpZF0ucXVlcnkudGFibGVzKSB7CiAgICAgICAgICBpZiAodG5hbWUgPT09IHRhYmxlMSkgewogICAgICAgICAgICBtYXRjaF9jb3VudCsrCiAgICAgICAgICAgIC8vbG9nKHRuYW1lLCAiaXMgYWxyZWFkeSBpbiB0aGUgcXVlcnkiKQogICAgICAgICAgICB0YWJsZV90b19hZGQgPSB0YWJsZTIKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0bmFtZSA9PT0gdGFibGUyKSB7CiAgICAgICAgICAgIG1hdGNoX2NvdW50KysKICAgICAgICAgICAgLy9sb2codG5hbWUsICJpcyBhbHJlYWR5IGluIHRoZSBxdWVyeSIpCiAgICAgICAgICAgIHRhYmxlX3RvX2FkZCA9IHRhYmxlMQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvL2xvZygidGFibGVfdG9fYWRkIix0YWJsZV90b19hZGQpCiAgICAgICAgaWYgKG1hdGNoX2NvdW50ID09PSAwKSB7CiAgICAgICAgICBtZXNzYWdlKHsKICAgICAgICAgICAgbWVzc2FnZTogJ05laXRoZXIgIicgKyB0YWJsZTEgKyAnIiBub3IgIicgKyB0YWJsZTIgKyAnIiBpcyBhbHJlYWR5IGluIHRoZSBxdWVyeSwgc28gd2UgY2Fubm90IGFkZCB0aGUgc2VsZWN0ZWQgam9pbi4nLAogICAgICAgICAgICB0aXRsZTogIlByb2JsZW0gQnVpbGRpbmcgU1FMIiwKICAgICAgICAgICAgc2Vjb25kczogNCwKICAgICAgICAgICAga2luZDogImVycm9yIiwKICAgICAgICAgICAgc2hvdzogdHJ1ZQogICAgICAgICAgfSkKICAKICAgICAgICAgIAogICAgICAgIH0gZWxzZSBpZiAobWF0Y2hfY291bnQgPT09IDEpIHsKICAgICAgICAgIC8vbG9nKCJyZWFkeSB0byBhZGQiLCBmcmFnbWVudCkKICAgICAgICAgIERJQUdSQU1TW2lkXS5xdWVyeS5mcm9tLnB1c2goIiAgSk9JTiAgIiArIHRhYmxlX3RvX2FkZCArICJcbiAgICBPTiAgIiArIGZyYWdtZW50LnNwbGl0KCIgT04gIilbMV0ucmVwbGFjZSgvIEFORCAvZywgJ1xuICAgIEFORCAnKSkKICAgICAgICAgIERJQUdSQU1TW2lkXS5xdWVyeS50YWJsZXMucHVzaCh0YWJsZV90b19hZGQpCiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIG1lc3NhZ2UoewogICAgICAgICAgICBtZXNzYWdlOiAnQm90aCAiJyArIHRhYmxlMSArICciIGFuZCAiJyArIHRhYmxlMiArICciIGFyZSBhbHJlYWR5IGluIHRoZSBxdWVyeSwgc28gd2UgY2Fubm90IGFkZCB0aGUgc2VsZWN0ZWQgam9pbi4nLAogICAgICAgICAgICB0aXRsZTogIlByb2JsZW0gQnVpbGRpbmcgU1FMIiwKICAgICAgICAgICAgc2Vjb25kczogNCwKICAgICAgICAgICAga2luZDogImVycm9yIiwKICAgICAgICAgICAgc2hvdzogdHJ1ZQogICAg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CA8IHEubGVuZ3RoOyB4KyspIHsKICAgICAgLy8gLS0tIGlnbm9yZSBhbnl0aGluZyBpbiBxdW90ZXMgLS0tCiAgICAgIGlmIChxW3hdID09PSAiJyIpIHdoaWxlIChxWysreF0gIT09ICInIikgeyB9CiAgICAgIGVsc2UgaWYgKHFbeF0gPT09ICciJykgd2hpbGUgKHFbKyt4XSAhPT0gJyInKSB7IH0KICAgICAgZWxzZSBpZiAocVt4XSA9PT0gJ2AnKSB3aGlsZSAocVsrK3hdICE9PSAnYCcpIHsgfQogICAgICAvLyAtLS0gYWgsIHdlIGZvdW5kIGEgcmVhbCBjb21tZW50IC0tLQogICAgICBlbHNlIGlmIChxW3hdICsgcVt4ICsgMV0gPT09ICctLScpIHsKICAgICAgICB3aGlsZSAocVt4XSAhPT0gJ1xuJyAmJiB4IDwgcS5sZW5ndGgpIHsgCiAgICAgICAgICBxW3hdID0gJycKICAgICAgICAgIHgrKyAKICAgICAgICB9CiAgICAgIH0KICAgICAgZWxzZSBpZiAocVt4XSArIHFbeCArIDFdID09PSAnLyonKSB7IAogICAgICAgIHdoaWxlIChxW3hdICsgcVt4ICsgMV0gIT09ICcqLycpIHsKICAgICAgICAgIHFbeF0gPSAnJwogICAgICAgICAgeCsrIAogICAgICAgIH0gCiAgCiAgICAgICAgcVt4XSA9ICcnCiAgICAgICAgcVt4KzFdID0gJycKICAgICAgICB4ID0geCArIDI7IAogICAgICB9CiAgICB9CiAgICByZXR1cm4gcS5qb2luKCIiKQogIH0KICAKICAKICAKICBhc3luYyBmdW5jdGlvbiBydW5fZGJfcXVlcnkocGFyYW1zKSB7CiAgICAvLyBwYXJhbXM6CiAgICAvLyAgICAgZW5naW5lOiAgKGlmIG5vdCBzdXBwbGllZCwgcmVhZHMgZnJvbSBib29rU2V0dGluZ3MpCiAgICAvLyAgICAgICAgIG9uZSBvZjogb3JhY2xlLHNxbGl0ZSxib29rLGRhdGF3b3JsZAogIAogICAgLy8gICAgIG9yYWNsZToKICAgIC8vIC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ga2luZDogImVycm9yIiwKICAgICAgICAgICAgICBzZWNvbmRzOiA4LAogICAgICAgICAgICB9KQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgbWVzc2FnZSh7CiAgICAgICAgICAgICAgbWVzc2FnZTogZS5tZXNzYWdlLAogICAgICAgICAgICAgIHRpdGxlOiAiRGF0YSBMb2FkaW5nIEVycm9yIiwKICAgICAgICAgICAgICBraW5kOiAiZXJyb3IiLAogICAgICAgICAgICAgIHNlY29uZHM6IDgsCiAgICAgICAgICAgIH0pCiAgICAgICAgICB9CiAgICAgICAgfQogIAogIAogICAgICAgIHN0bXQuZ2V0QXNPYmplY3QoKTsKICAgICAgICBzdG10LnN0ZXAoKQogICAgICAgIGNvbnN0IHJvdyA9IHN0bXQuZ2V0QXNPYmplY3QoKTsKICAgICAgICBpZiAocm93Lm5hbWUgIT09IHBhcmFtcy5zY2hlbWEpIHsKICAgICAgICAgIC8vIHRoZSBjb3JyZWN0IHNjaGVtYSBpcyBub3QgbG9hZGVkLCBsb2FkIGl0IHVwCiAgICAgICAgICAvL2xvZygibG9hZGluZyBzcWxpdGUgc2NoZW1hIiwgcGFyYW1zLnNjaGVtYSkKICAgICAgICAgIGF3YWl0IGxvYWRfc3FsaXRlX2RiKHBhcmFtcy5zY2hlbWEpCiAgICAgICAgfQogIAogICAgICAgIC8vbG9nKCJzY2hlbWEgaXMgbG9hZGVkLS0tLS0iKQogICAgICAgIHNjcmlwdF9yZXN1bHQgPSB7IGl0ZW1zOiBbXSB9CiAgICAgICAgbGV0IHN0YXRlbWVudElkID0gMAogICAgICAgIGZvciAoY29uc3QgcXVlcnkgb2Ygc3BsaXRfcXVlcmllcyhwYXJhbXMucXVlcnkpKSB7CiAgICAgICAgICBzdGF0ZW1lbnRJZCsrCiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBzcWwgPSBxdWVyeS50cmltKCkKICAgICAgICAgICAgaWYgKHNxbC5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgLy9sb2coIi0tNCIpCiAgICAgICAgICAgICAgY29uc3Qgc3RtdCA9IFNRTElURV9EQi5wcmVwYXJlKHNxbCk7CiAgICAgICAgICAgICAgc3RtdC5nZXRBc09iamVjdCgpOwogICAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBmb3JtYXRfc3FsaXRlX3Jlc3VsdHMoc3RtdCwgc3FsKQogICAgICAgICAgICAgIGl0ZW0uc3RhdGVtZW50SWQgPSBzdGF0ZW1lbnRJZAogICAgICAgICAgICAgIHNjcmlwdF9yZXN1bHQuaXRlbXMucHVzaChpdGVtKQogICAgICAgICAgICB9CiAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgIHNjcmlwdF9yZXN1bHQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgICAgc3RhdGVtZW50SWQ6IHN0YXRlbWVudElkLAogICAgICAgICAgICAgIHN0YXRlbWVudFRleHQ6IHF1ZXJ5LnRyaW0oKSwKICAgICAgICAgICAgICBlcnJvck1lc3NhZ2U6IGUubWVzc2FnZQogICAgICAgICAgICB9KQogICAgICAgICAgfQogICAgICAgIH0KICAKICAgICAgICByZXR1cm4gc2NyaXB0X3Jlc3VsdAogIAogIAogIAogICAgICAgIGJyZWFrCiAgICAgIGNhc2UgImRhdGF3b3JsZCI6CiAgICAgICAgbG9nKCJhdCBydW5fZGJfcXVlcnkgZHciLCBwYXJhbXMpCiAgICAgICAgLy8gcGFyYW1zLnNjaGVtYT0iY29va2Jvb2siICAKICAgICAgICAvLyBwYXJhbXMucXVlcnk9InNlbGVjdCAqIGZyb20gbnV0cml0aW9uIiAgCiAgICAgICAgc2NyaXB0X3Jlc3VsdCA9IHsgaXRlbXM6IFtdIH0KICAgICAgICBsZXQgc3RtdElkID0gMAogICAgICAgIGZvciAoY29uc3QgcXVlcnkgb2Ygc3BsaXRfcXVlcmllcyhwYXJhbXMucXVlcnkpKSB7CiAgICAgICAgICBzdG10SWQrKwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3Qgc3FsID0gcXVlcnkudHJpbSgpCiAgICAgICAgICAgIGlmIChzcWwubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgIC8vbG9nKCJkd3EiLCBzcWwpCiAgCiAgICAgICAgICAgICAgY29uc3QgdXJsID0gYGh0dHBzOi8vYXBpLmRhdGEud29ybGQvdjAvc3FsLyR7cGFyYW1zLm93bmVyfS8ke3BhcmFtcy5zY2hlbWF9YAogICAgICAgICAgICAgIGNvbnN0IG9wdGlvbnMgPSB7CiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7CiAgICAgICAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAnYXBwbGljYXRpb24vanNvbicsCiAgICAgICAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogJ0JlYXJlciAnICsgcGFyYW1zLnRva2VuLAogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICdtZXRob2QnOiAnUE9TVCcsCiAgICAgICAgICAgICAgICAnYm9keSc6IEpTT04uc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgICAgInF1ZXJ5Ijogc3FsLAogICAgICAgICAgICAgICAgICAiaW5jbHVkZVRhYmxlU2NoZW1hIjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgInF1ZXJ5UnVuVG9rZW4iOiB1dWlkKCkKICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGxldCByZXNwb25zZQogICAgICAgICAgICAgIGxvZyh1cmwsIG9wdGlvbnMpCiAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gYXdhaXQgZmV0Y2godXJsLCBvcHRpb25zKQogICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgIDtsb2coImh0dHAgZXJyb3IiLCBlKQogICAgICAgICAgICAgIH0KICAKICAgICAgICAgICAgICBpZiAocmVzcG9uc2U/Lm9rKSB7CiAgICAgICAgICAgICAgICAvL2xvZygicmVzcG9uc2UiLHJlc3BvbnNlKSAKICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSBhd2FpdCByZXNwb25zZS5qc29uKCkKICAgICAgICAgICAgICAgIC8vbG9nKGRhdGEpCiAgICAgICAgICAgICAgICBjb25zdCBpdGVtID0gZm9ybWF0X2R3X3Jlc3VsdHMoZGF0YSwgc3FsKQogICAgICAgICAgICAgICAgLy9sb2coIml0ZW0gaW4gcnVuIGR3IixpdGVtKQogICAgICAgICAgICAgICAgaXRlbS5zdGF0ZW1lbnRJZCA9IHN0bXRJZAogICAgICAgICAgICAgICAgc2NyaXB0X3Jlc3VsdC5pdGVtcy5wdXNoKGl0ZW0pCiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSBhd2FpdCByZXNwb25zZS50ZXh0KCkKICAgICAgICAgICAgICAgIC8vbG9nKCJlcnIgbXNnIiwgZGF0YSkKICAgICAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlbWVudElkOiBzdG10SWQsCiAgICAgICAgICAgICAgICAgIHN0YXRlbWVudFR5cGU6ICJxdWVyeSIsCiAgICAgICAgICAgICAgICAgIHN0YXRlbWVudFRleHQ6IHNxbCwKICAgICAgICAgICAgICAgICAgZXJyb3JNZXNzYWdlOiBkYXRhLAogICAgICAgICAgICAgICAgICByZXNwb25zZTogW10sCiAgICAgICAgICAgICAgICAgIHJlc3VsdDogMAogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc2NyaXB0X3Jlc3VsdC5pdGVtcy5wdXNoKGl0ZW0pCiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgIDtsb2coImVycm9yIiwgZSkKICAgICAgICAgICAgc2NyaXB0X3Jlc3VsdC5pdGVtcy5wdXNoKHsKICAgICAgICAgICAgICBzdGF0ZW1lbnR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IKICAgICAgZGVsZXRlIGl0ZW0ucmVzdWx0U2V0CiAgCiAgCiAgICB9CiAgICByZXR1cm4gaXRlbQogIAogIAogIH0KICAKICAKICBmdW5jdGlvbiBmb3JtYXRfc3FsaXRlX3Jlc3VsdHMoc3RtdCwgc3FsKSB7CiAgICBjb25zdCBpdGVtID0gewogICAgICBzdGF0ZW1lbnRUeXBlOiAicXVlcnkiLAogICAgICBzdGF0ZW1lbnRUZXh0OiBzcWwsCiAgICAgIHJlc3VsdFNldDogewogICAgICAgIG1ldGFkYXRhOiBbXSwKICAgICAgICBpdGVtczogW10KICAgICAgfQogICAgfQogICAgY29uc3QgY29sdW1ucyA9IHt9CiAgICB3aGlsZSAoc3RtdC5zdGVwKCkpIHsgLy8KICAgICAgY29uc3Qgcm93ID0gc3RtdC5nZXRBc09iamVjdCgpOwogICAgICBmb3IgKGNvbnN0IFtuYW1lLCB2YWxdIG9mIE9iamVjdC5lbnRyaWVzKHJvdykpIHsKICAgICAgICBpZiAoIWNvbHVtbnNbbmFtZV0pIHsKICAgICAgICAgIGl0ZW0ucmVzdWx0U2V0Lm1ldGFkYXRhLnB1c2gobmFtZSkKICAgICAgICAgIGNvbHVtbnNbbmFtZV0gPSB7CiAgICAgICAgICAgIGNvbHVtbk5hbWU6IG5hbWUudG9VcHBlckNhc2UoKSwKICAgICAgICAgICAganNvbkNvbHVtbk5hbWU6IG5hbWUsCiAgICAgICAgICAgIGNvbHVtblR5cGVOYW1lOiAiTlVNQkVSIiwKICAgICAgICAgICAgcHJlY2lzaW9uOiAwLAogICAgICAgICAgICBzY2FsZTogMAogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvbHVtbnNbbmFtZV0uY29sdW1uVHlwZU5hbWUgPT09ICJOVU1CRVIiKSB7CiAgICAgICAgICAgIC8vIHdlIGhhdmUgbm90IHlldCBmb3VuZCBhbnkgbm9uLW51bWVyaWMgdmFsdWVzCiAgICAgICAgICAgIGlmIChpc05hTih2YWwpKSB7CiAgICAgICAgICAgICAgLy9sb2coInZhbCIsIHZhbCkKICAgICAgICAgICAgICBjb2x1bW5zW25hbWVdLmNvbHVtblR5cGVOYW1lID0gIlZBUkNIQVIyIgogICAgICAgICAgICAgIC8vbG9nKG5hbWUsIGNvbHVtbnNbbmFtZV0pCiAgICAgICAgICAgIH0gZWxzZSBpZiAodmFsID09PSBudWxsKSB7CiAgICAgICAgICAgICAgLy8gc2tpcCBpZiBudWxsCiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgbnVtX3N0cnVjdCA9IHZhbC50b1N0cmluZygpLnNwbGl0KCIuIikKICAgICAgICAgICAgICBpZiAobnVtX3N0cnVjdC5sZW5ndGggPT09IDEpIHsgbnVtX3N0cnVjdC5wdXNoKCIiKSB9CiAgICAgICAgICAgICAgaWYgKG51bV9zdHJ1Y3RbMF0ubGVuZ3RoID4gY29sdW1uc1tuYW1lXS5wcmVjaXNpb24pIHsKICAgICAgICAgICAgICAgIGNvbHVtbnNbbmFtZV0ucHJlY2lzaW9uID0gbnVtX3N0cnVjdFswXS5sZW5ndGgKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKG51bV9zdHJ1Y3RbMV0ubGVuZ3RoID4gY29sdW1uc1tuYW1lXS5zY2FsZSkgewogICAgICAgICAgICAgICAgY29sdW1uc1tuYW1lXS5zY2FsZSA9IG51bV9zdHJ1Y3RbMV0ubGVuZ3RoCiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGl0ZW0ucmVzdWx0U2V0Lml0ZW1zLnB1c2gocm93KQogICAgfQogICAgZm9yIChsZXQgeCA9IDA7IHggPCBpdGVtLnJlc3VsdFNldC5tZXRhZGF0YS5sZW5ndGg7IHgrKykgewogICAgICAvLyByZXBsYWNlIHRoZSBuYW1lIG9mIHRoZSBjb2x1bW4gd2l0aCB0aGUgY29sdW1uIG9iamVjdAogICAgICAvLyAvL2xvZygiY29sdW1uIi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ZW5jb2RlZCcvLztjaGFyc2V0PVVURi04JwogICAgICB9LAogICAgICBib2R5OiBmaWVsZF92YWx1ZXMuam9pbigiJiIpCiAgICB9KS50aGVuKChyZXNwb25zZSkgPT4gcmVzcG9uc2UudGV4dCgpKQogICAgICAudGhlbigoZGF0YSkgPT4geztsb2coZGF0YSl9KTsKICAKICB9CiAgCiAgZnVuY3Rpb24gc2hvd19xdWVyeV9jZWxsKGV2dCl7CiAgICAvLyBzaG93cyBhbGwgY29udGVudHMgb2YgYSBjZWxsIGluIGEgcXVlcnkgaWYgdGhlIGNlbGwncyB0ZXh0IGlzIHRvbyB3aWRlIHRvIGJlIGRpc3BsYXllZCBieSBkZWZhdWx0CiAgICBjb25zdCBjZWxsPWV2dC50YXJnZXQKICAgIC8vbG9nKCJjZWxsIiwgY2VsbC50YWdOYW1lKQogICAgc3dpdGNoKGNlbGwudGFnTmFtZSl7CiAgICAgIGNhc2UgIlREIjoKICAgICAgICBpZihjZWxsLnN0eWxlLndoaXRlU3BhY2U9PT0ibm9ybWFsIil7CiAgICAgICAgICBjZWxsLnN0eWxlLndoaXRlU3BhY2U9Im5vd3JhcCIKICAgICAgICB9ZWxzZXsKICAgICAgICAgIGlmIChjZWxsLm9mZnNldFdpZHRoIDwgY2VsbC5zY3JvbGxXaWR0aCl7CiAgICAgICAgICAgIGNlbGwuc3R5bGUud2hpdGVTcGFjZT0ibm9ybWFsIgogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBicmVhayAgCiAgICAgIGNhc2UgIlRIIjoKICAgICAgICAvLyBUTyBETzogIGZpZ3VyZSBvdXQgcXVlcnlzZWxldG9yIG50aCBjb2x1bW4gdG8gbWFrZSB0aGlzIHdvcmsKICAgICAgICBpZihldnQub2Zmc2V0WDxjZWxsLm9mZnNldFdpZHRoKi4yNSl7CiAgICAgICAgICAvL2xvZygibmVlZCB0byBzaHJpbmsgY29sdW1uIikKICAgICAgICB9ZWxzZSBpZihldnQub2Zmc2V0WD5jZWxsLm9m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