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UiOiAwLOeUqOS6juaQnOe0ouaXtuaOkumZpOi/meS4qua6kAoyMDI0MDYwNDoKMS7pppbpobXmjqjojZDlj5bmtojnoazmjqfnrYnlvoXjgILlop7liqDpmo/mnLrmjqjojZDlip/og73jgIIKMi7pppbpobXmjqjojZDmlrDlop7mm7TmlrDml6Xlv5fmn6XnnIvlip/og70K44CQ54m55Yir6K+05piO44CR55uu5YmN5Y+q5pSv5oyB5qCH5YeGanNvbuagvOW8j+eahOmHh+mbhuermSjotYTmupDnq5nkuIDoiKzpg73mj5Dkvpt4bWzlkoxqc29u5Lik56eN5o6l5Y+j77yM55uu5YmN5rKh5pyJ5pSv5oyBeG1s55qE5oOz5rOV77yM5rKh5LuA5LmI5b+F6KaBKQrmnInkupvotYTmupDnq5nnmoRqc29u5o6l5Y+j5LiN5piv5qCH5YeG55qEL2FwaS5waHAvcHJvdmlkZS92b2QvLOmcgOimgeiHquW3seWcqOmHh+mbhumdmeaAgS5qc29u5Lit57yW6L6R5a+55bqU55qEYXBp5bGe5oCn5aGr5YaZ5q+U5aaCOi9hcGkucGhwL3Byb3ZpZGUvdm9kL2F0L2pzb24vCuacieS6m+i1hOa6kOermeeahOmHh+mbhuaVsOaNruaYr+WKoOWvhuWQjueahOWIh+eJh+eJh+aute+8jOWPr+iDvemcgOimgemHh+mbhuermeeJueWumueahOino+aekOaOpeWPo++8jOmcgOimgeiHquW3see8lui+kWpzb27ph4znmoRwYXJzZV91cmzlsZ7mgKcK6LWE5rqQ56uZ6YOo5YiG5aSn5YiG57G75LiL5peg5pWw5o2u5b6I5q2j5bi477yM5Y+v5Lul6Ieq6KGM57yW6L6RanNvbumHjGNhdGVfZXhjbHVkZeWxnuaAp+aOkumZpOaOieiHquW3sea1i+ivlei/h+aXoOaVsOaNrueahOWIhuexuyjlsI/nqIvluo/ml6Dms5Xoh6rliqjor4bliKvvvIzlj6rog73kurrlt6XmtYvlpb3lk6rkupvliIbnsbvml6DmlbDmja4pCmAudHJpbSgpLAogICAga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ogdHJ1ZSwKICAgIHBhcnNlX3VybDogJycsIC8vIOi/meS4quWPguaVsOaaguaXtuS4jei1t+S9nOeUqOOAguiBmuWQiOexu+eahOavj+S4qui1hOa6kOW6lOivpeacieiHquW3seeLrOeri+eahOino+aekOWPo+OAguWNleeLrOmFjee9ruWcqOmHh+mbhi5qc29u6YeM55qEcGFyc2VfdXJs5pyJ5pWICiAgICBzZWFyY2hfbWF0Y2g6IGZhbHNlLCAvLyDmkJzntKLnsr7lh4bljLnphY0KICAgIHNlYXJjaF9waWM6IHRydWUsIC8vIOaQnOe0ouW8uuWItumcgOimgeWbvueJhwogICAgLy8gcGFyYW1zOiAnaHR0cDovLzEyNy4wLjAuMTo1NzA3L2ZpbGVzL2pzb24vJUU5JTg3JTg3JUU5JTlCJTg2Lmpzb24nLAogICAgLy8gcGFyYW1zOiAnaHR0cDovLzEyNy4wLjAuMTo1NzA3L2ZpbGVzL2pzb24v6YeH6ZuG6Z2Z5oCBLmpzb24kMScsCiAgICAvLyBwYXJhbXM6ICdodHRwOi8vMTI3LjAuMC4xOjU3MDcvZmlsZXMvanNvbi/ph4fpm4Zbenld6Z2Z5oCBLmpzb24kMScsCiAgICAvLyBob3N0SnM6JGpzLnRvU3RyaW5nKCgpPT57CiAgICAvLwogICAgLy8gfSksCiAgICDpooTlpITnkIY6ICRqcy50b1N0cmluZygoKSA9PiB7CiAgICAgICAgZnVuY3Rpb24gZ2V0Q2xhc3NlcyhpdGVtKSB7CiAgICAgICAgICAgIGxldCBjbGFzc2VzID0gW107CiAgICAgICAgICAgIGlmIChpdGVtLmNsYXNzX25hbWUgJiYgaXRlbS5jbGFzc191cmwpIHsKICAgICAgICAgICAgICAgIGlmICghLyZ855S15b2xfOeUteinhuWJp3znu7zoibp85Yqo5ryrW1x1NEUwMC1cdTlGQTVdKy8udGVzdChpdGVtLmNsYXNzX25hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaXRlbS5jbGFzc19uYW1lID0gdW5nemlwKGl0ZW0uY2xhc3NfbmFtZSkKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhg5LiN6K+G5Yir55qEY2xhc3NfbmFtZeWvvOiHtGd6aXDop6PnoIHlpLHotKU6JHtlfWApCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjbGFzc2VzCiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGV0IG5hbWVzID0gaXRlbS5jbGFzc19uYW1lLnNwbGl0KCcmJyk7CiAgICAgICAgICAgICAgICBsZXQgdXJscyA9IGl0ZW0uY2xhc3NfdXJsLnNwbGl0KCcmJyk7CiAgICAgICAgICAgICAgICBsZXQgY250ID0gTWF0aC5taW4obmFtZXMubGVuZ3RoLCB1cmxzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgY2xhc3Nlcy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgJ3R5cGVfaWQnOiB1cmxzW2ldLAogICAgICAgICAgICAgICAgICAgICAgICAndHlwZV9uYW1lJzogbmFtZXNbaV0KICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gY2xhc3NlcwogICAgICAgIH0KCiAgICAgICAgaWYgKHR5cGVvZiAoYmF0Y2hGZXRjaCkgPT09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgLy8g5pSv5oyB5om56YeP6K+35rGC55u05o6l5pS+6aOe6Ieq5oiR44CC5pCc57Si6ZmQ5Yi25pyA5aSn57q/56iL5pWw6YePMTYKICAgICAgICAgICAgcnVsZS5zZWFyY2hfbGltaXQgPSAxNjsKICAgICAgICAgICAgbG9nKCflvZPliY3nqIvluo/mlK/mjIHmibnph4/or7fmsYJbYmF0Y2hGZXRjaF0s5pCc57Si6ZmQ5Yi25bey6K6+572u5Li6MTYnKTsKICAgICAgICB9CiAgICAgICAgbGV0IF91cmwgPSBydWxlLnBhcmFtczsKICAgICAgICBsb2coYOS8oOWFpeWPguaVsDoke191cmx9YCk7CiAgICAgICAgaWYgKF91cmwgJiYgdHlwZW9mIChfdXJsKSA9PT0gJ3N0cmluZycgJiYgL14oaHR0cHxmaWxlKS8udGVzdChfdXJsKSkgewogICAgICAgICAgICBpZiAoX3VybC5pbmNsdWRlcygnJCcpKSB7CiAgICAgICAgICAgICAgICBsZXQgX3VybF9wYXJhbXMgPSBfdXJsLnNwbGl0KCckJyk7CiAgICAgICAgICAgICAgICBfdXJsID0gX3VybF9wYXJhbXNbMF07CiAgICAgICAgICAgICAgICBydWxlLnNlYXJjaF9tYXRjaCA9ICEhKF91cmxfcGFyYW1zWzFdKTsKICAgICAgICAgICAgICAgIGlmIChfdXJsX3BhcmFtcy5sZW5ndGggPiAyKSB7IC8vIOW8uuWItuWbvueJhwogICAgICAgICAgICAgICAgICAgIHJ1bGUuc2VhcmNoX3BpYyA9ICEhKF91cmxfcGFyYW1zWzJdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoX3VybCk7CiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShodG1sKTsKICAgICAgICAgICAgbGV0IF9jbGFzc2VzID0gW107CiAgICAgICAgICAgIHJ1bGUuZmlsdGVyID0ge307CiAgICAgICAgICAgIHJ1bGUuZmlsdGVyX2RlZiA9IHt9OwogICAgICAgICAgICBqc29uLmZvckVhY2goaXQgPT4gewogICAgICAgICAgICAgICAgbGV0IF9vYmogPSB7CiAgICAgICAgICAgICAgICAgICAgdHlwZV9uYW1lOiBpdC5uYW1lLAogICAgICAgICAgICAgICAgICAgIHR5cGVfaWQ6IGl0LnVybCwKICAgICAgICAgICAgICAgICAgICBwYXJzZV91cmw6IGl0LnBhcnNlX3VybCB8fCAnJywKICAgICAgICAgICAgICAgICAgICBzZWFyY2hhYmxlOiBpdC5zZWFyY2hhYmxlICE9PSAwLAogICAgICAgICAgICAgICAgICAgIGFwaTogaXQuYXBpIHx8ICcnLAogICAgICAgICAgICAgICAgICAgIGNhdGVfZXhjbHVkZTogaXQuY2F0ZV9leGNsdWRlIHx8ICcnLAogICAgICAgICAgICAgICAgICAgIGNhdGVfZXhjbHVkZXM6IGl0LmNhdGVfZXhjbHVkZXMgfHwgW10sCiAgICAgICAgICAgICAgICAgICAgLy8gY2xhc3NfbmFtZTogaXQuY2xhc3NfbmFtZSB8fCAnJywKICAgICAgICAgICAgICAgICAgICAvLyBjbGFzc191cmw6IGl0LmNsYXNzX3VybCB8fCAnJywKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBfY2xhc3Nlcy5wdXNoKF9vYmopOwogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICBsZXQganNvbjEgPSBbXTsKICAgICAgICAgICAgICAgICAgICBpZiAoaXQuY2xhc3NfbmFtZSAmJiBpdC5jbGFzc191cmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAganNvbjEgPSBnZXRDbGFzc2VzKGl0KTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBqc29uMSA9IEpTT04ucGFyc2UocmVxdWVzdCh1cmxqb2luKF9vYmoudHlwZV9pZCwgX29iai5hcGkgfHwgcnVsZS5jbGFzc1VybCkpKS5jbGFzczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKF9vYmouY2F0ZV9leGNsdWRlcyAmJiBBcnJheS5pc0FycmF5KF9vYmouY2F0ZV9leGNsdWRlcykgJiYgX29iai5jYXRlX2V4Y2x1ZGVzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAganNvbjEgPSBqc29uMS5maWx0ZXIoY2wgPT4gIV9vYmouY2F0ZV9leGNsdWRlcy5pbmNsdWRlcyhjbC50eXBlX25hbWUpKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKF9vYmouY2F0ZV9leGNsdWRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGpzb24xID0ganNvbjEuZmlsdGVyKGNsID0+ICFuZXcgUmVnRXhwKF9vYmouY2F0ZV9leGNsdWRlLCAnaScpLnRlc3QoY2wudHlwZV9uYW1lKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJ1bGUuZmlsdGVyW19vYmoudHlwZV9pZF0gPSBbewogICAgICAgICAgICAgICAgICAgICAgICAia2V5IjogIuexu+WeiyIsICJuYW1lIjogIuexu+WeiyIsICJ2YWx1ZSI6IGpzb24xLm1hcChpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7Im4iOiBpLnR5cGVfbmFtZSwgJ3YnOiBpLnR5cGVfaWR9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pCiAgICAgICAgICAgICAgICAgICAgfV07CiAgICAgICAgICAgICAgICAgICAgaWYgKGpzb24xLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcnVsZS5maWx0ZXJfZGVmW2l0LnVybF0gPSB7Iuexu+WeiyI6IGpzb24xWzBdLnR5cGVfaWR9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICBydWxlLmZpbHRlcltpdC51cmxdID0gW3sia2V5IjogIuexu+WeiyIsICJuYW1lIjogIuexu+WeiyIsICJ2YWx1ZSI6IFt7Im4iOiAi5YWo6YOoIiwgInYiOiAiIn1dfV07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBydWxlLmNsYXNzZXMgPSBfY2xhc3NlczsKICAgICAgICB9CiAgICB9KSwKICAgIC8vIGNsYXNzX3BhcnNlOiAkanMudG9TdHJpbmcoKCkgPT4gewogICAgLy8gICAgIGxldCBfdXJsID0gcnVsZS5wYXJhbXM7CiAgICAvLyAgICAgaWYgKF91cmwgJiYgdHlwZW9mIChfdXJsKSA9PT0gJ3N0cmluZycgJiYgX3VybC5zdGFydHNXaXRoKCdodHRwJykpIHsKICAgIC8vICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KF91cmwpOwogICAgLy8gICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoaHRtbCk7CiAgICAvLyAgICAgICAgIGxldCBfY2xhc3NlcyA9IFtdOwogICAgLy8gICAgICAgICBob21lT2JqLmZpbHRlciA9IHt9OwogICAgLy8gICAgICAgICBydWxlLmZpbHRlcl9kZWYgPSB7fTsKICAgIC8vICAgICAgICAganNvbi5mb3JFYWNoKGl0ID0+IHsKICAgIC8vICAgICAgICAgICAgIGxldCBfb2JqID0gewogICAgLy8gICAgICAgICAgICAgICAgIHR5cGVfbmFtZTogaXQubmFtZSwKICAgIC8vICAgICAgICAgICAgICAgICB0eXBlX2lkOiBpdC51cmwsCiAgICAvLyAgICAgICAgICAgICAgICAgcGFyc2VfdXJsOiBpdC5wYXJzZV91cmwgfHwgJycsCiAgICAvLyAgICAgICAgICAgICAgICAgY2F0ZV9leGNsdWRlOiBpdC5jYXRlX2V4Y2x1ZGUgfHwgJycsCiAgICAvLyAgICAgICAgICAgICB9OwogICAgLy8gICAgICAgICAgICAgX2NsYXNzZXMucHVzaChfb2JqKTsKICAgIC8vICAgICAgICAgICAgIHRyeSB7CiAgICAvLyAgICAgICAgICAgICAgICAgbGV0IGpzb24xID0gSlNPTi5wYXJzZShyZXF1ZXN0KHVybGpvaW4oX29iai50eXBlX2lkLCBydWxlLmNsYXNzVXJsKSkpLmNsYXNzOwogICAgLy8gICAgICAgICAgICAgICAgIGlmIChfb2JqLmNhdGVfZXhjbHVkZSkgewogICAgLy8gICAgICAgICAgICAgICAgICAgICBqc29uMSA9IGpzb24xLmZpbHRlcihjbCA9PiAhbmV3IFJlZ0V4cChfb2JqLmNhdGVfZXhjbHVkZSwgJ2knKS50ZXN0KGNsLnR5cGVfbmFtZSkpOwogICAgLy8gICAgICAgICAgICAgICAgIH0KICAgIC8vICAgICAgICAgICAgICAgICBob21lT2JqLmZpbHRlcltfb2JqLnR5cGVfaWRdID0gW3sKICAgIC8vICAgICAgICAgICAgICAgICAgICAgImtleSI6ICLnsbvlnosiLCAibmFtZSI6ICLnsbvlnosiLCAidmFsdWUiOiBqc29uMS5tYXAoaSA9PiB7CiAgICAvLyAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyJuIjogaS50eXBlX25hbWUsICd2JzogaS50eXBlX2lkfQogICAgLy8gICAgICAgICAgICAgICAgICAgICB9KQogICAgLy8gICAgICAgICAgICAgICAgIH1dOwogICAgLy8gICAgICAgICAgICAgICAgIGlmIChqc29uMS5sZW5ndGggPiAwKSB7CiAgICAvLyAgICAgICAgICAgICAgICAgICAgIHJ1bGUuZmlsdGVyX2RlZltpdC51cmxdID0geyLnsbvlnosiOiBqc29uMVswXS50eXBlX2lkfTsKICAgIC8vICAgICAgICAgICAgICAgICB9CiAgICAvLyAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAvLyAgICAgICAgICAgICAgICAgaG9tZU9iai5maWx0ZXJbaXQudXJsXSA9IFt7ImtleSI6ICLnsbvlnosiLCAibmFtZSI6ICLnsbvlnosiLCAidmFsdWUiOiBbeyJuIjogIuWFqOmDqCIsICJ2IjogIiJ9XX1dOwogICAgLy8gICAgICAgICAgICAgfQogICAgLy8gICAgICAgICB9KTsKICAgIC8vICAgICAgICAgcnVsZS5jbGFzc2VzID0gX2NsYXNzZXM7CiAgICAvLyAgICAgICAgIGlucHV0ID0gX2NsYXNzZXM7CiAgICAvLyAgICAgfQogICAgLy8gfSksCiAgICBjbGFzc19wYXJzZTogJGpzLnRvU3RyaW5nKCgpID0+IHsKICAgICAgICBpbnB1dCA9IHJ1bGUuY2xhc3NlczsKICAgIH0pLAogICAg5o6o6I2QOiAkanMudG9TdHJpbmcoKCkgPT4gewogICAgICAgIGxldCB1cGRhdGVfaW5mbyA9IFt7CiAgICAgICAgICAgIHZvZF9uYW1lOiAn5pu05paw5pel5b+XJywKICAgICAgICAgICAgdm9kX2lkOiAndXBkYXRlX2luZm8nLAogICAgICAgICAgICB2b2RfcmVtYXJrczogYOeJiOacrDoke3J1bGUudmVyc2lvbn1gLAogICAgICAgICAgICB2b2RfcGljOiAnaHR0cHM6Ly9naHByb3h5Lm5ldC9odHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vaGpkaG54L2hpcHktc2VydmVyL21hc3Rlci9hcHAvc3RhdGljL2ltZy9sb2dvLnBuZycKICAgICAgICB9XTsKICAgICAgICBWT0RTID0gW107CiAgICAgICAgaWYgKHJ1bGUuY2xhc3NlcykgewogICAgICAgICAgICBsZXQgcmFuZG9tQ2xhc3MgPSBnZXRSYW5kb21JdGVtKHJ1bGUuY2xhc3Nlcyk7CiAgICAgICAgICAgIGxldCBfdXJsID0gdXJsam9pbihyYW5kb21DbGFzcy50eXBlX2lkLCBpbnB1dCk7CiAgICAgICAgICAgIGlmIChyYW5kb21DbGFzcy5hcGkpIHsKICAgICAgICAgICAgICAgIF91cmwgPSBfdXJsLnJlcGxhY2UoJy9hcGkucGhwL3Byb3ZpZGUvdm9kLycsIHJhbmRvbUNsYXNzLmFwaSkKICAgICAgICAgICAgfQogICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KF91cmwsIHt0aW1lb3V0OiBydWxlLnRpbWVvdXR9KTsKICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShodG1sKTsKICAgICAgICAgICAgICAgIFZPRFMgPSBqc29uLmxpc3Q7CiAgICAgICAgICAgICAgICBWT0RTLmZvckVhY2goaXQgPT4gewogICAgICAgICAgICAgICAgICAgIGl0LnZvZF9pZCA9IHJhbmRvbUNsYXNzLnR5cGVfaWQgKyAnJCcgKyBpdC52b2RfaWQ7CiAgICAgICAgICAgICAgICAgICAgaXQudm9kX3JlbWFya3MgPSBpdC52b2RfcmVtYXJrcyArICd8JyArIHJhbmRvbUNsYXNzLnR5cGVfbmFtZTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgVk9EUyA9IHVwZGF0ZV9pbmZvLmNvbmNhdChWT0RTKTsKICAgIH0pLAogICAg5LiA57qnOiAkanMudG9TdHJpbmcoKCkgPT4gewogICAgICAgIFZPRFMgPSBbXTsKICAgICAgICBpZiAocnVsZS5jbGFzc2VzKSB7CiAgICAgICAgICAgIC8vIGxvZyhpbnB1dCk7CiAgICAgICAgICAgIGxldCBfdXJsID0gdXJsam9pbihNWV9DQVRFLCBpbnB1dCk7CiAgICAgICAgICAgIGxldCBjdXJyZW50X3ZvZCA9IHJ1bGUuY2xhc3Nlcy5maW5kKGl0ZW0gPT4gaXRlbS50eXBlX2lkID09PSBNWV9DQVRFKTsKICAgICAgICAgICAgaWYgKGN1cnJlbnRfdm9kICYmIGN1cnJlbnRfdm9kLmFwaSkgewogICAgICAgICAgICAgICAgX3VybCA9IF91cmwucmVwbGFjZSgnL2FwaS5waHAvcHJvdmlkZS92b2QvJywgY3VycmVudF92b2QuYXBpKQogICAgICAgICAgICB9CiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChfdXJsKTsKICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGh0bWwpOwogICAgICAgICAgICBWT0RTID0ganNvbi5saXN0OwogICAgICAgICAgICBWT0RTLmZvckVhY2goaXQgPT4gewogICAgICAgICAgICAgICAgaXQudm9kX2lkID0gTVlfQ0FURSArICckJyArIGl0LnZvZF9pZAogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9KSwKICAgIC8vIOS4gOe6pzogJ2pzb246bGlzdDt2b2RfbmFtZTt2b2RfcGljO3ZvZF9yZW1hcmtzO3ZvZF9pZDt2b2RfcGxheV9mcm9tJywKICAgIOS6jOe6pzogJGpzLnRvU3RyaW5nKCgpID0+IHsKICAgICAgICBWT0QgPSB7fTsKICAgICAgICBpZiAob3JJZCA9PT0gJ3VwZGF0ZV9pbmZvJykgewogICAgICAgICAgICBWT0QgPSB7CiAgICAgICAgICAgICAgICB2b2RfY29udGVudDogcnVsZS51cGRhdGVfaW5mby50cmltKCksCiAgICAgICAgICAgICAgICB2b2RfbmFtZTogJ+abtOaWsOaXpeW/lycsCiAgICAgICAgICAgICAgICB0eXBlX25hbWU6ICfmm7TmlrDml6Xlv5cnLAogICAgICAgICAgICAgICAgdm9kX3BpYzogJ2h0dHBzOi8vcmVzb3VyY2UtY2RuLnR1eGlhb2JlaS5jb20vdmlkZW8vRnRXaHMybWV3WF83bkV1RTUxX2s2enZnNmF3bC5wbmcnLAogICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGDniYjmnKw6JHtydWxlLnZlcnNpb259YCwKICAgICAgICAgICAgICAgIHZvZF9wbGF5X2Zyb206ICfpgZPplb/lnKjnur8nLAogICAgICAgICAgICAgICAgLy8gdm9kX3BsYXlfdXJsOiAn5ZeF5o6i5pKt5pS+JGh0dHBzOi8vcmVzb3VyY2UtY2RuLnR1eGlhb2JlaS5jb20vdmlkZW8vMTAvOGYvMTA4ZmM5ZDFhYzNmNjlkMjlhNzM4Y2RjMDk3YzkwMTgubXA0JywKICAgICAgICAgICAgICAgIHZvZF9wbGF5X3VybDogJ+maj+acuuWwj+inhumikSRodHRwOi8vYXBpLnl1am4uY24vYXBpL3p6eGpqLnBocCcsCiAgICAgICAgICAgIH07CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgaWYgKHJ1bGUuY2xhc3NlcykgewogICAgICAgICAgICAgICAgbGV0IF91cmwgPSB1cmxqb2luKGZ5Y2xhc3MsIGlucHV0KTsKICAgICAgICAgICAgICAgIGxldCBjdXJyZW50X3ZvZCA9IHJ1bGUuY2xhc3Nlcy5maW5kKGl0ZW0gPT4gaXRlbS50eXBlX2lkID09PSBmeWNsYXNzKTsKICAgICAgICAgICAgICAgIGlmIChjdXJyZW50X3ZvZCAmJiBjdXJyZW50X3ZvZC5hcGkpIHsKICAgICAgICAgICAgICAgICAgICBfdXJsID0gX3VybC5yZXBsYWNlKCcvYXBpLnBocC9wcm92aWRlL3ZvZC8nLCBjdXJyZW50X3ZvZC5hcGkpCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoX3VybCk7CiAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoaHRtbCk7CiAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IGpzb24ubGlzdDsKICAgICAgICAgICAgICAgIFZPRCA9IGRhdGFbMF07CiAgICAgICAgICAgICAgICBpZiAoY3VycmVudF92b2QgJiYgY3VycmVudF92b2QudHlwZV9uYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgVk9ELnZvZF9wbGF5X2Zyb20gPSBWT0Qudm9kX3BsYXlfZnJvbS5zcGxpdCgnJCQkJykubWFwKGl0ID0+IGN1cnJlbnRfdm9kLnR5cGVfbmFtZSArICd8JyArIGl0KS5qb2luKCckJCQnKQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfSksCiAgICDmkJzntKI6ICRqcy50b1N0cmluZygoKSA9PiB7CiAgICAgICAgVk9EUyA9IFtdOwogICAgICAgIGlmIChydWxlLmNsYXNzZXMpIHsKICAgICAgICAgICAgbGV0IGNhblNlYXJjaCA9IHJ1bGUuY2xhc3Nlcy5maWx0ZXIoaXQgPT4gaXQuc2VhcmNoYWJsZSk7CiAgICAgICAgICAgIGxldCBwYWdlID0gTnVtYmVyKE1ZX1BBR0UpOwogICAgICAgICAgICBwYWdlID0gKE1ZX1BBR0UgLSAxKSAlIE1hdGguY2VpbChjYW5TZWFyY2gubGVuZ3RoIC8gcnVsZS5zZWFyY2hfbGltaXQpICsgMTsKICAgICAgICAgICAgbGV0IHRydWVQYWdlID0gTWF0aC5jZWlsKE1ZX1BBR0UgLyBNYXRoLmNlaWwoY2FuU2VhcmNoLmxlbmd0aCAvIHJ1bGUuc2VhcmNoX2xpbWl0KSk7CiAgICAgICAgICAgIGlmIChydWxlLnNlYXJjaF9saW1pdCkgewogICAgICAgICAgICAgICAgbGV0IHN0YXJ0ID0gKHBhZ2UgLSAxKSAqIHJ1bGUuc2VhcmNoX2xpbWl0OwogICAgICAgICAgICAgICAgbGV0IGVuZCA9IHBhZ2UgKiBydWxlLnNlYXJjaF9saW1pdDsKICAgICAgICAgICAgICAgIGxldCB0MSA9IG5ldyBEYXRlKCkuZ2V0VGltZSgpOwogICAgICAgICAgICAgICAgbGV0IHNlYXJjaE1vZGUgPSB0eXBlb2YgKGJhdGNoRmV0Y2gpID09PSAnZnVuY3Rpb24nID8gJ+aJuemHjycgOiAn5Y2V5LiqJzsKICAgICAgICAgICAgICAgIGxvZygnc3RhcnQ6JyArIHN0YXJ0KTsKICAgICAgICAgICAgICAgIGxvZygnZW5kOicgKyBlbmQpOwogICAgICAgICAgICAgICAgbG9nKCfmkJzntKLmqKHlvI86JyArIHNlYXJjaE1vZGUpOwogICAgICAgICAgICAgICAgbG9nKCfnsr7lh4bmkJzntKI6JyArIHJ1bGUuc2VhcmNoX21hdGNoKTsKICAgICAgICAgICAgICAgIC8vIGxvZygndDE6JyArIHQxKTsKICAgICAgICAgICAgICAgIGlmIChzdGFydCA8IGNhblNlYXJjaC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgc2VhcmNoX2NsYXNzZXMgPSBjYW5TZWFyY2guc2xpY2Uoc3RhcnQsIGVuZCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHVybHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICBzZWFyY2hfY2xhc3Nlcy5mb3JFYWNoKGl0ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IF91cmwgPSB1cmxqb2luKGl0LnR5cGVfaWQsIGlucHV0KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0LmFwaSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX3VybCA9IF91cmwucmVwbGFjZSgnL2FwaS5waHAvcHJvdmlkZS92b2QvJywgaXQuYXBpKQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF91cmwgPSBfdXJsLnJlcGxhY2UoIiNUcnVlUGFnZSMiLCAiIiArIHRydWVQYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdXJscy5wdXNoKF91cmwpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGxldCByZXN1bHRzX2xpc3QgPSBbXTsKICAgICAgICAgICAgICAgICAgICBsZXQgcmVzdWx0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgKGJhdGNoRmV0Y2gpID09PSAnZnVuY3Rpb24nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXFVcmxzID0gdXJscy5tYXAoaXQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IGl0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnM6IHt0aW1lb3V0OiBydWxlLnRpbWVvdXR9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmV0cyA9IGJhdGNoRmV0Y2gocmVxVXJscyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkZXRhaWxVcmxzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkZXRhaWxVcmxDb3VudCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHMuZm9yRWFjaCgocmV0LCBpZHgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpdCA9IHNlYXJjaF9jbGFzc2VzW2lkeF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmV0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0ganNvbi5saXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLmZvckVhY2goaSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpLnNpdGVfbmFtZSA9IGl0LnR5cGVfbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGkudm9kX2lkID0gaXQudHlwZV9pZCArICckJyArIGkudm9kX2lkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaS52b2RfcmVtYXJrcyA9IGkudm9kX3JlbWFya3MgKyAnfCcgKyBpdC50eXBlX25hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocnVsZS5zZWFyY2hfbWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBkYXRhLmZpbHRlcihpdGVtID0+IGl0ZW0udm9kX25hbWUgJiYgKG5ldyBSZWdFeHAoS0VZLCAnaScpKS50ZXN0KGl0ZW0udm9kX25hbWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChydWxlLnNlYXJjaF9waWMgJiYgIWRhdGFbMF0udm9kX3BpYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhg5b2T5YmN5pCc57Si56uZ54K544CQJHtpdC50eXBlX25hbWV944CR5rKh5Zu+54mHLOWwneivleiuv+mXruS6jOe6p+WOu+iOt+WPluWbvueJh2ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkZXRhaWxVcmwgPSB1cmxzW2lkeF0uc3BsaXQoJ3dkPScpWzBdICsgJ2FjPWRldGFpbCZpZHM9JyArIGRhdGEubWFwKGsgPT4gay52b2RfaWQuc3BsaXQoJyQnKVsxXSkuam9pbignLCcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbFVybHMucHVzaChkZXRhaWxVcmwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHNfbGlzdC5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzX3BpYzogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbFVybENvdW50OiBkZXRhaWxVcmxDb3VudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbFVybENvdW50Kys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgbGV0IGRldGFpbEpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QoZGV0YWlsVXJsKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gICAgIGRhdGEuZm9yRWFjaCgoZCwgX3NlcSkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICAgICAgbG9nKCfkuoznuqfmlbDmja7liJfooajlhYPntKDmlbA6JyArIGRldGFpbEpzb24ubGlzdC5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICAgICAgbGV0IGRldGFpbFZvZFBpYyA9IGRldGFpbEpzb24ubGlzdFtfc2VxXS52b2RfcGljOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICAgICAgaWYgKGRldGFpbFZvZFBpYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24oZCwge3ZvZF9waWM6IGRldGFpbFZvZFBpY30pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gICAgIGxvZyhg5by65Yi26I635Y+W572R56uZJHtpdC50eXBlX2lkfeeahOaQnOe0ouWbvueJh+Wksei0pToke2UubWVzc2FnZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHNfbGlzdC5wdXNoKHtkYXRhOiBkYXRhLCBoYXNfcGljOiB0cnVlfSk7CgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmVzdWx0cyA9IHJlc3VsdHMuY29uY2F0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coYOivt+axgjoke2l0LnR5cGVfaWR95Y+R55Sf6ZSZ6K+vOiR7ZS5tZXNzYWdlfWApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgLy8g5p6E6YCg6K+35rGC5LqM57qn55qEYmF0Y2hGZXRjaOWIl+ihqAogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVxVXJsczIgPSBkZXRhaWxVcmxzLm1hcChpdCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDogaXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uczoge3RpbWVvdXQ6IHJ1bGUudGltZW91dH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXRzMiA9IGJhdGNoRmV0Y2gocmVxVXJsczIpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IHJlc3VsdHNfbGlzdC5sZW5ndGg7IGsrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJlc3VsdF9kYXRhID0gcmVzdWx0c19saXN0W2tdLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXJlc3VsdHNfbGlzdFtrXS5oYXNfcGljKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRldGFpbEpzb24gPSBKU09OLnBhcnNlKHJldHMyW3Jlc3VsdHNfbGlzdFtrXS5kZXRhaWxVcmxDb3VudF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coJ+S6jOe6p+aVsOaNruWIl+ihqOWFg+e0oOaVsDonICsgZGV0YWlsSnNvbi5saXN0Lmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdF9kYXRhLmZvckVhY2goKGQsIF9zZXEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxldCBkZXRhaWxWb2RQaWMgPSBkZXRhaWxKc29uLmxpc3RbX3NlcV0udm9kX3BpYzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvZyhkZXRhaWxKc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkZXRhaWxWb2RQaWMgPSBkZXRhaWxKc29uLmxpc3QuZmluZCh2b2QgPT4gdm9kLnZvZF9pZC50b1N0cmluZygpID09PSBkLnZvZF9pZC5zcGxpdCgnJCcpWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZXRhaWxWb2RQaWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKGQsIHt2b2RfcGljOiBkZXRhaWxWb2RQaWMudm9kX3BpY30pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhg5by65Yi26I635Y+W572R56uZJHtyZXN1bHRfZGF0YVswXS5zaXRlX25hbWV955qE5pCc57Si5Zu+54mH5aSx6LSlOiR7ZS5tZXNzYWdlfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHMgPSByZXN1bHRzLmNvbmNhdChyZXN1bHRfZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgdXJscy5mb3JFYWNoKChfdXJsLCBpZHgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpdCA9IHNlYXJjaF9jbGFzc2VzW2lkeF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChfdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoaHRtbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSBqc29uLmxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5mb3JFYWNoKGkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpLnZvZF9pZCA9IGl0LnR5cGVfaWQgKyAnJCcgKyBpLnZvZF9pZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaS52b2RfcmVtYXJrcyA9IGkudm9kX3JlbWFya3MgKyAnfCcgKyBpdC50eXBlX25hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJ1bGUuc2VhcmNoX21hdGNoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBkYXRhLmZpbHRlcihpdGVtID0+IGl0ZW0udm9kX25hbWUgJiYgKG5ldyBSZWdFeHAoS0VZLCAnaScpKS50ZXN0KGl0ZW0udm9kX25hbWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChydWxlLnNlYXJjaF9waWMgJiYgIWRhdGFbMF0udm9kX3BpYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKGDlvZPliY3mkJzntKLnq5nngrnjgJAke2l0LnR5cGVfbmFtZX3jgJHmsqHlm77niYcs5bCd6K+V6K6/6Zeu5LqM57qn5Y676I635Y+W5Zu+54mHYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGV0YWlsVXJsID0gdXJsc1tpZHhdLnNwbGl0KCd3ZD0nKVswXSArICdhYz1kZXRhaWwmaWRzPScgKyBkYXRhLm1hcChrID0+IGsudm9kX2lkLnNwbGl0KCckJylbMV0pLmpvaW4oJywnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRldGFpbEpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QoZGV0YWlsVXJsKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCfkuoznuqfmlbDmja7liJfooajlhYPntKDmlbA6JyArIGRldGFpbEpzb24ubGlzdC5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEuZm9yRWFjaCgoZCwgX3NlcSkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBsZXQgZGV0YWlsVm9kUGljID0gZGV0YWlsSnNvbi5saXN0W19zZXFdLnZvZF9waWM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkZXRhaWxWb2RQaWMgPSBkZXRhaWxKc29uLmxpc3QuZmluZCh2b2QgPT4gdm9kLnZvZF9pZC50b1N0cmluZygpID09PSBkLnZvZF9pZC5zcGxpdCgnJCcpWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRldGFpbFZvZFBpYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihkLCB7dm9kX3BpYzogZGV0YWlsVm9kUGljLnZvZF9waWN9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhg5by65Yi26I635Y+W572R56uZJHtpdC50eXBlX2lkfeeahOaQnOe0ouWbvueJh+Wksei0pToke2UubWVzc2FnZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzID0gcmVzdWx0cy5jb25jYXQoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHMgPSByZXN1bHRzLmNvbmNhdChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2coYOivt+axgjoke2l0LnR5cGVfaWR95Y+R55Sf6ZSZ6K+vOiR7ZS5tZXNzYWdlfWApCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgVk9EUyA9IHJlc3VsdHM7CiAgICAgICAgICAgICAgICAgICAgbGV0IHQyID0gbmV3IERhdGUoKS5nZXRUaW1lKCk7CiAgICAgICAgICAgICAgICAgICAgLy8gbG9nKCd0MjonK3QyKTsKICAgICAgICAgICAgICAgICAgICBsb2coYCR7c2VhcmNoTW9kZX3mkJzntKI6JHt1cmxzLmxlbmd0aH3kuKrnq5nogJfml7Y6JHsoTnVtYmVyKHQyKSAtIE51bWJlcih0MSkpfW1zYCkKCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9KSwKICAgIGxhenk6ICRqcy50b1N0cmluZygoKSA9PiB7CiAgICAgICAgLy8gbGF6eeaDs+WKnuazleeUqOWvueW6lOeahHBhcnNlX3VybO+8jOS9huaYr+aciemavuW6pu+8jOaaguacquWunueOsAogICAgICAgIGxldCBwYXJzZV91cmwgPSAnJzsKICAgICAgICBpZiAoZmxhZyAmJiBmbGFnLmluY2x1ZGVzKCd8JykpIHsKICAgICAgICAgICAgbGV0IHR5cGVfbmFtZSA9IGZsYWcuc3BsaXQoJ3wnKVswXTsKICAgICAgICAgICAgbGV0IGN1cnJlbnRfdm9kID0gcnVsZS5jbGFzc2VzLmZpbmQoaXRlbSA9PiBpdGVtLnR5cGVfbmFtZSA9PT0gdHlwZV9uYW1lKTsKICAgICAgICAgICAgaWYgKGN1cnJlbnRfdm9kICYmIGN1cnJlbnRfdm9kLnBhcnNlX3VybCkgewogICAgICAgICAgICAgICAgcGFyc2VfdXJsID0gY3VycmVudF92b2QucGFyc2VfdXJsCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKC9cLihtM3U4fG1wNCkvLnRlc3QoaW5wdXQpKSB7CiAgICAgICAgICAgIGlucHV0ID0ge3BhcnNlOiAwLCB1cmw6IGlucHV0fQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGlmIChwYXJzZV91cmwuc3RhcnRzV2l0aCgnanNvbjonKSkgewogICAgICAgICAgICAgICAgbGV0IHB1cmwgPSBwYXJzZV91cmwucmVwbGFjZSgnanNvbjonLCAnJykgKyBpbnB1dDsKICAgICAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChwdXJsKTsKICAgICAgICAgICAgICAgIGlucHV0ID0ge3BhcnNlOiAwLCB1cmw6IEpTT04ucGFyc2UoaHRtbCkudXJsfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgaW5wdXQgPSBwYXJzZV91cmwgKyBpbnB1dDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0pLAp9 |