Advertisement
xiaomianao666

邀您一起看:创建配置

Nov 6th, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:二级页面详情¥page_detail¥创建配置@@eyJkYXRhIjoie1wiYXNzb2NpYXRlZE1vZGVsc01hcEZvckpvaW5UYWJsZVwiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhGS1wiOnt9LFwiYXNzb2NpYXRlZE1vZGVsc01hcFdpdGhvdXRGS1wiOnt9LFwiZmllbGRzVG9TZXRUb0RlZmF1bHRcIjpbXSxcImdtdE1vZGlmaWVkXCI6MCxcImlkXCI6MCxcImxhc3RfY2hhcHRlcl9ydWxlXCI6XCJcIixcImxpc3RUb0NsZWFyQXNzb2NpYXRlZEZLXCI6W10sXCJsaXN0VG9DbGVhclNlbGZGS1wiOltdLFwicGFnZUxpc3RcIjpbe1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHlcIixcInBhdGhcIjpcImRycHlcIixcInJ1bGVcIjpcImZ1bmN0aW9uIGluaXRIaWtlcigpIHtcXG4gICAgY29uc3QgaXNDbG9zZUxvZyA9ICFnZXRJdGVtKFxcXCJ1c2VMb2dcXFwiLCBcXFwiXFxcIik7XFxuICAgIGNvbnN0IGxvY2FsS2V5ID0gXFxcImRycHlcXFwiO1xcbiAgICBjb25zdCBDcnlwdG9VdGlsID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL2Fzc2V0cy9jcnlwdG8tamF2YS5qc1xcXCIpO1xcbiAgICBnbG9iYWxUaGlzLmxvY2FsID0ge1xcbiAgICAgICAgc2V0KHJ1bGVrZXksIGssIHYpIHtcXG4gICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKGxvY2FsS2V5ICsgXFxcIkBcXFwiICsgcnVsZWtleSArIFxcXCJAXFxcIiArIGssIHYpO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGdldChydWxla2V5LCBrLCB2KSB7XFx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PYmplY3QuYXNzaWduKHtcXG4gICAgICAgICAgICAgICAgQ29va2llOiBcXFwiI25vQ29va2llI1xcXCJcXG4gICAgICAgICAgICB9LCBvYmouaGVhZGVycyk7XFxuICAgICAgICAgICAgaWYgKHVybCA9PT0gXFxcImh0dHBzOi8vYXBpLm5uLmNpL29jci9iNjQvdGV4dFxcXCIgJiYgb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNbXFxcIkNvbnRlbnQtVHlwZVxcXCJdID0gXFxcInRleHQvcGxhaW5cXFwiO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSAmJiAodXJsLmluY2x1ZGVzKFxcXCI/dHlwZT1cXFwiKSB8fCB1cmwuaW5jbHVkZXMoXFxcIj9wYXJhbXM9XFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9iai5oZWFkZXJzW2tleV0gIT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFwicG9zdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcbiAgICAgICAgICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIkVycm9yXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgLypcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vY2RuLmJvb3RjZG4ubmV0L2FqYXgvbGlicy9tdXN0YWNoZS5qcy80LjEuMC9tdXN0YWNoZS5qc1xcXCIpO1xcbiAgXFxuICAgIGNvbnN0IEpQID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2pzb25wYXRoLXBsdXMuZ2l0aHViLmlvL0pTT05QYXRoL2Rpc3QvaW5kZXgtYnJvd3Nlci11bWQuY2pzXFxcIik7XFxuICAgIGdsb2JhbFRoaXMuY2hlZXJpbyA9IHtcXG4gICAgICAgIGppbmphMih0ZW1wbGF0ZSwgb2JqKSB7XFxuICAgICAgICAgICAgXFxuICAgICAgICAgICAgcmV0dXJuICQubG9nKEppbkphLnJlbmRlcih0ZW1wbGF0ZSwgb2JqKSk7XFxuICAgICAgICB9LFxcbiAgICAgICAganAocGF0aCwganNvbikge1xcbiAgICAgICAgICAgIHJldHVybiBKUC5KU09OUGF0aCh7XFxuICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgIGpzb25cXG4gICAgICAgICAgICB9KVswXTtcXG4gICAgICAgIH1cXG4gICAgfSovXFxuICAgIGdsb2JhbFRoaXMucGRmYSA9IF9wZGZhO1xcbiAgICBnbG9iYWxUaGlzLnBkID0gX3BkO1xcbiAgICBnbG9iYWxUaGlzLnBkZmggPSBfcGRmaDtcXG4gICAgU3RyaW5nLnByb3RvdHlwZS5yZXBsYWNlQWxsID0gZnVuY3Rpb24gKHNlYXJjaCwgcmVwbGFjZW1lbnQpIHtcXG4gICAgICAgIHJldHVybiB0aGlzLnNwbGl0KHNlYXJjaCkuam9pbihyZXBsYWNlbWVudCk7XFxuICAgIH07XFxuICAgIGxldCAkdG9TdHJpbmcgPSBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmc7XFxuICAgIEZ1bmN0aW9uLnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uICgpIHtcXG4gICAgICAgIHJldHVybiAkdG9TdHJpbmcuYXBwbHkodGhpcykudHJpbSgpO1xcbiAgICB9O1xcbiAgICBpZiAoaXNDbG9zZUxvZykge1xcbiAgICAgICAgLy8g6YeN5YaZY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgIGNvbnNvbGUubG9nID0gZnVuY3Rpb24gKCkge1xcbiAgICAgICAgICAgIC8vIOajgOafpeS8oOWFpeWPguaVsOeahOaVsOmHj1xcbiAgICAgICAgICAgIGlmIChhcmd1bWVudHMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICAgICAvLyDlpoLmnpzlj4LmlbDmlbDph4/lpKfkuo4x77yM6LCD55So5Y6f5aeL55qEY29uc29sZS5sb2flh73mlbBcXG4gICAgICAgICAgICAgICAgLy9vcmlnaW5hbExvZy5hcHBseShjb25zb2xlLCBhcmd1bWVudHMpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgLy8g5aaC5p6c5Y+C5pWw5Y+q5pyJ5LiA5Liq77yM5YiZ5LiN5YGa5Lu75L2V5pON5L2cXFxuICAgICAgICB9O1xcbiAgICB9XFxufVxcbmluaXRIaWtlcigpO1xcbmNvbnN0IGRycHlQYXRoID0gZ2V0UGF0aChcXFwiaGlrZXI6Ly9maWxlcy9kYXRhL1xcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIi9saWJzX2hpa2VyL2RycHkyLmpzXFxcIik7XFxuXFxuaWYgKCFmaWxlRXhpc3QoZHJweVBhdGgpKSB7XFxuICAgIHRocm93IG5ldyBFcnJvcihcXFwi57y65bCRZHJweS5qc+i/kOihjOW6k1xcXCIpO1xcbn1cXG5sZXQgZHJweSA9ICQucmVxdWlyZShkcnB5UGF0aCk7XFxuLypcXG5sZXQgY3VycmVudFBhdGggPSBcXFwiXFxcIjtcXG5sZXQgJGluaXQgPSBkcnB5LmluaXQ7XFxuZHJweS5pbml0ID0gZnVuY3Rpb24oZXh0KSB7XFxuICAgIGlmIChleHQgPT09IGN1cnJlbnRQYXRoKSByZXR1cm47XFxuICAgICRpbml0LmNhbGwodGhpcywgZXh0KTtcXG4gICAgY3VycmVudFBhdGggPSBleHQ7XFxufSovXFxuJC5leHBvcnRzID0gZHJweTtcI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cInRleHRfM1xcXCI7XFxuICAgICAgfSBlbHNlIGlmICh0YyA+PSAxNSkge1xcbiAgICAgICAgY29sID0gXFxcInRleHRfMlxcXCI7XFxuICAgICAgICB0ZXh0YWxpZ24gPSBcXFwibGVmdFxcXCI7XFxuICAgICAgfVxcbiAgICAgIGxldCBwbGF5b2JqID0gdC5zcGxpdChcXFwiI1xcXCIpLm1hcCgoaikgPT4ge1xcbiAgICAgICAgbGV0IGsgPSBqLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICBsZXQgdWlkID0gKGtbMV18fGtbMF0pO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSh0LCB7XFxuICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICB9KSxcXG4gICAgICAgICAgdXJsOiAgdWlkKyBcXFwiI1xcXCIgKyBmcm9tW2ldICsgcGxheUxhenkucmVwbGFjZSgnXFxcImlkXFxcIicsICdcXFwiJyArdWlkICsgJ1xcXCInKSxcXG4gICAgICAgICAgY29sX3R5cGU6IGNvbCxcXG4gICAgICAgICAgaW1nOiBpbWcsXFxuICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgXFxcIlJlZmVyZXJcXFwiOiBkZWNvZGVVUklDb21wb25lbnQoa1sxXSksXFxuICAgICAgICAgICAgaWQ6IGtbMV0sXFxuICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9KSovXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiL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XlwLm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgIGxldCBvYmogPSBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLCB7XFxuICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyAocGFnZW51bSA9PSBpID8geC5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogeCksXFxuICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGkpID0+IHtcXG4gICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIikgPT0gaSkge1xcbiAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCAkLnRlbXBfbGlzdFtpXSk7XFxuICAgICAgICAgICAgIGZpbmRJdGVtc0J5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpLmZvckVhY2goKHgsIGlpKSA9PiB7XFxuICAgICAgICAgICAgICAgbGV0IHRpdGxlID0geC50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgaWYgKGlpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlID0gJ+KAnOKAnOKAneKAnScgKyB0aXRsZS5mb250Y29sb3IoXFxcInJlZFxcXCIpO1xcbiAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAg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XJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9kb21haW5fY29uZmlnXFxcIixcXG4gICAgZXh0cmE6IHtcXG4gICAgICAgIHBhZ2VUaXRsZTogXFxcIuaWsOWinuino+aekFxcXCJcXG4gICAgfVxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5YiG5LqrXFxcIixcXG4gICAgdXJsOiAkKFxcXCItMVxcXCIsIFxcXCLovpPlhaXkvaDopoHliIbkuqvop6PmnpDnmoTluo/lj7dcXFxcbi0x5YWo6YOo77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahFxcXCIpLmlucHV0KChsZW5ndGgpID0+IHtcXG4gICAgICAgIGxldCBpbmRleGMgPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgIGxldCBpbmRleHMgPSBbXTtcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxuICAgICAgICBpZiAoIShpbmRleGMubGVuZ3RoICE9PSAwICYmIG1vIDwgMCAmJiBtbyA+IC01KSkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG51bSkgfHwgbnVtID49IGxlbmd0aCB8fCBudW0gPCAwKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiAkKFtcXFwiSElLRVJcXFwiLCBcXFwiVFhUXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSwgMiwgXFxcIuWIhuS6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5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yfXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZSh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BpZiAoaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAgICAgIGpzXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4LCBpc0ltcG9ydCkgPT4ge1xcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKS50cmltKCk7XFxuICAgICAgICBpZiAoIW5hbWUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZCN5a2X5b6X5pyJ5LiA5Liq5ZCnXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCB1cmwgPSBnZXRNeVZhcihcXFwicHNfdXJsXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghdXJsKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZmxhZyA9IGdldE15VmFyKFxcXCJwc19mbGFnXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFmbGFnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOagh+ivhuS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IGdldE15VmFyKFxcXCJwc19oZWFkZXJzXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIGlmKHR5cGVvZiBoZWFkZXJzIT09XFxcIm9iamVjdFxcXCIpIHRocm93IG5ldyBFcnJvcihcXFwi6ZSZ6K+v57G75Z6L77yM5b+F6aG75Li6T2JqZWN0XFxcIik7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICBsZXQganNvblBhdGggPSBnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiICYmICFqc29uUGF0aCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU09O5qih5byP5LiL5b+F6aG75aGranNvblBhdGhcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09PSBcXFwiSlNcXFwiICYmICFqcykge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgb2JqMSA9IHtcXG4gICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAganNcXG4gICAgICAgIH07XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBvYmoxLmdyb3VwO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgbmFtZXkgPSBhcnJbaW5kZXhdLm5hbWU7XFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xcbiAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIG9iajEpO1xcbiAgICAgICAgfVxcbiAgICAgICAgJC5yZXF1aXJlKFxcX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XFwiKTtcXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgbmV3SSA9IDA7XFxuICAgICAgICBmb3IgKGxldCBydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydWxlcy5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5paw5aKe77yaXFxcIiArIG5ld0kgKyBcXFwiIOimhuebluabtOaWsO+8mlxcXCIgKyAocnVsZXMubGVuZ3RoIC0gbmV3SSkpO1xcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIHRvYXN0KFxcXCLlr7zlhaXlpLHotKVcXFwiKTtcXG4gICAgfVxcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuinhumikeino+aekFwiLFwicGF0aFwiOlwidmlkZW9VcmxcIixcInJ1bGVcIjpcImZ1bmN0aW9uIGlzb2ZmaWNpYWwodXJsKSB7XFxuICBsZXQgZmxhZyA9IG5ldyBSZW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wgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpO1xcbiAgICBcXG4gICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKGpzb25UZXh0KTtcXG4gICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuICAgIGxldCBjb3VudCA9IDA7XFxuICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IG5hbWUgPSBpdC5uYW1lO1xcbiAgICAgICAgICAgIGxldCBzcGF0aCA9IGl0LnBhdGg7XFxuICAgICAgICAgICAgaWYgKCFuYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkgY29udGludWU7XFxuICAgICAgICAgICAgbmFtZSA9IG5hbWUuc2xpY2UoMCwgbmFtZS5sYXN0SW5kZXhPZihcXFwiLlxcXCIpKTtcXG4gICAgICAgICAgICBsZXQgcnVsZSA9IGZldGNoKGBodHRwczovL3Jhdy5naXRtaXJyb3IuY29tLyR7cm9wZX0vbWFzdGVyLyR7c3BhdGh9YCk7XFxuICAgICAgICAgICAgaWYgKCEoKCFydWxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXCJydWxlXFxcIikpICYmICFmaWxlRXhpc3QocGF0aCArIGl0Lm5hbWUpKSkge1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIGl0Lm5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgICAgICAgICAgICAgICAgICAgJ2FwaSc6Jy4uL2xpYnMvZHJweTIuanMnL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29tcG9uZW50KGl0LmV4dC5zcGxpdChcXFwiL1xcXCIpLmF0KC0xKSkgOiAoaXQubmFtZSArIFxcXCIuanNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGU7XFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaXQuZXh0KS5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGl0LmV4dCk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChqb2luVXJsKHVybCwgaXQuZXh0KSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcIi4vXFxcIiArIG5hbWU7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVFeGlzdChwYXRoICsgbmFtZSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXCJpbmRleC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoanNvbikpO1xcbiAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oiQ5Yqf5pu05pawXFxcIiArIG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ZXIoanNvbi5zaXRlcyk7XFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFwiaW5kZXhcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgZmlsZSA9IHZvaWQgMDtcXG4gICAgICAgIGxldCBjdXJyZW50U291cmNlLCBzZWFyY2hBbGxvdztcXG4gICAgICAgIGlmIChjb25maWcuY0tleSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgIC8vY29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBKU09OLnBhcnNlKGZldGNoKHNlYXJjaEFsbG93UGF0aCkgfHwgXFxcIltdXFxcIik7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgZGVsZXRlRmlsZShzZWFyY2hBbGxvd1BhdGgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gW107XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UsXFxuICAgICAgICAgICAgc2VhcmNoQWxsb3csXFxuICAgICAgICAgICAgc291cmNlTGlzdFxcbiAgICAgICAgfTtcXG4gICAgfSBjYXRjaCAo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cbiAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7fVxcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge31cXG5cXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICB9XFxuICAgICAgfTtcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgaSA9IGkgKyAxO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgZnVuYzogdGFzayxcXG4gICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgIH0sXFxuICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICBmdW5jOiBmdW5jdGlvbihvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1bHRzOiByZXN1bHRzXFxuICAgICAgICB9XFxuICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgIGxldCBpdGVtID0gZmluZEl0ZW0oXFxcInBhdGhcXFwiICsgeC5pbmRleCk7XFxuICAgICAgICBsZXQgcmVnZXggPSAvKOWQjeensDouKj8pKFxcXFxzKyk/XFxcXG4vZztcXG4gICAgICAgIGxld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Gl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtl1xcXCIsXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCkubWFwKHggPT4geC5uYW1lKTtcXG4gICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gbGlzdC5maWx0ZXIoeCA9PiB4LmluY2x1ZGVzKHRleHQpKTtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZmxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgIH0sXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIGxldCBuYXR1cmFsID0gZ2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAobmF0dXJhbCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIGxpc3Quc29ydChuYXR1cmFsU29ydCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgbmF0dXJhbCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgbmFtZXMucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBmdW5jdGlvbiBhcnJheURpZmZlcmVuY2UoYXJyMSwgYXJyMikge1xcbiAgICAgICAgICAgICAgY29uc3QgbWFwID0gbmV3IE1hcChhcnIyLm1hcChpdGVtID0+IFtpdGVtLmtleSwgaXRlbV0pKTtcXG4gICAgICAgICAgICAgIHJldHVybiBhcnIxLmZpbHRlcihpdGVtID0+ICFtYXAuaGFzKGl0ZW0ua2V5KSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIiwgXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgICAgbGV0IENrZXkgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKS5rZXk7XFxuICAgICAgICAgICAgLy9sb2coQ2tleSlcXG4gICAgICAgICAgICBsZXQgY2ZnID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50Q29uZmlnKClcXG4gICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgIG5hbWVcXG4gICAgICAgICAgICB9ID0gY2ZnO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxuICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRTb3VyY2UoQ2tleSk7XFxuICAgICAgICAgICAgbGV0IG5zb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG5cXG4gICAgICAgICAgICBsZXQgYWxpc3QgPSBhcnJheURpZmZlcmVuY2UobnNvdXJjZXMsIGxpc3QpO1xcbiAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxuXFxuICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDAgfHwgZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgYWxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGxvZyhcXFwi5paw5aKeOlxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgbXNnICs9IFxcXCLmlrDlop5cXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICBkbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnNwbGljZShtYW5hZ2UubGlzdC5pbmRleE9mKHgubmFtZSksIDEpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBsb2coXFxcIuenu+mZpDpcXFwiICsgZGxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFwiIOenu+mZpFxcXCIgKyBkbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXCIg5pu05aSa6K+m5oOF55yLbG9nXFxcIik7XFxuICAgICAgIC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IFxcXCLor7fpgInmi6lcXFwiLFxcbiAgICAgICAgY2xpY2socywgaSkge1xcbiAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcbiAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogMztcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAxKSB7XFxuICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi562b6YCJ5rqQXFxcIixcXG4gICAgICAgICAgICAgIGhpbnQ6IFxcXCLmupDlhbPplK7lrZcg5aSa5Liq55SofOmalOW8gFxcXCIsXFxuICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcbiAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dC5zcGxpdCgvXFxcXHwvKS5maWx0ZXIoZiA9PiBmKS5zb21lKHggPT4gdi5uYW1lLmluY2x1ZGVzKHgpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAodi5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpIDogdi5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG5cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgfSxcXG5cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG5cXG5cXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiBTdHJpbmcoYS5uYW1lKS5sb2NhbGVDb21wYXJlKFN0cmluZyhiLm5hbWUpLCB1bmRlZmluZWQsIHtcXG4gICAgICAgICAgICAgICAgbnVtZXJpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgc2Vuc2l0aXZpdHk6ICdiYXNlJ1xcbiAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gMykge1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLnJldmVyc2UoKTtcXG5cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA0KSB7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKCFzZWFyY2hBbGxvdy5pbmNsdWRlcyh2KSkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2VhcmNoQWxsb3cuc2xpY2UoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICA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Cc4oCd4oCdJyArIHQsXFxuICAgICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKG8pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBvLmk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJpc19kZWZcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV9vYmogPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwiY2F0ZV9vYmpcXFwiLCB7fSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX3RlbXAgPSBvLmNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcbiAgICAgICAgICAgICAgICAgIGNhdGVfdGVtcCA9IFtdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxuICAgICAgICAgICAgICAgIGxldCBjID0gY2F0ZV90ZW1wW2luZGV4XSB8fCBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcbiAgICAgICAgICAgICAgICBpZiAoYyA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBpICsgXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY2F0ZV9vYmpbby5jYXRlXSA9IGNhdGVfdGVtcDtcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcbiAgICAgICAgICAgICAgICAvL3N0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX3RlbXB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RGaWxlcygpO1xcbiAgICAgICAgICAgIGZvciAodmFyIGYgb2YgZmxpc3QpIHtcXG4gICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcbiAgICAgICAgICAgICAgaWYgKGYuaXNGaWxlKCkgJiYgZi5nZXROYW1lKCkudG9Mb3dlckNhc2UoKS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIHtcXG4gICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChqc0ZpbGVzLmxlbmd0aCA+PSA1KSB7XFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcbiAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgdGltZW91dDogNTAwMCxcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIGxldCBlID0gRGF0ZS5ub3coKTtcXG4gICAgICAgIGxldCBjID0gZSAtIHM7XFxuICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICB2YXIgaHRtbCA9IGouYm9keTtcXG4gICAgICAgICAgICB2YXIganNvbiA9IEpTT04ucGFyc2UocGRmaChodG1sLCBcXFwiI3JlcG8tY29udGVudC1wamF4LWNvbnRhaW5lciYmc2NyaXB0JiZIdG1sXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0ganNvbi5wYXlsb2FkLnRyZWUuaXRlbXM7XFxuICAgICAgICAgICAgY291bnQgPSBsaXN0LmZpbHRlcih4ID0+IHgubmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpLmxlbmd0aDtcXG4gICAgICAgICAgfSBjYXRjaCB7fVxcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge31cXG5cXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICB9XFxuICAgICAgfTtcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgaSA9IGkgKyAxO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgZnVuYzogdGFzayxcXG4gICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgIH0sXFxuICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICBmdW5jOiBmdW5jdGlvbihvYmosIGlkLCBlcnJvciwgdGFza1Jlc3VsdCkge1xcbiAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcbiAgICAgICAgICBpZiAoY291bnQgPiAwKSB7XFxuICAgICAgICAgICAgc2hvd0xvYWRpbmcoXFxcIuajgOa1i+S4rS4uLuWJqeS9meWcsOWdgO+8mlxcXCIgKyBjb3VudClcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICByZXN1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HtcXG4gICAgICAgIGNsZWFySXRlbShcXFwibm9fbG9hZGluZ1xcXCIpO1xcbiAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgIGxldCB7XFxuICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgIG5hbWVcXG4gICAgICAgIH0gPSBpdGVtO1xcbiAgICAgICAgaWYgKHBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmraPlnKjliqDovb3phY3nva4uLi5cXFwiKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICBuYW1lLFxcbiAgICAgICAgfSkpIHtcXG4gICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuY2xlYXIoKTtcXG4gICAgICAgICAgJC5yZXF1aXJlKFxcXCJDaGFuZ2VTb3VyY2VQb3BcXFwiKS5zaG93KDEwMCk7XFxuICAgICAgICAgIGhpZGVMb2FkaW5nKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5YiH5o2i5aSx6LSlXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICB9LCBpdGVtKSxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGlkOiAncGF0aCcg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AgICAgICAgICAgIG9iai5oZWFkZXJzW2tleV0gPSBTdHJpbmcob2JqLmhlYWRlcnNba2V5XSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgbGV0IHIgPSBcXFxcXFxcIlxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFxcXFxcInBvc3RcXFxcXFxcIikge1xcXFxuICAgICAgICAgICAgICAgICByID0gJHBvc3QodXJsLCBvYmopO1xcXFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxcXG4gICAgICAgICAgICAgfSovXFxcXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcXFxuICAgICAgICAgICAgaWYgKG9iai53aXRoSGVhZGVycykge1xcXFxuICAgICAgICAgICAgICAgIHIgPSBKU09OLnBhcnNlKHIpO1xcXFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcXFxuICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzID0ge307XFxcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgW2ssIHZdIG9mIE9iamVjdC5lbnRyaWVzKHIuaGVhZGVycyB8fCB7fSkpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXFxcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXM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cXFxcXFxcImNvcHk6Ly9cXFxcXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCBydWxlYjY0LCBcXFxcXFxcImFcXFxcXFxcIik7XFxcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiY29weTovL1xcXFxcXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXFxcXFwiYlxcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXFxcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXFxcXFwi56e75YqoXFxcXFxcXCIpIHtcXFxcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXFxcXFwiXFxcXFxcXCIsIFxcXFxcXFwi6L6T5YWl5L2N572uXFxcXFxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcXFxcXCJjb25maWdzXFxcXFxcXCIpLmdldEpzb24oKTtcXFxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUg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lkIDA7XFxcXG4gICAgICAgICAgICBpZiAoaGVhZGVycykge1xcXFxuICAgICAgICAgICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMgPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcXFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFxcXFxcIiArIGUudG9TdHJpbmcoKTtcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXFxcXFwidmlkZW9VcmxcXFxcXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcXFxuICAgICAgICAgICAgICAgIG5hbWUsXFxcXG4gICAgICAgICAgICAgICAgdXJsLFxcXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aCxcXFxcbiAgICAgICAgICAgICAgICBqc1xcXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcXFxuICAgICAgICB9KTtcXFxcbiAgICB9KSxcXFxcbiAgICBjb2xfdHlwZTogXFxcXFxcXCJ0ZXh0XzNcXFxcXFxcIixcXFxcbn0pO1xcXFxuXFxcXG5kLnB1c2goe1xcXFxuICAgIHRpdGxlOiBcXFxcXFxcIuS/neWtmFxcXFxcXFwiLFxcXFxuICAgIHVybDogJChcXFxcXFxcIiNub0xvYWRpbmcjXFxcXFxcXCIpLmxhenlSdWxlKChpbmRleCwgaXNJbXBvcnQpID0+IHtcXFxcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFxcXFxcInB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ID0gJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5nZXRKc29uKCk7XFxcXG4gICAgICAgIGxldCBvYmoxID0ge1xcXFxuICAgICAgICAgICAgbmFtZSxcXFxcbiAgICAgICAgICAgIHVybCxcXFxcbiAgICAgICAgICAgIGZsYWcsXFxcXG4gICAgICAgICAgICBoZWFkZXJzLFxcXFxuICAgICAgICAgICAgcnVuVHlwZSxcXFxcbiAgICAgICAgICAgIG1ldGhvZCxcXFxcbiAgICAgICAgICAgIGpzb25QYXRoLFxcXFxuICAgICAgICAgICAganNcXFxcbiAgICAgICAgfTtcXFxcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXFxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcXFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcXFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xcXFxuICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgb2JqMSk7XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgJC5yZXF1aXJlKFxcXFxcXFwiY29uZmlnc1xcXFxcXFwiKS5zYXZlSnNvbihhcnIpO1xcXFxuICAgICAgICBiYWNrKHRydWUpO1xcXFxuICAgICAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+S/neWtmOaIkOWKn1xcXFxcXFwiO1xcXFxuICAgIH0sIGluZGV4LCBpc0ltcG9ydCksXFxcXG4gICAgY29sX3R5cGU6IFxcXFxcXFwidGV4dF8zXFxcXFxcXCIsXFxcXG59KTtcXFxcblxcXFxuc2V0UmVzdWx0KGQpO1xcXCJ9LHtcXFwiY29sX3R5cGVcXFwiOlxcXCJtb3ZpZV8zXFxcIixcXFwibmFtZVxcXCI6XFxcIuino+aekOWvvOWFpVxc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AgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXFxcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxcXG4gICAgICAgICAgICAgICAgcnVsZSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcXFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFxcXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFxcXFxcIiArIGluZGV4ICsgXFxcXFxcXCImcnVsZT1cXFxcXFxcIiArIHJ1bGVUaXRsZTtcXFxcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFxcXFxcIuW3suabtOaWsOinhOWIme+8mlxcXFxcXFwiICsgcnVsZS5uYW1lKTtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFxcXFxcIiArIHJ1bGUubmFtZSlcXFxcbiAgICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgIG5ld0krKztcXFxcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXFxcbiAgICAgICAgICAgICAgICAgICAg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WxlIHx8ICFydWxlLmluY2x1ZGVzKFxcXFxcXFwicnVsZVxcXFxcXFwiKSkgJiYgIWZpbGVFeGlzdChwYXRoICsgaXQubmFtZSkpKSB7XFxcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXFxcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcXFxuICAgICAgICAgICAgICAgICAgICAnYXBpJzonLi4vbGlicy9kcnB5Mi5qcycsXFxcXG4gICAgICAgICAgICAgICAgICAgICdzZWFyY2hhYmxlJzogMSxcXFxcbiAgICAgICAgICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXFxcbiAgICAgICAgICAgICAgICAgICAgJ2ZpbHRlcmFibGUnOiAxLFxcXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogXFxcXFxcXCIuL1xcXFxcXFwiICsgaXQubmFtZSxcXFxcbiAgICAgICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXFxcbiAgICAgICAgfVxcXFxuICAgIH1cXFxcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXFxcXFwiaW5kZXguanNvblxcXFxcXFwiLCBKU09OLnN0cmluZ2lmeSh7c2l0ZXM6cnVsZXN9KSk7XFxcXG4gICAgcmV0dXJuIFxcXFxcXFwidG9hc3Q6Ly/miJDlip/mm7TmlrBcXFxcXFxcIiArIGNvdW50ICsgXFxcXFxcXCLkuKpcXFxcXFxcIjs7XFxcX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sgbmFtZTtcXFxcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcXFxcXCJydWxlXFxcXFxcXCIpKSB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcXFxuICAgICAgICAgICAgICAgIH07XFxcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXFxcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcXFxuICAgICAgICAgICAgfVxcXFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXFxcbiAgICAgICAgfVxcXFxuICAgICAgICBpKys7XFxcXG4gICAgfVxcXFxuICAgIHdyaXRlRmlsZShwYXRoICsgXFxcXFxcXCJpbmRleC5qc29uXFxcXFxcXCIsIEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXFxcbiAgICByZXR1cm4gXFxcXFxcXCJ0b2FzdDovL+aIkOWKn+abtOaWsFxcXFxcXFwiICsgY291bnQgKyBcXFxcXFxcIuS4qlxcXFxcXFwiO1xcXFxufVxcXFxuJC5leHBvcnRzLnBhcnNlVXJsID0gZnVuY3Rpb24odXJsLCBwYXRoKSB7XFxcXG4gICAgcGF0aCA9IGJhc2U2NERlY29kZShwYXRoKTtcXFxcbiAgICBwYXRoID0gcGF0aC5lbmRzV2l0aChcXFxcXFxcIi9cXFxcXFxcIikgPyBwYXRoIDogcGF0aCArIFxcXFxcXFwiL1xcXFxcXFwiO1xcXFxuICAgIHRyeSB7XFxcXG4gICAgICAgIGlmICh1cmwuc3RhcnRzV2l0aChcXFxcXFxcImh0dHBzOi8vZ2l0aHViLmNvbS9oamRobngvXFx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cXFxcXCI7XFxcXG4gICAgICAgIH1cXFxcbiAgICAgICAgZmlsZSA9IHZvaWQgMDtcXFxcbiAgICAgICAgbGV0IGN1cnJlbnRTb3VyY2UsIHNlYXJjaEFsbG93O1xcXFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXFxcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcXFxuICAgICAgICAgICAgaWYgKCFjdXJyZW50U291cmNlKSB7XFxcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXFxcbiAgICAgICAgICAgIH1cXFxcbiAgICAgICAgfSBlbHNlIHtcXFxcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcXFxuICAgICAgICAgICAgLy9jb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcXFxuICAgICAgICB9XFxcXG4gICAgICAgIHRyeSB7XFxcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IEpTT04ucGFyc2UoZmV0Y2goc2VhcmNoQWxsb3dQYXRoKSB8fCBcXFxcXFxcIltdXFxcXFxcXCIpO1xcXFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxcXG4gICAgICAgICAgICBkZWxldGVGaWxlKHNlYXJjaEFsbG93UGF0aCk7XFxcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IFtdO1xcXFxuICAgICAgICB9XFxcXG4gICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlLFxcXFxuICAgICAgICAgICAgc2VhcmNoQWxsb3csXFxcXG4gICAgICAgICAgICBzb3VyY2VMaXN0XFxcXG4gICAgICA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XFxcXG4gICAgICAgICAgICB9XFxcXG4gICAgICAgICAgfVxcXFxuICAgICAgICAgIGlmIChkaXIuaXNGaWxlKCkgJiYgZmlsZUV4aXN0KG9iai51cmwpKSB7XFxcXG4gICAgICAgICAgICB0cnkge1xcXFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxcXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxcXG4gICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxcXG4gICAgICAgICAgICAgIH1cXFxcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxcXG4gICAgICAgICAgICBjb2RlID0gXFxcXFxcXCJva1xcXFxcXFwiO1xcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcXFxuICAgICAgICAgICAgY291bnQgPSBqc0ZpbGVzLmxlbmd0aDtcXFxcbiAgICAgICAgICAgIGNvZGUgPSBcXFxcXFxcIm9rXFxcXFxcXCI7XFxcXG4gICAgICAgICAgfVxcXFxuICAgICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcXFxuICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcXFxuICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcXFxuICAgICAgICAgICAgY29kZTogY29kZSxcXFxcbiAgICAgICAgICAgIGluZGV4OiBvYmouaVxcXFxuICAgICAgICAgIH1cXFxcbiAgICAgICAgfVxcXFxuICAgICAgICB2YXIgaiA9IEpTT04ucGFyc2UoZmV0Y2gob2JqLnVybCwge1xcXFxuICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcXFxuICAgICAgICAgIHRpbWVv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iBjLFxcXFxuICAgICAgICAgIHVybDogai51cmwsXFxcXG4gICAgICAgICAgY291bnQ6IGNvdW50LFxcXFxuICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxcXG4gICAgICAgIH1cXFxcbiAgICAgIH07XFxcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcXFxuICAgICAgICBpID0gaSArIDE7XFxcXG4gICAgICAgIHJldHVybiB7XFxcXG4gICAgICAgICAgZnVuYzogdGFzayxcXFxcbiAgICAgICAgICBwYXJhbToge1xcXFxuICAgICAgICAgICAgdXJsOiB4LFxcXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxcXG4gICAgICAgICAgfSxcXFxcbiAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxcXG4gICAgICAgIH1cXFxcbiAgICAgIH0pO1xcXFxuICAgICAgdmFyIGNvdW50ID0gc3VjY2VzcyA9IHRhc2tzLmxlbmd0aDtcXFxcbiAgICAgIGJlKHRhc2tzLCB7XFxcXG4gICAgICAgIGZ1bmM6IGZ1bmN0aW9uKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxcXG4gICAgICAgICAgb2JqLnJlc3VsdHMucHVzaCh0YXNrUmVzdWx0KVxcXFxuICAgICAgICAgIGNvdW50ID0gY291bnQgLSAxO1xcXFxuICAgICAgICAgIGlmIChjb3VudCA+IDApIHtcXFxcbiAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXFxcXFwi5qOA5rWL5LitLi4u5Ymp5L2Z5Zyw5Z2A77yaXFxcXFxcXCIgKyBjb3VudClcXFxcbiAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXFxcbiAgICAgICAgICB9XFxcXG4gICAgICAgIH0sXFxcXG4gICAgICAgIHBhcmFtOiB7XFxcXG4gICAgICAgICAgaGk6ICd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ZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxcXG4gICAgICAgICAgICAgIG1heFRleHRhcmVhOiB0cnVlLFxcXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcXFxuICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXFxcbiAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFxcXFxcInJ1bnRpbWVDb25maWdcXFxcXFxcIiwgXFxcXFxcXCJydW50aW1lQ29uZmlnXFxcXFxcXCIpO1xcXFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpLm1hcCh4ID0+IHgubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGZsaXN0ID0gbGlzdC5maWx0ZXIoeCA9PiB4LmluY2x1ZGVzKHRleHQpKTtcXFxcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcXFxuICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcXFxuICAgICAgICAgICAgICAgIH0pO1xcXFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXFxcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFxcXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcXFxcXCIgKyB0ZXh0O1xcXFxuICAgICAgICAgICAgICB9LFxcXFxuXFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICB9IGVsc2Ug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IGVsc2Uge1xcXFxuICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXFxcbiAgICAgICAgICAgICAgY29uc3QgbWFwID0gbmV3IE1hcChhcnIyLm1hcChpdGVtID0+IFtpdGVtLmtleSwgaXRlbV0pKTtcXFxcbiAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXFxcbiAgICAgICAgICAgIH1cXFxcblxcXFxuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcXFxcXCJydW50aW1lQ29uZmlnXFxcXFxcXCIsIFxcXFxcXFwicnVudGltZUNvbmZpZ1xcXFxcXFwiKTtcXFxcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXFxcbiAgICAgICAgICAgIGxldCBDa2V5ID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCkua2V5O1xcXFxuICAgICAgICAgICAgLy9sb2coQ2tleSlcXFxcbiAgICAgICAgICAgIGxldCBjZmcgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKVxcXFxuICAgICAgICAgICAgbGV0IHtcXFxcbiAgICAgICAgICAgICAgcGF0aCxcXFxcbiAgICAgICAgICAgICAgbmFtZVxcXFxuICAgICAgICAgICAgfSA9IGNmZztcXFxcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxcXG4gICAgICAgICAgICAgIHBhdGgsXFxcXG4gICAgICAgICAgICAgIG5hbWUsXFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTtcXFxcbiAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxcXG5cXFxcbiAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxcXG4gICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcXFxuXFxcXG4gICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxcXG4gICAgICAgICAgICAgIGxldCBtc2cgPSBcXFxcXFxcIlxcXFxcXFwiO1xcXFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcXFxuICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxcXG4gICAgICAgICAgICAgICAgfSlcXFxcbiAgICAgICAgICAgICAgICBsb2coXFxcXFxcXCLmlrDlop46XFxcXFxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcXFxcXCIsXFxcXFxcXCIpKVxcXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFxcXFxcIuaWsOWinlxcXFxcXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcXFxcXCLkuKrmupBcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcXFxuICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXFxcbiAgICAgICAgICAgICAgICB9KVxcXFxuICAgICAgICAgICAgICAgIGxvZyhcXFxcXFxcIuenu+mZpDpcXFxc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cXFxcbiAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxcXG4gICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXFxcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxcXG4gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcXFxuICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcXFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXFxcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXFxcbiAgICAgICAgICAgICAgICAgIGNhblNlYXJjaFNvdXJjZS5mb3JFYWNoKCh2LCBpKSA9PiB7XFxcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcXFxcXHwvKS5maWx0ZXIoZiA9PiBmKS5zb21lKHggPT4gdi5uYW1lLmluY2x1ZGVzKHgpKSkge1xcXFxuICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXFxcbiAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXFxcXFwi4oCc4oCc4oCd4oCdXFxcXFxcXCIgKyAodi5uYW1lICsgXFxcXFxcXCJcXFxcXFxcIikuZm9udGNvbG9yKFxcXFxcXFwiIzAwOTk2NlxcXFxcXFwiKSA6IHYubmFtZSlcXFxcbiAgICAgICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgICAgfSk7XFxcXG4gICAgICAgICAg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ICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXFxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcXFxuXFxcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXFxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXFxcbiAgICAgICAgICAgICAgaWYgKCFzZWFyY2hBbGxvdy5pbmNsdWRlcyh2KSkge1xcXFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcXFxuICAgICAgICAgICAgICB9XFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcXFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcXFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcXFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA1KSB7XFxcXG4gICAgICAgICAgICBsZXQgdGVtbGlzdCA9IHNlYXJjaEFsbG93LnNsaWNlKCk7XFxcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcXFxuICAgICAgICAgICAgICBpZiAodGVtbGlzdC5pbmNsdWRlcyh2LmtleSkpIHJldHVybjtcXFxcbiAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxcXG4gICAgICAgICAgICB9KTtcXFxcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcXFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hB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ZTAuZ2V0TXlWYXIoXFxcXFxcXCJjYXRlX29ialxcXFxcXFwiLCB7fSk7XFxcXG5cXFxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxcXG4gICAgICAgICAgICAgICAgaWYgKGNhdGVfdGVtcC5jb25zdHJ1Y3RvciAhPSBBcnJheSkge1xcXFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IG8uaW5kZXg7XFxcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXFxcXFwiLTFcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICAvL2xvZyhjKVxcXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXFxcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXFxcXFwiLTFcXFxcXFxcIjtcXFxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcXFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXFxcXFwiXFxcXFxcXCI7XFxcXG4gICAgICAgICAgICAgICAgfVxcXFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxcXG4gICAgICAgICAgICAgICAgLy9sb2coY2F0ZV90ZW1wKVxcXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcXFxcXCJjYXRlX3RlbXBcXFxcXFxcIiwgY2F0ZV90ZW1wKTtcXFxcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFxcXFxcImNhdGVfb2JqXFxcXFxcXCIsIGNhdGVfb2JqKTtcXFxcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcXFxu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XFxcXG4gICAgdXJsOiBcXFxcXFxcImhpa2VyOi8vcGFnZS9Mb2NhbERpciNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFxcXFxcIixcXFxcbiAgICBleHRyYToge1xcXFxuICAgICAgICBjcGF0aDogTVlfUEFSQU1TLmNwYXRoLFxcXFxuICAgICAgICBuZXdXaW5kb3c6IHRydWUsXFxcXG4gICAgICAgIHdpbmRvd0lkOiBNWV9SVUxFLnRpdGxlICsgXFxcXFxcXCJAZWRpdGZpbGVcXFxcXFxcIixcXFxcbiAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcXFxuICAgICAgICBwYWdlVGl0bGU6IFxcXFxcXFwi5paH5Lu2566h55CGXFxcXFxcXCJcXFxcbiAgICB9XFxcXG59XSk7XFxcIn1dXCIsXCJwcm94eVwiOlwiXCJ9IiwidGl0bGUiOiLliJvlu7rphY3nva4ifQ==
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement