Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@云盘君.简@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoi5LqR55uY5ZCbLueugCIsImF1dGhvciI6IuWwj+ajieiihPCfjJ4mQExveURnSWsiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjoxNzEsImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoiYWxsIiwiY2xhc3NfdXJsIjoiIiwiYXJlYV9uYW1lIjoiIiwiYXJlYV91cmwiOiIiLCJzb3J0X25hbWUiOiIiLCJ5ZWFyX25hbWUiOiIiLCJzb3J0X3VybCI6IiIsInllYXJfdXJsIjoiIiwiZmluZF9ydWxlIjoianM6JC5yZXF1aXJlKFwiTWFpblwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zZWFyY2hUZXJtcz0qKiIsImdyb3VwIjoi4pGg572R55uYIiwic2VhcmNoRmluZCI6ImpzOlxubGV0IGlzZERlbGVnYXRlID0gISFnZXRJdGVtKFwiaXNkRGVsZWdhdGVcIiwgXCJcIik7XG5pZiAoaXNkRGVsZWdhdGUpIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5pCc57SiXCIgKyBNWV9LRVlXT1JELFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9zZWFyY2g/cz1cIiArIE1ZX0tFWVdPUkQsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICBkZWxlZ2F0ZU9ubHlTZWFyY2g6IHRydWUsXG4gICAgICAgICAgICBydWxlczogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVHcm91cCA9IGdldEl0ZW0oXCJydWxlR3JvdXBcIiwgXCJcIik7XG4gICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gJC5yZXF1aXJlKFwiZGF0YVwiKS5nZXRBbGxEYXRhKHJ1bGVHcm91cCk7XG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBkYXRhKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hfdXJsOiBcImhpa2VyOi8vZW1wdHk/cGFnZT1meXBhZ2Umc2VhcmNoVGVybXM9KipcIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygocnVsZSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRSZXN1bHQoJC5yZXF1aXJlKFwiZGF0YVwiKS5jYXJyeVNSdWxlKHJ1bGUsIE1ZX0tFWVdPUkQsIE1ZX1BBR0UsIGdldFNlYXJjaE1vZGUoKSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHJ1bGVzKTtcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICB9XSk7XG59IGVsc2Uge1xuICAgIHNldFJlc3VsdChbe1xuICAgICAgICB0aXRsZTogXCLngrnmiJHlvIDlp4vogZrlkIj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xX3ZlcnRpY2FsX3BpY1xcXCIgOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7XFxuICAgICAgICAgICAgICAgIGluaGVyaXRUaXRsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgIG5vUGljOiB0cnVlXFxuICAgICAgICAgICAgfSwgaXQuZXh0cmEpXFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICByZXR1cm4gcmVzTGlzdDtcXG59XFxuJC5leHBvcnRzLmNhcnJ5U1J1bGUgPSBmdW5jdGlvbihydWxlLCBzLCBwYWdlLCBzZWFyY2hNb2RlKSB7XFxuICAgIHJ1bGUgPSBnZXRDb21wbGV0ZVJ1bGUocnVsZSk7XFxuICAgIGxldCBsaXN0ID0gcnVsZS5maW5kKHMsIHBhZ2UpO1xcbiAgICBpZiAoIWxpc3QpIHJldHVybiBbXTtcXG4gICAgbGV0IHJlc0xpc3QgPSBbXTtcXG4gICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xcbiAgICAgICAgaWYgKGl0LnNraXApIHtcXG4gICAgICAgICAgICByZXNMaXN0LnB1c2goaXQpO1xcbiAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHNlYXJjaE1vZGUgJiYgIXNlYXJjaENvbnRhaW5zKGl0LnRpdGxlLCBzLCB0cnVlKSkgY29udGludWU7XFxuICAgICAgICBpZiAocnVsZS5maW5kQWxpVXJsKSB7XFxuICAgICAgICAgICAgaXQudXJsID0gJChpdC51cmwpLmxhenlSdWxlKHRvUmVkaXJlY3RUcmVhdGluZywge1xcbiAgICAgICAgICAgICAgICBmaW5kQWxpVXJsOiBydWxlLmZpbmRBbGlVcmwsXFxuICAgICAgICAgICAgICAgIGJhc2ljVXJsOiBydWxlLmJhc2ljVXJsLFxcbiAgICAgICAgICAgICAgICBuYW1lOiBydWxlLm5hbWUsXFxuICAgICAgICAgICAgICAgIGF1dGhvcjogcnVsZS5hdXRob3IsXFxuICAgICAgICAgICAgICAgIGFsaVVybDogaXQudXJsLFxcbiAgICAgICAgICAgICAgICBydWxlVHlwZTogcnVsZS5ydWxlVHlwZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBpdC51cmwgPSAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKHRvUmVkaXJlY3QsIGl0LnVybCwgaXQuc2hhcmVQd2QgfHwgXFxcIlxcXCIpO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmVzTGlzdC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogaXQudGl0bGUsXFxuICAgICAgICAgICAgZGVzYzogaXQuZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICB1cmw6IGl0LnVybCxcXG4gICAgICAgICAgICBwaWNfdXJsOiBpdC5waWNfdXJsLFxcbiAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHtcXG4gICAgICAgICAgICAgICAgaW5oZXJpdFRpdGxlOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgbm9QaWM6IHRydWVcXG4gICAgICAgICAgICB9LCBpdC5leHRyYSlcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHJldHVybiByZXNMaXN0O1xcbn1cXG5sZXQgc2l6ZSA9IDEwO1xcblxcbmxldCBydWxlcztcXG5cXG5mdW5jdGlvbiBnZXRSdWxlcyhncm91cCkge1xcbiAgICBsZXQgcnVsZXNUbXA7XFxuICAgIGlmICghcnVsZXMpIHtcXG4gICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICB9XFxuICAgIGlmIChncm91cCkge1xcbiAgICAgICAgcnVsZXNUbXAgPSBydWxlcy5maWx0ZXIodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgIH0gZWxzZSB7XFx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Z2V0U3lzdGVtU2VydmljZShDb250ZXh0LkNMSVBCT0FSRF9TRVJWSUNFKTtcXG4gICAgICAgICAgICAvLyDov5Tlm57mlbDmja5cXG4gICAgICAgICAgICBsZXQgY2xpcERhdGEgPSBjbGlwYm9hcmQuZ2V0UHJpbWFyeUNsaXAoKTtcXG4gICAgICAgICAgICBpZiAoY2xpcERhdGEgIT0gbnVsbCAmJiBjbGlwRGF0YS5nZXRJdGVtQ291bnQoKSA+IDApIHtcXG4gICAgICAgICAgICAgICAgLy8g5LuO5pWw5o2u6ZuG5Lit6I635Y+W77yI57KY6LS077yJ56ys5LiA5p2h5paH5pys5pWw5o2uXFxuICAgICAgICAgICAgICAgIGxldCB0ZXh0ID0gY2xpcERhdGEuZ2V0SXRlbUF0KDApLmdldFRleHQoKTtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQgIT0gbnVsbCkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyh0ZXh0LnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGxldCB0ZXh0ID0gZ2V0Q29weSgpIHx8IFxcXCJcXFwiO1xcbiAgICBsZXQgdXJsID0gYWxpdGVzdC5tYXRjaEFsaVVybCh0ZXh0KTtcXG4gICAgaWYgKHVybCkge1xcbiAgICAgICAgbGV0IGNhY2hlID0gZ2V0SXRlbShcXFwiY2xpcGJvYXJkQ2FjaGVcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICBpZiAodXJsICE9PSBjYWNoZSkge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdPGZvbnQgY29sb3I9XFxcIiMxM0I2MUJc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rva2VuUGF0aFxcXCIpLmFsaVRva2Vuc0ZpbGVwYXRoO1xcbiAgICAgICAgbGV0IGEgPSBmZXRjaChhbGlUb2tlbnNGaWxlcGF0aCk7XFxuICAgICAgICBpZiAoIWEgfHwgYSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAnPGZvbnQgY29sb3I9XFxcIiMxM0I2MUJcXFwiPuKWkCA8L2ZvbnQ+PGI+5rip6aao5o+Q56S6PGI+JyxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJyaWNoX3RleHRcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoKSA9PiAkLnJlcXVpcmUoXFxcImxvZ2luTW9kZVxcXCIpKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuacquajgOa1i+WIsOeZu+W9leS/oeaBr++8jOeCueaIkei3s+i9rOeZu+W9lei0puWPt+mhtemdou+8jOeZu+W9lemYv+mHjOS6keebmOi0puWPt+WQjuaWueWPr+S9v+eUqOacrOWcsOino+aekOaooeW8j1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IFxcXCLnmbvlvZXpmL/ph4zkupHnm5hcXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBhZGRMaXN0ZW5lcihcXFwib25DbG9zZVxcXCIsICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgY2xlYXJNeVZhcihcXFwic1xcXCIpO1xcbiAgICB9KSk7XFxuICAgIGFk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bmVudChwbGF5ZGF0YS50aXRsZS5zcGxpdCgnLScpWzBdKTtcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBNWV9SVUxFLnRpdGxlICsgXFxcIuW8ueW5leaQnOe0olxcXCJcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJydWxlOi8vXFxcIiArIGJhc2U2NEVuY29kZShcXFwi77+lcHJvamVjdGlvbl9zY3JlZW7vv6VcXFwiICsgSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoXFxcIuaSreaUvuaooeW8j1xcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgIGxldCBtb2RlcyA9IFtcXFwi6L2s56CBXFxcIiwgXFxcIuWOn+eUu1xcXCIsIFxcXCLljp/ovaxcXFwiXTtcXG4gICAgICAgICAgICAgICAgbGV0IG1vZGUgPSBnZXRJdGVtKFxcXCJhbGl5dW5fcGxheU1vZGVcXFwiLCBtb2Rlc1swXSk7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG1vZGVzLmluZGV4T2YobW9kZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKG1vZGVzLCAxLCBcXFwi5pKt5pS+5qih5byPXFxcIiwgaW5kZXgpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fcGxheU1vZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChcXFwi55m75b2V5L+h5oGvXFxcIiA9PSBpbnB1dCkge1xcbiAgICAgICAgICAgICAgICBjb25zdCB7XFxuICAgICAgICAgICAgICAgICAgICBvcGVuVG9rZW5zRmlsZXBhdGgsXFxuICAgICAgICAgICAgICAgICAgICBhbGlUb2tlbnNGaWxlcGF0aFxcbiAgICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJ0b2tlblBhdGhcXFwiKTtcXG4gICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QoYWxpVG9rZW5zRmlsZXBhdGgpKSByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5pyq55m76ZmGXFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IGFsaSA9IHJlcXVlc3QoYWxpVG9rZW5zRmlsZXBhdGgpO1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpID0gSlNPTi5wYXJzZShhbGkpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICBkZWxldGVGaWxlKGFsaVRva2Vuc0ZpbGVwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/ojrflj5blpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6ICfnmbvlvZXkv6Hmga8nLFxcbiAgICAgICAgICAgICAgICAgICAgY29udGVudDogXFxcIueUqOaItzpcXFwiICsgKGFsaS5uaWNrX25hbWUgfHwgYWxpLnVzZXJfbmFtZSB8fCBcXFwiVG9rZW7nmbvlvZVcXFwiKSArIFxcXCJcXFxcblRva2VuOlxcXCIgKyBhbGkucmVmcmVzaF90b2tlbiArIFxcXCJcXFxcbijlj5bmtojvvJrms6jplIDnmbvlvZXvvJvnoa7lrprvvJrlpI3liLZUb2tlbilcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygodG9rZW4pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgdG9rZW47XFxuICAgICAgICAgICAgICAgICAgICB9LCBhbGkucmVmcmVzaF90b2tlbiksXFxuICAgICAgICAgICAgICAgICAgICBjYW5jZWw6ICQudG9TdHJpbmcoKHBhdGgxLCBwYXRoMikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTms6jplIDnmbvlvZVcXFwiKS5jb25maXJtKChwYXRoMSwgcGF0aDIpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlRmlsZShwYXRoMSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUZpbGUocGF0aDIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5oiQ5Yqf6YCA5Ye655m76ZmGXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LCBwYXRoMSwgcGF0aDIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYWxpVG9rZW5zRmlsZXBhdGgsIG9wZW5Ub2tlbnNGaWxlcGF0aClcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC5yZXBsYWNlKFxcXCLmqKHlvI/vvJpcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwib3Blbk1vZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpZHMsIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLorr7nva58XFxcIiArIGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgaWYgKGlucHV0ID09IFxcXCLlrpjmlrlBUFBcXFwiK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UoKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCLlhajpg6hcXFwiICsgaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc5YWo6YOo4oCd4oCdXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgaWYgKHFyKSB7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkICsgcXIsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogcXJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBzLCBpZCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogXFxcIuWFqOmDqFxcXCIgKyBpZFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZm9yIChsZXQgW2l0LCBiYXNpY1VybF0gb2YgcnVsZXMpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IGl0ID09IHIgPyBcXFwi4oCc4oCcXFxcIiArIGl0ICsgXFxcIuKAneKAnVxcXCIgOiBpdCxcXG4gICAgICAgICAgICB1cmw6ICQoKGdldEhvbWUoYmFzaWNVcmwpIHx8IFxcXCJcXFwiKSArIFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChyLCBzLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgcXIgPSBnZXRJdGVtKFxcXCJydWxlXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJydWxlXFxcIiwgcik7XFxuICAgICAgICAgICAgICAgIGlmIChzKSB7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShxciA/IChpZCArIHFyKSA6IChcXFwi5YWo6YOoXFxcIiArIGlkKSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBxciB8fCBcXFwi5YWo6YOoXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkICsgciwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIHIgKyBcXFwi4oCd4oCdXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBpdCwgcywgaWQpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IGlkICsgaXRcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcblxcbn1cXG5cXG5mdW5jdGlvbiByZWNvcmQoKSB7XFxuICAgIGxldCBoaXN0b3J5ID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwic2VhcmNoSGlzdG9yeVxcXCIsIFtdKTtcXG4gICAgbGV0IGlpID0gaGlzdG9yeS5pbmRleE9mKHMpO1xcbiAgICBpZiAoaWkgPiAtMSkge1xcbiAgICAgICAgaGlzdG9yeS5zcGxpY2UoaWksIDEpO1xcbiAgICB9XFxuICAgIGlmIChoaXN0b3J5Lmxlbmd0aCA+IDIwKSB7XFxuICAgICAgICBoaXN0b3J5L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ICAgICAgICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJkYXRhXFxcIikuY2FycnlSdWxlKHJ1bGUsIHMsIHJlYWxQYWdlLCBzZWFyY2hNb2RlKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb2cocnVsZS5uYW1lICsgXFxcIjpcXFwiICsgZS50b1N0cmluZygpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvKmlmKGRhdGEubGVuZ3RoPT09MSYmcD09PTEpe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOlxcXCLigJzigJxcXFwiK3J1bGUubmFtZStcXFwiIEVSUk9S4oCd4oCdXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2M6IGUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOlxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDpcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYTp7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1dO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgLy9yZXR1cm4gcnVsZS5maW5kKHMsIHJlYWxQYWdlKTtcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgcGFyYW06IGl0LFxcbiAgICAgICAgICAgICAgICBpZDogXFxcInJ1bGVAXFxcIiArIGl0Lm5hbWVcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgICAgIGJhdGNoRXhlY3V0ZSh0YXNrcywge1xcbiAgICAgICAgICAgIGZ1bmM6IGZ1bmN0aW9uKHBhcmFtLCBpZCwgZXJyb3IsIHJlc3VsdCkge1xcbiAgICAgICAgICAgICAgICBwYXJhbS5pICs9IDE7XFxuICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHJlc3VsdCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oXFxcIl9ub3RoYXZlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQmVmb3JlKHBhZ2VpZCwgcmVzdWx0KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAocGFyYW0uaSA9PT0gcGFyYW0uYWxsKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXJlc3VsdCB8fCAhcmVzdWx0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oXFxcIl9ub3RoYXZlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUJlZm9yZShwYWdlaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCJ+fn7ku4DkuYjotYTmupDpg73msqHmnInlk6Z+fn5cXFwiLmZvbnRjb2xvcihcXFwiR3JheVxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJfbm90aGF2ZVxcXCJcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbShwYWdlaWQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbShwYWdlaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWKoOi9veesrFxcXCIgKyBNWV9QQUdFICsgXFxcIumhteS4re+8jOi/m+W6pu+8mlxcXCIgKyAocGFyYW0uaSArIDEpICsgXFxcIi9cXFwiICsgcGFyYW0uYWxsLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICBhbGw6IGRhdGEubGVuZ3RoLFxcbiAgICAgICAgICAgICAgICBpOiAwLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gc2V0SGlzdG9yeSgpIHtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiAnPHNwYW4gc3R5bGU9XFxcImNvbG9yOiNmZjY2MDFcXFwiPjxiPuWOhuWPsuiusOW9lTwvYj48L3NwYW4+JyxcXG4gICAgICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX2Nsb2NrXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiYXZhdGFyXFxcIixcXG4gICAgICAgIHVybDogJChbXFxcIua4hemZpOaQnOe0ouiusOW9lVxcXCIsIFxcXCLmiZPlvIDop4LnnIvorrDlvZVcXFwiXSkuc2VsZWN0KChpZCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIua4hemZpOaQnOe0ouiusOW9lVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruWumua4hemZpOWFqOmDqOaQnOe0ouiusOW9le+8n1xcXCIpLmNvbmZpcm0oKGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhpZCArIFxcXCI6a2V5XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoaWQgKyBcXFwiOnNlYXJjaEhpc3RvcnlcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSwgaWQpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9oaXN0b3J5P3J1bGU9XFxcIiArIE1ZX1JVTEUudGl0bGU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwiOnNlYXJjaEhpc3RvcnlcXFwiLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgbGV0IGhpc3RvcnkgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgW10pO1xcbiAgICBsZXQgaSA9IDA7XFxuICAgIGZvciAobGV0IGtleSBvZiBoaXN0b3J5KSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBrZXksXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpZCwga2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBleHRyYSA9IGZpbmRJdGVtKGlkICsgXFxcInNzXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIGV4dHJhLmRlZmF1bHRWYWx1ZSA9IGtleTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh7XFxuICAgICAgICAgICAgICAgICAgICBleHRyYTogZXh0cmFcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgaWQsIGtleSksXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJmbGV4X2J1dHRvblxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IGlkICsgXFxcIjprZXk6XFxcIiArIGtleSxcXG4gICAgICAgICAgICAgICAgY2xzOiBpZCArIFxcXCI6a2V5XFxcIixcXG4gICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaTlhbPplK7or406XFxcIiArIGtleSxcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpZCwga2V5LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGhpc3RvcnkgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJzZWFyY2hIaXN0b3J5XFxcIiwgW10pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpc3Rvcnkuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInNlYXJjaEhpc3RvcnlcXFwiLCBoaXN0b3J5KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtKGlkICsgXFxcIjprZXk6XFxcIiArIGtleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy90b2FzdCgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgaWQsIGtleSwgaSlcXG4gICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICBpZiAoaGlzdG9yeS5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBjbHM6IGlkICsgXFxcIjprZXlcXFwiLFxcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBzZXRUcmVuZGluZ1RhYkVuZCgpIHtcXG4gICAgbGV0IGhvdENsYXNzID0ge1xcbiAgICAgICAgXFxcIueZvuW6plxcXCI6IHtcXG4gICAgICAgICAgICBcXFwi55S16KeG5YmnXFxcIjogXFxcInRlbGVwbGF5XFxcIixcXG4gICAgICAgICAgICBcXFwi55S15b2xXFxcIjogXFxcIm1vdmllXFxcIlxcbiAgICAgICAgfSxcXG4gICAgICAgIFxcXCLlpLjlhYtcXFwiOiB7XFxuICAgICAgICAgICAgXFxcIueUteinhuWJp1xcXCI6IFxcXCLnlLXop4bliadcXFwiLFxcbiAgICAgICAgICAgIFxcXCLnlLXlvbFcXFwiOiBcXFwi55S15b2xXFxcIixcXG4gICAgICAgICAgICBcXFwi5Yqo5ryrXFxcIjogXFxcIuWKqOa8q1xcXCIsXFxuICAgICAgICAgICAgXFxcIue7vOiJulxcXCI6IFxcXCLnu7zoibpcXFwiXFxuICAgICAgICB9XFxuICAgIH07XFxuICAgIGxldCBkYXRhU291cmNlID0gT2JqZWN0LmtleXMoaG90Q2xhc3MpO1xcbiAgICBsZXQgc2VsZWN0c291cmNlID0gZ2V0SXRlbShcXFwiZGF0YVNvdXJjZVxcXCIsIGRhdGFTb3VyY2VbMF0pO1xcbiAgICBsZXQgaG90a2V5cyA9IE9iamVjdC5rZXlzKGhvdENsYXNzW3NlbGVjdHNvdXJjZV0pO1xcbiAgICBsZXQgc2VsZWN0a2V5ID0gZ2V0SXRlbShcXFwiaG90a2V5XFxcIiwgaG90a2V5c1swXSk7XFxuICA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gICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIh+aNouS4ulxcXCIgKyBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9LCBkYXRhU291cmNlKVxcbiAgICAgICAgICAgIH1dXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmraPlnKjliqDovb0uLi5cXFwiLFxcbiAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwiOmhvdGtleVxcXCIsXFxuICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIGxldCBzZCA9IFtdO1xcbiAgICBsZXQgc2V0U2VhcmNoS2V5ID0gbmFtZSA9PiB7XFxuICAgICAgICBwdXRNeVZhcigncycsIG5hbWUpO1xcbiAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIHJldHVybiAnaGlrZXI6Ly9lbXB0eSdcXG4gICAgfTtcXG5cXG4gICAgbGV0IGdldFRpdGxlID0gKGksIG5hbWUpID0+IHtcXG4gICAgICAgIGxldCBjb2xvcjtcXG4gICAgICAgIHN3aXRjaCAoaSkge1xcbiAgICAgICAgICAgIGNhc2UgMDpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcXFwiI2ZmMzMwMFxcXCI7XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgMTpcXG4gICAgICAgICAgICAgICAgY29sb3IgPSBcXFwiI2ZmN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ICAgICAgICAgICAgICAnQWNjZXB0JzogJ2FwcGxpY2F0aW9uL2pzb24sIHRleHQvcGxhaW4sICovKicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdC1MYW5ndWFnZSc6ICd6aC1DTix6aDtxPTAuOSxlbi1VUztxPTAuOCxlbjtxPTAuNycsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ0FjY2VwdC1FbmNvZGluZyc6ICdnemlwLCBkZWZsYXRlLCBicicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly90b3AuYmFpZHUuY29tL2JvYXJkP3RhYj1ub3ZlbCcsXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAvL3ZhciBzID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgdmFyIGxpc3QgPSBKU09OLnBhcnNlKGpzb24pLmRhdGEuY2FyZHNbMF0uY29udGVudDtcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaXN0Lmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0ZW0ud29yZCArICcgKCcgKyBpdGVtLnNob3dbMl0gKyAnKSc7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZGVzID0gaXRlbS5kZXNjO1xcbiAgICAgICAgICAgICAgICAgICAgc2QucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGdldFRpdGxlKGksIG5hbWUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZShzZXRTZWFyY2hLZXksIGl0ZW0ud29yZCksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogaXRlbS5pbWcsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJtb3ZpZV8xX3ZlcnRpY2FsX3BpY1xcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIGNhc2UgXFxcIuWkuOWFi1xcXCI6XFxuICAgICAgICAgICAgICAgIHZhciBqc29uID0gcmVxdWVzdChcXFwiaHR0cHM6Ly9uZXdzLm15cXVhcmsuY24vdjIvdG9wbGlzdC9tb3ZpZT8mY2hhbm5lbD1cXFwiICsgdGFia2V5ICsgXFxcIiZyYW5rX3R5cGU9JUU2JTlDJTgwJUU3JTgzJUFEXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciB4bWxEYXRhID0gKEpTT04ucGFyc2UoanNvbikuZGF0YSB8fCBcXFwiXFxcIikucmVwbGFjZSgvdGl0bGU+L2csIFxcXCJoX3RpdGxlPlxcXCIpLnJlcGxhY2UoL3NyYz4vZywgXFxcImhfc3JjPlxcXCIpLnJlcGxhY2UoL2FyZWE+L2csIFxcXCJoX2FyZWFcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGxpc3QgPSBwZGZhKHhtbERhdGEsIFxcXCJib2R5JiZpdGVtXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBnZXRUZXh0ID0gdCA9PiB0O1xcbiAgICAgICAgICAgICAgICB2YXIgdHJlbmQgPSBbXFxcIuOEp1xcXCIsIFxcXCLihpFcXFwiLCBcXFwi4oaTXFxcIl07XFxuICAgICAgICAgICAgICAgIC8vdmFyIHMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpdGVtID0gbGlzdFtpXTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuYW1lID0gcGRmaChpdGVtLCBcXFwiaF90aXRsZSYmVGV4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRlcyA9IFxcXCLng63luqbvvJpcXFwiICsgcGRmaChpdGVtLCBcXFwiaG90X3Njb3JlJiZUZXh0XFxcIikgKyBcXFwiIFxcXCIgKyB0cmVuZC5hdChwZGZoKGl0ZW0sIFxcXCJob3RfdHJlbmQmJlRleHRcXFwiKSkgK1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJcXFxcbuivhOWIhu+8mlxcXCIgKyBwZGZoKGl0ZW0sIFxcXCJzY29yZV9hdmcmJlRleHRcXFwiKS5yZXBsYWNlKC9eMCQvLCBcXFwi5pqC5peg6K+E5YiGXFxcIikgK1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJcXFxcblxcXCIgKyBwZGZoKGl0ZW0sIFxcXCJ5ZWFyJiZUZXh0XFxcIikgKyBcXFwiwrdcXFwiICsgcGRmaChpdGVtLCBcXFwiaF9hcmVhJiZUZXh0XFxcIikgKyBcXFwiwrdcXFwiICsgcGRmaChpdGVtLCBcXFwiY2F0ZWdvcnkmJlRleHRcXFwiKS5yZXBsYWNlKFxcXCIsXFxcIiwgXFxcIsK3XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBzZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZ2V0VGl0bGUoaSwgbmFtZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKHNldFNlYXJjaEtleSwgbmFtZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogcGRmaChpdGVtLCBcXFwiaF9zcmMmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcIm1vdmllXz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0YXJ0c1dpdGgoXFxcIm1hZ25ldFxcXCIpKSB7XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuajgOa1i+WIsOaWsOeahOejgemTvuWcsOWdgO+8jOeCueWHu+ehruWumuaMiemSruWNs+WPr+aSreaUvu+8jOeCueWHu+WPlua2iOaMiemSruWPr+S7peWkjeWItumTvuaOpVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobWFnKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBtYWc7XFxuICAgICAgICAgICAgfSwgaW5wdXQpLFxcbiAgICAgICAgICAgIGNhbmNlbDogJC50b1N0cmluZygobWFnKSA9PiB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBtYWdcXG4gICAgICAgICAgICB9LCBpbnB1dClcXG4gICAgICAgIH0pO1xcbiAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgIH0gZWxzZSBpZiAoJC5yZXF1aXJlKFxcXCJhbGl0ZXN0P3J1bGU9XFxcIitydWxlKS50ZXN0KGlucHV0KSAmJiBvcGVuTW9kZSAhPSBcXFwi5a6Y5pa5QVBQXFxcIikge1xcbiAgICAgICAgbG9nKGlucHV0KTtcXG4gICAgICAgIGlmIChpbnB1dC5pbmNsdWRlcygnY2hlY2t1cmw/dXJsPScpICYmIGlucHV0LmluY2x1ZGVzKCcmdXJscmVmZXInKSkge1xcbiAgICAgICAgICAgIGlucHV0ID0gZGVjb2RlVVJJQ29tcG9uZW50KGlucHV0LnNwbGl0KCcmdXJscmVmZXInKVswXS5zcGxpdCgnY2hlY2t1cmw/dXJsPScpWzFdKTtcXG4gICAgICAgICAgICAvL2xvZygn6LS05ZCnJytpbnB1dCk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gJC50b1N0cmluZygodXJsLCBydWxlKSA9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W5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgZXhwaXJlcyA9IHVybC5zcGxpdCgneC1vc3MtZXhwaXJlcz0nKVsxXS5zcGxpdCgnJicpWzBdO1xcbiAgICAgICAgY29uc3QgbGFzdHRpbWUgPSBwYXJzZUludChleHBpcmVzKSAtIERhdGUubm93KCkgLyAxMDAwO1xcbiAgICAgICAgaWYgKGxhc3R0aW1lIDwgNjApIHtcXG4gICAgICAgICAgICAvL2xvZygn6L+H5pyf5pu05pawJylcXG4gICAgICAgICAgICBsZXQgbGluZSA9IHVybC5zcGxpdCgnL21lZGlhJylbMF07IC8v5Y+W5LmL5YmN5pKt5pS+55qEdHPmrrXnur/ot69cXG4gICAgICAgICAgICBsaW5lID0gbGluZS5zdWJzdHJpbmcobGluZS5sYXN0SW5kZXhPZignLycpICsgMSk7XFxuICAgICAgICAgICAgbGV0IGYgPSBnZXRNM3U4Q29udGVudChnZXRBbGlQbGF5VXJsKGZpZCwgbGluZSkpLnNwbGl0KFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgIGYuZm9yRWFjaChpdCA9PiB7XFxuICAgICAgICAgICAgICAgIGlmIChpdCAmJiBpdC5zdGFydHNXaXRoKCcvcHJveHk/dXJsPScpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZnVybCA9IGJhc2U2NERlY29kZShpdC5yZXBsYWNlKCcvcHJveHk/dXJsPScsICcnKSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodXJsLnN1YnN0cih1cmwuaW5kZXhPZignL21lZGlhLScpLCB1cmwuaW5kZXhPZignLnRzJykpID09IGZ1cmwuc3Vic3RyKGZ1cmwuaW5kZXhPZignL21lZGlhLScpLCBmdXJsLmluZGV4T2YoJy50cycpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IGZ1cmw7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHVybDtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IHVybCA9IGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKTtcXG4gICAgICAgIGlmICh1cmwuaW5jbHVkZXMoXFxcIi50c1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiB1cGRhdGVUc1VybCh1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IHRlbXBsYXRlSWQgPSBNWV9QQVJBTVMudGVtcGxhdGVJZFswXTtcXG4gICAgICAgICAgICBpZihmaWxlRXhpc3QoY2FjaGVGaWxlUGF0aCkpe1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TTN1OENvbnRlbnQoZ2V0QWxpUGxheVVybChmaWxlSWQsIHRlbXBsYXRlSWQpKTtcXG4gICAgICAgICAgICB9ZWxzZXtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGdldE0zdThDb250ZW50KHVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgf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A9IHN0b3JhZ2UwLmdldE15VmFyKCdtb3VudHppbXUnLCB7fSk7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMobW91bnRzdWIpLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICB6aW11ID0gbW91bnRzdWI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc3VidGl0bGU7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMoemltdSB8fCB7fSkubGVuZ3RoID4gMCAmJiBwbGF5TGlzdCAmJiBwbGF5TGlzdC51cmxzICYmIHBsYXlMaXN0LnVybHMubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwKTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB2YXIgem11cmwgPSBhbGlBY2Nlc3NBcGkuZ2V0VmlkZW9UZW1QbGF5VXJsKHppbXUuZmlsZV9pZCk7XFxuICAgICAgICAgICAgICAgIGxldCBwYXRoID0gJ2hpa2VyOi8vZmlsZXMvY2FjaGUv5LqR55uY5ZCbL3N1Yi4nICsgemltdS5leHQ7XFxuICAgICAgICAgICAgICAgIGRvd25sb2FkRmlsZSh6bXVybCwgcGF0aCwge1xcbiAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLydcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHN1YnRpdGxlID0gZ2V0UGF0aChwYXRoKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLlrZfluZXliqDovb3lpLHotKVcXFwiKTtcXG4gICAgICAgICAgICAgICAgbG9nKGUubWVzc2FnZSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGRtbGlzdCA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJkbWxpc3RcX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XCIsIHN0eWxlc1swXSk7XFxuICAgIGlmIChNWV9QQUdFID09PSAxKSB7XFxuICAgICAgICBpZiAoIWdldE15VmFyKFxcXCJtb3VudHppbXVcXFwiLCBcXFwiXFxcIikpIHtcXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwibW91bnR6aW11XFxcIiwge30pO1xcbiAgICAgICAgICAgIGFkZExpc3RlbmVyKFxcXCJvbkNsb3NlXFxcIiwgJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcIm1vdW50emltdVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJhbGlTaGFyZVRva2VuXFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyVmFyKFxcXCJkbV9zaGFyZVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJkbWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwibGlzdFNlYXJjaEtleVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJkbV9saXN0VXJsTGlzdFxcXCIpO1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHNldE1hcmtlcigpO1xcbiAgICAgICAgaWYgKHJlYWx1cmwgJiYgIWlzU2VhcmNoKSB7XFxuICAgICAgICAgICAgbGV0IHNoYXJlSW5mbyA9IGFsaVNoYXJlQXBpLmdldFNoYXJlSW5mbygpO1xcbiAgICAgICAgICAgIGxldCBmaWxlSW5mbyA9IHNoYXJlSW5mby5maWxlX2luZm9zIHx8IFtdO1xcbiAgICAgICAgICAgIGlmIChmaWxlSW5mby5sZW5ndGggPT09IDEgJiYgZmlsZUluZm9bMF0udHlwZSA9PT0gXFxcImZvbGRlclxcXCIgJiYgIWZpbGVJZCkge1xcbiAgICAgICAgICAgICAgICBmaWxlSWQgPSBmaWxlSW5mb1swX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CIsXFxuICAgICAgICAgICAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpbnB1dCA9IGlucHV0LnRyaW0oKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghaW5wdXQpIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXlhbPplK7or41cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvYWxpeXVuI25vSGlzdG9yeSMjZnVsbFRoZW1lIz9wYWdlPWZ5cGFnZSZzZWFyY2hLZXk9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIG9uQ2hhbmdlOiBcXFwicHV0TXlWYXIoJ2xpc3RTZWFyY2hLZXknLGlucHV0KVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2QsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZUlkOiBzaGFyZUlkLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVUb2tlbjogc2hhcmVUb2tlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnFxcXCIgKyBzZWFyY2hLZXkgKyBcXFwi4oCd4oCd55qE5pCc57Si57uT5p6cXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGZ1bmNJdGVtcyA9IFtdO1xcbiAgICAgICAgZnVuY0l0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBzdHlsZSxcXG4gICAgICAgICAgICB1cmw6ICQoc3R5bGVzLCAxLCBcXFwi5o6S5biD5qC35byPXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiYWxpeXVuX3N0eWxlXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5YiH5o2iXFxcIjtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBwaWNfdXJsOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL2ltZy9hbGlfaWNvbi5zdmdcXFwiXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IG9yZGVyTmFtZSxcXG4gICAgICAgICAgICB1cmw6ICQob3JkZXJzS2V5cywgMiwgXFxcIuaOkuW6j+aWueW8j1xcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImFsaXl1bl9vcmRlclxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WIh+aNouaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX3NvcnQuc3ZnXFxcIlxcbiAg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AgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLovazlrZjkupHnm5hcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHNtYXJ0ZHJpdmU6Ly9zaGFyZS9icm93c2U/c2hhcmVJZD0ke3NoYXJlSWR9JnNoYXJlUHdkPSR7c2hhcmVQd2R8fFxcXCJcXFwifWA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi55m76ZmG6LSm5Y+3XFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvbG9naW4jbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLlpI3liLbliIbkuqvpk77mjqVcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChbXFxcIuWkjeWItumTvuaOpVxcXCIsIFxcXCLlpI3liLbmtbfpmJTlj6Pku6RcXFwiXSwgMSwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgodXJsKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLlpI3liLbpk77mjqVcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIHVybDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8v6Zi/6YeM5LqR55uY5YiG5Lqr5Y+j5Luk44CMXFxcIiArIGdldFBhZ2VUaXRsZSgpICsgXFxcIuOAjVxcXFxuXFxcIiArIHVybCArIFxcXCIgQGltcG9ydD1qczpgaGlrZXI6Ly9wYWdlL2FsaXl1bj9yZWFsdXJsPSR7aW5wdXQudHJpbSgpfSZydWxlPVxcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcImA7XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL1xcXCIgKyBzaGFyZUlkICsgKGZpbGVJZCA/IFxcXCIvZm9sZGVyL1xcXCIgKyBmaWxlSWQgOiBcXFwiXFxcIikpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuaJuemHj+aMgui9veacrOWcsOW8ueW5lVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2RtTW91bnQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmn6XnnIvmiYvliqjmjILovb3lrZfluZVcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgem0gPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwibW91bnR6aW11XFxcIiwge30pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGlwID0gem0ubmFtZSA/IFxcXCLlvZPliY3lrZfluZXmlofku7ZcXFxcblxcXCIgKyB6bS5uYW1lICsgXFxcIi5cXFwiICsgem0uZXh0IDogXFxcIui/mOacquaJi+WKqOaMgui9veWtl+W5lVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6ICfmiYvliqjmjILovb3lrZfluZUnLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudDogdGlwICsgXFxcIlxcXFxuKOeCueWHu+WPlua2iOWPr+S7pea4hemZpOaMgui9veWtl+W5lSlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsOiAoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwibW91bnR6aW11XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sua4hemZpOaJi+WKqOaMgui9veWtl+W5lVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6I635Y+W5by55bmV5pCc57Si6KeE5YiZXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwianNcXFwiOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL2xvYWREbT9ydWxlPVxcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIiZ0aXRsZT1cXFwiKSArIFxcXCIrZW5jb2RlVVJJQ29tcG9uZW50KHBsYXlkYXRhLnRpdGxlLnNwbGl0KCctJylbMF0pO1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwibmFtZVxcXCI6IE1ZX1JVTEUudGl0bGUgKyBcXFwi5by55bmV5pCc57SiXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInJ1bGU6Ly9cXFwiICsgYmFzZTY0RW5jb2RlKFxcXCLvv6Vwcm9qZWN0aW9uX3NjcmVlbu+/pVxcXCIgKyBKU09OLnN0cmluZ2lmeShydWxlKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5o6o6YCB5YiwVFZCb3hcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS90dmJveFB1c2gjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLorr7nva7mlLbol4/lsIHpnaJcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChbXFxcIuiuvue9ruWwgemdouWcsOWdgFxcXCIsIFxcXCLmkJzntKLlsIHpnaJcXFwiXSwgMSkuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PT0gXFxcIuiuvue9ruWwgemdouWcsOWdgFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwiXFxcIiwgXFxcIuivt+i+k+WFpeWbvueJh+WcsOWdgFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC50cmltKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW5wdXQpIHJldHVybiBcXFwidG9hc3Q6Ly/or7fovpPlhaXlnLDlnYBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRQYWdlUGljVXJsKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S/ruaUueaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2Zyb250Q292ZXIjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6I635Y+W5oqV5bGPSVBcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgaXAgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKS5nZXRJUHY0QWRkcmVzcygpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXAuc3RhcnRzV2l0aChcXFwiMTkyLjE2OC5cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXAgKyBcXFwiXFxcXG7or6VJUOmAgueUqOS6jua1gemHjyvng63ngrnnmoTmipXlsY9cXFxcbuivt+abv+aNoumTvuaOpeS4reeahDAuMC4wLjBcXFwiKS5jb25maXJtKChpcCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBpcDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGlwKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGlwICsgXFxcIlxcXFxu6I635Y+W5aSx6LSl6Z2e56iz5a6aSVAs6K+35byA5ZCv54Ot54K55YaN5L2/55SoLOivpUlQ5Y+v6IO95Lya5Y+YLOS4jeiDveaKleWxj1xcXCIpLmNvbmZpcm0oKCkgPT4ge30pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5p6B6YCf5Y6f55S75LiL6L2957q/56iLXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoZ2V0SXRlbShcXFwic3BlZWRUaHJlYWRcXFwiLCBcXFwiMjBcXFwiKSwgXFxcIuivt+i+k+WFpTMtMzLkuYvpl7TnmoTmlbTmlbBcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3BlZWRUaHJlYWQgPSBwYXJzZUludChpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3BlZWRUaHJlYWQgPCAzIHx8IHNwZWVkVGhyZWFkID4gMzIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K6+572u5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNwZWVkVGhyZWFkXFxcIiwgU3RyaW5nKHNwZWVkVGhyZWFkKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K6+572u5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6L2s5a2Y5b2T5YmN5paH5Lu25aS5XFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvbXlhbGl5dW4jbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP3BhZ2U9ZnlwYWdlXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgc2hhcmVJZCwgc2hhcmVQd2QsIGZpbGVJZCksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9maWxlaW50by5zdmdcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZUlkOiBwYWdlSWQsXFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSWQ6IHNoYXJlSWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBzaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IHNoYXJlUHdkLFxcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXI6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBmb2xkZXJOYW1lOiBnZXRQYWdlVGl0bGUoKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGZ1bmNJdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFtcXFwiQUxMXFxcIiwgXFxcIui3s+i/h+aWh+S7tlxcXCJdW051bWJlcihza2lwRmlsZSldLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHNraXBGaWxlKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJza2lwRmlsZVxcXCIsIFN0cmluZyhza2lwRmlsZSA/IFxcXCIwXFxcIiA6IFxcXCIxXFxcIikpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgc2tpcEZpbGUpLFxcbiAgICAgICAgICAgICAgICB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ZXI6IFxcXCLwn5OCXFxcIlxcbiAgICB9O1xcblxcbiAgICBmdW5jdGlvbiBnZXRIZWFkKHR5cGUsIGV4dCkge1xcbiAgICAgICAgbGV0IGhlYWQgPSB0aXRsZUhlYWRbdHlwZV07XFxuICAgICAgICBpZiAoc3ViRXh0cy5pbmNsdWRlcyhleHQpKSB7XFxuICAgICAgICAgICAgaGVhZCA9IFxcXCLwn5W4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBoZWFkIHx8IFxcXCLinZNcXFwiO1xcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIGdldFByZXZpZXdQaWMoZmlsZUl0ZW0pIHtcXG4gICAgICAgIGlmIChmaWxlSXRlbS50aHVtYm5haWwpIHtcXG4gICAgICAgICAgICByZXR1cm4gJChcXFwiaHR0cHM6Ly9lbXB0eT9cXFwiICsgZmlsZUl0ZW0uZmlsZV9pZCkuaW1hZ2UoKHBpYykgPT4ge1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoKHBpYywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0U3RyZWFtOiB0cnVlXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBmaWxlSXRlbS50aHVtYm5haWwpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGxldCBmb2xkZXJTdHlsZSwgZmlsZVN0eWxlO1xcbiAgICBsZXQgZmlsdGVyVHlwZSA9IFtdO1xcbiAgICBpZiAoc3R5bGUgPT09IFxcXCLov73liadcXFwiKSB7XFxuICAgICAgICBmb2xkZXJTdHlsZSA9IFxcXCJhdmF0YXJcXFwiO1xcbiAgICAgICAgZmlsZVN0eWxlID0gXFxcIm1vdmllXzJcXFwiO1xcbiAgICAgICAgZmlsdGVyVHlwZS5wdXNoKFxcXCJ2aWRlb1xcXCIpO1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIui/veWJp+aooeW8j+WPquaYvuekuuaWh+S7tuWkueWSjOinhumikVxcXCIuc21hbGwoKS5mb250Y29sb3IoXFxcImdyZXlcXFwiKSxcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9IGVsc2UgaWYgKHN0eWxlID09PSBcXFwi55yL5Zu+XFxcIikge1xcbiAgICAgICAgZm9sZGVyU3R5bGUgPSBcXFwiYXZhdGFyXFxcIjtcXG4gICAgICAgIGZpbGVTdHlsZSA9IFxcXCJjYXJkX3BpY18zXFxcIjtcXG4gICAgICAgIGZpbHRlclR5cGUucHVzaChcXFwiaW1hZ2VcXFwiKTtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIFxcXCLnnIvlm77mqKHlvI/lj6rmmL7npLrmlofku7blpLnlkozlm77niYdcXFwiLnNtYWxsKCkuZm9udGNvbG9yKFxcXCJncmV5XFxcIiksXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcX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YXJlSWQ6IHNoYXJlSWQsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBNWV9QQVJBTVMuc2hhcmVUb2tlbixcXG4gICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZmlsZUl0ZW0uZmlsZV9pZCxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZCxcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogZmlsZUl0ZW0ubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgbm9QaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLovazlrZhcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL215YWxpeXVuI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9wYWdlPWZ5cGFnZVxcXCIpXFxuICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2UgaWYgKG5vU2tpcEZpbGUpIHtcXG4gICAgICAgICAgICBpZiAoZmlsdGVyVHlwZS5sZW5ndGggPiAwICYmICFmaWx0ZXJUeXBlLmluY2x1ZGVzKGNhdGUpKSB7XFxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgc3VidGl0bGUsIGNscywgbG9uZ2MgPSBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui9rOWtmFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL215YWxpeXVuI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9wYWdlPWZ5cGFnZVxcXCIpXFxuICAgICAgICAgICAgfV07XFxuICAgICAgICAgICAgbGV0IHRpdGxlID0gZmlsZUl0ZW0ubmFtZTtcXG4gICAgICAgICAgICBsZXQgbmFtZU5vdEV4dCA9IGZpbGVJdGVtLm5hbWUucmVwbGFjZSgnLicgKyBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbiwgJycpO1xcbiAgICAgICAgICAgIGlmIChzdWJFeHRzLmluY2x1ZGVzKGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uKSkge1xcbiAgICAgICAgICAgICAgICBsb25nYy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5oyC6L295a2X5bmVXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh6bSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdtb3VudHppbXUnLCB6bSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0b2FzdDovL+aMgui9veWujOaIkO+8jOW9k+WJjeWtl+W5leaWh+S7tjogJyArIHptLm5hbWUgKyAnLicgKyB6bS5leHQ7XFxuICAgICAgICAgICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0OiBmaWxlSXRlbS5maWxlX2V4dGVuc2lvbixcXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlX2lkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IG5hbWVOb3RFeHRcXG4gICAgICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGNhdGUgPT09IFxcXCJ2aWRlb1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHppbXVsaXN0Lm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1xcbiAgICAgICAgICAgICAgICB9LCBzaGFyZUlkLCBzaGFyZVB3ZCwgTVlfUEFSQU1TLnNoYXJlVG9rZW4sIGZpbGVJdGVtLmZpbGVfaWQsIGNhdGUsIHN1YnRpdGxlKSxcXG4gICAgICAgICAgICAgICAgZGVzYzogZGVzYyxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogcGljX3VybCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBmaWxlSXRlbS5maWxlX2lkLFxcbiAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXI6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZUluZm86IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlSWQ6IHBhZ2VJZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVJZDogc2hhcmVJZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGFyZVRva2VuOiBzaGFyZVRva2VuLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZCxcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IGxvbmdjLFxcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBjbHMsXFxuICAgICAgICAgICAgICAgICAgICAvL2luaGVyaXRUaXRsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWVcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IGZpbGVTdHlsZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGlmIChjb250cy5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGl0ZW1zLnB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CIpIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLor7fovpPlhaXmj5Dlj5bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBzaGFyZVB3ZCA/IFxcXCLigJzigJzmj5Dlj5bnoIHplJnor6/igJ3igJ1cXFwiIDogXFxcIlxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJCgpLmlucHV0KChNWV9QQVJBTVMpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldFBhZ2VQYXJhbXMoT2JqZWN0LmFzc2lnbih7fSwgTVlfUEFSQU1TLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVQd2Q6IGlucHV0XFxuICAgICAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9LCBNWV9QQVJBTVMpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChlLnNpZ25pZmljYW5jZSA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdXFxcIiArIGUubWVzc2FnZS5iaWcoKS5iaWcoKS5mb250Y29sb3IoXFxcInJlZFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfY2VudGVyXzEnLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGUuc2lnbmlmaWNhbmNlID09PSAzKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgZS5tZXNzYWdlLmJpZygpLmZvbnRjb2xvcihcXFwiZ3JlZW5cXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICd0ZXh0X2NlbnRlcl8xJ1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuXFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBsb2coXFxcIuWIl+ihqOWKoOi9veWksei0pSNcXFxcbumUmeivr+S/oeaBrz5cXFwiICsgZS50b1N0cmluZygpICsgXFxcIlxcXFxu6ZSZ6K+v6KGMPlxcXCIgKyBlLmxpbmVOdW1iZXIpO1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6ICfmrKfmrKfvvIzmiqXplJnkuobjgILlnKjliLfmlrDlh6DmrKHvvJ/miJbogIXmm7TmjaLmlofku7blpLnjgIInLFxcbiAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgIGRlc2M6IGUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ3RleHRfY2VudGVyXzEnXFxuICAgICAgICB9KTtcXG4gICAgICAgIC8vdGhyb3cgZTtcXG4gICAgfVxcbn1cXG5zYXZlTXlQYUNhY2hlKCk7XFxuc2V0UmVzdWx0KGl0ZW1zKTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIueZu+W9lei0puWPt1wiLFwicGF0aFwiOlwibG9naW5cIixcInJ1bGVcIjpcImpzOlxcbnZhciBkID0gW107XFxuc2V0UGFnZVRpdGxlKFxcXCLnmbvlvZXpmL/ph4zkupH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tZShcXFwi6I635Y+W5aSx6LSlXFxcIik7XFxuICAgIGxldCBja2sgPSBxci5jb250ZW50LmRhdGE7XFxuICAgIGxldCBib2R5ID0ge1xcbiAgICAgICAgY2s6IGNray5jayxcXG4gICAgICAgIHQ6IGNray50ICsgXFxcIlxcXCIsXFxuICAgICAgICBhcHBOYW1lOiBcXFwiYWxpeXVuX2RyaXZlXFxcIixcXG4gICAgICAgIGFwcEVudHJhbmNlOiBcXFwid2ViXFxcIixcXG4gICAgICAgIGlzTW9iaWxlOiBmYWxzZSxcXG4gICAgICAgIGxhbmc6IFxcXCJ6aF9DTlxcXCIsXFxuICAgICAgICBuYXZQbGF0Zm9ybTogXFxcIk1hY0ludGVsXFxcIixcXG4gICAgICAgIHJldHVyblVybDogXFxcIlxcXCIsXFxuICAgICAgICBuYXZsYW5ndWFnZTogXFxcInpoLUNOXFxcIixcXG4gICAgICAgIGZyb21TaXRlOiA1MixcXG4gICAgICAgIGJpelBhcmFtczogXFxcIlxcXCJcXG5cXG4gICAgfTtcXG4gICAgLypcXG4gICAgIHtcXG4gICAgICAgIE5FVzogXFxcIuW+heaJq+aPj1xcXCIsXFxuICAgICAgICBDQU5DRUxFRDogXFxcIuWPlua2iFxcXCIsXFxuICAgICAgICBTQ0FORUQ6XFxcIuW3suaJq+aPj1xcXCIsXFxuICAgICAgICBDQU5DRUxFRDogXFxcIuWujOaIkFxcXCJcXG4gICAgfSovXFxuICAgIGxldCBlcnJvckNvdW50ID0gMDtcXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCAzMDsgaSsrKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCByZXN1bHQgPSBKU09OLnBhcnNlKHBvc3QoXFxcImh0dHBzOi8vcGFzc3BvcnQuYWxpeXVuZHJpdmUuY29tL25ld2xvZ2luL3FyY29kZS9xdWVyeS5kbz9hcHBOYW1lPWFsaXl1bl9kcml2ZSZmcm9tU2l0ZT01MiZfYngtdj0yLjIuM1xcXCIsIHtcXG4gICAgICAgICAgICAgICAgYm9keTogYm9keVxcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICBsZXQgcXJDb2RlU3RhdHVzID0gcmVzdWx0LmNvbnRlbnQuZGF0YS5xckNvZGVTdGF0dXM7XFxuXFxuICAgICAgICAgICAgaWYgKHFyQ29kZVN0YXR1cyA9PT0gXFxcIkNPTkZJUk1FRFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgaWYgKHJlc3VsdC5jb250ZW50LmRhdGEuYml6RXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaW5mbyA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKHJlc3VsdC5jb250ZW50LmRhdGEuYml6RXh0KSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgYWxpVG9rZW5zRmlsZXBhdGggPSAkLnJlcXVpcmUoXFxcImhpa2VyOi8vcGFnZS90b2tlblBhdGhcXFwiKS5hbGlUb2tlbnNGaWxlcGF0aDtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBhbGlUb2tlbiA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoX3Rva2VuOiBpbmZvLnBkc19sb2dpbl9yZXN1bHQucmVmcmVzaFRva2VuXFxuICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKGFsaVRva2Vuc0ZpbGVwYXRoLCBKU09OLnN0cmluZ2lmeShhbGlUb2tlbikpO1xcbiAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJsb2dpbnlcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnmbvlvZXmiJDlip8o54K55Ye76L+U5ZueKVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgYmFja0hvbWUoXFxcIueZu+W9leaIkOWKn1xcXCIsIHRydWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYmFja0hvbWUoXFxcIueZu+W9leWksei0pSzor7flsJ3or5Xlhbbku5bnmoTmlrnms5VcXFwiKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChxckNvZGVTdGF0dXMgPT09IFxcXCJDQU5DRUxFRFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgYmFja0hvbWUoXFxcIuWPlua2iOeZu+W9leaOiOadg1xcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChbXFxcIk5FV1xcXCIsIFxcXCJTQ0FORURcXFwiXS5pbmNsdWRlcyhxckNvZGVTdGF0dXMpKSB7XFxuICAgICAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMjUwMCk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgYmFja0hvbWUoXFxcIui2heaXtlxcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGVycm9yQ291bnQrKztcXG4gICAgICAgICAgICBpZiAoZXJyb3JDb3VudCA+IDQpIH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CIsIHtcXG4gICAgICAgIGdldCgpIHtcXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fc2hhcmVUb2tlbiB8fCB0aGlzLmdldFNoYXJlVG9rZW4oKTtcXG4gICAgICAgIH0sXFxuICAgICAgICBzZXQodikge1xcbiAgICAgICAgICAgIHRoaXMuX3NoYXJlVG9rZW4gPSB2O1xcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsIFxcXCJvcGVuVG9vbHNcXFwiLCB7XFxuICAgICAgICBnZXQoKSB7XFxuICAgICAgICAgICAgaWYgKHRoaXMuX29wZW5Ub29scykgcmV0dXJuIHRoaXMuX29wZW5Ub29scztcXG4gICAgICAgICAgICBsZXQgT3BlbkFwaVRvb2xzO1xcbiAgICAgICAgICAgIHN3aXRjaCAoZ2V0SXRlbShcXFwib3BlbkFwaU1vZGVcXFwiLCBcXFwiMFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGNhc2UgXFxcIjFcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgT3BlbkFwaVRvb2xzID0gJC5yZXF1aXJlKFxcXCJvcGVuQXBpX2FsaXl1bmRyaXZlXFxcIiArIHRoaXMub3BlblN1ZmZpeCk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgY2FzZSBcXFwiMlxcXCI6XFxuICAgICAgICAgICAgICAgICAgICBPcGVuQXBpVG9vbHMgPSAkLnJlcXVpcmUoXFxcIm9wZW5BcGlfdHZib3hcXFwiICsgdGhpcy5vcGVuU3VmZml4KTtcXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICBjYXNlIFxcXCIzXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgIE9wZW5BcGlUb29scyA9ICQucmVxdWlyZShcXFwib3BlbkFwaV9YQllcXFwiICsgdGhpcy5vcGVuU3VmZml4KTtcXG4gICAgICAgICAgICAgICAg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YXNzaWduKEFsaUFjY2Vzc0FwaS5wcm90b3R5cGUsIHtcXG4gICAgX29wZW5Ub29sczogdm9pZCAwLFxcbiAgICBfb3BlblRva2Vuczogdm9pZCAwLFxcbiAgICBfc2hhcmVUb2tlbjogdm9pZCAwLFxcbiAgICB3YWl0U2xlZXAodGltZSkge1xcbiAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCh0aW1lIHx8IDYwMCk7XFxuICAgICAgICByZXR1cm4gdGhpcztcXG4gICAgfSxcXG4gICAgcG9zdEFwaShhcGkpIHtcXG4gICAgICAgIHJldHVybiBodHRwUmVxdWVzdC5wb3N0KGFwaS5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikgPyBhcGkgOiAnaHR0cHM6Ly9hcGkuYWxpeXVuZHJpdmUuY29tJyArIGFwaSkuYm9keVRvU3RyaW5nKHRydWUpLmVycm9yKChlcnIpID0+IHtcXG4gICAgICAgICAgICB0aHJvdyBlcnI7XFxuICAgICAgICB9KS5lcnJvclR5cGUoKGVyciwgcmVzKSA9PiB7XFxuICAgICAgICAgICAgbGV0IHJlc3VsdCA9IHt9O1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHJlc3VsdCA9IEpTT04ucGFyc2UocmVzLmJvZHkpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVycjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJib2R5ID0gKHJlc3VsdC5jb2RlID8gcmVzdWx0IDogKHJlc3VsdCAmJiByZXN1bHQucmVzcG9uc2VzICYmIHJlc3VsdC5yZXNwb25zZXNbMF0gJiYgcmVzdWx0LnJlc3BvbnNlc1swXS5ib2R5KSkgfHwge307XFxuICAgICAgICAgICAgaWYgKHJib2R5LmNvZGUpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG1zZyA9IHJib2R5LmRpc3BsYXlfbWVzc2FnZSB8fCByYm9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AgICAgICAgICAgICAgICAgICB0aGlzLmRlZkRyaXZlSWQgPSB0aGlzLmFsaVRva2Vucy5kZWZhdWx0X2RyaXZlX2lkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhcXFwi55So5oi35L+h5oGv6I635Y+W5aSx6LSl77yaXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICB0aGlzLnJlZnJlc2hBY2Nlc3NDYWxsQmFjayhyZXN1bHQsIHRoaXMpO1xcbiAgICAgICAgcmV0dXJuIHRoaXMuYWxpVG9rZW5zO1xcbiAgICB9LFxcbiAgICBnZXRVc2VySW5mbygpIHtcXG4gICAgICAgIGxldCBpbmZvID0gdGhpcy5wb3N0QXBpKFxcXCJodHRwczovL3VzZXIuYWxpeXVuZHJpdmUuY29tL3YyL3VzZXIvZ2V0XFxcIikuaGVhZGVycyh7XFxuICAgICAgICAgICAgXFxcIlVzZXItQWdlbnRcXFwiOiBQQ19VQSxcXG4gICAgICAgICAgICBcXFwiYXV0aG9yaXphdGlvblxcXCI6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXFxcIlxcbiAgICAgICAgfSkuZXJyb3JXaXRoUmV0cnkoKGUsIF8sIGh0dHApID0+IHtcXG4gICAgICAgICAgICB0aGlzLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTt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ZW4pIHtcXG4gICAgICAgICAgICAgICAgdGhpcy5jYWNoZU9wZW5Ub2tlbihvcGVuUmVzdWx0KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMub3BlblRva2VucztcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIui/lOWbnue7k+aenOaXoFRva2VuXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwiT3BlblRva2Vu6I635Y+W5aSx6LSlOlxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICBfY2xvdWRGaWxlT3BlcmF0ZShib2R5LCBjbG91ZEZpbGVJZCwgb3BlcmF0ZVVybCkge1xcbiAgICAgICAgbGV0IHJlc3VsdCA9IHRoaXMucG9zdEFwaSgnaHR0cHM6Ly9hcGkuYWxpeXVuZHJpdmUuY29tL2Fkcml2ZS92Mi9iYXRjaCcpLmJvZHkoe1xcbiAgICAgICAgICAgIFxcXCJyZXF1ZXN0c1xcXCI6IFt7XFxuICAgICAgICAgICAgICAgIFxcXCJib2R5XFxcIjogYm9keSxcXG4gICAgICAgICAgICAgICAgXFxcImhlYWRlcnNcXFwiOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29udGVudC1UeXBlXFxcIjogXFxcImFwcGxpY2F0aW9uL2pzb25cXFwiXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIFxcXCJpZFxcXCI6IGNsb3VkRmlsZUlkIHx8IFxcXCIwXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIm1ldGhvZFxcXCI6IFxcXCJQT1NUXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcInVybFxcXCI6IG9wZXJhdGVVcmxcXG4gICAgICAgICAgICB9XSxcXG4gICAgICAgICAgICBc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HRoaXMuZ2V0TXlEcml2aWQoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgICAgICAneC1zaGFyZS10b2tlbic6IHRoaXMuc2hhcmVUb2tlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgIH0sXFxuICAgIGNvcHlGaWxlVG9DbG91ZEZpbGUoZmlsZUlkLCBwYXJlbnRGaWxlSWQsIHJldHJ5KSB7XFxuICAgICAgICBsZXQgcmVzdWx0ID0gdGhpcy5fY2xvdWRGaWxlT3BlcmF0ZSh7XFxuICAgICAgICAgICAgXFxcImZpbGVfaWRcXFwiOiBmaWxlSWQsXFxuICAgICAgICAgICAgXFxcInNoYXJlX2lkXFxcIjogdGhpcy5zaGFyZUlkLFxcbiAgICAgICAgICAgIFxcXCJhdXRvX3JlbmFtZVxcXCI6IHRydWUsXFxuICAgICAgICAgICAgXFxcInRvX3BhcmVudF9maWxlX2lkXFxcIjogcGFyZW50RmlsZUlkIHx8IFxcXCJyb290XFxcIixcXG4gICAgICAgICAgICBcXFwidG9fZHJpdmVfaWRcXFwiOiB0aGlzLmdldE15RHJpdmlkKClcXG4gICAgICAgIH0sIFxcXCIwXFxcIiwgXFxcIi9maWxlL2NvcHlcXFwiKTtcXG4gICAgICAgIGxldCBib2R5ID0gcmVzdWx0ICYmIHJlc3VsdC5yZXNwb25zZXMgJiYgcmVzdWx0LnJlc3BvbnNlc1swXSAmJiByZXN1bHQucmVzcG9uc2VzWzBdLmJvZHkgfHwge307XFxuICA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uICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgyLCAoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIC8vdGhpcy53YWl0U2xlZXAoMzApLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDMwKS50cnlPcGVuQXBpU29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgJ2RyaXZlX2lkJzogdGhpcy5nZXRNeURyaXZpZCgpLFxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMub3BlblRva2Vucy5BY2Nlc3NUb2tlbk9wZW5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gZmlsZUluZm8udmlkZW9fcHJldmlld19wbGF5X2luZm8ubGl2ZV90cmFuc2NvZGluZ190YXNrX2xpc3QucmV2ZXJzZSgpO1xcbiAgICB9LFxcbiAgICBnZXRBbGxWaWRlb1RlbVBsYXlVcmwoZmlsZUlkLCBvbmx5UHJldmlldykge1xcbiAgICAgICAgbGV0IGNsb3VkRmlsZUlkID0gdGhpcy5jb3B5RmlsZVRvQ2xvdWRGaWxlKGZpbGVJZCk7XFxuICAgICAgICB0aGlzLndhaXRTbGVlcCgyMCk7XFxuICAgICAgICBsZXQgcGxheVVybCA9IG9ubHlQcmV2aWV3ID8gdW5kZWZpbmVkIDogdGhpcy5vcGVuQ2xvdWRGaWxlVG9Eb3duVXJsKGNsb3VkRmlsZUlkKTtcXG4gICAgICAgIHRoaXMud2FpdFNsZWVwKDUwKTtcXG4gIC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gICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20nLFxcbiAgICAgICAgICAgICdBdXRob3JpemF0aW9uJzogdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICdYLVNoYXJlLVRva2VuJzogdGhpcy5zaGFyZVRva2VuLFxcbiAgICAgICAgICAgICd4LWRldmljZS1pZCc6IHRoaXMuYWxpVG9rZW5zLmRldmljZV9pZCxcXG4gICAgICAgICAgICAneC1zaWduYXR1cmUnOiBuZXdTaWduLnNpZ25hdHVyZVxcbiAgICAgICAgfSkuZXJyb3JXaXRoUmV0cnkoMywgKGUsIF8sIGh0dHApID0+IHtcXG4gICAgICAgICAgICBpZiAoZS5tZXNzYWdlID09PSBcXFwieC1kZXZpY2UtaWQgZW1wdHlcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHRoaXMud2FpdFNsZWVwKDIwKS5yZWZyZXNoQWNjZXNzVG9rZW4oKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdGhpcy50cnlTb2x2ZShlKTtcXG4gICAgICAgICAgICB0aGlzLndhaXRTbGVlcCg1MCk7XFxuICAgICAgICAgICAgbmV3U2lnbiA9IGNhbGN1bGF0ZU5ld1NpZ24oKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwicHViS2V5XFxcIjogbmV3U2lnbi5wdWJLZXlcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ0F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgICAgICAnWC1TaGFyZS1Ub2tlbic6IHRoaXMuc2hhcmVUb2tlbixcXG4gICAgICAgICAgICAgICAgICAgICd4LWRldmljZS1pZCc6IHRoa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ZXItQWdlbnQnOiBQQ19VQSxcXG4gICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vJyxcXG4gICAgICAgICAgICAnYXV0aG9yaXphdGlvbic6IHRoaXMub3BlblRva2Vucy5BY2Nlc3NUb2tlbk9wZW5cXG4gICAgICAgIH0pLmVycm9yV2l0aFJldHJ5KDIsIChlLCBfLCBodHRwKSA9PiB7XFxuXFxuICAgICAgICAgICAgdGhpcy53YWl0U2xlZXAoMzApLnRyeU9wZW5BcGlTb2x2ZShlKTtcXG4gICAgICAgICAgICBodHRwLm1lcmdlSGVhZEFuZEJvZHkoe1xcbiAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAnZHJpdmVfaWQnOiB0aGlzLmdldE15RHJpdmlkKCksXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy5vcGVuVG9rZW5zLkFjY2Vzc1Rva2VuT3BlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgIH0sXFxuICAgIGdldFNlYXJjaExpc3RGaWxlKGtleSwgbWFya2VyLCBvcmRlckJ5LCBvcmRlckRpcmVjdGlvbiwgbW9kZSkge1xcbiAgICAgICAgbGV0IHR5cGUgPSBcXFwiXFxcIjtcXG4gICAgICAgIGlmIChtb2RlID09PSAxKSB7XFxuICAgICAgICAgICAgdHlwZSA9IFxcXCJ0eXBlPVxcXFxcXFwiZmlsZVxcXFxcXFwiIGFuZCBcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChtb2RlID09PSAyKSB7XFxuICAgICAgICAgICAgdHlwZSA9IFxcXCJ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dkcml2ZV9pZCc6IHRoaXMuZ2V0TXlEcml2aWQoKSxcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ2F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMocmVzdWx0KS5sZW5ndGggPT09IDApIHtcXG4gICAgICAgICAgICByZXN1bHQuaXRlbXMgPSBbXTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgIH0sXFxuICAgIHNpZ25JblJld2FyZCgpIHtcXG4gICAgICAgIGxldCBzaWxEYXRhID0gdGhpcy5wb3N0QXBpKCdodHRwczovL21lbWJlci5hbGl5dW5kcml2ZS5jb20vdjEvYWN0aXZpdHkvc2lnbl9pbl9saXN0JykuYm9keSh7XFxuICAgICAgICAgICAgJ2dyYW50X3R5cGUnOiAncmVmcmVzaF90b2tlbicsXFxuICAgICAgICAgICAgJ3JlZnJlc2hfdG9rZW4nOiB0aGlzLmFsaVRva2Vucy5yZWZyZXNoX3Rva2VuXFxuICAgICAgICB9KS5oZWFkZXJzKHtcXG4gICAgICAgICAgICAnQXV0aG9yaXphdGlvbic6IHRoaXMucmVhY2Nlc3NUayxcXG4gICAgICAgICAgICAnQ29udGVudC1UeXBlJzogJ2FwcGxpY2F0aW9uL2pzb24nXFxuICAgICAgICB9KS5lcnJvcldpdGhSZXRyeSgoZSwgXywgaHR0cCkgPT4ge1xcbiAgICAgICAgICAgIHRoaXMudHJ5U29sdmUoZSk7XFxuICAgICAgICAgICAgaHR0cC5tZXJnZUhlYWRBbmRCb2R5KHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ0F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGssXFxuXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgICdyZWZyZXNoX3Rva2VuJzogdGhpcy5hbGlUb2tlbnMucmVmcmVzaF90b2tlblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIGxldCBkYXkgPSBzaWxEYXRhLnJlc3VsdC5zaWduSW5Db3VudDtcXG4gICAgICAgIGxldCBpc1Jld2FyZCA9IHNpbERhdGEucmVzdWx0LnNpZ25JbkxvZ3NbZGF5IC0gMV0uaXNSZXdhcmQ7XFxuICAgICAgICBpZiAoaXNSZXdhcmQpIHtcXG4gICAgICAgICAgICBsZXQgcmV3YXJkID0gc2lsRGF0YS5yZXN1bHQuc2lnbkluTG9nc1tkYXkgLSAxXS5yZXdhcmQ7XFxuICAgICAgICAgICAgaWYgKHJld2FyZCkge1xcbiAgICAgICAgICAgICAgICBsZXQgcmV3bm90aWNlID0gcmV3YXJkLm5vdGljZTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCLku4rlpKnlt7Lnu4/nrb7liLDvvIzor7fkuI3opoHph43lpI3nrb7liLDvvIFcXFxcblxcXCIgKyByZXdub3RpY2U7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgLy/msqHmnInlpZblirHvvIzlj6rmnInlubjov5Dnrb7lkI3niYdcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCLku4rlpKnlt7Lnu4/nrb7liLDvvIzor7fkuI3opoHph43lpI3nrb7liLDvvIFcXFxcbuS7iuaXpeWlvei/kOetvjpcXFwiICsgc2lsRGF0YS5yZXN1bHQuYmxlc3Npbmc7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgc2lyRGF0YSA9IHRoaXMucG9zdEFwaSgnaHR0cHM6Ly9tZW1iZXIuYWxpeXVuZHJpdmUuY29tL3YxL2FjdGl2aXR5L3NpZ25faW5fcmV3YXJkJykuYm9keSh7XFxuICAgICAgICAgICAgICAgIFxcXCJzaWduSW5EYXlcXFwiOiBkYXlcXG4gICAgICAgICAgICB9KS5oZWFkZXJzKHtcXG4gICAgICAgICAgICAgICAgJ0F1dGhvcml6YXRpb24nOiB0aGlzLnJlYWNjZXNzVGssXFxuICAgICAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAnYXBwbGljYXRpb24vanNvbidcXG4gICAgICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgICAgICBsZXQgcmV3YXJkID0gc2lyRGF0YS5yZXN1bHQ7XFxuICAgICAgICAgICAgaWYgKHJld2FyZCkge1xcbiAgICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcIuetvuWIsOaIkOWKnyEg6I635b6X5aWW5YqxOlxcXCIgKyByZXdhcmQubm90aWNlICsgXFxcIihcXFwiICsgcmV3YXJkLnN1Yk5vdGljZSArIFxcXCIpIOacrOaciOW3sui/nue7reetvuWIsDpcXFwiICsgZGF5ICsgXFxcIuWkqVxcXCI7XFxuICAgICAgICAgICAgICAgIHJldHVybiBtc2c7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgLy/msqHmnInlpZblirHvvIzlj6rmnInlubjov5Dnrb7lkI3niYdcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCLnrb7liLDmiJDlip/vvIHku4rml6Xlubjov5Dnrb46XFxcIiArIHNpbERhdGEucmVzdWx0LmJsZXNzaW5nO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfVxcbn0pO1xcblxcbkFsaUFjY2Vzc0FwaS5jcmVhdGVEZWZhdWx0ID0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ICh0eXBlb2YgZXJyb3JDYWxsYmFja1dpdGhSZXRyeSAhPT0gXFxcImZ1bmN0aW9uXFxcIikge1xcbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xcbiAgICAgICAgfVxcbiAgICAgICAgdGhpcy5yZXRyeUNvdW50ID0gTnVtYmVyKHJldHJ5Q291bnQpO1xcbiAgICAgICAgdGhpcy5lcnJvckNhbGxiYWNrV2l0aFJldHJ5ID0gZXJyb3JDYWxsYmFja1dpdGhSZXRyeTtcXG4gICAgICAgIHJldHVybiB0aGlzO1xcbiAgICB9LFxcbiAgICBzdGFydCh0b0pzb24pIHtcXG4gICAgICAgIGxldCBvcHRpb25zID0gT2JqZWN0LmFzc2lnbih7fSwgdGhpcy5vcHRpb25zKTtcXG4gICAgICAgIGlmICh0eXBlb2Ygb3B0aW9ucy5ib2R5ID09PSBcXFwib2JqZWN0XFxcIiAmJiB0aGlzLl9ib2R5VG9TdHJpbmcpIHtcXG4gICAgICAgICAgICBvcHRpb25zLmJvZHkgPSBKU09OLnN0cmluZ2lmeShvcHRpb25zLmJvZHkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgdmFyIHJlcyA9IEpTT04ucGFyc2UodGhpcy5zdGFydFJlcXVlc3QodGhpcy51cmwsIG9wdGlvbnMpKTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKHJlcy5zdGF0dXNDb2RlID49IDIwMCAmJiByZXMuc3RhdHVzQ29kZSA8PSAzMDApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGJvZHkgPSByZXMuYm9keTtcXG4gICAgICAgICAgICAgICAgaWYgKHRvSnNvbikge1xcbiAgICAgICAgICAgICAgICAgICAgYm9keSA9IEpTT04ucGFyc2UoYm9keSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc3VjY2Vzc0NhbGxiYWNrKGJvZHksIHJlcyk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFN0cmluZyhyZXMuc3RhdHVzQ29kZSkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGVycikge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIGVyciA9IHRoaXMuZXJyb3JUeXBlQ2FsbGJhY2soZXJyLCByZXMpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHRoaXMucmV0cnlDb3VudCkge1xcblxcbiAgICAgICAgICAgICAgICBsZXQgdHJ5UmVzdWx0ID0gdGhpcy5lcnJvckNhbGxiYWNrV2l0aFJldHJ5KGVyciwgcmVzLCB0aGlzKTtcXG4gICAgICAgICAgICAgICAgaWYgKHRyeVJlc3VsdCkge1xcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXRyeUNvdW50LS07XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zdGFydCh0b0pzb24pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXRyeUNvdW50ID0gMDtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmVycm9yQ2FsbGJhY2soZXJyLCByZXMpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZXJyb3JDYWxsYmFjayhlcnIsIHJlcyk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICBzZXRPcHRpb25zKG9wdGlvbnMpIHtcXG4gICAgICAgIHRoaXMub3B0aW9ucyA9IE9iamVjdC5hc3NpZ24oe30sIG9wdGlvbnMsIHtcXG4gICAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZVxcbiAgICAgICAgfSk7XFxuICAg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FtcyA9IHBhcmFtVGV4dC5zcGxpdChcXFwiLFxcXCIpO1xcbiAgICAgICAgbGV0IHBhcmFtc1QgPSBbXTtcXG4gICAgICAgIGZvciAobGV0IGkgaW4gcGFyYW1zKSB7XFxuICAgICAgICAgICAgLyppZiAoaSA9PSAwKSB7XFxuICAgICAgICAgICAgICAgIHBhcmFtc1QucHVzaChwYXJzZUludChwYXJhbXNbaV0pKTtcXG4gICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgaWYgKGkgPT0gMikge1xcbiAgICAgICAgICAgICAgICBwYXJhbXNULnB1c2goXFxcIjI1XFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICAgICAgLy/popzoibLlgLzkuLow5pe277yM6buY6K6k6K6+572u5Li655m96ImyXFxuICAgICAgICAgICAgICAgIGlmIChwYXJhbXNbaV0gPT0gXFxcIjBcXFwiIHx8IHBhcmFtc1tpXSA9PSBcXFwiLTFcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJhbXNULnB1c2goXFxcIjE2Nzc3MjE1XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBwYXJhbXNULnB1c2gocGFyYW1zW2ldKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHBhcmFtc1QucHVzaChcXFwiMFxcXCIpO1xcbiAgICAgICAgbGV0IHRpbWVzPXBhcnNlSW50KHBhcmFtc1swXS82MCkrXFxcIjpcXFwiK3BhcnNlSW50KHBhcmFtc1swXSU2MCk7XFxuICAgICAgICBkTWNvbnRleHQgKz0gYDxkIHA9XFxcIiR7cGFyYW1zVC5qb2luKCcsJyl9XFxcIj4ke2VuY29kZUh0bWwoY29tbWVudFRleHQpK1xcXCIj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si5bm25LiL6L29Li4uXFxcIik7XFxuICAgICAgICAgICAgbGV0IFtuYW1lLCBwb3NdID0gaW5wdXQuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgaWYgKCFuYW1lIHx8ICFwb3MpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgXFxcIuagvOW8j+mUmeivr1xcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCB1cmxJbmZvID0gZmV0Y2goYnVpbGRVcmwoXFxcImh0dHBzOi8vYXp1cmUubGV1c2UudG9wL3NlYXJjaGRtXFxcIiwge1xcbiAgICAgICAgICAgICAgICBwYXJhbXM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJuYW1lXFxcIjogbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwb3NcXFwiOiBwb3NcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICB1cmxJbmZvID0gSlNPTi5wYXJzZSh1cmxJbmZvKTtcXG4gICAgICAgICAgICBpZiAoIXVybEluZm8udXJsKSB0aHJvdyBcXFwi5pqC5pe25rKh5pyJ5om+5Yiw6K+l6KeG6aKR55qE5by55bmVXFxcIjtcXG4gICAgICAgICAgICBsZXQgeG1sID0gZmV0Y2goYnVpbGRVcmwoXFxcImh0dHBzOi8vYXp1cmUubGV1c2UudG9wL2Rhbm11XFxcIiwge1xcbiAgICAgICAgICAgICAgICBwYXJhbXM6IHVybEluZm9cXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICBpZiAoIXhtbCkge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBcXFwi6L+Y5rKh5pyJ5by55bmV5ZOfflxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvY2FjaGUvZGFubXUvXFxcIiArIHVybEluZm8ucGxhdGZvcm0gKyBcXFwiX1xcXCIgKyBuYW1lICsgXFxcIl9cXFwiICsgcG9zICsgXFxcIi54bWxcXFwiO1xcbiAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCAnPD94bWwgdmVyc2lvbj1cXFwiMS4wXFxcIiBlbmNvZGluZz1cXFwiVVRGLThcXFwiPz5cXFxcbicgKyB4bWwpO1xcbiAgICAgICAgICAgIGlmIChvbmx5RG93bmxvYWQpIHJldHVybiBcXFwidG9hc3Q6Ly/kuIvovb3lrozmiJBcXFwiO1xcbiAgICAgICAgICAgIHJlZnJlc2hWaWRlb1VybCh7XFxuICAgICAgICAgICAgICAgIGRhbm11OiBwYXRoXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WKoOi9veWujOaIkFxcXCI7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgIH1cXG4gICAgfSwgb25seURvd25sb2FkKSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiXFxufSk7XFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCJkbeebkuWtkOaQnOe0olxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoa2V5LCBvbmx5RG93bmxvYWQpID0+IHtcXG4gICAgICAgIGxldCBkbSA9IGdldFZhcihcXFwiZG1fc2hhcmVcXFwiKTtcXG4gICAgICAgIGlmIChkbSAmJiAhb25seURvd25sb2FkKSB7XFxuICAgICAgICAgICAgY2xlYXJWYXIoXFxcImRtX3NoYXJlXFxcIik7XFxuICAgICAgICAgICAgcmVmcmVzaFZpZGVvVXJsKHtcXG4gICAgICAgICAgICAgICAgZGFubXU6IGRtXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WKoOi9veWujOaIkFxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHJldHVybiAkKGtleSwgXFxcImRt55uS5a2Q5pCc57SiXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5LiL6L295a6M5oiQ5by55bmV5ZCO6K+36YeN5paw54K55Ye75pCc57SiXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9zZWFyY2g/cnVsZT1kbeebkuWtkCZzPVxcXCIgKyBpbnB1dDtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfSwga2V5LCBvbmx5RG93bmxvYWQpLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCJcXG59KTtcXG5cXG5mdW5jdGlvbiBzZWFyY2goZCwgbmFtZSkge1xcbiAgICBjb25zdCBkYW5tdSA9ICQucmVxdWlyZShcXFwiZGFubXVcXFwiKTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIlxcbiAgICB9KTtcXG4gICAgbGV0IGRtTGlzdCA9IGRhbm11LmdldERhbk11KG5hbWUpO1xcblxcbiAgICBmb3IgKGxldCBhbmltZSBvZiBkbUxpc3QuYW5pbWVzKSB7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiBhbmltZS5hbmltZVRpdGxlLFxcbiAgICAgICAgICAgIGRlc2M6IGFuaW1lLnR5cGVEZXNjcmlwdGlvbixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCIsXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCJcXFwiLCBcXFwi6K+36L6T5YWl5LiL6L296IyD5Zu0KDEsXFxcIiArIGFuaW1lLmVwaXNvZGVzLmxlbmd0aCArIFxcXCIpXFxcIikuaW5wdXQoKGFuaW1lVGl0bGUsIGVwaXNvZGVzKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBbYSwgYl0gPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgICAgICAgICAgYSA9IE51bWJlcihhKSwgYiA9IE51bWJlcihiKTtcXG4gICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihhKSB8fCBOdW1iZXIuaXNOYU4oYikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/or7fmjInmoLzlvI/ovpPlhaXmlbDlrZdcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChhIDwgMSB8fCBiID4gZXBpc29kZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl6KeE5a6a6IyD5Zu05YaF55qE5pWw5a2XXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjb25zdCBkYW5tdSA9ICQucmVxdWlyZShcXFwiZGFubXVcXFwiKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSBhIC0gMSwgaiA9IDE7IGkgPCBiOyBpKyssIGorKykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlcGlzb2RlID0gZXBpc29kZXNbaV07XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRtVGl0bGUgPSBhbmltZVRpdGxlICsgXFxcIl9cXFwiICsgZXBpc29kZS5lcGlzb2RlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOS4i+i9ve+8mlxcXCIgKyBlcGlzb2RlLmVwaXNvZGVUaXRsZSArIFxcXCJcXFxcdChcXFwiICsgaiArIFxcXCIvXFxcIiArIChiIC0gYSArIDEpICsgXFxcIilcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkYW5tdS5kb3dubG9hZERhbk11KGVwaXNvZGUuZXBpc29kZUlkLCBkbVRpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WTpuWTpuS4i+i9veWksei0pS4uLlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4i+i9veWujOaIkFxcXCI7XFxuICAgICAgICAgICAgfSwgYW5pbWUuYW5pbWVUaXRsZSwgYW5pbWUuZXBpc29kZXMpLFxcbiAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21vdmllLzE0LnN2Z1xcXCJcXG4gICAgICAgIH0pO1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgICAgICB9KTtcXG4gICAgICAgIGZvciAobGV0IGVwaXNvZGUgb2YgYW5pbWUuZXBpc29kZXMpIHtcXG4gICAgICAgICAgICBsZXQgZG1UaXRsZSA9IGFuaW1lLmFuaW1lVGl0bGUgKyBcXFwiX1xcXCIgKyBlcGlzb2RlLmVwaXNvZGVUaXRsZTtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogZXBpc29kZS5lcGlzb2RlVGl0bGUsXFxuICAgICAgICAgICAgICAgIHVybDogJChlcGlzb2RlLmVwaXNvZGVJZCkubGF6eVJ1bGUoKHVybCwgdGl0bGUsIG9ubHlEb3dubG9hZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGFubXUgPSAkLnJlcXVpcmUoXFxcImRhbm11XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IGRhbm11LmdldExvY2FsRGFuTXUoaW5wdXQsIHRpdGxlKSB8fCBkYW5tdS5kb3dubG9hZERhbk11KGlucHV0LCB0aXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAob25seURvd25sb2FkKSByZXR1cm4gXFxcInRvYXN0Oi8v5LiL6L295a6M5oiQXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkYW5tdVRleHQgPSBmZXRjaChwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZGFubXVUZXh0KSByZXR1cm4gXFxcInRvYXN0Oi8v6L+Y5rKh5pyJ5by55bmV5ZOfflxcXCI7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoVmlkZW9Vcmwoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhbm11OiBwYXRoXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WKoOi9veWujOaIkFxcXCI7XFxuICAgICAgICAgICAgICAgIH0sIE1ZX1BBUkFNUy5kdXJsLCBkbVRpdGxlLCBvbmx5RG93bmxvYWQpLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLlvLrliLbkuIvovb1cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChlcGlzb2RlVGl0bGUsIGVwaXNvZGVJZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi6K+3562J5b6FXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhbm11ID0gJC5yZXF1aXJlKFxcXCJkYW5tdVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYW5tdS5kb3dubG9hZERhbk11KGVwaXNvZGVJZCwgZXBpc29kZVRpdGxlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+mHjeaWsOS4i+i9veWujOaIkO+8jOWNleWHu+aMgui9veOAglxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgZG1UaXRsZSwgZXBpc29kZS5lcGlzb2RlSWQpXFxuICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZV9ibGFua1xcXCJcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIGlmICghZG1MaXN0LmFuaW1lcy5sZW5ndGgpIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmsqHmnInmib7liLDkuI5bXFxcIiArIG5h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FxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGlmIChyZWFsdXJsLmluY2x1ZGVzKFxcXCJjb20vcy9cXFwiKSAmJiByZWFsdXJsICE9IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBzaGFyZUlkID0gcmVhbHVybC5zcGxpdChcXFwiP1xcXCIpWzBdLnNwbGl0KFxcXCIvXFxcIilbNF07XFxuICAgICAgICAgICAgICAgIGxldCBzaGFyZSA9IGZldGNoKFxcXCJodHRwczovL2FwaS5hbGl5dW5kcml2ZS5jb20vYWRyaXZlL3YzL3NoYXJlX2xpbmsvZ2V0X3NoYXJlX2J5X2Fub255bW91c1xcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAnY29udGVudC10eXBlJzogJ2FwcGxpY2F0aW9uL2pzb24nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJVc2VyLUFnZW50XFxcIjogUENfVUEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcInNoYXJlX2lkXFxcIjogc2hhcmVJZFxcbiAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBpZiAoc2hhcmUuaW5jbHVkZXMoXFxcInNoYXJlX2xpbmsgaXNcXFwiKSB8fCBzaGFyZS5pbmNsdWRlcyhcXFwic2hhcmVfbGluayBjYW5ub3RcXFwiKSkgcmV0dXJuIGZhbHNlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0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yeSNcXFwiKX08L2E+KDxzbWFsbD7ngrnlh7vlj6/ov5vlhaXmjZDotaDvvIzlj6/lnKjkuLvpobXoj5zljZXov5vlhaU8L3NtYWxsPinjgIJcXG4gICAgMy4g5pys5bCP56iL5bqP5piv5Zyo5Y6f54mI44CM5LqR55uY5ZCb44CN55qE5Z+656GA6L+b6KGM55qE5LqM5qyh5L+u5pS577yM6K+35pSv5oyB5Y6f54mI44CCXFxuICAgIDQuIOivt+OAjOS6keebmOWQmy7nroDjgI3nmoTkuozmrKHkv67mlLnlsIrph43kuIDkuIvljp/niYjvvIzosKLosKLjgIJcXG4gICAgXFxuICAgIDxiPuW8gOWni+S9v+eUqOacrOinhOWImeWNs+S7o+ihqOmBteWuiOinhOWImeadoeS+izwvYj5cXG4gICAg5b2T5YmN54mI5pys77yaJHtNWV9SVUxFLnZlcnNpb259XFxuICAgIOWmguaenOS9oOaDs+S/neaMgeacgOaWsOeJiOivtyR7XFxcIuiuoumYheatpOinhOWImVxcXCIubGluayhcXFwicnVsZTovL1xcXCIgKyBiYXNlNjRFbmNvZGUoc3ViUGFzcykpfVxcbiAgICBgO1xcbiAgICBsZXQgdXBkYXRlSW5mbyA9IFxcXCLlop7liqDpg6jliIborr7nva5cXFwiO1xcbiAgICBcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc4oCd4oCdPHN0cm9uZz7kvb/nlKjliY3pobvnn6U8L3N0cm9uZz5cXFwiLmJpZygpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogY29udGVudC50cmltKCkucmVwbGFjZSgvXFxcXG5cXFxccyo/L2csIFxcXCI8YnI+XFxcIiksXFxuICAgICAgICBcXFwiY29sX3R5cGVcXFwiOiBcXFwicmljaF90ZXh0XFxcIlxcbiAgICB9LCB7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiB0aW1lICsgXFxcIuenkuWQjue7p+e7rVxcXCIsXFxuICAgICAgICB1cmw6IFxcXCJ0b2FzdDovL+ivt+iupOecn+mYheivu+S7peS4iuWGheWuuVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwidGltZXJcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBpZiAodXBkYXRlSW5mbykge1xcbiAgICAgICAgY29uZmlybSh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmm7TmlrDlhoXlrrlcXFwiLFxcbiAgICAgICAgICAgIGNvbnRlbnQ6IHVwZGF0ZUluZm8sXFxuICAgICAgICAgICAgY29uZmlybSgpe30sXFxuICAgICAgICAgICAgY2FuY2VsKCl7fVxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgc2V0UmVzdWx0KGQpO1xcbiAgICB3aGlsZSAodGltZSAhPSAwKSB7XFxuICAgICAgICBqYXZhLmxhbmcuVGhyZWFkLnNsZWVwKDEwMDApO1xcbiAgICAgICAgdGltZSAtPSAxO1xcbiAgICAgICAgdXBkYXRlSXRlbShpZCArIFxcXCJ0aW1lclxcXCIsIHtcXG4gICAgICAgICAgICB0aXRsZTogdGltZSArIFxcXCLnp5LlkI7nu6fnu61cXFwiXFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICB1cGRhdGVJdGVtKGlkICsgXFxcInRpbWVyXFxcIiwge1xcbiAgICAgICAgdGl0bGU6IFxcXCLigJzigJzmiJHlkIzmhI/ku6Xku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V4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlcykpO1xcbiAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChsZW5ndGgsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzkupHnroDmkJzntKLlvJXmk47vvIzlhbHjgIxcXFwiICsgbGVuZ3RoICsgXFxcIuOAjeadoe+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKGdldFBhc3RlcygpLmluY2x1ZGVzKGlucHV0KSkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGVzLmxlbmd0aCwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvcnVsZXMvTG95RGdJay9zaGFyZS/kupHnroDmkJzntKLlvJXmk47op4TliJnjgIxcXFwiICsgcnVsZXMubGVuZ3RoICsgXFxcIuOAjeadoS5cXFwiICsgKGlucHV0ID09PSBcXFwiSElLRVJcXFwiID8gXFxcImhpa2VyXFxcIiA6IFxcXCJ0eHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCBnZXRQYXNzKHJ1bGVzLmxlbmd0aCwgcnVsZWI2NCwgXFxcImFcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInNoYXJlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJ1bGVzO1xcbiAgICAgICAgICAgIGlmIChtbyA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTIpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRVc2VmdWxKc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTMpIHtcXG4gICAgICAgICAgICAgICAgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRGb3JiaWRkZW5Kc29uKCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChtbyA9PT0gLTQpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gZXh0O1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEdyb3VwSnNvbihleHQpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGVzLmxlbmd0aCkgcmV0d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jb25maXJtKChzdGFydCwgbnVtYmVyKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2Uoc3RhcnQsIG51bWJlcik7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIHN0YXJ0LCBudW1iZXIpO1xcbiAgICAgICAgICAgIH0sIGxlbmd0aCk7XFxuICAgICAgICB9XFxuICAgIH0sIGdyb3VwLCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxufSk7XFxuZm9yIChsZXQgaXQgb2YgZ3JvdXBzKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogaXQgPT09IGdyb3VwID8gXFxcIuKAnOKAnFxcXCIgKyBpdCArIFxcXCLigJ3igJ1cXFwiIDogaXQsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGl0LCBncm91cCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChncm91cCAhPT0gaXQpIHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwicnVsZU1hbmFnZV9ncm91cFxcXCIsIGl0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChbXFxcIue9rumhtlxcXCIsIFxcXCLnva7lupVcXFwiLCBcXFwi5pS55ZCNXFxcIiwgXFxcIuWIoOmZpFxcXCJdKS5zZWxlY3QoKGl0KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoXFxcIuaUueWQjVxcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoaXQsIFxcXCLor7fovpPlhaXmlrDlkI3np7BcXFwiKS5pbnB1dCgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcy5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ID09PSB2Lmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdi5ncm91cCA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVNYW5hZ2VfZ3JvdXBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoXFxcIuWIoOmZpFxcXCIgPT09IGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuaYr+WQpuWIoOmZpOivpee7hOaQnOe0ouW8leaTju+8mlxcXCIgKyBpdCkuY29uZmlybSgoaXQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlcyA9IHJ1bGVzLmZpbHRlcih2ID0+IHYuZ3JvdXAgIT09IGl0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInJ1bGVNYW5hZ2VfZ3JvdXBcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGl0KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB0Z1J1bGVzID0gW10sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdHhSdWxlcyA9IFtdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuZm9yRWFjaCgodikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdCA9PT0gdi5ncm91cCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0Z1J1bGVzLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHhSdWxlcy5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICA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KVtpbmRleF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlLnVzZXIgPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBydWxlLmZvcmJpZGRlbiA9IHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlYjY0ID0gYmFzZTY0RW5jb2RlKEpTT04uc3RyaW5naWZ5KHJ1bGUpKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBnZXRQYXNzID0gKG5hbWUsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzvvIzjgIxcXFwiICsgbmFtZSArIFxcXCLjgI3kupHnroDmkJzntKLlvJXmk47vvIzlpI3liLbmlbTmnaHlj6Pku6TmiZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHJ1bGUgKyBcXFwiJFxcXCIgKyB0eXBlICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT0gXFxcIuWujOaVtOWPo+S7pFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHJ1bGViNjQsIFxcXCJhXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGlmIChncm91cCkge1xcbiAgICAgICAgICAgICAgICAgICAgbmV3SW5kZXggPSBydWxlcy5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgICAgICBuZXdJbmRleCA9IG5ld0luZGV4ID09PSAtMSA/IDAgOiBuZXdJbmRleDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3suWIoOmZpFxcXCIgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV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cInBzX3J1bGVUeXBlXFxcIiwgXFxcIlxcXCIpLFxcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeinhOWImVxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge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AgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouYWNjb3VudCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogXFxcInBhc3N3b3JkXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19wYXNzd29yZFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5wYXNzd29yZCxcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgZC5wdXNoKHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIumineWkllxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHR5cGU6IFxcXCJ0ZXh0YXJlYVxcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicHNfZXh0cmFcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBvYmouZXh0cmEsXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICBoZWlnaHQ6IC0xXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgIGxldCBhY2NvdW50ID0gZ2V0TXlWYXIoXFxcInBzX2FjY291bnRcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgbGV0IHBhc3N3b3JkID0gZ2V0TXlWYXIoXFxcInBzX3Bhc3N3b3JkXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCBleHRyYSA9IGdldE15VmFyKFxcXCJwc19leHRyYVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAvKmlmICghKGFjY291bnR8fHBhc3N3b3JkfHxleHRyYSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveWFqOmDqOS4uuepulxcXCI7XFxuICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICBsZXQgaXRlbSA9IGFycltpbmRleF07XFxuICAgICAgICAgICAgaXRlbS51c2VyID0ge307XFxuICAgICAgICAgICAgaXRlbS51c2VyLmFjY291bnQgPSBhY2NvdW50XFxuICAgICAgICAgICAgaXRlbS51c2VyLnBhc3N3b3JkID0gcGFzc3dvcmQ7XFxuICAgICAgICAgICAgaXRlbS51c2VyLmV4dHJhID0gZXh0cmE7XFxuICAgICAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9pZOmUmeivr1xcXCI7XFxuIC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1xcbiAgICAgICAgfVxcbiAgICAgICAgLy9ydWxlcy5yZXZlcnNlKCk7XFxuICAgICAgICBNWV9VUkwgPSBtb2R1bGUuaWQ7XFxuICAgICAgICBsZXQgcnVsZVRpdGxlID0gZ2V0UGFyYW0oXFxcInJ1bGVcXFwiKTtcXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgbmV3SSA9IDA7XFxuICAgICAgICBmb3IgKGxldCBydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydWxlcy5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5paw5aKe77yaXFxcIiArIG5ld0kgKyBcXFwiIOimhuebluabtOaWsO+8mlxcXCIgKyAocnVsZXMubGVuZ3RoIC0gbmV3SSkpO1xcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIHRvYXN0KFxcXCLlr7zlhaXlpLHotKVcXFwiKTtcXG4gICAgfVxcbn1cIn0se1wiY29sX3R5cGVcIjpc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BsaXN0KSB7XFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IHBkZmgoaXRlbSwgXFxcImEmJlRleHRcXFwiKS5yZXBsYWNlKFxcXCIj5paH5Lu25aS5IFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgLy9sZXQgdGltZSA9IC9cXFxcZHs0fSgtXFxcXGR7Mn0pezJ9IFxcXFxkezJ9KFxcXFw6XFxcXGR7Mn0pezJ9Ly5leGVjKHBkZmgoaXRlbSwgXFxcIi5sYXl1aS1jYXJkLWJvZHkmJlRleHRcXFwiKSkgfHwgW107XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAvL2Rlc2M6IHRpbWVbMF0sXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGJhc2U2NERlY29kZShwZGZoKGl0ZW0sIFxcXCJhJiZ1cmxcXFwiKSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi5re35ZCI55uYXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsID0gXFxcImh0dHBzOi8vYXBpLmh1bmhlcGFuLmNvbS92MS9zZWFyY2hcXFwiO1xcbiAgICAgICAgICAgIGxldCBqc29uID0gcG9zdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgUmVmZXJlcjogXFxcImh0dHBzOi8vaHVuaGVwYW4uY29tL1xcXCJcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgXFxcInFcXFwiOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VcXFwiOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInNpemVcXFwiOiAxNVxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGpzb24gPSBKU09OLnBhcnNlKGpzb24pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5kYXRhLmxpc3Q7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gbGlzdFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGl0LmRpc2tfdHlwZSAhPT0gXFxcIkFMWVxcXCIgfHwgaXQuc2hhcmVfdXNlciA9PT0gXFxcIuS4tioqKuS4tlxcXCIpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LmRpc2tfbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHBkKGl0LCBcXFwiaW1nJiZzcmNcXFwiLCB1cmwpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpdC5saW5rLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQudXBkYXRlX3RpbWUgKyBcXFwiXFxcXG5cXFwiICsgaXQubGluayxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi6LWE5rqQ5biuXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBmdW5j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ZW1zLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGl0ZW1zW2ldO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSBpdGVtLmNvbnRlbnQgfHwgW107XFxuICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudC5sZW5ndGggPT0gMCB8fCAhaXRlbS5wYWdlX3VybCkgY29udGludWU7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdXJsID0gZGVfYWVzKGl0ZW0ucGFnZV91cmwpIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF1cmwpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICAgICAgcnRuTGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogKGl0ZW0udGl0bGUubGVuZ3RoID4gMzAgPyBpdGVtLnRpdGxlLnNsaWNlKDAsIDI3KSArIFxcXCIuLi5cXFwiIDogaXRlbS50aXRsZSkgfHwgXFxcIlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIuWIhuS6q+aXtumXtO+8mlxcXCIgKyBpdGVtLmluc2VydF90aW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogdXJsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICByZXR1cm4gcnRuTGlzdDtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJhdGVSYW5kb21IZXhTdHJpbmcobGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgY29uc3QgY2hhcmFjdGVycyA9IFxcXCIwMTIzNDU2Nzg5YWJjZGVmXFxcIjtcXG4gICAgICAgICAgICAgICAgY29uc3QgY2hhcmFjdGVyc0xlbmd0aCA9IGNoYXJhY3RlcnMubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gY2hhcmFjdGVycy5jaGFyQXQoTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogY2hhcmFjdGVyc0xlbmd0aCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGVuX2FlcyhlKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gXFxcInFxMTkyMDUyMDQ2MHFxenpcXFwiO1xcbiAgICAgICAgICAgICAgICAvLyBlbl9hZXNcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGkpO1xcbiAgICAgICAgICAgICAgICB2YXIgdCA9IENyeXB0b0pTLmVuYy5VdGY4LnBhcnNlKGUpLFxcbiAgICAgICAgICAgICAgICAgICAgciA9IENyeXB0b0pTLkFFUy5lbmNyeXB0KHQsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHIuY2lwaGVydGV4dC50b1N0cmluZygpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBmdW5jdGlvbiBkZV9hZXModnYpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBcXFwicXExOTIwNTIwNDYwcXF6elxcXCI7XFxuICAgICAgICAgICAgICAgIC8vIGRlX2Flc1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoaSk7XFxuICAgICAgICAgICAgICAgIGxldCBoZXhWYWwgPSBDcnlwdG9KUy5lbmMuSGV4LnBhcnNlKHZ2KSxcXG4gICAgICAgICAgICAgICAgICAgIHZhbCA9IENyeXB0b0pTLmVuYy5CYXNlNjQuc3RyaW5naWZ5KGhleFZhbCksXFxuICAgICAgICAgICAgICAgICAgICBkZWNyeXB0ZWQgPSBDcnlwdG9KUy5BRVMuZGVjcnlwdCh2YWwsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5DQkMsXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGRlY3J5cHRlZC50b1N0cmluZyhDcnlwdG9KUy5lbmMuVXRmOCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBzZWFyY2goKTtcXG4gICAgICAgIH1cXG4gICAgfSwge1xcbiAgICAgICAgbmFtZTogXFxcIuS6keebmOi1hOa6kFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9yZXMueXVucGFuLndpbi8/UGFnZUluZGV4PVxcXCIgKyBwYWdlICsgXFxcIiZQYWdlU2l6ZT0xMiZLZXl3b3JkPVxcXCIgKyBzICsgXFxcIiZUeXBlPSZUYWc9XFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vcmVzLnl1bnBhbi53aW4vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIm1haW4mJi5jYXJkXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZGZoKGl0LCBcXFwiLmNhcmQtbGluaywxJiZvbmNsaWNrXFxcIikubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgICAgIHUgPSB1Lmxlbmd0aCA+IDAgPyB1WzBdIDogdXJsO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgoaXQsIFxcXCIuY2FyZC10aXRsZSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogcGQoaXQsIFxcXCJpbWcmJnNyY1xcXCIsIHVybCksXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBwZGZoKGl0LCBcXFwiLmNhcmQtdGV4dCwtMSYmVGV4dFxcXCIpICsgXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIlVQ5LqR5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2FwaS51cHl1bnNvMi5jb20vc2VhcmNoP2tleXdvcmQ9XFxcIiArIHMgKyBcXFwiJnBhZ2U9XFxcIiArIHBhZ2UgKyBcXFwiJnNfdHlwZT0xXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8vd3d3LnVweXVuc28uY29tXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJDb29raWVcXFwiOiBcXFwiY29kZT0xOTE5XFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgLy9sb2coYmFzZTY0RGVjb2RlKGh0bWwpKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gSlNPTi5wYXJzZShiYXNlNjREZWNvZGUoaHRtbCkpLnJlc3VsdC5pdGVtcztcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgaWYgKCFhcnIpIHJldHVybiBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gaXQucGFnZV91cmw7XFxuICAgICAgICAgICAgICAgIC8vdSA9IHUubGVuZ3RoID4gMCA/IHVbMF0gOiB1cmw7XFxuICAgICAgICAgICAgICAgIGlmICghdS5pbmNsdWRlcyhcXFwiYWxpeXVuZHJpdmVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCJcXFxcblxcXCIgKyAodSksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIueMq+eLuOebmOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb20vc2VhcmNoP2s9XFxcIiArIHMsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cuYWxpcGFuc291LmNvbS9zZWFyY2g/az1cXFwiICsgc1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBkZmEoaHRtbCwgXFxcIiNhcHAmJmFcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhhcnIpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gXFxcIjxkaXY+XFxcIiArIGFycltpXSArIFxcXCI8L2Rpdj5cXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IHBkZmgoaXQsIFxcXCJhJiZocmVmXFxcIik7XFxuICAgICAgICAgICAgICAgIC8vbG9nKHUpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXUuaW5jbHVkZXMoXFxcIi9zL1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB1ID0gXFxcImh0dHBzOi8vd3d3LmFsaXBhbnNvdS5jb21cXFwiICsgdS5yZXBsYWNlKFxcXCIvcy9cXFwiLCBcXFwiL2N2L1xcXCIpO1xcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgoaXQsIFxcXCJ0ZW1wbGF0ZSYmVGV4dFxcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGRmaChpdCwgXFxcInRlbXBsYXRlLDEmJlRleHRcXFwiKSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoaW5wdXQsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIkNvb2tpZVxcXCI6IFxcXCJub19zaG93X2RvbmF0ZT0xXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogaW5wdXQucmVwbGFjZShcXFwiL2N2L1xcXCIsIFxcXCIvcy9cXFwiKVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICByZWRpcmVjdDogZmFsc2VcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBodG1sID0gcGFyc2VEb21Gb3JIdG1sKGh0bWwsICdhJiZocmVmJyk7XFxuICAgICAgICAgICAgaWYgKGh0bWwubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaHRtbDtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5wdXQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5piT5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICByZWdpc3RlclVybDogXFxcImh0dHBzOi8veWlzby5mdW5cXFwiLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgbGV0IENyeXB0b0pTID0gYWxpVXRpbC5nZXRDcnlwdG9KUygpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGtleWVuKHN0cikge1xcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjRPVG9TY1VGT2FlVlRySEVcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIGl2ID0gQ3J5cHRvSlMuZW5jLlV0ZjgucGFyc2UoXFxcIjlDTEdhbzF2SEtxbTE3T3pcXFwiKTtcXG4gICAgICAgICAgICAgICAgdmFyIGVuY3J5cHRlZCA9IENyeXB0b0pTLkFFUy5kZWNyeXB0KHtcXG4gICAgICAgICAgICAgICAgICAgIGNpcGhlcnRleHQ6IENyeXB0b0pTLmVuYy5CYXNlNjQucGFyc2Uoc3RyKVxcbiAgICAgICAgICAgICAgICB9LCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIGl2OiBpdixcXG4gICAgICAgICAgICAgICAgICAgIG1vZGU6IENyeXB0b0pTLm1vZGUuQ0JDLFxcbiAgICAgICAgICAgICAgICAgICAgcGFkZGluZzogQ3J5cHRvSlMucGFkLlBrY3M3XFxuICAgICAgICAgICAgICAgIH0pLnRvU3RyaW5nKENyeXB0b0pTLmVuYy5VdGY4KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGVuY3J5cHRlZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3lpc28uZnVuL2FwaS9zZWFyY2g/bmFtZT1cXFwiICsgcyArIFxcXCImcGFnZU5vPVxcXCIgKyBwYWdlLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8veWlzby5mdW4vaW5mbz9zZWFyY2hLZXk9XFxcIiArIHMsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogZ2V0SXRlbSgneWlzb3Vjb29rZScsICcnKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgLy9sb2coaHRtbCk7XFxuICAgICAgICAgICAgaWYgKGh0bWwuaW5jbHVkZXMoJ+eZu+W9leeUqOaIt+aXoOmZkOWIticpKSB7XFxuICAgICAgICAgICAgICAgIHZhciBpID0gMDtcXG4gICAgICAgICAgICAgICAgZG8ge1xcbiAgICAgICAgICAgICAgICAgICAgdmFyIHR5aW1nbGluID0gJ2h0dHBzOi8veWlzby5mdW4vYXBpL3VzZXIvbG9naW4vY2FwdGNoYT90PScgKyBwYXJzZUludChuZXcgRGF0ZSgpLmdldFRpbWUoKSkgKyAnJztcXG4gICAgICAgICAgICAgICAgICAgIGxldCBpbWcgPSBjb252ZXJ0QmFzZTY0SW1hZ2UodHlpbWdsaW4pLnNwbGl0KCcsJylbMV07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29kID0gcmVxdWVzdCgnaHR0cHM6Ly9hcGkueGhvZmUudG9wL29jci9iNjQvdGV4dCcsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb250ZW50LVR5cGUnOiAndGV4dC9wbGFpbidcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvZHk6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRob2Q6ICdQT1NUJ1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgdmVyID0gSlNPTi5wYXJzZShyZXF1ZXN0KCdodHRwczovL3lpc28uZnVuL2FwaS91c2VyL2xvZ2luJywge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2NvbnRlbnQtdHlwZSc6ICdhcHBsaWNhdGlvbi9qc29uJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJ3JlZmVyZXInOiAnaHR0cHM6Ly95aXNvLmZ1bi9sb2dpbicsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb29raWUnOiBnZXRDb29raWUodHlpbWdsaW4pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBib2R5OiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJ1c2VyTmFtZVxcXCI6IHVzZXIuYWNjb3VudCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcInBhc3N3b3JkXFxcIjogdXNlci5wYXNzd29yZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcImNvZGVcXFwiOiBjb2RcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodmVyLmNvZGUgPT0gMjAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9nKCfmmJPmkJznmbvlhaXpqozor4HmiJDlip8nKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKCd5aXNvdWNvb2tlJywgZ2V0Q29va2llKCdodHRwczovL3lpc28uZnVuJykpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwgPSByZXF1ZXN0KFxcXCJodHRwczovL3lpc28uZnVuL2FwaS9zZWFyY2g/bmFtZT1cXFwiICsgcyArIFxcXCImcGFnZU5vPVxcXCIgKyBwYWdlLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogXFxcImh0dHBzOi8veWlzby5mdW4vaW5mbz9zZWFyY2hLZXk9XFxcIiArIHMsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiQ29va2llXFxcIjogZ2V0SXRlbSgneWlzb3Vjb29rZScsICcnKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpKys7XFxuICAgICAgICAgICAgICAgIH0gd2hpbGUgKGkgPCA0KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoaHRtbCkuZGF0YS5saXN0O1xcbiAgICAgICAgICAgIC8vbG9nKGFycik7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBhcnJbaV07XFxuICAgICAgICAgICAgICAgIGxldCB1ID0ga2V5ZW4oaXQudXJsKTtcXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGlmICh1ID09IG51bGwgfHwgIXUuaW5jbHVkZXMoXFxcImFsaXl1blxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiAoaXQuZ210U2hhcmUgfHwgaXQuZ210Q3JlYXRlKSArIFxcXCJcXFxcblxcXCIgKyAodSksXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuWwj+e6uOadoVxcXCIsXFxuICAgICAgICBwYWdlOiBmYWxzZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgYWxpVXRpbCA9ICQucmVxdWlyZShcXFwiYWxpVXRpbFxcXCIpO1xcblxcbiAgICAgICAgICAgIGZ1bmN0aW9uIGdldHRva2VuKCkge1xcbiAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoJ3h6eXRva2VuJywgJycpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdG9rZW4gPSBKU09OLnBhcnNlKHBvc3QoJ2h0dHBzOi8vZ2l0Y2FmZS5uZXQvdG9vbC9hbGlwYXBlci8nLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3UuZ2l0Y2FmZS5pbmsvJ1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246ICdnZXRfdG9rZW4nXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSkpLmRhdGE7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcigneHp0dG9rZW4nLCB0b2tlbik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIGdldE15VmFyKCd4enR0b2tlbicsICcnKTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gY2F0X2NvZGUoYSkge1xcbiAgICAgICAgICAgICAgICB2YXIgZCwgZSwgYiA9IFtcXFwi5Y2O6K+t55S16KeGXFxcIiwgXFxcIuaXpemfqeeUteinhlxcXCIsIFxcXCLmrKfnvo7nlLXop4ZcXFwiLCBcXFwi5YW25LuW55S16KeGXFxcIiwgXFxcIuWNjuivreeUteW9sVxcXCIsIFxcXCLml6Xpn6nnlLXlvbFcXFwiLCBcXFwi5qyn576O55S15b2xXFxcIiwgXFxcIuWFtuS7lueUteW9sVxcXCIsIFxcXCLljY7or63liqjmvKtcXFwiLCBcXFwi5pel6Z+p5Yqo5ryrXFxcIiwgXFxcIuasp+e+juWKqOa8q1xcXCIsIFxcXCLnuqrlvZXniYdcXFwiLCBcXFwi57u86Im654mHXFxcIiwgXFxcIuaVmeiCsuWfueiurVxcXCIsIFxcXCLlhbbku5bop4bpopFcXFwiLCBcXFwi5Y2O6K+t6Z+z5LmQXFxcIiwgXFxcIuaXpemfqemf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alxcXCIsIFxcXCJxdHRwXFxcIiwgXFxcInF0XFxcIl07XFxuICAgICAgICAgICAgICAgIGZvciAoZCA9IDAsIGUgPSBjLmxlbmd0aDsgZSA+IGQ7IGQrKylcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjW2RdID09IGEpIHJldHVybiBiW2RdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBodG1sID0gcG9zdChcXFwiaHR0cHM6Ly9naXRjYWZlLm5ldC90b29sL2FsaXBhcGVyL1xcXCIsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly91LmdpdGNhZmUuaW5rLydcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgYm9keToge1xcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiBcXFwic2VhcmNoXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGZyb206IFxcXCJ3ZWJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgdG9rZW46IGdldHRva2VuKCksXFxuICAgICAgICAgICAgICAgICAgICBrZXl3b3JkOiBzXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKTtcXG4gICAgICAgICAgICBpZiAobGlzdC5kYXRhKSB7XFxuICAgICAgICAgICAgICAgIGxpc3QgPSBsaXN0LmRhdGE7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldXFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0LnRpdGxlO1xcbiAgICAgICAgICAgICAgICBsZXQgbXVybCA9ICdodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vcy8nICsgaXQuYWxpa2V5XFxuICAgICAgICAgICAgICAgIGlmICghYWxpVXRpbC5jaGVja2FsaShtdXJsKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oiaIFxcXCIgKyB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBjYXRfY29kZShpdC5jYXQpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlczogaXQuZGVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IG11cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi546p5YG25ZOl5ZOlXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBiYXNpY1VybDogXFxcImh0dHA6Ly93b2dnLnh5elxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGJhc2ljVXJsICsgXFxcIi9pbmRleC5waHAvdm9kc2VhcmNoL1xcXCIgKyBzICsgXFxcIi0tLS0tLS0tLS1cXFwiICsgcGFnZSArIFxcXCItLS0uaHRtbFxcXCI7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgXFxcIi5tb2R1bGUtaXRlbXMmJi5tb2R1bGUtc2VhcmNoLWl0ZW1cXFwiKTtcXG5cXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGRmaChpdCwgXFxcImgzJiZhJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGRmaChpdCwgXFxcIi52aWRlby1zZXJpYWwmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpbWFnZSA9IHBkZmgoaXQsIFxcXCJpbWcmJmRhdGEtc3JjXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGQoaXQsIFxcXCJoMyYmYSYmaHJlZlxcXCIsIGJhc2ljVXJsKTtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHV0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdSxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IHVpbWFnZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IHVzZXJpYWxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJldHVybiBiZXQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIHJldHVybiBwZGZhKHJlcXVlc3QoaW5wdXQpLCBcXFwiYm9keSYmLm1vZHVsZS1yb3ctdGV4dC5jb3B5XFxcIikubWFwKHYgPT4gcGRmaCh2LCBcXFwiYSYmZGF0YS1jbGlwYm9hcmQtdGV4dFxcXCIpKTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIumYv+mHjOS6keebmOe9kVxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgYmFzaWNVcmw6IFxcXCJodHRwczovL3d3dy5hbHlwdy5jblxcXCIsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IGJhc2ljVXJsICsgXFxcIi9zZWFyY2gucGhwP3E9XFxcIiArIHMgKyBcXFwiJnBhZ2U9XFxcIiArIHBhZ2U7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge30pO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCIubGlzdCYmbGlcXFwiKTtcXG4gICAgICAgICAgICBsZXQgYmV0ID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdXRpdGxlID0gcGRmaChpdCwgXFxcImEmJnRpdGxlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGRmaChpdCwgXFxcIi5mYS1jbG9jay1vJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1hZ2UgPSBwZGZoKGl0LCBcXFwiaW1nJiZzcmNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCBiYXNpY1VybCk7XFxuICAgICAgICAgICAgICAgIGlmICghdXRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBiZXQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdXRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgcGljX3VybDogdWltYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogdXNlcmlhbFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHBkZmEocmVxdWVzdChpbnB1dCksIFxcXCJib2R5JiZhW2hyZWZePWh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL11cXFwiKS5tYXAodiA9PiBwZGZoKHYsIFxcXCJhJiZocmVmXFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5Zyf5ouo6bygXFxcIixcXG4gICAgICAgIHBhZ2U6IGZhbHNlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBodG1sID0gZmV0Y2goJ2h0dHBzOi8vd3d3LnRic2R5LmNvbS9zZWFyY2guaHRtbD9rZXl3b3JkPScgKyBzICsgJyZjYXRlZ29yeT05ODM5MjAmZGF0YV90eXBlPTk4NzkxMCcsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgICAgbGV0IGFyciA9IHBhcnNlRG9tRm9yQXJyYXkoaHRtbCwgJy5zZWFyY2hfcmVzdWx0X25ldGRpc2tfbGlzdCYmYScpO1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhpdCk7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnYSYmaHJlZicpO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0ID0gcGFyc2VEb21Gb3JIdG1sKGl0LCAnLm5ldGRpc2tfaXRlbV9kZXRhaWxfbmFtZSYmVGV4dCcpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXRpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgLy9sb2codSk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0LFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIumYv+mHjOaQnFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBkID0gW107XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KCdodHRwczovL2FsaXNvLmNjL3MvJyArIHMgKyAnLScgKyBwYWdlICsgJy0wLmh0bWwnLCB7fSk7XFxuXFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBwYXJzZURvbUZvckFycmF5KGh0bWwsICcuc2VhcmNoLXJlc3VsdCYmLnJlc291cmNlLWl0ZW0nKTtcXG4gICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGxpc3QubGVuZ3RoOyBqKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBsaXN0W2pdO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0ID0gcGFyc2VEb21Gb3JIdG1sKHUsICdoMyYmVGV4dCcpO1xcbiAgICAgICAgICAgICAgICBpZiAoIXRpdC5pbmNsdWRlcyhzKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXQsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHBhcnNlRG9tKHUsICdoMyYmYSYmaHJlZicsICdodHRwczovL2FsaXNvLmNjLycpLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGFyc2VEb21Gb3JIdG1sKHUsICcudGltZSYmVGV4dCcpLFxcbiAgICAgICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGQ7XFxuICAgICAgICB9LFxcbiAgICAgICAgZmluZEFsaVVybChpbnB1dCkge1xcbiAgICAgICAgICAgIGV2YWwoZ2V0Q3J5cHRvSlMoKSk7XFxuXFxuICAgICAgICAgICAgZnVuY3Rpb24gZGVjcnkoc3RyKSB7XFxuICAgICAgICAgICAgICAgIHZhciBrZXkgPSBDcnlwdG9KUy5lbmMuVXRmOC5wYXJzZShcXFwiOUVCMjBEREZENkFGQkQ2OFxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgZW5jcnlwdGVkID0gQ3J5cHRvSlMuQUVTLmRlY3J5cHQoc3RyLCBrZXksIHtcXG4gICAgICAgICAgICAgICAgICAgIGl2OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICBtb2RlOiBDc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VNEMTIzXFxcIik7XFxuICAgICAgICAgICAgICAgIHZhciBlbmNyeXB0ZWQgPSBDcnlwdG9KUy5BRVMuZGVjcnlwdChzdHIsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgbW9kZTogQ3J5cHRvSlMubW9kZS5FQ0IsXFxuICAgICAgICAgICAgICAgICAgICBwYWRkaW5nOiBDcnlwdG9KUy5wYWQuUGtjczdcXG4gICAgICAgICAgICAgICAgfSkudG9TdHJpbmcoQ3J5cHRvSlMuZW5jLlV0ZjgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gZW5jcnlwdGVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoXFxcImh0dHBzOi8vd3d3Lnl1bnBhbmZlbnhpYW5nLmNuL2FwaS9iYnMvYXBpL2dldGRhdGE/a2V5PVxcXCIgKyBzICsgXFxcIiZ0eXBlPXZpZGVvXFxcIiwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3d3dy55dW5wYW5mZW54aWFuZy5jbi9cXFwiXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBsZXQganNvbiA9IGRlY3J5KEpTT04ucGFyc2UoaHRtbCkuZGF0YSk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoanNvbik7XFxuXFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGl0LnBpZDtcXG4gICAgICAgICAgICAgICAgYmV0LnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vYXBpL2Jicy9hcGkvZ2V0YXJ0aWNsZT9pZD1cXFwiICsgdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGl0LnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQuY3JlYXRldGltZVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgcmV0dXJuIGJldDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QoaW5wdXQsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBcXFwiaHR0cHM6Ly93d3cueXVucGFuZmVueGlhbmcuY24vXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSkpLmRhdGE7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLmRvd25sb2FkLnNwbGl0KFxcXCJAXFxcIik7XFxuICAgICAgICAgICAgbGV0IGFsaXN0ID0gbmV3IFNldCgpO1xcbiAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgbGlzdC5sZW5ndGg7IGorKykge1xcbiAgICAgICAgICAgICAgICBhbGlzdC5hZGQoXFxcImh0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS9zL1xcXCIgKyBsaXN0W2pdKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIEFycmF5LmZyb20oYWxpc3QpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi55uY5pCcXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCB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vXFxcIiArIHBpY191cmwgOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogcGFyc2VEb21Gb3JIdG1sKGl0LCAncCYmVGV4dCcpICsgXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIkRPVljmkJxcXFwiLFxcbiAgICAgICAgcGFnZTogZmFsc2UsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL2FwaS5kb3Z4LnRrL2FsaS9zZWFyY2g/d2Q9XFxcIiArIHM7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCk7XFxuICAgICAgICAgICAgbGV0IGFyciA9IEpTT04ucGFyc2UoaHRtbCkubGlzdDtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBhbGlVdGlsID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIik7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBhcnIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ID0gYXJyW2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdSA9IGl0LnZvZF9jb250ZW50O1xcbiAgICAgICAgICAgICAgICBpZiAoIXUuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikgfHwgIWFsaVV0aWwuY2hlY2thbGkodSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKImiBcXFwiICsgaXQudm9kX25hbWUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogXFxcIlxcXFxuXFxcIiArIHUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogXFxcIuW/heW6lFxcXCIsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBcXFwiaHR0cHM6Ly9jbi5iaW5nLmNvbS9zZWFyY2g/cT1cXFwiICsgcyArIFxcXCIrYWxpeXVuZHJpdmUmcXM9ZHMmZm9ybT1RQlJFXFxcIjtcXG4gICAgICAgICAgICBpZiAocGFnZSAhPSAxKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IGdldE15VmFyKFxcXCJiaW5nXFxcIiwgdXJsKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSByZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL2NuLmJpbmcuY29tL1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAvL1xcXCJYLVJlcXVlc3RlZC1XaXRoXFxcIjogXFxcImNvbS5leGFtcGxlLmhpa2Vydmlld1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiQWNjZXB0XFxcIjogXFxcInRleHQvaHRtbCxhcHBsaWNhdGlvbi94aHRtbCt4bWwsYXBwbGljYXRpb24veG1sO3E9MC45LGltYWdlL2F2aWYsaW1hZ2Uvd2VicCxpbWFnZS9hcG5nLCovKjtxPTAuOCxhcHBsaWNhdGlvbi9zaWduZWQtZXhjaGFuZ2U7dj1iMztxPTAuOVxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBhcnIgPSBwZGZhKGh0bWwsIFxcXCJib2R5JiZhXFxcIik7XFxuICAgICAgICAgICAgLy9sb2coYXJyKTtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHUgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCB1cmwpO1xcbiAgICAgICAgICAgICAgICBsZXQgdCA9IHBkZmgoaXQsIFxcXCJhJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGlmIChpdC5pbmNsdWRlcyhcXFwiTmV4dCBwYWdlXFxcIikgfHwgaXQuaW5jbHVkZXMoXFxcIuS4i+S4gOmhtVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgdTIgPSBwZChpdCwgXFxcImEmJmhyZWZcXFwiLCB1cmwpO1xcbiAgICAgICAgICAgICAgICAgICAgLy9sb2coXFxcIm5leHQgcGFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy9sb2codTIpO1xcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcImJpbmdcXFwiLCB1Mik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHUgPT0gbnVsbCB8fCB0ID09IG51bGwgfHwgIWl0LmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAoIWl0LmluY2x1ZGVzKFxcXCLnvZHnm5hcXFwiKSAmJiAhaXQuaW5jbHVkZXMoXFxcIuS6keebmFxcXCIpICYmXFxuICAgICAgICAgICAgICAgICAgICAhaXQuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikgJiYgIWl0LmluY2x1ZGVzKFxcXCJ5dW5wYW5cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHUuc3RhcnRzV2l0aChcXFwiaHR0cHM6Ly9jbi5iaW5nLmNvbS9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGRvbSA9IGdldEhvbWUodSkucmVwbGFjZShcXFwiaHR0cDovL1xcXCIsIFxcXCJcXFwiKS5yZXBsYWNlKFxcXCJodHRwczovL1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IF9saW5rcyA9IHQubWF0Y2goL2h0dHBzOlxcXFwvXFxcXC8od3d3XFxcXC5hbGl5dW5kcml2ZVxcXFwuY29tXFxcXC9zfGFseXdwXFxcXC5uZXQpXFxcXC9cXFxcdyovZykgfHwgW107XFxuICAgICAgICAgICAgICAgIGxldCBjID0gbnVsbDtcXG4gICAgICAgICAgICAgICAgaWYgKF9saW5rcy5sZW5ndGggPiAxICYmIF9saW5rc1sxXS5yZXBsYWNlKF9saW5rc1swXSwgXFxcIlxcXCIpLnJlcGxhY2UoL1thLXpBLVowLTldKy9nLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIGMgPSBfbGlua3NbMV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoX2xpbmtzLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIGMgPSBfbGlua3NbMF07XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0LFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogZG9tLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBjICE9IG51bGwgPyBjIDogdSxcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui/m+WFpee9keermVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBKU09OLnN0cmluZ2lmeShcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQodSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBpZiAoaW5wdXQuaW5jbHVkZXMoXFxcImFsaXl1bmRyaXZlXFxcIikpIHJldHVybiBpbnB1dDtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoaW5wdXQpO1xcbiAgICAgICAgICAgIHZhciBfbGlua3MgPSBodG1sLm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgIGlmIChfbGlua3MubGVuZ3RoID4gMSAmJiBfbGlua3NbMV0ucmVwbGFjZShfbGlua3NbMF0sIFxcXCJcXFwiKS5yZXBsYWNlKC9bYS16QS1aMC05XSsvZywgXFxcIlxcXCIpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBfbGlua3NbMV07XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChfbGlua3MubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gX2xpbmtzWzBdO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogJ0NDT0YnLFxcbiAgICAgICAgcGFnZTogdHJ1ZSxcXG4gICAgICAgIGZpbmQ6IGZ1bmN0aW9uKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgZCA9IFtdXFxuICAgICAgICAgICAgbGV0IGFsaVV0aWwgPSAkLnJlcXVpcmUoXFxcImFsaVV0aWxcXFwiKTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IGZldGNoKCdodHRwczovL3Bhbi5jY29mLmNjL2FwaS9zZWFyY2gnLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb250ZW50LXR5cGVcXFwiOiAnYXBwbGljYXRpb24vanNvbicsXFxuICAgICAgICAgICAgICAgICAgICAnUmVmZXJlcic6ICdodHRwczovL3Bhbi5jY29mLmNjL3NlYXJjaD9rZXl3b3JkPScgKyBzXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIGJvZHk6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJwYWdlU2l6ZVxcXCI6IDIwLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInBhZ2VOdW1cXFwiOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcImtleXdvcmRcXFwiOiBzLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcImZyb21Nb2JpbGVcXFwiOiB0cnVlXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIG1ldGhvZDogJ1BPU1QnXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IEpTT04ucGFyc2UoaHRtbClcXG4gICAgICAgICAgICAgICAgLmRhdGEucm93c1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXQgPSBsaXN0W2ldO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSBpdC5maWxlTmFtZVxcbiAgICAgICAgICAgICAgICBsZXQgbXVybCA9IGl0LnVybFxcbiAgICAgICAgICAgICAgICBsZXQgdHlwZSA9IGl0LnR5cGUucmVwbGFjZSgvZm9sZGVyLywgJ+aWh+S7tuWkuScpLnJlcGxhY2UoL2ZpbGUvLCAn5paH5Lu2JylcXG4gICAgICAgICAgICAgICAgaWYgKHRpdGxlLmluY2x1ZGVzKHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjOiAn5paH5Lu257G75Z6L77yaJyArIHR5cGUgKyAn77yM5paH5Lu25aSn5bCP77yaJyArIGFsaVV0aWwuYnl0ZXNUb1NpemUoaXQuc2l6ZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBtdXJsXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkXFxuICAgICAgICB9XFxuICAgIH0sXFxuICAg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bCkuZGF0YTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxpc3QubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBsaXN0W2ldLmF0dHJpYnV0ZXM7XFxuICAgICAgICAgICAgICAgIGxldCB1cmwgPSBob21lICsgXFxcIi9kL1xcXCIgKyBpdGVtLnNsdWc7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXRlbS50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6ICflj5HluIPml7bpl7TvvJonICsgJC5kYXRlRm9ybWF0KG5ldyBEYXRlKGl0ZW0uY3JlYXRlZEF0KSwgXFxcInl5eXktTU0tZGQgSEg6bW06c3NcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogdXJsLFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L+b5YWl5biW5a2QXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UveXNmeD93ZWJVcmw9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudCh1cmwpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gZDtcXG4gICAgICAgIH0sXFxuICAgICAgICBmaW5kQWxpVXJsKGlucHV0KSB7XFxuICAgICAgICAgICAgbGV0IGh0bWwgPSBwZGZoKHJlcXVlc3QoaW5wdXQpLCBcXFwiVGV4dFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBfbGlua3MgPSBodG1sLm1hdGNoKC9odHRwczpcXFxcL1xcXFwvKHd3d1xcXFwuYWxpeXVuZHJpdmVcXFxcLmNvbVxcXFwvc3xhbHl3cFxcXFwubmV0KVxcXFwvXFxcXHcqL2cpIHx8IFtdO1xcbiAgICAgICAgICAgIGxldCBzaGFyZVB3ZCA9IGh0bWwubWF0Y2goL+aPkOWPlueggVs677yaXVxcXFxzKj8oXFxcXHd7NH0pLyk7XFxuICAgICAgICAgICAgc2hhcmVQd2QgPSBBcnJheS5pc0FycmF5KHNoYXJlUHdkKSAmJiBzaGFyZVB3ZC5sZW5ndGggPiAwID8gc2hhcmVQd2RbMV0gOiBcXFwiXFxcIjtcXG4gICAgICAgICAgICBpZiAoX2xpbmtzLmxlbmd0aCA+IDEgJiYgX2xpbmtzWzFdLnJlcGxhY2UoX2xpbmtzWzBdLCBcXFwiXFxcIikucmVwbGFjZSgvW2EtekEtWjAtOV0rL2csIFxcXCJcXFwiKSA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgYWxpVXJsOiBfbGlua3NbMV0sXFxuICAgICAgICAgICAgICAgICAgICBzaGFyZVB3ZDogc2hhcmVQd2RcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKF9saW5rcy5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBhbGlVcmw6IF9saW5rc1swXSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlUHdkOiBzaGFyZVB3ZFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3lzZng/d2ViVXJsPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQoaW5wdXQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAge1xcbiAgICAgICAgbmFtZTogJ+S6keebmOWIhuS6q+ekvuWMuicsXFxuICAgICAgICBwYWdlOiB0cnVlLFxcbiAgICAgICAgZmluZDogZnVuY3Rpb24ocywgcGFnZSkge1xcbiAgICAgICAgICAgIGxldCBob21lID0gXFxcImh0dHBzOi8veXVucGFuMS5jY1xcXCI7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QoYnVpbGRVcmwoaG9tZSArIFxcXCIvYXBpL2Rpc2N1c3Npb25zXFxcIiwge1xcbiAgICAgICAgICAgICAgICBcXFwiaW5jbHVkZVxcXCI6IFxcXCJ1c2VyLGxhc3RQb3N0ZWRVc2VyLG1vc3RSZWxldmFudFBvc3QsbW9zdFJlbGV2YW50UG9zdC51c2VyLHRhZ3MsdGFncy5wYXJlbnQsZmlyc3RQb3N0XFxcIixcXG4gICAgICAgICAgICAgICAgXFxcImZpbHRlcltxXVxcXCI6IHMgLyogKyBcXFwiIHRhZzp2aWRlbyxjb21pY1xcXCIqLyAsXFxuICAgICAgICAgICAgICAgIC8vXFxcImZpbHRlclt0YWddXFxcIjogXFxcInZpZGVvLGNvbWljXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcInBhZ2Vbb2Zmc2V0XVxcXCI6IDIwICogKHBhZ2UgLSAxKVxcbiAgICAgICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJjb250ZW50LXR5cGVcXFwiOiBcXFwiYXBwbGljYXRpb24vanNvblxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IFxcXCJodHRwczovL3BhbjY2Ni5uZXQvP3E9XFxcIiArIHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gSlNPTi5wYXJzZShodG1sKS5kYXRhO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IGxpc3RbaV0uYXR0cmlidXRlcztcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IGhvbWUgKyBcXFwiL2QvXFxcIiArIGl0ZW0uc2x1ZztcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogJ+WPkeW4g+aXtumXtO+8micgKyAkLmRhdGVGb3JtYXQobmV3IERhdGUoaXRlbS5jcmVhdGVkQXQpLCBcXFwieXl5eS1NTS1kZCBISDptbTpzc1xcXCIpLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLov5vlhaXluJblrZBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS95c2Z4P3dlYlVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KHVybCkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfV1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBkO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHBkZmgocmVxdWVzdChpbnB1dCksIFxcXCJUZXh0XFxcIik7XFxuICAgICAgICAgICAgbGV0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xcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBuYW1lOiBcXFwi54ix55yL576O5YmnXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kOiBmdW5jdGlvbihzLCBwYWdlKSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJodHRwczovL3d3dy4ya21qLmNuL3NlYXJjaC5waHA/cT1cXFwiICsgcyArIFxcXCImcGFnZS9cXFwiICsgcGFnZSArIFxcXCIvXFxcIjtcXG4gICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QodXJsKTtcXG4gICAgICAgICAgICBsZXQgYXJyID0gcGFyc2VEb21Gb3JBcnJheShodG1sLCBcXFwiLmxpc3QtaXQmJmxpXFxcIik7XFxuXFxuICAgICAgICAgICAgbGV0IGJldCA9IFtdO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpdCA9IGFycltpXTtcXG4gICAgICAgICAgICAgICAgbGV0IHV0aXRsZSA9IHBhcnNlRG9tRm9ySHRtbChpdCwgXFxcImEmJnRpdGxlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1c2VyaWFsID0gcGFyc2VEb21Gb3JIdG1sKGl0LCBcXFwiLmluZm8mJnNwYW46bm90KDpoYXMoYSkpLS1pJiZUZXh0XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1aW1hZ2UgPSBwYXJzZURvbShpdCwgXFxcImltZyYmc3JjXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB1ID0gcGFyc2VEb20oaXQsIFxcXCJhJiZocmVmXFxcIik7XFxuICAgICAgICAgICAgICAgIGJldC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiB1dGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHUsXFxuICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiB1aW1hZ2UsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiB1c2VyaWFsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICByZXR1cm4gYmV0O1xcblxcbiAgICAgICAgfSxcXG4gICAgICAgIGZpbmRBbGlVcmwoaW5wdXQpIHtcXG4gICAgICAgICAgICByZXR1cm4gcGRmYShyZXF1ZXN0KGlucHV0KSwgXFxcImJvZHkmJiNkb3dubG9hZFxcXCIpLm1hcCh2ID0+IHBkZmgodiwgXFxcIi5kb3duJiZocmVmXFxcIikpO1xcbiAgICAgICAgfVxcbiAgICB9LFxcbiAgICB7XFxuICAgICAgICBuYW1lOiBcXFwi5aWH5aaZ5pCc57SiXFxcIixcXG4gICAgICAgIHBhZ2U6IHRydWUsXFxuICAgICAgICBmaW5kKHMsIHBhZ2UpIHtcXG4gICAgICAgICAgICBsZXQgdXJsO1xcbiAgICAgICAgICAgIGlmIChwYWdlID09PSAxKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IGJ1aWxkVXJsKFxcXCJodHRwczovL3d3dy5tYWdpY2Fsc2VhcmNoLnRvcC9hcGkvcHNob3UvZ2V0RGF0YVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHdvcmQ6IHMsXFxuICAgICAgICAgICAgICAgICAgICB0eXBlOiBcXFwi6Zi/6YeM572R55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB1cmwgPSBidWlsZFVybChcXFwiaHR0cHM6Ly93d3cubWFnaWNhbHNlYXJjaC50b3AvYXBpL3BzaG91L2dldE5leHRQYWdlXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcXFwiaHR0cHM6Ly9hcGkudXB5dW5zbzIuY29tL3NlYXJjaD9zX3R5cGU9MkBwYWdlPVxcXCIgKyBwYWdlICsgXFxcIkBrZXl3b3JkPVxcXCIgKyBlbmNvZGVVUklDb21wb25lbnQocyksXFxuICAgICAgICAgICAgICAgICAgICB3ZWJzaXRlOiBcXFwi6Zi/6YeM572R55uYXFxcIlxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJlc3VsdCA9IHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgIFJlZmVyZXI6IGJ1aWxkVXJsKFxcXCJodHRwczovL3d3dy5tYWdpY2Fsc2VhcmNoLnRvcC9zZWFyY2hcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgd29yZDogcyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjcGFnZTogMFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJlc3VsdCA9IEpTT04ucGFyc2UoSlNPTi5wYXJzZShyZXN1bHQpKTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHJlc3VsdC5yZXN1bHQuaXRlbXM7XFxuICAgICAgICAgICAgbGV0IGQgPSBbXTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XFxuICAgICAgICAgICAgICAgIGlmIChpdC5pZCA9PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLml6XmnJ/vvJpcXFwiICsgaXQuaW5zZXJ0X3RpbWUgKyBcXFwiXFxcXG7ot6/lvoTvvJpcXFwiICsgaXQucGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogaXQucGFnZV91cmxcXG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1VuaXQgPSBmYWxzZTtcXG4gICAgbGV0IHN0ciA9IGNoblN0ci5zcGxpdCgnJyk7XFxuXFxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgc3RyLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICBsZXQgbnVtID0gY2huTnVtQ2hhcltzdHJbaV1dO1xcbiAgICAgICAgaWYgKHR5cGVvZiBudW0gIT09ICd1bmRlZmluZWQnKSB7XFxuICAgICAgICAgICAgbnVtYmVyID0gbnVtO1xcbiAgICAgICAgICAgIGlmIChpID09PSBzdHIubGVuZ3RoIC0gMSkge1xcbiAgICAgICAgICAgICAgICBzZWN0aW9uICs9IG51bWJlcjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCB1bml0ID0gY2huTmFtZVZhbHVlW3N0cltpXV0udmFsdWU7XFxuICAgICAgICAgICAgc2VjVW5pdCA9IGNobk5hbWVWYWx1ZVtzdHJbaV1dLnNlY1VuaXQ7XFxuICAgICAgICAgICAgaWYgKHNlY1VuaXQpIHtcXG4gICAgICAgICAgICAgICAgc2VjdGlvbiA9IChzZWN0aW9uICsgbnVtYmVyKSAqIHVuaXQ7XFxuICAgICAgICAgICAgICAgIHJ0biArPSBzZWN0aW9uO1xcbiAgICAgICAgICAgICAgICBzZWN0aW9uID0gMDtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBzZWN0aW9uICs9IChudW1iZXIgKiB1bml0KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbnVtYmVyID0gMDtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICByZXR1cm4gcnRuICsgc2VjdGlvbjtcXG59XFxuXFxuZnVuY3Rpb24gbmFtZUNvbXBhcmUoYSwgYikge1xcbiAgICBpZiAoYSA9PSBudWxsIHx8IGIgPT0gbnVsbClcXG4gICAgICAgIHJldHVybiBhID09IG51bGwgPyBiID09IG51bGwgPyAwIDogLTEg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V0aC5tZXNzZW5zZS5tZS9vYXV0aC9hY2Nlc3NfdG9rZW5cXFwiLCB7XFxuICAgICAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIFxcXCJncmFudF90eXBlXFxcIjogXFxcImF1dGhvcml6YXRpb25fY29kZVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBcXFwiY29kZVxcXCI6IGNvZGUsXFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGxldCBkYXRhID0gSlNPTi5wYXJzZShyZXMpO1xcbiAgICAgICAgICAgIHJldHVybiBkYXRhW1xcXCJyZWZyZXNoX3Rva2VuXFxcIl07XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcmVzID0gcG9zdChcXFwiaHR0cHM6Ly9hbGl5dW5kcml2ZS1vYXV0aC5tZXNzZW5zZS5tZS9vYXV0aC9hdXRob3JpemUvcXJjb2RlXFxcIiwge1xcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgXFxcInNjb3Blc1xcXCI6IFtcXFwidXNlcjpiYXNlXFxcIiwgXFxcImZpbGU6YWxsOnJlYWRcXFwiLCBcXFwiZmlsZTphbGw6d3JpdGVcXFwiXSxcXG4gICAgICAgICAgICAgICAgXFxcIndpZHRoXFxcIjogMzAwLFxcbiAgICAgICAgICAgICAgICBcXFwiaGVpZ2h0XFxcIjogMzAwLFxcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG4gICAgICAgIGxldCBzaWQgPSBkYXRhW1xcXCJzaWRcXFwiXTtcXG4gICAgICAgIGxldCBxcmNvZGVfdXJsID0gZGF0YVtcXFwicXJDb2RlVXJsXFxcIl07XFxuICAgICAgICB1cGRhdGVJdGVtKFxcXCJpbmZvT3V0cHV0XFxcIiwge1xcbiAgICAgICAgICAgIHBpY191cmw6IHFyY29kZV91cmwsXFxuICAgICAgICAgICAgdXJsOiBxcmNvZGVfdXJsICsgXFxcIiMuanBnXFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInBpY18xX2Z1bGxcXFwiXFxuICAgICAgICB9KTtcXG4gICAgICAgIGFkZEl0ZW1BZnRlcihcXFwiaW5mb091dHB1dFxcXCIsIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAmOKAmOKAmeKAmVxcXCIgKyBcXFwi5L2/55So6Zi/6YeM5LqR55uYIEFwcCDmiavnoIFcXFwiLmZvbnRjb2xvcihcXFwiZ3JleVxcXCIpLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgY2xzOiBcXFwibG9naW5cXFwiXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBkZWxldGVJdGVtKFxcXCJnZXRRQ1xcXCIpO1xcbiAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgIGxldCByZWZyZXNoX3Rva2VuO1xcbiAgICAgICAgd2hpbGUgKHRydWUpIHtcXG4gICAgICAgICAgICBsZXQgZGF0YTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBkYXRhID0gZ2V0X3FyY29kZV9zdGF0dXMoc2lkKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mn6Xor6LmiavnoIHnu5PmnpzotoXml7YsIOWPr+iDveaYr+inpuWPkeS6humYv+mHjOS6keebmOaOpeWPo+mZkOWItiwg6K+356iN5ZCO5YaN6K+VLlxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzdGF0dXMgPSBkYXRhW1xcXC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nRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy4kdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICAgICAgICAgJ3gtc2hhcmUtdG9rZW4nOiB0aGlzLiR0aGlzLnNoYXJlVG9rZW5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSkuc3RhcnQodHJ1ZSk7XFxuICAgICAgICBsZXQgY29kZSA9IHJlc3VsdC5yZWRpcmVjdFVyaS5zcGxpdChcXFwiY29kZT1cXFwiKVsxXTtcXG4gICAgICAgIHJldHVybiBjb2RlO1xcbiAgICB9LFxcbiAgICBnZXRUb2tlbihib2R5KSB7XFxuICAgICAgICBsZXQganNvbiA9IHBvc3QoJ2h0dHBzOi8vYXBpLnhob2ZlLnRvcC9hbGlzdC9hbGlfb3Blbi9jb2RlJywge1xcbiAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgJ1VzZXItQWdlbnQnOiBQQ19VQSxcXG4gICAgICAgICAgICAgICAgJ1JlZmVyZXInOiAnaHR0cHM6Ly93d3cuYWxpeXVuZHJpdmUuY29tLydcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBpZiAoIWpzb24pIHtcXG4gICAgICAgICAgICBqc29uID0gcG9zdCgnaHR0cHM6Ly9hcGktY2Yubm4uY2kvYWxpc3QvYWxpX29wZW4vY29kZScsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczogaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgYm9keTogSlNPTi5zdHJpbmd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mV0cnkoKGUsIF8sIGh0dHApID0+IHtcXG4gICAgICAgICAgICB0aGlzLiR0aGlzLnRyeVNvbHZlKGUpO1xcbiAgICAgICAgICAgIGh0dHAubWVyZ2VIZWFkQW5kQm9keSh7XFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICdhdXRob3JpemF0aW9uJzogdGhpcy4kdGhpcy5yZWFjY2Vzc1RrLFxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICB9KS5zdGFydCh0cnVlKTtcXG4gICAgICAgIHJldHVybiBnZXRfcXJjb2RlX2NvZGUoc2lkKTtcXG4gICAgfSxcXG4gICAgZ2V0VG9rZW4oYm9keSkge1xcbiAgICAgICAgbGV0IHJlcyA9IHBvc3QoXFxcImh0dHBzOi8vb3BlbmFwaS5hbGl5dW5kcml2ZS5jb20vb2F1dGgvYWNjZXNzX3Rva2VuXFxcIiwge1xcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KGJvZHkpLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBsZXQgZGF0YSA9IEpTT04ucGFyc2UocmVzKTtcXG5cXG4gICAgICAgIHJldHVybiBkYXRhO1xcbiAgICB9LFxcbiAgICBnZXRPcGVuVG9rZW4oKSB7XFxuICAgICAgICByZXR1cm4gdGhpcy5nZXRUb2tlbih7XFxuICAgICAgICAgICAgY29kZTogdGhpcy5nZXRPcGVuVG9rZW5Db2RlKCksXFxuICAgICAgICAgICAgZ3JhbnRfdHlwZTogXFxcImF1dGhvcml6YXRpb25fY29kZVxcXCIsXFxuICAgICAgICAgICAgY2xpZW50X3NlY3JldDogdGhpcy5jbGllbnRfc2VjcmV0LFxcbiAgICAgICAgICAgIGNsaWVudF9pZDogdGhpcy5jbGllbnRfaWQsXFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgcmVmcmVzaE9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gICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpFxcXCIgKyBuYW1lICsgXFxcIuWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygobmFtZSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBuYW1lKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSh0cnVlKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WIoOmZpOaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgfSwgbmFtZSlcXG4gICAgICAgIH0pO1xcbiAgICB9LCBuYW1lKTtcXG59XFxuXFxuZnVuY3Rpb24gZG91YmxlVHJlYXRpbmcoe1xcbiAgICBmaW5kQWxpVXJsLFxcbiAgICBiYXNpY1VybCxcXG4gICAgbmFtZSxcXG4gICAgYXV0aG9yLFxcbiAgICBhbGlVcmwsXFxuICAgIHJ1bGVUeXBlXFxufSkge1xcbiAgICBpZiAoIWZpbmRBbGlVcmwpIHJldHVybiBnZXRNb2RlVXJsKGFsaVVybCk7XFxuICAgIGlmIChydWxlVHlwZSA9PT0gXFxcIkpTT05cXFwiKSB7XFxuICAgICAgICBsZXQgUGFyc2VSbHVlID0gJC5yZXF1aXJlKFxcXC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yaW5nJykge1xcbiAgICAgICAgcmV0dXJuIFtdO1xcbiAgICB9XFxuXFxuICAgIGxldCBwYXRoID0gW107XFxuICAgIGxldCBjdXJyZW50ID0gJyc7XFxuICAgIGxldCBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgIGxldCBlc2NhcGUgPSBmYWxzZTtcXG5cXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCB2YWx1ZS5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgbGV0IGNoYXIgPSB2YWx1ZVtpXTtcXG5cXG4gICAgICAgIGlmIChlc2NhcGUpIHtcXG4gICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgZXNjYXBlID0gZmFsc2U7XFxuICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXCcpIHtcXG4gICAgICAgICAgICBlc2NhcGUgPSB0cnVlO1xcbiAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnLicgJiYgIWluQnJhY2tldHMpIHtcXG4gICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgY3VycmVudCA9ICcnO1xcbiAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnWycpIHtcXG4gICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXG4gICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ10nKSB7XFxuICAgICAgICAgICAgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICB9XFxuICAgIH1cXG5cXG4gICAgaWYgKGN1cnJlbnQpIHtcXG4gICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgfVxcblxcbiAgICByZXR1cm4gcGF0aDtcXG59XFxuXFxuZnVuY3Rpb24gZ2V0SnNvbihvYmosIHBhdGgpIHtcXG4gICAgaWYgKCFvYmogf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SB7XFxuICAgICAgICBpZiAoIWdldE15VmFyKFxcXCJtb3VudHppbXVcXFwiLCBcXFwiXFxcIikpIHtcXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwibW91bnR6aW11XFxcIiwge30pO1xcbiAgICAgICAgICAgIGFkZExpc3RlbmVyKFxcXCJvbkNsb3NlXFxcIiwgJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcIm1vdW50emltdVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJhbGlTaGFyZVRva2VuXFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyVmFyKFxcXCJkbV9zaGFyZVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJkbWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwibGlzdFNlYXJjaEtleVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJkbV9saXN0VXJsTGlzdFxcXCIpO1xcbiAgICAgICAgICAgIH0pKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHNldE1hcmtlcigpO1xcbiAgICAgICAgaWYgKE1ZX1BBUkFNUy5pc0hvbWUpIHtcXG4gICAgICAgICAgICAvL3NpZ25JblJld2FyZChhbGlBY2Nlc3NBcGkpO1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWkh+S7veebmFxcXCIgKyBbXFxcIlxcXCIsIFxcXCLiiJpcXFwiXVtOdW1iZXIoaXNCYWNrdXBEcml2aWQpXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm15QWxpUGFuRHJpdmlkXFxcIiwgXFxcInRydWVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzJcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui1hOa6kOebmFxcXCIgKyBbXFxcIuKImlxcXCIsIFxcXCJcXFwiXVtOdW1iZXIoaXNCYWNrdXBEcml2aWQpXSxcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm15QWxpUGFuRHJpdmlkXFxcIiwgXFxcImZhbHNlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChzaGFyZUluZm8pIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzovazlrZjliLDlvZPliY3mlofku7blpLnigJ3igJ1cXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHNoYXJlSW5mbywgaXNCYWNrdXBEcml2aWQsIGZpbGVJZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgQWxpQWNjZXNzQXBpID0gJC5yZXF1aXJlKFxcXCJhbGlQbGF5QXBpXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgYWxpQWNjZXNzQXBpID0gQWxpQWNjZXNzQXBpLmNyZWF0ZURlZmF1bHQoc2hhcmVJbmZvLnNoYXJlSWQsIHNoYXJlSW5mby5zaGFyZVB3ZCwgc2hhcmVJbmZvLnNoYXJlVG9rZW4pO1xcbiAgICAgICAgICAgICAgICAgICAgYWxpQWNjZXNzQXBpLnNldE15RHJpdmlkVHlwZShpc0JhY2t1cERyaXZpZCk7XFxuICAgICAgICAgICAgICAgICAgICBhbGlBY2Nlc3NBcGkuY29weUZpbGVUb0Nsb3VkRmlsZShzaGFyZUluZm8uZmlsZUlkLCBmaWxlSWQpO1xcbiAgICAgICAgICAgICAgICAgICAgYmFja1RvSG9tZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgc2hhcmVJbmZvLCBpc0JhY2t1cERyaXZpZCwgZmlsZUlkKSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghaXNTZWFyY2gpIHtcXG4gICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmkJzntKJcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBpbnB1dC50cmltKCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl5YWz6ZSu6K+NXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL215YWxpeXVuI25vSGlzdG9yeSMjZnVsbFRoZW1lIz9wYWdlPWZ5cGFnZSZzZWFyY2hLZXk9XFxcIiArIGVuY29kZVVSSUNvbXBvbmVudChpbnB1dCk7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIG9uQ2hhbmdlOiBcXFwicHV0TXlWYXIoJ2xpc3RTZWFyY2hLZXknLGlucHV0KVxcXCIsXFxuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi4oCc4oCcXFxcIiArIHNlYXJjaEtleSArIFxcXCLigJ3igJ3nmoTmkJzntKLnu5PmnpxcXFwiLFxcbiAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZnVuY0l0ZW1zID0gW107XFxuICAgICAgICBmdW5jSXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IHN0eWxlLFxcbiAgICAgICAgICAgIHVybDogJChzdHlsZXMsIDEsIFxcXCLmjpLluIPmoLflvI9cXFwiKS5zZWxlY3QoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJhbGl5dW5fc3R5bGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliIfmjaJcXFwiO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHBpY191cmw6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2FsaV9pY29uLnN2Z1xcXCJcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogb3JkZXJOYW1lLFxcbiAgICAgICAgICAgIHVybDogJChvcmRlcnNLZXlzLCAyLCBcXFwi5o6S5bqP5pa55byPXFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwiYWxpeXVuX29yZGVyXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBwaWNfdXJsOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL2ltZy9hbGlfc29ydC5zdmdcXFwiXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IHBsYXlNb2RlLFxcbiAgICAgICAgICAgIHVybDogJChbXFxcIui9rOeggVxcXCIsIFxcXCLljp/nlLtcXFwiXSwgMSwgXFxcIuaSreaUvuaooeW8j1xcXCIpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm15X2FsaXl1bl9wbGF5TW9kZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WIh+aNouaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgfSksXFxuICAgICA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8ueW5leaQnOe0ouinhOWImVxcXCIsIFxcXCLmibnph4/mjILovb3mnKzlnLDlvLnluZVcXFwiLCBcXFwi5o6o6YCB5YiwVFZCb3hcXFwiLCBcXFwi6K6+572u5pS26JeP5bCB6Z2iXFxcIiwgXFxcIuiOt+WPluaKleWxj0lQXFxcIiAvKiwgXFxcIuaegemAn+WOn+eUu+S4i+i9vee6v+eoi1xcXCIqLyBdLCAyLCBcXFwi5pu05aSa5Yqf6IO9XFxcIikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFxcXCLmibnph4/mjILovb3mnKzlnLDlvLnluZVcXFwiOlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9kbU1vdW50I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi5p+l55yL5omL5Yqo5oyC6L295a2X5bmVXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHptID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcIm1vdW50emltdVxcXCIsIHt9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRpcCA9IHptLm5hbWUgPyBcXFwi5b2T5YmN5a2X5bmV5paH5Lu2XFxcXG5cXFwiICsgem0ubmFtZSArIFxcXCIuXFxcIiArIHptLmV4dCA6IFxcXCLov5jmnKrmiYvliqjmjILovb3lrZfluZVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiAn5omL5Yqo5oyC6L295a2X5bmVJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IHRpcCArIFxcXCJcXFxcbijngrnlh7vlj5bmtojlj6/ku6XmuIXpmaTmjILovb3lrZfluZUpXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbmNlbDogKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcIm1vdW50emltdVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LmuIXpmaTmiYvliqjmjILovb3lrZfluZVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiOt+WPluW8ueW5leaQnOe0ouinhOWImVxcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcImpzXFxcIjogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS9sb2FkRG0/cnVsZT1cXFwiICsgTVlfUlVMRS50aXRsZSArIFxcXCImdGl0bGU9XFxcIikgKyBcXFwiK2VuY29kZVVSSUNvbXBvbmVudChwbGF5ZGF0YS50aXRsZS5zcGxpdCgnLScpWzBdKTtcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIm5hbWVcXFwiOiBNWV9SVUxFLnRpdGxlICsgXFxcIuW8ueW5leaQnOe0olxcXCJcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJydWxlOi8vXFxcIiArIGJhc2U2NEVuY29kZShcXFwi77+lcHJvamVjdGlvbl9zY3JlZW7vv6VcXFwiICsgSlNPTi5zdHJpbmdpZnkocnVsZSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuaOqOmAgeWIsFRWQm94XFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvdHZib3hQdXNoI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBcXFwi6K6+572u5pS26JeP5bCB6Z2iXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoW1xcXCLorr7nva7lsIHpnaLlnLDlnYBcXFwiLCBcXFwi5pCc57Si5bCB6Z2iXFxcIl0sIDEpLnNlbGVjdCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLorr7nva7lsIHpnaLlnLDlnYBcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIsIFxcXCLor7fovpPlhaXlm77niYflnLDlnYBcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQudHJpbSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0KSByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWl5Zyw5Z2AXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UGFnZVBpY1VybChpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kv67mlLnmiJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9mcm9udENvdmVyI25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5I1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuiOt+WPluaKleWxj0lQXFxcIjpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlwID0gJC5yZXF1aXJlKFxcXCJhbGlVdGlsXFxcIikuZ2V0SVB2NEFkZHJlc3MoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlwLnN0YXJ0c1dpdGgoXFxcIjE5Mi4xNjguXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGlwICsgXFxcIlxcXFxu6K+lSVDpgILnlKjkuo7mtYHph48r54Ot54K555qE5oqV5bGPXFxcXG7or7fmm7/mjaLpk77mjqXkuK3nmoQwLjAuMC4wXFxcIikuY29uZmlybSgoaXApID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgaXA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBpcCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChpcCArIFxcXCJcXFxcbuiOt+WPluWksei0pemdnueos+WumklQLOivt+W8gOWQr+eDreeCueWGjeS9v+eUqCzor6VJUOWPr+iDveS8muWPmCzkuI3og73mipXlsY9cXFwiKS5jb25maXJtKCgpID0+IHt9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgXFxcIuaegemAn+WOn+eUu+S4i+i9vee6v+eoi1xcXCI6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGdldEl0ZW0oXFxcInNwZWVkVGhyZWFkXFxcIiwgXFxcIjIwXFxcIiksIFxcXCLor7fovpPlhaUzLTMy5LmL6Ze055qE5pW05pWwXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNwZWVkVGhyZWFkID0gcGFyc2VJbnQoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNwZWVkVGhyZWFkIDwgMyB8fCBzcGVlZFRocmVhZCA+IDMyKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruS4jeWQiOazlVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzcGVlZFRocmVhZFxcXCIsIFN0cmluZyhzcGVlZFRocmVhZCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgcGljX3VybDogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS9pbWcvYWxpX2ZpbGVpbnRvLnN2Z1xcXCIsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBwYWdlSWQ6IHBhZ2VJZCxcXG4gICAgICAgICAgICAgICAgICAgIGZpbGVJZDogZml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AgICAgaWYgKGZpbGVJdGVtLnRodW1ibmFpbCkge1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJodHRwczovL2VtcHR5P1xcXCIgKyBmaWxlSXRlbS5maWxlX2lkKS5pbWFnZSgocGljKSA9PiB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmV0Y2gocGljLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRTdHJlYW06IHRydWVcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGZpbGVJdGVtLnRodW1ibmFpbCk7XFxuICAgICAgICB9XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZGVsZXRlREZpbGUoZmlsZUlkLCBpc0JhY2t1cERyaXZpZCwgbmFtZSkge1xcbiAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOawuOS5heWIoOmZpFtcXFwiICsgbmFtZSArIFxcXCJdXFxcIikuY29uZmlybSgoZmlsZUlkLCBpc0JhY2t1cERyaXZpZCkgPT4ge1xcbiAgICAgICAgICAgIGNvbnN0IEFsaUFjY2Vzc0FwaSA9ICQucmVxdWlyZShcXFwiYWxpUGxheUFwaVxcXCIpO1xcbiAgICAgICAgICAgIGxldCBhbGlBY2Nlc3NBcGkgPSBBbGlBY2Nlc3NBcGkuY3JlYXRlRGVmYXVsdCgpO1xcbiAgICAgICAgICAgIGFsaUFjY2Vzc0FwaS5zZXRNeURyaXZpZFR5cGUoaXNCYWNrdXBEcml2aWQpO1xcbiAgICAgICAgICAgIGFsaUFjY2Vzc0FwaS5kZWxldGVlQ2xvdWRGaWxlKGZpbGVJZCk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgIC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RpdGxlLFxcbiAgICAgICAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvbXlhbGl5dW4/cGFnZT1meXBhZ2UnLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogZm9sZGVyU3R5bGUsXFxuICAgICAgICAgICAgICAgIGRlc2M6IGZvcm1hdERhdGUoZmlsZUl0ZW0udXBkYXRlZF9hdCksXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IHBpY191cmwsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBmaWxlSWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICBpc0JhY2t1cERyaXZpZCxcXG4gICAgICAgICAgICAgICAgICAgIHBhZ2VUaXRsZTogZmlsZUl0ZW0ubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHNoYXJlSW5mbyxcXG4gICAgICAgICAgICAgICAgICAgIG5vUGljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6Zmk5paH5Lu25aS5XFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhkZWxldGVERmlsZSwgZmlsZUl0ZW0uZmlsZV9pZCwgaXNCYWNrdXBEcml2aWQsIGZpbGVJdGVtLm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2UgaWYgKG5vU2tpcEZpbGUpIHtcXG4gICAgICAgICAgICBpZiAoZmlsdGVyVHlwZS5sZW5ndGggPiAwICYmICFmaWx0ZXJUeXBlLmluY2x1ZGVzKGNhdGUpKSB7XFxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgc3VidGl0bGUsIGNscywgbG9uZ2MgPSBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpOaWh+S7tlxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKGRlbGV0ZURGaWxlLCBmaWxlSXRlbS5maWxlX2lkLCBpc0JhY2t1cERyaXZpZCwgZmlsZUl0ZW0ubmFtZSlcXG4gICAgICAgICAgICB9XTtcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBmaWxlSXRlbS5uYW1lO1xcbiAgICAgICAgICAgIGxldCBuYW1lTm90RXh0ID0gZmlsZUl0ZW0ubmFtZS5yZXBsYWNlKCcuJyArIGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLCAnJyk7XFxuICAgICAgICAgICAgaWYgKHN1YkV4dHMuaW5jbHVkZXMoZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pKSB7XFxuICAgICAgICAgICAgICAgIGxvbmdjLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmjILovb3lrZfluZVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKHptKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ21vdW50emltdScsIHptKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3RvYXN0Oi8v5oyC6L295a6M5oiQ77yM5b2T5YmN5a2X5bmV5paH5Lu2OiAnICsgem0ubmFtZSArICcuJyArIHptLmV4dDtcXG4gICAgICAgICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHQ6IGZpbGVJdGVtLmZpbGVfZXh0ZW5zaW9uLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVfaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogbmFtZU5vdEV4dFxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY2F0ZSA9PT0gXFxcInZpZGVvXFxcIikge1xcbiAgICAgICAgICAgICAgICBpZiAoemltdWxpc3QubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IHppbXVsaXN0LmZpbmQodiA9PiB2Lm5hbWUuaW5jbHVkZXMobmFtZU5vdEV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNscyA9IFxcXCJwbGF5bGlzdCB2XFxcIiArIHBhZ2VJZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGZpbGVTdHlsZSA9PT0gXFxcInRleHRfMVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgZGVzYyArPSBcXFwiXFxcXHRcXFxcdFxcXCIgKyBmb3JtYXRTaXplKGZpbGVJdGVtLnNpemUpO1xcbiAgICAgICAgICAgICAgICB0aXRsZSA9IGdldEhlYWQoY2F0ZSwgZmlsZUl0ZW0uZmlsZV9leHRlbnNpb24pICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChbXFxcInZpZGVvXFxcIiwgXFxcImltYWdlXFxcIl0uaW5jbHVkZXMoY2F0ZSkpIHtcXG4gICAgICAgICAgICAgICAgcGljX3VybCA9IGdldFByZXZpZXdQaWMoZmlsZUl0ZW0pIHx8IHBpY191cmw7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vUHJlI1xcXCIpLmxhenlSdWxlKChmaWxlSWQsIGNhdGUsIGlzQmFja3VwRHJpdmlkLCBzdWJ0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwibXlhbGlsYXp5XFxcIikoZmlsZUlkLCBjYXRlLCBpc0JhY2t1cERyaXZpZCwgc3VidGl0bGUpO1xcbiAgICAgICAgICAgICAgICB9LCBmaWxlSXRlbS5maWxlX2lkLCBjYXRlLCBpc0JhY2t1cERyaXZpZCwgc3VidGl0bGUpLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBkZXNjLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBwaWNfdXJsLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGZpbGVJdGVtLmZpbGVfaWQsXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IGxvbmdjLFxcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBjbHMsXFxuICAgICAgICAgICAgICAgICAgICAvL2luaGVyaXRUaXRsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICBwYWdlVGl0bGU6IGZpbGVJdGVtLm5hbWVcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IGZpbGVTdHlsZVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIGlmIChjb250cy5sZW5ndGggPT09IDApIHtcXG4gICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCIsXFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ1cXFwiICsgXFxcIn5+fuS7gOS5iOmDveayoeacieS6huWTpn5+flxcXCIuZm9udGNvbG9yKFxcXCJHcmF5XFxcIiksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICB9XFxufVxcblxcbmxldCBpdGVtcyA9IFtdO1xcbnRyeSB7XFxuICAgIGlmIChNWV9QQUdFID4gMSAmJiAhTVlfUEFSQU1TLm1hcmtlcikge1xcbiAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOKAneKAnVxcXCIgKyBcXFwifn5+5LuA5LmI6YO95rKh5pyJ5LqG5ZOmfn5+XFxcIi5mb250Y29sb3IoXFxcIkdyYXlcXFwiKSxcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICBsb2FkKGl0ZW1zKTtcXG4gICAgfVxcbn0gY2F0Y2ggKGUpIHtcXG5cXG4gICAgbG9nKFxcXCLliJfooajliqDovb3lpLHotKUjXFxcXG7plJnor6/kv6Hmga8+XFxcIiArIGUudG9TdHJpbmcoKSArIFxcXCJcXFxcbumUmeivr+ihjD5cXFwiICsgZS5saW5lTnVtYmVyKTtcXG4gICAgaXRlbXMucHVzaCh7XFxuICAgICAgICB0aXRsZTogJ+asp+asp++8jOaKpemUmeS6huOAguWcqOWIt+aWsOWHoOasoe+8n+aIluiAheabtOaNouaWh+S7tuWkueOAgicsXFxuICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgIGRlc2M6IGUudG9TdHJpbmcoKSxcXG4gICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMSdcXG4gICAgfSk7XFxuICAgIC8vdGhyb3cgZTtcXG59XFxuc2F2ZU15UGFDYWNoZSgpO1xcbnNld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zcy1leHBpcmVzPScpWzFdLnNwbGl0KCcmJylbMF07XFxuICAgICAgICBjb25zdCBsYXN0dGltZSA9IHBhcnNlSW50KGV4cGlyZXMpIC0gRGF0ZS5ub3coKSAvIDEwMDA7XFxuICAgICAgICBpZiAobGFzdHRpbWUgPCA2MCkge1xcbiAgICAgICAgICAgIC8vbG9nKCfov4fmnJ/mm7TmlrAnKVxcbiAgICAgICAgICAgIGxldCBsaW5lID0gdXJsLnNwbGl0KCcvbWVkaWEnKVswXTsgLy/lj5bkuYvliY3mkq3mlL7nmoR0c+autee6v+i3r1xcbiAgICAgICAgICAgIGxpbmUgPSBsaW5lLnN1YnN0cmluZyhsaW5lLmxhc3RJbmRleE9mKCcvJykgKyAxKTtcXG4gICAgICAgICAgICBsZXQgZiA9IGdldE0zdThDb250ZW50KGdldEFsaVBsYXlVcmwoZmlkLCBsaW5lKSkuc3BsaXQoXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgZi5mb3JFYWNoKGl0ID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKGl0ICYmIGl0LnN0YXJ0c1dpdGgoJy9wcm94eT91cmw9JykpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBmdXJsID0gYmFzZTY0RGVjb2RlKGl0LnJlcGxhY2UoJy9wcm94eT91cmw9JywgJycpKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh1cmwuc3Vic3RyKHVybC5pbmRleE9mKCcvbWVkaWEtJyksIHVybC5pbmRleE9mKCcudHMnKSkgPT0gZnVybC5zdWJzdHIoZnVybC5pbmRleE9mKCcvbWVkaWEtJyksIGZ1cmwuaW5kZXhPZignLnRzJykpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gZnVybDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pXFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gdXJsO1xcbiAgICB9XFxuIC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pZiAoT2JqZWN0LmtleXMobW91bnRzdWIpLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICB6aW11ID0gbW91bnRzdWI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc3VidGl0bGU7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXMoemltdSB8fCB7fSkubGVuZ3RoID4gMCAmJiBwbGF5TGlzdCAmJiBwbGF5TGlzdC51cmxzICYmIHBsYXlMaXN0LnVybHMubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwKTtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB2YXIgem11cmwgPSBhbGlBY2Nlc3NBcGkub3BlbkNsb3VkRmlsZVRvRG93blVybCh6aW11LmZpbGVfaWQpO1xcbiAgICAgICAgICAgICAgICBsZXQgcGF0aCA9ICdoaWtlcjovL2ZpbGVzL2NhY2hlL+S6keebmOWQmy9zdWIuJyArIHppbXUuZXh0O1xcbiAgICAgICAgICAgICAgICBkb3dubG9hZEZpbGUoem11cmwsIHBhdGgsIHtcXG4gICAgICAgICAgICAgICAgICAgICdSZWZlcmVyJzogJ2h0dHBzOi8vd3d3LmFsaXl1bmRyaXZlLmNvbS8nXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBzdWJ0aXRsZSA9IGdldFBhdGgocGF0aCk7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5a2X5bmV5Yqg6L295aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIGxvZyhlLm1lc3NhZ2UpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBkbWxpc3QgPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiZG1saXN0XFxcIiwgW10pO1xcbiAgICAgICAgbGV0IGRtbGlzdF9jYWNoZSA9IGdldE15VmFy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oZmlsZUlkKTtcXG5cXG4gICAgaWYgKGNhdGUgPT09IFxcXCJpbWFnZVxcXCIpIHtcXG4gICAgICAgIHJldHVybiB1cmwgKyBcXFwiIy5qcGdcXFwiO1xcbiAgICB9IGVsc2UgaWYgKGNhdGUgPT09IFxcXCJhdWRpb1xcXCIpIHtcXG4gICAgICAgIHJldHVybiB1cmwgKyBcXFwiI2lzTXVzaWM9dHJ1ZSNcXFwiO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgcmV0dXJuIFxcXCJkb3dubG9hZDovL1xcXCIgKyB1cmw7XFxuICAgIH1cXG59XCJ9XSIsImljb24iOiJodHRwczovL2ltZy5hbGljZG4uY29tL2ltZ2V4dHJhL2kyL08xQ04wMURPWWNzNzF2M0I2Yk9lbVZNXyEhNjAwMDAwMDAwNjExNi0yLXRwcy01MTItNTEyLnBuZyIsInByb3h5IjoiIn0=
Add Comment
Please, Sign In to add comment