Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:小程序¥home_rule_v2¥base64://@DrpyHiker@eyJsYXN0X2NoYXB0ZXJfcnVsZSI6IiIsInRpdGxlIjoiRHJweUhpa2VyIiwiYXV0aG9yIjoiQExveURnSWsmemV0YWxwaGEiLCJ1cmwiOiJoaWtlcjovL2VtcHR5IyNmeXBhZ2UiLCJ2ZXJzaW9uIjo0NSwiY29sX3R5cGUiOiJtb3ZpZV8zIiwiY2xhc3NfbmFtZSI6IiIsInR5cGUiOiJ2aWRlbyIsImNsYXNzX3VybCI6IiIsImFyZWFfbmFtZSI6IiIsImFyZWFfdXJsIjoiIiwic29ydF9uYW1lIjoiIiwieWVhcl9uYW1lIjoiIiwic29ydF91cmwiOiIiLCJ5ZWFyX3VybCI6IiIsImZpbmRfcnVsZSI6ImpzOiQucmVxdWlyZShcIk1pYW5Mb2FkXCIpOyIsInNlYXJjaF91cmwiOiJoaWtlcjovL2VtcHR5P3M9KiomcGFnZT1meXBhZ2UiLCJncm91cCI6IuKRoGHkupHnm5giLCJzZWFyY2hGaW5kIjoianM6XG4oZnVuY3Rpb24gKCkge1xuICBsZXQgc21vZGUgPSBOdW1iZXIoZ2V0SXRlbShcInNtb2RlXCIsIFwiMFwiKSk7XG4gIGxldCB0ZW1zbW9kZSA9IGdldE15VmFyKFwidGVtc21vZGVcIiwgXCJcIik7XG4gIGlmICh0ZW1zbW9kZSkge1xuICAgIHNtb2RlID0gTnVtYmVyKHRlbXNtb2RlKTtcbiAgICBjbGVhck15VmFyKFwidGVtc21vZGVcIik7XG4gIH1cbiAgaWYgKCFmaWxlRXhpc3QoXCJoaWtlcjovL2ZpbGVzL2RhdGEvXCIgKyBNWV9SVUxFLnRpdGxlICsgXCIvbGlic19oaWtlci9kcnB5Mi5qc1wiKSkgcmV0dXJuIHNldFJlc3VsdChbe1xuICAgIHRpdGxlOiBcIuivt+WJjeW+gOWwj+eoi+W6j+S4u+mhteiuvue9r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O1xuXG4gICAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XG5cbiAgICAgICAgICAgIGxldCBsaXN0aSA9IGxpc3QuZmluZEluZGV4KHggPT4geC5rZXkgPT0gc291cmNlLmtleSk7XG5cbiAgICAgICAgICAgIGxldCBzZWFyY2hzb3J0ID0gTnVtYmVyKGdldEl0ZW0oXCJzZWFyY2hzb3J0XCIsIFwiMFwiKSk7XG4gICAgICAgICAgICBsZXQge1xuICAgICAgICAgICAgICBuYXR1cmFsU29ydCxcbiAgICAgICAgICAgICAgdXNpbmdTb3J0XG4gICAgICAgICAgICB9ID0gJC5yZXF1aXJlKFwibWV0aG9kc1wiKTtcblxuICAgICAgICAgICAgaWYgKHNlYXJjaHNvcnQgPiAwKSB7XG4gICAgICAgICAgICAgIGlmIChzZWFyY2hzb3J0ID09IDEpIHtcbiAgICAgICAgICAgICAgICBuYXR1cmFsU29ydChsaXN0LCBcIm5hbWVcIik7XG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2VhcmNoc29ydCA9PSAyKSB7XG4gICAgICAgICAgICAgICAgdXNpbmdTb3J0LnNldGtleShcIm5hbWVcIik7XG4gICAgICAgICAgICAgICAgdXNpbmdTb3J0LmdldChsaXN0KVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChzb3VyY2Uuc2VhcmNoYWJsZSAmJiBsaXN0aSAhPSAtMSkge1xuICAgICAgICAgICAgICBsaXN0LnNwbGljZShsaXN0LmluZGV4T2Yoc291cmNlKSwgMSk7XG4gICAgICAgICAgICAgIGxpc3QudW5zaGlmdChzb3VyY2UpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBsZXQgcnVsZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGxpc3QpIHtcbiAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgdGl0bGU6IGl0Lm5hbWUsXG4gICAgICAgICAgICAgICAgc2VhcmNoX3VybDogXCJoaWtlcjovL2VtcHR5P3BhZ2U9ZnlwYWdlJnNlYXJjaFRlcm1zPSoqXCIsXG4gICAgICAgICAgICAgICAgc2VhcmNoRmluZDogXCJqczpcIiArICQudG9TdHJpbmcoKGl0ZW0pID0+IHtcbiAgICAgICAgICAgICAgICAgIGxldCBkcnB5ID0gR00uZGVmaW5lTW9kdWxlKFwiRHJweU1hbmFnZVwiKS5nZXQoaXRlbS5rZXkpO1xuXG4gICAgICAgICAgICAgICAgICBsZXQgaG9tZUxpc3QgPSBKU09OLnBhcnNlKGRycHkuc2VhcmNoKE1ZX0tFWVdPUkQsIGZhbHNlLCBNWV9QQUdFKSkubGlzdCB8fCBbXTtcbiAgICAgICAgICAgICAgICAgIGxldCBkID0gW107XG4gICAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBob21lTGlzdCkge1xuICAgICAgICAgICAgICAgICAgICBkLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICAgIHRpdGxlOiBpdC52b2RfbmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICBkZXNjOiBpdC52b2RfcmVtYXJrcyxcbiAgICAgICAgICAgICAgICAgICAgICBjb250ZW50OiBpdC52b2RfY29udGVudCxcbiAgICAgICAgICAgICAgICAgICAgICB1cmw6IFwiaGlrZXI6Ly9wYWdlL2RldGFpbGVkI2ltbWVyc2l2ZVRoZW1lI1wiLFxuICAgICAgICAgICAgICAgICAgICAgIHBpY191cmw6IGl0LnZvZF9waWMsXG4gICAgICAgICAgICAgICAgICAgICAgY29sX3R5cGU6IFwibW92aWVfM1wiLFxuICAgICAgICAgICAgICAgICAgICAgIGV4dHJhOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2b2RJZDogU3RyaW5nKGl0LnZvZF9pZCksXG4gICAgICAgICAgICAgICAgICAgICAgICBpc1BvbHltZXJpemU6IHRydWUsXG4gICAgICAgICAgICAgICAgIC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IHVybCA9IHVybC5zbGljZSgwLCB1cmwubGFzdEluZGV4T2YoXFxcIj9cXFwiKSk7XFxuICAgICAgfVxcbiAgICAgIGZvciAobGV0IGtleSBpbiBvYmouaGVhZGVycykge1xcbiAgICAgICAgaWYgKHR5cGVvZiBvYmouaGVhZGVyc1trZXldICE9PSBcXFwic3RyaW5nXFxcIikge1xcbiAgICAgICAgICBvYmouaGVhZGVyc1trZXldID0gU3RyaW5nKG9iai5oZWFkZXJzW2tleV0pO1xcbiAgICAgICAgfVxcbiAgICAgIH1cXG4gICAgICBsZXQgciA9IFxcXCJcXFwiO1xcbiAgICAgIGlmIChpc0ZpbGUpIHtcXG4gICAgICAgIHIgPSByZWFkRmlsZVRvU3RyaW5nKHVybC5yZXBsYWNlKFxcXCJmaWxlOi8vXFxcIiwgXFxcIlxcXCIpKTtcXG4gICAgICB9IGVsc2Uge1xcbiAgICAgICAgciA9ICRyZXF1ZXN0KHVybCwgb2JqKTtcXG4gICAgICB9XFxuICAgICAgaWYgKG9iai53aXRoSGVhZGVycykge1xcbiAgICAgICAgciA9IEpTT04ucGFyc2Uocik7XFxuICAgICAgICByZXMuY29udGVudCA9IHIuYm9keTtcXG4gICAgICAgIHJlcy5oZWFkZXJzID0ge307XFxuICAgICAgICBmb3IgKGxldCBbaywgdl0gb2YgT2JqZWN0LmVudHJpZXMoci5oZWFkZXJzIHx8IHt9KSkge1xcbiAgICAgICAgICByZXMuaGVhZGVyc1trXSA9IHZbMF07XFxuICAgICAgICB9XFxuICAgICAgfSBlbHNlIHtcXG4gICAgICAgIHJlcy5jb250ZW50ID0gcjtcXG4gICAgICB9XFxuICAgICAgaWYgKG9iai5idWZmZXIgPT09IDIpIHtcXG4gICAgICAgIHJlcy5jb250ZW50ID0gQ3J5cHRvVXRpbC5EYXRhLnBhcnNlSGV4KHJlcy5jb250ZW50KS50b0Jhc2U2NChfYmFzZTY0Lk5PX1dSQVApO1xcbiAgICAgIH1cXG4gICAgICByZXR1cm4gcmVzO1xc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icj4uKj8+KS4rL2c7XFxuICAgICAgdmFyIGV4cCA9ICflsZXlvIA6JztcXG4gICAgICB2YXIgcmV0ID0gJ+aUtui1tzonO1xcbiAgICAgIGlmIChzaG93ID09ICcxJykge1xcbiAgICAgICAgdXBkYXRlSXRlbSgnZGVzYycsIHtcXG4gICAgICAgICAgdGl0bGU6IHRpdGxlXFxuICAgICAgICAgICAgLnJlcGxhY2UocmV0LCBleHApXFxuICAgICAgICAgICAgLnJlcGxhY2UocmUsICckMScgKyBzZGMgKyAnPC9zbWFsbD4nKVxcbiAgICAgICAgICAgIC5yZXBsYWNlKC8oPFxcXFwvc21hbGw+PGJyPlxcXFw8Zm9udCBjb2xvcj1cXFwiKS4qPyhcXFwiPikvLCAnJDEnICsgY3MuaGlkZSArICckMicpXFxuXFxuICAgICAgICB9KVxcbiAgICAgICAgc3RvcmFnZTAuc2V0SXRlbShtLCAnMCcpO1xcbiAgICAgIH0gZWxzZSB7XFxuICAgICAgICB1cGRhdGVJdGVtKCdkZXNjJywge1xcbiAgICAgICAgICB0aXRsZTogdGl0bGVcXG4gICAgICAgICAgICAucmVwbGFjZShleHAsIHJldClcXG4gICAgICAgICAgICAucmVwbGFjZShyZSwgJyQxJyArIGRjICsgJzwvc21hbGw+JylcXG4gICAgICAgICAgICAucmVwbGFjZSgvKDxcXFxcL3NtYWxsPjxicj5cXFxcPGZvbnQgY29sb3I9XFxcIikuKj8oXFxcIj4pLywgJyQxJyArIGNzLnNob3cgKyAnJDInKVxcbiAgICAgICAgfSlcXG4gICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0obSwgJzEnKTtcXG4gICAgICB9XFxuICAgICAgcmV0dXJuIGBoaWtlcjovL2VtcHR5YFxcbiAgICB9LCBkZXNjLCBzZGVzYywgbWFyaywgY29sb3JzKVxcbiAgICB2YXIgc2MgPSBzdG9yYWdlMC5nZXRJdGVtKG1hcmssICcwJykgPT0gJzAnID8gJ+WxleW8gDonIDogJ+aUtui1tzonO1xcbiAgICB2Y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gKHRjID49IDE1KSB7XFxuICAgICAgICBjb2wgPSBcXFwidGV4dF8yXFxcIjtcXG4gICAgICAgIHRleHRhbGlnbiA9IFxcXCJsZWZ0XFxcIjtcXG4gICAgICB9XFxuICAgICAgbGV0IHBsYXlvYmogPSB0LnNwbGl0KFxcXCIjXFxcIikubWFwKChqLCBpaSkgPT4ge1xcbiAgICAgICAgbGV0IGsgPSBqLnNwbGl0KFxcXCIkXFxcIik7XFxuICAgICAgICBsZXQgdCA9IGtbMF07XFxuICAgICAgICBsZXQgdWlkID0gKGtbMV0gfHwga1swXSk7XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICBzdGl0bGU6IHQsXFxuICAgICAgICAgIHRpdGxlOiBmb250c3R5bGUodCwge1xcbiAgICAgICAgICAgIHRhZ3M6IFxcXCJzbWFsbFxcXCJcXG4gICAgICAgICAgfSksXFxuICAgICAgICAgIHN1cmw6IHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0sXFxuICAgICAgICAgIHVybDogaXNOb3ZlbCA/IFxcXCJoaWtlcjovL3BhZ2Uvbm92ZWwjYXV0b1BhZ2UjI3JlYWRUaGVtZSNcXFwiIDogKHVpZCArIFxcXCIjXFxcIiArIGZyb21baV0gKyBwbGF5TGF6eSksXFxuICAgICAgICAgIGNvbF90eXBlOiBjb2wsXFxuICAgICAgICAgIGltZzogaW1nLFxcbiAgICAgICAgICAvKmV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBleHRyYSwge1xcbiAgICAgICAgICAgIFxcXCJSZWZlcmVyXFxcIjogZGVjb2RlVVJJQ29tcG9uZW50KGtbMV0pLFxcbiAgICAgICAgICAgIGlkOiBrWzFdLFxcbiAgICAgICAgICAgIC8vbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgICAgIHRleHRBbGlnbjogdGV4dGFsaWduLFxcbiAgICAgICAgICAgIGNsczogXFxcInBsYXlsaXN0XFxcIixcXG4gICAgICAgICAgfSkqL1xcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGZyb206IGZyb21baV0sXFxuICAgICAgICAgICAgc291cmNlOiBzb3VyY2UsXFxuICAgICAgICAgICAgaWQ6IHVpZCxcXG4gICAgICAgICAgICBibG9ja1J1bGVzOiBbJ2JiLioucG5nJywgJy5qcGcnLCBcXFwiaG1cXFxcLmJhaWR1XFxcXC5jb21cXFxcL2htLmpzXFxcIl0sXFxuICAgICAgICAgICAgdmlkZW9FeGNsdWRlUnVsZXM6IFsnP3VybD0nXSxcXG4gICAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2UsXFxuICAgICAgICAgICAgdGV4dEFsaWduOiB0ZXh0YWxpZ24sXFxuICAgICAgICAgICAgY2xzOiBcXFwicGxheWxpc3RcXFwiLFxcbiAgICAgICAgICB9XFxuICAgICAgICB9O1xcbiAgICAgIH0pO1xcblxcbiAgICAgIGlmICgoc3R5cGUgPT0gXFxcIua8q+eUu1xcXCIgfHwgc3R5cGUgPT0gXFxcIuWwj+ivtFxcXCIpICYmIGkgPT0gMCkge1xcblxcbiAgICAgICAgdmFyIGRvd25sb2FkbGF6eSA9ICQudG9TdHJpbmcoKGtleSwgc2tleSwgdGl0bGUpID0+IHtcXG4gICAgICAgICAgbGV0IGRycHk7XFxuICAgICAgICAgIGlmICgkLmhpa2VyW1xcXCJfX2RycHlfX1xcXCJdKSB7XFxuICAgICAgICAgICAgZHJweSA9ICQuaGlrZXJbXFxcIl9fZHJweV9fXFxcIl07XFxuXFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICAgIEdNXFxuICAgICAgICAgICAgfSA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NjkxNiZhdXRoPTFkMzVlOGYwLTIyZTgtNTI3MC1hOWQxLTgyNmY1M2YxNzdhZFxcXCIpO1xcbiAgICAgICAgICAgIEdNLnNldFNlbGZLZXkoa2V5KTtcXG4gICAgICAgICAgICBsZXQgRHJweU1hbmFnZSA9IEdNLmRlZmluZU1vZHVsZShcXFwiRHJweU1hbmFnZVxcXCIsIFxcXCJEcnB5TWFuYWdlP3J1bGU9XFxcIiArIHRpdGxlKTtcXG4gICAgICAgICAgICBkcnB5ID0gRHJweU1hbmFnZS5nZXQoc2tleSk7XFxuICAgICAgICAgICAgJC5oaWtlcltcXFwiX19kcnB5X19cXFwiXSA9IGRycHk7XFxuICAgICAgICAgICAgJC5oaWtlcltcXFwiX190ZXN0X19cXFwiXSA9IFtdO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlucHV0ID0gaW5wdXQuc3BsaXQoXFxcIiNcXFwiKTtcXG4gICAgICAgICAgbGV0IHJlc3VsdCA9IEpTT04ucGFyc2UoZHJweS5wbGF5KGlucHV0WzFdLCBpbnB1dFswXSkpO1xcbiAgICAgICAgICBpZiAocmVzdWx0LnVybC5zdGFydHNXaXRoKFxcXCJwaWNzOi8vXFxcIikpIHtcXG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0LnVybDtcXG4gICAgICAgICAgfSBlbHNlIGlmIChyZXN1bHQudXJsLnN0YXJ0c1dpdGgoXFxcIm5vdmVsOi8vXFxcIikpIHtcXG4gICAgICAgICAgICBsZXQgY29udGVudCA9IEpTT04ucGFyc2UocmVzdWx0LnVybC5yZXBsYWNlKFxcXCJub3ZlbDovL1xcXCIsIFxcXCJcXFwiKSkuY29udGVudDtcXG4gICAgICAgICAgICBsZXQgY21kNSA9IG1kNShjb250ZW50KTtcXG4gICAgICAgICAgICBsZXQgaW5kZXggPSAwO1xcbiAgICAgICAgICAgIGlmICgoaW5kZXggPSAkLmhpa2VyW1xcXCJfX3Rlc3RfX1xcXCJdLmluZGV4T2YoY21kNSkpICE9PSAtMSkge1xcbiAgICAgICAgICAgICAgbG9nKFxcXCLph43lpI3vvJpcXFwiICsgaW5wdXQgKyBcXFwiPT5cXFwiICsgaW5kZXgpO1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XFxuICAgICAgICAgICAgaW5mbzoge1xcbiAgICAgICAgICAgICAgYm9va05hbWU6IGluZm8udm9kX25hbWUsIC8v5ryr55S75ZCN56ewLFxcbiAgICAgICAgICAgICAgcnVsZU5hbWU6IE1ZX1JVTEUudGl0bGUsXFxuICAgICAgICAgICAgICBib29rVG9wUGljOiBpbmZvLnZvZF9waWMsXFxuICAgICAgICAgICAgICBwYXJzZUNvZGU6IGRvd25sb2FkbGF6eSxcXG4gICAgICAgICAgICAgIGJvb2tJZDogTVlfUEFSQU1TLnNuYW1lLFxcbiAgICAgICAgICAgICAgdHlwZTogc3R5cGUgPT09IFxcXCLmvKvnlLtcXFwiID8gXFxcImNvbWljXFxcIiA6IFxcXCJub3ZlbFxcXCIsXFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBkZWZhdWx0VmlldzogXFxcIjFcXFwiXFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICAgICAgZC5wdXNoKHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLmnKzlnLDkuabmnrZcXFwiLFxcbiAgICAgICAgICB1cmw6ICdoaWtlcjovL3BhZ2UvQm9va3JhY2sudmlldyNub1JlY29yZEhpc3RvcnkjP3J1bGU95pys5Zyw6LWE5rqQ566h55CGJnJ1bGVOYW1lPScgKyBNWV9SVUxFLnRpdGxlLFxcbiAgICAgICAgICBjb2xfdHlwZTogJ3Njcm9sbF9idXR0b24nLFxcbiAgICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIHR5cGU6IHN0eXBlID09PSBcXFwi5ryr55S7XFxcIiA/IFxcXCJjb21pY1xcXCIgOiBcXFwibm92ZWxcXFwiLFxcbiAgICAgICAgICB9XFxuICAgICAgICB9LCB7XFxuICAgICAgICAgIGNvbF90eXBlOiAnYmxhbmtfYmxvY2snXFxuICAgICAgICB9KTtcXG4gICAgICB9XFxuXFxuICAgICAgcGxheW9iaiA9ICQuc3BsaXRBcnJheUJ5UmFuZ2VzKHBsYXlvYm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291bnQsIHBhZ2VudW0pID0+IHtcXG4gICAgICAgICAgbGV0IGxvY2F0aW9uID0gZ2V0TXlWYXIoaWQgKyBcXFwic291cmNlaVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICAgIGxldCBlZiA9ICQucmVxdWlyZShcXFwibWV0aG9kc1xcXCIpLmdldEVJbmZvKCk7XFxuICAgICAgICAgIGxldCBwY291bnQgPSBlZi5tYXhbbG9jYXRpb25dO1xcbiAgICAgICAgICBsZXQgcGFnZW51bSA9IGVmLnBhZ2VudW07XFxuICAgICAgICAgIGlmIChwY291bnQgPT0gMSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKHBhZ2VudW0gPT0gMCkge1xcbiAgICAgICAgICAgIHBhZ2VudW0gPSBwY291bnQgLSAxO1xcbiAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHBhZ2VudW0tLTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBwdXRNeVZhcihcXFwicGFnZW51bVxcXCIsIFN0cmluZyhwYWdlbnVtKSk7XFxuICAgICAgICAgIEdNLmdldChcXFwicmVub3ZhdGVMaXN0XFxcIiwgKCkgPT4geyB9KShsb2NhdGlvbik7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9LCBpZCwgcGNvdW50LCBTdHJpbmcocGFnZW51bSkpLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgY2xzOiBcXFwicGxheXBhZ2VcXFwiLFxcbiAgICAgICAgICBpZDogXFxcInBsYXlwYWdlQHVwXFxcIlxcbiAgICAgICAgfVxcbiAgICAgIH0sIHtcXG4gICAgICAgIHRpdGxlOiBmb250c3R5bGUocGxheXBbcGFnZW51bV0sIHtcXG4gICAgICAgICAgYzogZmNcXG4gICAgICAgIH0pLFxcbiAgICAgICAgY29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FnZW51bSksXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBjbHM6IFxcXCJwbGF5cGFnZVxcXCIsXFxuICAgICAgICAgIGlkOiBcXFwicGxheXBhZ2VAcGFnZWFyclxcXCIsXFxuICAgICAgICB9XFxuICAgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IGZvbnRzdHlsZSgn5LiL5LiA6aG1Jywge1xcbiAgICAgICAgICBjOiBmY1xcbiAgICAgICAgfSksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfNFxcXCIsXFxuICAgICAgICB1cmw6ICQoXFxcIiNub0xvYWRpbmcjXFxcIikubGF6eVJ1bGUoKGlkKSA9PiB7XFxuICAgICAgICAgIGxldCBsb2NhdGlvbiA9IGdldE15VmFyKGlkICsgXFxcInNvdXJjZWlcXFwiLCBcXFwiMFxcXCIpO1xcbiAgICAgICAgICBsZXQgZWYgPSAkLnJlcXVpcmUoXFxcIm1ldGhvZHNcXFwiKS5nZXRFSW5mbygpO1xcbiAgICAgICAgICBsZXQgcGNvdW50ID0gZWYubWF4W2xvY2F0aW9uXTtcXG4gICAgICAgICAgbGV0IHBhZ2VudW0gPSBlZi5wYWdlbnVtO1xcbiAgICAgICAgICBpZiAocGNvdW50ID09IDEpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICB9XFxuXFxuICAgICAgICAgIGlmIChwYWdlbnVtID49IHBjb3VudCAtIDEpIHtcXG4gICAgICAgICAgICBwYWdlbnVtID0gMDtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBwYWdlbnVtKys7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcHV0TXlWYXIoXFxcInBhZ2VudW1cXFwiLCBTdHJpbmcocGFnZW51bSkpO1xcbiAgICAgICAgICBHTS5nZXQoXFxcInJlbm92YXRlTGlzdFxcXCIsICgpID0+IHsgfSkobG9jYXRpb24pO1xcbiAgICAgICA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UB1cFxcXCIsIHtcXG4gICAgICAgICAgdGl0bGU6IHBhZ2VvYmpbMF0udGl0bGUsXFxuICAgICAgICB9KVxcbiAgICAgICAgdXBkYXRlSXRlbShcXFwicGxheXBhZ2VAcGFnZWFyclxcXCIsIHtcXG4gICAgICAgICAgdGl0bGU6IHBhZ2VvYmpbMV0udGl0bGUsXFxuICAgICAgICB9KVxcbiAgICAgICAgdXBkYXRlSXRlbShcXFwicGxheXBhZ2VAbmV4dFxcXCIsIHtcXG4gICAgICAgICAgdGl0bGU6IHBhZ2VvYmpbMl0udGl0bGUsXFxuICAgICAgICB9KVxcbiAgICAgICAgaWYgKGVyLuWIhumhteWvvOiIqikge1xcbiAgICAgICAgICBsZXQgcG4gPSBmaW5kSXRlbXNCeUNscyhcXFwicGFnZW5hdlxcXCIpXFxuICAgICAgICAgIGlmIChwbi5sZW5ndGggPiBwbGF5cC5sZW5ndGgpIHtcXG4gICAgICAgICAgICBwbiA9IHBuLnNsaWNlKHBsYXlwLmxlbmd0aClcXG4gICAgICAgICAgICBwbi5tYXAoeCA9PiB7XFxuICAgICAgICAgICAgICBkZWxldGVJdGVtKHguZXh0cmEuaWQpXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAocG4ubGVuZ3RoIDwgcGxheXAubGVuZ3RoKSB7XFxuICAgICAgICAgICAgbGV0IHBpZCA9IHBuLmF0KC0xKTtcXG4gICAgICAgICAgICBsZXQgYWRkID0gdHBsYXkuc2xpY2UocG4ubGVuZ3RoKTtcXG4gICAgICAgICAgICBhZGRJdGVtQWZ0ZXIocGlkLmV4dHJhLmlkLCBhZGQpO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHRwbGF5LmZvckVhY2goKHgsIGkpID0+IHtcXG4gICAgICAgICAgICB1cGRhdGVJdGVtKFxcXCJwYWdlbnVtXFxcIiArIGksIHtcXG4gICAgICAgICAgICAgIHRpdGxlOiB4LnRpdGxlLFxcbiAgICAgICAgICAgI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o/lj7dcXFxcbi0x5YWo6YOo77yMLTLlt7LlkK/nlKjnmoTvvIwtM+W3suemgeeUqOeahFxcXCIpLmlucHV0KChsZW5ndGgpID0+IHtcXG4gICAgICAgIGxldCBpbmRleGMgPSBpbnB1dC5zcGxpdCgvLHzvvIwvKTtcXG4gICAgICAgIGxldCBpbmRleHMgPSBbXTtcXG4gICAgICAgIGxldCBtbyA9IHBhcnNlSW50KGluZGV4Y1swXSk7XFxuICAgICAgICBpZiAoIShpbmRleGMubGVuZ3RoICE9PSAwICYmIG1vIDwgMCAmJiBtbyA+IC01KSkge1xcbiAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGluZGV4Yykge1xcbiAgICAgICAgICAgICAgICBsZXQgbnVtID0gcGFyc2VJbnQoaXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzTmFOKG51bSkgfHwgbnVtID49IGxlbmd0aCB8fCBudW0gPCAwKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5pWw5a2X5LiN5ZCI5rOVXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBpbmRleHMucHVzaChudW0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG5cXG4gICAgICAgIHJldHVybiAkKFtcXFwiSElLRVJcXFwiLCBcXFwiVFhUXFxcIl0uY29uY2F0KGdldFBhc3RlcygpKSwgMiwgXFxcIuWIhuS6q+aWueW8j1xcXCIpLnNlbGVjdCgobW8sIGluZGV4cywgZXh0KSA9PiB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gdXAocnVsZXMpIHtcXG4gICAgICAgICAgICAgICAgbGV0IHJ1bGViNjQgPSBiYXNlNjRFbmNvZGUoSlNPTi5zdHJpbmdpZnkocnVsZXMpKTtcXG4gICAgICAgICAgICAgICAgbGV0IGdldFBhc3MgPSAobGVuZ3RoLCBydWxlLCB0eXBlKSA9PiBcXFwi5rW36ZiU6KeG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7XFxuICAgICAgICAgICAgICAgIGZsYWdpID0gW2ZdXFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgZmxhZ2kgPSBmbGFnaS5maWx0ZXIoeCA9PiAhLyjlhajpg6h85bey56aB55SoKS8udGVzdCh4KSk7XFxuICAgICAgICAgICAgICAgIGlmIChmbGFnaS5pbmNsdWRlcyhmKSkge1xcbiAgICAgICAgICAgICAgICAgICAgZmxhZ2kgPSBmbGFnaS5maWx0ZXIoeCA9PiB4ICE9IGYpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZsYWdpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ2kgPSBbXFxcIuWFqOmDqFxcXCJdXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBmbGFnaS5wdXNoKGYpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImZsYWdpXFxcIiwgZmxhZ2kpO1xcbiAgICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL2VtcHR5XFxcIjtcXG4gICAgICAgIH0sIGYpXFxuICAgIH0pXFxufSlcXG5mb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XFxuICAgIGxldCBpdCA9IGFycltpXTtcXG5cXG4gICAgbGV0IGZsYWcgPSBpdC5mbGFnLnNwbGl0KFxcXCJ8XFxcIik7XFxuICAgIGlmIChmbGFnaS5sZW5ndGggPiAwICYmICFbXFxcIuWFqOmDqFxcXCIsIFxcXCLlt7LnpoHnlKhcXFwiXS5pbmNsdWRlcyhmbGFnaVswXSkpIHtcXG4gICAgICAgIGlmICghZmxhZ2kuZXZlcnkoZiA9PiBmbGFnLmluY2x1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ICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB1ID0gc2hhcmVQYXN0ZShydWxlYjY0LCBpbnB1dCk7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJjb3B5Oi8vXFxcIiArIGdldFBhc3MocnVsZS5uYW1lLCB1LCBcXFwiYlxcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9LCBpbmRleCk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuenu+WKqFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoaW5kZXggKyBcXFwiXFxcIiwgXFxcIui+k+WFpeS9jee9rlxcXCIpLmlucHV0KChpbmRleCwgbGVuZ3RoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSBOdW1iZXIoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihuZXdJbmRleCkgfHwgbmV3SW5kZXggPj0gbGVuZ3RoKSB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+S4jeWSjOinhOeahOS9jee9rlxcXCI7XFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICBydWxlcy5zcGxpY2UobmV3SW5kZXgsIDAsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICAgICAgcmVmcmVzaFBhZ2UoZmFsc2UpO1xcbiAgICAgICAgICAgICAgICB9LCBpbmRleCwgbGVuZ3RoKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09PSBcXFwi572u6aG2XFxcIikge1xcbiAgICAgICAgICAgICAgICBsZXQgbmV3SW5kZXggPSAwO1xcbiAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gcnVsZXMuc3BsaWNlKGluZGV4LCAxKVswXTtcXG4gICAgICAgICAgICAgICAgcnVsZXMuc3BsaWNlKG5ld0luZGV4LCAwLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuc2F2ZUpzb24ocnVsZXMpO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgfSBlbHNlIGlmIChpbnB1dCA9PT0gXFxcIuWIoOmZpFxcXCIpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIuehruiupOWIoOmZpO+8n1xcXCIpLmNvbmZpcm0oKGluZGV4KSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZXMgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgICAgICBsZXQgcnVsZSA9IHJ1bGVzLnNwbGljZShpbmRleCwgMSlbMF07XFxuICAgICAgICAgICAgICAgICAgICAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5zYXZlSnNvbihydWxlcyk7XFxuICAgICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZShmYWxzZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey5Yig6ZmkXFxcIiArIHJ1bGUubmFtZTtcXG4gICAgICAgICAgICAgICAgfSwgaW5kZXgpO1xcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGxldCBhcnIgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3NcXFwiKS5nZXRKc29uKCk7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlID0gYXJyW2luZGV4XTtcXG4gICAgICAgICAgICAgICAgcnVsZS5mb3JiaWRkZW4gPSAhcnVsZS5mb3JiaWRkZW47XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIHJlZnJlc2hQYWdlKGZhbHNlKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8vXFxcIiArIChydWxlLmZvcmJpZGRlbiA/IFxcXCLnpoHnlKhcXFwiIDogXFxcIuWQr+eUqFxcXCIpICsgcnVsZS5uYW1lO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sIGksIGxlbmd0aCksXFxuICAgICAgICBjb2xfdHlwZTogXFxcInRleHRfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICAgIGk6IGksXFxuICAgICAgICAgICAgcGFnZVRpdGxlOiBpdC5uYW1lXFxuICAgICAgICB9XFxuICAgIH0pO1xcbn1cXG5cXG5jb3VudFRpdGxlLnRpdGxlID0gJzxmb250IGNvbG9yPVxcXCIjMTNCNjFCXFxcIj7ilpAgPC9mb250PjxiPuino+aekOWIl+ihqDxiPiAoJyArICgoaXRzLmxlbmd0aCAtIGNvdW50KSArIFxcXCIvXFxcIiArIGxlbmd0aCkuZm9udGNvbG9yKFxcXCIjZmY2NjAxXFxcIikgKyBcXFwiKVxcXCI7XFxuXFxuZCA9IGQuY29uY2F0KGl0cyk7XFxuXFxuc2V0UmVzdWx0KGQpO1wifSx7XCJjb2xfdHlwZVwiOlwibW92aWVfM1wiLFwibmFtZVwiOlwi6Kej5p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XCIpLmxhenlSdWxlKChpbmRleCwgdXJsSW5kZXgpID0+IHtcXG4gICAgICAgIGlmIChpbmRleCA9PT0gdm9pZCgwKSkge1xcbiAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/mraTpobnml6Dms5XliKDpmaRcXFwiO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKHVybEluZGV4ICE9PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+ato+WcqOabtOaWsOino+aekO+8jOWIoOmZpOivt+S7juino+aekOeuoeeQhui/m+WFpVxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBjb25maXJtKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIua4qemmqOaPkOekulxcXCIsXFxuICAgICAgICAgICAgY29udGVudDogXFxcIuehruWumuimgeWIoOmZpOatpOino+aekOWQl++8n+azqOaEj+WIoOmZpOWQjuaXoOazleaBouWkjVxcXCIsXFxuICAgICAgICAgICAgY29uZmlybTogJC50b1N0cmluZygoaW5kZXgpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGFyciA9ICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLmdldEpzb24oKTtcXG4gICAgICAgICAgICAgICAgYXJyLnNwbGljZShpbmRleCwgMSk7XFxuICAgICAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlnc1xcXCIpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgICAgIGJhY2sodHJ1ZSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/liKDpmaTmiJDlip9cXFwiO1xcbiAgICAgICAgICAgIH0sIGluZGV4KVxcbiAgICAgICAgfSk7XFxuICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiXFxuICAgIH0sIGluZGV4LCB1cmxJbmRleCksXFxuICAgIGNvbF90eXBlOiBcXFwidGV4dF8zXFxcIixcXG59KTtcXG5cXG5kLnB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AgICAgICAgaWYgKGhlYWRlcnMpIHtcXG4gICAgICAgICAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICAgICAgICAgIGhlYWRlcnMgPSBKU09OLnBhcnNlKGhlYWRlcnMpO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhlYWRlcnPmoLzlvI/plJnor686XFxcIiArIGUudG9TdHJpbmcoKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gJC5yZXF1aXJlKFxcXCJ2aWRlb1VybFxcXCIpLnByZXBhcmVQYXJzZXMoW3tcXG4gICAgICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICAgICAgdXJsLFxcbiAgICAgICAgICAgICAgICBmbGFnLFxcbiAgICAgICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgICAgICBydW5UeXBlLFxcbiAgICAgICAgICAgICAgICBtZXRob2QsXFxuICAgICAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgICAgICBqc1xcbiAgICAgICAgICAgIH1dLCBpbnB1dCxudWxsLCB0cnVlKTtcXG4gICAgICAgIH0pO1xcbiAgICB9KSxcXG4gICAgY29sX3R5cGU6IFxcXCJ0ZXh0XzNcXFwiLFxcbn0pO1xcblxcbmQucHVzaCh7XFxuICAgIHRpdGxlOiBcXFwi5L+d5a2YXFxcIixcXG4gICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChpbmRleCwgaXNJbXBvcnQpID0+IHtcXG4gICAgICAgIGxldCBuYW1lID0gZ2V0TXlWYXIoXFxcInBzX25hbWVcXFwiLCBcXFwiXFxcIikudHJpbSgpO1xcbiAgICAgICAgaWYgKCFuYW1lKSB7XFxuICAgICAgICAgICAgcmV0dXJuIFxcXCJ0b2FzdDovL+WQjeWtl+W+l+acieS4gOS4quWQp1xc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HNfbWV0aG9kXFxcIiwgXFxcIkdFVFxcXCIpO1xcbiAgICAgICAgbGV0IGpzb25QYXRoID0gZ2V0TXlWYXIoXFxcInBzX2pzb25QYXRoXFxcIiwgXFxcIlxcXCIpLnRyaW0oKSB8fCB2b2lkIDA7XFxuICAgICAgICBsZXQganMgPSBnZXRNeVZhcihcXFwicHNfanNcXFwiLCBcXFwiXFxcIikgfHwgdm9pZCAwO1xcbiAgICAgICAgaWYgKHJ1blR5cGUgPT09IFxcXCJKU09OXFxcIiAmJiAhanNvblBhdGgpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlNPTuaooeW8j+S4i+W/hemhu+Whq2pzb25QYXRoXFxcIjtcXG4gICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PT0gXFxcIkpTXFxcIiAmJiAhanMpIHtcXG4gICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8vSlPmqKHlvI/kuIvlv4Xpobvloatqc1xcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzXFxcIikuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG9iajEgPSB7XFxuICAgICAgICAgICAgbmFtZSxcXG4gICAgICAgICAgICB1cmwsXFxuICAgICAgICAgICAgZmxhZyxcXG4gICAgICAgICAgICBoZWFkZXJzLFxcbiAgICAgICAgICAgIHJ1blR5cGUsXFxuICAgICAgICAgICAgbWV0aG9kLFxcbiAgICAgICAgICAgIGpzb25QYXRoLFxcbiAgICAgICAgICAgIGpzXFxuICAgICAgICB9O1xcbiAgICAgICAgaWYgKGluZGV4ID09PSB2b2lkKDApKSB7XFxuICAgICAgICAgICAgaWYgKGFyci5zb21lKHYgPT4gdi5uYW1lID09PSBuYW1lKSkge1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKG9iajEuZ3JvdXApIHtcXG4gICAgICAgICAgICAgICAgbGV0IGdyb3VwID0gb2JqMS5ncm91cDtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gYXJyLmZpbmRJbmRleCh2ID0+IHYuZ3JvdXAgPT09IGdyb3VwKTtcXG4gICAgICAgICAgICAgICAgaWYgKGluZGV4ID09PSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnVuc2hpZnQob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAwLCBvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIGlmIChpc0ltcG9ydCkge1xcbiAgICAgICAgICAgICAgICAgICAgYXJyLnB1c2gob2JqMSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBhcnIudW5zaGlmdChvYmoxKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgbGV0IG5hbWV5ID0gYXJyW2luZGV4XS5uYW1lO1xcbiAgICAgICAgICAgIGlmIChuYW1lICE9PSBuYW1leSkge1xcbiAgICAgICAgICAgICAgICBpZiAoYXJyLnNvbWUodiA9PiB2Lm5hbWUgPT09IG5hbWUpKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v5bey57uP5a2Y5Zyo6K+l6Kej5p6QXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBvYmoxID0gT2JqZWN0LmFzc2lnbihhcnJbaW5kZXhdLCBvYmoxKTtcXG4gICAgICAgICAgICBhcnIuc3BsaWNlKGluZGV4LCAxLCBv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AgICAgICAgbGV0IHJ1bGVUaXRsZSA9IGdldFBhcmFtKFxcXCJydWxlXFxcIik7XFxuICAgICAgICBsZXQgYXJyID0gJC5yZXF1aXJlKFxcXCJjb25maWdzP3J1bGU9XFxcIiArIHJ1bGVUaXRsZSkuZ2V0SnNvbigpO1xcbiAgICAgICAgbGV0IG5ld0kgPSAwO1xcbiAgICAgICAgZm9yIChsZXQgcnVsZSBvZiBydWxlcykge1xcbiAgICAgICAgICAgIGxldCBpbmRleCA9IGFyci5maW5kSW5kZXgodiA9PiB2Lm5hbWUgPT09IHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgaWYgKGluZGV4ID4gLTEpIHtcXG4gICAgICAgICAgICAgICAgcnVsZSA9IE9iamVjdC5hc3NpZ24oYXJyW2luZGV4XSwgcnVsZSk7XFxuICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaW5kZXgsIDEsIHJ1bGUpO1xcbiAgICAgICAgICAgICAgICBpZiAocnVsZXMubGVuZ3RoID09PSAxKSB7XFxuICAgICAgICAgICAgICAgICAgICBzYXZlQ2FjaGUocnVsZSk7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vcGFnZS9ydWxlRWRpdCNub0hpc3RvcnkjI25vUmVjb3JkSGlzdG9yeSM/aXNJbXBvcnQ9dHJ1ZSZpbmRleD1cXFwiICsgaW5kZXggKyBcXFwiJnJ1bGU9XFxcIiArIHJ1bGVUaXRsZTtcXG4gICAgICAgICAgICAgICAgICAgIC8vdG9hc3QoXFxcIuW3suabtOaWsOinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgbG9nKFxcXCLlt7Lmm7TmlrDop4TliJnvvJpcXFwiICsgcnVsZS5uYW1lKVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgbmV3SSsrO1xcbiAgICAgICAgICAgICAgICBhcnIucHVzaChydWxlKTtcXG4gICAgICAgICAgICAgICAgaWYgKHJ1bGVzLmxlbmd0aCA9PT0gMSkge1xcbiAgICAgICAgICAgICAgICAgICAgc2F2ZUNhY2hlKHJ1bGUpO1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFxcXCJoaWtlcjovL3BhZ2UvcnVsZUVkaXQjbm9IaXN0b3J5IyNub1JlY29yZEhpc3RvcnkjP2lzSW1wb3J0PXRydWUmcnVsZT1cXFwiICsgcnVsZVRpdGxlO1xcbiAgICAgICAgICAgICAgICAgICAgLy90b2FzdChcXFwi5bey5a+85YWl6KeE5YiZ77yaXFxcIiArIHJ1bGUubmFtZSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBsb2coXFxcIuW3suWvvOWFpeinhOWIme+8mlxcXCIgKyBydWxlLm5hbWUpXFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpZiAocnVsZXMubGVuZ3RoID4gMSkge1xcbiAgICAgICAgICAgICQucmVxdWlyZShcXFwiY29uZmlncz9ydWxlPVxcXCIgKyBydWxlVGl0bGUpLnNhdmVKc29uKGFycik7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIuaWsOWinu+8mlxcXCIgKyBuZXdJICsgXFxcIiDopobnm5bmm7TmlrDvvJpcXFwiICsgKHJ1bGVzLmxlbmd0aCAtIG5ld0kpKTtcXG4gICAgICAgIH1cXG4gICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB0b2FzdChcXFwi5a+85YWl5aSx6LSlXFxcIik7XFxuICAgIH1cXG59XFxuXFxuZnVuY3Rpb24gaW1wb3J0UnVsZShwYXNzKSB7XFxuICAgIHRyeSB7XFxuICAgICAgICBsZXQgW18sIHJ1bGUsIHBuYW1lXSA9IHBhc3Muc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ghcnVsZSB8fCAhcnVsZS5pbmNsdWRlcyhcXFwicnVsZVxcXCIpKSAmJiAhZmlsZUV4aXN0KHBhdGggKyBpdC5uYW1lKSkpIHtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBpdC5uYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgcnVsZXMucHVzaCh7XFxuICAgICAgICAgICAgICAgICAgICAna2V5JzogYGhpcHlfanNfJHtuYW1lfWAsXFxuICAgICAgICAgICAgICAgICAgICAnbmFtZSc6IGAke25hbWV9YCxcXG4gICAgICAgICAgICAgICAgICAgICd0eXBlJzogMyxcXG4gICAgICAgICAgICAgICAgICAgICdhcGknOiAnLi4vbGlicy9kcnB5Mi5qcycsXFxuICAgICAgICAgICAgICAgICAgICAnc2VhcmNoYWJsZSc6IDEsXFxuICAgICAgICAgICAgICAgICAgICAncXVpY2tTZWFyY2gnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2ZpbHRlcmFibGUnOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgJ2V4dCc6IFxcXCIuL1xcXCIgKyBpdC5uYW1lLFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgXFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XFxuICAgICAgICBuYW1lcy5wdXNoKGl0Lm5hbWUpO1xcbiAgICB9XFxuICAgIGRlbGV0ZWxvc2UobmFtZXMsIHBhdGgpXFxuICAgIHdyaXRlRmlsZShwYXRoICsgXFxcImluZGV4Lmpzb25cXFwiLCBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICBzaXRlczogcnVsZXNcXG4gICAgfSkpO1xcblxcbiAgICByZXR1cm4gXFxcInRvYXN0Oi8v5oiQ5Yqf5pu05pawXFxcIiArIGNvdW50ICsgXFxcI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uaW5jbHVkZXMoXFxcImRycHkyLmpzXFxcIikpKSB7XFxuICAgICAgICAgICAgICAgIGxldCBuYW1lID0gaXQuZXh0LmVuZHNXaXRoKFxcXCIuanNcXFwiKSA/IGRlY29kZVVSSUNvbXBvbmVudChpdC5leHQuc3BsaXQoXFxcIi9cXFwiKS5hdCgtMSkpIDogKGl0Lm5hbWUgKyBcXFwiLmpzXFxcIik7XFxuICAgICAgICAgICAgICAgIGxldCBydWxlO1xcbiAgICAgICAgICAgICAgICBpZiAoU3RyaW5nKGl0LmV4dCkuc3RhcnRzV2l0aChcXFwiaHR0cFxcXCIpKSB7XFxuICAgICAgICAgICAgICAgICAgICBydWxlID0gcmVxdWVzdChpdC5leHQpO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcnVsZSA9IHJlcXVlc3Qoam9pblVybCh1cmwsIGl0LmV4dCkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGl0LmV4dCA9IFxcXCIuL1xcXCIgKyBuYW1lO1xcbiAgICAgICAgICAgICAgICBpZiAoIXJ1bGUgfHwgIXJ1bGUuaW5jbHVkZXMoXFxcInJ1bGVcXFwiKSkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWxlRXhpc3QocGF0aCArIG5hbWUpKVxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFyci5zcGxpY2UoaSwgMSk7XFxuICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICAgICAgd3JpdGVGaWxlKHBhdGggKyBuYW1lLCBydWxlKTtcXG4gICAgICAgICAgICAgICAgbmFtZXMucHVzaChuYW1lKTtcXG4gICAgICAgICAgICAgICAgY291bnQrKztcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICB9XF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YXRoKTtcXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXCJpbmRleGpzXFxcIjtcXG4gICAgICAgICAgICAvL3NvdXJjZUxpc3Q9W107XFxuICAgICAgICB9IGVsc2UgaWYgKGNvbmZpZy5wYXRoLnN0YXJ0c1dpdGgoXFxcImh0dHBzOi8vZ2l0aHViLmNvbVxcXCIpKSB7XFxuICAgICAgICAgICAgc291cmNlTGlzdCA9IGdlbmVyYXRlQ29uZmlnQnlHaXRodWIoY29uZmlnLnBhdGgpO1xcbiAgICAgICAgICAgIGNvbmZpZy50eXBlID0gXFxcImdpdGh1YkRpclxcXCI7XFxuICAgICAgICAgICAgLy9zb3VyY2VMaXN0PVtdO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQganNvbiA9IEpTT04ucGFyc2UodG9Db3JyZWN0SlNPTlN0cmluZyhmZXRjaChjb25maWcucGF0aCkgfHwgXFxcInt9XFxcIikpO1xcbiAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCAhanNvbi5zaXRlcy5sZW5ndGgpIHtcXG4gICAgICAgICAgICAgIGlmKGpzb24uaGFzT3duUHJvcGVydHkoXFxcInNpdGVzXFxcIikmJmpzb24uc2l0ZXMuaGFzT3duUHJvcGVydHkoXFxcImRhdGFcXFwiKSl7XFxuICAgICAgICAgICAgICAgIGpzb24uc2l0ZXM9anNvbi5zaXRlcy5kYXRhO1xcbiAgICAgICAgICAgICAgfWVsc2V7XFxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcXFwi5LuO572R57uc6I635Y+W55qE6YWN572u5paH5Lu25Li656m677yM6K+35qOA5p+l572R57ucXFxcIik7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIHNvdXJjZUxpc3QgPSBmaWx0ZXJPdGhlcihqc29uLnNpdGVzKTtcXG4gICAgICAgICAgICBjb25maWcudHlwZSA9IFxcXCJpbmRleFxcXCI7XFxuICAgICAgICB9XFxuICAgICAgICBmaWxlID0gdm9pZCAwO1xcbiAgICAgICAgbGV0IGN1cnJlbnRTb3VyY2UsIHNlYXJjaEFsbG93O1xcbiAgICAgICAgaWYgKGNvbmZpZy5jS2V5KSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3QuZmluZCh2ID0+IHYua2V5ID09PSBjb25maWcuY0tleSk7XFxuICAgICAgICAgICAgaWYgKCFjdXJyZW50U291cmNlKSB7XFxuICAgICAgICAgICAgICAgIGN1cnJlbnRTb3VyY2UgPSBzb3VyY2VMaXN0WzBdO1xcbiAgICAgICAgICAgICAgICAvL2N1cnJlbnRDb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSA9IHNvdXJjZUxpc3RbMF07XFxuICAgICAgICAgICAgLy9jb25maWcuY0tleSA9IHNvdXJjZUxpc3RbMF0ua2V5O1xcbiAgICAgICAgfVxcbiAgICAgICAgdHJ5IHtcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyA9IEpTT04ucGFyc2UoZmV0Y2goc2VhcmNoQWxsb3dQYXRoKSB8fCBcXFwiW11cXFwiKTtcXG4gICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICBkZWxldGVGaWxlKHNlYXJjaEFsbG93UGF0aCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cgPSBbXTtcXG4gICAgICAgIH1cXG4gICAgICAgIGxvYWRFcnJvciA9IHZvaWQgMDtcXG4gICAgICAgIHJldHVybiB7XFxuICAgICAgICAgICAgY3VycmVudFNvdXJjZSxcXG4gICAgICAgICAgICBzZWFyY2hBbGxvdyxcXG4gICAgICAgICAgICBzb3VyY2VMaXN0XFxuICAgICAgICB9O1xcbiAgICB9IGNhdGNoIChlKSB7XFxuICAgIC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IG1hcHBpbmcpIHtcXG4gICAgICAgICAgICAgICAgbGV0IGluZGV4ID0gcnVsZXMuZmluZEluZGV4KHYgPT4gdi5uYW1lID09PSBpdC5rZXkpO1xcbiAgICAgICAgICAgICAgICBpZiAoaW5kZXggPT09IC0xKSBjb250aW51ZTtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW0gPSBydWxlc1tpbmRleF07XFxuICAgICAgICAgICAgICAgIHJ1bGVzLnNwbGljZShpbmRleCwgMCwgT2JqZWN0LmFzc2lnbih7fSwgaXRlbSwge1xcbiAgICAgICAgICAgICAgICAgICAgJ2tleSc6IGBoaXB5X2pzXyR7aXQudG9rZXl9YCxcXG4gICAgICAgICAgICAgICAgICAgICduYW1lJzogYCR7aXQudG9rZXl9YCxcXG4gICAgICAgICAgICAgICAgICAgICdleHQnOiBpdGVtLmV4dCArIFxcXCI/XFxcIiArIGl0LnBhcmFtcyxcXG4gICAgICAgICAgICAgICAgICAgIGRlbDogdm9pZCAwXFxuICAgICAgICAgICAgICAgIH0pKTtcXG4gICAgICAgICAgICAgICAgaXRlbS5kZWwgPSB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBydWxlcyA9IHJ1bGVzLmZpbHRlcih2ID0+ICF2LmRlbCk7XFxuICAgICAgICB9XFxuICAgIH0gY2F0Y2ggKGUpIHtcXG5cXG4gICAgfVxcbiAgICByZXR1cm4gcnVsZXM7XFxufVxcblxcbmZ1bmN0aW9uIGdldExvYWNsTWFwcGluZyhkaXJGaWxlKSB7XFxuICAgIC8va2V5QHBhcmFtc0B0eXBlXFxuICAgIGxldCBtYXBwaW5nUGF0aCA9IFxcXCJmaWxlOi8vXFxcIiArIGpvaW5VcmwoZGlyRmlsZSwgXFxcIi4vXFxcIikgKyBcXFwiLy5tYXBwaW5nLnR4dFxcXCI7XFxuICAgIGxldCBtYXBwaW5nID0gW107XFxuICAgIGlmICghZmlsZUV4aXN0KG1hcHBpbmdQYXRoKSkgcmV0dXJuIG1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kgJiYgZmlsZS5pc0RpcmVjdG9yeSgpKSkgcmV0dXJuIG5hbWVzO1xcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpdCBvZiBmaWxlLmxpc3RGaWxlcygpKSB7XFxuICAgICAgICAgICAgICAgICAgICBuYW1lcy5wdXNoKFN0cmluZyhpdC5nZXROYW1lKCkpKTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgfSxcXG4gICAgICAgICAgICBkaXJuYW1lKHBhKSB7XFxuICAgICAgICAgICAgICAgIGxldCBwYXRoID0gam9pblVybChqc1BhdGgsIHBhKTtcXG4gICAgICAgICAgICAgICAgbGV0IG5hbWVzID0gW107XFxuICAgICAgICAgICAgICAgIGxldCBmaWxlID0gbmV3IGphdmEuaW8uRmlsZShwYXRoKTtcXG5cXG4gICAgICAgICAgICAgICAgaWYgKCEoZmlsZS5leGlzdHMoKSAmJiBmaWxlLmlzRGlyZWN0b3J5KCkpKSByZXR1cm4gbmFtZXM7XFxuICAgICAgICAgICAgICAgIGZvciAobGV0IGl0IG9mIGRpckZpbGUubGlzdEZpbGVzKCkpIHtcXG4gICAgICAgICAgICAgICAgICAgIGlmIChpdC5pc0RpcmVjdG9yeSkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWVzLnB1c2goU3RyaW5nKGl0LmdldE5hbWUoKSkpO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIHJldHVybiBwYXRocztcXG4gICAgICAgICAgICB9LFxcbiAgICAgICAgICAgIHN0YXQoKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH0sXFxuICAgICAgICBsb2c6IGxvZyxcXG4gICAgICAgIHBhdGg6IGpzUGF0aCxcXG4gICAgICAgIHBhdGhfZGlyOiBqb2luVXJsKGpzUGF0a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XFxuICAgICAgb3B0aW9uczogW1xcbiAgICAgICAgXFxcIuesrOS4gOepuijlkI3np7ApOuaWueS+v+S4i+asoeaJvuWIsFxcXCIsXFxuICAgICAgICBcXFwi56ys5LqM56m6KOi3r+W+hClb5aGr5pys5Zyw57Si5byV5Zyw5Z2AXTrpgInmi6lKU09OL1VSTOmAiemhue+8jOeCueWHu+aXgei+ueeahOmAieaLqeWPr+S7pea1j+iniOacrOWcsOaWh+S7tumAieaLqeacrOWcsOWMheeahC5qc29u57Si5byV5paH5Lu25Y2z5Y+v44CCXFxcXG4o5rOo5oSP77ya5L2/55So5q2k56eN5pa55byP77yM5Zyo5pys5Zyw5paH5Lu25aS55YaF5paw5aKe5oiW5Yig6ZmkLmpz5rqQ5pe26ZyA6KaB6Ieq6KGM6YWN572uLmpzb27mlofku7YpXFxcIixcXG4gICAgICAgIFxcXCLnrKzkuoznqboo6Lev5b6EKVvloavmnKzloavov5znqIvlnLDlnYBdOuebtOaOpeWhq+WGmei/nOeoi+mTvuaOpeWNs+WPr+S4gOiIrOaYr+S7pWh0dHDlvIDlpLQuanNvbue7k+Wwvu+8jOS5n+WPr+WPr+S7pei+k+WFpWdpdGh1YuS7k+W6k+eahOaWh+S7tuWkueWcsOWdgOOAguatpOenjeaWueW8j+WPr+S7peS/neaMgeS4jui/nOeoi+mFjee9ruiAheWQjOatpeabtOaWsO+8jOS9huS4jeWmguacrOWcsOW/q+OAglxcXCIsXFxuICAgICAgICBcXFwi56ys5LqM56m6KOi3r+W+hClb5aGr5pys5Zyw5paH5Lu25aS55Zyw5Z2AXTrpgInmi6nmlofku7blpLnpgInpobnvvIzlj6/ku6Xnm7TmjqXovpPlhaVqc+a6kOaJgOWcqCPmlofku7blpLkhISEj55qE6Lev5b6E77yM5Lmf5Y+v5Lul54K55Ye75peB6L656YCJ5oup5rWP6KeI5pys5Zyw6Lev5b6E6YCJ5oupI+aWh+S7tuWkuSEhISPvvIzkvb/nlKjor6Xnp43mlrnms5XvvIzlnKjmlofku7blpLnmlrDlop7miJbliKDpmaTmupDml7bvvIzkuI3nlKjmiYvliqjphY3nva4uanNvbuaWh+S7tu+8jOiHquWKqOivu+WPluOAgijms6jmhI/vvJrpnIDopoHliLfmlrDphY3nva7miJbph43lkK/ova/ku7bmiY3og73or7vlj5YpXFxcIixcXG4gICAgICAgIFxcXCJbUSZBXeS4uuS7gOS5iOiuoumYhemTvuaOpeacieW+iOWkmua6kO+8jOWNtOWPquivhuWIq+WIsOS6huWHoOS4qua6kO+8n1xcXFxu5pys5bCP56iL5bqP5Y+q5pSv5oyB6YGT6ZW/55qEZHJweVtqc13op4bpopHmupDvvIzlhbbku5bkuIDmpoLkuI3mlK/mjIHjgILlm6DmraTkvJroh6rliqjov4fmu6Tlhbbku5bmupBcXFwiLFxcbiAgICAgICAgXFxcIltRJkFd5omT566X5pSv5oyB5YW25LuWdHZib3jnmoTmupDlkJfvvJ/kuI3mlK/mjIHkuI3ogIPomZHjgILor7fnnIvlkI3lrZdEcnB5SGlrZXLvvIzlj6rmlK/mjIFkcnB577yM6KaB55So5YW25LuW5rqQ77yM5bu66K6u5Yig6Zmk5pys5bCP56iL5bqP77yM5Y6755So5ZCE56eN5aOz5a2Q44CCXFxcIlxcbiAgICAgIF1cXG4gICAgfSk7XFxuICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICB9KSxcXG59KTtcXG5sYXlvdXQucHVzaCh7XFxuICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gIGRlc2M6IFxcXCLlkI3np7Ao5b+F5aGrKVxcXCIsXFxuICBleHRyYToge1xcbiAgICB0aXRsZVZpc2libGU6IGZhbHNlLFxcbiAgICBkZWZhdWx0VmFsdWU6IGdldE15VmFyKFxcXCJkcnB5SGlrZXJfY29uZmlnX25hbWVcXFwiLCBcXFwiXFxcIiksXFxuICAgIG9uQ2hhbmdlOiAkLnRvU3RyaW5nKCgpID0+IHtcXG4gICAgICBwdXRNeVZhcihcXFwiZHJ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ICAgICAgICAgIC8vIOajgOafpeaWh+S7tuWQjeaYr+WQpuS7pS5qc+e7k+WwvlxcbiAgICAgICAgICAgICAgaWYgKGYuaXNGaWxlKCkgJiYgZi5nZXROYW1lKCkudG9Mb3dlckNhc2UoKS5lbmRzV2l0aChcXFwiLmpzXFxcIikpIHtcXG4gICAgICAgICAgICAgICAganNGaWxlcy5wdXNoKGYpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoZGlyLmlzRmlsZSgpICYmIGZpbGVFeGlzdChvYmoudXJsKSkge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICBqc29uID0gSlNPTi5wYXJzZShyZWFkRmlsZShvYmoudXJsKSk7XFxuICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShqc29uLnNpdGVzKSB8fCBqc29uLnNpdGVzLmxlbmd0aCkge1xcbiAgICAgICAgICAgICAgICBjb3VudCA9IGZpbHRlck90aGVyKGpzb24uc2l0ZXMpLmxlbmd0aDtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGNhdGNoIChlKSB7IH1cXG4gICAgICAgICAgICBjb2RlID0gXFxcIm9rXFxcIjtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICBpZiAoanNGaWxlcy5sZW5ndGggPj0gNSkge1xcbiAgICAgICAgICAgIGNvdW50ID0ganNGaWxlcy5sZW5ndGg7XFxuICAgICAgICAgICAgY29kZSA9IFxcXCJva1xcXCI7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgICB0aW1lOiAoRGF0ZS5ub3coKSAtIHMpLFxcbiAgICAgICAgICAgIHVybDogb2JqLnVybCxcXG4gICAgICAgICAgICBjb3VudDogY291bnQsXFxuICAgICAgICAgICAgY29kZTogY29kZSxcXG4gICAgICAgICAgICBpbmRleDogb2JqLmlcXG4gICAgICAgICAgfVxcbi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IHJldHVybiB7XFxuICAgICAgICAgIHRpbWU6IGMsXFxuICAgICAgICAgIHVybDogai51cmwsXFxuICAgICAgICAgIGNvdW50OiBjb3VudCxcXG4gICAgICAgICAgY29kZTogai5zdGF0dXNDb2RlLFxcbiAgICAgICAgICBpbmRleDogb2JqLmksXFxuICAgICAgICB9XFxuICAgICAgfTtcXG4gICAgICBsZXQgdGFza3MgPSBsaXN0Lm1hcCgoeCwgaSkgPT4ge1xcbiAgICAgICAgaSA9IGkgKyAxO1xcbiAgICAgICAgcmV0dXJuIHtcXG4gICAgICAgICAgZnVuYzogdGFzayxcXG4gICAgICAgICAgcGFyYW06IHtcXG4gICAgICAgICAgICB1cmw6IHgsXFxuICAgICAgICAgICAgaTogaSAtIDEsXFxuICAgICAgICAgIH0sXFxuICAgICAgICAgIGlkOiAndGFza2lkJyArIGlcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgICB2YXIgY291bnQgPSBzdWNjZXNzID0gdGFza3MubGVuZ3RoO1xcbiAgICAgIGJlKHRhc2tzLCB7XFxuICAgICAgICBmdW5jOiBmdW5jdGlvbiAob2JqLCBpZCwgZXJyb3IsIHRhc2tSZXN1bHQpIHtcXG4gICAgICAgICAgb2JqLnJlc3VsdHMucHVzaCh0YXNrUmVzdWx0KVxcbiAgICAgICAgICBjb3VudCA9IGNvdW50IC0gMTtcXG4gICAgICAgICAgaWYgKGNvdW50ID4gMCkge1xcbiAgICAgICAgICAgIHNob3dMb2FkaW5nKFxcXCLmo4DmtYvkuK0uLi7liankvZnlnLDlnYDvvJpcXFwiICsgY291bnQpXFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgaGlkZUxvYWRpbmcoKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSxcXG4gICAgICAgIHBhcmFtOiB7XFxuICAgICAgICAgIGhpOiAnY2NjJyxcXG4gICAgICAgICAgcmVzdWx0czogcmVzdWx0c1xcbiAgICAgICAgfVxcbiAgICAgIH0sIHN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GU6IFxcXCLor7fpgInmi6kg5pe26Ze0IFxcXCIgKyBkYXRldGltZSxcXG4gICAgICAgIGNsaWNrKHMsIGkpIHtcXG4gICAgICAgICAgaWYgKHMgPT0gXFxcIuaUueWPmOagt+W8j1xcXCIpIHtcXG4gICAgICAgICAgICBzcGVuID0gc3BlbiA9PSAzID8gMSA6IChzcGVuID09IDIgPyAzIDogMik7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZUNvbHVtbnMoc3Blbik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5YCS5bqPXFxcIikpIHtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5yZXZlcnNlKCk7XFxuICAgICAgICAgICAgbmFtZXMucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChzLmluY2x1ZGVzKFxcXCLoh6rnhLbmjpLluo9cXFwiKSkge1xcbiAgICAgICAgICAgIGxldCBsaXN0ID0gT2JqZWN0LmFzc2lnbihbXSwgbWFuYWdlLmxpc3QpO1xcbiAgICAgICAgICAgIGxldCBuYXR1cmFsID0gZ2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAobmF0dXJhbCA9PSBcXFwiXFxcIikge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIG5hdHVyYWxTb3J0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwibmF0dXJhbFxcXCIsIG5hdHVyYWwgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocy5pbmNsdWRlcyhcXFwi5L2/55So5o6S5bqPXFxcIikpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBsZXQgdXNpbmdzdCA9IGdldEl0ZW0oXFxcInVzaW5nc3RcXFwiLCBcXFwiXFxcIik7XFxuICAgICAgICAgICAgaWYgKHVzaW5nc3QgPT0gXFxcIlxcXCIpIHtcXG4gICAgICAgICAgICAgIG1hbmFnZS5saXN0Lmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICB1c2luZ1NvcnQuZ2V0KGxpc3QpLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIHNldEl0ZW0oXFxcIm5hdHVyYWxcXFwiLCBcXFwiXFxcIilcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgbWFuYWdlLmxpc3QubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICAgIHNuYW1lLmZvckVhY2goeCA9PiB7XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnB1c2goeCk7XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgc2V0SXRlbShcXFwidXNpbmdzdFxcXCIsIHVzaW5nc3QgPyBcXFwiXFxcIiA6IFxcXCIxXFxcIik7XFxuICAgICAgICAgIH0gZWxzZSBpZiAocyA9PSBcXFwi5Yi35paw6YWN572uXFxcIikge1xcbiAgICAgICAgICAgIGhpa2VyUG9wLnJ1bk9uTmV3VGhyZWFkKCgpID0+IHtcXG4gICAgICAgICAgICAgIGZ1bmN0aW9uIGFycmF5RGlmZmVyZW5jZShhcnIxLCBhcnIyKSB7XFxuICAgICAgICAgICAgICAgIGNvbnN0IG1hcCA9IG5ldyBNYXAoYXJyMi5tYXAoaXRlbSA9PiBbaXRlbS5rZXksIGl0ZW1dKSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLmZpbHRlcihpdGVtID0+ICFtYXAuaGFzKGl0ZW0ua2V5KSk7XFxuICAgICAgICAgICAgICB9XFxuXFxuICAgICAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIsIFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgICAgICBsZXQgbGlzdCA9IHJ1bnRpbWVDb25maWcuZ2V0QWxsU291cmNlKCk7XFxuICAgICAgICAgICAgICBpZiAoIXJ1bnRpbWVDb25maWcuaW5pdERlZmF1bHQoKSkge1xcbiAgICAgICAgICAgICAgICB0b2FzdChcXFwi5Yi35paw5aSx6LSlXFxcIik7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICAgIH07XFxuICAgICAgICAgICAgICBsZXQgbnNvdXJjZXMgPSBydW50aW1lQ29uZmlnLmdldEFsbFNvdXJjZSgpO1xcblxcbiAgICAgICAgICAgICAgbGV0IGFsaXN0ID0gYXJyYXlEaWZmZXJlbmNlKG5zb3VyY2VzLCBsaXN0KTtcXG4gICAgICAgICAgICAgIGxldCBkbGlzdCA9IGFycmF5RGlmZmVyZW5jZShsaXN0LCBuc291cmNlcyk7XFxuXFxuICAgICAgICAgICAgICBpZiAoYWxpc3QubGVuZ3RoID4gMCB8fCBkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgIGxldCBtc2cgPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgICAgaWYgKGFsaXN0Lmxlbmd0aCA+IDApIHtcXG4gICAgICAgICAgICAgICAgICBhbGlzdC5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaCh4Lm5hbWUpO1xcbiAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgbG9nKFxcXCLmlrDlop46XFxcIiArIGFsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwi5paw5aKeXFxcIiArIGFsaXN0Lmxlbmd0aCArIFxcXCLkuKrmupBcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGlmIChkbGlzdC5sZW5ndGggPiAwKSB7XFxuICAgICAgICAgICAgICAgICAgZGxpc3QuZm9yRWFjaCh4ID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIG1hbmFnZS5saXN0LnNwbGljZShtYW5hZ2UubGlzdC5pbmRleE9mKHgubmFtZSksIDEpO1xcbiAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgICAgbG9nKFxcXCLnp7vpmaQ6XFxcIiArIGRsaXN0Lm1hcChrID0+IGsubmFtZSkuam9pbihcXFwiLFxcXCIpKVxcbiAgICAgICAgICAgICAgICAgIG1zZyArPSBcXFwiIOenu+mZpFxcXCIgKyBkbGlzdC5sZW5ndGggKyBcXFwi5Liq5rqQXFxcIjtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBoaWtlclBvcC5ydW5PblVJVGhyZWFkKCgpID0+IHtcXG4gICAgICAgICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgICAgICAgICAgbWFuYWdlLnNldFRpdGxlKFxcXCLpgInmi6nop4bpopHmupAg5b2T5YmN5YWxOlxcXCIgKyBtYW5hZ2UubGlzdC5sZW5ndGggKyBcXFwi5Liq6KeG6aKR5rqQXFxcIik7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB0b2FzdChtc2cgKyBcXFwiIOabtOWkmuivpuaDheeci2xvZ1xcXCIpO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgdG9hc3QoXFxcIuW3suWIt+aWsFxcXCIpO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICB9IGVsc2UgaWYgKHMuaW5jbHVkZXMoXFxcIumdkuWwkeW5tOaooeW8j1xcXCIpKSB7XFxuICAgICAgICAgICAgZnVuY3Rpb24gc2VsZWN0KCkge1xcbiAgICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgICBcXFwidGl0bGVcXFwiOiBcXFwi6YCJ5oupXFxcIixcXG4gICAgICAgICAgICAgICAgXFxcIm9wdGlvbnNcXFwiOiBbXFxcIuS4tOaXtuWFs+mXrVxcXCIsIFxcXCLlhbPpl61cXFwiLCBcXFwi6K6+572u5a+G56CBXFxcIl0sXFxuICAgICAgICAgICAgICAgIGNvbDogMSxcXG4gICAgICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcblxcbiAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCA9PSBcXFwi5Li05pe25YWz6ZetXFxcIikge1xcbiAgICAgICAgICAgICAgICAgICAgcHV0TXlWYXIoXFxcInRlbXBMZWFjaFxcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlucHV0ID09IFxcXCLlhbPpl61cXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcImxlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAkKFxcXCJcXFwiLCBcXFwi6K6+572u5a+G56CBXFxcXG7mjIfnurnkuI3og73nlKjml7bmnInmlYhcXFwiKS5pbnB1dCgoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dCkge1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoUGFzc1xcXCIsIGlucHV0KTtcXG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gXFxcInRvYXN0Oi8v6K6+572u5oiQ5YqfXFxcIjtcXG4gICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGVhckl0ZW0oXFxcImxlYWNoUGFzc1xcXCIpO1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/kvb/nlKjpu5jorqTlr4bnoIFcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgbGV0IGxlYWNoUGFzcyA9IGdldEl0ZW0oXFxcImxlYWNoUGFzc1xcXCIsIFxcXCJcXFwiKTtcXG4gICAgICAgICAgICBpZiAocy5pbmNsdWRlcyhcXFwi5YWz6ZetXFxcIikpIHtcXG5cXG4gICAgICAgICAgICAgIGlmIChoaWtlclBvcC5jYW5CaW9tZXRyaWMoKSAhPT0gMCAmJiAhbGVhY2hQYXNzKSB7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLorr7nva7lr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGhpbnQ6IFxcXCLlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr4bnoIHkuI3og73kuLrnqbpcXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgICAgICAgc2V0SXRlbShcXFwibGVhY2hQYXNzXFxcIiwgdGV4dCk7XFxuICAgICAgICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidGVtcExlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmiZPlvIDov4fmu6RcXFwiKTtcXG4gICAgICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICAgICAgICB9LFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgIHNldEl0ZW0oXFxcImxlYWNoXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgY2xlYXJNeVZhcihcXFwidGVtcExlYWNoXFxcIik7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmiZPlvIDov4fmu6RcXFwiKTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgaWYgKGhpa2VyUG9wLmNhbkJpb21ldHJpYygpICE9PSAwKSB7XFxuICAgICAgICAgICAgICAgIGhpa2VyUG9wLmlucHV0Q29uZmlybSh7XFxuICAgICAgICAgICAgICAgICAgY29udGVudDogXFxcIui+k+WFpeWvhueggei/m+ihjOWFs+mXrVxcXCIsXFxuICAgICAgICAgICAgICAgICAgdGl0bGU6IFxcXCLovpPlhaXlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGhpbnQ6IFxcXCLlr4bnoIFcXFwiLFxcbiAgICAgICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRleHQgPT09IGxlYWNoUGFzcyB8fCAoIWxlYWNoUGFzcyAmJiB0ZXh0ID09PSBTdHJpbmcocHMpKSkge1xcbiAgICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKTtcXG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBcXFwidG9hc3Q6Ly/lr4bnoIHplJnor69cXFwiO1xcbiAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgIH0sXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgaGlrZXJQb3AuY2hlY2tCeUJpb21ldHJpYygoKSA9PiB7XFxuICAgICAgICAgICAgICAgICAgaGlrZXJQb3AucnVuT25OZXdUaHJlYWQoKCkgPT4ge1xcbiAgICAgICAgICAgICAgICAgICAgc2VsZWN0KCk7XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICBwb3AuZGlzbWlzcygpO1xcbiAgICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgc2hvd1NlbGVjdE9wdGlvbnMoe1xcbiAgICAgICAgICAgICAgdGl0bGU6IFxcXCLnvJbnoIHnsbvlnotcXFwiLFxcbiAgICAgICAgICAgICAgb3B0aW9uczogW1xcX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lv4XpobvkuLrnu53lr7not6/lvoRcXG5mdW5jdGlvbiBnZXRCeVNvdXJjZShzb3VyY2UpIHtcXG4gICAgcmV0dXJuIHN5bmMoKCkgPT4ge1xcbiAgICAgICAgbGV0IGtleSA9IHNvdXJjZS5rZXk7XFxuICAgICAgICAvL2xvZyhkcnB5TWFwLnNpemUpXFxuICAgICAgICBpZiAoZHJweU1hcC5oYXMoa2V5KSkge1xcbiAgICAgICAgICAgIHJldHVybiBkcnB5TWFwLmdldChrZXkpO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKGRycHlNYXAuc2l6ZSA+PSA1KSB7XFxuICAgICAgICAgICAgLy9sb2coXFxcIuivt+axgjpcXFwiICsga2V5KVxcbiAgICAgICAgICAgIGRlbChBcnJheS5mcm9tKGRycHlNYXAua2V5cygpKS5hdCgwKSk7XFxuICAgICAgICB9XFxuICAgICAgICBsZXQgZHJweSA9IGNyZWF0ZU5ld0RycHkoc291cmNlKTtcXG4gICAgICAgIHJldHVybiBkcnB5O1xcbiAgICB9LCB0aGlzKS5jYWxsKCk7XFxufVxcblxcbmZ1bmN0aW9uIHB1dChrZXksIGRycHkpIHtcXG4gICAgc3luYygoKSA9PiBkcnB5TWFwLnNldChrZXksIGRycHkpLCB0aGlzKS5jYWxsKCk7XFxufVxcblxcbmZ1bmN0aW9uIHJ1blByb3h5KGRycHksIGFyZ3MpIHtcXG4gICAgaWYgKHR5cGVvZiBkcnB5LnByb3h5ID09PSBcXFwiZnVuY3Rpb25cXFwiKSB7XFxuICAgICAgICB0cnkge1xcbiAgICAgICAgICAgIC8vbGV0IHRpbWUxID0gRGF0ZS5ub3coKTtcXG4gICAgICAgICAgICBwcm94eVNlbWFwaG9yZS5hY3F1aXJlKCk7XFxuICAgICAgICAgICAgLy9sZXQgdGltZTIgPSBEYXRlLm5vdygpO1xcbiAgICAgICAgICAgIC8vbG9nKFxcXCIx562J5b6F5pe26Ze0OlxcXCIgKyAodGltZTIgLSB0aW1lMSkgKyBcXF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hcmNoS2V5LFxcbiAgICAgICAgICAgICAgdGV4dGFyZWE6IGZhbHNlLCAvL+WkmuihjOaooeW8j1xcbiAgICAgICAgICAgICAgbWF4VGV4dGFyZWE6IHRydWUsXFxuICAgICAgICAgICAgICBub0F1dG9Tb2Z0OiBmYWxzZSxcXG4gICAgICAgICAgICAgIC8vaGlkZUNhbmNlbDogdHJ1ZSxcXG4gICAgICAgICAgICAgIGNvbmZpcm0odGV4dCkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hLZXkgPSB0ZXh0O1xcbiAgICAgICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcbiAgICAgICAgICAgICAgICBkeW5hbWljU291cmNlLmxlbmd0aCA9IDA7XFxuICAgICAgICAgICAgICAgIGlmICh0ZXh0KSB7XFxuICAgICAgICAgICAgICAgICAgY2FuU2VhcmNoU291cmNlLmZvckVhY2goKHYsIGkpID0+IHtcXG4gICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0LnNwbGl0KC9cXFxcfC8pLmZpbHRlcihmID0+IGYpLnNvbWUoeCA9PiB2Lm5hbWUuaW5jbHVkZXMoeCkpKSB7XFxuICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucHVzaCh2KTtcXG4gICAgICAgICAgICAgICAgICAgICAgbWFuYWdlLmxpc3QucHVzaChzZWFyY2hBbGxvdy5pbmNsdWRlcyh2LmtleSkgPyBcXFwi4oCc4oCc4oCd4oCdXFxcIiArICh2Lm5hbWUgKyBcXFwiXFxcIikuZm9udGNvbG9yKFxcXCIjMDA5OTY2XFxcIikgOiB2Lm5hbWUpXFxuICAgICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgZHluYW1pY1NvdXJjZSA9IGNhblNlYXJjaFNvdXJjZS5zbGljZSgpO1xcbiAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24obWFuYWdlLmxpc3QsIGdldE5hbWVzKCkpO1xcblxcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgICAgICAgLy9yZXR1cm4gXFxcInRvYXN0Oi8v6L6T5YWl5LqGXFxcIiArIHRleHQ7XFxuICAgICAgICAgICAgICB9LFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9IGVsc2UgaWYgKGkgPT09IDIpIHtcXG4gICAgICAgICAgICBsZXQgbGlzdCA9IE9iamVjdC5hc3NpZ24oW10sIG1hbmFnZS5saXN0KTtcXG4gICAgICAgICAgICBtYW5hZ2UubGlzdC5sZW5ndGggPSAwO1xcblxcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2Uuc29ydCgoYSwgYikgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhhLm5hbWUpLmxvY2FsZUNvbXBhcmUoU3RyaW5nKGIubmFtZSksIHVuZGVmaW5lZCwge1xcbiAgICAgICAgICAgICAgICBudW1lcmljOiB0cnVlLFxcbiAgICAgICAgICAgICAgICBzZW5zaXRpdml0eTogJ2Jhc2UnXFxuICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBtYW5hZ2UuY2hhbmdlKCk7XFxuICAgICAgICAgIH0gZWxzZSBpZiAoaSA9PSAzKSB7XFxuICAgICAgICAgICAgbWFuYWdlLmxpc3QucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIGR5bmFtaWNTb3VyY2UucmV2ZXJzZSgpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDQpIHtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAoIXNlYXJjaEFsbG93LmluY2x1ZGVzKHYua2V5KSkge1xcbiAgICAgICAgICAgICAgICBzZWFyY2hBbGxvdy5wdXNoKHYua2V5KTtcXG4gICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBtYW5hZ2Uuc2V0VGl0bGUocG9wVGl0bGUoc2VhcmNoQWxsb3cubGVuZ3RoKSk7XFxuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbihtYW5hZ2UubGlzdCwgZ2V0TmFtZXMoKSk7XFxuICAgICAgICAgICAgcnVudGltZUNvbmZpZy5zZXRTZWFyY2hBbGxvdygpO1xcbiAgICAgICAgICAgIG1hbmFnZS5jaGFuZ2UoKTtcXG4gICAgICAgICAgfSBlbHNlIGlmIChpID09IDUpIHtcXG4gICAgICAgICAgICBsZXQgdGVtbGlzdCA9IHNlYXJjaEFsbG93LnNsaWNlKCk7XFxuICAgICAgICAgICAgc2VhcmNoQWxsb3cubGVuZ3RoID0gMDtcXG4gICAgICAgICAgICBkeW5hbWljU291cmNlLmZvckVhY2godiA9PiB7XFxuICAgICAgICAgICAgICBpZiAodGVtbGlzdC5pbmNsdWRlcyh2LmtleSkpIHJldHVybjtcXG4gICAgICAgICAgICAgIHNlYXJjaEFsbG93LnB1c2godi5rZXkpO1xcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIG1hbmFnZS5zZXRUaXRsZShwb3BUaXRsZShzZWFyY2hBbGxvdy5sZW5ndGgpKTtcXG4gICAgICAgICAgICBPYmplY3QuYXNzaWduKG1hbmFnZS5saXN0LCBnZXROYW1lcygpKTtcXG4gICAgICAgICAgICBydW50aW1lQ29uZmlnLnNldFNlYXJjaEFsbG93KCk7XFxuICAgICAgICAgICAgbWFuYWdlLmNoYW5nZSgpO1xcbiAgICAgICAgICB9XFxuICAgICAgICB9LFxcbiAgICAgIH0pO1xcbiAgICB9XFxuICB9KTtcXG59XCJ9L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RlbXBbaW5kZXhdID09IGkpIHtcXG4gICAgICAgICAgICB0ID0gXFxcIjxiPjxmb250IGNvbG9yPVxcXCIgKyBjb2xvciArIFxcXCI+XFxcIiArIHQgKyBcXFwiPC9mb250PjwvYj5cXFwiO1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IGl0LnY7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgaWYgKGNhdGVfdGVtcFtpbmRleF0gPT0gXFxcIi0xXFxcIikge1xcbiAgICAgICAgICAgIGZsW3gua2V5XSA9IFxcXCJ1bmRlZmluZWRcXFwiO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIGlmIChmb2xkID09IDEpIHtcXG4gICAgICAgICAgICBsYXlvdXQucHVzaCh7XFxuICAgICAgICAgICAgICB0aXRsZTogJ+KAnOKAnOKAneKAnScgKyB0LFxcbiAgICAgICAgICAgICAgdXJsOiAkKFxcXCIjbm9Mb2FkaW5nI1xcXCIpLmxhenlSdWxlKChvKSA9PiB7XFxuICAgICAgICAgICAgICAgIGxldCBpID0gby5pO1xcbiAgICAgICAgICAgICAgICBzdG9yYWdlMC5wdXRNeVZhcihcXFwiaXNfZGVmXFxcIiwgXFxcIjFcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGNhdGVfb2JqID0gc3RvcmFnZTAuZ2V0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwge30pO1xcblxcbiAgICAgICAgICAgICAgICBsZXQgY2F0ZV90ZW1wID0gby5jYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIGlmIChjYXRlX3RlbXAuY29uc3RydWN0b3IgIT0gQXJyYXkpIHtcXG4gICAgICAgICAgICAgICAgICBjYXRlX3RlbXAgPSBbXTtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBsZXQgaW5kZXggPSBvLmluZGV4O1xcbiAgICAgICAgICAgICAgICBsZXQgYyA9IGNhdGVfdGVtcFtpbmRleF0gfHwgXFxcIi0xXFxcIjtcXG4gICAgICAgICAgICAgICAgLy9sb2coYylcXG4gICAgICAgICAgICAgICAgaWYgKGMgPT0gaSkge1xcbiAgICAgICAgICAgICAgICAgIG8uY2F0ZV90ZW1wW2luZGV4XSA9IFxcXCItMVxcXCI7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgby5jYXRlX3RlbXBbaW5kZXhdID0gaSArIFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGNhdGVfb2JqW28uY2F0ZV0gPSBjYXRlX3RlbXA7XFxuICAgICAgICAgICAgICAgIC8vbG9nKGNhdGVfdGVtcClcXG4gICAgICAgICAgICAgICAgLy9zdG9yYWdlMC5wdXRNeVZhcihcXFwiY2F0ZV90ZW1wXFxcIiwgY2F0ZV90ZW1wKTtcXG4gICAgICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcImNhdGVfb2JqXFxcIiwgY2F0ZV9vYmopO1xcbiAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgICAgICAgfSwge1xcbiAgICAgICAgICAgICAgICBpbmRleDogaW5kZXgsXFxuICAgICAgICAgICAgICAgIGNhdGVfdGVtcDogY2F0ZV90ZW1wLFxcbiAgICAgICAgICAgICAgICBpOiBpLFxcbiAgICAgICAgICAgICAgICBjYXRlOiBjYXRlXFxuICAgICAgICAgICAgICB9KSxcXG4gICAgICAgICAgICAgIGNvbF90eXBlOiAnc2Nyb2xsX2J1dHRvbicsXFxuICAgICAgICAgICAgfSlcXG4gICAgICAgICAgfVxcbiAgICAgICAgfSlcXG4gICAgICB9KVxcbiAgICB9XFxuICB9XFxufVxcblxcbmZ1bmN0aW9uIGdldEZsKCkge1xcbiAgZmwgPSBPYmplY3Qua2V5cyhmbCkuZmlsdGVyKGtleSA9PiBmbFtrZXldICE9P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4gICAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIHVybCA9IGlkLnNwbGl0KFxcXCJAQFxcXCIpWzBdO1xcbiAgICAgICAgICB9XFxuICAgICAgICAgIHJldHVybiAkLnJlcXVpcmUoXFxcInZpZGVvVXJsXFxcIikucGFyc2UodXJsLCBpZCwgc291cmNlKTtcXG4gICAgICAgIH0sIHNvdXJjZSwgaWQpO1xcbiAgICAgICAgY2lkID0gaWQ7XFxuICAgICAgfVxcbiAgICAgIGQucHVzaCh7XFxuICAgICAgICB0aXRsZTogbmFtZSxcXG4gICAgICAgIGRlc2M6IGl0LnZvZF9yZW1hcmtzLFxcbiAgICAgICAgdXJsOiB1cmwsXFxuICAgICAgICBpbWc6IGl0LnZvZF9waWMsXFxuICAgICAgICBjb2xfdHlwZTogaG9tZUxpc3RDb2wsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBpbWc6IGl0LnZvZF9waWMsXFxuICAgICAgICAgIHZvZElkOiBpZCxcXG4gICAgICAgICAgc25hbWU6IHNvdXJjZS5uYW1lLFxcbiAgICAgICAgICBza2V5OiBzb3VyY2Uua2V5LFxcbiAgICAgICAgICBpZDogY2lkLFxcbiAgICAgICAgICBsb25nQ2xpY2s6IFt7XFxuICAgICAgICAgICAgdGl0bGU6IFxcXCLogZrlkIjmkJzntKJcXFwiLFxcbiAgICAgICAgICAgIGpzOiBcXFwicHV0TXlWYXIoJ3RlbXNtb2RlJywgJzEnKTsnaGlrZXI6Ly9zZWFyY2g/cnVsZT0nICsgTVlfUlVMRS50aXRsZSArICcmcz1cXFwiICsgbmFtZSArIFxcXCInO1xcXCJcXG4gICAgICAgICAgfV1cXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgfVxcbiAgfVxcbiAgZGVsZXRlSXRlbShNWV9SVUxFLnRpdGxlICsgXFxcImxvYWRcXFwiKTtcXG59XFxuXFxuZnVuY3Rpb24gc2V0RHJweVBhdGgoZCkge1xcbiAgZC5wdXN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AgZXh0cmE6IHtcXG4gICAgICBjcGF0aDogY29uZmlnLnBhdGgsXFxuICAgICAgbG9uZ0NsaWNrOiBbe1xcbiAgICAgICAgdGl0bGU6IFxcXCLmm7TmjaLphY3nva5cXFwiLFxcbiAgICAgICAganM6IEpTT04uc3RyaW5naWZ5KFxcXCJoaWtlcjovL3BhZ2UvY3JlYXRlQ29uZmlnI25vUmVjb3JkSGlzdG9yeSMjbm9IaXN0b3J5I1xcXCIpXFxuICAgICAgfSwge1xcbiAgICAgICAgdGl0bGU6IFxcXCLorr/pl67nvZHnq5lcXFwiLFxcbiAgICAgICAganM6ICQudG9TdHJpbmcoKCkgPT4ge1xcbiAgICAgICAgICBsZXQgcnVudGltZUNvbmZpZyA9IEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpO1xcbiAgICAgICAgICBsZXQgc291cmNlID0gcnVudGltZUNvbmZpZy5nZXRDdXJyZW50U291cmNlKCk7XFxuICAgICAgICAgIGxldCBEcnB5TWFuYWdlID0gR00uZGVmaW5lTW9kdWxlKFxcXCJEcnB5TWFuYWdlXFxcIik7XFxuICAgICAgICAgIHJldHVybiBcXFwid2ViOi8vXFxcIiArIERycHlNYW5hZ2UuZ2V0KHNvdXJjZS5rZXkpLmdldFJ1bGUoXFxcImhvc3RcXFwiKTtcXG4gICAgICAgICAgLy9yZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgfSlcXG4gICAgICB9LCB7XFxuICAgICAgICB0aXRsZTogXFxcIuWIt+aWsOa6kFxcXCIsXFxuICAgICAgICBqczogJC50b1N0cmluZygoKSA9PiB7XFxuICAgICAgICAgIGxldCBydW50aW1lQ29uZmlnID0gR00uZGVmaW5lTW9kdWxlKFxcXCJydW50aW1lQ29uZmlnXFxcIik7XFxuICAgICAgICAgIGxldCBzb3VyY2UgPSBydW50aW1lQ29uZmlnLmdldEN1cnJlbnRTb3VyY2UoKTtcXG4gICAgICAgICAgbGV0IERycHlNYW5hZ2UgPSBHT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eeQhj0+5Y+z5LiK6KeSXFxcIixcXG4gICAgICB1cmw6IFxcXCJoaWtlcjovL2VtcHR5XFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcInRleHRfY2VudGVyXzFcXFwiXFxuICAgIH0pO1xcbiAgfSBlbHNlIGlmICghcnVudGltZUNvbmZpZy5pc1ByZXBhcmVkKCkpIHtcXG4gICAgbGV0IGxvYWRFcnJvciA9IHJ1bnRpbWVDb25maWcuZ2V0TG9hZEVycm9yKCk7XFxuICAgIGlmIChsb2FkRXJyb3IpIHtcXG4gICAgICBkLnB1c2goe1xcbiAgICAgICAgdGl0bGU6IFxcXCLigJzigJzphY3nva7mlofku7bliqDovb3lpLHotKXigJ3igJ1cXFwiLFxcbiAgICAgICAgZGVzYzogbG9hZEVycm9yLnRvU3RyaW5nKCksXFxuICAgICAgICB1cmw6ICQoKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICAgIEdNLmRlZmluZU1vZHVsZShcXFwicnVudGltZUNvbmZpZ1xcXCIpLmluaXREZWZhdWx0KCk7XFxuICAgICAgICAgIHJlZnJlc2hQYWdlKCk7XFxuICAgICAgICAgIHJldHVybiBcXFwiaGlrZXI6Ly9lbXB0eVxcXCI7XFxuICAgICAgICB9KSxcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgfSk7XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5pu05o2i6YWN572uXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vcGFnZS9jcmVhdGVDb25maWcjbm9SZWNvcmRIaXN0b3J5IyNub0hpc3RvcnkjXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF9jZW50ZXJfMVxcXCIsXFxuICAgICAgICBleHRyYToge1xcbiAgICAgICAgICBsaW5lVmlzaWJsZTogZmFsc2VcXG4gICAgICAgIH1cXG4gICAgICB9KTtcXG4gICAgfSBl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oLCB2YWx1ZSkge1xcbiAgICAgICAgdmFyIHBhcnRzID0gcGF0aC5zcGxpdCgnLicpO1xcbiAgICAgICAgdmFyIGN1cnJlbnQgPSBvYmo7XFxuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHBhcnRzLmxlbmd0aCAtIDE7IGkrKykge1xcbiAgICAgICAgICB2YXIgcGFydCA9IHBhcnRzW2ldO1xcbiAgICAgICAgICBpZiAoIWN1cnJlbnRbcGFydF0pIHtcXG4gICAgICAgICAgICBjdXJyZW50W3BhcnRdID0ge307XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgY3VycmVudCA9IGN1cnJlbnRbcGFydF07XFxuICAgICAgICB9XFxuICAgICAgICBjdXJyZW50W3BhcnRzW3BhcnRzLmxlbmd0aCAtIDFdXSA9IHZhbHVlO1xcbiAgICAgIH0sXFxuICAgICAgZ2V0KCkge1xcbiAgICAgICAgbGV0IHVjID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdGhpcy51Yyk7XFxuICAgICAgICBpZiAoT2JqZWN0LmtleXModWMpLmxlbmd0aCA9PSAwKSB7XFxuICAgICAgICAgIHVjID0gdGhpcy5kZWY7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gdWM7XFxuICAgICAgfSxcXG4gICAgICBzZXQodmFsdWUsIGtleSkge1xcbiAgICAgICAgbGV0IHVjID0gdGhpcy5nZXQoKTtcXG4gICAgICAgIGlmIChrZXkpIHtcXG4gICAgICAgICAgdGhpcy5kZWVwT2JqZWN0UHJvcGVydHkodWMsIGtleSwgdmFsdWUpO1xcbiAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgdWMgPSB2YWx1ZTtcXG4gICAgICAgIH1cXG4gICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVjKTtcXG4gICAgICB9LFxcbiAgICAgIGdldEluZGV4cygpIHtcXG4gICAgICAgIGxldCB1YyA9I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W50XFxcIiwge30pO1xcblxcbiAgICAgICAgICBpZiAoT2JqZWN0LmtleXMoY3VycmVudCkubGVuZ3RoID4gMCkge1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oaXRlbS5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGN1cnJlbnQudGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGN1cnJlbnQucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogY3VycmVudC5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGN1cnJlbnQudHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBpdGVtLmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogY3VycmVudC5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBjdXJyZW50LmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oY3VycmVudC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgdGl0bGU6IGl0ZW0udGl0bGUsXFxuICAgICAgICAgICAgICBwaWM6IGl0ZW0ucGljIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgZGVzYzogaXRlbS5kZXNjIHx8IFxcXCJcXFwiLFxcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGl0ZW0udHlwZSxcXG4gICAgICAgICAgICAgIGV4dHJhOiBPYmplY3QuYXNzaWduKHt9LCBjdXJyZW50LmV4dHJhLCB7XFxuICAgICAgICAgICAgICAgIGtleTogaXRlbS5leHRyYS5rZXksXFxuICAgICAgICAgICAgICAgIGluZGV4OiBpdGVtLmV4dHJhLmluZGV4XFxuICAgICAgICAgICAgICB9KVxcbiAgICAgICAgICAgIH0pO1xcblxcbiAgICAgICAgICAgIGxldCBuYXJyID0gJC5zd2FwQXJyYXlFbGVtZW50cyhpbmRleHMsIGN1cnJlbnQuZXh0cmEuaW5kZXgsIGl0ZW0uZXh0cmEuaW5kZXgpO1xcblxcbiAgICAgICAgICAgICQudWlDb25maWcuc2V0KG5hcnIsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgIGNsZWFyTXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiKTtcXG4gICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICBsZXQgaCA9ICfigJzigJzigJ3igJ0nO1xcbiAgICAgICAgICAgIGxldCB0aXRsZSA9IGl0ZW0udGl0bGU7XFxuICAgICAgICAgICAgdG9hc3QoXFxcIumAieaLqeenu+WKqOeahOebruagh1xcXCIpO1xcbiAgICAgICAgICAgIGlmICgvdGV4dF9pY29ufGF2YXRhcnxpY29uX3NtYWxsXzMvLnRlc3QoaXRlbS50eXBlKSkge1xcbiAgICAgICAgICAgICAgaCA9IFxcXCJcXFwiO1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9IGVsc2UgaWYgKC9pY29uXzFfc2VhcmNoLy50ZXN0KGl0ZW0udHlwZSkpIHtcXG4gICAgICAgICAgICAgIGggPSBcXFwiXFxcIjtcXG4gICAgICAgICAgICAgIHRpdGxlID0gXFxcIuKeoe+4j1xcXCIgKyB0aXRsZTtcXG4gICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgdGl0bGUgPSB0aXRsZS5mb250Y29sb3IoXFxcIiNmZmZcXFwiKTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgdXBkYXRlSXRlbShpdGVtLmV4dHJhLmlkLCB7XFxuICAgICAgICAgICAgICB0aXRsZTogaCArIHRpdGxlLFxcbiAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgc3RvcmFnZTAucHV0TXlWYXIoXFxcInVpX2N1cnJlbnRcXFwiLCBpdGVtKTtcXG4gICAgICAgICAgfVxcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaSlcXG4gICAgICAgIGl0ZW1bXFxcImV4dHJhXFxcIl0gPSB7XFxuICAgICAgICAgIGtleTogaXRlbS5rZXksXFxuICAgICAgICAgIGNsczogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiLFxcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgaW5kZXg6IGl0ZW0uaW5kZXgsXFxuICAgICAgICB9XFxuICAgICAgICBpZiAoaXRlbS5rZXkgIT0gXFxcIuiuvue9rlxcXCIpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuWIoOmZpFxcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgIGlmIChpICE9IC0xKSB7XFxuICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gLTE7XFxuICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAkLnVpQ29uZmlnLnNldChpdGVtcywgXFxcInlpLnVpXFxcIik7XFxuICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgIH0sIGl0ZW0ua2V5KVxcbiAgICAgICAgICB9KVxcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKCEvaWNvbl8xX3NlYXJjaHxhdmF0YXIvLnRlc3QoaXRlbS5jb2xfdHlwZSkpIHtcXG4gICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICB0aXRsZTogXFxcIuabtOaNouWbvuagh1xcXCIsXFxuICAgICAgICAgICAganM6ICQudG9TdHJpbmcoKGtleSkgPT4ge1xcbiAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbWdcXFwiXSA9IGlucHV0O1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICQudWlDb25maWcuc2V0KGl0ZW1zLCBcXFwieWkudWlcXFwiKTtcXG4gICAgICAgICAgICAgICAgbGV0IGlkID0gZmluZEl0ZW1zQnlDbHMoTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiKS5maWx0ZXIoeCA9PiB4LmV4dHJhLmtleSA9PSBrZXkpWzBdLmV4dHJhLmlkO1xcbiAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHBpYzogaW5wdXQgfSlcXG4gICAgICAgICAgICAgIH0sIGtleSlcXG4gICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgfSlcXG4gICAgICAgICAgaWYgKGl0ZW0ua2V5ICE9IFxcXCLmjaLmupBcXFwiICYmIGl0ZW0ua2V5ICE9IFxcXCLmkJzntKLmqKHlvI9cXFwiKSB7XFxuICAgICAgICAgICAgbG9uZ2NsaWNrcy5wdXNoKHtcXG4gICAgICAgICAgICAgIHRpdGxlOiBcXFwi5L+u5pS55ZCN56ewXFxcIixcXG4gICAgICAgICAgICAgIGpzOiAkLnRvU3RyaW5nKChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuICQoXFxcIlxcXCIpLmlucHV0KChrZXkpID0+IHtcXG4gICAgICAgICAgICAgICAgICBsZXQgaXRlbXMgPSAkLnVpQ29uZmlnLmdldEluZGV4cygpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpID0gaXRlbXMuZmluZEluZGV4KHggPT4geC5rZXkgPT0ga2V5KTtcXG4gICAgICAgICAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgICAgICAgICAgaXRlbXNbaV1bXFxcInRpdGxlXFxcIl0gPSBpbnB1dDtcXG4gICAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICAgICAgICAgIGxldCBpZCA9IGZpbmRJdGVtc0J5Q2xzKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIikuZmlsdGVyKHggPT4geC5leHRyYS5rZXkgPT0ga2V5KVswXS5leHRyYS5pZDtcXG4gICAgICAgICAgICAgICAgICB1cGRhdGVJdGVtKGlkLCB7IHRpdGxlOiBpbnB1dCB9KVxcbiAgICAgICAgICAgICAgICB9LCBrZXkpXFxuICAgICAgICAgICAgICB9LCBpdGVtLmtleSlcXG4gICAgICAgICAgICB9KVxcbiAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgICAgICBpdGVtLmV4dHJhLkxvbmdDbGljayA9IGxvbmdjbGlja3M7XFxuICAgICAgICByZXR1cm4gaXRlbTtcXG4gICAgICB9KVxcbiAgICB9IGVsc2Uge1xcbiAgICAgIHVpb2JqID0gdWlvYmoubWFwKChpdGVtLCBpKSA9PiB7XFxuICAgICAgICBpdGVtLmV4dHJhID0ge1xcbiAgICAgICAgICBpZDogTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiICsgaSxcXG4gICAgICAgICAgY2xzOiBNWV9SVUxFLnRpdGxlICsgXFxcIl91aVxcXCJcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBpdGVtO1xcbiAgICAgIH0pXFxuICAgIH1cXG4gICAgZCA9IGQuY29uY2F0KHVpb2JqKTtcXG5cXG4gICAgaWYgKGluZGV4cy5zb21lKHggPT4geC5pbmRleCA9PSAtMSkgJiYgdWltb2RlKSB7XFxuICAgICAgZC5wdXNoKHtcXG4gICAgICAgIHRpdGxlOiBcXFwi5bey56e76ZmkXFxcIixcXG4gICAgICAgIGNvbF90eXBlOiBcXFwidGV4dF8xXFxcIixcXG4gICAgICAgIHVybDogXFxcImhpa2VyOi8vZW1wdHlcXFwiLFxcbiAgICAgICAgZXh0cmE6IHtcXG4gICAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgfVxcbiAgICAgIH0pXFxuICAgICAgaW5kZXhzLmZpbHRlcih4ID0+IHguaW5kZXggPT0gLTEpLmZvckVhY2goKGl0ZW0sIGkpID0+IHtcXG4gICAgICAgIGxldCBtYXAgPSBuZXcgTWFwKHN1aW9iai5tYXAob2JqID0+IFtvYmoua2V5LCBvYmpdKSk7XFxuICAgICAgICBsZXQgb2JqID0gbWFwLmdldChpdGVtLmtleSk7XFxuICAgICAgICBvYmoudXJsID0gJChcXFwiXFxcIikubGF6eVJ1bGUoKGtleSwgaW5kZXgpID0+IHtcXG4gICAgICAgICAgbGV0IGl0ZW1zID0gJC51aUNvbmZpZy5nZXRJbmRleHMoKTtcXG4gICAgICAgICAgbGV0IGkgPSBpdGVtcy5maW5kSW5kZXgoeCA9PiB4LmtleSA9PSBrZXkpO1xcbiAgICAgICAgICBpZiAoaSAhPSAtMSkge1xcbiAgICAgICAgICAgIGl0ZW1zW2ldW1xcXCJpbmRleFxcXCJdID0gaW5kZXg7XFxuICAgICAgICAgIH1cXG4gICAgICAgICAgJC51aUNvbmZpZy5zZXQoaXRlbXMsIFxcXCJ5aS51aVxcXCIpO1xcbiAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICByZXR1cm4gXFxcImhpa2VyOi8vZW1wdHlcXFwiO1xcbiAgICAgICAgfSwgaXRlbS5rZXksIG9iai5pbmRleClcXG4gICAgICAgIG9iai50aXRsZSA9IG9iai5rZXk7XFxuICAgICAgICBpZiAob2JqLmV4dHJhID09IHVuZGVmaW5lZCkge1xcbiAgICAgICAgICBvYmouZXh0cmEgPSB7fTtcXG4gICAgICAgIH1cXG4gICAgICAgIG9iai5leHRyYS5pZCA9IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3VpXFxcIiArIG9iai5rZXk7XFxuICAgICAgICBvYmouZXh0cmEuY2xzID0gTVlfUlVMRS50aXRsZSArIFxcXCJfdWlcXFwiO1xcblxcbiAgICAgICAgaWYgKG9iai5jb2xfdHlwZSA9PSBcXFwiaW5wdXRcXFwiKSB7XFxuICAgICAgICAgIG9iai5jb2xfdHlwZSA9IFxcXCJpY29uXzFfc2VhcmNoXFxcIjtcXG4gICAgICAgIH1cXG4gICAgICAgIGQucHVzaChvYmopXFxuICAgICAgfSlcXG4gICAgfVxcblxcbiAgICBkLnB1c2goe1xcbiAgICAgIGNvbF90eXBlOiBcXFwibGluZVxcXCJcXG4gICAgfSwge1xcbiAgICAgIHRpdGxlOiAn4oCc4oCc4oCd4oCdJyArICh1aW1vZGUgPyBcXFwi5L+u5pS5XFxcIi5mb250Y29sb3IoXFxcInJlZFxcXCIpIDogXFxcIuS/ruaUuVxcXCIpLFxcbiAgICAgIHVybDogJCgnI25vTG9hZGluZyMnKS5sYXp5UnVsZSgoKSA9PiB7XFxuICAgICAgICBsZXQgdWltb2RlID0gZ2V0TXlWYXIoXFxcInVpbW9kZVxcXCIsIFxcXCIwXFxcIik7XFxuICAgICAgICBwdXRNeVZhcihcXFwidWltb2RlXFxcIiwgdWltb2RlID09IFxcXCIwXFxcIiA/IFxcXCIxXFxcIiA6IFxcXCIwXFxcIik7XFxuICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgcmV0dX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cmE6IHtcXG4gICAgICAgIExvbmdDbGljazogW3tcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlpI3liLZcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgY29weShKU09OLnN0cmluZ2lmeSh1aV9jb25maWcueWkpKTtcXG4gICAgICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICAgIH0sIHtcXG4gICAgICAgICAgdGl0bGU6IFxcXCLlr7zlhaVcXFwiLFxcbiAgICAgICAgICBqczogJC50b1N0cmluZygodWlfY29uZmlnKSA9PiB7XFxuICAgICAgICAgICAgdmFyIHVjID0gc3RvcmFnZTAuZ2V0SXRlbShcXFwidWlfY29uZmlnXFxcIiwgdWlfY29uZmlnKTtcXG4gICAgICAgICAgICByZXR1cm4gJChcXFwie3tjbGlwYm9hcmR9fVxcXCIpLmlucHV0KCh1YykgPT4ge1xcbiAgICAgICAgICAgICAgdmFyIHlpID0ge307XFxuICAgICAgICAgICAgICB0cnkge1xcbiAgICAgICAgICAgICAgICB5aSA9IEpTT04ucGFyc2UoaW5wdXQpO1xcbiAgICAgICAgICAgICAgICBpZiAoeWkuaGFzT3duUHJvcGVydHkoXFxcInVpXFxcIikpIHtcXG4gICAgICAgICAgICAgICAgICB1Yy55aSA9IHlpO1xcbiAgICAgICAgICAgICAgICAgIHN0b3JhZ2UwLnNldEl0ZW0oXFxcInVpX2NvbmZpZ1xcXCIsIHVjKTtcXG4gICAgICAgICAgICAgICAgICByZWZyZXNoUGFnZSgpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgIHRvYXN0KFxcXCLmoLzlvI/plJnor69cXFwiKVxcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIH0sIHVjKVxcbiAgICAgICAgICB9LCB1aV9jb25maWcpXFxuICAgICAgICB9XVxcbiAgICAgIH1cXG4gICAg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TEUudGl0bGUgKyBcXFwiX3VpXFxcIikgfHwgW10pLmZpbHRlcih4ID0+ICEvKGljb25fMV9zZWFyY2h8YXZhdGFyfGlucHV0KS8udGVzdCh4LnR5cGUpKTtcXG4gICAgICAgICAgb2Jqcy5mb3JFYWNoKHggPT4ge1xcbiAgICAgICAgICAgIHVwZGF0ZUl0ZW0oeC5leHRyYS5pZCwge1xcbiAgICAgICAgICAgICAgY29sX3R5cGU6IGlucHV0LFxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICB9KTtcXG4gICAgICAgICAgdWlfY29uZmlnLnlpLmNvbCA9IGlucHV0O1xcbiAgICAgICAgICBzdG9yYWdlMC5zZXRJdGVtKFxcXCJ1aV9jb25maWdcXFwiLCB1aV9jb25maWcpO1xcbiAgICAgICAgICB1cGRhdGVJdGVtKE1ZX1JVTEUudGl0bGUgKyBcXFwiX3lpY29sXFxcIiwge1xcbiAgICAgICAgICAgIHRpdGxlOiBcXFwi5aS06YOo57uE5Lu25qC35byPOlxcXCIgKyB1aV9jb25maWcueWkuY29sXFxuICAgICAgICAgIH0pXFxuICAgICAgICB9LCB1aV9jb25maWcpXFxuICAgICAgfSwgdWlfY29uZmlnKSxcXG4gICAgICBleHRyYToge1xcbiAgICAgICAgbGluZVZpc2libGU6IGZhbHNlLFxcbiAgICAgICAgaWQ6IE1ZX1JVTEUudGl0bGUgKyBcXFwiX3lpY29sXFxcIlxcbiAgICAgIH1cXG4gICAgfSlcXG4gIH1cXG5cXG4gIGlmICh1aV9uYXZpID09IFxcXCLkuoznuqdcXFwiKSB7XFxuICAgIGQucHVzaCh7XFxuICAgICAgdGl0bGU6IFxcXCLmr4/pobXmlbDph49cXFwiLFxcbiAgICAgIGRlc2M6IFxcXCIw5YiZ6KGo56S65LiN5YiG6aG1XFxcIixcXG4gICAgICBjb2xfdHlwZTogXFxcImlucHV0XFxcIixcXG4gICAgICB1cmw6ICQudG9TdHJpbmcoKHVpX2NvbmZpZykgPT4ge1xcbiAgICA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5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQgY2hhciA9IHZhbHVlW2ldO1xcbiAgICAgICAgICAgICAgICBpZiAoZXNjYXBlKSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSBmYWxzZTtcXG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGFyID09PSAnXFxcXFxcXFwnKSB7XFxuICAgICAgICAgICAgICAgICAgICBlc2NhcGUgPSB0cnVlO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICcuJyAmJiAhaW5CcmFja2V0cykge1xcbiAgICAgICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudCA9ICcnO1xcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoYXIgPT09ICdbJykge1xcbiAgICAgICAgICAgICAgICAgICAgaW5CcmFja2V0cyA9IHRydWU7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2hhciA9PT0gJ10nKSB7XFxuICAgICAgICAgICAgICAgICAgICBpbkJyYWNrZXRzID0gZmFsc2U7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgICAgICAgICBjdXJyZW50ICs9IGNoYXI7XFxuICAgICAgICAgICAgICAgIH1cXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKGN1cnJlbnQpIHtcXG4gICAgICAgICAgICAgICAgcGF0aC5wdXNoKGN1cnJlbnQpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gcGF0aDtcXG4gICAgICAgIH1cXG5cXG4gICAgICAgIGZ1bmN0aW9uIGdldEpzb24ob2JqLCBwYXRoKSB7XFxuICAgICAgICAgICAgaWYgKCFvYmogfHwgIUFycmF5LmlzQXJyYXkocGF0aCkpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICB9XFxuICAgICAgICAgICAgaWYgKHBhdGgubGVuZ3RoID09PSAwKSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBvYmo7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgICAgIGxldCBjdXJyZW50ID0gb2JqO1xcbiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgcGF0aC5sZW5ndGg7IGkrKykge1xcbiAgICAgICAgICAgICAgICBsZXQga2V5ID0gcGF0aFtpXTtcXG4gICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQgPT09IG51bGwgfHwgY3VycmVudCA9PT0gdW5kZWZpbmVkIHx8IHR5cGVvZiBjdXJyZW50ICE9PSAnb2JqZWN0Jykge1xcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcXG4gICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICBjdXJyZW50ID0gY3VycmVudFtrZXldO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXR1cm4gY3VycmVudDtcXG4gICAgICAgIH1cXG4gICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgbGV0IHJ1blR5cGUgPSBNWV9QQVJBTVMucnVuVHlwZVswXTtcXG4gICAgICAgICAgICBsZXQgdXJsID0gZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMudXJsWzBdKSk7XFxuICAgICAgICAgICAgaWYgKHJ1blR5cGUgPT0gXFxcIkpTT05cXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJhbSA9IEpTT04ucGFyc2UoZGVjb2RlVVJJQ29tcG9uZW50KGJhc2U2NERlY29kZShNWV9QQVJBTVMucGFyYW1bMF0pKSk7XFxuICAgICAgICAgICAgICAgIGxldCBqc29uID0gSlNPTi5wYXJzZShyZXF1ZXN0KHVybCwge1xcbiAgICAgICAgICAgICAgICAgICAgaGVhZGVyczogcGFyYW0uaGVhZGVycyB8fCB7fSxcXG4gICAgICAgICAgICAgICAgICAgIG1ldGhvZDogcGFyYW0ubWV0aG9kIHx8IHZvaWQgMFxcbiAgICAgICAgICAgICAgICB9KSk7XFxuICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICBzdGF0dXNDb2RlOiAzMDIsXFxuICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiBPYmplY3QuYXNzaWduKHt9LCBwYXJhbS5oZWFkZXJzIHx8IHt9LCB7XFxuICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogZ2V0SnNvbihqc29uLCB0b1BhdGgocGFyYW0uanNvblBhdGgpKSxcXG4gICAgICAgICAgICAgICAgICAgIH0pXFxuICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocnVuVHlwZSA9PSBcXFwiSlNcXFwiKSB7XFxuXFxuICAgICAgICAgICAgICAgIGxldCBwYXJzZTtcXG4gICAgICAgICAgICAgICAgaWYgKE1ZX1BBUkFNUy5pbmRleCkge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSAkLnJlcXVpcmUoXFxcImNvbmZpZ3M/cnVsZT1cXFwiICsgdGl0bGUpLmdldEpzb24oKVtNWV9QQVJBTVMuaW5kZXhbMF1dO1xcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgICAgICAgICAgcGFyc2UgPSBKU09OLnBhcnNlKGJhc2U2NERlY29kZShkZWNvZGVVUklDb21wb25lbnQoTVlfUEFSQU1TLnBhcmFtWzBdKSkpO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgICAgIGxldCByZXMgPSBuZXcgRnVuY3Rpb24oXFxcInVybFxcXCIsIFxcXCJzZWxmXFxcIiwgcGFyc2UuanMpKHVybCwgcGFyc2UpO1xcbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcyA9PT0gXFxcInN0cmluZ1xcXCIpIHtcXG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzQ29kZTogMzAyLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnM6IHtcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXFxcIkxvY2F0aW9uXFxcIjogcmVzXFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgICAgICAgfSk7XFxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoJC50eXBlKHJlcykgPT09IFxcXCJvYmplY3RcXFwiKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0NvZGU6IDMwMixcXG4gICAgICAgICAgICAgICAgICAgICAgICBoZWFkZXJzOiByZXNcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfSBjYXRjaCAoZSkge1xcbiAgICAgICAgICAgIGxvZyhlLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuXFxuICAgIGZ1bmN0aW9uIGRvSnMoTVlfUEFSQU1TLCB0aXRsZSwgZ2tleSkge1xcbiAgICAgICAgbGV0IHtcXG4gICAgICAgICAgICBHTVxcbiAgICAgICAgfSA9ICQucmVxdWlyZShcXFwiaHR0cDovL2hpa2VyLm5va2lhLnByZXNzL2hpa2VydWxlL3J1bGVsaXN0Lmpzb24/aWQ9NjkxNiZhdXRoPTFkMzVlOGYwLTIyZTgtNTI3MC1hOWQxLTgyNmY1M2YxNzdhZFxcXCIpO1xcbiAgICAgICAgR00uc2V0U2VsZktleShna2V5KTtcXG4gICAgICAgIG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2VyOi8vYXNzZXRzL2NyeXB0by1qYXZhLmpzXFxcIik7XFxuICAgICAgICAgICAgZGF0YSA9IENyeXB0b1V0aWwuRGF0YS5wYXJzZUJhc2U2NChkYXRhKS50b0J5dGVzKCk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4ge1xcbiAgICAgICAgICAgIHN0YXR1c0NvZGU6IGNvZGUsXFxuICAgICAgICAgICAgYm9keTogZGF0YSxcXG4gICAgICAgICAgICBoZWFkZXJzOiBoZWFkZXJzLFxcbiAgICAgICAgfTtcXG4gICAgfVxcblxcbiAgICBmdW5jdGlvbiBlbnRyYW5jZShNWV9QQVJBTVMsIHRpdGxlLCBna2V5KSB7XFxuICAgICAgICBpZiAoTVlfUEFSQU1TLmRvICYmIE1ZX1BBUkFNUy5kb1swXSA9PT0gXFxcImpzXFxcIikge1xcbiAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgIHJldHVybiBkb0pzKE1ZX1BBUkFNUywgdGl0bGUsIGdrZXkpO1xcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcXG4gICAgICAgICAgICAgICAgbG9nKGUudG9TdHJpbmcoKSk7XFxuICAgICAgICAgICAgICAgIHJldHVybjtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIHJldHVybiBwYXJzZVZpZGVvKE1ZX1BBUkFNUywgdGl0bGUpO1xcbiAgICAgICAgfVxcbiAgICB9XFxuICAgIHRoaXMuZW50cmFuY2UgPSBlbnRyYW5jZTtcXG59XFxuXFxuZnVuY3Rpb24gc3RhcnRQcm94eSh0aXRsZSwgZ2tleSkge1xcbiAgICByZXR1cm4gc3RhcnRQcm94eVNlcnZlcigkLnRvU3RyaW5nKChwcm94eSwgdGl0bGUsIGdrZXkpID0+IHtcXG4gICAgICAgIHJldHVybiBuZXcgcHJveHkoKS5lbnRyYW5jZShNWV9QQVJBTVMsIHRpdGxlLCBna2V5KTtcXG4gICAgfSwg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QgZW50cmllcyA9IE9iamVjdC5lbnRyaWVzKGl0ZW0pO1xcbiAgICAgICAgICAgIGNvbnN0IHByb2Nlc3NlZEVudHJpZXMgPSBlbnRyaWVzLm1hcCgoW2tleSwgdmFsdWVdKSA9PiB7XFxuICAgICAgICAgICAgICAvLyDlpoLmnpzmnInph43lkb3lkI3lm57osIPlh73mlbDvvIzliJnosIPnlKjlroNcXG4gICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVuYW1lQ2FsbGJhY2sgPT09ICdmdW5jdGlvbicpIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIFtyZW5hbWVDYWxsYmFjayhrZXksIHZhbHVlKSwgdmFsdWVdO1xcbiAgICAgICAgICAgICAgfVxcbiAgICAgICAgICAgICAgcmV0dXJuIFtrZXksIHZhbHVlXTtcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICBjb25zdCBmaWx0ZXJlZEVudHJpZXMgPSBzaG91bGRFeGNsdWRlID9cXG4gICAgICAgICAgICAgIHByb2Nlc3NlZEVudHJpZXMuZmlsdGVyKChba2V5XSkgPT4gIWtleXNUb0hhbmRsZS5pbmNsdWRlcyhrZXkpKSA6XFxuICAgICAgICAgICAgICBwcm9jZXNzZWRFbnRyaWVzLmZpbHRlcigoW2tleV0pID0+IGtleXNUb0hhbmRsZS5pbmNsdWRlcyhrZXkpKTtcXG4gICAgICAgICAgICByZXR1cm4gT2JqZWN0LmZyb21FbnRyaWVzKGZpbHRlcmVkRW50cmllcyk7XFxuICAgICAgICAgIH0gZWxzZSB7XFxuICAgICAgICAgICAgLy8g5aaC5p6c5YWD57Sg5LiN5piv5a+56LGh5oiW5pWw57uE77yM55u05o6l6L+U5ZueXFxuICAgICAgICAgICAgcmV0dXJuIGl0ZW07XFxuICAgICAgICAgIH1cXG4gICAgICAgIH0pO1xcbiAgICAgIH0sXFxuICAgICAgZW51bWVyYWJsZTogZmFsc2UsIC8vIOiuvue9ruS4uuS4jeWPr+aemuS4vlxcbiAgICB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vcHRpbWl6Ze+8muWcqOmAiea6kOeVjOmdouWIt+aWsOmFjee9ruWQjuS8muWQjOatpeabtOaWsOaVsOmHj+aYvuekuuOAglxcXCIsXFxuICAgIF1cXG59LCB7XFxuICAgIHRpdGxlOiBcXFwiMjAyNC8wNi8xMCAgTWF4VmVyc2lvbiAyNVxcXCIsXFxuICAgIHJlY29yZHM6IFtcXG4gICAgICAgIFxcXCLigJjigJhuZXfigJnigJnvvJrlop7liqDmm7TmlrDml6Xlv5fjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAmOKAmG5ld+KAmeKAme+8mumAiea6kOmVv+aMieiPnOWNle+8jOWinuWKoOi3s+i9rOe9kemhte+8jOafpeeci+a6kOeggeOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN57yW6L6R6Kej5p6Q55WM6Z2i5rWL6K+VanPop6PmnpDkuIDnm7TlpLHotKXjgIJcXFwiLFxcbiAgICAgICAgXFxcIuKAnOKAnGZpeOKAneKAne+8muS/ruWkjWdpdGh1YuiuoumYhe+8jOS8muWIoOmZpOWFqOmDqOinhOWImeaWh+S7tuOAglxcXCIsXFxuICAgICAgICBcXFwi4oCc4oCcZml44oCd4oCd77ya5L+u5aSN6Kej5p6Q6LCD55So5aSx6LSl44CCXFxcIixcXG4gICAgICAgIFxcXCLigJzigJxmaXjigJ3igJ3vvJrkv67lpI3mm7TmjaLphY3nva7ml7bmsqHmnInlj4rml7bmuIXnqbpkcnB557yT5a2Y44CCXFxcIixcXG4gICAgICAgIFxcXCJvcHRpbWl6Ze+8muabtOaUueiuoumYheabtOaWsOetlueVpe+8jOS8muWIoOmZpOacrOWcsOWkseaViOa6kOOAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrmm7TmlrBkcnB5Mi5qc+OAglxcXCIsXFxuICAgICAgICBcXFwib3B0aW1pemXvvJrkvJjljJbop6PmnpBmbGFn5Yy56YWN44CCXFxcIixcXG5cXG4gICAgXVx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ge1xcbiAgICAgICAgdGhpcy5jYWNoZUNsYXNzID0gbnVsbDtcXG4gICAgICAgIGxldCBkYXRhID0gdGhpcy5nZXRIb21lRGF0YSgpO1xcbiAgICAgICAgdGhpcy5ydWxlLuexu+WeiyA9IGRhdGEudHlwZSB8fCBcXFwi5b2x6KeGXFxcIjtcXG4gICAgICAgIGlmKEFycmF5LmlzQXJyYXkoZGF0YS5saXN0KSYmZGF0YS5saXN0Lmxlbmd0aD09PTEmJmRhdGEubGlzdFswXS52b2RfbmFtZT09PVxcXCLmtYvor5VcXFwiKXtcXG4gICAgICAgICAgICBkZWxldGUgdGhpcy5ydWxlLuaOqOiNkDtcXG4gICAgICAgICAgICBkYXRhLmxpc3Q9W107XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIGdldEhvbWVEYXRhKCkge1xcbiAgICAgICAgaWYgKHRoaXMuY2FjaGVDbGFzcykgcmV0dXJuIHRoaXMuY2FjaGVDbGFzcztcXG4gICAgICAgIGxldCBob21lID0gSlNPTi5wYXJzZShmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGV4dGVuZDogdGhpcy5leHQsXFxuICAgICAgICAgICAgZmlsdGVyOiBcXFwidHJ1ZVxcXCJcXG4gICAgICAgIH0pKSk7XFxuICAgICAgICB0aGlzLmNhY2hlQ2xhc3MgPSBob21lO1xcbiAgICAgICAgXFxuICAgICAgICByZXR1cm4gaG9tZTtcXG4gICAgfSxcXG4gICAgaG9tZVZvZCgpIHtcXG4gICAgICAgIC8qaWYodGhpcy52b2RDb3VudCl7XFxuICAgICAgICAgICAgdGhpcy5pbml0KCk7XFxuICAgICAgICB9Ki9cXG4gICAgICAgIGxldCBkYXRhID0gdGhpcy5nZXRIb21lRGF0YSgpO1xcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICBsaXN0OiAgZGF0YS5saXN0IHx8IFtdXFxuICAgICAgICB9KTtcXG4gICAgICAgIH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4gICAgICAgIGxldCBkYXRhID0gdGhpcy5nZXRIb21lRGF0YSgpO1xcbiAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGRhdGEubGlzdCkgfHwgIWRhdGEubGlzdC5sZW5ndGgpIHtcXG4gICAgICAgICAgICBkZWxldGUgdGhpcy5ydWxlLuaOqOiNkDtcXG4gICAgICAgICAgICBkYXRhLmxpc3QgPSBbXTtcXG4gICAgICAgIH1cXG4gICAgfSxcXG4gICAgZ2V0SG9tZURhdGEoKSB7XFxuICAgICAgICBpZiAodGhpcy5jYWNoZUNsYXNzKSByZXR1cm4gdGhpcy5jYWNoZUNsYXNzO1xcbiAgICAgICAgbGV0IHhtbCA9IGZldGNoKGJ1aWxkVXJsKHRoaXMuYXBpLCB7XFxuICAgICAgICAgICAgYWM6IFxcXCJjbGFzc1xcXCJcXG4gICAgICAgIH0pKS5yZXBsYWNlKC9cXFxcPC4qP3htbC4qP1xcXFw+LywgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IGhvbWUgPSB7XFxuICAgICAgICAgICAgbGlzdDogW10sXFxuICAgICAgICAgICAgY2xhc3M6IFtdXFxuICAgICAgICB9O1xcbiAgICAgICAgbGV0IGhvbWVYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmxpc3QudmlkZW8pIHtcXG4gICAgICAgICAgICBob21lLmxpc3QucHVzaCh7XFxuICAgICAgICAgICAgICAgIHZvZF9pZDogaXRlbS5pZC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfbmFtZTogaXRlbS5uYW1lLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF90aW1lOiBpdGVtLmxhc3QudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdHlwZV9pZDogaXRlbS50aWQudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3JlbWFya3M6IGl0ZW0ubm90ZS50b1N0cmluZygpXFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmNsYXNzLnR5KSB7XFxuICAgICAgICAgICAgaG9tZS5jbGFzcy5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdHlwZV9pZDogaXRlbS5AaWQsXFxuICAgICAgICAgICAgICAgIHR5cGVfbmFtZTogaXRlbS50b1N0cmluZygpLFxcblxcbiAgICAgICAgICAgIH0pO1xcbiAgICAgICAgfVxcbiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaG9tZS5jbGFzcykgJiYgQXJyYXkuaXNBcnJheSh0aGlzLmNhdGVnb3J5ZmlsdGVyKSkge1xcbiAgICAgICAgICAgIGhvbWUuY2xhc3MgPSBob21lLmNsYXNzLmZpbHRlcih2ID0+IHRoaXMuY2F0ZWdvcnlmaWx0ZXIuaW5jbHVkZXModi50eXBlX25hbWUpKVxcbiAgICAgICAgfVxcblxcbiAgICAgICAgdGhpcy5jYWNoZUNsYXNzID0gaG9tZTtcXG5cXG4gICAgICAgIHJldHVybiBob21lO1xcbiAgICB9LFxcbiAgICBob21lVm9kKCkge1xcbiAgICAgICAgbGV0IGRhdGEgPSB0aGlzLmdldEhvbWVEYXRhKCk7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3Q6IGRhdGEubGlzdCB8fCBbXVxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGhvbWUoKSB7XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkodGhpcy5nZXRIb21lRGF0YSgpKTtcXG4gICAgfSxcXG4gICAgY2F0ZWdvcnkodGlkLCBwZywgZmlsdGVyLCBleHRlbmQpIHtcXG4gICAgICAgIGxldCB4bWwgPSBmZXRjaChidWlsZFVybCh0aGlzLmFwaSwge1xcbiAgICAgICAgICAgIGFjOiBcXFwidmlkZW9saXN0XFxcIixcXG4gICAgICAgICAgICB0OiB0aWQsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKS5yZXBsYWNlKC9cXFxcPC4qP3htbC4qP1xcXFw+LywgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IGhvbWVYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBsZXQgbGlzdCA9IFtdO1xcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0gaW4gaG9tZVhtbC5saXN0LnZpZGVvKSB7XFxuICAgICAgICAgICAgbGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcGljOiBpdGVtLnBpYy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKClcXG4gICAgICAgICAgICB9KTtcXG4gICAgICAgIH1cXG4gICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgbGlzdFxcbiAgICAgICAgfSk7XFxuICAgIH0sXFxuICAgIGRldGFpbCh2b2RfdXJsKSB7XFxuICAgICAgICBsZXQgeG1sID0gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgaWRzOiB2b2RfdXJsLFxcbiAgICAgICAgfSkpLnJlcGxhY2UoL1xcXFw8Lio/eG1sLio/XFxcXD4vLCBcXFwiXFxcIik7XFxuICAgICAgICBsZXQgaG9tZVhtbCA9IG5ldyBYTUwoeG1sKTtcXG4gICAgICAgIGxldCBsaXN0ID0gW107XFxuICAgICAgICBmb3IgZWFjaChsZXQgaXRlbSBpbiBob21lWG1sLmxpc3QudmlkZW8pIHtcXG4gICAgICAgICAgICBsZXQgcmVzaXRlbSA9IHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcGljOiBpdGVtLnBpYy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9jb250ZW50OiBpdGVtLmRlcy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfYWN0b3I6IGl0ZW0uYWN0b3IudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX2RpcmVjdG9yOiBpdGVtLmRpcmVjdG9yLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgfTtcXG4gICAgICAgICAgICBsZXQgZnJvbSA9IFtdO1xcbiAgICAgICAgICAgIGxldCBwbGF5ID0gW107XFxuICAgICAgICAgICAgZm9yIGVhY2gobGV0IHBsYXlMaXN0SXRlbSBpbiBpdGVtLmRsLmRkKSB7XFxuICAgICAgICAgICAgICAgIGZyb20ucHVzaChwbGF5TGlzdEl0ZW0uQGZsYWcpO1xcbiAgICAgICAgICAgICAgICBwbGF5LnB1c2gocGxheUxpc3RJdGVtLnRvU3RyaW5nKCkpO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgICAgICByZXNpdGVtLnZvZF9wbGF5X2Zyb20gPSBmcm9tLmpvaW4oXFxcIiQkJFxcXCIpO1xcbiAgICAgICAgICAgIHJlc2l0ZW0udm9kX3BsYXlfdXJsID0gcGxheS5qb2luKFxcXCIkJCRcXFwiKTtcXG4gICAgICAgICAgICBsaXN0LnB1c2gocmVzaXRlbSk7XFxuICAgICAgICB9XFxuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgIGxpc3RcXG4gICAgICAgIH0pO1xcbiAgICB9LFxcbiAgICBwbGF5KGZsYWcsIGlucHV0KSB7XFxuICAgICAgICBsZXQgcGFyc2VfdXJsID0gdGhpcy5zb3VyY2UucGxheXVybCB8fCBcXFwiXFxcIjtcXG4gICAgICAgIGlmICgvXFxcXC4obTN1OHxtcDQpLy50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICB1cmw6IGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChwYXJzZV91cmwuc3RhcnRzV2l0aCgnanNvbjonKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgcHVybCA9IHBhcnNlX3VybC5yZXBsYWNlKCdqc29uOicsICcnKSArIGlucHV0O1xcbiAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QocHVybCk7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogSlNPTi5wYXJzZShodG1sKS51cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBwYXJzZV91cmwgKyBpbnB1dFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNlYXJjaCh3ZCwgcXVpY2ssIHBnKSB7XFxuICAgICAgICBsZXQgeG1sID0gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICB3ZDogd2QsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKS5yZXBsYWNlKC9cXFxcPC4qP3htbC4qP1xcXFw+LywgXFxcIlxcXCIpO1xcbiAgICAgICAgbGV0IGhvbWVYbWwgPSBuZXcgWE1MKHhtbCk7XFxuICAgICAgICBsZXQgbGlzdCA9IFtdO1xcbiAgICAgICAgZm9yIGVhY2gobGV0IGl0ZW0gaW4gaG9tZVhtbC5saXN0LnZpZGVvKSB7XFxuICAgICAgICAgICAgbGlzdC5wdXNoKHtcXG4gICAgICAgICAgICAgICAgdm9kX2lkOiBpdGVtLmlkLnRvU3RyaW5nKCksXFxuICAgICAgICAgICAgICAgIHZvZF9uYW1lOiBpdGVtLm5hbWUudG9TdHJpbmcoKSxcXG4gICAgICAgICAgICAgICAgdm9kX3RpbWU6IGl0ZW0ubGFzdC50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcGljOiBpdGVtLnBpYy50b1N0cmluZygpLFxcbiAgICAgICAgICAgICAgICB2b2RfcmVtYXJrczogaXRlbS5ub3RlLnRvU3RyaW5nKClcXG4gICAgICAg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Z2V0SG9tZURhdGEoKSk7XFxuICAgIH0sXFxuICAgIGNhdGVnb3J5KHRpZCwgcGcsIGZpbHRlciwgZXh0ZW5kKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcInZpZGVvbGlzdFxcXCIsXFxuICAgICAgICAgICAgdDogdGlkLFxcbiAgICAgICAgICAgIHBnOiBcXFwiXFxcIiArIHBnXFxuICAgICAgICB9KSk7XFxuICAgIH0sXFxuICAgIGRldGFpbCh2b2RfdXJsKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICBhYzogXFxcImRldGFpbFxcXCIsXFxuICAgICAgICAgICAgaWRzOiB2b2RfdXJsLFxcbiAgICAgICAgfSkpO1xcbiAgICB9LFxcbiAgICBwbGF5KGZsYWcsIGlucHV0KSB7XFxuICAgICAgICBsZXQgcGFyc2VfdXJsID0gdGhpcy5zb3VyY2UucGxheXVybCB8fCBcXFwiXFxcIjtcXG4gICAgICAgIGlmICgvXFxcXC4obTN1OHxtcDQpLy50ZXN0KGlucHV0KSkge1xcbiAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeSh7XFxuICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICB1cmw6IGlucHV0XFxuICAgICAgICAgICAgfSk7XFxuICAgICAgICB9IGVsc2Uge1xcbiAgICAgICAgICAgIGlmIChwYXJzZV91cmwuc3RhcnRzV2l0aCgnanNvbjonKSkge1xcbiAgICAgICAgICAgICAgICBsZXQgcHVybCA9IHBhcnNlX3VybC5yZXBsYWNlKCdqc29uOicsICcnKSArIGlucHV0O1xcbiAgICAgICAgICAgICAgICBsZXQgaHRtbCA9IHJlcXVlc3QocHVybCk7XFxuICAgICAgICAgICAgICAgIHRyeSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAwLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogSlNPTi5wYXJzZShodG1sKS51cmxcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XFxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkoe1xcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogaW5wdXRcXG4gICAgICAgICAgICAgICAgICAgIH0pO1xcbiAgICAgICAgICAgICAgICB9XFxuICAgICAgICAgICAgfSBlbHNlIHtcXG4gICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHtcXG4gICAgICAgICAgICAgICAgICAgIHBhcnNlOiAxLFxcbiAgICAgICAgICAgICAgICAgICAgdXJsOiBwYXJzZV91cmwgKyBpbnB1dFxcbiAgICAgICAgICAgICAgICB9KTtcXG4gICAgICAgICAgICB9XFxuICAgICAgICB9XFxuICAgIH0sXFxuICAgIHNlYXJjaCh3ZCwgcXVpY2ssIHBnKSB7XFxuICAgICAgICByZXR1cm4gZmV0Y2goYnVpbGRVcmwodGhpcy5hcGksIHtcXG4gICAgICAgICAgICB3ZDogd2QsXFxuICAgICAgICAgICAgcGc6IFxcXCJcXFwiICsgcGdcXG4gICAgICAgIH0pKTtcXG4gICAgfSxcXG4gICAgZ2V0UnVsZShrZXkpIHtcXG4gICAgICAgIHJldHVybiBrZXkgPyB0aGlzLnJ1bGVba2V5XSA6IHRoaXMucnVsZTtcXG4gICAgfSxcXG4gICAgcnVuTWFpbigpIHtcXG4gICAgICAgIHJldHVybiBcXFwiXFxcIjtcXG4gICAgfVxcbn0pO1xcbiQuZXhwb3J0cyA9IFQxQWRhcHRlcjtcIn1dIiwiaWNvbiI6IiIsInByb3h5IjoiIn0=
Add Comment
Please, Sign In to add comment