xiaomianao666

小程序:DrpyHiker

Nov 4th, 2024
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJmaXJzdEhlYWRlciI6ImNsYXNzIiwibGFzdF9jaGFwdGVyX3J1bGUiOiIiLCJ0aXRsZSI6IkRycHlIaWtlciIsImF1dGhvciI6IkFyaWVzIiwidXJsIjoiaGlrZXI6Ly9lbXB0eSMjZnlwYWdlIiwidmVyc2lvbiI6NDksImNvbF90eXBlIjoibW92aWVfMyIsImNsYXNzX25hbWUiOiIiLCJ0eXBlIjoidmlkZW8iLCJjbGFzc191cmwiOiIiLCJhcmVhX25hbWUiOiIiLCJhcmVhX3VybCI6IiIsInNvcnRfbmFtZSI6IiIsInllYXJfbmFtZSI6IiIsInNvcnRfdXJsIjoiIiwieWVhcl91cmwiOiIiLCJmaW5kX3J1bGUiOiJqczokLnJlcXVpcmUoXCJNaWFuTG9hZFwiKTsiLCJzZWFyY2hfdXJsIjoiaGlrZXI6Ly9lbXB0eT9zPSoqJnBhZ2U9ZnlwYWdlIiwiZ3JvdXAiOiLikaDmjqjojZAiLCJzZWFyY2hGaW5kIjoianM6XG4oZnVuY3Rpb24gKCkge1xuICBsZXQge1xuICAgIHVpX2NvbmZpZyxcbiAgfSA9ICQucmVxdWlyZShcIlVJTWFuYWdlXCIpO1xuICB1aV9jb25maWc9dWlfY29uZmlnLnlpO1xuXG4gIGxldCBzbW9kZSA9IE51bWJlcihnZXRJdGVtKFwic21vZGVcIiwgXCIwXCIpKTtcbiAgbGV0IHRlbXNtb2RlID0gZ2V0TXlWYXIoXCJ0ZW1zbW9kZVwiLCBcIlwiKTtcbiAgaWYgKHRlbXNtb2RlKSB7XG4gICAgc21vZGUgPSBOdW1iZXIodGVtc21vZGUpO1xuICAgIGNsZWFyTXlWYXIoXCJ0ZW1zbW9kZVwiKTtcbiAgfVxuICBpZiAoIWZpbGVFeGlzdChcImhpa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mxpc3QgfHwgW107XG4gICAgfSBjYXRjaCB7IH1cbiAgICBsZXQgZCA9IFtdO1xuICAgIGxldCBza2lwRXIgPSBkcnB5LmdldFJ1bGUoXCLkuoznuqdcIikgPT09IFwiKlwiICYmIGdldEl0ZW0oXCJza2lwRXJcIiwgXCJcIik7XG5cbiAgICBmb3IgKGxldCBpdCBvZiBob21lTGlzdCkge1xuICAgICAgbGV0IGNpZDtcbiAgICAgIGxldCBpZCA9IFN0cmluZyhpdC52b2RfaWQpO1xuICAgICAgbGV0IHVybCA9IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkXCIrdWlfY29uZmlnLm1hcms7XG4gICAgICBpZiAoc2tpcEVyKSB7XG4gICAgICAgIHVybCA9ICQoKS5sYXp5UnVsZSgoc291cmNlLCBpZCwgbXkpID0+IHtcbiAgICAgICAgICBsZXQgdXJsO1xuICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIik7XG4gICAgICAgICAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0QnlTb3VyY2Uoc291cmNlKTtcbiAgICAgICAgICAgIHVybCA9IEpTT04ucGFyc2UoZHJweS5kZXRhaWwoaWQpKS5saXN0WzBdLnZvZF9wbGF5X3VybC5zcGxpdChcIiRcIilbMV07XG4gICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgLy9sb2coZS5tZXNzYWdlKTtcbiAgICAgICAgICAgIHVybCA9IGlkLnNwbGl0KFwiQEBcIilbMF07XG4gICAgICAgICAgfVxuICAgICAgICAgIGxldCByZXN1bHQ7XG4gICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHJlc3VsdCA9ICQucmVxdWlyZShcInZpZGVvVXJsXCIpLnBhcnNlKHVybCwgaWQsIHNvdXJjZSk7XG4gICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHtcbiAgICAgICAgICAgIC8vbG9nKGVycm9yLm1lc3NhZ2UpO1xuICAgICAgICAgIH1cbiAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICB9LCBzb3VyY2UsIGlkLCBNWV9SVUxFLnRpdGxlKTtcbiAgICAgICAgY2lkID0gaWQ7XG4gICAgICB9XG5cbiAgICAgIGQucHVzaCh7XG4gICAgICAgIHRpdGxlOiBpdC52b2RfbmFtZSxcbiAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MgKyBcIsK3XCIgKyBzb3VyY2UubmFtZSxcbiAgICAgICAgY29udGVudDogaXQudm9kX2NvbnRlbnQsXG4gICAgICAgIHVybDogdXJsLFxuICAgICAgICBwaWNfdXJsOiBpdC52b2RfcGljLFxuICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgaWQ6IGNpZCxcbiAgICAgICAgICB2b2RJZDogaWQsXG4gICAgICAgICAgaW1nOiBpdC52b2RfcGljLFxuICAgICAgICAgIHNuYW1lOiBzb3VyY2UubmFtZSxcbiAgICAgICAgICBza2V5OiBzb3VyY2Uua2V5LFxuICAgICAgICB9XG4gICAgICB9KTtcbiAgICB9XG4gICAgc2V0UmVzdWx0KGQpO1xuICB9IGVsc2Uge1xuICAgIHNldFJlc3VsdChbe1xuICAgICAgdGl0bGU6IFwi54K55oiR5byA5aeL6IGa5ZCI5pCc57SiXCIgKyBNWV9LRVlXT1JELFxuICAgICAgdXJsOiBcImhpa2VyOi8vc2VhcmNoP3M9XCIgKyBNWV9LRVlXT1JELFxuICAgICAgZXh0cmE6IHtcbiAgICAgICAgZGVsZWdhdGVPbmx5U2VhcmNoOiB0cnVlLFxuICAgICAgICBydWxlczogJC50b1N0cmluZygoKSA9PiB7XG4gICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFwicnVudGltZUNvbmZpZ1wiLCBcInJ1bnRpbWVDb25maWdcIik7XG4gICAgICAgICAgICBsZXQgc21vZGUgPSBOdW1iZXIoZ2V0SXRlbShcInNtb2RlXCIsIFwiMFwiKSk7XG4gICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsb3dTZWFyY2hTb3VyY2Uoc21vZGUgPT09IDIpO1xuXG4gICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG5cbiAgICAgICAgICAgIGxldCBsaXN0aSA9IGxpc3QuZmluZEluZGV4KHggPT4geC5rZXkgPT0gc291cmNlLmtleSk7XG5cbiAgICAgICAgICAgIGxldCBzZWFyY2hzb3J0ID0gTnVtYmVyKGdldEl0ZW0oXCJzZWFyY2hzb3J0XCIsIFwiMFwiKSk7XG4gICAgICAgICAgICBsZXQge1xuICAgICAgICAgICAgICBuYXR1cmFsU29ydCxcbiAgICAgICAgICAgICAgdXNpbmdTb3J0XG4gICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFwibWV0aG9kc1wiKTtcblxuICAgICAgICAgICAgaWYgKHNlYXJjaHNvcnQgPiAwKSB7XG4gICAgICAgICAgICAgIGlmIChzZWFyY2hzb3J0ID09IDEpIHtcbiAgICAgICAgICAgICAgICBuYXR1cmFsU29ydChsaXN0LCBcIm5hbWVcIik7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2VhcmNoc29ydCA9PSAyKSB7XG4gICAgICAgICAgICAgICAgdXNpbmdTb3J0LnNldGtleShcIm5hbWVcIik7XG4gICAgICAgICAgICAgICAgdXNpbmdTb3J0LmdldChsaXN0KVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChzb3VyY2Uuc2VhcmNoYWJsZSAmJiBsaXN0aSAhPSAtMSkge1xuICAgICAgICAgICAgICBsaXN0LnNwbGljZShsaXN0LmluZGV4T2Yoc291cmNlKSwgMSk7XG4gICAgICAgICAgICAgIGxpc3QudW5zaGlmdChzb3VyY2UpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcbiAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgIGxldCB7XG4gICAgICAgICAgICAgICAgICAgIHVpX2NvbmZpZyxcbiAgICAgICAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXCJVSU1hbmFnZVwiKTtcbiAgICAgICAgICAgICAgICAgIHVpX2NvbmZpZz11aV9jb25maWcueWk7XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IEdNLmRlZmluZU1vZHVsZShcIkRycHlNYW5hZ2VcIikuZ2V0KGl0ZW0ua2V5KTtcbiAgICAgICAgICAgICAgICAgIGxldCBob21lTGlzdCA9IEpTT04ucGFyc2UoZHJweS5zZWFyY2goTVlfS0VZV09SRCwgZmFsc2UsIE1ZX1BBR0UpKS5saXN0IHx8IFtdO1xuICAgICAgICAgICAgICAgICAgbGV0IHNraXBFciA9IGRycHkuZ2V0UnVsZShcIuS6jOe6p1wiKSA9PT0gXCIqXCIgJiYgZ2V0SXRlbShcInNraXBFclwiLCBcIlwiKTtcbiAgICAgICAgICAgICAgICAgIGxldCBkID0gW107XG4gICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBob21lTGlzdCkge1xuICAgICAgICAgICAgICAgICAgICBsZXQgY2lkO1xuICAgICAgICAgICAgICAgICAgICBsZXQgaWQgPSBTdHJpbmcoaXQudm9kX2lkKTtcbiAgICAgICAgICAgICAgICAgICAgbGV0IHVybCA9IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkXCIrdWlfY29uZmlnLm1hcms7XG4gICAgICAgICAgICAgICAgICAgIGlmIChza2lwRXIpIHtcbiAgICAgICAgICAgICAgICAgICAgICB1cmwgPSAkKCkubGF6eVJ1bGUoKHNvdXJjZSwgaWQsIG15KSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgdXJsO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXCJEcnB5TWFuYWdlXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZHJweSA9IERycHlNYW5hZ2UuZ2V0QnlTb3VyY2Uoc291cmNlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gSlNPTi5wYXJzZShkcnB5LmRldGFpbChpZCkpLmxpc3RbMF0udm9kX3BsYXlfdXJsLnNwbGl0KFwiJFwiKVsxXTsgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyhlLm1lc3NhZ2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBpZC5zcGxpdChcIkBAXCIpWzBdO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJlc3VsdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9ICQucmVxdWlyZShcInZpZGVvVXJsXCIpLnBhcnNlKHVybCwgaWQsIHNvdXJjZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAvL2xvZyhlcnJvci5tZXNzYWdlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICAgICAgICAgICAgfSwgaXRlbSwgaWQsTVlfUlVMRS5fdGl0bGUpO1xuICAgICAgICAgICAgICAgICAgICAgIGNpZCA9IGlkO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgZC5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICB0aXRsZTogaXQudm9kX25hbWUsXG4gICAgICAgICAgICAgICAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MsXG4gICAgICAgICAgICAgICAgICAgICAgY29udGVudDogaXQudm9kX2NvbnRlbnQsXG4gICAgICAgICAgICAgICAgICAgICAgdXJsOiB1cmwsXG4gICAgICAgICAgICAgICAgICAgICAgcGljX3VybDogaXQudm9kX3BpYyxcbiAgICAgICAgICAgICAgICAgICAgICBjb2xfdHlwZTogXCJtb3ZpZV8zXCIsXG4gICAgICAgICAgICAgICAgICAgICAgZXh0cmE6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBjaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICB2b2RJZDogaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICBpc1BvbHltZXJpemU6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgICBzbmFtZTogaXRlbS5uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgc2tleTogaXRlbS5rZXksXG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIHNldFJlc3VsdChkKTtcbiAgICAgICAgICAgICAgICB9LCBpd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pLFxcbiAgICAgICAgICBzdXJsOiB1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldLFxcbiAgICAgICAgICB1cmw6IGlzTm92ZWwgPyBcXFwiaGlrZXI6Ly9wYWdlL25vdmVsI2F1dG9QYWdlIyNyZWFkVGhlbWUjXFxcIiA6ICh1aWQgKyBcXFwiI1xcXCIgKyBmcm9tW2ldICsgcGxheUxhenkpLFxcbiAgICAgICAgICBjb2xfdHlwZTogY29sLFxcbiAgICAgICAgICBpbWc6IGltZyxcXG4gICAgICAgICAgLypleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgZXh0cmEsIHtcXG4gICAgICAgICAgICBcXFwiUmVmZXJlclxcXCI6IGRlY29kZVVSSUNvbXBvbmVudChrWzFdKSxcXG4gICAgICAgICAgICBpZDoga1sxXSxcXG4gICAgICAgICAgICAvL2xpbmVWaXNpYmxlOiBmYWxzZSxcXG4gICAgICAgICAgICB0ZXh0QWxpZ246IHRleHRhbGlnbixcXG4gICAgICAgICAgICBjbHM6IFxcXCJwbGF5bGlzdFxcXCIsXFxuICAgICAgICAgIH0pKi9cXG4gICAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgICBmcm9tOiBmcm9tW2ldLFxcbiAgICAgICAgICAgIHNvdXJjZTogc291cmNlLFxcbiAgICAgICAgICAgIGlkOiB1aWQsXFxuICAgICAgICAgICAgYmxvY2tSdWxlczogWydiYi4qLnBuZycsICcuanBnJywgXFxcImhtXFxcXC5iYWlkdVxcXFwuY29tXFxcXC9obS5qc1xcXCJdLFxcbiAgICAgICAgICAgIHZpZGVvRXhjbHVkZVJ1bGVzOiBbJz91cmw9J10sXFxuICAgICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgfVxcbiAgICAgICAgfTtcXG4gICAgICB9KTtcXG5cXG4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xXSwgaW5wdXRbMF0pKTtcXG4gICAgICAgICAgaWYgKHJlc3VsdC51cmwuc3RhcnRzV2l0aChcXFwicGljczovL1xcXCIpKSB7XFxuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdC51cmw7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocmVzdWx0LnVybC5zdGFydHNXaXRoKFxcXCJub3ZlbDovL1xcXCIpKSB7XFxuICAgICAgICAgICAgbGV0IGNvbnRlbnQgPSBKU09OLnBhcnNlKHJlc3VsdC51cmwucmVwbGFjZShcXFwibm92ZWw6Ly9cXFwiLCBcXFwiXFxcIikpLmNvbnRlbnQ7XFxuICAgICAgICAgICAgbGV0IGNtZDUgPSBtZDUoY29udGVudCk7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gMDtcXG4gICAgICAgICAgICBpZiAoKGluZGV4ID0gJC5oaWtlcltcXFwiX190ZXN0X19cXFwiXS5pbmRleE9mKGNtZDUpKSAhPT0gLTEpIHtcXG4gICAgICAgICAgICAgIGxvZyhcXFwi6YeN5aSN77yaXFxcIiArIGlucHV0ICsgXFxcIj0+XFxcIiArIGluZGV4KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgJC5oaWtlcltcXFwiX190ZXN0X19cXFwiXS5wdXNoKGNtZDUpO1xcbiAgICAgICAgICAgIHJldHVybiBjb250ZW50O1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5ryr55S75oiW5q2j5paH6I635Y+W5aSx6LSlXFxcIik7XFxuICAgICAgICB9LCBHTS5nZXRTZWxmS2V5KCksIE1ZX1BBUkFNUy5za2V5LCBNWV9SVUxFLnRpdGxlKTtcXG5cXG4gICAgICAgIGxldCBjaGFwdGVyTGlzdCA9IHBsYXlvYmouZXhjbHVkZUtleXMoW1xcXCJzdXJsXFxcIiwgXFxcInN0aXRsZVxcXCJdLCBmYWxzZSkudHJhbnNmb3JtS2V5cyh7XFxuICAgICAgICAgIFxcXCJz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FnZW51bSksXFxuICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCB0ZW1wLmV4dHJhLCB7XFxuICAgICAgICAgICAgaWQ6IFxcXCJwYWdlbnVtXFxcIiArIGksXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9KVxcbiAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICB9KVxcblxcbiAgICAgIGxldCBmYyA9IFxcXCJcXFwiO1xcbiAgICAgIGlmICghKHBsYXlwICYmIHBsYXlwLmxlbmd0aCA+IDEpKSB7XFxuICAgICAgICBmYyA9IFxcXCJncmV5XFxcIjtcXG4gICAgICB9XFxuXFxuICAgICAgbGV0IHBhZ2VvYmogPSBbe1xcbiAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSgn5LiK5LiA6aG1Jywge1xcbiAgICAgICAgICBjOiBmY1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkLCBwY291bnQsIHBhZ2VudW0pID0+IHtcXG4gICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGVmLnBhZ2VudW07XFxuICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKHBhZ2VudW0gPT0gMCkge1xcbiAgICAgICAgICAgIHBhZ2VudW0gPSBwY291bnQgLSAxO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHBhZ2VudW0tLTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgIGxldCBlcnIgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5lclJlZnJlc2g7XFxuICAgICAgICAgIHJldHVybiBlcnIobG9jYXRpb24pO1xcbiAgICAgICAgfSwgaWQsIHBjb3VudCwgU3RyaW5nKHBhZ2VudW0pKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgaWQ6IFxcXCJwbGF5cGFnZUB1cFxcXCJcXG4gICAgICAgIH1cXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogZm9udHN0eWxlKHBsYXlwW3BhZ2VudW1dLCB7XFxuICAgICAgICAgIGM6IGZjXFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8yXFxcIixcXG4gICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaWQsIHBhZ2VudW0pID0+IHtcXG4gICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGxldCBwYWdlbnVtID0gZ2V0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBwYWdlbnVtKTtcXG4gICAgICAgICAgbGV0IGVmID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZ2V0RUluZm8oKTtcXG4gICAgICAgICAgbGV0IHBjb3VudCA9IGVmLm1heFtsb2NhdGlvbl07XFxuICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgbGV0IHBsYXlwID0gZWYucGxheXA7XFxuICAgICAgICAgIGxldCBlciA9ICQucmVxdWlyZShcXFwiVUlNYW5hZ2VcXFwiKS51aV9jb25maWcuZXI7XFxuICAgICAgICAgIGVyLue6v+i3r+agt+W8jyA9IGVyLue6v+i3r+agt+W8j3x8J3Njcm9sbF9idXR0b24nO1xcbiAgICAgICAgICBsZXQgcGFnZWFyciA9IHBsYXlwLm1hcCgoeCwgaSkgPT4gaSA9PSBwYWdlbnVtID8gJ+KAnOKAnOKAneKAnScgKyB4LmZvbnRjb2xvcihlci7nur/ot6/popzoibIpIDogeCk7XFxuICAgICAgICAgIHJldHVybiAkKHBhZ2VhcnIsIDMpLnNlbGVjdCgobG9jYXRpb24sIGVyKSA9PiB7XFxuICAgICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcoTVlfSU5ERVgpKTtcXG4gICAgICAgICAgICBpZiAoZXIu5LqM57qn5Yi35pawKSB7XFxuICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJwbGF5bGlzdF9yZWFkeVxcXCIpO1xcbiAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICB9LCBsb2NhdGlvbiwgZXIpXFxuICAgICAgICB9LCBpZCwgcGFnZW51bSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCIsXFxuICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VAcGFnZWFyclxcXCIsXFxuICAgICAgICB9XFxuICAgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSgn5LiL5LiA6aG1Jywge1xcbiAgICAgICAgICBjOiBmY1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkKSA9PiB7XFxuICAgICAgICAgIGxldCBsb2NhdGlvbiA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICBsZXQgZWYgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5nZXRFSW5mbygpO1xcbiAgICAgICAgICBsZXQgcGNvdW50ID0gZWYubWF4W2xvY2F0aW9uXTtcXG4gICAgICAgICAgbGV0IHBhZ2VudW0gPSBlZi5wYWdlbnVtO1xcbiAgICAgICAgICBpZiAocGNvdW50ID09IDEpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICB9XFxuXFxuICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwYWdlbnVtKys7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICBsZXQgZXJyID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIikuZXJSZWZyZXNoO1xcbiAgICAgICAgICByZXR1cm4gZXJyKGxvY2F0aW9uKTtcXG4gICAgICAgIH0sIGlkKSxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGNsczogXFxcInBsYXlwYWdlXFxcIixcXG4gICAgICAgICAgaWQ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IHVwZGF0ZUl0ZW0oXFxcInBsYXlwYWdlQHBhZ2VhcnJcXFwiLCB7XFxuICAgICAgICAgICAgdGl0bGU6IHBhZ2VvYmpbMV0udGl0bGUsXFxuICAgICAgICAgIH0pXFxuICAgICAgICAgIHVwZGF0ZUl0ZW0oXFxcInBsYXlwYWdlQG5leHRcXFwiLCB7XFxuICAgICAgICAgICAgdGl0bGU6IHBhZ2VvYmpbMl0udGl0bGUsXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9XFxuICAgICAgICBpZiAoZXIu5YiG6aG15a+86IiqKSB7XFxuICAgICAgICAgIGlmICghZXIu5LqM57qn5Yi35pawKSB7XFxuICAgICAgICAgICAgbGV0IHBuID0gZmluZEl0ZW1zQnlDbHMoXFxcInBhZ2VuYXZcXFwiKVxcbiAgICAgICAgICAgIGlmIChwbi5sZW5ndGggPiBwbGF5cC5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgIHBuID0gcG4uc2xpY2UocGxheXAubGVuZ3RoKVxcbiAgICAgICAgICAgICAgcG4ubWFwKHggPT4ge1xcbiAgICAgICAgICAgICAgICBkZWxldGVJdGVtKHguZXh0cmEuaWQpXFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAocG4ubGVuZ3RoIDwgcGxheXAubGVuZ3RoKSB7XFxuICAgICAgICAgICAgICBsZXQgcGlkID0gcG4uYXQoLTEpO1xcbiAgICAgICAgICAgICAgbGV0IGFkZCA9IHRwbGF5LnNsaWNlKHBuLmxlbmd0aCk7XFxuICAgICAgICAgICAgICBhZGRJdGVtQWZ0ZXIocGlkLmV4dHJhLmlkLCBhZGQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB0cGxheS5mb3JFYWNoKCh4LCBpKSA9PiB7XFxuICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJwYWdlbnVtXFxcIiArIGksIHtcXG4gICAgICAgICAgICAgICAgdGl0bGU6IHgudGl0bGU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0geC50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgICAgaWYgKGlpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlID0gJ+KAnOKAnOKAneKAnScgKyB0aXRsZS5mb250Y29sb3IoXFxcInJlZFxcXCIpO1xcbiAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICB1cGRhdGVJdGVtKHguZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgICAgIHRpdGxlOiB0aXRsZSxcXG4gICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgfSwgaSksXFxuICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgdGVtcC5leHRyYSwge1xcbiAgICAgICAgICAgICBpZDogXFxcInBhZ2VudW1cXFwiICsgaSxcXG4gICAgICAgICAgIH0pXFxuICAgICAgICAgfSlcXG4gICAgICAgICByZXR1cm4gb2JqO1xcbiAgICAgICB9KVxcbiAgICAgICBhZGRJdGVtQWZ0ZXIoXFxcInBsYXlwYWdlbGluZVxcXCIsIHBsYXlwKSovXFxuICAgIH0gZWxzZSB7XFxuICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwYWdlbmF2XFxcIik7XFxuICAgICAgZGVsZXRlSXRlbUJ5Q2xzKFxcXCJwbGF5cGFnZVxcXCIpO1xcbiAgICAgIHB1dE15VmFyKFxcXCJub3BhZ2VcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICB9XFxuXFxuICAgIGlmIChnZXRNeVZhcihcXFwicGxheWxpc3RfcmVhZHlcXFwiLCBcXFwiMFxcXCIpID09IFxcXCIxXFxcIikge1xcbiAgICAgIGxldCBvbGRJZHMgPSAoZmluZEl0ZW1zQnlDbHMoJ3BsYXlsaXN0JykgfHw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XFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgaWYgKGVyLue6v+i3r+agt+W8jyAhPSBcXFwic2VsZWN0XFxcIikge1xcbiAgICAgICAgZm9yIChsZXQgaSBpbiBmcm9tKSB7XFxuICAgICAgICAgIGxldCBpY29uaW1nID0gZXIu57q/6Lev5qC35byPLmluY2x1ZGVzKFxcXCJpY29uXFxcIikgPyBmaW5kSWNvbihmcm9tW2ldKSA6IFxcXCJcXFwiO1xcbiAgICAgICAgICBkLnB1c2goe1xcbiAgICAgICAgICAgIHRpdGxlOiAoaSA9PSBjaSA/IGZvbnRzdHlsZShmcm9tW2ldLCB7XFxuICAgICAgICAgICAgICBjOiBlci7nur/ot6/popzoibIsXFxuICAgICAgICAgICAgICB0YWdzOiBcXFwic21hbGxcXFwiXFxuICAgICAgICAgICAgfSwgZXIu57q/6Lev5qC35byPKSA6IGZvbnRzdHlsZShmcm9tW2ldLCB7XFxuICAgICAgICAgICAgICB0YWdzOiBcXFwic21hbGxcXFwiXFxuICAgICAgICAgICAgfSwgZXIu57q/6Lev5qC35byPKSksXFxuICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpID09IGkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgIHB1dE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBTdHJpbmcoaSkpO1xcbiAgICAgICAgICAgICAgbGV0IGVyciA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmVyUmVmcmVzaDtcXG4gICAgICAgICAgICAgIGVycihpKTtcXG4gICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgfSwgaSwgaWQpLFxcbiAgICAgICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgICBjbHM6IFxcXCJsb2NhdGlvbkBcXFwiLFxcbiAgICAgICAgICAgICAgaWQ6IFxcXCJsb2NhdGlvbkBcXFwiICsgaVxcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgaW1nOiBpY29uaW1nLFxcbiAgICAgICAgICAgIGNvbF90eXBlOiBlci7nur/ot6/moLflvI9cXG4gICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgfSBlbHNlIHtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgIHRpdGxlOiBmcm9tW2NpXSxcXG4gICAgICAgICAgZGVzYzogZnJvbS5sZW5ndGggKyBcXFwi5p2h57q/6LevXFxcIixcXG4gICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpZCkgPT4ge1xcbiAgICAgICAgICAgIGxldCB7XFxuICAgICAgICAgICAgICBmb250c3R5bGUsXFxuICAgICAgICAgICAgICBnZXRFSW5mbyxcXG4gICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIik7XFxuICAgICAgICAgICAgbGV0IGVmID0gZ2V0RUluZm8oKTtcXG5cXG4gICAgICAgICAgICBsZXQgZnJvbSA9IGVmLmZyb207XFxuICAgICAgICAgICAgbGV0IG1heCA9IGVmLnBsYXlzO1xcblxcbiAgICAgICAgICAgIGxldCBjaSA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICAgIGxldCBzaG93aSA9IGdldE15VmFyKFxcXCJzaG93aVxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBsZXQgdGZyb20gPSBmcm9tLm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuIGNpID09IGkgPyBmb250c3R5bGUoeCArIFxcXCJbXFxcIiArIG1heFtpXSArIFxcXCJdXFxcIiwge1xcbiAgICAgICAgICAgICAgICBjOiAkLmVyX3VpLue6v+i3r+minOiJsixcXG4gICAgICAgICAgICAgICAgdGFnczogXFxcInNtYWxsXFxcIlxcbiAgICAgICAgICAgICAgfSkgOiBmb250c3R5bGUoeCArIFxcXCJbXFxcIiArIG1heFtpXSArIFxcXCJdXFxcIiwge1xcbiAgICAgICAgICAgICAgICB0YWdzOiBcXFwic21hbGxcXFwiXFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgaWYgKHNob3dpID09IFxcXCJcXFwiKSB7XFxuICAgICAgICAgICAgICBwdXRNeVZhcihcXFwic2hvd2lcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgbGV0IHNob3cgPSAxO1xcbiAgICAgICAgICAgICAgbGV0IG51bSA9IHRmcm9tLmxlbmd0aDtcXG4gICAgICAgICAgICAgIGlmIChudW0gPCA4KSB7XFxuICAgICAgICAgICAgICB9IGVsc2UgaWYgKG51bSA+IDggJiYgbnVtIDw9IDEyKSB7XFxuICAgICAgICAgICAgICAgIHNob3cgPSAyO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgc2hvdyA9IDM7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgIHJldHVybiAkKHRmcm9tLCBzaG93KS5zZWxlY3QoKGNpLCBmLCBpZCkgPT4ge1xcbiAgICAgICAgICAgICAgICBNWV9VUkw9XFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICAgIGVyUmVmcmVzaFxcbiAgICAgICAgICAgICAgICB9PSQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpO1xcbiAgICAgICAgICAgICAgICBcXG4gICAgICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgICAgICBmaW5kSWNvblxcbiAgICAgICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzX2VyXFxcIik7XFxuICAgICAgICAgICAgICAgIFxcbiAgICAgICAgICAgICAgICBsZXQgaSA9IE1ZX0lOREVYO1xcbiAgICAgICAgICAgICAgICBpZiAoaSA9PSBjaSkge1xcbiAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IG5hbWUgPSBmW2ldO1xcbiAgICAgICAgICAgICAgICBwdXRNeVZhcihpZCArIFxcXCJzb3VyY2VpXFxcIiwgU3RyaW5nKGkpKTtcXG4gICAgICAgICAgICAgICAgZXJSZWZyZXNoKGkpO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgaWNvbmltZyA9IGZpbmRJY29uKG5hbWUsICQuZXJfdWkpO1xcblxcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJsb2NhdGlvbkBcXFwiLCB7XFxuICAgICAgICAgICAgICAgICAgdGl0bGU6IG5hbWUsXFxuICAgICAgICAgICAgICAgICAgaW1nOiBpY29uaW1nLFxcbiAgICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJzaG93aVxcXCIpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfSwgY2ksIGZyb20sIGlkKVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJzaG93aVxcXCIpO1xcbiAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH0sIGlkKSxcXG4gICAgICAgICAgaW1nOiBlci7nur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UmVmcmVzaCNcXFwiLFxcbiAgICBjb2xfdHlwZTogXFxcImljb25fc21hbGxfNFxcXCIsXFxuICAgIHBpY191cmw6IFxcXCJoaWtlcjovL2ltYWdlcy9pY29uX2RvbWFpbl9jb25maWdcXFwiLFxcbiAgICBleHRyYToge1xcbiAgICAgICAgcGFnZVRpdGxlOiBcXFwi5paw5aKe6Kej5p6QXFxcIlxcbiAgICB9XFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gICAgdGl0bGU6IFxcXCLliIbkuqtcXFwiLFxcbiAgICB1cmw6ICQoXFxcIi0xXFxcIiwgXFxcIui+k+WFpeS9oOimgeWIhuS6q+ino+aekOeahOW6j+WPt1xcXFxuLTHlhajpg6jvvIwtMuW3suWQr+eUqOeahO+8jC0z5bey56aB55So55qEXFxcIikuaW5wdXQoKGxlbmd0aCkgPT4ge1xcbiAgICAgICAgbGV0IGluZGV4YyA9IGlucHV0LnNwbGl0KC8sfO+8jC8pO1xcbiAgICAgICAgbGV0IGluZGV4cyA9IFtdO1xcbiAgICAgICAgbGV0IG1vID0gcGFyc2VJbnQoaW5kZXhjWzBdKTtcXG4gICAgICAgIGlmICghKGluZGV4Yy5sZW5ndGggIT09IDAgJiYgbW8gPCAwICYmIG1vID4gLTUpKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgaW5kZXhjKSB7XFxuICAgICAgICAgICAgICAgIGxldCBudW0gPSBwYXJzZUludChpdCk7XFxuICAgICAgICAgICAgICAgIGlmIChOdW1iZXIuaXNOYU4obnVtKSB8fCBudW0gPj0gbGVuZ3RoIHx8IG51bSA8IDApIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mlbDlrZfkuI3lkIjms5VcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGluZGV4cy5wdXNoKG51bSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcblxcbiAgICAgICAgcmV0dXJuICQ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W5ndGggKyBcXFwi44CN5p2hLlxcXCIgKyAoaW5wdXQgPT09IFxcXCJISUtFUlxcXCIgPyBcXFwiaGlrZXJcXFwiIDogXFxcInR4dFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGgsIGdldFBhc3MocnVsZXMubGVuZ3RoLCBydWxlYjY0LCBcXFwiYVxcXCIpKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwic2hhcmU6Ly9cXFwiICsgcGF0aDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVsZXM7XFxuICAgICAgICAgICAgaWYgKG1vID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMikge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldFVzZWZ1bEpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKG1vID09PSAtMykge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEZvcmJpZGRlbkpzb24oKTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKS5maWx0ZXIoKHYsIGkpID0+IGluZGV4cy5pbmNsdWRlcyhpKSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMubWFwKCh2KSA9PiB7XFxuICAgICAgICAgICAgICAgIHYuZm9yYmlkZGVuID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcXG4gICAgICAgICAgICB9KTtcXG4gIC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BmLmZvbnRjb2xvcihcXFwiIzEzQjYxQlxcXCIpIDogZiksXFxuICAgICAgICBjb2xfdHlwZTogY29sLFxcbiAgICAgICAgdXJsOiAkKCcjbm9Mb2FkaW5nIycpLmxhenlSdWxlKChmKSA9PiB7XFxuICAgICAgICAgICAgbGV0IGZsYWdpID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImZsYWdpXFxcIiwgW1xcXCLlhajpg6hcXFwiXSk7XFxuICAgICAgICAgICAgaWYgKC8o5YWo6YOofOW3suemgeeUqCkvLnRlc3QoZikpIHtcXG4gICAgICAgICAgICAgICAgZmxhZ2kgPSBbZl1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBmbGFnaSA9IGZsYWdpLmZpbHRlcih4ID0+ICEvKOWFqOmDqHzlt7LnpoHnlKgpLy50ZXN0KHgpKTtcXG4gICAgICAgICAgICAgICAgaWYgKGZsYWdpLmluY2x1ZGVzKGYpKSB7XFxuICAgICAgICAgICAgICAgICAgICBmbGFnaSA9IGZsYWdpLmZpbHRlcih4ID0+IHggIT0gZik7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoZmxhZ2kubGVuZ3RoID09IDApIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBmbGFnaSA9IFtcXFwi5YWo6YOoXFxcIl1cXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGZsYWdpLnB1c2goZilcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiZmxhZ2lcXFwiLCBmbGFnaSk7XFxuICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgZilcXG4gICAgfSlcXG59KVxcbmZvciAobGV0I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ndGgpID0+IHtcXG4gICAgICAgICAgICBpZiAoaW5wdXQgPT09IFxcXCLnvJbovpFcXFwiKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5IyNub1JlZnJlc2gjXFxcIjtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5YiG5LqrXFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgb3BzID0gZ2V0UGFzdGVzKCk7XFxuICAgICAgICAgICAgICAgIG9wcy51bnNoaWZ0KFxcXCLlrozmlbTlj6Pku6RcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQob3BzLCAyLCBcXFwi5YiG5Lqr5pa55byPXFxcIikuc2VsZWN0KChpbmRleCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKClbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS51c2VyID0gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSB1bmRlZmluZWQ7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZWI2NCA9IGJhc2U2NEVuY29kZShKU09OLnN0cmluZ2lmeShydWxlKSk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgZ2V0UGFzcyA9IChuYW1lLCBydWxlLCB0eXBlKSA9PiBcXFwi5rW36ZiU6KeG55WM77yM44CMXFxcIiArIG5hbWUgKyBcXFwi44CNRFJQWeino+aekO+8jOWkjeWItuaVtOadoeWPo+S7pOaJk+W8gOi9r+S7tuWwseS8muiHquWKqOWvvOWFpSRcXFwiICsgcnVsZSArIFxcXCIkXFxcIiArIHR5cGUgKyBcXFwiQGltcG9ydD1qczokLnJlcXVpcmUoJ2ltcG9ydD9ydWxlPScrXFxcIiArIEpTT04uc3RyaW5naWZ5KE1ZX1JVTEUudGl0bGUpICsgXFxcIikoaW5wdXQpXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5a6M5pW05Y+j5LukXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiY29weTovL1xcXCIgKyBnZXRQYXNzKHJ1bGUubmFtZSwgcnVsZWI2NCwgXFxcImFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHUgPSBzaGFyZVBhc3RlKHJ1bGViNjQsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImNvcHk6Ly9cXFwiICsgZ2V0UGFzcyhydWxlLm5hbWUsIHUsIFxcXCJiXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4KTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi56e75YqoXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChpbmRleCArIFxcXCJcXFwiLCBcXFwi6L6T5YWl5L2N572uXFxcIikuaW5wdXQoKGluZGV4LCBsZW5ndGgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IE51bWJlcihpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG5ld0luZGV4KSB8fCBuZXdJbmRleCA+PSBsZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5LiN5ZKM6KeE55qE5L2N572uXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShuZXdJbmRleCwgMCwgcnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgIH0sIGluZGV4LCBsZW5ndGgpO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT09IFxcXCLnva7pobZcXFwiKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuZXdJbmRleCA9IDA7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBydWxlcy5zcGxpY2UoaW5kZXgsIDEpWzBdO1xcbiAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6Zmk77yfXFxcIikuY29uZmlybSgoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlcyA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKHJ1bGVzKTtcXG4gICAgICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7LliKDpmaRcXFwiICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGUgPSBhcnJbaW5kZXhdO1xcbiAgICAgICAgICAgICAgICBydWxlLmZvcmJpZGRlbiA9ICFydWxlLmZvcmJpZGRlbjtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICAvL3JldHVybiBcXFwidG9hc3Q6Ly9cXFwiICsgKHJ1bGUuZm9yYmlkZGVuID8gXFxcIuemgeeUqFxcXCIgOiBcXFwi5ZCv55SoXFxcIikgKyBydWxlLm5hbWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSwgaSwgbGVuZ3RoKSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgICAgaTogaSxcXG4gICAgICAgICAgICBwYWdlVGl0bGU6IGl0Lm5hbWVcXG4gICAgICAgIH1cXG4gICAgfSk7XFxufVxcblxcbmNvdW50VGl0bGUudGl0bGUgPSAnPGZvbnQgY29sb3I9XFxcIiMxM0I2MUJcXFwi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ISFnZXRQYXJhbShcXFwiaXNJbXBvcnRcXFwiLCBcXFwiXFxcIik7XFxubGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG5sZXQgb2JqO1xcbmlmIChpc0ltcG9ydCkge1xcbiAgICB0cnkge1xcbiAgICAgICAgb2JqID0gJC5yZXF1aXJlKFxcXCJoaWtlcjovL2ZpbGVzL19jYWNoZS9qaWV4aVNpbXBsZUltcG9ydC5qc29uXFxcIik7XFxuICAgICAgICBsZXQgdGlwID0gaW5kZXggIT09IHZvaWQoMCkgPyBcXFwi5pu05paw6Kej5p6QXFxcIiA6IFxcXCLlr7zlhaXop6PmnpBcXFwiO1xcbiAgICAgICAgc2V0UGFnZVRpdGxlKHRpcCArIFxcXCI6XFxcIiArIG9iai5uYW1lKTtcXG4gICAgICAgIGQucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLigJjigJhcXFwiICsgdGlwICsgXFxcIuKAmeKAmVxcXCIsXFxuICAgICAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9KTtcXG5cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgb2JqID0ge307XFxuICAgICAgICBiYWNrKCk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl6ZSZ6K+vXFxcIik7XFxuICAgIH1cXG59IGVsc2UgaWYgKGluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgIG9iaiA9IGFycltpbmRleF07XFxuICAgIHNldFBhZ2VUaXRsZShcXFwi57yW6L6R6Kej5p6QOlxcXCIgKyBvYmoubmFtZSk7XFxufSBlbHNlIHtcXG4gICAgb2JqID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LCBcXFwiV0VCXFxcIik7XFxuICAgICAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICAgICAgbGV0IGpzb25QYXRoID0gZ2V0TXlWYXIoXFxcInBzX2pzb25QYXRoXFxcIiwgXFxcIlxcXCIpLnRyaW0oKSB8fCB2b2lkIDA7XFxuICAgICAgICAgICAgbGV0IGpzID0gZ2V0TXlWYXIoXFxcInBzX2pzXFxcIiwgXFxcIlxcXCIpIHx8IHZvaWQgMDtcXG4gICAgICAgICAgICBpZiAoaGVhZGVycykge1xcbiAgICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVycyA9IEpTT04ucGFyc2UoaGVhZGVycyk7XFxuICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGVhZGVyc+agvOW8j+mUmeivrzpcXFwiICsgZS50b1N0cmluZygpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucHJlcGFyZVBhcnNlcyhbe1xcbiAgICAgICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgICAgIGZsYWcsXFxuICAgICAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgICAgIG1ldGhvZCxcXG4gICAgICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAgICAgIGpzXFxuICAgICAgICAgICAgfV0sIGlucHV0LG51bGwsIHRydWUpO1xcbiAgICAgICAgfSk7XFxuICAgIH0pLFxcbiAgICBjb2xfdHlwZTogXFxcInRleHRfM1xcXCIsXFxufSk7XFxuXFxuZC5wdXNoKHtcXG4gIC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JqZWN0XFxcIik7XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVuVHlwZSA9IGdldE15VmFyKFxcXCJwc19ydW5UeXBlXFxcIiwgXFxcIldFQlxcXCIpO1xcbiAgICAgICAgbGV0IG1ldGhvZCA9IGdldE15VmFyKFxcXCJwc19tZXRob2RcXFwiLCBcXFwiR0VUXFxcIik7XFxuICAgICAgICBsZXQganNvblBhdGggPSBnZXRNeVZhcihcXFwicHNfanNvblBhdGhcXFwiLCBcXFwiXFxcIikudHJpbSgpIHx8IHZvaWQgMDtcXG4gICAgICAgIGxldCBqcyA9IGdldE15VmFyKFxcXCJwc19qc1xcXCIsIFxcXCJcXFwiKSB8fCB2b2lkIDA7XFxuICAgICAgICBpZiAocnVuVHlwZSA9PT0gXFxcIkpTT05cXFwiICYmICFqc29uUGF0aCkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU09O5qih5byP5LiL5b+F6aG75aGranNvblBhdGhcXFwiO1xcbiAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09PSBcXFwiSlNcXFwiICYmICFqcykge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly9KU+aooeW8j+S4i+W/hemhu+Whq2pzXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgb2JqMSA9IHtcXG4gICAgICAgICAgICBuYW1lLFxcbiAgICAgICAgICAgIHVybCxcXG4gICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgIGhlYWRlcnMsXFxuICAgICAgICAgICAgcnVuVHlwZSxcXG4gICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAganNvblBhdGgsXFxuICAgICAgICAgICAganNcXG4gICAgICAgIH07XFxuICAgICAgICBpZiAoaW5kZXggPT09IHZvaWQoMCkpIHtcXG4gICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lt7Lnu4/lrZjlnKjor6Xop6PmnpBcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAob2JqMS5ncm91cCkge1xcbiAgICAgICAgICAgICAgICBsZXQgZ3JvdXAgPSBvYmoxLmdyb3VwO1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBhcnIuZmluZEluZGV4KHYgPT4gdi5ncm91cCA9PT0gZ3JvdXApO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDAsIG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaWYgKGlzSW1wb3J0KSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIucHVzaChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGFyci51bnNoaWZ0KG9iajEpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgbmFtZXkgPSBhcnJbaW5kZXhdLm5hbWU7XFxuICAgICAgICAgICAgaWYgKG5hbWUgIT09IG5hbWV5KSB7XFxuICAgICAgICAgICAgICAgIGlmIChhcnIuc29tZ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nVsZSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgcnVsZXMgPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShydWxlKSk7XFxuICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkocnVsZXMpKSB7XFxuICAgICAgICAgICAgcnVsZXMgPSBbcnVsZXNdO1xcbiAgICAgICAgfVxcbiAgICAgICAgLy9ydWxlcy5yZXZlcnNlKCk7XFxuICAgICAgICBNWV9VUkwgPSBtb2R1bGUuaWQ7XFxuICAgICAgICBsZXQgcnVsZVRpdGxlID0gZ2V0UGFyYW0oXFxcInJ1bGVcXFwiKTtcXG4gICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgcnVsZVRpdGxlKS5nZXRKc29uKCk7XFxuICAgICAgICBsZXQgbmV3SSA9IDA7XFxuICAgICAgICBmb3IgKGxldCBydWxlIG9mIHJ1bGVzKSB7XFxuICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYubmFtZSA9PT0gcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICBpZiAoaW5kZXggPiAtMSkge1xcbiAgICAgICAgICAgICAgICBydWxlID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGlmIChydWxlcy5sZW5ndGggPT09IDEpIHtcXG4gICAgICAgICAgICAgICAgICAgIHNhdmVDYWNoZShydWxlKTtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9wYWdlL3J1bGVFZGl0I25vSGlzdG9yeSMjbm9SZWNvcmRIaXN0b3J5Iz9pc0ltcG9ydD10cnVlJmluZGV4PVxcXCIgKyBpbmRleCArIFxcXCImcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5pu05paw6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBuZXdJKys7XFxuICAgICAgICAgICAgICAgIGFyci5wdXNoKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZydWxlPVxcXCIgKyBydWxlVGl0bGU7XFxuICAgICAgICAgICAgICAgICAgICAvL3RvYXN0KFxcXCLlt7Llr7zlhaXop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGxvZyhcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSlcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIGlmIChydWxlcy5sZW5ndGggPiAxKSB7XFxuICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuc2F2ZUpzb24oYXJyKTtcXG4gICAgICAgICAgICB0b2FzdChcXFwi5paw5aKe77yaXFxcIiArIG5ld0kgKyBcXFwiIOimhuebluabtOaWsO+8mlxcXCIgKyAocnVsZXMubGVuZ3RoIC0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iAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgbmFtZSA9IGl0Lm5hbWU7XFxuICAgICAgICAgICAgbGV0IHNwYXRoID0gaXQucGF0aDtcXG4gICAgICAgICAgICBpZiAoIW5hbWUuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKSBjb250aW51ZTtcXG4gICAgICAgICAgICBuYW1lID0gbmFtZS5zbGljZSgwLCBuYW1lLmxhc3RJbmRleE9mKFxcXCIuXFxcIikpO1xcbiAgICAgICAgICAgIGxldCBydWxlID0gZmV0Y2goYGh0dHBzOi8vcmF3LmdpdG1pcnJvci5jb20vJHtyb3BlfS9tYXN0ZXIvJHtzcGF0aH1gKTtcXG4gICAgICAgICAgICBpZiAoISgoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkgJiYgIWZpbGVFeGlzdChwYXRoICsgaXQubmFtZSkpKSB7XFxuICAgICAgICAgICAgICAgIHdyaXRlRmlsZShwYXRoICsgaXQubmFtZSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnB1c2goe1xcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7bmFtZX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBgJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAndHlwZSc6IDMsXFxuICAgICAgICAgICAgICAgICAgICAnYXBpJzogJy4uL2xpYnMvZHJweTIuanMnLFxcbiAgICAgICAgICAgICAgICAgICAgJ3NlYXJjaGFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ3F1aWNrU2VhcmNoJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdmaWx0ZXJhYmxlJzogMSxcXG4gICAgICAgICAgICAgICAgICAgICdleHQnOiBcXFwiLi9cXFwiICsgaXQubmFtZSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIGNvdW50Kys7XFxuIC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AgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaXQuZXh0ID0gXFxcIi4vXFxcIiArIG5hbWU7XFxuICAgICAgICAgICAgICAgIGlmICghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIWZpbGVFeGlzdChwYXRoICsgbmFtZSkpXFxuICAgICAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpLCAxKTtcXG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICB9O1xcbiAgICAgICAgICAgICAgICB3cml0ZUZpbGUocGF0aCArIG5hbWUsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKG5hbWUpO1xcbiAgICAgICAgICAgICAgICBjb3VudCsrO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBsb2coZS50b1N0cmluZygpKTtcXG4gICAgICAgIH1cXG4gICAgICAgIGkrKztcXG4gICAgfVxcbiAgICBkZWxldGVsb3NlKG5hbWVzLCBwYXRoKTtcXG4gICAgd3JpdGVGaWxlKHBhdGggKyBcXFwiaW5kZXguanNvblxcXCIsIEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG4gICAgLy93cml0ZUZpbGUocGF0aC5yZXBsYWNlKC9cXFxcLmpzJC8sJy5qc29uJyksIEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG4gICAgcmV0dXJuIFxcXCJ0b2FzdDovL+aIkOWKn+abtOaWsFxcXCIgKyBjb3VudCArIFxcXCLkuKpcXFwiO1xcbn1cXG4kLmV4cG9ydHMucGFyc2VVcmwgPSBmdW5jdGlvbiAodXJsLCBwYXRoKSB7XFxuICAgIHBhdGggPSBiYXNlNjREZWNvZGUocGF0aCk7XFxuICAgIHBhdGggPSBwYXRoLmVuZHNXaXRoKFxcXCIvXFxcIikgPyBwYXRo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sZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhmZXRjaChjb25maWcucGF0aCkgfHwgXFxcInt9XFxcIikpO1xcbiAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCAhanNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgaWYgKGpzb24uaGFzT3duUHJvcGVydHkoXFxcInNpdGVzXFxcIikgJiYganNvbi5zaXRlcy5oYXNPd25Qcm9wZXJ0eShcXFwiZGF0YVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBqc29uLnNpdGVzID0ganNvbi5zaXRlcy5kYXRhO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxcXCLku47nvZHnu5zojrflj5bnmoTphY3nva7mlofku7bkuLrnqbrvvIzor7fmo4Dmn6XnvZHnu5xcXFwiKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBzb3VyY2VMaXN0ID0gZmlsdGVyT3RoZXIoanNvbi5zaXRlcyk7XFxuICAgICAgICAgICAgaWYgKHNvdXJjZUxpc3RbMF0uaGFzT3duUHJvcGVydHkoXFxcImlkXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgc291cmNlTGlzdCA9IHNvdXJjZUxpc3QubWFwKGl0ZW0gPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0uaGFzT3duUHJvcGVydHkoXFxcImlkXFxcIikgJiYgIWl0ZW0uaGFzT3duUHJvcGVydHkoXFxcImtleVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbVtcXFwia2V5XFxcIl0gPSBpdGVtW1xcXCJpZFxcXCJdO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImluZGV4XFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGZpbGUgPSB2b2lkIDA7XFxuICAgICAgICBsZXQgY3VycmVudFNvdXJjZSwgc2VhcmNoQWxsb3c7XFxuICAgICAgICBpZiAoY29uZmlnLmNLZXkpIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdC5maW5kKHYgPT4gdi5rZXkgPT09IGNvbmZpZy5jS2V5KTtcXG4gICAgICAgICAgICBpZiAoIWN1cnJlbnRTb3VyY2UpIHtcXG4gICAgICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgICAgIC8vY3VycmVudENvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlID0gc291cmNlTGlzdFswXTtcXG4gICAgICAgICAgICAvL2NvbmZpZy5jS2V5ID0gc291cmNlTGlzdFswXS5rZXk7XFxuICAgICAgICB9XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHNlYXJjaEFsbG93ID0gSlNPTi5wYXJzZShmZXRjaChzZWFyY2hBbGxvd1BhdGgpIHx8IFxcXCJbXVxcXCIpO1xcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGRlbGV0ZUZpbGUoc2VhcmNoQWxsb3dQYXRoKTtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IFtdO1xcbiAgICAgICAgfVxcbiAgICAgICAgbG9hZEVycm9yID0gdm9pZCAwO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICBjdXJyZW50U291cmNlLFxcbiAgICAgICAgICAgIHNlYXJjaEFsbG93LFxcbiAgICAg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BhdGgoKSkpO1xcblxcbiAgICAgICAgaWYgKG1hcHBpbmcubGVuZ3RoKSB7XFxuICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgbWFwcGluZykge1xcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBydWxlcy5maW5kSW5kZXgodiA9PiB2Lm5hbWUgPT09IGl0LmtleSk7XFxuICAgICAgICAgICAgICAgIGlmIChpbmRleCA9PT0gLTEpIGNvbnRpbnVlO1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbSA9IHJ1bGVzW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKGluZGV4LCAwLCBPYmplY3QuYXNzaWduKHt9LCBpdGVtLCB7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtpdC50b2tleX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ25hbWUnOiBgJHtpdC50b2tleX1gLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IGl0ZW0uZXh0ICsgXFxcIj9cXFwiICsgaXQucGFyYW1zLFxcbiAgICAgICAgICAgICAgICAgICAgZGVsOiB2b2lkIDBcXG4gICAgICAgICAgICAgICAgfSkpO1xcbiAgICAgICAgICAgICAgICBpdGVtLmRlbCA9IHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJ1bGVzID0gcnVsZXMuZmlsdGVyKHYgPT4gIXYuZGVsKTtcXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcblxcbiAgICB9XFxuICAgIHJldHVybiBydWxlcztcXG59XFxuXFxuZnVuY3Rpb24gZ2V0TG9hY2xNYXBwaW5nKGRpckZpbGUpIHtcXG4gICAgLy9rZXlAcGFyYW1zQHR5cGVcXG4gICAgbGV0IG1hcHBpbmdQYXRoID0gXFxcImZpbGU6Ly9cXFwiICsgam9pblVybChkaXJGaWxlLCBcXFwiLi9cXFwiKSArIFxcXCIvLm1hcHBpbmcudHh0XFx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YWNlKFxcXCJmaWxlOi8vXFxcIiwgXFxcIlxcXCIpKTtcXG5cXG4gICAgICAgICAgICAgICAgaWYgKCEoZmlsZS5leGlzdHMoKSAmJiBmaWxlLmlzRGlyZWN0b3J5KCkpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGZpbGUubGlzdEZpbGVzKCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goU3RyaW5nKGl0LmdldE5hbWUoKSkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBuYW1lcztcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIGRpcm5hbWUocGEpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHBhdGggPSBqb2luVXJsKGpzUGF0aCwgcGEpO1xcbiAgICAgICAgICAgICAgICBsZXQgbmFtZXMgPSBbXTtcXG4gICAgICAgICAgICAgICAgbGV0IGZpbGUgPSBuZXcgamF2YS5pby5GaWxlKHBhdGgpO1xcblxcbiAgICAgICAgICAgICAgICBpZiAoIShmaWxlLmV4aXN0cygpICYmIGZpbGUuaXNEaXJlY3RvcnkoKSkpIHJldHVybiBuYW1lcztcXG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaXQgb2YgZGlyRmlsZS5saXN0RmlsZXMoKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0LmlzRGlyZWN0b3J5KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgbmFtZXMucHVzaChTdHJpbmcoaXQuZ2V0TmFtZSgpKSk7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhdGhzO1xcbiAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgc3RhdCgpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfS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SBcXFwibm9cXFwiO1xcbiAgICAgICAgICBsZXQgcGF0aCA9IG9iai51cmwucmVwbGFjZShcXFwiZmlsZTovL1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgbGV0IGRpciA9IG5ldyBqYXZhLmlvLkZpbGUocGF0aCk7XFxuICAgICAgICAgIGlmIChkaXIuaXNEaXJlY3RvcnkoKSkge1xcbiAgICAgICAgICAgIGxldCBmbGlzdCA9IGRpci5saXN0RmlsZXMoKTtcXG4gICAgICAgICAgICBmb3IgKHZhciBmIG9mIGZsaXN0KSB7XFxuICAgICAgICAgICAgICAvLyDmo4Dmn6Xmlofku7blkI3mmK/lkKbku6UuanPnu5PlsL5cXG4gICAgICAgICAgICAgIGlmIChmLmlzRmlsZSgpICYmIGYuZ2V0TmFtZSgpLnRvTG93ZXJDYXNlKCkuZW5kc1dpdGgoXFxcIi5qc1xcXCIpKSB7XFxuICAgICAgICAgICAgICAgIGpzRmlsZXMucHVzaChmKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGRpci5pc0ZpbGUoKSAmJiBmaWxlRXhpc3Qob2JqLnVybCkpIHtcXG4gICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAganNvbiA9IEpTT04ucGFyc2UocmVhZEZpbGUob2JqLnVybCkpO1xcbiAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgICAgY291bnQgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKS5sZW5ndGg7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBjYXRjaCAoZSkgeyB9XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGpzRmlsZXMubGVuZ3RoID49IDUpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGpzRmlsZXMubGVuZ3RoO1xcbiAgICAgICAgICAgIGNvZGUgPSBcXFwib2tcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgdGltZTogKERhdGUubm93KCkgLSBzKSxcXG4gICAgICAgICAgICB1cmw6IG9iai51cmwsXFxuICAgICAgICAgICAgY291bnQ6IGNvdW50LFxcbiAgICAgICAgICAgIGNvZGU6IGNvZGUsXFxuICAgICAgICAgICAgaW5kZXg6IG9iai5pXFxuICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAgICAgIHZhciBqID0gSlNPTi5wYXJzZShmZXRjaChvYmoudXJsLCB7XFxuICAgICAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcbiAgICAgICAgICB0aW1lb3V0OiA1MDAwLFxcbiAgICAgICAgfSkpO1xcbiAgICAgICAgbGV0IGUgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgbGV0IGMgPSBlIC0gcztcXG4gICAgICAgIGlmIChvYmoudXJsLmluY2x1ZGVzKFxcXCJnaXRodWIuY29tXFxcIikgJiYgai5zdGF0dXNDb2RlID09IDIwMCkge1xcbiAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIHZhciBodG1sID0gai5ib2R5O1xcbiAgICAgICAgICAgIHZhciBqc29uID0gSlNPTi5wYXJzZShwZGZoKGh0bWwsIFxcXCIjcmVwby1jb250ZW50LXBqYXgtY29udGFpbmVyJiZzY3JpcHQmJkh0bWxcXFwiKSk7XFxuICAgICAgICAgICAgbGV0IGxpc3QgPSBqc29uLnBheWxvYWQudHJlZS5pdGVtcztcXG4gICAgICAgICAgICBjb3VudCA9IGxpc3QuZmlsdGVyKHggPT4geC5uYW1lLmVuZHNXaXRoKFxcXCIuanNcXFwiKSkubGVuZ3RoO1xcbiAgICAgICAgICB9IGNhdGNoIHsgfVxcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHRvQ29ycmVjdEpTT05TdHJpbmcoai5ib2R5KSB8fCBcXFwie31cXFwiKTtcXG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoanNvbi5zaXRlcykgfHwganNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkgeyB9XFxuXFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICB0aW1lOiBjLFxcbiAgICAgICAgICB1cmw6IGoudXJsLFxcbiAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgIGNvZGU6IGouc3RhdHVzQ29kZSxcXG4gICAgICAgICAgaW5kZXg6IG9iai5pLFxcbiAgICAgICAgfVxcbiAgICAgIH07XFxuICAgICAgbGV0IHRhc2tzID0gbGlzdC5tYXAoKHgsIGkpID0+IHtcXG4gICAgICAgIGkgPSBpICsgMTtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgIGZ1bmM6IHRhc2ssXFxuICAgICAgICAgIHBhcmFtOiB7XFxuICAgICAgICAgICAgdXJsOiB4LFxcbiAgICAgICAgICAgIGk6IGkgLSAxLFxcbiAgICAgICAgICB9LFxcbiAgICAgICAgICBpZDogJ3Rhc2tpZCcgKyBpXFxuICAgICAgICB9XFxuICAgICAgfSk7XFxuICAgICAgdmFyIGNvdW50ID0gc3VjY2VzcyA9IHRhc2tzLmxlbmd0aDtcXG4gICAgICBiZSh0YXNrcywge1xcbiAgICAgICAgZnVuYzogZnVuY3Rpb24gKG9iaiwgaWQsIGVycm9yLCB0YXNrUmVzdWx0KSB7XFxuICAgICAgICAgIG9iai5yZXN1bHRzLnB1c2godGFza1Jlc3VsdClcXG4gICAgICAgICAgY291bnQgPSBjb3VudCAtIDE7XFxuICAgICAgICAgIGlmIChjb3VudC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BsYXlvdXQucHVzaCh7XFxuICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgXFxcIjxzbWFsbD5cXFwiICsgY3VycmVudCArIFxcXCLlkI3np7A6XFxcIiArIGl0ZW0ubmFtZSArIFxcXCJcXFxcbui3r+W+hDpcXFwiICsgaXRlbS5wYXRoICsgXFxcIjwvc21hbGw+XFxcIixcXG4gICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoaXRlbSA9PiB7XFxuICAgICAgICBjbGVhckl0ZW0oXFxcIm5vX2xvYWRpbmdcXFwiKTtcXG4gICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICBsZXQge1xcbiAgICAgICAgICBwYXRoLFxcbiAgICAgICAgICBuYW1lXFxuICAgICAgICB9ID0gaXRlbTtcXG4gICAgICAgIGlmIChwYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBcXFwiKSkge1xcbiAgICAgICAgICBzaG93TG9hZGluZyhcXFwi5q2j5Zyo5Yqg6L296YWN572uLi4uXFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVudGltZUNvbmZpZy5zZXRDdXJyZW50Q29uZmlnKHtcXG4gICAgICAgICAgcGF0aCxcXG4gICAgICAgICAgbmFtZSxcXG4gICAgICAgIH0pKSB7XFxuXFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuY2xlYXIoKTtcXG4gICAgICAgICAgYmFjayhmYWxzZSk7XFxuICAgICAgICAgICQucmVxdWlyZShcXFwiQ2hhbmdlU291cmNlUG9wXFxcIikuc2hvdygxMDApO1xcbiAgICAgICAgICBoaWRlTG9hZGluZygpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW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ZXMudW5zaGlmdChcXFwi5YWo6YOoXFxcIik7XFxuICAgICAgICBoaWtlclBvcC5zZWxlY3RDZW50ZXIoe1xcbiAgICAgICAgICBvcHRpb25zOiB0YWdDbGFzc2VzLFxcbiAgICAgICAgICBjb2x1bW5zOiAzLFxcbiAgICAgICAgICB0aXRsZTogXFxcIlRBR1tcXFwiICsgdGFnQ2xhc3Nlcy5sZW5ndGggKyBcXFwiXVxcXCIsXFxuICAgICAgICAgIGNsaWNrKGEpIHtcXG4gICAgICAgICAgICBsZXQgdGFnID0gYTtcXG4gICAgICAgICAgICBpZiAoYSA9PSBcXFwi5YWo6YOoXFxcIikge1xcbiAgICAgICAgICAgICAgdGFnID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHRhZyA9IFxcXCJbXFxcIiArIGEgKyBcXFwiXVxcXCJcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaW5wdXRCb3guc2V0RGVmYXVsdFZhbHVlKHRhZyk7XFxuICAgICAgICAgICAgcHV0TXlWYXIoXFxcInNlYXJjaFNvdXJjZVRhZ1xcXCIsIHRhZyk7XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICAgIH0sXFxuICAgICAgdGl0bGVWaXNpYmxlOiB0cnVlXFxuICAgIH0pKSxcXG4gICAgbG9uZ0NsaWNrKHMsIGkpIHtcXG4gICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxuICAgICAgICB0aXRsZTogXFxcIuWIhuS6q+inhumikea6kFxcXCIsXFxuICAgICAgICBvcHRpb25zOiBbXFxcIkpT5paH5Lu25YiG5LqrXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSxcXG4gICAgICAgIGNvbDogMixcXG4gICAgICAgIGpzOiAkLnRvU3RyaW5nKG5hbWUgPT4ge1xcbiAgICAgICAgICBjb25zdCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29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iAgICAgICAgICAgICAgc2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJuYXR1cmFsXFxcIiwgbmF0dXJhbCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLkvb/nlKjmjpLluo9cXFwiKSkge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIGxldCB1c2luZ3N0ID0gZ2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAodXNpbmdzdCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHVzaW5nU29ydC5nZXQobGlzdCkuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgc25hbWUuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4KTtcXG4gICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICBzZXRJdGVtKFxcXCJ1c2luZ3N0XFxcIiwgdXNpbmdzdCA/IFxcXCJcXFwiIDogXFxcIjFcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChzID09IFxcXCLliLfmlrDphY3nva5cXFwiKSB7XFxuICAgICAgICAgICAgaGlrZXJQb3AucnVuT25OZXdUaHJlYWQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgZnVuY3Rpb24gYXJyYXlEaWZmZXJlbmNlKGFycjEsIGFycjIpIHtcXG4gICAgICAgICAgICAgICAgY29uc3QgbWFwID0gbmV3IE1hcChhcnIyLm1hcChpdGVtID0+IFtpdGVtLmtleSwgaXRlbV0pKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIGFycjEuZmlsdGVyKGl0ZW0gPT4gIW1hcC5oYXMoaXRlbS5rZXkpKTtcXG4gICAgICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIiwgXFxcInJ1bnRpbWVDb25maWdcXFwiKTtcXG4gICAgICAgICAgICAgIGxldCBsaXN0ID0gcnVudGltZUNvbmZpZy5nZXRBbGxTb3VyY2UoKTtcXG4gICAgICAgICAgICAgIGlmICghcnVudGltZUNvbmZpZy5pbml0RGVmYXVsdCgpKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLliLfmlrDlpLHotKVcXFwiKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xcbiAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgIGxldCBuc291cmNlcyA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuXFxuICAgICAgICAgICAgICBsZXQgYWxpc3QgPSBhcnJheURpZmZlcmVuY2UobnNvdXJjZXMsIGxpc3QpO1xcbiAgICAgICAgICAgICAgbGV0IGRsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKGxpc3QsIG5zb3VyY2VzKTtcXG5cXG4gICAgICAgICAgICAgIGlmIChhbGlzdC5sZW5ndGggPiAwIHx8IGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgbGV0IG1zZyA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgICAgICAgIGFsaXN0LmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5wdXNoKHgubmFtZSk7XFxuICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICBsb2coXFxcIuaWsOWinjpcXFwiICsgYWxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXCLmlrDlop5cXFwiICsgYWxpc3QubGVuZ3RoICsgXFxcIuS4qua6kFxcXCI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgaWYgKGRsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICBkbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3Quc3BsaWNlKG1hbmFnZS5saXN0LmluZGV4T2YoeC5uYW1lKSwgMSk7XFxuICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgICBsb2coXFxcIuenu+mZpDpcXFwiICsgZGxpc3QubWFwKGsgPT4gay5uYW1lKS5qb2luKFxcXCIsXFxcIikpXFxuICAgICAgICAgICAgICAgICAgbXNnICs9IFxcXCIg56e76ZmkXFxcIiArIGRsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLnJ1bk9uVUlUaHJlYWQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2Uuc2V0VGl0bGUoXFxcIumAieaLqeinhumikea6kCDlvZPliY3lhbE6XFxcIiArIG1hbmFnZS5saXN0Lmxlbmd0aCArIFxcXCLkuKrop4bpopHmupBcXFwiKTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIHRvYXN0KG1zZyArIFxcXCIg5pu05aSa6K+m5oOF55yLbG9nXFxcIik7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5bey5Yi35pawXFxcIik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSk7XFxuXFxuICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi6Z2S5bCR5bm05qih5byPXFxcIikpIHtcXG4gICAgICAgICAgICBmdW5jdGlvbiBzZWxlY3QoKSB7XFxuICAgICAgICAgICAgICBzaG93U2VsZWN0T3B0aW9ucyh7XFxuICAgICAgICAgICAgICAgIFxcXCJ0aXRsZVxcXCI6IFxcXCLpgInmi6lcXFwiLFxcbiAgICAgICAgICAgICAgICBcXFwib3B0aW9uc1xcXCI6IFtcXFwi5Li05pe25YWz6ZetXFxcIiwgXFxcIuWFs+mXrVxcXCIsIFxcXCLorr7nva7lr4bnoIFcXFwiXSxcXG4gICAgICAgICAgICAgICAgY29sOiAxLFxcbiAgICAgICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuXFxuICAgICAgICAgICAgICAgICAgaWYgKGlucHV0ID09IFxcXCLkuLTml7blhbPpl61cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBwdXRNeVZhcihcXFwidGVtcExlYWNoXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5wdXQgPT0gXFxcIuWFs+mXrVxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibGVhY2hcXFwiKTtcXG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIsIFxcXCLorr7nva7lr4bnoIFcXFxcbuaMh+e6ueS4jeiDveeUqOaXtuacieaViFxcXCIpLmlucHV0KCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgICAgaWYgKGlucHV0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hQYXNzXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/orr7nva7miJDlip9cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFySXRlbShcXFwibGVhY2hQYXNzXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S9v+eUqOm7mOiupOWvhueggVxcXCI7XFxuICAgICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgbGVhY2hQYXNzID0gZ2V0SXRlbShcXFwibGVhY2hQYXNzXFxcIiwgXFxcIlxcXCIpO1xcbiAgICAgICAgICAgIGlmIChzLmluY2x1ZGVzKFxcXCLlhbPpl61cXFwiKSkge1xcblxcbiAgICAgICAgICAgICAgaWYgKGhpa2VyUG9wLmNhbkJpb21ldHJpYygpICE9PSAwICYmICFsZWFjaFBhc3MpIHtcXG4gICAgICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIuiuvue9ruWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgaGludDogXFxcIuWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAoIXRleHQpIHtcXG4gICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WvhueggeS4jeiDveS4uuepulxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICBzZXRJdGVtKFxcXCJsZWFjaFBhc3NcXFwiLCB0ZXh0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ0ZW1wTGVhY2hcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgdG9hc3QoXFxcIuaJk+W8gOi/h+a7pFxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hcXFwiLCBcXFwiMVxcXCIpO1xcbiAgICAgICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ0ZW1wTGVhY2hcXFwiKTtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuaJk+W8gOi/h+a7pFxcXCIpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICBpZiAoaGlrZXJQb3AuY2FuQmlvbWV0cmljKCkgIT09IDApIHtcXG4gICAgICAgICAgICAgICAgaGlrZXJQb3AuaW5wdXRDb25maXJtKHtcXG4gICAgICAgICAgICAgICAgICBjb250ZW50OiBcXFwi6L6T5YWl5a+G56CB6L+b6KGM5YWz6ZetXFxcIixcXG4gICAgICAgICAgICAgICAgICB0aXRsZTogXFxcIui+k+WFpeWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgaGludDogXFxcIuWvhueggVxcXCIsXFxuICAgICAgICAgICAgICAgICAgY29uZmlybSh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICBpZiAodGV4dCA9PT0gbGVhY2hQYXNzIHx8ICghbGVhY2hQYXNzICYmIHRleHQgPT09IFN0cmluZyhwcykpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdCgpO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WvhueggemUmeivr1xcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5jaGVja0J5QmlvbWV0cmljKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICBoaWtlclBvcC5ydW5Pbk5ld1RocmVhZCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKTtcXG4gICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHBvcC5kaXNtaXNzKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBzaG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AgICAgICAgICAgICAgdGl0bGU6IFxcXCLnrZvpgInmupBcXFwiLFxcbiAgICAgICAgICAgICAgaGludDogXFxcIua6kOWFs+mUruWtlyDlpJrkuKrnlKh86ZqU5byAXFxcIixcXG4gICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZTogc2VhcmNoS2V5LFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaChzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkgPyBcXFwi4oCc4oCc4oCd4oCdXFxcIiArICh2Lm5hbWUgKyBcXFwiXFxcIikuZm9udGNvbG9yKFxcXCIjMDA5OTY2XFxcIikgOiB2Lm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZSA9IGNhblNlYXJjaFNvdXJjZS5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcblxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2Uuc29ydCgoYSwgYikgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcbiAgICAgICAgICAgICAgICBudW1lcmljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBtYW5hZ2Uuc2V0VGl0bGUocG9wVGl0bGUoc2VhcmNoQWxsb3cubGVuZ3RoKSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDUpIHtcXG4gICAgICAgICAgICBsZXQgdGVtbGlzdCA9IHNlYXJjaEFsbG93LnNsaWNlKCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAodGVtbGlzdC5pbmNsdWRlcyh2LmtleSkpIHJldHVybjtcXG4gICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIG1hbmFnZS5zZXRUaXRsZShwb3BUaXRsZShzZWFyY2hBbGxvdy5sZW5ndGgpKTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgIC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GNvZGUpKSB7XFxuICAgIGxldCByZXN1bHQgPSBKU09OLnBhcnNlKHJlcXVlc3QocnVsZS5ob21lVXJsLCB7XFxuICAgICAgdGltZW91dDogcnVsZS50aW1lb3V0IHx8IDUwMDAsXFxuICAgICAgaGVhZGVyczogcnVsZS5oZWFkZXJzIHx8IHt9LFxcbiAgICAgIHdpdGhIZWFkZXJzOiB0cnVlLFxcbiAgICB9KSk7XFxuICAgIGlmICgocmVzdWx0LmJvZHkgPT0gdW5kZWZpbmVkIHx8IHJlc3VsdC5ib2R5ID09IFxcXCJcXFwiKSB8fCAocmVzdWx0LmVycm9yICE9IHVuZGVmaW5lZCkgfHwgL14oLTF8NDA0fDUwMnw1MDMpJC8udGVzdChyZXN1bHQuc3RhdHVzQ29kZSkpIHtcXG4gICAgICBjbGVhck15VmFyKFxcXCJsaW5rc1xcXCIpO1xcbiAgICAgIC8qbGF5b3V0LnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLigJzigJxcXFwiICsgXFxcIue9keermeiuv+mXruW8guW4uFxcXCIgKyBcXFwi4oCd4oCdXFxcIixcXG4gICAgICAgIGRlc2M6IFxcXCIwXFxcIixcXG4gICAgICAgIHVybDogcnVsZS5ob21lVXJsLFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJ0ZXh0X2NlbnRlcl8xXFxcIixcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4hemZpHVp6K6+572uXFxcIixcXG4gICAgICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgICBsZXQge1xcbiAgICAgICAgICAgICAgICB1aV9jbGVhcixcXG4gICAgICAgICAgICAgIH0gPSAkLnJlcXVpcmUoXFxcIlVJTWFuYWdlXFxcIik7XFxuICAgICAgICAgICAgICB1aV9jbGVhcihcXFwieWlcXFwiKTtcXG4gICAgICAgICAgICAgIHJlZnJlc2hQYWdl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mFnZTAuZ2V0SXRlbShcXFwiZmlsdGVyX2RlZlxcXCIsIHt9KTtcXG4gICAgICBjbGFzc2lmeS5mb3JFYWNoKCh4LCBpbmRleCkgPT4ge1xcbiAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICBjb2xfdHlwZTogJ2JsYW5rX2Jsb2NrJ1xcbiAgICAgICAgfSlcXG4gICAgICAgIHgudmFsdWUuZm9yRWFjaCgoaXQsIGkpID0+IHtcXG4gICAgICAgICAgbGV0IHQgPSBpdC5uO1xcbiAgICAgICAgICBpZiAoY2F0ZV90ZW1wW2luZGV4XSA9PSBpKSB7XFxuICAgICAgICAgICAgdCA9IFxcXCI8Yj48Zm9udCBjb2xvcj1cXFwiICsgY29sb3IgKyBcXFwiPlxcXCIgKyB0ICsgXFxcIjwvZm9udD48L2I+XFxcIjtcXG4gICAgICAgICAgICBmbFt4LmtleV0gPSBpdC52O1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChjYXRlX3RlbXBbaW5kZXhdID09IFxcXCItMVxcXCIpIHtcXG4gICAgICAgICAgICBmbFt4LmtleV0gPSBcXFwidW5kZWZpbmVkXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZm9sZCA9PSAxKSB7XFxuICAgICAgICAgICAgbGF5b3V0LnB1c2goe1xcbiAgICAgICAgICAgICAgdGl0bGU6ICfigJzigJzigJ3igJ0nICsgdCxcXG4gICAgICAgICAgICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgobykgPT4ge1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IG8uaTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImlzX2RlZlxcXCIsIFxcXCIxXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBjYXRlX29iaiA9IHN0b3JhZ2UwLmdldE15VmFyKFxcXCJjYXRlX29ialxcXCIsIHt9KTtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfdGVtcCA9IG8uY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICBpZiAoY2F0ZV90ZW1wLmNvbnN0cnVjdG9yICE9IEFycmF5KSB7XFxuICAgICAgICAgICAgICAgICAgY2F0ZV90ZW1wID0gW107XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gby5pbmRleDtcXG4gICAgICAgICAgICAgICAgbGV0IGMgPSBjYXRlX3RlbXBbaW5kZXhdIHx8IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGMpXFxuICAgICAgICAgICAgICAgIGlmIChjID09IGkpIHtcXG4gICAgICAgICAgICAgICAgICBvLmNhdGVfdGVtcFtpbmRleF0gPSBcXFwiLTFcXFwiO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IGkgKyBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjYXRlX29ialtvLmNhdGVdID0gY2F0ZV90ZW1wO1xcbiAgICAgICAgICAgICAgICAvL2xvZyhjYXRlX3RlbXApXFxuICAgICAgICAgICAgICAgIC8vc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfdGVtcFxcXCIsIGNhdGVfdGVtcCk7XFxuICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJjYXRlX29ialxcXCIsIGNhdGVfb2JqKTtcXG4gICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgICAgICAgIH0sIHtcXG4gICAgICAgICAgICAgICAgaW5kZXg6IGluZGV4LFxcbiAgICAgICAgICAgICAgICBjYXRlX3RlbXA6IGNhdGVfdGVtcCxcXG4gICAgICAg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jZSwgaWQpID0+IHtcXG4gICAgICAgICAgbGV0IHVybDtcXG4gICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIpO1xcbiAgICAgICAgICAgIGxldCBkcnB5ID0gRHJweU1hbmFnZS5nZXRCeVNvdXJjZShzb3VyY2UpO1xcbiAgICAgICAgICAgIHVybCA9IEpTT04ucGFyc2UoZHJweS5kZXRhaWwoaWQpKS5saXN0WzBdLnZvZF9wbGF5X3VybC5zcGxpdChcXFwiJFxcXCIpWzFdO1xcbiAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgdXJsID0gaWQuc3BsaXQoXFxcIkBAXFxcIilbMF07XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuICQucmVxdWlyZShcXFwidmlkZW9VcmxcXFwiKS5wYXJzZSh1cmwsIGlkLCBzb3VyY2UpO1xcbiAgICAgICAgfSwgc291cmNlLCBpZCk7XFxuICAgICAgICBjaWQgPSBpZDtcXG4gICAgICB9XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBuYW1lLFxcbiAgICAgICAgZGVzYzogaXQudm9kX3JlbWFya3MsXFxuICAgICAgICB1cmw6IHVybCxcXG4gICAgICAgIGltZzogaXQudm9kX3BpYyxcXG4gICAgICAgIGNvbF90eXBlOiBob21lTGlzdENvbCxcXG4gICAgICAgIGV4dHJhOiB7XFxuICAgICAgICAgIGltZzogaXQudm9kX3BpYyxcXG4gICAgICAgICAgdm9kSWQ6IGlkLFxcbiAgICAgICAgICBzbmFtZTogc291cmNlLm5hbWUsXFxuICAgICAgICAgIHNrZXk6IHNvdXJjZS5rZXksXFxuICAgICAgICAgIGlkOiBjaWQsXFxuICAgICAgICAgIGxvbmdDbGljazogW3tcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuiBmuWQiOaQnOe0olxcXCIsXFxuICA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IH0pXFxuICAgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IFxcXCLliLfmlrDmupBcXFwiLFxcbiAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBjbGVhck15VmFyKFxcXCJsaW5rc1xcXCIpO1xcbiAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpLmluaXQocnVudGltZUNvbmZpZy5nZXRBYnNvbHV0ZVBhdGgoc291cmNlLmV4dCkpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSlcXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogXFxcIumHjei9vea6kFxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgIGNsZWFyTXlWYXIoXFxcImxpbmtzXFxcIik7XFxuICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHTS5kZWZpbmVNb2R1bGUoXFxcIkRycHlNYW5hZ2VcXFwiKTtcXG4gICAgICAgICAgRHJweU1hbmFnZS5kZWwoc291cmNlLmtleSk7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICB9KVxcbiAgICAg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uICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcImdpdGh1YnJhd1xcXCIsIHRleHQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgaWYgKCFydW50aW1lQ29uZmlnLmluaXREZWZhdWx0KCkpIHtcXG4gICAgICAgICAgICAgIHRvYXN0KFxcXCLliLfmlrDlpLHotKVcXFwiKTtcXG4gICAgICAgICAgICB9O1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLlt7Lkv53lrZhcXFwiKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICB9IGVsc2UgaWYgKGlucHV0LmluY2x1ZGVzKFxcXCLkuLvpophcXFwiKSkge1xcbiAgICAgICAgbGV0IGN0aGVtZSA9IGdldEl0ZW0oXFxcInRoZW1lXFxcIiwgXFxcIum7mOiupFxcXCIpO1xcbiAgICAgICAgbGV0IHMgPSAkLnRoZW1lcztcXG4gICAgICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXMocyk7XFxuICAgICAgICBpZiAoa2V5cy5sZW5ndGggPCAyKSB7XFxuICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/msqHmnInlhbbku5bkuLvpophcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGtleXMubGVuZ3RoID09IDIpIHtcXG4gICAgICAgICAgbGV0IG5hbWUgPSBrZXlzWzBdO1xcbiAgICAgICAgICBpZiAoY3RoZW1lID09IGtleXNbMF0pIHtcXG4gICAgICAgICAgICBuYW1lID0ga2V5c1sxXTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBzZXRJdGVtKFxcXCJ0aGVtZVxcXCIsIG5hbWUpO1xcbiAgICAgICAgICBsZXQgdGhlb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Tor6XooqvmjpLpmaRcXG4gICAgICBpZiAoIShleGMuaGFzT3duUHJvcGVydHkoa2V5KSAmJiBleGNba2V5XSA9PT0gdHJ1ZSkpIHtcXG4gICAgICAgIC8vIOWmguaenOmhtuWxgumUruWvueW6lOeahOWAvOaYr+Wvueixoe+8jOW5tuS4lOacieWtkOaOkumZpOinhOWIme+8jOWImemAkuW9kuiwg+eUqCBkZWVwT21pdFxcbiAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2Vba2V5XSA9PT0gJ29iamVjdCcgJiYgc291cmNlW2tleV0gIT09IG51bGwgJiYgZXhjW2tleV0pIHtcXG4gICAgICAgICAgcmVzdWx0W2tleV0gPSBkZWVwT21pdChzb3VyY2Vba2V5XSwgZXhjW2tleV0pO1xcbiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2Ygc291cmNlW2tleV0gIT09ICdvYmplY3QnIHx8IHNvdXJjZVtrZXldID09PSBudWxsIHx8ICFleGNba2V5XSkge1xcbiAgICAgICAgICAvLyDlpoLmnpzpobblsYLplK7lr7nlupTnmoTlgLzkuI3mmK/lr7nosaHvvIzmiJbogIXmsqHmnInlrZDmjpLpmaTop4TliJnvvIznm7TmjqXlpI3liLblgLxcXG4gICAgICAgICAgcmVzdWx0W2tleV0gPSBzb3VyY2Vba2V5XTtcXG4gICAgICAgIH1cXG4gICAgICB9XFxuICAgIH1cXG4gIH1cXG4gIHJldHVybiByZXN1bHQ7XFxufVxcblxcbi8qKlxcbiAqIOWIpOaWreS4pOS4quWvueixoeaYr+WQpuebuOetie+8jOW/veeVpeaMh+WumueahOmUruOAglxcbiAqIEBwYXJhbSB7Kn0geCAtIOesrOS4gOS4quWvueixoeOAglxcbiAqIEBwYXJhbSB7Kn0geSAtIOesrOS6jOS4quWvueixoeOAglxcbiAqIEBwYXJhbSB7QXJyYXl9IGV4Y2x1ZGVLZXlzIC0g6ZyA6KaB5b+955Wl5q+U6L6D55qE6ZSu5pWw57uE44CCXFxuICogQHJldHVybnMge2Jv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h0aGlzLnBhdGggKyB0aGlzLm5hbWUsIGNvbnRlbnQpO1xcbiAgfSxcXG4gIGluaXQoKSB7XFxuICAgIGxldCBqc29uID0ge307XFxuICAgIGlmICghZmlsZUV4aXN0KHRoaXMucGF0aCArIHRoaXMubmFtZSkpIHtcXG4gICAgICB0aGlzLnNhdmUoXFxcInt9XFxcIik7XFxuICAgIH1cXG4gICAgdHJ5IHtcXG4gICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZSh0aGlzLnBhdGggKyB0aGlzLm5hbWUpKTtcXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgIGpzb24gPSB7fTtcXG4gICAgICB0aGlzLnNhdmUoXFxcInt9XFxcIik7XFxuICAgIH1cXG4gICAgcmV0dXJuIGpzb247XFxuICB9LFxcbiAgaGFzKHRzKSB7XFxuICAgIGxldCBqc29uID0gdGhpcy5pbml0KCk7XFxuICAgIGxldCBzanNvbiA9IGRlZXBNZXJnZSh7fSwganNvbik7XFxuICAgIGxldCBrZXlzID0gT2JqZWN0LmtleXModHMpO1xcbiAgICBrZXlzLmZvckVhY2goayA9PiB7XFxuICAgICAgaWYgKCFqc29uLmhhc093blByb3BlcnR5KGspKSB7XFxuICAgICAgICBqc29uW2tdID0gdHNba107XFxuICAgICAgfVxcbiAgICB9KVxcbiAgICBpZiAoT2JqZWN0LmtleXMoc2pzb24pLmxlbmd0aCA9PSAwKSB7XFxuICAgICAganNvbiA9IGRlZXBNZXJnZShqc29uLCBzanNvbik7XFxuICAgICAgdGhpcy5zYXZlKEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG4gICAgICByZXR1cm4ganNvbjtcXG4gICAgfVxcbiAgICBpZiAoIWtleXMuZXZlcnkoa2V5ID0+IHNqc29uLmhhc093blByb3BlcnR5KGtleSkpKSB7XFxuICAgICAgdGhpcy5zYXZlKEpTT04uc3RyaW5naWZ5KGpzb24pKTtcXG4gICAgfVxcbiAgICByZXR1cm4ganNvbjtcXG4gIH0sXFxu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iZm9udFxcXCIpIHx8IGl0ZW0udGl0bGUuaW5jbHVkZXMoXFxcIuKeoe+4j1xcXCIpKSB7XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogaXRlbS50aXRsZS5yZXBsYWNlKC/igJh84oCZfOKAnHzigJ18PFtePl0rPi9nLCBcXFwiXFxcIikucmVwbGFjZShcXFwi4p6h77iPXFxcIiwgXFxcIlxcXCIpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidWlfY3VycmVudFxcXCIpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG5cXG4gICAgICAgICAgbGV0IGN1cnJlbnQgPSBzdG9yYWdlMC5nZXRNeVZhcihcXFwidWlfY3VycmVudFxcXCIsIHt9KTtcXG5cXG4gICAgICAgICAgaWYgKE9iamVjdC5rZXlzKGN1cnJlbnQpLmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKGl0ZW0uZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBjdXJyZW50LnRpdGxlLFxcbiAgICAgICAgICAgICAgcGljOiBjdXJyZW50LnBpYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGRlc2M6IGN1cnJlbnQuZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBjdXJyZW50LnR5cGUsXFxuICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgaXRlbS5leHRyYSwge1xcbiAgICAgICAgICAgICAgICBrZXk6IGN1cnJlbnQuZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICBpbmRleDogY3VycmVudC5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKGN1cnJlbnQuZXh0cmEuaWQsIHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBpdGVtLnRpdGxlLFxcbiAgICAgICAgICAgICAgcGljOiBpdGVtLnBpYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGRlc2M6IGl0ZW0uZGVzYyB8fCBcXFwiXFxcIixcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiBpdGVtLnR5cGUsXFxuICAgICAgICAgICAgICBleHRyYTogT2JqZWN0LmFzc2lnbih7fSwgY3VycmVudC5leHRyYSwge1xcbiAgICAgICAgICAgICAgICBrZXk6IGl0ZW0uZXh0cmEua2V5LFxcbiAgICAgICAgICAgICAgICBpbmRleDogaXRlbS5leHRyYS5pbmRleFxcbiAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICB9KTtcXG5cXG4gICAgICAgICAgICBsZXQgbmFyciA9ICQuc3dhcEFycmF5RWxlbWVudHMoaW5kZXhzLCBjdXJyZW50LmV4dHJhLmluZGV4LCBpdGVtLmV4dHJhLmluZGV4KTtcXG5cXG4gICAgICAgICAgICAkLnVpQ29uZmlnLnNldChuYXJyLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICBjbGVhck15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIik7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IGggPSAn4oCc4oCc4oCd4oCdJztcXG4gICAgICAgICAgICBsZXQgdGl0bGUgPSBpdGVtLnRpdGxlO1xcbiAgICAgICAgICAgIHRvYXN0KFxcXCLpgInmi6nnp7vliqjnmoTnm67moIdcXFwiKTtcXG4gICAgICAgICAgICBpZiAoL3RleHRfaWNvbnxhdmF0YXJ8aWNvbl9zbWFsbF8zLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUuZm9udGNvbG9yKFxcXCIjZmZmXFxcIik7XFxuICAgICAgICAgICAgfSBlbHNlIGlmICgvaWNvbl8xX3NlYXJjaC8udGVzdChpdGVtLnR5cGUpKSB7XFxuICAgICAgICAgICAgICBoID0gXFxcIlxcXCI7XFxuICAgICAgICAgICAgICB0aXRsZSA9IFxcXCLinqHvuI9cXFwiICsgdGl0bGU7XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgIHRpdGxlID0gdGl0bGUuZm9udGNvbG9yKFxcXCIjZmZmXFxcIik7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGggKyB0aXRsZSxcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIHN0b3JhZ2UwLnB1dE15VmFyKFxcXCJ1aV9jdXJyZW50XFxcIiwgaXRlbSk7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGkpXFxuICAgICAgICBpdGVtW1xcXCJleHRyYVxcXCJdID0ge1xcbiAgICAgICAgICBrZXk6IGl0ZW0ua2V5LFxcbiAgICAgICAgICBjbHM6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIixcXG4gICAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIGksXFxuICAgICAgICAgIGluZGV4OiBpdGVtLmluZGV4LFxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLorr7nva5cXFwiKSB7XFxuICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLliKDpmaRcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgIGxldCBpdGVtcyA9ICQudWlDb25maWcuZ2V0SW5kZXhzKCk7XFxuICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICBpdGVtc1tpXVtcXFwiaW5kZXhcXFwiXSA9IC0xO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1cXG4gICAgICAgIGlmICghL2ljb25fMV9zZWFyY2h8YXZhdGFyLy50ZXN0KGl0ZW0uY29sX3R5cGUpKSB7XFxuICAgICAgICAgIGxvbmdjbGlja3MucHVzaCh7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLmm7TmjaLlm77moIdcXFwiLFxcbiAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChpdGVtKSA9PiB7XFxuICAgICAgICAgICAgICByZXR1cm4gJChpdGVtLmltZykuaW5wdXQoKGl0ZW0pID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGtleSA9IGl0ZW0ua2V5O1xcbiAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICBsZXQgaSA9IGl0ZW1zLmZpbmRJbmRleCh4ID0+IHgua2V5ID09IGtleSk7XFxuICAgICAgICAgICAgICAgIGxldCBrID0ga2V5O1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgIGlmIChrZXkgPT0gXFxcIuaQnOe0ouaooeW8j1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIGsgPSBcXFwi5pCc57SiXFxcIjtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcInlpLmljb25zLlxcXCIgKyBrKTtcXG4gICAgICAgICAgICAgICAgICAvL2l0ZW1zW2ldW1xcXCJpbWdcXFwiXSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGlkID0gZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKS5maWx0ZXIoeCA9PiB4LmV4dHJhLmtleSA9PSBrZXkpWzBdLmV4dHJhLmlkO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHBpYzogaW5wdXQgfSlcXG4gICAgICAgICAgICAgIH0sIGl0ZW0pXFxuICAgICAgICAgICAgfSwgaXRlbSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLmjaLmupBcXFwiICYmIGl0ZW0ua2V5ICE9IFxcXCLmkJzntKLmqKHlvI9cXFwiKSB7XFxuICAgICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi5L+u5pS55ZCN56ewXFxcIixcXG4gICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcInRpdGxlXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHRpdGxlOiBpbnB1dCB9KVxcbiAgICAgICAgICAgICAgICB9LCBrZXkpXFxuICAgICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpdGVtLmV4dHJhLkxvbmdDbGljayA9IGxvbmdjbGlja3M7XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9IGVsc2Uge1xcbiAgICAgIHVpb2JqID0gdWlvYmoubWFwKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBpdGVtLmV4dHJhID0ge1xcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCJcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgIH0pXFxuICAgIH1cXG4gICAgZCA9IGQuY29uY2F0KHVpb2JqKTtcXG5cXG4gICAgaWYgKGluZGV4cy5zb21lKHggPT4geC5pbmRleCA9PSAtMSkgJiYgdWltb2RlKSB7XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5bey56e76ZmkXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICAgIH0pXFxuICAgICAgaW5kZXhzLmZpbHRlcih4ID0+IHguaW5kZXggPT0gLTEpLmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgIGxldCBtYXAgPSBuZXcgTWFwKHN1aW9iai5tYXAob2JqID0+IFtvYmoua2V5LCBvYmpdKSk7XFxuICAgICAgICBsZXQgb2JqID0gbWFwLmdldChpdGVtLmtleSk7XFxuICAgICAgICBvYmoudXJsID0gJChcXFwiXFxcIikubGF6eVJ1bGUoKGtleSwgaW5kZXgpID0+IHtcXG4gICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gaW5kZXg7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaXRlbS5rZXksIG9iai5pbmRleClcXG4gICAgICAgIG9iai50aXRsZSA9IG9iai5rZXk7XFxuICAgICAgICBpZiAob2JqLmV4dHJhID09IHVuZGVmaW5lZCkge1xcbiAgICAgICAgICBvYmouZXh0cmEgPSB7fTtcXG4gICAgICAgIH1cXG4gICAgICAgIG9iai5le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JpbmcoKCkgPT4ge1xcbiAgICAgICAgICAgIHZhciB1YyA9ICQudWlDb25maWcuZ2V0KCk7XFxuICAgICAgICAgICAgcmV0dXJuICQoXFxcInt7Y2xpcGJvYXJkfX1cXFwiKS5pbnB1dCgodWMpID0+IHtcXG4gICAgICAgICAgICAgIHZhciB5aSA9IHt9O1xcbiAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgeWkgPSBKU09OLnBhcnNlKGlucHV0KTtcXG4gICAgICAgICAgICAgICAgaWYgKHlpLmhhc093blByb3BlcnR5KFxcXCJ1aVxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgdWMueWkgPSB5aTtcXG4gICAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1Yyk7XFxuICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5qC85byP6ZSZ6K+vXFxcIilcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9LCB1YylcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH1dXFxuICAgICAgfVxcbiAgICB9KVxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5aS06YOo57uE5Lu25qC35byPOlxcXCIgKyB1aV9jb25maWcueWkuY29sLFxcbiAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICB1cmw6ICQoJyNub0xvYWRpbmcjJykubGF6eVJ1bGUoKHVpX2NvbmZpZykgPT4ge1xcbiAgICAgICAgdWlfY29uZmlnID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgIGxldCBhbGxfY29scyA9IFsnJ10uY29uY2F0KGdldENvbFR5cGVzK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ZUl0ZW0oTVlfUlVMRS50aXRsZSArIFxcXCJfeWljb2xcXFwiLCB7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLlpLTpg6jnu4Tku7bmoLflvI86XFxcIiArIHVpX2NvbmZpZy55aS5jb2xcXG4gICAgICAgICAgfSlcXG4gICAgICAgIH0sIHVpX2NvbmZpZylcXG4gICAgICB9LCB1aV9jb25maWcpLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfeWljb2xcXFwiXFxuICAgICAgfVxcbiAgICB9KVxcblxcbiAgICBsZXQgZG9iaiA9IHt9O1xcbiAgICAkLnVpQ29uZmlnLmdldCgpLnlpLnVpLmZpbHRlcih4ID0+IHguaW5kZXggIT0gLTEpLm1hcChpdCA9PiB7XFxuICAgICAgZG9ialtpdC5rZXldID0gdHJ1ZVxcbiAgICB9KVxcblxcbiAgICBPYmplY3QuZW50cmllcyhkZWVwT21pdCh1aV90aGVtZS55aS5pY29ucywgZG9iaikpLmZvckVhY2goKFtrZXksIHZhbHVlXSkgPT4ge1xcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZToga2V5LFxcbiAgICAgICAgY29sX3R5cGU6IFxcXCJpY29uXzVcXFwiLFxcbiAgICAgICAgaW1nOiB2YWx1ZSxcXG4gICAgICAgIHVybDogJCh2YWx1ZSkuaW5wdXQoKGspID0+IHtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcInlpLmljb25zLlxcXCIgKyBrKTtcXG4gICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGtleSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBkZWZhdWx0VmFsdWU6IHZhbHVlXFxuICAgICAgICB9XFxuICAgICAgfSlcXG4gICAgfSlcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIuWIhuexu+minOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgdXJsOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgIGxldCB7IGlzVmFsaWRDb2xvciB9ID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIik7XFxuICAgICAgICBpZiAoaXNWYWxpZENvbG9yKGlucHV0KSkge1xcbiAgICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwieWku5YiG57G76aKc6ImyXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICB0b2FzdChcXFwi6K+36L6T5YWl5q2j56Gu55qE6aKc6Imy5YC8XFxcIik7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgIH0pLFxcbiAgICAgIGV4dHJhOiB7XFxuICAgICAgICBkZWZhdWx0VmFsdWU6IHVpX2NvbmZpZy55aS7liIbnsbvpopzoibJcXG4gICAgICB9XFxuICAgIH0pXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmjaLmupDpopzoibJcXFwiLFxcbiAgICAgIGNvbF90eXBlOiBcXFwiaW5wdXRcXFwiLFxcbiAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICBsZXQgeyBpc1ZhbGlkQ29sb3IgfSA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpO1xcbiAgICAgICAgaWYgKGlzVmFsaWRDb2xvcihpbnB1dCkpIHtcXG4gICAgICAgICAgJC51aVRoZW1lLnNldChpbnB1dCwgXFxcInlpLuaNoua6kOminOiJslxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgdG9hc3QoXFxcIuivt+i+k+WFpeato+ehrueahOminOiJsuWAvFxcXCIpO1xcbiAgICAgICAgfVxcbiAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICB9KSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgZGVmYXVsdFZhbHVlOiB1aV9jb25maWcueWku5o2i5rqQ6aKc6ImyXFxuICAgICAgfVxcbiAgICB9KVxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5YiG57G76aKc6ImyXFxcIixcXG4gICAgICBpbWc6IHVpX2NvbmZpZy55aS7liIbnsbvpopzoibIgPT0gXFxcInJhbmRvbVxcXCIgPyBnZXRSYW5nZUNvbG9ycygpIDogdWlfY29uZmlnLnlpLuWIhuexu+minOiJsixcXG4gICAgICB1cmw6IFxcXCJ0b2FzdDovL+WIhuexu+minOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpY29uXzNfZmlsbFxcXCIsXFxuICAgIH0pXFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmjaLmupDpopzoibJcXFwiLFxcbiAgICAgIGltZzogdWlfY29uZmlnLnlpLuaNoua6kOminOiJsiA9PSBcXFwicmFuZG9tXFxcIiA/IGdldFJhbmdlQ29sb3JzKCkgOiB1aV9jb25maWcueWku5o2i5rqQ6aKc6ImyLFxcbiAgICAgIHVybDogXFxcInRvYXN0Oi8v5o2i5rqQ6aKc6ImyXFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcImljb25fM19maWxsXFxcIixcXG4gICAgfSlcXG4gIH1cXG5cXG4gIGlmICh1aV9uYXZpID09IFxcXCLkuoznuqdcXFwiKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmr4/pobXmlbDph49cXFwiLFxcbiAgICAgIGRlc2M6IFxcXCIw5YiZ6KGo56S65LiN5YiG6aG1X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gICAgdHlwZTogXFxcIm51bWJlclxcXCIsXFxuICAgICAgfVxcbiAgICB9KVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi57q/6Lev5qC35byPOiBcXFwiICsgdWlfY29uZmlnLmVyLue6v+i3r+agt+W8jyxcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKCgpID0+IHtcXG4gICAgICAgIGxldCBjb2wgPSAkLnVpQ29uZmlnLmdldCgpLmVyLue6v+i3r+agt+W8jztcXG4gICAgICAgIGxldCBjb2xzID0gW1xcXCJcXFwiXS5jb25jYXQoZ2V0Q29sVHlwZXMoKSk7XFxuICAgICAgICBjb2xzID0gY29scy5maWx0ZXIoeCA9PiAvdGV4dF98YnV0dG9ufF9maWxsfGljb24vZy50ZXN0KHgpLyomIXguaW5jbHVkZXMoXFxcImljb25cXFwiKSovKTtcXG4gICAgICAgIGNvbHMudW5zaGlmdChcXFwic2VsZWN0XFxcIik7XFxuICAgICAgICBjb2xzID0gY29scy5tYXAoeCA9PiB4ID09IGNvbCA/IFxcXCLinqHvuI9cXFwiICsgeCA6IHgpO1xcbiAgICAgICAgcmV0dXJuICQoY29scywgMikuc2VsZWN0KCgpID0+IHtcXG4gICAgICAgICAgaW5wdXQgPSBpbnB1dC5yZXBsYWNlKFxcXCLinqHvuI9cXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICQudWlDb25maWcuc2V0KGlucHV0LCBcXFwiZXIu57q/6Lev5qC35byPXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgIH0pXFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLmVyLue6v+i3r+agt+W8jyxcXG4gICAgICAgIGxpbmVWaXNpYmxlOiBmYWxzZ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GlzVmFsaWRDb2xvciB9ID0gJC5yZXF1aXJlKFxcXCJtZXRob2RzXFxcIik7XFxuICAgICAgICBpZiAoaXNWYWxpZENvbG9yKGlucHV0KSkge1xcbiAgICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwiZXIu57q/6Lev6aKc6ImyXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIHRvYXN0KFxcXCLor7fovpPlhaXmraPnoa7nmoTpopzoibLlgLxcXFwiKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLmVyLue6v+i3r+minOiJslxcbiAgICAgIH1cXG4gICAgfSlcXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIua1headpea6kOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgZGVzYzogXFxcIuWtl+S9k+minOiJsjvog4zmma/popzoibJcXFwiLFxcbiAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICBpZiAoaW5wdXQuaW5jbHVkZXMoXFxcIjtcXFwiKSkge1xcbiAgICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwiZXIu5rWF5p2l5rqQ6ImyXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIHRvYXN0KFxcXCLor7fovpPlhaXmraPnoa7mlbDlgLxcXFwiKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLmVyLua1headpea6kOiJslxcbiAgICAgIH1cXG4gICAgfSlcXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIua3seadpea6kOiJslxcXCIsXFxuICAgICAgY29sX3R5cGU6IFxcXCJpbnB1dFxcXCIsXFxuICAgICAgZGVzYzogXFxcIuWtl+S9k+minOiJsjvog4zmma/popzoibJcXFwiLFxcbiAgICAgIHVybDogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICBpZiAoaW5wdXQuaW5jbHVkZXMoXFxcIjtcXFwiKSkge1xcbiAgICAgICAgICAkLnVpVGhlbWUuc2V0KGlucHV0LCBcXFwiZXIu5rex5p2l5rqQ6ImyXFxcIik7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgIHRvYXN0KFxcXCLor7fovpPlhaXmraPnoa7mlbDlgLxcXFwiKTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgfSksXFxuICAgICAgZXh0cmE6IHtcXG4gICAgICAgIGRlZmF1bHRWYWx1ZTogdWlfY29uZmlnLmVyLua3seadpea6kOiJslxcbiAgICAgIH1cXG4gICAgfSlcXG5cXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIue6v+i3r+minOiJslxcXCIsXFxuICAgICAgaW1nOiB1aV9jb25maWcuZXIu57q/6Lev6aKc6ImyLFxcbiAgICAgIHVybDogXFxcInRvYXN0Oi8v57q/6Lev6aKc6ImyXFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcImljb25fM19maWxsXFxcIixcXG4gICAgfSlcXG5cXG4gICAgZC5wdXNoKHtcXG4gICAgICB0aXRsZTogXFxcIueugOS7i+agt+W8jzogXFxcIiArIHVpX2NvbmZpZy5lci7nroDku4vmo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AgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgICAgbGV0IHVjID0gJC51aUNvbmZpZy5nZXQoKTtcXG4gICAgICAgICAgICBjb3B5KEpTT04uc3RyaW5naWZ5KHVjLmVyKSk7XFxuICAgICAgICAgIH0pLFxcbiAgICAgICAgfSwge1xcbiAgICAgICAgICB0aXRsZTogXFxcIuWvvOWFpVxcXCIsXFxuICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICAgICAgICB2YXIgdWMgPSAkLnVpQ29uZmlnLmdldCgpO1xcbiAgICAgICAgICAgIHJldHVybiAkKFxcXCJ7e2NsaXBib2FyZH19XFxcIikuaW5wdXQoKHVjKSA9PiB7XFxuICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB1Yy5lciA9IEpTT04ucGFyc2UoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1Yyk7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuagvOW8j+mUmeivr1xcXCIpXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSwgdWMpXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9XVxcbiAgICAgIH1cXG4gICAgfSlcXG4gIH1cXG4gIHNldFJlc3VsdChkKTtcXG59XCJ9LHtcImNvbF90eXBlXCI6XCJtb3ZpZV8zXCIsXCJuYW1lXCI6XCJMb2NhbFByb3h5XCIsXCJwYXRoXCI6XCJMb2NhbFByb3h5XCIsXCJydWxlXCI6XCJmdW5jdGlvbiBwcm94eSgpIHtcXG4gICAgZnVuY3Rpb24gcGFyc2VWaWRlbyhNWV9QQVJBTVMsIHRpdGxlKSB7XFxuICAgICAgICBmdW5jdGlvbiB0b1BhdGgodmFsdWUpIHtcXG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAnc3RyaW5nJykge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gW107XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBwYXRoID0gW107XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSAnJztcXG4gICAgICAgICAgICBsZXQgaW5CcmFja2V0cyA9IGZhbHNlO1xcbiAgICAgICAgICAgIGxldCBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHZhbHVlLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBjaGFyID0gdmFsdWVbaV07XFxuICAgICAgICAgICAgICAgIGlmIChlc2NhcGUpIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IGZhbHNlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdcXFxcXFxcXCcpIHtcXG4gICAgICAgICAgICAgICAgICAgIGVzY2FwZSA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJy4nICYmICFpbkJyYWNrZXRzKSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gJyc7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ1snKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gdHJ1ZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXScpIHtcXG4gICAgICAgICAgICAgICAgICAgIGluQnJhY2tldHMgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnQgKz0gY2hhcjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAoY3VycmVudCkge1xcbiAgICAgICAgICAgICAgICBwYXRoLnB1c2goY3VycmVudCk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBwYXRoO1xcbiAgICAgICAgfVxcblxcbiAgICAgICAgZnVuY3Rpb24gZ2V0SnNvbihvYmosIHBhdGgpIHtcXG4gICAgICAgICAgICBpZiAoIW9iaiB8fCAhQXJyYXkuaXNBcnJheShwYXRoKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBpZiAocGF0aC5sZW5ndGggPT09IDApIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIG9iajtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGN1cnJlbnQgPSBvYmo7XFxuICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XFxuICAgICAgICAgICAgICAgIGxldCBrZXkgPSBwYXRoW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoY3VycmVudCA9PT0gbnVsbCB8fCBjdXJyZW50ID09PSB1bmRlZmluZWQgfHwgdHlwZW9mIGN1cnJlbnQgIT09ICdvYmplY3QnKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGN1cnJlbnQgPSBjdXJyZW50W2tleV07XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHJldHVybiBjdXJyZW50O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBsZXQgcnVuVHlwZSA9IE1ZX1BBUkFNUy5ydW5UeXBlWzBdO1xcbiAgICAgICAgICAgIGxldCB1cmwgPSBkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy51cmxbMF0pKTtcXG4gICAgICAgICAgICBpZiAocnVuVHlwZSA9PSBcXFwiSlNPTlxcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcmFtID0gSlNPTi5wYXJzZShkZWNvZGVVUklDb21wb25lbnQoYmFzZTY0RGVjb2RlKE1ZX1BBUkFNUy5wYXJhbVswXSkpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGpzb24gPSBKU09OLnBhcnNlKHJlcXVlc3QodXJsLCB7XFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBwYXJhbS5oZWFkZXJzIHx8IHt9LFxcbiAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiBwYXJhbS5tZXRob2QgfHwgdm9pZCAwXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IE9iamVjdC5hc3NpZ24oe30sIHBhcmFtLmhlYWRlcnMgfHwge30sIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiBnZXRKc29uKGpzb24sIHRvUGF0aChwYXJhbS5qc29uUGF0aCkpLFxcbiAgICAgICAgICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChydW5UeXBlID09IFxcXCJKU1xcXCIpIHtcXG5cXG4gICAgICAgICAgICAgICAgbGV0IHBhcnNlO1xcbiAgICAgICAgICAgICAgICBpZiAoTVlfUEFSQU1TLmluZGV4KSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9ICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyB0aXRsZSkuZ2V0SnNvbigpW01ZX1BBUkFNUy5pbmRleFswXV07XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBwYXJzZSA9IEpTT04ucGFyc2UoYmFzZTY0RGVjb2RlKGRlY29kZVVSSUNvbXBvbmVudChNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgbGV0IHJlcyA9IG5ldyBGdW5jdGlvbihcXFwidXJsXFxcIiwgXFxcInNlbGZcXFwiLCBwYXJzZS5qcykodXJsLCBwYXJzZSk7XFxuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzID09PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyczoge1xcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcXFwiTG9jYXRpb25cXFwiOiByZXNcXG4gICAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgkLnR5cGUocmVzKSA9PT0gXFxcIm9iamVjdFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHJlc1xcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICA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cmV0dXJuIHRoaXMuY2FjaGVDbGFzcztcXG4gICAgICAgIGxldCBob21lID0gSlNPTi5wYXJzZShmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGV4dGVuZDogdGhpcy5leHQsXFxuICAgICAgICAgICAgZmlsdGVyOiBcXFwidHJ1ZVxcXCJcXG4gICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgcmVkaXJlY3Q6IHRoaXMucmVkaXJlY3RcXG4gICAgICAgIH0pKTtcXG4gICAgICAgIHRoaXMuY2FjaGVDbGFzcyA9IGhvbWU7XFxuXFxuICAgICAgICByZXR1cm4gaG9tZTtcXG4gICAgfSxcXG4gICAgaG9tZVZvZCgpIHtcXG4gICAgICAgIC8qaWYodGhpcy52b2RDb3VudCl7XFxuICAgICAgICAgICAgdGhpcy5pbml0KCk7XFxuICAgICAgICB9Ki9cXG4gICAgICAgIGxldCBkYXRhID0gdGhpcy5nZXRIb21lRGF0YSgpO1xcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICBsaXN0OiBkYXRhLmxpc3QgfHwgW11cXG4gICAgICAgIH0pO1xcbiAgICAgICAgdGhpcy52b2RDb3VudCsrO1xcbiAgICB9LFxcbiAgICBob21lKCkge1xcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHRoaXMuZ2V0SG9tZURhdGEoKSk7XFxuICAgIH0sXFxuICAgIGNhdGVnb3J5KHRpZCwgcGcsIGZpbHRlciwgZXh0ZW5kKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcInZpZGVvbGlzdFxcXCIsXFxuICAgICAgICAgICAgdDogdGlkLFxcbiAgICAgICAgICAgIHBnOiBcXFwiXFxcIiArIHBnLFxcbiAgICAgICAgICAgIGV4dGVuZDogdGhpcy5leHQsXFxuICAgICAgICAgICAgZXh0OiBleHRlbmQgPyBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkoZXh0ZW5kKSkgOiBcXFwiXFxcIlxcbiAgICAgICAgfSksIHtcXG4gICAgICAgICAgICByZWRpcmVjdDogdGhpcy5yZWRpcmVjdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGRldGFpbCh2b2RfdXJsKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgaWRzOiB2b2RfdXJsLFxcbiAgICAgICAgICAgIGV4dGVuZDogdGhpcy5leHQsXFxuICAgICAgICB9KSwge1xcbiAgICAgICAgICAgIHJlZGlyZWN0OiB0aGlzLnJlZGlyZWN0XFxuICAgICAgICB9KTtcXG4gICAgfSxcXG4gICAgcGxheShmbGFnLCBpZCkge1xcbiAgICAgICAgcmV0dXJuIGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgLy9hYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgZmxhZzogZmxhZyxcXG4gICAgICAgICAgICBwbGF5OiBpZFxcbiAgICAgICAgfSksIHtcXG4gICAgICAgICAgICByZWRpcmVjdDogdGhpcy5yZWRpcmVjdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIHNlYXJjaCh3ZCwgcXVpY2ssIHBnKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICB3ZDogd2QsXFxuICAgICAgICAgICAgZXh0ZW5kOiB0aGlzLmV4dCxcXG4gICAgICAgICAgICBwZzogcGdcXG4gICAgICAgIH0pLCB7XFxuICAgICAgICAgICAgcmVkaXJlY3Q6IHRoaXMucmVkaXJlY3RcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBnZXRSdWxlKGtleSkge1xcbiAgICA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WxlLuaOqOiNkDtcXG4gICAgICAgICAgICBkYXRhLmxpc3QgPSBbXTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAgZ2V0SG9tZURhdGEoKSB7XFxuICAgICAgICBpZiAodGhpcy5jYWNoZUNsYXNzKSByZXR1cm4gdGhpcy5jYWNoZUNsYXNzO1xcbiAgICAgICAgbGV0IHhtbCA9IGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgYWM6IFxcXCJjbGFzc1xcXCJcXG4gICAgICAgIH0pKS5yZXBsYWNlKC9cXFxcPC4qP3htbC4qP1xcXFw+LywgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IGhvbWUgPSB7XFxuICAgICAgICAgICAgbGlzdDogW10sXFxuICAgICAgICAgICAgY2xhc3M6IFtdXFxuICAgICAgICB9O1xcbiAgICAgICAgbGV0IGhvbWVYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmxpc3QudmlkZW8pIHtcXG4gICAgICAgICAgICBob21lLmxpc3QucHVzaCh7XFxuICAgICAgICAgICAgICAgIHZvZF9pZDogaXRlbS5pZC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfbmFtZTogaXRlbS5uYW1lLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF90aW1lOiBpdGVtLmxhc3QudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdHlwZV9pZDogaXRlbS50aWQudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGl0ZW0ubm90ZS50b1N0cmluZygpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmNsYXNzLnR5KSB7XFxuICAgICAgICAgICAgaG9tZS5jbGFzcy5wdXNoKHtcXG4gICAgICAgICAgICA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VYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBsZXQgbGlzdCA9IFtdO1xcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0gaW4gaG9tZVhtbC5saXN0LnZpZGVvKSB7XFxuICAgICAgICAgICAgbGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcGljOiBpdGVtLnBpYy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKClcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgbGlzdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGRldGFpbCh2b2RfdXJsKSB7XFxuICAgICAgICBsZXQgeG1sID0gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgaWRzOiB2b2RfdXJsLFxcbiAgICAgICAgfSkpLnJlcGxhY2UoL1xcXFw8Lio/eG1sLio/XFxcXD4vLCBcXFwiXFxcIik7XFxuICAgICAgICBsZXQgaG9tZVhtbCA9IG5ldyBYTUwoeG1sKTtcXG4gICAgICAgIGxldCBsaXN0ID0gW107XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmxpc3QudmlkZW8pIHtcXG4gICAgICAgICAgICBsZXQgcmVzaXRlbSA9IHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcGljOiBpdGVtLnBpYy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9jb250ZW50OiBpdGVtLmRlcy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfYWN0b3I6IGl0ZW0uYWN0b3IudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX2RpcmVjdG9yOiBpdGVtLmRpcmVjdG9yLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICBsZXQgZnJvbSA9IFtdO1xcbiAgICAgICAgICAgIGxldCBwbGF5ID0gW107XFxuICAgICAgICAgICAgZm9yIGVhY2gobGV0IHBsYXlMaXN0SXRlbSBpbiBpdGVtLmRsLmRkKSB7XFxuICAgICAgICAgICAgICAgIGZyb20ucHVzaChwbGF5TGlzdEl0ZW0uQGZsYWcpO1xcbiAgICAgICAgICAgICAgICBwbGF5LnB1c2gocGxheUxpc3RJdGVtLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXNpdGVtLnZvZF9wbGF5X2Zyb20gPSBmcm9tLmpvaW4oXFxcIiQkJFxcXCIpO1xcbiAgICAgICAgICAgIHJlc2l0ZW0udm9kX3BsYXlfdXJsID0gcGxheS5qb2luKFxcXCIkJCRcXFwiKTtcXG4gICAgICAgICAgICBsaXN0LnB1c2gocmVzaXRlbSk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3RcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBwbGF5KGZsYWcsIGlucHV0KSB7XFxuICAgICAgICBsZXQgcGFyc2VfdXJsID0gdGhpcy5zb3VyY2UucGxheXVybCB8fCBcXFwiXFxcIjtcXG4gICAgICAgIGlmICgvXFxcXC4obTN1OHxtcDQpLy50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICB1cmw6IGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChwYXJzZV91cmwuc3RhcnRzV2l0aCgnanNvbjonKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgcHVybCA9IHBhcnNlX3VybC5yZXBsYWNlKCdqc29uOicsICcnKSArIGlucHV0O1xcbiAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QocHVybCk7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogSlNPTi5wYXJzZShodG1sKS51cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBwYXJzZV91cmwgKyBpbnB1dFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNlYXJjaCh3ZCwgcXVpY2ssIHBnKSB7XFxuICAgICAgICBsZXQgeG1sID0gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICB3ZDogd2QsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKS5yZXBsYWNlKC9cXFxcPC4qP3htbC4qP1xcXFw+LywgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IGhvbWVYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBsZXQgbGlzdCA9IFtdO1xcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0gaW4gaG9tZVhtbC5saXN0LnZpZGVvKSB7XFxuICAgICAgICAgICAgbGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcGljOiBpdGVtLnBpYy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKClcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgbGlzdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGdldFJ1bGUoa2V5KSB7XFxuICAgICAgICByZXR1cm4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XFxcInZpZGVvbGlzdFxcXCIsXFxuICAgICAgICAgICAgdDogdGlkLFxcbiAgICAgICAgICAgIHBnOiBcXFwiXFxcIiArIHBnXFxuICAgICAgICB9KSk7XFxuICAgIH0sXFxuICAgIGRldGFpbCh2b2RfdXJsKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgaWRzOiB2b2RfdXJsLFxcbiAgICAgICAgfSkpO1xcbiAgICB9LFxcbiAgICBwbGF5KGZsYWcsIGlucHV0KSB7XFxuICAgICAgICBsZXQgcGFyc2VfdXJsID0gdGhpcy5zb3VyY2UucGxheXVybCB8fCBcXFwiXFxcIjtcXG4gICAgICAgIGlmICgvXFxcXC4obTN1OHxtcDQpLy50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICB1cmw6IGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChwYXJzZV91cmwuc3RhcnRzV2l0aCgnanNvbjonKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgcHVybCA9IHBhcnNlX3VybC5yZXBsYWNlKCdqc29uOicsICcnKSArIGlucHV0O1xcbiAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QocHVybCk7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogSlNPTi5wYXJzZShodG1sKS51cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBwYXJzZV91cmwgKyBpbnB1dFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNlYXJjaCh3ZCwgcXVpY2ssIHBnKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICB3ZDogd2QsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKTtcXG4gICAgfSxcXG4gICAgZ2V0UnVsZShrZXkpIHtcXG4gICAgICAgIHJldHVybiBrZXkgPyB0aGlzLnJ1bGVba2V5XSA6IHRoaXMucnVsZTtcXG4gICAgfSxcXG4gICAgcnVuTWFpbigpIHtcXG4gICAgICAgIHJldHVybiBcXFwiXFxcIjtcXG4gICAgfVxcbn0pO1xcbiQuZXhwb3J0cyA9IFQxQWRhcHRlcjtcIn0se1wiY29sX3R5cGVcIjpcIm1vdmllXzNcIixcIm5hbWVcIjpcIuS6jOe6p+aWueazlVwiLFwicGF0aFwiOlwibWV0aG9kc19lclwiLFwicnVsZVwiOlwianM6XFxubGV0IHtcXG4gIHVpX2NvbmZpZyxcXG59ID0gJC5yZXF1aXJlKFxcXCJVSU1hbmFnZT9ydWxlXFxcIitNW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cbiAgICAucmVwbGFjZShlbW9qaVJlZywgXFxcIlxcXCIpO1xcbiAgLy8g5p6E5bu65bm25o6o5YWl5o+P6L+w6aG56IezZFxcbiAgYXJyLnB1c2goe1xcbiAgICB0aXRsZTogXFxcIuW9seeJh+eugOS7i1xcXCIsXFxuICAgIGRlc2M6IGA8c21hbGw+PHNwYW4gc3R5bGU9XFxcImNvbG9yOiAke0NvbG9yfVxcXCI+5bGV5byAPj48L3NwYW4+PC9zbWFsbD5gLFxcbiAgICBpbWc6IFxcXCJodHRwczovL2hpa2VyZmFucy5jb20vaW1nL2pqLnN2Z1xcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZShcXG4gICAgICAoamppZCwgZGVjaWQsIGRlc1RleHQsIENvbG9yKSA9PiB7XFxuICAgICAgICBjb25zdCBhY3Rpb24gPSBnZXRNeVZhcihcXFwiampzXFxcIiwgXFxcIuWxleW8gFxcXCIpID09PSBcXFwi5bGV5byAXFxcIiA/IFxcXCLmlLbotbdcXFwiIDogXFxcIuWxleW8gFxcXCI7XFxuICAgICAgICBwdXRNeVZhcihcXFwiampzXFxcIiwgYWN0aW9uKTtcXG5cXG4gICAgICAgIHVwZGF0ZUl0ZW0oe1xcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGlkOiBqamlkXFxuICAgICAgICAgIH0sXFxuICAgICAgICAgIGRlc2M6IGA8c21hbGw+PHNwYW4gc3R5bGU9XFxcImNvbG9yOiAke0NvbG9yfVxcXCI+JHthY3Rpb259Pj48L3NwYW4+PC9zbWFsbD5gXFxuICAgICAgICB9KTtcXG4gICAgICAgIHVwZGF0ZUl0ZW0oe1xcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHRleHRTaXplOiAxNCxcXG4gICAgICAgICAgICBsaW5lU3BhY2luZzogMyxcXG4gICAgICAgICAgICBpZDogZGVjaWRcXG4gICAgICAgICAgfSxcXG4gICAgICAgICAgdGl0bGU6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SA9PiB7XFxuICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IGpzb24gPSAkLl90aGVtZS5nZXQoKTtcXG4gICAgICAgICAgICBsZXQgb2JqID0gSlNPTi5wYXJzZShpbnB1dCk7XFxuICAgICAgICAgICAgbGV0IHN1Y2Nlc3MgPSBmYWxzZTtcXG4gICAgICAgICAgICBPYmplY3QuZW50cmllcyhvYmopLmZvckVhY2goKFtrLCB2XSkgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKCFqc29uLmhhc093blByb3BlcnR5KGspKSB7XFxuICAgICAgICAgICAgICAgICQuX3RoZW1lLnNldChrLCB2KTtcXG4gICAgICAgICAgICAgICAgc3VjY2VzcyA9IHRydWU7XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwia2V5OlxcXCIgKyBrICsgXFxcIiDlt7Lnu4/lrZjlnKgs6Lez6L+HXFxcIik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgICBpZiAoc3VjY2Vzcykge1xcbiAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoKTtcXG4gICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr7zlhaXmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/moLzlvI/plJnor69cXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9KVxcbiAgICAgIH1cXG4gICAgICBpZiAoeCA9PSBcXFwi5pS55ZCNXFxcIikge1xcbiAgICAgICAgaWYgKC9eKOm7mOiupHzlvZPliY0pJC8udGVzdChuaykpIHtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveaUueWQjVxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICByZXR1cm4gJChcXFwi5paw5ZCN56ewXFxcIikuaW5wdXQoKGspID0+IHtcXG4gICAgICAgICAgICBsZXQgb2JqID0gJC5fdGhlbWUuZ2V0KCk7XFxuICAgICAgICAgICAgbGV0IG5ld09iaiA9IE9iamVjdC5rZXlzKG9iaikucmVkdWNlKChhY2MsIGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgaWYgKGtleSA9PT0gaykge1xcbiAgICAgICAgICAgICAgICBhY2NbaW5wdXRdID0gb2JqW2tleV07XFxuICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICBhY2Nba2V5XSA9IG9ialtrZXldO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgcmV0dXJuIGFjYztcXG4gICAgICAgICAgICB9LCB7fSk7XFxuICAgICAgICAgICAgJC5fdGhlbWUuc2F2ZShKU09OLnN0cmluZ2lmeShuZXdPYmopKTtcXG4gICAgICAgICAgICBwdXRNeVZhcigkLm15X3VybCArIFxcXCJuXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIH0sIG5rKVxcbiAgICAgICAgfVxcbiAgICAgIH1cXG4gICAgICBpZiAoeCA9PSBcXFwi5Yig6ZmkXFxcIikge1xcbiAgICAgICAgaWYgKC9eKOm7mOiupHzlvZPliY0pJC8udGVzdChuaykpIHtcXG4gICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeiDveWIoOmZpFxcXCI7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICByZXR1cm4gJChcXFwi56Gu6K6k5Yig6ZmkXFxcIikuY29uZmlybSgoaykgPT4ge1xcbiAgICAgICAgICAgIC8qKlxcbiAgICAgICAgICAgICAqIOiOt+WPluWvueixoeS4ree7meWumumUrueahOWJjeS4gOS4quaIluWQjuS4gOS4qumUruOAglxcblxcbiAgICAgICAgICAgICAqIOatpOWHveaVsOeUqOS6jumBjeWOhuWvueixoeeahOmUru+8jOagueaNrue7meWumueahOmUruaJvuWIsOWFtuWJjeS4gOS4quaIluWQjuS4gOS4qumUruOAglxcbiAgICAgICAgICAgICAqIOWmguaenOe7meWumueahOmUruS4jeWtmOWcqOS6juWvueixoeS4re+8jOWHveaVsOWwhuWwneivleaJvuWIsOWkp+S6jue7meWumumUrueahOesrOS4gOS4qumUruOAglxcbiAgICAgICAgICAgICAqIOWmguaenOWvueixoeS4reayoeacieWkp+S6jue7meWumumUrueahOmUru+8jOWImei/lOWbnuWvueixoeeahOacgOWQjuS4gOS4qumUruOAglxcbiAgICAgICAgICAgICAqIFxcbiAgICAgICAgICAgICAqIEBwYXJhbSB7T2JqZWN0fSBvYmog6KaB6YGN5Y6G55qE5a+56LGh44CCXFxuICAgICAgICAgICAgICogQHBhcmFtIHtzdHJpbmd9IGtleSDopoHmn6Xmib7liY3kuIDkuKrmiJblkI7kuIDkuKrplK7nmoTplK7jgIJcXG4gICAgICAgICAgICAgKiBAcmV0dXJucyB7c3RyaW5nfSDov5Tlm57mib7liLDnmoTliY3kuIDkuKrmiJblkI7kuIDkuKrplK7jgIJcXG4gICAgICAgICAgICAgKi9cXG4gICAgICAgICAgICBmdW5jdGlvbiBnZXRQcmV2aW91c09yTmV4dEtleShvYmosIGtleSkge1xcbiAgICAgICAgICAgICAgY29uc3Qga2V5cyA9IE9iamVjdC5rZXlzKG9iaik7XFxuICAgICAgICAgICAgICBjb25zdCBpbmRleCA9IGtleXMuaW5kZXhPZihrZXkpO1xcbiAgICAgICAgICAgICAgaWYgKGluZGV4ID4gLTEpIHtcXG4gICAgICAgICAgICAgICAgLy8g5aaC5p6c6ZSu5a2Y5Zyo77yM6L+U5Zue5YmN5LiA5Liq6ZSuXFxuICAgICAgICAgICAgICAgIHJldHVybiBpbmRleCA+IDAgPyBrZXlzW2luZGV4IC0gMV0gOiBrZXlzW2luZGV4ICsgMV07IC8vIOWmguaenOaYr+esrOS4gOS4qumUru+8jOi/lOWbnuS4i+S4gOS4qumUrlxcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgLy8g5aaC5p6c6ZSu5LiN5a2Y5Zyo77yM6L+U5Zue5LiL5LiA5Liq6ZSuXFxuICAgICAgICAgICAgICAgIGNvbnN0IG5leHRJbmRleCA9IGtleXMuZmluZEluZGV4KGsgPT4gayA+IGtleSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBuZXh0SW5kZXggPiAtMSA/IGtleXNbbmV4dEluZGV4XSA6IGtleXNba2V5cy5sZW5ndGggLSAxXTsgLy8g5aaC5p6c5rKh5pyJ5LiL5LiA5Liq6ZSu77yM6L+U5Zue5pyA5ZCO5LiA5Liq6ZSuXFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcblxcbiAgICAgICAgICAgIGxldCBvYmogPSAkLl90aGVtZS5nZXQoKTtcXG4gICAgICAgICAgICBsZXQgbmFtZSA9IGdldFByZXZpb3VzT3JOZXh0S2V5KG9iaiwgayk7XFxuICAgICAgICAgICAgZGVsZXRlIG9ialtrXTtcXG4gICAgICAgICAgICAkLl90aGVtZS5zYXZlKEpTT04uc3RyaW5naWZ5KG9iaikpO1xcblxcbiAgICAgICAgICAgIHB1dE15VmFyKCQubXlfdXJsICsgXFxcIm5cXFwiLCBuYW1lKTtcXG4gICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICB9LCBuaylcXG4gICAgICAgIH1cXG4gICAgICB9XFxuICAgIH0sIHgsIG5rLCBpdGVtKVxcbiAgfSlcXG59KVxcbmQucHVzaCh7XFxuICBjb2xfdHlwZTogXFxcImJpZ19ibGFua19ibG9ja1xcXCJcXG59KVxcblxcbk9iamVjdC5rZXlzKGpzb24pLmZvckVhY2goKGssIGkpID0+IHtcXG4gIGxldCBsb25nY2xpY2tzID0gW107XFxuICBpZiAoIS9eKOm7mOiupHzlvZPliY0pJC8udGVzdChrKSkge1xcbiAgICBsb25nY2xpY2tzLnB1c2goe1xcbiAgICAgIHRpdGxlOiBcXFwi5pS55ZCNXFxcIixcXG4gICAgICBqczogJC50b1N0cmluZygoaykgPT4ge1xcbiAgICAgICAgcmV0dXJuICQoXFxcIuaWsOWQjeensFxcXCIpLmlucHV0KChrKSA9PiB7XFxuICAgICAgICAgIGxldCBvYmogPSAkLl90aGVtZS5nZXQoKTtcXG4gICAgICAgICAgbGV0IG5ld09iaiA9IE9iamVjdC5rZXlzKG9iaikucmVkdWNlKChhY2MsIGtleSkgPT4ge1xcbiAgICAgICAgICAgIGlmIChrZXkgPT09IGspIHtcXG4gICAgICAgICAgICAgIGFjY1tpbnB1dF0gPSBvYmpba2V5XTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgYWNjW2tleV0gPSBvYmpba2V5XTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgcmV0dXJuIGFjYztcXG4gICAgICAgICAgfSwge30pO1xcbiAgICAgICAgICAkLl90aGVtZS5zYXZlKEpTT04uc3RyaW5naWZ5KG5ld09iaikpO1xcbiAgICAgICAgICBwdXRNeVZhcigkLm15X3VybCArIFxcXCJuXFxcIiwgaW5wdXQpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSwgaylcXG4gICAgICB9LCBrKVxcbiAgICB9KVxcbiAgfVxcbiAgZC5wdXNoKHtcXG4gICAgdGl0bGU6IG5rID09IGsgPyAn4oCc4oCc4oCd4oCdJyArIGsuZm9udGNvbG9yKFxcXCJyZWRcXFwiKSA6IGssXFxuICAgIGNvbF90eXBlOiBcXFwic2Nyb2xsX2J1dHRvblxcXCIsXFxuICAgIHVybDogJChcXFwiI25vTG9hZGluZyNcXFwiKS5sYXp5UnVsZSgoaykgPT4ge1xcbiAgICAgIHB1dE15VmFyKE1ZX1VSTCArIFxcXCJuXFxcIiwgayk7XF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