xiaomianao666

小程序:DrpyHiker

Jul 24th, 2024
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjo0MiwiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1pYW5Mb2FkXCIpOyIsInNlYXJjaF91cmwiOiJoaWtlcjovL2VtcHR5P3M9KiomcGFnZT1meXBhZ2UiLCJncm91cCI6IuKRouiBmuWQiOaQnOe0oiIsInNlYXJjaEZpbmQiOiJqczpcbihmdW5jdGlvbiAoKSB7XG4gIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgbGV0IHRlbXNtb2RlID0gZ2V0TXlWYXIoXCJ0ZW1zbW9kZVwiLCBcIlwiKTtcbiAgaWYgKHRlbXNtb2RlKSB7XG4gICAgc21vZGUgPSBOdW1iZXIodGVtc21vZGUpO1xuICAgIGNsZWFyTXlWYXIoXCJ0ZW1zbW9kZVwiKTtcbiAgfVxuICBpZiAoIWZpbGVFeGlzdChcImhpa2VyOi8vZmlsZXMvZGF0YS9cIiArIE1ZX1JVTEUudGl0bGUgKyBcIi9saWJzX2hpa2VyL2RycHkyLmpzXCIpKSByZXR1cm4gc2V0UmVzdWx0KFt7X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B1c2goe1xuICAgICAgICB0aXRsZTogaXQudm9kX25hbWUsXG4gICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzICsgXCLCt1wiICsgc291cmNlLm5hbWUsXG4gICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1wiLFxuICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgdm9kSWQ6IFN0cmluZyhpdC52b2RfaWQpLFxuICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXG4gICAgICAgICAgc2tleTogc291cmNlLmtleSxcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuICAgIHNldFJlc3VsdChkKTtcbiAgfSBlbHNlIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgIHVybDogXCJoaWtlcjovL3NlYXJjaD9zPVwiICsgTVlfS0VZV09SRCxcbiAgICAgIGV4dHJhOiB7XG4gICAgICAgIGRlbGVnYXRlT25seVNlYXJjaDogdHJ1ZSxcbiAgICAgICAgcnVsZXM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcInJ1bnRpbWVDb25maWdcIiwgXCJydW50aW1lQ29uZmlnXCIpO1xuICAgICAgICAgICAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXCJzbW9kZVwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbG93U2VhcmNoU291cmNlKHNtb2RlPT09Mik7XG5cbiAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcblxuICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcblxuICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgIGxpc3Quc3BsaWNlKGxpc3QuaW5kZXhPZihzb3VyY2UpLCAxKTtcbiAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgc2VhcmNoc29ydCA9IE51bWJlcihnZXRJdGVtKFwic2VhcmNoc29ydFwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IHtcbiAgICAgICAgICAgICAgbmF0dXJhbFNvcnQsXG4gICAgICAgICAgICAgIHVzaW5nU29ydFxuICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcIm1ldGhvZHNcIik7XG5cbiAgICAgICAgICAgIGlmIChzZWFyY2hzb3J0ID4gMCkge1xuICAgICAgICAgICAgICBpZiAoc2VhcmNoc29ydCA9PSAxKSB7XG4gICAgICAgICAgICAgICAgbmF0dXJhbFNvcnQobGlzdCwgXCJuYW1lXCIpO1xuICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNlYXJjaHNvcnQgPT0gMikge1xuICAgICAgICAgICAgICAgIHVzaW5nU29ydC5zZXRrZXkoXCJuYW1lXCIpO1xuICAgICAgICAgICAgICAgIHVzaW5nU29ydC5nZXQobGlzdClcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcbiAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgIGxldCBkcnB5ID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKS5nZXQoaXRlbS5rZXkpO1xuXG4gICAgICAgICAgICAgICAgICBsZXQgaG9tZUxpc3QgPSBKU09OLnBhcnNlKGRycHkuc2VhcmNoKE1ZX0tFWVdPUkQsIGZhbHNlLCBNWV9QQUdFKSkubGlzdCB8fCBbXTtcbiAgICAgICAgICAgICAgICAgIGxldCBkID0gW107XG4gICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBob21lTGlzdCkge1xuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC52b2RfbmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcbiAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBpdC52b2RfY29udGVudCxcbiAgICAgICAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1wiLFxuICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2b2RJZDogU3RyaW5nKGl0LnZvZF9pZCksXG4gICAgICAgICAgICAg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NrZXkpICsgXFxcIiZkbz1qc1xcXCI7XFxuICAgIH1cXG4gICAgZXZhbChnZXRDcnlwdG9KUygpKTtcXG4gICAgZ2xvYmFsVGhpcy5DcnlwdG9KUyA9IENyeXB0b0pTO1xcblxcbiAgICBsZXQgJHJlcXVlc3QgPSByZXF1ZXN0O1xcbiAgICBsZXQgJHBvc3QgPSBwb3N0O1xcbiAgICBnbG9iYWxUaGlzLnJlcSA9IGZ1bmN0aW9uICh1cmwsIGNvYmopIHtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IHJlcyA9IHt9O1xcbiAgICAgICAgICAgIGxldCBvYmogPSBPYmplY3QuYXNzaWduKHt9LCBjb2JqKTtcXG4gICAgICAgICAgICBpZiAob2JqLmRhdGEpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmJvZHkgPSBvYmouZGF0YTtcXG4gICAgICAgICAgICAgICAgZGVsZXRlIG9iai5kYXRhO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAob2JqLmhhc093blByb3BlcnR5KFxcXCJyZWRpcmVjdFxcXCIpKSBvYmoucmVkaXJlY3QgPSAhIW9iai5yZWRpcmVjdDtcXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICBvYmoudG9IZXggPSB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmouaGVhZGVycyA9IE9iamVjdC5hc3NpZ24oe1xcbiAgICAgICAgICAgICAgICBDb29raWU6IFxcXCIjbm9Db29raWUjXFxcIlxcbiAgICAgICAgICAgIH0sIG9iai5oZWFkZXJzKTtcXG4gICAgICAgICAgICBpZiAodXJsID09PSBcXFwiaHR0cHM6Ly9hcGkubm4uY2kvb2NyL2I2NC90ZXh0XFxcIiAmJiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1tcXFwiQ29udGVudC1UeXBlXFxcIl0gPSBcXFwidGV4dC9wbGFpblxcXCI7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGlmICh1cmwuc3RhcnRzV2l0aChcXFwiZmlsZTovL1xcXCIpICYmICh1cmwuaW5jbHVkZXMoXFxcIj90eXBlPVxcXCIpIHx8IHVybC5pbmNsdWRlcyhcXFwiP3BhcmFtcz1cXFwiKSkpIHtcXG4gICAgICAgICAgICAgICAgdXJsID0gdXJsLnNsaWNlKDAsIHVybC5sYXN0SW5kZXhPZihcXFwiP1xcXCIpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgZm9yIChsZXQga2V5IGluIG9iai5oZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygb2JqLmhlYWRlcnNba2V5XSAhPT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIG9iai5oZWFkZXJzW2tleV0gPSBTdHJpbmcob2JqLmhlYWRlcnNba2V5XSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHIgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAvKiBpZiAoU3RyaW5nKG9iai5tZXRob2QpLnRvTG93ZXJDYXNlKCkgPT09IFxcXCJwb3N0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgciA9ICRwb3N0KHVybCwgb2JqKTtcXG4gICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0qL1xcbiAgICAgICAgICAgIHIgPSAkcmVxdWVzdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgaWYgKG9iai53aXRoSGVhZGVycykge1xcbiAgICAgICAgICAgICAgICByID0gSlNPTi5wYXJzZShyKTtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByLmJvZHk7XFxuICAgICAgICAgICAgICAgIHJlcy5oZWFkZXJzID0ge307XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IFtrLCB2XSBvZiBPYmplY3QuZW50cmllcyhyLmhlYWRlcnMgfHwge30pKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXMuaGVhZGVyc1trXSA9IHZbMF07XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IHI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmouYnVmZmVyID09PSAyKSB7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gQ3J5cHRvVXRpbC5EYXRhLnBhcnNlSGV4KHJlcy5jb250ZW50KS50b0Jhc2U2NChfYmFzZTY0Lk5PX1dSQVApO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcmVzO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhcXFwiRXJyb3JcXFwiICsgZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICAvKlxcbiAgICBjb25zdCBKaW5KYSA9ICQucmVxdWlyZShcXFwiaHR0cHM6Ly9jZG4uYm9vdGNkbi5uZXQvYWpheC9saWJzL211c3RhY2hlLmpzLzQuMS4wL211c3RhY2hlLmpzXFxcIik7XFxuICBcXG4gICAgY29uc3QgSlAgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vanNvbnBhdGgtcGx1cy5naXRodWIuaW8vSlNPTlBhdGgvZGlzdC9pbmRleC1icm93c2VyLXVtZC5janNcXFwiKTtcXG4gICAgZ2xvYmFsVGhpcy5jaGVlcmlvID0ge1xcbiAgICAgICAgamluamEyKHRlbXBsYXRlLCBvYmopIHtcXG4gICAgICAgICAgICBcXG4gICAgICAgICAgICByZXR1cm4gJC5sb2coSmluSmEucmVuZGVyKHRlbXBsYXRlLCBvYmopKTtcXG4gICAgICAgIH0sXF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xuICAgICAgICBkZXNjID0gZGVzYy5jb25zdHJ1Y3RvciA9PSBBcnJheSA/IGRlc2Muam9pbignPGJyPicpIDogZGVzYztcXG4gICAgICAgIGlmIChkZXNjLnJlcGxhY2UoLyg8YnI+fFxcXFxzKykvZywgJycpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgY29sX3R5cGU6ICdiaWdfYmxhbmtfYmxvY2snXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ2JpZ19ibGFua19ibG9jaydcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgIH1cXG5cXG4gICAgICAgIGNvbnN0IG1hcmsgPSAnZGVzYyc7XFxuICAgICAgICBudW0gPSB0eXBlb2YobnVtKSA9PSAndW5kZWZpbmVkJyA/IDEwMCA6IG51bVxcbiAgICAgICAgZGVzYyA9IGRlc2Muc3RhcnRzV2l0aCgn44CA44CAJykgPyBkZXNjIDogJ+OAgOOAgCcgKyBkZXNjO1xcbiAgICAgICAgZGVzYyA9IGRlc2MucmVwbGFjZSgvJy9nLCBcXFwiJiMzOTtcXFwiKTtcXG4gICAgICAgIGRlc2MgPSBkZXNjLnJlcGxhY2UoL1xcXFxyXFxcXG4vZywgXFxcIjxicj5cXFwiKTtcXG4gICAgICAgIGRlc2MgPSBkZXNjLnJlcGxhY2UoL1xcXFxuL2csIFxcXCI8YnI+XFxcIik7XFxuICAgICAgICBsZXQgc2Rlc2MgPSBzdWJzdHIoZGVzYywgbnVtKTtcXG5cXG4gICAgICAgIHZhciBjb2xvcnMgPSB7XFxuICAgICAgICAgICAgc2hvdzogXFxcImJsYWNrXFxcIixcXG4gICAgICAgICAgICBoaWRlOiBcXFwiZ3JleVxcXCJcXG4gICAgICAgIH1cXG5cXG4gICAgICAgIHZhciBsYXp5ID0gJChgI25vTG9hZGluZyNgKS5sYXp5UnVsZSgoZGMsIHNkYywgbSwgY3MpID0+IHtcXG4gICAgICAgICAgICB2YXIgc2hvdyA9IHN0b3JhZ2UwLmdldEl0ZW0obSwgJzAnKTtcXG4gICAgICAgICAgICB2YXIgdGl0bGUgPSBmaW5kSXRlbSgnZGVzYycpLnRpdGxlO1xcbiAgICAgICAgICAgIHZhciByZSA9IC8oPFxcXFwvc21hbGw+PGJyPi4qPz4pLisvZztcXG4gICAgICAgICAgICB2YXIgZXhwID0gJ+WxleW8gDonO1xcbiAgICAgICAgICAgIHZhciByZXQgPSAn5pS26LW3Oic7XFxuICAgICAgICAgICAgaWYgKHNob3cgPT0gJzEnKSB7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oJ2Rlc2MnLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGVcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShyZXQsIGV4cClcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIHNkYyArICc8L3NtYWxsPicpXFxuICAgICAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoLyg8XFxcXC9zbWFsbD48YnI+XFxcXDxmb250IGNvbG9yPVxcXCIpLio/KFxcXCI+KS8sICckMScgKyBjcy5oaWRlICsgJyQyJylcXG5cXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShtLCAnMCcpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oJ2Rlc2MnLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGl0bGVcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShleHAsIHJldClcXG4gICAgICAgICAgICAgICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIGRjICsgJzwvc21hbGw+JylcXG4gICAgICAgICAg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LFxcbiAgICAgICAgICAgICAgICBsaW5lU3BhY2luZzogNixcXG4gICAgICAgICAgICAgICAgdGV4dFNpemU6IDE1LFxcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogdHJ1ZSxcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICB9XFxuXFxuICAgIGxldCBzb3J0b2JqID0gW3tcXG4gICAgICAgICAgICB0aXRsZTogZm9udHN0eWxlKFxcXCLihr9cXFwiLCB7XFxuICAgICAgICAgICAgICAgIGg6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICBjOiBcXFwiIzFBQUQxOVxcXCIsXFxuICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJiXFxcIlxcbiAgICAgICAgICAgIH0pICsgZm9udHN0eWxlKFxcXCLih4JcXFwiLCB7XFxuICAgICAgICAgICAgICAgIGg6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICB0YWdzOiBcXFwiYlxcXCJcXG4gICAgICAgICAgICB9KSArIFxcXCJcXFxcdFxcXCIsXFxuICAgICAgICAgICAgaW1nOiBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9tZXNzeS8xMjMuc3ZnXFxcIlxcbiAgICAgICAgfSxcXG4gICAgICAgIHtcXG4gICAgICAgICAgICB0aXRsZTogZm9udHN0eWxlKFxcXCLihr9cXFwiLCB7XFxuICAgICAgICAgICAgICAgIGg6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICB0YWdzOiBcXFwiYlxcXCJcXG4gICAgICAgICAgICB9KSArIGZvbnRzdHlsZShcXFwi4oeCXFxcIiwge1xcbiAgICAgICAgICAgICAgICBoOiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgYzogXFxcIiNGRjAwMDBcXFwiLFxcbiAgICAgICAgICAgICAgICB0YWdzOiBcXFwiYlxcXCJcXG4gICAgICAgICAgICB9KSArIFxcXCJcXFxcdFxcXCIsXFxuICAgICAgICAgICAgaW1nOiBcXFwiaHR0cHM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cihlID0+IGUgIT0gXFxcIlxcXCIpLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBwbGF5cGFnZXNbaV0gPSBwYWdlcztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHRjID4gMjQpIHtcXG4gICAgICAgICAgICAgICAgY29sID0gXFxcInRleHRfMVxcXCI7XFxuICAgICAgICAgICAgICAgIGltZyA9IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL21vdmllLzE0Ni5zdmdcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGMgPj0gMTIgJiYgdGMgPCAxNSkge1xcbiAgICAgICAgICAgICAgICBjb2wgPSBcXFwidGV4dF8zXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHRjID49IDE1KSB7XFxuICAgICAgICAgICAgICAgIGNvbCA9IFxcXCJ0ZXh0XzJcXFwiO1xcbiAgICAgICAgICAgICAgICB0ZXh0YWxpZ24gPSBcXFwibGVmdFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwbGF5b2JqID0gdC5zcGxpdChcXFwiI1xcXCIpLm1hcCgoaiwgaWkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGsgPSBqLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB0ID0ga1swXTtcXG4gICAgICAgICAgICAgICAgbGV0IHVpZCA9IChrWzFdIHx8IGtbMF0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgc3RpdGxlOiB0LFxcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSh0LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgICAgICBzdXJsOiB1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBpc05vdmVsID8gXFxcImhpa2VyOi8vcGFnZS9ub3ZlbCNhdXRvUGFnZSMjcmVhZFRoZW1lI1xcXCIgOiAodWlkICsgXFxcIiNcXFwiICsgZnJvbVtpXSArIHBsYXlMYXp5KSxcXG4gICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgICAgICAgICAgICBpbWc6IGltZyxcXG4gICAgICAgICAgICAgICAgICAgIC8qZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIGV4dHJhLCB7XFxuICAgICAgICAgICAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgICAgICAgICAgICBpZDoga1sxXSxcXG4gICAgICAgICAgICAgICAgICAgICAgLy9saW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgICAgICAgICAgICB9KSovXFxuICAgICAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaWR1XFxcXC5jb21cXFxcL2htLmpzXFxcIl0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgdmlkZW9FeGNsdWRlUnVsZXM6IFsnP3VybD0nXSxcXG4gICAgICAgICAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGlmIChzdHlwZSA9PSBcXFwi5ryr55S7XFxcIiB8fCBzdHlwZSA9PSBcXFwi5bCP6K+0XFxcIikge1xcblxcbiAgICAgICAgICAgICAgICB2YXIgZG93bmxvYWRsYXp5ID0gJC50b1N0cmluZygoa2V5LCBza2V5LCB0aXRsZSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGRycHk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoJC5oaWtlcltcXFwiX19kcnB5X19cXFwiXSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRycHkgPSAkLmhpa2VyW1xcXCJfX2RycHlfX1xcXCJdO1xcblxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBHTVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcImh0dHA6Ly9oaWtlci5ub2tpYS5wcmVzcy9oaWtlcnVsZS9ydWxlbGlzdC5qc29uP2lkPTY5MTYmYXV0aD0xZDM1ZThmMC0yMmU4LTUyNzAtYTlkMS04MjZmNTNmMTc3YWRcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBHTS5zZXRTZWxmS2V5KGtleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiLCBcXFwiRHJweU1hbmFnZT9ydWxlPVxcXCIgKyB0aXRsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZHJweSA9IERycHlNYW5hZ2UuZ2V0KHNrZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICQuaGlrZXJbXFxcIl9fZHJweV9fXFxcIl0gPSBkcnB5O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICQuaGlrZXJbXFxcIl9fdGVzdF9fXFxcIl0gPSBbXTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGlucHV0ID0gaW5wdXQuc3BsaXQoXFxcIiNcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCByZXN1bHQgPSBKU09OLnBhcnNlKGRycHkucGxheShpbnB1dFsxXSwgaW5wdXRbMF0pKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHQudXJsLnN0YXJ0c1dpdGgoXFxcInBpY3M6Ly9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQudXJsO1xcbiAgICAgICAgICAgICAgICAgICAgfWVsc2UgaWYgKHJlc3VsdC51cmwuc3RhcnRzV2l0aChcXFwibm92ZWw6Ly9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50PUpTT04ucGFyc2UocmVzdWx0LnVybC5yZXBsYWNlKFxcXCJub3ZlbDovL1xcXCIsIFxcXCJcXFwiKSkuY29udGVudDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgY21kNT1tZDUoY29udGVudCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGluZGV4PTA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYoKGluZGV4PSQuaGlrZXJbXFxcIl9fdGVzdF9fXFxcIl0uaW5kZXhPZihjbWQ1KSkhPT0tMSl7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi6YeN5aSN77yaXFxcIitpbnB1dCtcXFwiPT5cXFwiK2luZGV4KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgJC5oaWtlcltcXFwiX190ZXN0X19cXFwiXS5wdXNoKGNtZDUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb250ZW50O1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLmvKvnlLvmiJbmraPmlofojrflj5blpLHotKVcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSwgR00uZ2V0U2VsZktleSgpLCBNWV9QQVJBTVMuc2tleSwgTVlfUlVMRS50aXRsZSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBjaGFwdGVyTGlzdCA9IHBsYXlvYmouZXhjbHVkZUtleXMoW1xcXCJzdXJsXFxcIiwgXFxcInN0aXRsZVxcXCJdLCBmYWxzZSkudHJhbnNmb3JtS2V5cyh7XFxuICAgICAgICAgICAgICAgICAgICBcXFwic3VybFxcXCI6IFxcXCJ1cmxcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgXFxcInN0aXRsZVxcXCI6IFxcXCJ0aXRsZVxcXCJcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvZHJfZG93X2xpc3QuanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KGNoYXB0ZXJMaXN0KSk7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuS4i+i9vVxcXCIgKyBzdHlwZSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogJ2hpa2VyOi8vcGFnZS9kb3dubG9hZC52aWV3I25vUmVjb3JkSGlzdG9yeSMjbm9SZWZyZXNoIz9ydWxlPeacrOWcsOi1hOa6kOeuoeeQhicsXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjaGFwdGVyTGlzdDogXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL2RyX2Rvd19saXN0Lmpzb25cXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZm86IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9va05hbWU6IGluZm8udm9kX25hbWUsIC8v5ryr55S75ZCN56ewLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlTmFtZTogTVlfUlVMRS50aXRsZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9va1RvcFBpYzogaW5mby52b2RfcGljLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJzZUNvZGU6IGRvd25sb2FkbGF6eSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9va0lkOiBNWV9QQVJBTVMuc25hbWUsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHN0eXBlID09PSBcXFwi5ryr55S7XFxcIiA/IFxcXCJjb21pY1xcXCIgOiBcXFwibm92ZWxcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFZpZXc6IFxcXCIxXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pys5Zyw5Lmm5p62XFxcIixcXG4gICAgICAgICAgICAgICAgICAgIHVybDogJ2hpa2VyOi8vcGFnZS9Cb29rcmFjay52aWV3I25vUmVjb3JkSGlzdG9yeSM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYmcnVsZU5hbWU9JyArIE1ZX1JVTEUudGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBzdHlwZSA9PT0gXFxcIua8q+eUu1xcXCIgPyBcXFwiY29taWNcXFwiIDogXFxcIm5vdmVsXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6ICdibGFua19ibG9jaydcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHBsYXlvYmogPSAkLnNwbGl0QXJyYXlCeVJhbmdlcyhwbGF5b2JqLCBwYWdlcyk7XFxuICAgICAgICAgICAgcmV0dXJuIHBsYXlvYmo7XFxuICAgICAgICB9KTtcXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIlxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5pqC5peg5pKt5pS+5rqQ5oiW5pKt5pS+5YiX6KGo5a6a5L2N6ZSZ6K+vXFxcIixcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIHVybDogTVlfUEFSQU1TLnZvZElkLFxcbiAgICAgICAgfSk7XFxuICAgICAgICBjYWNoZVNob3dUaXBzKCk7XFxuICAgICAgICBzZXRSZXN1bHQoZCk7XFxuICAgIH1cXG5cXG5cXG4gICAgbGV0IGN1cnJlbnRMb2NhdGlvbiA9IDA7XFxuXFxuICAgIGlmIChmcm9tLmxlbmd0aCkge1xcbiAgICAgICAgZXJPcHRpb25zLnNldChcXFwiZnJvbVxcXCIsIGZyb20pO1xcbiAgICAgICAgZXJPcHRpb25zLnNldChcXFwidG90YWxcXFwiLCBwbGF5VXJsTGlzdC5tYXAoeCA9PiB4Lmxlbmd0aCkpO1xcbiAgICAgICAgZXJPcHRpb25zLnNldChcXFwicGxheXNcXFwiLCBwbGF5VXJsTGlzdC5tYXAoeCA9PiB4LmZsYXQoKS5sZW5ndGgpKTtcXG4gICAgfVxcblxcblxcbiAgICBmdW5jdGlvbiByZW5vdmF0ZUxpc3QobG9jYXRpb24pIHtcXG4gICAgICAgIC8vZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpO1xcbiAgICAgICAgLy9kZWxldGVJdGVtQnlDbHMoXFxcInBsYXlsaXN0XFxcIik7XFxuXFxuICAgICAgICBpZiAocGxheVVybExpc3QubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICByZXR1cm47XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGlzID0gaGlzdG9yeWxvZyhcXFwiZ2V0XFxcIiwgTVlfUEFSQU1TLnNrZXksIG1kNShNWV9QQVJBTVMudm9kSWQpKTtcXG5cXG5cXG4gICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCAoaGlzIHx8IFxcXCIwXFxcIikpO1xcblxcbiAgICAgICAgbGV0IHBjb3VudCA9IHBsYXlVcmxMaXN0W2xvY2F0aW9uXS5sZW5ndGg7XFxuICAgICAgICBsZXQgbGlzdCA9IHBsYXlVcmxMaXN0W2xvY2F0aW9uXVtwYWdlbnVtXTtcXG4gICAgICAgIGlmICghbGlzdCkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSBwYWdlbnVtOyBpID49IDA7IGktLSkge1xcbiAgICAgICAgICAgICAgICBsaXN0ID0gcGxheVVybExpc3RbbG9jYXRpb25dW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAobGlzdCkge1xcbiAgICAgICAgICAgICAgICAgICAgcGFnZW51bSA9IGk7XFxuICAgICAgICAgICAgICAgICAgICBicmVhaztcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChnZXRNeVZhcihcXFwic29ydGlcXFwiLCBcXFwiMFxcXCIpID09IDEpIHtcXG4gICAgICAgICAgICBsaXN0LnJldmVyc2UoKTtcXG4gICAgICAgIH1cXG4gICAgICAgICQuZXh0ZW5kKHtcXG4gICAgICAgICAgICB0ZW1wX2xpc3Q6IHBsYXlVcmxMaXN0W2xvY2F0aW9uXSxcXG4gICAgICAgIH0pXFxuICAgICAgICBsZXQgcGxheXAgPSBwbGF5cGFnZXNbbG9jYXRpb25dO1xcbiAgICAgICAgLy9kZWxldGVJdGVtQnlDbHMoXFxcInBsYXlwYWdlXFxcIilcXG4gICAgICAgIC8vcGxheXAgJiYgcGxheXAubGVuZ3RoID4gMVxcbiAgICAgICAgLy9lck9wdGlvbnMuZ2V0KFxcXCJ0b3RhbFxcXCIpLnNvbWUoeD0+eD4xKVxcbiAgICAgICAgbGV0IGJvb2wgPSAoIWVyLuWIhumhtemAu+i+kSB8fCBlci7liIbpobXpgLvovpEgPT0gXFxcIjBcXFwiID8gZXJPcHRpb25zLmdldChcXFwidG90YWxcXFwiKS5zb21lKHggPT4geCA+IDEpIDogcGxheXAgJiYgcGxheXAubGVuZ3RoID4gMSk7XFxuXFxuICAgICAgICBpZiAoYm9vbCkge1xcbiAgICAgICAgICAgIGlmIChwbGF5cCAmJiBwbGF5cC5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgICAgIGVyT3B0aW9ucy5zZXQoXFxcInBsYXlwXFxcIiwgcGxheXApO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBoaXN0b3J5bG9nKFxcXCJzZXRcXFwiLCBNWV9QQVJBTVMuc2tleSwgbWQ1KE1ZX1BBUkFNUy52b2RJZCksIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGluZm8udm9kX25hbWUsXFxuICAgICAgICAgICAgICAgIHBhZ2U6IHBhZ2VudW0sXFxuICAgICAgICAgICAgICAgIGRhdGU6IG5ldyBEYXRlKCkuZ2V0VGltZSgpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbGV0IHRlbXAgPSB7XFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF8xJyxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGxldCBmYyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgIGlmICghKHBsYXlwICYmIHBsYXlwLmxlbmd0aCA+IDEpKSB7XFxuICAgICAgICAgICAgICAgIGZjID0gXFxcImdyZXlcXFwiO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBsZXQgcGFnZW9iaiA9IFt7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUoJ+S4iuS4gOmhtScsIHtcXG4gICAgICAgICAgICAgICAgICAgIGM6IGZjXFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQsIHBjb3VudCwgcGFnZW51bSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZWYgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5nZXRFSW5mbygpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBjb3VudCA9IGVmLm1heFtsb2NhdGlvbl07XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZW51bSA9IGVmLnBhZ2VudW07XFxuICAgICAgICAgICAgICAgICAgICBpZiAocGNvdW50ID09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VudW0gPT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VudW0gPSBwY291bnQgLSAxO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtLS07XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICB9LCBpZCwgcGNvdW50LCBTdHJpbmcocGFnZW51bSkpLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZUB1cFxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZShwbGF5cFtwYWdlbnVtXSwge1xcbiAgICAgICAgICAgICAgICAgICAgYzogZmNcXG4gICAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpZCwgcGFnZW51bSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZW51bSA9IGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgcGFnZW51bSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZWYgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5nZXRFSW5mbygpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBjb3VudCA9IGVmLm1heFtsb2NhdGlvbl07XFxuICAgICAgICAgICAgICAgICAgICBpZiAocGNvdW50ID09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBsYXlwID0gZWYucGxheXA7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZWFyciA9IHBsYXlwLm1hcCgoeCwgaSkgPT4gaSA9PSBwYWdlbnVtID8gJ+KAnOKAnOKAneKAnScgKyB4LmZvbnRjb2xvcihcXFwiI2ZmYTUwMFxcXCIpIDogeCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChwYWdlYXJyLCAzKS5zZWxlY3QoKGxvY2F0aW9uKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcoTVlfSU5ERVgpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSwgbG9jYXRpb24pXFxuICAgICAgICAgICAgICAgIH0sIGlkLCBwYWdlbnVtKSxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VAcGFnZWFyclxcXCIsXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUoJ+S4i+S4gOmhtScsIHtcXG4gICAgICAgICAgICAgICAgICAgIGM6IGZjXFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBsb2NhdGlvbiA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGVmID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZ2V0RUluZm8oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhZ2VudW0gPSBlZi5wYWdlbnVtO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBjb3VudCA9PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFnZW51bSsrO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgICAgICAgICAgR00uZ2V0KFxcXCJyZW5vdmF0ZUxpc3RcXFwiLCAoKSA9PiB7fSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZUBuZXh0XFxcIlxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfV1cXG5cXG4gICAgICAgICAgICBsZXQgcGxpbmUgPSBkLmZpbmRJbmRleCh4ID0+IHguZXh0cmEgJiYgeC5leHRyYS5pZCA9PSBcXFwicGxheXBhZ2VsaW5lXFxcIik7XFxuXFxuICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJwbGF5bGlzdF9yZWFkeVxcXCIsIFxcXCIwXFxcIikgPT0gXFxcIjBcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGlmIChwbGluZSA+IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbnNlcnRBcnJheUF0KGQsIHBsaW5lICsgMSwgcGFnZW9iaik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgLy9BcnJheS5wcm90b3R5cGUucHVzaC5hcHBseShkLHBhZ2VvYmopO1xcbiAgICAgICAgICAgICAgICAvL2FkZEl0ZW1BZnRlcihcXFwicGxheXBhZ2VsaW5lXFxcIiwgcGFnZW9iaik7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJub3BhZ2VcXFwiLCBcXFwiMFxcXCIpID09IFxcXCIxXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5cGFnZWxpbmVcXFwiLCBwYWdlb2JqKTtcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcIm5vcGFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcInBsYXlwYWdlQHVwXFxcIiwge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHBhZ2VvYmpbMF0udGl0bGUsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcInBsYXlwYWdlQHBhZ2VhcnJcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogcGFnZW9ialsxXS50aXRsZSxcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwicGxheXBhZ2VAbmV4dFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBwYWdlb2JqWzJdLnRpdGxlLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAvLyBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIFt7XFxuICAgICAgICAgICAgLy8gICB0aXRsZTogJ+S4iuS4gOmhtScsXFxuICAgICAgICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICAgICAgLy8gICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgICAvLyAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgLy8gICAgIGlmIChwYWdlbnVtID09IDApIHtcXG4gICAgICAgICAgICAvLyAgICAgICBwYWdlbnVtID0gcGNvdW50IC0gMTtcXG4gICAgICAgICAgICAvLyAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAvLyAgICAgICBwYWdlbnVtLS07XFxuICAgICAgICAgICAgLy8gICAgIH1cXG4gICAgICAgICAgICAvLyAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIC8vICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICAgICAgLy8gICBleHRyYToge1xcbiAgICAgICAgICAgIC8vICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAvLyAgIH1cXG4gICAgICAgICAgICAvLyB9LCB7XFxuICAgICAgICAgICAgLy8gICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgICAgICAgLy8gICB1cmw6ICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbikgPT4ge1xcbiAgICAgICAgICAgIC8vICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgICAgICAgLy8gICB9LCBsb2NhdGlvbiksXFxuICAgICAgICAgICAgLy8gICBleHRyYToge1xcbiAgICAgICAgICAgIC8vICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAvLyAgIH1cXG4gICAgICAgICAgICAvLyB9LCB7XFxuICAgICAgICAgICAgLy8gICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICAgICAgLy8gICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAgICAgICAvLyAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgLy8gICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICAvLyAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgICAvLyAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAvLyAgICAgICBwYWdlbnVtKys7XFxuICAgICAgICAgICAgLy8gICAgIH1cXG4gICAgICAgICAgICAvLyAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIC8vICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgICAgICAgLy8gICBleHRyYToge1xcbiAgICAgICAgICAgIC8vICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAgICAgICAvLyAgIH1cXG4gICAgICAgICAgICAvLyB9XSlcXG4gICAgICAgICAgICAvKnBsYXlwID0gcGxheXAubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIHRlbXAsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArIChwYWdlbnVtID09IGkgPyB4LmZvbnRjb2xvcihcXFwicmVkXFxcIikgOiB4KSxcXG4gICAgICAgICAgICAgICAgIGNvbF90eXBlOlxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXG4gICAgICAgICAgICAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiKSA9PSBpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKGkpKTtcXG4gICAgICAgICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5bGlzdFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlsaXN0c1xcXCIsICQudGVtcF9saXN0W2ldKTtcXG4gICAgICAgICAgICAgICAgICAgZmluZEl0ZW1zQnlDbHMoXFxcInBsYXlwYWdlXFxcIikuZm9yRWFjaCgoeCwgaWkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICBsZXQgdGl0bGUgPSB4LnRpdGxlLnJlcGxhY2UoL+KAmHzigJl84oCcfOKAnXw8W14+XSs+L2csIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICBpZiAoaWkgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgdGl0bGUgPSAn4oCc4oCc4oCd4oCdJyArIHRpdGxlLmZvbnRjb2xvcihcXFwicmVkXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oeC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IHRpdGxlLFxcbiAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgICB9LCBpKSxcXG4gICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgICAgIGlkOiBcXFwicGFnZW51bVxcXCIgKyBpLFxcbiAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihcXFwicGxheXBhZ2VsaW5lXFxcIiwgcGxheXApKi9cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpO1xcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJub3BhZ2VcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGdldE15VmFyKFxcXCJwbGF5bGlzdF9yZWFkeVxcXCIsIFxcXCIwXFxcIikgPT0gXFxcIjFcXFwiKSB7XFxuICAgICAgICAgICAgbGV0IG9sZElkcyA9IChmaW5kSXRlbXNCeUNscygncGxheWxpc3QnKSB8fCBbXSkubWFwKGl0ID0+IGl0LmV4dHJhLmlkKTtcXG4gICAgICAgICAgICBsZXQgdG9EZWxldGVJZHMgPSBbXTsgLy/lvoXliKDpmaTnmoTml6dpZFxcbiAgICAgICAgICAgIGxldCB0b0FkZERhdGFzID0gW107IC8v5b6F5paw5aKe55qE5paw5pWw5o2uXFxuICAgICAgICAgICAgaWYgKG9sZElkcy5sZW5ndGggPiBsaXN0Lmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICB0b0RlbGV0ZUlkcyA9IG9sZElkcy5zbGljZShsaXN0Lmxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChvbGRJZHMubGVuZ3RoIDwgbGlzdC5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgdG9BZGREYXRhcyA9IGxpc3Quc2xpY2Uob2xkSWRzLmxlbmd0aClcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGNudCA9IE1hdGgubWluKG9sZElkcy5sZW5ndGgsIGxpc3QubGVuZ3RoKTtcXG4gICAgICAgICAgICBpZiAodG9EZWxldGVJZHMubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAvL+acieWIoOmZpOeahOWFiOWIoOmZpFxcbiAgICAgICAgICAgICAgICBkZWxldGVJdGVtKHRvRGVsZXRlSWRzKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHRvQWRkRGF0YXMubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAvL+acieaWsOWinueahOWFiOaWsOWinlxcbiAgICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIob2xkSWRzW2NudCAtIDFdLCB0b0FkZERhdGFzKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgLy9zaG93TG9hZGluZygn5Yqg6L295LitJylcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNudDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIC8v5pyA5ZCO6aG65bqP5pu05pawXFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0ob2xkSWRzW2ldLCBsaXN0W2ldKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcblxcbiAgICAgICAgICAgIC8vbG9nKGxpc3QubGVuZ3RoKVxcbiAgICAgICAgICAgIGlmIChsaXN0KSB7XFxuICAgICAgICAgICAgICAgIGxldCBwbHMgPSBkLmZpbmRJbmRleCh4ID0+IHguZXh0cmEgJiYgeC5leHRyYS5pZCA9PSBcXFwicGxheWxpc3RzXFxcIik7XFxuICAgICAgICAgICAgICAgIGlmIChwbHMgPiAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaW5zZXJ0QXJyYXlBdChkLCBwbHMgKyAxLCBsaXN0KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAvL0FycmF5LnByb3RvdHlwZS5wdXNoLmFwcGx5KGQsbGlzdCk7XFxuICAgICAgICAgICAgICAgIC8vYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCBsaXN0KTtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBsYXlsaXN0X3JlYWR5XFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuXFxuICAgICAgICB1cGRhdGVJdGVtKFxcXCJsb2NhdGlvbkBcXFwiICsgY3VycmVudExvY2F0aW9uLCB7XFxuICAgICAgICAgICAgdGl0bGU6IGZyb21bY3VycmVudExvY2F0aW9uXSxcXG4gICAgICAgIH0pO1xcblxcbiAgICAgICAgdXBkYXRlSXRlbShcXFwibG9jYXRpb25AXFxcIiArIGxvY2F0aW9uLCB7XFxuICAgICAgICAgICAgdGl0bGU6IGZvbnRzdHlsZShmcm9tW2xvY2F0aW9uXSwge1xcbiAgICAgICAgICAgICAgICBjOiBcXFwiI0ZGRDcwMFxcXCIsXFxuIC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W5nIycpLmxhenlSdWxlKChzbykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgc2kgPSBnZXRNeVZhcihcXFwic29ydGlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgaWkgPSAoc2kgPT0gXFxcIjBcXFwiID8gXFxcIjFcXFwiIDogXFxcIjBcXFwiKTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbShcXFwiQHNvcnRcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICBkZXNjOiBzb1tpaV0udGl0bGUsXFxuICAgICAgICAgICAgICAgICAgICBpbWc6IHNvW2lpXS5pbWcsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIHZhciBwbGF5cyA9IGZpbmRJdGVtc0J5Q2xzKFxcXCJwbGF5bGlzdFxcXCIpLnJldmVyc2UoKS5tYXAoeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICB4LmNvbF90eXBlID0geC50eXBlO1xcbiAgICAgICAgICAgICAgICAgICAgeC5leHRyYS5pZCA9IHguZXh0cmEuaWQuZW5kc1dpdGgoXFxcIuKHhVxcXCIpID8geC5leHRyYS5pZC5yZXBsYWNlKC/ih4UkLywgXFxcIlxcXCIpIDogeC5leHRyYS5pZCArIFxcXCLih4VcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHg7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBsZXQgb2xkSWRzID0gKGZpbmRJdGVtc0J5Q2xzKCdwbGF5bGlzdCcpIHx8IFtdKS5tYXAoaXQgPT4gaXQuZXh0cmEuaWQpO1xcblxcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG9sZElkcy5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICAgICAgLy/mnIDlkI7pobrluo/mm7TmlrBcXG4gICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0ob2xkSWRzW2ldLCBwbGF5c1tpXSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IG5ld0l0ZW0gPSAoZmluZEl0ZW1zQnlDbHMoJ3BsYXlsaXN0JykgfHwgW10pO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG5ld0l0ZW0ubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgICAgIC8v5pyA5ZCO6aG65bqP5pu05pawXFxuICAgICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKG5ld0l0ZW1baV0uZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgbmV3SXRlbVtpXS5leHRyYSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogbmV3SXRlbVtpXS5leHRyYS5pZC5yZXBsYWNlKC/ih4UkLywgXFxcIlxcXCIpXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICAgIC8vIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgICAgLy8gYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCBwbGF5cyk7XFxuXFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJzb3J0aVxcXCIsIGlpKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL1xcXCIgKyAoaWkgPT0gXFxcIjBcXFwiID8gXFxcIuato+W6j1xcXCIgOiBcXFwi5YCS5bqPXFxcIik7XFxuICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBzb3J0b2JqKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogJ2F2YXRhcicsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6IFxcXCJAc29ydFxcXCIsXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICAgIGlmIChmcm9tLmxlbmd0aCA+IDEpIHtcXG4gICAgICAgICAgICBmb3IgKGxldCBpIGluIGZyb20pIHtcXG4gICAgICAgICAgICAgICAgbGV0IGNpID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICB0aXRsZTogKGkgPT0gY2kgPyBmb250c3R5bGUoZnJvbVtpXSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGM6IFxcXCIjRkZENzAwXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICB0YWdzOiBcXFwiXFxcIlxcbiAgICAgICAgICAgICAgICAgICAgfSkgOiBmcm9tW2ldKSxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaSwgaWQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIikgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgU3RyaW5nKGkpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHt9KShpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfSwgaSwgaWQpLFxcbiAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbHM6IFxcXCJsb2NhdGlvbkBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBcXFwibG9jYXRpb25AXFxcIiArIGlcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInNjcm9sbF9idXR0b25cXFwiXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJibGFua19ibG9ja1xcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VsaW5lXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJsaW5lXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaWQ6IFxcXCJwbGF5bGlzdHNcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBkLnB1c2goe1xcbiAgICAgICAgY29sX3R5cGU6IFxcXCJibGFua19ibG9ja1xcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFwicGxheWxpc3RzRU5EXFxcIlxcbiAgICAgICAgfVxcbiAgICB9KTtcXG4gICAgY2FjaGVTaG93VGlwcygpO1xcbiAgICByZW5vdmF0ZUxpc3QoZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIikpO1xcbiAgICBzZXRSZXN1bHQoZCk7XFxufSkoKVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVw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aDopoHliIbkuqvop6PmnpDnmoTluo/lj7dcXFxcbi0x5YWo6YOo77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahFxcXCIpLmlucHV0KChsZW5ndGgpID0+IHtcXG4gICAgICAgIGxldCBpbmRleGMgPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgIGxldCBpbmRleHMgPSBbXTtcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxuICAgICAgICBpZiAoIShpbmRleGMubGVuZ3RoICE9PSAwICYmIG1vIDwgMCAmJiBtbyA+IC01KSkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG51bSkgfHwgbnVtID49IGxlbmd0aCB8fCBudW0gPCAwKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG5cXG4gICAgICAgIHJldHVybiAkKFtcXFwiSElLRVJcXFwiLCBcXFwiVFhUXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSwgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgobW8sIGluZGV4cywgZXh0KSA9PiB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gdXAocnVsZXMpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGViNjQgPSBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkocnVsZXMpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGdldFBhc3MgPSAobGVuZ3RoLCBydWxlLCB0eXBl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npoHnlKgpLy50ZXN0KGYpKSB7XFxuICAgICAgICAgICAgICAgIGZsYWdpID0gW2ZdXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgZmxhZ2kgPSBmbGFnaS5maWx0ZXIoeCA9PiAhLyjlhajpg6h85bey56aB55SoKS8udGVzdCh4KSk7XFxuICAgICAgICAgICAgICAgIGlmIChmbGFnaS5pbmNsdWRlcyhmKSkge1xcbiAgICAgICAgICAgICAgICAgICAgZmxhZ2kgPSBmbGFnaS5maWx0ZXIoeCA9PiB4ICE9IGYpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZsYWdpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ2kgPSBbXFxcIuWFqOmDqFxcXCJdXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBmbGFnaS5wdXNoKGYpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImZsYWdpXFxcIiwgZmxhZ2kpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGYpXFxuICAgIH0pXFxufSlcXG5mb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgIGxldCBpdCA9IGFycltpXTtcXG5cXG4gICAgbGV0IGZsYWcgPSBpdC5mbGFnLnNwbGl0KFxcXCJ8XFxcIik7XFxuICAgIGlmIChmbGFnaS5sZW5ndGggPiAwICYmICFbXFxcIuWFqOmDqFxcXCIsIFxcXCLlt7LnpoHnlKhcXFwiXS5pbmNsdWRlcyhmbGFnaVswXSkpIHtcXG4gICAgICAgIGlmICghZmxhZ2kuZXZl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FxcXCJhXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8n1xcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcIiArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gYXJyW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSAhcnVsZS5mb3JiaWRkZW47XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIChydWxlLmZvcmJpZGRlbiA/IFxcXCLnpoHnlKhcXFwiIDogXFxcIuWQr+eUqFxcXCIpICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGksIGxlbmd0aCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGk6IGksXFxuICAgICAgICAgICAgcGFnZVRpdGxlOiBpdC5uYW1lXFxuICAgICAgICB9XFxuICAgIH0pO1xcbn1cXG5cXG5jb3VudFRpdGxlLnRpdGxlID0gJzxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPuino+aekOWIl+ihqDxiPiAoJyArICgoaXRzLmxlbmd0aCAtIGNvdW50KSArIFxcXCIvXFxcIiArIGxlbmd0aCkuZm9udGNvbG9yKFxcXCIjZmY2NjAxXFxcIikgKyBcXFwiKVxcXCI7XFxuXFxuZCA9IGQuY29uY2F0KGl0cyk7XFxuXFxuc2V0UmVzdWx0KGQpO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM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FxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgdXJsSW5kZXgpID0+IHtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mraTpobnml6Dms5XliKDpmaRcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHVybEluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ato+WcqOabtOaWsOino+aekO+8jOWIoOmZpOivt+S7juino+aekOeuoeeQhui/m+WFpVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpOatpOino+aekOWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liKDpmaTmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0sIGluZGV4KVxcbiAgICAgICAgfSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgIH0sIGluZGV4LCB1cmxJbmRleCksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zX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KSB8fCB2b2lkIDA7XFxuICAgICAgICAgICAgaWYgKGhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMgPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJ2aWRlb1VybFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXG4gICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgICAgICBqc1xcbiAgICAgICAgICAgIH1dLCBpbnB1dCxudWxsLCB0cnVlKTtcXG4gICAgICAgIH0pO1xcbiAgICB9KSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5L+d5a2YXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgaXNJbXBvcnQpID0+IHtcXG4gICAgICAgIGxldCBuYW1lID0gZ2V0TXlWYXIoXFxcInBzX25hbWVcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKCFuYW1lKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WQj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Rob2QgPSBnZXRNeVZhcihcXFwicHNfbWV0aG9kXFxcIiwgXFxcIkdFVFxcXCIpO1xcbiAgICAgICAgbGV0IGpzb25QYXRoID0gZ2V0TXlWYXIoXFxcInBzX2pzb25QYXRoXFxcIiwgXFxcIlxcXCIpLnRyaW0oKSB8fCB2b2lkIDA7XFxuICAgICAgICBsZXQganMgPSBnZXRNeVZhcihcXFwicHNfanNcXFwiLCBcXFwiXFxcIikgfHwgdm9pZCAwO1xcbiAgICAgICAgaWYgKHJ1blR5cGUgPT09IFxcXCJKU09OXFxcIiAmJiAhanNvblBhdGgpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlNPTuaooeW8j+S4i+W/hemhu+Whq2pzb25QYXRoXFxcIjtcXG4gICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PT0gXFxcIkpTXFxcIiAmJiAhanMpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlPmqKHlvI/kuIvlv4Xpobvloatqc1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG9iajEgPSB7XFxuICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgIGpzXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcbiAgICAgICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmoxID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBvYmoxKTtcXG4gICAgICAgICAgICBhcnI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gICAgICAgICAgICAgICAgbmV3SSsrO1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVsZXMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIuaWsOWinu+8mlxcXCIgKyBuZXdJICsgXFxcIiDopobnm5bmm7TmlrDvvJpcXFwiICsgKHJ1bGVzLmxlbmd0aCAtIG5ld0kpKTtcXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl5aSx6LSlXFxcIik7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gaW1wb3J0UnVsZShwYXNzKSB7XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgW18sIHJ1b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mICFmaWxlRXhpc3QocGF0aCArIGl0Lm5hbWUpKSkge1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIGl0Lm5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ3R5cGUnOiAzLFxcbiAgICAgICAgICAgICAgICAgICAgJ2FwaSc6ICcuLi9saWJzL2RycHkyLmpzJyxcXG4gICAgICAgICAgICAgICAgICAgICdzZWFyY2hhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdxdWlja1NlYXJjaCc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogXFxcIi4vXFxcIiArIGl0Lm5hbWUsXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIG5hbWVzLnB1c2goaXQubmFtZSk7XFxuICAgIH1cXG4gICAgZGVsZXRlbG9zZShuYW1lcywgcGF0aClcXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgIHNpdGVzOiBydWxlc1xcbiAgICB9KSk7XFxuXFxuICAgIHJldHVybiBcXFwidG9hc3Q6Ly/miJDlip/mm7TmlrBcXFwiICsgY291bnQgKyBcXFwi5LiqXFxcIjs7XFxufVxcblxcbmZ1bmN0aW9uIGRlbGV0ZWxvc2UobmFt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WUgPSBpdC5leHQuZW5kc1dpdGgoXFxcIi5qc1xcXCIpID8gZGVjb2RlVVJJQ29tcG9uZW50KGl0LmV4dC5zcGxpdChcXFwiL1xcXCIpLmF0KC0xKSkgOiAoaXQubmFtZSArIFxcXCIuanNcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGU7XFxuICAgICAgICAgICAgICAgIGlmIChTdHJpbmcoaXQuZXh0KS5zdGFydHNXaXRoKFxcXCJodHRwXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGUgPSByZXF1ZXN0KGl0LmV4dCk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChqb2luVXJsKHVybCwgaXQuZXh0KSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcIi4vXFxcIiArIG5hbWU7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVFeGlzdChwYXRoICsgbmFtZSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKG5hbWUpO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICBkZWxldGVsb3NlKG5hbWVzLCBwYXRoK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vL3NvdXJjZUxpc3Q9W107XFxuICAgICAgICB9IGVsc2UgaWYgKGNvbmZpZy5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBzOi8vZ2l0aHViLmNvbVxcXCIpKSB7XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGdlbmVyYXRlQ29uZmlnQnlHaXRodWIoY29uZmlnLnBhdGgpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImdpdGh1YkRpclxcXCI7XFxuICAgICAgICAgICAgLy9zb3VyY2VMaXN0PVtdO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhmZXRjaChjb25maWcucGF0aCkgfHwgXFxcInt9XFxcIikpO1xcbiAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCAhanNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLku47nvZHnu5zojrflj5bnmoTphY3nva7mlofku7bkuLrnqbrvvIzor7fmo4Dmn6XnvZHnu5xcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImluZGV4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGZpbGUgPSB2b2lkIDA7XFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdC5maW5kKHYgPT4gdi5rZXkgPT09IGNvbmZpZy5jS2V5KTtcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgICAgIC8vY3VycmVudENvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAvL2NvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gSlNPTi5wYXJzZShmZXRjaChzZWFyY2hBbGxvd1BhdGgpIHx8IFxcXCJbXVxcXCIpO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGRlbGV0ZUZpbGUoc2VhcmNoQWxsb3dQYXRoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgbG9hZEVycm9yID0gdm9pZCAwO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlLFxcbiAgICAgICAgICAgIHNlYXJjaEFsbG93LFxcbiAgICAgICAgICAgIHNvdXJjZUxpc3RcXG4gICAgICAgIH07XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgbG9hZEVycm9yID0gZTtcXG4gICAgfVxcblxcbiAgICByZXR1cm4gbnVsbDtcXG59XFxuXFxuZnVuY3Rpb24gZ2VuZXJhdGVDb25maWdCeUxvY2FsKGRpckZpbGUpIHtcXG4gICAgbGV0IGxpc3QgPSBkaXJGaWxlLmxpc3RGaWxlcygpO1xcbiAgICBsZXQgcnVsZXMgPSBbXTtcXG5cXG4gICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xcbiAgICAgICAgbGV0I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xcIiwgMSk7XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlKcyhqc1BhdGgpIHtcXG5cXG4gICAgbGV0IG1haW4gPSBldmFsSnMocmVxdWVzdChqc1BhdGgpLnJlcGxhY2UoL2FzeW5jXFxcXHMqP2Z1bmN0aW9uXFxcXHMqP21haW4vZywgXFxcImZ1bmN0aW9uIG1haW5cXFwiKSArIFxcXCJcXFxcbjttYWluO1xcXCIsIHtcXG4gICAgICAgIHBhdGhMaWI6IHtcXG4gICAgICAgICAgICBqb2luOiBqb2luVXJsLFxcbiAgICAgICAgICAgIHJlYWRGaWxlKHBhdGgpIHtcXG4gICAgICAgICAgICAgICAgcGF0aCA9IHBhdGguc3RhcnRzV2l0aChcXFwiZmlsZTovL1xcXCIpID8gcGF0aCA6IChcXFwiZmlsZTovL1xcXCIgKyBwYXRoKTtcXG5cXG4gICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgcmVhZERpcihwYXRoKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuYW1lcyA9IFtdO1xcbiAgICAgICAgICAgICAgICBsZXQgZmlsZSA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aC5yZXBsYWNlKFxcXCJmaWxlOi8vXFxcIiwgXFxcIlxcXCIpKTtcXG5cXG4gICAgICAgICAgICAgICAgaWYgKCEoZmlsZS5leGlzdHMoKSAmJiBmaWxlLmlzRGlyZWN0b3J5KCkpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGZpbGUubGlzdEZpbGVzKCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goU3RyaW5nKGl0LmdldE5hbWUoKSkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBuYW1lcztcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGRpcm5hbWUocGEpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHBhdGggPSBqb2luVXJsKGpzUGF0aCwgcGEpO1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGZpbGUgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcblxcbiAgICAgICAgICAgICAgICBpZiAoIShmaWxlLmV4aXN0cygpICYmIGZpbGUuaXNEaXJlY3RvcnkoKSkpIHJldHVybiBuYW1lcztcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgZGlyRmlsZS5saXN0RmlsZXMoKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0LmlzRGlyZWN0b3J5KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZXMucHVzaChTdHJpbmcoaXQuZ2V0TmFtZSgpKSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhdGhzO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgc3RhdCgpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICAgIGxvZzogbG9nLFxcbiAgICAgICAgcGF0aDoganNQYXRoLFxcbiAgICAgICAgcGF0aF9kaXI6IGpvaW5VcmwoanNQYXRoLCBcXFwiLi9cXFwiKVxcbiAgICB9KTtcXG4gICAgbGV0IGpzb25UZXh0ID0gbWFpbigpO1xcbiAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoanNvblRleHQpO1xcblxcbiAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uKSkge1xcbiAgICAgICAgcmV0dXJuIGZpbHRlck90aGVyKGpzb24pO1xcbiAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgJiYganNvbi5zaXRlcy5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GNvZGUgPSBcXFwibm9cXFwiO1xcbiAgICAgICAgICBsZXQgcGF0aCA9IG9iai51cmwucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgbGV0IGRpciA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxuICAgICAgICAgIGlmIChkaXIuaXNEaXJlY3RvcnkoKSkge1xcbiAgICAgICAgICAgIGxldCBmbGlzdCA9IGRpci5saXN0RmlsZXMoKTtcXG4gICAgICAgICAgICBmb3IgKHZhciBmIG9mIGZsaXN0KSB7XFxuICAgICAgICAgICAgICAvLyDmo4Dmn6Xmlofku7blkI3mmK/lkKbku6UuanPnu5PlsL5cXG4gICAgICAgICAgICAgIGlmIChmLmlzRmlsZSgpICYmIGYuZ2V0TmFtZSgpLnRvTG93ZXJDYXNlKCkuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcbiAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkgeyB9XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGpzRmlsZXMubGVuZ3RoID49IDUpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGpzRmlsZXMubGVuZ3RoO1xcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgdGltZTogKERhdGUubm93KCkgLSBzKSxcXG4gICAgICAgICAgICB1cmw6IG9iai51cmwsXFxuICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICAgIGNvZGU6IGNvZGUsXFxuICAgICAgICAgICAgaW5kZXg6IG9iai5pXFxuICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHZhciBqID0gSlNPTi5wYXJzZShmZXRjaChvYmoudXJsLCB7XFxuICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcbiAgICAgICAgICB0aW1lb3V0OiA1MDAwLFxcbiAgICAgICAgfSkpO1xcbiAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgbGV0IGMgPSBlIC0gcztcXG4gICAgICAgIGlmIChvYmoudXJsLmluY2x1ZGVzKFxcXCJnaXRodWIuY29tXFxcIikgJiYgai5zdGF0dXNDb2RlID09IDIwMCkge1xcbiAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHZhciBodG1sID0gai5ib2R5O1xcbiAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkubGVuZ3RoO1xcbiAgICAgICAgICB9IGNhdGNoIHsgfVxcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkgeyB9XFxuXFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICB0aW1lOiBjLFxcbiAgICAgICAgICB1cmw6IGoudXJsLFxcbiAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXG4gICAgICAgICAgaW5kZXg6IG9iai5pLFxcbiAgICAgICAgfVxcbiAgICAgIH07XFxuICAgICAgbGV0IHRhc2tzID0gbGlzdC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgIGkgPSBpICsgMTtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIGZ1bmM6IHRhc2ssXFxuICAgICAgICAgIHBhcmFtOiB7XFxuICAgICAgICAgICAgdXJsOiB4LFxcbiAgICAgICAgICAgIGk6IGkgLSAxLFxcbiAgICAgICAgICB9LFxcbiAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxuICAgICAgICB9XFxuICAgICAgfSk7XFxuICAgICAgdmFyIGNvdW50ID0gc3VjY2VzcyA9IHRhc2tzLmxlbmd0aDtcXG4gICAgICBiZSh0YXNrcywge1xcbiAgICAgICAgZnVuYzogZnVuY3Rpb24gKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxuICAgICAgICAgIG9iai5yZXN1bHRzLnB1c2godGFza1Jlc3VsdClcXG4gICAgICAgICAgY291bnQgPSBjb3VudCAtIDE7XFxuICAgICAgICAgIGlm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VxcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgXFxcIjxzbWFsbD5cXFwiICsgY3VycmVudCArIFxcXCLlkI3np7A6XFxcIiArIGl0ZW0ubmFtZSArIFxcXCJcXFxcbui3r+W+hDpcXFwiICsgaXRlbS5wYXRoICsgXFxcIjwvc21hbGw+XFxcIixcXG4gICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoaXRlbSA9PiB7XFxuICAgICAgICBjbGVhckl0ZW0oXFxcIm5vX2xvYWRpbmdcXFwiKTtcXG4gICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICBsZXQge1xcbiAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICBuYW1lXFxuICAgICAgICB9ID0gaXRlbTtcXG4gICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgbmFtZSxcXG4gICAgICAgIH0pKSB7XFxuXFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuY2xlYXIoKTtcXG4gICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICQucmVxdWlyZShcXFwiQ2hhbmdlU291cmNlUG9wXFxcIikuc2hvdygxMDApO1xcbiAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2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gICAgICAgICAgICAgIG5hdHVyYWxTb3J0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5L2/55So5o6S5bqPXFxcIikpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBsZXQgdXNpbmdzdCA9IGdldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgaWYgKHVzaW5nc3QgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIHVzaW5nc3QgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocyA9PSBcXFwi5Yi35paw6YWN572uXFxcIikge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIGFycmF5RGlmZmVyZW5jZShhcnIxLCBhcnIyKSB7XFxuICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKGFycjIubWFwKGl0ZW0gPT4gW2l0ZW0ua2V5LCBpdGVtXSkpO1xcbiAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICBpZiAoIXJ1bnRpbWVDb25maWcuaW5pdERlZmF1bHQoKSkge1xcbiAgICAgICAgICAgICAgdG9hc3QoXFxcIuWIt+aWsOWksei0pVxcXCIpO1xcbiAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgLypcXG4gICAgICAgICAgICBsZXQgQ2tleSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpLmtleTtcXG4gICAgICAgICAgICAvL2xvZyhDa2V5KVxcbiAgICAgICAgICAgIGxldCBjZmcgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRDb25maWcoKVxcbiAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgIG5hbWVcXG4gICAgICAgICAgICB9ID0gY2ZnO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxuICAgICAgICAgICAgICAgIHBhdGgsXFxuICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRDdXJyZW50U291cmNlKENrZXkpOyovXFxuICAgICAgICAgICAgbGV0IG5zb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG5cXG4gICAgICAgICAgICBsZXQgYWxpc3QgPSBhcnJheURpZmZlcmVuY2UobnNvdXJjZXMsIGxpc3QpO1xcbiAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxuXFxuICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDAgfHwgZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgYWxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGxvZyhcXFwi5paw5aKeOlxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgbXNnICs9IFxcXCLmlrDlop5cXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICBkbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnNwbGljZShtYW5hZ2UubGlzdC5pbmRleE9mKHgubmFtZSksIDEpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBsb2coXFxcIuenu+mZpDpcXFwiICsgZGxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgIG1zZyArPSBcXFwiIOenu+mZpFxcXCIgKyBkbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgIG1hbmFnZS5zZXRUaXRsZShcXFwi6YCJ5oup6KeG6aKR5rqQIOW9k+WJjeWFsTpcXFwiICsgbWFuYWdlLmxpc3QubGVuZ3RoICsgXFxcIuS4quinhumikea6kFxcXCIpO1xcbiAgICAgICAgICAgICAgdG9hc3QobXNnICsgXFxcIiDmm7TlpJror6bmg4XnnItsb2dcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdG9hc3QoXFxcIuW3suWIt+aWsFxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLpnZLlsJHlubTmqKHlvI9cXFwiKSkge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIHNlbGVjdCgpIHtcXG4gICAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgXFxcInRpdGxlXFxcIjogXFxcIumAieaLqVxcXCIsIFxcXCJvcHRpb25zXFxcIjogW1xcXCLkuLTml7blhbPpl61cXFwiLCBcXFwi5YWz6ZetXFxcIl0sIGNvbDogMSxcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgIHRvYXN0KGlucHV0ICsgXFxcIui/h+a7pFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5Li05pe25YWz6ZetXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInRlbXBMZWFjaFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJsZWFjaFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAocy5pbmNsdWRlcyhcXFwi5YWz6ZetXFxcIikpIHtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIixcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidGVtcExlYWNoXFxcIik7XFxuICAgICAgICAgICAgICB0b2FzdChcXFwi5omT5byA6L+H5rukXFxcIik7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIGlmIChoaWtlclBvcC5jYW5CaW9tZXRyaWMoKSAhPT0gMCkge1xcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlr4bnoIHov5vooYzlhbPpl61cXFwiLFxcbiAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L6T5YWl5a+G56CBXFxcIixcXG4gICAgICAgICAgICAgICAgICBoaW50OiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgICAgIHRleHRhcmVhOiBmYWxzZSwgLy/lpJrooYzmqKHlvI9cXG4gICAgICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgICAgICAvL2hpZGVDYW5jZWw6IHRydWUsXFxuICAgICAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dCAhPSBTdHJpbmcocHMpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr4bnoIHplJnor69cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgc2VsZWN0KCk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5jaGVja0J5QmlvbWV0cmljKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICBoaWtlclBvcC5ydW5Pbk5ld1RocmVhZCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKTtcXG4gICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHBvcC5kaXNtaXNzKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxuICAgICAgICAgICAgICB0aXRsZTogXFxcIue8lueggeexu+Wei1xcXCIsXFxuICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIuS4jee8lueggVxcXCIsIFxcXCJHemlwXFxcIiwgXFxcIkJhc2U2NFxcXCIsIFxcXCJBRVNcXFwiXSxcXG4gICAgICAgICAgICAgIGNvbDogMSxcXG4gICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgaWYgKE1ZX0lOREVYID09PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJzaGFyZV9lbmNvZGVcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzaGFyZV9lbmNvZGVcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL1xcXCIgKyBpbnB1dDtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgfSk7XFxuICAgIH1cXG4gIH0pO1xcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHnnrqHnkIZcIixcInBhdGhcIjpcIkRycHlNYW5hZ2VcIixcInJ1bGVcIjpcImpzOlxcbmNvbnN0IEpTRW5naW5lID0gY29tLmV4YW1wbGUuaGlrZXJ2aWV3LnNlcnZpY2UucGFyc2VyLkpTRW5naW5lO1xcbmNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG5jb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lNYW5hZ2UpID0+IHtcXG4gICAgICAgICAgICBEcnB5TWFuYWdlLnB1dChrZXksIGRycHkpO1xcbiAgICAgICAgfSk7XFxuICAgIH0sIGtleSwgR01rZXksIE1ZX1RJQ0tFVCkgKyBcXFwiO1xcXFxuXFxcIiwgXFxcIlxcXCIsIGZhbHNlKTtcXG59XFxuXFxuZnVuY3Rpb24gZ2V0KGtleSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICAvL2xvZyhkcnB5TWFwLnNpemUpXFxuICAgICAgICBpZiAoZHJweU1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGRycHlNYXAuc2l6ZSA+PSA1KSB7XFxuICAgICAgICAgICAgLy9sb2coXFxcIuivt+axgjpcXFwiICsga2V5KVxcbiAgICAgICAgICAgIGRlbChBcnJheS5mcm9tKGRycHlNYXAua2V5cygpKS5hdCgwKSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2VzKCkuZmluZCh2ID0+IHYua2V5ID09PSBrZXkpO1xcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpKTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKGRycHkuZ2V0UnVsZShcXFwicHJveHlfcnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBQcm94eSA9ICQucmVxdWlyZShcXFwiTG9jYWxQcm94eVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcHJveHlVcmwgPSBQcm94eS5zdGFydFByb3h5KE1ZX1JVTEUudGl0bGUsIEdNLmdldFNlbGZLZXkoKSk7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJQcm94eV9VcmxcXFwiLCBwcm94eVVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuLy9zb3VyY2UuZXh05b+F6aG75Li657ud5a+56Lev5b6EXFxuZnVuY3Rpb24gZ2V0QnlTb3VyY2Uoc291cmNlKSB7XFxuICAgIHJldHVybiBzeW5jKCgpID0+IHtcXG4gICAgICAgIGxldCBrZXkgPSBzb3VyY2Uua2V5O1xcbiAgICAgICAgLy9sb2coZHJweU1hcC5zaXplKVxcbiAgICAgICAgaWYgKGRycHlNYXAuaGFzKGtleSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChkcnB5TWFwLnNpemUgPj0gNSkge1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCLor7fmsYI6XFxcIiArIGtleSlcXG4gICAgICAgICAgICBkZWwoQXJyYXkuZnJvbShkcnB5TWFwLmtleXMoKSkuYXQoMCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHNvdXJjZS5leHQpO1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBpZiAoZHJweS5nZXRSdWxlKFxcXCJwcm94eV9ydWxlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgbGV0IFByb3h5ID0gJC5yZXF1aXJlKFxcXCJMb2NhbFByb3h5XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBwcm94eVVybCA9IFByb3h5LnN0YXJ0UHJveHkoTVlfUlVMRS50aXRsZSwgR00uZ2V0U2VsZktleSgpKTtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcIlByb3h5X1VybFxcXCIsIHByb3h5VXJsKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gZHJweTtcXG4gICAgfSwgdGhpcykuY2FsbCgpO1xcbn1cXG5cXG5mdW5jdGlvbiBwdXQoa2V5LCBkcnB5KSB7XFxuICAgIHN5bmMoKCkgPT4gZHJweU1hcC5zZXQoa2V5LCBkcnB5KSwgdGhpcykuY2FsbCgpO1xcbn1cXG5cXG5mdW5jdGlvbiBydW5Qcm94eShkcnB5LCBhcmdzKSB7XFxuICAgIGlmICh0eXBlb2YgZHJweS5wcm94eSA9PT0gXFxcImZ1bmN0aW9uXFxcIikge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMSA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgcHJveHlTZW1hcGhvcmUuYWNxdWlyZSgpO1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUyID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiMeetieW+heaXtumXtDpcXFwiICsgKHRpbWUyIC0gdGltZTEpICsgXFxcIm1zXFxcIik7XFxuICAgICAgICAgICAgbGV0IHJlcyA9IGRycHkucHJveHkuYXBwbHkoZHJweSwgYXJncyk7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCIy5omn6KGM5Luj55CG6ICX5pe2OlxcXCIgKyAodGltZTMgLSB0aW1lMikgKyBcXFwibXNcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiM+aAu+iAl+aXtuiAl+aXtjpcXFwiICsgKHRpbWUzIC0gdGltZTEpICsgXFxcIm1zXFxcIik7XFxuXFxuICA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BzZWFyY2hLZXksXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxuICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXG4gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICBjYW5TZWFyY2hTb3VyY2UuZm9yRWFjaCgodiwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlID0gY2FuU2VhcmNoU291cmNlLnNsaWNlKCk7XFxuICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgIH0sXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuXFxuXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5zb3J0KChhLCBiKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nKGEubmFtZSkubG9jYWxlQ29tcGFyZShTdHJpbmcoYi5uYW1lKSwgdW5kZWZpbmVkLCB7XFxuICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgIHNlbnNpdGl2aXR5OiAnYmFzZSdcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5yZXZlcnNlKCk7XFxuXFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNCkge1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICghc2VhcmNoQWxsb3cuaW5jbHVkZXModikpIHtcXG4gICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDUpIHtcXG4gICAgICAgICAgICBsZXQgdGVtbGlzdCA9IHNlYXJjaEFsbG93LnNsaWNlKCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAodGVtbGlzdC5pbmNsdWRlcyh2LmtleSkpIHJldHVybjtcXG4gICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgfSk7XFxuICAgIH1cXG4gIH0pO1xcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuWIhuexu1wiLFwicGF0aFwiOlwiY2F0ZWdvcnlzXCIsXCJydWxlXCI6XCJqczpcXG5sZXQgZmwgPSB7fTtcXG5sZXQgcmVz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AgICAgdCA9IFxcXCI8Yj48Zm9udCBjb2xvcj1cXFwiICsgY29sb3IgKyBcXFwiPlxcXCIgKyB0ICsgXFxcIjwvZm9udD48L2I+XFxcIjtcXG4gICAgICAgICAgICBmbFt4LmtleV0gPSBpdC52O1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChjYXRlX3RlbXBbaW5kZXhdID09IFxcXCItMVxcXCIpIHtcXG4gICAgICAgICAgICBmbFt4LmtleV0gPSBcXFwidW5kZWZpbmVkXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZm9sZCA9PSAxKSB7XFxuICAgICAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgdCxcXG4gICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgobykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IG8uaTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImlzX2RlZlxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX29iaiA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJjYXRlX29ialxcXCIsIHt9KTtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfdGVtcCA9IG8uY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICBpZiAoY2F0ZV90ZW1wLmNvbnN0cnVjdG9yICE9IEFycmF5KSB7XFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5pbmRleDtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGMpXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IGkgKyBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjYXRlX29ialtvLmNhdGVdID0gY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjYXRlX3RlbXApXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfdGVtcFxcXCIsIGNhdGVfdGVtcCk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX29ialxcXCIsIGNhdGVfb2JqKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxcbiAgICAgICAgICAgICAgICBjYXRlX3RlbXA6IGNhdGVfdGVtcCxcXG4gICAgICAgICAgICAgICAgaTogaSxcXG4gICAgICAgICAgICAgICAgY2F0ZTogY2F0ZVxcbiAgICAgICAgICAgICAgfSksXFxuICAgICAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgfSlcXG4gICAgfVxcbiAgfVxcbn1cXG5cXG5mdW5jdGlvbiBnZXRGbCgpIHtcXG4gIGZsID0gT2JqZWN0LmtleXMoZmwpLmZpbHRlcihrZXkgPT4gZmxba2V5XSAhPT0gXFxcInVuZGVmaW5lZFxcXCIpLnJlZHV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mtleSkuaW5pdChydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KSk7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICB9KVxcbiAgICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiBcXFwi6YeN6L295rqQXFxcIixcXG4gICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICBEcnB5TWFuYWdlLmRlbChzb3VyY2Uua2V5KTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIH0pXFxuICAgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IFxcXCLmn6XnnIvmupDku6PnoIFcXFwiLFxcbiAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIGxldCBjb2RlID0gRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkucnVuTWFpbihcXFwibGV0IG1haW49XFxcIiArICQudG9TdHJpbmcoKGV4dCkgPT4ge1xcbiAgICAgICA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Ckge1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGN1cnJlbnQudGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGN1cnJlbnQucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogY3VycmVudC5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGN1cnJlbnQudHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBpdGVtLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogY3VycmVudC5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBjdXJyZW50LmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oY3VycmVudC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGl0ZW0ucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogaXRlbS5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGl0ZW0udHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBjdXJyZW50LmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogaXRlbS5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBpdGVtLmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxldCBuYXJyID0gJC5zd2FwQXJyYXlFbGVtZW50cyhpbmRleHMsIGN1cnJlbnQuZXh0cmEuaW5kZXgsIGl0ZW0uZXh0cmEuaW5kZXgpO1xcblxcbiAgICAgICAgICAgICQudWlDb25maWcuc2V0KG5hcnIsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgaCA9ICfigJzigJzigJ3igJ0nO1xcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0ZW0udGl0bGU7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIumAieaLqeenu+WKqOeahOebruagh1xcXCIpO1xcbiAgICAgICAgICAgIGlmICgvdGV4dF9pY29ufGF2YXRhcnxpY29uX3NtYWxsXzMvLnRlc3QoaXRlbS50eXBlKSkge1xcbiAgICAgICAgICAgICAgaCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKC9pY29uXzFfc2VhcmNoLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gXFxcIuKeoe+4j1xcXCIgKyB0aXRsZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogaCArIHRpdGxlLFxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiLCBpdGVtKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaSlcXG4gICAgICAgIGl0ZW1bXFxcImV4dHJhXFxcIl0gPSB7XFxuICAgICAgICAgIGtleTogaXRlbS5rZXksXFxuICAgICAgICAgIGNsczogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiLFxcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgaW5kZXg6IGl0ZW0uaW5kZXgsXFxuICAgICAgICB9XFxuICAgICAgICBpZiAoaXRlbS5rZXkgIT0gXFxcIuiuvue9rlxcXCIpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gLTE7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0sIGl0ZW0ua2V5KVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCEvaWNvbl8xX3NlYXJjaHxhdmF0YXIvLnRlc3QoaXRlbS5jb2xfdHlwZSkpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuabtOaNouWbvuagh1xcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbWdcXFwiXSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGlkID0gZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKS5maWx0ZXIoeCA9PiB4LmV4dHJhLmtleSA9PSBrZXkpWzBdLmV4dHJhLmlkO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHBpYzogaW5wdXQgfSlcXG4gICAgICAgICAgICAgIH0sIGtleSlcXG4gICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLmjaLmupBcXFwiICYmIGl0ZW0ua2V5ICE9IFxcXCLmkJzntKLmqKHlvI9cXFwiKSB7XFxuICAgICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi5L+u5pS55ZCN56ewXFxcIixcXG4gICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcInRpdGxlXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHRpdGxlOiBpbnB1dCB9KVxcbiAgICAgICAgICAgICAgICB9LCBrZXkpXFxuICAgICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpdGVtLmV4dHJhLkxvbmdDbGljayA9IGxvbmdjbGlja3M7XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9IGVsc2Uge1xcbiAgICAgIHVpb2JqID0gdWlvYmoubWFwKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBpdGVtLmV4dHJhID0ge1xcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCJcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgIH0pXFxuICAgIH1cXG4gICAgZCA9IGQuY29uY2F0KHVpb2JqKTtcXG5cXG4gICAgaWYgKGluZGV4cy5zb21lKHggPT4geC5pbmRleCA9PSAtMSkgJiYgdWltb2RlKSB7XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5bey56e76ZmkXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICAgIH0pXFxuICAgICAgaW5kZXhzLmZpbHRlcih4ID0+IHguaW5kZXggPT0gLTEpLmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgIGxldCBtYXAgPSBuZXcgTWFwKHN1aW9iai5tYXAob2JqID0+IFtvYmoua2V5LCBvYmpdKSk7XFxuICAgICAgICBsZXQgb2JqID0gbWFwLmdldChpdGVtLmtleSk7XFxuICAgICAgICBvYmoudXJsID0gJChcXFwiXFxcIikubGF6eVJ1bGUoKGtleSwgaW5kZXgpID0+IHtcXG4gICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gaW5kZXg7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBpdGVtLmt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xcIuWkjeWItlxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICBjb3B5KEpTT04uc3RyaW5naWZ5KHVpX2NvbmZpZy55aSkpO1xcbiAgICAgICAgICB9LCB1aV9jb25maWcpLFxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWvvOWFpVxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCh1aV9jb25maWcpID0+IHtcXG4gICAgICAgICAgICB2YXIgdWMgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJ7e2NsaXBib2FyZH19XFxcIikuaW5wdXQoKHVjKSA9PiB7XFxuICAgICAgICAgICAgICB2YXIgeWkgPSB7fTtcXG4gICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHlpID0gSlNPTi5wYXJzZShpbnB1dCk7XFxuICAgICAgICAgICAgICAgIGlmICh5aS5oYXNPd25Qcm9wZXJ0eShcXFwidWlcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgIHVjLnlpID0geWk7XFxuICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWMpO1xcbiAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuagvOW8j+mUmeivr1xcXCIpXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgdWMpXFxuICAgICAgICAgIH0sIHVpX2NvbmZpZylcXG4gICAgICAgIH1dXFxuICAgICAgfVxcbiAgICB9KVxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBc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pIHtcXG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAnc3RyaW5nJykge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gW107XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwYXRoID0gW107XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICBsZXQgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgIGxldCBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHZhbHVlLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBjaGFyID0gdmFsdWVbaV07XFxuICAgICAgICAgICAgICAgIGlmIChlc2NhcGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJy4nICYmICFpbkJyYWNrZXRzKSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1snKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBwYXRoO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgZnVuY3Rpb24gZ2V0SnNvbihvYmosIHBhdGgpIHtcXG4gICAgICAgICAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBwYXRoW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gbnVsbCB8fCBjdXJyZW50ID09PSB1bmRlZmluZWQgfHwgdHlwZW9mIGN1cnJlbnQgIT09ICdvYmplY3QnKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyZW50W2tleV07XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBjdXJyZW50O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcnVuVHlwZSA9IE1ZX1BBUkFNUy5ydW5UeXBlWzBdO1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pKTtcXG4gICAgICAgICAgICBpZiAocnVuVHlwZSA9PSBcXFwiSlNPTlxcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcmFtID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBwYXJhbS5oZWFkZXJzIHx8IHt9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBwYXJhbS5tZXRob2QgfHwgdm9pZCAwXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IE9iamVjdC5hc3NpZ24oe30sIHBhcmFtLmhlYWRlcnMgfHwge30sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiBnZXRKc29uKGpzb24sIHRvUGF0aChwYXJhbS5qc29uUGF0aCkpLFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09IFxcXCJKU1xcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcnNlO1xcbiAgICAgICAgICAgICAgICBpZiAoTVlfUEFSQU1TLmluZGV4KSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyB0aXRsZSkuZ2V0SnNvbigpW01ZX1BBUkFNUy5pbmRleFswXV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKGRlY29kZVVSSUNvbXBvbmVudChNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IHJlcyA9IG5ldyBGdW5jdGlvbihcXFwidXJsXFxcIiwgXFxcInNlbGZcXFwiLCBwYXJzZS5qcykodXJsLCBwYXJzZSk7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzID09PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiByZXNcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgkLnR5cGUocmVzKSA9PT0gXFxcIm9iamVjdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHJlc1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG5cXG4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nRyaWVzID0gZW50cmllcy5tYXAoKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgICAgICAgICAgLy8g5aaC5p6c5pyJ6YeN5ZG95ZCN5Zue6LCD5Ye95pWw77yM5YiZ6LCD55So5a6DXFxuICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbmFtZUNhbGxiYWNrID09PSAnZnVuY3Rpb24nKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBbcmVuYW1lQ2FsbGJhY2soa2V5LCB2YWx1ZSksIHZhbHVlXTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIHJldHVybiBba2V5LCB2YWx1ZV07XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgY29uc3QgZmlsdGVyZWRFbnRyaWVzID0gc2hvdWxkRXhjbHVkZSA/XFxuICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+ICFrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSkgOlxcbiAgICAgICAgICAgICAgcHJvY2Vzc2VkRW50cmllcy5maWx0ZXIoKFtrZXldKSA9PiBrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSk7XFxuICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5mcm9tRW50cmllcyhmaWx0ZXJlZEVudHJpZXMpO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIC8vIOWmguaenOWFg+e0oOS4jeaYr+WvueixoeaIluaVsOe7hO+8jOebtOaOpei/lOWbnlxcbiAgICAgICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgICB9LFxcbiAgICAgIGVudW1lcmFibGU6IGZhbHNlLCAvLyDorr7nva7kuLrkuI3lj6/mnprkuL5cXG4gICAgfSxcXG4gICAgdHJhbnNmb3JtS2V5czoge1xcbiAgICAgIHZhbHVlOiBmdW5jdGlvbiAoa2V5TWFwcGlu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It+aWsOmFjee9ruWQjuS8muWQjOatpeabtOaWsOaVsOmHj+aYvuekuuOAglxcXCIsXFxuICAgIF1cXG59LCB7XFxuICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8xMCAgTWF4VmVyc2lvbiAyNVxcXCIsXFxuICAgIHJlY29yZHM6IFtcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrlop7liqDmm7TmlrDml6Xlv5fjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8mumAiea6kOmVv+aMieiPnOWNle+8jOWinuWKoOi3s+i9rOe9kemhte+8jOafpeeci+a6kOeggeOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN57yW6L6R6Kej5p6Q55WM6Z2i5rWL6K+VanPop6PmnpDkuIDnm7TlpLHotKXjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjWdpdGh1YuiuoumYhe+8jOS8muWIoOmZpOWFqOmDqOinhOWImeaWh+S7tuOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN6Kej5p6Q6LCD55So5aSx6LSl44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3mm7TmjaLphY3nva7ml7bmsqHmnInlj4rml7bmuIXnqbpkcnB557yT5a2Y44CCXFxcIixcXG4gICAgICAgIFxcXCJvcHRpbWl6Ze+8muabtOaUueiuoumYheabtOaWsOetlueVpe+8jOS8muWIoOmZpOacrOWcsOWkseaViOa6kOOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrmm7TmlrBkcnB5Mi5qc+OAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrkvJjljJbop6PmnpBmbGFn5Yy56YWN44CCXFxcIixcXG5cXG4gICAgXVxcbn0sIHtcXG4gICAgdGl0bGU6IFxcXCIyMDI0LzA2LzA5IE1heFZlcnNpb24gMjBcXFwiLFxcbiAgICByZWNvcmRzOiBbXFxuICAgICAgICBcXFwi4oCY4oCYbmV34oCZ4oCZ77ya5pSv5oyBcHJveHlfcnVsZeS7o+eQhuOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN5LqR55uY6ZO+5o6l5LiN6LCD5Y+W5LqR55uY566A44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3lk5Tlk6nlvbHop4bkuI3og73kvb/nlKjop6PmnpDjgIJcXFwiLFxcbiAgICBdXFxufV07XCJ9XSIsImljb24iOiIiLCJwcm94eSI6IiJ9
Add Comment
Please, Sign In to add comment