Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@福建兄妹@eyJ0aXRsZSI6Iuemj+W7uuWFhOWmuSIsInR5cGUiOiJ2aWRlbyIsImF1dGhvciI6Im9mbyIsInZlcnNpb24iOjAsImdyb3VwIjoi4pGg57uD5omLIiwiaWNvbiI6Imh0dHBzOi8vY2RuMi5pY29uZmluZGVyLmNvbS9kYXRhL2ljb25zL2phcGFuLWZsYXQtMi8zNDAvamFwYW5faWRvbF9qYXBhbmVzZV9jdXRlX2FzaWFuX3ByZXR0eV9mZW1hbGUtMTI4LnBuZyIsInVhIjoibW9iaWxlIiwicHJveHkiOiIiLCJwcmVSdWxlIjoiLy9ATG95RGdJa+Wkp+S9rOWGmeeahOiHquWKqOabtOaWsO+8jOWkjeWItum7j+i0tOWwseWujOS6i++8jOaEn+iwouWkp+S9rOeahOWIhuS6q1xuICAgICAgICAgICAgbGV0IE1ZX0hPTUUgPSBNWV9SVUxFLnVybC5tYXRjaCgvaHR0cHM/XFw6XFwvXFwvLio/XFwvLylbMF07XG4gICAgICAgICAgICBsZXQgdXJsID1KU09OLnBhcnNlKGZldGNoKE1ZX0hPTUUse29ubHlIZWFkZXJzOnRydWV9KSkudXJsO1xuXG5pZiAoTVlfSE9NRSAhPSB1cmwpIHtcbiAgICBjb25maXJtKHtcbiAgICAgICAgdGl0bGU6IFwi5pu05paw6KeE5YiZXCIsXG4gICAgICAgIGNvbnRlbnQ6IFwi5qOA5rWL5Yiw5L2g6KeE5YiZ55qE5Z+f5ZCN5bey5aSx5pWI77yM5piv5ZCm56uL5Y2z5pu05paw77yfXCIsXG4gICAgICAgIGNvbmZpcm06ICgpID0+IHtcbiAgICAgICAgICAgIHNob3dMb2FkaW5nKFwi5q2j5Zyo6I635Y+W5Y+v55So5Z+f5ZCNXCIpO1xuICAgICAgICAgICAgbGV0IGh0bWwgPSAnaHR0cHM6Ly94bnYxNjUueHl6Lyc7XG4g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zFhYWQxOVwiKSArIFwiPC9iPlwiLFxuICAgICAgICDlsZXlvIA6IFwi4oCc4oCc4oCd4oCdPGI+XCIgKyBcIuKIqFwiLmZvbnRjb2xvcihcIiNGRjAwMDBcIikgKyBcIjwvYj5cIixcbiAgICAgICAgb3BlbjogdHJ1ZSxcbiAgICAgICAgc3RhdGU6IE1ZX1JVTEUudXJsLFxuICAgICAgICBzZWFyY2g6IGZhbHNlLFxuICAgICAgICBjbGVhcnM6IFtdLFxuICAgICAgICBjbGVhcmFsbDogW1wieWlfZmlyc3RwYWdlXCJdLFxuICAgICAgICBkZWJ1ZzogZmFsc2UsXG5cbiAgICAgICAg6aKE6K6+KHBhcmFtKSB7XG4gICAgICAgICAgICBpZiAocGFyYW0gPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgcGFyYW0gPSBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIE9iamVjdC5rZXlzKHBhcmFtKS5mb3JFYWNoKChwcm9wZXJ0eSkgPT4ge1xuICAgICAgICAgICAgICAgIC8vIOWvueavj+S4quWxnuaAp+WQjeaJp+ihjOaTjeS9nFxuICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gcGFyYW1bcHJvcGVydHldOyAvLyDojrflj5blsZ7mgKflgLxcbiAgICAgICAgICAgICAgICAvLyDlnKjov5nph4zmiafooYzmgqjnmoTmk43kvZxcbiAgICAgICAgICAgICAgICB0aGlzW3Byb3BlcnR5XSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlYnVnKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKHByb3BlcnR5ICsgXCI6XCIgKyB2YWx1ZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0sXG4gICAgICAgIGV2YWxKU1J1bGUoaXRlbSxcbiAgICAgICAgICAgIGpzUnVsZSkge1xuICAgICAgICAgICAgbGV0IHJ1bGUgPSBqc1J1bGUucmVwbGFjZShcIkBqczpcIixcbiAgICAgICAgICAgICAgICBcIlwiKTtcbiAgICAgICAgICAgIHJ1bGUgPSBydWxlLnRyaW0oKTtcbiAgICAgICAgICAgIC8vbG9nKCQuc3RyaW5naWZ5KHJ1bGUpKVxuICAgICAgICAgICAgbGV0IGlucHV0ID0gaXRlbTtcbiAgICAgICAgICAgIGlmIChydWxlLnN0YXJ0c1dpdGgoXCIoXCIpKSB7XG4gICAgICAgICAgICAgICAgZXZhbChcInJlc3VsdCA9IFwiICsgcnVsZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8qKlxuICAgICAgICAgICAgICAgICAqIOi/mOWOn+aIkCAkLnRvU3RyaW5nKC4uLikg55qE5pyA57uI57uT5p6c77yM6L6+5Yiw5pyA57uI5aSE55CG5pa55byP6Lef5LiK6Z2i55qEIGlmIOS4gOiHtOeahOebrueahFxuICAgICAgICAgICAgICAgICAqL1xuICAgICAgICAgICAgICAgIGV2YWwoXCJyZXN1bHQgPSBcIiArIFwiKCgpID0+IHtcIiArIHJ1bGUgKyBcIn0pKClcIik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0IHx8IFwiXCI7XG4gICAgICAgIH0sXG4gICAgICAgIGdldFRpdGxlKHNyYywgY2F0ZWdvcnkpIHtcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IFwiXCI7XG4gICAgICAgICAgICBsZXQgdGl0bGVSdWxlID0gY2F0ZWdvcnkgfHwgXCJhJiZUZXh0XCI7XG4gICAgICAgICAgICBpZiAodGl0bGVSdWxlLnN0YXJ0c1dpdGgoXCJAanM6XCIpKSB7XG4gICAgICAgICAgICAgICAgdGl0bGUgPSB0aGlzLmV2YWxKU1J1bGUoc3JjLCB0aXRsZVJ1bGUpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aXRsZSA9IHBhcnNlRG9tRm9ySHRtbChzcmMsIHRpdGxlUnVsZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdGl0bGUgfHwgXCJcIjtcbiAgICAgICAgfSxcbiAgICAgICAgZ2V0VXJsKHNyYywgY2F0ZWdvcnkpIHtcbiAgICAgICAgICAgIGxldCB1cmwgPSBcIlwiO1xuICAgICAgICAgICAgbGV0IHVybFJ1bGUgPSBjYXRlZ29yeS7pk77mjqUgfHwgXCJhJiZocmVmXCI7XG4gICAgICAgICAgICBpZiAodXJsUnVsZS5zdGFydHNXaXRoKFwiQGpzOlwiKSkge1xuICAgICAgICAgICAgICAgIHVybCA9IHRoaXMuZXZhbEpTUnVsZShzcmMsIHVybFJ1bGUpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB1cmwgPSBwZChzcmMsIHVybFJ1bGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHR5cGVvZiBjYXRlZ29yeS7pk77mjqXlpITnkIYgPT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgdXJsID0gY2F0ZWdvcnku6ZO+5o6l5aSE55CGKHVybCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdXJsIHx8IFwiXCI7XG4gICAgICAgIH0sXG4gICAgICAgIGlzTnVsbChwYXJhbSkge1xuICAgICAgICAgICAgaWYgKHBhcmFtID09IG51bGwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfSxcbiAgICAgICAgaXNCb29sZWFuKHZhcmlhYmxlKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhcmlhYmxlICE9PSBcImJvb2xlYW5cIikge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIuW8gOWQr+aKmOWPoOivt+S8oOWFpeW4g+WwlOWAvFwiKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAg5riF6ZmkKGxpc3QpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmlzTnVsbChsaXN0KSkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGxpc3QuY29uc3RydWN0b3IgPT0gU3RyaW5nKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwi5riF6Zmk5oql6ZSZOuivt+S8oOWIl+ihqFwiKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuY2xlYXJzID0gbGlzdDtcbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9LFxuICAgICAgICDlhajmuIUobGlzdCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuaXNOdWxsKGxpc3QpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgYyA9IHRoaXMuY2xlYXJhbGw7XG4gICAgICAgICAgICBsaXN0ID0gYy5jb25jYXQobGlzdCk7XG4gICAgICAgICAgICB0aGlzLmNsZWFyYWxsID0gbGlzdDtcbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9LFxuICAgICAgICDmupDnoIEoaW5wdXQpIHtcbiAgICAgICAgICAgIHRoaXMuaHRtbCA9IGlucHV0O1xuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICAgIH0sXG4gICAgICAgIOeVjOmdoihpbnB1dCkge1xuICAgICAgICAgICAgdGhpcy5sYXlvdXQgPSBpbnB1dDtcbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9LFxuICAgICAgICDpobXnoIEoaW5wdXQpIHtcbiAgICAgICAgICAgIHRoaXMucGFnZSA9IGlucHV0O1xuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICAgIH0sXG4gICAgICAgIOeKtuaAgShpbnB1dCkge1xuICAgICAgICAgICAgdGhpcy5zdGF0ZSA9IGlucHV0O1xuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICAgIH0sXG4gICAgICAgIOW8gOWQr+aQnOe0oihpbnB1dCkge1xuICAgICAgICAgICAgaWYgKGlucHV0ID09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGlucHV0ID0gdHJ1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuc2VhcmNoID0gaW5wdXQ7XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSxcbiAgICAgICAg5byA5ZCv5oqY5Y+gKGlucHV0KSB7XG4gICAgICAgICAgICBpZiAoaW5wdXQgPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgaW5wdXQgPSB0cnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5pc0Jvb2xlYW4oaW5wdXQpO1xuICAgICAgICAgICAgdGhpcy5vcGVuID0gaW5wdXQ7XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSxcbiAgICAgICAgc2V0VGl0bGUoaywgaSwgdCkge1xuICAgICAgICAgICAgcmV0dXJuIGsgPT0gaSA/IFwi4oCc4oCc4oCd4oCdXCIgKyB0LmZvbnRjb2xvcih0aGlzLuWIhuexu+minOiJsikgOiB0O1xuICAgICAgICB9LFxuICAgICAgICBhY3Rpb24ob2JqKSB7XG4gICAgICAgICAgICByZXR1cm4gW3tcbiAgICAgICAgICAgICAgICB0aXRsZTogXCLmuIXpmaTnirbmgIFcIixcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygob2JqKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGxvZyhvYmopO1xuICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKG9iai5zdGF0ZSk7XG4gICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXCJoZWFkLmNhdGVcIik7XG4gICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoJ2NhdGVfYnV0dG9uJyk7XG4gICAgICAgICAgICAgICAgICAgIG9iai5hbGwuZm9yRWFjaCgoaXRlbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIG9iai5jbC5mb3JFYWNoKChpdGVtKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKGl0ZW0pO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcbiAgICAgICAgICAgICAgICB9LCBvYmopLFxuICAgICAgICAgICAgfSwgXTtcbiAgICAgICAgfSxcbiAgICAgICAgY2hlY2tQYXJhbSgpIHtcbiAgICAgICAgICAgIHZhciBvYmogPSB7fTtcbiAgICAgICAgICAgIGlmICh0aGlzLnBhZ2UgPT0gMCAmJiB0eXBlb2YgcGFnZSA9PSBcInVuZGVmaW5lZFwiKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwi6K+35Lyg5YWl6aG156CBXCIpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHBhZ2UgPT0gXCJ1bmRlZmluZWRcIikge1xuICAgICAgICAgICAgICAgICAgICBvYmpbXCLpobXnoIFcIl0gPSB0aGlzLnBhZ2U7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgb2JqW1wi6aG156CBXCJdID0gcGFnZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5odG1sID09IFwiZW1wdHlcIiAmJiB0eXBlb2YgaHRtbCA9PSBcInVuZGVmaW5lZFwiKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwi6K+35Lyg5YWl5rqQ56CBXCIpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGh0bWwgPT0gXCJ1bmRlZmluZWRcIikge1xuICAgICAgICAgICAgICAgICAgICBvYmpbXCLmupDnoIFcIl0gPSB0aGlzLmh0bWw7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgb2JqW1wi5rqQ56CBXCJdID0gaHRtbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5sYXlvdXQgPT0gXCJ1bmRlZmluZWRcIiAmJiB0eXBlb2YgZCA9PSBcInVuZGVmaW5lZFwiKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFwi6K+35Lyg5YWl55WM6Z2iXCIpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGQgPT0gXCJ1bmRlZmluZWRcIikge1xuICAgICAgICAgICAgICAgICAgICBvYmpbXCLnlYzpnaJcIl0gPSB0aGlzLmxheW91dDtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBvYmpbXCLnlYzpnaJcIl0gPSBkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBvYmo7XG4gICAgICAgIH0sXG4gICAgICAgIOWIm+W7uuWKqOaAgeWIhuexuyhydWxlT2JqKSB7XG4gICAgICAgICAgICBsZXQgaXRlbXMgPSBbXTtcbiAgICAgICAgICAgIGxldCBjYXRlcyA9IFtdO1xuICAgICAgICAgICAgaWYgKHJ1bGVPYmogPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgcnVsZU9iaiA9IFtdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy/liJ3lp4vljJblj5jph4/lvIDlp4tcbiAgICAgICAgICAgIGNvbnN0IHBhcmFtID0gdGhpcy5jaGVja1BhcmFtKCk7XG4gICAgICAgICAgICBjb25zdCBwYWdlID0gcGFyYW0u6aG156CBO1xuICAgICAgICAgICAgY29uc3QgaHRtbCA9IHBhcmFtLua6kOeggTtcbiAgICAgICAgICAgIGNvbnN0IGQgPSBwYXJhbS7nlYzpnaI7XG4gICAgICAgICAgICBjb25zdCDnirbmgIEgPSB0aGlzLnN0YXRlO1xuICAgICAgICAgICAgY29uc3Qgc2VhcmNoID0gdGhpcy5zZWFyY2g7XG4gICAgICAgICAgICBjb25zdCBlbXB0eSA9IFwiaGlrZXI6Ly9lbXB0eVwiO1xuICAgICAgICAgICAgY29uc3Qg5oqY5Y+g54q25oCBID0gdGhpcy5vcGVuO1xuICAgICAgICAgICAgdmFyIOWxleW8gCA9IHRoaXMu5bGV5byAO1xuICAgICAgICAgICAgdmFyIOaKmOWPoCA9IHRoaXMu5oqY5Y+gO1xuICAgICAgICAgICAgdmFyIOWFqOa4hSA9IHRoaXMuY2xlYXJhbGw7XG4gICAgICAgICAgICB2YXIg5riF6ZmkID0gdGhpcy5jbGVhcnM7XG4gICAgICAgICAgICAvL+WIneWni+WMluWPmOmHj+e7k+adn1xuICAgICAgICAgICAgbGV0IGluaXRfY2F0ZSA9IG5ldyBBcnJheSgyMCkuZmlsbChcIjBcIik7XG4gICAgICAgICAgICBjb25zdCBmb2xkID0gZ2V0TXlWYXIoTVlfUlVMRS5ncm91cCwgXCIwXCIpO1xuICAgICAgICAgICAgY29uc3QgY2F0ZV90ZW1wID0gSlNPTi5wYXJzZShcbiAgICAgICAgICAgICAgICBnZXRNeVZhcihcImhlYWQuY2F0ZVwiLCBKU09OLnN0cmluZ2lmeShpbml0X2NhdGUpKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGlmIChzZWFyY2ggJiYgcGFnZSA9PSAxKSB7XG4gICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcIvCflI5cIixcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBcIidoaWtlcjovL3NlYXJjaD9ydWxlPVwiICsgTVlfUlVMRS50aXRsZSArIFwiJnM9JytpbnB1dFwiLFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBcIuaQnOe0ouWFs+mUruivjVwiLFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJpbnB1dFwiLFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBnZXRNeVZhcihcImtleXdvcmRcIiwgXCJcIiksXG4gICAgICAgICAgICAgICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXCJrZXl3b3JkXCIsIGlucHV0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29uc3QgY2F0ZWdvcmllcyA9IFtdO1xuICAgICAgICAgICAgcnVsZU9iai5mb3JFYWNoKCh4KSA9PiB7XG4gICAgICAgICAgICAgICAgdmFyIGxpc3QgPSBbXTtcbiAgICAgICAgICAgICAgICAvL2xvZyh4KVxuICAgICAgICAgICAgICAgIGlmICh4Lmpzb24gIT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgIHguanNvbi5tYXAoayA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYXRlZ29yaWVzLnB1c2goSlNPTi5zdHJpbmdpZnkoaykucmVwbGFjZSgvXlxcW3xcXF0kL2csICcnKSlcbiAgICAgICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgLy9jYXRlZ29yaWVzLnB1c2goeC5qc29uKVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoeC7kuIDnuqflrprkvY0pIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHgu5LiA57qn5a6a5L2NLnN0YXJ0c1dpdGgoXCJAanM6XCIpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaXN0ID0gdGhpcy5ldmFsSlNSdWxlKGh0bWwsIHgu5LiA57qn5a6a5L2NKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpc3QgPSBwZGZhKGh0bWwsIHgu5LiA57qn5a6a5L2NKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoeC7lpKfnsbvlrprkvY0pIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHgu5aSn57G75a6a5L2NLnN0YXJ0c1dpdGgoXCJAanM6XCIpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsaXN0ID0gdGhpcy5ldmFsSlNSdWxlKGh0bWwsIHgu5aSn57G75a6a5L2NKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpc3QgPSBbcGRmYShodG1sLCB4LuWkp+exu+WumuS9jSkuam9pbignXFxuJyldO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8tLemineWkluWkhOeQhi0tXG4gICAgICAgICAgICAgICAgdmFyIOS4gOe6pyA9IGxpc3QubWFwKChzKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBzbGlzdCA9IFtdO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIShcIuWwj+exu1wiIGluIHgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB4LuWwj+exuyA9IFwiYm9keSYmYTpub3QoOm1hdGNoZXMo6aaW6aG1KSk6bm90KGE6bm90KFtocmVmXSkpXCI7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHgu5bCP57G7LnN0YXJ0c1dpdGgoXCJAanM6XCIpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzbGlzdCA9IHRoaXMuZXZhbEpTUnVsZShzLCB4LuWwj+exuyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzbGlzdCA9IHBkZmEocywgeC7lsI/nsbspO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIC8vLS3pop3lpJblpITnkIYtLVxuICAgICAgICAgICAgICAgIGlmICgoJ+WinuWKoCcgaW4geCkpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHgu5aKe5YqgLmNvbnN0cnVjdG9yID09IFN0cmluZykge1xuICAgICAgICAgICAgICAgICAgICAgICAgeC7lop7liqAgPSBldmFsKHgu5aKe5YqgKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzbGlzdCA9IHgu5aKe5YqgLmNvbmNhdChzbGlzdCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICgoJ+ihpeWFhScgaW4geCkpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHgu6KGl5YWFLmNvbnN0cnVjdG9yID09IFN0cmluZykge1xuICAgICAgICAgICAgICAgICAgICAgICAgeC7ooaXlhYUgPSBldmFsKHgu6KGl5YWFKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBzbGlzdCA9IHNsaXN0LmNvbmNhdCh4LuihpeWFhSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgICAgICB2YXIg5a6a5L2NID0gc2xpc3QubWFwKChpdGVtKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGl0bGUgPSB0aGlzLmdldFRpdGxlKGl0ZW0sIHgu5qCH6aKYKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB1cmwgPSB0aGlzLmdldFVybChpdGVtLCB4KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmogPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDogdXJsXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KG9iaik7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4g5a6a5L2NO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIC8vbG9nKOS4gOe6pylcbiAgICAgICAgICAgICAgICAvL2xvZyjkuIDnuqcubGVuZ3RoKVxuICAgICAgICAgICAgICAgIGlmICjkuIDnuqcubGVuZ3RoID09IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgY2F0ZWdvcmllcy5wdXNoKOS4gOe6py5qb2luKFwiXFxuXCIpKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICDkuIDnuqcuZm9yRWFjaCgoaXRlbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2F0ZWdvcmllcy5wdXNoKGl0ZW0uam9pbihcIixcIikpO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZWdvcmllcylcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaWYgKOaKmOWPoOeKtuaAgSkge1xuICAgICAgICAgICAgICAgIGlmIChwYWdlID09IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZm9sZCA9PT0gXCIxXCIgPyDmipjlj6AgOiDlsZXlvIAsXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoXCIjbm9Mb2FkaW5nI1wiKS5sYXp5UnVsZShcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAodGl0bGUsIGZvbGQsIHUsIGFsbCwgZXhwcykgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZm9sZCA9IGdldE15VmFyKE1ZX1JVTEUuZ3JvdXAsIGZvbGQpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBb5bGV5byALCDmipjlj6BdID0gZXhwcztcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9sZCA9PSAxKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgY3ggPSBmaW5kSXRlbXNCeUNscyh0aXRsZSArICdjYXRlX2J1dHRvbicpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ2NhdGVfYnV0dG9uJywgY3gpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKHRpdGxlICsgJ2NhdGVfYnV0dG9uJyk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjeCA9IHN0b3JhZ2UwLmdldE15VmFyKCdjYXRlX2J1dHRvbicsIFtdKS5tYXAoeCA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeFsnY29sX3R5cGUnXSA9IHhbJ2NvbF90eXBlJ10gPyB4Wydjb2xfdHlwZSddIDogeFsndHlwZSddO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIodGl0bGUgKyAnY2F0ZV9saW5lJywgY3gpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKmFsbC5mb3JFYWNoKChpdGVtKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7Ki9cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh0aXRsZSArICdjYXRlX2V4cCcsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBmb2xkID09IDEgPyDlsZXlvIAgOiDmipjlj6AsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoTVlfUlVMRS5ncm91cCwgZm9sZCA9PT0gXCIxXCIgPyBcIjBcIiA6IFwiMVwiKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL3JlZnJlc2hQYWdlKGZhbHNlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFwiaGlrZXI6Ly9lbXB0eVwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgTVlfUlVMRS50aXRsZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb2xkLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIOeKtuaAgSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICDlhajmuIUsIFvlsZXlvIAsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIOaKmOWPoFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF0sXG4gICAgICAgICAgICAgICAgICAgICAgICApLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwic2Nyb2xsX2J1dHRvblwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArICdjYXRlX2V4cCcsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiB0aGlzLmFjdGlvbih7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlOiDnirbmgIEsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbDog5YWo5riFLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbDog5riF6ZmkLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHBhZ2UgPT0gMSkge1xuICAgICAgICAgICAgICAgIGNhdGVnb3JpZXMuZm9yRWFjaCgoY2F0ZWdvcnksIGluZGV4KSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIC8vbG9nKGNhdGVnb3J5KVxuICAgICAgICAgICAgICAgICAgICBsZXQgc3ViX2NhdGVnb3JpZXMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgLyppZiAo5bCP57G75a6a5L2NLmluY2x1ZGVzKFwiO1wiKSkge1xuICAgICAgICAgICAgICAgICAgICAgIHN1Yl9jYXRlZ29yaWVzID0gcGRmYShjYXRlZ29yeSwg5bCP57G75a6a5L2NLnNwbGl0KFwiO1wiKVswXSk7XG4gICAgICAgICAgICAgICAgICAgICAgaWYgKHN1Yl9jYXRlZ29yaWVzLmxlbmd0aCA9PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJfY2F0ZWdvcmllcyA9IHBkZmEoY2F0ZWdvcnksIOWwj+exu+WumuS9jS5zcGxpdChcIjtcIilbMV0pO1xuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsqL1xuICAgICAgICAgICAgICAgICAgICAvL2xvZyhpbmRleClcbiAgICAgICAgICAgICAgICAgICAgc3ViX2NhdGVnb3JpZXMgPSBKU09OLnBhcnNlKGBbJHtjYXRlZ29yeX1dYCk7XG4gICAgICAgICAgICAgICAgICAgIC8vbG9nKHN1Yl9jYXRlZ29yaWVzKVxuICAgICAgICAgICAgICAgICAgICAvLyBzdWJfY2F0ZWdvcmllcyA9IHBkZmEoY2F0ZWdvcnksIOWwj+exu+WumuS9jSk7XG4gICAgICAgICAgICAgICAgICAgIC8vfVxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8v5aSn57G7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJfY2F0ZWdvcmllcy5mb3JFYWNoKChpdGVtLCBrZXkpID0+IHtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vbGV0IHRpdGxlID0gcGRmaChpdGVtLCBf5aSn57G75qCH6aKYKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSBpdGVtLnRpdGxlO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiDmjpLpmaQgIT0gXCJ1bmRlZmluZWRcIiAmJiDmjpLpmaQgIT0gXCJcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZSA9IHRpdGxlLnJlcGxhY2UobmV3UmVnRXhwKOaOkumZpCwgXCJnXCIpLCBcIlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGpzb24gPSAnJ1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzb24gPSBpdGVtLnVybDtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXJhbXMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXk6IGtleSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFnZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJzOiDmuIXpmaQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzb246IGpzb24sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlOiDnirbmgIEsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbGNsZWFyczog5YWo5riFLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xldCB1cmwgPSBwZChpdGVtLCBf5aSn57G76ZO+5o6lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdXJsID0gaXRlbS51cmw7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLyppZiAo5aSn57G75aSE55CGKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSDkuIDnuqfliIbnsbvlpITnkIYodXJsKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9Ki9cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyh1cmwpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aGlzLnNldFRpdGxlKGtleS50b1N0cmluZygpLCBjYXRlX3RlbXBbaW5kZXhdLCB0aXRsZSksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcInNjcm9sbF9idXR0b25cIixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKFwiaGlrZXI6Ly9lbXB0eSNub0xvYWRpbmcjXCIpLmxhenlSdWxlKChwYXJhbXMpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmV3X2NhdGUgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMuY2xlYXJzLmZvckVhY2goKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMuYWxsY2xlYXJzLmZvckVhY2goKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKCdjYXRlX2J1dHRvbicpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmNhdGVfdGVtcC5mb3JFYWNoKChjYXRlLCBpbmRleCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdfY2F0ZS5wdXNoKGluZGV4ID09PSAwID8gcGFyYW1zLmtleS50b1N0cmluZygpIDogXCIwXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFwiaGVhZC5jYXRlXCIsIEpTT04uc3RyaW5naWZ5KG5ld19jYXRlKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtcy5qc29uLmNvbnN0cnVjdG9yID09PSBPYmplY3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXCJkdF9cIiArIHBhcmFtcy5qc29uLnR5cGUsIHBhcmFtcy5qc29uLnZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihwYXJhbXMuc3RhdGUsIHBhcmFtcy5qc29uKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFwiaGlrZXI6Ly9lbXB0eVwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcyksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcImJsYW5rX2Jsb2NrXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyAnY2F0ZV9saW5lJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8v5bCP57G7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJfY2F0ZWdvcmllcy5mb3JFYWNoKChpdGVtLCBrZXkpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZXh0cmFwb3MgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKmlmIChpdGVtLmluY2x1ZGVzKCd0eXBlPVwiQGV4dHJhXCInKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmFwb3MgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coJ+mZhOWKoOWumuS9jScpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSovXG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXh0cmFwb3MpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRpdGxlID0gcGRmaChpdGVtLCBcImEmJlRleHRcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Yg5o6S6ZmkICE9IFwidW5kZWZpbmVkXCIgJiYg5o6S6ZmkICE9IFwiXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUucmVwbGFjZShuZXcgUmVnRXhwKOaOkumZpCwgXCJnXCIpLCBcIlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIganNvbiA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHBkZmgoaXRlbSwgXCJhJiZzdGF0ZVwiKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwZGZoKGl0ZW0sIFwiYSYmdmFsdWVcIiksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy92YXIgdGl0bGUgPSBwZGZoKGl0ZW0sIOWIhuexu+agh+mimCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aXRsZSA9IGl0ZW0udGl0bGU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Yg5o6S6ZmkICE9IFwidW5kZWZpbmVkXCIgJiYg5o6S6ZmkICE9IFwiXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUucmVwbGFjZShuZXcgUmVnRXhwKOaOkumZpCwgXCJnXCIpLCBcIlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBqc29uID0gXCJcIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLypzd2l0Y2ggKHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIOWIhuexu+mTvuaOpS5pbmNsdWRlcyhcIkBAQFwiKTpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzb24gPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHBkZmgoaXRlbSwg5YiG57G76ZO+5o6lLnNwbGl0KFwiQEBAXCIpWzBdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHBkZmgoaXRlbSwg5YiG57G76ZO+5o6lLnNwbGl0KFwiQEBAXCIpWzFdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIOWIhuexu+mTvuaOpS5pbmNsdWRlcyhcIkBAXCIpOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganNvbiA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTog5YiG57G76ZO+5o6lLnNwbGl0KFwiQEBcIilbMF0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBwZGZoKGl0ZW0sIOWIhuexu+mTvuaOpS5zcGxpdChcIkBAXCIpWzFdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganNvbiA9IGl0ZW0udXJsO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8ganNvbiA9IHBkKGl0ZW0sIOWIhuexu+mTvuaOpSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSovXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzb24gPSBpdGVtLnVybDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyp2YXIganNvbj3liIbnsbvpk77mjqUuaW5jbHVkZXMoJ0BAQCcpP3tcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTpwZGZoKGl0ZW0s5YiG57G76ZO+5o6lLnNwbGl0KCdAQEAnKVswXSksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOnBkZmgoaXRlbSzliIbnsbvpk77mjqUuc3BsaXQoJ0BAQCcpWzFdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OnBkKGl0ZW0s5YiG57G76ZO+5o6lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc29uPeWIhuexu+mTvuaOpS5pbmNsdWRlcygnQEAnKT97XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU65YiG57G76ZO+5o6lLnNwbGl0KCdAQCcpWzBdLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTpwZGZoKGl0ZW0s5YiG57G76ZO+5o6lLnNwbGl0KCdAQCcpWzFdKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OnBkKGl0ZW0s5YiG57G76ZO+5o6lKTsqL1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXJhbXMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleDogaW5kZXgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleToga2V5LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlOiBwYWdlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc29uOiBqc29uLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZTog54q25oCBLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxjbGVhcnM6IOWFqOa4hSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGVzLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGhpcy5zZXRUaXRsZShrZXkudG9TdHJpbmcoKSwgY2F0ZV90ZW1wW2luZGV4XSwgdGl0bGUpLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoXCJoaWtlcjovL2VtcHR5XCIgKyBcIiNub0xvYWRpbmcjXCIpLmxhenlSdWxlKChwYXJhbXMpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMuYWxsY2xlYXJzLmZvckVhY2goKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKCdjYXRlX2J1dHRvbicpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmNhdGVfdGVtcFtwYXJhbXMuaW5kZXhdID0gcGFyYW1zLmtleS50b1N0cmluZygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFwiaGVhZC5jYXRlXCIsIEpTT04uc3RyaW5naWZ5KHBhcmFtcy5jYXRlX3RlbXApKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW1zLmpzb24uY29uc3RydWN0b3IgPT09IE9iamVjdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcImR0X1wiICsgcGFyYW1zLmpzb24udHlwZSwgcGFyYW1zLmpzb24udmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKHBhcmFtcy5zdGF0ZSwgcGFyYW1zLmpzb24pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcImhpa2VyOi8vZW1wdHlcIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMpLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJzY3JvbGxfYnV0dG9uXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbHM6IE1ZX1JVTEUudGl0bGUgKyAnY2F0ZV9idXR0b24nLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhdGVzLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcImJsYW5rX2Jsb2NrXCIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgJ2NhdGVfYnV0dG9uJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGZvbGQgPT09IFwiMVwiIHx8IOaKmOWPoOeKtuaAgSA9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgIGl0ZW1zID0gaXRlbXMuY29uY2F0KGNhdGVzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChmb2xkID09PSBcIjBcIikge1xuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdjYXRlX2J1dHRvbicsIGNhdGVzKVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHR5cGVvZiBzZXRQcmVSZXN1bHQgIT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICBpdGVtcyA9IGQuY29uY2F0KGl0ZW1zKTtcbiAgICAgICAgICAgICAgICAvL+a4heepuue7p+aJv+aVsOe7hFxuICAgICAgICAgICAgICAgIGQubGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICBzZXRQcmVSZXN1bHQoaXRlbXMpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpdGVtcy5mb3JFYWNoKGl0ZW0gPT4ge1xuICAgICAgICAgICAgICAgICAgICBkLnB1c2goaXRlbSk7XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICB9O1xuICAgIG9iai7pooTorr4ob3B0aW9ucyk7XG4gICAgcmV0dXJuIG9iajtcbn1cblxudmFyIOeKtuaAgSA9XG4gICAgdHlwZW9mIOeKtuaAgeagh+iusCAhPSBcInVuZGVmaW5lZFwiICYmIOeKtuaAgeagh+iusCAhPSBcIlwiID8g54q25oCB5qCH6K6wIDogTVlfUlVMRS51cmw7XG5cbmxldCBkdF9kZWJ1ZyA9IGZhbHNlO1xuXG5hZGRMaXN0ZW5lcihcbiAgICBcIm9uQ2xvc2VcIixcbiAgICAkLnRvU3RyaW5nKCgpID0+IHt9KVxuKTtcblxudmFyIENyZWF0ZSA9IHtcbiAgICBuZXh0UGFnZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciByZXN1bHQgPSBmYWxzZTtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHZhciBuZXh0ID0gZXZhbCjkuIvkuIDpobUpO1xuICAgICAgICAgICAgLy9sb2coJ246JytuZXh0KVxuICAgICAgICAgICAgaWYgKG5leHQgPT0gXCJcIikge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcign5LiL5LiA6aG16ZO+5o6l5Li656m6JylcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJlc3VsdCA9IHRydWU7XG4gICAgICAgICAgICBpZiAodHJ1ZV91cmwgPT0gbmV4dCkge1xuICAgICAgICAgICAgICAgIHJlc3VsdCA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAvL2xvZyhcIuWPr+iDveS4jeWtmOWcqOS4i+S4gOmhteaIluiAheS4i+S4gOmhteWumuS9jeaciemXrumimFwiKTtcbiAgICAgICAgICAgIGxvZyhcIumUmeivr+S/oeaBrzpcIiArIGUubWVzc2FnZSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKChuZXh0ID09IFwiXCIgfHwgbmV4dCA9PSB1bmRlZmluZWQpICYmIHBhZ2UgPT0gMSkge1xuICAgICAgICAgICAgbmV4dCA9IHRydWVfdXJsO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy9yZXN1bHQ9ZmFsc2U7XG4gICAgICAgICAgICBuZXh0ID0gZ2V0TXlWYXIo54q25oCBKTtcbiAgICAgICAgfVxuICAgICAgICAvL2xvZygnbCcrdHJ1ZV91cmwpXG4gICAgICAgIC8vbG9nKCduJytuZXh0KVxuICAgICAgICBpZiAocGFnZSAhPSAxKSB7XG4gICAgICAgICAgICBpZiAodHJ1ZV91cmwgPT0gbmV4dCAmJiAhcmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0ID0gZmFsc2U7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHJlc3VsdCA9I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Zykge1xuICAgICAgICAgICAgaW1nID0gcGRmaChpdGVtLCBydWxlLmltZyk7XG4gICAgICAgICAgICBpbWcgPSB0aGlzLmdldEJhY2tJbWFnZShpbWcpO1xuICAgICAgICAgICAgaW1nID0gdGhpcy5odHRwSGFuZGxlKGltZyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpbWcgPSBwZGZoKGl0ZW0sIHJ1bGUuaW1nKTtcbiAgICAgICAgICAgIGlmICghaW1nLnN0YXJ0c1dpdGgoXCJodHRwXCIpKSB7XG4gICAgICAgICAgICAgICAgaW1nID0gcGQoaXRlbSwgcnVsZS5pbWcpO1xuICAgICAgICAgICAgICAgIGltZyA9IHRoaXMuaHR0cEhhbmRsZShpbWcpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBpbWcgKyBydWxlLnJlZjtcbiAgICB9LFxuICAgIHVybEhhbmRsZTogZnVuY3Rpb24oaXRlbSwgcnVsZSkge1xuICAgICAgICB2YXIgaHJlZiA9IFwiXCI7XG4gICAgICAgIGlmIChydWxlLnVybC5zdGFydHNXaXRoKFwicGRcIikpIHtcbiAgICAgICAgICAgIGhyZWYgPSBldmFsKHJ1bGUudXJsKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGhyZWYgPSBwZChpdGVtLCBydWxlLnVybCk7XG4gICAgICAgIH1cbiAgICAgICAgaHJlZiA9IHJ1bGUuaW10ID8gaHJlZiArIFwiI2ltbWVyc2l2ZVRoZW1lI1wiIDogaHJlZjtcbiAgICAgICAgcmV0dXJuIGhyZWY7XG4gICAgfSxcbiAgICBzZXRDb250ZW50OiBmdW5jdGlvbihpdGVtLCBpbnB1dCkge1xuICAgICAgICBsZXQgb3V0cHV0ID0gXCJcIjtcbiAgICAgICAgaWYgKGlucHV0ID09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgcmV0dXJuIG91dHB1dDtcbiAgICAgICAgfVxuICAgICAgICBpZiAoaW5w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GVt5YaF5a65OlxcclxcbicgKyBpdGVtICsgJ1xcclxcbicgK1xuICAgICAgICAgICAgYFxcblxcdHRpdGxl5a6a5L2NOiAgJHtydWxlLnRpdGxlfSAgLS0tPiDnu5Pmnpw6ICAke29iai50aXRsZX1gICtcbiAgICAgICAgICAgIGBcXG5cXHRkZXNj5a6a5L2NOiAgJHtydWxlLmRlc2N9ICAtLS0+IOe7k+aenDogICR7b2JqLmRlc2N9YCArXG4gICAgICAgICAgICBgXFxuXFx0aW1n5a6a5L2NOiAgJHtydWxlLmltZ30gIC0tLT4g57uT5p6cOiAgJHtvYmouaW1nfWAgK1xuICAgICAgICAgICAgKHJ1bGUuY29udGVudCAhPSB1bmRlZmluZWQgPyBgXFxuXFx0Y29udGVudOWumuS9jTogICR7cnVsZS5jb250ZW50fSAgLS0tPiDnu5Pmnpw6ICAke29iai5jb250ZW50fWAgOiAnJykgK1xuICAgICAgICAgICAgYFxcblxcdHVybOWumuS9jTogICR7cnVsZS51cmx9ICAtLS0+IOe7k+aenDogICR7b2JqLnVybH1gXG4gICAgICAgICk7XG4gICAgICAgIGxvZygnLS0tLS0tLS0tLScgKyAoaSArIDEpICsgJzrosIPor5Xnu5PmnZ8tLS0tLS0tLS0tJyk7XG4gICAgfSxcbiAgICBqc29uTGlzdDogZnVuY3Rpb24oYXJyLCBqc29uLCBydWxlKSB7XG4gICAgICAgIGlmIChqc29uLmNvbnN0cnVjdG9yICE9IE9iamVjdCkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShqc29uKTtcbiAgICAgICAgICAgIH0gY2F0Y2gge31cbiAgICAgICAgfVxuICAgICAgICBpZiAoanNvbltydWxlLmxpc3RdID09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgYXJyLnB1c2goe1xuICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdPGZvbnQgY29sb3I9XCJncmV5XCI+PHNtYWxsPuaXoOWGheWuuTwvc21hbGw+PC9mb250PicsXG4gICAgICAgICAgICAgICAgdXJsOiBcImhpa2VyOi8vZW1wdHlcIixcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJ0ZXh0X2NlbnRlcl8xXCIsXG4gICAgICAgICAgICAgICAgZXh0cmE6IHt9LFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGRlYnVnID0gdGhpcy5nZXRCb29sZWFuVmFsdWUocnVsZS5kZWJ1ZywgZmFsc2UpO1xuICAgICAgICB2YXIgZW1wdHkgPSB0aGlzLmdldEJvb2xlYW5WYWx1ZShydWxlLmVtcHR5KTtcbiAgICAgICAgaWYgKGRlYnVnKSB7XG4gICAgICAgICAgICBsb2coJ+WumuS9jeWIl+ihqDonICsgcnVsZS5saXN0KTtcbiAgICAgICAgfVxuICAgICAgICBqc29uW3J1bGUubGlzdF0uZm9yRWFjaCgoaXRlbSwgaSkgPT4ge1xuICAgICAgICAgICAgdmFyIHRpdGxlID0gZXZhbChydWxlLnRpdGxlKTtcbiAgICAgICAgICAgIHZhciBkZXNjID0gZXZhbChydWxlLmRlc2MpO1xuICAgICAgICAgICAgdmFyIGNvbnRlbnQgPSBldmFsKHJ1bGUuY29udGVudCk7XG4gICAgICAgICAgICB2YXIgaW1nID0gZXZhbChydWxlLmltZykgKyBydWxlLnJlZjtcbiAgICAgICAgICAgIHZhciBocmVmID0gZXZhbChydWxlLnVybCk7XG4gICAgICAgICAgICB2YXIgdXJsID0gcnVsZS5pbXQgPyBocmVmICsgXCIjaW1tZXJzaXZlVGhlbWUjXCIgOiBocmVmO1xuICAgICAgICAgICAgdmFyIGxhenkgPSBydWxlLmxhenkgPyBydWxlLmxhenkgOiBcIlwiO1xuXG4gICAgICAgICAgICB2YXIgZGQgPSB7XG4gICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxuICAgICAgICAgICAgICAgIGRlc2M6IGRlc2MsXG4gICAgICAgICAgICAgICAgY29udGVudDogY29udGVudCxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBpbWcsXG4gICAgICAgICAgICAgICAgdXJsOiAoZW1wdHkgPyBcImhpa2VyOi8vZW1wdHkjI1wiIDogJycpICsgdXJsLFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBydWxlLmNvbF90eXBlLFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgIGltZzogaW1nLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICBpZiAoZGVidWcpIHtcbiAgICAgICAgICAgICAgICB2YXIgcnggPSB7XG4gICAgICAgICAgICAgICAgICAgIHRpdGxlLFxuICAgICAgICAgICAgICAgICAgICBkZXNjLFxuICAgICAgICAgICAgICAgICAgICBpbWcsXG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgIHVybFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgdGhpcy5kZWJ1Z2xvZyhpLCBpdGVtLCBydWxlLCByeCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChsYXp5ICE9IFwiXCIpIHtcbiAgICAgICAgICAgICAgICBkZFtcInVybFwiXSA9IGhyZWYgKyBsYXp5O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYXJyLnB1c2goZGQpO1xuICAgICAgICB9KTtcbiAgICB9LFxuICAgIHJ1bGVMaXN0OiBmdW5jdGlvbihhcnIsIGh0bWwsIHJ1bGUpIHtcbiAgICAgICAgdmFyIGxpc3QgPSBwZGZhKGh0bWwsXG4gICAgICAgICAgICBydWxlLmxpc3QpO1xuICAgICAgICB2YXIgZGVidWcgPSB0aGlzLmdldEJvb2xlYW5WYWx1ZShydWxlLmRlYnVnLFxuICAgICAgICAgICAgZmFsc2UpO1xuICAgICAgICB2YXIgZW1wdHkgPSB0aGlzLmdldEJvb2xlYW5WYWx1ZShydWxlLmVtcHR5KTtcbiAgICAgICAgaWYgKGRlYnVnKSB7XG4gICAgICAgICAgICBsb2coJ+WumuS9jeWIl+ihqDonICsgcnVsZS5saXN0KTtcbiAgICAgICAgfVxuICAgICAgICBsaXN0LmZvckVhY2goKGl0ZW0sIGkpID0+IHtcbiAgICAgICAgICAgIHZhciB0aXRsZSA9IHRoaXMuc2V0Q29udGVudChpdGVtLCBydWxlLnRpdGxlKTtcbiAgICAgICAgICAgIHZhciBkZXNjID0gdGhpcy5zZXRDb250ZW50KGl0ZW0sIHJ1bGUuZGVzYyk7XG4gICAgICAgIHZhciBkZXNjMCA9IHRoaXMuc2V0Q29udGVudChpdGVtLCBydWxlLmRlc2MwKTtcbiAgICAgICAgdmFyIGRlc2MxID0gdGhpcy5zZXRDb250ZW50KGl0ZW0sIHJ1bGUuZGVzYzEpO1xuICAgICAgICAgICAgdmFyIGltZyA9IHRoaXMuaW1nSGFuZGxlKGl0ZW0sIHJ1bGUpO1xuICAgICAgICAgICAgdmFyIHVybCA9IHRoaXMudXJsSGFuZGxlKGl0ZW0sIHJ1bGUpO1xuICAgICAgICAgICAgdmFyIGNvbnRlbnQgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS5jb250ZW50KTtcblxuICAgICAgICAgICAgaWYgKGRlYnVnKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJ4ID0ge1xuICAgICAgICAgICAgICAgICAgICB0aXRsZSxcbiAgICAgICAgICAgICAgICAgICAgZGVzYyxcbiAgICAgICAgICAgICAgICAgICAgaW1nLFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50LFxuICAgICAgICAgICAgICAgICAgICB1cmxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIHRoaXMuZGVidWdsb2coaSwgaXRlbSwgcnVsZSwgcngpO1xuICAgICAgICAgICAgfVxuICAgIC8vZGVzYzAgKyAnXFx0XFx0XFx0XFx0XFx0XFx0XFx0XFx0XFx0XFx0JyArIGRlc2MxICsgJ1xcdFxcdFxcdFxcdFxcdFxcdFxcdFxcdFxcdFxcdCcgKyBcbiAgICAgICAgICAgIC8vdmFyIGxhenkgPSBydWxlLmxhenkgPyBydWxlLmxhenkgOiBcIlwiO1xuICAgICAgICAgICAgdmFyIGRkID0ge1xuICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcbiAgICAgICAgICAgICAgICBkZXNjOiBkZXNjMCArICdcXHRcXHRcXHRcXHRcXHRcXHQnICsgZGVzYyxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBpbWcsXG4gICAgICAgICAgICAgICAgdXJsOiB1cmwgKyBsYXp5LFxuICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGNvbnRlbnQsXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IHJ1bGUuY29sX3R5cGUsXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgaW1nOiBpbWcsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAobGF6eSAhPSBcIlwiKSB7XG4gICAgICAgICAgICAgICAgZGRbXCJ1cmxcIl0gPSB1cmwgKyBsYXp5O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYXJyLnB1c2goZGQpO1xuICAgICAgICB9KTtcbiAgICB9LFxuICAgIExpc3Q6IGZ1bmN0aW9uKGFyciwgaHRtbCwgcnVsZSwgcGFyYW0pIHtcbiAgICAgICAgcGFyYW0gPSBwYXJhbSA/IHBhcmFtIDoge307XG4gICAgICAgIHZhciBhdXRvID0gcGFyYW0uYXV0byA/IHBhcmFtLmF1dG8gOiBmYWxzZTtcbiAgICAgICAgdmFyIHNob3cgPSBwYXJhbS5zaG93ID8gcGFyYW0uc2hvdyA6IGZhbHNlO1xuICAgICAgICBpZiAocGFnZSA9PSAxKSB7XG4gICAgICAgICAgICAvL3RoaXMuc3BhZ2Uuc2V0KHRydWVfdXJsKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnJlZnJlc2goKTtcbiAgICAgICAgdmFyIGRlYnVnID0gdGhpcy5nZXRCb29sZWFuVmFsdWUocnVsZS5kZWJ1ZywgZmFsc2UpO1xuICAgICAgICB2YXIgZW1wdHkgPSB0aGlzLmdldEJvb2xlYW5WYWx1ZShydWxlLmVtcHR5KTtcbiAgICAgICAgdmFyIGxpc3QgPSBwZGZhKGh0bWwsIHJ1bGUubGlzdCk7XG4gICAgICAgIGlmIChkZWJ1Zykge1xuICAgICAgICAgICAgbG9nKCflrprkvY3liJfooag6JyArIHJ1bGUubGlzdCk7XG4gICAgICAgIH1cbiAgICAgICAgLy9sb2codGhpcy5uZXh0UGFnZSgpKVxuICAgICAgICBpZiAoKHN0b3JhZ2UwLmdldE15VmFyKCd5aV9pc25leHQnLCAndCcpID09ICd0JyAmJiBsaXN0Lmxlbmd0aCA+IDApIHx8IHBhZ2UgPT0gMSkge1xuICAgICAgICAgICAgbGlzdC5mb3JFYWNoKChpdGVtLCBpKSA9PiB7XG4gICAgICAgICAgICAgICAgZGVsZXRlSXRlbShcInBhZ2VudW1cIik7XG4gICAgICAgICAgICAgICAgZGVsZXRlSXRlbShcInBhZ2VsaW5lXCIpO1xuICAgICAgICAgICAgICAgIHZhciBpZCA9IFwiXCI7XG4gICAgICAgICAgICAgICAgdmFyIGNscyA9IFwiXCI7XG4gICAgICAgICAgICAgICAgdmFyIHRpdGxlID0gdGhpcy5zZXRDb250ZW50KGl0ZW0sIHJ1bGUudGl0bGUpO1xuICAgICAgICAgICAgICAgIHZhciBkZXNjID0gdGhpcy5zZXRDb250ZW50KGl0ZW0sIHJ1bGUuZGVzYyk7XG4gICAgICAgIHZhciBkZXNjMCA9IHRoaXMuc2V0Q29udGVudChpdGVtLCBydWxlLmRlc2MwKTtcbiAgICAgICAgdmFyIGRlc2MxID0gdGhpcy5zZXRDb250ZW50KGl0ZW0sIHJ1bGUuZGVzYzEpO1xuICAgICAgICAgICAgICAgIHZhciBpbWcgPSB0aGlzLmltZ0hhbmRsZShpdGVtLCBydWxlKTtcbiAgICAgICAgICAgICAgICB2YXIgdXJsID0gdGhpcy51cmxIYW5kbGUoaXRlbSwgcnVsZSk7XG4gICAgICAgICAgICAgICAgdmFyIGNvbnRlbnQgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS5jb250ZW50KTtcblxuICAgICAgICAgICAgICAgIGlmIChkZWJ1Zykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgcnggPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlc2MsXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWcsXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsXG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZGVidWdsb2coaSwgaXRlbSwgcnVsZSwgcngpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChpID09IGxpc3QubGVuZ3RoIC0gMSkge1xuICAgICAgICAgICAgICAgICAgICBpZCA9IFwibGFzdGlkX1wiICsgcGFnZTtcbiAgICAgICAgICAgICAgICAgICAgY2xzID0gXCJsYXN0bWFya1wiO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IGRlc2MsXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGltZyxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiAoZW1wdHkgPyBcImhpa2VyOi8vZW1wdHkjI1wiIDogJycpICsgdXJsICsgJyMjZnlwYWdlQHJ1bGU9anM6JC5yZXF1aXJlKFwieWlqaVwiKScsXG4gICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IGNvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBydWxlLmNvbF90eXBlLFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW1nOiBpbWcsXG4gICAgICAgICAgICAgICAgICAgICAgICBpZDogaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICBjbHM6IGNscyxcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBpZiAoaSA9PSBsaXN0Lmxlbmd0aCAtIDEgJiYgc2hvdykge1xuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwibGluZVwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogXCJwYWdlbGluZVwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcIuKAnOKAnOKAneKAnTxzbWFsbD7liqDovb3kuK0uLi48L3NtYWxsPlwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBcImhpa2VyOi8vZW1wdHlcIixcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcInRleHRfY2VudGVyXzFcIixcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IFwicGFnZW51bVwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB1cGRhdGVJdGVtKFwicGFnZW51bVwiLCB7XG4gICAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ08Zm9udCBjb2xvcj1cImdyZXlcIj48c21hbGw+5Yiw5bqV5LqGPC9zbWFsbD48L2ZvbnQ+JyxcbiAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9lbXB0eVwiLFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcInRleHRfY2VudGVyXzFcIixcbiAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICBpZDogXCJsYXN0XCIsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGlmIChsaXN0Lmxlbmd0aCA9PSAwICYmIHBhZ2UgPT0gMSkge1xuICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJsaW5lXCIsXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGQucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ08Zm9udCBjb2xvcj1cImdyZXlcIj48c21hbGw+5peg5YaF5a65PC9zbWFsbD48L2ZvbnQ+JyxcbiAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9lbXB0eVwiLFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcInRleHRfY2VudGVyXzFcIixcbiAgICAgICAgICAgICAgICBleHRyYToge30sXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5uZXh0UGFnZSgpKSB7XG4gICAgICAgICAgICAvL2xvZygndCcpO1xuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ3lpX2lzbmV4dCcsICd0Jyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvL2xvZygnZicpO1xuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoJ3lpX2lzbmV4dCcsICdmJyk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGF1dG8pIHtcbiAgICAgICAgICAgIC8vY3JlYXRlTmV4dFBhZ2UoKTtcbiAgICAgICAgICAgIGF1dG9QYWdlKCk7XG4gICAgICAgIH1cbiAgICB9LFxufTtcblxudmFyIGV4dE1ldGhvZCA9IHtcbiAgICBUb1BhcmFtczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBqc29uID0gYXJndW1lbnRzWzBdO1xuICAgICAgICByZXR1cm4gT2JqZWN0LmtleXMoanNvbilcbiAgICAgICAgICAgIC5tYXAoKGtleSkgPT4ga2V5ICsgXCI9XCIgKyBqc29uW2tleV0pXG4gICAgICAgICAgICAuam9pbihcIiZcIik7XG4gICAgfSxcbiAgICB1cmxQYXJzZTogZnVuY3Rpb24odSkge1xuICAgICAgICB2YXIgZGljdCA9IHt9O1xuICAgICAgICBkaWN0LlNvdXJjZSA9IHU7XG4gICAgICAgIGxldCBwYXJhbXMgPSAodXJsKSA9PiB7XG4gICAgICAgICAgICBsZXQgcXVlcnlQYXJhbXMgPSB7fTtcbiAgICAgICAgICAgIGxldCByZWcgPSAvKFtePz0mXSspPShbXj89Jl0rKS9nO1xuICAgICAgICAgICAgdXJsLnJlcGxhY2UocmVnLCBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICBxdWVyeVBhcmFtc1thcmd1bWVudHNbMV1dID0gYXJndW1lbnRzWzJdO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm4gcXVlcnlQYXJhbXM7XG4gICAgICAgIH07XG4gICAgICAgIHZhciBqYXZhVXJsID0gSmF2YUltcG9ydGVyKGphdmEubmV0LlVSTCk7XG4gICAgICAgIHdpdGgoamF2YVVybCkge1xuICAgICAgICAgICAgdmFyIHVybCA9IG5ldyBVUkwodSk7XG4gICAgICAgICAgICBkaWN0LlByb3RvY29sID0gdXJsLmdldFByb3RvY29sKCk7XG4gICAgICAgICAgICBkaWN0Lkh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gICAgICAgICAgICAgICAgaW5kZXg6IGksXG4gICAgICAgICAgICAgICAgICAgIHMxOiBzdHIxW2ldLFxuICAgICAgICAgICAgICAgICAgICBzMjogc3RyMltpXSxcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZGlmZkNoYXJzO1xuICAgIH0sXG4gICAgcmVwbGFjZUNoYXJBdDogZnVuY3Rpb24oc3RyLCBpbmRleCwgcmVwbGFjZW1lbnQpIHtcbiAgICAgICAgaWYgKGluZGV4IDwgMCB8fCBpbmRleCA+PSBzdHIubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gc3RyO1xuICAgICAgICB9XG4gICAgICAgIC8vbG9nKGluZGV4KVxuICAgICAgICBjb25zdCBhcnIgPSBzdHIuc3BsaXQoXCJcIik7XG4gICAgICAgIGFycltpbmRleF0gPSByZXBsYWNlbWVudDtcbiAgICAgICAgcmV0dXJuIGFyci5qb2luKFwiXCIpO1xuICAgIH0sXG4gICAgZ2V0T2JqZWN0S2V5c0RpZmY6IGZ1bmN0aW9uKG9iajEsIG9iajIpIHtcbiAgICAgICAgY29uc3QgZGlmZmVyZW50S2V5cyA9IFtdO1xuICAgICAgICBmb3IgKGxldCBrZXkgaW4gb2JqMSkge1xuICAgICAgICAgICAgaWYgKCFvYmoyLmhhc093blByb3BlcnR5KGtleSkgfHwgb2JqMVtrZXldICE9PSBvYmoyW2tleV0pIHtcbiAgICAgICAgICAgICAgICBkaWZmZXJlbnRLZXlzLnB1c2goa2V5KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBmb3IgKGxldCBrZXkgaW4gb2JqMikge1xuICAgICAgICAgICAgaWYgKCFvYmoxLmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgICAgICAgICBkaWZmZXJlbnRLZXlzLnB1c2goa2V5KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1c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kZXgoU3RyaW5nKHUxLlBhdGgpLCBTdHJpbmcodTIuUGF0aCkpO1xuICAgICAgICAgICAgICAgIGlmIChkdF9kZWJ1Zykge1xuICAgICAgICAgICAgICAgICAgICBsb2coZGYpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoZGYubGVuZ3RoID09IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHJlID0gZGZbMF0uaW5kZXg7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGYgPSBkZi5maWx0ZXIoKHgpID0+IC9cXGQrLy50ZXN0KHguczIpKTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHJlID0gZlswXS5pbmRleDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdmFyIGVxID0gdGhpcy5yZXBsYWNlQ2hhckF0KFN0cmluZyh1Mi5QYXRoKSwgcmUsIFwiZnlwYWdlXCIpO1xuICAgICAgICAgICAgICAgIG5leHR1cmwgPSB1Mi5Ib3N0cyArIGVxICsgY2EgKyB0aGlzLlRvUGFyYW1zKHUyLlBhcmFtcyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHZhciBlcCA9IHRoaXMuZ2V0T2JqZWN0S2V5c0RpZmYodTEuUGFyYW1zLCB1Mi5QYXJhbXMpXG4gICAgICAgICAgICAgICAgaWYgKGVwLmxlbmd0aCA9PSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIHUxLlBhcmFtc1tlcFswXV0gPSAnZnlwYWdlJ1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGxvZyhlcCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBlcSA9IFN0cmluZyh1MS5QYXRoKS5yZXBsYWNlKC9cXGQrLywgXCJmeXBhZ2VcIik7XG4gICAgICAgICAgICAgICAgbmV4dHVybCA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XG4gICAgICAgICAgICBsb2coXCLlj6/og73kuI3lrZjlnKjkuIvkuIDpobXmiJbogIXkuIvkuIDpobXlrprkvY3mnInpl67pophcIik7XG4gICAgICAgICAgICBuZXh0ID0gXCJcIjtcbiAgICAgICAgfVxuICAgICAgICBpZiAobmV4dCAhPSBcIlwiKSB7XG4gICAgICAgICAgICB2YXIgbnh1cmwgPSBleHRNZXRob2QuZ2V0TmV4dFVybCh0cnVlX3VybCwgbmV4dCwgb2JqKTtcbiAgICAgICAgICAgIC8vbG9nKFwibnh1cmw6XCIgKyBueHVybCk7XG4gICAgICAgICAgICBwdXRNeVZhcijnirbmgIEsIG54dXJsKTtcbiAgICAgICAgICAgIHB1dE15VmFyKFwieWlfcGFnZXVybFwiLCBueHVybCk7XG4gICAgICAgIH1cbiAgICB9XG59XG5cbmZ1bmN0aW9uIGF1dG9QYWdlKCkge1xuICAgIGlmIChwYWdlID09IDEpIHtcbiAgICAgICAgcHV0TXlWYXIoXCJ5aV9maXJzdHBhZ2VcIiwgdHJ1ZV91cmwpO1xuICAgIH1cbiAgICB0cnkge1xuICAgICAgICB2YXIgbmV4dCA9IGV2YWwo5LiL5LiA6aG1KTtcbiAgICAgICAgLy9sb2coXCJuZXh0XCIpO1xuICAgICAgICAvL2xvZygnbmV4dDonK25leHQpO1xuICAgIH0gY2F0Y2gge1xuICAgICAgICBsb2coXCLlj6/og73kuI3lrZjlnKjkuIvkuIDpobXmiJbogIXkuIvkuIDpobXlrprkvY3mnInpl67pophcIik7XG4gICAgICAgIG5leHQgPSBcIlwiO1xuICAgIH1cbiAgICBpZiAobmV4dCAhPSBcIlwiKSB7XG4gICAgICAgIHB1dE15VmFyKOeKtuaAgSwgbmV4dCk7XG4gICAgfVxufSJ9LHsiY29sX3R5cGUiOiJtb3ZpZV8zIiwibmFtZSI6Iuino+aekCIsInBhdGgiOiJsYXp5IiwicnVsZSI6InZhciBsYXp5ID0gJCgnJykubGF6eVJ1bGUoKCkgPT4ge1xuICAgICAgICA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mEoY29udHNbaV0sICdib2R5JiYudm9kJyk7IFxuICAgICBkLnB1c2goe1xuICAgICAgICB0aXRsZTogJzxtaWRkbGU+PGZvbnQgY29sb3I9I0ZGQTUwMD4nK3BkZmgodGFic1tpXSwgJ1RleHQnKSsnPC9mb250PjwvbWlkZGxlPicsXG4gICAgICAgIGltZzogJ2h0dHBzOi8vdGh1bWJzbmFwLmNvbS9pL2g4Mm96UllkLnBuZycsXG4gICAgICAgIHVybDogJ2hpa2VyOi8vZW1wdHknLFxuICAgICAgICAvL3VybDogcGQodGFic1tpXSwnYSYmaHJlZicpICsgJyMjZnlwYWdlQHJ1bGU9anM6JC5yZXF1aXJlKFwic3hcIiknLFxuICAgICAgICBjb2xfdHlwZTogXCJhdmF0YXJcIixcbiAgICAgICAgZXh0cmE6IHtsaW5lVmlzaWJsZTpmYWxzZX1cbiAgICB9KTtcblxuICAgICAgICBmb3IgKHZhciBqID0gMDsgaiA8IChsaXN0Lmxlbmd0aC1saXN0Lmxlbmd0aCUyKTsgaisrKSB7ICAgICAgIFxuICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICB0aXRsZTogcGRmaChsaXN0W2pdLCAnLnZvZC10eHQmJlRleHQnKSxcbiAgICAgICAgICAgICAgICBkZXNjOiBwZGZoKGxpc3Rbal0sICcudGltZSYmVGV4dCcpLFxuICAgICAgICAgICAgICAgIGltZzogcGQobGlzdFtqXSwnaW1nfHxhJiZzcmMnKSxcbiAgICAgICAgICAgICAgICB1cmw6IHBkKGxpc3Rbal0sICdhJiZocmVmJykucmVwbGFjZShcImluZm9cIixcInBsYXlcIikgKyBsYXp5LFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAnbW92aWVfMicsICAgICAgICAgICAgICBcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfSJ9XSwiYXNzb2NpYXRlZE1vZGVsc01hcEZvckpvaW5UYWJsZSI6e30sImFzc29jaWF0ZWRNb2RlbHNNYXBXaXRoR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FhZDE5XFxcIikgKyBcXFwiPC9iPlxcXCIsXFxuICAgICAgICDlsZXlvIA6IFxcXCLigJzigJzigJ3igJ08Yj5cXFwiICsgXFxcIuKIqFxcXCIuZm9udGNvbG9yKFxcXCIjRkYwMDAwXFxcIikgKyBcXFwiPC9iPlxcXCIsXFxuICAgICAgICBvcGVuOiB0cnVlLFxcbiAgICAgICAgc3RhdGU6IE1ZX1JVTEUudXJsLFxcbiAgICAgICAgc2VhcmNoOiBmYWxzZSxcXG4gICAgICAgIGNsZWFyczogW10sXFxuICAgICAgICBjbGVhcmFsbDogW1xcXCJ5aV9maXJzdHBhZ2VcXFwiXSxcXG4gICAgICAgIGRlYnVnOiBmYWxzZSxcXG5cXG4gICAgICAgIOmihOiuvihwYXJhbSkge1xcbiAgICAgICAgICAgIGlmIChwYXJhbSA9PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICAgICAgcGFyYW0gPSBbXTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgT2JqZWN0LmtleXMocGFyYW0pLmZvckVhY2goKHByb3BlcnR5KSA9PiB7XFxuICAgICAgICAgICAgICAgIC8vIOWvueavj+S4quWxnuaAp+WQjeaJp+ihjOaTjeS9nFxcbiAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHBhcmFtW3Byb3BlcnR5XTsgLy8g6I635Y+W5bGe5oCn5YC8XFxuICAgICAgICAgICAgICAgIC8vIOWcqOi/memHjOaJp+ihjOaCqOeahOaTjeS9nFxcbiAgICAgICAgICAgICAgICB0aGlzW3Byb3BlcnR5XSA9IHZhbHVlO1xcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5kZWJ1Zykge1xcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2cocHJvcGVydHkgKyBcXFwiOlxcXCIgKyB2YWx1ZSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0sXFxuICAgICAgICBldmFsSlNSdWxlKGl0ZW0sXFxuICAgICAgICAgICAganNSdWxlKSB7XFxuICAgICAgICAgICAgbGV0IHJ1bGUgPSBqc1J1bGUucmVwbGFjZShcXFwiQGpzOlxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBydWxlID0gcnVsZS50cmltKCk7XFxuICAgICAgICAgICAgLy9sb2coJC5zdHJpbmdpZnkocnVsZSkpXFxuICAgICAgICAgICAgbGV0IGlucHV0ID0gaXRlbTtcXG4gICAgICAgICAgICBpZiAocnVsZS5zdGFydHNXaXRoKFxcXCIoXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgZXZhbChcXFwicmVzdWx0ID0gXFxcIiArIHJ1bGUpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIC8qKlxcbiAgICAgICAgICAgICAgICAgKiDov5jljp/miJAgJC50b1N0cmluZyguLi4pIOeahOacgOe7iOe7k+aenO+8jOi+vuWIsOacgOe7iOWkhOeQhuaWueW8j+i3n+S4iumdoueahCBpZiDkuIDoh7TnmoTnm67nmoRcXG4gICAgICAgICAgICAgICAgICovXFxuICAgICAgICAgICAgICAgIGV2YWwoXFxcInJlc3VsdCA9IFxcXCIgKyBcXFwiKCgpID0+IHtcXFwiICsgcnVsZSArIFxcXCJ9KSgpXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiByZXN1bHQgfHwgXFxcIlxcXCI7XFxuICAgICAgICB9LFxcbiAgICAgICAgZ2V0VGl0bGUoc3JjLCBjYXRlZ29yeSkge1xcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIGxldCB0aXRsZVJ1bGUgPSBjYXRlZ29yeSB8fCBcXFwiYSYmVGV4dFxcXCI7XFxuICAgICAgICAgICAgaWYgKHRpdGxlUnVsZS5zdGFydHNXaXRoKFxcXCJAanM6XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgdGl0bGUgPSB0aGlzLmV2YWxKU1J1bGUoc3JjLCB0aXRsZVJ1bGUpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHRpdGxlID0gcGFyc2VEb21Gb3JIdG1sKHNyYywgdGl0bGVSdWxlKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHRpdGxlIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGdldFVybChzcmMsIGNhdGVnb3J5KSB7XFxuICAgICAgICAgICAgbGV0IHVybCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIGxldCB1cmxSdWxlID0gY2F0ZWdvcnku6ZO+5o6lIHx8IFxcXCJhJiZocmVmXFxcIjtcXG4gICAgICAgICAgICBpZiAodXJsUnVsZS5zdGFydHNXaXRoKFxcXCJAanM6XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gdGhpcy5ldmFsSlNSdWxlKHNyYywgdXJsUnVsZSk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gcGQoc3JjLCB1cmxSdWxlKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHR5cGVvZiBjYXRlZ29yeS7pk77mjqXlpITnkIYgPT0gXFxcImZ1bmN0aW9uXFxcIikge1xcbiAgICAgICAgICAgICAgICB1cmwgPSBjYXRlZ29yeS7pk77mjqXlpITnkIYodXJsKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHVybCB8fCBcXFwiXFxcIjtcXG4gICAgICAgIH0sXFxuICAgICAgICBpc051bGwocGFyYW0pIHtcXG4gICAgICAgICAgICBpZiAocGFyYW0gPT0gbnVsbCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGlzQm9vbGVhbih2YXJpYWJsZSkge1xcbiAgICAgICAgICAgIGlmICh0eXBlb2YgdmFyaWFibGUgIT09IFxcXCJib29sZWFuXFxcIikge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIuW8gOWQr+aKmOWPoOivt+S8oOWFpeW4g+WwlOWAvFxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgICDmuIXpmaQobGlzdCkge1xcbiAgICAgICAgICAgIGlmICh0aGlzLmlzTnVsbChsaXN0KSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGxpc3QuY29uc3RydWN0b3IgPT0gU3RyaW5nKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5riF6Zmk5oql6ZSZOuivt+S8oOWIl+ihqFxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB0aGlzLmNsZWFycyA9IGxpc3Q7XFxuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgICAgICB9LFxcbiAgICAgICAg5YWo5riFKGxpc3QpIHtcXG4gICAgICAgICAgICBpZiAodGhpcy5pc051bGwobGlzdCkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHZhciBjID0gdGhpcy5jbGVhcmFsbDtcXG4gICAgICAgICAgICBsaXN0ID0gYy5jb25jYXQobGlzdCk7XFxuICAgICAgICAgICAgdGhpcy5jbGVhcmFsbCA9IGxpc3Q7XFxuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgICAgICB9LFxcbiAgICAgICAg5rqQ56CBKGlucHV0KSB7XFxuICAgICAgICAgICAgdGhpcy5odG1sID0gaW5wdXQ7XFxuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgICAgICB9LFxcbiAgICAgICAg55WM6Z2iKGlucHV0KSB7XFxuICAgICAgICAgICAgdGhpcy5sYXlvdXQgPSBpbnB1dDtcXG4gICAgICAgICAgICByZXR1cm4gdGhpcztcXG4gICAgICAgIH0sXFxuICAgICAgICDpobXnoIEoaW5wdXQpIHtcXG4gICAgICAgICAgICB0aGlzLnBhZ2UgPSBpbnB1dDtcXG4gICAgICAgICAgICByZXR1cm4gdGhpcztcXG4gICAgICAgIH0sXFxuICAgICAgICDnirbmgIEoaW5wdXQpIHtcXG4gICAgICAgICAgICB0aGlzLnN0YXRlID0gaW5wdXQ7XFxuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgICAgICB9LFxcbiAgICAgICAg5byA5ZCv5pCc57SiKGlucHV0KSB7XFxuICAgICAgICAgICAgaWYgKGlucHV0ID09IHVuZGVmaW5lZCkge1xcbiAgICAgICAgICAgICAgICBpbnB1dCA9IHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRoaXMuc2VhcmNoID0gaW5wdXQ7XFxuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XFxuICAgICAgICB9LFxcbiAgICAgICAg5byA5ZCv5oqY5Y+gKGlucHV0KSB7XFxuICAgICAgICAgICAgaWYgKGlucHV0ID09IHVuZGVmaW5lZCkge1xcbiAgICAgICAgICAgICAgICBpbnB1dCA9IHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRoaXMuaXNCb29sZWFuKGlucHV0KTtcXG4gICAgICAgICAgICB0aGlzLm9wZW4gPSBpbnB1dDtcXG4gICAgICAgICAgICByZXR1cm4gdGhpcztcXG4gICAgICAgIH0sXFxuICAgICAgICBzZXRUaXRsZShrLCBpLCB0KSB7XFxuICAgICAgICAgICAgcmV0dXJuIGsgPT0gaSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgdC5mb250Y29sb3IodGhpcy7liIbnsbvpopzoibIpIDogdDtcXG4gICAgICAgIH0sXFxuICAgICAgICBhY3Rpb24ob2JqKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5riF6Zmk54q25oCBXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKG9iaikgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKG9iaik7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKG9iai5zdGF0ZSk7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJoZWFkLmNhdGVcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoJ2NhdGVfYnV0dG9uJyk7XFxuICAgICAgICAgICAgICAgICAgICBvYmouYWxsLmZvckVhY2goKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKGl0ZW0pO1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICBvYmouY2wuZm9yRWFjaCgoaXRlbSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0sIG9iaiksXFxuICAgICAgICAgICAgfSwgXTtcXG4gICAgICAgIH0sXFxuICAgICAgICBjaGVja1BhcmFtKCkge1xcbiAgICAgICAgICAgIHZhciBvYmogPSB7fTtcXG4gICAgICAgICAgICBpZiAodGhpcy5wYWdlID09IDAgJiYgdHlwZW9mIHBhZ2UgPT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLor7fkvKDlhaXpobXnoIFcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHBhZ2UgPT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIG9ialtcXFwi6aG156CBXFxcIl0gPSB0aGlzLnBhZ2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmpbXFxcIumhteeggVxcXCJdID0gcGFnZTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAodGhpcy5odG1sID09IFxcXCJlbXB0eVxcXCIgJiYgdHlwZW9mIGh0bWwgPT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLor7fkvKDlhaXmupDnoIFcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGh0bWwgPT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIG9ialtcXFwi5rqQ56CBXFxcIl0gPSB0aGlzLmh0bWw7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmpbXFxcIua6kOeggVxcXCJdID0gaHRtbDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAodGhpcy5sYXlvdXQgPT0gXFxcInVuZGVmaW5lZFxcXCIgJiYgdHlwZW9mIGQgPT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLor7fkvKDlhaXnlYzpnaJcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGQgPT0gXFxcInVuZGVmaW5lZFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIG9ialtcXFwi55WM6Z2iXFxcIl0gPSB0aGlzLmxheW91dDtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIG9ialtcXFwi55WM6Z2iXFxcIl0gPSBkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICB9LFxcbiAgICAgICAg5Yib5bu65Yqo5oCB5YiG57G7KHJ1bGVPYmopIHtcXG4gICAgICAgICAgICBsZXQgaXRlbXMgPSBbXTtcXG4gICAgICAgICAgICBsZXQgY2F0ZXMgPSBbXTtcXG4gICAgICAgICAgICBpZiAocnVsZU9iaiA9PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICAgICAgcnVsZU9iaiA9IFtdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAvL+WIneWni+WMluWPmOmHj+W8gOWni1xcbiAgICAgICAgICAgIGNvbnN0IHBhcmFtID0gdGhpcy5jaGVja1BhcmFtKCk7XFxuICAgICAgICAgICAgY29uc3QgcGFnZSA9IHBhcmFtLumhteeggTtcXG4gICAgICAgICAgICBjb25zdCBodG1sID0gcGFyYW0u5rqQ56CBO1xcbiAgICAgICAgICAgIGNvbnN0IGQgPSBwYXJhbS7nlYzpnaI7XFxuICAgICAgICAgICAgY29uc3Qg54q25oCBID0gdGhpcy5zdGF0ZTtcXG4gICAgICAgICAgICBjb25zdCBzZWFyY2ggPSB0aGlzLnNlYXJjaDtcXG4gICAgICAgICAgICBjb25zdCBlbXB0eSA9IFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICBjb25zdCDmipjlj6DnirbmgIEgPSB0aGlzLm9wZW47XFxuICAgICAgICAgICAgdmFyIOWxleW8gCA9IHRoaXMu5bGV5byAO1xcbiAgICAgICAgICAgIHZhciDmipjlj6AgPSB0aGlzLuaKmOWPoDtcXG4gICAgICAgICAgICB2YXIg5YWo5riFID0gdGhpcy5jbGVhcmFsbDtcXG4gICAgICAgICAgICB2YXIg5riF6ZmkID0gdGhpcy5jbGVhcnM7XFxuICAgICAgICAgICAgLy/liJ3lp4vljJblj5jph4/nu5PmnZ9cXG4gICAgICAgICAgICBsZXQgaW5pdF9jYXRlID0gbmV3IEFycmF5KDIwKS5maWxsKFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgY29uc3QgZm9sZCA9IGdldE15VmFyKE1ZX1JVTEUuZ3JvdXAsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgY29uc3QgY2F0ZV90ZW1wID0gSlNPTi5wYXJzZShcXG4gICAgICAgICAgICAgICAgZ2V0TXlWYXIoXFxcImhlYWQuY2F0ZVxcXCIsIEpTT04uc3RyaW5naWZ5KGluaXRfY2F0ZSkpXFxuICAgICAgICAgICAgKTtcXG4gICAgICAgICAgICBpZiAoc2VhcmNoICYmIHBhZ2UgPT0gMSkge1xcbiAgICAgICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi8J+UjlxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IFxcXCInaGlrZXI6Ly9zZWFyY2g/cnVsZT1cXFwiICsgTVlfUlVMRS50aXRsZSArIFxcXCImcz0nK2lucHV0XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGRlc2M6IFxcXCLmkJzntKLlhbPplK7or41cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogZ2V0TXlWYXIoXFxcImtleXdvcmRcXFwiLCBcXFwiXFxcIiksXFxuICAgICAgICAgICAgICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwia2V5d29yZFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBjb25zdCBjYXRlZ29yaWVzID0gW107XFxuICAgICAgICAgICAgcnVsZU9iai5mb3JFYWNoKCh4KSA9PiB7XFxuICAgICAgICAgICAgICAgIHZhciBsaXN0ID0gW107XFxuICAgICAgICAgICAgICAgIC8vbG9nKHgpXFxuICAgICAgICAgICAgICAgIGlmICh4Lmpzb24gIT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgICAgICAgICAgICB4Lmpzb24ubWFwKGsgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhdGVnb3JpZXMucHVzaChKU09OLnN0cmluZ2lmeShrKS5yZXBsYWNlKC9eXFxcXFt8XFxcXF0kL2csICcnKSlcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAvL2NhdGVnb3JpZXMucHVzaCh4Lmpzb24pXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHgu5LiA57qn5a6a5L2NKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoeC7kuIDnuqflrprkvY0uc3RhcnRzV2l0aChcXFwiQGpzOlxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGlzdCA9IHRoaXMuZXZhbEpTUnVsZShodG1sLCB4LuS4gOe6p+WumuS9jSk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxpc3QgPSBwZGZhKGh0bWwsIHgu5LiA57qn5a6a5L2NKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAoeC7lpKfnsbvlrprkvY0pIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh4LuWkp+exu+WumuS9jS5zdGFydHNXaXRoKFxcXCJAanM6XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsaXN0ID0gdGhpcy5ldmFsSlNSdWxlKGh0bWwsIHgu5aSn57G75a6a5L2NKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGlzdCA9IFtwZGZhKGh0bWwsIHgu5aSn57G75a6a5L2NKS5qb2luKCdcXFxcbicpXTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICAvLy0t6aKd5aSW5aSE55CGLS1cXG4gICAgICAgICAgICAgICAgdmFyIOS4gOe6pyA9IGxpc3QubWFwKChzKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgc2xpc3QgPSBbXTtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghKFxcXCLlsI/nsbtcXFwiIGluIHgpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgeC7lsI/nsbsgPSBcXFwiYm9keSYmYTpub3QoOm1hdGNoZXMo6aaW6aG1KSk6bm90KGE6bm90KFtocmVmXSkpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGlmICh4LuWwj+exuy5zdGFydHNXaXRoKFxcXCJAanM6XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzbGlzdCA9IHRoaXMuZXZhbEpTUnVsZShzLCB4LuWwj+exuyk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNsaXN0ID0gcGRmYShzLCB4LuWwj+exuyk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAvLy0t6aKd5aSW5aSE55CGLS1cXG4gICAgICAgICAgICAgICAgaWYgKCgn5aKe5YqgJyBpbiB4KSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHgu5aKe5YqgLmNvbnN0cnVjdG9yID09IFN0cmluZykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHgu5aKe5YqgID0gZXZhbCh4LuWinuWKoCk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBzbGlzdCA9IHgu5aKe5YqgLmNvbmNhdChzbGlzdCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKCgn6KGl5YWFJyBpbiB4KSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHgu6KGl5YWFLmNvbnN0cnVjdG9yID09IFN0cmluZykge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHgu6KGl5YWFID0gZXZhbCh4LuihpeWFhSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBzbGlzdCA9IHNsaXN0LmNvbmNhdCh4LuihpeWFhSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgICAgICB2YXIg5a6a5L2NID0gc2xpc3QubWFwKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRpdGxlID0gdGhpcy5nZXRUaXRsZShpdGVtLCB4Luagh+mimCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHVybCA9IHRoaXMuZ2V0VXJsKGl0ZW0sIHgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmogPSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShvYmopO1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4g5a6a5L2NO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgLy9sb2co5LiA57qnKVxcbiAgICAgICAgICAgICAgICAvL2xvZyjkuIDnuqcubGVuZ3RoKVxcbiAgICAgICAgICAgICAgICBpZiAo5LiA57qnLmxlbmd0aCA9PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBjYXRlZ29yaWVzLnB1c2go5LiA57qnLmpvaW4oXFxcIlxcXFxuXFxcIikpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAg5LiA57qnLmZvckVhY2goKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjYXRlZ29yaWVzLnB1c2goaXRlbS5qb2luKFxcXCIsXFxcIikpO1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZWdvcmllcylcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBpZiAo5oqY5Y+g54q25oCBKSB7XFxuICAgICAgICAgICAgICAgIGlmIChwYWdlID09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBmb2xkID09PSBcXFwiMVxcXCIgPyDmipjlj6AgOiDlsZXlvIAsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAodGl0bGUsIGZvbGQsIHUsIGFsbCwgZXhwcykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGZvbGQgPSBnZXRNeVZhcihNWV9SVUxFLmdyb3VwLCBmb2xkKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBb5bGV5byALCDmipjlj6BdID0gZXhwcztcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb2xkID09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgY3ggPSBmaW5kSXRlbXNCeUNscyh0aXRsZSArICdjYXRlX2J1dHRvbicpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdjYXRlX2J1dHRvbicsIGN4KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGVJdGVtQnlDbHModGl0bGUgKyAnY2F0ZV9idXR0b24nKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGN4ID0gc3RvcmFnZTAuZ2V0TXlWYXIoJ2NhdGVfYnV0dG9uJywgW10pLm1hcCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeFsnY29sX3R5cGUnXSA9IHhbJ2NvbF90eXBlJ10gPyB4Wydjb2xfdHlwZSddIDogeFsndHlwZSddO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIodGl0bGUgKyAnY2F0ZV9saW5lJywgY3gpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKmFsbC5mb3JFYWNoKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsqL1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh0aXRsZSArICdjYXRlX2V4cCcsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogZm9sZCA9PSAxID8g5bGV5byAIDog5oqY5Y+gLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKE1ZX1JVTEUuZ3JvdXAsIGZvbGQgPT09IFxcXCIxXFxcIiA/IFxcXCIwXFxcIiA6IFxcXCIxXFxcIik7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL3JlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1ZX1JVTEUudGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvbGQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIOeKtuaAgSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAg5YWo5riFLCBb5bGV5byALFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg5oqY5Y+gXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgJ2NhdGVfZXhwJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9uZ0NsaWNrOiB0aGlzLmFjdGlvbih7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZTog54q25oCBLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsOiDlhajmuIUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbDog5riF6ZmkLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHBhZ2UgPT0gMSkge1xcbiAgICAgICAgICAgICAgICBjYXRlZ29yaWVzLmZvckVhY2goKGNhdGVnb3J5LCBpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgLy9sb2coY2F0ZWdvcnkpXFxuICAgICAgICAgICAgICAgICAgICBsZXQgc3ViX2NhdGVnb3JpZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgICAgIC8qaWYgKOWwj+exu+WumuS9jS5pbmNsdWRlcyhcXFwiO1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHN1Yl9jYXRlZ29yaWVzID0gcGRmYShjYXRlZ29yeSwg5bCP57G75a6a5L2NLnNwbGl0KFxcXCI7XFxcIilbMF0pO1xcbiAgICAgICAgICAgICAgICAgICAgICBpZiAoc3ViX2NhdGVnb3JpZXMubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdWJfY2F0ZWdvcmllcyA9IHBkZmEoY2F0ZWdvcnksIOWwj+exu+WumuS9jS5zcGxpdChcXFwiO1xcXCIpWzFdKTtcXG4gICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsqL1xcbiAgICAgICAgICAgICAgICAgICAgLy9sb2coaW5kZXgpXFxuICAgICAgICAgICAgICAgICAgICBzdWJfY2F0ZWdvcmllcyA9IEpTT04ucGFyc2UoYFske2NhdGVnb3J5fV1gKTtcXG4gICAgICAgICAgICAgICAgICAgIC8vbG9nKHN1Yl9jYXRlZ29yaWVzKVxcbiAgICAgICAgICAgICAgICAgICAgLy8gc3ViX2NhdGVnb3JpZXMgPSBwZGZhKGNhdGVnb3J5LCDlsI/nsbvlrprkvY0pO1xcbiAgICAgICAgICAgICAgICAgICAgLy99XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAvL+Wkp+exu1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1Yl9jYXRlZ29yaWVzLmZvckVhY2goKGl0ZW0sIGtleSkgPT4ge1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xldCB0aXRsZSA9IHBkZmgoaXRlbSwgX+Wkp+exu+agh+mimCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0ZW0udGl0bGU7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Yg5o6S6ZmkICE9IFxcXCJ1bmRlZmluZWRcXFwiICYmIOaOkumZpCAhPSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5yZXBsYWNlKG5ld1JlZ0V4cCjmjpLpmaQsIFxcXCJnXFxcIiksIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQganNvbiA9ICcnXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzb24gPSBpdGVtLnVybDtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhcmFtcyA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlOiBwYWdlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJzOiDmuIXpmaQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc29uOiBqc29uLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IOeKtuaAgSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbGNsZWFyczog5YWo5riFLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xldCB1cmwgPSBwZChpdGVtLCBf5aSn57G76ZO+5o6lKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9IGl0ZW0udXJsO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKmlmICjlpKfnsbvlpITnkIYpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSDkuIDnuqfliIbnsbvlpITnkIYodXJsKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSovXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKHVybClcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGhpcy5zZXRUaXRsZShrZXkudG9TdHJpbmcoKSwgY2F0ZV90ZW1wW2luZGV4XSwgdGl0bGUpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVybDogJChcXFwiaGlrZXI6Ly9lbXB0eSNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHBhcmFtcykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmV3X2NhdGUgPSBbXTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmNsZWFycy5mb3JFYWNoKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKGl0ZW0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmFsbGNsZWFycy5mb3JFYWNoKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKGl0ZW0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcignY2F0ZV9idXR0b24nKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLmNhdGVfdGVtcC5mb3JFYWNoKChjYXRlLCBpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3X2NhdGUucHVzaChpbmRleCA9PT0gMCA/IHBhcmFtcy5rZXkudG9TdHJpbmcoKSA6IFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiaGVhZC5jYXRlXFxcIiwgSlNPTi5zdHJpbmdpZnkobmV3X2NhdGUpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtcy5qc29uLmNvbnN0cnVjdG9yID09PSBPYmplY3QpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJkdF9cXFwiICsgcGFyYW1zLmpzb24udHlwZSwgcGFyYW1zLmpzb24udmFsdWUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIocGFyYW1zLnN0YXRlLCBwYXJhbXMuanNvbik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UodHJ1ZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpdGVtcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJibGFua19ibG9ja1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArICdjYXRlX2xpbmUnLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8v5bCP57G7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3ViX2NhdGVnb3JpZXMuZm9yRWFjaCgoaXRlbSwga2V5KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBleHRyYXBvcyA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKmlmIChpdGVtLmluY2x1ZGVzKCd0eXBlPVxcXCJAZXh0cmFcXFwiJykpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYXBvcyA9IHRydWU7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coJ+mZhOWKoOWumuS9jScpXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0qL1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXh0cmFwb3MpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aXRsZSA9IHBkZmgoaXRlbSwgXFxcImEmJlRleHRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Yg5o6S6ZmkICE9IFxcXCJ1bmRlZmluZWRcXFwiICYmIOaOkumZpCAhPSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUucmVwbGFjZShuZXcgUmVnRXhwKOaOkumZpCwgXFxcImdcXFwiKSwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGpzb24gPSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogcGRmaChpdGVtLCBcXFwiYSYmc3RhdGVcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogcGRmaChpdGVtLCBcXFwiYSYmdmFsdWVcXFwiKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL3ZhciB0aXRsZSA9IHBkZmgoaXRlbSwg5YiG57G75qCH6aKYKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aXRsZSA9IGl0ZW0udGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIOaOkumZpCAhPSBcXFwidW5kZWZpbmVkXFxcIiAmJiDmjpLpmaQgIT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZSA9IHRpdGxlLnJlcGxhY2UobmV3IFJlZ0V4cCjmjpLpmaQsIFxcXCJnXFxcIiksIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBqc29uID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKnN3aXRjaCAodHJ1ZSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIOWIhuexu+mTvuaOpS5pbmNsdWRlcyhcXFwiQEBAXFxcIik6XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganNvbiA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHBkZmgoaXRlbSwg5YiG57G76ZO+5o6lLnNwbGl0KFxcXCJAQEBcXFwiKVswXSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogcGRmaChpdGVtLCDliIbnsbvpk77mjqUuc3BsaXQoXFxcIkBAQFxcXCIpWzFdKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIOWIhuexu+mTvuaOpS5pbmNsdWRlcyhcXFwiQEBcXFwiKTpcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc29uID0ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTog5YiG57G76ZO+5o6lLnNwbGl0KFxcXCJAQFxcXCIpWzBdLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHBkZmgoaXRlbSwg5YiG57G76ZO+5o6lLnNwbGl0KFxcXCJAQFxcXCIpWzFdKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzb24gPSBpdGVtLnVybDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBqc29uID0gcGQoaXRlbSwg5YiG57G76ZO+5o6lKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganNvbiA9IGl0ZW0udXJsO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyp2YXIganNvbj3liIbnsbvpk77mjqUuaW5jbHVkZXMoJ0BAQCcpP3tcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6cGRmaChpdGVtLOWIhuexu+mTvuaOpS5zcGxpdCgnQEBAJylbMF0pLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6cGRmaChpdGVtLOWIhuexu+mTvuaOpS5zcGxpdCgnQEBAJylbMV0pLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OnBkKGl0ZW0s5YiG57G76ZO+5o6lKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganNvbj3liIbnsbvpk77mjqUuaW5jbHVkZXMoJ0BAJyk/e1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTrliIbnsbvpk77mjqUuc3BsaXQoJ0BAJylbMF0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTpwZGZoKGl0ZW0s5YiG57G76ZO+5o6lLnNwbGl0KCdAQCcpWzFdKSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTpwZChpdGVtLOWIhuexu+mTvuaOpSk7Ki9cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGFyYW1zID0ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wOiBjYXRlX3RlbXAsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleDogaW5kZXgsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXk6IGtleSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhZ2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc29uOiBqc29uLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IOeKtuaAgSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbGNsZWFyczog5YWo5riFLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXRlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiB0aGlzLnNldFRpdGxlKGtleS50b1N0cmluZygpLCBjYXRlX3RlbXBbaW5kZXhdLCB0aXRsZSksXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6ICQoXFxcImhpa2VyOi8vZW1wdHlcXFwiICsgXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHBhcmFtcykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMuYWxsY2xlYXJzLmZvckVhY2goKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoaXRlbSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKCdjYXRlX2J1dHRvbicpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMuY2F0ZV90ZW1wW3BhcmFtcy5pbmRleF0gPSBwYXJhbXMua2V5LnRvU3RyaW5nKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJoZWFkLmNhdGVcXFwiLCBKU09OLnN0cmluZ2lmeShwYXJhbXMuY2F0ZV90ZW1wKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbXMuanNvbi5jb25zdHJ1Y3RvciA9PT0gT2JqZWN0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiZHRfXFxcIiArIHBhcmFtcy5qc29uLnR5cGUsIHBhcmFtcy5qc29uLnZhbHVlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKHBhcmFtcy5zdGF0ZSwgcGFyYW1zLmpzb24pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgJ2NhdGVfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2F0ZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwiYmxhbmtfYmxvY2tcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgJ2NhdGVfYnV0dG9uJyxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGZvbGQgPT09IFxcXCIxXFxcIiB8fCDmipjlj6DnirbmgIEgPT0gZmFsc2UpIHtcXG4gICAgICAgICAgICAgICAgaXRlbXMgPSBpdGVtcy5jb25jYXQoY2F0ZXMpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoZm9sZCA9PT0gXFxcIjBcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKCdjYXRlX2J1dHRvbicsIGNhdGVzKVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAodHlwZW9mIHNldFByZVJlc3VsdCAhPSAndW5kZWZpbmVkJykge1xcbiAgICAgICAgICAgICAgICBpdGVtcyA9IGQuY29uY2F0KGl0ZW1zKTtcXG4gICAgICAgICAgICAgICAgLy/muIXnqbrnu6fmib/mlbDnu4RcXG4gICAgICAgICAgICAgICAgZC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBzZXRQcmVSZXN1bHQoaXRlbXMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zLmZvckVhY2goaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goaXRlbSk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgfTtcXG4gICAgb2JqLumihOiuvihvcHRpb25zKTtcXG4gICAgcmV0dXJuIG9iajtcXG59XFxuXFxudmFyIOeKtuaAgSA9XFxuICAgIHR5cGVvZiDnirbmgIHmoIforrAgIT0gXFxcInVuZGVmaW5lZFxcXCIgJiYg54q25oCB5qCH6K6wICE9IFxcXCJcXFwiID8g54q25oCB5qCH6K6wIDogTVlfUlVMRS51cmw7XFxuXFxubGV0IGR0X2RlYnVnID0gZmFsc2U7XFxuXFxuYWRkTGlzdGVuZXIoXFxuICAgIFxcXCJvbkNsb3NlXFxcIixcXG4gICAgJC50b1N0cmluZygoKSA9PiB7fSlcXG4pO1xcblxcbnZhciBDcmVhdGUgPSB7XFxuICAgIG5leHRQYWdlOiBmdW5jdGlvbigpIHtcXG4gICAgICAgIHZhciByZXN1bHQgPSBmYWxzZTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgdmFyIG5leHQgPSBldmFsKOS4i+S4gOmhtSk7XFxuICAgICAgICAgICAgLy9sb2coJ246JytuZXh0KVxcbiAgICAgICAgICAgIGlmIChuZXh0ID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcign5LiL5LiA6aG16ZO+5o6l5Li656m6JylcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmVzdWx0ID0gdHJ1ZTtcXG4gICAgICAgICAgICBpZiAodHJ1ZV91cmwgPT0gbmV4dCkge1xcbiAgICAgICAgICAgICAgICByZXN1bHQgPSBmYWxzZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgLy9sb2coXFxcIuWPr+iDveS4jeWtmOWcqOS4i+S4gOmhteaIluiAheS4i+S4gOmhteWumuS9jeaciemXrumimFxcXCIpO1xcbiAgICAgICAgICAgIGxvZyhcXFwi6ZSZ6K+v5L+h5oGvOlxcXCIgKyBlLm1lc3NhZ2UpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKChuZXh0ID09IFxcXCJcXFwiIHx8IG5leHQgPT0gdW5kZWZpbmVkKSAmJiBwYWdlID09IDEpIHtcXG4gICAgICAgICAgICBuZXh0ID0gdHJ1ZV91cmw7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIC8vcmVzdWx0PWZhbHNlO1xcbiAgICAgICAgICAgIG5leHQgPSBnZXRNeVZhcijnirbmgIEpO1xcbiAgICAgICAgfVxcbiAgICAgICAgLy9sb2coJ2wnK3RydWVfdXJsKVxcbiAgICAgICAgLy9sb2coJ24nK25leHQpXFxuICAgICAgICBpZiAocGFnZSAhPSAxKSB7XFxuICAgICAgICAgICAgaWYgKHRydWVfdXJsID09IG5leHQgJiYgIXJlc3VsdCkge1xcbiAgICAgICAgICAgICAgICByZXN1bHQgPSBmYWxzZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXN1bHQgPSB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgICAgICAvL3B1dE15VmFyKOeKtuaAgSwgbmV4dCk7XFxuICAgIH0sXFxuICAgIGdldEJhY2tJbWFnZTogZnVuY3Rpb24oaW1ndXJsKSB7XFxuICAgICAgICB2YXIgcmVzdWx0ID0gaW1ndXJsO1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICByZXN1bHQgPSAvdXJsKD86XFxcXHMrKT9cXFxcKCguKj8pXFxcXCkvZ1xcbiAgICAgICAgICAgICAgICAuZXhlYyhpbWd1cmwpWzFdXFxuICAgICAgICAgICAgICAgIC5yZXBsYWNlKC8oJ3xcXFwifCZxdW90OykvZ20sIFxcXCJcXFwiKTtcXG4gICAgICAgIH0gY2F0Y2gge31cXG4gICAgICAgIHJldHVybiByZXN1bHQ7XFxuICAgIH0sXFxuICAgIGh0dHBIYW5kbGU6IGZ1bmN0aW9uKGlucHV0KSB7XFxuICAgICAgICBpZiAoaW5wdXQuc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIGlucHV0O1xcbiAgICAgICAgfSBlbHNlIGlmIChpbnB1dC5zdGFydHNXaXRoKFxcXCIvL1xcXCIpKSB7XFxuICAgICAgICAgICAgc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H1gIDogJycpICtcXG4gICAgICAgICAgICBgXFxcXG5cXFxcdHVybOWumuS9jTogICR7cnVsZS51cmx9ICAtLS0+IOe7k+aenDogICR7b2JqLnVybH1gXFxuICAgICAgICApO1xcbiAgICAgICAgbG9nKCctLS0tLS0tLS0tJyArIChpICsgMSkgKyAnOuiwg+ivlee7k+adny0tLS0tLS0tLS0nKTtcXG4gICAgfSxcXG4gICAganNvbkxpc3Q6IGZ1bmN0aW9uKGFyciwganNvbiwgcnVsZSkge1xcbiAgICAgICAgaWYgKGpzb24uY29uc3RydWN0b3IgIT0gT2JqZWN0KSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UoanNvbik7XFxuICAgICAgICAgICAgfSBjYXRjaCB7fVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGpzb25bcnVsZS5saXN0XSA9PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICBhcnIucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdPGZvbnQgY29sb3I9XFxcImdyZXlcXFwiPjxzbWFsbD7ml6DlhoXlrrk8L3NtYWxsPjwvZm9udD4nLFxcbiAgICAgICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHt9LFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgIH1cXG4gICAgICAgIHZhciBkZWJ1ZyA9IHRoaXMuZ2V0Qm9vbGVhblZhbHVlKHJ1bGUuZGVidWcsIGZhbHNlKTtcXG4gICAgICAgIHZhciBlbXB0eSA9IHRoaXMuZ2V0Qm9vbGVhblZhbHVlKHJ1bGUuZW1wdHkpO1xcbiAgICAgICAgaWYgKGRlYnVnKSB7XFxuICAgICAgICAgICAgbG9nKCflrprkvY3liJfooag6JyArIHJ1bGUubGlzdCk7XFxuICAgICAgICB9XFxuICAgICAgICBqc29uW3J1bGUubGlzdF0uZm9yRWFjaCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgICAgIHZhciB0aXRsZSA9IGV2YWwocnVsZS50aXRsZSk7XFxuICAgICAgICAgICAgdmFyIGRlc2MgPSBldmFsKHJ1bGUuZGVzYyk7XFxuICAgICAgICAgICAgdmFyIGNvbnRlbnQgPSBldmFsKHJ1bGUuY29udGVudCk7XFxuICAgICAgICAgICAgdmFyIGltZyA9IGV2YWwocnVsZS5pbWcpICsgcnVsZS5yZWY7XFxuICAgICAgICAgICAgdmFyIGhyZWYgPSBldmFsKHJ1bGUudXJsKTtcXG4gICAgICAgICAgICB2YXIgdXJsID0gcnVsZS5pbXQgPyBocmVmICsgXFxcIiNpbW1lcnNpdmVUaGVtZSNcXFwiIDogaHJlZjtcXG4gICAgICAgICAgICB2YXIgbGF6eSA9IHJ1bGUubGF6eSA/IHJ1bGUubGF6eSA6IFxcXCJcXFwiO1xcblxcbiAgICAgICAgICAgIHZhciBkZCA9IHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBkZXNjLFxcbiAgICAgICAgICAgICAgICBjb250ZW50OiBjb250ZW50LFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBpbWcsXFxuICAgICAgICAgICAgICAgIHVybDogKGVtcHR5ID8gXFxcImhpa2VyOi8vZW1wdHkjI1xcXCIgOiAnJykgKyB1cmwsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBydWxlLmNvbF90eXBlLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgfTtcXG5cXG4gICAgICAgICAgICBpZiAoZGVidWcpIHtcXG4gICAgICAgICAgICAgICAgdmFyIHJ4ID0ge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBkZXNjLFxcbiAgICAgICAgICAgICAgICAgICAgaW1nLFxcbiAgICAgICAgICAgICAgICAgICAgY29udGVudCxcXG4gICAgICAgICAgICAgICAgICAgIHVybFxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICB0aGlzLmRlYnVnbG9nKGksIGl0ZW0sIHJ1bGUsIHJ4KTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKGxhenkgIT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgZGRbXFxcInVybFxcXCJdID0gaHJlZiArIGxhenk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGFyci5wdXNoKGRkKTtcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBydWxlTGlzdDogZnVuY3Rpb24oYXJyLCBodG1sLCBydWxlKSB7XFxuICAgICAgICB2YXIgbGlzdCA9IHBkZmEoaHRtbCxcXG4gICAgICAgICAgICBydWxlLmxpc3QpO1xcbiAgICAgICAgdmFyIGRlYnVnID0gdGhpcy5nZXRCb29sZWFuVmFsdWUocnVsZS5kZWJ1ZyxcXG4gICAgICAgICAgICBmYWxzZSk7XFxuICAgICAgICB2YXIgZW1wdHkgPSB0aGlzLmdldEJvb2xlYW5WYWx1ZShydWxlLmVtcHR5KTtcXG4gICAgICAgIGlmIChkZWJ1Zykge1xcbiAgICAgICAgICAgIGxvZygn5a6a5L2N5YiX6KGoOicgKyBydWxlLmxpc3QpO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGlzdC5mb3JFYWNoKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHRpdGxlID0gdGhpcy5zZXRDb250ZW50KGl0ZW0sIHJ1bGUudGl0bGUpO1xcbiAgICAgICAgICAgIHZhciBkZXNjID0gdGhpcy5zZXRDb250ZW50KGl0ZW0sIHJ1bGUuZGVzYyk7XFxuICAgICAgICB2YXIgZGVzYzAgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS5kZXNjMCk7XFxuICAgICAgICB2YXIgZGVzYzEgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS5kZXNjMSk7XFxuICAgICAgICAgICAgdmFyIGltZyA9IHRoaXMuaW1nSGFuZGxlKGl0ZW0sIHJ1bGUpO1xcbiAgICAgICAgICAgIHZhciB1cmwgPSB0aGlzLnVybEhhbmRsZShpdGVtLCBydWxlKTtcXG4gICAgICAgICAgICB2YXIgY29udGVudCA9IHRoaXMuc2V0Q29udGVudChpdGVtLCBydWxlLmNvbnRlbnQpO1xcblxcbiAgICAgICAgICAgIGlmIChkZWJ1Zykge1xcbiAgICAgICAgICAgICAgICB2YXIgcnggPSB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgIGRlc2MsXFxuICAgICAgICAgICAgICAgICAgICBpbWcsXFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50LFxcbiAgICAgICAgICAgICAgICAgICAgdXJsXFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgIHRoaXMuZGVidWdsb2coaSwgaXRlbSwgcnVsZSwgcngpO1xcbiAgICAgICAgICAgIH1cXG4gICAgLy9kZXNjMCArICdcXFxcdFxcXFx0XFxcXHRcXFxcdFxcXFx0XFxcXHRcXFxcdFxcXFx0XFxcXHRcXFxcdCcgKyBkZXNjMSArICdcXFxcdFxcXFx0XFxcXHRcXFxcdFxcXFx0XFxcXHRcXFxcdFxcXFx0XFxcXHRcXFxcdCcgKyBcXG4gICAgICAgICAgICAvL3ZhciBsYXp5ID0gcnVsZS5sYXp5ID8gcnVsZS5sYXp5IDogXFxcIlxcXCI7XFxuICAgICAgICAgICAgdmFyIGRkID0ge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGUsXFxuICAgICAgICAgICAgICAgIGRlc2M6IGRlc2MwICsgJ1xcXFx0XFxcXHRcXFxcdFxcXFx0XFxcXHRcXFxcdCcgKyBkZXNjLFxcbiAgICAgICAgICAgICAgICBwaWNfdXJsOiBpbWcsXFxuICAgICAgICAgICAgICAgIHVybDogdXJsICsgbGF6eSxcXG4gICAgICAgICAgICAgICAgY29udGVudDogY29udGVudCxcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6IHJ1bGUuY29sX3R5cGUsXFxuICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICBpbWc6IGltZyxcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIGlmIChsYXp5ICE9IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGRkW1xcXCJ1cmxcXFwiXSA9IHVybCArIGxhenk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGFyci5wdXNoKGRkKTtcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBMaXN0OiBmdW5jdGlvbihhcnIsIGh0bWwsIHJ1bGUsIHBhcmFtKSB7XFxuICAgICAgICBwYXJhbSA9IHBhcmFtID8gcGFyYW0gOiB7fTtcXG4gICAgICAgIHZhciBhdXRvID0gcGFyYW0uYXV0byA/IHBhcmFtLmF1dG8gOiBmYWxzZTtcXG4gICAgICAgIHZhciBzaG93ID0gcGFyYW0uc2hvdyA/IHBhcmFtLnNob3cgOiBmYWxzZTtcXG4gICAgICAgIGlmIChwYWdlID09IDEpIHtcXG4gICAgICAgICAgICAvL3RoaXMuc3BhZ2Uuc2V0KHRydWVfdXJsKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRoaXMucmVmcmVzaCgpO1xcbiAgICAgICAgdmFyIGRlYnVnID0gdGhpcy5nZXRCb29sZWFuVmFsdWUocnVsZS5kZWJ1ZywgZmFsc2UpO1xcbiAgICAgICAgdmFyIGVtcHR5ID0gdGhpcy5nZXRCb29sZWFuVmFsdWUocnVsZS5lbXB0eSk7XFxuICAgICAgICB2YXIgbGlzdCA9IHBkZmEoaHRtbCwgcnVsZS5saXN0KTtcXG4gICAgICAgIGlmIChkZWJ1Zykge1xcbiAgICAgICAgICAgIGxvZygn5a6a5L2N5YiX6KGoOicgKyBydWxlLmxpc3QpO1xcbiAgICAgICAgfVxcbiAgICAgICAgLy9sb2codGhpcy5uZXh0UGFnZSgpKVxcbiAgICAgICAgaWYgKChzdG9yYWdlMC5nZXRNeVZhcigneWlfaXNuZXh0JywgJ3QnKSA9PSAndCcgJiYgbGlzdC5sZW5ndGggPiAwKSB8fCBwYWdlID09IDEpIHtcXG4gICAgICAgICAgICBsaXN0LmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgZGVsZXRlSXRlbShcXFwicGFnZW51bVxcXCIpO1xcbiAgICAgICAgICAgICAgICBkZWxldGVJdGVtKFxcXCJwYWdlbGluZVxcXCIpO1xcbiAgICAgICAgICAgICAgICB2YXIgaWQgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgdmFyIGNscyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICB2YXIgdGl0bGUgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS50aXRsZSk7XFxuICAgICAgICAgICAgICAgIHZhciBkZXNjID0gdGhpcy5zZXRDb250ZW50KGl0ZW0sIHJ1bGUuZGVzYyk7XFxuICAgICAgICB2YXIgZGVzYzAgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS5kZXNjMCk7XFxuICAgICAgICB2YXIgZGVzYzEgPSB0aGlzLnNldENvbnRlbnQoaXRlbSwgcnVsZS5kZXNjMSk7XFxuICAgICAgICAgICAgICAgIHZhciBpbWcgPSB0aGlzLmltZ0hhbmRsZShpdGVtLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgdmFyIHVybCA9IHRoaXMudXJsSGFuZGxlKGl0ZW0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICB2YXIgY29udGVudCA9IHRoaXMuc2V0Q29udGVudChpdGVtLCBydWxlLmNvbnRlbnQpO1xcblxcbiAgICAgICAgICAgICAgICBpZiAoZGVidWcpIHtcXG4gICAgICAgICAgICAgICAgICAgIHZhciByeCA9IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZXNjLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZyxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybFxcbiAgICAgICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZGVidWdsb2coaSwgaXRlbSwgcnVsZSwgcngpO1xcbiAgICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICAgIGlmIChpID09IGxpc3QubGVuZ3RoIC0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWQgPSBcXFwibGFzdGlkX1xcXCIgKyBwYWdlO1xcbiAgICAgICAgICAgICAgICAgICAgY2xzID0gXFxcImxhc3RtYXJrXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgZGVzYzogZGVzYyxcXG4gICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogKGVtcHR5ID8gXFxcImhpa2VyOi8vZW1wdHkjI1xcXCIgOiAnJykgKyB1cmwgKyAnIyNmeXBhZ2VAcnVsZT1qczokLnJlcXVpcmUoXFxcInlpamlcXFwiKScsXFxuICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBjb250ZW50LFxcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IHJ1bGUuY29sX3R5cGUsXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogaW1nLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBpZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbHM6IGNscyxcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBpZiAoaSA9PSBsaXN0Lmxlbmd0aCAtIDEgJiYgc2hvdykge1xcbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBcXFwicGFnZWxpbmVcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLigJzigJzigJ3igJ08c21hbGw+5Yqg6L295LitLi4uPC9zbWFsbD5cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJwYWdlbnVtXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwicGFnZW51bVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ08Zm9udCBjb2xvcj1cXFwiZ3JleVxcXCI+PHNtYWxsPuWIsOW6leS6hjwvc21hbGw+PC9mb250PicsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJsYXN0XFxcIixcXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChsaXN0Lmxlbmd0aCA9PSAwICYmIHBhZ2UgPT0gMSkge1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCIsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ08Zm9udCBjb2xvcj1cXFwiZ3JleVxcXCI+PHNtYWxsPuaXoOWGheWuuTwvc21hbGw+PC9mb250PicsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge30sXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAodGhpcy5uZXh0UGFnZSgpKSB7XFxuICAgICAgICAgICAgLy9sb2coJ3QnKTtcXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcigneWlfaXNuZXh0JywgJ3QnKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgLy9sb2coJ2YnKTtcXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcigneWlfaXNuZXh0JywgJ2YnKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChhdXRvKSB7XFxuICAgICAgICAgICAgLy9jcmVhdGVOZXh0UGFnZSgpO1xcbiAgICAgICAgICAgIGF1dG9QYWdlKCk7XFxuICAgICAgICB9XFxuICAgIH0sXFxufTtcXG5cXG52YXIgZXh0TWV0aG9kID0ge1xcbiAgICBUb1BhcmFtczogZnVuY3Rpb24oKSB7XFxuICAgICAgICB2YXIganNvbiA9IGFyZ3VtZW50c1swXTtcXG4gICAgICAgIHJldHVybiBPYmplY3Qua2V5cyhqc29uKVxcbiAgICAgICAgICAgIC5tYXAoKGtleSkgPT4ga2V5ICsgXFxcIj1cXFwiICsganNvbltrZXldKVxcbiAgICAgICAgICAgIC5qb2luKFxcXCImXFxcIik7XFxuICAgIH0sXFxuICAgIHVybFBhcnNlOiBmdW5jdGlvbih1KSB7XFxuICAgICAgICB2YXIgZGljdCA9IHt9O1xcbiAgICAgICAgZGljdC5Tb3VyY2UgPSB1O1xcbiAgICAgICAgbGV0IHBhcmFtcyA9ICh1cmwpID0+IHtcXG4gICAgICAgICAgICBsZXQgcXVlcnlQYXJhbXMgPSB7fTtcXG4gICAgICAgICAgICBsZXQgcmVnID0gLyhbXj89Jl0rKT0oW14/PSZdKykvZztcXG4gICAgICAgICAgICB1cmwucmVwbGFjZShyZWcsIGZ1bmN0aW9uKCkge1xcbiAgICAgICAgICAgICAgICBxdWVyeVBhcmFtc1thcmd1bWVudHNbMV1dID0gYXJndW1lbnRzWzJdO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiBxdWVyeVBhcmFtcztcXG4gICAgICAgIH07XFxuICAgICAgICB2YXIgamF2YVVybCA9IEphdmFJbXBvcnRlcihqYXZhLm5ldC5VUkwpO1xcbiAgICAgICA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zID0gW107XFxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0cjIubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICBpZiAoc3RyMVtpXSAhPT0gc3RyMltpXSkge1xcbiAgICAgICAgICAgICAgICBkaWZmQ2hhcnMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICBpbmRleDogaSxcXG4gICAgICAgICAgICAgICAgICAgIHMxOiBzdHIxW2ldLFxcbiAgICAgICAgICAgICAgICAgICAgczI6IHN0cjJbaV0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBkaWZmQ2hhcnM7XFxuICAgIH0sXFxuICAgIHJlcGxhY2VDaGFyQXQ6IGZ1bmN0aW9uKHN0ciwgaW5kZXgsIHJlcGxhY2VtZW50KSB7XFxuICAgICAgICBpZiAoaW5kZXggPCAwIHx8IGluZGV4ID49IHN0ci5sZW5ndGgpIHtcXG4gICAgICAgICAgICByZXR1cm4gc3RyO1xcbiAgICAgICAgfVxcbiAgICAgICAgLy9sb2coaW5kZXgpXFxuICAgICAgICBjb25zdCBhcnIgPSBzdHIuc3BsaXQoXFxcIlxcXCIpO1xcbiAgICAgICAgYXJyW2luZGV4XSA9IHJlcGxhY2VtZW50O1xcbiAgICAgICAgcmV0dXJuIGFyci5qb2luKFxcXCJcXFwiKTtcXG4gICAgfSxcXG4gICAgZ2V0T2JqZWN0S2V5c0RpZmY6IGZ1bmN0aW9uKG9iajEsIG9iajIpIHtcXG4gICAgICAgIGNvbnN0IGRpZmZlcmVudEtleXMgPSBbXTtcXG4gICAgICAgIGZvciAobGV0IGtleSBpbiBvYmoxKSB7XFxuICAgICAgICAgICAgaWYgKCFvYmoyLmhhc093blByb3BlcnR5KGtleSkgfHwgb2JqMVtrZXldICE9PSBvYmoyW2tleV0pIHtcXG4gICAgICAgICAgICAgICAgZGlmZmVyZW50S2V5cy5wdXNoKGtleSk7XFxuIC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Vsc2Uge1xcbiAgICAgICAgICAgIGlmICh0aGlzLmlzRXF1YWwodTEuUGFyYW1zLCB1Mi5QYXJhbXMpKSB7XFxuICAgICAgICAgICAgICAgIGlmIChkdF9kZWJ1Zykge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKHUxLlBhdGgpO1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKHUyLlBhdGgpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHZhciBkZiA9IHRoaXMuZmluZERpZmZlcmVudEluZGV4KFN0cmluZyh1MS5QYXRoKSwgU3RyaW5nKHUyLlBhdGgpKTtcXG4gICAgICAgICAgICAgICAgaWYgKGR0X2RlYnVnKSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coZGYpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChkZi5sZW5ndGggPT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgdmFyIHJlID0gZGZbMF0uaW5kZXg7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgZiA9IGRmLmZpbHRlcigoeCkgPT4gL1xcXFxkKy8udGVzdCh4LnMyKSk7XFxuICAgICAgICAgICAgICAgICAgICB2YXIgcmUgPSBmWzBdLmluZGV4O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHZhciBlcSA9IHRoaXMucmVwbGFjZUNoYXJBdChTdHJpbmcodTIuUGF0aCksIHJlLCBcXFwiZnlwYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgIG5leHR1cmwgPSB1Mi5Ib3N0cyArIGVxICsgY2EgKyB0aGlzLlRvUGFyYW1zKHUyLlBhcmFtcyk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdmFyIGVwID0gdGhpcy5nZXRPYmplY3RLZXlzRGlmZih1MS5QYXJhbXMsIHUyLlBhcmFtcylcXG4gICAgICAgICAgICAgICAgaWYgKGVwLmxlbmd0aCA9PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICB1MS5QYXJhbXNbZXBbMF1dID0gJ2Z5cGFnZSdcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhlcCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgdmFyIGVxID0gU3RyaW5nKHUxLlBhdGgpLnJlcGxhY2UoL1xcXFxkKy8sIFxcXCJmeXBhZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgbmV4dHVybCA9IHUxLkhvc3RzICsgZXEgKyBjYSArIHRoaXMuVG9QYXJhbXModTEuUGFyYW1zKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICAvL2xvZygnbmV4dDonK25leHR1cmwpXFxuICAgICAgICByZXR1cm4gbmV4dHVybDtcXG4gICAgfSxcXG59O1xcblxcbmZ1bmN0aW9uIGdldFRydWVsaW5rKG1hcmssIHVybCwgcGFnZSkge1xcbiAgICB2YXIgcCA9IGdldE15VmFyKG1hcmssIHVybCkucmVwbGFjZShcXFwiZnlwYWdlXFxcIiwgcGFnZSk7XFxuICAgIGlmIChwYWdlID09IDEpIHtcXG4gICAgICAgIHJldHVybiBnZXRNeVZhcihcXFwieWlfZmlyc3RwYWdlXFxcIiwgcCk7XFxuICAgIH0gZWxzZSBpZiAocCAhPSBcXFwiXFxcIikge1xcbiAgICAgICAgcmV0dXJuIHA7XFxuICAgIH0gZWxzZSB7XFxuICAgICAgICByZXR1cm4gdXJsO1xcbiAgICB9XFxufVxcbi8v5p6E5bu6XFxuZnVuY3Rpb24gY3JlYXRlTmV4dFBhZ2UoKSB7XFxuICAgIGxldCBzdGFydG51bSA9IDE7XFxuICAgIHZhciBvYmogPSBhcmd1bWVudHNbMF07XFxuICAgIGlmICh0cnVlX3VybCAhPSBnZXRNeVZhcihcXFwieWlfcGFnZXVybFxcXCIsIFxcXCJcXFwiKSkge1xcbiAgICAgICAgY2xlYXJNeVZhcihcXFwieWlfcGFnZXVybFxcXCIpO1xcbiAgICB9XFxuICAgIGlmIChwYWdlID09IHN0YXJ0bnVtICYmIGdldE15VmFyKFxcXCJ5aV9wYWdldXJsXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgIHB1dE15VmFyKFxcXCJ5aV9maXJzdHBhZ2VcXFwiLCB0cnVlX3VybCk7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHZhciBuZXh0ID0gZXZhbCjkuIvkuIDpobUpO1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCJuZXh0XFxcIik7XFxuICAgICAgICAgICAgLy9sb2cobmV4dCk7XFxuICAgICAgICB9IGNhdGNoIHtcXG4gICAgICAgICAgICBsb2coXFxcIuWPr+iDveS4jeWtmOWcqOS4i+S4gOmhteaIluiAheS4i+S4gOmhteWumuS9jeaciemXrumimFxcXCIpO1xcbiAgICAgICAgICAgIG5leHQgPSBcXFwiXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChuZXh0ICE9IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgdmFyIG54dXJsID0gZXh0TWV0aG9kLmdldE5leHRVcmwodHJ1ZV91cmwsIG5leHQsIG9iaik7XFxuICAgICAgICAgICAgLy9sb2coXFxcIm54dXJsOlxcXCIgKyBueHVybCk7XFxuICAgICAgICAgICAgcHV0TXlWYXIo54q25oCBLCBueHVybCk7XFxuICAgICAgICAgICAgcHV0TXlWYXIoXFxcInlpX3BhZ2V1cmxcXFwiLCBueHVybCk7XFxuICAgICAgICB9XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gYXV0b1BhZ2UoKSB7XFxuICAgIGlmIChwYWdlID09IDEpIHtcXG4gICAgICAgIHB1dE15VmFyKFxcXCJ5aV9maXJzdHBhZ2VcXFwiLCB0cnVlX3VybCk7XFxuICAgIH1cXG4gICAgdHJ5IHtcXG4gICAgICAgIHZhciB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ZWYnKSArICcjI2Z5cGFnZUBydWxlPWpzOiQucmVxdWlyZShcXFwic3hcXFwiKScsXFxuICAgICAgICBjb2xfdHlwZTogXFxcImF2YXRhclxcXCIsXFxuICAgICAgICBleHRyYToge2xpbmVWaXNpYmxlOmZhbHNlfVxcbiAgICB9KTtcXG5cXG4gICAgICAgIGZvciAodmFyIGogPSAwOyBqIDwgKGxpc3QubGVuZ3RoLWxpc3QubGVuZ3RoJTIpOyBqKyspIHsgICAgICAgXFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHBkZmgobGlzdFtqXSwgJy52b2QtdHh0JiZUZXh0JyksXFxuICAgICAgICAgICAgICAgIGRlc2M6IHBkZmgobGlzdFtqXSwgJy50aW1lJiZUZXh0JyksXFxuICAgICAgICAgICAgICAgIGltZzogcGQobGlzdFtqXSwnaW1nfHxhJiZzcmMnKSxcXG4gICAgICAgICAgICAgICAgdXJsOiBwZChsaXN0W2pdLCAnYSYmaHJlZicpLnJlcGxhY2UoXFxcImluZm9cXFwiLFxcXCJwbGF5XFxcIikgKyBsYXp5LFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ21vdmllXzInLCAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH1cIn1dIn0=
Add Comment
Please, Sign In to add comment