xiaomianao666

小程序:DrpyHiker

Jul 29th, 2024
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjo0OSwiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1pYW5Mb2FkXCIpOyIsInNlYXJjaF91cmwiOiJoaWtlcjovL2VtcHR5P3M9KiomcGFnZT1meXBhZ2UiLCJncm91cCI6Iua1i+ivlSIsInNlYXJjaEZpbmQiOiJqczpcbihmdW5jdGlvbiAoKSB7XG4gIGxldCB7XG4gICAgdWlfY29uZmlnLFxuICB9ID0gJC5yZXF1aXJlKFwiVUlNYW5hZ2VcIik7XG4gIHVpX2NvbmZpZz11aV9jb25maWcueWk7XG5cbiAgbGV0IHNtb2RlID0gTnVtYmVyKGdldEl0ZW0oXCJzbW9kZVwiLCBcIjBcIikpO1xuICBsZXQgdGVtc21vZGUgPSBnZXRNeVZhcihcInRlbXNtb2RlXCIsIFwiXCIpO1xuICBpZiAodGVtc21vZGUpIHtcbiAgICBzbW9kZSA9IE51bWJlcih0ZW1zbW9kZSk7XG4gICAgY2xlYXJNeVZhcihcInRlbXNtb2RlXCIpO1xuICB9XG4gIGlmICghZmlsZUV4aXN0KFwiaGlrZXI6Ly9maWxlcy9kYXRh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NhdGNoIHsgfVxuICAgIGxldCBkID0gW107XG4gICAgbGV0IHNraXBFciA9IGRycHkuZ2V0UnVsZShcIuS6jOe6p1wiKSA9PT0gXCIqXCIgJiYgZ2V0SXRlbShcInNraXBFclwiLCBcIlwiKTtcblxuICAgIGZvciAobGV0IGl0IG9mIGhvbWVMaXN0KSB7XG4gICAgICBsZXQgY2lkO1xuICAgICAgbGV0IGlkID0gU3RyaW5nKGl0LnZvZF9pZCk7XG4gICAgICBsZXQgdXJsID0gXCJoaWtlcjovL3BhZ2UvZGV0YWlsZWRcIit1aV9jb25maWcubWFyaztcbiAgICAgIGlmIChza2lwRXIpIHtcbiAgICAgICAgdXJsID0gJCgpLmxhenlSdWxlKChzb3VyY2UsIGlkLCBteSkgPT4ge1xuICAgICAgICAgIGxldCB1cmw7XG4gICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKTtcbiAgICAgICAgICAgIGxldCBkcnB5ID0gRHJweU1hbmFnZS5nZXRCeVNvdXJjZShzb3VyY2UpO1xuICAgICAgICAgICAgdXJsID0gSlNPTi5wYXJzZShkcnB5LmRldGFpbChpZCkpLmxpc3RbMF0udm9kX3BsYXlfdXJsLnNwbGl0KFwiJFwiKVsxXTtcbiAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAvL2xvZyhlLm1lc3NhZ2UpO1xuICAgICAgICAgICAgdXJsID0gaWQuc3BsaXQoXCJAQFwiKVswXTtcbiAgICAgICAgICB9XG4gICAgICAgICAgbGV0IHJlc3VsdDtcbiAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgcmVzdWx0ID0gJC5yZXF1aXJlKFwidmlkZW9VcmxcIikucGFyc2UodXJsLCBpZCwgc291cmNlKTtcbiAgICAgICAgICB9IGNhdGNoIChlcnJvcikge1xuICAgICAgICAgICAgLy9sb2coZXJyb3IubWVzc2FnZSk7XG4gIC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ICAgICAgICAgIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxvd1NlYXJjaFNvdXJjZShzbW9kZSA9PT0gMik7XG5cbiAgICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcblxuICAgICAgICAgICAgbGV0IGxpc3RpID0gbGlzdC5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBzb3VyY2Uua2V5KTtcblxuICAgICAgICAgICAgbGV0IHNlYXJjaHNvcnQgPSBOdW1iZXIoZ2V0SXRlbShcInNlYXJjaHNvcnRcIiwgXCIwXCIpKTtcbiAgICAgICAgICAgIGxldCB7XG4gICAgICAgICAgICAgIG5hdHVyYWxTb3J0LFxuICAgICAgICAgICAgICB1c2luZ1NvcnRcbiAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXCJtZXRob2RzXCIpO1xuXG4gICAgICAgICAgICBpZiAoc2VhcmNoc29ydCA+IDApIHtcbiAgICAgICAgICAgICAgaWYgKHNlYXJjaHNvcnQgPT0gMSkge1xuICAgICAgICAgICAgICAgIG5hdHVyYWxTb3J0KGxpc3QsIFwibmFtZVwiKTtcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChzZWFyY2hzb3J0ID09IDIpIHtcbiAgICAgICAgICAgICAgICB1c2luZ1NvcnQuc2V0a2V5KFwibmFtZVwiKTtcbiAgICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHNvdXJjZS5zZWFyY2hhYmxlICYmIGxpc3RpICE9IC0xKSB7XG4gICAgICAgICAgICAgIGxpc3Quc3BsaWNlKGxpc3QuaW5kZXhPZihzb3VyY2UpLCAxKTtcbiAgICAgICAgICAgICAgbGlzdC51bnNoaWZ0KHNvdXJjZSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGxldCBydWxlcyA9IFtdO1xuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xuICAgICAgICAgICAgICBydWxlcy5wdXNoKHtcbiAgICAgICAgICAgICAgICB0aXRsZTogaXQubmFtZSxcbiAgICAgICAgICAgICAgICBzZWFyY2hfdXJsOiBcImhpa2VyOi8vZW1wdHk/cGFnZT1meXBhZ2Umc2VhcmNoVGVybXM9KipcIixcbiAgICAgICAgICAgICAgICBzZWFyY2hGaW5kOiBcImpzOlwiICsgJC50b1N0cmluZygoaXRlbSkgPT4ge1xuICAgICAgICAgICAgICAgICAgbGV0IHtcbiAgICAgICAgICAgICAgICAgICAgdWlfY29uZmlnLFxuICAgICAgICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcIlVJTWFuYWdlXCIpO1xuICAgICAgICAgICAgICAgICAgdWlfY29uZmlnPXVpX2NvbmZpZy55aTtcbiAgICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgICAgIGxldCBkcnB5ID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKS5nZXQoaXRlbS5rZXkpO1xuICAgICAgICAgICAgICAgICAgbGV0IGhvbWVMaXN0ID0gSlNPTi5wYXJzZShkcnB5LnNlYXJjaChNWV9LRVlXT1JELCBmYWxzZSwgTVlfUEFHRSkpLmxpc3QgfHwgW107XG4gICAgICAgICAgICAgICAgICBsZXQgc2tpcEVyID0gZHJweS5nZXRSdWxlKFwi5LqM57qnXCIpID09PSBcIipcIiAmJiBnZXRJdGVtKFwic2tpcEVyXCIsIFwiXCIpO1xuICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTtcbiAgICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGhvbWVMaXN0KSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBjaWQ7XG4gICAgICAgICAgICAgICAgICAgIGxldCBpZCA9IFN0cmluZyhpdC52b2RfaWQpO1xuICAgICAgICAgICAgICAgICAgICBsZXQgdXJsID0gXCJoaWtlcjovL3BhZ2UvZGV0YWlsZWRcIit1aV9jb25maWcubWFyaztcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNraXBFcikge1xuICAgICAgICAgICAgICAgICAgICAgIHVybCA9ICQoKS5sYXp5UnVsZSgoc291cmNlLCBpZCwgbXkpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1cmw7XG4gICAgICAgICAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkcnB5ID0gRHJweU1hbmFnZS5nZXRCeVNvdXJjZShzb3VyY2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBKU09OLnBhcnNlKGRycHkuZGV0YWlsKGlkKSkubGlzdFswXS52b2RfcGxheV91cmwuc3BsaXQoXCIkXCIpWzFdOyAgICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKGUubWVzc2FnZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHVybCA9IGlkLnNwbGl0KFwiQEBcIilbMF07XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVzdWx0O1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gJC5yZXF1aXJlKFwidmlkZW9VcmxcIikucGFyc2UodXJsLCBpZCwgc291cmNlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIC8vbG9nKGVycm9yLm1lc3NhZ2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgICAgICAgICAgICB9LCBpdGVtLCBpZCxNWV9SVUxFLl90aXRsZSk7XG4gICAgICAgICAgICAgICAgICAgICAgY2lkID0gaWQ7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC52b2RfbmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcbiAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBpdC52b2RfY29udGVudCxcbiAgICAgICAgICAgICAgICAgICAgICB1cmw6IHVybCxcbiAgICAgICAgICAgICAgICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbF90eXBlOiBcIm1vdmllXzNcIixcbiAgICAgICAgICAgICAgICAgICAgICBleHRyYToge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IGNpZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZvZElkOiBpZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGlzUG9seW1lcml6ZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICAgIHNuYW1lOiBpdGVtLm5hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBza2V5OiBpdGVtLmtleSxcbiAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgc2V0UmVzdWx0KGQpO1xuICAgICAgICAgICAgICAgIH0sIGl0KVxuICAgICAgICAgICAgICB9KTt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lbCA/IFxcXCJoaWtlcjovL3BhZ2Uvbm92ZWwjYXV0b1BhZ2UjI3JlYWRUaGVtZSNcXFwiIDogKHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0gKyBwbGF5TGF6eSksXFxuICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgIGltZzogaW1nLFxcbiAgICAgICAgICAvKmV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBleHRyYSwge1xcbiAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgIGlkOiBrWzFdLFxcbiAgICAgICAgICAgIC8vbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgfSkqL1xcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxuICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsXFxuICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaWR1XFxcXC5jb21cXFxcL2htLmpzXFxcIl0sXFxuICAgICAgICAgICAgdmlkZW9FeGNsdWRlUnVsZXM6IFsnP3VybD0nXSxcXG4gICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9XFxuICAgICAgICB9O1xcbiAgICAgIH0pO1xcblxcbiAgICAgIGlmICgoc3R5cGUgPT0gXFxcIua8q+eUu1xcXCIgfHwgc3R5cGUgPT0gXFxcIuWwj+ivtFxcXCIpICYmIGkg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4gICAgICAgIH0pO1xcbiAgICAgICAgd3JpdGVGaWxlKFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9kcl9kb3dfbGlzdC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoY2hhcHRlckxpc3QpKTtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgIHRpdGxlOiBcXFwi5LiL6L29XFxcIiArIHN0eXBlLFxcbiAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvZG93bmxvYWQudmlldyNub1JlY29yZEhpc3RvcnkjI25vUmVmcmVzaCM/cnVsZT3mnKzlnLDotYTmupDnrqHnkIYnLFxcbiAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGNoYXB0ZXJMaXN0OiBcXFwiaGlrZXI6Ly9maWxlcy9fY2FjaGUvZHJfZG93X2xpc3QuanNvblxcXCIsXFxuICAgICAgICAgICAgaW5mbzoge1xcbiAgICAgICAgICAgICAgYm9va05hbWU6IGluZm8udm9kX25hbWUsIC8v5ryr55S75ZCN56ewLFxcbiAgICAgICAgICAgICAgcnVsZU5hbWU6IE1ZX1JVTEUudGl0bGUsXFxuICAgICAgICAgICAgICBib29rVG9wUGljOiBpbmZvLnZvZF9waWMsXFxuICAgICAgICAgICAgICBwYXJzZUNvZGU6IGRvd25sb2FkbGF6eSxcXG4gICAgICAgICAgICAgIGJvb2tJZDogTVlfUEFSQU1TLnNuYW1lLFxcbiAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBkZWZhdWx0VmlldzogXFxcIjFcXFwiXFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgdGl0bGU6IFxcX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dHlwZTogJ3RleHRfMScsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwYWdlbmF2XFxcIlxcbiAgICAgICAgfVxcbiAgICAgIH1cXG5cXG4gICAgICB0cGxheSA9IHBsYXlwLm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgbGV0IG9iaiA9IE9iamVjdC5hc3NpZ24oe30sIHRlbXAsIHtcXG4gICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgKHBhZ2VudW0gPT0gaSA/IHguZm9udGNvbG9yKGVyLue6v+i3r+minOiJsikgOiB4KSxcXG4gICAgICAgICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXG4gICAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChpLCBpZCwgcGFnZW51bSkgPT4ge1xcbiAgICAgICAgICAgIGxldCBsb2NhdGlvbiA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgIGlmIChnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIHBhZ2VudW0pID09IGkpIHtcXG4gICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgIGxldCBlcnIgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5lclJlZnJlc2g7XFxuICAgICAgICAgICAgcmV0dXJuIGVycihsb2NhdGlvbik7XFxuICAgICAgICAgIH0sIGksIGlkLCBwYWdlbnVtKSxcXG4gICAgICAgICAgZXh0cmE6IE9iamVjdC5hc3NpZ24oe30sIHRlbXAuZXh0cmEsIHtcXG4gICAgICAgICAgICBpZDogXFxcInBhZ2VudW1cXFwiICsgaSxcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH0pXFxuICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgIH0pXFxuXFxuICAgICAgbGV0IGZjID0gXFxcIlxcXCI7XFxuICAgICAgaWYgKCEocGxheXAgJiYgcGxheXAubGVuZ3RoID4gMSkpIHtcXG4gICAgICAgIGZjID0gXFxcImdyZXlcXFwiO1xcbiAgICAgIH1cXG5cXG4gICAgICBsZXQgcGFnZW9iaiA9IFt7XFxuICAgICAgICB0aXRsZTogZm9udHN0eWxlKCfkuIrkuIDpobUnLCB7XFxuICAgICAgICAgIGM6IGZjXFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQsIHBjb3VudCwgcGFnZW51bSkgPT4ge1xcbiAgICAgICAgICBsZXQgbG9jYXRpb24gPSBnZXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgXFxcIjBcXFwiKTtcXG4gICAgICAgICAgbGV0IGVmID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZ2V0RUluZm8oKTtcXG4gICAgICAgICAgbGV0IHBjb3VudCA9IGVmLm1heFtsb2NhdGlvbl07XFxuICAgICAgICAgIGxldCBwYWdlbnVtID0gZWYucGFnZW51bTtcXG4gICAgICAgICAgaWYgKHBjb3VudCA9PSAxKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAocGFnZW51bSA9PSAwKSB7XFxuICAgICAgICAgICAgcGFnZW51bSA9IHBjb3VudCAtIDE7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgcGFnZW51bS0tO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHB1dE15VmFyKFxcXCJwYWdlbnVtXFxcIiwgU3RyaW5nKHB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hbmFnZVxcXCIpLnVpX2NvbmZpZy5lcjtcXG4gICAgICAgICAgZXIu57q/6Lev5qC35byPID0gZXIu57q/6Lev5qC35byPfHwnc2Nyb2xsX2J1dHRvbic7XFxuICAgICAgICAgIGxldCBwYWdlYXJyID0gcGxheXAubWFwKCh4LCBpKSA9PiBpID09IHBhZ2VudW0gPyAn4oCc4oCc4oCd4oCdJyArIHguZm9udGNvbG9yKGVyLue6v+i3r+minOiJsikgOiB4KTtcXG4gICAgICAgICAgcmV0dXJuICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbiwgZXIpID0+IHtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgICAgICAgIGlmIChlci7kuoznuqfliLfmlrApIHtcXG4gICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInBsYXlsaXN0X3JlYWR5XFxcIik7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4geyB9KShsb2NhdGlvbik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH0sIGxvY2F0aW9uLCBlcilcXG4gICAgICAgIH0sIGlkLCBwYWdlbnVtKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZUBwYWdlYXJyXFxcIixcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogZm9udHN0eWxlKCfkuIvkuIDpobUnLCB7XFxuICAgICAgICAgIGM6IGZjXFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF80XFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQpID0+IHtcXG4gICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGVmLnBhZ2VudW07XFxuICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgaWYgKHBhZ2VudW0gPj0gcGNvdW50IC0gMSkge1xcbiAgICAgICAgICAgIHBhZ2VudW0gPSAwO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHBhZ2VudW0rKztcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgIGxldCBlcnIgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5lclJlZnJlc2g7XFxuICAgICAgICAgIHJldHVybiBlcnIobG9jYXRpb24pO1xcbiAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiLFxcbiAgICAgICAgICBpZDogXFxcInBsYXlwYWdlQG5leHRcXFwiXFxuICAgICAgICB9XFxuICAgICAgfV1cXG5cXG4gICAgICBpZiAoZXIu5YiG6aG15a+86IiqKSB7XFxuICAgICAgICBwYWdlb2JqID0gcGFnZW9iai5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FwicGxheXBhZ2VAbmV4dFxcXCIsIHtcXG4gICAgICAgICAgICB0aXRsZTogcGFnZW9ialsyXS50aXRsZSxcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChlci7liIbpobXlr7zoiKopIHtcXG4gICAgICAgICAgaWYgKCFlci7kuoznuqfliLfmlrApIHtcXG4gICAgICAgICAgICBsZXQgcG4gPSBmaW5kSXRlbXNCeUNscyhcXFwicGFnZW5hdlxcXCIpXFxuICAgICAgICAgICAgaWYgKHBuLmxlbmd0aCA+IHBsYXlwLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgcG4gPSBwbi5zbGljZShwbGF5cC5sZW5ndGgpXFxuICAgICAgICAgICAgICBwbi5tYXAoeCA9PiB7XFxuICAgICAgICAgICAgICAgIGRlbGV0ZUl0ZW0oeC5leHRyYS5pZClcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChwbi5sZW5ndGggPCBwbGF5cC5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgIGxldCBwaWQgPSBwbi5hdCgtMSk7XFxuICAgICAgICAgICAgICBsZXQgYWRkID0gdHBsYXkuc2xpY2UocG4ubGVuZ3RoKTtcXG4gICAgICAgICAgICAgIGFkZEl0ZW1BZnRlcihwaWQuZXh0cmEuaWQsIGFkZCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHRwbGF5LmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcInBhZ2VudW1cXFwiICsgaSwge1xcbiAgICAgICAgICAgICAgICB0aXRsZTogeC50aXRsZSxcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgIH1cXG5cXG4gICAgICAvLyBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIFt7XFxuICAgICAgLy8gICB0aXRsZTogJ+S4iuS4gOmhtScsXFxuICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgLy8gICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAvLyAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgLy8gICAgIGlmIChwYWdlbnVtID09IDApIHtcXG4gICAgICAvLyAgICAgICBwYWdlbnVtID0gcGNvdW50IC0gMTtcXG4gICAgICAvLyAgICAgfSBlbHNlIHtcXG4gICAgICAvLyAgICAgICBwYWdlbnVtLS07XFxuICAgICAgLy8gICAgIH1cXG4gICAgICAvLyAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIC8vICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgLy8gICBleHRyYToge1xcbiAgICAgIC8vICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAvLyAgIH1cXG4gICAgICAvLyB9LCB7XFxuICAgICAgLy8gICB0aXRsZTogcGxheXBbcGFnZW51bV0sXFxuICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgLy8gICB1cmw6ICQocGFnZWFyciwgMykuc2VsZWN0KChsb2NhdGlvbikgPT4ge1xcbiAgICAgIC8vICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhNWV9JTkRFWCkpO1xcbiAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgICAgLy8gICB9LCBsb2NhdGlvbiksXFxuICAgICAgLy8gICBleHRyYToge1xcbiAgICAgIC8vICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAvLyAgIH1cXG4gICAgICAvLyB9LCB7XFxuICAgICAgLy8gICB0aXRsZTogJ+S4i+S4gOmhtScsXFxuICAgICAgLy8gICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgLy8gICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGxvY2F0aW9uLCBwY291bnQpID0+IHtcXG4gICAgICAvLyAgICAgbGV0IHBhZ2VudW0gPSBnZXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgLy8gICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAvLyAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAvLyAgICAgfSBlbHNlIHtcXG4gICAgICAvLyAgICAgICBwYWdlbnVtKys7XFxuICAgICAgLy8gICAgIH1cXG4gICAgICAvLyAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgIC8vICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgIC8vICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIC8vICAgfSwgbG9jYXRpb24sIHBjb3VudCksXFxuICAgICAgLy8gICBleHRyYToge1xcbiAgICAgIC8vICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCJcXG4gICAgICAvLyAgIH1cXG4gICAgICAv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xcIlxcXCI7XFxuICAgICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IChpID09IGNpID8gZm9udHN0eWxlKGZyb21baV0sIHtcXG4gICAgICAgICAgICAgIGM6IGVyLue6v+i3r+minOiJsixcXG4gICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICB9LCBlci7nur/ot6/moLflvI8pIDogZm9udHN0eWxlKGZyb21baV0sIHtcXG4gICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICB9LCBlci7nur/ot6/moLflvI8pKSxcXG4gICAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGksIGlkKSA9PiB7XFxuICAgICAgICAgICAgICBpZiAoZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIikgPT0gaSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgcHV0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFN0cmluZyhpKSk7XFxuICAgICAgICAgICAgICBsZXQgZXJyID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZXJSZWZyZXNoO1xcbiAgICAgICAgICAgICAgZXJyKGkpO1xcbiAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9LCBpLCBpZCksXFxuICAgICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICAgIGNsczogXFxcImxvY2F0aW9uQFxcXCIsXFxuICAgICAgICAgICAgICBpZDogXFxcImxvY2F0aW9uQFxcXCIgKyBpXFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBpbWc6IGljb25pbWcsXFxuICAgICAgICAgICAgY29sX3R5cGU6IGVyLue6v+i3r+agt+W8j1xcbiAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICB9IGVsc2Uge1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgdGl0bGU6IGZyb21bY2ldLFxcbiAgICAgICAgICBkZXNjOiBmcm9tLmxlbmd0aCArIFxcXCLmnaHnur/ot69cXFwiLFxcbiAgICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkKSA9PiB7XFxuICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgIGZvbnRzdHlsZSxcXG4gICAgICAgICAgICAgIGdldEVJbmZvLFxcbiAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKTtcXG4gICAgICAgICAgICBsZXQgZWYgPSBnZXRFSW5mbygpO1xcblxcbiAgICAgICAgICAgIGxldCBmcm9tID0gZWYuZnJvbTtcXG4gICAgICAgICAgICBsZXQgbWF4ID0gZWYucGxheXM7XFxuXFxuICAgICAgICAgICAgbGV0IGNpID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgICAgbGV0IHNob3dpID0gZ2V0TXlWYXIoXFxcInNob3dpXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGxldCB0ZnJvbSA9IGZyb20ubWFwKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gY2kgPT0gaSA/IGZvbnRzdHlsZSh4ICsgXFxcIltcXFwiICsgbWF4W2ldICsgXFxcIl1cXFwiLCB7XFxuICAgICAgICAgICAgICAgIGM6ICQuZXJfdWku57q/6Lev6aKc6ImyLFxcbiAgICAgICAgICAgICAgICB0YWdzOiBcXFwic21hbGxcXFwiXFxuICAgICAgICAgICAgICB9KSA6IGZvbnRzdHlsZSh4ICsgXFxcIltcXFwiICsgbWF4W2ldICsgXFxcIl1cXFwiLCB7XFxuICAgICAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBpZiAoc2hvd2kgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJzaG93aVxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICBsZXQgc2hvdyA9IDE7XFxuICAgICAgICAgICAgICBsZXQgbnVtID0gdGZyb20ubGVuZ3RoO1xcbiAgICAgICAgICAgICAgaWYgKG51bSA8IDgpIHtcXG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAobnVtID4gOCAmJiBudW0gPD0gMTIpIHtcXG4gICAgICAgICAgICAgICAgc2hvdyA9IDI7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBzaG93ID0gMztcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIFxcbiAgICAgICAgICAgICAgcmV0dXJuICQodGZyb20sIHNob3cpLnNlbGVjdCgoY2ksIGYsIGlkKSA9PiB7XFxuICAgICAgICAgICAgICAgIE1ZX1VSTD1cXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICAgICAgZXJSZWZyZXNoXFxuICAgICAgICAgICAgICAgIH09JC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIik7XFxuICAgICAgICAgICAgICAgIFxcbiAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgIGZpbmRJY29uXFxuICAgICAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNfZXJcXFwiKTtcXG4gICAgICAgICAgICAgICAgXFxuICAgICAgICAgICAgICAgIGxldCBpID0gTVlfSU5ERVg7XFxuICAgICAgICAgICAgICAgIGlmIChpID09IGNpKSB7XFxuICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgbmFtZSA9IGZbaV07XFxuICAgICAgICAgICAgICAgIHB1dE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICAgICBlclJlZnJlc2goaSk7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBpY29uaW1nID0gZmluZEljb24obmFtZSwgJC5lcl91aSk7XFxuXFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcImxvY2F0aW9uQFxcXCIsIHtcXG4gICAgICAgICAgICAgICAgICB0aXRsZTogbmFtZSxcXG4gICAgICAgICAgICAgICAgICBpbWc6IGljb25pbWcsXFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInNob3dpXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICB9LCBjaSwgZnJvbSwgaWQpXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInNob3dpXFxcIik7XFxuICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfSwgaWQpLFxcbiAgICAgICAgICBpbWc6IGVyLue6v+i3r+agt+W8jy5pbmNsdWRlcyhcXFwic2VsZWN0XFxcIikgPyBmaW5kSWNvbihmcm9tW2NpXSkgOiBcXFwiXFxcIixcXG4gICAgICAgICAgY29sX3R5cGU6ICdhdmF0YXInLFxcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBcXFwibG9jYXRpb25AXFxcIlxcbiAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgIH1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AgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJzaGFyZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBydWxlcztcXG4gICAgICAgICAgICBpZiAobW8gPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0yKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0VXNlZnVsSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW8gPT09IC0zKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0Rm9yYmlkZGVuSnNvbigpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpLmZpbHRlcigodiwgaSkgPT4gaW5kZXhzLmluY2x1ZGVzKGkpKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcnVsZXMgPSBydWxlcy5tYXAoKHYpID0+IHtcXG4gICAgICAgICAgICAgICAgdi5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIHJldHVybiB2O1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHJldHVybiB1cChydWxlcyk7XFxuICAgICAgICB9LCBtbywgaW5kZXhzLCBpbmRleGNbMV0pO1xcblxcbiAgICB9LCBsZW5ndGgpLFxcbiAgICBjb2xfdHlwZTogXFxcImljb25fc21hbGxfNFxcXCIsXFxuICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX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hZ2lcXFwiLCBbXFxcIuWFqOmDqFxcXCJdKTtcXG4gICAgICAgICAgICBpZiAoLyjlhajpg6h85bey56aB55SoKS8udGVzdChmKSkge1xcbiAgICAgICAgICAgICAgICBmbGFnaSA9IFtmXVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGZsYWdpID0gZmxhZ2kuZmlsdGVyKHggPT4gIS8o5YWo6YOofOW3suemgeeUqCkvLnRlc3QoeCkpO1xcbiAgICAgICAgICAgICAgICBpZiAoZmxhZ2kuaW5jbHVkZXMoZikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGZsYWdpID0gZmxhZ2kuZmlsdGVyKHggPT4geCAhPSBmKTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChmbGFnaS5sZW5ndGggPT0gMCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdpID0gW1xcXCLlhajpg6hcXFwiXVxcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgZmxhZ2kucHVzaChmKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJmbGFnaVxcXCIsIGZsYWdpKTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBmKVxcbiAgICB9KVxcbn0pXFxuZm9yIChsZXQgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykge1xcbiAgICBsZXQgaXQgPSBhcnJbaV07XFxuXFxuICAgIGxldCBmbGFnID0gaXQuZmxhZy5zcGxpdChcXFwifFxcXCIpO1xcbiAgICBpZiAoZmxhZ2kubGVuZ3RoID4gMCAmJiAhW1xcXCLlhajpg6hcXFwiLCBcXFwi5bey56aB55SoXFxc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3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCBydWxlYjY0LCBcXFwiYVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdSA9IHNoYXJlUGFzdGUocnVsZWI2NCwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgdSwgXFxcImJcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnp7vliqhcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKGluZGV4ICsgXFxcIlxcXCIsIFxcXCLovpPlhaXkvY3nva5cXFwiKS5pbnB1dCgoaW5kZXgsIGxlbmd0aCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gTnVtYmVyKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obmV3SW5kZXgpIHx8IG5ld0luZGV4ID49IGxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kuI3lkozop4TnmoTkvY3nva5cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgsIGxlbmd0aCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIue9rumhtlxcXCIpIHtcXG4gICAgICAgICAgICAgICAgbGV0IG5ld0luZGV4ID0gMDtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaTvvJ9cXFwiKS5jb25maXJtKChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGVzID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO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ZvaWQgMDtcXG4gICAgICAgICAgICBsZXQganMgPSBnZXRNeVZhcihcXFwicHNfanNcXFwiLCBcXFwiXFxcIikgfHwgdm9pZCAwO1xcbiAgICAgICAgICAgIGlmIChoZWFkZXJzKSB7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzID0gSlNPTi5wYXJzZShoZWFkZXJzKTtcXG4gICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoZWFkZXJz5qC85byP6ZSZ6K+vOlxcXCIgKyBlLnRvU3RyaW5nKCk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwidmlkZW9VcmxcXFwiKS5wcmVwYXJlUGFyc2VzKFt7XFxuICAgICAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICAgICAganNcXG4gICAgICAgICAgICB9XSwgaW5wdXQsbnVsbCwgdHJ1ZSk7XFxuICAgICAgICB9KTtcXG4gICAgfSksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuS/neWtmFxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaW5kZXgsIGlzSW1wb3J0KSA9PiB7XFxuICAgICAgICBsZXQgbmFtZSA9IGdldE15VmFyKFxcXCJwc19uYW1lXFxcIiwgXFxcIlxcXCIpLnRyaW0oKTtcXG4gICAgICAgIGlmICghbmFtZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lkI3lrZflvpfmnInkuIDkuKrlkKdcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IHVybCA9IGdldE15VmFyKFxcXCJwc191cmxcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKCF1cmwpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6Kej5p6Q5Zyw5Z2A5LiN6IO95Li656m6XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBmbGFnID0gZ2V0TXlWYXIoXFxcInBzX2ZsYWdcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICBpZiAoIWZsYWcpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6Kej5p6Q5Zyw5Z2A5qCH6K+G5LiN6IO95Li656m6XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBoZWFkZXJzID0gZ2V0TXlWYXIoXFxcInBzX2hlYWRlcnNcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKGhlYWRlcnMpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICBoZWFkZXJzID0gSlNPTi5wYXJzZShoZWFkZXJzKTtcXG4gICAgICAgICAgICAgICAgaWYodHlwZW9mIGhlYWRlcnMhPT1cXFwib2JqZWN0XFxcIikgdGhyb3cgbmV3IEVycm9yKFxcXCLplJnor6/nsbvlnovvvIzlv4XpobvkuLpPYmplY3RcXFwiKTtcXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBydW5UeXBlID0gZ2V0TXlWYXIoXFxcInBzX3J1blR5cGVcXFwiLCBcXFwiV0VCXFxcIik7XFxuICAgICAgICBsZXQgbWV0aG9kID0gZ2V0TXlWYXIoXFxcInBzX21ldGhvZFxcXCIsIFxcXCJHRVRcXFwiKTtcXG4gICAgICAgIGxldCBqc29uUGF0aCA9IGdldE15VmFyKFxcXCJwc19qc29uUGF0aFxcXCIsIFxcXCJcXFwiKS50cmltKCkgfHwgdm9pZCAwO1xcbiAgICAgICAgbGV0IGpzID0gZ2V0TXlWYXIoXFxcInBzX2pzXFxcIiwgXFxcIlxcXCIpIHx8IHZvaWQgMDtcXG4gICAgICAgIGlmIChydW5UeXBlID09PSBcXFwiSlNPTlxcXCIgJiYgIWpzb25QYXRoKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pTT07mqKHlvI/kuIvlv4Xpobvloatqc29uUGF0aFxcXCI7XFxuICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT09IFxcXCJKU1xcXCIgJiYgIWpzKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL0pT5qih5byP5LiL5b+F6aG75aGranNcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBvYmoxID0ge1xcbiAgICAgICAgICAgIG5hbWUsXFxuICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgaGVhZGVycyxcXG4gICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICBqc29uUGF0aCxcXG4gICAgICAgICAgICBqc1xcbiAgICAgICAgfTtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIGlmIChhcnIuc29tZSh2ID0+IHYubmFtZSA9PT0gbmFtZSkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChvYmoxLmdyb3VwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBncm91cCA9IG9iajEuZ3JvdXA7XFxuICAgICAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lmdyb3VwID09PSBncm91cCk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMCwgb2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBpZiAoaXNJbXBvcnQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5wdXNoKG9iajEpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGxldCBuYW1leSA9IGFycltpbmRleF0ubmFtZTtcXG4gICAgICAgICAgICBpZiAobmFtZSAhPT0gbmFtZXkpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+W3sue7j+WtmOWcqOivpeino+aekFxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgb2JqMSA9IE9iamVjdC5hc3NpZ24o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yc2UoKTtcXG4gICAgICAgIE1ZX1VSTCA9IG1vZHVsZS5pZDtcXG4gICAgICAgIGxldCBydWxlVGl0bGUgPSBnZXRQYXJhbShcXFwicnVsZVxcXCIpO1xcbiAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLmdldEpzb24oKTtcXG4gICAgICAgIGxldCBuZXdJID0gMDtcXG4gICAgICAgIGZvciAobGV0IHJ1bGUgb2YgcnVsZXMpIHtcXG4gICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgIGlmIChpbmRleCA+IC0xKSB7XFxuICAgICAgICAgICAgICAgIHJ1bGUgPSBPYmplY3QuYXNzaWduKGFycltpbmRleF0sIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmaW5kZXg9XFxcIiArIGluZGV4ICsgXFxcIiZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIG5ld0krKztcXG4gICAgICAgICAgICAgICAgYXJyLnB1c2gocnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA+IDEpIHtcXG4gICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5zYXZlSnNvbihhcnIpO1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLmlrDlop7vvJpcXFwiICsgbmV3SSArIFxcXCIg6KaG55uW5pu05paw77yaXFxcIiArIChydWxlcy5sZW5ndGggLSBuZXdJKSk7XFxuICAgICAgICB9XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgdG9hc3QoXFxcIuWvvOWFpeWksei0pVxcXCIpO1xcbiAgICB9XFxufVxcblxcbmZ1bmN0aW9uIGltcG9ydFJ1bGUocGFzcykge1xcbiAgICB0cnk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pIGNvbnRpbnVlO1xcbiAgICAgICAgICAgIG5hbWUgPSBuYW1lLnNsaWNlKDAsIG5hbWUubGFzdEluZGV4T2YoXFxcIi5cXFwiKSk7XFxuICAgICAgICAgICAgbGV0IHJ1bGUgPSBmZXRjaChgaHR0cHM6Ly9yYXcuZ2l0bWlycm9yLmNvbS8ke3JvcGV9L21hc3Rlci8ke3NwYXRofWApO1xcbiAgICAgICAgICAgIGlmICghKCghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSAmJiAhZmlsZUV4aXN0KHBhdGggKyBpdC5uYW1lKSkpIHtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAgICAgICAgICdhcGknOiAnLi4vbGlicy9kcnB5Mi5qcycsXFxuICAgICAgICAgICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAncXVpY2tTZWFyY2gnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2ZpbHRlcmFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IFxcXCIuL1xcXCIgKyBpdC5uYW1lLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgXFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBuYW1lcy5wdXNoKGl0Lm5hbWUpO1xcbiAgICB9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IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghZmlsZUV4aXN0KHBhdGggKyBuYW1lKSlcXG4gICAgICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGksIDEpO1xcbiAgICAgICAgICAgICAgICAgICAgY29udGludWU7XFxuICAgICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgbmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIG5hbWVzLnB1c2gobmFtZSk7XFxuICAgICAgICAgICAgICAgIGNvdW50Kys7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaSsrO1xcbiAgICB9XFxuICAgIGRlbGV0ZWxvc2UobmFtZXMsIHBhdGgpO1xcbiAgICB3cml0ZUZpbGUocGF0aCArIFxcXCJpbmRleC5qc29uXFxcIiwgSlNPTi5zdHJpbmdpZnkoanNvbikpO1xcbiAgICAvL3dyaXRlRmlsZShwYXRoLnJlcGxhY2UoL1xcXFwuanMkLywnLmpzb24nKSwgSlNPTi5zdHJpbmdpZnkoanNvbikpO1xcbiAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oiQ5Yqf5pu05pawXFxcIiArIGNvdW50ICsgXFxcIuS4qlxcXCI7XFxufVxcbiQuZXhwb3J0cy5wYXJzZVVybCA9IGZ1bmN0aW9uICh1cmwsIHBhdGgpIHtcXG4gICAgcGF0aCA9IGJhc2U2NERlY29kZShwYXRoKTtcXG4gICAgcGF0aCA9IHBhdGguZW5kc1dpdGgoXFxcIi9cXFwiKSA/IHBhdGggOiBwYXRoICsgXFxcIi9cXFwiO1xcbiAgICB0cnkge1xcbiAgICAgICAgaWYgKHVybC5zdGFydHNXaXRoKFxcXCJodHRwczovL2dpdGh1Yi5jb20vaGpkaG54L1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV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l0ZXMpIHx8ICFqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBpZiAoanNvbi5oYXNPd25Qcm9wZXJ0eShcXFwic2l0ZXNcXFwiKSAmJiBqc29uLnNpdGVzLmhhc093blByb3BlcnR5KFxcXCJkYXRhXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgIGpzb24uc2l0ZXMgPSBqc29uLnNpdGVzLmRhdGE7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXFxcIuS7jue9kee7nOiOt+WPlueahOmFjee9ruaWh+S7tuS4uuepuu+8jOivt+ajgOafpee9kee7nFxcXCIpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHNvdXJjZUxpc3QgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKTtcXG4gICAgICAgICAgICBpZiAoc291cmNlTGlzdFswXS5oYXNPd25Qcm9wZXJ0eShcXFwiaWRcXFwiKSkge1xcbiAgICAgICAgICAgICAgICBzb3VyY2VMaXN0ID0gc291cmNlTGlzdC5tYXAoaXRlbSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS5oYXNPd25Qcm9wZXJ0eShcXFwiaWRcXFwiKSAmJiAhaXRlbS5oYXNPd25Qcm9wZXJ0eShcXFwia2V5XFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBpdGVtW1xcXCJrZXlcXFwiXSA9IGl0ZW1bXFxcImlkXFxcIl07XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgY29uZmlnLnR5cGUgPSBcXFwiaW5kZXhcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgZmlsZSA9IHZvaWQgMDtcXG4gICAgICAgIGxldCBjdXJyZW50U291cmNlLCBzZWFyY2hBbGxvdztcXG4gICAgICAgIGlmIChjb25maWcuY0tleSkge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0LmZpbmQodiA9PiB2LmtleSA9PT0gY29uZmlnLmNLZXkpO1xcbiAgICAgICAgICAgIGlmICghY3VycmVudFNvdXJjZSkge1xcbiAgICAgICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAgICAgLy9jdXJyZW50Q29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgIC8vY29uZmlnLmNLZXkgPSBzb3VyY2VMaXN0WzBdLmtleTtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBKU09OLnBhcnNlKGZldGNoKHNlYXJjaEFsbG93UGF0aCkgfHwgXFxcIltdXFxcIik7XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgZGVsZXRlRmlsZShzZWFyY2hBbGxvd1BhdGgpO1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gW107XFxuICAgICAgICB9XFxuICAgICAgICBsb2FkRXJyb3IgPSB2b2lkIDA7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UsXFxuICAgICAgICAgICAgc2VhcmNoQWxsb3csXFxuICAgICAgICAgICAgc291cmNlTGlzdFxcbiAgICAgICAgfTtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICBsb2FkRXJyb3IgPSBlO1xcbiAgICB9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GVzLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gaXQua2V5KTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkgY29udGludWU7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtID0gcnVsZXNbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UoaW5kZXgsIDAsIE9iamVjdC5hc3NpZ24oe30sIGl0ZW0sIHtcXG4gICAgICAgICAgICAgICAgICAgICdrZXknOiBgaGlweV9qc18ke2l0LnRva2V5fWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke2l0LnRva2V5fWAsXFxuICAgICAgICAgICAgICAgICAgICAnZXh0JzogaXRlbS5leHQgKyBcXFwiP1xcXCIgKyBpdC5wYXJhbXMsXFxuICAgICAgICAgICAgICAgICAgICBkZWw6IHZvaWQgMFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIGl0ZW0uZGVsID0gdHJ1ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcnVsZXMgPSBydWxlcy5maWx0ZXIodiA9PiAhdi5kZWwpO1xcbiAgICAgICAgfVxcbiAgICB9IGNhdGNoIChlKSB7XFxuXFxuICAgIH1cXG4gICAgcmV0dXJuIHJ1bGVzO1xcbn1cXG5cXG5mdW5jdGlvbiBnZXRMb2FjbE1hcHBpbmcoZGlyRmlsZSkge1xcbiAgICAvL2tleUBwYXJhbXNAdHlwZVxcbiAgICBsZXQgbWFwcGluZ1BhdGggPSBcXFwiZmlsZTovL1xcXCIgKyBqb2luVXJsKGRpckZpbGUsIFxcXCIuL1xcXCIpICsgXFxcIi8ubWFwcGluZy50eHRcXFwiO1xcbiAgICBsZXQgbWFwcGluZyA9IFtdO1xcbiAgICBpZiAoIWZpbGVFeGlzdChtYXBwaW5nUGF0aCkpIHJldHVybiBtYXBwaW5nO1xcbiAgICB0cnkge1xcbiAgICAgICAgbGV0IG1hcHBpbmdUe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AgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgZmlsZS5saXN0RmlsZXMoKSkge1xcbiAgICAgICAgICAgICAgICAgICAgbmFtZXMucHVzaChTdHJpbmcoaXQuZ2V0TmFtZSgpKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgZGlybmFtZShwYSkge1xcbiAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IGpvaW5VcmwoanNQYXRoLCBwYSk7XFxuICAgICAgICAgICAgICAgIGxldCBuYW1lcyA9IFtdO1xcbiAgICAgICAgICAgICAgICBsZXQgZmlsZSA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxuXFxuICAgICAgICAgICAgICAgIGlmICghKGZpbGUuZXhpc3RzKCkgJiYgZmlsZS5pc0RpcmVjdG9yeSgpKSkgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBkaXJGaWxlLmxpc3RGaWxlcygpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoaXQuaXNEaXJlY3RvcnkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKFN0cmluZyhpdC5nZXROYW1lKCkpKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gcGF0aHM7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBzdGF0KCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgICAgbG9nOiBsb2csXFxuICAgICAgICBwYXRoOiBqc1BhdGgsXFxuICAgICAgICBwYXRoX2Rpcjogam9pblVybChqc1BhdGgsIFxcXCIuL1xcXCIpXFxuICAgIH0pO1xcbiAgICBsZXQganNvblRle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goaHRtbCwgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpO1xcbiAgICBsZXQganNvbiA9IEpTT04ucGFyc2UoanNvblRleHQpO1xcbiAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcbiAgICBsZXQgcnVsZXMgPSBbXTtcXG4gICAgZm9yIChsZXQgaXQgb2YgbGlzdCkge1xcbiAgICAgICAgbGV0IG5hbWUgPSBpdC5uYW1lO1xcbiAgICAgICAgbGV0IHBhdGggPSBpdC5wYXRoO1xcbiAgICAgICAgaWYgKCFuYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkgY29udGludWU7XFxuICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICduYW1lJzogYCR7bmFtZX1gLFxcbiAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAnZmlsdGVyYWJsZSc6IDEsXFxuICAgICAgICAgICAgJ2V4dCc6IGAke3ByZWZpeH0vJHtyb3BlfS9tYXN0ZXIvJHtwYXRofWAsXFxuICAgICAgICB9KTtcXG4gICAgICAgIC8qXFxuICAgICAgICBodHRwczovL2dpdGh1Yi5jb20vaGpkaG54L2hpcHktc2VydmVyL3RyZWUvbWFzdGVyL2FwcC90NC9maWxlcy9kcnB5X2pzXFxuICAgICAgICBodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vaGpkaG54L2hpcHktc2VydmVyL21hc3Rlci9hcHAvdDQvZmlsZXMvZHJweV9qcy8zNjAlRTUlQ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3J1bGVsaXN0Lmpzb24/aWQ9Njk2NlxcXCIpO1xcbiAgICBsZXQgcG9wID0gaGlrZXJQb3AuaW5mb0JvdHRvbSh7XFxuICAgICAgY29udGVudDogXFxcIuivpue7hlxcXCIsXFxuICAgICAgb3B0aW9uczogW1xcbiAgICAgICAgXFxcIuesrOS4gOepuijlkI3np7ApOuaWueS+v+S4i+asoeaJvuWIsFxcXCIsXFxuICAgICAgICBcXFwi56ys5LqM56m6KOi3r+W+hClb5aGr5pys5Zyw57Si5byV5Zyw5Z2AXTrpgInmi6lKU09OL1VSTOmAiemhue+8jOeCueWHu+aXgei+ueeahOmAieaLqeWPr+S7pea1j+iniOacrOWcsOaWh+S7tumAieaLqeacrOWcsOWMheeahC5qc29u57Si5byV5paH5Lu25Y2z5Y+v44CCXFxcXG4o5rOo5oSP77ya5L2/55So5q2k56eN5pa55byP77yM5Zyo5pys5Zyw5paH5Lu25aS55YaF5paw5aKe5oiW5Yig6ZmkLmpz5rqQ5pe26ZyA6KaB6Ieq6KGM6YWN572uLmpzb27mlofku7YpXFxcIixcXG4gICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzloavov5znqIvlnLDlnYBdOuebtOaOpeWhq+WGmei/nOeoi+mTvuaOpeWNs+WPr+S4gOiIrOaYr+S7pWh0dHDlvIDlpLQuanNvbue7k+Wwvu+8jOS5n+WPr+WPr+S7pei+k+WFpWdpdGh1YuS7k+W6k+eahOaWh+S7tuWkueWcsOWdgOOAguatpOenjeaWueW8j+WPr+S7peS/neaMgeS4jui/nOeoi+mFjee9ruiAheWQjOatpeabtOaWsO+8jOS9huS4jeWmguacrOWcsOW/q+OAglxcXCIsXFxuICAgICAgICBcXFwi56ys5LqM56m6KOi3r+W+hClb5aGr5pys5Zyw5paH5Lu25aS55Zyw5Z2AXTrpgInmi6nmlofku7blpLnpgInpobnvvIzlj6/ku6Xnm7TmjqXovpPlhaVqc+a6kOaJgOWcqCPmlofku7blpLkhISEj55qE6Lev5b6E77yM5Lmf5Y+v5Lul54K55Ye75peB6L656YCJ5oup5rWP6KeI5pys5Zyw6Lev5b6E6YCJ5oupI+aWh+S7tuWkuSEhISPvvIzkvb/nlKjor6Xnp43mlrnms5XvvIzlnKjmlofku7blpLnmlrDlop7miJbliKDpmaTmupDml7bvvIzkuI3nlKjmiYvliqjphY3nva4uanNvbuaWh+S7tu+8jOiHquWKqOivu+WPluOAgijms6jmhI/vvJrpnIDopoHliLfmlrDphY3nva7miJbph43lkK/ova/ku7bmiY3og73or7vlj5YpXFxcIixcXG4gICAgICAgIFxcXCJbUSZBXeS4uuS7gOS5iOiuoumYhemTvuaOpeacieW+iOWkmua6kO+8jOWNtOWPquivhuWIq+WIsOS6huWHoOS4qua6kO+8n1xcXFxu5pys5bCP56iL5bqP5Y+q5pSv5oyB6YGT6ZW/55qEZHJweVtqc13op4bpopHmupDvvIzlhbbku5bkuIDmpoLkuI3mlK/mjIHjgILlm6DmraTkvJroh6rliqjov4fmu6Tlhbbku5bmupBcXFwiLFxcbiAgICAgICAgXFxcIltRJkFd5omT566X5pSv5oyB5YW25LuWdHZib3jnmoTmupDlkJfvvJ/kuI3mlK/mjIHkuI3ogIPomZHjgILor7fnnIvlkI3lrZdEcnB5SGlrZXLvvIzlj6rmlK/mjIFkcnB577yM6KaB55So5YW25LuW5rqQ77yM5bu66K6u5Yig6Zmk5pys5bCP56iL5bqP77yM5Y6755So5ZCE56eN5aOz5a2Q44CCXFxcIlxcbiAgICAgIF1cXG4gICAgfSk7XFxuICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICB9KSxcXG59KTtcXG5sYXlvdXQucHVzaCh7XFxuICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gIGRlc2M6IFxcXCLlkI3np7Ao5b+F5aGrKVxcXCIsXFxuICBleHRyYToge1xcbiAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICBkZWZhdWx0VmFsdWU6IGdldE15VmFyKFxcXC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pcmVjdG9yeSgpKSB7XFxuICAgICAgICAgICAgbGV0IGZsaXN0ID0gZGlyLmxpc3RGaWxlcygpO1xcbiAgICAgICAgICAgIGZvciAodmFyIGYgb2YgZmxpc3QpIHtcXG4gICAgICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcbiAgICAgICAgICAgICAgaWYgKGYuaXNGaWxlKCkgJiYgZi5nZXROYW1lKCkudG9Mb3dlckNhc2UoKS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIHtcXG4gICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7IH1cXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcbiAgICAgICAgICAgIGNvdW50ID0ganNGaWxlcy5sZW5ndGg7XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcbiAgICAgICAgICAgIHVybDogb2JqLnVybCxcXG4gICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgY29kZTogY29kZSxcXG4gICAgICAgICAgICBpbmRleDogb2JqLmlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICAgICAgdmFyIGogPSBKU09OLnBhcnNlKGZldGNoKG9iai51cmwsIHtcXG4gICAgICAgICAgd2l0aEhlYWRlcnM6IHRydWUsXFxuICAgICAgICAgIHRpbWVvdXQ6IDUwMDAsXFxuICAgICAgICB9KSk7XFxuICAgICAgICBsZXQgZSA9IERhdGUubm93KCk7XFxuICAgICAgICBsZXQgYyA9IGUgLSBzO1xcbiAgICAgICAgaWYgKG9iai51cmwuaW5jbHVkZXMoXFxcImdpdGh1Yi5jb21cXFwiKSAmJiBqLnN0YXR1c0NvZGUgPT0gMjAwKSB7XFxuICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgdmFyIGh0bWwgPSBqLmJvZHk7XFxuICAgICAgICAgICAgdmFyIGpzb24gPSBKU09OLnBhcnNlKHBkZmgoaHRtbCwgXFxcIiNyZXBvLWNvbnRlbnQtcGpheC1jb250YWluZXImJnNjcmlwdCYmSHRtbFxcXCIpKTtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IGpzb24ucGF5bG9hZC50cmVlLml0ZW1zO1xcbiAgICAgICAgICAgIGNvdW50ID0gbGlzdC5maWx0ZXIoeCA9PiB4Lm5hbWUuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKS5sZW5ndGg7XFxuICAgICAgICAgIH0gY2F0Y2ggeyB9XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhqLmJvZHkpIHx8IFxcXCJ7fVxcXCIpO1xcbiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgIGNvdW50ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcykubGVuZ3RoO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7IH1cXG5cXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICB9XFxuICAgICAgfTtcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgaSA9IGkgKyAxO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgZnVuYzogdGFzayxcXG4gICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgIH0sXFxuICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICBmdW5jOiBmdW5jdGlvbiAob2JqLCBpZCwgZXJyb3IsIHRhc2tSZXN1bHQpIHtcXG4gICAgICAgICAgb2JqLnJlc3VsdHMucHVzaCh0YXNrUmVzdWx0KVxcbiAgICAgICAgICBjb3VudCA9IGNvdW50IC0gMTtcXG4gICAgICAgICAgaWYgKGNvdW50ID4gMCkge1xcbiAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmo4DmtYvkuK0uLi7liankvZnlnLDlnYDvvJpcXFwiICsgY291bnQpXFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgfVxcbiAgICA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tbnM6IDMsXFxuICAgICAgICAgIHRpdGxlOiBcXFwiVEFHW1xcXCIgKyB0YWdDbGFzc2VzLmxlbmd0aCArIFxcXCJdXFxcIixcXG4gICAgICAgICAgY2xpY2soYSkge1xcbiAgICAgICAgICAgIGxldCB0YWcgPSBhO1xcbiAgICAgICAgICAgIGlmIChhID09IFxcXCLlhajpg6hcXFwiKSB7XFxuICAgICAgICAgICAgICB0YWcgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdGFnID0gXFxcIltcXFwiICsgYSArIFxcXCJdXFxcIlxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpbnB1dEJveC5zZXREZWZhdWx0VmFsdWUodGFnKTtcXG4gICAgICAgICAgICBwdXRNeVZhcihcXFwic2VhcmNoU291cmNlVGFnXFxcIiwgdGFnKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSk7XFxuICAgICAgfSxcXG4gICAgICB0aXRsZVZpc2libGU6IHRydWVcXG4gICAgfSkpLFxcbiAgICBsb25nQ2xpY2socywgaSkge1xcbiAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5YiG5Lqr6KeG6aKR5rqQXFxcIixcXG4gICAgICAgIG9wdGlvbnM6IFtcXFwiSlPmlofku7bliIbkuqtcXFwiXS5jb25jYXQoZ2V0UGFzdGVzKCkpLFxcbiAgICAgICAgY29sOiAyLFxcbiAgICAgICAganM6ICQudG9TdHJpbmcobmFtZSA9PiB7XFxuICAgICAgICAgIGNvbnN0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgbGV0IHNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gc291cmNlcy5maW5kKHYgPT4gdi5uYW1lID09IG5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ICAgICAgICAgICAgICBzbmFtZS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBuYXR1cmFsID8gXFxcIlxcXCIgOiBcXFwiMVxcXCIpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKHMuaW5jbHVkZXMoXFxcIuS9v+eUqOaOkuW6j1xcXCIpKSB7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBPYmplY3QuYXNzaWduKFtdLCBtYW5hZ2UubGlzdCk7XFxuICAgICAgICAgICAgbGV0IHVzaW5nc3QgPSBnZXRJdGVtKFxcXCJ1c2luZ3N0XFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmICh1c2luZ3N0ID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgdXNpbmdTb3J0LmdldChsaXN0KS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgXFxcIlxcXCIpXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICBzbmFtZS5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgpO1xcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCB1c2luZ3N0ID8gXFxcIlxcXCIgOiBcXFwiMVxcXCIpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKHMgPT0gXFxcIuWIt+aWsOmFjee9rlxcXCIpIHtcXG4gICAgICAgICAgICBoaWtlclBvcC5ydW5Pbk5ld1RocmVhZCgoKSA9PiB7XFxuICAgICAgICAgICAgICBmdW5jdGlvbiBhcnJheURpZmZlcmVuY2UoYXJyMSwgYXJyMikge1xcbiAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKGFycjIubWFwKGl0ZW0gPT4gW2l0ZW0ua2V5LCBpdGVtXSkpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5maWx0ZXIoaXRlbSA9PiAhbWFwLmhhcyhpdGVtLmtleSkpO1xcbiAgICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgICAgbGV0IHJ1bnRpbWVDb25maWcgPSBHTS5kZWZpbmVNb2R1bGUoXFxcInJ1bnRpbWVDb25maWdcXFwiLCBcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICAgICAgbGV0IGxpc3QgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcbiAgICAgICAgICAgICAgaWYgKCFydW50aW1lQ29uZmlnLmluaXREZWZhdWx0KCkpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuWIt+aWsOWksei0pVxcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm47XFxuICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgbGV0IG5zb3VyY2VzID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG5cXG4gICAgICAgICAgICAgIGxldCBhbGlzdCA9IGFycmF5RGlmZmVyZW5jZShuc291cmNlcywgbGlzdCk7XFxuICAgICAgICAgICAgICBsZXQgZGxpc3QgPSBhcnJheURpZmZlcmVuY2UobGlzdCwgbnNvdXJjZXMpO1xcblxcbiAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDAgfHwgZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICBsZXQgbXNnID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgYWxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeC5uYW1lKTtcXG4gICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5paw5aKeOlxcXCIgKyBhbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIuaWsOWinlxcXCIgKyBhbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpZiAoZGxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgIGRsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5zcGxpY2UobWFuYWdlLmxpc3QuaW5kZXhPZih4Lm5hbWUpLCAxKTtcXG4gICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICAgIGxvZyhcXFwi56e76ZmkOlxcXCIgKyBkbGlzdC5tYXAoayA9PiBrLm5hbWUpLmpvaW4oXFxcIixcXFwiKSlcXG4gICAgICAgICAgICAgICAgICBtc2cgKz0gXFxcIiDnp7vpmaRcXFwiICsgZGxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaGlrZXJQb3AucnVuT25VSVRocmVhZCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5zZXRUaXRsZShcXFwi6YCJ5oup6KeG6aKR5rqQIOW9k+WJjeWFsTpcXFwiICsgbWFuYWdlLmxpc3QubGVuZ3RoICsgXFxcIuS4quinhumikea6kFxcXCIpO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgdG9hc3QobXNnICsgXFxcIiDmm7TlpJror6bmg4XnnItsb2dcXFwiKTtcXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLlt7LliLfmlrBcXFwiKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLpnZLlsJHlubTmqKHlvI9cXFwiKSkge1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIHNlbGVjdCgpIHtcXG4gICAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgICAgXFxcInRpdGxlXFxcIjogXFxcIumAieaLqVxcXCIsXFxuICAgICAgICAgICAgICAgIFxcXCJvcHRpb25zXFxcIjogW1xcXCLkuLTml7blhbPpl61cXFwiLCBcXFwi5YWz6ZetXFxcIiwgXFxcIuiuvue9ruWvhueggVxcXCJdLFxcbiAgICAgICAgICAgICAgICBjb2w6IDEsXFxuICAgICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG5cXG4gICAgICAgICAgICAgICAgICBpZiAoaW5wdXQgPT0gXFxcIuS4tOaXtuWFs+mXrVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHB1dE15VmFyKFxcXCJ0ZW1wTGVhY2hcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PSBcXFwi5YWz6ZetXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJsZWFjaFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwiXFxcIiwgXFxcIuiuvue9ruWvhueggVxcXFxu5oyH57q55LiN6IO955So5pe25pyJ5pWIXFxcIikuaW5wdXQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJsZWFjaFBhc3NcXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+iuvue9ruaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJsZWFjaFBhc3NcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5L2/55So6buY6K6k5a+G56CBXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBsZWFjaFBhc3MgPSBnZXRJdGVtKFxcXCJsZWFjaFBhc3NcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgaWYgKHMuaW5jbHVkZXMoXFxcIuWFs+mXrVxcXCIpKSB7XFxuXFxuICAgICAgICAgICAgICBpZiAoaGlrZXJQb3AuY2FuQmlvbWV0cmljKCkgIT09IDAgJiYgIWxlYWNoUGFzcykge1xcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6K6+572u5a+G56CBXFxcIixcXG4gICAgICAgICAgICAgICAgICBoaW50OiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICghdGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5a+G56CB5LiN6IO95Li656m6XFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoUGFzc1xcXCIsIHRleHQpO1xcbiAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJsZWFjaFxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInRlbXBMZWFjaFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICB0b2FzdChcXFwi5omT5byA6L+H5rukXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJsZWFjaFxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInRlbXBMZWFjaFxcXCIpO1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5omT5byA6L+H5rukXFxcIik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIGlmIChoaWtlclBvcC5jYW5CaW9tZXRyaWMoKSAhPT0gMCkge1xcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5pbnB1dENvbmZpcm0oe1xcbiAgICAgICAgICAgICAgICAgIGNvbnRlbnQ6IFxcXCLovpPlhaXlr4bnoIHov5vooYzlhbPpl61cXFwiLFxcbiAgICAgICAgICAgICAgICAgIHRpdGxlOiBcXFwi6L6T5YWl5a+G56CBXFxcIixcXG4gICAgICAgICAgICAgICAgICBoaW50OiBcXFwi5a+G56CBXFxcIixcXG4gICAgICAgICAgICAgICAgICBjb25maXJtKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0ID09PSBsZWFjaFBhc3MgfHwgKCFsZWFjaFBhc3MgJiYgdGV4dCA9PT0gU3RyaW5nKHBzKSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgc2VsZWN0KCk7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5a+G56CB6ZSZ6K+vXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLmNoZWNrQnlCaW9tZXRyaWMoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgIGhpa2VyUG9wLnJ1bk9uTmV3VGhyZWFkKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIHNlbGVjdCgpO1xcbiAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcG9wLmRpc21pc3MoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHNob3dTZWxlY3RPcHRpb25zKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi57yW56CB57G75Z6LXFxcIixcXG4gICAgICAgICAgICAgIG9wdGlvbnM6IFtcXFwi5LiN57yW56CBXFxcIiwgXFxcIkd6aXBcXFwiLCBcXFwiQmFzZTY0XFxcIiwgXFxcIkFFU1xcXCJdLFxcbiAgICAgICAgICAgICAgY29sOiAxLFxcbiAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICBpZiAoTVlfSU5ERVggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcInNoYXJlX2VuY29kZVxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIGlucHV0O1xcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICB9KTtcXG4gICAgfVxcbiAgfSk7XFxufVwifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwiZHJweeeuoeeQhlwiLFwicGF0aFwiOlwiRHJweU1hbmFnZVwiLFwicnVsZVwiOlwianM6XFxuY29uc3QgSlNFbmdpbmUgPSBjb20uZXhhbXBsZS5oaWtlcnZpZXcuc2VydmljZS5wYXJzZXIuSlNFbmdpbmU7XFxuY29uc3QgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbmNvbnN0IGRycHlNYXAgPSBuZXcgTWFwKCk7XFxuY29uc3QgR01rZXkgPSBtb2R1bGUuaW1wb3J0UGFyYW07XFxuLy9sb2coXFxcIuWIneWni+WMlkRycHlNYW5hZ2VcXFwiKTtcXG5jb25zdCBwcm94eVNlbWFwaG9yZSA9IG5ldyBqYXZhLnV0aWwuY29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ZXQgdDEgPSBuZXcgVDFBZGFwdGVyKHNvdXJjZSk7XFxuICAgICAgICB0MS5pbml0KCk7XFxuICAgICAgICBkcnB5TWFwLnNldChzb3VyY2Uua2V5LCB0MSk7XFxuICAgICAgICByZXR1cm4gdDE7XFxuICAgIH0gZWxzZSBpZiAoc291cmNlLnR5cGUgPT09IDApIHtcXG4gICAgICAgIGxldCBUMEFkYXB0ZXIgPSAkLnJlcXVpcmUoXFxcIlQwQWRhcHRlclxcXCIpO1xcbiAgICAgICAgbGV0IHQwID0gbmV3IFQwQWRhcHRlcihzb3VyY2UpO1xcbiAgICAgICAgdDAuaW5pdCgpO1xcbiAgICAgICAgZHJweU1hcC5zZXQoc291cmNlLmtleSwgdDApO1xcbiAgICAgICAgcmV0dXJuIHQwO1xcbiAgICB9IGVsc2Uge1xcbiAgICAgICAgcmV0dXJuIGNyZWF0ZVQzKHNvdXJjZSk7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gZ2V0KGtleSkge1xcbiAgICByZXR1cm4gc3luYygoKSA9PiB7XFxuICAgICAgICAvL2xvZyhkcnB5TWFwLnNpemUpXFxuICAgICAgICBpZiAoZHJweU1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGRycHlNYXAuc2l6ZSA+PSA1KSB7XFxuICAgICAgICAgICAgLy9sb2coXFxcIuivt+axgjpcXFwiICsga2V5KVxcbiAgICAgICAgICAgIGRlbChBcnJheS5mcm9tKGRycHlNYXAua2V5cygpKS5hdCgwKSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2VzKCkuZmluZCh2ID0+IHYua2V5ID09PSBrZXkpO1xcbiAgICAgICAgbGV0IGRycHkgPSBjcmVhdGVOZXdEcnB5KHNvdXJjZSk7XFxuXFxuICAgICAgICByZXR1cm4gZHJweTtcXG4gICAgfSwgdGhpcykuY2FsbCgpO1xcbn1cXG4vL3NvdXJjZS5leHTlv4XpobvkuLrnu53lr7not6/lvoRcXG5mdW5jdGlvbiBnZXRCeVNvdXJjZShzb3VyY2UpIHtcXG4gICAgcmV0dXJuIHN5bmMoKCkgPT4ge1xcbiAgICAgICAgbGV0IGtleSA9IHNvdXJjZS5rZXk7XFxuICAgICAgICAvL2xvZyhkcnB5TWFwLnNpemUpXFxuICAgICAgICBpZiAoZHJweU1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGRycHlNYXAuc2l6ZSA+PSA1KSB7XFxuICAgICAgICAgICAgLy9sb2coXFxcIuivt+axgjpcXFwiICsga2V5KVxcbiAgICAgICAgICAgIGRlbChBcnJheS5mcm9tKGRycHlNYXAua2V5cygpKS5hdCgwKSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZHJweSA9IGNyZWF0ZU5ld0RycHkoc291cmNlKTtcXG4gICAgICAgIHJldHVybiBkcnB5O1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcblxcbmZ1bmN0aW9uIHB1dChrZXksIGRycHkpIHtcXG4gICAgc3luYygoKSA9PiBkcnB5TWFwLnNldChrZXksIGRycHkpLCB0aGlzKS5jYWxsKCk7XFxufVxcblxcbmZ1bmN0aW9uIHJ1blByb3h5KGRycHksIGFyZ3MpIHtcXG4gICAgaWYgKHR5cGVvZiBkcnB5LnByb3h5ID09PSBcXFwiZnVuY3Rpb25cXFwiKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUxID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICBwcm94eVNlbWFwaG9yZS5hY3F1aXJlKCk7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTIgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIC8vbG9nKF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BcXFwiLFxcbiAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlOiBzZWFyY2hLZXksXFxuICAgICAgICAgICAgICB0ZXh0YXJlYTogZmFsc2UsIC8v5aSa6KGM5qih5byPXFxuICAgICAgICAgICAgICBtYXhUZXh0YXJlYTogdHJ1ZSxcXG4gICAgICAgICAgICAgIG5vQXV0b1NvZnQ6IGZhbHNlLFxcbiAgICAgICAgICAgICAgLy9oaWRlQ2FuY2VsOiB0cnVlLFxcbiAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEtleSA9IHRleHQ7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgICAgaWYgKHRleHQpIHtcXG4gICAgICAgICAgICAgICAgICBjYW5TZWFyY2hTb3VyY2UuZm9yRWFjaCgodiwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQuc3BsaXQoL1xcXFx8LykuZmlsdGVyKGYgPT4gZikuc29tZSh4ID0+IHYubmFtZS5pbmNsdWRlcyh4KSkpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5wdXNoKHYpO1xcbiAgICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSA/IFxcXCLigJzigJzigJ3igJ1cXFwiICsgKHYubmFtZSArIFxcXCJcXFwiKS5mb250Y29sb3IoXFxcIiMwMDk5NjZcXFwiKSA6IHYubmFtZSlcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlID0gY2FuU2VhcmNoU291cmNlLnNsaWNlKCk7XFxuICAgICAgICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly/ovpPlhaXkuoZcXFwiICsgdGV4dDtcXG4gICAgICAgICAgICAgIH0sXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PT0gMikge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuXFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5zb3J0KChhLCBiKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nKGEubmFtZSkubG9jYWxlQ29tcGFyZShTdHJpbmcoYi5uYW1lKSwgdW5kZWZpbmVkLCB7XFxuICAgICAgICAgICAgICAgIG51bWVyaWM6IHRydWUsXFxuICAgICAgICAgICAgICAgIHNlbnNpdGl2aXR5OiAnYmFzZSdcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDMpIHtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgZHluYW1pY1NvdXJjZS5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNCkge1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICghc2VhcmNoQWxsb3cuaW5jbHVkZXModi5rZXkpKSB7XFxuICAgICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIG1hbmFnZS5zZXRUaXRsZShwb3BUaXRsZShzZWFyY2hBbGxvdy5sZW5ndGgpKTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT0gNSkge1xcbiAgICAgICAgICAgIGxldCB0ZW1saXN0ID0gc2VhcmNoQWxsb3cuc2xpY2UoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdy5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UuZm9yRWFjaCh2ID0+IHtcXG4gICAgICAgICAgICAgIGlmICh0ZW1saXN0LmluY2x1ZGVzKHYua2V5KSkgcmV0dXJuO1xcbiAgICAgICAgICAgICAgc2VhcmNoQWxsb3cucHVzaCh2LmtleSk7XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgbWFuYWdlLnNldFRpdGxlKHBvcFRpdGxlKHNlYXJjaEFsbG93Lmxlbmd0aCkpO1xcbiAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcbiAgICAgICAgICAgIHJ1bnRpbWVDb25maWcuc2V0U2VhcmNoQWxsb3coKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICA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B7XFxuICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgIGNvbF90eXBlOiAnYmxhbmtfYmxvY2snXFxuICAgICAgICB9KVxcbiAgICAgICAgeC52YWx1ZS5mb3JFYWNoKChpdCwgaSkgPT4ge1xcbiAgICAgICAgICBsZXQgdCA9IGl0Lm47XFxuICAgICAgICAgIGlmIChjYXRlX3RlbXBbaW5kZXhdID09IGkpIHtcXG4gICAgICAgICAgICB0ID0gXFxcIjxiPjxmb250IGNvbG9yPVxcXCIgKyBjb2xvciArIFxcXCI+XFxcIiArIHQgKyBcXFwiPC9mb250PjwvYj5cXFwiO1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IGl0LnY7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGNhdGVfdGVtcFtpbmRleF0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IFxcXCJ1bmRlZmluZWRcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChmb2xkID09IDEpIHtcXG4gICAgICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyB0LFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gby5pO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiaXNfZGVmXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwge30pO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIGlmIChjYXRlX3RlbXAuY29uc3RydWN0b3IgIT0gQXJyYXkpIHtcXG4gICAgICAgICAgICAgICAgICBjYXRlX3RlbXAgPSBbXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBvLmluZGV4O1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGNhdGVfdGVtcFtpbmRleF0gfHwgXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgLy9sb2coYylcXG4gICAgICAgICAgICAgICAgaWYgKGMgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGNhdGVfdGVtcClcXG4gICAgICAgICAgICAgICAgLy9zdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV90ZW1wXFxcIiwgY2F0ZV90ZW1wKTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwgY2F0ZV9vYmopO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICBpbmRleDogaW5kZXgsXFxuICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcbiAgICAgICAgICAgICAgICBpOiBpLFxcbiAgICAgICAgICAgICAgICBjYXRlOiBjYXRlXFxuICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiAnc2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T4ge1xcbiAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIGxldCBjb2RlID0gRHJweU1hbmFnZS5nZXQoc291cmNlLmtleSkucnVuTWFpbihcXFwibGV0IG1haW49XFxcIiArICQudG9TdHJpbmcoKGV4dCkgPT4ge1xcbiAgICAgICAgICAgIHJldHVybiAoKSA9PiBnZXRPcmlnaW5hbEpzKHJlcXVlc3QoZXh0LCB7XFxuICAgICAgICAgICAgICAnbWV0aG9kJzogJ0dFVCdcXG4gICAgICAgICAgICB9KSk7XFxuICAgICAgICAgIH0sIHJ1bnRpbWVDb25maWcuZ2V0Q3VycmVudFNvdXJjZVBhdGgoKSkpO1xcblxcbiAgICAgICAgICBsZXQgcGF0aCA9IFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS92aWV3U291cmNlQ29kZS5qc1xcXCI7XFxuICAgICAgICAgIHdyaXRlRmlsZShwYXRoLCBjb2RlKTtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJlZGl0RmlsZTovL1xcXCIgKyBwYXRoO1xcbiAgICAgICAgfSlcXG4gICAgICB9XS5jb25jYXQoY29uZmlnLnR5cGUgPT09IFxcXCJsb2NhbERpclxcXCIgPyBbe1xcbiAgICAgICAgdGl0bGU6IFxcXCLnvJbovpHlj4LmlbDmmKDlsITooahcXFwiLFxcbiAgICAgICAganM6ICQudG9TdHJpbmcoKHBhdGgpID0+IHtcXG4gICAgICAgICAgcGF0aCArPSBcXFwiLy5tYXBwaW5nLnR4dFxcXCI7XFxuICAgICAgICAgIGlmIChmaWxlRXhpc3QocGF0aCkpI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ICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIiwgXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICBpZiAoIXJ1bnRpbWVDb25maWcuaW5pdERlZmF1bHQoKSkge1xcbiAgICAgICAgICAgICAgdG9hc3QoXFxcIuWIt+aWsOWksei0pVxcXCIpO1xcbiAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgdG9hc3QoXFxcIuW3suS/neWtmFxcXCIpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgIH0gZWxzZSBpZiAoaW5wdXQuaW5jbHVkZXMoXFxcIuS4u+mimFxcXCIpKSB7XFxuICAgICAgICBsZXQgY3RoZW1lID0gZ2V0SXRlbShcXFwidGhlbWVcXFwiLCBcXFwi6buY6K6kXFxcIik7XFxuICAgICAgICBsZXQgcyA9ICQudGhlbWVzO1xcbiAgICAgICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyhzKTtcXG4gICAgICAgIGlmIChrZXlzLmxlbmd0aCA8IDIpIHtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ayoeacieWFtuS7luS4u+mimFxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoa2V5cy5sZW5ndGggPT0gMikge1xcbiAgICAgICAgICBsZXQgbmFtZSA9IGtleXNbMF07XFxuICAgICAgICAgIGlmIChjdGhlbWUgPT0ga2V5c1swXSkge1xcbiAgICAgICAgICAgIG5hbWUgPSBrZXlzWzFdO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHNldEl0ZW0oXFxcInRoZW1lXFxcIiwgbmFtZSk7XFxuICAgICAgICAgIGxldCB0aGVtZSA9ICQudGhlbWVzW25hbWVdO1xcbiAgICAgICAgICAkLnVpVGhlbWUuc2V0KHRoZW1lKTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICA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G4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgdGl0bGVWaXNpYmxlOiBmYWxzZVxcbiAgICAgICAgfVxcbiAgICB9LCB7XFxuICAgICAgICBjb2xfdHlwZTogXFxcImxpbmVcXFwiXFxuICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiB0aW1lICsgXFxcIuenkuWQjue7p+e7rVxcXCIsXFxuICAgICAgICB1cmw6IFxcXCJ0b2FzdDovL+ivt+iupOecn+mYheivu+S7peS4iuWGheWuuVxcXCIsXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBpZDogaWQgKyBcXFwidGltZXJcXFwiXFxuICAgICAgICB9XFxuICAgIH0pO1xcblxcbiAgICBzZXRSZXN1bHQoZCk7XFxuICAgIHdoaWxlICh0aW1lICE9IDApIHtcXG4gICAgICAgIGphdmEubGFuZy5UaHJlYWQuc2xlZXAoMTAwMCk7XFxuICAgICAgICB0aW1lIC09IDE7XFxuICAgICAgICB1cGRhdGVJdGVtKGlkICsgXFxcInRpbWVyXFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiB0aW1lICsgXFxcIuenkuWQjue7p+e7rVxcXCJcXG4gICAgICAgIH0pO1xcbiAgICB9XFxuICAgIHVwZGF0ZUl0ZW0oaWQgKyBcXFwidGltZXJcXFwiLCB7XFxuICAgICAgICB0aXRsZTogXFxcIuKAnOKAnOaIkeWQjOaEj+S7peS4iuimgeaxguKAneKAnVxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKHYpID0+IHtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJmaXJzdG9wZW5cXFwiLCBTdHJpbmcodikpO1xcbiAgICAgICAgICAgIEdNLmNsZWFyKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ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KHNvdXJjZVtrZXldKSkge1xcbiAgICAgICAgaWYgKCF0YXJnZXRba2V5XSkge1xcbiAgICAgICAgICB0YXJnZXRba2V5XSA9IHt9O1xcbiAgICAgICAgfVxcbiAgICAgICAgZGVlcE1lcmdlKHRhcmdldFtrZXldLCBzb3VyY2Vba2V5XSk7XFxuICAgICAgfSBlbHNlIHtcXG4gICAgICAgIHRhcmdldFtrZXldID0gc291cmNlW2tleV07XFxuICAgICAgfVxcbiAgICB9XFxuICB9XFxuICByZXR1cm4gdGFyZ2V0O1xcbn1cXG5cXG4vKipcXG4gKiDku47mupDlr7nosaHkuK3mt7HluqbliKDpmaTmjIflrprnmoTlsZ7mgKfjgIJcXG4gKiBAcGFyYW0ge09iamVjdH0gc291cmNlIC0g6KaB5aSE55CG55qE5rqQ5a+56LGh44CCXFxuICogQHBhcmFtIHtPYmplY3R9IGV4YyAtIOaMh+WumuimgeaOkumZpOeahOWxnuaAp++8jOS7pemUruWAvOWvueW9ouW8j+aMh+WumuOAglxcbiAqIEByZXR1cm5zIHtPYmplY3R9IC0g6L+U5Zue5LiA5Liq5paw55qE5a+56LGh77yM5LiN5YyF5ZCr5oyH5a6a6KaB5o6S6Zmk55qE5bGe5oCn44CCXFxuICovXFxuZnVuY3Rpb24gZGVlcE9taXQoc291cmNlLCBleGMpIHtcXG4gIGNvbnN0IHJlc3VsdCA9IHt9O1xcbiAgLy8g6YGN5Y6G6aG25bGC6ZSuXFxuICBmb3IgKGxldCBrZXkgaW4gc291cmNlKSB7XFxuICAgIGlmIChzb3VyY2UuaGFzT3duUHJvcGVydHkoa2V5KSkge1xcbiAgICAgIC8vIOajgOafpemhtuWxgumUruaYr+WQpuW6lOivpeiiq+aOkumZpFxcbiAgICAgIGlmICghKGV4Yy5oYXNPd25Qcm9wZXJ0eShrZXkpICYmIGV4Y1trZXldID09PSB0cnVlKSkge1xcbiAgICAgICAgLy8g5aaC5p6c6aG25bGC6ZSu5a+55bqU55qE5YC85piv5a+56LGh77yM5bm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y5uYW1lKSkge1xcbiAgICAgIHRoaXMuc2F2ZShcXFwie31cXFwiKTtcXG4gICAgfVxcbiAgICB0cnkge1xcbiAgICAgIGpzb24gPSBKU09OLnBhcnNlKHJlYWRGaWxlKHRoaXMucGF0aCArIHRoaXMubmFtZSkpO1xcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgICAganNvbiA9IHt9O1xcbiAgICAgIHRoaXMuc2F2ZShcXFwie31cXFwiKTtcXG4gICAgfVxcbiAgICByZXR1cm4ganNvbjtcXG4gIH0sXFxuICBoYXModHMpIHtcXG4gICAgbGV0IGpzb24gPSB0aGlzLmluaXQoKTtcXG4gICAgbGV0IHNqc29uID0gZGVlcE1lcmdlKHt9LCBqc29uKTtcXG4gICAgbGV0IGtleXMgPSBPYmplY3Qua2V5cyh0cyk7XFxuICAgIGtleXMuZm9yRWFjaChrID0+IHtcXG4gICAgICBpZiAoIWpzb24uaGFzT3duUHJvcGVydHkoaykpIHtcXG4gICAgICAgIGpzb25ba10gPSB0c1trXTtcXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGlmIChPYmplY3Qua2V5cyhzanNvbikubGVuZ3RoID09IDApIHtcXG4gICAgICBqc29uID0gZGVlcE1lcmdlKGpzb24sIHNqc29uKTtcXG4gICAgICB0aGlzLnNhdmUoSlNPTi5zdHJpbmdpZnkoanNvbikpO1xcbiAgICAgIHJldHVybiBqc29uO1xcbiAgICB9XFxuICAgIGlmICgha2V5cy5ldmVyeShrZXkgPT4gc2pzb24uaGFzT3duUHJvcGVydHkoa2V5KSkpIHtcXG4gICAgICB0aGlzLnNhdmUoSlNPTi5zdHJpbmdpZnkoanNvbikpO1xcbiAgICB9XFxuICAgIHJldHVybiBqc29uO1xcbiAgfSxcXG4gIGdldChrZXkpIHtcXG4gICAgbGV0IGpzb24gPSB0aGlzLmluaXQoKTtcXG4gICAgaWYgKGtleSAhPSB1bmRlZmluZWQpIHtcXG4gICAgICBpZiAodHlwZW9mIGtleSAhPSBcXFwic3RyaW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ubGVuZ3RoLFxcbiAgICBmb3JtOiBlZi5mcm9tW2VmLmxpbmVdLFxcbiAgICBwbGF5czogZWYucGxheXNbZWYubGluZV0sXFxuICAgIHNwYWdlOiBlZi5zcGFnZW51bSxcXG4gICAgbWF4OiBlZi5tYXhbZWYubGluZV1cXG4gIH1cXG4gIGZ1bmN0aW9uIFRlbXBsYXRlKHRlbXBsYXRlLCBkYXRhKSB7XFxuICAgIC8vIOeUqOS6juaJp+ihjOWtl+espuS4suS4reeahOihqOi+vuW8j1xcbiAgICBmdW5jdGlvbiBldmFsdWF0ZUV4cHJlc3Npb24oZXhwcikge1xcbiAgICAgIHRyeSB7XFxuICAgICAgICAvLyDkvb/nlKggd2l0aCDor63lj6XlsIYgZGF0YSDlr7nosaHmlL7lhaXlvZPliY3kvZznlKjln59cXG4gICAgICAgIC8vIOi/meagt+WPr+S7peWcqOihqOi+vuW8j+S4reebtOaOpeS9v+eUqCBkYXRhIOeahOWxnuaAp1xcbiAgICAgICAgd2l0aCAoZGF0YSkge1xcbiAgICAgICAgICByZXR1cm4gZXZhbChleHByKTtcXG4gICAgICAgIH1cXG4gICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICByZXR1cm4gZXhwcjsgLy8g5aaC5p6c6KGo6L6+5byP5peg5rOV6K6h566X77yM5YiZ6L+U5Zue5Y6f5aeL5a2X56ym5LiyXFxuICAgICAgfVxcbiAgICB9XFxuICAgIC8vIOato+WImeihqOi+vuW8j+WMuemFjSB7IOihqOi+vuW8jyB9IOagvOW8j+eahOWNoOS9jeesplxcbiAgICByZXR1cm4gdGVtcGxhdGUucmVwbGFjZSgveyguKj8pfS9nLCAobWF0Y2gsIGV4cHIpID0+IHtcXG4gICAgICAvL2NvbnNvbGUubG9nKGV4cHIpXFxuICAgICAgLy8g5omn6KGM6KGo6L6+5byPXFxuICAgICAgcmV0dXJuIGV2YWx1YXRlRXhwcmVzc2lvbihleHByKTtcXG4gICAgfSk7XFxuICB9XFxuICBsZXQgbHNob3c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AgICAgICBpZiAoIWN1cnJlbnRbcGFydF0pIHtcXG4gICAgICAgICAgICBjdXJyZW50W3BhcnRdID0ge307XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgY3VycmVudCA9IGN1cnJlbnRbcGFydF07XFxuICAgICAgICB9XFxuICAgICAgICBjdXJyZW50W3BhcnRzW3BhcnRzLmxlbmd0aCAtIDFdXSA9IHZhbHVlO1xcbiAgICAgIH0sXFxuICAgICAgZ2V0KCkge1xcbiAgICAgICAgbGV0IHVjID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdGhpcy51Yyk7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXModWMpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgIHVjID0gdGhpcy5kZWY7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gdWM7XFxuICAgICAgfSxcXG4gICAgICBzZXQodmFsdWUsIGtleSkge1xcbiAgICAgICAgbGV0IHVjID0gdGhpcy5nZXQoKTtcXG4gICAgICAgIGlmIChrZXkpIHtcXG4gICAgICAgICAgdGhpcy5kZWVwT2JqZWN0UHJvcGVydHkodWMsIGtleSwgdmFsdWUpO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgdWMgPSB2YWx1ZTtcXG4gICAgICAgIH1cXG4gICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVjKTtcXG4gICAgICB9LFxcbiAgICAgIGdldEluZGV4cygpIHtcXG4gICAgICAgIGxldCB1YyA9IHRoaXMuZ2V0KCk7XFxuICAgICAgICBpZiAodWMueWkudWkubGVuZ3RoID4gMCAmJiB1Yy55aS51aS5zb21lKHggPT4gT2JqZWN0LmtleXMoeCkubGVuZ3RoID4gMCkpIHtcXG4gICAgICAgICAgcmV0dXJuIHVjLnlpLnVpO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgdGhpcy5zZXQodGhpcy5pdG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Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9XFxuXFxuICAgICAgICBpZiAobmFtZSA9PSBcXFwi57yW6L6R5Li76aKYXFxcIikge1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9UaGVtZUVkaXRcXFwiXFxuICAgICAgICB9XFxuICAgICAgICBzZXRJdGVtKFxcXCJ0aGVtZVxcXCIsIG5hbWUpO1xcbiAgICAgICAgJC51aVRoZW1lLnNldChzW25hbWVdKTtcXG4gICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgfSwgdGhlbWVzLCBzLCBjdGhlbWUpXFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxuICAgIGV4dHJhOiB7XFxuICAgICAgcGFnZVRpdGxlOiBcXFwi5Li76aKY57yW6L6RXFxcIixcXG4gICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICB0aXRsZTogXFxcIumHjee9rlxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgIHJldHVybiAkKFxcXCLmuIXpmaTmiYDmnInorr7nva5cXFwiKS5jb25maXJtKCgpID0+IHtcXG4gICAgICAgICAgICBjbGVhckl0ZW0oXFxcInRoZW1lXFxcIik7XFxuICAgICAgICAgICAgY2xlYXJJdGVtKFxcXCJ1aV9jb25maWdcXFwiKTtcXG4gICAgICAgICAgICBjbGVhckl0ZW0oXFxcInVpX3RoZW1lXFxcIik7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WIneWni+WMluWujOaIkFxcXCI7XFxuICAgICAgICAgIH0pXFxuICAgICAgICB9KSxcXG4gICAgICB9XVxcbiAgICB9XFxuICB9KVxcbiAgZC5wdXNoKHtcXG4gICAgY29sX3R5cGU6IFxcXCJibGFua19ibG9ja1xcXCJcXG4gIH0pXFxuXFxuXFxuICBpZiAodWlfbmF2aSA9PSBcXFwi5LiA57qnXFxcIikge1xcb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AgICB9KTtcXG4gICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIik7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgfVxcblxcbiAgICAgICAgICBsZXQgY3VycmVudCA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIiwge30pO1xcblxcbiAgICAgICAgICBpZiAoT2JqZWN0LmtleXMoY3VycmVudCkubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGN1cnJlbnQudGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGN1cnJlbnQucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogY3VycmVudC5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGN1cnJlbnQudHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBpdGVtLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogY3VycmVudC5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBjdXJyZW50LmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oY3VycmVudC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGl0ZW0ucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogaXRlbS5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGl0ZW0udHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBjdXJyZW50LmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogaXRlbS5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBpdGVtLmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxldCBuYXJyID0gJC5zd2FwQXJyYXlFbGVtZW50cyhpbmRleHMsIGN1cnJlbnQuZXh0cmEuaW5kZXgsIGl0ZW0uZXh0cmEuaW5kZXgpO1xcblxcbiAgICAgICAgICAgICQudWlDb25maWcuc2V0KG5hcnIsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgaCA9ICfigJzigJzigJ3igJ0nO1xcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0ZW0udGl0bGU7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIumAieaLqeenu+WKqOeahOebruagh1xcXCIpO1xcbiAgICAgICAgICAgIGlmICgvdGV4dF9pY29ufGF2YXRhcnxpY29uX3NtYWxsXzMvLnRlc3QoaXRlbS50eXBlKSkge1xcbiAgICAgICAgICAgICAgaCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKC9pY29uXzFfc2VhcmNoLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gXFxcIuKeoe+4j1xcXCIgKyB0aXRsZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogaCArIHRpdGxlLFxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiLCBpdGVtKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaSlcXG4gICAgICAgIGl0ZW1bXFxcImV4dHJhXFxcIl0gPSB7XFxuICAgICAgICAgIGtleTogaXRlbS5rZXksXFxuICAgICAgICAgIGNsczogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiLFxcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgaW5kZXg6IGl0ZW0uaW5kZXgsXFxuICAgICAgICB9XFxuICAgICAgICBpZiAoaXRlbS5rZXkgIT0gXFxcIuiuvue9rlxcXCIpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gLTE7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0sIGl0ZW0ua2V5KVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCEvaWNvbl8xX3NlYXJjaHxhdmF0YXIvLnRlc3QoaXRlbS5jb2xfdHlwZSkpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuabtOaNouWbvuagh1xcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgIHJldHVybiAkKGl0ZW0uaW1nKS5pbnB1dCgoaXRlbSkgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gaXRlbS5rZXk7XFxuICAgICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgbGV0IGsgPSBrZXk7XFxuICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgaWYgKGtleSA9PSBcXFwi5pCc57Si5qih5byPXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgayA9IFxcXCLmkJzntKJcXFwiO1xcbiAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwieWkuaWNvbnMuXFxcIiArIGspO1xcbiAgICAgICAgICAgICAgICAgIC8vaXRlbXNbaV1bXFxcImltZ1xcXCJdID0gaW5wdXQ7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgICBsZXQgaWQgPSBmaW5kSXRlbXNCeUNscyhNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIpLmZpbHRlcih4ID0+IHguZXh0cmEua2V5ID09IGtleSlbMF0uZXh0cmEuaWQ7XFxuICAgICAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaWQsIHsgcGljOiBpbnB1dCB9KVxcbiAgICAgICAgICAgICAgfSwgaXRlbSlcXG4gICAgICAgICAgICB9LCBpdGVtKVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgICBpZiAoaXRlbS5rZXkgIT0gXFxcIuaNoua6kFxcXCIgJiYgaXRlbS5rZXkgIT0gXFxcIuaQnOe0ouaooeW8j1xcXCIpIHtcXG4gICAgICAgICAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLkv67mlLnlkI3np7BcXFwiLFxcbiAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwiXFxcIikuaW5wdXQoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwidGl0bGVcXFwiXSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICAgICAgbGV0IGlkID0gZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKS5maWx0ZXIoeCA9PiB4LmV4dHJhLmtleSA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cbiAgICAgICAgbGV0IG1hcCA9IG5ldyBNYXAoc3Vpb2JqLm1hcChvYmogPT4gW29iai5rZXksIG9ial0pKTtcXG4gICAgICAgIGxldCBvYmogPSBtYXAuZ2V0KGl0ZW0ua2V5KTtcXG4gICAgICAgIG9iai51cmwgPSAkKFxcXCJcXFwiKS5sYXp5UnVsZSgoa2V5LCBpbmRleCkgPT4ge1xcbiAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgaXRlbXNbaV1bXFxcImluZGV4XFxcIl0gPSBpbmRleDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBpdGVtLmtleSwgb2JqLmluZGV4KVxcbiAgICAgICAgb2JqLnRpdGxlID0gb2JqLmtleTtcXG4gICAgICAgIGlmIChvYmouZXh0cmEgPT0gdW5kZWZpbmVkKSB7XFxuICAgICAgICAgIG9iai5leHRyYSA9IHt9O1xcbiAgICAgICAgfVxcbiAgICAgICAgb2JqLmV4dHJhLmlkID0gTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgb2JqLmtleTtcXG4gICAgICAgIG9iai5leHRyYS5jbHMgPSBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCI7XFxuXFxuICAgICAgICBpZiAob2JqLmNvbF90eXBlID09IFxcXCJpbnB1dFxcXCIpIHtcXG4gICAgICAgICAgb2JqLmNvbF90eXBlID0gXFxcImljb25fMV9zZWFyY2hcXFwiO1xcbiAgICAgICAgf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nNldChkZWYueWksIFxcXCJ5aVxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/ov5jljp/lrozmiJBcXFwiO1xcbiAgICAgICAgfSwgZGVmKVxcbiAgICAgIH0sIGRlZiksXFxuICAgIH0sIHtcXG4gICAgICB0aXRsZTogXFxcIuehruiupFxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbiAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICBiYWNrKHRydWUpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIlxcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBMb25nQ2xpY2s6IFt7XFxuICAgICAgICAgIHRpdGxlOiBcXFwi5aSN5Yi2XFxcIixcXG4gICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHZhciB1YyA9ICQudWlDb25maWcuZ2V0KCk7XFxuICAgICAgICAgICAgY29weShKU09OLnN0cmluZ2lmeSh1Yy55aSkpO1xcbiAgICAgICAgICB9KSxcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlr7zlhaVcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHVjID0gJC51aUNvbmZpZy5nZXQoKTtcXG4gICAgICAgICAgICByZXR1cm4gJChcXFwie3tjbGlwYm9hcmR9fVxcXCIpLmlucHV0KCh1YykgPT4ge1xcbiAgICAgICAgICAgICAgdmFyIHlpID0ge307XFxuICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB5aSA9IEpTT04ucGFyc2UoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoeWkuaGFzT3duUHJvcGVydHkoXFxcInVpXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICB1Yy55aSA9IHlpO1xcbiAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVjKTtcXG4gICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmoLzlvI/plJnor69cXFwiKVxcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHVjKVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfV1cXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLlpLTpg6jnu4Tku7bmoLflvI86XFxcIiArIHVpX2NvbmZpZy55aS5jb2wsXFxuICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzFcXFwiLFxcbiAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICB1aV9jb25maWcgPSBzdG9yYWdlMC5nZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgbGV0IGFsbF9jb2xzID0gWycnXS5jb25jYXQoZ2V0Q29sVHlwZXMoKSk7XFxuICAgICAgICBhbGxfY29scyA9IGFsbF9jb2xzLmZpbHRlcih4ID0+XFxuICAgICAgICAgIC8oaWNvbikvLnRlc3QoeCkgJiYgeCAhPSAndGV4dF9pY29uJyAmJlxcbiAgICAgICAgICB4ICE9IFxcXCJpY29uXzFfc2VhcmNoXFxcIik7XFxuICAgICAgICAvL2xvZyhhbGxfY29scylcXG4gICAgICAgIGxldCBjb2wgPSB1aV9jb25maWcueWkuY29sO1xcbiAgICAgICAgbGV0IOaMiemSruagt+W8jyA9IGFsbF9jb2xzLm1hcCgoaXQpID0+IHtcXG4gICAgICAgICAgcmV0dXJuIGl0ID09PSBjb2wgPyAn4p6h77iPJyArIGl0IDogaXQ7XFxuICAgICAgICB9KTtcXG4gICAgICAgIGxldCB0aXBzID0gJ+ivt+mAieaLqeWktOmDqOaMiemSruagt+W8jyc7XFxuICAgICAgICByZXR1cm4gJCjmjInpkq7moLflvI8sIDIsIHRpcHMpLnNlbGVjdCgodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgIGlucHV0ID0gaW5wdXQucmVwbGFjZShcXFwi4p6h77iPXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICBsZXQgb2JqcyA9IChmaW5kSXRlbXNCeUNscyhNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCIpIHx8IFtdKS5maWx0ZXIoeCA9PiAhLyhpY29uXzFfc2VhcmNofGF2YXRhcnxpbnB1dCkvLnRlc3QoeC50eXBlKSk7XFxuICAgICAgICAgIG9ianMuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBpbnB1dCxcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgfSk7XFxuICAgICAgICAgICQudWlDb25maWcuc2V0KGlucHV0LCBcXFwieWkuY29sXFxcIilcXG4gICAgICAgICAgdXBkYXRlSXRlbShNWV9SVUxFLnRpdGxlICsgXFxcIl95aWNvbFxcXCIsIHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWktOmDqOe7hOS7tuagt+W8jzpcXFwiICsgdWlfY29uZmlnLnlpLmNvbFxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfSwgdWlfY29uZmlnKVxcbiAgICAgIH0sIHVpX2NvbmZpZyksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgIGlkOiBNWV9SVUxFLnRpd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gICAgICAgICQudWlUaGVtZS5zZXQoaW5wdXQsIFxcXCJ5aS7liIbnsbvpopzoibJcXFwiKTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIHRvYXN0KFxcXCLor7fovpPlhaXmraPnoa7nmoTpopzoibLlgLxcXFwiKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLnlpLuWIhuexu+minOiJslxcbiAgICAgIH1cXG4gICAgfSlcXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIuaNoua6kOminOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGxldCB7IGlzVmFsaWRDb2xvciB9ID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIik7XFxuICAgICAgICBpZiAoaXNWYWxpZENvbG9yKGlucHV0KSkge1xcbiAgICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwieWku5o2i5rqQ6aKc6ImyXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWl5q2j56Gu55qE6aKc6Imy5YC8XFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBkZWZhdWx0VmFsdWU6IHVpX2NvbmZpZy55aS7mjaLmupDpopzoibJcXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGQucHVzaCh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JiYgaW5wdXQgIT0gMCkge1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K+36L6T5YWlMuS9jeaVsOWtl+S7peS4ilxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICAkLnVpQ29uZmlnLnNldChpbnB1dCwgXFxcImVyLuWIhumhtVxcXCIpO1xcbiAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgKGlucHV0ID4gMCA/IFxcXCLmr4/pobXmlbDph4/orr7nva7kuLo6XFxcIiArIGlucHV0IDogXFxcIuS4jeWIhumhtVxcXCIpO1xcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBvbkNoYW5nZTogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgIGlmIChTdHJpbmcoaW5wdXQpLmxlbmd0aCA+IDMpIHtcXG4gICAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWlM+S9jeaVsOWtl+S7peWGhVxcXCIpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoU3RyaW5nKGlucHV0KS5sZW5ndGggPCAyICYmIGlucHV0ICE9IDApIHtcXG4gICAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWlMuS9jeaVsOWtl+S7peS4ilxcXCIpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCJcXG4gICAgICAgICAgfVxcbiAgICAgICAgICAkLnVpQ29uZmlnLnNldChpbnB1dCwgXFxcImVyLuWIhumhtVxcXCIpO1xcbiAgICAgICAgfSksXFxuICAgICAgICBkZWZhdWx0VmFsdWU6IHVpX2NvbmZpZy5lci7liIbpobUsXFxuICAgICAgICB0eXBlOiBcXFwibnVtYmVyXFxcIixcXG4gICAgICB9XFxuICAgIH0pXFxuXFxuICAgI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ZXIu5YiG6aG16YC76L6RXFxcIik7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIH0pLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9pY29uXFxcIlxcbiAgICB9KVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5YiG6aG15a+86IiqXFxcIixcXG4gICAgICBpbWc6IGJ1dHRvbkltZyh1aV9jb25maWcuZXIu5YiG6aG15a+86IiqKSxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfaWNvblxcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGxldCBwYSA9ICQudWlDb25maWcuZ2V0KCkuZXIu5YiG6aG15a+86IiqO1xcbiAgICAgICAgaWYgKHBhKSB7XFxuICAgICAgICAgIHBhID0gZmFsc2U7XFxuICAgICAgICB9IGVsc2UgaWYgKCFwYSkge1xcbiAgICAgICAgICBwYSA9IHRydWU7XFxuICAgICAgICB9XFxuICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAkLnVpQ29uZmlnLnNldChwYSwgXFxcImVyLuWIhumhteWvvOiIqlxcXCIpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICB9KVxcbiAgICB9KVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5LqM57qn5Yi35pawXFxcIixcXG4gICAgICBpbWc6IGJ1dHRvbkltZyh1aV9jb25maWcuZXIu5LqM57qn5Yi35pawKSxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfaWNvblxcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGxldCBwYSA9ICQudWlDb25maWcuZ2V0KCkuZXIu5LqM57qn5Yi35pawO1xcbiAgICAgICAgaWYgKHBhKSB7XFxuICAgICAgICAgIHBhID0gZmFsc2U7XFxuICAgICAgICB9IGVsc2UgaWYgKCFwYSkge1xcbiAgICAgICAgICBwYSA9IHRydWU7XFxuICAgICAgICB9XFxuICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAkLnVpQ29uZmlnLnNldChwYSwgXFxcImVyLuS6jOe6p+WIt+aWsFxcXCIpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICB9KVxcbiAgICB9KVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5LqM57qn57yT5a2YXFxcIixcXG4gICAgICBpbWc6IGJ1dHRvbkltZyh1aV9jb25maWcuZXIu5LqM57qn57yT5a2YKSxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfaWNvblxcXCIsXFxuICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGxldCBwYSA9ICQudWlDb25maWcuZ2V0KCkuZXIu5LqM57qn57yT5a2YO1xcbiAgICAgICAgaWYgKHBhKSB7XFxuICAgICAgICAgIHBhID0gZmFsc2U7XFxuICAgICAgICB9IGVsc2UgaWYgKCFwYSkge1xcbiAgICAgICAgICBwYSA9IHRydWU7XFxuICAgICAgICB9XFxuICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAkLnVpQ29uZmlnLnNldChwYSwgXFxcImVyLuS6jOe6p+e8k+WtmFxcXCIpO1xcbiAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICB9KVxcbiAgICB9KVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi6L+Y5Y6fXFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfMlxcXCIsXFxuICAgICAgdXJsOi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T4ge1xcbiAgICAgICAgICAgIHZhciB1YyA9ICQudWlDb25maWcuZ2V0KCk7XFxuICAgICAgICAgICAgcmV0dXJuICQoXFxcInt7Y2xpcGJvYXJkfX1cXFwiKS5pbnB1dCgodWMpID0+IHtcXG4gICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHVjLmVyID0gSlNPTi5wYXJzZShpbnB1dCk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVjKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5qC85byP6ZSZ6K+vXFxcIilcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCB1YylcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1dXFxuICAgICAgfVxcbiAgICB9KVxcbiAgfVxcbiAgc2V0UmVzdWx0KGQpO1xcbn1cIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIkxvY2FsUHJveHlcIixcInBhdGhcIjpcIkxvY2FsUHJveHlcIixcInJ1bGVcIjpcImZ1bmN0aW9uIHByb3h5KCkge1xcbiAgICBmdW5jdGlvbiBwYXJzZVZpZGVvKE1ZX1BBUkFNUywgdGl0bGUpIHtcXG4gICAgICAgIGZ1bmN0aW9uIHRvUGF0aCh2YWx1ZSkge1xcbiAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgIT09ICdzdHJpbmcnKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBbXTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IHBhdGggPSBbXTtcXG4gICAgICAgICAgICBsZXQgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgIGxldCBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgbGV0IGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdmFsdWUubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGNoYXIgPSB2YWx1ZVtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGVzY2FwZSkge1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgICAgICAgICAgZXNjYXBlID0gZmFsc2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1xcXFxcXFxcJykge1xcbiAgICAgICAgICAgICAgICAgICAgZXNjYXBlID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnLicgJiYgIWluQnJhY2tldHMpIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnWycpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSB0cnVlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICddJykge1xcbiAgICAgICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCArPSBjaGFyO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChjdXJyZW50KSB7XFxuICAgICAgICAgICAgICAgIHBhdGgucHVzaChjdXJyZW50KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIHBhdGg7XFxuICAgICAgICB9XFxuXFxuICAgICAgICBmdW5jdGlvbiBnZXRKc29uKG9iaiwgcGF0aCkge1xcbiAgICAgICAgICAgIGlmICghb2JqIHx8ICFBcnJheS5pc0FycmF5KHBhdGgpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGlmIChwYXRoLmxlbmd0aCA9PT0gMCkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgY3VycmVudCA9IG9iajtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHBhdGgubGVuZ3RoOyBpKyspIHtcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IHBhdGhbaV07XFxuICAgICAgICAgICAgICAgIGlmIChjdXJyZW50ID09PSBudWxsIHx8IGN1cnJlbnQgPT09IHVuZGVmaW5lZCB8fCB0eXBlb2YgY3VycmVudCAhPT0gJ29iamVjdCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgY3VycmVudCA9IGN1cnJlbnRba2V5XTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGN1cnJlbnQ7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIGxldCBydW5UeXBlID0gTVlfUEFSQU1TLnJ1blR5cGVbMF07XFxuICAgICAgICAgICAgbGV0IHVybCA9IGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnVybFswXSkpO1xcbiAgICAgICAgICAgIGlmIChydW5UeXBlID09IFxcXCJKU09OXFxcIikge1xcblxcbiAgICAgICAgICAgICAgICBsZXQgcGFyYW0gPSBKU09OLnBhcnNlKGRlY29kZVVSSUNvbXBvbmVudChiYXNlNjREZWNvZGUoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UocmVxdWVzdCh1cmwsIHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHBhcmFtLmhlYWRlcnMgfHwge30sXFxuICAgICAgICAgICAgICAgICAgICBtZXRob2Q6IHBhcmFtLm1ldGhvZCB8fCB2b2lkIDBcXG4gICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogT2JqZWN0LmFzc2lnbih7fSwgcGFyYW0uaGVhZGVycyB8fCB7fSwge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IGdldEpzb24oanNvbiwgdG9QYXRoKHBhcmFtLmpzb25QYXRoKSksXFxuICAgICAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKHJ1blR5cGUgPT0gXFxcIkpTXFxcIikge1xcblxcbiAgICAgICAgICAgICAgICBsZXQgcGFyc2U7XFxuICAgICAgICAgICAgICAgIGlmIChNWV9QQVJBTVMuaW5kZXgpIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlID0gJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHRpdGxlKS5nZXRKc29uKClbTVlfUEFSQU1TLmluZGV4WzBdXTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlID0gSlNPTi5wYXJzZShiYXNlNjREZWNvZGUoZGVjb2RlVVJJQ29tcG9uZW50KE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgcmVzID0gbmV3IEZ1bmN0aW9uKFxcXCJ1cmxcXFwiLCBcXFwic2VsZlxcXCIsIHBhcnNlLmpzKSh1cmwsIHBhcnNlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXMgPT09IFxcXCJzdHJpbmdcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxcXCJMb2NhdGlvblxcXCI6IHJlc1xcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCQudHlwZShyZXMpID09PSBcXFwib2JqZWN0XFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcmVzXFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBkb0pzKE1ZX1BBUkFNUywgdGl0bGUsIGdrZXkpIHtcXG4gICAgICAgIGxldCB7XFxuICAgICAgICAgICAgR01cXG4gICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcImh0dHA6Ly9oaWtlci5ub2tpYS5wcmVzcy9oaWtlcnVsZS9ydWxlbGlzdC5qc29uP2lkPTY5MTYmYXV0aD0xZDM1ZThmMC0yMmU4LTUyNzAtYTlkMS04MjZmNTNmMT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5a+56LGh77yM5L2/55SoT2JqZWN0LmZyb21FbnRyaWVz5ZKMT2JqZWN0LmVudHJpZXPmnaXlpITnkIbplK5cXG4gICAgICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXMoaXRlbSk7XFxuICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkRW50cmllcyA9IGVudHJpZXMubWFwKChba2V5LCB2YWx1ZV0pID0+IHtcXG4gICAgICAgICAgICAgIC8vIOWmguaenOaciemHjeWRveWQjeWbnuiwg+WHveaVsO+8jOWImeiwg+eUqOWug1xcbiAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZW5hbWVDYWxsYmFjayA9PT0gJ2Z1bmN0aW9uJykge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gW3JlbmFtZUNhbGxiYWNrKGtleSwgdmFsdWUpLCB2YWx1ZV07XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICByZXR1cm4gW2tleSwgdmFsdWVdO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIGNvbnN0IGZpbHRlcmVkRW50cmllcyA9IHNob3VsZEV4Y2x1ZGUgP1xcbiAgICAgICAgICAgICAgcHJvY2Vzc2VkRW50cmllcy5maWx0ZXIoKFtrZXldKSA9PiAha2V5c1RvSGFuZGxlLmluY2x1ZGVzKGtleSkpIDpcXG4gICAgICAgICAgICAgIHByb2Nlc3NlZEVudHJpZXMuZmlsdGVyKChba2V5XSkgPT4ga2V5c1RvSGFuZGxlLmluY2x1ZGVzKGtleSkpO1xcbiAgICAgICAgICAgIHJldHVybiBPYmplY3QuZnJvbUVudHJpZXMoZmlsdGVyZWRFbnRyaWVzKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAvLyDlpoLmnpzlhYPntKDkuI3mmK/lr7nosaHmiJbmlbDnu4TvvIznm7TmjqXov5Tlm55cXG4gICAgICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICAgICAgfVxcb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UNsYXNzID0gaG9tZTtcXG5cXG4gICAgICAgIHJldHVybiBob21lO1xcbiAgICB9LFxcbiAgICBob21lVm9kKCkge1xcbiAgICAgICAgLyppZih0aGlzLnZvZENvdW50KXtcXG4gICAgICAgICAgICB0aGlzLmluaXQoKTtcXG4gICAgICAgIH0qL1xcbiAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmdldEhvbWVEYXRhKCk7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3Q6IGRhdGEubGlzdCB8fCBbXVxcbiAgICAgICAgfSk7XFxuICAgICAgICB0aGlzLnZvZENvdW50Kys7XFxuICAgIH0sXFxuICAgIGhvbWUoKSB7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkodGhpcy5nZXRIb21lRGF0YSgpKTtcXG4gICAgfSxcXG4gICAgY2F0ZWdvcnkodGlkLCBwZywgZmlsdGVyLCBleHRlbmQpIHtcXG4gICAgICAgIHJldHVybiBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwidmlkZW9saXN0XFxcIixcXG4gICAgICAgICAgICB0OiB0aWQsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGcsXFxuICAgICAgICAgICAgZXh0ZW5kOiB0aGlzLmV4dCxcXG4gICAgICAgICAgICBleHQ6IGV4dGVuZCA/IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShleHRlbmQpKSA6IFxcXCJcXFwiXFxuICAgICAgICB9KSwge1xcbiAgICAgICAgICAgIHJlZGlyZWN0OiB0aGlzLnJlZGlyZWN0XFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgZGV0YWlsKHZvZF91cmwpIHtcXG4gICAgICAgIHJldHVybiBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwiZGV0YWlsXFxcIixcXG4gICAgICAgICAgICB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kpLnJlcGxhY2UoL1xcXFw8Lio/eG1sLio/XFxcXD4vLCBcXFwiXFxcIik7XFxuICAgICAgICBsZXQgaG9tZSA9IHtcXG4gICAgICAgICAgICBsaXN0OiBbXSxcXG4gICAgICAgICAgICBjbGFzczogW11cXG4gICAgICAgIH07XFxuICAgICAgICBsZXQgaG9tZVhtbCA9IG5ldyBYTUwoeG1sKTtcXG4gICAgICAgIGZvciBlYWNoKGxldCBpdGVtIGluIGhvbWVYbWwubGlzdC52aWRlbykge1xcbiAgICAgICAgICAgIGhvbWUubGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB0eXBlX2lkOiBpdGVtLnRpZC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKClcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIGZvciBlYWNoKGxldCBpdGVtIGluIGhvbWVYbWwuY2xhc3MudHkpIHtcXG4gICAgICAgICAgICBob21lLmNsYXNzLnB1c2goe1xcbiAgICAgICAgICAgICAgICB0eXBlX2lkOiBpdGVtLkBpZCxcXG4gICAgICAgICAgICAgICAgdHlwZV9uYW1lOiBpdGVtLnRvU3RyaW5nKCksXFxuXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShob21lLmNsYXNzKSAmJiBBcnJheS5pc0FycmF5KHRoaXMuY2F0ZWdvcnlmaWx0ZXIpKSB7XFxuICAgICAgICAgICAgaG9tZS5jbGFzcyA9IGhvbWUuY2xhc3MuZmlsdGVyKHYgPT4g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gICAgICAgICAgICAgICB2b2RfdGltZTogaXRlbS5sYXN0LnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9waWM6IGl0ZW0ucGljLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9yZW1hcmtzOiBpdGVtLm5vdGUudG9TdHJpbmcoKVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICBsaXN0XFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgZGV0YWlsKHZvZF91cmwpIHtcXG4gICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwiZGV0YWlsXFxcIixcXG4gICAgICAgICAgICBpZHM6IHZvZF91cmwsXFxuICAgICAgICB9KSkucmVwbGFjZSgvXFxcXDwuKj94bWwuKj9cXFxcPi8sIFxcXCJcXFwiKTtcXG4gICAgICAgIGxldCBob21lWG1sID0gbmV3IFhNTCh4bWwpO1xcbiAgICAgICAgbGV0IGxpc3QgPSBbXTtcXG4gICAgICAgIGZvciBlYWNoKGxldCBpdGVtIGluIGhvbWVYbWwubGlzdC52aWRlbykge1xcbiAgICAgICAgICAgIGxldCByZXNpdGVtID0ge1xcbiAgICAgICAgICAgICAgICB2b2RfaWQ6IGl0ZW0uaWQudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX25hbWU6IGl0ZW0ubmFtZS50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfdGltZTogaXRlbS5sYXN0LnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9waWM6IGl0ZW0ucGljLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9yZW1hcmtzOiBpdGVtLm5vdGUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX2NvbnRlbnQ6IGl0ZW0uZGVzLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9hY3RvcjogaXRlbS5hY3Rvci50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfZGlyZWN0b3I6IGl0ZW0uZGlyZWN0b3IudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIGxldCBmcm9tID0gW107XFxuICAgICAgICAgICAgbGV0IHBsYXkgPSBbXTtcXG4gICAgICAgICAgICBmb3IgZWFjaChsZXQgcGxheUxpc3RJdGVtIGluIGl0ZW0uZGwuZGQpIHtcXG4gICAgICAgICAgICAgICAgZnJvbS5wdXNoKHBsYXlMaXN0SXRlbS5AZmxhZyk7XFxuICAgICAgICAgICAgICAgIHBsYXkucHVzaChwbGF5TGlzdEl0ZW0udG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJlc2l0ZW0udm9kX3BsYXlfZnJvbSA9IGZyb20uam9pbihcXFwiJCQkXFxcIik7XFxuICAgICAgICAgICAgcmVzaXRlbS52b2RfcGxheV91cmwgPSBwbGF5LmpvaW4oXFxcIiQkJFxcXCIpO1xcbiAgICAgICAgICAgIGxpc3QucHVzaChyZXNpdGVtKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgbGlzdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIHBsYXkoZmxhZywgaW5wdXQpIHtcXG4gICAgICAgIGxldCBwYXJzZV91cmwgPSB0aGlzLnNvdXJjZS5wbGF5dXJsIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKC9cXFxcLihtM3U4fG1wNCkvLnRlc3QoaW5wdXQpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgcGFyc2U6IDAsXFxuICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaWYgKHBhcnNlX3VybC5zdGFydHNXaXRoKCdqc29uOicpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBwdXJsID0gcGFyc2VfdXJsLnJlcGxhY2UoJ2pzb246JywgJycpICsgaW5wdXQ7XFxuICAgICAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChwdXJsKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDAsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBKU09OLnBhcnNlKGh0bWwpLnVybFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBpbnB1dFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDEsXFxuICAgICAgICAgICAgICAgICAgICB1cmw6IHBhcnNlX3VybCArIGlucHV0XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAgc2VhcmNoKHdkLCBxdWljaywgcGcpIHtcXG4gICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIHdkO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hc3NcXFwiXFxuICAgICAgICB9KSkpO1xcbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaG9tZS5jbGFzcykgJiYgQXJyYXkuaXNBcnJheSh0aGlzLmNhdGVnb3J5ZmlsdGVyKSkge1xcbiAgICAgICAgICAgIGhvbWUuY2xhc3MgPSBob21lLmNsYXNzLmZpbHRlcih2ID0+IHRoaXMuY2F0ZWdvcnlmaWx0ZXIuaW5jbHVkZXModi50eXBlX25hbWUpKVxcbiAgICAgICAgfVxcbiAgICAgICAgdGhpcy5jYWNoZUNsYXNzID0gaG9tZTtcXG5cXG4gICAgICAgIHJldHVybiBob21lO1xcbiAgICB9LFxcbiAgICBob21lVm9kKCkge1xcbiAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmdldEhvbWVEYXRhKCk7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3Q6IGRhdGEubGlzdCB8fCBbXVxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGhvbWUoKSB7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkodGhpcy5nZXRIb21lRGF0YSgpKTtcXG4gICAgfSxcXG4gICAgY2F0ZWdvcnkodGlkLCBwZywgZmlsdGVyLCBleHRlbmQpIHtcXG4gICAgICAgIHJldHVybiBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwidmlkZW9saXN0XFxcIixcXG4gICAgICAgICAgICB0OiB0aWQsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKTtcXG4gICAgfSxcXG4gICAgZGV0YWlsKHZvZF91cmwpIHtcXG4gICAgICAgIHJldHVybiBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwiZGV0YWlsXFxcIixcXG4gICAgICAgICAgICBpZHM6IHZvZF91cmwsXFxuICAgICAgICB9KSk7XFxuICAgIH0sXFxuICAgIHBsYXkoZmxhZywgaW5wdXQpIHtcXG4gICAgICAgIGxldCBwYXJzZV91cmwgPSB0aGlzLnNvdXJjZS5wbGF5dXJsIHx8IFxcXCJcXFwiO1xcbiAgICAgICAgaWYgKC9cXFxcLihtM3U4fG1wNCkvLnRlc3QoaW5wdXQpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgcGFyc2U6IDAsXFxuICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaWYgKHBhcnNlX3VybC5zdGFydHNXaXRoKCdqc29uOicpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBwdXJsID0gcGFyc2VfdXJsLnJlcGxhY2UoJ2pzb246JywgJycpICsgaW5wdXQ7XFxuICAgICAgICAgICAgICAgIGxldCBodG1sID0gcmVxdWVzdChwdXJsKTtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDAsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBKU09OLnBhcnNlKGh0bWwpLnVybFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2U6IDEsXFxuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBpbnB1dFxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi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Wpzb24uaGFzT3duUHJvcGVydHkoaykpIHtcXG4gICAgICAgICAgICAgICAgJC5fdGhlbWUuc2V0KGssIHYpO1xcbiAgICAgICAgICAgICAgICBzdWNjZXNzID0gdHJ1ZTtcXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCJrZXk6XFxcIiArIGsgKyBcXFwiIOW3sue7j+WtmOWcqCzot7Pov4dcXFwiKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIGlmIChzdWNjZXNzKSB7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WvvOWFpeaIkOWKn1xcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+agvOW8j+mUmeivr1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pXFxuICAgICAgfVxcbiAgICAgIGlmICh4ID09IFxcXCLmlLnlkI1cXFwiKSB7XFxuICAgICAgICBpZiAoL14o6buY6K6kfOW9k+WJjSkkLy50ZXN0KG5rKSkge1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN6IO95pS55ZCNXFxcIjtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIHJldHVybiAkKFxcXCLmlrDlkI3np7BcXFwiKS5pbnB1dCgoaykgPT4ge1xcbiAgICAgICAgICAgIGxldCBvYmogPSAkLl90aGVtZS5nZXQoKTtcXG4gICAgICAgICAgICBsZXQgbmV3T2JqID0gT2JqZWN0LmtleXMob2JqKS5yZWR1Y2UoKGFjYywga2V5KSA9PiB7XFxuICAgICAgICAgICAgICBpZiAoa2V5ID09PSBrKSB7XFxuICAgICAgICAgICAgICAgIGFjY1tpbnB1dF0gPSBvYmpba2V5XTtcXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGFjY1trZXldID0gb2JqW2tleV07XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICByZXR1cm4gYWNjO1xcbiAgICAgICAgICAgIH0sIHt9KTtcXG4gICAgICAgICAgICAkLl90aGVtZS5zYXZlKEpTT04uc3RyaW5naWZ5KG5ld09iaikpO1xcbiAgICAgICAgICAgIHB1dE15VmFyKCQubXlfdXJsICsgXFxcIm5cXFwiLCBpbnB1dCk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgfSwgbmspXFxuICAgICAgICB9XFxuICAgICAgfVxcbiAgICAgIGlmICh4ID09IFxcXCLliKDpmaRcXFwiKSB7XFxuICAgICAgICBpZiAoL14o6buY6K6kfOW9k+WJjSkkLy50ZXN0KG5rKSkge1xcbiAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN6IO95Yig6ZmkXFxcIjtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIHJldHVybiAkKFxcXCLnoa7orqTliKDpmaRcXFwiKS5jb25maXJtKChrKSA9PiB7XFxuICAgICAgICAgICAgLyoqXFxuICAgICAgICAgICAgICog6I635Y+W5a+56LGh5Lit57uZ5a6a6ZSu55qE5YmN5LiA5Liq5oiW5ZCO5LiA5Liq6ZSu44CCXFxuXFxuICAgICAgICAgICAgICog5q2k5Ye95pWw55So5LqO6YGN5Y6G5a+56LGh55qE6ZSu77yM5qC55o2u57uZ5a6a55qE6ZSu5om+5Yiw5YW25YmN5LiA5Liq5oiW5ZCO5LiA5Liq6ZSu44CCXFxuICAgICAgICAgICAgICog5aaC5p6c57uZ5a6a55qE6ZSu5LiN5a2Y5Zyo5LqO5a+56LGh5Lit77yM5Ye95pWw5bCG5bCd6K+V5om+5Yiw5aSn5LqO57uZ5a6a6ZSu55qE56ys5LiA5Liq6ZSu44CCXFxuICAgICAgICAgICAgICog5aaC5p6c5a+56LGh5Lit5rKh5pyJ5aSn5LqO57uZ5a6a6ZSu55qE6ZSu77yM5YiZ6L+U5Zue5a+56LGh55qE5pyA5ZCO5LiA5Liq6ZSu44CCXFxuICAgICAgICAgICAgICogXFxuICAgICAgICAgICAgICogQHBhcmFtIHtPYmplY3R9IG9iaiDopoHpgY3ljobnmoTlr7nosaHjgIJcXG4gICAgICAgICAgICAgKiBAcGFyYW0ge3N0cmluZ30ga2V5IOimgeafpeaJvuWJjeS4gOS4quaIluWQjuS4gOS4qumUrueahOmUruOAglxcbiAgICAgICAgICAgICAqIEByZXR1cm5zIHtzdHJpbmd9IOi/lOWbnuaJvuWIsOeahOWJjeS4gOS4quaIluWQjuS4gOS4qumUruOAglxcbiAgICAgICAgICAgICAqL1xcbiAgICAgICAgICAgIGZ1bmN0aW9uIGdldFByZXZpb3VzT3JOZXh0S2V5KG9iaiwga2V5KSB7XFxuICAgICAgICAgICAgICBjb25zdCBrZXlzID0gT2JqZWN0LmtleXMob2JqKTtcXG4gICAgICAgICAgICAgIGNvbnN0IGluZGV4ID0ga2V5cy5pbmRleE9mKGtleSk7XFxuICAgICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICAvLyDlpoLmnpzplK7lrZjlnKjvvIzov5Tlm57liY3kuIDkuKrplK5cXG4gICAgICAgICAgICAgICAgcmV0dXJuIGluZGV4ID4gMCA/IGtleXNbaW5kZXggLSAxXSA6IGtleXNbaW5kZXggKyAxXTsgLy8g5aaC5p6c5piv56ys5LiA5Liq6ZSu77yM6L+U5Zue5LiL5LiA5Liq6ZSuXFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAvLyDlpoLmnpzplK7kuI3lrZjlnKjvvIzov5Tlm57kuIvkuIDkuKrplK5cXG4g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i5paw5ZCN56ewXFxcIikuaW5wdXQoKGspID0+IHtcXG4gICAgICAgICAgbGV0IG9iaiA9ICQuX3RoZW1lLmdldCgpO1xcbiAgICAgICAgICBsZXQgbmV3T2JqID0gT2JqZWN0LmtleXMob2JqKS5yZWR1Y2UoKGFjYywga2V5KSA9PiB7XFxuICAgICAgICAgICAgaWYgKGtleSA9PT0gaykge1xcbiAgICAgICAgICAgICAgYWNjW2lucHV0XSA9IG9ialtrZXldO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBhY2Nba2V5XSA9IG9ialtrZXldO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gYWNjO1xcbiAgICAgICAgICB9LCB7fSk7XFxuICAgICAgICAgICQuX3RoZW1lLnNhdmUoSlNPTi5zdHJpbmdpZnkobmV3T2JqKSk7XFxuICAgICAgICAgIHB1dE15VmFyKCQubXlfdXJsICsgXFxcIm5cXFwiLCBpbnB1dCk7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICB9LCBrKVxcbiAgICAgIH0sIGspXFxuICAgIH0pXFxuICB9XFxuICBkLnB1c2goe1xcbiAgICB0aXRsZTogbmsgPT0gayA/ICfigJzigJzigJ3igJ0nICsgay5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogayxcXG4gICAgY29sX3R5cGU6IFxcXCJzY3JvbGxfYnV0dG9uXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChrKSA9PiB7XFxuICAgICAgcHV0TXlWYXIoTVlfVVJMICsgXFxcIm5cXFwiLCBrKTtcXG4gICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgIH0sIGspLFxcbiAgICBleHRyYToge1xcbiAgICAgIExvbmdDbGljazogbG9uZ2NsaWNrc1xcbiAgICB9XFxuICB9KVxcb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