Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjo0MCwiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1pYW5Mb2FkXCIpOyIsInNlYXJjaF91cmwiOiJoaWtlcjovL2VtcHR5P3M9KiomcGFnZT1meXBhZ2UiLCJncm91cCI6Iua1i+ivlSIsInNlYXJjaEZpbmQiOiJqczpcbihmdW5jdGlvbiAoKSB7XG4gIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgbGV0IHRlbXNtb2RlID0gZ2V0TXlWYXIoXCJ0ZW1zbW9kZVwiLCBcIlwiKTtcbiAgaWYgKHRlbXNtb2RlKSB7XG4gICAgc21vZGUgPSBOdW1iZXIodGVtc21vZGUpO1xuICAgIGNsZWFyTXlWYXIoXCJ0ZW1zbW9kZVwiKTtcbiAgfVxuICBpZiAoIWZpbGVFeGlzdChcImhpa2VyOi8vZmlsZXMvZGF0YS9cIiArIE1ZX1JVTEUudGl0bGUgKyBcIi9saWJzX2hpa2VyL2RycHkyLmpzXCIpKSByZXR1cm4gc2V0UmVzdWx0KFt7XG4gICAgdGl0bGU6IFwi6K+35YmN5b6A5bCP56iL5bqP5Li76aG16K6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IGRlc2M6IGl0LnZvZF9yZW1hcmtzICsgXCLCt1wiICsgc291cmNlLm5hbWUsXG4gICAgICAgIGNvbnRlbnQ6IGl0LnZvZF9jb250ZW50LFxuICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1wiLFxuICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgdm9kSWQ6IFN0cmluZyhpdC52b2RfaWQpLFxuICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXG4gICAgICAgICAgc2tleTogc291cmNlLmtleSxcbiAgICAgICAgfVxuICAgICAgfSk7XG4gICAgfVxuICAgIHNldFJlc3VsdChkKTtcbiAgfSBlbHNlIHtcbiAgICBzZXRSZXN1bHQoW3tcbiAgICAgIHRpdGxlOiBcIueCueaIkeW8gOWni+iBmuWQiOaQnOe0olwiICsgTVlfS0VZV09SRCxcbiAgICAgIHVybDogXCJoaWtlcjovL3NlYXJjaD9zPVwiICsgTVlfS0VZV09SRCxcbiAgICAgIGV4dHJhOiB7XG4gICAgICAgIGRlbGVnYXRlT25seVNlYXJjaDogdHJ1ZSxcbiAgICAgICAgcnVsZXM6ICQudG9TdHJpbmcoKCkgPT4ge1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcInJ1bnRpbWVDb25maWdcIiwgXCJydW50aW1lQ29uZmlnXCIpO1xuICAgICAgICAgICAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXCJzbW9kZVwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbG93U2VhcmNoU291cmNlKHNtb2RlPT09Mik7XG5cbiAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcblxuICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcblxuICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgIGxpc3Quc3BsaWNlKGxpc3QuaW5kZXhPZihzb3VyY2UpLCAxKTtcbiAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsZXQgc2VhcmNoc29ydCA9IE51bWJlcihnZXRJdGVtKFwic2VhcmNoc29ydFwiLCBcIjBcIikpO1xuICAgICAgICAgICAgbGV0IHtcbiAgICAgICAgICAgICAgbmF0dXJhbFNvcnQsXG4gICAgICAgICAgICAgIHVzaW5nU29ydFxuICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcIm1ldGhvZHNcIik7XG5cbiAgICAgICAgICAgIGlmIChzZWFyY2hzb3J0ID4gMCkge1xuICAgICAgICAgICAgICBpZiAoc2VhcmNoc29ydCA9PSAxKSB7XG4gICAgICAgICAgICAgICAgbmF0dXJhbFNvcnQobGlzdCwgXCJuYW1lXCIpO1xuICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNlYXJjaHNvcnQgPT0gMikge1xuICAgICAgICAgICAgICAgIHVzaW5nU29ydC5zZXRrZXkoXCJuYW1lXCIpO1xuICAgICAgICAgICAgICAgIHVzaW5nU29ydC5nZXQobGlzdClcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcbiAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgIGxldCBkcnB5ID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKS5nZXQoaXRlbS5rZXkpO1xuXG4gICAgICAgICAgICAgICAgICBsZXQgaG9tZUxpc3QgPSBKU09OLnBhcnNlKGRycHkuc2VhcmNoKE1ZX0tFWVdPUkQsIGZhbHNlLCBNWV9QQUdFKSkubGlzdCB8fCBbXTtcbiAgICAgICAgICAgICAgICAgIGxldCBkID0gW107XG4gICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBob21lTGlzdCkge1xuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC52b2RfbmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcbiAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBpdC52b2RfY29udGVudCxcbiAgICAgICAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1wiLFxuICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2b2RJZDogU3RyaW5nKGl0LnZvZF9pZCksXG4gICAgICAgICAgICAgICAgICAgICAgICBpc1BvbHltZXJpemU6IHRydWUsXG4gICAgICAgICAgICAg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GdldENyeXB0b0pTKCkpO1xcbiAgICBnbG9iYWxUaGlzLkNyeXB0b0pTID0gQ3J5cHRvSlM7XFxuXFxuICAgIGxldCAkcmVxdWVzdCA9IHJlcXVlc3Q7XFxuICAgIGxldCAkcG9zdCA9IHBvc3Q7XFxuICAgIGdsb2JhbFRoaXMucmVxID0gZnVuY3Rpb24odXJsLCBjb2JqKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCByZXMgPSB7fTtcXG4gICAgICAgICAgICBsZXQgb2JqID0gT2JqZWN0LmFzc2lnbih7fSwgY29iaik7XFxuICAgICAgICAgICAgaWYgKG9iai5kYXRhKSB7XFxuICAgICAgICAgICAgICAgIG9iai5ib2R5ID0gb2JqLmRhdGE7XFxuICAgICAgICAgICAgICAgIGRlbGV0ZSBvYmouZGF0YTtcXG4gICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgaWYgKG9iai5oYXNPd25Qcm9wZXJ0eShcXFwicmVkaXJlY3RcXFwiKSkgb2JqLnJlZGlyZWN0ID0gISFvYmoucmVkaXJlY3Q7XFxuICAgICAgICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXG4gICAgICAgICAgICAgICAgb2JqLnRvSGV4ID0gdHJ1ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqLmhlYWRlcnMgPSBPYmplY3QuYXNzaWduKHtcXG4gICAgICAgICAgICAgICAgQ29va2llOiBcXFwiI25vQ29va2llI1xcXCJcXG4gICAgICAgICAgICB9LCBvYmouaGVhZGVycyk7XFxuICAgICAgICAgICAgaWYgKHVybCA9PT0gXFxcImh0dHBzOi8vYXBpLm5uLmNpL29jci9iNjQvdGV4dFxcXCIgJiYgb2JqLmhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgb2JqLmhlYWRlcnNbXFxcIkNvbnRlbnQtVHlwZVxcXCJdID0gXFxcInRleHQvcGxhaW5cXFwiO1xcbiAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICBpZiAodXJsLnN0YXJ0c1dpdGgoXFxcImZpbGU6Ly9cXFwiKSAmJiAodXJsLmluY2x1ZGVzKFxcXCI/dHlwZT1cXFwiKSB8fCB1cmwuaW5jbHVkZXMoXFxcIj9wYXJhbXM9XFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIG9iai5oZWFkZXJzW2tleV0gIT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCByID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgLyogaWYgKFN0cmluZyhvYmoubWV0aG9kKS50b0xvd2VyQ2FzZSgpID09PSBcXFwicG9zdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgIHIgPSAkcG9zdCh1cmwsIG9iaik7XFxuICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgICB9Ki9cXG4gICAgICAgICAgICByID0gJHJlcXVlc3QodXJsLCBvYmopO1xcbiAgICAgICAgICAgIGlmIChvYmoud2l0aEhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICAgICAgICAgIHJlcy5jb250ZW50ID0gci5ib2R5O1xcbiAgICAgICAgICAgICAgICByZXMuaGVhZGVycyA9IHt9O1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmVzLmhlYWRlcnNba10gPSB2WzBdO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmVzLmNvbnRlbnQgPSByO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqLmJ1ZmZlciA9PT0gMikge1xcbiAgICAgICAgICAgICAgICByZXMuY29udGVudCA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChyZXMuY29udGVudCkudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coXFxcIkVycm9yXFxcIiArIGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgLypcXG4gICAgY29uc3QgSmluSmEgPSAkLnJlcXVpcmUoXFxcImh0dHBzOi8vY2RuLmJvb3RjZG4ubmV0L2FqYXgvbGlicy9tdXN0YWNoZS5qcy80LjEuMC9tdXN0YWNoZS5qc1xcXCIpO1xcbiAgXFxuICAgIGNvbnN0IEpQID0gJC5yZXF1aXJlKFxcXCJodHRwczovL2pzb25wYXRoLXBsdXMuZ2l0aHViLmlvL0pTT05QYXRoL2Rpc3QvaW5kZXgtYnJvd3Nlci11bWQuY2pzXFxcIik7XFxuICAgIGdsb2JhbFRoaXMuY2hlZXJpbyA9IHtcXG4gICAgICAgIGppbmphMih0ZW1wbGF0ZSwgb2JqKSB7XFxuICAgICAgICAgICAgXFxuICAgICAgICAgICAgcmV0dXJuICQubG9nKEppbkphLnJlbmRlcih0ZW1wbGF0ZSwgb2JqKSk7XFxuICAgICAgICB9LFxcbiAgICAgICAganAocGF0aCwganNvbikge1xcbiAgICAgICAgICAgIHJldHVyb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oZXhjbHVkZUtleXNcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaXRlbSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gaXRlbS5leGNsdWRlS2V5cyhleGNsdWRlLCBrZXlzLCByZW5hbWVDYWxsYmFjayk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGl0ZW0gPT09ICdvYmplY3QnICYmIGl0ZW0gIT09IG51bGwpIHtcXG4gICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDmmK/kuIDkuKrlr7nosaHvvIzkvb/nlKhPYmplY3QuZnJvbUVudHJpZXPlkoxPYmplY3QuZW50cmllc+adpeWkhOeQhumUrlxcbiAgICAgICAgICAgIGNvbnN0IGVudHJpZXMgPSBPYmplY3QuZW50cmllcyhpdGVtKTtcXG4gICAgICAgICAgICBjb25zdCBwcm9jZXNzZWRFbnRyaWVzID0gZW50cmllcy5tYXAoKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgICAgICAgICAgLy8g5aaC5p6c5pyJ6YeN5ZG95ZCN5Zue6LCD5Ye95pWw77yM5YiZ6LCD55So5a6DXFxuICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbmFtZUNhbGxiYWNrID09PSAnZnVuY3Rpb24nKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBbcmVuYW1lQ2FsbGJhY2soa2V5LCB2YWx1ZSksIHZhbHVlXTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIHJldHVybiBba2V5LCB2YWx1ZV07XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgY29uc3QgZmlsdGVyZWRFbnRyaWVzID0gc2hvdWxkRXhjbHVkZSA/XFxuICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+ICFrZXlzVG9IYW5kbGUuaW5jbHVkZXMoa2V5KSkgOlxcbiAgICAgICAgICAgICAgcHJvY2Vzc2VkRW50cmllcy5maWx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llcyA9IE9iamVjdC5lbnRyaWVzKGl0ZW0pO1xcbiAgICAgICAgICAgIGNvbnN0IHRyYW5zZm9ybWVkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXG4gICAgICAgICAgICAgIGNvbnN0IG5ld0tleSA9IGtleU1hcHBpbmdba2V5XSB8fCBrZXk7IC8vIOWmguaenOmUruWcqOaYoOWwhOS4re+8jOS9v+eUqOaWsOmUru+8m+WQpuWImeS9v+eUqOWOn+Wni+mUrlxcbiAgICAgICAgICAgICAgcmV0dXJuIFtuZXdLZXksIHZhbHVlXTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKHRyYW5zZm9ybWVkRW50cmllcyk7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5LiN5piv5a+56LGh5oiW5pWw57uE77yM55u05o6l6L+U5ZueXFxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICAgIH0sXFxuICAgICAgZW51bWVyYWJsZTogZmFsc2UsIC8vIOiuvue9ruS4uuS4jeWPr+aemuS4vlxcbiAgICB9XFxuICB9KTtcXG5cXG4gIGxldCBzb3J0b2JqID0gW1xcbiAgICBmb250c3R5bGUoXFxcIuato+W6j1xcXCIsIHtcXG4gICAgICBjOiBcXFwiIzFBQUQxOVxcXCIsXFxuICAgICAgdGFnczogXFxcImJcXFwiXFxuICAgIH0pLFxcbiAgICBmb250c3R5bGUoXFxcIumAhuW6j1xcXCIsIHtcXG4gICAgICBjOiBcXFwiI0ZGMDAwMFxcXCIsXFxuICAgICAgdGFnczogXFxcImJcXFwiXFxuICAgIH0pXFxuICBdXFxuICAvL+aWueazlVxcblxcbiAgdmFyIHNvcnRpID0gZ2V0TXlWYXIoXFxcInNvcnRpXFxcIiwgXFxcIjBcXFwiK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tbMF0pO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgc3RpdGxlOiB0LFxcbiAgICAgICAgICB0aXRsZTogZm9udHN0eWxlKHQsIHtcXG4gICAgICAgICAgICB0YWdzOiBcXFwic21hbGxcXFwiXFxuICAgICAgICAgIH0pLFxcbiAgICAgICAgICBzdXJsOiB1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldLFxcbiAgICAgICAgICB1cmw6IGlzTm92ZWwgPyBcXFwiaGlrZXI6Ly9wYWdlL25vdmVsI2F1dG9QYWdlIyNyZWFkVGhlbWUjXFxcIiA6ICh1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldICsgcGxheUxhenkpLFxcbiAgICAgICAgICBjb2xfdHlwZTogY29sLFxcbiAgICAgICAgICBpbWc6IGltZyxcXG4gICAgICAgICAgLypleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgZXh0cmEsIHtcXG4gICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IGRlY29kZVVSSUNvbXBvbmVudChrWzFdKSxcXG4gICAgICAgICAgICBpZDoga1sxXSxcXG4gICAgICAgICAgICAvL2xpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXG4gICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgIH0pKi9cXG4gICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBmcm9tOiBmcm9tW2ldLFxcbiAgICAgICAgICAgIHNvdXJjZTogc291cmNlLFxcbiAgICAgICAgICAgIGlkOiB1aWQsXFxuICAgICAgICAgICAgYmxvY2tSdWxlczogWydiYi4qLnBuZycsICcuanBnJywgXFxcImhtXFxcXC5iYWlkdVxcXFwuY29tXFxcXC9obS5qc1xcXCJdLFxcbiAgICAgICAgICAgIHZpZGVvRXhjbHVkZVJ1bGVzOiBbJz91cmw9J10sXFxuICAgICAgICAgICAgbGluZVZ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bmZvOiB7XFxuICAgICAgICAgICAgICBib29rTmFtZTogaW5mby52b2RfbmFtZSwgLy/mvKvnlLvlkI3np7AsXFxuICAgICAgICAgICAgICBydWxlTmFtZTogTVlfUlVMRS50aXRsZSxcXG4gICAgICAgICAgICAgIGJvb2tUb3BQaWM6IGluZm8udm9kX3BpYyxcXG4gICAgICAgICAgICAgIHBhcnNlQ29kZTogZG93bmxvYWRsYXp5LFxcbiAgICAgICAgICAgICAgYm9va0lkOiBNWV9QQVJBTVMuc25hbWUsXFxuICAgICAgICAgICAgICB0eXBlOiBzdHlwZSA9PT0gXFxcIua8q+eUu1xcXCIgPyBcXFwiY29taWNcXFwiIDogXFxcIm5vdmVsXFxcIixcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGRlZmF1bHRWaWV3OiBcXFwiMVxcXCJcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICB0aXRsZTogXFxcIuacrOWcsOS5puaetlxcXCIsXFxuICAgICAgICAgIHVybDogJ2hpa2VyOi8vcGFnZS9Cb29rcmFjay52aWV3I25vUmVjb3JkSGlzdG9yeSM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYmcnVsZU5hbWU9JyArIE1ZX1JVTEUudGl0bGUsXFxuICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgIH1cXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgY29sX3R5cGU6ICdibGFua19ibG9jaydcXG4gICAgICAgIH0pO1xcbiAgICAgIH1cXG5cXG4gICAgICBwbGF5b2JqID0gJC5zcGxpdEFycmF5QnlSYW5nZXMocGxheW9iaiwgcGFnZXMpO1xcbiAgICA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QuYXNzaWduKHt9LCB0ZW1wLCB7XFxuICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyAocGFnZW51bSA9PSBpID8geC5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogeCksXFxuICAgICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKGkpID0+IHtcXG4gICAgICAgICAgICAgaWYgKGdldE15VmFyKFxcXCJwYWdlbnVtXFxcIikgPT0gaSkge1xcbiAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgIGRlbGV0ZUl0ZW1CeUNscyhcXFwicGxheWxpc3RcXFwiKTtcXG4gICAgICAgICAgICAgYWRkSXRlbUFmdGVyKFxcXCJwbGF5bGlzdHNcXFwiLCAkLnRlbXBfbGlzdFtpXSk7XFxuICAgICAgICAgICAgIGZpbmRJdGVtc0J5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpLmZvckVhY2goKHgsIGlpKSA9PiB7XFxuICAgICAgICAgICAgICAgbGV0IHRpdGxlID0geC50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgaWYgKGlpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlID0gJ+KAnOKAnOKAneKAnScgKyB0aXRsZS5mb250Y29sb3IoXFxcInJlZFxcXCIpO1xcbiAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICByZXR1cm4gXFxcImh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iAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcblxcbiAgICAgICAgcmV0dXJuICQoW1xcXCJISUtFUlxcXCIsIFxcXCJUWFRcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChtbywgaW5kZXhzLCBleHQpID0+IHtcXG4gICAgICAgICAgICBmdW5jdGlvbiB1cChydWxlcykge1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlcykpO1xcbiAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChsZW5ndGgsIHJ1bGUsIHR5cGUpID0+IFxcXCLmtbfpmJTop4bnlYzvvIxEUlBZ6Kej5p6Q77yM5YWx44CMXFxcIiArIGxlbmd0aCArIFxcXCLjgI3mnaHvvIzlpI3liLbmlbTmnaHlj6Pku6TmiZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHJ1bGUgKyBcXFwiJFxcXCIgKyB0eXBlICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0KVxcXCI7XFxuICAgICAgICAgICAgICAgIGlmIChnZXRQYXN0ZXMoKS5pbmNsdWRlcyhpbnB1dCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlcy5sZW5ndGgsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IFxcXCJoaWtlcjovL2ZpbGVzL3J1bGVzL0xveURnSWsvc2hhcmUvZHJweeino+aekOOAjFxcXCIgKyBydWxlcy5sZW5ndGggKyBcXFwi44CN5p2hLlxcXCIgKyAoaW5wdXQgPT09IFxcXCJISUtFUlxcXCIgPyBcXFwiaGlrZXJcXFwiIDogXFxcInR4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIGdldFBhc3MocnVsZXMubGVuZ3RoLCBydWxlYjY0LCBcXFwiYVxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVsZXM7XFxuICAgICAgICAgICAgaWYgKG1vID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICByZXR1cm4gdXAocnVsZXMpO1xcbiAgICAgICAgfSwgbW8sIGluZGV4cywgaW5kZXhjWzFdKTtcXG5cXG4gICAgfSwgbGVuZ3RoKSxcXG4gICAgY29sX3R5cGU6IFxcXCJpY29uX3NtYWxsXzRcXFwiLFxcbiAgICBwaWNfdXJsOiBcXFwiaGlrZXI6Ly9pbWFnZXMvaWNvbl9zaGFyZV9ncmVlblxcXCJcXG59KTtcXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIumHjee9rlxcXCIsXFxuICAgIHVybDogJChcXFwi5L2g56Gu5a6a6YeN572u77yfXFxcXG7or6Xmk43kvZzkvJrliKDpmaTnjrDmnInop6PmnpDvvIzmgaLlpI3oh6rluKbop6PmnpDjgIJcXFwiKS5jb25maXJtKChwYXRoKSA9PiB7XFxuICAgICAgICBkZWxldGVGaWxlKHBhdGgpO1xcbiAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xc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SB7XFxuICAgICAgICAgICAgICAgICAgICBmbGFnaSA9IGZsYWdpLmZpbHRlcih4ID0+IHggIT0gZik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoZmxhZ2kubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmbGFnaSA9IFtcXFwi5YWo6YOoXFxcIl1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGZsYWdpLnB1c2goZilcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiZmxhZ2lcXFwiLCBmbGFnaSk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgZilcXG4gICAgfSlcXG59KVxcbmZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHtcXG4gICAgbGV0IGl0ID0gYXJyW2ldO1xcblxcbiAgICBsZXQgZmxhZyA9IGl0LmZsYWcuc3BsaXQoXFxcInxcXFwiKTtcXG4gICAgaWYgKGZsYWdpLmxlbmd0aCA+IDAgJiYgIVtcXFwi5YWo6YOoXFxcIiwgXFxcIuW3suemgeeUqFxcXCJdLmluY2x1ZGVzKGZsYWdpWzBdKSkge1xcbiAgICAgICAgaWYgKCFmbGFnaS5ldmVyeShmID0+IGZsYWcuaW5jbHVkZXMoZikpKSB7XFxuICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICB9XFxuICAgIH1cXG4gICAgaWYgKFtcXFwi5bey56aB55SoXFxcIl0uaW5jbHVkZXMoZmxhZ2lbMF0pKSB7XFxuICAgICAgICBpZiAoIWl0Lmhhc093blByb3BlcnR5KFxcXCJmb3JiaWRkZW5cXFwiKSB8fCAhaXQuZm9yYmlkZ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cXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKClbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS51c2VyID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlKSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChuYW1lLCBydWxlLCB0eXBlKSA9PiBcXFwi5rW36ZiU6KeG55WM77yM44CMXFxcIiArIG5hbWUgKyBcXFwi44CNRFJQWeino+aekO+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yfXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliKDpmaRcXFwiICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBhcnJbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICBydWxlLmZvcmJpZGRlbiA9ICFydWxlLmZvcmJpZGRlbjtcXG4g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wICsgXFxcIuKAmeKAmVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgb2JqID0ge307XFxuICAgICAgICBiYWNrKCk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl6ZSZ6K+vXFxcIik7XFxuICAgIH1cXG59IGVsc2UgaWYgKGluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgIG9iaiA9IGFycltpbmRleF07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi57yW6L6R6Kej5p6QOlxcXCIgKyBvYmoubmFtZSk7XFxufSBlbHNlIHtcXG4gICAgb2JqID0ge1xcbiAgICAgICAgcnVuVHlwZTogXFxcIldFQlxcXCIsXFxuICAgICAgICBtZXRob2Q6IFxcXCJHRVRcXFwiXFxuICAgIH07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi5paw5bu66Kej5p6QXFxcIik7XFxufVxcblxcbmQucHVzaCh7XFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5ZCN5a2XKOW/heWhqylcXFwiLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgb25DaGFuZ2U6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHB1dE15VmFyKFxcXCJwc19uYW1lXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBkZWZhdWx0VmFsdWU6IG9iai5uYW1lLFxcbiAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICB9XFxufSk7XFxuXFxuXFxuZC5w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Vyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAgICAgIGpzXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLkv53lrZhcXFwiLFxcbiAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGluZGV4LCBpc0ltcG9ydCkgPT4ge1xcbiAgICAgICAgbGV0IG5hbWUgPSBnZXRNeVZhcihcXFwicHNfbmFtZVxcXCIsIFxcXCJcXFwiKS50cmltKCk7XFxuICAgICAgICBpZiAoIW5hbWUpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5ZCN5a2X5b6X5pyJ5LiA5Liq5ZCnXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCB1cmwgPSBnZXRNeVZhcihcXFwicHNfdXJsXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghdXJsKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZmxhZyA9IGdldE15VmFyKFxcXCJwc19mbGFnXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgaWYgKCFmbGFnKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ino+aekOWcsOWdgOagh+ivhuS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgaGVhZGVycyA9IGdldE15VmFyKFxcXCJwc19oZWFkZXJzXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIGlmKHR5cGVvZiBoZWFkZXJzIT09XFxcIm9iamVjdFxcXCIpIHRocm93IG5ldyBFcnJvcihcXFwi6ZSZ6K+v57G75Z6L77yM5b+F6aG75Li6T2JqZWN0XFxcIik7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICBsZXQganNvblBhdGggPSBnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiICYmICFqc29uUGF0aCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU09O5qih5byP5LiL5b+F6aG75aGranNvblBhdGhcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09PSBcXFwiSlNcXFwiICYmICFqcykge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgb2JqMSA9IHtcXG4gICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAganNcXG4gICAgICAgIH07XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBvYmoxLmdyb3VwO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgbmFtZXkgPSBhcnJbaW5kZXhdLm5hbWU7XFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG9iajEgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIG9iajEpO1xcbiAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIG9iajEpO1xcbiAgICAgICAgfVxcbiAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L+d5a2Y5oiQ5YqfXFxcIjtcXG4gICAgfSwgaW5kZXgsIGlzSW1wb3J0KSxcXG4gICAgY29sX3R5cGU6IFxcXCJ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AgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ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29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgbGV0IHJ1bGVzID0gW107XFxuICAgIGxldCBjb3VudCA9IDA7XFxuICAgIGxldCBuYW1lcyA9IFtdO1xcbiAgICBpZiAobGlzdC5sZW5ndGggPT09IDApIHJldHVybiBcXFwidG9hc3Q6Ly/lj6/og73liKDlupPkuoZcXFwiO1xcbiAgICBmb3IgKGxldCBpdCBvZiBsaXN0KSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCBuYW1lID0gaXQubmFtZTtcXG4gICAgICAgICAgICBsZXQgc3BhdGggPSBpdC5wYXRoO1xcbiAgICAgICAgICAgIGlmICghbmFtZS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIG5hbWUgPSBuYW1lLnNsaWNlKDAsIG5hbWUubGFzdEluZGV4T2YoXFxcIi5cXFwiKSk7XFxuICAgICAgICAgICAgbGV0IHJ1bGUgPSBmZXRjaChgaHR0cHM6Ly9yYXcuZ2l0bWlycm9yLmNvbS8ke3JvcGV9L21hc3Rlci8ke3NwYXRofWApO1xcbiAgICAgICAgICAgIGlmICghKCghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSAmJiAhZmlsZUV4aXN0KHBhdGggKyBpdC5uYW1lKSkpIHtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAgICAgICAgICdhcGknOiAnLi4vbGlicy9kcnB5Mi5qcycsXFxuICAgICAgICAgICAgICAgICAgICAnc2VhcmNoYWJsZS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AgICAgcnVsZSA9IHJlcXVlc3Qoam9pblVybCh1cmwsIGl0LmV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXCIuL1xcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QocGF0aCArIG5hbWUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgbmFtZXMucHVzaChuYW1lKTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBpKys7XFxuICAgIH1cXG4gICAgZGVsZXRlbG9zZShuYW1lcywgcGF0aCk7XFxuICAgIHdyaXRlRmlsZShwYXRoICsgXFxcImluZGV4Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeShqc29uKSk7XFxuICAgIHJldHVybiBcXFwidG9hc3Q6Ly/miJDlip/mm7TmlrBcXFwiICsgY291bnQgKyBcXFwi5LiqXFxcIjtcXG59XFxuJC5leHBvcnRzLnBhcnNlVXJsID0gZnVuY3Rpb24gKHVybCwgcGF0aCkge1xcbiAgICBwYXRoID0gYmFzZTY0RGVjb2RlKHBhdGgpO1xcbiAgICBwYXRoID0gcGF0aC5lbmRzV2l0aChcXFwiL1xcXCIpID8gcGF0aCA6IHBhdGggKyBcXFwiL1xcXCI7XFxuICAgIHRyeSB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aW5nKGZldGNoKGNvbmZpZy5wYXRoKSB8fCBcXFwie31cXFwiKSk7XFxuICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8ICFqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIuS7jue9kee7nOiOt+WPlueahOmFjee9ruaWh+S7tuS4uuepuu+8jOivt+ajgOafpee9kee7nFxcXCIpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBzb3VyY2VMaXN0ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcyk7XFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFwiaW5kZXhcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgZmlsZSA9IHZvaWQgMDtcXG4gICAgICAgIGxldCBjdXJyZW50U291cmNlLCBzZWFyY2hBbGxvdztcXG4gICAgICAgIGlmIChjb25maWcuY0tleSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgIC8vY29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBKU09OLnBhcnNlKGZldGNoKHNlYXJ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4gICAgICAgICAgICAndHlwZSc6IDMsXFxuICAgICAgICAgICAgJ3NlYXJjaGFibGUnOiAxLFxcbiAgICAgICAgICAgICdxdWlja1NlYXJjaCc6IDEsXFxuICAgICAgICAgICAgJ2ZpbHRlcmFibGUnOiAxLFxcbiAgICAgICAgICAgICdleHQnOiBgJHtwYXRofWAsXFxuICAgICAgICB9KTtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IG1hcHBpbmcgPSBnZXRMb2FjbE1hcHBpbmcoU3RyaW5nKGRpckZpbGUuZ2V0UGF0aCgpKSk7XFxuXFxuICAgICAgICBpZiAobWFwcGluZy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBtYXBwaW5nKSB7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IHJ1bGVzLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gaXQua2V5KTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkgY29udGludWU7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtID0gcnVsZXNbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UoaW5kZXgsIDAsIE9iamVjdC5hc3NpZ24oe30sIGl0ZW0sIHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke2l0LnRva2V5fWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke2l0LnRva2V5fWAsXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogaXRlbS5leHQgKyBcXFwiP1xcXCIgKyBpdC5wYXJhbXMsXFxuICAgICAgICAgICAgICAgICAgICBkZWw6IHZvaWQgMFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIGl0ZW0uZGVsID0gdHJ1ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcnVsZXMgPSBydWxlcy5maWx0ZXIodiA9PiAhdi5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gcGF0aC5zdGFydHNXaXRoKFxcXCJmaWxlOi8vXFxcIikgPyBwYXRoIDogKFxcXCJmaWxlOi8vXFxcIiArIHBhdGgpO1xcbiAgICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoKHBhdGgpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgcmVhZERpcihwYXRoKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuYW1lcyA9IFtdO1xcbiAgICAgICAgICAgICAgICBsZXQgZmlsZSA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aC5yZXBsYWNlKFxcXCJmaWxlOi8vXFxcIixcXFwiXFxcIikpO1xcbiAgICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgICAgaWYoIShmaWxlLmV4aXN0cygpJiZmaWxlLmlzRGlyZWN0b3J5KCkpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvcihsZXQgaXQgb2YgZmlsZS5saXN0RmlsZXMoKSl7XFxuICAgICAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKFN0cmluZyhpdC5nZXROYW1lKCkpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBkaXJuYW1lKHBhKXtcXG4gICAgICAgICAgICAgICAgbGV0IHBhdGggPSBqb2luVXJsKGpzUGF0aCwgcGEpO1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGZpbGUgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcbiAgICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgICAgaWYoIShmaWxlLmV4aXN0cygpJiZmaWxlLmlzRGlyZWN0b3J5KCkpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvcihsZXQgaXQgb2YgZGlyRmlsZS5saXN0RmlsZXMoKSl7XFxuICAgICAgICAgICAgICAgICAgICBpZihpdC5pc0RpcmVjdG9yeSl7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZXMucHVzaChTdHJpbmcoaXQuZ2V0TmFtZSgpKSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhdGhzO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgc3RhdCgpe1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgbG9nOiBsb2csXFxuICAgICAgICBwYXRoOiBqc1BhdGgsXFxuICAgICAgICBwYXRoX2Rpcjogam9pblVybChqc1BhdGgsIFxcXCIuL1xcXCIpXFxuICAgIH0pO1xcbiAgICBsZXQganNvblRleHQ9bWFpbigpO1xcbiAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoanNvblRleHQpO1xcbiAgICBcXG4gICAgaWYoQXJyYXkuaXNBcnJheShqc29uKSl7XFxuICAgICAgICByZXR1cm4gZmlsdGVyT3RoZXIoanNvbik7XFxuICAgIH1lbHNlIGlmKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykmJmpzb24uc2l0ZXMubGVuZ3RoKXtcXG4gICAgICAgIHdyaXRlRmlsZShqb2luVXJsKGpzUGF0aCwgXFxcIi4vaW5kZXguanNvblxcXCIpLCBqc29uVGV4dCk7XFxuICAgICAgICByZXR1cm4gZmlsdGVyT3RoZXIoanNvbi5zaXRlc3x8W10pO1xcbiAgICB9XFxufVxcblxcbmZ1bmN0aW9uIGdlbmVyYXRlQ29uZmlnQnlHaXRodWIodXJsKSB7XFxuICAgIC8vdXJsPXVybC5yZXBsYWNlKC8oI0dJVEhVQiMpJC8sXFxcIlxcXCIpO1xcbiAgICBsZXQgcm9wZSA9IHVybC5zcGxpdChcXFwiL1xcXCIpLnNsaWNl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ICAgICBjb250ZW50OiBcXFwi6K+m57uGXFxcIixcXG4gICAgICAgICAgICBvcHRpb25zOiBbXFxuICAgICAgICAgICAgICAgIFxcXCLnrKzkuIDnqboo5ZCN56ewKTrmlrnkvr/kuIvmrKHmib7liLBcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwi56ys5LqM56m6KOi3r+W+hClb5aGr5pys5Zyw57Si5byV5Zyw5Z2AXTrpgInmi6lKU09OL1VSTOmAiemhue+8jOeCueWHu+aXgei+ueeahOmAieaLqeWPr+S7pea1j+iniOacrOWcsOaWh+S7tumAieaLqeacrOWcsOWMheeahC5qc29u57Si5byV5paH5Lu25Y2z5Y+v44CCXFxcXG4o5rOo5oSP77ya5L2/55So5q2k56eN5pa55byP77yM5Zyo5pys5Zyw5paH5Lu25aS55YaF5paw5aKe5oiW5Yig6ZmkLmpz5rqQ5pe26ZyA6KaB6Ieq6KGM6YWN572uLmpzb27mlofku7YpXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIuesrOS6jOepuijot6/lvoQpW+Whq+acrOWhq+i/nOeoi+WcsOWdgF0655u05o6l5aGr5YaZ6L+c56iL6ZO+5o6l5Y2z5Y+v5LiA6Iis5piv5LulaHR0cOW8gOWktC5qc29u57uT5bC+77yM5Lmf5Y+v5Y+v5Lul6L6T5YWlZ2l0aHVi5LuT5bqT55qE5paH5Lu25aS55Zyw5Z2A44CC5q2k56eN5pa55byP5Y+v5Lul5L+d5oyB5LiO6L+c56iL6YWN572u6ICF5ZCM5q2l5pu05paw77yM5L2G5LiN5aaC5pys5Zyw5b+r44CCXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIuesrOS6jOepuijot6/lvoQpW+Whq+acrOWcsOaWh+S7tuWkueWcsOWdgF066YCJ5oup5paH5Lu25aS56YCJ6aG577yM5Y+v5Lul55u05o6l6L6T5YWlanPmupDmiYDlnKgj5paH5Lu25aS5ISEhI+eahOi3r+W+hO+8jOS5n+WPr+S7peeCueWHu+aXgei+uemAieaLqea1j+iniOacrOWcsOi3r+W+hOmAieaLqSPmlofku7blpLkhISEj77yM5L2/55So6K+l56eN5pa55rOV77yM5Zyo5paH5Lu25aS55paw5aKe5oiW5Yig6Zmk5rqQ5pe277yM5LiN55So5omL5Yqo6YWN572uLmpzb27mlofku7bvvIzoh6rliqjor7vlj5bjgIIo5rOo5oSP77ya6ZyA6KaB5Yi35paw6YWN572u5oiW6YeN5ZCv6L2v5Lu25omN6IO96K+75Y+WKVxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCJbUSZBXeS4uuS7gOS5iOiuoumYhemTvuaOpeacieW+iOWkmua6kO+8jOWNtOWPquivhuWIq+WIsOS6huWHoOS4qua6kO+8n1xcXFxu5pys5bCP56iL5bqP5Y+q5pSv5oyB6YGT6ZW/55qEZHJweVtqc13op4bpopHmupDvvIzlhbbku5bkuIDmpoLkuI3mlK/mjIHjgILlm6DmraTkvJroh6rliqjov4fmu6Tlhbbku5bmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwiW1EmQV3miZPnrpfmlK/mjIHlhbbku5Z0dmJveOeahOa6kOWQl++8n+S4jeaUr+aMgeS4jeiAg+iZkeOAguivt+eci+WQjeWtl0RycHlIaWtlcu+8jOWPquaUr+aMgWRycHnvvIzopoHnlKjlhbbku5bmupDvvIzlu7rorq7liKDpmaTmnKzlsI/nqIvluo/vvIzljrvnlKjlkITnp43lo7PlrZDjgIJcXFwiXFxuICAgICAgICAgICAgXVxcbiAgICAgICAgfSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICB9KSxcXG59KTtcXG5sYXlvdXQucHVzaCh7XFxuICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICBkZXNjOiBcXFwi5ZCN56ewKOW/heWhqylcXFwiLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogZ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Wxlcy9cXFwiKSwgXFxcIi4uL1xcXCIucmVwZWF0KDUpKS5zbGljZSg3KTtcXG5cXG5pZiAoc2VsZWN0X21vZGUgPT0gXFxcIjBcXFwiKSB7XFxuICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi6YCJ5oupXFxcIixcXG4gICAgICAgIHVybDogSlNPTi5zdHJpbmdpZnkoZi5maWxlU2VsZWN0aW9uVXJpKHtcXG4gICAgICAgICAgICBjYWxsYmFjazogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCB0YXJnZXQgPSBmaW5kSXRlbShcXFwiZHJweUhpa2VyX2NvbmZpZ19wYXRoXFxcIikuZXh0cmE7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHRhcmdldCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHJvb3REaXJQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIHBhdHRlcm46IDAsXFxuICAgICAgICAgICAgZmlsZVR5cGU6IFxcXCIuanNvbnwuanNcXFwiLFxcbiAgICAgICAgfSkpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgICBkZXNjOiBcXFwi6Lev5b6EKFVSTC9KU09OL0pTL0dpdGh1YilcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBkZWZhdWx0VmFsdWU6IFxcXCJcXFwiLFxcbiAgICAgICAgICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICBpZDogXFxcImRycHlIaWtlcl9jb25maWdfcGF0aFxcXCJcXG4gICAgICAgIH1cXG4gICAgfSk7XFxufVxcbmlmIChzZWxlY3RfbW9kZSA9PSBcXFwiMVxcXCIpIHtcXG4gICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLpgInmi6lcXFwiLFxcbiAgICAgICAgdXJsOiBKU09OLnN0cmluZ2lmeShmLmZpbGVTZWxlY3Rpb25Vcmkoe1xcbiAgICAgICAgICAgIGNhbGxiYWNrOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IHRhcmdldCA9IGZpbmRJdGVtKFxcXCJkcnB5SGlrZXJfY29uZmlnX2ZvbGRlclxcXCIpLmV4dHJhO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJkcnB5SGlrZXJfY29uZmlnX2ZvbGRlclxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHRhcmdldCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogUEFUSFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgIHJvb3REaXJQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIGluaXRpYWxQYXRoOiBwYXRoLFxcbiAgICAgICAgICAgIHBhdHRlcm46IDEsXFxuICAgICAgICAgICAgLy9maWxlVHlwZTogXFxcIi5qc29uX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SA/IChcXFwiZmlsZTovL1xcXCIgKyBwYXRoKSA6IHBhdGg7XFxuICAgICAgICAvL2xvZyhwYXRoKVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBjb25maWdjID0ge1xcbiAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgaWYgKHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyhjb25maWdjKSkge1xcbiAgICAgICAgICAgICAgICBjb2JqLmNvbmZpZ3MucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibm9fbG9hZGluZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICBzYXZlRmlsZShjb2JqLnBhdGgsIEpTT04uc3RyaW5naWZ5KGNvYmouY29uZmlncykpO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmNsZWFyKCk7XFxuICAgICAgICAgICAgICAgIGJhY2soZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcIkNoYW5nZVNvdXJjZVBvcFxcXCIpLnNob3coMTAwKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/phY3nva7mlofku7bmnInor69cXFwiO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgfSBmaW5hbGx5IHtcXG4gICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgfVxcbiAgICB9LCBjb25maWdzX29iaiksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxufSk7XFxuXFxuaWYgKHBhdGhjb25maWdzLmxlbmd0aCkge1xcbiAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyBcXFwiPHNtYWxsPuWOhuWPsumFjee9ruiusOW9lSDngrnmiJHov5vooYzphY3nva7mo4Dpqow8L3NtYWxsPlxcXCIsXFxuICAgICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHApID0+IHtcXG4gICAgICAgICAgICAvL2xvZyhwKVxcbiAgICAgICAgICAgIGZ1bmN0aW9uIHVuaXF1ZShhcnIpIHtcXG4gICAgICAgICAgICAgICAgY29uc3QgcmVzID0gbmV3IE1hcCgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gYXJyLmZpbHRlcigoYSkgPT4gIXJlcy5oYXMoYSkgJiYgcmVzLnNldChhLCAxKSlcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdmFyIHJlc3VsdHMgPSBbXTtcXG4gICAgICAgICAgICBpZiAocC5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5peg5Zyw5Z2AXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGlzdCA9IHAubWFwKHggPT4geC5wYXRoKTtcXG4gICAgICAgICAgICB2YXIgdGFzayA9IGZ1bmN0aW9uKG9iaikge1xcbiAgICAgICAgICAgICAgICBsZXQgcyA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgICAgIGxldCBqc0ZpbGVzID0gW107XFxuICAgICAgICAgICAgICAgIGxldCBjb3VudCA9IDA7XFxuXFxuICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGZpbHRlck90aGVyKGxpc3QpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBsaXN0LmZpbHRlcihpdCA9PiBTdHJpbmcoaXQuYXBpKS5pbmNsdWRlcyhcXFwiZHJweTIubWluLmpzXFxcIikgfHwgU3RyaW5nKGl0LmFwaSkuaW5jbHVkZXMoXFxcImRycHkyLmpzXFxcIikpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKG9iai51cmwuc3RhcnRzV2l0aChcXFwiZmlsZTpcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IGNvZGUgPSBcXFwibm9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGggPSBvYmoudXJsLnJlcGxhY2UoXFxcImZpbGU6Ly9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZGlyID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChkaXIuaXNEaXJlY3RvcnkoKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmbGlzdCA9IGRpci5saXN0RmlsZXMoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBmIG9mIGZsaXN0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZi5pc0ZpbGUoKSAmJiBmLmdldE5hbWUoKS50b0xvd2VyQ2FzZSgpLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGpzb24uc2l0ZXMpIHx8IGpzb24uc2l0ZXMubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0ganNGaWxlcy5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHRpbWU6IChEYXRlLm5vdygpIC0gcyksXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBvYmoudXJsLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2RlOiBjb2RlLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBvYmouaVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHZhciBqID0gSlNPTi5wYXJzZShmZXRjaChvYmoudXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICB3aXRoSGVhZGVyczogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgIHRpbWVvdXQ6IDUwMDAsXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGUgLSBzO1xcbiAgICAgICAgICAgICAgICBpZiAob2JqLnVybC5pbmNsdWRlcyhcXFwiZ2l0aHViLmNvbVxcXCIpICYmIGouc3RhdHVzQ29kZSA9PSAyMDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSBqLmJvZHk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGpzb24gPSBKU09OLnBhcnNlKHBkZmgoaHRtbCwgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gbGlzdC5maWx0ZXIoeCA9PiB4Lm5hbWUuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKS5sZW5ndGg7XFxuICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIHt9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZSh0b0NvcnJlY3RKU09OU3RyaW5nKGouYm9keSkgfHwgXFxcInt9XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fVxcblxcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgICAgICAgICAgdGltZTogYyxcXG4gICAgICAgICAgICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgICAgICAgICBjb2RlOiBqLnN0YXR1c0NvZGUsXFxuICAgICAgICAgICAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIGxldCB0YXNrcyA9IGxpc3QubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgIGkgPSBpICsgMTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICAgICAgICAgIGZ1bmM6IHRhc2ssXFxuICAgICAgICAgICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogeCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBpOiBpIC0gMSxcXG4gICAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgICAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICAgICAgICAgIGZ1bmM6IGZ1bmN0aW9uKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxuICAgICAgICAgICAgICAgICAgICBvYmoucmVzdWx0cy5wdXNoKHRhc2tSZXN1bHQpXFxuICAgICAgICAgICAgICAgICAgICBjb3VudCA9IGNvdW50IC0gMTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5qOA5rWL5LitLi4u5Ymp5L2Z5Zyw5Z2A77yaXFxcIiArIGNvdW50KVxcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICBwYXJhbToge1xcbiAgICAgICAgICAgICAgICAgICAgaGk6ICdjY2MnLFxcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0czogcmVzdWx0c1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgc3VjY2Vzcyk7XFxuICAgICAgICAgICAgLy9sb2cocmVzdWx0cylcXG4gICAgICAgICAgICByZXN1bHRzID0gcmVzdWx0cy5maWx0ZXIoZiA9PiBmKTtcXG4gICAgICAgICAgICByZXN1bHRzLmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBmaW5kSXRlbShcXFwicGF0aFxcXCIgKyB4LmluZGV4KTtcXG4gICAgICAgICAgICAgICAgbGV0IHJlZ2V4ID0gLyjlkI3np7A6Lio/KShcXFxccyspP1xcXFxuL2c7XFxuICAgICAgICAgICAgICAgIGxldCB0aXRsZSA9IFxcXCLlkI3np7A6XFxcIiArIHBbeC5pbmRleF0ubmFtZSArIFxcXCIgXFxcIjtcXG4gICAgICAgICAgICAgICAgbGV0IHVybCA9IHBbeC5pbmRleF0ucGF0aDtcXG4gICAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQgY291bnQgPSB4LmNvdW50ICE9IDAgPyBcXFwiIOa6kOaVsOmHjzpcXFwiICsgeC5jb3VudCA6IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBpZiAoL25vLy50ZXN0KHguY29kZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YWN572u5pyJ6K+vXFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoL14oLTF8MHw0MDQpLy50ZXN0KHguY29kZSkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi5peg5rOV6K6/6ZeuXFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoL14yMDAvLnRlc3QoeC5jb2RlKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbXNnID0gaXRlbS50aXRsZS5yZXBsYWNlKHJlZ2V4LCB0aXRsZSArIFxcXCLpgJrorq/mraPluLhcXFwiLmZvbnRjb2xvcihcXFwiIzNDQjM3MVxcXCIpICsgXFxcIiAg5bu26L+fOlxcXCIgKyB4LnRpbWUgKyBjb3VudCArIFxcXCJcXFxcblxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgLy91cmwgPSBpdGVtLnVybDtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIG1zZyA9IGl0ZW0udGl0bGUucmVwbGFjZShyZWdleCwgdGl0bGUgKyBcXFwi6YWN572u5q2j56GuXFxcIi5mb250Y29sb3IoXFxcIiMzQ0IzNzFcXFwiKSArIGNvdW50ICsgXFxcIlxcXFxuXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAvL3VybCA9IGl0ZW0udXJsO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgICAgICAgdGl0bGU6IG1zZyxcXG4gICAgICAgICAgICAgICAgICAgIC8vdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgICAgfSwgcGF0aGNvbmZpZ3MpLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIlxcbiAgICB9KTtcXG4gICAgcGF0aGNvbmZpZ3MuZm9yRWFjaCgoaXRlbSwgaSkgPT4ge1xcbiAgICAgICAgbGV0IGxvbmdDID0gW3tcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWQjeensFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0sIHAsIGMpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBjLmZpbmRJbmRleCh4ID0+IHgubmFtZSA9PSBpdGVtLm5hbWUpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoY1tpXS5uYW1lLCBcXFwi6L6T5YWl5paw5ZCN56ewXFxcIikuaW5wdXQoKGMsIHAsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjW2ldLm5hbWUgPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzYXZlRmlsZShwLCBKU09OLnN0cmluZ2lmeShjKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0sIGMsIHAsIGkpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBpdGVtLCBjcGF0aCwgcGF0aGNvbmZpZ3MpXFxuICAgICAgICB9LCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLot6/lvoRcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtLCBwLCBjKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gYy5maW5kSW5kZXgoeCA9PiB4Lm5hbWUgPT0gaXRlbS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgaWYgKGkgIT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKGNbaV0ucGF0aCwgXFxcIui+k+WFpeaWsOi3r+W+hFxcXCIpLmlucHV0KChjLCBwLCBpKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY1tpXS5wYXRoID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZUZpbGUocCwgSlNPTi5zdHJpbmdpZnkoYykpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgICAgICB9LCBjLCBwLCBpKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgaXRlbSwgY3BhdGgsIHBhdGhjb25maWdzKVxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5Yig6ZmkXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoaXRlbSwgcCwgYykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGMuZmluZEluZGV4KHggPT4geC5uYW1lID09IGl0ZW0ubmFtZSk7XFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBjLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVGaWxlKHAsIEpTT04uc3RyaW5naWZ5KGMpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBpdGVtLCBjcGF0aCwgcGF0aGNvbmZpZ3MpXFxuICAgICAgICB9XTtcXG4gICAgICAgIGlmIChpdGVtLnBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgbG9uZ0MucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K6/6ZeuXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLnBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ3ZWI6Ly9cXFwiICsgaXRlbS5wYXRoO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpdGVtKVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICB9XFxuICAgICAgICBsZXQgY3VycmVudCA9IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKGN1cnJlbnRjb25maWcgJiYgY3VycmVudGNvbmZpZy5oYXNPd25Qcm9wZXJ0eShcXFwicGF0aFxcXCIpKSB7XFxuICAgICAgICAgICAgaWYgKGl0ZW0ucGF0aCA9PSBjdXJyZW50Y29uZmlnLnBhdGgpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudCA9IFxcXCLinqHvuI9cXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxheW91dC5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyBcXFwiPHNtYWxsPlxcXCIgKyBjdXJyZW50ICsgXFxcIuWQjeensDpcXFwiICsgaXRlbS5uYW1lICsgXFxcIlxcXFxu6Lev5b6EOlxcXCIgKyBpdGVtLnBhdGggKyBcXFwiPC9zbWFsbD5cXFwiLFxcbiAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZShpdGVtID0+IHtcXG4gICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJub19sb2FkaW5nXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgbmFtZVxcbiAgICAgICAgICAgICAgICB9ID0gaXRlbTtcXG4gICAgICAgICAgICAgICAgaWYgKHBhdGguc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudENvbmZpZyh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgfSkpIHtcXG5cXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBEcnB5TWFuYWdlLmNsZWFyKCk7XFxuICAgICAgICAgICAgICAgICAgICBiYWNrKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiQ2hhbmdlU291cmNlUG9wXFxcIikuc2hvdygxMDApO1xcbiAgICAgICAgICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WIh+aNouWksei0pVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCBpdGVtKSxcXG4gICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgaWQ6ICdwYXRoJyArIGksXFxuICAgICAgICAgICAgICAgIGxvbmdDbGljazogbG9uZ0NcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG4gICAgfSk7XFxufVxcblxcblxcbnNldFJlc3VsdChsYXlvdXQpO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi5o2i5rqQ5by556qXXCIsXCJwYXRoXCI6XCJDaGFuZ2VTb3VyY2VQb3BcIixcInJ1bGVcIjpcIiQuZXhwb3J0cy5zaG93ID0gZnVuY3Rpb24odGltZSkge1xcbiAgICBpZiAodGltZSkge1xcbiAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCh0aW1lKTtcXG4gICAgfVxcbiAgICBjb25zdCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFx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ICAgICAgICAgICAgICAgIGZsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBcXFwiXFxcIixcXG4gICAgICAgICAgICBjbGljayhzLCBtYW5hZ2UpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHRhZ0NsYXNzZXMgPSBydW50aW1lQ29uZmlnLmdldFRhZ0NsYXNzZXMoKTtcXG4gICAgICAgICAgICAgICAgaWYgKCF0YWdDbGFzc2VzLmxlbmd0aCkgcmV0dXJuIFxcXCJ0b2FzdDovL+W9k+WJjemFjee9ruayoeaciVRBR+WTpuOAglxcXCI7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLnNlbGVjdENlbnRlcih7XFxuICAgICAgICAgICAgICAgICAgICBvcHRpb25zOiB0YWdDbGFzc2VzLFxcbiAgICAgICAgICAgICAgICAgICAgY29sdW1uczogMyxcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwiVEFHW1xcXCIgKyB0YWdDbGFzc2VzLmxlbmd0aCArIFxcXCJdXFxcIixcXG4gICAgICAgICAgICAgICAgICAgIGNsaWNrKGEpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpbnB1dEJveC5zZXREZWZhdWx0VmFsdWUoXFxcIltcXFwiICsgYSArIFxcXCJdXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiB0cnVlXFxuICAgICAgICB9KSksXFxuICAgICAgICBsb25nQ2xpY2socywgaSkge1xcbiAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLliIbkuqvop4bpopHmupBcXFwiLFxcbiAgICAgICAgICAgICAgICBvcHRpb25zOiBbXFxcIkpT5paH5Lu25YiG5LqrXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSxcXG4gICAgICAgICAgICAgICAgY29sOiAyLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZyhuYW1lID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBzb3VyY2VzLmZpbmQodiA9PiB2Lm5hbWUgPT0gbmFtZSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHBuYW1lID0gcGF0aC5zcGxpdChcXFwiL1xcXCIpLmF0KC0xKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gZmV0Y2gocGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZW5jb2RlTW9kZSA9IGdldEl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChlbmNvZGVNb2RlICYmIC92YXIgcnVsZXxbXFxcXHU0RTAwLVxcXFx1OUZBNV0rfGZ1bmN0aW9ufGxldCB8dmFyIHxjb25zdCB8XFxcXCh8XFxcXCl8XFxcInwnLy50ZXN0KHJ1bGUpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kZU1vZGUgPT09IFxcXCJHemlwXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgR1pJUCA9ICQucmVxdWlyZShcXFwiR1pJUFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gR1pJUC56aXAocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChlbmNvZGVNb2RlID09PSBcXFwiQmFzZTY0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYmFzZTY0RW5jb2RlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZW5jb2RlTW9kZSA9PT0gXFxcIkFFU1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQ3J5cHRvVXRpbCA9ICQucmVxdWlyZShcXFwiaGlrZXI6Ly9hc3NldHMvY3J5cHRvLWphdmEuanNcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGtleSA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUhleChcXFwiNjg2QTY0Njg2RTc4MEEwQTBBMEEwQTBBMEEwQTBBMEFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGl2ID0gQ3J5cHRvVXRpbC5EYXRhLnBhcnNlSGV4KFxcXCI2NDdBNzk3OTY0NzMwQTBBMEEwQTBBMEEwQTBBMEEwQVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGV4dERhdGEgPSBDcnlwdG9VdGlsLkRhdGEucGFyc2VVVEY4KHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZW5jcnlwdGVkMCA9IENyeXB0b1V0aWwuQUVTLmVuY3J5cHQodGV4dERhdGEsIGtleSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogXFxcIkFFUy9DQkMvUEtDUzdQYWRkaW5nXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl2OiBpdlxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcnVsZSA9IGVuY3J5cHRlZDAudG9CYXNlNjQoX2Jhc2U2NC5OT19XUkFQKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXJ1bGUpIHJldHVybiBcXFwidG9hc3Q6Ly/ojrflj5blpLHotKVcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE1ZX0lOREVYID09PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9cXFwiICsgcG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9oaWtlcjovL2ZpbGVzL19jYWNoZS9cXFwiICsgcG5hbWU7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1cmwgPSBzaGFyZVBhc3RlKGJhc2U2NEVuY29kZShydWxlKSwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL+a1t+mYlOinhueVjO+8jERSUFnop4bpopHmupDjgIxcXFwiICsgbmFtZSArIFxcXCLjgI3lpI3liLbmlbTmnaHlj6Pku6TmiZPlvIDova/ku7blsLHkvJroh6rliqjlr7zlhaUkXFxcIiArIHVybCArIFxcXCIkXFxcIiArIHBuYW1lICsgXFxcIkBpbXBvcnQ9anM6JC5yZXF1aXJlKCdpbXBvcnQ/cnVsZT0nK1xcXCIgKyBKU09OLnN0cmluZ2lmeShNWV9SVUxFLnRpdGxlKSArIFxcXCIpKGlucHV0LCB0cnVlKVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIHMucmVwbGFjZSgvW+KAmeKAmF0vZywgXFxcIlxcXCIpKVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfSxcXG4gICAgICAgIGNsaWNrKHMsIGksIG1hbmFnZSkge1xcbiAgICAgICAgICAgIHBvcC5kaXNtaXNzKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwibm9fbG9hZGluZ1xcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgLy8gbWFuYWdlLmxpc3QuZm9yRWFjaCgodiwgaWkpID0+IChcXG4gICAgICAgICAgICAvLyAgIG1hbmFnZS5saXN0W2lpXSA9IGkgPT09IGlpID8gXFxcIuKAmOKAmFxcXCIgKyBuYW1lc1tpaV0gKyBcXFwi4oCZ4oCZXFxcIiA6IG5hbWVzW2lpXS5yZXBsYWNlKC9b4oCZ4oCYXS9nLCBcXFwiXFxcIilcXG4gICAgICAgICAgICAvLyApKTtcXG4gICAgICAgICAgICBsZXQgbmFtZSA9IG1hbmFnZS5saXN0W2ldLnJlcGxhY2UoL1vigJnigJhdL2csIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAobmFtZSA9PSBzb3VyY2UubmFtZSkge1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBzb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICBsZXQga2V5ID0gc291cmNlcy5maW5kKHYgPT4gdi5uYW1lID09IG5hbWUpLmtleTtcXG5cXG4gICAgICAgICAgICB1c2luZ1NvcnQuc2V0KG5hbWUpO1xcblxcbiAgICAgICAgICAgIC8vbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIGxldCBzb3VyY2VOYW1lTGlzdCA9I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xcXCLmlLnlj5jmoLflvI9cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3BlbiA9IHNwZW4gPT0gMyA/IDEgOiAoc3BlbiA9PSAyID8gMyA6IDIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2VDb2x1bW5zKHNwZW4pO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLlgJLluo9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnJldmVyc2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lcy5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLoh6rnhLbmjpLluo9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBuYXR1cmFsID0gZ2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAobmF0dXJhbCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYXR1cmFsU29ydChsaXN0KS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzbmFtZS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBuYXR1cmFsID8gXFxcIlxcXCIgOiBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLkvb/nlKjmjpLluo9cXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1c2luZ3N0ID0gZ2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodXNpbmdzdCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIHVzaW5nc3QgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHMgPT0gXFxcIuWIt+aWsOmFjee9rlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBhcnJheURpZmZlcmVuY2UoYXJyMSwgYXJyMikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKGFycjIubWFwKGl0ZW0gPT4gW2l0ZW0ua2V5LCBpdGVtXSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5maWx0ZXIoaXRlbSA9PiAhbWFwLmhhcyhpdGVtLmtleSkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmKCFydW50aW1lQ29uZmlnLmluaXREZWZhdWx0KCkpe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChcXFwi5Yi35paw5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICAgICAgICAgIC8qXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IENrZXkgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKS5rZXk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgLy9sb2coQ2tleSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2ZnID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50Q29uZmlnKClcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGNmZztcXG4gICAgICAgICAgICAgICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldEN1cnJlbnRDb25maWcoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0Q3VycmVudFNvdXJjZShDa2V5KTsqL1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwIHx8IGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLmlrDlop46XFxcIiArIGFsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXCLmlrDlop5cXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3Quc3BsaWNlKG1hbmFnZS5saXN0LmluZGV4T2YoeC5uYW1lKSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLnp7vpmaQ6XFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXCIg56e76ZmkXFxcIiArIGRsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLnNldFRpdGxlKFxcXCLpgInmi6nop4bpopHmupAg5b2T5YmN5YWxOlxcXCIgKyBtYW5hZ2UubGlzdC5sZW5ndGggKyBcXFwi5Liq6KeG6aKR5rqQXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXCIg5pu05aSa6K+m5oOF55yLbG9nXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuW3suWIt+aWsFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIue8lueggeexu+Wei1xcXCIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnM6IFtcXFwi5LiN57yW56CBXFxcIiwgXFxcIkd6aXBcXFwiLCBcXFwiQmFzZTY0XFxcIiwgXFxcIkFFU1xcXCJdLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2w6IDEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwic2hhcmVfZW5jb2RlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgaW5wdXQ7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgIH0pO1xcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcImRycHnnrqHnkIZcIixcInBhdGhcIjpcIkRycHlNYW5hZ2VcIixcInJ1bGVcIjpcImpzOlxcbmNvbnN0IEpTRW5naW5lID0gY29tLmV4YW1wbGUuaGlrZXJ2aWV3LnNlcnZpY2UucGFyc2VyLkpTRW5naW5lO1xcbmNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG5jb25zdCBkcnB5TWFwID0gbmV3IE1hcCgpO1xcbmNvbnN0IEdNa2V5ID0gbW9kdWxlLmltcG9ydFBhcmFtO1xcbi8vbG9nKFxcXCLliJ3lp4vljJZEcnB5TWFuYWdlXFxcIik7XF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FwiO1xcXFxuXFxcIiwgXFxcIlxcXCIsIGZhbHNlKTtcXG59XFxuXFxuZnVuY3Rpb24gZ2V0KGtleSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICAvL2xvZyhkcnB5TWFwLnNpemUpXFxuICAgICAgICBpZiAoZHJweU1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGRycHlNYXAuc2l6ZSA+PSA1KSB7XFxuICAgICAgICAgICAgLy9sb2coXFxcIuivt+axgjpcXFwiICsga2V5KVxcbiAgICAgICAgICAgIGRlbChBcnJheS5mcm9tKGRycHlNYXAua2V5cygpKS5hdCgwKSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2VzKCkuZmluZCh2ID0+IHYua2V5ID09PSBrZXkpO1xcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHJ1bnRpbWVDb25maWcuZ2V0QWJzb2x1dGVQYXRoKHNvdXJjZS5leHQpKTtcXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgaWYgKGRycHkuZ2V0UnVsZShcXFwicHJveHlfcnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBQcm94eSA9ICQucmVxdWlyZShcXFwiTG9jYWxQcm94eVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgcHJveHlVcmwgPSBQcm94eS5zdGFydFByb3h5KE1ZX1JVTEUudGl0bGUsIEdNLmdldFNlbGZLZXkoKSk7XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJQcm94eV9VcmxcXFwiLCBwcm94eVVybCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIGRycHk7XFxuICAgIH0sIHRoaXMpLmNhbGwoKTtcXG59XFxuLy9zb3VyY2UuZXh05b+F6aG75Li657ud5a+56Lev5b6EXFxuZnVuY3Rpb24gZ2V0QnlTb3VyY2Uoc291cmNlKSB7XFxuICAgIHJldHVybiBzeW5jKCgpID0+IHtcXG4gICAgICAgIGxldCBrZXkgPSBzb3VyY2Uua2V5O1xcbiAgICAgICAgLy9sb2coZHJweU1hcC5zaXplKVxcbiAgICAgICAgaWYgKGRycHlNYXAuaGFzKGtleSkpIHtcXG4gICAgICAgICAgICByZXR1cm4gZHJweU1hcC5nZXQoa2V5KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChkcnB5TWFwLnNpemUgPj0gNSkge1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCLor7fmsYI6XFxcIiArIGtleSlcXG4gICAgICAgICAgICBkZWwoQXJyYXkuZnJvbShkcnB5TWFwLmtleXMoKSkuYXQoMCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgY3JlYXRlRHJweShrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgZHJweS5pbml0KHNvdXJjZS5leHQpO1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBpZiAoZHJweS5nZXRSdWxlKFxcXCJwcm94eV9ydWxlXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgbGV0IFByb3h5ID0gJC5yZXF1aXJlKFxcXCJMb2NhbFByb3h5XFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBwcm94eVVybCA9IFByb3h5LnN0YXJ0UHJveHkoTVlfUlVMRS50aXRsZSwgR00uZ2V0U2VsZktleSgpKTtcXG4gICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcIlByb3h5X1VybFxcXCIsIHByb3h5VXJsKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuXFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gZHJweTtcXG4gICAgfSwgdGhpcykuY2FsbCgpO1xcbn1cXG5cXG5mdW5jdGlvbiBwdXQoa2V5LCBkcnB5KSB7XFxuICAgIHN5bmMoKCkgPT4gZHJweU1hcC5zZXQoa2V5LCBkcnB5KSwgdGhpcykuY2FsbCgpO1xcbn1cXG5cXG5mdW5jdGlvbiBydW5Qcm94eShkcnB5LCBhcmdzKSB7XFxuICAgIGlmICh0eXBlb2YgZHJweS5wcm94eSA9PT0gXFxcImZ1bmN0aW9uXFxcIikge1xcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAvL2xldCB0aW1lMSA9IERhdGUubm93KCk7XFxuICAgICAgICAgICAgcHJveHlTZW1hcGhvcmUuYWNxdWlyZSgpO1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUyID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiMeetieW+heaXtumXtDpcXFwiICsgKHRpbWUyIC0gdGltZTEpICsgXFxcIm1zXFxcIik7XFxuICAgICAgICAgICAgbGV0IHJlcyA9IGRycHkucHJveHkuYXBwbHkoZHJweSwgYXJncyk7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTMgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCIy5omn6KGM5Luj55CG6ICX5pe2OlxcXCIgKyAodGltZTMgLSB0aW1lMikgKyBcXFwibXNcXFwiKTtcXG4gICAgICAgICAgICAvL2xvZyhcXFwiM+aAu+iAl+aXtuiAl+aXtjpcXFwiICsgKHRpbWUzIC0gdGltZTEpICsgXFxcIm1zXFxcIik7XFxuXFxuICAgICAgICAgICAgcmV0dXJuIHJlcztcXG4gICAgICAgIH0gZmluYWxseSB7XFxuICAgICAgICAgICAgcHJveHlTZW1hcGhvcmUucmVsZWFzZSgpO1xcbiAgICAgICAgfVxcbiAgICB9XFxufVxcbl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lbGVjdEJvdHRvbVJlcyh7XFxuICAgICAgICBvcHRpb25zOiBnZXROYW1lcygpLFxcbiAgICAgICAgY29sdW1uczogc3BlbixcXG4gICAgICAgIHRpdGxlOiBcXFwi5ZCv55So5pCc57Si5rqQOlxcXCIgKyBzZWFyY2hvbmNvdW50ICsgXFxcIuS4qiDlhbE6XFxcIiArIGNhblNlYXJjaFNvdXJjZS5sZW5ndGggKyBcXFwi5Liq5pCc57Si5rqQXFxcIixcXG4gICAgICAgIG5vQXV0b0Rpc21pc3M6IHRydWUsXFxuICAgICAgICBwb3NpdGlvbjogMSxcXG4gICAgICAgIGhlaWdodDogLjksXFxuICAgICAgICBleHRyYUlucHV0Qm94OiBuZXcgaGlrZXJQb3AuUmVzRXh0cmFJbnB1dEJveCh7XFxuICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICB0aXRsZTogXFxcIm9rXFxcIixcXG4gICAgICAgICAgICBvbkNoYW5nZSh0ZXh0LCBtYW5hZ2UpIHtcXG4gICAgICAgICAgICAgICAgLy9sb2coXFxcIm9uQ2hhbmdlOlxcXCIrdGV4dClcXG4gICAgICAgICAgICAgICAgc2VhcmNoS2V5ID0gdGV4dDtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBpZiAodGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGV4dC5zcGxpdCgvXFxcXHwvKS5maWx0ZXIoZiA9PiBmKS5zb21lKHggPT4gdi5uYW1lLmluY2x1ZGVzKHgpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnB1c2godik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAodi5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpIDogdi5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZSA9IGNhblNlYXJjaFNvdXJjZS5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBcXFwiXFxcIixcXG4gICAgICAgICAgICBjbGljayhzLCBtYW5hZ2UpIHtcXG4gICAgICAgICAgICAgICAgLy90b2FzdChzKTtcXG4gICAgICAgICAgICAgICAgLy9sb2cobWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfSksXFxuICAgICAgICBjbGljayhzLCBpLCBtYW5hZ2UpIHtcXG5cXG4gICAgICAgICAgICBsZXQga2V5ID0gZHluYW1pY1NvdXJjZVtpXS5rZXk7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gLTE7XFxuICAgICAgICAgICAgaWYgKChpbmRleCA9IHNlYXJjaEFsbG93LmluZGV4T2Yoa2V5KSkgIT09IC0xKSB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0W2ldID0gZHluYW1pY1NvdXJjZVtpXS5uYW1lO1xcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5zcGxpY2UoaW5kZXgsIDEpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0W2ldID0gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAoZHluYW1pY1NvdXJjZVtpXS5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpO1xcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKGtleSk7XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICB9LFxcbiAgICAgICAgbWVudUNsaWNrKG1hbmFnZSkge1xcbiAgICAgICAgICAgIGhpa2VyUG9wLnNlbGVjdENlbnRlcih7XFxuICAgICAgICAgICAgICAgIG9wdGlvbnM6IFtcXFwi5pS55Y+Y5qC35byPXFxcIiwgXFxcIuetm+mAiea6kFxcXCIsIFxcXCLoh6rnhLbmjpLluo9cXFwiLCBcXFwi5YCS5bqPXFxcIiwgXFxcIuWFqOmAiVxcXCIsIFxcXCLlj43pgIlcXFwiXSxcXG4gICAgICAgICAgICAgICAgY29sdW1uczogMixcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLor7fpgInmi6lcXFwiLFxcbiAgICAgICAgICAgICAgICBjbGljayhzLCBpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNwZW4gPSBzcGVuID09IDMgPyAxIDogKHNwZW4gPT0gMiA/IDMgOiAyKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlQ29sdW1ucyhzcGVuKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlhbPplK7lrZcg56m65pi+56S65YWo6YOoXFxcIixcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaW50OiBcXFwi5rqQ5YWz6ZSu5a2XIOWkmuS4queUqHzpmpTlvIBcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VmFsdWU6IHNlYXJjaEtleSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9BdXRvU29mdDogZmFsc2UsXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpID8gXFxcIuKAnOKAnOKAneKAnVxcXCIgKyAodi5uYW1lICsgXFxcIlxcXCIpLmZvbnRjb2xvcihcXFwiIzAwOTk2NlxcXCIpIDogdi5uYW1lKVxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UgPSBjYW5TZWFyY2hTb3VyY2Uuc2xpY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vcmV0dXJuIFxcXCJ0b2FzdDovL+i+k+WFpeS6hlxcXCIgKyB0ZXh0O1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpID09PSAyKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG5cXG5cXG4gICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLnNvcnQoKGEsIGIpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbnVtZXJpYzogdHJ1ZSxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbnNpdGl2aXR5OiAnYmFzZSdcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5yZXZlcnNlKCk7XFxuXFxuICAgICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2VhcmNoQWxsb3cuaW5jbHVkZXModikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSA1KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRlbWxpc3QgPSBzZWFyY2hBbGxvdy5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5mb3JFYWNoKHYgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGVtbGlzdC5pbmNsdWRlcyh2LmtleSkpIHJldHVybjtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAg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YmxvY2snXFxuICAgICAgICB9KVxcbiAgICAgICAgeC52YWx1ZS5mb3JFYWNoKChpdCwgaSkgPT4ge1xcbiAgICAgICAgICBsZXQgdCA9IGl0Lm47XFxuICAgICAgICAgIGlmIChjYXRlX3RlbXBbaW5kZXhdID09IGkpIHtcXG4gICAgICAgICAgICB0ID0gXFxcIjxiPjxmb250IGNvbG9yPVxcXCIgKyBjb2xvciArIFxcXCI+XFxcIiArIHQgKyBcXFwiPC9mb250PjwvYj5cXFwiO1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IGl0LnY7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGNhdGVfdGVtcFtpbmRleF0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IFxcXCJ1bmRlZmluZWRcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChmb2xkID09IDEpIHtcXG4gICAgICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyB0LFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gby5pO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiaXNfZGVmXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwge30pO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIGlmIChjYXRlX3RlbXAuY29uc3RydWN0b3IgIT0gQXJyYXkpIHtcXG4gICAgICAgICAgICAgICAgICBjYXRlX3RlbXAgPSBbXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBvLmluZGV4O1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGNhdGVfdGVtcFtpbmRleF0gfHwgXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgLy9sb2coYylcXG4gICAgICAgICAgICAgICAgaWYgKGMgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGNhdGVfdGVtcClcXG4gICAgICAgICAgICAgICAgLy9zdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV90ZW1wXFxcIiwgY2F0ZV90ZW1wKTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwgY2F0ZV9vYmopO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICBpbmRleDogaW5kZXgsXFxuICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcbiAgICAgICAgICAgICAgICBpOiBpLFxcbiAgICAgICAgICAgICAgICBjYXRlOiBjYXRlXFxuICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfS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G75Z6LXFxcIik7XFxuICAgIGxldCBpY29uID0gXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8va2UvMTUwLnBuZ1xcXCI7XFxuICAgIHN3aXRjaCAoc3R5cGUpIHtcXG4gICAgICAgIGNhc2UgJ+a8q+eUuyc6XFxuICAgICAgICAgICAgaWNvbiA9IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vdHViaWFvL2tlLzEzLnBuZ1xcXCI7XFxuICAgICAgICAgICAgYnJlYWs7XFxuICAgICAgICBjYXNlICflsI/or7QnOlxcbiAgICAgICAgICAgIGljb24gPSBcXFwiaHR0cHM6Ly9oaWtlcmZhbnMuY29tL3R1Ymlhby9rZS8zOC5wbmdcXFwiO1xcbiAgICAgICAgICAgIGJyZWFrO1xcbiAgICAgICAgZGVmYXVsdDpcXG4gICAgfVxcbiAgICB1cGRhdGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwic291cmNlbmFtZVxcXCIsIHtcXG4gICAgICAgIGltZzogaWNvbixcXG4gICAgfSk7XFxuXFxuICAgIGxldCBsaXN0ID0gW107XFxuICAgIGlmIChjYXRlID09IFxcXCJob21lXFxcIikge1xcbiAgICAgICAgaWYgKHBhZ2UgPT0gMSkge1xcbiAgICAgICAgICAgIGxpc3QgPSBob21lbGlzdDtcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChsaXN0ID09PSB1bmRlZmluZWQpIHtcXG4gICAgICAgICAgICBsaXN0ID0gW107XFxuICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwiaXNob21lXFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAobGlzdC5sZW5ndGggPiAwICYmICFsaXN0LmF0KDApLnZvZF9waWMgJiYgIWxpc3QuYXQoLTEpLnZvZF9waWMgJiYgIWRlQ29sKSB7XFxuICAgICAgICAgICAgaG9tZUxpc3RDb2wgPSBcXFwidGV4dF8xXFxcIjtcXG4gICAgICAgIH1cXG4gICAgfSBlbHNlIHtcXG4g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cmNlLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHVybDtcXG4gICAgICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0QnlTb3VyY2Uoc291cmNlKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBKU09OLnBhcnNlKGRycHkuZGV0YWlsKGlkKSkubGlzdFswXS52b2RfcGxheV91cmwuc3BsaXQoXFxcIiRcXFwiKVsxXTtcXG4gICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBpZC5zcGxpdChcXFwiQEBcXFwiKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucGFyc2UodXJsLCBpZCwgc291cmNlKTtcXG4gICAgICAgICAgICAgICAgfSwgc291cmNlLCBpZCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBuYW1lLFxcbiAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcXG4gICAgICAgICAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiBob21lTGlzdENvbCxcXG4gICAgICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcXG4gICAgICAgICAgICAgICAgICAgIHZvZElkOiBpZCxcXG4gICAgICAgICAgICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcXG4gICAgICAgICAgICAgICAgICAgIHNrZXk6IHNvdXJjZS5rZXksXFxuICAgICAgICAgICAgICAgICAgICBpZDogaWQsXFxuICAgICAgICAgICAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLogZrlkIjmkJzntKJcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGpzOiBcXFwicHV0TXlWYXIoJ3RlbXNtb2RlJywgJzEnKTsnaGlrZXI6Ly9zZWFyY2g/cnVsZT0nICsgTVlfUlVMRS50aXRsZSArICcmcz1cXFwiICsgbmFtZSArIFxcXCInO1xcXCJcXG4gICAgICAgICAgICAgICAgICAgIH1dXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgfVxcbiAgICBkZWxldGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwibG9hZFxcXCIpO1xcbn1cXG5cXG5mdW5jdGlvbiBzZXREcnB5UGF0aChkKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogXFxcIue8uuWwkei/kOihjOW6k1xcXFxu6K+l5bCP56iL5bqP5LiN6IO96YCa6L+H5LqR5Ymq6LS05p2/5YiG5Lqr77yM5Y+q6IO96YCa6L+H5omT5YyF5YiG5LqrXFxcIixcXG4gICAgICAgIGRlc2M6IFxcXCLlsIbov5DooYzlupPmlL7lhaVcXFwiICsgZ2V0UGF0aChcXFwiaGlrZXI6Ly9maWxlcy9kYXRhL1xcXCIgKyBNWV9SVUxFLnRpdGxlICsgXFxcIi9saWJzX2hpa2VyL2RycHkyLmpzXFxcIiksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgfSk7XFxufVxcblxcb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xcXCLmm7TmjaLphY3nva5cXFwiLFxcbiAgICAgICAgICAgICAgICBqczogSlNPTi5zdHJpbmdpZnkoXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIilcXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K6/6Zeu572R56uZXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcIndlYjovL1xcXCIgKyBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KS5nZXRSdWxlKFxcXCJob3N0XFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAvL3JlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuWIt+aWsOa6kFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkuaW5pdChydW50aW1lQ29uZmlnLmdldEFic29sdXRlUGF0aChzb3VyY2UuZXh0KSk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLph43ovb3mupBcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHNvdXJjZSA9IHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuZGVsKHNvdXJjZS5rZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9LCB7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5p+l55yL5rqQ5Luj56CBXFxcIixcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgY29kZSA9IERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpLnJ1bk1haW4oXFxcImxldCBtYWluPVxcXCIgKyAkLnRvU3RyaW5nKChleHQpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKCkgPT4gZ2V0T3JpZ2luYWxKcyhyZXF1ZXN0KGV4dCwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnbWV0aG9kJzogJ0dFVCdcXG4gICAgICAgICAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgICAgICB9LCBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2VQYXRoKCkpKTtcXG5cXG4gICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gXFxcImhpa2VyOi8vZmlsZXMvX2NhY2hlL3ZpZXdTb3VyY2VDb2RlLmpzXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCBjb2RlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiZWRpdEZpbGU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XS5jb25jYXQoY29uZmlnLnR5cGUgPT09IFxcXCJsb2NhbERpclxcXCIgPyBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIue8lui+keWPguaVsOaYoOWwhOihqFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChwYXRoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoICs9IFxcXCIvLm1hcHBpbmcudHh0XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChmaWxlRXhpc3QocGF0aCkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICB0b2FzdChcXFwi5L+d5a2Y5ZCO5Yi35paw6YWN572u5oiW6YeN5ZCv5omN5Lya55Sf5pWIXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJlZGl0RmlsZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi5LiN5a2Y5Zyo5pig5bCE5paH5Lu25piv5ZCm5Yib5bu677yfXFxcIikuY29uZmlybShwYXRoID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuS/neWtmOWQjuWIt+aWsOmFjee9ruaIlumHjeWQr+aJjeS8mueUn+aViFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImVkaXRGaWxlOi8vXFxcIiArIHBhdGg7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSwgcGF0aCk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGNvbmZpZy5wYXRoKVxcbiAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmnKzlnLDnrqHnkIZcXFwiLFxcbiAgICAgICAgICAgICAgICBqczogXFxcIidoaWtlcjovL3BhZ2UvTG9jYWxEaXIjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjJ1xcXCJcXG4gICAgICAgICAgICB9XSA6IFtdKVxcbiAgICAgICAgfVxcbiAgICB9KTtcXG5cXG4gICAgdWlvYmoucHVzaCh7XFxuICAgICAgICBpbmRleD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ZihzdGFnKSArIDE7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB0YWdDbGFzc2VzLnVuc2hpZnQoXFxcIlvml6BUQUddXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJCh0YWdDbGFzc2VzLCAzLCBcXFwi5pCc57SiVEFHW1xcXCIgKyB0YWdDbGFzc2VzLmxlbmd0aCArIFxcXCJdXFxcIiwgaW5kZXgpLnNlbGVjdCgodCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRhZyA9IE1ZX0lOREVYID09PSAwID8gXFxcIlxcXCIgOiBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocnVudGltZUNvbmZpZy5zZXRTZWFyY2hUYWcodGFnKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJzbW9kZVxcXCIsIFxcXCIyXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0odCArIFxcXCJAc2VhcmNoX21vZGVcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogdGFnIHx8IFxcXCLml6BUQUdcXFwiLFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruWksei0pVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSwgdCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwic21vZGVcXFwiLCBcXFwiXFxcIiArIE1ZX0lOREVYKTtcXG4gICAgICAgICAgICAgICAgdXBkYXRlSXRlbSh0ICsgXFxcIkBzZWFyY2hfbW9kZVxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICAgIHRpdGxlOiBbXFxcIumAieS4rVxcXCIsIFxcXCLogZrlkIhcXFwiXVtNWV9JTkRFWF0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH0sIE1ZX1JVTEUudGl0bGUpXFxuICAgICAgICB9KSxcXG4gICAgICAgIGltZzogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vc3lzdGVtLzE0OS5wbmdcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IHVpX2NvbmZpZy5jb2wsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBNWV9SVUxFLnRpdGxlICsgXFxcIkBzZWFyY2hfbW9kZVxcXCIsXFxuICAgICAgICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuaMh+WumuaQnOe0oua6kFxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiU2VhcmNoQWxsb3dQb3BcXFwiKS5zaG93KCk7XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuaQnOe0ouaOkuW6jzpcXFwiICsgW1xcXCLml6BcXFwiLCBcXFwi6Ieq54S2XFxcIiwgXFxcIuS9v+eUqFxcXCJdW3NlYXJjaHNvcnRdLFxcbiAgICAgICAgICAgICAgICBqcz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UxvZykgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwidXNlTG9nXFxcIiwgdXNlTG9nID8gXFxcIlxcXCIgOiBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChzb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIERycHlNYW5hZ2UuZGVsKHNvdXJjZS5rZXkpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgKHVzZUxvZyA/IFxcXCLlt7LlhbPpl61cXFwiIDogXFxcIuW3suW8gOWQr1xcXCIpO1xcbiAgICAgICAgICAgICAgICB9LCB1c2VMb2cpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliJvlu7rorqLpmIXlnLDlnYBcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL2NyZWF0ZVN1YnNjcmlwdGlvbiNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliIfmjaLliJfooajmoLflvI9cXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBjb2xsaXN0ID0gW1xcXCLpu5jorqRcXFwiLCBcXFwibW92aWVfM19tYXJxdWVlXFxcIiwgXFxcIm1vdmllXzNcXFwiLCBcXFwibW92aWVfMlxcXCIsIFxcXCJtb3ZpZV8xXFxcIiwgXFxcInRleHRfMVxcXCIsIFxcXCJhdmF0YXJcXFwiLCBcXFwidGV4dF9pY29uXFxcIiwgXFxcImNhcmRfcGljXzNcXFwiLCBcXFwiY2FyZF9waWNfM19jZW50ZXJcXFwiLCBcXFwicGljXzFfY2FyZFxcXCIsIFxcXCJwaWNfMl9jYXJkXFxcIiwgXFxcIm1vdmllXzFfdmVydGljYWxfcGljXFxcIiwgXFxcIm1vdmllXzFfbGVmdF9waWNcXFwiXTtcXG4gICAgICAgICAgICAgICAgbGV0IGhvbWVMaXN0Q29sID0gZ2V0SXRlbShcXFwiaG9tZUxpc3RDb2xcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGhvbWVMaXN0Q29sID8gY29sbGlzdC5pbmRleE9mKGhvbWVMaXN0Q29sKSA6IDA7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGNvbGxpc3QsIDIsIFxcXCLpgInmi6nmoLflvI9cXFwiLCBpbmRleCkuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChNWV9JTkRFWCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImhvbWVMaXN0Q29sXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJob21lTGlzdENvbFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgP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A9IHN1aW9ialtvYmppXS51cmw7XFxuICAgICAgICAgICAgICAgIGlmIChzdWlvYmpbb2JqaV0uaGFzT3duUHJvcGVydHkoXFxcImV4dHJhXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIHVpb2JqW2NvYmppXS5leHRyYSA9IHN1aW9ialtvYmppXS5leHRyYTtcXG4gICAgICAgICAgICAgICAgICAgIHVpb2JqW2NvYmppXS5leHRyYS5pZCA9IE1ZX1JVTEUudGl0bGUgKyBcXFwic291cmNlbmFtZVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoaXRlbS5rZXkgPT0gXFxcIua6kOWQjVxcXCIgJiYgaXRlbS5pbmRleCA9PSAtMSkge1xcbiAgICAgICAgICAgIGxldCBvYmppID0gc3Vpb2JqLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IFxcXCLmupDlkI1cXFwiKTtcXG4gICAgICAgICAgICBsZXQgY29iamkgPSB1aW9iai5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBcXFwi5o2i5rqQXFxcIik7XFxuICAgICAgICAgICAgaWYgKG9iamkgIT0gMSAmJiBjb2JqaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICB1aW9ialtjb2JqaV0udGl0bGUgPSBuYW1lIHx8IFxcXCLmjaLmupBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChpdGVtLmtleSA9PSBcXFwi5Y6G5Y+yXFxcIiAmJiBpdGVtLmluZGV4ID09IC0xKSB7XFxuICAgICAgICAgICAgc2VsZWN0cy51bnNoaWZ0KHtcXG4gICAgICAgICAgICAgICAgXFxcInRpdGxlXFxcIjogXFxcIuWOhuWPslxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCJpY29uXFxcIjogXFxcImh0dHBzOi8vaGlrZXJmYW5zLmNvbS90dWJpYW8vc3lzdGVtLzEzNi5wbmdcXF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gfSk7XFxuICAgIH0gZWxzZSBpZiAoIXJ1bnRpbWVDb25maWcuaXNQcmVwYXJlZCgpKSB7XFxuICAgICAgICBsZXQgbG9hZEVycm9yID0gcnVudGltZUNvbmZpZy5nZXRMb2FkRXJyb3IoKTtcXG4gICAgICAgIGlmIChsb2FkRXJyb3IpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOmFjee9ruaWh+S7tuWKoOi9veWksei0peKAneKAnVxcXCIsXFxuICAgICAgICAgICAgICAgIGRlc2M6IGxvYWRFcnJvci50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB1cmw6ICQoKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKS5pbml0RGVmYXVsdCgpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH0pLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi5pu05o2i6YWN572uXFxcIixcXG4gICAgICAgICAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9wYWdlL2NyZWF0ZUNvbmZpZyNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiLFxcbiAgICAgICAgICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICAgICAgICA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hc0hhZWQgPSBmYWxzZTtcXG4gICAgICAgIGlmIChnZXRNeVZhcihcXFwibGlua3NcXFwiLCBcXFwiXFxcIikgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0aXRsZTogJ+WKoOi9veS4rS4uLicsXFxuICAgICAgICAgICAgICAgIGNvbF90eXBlOiAndGV4dF9jZW50ZXJfMScsXFxuICAgICAgICAgICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwibG9hZFxcXCJcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHNldFByZVJlc3VsdChkKTtcXG4gICAgICAgICAgICBkLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgaGFzSGFlZCA9IHRydWU7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoc291cmNlKSB7XFxuICAgICAgICAgICAgbG9hZChkLCBEcnB5TWFuYWdlLmdldChzb3VyY2Uua2V5KSwgc291cmNlLCBoYXNIYWVkKTtcXG4gICAgICAgIH1cXG4gICAgfSBlbHNlIHtcXG4gICAgICAgIHNldERycHlQYXRoKGQpO1xcbiAgICB9XFxuXFxufSBjYXRjaCAoZSkge1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgZS50b1N0cmluZygpICsgXFxcIuKAneKAnVxcXCIsXFxuICAgICAgICBkZXNjOiBlLmxpbmVOdW1iZXIsXFxuICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLmuIXpmaR1aeiuvue9rlxcXCIsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgdWlfY2xlYXIsXFxuICAgICAgICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJVSU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgdWlfY2xlYXIoXFxcInlpXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1dXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmm7TmjaLphY3nva5cXFwiLFxcbiAgICAgICAgdXJsOiBcXFwiaGlrZXI6Ly9wYWdlL2NyZWF0ZUNvbmZpZyNub1JlY29yZEhpc3RvcnkjI25vSGlzdG9yeSNcXFwiLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0pO1xcbiAgICBkZWxldGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwibG9hZFxcXCIpO1xcbn1cXG5cXG5zZXRSZXN1bHQoZCk7XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCLkuLvpobXlpITnkIZcIixcInBhdGhcIjpcIk1pYW5Mb2FkXCIsXCJydWxlXCI6XCJpZiAoZ2V0SXRlbShcXFwiZmlyc3RvcGVuXFxcIikgPT0gTVlfUlVMRS52ZXJzaW9uKS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IFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0pLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICB0aXRsZVZpc2libGU6IGZhbHNlXFxuICAgICAgICB9XFxuICAgIH0sIHtcXG4gICAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgfSwge1xcbiAgICAgICAgdGl0bGU6IHRpbWUgKyBcXFwi56eS5ZCO57un57utXFxcIixcXG4gICAgICAgIHVybDogXFxcInRvYXN0Oi8v6K+36K6k55yf6ZiF6K+75Lul5LiK5YaF5a65XFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBpZCArIFxcXCJ0aW1lclxcXCJcXG4gICAgICAgIH1cXG4gICAgfSk7XFxuXFxuICAgIHNldFJlc3VsdChkKTtcXG4gICAgd2hpbGUgKHRpbWUgIT0gMCkge1xcbiAgICAgICAgamF2YS5sYW5nLlRocmVhZC5zbGVlcCgxMDAwKTtcXG4gICAgICAgIHRpbWUgLT0gMTtcXG4gICAgICAgIHVwZGF0ZUl0ZW0oaWQgKyBcXFwidGltZXJcXFwiLCB7XFxuICAgICAgICAgICAgdGl0bGU6IHRpbWUgKyBcXFwi56eS5ZCO57un57utXFxcIlxcbiAgICAgICAgfSk7XFxuICAgIH1cXG4gICAgdXBkYXRlSXRlbShpZCArIFxcXCJ0aW1lclxcXCIsIHtcXG4gICAgICAgIHRpdGxlOiBcXFwi4oCc4oCc5oiR5ZCM5oSP5Lul5LiK6KaB5rGC4oCd4oCdXFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgodikgPT4ge1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcImZpcnN0b3BlblxcXCIsIFN0cmluZyh2KSk7XFxuICAgICAgICAgICAgR00uY2xlYXIoXFxcInJ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ICAgICAgICBkZWVwT2JqZWN0UHJvcGVydHkob2JqLCBwYXRoLCB2YWx1ZSkge1xcbiAgICAgICAgICB2YXIgcGFydHMgPSBwYXRoLnNwbGl0KCcuJyk7XFxuICAgICAgICAgIHZhciBjdXJyZW50ID0gb2JqO1xcbiAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHBhcnRzLmxlbmd0aCAtIDE7IGkrKykge1xcbiAgICAgICAgICAgIHZhciBwYXJ0ID0gcGFydHNbaV07XFxuICAgICAgICAgICAgaWYgKCFjdXJyZW50W3BhcnRdKSB7XFxuICAgICAgICAgICAgICBjdXJyZW50W3BhcnRdID0ge307XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyZW50W3BhcnRdO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGN1cnJlbnRbcGFydHNbcGFydHMubGVuZ3RoIC0gMV1dID0gdmFsdWU7XFxuICAgICAgICB9LFxcbiAgICAgICAgZ2V0KCkge1xcbiAgICAgICAgICBsZXQgdWMgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB0aGlzLnVjKTtcXG4gICAgICAgICAgaWYgKE9iamVjdC5rZXlzKHVjKS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgIHVjID0gdGhpcy5kZWY7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIHVjO1xcbiAgICAgICAgfSxcXG4gICAgICAgIHNldCh2YWx1ZSwga2V5KSB7XFxuICAgICAgICAgIGxldCB1YyA9IHRoaXMuZ2V0KCk7XFxuICAgICAgICAgIGlmIChrZXkpIHtcXG4gICAgICAgICAgICB0aGlzLmRlZXBPYmplY3RQcm9wZXJ0eSh1Yywga2V5LCB2YWx1ZSk7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgdWMgPSB2YWx1ZTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBzdG9yYWdlMC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XG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBpdGVtLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogY3VycmVudC5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBjdXJyZW50LmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oY3VycmVudC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGl0ZW0ucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogaXRlbS5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGl0ZW0udHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBjdXJyZW50LmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogaXRlbS5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBpdGVtLmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxldCBuYXJyID0gJC5zd2FwQXJyYXlFbGVtZW50cyhpbmRleHMsIGN1cnJlbnQuZXh0cmEuaW5kZXgsIGl0ZW0uZXh0cmEuaW5kZXgpO1xcblxcbiAgICAgICAgICAgICQudWlDb25maWcuc2V0KG5hcnIsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgaCA9ICfigJzigJzigJ3igJ0nO1xcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0ZW0udGl0bGU7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIumAieaLqeenu+WKqOeahOebruagh1xcXCIpO1xcbiAgICAgICAgICAgIGlmICgvdGV4dF9pY29ufGF2YXRhcnxpY29uX3NtYWxsXzMvLnRlc3QoaXRlbS50eXBlKSkge1xcbiAgICAgICAgICAgICAgaCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKC9pY29uXzFfc2VhcmNoLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gXFxcIuKeoe+4j1xcXCIgKyB0aXRsZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogaCArIHRpdGxlLFxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiLCBpdGVtKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaSlcXG4gICAgICAgIGl0ZW1bXFxcImV4dHJhXFxcIl0gPSB7XFxuICAgICAgICAgIGtleTogaXRlbS5rZXksXFxuICAgICAgICAgIGNsczogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiLFxcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgaW5kZXg6IGl0ZW0uaW5kZXgsXFxuICAgICAgICB9XFxuICAgICAgICBpZiAoaXRlbS5rZXkgIT0gXFxcIuiuvue9rlxcXCIpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gLTE7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0sIGl0ZW0ua2V5KVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCEvaWNvbl8xX3NlYXJjaHxhdmF0YXIvLnRlc3QoaXRlbS5jb2xfdHlwZSkpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuabtOaNouWbvuagh1xcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbWdcXFwiXSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGlkID0gZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKS5maWx0ZXIoeCA9PiB4LmV4dHJhLmtleSA9PSBrZXkpWzBdLmV4dHJhLmlkO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHBpYzogaW5wdXQgfSlcXG4gICAgICAgICAgICAgIH0sIGtleSlcXG4gICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLmjaLmupBcXFwiICYmIGl0ZW0ua2V5ICE9IFxcXCLmkJzntKLmqKHlvI9cXFwiKSB7XFxuICAgICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi5L+u5pS55ZCN56ewXFxcIixcXG4gICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcInRpdGxlXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHRpdGxlOiBpbnB1dCB9KVxcbiAgICAgICAgICAgICAgICB9LCBrZXkpXFxuICAgICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpdGVtLmV4dHJhLkxvbmdDbGljayA9IGxvbmdjbGlja3M7XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9IGVsc2Uge1xcbiAgICAgIHVpb2JqID0gdWlvYmoubWFwKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBpdGVtLmV4dHJhID0ge1xcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCJcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgIH0pXFxuICAgIH1cXG4gICAgZCA9IGQuY29uY2F0KHVpb2JqKTtcXG5cXG4gICAgaWYgKGluZGV4cy5zb21lKHggPT4geC5pbmRleCA9PSAtMSkgJiYgdWltb2RlKSB7XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5bey56e76ZmkXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICAgIH0pXFxuICAgICAgaW5kZXhzLmZpbHRlcih4ID0+IHguaW5kZXggPT0gLTEpLmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgIGxldCBtYXAgPSBuZXcgTWFwKHN1aW9iai5tYXAob2JqID0+IFtvYmoua2V5LCBvYmpdKSk7XFxuICAgICAgICBsZXQgb2JqID0gbWFwLmdldChpdGVtLmtleSk7XFxuICAgICAgICBvYmoudXJsID0gJChcXFwiXFxcIikubGF6eVJ1bGUoKGtleSwgaW5kZXgpID0+IHtcXG4gICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gaW5kZXg7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBpdGVtLmtleSwgb2JqLmluZGV4KVxcbiAgICAgICAgb2JqLnRpdGxlID0gb2JqLmtleTtcXG4gICAgICAgIGlmIChvYmouZXh0cmEgPT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgIG9iai5leHRyYSA9IHt9O1xcbiAgICAgICAgfVxcbiAgICAgICAgb2JqLmV4dHJhLmlkID0gTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgb2JqLmtleTtcXG4gICAgICAgIG9iai5leHRyYS5jbHMgPSBNW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b25maWcpID0+IHtcXG4gICAgICAgICAgICB2YXIgdWMgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJ7e2NsaXBib2FyZH19XFxcIikuaW5wdXQoKHVjKSA9PiB7XFxuICAgICAgICAgICAgICB2YXIgeWkgPSB7fTtcXG4gICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHlpID0gSlNPTi5wYXJzZShpbnB1dCk7XFxuICAgICAgICAgICAgICAgIGlmICh5aS5oYXNPd25Qcm9wZXJ0eShcXFwidWlcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgIHVjLnlpID0geWk7XFxuICAgICAgICAgICAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWMpO1xcbiAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuagvOW8j+mUmeivr1xcXCIpXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgdWMpXFxuICAgICAgICAgIH0sIHVpX2NvbmZpZylcXG4gICAgICAgIH1dXFxuICAgICAgfVxcbiAgICB9KVxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5aS06YOo57uE5Lu25qC35byPOlxcXCIgKyB1aV9jb25maWcueWkuY29sLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHVpX2NvbmZpZykgPT4ge1xcbiAgICAgICAgdWlfY29uZmlnID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAg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AgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSAhPT0gJ3N0cmluZycpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFtdO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcGF0aCA9IFtdO1xcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgbGV0IGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICBsZXQgZXNjYXBlID0gZmFsc2U7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB2YWx1ZS5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgY2hhciA9IHZhbHVlW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoZXNjYXBlKSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXFxcXFxcXFwnKSB7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSB0cnVlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ10nKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGN1cnJlbnQpIHtcXG4gICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcGF0aDtcXG4gICAgICAgIH1cXG5cXG4gICAgICAgIGZ1bmN0aW9uIGdldEpzb24ob2JqLCBwYXRoKSB7XFxuICAgICAgICAgICAgaWYgKCFvYmogfHwgIUFycmF5LmlzQXJyYXkocGF0aCkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHBhdGgubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gb2JqO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0aC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gcGF0aFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQgPT09IG51bGwgfHwgY3VycmVudCA9PT0gdW5kZWZpbmVkIHx8IHR5cGVvZiBjdXJyZW50ICE9PSAnb2JqZWN0Jykge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtrZXldO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gY3VycmVudDtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IHJ1blR5cGUgPSBNWV9QQVJBTVMucnVuVHlwZVswXTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKSk7XFxuICAgICAgICAgICAgaWYgKHJ1blR5cGUgPT0gXFxcIkpTT05cXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJhbSA9IEpTT04ucGFyc2UoZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcGFyYW0uaGVhZGVycyB8fCB7fSxcXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZDogcGFyYW0ubWV0aG9kIHx8IHZvaWQgMFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBPYmplY3QuYXNzaWduKHt9LCBwYXJhbS5oZWFkZXJzIHx8IHt9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogZ2V0SnNvbihqc29uLCB0b1BhdGgocGFyYW0uanNvblBhdGgpKSxcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PSBcXFwiSlNcXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJzZTtcXG4gICAgICAgICAgICAgICAgaWYgKE1ZX1BBUkFNUy5pbmRleCkge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgdGl0bGUpLmdldEpzb24oKVtNWV9QQVJBTVMuaW5kZXhbMF1dO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShkZWNvZGVVUklDb21wb25lbnQoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCByZXMgPSBuZXcgRnVuY3Rpb24oXFxcInVybFxcXCIsIFxcXCJzZWxmXFxcIiwgcGFyc2UuanMpKHVybCwgcGFyc2UpO1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcyA9PT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogcmVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoJC50eXBlKHJlcykgPT09IFxcXCJvYmplY3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiByZXNcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuX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kuI3og73kvb/nlKjop6PmnpDjgIJcXFwiLFxcbiAgICBdXFxufV07XCJ9XSIsImljb24iOiIiLCJwcm94eSI6IiJ9
Add Comment
Please, Sign In to add comment