Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@云盘君.简@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IuS6keebmOWQmy7nroAiLCJhdXRob3IiOiLlsI/mo4noooTwn4yeJkBMb3lEZ0lrIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6MTY5LCJjb2xfdHlwZSI6Im1vdmllXzMiLCJjbGFzc19uYW1lIjoiIiwidHlwZSI6ImFsbCIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1haW5cIik7Iiwic2VhcmNoX3VybCI6Imhpa2VyOi8vZW1wdHk/c2VhcmNoVGVybXM9KioiLCJncm91cCI6IuKRoOe9keebmCIsInNlYXJjaEZpbmQiOiJqczpcbmxldCBpc2REZWxlZ2F0ZSA9ICEhZ2V0SXRlbShcImlzZERlbGVnYXRlXCIsIFwiXCIpO1xuaWYgKGlzZERlbGVnYXRlKSB7XG4gICAgc2V0UmVzdWx0KFt7XG4gICAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgICAgdXJsOiBcImhpa2VyOi8vc2VhcmNoP3M9XCIgKyBNWV9LRVlXT1JELFxuICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgZGVsZWdhdGVPbmx5U2VhcmNoOiB0cnVlLFxuICAgICAgICAgICAgcnVsZXM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlR3JvdXAgPSBnZXRJdGVtKFwicnVsZUdyb3VwXCIsIFwiXCIpO1xuICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9ICQucmVxdWlyZShcImRhdGFcIikuZ2V0QWxsRGF0YShydWxlR3JvdXApO1xuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgZGF0YSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKHJ1bGUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UmVzdWx0KCQucmVxdWlyZShcImRhdGFcIikuY2FycnlTUnVsZShydWxlLCBNWV9LRVlXT1JELCBNWV9QQUdFLCBnZXRTZWFyY2hNb2RlKCkpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBpdClcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShydWxlcyk7XG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KVxuICAgICAgICB9XG4gICAgfV0pO1xufSBlbHNlIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5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MV92ZXJ0aWNhbF9waWNcXFwiIDogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe1xcbiAgICAgICAgICAgICAgICBpbmhlcml0VGl0bGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZVxcbiAgICAgICAgICAgIH0sIGl0LmV4dHJhKVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgcmV0dXJuIHJlc0xpc3Q7XFxufVxcbiQuZXhwb3J0cy5jYXJyeVNSdWxlID0gZnVuY3Rpb24ocnVsZSwgcywgcGFnZSwgc2VhcmNoTW9kZSkge1xcbiAgICBydWxlID0gZ2V0Q29tcGxldGVSdWxlKHJ1bGUpO1xcbiAgICBsZXQgbGlzdCA9IHJ1bGUuZmluZChzLCBwYWdlKTtcXG4gICAgaWYgKCFsaXN0KSByZXR1cm4gW107XFxuICAgIGxldCByZXNMaXN0ID0gW107XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIGlmIChpdC5za2lwKSB7XFxuICAgICAgICAgICAgcmVzTGlzdC5wdXNoKGl0KTtcXG4gICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChzZWFyY2hNb2RlICYmICFzZWFyY2hDb250YWlucyhpdC50aXRsZSwgcywgdHJ1ZSkpIGNvbnRpbnVlO1xcbiAgICAgICAgaWYgKHJ1bGUuZmluZEFsaVVybCkge1xcbiAgICAgICAgICAgIGl0LnVybCA9ICQoaXQudXJsKS5sYXp5UnVsZSh0b1JlZGlyZWN0VHJlYXRpbmcsIHtcXG4gICAgICAgICAgICAgICAgZmluZEFsaVVybDogcnVsZS5maW5kQWxpVXJsLFxcbiAgICAgICAgICAgICAgICBiYXNpY1VybDogcnVsZS5iYXNpY1VybCxcXG4gICAgICAgICAgICAgICAgbmFtZTogcnVsZS5uYW1lLFxcbiAgICAgICAgICAgICAgICBhdXRob3I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xldCBjbGlwYm9hcmQgPSBjb250ZXh0LmdldFN5c3RlbVNlcnZpY2UoQ29udGV4dC5DTElQQk9BUkRfU0VSVklDRSk7XFxuICAgICAgICAgICAgLy8g6L+U5Zue5pWw5o2uXFxuICAgICAgICAgICAgbGV0IGNsaXBEYXRhID0gY2xpcGJvYXJkLmdldFByaW1hcnlDbGlwKCk7XFxuICAgICAgICAgICAgaWYgKGNsaXBEYXRhICE9IG51bGwgJiYgY2xpcERhdGEuZ2V0SXRlbUNvdW50KCkgPiAwKSB7XFxuICAgICAgICAgICAgICAgIC8vIOS7juaVsOaNrumbhuS4reiOt+WPlu+8iOeymOi0tO+8ieesrOS4gOadoeaWh+acrOaVsOaNrlxcbiAgICAgICAgICAgICAgICBsZXQgdGV4dCA9IGNsaXBEYXRhLmdldEl0ZW1BdCgwKS5nZXRUZXh0KCk7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0ICE9IG51bGwpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcodGV4dC50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgdGV4dCA9IGdldENvcHkoKSB8fCBcXFwiXFxcIjtcXG4gICAgbGV0IHVybCA9IGFsaXRlc3QubWF0Y2hBbGlVcmwodGV4dCk7XFxuICAgIGlmICh1cmwpIHtcXG4gICAgICAgIGxldCBjYWNoZSA9IGdldEl0ZW0oXFxcImNsaXBib2FyZENhY2hlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKHVybCAhPT0gY2FjaGUpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnTxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPua4qemmqOaPkOekujxiPicsXFxuICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLmo4DmtYvliLDliarotLTmnb/lkKvmnInpmL/ph4zpk77mjqXmmK/lkKbmiZPlvIA/XFxcXG5cXFwiICsgdXJsLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlucHV0LCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShpZCArIFxcXCJjbGlwYm9hcmRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1bj9wYWdlPWZ5cGFnZSZyZWFsdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpICsgXFxcIiZzaGFyZVB3ZD1cXFwiO1xcbiAgICAgICAgICAgICAgICB9LCB1cmwsIGlkKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGlkICsgXFxcImNsaXBib2FyZFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IFxcXCLmiZPlvIDpk77mjqVcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJjbGlwYm9hcmRDYWNoZVxcXCIsIHVybCk7XFxuICAgICAgICB9XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0UHJlcG9zZSgpIHtcXG4gICAgaWYgKG9wZW5Nb2RlID09IFxcXCLmnKzlnLDop6PmnpBcXFwiKSB7XFxuICAgICAgICBsZXQgYWxpVG9rZW5zRmlsZXBhdGggPSAkLnJlcXVpcmUoXFxcImhpa2VyOi8vcGFnZS90b2tlblBhdGhcXFwiKS5hbGlUb2tlbnNGaWxlcGF0aDtcXG4gICAgICAgIGxldCBhID0gZmV0Y2goYWxpVG9rZW5zRmlsZXBhdGgpO1xcbiAgICAgICAgaWYgKCFhIHx8IGEgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJzxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPua4qemmqOaPkOekujxiPicsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwicmljaF90ZXh0XFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4gJC5yZXF1aXJlKFxcXCJsb2dpbk1vZGVcXFwiKSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmnKrmo4DmtYvliLDnmbvlvZXkv6Hmga/vvIzngrnmiJHot7PovaznmbvlvZXotKblj7fpobXpnaLvvIznmbvlvZXpmL/ph4zkupHnm5jotKblj7flkI7mlrnlj6/kvb/nlKjmnKzlnLDop6PmnpDmqKHlvI9cXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBcXFwi55m75b2V6Zi/6YeM5LqR55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgYWRkTGlzdGVuZXIoXFxcIm9uQ2xvc2VcXFwiLCAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGNsZWFyTXlWYXIoXFxcInNcXFwiKTtcXG4gICAg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0b2FzdDovL+i/mOacqueZu+mZhlxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCBhbGkgPSByZXF1ZXN0KGFsaVRva2Vuc0ZpbGVwYXRoKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaSA9IEpTT04ucGFyc2UoYWxpKTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlRmlsZShhbGlUb2tlbnNGaWxlcGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6I635Y+W5aSx6LSlXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiAn55m75b2V5L+h5oGvJyxcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLnlKjmiLc6XFxcIiArIChhbGkubmlja19uYW1lIHx8IGFsaS51c2VyX25hbWUgfHwgXFxcIlRva2Vu55m75b2VXFxcIikgKyBcXFwiXFxcXG5Ub2tlbjpcXFwiICsgYWxpLnJlZnJlc2hfdG9rZW4gKyBcXFwiXFxcXG4o5Y+W5raI77ya5rOo6ZSA55m75b2V77yb56Gu5a6a77ya5aSN5Yi2VG9rZW4pXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNvbmZpcm06ICQudG9TdHJpbmcoKHRva2VuKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIHRva2VuO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYWxpLnJlZnJlc2hfdG9rZW4pLFxcbiAgICAgICAgICAgICAgICAgICAgY2FuY2VsOiAkLnRvU3RyaW5nKChwYXRoMSwgcGF0aDIpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5rOo6ZSA55m75b2VXFxcIikuY29uZmlybSgocGF0aDEsIHBhdGgyKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUZpbGUocGF0aDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVGaWxlKHBhdGgyKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suaIkOWKn+mAgOWHuueZu+mZhlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgcGF0aDEsIHBhdGgyKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGFsaVRva2Vuc0ZpbGVwYXRoLCBvcGVuVG9rZW5zRmlsZXBhdGgpXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlucHV0ID0gaW5wdXQucmVwbGFjZShcXFwi5qih5byP77yaXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcIm9wZW5Nb2RlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaWRzLCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K6+572ufFxcXCIgKyBpbnB1dFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6Y5pa5QVBQXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS55oiQ5Yqf77yM6K+356Gu5L+d5omL5py65pyJ5a6J6KOF6Zi/6YeM5LqR55uY562J5a6Y5pa5QVBQXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9LCBpZCArIFxcXCJtb2RlXFxcIiksXFxuICAgICAgICBjb2xfdHlwZTogXFxcImljb25fM19yb3VuZF9maWxsXFxcIixcXG4gICAgICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX21lbnU2XFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IGlkICsgXFxcIm1vZGVcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6ICfmkJzntKInLFxcbiAgICAgICAgZGVzYzogJ+ivt+i+k+WFpeWFs+mUruivjS/pk77mjqUnLFxcbiAgICAgICAgY29sX3R5cGU6ICdpbnB1dCcsXFxuICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgIGlmICgkLnJlcXVpcmUoXFxcImFsaXRlc3RcXFwiKS50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJzXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2FsaXl1bj9wYWdlPWZ5cGFnZSZyZWFsdXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpICsgXFxcIiZzaGFyZVB3ZD1cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwic1xcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9KSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgb25DaGFuZ2U6IFxcXCJwdXRNeVZhcigncmVmcycsaW5wdXQpXFxcIixcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwic3NcXFwiLFxcbiAgICAg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5oup5YiG57uEXFxcIiwgaW5kZXgpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGlmICghTVlfSU5ERVgpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInJ1bGVHcm91cFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInJ1bGVHcm91cFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIlxcbiAgICB9LCB7XFxuICAgICAgICB0aXRsZTogXFxcIlxcXCIgPT0gciA/IFxcXCLigJzigJzlhajpg6jigJ3igJ1cXFwiIDogXFxcIuWFqOmDqFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHMsIGlkKSA9PiB7XFxuICAgICAgICAgICAgbGV0IHFyID0gZ2V0SXRlbShcXFwicnVsZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVcXFwiKTtcXG4gICAgICAgICAgICBpZiAocykge1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcIuWFqOmDqFxcXCIgKyBpZCwge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzlhajpg6jigJ3igJ1cXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBpZiAocXIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaWQgKyBxciwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBxclxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIHMsIGlkKSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFwi5YWo6YOoXFxcIiArIGlkXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBmb3IgKGxldCBbaXQsIGJhc2ljVXJsXSBvZiBydWxlcykge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogaXQgPT0gciA/IFxcXCLigJzigJxcXFwiICsgaXQgKyBcXFwi4oCd4oCdXFxcIiA6IGl0LFxcbiAgICAgICAgICAgIHVybDogJCgoZ2V0SG9tZShiYXNpY1VybCkgfHwgXFxcIlxcXCIpICsgXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHIsIHMsIGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBxciA9IGdldEl0ZW0oXFxcInJ1bGVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInJ1bGVcXFwiLCByKTtcXG4gICAgICAgICAgICAgICAgaWYgKHMpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKHFyID8gKGlkICsgcXIpIDogKFxcXCLlhajpg6hcXFwiICsgaWQpLCB7XFxuICAgICAgICAgICAgIC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V0IHAgPSBNWV9QQUdFO1xcbiAgICBsZXQgZGF0YSA9ICQucmVxdWlyZShcXFwiZGF0YVxcXCIpLmdldERhdGEocCwgciwgcnVsZUdyb3VwKTtcXG4gICAgbGV0IHBhZ2VpZCA9IGlkICsgXFxcInlwai1wYWdlXFxcIiArIHA7XFxuICAgIGlmIChkYXRhLmxlbmd0aCA+IDApIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLliqDovb3nrKxcXFwiICsgcCArIFxcXCLpobXkuK3vvIzov5vluqbvvJoxL1xcXCIgKyBkYXRhLmxlbmd0aCxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGlkOiBwYWdlaWRcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIGlmIChkYXRhLmxlbmd0aCA+IDApIHtcXG4gICAgICAgIC8v5aSa57q/56iL5Yqg6L29ICAgICAgICBcXG4gICAgICAgIGxldCByZWFsUGFnZSA9IFxcXCJcXFwiID09IHIgPyAxIDogcDtcXG4gICAgICAgIGxldCB0YXNrcyA9IGRhdGEubWFwKGl0ID0+IHtcXG4gICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICBmdW5jOiBmdW5jdGlvbihydWxlKSB7XFxuICAgICAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcImRhdGFcXFwiKS5jYXJyeVJ1bGUocnVsZSwgcywgcmVhbFBhZ2UsIHNlYXJjaE1vZGUpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhydWxlLm5hbWUgKyBcXFwiOlxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8qaWYoZGF0YS5sZW5ndGg9PT0xJiZwPT09MSl7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6XFxcIuKAnOKAnFxcXCIrcnVsZS5uYW1lK1xcXCIgRVJST1LigJ3igJ1cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZS50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6XFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOlxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOntcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfV07XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAvL3JldHVybiBydWxlLmZpbmQocywgcmVhbFBhZ2UpO1xcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBwYXJhbTogaXQsXFxuICAgICAgICAgICAgICAgIGlkOiBcXFwicnVsZUBcXFwiICsgaXQubmFtZVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcblxcbiAgICAgICAgYmF0Y2hFeGVjdXRlKHRhc2tzLCB7XFxuICAgICAgICAgICAgZnVuYzogZnVuY3Rpb24ocGFyYW0sIGlkLCBlcnJvciwgcmVzdWx0KSB7XFxuICAgICAgICAgICAgICAgIHBhcmFtLmkgKz0gMTtcXG4gICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkocmVzdWx0KSkge1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShcXFwiX25vdGhhdmVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1CZWZvcmUocGFnZWlkLCByZXN1bHQpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChwYXJhbS5pID09PSBwYXJhbS5hbGwpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghcmVzdWx0IHx8ICFyZXN1bHQubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShcXFwiX25vdGhhdmVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQmVmb3JlKHBhZ2VpZCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOi1hOa6kOmDveayoeacieWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogXFxcIl9ub3RoYXZlXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKHBhZ2VpZCk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKHBhZ2VpZCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yqg6L2956ysXFxcIiArIE1ZX1BBR0UgKyBcXFwi6aG15Lit77yM6L+b5bqm77yaXFxcIiArIChwYXJhbS5pICsgMSkgKyBcXFwiL1xcXCIgKyBwYXJhbS5hbGwsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHBhcmFtOiB7XFxuICAgICAgICAgICAgICAgIGFsbDogZGF0YS5sZW5ndGgsXFxuICAgICAgICAgICAgICAgIGk6IDAsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBzZXRIaXN0b3J5KCkge1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6ICc8c3BhbiBzdHlsZT1cXFwiY29sb3I6I2ZmNjYwMVxcXCI+PGI+5Y6G5Y+y6K6w5b2VPC9iPjwvc3Bhbj4nLFxcbiAgICAgICAgcGljX3VybDogXFxcImhpa2VyOi8vaW1hZ2VzL2ljb25fY2xvY2tcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJhdmF0YXJcXFwiLFxcbiAgICAgICAgdXJsOiAkKFtcXFwi5riF6Zmk5pCc57Si6K6w5b2VXFxcIiwgXFxcIuaJk+W8gOingueci+iusOW9lVxcXCJdKS5zZWxlY3QoKGlkKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi5riF6Zmk5pCc57Si6K6w5b2VXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu5a6a5riF6Zmk5YWo6YOo5pCc57Si6K6w5b2V77yfXFxcIikuY29uZmlybSgoaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKGlkICsgXFxcIjprZXlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihpZCArIFxcXCI6c2VhcmNoSGlzdG9yeVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInlk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsczogaWQgKyBcXFwiOmtleVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9LCBpZCk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2hpc3Rvcnk/cnVsZT1cXFwiICsgTVlfUlVMRS50aXRsZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9LCBpZCksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBpZCArIFxcXCI6c2VhcmNoSGlzdG9yeVxcXCIsXFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBsZXQgaGlzdG9yeSA9IHN0b3JhZ2UwLmdldEl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiLCBbXSk7XFxuICAgIGxldCBpID0gMDtcXG4gICAgZm9yIChsZXQga2V5IG9mIGhpc3RvcnkpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IGtleSxcXG4gICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkLCBrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGV4dHJhID0gZmluZEl0ZW0oaWQgKyBcXFwic3NcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICAgICAgZXh0cmEuZGVmYXVsdFZhbHVlID0ga2V5O1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKHtcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiBleHRyYVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBpZCwga2V5KSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImZsZXhfYnV0dG9uXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBpZDogaWQgKyBcXFwiOmtleTpcXFwiICsga2V5LFxcbiAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpOWFs+mUruivjTpcXFwiICsga2V5LFxcbiAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGlkLCBrZXksIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgaGlzdG9yeSA9IHN0b3JhZ2UwLmdldEl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiLCBbXSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGlzdG9yeS5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIsIGhpc3RvcnkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oaWQgKyBcXFwiOmtleTpcXFwiICsga2V5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KCk7XFxuICAgICAgICAgICAgICAgICAgICB9LCBpZCwga2V5LCBpKVxcbiAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICAgICAgaSsrO1xcbiAgICB9XFxuICAgIGlmIChoaXN0b3J5Lmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInlk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGNsczogaWQgKyBcXFwiOmtleVxcXCIsXFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9XFxufVxcblxcbmZ1bmN0aW9uIHNldFRy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gICAgICAgdXJsOiAkKGhvdGtleXMsIDEsIFxcXCLliIfmjaLng63mkJxcXFwiKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcImhvdGtleVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNouS4ulxcXCIgKyBpbnB1dDtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJhdmF0YXJcXFwiLFxcbiAgICAgICAgcGljX3VybDogXFxcImhpa2VyOi8vaW1hZ2VzL2ljb25fZmlyZVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliIfmjaLmlbDmja7mupBcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoZGF0YVNvdXJjZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoZGF0YVNvdXJjZSwgMSwgXFxcIuWIh+aNouaVsOaNrua6kFxcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiZGF0YVNvdXJjZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcImhvdGtleVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5YiH5o2i5Li6XFxcIiArIGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0sIGRhdGFTb3VyY2UpXFxuICAgICAgICAgICAgfV1cXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuato+WcqOWKoOi9vS4uLlxcXCIsXFxuICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBpZCArIFxcXCI6aG90a2V5XFxcIixcXG4gICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIHNldFJlc3VsdChkKTtcXG4gICAgbGV0IHNkID0gW107XFxuICAgIGxldCBzZXRTZWFyY2hLZXkgPSBuYW1lID0+IHtcXG4gICAgICAgIHB1dE15VmFyKCdzJywgbmFtZSk7XFxuICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgcmV0dXJuICdoaWtlcjovL2VtcHR5J1xcbiAgICB9O1xcblxcbiAgICBsZXQgZ2V0VGl0bGUgPSAoaSwgbmFtZSkgPT4ge1xcbiAgICAgICAgbGV0IGNvbG9yO1xcbiAgICAgICAgc3dpdGNoIChpKSB7XFxuICAgICAgICAgICAgY2FzZSAwOlxcbiAgICAgICAgICAgICAgICBjb2xvciA9IFxcXCIjZmYzMzAwXFxcIjtcXG4gICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgY2FzZSAxOlxcbiAgICAgICAgICAgICAgICBjb2xvciA9IFxcXCIjZmY2NjAwXFxcIjtcXG4gICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgY2FzZSAyOlxcbiAgICAgICAgICAgICAgICBjb2xvciA9IFxcXCIjZmY5OTAwXFxcIlxcbiAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICBkZWZhdWx0OlxcbiAgICAgICAgICAgICAgICBjb2xvciA9IFxcXCJibGFja1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICByZX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cXG4gICAgICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3RvcC5iYWlkdS5jb20vYm9hcmQ/dGFiPW5vdmVsJyxcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIC8vdmFyIHMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICB2YXIgbGlzdCA9IEpTT04ucGFyc2UoanNvbikuZGF0YS5jYXJkc1swXS5jb250ZW50O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpdGVtID0gbGlzdFtpXTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuYW1lID0gaXRlbS53b3JkICsgJyAoJyArIGl0ZW0uc2hvd1syXSArICcpJztcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkZXMgPSBpdGVtLmRlc2M7XFxuICAgICAgICAgICAgICAgICAgICBzZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZ2V0VGl0bGUoaSwgbmFtZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKHNldFNlYXJjaEtleSwgaXRlbS53b3JkKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBkZXMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaW1nOiBpdGVtLmltZyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcIm1vdmllXzFfdmVydGljYWxfcGljXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgY2FzZSBcXFwi5aS45YWLXFxcIjpcXG4gICAgICAgICAgICAgICAgdmFyIGpz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ICAgICAgICAgICAgXFxcIlxcXFxu6K+E5YiG77yaXFxcIiArIHBkZmgoaXRlbSwgXFxcInNjb3JlX2F2ZyYmVGV4dFxcXCIpLnJlcGxhY2UoL14wJC8sIFxcXCLmmoLml6Dor4TliIZcXFwiKSArXFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIlxcXFxuXFxcIiArIHBkZmgoaXRlbSwgXFxcInllYXImJlRleHRcXFwiKSArIFxcXCLCt1xcXCIgKyBwZGZoKGl0ZW0sIFxcXCJoX2FyZWEmJlRleHRcXFwiKSArIFxcXCLCt1xcXCIgKyBwZGZoKGl0ZW0sIFxcXCJjYXRlZ29yeSYmVGV4dFxcXCIpLnJlcGxhY2UoXFxcIixcXFwiLCBcXFwiwrdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHNkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBnZXRUaXRsZShpLCBuYW1lKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoc2V0U2VhcmNoS2V5LCBuYW1lKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBkZXMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaW1nOiBwZGZoKGl0ZW0sIFxcXCJoX3NyYyYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibW92aWVfMV92ZXJ0aWNhbF9waWNcXFwiXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgIH1cXG4gICAgICAgIGFkZEl0ZW1BZnRlcihpZCArIFxcXCI6aG90a2V5XFxcIiwgc2QpO1xcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgfSBmaW5hbGx5IHtcXG4gICAgICAg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FxuICAgICAgICBjb25zdCBsYXN0dGltZSA9IHBhcnNlSW50KGV4cGlyZXMpIC0gRGF0ZS5ub3coKSAvIDEwMDA7XFxuICAgICAgICBpZiAobGFzdHRpbWUgPCA2MCkge1xcbiAgICAgICAgICAgIC8vbG9nKCfov4fmnJ/mm7TmlrAnKVxcbiAgICAgICAgICAgIGxldCBsaW5lID0gdXJsLnNwbGl0KCcvbWVkaWEnKVswXTsgLy/lj5bkuYvliY3mkq3mlL7nmoR0c+autee6v+i3r1xcbiAgICAgICAgICAgIGxpbmUgPSBsaW5lLnN1YnN0cmluZyhsaW5lLmxhc3RJbmRleE9mKCcvJykgKyAxKTtcXG4gICAgICAgICAgICBsZXQgZiA9IGdldE0zdThDb250ZW50KGdldEFsaVBsYXlVcmwoZmlkLCBsaW5lKSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgZi5mb3JFYWNoKGl0ID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKGl0ICYmIGl0LnN0YXJ0c1dpdGgoJy9wcm94eT91cmw9JykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gdXJsO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgdXJsID0gYmFz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AgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhcXFwiI1xcXCIgKyBwbGF5TW9kZSArIFxcXCLmkq3mlL7lpLHotKUjXFxcXG7plJnor6/kv6Hmga8+XFxcIiArIGUudG9TdHJpbmcoKSArIFxcXCJcXFxcbumUmeivr+ihjD5cXFwiICsgZS5saW5lTnVtYmVyKTtcXG4gICAgICAgICAgICBpZiAoZS5jb2RlID09PSBcXFwiSW52YWxpZFBhcmFtZXRlci5SZWZyZXNoVG9rZW5cXFwiKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLnmbvpmYbov4fmnJ/vvIzor7fph43mlrDnmbvpmYZcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvbG9naW4jbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjP25vUmVmcmVzaD0xXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGUuY29kZSA9PT0gXFxcIlF1b3RhRXhoYXVzdGVkLkRyaXZlXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v572R55uY56m66Ze05LiN6Laz77yM5peg5rOV5pKt5pS+6K+35riF55CG44CCXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aSreaUvuWksei0pe+8jOmUmeivr+S/oeaBr+W3suaJk+WNsOOAglxcXFxu6K+35p+l55yL5pel5b+XKExPRylcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IG1vdW50c3ViID0gc3RvcmFnZTAuZ2V0TXlWYXIoJ21vdW50emltdScsIHt9KTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyhtb3VudHN1YikubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIHppbXUgPSBtb3VudHN1YjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBzdWJ0aXRsZTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyh6aW11IHx8IHt9KS5sZW5ndGggPiAwICYmIHBsYXlMaXN0ICYmIHBsYXlMaXN0LnVybHMgJiYgcGxheUxpc3QudXJscy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCgxMDApO1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHZhciB6bXVybCA9IGFsaUFjY2Vzc0FwaS5nZXRWaWRlb1RlbVBsYXlVcmwoemltdS5maWxlX2lkKTtcXG4gICAgICAgICAgICAgICAgbGV0IHBhdGggPSAnaGlrZXI6Ly9maWxlcy9jYWNoZS/kupHnm5jlkJsvc3ViLicgKyB6aW11LmV4dDtcXG4gICAgICAgICAgICAgICAgZG93bmxvYWRGaWxlKHptdXJsLCBwYXRoLCB7XFxuICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgc3VidGl0bGUgPSBnZXRQYXRoKHBhdGgpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuWtl+W5leWKoOi9veWksei0pVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsb2coZS5tZXNzYWdlKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZG1saXN0ID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImRtbGlzdFxcXCIsIFtdKTtcXG4gICAgICAgIGxldCBkbWxpc3RfY2FjaGUgPSBnZXRNeVZhcihcXFwiZG1saXN0X2NhY2hlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKGRtbGlzdF9jYWNoZSAmJiBkbWxpc3RfY2FjaGUuc3RhcnRzV2l0aChmaWxlS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ICAgICAgICAgICAgIHNldFBhZ2VUaXRsZShzaGFyZUluZm8uc2hhcmVfbmFtZSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBkZWFkbGluZSA9IFxcXCLmsLjkuYXmnInmlYhcXFwiO1xcblxcbiAgICAgICAgICAgIGlmIChzaGFyZUluZm8uZXhwaXJhdGlvbikge1xcbiAgICAgICAgICAgICAgICBkZWFkbGluZSA9IFxcXCLmnInmlYjoh7PvvJpcXFwiICsgZm9ybWF0RGF0ZShzaGFyZUluZm8uZXhwaXJhdGlvbik7XFxuICAgICAgICAgICAgICAgIC8vc2hhcmVJbmZvLnVwZGF0ZWRfYXRcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAoc2hhcmVJbmZvLmNyZWF0b3JfbmFtZSB8fCBzaGFyZUluZm8uY3JlYXRvcl9waG9uZSkgKyBcXFwiJm5ic3A7Jm5ic3A7XFxcIiArIGRlYWRsaW5lLnNtYWxsKCksXFxuICAgICAgICAgICAgICAgIHVybDogcmVhbHVybCArIFxcXCIjbm9IaXN0b3J5I1xcXCIsXFxuICAgICAgICAgICAgICAgIGltZzogc2hhcmVJbmZvLmF2YXRhciB8fCBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl91bmtub3duXFxcIixcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJhdmF0YXJcXFwiXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoIWlzU2VhcmNoKSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pCc57SiXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeWFs+mUruivjVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9hbGl5dW4jbm9IaXN0b3J5IyNmdWxsVGhlbWUjP3BhZ2U9ZnlwYWdlJnNlYXJjaEtleT1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgb25DaGFuZ2U6IFxcXCJwdXRNeVZhcignbGlzdFNlYXJjaEtleScsaW5wdXQpXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSWQ6IHNoYXJlSWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBzaGFyZVRva2VuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIHNlYXJjaEtleSArIFxcXCLigJ3igJ3nmoTmkJzntKLnu5PmnpxcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZnVuY0l0ZW1zID0gW107XFxuICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IHN0eWxlLFxcbiAgICAgICAgICAgIHVybDogJChzdHlsZXMsIDEsIFxcXCLmjpLluIPmoLflvI9cXFwiKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fc3R5bGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliIfmjaJcXFwiO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9pY29uLnN2Z1xcXCJcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogb3JkZXJOYW1lLFxcbiAgICAgICAgICAgIHVybDogJChvcmRlcnNLZXlzLCAyLCBcXFwi5o6S5bqP5pa55byPXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiYWxpeXVuX29yZGVyXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBwaWNfdXJsOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL2ltZy9hbGlfc29ydC5zdmdcXFwiXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IHBsYXlNb2RlLFxcbiAgICAgICAgICAgIHVybDogJChbXFxcIui9rOeggVxcXCIsIFxcXCLljp/nlLtcXFwiLCBcXFwi5Y6f6L2sXFxc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ey5YiH5o2i5Li6XFxcIiArIGlucHV0O1xcbiAgICAgICAgICAgICAgICB9LCBvcGVuQVBJTGlzdCksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9hcGkuc3ZnXFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghaXNTZWFyY2gpIHtcXG4gICAgICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yqf6IO9XFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFtcXFwi6L2s5a2Y5LqR55uYXFxcIiwgXFxcIueZu+mZhui0puWPt1xcXCIsIFxcXCLlpI3liLbliIbkuqvpk77mjqVcXFwiLCBcXFwi5p+l55yL5omL5Yqo5oyC6L295a2X5bmVXFxcIiwgXFxcIuiOt+WPluW8ueW5leaQnOe0ouinhOWImVxcXCIsIFxcXCLmibnph4/mjILovb3mnKzlnLDlvLnluZVcXFwiLCBcXFwi5o6o6YCB5YiwVFZCb3hcXFwiLCBcXFwi6K6+572u5pS26JeP5bCB6Z2iXFxcIiwgXFxcIuiOt+WPluaKleWxj0lQXFxcIiAvKiwgXFxcIuaegemAn+WOn+eUu+S4i+i9vee6v+eoi1xcXCIqLyAsIFxcXCLovazlrZjlvZPliY3mlofku7blpLlcXFwiXSwgMiwgXFxcIuabtOWkmuWKn+iDvVxcXCIpLnNlbGVjdCgoc2hhcmVJZCwgc2hhcmVQd2QsIGZpbGVJZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChpbnB1dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIui9rOWtmOS6keebmFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgc21hcnRkcml2ZTovL3NoYXJlL2Jyb3dzZT9zaGFyZUlkPSR7c2hhcmVJZH0mc2hhcmVQd2Q9JHtzaGFyZVB3ZHx8XFxcIlxcXCJ9YDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLnmbvpmYbotKblj7dcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9sb2dpbiNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuWkjeWItuWIhuS6q+mTvuaOpVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi5aSN5Yi26ZO+5o6lXFxcIiwgXFxcIuWkjeWItua1t+mYlOWPo+S7pFxcXCJdLCAxLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KCh1cmwpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIuWkjeWItumTvuaOpVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgdXJsO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly/pmL/ph4zkupHnm5jliIbkuqvlj6Pku6TjgIxcXFwiICsgZ2V0UGFnZVRpdGxlKCkgKyBcXFwi44CNXFxcXG5cXFwiICsgdXJsICsgXFxcIiBAaW1wb3J0PWpzOmBoaWtlcjovL3BhZ2UvYWxpeXVuP3JlYWx1cmw9JHtpbnB1dC50cmltKCl9JnJ1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiYDtcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXFxcIiArIHNoYXJlSWQgKyAoZmlsZUlkID8gXFxcIi9mb2xkZXIvXFxcIiArIGZpbGVJZCA6IFxcXCJcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5om56YeP5oyC6L295pys5Zyw5by55bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZG1Nb3VudCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuafpeeci+aJi+WKqOaMgui9veWtl+W5lVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB6bSA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJtb3VudHppbXVcXFwiLCB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0aXAgPSB6bS5uYW1lID8gXFxcIuW9k+WJjeWtl+W5leaWh+S7tlxcXFxuXFxcIiArIHptLm5hbWUgKyBcXFwiLlxcXCIgKyB6bS5leHQgOiBcXFwi6L+Y5pyq5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogJ+aJi+WKqOaMgui9veWtl+W5lScsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiB0aXAgKyBcXFwiXFxcXG4o54K55Ye75Y+W5raI5Y+v5Lul5riF6Zmk5oyC6L295a2X5bmVKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWw6ICgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJtb3VudHppbXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5riF6Zmk5omL5Yqo5oyC6L295a2X5bmVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5blvLnluZXmkJzntKLop4TliJlcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJqc1xcXCI6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbG9hZERtP3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGUgKyBcXFwiJnRpdGxlPVxcXCIpICsgXFxcIitlbmNvZGVVUklDb21wb25lbnQocGxheWRhdGEudGl0bGUuc3BsaXQoJy0nKVswXSk7XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJuYW1lXFxcIjogTVlfUlVMRS50aXRsZSArIFxcXCLlvLnluZXmkJzntKJcXFwiXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoXFxcIu+/pXByb2plY3Rpb25fc2NyZWVu77+lXFxcIiArIEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmjqjpgIHliLBUVkJveFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3R2Ym94UHVzaCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiuvue9ruaUtuiXj+WwgemdolxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIiwgXFxcIuaQnOe0ouWwgemdolxcXCJdLCAxKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi6K6+572u5bCB6Z2i5Zyw5Z2AXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiLCBcXFwi6K+36L6T5YWl5Zu+54mH5Zyw5Z2AXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnB1dCkgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+i+k+WFpeWcsOWdgFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFBhZ2VQaWNVcmwoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+u5pS55oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZnJvbnRDb3ZlciNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLojrflj5bmipXlsY9JUFxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpcCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpLmdldElQdjRBZGRyZXNzKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpcC5zdGFydHNXaXRoKFxcXCIxOTIuMTY4LlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpcCArIFxcXCJcXFxcbuivpUlQ6YCC55So5LqO5rWB6YePK+eDreeCueeahOaKleWxj1xcXFxu6K+35pu/5o2i6ZO+5o6l5Lit55qEMC4wLjAuMFxcXCIpLmNvbmZpcm0oKGlwKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGlwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXApO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXAgKyBcXFwiXFxcXG7ojrflj5blpLHotKXpnZ7nqLPlrppJUCzor7flvIDlkK/ng63ngrnlho3kvb/nlKgs6K+lSVDlj6/og73kvJrlj5gs5LiN6IO95oqV5bGPXFxcIikuY29uZmlybSgoKSA9PiB7fSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmnoHpgJ/ljp/nlLvkuIvovb3nur/nqItcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChnZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFxcXCIyMFxcXCIpLCBcXFwi6K+36L6T5YWlMy0zMuS5i+mXtOeahOaVtOaVsFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzcGVlZFRocmVhZCA9IHBhcnNlSW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzcGVlZFRocmVhZCA8IDMgfHwgc3BlZWRUaHJlYWQgPiAzMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7kuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic3BlZWRUaHJlYWRcXFwiLCBTdHJpbmcoc3BlZWRUaHJlYWQpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLovazlrZjlvZPliY3mlofku7blpLlcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9teWFsaXl1biNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/cGFnZT1meXBhZ2VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUlkLCBzaGFyZVB3ZCwgZmlsZUlkKSxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ZpbGVpbnRvLnN2Z1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlSWQ6IHBhZ2VJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2QsXFxuICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcjogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGZvbGRlck5hbWU6IGdldFBhZ2VUaXRsZSgpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCJBTExcXFwiLCBcXFwi6Lez6L+H5paH5Lu2XFxcIl1bTnVtYmVyKHNraXBGaWxlKV0sXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoc2tpcEZpbGUpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNraXBGaWxlXFxcIiwgU3RyaW5nKHNraXBGaWxlID8gXFxcIjBcXFwiIDogXFxcIjFcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBza2lwRmlsZSksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX3NlYXJjaDZcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGZ1blN0eWxlID0gW1xcXCJcXFwiLCBcXFwiXFx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cXG4gICAgICAgIGlmIChzdWJFeHRzLmluY2x1ZGVzKGV4dCkpIHtcXG4gICAgICAgICAgICBoZWFkID0gXFxcIvCflbhcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGhlYWQgfHwgXFxcIuKdk1xcXCI7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZ2V0UHJldmlld1BpYyhmaWxlSXRlbSkge1xcbiAgICAgICAgaWYgKGZpbGVJdGVtLnRodW1ibmFpbCkge1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJodHRwczovL2VtcHR5P1xcXCIgKyBmaWxlSXRlbS5maWxlX2lkKS5pbWFnZSgocGljKSA9PiB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmV0Y2gocGljLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRTdHJlYW06IHRydWVcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGZpbGVJdGVtLnRodW1ibmFpbCk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgbGV0IGZvbGRlclN0eWxlLCBmaWxlU3R5bGU7XFxuICAgIGxldCBmaWx0ZXJUeXBlID0gW107XFxuICAgIGlmIChzdHlsZSA9PT0gXFxcIui/veWJp1xcXCIpIHtcXG4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwibW92aWVfMlxcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcInZpZGVvXFxcIik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCI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xlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBmaWxlSXRlbS5uYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXI6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui9rOWtmFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP3BhZ2U9ZnlwYWdlXFxcIilcXG4gICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSBpZiAobm9Ta2lwRmlsZSkge1xcbiAgICAgICAgICAgIGlmIChmaWx0ZXJUeXBlLmxlbmd0aCA+IDAgJiYgIWZpbHRlclR5cGUuaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzdWJ0aXRsZSwgY2xzLCBsb25nYyA9IFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L2s5a2YXFxcIixcXG4gICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP3BhZ2U9ZnlwYWdlXFxcIilcXG4gICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBmaWxlSXRlbS5uYW1lO1xcbiAgICAgICAgICAgIGxldCBuYW1lTm90RXh0ID0gZmlsZUl0ZW0ubmFtZS5yZXBsYWNlKCcuJyArIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLCAnJyk7XFxuICAgICAgICAgICAgaWYgKHN1YkV4dHMuaW5jbHVkZXMoZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pKSB7XFxuICAgICAgICAgICAgICAgIGxvbmdjLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjILovb3lrZfluZVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKHptKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ21vdW50emltdScsIHptKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3RvYXN0Oi8v5oyC6L295a6M5oiQ77yM5b2T5YmN5a2X5bmV5paH5Lu2OiAnICsgem0ubmFtZSArICcuJyArIHptLmV4dDtcXG4gICAgICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHQ6IGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVfaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogbmFtZU5vdEV4dFxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY2F0ZSA9PT0gXFxcInZpZGVvXFxcIikge1xcbiAgICAgICAgICAgICAgICBpZiAoemltdWxpc3QubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IHppbXVsaXN0LmZpbmQodiA9PiB2Lm5hbWUuaW5jbHVkZXMobmFtZU5vdEV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgIC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NjLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcjogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSW5mbzoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJZDogcGFnZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUl0ZW0uZmlsZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZUlkOiBzaGFyZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlVG9rZW46IHNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogbG9uZ2MsXFxuICAgICAgICAgICAgICAgICAgICBjbHM6IGNscyxcXG4gICAgICAgICAgICAgICAgICAgIC8vaW5oZXJpdFRpdGxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogZmlsZUl0ZW0ubmFtZVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogZmlsZVN0eWxlXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgaWYgKGNvbnRzLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5LqG5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG59XFxuXFxubGV0IGl0ZW1zID0gW107XFxudHJ5IHtcXG4gICAgaWYgKE1ZX1BBR0UgPiAxICYmICFNWV9QQVJBTVMubWFya2VyKSB7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInkuoblk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIGxvYWQoaXRlbXMpO1xcbiAgICB9XFxufSBjYXRjaCAoZSkge1xcbiAgICBpZiAoZS5uYW1lID09PSBcXFwiQWxpRXJyb3JcXFwiKSB7XFxuICAgICAgICBpZiAoZS5jb2RlID09PSBcXFwiSW52YWxpZFJlc291cmNlLlNoYXJlUHdkXFxcIikge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuivt+i+k+WFpeaPkOWPlueggVxcXCIsXFxuICAgICAgICAgICAgICAgIGRlc2M6IHNoYXJlUHdkID8gXFxcIuKAnOKAnOaPkOWPlueggemUmeivr+KAneKAnVxcXCIgOiBcXFwiXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKCkuaW5wdXQoKE1ZX1BBUkFNUykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0UGFnZVBhcmFtcyhPYmplY3QuYXNzaWduKHt9LCBNWV9QQVJBTVMsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0sIE1ZX1BBUkFNUyksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCJcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaWYgKGUuc2lnbmlmaWNhbmNlID09PSAxKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgZS5tZXNzYWdlLmJpZygpLmJpZygpLmZvbnRjb2xvcihcXFwicmVkXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMScsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoZS5zaWduaWZpY2FuY2UgPT09IDMpIHtcXG4gICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBlLm1lc3NhZ2UuYmlnKCkuZm9udGNvbG9yKFxcXCJncmVlblxcXCIpLFxcbiAgICAgICAgICA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XG5cXG4gICAgICAgICAgICBpZiAocXJDb2RlU3RhdHVzID09PSBcXFwiQ09ORklSTUVEXFxcIikge1xcbiAgICAgICAgICAgICAgICBpZiAocmVzdWx0LmNvbnRlbnQuZGF0YS5iaXpFeHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbmZvID0gSlNPTi5wYXJzZShiYXNlNjREZWNvZGUocmVzdWx0LmNvbnRlbnQuZGF0YS5iaXpFeHQpKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBhbGlUb2tlbnNGaWxlcGF0aCA9ICQucmVxdWlyZShcXFwiaGlrZXI6Ly9wYWdlL3Rva2VuUGF0aFxcXCIpLmFsaVRva2Vuc0ZpbGVwYXRoO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGFsaVRva2VuID0ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW46IGluZm8ucGRzX2xvZ2luX3Jlc3VsdC5yZWZyZXNoVG9rZW5cXG4gICAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgICB3cml0ZUZpbGUoYWxpVG9rZW5zRmlsZXBhdGgsIEpTT04uc3RyaW5naWZ5KGFsaVRva2VuKSk7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcImxvZ2lueVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIueZu+W9leaIkOWKnyjngrnlh7vov5Tlm54pXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi55m75b2V5oiQ5YqfXFxcIiwgdHJ1ZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi55m75b2V5aSx6LSlLOivt+WwneivleWFtuS7lueahOaWueazlVxcXCIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHFyQ29kZVN0YXR1cyA9PT0gXFxcIkNBTkNFTEVEXFxcIikge1xcbiAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi5Y+W5raI55m75b2V5o6I5p2DXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKFtcXFwiTkVXXFxcIiwgXFxcIlNDQU5FRFxcXCJdLmluY2x1ZGVzKHFyQ29kZVN0YXR1cykpIHtcXG4gICAgICAgICAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCgyNTAwKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBiYWNrSG9tZShcXFwi6LaF5pe2XFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgZXJyb3JDb3VudCsrO1xcbiAgICAgICAgICAgIGlmIChlcnJvckNvdW50ID4gNCkge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfVxcblxcbn1cXG5pZiAoaW5kZXggPiAtMSkge1xcbiAgICBsZXQgbG9naW5VcmxzID0gW1xcXCJod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GZ5X2JyaWRnZV9hcHAuYmFjayhpc1JlZnJlc2gpO1xcbiAgICAgICAgICAgICAgICBmeV9icmlkZ2VfYXBwLnRvYXN0KCdUT0tFTuiOt+WPluaIkOWKn++8jOivt+WLv+azhOa8j+S4quS6uumakOenge+8ge+8ge+8gScpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgMzAwKTtcXG4gICAgfSwgaXNSZWZyZXNoLCBhbGlUb2tlbnNGaWxlcGF0aCk7XFxuXFxuICAgIGQucHVzaCh7XFxuICAgICAgICB1cmw6IHVybCxcXG4gICAgICAgIGNvbF90eXBlOiAneDVfd2Vidmlld19zaW5nbGUnLFxcbiAgICAgICAgZGVzYzogJzEwMCUmJmZsb2F0JyxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgY2FuQmFjazogZmFsc2UsXFxuICAgICAgICAgICAganM6IGpzLFxcbiAgICAgICAgICAgIHVybEludGVyY2VwdG9yOiAkLnRvU3RyaW5nKCgpID0+IHRydWUpXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxufSBlbHNlIHtcXG4gICAgXFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIuetieW+heaOiOadgy4uLlxcXCIuYmlnKCkuYmlnKCksXFxuICAgICAgICBkZXNjOiBcXFwi5aaC5p6c5Y2H57qn5LqG5a6Y5pa5QXBw77yM5peg5rOV6Ieq5Yqo6LCD6LW35o6I5p2D77yM6K+35omr56CB55m75b2VXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogXFxcImxvZ2lueVxcXCIsXFxuICAgICAgICB9XFx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IHNldCh2KSB7XFxuICAgICAgICAgICAgdGhpcy5fc2hhcmVUb2tlbiA9IHY7XFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkodGhpcywgXFxcIm9wZW5Ub29sc1xcXCIsIHtcXG4gICAgICAgIGdldCgpIHtcXG4gICAgICAgICAgICBpZiAodGhpcy5fb3BlblRvb2xzKSByZXR1cm4gdGhpcy5fb3BlblRvb2xzO1xcbiAgICAgICAgICAgIGxldCBPcGVuQXBpVG9vbHM7XFxuICAgICAgICAgICAgc3dpdGNoIChnZXRJdGVtKFxcXCJvcGVuQXBpTW9kZVxcXCIsIFxcXCIwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiMVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfYWxpeXVuZHJpdmVcXFwiICsgdGhpcy5vcGVuU3VmZml4KTtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICBjYXNlIFxcXCIyXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgIE9wZW5BcGlUb29scyA9ICQucmVxdWlyZShcXFwib3BlbkFwaV90dmJveFxcXCIgKyB0aGlzLm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjNcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX1hCWVxcXCIgKyB0aGlzLm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjBcXFwiOlxcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX2FsaXN0XFxcIiArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRoaXMuX29wZW5Ub29scyA9IG5ldyBPcGVuQXBpVG9vbHModGhpcyk7XFxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX29wZW5Ub29scztcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCBcXFwib3BlblRva2Vuc1xcXCIsIHtcXG4gICAgICAgIGdldCgpIHtcXG4gICAgICAgICAgICBpZiAodGhpcy5fb3BlblRva2VucykgcmV0dXJuIHRoaXMuX29wZW5Ub2tlbnM7XFxuICAgICAgICAgICAgdGhpcy5fb3BlblRva2VucyA9IE9iamVjdC5hc3NpZ24oe1xcbiAgICAgICAgICAgICAgICAnUmVmcmVzaFRva2VuT3Blbic6ICcnLFxcbiAgICAgICAgICAgICAgICAnQWNjZXNzVG9rZW5PcGVuJzogJycsXFxuICAgICAgICAgICAgICAgICdCaW5kUmVmcmVzaFRva2VuJzogJycsXFxuICAgICAgICAgICAgfSwgb3BlblRva2Vucyk7XFxuICAgICAgICAgICAgaWYgKG9wZW5Ub2tlbnMgIT09IG51bGwgJiYgIXRoaXMuX29wZW5Ub2tlbnMuQWNjZXNzVG9rZW5PcGVuKSB7XFxuICAgICAgICAgICAgICAgIHRoaXMucmVmcmVzaE9wZW5Ub2tlbigpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fb3BlblRva2VucztcXG4gICAgICAgIH1cXG4gICAgfSk7XFxufVxcbk9iamVjdC5hc3NpZ24oQWxpQWNjZXNzQXBpLnByb3RvdHlwZSwge1xcbiAgICBfb3BlblRvb2xzOiB2b2lkIDAsXFxuICAgIF9vcGVuVG9rZW5zOiB2b2lkIDAsXFxuICAgIF9zaGFyZVRva2VuOiB2b2lkIDAsXFxu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gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi6L+U5Zue57uT5p6c5pegVG9rZW5cXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCJPcGVuVG9rZW7ojrflj5blpLHotKU6XFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIF9jbG91ZEZpbGVPcGVyYXRlKGJvZHksIGNsb3VkRmlsZUlkLCBvcGVyYXRlVXJsKSB7XFxuICAgICAgICBsZXQgcmVzdWx0ID0gdGhpcy5wb3N0QXBpKCdodHRwczovL2FwaS5hbGl5dW5kcml2ZS5jb20vYWRyaXZlL3YyL2JhdGNoJykuYm9keSh7XFxuICAgICAgICAgICAgXFxcInJlcXVlc3RzXFxcIjogW3tcXG4gICAgICAgICAgICAgICAgXFxcImJvZHlcXFwiOiBib2R5LFxcbiAgICAgICAgICAgICAgICBcXFwiaGVhZGVyc1xcXCI6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJDb250ZW50LVR5cGVcXFwiOiBcXFwiYXBwbGljYXRpb24vanNvblxcXCJcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgXFxcImlkXFxcIjogY2xvdWRGaWxlSWQgfHwgXFxcIjBcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwibWV0aG9kXFxcIjogXFxcIlBPU1RcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwidXJsXFxcIjogb3BlcmF0ZVVybFxcbiAgICAgICAgICAgIH1dLFxcbiAgICAgICAgICAgIFxcXCJyZXNvdXJjZVxcXCI6IFxcXCJmaWxlXFxcIlxcbiAgICAgICAgfSkuaGVhZGVycyh7XFxuICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQSxcXG4gICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJyxcXG4gICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAvL2dldEFjY2Vzc1Rva2VuXFxuICAgICAgICAgICAgJ3gtY2FuYXJ5JzogJ2NsaWVudD13ZWIsYXBwPXNoYXJlLHZlcnNpb249djIuMy4xJyxcXG4gICAgICAgICAgICAneC1zaGFyZS10b2tlbic6IHRoaXMuc2hhcmVUb2tlblxcbiAgICAgICAgfSkuZXJyb3JXaXRoUmV0cnkoKGUsIF8sIGh0dHApID0+IHtcXG4gICAgICAgICAgICBpZiAoZS5jb2RlID09PSBcXFwiUXVvdGFFeGhhdXN0ZWQuRHJpdmVcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IGU7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmICghdGhpcy50cnlTb2x2ZShlKSkge1xcbiAgICAgICAgICAgICAgICB0aGlzLndhaXRTbGVlcCgyMCkucmVmcmVzaEFjY2Vzc1Rva2VuKCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBib2R5ID0gaHR0cC5vcHRpb25zLmJvZHkucmVxdWVzdHNbMF0uYm9keTtcXG4gICAgICAgICAgICBpZiAoYm9keS5kcml2ZV9pZCkge1xcbiAgICAgICAgICAgICAgICBib2R5LmRyaXZlX2lkID0gdGhpcy5nZXRNeURyaXZpZCgpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoYm9keS50b19kcml2ZV9pZCkge1xcbiAgICAgICAgICAgICAgICBib2R5LnRvX2RyaXZlX2lkID0gdGhpcy5nZXRNeURyaXZpZCgpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG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CBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgLy90aGlzLndhaXRTbGVlcCgzMCkudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMzApLnRyeU9wZW5BcGlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmdldE15RHJpdmlkKCksXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5vcGVuVG9rZW5zLkFjY2Vzc1Rva2VuT3BlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGlmICghZmlsZUluZm8udXJsIHx8IGZpbGVJbmZvLmNvZGUpIHRocm93IG5ldyBFcnJvcihcXFwi5LiL6L296ZO+5o6l6I635Y+W5aSx6LSlXFxcXG5cXFwiICsgZmlsZUluZm8uY29kZSArIFxcXCI6XFxcIiArIGZpbGVJbmZvLm1lc3NhZ2UpO1xcbiAgICAgICAgcmV0dXJuIGZpbGVJbmZvLnVybDtcXG4gICAgfSxcXG4gICAgZGVsZXRlZUNsb3VkRmlsZShjbG91ZEZpbGVJZCkge1xcbiAgICAgICAgbGV0IHJlc3VsdCA9IHRoaXMuX2Nsb3VkRmlsZU9wZXJhdGUoe1xcbiAgICAgICAgICAgIFxcXCJkcml2ZV9pZFxcXCI6IHRoaXMuZ2V0TXlEcml2aWQoKSxcXG4gICAgICAgICAgICBcXFwiZmlsZV9pZFxcXCI6IGNsb3VkRmlsZUlkXFxuICAgICAgICB9LCBjbG91ZEZpbGVJZCwgXFxcIi9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AgICAgdGhpcy53YWl0U2xlZXAoMzApLnRyeU9wZW5BcGlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmdldE15RHJpdmlkKCksXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5vcGVuVG9rZW5zLkFjY2Vzc1Rva2VuT3BlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiBmaWxlSW5mby52aWRlb19wcmV2aWV3X3BsYXlfaW5mby5saXZlX3RyYW5zY29kaW5nX3Rhc2tfbGlzdC5yZXZlcnNlKCk7XFxuICAgIH0sXFxuICAgIGdldEFsbFZpZGVvVGVtUGxheVVybChmaWxlSWQsIG9ubHlQcmV2aWV3KSB7XFxuICAgICAgICBsZXQgY2xvdWRGaWxlSWQgPSB0aGlzLmNvcHlGaWxlVG9DbG91ZEZpbGUoZmlsZUlkKTtcXG4gICAgICAgIHRoaXMud2FpdFNsZWVwKDIwKTtcXG4gICAgICAgIGxldCBwbGF5VXJsID0gb25seVByZXZpZXcgPyB1bmRlZmluZWQgOiB0aGlzLm9wZW5DbG91ZEZpbGVUb0Rvd25VcmwoY2xvdWRGaWxlSWQpO1xcbiAgICAgICAgdGhpcy53YWl0U2xlZXAoNTApO1xcbiAgICAgICAgbGV0IHByZXZpZXcgPSB0aGlzLmdldFZpZGVvQ2xvdWRQcmV2aWV3KGNsb3VkRmlsZUlkKTtcXG4gICAgICAgIHRoaXMud2FpdFNsZWVwKDUwKTtcXG4gICAgICAgIHRyeSB7X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G93bmxvYWRJbmZvID0gdGhpcy5wb3N0QXBpKFxcXCIvdjIvZmlsZS9nZXRfc2hhcmVfbGlua19kb3dubG9hZF91cmxcXFwiKS5ib2R5KHtcXG4gICAgICAgICAgICBcXFwiZXhwaXJlX3NlY1xcXCI6IDYwMCxcXG4gICAgICAgICAgICBcXFwiZmlsZV9pZFxcXCI6IGZpbGVJZCxcXG4gICAgICAgICAgICBcXFwic2hhcmVfaWRcXFwiOiB0aGlzLnNoYXJlSWRcXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgIFxcXCJYLVNoYXJlLVRva2VuXFxcIjogdGhpcy5zaGFyZVRva2VuLFxcbiAgICAgICAgICAgIFxcXCJhdXRob3JpemF0aW9uXFxcIjogdGhpcy5hbGlUb2tlbnMuYWNjZXNzX3Rva2VuXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlgtU2hhcmUtVG9rZW5cXFwiOiB0aGlzLnNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICBcXFwiYXV0aG9yaXphdGlvblxcXCI6IHRoaXMuYWxpVG9rZW5zLmFjY2Vzc190b2tlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiBkb3dubG9hZEluZm8uZG93bmxvYWRfdXJsO1xcbiAgICB9LFxcbiAgICBnZXRTaWduKCkge1xcbiAgICAgICAgaWYgKCF0aGlzLmFsaVRva2Vucy5kZXZpY2VfaWQpIHtcXG4gICAgICAgICAgICB0aGl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1gtU2hhcmUtVG9rZW4nOiB0aGlzLnNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgJ3gtZGV2aWNlLWlkJzogdGhpcy5hbGlUb2tlbnMuZGV2aWNlX2lkLFxcbiAgICAgICAgICAgICd4LXNpZ25hdHVyZSc6IG5ld1NpZ24uc2lnbmF0dXJlXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgzLCAoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChlLm1lc3NhZ2UgPT09IFxcXCJ4LWRldmljZS1pZCBlbXB0eVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMjApLnJlZnJlc2hBY2Nlc3NUb2tlbigpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB0aGlzLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDUwKTtcXG4gICAgICAgICAgICBuZXdTaWduID0gY2FsY3VsYXRlTmV3U2lnbigpO1xcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwdWJLZXlcXFwiOiBuZXdTaWduLnB1YktleVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgICAgICdYLVNoYXJlLVRva2VuJzogdGhpcy5zaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgJ3gtZGV2aWNlLWlkJzogdGhpcy5hbGlUb2tlbnMuZGV2aWNlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgJ3gtc2lnbmF0dXJlJzogbmV3U2lnbi5zaWduYXR1cmVcXG4gICAgICAgICAgICAgICAgfVxcbi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XJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUa1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyhyZXN1bHQpLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgICAgIHJlc3VsdC5pdGVtcyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcXG4gICAgfSxcXG4gICAgc2lnbkluUmV3YXJkKCkge1xcbiAgICAgICAgbGV0IHNpbERhdGEgPSB0aGlzLnBvc3RBcGkoJ2h0dHBzOi8vbWVtYmVyLmFsaXl1bmRyaXZlLmNvbS92MS9hY3Rpdml0eS9zaWduX2luX2xpc3QnKS5ib2R5KHtcXG4gICAgICAgICAgICAnZ3JhbnRfdHlwZSc6ICdyZWZyZXNoX3Rva2VuJyxcXG4gICAgICAgICAgICAncmVmcmVzaF90b2tlbic6IHRoaXMuYWxpVG9rZW5zLnJlZnJlc2hfdG9rZW5cXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAnYXBwbGljYXRpb24vanNvbidcXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgdGhpcy50cnlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG5cXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ3JlZnJlc2hfdG9rZW4nOiB0aGlzLmFsaVRva2Vucy5yZWZyZXNoX3Rva2VuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgbGV0IGRheSA9IHNpbERhdGEucmVzdWx0LnNpZ25JbkNvdW50O1xcbiAgICAgICAgbGV0IGlzUmV3YXJkID0gc2lsRGF0YS5yZXN1bHQuc2lnbkluTG9nc1tkYXkgLSAxXS5pc1Jld2FyZDtcXG4gICAgICAgIGlmIChpc1Jld2FyZCkge1xcbiAgICAgICAgICAgIGxldCByZXdhcmQgPSBzaWxEYXRhLnJlc3VsdC5zaWduSW5Mb2dzW2RheSAtIDFdLnJld2FyZDtcXG4gICAgICAgICAgICBpZiAocmV3YXJkKSB7XFxuICAgICAgICAgICAgICAgIGxldCByZXdub3RpY2UgPSByZXdhcmQubm90aWNlO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcIuS7iuWkqeW3sue7j+etvuWIsO+8jOivt+S4jeimgemHjeWkjeetvuWIsO+8gVxcXFxuXFxcIiArIHJld25vdGljZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAvL+ayoeacieWlluWKse+8jOWPquacieW5uOi/kOetvuWQjeeJh1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcIuS7iuWkqeW3sue7j+etvuWIsO+8jOivt+S4jeimgemHjeWkjeetvuWIsO+8gVxcXFxu5LuK5pel5aW96L+Q562+OlxcXCIgKyBzaWxEYXRhLnJlc3VsdC5ibGVzc2luZztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBzaXJEYXRhID0gdGhpcy5wb3N0QXBpKCdodHRwczovL21lbWJlci5hbGl5dW5kcml2ZS5jb20vdjEvYWN0aXZpdHkvc2lnbl9pbl9yZXdhcmQnKS5ib2R5KHtcXG4gICAgICAgICAgICAgICAgXFxcInNpZ25JbkRheVxcXCI6IGRheVxcbiAgICAgICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJ1xcbiAgICAgICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgICAgIGxldCByZXdhcmQgPSBzaXJEYXRhLnJlc3VsdDtcXG4gICAgICAgICAgICBpZiAocmV3YXJkKSB7XFxuICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwi562+5Yiw5oiQ5YqfISDojrflvpflpZblirE6XFxcIiArIHJld2FyZC5ub3RpY2UgKyBcXFwiKFxcXCIgKyByZXdhcmQuc3ViTm90aWNlICsgXFxcIikg5pys5pyI5bey6L+e57ut562+5YiwOlxcXCIgKyBkYXkgKyBcXFwi5aSpXFxcIjtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG1zZztcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAvL+ayoeacieWlluWKse+8jOWPquacieW5uOi/kOetvuWQjeeJh1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcIuetvuWIsOaIkOWKn++8geS7iuaXpeW5uOi/kOetvjpcXFwiICsgc2lsRGF0YS5yZXN1bHQuYmxlc3Npbmc7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9XFxufSk7XFxuXFxuQWxpQWNjZXNzQXBpLmNyZWF0ZURlZmF1bHQgPSBmdW5jdGlvbihzaGFyZUlkLCBzaGFyZVB3ZCwgc2hhcmVUb2tlbiwgYWxpVG9rZW4sIG9wZW5Ub2tlbiwgT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k7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZXJyKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgZXJyID0gdGhpcy5lcnJvclR5cGVDYWxsYmFjayhlcnIsIHJlcyk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAodGhpcy5yZXRyeUNvdW50KSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCB0cnlSZXN1bHQgPSB0aGlzLmVycm9yQ2FsbGJhY2tXaXRoUmV0cnkoZXJyLCByZXMsIHRoaXMpO1xcbiAgICAgICAgICAgICAgICBpZiAodHJ5UmVzdWx0KSB7XFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJldHJ5Q291bnQtLTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnN0YXJ0KHRvSnNvbik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJldHJ5Q291bnQgPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZXJyb3JDYWxsYmFjayhlcnIsIHJlcyk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lcnJvckNhbGxiYWNrKGVyciwgcmVzKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNldE9wdGlvbnMob3B0aW9ucykge1xcbiAgICAgICAgdGhpcy5vcHRpb25zID0gT2JqZWN0LmFzc2lnbih7fSwgb3B0aW9ucywge1xcbiAgICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlXFxuICAgICAgICB9KTtcXG4gICAgICAgIHJldHVybiB0aGlzO1xcbiAgICB9LFxcbiAgICBtZXJnZUhlYWRBbmRCb2R5KG9wdGl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9IFtdO1xcbiAgICAgICAgZm9yIChsZXQgaSBpbiBwYXJhbXMpIHtcXG4gICAgICAgICAgICAvKmlmIChpID09IDApIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKHBhcnNlSW50KHBhcmFtc1tpXSkpO1xcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICBpZiAoaSA9PSAyKSB7XFxuICAgICAgICAgICAgICAgIHBhcmFtc1QucHVzaChcXFwiMjVcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgICAgICAvL+minOiJsuWAvOS4ujDml7bvvIzpu5jorqTorr7nva7kuLrnmb3oibJcXG4gICAgICAgICAgICAgICAgaWYgKHBhcmFtc1tpXSA9PSBcXFwiMFxcXCIgfHwgcGFyYW1zW2ldID09IFxcXCItMVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcmFtc1QucHVzaChcXFwiMTY3NzcyMTVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHBhcmFtc1QucHVzaChwYXJhbXNbaV0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgcGFyYW1zVC5wdXNoKFxcXCIwXFxcIik7XFxuICAgICAgICBsZXQgdGltZXM9cGFyc2VJbnQocGFyYW1zWzBdLzYwKStcXFwiOlxcXCIrcGFyc2VJbnQocGFyYW1zWzBdJTYwKTtcXG4gICAgICAgIGRNY29udGV4dCArPSBgPGQgcD1cXFwiJHtwYXJhbXNULmpvaW4oJywnKX1cXFwiPiR7ZW5jb2RlSHRtbChjb21tZW50VGV4dCkrXFxcIiNcXFwiK3RpbWVzfTwvZD5cXFxcbmA7XFxuICAgIH1cXG4gICAgaWYgKCF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G4gICAgICAgICAgICBpZiAoIW5hbWUgfHwgIXBvcykge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBcXFwi5qC85byP6ZSZ6K+vXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHVybEluZm8gPSBmZXRjaChidWlsZFVybChcXFwiaHR0cHM6Ly9henVyZS5sZXVzZS50b3Avc2VhcmNoZG1cXFwiLCB7XFxuICAgICAgICAgICAgICAgIHBhcmFtczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBvc1xcXCI6IHBvc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgIHVybEluZm8gPSBKU09OLnBhcnNlKHVybEluZm8pO1xcbiAgICAgICAgICAgIGlmICghdXJsSW5mby51cmwpIHRocm93IFxcXCLmmoLml7bmsqHmnInmib7liLDor6Xop4bpopHnmoTlvLnluZVcXFwiO1xcbiAgICAgICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybChcXFwiaHR0cHM6Ly9henVyZS5sZXVzZS50b3AvZGFubXVcXFwiLCB7XFxuICAgICAgICAgICAgICAgIHBhcmFtczogdXJsSW5mb1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgIGlmICgheG1sKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IFxcXCLov5jmsqHmnInlvLnluZXlk59+XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBhdGggPSBcXFwiaGlrZXI6Ly9maWxlcy9jYWNoZS9kYW5tdS9cXFwiICsgdXJsSW5mby5wbGF0Zm9ybSArIFxcXCJfXFxcIiArIG5hbWUgKyBcXFwiX1xcXCIgKyBwb3MgKyBcXFwiLnhtbFxcXCI7XFxuICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsICc8P3htbCB2ZXJzaW9uPVxcXCIxLjBcXFwiIGVuY29kaW5nPVxcXCJVVEYtOFxcXCI/PlxcXFxuJyArIHhtbCk7XFxuICAgICAgICAgICAgaWYgKG9ubHlEb3dubG9hZCkgcmV0dXJuIFxcXCJ0b2FzdDovL+S4i+i9veWujOaIkFxcXCI7XFxuICAgICAgICAgICAgcmVmcmVzaFZpZGVvVXJsKHtcXG4gICAgICAgICAgICAgICAgZGFubXU6IHBhdGhcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5Yqg6L295a6M5oiQXFxcIjtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgfVxcbiAgICB9LCBvbmx5RG93bmxvYWQpLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcImRt55uS5a2Q5pCc57SiXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChrZXksIG9ubHlEb3dubG9hZCkgPT4ge1xcbiAgICAgICAgbGV0IGRtID0gZ2V0VmFyKFxcXCJkbV9zaGFyZVxcXCIpO1xcbiAgICAgICAgaWYgKGRtICYmICFvbmx5RG93bmxvYWQpIHtcXG4gICAgICAgICAgICBjbGVhclZhcihcXFwiZG1fc2hhcmVcXFwiKTtcXG4gICAgICAgICAgICByZWZyZXNoVmlkZW9Vcmwoe1xcbiAgICAgICAgICAgICAgICBkYW5tdTogZG1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICByZXR1cm4g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cIixcXG4gICAgICAgICAgICB1cmw6ICQoXFxcIlxcXCIsIFxcXCLor7fovpPlhaXkuIvovb3ojIPlm7QoMSxcXFwiICsgYW5pbWUuZXBpc29kZXMubGVuZ3RoICsgXFxcIilcXFwiKS5pbnB1dCgoYW5pbWVUaXRsZSwgZXBpc29kZXMpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IFthLCBiXSA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgICAgICAgICBhID0gTnVtYmVyKGEpLCBiID0gTnVtYmVyKGIpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKGEpIHx8IE51bWJlci5pc05hTihiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+aMieagvOW8j+i+k+WFpeaVsOWtl1xcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKGEgPCAxIHx8IGIgPiBlcGlzb2Rlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXop4TlrprojIPlm7TlhoXnmoTmlbDlrZdcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNvbnN0IGRhbm11ID0gJC5yZXF1aXJlKFxcXCJkYW5tdVxcXCIpO1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IGEgLSAxLCBqID0gMTsgaSA8IGI7IGkrKywgaisrKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVwaXNvZGUgPSBlcGlzb2Rlc1tpXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZG1UaXRsZSA9IGFuaW1lVGl0bGUgKyBcXFwiX1xcXCIgKyBlcGlzb2RlLmVwaXNvZGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5LiL6L2977yaXFxcIiArIGVwaXNvZGUuZXBpc29kZVRpdGxlICsgXFxcIlxcXFx0KFxcXCIgKyBqICsgXFxcIi9cXFwiICsgKGIgLSBhICsgMSkgKyBcXFwiKVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhbm11LmRvd25sb2FkRGFuTXUoZXBpc29kZS5lcGlzb2RlSWQsIGRtVGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZOm5ZOm5LiL6L295aSx6LSlLi4uXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiL6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICB9LCBhbmltZS5hbmltZVRpdGxlLCBhbmltZS5lcGlzb2RlcyksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vbW92aWUvMTQuc3ZnXFxcIlxcbiAgICAgICAgfSk7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgICAgIH0pO1xcbiAgICAgICAgZm9yIChsZXQgZXBpc29kZSBvZiBhbmltZS5lcGlzb2Rlcykge1xcbiAgICAgICAgICAgIGxldCBkbVRpdGxlID0gYW5pbWUuYW5pbWVUaXRsZSArIFxcXCJfXFxcIiArIGVwaXNvZGUuZXBpc29kZVRpdGxlO1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBlcGlzb2RlLmVwaXNvZGVUaXRsZSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKGVwaXNvZGUuZXBpc29kZUlkKS5sYXp5UnVsZSgodXJsLCB0aXRsZSwgb25seURvd25sb2FkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjb25zdCBkYW5tdSA9ICQucmVxdWlyZShcXFwiZGFubXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gZGFubXUuZ2V0TG9jYWxEYW5NdShpbnB1dCwgdGl0bGUpIHx8IGRhbm11LmRvd25sb2FkRGFuTXUoaW5wdXQsIHRpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChvbmx5RG93bmxvYWQpIHJldHVybiBcXFwidG9hc3Q6Ly/kuIvovb3lrozmiJBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRhbm11VGV4dCA9IGZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFkYW5tdVRleHQpIHJldHVybiBcXFwidG9hc3Q6Ly/ov5jmsqHmnInlvLnluZXlk59+XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hWaWRlb1VybCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGFubXU6IHBhdGhcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5Yqg6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgTVlfUEFSQU1TLmR1cmwsIGRtVGl0bGUsIG9ubHlEb3dubG9hZCksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuW8uuWItuS4i+i9vVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGVwaXNvZGVUaXRsZSwgZXBpc29kZUlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLor7fnrYnlvoVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhbm11LmRvd25sb2FkRGFuTXUoZXBpc29kZUlkLCBlcGlzb2RlVGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6YeN5paw5LiL6L295a6M5oiQ77yM5Y2V5Ye75oyC6L2944CCXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBkbVRpdGxlLCBlcGlzb2RlLmVwaXNvZGVJZClcXG4gICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lX2JsYW5rXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgaWYgKCFkbUxpc3QuYW5pbWVzLmxlbmd0aCkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuayoeacieaJvuWIsOS4jltcXFwiICsgbmFtZSArIFxcXCJd55u45YWz55qE5by55bmVXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixc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cXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHNoYXJlSWQgPSByZWFsdXJsLnNwbGl0KFxcXCI/XFxcIilbMF0uc3BsaXQoXFxcIi9cXFwiKVs0XTtcXG4gICAgICAgICAgICAgICAgbGV0IHNoYXJlID0gZmV0Y2goXFxcImh0dHBzOi8vYXBpLmFsaXl1bmRyaXZlLmNvbS9hZHJpdmUvdjMvc2hhcmVfbGluay9nZXRfc2hhcmVfYnlfYW5vbnltb3VzXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICdjb250ZW50LXR5cGUnOiAnYXBwbGljYXRpb24vanNvbicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwic2hhcmVfaWRcXFwiOiBzaGFyZUlkXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAnUE9TVCdcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGlmIChzaGFyZS5pbmNsdWRlcyhcXFwic2hhcmVfbGluayBpc1xcXCIpIHx8IHNoYXJlLmluY2x1ZGVzKFxcXCJzaGFyZV9saW5rIGNhbm5vdFxcXCIpKSByZXR1cm4gZmFsc2U7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge31cXG4gICAgICAgIHJldHVybiB0cnVlO1xcbiAgICB9LFxcbiAgICBieXRlc1RvU2l6ZShzaXplKSB7XFxuICAgICAgICBpZiAoIXNpemUpIHtcXG4gICAgICAgICAgICByZXR1cm4gJzAnO1xcbiAgICAgICAgfVxcbiAgICAgICAgY29uc3QgdW5pdHMgPSBbJ0InLCAnS0InLCAnTUInLCAnR0InLCAnVEInLCAnUEInLCAnRUInLCAnWkInLCAnWUInXTtcXG4gICAgICAgIGxldCBpID0gMDtcXG4gICAgICAgIHdoaWxlIChzaXplID49IDEwMjQpIHtcXG4gICAgICAgICAgICBzaXplIC89IDEwMjQ7XFxuICAgICAgICAgICAgaSsrO1xcbiAgICAgICAgfVxcbiAgICAgICAgc2l6ZSA9IGkgPyBOdW1iZXIoc2l6ZS50b0ZpeGVkKDIpKSA6IHNpemU7XFxuICAgICAgICByZXR1cm4gYCR7c2l6ZX0gJHt1bml0c1tpXX1gO1xcbiAgICB9LFxcbiAgICBnZXRDcnlwdG9KUygpIHtcXG4gICAgICAgIGlmICh0eXBlb2YgQ3J5cHRvSlMgPT09IFxcXCJ1bmRlZmluZWRcXFwiKSB7XFxuICAgICAgICAgICAgZXZhbChnZXRDcnlwdG9KUygpKTtcXG4gICAgICAgICAgICByZXR1cm4gQ3J5cHRvSlM7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gQ3J5cHRvSlM7XFxuICAgIH0sXFxuICAgIG1hdGNoQWxpVXJsKHRleHQsIGlzRykge1xcbiAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwiYWxpdGVzdFxcXCIpLm1hdGNoQWxpVXJsKHRleHQsIGlzRyk7XFxuICAgIH0sXFxuICAgIGdldElQdjRBZGRyZXNzKCkge1xcbiAgICAgICAgY29uc3QgTmV0d29ya0ludGVyZmFjZSA9IGphdmEubmV0Lk5ldHdvcmtJbnRlcmZhY2U7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGVuID0gTmV0d29ya0ludGVyZmFjZS5nZXROZXR3b3JrSW50ZXJmYWNlcygpOyBlbi5oYXNNb3JlRWxlbWVudHMoKTspIHtcXG4gICAgICAgICAgICAgICAgbGV0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qg5oiR55qE6Zi/6YeM5LqR55uYXFxcXG4wNTEzOuavj+aXpemmluasoeaJk+W8gOaIkeeahOmYv+mHjOWwhuiHquWKqOetvuWIsFxcXCI7XFxuICAgIFxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ08c3Ryb25nPuS9v+eUqOWJjemhu+efpTwvc3Ryb25nPlxcXCIuYmlnKCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBjb250ZW50LnRyaW0oKS5yZXBsYWNlKC9cXFxcblxcXFxzKj8vZywgXFxcIjxicj5cXFwiKSxcXG4gICAgICAgIFxcXCJjb2xfdHlwZVxcXCI6IFxcXCJyaWNoX3RleHRcXFwiXFxuICAgIH0sIHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgfSwge1xcbiAgICAgICAgdGl0bGU6IHRpbWUgKyBcXFwi56eS5ZCO57un57utXFxcIixcXG4gICAgICAgIHVybDogXFxcInRvYXN0Oi8v6K+36K6k55yf6ZiF6K+75Lul5LiK5YaF5a65XFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBpZCArIFxcXCJ0aW1lclxcXCJcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGlmICh1cGRhdGVJbmZvKSB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuabtOaWsOWGheWuuVxcXCIsXFxuICAgICAgICAgIC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zQXJyYXkobGlzdCkgfHwgbGlzdC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIC8qdG9hc3QoXFxcIui/mOayoeacieWKoOi9veWujOaIkOeahOinhumikVxcXCIpO1xcbiAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICByZXR1cm47Ki9cXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fui/mOacqOacieinhumikeWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJncmV5XFxcIiksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGFsbC51cmwgPSBcXFwidG9hc3Q6Ly/msqHmnInop4bpopHml6Dms5XmjqjpgIFcXFwiO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgbGlzdC5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgIHYuY29sX3R5cGUgPSB2LnR5cGU7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSB2LmV4dHJhLnBhZ2VUaXRsZTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gbmFtZS5yZXBsYWNlKC9cXFxcIy9nLCAnXycpLnJlcGxhY2UoL1xcXFwkL2csICdfJykgKyBcXFwiJHZpZGVvfFxcXCIgKyB2LmV4dHJhLmlkO1xcbiAgICAgICAgICAgIGFsbFVybHMucHVzaCh1cmwpO1xcbiAgICAgICAgICAgIHYudXJsID0gZ2V0UHVzaChuYW1lLCB1cmwpO1xcbiAgICAgICAgICAgIHYuZXh0cmEuY2xzID0gdi5leHRyYS5pZCA9IHVuZGVmaW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XG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgcGljX3VybDogcGljLFxcbiAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgocGljKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJmcm9udGNvdmVycGljXFxcIiwgcGljKTtcXG4gICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0sIHBpYyksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJwaWNfMl9jYXJkXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH1cXG5cXG59XFxuYWRkTGlzdGVuZXIoXFxcIm9uQ2xvc2VcXFwiLCAoKSA9PiB7XFxuICAgIGxldCBwaWMgPSBnZXRNeVZhcihcXFwiZnJvbnRjb3ZlcnBpY1xcXCIpO1xcbiAgICBjbGVhck15VmFyKFxcXCJmcm9udGNvdmVycGljXFxcIik7XFxuICAgIGNsZWFyTXlWYXIoXFxcImZyb250Y292ZXJrZXlcXFwiKTtcXG4gICAgc2V0UGFnZVBpY1VybChwaWMpO1xcbn0pO1xcbnNldFJlc3VsdChkKTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuinhOWImeaWh+S7tlwiLFwicGF0aFwiOlwiY29uZmlnc1wiLFwicnVsZVwiOlwiY29uc3QgcGF0aCA9IFxcXCJoaWtlcjovL2ZpbGVzL3J1bGVzL0xveURnSWsvYWxpU2ltcGxlUnVsZXMuanNvblxcXCI7XFxubGV0IGRhdGE7XFxuXFxuZnVuY3Rpb24gZ2V0SnNvbigpIHtcXG4gICAgaWYgKEFycmF5LmlzQXJyYXkoZGF0YSkpIHtcXG4gICAgICAgIHJldHVybiBkYXRhO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICB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CJAaW1wb3J0PWpzOiQucmVxdWlyZSgnaW1wb3J0P3J1bGU9JytcXFwiICsgSlNPTi5zdHJpbmdpZnkoTVlfUlVMRS50aXRsZSkgKyBcXFwiKShpbnB1dClcXFwiO1xcbiAgICAgICAgICAgICAgICBpZiAoZ2V0UGFzdGVzKCkuaW5jbHVkZXMoaW5wdXQpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZXMubGVuZ3RoLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGggPSBcXFwiaGlrZXI6Ly9maWxlcy9ydWxlcy9Mb3lEZ0lrL3NoYXJlL+S6keeugOaQnOe0ouW8leaTjuinhOWImeOAjFxcXCIgKyBydWxlcy5sZW5ndGggKyBcXFwi44CN5p2hLlxcXCIgKyAoaW5wdXQgPT09IFxcXCJISUtFUlxcXCIgPyBcXFwiaGlrZXJcXFwiIDogXFxcInR4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIGdldFBhc3MocnVsZXMubGVuZ3RoLCBydWxlYjY0LCBcXFwiYVxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVsZXM7XFxuICAgICAgICAgICAgaWYgKG1vID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtNCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBleHQ7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0R3JvdXBKc29uKGV4dCk7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZXMubGVuZ3RoKSByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5a2Y5Zyo6K+l57uEXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYudXNlciA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAgICAgICB9LCBtbywgaW5kZXhzLCBpbmRleGNbMV0pO1xcblxcbiAgICB9LCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcImljb25fc21hbGxfNFxcXCIsXFxuICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2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IGl0ICsgXFxcIuKAneKAnVxcXCIgOiBpdCxcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaXQsIGdyb3VwKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGdyb3VwICE9PSBpdCkge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJydWxlTWFuYWdlX2dyb3VwXFxcIiwgaXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFtcXFwi572u6aG2XFxcIiwgXFxcIue9ruW6lVxcXCIsIFxcXCLmlLnlkI1cXFwiLCBcXFwi5Yig6ZmkXFxcIl0pLnNlbGVjdCgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChcXFwi5pS55ZCNXFxcIiA9PT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpdCwgXFxcIuivt+i+k+WFpeaWsOWQjeensFxcXCIpLmlucHV0KChpdCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVzLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXQgPT09IHYuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2Lmdyb3VwID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChcXFwi5Yig6ZmkXFxcIiA9PT0gaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi5piv5ZCm5Yig6Zmk6K+l57uE5pCc57Si5byV5pOO77yaXFxcIiArIGl0KS5jb25maXJtKChpdCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMuZmlsdGVyKHYgPT4gdi5ncm91cCAhPT0gaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHRnUnVsZXMgPSBbXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB0eFJ1bGVzID0gW107XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5mb3JFYWNoKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ID09PSB2Lmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRnUnVsZXMucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eFJ1bGVzLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGdSdWxlcyA9IHRnUnVsZXMuY29uY2F0KHR4UnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0Z1J1bGVzID0gdHhSdWxlcy5jb25jYXQodGdSdWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbih0Z1J1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaXQpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgIH0sIGl0LCBncm91cCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxuICAgIH0pO1xcbn1cXG5cXG5sZXQgY291bnQgPSBkLmxlbmd0aDtcXG5cXG5mb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgaWYgKGdy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FnZS9wYXNzd29yZCNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSMjbm9SZWZyZXNoI1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIhuS6q1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG9wcyA9IGdldFBhc3RlcygpO1xcbiAgICAgICAgICAgICAgICBvcHMudW5zaGlmdChcXFwi5a6M5pW05Y+j5LukXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKG9wcywgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUudXNlciA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGViNjQgPSBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGdldFBhc3MgPSAobmFtZSwgcnVsZSwgdHlwZSkgPT4gXFxcIua1t+mYlOinhueVjO+8jOOAjFxcXCIgKyBuYW1lICsgXFxcIuOAjeS6keeugOaQnOe0ouW8leaTju+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgaWYgKGdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICBuZXdJbmRleCA9IHJ1bGVzLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgICAgIG5ld0luZGV4ID0gbmV3SW5kZXggPT09IC0xID8gMCA6IG5ld0luZGV4O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8n1xcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcIiArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gYXJyW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSAhcnVsZS5mb3JiaWRkZW47XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIChydWxlLmZvcmJpZGRlbiA/IFxcXCLnpoHnlKhcXFwiIDogXFxcIuWQr+eUqFxcXCIpICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGksIGxlbmd0aCwgZ3JvdXApLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpOiBpLFxcbiAgICAg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0cmE6IHtcXG4gICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfYXV0aG9yXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5hdXRob3IsXFxuICAgICAgICBpZDogXFxcImlkQHBzX2F1dGhvclxcXCJcXG4gICAgICAgIC8vdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICB9XFxufSk7XFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLpgInmi6lcXFwiLFxcbiAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgZGVzYzogXFxcIuWIhue7hCjpgInloaspXFxcIixcXG4gICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGxldCBncm91cCA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEdyb3VwTmFtZXMoKTtcXG4gICAgICAgIGlmICghZ3JvdXAubGVuZ3RoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoZ3JvdXApLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgbGV0IGV4dHJhID0gZmluZEl0ZW0oXFxcInJ1bGVFZGl0R3JvdXBcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJydWxlRWRpdEdyb3VwXFxcIiwge1xcbiAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbihleHRyYSwge1xcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBpbnB1dFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgb25DaGFuZ2U6ICQ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WYXIoXFxcInBzX2ZpbmRBbGlVcmxcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgcGFnZTogISFnZXRNeVZhcihcXFwicHNfcGFnZVxcXCIsIHBhZ2UgPyBcXFwiMVxcXCIgOiBcXFwiXFxcIiksXFxuICAgICAgICAgICAgcmVnaXN0ZXJVcmw6IGdldE15VmFyKFxcXCJwc19yZWdpc3RlclVybFxcXCIsIFxcXCJcXFwiKSB8fCB1bmRlZmluZWQsXFxuICAgICAgICAgICAgbGFzdE1vZGlmeTogRGF0ZS5ub3coKSxcXG4gICAgICAgICAgICBncm91cDogZ2V0TXlWYXIoXFxcInBzX2dyb3VwXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgICAgIHJ1bGVUeXBlOiBnZXRNeVZhcihcXFwicHNfcnVsZVR5cGVcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6KeE5YiZXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcbiAgICAgICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6KeE5YiZXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmoxID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBvYmoxKTtcXG4gICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBvYmoxKTtcXG4gICAgICAgIH1cXG4gICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICBiYWNrKHRydWUpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S/neWtmOaIkOWKn1xcXCI7XFxuICAgIH0sIGluZGV4LCBvYmoucGFnZSwgaXNJbXBvcnQpLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuc2V0UmVzdWx0KGQpO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi6KeE5YiZ6LSm5Y+3XCIsXCJwYXRoXCI6XCJ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gIGRlc2M6XFxcImZsb2F0JiYxMDAlXFxcIlxcbiAgICAgICAgICAgICAgICB9XSk7XFxuICAgICAgICAgICAgfSwgcmVnaXN0ZXJVcmwpLFxcbiAgICAgICAgICAgIGV4dHJhOntcXG4gICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBcXFwi5rOo5YaM6LSm5Y+3OlxcXCIgKyBvYmoubmFtZVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIG9iaiA9IG9iai51c2VyIHx8IHt9O1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi55So5oi35ZCNXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfYWNjb3VudFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5hY2NvdW50LFxcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICAgIGRlc2M6IFxcXCLlr4bnoIFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICB0eXBlOiBcXFwicGFzc3dvcmRcXFwiLFxcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBzX3Bhc3N3b3JkXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogb2JqLnBhc3N3b3JkLFxcbiAgICAgICAgICAgIHRpdGxlVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi6aKd5aSWXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogXFxcInRleHRhcmVhXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19leHRyYVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5leHRyYSxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIGhlaWdodDogLTFcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgbGV0IGFjY291bnQgPSBnZXRNeVZhcihcXFwicHNfYWNjb3VudFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgcGFzc3dvcmQgPSBnZXRNeVZhcihcXFwicHNfcGFzc3dvcmRcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IGV4dHJhID0gZ2V0TXlWYXIoXFxcInBzX2V4dHJhXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIC8qaWYgKCEoYWNjb3VudHx8cGFzc3dvcmR8fGV4dHJhKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN6IO95YWo6YOo5Li656m6XFxcIjtcXG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TaW1wbGVJbXBvcnQuanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG59XFxuJC5leHBvcnRzID0gZnVuY3Rpb24ocGFzcykge1xcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IFtfLCBydWxlLCB0eXBlXSA9IHBhc3Muc3BsaXQoXFxcIiRcXFwiKTtcXG4gICAgICAgIGlmICh0eXBlID09PSBcXFwiYlxcXCIpIHtcXG4gICAgICAgICAgICBydWxlID0gcGFyc2VQYXN0ZShydWxlKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBydWxlcyA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKHJ1bGUpKTtcXG4gICAgICAgIGlmICghQXJyYXkuaXNBcnJheShydWxlcykpIHtcXG4gICAgICAgICAgICBydWxlcyA9IFtydWxlc107XFxuICAgICAgICB9XFxuICAgICAgICAvL3J1bGVzLnJldmVyc2UoKTtcXG4gICAgICAgIE1ZX1VSTCA9IG1vZHVsZS5pZDtcXG4gICAgICAgIGxldCBydWxlVGl0bGUgPSBnZXRQYXJhbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBuZXdJID0gMDtcXG4gICAgICAgIGZvciAobGV0IHJ1bGUgb2YgcnVsZXMpIHtcXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGUgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmaW5kZXg9XFxcIiArIGluZGV4ICsgXFxcIiZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG5ld0krKztcXG4gICAgICAgICAgICAgICAgYXJyLnB1c2gocnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgIC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Hk6IFxcXCJkYXRhPVxcXCIgKyBhcGksXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFJlZmVyZXI6IFxcXCJodHRwczovL3d3dy55dW5zby5uZXQvaW5kZXgvdXNlci9zP3dkPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQocylcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gSlNPTi5wYXJzZShqc29uKS5kYXRhO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcGRmYShodG1sLCBcXFwiYm9keSYmLmxheXVpLWNhcmQ6aGFzKGEpXFxcIik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpdGVtIG9mIGxpc3QpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gcGRmaChpdGVtLCBcXFwiYSYmVGV4dFxcXCIpLnJlcGxhY2UoXFxcIiPmlofku7blpLkgXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAvL2xldCB0aW1lID0gL1xcXFxkezR9KC1cXFxcZHsyfSl7Mn0gXFxcXGR7Mn0oXFxcXDpcXFxcZHsyfSl7Mn0vLmV4ZWMocGRmaChpdGVtLCBcXFwiLmxheXVpLWNhcmQtYm9keSYmVGV4dFxcXCIpKSB8fCBbXTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIC8vZGVzYzogdGltZVswXSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogYmFzZTY0RGVjb2RlKHBkZmgoaXRlbSwgXFxcImEmJnVybFxcXCIpKVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sIHtcXG4gICAgICAgIG5hbWU6IFxcXCLmt7flkIjnm5hcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9hcGkuaHVuaGVwYW4uY29tL3YxL3NlYXJjaFxcXCI7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBwb3N0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBSZWZlcmVyOiBcXFwiaHR0cHM6Ly9odW5oZXBhbi5jb20vXFxcIlxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBib2R5OiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBcXFwicVxcXCI6IHMsXFxuICAgICAgICAgICAgICAgICAgICBcXFwicGFnZVxcXCI6IHBhZ2UsXFxuICAgICAgICAgICAgICAgICAgICBcXFwic2l6ZVxcXCI6IDE1XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UoanNvbik7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLmRhdGEubGlzdDtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoaXQuZGlza190eXBlICE9PSBcXFwiQUxZXFxcIiB8fCBpdC5zaGFyZV91c2VyID09PSBcXFwi5Li2Kioq5Li2XFxcIikgY29udGludWU7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQuZGlza19uYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogcGQoaXQsIFxcXCJpbWcmJnNyY1xcXCIsIHVybCksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGl0LmxpbmssXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC51cGRhdGVfdGltZSArIFxcXCJcXFxcblxcXCIgKyBpdC5saW5rLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH0sIHtcXG4gICAgICAgIG5hbWU6IFxcXCLotYTmupDluK5cXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQocywgcGFnZSkge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIHNlYXJjaCgpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJ0bkxpc3QgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc3AgPSByZXF1ZXN0KFxcXCJodHRwczovL3p5Yi51cHl1bnNvLmNvbS92MTUvc2VhcmNoP2tleXdvcmQ9XFxcIiArIGVuX2FlcyhzKSArIFxcXCImc190eXBlPTImcGFnZT1cXFwiICsgcGFnZSArIFxcXCImYXRrPSZkaWQ9XFxcIiArIGdlbmVyYXRlUmFuZG9tSGV4U3RyaW5nKDY0KSwge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJ1c2VyLWFnZW50XFxcIjogXFxcIk1vemlsbGEvNS4wIChMaW51eDsgQW5kcm9pZCAxMDsgUmVkbWkgTm90ZSA3IEJ1aWxkL1FLUTEuMTkwOTEwLjAwMjsgd3YpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIFZlcnNpb24vNC4wIENocm9tZS84MS4wLjQwNDQuMTM4IE1vYmlsZSBTYWZhcmkvNTM3LjM2IHVuaS1hcHAgSHRtbDVQbHVzLzEuMCAoSW1tZXJzZWQvMjkuMDkwOTEpXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBsZXQgcmVzcERhdGEgPSBkZV9hZXMocmVzcCk7XFxuICAgICAgICAgICAgICAgIGxldCBqc29uRGF0YSA9IEpTT04ucGFyc2UocmVzcERhdGEpIHx8IHt9O1xcbiAgICAgICAgICAgICAgICBsZXQgcmVzdWx0ID0ganNvbkRhdGEucmVzdWx0IHx8IHt9O1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSByZXN1bHQuaXRlbXMgfHwgW107XFxuXFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaXRlbXMubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpdGVtID0gaXRlbXNbaV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29udGVudCA9IGl0ZW0uY29udGVudCB8fCBbXTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjb250ZW50Lmxlbmd0aCA9PSAwIHx8ICFpdGVtLnBhZ2VfdXJsKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB1cmwgPSBkZV9hZXMoaXRlbS5wYWdlX3VybCkgfHwgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXVybCkgY29udGludWU7XFxuICAgICAgICAgICAgICAgICAgICBydG5MaXN0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiAoaXRlbS50aXRsZS5sZW5ndGggPiAzMCA/IGl0ZW0udGl0bGUuc2xpY2UoMCwgMjcpICsgXFxcIi4uLlxcXCIgOiBpdGVtLnRpdGxlKSB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBcXFwi5YiG5Lqr5pe26Ze077yaXFxcIiArIGl0ZW0uaW5zZXJ0X3RpbWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICAgIHJldHVybiBydG5MaXN0O1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBnZW5lcmF0ZVJhbmRvbUhleFN0cmluZyhsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc3VsdCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXJzID0gXFxcIjAxMjM0NTY3ODlhYmNkZWZcXFwiO1xcbiAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXJzTGVuZ3RoID0gY2hhcmFjdGVycy5sZW5ndGg7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSBjaGFyYWN0ZXJzLmNoYXJBdChNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkgKiBjaGFyYWN0ZXJzTGVuZ3RoKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG4gICAgICAgICAgICBsZXQgQ3J5cHRvSlMgPSBhbGlVdGlsLmdldENyeXB0b0pTKCk7XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZW5fYWVzKGUpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBcXFwicXExOTIwNTIwNDYwcXF6elxcXCI7XFxuICAgICAgICAgICAgICAgIC8vIGVuX2Flc1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoaSk7XFxuICAgICAgICAgICAgICAgIHZhciB0ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoZSksXFxuICAgICAgICAgICAgICAgICAgICByID0gQ3J5cHRvSlMuQUVTLmVuY3J5cHQodCwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaXY6IGtleSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkNCQyxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gci5jaXBoZXJ0ZXh0LnRvU3RyaW5nKCk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGRlX2Flcyh2dikge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IFxcXCJxcTE5MjA1MjA0NjBxcXp6XFxcIjtcXG4gICAgICAgICAgICAgICAgLy8gZGVfYWVzXFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBDcnlwdG9KUy5lbmMuVXRmOC5wYXJzZShpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGhleFZhbCA9IENyeXB0b0pTLmVuYy5IZXgucGFyc2UodnYpLFxcbiAgICAgICAgICAgICAgICAgICAgdmFsID0gQ3J5cHRvSlMuZW5jLkJhc2U2NC5zdHJpbmdpZnkoaGV4VmFsKSxcXG4gICAgICAgICAgICAgICAgICAgIGRlY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHZhbCwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaXY6IGtleSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkNCQyxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZGVjcnlwdGVkLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtc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AgICAgICAgICAgdSA9IHUubGVuZ3RoID4gMCA/IHVbMF0gOiB1cmw7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogcGRmaChpdCwgXFxcIi5jYXJkLXRpdGxlJiZUZXh0XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBwZChpdCwgXFxcImltZyYmc3JjXFxcIiwgdXJsKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHBkZmgoaXQsIFxcXCIuY2FyZC10ZXh0LC0xJiZUZXh0XFxcIikgKyBcXFwiXFxcXG5cXFwiICsgdSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwiVVDkupHmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vYXBpLnVweXVuc28yLmNvbS9zZWFyY2g/a2V5d29yZD1cXFwiICsgcyArIFxcXCImcGFnZT1cXFwiICsgcGFnZSArIFxcXCImc190eXBlPTFcXFwiO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cudXB5dW5zby5jb21cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIkNvb2tpZVxcXCI6IFxcXCJjb2RlPTE5MTlcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAvL2xvZyhiYXNlNjREZWNvZGUoaHRtbCkpO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShodG1sKSkucmVzdWx0Lml0ZW1zO1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBpZiAoIWFycikgcmV0dXJuIFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBpdC5wYWdlX3VybDtcXG4gICAgICAgICAgICAgICAgLy91ID0gdS5sZW5ndGggPiAwID8gdVswXSA6IHVybDtcXG4gICAgICAgICAgICAgICAgaWYgKCF1LmluY2x1ZGVzKFxcXCJhbGl5dW5kcml2ZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArICh1KSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi54yr54u455uY5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChcXFwiaHR0cHM6Ly93d3cuYWxpcGFuc291LmNvbS9zZWFyY2g/az1cXFwiICsgcywge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGlwYW5zb3UuY29tL3NlYXJjaD9rPVxcXCIgKyBzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gcGRmYShodG1sLCBcXFwiI2FwcCYmYVxcXCIpO1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBcXFwiPGRpdj5cXFwiICsgYXJyW2ldICsgXFxcIjwvZGl2PlxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGRmaChpdCwgXFxcImEmJmhyZWZcXFwiKTtcXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGlmICghdS5pbmNsdWRlcyhcXFwiL3MvXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHUgPSBcXFwiaHR0cHM6Ly93d3cuYWxpcGFuc291LmNvbVxcXCIgKyB1LnJlcGxhY2UoXFxcIi9zL1xcXCIsIFxcXCIvY3YvXFxcIik7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogcGRmaChpdCwgXFxcInRlbXBsYXRlJiZUZXh0XFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwZGZoKGl0LCBcXFwidGVtcGxhdGUsMSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChpbnB1dCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogXFxcIm5vX3Nob3dfZG9uYXRlPTFcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBpbnB1dC5yZXBsYWNlKFxcXCIvY3YvXFxcIiwgXFxcIi9zL1xcXCIpXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIHJlZGlyZWN0OiBmYWxzZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGh0bWwgPSBwYXJzZURvbUZvckh0bWwoaHRtbCwgJ2EmJmhyZWYnKTtcXG4gICAgICAgICAgICBpZiAoaHRtbC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBodG1sO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBpbnB1dDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLmmJPmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIHJlZ2lzdGVyVXJsOiBcXFwiaHR0cHM6Ly95aXNvLmZ1blxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG4gICAgICAgICAgICBsZXQgQ3J5cHRvSlMgPSBhbGlVdGlsLmdldENyeXB0b0pTKCk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Cd5aXNvdWNvb2tlJywgJycpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAvL2xvZyhodG1sKTtcXG4gICAgICAgICAgICBpZiAoaHRtbC5pbmNsdWRlcygn55m75b2V55So5oi35peg6ZmQ5Yi2JykpIHtcXG4gICAgICAgICAgICAgICAgdmFyIGkgPSAwO1xcbiAgICAgICAgICAgICAgICBkbyB7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgdHlpbWdsaW4gPSAnaHR0cHM6Ly95aXNvLmZ1bi9hcGkvdXNlci9sb2dpbi9jYXB0Y2hhP3Q9JyArIHBhcnNlSW50KG5ldyBEYXRlKCkuZ2V0VGltZSgpKSArICcnO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGltZyA9IGNvbnZlcnRCYXNlNjRJbWFnZSh0eWltZ2xpbikuc3BsaXQoJywnKVsxXTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb2QgPSByZXF1ZXN0KCdodHRwczovL2FwaS54aG9mZS50b3Avb2NyL2I2NC90ZXh0Jywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZSc6ICd0ZXh0L3BsYWluJ1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgYm9keTogaW1nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIHZhciB2ZXIgPSBKU09OLnBhcnNlKHJlcXVlc3QoJ2h0dHBzOi8veWlzby5mdW4vYXBpL3VzZXIvbG9naW4nLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnY29udGVudC10eXBlJzogJ2FwcGxpY2F0aW9uL2pzb24nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAncmVmZXJlcic6ICdodHRwczovL3lpc28uZnVuL2xvZ2luJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ0Nvb2tpZSc6IGdldENvb2tpZSh0eWltZ2xpbilcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcInVzZXJOYW1lXFxcIjogdXNlci5hY2NvdW50LFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwicGFzc3dvcmRcXFwiOiB1c2VyLnBhc3N3b3JkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiY29kZVxcXCI6IGNvZFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAnUE9TVCdcXG4gICAgICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh2ZXIuY29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb2coJ+aYk+aQnOeZu+WFpemqjOivgeaIkOWKnycpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oJ3lpc291Y29va2UnLCBnZXRDb29raWUoJ2h0dHBzOi8veWlzby5mdW4nKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaHRtbCA9IHJlcXVlc3QoXFxcImh0dHBzOi8veWlzby5mdW4vYXBpL3NlYXJjaD9uYW1lPVxcXCIgKyBzICsgXFxcIiZwYWdlTm89XFxcIiArIHBhZ2UsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly95aXNvLmZ1bi9pbmZvP3NlYXJjaEtleT1cXFwiICsgcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJDb29raWVcXFwiOiBnZXRJdGVtKCd5aXNvdWNvb2tlJywgJycpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGkrKztcXG4gICAgICAgICAgICAgICAgfSB3aGlsZSAoaSA8IDQpO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShodG1sKS5kYXRhLmxpc3Q7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBrZXllbihpdC51cmwpO1xcbiAgICAgICAgICAgICAgICAvL2xvZyh1KTtcXG4gICAgICAgICAgICAgICAgaWYgKHUgPT0gbnVsbCB8fCAhdS5pbmNsdWRlcyhcXFwiYWxpeXVuXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IChpdC5nbXRTaGFyZSB8fCBpdC5nbXRDcmVhdGUpICsgXFxcIlxcXFxuXFxcIiArICh1KSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5bCP57q45p2hXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZ2V0dG9rZW4oKSB7XFxuICAgICAgICAgICAgICAgIGlmIChnZXRNeVZhcigneHp5dG9rZW4nLCAnJykubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB0b2tlbiA9IEpTT04ucGFyc2UocG9zdCgnaHR0cHM6Ly9naXRjYWZlLm5ldC90b29sL2FsaXBhcGVyLycsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vdS5naXRjYWZlLmluay8nXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogJ2dldF90b2tlbidcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KSkuZGF0YTtcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKCd4enR0b2tlbicsIHRva2VuKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TXlWYXIoJ3h6dHRva2VuJywgJycpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBjYXRfY29kZShhKSB7XFxuICAgICAgICAgICAgICAgIHZhciBkLCBlLCBiID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gICAgICAgICAgICB0b2tlbjogZ2V0dG9rZW4oKSxcXG4gICAgICAgICAgICAgICAgICAgIGtleXdvcmQ6IHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBKU09OLnBhcnNlKGh0bWwpO1xcbiAgICAgICAgICAgIGlmIChsaXN0LmRhdGEpIHtcXG4gICAgICAgICAgICAgICAgbGlzdCA9IGxpc3QuZGF0YTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGxpc3RbaV1cXG4gICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gaXQudGl0bGU7XFxuICAgICAgICAgICAgICAgIGxldCBtdXJsID0gJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zLycgKyBpdC5hbGlrZXlcXG4gICAgICAgICAgICAgICAgaWYgKCFhbGlVdGlsLmNoZWNrYWxpKG11cmwpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAodGl0bGUuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLiiJogXFxcIiArIHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGNhdF9jb2RlKGl0LmNhdCksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzOiBpdC5kZXNcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogbXVybFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICA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wgYmFzaWNVcmwpO1xcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdXRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogdWltYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogdXNlcmlhbFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHBkZmEocmVxdWVzdChpbnB1dCksIFxcXCJib2R5JiYubW9kdWxlLXJvdy10ZXh0LmNvcHlcXFwiKS5tYXAodiA9PiBwZGZoKHYsIFxcXCJhJiZkYXRhLWNsaXBib2FyZC10ZXh0XFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi6Zi/6YeM5LqR55uY572RXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBiYXNpY1VybDogXFxcImh0dHBzOi8vd3d3LmFseXB3LmNuXFxcIixcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gYmFzaWNVcmwgKyBcXFwiL3NlYXJjaC5waHA/cT1cXFwiICsgcyArIFxcXCImcGFnZT1cXFwiICsgcGFnZTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7fSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIi5saXN0JiZsaVxcXCIpO1xcbiAgICAgICAgICAgIGxldCBiZXQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1dGl0bGUgPSBwZGZoKGl0LCBcXFwiYSYmdGl0bGVcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVzZXJpYWwgPSBwZGZoKGl0LCBcXFwiLmZhLWNsb2NrLW8mJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpbWFnZSA9IHBkZmgoaXQsIFxcXCJpbWcmJnNyY1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkKGl0LCBcXFwiYSYmaHJlZlxcXCIsIGJhc2ljVXJsKTtcXG4gICAgICAgICAgICAgICAgaWYgKCF1dGl0bGUuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGJldC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB1dGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiB1aW1hZ2UsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiB1c2VyaWFsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICByZXR1cm4gYmV0O1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICByZXR1cm4gcGRmYShyZXF1ZXN0KGlucHV0KSwgXFxcImJvZHkmJmFbaHJlZl49aHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXVxcXCIpLm1hcCh2ID0+IHBkZmgodiwgXFxcImEmJmhyZWZcXFwiKSk7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLlnJ/mi6jpvKBcXFwiLFxcbiAgICAgICAgcGFnZTogZmFsc2UsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSBmZXRjaCgnaHR0cHM6Ly93d3cudGJzZHkuY29tL3NlYXJjaC5odG1sP2tleXdvcmQ9JyArIHMgKyAnJmNhdGVnb3J5PTk4MzkyMCZkYXRhX3R5cGU9OTg3OTEwJywge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnVXNlci1BZ2VudCc6IFBDX1VBXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBsZXQgYXJyID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCAnLnNlYXJjaF9yZXN1bHRfbmV0ZGlza19saXN0JiZhJyk7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIC8vbG9nKGl0KTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwYXJzZURvbUZvckh0bWwoaXQsICdhJiZocmVmJyk7XFxuICAgICAgICAgICAgICAgIGxldCB0aXQgPSBwYXJzZURvbUZvckh0bWwoaXQsICcubmV0ZGlza19pdGVtX2RldGFpbF9uYW1lJiZUZXh0Jyk7XFxuICAgICAgICAgICAgICAgIGlmICghdGl0LmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAvL2xvZyh1KTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXQsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBcXFwiXFxcXG5cXFwiICsgdSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi6Zi/6YeM5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoJ2h0dHBzOi8vYWxpc28uY2Mvcy8nICsgcyArICctJyArIHBhZ2UgKyAnLTAuaHRtbCcsIHt9KTtcXG5cXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgJy5zZWFyY2gtcmVzdWx0JiYucmVzb3VyY2UtaXRlbScpO1xcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbGlzdC5sZW5ndGg7IGorKykge1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IGxpc3Rbal07XFxuICAgICAgICAgICAgICAgIGxldCB0aXQgPSBwYXJzZURvbUZvckh0bWwodSwgJ2gzJiZUZXh0Jyk7XFxuICAgICAgICAgICAgICAgIGlmICghdGl0LmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdCxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogcGFyc2VEb20odSwgJ2gzJiZhJiZocmVmJywgJ2h0dHBzOi8vYWxpc28uY2MvJyksXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwYXJzZURvbUZvckh0bWwodSwgJy50aW1lJiZUZXh0JyksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgZXZhbChnZXRDcnlwdG9KUygpKTtcXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBkZWNyeShzdHIpIHtcXG4gICAgICAgICAgICAgICAgdmFyIGtleSA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKFxcXCI5RUIyMERERkQ2QUZCRDY4XFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBlbmNyeXB0ZWQgPSBDcnlwdG9KUy5BRVMuZGVjcnlwdChzdHIsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgaXY6IGtleSxcXG4gICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuQ0JDLFxcbiAgICAgICAgICAgICAgICAgICAgcGFkZGluZzogQ3J5cHRvSlMucGFkLlBrY3M3XFxuICAgICAgICAgICAgICAgIH0pLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVuY3J5cHRlZDtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KGlucHV0KTtcXG4gICAgICAgICAgICBsZXQgYnV0ID0gcGFyc2VEb20oaHRtbCwgJy5idXR0b24mJmhyZWYnLCAnaHR0cHM6Ly9hbGlzby5jYy8nKTtcXG4gICAgICAgICAgICAvL2xvZyhidXQpO1xcbiAgICAgICAgICAgIGxldCBnb3QgPSByZXF1ZXN0KGJ1dCk7XFxuICAgICAgICAgICAgLy9sb2coZ290KTtcXG4gICAgICAgICAgICBldmFsKHBhcnNlRG9tRm9ySHRtbChnb3QsICdoZWFkJiZzY3JpcHQsMSYmSHRtbCcpKTtcXG4gICAgICAgICAgICByZXR1cm4gZGVjcnkoYmFzZTY0LnNwbGl0KCchJylbMF0pO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5LqR55uY5YiG5Lqr56S+XFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGRlY3J5KHN0cikge1xcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjVGNkIyQUszM0RBU0QxMjNcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGVuY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHN0ciwga2V5LCB7XFxuICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkVDQixcXG4gICAgICAgICAgICAgICAgICAgIHBhZGRpbmc6IENyeXB0b0pTLnBhZC5Qa2NzN1xcbiAgICAgICAgICAgICAgICB9KS50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlbmNyeXB0ZWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vYXBpL2Jicy9hcGkvZ2V0ZGF0YT9rZXk9XFxcIiArIHMgKyBcXFwiJnR5cGU9dmlkZW9cXFwiLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3Lnl1bnBhbmZlbnhpYW5nLmNuL1xcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBqc29uID0gZGVjcnkoSlNPTi5wYXJzZShodG1sKS5kYXRhKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShqc29uKTtcXG5cXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXJsID0gaXQucGlkO1xcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJodHRwczovL3d3dy55dW5wYW5mZW54aWFuZy5jbi9hcGkvYmJzL2FwaS9nZXRhcnRpY2xlP2lkPVxcXCIgKyB1cmwsXFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC5jcmVhdGV0aW1lXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICByZXR1cm4gYmV0O1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UocmVxdWVzdChpbnB1dCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy55dW5wYW5mZW54aWFuZy5jbi9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KSkuZG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Kykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnYVtocmVmXj1odHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy9dJiZocmVmJyk7XFxuICAgICAgICAgICAgICAgIGxldCBwaWNfdXJsID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnaW1nJiZzcmMnKTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBwYXJzZURvbUZvckh0bWwoaXQsICcuYnJlYWstYWxsJiZUZXh0Jykuc3BsaXQoJ2h0dHAnKVswXSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBpY191cmwgPT09IFxcXCIvZmF2aWNvbi5wbmdcXFwiID8gXFxcImh0dHBzOi8vd3d3LnBhbnNlYXJjaC5tZS9cXFwiICsgcGljX3VybCA6IHBpY191cmwsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwYXJzZURvbUZvckh0bWwoaXQsICdwJiZUZXh0JykgKyBcXFwiXFxcXG5cXFwiICsgdSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwiRE9WWOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vYXBpLmRvdngudGsvYWxpL3NlYXJjaD93ZD1cXFwiICsgcztcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShodG1sKS5saXN0O1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gaXQudm9kX2NvbnRlbnQ7XFxuICAgICAgICAgICAgICAgIGlmICghdS5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSB8fCAhYWxpVXRpbC5jaGVja2FsaSh1KSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oiaIFxcXCIgKyBpdC52b2RfbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBcXFwiXFxcXG5cXFwiICsgdSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5b+F5bqUXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2NuLmJpbmcuY29tL3NlYXJjaD9xPVxcXCIgKyBzICsgXFxcIithbGl5dW5kcml2ZSZxcz1kcyZmb3JtPVFCUkVcXFwiO1xcbiAgICAgICAgICAgIGlmIChwYWdlICE9IDEpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gZ2V0TXlWYXIoXFxcImJpbmdcXFwiLCB1cmwpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vY24uYmluZy5jb20vXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIC8vXFxcIlgtUmVxdWVzdGVkLVdpdGhcXFwiOiBcXFwiY29tLmV4YW1wbGUuaGlrZXJ2aWV3XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJBY2NlcHRcXFwiOiBcXFwidGV4dC9odG1sLGFwcGxpY2F0aW9uL3hodG1sK3htbCxhcHBsaWNhdGlvbi94bWw7cT0wLjksaW1hZ2UvYXZpZixpbWFnZS93ZWJwLGltYWdlL2FwbmcsKi8qO3E9MC44LGFwcGxpY2F0aW9uL3NpZ25lZC1leGNoYW5nZTt2PWIzO3E9MC45XFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcImJvZHkmJmFcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkKGl0LCBcXFwiYSYmaHJlZlxcXCIsIHVybCk7XFxuICAgICAgICAgICAgICAgIGxldCB0ID0gcGRmaChpdCwgXFxcImEmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgaWYgKGl0LmluY2x1ZGVzKFxcXCJOZXh0IHBhZ2VcXFwiKSB8fCBpdC5pbmNsdWRlcyhcXFwi5LiL5LiA6aG1XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB1MiA9IHBkKGl0LCBcXFwiYSYmaHJlZlxcXCIsIHVybCk7XFxuICAgICAgICAgICAgICAgICAgICAvL2xvZyhcXFwibmV4dCBwYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAvL2xvZyh1Mik7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiYmluZ1xcXCIsIHUyKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAodSA9PSBudWxsIHx8IHQgPT0gbnVsbCB8fCAhaXQuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmICghaXQuaW5jbHVkZXMoXFxcIue9keebmFxcXCIpICYmICFpdC5pbmNsdWRlcyhcXFwi5LqR55uYXFxcIikgJiZcXG4gICAgICAgICAgICAgICAgICAgICFpdC5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSAmJiAhaXQuaW5jbHVkZXMoXFxcInl1bnBhblxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAodS5zdGFydHNXaXRoKFxcXCJodHRwczovL2NuLmJpbmcuY29tL1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgZG9tID0gZ2V0SG9tZSh1KS5yZXBsYWNlKFxcXCJodHRwOi8vXFxcIiwgXFxcIlxcXCIpLnJlcGxhY2UoXFxcImh0dHBzOi8vXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgX2xpbmtzID0gdC5tYXRjaCgvaHR0cHM6XFxcXC9cXFxcLyh3d3dcXFxcLmFsaXl1bmRyaXZlXFxcXC5jb21cXFxcL3N8YWx5d3BcXFxcLm5ldClcXFxcL1xcXFx3Ki9nKSB8fCBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBudWxsO1xcbiAgICAgICAgICAgICAgICBpZiAoX2xpbmtzLmxlbmd0aCA+IDEgJiYgX2xpbmtzWzFdLnJlcGxhY2UoX2xpbmtzWzBdLCBcXFwiXFxcIikucmVwbGFjZSgvW2EtekEtWjAtOV0rL2csIFxcXCJcXFwiKSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgYyA9IF9saW5rc1sxXTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChfbGlua3MubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgYyA9IF9saW5rc1swXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHQsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBkb20sXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGMgIT0gbnVsbCA/IGMgOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L+b5YWl572R56uZXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudCh1KSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGlmIChpbnB1dC5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSkgcmV0dXJuIGlucHV0O1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChpbnB1dCk7XFxuICAgICAgICAgICAgdmFyIF9saW5rcyA9IGh0bWwubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgaWYgKF9saW5rcy5sZW5ndGggPiAxICYmIF9saW5rc1sxXS5yZXBsYWNlKF9saW5rc1swXSwgXFxcIlxcXCIpLnJlcGxhY2UoL1thLXpBLVowLTldKy9nLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIF9saW5rc1sxXTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKF9saW5rcy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBfbGlua3NbMF07XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiAnQ0NPRicsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBkID0gW11cXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gZmV0Y2goJ2h0dHBzOi8vcGFuLmNjb2YuY2MvYXBpL3NlYXJjaCcsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcImNvbnRlbnQtdHlwZVxcXCI6ICdhcHBsaWNhdGlvbi9qc29uJyxcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vcGFuLmNjb2YuY2Mvc2VhcmNoP2tleXdvcmQ9JyArIHNcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VTaXplXFxcIjogMjAsXFxuICAgICAgICAgICAgICAgICAgICBcXFwicGFnZU51bVxcXCI6IHBhZ2UsXFxuICAgICAgICAgICAgICAgICAgICBcXFwia2V5d29yZFxcXCI6IHMsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiZnJvbU1vYmlsZVxcXCI6IHRydWVcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kOiAnUE9TVCdcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKVxcbiAgICAgICAgICAgICAgICAuZGF0YS5yb3dzXFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0LmZpbGVOYW1lXFxuICAgICAgICAgICAgICAgIGxldCBtdXJsID0gaXQudXJsXFxuICAgICAgICAgICAgICAgIGxldCB0eXBlID0gaXQudHlwZS5yZXBsYWNlKC9mb2xkZXIvLCAn5paH5Lu25aS5JykucmVwbGFjZSgvZmlsZS8sICfmlofku7YnKVxcbiAgICAgICAgICAgICAgICBpZiAodGl0bGUuaW5jbHVkZXMocykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6ICfmlofku7bnsbvlnovvvJonICsgdHlwZSArICfvvIzmlofku7blpKflsI/vvJonICsgYWxpVXRpbC5ieXRlc1RvU2l6ZShpdC5zaXplKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IG11cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGRcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogJ+mYv+mHjOWwj+ermScsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBob21lID0gXFxcImh0dHBzOi8vcGFuNjY2Lm5ldFxcXCI7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoYnVpbGRVcmwoaG9tZSArIFxcXCIvYXBpL2Rpc2N1c3Npb25zXFxcIiwge1xcbiAgICAgICAgICAgICAgICBcXFwiaW5jbHVkZVxcXCI6IFxcXCJ1c2VyLGxhc3RQb3N0ZWRVc2VyLG1vc3RSZWxldmFudFBvc3QsbW9zdFJlbGV2YW50UG9zdC51c2VyLHRhZ3MsdGFncy5wYXJlbnQsZmlyc3RQb3N0XFxcIixcXG4gICAgICAgICAgICAgICAgXFxcImZpbHRlcltxXVxcXCI6IHMgLyogKyBcXFwiIHRhZzp2aWRlbyxjb21pY1xcXCIqLyAsXFxuICAgICAgICAgICAgICAgIC8vXFxcImZpbHRlclt0YWddXFxcIjogXFxcInZpZGVvLGNvbWljXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcInBhZ2Vbb2Zmc2V0XVxcXCI6IDIwICogKHBhZ2UgLSAxKVxcbiAgICAgICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb250ZW50LXR5cGVcXFwiOiBcXFwiYXBwbGljYXRpb24vanNvblxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3BhbjY2Ni5uZXQvP3E9XFxcIiArIHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKS5kYXRhO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV0uYXR0cmlidXRlcztcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGhvbWUgKyBcXFwiL2QvXFxcIiArIGl0ZW0uc2x1ZztcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogJ+WPkeW4g+aXtumXtO+8micgKyAkLmRhdGVGb3JtYXQobmV3IERhdGUoaXRlbS5jcmVhdGVkQXQpLCBcXFwieXl5eS1NTS1kZCBISDptbTpzc1xcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLov5vlhaXluJblrZBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHVybCkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHBkZmgocmVxdWVzdChpbnB1dCksIFxcXCJUZXh0XFxcIik7XFxuICAgICAgICAgICAgbGV0IF9saW5rcyA9IGh0bWwubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgbGV0IHNoYXJlUHdkID0gaHRtbC5tYXRjaCgv5o+Q5Y+W56CBWzrvvJpdXFxcXHMqPyhcXFxcd3s0fSkvKTtcXG4gICAgICAgICAgICBzaGFyZVB3ZCA9IEFycmF5LmlzQXJyYXkoc2hhcmVQd2QpICYmIHNoYXJlUHdkLmxlbmd0aCA+IDAgPyBzaGFyZVB3ZFsxXSA6IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIGlmIChfbGlua3MubGVuZ3RoID4gMSAmJiBfbGlua3NbMV0ucmVwbGFjZShfbGlua3NbMF0sIFxcXCJcXFwiKS5yZXBsYWNlKC9bYS16QS1aMC05XSsvZywgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBhbGlVcmw6IF9saW5rc1sxXSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoX2xpbmtzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaVVybDogX2xpbmtzWzBdLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiAn5LqR55uY5YiG5Lqr56S+5Yy6JyxcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IGhvbWUgPSBcXFwiaHR0cHM6Ly95dW5wYW4xLmNjXFxcIjtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChidWlsZFVybChob21lICsgXFxcIi9hcGkvZGlzY3Vzc2lvbnNcXFwiLCB7XFxuICAgICAgICAgICAgICAgIFxcXCJpbmNsdWRlXFxcIjogXFxcInVzZXIsbGFzdFBvc3RlZFVzZXIsbW9zdFJlbGV2YW50UG9zdCxtb3N0UmVsZXZhbnRQb3N0LnVzZXIsdGFncyx0YWdzLnBhcmVudCxmaXJzdFBvc3RcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwiZmlsdGVyW3FdXFxcIjogcyAvKiArIFxcXCIgdGFnOnZpZGVvLGNvbWljXFxcIiovICxcXG4gICAgICAgICAgICAgICAgLy9cXFwiZmlsdGVyW3RhZ11cXFwiOiBcXFwidmlkZW8sY29taWNcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwicGFnZVtvZmZzZXRdXFxcIjogMjAgKiAocGFnZSAtIDEpXFxuICAgICAgICAgICAgfSksIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcImNvbnRlbnQtdHlwZVxcXCI6IFxcXCJhcHBsaWNhdGlvbi9qc29uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vcGFuNjY2Lm5ldC8/cT1cXFwiICsgc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBKU09OLnBhcnNlKGh0bWwpLmRhdGE7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtID0gbGlzdFtpXS5hdHRyaWJ1dGVzO1xcbiAgICAgICAgICAgICAgICBsZXQgdXJsID0gaG9tZSArIFxcXCIvZC9cXFwiICsgaXRlbS5zbHVnO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiAn5Y+R5biD5pe26Ze077yaJyArICQuZGF0ZUZvcm1hdChuZXcgRGF0ZShpdGVtLmNyZWF0ZWRBdCksIFxcXCJ5eXl5LU1NLWRkIEhIOm1tOnNzXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHVybCxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui/m+WFpeW4luWtkFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQodXJsKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcGRmaChyZXF1ZXN0KGlucHV0KSwgXFxcIlRleHRcXFwiKTtcXG4gICAgICAgICAgICBsZXQgX2xpbmtzID0gaHRtbC5tYXRjaCgvaHR0cHM6XFxcXC9cXFxcLyh3d3dcXFxcLmFsaXl1bmRyaXZlXFxcXC5jb21cXFxcL3N8YWx5d3BcXFxcLm5ldClcXFxcL1xcXFx3Ki9nKSB8fCBbXTtcXG4gICAgICAgICAgICBsZXQgc2hhcmVQd2QgPSBodG1sLm1hdGNoKC/mj5Dlj5bnoIFbOu+8ml1cXFxccyo/KFxcXFx3ezR9KS8pO1xcbiAgICAgICAgICAgIHNoYXJlUHdkID0gQXJyYXkuaXNBcnJheShzaGFyZVB3ZCkgJiYgc2hhcmVQd2QubGVuZ3RoID4gMCA/IHNoYXJlUHdkWzFdIDogXFxcIlxcXCI7XFxuICAgICAgICAgICAgaWYgKF9saW5rcy5sZW5ndGggPiAxICYmIF9saW5rc1sxXS5yZXBsYWNlKF9saW5rc1swXSwgXFxcIlxcXCIpLnJlcGxhY2UoL1thLXpBLVowLTldKy9nLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaVVybDogX2xpbmtzWzFdLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChfbGlua3MubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpVXJsOiBfbGlua3NbMF0sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2RcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sIHtcXG4gICAgICAgIG5hbWU6IFxcXCLniLHnnIvnvo7liadcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vd3d3LjJrbWouY24vc2VhcmNoLnBocD9xPVxcXCIgKyBzICsgXFxcIiZwYWdlL1xcXCIgKyBwYWdlICsgXFxcIi9cXFwiO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwpO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsIFxcXCIubGlzdC1pdCYmbGlcXFwiKTtcXG5cXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGFyc2VEb21Gb3JIdG1sKGl0LCBcXFwiYSYmdGl0bGVcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVzZXJpYWwgPSBwYXJzZURvbUZvckh0bWwoaXQsIFxcXCIuaW5mbyYmc3Bhbjpub3QoOmhhcyhhKSktLWkmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpbWFnZSA9IHBhcnNlRG9tKGl0LCBcXFwiaW1nJiZzcmNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwYXJzZURvbShpdCwgXFxcImEmJmhyZWZcXFwiKTtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHV0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHVpbWFnZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHVzZXJpYWxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJldHVybiBiZXQ7XFxuXFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIHJldHVybiBwZGZhKHJlcXVlc3QoaW5wdXQpLCBcXFwiYm9keSYmI2Rvd25sb2FkXFxcIikubWFwKHYgPT4gcGRmaCh2LCBcXFwiLmRvd24mJmhyZWZcXFwiKSk7XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6IFxcXCLlpYflppnmkJzntKJcXFwiLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmw7XFxuICAgICAgICAgICAgaWYgKHBhZ2UgPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gYnVpbGRVcmwoXFxcImh0dHBzOi8vd3d3Lm1hZ2ljYWxzZWFyY2gudG9wL2FwaS9wc2hvdS9nZXREYXRhXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgd29yZDogcyxcXG4gICAgICAgICAgICAgICAgICAgIHR5cGU6IFxcXCLpmL/ph4znvZHnm5hcXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IGJ1aWxkVXJsKFxcXCJodHRwczovL3d3dy5tYWdpY2Fsc2VhcmNoLnRvcC9hcGkvcHNob3UvZ2V0TmV4dFBhZ2VcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJodHRwczovL2FwaS51cHl1bnNvMi5jb20vc2VhcmNoP3NfdHlwZT0yQHBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiQGtleXdvcmQ9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChzKSxcXG4gICAgICAgICAgICAgICAgICAgIHdlYnNpdGU6IFxcXCLpmL/ph4znvZHnm5hcXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcmVzdWx0ID0gcmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgUmVmZXJlcjogYnVpbGRVcmwoXFxcImh0dHBzOi8vd3d3Lm1hZ2ljYWxzZWFyY2gudG9wL3NlYXJjaFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB3b3JkOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNwYWdlOiAwXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmVzdWx0ID0gSlNPTi5wYXJzZShKU09OLnBhcnNlKHJlc3VsdCkpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcmVzdWx0LnJlc3VsdC5pdGVtcztcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGl0LmlkID09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIuaXpeacn++8mlxcXCIgKyBpdC5pbnNlcnRfdGltZSArIFxcXCJcXFxcbui3r+W+hO+8mlxcXCIgKyBpdC5wYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpdC5wYWdlX3VybFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9XFxuICAgIH1cXG5dO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi5paH5Lu25o6S5bqPXCIsXCJwYXRoXCI6XCJGaWxlU29ydGluZ1wiLFwicnVsZVwiOlwibGV0IGNobk51bUNoYXIgPSB7XFxuICAgIOmbtjogMCxcXG4gICAg5LiAOiAxLFxcbiAgICDkuow6IDIsXFxuICAgIOS4iTogMyxcXG4gICAg5ZubOiA0LFxcbiAgICDkupQ6IDUsXFxuICAgIOWFrTogNixcXG4gICAg5LiDOiA3LFxcbiAgICDlhas6IDgsXFxuICAgIOS5nTogOVxcbn07XFxuXFxubGV0IGNobk5hbWVWYWx1ZSA9IHtcXG4gICAg5Y2BOiB7XFxuICAgICAgICB2YWx1ZTogMTAsXFxuICAgICAgICBzZWNVbml0OiBmYWxzZVxcbiAgICB9LFxcbiAgICDnmb46IHtcXG4g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ICAgIHB1dE15VmFyKFxcXCJMb2dnaW5naW5cXFwiLCBcXFwidHJ1ZVxcXCIpO1xcbiAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOiOt+WPluS6jOe7tOeggVxcXCIpO1xcblxcbiAgICAgICAgZnVuY3Rpb24gZ2V0X3FyY29kZV9zdGF0dXMoc2lkKSB7XFxuICAgICAgICAgICAgbGV0IHJlcyA9IGZldGNoKFxcXCJodHRwczovL29wZW5hcGkuYWxpeXVuZHJpdmUuY29tL29hdXRoL3FyY29kZS9cXFwiICsgc2lkICsgXFxcIi9zdGF0dXNcXFwiKTtcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5wYXJzZShyZXMpO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgZnVuY3Rpb24gZ2V0X3JlZnJlc2hfdG9rZW4oY29kZSkge1xcbiAgICAgICAgICAgIGxldCByZXMgPSBwb3N0KFxcXCJodHRwczovL2FsaXl1bmRyaXZlLW9hdXRoLm1lc3NlbnNlLm1lL29hdXRoL2FjY2Vzc190b2tlblxcXCIsIHtcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcImdyYW50X3R5cGVcXFwiOiBcXFwiYXV0aG9yaXphdGlvbl9jb2RlXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb2RlXFxcIjogY29kZSxcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGRhdGEgPSBKU09OLnBhcnNlKHJlcyk7XFxuICAgICAgICAgICAgcmV0dXJuIGRhdGFbXFxcInJlZnJlc2hfdG9rZW5cXFwiXTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCByZXMgPSBwb3N0KFxcXCJodHRwczovL2FsaXl1bmRyaXZlLW9hdXRoLm1lc3NlbnNlLm1lL29hdXRoL2F1dGhvcml6ZS9xcmNvZGVcXFwiLCB7XFxuICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICBcXFwic2NvcGVzXFxcIjogW1xcXCJ1c2VyOmJhc2VcXFwiLCBcXFwiZmlsZTphbGw6cmVhZFxcXCIsIFxcXCJmaWxlOmFsbDp3cml0ZVxcXCJdLFxcbiAgICAgICAgICAgICAgICBcXFwid2lkdGhcXFwiOiAzMDAsXFxuICAgICAgICAgICAgICAgIFxcXCJoZWlnaHRcXFwiOiAzMDAsXFxuICAgICAgICAgICAgfSksXFxuICAgICAgICB9KTtcXG4gICAgICAgIGxldCBkYXRhID0gSlNPTi5wYXJzZShyZXMpO1xcbiAgICAgICAgbGV0IHNpZCA9IGRhdGFbXFxcInNpZFxcXCJdO1xcbiAgICAgICAgbGV0IHFyY29kZV91cmwgPSBkYXRhW1xcXCJxckNvZGVVcmxcXFwiXTtcXG4gICAgICAgIHVwZGF0ZUl0ZW0oXFxcImluZm9PdXRwdXRcXFwiLCB7XFxuICAgICAgICAgICAgcGljX3VybDogcXJjb2RlX3VybCxcXG4gICAgICAgICAgICB1cmw6IHFyY29kZV91cmwgKyBcXFwiIy5qcGdcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwicGljXzFfZnVsbFxcXCJcXG4gICAgICAgIH0pO1xcbiAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJpbmZvT3V0cHV0XFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCY4oCY4oCZ4oCZXFxcIiArIFxcXCLkvb/nlKjpmL/ph4zkupHnm5ggQXBwIOaJq+eggVxcXCIuZm9udGNvbG9yKFxcXCJncmV5XFxcIiksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBjbHM6IFxcXCJsb2dpblxcXCJcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGRlbGV0ZUl0ZW0oXFxcImdldFFDXFxcIik7XFxuICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgbGV0IHJlZnJlc2hfdG9rZW47XFxuICAgICAgICB3aGlsZSAodHJ1ZSkge1xcbiAgICAgICAgICAgIGxldCBkYXRhO1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIGRhdGEgPSBnZXRfcXJjb2RlX3N0YXR1cyhzaWQpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+afpeivouaJq+eggee7k+aenOi2heaXtiwg5Y+v6IO95piv6Kem5Y+R5LqG6Zi/6YeM5LqR55uY5o6l5Y+j6ZmQ5Yi2LCDor7fnqI3lkI7lho3or5UuXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHN0YXR1cyA9IGRhdGFbXFxcInN0YXR1c1xcXCJdO1xcbiAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gXFxcIkxvZ2luU3VjY2Vzc1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaF90b2tlbiA9IGdldF9yZWZyZXNoX3Rva2VuKGRhdGFbXFxcImF1dGhDb2RlXFxcIl0pO1xcbiAgICAgICAgICAgICAgICBicmVha1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RhdHVzID09IFxcXCJRUkNvZGVFeHBpcmVkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LqM57u056CB5bey6L+H5pyfLCDor7fliLfmlrDpobXpnaLlkI7ph43or5VcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoIWdldE15VmFyKFxcXCJMb2dnaW5naW5cXFwiLCBcXFwiXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL2NhbmNlbFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTUwMCk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocmVmcmVzaF90b2tlbikge1xcbiAgICAgICAgICAgIGNvbnN0IHtcXG4gICAgICAgICAgICAgICAgb3BlblRva2Vuc0ZpbGVwYXRoLFxcbiAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcInRva2VuUGF0aFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBvcGVuID0ge1xcbiAgICAgICAgICAgICAgICBSZWZyZXNoVG9rZW5PcGVuOiByZWZyZXNoX3Rva2VuLFxcbiAgICAgICAgICAgICAgICBpc1YyOiB0cnVlXFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB3cml0ZUZpbGUob3BlblRva2Vuc0ZpbGVwYXRoLCBKU09OLnN0cmluZ2lmeShvcGVuKSk7XFxuICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJpbmZvT3V0cHV0XFxcIiwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIueZu+W9leaIkOWKnyjngrnlh7vov5Tlm54pXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCk9PntcXG4gICAgICAgICAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJsb2dpblxcXCIpO1xcblxcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9zdWNjZXNzXFxcIjtcX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cGkueGhvZmUudG9wL2FsaXN0L2FsaV9vcGVuL2NvZGUnLCB7XFxuICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAnVXNlci1BZ2VudCc6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJ1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoYm9keSksXFxuICAgICAgICB9KTtcXG4gICAgICAgIGlmICghanNvbikge1xcbiAgICAgICAgICAgIGpzb24gPSBwb3N0KCdodHRwczovL2FwaS1jZi5ubi5jaS9hbGlzdC9hbGlfb3Blbi9jb2RlJywge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBib2R5OiBKU09OLnN0cmluZ2lmeShib2R5KSxcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChqc29uLmluY2x1ZGVzKCdUb28gTWFueSBSZXF1ZXN0cycpIHx8IGpzb24uaW5jbHVkZXMoXFxcIjUwMiBCYWQgR2F0ZXdheVxcXCIpKSB7XFxuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLpopHnuYHor7fmsYLmmoLml7booqvlsIHnpoFcXFxcblxcXCIgKyBqc29uKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG9wZW5SZXN1bHQgPSBKU09OLnBhcnNlKGpzb24pO1xcbiAgICAgICAgICAgIHJldHVybiBvcGVuUmVzdWx0O1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICBnZXRPcGVuVG9rZW4oKSB7XFxuICAgICAgICByZXR1cm4gdGhpcy5nZXRUb2tlbih7XFxuICAgICAgICAgICAgY29kZTogdGhpcy5nZXRPcGVuVG9rZW5Db2RlKCksXFxuICAgICAgICAgICAgZ3JhbnRfdHlw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4gICAgICAgIGxldCBib2R5ID0ge1xcbiAgICAgICAgICAgIFxcXCJhdXRob3JpemVcXFwiOiAxLFxcbiAgICAgICAgICAgIFxcXCJzY29wZVxcXCI6IFxcXCJ1c2VyOmJhc2UsZmlsZTphbGw6cmVhZCxmaWxlOmFsbDp3cml0ZVxcXCIsXFxuICAgICAgICAgICAgXFxcImRyaXZlc1xcXCI6IFtcXFwiYmFja3VwXFxcIiwgXFxcInJlc291cmNlXFxcIl0sXFxuICAgICAgICAgICAgXFxcInNjb3Blc1xcXCI6IFtcXFwidXNlcjpiYXNlXFxcIiwgXFxcImZpbGU6YWxsOnJlYWRcXFwiLCBcXFwiZmlsZTphbGw6d3JpdGVcXFwiXSxcXG4gICAgICAgICAgICBcXFwic2lkXFxcIjogc2lkXFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IHtcXG4gICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMuJHRoaXMucmVhY2Nlc3NUa1xcbiAgICAgICAgfTtcXG4gICAgICAgIGxldCByZXMyID0gdGhpcy4kdGhpcy5wb3N0QXBpKFxcXCJodHRwczovL29wZW4uYWxpeXVuZHJpdmUuY29tL29hdXRoL3VzZXJzL3FyY29kZS9hdXRob3JpemU/c2lkPVxcXCIgKyBzaWQpLmJvZHkoYm9keSkuaGVhZGVycyhoZWFkZXJzKS5lcnJvcldpdGhSZXRyeSgoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIHRoaXMuJHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLiR0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgcmV0dXJuIGdldF9xcmNvZGVfY29kZShzaWQpO1xcbiAgICB9LFxcbiAgICBnZXRUb2tlbihib2R5KSB7XFxuICAgICAgICBsZXQgdXJsID0gXFxcIlxcXCI7XFxuICAgICAgICBpZiAoYm9keS5jb2RlKSB7XFxuICAgICAgICAgICAgdXJsID0gYnVpbGRVcmwoXFxcImh0dHA6Ly8xNTkuNzUuMjA4LjQ3L2Nsb3VkaXNrL2FwaS9vYXV0aC9hY2Nlc3NUb2tlblxcXCIsIHtcXG4gICAgICAgICAgICAgICAgYXV0aENvZGU6IGJvZHkuY29kZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICB1cmwgPSBidWlsZFVybChcXFwiaHR0cDovLzE1OS43NS4yMDguNDcvY2xvdWRpc2svYXBpL29hdXRoL2FjY2Vzc1Rva2VuXFxcIiwge1xcbiAgICAgICAgICAgICAgICByZWZyZXNoVG9rZW46IGJvZHkucmVmcmVzaF90b2tlblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHJlcyA9IGZldGNoKHVybCk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG4gICAgICAgIGxldCByZXQgPSB7XFxuICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogZGF0YS5yZWZyZXNoVG9rZW4sXFxuICAgICAgICAgICAgdG9rZW5fdHlwZTogZGF0YS50b2tlblR5cGUsXFxuICAgICAgICAgICAgYWNjZXNzX3Rva2VuOiBkYXRhLmFjY2Vzc1Rva2VuXFxuICAgICAgICB9O1xcbiAgICAgICAgcmV0dXJuIHJldDtcXG4gICAgfSxcXG4gICAgZ2V0T3BlblRva2VuKCkge1xcbiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0VG9rZW4oe1xcbiAgICAgICAgICAgIGNvZGU6IHRoaXMuZ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fSkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgc2V0TWFya2VyKCk7XFxuICAgICAgICBpZiAoTVlfUEFSQU1TLmlzSG9tZSkge1xcbiAgICAgICAgICAgIHNpZ25JblJld2FyZChhbGlBY2Nlc3NBcGkpO1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWkh+S7veebmFxcXCIgKyBbXFxcIlxcXCIsIFxcXCLiiJpcXFwiXVtOdW1iZXIoaXNCYWNrdXBEcml2aWQpXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm15QWxpUGFuRHJpdmlkXFxcIiwgXFxcInRydWVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzJcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui1hOa6kOebmFxcXCIgKyBbXFxcIuKImlxcXCIsIFxcXCJcXFwiXVtOdW1iZXIoaXNCYWNrdXBEcml2aWQpXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm15QWxpUGFuRHJpdmlkXFxcIiwgXFxcImZhbHNlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChzaGFyZUluZm8pIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzovazlrZjliLDlvZPliY3mlofku7blpLnigJ3igJ1cXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHNoYXJlSW5mbywgaXNCYWNrdXBEcml2aWQsIGZpbGVJZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgQWxpQWNjZXNzQXBpID0gJC5yZXF1aXJlKFxcXCJhbGlQbGF5QXBpXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgYWxpQWNjZXNzQXBpID0gQWxpQWNjZXNzQXBpLmNyZWF0ZURlZmF1bHQoc2hhcmVJbmZvLnNoYXJlSWQsIHNoYXJlSW5mby5zaGFyZVB3ZCwgc2hhcmVJbmZvLnNoYXJlVG9rZW4pO1xcbiAgICAgICAgICAgICAgICAgICAgYWxpQWNjZXNzQXBpLnNldE15RHJpdmlkVHlwZShpc0JhY2t1cERyaXZpZCk7XFxuICAgICAgICAgICAgICAgICAgICBhbGlBY2Nlc3NBcGkuY29weUZpbGVUb0Nsb3VkRmlsZShzaGFyZUluZm8uZmlsZUlkLCBmaWxlSWQpO1xcbiAgICAgICAgICAgICAgICAgICAgYmFja1RvSG9tZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgc2hhcmVJbmZvLCBpc0JhY2t1cERyaXZpZCwgZmlsZUlkKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghaXNTZWFyY2gpIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmkJzntKJcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC50cmltKCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl5YWz6ZSu6K+NXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL215YWxpeXVuI25vSGlzdG9yeSMjZnVsbFRoZW1lIz9wYWdlPWZ5cGFnZSZzZWFyY2hLZXk9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIG9uQ2hhbmdlOiBcXFwicHV0TXlWYXIoJ2xpc3RTZWFyY2hLZXknLGlucHV0KVxcXCIsXFxuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIHNlYXJjaEtleSArIFxcXCLigJ3igJ3nmoTmkJzntKLnu5PmnpxcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZnVuY0l0ZW1zID0gW107XFxuICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IHN0eWxlLFxcbiAgICAgICAgICAgIHVybDogJChzdHlsZXMsIDEsIFxcXCLmjpLluIPmoLflvI9cXFwiKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fc3R5bGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliIfmjaJcXFwiO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9pY29uLnN2Z1xcXCJcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogb3JkZXJOYW1lLFxcbiAgICAgICAgICAgIHVybDogJChvcmRlcnNLZXlzLCAyLCBcXFwi5o6S5bqP5pa55byPXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiYWxpeXVuX29yZGVyXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBwaWNfdXJsOiBcXFw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ZmFsc2UpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5YiH5o2i5Li6XFxcIiArIGlucHV0O1xcbiAgICAgICAgICAgIH0sIG9wZW5BUElMaXN0KSxcXG4gICAgICAgICAgICBwaWNfdXJsOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL2ltZy9hbGlfYXBpLnN2Z1xcXCIsXFxuICAgICAgICB9KTtcXG5cXG4gICAgICAgIGlmICghaXNTZWFyY2gpIHtcXG4gICAgICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yqf6IO9XFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFtcXFwi5p+l55yL5omL5Yqo5oyC6L295a2X5bmVXFxcIiwgXFxcIuiOt+WPluW8ueW5leaQnOe0ouinhOWImVxcXCIsIFxcXCLmibnph4/mjILovb3mnKzlnLDlvLnluZVcXFwiLCBcXFwi5o6o6YCB5YiwVFZCb3hcXFwiLCBcXFwi6K6+572u5pS26JeP5bCB6Z2iXFxcIiwgXFxcIuiOt+WPluaKleWxj0lQXFxcIiAvKiwgXFxcIuaegemAn+WOn+eUu+S4i+i9vee6v+eoi1xcXCIqLyBdLCAyLCBcXFwi5pu05aSa5Yqf6IO9XFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmibnph4/mjILovb3mnKzlnLDlvLnluZVcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9kbU1vdW50I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5p+l55yL5omL5Yqo5oyC6L295a2X5bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHptID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcIm1vdW50emltdVxcXCIsIHt9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRpcCA9IHptLm5hbWUgPyBcXFwi5b2T5YmN5a2X5bmV5paH5Lu2XFxcXG5cXFwiICsgem0ubmFtZSArIFxcXCIuXFxcIiArIHptLmV4dCA6IFxcXCLov5jmnKrmiYvliqjmjILovb3lrZfluZVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiAn5omL5Yqo5oyC6L295a2X5bmVJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRpcCArIFxcXCJcXFxcbijngrnlh7vlj5bmtojlj6/ku6XmuIXpmaTmjILovb3lrZfluZUpXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbmNlbDogKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcIm1vdW50emltdVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LmuIXpmaTmiYvliqjmjILovb3lrZfluZVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiOt+WPluW8ueW5leaQnOe0ouinhOWImVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcImpzXFxcIjogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS9sb2FkRG0/cnVsZT1cXFwiICsgTVlfUlVMRS50aXRsZSArIFxcXCImdGl0bGU9XFxcIikgKyBcXFwiK2VuY29kZVVSSUNvbXBvbmVudChwbGF5ZGF0YS50aXRsZS5zcGxpdCgnLScpWzBdKTtcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBNWV9SVUxFLnRpdGxlICsgXFxcIuW8ueW5leaQnOe0olxcXCJcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJydWxlOi8vXFxcIiArIGJhc2U2NEVuY29kZShcXFwi77+lcHJvamVjdGlvbl9zY3JlZW7vv6VcXFwiICsgSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuaOqOmAgeWIsFRWQm94XFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvdHZib3hQdXNoI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6K6+572u5pS26JeP5bCB6Z2iXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoW1xcXCLorr7nva7lsIHpnaLlnLDlnYBcXFwiLCBcXFwi5pCc57Si5bCB6Z2iXFxcIl0sIDEpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLorr7nva7lsIHpnaLlnLDlnYBcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIsIFxcXCLor7fovpPlhaXlm77niYflnLDlnYBcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl5Zyw5Z2AXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UGFnZVBpY1VybChpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kv67mlLnmiJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9mcm9udENvdmVyI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiOt+WPluaKleWxj0lQXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlwID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIikuZ2V0SVB2NEFkZHJlc3MoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlwLnN0YXJ0c1dpdGgoXFxcIjE5Mi4xNjguXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGlwICsgXFxcIlxcXFxu6K+lSVDpgILnlKjkuo7mtYHph48r54Ot54K555qE5oqV5bGPXFxcXG7or7fmm7/mjaLpk77mjqXkuK3nmoQwLjAuMC4wXFxcIikuY29uZmlybSgoaXApID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgaXA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBpcCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpcCArIFxcXCJcXFxcbuiOt+WPluWksei0pemdnueos+WumklQLOivt+W8gOWQr+eDreeCueWGjeS9v+eUqCzor6VJUOWPr+iDveS8muWPmCzkuI3og73mipXlsY9cXFwiKS5jb25maXJtKCgpID0+IHt9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuaegemAn+WOn+eUu+S4i+i9vee6v+eoi1xcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGdldEl0ZW0oXFxcInNwZWVkVGhyZWFkXFxcIiwgXFxcIjIwXFxcIiksIFxcXCLor7fovpPlhaUzLTMy5LmL6Ze055qE5pW05pWwXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNwZWVkVGhyZWFkID0gcGFyc2VJbnQoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNwZWVkVGhyZWFkIDwgMyB8fCBzcGVlZFRocmVhZCA+IDMyKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruS4jeWQiOazlVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFN0cmluZyhzcGVlZFRocmVhZCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ZpbGVpbnRvLnN2Z1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlSWQ6IHBhZ2VJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgZm9sZGVyTmFtZTogZ2V0UGFnZVRpdGxlKClcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBbXFxcIkFMTFxcXCIsIFxcXCLku4Xmlofku7ZcXFwiLCBcXFwi5LuF5paH5Lu25aS5XFxcIl1bc2tpcEZpbGVdLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoW1xcXCJBTExcXFwiLCBcXFwi5LuF5paH5Lu2XFxcIiwgXFxcIuS7heaWh+S7tuWkuVxcXCJdKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibXlza2lwRmlsZVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2Vt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gICAgIGltYWdlOiBcXFwi8J+WvFxcXCIsXFxuICAgICAgICB6aXA6IFxcXCLwn5OmXFxcIixcXG4gICAgICAgIGZvbGRlcjogXFxcIvCfk4JcXFwiXFxuICAgIH07XFxuXFxuICAgIGZ1bmN0aW9uIGdldEhlYWQodHlwZSwgZXh0KSB7XFxuICAgICAgICBsZXQgaGVhZCA9IHRpdGxlSGVhZFt0eXBlXTtcXG4gICAgICAgIGlmIChzdWJFeHRzLmluY2x1ZGVzKGV4dCkpIHtcXG4gICAgICAgICAgICBoZWFkID0gXFxcIvCflbhcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGhlYWQgfHwgXFxcIuKdk1xcXCI7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZ2V0UHJldmlld1BpYyhmaWxlSXRlbSkge1xcbiAgICAgICAgaWYgKGZpbGVJdGVtLnRodW1ibmFpbCkge1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJodHRwczovL2VtcHR5P1xcXCIgKyBmaWxlSXRlbS5maWxlX2lkKS5pbWFnZSgocGljKSA9PiB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmV0Y2gocGljLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRTdHJlYW06IHRydWVcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGZpbGVJdGVtLnRodW1ibmFpbCk7XFxuICAgICAgICB9XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZGVsZXRlREZpbGUoZmlsZUlkLCBpc0JhY2t1cERyaXZpZCwgbmFtZSkge1xcbiAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOawuOS5heWIoOmZpFtcXFwi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ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIGlmIChzdHlsZSA9PT0gXFxcIueci+WbvlxcXCIpIHtcXG4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwiY2FyZF9waWNfM1xcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcImltYWdlXFxcIik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwi55yL5Zu+5qih5byP5Y+q5pi+56S65paH5Lu25aS55ZKM5Zu+54mHXFxcIi5zbWFsbCgpLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBmb2xkZXJTdHlsZSA9IGZpbGVTdHlsZSA9IHN0eWxlO1xcbiAgICB9XFxuICAgIGxldCBub1NraXBGaWxlID0gdHJ1ZTtcXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb250cy5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgbGV0IGZpbGVJdGVtID0gY29udHNbaV07XFxuICAgICAgICBsZXQgY2F0ZSA9IGZpbGVJdGVtLmNhdGVnb3J5O1xcbiAgICAgICAgbGV0IGRlc2MgPSBmb3JtYXREYXRlKGZpbGVJdGVtLnVwZGF0ZWRfYXQpO1xcbiAgICAgICAgbGV0IHBpY191cmwgPSBnZXRJY29uKGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLCBmaWxlSXRlbS50eXBlKTtcXG5cXG4gICAgICAgIGlmIChmaWxlSXRlbS50eXBlID09PSBcXFwiZm9sZGVyXFxcIikge1xcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IChmb2xkZXJTdHlsZSA9PT0gXFxcInRleHRfMVxcXCIgPyB0aXRsZUhlYWQuZm9sZGVyIDogXFxcIlxcXCIpICsgZmlsZUl0ZW0ubmFtZTtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvbXlhbGl5dW4/cGFnZT1meXBhZ2UnLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogZm9sZGVyU3R5bGUsXFxuICAgICAgICAgICAgICAgIGRlc2M6IGZvcm1hdERhdGUoZmlsZUl0ZW0udXBkYXRlZF9hdCksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IHBpY191cmwsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICBpc0JhY2t1cERyaXZpZCxcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogZmlsZUl0ZW0ubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSW5mbyxcXG4gICAgICAgICAgICAgICAgICAgIG5vUGljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6Zmk5paH5Lu25aS5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhkZWxldGVERmlsZSwgZmlsZUl0ZW0uZmlsZV9pZCwgaXNCYWNrdXBEcml2aWQsIGZpbGVJdGVtLm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2UgaWYgKG5vU2tpcEZpbGUpIHtcXG4gICAgICAgICAgICBpZiAoZmlsdGVyVHlwZS5sZW5ndGggPiAwICYmICFmaWx0ZXJUeXBlLmluY2x1ZGVzKGNhdGUpKSB7XFxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgc3VidGl0bGUsIGNscywgbG9uZ2MgPSBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpOaWh+S7tlxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKGRlbGV0ZURGaWxlLCBmaWxlSXRlbS5maWxlX2lkLCBpc0JhY2t1cERyaXZpZCwgZmlsZUl0ZW0ubmFtZSlcXG4gICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBmaWxlSXRlbS5uYW1lO1xcbiAgICAgICAgICAgIGxldCBuYW1lTm90RXh0ID0gZmlsZUl0ZW0ubmFtZS5yZXBsYWNlKCcuJyArIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLCAnJyk7XFxuICAgICAgICAgICAgaWYgKHN1YkV4dHMuaW5jbHVkZXMoZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pKSB7XFxuICAgICAgICAgICAgICAgIGxvbmdjLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjILovb3lrZfluZVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKHptKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ21vdW50emltdScsIHptKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3RvYXN0Oi8v5oyC6L295a6M5oiQ77yM5b2T5YmN5a2X5bmV5paH5Lu2OiAnICsgem0ubmFtZSArICcuJyArIHptLmV4dDtcXG4gICAgICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHQ6IGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVfaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogbmFtZU5vdEV4dFxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY2F0ZSA9PT0gXFxcInZpZGVvXFxcIikge1xcbiAgICAgICAgICAgICAgICBpZiAoemltdWxpc3QubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IHppbXVsaXN0LmZpbmQodiA9PiB2Lm5hbWUuaW5jbHVkZXMobmFtZU5vdEV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNscyA9IFxcXCJwbGF5bGlzdCB2XFxcIiArIHBhZ2VJZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGZpbGVTdHlsZSA9PT0gXFxcInRleHRfMVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgZGVzYyArPSBcXFwiXFxcXHRcXFxcdFxcXCIgKyBmb3JtYXRTaXplKGZpbGVJdGVtLnNpemUpO1xcbiAgICAgICAgICAgICAgICB0aXRsZSA9IGdldEhlYWQoY2F0ZSwgZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChbXFxcInZpZGVvXFxcIiwgXFxcImltYWdlXFxcIl0uaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgcGljX3VybCA9IGdldFByZXZpZXdQaWMoZmlsZUl0ZW0pIHx8IHBpY191cmw7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vUHJlI1xcXCIpLmxhenlSdWxlKChmaWxlSWQsIGNhdGUsIGlzQmFja3VwRHJpdmlkLCBzdWJ0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwibXlhbGlsYXp5XFxcIikoZmlsZUlkLCBjYXRlLCBpc0JhY2t1cERyaXZpZCwgc3VidGl0bGUpO1xcbiAgICAgICAgICAgICAgICB9LCBmaWxlSXRlbS5maWxlX2lkLCBjYXRlLCBpc0JhY2t1cERyaXZpZCwgc3VidGl0bGUpLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBkZXNjLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IGxvbmdjLFxcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBjbHMsXFxuICAgICAgICAgICAgICAgICAgICAvL2luaGVyaXRUaXRsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWVcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IGZpbGVTdHlsZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGlmIChjb250cy5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieS6huWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9XFxufVxcblxcbmxldCBpdGVtcyA9IFtdO1xcbnRyeSB7XFxuICAgIGlmIChNWV9QQUdFID4gMSAmJiAhTVlfUEFSQU1TLm1hcmtlcikge1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5LqG5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBsb2FkKGl0ZW1zKTtcXG4gICAgfVxcbn0gY2F0Y2ggKGUpIHtcXG5cXG4gICAgbG9nKFx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91cmw9JykpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGZ1cmwgPSBiYXNlNjREZWNvZGUoaXQucmVwbGFjZSgnL3Byb3h5P3VybD0nLCAnJykuc3BsaXQoXFxcIiZcXFwiKVswXSk7XFxuICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICB1cmwgPSBmdXJsO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICAgIGxldCBleHBpcmVzID0gdXJsLnNwbGl0KCd4LW9zcy1leHBpcmVzPScpWzFdLnNwbGl0KCcmJylbMF07XFxuICAgICAgICBjb25zdCBsYXN0dGltZSA9IHBhcnNlSW50KGV4cGlyZXMpIC0gRGF0ZS5ub3coKSAvIDEwMDA7XFxuICAgICAgICBpZiAobGFzdHRpbWUgPCA2MCkge1xcbiAgICAgICAgICAgIC8vbG9nKCfov4fmnJ/mm7TmlrAnKVxcbiAgICAgICAgICAgIGxldCBsaW5lID0gdXJsLnNwbGl0KCcvbWVkaWEnKVswXTsgLy/lj5bkuYvliY3mkq3mlL7nmoR0c+autee6v+i3r1xcbiAgICAgICAgICAgIGxpbmUgPSBsaW5lLnN1YnN0cmluZyhsaW5lLmxhc3RJbmRleE9mKCcvJykgKyAxKTtcXG4gICAgICAgICAgICBsZXQgZiA9IGdldE0zdThDb250ZW50KGdldEFsaVBsYXlVcmwoZmlkLCBsaW5lKSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgZi5mb3JFYWNoKGl0ID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKGl0ICYmIGl0LnN0YXJ0c1dpdGgoJy9wcm94eT91cmw9JykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gdXJsO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgdXJsID0gYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pO1xcbiAgICAgICAgaWYgKHVybC5pbmNsdWRlcyhcXFwiLnRzXFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IHVwZGF0ZVRzVXJsKHVybCksXFxuICAgICAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgdGVtcGxhdGVJZCA9IE1ZX1BBUkFN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MVxcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChlLmNvZGUgPT09IFxcXCJRdW90YUV4aGF1c3RlZC5Ecml2ZVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+e9keebmOepuumXtOS4jei2s++8jOaXoOazleaSreaUvuivt+a4heeQhuOAglxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mkq3mlL7lpLHotKXvvIzplJnor6/kv6Hmga/lt7LmiZPljbDjgIJcXFxcbuivt+afpeeci+aXpeW/lyhMT0cpXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBtb3VudHN1YiA9IHN0b3JhZ2UwLmdldE15VmFyKCdtb3VudHppbXUnLCB7fSk7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMobW91bnRzdWIpLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICB6aW11ID0gbW91bnRzdWI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc3VidGl0bGU7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMoemltdSB8fCB7fSkubGVuZ3RoID4gMCAmJiBwbGF5TGlzdCAmJiBwbGF5TGlzdC51cmxzICYmIHBsYXlMaXN0LnVybHMubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwKTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB2YXIgem11cmwgPSBhbGlBY2Nlc3NBcGkub3BlbkNsb3VkRmlsZVRvRG93blVybCh6aW11LmZpbGVfaWQpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGF0aCA9ICdoaWtlcjovL2ZpbGVzL2NhY2hlL+S6keebmOWQmy9zdWIuJyArIHppbXUuZXh0O1xcbiAgICAgICAgICAgICAgICBkb3dubG9hZEZpbGUoem11cmwsIHBhdGgsIHtcXG4gICAgICA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AgICAgICAgICBpZiAoZG1saXN0Lmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5by55bmV5YiX6KGo5bey5YWo6YOo5oyC6L29XFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwbGF5TGlzdC5kYW5tdSA9IGdldFZhcihcXFwiZG1fc2hhcmVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICBwbGF5TGlzdC5zdWJ0aXRsZSA9IHN1YnRpdGxlO1xcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHBsYXlMaXN0KTtcXG4gICAgfVxcblxcbiAgICBsZXQgdXJsID0gYWxpQWNjZXNzQXBpLm9wZW5DbG91ZEZpbGVUb0Rvd25VcmwoZmlsZUlkKTtcXG5cXG4gICAgaWYgKGNhdGUgPT09IFxcXCJpbWFnZVxcXCIpIHtcXG4gICAgICAgIHJldHVybiB1cmwgKyBcXFwiIy5qcGdcXFwiO1xcbiAgICB9IGVsc2UgaWYgKGNhdGUgPT09IFxcXCJhdWRpb1xcXCIpIHtcXG4gICAgICAgIHJldHVybiB1cmwgKyBcXFwiI2lzTXVzaWM9dHJ1ZSNcXFwiO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgcmV0dXJuIFxcXCJkb3dubG9hZDovL1xcXCIgKyB1cmw7XFxuICAgIH1cXG59XCJ9XSIsImljb24iOiIiLCJwcm94eSI6IiJ9
Add Comment
Please, Sign In to add comment