Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@云盘君.简@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoi5LqR55uY5ZCbLueugCIsImF1dGhvciI6IuWwj+ajieiihPCfjJ4mQExveURnSWsiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjoxNzYsImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoiYWxsIiwiY2xhc3NfdXJsIjoiIiwiYXJlYV9uYW1lIjoiIiwiYXJlYV91cmwiOiIiLCJzb3J0X25hbWUiOiIiLCJ5ZWFyX25hbWUiOiIiLCJzb3J0X3VybCI6IiIsInllYXJfdXJsIjoiIiwiZmluZF9ydWxlIjoianM6JC5yZXF1aXJlKFwiTWFpblwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zZWFyY2hUZXJtcz0qKiIsImdyb3VwIjoi4p6K4pOR6ZuG5ZCIIiwic2VhcmNoRmluZCI6ImpzOlxubGV0IGlzZERlbGVnYXRlID0gISFnZXRJdGVtKFwiaXNkRGVsZWdhdGVcIiwgXCJcIik7XG5pZiAoaXNkRGVsZWdhdGUpIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5pCc57SiXCIgKyBNWV9LRVlXT1JELFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9zZWFyY2g/cz1cIiArIE1ZX0tFWVdPUkQsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICBkZWxlZ2F0ZU9ubHlTZWFyY2g6IHRydWUsXG4gICAgICAgICAgICBydWxlczogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVHcm91cCA9IGdldEl0ZW0oXCJydWxlR3JvdXBcIiwgXCJcIik7XG4gICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gJC5yZXF1aXJlKFwiZGF0YVwiKS5nZXRBbGxEYXRhKHJ1bGVHcm91cCk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBkYXRhKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hfdXJsOiBcImhpa2VyOi8vZW1wdHk/cGFnZT1meXBhZ2Umc2VhcmNoVGVybXM9KipcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygocnVsZSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRSZXN1bHQoJC5yZXF1aXJlKFwiZGF0YVwiKS5jYXJyeVNSdWxlKHJ1bGUsIE1ZX0tFWVdPUkQsIE1ZX1BBR0UsIGdldFNlYXJjaE1vZGUoKSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHJ1bGVzKTtcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICB9XSk7XG59IGVsc2Uge1xuICAgIHNldFJlc3VsdChbe1xuICAgICAgICB0aXRsZTogXCLngrnmiJHlvIDlp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tb3ZpZV8xX3ZlcnRpY2FsX3BpY1xcXCIgOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7XFxuICAgICAgICAgICAgICAgIGluaGVyaXRUaXRsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgIG5vUGljOiB0cnVlXFxuICAgICAgICAgICAgfSwgaXQuZXh0cmEpXFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICByZXR1cm4gcmVzTGlzdDtcXG59XFxuJC5leHBvcnRzLmNhcnJ5U1J1bGUgPSBmdW5jdGlvbihydWxlLCBzLCBwYWdlLCBzZWFyY2hNb2RlKSB7XFxuICAgIHJ1bGUgPSBnZXRDb21wbGV0ZVJ1bGUocnVsZSk7XFxuICAgIGxldCBsaXN0ID0gcnVsZS5maW5kKHMsIHBhZ2UpO1xcbiAgICBpZiAoIWxpc3QpIHJldHVybiBbXTtcXG4gICAgbGV0IHJlc0xpc3QgPSBbXTtcXG4gICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xcbiAgICAgICAgaWYgKGl0LnNraXApIHtcXG4gICAgICAgICAgICByZXNMaXN0LnB1c2goaXQpO1xcbiAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHNlYXJjaE1vZGUgJiYgIXNlYXJjaENvbnRhaW5zKGl0LnRpdGxlLCBzLCB0cnVlKSkgY29udGludWU7XFxuICAgICAgICBpZiAocnVsZS5maW5kQWxpVXJsKSB7XFxuICAgICAgICAgICAgaXQudXJsID0gJChpdC51cmwpLmxhenlSdWxlKHRvUmVkaXJlY3RUcmVhdGluZywge1xcbiAgICAgICAgICAgICAgICBmaW5kQWxpVXJsOiBydWxlLmZpbmRBbGlVcmwsXFxuICAgICAgICAgICAgICAgIGJhc2ljVXJsOiBydWxlLmJhc2ljVXJsLFxcbiAgICAgICAgICAgICAgICBuYW1lOiBydWxlLm5hbWUsXFxuICAgICAgICAgICAgICAgIGF1dGhvcjogcnVsZS5hdXRob3IsXFxuICAgICAgICAgICAgICAgIGFsaVVybDogaXQudXJsLFxcbiAgICAgICAgICAgICAgICBydWxlVHlwZTogcnVsZS5ydWxlVHlwZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdC51cmwgPSAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKHRvUmVkaXJlY3QsIGl0LnVybCwgaXQuc2hhcmVQd2QgfHwgXFxcIlxcXCIpO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmVzTGlzdC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogaXQudGl0bGUsXFxuICAgICAgICAgICAgZGVzYzogaXQuZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICB1cmw6IGl0LnVybCxcXG4gICAgICAgICAgICBwaWNfdXJsOiBpdC5waWNfdXJsLFxcbiAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHtcXG4gICAgICAgICAgICAgICAgaW5oZXJpdFRpdGxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgbm9QaWM6IHRydWVcXG4gICAgICAgICAgICB9LCBpdC5leHRyYSlcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHJldHVybiByZXNMaXN0O1xcbn1cXG5sZXQgc2l6ZSA9IDEwO1xcblxcbmxldCBydWxlcztcXG5cXG5mdW5jdGlvbiBnZXRSdWxlcyhncm91cCkge1xcbiAgICBsZXQgcnVsZXNUbXA7XFxuICAgIGlmICghcnVsZXMpIHtcXG4gICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICB9XFxuICAgIGlmIChncm91cCkge1xcbiAgICAgICAgcnVsZXNUbXAgPSBydWxlcy5maWx0ZXIodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgIH0gZW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NvbnRleHQuZ2V0U3lzdGVtU2VydmljZShDb250ZXh0LkNMSVBCT0FSRF9TRVJWSUNFKTtcXG4gICAgICAgICAgICAvLyDov5Tlm57mlbDmja5cXG4gICAgICAgICAgICBsZXQgY2xpcERhdGEgPSBjbGlwYm9hcmQuZ2V0UHJpbWFyeUNsaXAoKTtcXG4gICAgICAgICAgICBpZiAoY2xpcERhdGEgIT0gbnVsbCAmJiBjbGlwRGF0YS5nZXRJdGVtQ291bnQoKSA+IDApIHtcXG4gICAgICAgICAgICAgICAgLy8g5LuO5pWw5o2u6ZuG5Lit6I635Y+W77yI57KY6LS077yJ56ys5LiA5p2h5paH5pys5pWw5o2uXFxuICAgICAgICAgICAgICAgIGxldCB0ZXh0ID0gY2xpcERhdGEuZ2V0SXRlbUF0KDApLmdldFRleHQoKTtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQgIT0gbnVsbCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyh0ZXh0LnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGxldCB0ZXh0ID0gZ2V0Q29weSgpIHx8IFxcXCJcXFwiO1xcbiAgICBsZXQgdXJsID0gYWxpdGVzdC5tYXRjaEFsaVVybCh0ZXh0KTtcXG4gICAgaWYgKHVybCkge1xcbiAgICAgICAgbGV0IGNhY2hlID0gZ2V0SXRlbShcXFwiY2xpcGJvYXJkQ2FjaGVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICBpZiAodXJsICE9PSBjYWNoZSkge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdPGZvbnQgY29sb3I9XFxcIiMxM0I2MUJcXFwiPuKWkCA8L2ZvbnQ+PGI+5rip6aao5o+Q56S6PGI+JyxcXG4gICAgICAgICAgICAgICAgZGVzYzogXFxcIuajgOa1i+WIsOWJqui0tOadv+WQq+aciemYv+mHjOmTvuaOpeaYr+WQpuaJk+W8gD9cXFxcblxcXCIgKyB1cmwsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5wdXQsIGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKGlkICsgXFxcImNsaXBib2FyZFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvYWxpeXVuP3BhZ2U9ZnlwYWdlJnJlYWx1cmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCkgKyBcXFwiJnNoYXJlUHdkPVxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIHVybCwgaWQpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBpZDogaWQgKyBcXFwiY2xpcGJvYXJkXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogXFxcIuaJk+W8gOmTvuaOpVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcImNsaXBib2FyZENhY2hlXFxcIiwgdXJsKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBzZXRQcmVwb3NlKCkge1xcbiAgICBpZiAob3Blbk1vZGUgPT0gXFxcIuacrOWcsOino+aekFxcXCIpIHtcXG4gICAgICAgIGxldCBhbGlUb2tlbnNGaWxlcGF0aCA9ICQucmVxdWlyZShcXFwiaGlrZXI6Ly9wYWdlL3Rva2VuUGF0aFxcXCIpLmFsaVRva2Vuc0ZpbGVwYXRoO1xcbiAgICAgICAgbGV0IGEgPSBmZXRjaChhbGlUb2tlbnNGaWxlcGF0aCk7XFxuICAgICAgICBpZiAoIWEgfHwgYSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAnPGZvbnQgY29sb3I9XFxcIiMxM0I2MUJcXFwiPuKWkCA8L2ZvbnQ+PGI+5rip6aao5o+Q56S6PGI+JyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJyaWNoX3RleHRcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiAkLnJlcXVpcmUoXFxcImxvZ2luTW9kZVxcXCIpKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuacquajgOa1i+WIsOeZu+W9leS/oeaBr++8jOeCueaIkei3s+i9rOeZu+W9lei0puWPt+mhtemdou+8jOeZu+W9lemYv+mHjOS6keebmOi0puWPt+WQjuaWueWPr+S9v+eUqOacrOWcsOino+aekOaooeW8j1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IFxcXCLnmbvlvZXpmL/ph4zkupHnm5hcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBhZGRMaXN0ZW5lcihcXFwib25DbG9zZVxcXCIsICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgY2xlYXJNeVZhcihcXFwic1xcXCIpO1xcbiAgICB9KSk7XF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SSUNvbXBvbmVudChwbGF5ZGF0YS50aXRsZS5zcGxpdCgnLScpWzBdKTtcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBNWV9SVUxFLnRpdGxlICsgXFxcIuW8ueW5leaQnOe0olxcXCJcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJydWxlOi8vXFxcIiArIGJhc2U2NEVuY29kZShcXFwi77+lcHJvamVjdGlvbl9zY3JlZW7vv6VcXFwiICsgSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoXFxcIuaSreaUvuaooeW8j1xcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIGxldCBtb2RlcyA9IFtcXFwi6L2s56CBXFxcIiwgXFxcIuWOn+eUu1xcXCIsIFxcXCLljp/ovaxcXFwiXTtcXG4gICAgICAgICAgICAgICAgbGV0IG1vZGUgPSBnZXRJdGVtKFxcXCJhbGl5dW5fcGxheU1vZGVcXFwiLCBtb2Rlc1swXSk7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG1vZGVzLmluZGV4T2YobW9kZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKG1vZGVzLCAxLCBcXFwi5pKt5pS+5qih5byPXFxcIiwgaW5kZXgpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fcGxheU1vZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChcXFwi55m75b2V5L+h5oGvXFxcIiA9PSBpbnB1dCkge1xcbiAgICAgICAgICAgICAgICBjb25zdCB7XFxuICAgICAgICAgICAgICAgICAgICBvcGVuVG9rZW5zRmlsZXBhdGgsXFxuICAgICAgICAgICAgICAgICAgICBhbGlUb2tlbnNGaWxlcGF0aFxcbiAgICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJ0b2tlblBhdGhcXFwiKTtcXG4gICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QoYWxpVG9rZW5zRmlsZXBhdGgpKSByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5pyq55m76ZmGXFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IGFsaSA9IHJlcXVlc3QoYWxpVG9rZW5zRmlsZXBhdGgpO1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpID0gSlNPTi5wYXJzZShhbGkpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVGaWxlKGFsaVRva2Vuc0ZpbGVwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/ojrflj5blpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6ICfnmbvlvZXkv6Hmga8nLFxcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogXFxcIueUqOaItzpcXFwiICsgKGFsaS5uaWNrX25hbWUgfHwgYWxpLnVzZXJfbmFtZSB8fCBcXFwiVG9rZW7nmbvlvZVcXFwiKSArIFxcXCJcXFxcblRva2VuOlxcXCIgKyBhbGkucmVmcmVzaF90b2tlbiArIFxcXCJcXFxcbijlj5bmtojvvJrms6jplIDnmbvlvZXvvJvnoa7lrprvvJrlpI3liLZUb2tlbilcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygodG9rZW4pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgdG9rZW47XFxuICAgICAgICAgICAgICAgICAgICB9LCBhbGkucmVmcmVzaF90b2tlbiksXFxuICAgICAgICAgICAgICAgICAgICBjYW5jZWw6ICQudG9TdHJpbmcoKHBhdGgxLCBwYXRoMikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTms6jplIDnmbvlvZVcXFwiKS5jb25maXJtKChwYXRoMSwgcGF0aDIpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlRmlsZShwYXRoMSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUZpbGUocGF0aDIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5oiQ5Yqf6YCA5Ye655m76ZmGXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBwYXRoMSwgcGF0aDIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYWxpVG9rZW5zRmlsZXBhdGgsIG9wZW5Ub2tlbnNGaWxlcGF0aClcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC5yZXBsYWNlKFxcXCLmqKHlvI/vvJpcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwib3Blbk1vZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpZHMsIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLorr7nva58XFxcIiArIGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgaWYgKGlucHV0ID09IFxcXCLlrpjmlrlB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VzaFBhZ2UoKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCLlhajpg6hcXFwiICsgaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc5YWo6YOo4oCd4oCdXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgaWYgKHFyKSB7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkICsgcXIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogcXJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBzLCBpZCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogXFxcIuWFqOmDqFxcXCIgKyBpZFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZm9yIChsZXQgW2l0LCBiYXNpY1VybF0gb2YgcnVsZXMpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IGl0ID09IHIgPyBcXFwi4oCc4oCcXFxcIiArIGl0ICsgXFxcIuKAneKAnVxcXCIgOiBpdCxcXG4gICAgICAgICAgICB1cmw6ICQoKGdldEhvbWUoYmFzaWNVcmwpIHx8IFxcXCJcXFwiKSArIFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChyLCBzLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgcXIgPSBnZXRJdGVtKFxcXCJydWxlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJydWxlXFxcIiwgcik7XFxuICAgICAgICAgICAgICAgIGlmIChzKSB7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShxciA/IChpZCArIHFyKSA6IChcXFwi5YWo6YOoXFxcIiArIGlkKSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBxciB8fCBcXFwi5YWo6YOoXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkICsgciwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIHIgKyBcXFwi4oCd4oCdXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBpdCwgcywgaWQpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IGlkICsgaXRcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcblxcbn1cXG5cXG5mdW5jdGlvbiByZWNvcmQoKSB7XFxuICAgIGxldCBoaXN0b3J5ID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIsIFtdKTtcXG4gICAgbGV0IGlpID0gaGlzdG9yeS5pbmRleE9mKHMpO1xcbiAgICBpZiAoaWkgPiAtMSkge1xcbiAgICAgICAgaGlzdG9yeS5zcGxpY2UoaWksIDEpO1xcbiAgICB9XFxuICAgIGlmIChoaXN0b3J5Lmxlbmd0aCA+IDIwKSB7XFxuICAgICAgICBo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G4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJkYXRhXFxcIikuY2FycnlSdWxlKHJ1bGUsIHMsIHJlYWxQYWdlLCBzZWFyY2hNb2RlKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb2cocnVsZS5uYW1lICsgXFxcIjpcXFwiICsgZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvKmlmKGRhdGEubGVuZ3RoPT09MSYmcD09PTEpe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOlxcXCLigJzigJxcXFwiK3J1bGUubmFtZStcXFwiIEVSUk9S4oCd4oCdXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOlxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDpcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYTp7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1dO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgLy9yZXR1cm4gcnVsZS5maW5kKHMsIHJlYWxQYWdlKTtcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgcGFyYW06IGl0LFxcbiAgICAgICAgICAgICAgICBpZDogXFxcInJ1bGVAXFxcIiArIGl0Lm5hbWVcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgICAgIGJhdGNoRXhlY3V0ZSh0YXNrcywge1xcbiAgICAgICAgICAgIGZ1bmM6IGZ1bmN0aW9uKHBhcmFtLCBpZCwgZXJyb3IsIHJlc3VsdCkge1xcbiAgICAgICAgICAgICAgICBwYXJhbS5pICs9IDE7XFxuICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHJlc3VsdCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oXFxcIl9ub3RoYXZlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQmVmb3JlKHBhZ2VpZCwgcmVzdWx0KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAocGFyYW0uaSA9PT0gcGFyYW0uYWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXJlc3VsdCB8fCAhcmVzdWx0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oXFxcIl9ub3RoYXZlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUJlZm9yZShwYWdlaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjotYTmupDpg73msqHmnInlk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJfbm90aGF2ZVxcXCJcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShwYWdlaWQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShwYWdlaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWKoOi9veesrFxcXCIgKyBNWV9QQUdFICsgXFxcIumhteS4re+8jOi/m+W6pu+8mlxcXCIgKyAocGFyYW0uaSArIDEpICsgXFxcIi9cXFwiICsgcGFyYW0uYWxsLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICBhbGw6IGRhdGEubGVuZ3RoLFxcbiAgICAgICAgICAgICAgICBpOiAwLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0SGlzdG9yeSgpIHtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiAnPHNwYW4gc3R5bGU9XFxcImNvbG9yOiNmZjY2MDFcXFwiPjxiPuWOhuWPsuiusOW9lTwvYj48L3NwYW4+JyxcXG4gICAgICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX2Nsb2NrXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYXZhdGFyXFxcIixcXG4gICAgICAgIHVybDogJChbXFxcIua4hemZpOaQnOe0ouiusOW9lVxcXCIsIFxcXCLmiZPlvIDop4LnnIvorrDlvZVcXFwiXSkuc2VsZWN0KChpZCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIua4hemZpOaQnOe0ouiusOW9lVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruWumua4hemZpOWFqOmDqOaQnOe0ouiusOW9le+8n1xcXCIpLmNvbmZpcm0oKGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhpZCArIFxcXCI6a2V5XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoaWQgKyBcXFwiOnNlYXJjaEhpc3RvcnlcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSwgaWQpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9oaXN0b3J5P3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwiOnNlYXJjaEhpc3RvcnlcXFwiLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgbGV0IGhpc3RvcnkgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgW10pO1xcbiAgICBsZXQgaSA9IDA7XFxuICAgIGZvciAobGV0IGtleSBvZiBoaXN0b3J5KSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBrZXksXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpZCwga2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBleHRyYSA9IGZpbmRJdGVtKGlkICsgXFxcInNzXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIGV4dHJhLmRlZmF1bHRWYWx1ZSA9IGtleTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh7XFxuICAgICAgICAgICAgICAgICAgICBleHRyYTogZXh0cmFcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgaWQsIGtleSksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJmbGV4X2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IGlkICsgXFxcIjprZXk6XFxcIiArIGtleSxcXG4gICAgICAgICAgICAgICAgY2xzOiBpZCArIFxcXCI6a2V5XFxcIixcXG4gICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaTlhbPplK7or406XFxcIiArIGtleSxcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpZCwga2V5LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGhpc3RvcnkgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgW10pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpc3Rvcnkuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiLCBoaXN0b3J5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKGlkICsgXFxcIjprZXk6XFxcIiArIGtleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy90b2FzdCgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgaWQsIGtleSwgaSlcXG4gICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICBpZiAoaGlzdG9yeS5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBzZXRUcmVuZGluZ1RhYkVuZCgpIHtcXG4gICAgbGV0IGhvdENsYXNzID0ge1xcbiAgICAgICAgXFxcIueZvuW6plxcXCI6IHtcXG4gICAgICAgICAgICBcXFwi55S16KeG5YmnXFxcIjogXFxcInRlbGVwbGF5XFxcIixcXG4gICAgICAgICAgICBcXFwi55S15b2xXFxcIjogXFxcIm1vdmllXFxcIlxcbiAgICAgICAgfSxcXG4gICAgICAgIFxcXCLlpLjlhYtcXFwiOiB7XFxuICAgICAgICAgICAgXFxcIueUteinhuWJp1xcXCI6IFxcXCLnlLXop4bliadcXFwiLFxcbiAgICAgICAgICAgIFxcXCLnlLXlvbFcXFwiOiBcXFwi55S15b2xXFxcIixcXG4gICAgICAgICAgICBcXFwi5Yqo5ryrXFxcIjogXFxcIuWKqOa8q1xcXCIsXFxuICAgICAgICAgICAgXFxcIue7vOiJulxcXCI6IFxcXCLnu7zoibpcXFwiXFxuICAgICAgICB9XFxuICAgIH07XFxuICAgIGxldCBkYXRhU291cmNlID0gT2JqZWN0LmtleXMoaG90Q2xhc3MpO1xcbiAgICBsZXQgc2VsZWN0c291cmNlID0gZ2V0SXRlbShcXFwiZGF0YVNvdXJjZVxcXCIsIGRhdGFTb3VyY2VbMF0pO1xcbiAgICBsZXQgaG90a2V5cyA9IE9iamVjdC5rZXlzKGhvdENsYXNzW3NlbGVjdHNvdXJjZV0pO1xcbiAgICBsZXQgc2VsZWN0a2V5ID0gZ2V0SXRlbShcXFwiaG90a2V5XFxcIiwgaG90a2V5c1swX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gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNouS4ulxcXCIgKyBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9LCBkYXRhU291cmNlKVxcbiAgICAgICAgICAgIH1dXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmraPlnKjliqDovb0uLi5cXFwiLFxcbiAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwiOmhvdGtleVxcXCIsXFxuICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIGxldCBzZCA9IFtdO1xcbiAgICBsZXQgc2V0U2VhcmNoS2V5ID0gbmFtZSA9PiB7XFxuICAgICAgICBwdXRNeVZhcigncycsIG5hbWUpO1xcbiAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIHJldHVybiAnaGlrZXI6Ly9lbXB0eSdcXG4gICAgfTtcXG5cXG4gICAgbGV0IGdldFRpdGxlID0gKGksIG5hbWUpID0+IHtcXG4gICAgICAgIGxldCBjb2xvcjtcXG4gICAgICAgIHN3aXRjaCAoaSkge1xcbiAgICAgICAgICAgIGNhc2UgMDpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcXFwiI2ZmMzMwMFxcXCI7XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgMTpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcX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ICAgICAgICAgICAgICAgICAgICAgICAnQWNjZXB0JzogJ2FwcGxpY2F0aW9uL2pzb24sIHRleHQvcGxhaW4sICovKicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdC1MYW5ndWFnZSc6ICd6aC1DTix6aDtxPTAuOSxlbi1VUztxPTAuOCxlbjtxPTAuNycsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdC1FbmNvZGluZyc6ICdnemlwLCBkZWZsYXRlLCBicicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly90b3AuYmFpZHUuY29tL2JvYXJkP3RhYj1ub3ZlbCcsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAvL3ZhciBzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgdmFyIGxpc3QgPSBKU09OLnBhcnNlKGpzb24pLmRhdGEuY2FyZHNbMF0uY29udGVudDtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0ZW0ud29yZCArICcgKCcgKyBpdGVtLnNob3dbMl0gKyAnKSc7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZGVzID0gaXRlbS5kZXNjO1xcbiAgICAgICAgICAgICAgICAgICAgc2QucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGdldFRpdGxlKGksIG5hbWUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZShzZXRTZWFyY2hLZXksIGl0ZW0ud29yZCksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogaXRlbS5pbWcsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJtb3ZpZV8xX3ZlcnRpY2FsX3BpY1xcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgXFxcIuWkuOWFi1xcXCI6XFxuICAgICAgICAgICAgICAgIHZhciBqc29uID0gcmVxdWVzdChcXFwiaHR0cHM6Ly9uZXdzLm15cXVhcmsuY24vdjIvdG9wbGlzdC9tb3ZpZT8mY2hhbm5lbD1cXFwiICsgdGFia2V5ICsgXFxcIiZyYW5rX3R5cGU9JUU2JTlDJTgwJUU3JTgzJUFEXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciB4bWxEYXRhID0gKEpTT04ucGFyc2UoanNvbikuZGF0YSB8fCBcXFwiXFxcIikucmVwbGFjZSgvdGl0bGU+L2csIFxcXCJoX3RpdGxlPlxcXCIpLnJlcGxhY2UoL3NyYz4vZywgXFxcImhfc3JjPlxcXCIpLnJlcGxhY2UoL2FyZWE+L2csIFxcXCJoX2FyZWFcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGxpc3QgPSBwZGZhKHhtbERhdGEsIFxcXCJib2R5JiZpdGVtXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBnZXRUZXh0ID0gdCA9PiB0O1xcbiAgICAgICAgICAgICAgICB2YXIgdHJlbmQgPSBbXFxcIuOEp1xcXCIsIFxcXCLihpFcXFwiLCBcXFwi4oaTXFxcIl07XFxuICAgICAgICAgICAgICAgIC8vdmFyIHMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpdGVtID0gbGlzdFtpXTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuYW1lID0gcGRmaChpdGVtLCBcXFwiaF90aXRsZSYmVGV4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRlcyA9IFxcXCLng63luqbvvJpcXFwiICsgcGRmaChpdGVtLCBcXFwiaG90X3Njb3JlJiZUZXh0XFxcIikgKyBcXFwiIFxcXCIgKyB0cmVuZC5hdChwZGZoKGl0ZW0sIFxcXCJob3RfdHJlbmQmJlRleHRcXFwiKSkgK1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJcXFxcbuivhOWIhu+8mlxcXCIgKyBwZGZoKGl0ZW0sIFxcXCJzY29yZV9hdmcmJlRleHRcXFwiKS5yZXBsYWNlKC9eMCQvLCBcXFwi5pqC5peg6K+E5YiGXFxcIikgK1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJcXFxcblxcXCIgKyBwZGZoKGl0ZW0sIFxcXCJ5ZWFyJiZUZXh0XFxcIikgKyBcXFwiwrdcXFwiICsgcGRmaChpdGVtLCBcXFwiaF9hcmVhJiZUZXh0XFxcIikgKyBcXFwiwrdcXFwiICsgcGRmaChpdGVtLCBcXFwiY2F0ZWdvcnkmJlRleHRcXFwiKS5yZXBsYWNlKFxcXCIsXFxcIiwgXFxcIsK3XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBzZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZ2V0VGl0bGUoaSwgbmFtZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKHNldFNlYXJjaEtleSwgbmFtZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogcGRmaChpdGVtLCBcXFwiaF9zcmMmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxc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GlucHV0LnN0YXJ0c1dpdGgoXFxcIm1hZ25ldFxcXCIpKSB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuajgOa1i+WIsOaWsOeahOejgemTvuWcsOWdgO+8jOeCueWHu+ehruWumuaMiemSruWNs+WPr+aSreaUvu+8jOeCueWHu+WPlua2iOaMiemSruWPr+S7peWkjeWItumTvuaOpVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobWFnKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBtYWc7XFxuICAgICAgICAgICAgfSwgaW5wdXQpLFxcbiAgICAgICAgICAgIGNhbmNlbDogJC50b1N0cmluZygobWFnKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBtYWdcXG4gICAgICAgICAgICB9LCBpbnB1dClcXG4gICAgICAgIH0pO1xcbiAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgIH0gZWxzZSBpZiAoJC5yZXF1aXJlKFxcXCJhbGl0ZXN0P3J1bGU9XFxcIitydWxlKS50ZXN0KGlucHV0KSAmJiBvcGVuTW9kZSAhPSBcXFwi5a6Y5pa5QVBQXFxcIikge1xcbiAgICAgICAgbG9nKGlucHV0KTtcXG4gICAgICAgIGlmIChpbnB1dC5pbmNsdWRlcygnY2hlY2t1cmw/dXJsPScpICYmIGlucHV0LmluY2x1ZGVzKCcmdXJscmVmZXInKSkge1xcbiAgICAgICAgICAgIGlucHV0ID0gZGVjb2RlVVJJQ29tcG9uZW50KGlucHV0LnNwbGl0KCcmdXJscmVmZXInKVswXS5zcGxpdCgnY2hlY2t1cmw/dXJsPScpWzFdKTtcXG4gICAgICAgICAgICAvL2xvZygn6LS05ZCnJytpbnB1dCk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gJC50b1N0cmluZygodXJsLC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k7XFxuICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICB1cmwgPSBmdXJsO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICAgIGxldCBleHBpcmVzID0gdXJsLnNwbGl0KCd4LW9zcy1leHBpcmVzPScpWzFdLnNwbGl0KCcmJylbMF07XFxuICAgICAgICBjb25zdCBsYXN0dGltZSA9IHBhcnNlSW50KGV4cGlyZXMpIC0gRGF0ZS5ub3coKSAvIDEwMDA7XFxuICAgICAgICBpZiAobGFzdHRpbWUgPCA2MCkge1xcbiAgICAgICAgICAgIC8vbG9nKCfov4fmnJ/mm7TmlrAnKVxcbiAgICAgICAgICAgIGxldCBsaW5lID0gdXJsLnNwbGl0KCcvbWVkaWEnKVswXTsgLy/lj5bkuYvliY3mkq3mlL7nmoR0c+autee6v+i3r1xcbiAgICAgICAgICAgIGxpbmUgPSBsaW5lLnN1YnN0cmluZyhsaW5lLmxhc3RJbmRleE9mKCcvJykgKyAxKTtcXG4gICAgICAgICAgICBsZXQgZiA9IGdldE0zdThDb250ZW50KGdldEFsaVBsYXlVcmwoZmlkLCBsaW5lKSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgZi5mb3JFYWNoKGl0ID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKGl0ICYmIGl0LnN0YXJ0c1dpdGgoJy9wcm94eT91cmw9JykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gdXJsO1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgdXJsID0gYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pO1xcbiAgICAgICAgaWYgKHVybC5pbmNsdWRlcyhcXFwiLnRzXFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IHVwZGF0ZVRzVXJsKHVybCksXFxuICAgICAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgdGVtcGxhdGVJZCA9IE1ZX1BBUkFNUy50ZW1wbGF0ZUlkWzBdO1xcbiAgICAgICAgICAgIGlmKGZpbGVFeGlzdChjYWNoZUZpbGVQYXRoKSl7XFxuICAgICAgICAgICAgICAgIHJldHVybiBnZXRNM3U4Q29udGVudChnZX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cbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pKt5pS+5aSx6LSl77yM6ZSZ6K+v5L+h5oGv5bey5omT5Y2w44CCXFxcXG7or7fmn6XnnIvml6Xlv5coTE9HKVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgbW91bnRzdWIgPSBzdG9yYWdlMC5nZXRNeVZhcignbW91bnR6aW11Jywge30pO1xcbiAgICAgICAgaWYgKE9iamVjdC5rZXlzKG1vdW50c3ViKS5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgemltdSA9IG1vdW50c3ViO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHN1YnRpdGxlO1xcbiAgICAgICAgaWYgKE9iamVjdC5rZXlzKHppbXUgfHwge30pLmxlbmd0aCA+IDAgJiYgcGxheUxpc3QgJiYgcGxheUxpc3QudXJscyAmJiBwbGF5TGlzdC51cmxzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDEwMCk7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgdmFyIHptdXJsID0gYWxpQWNjZXNzQXBpLmdldFZpZGVvVGVtUGxheVVybCh6aW11LmZpbGVfaWQpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGF0aCA9ICdoaWtlcjovL2ZpbGVzL2NhY2hlL+S6keebmOWQmy9zdWIuJyArIHppbXUuZXh0O1xcbiAgICAgICAgICAgICAgICBkb3dubG9hZEZpbGUoem11cmwsIHBhdGgsIHtcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IGdldFBhdGgocGF0aCk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAg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XFwiI25vSGlzdG9yeSNcXFwiLFxcbiAgICAgICAgICAgICAgICBpbWc6IHNoYXJlSW5mby5hdmF0YXIgfHwgXFxcImhpa2VyOi8vaW1hZ2VzL2ljb25fdW5rbm93blxcXCIsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiYXZhdGFyXFxcIlxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCFpc1NlYXJjaCkge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuaQnOe0olxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghaW5wdXQpIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXlhbPplK7or41cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvYWxpeXVuI25vSGlzdG9yeSMjZnVsbFRoZW1lIz9wYWdlPWZ5cGFnZSZzZWFyY2hLZXk9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIG9uQ2hhbmdlOiBcXFwicHV0TXlWYXIoJ2xpc3RTZWFyY2hLZXknLGlucHV0KVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2QsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZUlkOiBzaGFyZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVUb2tlbjogc2hhcmVUb2tlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnFxcXCIgKyBzZWFyY2hLZXkgKyBcXFwi4oCd4oCd55qE5pCc57Si57uT5p6cXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGZ1bmNJdGVtcyA9IFtdO1xcbiAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBzdHlsZSxcXG4gICAgICAgICAgICB1cmw6ICQoc3R5bGVzLCAxLCBcXFwi5o6S5biD5qC35byPXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiYWxpeXVuX3N0eWxlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5YiH5o2iXFxcIjtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBwaWNfdXJsOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL2ltZy9hbGlfaWNvbi5zdmdcXFwiXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IG9yZGVyTmFtZSxcXG4gICAgICAgICAgICB1cmw6ICQob3JkZXJzS2V5cywgMiwgXFxcIuaOkuW6j+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kFQSUxpc3RbZ2V0SXRlbShcXFwib3BlbkFwaU1vZGVcXFwiLCBcXFwiMFxcXCIpXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKG9wZW5BUElMaXN0LCAxLCBcXFwi5Y6f55S7QVBJKOS4jeimgemikee5geWIh+aNoilcXFwiKS5zZWxlY3QoKG9wZW5BUElMaXN0KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJvcGVuQXBpTW9kZVxcXCIsIFN0cmluZyhvcGVuQVBJTGlzdC5pbmRleE9mKGlucHV0KSkpO1xcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlRmlsZSgkLnJlcXVpcmUoXFxcInRva2VuUGF0aFxcXCIpLm9wZW5Ub2tlbnNGaWxlcGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5YiH5o2i5Li6XFxcIiArIGlucHV0O1xcbiAgICAgICAgICAgICAgICB9LCBvcGVuQVBJTGlzdCksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9hcGkuc3ZnXFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghaXNTZWFyY2gpIHtcXG4gICAgICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yqf6IO9XFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFtcXFwi6L2s5a2Y5LqR55uYXFxcIiwgXFxcIueZu+mZhui0puWPt1xcXCIsIFxcXCLlpI3liLbliIbkuqvpk77mjqVcXFwiLCBcXFwi5p+l55yL5omL5Yqo5oyC6L295a2X5bmVXFxcIiwgXFxcIuiOt+WPluW8ueW5leaQnOe0ouinhOWImVxcXCIsIFxcXCLmibnph4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SN5Yi26ZO+5o6lXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyB1cmw7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL+mYv+mHjOS6keebmOWIhuS6q+WPo+S7pOOAjFxcXCIgKyBnZXRQYWdlVGl0bGUoKSArIFxcXCLjgI1cXFxcblxcXCIgKyB1cmwgKyBcXFwiIEBpbXBvcnQ9anM6YGhpa2VyOi8vcGFnZS9hbGl5dW4/cmVhbHVybD0ke2lucHV0LnRyaW0oKX0mcnVsZT1cXFwiICsgTVlfUlVMRS50aXRsZSArIFxcXCJgO1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy9cXFwiICsgc2hhcmVJZCArIChmaWxlSWQgPyBcXFwiL2ZvbGRlci9cXFwiICsgZmlsZUlkIDogXFxcIlxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmibnph4/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+eoi1xcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGdldEl0ZW0oXFxcInNwZWVkVGhyZWFkXFxcIiwgXFxcIjEwXFxcIiksIFxcXCLor7fovpPlhaUzLTMy5LmL6Ze055qE5pW05pWwXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNwZWVkVGhyZWFkID0gcGFyc2VJbnQoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNwZWVkVGhyZWFkIDwgMyB8fCBzcGVlZFRocmVhZCA+IDMyKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruS4jeWQiOazlVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFN0cmluZyhzcGVlZFRocmVhZCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIui9rOWtmOW9k+WJjeaWh+S7tuWkuVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL215YWxpeXVuI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9wYWdlPWZ5cGFnZVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIHNoYXJlSWQsIHNoYXJlUHdkLCBmaWxlSWQpLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL2ltZy9hbGlfZmlsZWludG8uc3ZnXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VJZDogcGFnZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgZmlsZUlkOiBmaWxlSWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZUlkOiBzaGFyZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVUb2tlbjogc2hhcmVUb2tlbixcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZCxcXG4gICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgZm9sZGVyTmFtZTogZ2V0UGFnZVRpdGxlKClcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBbXFxcIkFMTFxcXCIsIFxcXCLot7Pov4fmlofku7ZcXFwiXVtOdW1iZXIoc2tpcEZpbGUpXSxcXG4g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ICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgZmlsZUl0ZW0udGh1bWJuYWlsKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgZm9sZGVyU3R5bGUsIGZpbGVTdHlsZTtcXG4gICAgbGV0IGZpbHRlclR5cGUgPSBbXTtcXG4gICAgaWYgKHN0eWxlID09PSBcXFwi6L+95YmnXFxcIikge1xcbiAgICAgICAgZm9sZGVyU3R5bGUgPSBcXFwiYXZhdGFyXFxcIjtcXG4gICAgICAgIGZpbGVTdHlsZSA9IFxcXCJtb3ZpZV8yXFxcIjtcXG4gICAgICAgIGZpbHRlclR5cGUucHVzaChcXFwidmlkZW9cXFwiKTtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCLov73liafmqKHlvI/lj6rmmL7npLrmlofku7blpLnlkozop4bpopFcXFwiLnNtYWxsKCkuZm9udGNvbG9yKFxcXCJncmV5XFxcIiksXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIGlmIChzdHlsZSA9PT0gXFxcIueci+WbvlxcXCIpIHtcXG4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwiY2FyZF9waWNfM1xcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcImltYWdl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uYW1lO1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgIHVybDogJ2hpa2VyOi8vcGFnZS9hbGl5dW4/cGFnZT1meXBhZ2UnLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogZm9sZGVyU3R5bGUsXFxuICAgICAgICAgICAgICAgIGRlc2M6IGZvcm1hdERhdGUoZmlsZUl0ZW0udXBkYXRlZF9hdCksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IHBpY191cmwsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBzaGFyZUlkOiBzaGFyZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVUb2tlbjogTVlfUEFSQU1TLnNoYXJlVG9rZW4sXFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2QsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcjogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIG5vUGljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L2s5a2YXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS9teWFsaXl1biNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/cGFnZT1meXBhZ2VcXFwiKVxcbiAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIGlmIChub1NraXBGaWxlKSB7XFxuICAgICAgICAgICAgaWYgKGZpbHRlclR5cGUubGVuZ3RoID4gMCAmJiAhZmlsdGVyVHlwZS5pbmNsdWRlcyhjYXRlKSkge1xcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHN1YnRpdGxlLCBjbHMsIGxvbmdjID0gW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLovazlrZhcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS9teWFsaXl1biNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/cGFnZT1meXBhZ2VcXFwiKVxcbiAgICAgICAgICAgIH1dO1xcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IGZpbGVJdGVtLm5hbWU7XFxuICAgICAgICAgICAgbGV0IG5hbWVOb3RFeHQgPSBmaWxlSXRlbS5uYW1lLnJlcGxhY2UoJy4nICsgZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24sICcnKTtcXG4gICAgICAgICAgICBpZiAoc3ViRXh0cy5pbmNsdWRlcyhmaWxlSXRlbS5maWxlX2V4dGVuc2lvbikpIHtcXG4gICAgICAgICAgICAgICAgbG9uZ2MucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuaMgui9veWtl+W5lVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoem0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcignbW91bnR6aW11Jywgem0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAndG9hc3Q6Ly/mjILovb3lrozmiJDvvIzlvZPliY3lrZfluZXmlofku7Y6ICcgKyB6bS5uYW1lICsgJy4nICsgem0uZXh0O1xcbiAgICAgICAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dDogZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24sXFxuICAgICAgICAgICAgICAgICAgICAgICAgZmlsZV9pZDogZmlsZUl0ZW0uZmlsZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiBuYW1lTm90RXh0XFxuICAgICAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChjYXRlID09PSBcXFwidmlkZW9cXFwiKSB7XFxuICAgICAgICAgICAgICAgIGlmICh6aW11bGlzdC5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgIHN1YnRpdGxlID0gemltdWxpc3QuZmluZCh2ID0+IHYubmFtZS5pbmNsdWRlcyhuYW1lTm90RXh0KSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2xzID0gXFxcInBsYXlsaXN0IHZcXFwiICsgcGFnZUlkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoZmlsZVN0eWxlID09PSBcXFwidGV4dF8xXFxcIikge1xcbiAgICAgICAgICAgICAgICBkZXNjICs9IFxcXCJcXFxcdFxcXFx0XFxcIiArIGZvcm1hdFNpemUoZmlsZUl0ZW0uc2l6ZSk7XFxuICAgICAgICAgICAgICAgIHRpdGxlID0gZ2V0SGVhZChjYXRlLCBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbikgKyB0aXRsZTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKFtcXFwidmlkZW9cXFwiLCBcXFwiaW1hZ2VcXFwiXS5pbmNsdWRlcyhjYXRlKSkge1xcbiAgICAgICAgICAgICAgICBwaWNfdXJsID0gZ2V0UHJldmlld1BpYyhmaWxlSXRlbSkgfHwgcGljX3VybDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9QcmUjXFxcIikubGF6eVJ1bGUoKHNoYXJlSWQsIHNoYXJlUHdkLCBzaGFyZVRva2VuLCBmaWxlSWQsIGNhdGUsIHN1YnRpdGxlKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJoaWtlcjovL3BhZ2UvYWxpbGF6eVxcXCIpKHNoYXJlSWQsIHNoYXJlUHdkLCBzaGFyZVRva2VuLCBmaWxlSWQsIGNhdGUsIHN1YnRpdGxlKTtcXG4gICAgICAgICAgICAgICAgfSwgc2hhcmVJZCwgc2hhcmVQd2QsIE1ZX1BBUkFNUy5zaGFyZVRva2VuLCBmaWxlSXRlbS5maWxlX2lkLCBjYXRlLCBzdWJ0aXRsZSksXFxuICAgICAgICAgICAgICAgIGRlc2M6IGRlc2MsXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IHBpY191cmwsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBpZDogZmlsZUl0ZW0uZmlsZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVJbmZvOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUlkOiBwYWdlSWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZmlsZUlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlSWQ6IHNoYXJlSWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVUb2tlbjogc2hhcmVUb2tlbixcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2QsXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBsb25nYyxcXG4gICAgICAgICAgICAgICAgICAgIGNsczogY2xzLFxcbiAgICAgICAgICAgICAgICAgICAgLy9pbmhlcml0VGl0bGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBmaWxlSXRlbS5uYW1lXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBmaWxlU3R5bGVcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBpZiAoY29udHMubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInkuoblk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5cXG5sZXQgaXRlbXMgPSBbXTtcXG50cnkge1xcbiAgICBpZiAoTVlfUEFHRSA+IDEgJiYgIU1ZX1BBUkFNUy5tYXJrZXIpIHtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieS6huWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgbG9hZChpdGVtcyk7XFxuICAgIH1cXG59IGNhdGNoIChlKSB7XFxuICAgIGlmIChlLm5hbWUgPT09IFxcXCJBbGlFcnJvclxcXCIpIHtcXG4gICAgICAgIGlmIChlLmNvZGUgPT09IFxcXCJJbnZhbGlkUmVzb3VyY2UuU2hhcmVQd2RcXFwiKSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K+36L6T5YWl5o+Q5Y+W56CBXFxcIixcXG4gICAgICAgICAgICAgICAgZGVzYzogc2hhcmVQd2QgPyBcXFwi4oCc4oCc5o+Q5Y+W56CB6ZSZ6K+v4oCd4oCdXFxcIiA6IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoKS5pbnB1dCgoTVlfUEFSQU1TKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRQYWdlUGFyYW1zKE9iamVjdC5hc3NpZ24oe30sIE1ZX1BBUkFNUywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBpbnB1dFxcbiAgICAgICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSwgTVlfUEFSQU1TKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIlxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpZiAoZS5zaWduaWZpY2FuY2UgPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBlLm1lc3NhZ2UuYmlnKCkuYmlnKCkuZm9udGNvbG9yKFxcXCJyZWRcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICd0ZXh0X2NlbnRlcl8xJyxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChlLnNpZ25pZmljYW5jZSA9PT0gMykge1xcbiAgICAgICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIGUubWVzc2FnZS5iaWcoKS5mb250Y29sb3IoXFxcImdyZWVuXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMSdcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcblxcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgbG9nKFxcXCLliJfooajliqDovb3lpLHotKUjXFxcXG7plJnor6/kv6Hmga8+XFxcIiArIGUudG9TdHJpbmcoKSArIFxcXCJcXFxcbumUmeivr+ihjD5cXFwiICsgZS5saW5lTnVtYmVyKTtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiAn5qyn5qyn77yM5oql6ZSZ5LqG44CC5Zyo5Yi35paw5Yeg5qyh77yf5oiW6ICF5pu05o2i5paH5Lu25aS544CCJyxcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBkZXNjOiBlLnRvU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ICAgICAgICAgICAgIHdyaXRlRmlsZShhbGlUb2tlbnNGaWxlcGF0aCwgSlNPTi5zdHJpbmdpZnkoYWxpVG9rZW4pKTtcXG4gICAgICAgICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwibG9naW55XFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi55m75b2V5oiQ5YqfKOeCueWHu+i/lOWbnilcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIGJhY2tIb21lKFxcXCLnmbvlvZXmiJDlip9cXFwiLCB0cnVlKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGJhY2tIb21lKFxcXCLnmbvlvZXlpLHotKUs6K+35bCd6K+V5YW25LuW55qE5pa55rOVXFxcIik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocXJDb2RlU3RhdHVzID09PSBcXFwiQ0FOQ0VMRURcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGJhY2tIb21lKFxcXCLlj5bmtojnmbvlvZXmjojmnYNcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoW1xcXC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ArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiMlxcXCI6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfdHZib3hcXFwiICsgdGhpcy5vcGVuU3VmZml4KTtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICBjYXNlIFxcXCIzXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgIE9wZW5BcGlUb29scyA9ICQucmVxdWlyZShcXFwib3BlbkFwaV9YQllcXFwiICsgdGhpcy5vcGVuU3VmZml4KTtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICBjYXNlIFxcXCI0XFxcIjpcXG4gICAgICAgICAgICAgICAgICAgIE9wZW5BcGlUb29scyA9ICQucmVxdWlyZShcXFwib3BlbkFwaV90dlxcXCIgKyB0aGlzLm9wZW5TdWZmaXgpO1xcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjBcXFwiOlxcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX2FsaXN0XFxcIiArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRoaXMuX29wZW5Ub29scyA9IG5ldyBPcGVuQXBpVG9vbHModGhpcyk7XFxuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX29wZW5Ub29scztcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0aGlzLCBcXFwib3BlblRva2Vuc1xcXCIsIHtcXG4gICAgICAgIGdldCgpIHtcXG4gICAgIC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GVycikgPT4ge1xcbiAgICAgICAgICAgIHRocm93IGVycjtcXG4gICAgICAgIH0pLmVycm9yVHlwZSgoZXJyLCByZXMpID0+IHtcXG4gICAgICAgICAgICBsZXQgcmVzdWx0ID0ge307XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgcmVzdWx0ID0gSlNPTi5wYXJzZShyZXMuYm9keSk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZXJyO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcmJvZHkgPSAocmVzdWx0LmNvZGUgPyByZXN1bHQgOiAocmVzdWx0ICYmIHJlc3VsdC5yZXNwb25zZXMgJiYgcmVzdWx0LnJlc3BvbnNlc1swXSAmJiByZXN1bHQucmVzcG9uc2VzWzBdLmJvZHkpKSB8fCB7fTtcXG4gICAgICAgICAgICBpZiAocmJvZHkuY29kZSkge1xcbiAgICAgICAgICAgICAgICBsZXQgbXNnID0gcmJvZHkuZGlzcGxheV9tZXNzYWdlIHx8IHJib2R5Lm1lc3NhZ2U7XFxuICAgICAgICAgICAgICAgIGxldCBlcnJvciA9IG5ldyBFcnJvcihhcGkgKyBcXFwiPT5cXFwiICsgcmJvZHkuY29kZSArIFxcXCI6XFxcIiArIG1zZyk7XFxuICAgICAgICAgICAgICAgIGVycm9yLmNvZGUgPSByYm9keS5jb2RlO1xcbiAgICAgICAgICAgICAgICBlcnJvci5qdWRnZU1zZyA9IG1zZztcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVycm9yO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZXJyO1xcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIHNldE15RHJpdmlkVHlwZShpc0JhY2t1cCkge1xcbiAgICAgICAgdGhpcy5teURyaXZpZFR5cGUgPSAhIWlzQmFja3VwO1xcbiAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgI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VXJsKSB7XFxuICAgICAgICBsZXQgcmVzdWx0ID0gdGhpcy5wb3N0QXBpKCdodHRwczovL2FwaS5hbGl5dW5kcml2ZS5jb20vYWRyaXZlL3YyL2JhdGNoJykuYm9keSh7XFxuICAgICAgICAgICAgXFxcInJlcXVlc3RzXFxcIjogW3tcXG4gICAgICAgICAgICAgICAgXFxcImJvZHlcXFwiOiBib2R5LFxcbiAgICAgICAgICAgICAgICBcXFwiaGVhZGVyc1xcXCI6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJDb250ZW50LVR5cGVcXFwiOiBcXFwiYXBwbGljYXRpb24vanNvblxcXCJcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgXFxcImlkXFxcIjogY2xvdWRGaWxlSWQgfHwgXFxcIjBcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwibWV0aG9kXFxcIjogXFxcIlBPU1RcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwidXJsXFxcIjogb3BlcmF0ZVVybFxcbiAgICAgICAgICAgIH1dLFxcbiAgICAgICAgICAgIFxcXCJyZXNvdXJjZVxcXCI6IFxcXCJmaWxlXFxcIlxcbiAgICAgICAgfSkuaGVhZGVycyh7XFxuICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQSxcXG4gICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJyxcXG4gICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAvL2dldEFjY2Vzc1Rva2VuXFxuICAgICAgICAgICAgJ3gtY2FuYXJ5JzogJ2NsaWVudD13ZWIsYXBwPXNoYXJlLHZlcnNpb249djIuMy4xJyxcXG4gICAgICAgICAgICAneC1zaGFyZS10b2tlbic6IHRoaXMuc2hhcmVUb2tlblxcbiAgICAgICAgfSkuZXJyb3JXaXRoUmV0cnkoKGUsIF8sIGh0dHApID0+IHtcXG4gICAgICAgICAgICBpZiAoZS5jb2RlID09PSBcXFwiUXVvdGFFeGhhdXN0ZWQuRHJpdmVcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IGU7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmICghdGhpcy50cnlTb2x2ZShlKSkge1xcbiAgICAgICAgICAgICAgICB0aGlzLndhaXRTbGVlcCgyMCkucmVmcmVzaEFjY2Vzc1Rva2VuKCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBib2R5ID0gaHR0cC5vcHRpb25zLmJvZHkucmVxdWVzdHNbMF0uYm9keTtcXG4gICAgICAgICAgICBpZiAoYm9keS5kcml2ZV9pZCkge1xcbiAgICAgICAgICAgICAgICBib2R5LmRyaXZlX2lkID0gdGhpcy5nZXRNeURyaXZpZCgpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoYm9keS50b19kcml2ZV9pZCkge1xcbiAgICAgICAgICAgICAgICBib2R5LnRvX2RyaXZlX2lkID0gdGhpcy5nZXRNeURyaXZpZCgpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgICAgICd4LXNoYXJlLXRva2VuJzogdGhpcy5zaGFyZVRva2VuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcXG4gICAgfSxcXG4gICAgY29weUZpbGVUb0Nsb3VkRmlsZShmaWxlSWQsIHBhcmVudEZpbGVJZCwgcmV0cnkpIHtcXG4gIC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FxuICAgICAgICAgICAgJ2RyaXZlX2lkJzogdGhpcy5nZXRNeURyaXZpZCgpLFxcbiAgICAgICAgICAgIFxcXCJjYXRlZ29yeVxcXCI6IFxcXCJsaXZlX3RyYW5zY29kaW5nXFxcIixcXG4gICAgICAgICAgICBcXFwidGVtcGxhdGVfaWRcXFwiOiBcXFwiXFxcIixcXG4gICAgICAgICAgICBcXFwiZ2V0X3N1YnRpdGxlX2luZm9cXFwiOiB0cnVlLFxcbiAgICAgICAgICAgIFxcXCJ1cmxfZXhwaXJlX3NlY1xcXCI6IDE0NDAwLFxcbiAgICAgICAgICAgIFxcXCJ3aXRoX3BsYXlfY3Vyc29yXFxcIjogdHJ1ZVxcbiAgICAgICAgfSkuaGVhZGVycyh7XFxuICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQSxcXG4gICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJyxcXG4gICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMub3BlblRva2Vucy5BY2Nlc3NUb2tlbk9wZW5cXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KDIsIChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgLy90aGlzLndhaXRTbGVlcCgzMCkudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMzApLnRyeU9wZW5BcGlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmdldE15RHJpdmlkKCksXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5vcGVuVG9rZW5zLkFjY2Vzc1Rva2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ICAgdGhpcy53YWl0U2xlZXAoMjApLnJlZnJlc2hBY2Nlc3NUb2tlbigpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB0aGlzLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDUwKTtcXG4gICAgICAgICAgICBuZXdTaWduID0gY2FsY3VsYXRlTmV3U2lnbigpO1xcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwdWJLZXlcXFwiOiBuZXdTaWduLnB1YktleVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgICAgICdYLVNoYXJlLVRva2VuJzogdGhpcy5zaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgJ3gtZGV2aWNlLWlkJzogdGhpcy5hbGlUb2tlbnMuZGV2aWNlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgJ3gtc2lnbmF0dXJlJzogbmV3U2lnbi5zaWduYXR1cmVcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuZXJyb3IoKGVyciwgcmVzKSA9PiB7XFxuICAgICAgICAgICAgcmV0dXJuIHt9O1xcbiAgICAgICAgfSkuc3VjY2VzcygoYm9keSkgPT4ge1xcbiAgICAgICAgICAgIHJldHVybiBib2R5O1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICBpZiAocmVzdWx0LnN1Y2Nlc3MpIHtcXG4gICAgICAgICAgICByZXR1cm4gbmV3U2lnbjtcXG4gICAgICAgIH0gZWxzZSB7XF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FxcIjogb3JkZXJCeSArIFxcXCIgXFxcIiArIG9yZGVyRGlyZWN0aW9uLFxcbiAgICAgICAgICAgIFxcXCJtYXJrZXJcXFwiOiBtYXJrZXIgfHwgdW5kZWZpbmVkXFxuICAgICAgICB9KS5oZWFkZXJzKHtcXG4gICAgICAgICAgICAnVXNlci1BZ2VudCc6IFBDX1VBLFxcbiAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nLFxcbiAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgyLCAoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDIwKS5yZWZyZXNoQWNjZXNzVG9rZW4oKTtcXG4gICAgICAgICAgICAvL3RoaXMud2FpdFNsZWVwKDMwKS50cnlPcGVuQXBpU29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ2RyaXZlX2lkJzogdGhpcy5nZXRNeURyaXZpZCgpLFxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUa1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGlmIChPYmplY3Qua2V5cyhyZXN1bHQpLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgICAgIHJlc3VsdC5pdGVtcyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcXG4gICAgfSxcXG4gICAgc2lnbkluUmV3YXJkKCkge1xcbiAgICAgICAgbGV0IHNpbERhdGEgPSB0aGlzLnBvc3RBcGkoJ2h0dHBzOi8vbWVtYmVyLmFsaXl1bmRyaXZlLmNvbS92MS9hY3Rpdml0eS9zaWduX2luX2xpc3QnKS5ib2R5KHtcXG4gICAgICAgICAgICAnZ3JhbnRfdHlwZSc6ICdyZWZyZXNoX3Rva2VuJyxcXG4gICAgICAgICAgICAncmVmcmVzaF90b2tlbic6IHRoaXMuYWxpVG9rZW5zLnJlZnJlc2hfdG9rZW5cXG4gICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAnYXBwbGljYXRpb24vanNvbidcXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KChlLCBfLCBodHRwKSA9PiB7XFxuICAgICAgICAgICAgdGhpcy50cnlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG5cXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ3JlZnJlc2hfdG9rZW4nOiB0aGlzLmFsaVRva2Vucy5yZWZyZXNoX3Rva2VuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgbGV0IGRheSA9IHNpbERhdGEucmVzdWx0LnNpZ25JbkNvdW50O1xcbiAgICAgICAgbGV0IGlzUmV3YXJkID0gc2lsRGF0YS5yZXN1bHQuc2lnbkluTG9nc1tkYXkgLSAxXS5pc1Jld2FyZDtcXG4gICAgICAgIGlmIChpc1Jld2FyZCkge1xcbiAgICAgICAgICAgIGxldCByZXdhcmQgPSBzaWxEYXRhLnJlc3VsdC5zaWduSW5Mb2dzW2RheSAtIDFdLnJld2FyZDtcXG4gICAgICAgICAgICBpZiAocmV3YXJkKSB7XFxuICAgICAgICAgICAgICAgIGxldCByZXdub3RpY2UgPSByZXdhcmQubm90aWNlO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcIuS7iuWkqeW3sue7j+etvuWIsO+8jOivt+S4jeimgemHjeWkjeetvuWIsO+8gVxcXFxuXFxcIiArIHJld25vdGljZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAvL+ayoeacieWlluWKse+8jOWPquacieW5uOi/kOetvuWQjeeJh1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcIuS7iuWkqeW3sue7j+etvuWIsO+8jOivt+S4jeimgemHjeWkjeetvuWIsO+8gVxcXFxu5LuK5pel5aW96L+Q562+OlxcXCIgKyBzaWxEYXRhLnJlc3VsdC5ibGVzc2luZztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBzaXJEYXRhID0gdGhpcy5wb3N0QXBpKCdodHRwczovL21lbWJlci5hbGl5dW5kcml2ZS5jb20vdjEvYWN0aXZpdHkvc2lnbl9pbl9yZXdhcmQnKS5ib2R5KHtcXG4gICAgICAgICAgICAgICAgXFxcInNpZ25JbkRheVxcXCI6IGRheVxcbiAgICAgICAgICAgIH0pLmhlYWRlcnMoe1xcbiAgICAgICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAgICAgJ0NvbnRlbnQtVHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJ1xcbiAgICAgICAgICAgIH0pLnN0YXJ0KHRydWUp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1xcbiAgICAgICAgaWYgKHR5cGVvZiBvcHRpb25zLmJvZHkgPT09IFxcXCJvYmplY3RcXFwiICYmIHRoaXMuX2JvZHlUb1N0cmluZykge1xcbiAgICAgICAgICAgIG9wdGlvbnMuYm9keSA9IEpTT04uc3RyaW5naWZ5KG9wdGlvbnMuYm9keSk7XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgcmVzID0gSlNPTi5wYXJzZSh0aGlzLnN0YXJ0UmVxdWVzdCh0aGlzLnVybCwgb3B0aW9ucykpO1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBpZiAocmVzLnN0YXR1c0NvZGUgPj0gMjAwICYmIHJlcy5zdGF0dXNDb2RlIDw9IDMwMCkge1xcbiAgICAgICAgICAgICAgICBsZXQgYm9keSA9IHJlcy5ib2R5O1xcbiAgICAgICAgICAgICAgICBpZiAodG9Kc29uKSB7XFxuICAgICAgICAgICAgICAgICAgICBib2R5ID0gSlNPTi5wYXJzZShib2R5KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zdWNjZXNzQ2FsbGJhY2soYm9keSwgcmVzKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoU3RyaW5nKHJlcy5zdGF0dXNDb2RlKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZXJyKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgZXJyID0gdGhpcy5lcnJvclR5cGVDYWxsYmFjayhlcnIsIHJlcyk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAodGhpcy5yZXRyeUNvdW50KSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCB0cnlSZXN1bHQgPSB0aGlzLmVycm9yQ2FsbGJhY2tXaXRoUmV0cnkoZXJyLCByZXMsIHRoaXMpO1xcbiAgICAgICAgICAgICAgICBpZiAodHJ5UmVzdWx0KSB7XFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJldHJ5Q291bnQtLTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnN0YXJ0KHRvSnNvbik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICB0aGlzLnJldHJ5Q291bnQgPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZXJyb3JDYWxsYmFjayhlcnIsIHJlcyk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lcnJvckNhbGxiYWNrKGVyciwgcmVzKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNldE9wdGlvbnMob3B0aW9ucykge1xcbiAgICAgICAgdGhpcy5vcHRpb25zID0gT2JqZWN0LmFzc2lnbih7fSwgb3B0aW9ucywge1xcbiAgICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlXFxuICAgICAgICB9KTtcXG4gICAgICAgIHJldHVybiB0aGlzO1xcbiAgICB9LFxcbiAgICBtZXJnZUhlYWRBbmRCb2R5KG9wdGlvbnMpIHtcXG4gICAgICAgIG9wdGlvbnMgPSBvcHRpb25zIHx8IHt9O1xcbiAgICAgICAgdGhpcy5vcHRpb25zLmhlYWRlcnMgPSBPYmplY3QuYXNzaWduKHRoaXMub3B0aW9ucy5oZWFkZXJzLCBvcHRpb25zLmhlYWRlcnMpO1xcbiAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9wdGlvbnMuYm9keSA9PT0gXFxcIm9iamVjdFxcXCIgJiYgdHlwZW9mIG9wdGlvbnMuYm9keSA9PT0gXFxcIm9iamVjdFxcXCIpIHtcXG4gICAgICAgICAgICB0aGlzLm9wdGlvbnMu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XG4gICAgICAgIGNoQ29udmVydDogMVxcbiAgICB9KSkpO1xcbiAgICBsZXQgZE1jb250ZXh0ID0gXFxcIlxcXCI7XFxuICAgIC8vbGV0IGZwc20gPSBnZXRSZWZyZXNoUmF0ZSgpLzYwKjAuOTU7XFxuICAgIC8vZGFuTXVEYXRhLmNvbW1lbnRzLnNvcnQoKHYseCk9PnYucC5zcGxpdChcXFwiLFxcXCIpWzBdLXgucC5zcGxpdChcXFwiLFxcXCIpWzBdKTtcXG4gICAgZm9yIChsZXQgY29tbWVudCBvZiBkYW5NdURhdGEuY29tbWVudHMpIHtcXG4gICAgICAgIC8vZE1jb250ZXh0ICs9IGA8ZCBwPVxcXCIke01hdGgucm91bmQodGltZXBvaW50KX0sJHtjdH0sJHtzaXplfSwke2NvbG9yfSwwXFxcIj4ke2NvbnRlbnR9PC9kPlxcXFxuYDtcXG4gICAgICAgIGxldCBwYXJhbVRleHQgPSBjb21tZW50LnA7XFxuICAgICAgICBsZXQgY29tbWVudFRleHQgPSBjb21tZW50Lm07XFxuICAgICAgICBpZiAocGFyYW1UZXh0ID09IG51bGwgfHwgY29tbWVudFRleHQgPT0gbnVsbCkgY29udGludWU7XFxuICAgICAgICBsZXQgcGFyYW1zID0gcGFyYW1UZXh0LnNwbGl0KFxcXCIsXFxcIik7XFxuICAgICAgICBsZXQgcGFyYW1zVCA9IFtdO1xcbiAgICAgICAgZm9yIChsZXQgaSBpbiBwYXJhbXMpIHtcXG4gICAgICAgICAgICAvKmlmIChpID09IDApIHtcXG4gICAgICAgICAgICAgICAgcGFyYW1zVC5wdXNoKHBhcnNlSW50KHBhcmFtc1tpXSkpO1xcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICBpZiAoaSA9PSAyKSB7XFxuICAgICAgICAgICAgICAgIHBhcmFtc1QucHVzaChcXFwiMjVcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgICAgICAvL+minOiJsuWAvOS4ujDml7bvvIzpu5jorqTorr7nva7kuLrnmb3oibJcXG4gICAgICAgICAgICAgICAgaWYgKHBhcmFtc1tpXSA9PSBcXFwiMFxcXCIgfHwgcGFyYW1zW2ldID09IFxcXCItMVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcmFtc1QucHVzaChcXFwiMTY3NzcyMTVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHBhcmFtc1QucHVzaChwYXJhbXNbaV0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgcGFyYW1zVC5wdXNoKFxcXCIwXFxcIik7XFxuICAgICAgICBsZXQgdGltZXM9cGFyc2VJbnQocGFyYW1zWzBdLzYwKStcXFwiOlxcXCIrcGFyc2VJbnQocGFyYW1zWzBdJTYwKTtcXG4gICAgICAgIGRNY29udGV4dCArPSBgPGQgcD1cXFwiJHtwYXJhbXNULmpvaW4oJywnKX1cXFwiPiR7ZW5jb2RlSHRtbChjb21tZW50VGV4dCkrXFxcIiNcXFwiK3RpbWVzfTwvZD5cXFxcbmA7XFxuICAgIH1cXG4gICAgaWYgKCFkTWNvbnRleHQpIHJldHVybjtcXG4gICAgZE1jb250ZXh0ID0gYDw/eG1sIHZlcnNpb249XFxcIjEuMFxcXCIgZW5jb2Rpbmc9XFxcIlVURi04XFxcIj8+PGk+XFxcXG4ke2RNY29udGV4dH08L2k+YDtcXG4gICAgbGV0IHBhdGggPSBzZXZlUGF0aCArIG5hbWUucmVwbGFjZSgvXFxcXC8vZywgXFxcIl9cXFwiKSArIFxcXCJfXFxcIiArIGVwaXNvZGVJZCArIFxcXCIueG1sXFxcIjtcXG4gICAgd3JpdGVGaWxlKHBhdGgsIGRNY29udGV4dCk7XFxuICAgIHJldHVybi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cXFwiO1xcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YaF572u5pCc57SiUFxcXCIsXFxuICAgIHVybDogJChrZXksIFxcXCLor7fmkJzntKLnlarliaflkI3np7BcXFwiKS5pbnB1dCgoTVlfUEFSQU1TKSA9PiB7XFxuICAgICAgICBzZXRQYWdlUGFyYW1zKE9iamVjdC5hc3NpZ24oTVlfUEFSQU1TLCB7XFxuICAgICAgICAgICAgbmFtZTogaW5wdXQsXFxuICAgICAgICB9KSk7XFxuICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICB9LCBNWV9QQVJBTVMpLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuWGhee9ruaQnOe0olRcXFwiLFxcbiAgICB1cmw6ICQoa2V5LCBcXFwi5qC85byP77ya5pCc57Si5YWz6ZSu6K+NW+Wbnui9pl3pm4bmlbBcXFwiKS5pbnB1dCgob25seURvd25sb2FkKSA9PiB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjmkJzntKLlubbkuIvovb0uLi5cXFwiKTtcXG4gICAgICAgICAgICBsZXQgW25hbWUsIHBvc10gPSBpbnB1dC5zcGxpdChcXFwiXFxcXG5cXFwiKTtcXG4gICAgICAgICAgICBpZiAoIW5hbWUgfHwgIXBvcykge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBcXFwi5qC85byP6ZSZ6K+vXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHVybEluZm8gPSBmZXRjaChidWlsZFVybChcXFwiaHR0cHM6Ly9henVyZS5sZXVzZS50b3Avc2VhcmNoZG1cXFwiLCB7XFxuICAgICAgICAgICAgICAgIHBhcmFtczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBvc1xcXCI6IHBvc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgIHVybEluZm8gPSBKU09OLnBhcnNlKHVybEluZm8pO1xcbiAgICAgICAgICAgIGlmICghdXJsSW5mby51cmwpIHRocm93IFxcXCLmmoLml7bmsqHmnInmib7liLDor6Xop4bpopHnmoTlvLnluZVcXFwiO1xcbiAgICAgICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybChcXFwiaHR0cHM6Ly9henVyZS5sZXVzZS50b3AvZGFubXVcXFwiLCB7XFxuICAgICAgICAgICAgICAgIHBhcmFtczogdXJsSW5mb1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgIGlmICgheG1sKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IFxcXCLov5jmsqHmnInlvLnluZXlk59+XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBhdGggPSBcXFwiaGlrZXI6Ly9maWxlcy9jYWNoZS9kYW5tdS9cXFwiICsgdXJsSW5mby5wbGF0Zm9ybSArIFxcXCJfXFxcIiArIG5hbWUgKyBcXFwiX1xcXCIgKyBwb3MgKyBcXFwiLnhtbFxcXCI7XFxuICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsICc8P3htbCB2ZXJzaW9uPVxcXCIxLjBcXFwiIGVuY29kaW5nPVxcXCJVVEYtOFxcXCI/PlxcXFxuJyArIHhtbCk7XFxuICAgICAgICAgICAgaWYgKG9ubHlEb3dubG9hZCkgcmV0dXJuIFxcXCJ0b2FzdDovL+S4i+i9veWujOaIkFxcXCI7XFxuICAgICAgICAgICAgcmVmcmVzaFZpZGVvVXJsKHtcXG4gICAgICAgICAgICAgICAgZGFubXU6IHBhdGhcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICByZXR1cm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mlzTmFOKGEpIHx8IE51bWJlci5pc05hTihiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ivt+aMieagvOW8j+i+k+WFpeaVsOWtl1xcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKGEgPCAxIHx8IGIgPiBlcGlzb2Rlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXop4TlrprojIPlm7TlhoXnmoTmlbDlrZdcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNvbnN0IGRhbm11ID0gJC5yZXF1aXJlKFxcXCJkYW5tdVxcXCIpO1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IGEgLSAxLCBqID0gMTsgaSA8IGI7IGkrKywgaisrKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVwaXNvZGUgPSBlcGlzb2Rlc1tpXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZG1UaXRsZSA9IGFuaW1lVGl0bGUgKyBcXFwiX1xcXCIgKyBlcGlzb2RlLmVwaXNvZGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5LiL6L2977yaXFxcIiArIGVwaXNvZGUuZXBpc29kZVRpdGxlICsgXFxcIlxcXFx0KFxcXCIgKyBqICsgXFxcIi9cXFwiICsgKGIgLSBhICsgMSkgKyBcXFwiKVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhbm11LmRvd25sb2FkRGFuTXUoZXBpc29kZS5lcGlzb2RlSWQsIGRtVGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZOm5ZOm5LiL6L295aSx6LSlLi4uXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiL6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICB9LCBhbmltZS5hbmltZVRpdGxlLCBhbmltZS5lcGlzb2RlcyksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vbW92aWUvMTQuc3ZnXFxcIlxcbiAgICAgICAgfSk7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgICAgIH0pO1xcbiAgICAgICAgZm9yIChsZXQgZXBpc29kZSBvZiBhbmltZS5lcGlzb2Rlcykge1xcbiAgICAgICAgICAgIGxldCBkbVRpdGxlID0gYW5pbWUuYW5pbWVUaXRsZSArIFxcXCJfXFxcIiArIGVwaXNvZGUuZXBpc29kZVRpdGxlO1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBlcGlzb2RlLmVwaXNvZGVUaXRsZSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKGVwaXNvZGUuZXBpc29kZUlkKS5sYXp5UnVsZSgodXJsLCB0aXRsZSwgb25seURvd25sb2FkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjb25zdCBkYW5tdSA9ICQucmVxdWlyZShcXFwiZGFubXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gZGFubXUuZ2V0TG9jYWxEYW5NdShpbnB1dCwgdGl0bGUpIHx8IGRhbm11LmRvd25sb2FkRGFuTXUoaW5wdXQsIHRpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChvbmx5RG93bmxvYWQpIHJldHVybiBcXFwidG9hc3Q6Ly/kuIvovb3lrozmiJBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRhbm11VGV4dCA9IGZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFkYW5tdVRleHQpIHJldHVybiBcXFwidG9hc3Q6Ly/ov5jmsqHmnInlvLnluZXlk59+XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hWaWRlb1VybCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGFubXU6IHBhdGhcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5Yqg6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgTVlfUEFSQU1TLmR1cmwsIGRtVGl0bGUsIG9ubHlEb3dubG9hZCksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuW8uuWItuS4i+i9vVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGVwaXNvZGVUaXRsZSwgZXBpc29kZUlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLor7fnrYnlvoVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhbm11LmRvd25sb2FkRGFuTXUoZXBpc29kZUlkLCBlcGlzb2RlVGl0bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6YeN5paw5LiL6L295a6M5oiQ77yM5Y2V5Ye75oyC6L2944CCXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBkbVRpdGxlLCBlcGlzb2RlLmVwaXNvZGVJZClcXG4gICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lX2JsYW5rXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgaWYgKCFkbUxpc3QuYW5pbWVzLmxlbmd0aCkge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuayoeacieaJvuWIsOS4jltcXFwiICsgbmFtZSArIFxcXCJd55u45YWz55qE5by55bmVXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBkZXNjOiBcXFwi5pCc5LiN5Yiw5oCO5LmI5Yqe77yfXFxcXG7mo4Dmn6XlkI3np7DmmK/lkKbmraPnoa7vvJvlj6/ku6XlsJ3or5XliKDpmaTpg6jliIbpmZDlrpror43vvIzlpoLnrKzkuIDlraPnrYnvvJvogIzkuJTlj6rog73mkJzntKLnlarliaflk6bvvIHlhbbku5blvLnluZXlj6/nlKhkbeebkuWtkOOAglxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH1cX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ZW50LXR5cGUnOiAnYXBwbGljYXRpb24vanNvbicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwic2hhcmVfaWRcXFwiOiBzaGFyZUlkXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAnUE9TVCdcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGlmIChzaGFyZS5pbmNsdWRlcyhcXFwic2hhcmVfbGluayBpc1xcXCIpIHx8IHNoYXJlLmluY2x1ZGVzKFxcXCJzaGFyZV9saW5rIGNhbm5vdFxcXCIpKSByZXR1cm4gZmFsc2U7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge31cXG4gICAgICAgIHJldHVybiB0cnVlO1xcbiAgICB9LFxcbiAgICBieXRlc1RvU2l6ZShzaXplKSB7XFxuICAgICAgICBpZiAoIXNpemUpIHtcXG4gICAgICAgICAgICByZXR1cm4gJzAnO1xcbiAgICAgICAgfVxcbiAgICAgICAgY29uc3QgdW5pdHMgPSBbJ0InLCAnS0InLCAnTUInLCAnR0InLCAnVEInLCAnUEInLCAnRUInLCAnWkInLCAnWUInXTtcXG4gICAgICAgIGxldCBpID0gMDtcXG4gICAgICAgIHdoaWxlIChzaXplID49IDEwMjQpIHtcXG4gICAgICAgICAgICBzaXplIC89IDEwMjQ7XFxuICAgICAgICAgICAgaSsrO1xcbiAgICAgICAgfVxcbiAgICAgICAgc2l6ZSA9IGkgPyBOdW1iZXIoc2l6ZS50b0ZpeGVkKDI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dHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwidGltZXJcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBpZiAodXBkYXRlSW5mbykge1xcbiAgICAgICAgY29uZmlybSh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmm7TmlrDlhoXlrrlcXFwiLFxcbiAgICAgICAgICAgIGNvbnRlbnQ6IHVwZGF0ZUluZm8sXFxuICAgICAgICAgICAgY29uZmlybSgpe30sXFxuICAgICAgICAgICAgY2FuY2VsKCl7fVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgc2V0UmVzdWx0KGQpO1xcbiAgICB3aGlsZSAodGltZSAhPSAwKSB7XFxuICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDEwMDApO1xcbiAgICAgICAgdGltZSAtPSAxO1xcbiAgICAgICAgdXBkYXRlSXRlbShpZCArIFxcXCJ0aW1lclxcXCIsIHtcXG4gICAgICAgICAgICB0aXRsZTogdGltZSArIFxcXCLnp5LlkI7nu6fnu61cXFwiXFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICB1cGRhdGVJdGVtKGlkICsgXFxcInRpbWVyXFxcIiwge1xcbiAgICAgICAgdGl0bGU6IFxcXCLigJzigJzmiJHlkIzmhI/ku6XkuIropoHmsYLigJ3igJ1cXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCh2KSA9PiB7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwiZmlyc3RcXFwiLCBTdHJpbmcodikpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aEn+iwouaCqOeahOeQhuino1xcXCI7XFxuICAgICAgICB9LCBNWV9SVUxFLnZlcnNpb24pLFxcbi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XJsOiAkKFxcXCItMVxcXCIsIFxcXCLovpPlhaXkvaDopoHliIbkuqvop4TliJnnmoTluo/lj7dcXFxcbi0x5YWo6YOo77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahO+8jC00LOe7hOWQjeWIhuS6q+e7hO+8jOWkmuS4queUqCfvvIwn6ZqU5byAXFxcIikuaW5wdXQoKGxlbmd0aCkgPT4ge1xcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU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ICAgICAgICByZXR1cm4gXFxcInNoYXJlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJ1bGVzO1xcbiAgICAgICAgICAgIGlmIChtbyA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTIpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRVc2VmdWxKc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTMpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRGb3JiaWRkZW5Kc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTQpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gZXh0O1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEdyb3VwSnNvbihleHQpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGVzLmxlbmd0aCkgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWtmOWcqOivpee7hFxcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCkuZmlsdGVyKCh2LCBpKSA9PiBpbmRleHMuaW5jbHVkZXMoaSkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBydWxlcyA9IHJ1bGVzLm1hcCgodikgPT4ge1xcbiAgICAgICAgICAgICAgICB2LnVzZXIgPSB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uW8gOWni+S9jee9ru+8jOe7k+adn+S9jee9rijljLrpl7RbMCxcXFwiICsgKGxlbmd0aCAtIDEpICsgXFxcIl0pXFxcIikuaW5wdXQoKGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgW3N0YXJ0LCBlbmRdID0gaW5wdXQuc3BsaXQoLyx877yMLyk7XFxuICAgICAgICAgICAgICAgIHN0YXJ0ID0gcGFyc2VJbnQoc3RhcnQpLCBlbmQgPSBwYXJzZUludChlbmQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKHN0YXJ0KSB8fCBOdW1iZXIuaXNOYU4oZW5kKSB8fCBzdGFydCA8IDAgfHwgZW5kID4gbGVuZ3RoIC0gMSB8fCBzdGFydCA+IGVuZCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aVsOWtl+S4jeWQiOazlVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IG51bWJlciA9IGVuZCAtIHN0YXJ0ICsgMTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8mltcXFwiICsgc3RhcnQgKyBcXFwiLFxcXCIgKyBlbmQgKyBcXFwiXVxcXFxu5YWxXFxcIiArIG51bWJlciArIFxcXCLmnaHmkJzntKLlvJXmk45cXFwiKS5jb25maXJtKChzdGFydCwgbnVtYmVyKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2Uoc3RhcnQsIG51bWJlcik7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIHN0YXJ0LCBudW1iZXIpO1xcbiAgICAgICAgICAgIH0sIGxlbmd0aCk7XFxuICAgICAgICB9XFxuICAgIH0sIGdyb3VwLCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxufSk7XFxuZm9yIChsZXQgaXQgb2YgZ3JvdXBzKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogaXQgPT09IGdyb3VwID8gXFxcIuKAnOKAnFxcXCIgKyBpdCArIFxcXCLigJ3igJ1cXFwiIDogaXQsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGl0LCBncm91cCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChncm91cCAhPT0gaXQpIHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIsIGl0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChbXFxcIue9rumhtlxcXCIsIFxcXCLnva7lupVcXFwiLCBcXFwi5pS55ZCNXFxcIiwgXFxcIuWIoOmZpFxcXCJdKS5zZWxlY3QoKGl0KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoXFxcIuaUueWQjVxcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXQsIFxcXCLor7fovpPlhaXmlrDlkI3np7BcXFwiKS5pbnB1dCgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcy5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ID09PSB2Lmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdi5ncm91cCA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVNYW5hZ2VfZ3JvdXBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoXFxcIuWIoOmZpFxcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuaYr+WQpuWIoOmZpOivpee7hOaQnOe0ouW8leaTju+8mlxcXCIgKyBpdCkuY29uZmlybSgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcyA9IHJ1bGVzLmZpbHRlcih2ID0+IHYuZ3JvdXAgIT09IGl0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVNYW5hZ2VfZ3JvdXBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB0Z1J1bGVzID0gW10sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdHhSdWxlcyA9IFtdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuZm9yRWFjaCgodikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdCA9PT0gdi5ncm91cCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0Z1J1bGVzLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHhSdWxlcy5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRnUnVsZXMgPSB0Z1J1bGVzLmNvbmNhdCh0eFJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGdSdWxlcyA9IHR4UnVsZXMuY29uY2F0KHRnUnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24odGdSdWxlcyk7XFxuICAgICAgICAgICAgICAgICAgIC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GgsIGdyb3VwKSA9PiB7XFxuICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi57yW6L6RXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSMjbm9SZWZyZXNoI1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIui0puWPt1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcGFzc3dvcmQjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjI25vUmVmcmVzaCNcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliIbkuqtcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBvcHMgPSBnZXRQYXN0ZXMoKTtcXG4gICAgICAgICAgICAgICAgb3BzLnVuc2hpZnQoXFxcIuWujOaVtOWPo+S7pFxcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChvcHMsIDIsIFxcXCLliIbkuqvmlrnlvI9cXFwiKS5zZWxlY3QoKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKVtpbmRleF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlLnVzZXIgPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBydWxlLmZvcmJpZGRlbiA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlYjY0ID0gYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBnZXRQYXNzID0gKG5hbWUsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzvvIzjgIxcXFwiICsgbmFtZSArIFxcXCLjgI3kupHnroDmkJzntKLlvJXmk47vvIzlpI3liLbmlbTmnaHlj6Pku6TmiZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHJ1bGUgKyBcXFwiJFxcXCIgKyB0eXBlICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT0gXFxcIuWujOaVtOWPo+S7pFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHJ1bGViNjQsIFxcXCJhXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGlmIChncm91cCkge1xcbiAgICAgICAgICAgICAgICAgICAgbmV3SW5kZXggPSBydWxlcy5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgICAgICBuZXdJbmRleCA9IG5ld0luZGV4ID09PSAtMSA/IDAgOiBuZXdJbmRleDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXCIgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgICAgIHJ1bGUuZm9yYmlkZGVuID0gIXJ1bGUuZm9yYmlkZGVuO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihhcnIpO1xcbi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leXdvcmRcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICByZXR1cm4gJCh0ZXN0S2V5d29yZCwgXFxcIuivt+i+k+WFpeWFs+mUruivjVxcXCIpLmlucHV0KChwYWdlKSA9PiB7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwidGVzdEtleXdvcmRcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgZmluZCA9IGdldE15VmFyKFxcXCJwc19maW5kXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmICghZmluZCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pCc57Si6KeE5YiZ5LiN6IO95Li656m6XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICBsZXQgdGVzdFJ1bGUgPSB7XFxuICAgICAgICAgICAgICAgIG5hbWU6IG5hbWUsXFxuICAgICAgICAgICAgICAgIGZpbmQ6IGZpbmQsXFxuICAgICAgICAgICAgICAgIGJhc2ljVXJsOiBnZXRNeVZhcihcXFwicHNfYmFzaWNVcmxcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgICAgIGZpbmRBbGlVcmw6IGdldE15VmFyKFxcXCJwc19maW5kQWxpVXJsXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgICAgICAgICBwYWdlOiAhIWdldE15VmFyKFxcXCJwc19wYWdlXFxcIiwgcGFnZSA/IFxcXCIxXFxcIiA6IFxcXCJcXFwiKSxcXG4gICAgICAgICAgICAgICAgcnVsZVR5cGU6IGdldE15VmFyKFxcXCJwc19ydWxlVHlwZVxcXCIsIFxcXCJcXFwiKSxcXG4gICAgICAgICAgICB9O1xcbiA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gICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeinhOWImVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqMSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgb2JqMSk7XFxuICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgb2JqMSk7XFxuICAgICAgICB9XFxuICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYX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eW+gOazqOWGjFxcXCIsXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCJoaWtlcjovL2VtcHR5I25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCIpLnJ1bGUoKHJlZ2lzdGVyVXJsKT0+e1xcbiAgICAgICAgICAgICAgICBzZXRSZXN1bHQoW3tcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOlxcXCJ4NV93ZWJ2aWV3X3NpbmdsZVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6cmVnaXN0ZXJVcmwsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOlxcXCJmbG9hdCYmMTAwJVxcXCJcXG4gICAgICAgICAgICAgICAgfV0pO1xcbiAgICAgICAgICAgIH0sIHJlZ2lzdGVyVXJsKSxcXG4gICAgICAgICAgICBleHRyYTp7XFxuICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogXFxcIuazqOWGjOi0puWPtzpcXFwiICsgb2JqLm5hbWVcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICBvYmogPSBvYmoudXNlciB8fCB7fTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIueUqOaIt+WQjVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouYWNjb3VudCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogXFxcInBhc3N3b3JkXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19wYXNzd29yZFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5wYXNzd29yZCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIumineWkllxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHR5cGU6IFxcXCJ0ZXh0YXJlYVxcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfZXh0cmFcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouZXh0cmEsXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICBoZWlnaHQ6IC0xXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgIGxldCBhY2NvdW50ID0gZ2V0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IHBhc3N3b3JkID0gZ2V0TXlWYXIoXFxcInBzX3Bhc3N3b3JkXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBleHRyYSA9IGdldE15VmFyKFxcXCJwc19leHRyYVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAvKmlmICghKGFjY291bnR8fHBhc3N3b3JkfHxleHRyYSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveWFqOmDqOS4uuepulxcXCI7XFxuICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICBsZXQgaXRlbSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgaXRlbS51c2VyID0ge307XFxuICAgICAgICAgICAgaXRlbS51c2VyLmFjY291bnQgPSBhY2NvdW50XFxuICAgICAgICAgICAgaXRlbS51c2VyLnBhc3N3b3JkID0gcGFzc3dvcmQ7XFxuICAgICAgICAgICAgaXRlbS51c2VyLmV4dHJhID0gZXh0cmE7XFxuICAgICAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9pZOmUmeivr1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgaXRlbSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgYmFjayh0cnVlKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+d5a2Y5oiQ5YqfXFxcIjtcXG4gICAgICAgIH0sIGluZGV4KSxcXG4gICAgICAgIGNvbF90eXBl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CBydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vU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iKSkgfHwgW107XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAvL2Rlc2M6IHRpbWVbMF0sXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGJhc2U2NERlY29kZShwZGZoKGl0ZW0sIFxcXCJhJiZ1cmxcXFwiKSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi5re35ZCI55uYXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vYXBpLmh1bmhlcGFuLmNvbS92MS9zZWFyY2hcXFwiO1xcbiAgICAgICAgICAgIGxldCBqc29uID0gcG9zdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgUmVmZXJlcjogXFxcImh0dHBzOi8vaHVuaGVwYW4uY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInFcXFwiOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VcXFwiOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInNpemVcXFwiOiAxNVxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKGpzb24pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5kYXRhLmxpc3Q7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gbGlzdFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGl0LmRpc2tfdHlwZSAhPT0gXFxcIkFMWVxcXCIgfHwgaXQuc2hhcmVfdXNlciA9PT0gXFxcIuS4tioqKuS4tlxcXCIpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LmRpc2tfbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBkKGl0LCBcXFwiaW1nJiZzcmNcXFwiLCB1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpdC5saW5rLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQudXBkYXRlX3RpbWUgKyBcXFwiXFxcXG5cXFwiICsgaXQubGluayxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi6LWE5rqQ5biuXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBmdW5jdGlvbiBzZWFyY2goKSB7XFxuICAgICAgICAgICAgICAgIGxldCBydG5MaXN0ID0gW107XFxuICAgICAgICAgICAgICAgIGxldCByZXNwID0gcmVxdWVzdChcXFwiaHR0cHM6Ly96eWIudXB5dW5zby5jb20vdjE1L3NlYXJjaD9rZXl3b3JkPVxcXCIgKyBlbl9hZXMocykgKyBcXFwiJnNfdHlwZT0yJnBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiJmF0az0mZGlkPVxcXCIgKyBnZW5lcmF0ZVJhbmRvbUhleFN0cmluZyg2NCksIHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwidXNlci1hZ2VudFxcXCI6IFxcXCJNb3ppbGxhLzUuMCAoTGludXg7IEFuZHJvaWQgMTA7IFJlZG1pIE5vdGUgNyBCdWlsZC9RS1ExLjE5MDkxMC4wMDI7IHd2KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBWZXJzaW9uLzQuMCBDaHJvbWUvODEuMC40MDQ0LjEzOCBNb2JpbGUgU2FmYXJpLzUzNy4zNiB1bmktYXBwIEh0bWw1UGx1cy8xLjAgKEltbWVyc2VkLzI5LjA5MDkxKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc3BEYXRhID0gZGVfYWVzKHJlc3ApO1xcbiAgICAgICAgICAgICAgICBsZXQganNvbkRhdGEgPSBKU09OLnBhcnNlKHJlc3BEYXRhKSB8fCB7fTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlc3VsdCA9IGpzb25EYXRhLnJlc3VsdCB8fCB7fTtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gcmVzdWx0Lml0ZW1zIHx8IFtdO1xcblxcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGl0ZW1zLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGl0ZW1zW2ldO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSBpdGVtLmNvbnRlbnQgfHwgW107XFxuICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudC5sZW5ndGggPT0gMCB8fCAhaXRlbS5wYWdlX3VybCkgY29udGludWU7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdXJsID0gZGVfYWVzKGl0ZW0ucGFnZV91cmwpIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF1cmwpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICAgICAgcnRuTGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogKGl0ZW0udGl0bGUubGVuZ3RoID4gMzAgPyBpdGVtLnRpdGxlLnNsaWNlKDAsIDI3KSArIFxcXCIuLi5cXFwiIDogaXRlbS50aXRsZSkgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIuWIhuS6q+aXtumXtO+8mlxcXCIgKyBpdGVtLmluc2VydF90aW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogdXJsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICByZXR1cm4gcnRuTGlzdDtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJhdGVSYW5kb21IZXhTdHJpbmcobGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgY29uc3QgY2hhcmFjdGVycyA9IFxcXCIwMTIzNDU2Nzg5YWJjZGVmXFxcIjtcXG4gICAgICAgICAgICAgICAgY29uc3QgY2hhcmFjdGVyc0xlbmd0aCA9IGNoYXJhY3RlcnMubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gY2hhcmFjdGVycy5jaGFyQXQoTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogY2hhcmFjdGVyc0xlbmd0aCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGVuX2FlcyhlKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gXFxcInFxMTkyMDUyMDQ2MHFxenpcXFwiO1xcbiAgICAgICAgICAgICAgICAvLyBlbl9hZXNcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGkpO1xcbiAgICAgICAgICAgICAgICB2YXIgdCA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGUpLFxcbiAgICAgICAgICAgICAgICAgICAgciA9IENyeXB0b0pTLkFFUy5lbmNyeXB0KHQsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHIuY2lwaGVydGV4dC50b1N0cmluZygpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBkZV9hZXModnYpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBcXFwicXExOTIwNTIwNDYwcXF6elxcXCI7XFxuICAgICAgICAgICAgICAgIC8vIGRlX2Flc1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoaSk7XFxuICAgICAgICAgICAgICAgIGxldCBoZXhWYWwgPSBDcnlwdG9KUy5lbmMuSGV4LnBhcnNlKHZ2KSxcXG4gICAgICAgICAgICAgICAgICAgIHZhbCA9IENyeXB0b0pTLmVuYy5CYXNlNjQuc3RyaW5naWZ5KGhleFZhbCksXFxuICAgICAgICAgICAgICAgICAgICBkZWNyeXB0ZWQgPSBDcnlwdG9KUy5BRVMuZGVjcnlwdCh2YWwsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGRlY3J5cHRlZC50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBzZWFyY2goKTtcXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgbmFtZTogXFxcIuS6keebmOi1hOa6kFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9yZXMueXVucGFuLndpbi8/UGFnZUluZGV4PVxcXCIgKyBwYWdlICsgXFxcIiZQYWdlU2l6ZT0xMiZLZXl3b3JkPVxcXCIgKyBzICsgXFxcIiZUeXBlPSZUYWc9XFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vcmVzLnl1bnBhbi53aW4vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIm1haW4mJi5jYXJkXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZGZoKGl0LCBcXFwiLmNhcmQtbGluaywxJiZvbmNsaWNrXFxcIikubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgICAgIHUgPSB1Lmxlbmd0aCA+IDAgPyB1WzBdIDogdXJsO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgoaXQsIFxcXCIuY2FyZC10aXRsZSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogcGQoaXQsIFxcXCJpbWcmJnNyY1xcXCIsIHVybCksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwZGZoKGl0LCBcXFwiLmNhcmQtdGV4dCwtMSYmVGV4dFxcXCIpICsgXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIlVQ5LqR5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2FwaS51cHl1bnNvMi5jb20vc2VhcmNoP2tleXdvcmQ9XFxcIiArIHMgKyBcXFwiJnBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiJnNfdHlwZT0xXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LnVweXVuc28uY29tXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJDb29raWVcXFwiOiBcXFwiY29kZT0xOTE5XFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgLy9sb2coYmFzZTY0RGVjb2RlKGh0bWwpKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShiYXNlNjREZWNvZGUoaHRtbCkpLnJlc3VsdC5pdGVtcztcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgaWYgKCFhcnIpIHJldHVybiBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gaXQucGFnZV91cmw7XFxuICAgICAgICAgICAgICAgIC8vdSA9IHUubGVuZ3RoID4gMCA/IHVbMF0gOiB1cmw7XFxuICAgICAgICAgICAgICAgIGlmICghdS5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCJcXFxcblxcXCIgKyAodSksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIueMq+eLuOebmOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb20vc2VhcmNoP2s9XFxcIiArIHMsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpcGFuc291LmNvbS9zZWFyY2g/az1cXFwiICsgc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIiNhcHAmJmFcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gXFxcIjxkaXY+XFxcIiArIGFycltpXSArIFxcXCI8L2Rpdj5cXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkZmgoaXQsIFxcXCJhJiZocmVmXFxcIik7XFxuICAgICAgICAgICAgICAgIC8vbG9nKHUpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXUuaW5jbHVkZXMoXFxcIi9zL1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB1ID0gXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb21cXFwiICsgdS5yZXBsYWNlKFxcXCIvcy9cXFwiLCBcXFwiL2N2L1xcXCIpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgoaXQsIFxcXCJ0ZW1wbGF0ZSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGRmaChpdCwgXFxcInRlbXBsYXRlLDEmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoaW5wdXQsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIkNvb2tpZVxcXCI6IFxcXCJub19zaG93X2RvbmF0ZT0xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogaW5wdXQucmVwbGFjZShcXFwiL2N2L1xcXCIsIFxcXCIvcy9cXFwiKVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICByZWRpcmVjdDogZmFsc2VcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBodG1sID0gcGFyc2VEb21Gb3JIdG1sKGh0bWwsICdhJiZocmVmJyk7XFxuICAgICAgICAgICAgaWYgKGh0bWwubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaHRtbDtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5wdXQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5piT5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICByZWdpc3RlclVybDogXFxcImh0dHBzOi8veWlzby5mdW5cXFwiLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGtleWVuKHN0cikge1xcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjRPVG9TY1VGT2FlVlRySEVcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIGl2ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjlDTEdhbzF2SEtxbTE3T3pcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGVuY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHtcXG4gICAgICAgICAgICAgICAgICAgIGNpcGhlcnRleHQ6IENyeXB0b0pTLmVuYy5CYXNlNjQucGFyc2Uoc3RyKVxcbiAgICAgICAgICAgICAgICB9LCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIGl2OiBpdixcXG4gICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuQ0JDLFxcbiAgICAgICAgICAgICAgICAgICAgcGFkZGluZzogQ3J5cHRvSlMucGFkLlBrY3M3XFxuICAgICAgICAgICAgICAgIH0pLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVuY3J5cHRlZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3lpc28uZnVuL2FwaS9zZWFyY2g/bmFtZT1cXFwiICsgcyArIFxcXCImcGFnZU5vPVxcXCIgKyBwYWdlLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8veWlzby5mdW4vaW5mbz9zZWFyY2hLZXk9XFxcIiArIHMsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogZ2V0SXRlbSgneWlzb3Vjb29rZScsICcnKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgLy9sb2coaHRtbCk7XFxuICAgICAgICAgICAgaWYgKGh0bWwuaW5jbHVkZXMoJ+eZu+W9leeUqOaIt+aXoOmZkOWIticpKSB7XFxuICAgICAgICAgICAgICAgIHZhciBpID0gMDtcXG4gICAgICAgICAgICAgICAgZG8ge1xcbiAgICAgICAgICAgICAgICAgICAgdmFyIHR5aW1nbGluID0gJ2h0dHBzOi8veWlzby5mdW4vYXBpL3VzZXIvbG9naW4vY2FwdGNoYT90PScgKyBwYXJzZUludChuZXcgRGF0ZSgpLmdldFRpbWUoKSkgKyAnJztcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbWcgPSBjb252ZXJ0QmFzZTY0SW1hZ2UodHlpbWdsaW4pLnNwbGl0KCcsJylbMV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29kID0gcmVxdWVzdCgnaHR0cHM6Ly9hcGkueGhvZmUudG9wL29jci9iNjQvdGV4dCcsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAndGV4dC9wbGFpbidcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvZHk6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICdQT1NUJ1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgdmVyID0gSlNPTi5wYXJzZShyZXF1ZXN0KCdodHRwczovL3lpc28uZnVuL2FwaS91c2VyL2xvZ2luJywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2NvbnRlbnQtdHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ3JlZmVyZXInOiAnaHR0cHM6Ly95aXNvLmZ1bi9sb2dpbicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb29raWUnOiBnZXRDb29raWUodHlpbWdsaW4pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJ1c2VyTmFtZVxcXCI6IHVzZXIuYWNjb3VudCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcInBhc3N3b3JkXFxcIjogdXNlci5wYXNzd29yZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcImNvZGVcXFwiOiBjb2RcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodmVyLmNvZGUgPT0gMjAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCfmmJPmkJznmbvlhaXpqozor4HmiJDlip8nKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKCd5aXNvdWNvb2tlJywgZ2V0Q29va2llKCdodHRwczovL3lpc28uZnVuJykpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3lpc28uZnVuL2FwaS9zZWFyY2g/bmFtZT1cXFwiICsgcyArIFxcXCImcGFnZU5vPVxcXCIgKyBwYWdlLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8veWlzby5mdW4vaW5mbz9zZWFyY2hLZXk9XFxcIiArIHMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogZ2V0SXRlbSgneWlzb3Vjb29rZScsICcnKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpKys7XFxuICAgICAgICAgICAgICAgIH0gd2hpbGUgKGkgPCA0KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoaHRtbCkuZGF0YS5saXN0O1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0ga2V5ZW4oaXQudXJsKTtcXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGlmICh1ID09IG51bGwgfHwgIXUuaW5jbHVkZXMoXFxcImFsaXl1blxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiAoaXQuZ210U2hhcmUgfHwgaXQuZ210Q3JlYXRlKSArIFxcXCJcXFxcblxcXCIgKyAodSksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuWwj+e6uOadoVxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGdldHRva2VuKCkge1xcbiAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoJ3h6eXRva2VuJywgJycpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdG9rZW4gPSBKU09OLnBhcnNlKHBvc3QoJ2h0dHBzOi8vZ2l0Y2FmZS5uZXQvdG9vbC9hbGlwYXBlci8nLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3UuZ2l0Y2FmZS5pbmsvJ1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246ICdnZXRfdG9rZW4nXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVx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cXCIsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly91LmdpdGNhZmUuaW5rLydcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiBcXFwic2VhcmNoXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGZyb206IFxcXCJ3ZWJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgdG9rZW46IGdldHRva2VuKCksXFxuICAgICAgICAgICAgICAgICAgICBrZXl3b3JkOiBzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKTtcXG4gICAgICAgICAgICBpZiAobGlzdC5kYXRhKSB7XFxuICAgICAgICAgICAgICAgIGxpc3QgPSBsaXN0LmRhdGE7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldXFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0LnRpdGxlO1xcbiAgICAgICAgICAgICAgICBsZXQgbXVybCA9ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy8nICsgaXQuYWxpa2V5XFxuICAgICAgICAgICAgICAgIGlmICghYWxpVXRpbC5jaGVja2FsaShtdXJsKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oiaIFxcXCIgKyB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBjYXRfY29kZShpdC5jYXQpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlczogaXQuZGVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IG11cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi546p5YG25ZOl5ZOlXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBiYXNpY1VybDogXFxcImh0dHA6Ly93b2dnLnh5elxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGJhc2ljVXJsICsgXFxcIi9pbmRleC5waHAvdm9kc2VhcmNoL1xcXCIgKyBzICsgXFxcIi0tLS0tLS0tLS1cXFwiICsgcGFnZSArIFxcXCItLS0uaHRtbFxcXCI7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgXFxcIi5tb2R1bGUtaXRlbXMmJi5tb2R1bGUtc2VhcmNoLWl0ZW1cXFwiKTtcXG5cXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGRmaChpdCwgXFxcImgzJiZhJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGRmaChpdCwgXFxcIi52aWRlby1zZXJpYWwmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpbWFnZSA9IHBkZmgoaXQsIFxcXCJpbWcmJmRhdGEtc3JjXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGQoaXQsIFxcXCJoMyYmYSYmaHJlZlxcXCIsIGJhc2ljVXJsKTtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHV0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHVpbWFnZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHVzZXJpYWxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJldHVybiBiZXQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIHJldHVybiBwZGZhKHJlcXVlc3QoaW5wdXQpLCBcXFwiYm9keSYmLm1vZHVsZS1yb3ctdGV4dC5jb3B5XFxcIikubWFwKHYgPT4gcGRmaCh2LCBcXFwiYSYmZGF0YS1jbGlwYm9hcmQtdGV4dFxcXCIpKTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIumYv+mHjOS6keebmOe9kVxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgYmFzaWNVcmw6IFxcXCJodHRwczovL3d3dy5hbHlwdy5jblxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGJhc2ljVXJsICsgXFxcIi9zZWFyY2gucGhwP3E9XFxcIiArIHMgKyBcXFwiJnBhZ2U9XFxcIiArIHBhZ2U7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge30pO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCIubGlzdCYmbGlcXFwiKTtcXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGRmaChpdCwgXFxcImEmJnRpdGxlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGRmaChpdCwgXFxcIi5mYS1jbG9jay1vJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1hZ2UgPSBwZGZoKGl0LCBcXFwiaW1nJiZzcmNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCBiYXNpY1VybCk7XFxuICAgICAgICAgICAgICAgIGlmICghdXRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdXRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogdWltYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogdXNlcmlhbFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHBkZmEocmVxdWVzdChpbnB1dCksIFxcXCJib2R5JiZhW2hyZWZePWh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL11cXFwiKS5tYXAodiA9PiBwZGZoKHYsIFxcXCJhJiZocmVmXFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5Zyf5ouo6bygXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gZmV0Y2goJ2h0dHBzOi8vd3d3LnRic2R5LmNvbS9zZWFyY2guaHRtbD9rZXl3b3JkPScgKyBzICsgJyZjYXRlZ29yeT05ODM5MjAmZGF0YV90eXBlPTk4NzkxMCcsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgJy5zZWFyY2hfcmVzdWx0X25ldGRpc2tfbGlzdCYmYScpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhpdCk7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnYSYmaHJlZicpO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnLm5ldGRpc2tfaXRlbV9kZXRhaWxfbmFtZSYmVGV4dCcpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXRpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0LFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIumYv+mHjOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KCdodHRwczovL2FsaXNvLmNjL3MvJyArIHMgKyAnLScgKyBwYWdlICsgJy0wLmh0bWwnLCB7fSk7XFxuXFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsICcuc2VhcmNoLXJlc3VsdCYmLnJlc291cmNlLWl0ZW0nKTtcXG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGxpc3QubGVuZ3RoOyBqKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBsaXN0W2pdO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0ID0gcGFyc2VEb21Gb3JIdG1sKHUsICdoMyYmVGV4dCcpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXRpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXQsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHBhcnNlRG9tKHUsICdoMyYmYSYmaHJlZicsICdodHRwczovL2FsaXNvLmNjLycpLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGFyc2VEb21Gb3JIdG1sKHUsICcudGltZSYmVGV4dCcpLFxcbiAgICAgICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGV2YWwoZ2V0Q3J5cHRvSlMoKSk7XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZGVjcnkoc3RyKSB7XFxuICAgICAgICAgICAgICAgIHZhciBrZXkgPSBDcnlwdG9KUy5lbmMuVXRmOC5wYXJzZShcXFwiOUVCMjBEREZENkFGQkQ2OFxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgZW5jcnlwdGVkID0gQ3J5cHRvSlMuQUVTLmRlY3J5cHQoc3RyLCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICBtb2RlOiBDcnlwdG9KUy5tb2RlLkNCQyxcXG4gICAgICAgICAgICAgICAgICAgIHBhZGRpbmc6IENyeXB0b0pTLnBhZC5Qa2NzN1xcbiAgICAgICAgICAgICAgICB9KS50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBlbmNyeXB0ZWQ7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChpbnB1dCk7XFxuICAgICAgICAgICAgbGV0IGJ1dCA9IHBhcnNlRG9tKGh0b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m4gZW5jcnlwdGVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoXFxcImh0dHBzOi8vd3d3Lnl1bnBhbmZlbnhpYW5nLmNuL2FwaS9iYnMvYXBpL2dldGRhdGE/a2V5PVxcXCIgKyBzICsgXFxcIiZ0eXBlPXZpZGVvXFxcIiwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy55dW5wYW5mZW54aWFuZy5jbi9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQganNvbiA9IGRlY3J5KEpTT04ucGFyc2UoaHRtbCkuZGF0YSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoanNvbik7XFxuXFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGl0LnBpZDtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vYXBpL2Jicy9hcGkvZ2V0YXJ0aWNsZT9pZD1cXFwiICsgdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQuY3JlYXRldGltZVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QoaW5wdXQsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSkpLmRhdGE7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLmRvd25sb2FkLnNwbGl0KFxcXCJAXFxcIik7XFxuICAgICAgICAgICAgbGV0IGFsaXN0ID0gbmV3IFNldCgpO1xcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbGlzdC5sZW5ndGg7IGorKykge1xcbiAgICAgICAgICAgICAgICBhbGlzdC5hZGQoXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL1xcXCIgKyBsaXN0W2pdKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIEFycmF5LmZyb20oYWxpc3QpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi55uY5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgcGFnZSA9IChwYWdlIC0gMSkgKiAxMDtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vd3d3LnBhbnNlYXJjaC5tZS9zZWFyY2g/a2V5d29yZD1cXFwiICsgcyArIFxcXCImb2Zmc2V0PVxcXCIgKyBwYWdlICsgXFxcIiZwYW49YWxpeXVuZHJpdmVcXFwiO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdCh1cmwsIHt9KTtcXG5cXG4gICAgICAgICAgICBsZXQgYXJyID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCAnLmdyaWQmJi5zaGFkb3c6aGFzKGFbaHJlZl49aHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXSknKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBhcnNlRG9tRm9ySHRtbChpdCwgJ2FbaHJlZl49aHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL3MvXSYmaHJlZicpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGljX3VybCA9IHBhcnNlRG9tRm9ySHRtbChpdCwgJ2ltZyYmc3JjJyk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogcGFyc2VEb21Gb3JIdG1sKGl0LCAnLmJyZWFrLWFsbCYmVGV4dCcpLnNwbGl0KCdodHRwJylbMF0sXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsID09PSBcXFwiL2Zhdmljb24ucG5nXFxcIiA/IFxcXCJodHRwczovL3d3dy5wYW5zZWFyY2gubWUvXFxcIiArIHBpY191cmwgOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGFyc2VEb21Gb3JIdG1sKGl0LCAncCYmVGV4dCcpICsgXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIkRPVljmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogZmFsc2UsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2FwaS5kb3Z4LnRrL2FsaS9zZWFyY2g/d2Q9XFxcIiArIHM7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoaHRtbCkubGlzdDtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IGl0LnZvZF9jb250ZW50O1xcbiAgICAgICAgICAgICAgICBpZiAoIXUuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikgfHwgIWFsaVV0aWwuY2hlY2thbGkodSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKImiBcXFwiICsgaXQudm9kX25hbWUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuW/heW6lFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9jbi5iaW5nLmNvbS9zZWFyY2g/cT1cXFwiICsgcyArIFxcXCIrYWxpeXVuZHJpdmUmcXM9ZHMmZm9ybT1RQlJFXFxcIjtcXG4gICAgICAgICAgICBpZiAocGFnZSAhPSAxKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IGdldE15VmFyKFxcXCJiaW5nXFxcIiwgdXJsKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL2NuLmJpbmcuY29tL1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAvL1xcXCJYLVJlcXVlc3RlZC1XaXRoXFxcIjogXFxcImNvbS5leGFtcGxlLmhpa2Vydmlld1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiQWNjZXB0XFxcIjogXFxcInRleHQvaHRtbCxhcHBsaWNhdGlvbi94aHRtbCt4bWwsYXBwbGljYXRpb24veG1sO3E9MC45LGltYWdlL2F2aWYsaW1hZ2Uvd2VicCxpbWFnZS9hcG5nLCovKjtxPTAuOCxhcHBsaWNhdGlvbi9zaWduZWQtZXhjaGFuZ2U7dj1iMztxPTAuOVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCJib2R5JiZhXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCB1cmwpO1xcbiAgICAgICAgICAgICAgICBsZXQgdCA9IHBkZmgoaXQsIFxcXCJhJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGlmIChpdC5pbmNsdWRlcyhcXFwiTmV4dCBwYWdlXFxcIikgfHwgaXQuaW5jbHVkZXMoXFxcIuS4i+S4gOmhtVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdTIgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCB1cmwpO1xcbiAgICAgICAgICAgICAgICAgICAgLy9sb2coXFxcIm5leHQgcGFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy9sb2codTIpO1xcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcImJpbmdcXFwiLCB1Mik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHUgPT0gbnVsbCB8fCB0ID09IG51bGwgfHwgIWl0LmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAoIWl0LmluY2x1ZGVzKFxcXCLnvZHnm5hcXFwiKSAmJiAhaXQuaW5jbHVkZXMoXFxcIuS6keebmFxcXCIpICYmXFxuICAgICAgICAgICAgICAgICAgICAhaXQuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikgJiYgIWl0LmluY2x1ZGVzKFxcXCJ5dW5wYW5cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHUuc3RhcnRzV2l0aChcXFwiaHR0cHM6Ly9jbi5iaW5nLmNvbS9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGRvbSA9IGdldEhvbWUodSkucmVwbGFjZShcXFwiaHR0cDovL1xcXCIsIFxcXCJcXFwiKS5yZXBsYWNlKFxcXCJodHRwczovL1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IF9saW5rcyA9IHQubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgICAgIGxldCBjID0gbnVsbDtcXG4gICAgICAgICAgICAgICAgaWYgKF9saW5rcy5sZW5ndGggPiAxICYmIF9saW5rc1sxXS5yZXBsYWNlKF9saW5rc1swXSwgXFxcIlxcXCIpLnJlcGxhY2UoL1thLXpBLVowLTldKy9nLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIGMgPSBfbGlua3NbMV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoX2xpbmtzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIGMgPSBfbGlua3NbMF07XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogZG9tLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBjICE9IG51bGwgPyBjIDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui/m+WFpee9keermVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQodSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBpZiAoaW5wdXQuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikpIHJldHVybiBpbnB1dDtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoaW5wdXQpO1xcbiAgICAgICAgICAgIHZhciBfbGlua3MgPSBodG1sLm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgIGlmIChfbGlua3MubGVuZ3RoID4gMSAmJiBfbGlua3NbMV0ucmVwbGFjZShfbGlua3NbMF0sIFxcXCJcXFwiKS5yZXBsYWNlKC9bYS16QS1aMC05XSsvZywgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBfbGlua3NbMV07XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChfbGlua3MubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gX2xpbmtzWzBdO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogJ0NDT0YnLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdXFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IGZldGNoKCdodHRwczovL3Bhbi5jY29mLmNjL2FwaS9zZWFyY2gnLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb250ZW50LXR5cGVcXFwiOiAnYXBwbGljYXRpb24vanNvbicsXFxuICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3Bhbi5jY29mLmNjL3NlYXJjaD9rZXl3b3JkPScgKyBzXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwYWdlU2l6ZVxcXCI6IDIwLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VOdW1cXFwiOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcImtleXdvcmRcXFwiOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcImZyb21Nb2JpbGVcXFwiOiB0cnVlXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IEpTT04ucGFyc2UoaHRtbClcXG4gICAgICAgICAgICAgICAgLmRhdGEucm93c1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSBpdC5maWxlTmFtZVxcbiAgICAgICAgICAgICAgICBsZXQgbXVybCA9IGl0LnVybFxcbiAgICAgICAgICAgICAgICBsZXQgdHlwZSA9IGl0LnR5cGUucmVwbGFjZSgvZm9sZGVyLywgJ+aWh+S7tuWkuScpLnJlcGxhY2UoL2ZpbGUvLCAn5paH5Lu2JylcXG4gICAgICAgICAgICAgICAgaWYgKHRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiAn5paH5Lu257G75Z6L77yaJyArIHR5cGUgKyAn77yM5paH5Lu25aSn5bCP77yaJyArIGFsaVV0aWwuYnl0ZXNUb1NpemUoaXQuc2l6ZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBtdXJsXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkXFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHtcXG4gICAgICAgIG5hbWU6ICfpmL/ph4zlsI/nq5knLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgaG9tZSA9IFxcXCJodHRwczovL3BhbjY2Ni5uZXRcXFwiO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KGJ1aWxkVXJsKGhvbWUgKyBcXFwiL2FwaS9kaXNjdXNzaW9uc1xcXCIsIHtcXG4gICAgICAgICAgICAgICAgXFxcImluY2x1ZGVcXFwiOiBcXFwidXNlcixsYXN0UG9zdGVkVXNlcixtb3N0UmVsZXZhbnRQb3N0LG1vc3RSZWxldmFudFBvc3QudXNlcix0YWdzLHRhZ3MucGFyZW50LGZpcnN0UG9zdFxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCJmaWx0ZXJbcV1cXFwiOiBzIC8qICsgXFxcIiB0YWc6dmlkZW8sY29taWNcXFwiKi8gLFxcbiAgICAgICAgICAgICAgICAvL1xcXCJmaWx0ZXJbdGFnXVxcXCI6IFxcXCJ2aWRlbyxjb21pY1xcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCJwYWdlW29mZnNldF1cXFwiOiAyMCAqIChwYWdlIC0gMSlcXG4gICAgICAgICAgICB9KSwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiY29udGVudC10eXBlXFxcIjogXFxcImFwcGxpY2F0aW9uL2pzb25cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly9wYW42NjYubmV0Lz9xPVxcXCIgKyBzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IEpTT04ucGFyc2UoaHRtbCkuZGF0YTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBsaXN0W2ldLmF0dHJpYnV0ZXM7XFxuICAgICAgICAgICAgICAgIGxldCB1cmwgPSBob21lICsgXFxcIi9kL1xcXCIgKyBpdGVtLnNsdWc7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXRlbS50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6ICflj5HluIPml7bpl7TvvJonICsgJC5kYXRlRm9ybWF0KG5ldyBEYXRlKGl0ZW0uY3JlYXRlZEF0KSwgXFxcInl5eXktTU0tZGQgSEg6bW06c3NcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L+b5YWl5biW5a2QXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudCh1cmwpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSBwZGZoKHJlcXVlc3QoaW5wdXQpLCBcXFwiVGV4dFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBfbGlua3MgPSBodG1sLm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgIGxldCBzaGFyZVB3ZCA9IGh0bWwubWF0Y2goL+aPkOWPlueggVs677yaXVxcXFxzKj8oXFxcXHd7NH0pLyk7XFxuICAgICAgICAgICAgc2hhcmVQd2QgPSBBcnJheS5pc0FycmF5KHNoYXJlUHdkKSAmJiBzaGFyZVB3ZC5sZW5ndGggPiAwID8gc2hhcmVQd2RbMV0gOiBcXFwiXFxcIjtcXG4gICAgICAgICAgICBpZiAoX2xpbmtzLmxlbmd0aCA+IDEgJiYgX2xpbmtzWzFdLnJlcGxhY2UoX2xpbmtzWzBdLCBcXFwiXFxcIikucmVwbGFjZSgvW2EtekEtWjAtOV0rL2csIFxcXCJcXFwiKSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpVXJsOiBfbGlua3NbMV0sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2RcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKF9saW5rcy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBhbGlVcmw6IF9saW5rc1swXSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogJ+S6keebmOWIhuS6q+ekvuWMuicsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBob21lID0gXFxcImh0dHBzOi8veXVucGFuMS5jY1xcXCI7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoYnVpbGRVcmwoaG9tZSArIFxcXCIvYXBpL2Rpc2N1c3Npb25zXFxcIiwge1xcbiAgICAgICAgICAgICAgICBcXFwiaW5jbHVkZVxcXCI6IFxcXCJ1c2VyLGxhc3RQb3N0ZWRVc2VyLG1vc3RSZWxldmFudFBvc3QsbW9zdFJlbGV2YW50UG9zdC51c2VyLHRhZ3MsdGFncy5wYXJlbnQsZmlyc3RQb3N0XFxcIixcXG4gICAgICAgICAgICAgICAgXFxcImZpbHRlcltxXVxcXCI6IHMgLyogKyBcXFwiIHRhZzp2aWRlbyxjb21pY1xcXCIqLyAsXFxuICAgICAgICAgICAgICAgIC8vXFxcImZpbHRlclt0YWddXFxcIjogXFxcInZpZGVvLGNvbWljXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcInBhZ2Vbb2Zmc2V0XVxcXCI6IDIwICogKHBhZ2UgLSAxKVxcbiAgICAgICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb250ZW50LXR5cGVcXFwiOiBcXFwiYXBwbGljYXRpb24vanNvblxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3BhbjY2Ni5uZXQvP3E9XFxcIiArIHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKS5kYXRhO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV0uYXR0cmlidXRlcztcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGhvbWUgKyBcXFwiL2QvXFxcIiArIGl0ZW0uc2x1ZztcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogJ+WPkeW4g+aXtumXtO+8micgKyAkLmRhdGVGb3JtYXQobmV3IERhdGUoaXRlbS5jcmVhdGVkQXQpLCBcXFwieXl5eS1NTS1kZCBISDptbTpzc1xcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLov5vlhaXluJblrZBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHVybCkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHBkZmgocmVxdWVzdChpbnB1dCksIFxcXCJUZXh0XFxcIik7XFxuICAgICAgICAgICAgbGV0IF9saW5rcyA9IGh0bWwubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgbGV0IHNoYXJlUHdkID0gaHRtbC5tYXRjaCgv5o+Q5Y+W56CBWzrvvJpdXFxcXHMqPyhcXFxcd3s0fSkvKTtcXG4gICAgICAgICAgICBzaGFyZVB3ZCA9IEFycmF5LmlzQXJyYXkoc2hhcmVQd2QpICYmIHNoYXJlUHdkLmxlbmd0aCA+IDAgPyBzaGFyZVB3ZFsxXSA6IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIGlmIChfbGlua3MubGVuZ3RoID4gMSAmJiBfbGlua3NbMV0ucmVwbGFjZShfbGlua3NbMF0sIFxcXCJcXFwiKS5yZXBsYWNlKC9bYS16QS1aMC05XSsvZywgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBhbGlVcmw6IF9saW5rc1sxXSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoX2xpbmtzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGFsaVVybDogX2xpbmtzWzBdLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi54ix55yL576O5YmnXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL3d3dy4ya21qLmNuL3NlYXJjaC5waHA/cT1cXFwiICsgcyArIFxcXCImcGFnZS9cXFwiICsgcGFnZSArIFxcXCIvXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCBcXFwiLmxpc3QtaXQmJmxpXFxcIik7XFxuXFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHV0aXRsZSA9IHBhcnNlRG9tRm9ySHRtbChpdCwgXFxcImEmJnRpdGxlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGFyc2VEb21Gb3JIdG1sKGl0LCBcXFwiLmluZm8mJnNwYW46bm90KDpoYXMoYSkpLS1pJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1hZ2UgPSBwYXJzZURvbShpdCwgXFxcImltZyYmc3JjXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb20oaXQsIFxcXCJhJiZocmVmXFxcIik7XFxuICAgICAgICAgICAgICAgIGJldC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB1dGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiB1aW1hZ2UsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiB1c2VyaWFsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICByZXR1cm4gYmV0O1xcblxcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICByZXR1cm4gcGRmYShyZXF1ZXN0KGlucHV0KSwgXFxcImJvZHkmJiNkb3dubG9hZFxcXCIpLm1hcCh2ID0+IHBkZmgodiwgXFxcIi5kb3duJiZocmVmXFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5aWH5aaZ5pCc57SiXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsO1xcbiAgICAgICAgICAgIGlmIChwYWdlID09PSAxKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IGJ1aWxkVXJsKFxcXCJodHRwczovL3d3dy5tYWdpY2Fsc2VhcmNoLnRvcC9hcGkvcHNob3UvZ2V0RGF0YVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHdvcmQ6IHMsXFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBcXFwi6Zi/6YeM572R55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cmwgPSBidWlsZFVybChcXFwiaHR0cHM6Ly93d3cubWFnaWNhbHNlYXJjaC50b3AvYXBpL3BzaG91L2dldE5leHRQYWdlXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaHR0cHM6Ly9hcGkudXB5dW5zbzIuY29tL3NlYXJjaD9zX3R5cGU9MkBwYWdlPVxcXCIgKyBwYWdlICsgXFxcIkBrZXl3b3JkPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQocyksXFxuICAgICAgICAgICAgICAgICAgICB3ZWJzaXRlOiBcXFwi6Zi/6YeM572R55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJlc3VsdCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFJlZmVyZXI6IGJ1aWxkVXJsKFxcXCJodHRwczovL3d3dy5tYWdpY2Fsc2VhcmNoLnRvcC9zZWFyY2hcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgd29yZDogcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjcGFnZTogMFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJlc3VsdCA9IEpTT04ucGFyc2UoSlNPTi5wYXJzZShyZXN1bHQpKTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHJlc3VsdC5yZXN1bHQuaXRlbXM7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XFxuICAgICAgICAgICAgICAgIGlmIChpdC5pZCA9PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLml6XmnJ/vvJpcXFwiICsgaXQuaW5zZXJ0X3RpbWUgKyBcXFwiXFxcXG7ot6/lvoTvvJpcXFwiICsgaXQucGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogaXQucGFnZV91cmxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9XFxuXTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuaWh+S7tuaOkuW6j1wiLFwicGF0aFwiOlwiRmlsZVNvcnRpbmdcIixcInJ1bGVcIjpcImxldCBjaG5OdW1DaGFyID0ge1xcbiAgICDpm7Y6IDAsXFxuICAgIOS4gDogMSxcXG4gICAg5LqMOiAyLFxcbiAgICDkuIk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0gMSkge1xcbiAgICAgICAgICAgICAgICBzZWN0aW9uICs9IG51bWJlcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCB1bml0ID0gY2huTmFtZVZhbHVlW3N0cltpXV0udmFsdWU7XFxuICAgICAgICAgICAgc2VjVW5pdCA9IGNobk5hbWVWYWx1ZVtzdHJbaV1dLnNlY1VuaXQ7XFxuICAgICAgICAgICAgaWYgKHNlY1VuaXQpIHtcXG4gICAgICAgICAgICAgICAgc2VjdGlvbiA9IChzZWN0aW9uICsgbnVtYmVyKSAqIHVuaXQ7XFxuICAgICAgICAgICAgICAgIHJ0biArPSBzZWN0aW9uO1xcbiAgICAgICAgICAgICAgICBzZWN0aW9uID0gMDtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBzZWN0aW9uICs9IChudW1iZXIgKiB1bml0KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbnVtYmVyID0gMDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICByZXR1cm4gcnRuICsgc2VjdGlvbjtcXG59XFxuXFxuZnVuY3Rpb24gbmFtZUNvbXBhcmUoYSwgYikge1xcbiAgICBpZiAoYSA9PSBudWxsIHx8IGIgPT0gbnVsbClcXG4gICAgICAgIHJldHVybiBhID09IG51bGwgPyBiID09IG51bGwgPyAwIDogLTEgOiAxO1xcblxcbiAgICBhID0gYS5yZXBsYWNlKC8oW+mbtuS4gOS6jOS4ieWbm+S6lOWFreS4g+WFq+S5neWNgeeZvuWNg+S4h+S6v10pL2csIGZ1bmN0aW9uKG1hdGNoLCBwMSwgcDIsIHAzLCBvZmZzZXQsIHN0cmluZykge1xcbiAgICAgICAgLy8gcDEgaXMgbm9uZGlnaXRzLCBwMiBkaWdpdHMsIGFuZCBwMyBub24tYWxwaGFudW1lcmljc1xcbiAgICAgICAgcmV0dXJuIENoaW5lc2VUb051bWJlcihwMSk7XFxuICAgIH0pX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vZGUgJiYgYzIgPj0gemVyb0NoYXJDb2RlICYmIGMyIDw9IG5pbmVDaGFyQ29kZSkge1xcbiAgICAgICAgICAgIGNtcCA9IG5ldyBqYXZhLm1hdGguQmlnSW50ZWdlcihzcGxpdDFbaV0pLmNvbXBhcmVUbyhuZXcgamF2YS5tYXRoLkJpZ0ludGVnZXIoc3BsaXQyW2ldKSk7XFxuICAgICAgICB9XFxuXFxuICAgICAgICBpZiAoY21wID09PSAwKSB7XFxuICAgICAgICAgICAgbGV0IHJlZ2V4ID0gL1thLXpBLVowLTldL1xcbiAgICAgICAgICAgIGxldCBzMSA9IFN0cmluZyhzcGxpdDFbaV0pXFxuICAgICAgICAgICAgbGV0IHMyID0gU3RyaW5nKHNwbGl0MltpXSlcXG4gICAgICAgICAgICBpZiAocmVnZXgudGVzdChzMSkgfHwgcmVnZXgudGVzdChzMikpIHtcXG4gICAgICAgICAgICAgICAgY21wID0gbmV3IGphdmEubGFuZy5TdHJpbmcoc3BsaXQxW2ldKS5jb21wYXJlVG8obmV3IGphdmEubGFuZy5TdHJpbmcoc3BsaXQyW2ldKSk7XFxuICAgICAgICAgICAgICAgIC8vIGNtcCA9IHMxLmxvY2FsZUNvbXBhcmUoczIsICdlbicpXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgY21wID0gczEubG9jYWxlQ29tcGFyZShzMiwgJ3poJylcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuXFxuICAgICAgICBpZiAoY21wICE9PSAwKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGNtcDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBsZXQgbGVuZ3RoQ21wID0gc3BsaXQxLmxlbmd0aCAtIHNwbGl0Mi5sZW5ndGg7XFxuICAgIC8vIGlmIChsZW5ndGhDbXAgIT09IDApIGxlbmd0aENtcCA9IGxlbmd0aENtcCA+IDAgPyAtMSA6IDE7XFxuICAgIHJldHVybiBsZW5ndGhDbXA7XFxuf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/6YeM5LqR55uYIEFwcCDmiavnoIFcXFwiLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgY2xzOiBcXFwibG9naW5cXFwiXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBkZWxldGVJdGVtKFxcXCJnZXRRQ1xcXCIpO1xcbiAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgIGxldCByZWZyZXNoX3Rva2VuO1xcbiAgICAgICAgd2hpbGUgKHRydWUpIHtcXG4gICAgICAgICAgICBsZXQgZGF0YTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBkYXRhID0gZ2V0X3FyY29kZV9zdGF0dXMoc2lkKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mn6Xor6LmiavnoIHnu5PmnpzotoXml7YsIOWPr+iDveaYr+inpuWPkeS6humYv+mHjOS6keebmOaOpeWPo+mZkOWItiwg6K+356iN5ZCO5YaN6K+VLlxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzdGF0dXMgPSBkYXRhW1xcXCJzdGF0dXNcXFwiXTtcXG4gICAgICAgICAgICBpZiAoc3RhdHVzID09IFxcXCJMb2dpblN1Y2Nlc3NcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hfdG9rZW4gPSBnZXRfcmVmcmVzaF90b2tlbihkYXRhW1xcXCJhdXRoQ29kZVxcXCJdKTtcXG4gICAgICAgICAgICAgICAgYnJlYWtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHN0YXR1cyA9PSBcXFwiUVJDb2RlRXhwaXJlZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S6jOe7tOeggeW3sui/h+acnywg6K+35Yi35paw6aG16Z2i5ZCO6YeN6K+VXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKCFnZXRNeVZhcihcXFwiTG9nZ2luZ2luXFxcIiwgXFxcIlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9jYW5jZWxcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDE1MDApO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHJlZnJlc2hfdG9rZW4pIHtcXG4gICAgICAgICAgICBjb25zdCB7XFxuICAgICAgICAgICAgICAgIG9wZW5Ub2tlbnNGaWxlcGF0aCxcXG4gICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJ0b2tlblBhdGhcXFwiKTtcXG4gICAgICAgICAgICBsZXQgb3BlbiA9IHtcXG4gICAgICAgICAgICAgICAgUmVmcmVzaFRva2VuT3BlbjogcmVmcmVzaF90b2tlbixcXG4gICAgICAgICAgICAgICAgaXNWMjogdHJ1ZVxcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgd3JpdGVGaWxlKG9wZW5Ub2tlbnNGaWxlcGF0aCwgSlNPTi5zdHJpbmdpZnkob3BlbikpO1xcbiAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwiaW5mb091dHB1dFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnmbvlvZXmiJDlip8o54K55Ye76L+U5ZueKVxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDokKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpPT57XFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0e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ICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICBsZXQgY29kZSA9IHJlc3VsdC5yZWRpcmVjdFVyaS5zcGxpdChcXFwiY29kZT1cXFwiKVsxXTtcXG4gICAgICAgIHJldHVybiBjb2RlO1xcbiAgICB9LFxcbiAgICBnZXRUb2tlbihib2R5KSB7XFxuICAgICAgICBsZXQganNvbiA9IHBvc3QoJ2h0dHBzOi8vYXBpLnhob2ZlLnRvcC9hbGlzdC9hbGlfb3Blbi9jb2RlJywge1xcbiAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLydcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBpZiAoIWpzb24pIHtcXG4gICAgICAgICAgICBqc29uID0gcG9zdCgnaHR0cHM6Ly9hcGktY2Yubm4uY2kvYWxpc3QvYWxpX29wZW4vY29kZScsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoYm9keSksXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoanNvbi5pbmNsdWRlcygnVG9vIE1hbnkgUmVxdWVzdHMnKSB8fCBqc29uLmluY2x1ZGVzKFxcXCI1MDIgQmFkIEdhdGV3YXlcXFwiKSkge1xcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi6aKR57mB6K+35rGC5pqC5pe26KKr5bCB56aBXFxcXG5cXFwiICsganNvbik7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCB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U7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiBnZXRfcXJjb2RlX2NvZGUoc2lkKTtcXG4gICAgfSxcXG4gICAgZ2V0VG9rZW4oYm9keSkge1xcbiAgICAgICAgbGV0IHJlcyA9IHBvc3QoXFxcImh0dHBzOi8vb3BlbmFwaS5hbGl5dW5kcml2ZS5jb20vb2F1dGgvYWNjZXNzX3Rva2VuXFxcIiwge1xcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG5cXG4gICAgICAgIHJldHVybiBkYXRhO1xcbiAgICB9LFxcbiAgICBnZXRPcGVuVG9rZW4oKSB7XFxuICAgICAgICByZXR1cm4gdGhpcy5nZXRUb2tlbih7XFxuICAgICAgICAgICAgY29kZTogdGhpcy5nZXRPcGVuVG9rZW5Db2RlKCksXFxuICAgICAgICAgICAgZ3JhbnRfdHlwZTogXFxcImF1dGhvcml6YXRpb25fY29kZVxcXCIsXFxuICAgICAgICAgICAgY2xpZW50X3NlY3JldDogdGhpcy5jbGllbnRfc2VjcmV0LFxcbiAgICAgICAgICAgIGNsaWVudF9pZDogdGhpcy5jbGllbnRfaWQsXFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgcmVmcmVzaE9wZW5Ub2tlbigpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLmdldFRva2VuKHtcXG4gICAgICAgICAgICBncmFudF90eXBlOiBcXFwicmVmcmVzaF90b2tlblxcXCIsXFxuICAgICAgICAgICAgcmVmcmVzaF90b2tlbjogdGhpcy4kdGhpcy5vcGVuVG9rZW5zLlJlZnJlc2hUb2tlbk9wZW4sXFxuICAgICAgICAgICAgY2xpZW50X3NlY3JldDogdGhpcy5jbGllbnRfc2VjcmV0LFxcbiAgICAgICAgICAgIGNsaWVudF9pZDogdGhpcy5jbGllbnRfaW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ICAgICAgIGNvbF90eXBlLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoKS5sYXp5UnVsZSh2ID0+ICQucmVxdWlyZShcXFwicmVkaXJlY3RcXFwiKS5kZWFsUmVzdWx0KHYpLCB2KSxcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHYudGl0bGUgfHwgdi5hbGlVcmwucmVwbGFjZSgvaHR0cC4qP1xcXFwvc1xcXFwvLywgXFxcIlxcXCIpXFxuICAgICAgICAgICAgfSkpKTtcXG4gICAgICAgIH0sIGxpc3QsIGNvbCk7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0RXJyb3JQb3AobmFtZSwgYXV0aG9yKSB7XFxuICAgIHJldHVybiAkKFxcXCLmkJzntKLlvJXmk47jgIxcXFwiICsgbmFtZSArIFxcXCLjgI3lpLHmlYjor7fogZTns7vmkJzntKLlvJXmk47kvZzogIVcXFwiICsgKGF1dGhvciA/IFxcXCJbXFxcIiArIGF1dGhvciArIFxcXCJdXFxcIiA6IFxcXCJcXFwiKSArIFxcXCLkv67lpI3miJbliKDpmaRcXFxcblxcXFxu5byV5pOO5L2c6ICF5Y+v5Lul5Y675a6Y5pa56aKR6YGT6K+i6ZeuXFxcXG7ngrnlh7vnoa7lrprlv6vpgJ/liKDpmaRcXFwiKS5jb25maXJtKChuYW1lKSA9PiB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpFxcXCIgKyBuYW1lICsgXFxcIuWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobmFtZSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICA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AgICAgICBsZXQgY2hhciA9IHZhbHVlW2ldO1xcblxcbiAgICAgICAgaWYgKGVzY2FwZSkge1xcbiAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1xcXFxcXFxcJykge1xcbiAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxuICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgIGluQnJhY2tldHMgPSB0cnVlO1xcbiAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgIH1cXG4gICAgfVxcblxcbiAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICB9XFxuXFxuICAgIHJldHVybiBwYXRoO1xcbn1cXG5cXG5mdW5jdGlvbiBnZXRKc29uKG9iaiwgcGF0aCkge1xcbiAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgfVxcbiAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIHJldHVybiBvYmo7XFxuICAgIH1cXG5cXG4gICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuXFxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0aC5sZW5ndGg7IGk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gY2xlYXJNeVZhcihcXFwibW91bnR6aW11XFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImFsaVNoYXJlVG9rZW5cXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJWYXIoXFxcImRtX3NoYXJlXFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImRtbGlzdFxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJsaXN0U2VhcmNoS2V5XFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImRtX2xpc3RVcmxMaXN0XFxcIik7XFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgc2V0TWFya2VyKCk7XFxuICAgICAgICBpZiAoTVlfUEFSQU1TLmlzSG9tZSkge1xcbiAgICAgICAgICAgIC8vc2lnbkluUmV3YXJkKGFsaUFjY2Vzc0FwaSk7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5aSH5Lu955uYXFxcIiArIFtcXFwiXFxcIiwgXFxcIuKImlxcXCJdW051bWJlcihpc0JhY2t1cERyaXZpZCldLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibXlBbGlQYW5Ecml2aWRcXFwiLCBcXFwidHJ1ZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgaXR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2tlbik7XFxuICAgICAgICAgICAgICAgICAgICBhbGlBY2Nlc3NBcGkuc2V0TXlEcml2aWRUeXBlKGlzQmFja3VwRHJpdmlkKTtcXG4gICAgICAgICAgICAgICAgICAgIGFsaUFjY2Vzc0FwaS5jb3B5RmlsZVRvQ2xvdWRGaWxlKHNoYXJlSW5mby5maWxlSWQsIGZpbGVJZCk7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrVG9Ib21lKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUluZm8sIGlzQmFja3VwRHJpdmlkLCBmaWxlSWQpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCFpc1NlYXJjaCkge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuaQnOe0olxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghaW5wdXQpIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXlhbPplK7or41cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNmdWxsVGhlbWUjP3BhZ2U9ZnlwYWdlJnNlYXJjaEtleT1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgb25DaGFuZ2U6IFxcXCJwdXRNeVZhcignbGlzdFNlYXJjaEtleScsaW5wdXQpXFxcIixcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgc2VhcmNoS2V5ICsgXFxcIuKAneKAneeahOaQnOe0oue7k+aenFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBmdW5jSXRlbXMgPSBbXTtcXG4gICAgICAgIGZ1bmNJdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogc3R5bGUsXFxuICAgICAgICAgICAgdXJsOiAkKHN0eWxlcywgMSwgXFxcIuaOkuW4g+agt+W8j1xcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImFsaXl1bl9zdHlsZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNolxcXCI7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ljb24uc3ZnXFxcIlxcbiAgICAgICAgfSwge1xcbiAgICA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wgMiwgXFxcIuabtOWkmuWKn+iDvVxcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5om56YeP5oyC6L295pys5Zyw5by55bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvZG1Nb3VudCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuafpeeci+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/nqItcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChnZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFxcXCIxMFxcXCIpLCBcXFwi6K+36L6T5YWlMy0zMuS5i+mXtOeahOaVtOaVsFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzcGVlZFRocmVhZCA9IHBhcnNlSW50KGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzcGVlZFRocmVhZCA8IDMgfHwgc3BlZWRUaHJlYWQgPiAzMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7kuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic3BlZWRUaHJlYWRcXFwiLCBTdHJpbmcoc3BlZWRUaHJlYWQpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9maWxlaW50by5zdmdcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZUlkOiBwYWdlSWQsXFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZvbGRlck5hbWU6IGdldFBhZ2VUaXRsZSgpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogW1xcXCJBTExcXFwiLCBcXFwi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4gICAgICAgIGZvbGRlclN0eWxlID0gXFxcImF2YXRhclxcXCI7XFxuICAgICAgICBmaWxlU3R5bGUgPSBcXFwibW92aWVfMlxcXCI7XFxuICAgICAgICBmaWx0ZXJUeXBlLnB1c2goXFxcInZpZGVvXFxcIik7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwi6L+95Ymn5qih5byP5Y+q5pi+56S65paH5Lu25aS55ZKM6KeG6aKRXFxcIi5zbWFsbCgpLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSBpZiAoc3R5bGUgPT09IFxcXCLnnIvlm75cXFwiKSB7XFxuICAgICAgICBmb2xkZXJTdHlsZSA9IFxcXCJhdmF0YXJcXFwiO1xcbiAgICAgICAgZmlsZVN0eWxlID0gXFxcImNhcmRfcGljXzNcXFwiO1xcbiAgICAgICAgZmlsdGVyVHlwZS5wdXNoKFxcXCJpbWFnZVxcXCIpO1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIueci+WbvuaooeW8j+WPquaYvuekuuaWh+S7tuWkueWSjOWbvueJh1xcXCIuc21hbGwoKS5mb250Y29sb3IoXFxcImdyZXlcXFwiKSxcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcX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ICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgZmlsZUlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgaXNCYWNrdXBEcml2aWQsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZUluZm8sXFxuICAgICAgICAgICAgICAgICAgICBub1BpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpOaWh+S7tuWkuVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoZGVsZXRlREZpbGUsIGZpbGVJdGVtLmZpbGVfaWQsIGlzQmFja3VwRHJpdmlkLCBmaWxlSXRlbS5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIGlmIChub1NraXBGaWxlKSB7XFxuICAgICAgICAgICAgaWYgKGZpbHRlclR5cGUubGVuZ3RoID4gMCAmJiAhZmlsdGVyVHlwZS5pbmNsdWRlcyhjYXRlKSkge1xcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHN1YnRpdGxlLCBjbHMsIGxvbmdjID0gW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaTmlofku7ZcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhkZWxldGVERmlsZSwgZmlsZUl0ZW0uZmlsZV9pZCwgaXNCYWNrdXBEcml2aWQsIGZpbGVJdGVtLm5hbWUpXFxuICAgICAgICAgICAgfV07XFxuICAgICAgICAgICAgbGV0IHRpdGxlID0gZmlsZUl0ZW0ubmFtZTtcXG4gICAgICAgICAgICBsZXQgbmFtZU5vdEV4dCA9IGZpbGVJdGVtLm5hbWUucmVwbGFjZSgnLicgKyBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbiwgJycpO1xcbiAgICAgICAgICAgIGlmIChzdWJFeHRzLmluY2x1ZGVzKGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uKSkge1xcbiAgICAgICAgICAgICAgICBsb25nYy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5oyC6L295a2X5bmVXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh6bSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdtb3VudHppbXUnLCB6bSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+aMgui9veWujOaIkO+8jOW9k+WJjeWtl+W5leaWh+S7tjogJyArIHptLm5hbWUgKyAnLicgKyB6bS5leHQ7XFxuICAgICAgICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0OiBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbixcXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlX2lkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IG5hbWVOb3RFeHRcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGNhdGUgPT09IFxcXCJ2aWRlb1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHppbXVsaXN0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgc3VidGl0bGUgPSB6aW11bGlzdC5maW5kKHYgPT4gdi5uY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AgICAgICAgICAgICAgcGljX3VybDogcGljX3VybCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBsb25nYyxcXG4gICAgICAgICAgICAgICAgICAgIGNsczogY2xzLFxcbiAgICAgICAgICAgICAgICAgICAgLy9pbmhlcml0VGl0bGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgcGFnZVRpdGxlOiBmaWxlSXRlbS5uYW1lXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBmaWxlU3R5bGVcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBpZiAoY29udHMubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjpg73msqHmnInkuoblk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5cXG5sZXQgaXRlbXMgPSBbXTtcXG50cnkge1xcbiAgICBpZiAoTVlfUEFHRSA+IDEgJiYgIU1ZX1BBUkFNUy5tYXJrZXIpIHtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCI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l1cmwgPSBwbGF5VXJsTGlzdC5maW5kKHYgPT4gdi50ZW1wbGF0ZV9pZCA9PSBsaW5lKVt1cmxuYW1lXTtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICB0aHJvdyBlO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGFsaXVybDtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBnZXRNM3U4Q29udGVudChwbGF5dXJsKSB7XFxuICAgICAgICAvL21lZGlhLm0zdThcXG4gICAgICAgIGxldCBob21lID0gcGxheXVybC5zcGxpdChzdWZmaXgpWzBdO1xcbiAgICAgICAgbGV0IGYgPSBmZXRjaChwbGF5dXJsLCB7XFxuICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICBcXFwiVXNlci1BZ2VudFxcXCI6IFBDX1VBLFxcbiAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGltZW91dDogMzAwMFxcbiAgICAgICAgfSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICBsZXQgZmYgPSBmLm1hcChpdCA9PiB7XFxuICAgICAgICAgICAgaWYgKGl0LnN0YXJ0c1dpdGgoXFxcIm1lZGlhLVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiL3Byb3h5P3VybD1cXFwiICsgYmFzZTY0RW5jb2RlKGhvbWUgKyBpdCkrXFxcIiZ0aW1lc3RhbXA9XFxcIitNWV9QQVJBTVMudGltZXN0YW1wWzBdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gaXQ7XFxuICAgICAgICB9KS5qb2luKFxcXCJcXFxcblxcXCIpO1xcblxcbiAgICAgICAgd3JpdGVGaWxlKGNhY2hlRmlsZVBhdGgsIGZmKTtcXG4gICAgICAgIHJldHVybiBmZjtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiB1cGRhdGVUc1VybCh1cmwpIHtcXG4gICAgICAgIGxldCBmaWQgPSB1cmwuc3BsaXQoJyZmPScpWzFdLnNwbGl0KCcmJylbMF07XFxuICAgICAgICAvL2xvZygnc2ZpZC0nICsgZmlkKTtcXG4gICAgICAgIGxldCBmID0gZmV0Y2goY2FjaGVGaWxlUGF0aCkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICBmLmZvckVhY2goaXQgPT4ge1xcbiAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpLnNwbGl0KFxcXCImXFxcIilbMF0pO1xcbiAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgZXhwaXJlcyA9IHVybC5zcGxpdCgneC1vc3MtZXhwaXJlcz0nKVsxXS5zcGxpdCgnJicpWzBdO1xcbiAgICAgICAgY29uc3QgbGFzdHRpbWUgPSBwYXJzZUludChleHBpcmVzKSAtIERhdGUubm93KCkgLyAxMDAwO1xcbiAgICAgICAgaWYgKGxhc3R0aW1lIDwgNjApIHtcXG4gICAgICAgICAgICAvL2xvZygn6L+H5pyf5pu05pawJylcXG4gICAgICAgICAgICBsZXQgbGluZSA9IHVybC5zcGxpdCgnL21lZGlhJylbMF07IC8v5Y+W5LmL5YmN5pKt5pS+55qEdHPmrrXnur/ot69cXG4gICAgICAgICAgICBsaW5lID0gbGluZS5zdWJzdHJpbmcobGluZS5sYXN0SW5kZXhPZignLycpICsgMSk7XFxuICAgICAgICAgICAgbGV0IGYgPSBnZXRNM3U4Q29udGVudChnZXRBbGlQbGF5VXJsKGZpZCwgbGluZSkpLnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGYuZm9yRWFjaChpdCA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZnVybCA9IGJhc2U2NERlY29kZShpdC5yZXBsYWNlKCcvcHJveHk/dXJsPScsICcnKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IGZ1cmw7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHVybDtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHVybCA9IGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKTtcXG4gICAgICAgIGlmICh1cmwuaW5jbHVkZXMoXFxcIi50c1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiB1cGRhdGVUc1VybCh1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IHRlbXBsYXRlSWQgPSBNWV9QQVJBTVMudGVtcGxhdGVJZFswXTtcXG4gICAgICAgICAgICBpZihmaWxlRXhpc3QoY2FjaGVGaWxlUGF0aCkpe1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TTN1OENvbnRlbnQoZ2V0QWxpUGxheVVybChmaWxlSWQsIHRlbXBsYXRlSWQpKTtcXG4gICAgICAgICAgICB9ZWxzZXtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGdldE0zdThDb250ZW50KHVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coXFxcIiPku6PnkIbmkq3mlL7lpLHotKUjXFxcXG7plJnor6/kv6Hmga8+XFxcIiArIGUudG9TdHJpbmcoKSArIFxcXCJcXFxcbumUmeivr+ihjD5cXFwiICsgZS5saW5lTnVtYmVyKTtcXG4gICAgfVxcbn1cXG5jb25zdCB0cmFuc2NvZGluZyA9IHtcXG4gICAgVUhEOiBcXFwiNEsg6LaF5riFXFxcIixcXG4gICAgUUhEOiBcXFwiMksg6LaF5riFXFxcIixcXG4gICAgRkhEOiBcXFwiMTA4MCDlhajpq5jmuIVcXFwiLFxcbiAgICBIRDogXFxcIjcyMCDpq5jmuIVcXFwiLFxcbiAgICBTRDogXFxcIjU0MCDmoIfmuI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YiA9IHN0b3JhZ2UwLmdldE15VmFyKCdtb3VudHppbXUnLCB7fSk7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMobW91bnRzdWIpLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICB6aW11ID0gbW91bnRzdWI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc3VidGl0bGU7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMoemltdSB8fCB7fSkubGVuZ3RoID4gMCAmJiBwbGF5TGlzdCAmJiBwbGF5TGlzdC51cmxzICYmIHBsYXlMaXN0LnVybHMubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwKTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB2YXIgem11cmwgPSBhbGlBY2Nlc3NBcGkub3BlbkNsb3VkRmlsZVRvRG93blVybCh6aW11LmZpbGVfaWQpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGF0aCA9ICdoaWtlcjovL2ZpbGVzL2NhY2hlL+S6keebmOWQmy9zdWIuJyArIHppbXUuZXh0O1xcbiAgICAgICAgICAgICAgICBkb3dubG9hZEZpbGUoem11cmwsIHBhdGgsIHtcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IGdldFBhdGgocGF0aCk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5a2X5bmV5Yqg6L295aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxvZyhlLm1lc3NhZ2UpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBkbWxpc3QgPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiZG1saX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pemU/c2lkPVxcXCIgKyBzaWQpLmJvZHkoYm9keSkuaGVhZGVycyhoZWFkZXJzKS5lcnJvcldpdGhSZXRyeSgoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIHRoaXMuJHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLiR0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgIH0pLnN0YXJ0KHRydWUpO1xcbiAgICAgICAgcmV0dXJuIGdldF9xcmNvZGVfY29kZShzaWQpO1xcbiAgICB9LFxcbiAgICBnZXRUb2tlbihib2R5KSB7XFxuICAgICAgICBsZXQgcmVzID0gcG9zdChcXFwiaHR0cDovL2FwaS5leHRzY3JlZW4uY29tL2FsaXl1bmRyaXZlL3Rva2VuXFxcIiwge1xcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG5cXG4gICAgICAgIHJldHVybiBkYXRhLmRhdGE7XFxuICAgIH0sXFxuICAgIGdldE9wZW5Ub2tlbigpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLmdldFRva2VuKHtcXG4gICAgICAgICAgICBjb2RlOiB0aGlzLmdldE9wZW5Ub2tlbkNvZGUoKSxcXG4gICAgICAgICAgICBncmFudF90eXBlOiBcXFwiYXV0aG9yaXphdGlvbl9jb2RlXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIHJlZnJlc2hPcGVuVG9rZW4oKSB7XFxuICAgICAgICByZXR1cm4gdGhpcy5nZXRUb2tlbih7XFxuICAgICAgICAgICAgZ3JhbnRfdHlwZTogXFxcInJlZnJlc2hfdG9rZW5cXFwiLFxcbiAgICAgICAgICAgIHJlZnJlc2hfdG9rZW46IHRoaXMuJHRoaXMub3BlblRva2Vucy5SZWZyZXNoVG9rZW5PcGVuLFxcbiAgICAgICAgfSk7XFxuICAgIH1cXG59KTtcXG4kLmV4cG9ydHMgPSBPcGVuQXBpO1wifV0iLCJpY29uIjoiaHR0cHM6Ly9pbWcuYWxpY2RuLmNvbS9pbWdleHRyYS9pMi9PMUNOMDFET1ljczcxdjNCNmJPZW1WTV8hITYwMDAwMDAwMDYxMTYtMi10cHMtNTEyLTUxMi5wbmciLCJwcm94eSI6IiJ9
Add Comment
Please, Sign In to add comment