Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:二级页面详情¥page_detail¥创建配置@@eyJkYXRhIjoie1wiYXNzb2NpYXRlZE1vZGVsc01hcEZvckpvaW5UYWJsZVwiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhGS1wiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhvdXRGS1wiOnt9LFwiZmllbGRzVG9TZXRUb0RlZmF1bHRcIjpbXSxcImdtdE1vZGlmaWVkXCI6MCxcImlkXCI6MCxcImxhc3RfY2hhcHRlcl9ydWxlXCI6XCJcIixcImxpc3RUb0NsZWFyQXNzb2NpYXRlZEZLXCI6W10sXCJsaXN0VG9DbGVhclNlbGZGS1wiOltdLFwicGFnZUxpc3RcIjpbe1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHlcIixcInBhdGhcIjpcImRycHlcIixcInJ1bGVcIjpcImZ1bmN0aW9uIGluaXRIaWtlcigpIHtcXG4gICAgY29uc3QgaXNDbG9zZUxvZyA9ICFnZXRJdGVtKFxcXCJ1c2VMb2dcXFwiLCBcXFwiXFxcIik7XFxuICAgIGNvbnN0IGxvY2FsS2V5ID0gXFxcImRycHlcXFwiO1xcbiAgICBjb25zdCBDcnlwdG9VdGlsID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL2Fzc2V0cy9jcnlwdG8tamF2YS5qc1xcXCIpO1xcbiAgICBnbG9iYWxUaGlzLmxvY2FsID0ge1xcbiAgICAgICAgc2V0KHJ1bGVrZXksIGssIHYpIHtcXG4gICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKGxvY2FsS2V5ICsgXFxcIkBcXFwiICsgcnVsZWtleSArIFxcXCJAXFxcIiArIGssIHYpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGdldChydWxla2V5LCBrLCB2KSB7XFxuICAgICAgICAgICAgcmV0dXJuIHN0b3JhZ2UwLmdld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Q29va2llOiBcXFwiI25vQ29va2llI1xcXCJcXG4gICAgICAgICAgICB9LCBvYmouaGVhZGVycyk7XFxuICAgICAgICAgICAgaWYgKHVybCA9PT0gXFxcImh0dHBzOi8vYXBpLm5uLmNpL29jci9iNjQvdGV4dFxcXCIgJiYgb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNbXFxcIkNvbnRlbnQtVHlwZVxcXCJdID0gXFxcInRleHQvcGxhaW5cXFwiO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSAmJiAodXJsLmluY2x1ZGVzKFxcXCI/dHlwZT1cXFwiKSB8fCB1cmwuaW5jbHVkZXMoXFxcIj9wYXJhbXM9XFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9iai5oZWFkZXJzW2tleV0gIT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFwicG9zdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcbiAgICAgICAgICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIkVycm9yXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgLypcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vY2RuLmJvb3RjZG4ubmV0L2FqYXgvbGlicy9tdXN0YWNoZS5qcy80LjEuMC9tdXN0YWNoZS5qc1xcXCIpO1xcbiAgXFxuICAgIGNvbnN0IEpQID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2pzb25wYXRoLXBsdXMuZ2l0aHViLmlvL0pTT05QYXRoL2Rpc3QvaW5kZXgtYnJvd3Nlci11bWQuY2pzXFxcIik7XFxuICAgIGdsb2JhbFRoaXMuY2hlZXJpbyA9IHtcXG4gICAgICAgIGppbmphMih0ZW1wbGF0ZSwgb2JqKSB7XFxuICAgICAgICAgICAgXFxuICAgICAgICAgICAgcmV0dXJuICQubG9nKEppbkphLnJlbmRlcih0ZW1wbGF0ZSwgb2JqKSk7XFxuICAgICAgICB9LFxcbiAgICAgICAganAocGF0aCwganNvbikge1xcbiAgICAgICAgICAgIHJldHVybiBKUC5KU09OUGF0aCh7XFxuICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgIGpzb25cXG4gICAgICAgICAgICB9KVswXTtcXG4gICAgICAgIH1cXG4gICAgfSovXFxuICAgIGdsb2JhbFRoaXMucGRmYSA9IF9wZGZhO1xcbiAgICBnbG9iYWxUaGlzLnBkID0gX3BkO1xcbiAgICBnbG9iYWxUaGlzLnBkZmggPSBfcGRmaDtcXG4gICAgU3RyaW5nLnByb3RvdHlwZS5yZXBsYWNlQWxsID0gZnVuY3Rpb24gKHNlYXJjaCwgcmVwbGFjZW1lbnQpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLnNwbGl0KHNlYXJjaCkuam9pbihyZXBsYWNlbWVudCk7XFxuICAgIH07XFxuICAgIGxldCAkdG9TdHJpbmcgPSBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmc7XFxuICAgIEZ1bmN0aW9uLnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uICgpIHtcXG4gICAgICAgIHJldHVybiAkdG9TdHJpbmcuYXBwbHkodGhpcykudHJpbSgpO1xcbiAgICB9O1xcbiAgICBpZiAoaXNDbG9zZUxvZykge1xcbiAgICAgICAgLy8g6YeN5YaZY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgIGNvbnNvbGUubG9nID0gZnVuY3Rpb24gKCkge1xcbiAgICAgICAgICAgIC8vIOajgOafpeS8oOWFpeWPguaVsOeahOaVsOmHj1xcbiAgICAgICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICAgICAvLyDlpoLmnpzlj4LmlbDmlbDph4/lpKfkuo4x77yM6LCD55So5Y6f5aeL55qEY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgICAgICAgICAgLy9vcmlnaW5hbExvZy5hcHBseShjb25zb2xlLCBhcmd1bWVudHMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgLy8g5aaC5p6c5Y+C5pWw5Y+q5pyJ5LiA5Liq77yM5YiZ5LiN5YGa5Lu75L2V5pON5L2cXFxuICAgICAgICB9O1xcbiAgICB9XFxufVxcbmluaXRIaWtlcigpO1xcbmNvbnN0IGRycHlQYXRoID0gZ2V0UGF0aChcXFwiaGlrZXI6Ly9maWxlcy9kYXRhL1xcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIi9saWJzX2hpa2VyL2RycHkyLmpzXFxcIik7XFxuXFxuaWYgKCFmaWxlRXhpc3QoZHJweVBhdGgpKSB7XFxuICAgIHRocm93IG5ldyBFcnJvcihcXFwi57y65bCRZHJweS5qc+i/kOihjOW6k1xcXCIpO1xcbn1cXG5sZXQgZHJweSA9ICQucmVxdWlyZShkcnB5UGF0aCk7XFxuLypcXG5sZXQgY3VycmVudFBhdGggPSBcXFwiXFxcIjtcXG5sZXQgJGluaXQgPSBkcnB5LmluaXQ7XFxuZHJweS5pbml0ID0gZnVuY3Rpb24oZXh0KSB7XFxuICAgIGlmIChleHQgPT09IGN1cnJlbnRQYXRoKSByZXR1cm47XFxuICAgICRpbml0LmNhbGwodGhpcywgZXh0KTtcXG4gICAgY3VycmVudFBhdGggPSBleHQ7XFxufSovXFxuJC5leHBvcnRzID0gZHJweTtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzFfdmVydGlj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h0YyA+PSAxNSkge1xcbiAgICAgICAgY29sID0gXFxcInRleHRfMlxcXCI7XFxuICAgICAgICB0ZXh0YWxpZ24gPSBcXFwibGVmdFxcXCI7XFxuICAgICAgfVxcbiAgICAgIGxldCBwbGF5b2JqID0gdC5zcGxpdChcXFwiI1xcXCIpLm1hcCgoaikgPT4ge1xcbiAgICAgICAgbGV0IGsgPSBqLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICBsZXQgdWlkID0gKGtbMV18fGtbMF0pO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSh0LCB7XFxuICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICB9KSxcXG4gICAgICAgICAgdXJsOiAgdWlkKyBcXFwiI1xcXCIgKyBmcm9tW2ldICsgcGxheUxhenkucmVwbGFjZSgnXFxcImlkXFxcIicsICdcXFwiJyArdWlkICsgJ1xcXCInKSxcXG4gICAgICAgICAgY29sX3R5cGU6IGNvbCxcXG4gICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBkZWNvZGVVUklDb21wb25lbnQoa1sxXSksXFxuICAgICAgICAgICAgaWQ6IGtbMV0sXFxuICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9KSovXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaW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GxldCBvYmogPSBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLCB7XFxuICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyAocGFnZW51bSA9PSBpID8geC5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogeCksXFxuICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGkpID0+IHtcXG4gICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIikgPT0gaSkge1xcbiAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCAkLnRlbXBfbGlzdFtpXSk7XFxuICAgICAgICAgICAgIGZpbmRJdGVtc0J5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpLmZvckVhY2goKHgsIGlpKSA9PiB7XFxuICAgICAgICAgICAgICAgbGV0IHRpdGxlID0geC50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgaWYgKGlpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlID0gJ+KAnOKAnOKAneKAnScgKyB0aXRsZS5mb250Y29sb3IoXFxcInJlZFxcXCIpO1xcbiAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICB9KVxcbiAgICAgICAgIC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9kb21haW5fY29uZmlnXFxcIixcXG4gICAgZXh0cmE6IHtcXG4gICAgICAgIHBhZ2VUaXRsZTogXFxcIuaWsOWinuino+aekFxcXCJcXG4gICAgfVxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YiG5LqrXFxcIixcXG4gICAgdXJsOiAkKFxcXCItMVxcXCIsIFxcXCLovpPlhaXkvaDopoHliIbkuqvop6PmnpDnmoTluo/lj7dcXFxcbi0x5YWo6YOo77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahFxcXCIpLmlucHV0KChsZW5ndGgpID0+IHtcXG4gICAgICAgIGxldCBpbmRleGMgPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgIGxldCBpbmRleHMgPSBbXTtcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxuICAgICAgICBpZiAoIShpbmRleGMubGVuZ3RoICE9PSAwICYmIG1vIDwgMCAmJiBtbyA+IC01KSkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG51bSkgfHwgbnVtID49IGxlbmd0aCB8fCBudW0gPCAwKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiAkKFtcXFwiSElLRVJcXFwiLCBcXFwiVFhUXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSwgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgobW8sIGluZGV4c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lmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yfXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bG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cnkge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAgICAgIGpzXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4LCBpc0ltcG9ydCkgPT4ge1xcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKS50cmltKCk7XFxuICAgICAgICBpZiAoIW5hbWUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZCN5a2X5b6X5pyJ5LiA5Liq5ZCnXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCB1cmwgPSBnZXRNeVZhcihcXFwicHNfdXJsXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghdXJsKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZmxhZyA9IGdldE15VmFyKFxcXCJwc19mbGFnXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFmbGFnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOagh+ivhuS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IGdldE15VmFyKFxcXCJwc19oZWFkZXJzXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIGlmKHR5cGVvZiBoZWFkZXJzIT09XFxcIm9iamVjdFxcXCIpIHRocm93IG5ldyBFcnJvcihcXFwi6ZSZ6K+v57G75Z6L77yM5b+F6aG75Li6T2JqZWN0XFxcIik7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICBsZXQganNvblBhdGggPSBnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiICYmICFqc29uUGF0aCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU09O5qih5byP5LiL5b+F6aG75aGranNvblBhdGhcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09PSBcXFwiSlNcXFwiICYmICFqcykge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgb2JqMSA9IHtcXG4gICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAganNcXG4gICAgICAgIH07XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBvYmoxLmdyb3VwO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgbmFtZXkgPSBhcnJbaW5kZXhdLm5hbWU7XFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xcbiAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIG9iajEpO1xcbiAgICAgICAgfVxcbiAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24oYXJyKTtcXG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XVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgbmV3SSA9IDA7XFxuICAgICAgICBmb3IgKGxldCBydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydWxlcy5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5paw5aKe77yaXFxcIiArIG5ld0kgKyBcXFwiIOimhuebluabtOaWsO+8mlxcXCIgKyAocnVsZXMubGVuZ3RoIC0gbmV3SSkpO1xcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIHRvYXN0KFxcXCLlr7zlhaXlpLHotKVcXFwiKTtcXG4gICAgfVxcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuinhumikeino+aekFwiLFwicGF0aFwiOlwidmlkZW9VcmxcIixcInJ1bGVcIjpcImZ1bmN0aW9uIGlzb2ZmaWNpYWwodXJsKSB7XFxuICAgIGxldCBmbGFnID0gbmV3IFJlZ0V4cCgncXFcXFxcLmNvbXxpcWl5aVxcXFwuY29tfHlvdWt1XFxcXC5jb218bWd0dlxcXFwuY29tfGJpbGliaWxpXFxcXC5jb218c29odVxcXFwuY29tfGl4aWd1YVxcXFwuY29tfHBwdHZcXFxcLmNvbXxtaWd1dmlkZW9cXFxcLmNvbXxsZVxcXFwuY29tfDE5MDVcXFxcLmNvbXxmdW5cXFxcLnR2Jyk7XFxuICAgIHJldHVybiBmbGFnLnRlc3QodXJsKTtcXG59XFxuXFxuZnVuY3Rpb24gcHJveHkodGl0bGUpIHtcXG4gICAgZnVuY3Rpb24gdG9QYXRoKHZhbHVlKSB7XFxuICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAnc3RyaW5nJykge1xcbiAgICAgICAgICAgIHJldHVybiBbXTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBwYXRoID0gW107XFxuICAgICAgICBsZXQgY3VycmVudCA9ICcnO1xcbiAgICAgICAgbGV0IGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgIGxldCBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdmFsdWUubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICBsZXQgY2hhciA9IHZhbHVlW2ldO1xcbiAgICAgICAgICAgIGlmIChlc2NhcGUpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgICAgICBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXCcpIHtcXG4gICAgICAgICAgICAgICAgZXNjYXBlID0gdHJ1ZTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICddJykge1xcbiAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChjdXJyZW50KSB7XFxuICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHBhdGg7XFxuICAgIH1cXG5cXG4gICAgZnVuY3Rpb24gZ2V0SnNvbihvYmosIHBhdGgpIHtcXG4gICAgICAgIGlmICghb2JqIHx8ICFBcnJheS5pc0FycmF5KHBhdGgpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChwYXRoLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgY3VycmVudCA9IG9iajtcXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0aC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgIGxldCBrZXkgPSBwYXRoW2ldO1xcbiAgICAgICAgICAgIGlmIChjdXJyZW50ID09PSBudWxsIHx8IGN1cnJlbnQgPT09IHVuZGVmaW5lZCB8fCB0eXBlb2YgY3VycmVudCAhPT0gJ29iamVjdCcpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgY3VycmVudCA9IGN1cnJlbnRba2V5XTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBjdXJyZW50O1xcbiAgICB9XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IE1ZX1BBUkFNUy5ydW5UeXBlWzBdO1xcbiAgICAgICAgbGV0IHVybCA9IGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnVybFswXSkpO1xcbiAgICAgICAgaWYgKHJ1blR5cGUgPT0gXFxcIkpTT05cXFwiKSB7XFxuXFxuICAgICAgICAgICAgbGV0IHBhcmFtID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UocmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgaGVhZGVyczogcGFyYW0uaGVhZGVycyB8fCB7fSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kOiBwYXJhbS5tZXRob2QgfHwgdm9pZCAwXFxuICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgaGVhZGVyczogT2JqZWN0LmFzc2lnbih7fSwgcGFyYW0uaGVhZGVycyB8fCB7fSwge1xcbiAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogZ2V0SnNvbihqc29uLCB0b1BhdGgocGFyYW0uanNvblBhdGgpKSxcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PSBcXFwiSlNcXFwiKSB7XFxuXFxuICAgICAgICAgICAgbGV0IHBhcnNlO1xcbiAgICAgICAgICAgIGlmIChNWV9QQVJBTVMuaW5kZXgpIHtcXG4gICAgICAgICAgICAgICAgcGFyc2UgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgdGl0bGUpLmdldEpzb24oKVtNWV9QQVJBTVMuaW5kZXhbMF1dO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHBhcnNlID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHJlcyA9IG5ldyBGdW5jdGlvbihcXFwidXJsXFxcIiwgXFxcInNlbGZcXFwiLCBwYXJzZS5qcykodXJsLCBwYXJzZSk7XFxuICAgICAgICAgICAgaWYgKHR5cGVvZiByZXMgPT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogcmVzXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoJC50eXBlKHJlcykgPT09IFxcXCJvYmplY3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiByZXNcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgfVxcbn1cXG5cXG5mdW5jdGlvbiBwcmVwYXJlUGFyc2VzKHBhcnNlcywgdXJsLCBwbGF5bGlzdCwgaXNUZXN0KSB7XFxuICAgIHBsYXlsaXN0ID0gcGxheWxpc3QgfHwge1xcbiAgICAgICAgdXJsczogW10sXFxuICAgICAgICBuYW1lczogW10sXFxuICAgICAgICBoZWFkZXJzOiBbXSxcXG4gICAgICAgIGlzOiBcXFwiI2lzVmlkZW89dHJ1ZSNcXFwiLFxcbiAgICB9O1xcbiAgICBsZXQgcHJveHlVcmwgPSBzdGFydFByb3h5U2VydmVyKCQudG9TdHJpbmcocHJveHksIE1ZX1JVTEUudGl0bGUpKTtcXG4gICAgcGFyc2VzLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgIGlmICh2LmZvcmJpZGRlbikgcmV0dXJuO1xcbiAgICAgICAgcGxheWxpc3QubmFtZXMucHVzaCh2Lm5hbWUpO1xcbiAgICAgICAgaWYgKHYuaGVhZGVycykge1xcbiAgICAgICAgICAgIHBsYXlsaXN0LmhlYWRlcnMucHVzaCh2LmhlYWRlcnMpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHYucnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiKSB7XFxuICAgICAgICAgICAgbGV0IHBhcmFtID0ge1xcbiAgICAgICAgICAgICAgICAvL3VybDogdi51cmwsXFxuICAgICAgICAgICAgICAgIG1ldGhvZDogdi5tZXRob2QsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHYuaGVhZGVycyxcXG4gICAgICAgICAgICAgICAganNvblBhdGg6IHYuanNvblBhdGhcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIHBsYXlsaXN0LnVybHMucHVzaChwcm94eVVybCArIFxcXCI/cnVuVHlwZT1KU09OJnVybD1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGJhc2U2NEVuY29kZSh2LnVybCArIHVybCkpICsgXFxcIiZwYXJhbT1cXFwiICsgZW5jb2RlVVJJQ29tcG9uZW50KGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShwYXJhbSkpKSk7XFxuICAgICAgICB9IGV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b2cobG9jYXRpb24uaHJlZilcXG4gICAgICAgIH0sICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkobmF2aWdhdG9yLCAndXNlckFnZW50Jywge1xcbiAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkge1xcbiAgICAgICAgICAgICAgcmV0dXJuICdNeS1DdXN0b20tVUEtU3RyaW5nJztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH0pO1xcbiAgICAgICAgfSkpKi9cXG4gICAgfVxcbiAgICBpZiAocGFyc2Vfb2JqLmhhc093blByb3BlcnR5KFxcXCJjdXN0b21fcmVnZXhcXFwiKSkge1xcbiAgICAgICAgbGV0IGN1cnJlbnQgPSBwYXJzZV9vYmpbXFxcImRlZlJ1bGVzXFxcIl07XFxuICAgICAgICBleHRyYVtcXFwidmlkZW9SdWxlc1xcXCJdID0gY3VycmVudC5jb25jYXQocGFyc2Vfb2JqLmN1c3RvbV9yZWdleC5zcGxpdCgvXFxcXHwvZykuZmlsdGVyKGUgPT4gZSkpXFxuICAgIH1cXG4gICAgaWYgKHBhcnNlLmhhc093blByb3BlcnR5KFxcXCJqc1xcXCIpICYmIHBhcnNlLmpzICE9IFxcXCJcXFwiKSB7XFxuICAgICAgICBleHRyYVtcXFwianNcXFwiXSA9ICQudG9TdHJpbmcoKGpzLCBwYXJzZSwgdCkgPT4ge1xcbiAgICAgICAgICAgIGlmIChwYXJzZS5oYXNPd25Qcm9wZXJ0eShcXFwiaW5pdF9zY3JpcHRcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBmYmEubG9nKHQgKyBcXFwiOuaJp+ihjGluaXRfc2NyaXB0XFxcIik7XFxuICAgICAgICAgICAgICAgIGV2YWwocGFyc2UuaW5pdF9zY3JpcHQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBmYmEubG9nKG5hdmlnYXRvci5wbGF0Zm9ybSk7XFxuICAgICAgICAgICAgZmJhLmx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NoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgcHV0TXlWYXIoXFxcImRycHlIaWtlcl9zdWJuYW1lX2lucHV0XFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBpZDogXFxcImRycHlIaWtlcl9zdWJuYW1lX2lucHV0XFxcIlxcbiAgICB9XFxufSk7XFxubGV0IHBhdGggPSBqb2luVXJsKGdldFBhdGgoXFxcImhpa2VyOi8vZmlsZXMvXFxcIiksIFxcXCIuLi9cXFwiLnJlcGVhdCg1KSkuc2xpY2UoNyk7XFxubGF5b3V0LnB1c2goe1xcbiAgICB0aXRsZTogXFxcIumAieaLqVxcXCIsXFxuICAgIHVybDogSlNPTi5zdHJpbmdpZnkoZi5maWxlU2VsZWN0aW9uVXJpKHtcXG4gICAgICAgIGNhbGxiYWNrOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICBsZXQgdGFyZ2V0ID0gZmluZEl0ZW0oXFxcImRycHlIaWtlcl9zdWJfaW5wdXRcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJkcnB5SGlrZXJfc3ViX2lucHV0XFxcIiwge1xcbiAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih0YXJnZXQsIHtcXG4gICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgfSksXFxuICAgICAgICByb290RGlyUGF0aDogcGF0aCxcXG4gICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgcGF0dGVybjogMVxcbiAgICB9KSksXFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5YKo5a2Y6Lev5b6EXFxcIixcXG4gICAgZX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ZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKTtcXG4gICAgXFxuICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShqc29uVGV4dCk7XFxuICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgIGxldCBydWxlcyA9IFtdO1xcbiAgICBsZXQgY291bnQgPSAwO1xcbiAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCBuYW1lID0gaXQubmFtZTtcXG4gICAgICAgICAgICBsZXQgc3BhdGggPSBpdC5wYXRoO1xcbiAgICAgICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIG5hbWUgPSBuYW1lLnNsaWNlKDAsIG5hbWUubGFzdEluZGV4T2YoXFxcIi5cXFwiKSk7XFxuICAgICAgICAgICAgbGV0IHJ1bGUgPSBmZXRjaChgaHR0cHM6Ly9yYXcuZ2l0bWlycm9yLmNvbS8ke3JvcGV9L21hc3Rlci8ke3NwYXRofWApO1xcbiAgICAgICAgICAgIGlmICghKCghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSAmJiAhZmlsZUV4aXN0KHBhdGggKyBpdC5uYW1lKSkpIHtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAgICAgICAgICdhcGknOicuLi9saWJzL2RycHk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oKFxcXCIuanNcXFwiKSA/IGRlY29kZVVSSUNvbXBvbmVudChpdC5leHQuc3BsaXQoXFxcIi9cXFwiKS5hdCgtMSkpIDogKGl0Lm5hbWUgKyBcXFwiLmpzXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlO1xcbiAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGl0LmV4dCkuc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChpdC5leHQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3Qoam9pblVybCh1cmwsIGl0LmV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXCIuL1xcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QocGF0aCArIG5hbWUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG4gICAgcmV0dXJuIFxcXCJ0b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gc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImluZGV4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGZpbGUgPSB2b2lkIDA7XFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdC5maW5kKHYgPT4gdi5rZXkgPT09IGNvbmZpZy5jS2V5KTtcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgICAgIC8vY3VycmVudENvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAvL2NvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gSlNPTi5wYXJzZShmZXRjaChzZWFyY2hBbGxvd1BhdGgpIHx8IFxcXCJbXVxcXCIpO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGRlbGV0ZUZpbGUoc2VhcmNoQWxsb3dQYXRoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlLFxcbiAgICAgICAgICAgIHNlYXJjaEFsbG93LFxcbiAgICAgICAgICAgIHNvdXJjZUxpc3RcXG4gICA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mkoe1xcbiAgICAgICAgICAgIGNhbGxiYWNrOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IHRhcmdldCA9IGZpbmRJdGVtKFxcXCJkcnB5SGlrZXJfY29uZmlnX3BhdGhcXFwiKS5leHRyYTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24odGFyZ2V0LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBQQVRIXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcm9vdERpclBhdGg6IHBhdGgsXFxuICAgICAgICAgICAgaW5pdGlhbFBhdGg6IHBhdGgsXFxuICAgICAgICAgICAgcGF0dGVybjogMCxcXG4gICAgICAgICAgICBmaWxlVHlwZTogXFxcIi5qc29uXFxcIixcXG4gICAgICAgIH0pKSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIumFjee9rui3r+W+hC9VUkwg5pys5Zyw6YCJ5oupaW5kZXguanNvblxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogXFxcIlxcXCIsXFxuICAgICAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIGlkOiBcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG59XFxuaWYgKHNlbGVjdF9tb2RlID09IFxcXCIxXFxcIikge1xcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIumAieaLqVxcXCIsXFxuICAgICAgICB1cmw6IEpTT04uc3RyaW5naWZ5KGYuZmlsZVNlbGVjdGlvblVyaSh7XFxuICAgICAgICAgICAgY2FsbGJhY2s6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgdGFyZ2V0ID0gZmluZEl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfZm9sZGVyXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfZm9sZGVyXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24odGFyZ2V0LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBQQVRIXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgcm9vdERpclBhdGg6IHBhdGgsXFxuICAgICAgICAgICAgaW5pdGlhbFBhdGg6IHBhdGgsXFxuICAgICAgICAgICAgcGF0dGVybjogMSxcXG4gICAgICAgICAgICAvL2ZpbGVUeXBlOiBcXFwiLmpzb25cXFwiLFxcbiAgICAgICAgfSkpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi6YWN572u5paH5Lu25aS56Lev5b6EIOmAieaLqWRycHlfanPnm67lvZVcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFxcXCJcXFwiLFxcbiAgICAgICAgIC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3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjliqDovb3phY3nva4uLi5cXFwiKTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgfSkpIHtcXG4gICAgICAgICAgICAgICAgY29iai5jb25maWdzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibm9fbG9hZGluZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBzYXZlRmlsZShjb2JqLnBhdGgsIEpTT04uc3RyaW5naWZ5KGNvYmouY29uZmlncykpO1xcbiAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgRHJweU1hbmFnZS5jbGVhcigpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIkNoYW5nZVNvdXJjZVBvcFxcXCIpLnNob3coMTAwKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/phY3nva7mlofku7bmnInor69cXFwiO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgfSBmaW5hbGx5IHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgfVxcbiAgICB9LCBjb25maWdzX29iaiksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxufSk7XFxuXFxuaWYgKHBhdGhjb25maWdzLmxlbmd0aCkge1xcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyBcXFwiPHNtYWxsPuWOhuWPsumFjee9ruiusOW9lSDngrnmiJHov5vooYzphY3nva7mo4Dpqow8L3NtYWxsPlxcXCIsXFxuICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHApID0+IHtcXG4gICAgICAgICAgICAvL2xvZyhwKVxcbiAgICAgICAgICAgIGZ1bmN0aW9uIHVuaXF1ZShhcnIpIHtcXG4gICAgICAgICAgICAgICAgY29uc3QgcmVzID0gbmV3IE1hcCgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gYXJyLmZpbHRlcigoYSkgPT4gIXJlcy5oYXMoYSkgJiYgcmVzLnNldChhLCAxKSlcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdmFyIHJlc3VsdHMgPSBbXTtcXG4gICAgICAgICAgICBpZiAocC5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5peg5Zyw5Z2AXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGlzdCA9IHAubWFwKHggPT4geC5wYXRoKTtcXG4gICAgICAgICAgICB2YXIgdGFzayA9IGZ1bmN0aW9uKG9iaikge1xcbiAgICAgICAgICAgICAgICBsZXQgcyA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgICAgIGxldCBqc0ZpbGVzID0gW107XFxuICAgICAgICAgICAgICAgIGxldCBjb3VudCA9IDA7XFxuXFxuICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGZpbHRlck90aGVyKGxpc3QpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBsaXN0LmZpbHRlcihpdCA9PiBTdHJpbmcoaXQuYXBpKS5pbmNsdWRlcyhcXFwiZHJweTIubWluLmpzXFxcIikgfHwgU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLmpzXFxcIikpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKG9iai51cmwuc3RhcnRzV2l0aChcXFwiZmlsZTpcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvZGUgPSBcXFwibm9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGggPSBvYmoudXJsLnJlcGxhY2UoXFxcImZpbGU6Ly9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZGlyID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChkaXIuaXNEaXJlY3RvcnkoKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmbGlzdCA9IGRpci5saXN0RmlsZXMoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBmIG9mIGZsaXN0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0ganNGaWxlcy5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHZhciBqID0gSlNPTi5wYXJzZShmZXRjaChvYmoudXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIHRpbWVvdXQ6IDUwMDAsXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGUgLSBzO1xcbiAgICAgICAgICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSBqLmJvZHk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGpzb24gPSBKU09OLnBhcnNlKHBkZmgoaHRtbCwgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gbGlzdC5maWx0ZXIoeCA9PiB4Lm5hbWUuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKS5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIHt9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcblxcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgICAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgIGkgPSBpICsgMTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGZ1bmM6IHRhc2ssXFxuICAgICAgICAgICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgICAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICAgICAgICAgIGZ1bmM6IGZ1bmN0aW9uKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGNvdW50IC0gMTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5qOA5rWL5LitLi4u5Ymp5L2Z5Zyw5Z2A77yaXFxcIiArIGNvdW50KVxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0czogcmVzdWx0c1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICAgICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICAgICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBmaW5kSXRlbShcXFwicGF0aFxcXCIgKyB4LmluZGV4KTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlZ2V4ID0gLyjlkI3np7A6Lio/KShcXFxccyspP1xcXFxuL2c7XFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IFxcXCLlkI3np7A6XFxcIiArIHBbeC5pbmRleF0ubmFtZSArIFxcXCIgXFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IHBbeC5pbmRleF0ucGF0aDtcXG4gICAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQgY291bnQgPSB4LmNvdW50ICE9IDAgPyBcXFwiIOa6kOaVsOmHjzpcXFwiICsgeC5jb3VudCA6IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBpZiAoL25vLy50ZXN0KHguY29kZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YWN572u5pyJ6K+vXFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoL14oLTF8MHw0MDQpLy50ZXN0KHguY29kZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi5peg5rOV6K6/6ZeuXFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoL14yMDAvLnRlc3QoeC5jb2RlKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbXNnID0gaXRlbS50aXRsZS5yZXBsYWNlKHJlZ2V4LCB0aXRsZSArIFxcXCLpgJrorq/mraPluLhcXFwiLmZvbnRjb2xvcihcXFwiIzNDQjM3MVxcXCIpICsgXFxcIiAg5bu26L+fOlxcXCIgKyB4LnRpbWUgKyBjb3VudCArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy91cmwgPSBpdGVtLnVybDtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YWN572u5q2j56GuXFxcIi5mb250Y29sb3IoXFxcIiMzQ0IzNzFcXFwiKSArIGNvdW50ICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAvL3VybCA9IGl0ZW0udXJsO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IG1zZyxcXG4gICAgICAgICAgICAgICAgICAgIC8vdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgfSwgcGF0aGNvbmZpZ3MpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIlxcbiAgICB9KVxcbiAgICBwYXRoY29uZmlncy5mb3JFYWNoKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBsZXQgbG9uZ0MgPSBbe1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5ZCN56ewXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSwgcCwgYykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGMuZmluZEluZGV4KHggPT4geC5uYW1lID09IGl0ZW0ubmFtZSk7XFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChjW2ldLm5hbWUsIFxcXCLovpPlhaXmlrDlkI3np7BcXFwiKS5pbnB1dCgoYywgcCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNbaV0ubmFtZSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVGaWxlKHAsIEpTT04uc3RyaW5naWZ5KGMpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgYywgcCwgaSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGl0ZW0sIGNwYXRoLCBwYXRoY29uZmlncylcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIui3r+W+hFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0sIHAsIGMpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBjLmZpbmRJbmRleCh4ID0+IHgubmFtZSA9PSBpdGVtLm5hbWUpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoY1tpXS5wYXRoLCBcXFwi6L6T5YWl5paw6Lev5b6EXFxcIikuaW5wdXQoKGMsIHAsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjW2ldLnBhdGggPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzYXZlRmlsZShwLCBKU09OLnN0cmluZ2lmeShjKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGMsIHAsIGkpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBpdGVtLCBjcGF0aCwgcGF0aGNvbmZpZ3MpXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaRcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtLCBwLCBjKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gYy5maW5kSW5kZXgoeCA9PiB4Lm5hbWUgPT0gaXRlbS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGMuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUZpbGUocCwgSlNPTi5zdHJpbmdpZnkoYykpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIGl0ZW0sIGNwYXRoLCBwYXRoY29uZmlncylcXG4gICAgICAgIH1dXFxuICAgICAgICBpZiAoaXRlbS5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgIGxvbmdDLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuiuv+mXrlxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwid2ViOi8vXFxcIiArIGl0ZW0ucGF0aDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaXRlbSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGN1cnJlbnQgPSBcXFwiXFxcIjtcXG4gICAgICAgIGlmIChjdXJyZW50Y29uZmlnICYmIGN1cnJlbnRjb25maWcuaGFzT3duUHJvcGVydHkoXFxcInBhdGhcXFwiKSkge1xcbiAgICAgICAgICAgIGlmIChpdGVtLnBhdGggPT0gY3VycmVudGNvbmZpZy5wYXRoKSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBcXFwi4p6h77iPXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgXFxcIjxzbWFsbD5cXFwiICsgY3VycmVudCArIFxcXCLlkI3np7A6XFxcIiArIGl0ZW0ubmFtZSArIFxcXCJcXFxcbui3r+W+hDpcXFwiICsgaXRlbS5wYXRoICsgXFxcIjwvc21hbGw+XFxcIixcXG4gICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibm9fbG9hZGluZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIG5hbWVcXG4gICAgICAgICAgICAgICAgfSA9IGl0ZW07XFxuICAgICAgICAgICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuato+WcqOWKoOi9vemFjee9ri4uLlxcXCIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIH0pKSB7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmNsZWFyKCk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIkNoYW5nZVNvdXJjZVBvcFxcXCIpLnNob3coMTAwKTtcXG4gICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgIC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1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKS5tYXAoeCA9PiB4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICBsZXQgZmxpc3QgPSBsaXN0LmZpbHRlcih4ID0+IHguaW5jbHVkZXModGV4dCkpO1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBmbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbGV0IG5hdHVyYWwgPSBnZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmIChuYXR1cmFsID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgbGlzdC5z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IGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICBsZXQgQ2tleSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpLmtleTtcXG4gICAgICAgICAgICAvL2xvZyhDa2V5KVxcbiAgICAgICAgICAgIGxldCBjZmcgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKVxcbiAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgbmFtZVxcbiAgICAgICAgICAgIH0gPSBjZmc7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTtcXG4gICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcblxcbiAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxuICAgICAgICAgICAgbGV0IGRsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKGxpc3QsIG5zb3VyY2VzKTtcXG5cXG4gICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeC5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgbG9nKFxcXCLmlrDlop46XFxcIiArIGFsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIuaWsOWinlxcXCIgKyBhbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3Quc3BsaWNlKG1hbmFnZS5saXN0LmluZGV4T2YoeC5uYW1lKSwgMSk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGxvZyhcXFwi56e76ZmkOlxcXCIgKyBkbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgbXNnICs9IFxcXCIg56e76ZmkXFxcIiArIGRsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgdG9hc3QobXNnICsgXFxcIiDmm7TlpJror6bmg4XnnItsb2dcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdG9hc3QoXFxcIuW3suWIt+aWsFxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICB9KTtcXG4gICAgfVxcbiAgfSk7XFxufVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwiZHJweeeuoeeQhlwiLFwicGF0aFwiOlwiRHJweU1hbmFnZVwiLFwicnVsZVwiOlwianM6XFxuY29uc3QgSlNFbmdpbmUg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gICAgY29udGVudDogXFxcIui+k+WFpeWFs+mUruWtlyDnqbrmmL7npLrlhajpg6hcXFwiLFxcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaChzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkgPyBcXFwi4oCc4oCc4oCd4oCdXFxcIiArICh2Lm5hbWUgKyBcXFwiXFxcIikuZm9udGNvbG9yKFxcXCIjMDA5OTY2XFxcIikgOiB2Lm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZSA9IGNhblNlYXJjaFNvdXJjZS5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcblxcblxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2Uuc29ydCgoYSwgYikgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcbiAgICAgICAgICAgICAgICBudW1lcmljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcblxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYpKSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA1KSB7XFxuICAgICAgICAgICAgbGV0IHRlbWxpc3QgPSBzZWFyY2hBbGxvdy5zbGljZSgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKHRlbWxpc3QuaW5jbHVkZXModi5rZXkpKSByZXR1cm47XFxuICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZ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JhZ2UwLmdldE15VmFyKFxcXCJjYXRlX29ialxcXCIsIHt9KTtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfdGVtcCA9IG8uY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICBpZiAoY2F0ZV90ZW1wLmNvbnN0cnVjdG9yICE9IEFycmF5KSB7XFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5pbmRleDtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGMpXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IGkgKyBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjYXRlX29ialtvLmNhdGVdID0gY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjYXRlX3RlbXApXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfdGVtcFxcXCIsIGNhdGVfdGVtcCk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX29ialxcXCIsIGNhdGVfb2JqKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4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4gICAgICAgIHVybDogSlNPTi5zdHJpbmdpZnkoZi5maWxlU2VsZWN0aW9uVXJpKHtcXG4gICAgICAgICAgICBjYWxsYmFjazogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCB0YXJnZXQgPSBmaW5kSXRlbShcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHRhcmdldCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHJvb3REaXJQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIHBhdHRlcm46IDAsXFxuICAgICAgICAgICAgZmlsZVR5cGU6IFxcXCIuanNvblxcXCIsXFxuICAgICAgICB9KSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICAgIGRlc2M6IFxcXCLphY3nva7ot6/lvoQvVVJMIOacrOWcsOmAieaLqWluZGV4Lmpzb25cXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFxcXCJcXFwiLFxcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBpZDogXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCJcXG4gICAgICAgIH1cXG4gICAgfSk7XFxufVxcbmlmIChzZWxlY3RfbW9kZSA9PSBcXFwiMVxcXCIpIHtcXG4gICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLpgInmi6lcXFwiLFxcbiAgICAgICAgdXJsOiBKU09OLnN0cmluZ2lmeShmLmZpbGVTZWxlY3Rpb25Vcmkoe1xcbiAgICAgICAgICAgIGNhbGxiYWNrOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IHRhcmdldCA9IGZpbmRJdGVtKFxcXCJkcnB5SGlrZXJfY29uZmlnX2ZvbGRlclxcXCIpLmV4dHJhO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJkcnB5SGlrZXJfY29uZmlnX2ZvbGRlclxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHRhcmdldCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHJvb3REaXJQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIHBhdHRlcm46IDEsXFxuICAgICAgICAgICAgLy9maWxlVHlwZTogXFxcIi5qc29uXFxcIixcXG4gICAgICAgIH0pKSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgICAgZGVzYzogXFxcIumFjee9ruaWh+S7tuWkuei3r+W+hCDpgInmi6lkcnB5X2pz55uu5b2VXFxcIixcXG4gICAgICAgIGV4dHJhOi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RlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmIChydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIH0pKSB7XFxuICAgICAgICAgICAgICAgIGNvYmouY29uZmlncy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcIm5vX2xvYWRpbmdcXFwiKTtcXG4gICAgICAgICAgICAgICAgc2F2ZUZpbGUoY29iai5wYXRoLCBKU09OLnN0cmluZ2lmeShjb2JqLmNvbmZpZ3MpKTtcXG4gICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuY2xlYXIoKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJDaGFuZ2VTb3VyY2VQb3BcXFwiKS5zaG93KDEwMCk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6YWN572u5paH5Lu25pyJ6K+vXFxcIjtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgIH0gZmluYWxseSB7XFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgIH1cXG4gICAgfSwgY29uZmlnc19vYmopLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbn0pO1xcblxcbmlmIChwYXRoY29uZmlncy5sZW5ndGgpIHtcXG4gICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgXFxcIjxzbWFsbD7ljoblj7LphY3nva7orrDlvZUg54K55oiR6L+b6KGM6YWN572u5qOA6aqMPC9zbWFsbD5cXFwiLFxcbiAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChwKSA9PiB7XFxuICAgICAgICAgICAgLy9sb2cocClcXG4gICAgICAgICAgICBmdW5jdGlvbiB1bmlxdWUoYXJyKSB7XFxuICAgICAgICAgICAgICAgIGNvbnN0IHJlcyA9IG5ldyBNYXAoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGFyci5maWx0ZXIoKGEpID0+ICFyZXMuaGFzKGEpICYmIHJlcy5zZXQoYSwgMSkpXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHZhciByZXN1bHRzID0gW107XFxuICAgICAgICAgICAgaWYgKHAubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aXoOWcsOWdgFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxpc3QgPSBwLm1hcCh4ID0+IHgucGF0aCk7XFxuICAgICAgICAgICAgdmFyIHRhc2sgPSBmdW5jdGlvbihvYmopIHtcXG4gICAgICAgICAgICAgICAgbGV0IHMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICBsZXQganNGaWxlcyA9IFtdO1xcbiAgICAgICAgICAgICAgICBsZXQgY291bnQgPSAwO1xcblxcbiAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaWx0ZXJPdGhlcihsaXN0KSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbGlzdC5maWx0ZXIoaXQgPT4gU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLm1pbi5qc1xcXCIpIHx8IFN0cmluZyhpdC5hcGkpLmluY2x1ZGVzKFxcXCJkcnB5Mi5qc1xcXCIpKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChvYmoudXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb2RlID0gXFxcIm5vXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gb2JqLnVybC5yZXBsYWNlKFxcXCJmaWxlOi8vXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRpciA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoZGlyLmlzRGlyZWN0b3J5KCkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmxpc3QgPSBkaXIubGlzdEZpbGVzKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgZiBvZiBmbGlzdCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyDmo4Dmn6Xmlofku7blkI3mmK/lkKbku6UuanPnu5PlsL5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGYuaXNGaWxlKCkgJiYgZi5nZXROYW1lKCkudG9Mb3dlckNhc2UoKS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaWYgKGpzRmlsZXMubGVuZ3RoID49IDUpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGpzRmlsZXMubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogb2JqLnVybCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZTogY29kZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmRleDogb2JqLmlcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICAgICAgICAgICAgd2l0aEhlYWRlcnM6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgICB0aW1lb3V0OiA1MDAwLFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBlIC0gcztcXG4gICAgICAgICAgICAgICAgaWYgKG9iai51cmwuaW5jbHVkZXMoXFxcImdpdGh1Yi5jb21cXFwiKSAmJiBqLnN0YXR1c0NvZGUgPT0gMjAwKSB7XFxuICAgICAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gai5ib2R5O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCB7fVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhqLmJvZHkpIHx8IFxcXCJ7fVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge31cXG5cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGoudXJsLFxcbiAgICAgICAgICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICAgICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICAgICAgICAgICAgaW5kZXg6IG9iai5pLFxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICBpID0gaSArIDE7XFxuICAgICAgICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgICAgICAgICBmdW5jOiB0YXNrLFxcbiAgICAgICAgICAgICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICAgICAgaWQ6ICd0YXNraWQnICsgaVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgdmFyIGNvdW50ID0gc3VjY2VzcyA9IHRhc2tzLmxlbmd0aDtcXG4gICAgICAgICAgICBiZSh0YXNrcywge1xcbiAgICAgICAgICAgICAgICBmdW5jOiBmdW5jdGlvbihvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICAgICAgICAgICAgb2JqLnJlc3VsdHMucHVzaCh0YXNrUmVzdWx0KVxcbiAgICAgICAgICAgICAgICAgICAgY291bnQgPSBjb3VudCAtIDE7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICAgICAgICAgIGhpOiAnY2NjJyxcXG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdHM6IHJlc3VsdHNcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHN1Y2Nlc3MpO1xcbiAgICAgICAgICAgIC8vbG9nKHJlc3VsdHMpXFxuICAgICAgICAgICAgcmVzdWx0cyA9IHJlc3VsdHMuZmlsdGVyKGYgPT4gZik7XFxuICAgICAgICAgICAgcmVzdWx0cy5mb3JFYWNoKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcInBhdGhcXFwiICsgeC5pbmRleCk7XFxuICAgICAgICAgICAgICAgIGxldCByZWdleCA9IC8o5ZCN56ewOi4qPykoXFxcXHMrKT9cXFxcbi9nO1xcbiAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSBcXFwi5ZCN56ewOlxcXCIgKyBwW3guaW5kZXhdLm5hbWUgKyBcXFwiIFxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCB1cmwgPSBwW3guaW5kZXhdLnBhdGg7XFxuICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IGNvdW50ID0geC5jb3VudCAhPSAwID8gXFxcIiDmupDmlbDph486XFxcIiArIHguY291bnQgOiBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKC9uby8udGVzdCh4LmNvZGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICBtc2cgPSBpdGVtLnRpdGxlLnJlcGxhY2UocmVnZXgsIHRpdGxlICsgXFxcIumFjee9ruacieivr1xcXCIuZm9udGNvbG9yKFxcXCJyZWRcXFwiKSArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKC9eKC0xfDB8NDA0KS8udGVzdCh4LmNvZGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICBtc2cgPSBpdGVtLnRpdGxlLnJlcGxhY2UocmVnZXgsIHRpdGxlICsgXFxcIuaXoOazleiuv+mXrlxcXCIuZm9udGNvbG9yKFxcXCJyZWRcXFwiKSArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKC9eMjAwLy50ZXN0KHguY29kZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YCa6K6v5q2j5bi4XFxcIi5mb250Y29sb3IoXFxcIiMzQ0IzNzFcXFwiKSArIFxcXCIgIOW7tui/nzpcXFwiICsgeC50aW1lICsgY291bnQgKyBcXFwiXFxcXG5cXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdXJsID0gaXRlbS51cmw7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBtc2cgPSBpdGVtLnRpdGxlLnJlcGxhY2UocmVnZXgsIHRpdGxlICsgXFxcIumFjee9ruato+ehrlxcXCIuZm9udGNvbG9yKFxcXCIjM0NCMzcxXFxcIikgKyBjb3VudCArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy91cmwgPSBpdGVtLnVybDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGl0ZW0uZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBtc2csXFxuICAgICAgICAgICAgICAgICAgICAvL3VybDogdXJsLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgIH0sIHBhdGhjb25maWdzKSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCJcXG4gICAgfSlcXG4gICAgcGF0aGNvbmZpZ3MuZm9yRWFjaCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgbGV0IGxvbmdDID0gW3tcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWQjeensFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0sIHAsIGMpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBjLmZpbmRJbmRleCh4ID0+IHgubmFtZSA9PSBpdGVtLm5hbWUpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoY1tpXS5uYW1lLCBcXFwi6L6T5YWl5paw5ZCN56ewXFxcIikuaW5wdXQoKGMsIHAsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjW2ldLm5hbWUgPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzYXZlRmlsZShwLCBKU09OLnN0cmluZ2lmeShjKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGMsIHAsIGkpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBpdGVtLCBjcGF0aCwgcGF0aGNvbmZpZ3MpXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLot6/lvoRcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtLCBwLCBjKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gYy5maW5kSW5kZXgoeCA9PiB4Lm5hbWUgPT0gaXRlbS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGNbaV0ucGF0aCwgXFxcIui+k+WFpeaWsOi3r+W+hFxcXCIpLmlucHV0KChjLCBwLCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY1tpXS5wYXRoID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZUZpbGUocCwgSlNPTi5zdHJpbmdpZnkoYykpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICB9LCBjLCBwLCBpKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgaXRlbSwgY3BhdGgsIHBhdGhjb25maWdzKVxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6ZmkXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSwgcCwgYykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGMuZmluZEluZGV4KHggPT4geC5uYW1lID09IGl0ZW0ubmFtZSk7XFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBjLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVGaWxlKHAsIEpTT04uc3RyaW5naWZ5KGMpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBpdGVtLCBjcGF0aCwgcGF0aGNvbmZpZ3MpXFxuICAgICAgICB9XVxcbiAgICAgICAgaWYgKGl0ZW0ucGF0aC5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICBsb25nQy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLorr/pl65cXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0ucGF0aC5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcIndlYjovL1xcXCIgKyBpdGVtLnBhdGg7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGl0ZW0pXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBjdXJyZW50ID0gXFxcIlxcXCI7XFxuICAgICAgICBpZiAoY3VycmVudGNvbmZpZyAmJiBjdXJyZW50Y29uZmlnLmhhc093blByb3BlcnR5KFxcXCJwYXRoXFxcIikpIHtcXG4gICAgICAgICAgICBpZiAoaXRlbS5wYXRoID09IGN1cnJlbnRjb25maWcucGF0aCkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50ID0gXFxcIuKeoe+4j1xcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIFxcXCI8c21hbGw+XFxcIiArIGN1cnJlbnQgKyBcXFwi5ZCN56ewOlxcXCIgKyBpdGVtLm5hbWUgKyBcXFwiXFxcXG7ot6/lvoQ6XFxcIiArIGl0ZW0ucGF0aCArIFxcXCI8L3NtYWxsPlxcXCIsXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKGl0ZW0gPT4ge1xcbiAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcIm5vX2xvYWRpbmdcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgICAgICBuYW1lXFxuICAgICAgICAgICAgICAgIH0gPSBpdGVtO1xcbiAgICAgICAgICAgICAgICBpZiAocGF0aC5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjliqDovb3phY3nva4uLi5cXFwiKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAocnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgICAgICB9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgRHJweU1hbmFnZS5jbGVhcigpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJDaG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VxdWVzdDtcXFxcbiAgICBsZXQgJHBvc3QgPSBwb3N0O1xcXFxuICAgIGdsb2JhbFRoaXMucmVxID0gZnVuY3Rpb24gKHVybCwgY29iaikge1xcXFxuICAgICAgICB0cnkge1xcXFxuICAgICAgICAgICAgbGV0IHJlcyA9IHt9O1xcXFxuICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIGNvYmopO1xcXFxuICAgICAgICAgICAgaWYgKG9iai5kYXRhKSB7XFxcXG4gICAgICAgICAgICAgICAgb2JqLmJvZHkgPSBvYmouZGF0YTtcXFxcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqLmRhdGE7XFxcXG4gICAgICAgICAgICB9XFxcXG5cXFxcbiAgICAgICAgICAgIGlmIChvYmouaGFzT3duUHJvcGVydHkoXFxcXFxcXCJyZWRpcmVjdFxcXFxcXFwiKSkgb2JqLnJlZGlyZWN0ID0gISFvYmoucmVkaXJlY3Q7XFxcXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcXFxuICAgICAgICAgICAgICAgIG9iai50b0hleCA9IHRydWU7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBvYmouaGVhZGVycyA9IE9iamVjdC5hc3NpZ24oe1xcXFxuICAgICAgICAgICAgICAgIENvb2tpZTogXFxcXFxcXCIjbm9Db29raWUjXFxcXFxcXCJcXFxcbiAgICAgICAgICAgIH0sIG9iai5oZWFkZXJzKTtcXFxcbiAgICAgICAgICAgIGlmICh1cmwgPT09IFxcXFxcXFwiaHR0cHM6Ly9hcGkubm4uY2kvb2NyL2I2NC90ZXh0XFxcXFxcXCIgJiYgb2JqLmhlYWRlcnMpIHtcXFxcbiAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1tcXFxcXFxcIkNvbnRlbnQtVHlwZVxcXFxcXFwiXSA9IFxcXFxcXFwidGV4dC9wbGFpblxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgfVxcXFxuXFxcXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcXFxcXCJmaWxlOi8vXFxcXFxcXCIpICYmICh1cmwuaW5jbHVkZXMoXFxcXFxcXCI/dHlwZT1cXFxcXFxcIikgfHwgdXJsLmluY2x1ZGVzKFxcXFxcXFwiP3BhcmFtcz1cXFxcXFxcIikpKSB7XFxcXG4gICAgICAgICAgICAgICAgdXJsID0gdXJsLnNsaWNlKDAsIHVybC5sYXN0SW5kZXhPZihcXFxcXFxcIj9cXFxcXFxcIikpO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgZm9yIChsZXQga2V5IGluIG9iai5oZWFkZXJzKSB7XFxcXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBvYmouaGVhZGVyc1trZXldICE9PSBcXFxcXFxcInN0cmluZ1xcXFxcXFwiKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW2tleV0gPSBTdHJpbmcob2JqLmhlYWRlcnNba2V5XSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgbGV0IHIgPSBcXFxcXFxcIlxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFxcXFxcInBvc3RcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgICByID0gJHBvc3QodXJsLCBvYmopO1xcXFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxcXG4gICAgICAgICAgICAgfSovXFxcXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcXFxuICAgICAgICAgICAgaWYgKG9iai53aXRoSGVhZGVycykge1xcXFxuICAgICAgICAgICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcXFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcXFxuICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzID0ge307XFxcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXFxcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIHJldHVybiByZXM7XFxcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXFxcbiAgICAgICAgICAgIGxvZyhcXFxcXFxcIkVycm9yXFxcXFxcXCIgKyBlLnRvU3RyaW5nKCkpO1xcXFxuICAgICAgICB9XFxcXG4gICAgfVxcXFxuICAgIC8qXFxcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcXFxcXCJodHRwczovL2Nkbi5ib290Y2RuLm5ldC9hamF4L2xpYnMvbXVzdGFjaGUuanMvNC4xLjAvbXVzdGFjaGUuanNcXFxcXFxcIik7XFxcXG4gIFxcXFxuICAgIGNvbnN0IEpQID0gJC5yZXF1aXJlKFxcXFxcXFwiaHR0cHM6Ly9qc29ucGF0aC1wbHVzLmdpdGh1Yi5pby9KU09OUGF0aC9kaXN0L2luZGV4LWJyb3dzZXItdW1kLmNqc1xcXFxcXFwiKTtcXFxcbiAgICBnbG9i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Pjxicj4uKj8+KS4rL2c7XFxcXG4gICAgICB2YXIgZXhwID0gJ+WxleW8gDonO1xcXFxuICAgICAgdmFyIHJldCA9ICfmlLbotbc6JztcXFxcbiAgICAgIGlmIChzaG93ID09ICcxJykge1xcXFxuICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcXFxuICAgICAgICAgIHRpdGxlOiB0aXRsZVxcXFxuICAgICAgICAgICAgLnJlcGxhY2UocmV0LCBleHApXFxcXG4gICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIHNkYyArICc8L3NtYWxsPicpXFxcXG4gICAgICAgICAgICAucmVwbGFjZSgvKDxcXFxcXFxcXC9zbWFsbD48YnI+XFxcXFxcXFw8Zm9udCBjb2xvcj1cXFxcXFxcIikuKj8oXFxcXFxcXCI+KS8sICckMScgKyBjcy5oaWRlICsgJyQyJylcXFxcblxcXFxuICAgICAgICB9KVxcXFxuICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKG0sICcwJyk7XFxcXG4gICAgICB9IGVsc2Uge1xcXFxuICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcXFxuICAgICAgICAgIHRpdGxlOiB0aXRsZVxcXFxuICAgICAgICAgICAgLnJlcGxhY2UoZXhwLCByZXQpXFxcXG4gICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIGRjICsgJzwvc21hbGw+JylcXFxcbiAgICAgICAgICAgIC5yZXBsYWNlKC8oPFxcXFxcXFxcL3NtYWxsPjxicj5cXFxcXFxcXDxmb250IGNvbG9yPVxcXFxcXFwiKS4qPyhcXFxcXFxcIj4pLywgJyQxJyArIGNzLnNob3cgKyAnJDInKVxcXFxuICAgICAgICB9KVxcXFxuICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKG0sICcxJyk7XFxcXG4gICAgICB9XFxcXG4gICAgICByZXR1cm4gYGhpa2VyOi8vZW1wdHlgXFxcXG4gICAgfSwgZGVzYywgc2Rlc2MsIG1hcmssIGNvbG9ycylcXFx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uXFxcXFxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLmdldEpzb24oKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcXFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcXFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcXFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcXFxcXCLnva7pobZcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5nZXRKc29uKCk7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcXFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcXFxcXCLliKDpmaRcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXFxcXFwi56Gu6K6k5Yig6Zmk77yfXFxcXFxcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuZ2V0SnNvbigpO1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFxcXFxcImNvbmZpZ3NcXFxcXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcXFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcXFxcXCIgKyBydWxlLm5hbWU7XFxcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcXFxuICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5nZXRKc29uKCk7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBhcnJbaW5kZXhdO1xc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FwiKTtcXFxcbiAgICAgICAgICAgIGxldCBydW5UeXBlID0gZ2V0TXlWYXIoXFxcXFxcXCJwc19ydW5UeXBlXFxcXFxcXCIsIFxcXFxcXFwiV0VCXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXFxcXFwicHNfbWV0aG9kXFxcXFxcXCIsIFxcXFxcXFwiR0VUXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgbGV0IGpzb25QYXRoID0gZ2V0TXlWYXIoXFxcXFxcXCJwc19qc29uUGF0aFxcXFxcXFwiLCBcXFxcXFxcIlxcXFxcXFwiKS50cmltKCkgfHwgdm9pZCAwO1xcXFxuICAgICAgICAgICAgbGV0IGpzID0gZ2V0TXlWYXIoXFxcXFxcXCJwc19qc1xcXFxcXFwiLCBcXFxcXFxcIlxcXFxcXFwiKSB8fCB2b2lkIDA7XFxcXG4gICAgICAgICAgICBpZiAoaGVhZGVycykge1xcXFxuICAgICAgICAgICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMgPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcXFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFxcXFxcIiArIGUudG9TdHJpbmcoKTtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXFxcXFwidmlkZW9VcmxcXFxcXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcXFxuICAgICAgICAgICAgICAgIG5hbWUsXFxcXG4gICAgICAgICAgICAgICAgdXJsLFxcXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXFxcbiAgICAgICAgICAgICAgICByd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AgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXFxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcXFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcXFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xc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ICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFxcXFxcIuW3suabtOaWsOinhOWIme+8mlxcXFxcXFwiICsgcnVsZS5uYW1lKTtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFxcXFxcIiArIHJ1bGUubmFtZSlcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgIG5ld0krKztcXFxcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcXFxcXCIgKyBydWxlVGl0bGU7XFxcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcXFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFxcXFxcIiArIHJ1bGUubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXFxcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcXFxcXCIgKyBydWxlLm5hbWUpXFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9XFxcXG4gICAgICAgIGlmIChydWxlcy5sZW5ndGggPiAxKSB7XFxcXG4gICAgICAgICAgICAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzP3J1bGU9XFxcXFxcXCIgKyBydWxlVGl0bGUpLnNhdmVKc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iBbXTtcXFxcbiAgICAgICAgfVxcXFxuICAgICAgICBsZXQgcGF0aCA9IFtdO1xcXFxuICAgICAgICBsZXQgY3VycmVudCA9ICcnO1xcXFxuICAgICAgICBsZXQgaW5CcmFja2V0cyA9IGZhbHNlO1xcXFxuICAgICAgICBsZXQgZXNjYXBlID0gZmFsc2U7XFxcXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdmFsdWUubGVuZ3RoOyBpKyspIHtcXFxcbiAgICAgICAgICAgIGxldCBjaGFyID0gdmFsdWVbaV07XFxcXG4gICAgICAgICAgICBpZiAoZXNjYXBlKSB7XFxcXG4gICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcXFxuICAgICAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXFxcXFxcXFxcXFxcXFxcXCcpIHtcXFxcbiAgICAgICAgICAgICAgICBlc2NhcGUgPSB0cnVlO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnLicgJiYgIWluQnJhY2tldHMpIHtcXFxcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxcXG4gICAgICAgICAgICAgICAgY3VycmVudCA9ICcnO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnWycpIHtcXFxcbiAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXFxcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ10nKSB7XFxcXG4gICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IGZhbHNlO1xcXFxuICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgaWYgKGN1cnJlbnQpIHtcXFxcbiAgICAgICAgICA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xcXFxuICAgICAgICAgICAgbGV0IHBhcmFtID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXFxcbiAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KHVybCwge1xcXFxuICAgICAgICAgICAgICAgIGhlYWRlcnM6IHBhcmFtLmhlYWRlcnMgfHwge30sXFxcXG4gICAgICAgICAgICAgICAgbWV0aG9kOiBwYXJhbS5tZXRob2QgfHwgdm9pZCAwXFxcXG4gICAgICAgICAgICB9KSk7XFxcXG4gICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcXFxuICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzOiBPYmplY3QuYXNzaWduKHt9LCBwYXJhbS5oZWFkZXJzIHx8IHt9LCB7XFxcXG4gICAgICAgICAgICAgICAgICAgIFxcXFxcXFwiTG9jYXRpb25cXFxcXFxcIjogZ2V0SnNvbihqc29uLCB0b1BhdGgocGFyYW0uanNvblBhdGgpKSxcXFxcbiAgICAgICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PSBcXFxcXFxcIkpTXFxcXFxcXCIpIHtcXFxcblxcXFxuICAgICAgICAgICAgbGV0IHBhcnNlO1xcXFxuICAgICAgICAgICAgaWYgKE1ZX1BBUkFNUy5pbmRleCkge1xcXFxuICAgICAgICAgICAgICAgIHBhcnNlID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlncz9ydWxlPVxcXFxcXFwiICsgdGl0bGUpLmdldEpzb24oKVtNWV9QQVJBTVMuaW5kZXhbMF1dO1xcXFxuICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICBwYXJzZSA9IEpTT04ucGFyc2UoZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBsZXQgcmVzID0gbmV3IEZ1bmN0aW9uKFxcXFxcXFwidXJsXFxcXFxcXCIsIFxcXFxcXFwic2VsZlxcXFxcXFwiLCBwYXJzZS5qcykodXJsLCBwYXJzZSk7XFxcXG4gICAgICAgICAgICBpZiAodHlwZW9mIHJlcyA9PT0gXFxcXFxcXCJzdHJpbmdcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXFxcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcXFxcXCJMb2NhdGlvblxcXFxcXFwiOiByZXNcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgfSBlbHNlIGlmICgkLnR5cGUocmVzKSA9PT0gXFxcXFxcXCJvYmplY3RcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXFxcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcmVzXFxcXG4gICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgIH1cXFxcbiAgICB9IGNhdGNoIChlKSB7XFxcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcXFxuICAgIH1cXFxcbn1cXFxcblxcXFxuZnVuY3Rpb24gcHJlcGFyZVBhcnNlcyhwYXJzZXMsIHVybCwgcGxheWxpc3QsIGlzVGVzdCkge1xcXFxuICAgIHBsYX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FxcXCJkcnB5Mi5qc1xcXFxcXFwiKSkpIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGl0LmV4dC5lbmRzV2l0aChcXFxcXFxcIi5qc1xcXFxcXFwiKSA/IGRlY29kZVVSSUNvbXBvbmVudChpdC5leHQuc3BsaXQoXFxcXFxcXCIvXFxcXFxcXCIpLmF0KC0xKSkgOiAoaXQubmFtZSArIFxcXFxcXFwiLmpzXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgIGxldCBydWxlO1xcXFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaXQuZXh0KS5zdGFydHNXaXRoKFxcXFxcXFwiaHR0cFxcXFxcXFwiKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChpdC5leHQpO1xcXFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGpvaW5VcmwodXJsLCBpdC5leHQpKTtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcXFxcXCIuL1xcXFxcXFwiICsgbmFtZTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcXFxcXCJydWxlXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcXFxuICAgICAgICAgICAgICAgIH07XFxcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9IG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ChcXFxcXFxcImh0dHBzOi8vZ2l0aHViLmNvbVxcXFxcXFwiKSkge1xcXFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGdlbmVyYXRlQ29uZmlnQnlHaXRodWIoY29uZmlnLnBhdGgpO1xcXFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFxcXFxcImdpdGh1YkRpclxcXFxcXFwiO1xcXFxuICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoZmV0Y2goY29uZmlnLnBhdGgpIHx8IFxcXFxcXFwie31cXFxcXFxcIikpO1xcXFxuICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8ICFqc29uLnNpdGVzLmxlbmd0aCkge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBudWxsO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcXFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFxcXFxcImluZGV4XFxcXFxcXCI7XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgZmlsZSA9IHZvaWQgMDtcXFxcbiAgICAgICAgbGV0IGN1cnJlbnRTb3VyY2UsIHNlYXJjaEFsbG93O1xcXFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXFxcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcXFxuICAgICAgICAgICAgaWYgKCFjdXJyZW50U291cmNlKSB7XFxcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2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mE6IE9iamVjdC5hc3NpZ24odGFyZ2V0LCB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFBBVEhcXFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXFxcbiAgICAgICAgICAgIH0pLFxcXFxuICAgICAgICAgICAgcm9vdERpclBhdGg6IHBhdGgsXFxcXG4gICAgICAgICAgICBpbml0aWFsUGF0aDogcGF0aCxcXFxcbiAgICAgICAgICAgIHBhdHRlcm46IDAsXFxcXG4gICAgICAgICAgICBmaWxlVHlwZTogXFxcXFxcXCIuanNvblxcXFxcXFwiLFxcXFxuICAgICAgICB9KSksXFxcXG4gICAgICAgIGNvbF90eXBlOiBcXFxcXFxcImlucHV0XFxcXFxcXCIsXFxcXG4gICAgICAgIGRlc2M6IFxcXFxcXFwi6YWN572u6Lev5b6EL1VSTCDmnKzlnLDpgInmi6lpbmRleC5qc29uXFxcXFxcXCIsXFxcXG4gICAgICAgIGV4dHJhOiB7XFxcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFxcXFxcXFwiXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcXFxcXCJkcnB5SGlrZXJfY29uZmlnX3BhdGhcXFxcXFxcIiwgaW5wdXQpO1xcXFxuICAgICAgICAgICAgfSksXFxcXG4gICAgICAgICAgICBpZDogXFxcXFxcXCJkcnB5SGlrZXJfY29uZmlnX3BhdGhcXFxcXFxcIlxcXFxuICAgICAgICB9XFxcXG4gICAgfSk7XFxcXG59XFxcXG5pZiAoc2VsZWN0X21vZGUgPT0gXFxcXFxcXCIxXFxcXFxcXCIpIHtcXFxcbiAgICBsYXlvdXQucHVzaCh7XFxcXG4gICAgICAgIHRpdGxlOiBcXFxcXFxcIumAieaLqVxcXFxcXFwiLFxcXFxuICAgICAgICB1cmw6IEpTT04uc3RyaW5naWZ5KGYuZmlsZVNlbGVjdGlvblVyaSh7XFxcXG4gICAgICAgICAgICBjYWxsYmFjazogJC50b1N0cmluZygoKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHRhcmdldCA9IGZpbmRJdGVtKFxcXFxcXFwiZHJweUhpa2VyX2NvbmZpZ19mb2xkZXJcXFxcXFxcIikuZXh0cmE7XFxcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFxcXFxcImRycHlIaWtlcl9jb25maWdfZm9sZGVyXFxcXFxcXCIsIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24odGFyZ2V0LCB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFBBVEhcXFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXFxcbiAgICAgICAgICAgIH0pLFxcXFxuICAgICAgICAgICAgcm9vdERpclBhdGg6IHBhdGgsXFxcXG4gICAgICAgICAgICBpbml0aWFsUGF0aDogcGF0aCxcXFxcbiAgICAgICAgICAgIHBhdHRlcm46IDEsXFxcXG4gICAgICAgICAgICAvL2ZpbGVUeXBlOiBcXFxcXFxcIi5qc29uXFxcXFxcXCIsXFxcXG4gICAgICAgIH0pKSxcXFxcbiAgICAgICAgY29sX3R5cGU6IFxcXFxcXFwiaW5wdXRcXFxcXFxcIixcXFxcbiAgICAgICAgZGVzYzogXFxcXFxcXCLphY3nva7mlofku7blpLnot6/lvoQg6YCJ5oupZHJweV9qc+ebruW9lVxcXFxcXFwiLFxcXFxuICAgICAgICBleHRyYToge1xcXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBcXFxcXFxcIlxcXFxcXFwiLFxcXFxuICA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aWxlOi8vXFxcXFxcXCIgKyBwYXRoKSA6IHBhdGg7XFxcXG4gICAgICAgIC8vbG9nKHBhdGgpXFxcXG4gICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFxcXFxcInJ1bnRpbWVDb25maWdcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICBpZiAocGF0aC5zdGFydHNXaXRoKFxcXFxcXFwiaHR0cFxcXFxcXFwiKSkge1xcXFxuICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXFxcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgfVxcXFxuXFxcXG4gICAgICAgICAgICBpZiAocnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXFxcbiAgICAgICAgICAgICAgICAgICAgbmFtZSxcXFxcbiAgICAgICAgICAgICAgICB9KSkge1xcXFxuICAgICAgICAgICAgICAgIGNvYmouY29uZmlncy5wdXNoKHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcGF0aCxcXFxcbiAgICAgICAgICAgICAgICAgICAgbmFtZSxcXFxcbiAgICAgICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFxcXFxcIm5vX2xvYWRpbmdcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgc2F2ZUZpbGUoY29iai5wYXRoLCBKU09OLnN0cmluZ2lmeShjb2JqLmNvbmZpZ3MpKTtcXFxcbiAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXFxcbiAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFxcXFxcIkRycHlNYW5hZ2VcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgRHJweU1hbmFnZS5jbGVhcigpO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cy5oYXMoYSkgJiYgcmVzLnNldChhLCAxKSlcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIHZhciByZXN1bHRzID0gW107XFxcXG4gICAgICAgICAgICBpZiAocC5sZW5ndGggPT0gMCkge1xcXFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcInRvYXN0Oi8v5peg5Zyw5Z2AXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICBsaXN0ID0gcC5tYXAoeCA9PiB4LnBhdGgpO1xcXFxuICAgICAgICAgICAgdmFyIHRhc2sgPSBmdW5jdGlvbihvYmopIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgcyA9IERhdGUubm93KCk7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGpzRmlsZXMgPSBbXTtcXFxcbiAgICAgICAgICAgICAgICBsZXQgY291bnQgPSAwO1xcXFxuXFxcXG4gICAgICAgICAgICAgICAgZnVuY3Rpb24gZmlsdGVyT3RoZXIobGlzdCkge1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gbGlzdC5maWx0ZXIoaXQgPT4gU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcXFxcXCJkcnB5Mi5taW4uanNcXFxcXFxcIikgfHwgU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcXFxcXCJkcnB5Mi5qc1xcXFxcXFwiKSlcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgaWYgKG9iai51cmwuc3RhcnRzV2l0aChcXFxcXFxcImZpbGU6XFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBjb2RlID0gXFxcXFxcXCJub1xcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IG9iai51cmwucmVwbGFjZShcXFxcXFxcImZpbGU6Ly9cXFxcXFxcIiwgXFxcXFxcXCJcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBkaXIgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcXFxuICAgICAgICAgICAgICAgICAgICBpZiAoZGlyLmlzRGlyZWN0b3J5KCkpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmbGlzdCA9IGRpci5saXN0RmlsZXMoKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGYgb2YgZmxpc3QpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyDmo4Dmn6Xmlofku7blkI3mmK/lkKbku6UuanPnu5PlsL5cXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXFxcXFwiLmpzXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2RlID0gXFxcXFxcXCJva1xcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGpzRmlsZXMubGVuZ3RoO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IFxcXFxcXFwib2tcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGltZTogKERhdGUubm93KCkgLSBzKSxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogb2JqLnVybCxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvZGU6IGNvZGUsXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmRleDogb2JqLmlcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcXFxuICAgICAgICAgICAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXFxcbiAgICAgICAgICAgICAgICAgICAgdGltZW91dDogNTAwMCxcXFxcbiAgICAgICAgICAgICAgICB9KSk7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcXFxuICAgICAgICAgICAgICAgIGxldCBjID0gZSAtIHM7XFxcXG4gICAgICAgICAgICAgICAgaWYgKG9iai51cmwuaW5jbHVkZXMoXFxcXFxcXCJnaXRodWIuY29tXFxcXFxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gai5ib2R5O1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGpzb24gPSBKU09OLnBhcnNlKHBkZmgoaHRtbCwgXFxcXFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFxcXFxcIikpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gbGlzdC5maWx0ZXIoeCA9PiB4Lm5hbWUuZW5kc1dpdGgoXFxcXFxcXCIuanNcXFxcXFxcIikpLmxlbmd0aDtcXFxcbiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCB7fVxcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICB0cnkge1xcXFxuICAgICAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhqLmJvZHkpIHx8IFxcXFxcXFwie31cXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxcXG5cXFxcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcXFxuICAgICAgICAgICAgICAgICAgICB0aW1lOiBjLFxcXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IGoudXJsLFxcXFxuICAgICAgICAgICAgICAgICAgICBjb3VudDogY291bnQsXFxcXG4gICAgICAgICAgICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXFxcbiAgICAgICAgICAgICAgICAgICAgaW5kZXg6IG9iai5pLFxcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH07XFxcXG4gICAgICAgICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcXFxuICAgICAgICAgICAgICAgIGkgPSBpICsgMTtcXFxcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcXFxuICAgICAgICAgICAgICAgICAgICBmdW5jOiB0YXNrLFxcXFxuICAgICAgICAgICAgICAgICAgICBwYXJhbToge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiB4LFxcXFxuICAgICAgICAgICAgICAgICAgICAgICAgaTogaSAtIDEsXFxcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxcXG4gICAgICAgICAgICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIHZhciBjb3VudCA9IHN1Y2Nlc3MgPSB0YXNrcy5sZW5ndGg7XFxcXG4gICAgICAgICAgICBiZSh0YXNrcywge1xcXFxuICAgICAgICAgICAgICAgIGZ1bmM6IGZ1bmN0aW9uKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIG9iai5yZXN1bHRzLnB1c2godGFza1Jlc3VsdClcXFxcbiAgICAgICAgICAgICAgICAgICAgY291bnQgPSBjb3VudCAtIDE7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IDApIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXFxcXFwi5qOA5rWL5LitLi4u5Ymp5L2Z5Zyw5Z2A77yaXFxcXFxcXCIgKyBjb3VudClcXFxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICB9LFxcXFxuICAgICAgICAgICAgICAgIHBhcmFtOiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGhpOiAnY2NjJyxcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0czogcmVzdWx0c1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0sIHN1Y2Nlc3MpO1xcXFxuICAgICAgICAgICAgLy9sb2cocmVzdWx0cylcXFxcbiAgICAgICAgICAgIHJlc3VsdHMgPSByZXN1bHRzLmZpbHRlcihmID0+IGYpO1xcXFxuICAgICAgICAgICAgcmVzdWx0cy5mb3JFYWNoKCh4LCBpKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBmaW5kSXRlbShcXFxcXFxcInBhdGhcXFxcXFxcIiArIHguaW5kZXgpO1xcXFxuICAgICAgICAgICAgICAgIGxldCByZWdleCA9IC8o5ZCN56ewOi4qPykoXFxcXFxcXFxzKyk/XFxcXFxcXFxuL2c7XFxcXG4gICAgICAgICAgICAgICAgbGV0IHRpdGxlID0gXFxcXFxcXCLlkI3np7A6XFxcXFxcXCIgKyBwW3guaW5kZXhdLm5hbWUgKyBcXFxcXFxcIiBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICBsZXQgdXJsID0gcFt4LmluZGV4XS5wYXRoO1xcXFxuICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFxcXFxcIlxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgIGxldCBjb3VudCA9IHguY291bnQgIT0gMCA/IFxcXFxcXFwiIOa6kOaVsO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aXRsZSArIFxcXFxcXFwi6YWN572u5q2j56GuXFxcXFxcXCIuZm9udGNvbG9yKFxcXFxcXFwiIzNDQjM3MVxcXFxcXFwiKSArIGNvdW50ICsgXFxcXFxcXCJcXFxcXFxcXG5cXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgIC8vdXJsID0gaXRlbS51cmw7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcXFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogbXNnLFxcXFxuICAgICAgICAgICAgICAgICAgICAvL3VybDogdXJsLFxcXFxuICAgICAgICAgICAgICAgIH0pXFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vZW1wdHlcXFxcXFxcIlxcXFxuICAgICAgICB9LCBwYXRoY29uZmlncyksXFxcXG4gICAgICAgIGNvbF90eXBlOiBcXFxcXFxcInRleHRfY2VudGVyXzFcXFxcXFxcIlxcXFxuICAgIH0pXFxcXG4gICAgcGF0aGNvbmZpZ3MuZm9yRWFjaCgoaXRlbSwgaSkgPT4ge1xcXFxuICAgICAgICBsZXQgbG9uZ0MgPSBbe1xcXFxuICAgICAgICAgICAgdGl0bGU6IFxcXFxcXFwi5ZCN56ewXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSwgcCwgYykgPT4ge1xcXFxuICAgICAgICAgICAgICAgIGxldCBpID0gYy5maW5kSW5kZXgoeCA9PiB4Lm5hbWUgPT0gaXRlbS5uYW1lKTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChjW2ldLm5hbWUsIFxcXFxcXFwi6L6T5YWl5paw5ZCN56ewXFxcXFxcXCIpLmlucHV0KChjLCBwLCBpKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjW2ldLm5hbWUgPSBpbnB1dDtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVGaWxlKHAsIEpTT04uc3RyaW5naWZ5KGMpKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIH0sIGMsIHAsIGkpXFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfSwgaXRlbSwgY3BhdGgsIHBhdGhjb25maWdzKVxcXFxuICAgICAgICB9LCB7XFxcXG4gICAgICAgICAgICB0aXRsZTogXFxcXFxcXCLot6/lvoRcXFxcXFxcIixcXFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtLCBwLCBjKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBjLmZpbmRJbmRleCh4ID0+IHgubmFtZSA9PSBpdGVtLm5hbWUpO1xcXFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGNbaV0ucGF0aCwgXFxcXFxcXCLovpPlhaXmlrDot6/lvoRcXFxcXFxcIikuaW5wdXQoKGMsIHAsIGkpID0+IHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNbaV0ucGF0aCA9IGlucHV0O1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZUZpbGUocCwgSlNPTi5zdHJpbmdpZnkoYykpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgfSwgYywgcCwgaSlcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9LCBpdGVtLCBjcGF0aCwgcGF0aGNvbmZpZ3MpXFxcXG4gICAgICAgIH0sIHtcXFxcbiAgICAgICAgICAgIHRpdGxlOiBcXFxcXFxcIuWIoOmZpFxcXFxcXFwiLFxcXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0sIHAsIGMpID0+IHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGMuZmluZEluZGV4KHggPT4geC5uYW1lID09IGl0ZW0ubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYy5zcGxpY2UoaSwgMSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVGaWxlKHAsIEpTT04uc3RyaW5naWZ5KGMpKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9LCBpdGVtLCBjcGF0aCwgcGF0aGNvbmZpZ3MpXFxcXG4gICAgICAgIH1dXFxcXG4gICAgICAgIGlmIChpdGVtLnBhdGguc3RhcnRzV2l0aChcXFxcXFxcImh0dHBcXFxcXFxcIikpIHtcXFxcbiAgICAgICAgICAgIGxvbmdDLnB1c2goe1xcXFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFxcXFxcIuiuv+mXrlxcXFxcXFwiLFxcXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLnBhdGguc3RhcnRzV2l0aChcXFxcXFxcImh0dHBcXFxcXFxcIikpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcIndlYjovL1xcXFxcXFwiICsgaXRlbS5wYXRoO1xcXFxuICAgICAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICAgICAgfSwgaXRlbSlcXFxcbiAgICAgICAgICAgIH0pXFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgbGV0IGN1cnJlbnQgPSBcXFxcXFxcIlxcXFxcXFwiO1xcXF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gICAgICAgICAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXFxcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgICAgICBpZiAocnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgsXFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lLFxcXFxuICAgICAgICAgICAgICAgICAgICB9KSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcXFxcXCJEcnB5TWFuYWdlXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmNsZWFyKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFxcXFxcIkNoYW5nZVNvdXJjZVBvcFxcXFxcXFwiKS5zaG93KDEwMCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vZW1wdHlcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+WIh+aNouWksei0pVxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0sIGl0ZW0pLFxcXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXFxcXFwidGV4dF8xXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICBleHRyYToge1xcXFxuICAgICAgICAgICAgICAgI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tlyDnqbrmmL7npLrlhajpg6hcXFxcXFxcIixcXFxcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXFxcXFwi562b6YCJ5rqQXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgIGhpbnQ6IFxcXFxcXFwi5rqQ5YWz6ZSu5a2XXFxcXFxcXCIsXFxcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxcXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFxcXFxcInJ1bnRpbWVDb25maWdcXFxcXFxcIiwgXFxcXFxcXCJydW50aW1lQ29uZmlnXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpLm1hcCh4ID0+IHgubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gbGlzdC5maWx0ZXIoeCA9PiB4LmluY2x1ZGVzKHRleHQpKTtcXFxcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcXFxuICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcXFxuICAgICAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgICA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cIik7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXFxcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXFxcbiAgICAgICAgICAgIG5hbWVzLnJldmVyc2UoKTtcXFxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXFxcbiAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXFxcbiAgICAgICAgICAgICAgY29uc3QgbWFwID0gbmV3IE1hcChhcnIyLm1hcChpdGVtID0+IFtpdGVtLmtleSwgaXRlbV0pKTtcXFxcbiAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXFxcbiAgICAgICAgICAgIH1cXFxcblxcXFxuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcXFxcXCJydW50aW1lQ29uZmlnXFxcXFxcXCIsIFxcXFxcXFwicnVudGltZUNvbmZpZ1xcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXFxcbiAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcXFxuICAgICAgICAgICAgLy9sb2coQ2tleSlcXFxcbiAgICAgICAgICAgIGxldCBjZmcgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKVxcXFxuICAgICAgICAgICAgbGV0IHtcXFxcbiAgICAgICAgICAgICAgcGF0aCxcXFxcbiAgICAgICAgICAgICAgbmFtZVxcXFxuICAgICAgICAgICAgfSA9IGNmZztcXFxcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxcXG4gICAgICAgICAgICAgIHBhdGgsXFxcXG4gICAgICAgICAgICAgIG5hbWUsXFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTtcXFxcbiAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxcXG5cXFxcbiAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxcXG4gICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcXFxuXFxcXG4gICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxcXG4gICAgICAgICAgICAgIGxldCBtc2cgPSBcXFxcXFxcIlxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcXFxuICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLmlrDlop46XFxcXFxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcXFxcXCIsXFxcXFxcXCIpKVxcXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFxcXFxcIuaWsOWinlxcXFxcXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcXFxcXCLkuKrmupBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcXFxuICAgICAgICAgICAgICAgIGRs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4oCc4oCd4oCdXFxcXFxcXCIgKyAodi5uYW1lICsgXFxcXFxcXCJcXFxcXFxcIikuZm9udGNvbG9yKFxcXFxcXFwiIzAwOTk2NlxcXFxcXFwiKSA6IHYubmFtZSlcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXFxcbiAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcXFxuXFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXFxcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFxcXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcXFxcXCIgKyB0ZXh0O1xcXFxuICAgICAgICAgICAgICB9LFxcXFxuXFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXFxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcXFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXFxcblxcXFxuXFxcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXFxcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcXFxuICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxcXG4gICAgICAgICAgICAgICAgc2Vuc2l0aXZpdHk6ICdiYXNlJ1xcXFxuICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXFxcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXFxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcXFxuXFxcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXFxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXFxcbiAgICAgICAgICAgICAgaWYgKCFzZWFyY2hBbGxvdy5pbmNsdWRlcyh2KSkge1xcXFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcXFxuICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcXFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcXFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcXFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA1KSB7XFxcXG4gICAgICAgICAgICBsZXQgdGVtbGlzdCA9IHNlYXJjaEFsbG93LnNsaWNlKCk7XFxcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcXFxuICAgICAgICAgICAgICBpZiAodGVtbGlzdC5pbmNsdWRlcyh2LmtleSkpIHJldHVybj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HtcXFxcbiAgICAgICAgICAgICAgICBsZXQgaSA9IG8uaTtcXFxcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFxcXFxcImlzX2RlZlxcXFxcXFwiLCBcXFxcXFxcIjFcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcXFxcXCJjYXRlX29ialxcXFxcXFwiLCB7fSk7XFxcXG5cXFxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcXFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXFxcXFwiLTFcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXFxcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXFxcXFwiLTFcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXFxcXFwiXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIo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RpYWxQYXRoOiBwYXRoLFxcXFxufSwgTVlfUEFSQU1TLm5ld1dpbmRvdyA/IFtdIDogW3tcXFxcbiAgICB0aXRsZTogXFxcXFxcXCLmlrDnqpflj6PmiZPlvIBcXFxcXFxcIixcXFxcbiAgICBjb2xfdHlwZTogXFxcXFxcXCJ0ZXh0X2NlbnRlcl8xXFxcXFxcXCIsXFxcXG4gICAgdXJsOiBcXFxcXFxcImhpa2VyOi8vcGFnZS9Mb2NhbERpciNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFxcXFxcIixcXFxcbiAgICBleHRyYToge1xcXFxuICAgICAgICBjcGF0aDogTVlfUEFSQU1TLmNwYXRoLFxcXFxuICAgICAgICBuZXdXaW5kb3c6IHRydWUsXFxcXG4gICAgICAgIHdpbmRvd0lkOiBNWV9SVUxFLnRpdGxlICsgXFxcXFxcXCJAZWRpdGZpbGVcXFxcXFxcIixcXFxcbiAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcXFxuICAgICAgICBwYWdlVGl0bGU6IFxcXFxcXFwi5paH5Lu2566h55CGXFxcXFxcXCJcXFxcbiAgICB9XFxcXG59XSk7XFxcIn1dXCIsXCJwcm94eVwiOlwiXCJ9IiwidGl0bGUiOiLliJvlu7rphY3nva4ifQ==
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement